本文整理汇总了C++中Parcel::readNativeHandle方法的典型用法代码示例。如果您正苦于以下问题:C++ Parcel::readNativeHandle方法的具体用法?C++ Parcel::readNativeHandle怎么用?C++ Parcel::readNativeHandle使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Parcel
的用法示例。
在下文中一共展示了Parcel::readNativeHandle方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: OverlayRef
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;
}
示例2: onTransact
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);
}
}
示例3: ImageBuffer
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;
}
示例4: onTransact
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);
}
}