blob: b83edf7060232dbcc2e53c12e0fcf5a707e32c22 [file] [log] [blame]
Mathias Agopian3cf61352010-02-09 17:46:37 -08001/*
2**
3** Copyright 2008, The Android Open Source Project
4**
5** Licensed under the Apache License, Version 2.0 (the "License");
6** you may not use this file except in compliance with the License.
7** You may obtain a copy of the License at
8**
9** http://www.apache.org/licenses/LICENSE-2.0
10**
11** Unless required by applicable law or agreed to in writing, software
12** distributed under the License is distributed on an "AS IS" BASIS,
13** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14** See the License for the specific language governing permissions and
15** limitations under the License.
16*/
17
18//#define LOG_NDEBUG 0
19#define LOG_TAG "ICamera"
20#include <utils/Log.h>
21#include <stdint.h>
22#include <sys/types.h>
23#include <binder/Parcel.h>
Praveen Chavan6773d472016-01-13 01:24:30 -080024#include <camera/CameraUtils.h>
Eino-Ville Talvalad56db1d2015-12-17 16:50:35 -080025#include <android/hardware/ICamera.h>
26#include <android/hardware/ICameraClient.h>
Andy McFadden8ba01022012-12-18 09:46:54 -080027#include <gui/IGraphicBufferProducer.h>
Mathias Agopiandf712ea2012-02-25 18:48:35 -080028#include <gui/Surface.h>
Praveen Chavan6773d472016-01-13 01:24:30 -080029#include <media/hardware/HardwareAPI.h>
Mathias Agopian3cf61352010-02-09 17:46:37 -080030
31namespace android {
Eino-Ville Talvalad56db1d2015-12-17 16:50:35 -080032namespace hardware {
Mathias Agopian3cf61352010-02-09 17:46:37 -080033
34enum {
35 DISCONNECT = IBinder::FIRST_CALL_TRANSACTION,
Eino-Ville Talvala1ce7c342013-08-21 13:57:21 -070036 SET_PREVIEW_TARGET,
Mathias Agopian3cf61352010-02-09 17:46:37 -080037 SET_PREVIEW_CALLBACK_FLAG,
Eino-Ville Talvala3ee35502013-04-02 15:45:11 -070038 SET_PREVIEW_CALLBACK_TARGET,
Mathias Agopian3cf61352010-02-09 17:46:37 -080039 START_PREVIEW,
40 STOP_PREVIEW,
41 AUTO_FOCUS,
42 CANCEL_AUTO_FOCUS,
43 TAKE_PICTURE,
44 SET_PARAMETERS,
45 GET_PARAMETERS,
46 SEND_COMMAND,
47 CONNECT,
48 LOCK,
49 UNLOCK,
50 PREVIEW_ENABLED,
51 START_RECORDING,
52 STOP_RECORDING,
53 RECORDING_ENABLED,
54 RELEASE_RECORDING_FRAME,
Chien-Yu Chen8cca0752015-11-13 15:28:48 -080055 SET_VIDEO_BUFFER_MODE,
56 SET_VIDEO_BUFFER_TARGET,
Chien-Yu Chen2d13b1d2016-04-28 12:11:20 -070057 RELEASE_RECORDING_FRAME_HANDLE,
Yin-Chia Yehb5df5472017-03-20 19:32:19 -070058 RELEASE_RECORDING_FRAME_HANDLE_BATCH,
Yin-Chia Yehdba03232019-08-19 15:54:28 -070059 SET_AUDIO_RESTRICTION,
Yin-Chia Yehcfab4e12019-09-09 13:08:28 -070060 GET_GLOBAL_AUDIO_RESTRICTION,
Mathias Agopian3cf61352010-02-09 17:46:37 -080061};
62
63class BpCamera: public BpInterface<ICamera>
64{
65public:
Chih-Hung Hsieh090ef602016-04-27 10:39:54 -070066 explicit BpCamera(const sp<IBinder>& impl)
Mathias Agopian3cf61352010-02-09 17:46:37 -080067 : BpInterface<ICamera>(impl)
68 {
69 }
70
71 // disconnect from camera service
Eino-Ville Talvalad56db1d2015-12-17 16:50:35 -080072 binder::Status disconnect()
Mathias Agopian3cf61352010-02-09 17:46:37 -080073 {
Steve Block3856b092011-10-20 11:56:00 +010074 ALOGV("disconnect");
Mathias Agopian3cf61352010-02-09 17:46:37 -080075 Parcel data, reply;
76 data.writeInterfaceToken(ICamera::getInterfaceDescriptor());
77 remote()->transact(DISCONNECT, data, &reply);
Igor Murashkinbef3f232013-05-30 17:47:38 -070078 reply.readExceptionCode();
Eino-Ville Talvalad56db1d2015-12-17 16:50:35 -080079 return binder::Status::ok();
Mathias Agopian3cf61352010-02-09 17:46:37 -080080 }
81
Andy McFadden8ba01022012-12-18 09:46:54 -080082 // pass the buffered IGraphicBufferProducer to the camera service
Eino-Ville Talvala1ce7c342013-08-21 13:57:21 -070083 status_t setPreviewTarget(const sp<IGraphicBufferProducer>& bufferProducer)
Jamie Gennisbfa33aa2010-12-20 11:51:31 -080084 {
Eino-Ville Talvala1ce7c342013-08-21 13:57:21 -070085 ALOGV("setPreviewTarget");
Jamie Gennisbfa33aa2010-12-20 11:51:31 -080086 Parcel data, reply;
87 data.writeInterfaceToken(ICamera::getInterfaceDescriptor());
Marco Nelissen06b46062014-11-14 07:58:25 -080088 sp<IBinder> b(IInterface::asBinder(bufferProducer));
Jamie Gennisbfa33aa2010-12-20 11:51:31 -080089 data.writeStrongBinder(b);
Eino-Ville Talvala1ce7c342013-08-21 13:57:21 -070090 remote()->transact(SET_PREVIEW_TARGET, data, &reply);
Jamie Gennisbfa33aa2010-12-20 11:51:31 -080091 return reply.readInt32();
92 }
93
Mathias Agopian3cf61352010-02-09 17:46:37 -080094 // set the preview callback flag to affect how the received frames from
95 // preview are handled. See Camera.h for details.
96 void setPreviewCallbackFlag(int flag)
97 {
Steve Block3856b092011-10-20 11:56:00 +010098 ALOGV("setPreviewCallbackFlag(%d)", flag);
Mathias Agopian3cf61352010-02-09 17:46:37 -080099 Parcel data, reply;
100 data.writeInterfaceToken(ICamera::getInterfaceDescriptor());
101 data.writeInt32(flag);
102 remote()->transact(SET_PREVIEW_CALLBACK_FLAG, data, &reply);
103 }
104
Eino-Ville Talvala3ee35502013-04-02 15:45:11 -0700105 status_t setPreviewCallbackTarget(
106 const sp<IGraphicBufferProducer>& callbackProducer)
107 {
108 ALOGV("setPreviewCallbackTarget");
109 Parcel data, reply;
110 data.writeInterfaceToken(ICamera::getInterfaceDescriptor());
Marco Nelissen06b46062014-11-14 07:58:25 -0800111 sp<IBinder> b(IInterface::asBinder(callbackProducer));
Eino-Ville Talvala3ee35502013-04-02 15:45:11 -0700112 data.writeStrongBinder(b);
113 remote()->transact(SET_PREVIEW_CALLBACK_TARGET, data, &reply);
114 return reply.readInt32();
115 }
116
Eino-Ville Talvala1ce7c342013-08-21 13:57:21 -0700117 // start preview mode, must call setPreviewTarget first
Mathias Agopian3cf61352010-02-09 17:46:37 -0800118 status_t startPreview()
119 {
Steve Block3856b092011-10-20 11:56:00 +0100120 ALOGV("startPreview");
Mathias Agopian3cf61352010-02-09 17:46:37 -0800121 Parcel data, reply;
122 data.writeInterfaceToken(ICamera::getInterfaceDescriptor());
123 remote()->transact(START_PREVIEW, data, &reply);
124 return reply.readInt32();
125 }
126
Eino-Ville Talvala1ce7c342013-08-21 13:57:21 -0700127 // start recording mode, must call setPreviewTarget first
Mathias Agopian3cf61352010-02-09 17:46:37 -0800128 status_t startRecording()
129 {
Steve Block3856b092011-10-20 11:56:00 +0100130 ALOGV("startRecording");
Mathias Agopian3cf61352010-02-09 17:46:37 -0800131 Parcel data, reply;
132 data.writeInterfaceToken(ICamera::getInterfaceDescriptor());
133 remote()->transact(START_RECORDING, data, &reply);
134 return reply.readInt32();
135 }
136
137 // stop preview mode
138 void stopPreview()
139 {
Steve Block3856b092011-10-20 11:56:00 +0100140 ALOGV("stopPreview");
Mathias Agopian3cf61352010-02-09 17:46:37 -0800141 Parcel data, reply;
142 data.writeInterfaceToken(ICamera::getInterfaceDescriptor());
143 remote()->transact(STOP_PREVIEW, data, &reply);
144 }
145
146 // stop recording mode
147 void stopRecording()
148 {
Steve Block3856b092011-10-20 11:56:00 +0100149 ALOGV("stopRecording");
Mathias Agopian3cf61352010-02-09 17:46:37 -0800150 Parcel data, reply;
151 data.writeInterfaceToken(ICamera::getInterfaceDescriptor());
152 remote()->transact(STOP_RECORDING, data, &reply);
153 }
154
155 void releaseRecordingFrame(const sp<IMemory>& mem)
156 {
Steve Block3856b092011-10-20 11:56:00 +0100157 ALOGV("releaseRecordingFrame");
Mathias Agopian3cf61352010-02-09 17:46:37 -0800158 Parcel data, reply;
159 data.writeInterfaceToken(ICamera::getInterfaceDescriptor());
Marco Nelissen06b46062014-11-14 07:58:25 -0800160 data.writeStrongBinder(IInterface::asBinder(mem));
Praveen Chavan6773d472016-01-13 01:24:30 -0800161
Mathias Agopian3cf61352010-02-09 17:46:37 -0800162 remote()->transact(RELEASE_RECORDING_FRAME, data, &reply);
Chien-Yu Chen2d13b1d2016-04-28 12:11:20 -0700163 }
Praveen Chavan6773d472016-01-13 01:24:30 -0800164
Chien-Yu Chen2d13b1d2016-04-28 12:11:20 -0700165 void releaseRecordingFrameHandle(native_handle_t *handle) {
166 ALOGV("releaseRecordingFrameHandle");
167 Parcel data, reply;
168 data.writeInterfaceToken(ICamera::getInterfaceDescriptor());
169 data.writeNativeHandle(handle);
170
171 remote()->transact(RELEASE_RECORDING_FRAME_HANDLE, data, &reply);
172
173 // Close the native handle because camera received a dup copy.
174 native_handle_close(handle);
175 native_handle_delete(handle);
Mathias Agopian3cf61352010-02-09 17:46:37 -0800176 }
177
Yin-Chia Yehb5df5472017-03-20 19:32:19 -0700178 void releaseRecordingFrameHandleBatch(const std::vector<native_handle_t*>& handles) {
179 ALOGV("releaseRecordingFrameHandleBatch");
180 Parcel data, reply;
181 data.writeInterfaceToken(ICamera::getInterfaceDescriptor());
182 uint32_t n = handles.size();
183 data.writeUint32(n);
184 for (auto& handle : handles) {
185 data.writeNativeHandle(handle);
186 }
187 remote()->transact(RELEASE_RECORDING_FRAME_HANDLE_BATCH, data, &reply);
188
189 // Close the native handle because camera received a dup copy.
190 for (auto& handle : handles) {
191 native_handle_close(handle);
192 native_handle_delete(handle);
193 }
194 }
195
Yin-Chia Yehcfab4e12019-09-09 13:08:28 -0700196 status_t setAudioRestriction(int32_t mode) {
Yin-Chia Yehdba03232019-08-19 15:54:28 -0700197 Parcel data, reply;
198 data.writeInterfaceToken(ICamera::getInterfaceDescriptor());
199 data.writeInt32(mode);
200 remote()->transact(SET_AUDIO_RESTRICTION, data, &reply);
201 return reply.readInt32();
202 }
203
Yin-Chia Yehcfab4e12019-09-09 13:08:28 -0700204 int32_t getGlobalAudioRestriction() {
205 Parcel data, reply;
206 data.writeInterfaceToken(ICamera::getInterfaceDescriptor());
207 remote()->transact(GET_GLOBAL_AUDIO_RESTRICTION, data, &reply);
208 return reply.readInt32();
209 }
210
Chien-Yu Chen8cca0752015-11-13 15:28:48 -0800211 status_t setVideoBufferMode(int32_t videoBufferMode)
James Donge2ad6732010-10-18 20:42:51 -0700212 {
Chien-Yu Chen8cca0752015-11-13 15:28:48 -0800213 ALOGV("setVideoBufferMode: %d", videoBufferMode);
James Donge2ad6732010-10-18 20:42:51 -0700214 Parcel data, reply;
215 data.writeInterfaceToken(ICamera::getInterfaceDescriptor());
Chien-Yu Chen8cca0752015-11-13 15:28:48 -0800216 data.writeInt32(videoBufferMode);
217 remote()->transact(SET_VIDEO_BUFFER_MODE, data, &reply);
James Donge2ad6732010-10-18 20:42:51 -0700218 return reply.readInt32();
219 }
220
Mathias Agopian3cf61352010-02-09 17:46:37 -0800221 // check preview state
222 bool previewEnabled()
223 {
Steve Block3856b092011-10-20 11:56:00 +0100224 ALOGV("previewEnabled");
Mathias Agopian3cf61352010-02-09 17:46:37 -0800225 Parcel data, reply;
226 data.writeInterfaceToken(ICamera::getInterfaceDescriptor());
227 remote()->transact(PREVIEW_ENABLED, data, &reply);
228 return reply.readInt32();
229 }
230
231 // check recording state
232 bool recordingEnabled()
233 {
Steve Block3856b092011-10-20 11:56:00 +0100234 ALOGV("recordingEnabled");
Mathias Agopian3cf61352010-02-09 17:46:37 -0800235 Parcel data, reply;
236 data.writeInterfaceToken(ICamera::getInterfaceDescriptor());
237 remote()->transact(RECORDING_ENABLED, data, &reply);
238 return reply.readInt32();
239 }
240
241 // auto focus
242 status_t autoFocus()
243 {
Steve Block3856b092011-10-20 11:56:00 +0100244 ALOGV("autoFocus");
Mathias Agopian3cf61352010-02-09 17:46:37 -0800245 Parcel data, reply;
246 data.writeInterfaceToken(ICamera::getInterfaceDescriptor());
247 remote()->transact(AUTO_FOCUS, data, &reply);
248 status_t ret = reply.readInt32();
249 return ret;
250 }
251
252 // cancel focus
253 status_t cancelAutoFocus()
254 {
Steve Block3856b092011-10-20 11:56:00 +0100255 ALOGV("cancelAutoFocus");
Mathias Agopian3cf61352010-02-09 17:46:37 -0800256 Parcel data, reply;
257 data.writeInterfaceToken(ICamera::getInterfaceDescriptor());
258 remote()->transact(CANCEL_AUTO_FOCUS, data, &reply);
259 status_t ret = reply.readInt32();
260 return ret;
261 }
262
263 // take a picture - returns an IMemory (ref-counted mmap)
James Donge468ac52011-02-17 16:38:06 -0800264 status_t takePicture(int msgType)
Mathias Agopian3cf61352010-02-09 17:46:37 -0800265 {
Steve Block3856b092011-10-20 11:56:00 +0100266 ALOGV("takePicture: 0x%x", msgType);
Mathias Agopian3cf61352010-02-09 17:46:37 -0800267 Parcel data, reply;
268 data.writeInterfaceToken(ICamera::getInterfaceDescriptor());
James Donge468ac52011-02-17 16:38:06 -0800269 data.writeInt32(msgType);
Mathias Agopian3cf61352010-02-09 17:46:37 -0800270 remote()->transact(TAKE_PICTURE, data, &reply);
271 status_t ret = reply.readInt32();
272 return ret;
273 }
274
275 // set preview/capture parameters - key/value pairs
276 status_t setParameters(const String8& params)
277 {
Steve Block3856b092011-10-20 11:56:00 +0100278 ALOGV("setParameters");
Mathias Agopian3cf61352010-02-09 17:46:37 -0800279 Parcel data, reply;
280 data.writeInterfaceToken(ICamera::getInterfaceDescriptor());
281 data.writeString8(params);
282 remote()->transact(SET_PARAMETERS, data, &reply);
283 return reply.readInt32();
284 }
285
286 // get preview/capture parameters - key/value pairs
287 String8 getParameters() const
288 {
Steve Block3856b092011-10-20 11:56:00 +0100289 ALOGV("getParameters");
Mathias Agopian3cf61352010-02-09 17:46:37 -0800290 Parcel data, reply;
291 data.writeInterfaceToken(ICamera::getInterfaceDescriptor());
292 remote()->transact(GET_PARAMETERS, data, &reply);
293 return reply.readString8();
294 }
295 virtual status_t sendCommand(int32_t cmd, int32_t arg1, int32_t arg2)
296 {
Steve Block3856b092011-10-20 11:56:00 +0100297 ALOGV("sendCommand");
Mathias Agopian3cf61352010-02-09 17:46:37 -0800298 Parcel data, reply;
299 data.writeInterfaceToken(ICamera::getInterfaceDescriptor());
300 data.writeInt32(cmd);
301 data.writeInt32(arg1);
302 data.writeInt32(arg2);
303 remote()->transact(SEND_COMMAND, data, &reply);
304 return reply.readInt32();
305 }
306 virtual status_t connect(const sp<ICameraClient>& cameraClient)
307 {
308 Parcel data, reply;
309 data.writeInterfaceToken(ICamera::getInterfaceDescriptor());
Marco Nelissen06b46062014-11-14 07:58:25 -0800310 data.writeStrongBinder(IInterface::asBinder(cameraClient));
Mathias Agopian3cf61352010-02-09 17:46:37 -0800311 remote()->transact(CONNECT, data, &reply);
312 return reply.readInt32();
313 }
314 virtual status_t lock()
315 {
316 Parcel data, reply;
317 data.writeInterfaceToken(ICamera::getInterfaceDescriptor());
318 remote()->transact(LOCK, data, &reply);
319 return reply.readInt32();
320 }
321 virtual status_t unlock()
322 {
323 Parcel data, reply;
324 data.writeInterfaceToken(ICamera::getInterfaceDescriptor());
325 remote()->transact(UNLOCK, data, &reply);
326 return reply.readInt32();
327 }
Chien-Yu Chen8cca0752015-11-13 15:28:48 -0800328
329 status_t setVideoTarget(const sp<IGraphicBufferProducer>& bufferProducer)
330 {
331 ALOGV("setVideoTarget");
332 Parcel data, reply;
333 data.writeInterfaceToken(ICamera::getInterfaceDescriptor());
334 sp<IBinder> b(IInterface::asBinder(bufferProducer));
335 data.writeStrongBinder(b);
336 remote()->transact(SET_VIDEO_BUFFER_TARGET, data, &reply);
337 return reply.readInt32();
338 }
Mathias Agopian3cf61352010-02-09 17:46:37 -0800339};
340
341IMPLEMENT_META_INTERFACE(Camera, "android.hardware.ICamera");
342
343// ----------------------------------------------------------------------
344
345status_t BnCamera::onTransact(
346 uint32_t code, const Parcel& data, Parcel* reply, uint32_t flags)
347{
348 switch(code) {
349 case DISCONNECT: {
Steve Block3856b092011-10-20 11:56:00 +0100350 ALOGV("DISCONNECT");
Mathias Agopian3cf61352010-02-09 17:46:37 -0800351 CHECK_INTERFACE(ICamera, data, reply);
352 disconnect();
Igor Murashkinbef3f232013-05-30 17:47:38 -0700353 reply->writeNoException();
Mathias Agopian3cf61352010-02-09 17:46:37 -0800354 return NO_ERROR;
355 } break;
Eino-Ville Talvala1ce7c342013-08-21 13:57:21 -0700356 case SET_PREVIEW_TARGET: {
357 ALOGV("SET_PREVIEW_TARGET");
Jamie Gennisbfa33aa2010-12-20 11:51:31 -0800358 CHECK_INTERFACE(ICamera, data, reply);
Andy McFadden8ba01022012-12-18 09:46:54 -0800359 sp<IGraphicBufferProducer> st =
360 interface_cast<IGraphicBufferProducer>(data.readStrongBinder());
Eino-Ville Talvala1ce7c342013-08-21 13:57:21 -0700361 reply->writeInt32(setPreviewTarget(st));
Jamie Gennisbfa33aa2010-12-20 11:51:31 -0800362 return NO_ERROR;
363 } break;
Mathias Agopian3cf61352010-02-09 17:46:37 -0800364 case SET_PREVIEW_CALLBACK_FLAG: {
Steve Block3856b092011-10-20 11:56:00 +0100365 ALOGV("SET_PREVIEW_CALLBACK_TYPE");
Mathias Agopian3cf61352010-02-09 17:46:37 -0800366 CHECK_INTERFACE(ICamera, data, reply);
367 int callback_flag = data.readInt32();
368 setPreviewCallbackFlag(callback_flag);
369 return NO_ERROR;
370 } break;
Eino-Ville Talvala3ee35502013-04-02 15:45:11 -0700371 case SET_PREVIEW_CALLBACK_TARGET: {
372 ALOGV("SET_PREVIEW_CALLBACK_TARGET");
373 CHECK_INTERFACE(ICamera, data, reply);
374 sp<IGraphicBufferProducer> cp =
375 interface_cast<IGraphicBufferProducer>(data.readStrongBinder());
376 reply->writeInt32(setPreviewCallbackTarget(cp));
377 return NO_ERROR;
378 }
Mathias Agopian3cf61352010-02-09 17:46:37 -0800379 case START_PREVIEW: {
Steve Block3856b092011-10-20 11:56:00 +0100380 ALOGV("START_PREVIEW");
Mathias Agopian3cf61352010-02-09 17:46:37 -0800381 CHECK_INTERFACE(ICamera, data, reply);
382 reply->writeInt32(startPreview());
383 return NO_ERROR;
384 } break;
385 case START_RECORDING: {
Steve Block3856b092011-10-20 11:56:00 +0100386 ALOGV("START_RECORDING");
Mathias Agopian3cf61352010-02-09 17:46:37 -0800387 CHECK_INTERFACE(ICamera, data, reply);
388 reply->writeInt32(startRecording());
389 return NO_ERROR;
390 } break;
391 case STOP_PREVIEW: {
Steve Block3856b092011-10-20 11:56:00 +0100392 ALOGV("STOP_PREVIEW");
Mathias Agopian3cf61352010-02-09 17:46:37 -0800393 CHECK_INTERFACE(ICamera, data, reply);
394 stopPreview();
395 return NO_ERROR;
396 } break;
397 case STOP_RECORDING: {
Steve Block3856b092011-10-20 11:56:00 +0100398 ALOGV("STOP_RECORDING");
Mathias Agopian3cf61352010-02-09 17:46:37 -0800399 CHECK_INTERFACE(ICamera, data, reply);
400 stopRecording();
401 return NO_ERROR;
402 } break;
403 case RELEASE_RECORDING_FRAME: {
Steve Block3856b092011-10-20 11:56:00 +0100404 ALOGV("RELEASE_RECORDING_FRAME");
Mathias Agopian3cf61352010-02-09 17:46:37 -0800405 CHECK_INTERFACE(ICamera, data, reply);
406 sp<IMemory> mem = interface_cast<IMemory>(data.readStrongBinder());
407 releaseRecordingFrame(mem);
408 return NO_ERROR;
409 } break;
Chien-Yu Chen2d13b1d2016-04-28 12:11:20 -0700410 case RELEASE_RECORDING_FRAME_HANDLE: {
411 ALOGV("RELEASE_RECORDING_FRAME_HANDLE");
412 CHECK_INTERFACE(ICamera, data, reply);
413 // releaseRecordingFrameHandle will be responsble to close the native handle.
414 releaseRecordingFrameHandle(data.readNativeHandle());
415 return NO_ERROR;
416 } break;
Yin-Chia Yehb5df5472017-03-20 19:32:19 -0700417 case RELEASE_RECORDING_FRAME_HANDLE_BATCH: {
418 ALOGV("RELEASE_RECORDING_FRAME_HANDLE_BATCH");
419 CHECK_INTERFACE(ICamera, data, reply);
420 // releaseRecordingFrameHandle will be responsble to close the native handle.
421 uint32_t n = data.readUint32();
422 std::vector<native_handle_t*> handles;
423 handles.reserve(n);
424 for (uint32_t i = 0; i < n; i++) {
425 handles.push_back(data.readNativeHandle());
426 }
427 releaseRecordingFrameHandleBatch(handles);
428 return NO_ERROR;
429 } break;
Chien-Yu Chen8cca0752015-11-13 15:28:48 -0800430 case SET_VIDEO_BUFFER_MODE: {
431 ALOGV("SET_VIDEO_BUFFER_MODE");
James Donge2ad6732010-10-18 20:42:51 -0700432 CHECK_INTERFACE(ICamera, data, reply);
Chien-Yu Chen8cca0752015-11-13 15:28:48 -0800433 int32_t mode = data.readInt32();
434 reply->writeInt32(setVideoBufferMode(mode));
James Donge2ad6732010-10-18 20:42:51 -0700435 return NO_ERROR;
436 } break;
Mathias Agopian3cf61352010-02-09 17:46:37 -0800437 case PREVIEW_ENABLED: {
Steve Block3856b092011-10-20 11:56:00 +0100438 ALOGV("PREVIEW_ENABLED");
Mathias Agopian3cf61352010-02-09 17:46:37 -0800439 CHECK_INTERFACE(ICamera, data, reply);
440 reply->writeInt32(previewEnabled());
441 return NO_ERROR;
442 } break;
443 case RECORDING_ENABLED: {
Steve Block3856b092011-10-20 11:56:00 +0100444 ALOGV("RECORDING_ENABLED");
Mathias Agopian3cf61352010-02-09 17:46:37 -0800445 CHECK_INTERFACE(ICamera, data, reply);
446 reply->writeInt32(recordingEnabled());
447 return NO_ERROR;
448 } break;
449 case AUTO_FOCUS: {
Steve Block3856b092011-10-20 11:56:00 +0100450 ALOGV("AUTO_FOCUS");
Mathias Agopian3cf61352010-02-09 17:46:37 -0800451 CHECK_INTERFACE(ICamera, data, reply);
452 reply->writeInt32(autoFocus());
453 return NO_ERROR;
454 } break;
455 case CANCEL_AUTO_FOCUS: {
Steve Block3856b092011-10-20 11:56:00 +0100456 ALOGV("CANCEL_AUTO_FOCUS");
Mathias Agopian3cf61352010-02-09 17:46:37 -0800457 CHECK_INTERFACE(ICamera, data, reply);
458 reply->writeInt32(cancelAutoFocus());
459 return NO_ERROR;
460 } break;
461 case TAKE_PICTURE: {
Steve Block3856b092011-10-20 11:56:00 +0100462 ALOGV("TAKE_PICTURE");
Mathias Agopian3cf61352010-02-09 17:46:37 -0800463 CHECK_INTERFACE(ICamera, data, reply);
James Donge468ac52011-02-17 16:38:06 -0800464 int msgType = data.readInt32();
465 reply->writeInt32(takePicture(msgType));
Mathias Agopian3cf61352010-02-09 17:46:37 -0800466 return NO_ERROR;
467 } break;
468 case SET_PARAMETERS: {
Steve Block3856b092011-10-20 11:56:00 +0100469 ALOGV("SET_PARAMETERS");
Mathias Agopian3cf61352010-02-09 17:46:37 -0800470 CHECK_INTERFACE(ICamera, data, reply);
471 String8 params(data.readString8());
472 reply->writeInt32(setParameters(params));
473 return NO_ERROR;
474 } break;
475 case GET_PARAMETERS: {
Steve Block3856b092011-10-20 11:56:00 +0100476 ALOGV("GET_PARAMETERS");
Mathias Agopian3cf61352010-02-09 17:46:37 -0800477 CHECK_INTERFACE(ICamera, data, reply);
478 reply->writeString8(getParameters());
479 return NO_ERROR;
480 } break;
481 case SEND_COMMAND: {
Steve Block3856b092011-10-20 11:56:00 +0100482 ALOGV("SEND_COMMAND");
Mathias Agopian3cf61352010-02-09 17:46:37 -0800483 CHECK_INTERFACE(ICamera, data, reply);
484 int command = data.readInt32();
485 int arg1 = data.readInt32();
486 int arg2 = data.readInt32();
487 reply->writeInt32(sendCommand(command, arg1, arg2));
488 return NO_ERROR;
489 } break;
490 case CONNECT: {
491 CHECK_INTERFACE(ICamera, data, reply);
492 sp<ICameraClient> cameraClient = interface_cast<ICameraClient>(data.readStrongBinder());
493 reply->writeInt32(connect(cameraClient));
494 return NO_ERROR;
495 } break;
496 case LOCK: {
497 CHECK_INTERFACE(ICamera, data, reply);
498 reply->writeInt32(lock());
499 return NO_ERROR;
500 } break;
501 case UNLOCK: {
502 CHECK_INTERFACE(ICamera, data, reply);
503 reply->writeInt32(unlock());
504 return NO_ERROR;
505 } break;
Chien-Yu Chen8cca0752015-11-13 15:28:48 -0800506 case SET_VIDEO_BUFFER_TARGET: {
507 ALOGV("SET_VIDEO_BUFFER_TARGET");
508 CHECK_INTERFACE(ICamera, data, reply);
509 sp<IGraphicBufferProducer> st =
510 interface_cast<IGraphicBufferProducer>(data.readStrongBinder());
511 reply->writeInt32(setVideoTarget(st));
512 return NO_ERROR;
513 } break;
Yin-Chia Yehdba03232019-08-19 15:54:28 -0700514 case SET_AUDIO_RESTRICTION: {
515 CHECK_INTERFACE(ICamera, data, reply);
516 int32_t mode = data.readInt32();
517 reply->writeInt32(setAudioRestriction(mode));
518 return NO_ERROR;
519 } break;
Yin-Chia Yehcfab4e12019-09-09 13:08:28 -0700520 case GET_GLOBAL_AUDIO_RESTRICTION: {
521 CHECK_INTERFACE(ICamera, data, reply);
522 reply->writeInt32(getGlobalAudioRestriction());
523 return NO_ERROR;
524 } break;
Mathias Agopian3cf61352010-02-09 17:46:37 -0800525 default:
526 return BBinder::onTransact(code, data, reply, flags);
527 }
528}
529
530// ----------------------------------------------------------------------------
531
Eino-Ville Talvalad56db1d2015-12-17 16:50:35 -0800532} // namespace hardware
533} // namespace android