2 * Copyright (C) 2011 The Android Open Source Project
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
8 * http://www.apache.org/licenses/LICENSE-2.0
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.
17 #ifndef ANDROID_HARDWARE_ICAMERA_RECORDING_PROXY_H
18 #define ANDROID_HARDWARE_ICAMERA_RECORDING_PROXY_H
20 #include <binder/IInterface.h>
21 #include <utils/RefBase.h>
25 class ICameraRecordingProxyListener;
30 * The purpose of ICameraRecordingProxy and ICameraRecordingProxyListener is to
31 * allow applications using the camera during recording.
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.
40 * ICameraRecordingProxy
43 * releaseRecordingFrame()
45 * ICameraRecordingProxyListener
46 * dataCallbackTimestamp()
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
60 * The call sequences are as follows:
61 * 1. The app: Camera.unlock().
62 * 2. The app: MediaRecorder.setCamera().
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().
70 * (1) The recorder: receive frames from ICameraRecordingProxyListener.dataCallbackTimestamp()
71 * (2) The recorder: release frames by ICameraRecordingProxy.releaseRecordingFrame().
73 * (1) The app: MediaRecorder.stop()
74 * (2) The recorder: ICameraRecordingProxy.stopRecording().
75 * (3) The app: ICamera.stopRecording().
78 class ICameraRecordingProxy: public IInterface
81 DECLARE_META_INTERFACE(CameraRecordingProxy);
83 virtual status_t startRecording(const sp<ICameraRecordingProxyListener>& listener) = 0;
84 virtual void stopRecording() = 0;
85 virtual void releaseRecordingFrame(const sp<IMemory>& mem) = 0;
88 // ----------------------------------------------------------------------------
90 class BnCameraRecordingProxy: public BnInterface<ICameraRecordingProxy>
93 virtual status_t onTransact( uint32_t code,
99 }; // namespace android