Mathias Agopian | 3cf6135 | 2010-02-09 17:46:37 -0800 | [diff] [blame] | 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> |
Mathias Agopian | 3cf6135 | 2010-02-09 17:46:37 -0800 | [diff] [blame] | 23 | #include <binder/IMemory.h> |
| 24 | #include <utils/String8.h> |
| 25 | #include <camera/Camera.h> |
| 26 | |
| 27 | namespace android { |
| 28 | |
| 29 | class ICameraClient; |
Andy McFadden | 8ba0102 | 2012-12-18 09:46:54 -0800 | [diff] [blame] | 30 | class IGraphicBufferProducer; |
Mathias Agopian | df712ea | 2012-02-25 18:48:35 -0800 | [diff] [blame] | 31 | class Surface; |
Mathias Agopian | 3cf6135 | 2010-02-09 17:46:37 -0800 | [diff] [blame] | 32 | |
| 33 | class ICamera: public IInterface |
| 34 | { |
Igor Murashkin | bef3f23 | 2013-05-30 17:47:38 -0700 | [diff] [blame] | 35 | /** |
| 36 | * Keep up-to-date with ICamera.aidl in frameworks/base |
| 37 | */ |
Mathias Agopian | 3cf6135 | 2010-02-09 17:46:37 -0800 | [diff] [blame] | 38 | public: |
| 39 | DECLARE_META_INTERFACE(Camera); |
| 40 | |
| 41 | virtual void disconnect() = 0; |
| 42 | |
| 43 | // connect new client with existing camera remote |
| 44 | virtual status_t connect(const sp<ICameraClient>& client) = 0; |
| 45 | |
| 46 | // prevent other processes from using this ICamera interface |
| 47 | virtual status_t lock() = 0; |
| 48 | |
| 49 | // allow other processes to use this ICamera interface |
| 50 | virtual status_t unlock() = 0; |
| 51 | |
Andy McFadden | 8ba0102 | 2012-12-18 09:46:54 -0800 | [diff] [blame] | 52 | // pass the buffered IGraphicBufferProducer to the camera service |
Eino-Ville Talvala | 1ce7c34 | 2013-08-21 13:57:21 -0700 | [diff] [blame^] | 53 | virtual status_t setPreviewTarget( |
Andy McFadden | 8ba0102 | 2012-12-18 09:46:54 -0800 | [diff] [blame] | 54 | const sp<IGraphicBufferProducer>& bufferProducer) = 0; |
Jamie Gennis | bfa33aa | 2010-12-20 11:51:31 -0800 | [diff] [blame] | 55 | |
Mathias Agopian | 3cf6135 | 2010-02-09 17:46:37 -0800 | [diff] [blame] | 56 | // set the preview callback flag to affect how the received frames from |
Eino-Ville Talvala | 3ee3550 | 2013-04-02 15:45:11 -0700 | [diff] [blame] | 57 | // preview are handled. Enabling preview callback flags disables any active |
| 58 | // preview callback surface set by setPreviewCallbackTarget(). |
Mathias Agopian | 3cf6135 | 2010-02-09 17:46:37 -0800 | [diff] [blame] | 59 | virtual void setPreviewCallbackFlag(int flag) = 0; |
Eino-Ville Talvala | 3ee3550 | 2013-04-02 15:45:11 -0700 | [diff] [blame] | 60 | // set a buffer interface to use for client-received preview frames instead |
| 61 | // of preview callback buffers. Passing a valid interface here disables any |
| 62 | // active preview callbacks set by setPreviewCallbackFlag(). Passing NULL |
| 63 | // disables the use of the callback target. |
| 64 | virtual status_t setPreviewCallbackTarget( |
| 65 | const sp<IGraphicBufferProducer>& callbackProducer) = 0; |
Mathias Agopian | 3cf6135 | 2010-02-09 17:46:37 -0800 | [diff] [blame] | 66 | |
Eino-Ville Talvala | 1ce7c34 | 2013-08-21 13:57:21 -0700 | [diff] [blame^] | 67 | // start preview mode, must call setPreviewTarget first |
Mathias Agopian | 3cf6135 | 2010-02-09 17:46:37 -0800 | [diff] [blame] | 68 | virtual status_t startPreview() = 0; |
| 69 | |
| 70 | // stop preview mode |
| 71 | virtual void stopPreview() = 0; |
| 72 | |
| 73 | // get preview state |
| 74 | virtual bool previewEnabled() = 0; |
| 75 | |
| 76 | // start recording mode |
| 77 | virtual status_t startRecording() = 0; |
| 78 | |
| 79 | // stop recording mode |
James Dong | e468ac5 | 2011-02-17 16:38:06 -0800 | [diff] [blame] | 80 | virtual void stopRecording() = 0; |
Mathias Agopian | 3cf6135 | 2010-02-09 17:46:37 -0800 | [diff] [blame] | 81 | |
| 82 | // get recording state |
| 83 | virtual bool recordingEnabled() = 0; |
| 84 | |
| 85 | // release a recording frame |
| 86 | virtual void releaseRecordingFrame(const sp<IMemory>& mem) = 0; |
| 87 | |
| 88 | // auto focus |
| 89 | virtual status_t autoFocus() = 0; |
| 90 | |
| 91 | // cancel auto focus |
| 92 | virtual status_t cancelAutoFocus() = 0; |
| 93 | |
James Dong | e468ac5 | 2011-02-17 16:38:06 -0800 | [diff] [blame] | 94 | /* |
| 95 | * take a picture. |
| 96 | * @param msgType the message type an application selectively turn on/off |
| 97 | * on a photo-by-photo basis. The supported message types are: |
| 98 | * CAMERA_MSG_SHUTTER, CAMERA_MSG_RAW_IMAGE, CAMERA_MSG_COMPRESSED_IMAGE, |
| 99 | * and CAMERA_MSG_POSTVIEW_FRAME. Any other message types will be ignored. |
| 100 | */ |
| 101 | virtual status_t takePicture(int msgType) = 0; |
Mathias Agopian | 3cf6135 | 2010-02-09 17:46:37 -0800 | [diff] [blame] | 102 | |
| 103 | // set preview/capture parameters - key/value pairs |
| 104 | virtual status_t setParameters(const String8& params) = 0; |
| 105 | |
| 106 | // get preview/capture parameters - key/value pairs |
| 107 | virtual String8 getParameters() const = 0; |
| 108 | |
| 109 | // send command to camera driver |
| 110 | virtual status_t sendCommand(int32_t cmd, int32_t arg1, int32_t arg2) = 0; |
James Dong | e2ad673 | 2010-10-18 20:42:51 -0700 | [diff] [blame] | 111 | |
James Dong | e2ad673 | 2010-10-18 20:42:51 -0700 | [diff] [blame] | 112 | // tell the camera hal to store meta data or real YUV data in video buffers. |
| 113 | virtual status_t storeMetaDataInBuffers(bool enabled) = 0; |
Mathias Agopian | 3cf6135 | 2010-02-09 17:46:37 -0800 | [diff] [blame] | 114 | }; |
| 115 | |
| 116 | // ---------------------------------------------------------------------------- |
| 117 | |
| 118 | class BnCamera: public BnInterface<ICamera> |
| 119 | { |
| 120 | public: |
| 121 | virtual status_t onTransact( uint32_t code, |
| 122 | const Parcel& data, |
| 123 | Parcel* reply, |
| 124 | uint32_t flags = 0); |
| 125 | }; |
| 126 | |
| 127 | }; // namespace android |
| 128 | |
| 129 | #endif |