status_t BnCameraClient::onTransact( uint32_t code, const Parcel& data, Parcel* reply, uint32_t flags) { switch(code) { case NOTIFY_CALLBACK: { ALOGV("NOTIFY_CALLBACK"); CHECK_INTERFACE(ICameraClient, data, reply); int32_t msgType = data.readInt32(); int32_t ext1 = data.readInt32(); int32_t ext2 = 0; if ((msgType == CAMERA_MSG_PREVIEW_FRAME) && (ext1 == CAMERA_FRAME_DATA_FD)) { ext2 = data.readFileDescriptor(); ALOGD("onTransact: CAMERA_MSG_PREVIEW_FRAME fd = %d", ext2); } else { ext2 = data.readInt32(); } notifyCallback(msgType, ext1, ext2); return NO_ERROR; } break; case DATA_CALLBACK: { ALOGV("DATA_CALLBACK"); CHECK_INTERFACE(ICameraClient, data, reply); int32_t msgType = data.readInt32(); sp<IMemory> imageData = interface_cast<IMemory>(data.readStrongBinder()); camera_frame_metadata_t *metadata = NULL; if (data.dataAvail() > 0) { metadata = new camera_frame_metadata_t; metadata->number_of_faces = data.readInt32(); metadata->faces = (camera_face_t *) data.readInplace( sizeof(camera_face_t) * metadata->number_of_faces); } dataCallback(msgType, imageData, metadata); if (metadata) delete metadata; return NO_ERROR; } break; case DATA_CALLBACK_TIMESTAMP: { ALOGV("DATA_CALLBACK_TIMESTAMP"); CHECK_INTERFACE(ICameraClient, data, reply); nsecs_t timestamp = data.readInt64(); int32_t msgType = data.readInt32(); sp<IMemory> imageData = interface_cast<IMemory>(data.readStrongBinder()); dataCallbackTimestamp(timestamp, msgType, imageData); return NO_ERROR; } break; default: return BBinder::onTransact(code, data, reply, flags); } }
status_t BnCameraRecordingProxyListener::onTransact( uint32_t code, const Parcel& data, Parcel* reply, uint32_t flags) { switch(code) { case DATA_CALLBACK_TIMESTAMP: { ALOGV("DATA_CALLBACK_TIMESTAMP"); CHECK_INTERFACE(ICameraRecordingProxyListener, data, reply); nsecs_t timestamp = data.readInt64(); int32_t msgType = data.readInt32(); sp<IMemory> imageData = interface_cast<IMemory>(data.readStrongBinder()); dataCallbackTimestamp(timestamp, msgType, imageData); return NO_ERROR; } break; case RECORDING_FRAME_HANDLE_CALLBACK_TIMESTAMP: { ALOGV("RECORDING_FRAME_HANDLE_CALLBACK_TIMESTAMP"); CHECK_INTERFACE(ICameraRecordingProxyListener, data, reply); nsecs_t timestamp; status_t res = data.readInt64(×tamp); if (res != OK) { ALOGE("%s: Failed to read timestamp: %s (%d)", __FUNCTION__, strerror(-res), res); return BAD_VALUE; } native_handle_t* handle = data.readNativeHandle(); if (handle == nullptr) { ALOGE("%s: Received a null native handle", __FUNCTION__); return BAD_VALUE; } // The native handle will be freed in // BpCameraRecordingProxy::releaseRecordingFrameHandle. recordingFrameHandleCallbackTimestamp(timestamp, handle); return NO_ERROR; } break; case RECORDING_FRAME_HANDLE_CALLBACK_TIMESTAMP_BATCH: { ALOGV("RECORDING_FRAME_HANDLE_CALLBACK_TIMESTAMP_BATCH"); CHECK_INTERFACE(ICameraRecordingProxyListener, data, reply); uint32_t n = 0; status_t res = data.readUint32(&n); if (res != OK) { ALOGE("%s: Failed to read batch size: %s (%d)", __FUNCTION__, strerror(-res), res); return BAD_VALUE; } std::vector<nsecs_t> timestamps; std::vector<native_handle_t*> handles; timestamps.reserve(n); handles.reserve(n); for (uint32_t i = 0; i < n; i++) { nsecs_t t; res = data.readInt64(&t); if (res != OK) { ALOGE("%s: Failed to read timestamp[%d]: %s (%d)", __FUNCTION__, i, strerror(-res), res); return BAD_VALUE; } timestamps.push_back(t); } for (uint32_t i = 0; i < n; i++) { native_handle_t* handle = data.readNativeHandle(); if (handle == nullptr) { ALOGE("%s: Received a null native handle at handles[%d]", __FUNCTION__, i); return BAD_VALUE; } handles.push_back(handle); } // The native handle will be freed in // BpCameraRecordingProxy::releaseRecordingFrameHandleBatch. recordingFrameHandleCallbackTimestampBatch(timestamps, handles); return NO_ERROR; } break; default: return BBinder::onTransact(code, data, reply, flags); } }