The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -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> |
Mathias Agopian | 0795272 | 2009-05-19 19:08:10 -0700 | [diff] [blame] | 21 | #include <binder/IInterface.h> |
| 22 | #include <binder/Parcel.h> |
Jamie Gennis | 85cfdd0 | 2010-08-10 16:37:53 -0700 | [diff] [blame] | 23 | #include <surfaceflinger/Surface.h> |
Mathias Agopian | 0795272 | 2009-05-19 19:08:10 -0700 | [diff] [blame] | 24 | #include <binder/IMemory.h> |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 25 | #include <utils/String8.h> |
Mathias Agopian | 000479f | 2010-02-09 17:46:37 -0800 | [diff] [blame] | 26 | #include <camera/Camera.h> |
Jamie Gennis | ff2dc46 | 2010-12-20 11:51:31 -0800 | [diff] [blame] | 27 | #include <gui/ISurfaceTexture.h> |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 28 | |
| 29 | namespace android { |
| 30 | |
| 31 | class ICameraClient; |
| 32 | |
| 33 | class ICamera: public IInterface |
| 34 | { |
| 35 | public: |
| 36 | DECLARE_META_INTERFACE(Camera); |
| 37 | |
| 38 | virtual void disconnect() = 0; |
| 39 | |
| 40 | // connect new client with existing camera remote |
| 41 | virtual status_t connect(const sp<ICameraClient>& client) = 0; |
| 42 | |
| 43 | // prevent other processes from using this ICamera interface |
| 44 | virtual status_t lock() = 0; |
| 45 | |
| 46 | // allow other processes to use this ICamera interface |
| 47 | virtual status_t unlock() = 0; |
| 48 | |
Jamie Gennis | 85cfdd0 | 2010-08-10 16:37:53 -0700 | [diff] [blame] | 49 | // pass the buffered Surface to the camera service |
| 50 | virtual status_t setPreviewDisplay(const sp<Surface>& surface) = 0; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 51 | |
Jamie Gennis | ff2dc46 | 2010-12-20 11:51:31 -0800 | [diff] [blame] | 52 | // pass the buffered ISurfaceTexture to the camera service |
| 53 | virtual status_t setPreviewTexture( |
| 54 | const sp<ISurfaceTexture>& surfaceTexture) = 0; |
| 55 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 56 | // set the preview callback flag to affect how the received frames from |
| 57 | // preview are handled. |
| 58 | virtual void setPreviewCallbackFlag(int flag) = 0; |
| 59 | |
| 60 | // start preview mode, must call setPreviewDisplay first |
| 61 | virtual status_t startPreview() = 0; |
| 62 | |
| 63 | // stop preview mode |
| 64 | virtual void stopPreview() = 0; |
| 65 | |
| 66 | // get preview state |
| 67 | virtual bool previewEnabled() = 0; |
| 68 | |
| 69 | // start recording mode |
| 70 | virtual status_t startRecording() = 0; |
| 71 | |
| 72 | // stop recording mode |
James Dong | e00cab7 | 2011-02-17 16:38:06 -0800 | [diff] [blame] | 73 | virtual void stopRecording() = 0; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 74 | |
| 75 | // get recording state |
| 76 | virtual bool recordingEnabled() = 0; |
| 77 | |
| 78 | // release a recording frame |
| 79 | virtual void releaseRecordingFrame(const sp<IMemory>& mem) = 0; |
| 80 | |
| 81 | // auto focus |
| 82 | virtual status_t autoFocus() = 0; |
| 83 | |
Chih-Chung Chang | 244f8c2 | 2009-09-15 14:51:56 +0800 | [diff] [blame] | 84 | // cancel auto focus |
| 85 | virtual status_t cancelAutoFocus() = 0; |
| 86 | |
James Dong | e00cab7 | 2011-02-17 16:38:06 -0800 | [diff] [blame] | 87 | /* |
| 88 | * take a picture. |
| 89 | * @param msgType the message type an application selectively turn on/off |
| 90 | * on a photo-by-photo basis. The supported message types are: |
| 91 | * CAMERA_MSG_SHUTTER, CAMERA_MSG_RAW_IMAGE, CAMERA_MSG_COMPRESSED_IMAGE, |
| 92 | * and CAMERA_MSG_POSTVIEW_FRAME. Any other message types will be ignored. |
| 93 | */ |
| 94 | virtual status_t takePicture(int msgType) = 0; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 95 | |
| 96 | // set preview/capture parameters - key/value pairs |
| 97 | virtual status_t setParameters(const String8& params) = 0; |
| 98 | |
| 99 | // get preview/capture parameters - key/value pairs |
| 100 | virtual String8 getParameters() const = 0; |
Wu-cheng Li | 36f68b8 | 2009-09-28 16:14:58 -0700 | [diff] [blame] | 101 | |
| 102 | // send command to camera driver |
| 103 | virtual status_t sendCommand(int32_t cmd, int32_t arg1, int32_t arg2) = 0; |
James Dong | 3831185 | 2010-10-18 20:42:51 -0700 | [diff] [blame] | 104 | |
James Dong | 3831185 | 2010-10-18 20:42:51 -0700 | [diff] [blame] | 105 | // tell the camera hal to store meta data or real YUV data in video buffers. |
| 106 | virtual status_t storeMetaDataInBuffers(bool enabled) = 0; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 107 | }; |
| 108 | |
| 109 | // ---------------------------------------------------------------------------- |
| 110 | |
| 111 | class BnCamera: public BnInterface<ICamera> |
| 112 | { |
| 113 | public: |
| 114 | virtual status_t onTransact( uint32_t code, |
| 115 | const Parcel& data, |
| 116 | Parcel* reply, |
| 117 | uint32_t flags = 0); |
| 118 | }; |
| 119 | |
| 120 | }; // namespace android |
| 121 | |
| 122 | #endif |