1 /* 2 * Copyright (C) 2011 The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17 #ifndef ANDROID_HARDWARE_ICAMERA_RECORDING_PROXY_H 18 #define ANDROID_HARDWARE_ICAMERA_RECORDING_PROXY_H 19 20 #include <vector> 21 #include <binder/IInterface.h> 22 #include <cutils/native_handle.h> 23 #include <utils/RefBase.h> 24 25 namespace android { 26 27 class Parcel; 28 29 /* 30 * The purpose of ICameraRecordingProxy is to 31 * allow applications to use the camera during recording with the old camera API. 32 * 33 * Camera service allows only one client at a time. Since camcorder application 34 * needs to own the camera to do things like zoom, the media recorder cannot 35 * access the camera directly during recording. So ICameraRecordingProxy is a 36 * proxy of ICamera, which allows the media recorder to start/stop the recording 37 * and release recording frames. ICameraRecordingProxyListener is an interface 38 * that allows the recorder to receive video frames during recording. 39 * 40 * ICameraRecordingProxy 41 * startRecording() 42 * stopRecording() 43 * 44 * The camcorder app opens the camera and starts the preview. The app passes 45 * ICamera and ICameraRecordingProxy to the media recorder by 46 * MediaRecorder::setCamera(). The recorder uses ICamera to setup the camera in 47 * MediaRecorder::start(). After setup, the recorder disconnects from camera 48 * service. The recorder calls ICameraRecordingProxy::startRecording() and The 49 * app owns the camera and can do things like zoom. The media recorder receives 50 * the video frames via a buffer queue. The recorder calls 51 * ICameraRecordingProxy::stopRecording() to stop the recording. 52 * 53 * The call sequences are as follows: 54 * 1. The app: Camera.unlock(). 55 * 2. The app: MediaRecorder.setCamera(). 56 * 3. Start recording 57 * (1) The app: MediaRecorder.start(). 58 * (2) The recorder: ICamera.setVideoTarget(buffer queue). 59 * (3) The recorder: ICamera.unlock() and ICamera.disconnect(). 60 * (4) The recorder: ICameraRecordingProxy.startRecording(). 61 * (5) The app: ICamera.reconnect(). 62 * (6) The app: ICamera.startRecording(). 63 * 4. During recording 64 * (1) The recorder: receive frames via a buffer queue 65 * (2) The recorder: release frames via a buffer queue 66 * 5. Stop recording 67 * (1) The app: MediaRecorder.stop() 68 * (2) The recorder: ICameraRecordingProxy.stopRecording(). 69 * (3) The app: ICamera.stopRecording(). 70 */ 71 72 class ICameraRecordingProxy: public IInterface 73 { 74 public: 75 DECLARE_META_INTERFACE(CameraRecordingProxy); 76 77 virtual status_t startRecording() = 0; 78 virtual void stopRecording() = 0; 79 }; 80 81 // ---------------------------------------------------------------------------- 82 83 class BnCameraRecordingProxy: public BnInterface<ICameraRecordingProxy> 84 { 85 public: 86 virtual status_t onTransact( uint32_t code, 87 const Parcel& data, 88 Parcel* reply, 89 uint32_t flags = 0); 90 }; 91 92 }; // namespace android 93 94 #endif 95