/include/camera/ICameraRecordingProxy.h

http://github.com/CyanogenMod/android_frameworks_base · C++ Header · 101 lines · 26 code · 11 blank · 64 comment · 0 complexity · 5501767e4aea6462cbfe8141963522ba MD5 · raw file

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