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