blob: 1dd89125b6341260ea2983563ae5f5c2891e7f37 [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>
Mathias Agopian3cf61352010-02-09 17:46:37 -080025#include <camera/ICamera.h>
Andy McFadden8ba01022012-12-18 09:46:54 -080026#include <gui/IGraphicBufferProducer.h>
Mathias Agopiandf712ea2012-02-25 18:48:35 -080027#include <gui/Surface.h>
Praveen Chavan6773d472016-01-13 01:24:30 -080028#include <media/hardware/HardwareAPI.h>
Mathias Agopian3cf61352010-02-09 17:46:37 -080029
30namespace android {
31
32enum {
33 DISCONNECT = IBinder::FIRST_CALL_TRANSACTION,
Eino-Ville Talvala1ce7c342013-08-21 13:57:21 -070034 SET_PREVIEW_TARGET,
Mathias Agopian3cf61352010-02-09 17:46:37 -080035 SET_PREVIEW_CALLBACK_FLAG,
Eino-Ville Talvala3ee35502013-04-02 15:45:11 -070036 SET_PREVIEW_CALLBACK_TARGET,
Mathias Agopian3cf61352010-02-09 17:46:37 -080037 START_PREVIEW,
38 STOP_PREVIEW,
39 AUTO_FOCUS,
40 CANCEL_AUTO_FOCUS,
41 TAKE_PICTURE,
42 SET_PARAMETERS,
43 GET_PARAMETERS,
44 SEND_COMMAND,
45 CONNECT,
46 LOCK,
47 UNLOCK,
48 PREVIEW_ENABLED,
49 START_RECORDING,
50 STOP_RECORDING,
51 RECORDING_ENABLED,
52 RELEASE_RECORDING_FRAME,
Chien-Yu Chen8cca0752015-11-13 15:28:48 -080053 SET_VIDEO_BUFFER_MODE,
54 SET_VIDEO_BUFFER_TARGET,
Mathias Agopian3cf61352010-02-09 17:46:37 -080055};
56
57class BpCamera: public BpInterface<ICamera>
58{
59public:
60 BpCamera(const sp<IBinder>& impl)
61 : BpInterface<ICamera>(impl)
62 {
63 }
64
65 // disconnect from camera service
66 void disconnect()
67 {
Steve Block3856b092011-10-20 11:56:00 +010068 ALOGV("disconnect");
Mathias Agopian3cf61352010-02-09 17:46:37 -080069 Parcel data, reply;
70 data.writeInterfaceToken(ICamera::getInterfaceDescriptor());
71 remote()->transact(DISCONNECT, data, &reply);
Igor Murashkinbef3f232013-05-30 17:47:38 -070072 reply.readExceptionCode();
Mathias Agopian3cf61352010-02-09 17:46:37 -080073 }
74
Andy McFadden8ba01022012-12-18 09:46:54 -080075 // pass the buffered IGraphicBufferProducer to the camera service
Eino-Ville Talvala1ce7c342013-08-21 13:57:21 -070076 status_t setPreviewTarget(const sp<IGraphicBufferProducer>& bufferProducer)
Jamie Gennisbfa33aa2010-12-20 11:51:31 -080077 {
Eino-Ville Talvala1ce7c342013-08-21 13:57:21 -070078 ALOGV("setPreviewTarget");
Jamie Gennisbfa33aa2010-12-20 11:51:31 -080079 Parcel data, reply;
80 data.writeInterfaceToken(ICamera::getInterfaceDescriptor());
Marco Nelissen06b46062014-11-14 07:58:25 -080081 sp<IBinder> b(IInterface::asBinder(bufferProducer));
Jamie Gennisbfa33aa2010-12-20 11:51:31 -080082 data.writeStrongBinder(b);
Eino-Ville Talvala1ce7c342013-08-21 13:57:21 -070083 remote()->transact(SET_PREVIEW_TARGET, data, &reply);
Jamie Gennisbfa33aa2010-12-20 11:51:31 -080084 return reply.readInt32();
85 }
86
Mathias Agopian3cf61352010-02-09 17:46:37 -080087 // set the preview callback flag to affect how the received frames from
88 // preview are handled. See Camera.h for details.
89 void setPreviewCallbackFlag(int flag)
90 {
Steve Block3856b092011-10-20 11:56:00 +010091 ALOGV("setPreviewCallbackFlag(%d)", flag);
Mathias Agopian3cf61352010-02-09 17:46:37 -080092 Parcel data, reply;
93 data.writeInterfaceToken(ICamera::getInterfaceDescriptor());
94 data.writeInt32(flag);
95 remote()->transact(SET_PREVIEW_CALLBACK_FLAG, data, &reply);
96 }
97
Eino-Ville Talvala3ee35502013-04-02 15:45:11 -070098 status_t setPreviewCallbackTarget(
99 const sp<IGraphicBufferProducer>& callbackProducer)
100 {
101 ALOGV("setPreviewCallbackTarget");
102 Parcel data, reply;
103 data.writeInterfaceToken(ICamera::getInterfaceDescriptor());
Marco Nelissen06b46062014-11-14 07:58:25 -0800104 sp<IBinder> b(IInterface::asBinder(callbackProducer));
Eino-Ville Talvala3ee35502013-04-02 15:45:11 -0700105 data.writeStrongBinder(b);
106 remote()->transact(SET_PREVIEW_CALLBACK_TARGET, data, &reply);
107 return reply.readInt32();
108 }
109
Eino-Ville Talvala1ce7c342013-08-21 13:57:21 -0700110 // start preview mode, must call setPreviewTarget first
Mathias Agopian3cf61352010-02-09 17:46:37 -0800111 status_t startPreview()
112 {
Steve Block3856b092011-10-20 11:56:00 +0100113 ALOGV("startPreview");
Mathias Agopian3cf61352010-02-09 17:46:37 -0800114 Parcel data, reply;
115 data.writeInterfaceToken(ICamera::getInterfaceDescriptor());
116 remote()->transact(START_PREVIEW, data, &reply);
117 return reply.readInt32();
118 }
119
Eino-Ville Talvala1ce7c342013-08-21 13:57:21 -0700120 // start recording mode, must call setPreviewTarget first
Mathias Agopian3cf61352010-02-09 17:46:37 -0800121 status_t startRecording()
122 {
Steve Block3856b092011-10-20 11:56:00 +0100123 ALOGV("startRecording");
Mathias Agopian3cf61352010-02-09 17:46:37 -0800124 Parcel data, reply;
125 data.writeInterfaceToken(ICamera::getInterfaceDescriptor());
126 remote()->transact(START_RECORDING, data, &reply);
127 return reply.readInt32();
128 }
129
130 // stop preview mode
131 void stopPreview()
132 {
Steve Block3856b092011-10-20 11:56:00 +0100133 ALOGV("stopPreview");
Mathias Agopian3cf61352010-02-09 17:46:37 -0800134 Parcel data, reply;
135 data.writeInterfaceToken(ICamera::getInterfaceDescriptor());
136 remote()->transact(STOP_PREVIEW, data, &reply);
137 }
138
139 // stop recording mode
140 void stopRecording()
141 {
Steve Block3856b092011-10-20 11:56:00 +0100142 ALOGV("stopRecording");
Mathias Agopian3cf61352010-02-09 17:46:37 -0800143 Parcel data, reply;
144 data.writeInterfaceToken(ICamera::getInterfaceDescriptor());
145 remote()->transact(STOP_RECORDING, data, &reply);
146 }
147
148 void releaseRecordingFrame(const sp<IMemory>& mem)
149 {
Steve Block3856b092011-10-20 11:56:00 +0100150 ALOGV("releaseRecordingFrame");
Mathias Agopian3cf61352010-02-09 17:46:37 -0800151 Parcel data, reply;
152 data.writeInterfaceToken(ICamera::getInterfaceDescriptor());
Marco Nelissen06b46062014-11-14 07:58:25 -0800153 data.writeStrongBinder(IInterface::asBinder(mem));
Praveen Chavan6773d472016-01-13 01:24:30 -0800154
155 native_handle_t *nh = nullptr;
156 if (CameraUtils::isNativeHandleMetadata(mem)) {
157 VideoNativeHandleMetadata *metadata =
158 (VideoNativeHandleMetadata*)(mem->pointer());
159 nh = metadata->pHandle;
160 data.writeNativeHandle(nh);
161 }
162
Mathias Agopian3cf61352010-02-09 17:46:37 -0800163 remote()->transact(RELEASE_RECORDING_FRAME, data, &reply);
Praveen Chavan6773d472016-01-13 01:24:30 -0800164
165 if (nh) {
166 // Close the native handle because camera received a dup copy.
167 native_handle_close(nh);
168 native_handle_delete(nh);
169 }
Mathias Agopian3cf61352010-02-09 17:46:37 -0800170 }
171
Chien-Yu Chen8cca0752015-11-13 15:28:48 -0800172 status_t setVideoBufferMode(int32_t videoBufferMode)
James Donge2ad6732010-10-18 20:42:51 -0700173 {
Chien-Yu Chen8cca0752015-11-13 15:28:48 -0800174 ALOGV("setVideoBufferMode: %d", videoBufferMode);
James Donge2ad6732010-10-18 20:42:51 -0700175 Parcel data, reply;
176 data.writeInterfaceToken(ICamera::getInterfaceDescriptor());
Chien-Yu Chen8cca0752015-11-13 15:28:48 -0800177 data.writeInt32(videoBufferMode);
178 remote()->transact(SET_VIDEO_BUFFER_MODE, data, &reply);
James Donge2ad6732010-10-18 20:42:51 -0700179 return reply.readInt32();
180 }
181
Mathias Agopian3cf61352010-02-09 17:46:37 -0800182 // check preview state
183 bool previewEnabled()
184 {
Steve Block3856b092011-10-20 11:56:00 +0100185 ALOGV("previewEnabled");
Mathias Agopian3cf61352010-02-09 17:46:37 -0800186 Parcel data, reply;
187 data.writeInterfaceToken(ICamera::getInterfaceDescriptor());
188 remote()->transact(PREVIEW_ENABLED, data, &reply);
189 return reply.readInt32();
190 }
191
192 // check recording state
193 bool recordingEnabled()
194 {
Steve Block3856b092011-10-20 11:56:00 +0100195 ALOGV("recordingEnabled");
Mathias Agopian3cf61352010-02-09 17:46:37 -0800196 Parcel data, reply;
197 data.writeInterfaceToken(ICamera::getInterfaceDescriptor());
198 remote()->transact(RECORDING_ENABLED, data, &reply);
199 return reply.readInt32();
200 }
201
202 // auto focus
203 status_t autoFocus()
204 {
Steve Block3856b092011-10-20 11:56:00 +0100205 ALOGV("autoFocus");
Mathias Agopian3cf61352010-02-09 17:46:37 -0800206 Parcel data, reply;
207 data.writeInterfaceToken(ICamera::getInterfaceDescriptor());
208 remote()->transact(AUTO_FOCUS, data, &reply);
209 status_t ret = reply.readInt32();
210 return ret;
211 }
212
213 // cancel focus
214 status_t cancelAutoFocus()
215 {
Steve Block3856b092011-10-20 11:56:00 +0100216 ALOGV("cancelAutoFocus");
Mathias Agopian3cf61352010-02-09 17:46:37 -0800217 Parcel data, reply;
218 data.writeInterfaceToken(ICamera::getInterfaceDescriptor());
219 remote()->transact(CANCEL_AUTO_FOCUS, data, &reply);
220 status_t ret = reply.readInt32();
221 return ret;
222 }
223
224 // take a picture - returns an IMemory (ref-counted mmap)
James Donge468ac52011-02-17 16:38:06 -0800225 status_t takePicture(int msgType)
Mathias Agopian3cf61352010-02-09 17:46:37 -0800226 {
Steve Block3856b092011-10-20 11:56:00 +0100227 ALOGV("takePicture: 0x%x", msgType);
Mathias Agopian3cf61352010-02-09 17:46:37 -0800228 Parcel data, reply;
229 data.writeInterfaceToken(ICamera::getInterfaceDescriptor());
James Donge468ac52011-02-17 16:38:06 -0800230 data.writeInt32(msgType);
Mathias Agopian3cf61352010-02-09 17:46:37 -0800231 remote()->transact(TAKE_PICTURE, data, &reply);
232 status_t ret = reply.readInt32();
233 return ret;
234 }
235
236 // set preview/capture parameters - key/value pairs
237 status_t setParameters(const String8& params)
238 {
Steve Block3856b092011-10-20 11:56:00 +0100239 ALOGV("setParameters");
Mathias Agopian3cf61352010-02-09 17:46:37 -0800240 Parcel data, reply;
241 data.writeInterfaceToken(ICamera::getInterfaceDescriptor());
242 data.writeString8(params);
243 remote()->transact(SET_PARAMETERS, data, &reply);
244 return reply.readInt32();
245 }
246
247 // get preview/capture parameters - key/value pairs
248 String8 getParameters() const
249 {
Steve Block3856b092011-10-20 11:56:00 +0100250 ALOGV("getParameters");
Mathias Agopian3cf61352010-02-09 17:46:37 -0800251 Parcel data, reply;
252 data.writeInterfaceToken(ICamera::getInterfaceDescriptor());
253 remote()->transact(GET_PARAMETERS, data, &reply);
254 return reply.readString8();
255 }
256 virtual status_t sendCommand(int32_t cmd, int32_t arg1, int32_t arg2)
257 {
Steve Block3856b092011-10-20 11:56:00 +0100258 ALOGV("sendCommand");
Mathias Agopian3cf61352010-02-09 17:46:37 -0800259 Parcel data, reply;
260 data.writeInterfaceToken(ICamera::getInterfaceDescriptor());
261 data.writeInt32(cmd);
262 data.writeInt32(arg1);
263 data.writeInt32(arg2);
264 remote()->transact(SEND_COMMAND, data, &reply);
265 return reply.readInt32();
266 }
267 virtual status_t connect(const sp<ICameraClient>& cameraClient)
268 {
269 Parcel data, reply;
270 data.writeInterfaceToken(ICamera::getInterfaceDescriptor());
Marco Nelissen06b46062014-11-14 07:58:25 -0800271 data.writeStrongBinder(IInterface::asBinder(cameraClient));
Mathias Agopian3cf61352010-02-09 17:46:37 -0800272 remote()->transact(CONNECT, data, &reply);
273 return reply.readInt32();
274 }
275 virtual status_t lock()
276 {
277 Parcel data, reply;
278 data.writeInterfaceToken(ICamera::getInterfaceDescriptor());
279 remote()->transact(LOCK, data, &reply);
280 return reply.readInt32();
281 }
282 virtual status_t unlock()
283 {
284 Parcel data, reply;
285 data.writeInterfaceToken(ICamera::getInterfaceDescriptor());
286 remote()->transact(UNLOCK, data, &reply);
287 return reply.readInt32();
288 }
Chien-Yu Chen8cca0752015-11-13 15:28:48 -0800289
290 status_t setVideoTarget(const sp<IGraphicBufferProducer>& bufferProducer)
291 {
292 ALOGV("setVideoTarget");
293 Parcel data, reply;
294 data.writeInterfaceToken(ICamera::getInterfaceDescriptor());
295 sp<IBinder> b(IInterface::asBinder(bufferProducer));
296 data.writeStrongBinder(b);
297 remote()->transact(SET_VIDEO_BUFFER_TARGET, data, &reply);
298 return reply.readInt32();
299 }
Mathias Agopian3cf61352010-02-09 17:46:37 -0800300};
301
302IMPLEMENT_META_INTERFACE(Camera, "android.hardware.ICamera");
303
304// ----------------------------------------------------------------------
305
306status_t BnCamera::onTransact(
307 uint32_t code, const Parcel& data, Parcel* reply, uint32_t flags)
308{
309 switch(code) {
310 case DISCONNECT: {
Steve Block3856b092011-10-20 11:56:00 +0100311 ALOGV("DISCONNECT");
Mathias Agopian3cf61352010-02-09 17:46:37 -0800312 CHECK_INTERFACE(ICamera, data, reply);
313 disconnect();
Igor Murashkinbef3f232013-05-30 17:47:38 -0700314 reply->writeNoException();
Mathias Agopian3cf61352010-02-09 17:46:37 -0800315 return NO_ERROR;
316 } break;
Eino-Ville Talvala1ce7c342013-08-21 13:57:21 -0700317 case SET_PREVIEW_TARGET: {
318 ALOGV("SET_PREVIEW_TARGET");
Jamie Gennisbfa33aa2010-12-20 11:51:31 -0800319 CHECK_INTERFACE(ICamera, data, reply);
Andy McFadden8ba01022012-12-18 09:46:54 -0800320 sp<IGraphicBufferProducer> st =
321 interface_cast<IGraphicBufferProducer>(data.readStrongBinder());
Eino-Ville Talvala1ce7c342013-08-21 13:57:21 -0700322 reply->writeInt32(setPreviewTarget(st));
Jamie Gennisbfa33aa2010-12-20 11:51:31 -0800323 return NO_ERROR;
324 } break;
Mathias Agopian3cf61352010-02-09 17:46:37 -0800325 case SET_PREVIEW_CALLBACK_FLAG: {
Steve Block3856b092011-10-20 11:56:00 +0100326 ALOGV("SET_PREVIEW_CALLBACK_TYPE");
Mathias Agopian3cf61352010-02-09 17:46:37 -0800327 CHECK_INTERFACE(ICamera, data, reply);
328 int callback_flag = data.readInt32();
329 setPreviewCallbackFlag(callback_flag);
330 return NO_ERROR;
331 } break;
Eino-Ville Talvala3ee35502013-04-02 15:45:11 -0700332 case SET_PREVIEW_CALLBACK_TARGET: {
333 ALOGV("SET_PREVIEW_CALLBACK_TARGET");
334 CHECK_INTERFACE(ICamera, data, reply);
335 sp<IGraphicBufferProducer> cp =
336 interface_cast<IGraphicBufferProducer>(data.readStrongBinder());
337 reply->writeInt32(setPreviewCallbackTarget(cp));
338 return NO_ERROR;
339 }
Mathias Agopian3cf61352010-02-09 17:46:37 -0800340 case START_PREVIEW: {
Steve Block3856b092011-10-20 11:56:00 +0100341 ALOGV("START_PREVIEW");
Mathias Agopian3cf61352010-02-09 17:46:37 -0800342 CHECK_INTERFACE(ICamera, data, reply);
343 reply->writeInt32(startPreview());
344 return NO_ERROR;
345 } break;
346 case START_RECORDING: {
Steve Block3856b092011-10-20 11:56:00 +0100347 ALOGV("START_RECORDING");
Mathias Agopian3cf61352010-02-09 17:46:37 -0800348 CHECK_INTERFACE(ICamera, data, reply);
349 reply->writeInt32(startRecording());
350 return NO_ERROR;
351 } break;
352 case STOP_PREVIEW: {
Steve Block3856b092011-10-20 11:56:00 +0100353 ALOGV("STOP_PREVIEW");
Mathias Agopian3cf61352010-02-09 17:46:37 -0800354 CHECK_INTERFACE(ICamera, data, reply);
355 stopPreview();
356 return NO_ERROR;
357 } break;
358 case STOP_RECORDING: {
Steve Block3856b092011-10-20 11:56:00 +0100359 ALOGV("STOP_RECORDING");
Mathias Agopian3cf61352010-02-09 17:46:37 -0800360 CHECK_INTERFACE(ICamera, data, reply);
361 stopRecording();
362 return NO_ERROR;
363 } break;
364 case RELEASE_RECORDING_FRAME: {
Steve Block3856b092011-10-20 11:56:00 +0100365 ALOGV("RELEASE_RECORDING_FRAME");
Mathias Agopian3cf61352010-02-09 17:46:37 -0800366 CHECK_INTERFACE(ICamera, data, reply);
367 sp<IMemory> mem = interface_cast<IMemory>(data.readStrongBinder());
Praveen Chavan6773d472016-01-13 01:24:30 -0800368
369 if (CameraUtils::isNativeHandleMetadata(mem)) {
370 VideoNativeHandleMetadata *metadata =
371 (VideoNativeHandleMetadata*)(mem->pointer());
372 metadata->pHandle = data.readNativeHandle();
373 // releaseRecordingFrame will be responsble to close the native handle.
374 }
375
Mathias Agopian3cf61352010-02-09 17:46:37 -0800376 releaseRecordingFrame(mem);
377 return NO_ERROR;
378 } break;
Chien-Yu Chen8cca0752015-11-13 15:28:48 -0800379 case SET_VIDEO_BUFFER_MODE: {
380 ALOGV("SET_VIDEO_BUFFER_MODE");
James Donge2ad6732010-10-18 20:42:51 -0700381 CHECK_INTERFACE(ICamera, data, reply);
Chien-Yu Chen8cca0752015-11-13 15:28:48 -0800382 int32_t mode = data.readInt32();
383 reply->writeInt32(setVideoBufferMode(mode));
James Donge2ad6732010-10-18 20:42:51 -0700384 return NO_ERROR;
385 } break;
Mathias Agopian3cf61352010-02-09 17:46:37 -0800386 case PREVIEW_ENABLED: {
Steve Block3856b092011-10-20 11:56:00 +0100387 ALOGV("PREVIEW_ENABLED");
Mathias Agopian3cf61352010-02-09 17:46:37 -0800388 CHECK_INTERFACE(ICamera, data, reply);
389 reply->writeInt32(previewEnabled());
390 return NO_ERROR;
391 } break;
392 case RECORDING_ENABLED: {
Steve Block3856b092011-10-20 11:56:00 +0100393 ALOGV("RECORDING_ENABLED");
Mathias Agopian3cf61352010-02-09 17:46:37 -0800394 CHECK_INTERFACE(ICamera, data, reply);
395 reply->writeInt32(recordingEnabled());
396 return NO_ERROR;
397 } break;
398 case AUTO_FOCUS: {
Steve Block3856b092011-10-20 11:56:00 +0100399 ALOGV("AUTO_FOCUS");
Mathias Agopian3cf61352010-02-09 17:46:37 -0800400 CHECK_INTERFACE(ICamera, data, reply);
401 reply->writeInt32(autoFocus());
402 return NO_ERROR;
403 } break;
404 case CANCEL_AUTO_FOCUS: {
Steve Block3856b092011-10-20 11:56:00 +0100405 ALOGV("CANCEL_AUTO_FOCUS");
Mathias Agopian3cf61352010-02-09 17:46:37 -0800406 CHECK_INTERFACE(ICamera, data, reply);
407 reply->writeInt32(cancelAutoFocus());
408 return NO_ERROR;
409 } break;
410 case TAKE_PICTURE: {
Steve Block3856b092011-10-20 11:56:00 +0100411 ALOGV("TAKE_PICTURE");
Mathias Agopian3cf61352010-02-09 17:46:37 -0800412 CHECK_INTERFACE(ICamera, data, reply);
James Donge468ac52011-02-17 16:38:06 -0800413 int msgType = data.readInt32();
414 reply->writeInt32(takePicture(msgType));
Mathias Agopian3cf61352010-02-09 17:46:37 -0800415 return NO_ERROR;
416 } break;
417 case SET_PARAMETERS: {
Steve Block3856b092011-10-20 11:56:00 +0100418 ALOGV("SET_PARAMETERS");
Mathias Agopian3cf61352010-02-09 17:46:37 -0800419 CHECK_INTERFACE(ICamera, data, reply);
420 String8 params(data.readString8());
421 reply->writeInt32(setParameters(params));
422 return NO_ERROR;
423 } break;
424 case GET_PARAMETERS: {
Steve Block3856b092011-10-20 11:56:00 +0100425 ALOGV("GET_PARAMETERS");
Mathias Agopian3cf61352010-02-09 17:46:37 -0800426 CHECK_INTERFACE(ICamera, data, reply);
427 reply->writeString8(getParameters());
428 return NO_ERROR;
429 } break;
430 case SEND_COMMAND: {
Steve Block3856b092011-10-20 11:56:00 +0100431 ALOGV("SEND_COMMAND");
Mathias Agopian3cf61352010-02-09 17:46:37 -0800432 CHECK_INTERFACE(ICamera, data, reply);
433 int command = data.readInt32();
434 int arg1 = data.readInt32();
435 int arg2 = data.readInt32();
436 reply->writeInt32(sendCommand(command, arg1, arg2));
437 return NO_ERROR;
438 } break;
439 case CONNECT: {
440 CHECK_INTERFACE(ICamera, data, reply);
441 sp<ICameraClient> cameraClient = interface_cast<ICameraClient>(data.readStrongBinder());
442 reply->writeInt32(connect(cameraClient));
443 return NO_ERROR;
444 } break;
445 case LOCK: {
446 CHECK_INTERFACE(ICamera, data, reply);
447 reply->writeInt32(lock());
448 return NO_ERROR;
449 } break;
450 case UNLOCK: {
451 CHECK_INTERFACE(ICamera, data, reply);
452 reply->writeInt32(unlock());
453 return NO_ERROR;
454 } break;
Chien-Yu Chen8cca0752015-11-13 15:28:48 -0800455 case SET_VIDEO_BUFFER_TARGET: {
456 ALOGV("SET_VIDEO_BUFFER_TARGET");
457 CHECK_INTERFACE(ICamera, data, reply);
458 sp<IGraphicBufferProducer> st =
459 interface_cast<IGraphicBufferProducer>(data.readStrongBinder());
460 reply->writeInt32(setVideoTarget(st));
461 return NO_ERROR;
462 } break;
Mathias Agopian3cf61352010-02-09 17:46:37 -0800463 default:
464 return BBinder::onTransact(code, data, reply, flags);
465 }
466}
467
468// ----------------------------------------------------------------------------
469
470}; // namespace android