summaryrefslogtreecommitdiffstats
path: root/camera/camera2
diff options
context:
space:
mode:
Diffstat (limited to 'camera/camera2')
-rw-r--r--camera/camera2/CaptureRequest.cpp9
-rw-r--r--camera/camera2/ICameraDeviceCallbacks.cpp22
-rw-r--r--camera/camera2/ICameraDeviceUser.cpp171
-rw-r--r--camera/camera2/OutputConfiguration.cpp84
4 files changed, 251 insertions, 35 deletions
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/ICameraDeviceCallbacks.cpp b/camera/camera2/ICameraDeviceCallbacks.cpp
index 4cc7b5d..f599879 100644
--- a/camera/camera2/ICameraDeviceCallbacks.cpp
+++ b/camera/camera2/ICameraDeviceCallbacks.cpp
@@ -37,6 +37,7 @@ enum {
CAMERA_IDLE,
CAPTURE_STARTED,
RESULT_RECEIVED,
+ PREPARED
};
class BpCameraDeviceCallbacks: public BpInterface<ICameraDeviceCallbacks>
@@ -80,7 +81,6 @@ public:
data.writeNoException();
}
-
void onResultReceived(const CameraMetadata& metadata,
const CaptureResultExtras& resultExtras) {
ALOGV("onResultReceived");
@@ -93,6 +93,17 @@ public:
remote()->transact(RESULT_RECEIVED, data, &reply, IBinder::FLAG_ONEWAY);
data.writeNoException();
}
+
+ void onPrepared(int streamId)
+ {
+ ALOGV("onPrepared");
+ Parcel data, reply;
+ data.writeInterfaceToken(ICameraDeviceCallbacks::getInterfaceDescriptor());
+ data.writeInt32(streamId);
+ remote()->transact(PREPARED, data, &reply, IBinder::FLAG_ONEWAY);
+ data.writeNoException();
+ }
+
};
IMPLEMENT_META_INTERFACE(CameraDeviceCallbacks,
@@ -160,6 +171,15 @@ status_t BnCameraDeviceCallbacks::onTransact(
data.readExceptionCode();
return NO_ERROR;
} break;
+ case PREPARED: {
+ ALOGV("onPrepared");
+ CHECK_INTERFACE(ICameraDeviceCallbacks, data, reply);
+ CaptureResultExtras result;
+ int streamId = data.readInt32();
+ onPrepared(streamId);
+ data.readExceptionCode();
+ return NO_ERROR;
+ } break;
default:
return BBinder::onTransact(code, data, reply, flags);
}
diff --git a/camera/camera2/ICameraDeviceUser.cpp b/camera/camera2/ICameraDeviceUser.cpp
index 277b5db..d2dc200 100644
--- a/camera/camera2/ICameraDeviceUser.cpp
+++ b/camera/camera2/ICameraDeviceUser.cpp
@@ -26,6 +26,7 @@
#include <gui/Surface.h>
#include <camera/CameraMetadata.h>
#include <camera/camera2/CaptureRequest.h>
+#include <camera/camera2/OutputConfiguration.h>
namespace android {
@@ -41,10 +42,14 @@ enum {
END_CONFIGURE,
DELETE_STREAM,
CREATE_STREAM,
+ CREATE_INPUT_STREAM,
+ GET_INPUT_SURFACE,
CREATE_DEFAULT_REQUEST,
GET_CAMERA_INFO,
WAIT_UNTIL_IDLE,
- FLUSH
+ FLUSH,
+ PREPARE,
+ TEAR_DOWN
};
namespace {
@@ -78,7 +83,7 @@ public:
reply.readExceptionCode();
}
- virtual status_t submitRequest(sp<CaptureRequest> request, bool repeating,
+ virtual int submitRequest(sp<CaptureRequest> request, bool repeating,
int64_t *lastFrameNumber)
{
Parcel data, reply;
@@ -107,13 +112,13 @@ public:
}
}
- if ((res < NO_ERROR) || (resFrameNumber != NO_ERROR)) {
+ if (res < 0 || (resFrameNumber != NO_ERROR)) {
res = FAILED_TRANSACTION;
}
return res;
}
- virtual status_t submitRequestList(List<sp<CaptureRequest> > requestList, bool repeating,
+ virtual int submitRequestList(List<sp<CaptureRequest> > requestList, bool repeating,
int64_t *lastFrameNumber)
{
Parcel data, reply;
@@ -147,7 +152,7 @@ public:
resFrameNumber = reply.readInt64(lastFrameNumber);
}
}
- if ((res < NO_ERROR) || (resFrameNumber != NO_ERROR)) {
+ if (res < 0 || (resFrameNumber != NO_ERROR)) {
res = FAILED_TRANSACTION;
}
return res;
@@ -186,11 +191,13 @@ public:
return reply.readInt32();
}
- virtual status_t endConfigure()
+ virtual status_t endConfigure(bool isConstrainedHighSpeed)
{
ALOGV("endConfigure");
Parcel data, reply;
data.writeInterfaceToken(ICameraDeviceUser::getInterfaceDescriptor());
+ data.writeInt32(isConstrainedHighSpeed);
+
remote()->transact(END_CONFIGURE, data, &reply);
reply.readExceptionCode();
return reply.readInt32();
@@ -208,8 +215,23 @@ public:
return reply.readInt32();
}
- virtual status_t createStream(int width, int height, int format,
- const sp<IGraphicBufferProducer>& bufferProducer)
+ virtual status_t createStream(const OutputConfiguration& outputConfiguration)
+ {
+ Parcel data, reply;
+ data.writeInterfaceToken(ICameraDeviceUser::getInterfaceDescriptor());
+ if (outputConfiguration.getGraphicBufferProducer() != NULL) {
+ data.writeInt32(1); // marker that OutputConfiguration is not null. Mimic aidl behavior
+ outputConfiguration.writeToParcel(data);
+ } else {
+ data.writeInt32(0);
+ }
+ remote()->transact(CREATE_STREAM, data, &reply);
+
+ reply.readExceptionCode();
+ return reply.readInt32();
+ }
+
+ virtual status_t createInputStream(int width, int height, int format)
{
Parcel data, reply;
data.writeInterfaceToken(ICameraDeviceUser::getInterfaceDescriptor());
@@ -217,17 +239,42 @@ public:
data.writeInt32(height);
data.writeInt32(format);
- data.writeInt32(1); // marker that bufferProducer is not null
- data.writeString16(String16("unknown_name")); // name of surface
- sp<IBinder> b(IInterface::asBinder(bufferProducer));
- data.writeStrongBinder(b);
-
- remote()->transact(CREATE_STREAM, data, &reply);
+ 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<IGraphicBufferProducer> *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<IGraphicBufferProducer> bp = NULL;
+ if (reply.readInt32() != 0) {
+ String16 name = readMaybeEmptyString16(reply);
+ bp = interface_cast<IGraphicBufferProducer>(
+ reply.readStrongBinder());
+ }
+
+ *producer = bp;
+
+ return *producer == NULL ? INVALID_OPERATION : OK;
+ }
+
// Create a request object from a template.
virtual status_t createDefaultRequest(int templateId,
/*out*/
@@ -305,6 +352,34 @@ public:
return res;
}
+ virtual status_t prepare(int streamId)
+ {
+ ALOGV("prepare");
+ Parcel data, reply;
+
+ data.writeInterfaceToken(ICameraDeviceUser::getInterfaceDescriptor());
+ data.writeInt32(streamId);
+
+ remote()->transact(PREPARE, data, &reply);
+
+ reply.readExceptionCode();
+ return reply.readInt32();
+ }
+
+ virtual status_t tearDown(int streamId)
+ {
+ ALOGV("tearDown");
+ Parcel data, reply;
+
+ data.writeInterfaceToken(ICameraDeviceUser::getInterfaceDescriptor());
+ data.writeInt32(streamId);
+
+ remote()->transact(TEAR_DOWN, data, &reply);
+
+ reply.readExceptionCode();
+ return reply.readInt32();
+ }
+
private:
@@ -396,39 +471,51 @@ status_t BnCameraDeviceUser::onTransact(
} break;
case CREATE_STREAM: {
CHECK_INTERFACE(ICameraDeviceUser, data, reply);
+
+ status_t ret = BAD_VALUE;
+ if (data.readInt32() != 0) {
+ OutputConfiguration outputConfiguration(data);
+ ret = createStream(outputConfiguration);
+ } else {
+ ALOGE("%s: cannot take an empty OutputConfiguration", __FUNCTION__);
+ }
+
+ reply->writeNoException();
+ ALOGV("%s: CREATE_STREAM: write noException", __FUNCTION__);
+ reply->writeInt32(ret);
+ ALOGV("%s: CREATE_STREAM: write ret = %d", __FUNCTION__, ret);
+
+ return NO_ERROR;
+ } break;
+ case CREATE_INPUT_STREAM: {
+ CHECK_INTERFACE(ICameraDeviceUser, data, reply);
int width, height, format;
width = data.readInt32();
- ALOGV("%s: CREATE_STREAM: width = %d", __FUNCTION__, width);
height = data.readInt32();
- ALOGV("%s: CREATE_STREAM: height = %d", __FUNCTION__, height);
format = data.readInt32();
- ALOGV("%s: CREATE_STREAM: format = %d", __FUNCTION__, format);
+ status_t ret = createInputStream(width, height, format);
- sp<IGraphicBufferProducer> bp;
- if (data.readInt32() != 0) {
- String16 name = readMaybeEmptyString16(data);
- bp = interface_cast<IGraphicBufferProducer>(
- data.readStrongBinder());
+ reply->writeNoException();
+ reply->writeInt32(ret);
+ return NO_ERROR;
- ALOGV("%s: CREATE_STREAM: bp = %p, name = %s", __FUNCTION__,
- bp.get(), String8(name).string());
- } else {
- ALOGV("%s: CREATE_STREAM: bp = unset, name = unset",
- __FUNCTION__);
- }
+ } break;
+ case GET_INPUT_SURFACE: {
+ CHECK_INTERFACE(ICameraDeviceUser, data, reply);
- status_t ret;
- ret = createStream(width, height, format, bp);
+ sp<IGraphicBufferProducer> bp;
+ status_t ret = getInputBufferProducer(&bp);
+ sp<IBinder> b(IInterface::asBinder(ret == OK ? bp : NULL));
reply->writeNoException();
- ALOGV("%s: CREATE_STREAM: write noException", __FUNCTION__);
reply->writeInt32(ret);
- ALOGV("%s: CREATE_STREAM: write ret = %d", __FUNCTION__, 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);
@@ -486,10 +573,26 @@ status_t BnCameraDeviceUser::onTransact(
} break;
case END_CONFIGURE: {
CHECK_INTERFACE(ICameraDeviceUser, data, reply);
+ bool isConstrainedHighSpeed = data.readInt32();
reply->writeNoException();
- reply->writeInt32(endConfigure());
+ reply->writeInt32(endConfigure(isConstrainedHighSpeed));
return NO_ERROR;
} break;
+ case PREPARE: {
+ CHECK_INTERFACE(ICameraDeviceUser, data, reply);
+ int streamId = data.readInt32();
+ reply->writeNoException();
+ reply->writeInt32(prepare(streamId));
+ return NO_ERROR;
+ } break;
+ case TEAR_DOWN: {
+ CHECK_INTERFACE(ICameraDeviceUser, data, reply);
+ int streamId = data.readInt32();
+ reply->writeNoException();
+ reply->writeInt32(tearDown(streamId));
+ return NO_ERROR;
+ } break;
+
default:
return BBinder::onTransact(code, data, reply, flags);
}
diff --git a/camera/camera2/OutputConfiguration.cpp b/camera/camera2/OutputConfiguration.cpp
new file mode 100644
index 0000000..20a23e0
--- /dev/null
+++ b/camera/camera2/OutputConfiguration.cpp
@@ -0,0 +1,84 @@
+/*
+**
+** Copyright 2015, The Android Open Source Project
+**
+** Licensed under the Apache License, Version 2.0 (the "License");
+** you may not use this file except in compliance with the License.
+** You may obtain a copy of the License at
+**
+** http://www.apache.org/licenses/LICENSE-2.0
+**
+** Unless required by applicable law or agreed to in writing, software
+** distributed under the License is distributed on an "AS IS" BASIS,
+** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+** See the License for the specific language governing permissions and
+** limitations under the License.
+*/
+
+#define LOG_TAG "OutputConfiguration"
+#include <utils/Log.h>
+
+#include <camera/camera2/OutputConfiguration.h>
+#include <binder/Parcel.h>
+
+namespace android {
+
+
+const int OutputConfiguration::INVALID_ROTATION = -1;
+
+// Read empty strings without printing a false error message.
+String16 OutputConfiguration::readMaybeEmptyString16(const Parcel& parcel) {
+ size_t len;
+ const char16_t* str = parcel.readString16Inplace(&len);
+ if (str != NULL) {
+ return String16(str, len);
+ } else {
+ return String16();
+ }
+}
+
+sp<IGraphicBufferProducer> OutputConfiguration::getGraphicBufferProducer() const {
+ return mGbp;
+}
+
+int OutputConfiguration::getRotation() const {
+ return mRotation;
+}
+
+OutputConfiguration::OutputConfiguration(const Parcel& parcel) {
+ status_t err;
+ int rotation = 0;
+ if ((err = parcel.readInt32(&rotation)) != OK) {
+ ALOGE("%s: Failed to read rotation from parcel", __FUNCTION__);
+ mGbp = NULL;
+ mRotation = INVALID_ROTATION;
+ return;
+ }
+
+ String16 name = readMaybeEmptyString16(parcel);
+ const sp<IGraphicBufferProducer>& gbp =
+ interface_cast<IGraphicBufferProducer>(parcel.readStrongBinder());
+ mGbp = gbp;
+ mRotation = rotation;
+
+ ALOGV("%s: OutputConfiguration: bp = %p, name = %s", __FUNCTION__,
+ gbp.get(), String8(name).string());
+}
+
+OutputConfiguration::OutputConfiguration(sp<IGraphicBufferProducer>& gbp, int rotation) {
+ mGbp = gbp;
+ mRotation = rotation;
+}
+
+status_t OutputConfiguration::writeToParcel(Parcel& parcel) const {
+
+ parcel.writeInt32(mRotation);
+ parcel.writeString16(String16("unknown_name")); // name of surface
+ sp<IBinder> b(IInterface::asBinder(mGbp));
+ parcel.writeStrongBinder(b);
+
+ return OK;
+}
+
+}; // namespace android
+