sp<OverlayRef> OverlayRef::readFromParcel(const Parcel& data) { sp<OverlayRef> result; sp<IOverlay> overlay = IOverlay::asInterface(data.readStrongBinder()); if (overlay != NULL) { uint32_t w = data.readInt32(); uint32_t h = data.readInt32(); uint32_t f = data.readInt32(); uint32_t ws = data.readInt32(); uint32_t hs = data.readInt32(); native_handle* handle = data.readNativeHandle(); result = new OverlayRef(); result->mOverlayHandle = handle; result->mOverlayChannel = overlay; result->mWidth = w; result->mHeight = h; result->mFormat = f; result->mWidthStride = ws; result->mHeightStride = hs; } return result; }
status_t BnCameraRecordingProxy::onTransact( uint32_t code, const Parcel& data, Parcel* reply, uint32_t flags) { switch(code) { case START_RECORDING: { ALOGV("START_RECORDING"); CHECK_INTERFACE(ICameraRecordingProxy, data, reply); sp<ICameraRecordingProxyListener> listener = interface_cast<ICameraRecordingProxyListener>(data.readStrongBinder()); reply->writeInt32(startRecording(listener)); return NO_ERROR; } break; case STOP_RECORDING: { ALOGV("STOP_RECORDING"); CHECK_INTERFACE(ICameraRecordingProxy, data, reply); stopRecording(); return NO_ERROR; } break; case RELEASE_RECORDING_FRAME: { ALOGV("RELEASE_RECORDING_FRAME"); CHECK_INTERFACE(ICameraRecordingProxy, data, reply); sp<IMemory> mem = interface_cast<IMemory>(data.readStrongBinder()); releaseRecordingFrame(mem); return NO_ERROR; } break; case RELEASE_RECORDING_FRAME_HANDLE: { ALOGV("RELEASE_RECORDING_FRAME_HANDLE"); CHECK_INTERFACE(ICameraRecordingProxy, data, reply); // releaseRecordingFrameHandle will be responsble to close the native handle. releaseRecordingFrameHandle(data.readNativeHandle()); return NO_ERROR; } break; default: return BBinder::onTransact(code, data, reply, flags); } }
sp<ImageBuffer> ImageBuffer::readFromParcel(const Parcel& data) { ARX_PRINT(ARX_ZONE_API, "%s\n", __FUNCTION__); sp<ImageBuffer> imBuf = new ImageBuffer(); imBuf->mRemote = true; imBuf->mIndex = data.readInt32(); DVP_Image_t *pImage = &imBuf->mImage; pImage->planes = data.readInt32(); pImage->width = data.readInt32(); pImage->height = data.readInt32(); pImage->bufWidth = data.readInt32(); pImage->bufHeight = data.readInt32(); pImage->x_start = data.readInt32(); pImage->y_start = data.readInt32(); pImage->x_stride = data.readInt32(); pImage->y_stride = data.readInt32(); pImage->color = data.readInt32(); pImage->numBytes = data.readInt32(); pImage->memType = data.readInt32(); if (pImage->memType == DVP_MTYPE_GRALLOC_2DTILED || pImage->memType == DVP_MTYPE_DISPLAY_2DTILED) { pImage->reserved = data.readNativeHandle(); imBuf->mUsingTexture = data.readInt32(); } else { for (uint32_t i = 0; i < pImage->planes; i++) { if (pImage->memType == DVP_MTYPE_MPUCACHED_VIRTUAL_SHARED) { imBuf->mSharedFds[i] = data.readInt32(); } else { imBuf->mSharedFds[i] = dup(data.readFileDescriptor()); } } } return imBuf; }
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); } }