Bug 822531 - Fix regression of bug 783682 caused by bug 779139. r=mwu
authorMike Habicher <mikeh@mozilla.com>
Tue, 18 Dec 2012 18:19:38 -0500
changeset 116461 03b9ac3761463acbd5780afcf250de51520ea884
parent 116460 7286dac152917c6c422da100ecf6b963ca37fb87
child 116462 b3d7e749388b30ae5765e62ae7393c6efd87e086
push id24052
push useremorley@mozilla.com
push dateWed, 19 Dec 2012 19:30:46 +0000
treeherdermozilla-central@27a1c1839d42 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmwu
bugs822531, 783682, 779139
milestone20.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 822531 - Fix regression of bug 783682 caused by bug 779139. r=mwu
dom/camera/GonkCameraControl.cpp
--- a/dom/camera/GonkCameraControl.cpp
+++ b/dom/camera/GonkCameraControl.cpp
@@ -42,16 +42,26 @@
 #include "GonkCameraControl.h"
 #include "CameraCommon.h"
 
 using namespace mozilla;
 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) {
     case CAMERA_PARAM_EFFECT:
       return CameraParameters::KEY_EFFECT;
     case CAMERA_PARAM_WHITEBALANCE:
       return CameraParameters::KEY_WHITE_BALANCE;
     case CAMERA_PARAM_SCENEMODE:
@@ -184,17 +194,21 @@ nsGonkCameraControl::nsGonkCameraControl
   , mHwHandle(0)
   , mExposureCompensationMin(0.0)
   , mExposureCompensationStep(0.0)
   , mDeferConfigUpdate(false)
   , mWidth(0)
   , 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)
   , mRecorder(nullptr)
   , mProfileManager(nullptr)
   , mRecorderProfile(nullptr)
   , mVideoFile(nullptr)
 {
@@ -212,35 +226,42 @@ nsGonkCameraControl::Init()
 {
   mHwHandle = GonkCameraHardware::GetHandle(this, mCameraId);
   DOM_CAMERA_LOGI("Initializing camera %d (this=%p, mHwHandle=%d)\n", mCameraId, this, mHwHandle);
 
   // Initialize our camera configuration database.
   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/ */
   } else if (strcmp(format, BAD_PREVIEW_FORMAT) == 0) {
     mFormat = PREVIEW_FORMAT_YUV420SP;
     DOM_CAMERA_LOGA("Camera ignored our request for '%s' preview, will have to convert (from %d)\n", PREVIEW_FORMAT, mFormat);
   } else {
     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();
   if (fps != mFps) {
     DOM_CAMERA_LOGA("We asked for %d fps but camera returned %d fps, using that", mFps, fps);
     mFps = fps;
   }