Bug 990761 - handle HDR sending us more than one picture, r=dhylands
authorMike Habicher <mikeh@mozilla.com>
Wed, 16 Apr 2014 21:46:36 -0400
changeset 191010 4953b30842cd880557ddd5ebf359469d3d6946cd
parent 191009 41151cd34e44cd94190a6ffbb9a65abd5bec09a5
child 191011 2e6155d9aac74067d712cbf719ddc1281f0d4dcb
push id5832
push userraliiev@mozilla.com
push dateMon, 28 Apr 2014 18:43:22 +0000
treeherdermozilla-aurora@4974d9da2f7d [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersdhylands
bugs990761
milestone31.0a1
Bug 990761 - handle HDR sending us more than one picture, r=dhylands
dom/camera/GonkCameraControl.cpp
dom/camera/GonkCameraControl.h
dom/camera/GonkCameraParameters.cpp
dom/camera/GonkCameraParameters.h
dom/camera/ICameraControl.h
--- a/dom/camera/GonkCameraControl.cpp
+++ b/dom/camera/GonkCameraControl.cpp
@@ -134,16 +134,18 @@ nsGonkCameraControl::Initialize()
 
   DOM_CAMERA_LOGI("Initializing camera %d (this=%p, mCameraHw=%p)\n", mCameraId, this, mCameraHw.get());
 
   // Initialize our camera configuration database.
   PullParametersImpl();
 
   // Set preferred preview frame format.
   mParams.Set(CAMERA_PARAM_PREVIEWFORMAT, NS_LITERAL_STRING("yuv420sp"));
+  // Turn off any normal pictures returned by the HDR scene mode
+  mParams.Set(CAMERA_PARAM_SCENEMODE_HDR_RETURNNORMALPICTURE, false);
   PushParametersImpl();
 
   // Grab any other settings we'll need later.
   mParams.Get(CAMERA_PARAM_PICTURE_FILEFORMAT, mFileFormat);
   mParams.Get(CAMERA_PARAM_THUMBNAILSIZE, mLastThumbnailSize);
 
   // The emulator's camera returns -1 for these values; bump them up to 0
   int areas;
--- a/dom/camera/GonkCameraControl.h
+++ b/dom/camera/GonkCameraControl.h
@@ -142,17 +142,16 @@ protected:
   Size                      mLastPictureSize;
   Size                      mLastThumbnailSize;
   Size                      mLastRecorderSize;
   uint32_t                  mPreviewFps;
   bool                      mResumePreviewAfterTakingPicture;
   bool                      mFlashSupported;
   bool                      mLuminanceSupported;
   bool                      mAutoFlashModeOverridden;
-
   Atomic<uint32_t>          mDeferConfigUpdate;
   GonkCameraParameters      mParams;
 
   nsRefPtr<mozilla::layers::ImageContainer> mImageContainer;
 
   android::MediaProfiles*   mMediaProfiles;
   nsRefPtr<android::GonkRecorder> mRecorder;
 
--- a/dom/camera/GonkCameraParameters.cpp
+++ b/dom/camera/GonkCameraParameters.cpp
@@ -76,16 +76,20 @@ GonkCameraParameters::Parameters::GetTex
     case CAMERA_PARAM_VIDEOSIZE:
       return KEY_VIDEO_SIZE;
     case CAMERA_PARAM_ISOMODE:
       // Not every platform defines KEY_ISO_MODE;
       // for those that don't, we use the raw string key.
       return "iso";
     case CAMERA_PARAM_LUMINANCE:
       return "luminance-condition";
+    case CAMERA_PARAM_SCENEMODE_HDR_RETURNNORMALPICTURE:
+      // Not every platform defines KEY_QC_HDR_NEED_1X;
+      // for those that don't, we use the raw string key.
+      return "hdr-need-1x";
 
     case CAMERA_PARAM_SUPPORTED_PREVIEWSIZES:
       return KEY_SUPPORTED_PREVIEW_SIZES;
     case CAMERA_PARAM_SUPPORTED_PICTURESIZES:
       return KEY_SUPPORTED_PICTURE_SIZES;
     case CAMERA_PARAM_SUPPORTED_VIDEOSIZES:
       return KEY_SUPPORTED_VIDEO_SIZES;
     case CAMERA_PARAM_SUPPORTED_PICTUREFORMATS:
@@ -680,16 +684,29 @@ GonkCameraParameters::GetTranslated(uint
   if (val < 0) {
     return NS_ERROR_FAILURE;
   }
 
   aValue = val;
   return NS_OK;
 }
 
+// Handle bools
+nsresult
+GonkCameraParameters::SetTranslated(uint32_t aKey, const bool& aValue)
+{
+  return SetImpl(aKey, aValue);
+}
+
+nsresult
+GonkCameraParameters::GetTranslated(uint32_t aKey, bool& aValue)
+{
+  return GetImpl(aKey, aValue);
+}
+
 nsresult
 ParseItem(const char* aStart, const char* aEnd, ICameraControl::Size* aItem)
 {
   if (sscanf(aStart, "%ux%u", &aItem->width, &aItem->height) == 2) {
     return NS_OK;
   }
 
   DOM_CAMERA_LOGE("Size tuple has bad format: '%s'\n", __func__, __LINE__, aStart);
--- a/dom/camera/GonkCameraParameters.h
+++ b/dom/camera/GonkCameraParameters.h
@@ -98,23 +98,28 @@ protected:
   nsTArray<nsString> mIsoModes;
 
   // This subclass of android::CameraParameters just gives
   // all of the AOSP getters and setters the same signature.
   class Parameters : public android::CameraParameters
   {
   public:
     using android::CameraParameters::set;
+    using android::CameraParameters::get;
+    using android::CameraParameters::TRUE;
+    using android::CameraParameters::FALSE;
 
     void set(const char* aKey, float aValue)      { setFloat(aKey, aValue); }
     void set(const char* aKey, double aValue)     { setFloat(aKey, aValue); }
+    void set(const char* aKey, bool aValue)       { set(aKey, aValue ? TRUE : FALSE); }
     void get(const char* aKey, float& aRet)       { aRet = getFloat(aKey); }
     void get(const char* aKey, double& aRet)      { aRet = getFloat(aKey); }
-    void get(const char* aKey, const char*& aRet) { aRet = android::CameraParameters::get(aKey); }
+    void get(const char* aKey, const char*& aRet) { aRet = get(aKey); }
     void get(const char* aKey, int& aRet)         { aRet = getInt(aKey); }
+    void get(const char* aKey, bool& aRet)        { aRet = strcmp(get(aKey), FALSE); }
 
     static const char* GetTextKey(uint32_t aKey);
   };
 
   Parameters mParams;
 
   // The *Impl() templates handle converting the parameter keys from
   // their enum values to string types, if necessary. These are the
@@ -168,16 +173,18 @@ protected:
   nsresult SetTranslated(uint32_t aKey, const int64_t& aValue);
   nsresult GetTranslated(uint32_t aKey, int64_t& aValue);
   nsresult SetTranslated(uint32_t aKey, const double& aValue);
   nsresult GetTranslated(uint32_t aKey, double& aValue);
   nsresult SetTranslated(uint32_t aKey, const int& aValue);
   nsresult GetTranslated(uint32_t aKey, int& aValue);
   nsresult SetTranslated(uint32_t aKey, const uint32_t& aValue);
   nsresult GetTranslated(uint32_t aKey, uint32_t& aValue);
+  nsresult SetTranslated(uint32_t aKey, const bool& aValue);
+  nsresult GetTranslated(uint32_t aKey, bool& aValue);
   nsresult GetTranslated(uint32_t aKey, nsTArray<nsString>& aValues);
   nsresult GetTranslated(uint32_t aKey, nsTArray<double>& aValues);
 
   template<class T> nsresult GetListAsArray(uint32_t aKey, nsTArray<T>& aArray);
   nsresult MapIsoToGonk(const nsAString& aIso, nsACString& aIsoOut);
   nsresult MapIsoFromGonk(const char* aIso, nsAString& aIsoOut);
 
   nsresult Initialize();
--- a/dom/camera/ICameraControl.h
+++ b/dom/camera/ICameraControl.h
@@ -46,16 +46,17 @@ enum {
   CAMERA_PARAM_FOCUSDISTANCEOPTIMUM,
   CAMERA_PARAM_FOCUSDISTANCEFAR,
   CAMERA_PARAM_EXPOSURECOMPENSATION,
   CAMERA_PARAM_THUMBNAILSIZE,
   CAMERA_PARAM_THUMBNAILQUALITY,
   CAMERA_PARAM_SENSORANGLE,
   CAMERA_PARAM_ISOMODE,
   CAMERA_PARAM_LUMINANCE,
+  CAMERA_PARAM_SCENEMODE_HDR_RETURNNORMALPICTURE,
 
   // supported features
   CAMERA_PARAM_SUPPORTED_PREVIEWSIZES,
   CAMERA_PARAM_SUPPORTED_PICTURESIZES,
   CAMERA_PARAM_SUPPORTED_VIDEOSIZES,
   CAMERA_PARAM_SUPPORTED_PICTUREFORMATS,
   CAMERA_PARAM_SUPPORTED_WHITEBALANCES,
   CAMERA_PARAM_SUPPORTED_SCENEMODES,