summaryrefslogtreecommitdiffstats
path: root/media
diff options
context:
space:
mode:
authorRuben Brunk <rubenbrunk@google.com>2014-05-09 19:58:49 -0700
committerRuben Brunk <rubenbrunk@google.com>2014-05-21 16:37:59 -0700
commitfeb50af361e4305a25758966b6b5df2738c00259 (patch)
treeb20b9bcaf34685467c1317d0835242cd7c8135c9 /media
parent2a2dace66500d6057b9dc87bbe9597d7302ec914 (diff)
downloadframeworks_base-feb50af361e4305a25758966b6b5df2738c00259.zip
frameworks_base-feb50af361e4305a25758966b6b5df2738c00259.tar.gz
frameworks_base-feb50af361e4305a25758966b6b5df2738c00259.tar.bz2
camera2: Add HAL1 compatibility shim skeleton.
This adds basic support for running the Camera2 API on a device running a camera HAL version lower than CAMERA_MODULE_API_VERSION_2_0. This CL includes support for: - N-way preview output streams - N-way jpeg output streams - CameraDevice emulation at the binder interface - Basic camera metadata querying in the CameraManager Bug: 15117269 Bug: 15116722 Change-Id: I8322955034c91f34bb348d4b28c2b774dbef38f6
Diffstat (limited to 'media')
-rw-r--r--media/jni/android_media_ImageReader.cpp39
1 files changed, 24 insertions, 15 deletions
diff --git a/media/jni/android_media_ImageReader.cpp b/media/jni/android_media_ImageReader.cpp
index 7a86811..36cfb0f 100644
--- a/media/jni/android_media_ImageReader.cpp
+++ b/media/jni/android_media_ImageReader.cpp
@@ -764,21 +764,30 @@ static jint ImageReader_imageSetup(JNIEnv* env, jobject thiz,
return -1;
}
- if (ctx->getBufferFormat() != buffer->format) {
- // Return the buffer to the queue.
- consumer->unlockBuffer(*buffer);
- ctx->returnLockedBuffer(buffer);
-
- // Throw exception
- ALOGE("Producer output buffer format: 0x%x, ImageReader configured format: 0x%x",
- buffer->format, ctx->getBufferFormat());
- String8 msg;
- msg.appendFormat("The producer output buffer format 0x%x doesn't "
- "match the ImageReader's configured buffer format 0x%x.",
- buffer->format, ctx->getBufferFormat());
- jniThrowException(env, "java/lang/UnsupportedOperationException",
- msg.string());
- return -1;
+ int imgReaderFmt = ctx->getBufferFormat();
+ int bufFmt = buffer->format;
+ if (imgReaderFmt != bufFmt) {
+ // Special casing for when producer switches format
+ if (imgReaderFmt == HAL_PIXEL_FORMAT_YCbCr_420_888 && bufFmt ==
+ HAL_PIXEL_FORMAT_YCrCb_420_SP) {
+ ctx->setBufferFormat(HAL_PIXEL_FORMAT_YCrCb_420_SP);
+ ALOGV("%s: Overriding NV21 to YUV_420_888.", __FUNCTION__);
+ } else {
+ // Return the buffer to the queue.
+ consumer->unlockBuffer(*buffer);
+ ctx->returnLockedBuffer(buffer);
+
+ // Throw exception
+ ALOGE("Producer output buffer format: 0x%x, ImageReader configured format: 0x%x",
+ buffer->format, ctx->getBufferFormat());
+ String8 msg;
+ msg.appendFormat("The producer output buffer format 0x%x doesn't "
+ "match the ImageReader's configured buffer format 0x%x.",
+ buffer->format, ctx->getBufferFormat());
+ jniThrowException(env, "java/lang/UnsupportedOperationException",
+ msg.string());
+ return -1;
+ }
}
// Set SurfaceImage instance member variables
Image_setBuffer(env, image, buffer);