本文整理汇总了C++中Parcel::readUint32方法的典型用法代码示例。如果您正苦于以下问题:C++ Parcel::readUint32方法的具体用法?C++ Parcel::readUint32怎么用?C++ Parcel::readUint32使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Parcel
的用法示例。
在下文中一共展示了Parcel::readUint32方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: read
status_t DisplayState::read(const Parcel& input) {
token = input.readStrongBinder();
surface = interface_cast<IGraphicBufferProducer>(input.readStrongBinder());
what = input.readUint32();
layerStack = input.readUint32();
orientation = input.readUint32();
input.read(viewport);
input.read(frame);
width = input.readUint32();
height = input.readUint32();
return NO_ERROR;
}
示例2: readFromParcel
static void readFromParcel(const Parcel &data, Vector<T> *items) {
size_t size = (size_t)data.readUint32();
for (size_t i = 0; i < size && data.dataAvail() > 0; i++) {
T item;
item.readFromParcel(data);
items->add(item);
}
}
示例3: onTransact
status_t BnGraphicBufferAlloc::onTransact(
uint32_t code, const Parcel& data, Parcel* reply, uint32_t flags)
{
// codes that don't require permission check
// BufferReference just keeps a strong reference to a GraphicBuffer until it
// is destroyed (that is, until no local or remote process have a reference
// to it).
class BufferReference : public BBinder {
sp<GraphicBuffer> mBuffer;
public:
BufferReference(const sp<GraphicBuffer>& buffer) : mBuffer(buffer) {}
};
switch (code) {
case CREATE_GRAPHIC_BUFFER: {
CHECK_INTERFACE(IGraphicBufferAlloc, data, reply);
uint32_t width = data.readUint32();
uint32_t height = data.readUint32();
PixelFormat format = static_cast<PixelFormat>(data.readInt32());
uint32_t usage = data.readUint32();
status_t error;
sp<GraphicBuffer> result =
createGraphicBuffer(width, height, format, usage, &error);
reply->writeInt32(error);
if (result != 0) {
reply->write(*result);
// We add a BufferReference to this parcel to make sure the
// buffer stays alive until the GraphicBuffer object on
// the other side has been created.
// This is needed so that the buffer handle can be
// registered before the buffer is destroyed on implementations
// that do not use file-descriptors to track their buffers.
reply->writeStrongBinder( new BufferReference(result) );
}
return NO_ERROR;
}
default:
return BBinder::onTransact(code, data, reply, flags);
}
}
示例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);
}
}
示例5: onTransact
status_t BnGraphicBufferConsumer::onTransact(
uint32_t code, const Parcel& data, Parcel* reply, uint32_t flags)
{
switch(code) {
case ACQUIRE_BUFFER: {
CHECK_INTERFACE(IGraphicBufferConsumer, data, reply);
BufferItem item;
int64_t presentWhen = data.readInt64();
uint64_t maxFrameNumber = data.readUint64();
status_t result = acquireBuffer(&item, presentWhen, maxFrameNumber);
status_t err = reply->write(item);
if (err) return err;
reply->writeInt32(result);
return NO_ERROR;
}
case DETACH_BUFFER: {
CHECK_INTERFACE(IGraphicBufferConsumer, data, reply);
int slot = data.readInt32();
int result = detachBuffer(slot);
reply->writeInt32(result);
return NO_ERROR;
}
case ATTACH_BUFFER: {
CHECK_INTERFACE(IGraphicBufferConsumer, data, reply);
sp<GraphicBuffer> buffer = new GraphicBuffer();
data.read(*buffer.get());
int slot = -1;
int result = attachBuffer(&slot, buffer);
reply->writeInt32(slot);
reply->writeInt32(result);
return NO_ERROR;
}
case RELEASE_BUFFER: {
CHECK_INTERFACE(IGraphicBufferConsumer, data, reply);
int buf = data.readInt32();
uint64_t frameNumber = static_cast<uint64_t>(data.readInt64());
sp<Fence> releaseFence = new Fence();
status_t err = data.read(*releaseFence);
if (err) return err;
status_t result = releaseBuffer(buf, frameNumber,
EGL_NO_DISPLAY, EGL_NO_SYNC_KHR, releaseFence);
reply->writeInt32(result);
return NO_ERROR;
}
case CONSUMER_CONNECT: {
CHECK_INTERFACE(IGraphicBufferConsumer, data, reply);
sp<IConsumerListener> consumer = IConsumerListener::asInterface( data.readStrongBinder() );
bool controlledByApp = data.readInt32();
status_t result = consumerConnect(consumer, controlledByApp);
reply->writeInt32(result);
return NO_ERROR;
}
case CONSUMER_DISCONNECT: {
CHECK_INTERFACE(IGraphicBufferConsumer, data, reply);
status_t result = consumerDisconnect();
reply->writeInt32(result);
return NO_ERROR;
}
case GET_RELEASED_BUFFERS: {
CHECK_INTERFACE(IGraphicBufferConsumer, data, reply);
uint64_t slotMask = 0;
status_t result = getReleasedBuffers(&slotMask);
reply->writeInt64(static_cast<int64_t>(slotMask));
reply->writeInt32(result);
return NO_ERROR;
}
case SET_DEFAULT_BUFFER_SIZE: {
CHECK_INTERFACE(IGraphicBufferConsumer, data, reply);
uint32_t width = data.readUint32();
uint32_t height = data.readUint32();
status_t result = setDefaultBufferSize(width, height);
reply->writeInt32(result);
return NO_ERROR;
}
case SET_MAX_BUFFER_COUNT: {
CHECK_INTERFACE(IGraphicBufferConsumer, data, reply);
int bufferCount = data.readInt32();
status_t result = setMaxBufferCount(bufferCount);
reply->writeInt32(result);
return NO_ERROR;
}
case SET_MAX_ACQUIRED_BUFFER_COUNT: {
CHECK_INTERFACE(IGraphicBufferConsumer, data, reply);
int maxAcquiredBuffers = data.readInt32();
status_t result = setMaxAcquiredBufferCount(maxAcquiredBuffers);
reply->writeInt32(result);
return NO_ERROR;
}
case SET_CONSUMER_NAME: {
CHECK_INTERFACE(IGraphicBufferConsumer, data, reply);
setConsumerName( data.readString8() );
return NO_ERROR;
}
case SET_DEFAULT_BUFFER_FORMAT: {
CHECK_INTERFACE(IGraphicBufferConsumer, data, reply);
PixelFormat defaultFormat = static_cast<PixelFormat>(data.readInt32());
status_t result = setDefaultBufferFormat(defaultFormat);
reply->writeInt32(result);
return NO_ERROR;
}
//.........这里部分代码省略.........