From 618ff8a48a0c895a78f91f5692510c2a809425c3 Mon Sep 17 00:00:00 2001 From: Chien-Yu Chen Date: Fri, 13 Mar 2015 11:27:17 -0700 Subject: camera2: add reprocess support Add support to create input stream, submit reprocess capture requests, and receive reprocess capture results. Change-Id: Iee2d4313f3d52616a484eaea7a28f5ef9d8a674b --- camera/camera2/CaptureRequest.cpp | 9 +++++ camera/camera2/ICameraDeviceUser.cpp | 74 ++++++++++++++++++++++++++++++++++++ 2 files changed, 83 insertions(+) (limited to 'camera') diff --git a/camera/camera2/CaptureRequest.cpp b/camera/camera2/CaptureRequest.cpp index 66d6913..4217bc6 100644 --- a/camera/camera2/CaptureRequest.cpp +++ b/camera/camera2/CaptureRequest.cpp @@ -81,6 +81,13 @@ status_t CaptureRequest::readFromParcel(Parcel* parcel) { mSurfaceList.push_back(surface); } + int isReprocess = 0; + if ((err = parcel->readInt32(&isReprocess)) != OK) { + ALOGE("%s: Failed to read reprocessing from parcel", __FUNCTION__); + return err; + } + mIsReprocess = (isReprocess != 0); + return OK; } @@ -118,6 +125,8 @@ status_t CaptureRequest::writeToParcel(Parcel* parcel) const { parcel->writeStrongBinder(binder); } + parcel->writeInt32(mIsReprocess ? 1 : 0); + return OK; } diff --git a/camera/camera2/ICameraDeviceUser.cpp b/camera/camera2/ICameraDeviceUser.cpp index 89c6fb7..2ec08a9 100644 --- a/camera/camera2/ICameraDeviceUser.cpp +++ b/camera/camera2/ICameraDeviceUser.cpp @@ -42,6 +42,8 @@ enum { END_CONFIGURE, DELETE_STREAM, CREATE_STREAM, + CREATE_INPUT_STREAM, + GET_INPUT_SURFACE, CREATE_DEFAULT_REQUEST, GET_CAMERA_INFO, WAIT_UNTIL_IDLE, @@ -225,6 +227,50 @@ public: return reply.readInt32(); } + virtual status_t createInputStream(int width, int height, int format) + { + Parcel data, reply; + data.writeInterfaceToken(ICameraDeviceUser::getInterfaceDescriptor()); + data.writeInt32(width); + data.writeInt32(height); + data.writeInt32(format); + + remote()->transact(CREATE_INPUT_STREAM, data, &reply); + + reply.readExceptionCode(); + return reply.readInt32(); + } + + // get the buffer producer of the input stream + virtual status_t getInputBufferProducer( + sp *producer) { + if (producer == NULL) { + return BAD_VALUE; + } + + Parcel data, reply; + data.writeInterfaceToken(ICameraDeviceUser::getInterfaceDescriptor()); + + remote()->transact(GET_INPUT_SURFACE, data, &reply); + + reply.readExceptionCode(); + status_t result = reply.readInt32() ; + if (result != OK) { + return result; + } + + sp bp = NULL; + if (reply.readInt32() != 0) { + String16 name = readMaybeEmptyString16(reply); + bp = interface_cast( + reply.readStrongBinder()); + } + + *producer = bp; + + return *producer == NULL ? INVALID_OPERATION : OK; + } + // Create a request object from a template. virtual status_t createDefaultRequest(int templateId, /*out*/ @@ -409,7 +455,35 @@ status_t BnCameraDeviceUser::onTransact( return NO_ERROR; } break; + case CREATE_INPUT_STREAM: { + CHECK_INTERFACE(ICameraDeviceUser, data, reply); + int width, height, format; + + width = data.readInt32(); + height = data.readInt32(); + format = data.readInt32(); + status_t ret = createInputStream(width, height, format); + + reply->writeNoException(); + reply->writeInt32(ret); + return NO_ERROR; + + } break; + case GET_INPUT_SURFACE: { + CHECK_INTERFACE(ICameraDeviceUser, data, reply); + + sp bp; + status_t ret = getInputBufferProducer(&bp); + sp b(IInterface::asBinder(ret == OK ? bp : NULL)); + + reply->writeNoException(); + reply->writeInt32(ret); + reply->writeInt32(1); + reply->writeString16(String16("camera input")); // name of surface + reply->writeStrongBinder(b); + return NO_ERROR; + } break; case CREATE_DEFAULT_REQUEST: { CHECK_INTERFACE(ICameraDeviceUser, data, reply); -- cgit v1.1