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 <binder/IInterface.h> 21 #include <utils/RefBase.h> 22 23 namespace android { 24 25 class ICameraRecordingProxyListener; 26 class IMemory; 27 class Parcel; 28 29 /* 30 * The purpose of ICameraRecordingProxy and ICameraRecordingProxyListener is to 31 * allow applications using the camera during recording. 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 * releaseRecordingFrame() 44 * 45 * ICameraRecordingProxyListener 46 * dataCallbackTimestamp() 47 48 * The camcorder app opens the camera and starts the preview. The app passes 49 * ICamera and ICameraRecordingProxy to the media recorder by 50 * MediaRecorder::setCamera(). The recorder uses ICamera to setup the camera in 51 * MediaRecorder::start(). After setup, the recorder disconnects from camera 52 * service. The recorder calls ICameraRecordingProxy::startRecording() and 53 * passes a ICameraRecordingProxyListener to the app. The app connects back to 54 * camera service and starts the recording. The app owns the camera and can do 55 * things like zoom. The media recorder receives the video frames from the 56 * listener and releases them by ICameraRecordingProxy::releaseRecordingFrame. 57 * The recorder calls ICameraRecordingProxy::stopRecording() to stop the 58 * recording. 59 * 60 * The call sequences are as follows: 61 * 1. The app: Camera.unlock(). 62 * 2. The app: MediaRecorder.setCamera(). 63 * 3. Start recording 64 * (1) The app: MediaRecorder.start(). 65 * (2) The recorder: ICamera.unlock() and ICamera.disconnect(). 66 * (3) The recorder: ICameraRecordingProxy.startRecording(). 67 * (4) The app: ICamera.reconnect(). 68 * (5) The app: ICamera.startRecording(). 69 * 4. During recording 70 * (1) The recorder: receive frames from ICameraRecordingProxyListener.dataCallbackTimestamp() 71 * (2) The recorder: release frames by ICameraRecordingProxy.releaseRecordingFrame(). 72 * 5. Stop recording 73 * (1) The app: MediaRecorder.stop() 74 * (2) The recorder: ICameraRecordingProxy.stopRecording(). 75 * (3) The app: ICamera.stopRecording(). 76 */ 77 78 class ICameraRecordingProxy: public IInterface 79 { 80 public: 81 DECLARE_META_INTERFACE(CameraRecordingProxy); 82 83 virtual status_t startRecording(const sp<ICameraRecordingProxyListener>& listener) = 0; 84 virtual void stopRecording() = 0; 85 virtual void releaseRecordingFrame(const sp<IMemory>& mem) = 0; 86 }; 87 88 // ---------------------------------------------------------------------------- 89 90 class BnCameraRecordingProxy: public BnInterface<ICameraRecordingProxy> 91 { 92 public: 93 virtual status_t onTransact( uint32_t code, 94 const Parcel& data, 95 Parcel* reply, 96 uint32_t flags = 0); 97 }; 98 99 }; // namespace android 100 101 #endif 102