blob: 3b12afedced486a12bb7bd1787935d5d4c9f85a5 [file] [log] [blame]
Mathias Agopian3cf61352010-02-09 17:46:37 -08001/*
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 Agopian3cf61352010-02-09 17:46:37 -080023#include <binder/IMemory.h>
Eino-Ville Talvalad56db1d2015-12-17 16:50:35 -080024#include <binder/Status.h>
Mathias Agopian3cf61352010-02-09 17:46:37 -080025#include <utils/String8.h>
Mathias Agopian3cf61352010-02-09 17:46:37 -080026
27namespace android {
28
Andy McFadden8ba01022012-12-18 09:46:54 -080029class IGraphicBufferProducer;
Mathias Agopiandf712ea2012-02-25 18:48:35 -080030class Surface;
Mathias Agopian3cf61352010-02-09 17:46:37 -080031
Eino-Ville Talvalad56db1d2015-12-17 16:50:35 -080032namespace hardware {
33
34class ICameraClient;
35
Mathias Agopian3cf61352010-02-09 17:46:37 -080036class ICamera: public IInterface
37{
Igor Murashkinbef3f232013-05-30 17:47:38 -070038 /**
39 * Keep up-to-date with ICamera.aidl in frameworks/base
40 */
Mathias Agopian3cf61352010-02-09 17:46:37 -080041public:
Chien-Yu Chen8cca0752015-11-13 15:28:48 -080042 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
Mathias Agopian3cf61352010-02-09 17:46:37 -080051 DECLARE_META_INTERFACE(Camera);
52
Eino-Ville Talvalad56db1d2015-12-17 16:50:35 -080053 virtual binder::Status disconnect() = 0;
Mathias Agopian3cf61352010-02-09 17:46:37 -080054
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
Andy McFadden8ba01022012-12-18 09:46:54 -080064 // pass the buffered IGraphicBufferProducer to the camera service
Eino-Ville Talvala1ce7c342013-08-21 13:57:21 -070065 virtual status_t setPreviewTarget(
Andy McFadden8ba01022012-12-18 09:46:54 -080066 const sp<IGraphicBufferProducer>& bufferProducer) = 0;
Jamie Gennisbfa33aa2010-12-20 11:51:31 -080067
Mathias Agopian3cf61352010-02-09 17:46:37 -080068 // set the preview callback flag to affect how the received frames from
Eino-Ville Talvala3ee35502013-04-02 15:45:11 -070069 // preview are handled. Enabling preview callback flags disables any active
70 // preview callback surface set by setPreviewCallbackTarget().
Mathias Agopian3cf61352010-02-09 17:46:37 -080071 virtual void setPreviewCallbackFlag(int flag) = 0;
Eino-Ville Talvala3ee35502013-04-02 15:45:11 -070072 // 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;
Mathias Agopian3cf61352010-02-09 17:46:37 -080078
Eino-Ville Talvala1ce7c342013-08-21 13:57:21 -070079 // start preview mode, must call setPreviewTarget first
Mathias Agopian3cf61352010-02-09 17:46:37 -080080 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
James Donge468ac52011-02-17 16:38:06 -080092 virtual void stopRecording() = 0;
Mathias Agopian3cf61352010-02-09 17:46:37 -080093
94 // get recording state
95 virtual bool recordingEnabled() = 0;
96
Chien-Yu Chen2d13b1d2016-04-28 12:11:20 -070097 // Release a recording frame that was received via ICameraClient::dataCallbackTimestamp.
Mathias Agopian3cf61352010-02-09 17:46:37 -080098 virtual void releaseRecordingFrame(const sp<IMemory>& mem) = 0;
99
Chien-Yu Chen2d13b1d2016-04-28 12:11:20 -0700100 // Release a recording frame handle that was received via
101 // ICameraClient::recordingFrameHandleCallbackTimestamp.
102 virtual void releaseRecordingFrameHandle(native_handle_t *handle) = 0;
103
Mathias Agopian3cf61352010-02-09 17:46:37 -0800104 // auto focus
105 virtual status_t autoFocus() = 0;
106
107 // cancel auto focus
108 virtual status_t cancelAutoFocus() = 0;
109
James Donge468ac52011-02-17 16:38:06 -0800110 /*
111 * take a picture.
112 * @param msgType the message type an application selectively turn on/off
113 * on a photo-by-photo basis. The supported message types are:
114 * CAMERA_MSG_SHUTTER, CAMERA_MSG_RAW_IMAGE, CAMERA_MSG_COMPRESSED_IMAGE,
115 * and CAMERA_MSG_POSTVIEW_FRAME. Any other message types will be ignored.
116 */
117 virtual status_t takePicture(int msgType) = 0;
Mathias Agopian3cf61352010-02-09 17:46:37 -0800118
119 // set preview/capture parameters - key/value pairs
120 virtual status_t setParameters(const String8& params) = 0;
121
122 // get preview/capture parameters - key/value pairs
123 virtual String8 getParameters() const = 0;
124
125 // send command to camera driver
126 virtual status_t sendCommand(int32_t cmd, int32_t arg1, int32_t arg2) = 0;
James Donge2ad6732010-10-18 20:42:51 -0700127
Chien-Yu Chen8cca0752015-11-13 15:28:48 -0800128
129 // Tell camera how to pass video buffers. videoBufferMode is one of VIDEO_BUFFER_MODE_*.
130 // Returns OK if the specified video buffer mode is supported. If videoBufferMode is
131 // VIDEO_BUFFER_MODE_BUFFER_QUEUE, setVideoTarget() must be called before starting video
132 // recording.
133 virtual status_t setVideoBufferMode(int32_t videoBufferMode) = 0;
134
135 // Set the video buffer producer for camera to use in VIDEO_BUFFER_MODE_BUFFER_QUEUE mode.
136 virtual status_t setVideoTarget(
137 const sp<IGraphicBufferProducer>& bufferProducer) = 0;
Mathias Agopian3cf61352010-02-09 17:46:37 -0800138};
139
140// ----------------------------------------------------------------------------
141
142class BnCamera: public BnInterface<ICamera>
143{
144public:
145 virtual status_t onTransact( uint32_t code,
146 const Parcel& data,
147 Parcel* reply,
148 uint32_t flags = 0);
149};
150
Eino-Ville Talvalad56db1d2015-12-17 16:50:35 -0800151} // namespace hardware
152} // namespace android
Mathias Agopian3cf61352010-02-09 17:46:37 -0800153
154#endif