1 /* 2 * Copyright (C) 2008 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_H 18 #define ANDROID_HARDWARE_ICAMERA_H 19 20 #include <utils/RefBase.h> 21 #include <binder/IInterface.h> 22 #include <binder/Parcel.h> 23 #include <binder/IMemory.h> 24 #include <binder/Status.h> 25 #include <gui/Flags.h> 26 #include <utils/String8.h> 27 28 namespace android { 29 30 class IGraphicBufferProducer; 31 class Surface; 32 33 namespace hardware { 34 35 class ICameraClient; 36 37 #if WB_LIBCAMERASERVICE_WITH_DEPENDENCIES 38 typedef Surface ProducerType; 39 #else 40 typedef IGraphicBufferProducer ProducerType; 41 #endif 42 43 class ICamera : public android::IInterface { 44 /** 45 * Keep up-to-date with ICamera.aidl in frameworks/base 46 */ 47 public: 48 enum { 49 // Pass real YUV data in video buffers through ICameraClient.dataCallbackTimestamp(). 50 VIDEO_BUFFER_MODE_DATA_CALLBACK_YUV = 0, 51 // Pass metadata in video buffers through ICameraClient.dataCallbackTimestamp(). 52 VIDEO_BUFFER_MODE_DATA_CALLBACK_METADATA = 1, 53 // Pass video buffers through IGraphicBufferProducer set with setVideoTarget(). 54 VIDEO_BUFFER_MODE_BUFFER_QUEUE = 2, 55 }; 56 57 DECLARE_META_INTERFACE(Camera); 58 59 virtual binder::Status disconnect() = 0; 60 61 // connect new client with existing camera remote 62 virtual status_t connect(const sp<ICameraClient>& client) = 0; 63 64 // prevent other processes from using this ICamera interface 65 virtual status_t lock() = 0; 66 67 // allow other processes to use this ICamera interface 68 virtual status_t unlock() = 0; 69 70 // pass the SurfaceType to the camera service 71 virtual status_t setPreviewTarget(const sp<SurfaceType>& bufferProducer) = 0; 72 73 // set the preview callback flag to affect how the received frames from 74 // preview are handled. Enabling preview callback flags disables any active 75 // preview callback surface set by setPreviewCallbackTarget(). 76 virtual void setPreviewCallbackFlag(int flag) = 0; 77 // set a buffer interface to use for client-received preview frames instead 78 // of preview callback buffers. Passing a valid interface here disables any 79 // active preview callbacks set by setPreviewCallbackFlag(). Passing NULL 80 // disables the use of the callback target. 81 virtual status_t setPreviewCallbackTarget(const sp<SurfaceType>& callbackProducer) = 0; 82 83 // start preview mode, must call setPreviewTarget first 84 virtual status_t startPreview() = 0; 85 86 // stop preview mode 87 virtual void stopPreview() = 0; 88 89 // get preview state 90 virtual bool previewEnabled() = 0; 91 92 // start recording mode 93 virtual status_t startRecording() = 0; 94 95 // stop recording mode 96 virtual void stopRecording() = 0; 97 98 // get recording state 99 virtual bool recordingEnabled() = 0; 100 101 // Release a recording frame that was received via ICameraClient::dataCallbackTimestamp. 102 virtual void releaseRecordingFrame(const sp<IMemory>& mem) = 0; 103 104 // Release a recording frame handle that was received via 105 // ICameraClient::recordingFrameHandleCallbackTimestamp. 106 virtual void releaseRecordingFrameHandle(native_handle_t *handle) = 0; 107 108 // Release a batch of recording frame handles that was received via 109 // ICameraClient::recordingFrameHandleCallbackTimestampBatch 110 virtual void releaseRecordingFrameHandleBatch( 111 const std::vector<native_handle_t*>& handles) = 0; 112 113 // auto focus 114 virtual status_t autoFocus() = 0; 115 116 // cancel auto focus 117 virtual status_t cancelAutoFocus() = 0; 118 119 /* 120 * take a picture. 121 * @param msgType the message type an application selectively turn on/off 122 * on a photo-by-photo basis. The supported message types are: 123 * CAMERA_MSG_SHUTTER, CAMERA_MSG_RAW_IMAGE, CAMERA_MSG_COMPRESSED_IMAGE, 124 * and CAMERA_MSG_POSTVIEW_FRAME. Any other message types will be ignored. 125 */ 126 virtual status_t takePicture(int msgType) = 0; 127 128 // set preview/capture parameters - key/value pairs 129 virtual status_t setParameters(const String8& params) = 0; 130 131 // get preview/capture parameters - key/value pairs 132 virtual String8 getParameters() const = 0; 133 134 // send command to camera driver 135 virtual status_t sendCommand(int32_t cmd, int32_t arg1, int32_t arg2) = 0; 136 137 138 // Tell camera how to pass video buffers. videoBufferMode is one of VIDEO_BUFFER_MODE_*. 139 // Returns OK if the specified video buffer mode is supported. If videoBufferMode is 140 // VIDEO_BUFFER_MODE_BUFFER_QUEUE, setVideoTarget() must be called before starting video 141 // recording. 142 virtual status_t setVideoBufferMode(int32_t videoBufferMode) = 0; 143 144 // Set the video buffer producer for camera to use in VIDEO_BUFFER_MODE_BUFFER_QUEUE mode. 145 virtual status_t setVideoTarget(const sp<SurfaceType>& bufferProducer) = 0; 146 147 // Set the audio restriction mode 148 virtual status_t setAudioRestriction(int32_t mode) = 0; 149 150 // Get the global audio restriction mode 151 virtual int32_t getGlobalAudioRestriction() = 0; 152 }; 153 154 // ---------------------------------------------------------------------------- 155 156 class BnCamera: public android::BnInterface<ICamera> 157 { 158 public: 159 virtual status_t onTransact( uint32_t code, 160 const Parcel& data, 161 Parcel* reply, 162 uint32_t flags = 0); 163 }; 164 165 } // namespace hardware 166 } // namespace android 167 168 #endif 169