From 49025fcfffd9935254e55ed84133f9437c286372 Mon Sep 17 00:00:00 2001 From: Mike Habicher Date: Tue, 18 Dec 2012 18:19:38 -0500 Subject: [PATCH] Bug 822531 - Fix regression of bug 783682 caused by bug 779139. r=mwu --- dom/camera/GonkCameraControl.cpp | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/dom/camera/GonkCameraControl.cpp b/dom/camera/GonkCameraControl.cpp index 588409bb1340..08daf0bd6b8b 100644 --- a/dom/camera/GonkCameraControl.cpp +++ b/dom/camera/GonkCameraControl.cpp @@ -47,6 +47,16 @@ using namespace mozilla::dom; using namespace mozilla::layers; using namespace android; +/** + * See bug 783682. Most camera implementations, despite claiming they + * support 'yuv420p' as a preview format, actually ignore this setting + * and return 'yuv420sp' data anyway. We have come across a new implementation + * that, while reporting that 'yuv420p' is supported *and* has been accepted, + * still returns the frame data in 'yuv420sp' anyway. So for now, since + * everyone seems to return this format, we just force it. + */ +#define FORCE_PREVIEW_FORMAT_YUV420SP 1 + static const char* getKeyText(uint32_t aKey) { switch (aKey) { @@ -189,7 +199,11 @@ nsGonkCameraControl::nsGonkCameraControl(uint32_t aCameraId, nsIThread* aCameraT , mHeight(0) , mLastPictureWidth(0) , mLastPictureHeight(0) +#if !FORCE_PREVIEW_FORMAT_YUV420SP , mFormat(PREVIEW_FORMAT_UNKNOWN) +#else + , mFormat(PREVIEW_FORMAT_YUV420SP) +#endif , mFps(30) , mDiscardedFrameCount(0) , mMediaProfiles(nullptr) @@ -217,15 +231,21 @@ nsGonkCameraControl::Init() PullParametersImpl(); // Try to set preferred image format and frame rate +#if !FORCE_PREVIEW_FORMAT_YUV420SP DOM_CAMERA_LOGI("Camera preview formats: %s\n", mParams.get(mParams.KEY_SUPPORTED_PREVIEW_FORMATS)); const char* const PREVIEW_FORMAT = "yuv420p"; const char* const BAD_PREVIEW_FORMAT = "yuv420sp"; mParams.setPreviewFormat(PREVIEW_FORMAT); mParams.setPreviewFrameRate(mFps); +#else + mParams.setPreviewFormat("yuv420sp"); + mParams.setPreviewFrameRate(mFps); +#endif PushParametersImpl(); // Check that our settings stuck PullParametersImpl(); +#if !FORCE_PREVIEW_FORMAT_YUV420SP const char* format = mParams.getPreviewFormat(); if (strcmp(format, PREVIEW_FORMAT) == 0) { mFormat = PREVIEW_FORMAT_YUV420P; /* \o/ */ @@ -236,6 +256,7 @@ nsGonkCameraControl::Init() mFormat = PREVIEW_FORMAT_UNKNOWN; DOM_CAMERA_LOGE("Camera ignored our request for '%s' preview, returned UNSUPPORTED format '%s'\n", PREVIEW_FORMAT, format); } +#endif // Check the frame rate and log if the camera ignored our setting uint32_t fps = mParams.getPreviewFrameRate();