From feb50af361e4305a25758966b6b5df2738c00259 Mon Sep 17 00:00:00 2001 From: Ruben Brunk Date: Fri, 9 May 2014 19:58:49 -0700 Subject: 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 --- media/jni/android_media_ImageReader.cpp | 39 ++++++++++++++++++++------------- 1 file changed, 24 insertions(+), 15 deletions(-) (limited to 'media') 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); -- cgit v1.1