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