Bug 1306137 - remove b2g camera code: Remove dom/camera/ and code which depends on it. r=aosmond,bkelly
authorSebastian Hengst <archaeopteryx@coole-files.de>
Tue, 04 Oct 2016 20:16:28 +0200
changeset 363140 09943651fa859ca1c208a0682e34dd32e7a7d8f5
parent 363139 d3e988b1b4808ff99b8174805324edc143df0bfd
child 363141 905f1bc96fb67f7a827387203cb5cafce70b67bf
push id1369
push userjlorenzo@mozilla.com
push dateMon, 27 Feb 2017 14:59:41 +0000
treeherdermozilla-release@d75a1dba431f [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersaosmond, bkelly
bugs1306137
milestone52.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 1306137 - remove b2g camera code: Remove dom/camera/ and code which depends on it. r=aosmond,bkelly MozReview-Commit-ID: 7gvZrDtmcZP
dom/base/Navigator.cpp
dom/base/Navigator.h
dom/base/nsContentPermissionHelper.cpp
dom/base/nsGkAtomList.h
dom/bindings/Bindings.conf
dom/bindings/moz.build
dom/camera/AutoRwLock.h
dom/camera/CameraCommon.h
dom/camera/CameraControlImpl.cpp
dom/camera/CameraControlImpl.h
dom/camera/CameraControlListener.h
dom/camera/CameraPreferences.cpp
dom/camera/CameraPreferences.h
dom/camera/CameraPreviewMediaStream.cpp
dom/camera/CameraPreviewMediaStream.h
dom/camera/DOMCameraCapabilities.cpp
dom/camera/DOMCameraCapabilities.h
dom/camera/DOMCameraControl.cpp
dom/camera/DOMCameraControl.h
dom/camera/DOMCameraControlListener.cpp
dom/camera/DOMCameraControlListener.h
dom/camera/DOMCameraDetectedFace.cpp
dom/camera/DOMCameraDetectedFace.h
dom/camera/DOMCameraManager.cpp
dom/camera/DOMCameraManager.h
dom/camera/FallbackCameraControl.cpp
dom/camera/FallbackCameraManager.cpp
dom/camera/FallbackCameraPlatform.cpp
dom/camera/FallbackCameraPlatform.h
dom/camera/GonkCameraHwMgr.cpp
dom/camera/GonkCameraHwMgr.h
dom/camera/GonkCameraListener.h
dom/camera/GonkCameraManager.cpp
dom/camera/GonkCameraParameters.cpp
dom/camera/GonkCameraParameters.h
dom/camera/GonkCameraSource.cpp
dom/camera/GonkCameraSource.h
dom/camera/GonkRecorder.cpp
dom/camera/GonkRecorder.h
dom/camera/GonkRecorderProfiles.cpp
dom/camera/GonkRecorderProfiles.def
dom/camera/GonkRecorderProfiles.h
dom/camera/ICameraControl.h
dom/camera/README
dom/camera/moz.build
dom/camera/update.patch
dom/camera/update.sh
dom/camera/update2.patch
dom/events/KeyNameList.h
dom/events/test/test_all_synthetic_events.html
dom/html/HTMLMediaElement.cpp
dom/ipc/TabChild.cpp
dom/ipc/TabChild.h
dom/media/DOMMediaStream.cpp
dom/media/DOMMediaStream.h
dom/media/MediaManager.h
dom/media/MediaStreamGraph.h
dom/media/imagecapture/ImageCapture.h
dom/media/moz.build
dom/media/standalone/moz.build
dom/media/test/test_imagecapture.html
dom/media/webrtc/moz.build
dom/moz.build
dom/permission/tests/mochitest.ini
dom/permission/tests/test_camera.html
dom/webidl/CameraCapabilities.webidl
dom/webidl/CameraClosedEvent.webidl
dom/webidl/CameraConfigurationEvent.webidl
dom/webidl/CameraControl.webidl
dom/webidl/CameraFacesDetectedEvent.webidl
dom/webidl/CameraManager.webidl
dom/webidl/CameraStateChangeEvent.webidl
dom/webidl/CameraUtil.webidl
dom/webidl/Navigator.webidl
dom/webidl/moz.build
layout/build/moz.build
layout/build/nsLayoutStatics.cpp
widget/NativeKeyToDOMKeyName.h
widget/gonk/nativewindow/GonkNativeWindowJB.h
widget/gonk/nativewindow/GonkNativeWindowKK.h
--- a/dom/base/Navigator.cpp
+++ b/dom/base/Navigator.cpp
@@ -79,17 +79,16 @@
 #include "WidgetUtils.h"
 #include "nsIPresentationService.h"
 
 #include "mozilla/dom/MediaDevices.h"
 #include "MediaManager.h"
 #ifdef MOZ_B2G_BT
 #include "BluetoothManager.h"
 #endif
-#include "DOMCameraManager.h"
 
 #ifdef MOZ_AUDIO_CHANNEL_MANAGER
 #include "AudioChannelManager.h"
 #endif
 
 #include "nsIDOMGlobalPropertyInitializer.h"
 #include "nsJSUtils.h"
 
@@ -228,17 +227,16 @@ NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN(
   NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mMobileConnections)
 #endif
 #ifdef MOZ_B2G_BT
   NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mBluetooth)
 #endif
 #ifdef MOZ_AUDIO_CHANNEL_MANAGER
   NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mAudioChannelManager)
 #endif
-  NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mCameraManager)
   NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mMediaDevices)
   NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mTimeManager)
   NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mServiceWorkerContainer)
 
   NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mWindow)
   NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mMediaKeySystemAccessManager)
   NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mDeviceStorageAreaListener)
   NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mPresentation)
@@ -326,17 +324,16 @@ Navigator::Invalidate()
 #endif
 
 #ifdef MOZ_B2G_BT
   if (mBluetooth) {
     mBluetooth = nullptr;
   }
 #endif
 
-  mCameraManager = nullptr;
   mMediaDevices = nullptr;
 
 #ifdef MOZ_AUDIO_CHANNEL_MANAGER
   if (mAudioChannelManager) {
     mAudioChannelManager = nullptr;
   }
 #endif
 
@@ -1897,33 +1894,16 @@ Navigator::GetMozTime(ErrorResult& aRv)
   if (!mTimeManager) {
     mTimeManager = new time::TimeManager(mWindow);
   }
 
   return mTimeManager;
 }
 #endif
 
-nsDOMCameraManager*
-Navigator::GetMozCameras(ErrorResult& aRv)
-{
-  if (!mCameraManager) {
-    if (!mWindow ||
-        !mWindow->GetOuterWindow() ||
-        mWindow->GetOuterWindow()->GetCurrentInnerWindow() != mWindow) {
-      aRv.Throw(NS_ERROR_NOT_AVAILABLE);
-      return nullptr;
-    }
-
-    mCameraManager = nsDOMCameraManager::CreateInstance(mWindow);
-  }
-
-  return mCameraManager;
-}
-
 already_AddRefed<ServiceWorkerContainer>
 Navigator::ServiceWorker()
 {
   MOZ_ASSERT(mWindow);
 
   if (!mServiceWorkerContainer) {
     mServiceWorkerContainer = new ServiceWorkerContainer(mWindow);
   }
@@ -1960,19 +1940,16 @@ Navigator::OnNavigation()
     return;
   }
 
   // If MediaManager is open let it inform any live streams or pending callbacks
   MediaManager *manager = MediaManager::GetIfExists();
   if (manager) {
     manager->OnNavigation(mWindow->WindowID());
   }
-  if (mCameraManager) {
-    mCameraManager->OnNavigation(mWindow->WindowID());
-  }
 }
 
 bool
 Navigator::CheckPermission(const char* type)
 {
   return CheckPermission(mWindow, type);
 }
 
@@ -2018,24 +1995,16 @@ Navigator::HasWakeLockSupport(JSContext*
   nsCOMPtr<nsIPowerManagerService> pmService =
     do_GetService(POWERMANAGERSERVICE_CONTRACTID);
   // No service means no wake lock support
   return !!pmService;
 }
 
 /* static */
 bool
-Navigator::HasCameraSupport(JSContext* /* unused */, JSObject* aGlobal)
-{
-  nsCOMPtr<nsPIDOMWindowInner> win = GetWindowFromGlobal(aGlobal);
-  return win && nsDOMCameraManager::CheckPermission(win);
-}
-
-/* static */
-bool
 Navigator::HasWifiManagerSupport(JSContext* /* unused */,
                                  JSObject* aGlobal)
 {
   // On XBL scope, the global object is NOT |window|. So we have
   // to use nsContentUtils::GetObjectPrincipal to get the principal
   // and test directly with permission manager.
 
   nsIPrincipal* principal = nsContentUtils::ObjectPrincipal(aGlobal);
--- a/dom/base/Navigator.h
+++ b/dom/base/Navigator.h
@@ -19,17 +19,16 @@
 #include "nsTArray.h"
 #include "nsWeakPtr.h"
 #include "mozilla/dom/MediaKeySystemAccessManager.h"
 
 class nsPluginArray;
 class nsMimeTypeArray;
 class nsPIDOMWindowInner;
 class nsIDOMNavigatorSystemMessages;
-class nsDOMCameraManager;
 class nsDOMDeviceStorage;
 class nsIPrincipal;
 class nsIURI;
 
 namespace mozilla {
 namespace dom {
 class Geolocation;
 class systemMessageCallback;
@@ -225,17 +224,16 @@ public:
   DesktopNotificationCenter* GetMozNotification(ErrorResult& aRv);
   IccManager* GetMozIccManager(ErrorResult& aRv);
   MobileMessageManager* GetMozMobileMessage();
   Telephony* GetMozTelephony(ErrorResult& aRv);
   Voicemail* GetMozVoicemail(ErrorResult& aRv);
   InputPortManager* GetInputPortManager(ErrorResult& aRv);
   already_AddRefed<LegacyMozTCPSocket> MozTCPSocket();
   network::Connection* GetConnection(ErrorResult& aRv);
-  nsDOMCameraManager* GetMozCameras(ErrorResult& aRv);
   MediaDevices* GetMediaDevices(ErrorResult& aRv);
 
 #ifdef MOZ_B2G_RIL
   MobileConnectionArray* GetMozMobileConnections(ErrorResult& aRv);
 #endif // MOZ_B2G_RIL
 #ifdef MOZ_GAMEPAD
   void GetGamepads(nsTArray<RefPtr<Gamepad> >& aGamepads, ErrorResult& aRv);
   GamepadServiceTest* RequestGamepadServiceTest();
@@ -276,18 +274,16 @@ public:
   bool MozE10sEnabled();
 
   StorageManager* Storage();
 
   static void GetAcceptLanguages(nsTArray<nsString>& aLanguages);
 
   // WebIDL helper methods
   static bool HasWakeLockSupport(JSContext* /* unused*/, JSObject* /*unused */);
-  static bool HasCameraSupport(JSContext* /* unused */,
-                               JSObject* aGlobal);
   static bool HasWifiManagerSupport(JSContext* /* unused */,
                                   JSObject* aGlobal);
 #ifdef MOZ_NFC
   static bool HasNFCSupport(JSContext* /* unused */, JSObject* aGlobal);
 #endif // MOZ_NFC
   static bool HasUserMediaSupport(JSContext* /* unused */,
                                   JSObject* /* unused */);
 
@@ -342,17 +338,16 @@ private:
   RefPtr<MobileConnectionArray> mMobileConnections;
 #endif
 #ifdef MOZ_B2G_BT
   RefPtr<bluetooth::BluetoothManager> mBluetooth;
 #endif
 #ifdef MOZ_AUDIO_CHANNEL_MANAGER
   RefPtr<system::AudioChannelManager> mAudioChannelManager;
 #endif
-  RefPtr<nsDOMCameraManager> mCameraManager;
   RefPtr<MediaDevices> mMediaDevices;
   nsTArray<nsWeakPtr> mDeviceStorageStores;
   RefPtr<time::TimeManager> mTimeManager;
   RefPtr<ServiceWorkerContainer> mServiceWorkerContainer;
   nsCOMPtr<nsPIDOMWindowInner> mWindow;
   RefPtr<DeviceStorageAreaListener> mDeviceStorageAreaListener;
   RefPtr<Presentation> mPresentation;
 #ifdef MOZ_GAMEPAD
--- a/dom/base/nsContentPermissionHelper.cpp
+++ b/dom/base/nsContentPermissionHelper.cpp
@@ -681,32 +681,16 @@ nsContentPermissionRequestProxy::Allow(J
   }
 
   // Don't send out the delete message when the managing protocol (PBrowser) is
   // being destroyed and PContentPermissionRequest will soon be.
   if (mParent->IsBeingDestroyed()) {
     return NS_ERROR_FAILURE;
   }
 
-#ifdef MOZ_WIDGET_GONK
-  uint32_t len = mPermissionRequests.Length();
-  for (uint32_t i = 0; i < len; i++) {
-    if (mPermissionRequests[i].type().EqualsLiteral("audio-capture")) {
-      GonkPermissionService::GetInstance()->addGrantInfo(
-        "android.permission.RECORD_AUDIO",
-        static_cast<ContentParent*>(mParent->Manager())->Pid());
-    }
-    if (mPermissionRequests[i].type().EqualsLiteral("video-capture")) {
-      GonkPermissionService::GetInstance()->addGrantInfo(
-        "android.permission.CAMERA",
-        static_cast<ContentParent*>(mParent->Manager())->Pid());
-    }
-  }
-#endif
-
   nsTArray<PermissionChoice> choices;
   if (aChoices.isNullOrUndefined()) {
     // No choice is specified.
   } else if (aChoices.isObject()) {
     // Iterate through all permission types.
     for (uint32_t i = 0; i < mPermissionRequests.Length(); ++i) {
       nsCString type = mPermissionRequests[i].type();
 
--- a/dom/base/nsGkAtomList.h
+++ b/dom/base/nsGkAtomList.h
@@ -729,17 +729,16 @@ GK_ATOM(onclick, "onclick")
 GK_ATOM(onclirmodechange, "onclirmodechange")
 GK_ATOM(onclose, "onclose")
 GK_ATOM(oncommand, "oncommand")
 GK_ATOM(oncommandupdate, "oncommandupdate")
 GK_ATOM(oncomplete, "oncomplete")
 GK_ATOM(oncompositionend, "oncompositionend")
 GK_ATOM(oncompositionstart, "oncompositionstart")
 GK_ATOM(oncompositionupdate, "oncompositionupdate")
-GK_ATOM(onconfigurationchange, "onconfigurationchange")
 GK_ATOM(onconnect, "onconnect")
 GK_ATOM(onconnected, "onconnected")
 GK_ATOM(onconnecting, "onconnecting")
 GK_ATOM(onconnectionavailable, "onconnectionavailable")
 GK_ATOM(onconnectionstatechanged, "onconnectionstatechanged")
 GK_ATOM(oncontextmenu, "oncontextmenu")
 GK_ATOM(oncopy, "oncopy")
 GK_ATOM(oncurrentchannelchanged, "oncurrentchannelchanged")
@@ -786,17 +785,16 @@ GK_ATOM(ondragstart, "ondragstart")
 GK_ATOM(ondrain, "ondrain")
 GK_ATOM(ondrop, "ondrop")
 GK_ATOM(oneitbroadcasted, "oneitbroadcasted")
 GK_ATOM(onenabled, "onenabled")
 GK_ATOM(onenterpincodereq, "onenterpincodereq")
 GK_ATOM(onemergencycbmodechange, "onemergencycbmodechange")
 GK_ATOM(onerror, "onerror")
 GK_ATOM(onevicted, "onevicted")
-GK_ATOM(onfacesdetected, "onfacesdetected")
 GK_ATOM(onfailed, "onfailed")
 GK_ATOM(onfetch, "onfetch")
 GK_ATOM(onfinish, "onfinish")
 GK_ATOM(onfocus, "onfocus")
 GK_ATOM(onfrequencychange, "onfrequencychange")
 GK_ATOM(onfullscreenchange, "onfullscreenchange")
 GK_ATOM(onfullscreenerror, "onfullscreenerror")
 GK_ATOM(onspeakerforcedchange, "onspeakerforcedchange")
@@ -877,42 +875,38 @@ GK_ATOM(onpagehide, "onpagehide")
 GK_ATOM(onpageshow, "onpageshow")
 GK_ATOM(onpaint, "onpaint")
 GK_ATOM(onpairingaborted, "onpairingaborted")
 GK_ATOM(onpairingconfirmationreq, "onpairingconfirmationreq")
 GK_ATOM(onpairingconsentreq, "onpairingconsentreq")
 GK_ATOM(onpaste, "onpaste")
 GK_ATOM(onpendingchange, "onpendingchange")
 GK_ATOM(onpichange, "onpichange")
-GK_ATOM(onpicture, "onpicture")
 GK_ATOM(onpointerlockchange, "onpointerlockchange")
 GK_ATOM(onpointerlockerror, "onpointerlockerror")
 GK_ATOM(onpopuphidden, "onpopuphidden")
 GK_ATOM(onpopuphiding, "onpopuphiding")
 GK_ATOM(onpopuppositioned, "onpopuppositioned")
 GK_ATOM(onpopupshowing, "onpopupshowing")
 GK_ATOM(onpopupshown, "onpopupshown")
-GK_ATOM(onposter, "onposter")
-GK_ATOM(onpreviewstatechange, "onpreviewstatechange")
 GK_ATOM(onpullphonebookreq, "onpullphonebookreq")
 GK_ATOM(onpullvcardentryreq, "onpullvcardentryreq")
 GK_ATOM(onpullvcardlistingreq, "onpullvcardlistingreq")
 GK_ATOM(onpush, "onpush")
 GK_ATOM(onpushsubscriptionchange, "onpushsubscriptionchange")
 GK_ATOM(onpschange, "onpschange")
 GK_ATOM(onptychange, "onptychange")
 GK_ATOM(onradiostatechange, "onradiostatechange")
 GK_ATOM(onrdsdisabled, "onrdsdisabled")
 GK_ATOM(onrdsenabled, "onrdsenabled")
 GK_ATOM(onreaderror, "onreaderror")
 GK_ATOM(onreadsuccess, "onreadsuccess")
 GK_ATOM(onready, "onready")
 GK_ATOM(onreadystatechange, "onreadystatechange")
 GK_ATOM(onreceived, "onreceived")
-GK_ATOM(onrecorderstatechange, "onrecorderstatechange")
 GK_ATOM(onremoteheld, "onremoteheld")
 GK_ATOM(onremoteresumed, "onremoteresumed")
 GK_ATOM(onresourcetimingbufferfull, "onresourcetimingbufferfull")
 GK_ATOM(onretrieving, "onretrieving")
 GK_ATOM(onRequest, "onRequest")
 GK_ATOM(onrequestmediaplaystatus, "onrequestmediaplaystatus")
 GK_ATOM(onreset, "onreset")
 GK_ATOM(onresuming, "onresuming")
@@ -923,17 +917,16 @@ GK_ATOM(onscostatuschanged, "onscostatus
 GK_ATOM(onscroll, "onscroll")
 GK_ATOM(onselect, "onselect")
 GK_ATOM(onselectionchange, "onselectionchange")
 GK_ATOM(onselectstart, "onselectstart")
 GK_ATOM(onsending, "onsending")
 GK_ATOM(onsent, "onsent")
 GK_ATOM(onset, "onset")
 GK_ATOM(onshow, "onshow")
-GK_ATOM(onshutter, "onshutter")
 GK_ATOM(onstatechange, "onstatechange")
 GK_ATOM(onstatuschanged, "onstatuschanged")
 GK_ATOM(onstkcommand, "onstkcommand")
 GK_ATOM(onstksessionend, "onstksessionend")
 GK_ATOM(onstorage, "onstorage")
 GK_ATOM(onstorageareachanged, "onstorageareachanged")
 GK_ATOM(onsubmit, "onsubmit")
 GK_ATOM(onsuccess, "onsuccess")
--- a/dom/bindings/Bindings.conf
+++ b/dom/bindings/Bindings.conf
@@ -184,55 +184,16 @@ DOMInterfaces = {
     'implicitJSContext': [ 'add', 'addAll' ],
     'nativeType': 'mozilla::dom::cache::Cache',
 },
 
 'CacheStorage': {
     'nativeType': 'mozilla::dom::cache::CacheStorage',
 },
 
-'CameraCapabilities': {
-    'nativeType': 'mozilla::dom::CameraCapabilities',
-    'headerFile': 'DOMCameraCapabilities.h'
-},
-
-'CameraControl': {
-    'nativeType': 'mozilla::nsDOMCameraControl',
-    'headerFile': 'DOMCameraControl.h',
-    'binaryNames': {
-        "release": "ReleaseHardware"
-    }
-},
-
-'CameraDetectedFace': {
-    'nativeType': 'mozilla::dom::DOMCameraDetectedFace',
-    'headerFile': 'DOMCameraDetectedFace.h'
-},
-
-'CameraManager': {
-    'nativeType': 'nsDOMCameraManager',
-    'headerFile': 'DOMCameraManager.h'
-},
-
-'CameraRecorderAudioProfile': {
-    'headerFile': 'DOMCameraCapabilities.h'
-},
-
-'CameraRecorderProfile': {
-    'headerFile': 'DOMCameraCapabilities.h'
-},
-
-'CameraRecorderProfiles': {
-    'headerFile': 'DOMCameraCapabilities.h'
-},
-
-'CameraRecorderVideoProfile': {
-    'headerFile': 'DOMCameraCapabilities.h'
-},
-
 'CanvasRenderingContext2D': {
     'implicitJSContext': [
         'createImageData', 'getImageData'
     ],
     'binaryNames': {
         'mozImageSmoothingEnabled': 'imageSmoothingEnabled'
     }
 },
--- a/dom/bindings/moz.build
+++ b/dom/bindings/moz.build
@@ -55,17 +55,16 @@ EXPORTS.mozilla.dom += [
 LOCAL_INCLUDES += [
     '!/dist/include/mozilla/dom',
 ]
 
 LOCAL_INCLUDES += [
     '/dom/base',
     '/dom/battery',
     '/dom/bluetooth/common/webapi',
-    '/dom/camera',
     '/dom/canvas',
     '/dom/geolocation',
     '/dom/html',
     '/dom/indexedDB',
     '/dom/media/webaudio',
     '/dom/media/webspeech/recognition',
     '/dom/svg',
     '/dom/workers',
deleted file mode 100644
--- a/dom/camera/AutoRwLock.h
+++ /dev/null
@@ -1,49 +0,0 @@
-/* This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this file,
- * You can obtain one at http://mozilla.org/MPL/2.0/. */
-
-#ifndef RWLOCK_AUTO_ENTER_H
-#define RWLOCK_AUTO_ENTER_H
-
-#include "prrwlock.h"
-#include "mozilla/Assertions.h"
-
-class RwLockAutoEnterRead
-{
-public:
-  explicit RwLockAutoEnterRead(PRRWLock* aRwLock)
-    : mRwLock(aRwLock)
-  {
-    MOZ_ASSERT(mRwLock);
-    PR_RWLock_Rlock(mRwLock);
-  }
-
-  ~RwLockAutoEnterRead()
-  {
-    PR_RWLock_Unlock(mRwLock);
-  }
-
-protected:
-  PRRWLock* mRwLock;
-};
-
-class RwLockAutoEnterWrite
-{
-public:
-  explicit RwLockAutoEnterWrite(PRRWLock* aRwLock)
-    : mRwLock(aRwLock)
-  {
-    MOZ_ASSERT(mRwLock);
-    PR_RWLock_Wlock(mRwLock);
-  }
-
-  ~RwLockAutoEnterWrite()
-  {
-    PR_RWLock_Unlock(mRwLock);
-  }
-
-protected:
-  PRRWLock* mRwLock;
-};
-
-#endif // RWLOCK_AUTO_ENTER_H
deleted file mode 100644
--- a/dom/camera/CameraCommon.h
+++ /dev/null
@@ -1,44 +0,0 @@
-/* -*- Mode: c++; c-basic-offset: 2; indent-tabs-mode: nil; tab-width: 40 -*- */
-/* vim: set ts=2 et sw=2 tw=40: */
-/* This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this file,
- * You can obtain one at http://mozilla.org/MPL/2.0/. */
-
-#ifndef DOM_CAMERA_CAMERACOMMON_H
-#define DOM_CAMERA_CAMERACOMMON_H
-
-#include "mozilla/Logging.h"
-
-extern mozilla::LogModule* GetCameraLog();
-#define DOM_CAMERA_LOG( type, ... ) MOZ_LOG(GetCameraLog(), (mozilla::LogLevel)type, ( __VA_ARGS__ ))
-
-#define DOM_CAMERA_LOGA( ... )      DOM_CAMERA_LOG( mozilla::LogLevel::Error, __VA_ARGS__ )
-
-/**
- * From the least to the most output.
- */
-enum {
-  DOM_CAMERA_LOG_NOTHING,
-  DOM_CAMERA_LOG_ERROR,
-  DOM_CAMERA_LOG_WARNING,
-  DOM_CAMERA_LOG_INFO,
-  DOM_CAMERA_LOG_TRACE,
-  DOM_CAMERA_LOG_REFERENCES
-};
-
-/**
- * DOM_CAMERA_LOGR() can be called before 'gCameraLog' is set, so
- * we need to handle this one a little differently.
- */
-#define DOM_CAMERA_LOGR( ... )                                  \
-  do {                                                          \
-    if (GetCameraLog()) {                                       \
-      DOM_CAMERA_LOG( DOM_CAMERA_LOG_REFERENCES, __VA_ARGS__ ); \
-    }                                                           \
-  } while (0)
-#define DOM_CAMERA_LOGT( ... )      DOM_CAMERA_LOG( DOM_CAMERA_LOG_TRACE, __VA_ARGS__ )
-#define DOM_CAMERA_LOGI( ... )      DOM_CAMERA_LOG( DOM_CAMERA_LOG_INFO, __VA_ARGS__ )
-#define DOM_CAMERA_LOGW( ... )      DOM_CAMERA_LOG( DOM_CAMERA_LOG_WARNING, __VA_ARGS__ )
-#define DOM_CAMERA_LOGE( ... )      DOM_CAMERA_LOG( DOM_CAMERA_LOG_ERROR, __VA_ARGS__ )
-
-#endif // DOM_CAMERA_CAMERACOMMON_H
deleted file mode 100644
--- a/dom/camera/CameraControlImpl.cpp
+++ /dev/null
@@ -1,795 +0,0 @@
-/* This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this file,
- * You can obtain one at http://mozilla.org/MPL/2.0/. */
-
-#include "CameraControlImpl.h"
-#include "base/basictypes.h"
-#include "mozilla/Assertions.h"
-#include "mozilla/Unused.h"
-#include "nsPrintfCString.h"
-#include "nsIWeakReferenceUtils.h"
-#include "CameraCommon.h"
-#include "nsGlobalWindow.h"
-#include "DeviceStorageFileDescriptor.h"
-#include "CameraControlListener.h"
-
-using namespace mozilla;
-
-/* static */ StaticRefPtr<nsIThread> CameraControlImpl::sCameraThread;
-
-CameraControlImpl::CameraControlImpl()
-  : mListenerLock("mozilla::camera::CameraControlImpl.Listeners")
-  , mPreviewState(CameraControlListener::kPreviewStopped)
-  , mHardwareState(CameraControlListener::kHardwareUninitialized)
-  , mHardwareStateChangeReason(NS_OK)
-{
-  DOM_CAMERA_LOGT("%s:%d : this=%p\n", __func__, __LINE__, this);
-  mCurrentConfiguration.mMode = ICameraControl::kUnspecifiedMode;
-
-  class Delegate : public Runnable
-  {
-  public:
-    NS_IMETHOD
-    Run() override
-    {
-      char stackBaseGuess;
-      profiler_register_thread("CameraThread", &stackBaseGuess);
-      return NS_OK;
-    }
-  };
-
-  // reuse the same camera thread to conserve resources
-  nsCOMPtr<nsIThread> ct = do_QueryInterface(sCameraThread);
-  if (ct) {
-    mCameraThread = ct.forget();
-  } else {
-    nsresult rv = NS_NewNamedThread("CameraThread", getter_AddRefs(mCameraThread));
-    if (NS_FAILED(rv)) {
-      MOZ_CRASH("Failed to create new Camera Thread");
-    }
-    mCameraThread->Dispatch(new Delegate(), NS_DISPATCH_NORMAL);
-    sCameraThread = mCameraThread;
-  }
-}
-
-CameraControlImpl::~CameraControlImpl()
-{
-  DOM_CAMERA_LOGT("%s:%d : this=%p\n", __func__, __LINE__, this);
-}
-
-void
-CameraControlImpl::OnHardwareStateChange(CameraControlListener::HardwareState aNewState,
-                                         nsresult aReason)
-{
-  // This callback can run on threads other than the Main Thread and
-  //  the Camera Thread. On Gonk, it may be called from the camera's
-  //  local binder thread, should the mediaserver process die.
-  MutexAutoLock lock(mListenerLock);
-
-  if (aNewState == mHardwareState) {
-    DOM_CAMERA_LOGI("OnHardwareStateChange: state did not change from %d\n", mHardwareState);
-    return;
-  }
-
-  const char* state[] = { "uninitialized", "closed", "open", "failed" };
-  MOZ_ASSERT(aNewState >= 0);
-  if (static_cast<unsigned int>(aNewState) < sizeof(state) / sizeof(state[0])) {
-    DOM_CAMERA_LOGI("New hardware state is '%s' (reason=0x%x)\n",
-      state[aNewState], aReason);
-  } else {
-    DOM_CAMERA_LOGE("OnHardwareStateChange: got invalid HardwareState value %d\n", aNewState);
-  }
-
-  mHardwareState = aNewState;
-  mHardwareStateChangeReason = aReason;
-
-  for (uint32_t i = 0; i < mListeners.Length(); ++i) {
-    CameraControlListener* l = mListeners[i];
-    l->OnHardwareStateChange(mHardwareState, mHardwareStateChangeReason);
-  }
-}
-
-void
-CameraControlImpl::OnConfigurationChange()
-{
-  MOZ_ASSERT(NS_GetCurrentThread() == mCameraThread);
-  MutexAutoLock lock(mListenerLock);
-
-  DOM_CAMERA_LOGI("OnConfigurationChange : %zu listeners\n", mListeners.Length());
-
-  for (uint32_t i = 0; i < mListeners.Length(); ++i) {
-    CameraControlListener* l = mListeners[i];
-    l->OnConfigurationChange(mCurrentConfiguration);
-  }
-}
-
-void
-CameraControlImpl::OnAutoFocusComplete(bool aAutoFocusSucceeded)
-{
-  // This callback can run on threads other than the Main Thread and
-  //  the Camera Thread. On Gonk, it is called from the camera
-  //  library's auto focus thread.
-  MutexAutoLock lock(mListenerLock);
-
-  for (uint32_t i = 0; i < mListeners.Length(); ++i) {
-    CameraControlListener* l = mListeners[i];
-    l->OnAutoFocusComplete(aAutoFocusSucceeded);
-  }
-}
-
-void
-CameraControlImpl::OnAutoFocusMoving(bool aIsMoving)
-{
-  MutexAutoLock lock(mListenerLock);
-
-  for (uint32_t i = 0; i < mListeners.Length(); ++i) {
-    CameraControlListener* l = mListeners[i];
-    l->OnAutoFocusMoving(aIsMoving);
-  }
-}
-
-void
-CameraControlImpl::OnFacesDetected(const nsTArray<Face>& aFaces)
-{
-  // This callback can run on threads other than the Main Thread and
-  //  the Camera Thread. On Gonk, it is called from the camera
-  //  library's face detection thread.
-  MutexAutoLock lock(mListenerLock);
-
-  for (uint32_t i = 0; i < mListeners.Length(); ++i) {
-    CameraControlListener* l = mListeners[i];
-    l->OnFacesDetected(aFaces);
-  }
-}
-
-void
-CameraControlImpl::OnTakePictureComplete(const uint8_t* aData, uint32_t aLength, const nsAString& aMimeType)
-{
-  // This callback can run on threads other than the Main Thread and
-  //  the Camera Thread. On Gonk, it is called from the camera
-  //  library's snapshot thread.
-  MutexAutoLock lock(mListenerLock);
-
-  for (uint32_t i = 0; i < mListeners.Length(); ++i) {
-    CameraControlListener* l = mListeners[i];
-    l->OnTakePictureComplete(aData, aLength, aMimeType);
-  }
-}
-
-void
-CameraControlImpl::OnPoster(dom::BlobImpl* aBlobImpl)
-{
-  // This callback can run on threads other than the Main Thread and
-  //  the Camera Thread.
-  MutexAutoLock lock(mListenerLock);
-
-  for (uint32_t i = 0; i < mListeners.Length(); ++i) {
-    CameraControlListener* l = mListeners[i];
-    l->OnPoster(aBlobImpl);
-  }
-}
-
-void
-CameraControlImpl::OnShutter()
-{
-  // This callback can run on threads other than the Main Thread and
-  //  the Camera Thread. On Gonk, it is called from the camera driver's
-  //  preview thread.
-  MutexAutoLock lock(mListenerLock);
-
-  for (uint32_t i = 0; i < mListeners.Length(); ++i) {
-    CameraControlListener* l = mListeners[i];
-    l->OnShutter();
-  }
-}
-
-void
-CameraControlImpl::OnRecorderStateChange(CameraControlListener::RecorderState aState,
-                                         int32_t aStatus, int32_t aTrackNumber)
-{
-  // This callback can run on threads other than the Main Thread and
-  //  the Camera Thread. On Gonk, it is called from the media encoder
-  //  thread.
-  MutexAutoLock lock(mListenerLock);
-
-  for (uint32_t i = 0; i < mListeners.Length(); ++i) {
-    CameraControlListener* l = mListeners[i];
-    l->OnRecorderStateChange(aState, aStatus, aTrackNumber);
-  }
-}
-
-void
-CameraControlImpl::OnPreviewStateChange(CameraControlListener::PreviewState aNewState)
-{
-  // This callback runs on the Main Thread and the Camera Thread, and
-  //  may run on the local binder thread, should the mediaserver
-  //  process die.
-  MutexAutoLock lock(mListenerLock);
-
-  if (aNewState == mPreviewState) {
-    DOM_CAMERA_LOGI("OnPreviewStateChange: state did not change from %d\n", mPreviewState);
-    return;
-  }
-
-  const char* state[] = { "stopped", "paused", "started" };
-  MOZ_ASSERT(aNewState >= 0);
-  if (static_cast<unsigned int>(aNewState) < sizeof(state) / sizeof(state[0])) {
-    DOM_CAMERA_LOGI("New preview state is '%s'\n", state[aNewState]);
-  } else {
-    DOM_CAMERA_LOGE("OnPreviewStateChange: got unknown PreviewState value %d\n", aNewState);
-  }
-
-  mPreviewState = aNewState;
-
-  for (uint32_t i = 0; i < mListeners.Length(); ++i) {
-    CameraControlListener* l = mListeners[i];
-    l->OnPreviewStateChange(mPreviewState);
-  }
-}
-
-void
-CameraControlImpl::OnRateLimitPreview(bool aLimit)
-{
-  // This function runs on neither the Main Thread nor the Camera Thread.
-  MutexAutoLock lock(mListenerLock);
-
-  DOM_CAMERA_LOGI("OnRateLimitPreview: %d\n", aLimit);
-
-  for (uint32_t i = 0; i < mListeners.Length(); ++i) {
-    CameraControlListener* l = mListeners[i];
-    l->OnRateLimitPreview(aLimit);
-  }
-}
-
-bool
-CameraControlImpl::OnNewPreviewFrame(layers::Image* aImage, uint32_t aWidth, uint32_t aHeight)
-{
-  // This function runs on neither the Main Thread nor the Camera Thread.
-  //  On Gonk, it is called from the camera driver's preview thread.
-  MutexAutoLock lock(mListenerLock);
-
-  DOM_CAMERA_LOGI("OnNewPreviewFrame: we have %zu preview frame listener(s)\n",
-    mListeners.Length());
-
-  bool consumed = false;
-
-  for (uint32_t i = 0; i < mListeners.Length(); ++i) {
-    CameraControlListener* l = mListeners[i];
-    consumed = l->OnNewPreviewFrame(aImage, aWidth, aHeight) || consumed;
-  }
-  return consumed;
-}
-
-void
-CameraControlImpl::OnUserError(CameraControlListener::UserContext aContext,
-                               nsresult aError)
-{
-  // This callback can run on threads other than the Main Thread and
-  //  the Camera Thread.
-  MutexAutoLock lock(mListenerLock);
-
-  const char* context[] = {
-    "StartCamera",
-    "StopCamera",
-    "AutoFocus",
-    "StartFaceDetection",
-    "StopFaceDetection",
-    "TakePicture",
-    "StartRecording",
-    "StopRecording",
-    "PauseRecording",
-    "ResumeRecording",
-    "SetConfiguration",
-    "StartPreview",
-    "StopPreview",
-    "SetPictureSize",
-    "SetThumbnailSize",
-    "ResumeContinuousFocus",
-    "Unspecified"
-  };
-  if (static_cast<size_t>(aContext) < sizeof(context) / sizeof(context[0])) {
-    DOM_CAMERA_LOGW("CameraControlImpl::OnUserError : aContext='%s' (%d), aError=0x%x\n",
-      context[aContext], aContext, aError);
-  } else {
-    DOM_CAMERA_LOGE("CameraControlImpl::OnUserError : aContext=%d, aError=0x%x\n",
-      aContext, aError);
-  }
-
-  for (uint32_t i = 0; i < mListeners.Length(); ++i) {
-    CameraControlListener* l = mListeners[i];
-    l->OnUserError(aContext, aError);
-  }
-}
-
-void
-CameraControlImpl::OnSystemError(CameraControlListener::SystemContext aContext,
-                                 nsresult aError)
-{
-  // This callback can run on threads other than the Main Thread and
-  //  the Camera Thread.
-  MutexAutoLock lock(mListenerLock);
-
-  const char* context[] = {
-    "Camera Service"
-  };
-  if (static_cast<size_t>(aContext) < sizeof(context) / sizeof(context[0])) {
-    DOM_CAMERA_LOGW("CameraControlImpl::OnSystemError : aContext='%s' (%d), aError=0x%x\n",
-      context[aContext], aContext, aError);
-  } else {
-    DOM_CAMERA_LOGE("CameraControlImpl::OnSystemError : aContext=%d, aError=0x%x\n",
-      aContext, aError);
-  }
-
-  for (uint32_t i = 0; i < mListeners.Length(); ++i) {
-    CameraControlListener* l = mListeners[i];
-    l->OnSystemError(aContext, aError);
-  }
-}
-
-// Camera control asynchronous message; these are dispatched from
-//  the Main Thread to the Camera Thread, where they are consumed.
-
-class CameraControlImpl::ControlMessage : public Runnable
-{
-public:
-  ControlMessage(CameraControlImpl* aCameraControl,
-                 CameraControlListener::UserContext aContext)
-    : mCameraControl(aCameraControl)
-    , mContext(aContext)
-  { }
-
-  virtual nsresult RunImpl() = 0;
-
-  NS_IMETHOD
-  Run() override
-  {
-    MOZ_ASSERT(mCameraControl);
-    MOZ_ASSERT(NS_GetCurrentThread() == mCameraControl->mCameraThread);
-
-    nsresult rv = RunImpl();
-    if (NS_FAILED(rv)) {
-      nsPrintfCString msg("Camera control API(%d) failed with 0x%x", mContext, rv);
-      NS_WARNING(msg.get());
-      mCameraControl->OnUserError(mContext, rv);
-    }
-
-    return NS_OK;
-  }
-
-protected:
-  virtual ~ControlMessage() { }
-
-  RefPtr<CameraControlImpl> mCameraControl;
-  CameraControlListener::UserContext mContext;
-};
-
-nsresult
-CameraControlImpl::Dispatch(ControlMessage* aMessage)
-{
-  nsresult rv = mCameraThread->Dispatch(aMessage, NS_DISPATCH_NORMAL);
-  if (NS_SUCCEEDED(rv)) {
-    return NS_OK;
-  }
-
-  nsPrintfCString msg("Failed to dispatch camera control message (0x%x)", rv);
-  NS_WARNING(msg.get());
-  return NS_ERROR_FAILURE;
-}
-
-nsresult
-CameraControlImpl::Start(const Configuration* aConfig)
-{
-  class Message : public ControlMessage
-  {
-  public:
-    Message(CameraControlImpl* aCameraControl,
-            CameraControlListener::UserContext aContext,
-            const Configuration* aConfig)
-      : ControlMessage(aCameraControl, aContext)
-      , mHaveInitialConfig(false)
-    {
-      if (aConfig) {
-        mConfig = *aConfig;
-        mHaveInitialConfig = true;
-      }
-    }
-
-    nsresult
-    RunImpl() override
-    {
-      if (mHaveInitialConfig) {
-        return mCameraControl->StartImpl(&mConfig);
-      }
-      return mCameraControl->StartImpl();
-    }
-
-  protected:
-    bool mHaveInitialConfig;
-    Configuration mConfig;
-  };
-
-  return Dispatch(new Message(this, CameraControlListener::kInStartCamera, aConfig));
-}
-
-nsresult
-CameraControlImpl::SetConfiguration(const Configuration& aConfig)
-{
-  class Message : public ControlMessage
-  {
-  public:
-    Message(CameraControlImpl* aCameraControl,
-            CameraControlListener::UserContext aContext,
-            const Configuration& aConfig)
-      : ControlMessage(aCameraControl, aContext)
-      , mConfig(aConfig)
-    { }
-
-    nsresult
-    RunImpl() override
-    {
-      return mCameraControl->SetConfigurationImpl(mConfig);
-    }
-
-  protected:
-    Configuration mConfig;
-  };
-
-  return Dispatch(new Message(this, CameraControlListener::kInSetConfiguration, aConfig));
-}
-
-nsresult
-CameraControlImpl::AutoFocus()
-{
-  class Message : public ControlMessage
-  {
-  public:
-    Message(CameraControlImpl* aCameraControl,
-            CameraControlListener::UserContext aContext)
-      : ControlMessage(aCameraControl, aContext)
-    { }
-
-    nsresult
-    RunImpl() override
-    {
-      return mCameraControl->AutoFocusImpl();
-    }
-  };
-
-  return Dispatch(new Message(this, CameraControlListener::kInAutoFocus));
-}
-
-nsresult
-CameraControlImpl::StartFaceDetection()
-{
-  class Message : public ControlMessage
-  {
-  public:
-    Message(CameraControlImpl* aCameraControl,
-            CameraControlListener::UserContext aContext)
-      : ControlMessage(aCameraControl, aContext)
-    { }
-
-    nsresult
-    RunImpl() override
-    {
-      return mCameraControl->StartFaceDetectionImpl();
-    }
-  };
-
-  return Dispatch(new Message(this, CameraControlListener::kInStartFaceDetection));
-}
-
-nsresult
-CameraControlImpl::StopFaceDetection()
-{
-  class Message : public ControlMessage
-  {
-  public:
-    Message(CameraControlImpl* aCameraControl,
-            CameraControlListener::UserContext aContext)
-      : ControlMessage(aCameraControl, aContext)
-    { }
-
-    nsresult
-    RunImpl() override
-    {
-      return mCameraControl->StopFaceDetectionImpl();
-    }
-  };
-
-  return Dispatch(new Message(this, CameraControlListener::kInStopFaceDetection));
-}
-
-nsresult
-CameraControlImpl::TakePicture()
-{
-  class Message : public ControlMessage
-  {
-  public:
-    Message(CameraControlImpl* aCameraControl,
-            CameraControlListener::UserContext aContext)
-      : ControlMessage(aCameraControl, aContext)
-    { }
-
-    nsresult
-    RunImpl() override
-    {
-      return mCameraControl->TakePictureImpl();
-    }
-  };
-
-  return Dispatch(new Message(this, CameraControlListener::kInTakePicture));
-}
-
-nsresult
-CameraControlImpl::StartRecording(DeviceStorageFileDescriptor* aFileDescriptor,
-                                  const StartRecordingOptions* aOptions)
-{
-  class Message : public ControlMessage
-  {
-  public:
-    Message(CameraControlImpl* aCameraControl,
-            CameraControlListener::UserContext aContext,
-            const StartRecordingOptions* aOptions,
-            DeviceStorageFileDescriptor* aFileDescriptor)
-      : ControlMessage(aCameraControl, aContext)
-      , mOptionsPassed(false)
-      , mFileDescriptor(aFileDescriptor)
-    {
-      if (aOptions) {
-        mOptions = *aOptions;
-        mOptionsPassed = true;
-      }
-    }
-
-    nsresult
-    RunImpl() override
-    {
-      return mCameraControl->StartRecordingImpl(mFileDescriptor,
-        mOptionsPassed ? &mOptions : nullptr);
-    }
-
-  protected:
-    StartRecordingOptions mOptions;
-    bool mOptionsPassed;
-    RefPtr<DeviceStorageFileDescriptor> mFileDescriptor;
-  };
-
-  if (!aFileDescriptor) {
-    return NS_ERROR_INVALID_ARG;
-  }
-  return Dispatch(new Message(this, CameraControlListener::kInStartRecording,
-    aOptions, aFileDescriptor));
-}
-
-nsresult
-CameraControlImpl::StopRecording()
-{
-  class Message : public ControlMessage
-  {
-  public:
-    Message(CameraControlImpl* aCameraControl,
-            CameraControlListener::UserContext aContext)
-      : ControlMessage(aCameraControl, aContext)
-    { }
-
-    nsresult
-    RunImpl() override
-    {
-      return mCameraControl->StopRecordingImpl();
-    }
-  };
-
-  return Dispatch(new Message(this, CameraControlListener::kInStopRecording));
-}
-
-nsresult
-CameraControlImpl::PauseRecording()
-{
-  class Message : public ControlMessage
-  {
-  public:
-    Message(CameraControlImpl* aCameraControl,
-            CameraControlListener::UserContext aContext)
-      : ControlMessage(aCameraControl, aContext)
-    { }
-
-    nsresult
-    RunImpl() override
-    {
-      return mCameraControl->PauseRecordingImpl();
-    }
-  };
-
-  return Dispatch(new Message(this, CameraControlListener::kInPauseRecording));
-}
-
-nsresult
-CameraControlImpl::ResumeRecording()
-{
-  class Message : public ControlMessage
-  {
-  public:
-    Message(CameraControlImpl* aCameraControl,
-            CameraControlListener::UserContext aContext)
-      : ControlMessage(aCameraControl, aContext)
-    { }
-
-    nsresult
-    RunImpl() override
-    {
-      return mCameraControl->ResumeRecordingImpl();
-    }
-  };
-
-  return Dispatch(new Message(this, CameraControlListener::kInResumeRecording));
-}
-
-nsresult
-CameraControlImpl::StartPreview()
-{
-  class Message : public ControlMessage
-  {
-  public:
-    Message(CameraControlImpl* aCameraControl,
-            CameraControlListener::UserContext aContext)
-      : ControlMessage(aCameraControl, aContext)
-    { }
-
-    nsresult
-    RunImpl() override
-    {
-      return mCameraControl->StartPreviewImpl();
-    }
-  };
-
-  return Dispatch(new Message(this, CameraControlListener::kInStartPreview));
-}
-
-nsresult
-CameraControlImpl::StopPreview()
-{
-  class Message : public ControlMessage
-  {
-  public:
-    Message(CameraControlImpl* aCameraControl,
-            CameraControlListener::UserContext aContext)
-      : ControlMessage(aCameraControl, aContext)
-    { }
-
-    nsresult
-    RunImpl() override
-    {
-      return mCameraControl->StopPreviewImpl();
-    }
-  };
-
-  return Dispatch(new Message(this, CameraControlListener::kInStopPreview));
-}
-
-nsresult
-CameraControlImpl::ResumeContinuousFocus()
-{
-  class Message : public ControlMessage
-  {
-  public:
-    Message(CameraControlImpl* aCameraControl,
-            CameraControlListener::UserContext aContext)
-      : ControlMessage(aCameraControl, aContext)
-    { }
-
-    nsresult
-    RunImpl() override
-    {
-      return mCameraControl->ResumeContinuousFocusImpl();
-    }
-  };
-
-  return Dispatch(new Message(this, CameraControlListener::kInResumeContinuousFocus));
-}
-
-nsresult
-CameraControlImpl::Stop()
-{
-  class Message : public ControlMessage
-  {
-  public:
-    Message(CameraControlImpl* aCameraControl,
-            CameraControlListener::UserContext aContext)
-      : ControlMessage(aCameraControl, aContext)
-    { }
-
-    nsresult
-    RunImpl() override
-    {
-      return mCameraControl->StopImpl();
-    }
-  };
-
-  return Dispatch(new Message(this, CameraControlListener::kInStopCamera));
-}
-
-class CameraControlImpl::ListenerMessage : public CameraControlImpl::ControlMessage
-{
-public:
-  ListenerMessage(CameraControlImpl* aCameraControl,
-                  CameraControlListener* aListener)
-    : ControlMessage(aCameraControl, CameraControlListener::kInUnspecified)
-    , mListener(aListener)
-  { }
-
-protected:
-  RefPtr<CameraControlListener> mListener;
-};
-
-void
-CameraControlImpl::AddListenerImpl(already_AddRefed<CameraControlListener> aListener)
-{
-  MutexAutoLock lock(mListenerLock);
-
-  CameraControlListener* l = *mListeners.AppendElement() = aListener;
-  DOM_CAMERA_LOGI("Added camera control listener %p\n", l);
-
-  // Update the newly-added listener's state
-  l->OnConfigurationChange(mCurrentConfiguration);
-  l->OnHardwareStateChange(mHardwareState, mHardwareStateChangeReason);
-  l->OnPreviewStateChange(mPreviewState);
-}
-
-void
-CameraControlImpl::AddListener(CameraControlListener* aListener)
- {
-  class Message : public ListenerMessage
-  {
-  public:
-    Message(CameraControlImpl* aCameraControl,
-            CameraControlListener* aListener)
-      : ListenerMessage(aCameraControl, aListener)
-    { }
-
-    nsresult
-    RunImpl() override
-    {
-      mCameraControl->AddListenerImpl(mListener.forget());
-      return NS_OK;
-    }
-  };
-
-  if (aListener) {
-    Dispatch(new Message(this, aListener));
-  }
-}
-
-void
-CameraControlImpl::RemoveListenerImpl(CameraControlListener* aListener)
-{
-  MutexAutoLock lock(mListenerLock);
-
-  RefPtr<CameraControlListener> l(aListener);
-  mListeners.RemoveElement(l);
-  DOM_CAMERA_LOGI("Removed camera control listener %p\n", l.get());
-  // XXXmikeh - do we want to notify the listener that it has been removed?
-}
-
-void
-CameraControlImpl::RemoveListener(CameraControlListener* aListener)
- {
-  class Message : public ListenerMessage
-  {
-  public:
-    Message(CameraControlImpl* aCameraControl, CameraControlListener* aListener)
-      : ListenerMessage(aCameraControl, aListener)
-    { }
-
-    nsresult
-    RunImpl() override
-    {
-      mCameraControl->RemoveListenerImpl(mListener);
-      return NS_OK;
-    }
-  };
-
-  if (aListener) {
-    Dispatch(new Message(this, aListener));
-  }
-}
deleted file mode 100644
--- a/dom/camera/CameraControlImpl.h
+++ /dev/null
@@ -1,148 +0,0 @@
-/* This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this file,
- * You can obtain one at http://mozilla.org/MPL/2.0/. */
-
-#ifndef DOM_CAMERA_CAMERACONTROLIMPL_H
-#define DOM_CAMERA_CAMERACONTROLIMPL_H
-
-#include "nsTArray.h"
-#include "nsWeakPtr.h"
-#include "mozilla/Attributes.h"
-#include "mozilla/ReentrantMonitor.h"
-#include "mozilla/Mutex.h"
-#include "nsIFile.h"
-#include "nsProxyRelease.h"
-#include "ICameraControl.h"
-#include "CameraCommon.h"
-#include "DeviceStorage.h"
-#include "DeviceStorageFileDescriptor.h"
-#include "CameraControlListener.h"
-
-namespace mozilla {
-
-namespace dom {
-  class BlobImpl;
-} // namespace dom
-
-namespace layers {
-  class Image;
-} // namespace layers
-
-class CameraControlImpl : public ICameraControl
-{
-public:
-  explicit CameraControlImpl();
-  virtual void AddListener(CameraControlListener* aListener) override;
-  virtual void RemoveListener(CameraControlListener* aListener) override;
-
-  // See ICameraControl.h for these methods' return values.
-  virtual nsresult Start(const Configuration* aConfig = nullptr) override;
-  virtual nsresult Stop() override;
-  virtual nsresult SetConfiguration(const Configuration& aConfig) override;
-  virtual nsresult StartPreview() override;
-  virtual nsresult StopPreview() override;
-  virtual nsresult AutoFocus() override;
-  virtual nsresult StartFaceDetection() override;
-  virtual nsresult StopFaceDetection() override;
-  virtual nsresult TakePicture() override;
-  virtual nsresult StartRecording(DeviceStorageFileDescriptor* aFileDescriptor,
-                                  const StartRecordingOptions* aOptions) override;
-  virtual nsresult StopRecording() override;
-  virtual nsresult PauseRecording() override;
-  virtual nsresult ResumeRecording() override;
-  virtual nsresult ResumeContinuousFocus() override;
-
-  // Event handlers called directly from outside this class.
-  void OnShutter();
-  void OnUserError(CameraControlListener::UserContext aContext, nsresult aError);
-  void OnSystemError(CameraControlListener::SystemContext aContext, nsresult aError);
-  void OnAutoFocusMoving(bool aIsMoving);
-
-protected:
-  // Event handlers.
-  void OnAutoFocusComplete(bool aAutoFocusSucceeded);
-  void OnFacesDetected(const nsTArray<Face>& aFaces);
-  void OnTakePictureComplete(const uint8_t* aData, uint32_t aLength, const nsAString& aMimeType);
-  void OnPoster(dom::BlobImpl* aBlobImpl);
-
-  void OnRateLimitPreview(bool aLimit);
-  bool OnNewPreviewFrame(layers::Image* aImage, uint32_t aWidth, uint32_t aHeight);
-  void OnRecorderStateChange(CameraControlListener::RecorderState aState,
-                             int32_t aStatus = -1, int32_t aTrackNumber = -1);
-  void OnPreviewStateChange(CameraControlListener::PreviewState aState);
-  void OnHardwareStateChange(CameraControlListener::HardwareState aState,
-                             nsresult aReason);
-  void OnConfigurationChange();
-
-  // When we create a new CameraThread, we keep a static reference to it so
-  // that multiple CameraControl instances can find and reuse it; but we
-  // don't want that reference to keep the thread object around unnecessarily,
-  // so we make it a weak reference. The strong dynamic references will keep
-  // the thread object alive as needed.
-  static StaticRefPtr<nsIThread> sCameraThread;
-  nsCOMPtr<nsIThread> mCameraThread;
-
-  virtual ~CameraControlImpl();
-
-  virtual void BeginBatchParameterSet() override { }
-  virtual void EndBatchParameterSet() override { }
-
-  // Manage camera event listeners.
-  void AddListenerImpl(already_AddRefed<CameraControlListener> aListener);
-  void RemoveListenerImpl(CameraControlListener* aListener);
-  nsTArray<RefPtr<CameraControlListener> > mListeners;
-  mutable Mutex mListenerLock;
-
-  class ControlMessage;
-  class ListenerMessage;
-
-  nsresult Dispatch(ControlMessage* aMessage);
-
-  // Asynchronous method implementations, invoked on the Camera Thread.
-  //
-  // Return values:
-  //  - NS_OK on success;
-  //  - NS_ERROR_INVALID_ARG if one or more arguments is invalid;
-  //  - NS_ERROR_NOT_INITIALIZED if the underlying hardware is not initialized,
-  //      failed to initialize (in the case of StartImpl()), or has been stopped;
-  //      for StartRecordingImpl(), this indicates that no recorder has been
-  //      configured (either by calling StartImpl() or SetConfigurationImpl());
-  //  - NS_ERROR_ALREADY_INITIALIZED if the underlying hardware is already
-  //      initialized;
-  //  - NS_ERROR_NOT_IMPLEMENTED if the method is not implemented;
-  //  - NS_ERROR_FAILURE on general failures.
-  virtual nsresult StartImpl(const Configuration* aConfig = nullptr) = 0;
-  virtual nsresult StopImpl() = 0;
-  virtual nsresult SetConfigurationImpl(const Configuration& aConfig) = 0;
-  virtual nsresult StartPreviewImpl() = 0;
-  virtual nsresult StopPreviewImpl() = 0;
-  virtual nsresult AutoFocusImpl() = 0;
-  virtual nsresult StartFaceDetectionImpl() = 0;
-  virtual nsresult StopFaceDetectionImpl() = 0;
-  virtual nsresult TakePictureImpl() = 0;
-  virtual nsresult StartRecordingImpl(DeviceStorageFileDescriptor* aFileDescriptor,
-                                      const StartRecordingOptions* aOptions) = 0;
-  virtual nsresult StopRecordingImpl() = 0;
-  virtual nsresult PauseRecordingImpl() = 0;
-  virtual nsresult ResumeRecordingImpl() = 0;
-  virtual nsresult ResumeContinuousFocusImpl() = 0;
-  virtual nsresult PushParametersImpl() = 0;
-  virtual nsresult PullParametersImpl() = 0;
-
-  void OnShutterInternal();
-  void OnClosedInternal();
-
-  CameraControlListener::CameraListenerConfiguration mCurrentConfiguration;
-
-  CameraControlListener::PreviewState   mPreviewState;
-  CameraControlListener::HardwareState  mHardwareState;
-  nsresult                              mHardwareStateChangeReason;
-
-private:
-  CameraControlImpl(const CameraControlImpl&) = delete;
-  CameraControlImpl& operator=(const CameraControlImpl&) = delete;
-};
-
-} // namespace mozilla
-
-#endif // DOM_CAMERA_CAMERACONTROLIMPL_H
deleted file mode 100644
--- a/dom/camera/CameraControlListener.h
+++ /dev/null
@@ -1,130 +0,0 @@
-/* This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this file,
- * You can obtain one at http://mozilla.org/MPL/2.0/. */
-
-#ifndef DOM_CAMERA_CAMERACONTROLLISTENER_H
-#define DOM_CAMERA_CAMERACONTROLLISTENER_H
-
-#include <stdint.h>
-#include "ICameraControl.h"
-
-namespace mozilla {
-
-namespace dom {
-  class BlobImpl;
-} // namespace dom
-
-namespace layers {
-  class Image;
-} // namespace layers
-
-class CameraControlListener
-{
-public:
-  CameraControlListener()
-  {
-    MOZ_COUNT_CTOR(CameraControlListener);
-  }
-
-protected:
-  // Protected destructor, to discourage deletion outside of Release():
-  virtual ~CameraControlListener()
-  {
-    MOZ_COUNT_DTOR(CameraControlListener);
-  }
-
-public:
-  NS_INLINE_DECL_THREADSAFE_REFCOUNTING(CameraControlListener);
-
-  enum HardwareState
-  {
-    kHardwareUninitialized,
-    kHardwareClosed,
-    kHardwareOpen,
-    kHardwareOpenFailed
-  };
-  // aReason:
-  //    NS_OK : state change was expected and normal;
-  //    NS_ERROR_FAILURE : one or more system-level components failed and
-  //                       the camera was closed;
-  //    NS_ERROR_NOT_AVAILABLE : the hardware is in use by another process
-  //                             and cannot be acquired, or another process
-  //                             was given access to the camera hardware.
-  virtual void OnHardwareStateChange(HardwareState aState, nsresult aReason) { }
-
-  enum PreviewState
-  {
-    kPreviewStopped,
-    kPreviewPaused,
-    kPreviewStarted
-  };
-  virtual void OnPreviewStateChange(PreviewState aState) { }
-
-  enum RecorderState
-  {
-    kRecorderStopped,
-    kRecorderStarted,
-    kRecorderPaused,
-    kRecorderResumed,
-    kPosterCreated,
-    kPosterFailed,
-  };
-  enum { kNoTrackNumber = -1 };
-  virtual void OnRecorderStateChange(RecorderState aState, int32_t aStatus, int32_t aTrackNum) { }
-
-  virtual void OnShutter() { }
-  virtual void OnRateLimitPreview(bool aLimit) { }
-  virtual bool OnNewPreviewFrame(layers::Image* aFrame, uint32_t aWidth, uint32_t aHeight)
-  {
-    return false;
-  }
-
-  class CameraListenerConfiguration : public ICameraControl::Configuration
-  {
-  public:
-    uint32_t mMaxMeteringAreas;
-    uint32_t mMaxFocusAreas;
-  };
-  virtual void OnConfigurationChange(const CameraListenerConfiguration& aConfiguration) { }
-
-  virtual void OnAutoFocusComplete(bool aAutoFocusSucceeded) { }
-  virtual void OnAutoFocusMoving(bool aIsMoving) { }
-  virtual void OnTakePictureComplete(const uint8_t* aData, uint32_t aLength, const nsAString& aMimeType) { }
-  virtual void OnFacesDetected(const nsTArray<ICameraControl::Face>& aFaces) { }
-  virtual void OnPoster(dom::BlobImpl* aBlobImpl) { }
-
-  enum UserContext
-  {
-    kInStartCamera,
-    kInStopCamera,
-    kInAutoFocus,
-    kInStartFaceDetection,
-    kInStopFaceDetection,
-    kInTakePicture,
-    kInStartRecording,
-    kInStopRecording,
-    kInPauseRecording,
-    kInResumeRecording,
-    kInSetConfiguration,
-    kInStartPreview,
-    kInStopPreview,
-    kInSetPictureSize,
-    kInSetThumbnailSize,
-    kInResumeContinuousFocus,
-    kInUnspecified
-  };
-  // Error handler for problems arising due to user-initiated actions.
-  virtual void OnUserError(UserContext aContext, nsresult aError) { }
-
-  enum SystemContext
-  {
-    kSystemService
-  };
-  // Error handler for problems arising due to system failures, not triggered
-  // by something the CameraControl API user did.
-  virtual void OnSystemError(SystemContext aContext, nsresult aError) { }
-};
-
-} // namespace mozilla
-
-#endif // DOM_CAMERA_CAMERACONTROLLISTENER_H
deleted file mode 100644
--- a/dom/camera/CameraPreferences.cpp
+++ /dev/null
@@ -1,425 +0,0 @@
-/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
-/* This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
-
-#include "CameraPreferences.h"
-#include "CameraCommon.h"
-#include "DOMCameraManager.h"
-#include "mozilla/ArrayUtils.h"
-#include "mozilla/Monitor.h"
-#include "mozilla/StaticPtr.h"
-#include "mozilla/Preferences.h"
-#ifdef MOZ_WIDGET_GONK
-#include "mozilla/Services.h"
-#include "nsIObserverService.h"
-#endif
-
-using namespace mozilla;
-
-/* statics */
-static StaticAutoPtr<Monitor> sPrefMonitor;
-
-StaticAutoPtr<nsCString> CameraPreferences::sPrefTestEnabled;
-StaticAutoPtr<nsCString> CameraPreferences::sPrefHardwareTest;
-StaticAutoPtr<nsCString> CameraPreferences::sPrefGonkParameters;
-
-nsresult CameraPreferences::sPrefCameraControlMethodErrorOverride = NS_OK;
-nsresult CameraPreferences::sPrefCameraControlAsyncErrorOverride = NS_OK;
-
-uint32_t CameraPreferences::sPrefCameraControlLowMemoryThresholdMB = 0;
-
-bool CameraPreferences::sPrefCameraParametersIsLowMemory = false;
-
-bool CameraPreferences::sPrefCameraParametersPermission = false;
-
-#ifdef MOZ_WIDGET_GONK
-StaticRefPtr<CameraPreferences> CameraPreferences::sObserver;
-
-NS_IMPL_ISUPPORTS(CameraPreferences, nsIObserver);
-#endif
-
-/* static */
-nsresult
-CameraPreferences::UpdatePref(const char* aPref, nsresult& aVal)
-{
-  uint32_t val;
-  nsresult rv = Preferences::GetUint(aPref, &val);
-  if (NS_SUCCEEDED(rv)) {
-    aVal = static_cast<nsresult>(val);
-  } else if(rv == NS_ERROR_UNEXPECTED) {
-    // Preference does not exist
-    rv = NS_OK;
-    aVal = NS_OK;
-  }
-  return rv;
-}
-
-/* static */
-nsresult
-CameraPreferences::UpdatePref(const char* aPref, uint32_t& aVal)
-{
-  uint32_t val;
-  nsresult rv = Preferences::GetUint(aPref, &val);
-  if (NS_SUCCEEDED(rv)) {
-    aVal = val;
-  } else if(rv == NS_ERROR_UNEXPECTED) {
-    // Preference does not exist
-    rv = NS_OK;
-    aVal = 0;
-  }
-  return rv;
-}
-
-/* static */
-nsresult
-CameraPreferences::UpdatePref(const char* aPref, nsACString& aVal)
-{
-  nsCString val;
-  nsresult rv = Preferences::GetCString(aPref, &val);
-  if (NS_SUCCEEDED(rv)) {
-    aVal = val;
-  } else if(rv == NS_ERROR_UNEXPECTED) {
-    // Preference does not exist
-    rv = NS_OK;
-    aVal.Truncate();
-  }
-  return rv;
-}
-
-/* static */
-nsresult
-CameraPreferences::UpdatePref(const char* aPref, bool& aVal)
-{
-  bool val;
-  nsresult rv = Preferences::GetBool(aPref, &val);
-  if (NS_SUCCEEDED(rv)) {
-    aVal = val;
-  } else if(rv == NS_ERROR_UNEXPECTED) {
-    // Preference does not exist
-    rv = NS_OK;
-    aVal = false;
-  }
-  return rv;
-}
-
-/* static */
-CameraPreferences::Pref CameraPreferences::sPrefs[] = {
-  {
-    "camera.control.test.enabled",
-    kPrefValueIsCString,
-    { &sPrefTestEnabled }
-  },
-  {
-    "camera.control.test.hardware",
-    kPrefValueIsCString,
-    { &sPrefHardwareTest }
-  },
-  {
-    "camera.control.test.permission",
-    kPrefValueIsBoolean,
-    { &sPrefCameraParametersPermission }
-  },
-#ifdef MOZ_B2G
-  {
-    "camera.control.test.hardware.gonk.parameters",
-    kPrefValueIsCString,
-    { &sPrefGonkParameters }
-  },
-#endif
-  {
-    "camera.control.test.method.error",
-    kPrefValueIsNsResult,
-    { &sPrefCameraControlMethodErrorOverride }
-  },
-  {
-    "camera.control.test.async.error",
-    kPrefValueIsNsResult,
-    { &sPrefCameraControlAsyncErrorOverride }
-  },
-  {
-    "camera.control.test.is_low_memory",
-    kPrefValueIsBoolean,
-    { &sPrefCameraParametersIsLowMemory }
-  },
-  {
-    "camera.control.low_memory_thresholdMB",
-    kPrefValueIsUint32,
-    { &sPrefCameraControlLowMemoryThresholdMB }
-  },
-};
-
-/* static */
-uint32_t
-CameraPreferences::PrefToIndex(const char* aPref)
-{
-  for (uint32_t i = 0; i < ArrayLength(sPrefs); ++i) {
-    if (strcmp(aPref, sPrefs[i].mPref) == 0) {
-      return i;
-    }
-  }
-  return kPrefNotFound;
-}
-
-/* static */
-void
-CameraPreferences::PreferenceChanged(const char* aPref, void* aClosure)
-{
-  MonitorAutoLock mon(*sPrefMonitor);
-
-  uint32_t i = PrefToIndex(aPref);
-  if (i == kPrefNotFound) {
-    DOM_CAMERA_LOGE("Preference '%s' is not tracked by CameraPreferences\n", aPref);
-    return;
-  }
-
-  Pref& p = sPrefs[i];
-  nsresult rv;
-  switch (p.mValueType) {
-    case kPrefValueIsNsResult:
-      {
-        nsresult& v = *p.mValue.mAsNsResult;
-        rv = UpdatePref(aPref, v);
-        if (NS_SUCCEEDED(rv)) {
-          DOM_CAMERA_LOGI("Preference '%s' has changed, 0x%x\n", aPref, v);
-        }
-      }
-      break;
-
-    case kPrefValueIsUint32:
-      {
-        uint32_t& v = *p.mValue.mAsUint32;
-        rv = UpdatePref(aPref, v);
-        if (NS_SUCCEEDED(rv)) {
-          DOM_CAMERA_LOGI("Preference '%s' has changed, %u\n", aPref, v);
-        }
-      }
-      break;
-
-    case kPrefValueIsCString:
-      {
-        nsCString& v = **p.mValue.mAsCString;
-        rv = UpdatePref(aPref, v);
-        if (NS_SUCCEEDED(rv)) {
-          DOM_CAMERA_LOGI("Preference '%s' has changed, '%s'\n", aPref, v.get());
-        }
-      }
-      break;
-
-    case kPrefValueIsBoolean:
-      {
-        bool& v = *p.mValue.mAsBoolean;
-        rv = UpdatePref(aPref, v);
-        if (NS_SUCCEEDED(rv)) {
-          DOM_CAMERA_LOGI("Preference '%s' has changed, %s\n",
-            aPref, v ? "true" : "false");
-        }
-      }
-      break;
-
-    default:
-      MOZ_ASSERT_UNREACHABLE("Unhandled preference value type!");
-      return;
-  }
-
-  if (NS_FAILED(rv)) {
-    DOM_CAMERA_LOGE("Failed to get pref '%s' (0x%x)\n", aPref, rv);
-  }
-}
-
-/* static */
-bool
-CameraPreferences::Initialize()
-{
-  DOM_CAMERA_LOGI("Initializing camera preference callbacks\n");
-
-  nsresult rv;
-
-#ifdef MOZ_WIDGET_GONK
-  nsCOMPtr<nsIObserverService> obs = services::GetObserverService();
-  if (obs) {
-    sObserver = new CameraPreferences();
-    rv = obs->AddObserver(sObserver, "init-camera-hw", false);
-    if (NS_WARN_IF(NS_FAILED(rv))) {
-      sObserver = nullptr;
-    }
-  } else {
-    DOM_CAMERA_LOGE("Could not get observer service\n");
-  }
-#endif
-
-  sPrefMonitor = new Monitor("CameraPreferences.sPrefMonitor");
-
-  sPrefTestEnabled = new nsCString();
-  sPrefHardwareTest = new nsCString();
-  sPrefGonkParameters = new nsCString();
-
-  for (uint32_t i = 0; i < ArrayLength(sPrefs); ++i) {
-    rv = Preferences::RegisterCallbackAndCall(CameraPreferences::PreferenceChanged,
-                                              sPrefs[i].mPref);
-    if (NS_WARN_IF(NS_FAILED(rv))) {
-      return false;
-    }
-  }
-
-  DOM_CAMERA_LOGI("Camera preferences initialized\n");
-  return true;
-}
-
-/* static */
-void
-CameraPreferences::Shutdown()
-{
-  DOM_CAMERA_LOGI("Shutting down camera preference callbacks\n");
-
-  for (uint32_t i = 0; i < ArrayLength(sPrefs); ++i) {
-    Preferences::UnregisterCallback(CameraPreferences::PreferenceChanged,
-                                    sPrefs[i].mPref);
-  }
-
-  sPrefTestEnabled = nullptr;
-  sPrefHardwareTest = nullptr;
-  sPrefGonkParameters = nullptr;
-  sPrefMonitor = nullptr;
-
-#ifdef MOZ_WIDGET_GONK
-  nsCOMPtr<nsIObserverService> obs = services::GetObserverService();
-  if (obs) {
-    nsresult rv = obs->RemoveObserver(sObserver , "init-camera-hw");
-    if (NS_FAILED(rv)) {
-      DOM_CAMERA_LOGE("Failed to remove CameraPreferences observer (0x%x)\n", rv);
-    }
-    sObserver = nullptr;
-  } else {
-    DOM_CAMERA_LOGE("Could not get observer service\n");
-  }
-#endif
-
-  DOM_CAMERA_LOGI("Camera preferences shut down\n");
-}
-
-#ifdef MOZ_WIDGET_GONK
-nsresult
-CameraPreferences::PreinitCameraHardware()
-{
-  nsDOMCameraManager::PreinitCameraHardware();
-  return NS_OK;
-}
-
-NS_IMETHODIMP
-CameraPreferences::Observe(nsISupports* aSubject, const char* aTopic, const char16_t* aData)
-{
-  if (strcmp(aTopic, "init-camera-hw") == 0) {
-    return PreinitCameraHardware();
-  }
-
-  DOM_CAMERA_LOGE("Got unhandled topic '%s'\n", aTopic);
-  return NS_OK;
-}
-#endif
-
-/* static */
-bool
-CameraPreferences::GetPref(const char* aPref, nsACString& aVal)
-{
-  MOZ_ASSERT(sPrefMonitor, "sPrefMonitor missing in CameraPreferences::GetPref()");
-  MonitorAutoLock mon(*sPrefMonitor);
-
-  uint32_t i = PrefToIndex(aPref);
-  if (i == kPrefNotFound || i >= ArrayLength(sPrefs)) {
-    DOM_CAMERA_LOGW("Preference '%s' is not tracked by CameraPreferences\n", aPref);
-    return false;
-  }
-  if (sPrefs[i].mValueType != kPrefValueIsCString) {
-    DOM_CAMERA_LOGW("Preference '%s' is not a string type\n", aPref);
-    return false;
-  }
-
-  StaticAutoPtr<nsCString>* s = sPrefs[i].mValue.mAsCString;
-  if (!*s) {
-    DOM_CAMERA_LOGE("Preference '%s' cache is not initialized\n", aPref);
-    return false;
-  }
-  if ((*s)->IsEmpty()) {
-    DOM_CAMERA_LOGI("Preference '%s' is not set\n", aPref);
-    return false;
-  }
-
-  DOM_CAMERA_LOGI("Preference '%s', got '%s'\n", aPref, (*s)->get());
-  aVal = **s;
-  return true;
-}
-
-/* static */
-bool
-CameraPreferences::GetPref(const char* aPref, nsresult& aVal)
-{
-  MOZ_ASSERT(sPrefMonitor, "sPrefMonitor missing in CameraPreferences::GetPref()");
-  MonitorAutoLock mon(*sPrefMonitor);
-
-  uint32_t i = PrefToIndex(aPref);
-  if (i == kPrefNotFound || i >= ArrayLength(sPrefs)) {
-    DOM_CAMERA_LOGW("Preference '%s' is not tracked by CameraPreferences\n", aPref);
-    return false;
-  }
-  if (sPrefs[i].mValueType != kPrefValueIsNsResult) {
-    DOM_CAMERA_LOGW("Preference '%s' is not an nsresult type\n", aPref);
-    return false;
-  }
-
-  nsresult v = *sPrefs[i].mValue.mAsNsResult;
-  if (v == NS_OK) {
-    DOM_CAMERA_LOGW("Preference '%s' is not set\n", aPref);
-    return false;
-  }
-
-  DOM_CAMERA_LOGI("Preference '%s', got 0x%x\n", aPref, v);
-  aVal = v;
-  return true;
-}
-
-/* static */
-bool
-CameraPreferences::GetPref(const char* aPref, uint32_t& aVal)
-{
-  MOZ_ASSERT(sPrefMonitor, "sPrefMonitor missing in CameraPreferences::GetPref()");
-  MonitorAutoLock mon(*sPrefMonitor);
-
-  uint32_t i = PrefToIndex(aPref);
-  if (i == kPrefNotFound || i >= ArrayLength(sPrefs)) {
-    DOM_CAMERA_LOGW("Preference '%s' is not tracked by CameraPreferences\n", aPref);
-    return false;
-  }
-  if (sPrefs[i].mValueType != kPrefValueIsUint32) {
-    DOM_CAMERA_LOGW("Preference '%s' is not a uint32_t type\n", aPref);
-    return false;
-  }
-
-  uint32_t v = *sPrefs[i].mValue.mAsUint32;
-  DOM_CAMERA_LOGI("Preference '%s', got %u\n", aPref, v);
-  aVal = v;
-  return true;
-}
-
-/* static */
-bool
-CameraPreferences::GetPref(const char* aPref, bool& aVal)
-{
-  MOZ_ASSERT(sPrefMonitor, "sPrefMonitor missing in CameraPreferences::GetPref()");
-  MonitorAutoLock mon(*sPrefMonitor);
-
-  uint32_t i = PrefToIndex(aPref);
-  if (i == kPrefNotFound || i >= ArrayLength(sPrefs)) {
-    DOM_CAMERA_LOGW("Preference '%s' is not tracked by CameraPreferences\n", aPref);
-    return false;
-  }
-  if (sPrefs[i].mValueType != kPrefValueIsBoolean) {
-    DOM_CAMERA_LOGW("Preference '%s' is not a boolean type\n", aPref);
-    return false;
-  }
-
-  bool v = *sPrefs[i].mValue.mAsBoolean;
-  DOM_CAMERA_LOGI("Preference '%s', got %s\n", aPref, v ? "true" : "false");
-  aVal = v;
-  return true;
-}
deleted file mode 100644
--- a/dom/camera/CameraPreferences.h
+++ /dev/null
@@ -1,104 +0,0 @@
-/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
-/* This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
-
-#ifndef DOM_CAMERA_CAMERAPREFERENCES_H
-#define DOM_CAMERA_CAMERAPREFERENCES_H
-
-#include "nsString.h"
-#include "nsIObserver.h"
-#ifdef MOZ_WIDGET_GONK
-#include "mozilla/StaticPtr.h"
-#endif
-
-namespace mozilla {
-
-template<class T> class StaticAutoPtr;
-
-class CameraPreferences
-#ifdef MOZ_WIDGET_GONK
-  : public nsIObserver
-#endif
-{
-public:
-#ifdef MOZ_WIDGET_GONK
-  NS_DECL_ISUPPORTS
-  NS_DECL_NSIOBSERVER
-#endif
-
-  static bool Initialize();
-  static void Shutdown();
-
-  static bool GetPref(const char* aPref, nsACString& aVal);
-  static bool GetPref(const char* aPref, nsresult& aVal);
-  static bool GetPref(const char* aPref, uint32_t& aVal);
-  static bool GetPref(const char* aPref, bool& aVal);
-
-protected:
-  static const uint32_t kPrefNotFound = UINT32_MAX;
-  static uint32_t PrefToIndex(const char* aPref);
-
-  static void PreferenceChanged(const char* aPref, void* aClosure);
-  static nsresult UpdatePref(const char* aPref, nsresult& aVar);
-  static nsresult UpdatePref(const char* aPref, uint32_t& aVar);
-  static nsresult UpdatePref(const char* aPref, nsACString& aVar);
-  static nsresult UpdatePref(const char* aPref, bool& aVar);
-
-  enum PrefValueType {
-    kPrefValueIsNsResult,
-    kPrefValueIsUint32,
-    kPrefValueIsCString,
-    kPrefValueIsBoolean
-  };
-  struct Pref {
-    const char* const           mPref;
-    PrefValueType               mValueType;
-    union {
-      // The 'mAsVoid' member must be first and is required to allow 'mValue'
-      // to be initialized with any pointer type, as not all of our platforms
-      // support the use of designated initializers; in their absence, only
-      // the first element of a union can be statically initialized, and
-      // 'void*' lets us stuff any pointer type into it.
-      void*                     mAsVoid;
-      StaticAutoPtr<nsCString>* mAsCString;
-      nsresult*                 mAsNsResult;
-      uint32_t*                 mAsUint32;
-      bool*                     mAsBoolean;
-    } mValue;
-  };
-  static Pref sPrefs[];
-
-  static StaticAutoPtr<nsCString> sPrefTestEnabled;
-  static StaticAutoPtr<nsCString> sPrefHardwareTest;
-  static StaticAutoPtr<nsCString> sPrefGonkParameters;
-
-  static nsresult sPrefCameraControlMethodErrorOverride;
-  static nsresult sPrefCameraControlAsyncErrorOverride;
-
-  static uint32_t sPrefCameraControlLowMemoryThresholdMB;
-
-  static bool sPrefCameraParametersIsLowMemory;
-
-  static bool sPrefCameraParametersPermission;
-
-#ifdef MOZ_WIDGET_GONK
-  static StaticRefPtr<CameraPreferences> sObserver;
-
-  nsresult PreinitCameraHardware();
-
-protected:
-  // Objects may be instantiated for use as observers.
-  CameraPreferences() { }
-  virtual ~CameraPreferences() { }
-#else
-private:
-  // Static class only.
-  CameraPreferences();
-  ~CameraPreferences();
-#endif
-};
-
-} // namespace mozilla
-
-#endif // DOM_CAMERA_CAMERAPREFERENCES_H
deleted file mode 100644
--- a/dom/camera/CameraPreviewMediaStream.cpp
+++ /dev/null
@@ -1,200 +0,0 @@
-/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-*/
-/* This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this file,
- * You can obtain one at http://mozilla.org/MPL/2.0/. */
-
-#include "CameraPreviewMediaStream.h"
-#include "CameraCommon.h"
-#include "MediaStreamListener.h"
-#include "VideoFrameContainer.h"
-
-/**
- * Maximum number of outstanding invalidates before we start to drop frames;
- * if we hit this threshold, it is an indicator that the main thread is
- * either very busy or the device is busy elsewhere (e.g. encoding or
- * persisting video data).
- */
-#define MAX_INVALIDATE_PENDING 4
-
-using namespace mozilla::layers;
-using namespace mozilla::dom;
-
-namespace mozilla {
-
-static const TrackID TRACK_VIDEO = 2;
-
-void
-FakeMediaStreamGraph::DispatchToMainThreadAfterStreamStateUpdate(already_AddRefed<nsIRunnable> aRunnable)
-{
-  nsCOMPtr<nsIRunnable> task = aRunnable;
-  NS_DispatchToMainThread(task);
-}
-
-CameraPreviewMediaStream::CameraPreviewMediaStream()
-  : ProcessedMediaStream()
-  , mMutex("mozilla::camera::CameraPreviewMediaStream")
-  , mInvalidatePending(0)
-  , mDiscardedFrames(0)
-  , mRateLimit(false)
-  , mTrackCreated(false)
-{
-  SetGraphImpl(
-      MediaStreamGraph::GetInstance(
-        MediaStreamGraph::SYSTEM_THREAD_DRIVER, AudioChannel::Normal));
-  mFakeMediaStreamGraph = new FakeMediaStreamGraph();
-}
-
-void
-CameraPreviewMediaStream::AddAudioOutput(void* aKey)
-{
-}
-
-void
-CameraPreviewMediaStream::SetAudioOutputVolume(void* aKey, float aVolume)
-{
-}
-
-void
-CameraPreviewMediaStream::RemoveAudioOutput(void* aKey)
-{
-}
-
-void
-CameraPreviewMediaStream::AddVideoOutput(MediaStreamVideoSink* aSink, TrackID aID)
-{
-  MutexAutoLock lock(mMutex);
-  RefPtr<MediaStreamVideoSink> sink = aSink;
-  AddVideoOutputImpl(sink.forget(), aID);
-}
-
-void
-CameraPreviewMediaStream::RemoveVideoOutput(MediaStreamVideoSink* aSink, TrackID aID)
-{
-  MutexAutoLock lock(mMutex);
-  RemoveVideoOutputImpl(aSink, aID);
-}
-
-void
-CameraPreviewMediaStream::AddListener(MediaStreamListener* aListener)
-{
-  MutexAutoLock lock(mMutex);
-
-  MediaStreamListener* listener = *mListeners.AppendElement() = aListener;
-  listener->NotifyBlockingChanged(mFakeMediaStreamGraph, MediaStreamListener::UNBLOCKED);
-  listener->NotifyHasCurrentData(mFakeMediaStreamGraph);
-}
-
-void
-CameraPreviewMediaStream::RemoveListener(MediaStreamListener* aListener)
-{
-  MutexAutoLock lock(mMutex);
-
-  RefPtr<MediaStreamListener> listener(aListener);
-  mListeners.RemoveElement(aListener);
-  listener->NotifyEvent(mFakeMediaStreamGraph, MediaStreamGraphEvent::EVENT_REMOVED);
-}
-
-void
-CameraPreviewMediaStream::OnPreviewStateChange(bool aActive)
-{
-  if (aActive) {
-    MutexAutoLock lock(mMutex);
-    if (!mTrackCreated) {
-      mTrackCreated = true;
-      VideoSegment tmpSegment;
-      for (uint32_t j = 0; j < mListeners.Length(); ++j) {
-        MediaStreamListener* l = mListeners[j];
-        l->NotifyQueuedTrackChanges(mFakeMediaStreamGraph, TRACK_VIDEO, 0,
-                                    TrackEventCommand::TRACK_EVENT_CREATED,
-                                    tmpSegment);
-        l->NotifyFinishedTrackCreation(mFakeMediaStreamGraph);
-      }
-    }
-  }
-}
-
-void
-CameraPreviewMediaStream::Destroy()
-{
-  MutexAutoLock lock(mMutex);
-  mMainThreadDestroyed = true;
-  DestroyImpl();
-}
-
-void
-CameraPreviewMediaStream::Invalidate()
-{
-  MutexAutoLock lock(mMutex);
-  --mInvalidatePending;
-  for (const TrackBound<MediaStreamVideoSink>& sink : mVideoOutputs) {
-    VideoFrameContainer* output = sink.mListener->AsVideoFrameContainer();
-    if (!output) {
-      continue;
-    }
-    output->Invalidate();
-  }
-}
-
-void
-CameraPreviewMediaStream::ProcessInput(GraphTime aFrom, GraphTime aTo,
-                                       uint32_t aFlags)
-{
-  return;
-}
-
-void
-CameraPreviewMediaStream::RateLimit(bool aLimit)
-{
-  mRateLimit = aLimit;
-}
-
-void
-CameraPreviewMediaStream::SetCurrentFrame(const gfx::IntSize& aIntrinsicSize, Image* aImage)
-{
-  {
-    MutexAutoLock lock(mMutex);
-
-    if (mInvalidatePending > 0) {
-      if (mRateLimit || mInvalidatePending > MAX_INVALIDATE_PENDING) {
-        ++mDiscardedFrames;
-        DOM_CAMERA_LOGW("Discard preview frame %d, %d invalidation(s) pending",
-          mDiscardedFrames, mInvalidatePending);
-        return;
-      }
-
-      DOM_CAMERA_LOGI("Update preview frame, %d invalidation(s) pending",
-        mInvalidatePending);
-    }
-    mDiscardedFrames = 0;
-
-    TimeStamp now = TimeStamp::Now();
-    for (const TrackBound<MediaStreamVideoSink>& sink : mVideoOutputs) {
-      VideoFrameContainer* output = sink.mListener->AsVideoFrameContainer();
-      if (!output) {
-        continue;
-      }
-      output->SetCurrentFrame(aIntrinsicSize, aImage, now);
-    }
-
-    ++mInvalidatePending;
-  }
-
-  NS_DispatchToMainThread(NewRunnableMethod(this, &CameraPreviewMediaStream::Invalidate));
-}
-
-void
-CameraPreviewMediaStream::ClearCurrentFrame()
-{
-  MutexAutoLock lock(mMutex);
-
-  for (const TrackBound<MediaStreamVideoSink>& sink : mVideoOutputs) {
-    VideoFrameContainer* output = sink.mListener->AsVideoFrameContainer();
-    if (!output) {
-      continue;
-    }
-    output->ClearCurrentFrame();
-    NS_DispatchToMainThread(NewRunnableMethod(output, &VideoFrameContainer::Invalidate));
-  }
-}
-
-} // namespace mozilla
deleted file mode 100644
--- a/dom/camera/CameraPreviewMediaStream.h
+++ /dev/null
@@ -1,81 +0,0 @@
-/* This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this file,
- * You can obtain one at http://mozilla.org/MPL/2.0/. */
-
-#ifndef DOM_CAMERA_CAMERAPREVIEWMEDIASTREAM_H
-#define DOM_CAMERA_CAMERAPREVIEWMEDIASTREAM_H
-
-#include "MediaStreamGraph.h"
-#include "mozilla/Mutex.h"
-
-namespace mozilla {
-
-class MediaStreamVideoSink;
-
-class FakeMediaStreamGraph : public MediaStreamGraph
-{
-  NS_INLINE_DECL_THREADSAFE_REFCOUNTING(FakeMediaStreamGraph)
-public:
-  FakeMediaStreamGraph()
-    : MediaStreamGraph(16000)
-  {
-  }
-
-  virtual void
-  DispatchToMainThreadAfterStreamStateUpdate(already_AddRefed<nsIRunnable> aRunnable) override;
-
-protected:
-  ~FakeMediaStreamGraph()
-  {}
-};
-
-/**
- * This is a stream for camera preview.
- *
- * XXX It is a temporary fix of SourceMediaStream.
- * A camera preview requests no delay and no buffering stream,
- * but the SourceMediaStream does not support it.
- */
-class CameraPreviewMediaStream : public ProcessedMediaStream
-{
-  typedef mozilla::layers::Image Image;
-
-public:
-  CameraPreviewMediaStream();
-
-  void AddAudioOutput(void* aKey) override;
-  void SetAudioOutputVolume(void* aKey, float aVolume) override;
-  void RemoveAudioOutput(void* aKey) override;
-  void AddVideoOutput(MediaStreamVideoSink* aSink, TrackID aID) override;
-  void RemoveVideoOutput(MediaStreamVideoSink* aSink, TrackID aID) override;
-  void Suspend() override {}
-  void Resume() override {}
-  void AddListener(MediaStreamListener* aListener) override;
-  void RemoveListener(MediaStreamListener* aListener) override;
-  void Destroy() override;
-  void OnPreviewStateChange(bool aActive);
-
-  void Invalidate();
-
-  void ProcessInput(GraphTime aFrom, GraphTime aTo, uint32_t aFlags) override;
-
-  // Call these on any thread.
-  void SetCurrentFrame(const gfx::IntSize& aIntrinsicSize, Image* aImage);
-  void ClearCurrentFrame();
-  void RateLimit(bool aLimit);
-
-protected:
-  // mMutex protects all the class' fields.
-  // This class is not registered to MediaStreamGraph.
-  // It needs to protect all the fields.
-  Mutex mMutex;
-  int32_t mInvalidatePending;
-  uint32_t mDiscardedFrames;
-  bool mRateLimit;
-  bool mTrackCreated;
-  RefPtr<FakeMediaStreamGraph> mFakeMediaStreamGraph;
-};
-
-} // namespace mozilla
-
-#endif // DOM_CAMERA_CAMERAPREVIEWMEDIASTREAM_H
deleted file mode 100644
--- a/dom/camera/DOMCameraCapabilities.cpp
+++ /dev/null
@@ -1,604 +0,0 @@
-/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
-/* vim:set ts=2 sw=2 sts=2 et cindent: */
-/* This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
-
-#include "DOMCameraCapabilities.h"
-#include "nsPIDOMWindow.h"
-#include "nsContentUtils.h"
-#include "nsProxyRelease.h"
-#include "mozilla/dom/CameraManagerBinding.h"
-#include "mozilla/dom/CameraCapabilitiesBinding.h"
-#include "Navigator.h"
-#include "CameraCommon.h"
-#include "ICameraControl.h"
-#include "CameraControlListener.h"
-
-namespace mozilla {
-namespace dom {
-
-/**
- * CameraClosedListenerProxy and CameraClosedMessage
- */
-template<class T>
-class CameraClosedMessage : public Runnable
-{
-public:
-  explicit CameraClosedMessage(nsMainThreadPtrHandle<T> aListener)
-    : mListener(aListener)
-  {
-    DOM_CAMERA_LOGT("%s:%d : this=%p\n", __func__, __LINE__, this);
-  }
-
-  NS_IMETHOD
-  Run() override
-  {
-    MOZ_ASSERT(NS_IsMainThread());
-
-    RefPtr<T> listener = mListener.get();
-    if (listener) {
-      listener->OnHardwareClosed();
-    }
-    return NS_OK;
-  }
-
-protected:
-  virtual ~CameraClosedMessage()
-  {
-    DOM_CAMERA_LOGT("%s:%d : this=%p\n", __func__, __LINE__, this);
-  }
-
-  nsMainThreadPtrHandle<T> mListener;
-};
-
-template<class T>
-class CameraClosedListenerProxy : public CameraControlListener
-{
-public:
-  explicit CameraClosedListenerProxy(T* aListener)
-    : mListener(new nsMainThreadPtrHolder<T>(aListener))
-  {
-    DOM_CAMERA_LOGT("%s:%d : this=%p\n", __func__, __LINE__, this);
-  }
-
-  virtual void
-  OnHardwareStateChange(HardwareState aState, nsresult aReason) override
-  {
-    if (aState != kHardwareClosed) {
-      return;
-    }
-    NS_DispatchToMainThread(new CameraClosedMessage<T>(mListener));
-  }
-
-protected:
-  virtual ~CameraClosedListenerProxy()
-  {
-    DOM_CAMERA_LOGT("%s:%d : this=%p\n", __func__, __LINE__, this);
-  }
-
-  nsMainThreadPtrHandle<T> mListener;
-};
-
-/**
- * CameraRecorderVideoProfile
- */
-NS_IMPL_CYCLE_COLLECTION_WRAPPERCACHE(CameraRecorderVideoProfile, mParent)
-
-NS_IMPL_CYCLE_COLLECTING_ADDREF(CameraRecorderVideoProfile)
-NS_IMPL_CYCLE_COLLECTING_RELEASE(CameraRecorderVideoProfile)
-
-NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(CameraRecorderVideoProfile)
-  NS_WRAPPERCACHE_INTERFACE_MAP_ENTRY
-  NS_INTERFACE_MAP_ENTRY(nsISupports)
-NS_INTERFACE_MAP_END
-
-JSObject*
-CameraRecorderVideoProfile::WrapObject(JSContext* aCx, JS::Handle<JSObject*> aGivenProto)
-{
-  return CameraRecorderVideoProfileBinding::Wrap(aCx, this, aGivenProto);
-}
-
-CameraRecorderVideoProfile::CameraRecorderVideoProfile(nsISupports* aParent,
-    const ICameraControl::RecorderProfile::Video& aProfile)
-  : mParent(aParent)
-  , mCodec(aProfile.GetCodec())
-  , mBitrate(aProfile.GetBitsPerSecond())
-  , mFramerate(aProfile.GetFramesPerSecond())
-{
-  DOM_CAMERA_LOGT("%s:%d : this=%p\n", __func__, __LINE__, this);
-
-  mSize.mWidth = aProfile.GetSize().width;
-  mSize.mHeight = aProfile.GetSize().height;
-
-  DOM_CAMERA_LOGI("  video: '%s' %ux%u bps=%u fps=%u\n",
-    NS_ConvertUTF16toUTF8(mCodec).get(), mSize.mWidth, mSize.mHeight, mBitrate, mFramerate);
-}
-
-CameraRecorderVideoProfile::~CameraRecorderVideoProfile()
-{
-  DOM_CAMERA_LOGT("%s:%d : this=%p\n", __func__, __LINE__, this);
-}
-
-/**
- * CameraRecorderAudioProfile
- */
-NS_IMPL_CYCLE_COLLECTION_WRAPPERCACHE(CameraRecorderAudioProfile, mParent)
-
-NS_IMPL_CYCLE_COLLECTING_ADDREF(CameraRecorderAudioProfile)
-NS_IMPL_CYCLE_COLLECTING_RELEASE(CameraRecorderAudioProfile)
-
-NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(CameraRecorderAudioProfile)
-  NS_WRAPPERCACHE_INTERFACE_MAP_ENTRY
-  NS_INTERFACE_MAP_ENTRY(nsISupports)
-NS_INTERFACE_MAP_END
-
-JSObject*
-CameraRecorderAudioProfile::WrapObject(JSContext* aCx, JS::Handle<JSObject*> aGivenProto)
-{
-  return CameraRecorderAudioProfileBinding::Wrap(aCx, this, aGivenProto);
-}
-
-CameraRecorderAudioProfile::CameraRecorderAudioProfile(nsISupports* aParent,
-    const ICameraControl::RecorderProfile::Audio& aProfile)
-  : mParent(aParent)
-  , mCodec(aProfile.GetCodec())
-  , mBitrate(aProfile.GetBitsPerSecond())
-  , mSamplerate(aProfile.GetSamplesPerSecond())
-  , mChannels(aProfile.GetChannels())
-{
-  DOM_CAMERA_LOGT("%s:%d : this=%p\n", __func__, __LINE__, this);
-  DOM_CAMERA_LOGI("  audio: '%s' bps=%u samples/s=%u channels=%u\n",
-    NS_ConvertUTF16toUTF8(mCodec).get(), mBitrate, mSamplerate, mChannels);
-}
-
-CameraRecorderAudioProfile::~CameraRecorderAudioProfile()
-{
-  DOM_CAMERA_LOGT("%s:%d : this=%p\n", __func__, __LINE__, this);
-}
-
-/**
- * CameraRecorderProfile
- */
-NS_IMPL_CYCLE_COLLECTION_WRAPPERCACHE(CameraRecorderProfile,
-                                      mParent,
-                                      mVideo,
-                                      mAudio)
-
-NS_IMPL_CYCLE_COLLECTING_ADDREF(CameraRecorderProfile)
-NS_IMPL_CYCLE_COLLECTING_RELEASE(CameraRecorderProfile)
-
-NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(CameraRecorderProfile)
-  NS_WRAPPERCACHE_INTERFACE_MAP_ENTRY
-  NS_INTERFACE_MAP_ENTRY(nsISupports)
-NS_INTERFACE_MAP_END
-
-JSObject*
-CameraRecorderProfile::WrapObject(JSContext* aCx, JS::Handle<JSObject*> aGivenProto)
-{
-  return CameraRecorderProfileBinding::Wrap(aCx, this, aGivenProto);
-}
-
-CameraRecorderProfile::CameraRecorderProfile(nsISupports* aParent,
-                                             const ICameraControl::RecorderProfile& aProfile)
-  : mParent(aParent)
-  , mName(aProfile.GetName())
-  , mContainerFormat(aProfile.GetContainer())
-  , mMimeType(aProfile.GetMimeType())
-  , mVideo(new CameraRecorderVideoProfile(this, aProfile.GetVideo()))
-  , mAudio(new CameraRecorderAudioProfile(this, aProfile.GetAudio()))
-{
-  DOM_CAMERA_LOGT("%s:%d : this=%p\n", __func__, __LINE__, this);
-  DOM_CAMERA_LOGI("profile: '%s' container=%s mime-type=%s\n",
-    NS_ConvertUTF16toUTF8(mName).get(),
-    NS_ConvertUTF16toUTF8(mContainerFormat).get(),
-    NS_ConvertUTF16toUTF8(mMimeType).get());
-}
-
-CameraRecorderProfile::~CameraRecorderProfile()
-{
-  DOM_CAMERA_LOGT("%s:%d : this=%p\n", __func__, __LINE__, this);
-}
-
-/**
- * CameraRecorderProfiles
- */
-NS_IMPL_CYCLE_COLLECTION_WRAPPERCACHE(CameraRecorderProfiles,
-                                      mParent,
-                                      mProfiles)
-
-NS_IMPL_CYCLE_COLLECTING_ADDREF(CameraRecorderProfiles)
-NS_IMPL_CYCLE_COLLECTING_RELEASE(CameraRecorderProfiles)
-
-NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(CameraRecorderProfiles)
-  NS_WRAPPERCACHE_INTERFACE_MAP_ENTRY
-  NS_INTERFACE_MAP_ENTRY(nsISupports)
-NS_INTERFACE_MAP_END
-
-JSObject*
-CameraRecorderProfiles::WrapObject(JSContext* aCx, JS::Handle<JSObject*> aGivenProto)
-{
-  return CameraRecorderProfilesBinding::Wrap(aCx, this, aGivenProto);
-}
-
-CameraRecorderProfiles::CameraRecorderProfiles(nsISupports* aParent,
-                                               ICameraControl* aCameraControl)
-  : mParent(aParent)
-  , mCameraControl(aCameraControl)
-{
-  DOM_CAMERA_LOGT("%s:%d : this=%p\n", __func__, __LINE__, this);
-  if (mCameraControl) {
-    mListener = new CameraClosedListenerProxy<CameraRecorderProfiles>(this);
-    mCameraControl->AddListener(mListener);
-  }
-}
-
-CameraRecorderProfiles::~CameraRecorderProfiles()
-{
-  DOM_CAMERA_LOGT("%s:%d : this=%p\n", __func__, __LINE__, this);
-}
-
-void
-CameraRecorderProfiles::GetSupportedNames(nsTArray<nsString>& aNames)
-{
-  DOM_CAMERA_LOGT("%s:%d : this=%p\n",
-    __func__, __LINE__, this);
-  if (!mCameraControl) {
-    aNames.Clear();
-    return;
-  }
-
-  nsresult rv = mCameraControl->GetRecorderProfiles(aNames);
-  if (NS_WARN_IF(NS_FAILED(rv))) {
-    aNames.Clear();
-  }
-}
-
-CameraRecorderProfile*
-CameraRecorderProfiles::NamedGetter(const nsAString& aName, bool& aFound)
-{
-  DOM_CAMERA_LOGT("%s:%d : this=%p, name='%s'\n", __func__, __LINE__, this,
-    NS_ConvertUTF16toUTF8(aName).get());
-  if (!mCameraControl) {
-    return nullptr;
-  }
-
-  CameraRecorderProfile* profile = mProfiles.GetWeak(aName, &aFound);
-  if (!aFound || !profile) {
-    RefPtr<ICameraControl::RecorderProfile> p = mCameraControl->GetProfileInfo(aName);
-    if (p) {
-      profile = new CameraRecorderProfile(this, *p);
-      mProfiles.Put(aName, profile);
-      aFound = true;
-    }
-  }
-  return profile;
-}
-
-void
-CameraRecorderProfiles::OnHardwareClosed()
-{
-  DOM_CAMERA_LOGT("%s:%d : this=%p\n", __func__, __LINE__, this);
-  MOZ_ASSERT(NS_IsMainThread());
-
-  if (mCameraControl) {
-    mCameraControl->RemoveListener(mListener);
-    mCameraControl = nullptr;
-  }
-  mListener = nullptr;
-}
-
-/**
- * CameraCapabilities
- */
-NS_IMPL_CYCLE_COLLECTION_WRAPPERCACHE(CameraCapabilities, mWindow)
-
-NS_IMPL_CYCLE_COLLECTING_ADDREF(CameraCapabilities)
-NS_IMPL_CYCLE_COLLECTING_RELEASE(CameraCapabilities)
-
-NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(CameraCapabilities)
-  NS_WRAPPERCACHE_INTERFACE_MAP_ENTRY
-  NS_INTERFACE_MAP_ENTRY(nsISupports)
-NS_INTERFACE_MAP_END
-
-/* static */
-bool
-CameraCapabilities::HasSupport(JSContext* aCx, JSObject* aGlobal)
-{
-  return Navigator::HasCameraSupport(aCx, aGlobal);
-}
-
-CameraCapabilities::CameraCapabilities(nsPIDOMWindowInner* aWindow,
-                                       ICameraControl* aCameraControl)
-  : mWindow(aWindow)
-  , mCameraControl(aCameraControl)
-{
-  DOM_CAMERA_LOGT("%s:%d : this=%p\n", __func__, __LINE__, this);
-  MOZ_COUNT_CTOR(CameraCapabilities);
-  if (mCameraControl) {
-    mListener = new CameraClosedListenerProxy<CameraCapabilities>(this);
-    mCameraControl->AddListener(mListener);
-  }
-}
-
-CameraCapabilities::~CameraCapabilities()
-{
-  DOM_CAMERA_LOGT("%s:%d : this=%p\n", __func__, __LINE__, this);
-  MOZ_COUNT_DTOR(CameraCapabilities);
-}
-
-void
-CameraCapabilities::OnHardwareClosed()
-{
-  DOM_CAMERA_LOGT("%s:%d : this=%p\n", __func__, __LINE__, this);
-  MOZ_ASSERT(NS_IsMainThread());
-
-  if (mCameraControl) {
-    mCameraControl->RemoveListener(mListener);
-    mCameraControl = nullptr;
-  }
-  mListener = nullptr;
-}
-
-JSObject*
-CameraCapabilities::WrapObject(JSContext* aCx, JS::Handle<JSObject*> aGivenProto)
-{
-  return CameraCapabilitiesBinding::Wrap(aCx, this, aGivenProto);
-}
-
-#define LOG_IF_ERROR(rv, param)                               \
-  do {                                                        \
-    if (NS_FAILED(rv)) {                                      \
-      DOM_CAMERA_LOGW("Error %x trying to get " #param "\n",  \
-        (rv));                                                \
-    }                                                         \
-  } while(0)
-
-nsresult
-CameraCapabilities::TranslateToDictionary(uint32_t aKey, nsTArray<CameraSize>& aSizes)
-{
-  if (NS_WARN_IF(!mCameraControl)) {
-    return NS_ERROR_NOT_AVAILABLE;
-  }
-
-  nsresult rv;
-  nsTArray<ICameraControl::Size> sizes;
-
-  rv = mCameraControl->Get(aKey, sizes);
-  if (NS_FAILED(rv)) {
-    return rv;
-  }
-
-  aSizes.Clear();
-  aSizes.SetCapacity(sizes.Length());
-  for (uint32_t i = 0; i < sizes.Length(); ++i) {
-    CameraSize* s = aSizes.AppendElement();
-    s->mWidth = sizes[i].width;
-    s->mHeight = sizes[i].height;
-  }
-
-  return NS_OK;
-}
-
-// The following attributes are tagged [Cached, Constant] in the WebIDL, so
-// the framework will handle caching them for us.
-
-void
-CameraCapabilities::GetPreviewSizes(nsTArray<dom::CameraSize>& aRetVal)
-{
-  nsresult rv = TranslateToDictionary(CAMERA_PARAM_SUPPORTED_PREVIEWSIZES, aRetVal);
-  LOG_IF_ERROR(rv, CAMERA_PARAM_SUPPORTED_PREVIEWSIZES);
-}
-
-void
-CameraCapabilities::GetPictureSizes(nsTArray<dom::CameraSize>& aRetVal)
-{
-  nsresult rv = TranslateToDictionary(CAMERA_PARAM_SUPPORTED_PICTURESIZES, aRetVal);
-  LOG_IF_ERROR(rv, CAMERA_PARAM_SUPPORTED_PICTURESIZES);
-}
-
-void
-CameraCapabilities::GetThumbnailSizes(nsTArray<dom::CameraSize>& aRetVal)
-{
-  nsresult rv = TranslateToDictionary(CAMERA_PARAM_SUPPORTED_JPEG_THUMBNAIL_SIZES, aRetVal);
-  LOG_IF_ERROR(rv, CAMERA_PARAM_SUPPORTED_JPEG_THUMBNAIL_SIZES);
-}
-
-void
-CameraCapabilities::GetVideoSizes(nsTArray<dom::CameraSize>& aRetVal)
-{
-  nsresult rv = TranslateToDictionary(CAMERA_PARAM_SUPPORTED_VIDEOSIZES, aRetVal);
-  LOG_IF_ERROR(rv, CAMERA_PARAM_SUPPORTED_VIDEOSIZES);
-}
-
-void
-CameraCapabilities::GetFileFormats(nsTArray<nsString>& aRetVal)
-{
-  if (NS_WARN_IF(!mCameraControl)) {
-    return;
-  }
-
-  nsresult rv = mCameraControl->Get(CAMERA_PARAM_SUPPORTED_PICTUREFORMATS, aRetVal);
-  LOG_IF_ERROR(rv, CAMERA_PARAM_SUPPORTED_PICTUREFORMATS);
-}
-
-void
-CameraCapabilities::GetWhiteBalanceModes(nsTArray<nsString>& aRetVal)
-{
-  if (NS_WARN_IF(!mCameraControl)) {
-    return;
-  }
-
-  nsresult rv = mCameraControl->Get(CAMERA_PARAM_SUPPORTED_WHITEBALANCES, aRetVal);
-  LOG_IF_ERROR(rv, CAMERA_PARAM_SUPPORTED_WHITEBALANCES);
-}
-
-void
-CameraCapabilities::GetSceneModes(nsTArray<nsString>& aRetVal)
-{
-  if (NS_WARN_IF(!mCameraControl)) {
-    return;
-  }
-
-  nsresult rv = mCameraControl->Get(CAMERA_PARAM_SUPPORTED_SCENEMODES, aRetVal);
-  LOG_IF_ERROR(rv, CAMERA_PARAM_SUPPORTED_SCENEMODES);
-}
-
-void
-CameraCapabilities::GetEffects(nsTArray<nsString>& aRetVal)
-{
-  if (NS_WARN_IF(!mCameraControl)) {
-    return;
-  }
-
-  nsresult rv = mCameraControl->Get(CAMERA_PARAM_SUPPORTED_EFFECTS, aRetVal);
-  LOG_IF_ERROR(rv, CAMERA_PARAM_SUPPORTED_EFFECTS);
-}
-
-void
-CameraCapabilities::GetFlashModes(nsTArray<nsString>& aRetVal)
-{
-  if (NS_WARN_IF(!mCameraControl)) {
-    return;
-  }
-
-  nsresult rv = mCameraControl->Get(CAMERA_PARAM_SUPPORTED_FLASHMODES, aRetVal);
-  LOG_IF_ERROR(rv, CAMERA_PARAM_SUPPORTED_FLASHMODES);
-}
-
-void
-CameraCapabilities::GetFocusModes(nsTArray<nsString>& aRetVal)
-{
-  if (NS_WARN_IF(!mCameraControl)) {
-    return;
-  }
-
-  nsresult rv = mCameraControl->Get(CAMERA_PARAM_SUPPORTED_FOCUSMODES, aRetVal);
-  LOG_IF_ERROR(rv, CAMERA_PARAM_SUPPORTED_FOCUSMODES);
-}
-
-void
-CameraCapabilities::GetZoomRatios(nsTArray<double>& aRetVal)
-{
-  if (NS_WARN_IF(!mCameraControl)) {
-    return;
-  }
-
-  nsresult rv = mCameraControl->Get(CAMERA_PARAM_SUPPORTED_ZOOMRATIOS, aRetVal);
-  LOG_IF_ERROR(rv, CAMERA_PARAM_SUPPORTED_ZOOMRATIOS);
-}
-
-uint32_t
-CameraCapabilities::MaxFocusAreas()
-{
-  if (NS_WARN_IF(!mCameraControl)) {
-    return 0;
-  }
-
-  int32_t areas = 0;
-  nsresult rv = mCameraControl->Get(CAMERA_PARAM_SUPPORTED_MAXFOCUSAREAS, areas);
-  LOG_IF_ERROR(rv, CAMERA_PARAM_SUPPORTED_MAXFOCUSAREAS);
-  return areas < 0 ? 0 : areas;
-}
-
-uint32_t
-CameraCapabilities::MaxMeteringAreas()
-{
-  if (NS_WARN_IF(!mCameraControl)) {
-    return 0;
-  }
-
-  int32_t areas = 0;
-  nsresult rv = mCameraControl->Get(CAMERA_PARAM_SUPPORTED_MAXMETERINGAREAS, areas);
-  LOG_IF_ERROR(rv, CAMERA_PARAM_SUPPORTED_MAXMETERINGAREAS);
-  return areas < 0 ? 0 : areas;
-}
-
-uint32_t
-CameraCapabilities::MaxDetectedFaces()
-{
-  if (NS_WARN_IF(!mCameraControl)) {
-    return 0;
-  }
-
-  int32_t faces = 0;
-  nsresult rv = mCameraControl->Get(CAMERA_PARAM_SUPPORTED_MAXDETECTEDFACES, faces);
-  LOG_IF_ERROR(rv, CAMERA_PARAM_SUPPORTED_MAXDETECTEDFACES);
-  return faces < 0 ? 0 : faces;
-}
-
-double
-CameraCapabilities::MinExposureCompensation()
-{
-  if (NS_WARN_IF(!mCameraControl)) {
-    return 0.0;
-  }
-
-  double minEv = 0.0;
-  nsresult rv = mCameraControl->Get(CAMERA_PARAM_SUPPORTED_MINEXPOSURECOMPENSATION, minEv);
-  LOG_IF_ERROR(rv, CAMERA_PARAM_SUPPORTED_MINEXPOSURECOMPENSATION);
-  return minEv;
-}
-
-double
-CameraCapabilities::MaxExposureCompensation()
-{
-  if (NS_WARN_IF(!mCameraControl)) {
-    return 0.0;
-  }
-
-  double maxEv = 0.0;
-  nsresult rv = mCameraControl->Get(CAMERA_PARAM_SUPPORTED_MAXEXPOSURECOMPENSATION, maxEv);
-  LOG_IF_ERROR(rv, CAMERA_PARAM_SUPPORTED_MAXEXPOSURECOMPENSATION);
-  return maxEv;
-}
-
-double
-CameraCapabilities::ExposureCompensationStep()
-{
-  if (NS_WARN_IF(!mCameraControl)) {
-    return 0.0;
-  }
-
-  double evStep = 0.0;
-  nsresult rv = mCameraControl->Get(CAMERA_PARAM_SUPPORTED_EXPOSURECOMPENSATIONSTEP, evStep);
-  LOG_IF_ERROR(rv, CAMERA_PARAM_SUPPORTED_EXPOSURECOMPENSATIONSTEP);
-  return evStep;
-}
-
-CameraRecorderProfiles*
-CameraCapabilities::RecorderProfiles()
-{
-  if (NS_WARN_IF(!mCameraControl)) {
-    return nullptr;
-  }
-
-  RefPtr<CameraRecorderProfiles> profiles =
-    new CameraRecorderProfiles(this, mCameraControl);
-  return profiles;
-}
-
-void
-CameraCapabilities::GetIsoModes(nsTArray<nsString>& aRetVal)
-{
-  if (NS_WARN_IF(!mCameraControl)) {
-    return;
-  }
-
-  nsresult rv = mCameraControl->Get(CAMERA_PARAM_SUPPORTED_ISOMODES, aRetVal);
-  LOG_IF_ERROR(rv, CAMERA_PARAM_SUPPORTED_ISOMODES);
-}
-
-void
-CameraCapabilities::GetMeteringModes(nsTArray<nsString>& aRetVal)
-{
-  if (NS_WARN_IF(!mCameraControl)) {
-    return;
-  }
-
-  nsresult rv = mCameraControl->Get(CAMERA_PARAM_SUPPORTED_METERINGMODES, aRetVal);
-  LOG_IF_ERROR(rv, CAMERA_PARAM_SUPPORTED_METERINGMODES);
-}
-
-} // namespace dom
-} // namespace mozilla
deleted file mode 100644
--- a/dom/camera/DOMCameraCapabilities.h
+++ /dev/null
@@ -1,243 +0,0 @@
-/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
-/* vim:set ts=2 sw=2 sts=2 et cindent: */
-/* This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
-
-#ifndef mozilla_dom_CameraCapabilities_h__
-#define mozilla_dom_CameraCapabilities_h__
-
-#include "nsString.h"
-#include "base/basictypes.h"
-#include "mozilla/Attributes.h"
-#include "mozilla/ErrorResult.h"
-#include "mozilla/dom/CameraManagerBinding.h"
-#include "nsCycleCollectionParticipant.h"
-#include "nsWrapperCache.h"
-#include "nsPIDOMWindow.h"
-#include "nsHashKeys.h"
-#include "nsRefPtrHashtable.h"
-#include "nsDataHashtable.h"
-#include "ICameraControl.h"
-
-struct JSContext;
-
-namespace mozilla {
-namespace dom {
-
-/**
- * CameraRecorderVideoProfile
- */
-class CameraRecorderVideoProfile final : public nsISupports
-                                       , public nsWrapperCache
-{
-public:
-  NS_DECL_CYCLE_COLLECTING_ISUPPORTS
-  NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS(CameraRecorderVideoProfile)
-
-  explicit CameraRecorderVideoProfile(nsISupports* aParent,
-    const ICameraControl::RecorderProfile::Video& aProfile);
-  nsISupports* GetParentObject() const        { return mParent; }
-  virtual JSObject* WrapObject(JSContext* aCx, JS::Handle<JSObject*> aGivenProto) override;
-
-  uint32_t BitsPerSecond() const              { return mBitrate; }
-  uint32_t FramesPerSecond() const            { return mFramerate; }
-  void GetCodec(nsAString& aCodec) const      { aCodec = mCodec; }
-
-  void GetSize(dom::CameraSize& aSize) const  { aSize = mSize; }
-
-  // XXXmikeh - legacy, remove these when the Camera app is updated
-  uint32_t Width() const                      { return mSize.mWidth; }
-  uint32_t Height() const                     { return mSize.mHeight; }
-
-protected:
-  virtual ~CameraRecorderVideoProfile();
-
-  nsCOMPtr<nsISupports> mParent;
-
-  const nsString mCodec;
-  uint32_t mBitrate;
-  uint32_t mFramerate;
-  dom::CameraSize mSize;
-
-private:
-  DISALLOW_EVIL_CONSTRUCTORS(CameraRecorderVideoProfile);
-};
-
-/**
- * CameraRecorderAudioProfile
- */
-class CameraRecorderAudioProfile final : public nsISupports
-                                       , public nsWrapperCache
-{
-public:
-  NS_DECL_CYCLE_COLLECTING_ISUPPORTS
-  NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS(CameraRecorderAudioProfile)
-
-  explicit CameraRecorderAudioProfile(nsISupports* aParent,
-    const ICameraControl::RecorderProfile::Audio& aProfile);
-  nsISupports* GetParentObject() const    { return mParent; }
-  virtual JSObject* WrapObject(JSContext* aCx, JS::Handle<JSObject*> aGivenProto) override;
-
-  uint32_t BitsPerSecond() const          { return mBitrate; }
-  uint32_t SamplesPerSecond() const       { return mSamplerate; }
-  uint32_t Channels() const               { return mChannels; }
-  void GetCodec(nsAString& aCodec) const  { aCodec = mCodec; }
-
-protected:
-  virtual ~CameraRecorderAudioProfile();
-
-  nsCOMPtr<nsISupports> mParent;
-
-  const nsString mCodec;
-  uint32_t mBitrate;
-  uint32_t mSamplerate;
-  uint32_t mChannels;
-
-private:
-  DISALLOW_EVIL_CONSTRUCTORS(CameraRecorderAudioProfile);
-};
-
-/**
- * CameraRecorderProfile
- */
-class CameraRecorderProfile final : public nsISupports
-                                  , public nsWrapperCache
-{
-public:
-  NS_DECL_CYCLE_COLLECTING_ISUPPORTS
-  NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS(CameraRecorderProfile)
-
-  explicit CameraRecorderProfile(nsISupports* aParent,
-                                 const ICameraControl::RecorderProfile& aProfile);
-  nsISupports* GetParentObject() const          { return mParent; }
-  virtual JSObject* WrapObject(JSContext* aCx, JS::Handle<JSObject*> aGivenProto) override;
-
-  void GetMimeType(nsAString& aMimeType) const  { aMimeType = mMimeType; }
-
-  CameraRecorderVideoProfile* Video()           { return mVideo; }
-  CameraRecorderAudioProfile* Audio()           { return mAudio; }
-
-  void GetName(nsAString& aName) const          { aName = mName; }
-
-  void
-  GetContainerFormat(nsAString& aContainerFormat) const
-  {
-    aContainerFormat = mContainerFormat;
-  }
-
-protected:
-  virtual ~CameraRecorderProfile();
-
-  nsCOMPtr<nsISupports> mParent;
-
-  const nsString mName;
-  const nsString mContainerFormat;
-  const nsString mMimeType;
-
-  RefPtr<CameraRecorderVideoProfile> mVideo;
-  RefPtr<CameraRecorderAudioProfile> mAudio;
-
-private:
-  DISALLOW_EVIL_CONSTRUCTORS(CameraRecorderProfile);
-};
-
-/**
- * CameraRecorderProfiles
- */
-template<class T> class CameraClosedListenerProxy;
-
-class CameraRecorderProfiles final : public nsISupports
-                                   , public nsWrapperCache
-{
-public:
-  NS_DECL_CYCLE_COLLECTING_ISUPPORTS
-  NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS(CameraRecorderProfiles)
-
-  explicit CameraRecorderProfiles(nsISupports* aParent,
-                                  ICameraControl* aCameraControl);
-  nsISupports* GetParentObject() const { return mParent; }
-  virtual JSObject* WrapObject(JSContext* aCx, JS::Handle<JSObject*> aGivenProto) override;
-
-  CameraRecorderProfile* NamedGetter(const nsAString& aName, bool& aFound);
-  void GetSupportedNames(nsTArray<nsString>& aNames);
-
-  virtual void OnHardwareClosed();
-
-protected:
-  virtual ~CameraRecorderProfiles();
-
-  nsCOMPtr<nsISupports> mParent;
-  RefPtr<ICameraControl> mCameraControl;
-  nsRefPtrHashtable<nsStringHashKey, CameraRecorderProfile> mProfiles;
-  RefPtr<CameraClosedListenerProxy<CameraRecorderProfiles>> mListener;
-
-private:
-  DISALLOW_EVIL_CONSTRUCTORS(CameraRecorderProfiles);
-};
-
-/**
- * CameraCapabilities
- */
-class CameraCapabilities final : public nsISupports
-                               , public nsWrapperCache
-{
-public:
-  NS_DECL_CYCLE_COLLECTING_ISUPPORTS
-  NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS(CameraCapabilities)
-
-  // Because this header's filename doesn't match its C++ or DOM-facing
-  // classname, we can't rely on the [Func="..."] WebIDL tag to implicitly
-  // include the right header for us; instead we must explicitly include a
-  // HasSupport() method in each header. We can get rid of these with the
-  // Great Renaming proposed in bug 983177.
-  static bool HasSupport(JSContext* aCx, JSObject* aGlobal);
-
-  explicit CameraCapabilities(nsPIDOMWindowInner* aWindow,
-                              ICameraControl* aCameraControl);
-
-  nsPIDOMWindowInner* GetParentObject() const { return mWindow; }
-
-  virtual JSObject* WrapObject(JSContext* aCx, JS::Handle<JSObject*> aGivenProto) override;
-
-  void GetPreviewSizes(nsTArray<CameraSize>& aRetVal);
-  void GetPictureSizes(nsTArray<CameraSize>& aRetVal);
-  void GetThumbnailSizes(nsTArray<CameraSize>& aRetVal);
-  void GetVideoSizes(nsTArray<CameraSize>& aRetVal);
-  void GetFileFormats(nsTArray<nsString>& aRetVal);
-  void GetWhiteBalanceModes(nsTArray<nsString>& aRetVal);
-  void GetSceneModes(nsTArray<nsString>& aRetVal);
-  void GetEffects(nsTArray<nsString>& aRetVal);
-  void GetFlashModes(nsTArray<nsString>& aRetVal);
-  void GetFocusModes(nsTArray<nsString>& aRetVal);
-  void GetZoomRatios(nsTArray<double>& aRetVal);
-  uint32_t MaxFocusAreas();
-  uint32_t MaxMeteringAreas();
-  uint32_t MaxDetectedFaces();
-  double MinExposureCompensation();
-  double MaxExposureCompensation();
-  double ExposureCompensationStep();
-  void GetIsoModes(nsTArray<nsString>& aRetVal);
-  void GetMeteringModes(nsTArray<nsString>& aRetVal);
-
-  CameraRecorderProfiles* RecorderProfiles();
-
-  virtual void OnHardwareClosed();
-
-protected:
-  ~CameraCapabilities();
-
-  nsresult TranslateToDictionary(uint32_t aKey, nsTArray<CameraSize>& aSizes);
-
-  RefPtr<nsPIDOMWindowInner> mWindow;
-  RefPtr<ICameraControl> mCameraControl;
-  RefPtr<CameraClosedListenerProxy<CameraCapabilities>> mListener;
-
-private:
-  DISALLOW_EVIL_CONSTRUCTORS(CameraCapabilities);
-};
-
-} // namespace dom
-} // namespace mozilla
-
-#endif // mozilla_dom_CameraCapabilities_h__
deleted file mode 100755
--- a/dom/camera/DOMCameraControl.cpp
+++ /dev/null
@@ -1,1729 +0,0 @@
-/* This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this file,
- * You can obtain one at http://mozilla.org/MPL/2.0/. */
-
-#include "DOMCameraControl.h"
-#include "base/basictypes.h"
-#include "nsCOMPtr.h"
-#include "nsDOMClassInfo.h"
-#include "nsHashPropertyBag.h"
-#include "nsThread.h"
-#include "DeviceStorage.h"
-#include "DeviceStorageFileDescriptor.h"
-#include "mozilla/dom/File.h"
-#include "mozilla/dom/TabChild.h"
-#include "mozilla/ipc/FileDescriptorUtils.h"
-#include "mozilla/MediaManager.h"
-#include "mozilla/Services.h"
-#include "mozilla/Unused.h"
-#include "nsIAppsService.h"
-#include "nsIObserverService.h"
-#include "nsIDOMEventListener.h"
-#include "nsIScriptSecurityManager.h"
-#include "Navigator.h"
-#include "nsXULAppAPI.h"
-#include "DOMCameraManager.h"
-#include "DOMCameraCapabilities.h"
-#include "CameraCommon.h"
-#include "nsGlobalWindow.h"
-#include "CameraPreviewMediaStream.h"
-#include "mozilla/dom/CameraUtilBinding.h"
-#include "mozilla/dom/CameraControlBinding.h"
-#include "mozilla/dom/CameraManagerBinding.h"
-#include "mozilla/dom/CameraCapabilitiesBinding.h"
-#include "mozilla/dom/CameraConfigurationEvent.h"
-#include "mozilla/dom/CameraConfigurationEventBinding.h"
-#include "mozilla/dom/CameraFacesDetectedEvent.h"
-#include "mozilla/dom/CameraFacesDetectedEventBinding.h"
-#include "mozilla/dom/CameraStateChangeEvent.h"
-#include "mozilla/dom/CameraClosedEvent.h"
-#include "mozilla/dom/VideoStreamTrack.h"
-#include "mozilla/dom/BlobEvent.h"
-#include "DOMCameraDetectedFace.h"
-#include "mozilla/dom/BindingUtils.h"
-#include "nsPrintfCString.h"
-
-using namespace mozilla;
-using namespace mozilla::dom;
-using namespace mozilla::ipc;
-
-class mozilla::TrackCreatedListener : public MediaStreamListener
-{
-public:
-  explicit TrackCreatedListener(nsDOMCameraControl* aCameraControl)
-    : mCameraControl(aCameraControl) {}
-
-  void Forget() { mCameraControl = nullptr; }
-
-  void DoNotifyTrackCreated(TrackID aTrackID)
-  {
-    MOZ_ASSERT(NS_IsMainThread());
-
-    if (!mCameraControl) {
-      return;
-    }
-
-    mCameraControl->TrackCreated(aTrackID);
-  }
-
-  void NotifyQueuedTrackChanges(MediaStreamGraph* aGraph, TrackID aID,
-                                StreamTime aTrackOffset, TrackEventCommand aTrackEvents,
-                                const MediaSegment& aQueuedMedia,
-                                MediaStream* aInputStream,
-                                TrackID aInputTrackID) override
-  {
-    if (aTrackEvents & TrackEventCommand::TRACK_EVENT_CREATED) {
-      aGraph->DispatchToMainThreadAfterStreamStateUpdate(NewRunnableMethod<TrackID>(
-          this, &TrackCreatedListener::DoNotifyTrackCreated, aID));
-    }
-  }
-
-protected:
-  ~TrackCreatedListener() {}
-
-  nsDOMCameraControl* mCameraControl;
-};
-
-#ifdef MOZ_WIDGET_GONK
-StaticRefPtr<ICameraControl> nsDOMCameraControl::sCachedCameraControl;
-/* static */ nsresult nsDOMCameraControl::sCachedCameraControlStartResult = NS_OK;
-/* static */ nsCOMPtr<nsITimer> nsDOMCameraControl::sDiscardCachedCameraControlTimer;
-#endif
-
-NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION_INHERITED(nsDOMCameraControl)
-  NS_INTERFACE_MAP_ENTRY(nsISupportsWeakReference)
-  // nsISupports is an ambiguous base of nsDOMCameraControl
-  // so we have to work around that.
-  if ( aIID.Equals(NS_GET_IID(nsDOMCameraControl)) )
-    foundInterface = static_cast<nsISupports*>(static_cast<void*>(this));
-  else
-NS_INTERFACE_MAP_END_INHERITING(DOMMediaStream)
-
-NS_IMPL_ADDREF_INHERITED(nsDOMCameraControl, DOMMediaStream)
-NS_IMPL_RELEASE_INHERITED(nsDOMCameraControl, DOMMediaStream)
-
-NS_IMPL_CYCLE_COLLECTION_INHERITED(nsDOMCameraControl, DOMMediaStream,
-                                   mAudioChannelAgent,
-                                   mCapabilities,
-                                   mWindow,
-                                   mGetCameraPromise,
-                                   mAutoFocusPromise,
-                                   mTakePicturePromise,
-                                   mStartRecordingPromise,
-                                   mReleasePromise,
-                                   mSetConfigurationPromise)
-
-/* static */
-bool
-nsDOMCameraControl::HasSupport(JSContext* aCx, JSObject* aGlobal)
-{
-  return Navigator::HasCameraSupport(aCx, aGlobal);
-}
-
-static nsresult
-RegisterStorageRequestEvents(DOMRequest* aRequest, nsIDOMEventListener* aListener)
-{
-  EventListenerManager* elm = aRequest->GetOrCreateListenerManager();
-  if (NS_WARN_IF(!elm)) {
-    return NS_ERROR_UNEXPECTED;
-  }
-
-  elm->AddEventListener(NS_LITERAL_STRING("success"), aListener, false, false);
-  elm->AddEventListener(NS_LITERAL_STRING("error"), aListener, false, false);
-  return NS_OK;
-}
-
-class mozilla::StartRecordingHelper : public nsIDOMEventListener
-{
-public:
-  NS_DECL_ISUPPORTS
-  NS_DECL_NSIDOMEVENTLISTENER
-
-  explicit StartRecordingHelper(nsDOMCameraControl* aDOMCameraControl)
-    : mDOMCameraControl(aDOMCameraControl)
-    , mState(false)
-  {
-    MOZ_COUNT_CTOR(StartRecordingHelper);
-  }
-
-protected:
-  virtual ~StartRecordingHelper()
-  {
-    MOZ_COUNT_DTOR(StartRecordingHelper);
-    mDOMCameraControl->OnCreatedFileDescriptor(mState);
-  }
-
-protected:
-  RefPtr<nsDOMCameraControl> mDOMCameraControl;
-  bool mState;
-};
-
-NS_IMETHODIMP
-StartRecordingHelper::HandleEvent(nsIDOMEvent* aEvent)
-{
-  nsString eventType;
-  aEvent->GetType(eventType);
-  mState = eventType.EqualsLiteral("success");
-  return NS_OK;
-}
-
-NS_IMPL_ISUPPORTS(mozilla::StartRecordingHelper, nsIDOMEventListener)
-
-nsDOMCameraControl::DOMCameraConfiguration::DOMCameraConfiguration()
-  : CameraConfiguration()
-  , mMaxFocusAreas(0)
-  , mMaxMeteringAreas(0)
-{
-  MOZ_COUNT_CTOR(nsDOMCameraControl::DOMCameraConfiguration);
-}
-
-nsDOMCameraControl::DOMCameraConfiguration::DOMCameraConfiguration(const CameraConfiguration& aConfiguration)
-  : CameraConfiguration(aConfiguration)
-  , mMaxFocusAreas(0)
-  , mMaxMeteringAreas(0)
-{
-  MOZ_COUNT_CTOR(nsDOMCameraControl::DOMCameraConfiguration);
-}
-
-nsDOMCameraControl::DOMCameraConfiguration::~DOMCameraConfiguration()
-{
-  MOZ_COUNT_DTOR(nsDOMCameraControl::DOMCameraConfiguration);
-}
-
-#ifdef MOZ_WIDGET_GONK
-// This should be long enough for even our slowest platforms.
-static const unsigned long kCachedCameraTimeoutMs = 3500;
-
-// Open the battery-door-facing camera by default.
-static const uint32_t kDefaultCameraId = 0;
-
-/* static */ void
-nsDOMCameraControl::PreinitCameraHardware()
-{
-  // Assume a default, minimal configuration. This should initialize the
-  // hardware, but won't (can't) start the preview.
-  RefPtr<ICameraControl> cameraControl = ICameraControl::Create(kDefaultCameraId);
-  if (NS_WARN_IF(!cameraControl)) {
-    return;
-  }
-
-  sCachedCameraControlStartResult = cameraControl->Start();
-  if (NS_WARN_IF(NS_FAILED(sCachedCameraControlStartResult))) {
-    return;
-  }
-
-  sCachedCameraControl = cameraControl;
-
-  nsCOMPtr<nsITimer> timer = do_CreateInstance(NS_TIMER_CONTRACTID);
-  if (NS_WARN_IF(!timer)) {
-    return;
-  }
-
-  nsresult rv = timer->InitWithFuncCallback(DiscardCachedCameraInstance,
-                                            nullptr,
-                                            kCachedCameraTimeoutMs,
-                                            nsITimer::TYPE_ONE_SHOT);
-  if (NS_WARN_IF(NS_FAILED(rv))) {
-    // If we can't start the timer, it's possible for an app to never grab the
-    // camera, leaving the hardware tied up indefinitely. Better to take the
-    // performance hit.
-    sCachedCameraControl = nullptr;
-    return;
-  }
-
-  sDiscardCachedCameraControlTimer = timer;
-}
-
-/* static */ void
-nsDOMCameraControl::DiscardCachedCameraInstance(nsITimer* aTimer, void* aClosure)
-{
-  MOZ_ASSERT(NS_IsMainThread());
-
-  sDiscardCachedCameraControlTimer = nullptr;
-  sCachedCameraControl = nullptr;
-}
-#endif
-
-nsDOMCameraControl::nsDOMCameraControl(uint32_t aCameraId,
-                                       const CameraConfiguration& aInitialConfig,
-                                       Promise* aPromise,
-                                       nsPIDOMWindowInner* aWindow)
-  : DOMMediaStream(aWindow, nullptr)
-  , mCameraControl(nullptr)
-  , mAudioChannelAgent(nullptr)
-  , mGetCameraPromise(aPromise)
-  , mWindow(aWindow)
-  , mPreviewState(CameraControlListener::kPreviewStopped)
-  , mRecording(false)
-  , mRecordingStoppedDeferred(false)
-  , mSetInitialConfig(false)
-{
-  DOM_CAMERA_LOGT("%s:%d : this=%p\n", __func__, __LINE__, this);
-  mInput = new CameraPreviewMediaStream();
-  mOwnedStream = mInput;
-
-  BindToOwner(aWindow);
-
-  RefPtr<DOMCameraConfiguration> initialConfig =
-    new DOMCameraConfiguration(aInitialConfig);
-
-  // Create and initialize the underlying camera.
-  ICameraControl::Configuration config;
-  bool haveInitialConfig = false;
-  nsresult rv;
-
-  switch (aInitialConfig.mMode) {
-    case CameraMode::Picture:
-      config.mMode = ICameraControl::kPictureMode;
-      haveInitialConfig = true;
-      break;
-
-    case CameraMode::Video:
-      config.mMode = ICameraControl::kVideoMode;
-      haveInitialConfig = true;
-      break;
-
-    case CameraMode::Unspecified:
-      break;
-
-    default:
-      MOZ_ASSERT_UNREACHABLE("Unanticipated camera mode!");
-      break;
-  }
-
-  if (haveInitialConfig) {
-    rv = SelectPreviewSize(aInitialConfig.mPreviewSize, config.mPreviewSize);
-    if (NS_FAILED(rv)) {
-      mListener->OnUserError(DOMCameraControlListener::kInStartCamera, rv);
-      return;
-    }
-
-    config.mPictureSize.width = aInitialConfig.mPictureSize.mWidth;
-    config.mPictureSize.height = aInitialConfig.mPictureSize.mHeight;
-    config.mRecorderProfile = aInitialConfig.mRecorderProfile;
-  }
-
-#ifdef MOZ_WIDGET_GONK
-  bool gotCached = false;
-  if (sCachedCameraControl && aCameraId == kDefaultCameraId) {
-    mCameraControl = sCachedCameraControl;
-    sCachedCameraControl = nullptr;
-    gotCached = true;
-  } else {
-    sCachedCameraControl = nullptr;
-#endif
-    mCameraControl = ICameraControl::Create(aCameraId);
-#ifdef MOZ_WIDGET_GONK
-  }
-#endif
-  mCurrentConfiguration = initialConfig.forget();
-
-  // Register a TrackCreatedListener directly on CameraPreviewMediaStream
-  // so we can know the TrackID of the video track.
-  mTrackCreatedListener = new TrackCreatedListener(this);
-  mInput->AddListener(mTrackCreatedListener);
-
-  // Register the playback listener directly on the camera input stream.
-  // We want as low latency as possible for the camera, thus avoiding
-  // MediaStreamGraph altogether. Don't do the regular InitStreamCommon()
-  // to avoid initializing the Owned and Playback streams. This is OK since
-  // we are not user/DOM facing anyway.
-  CreateAndAddPlaybackStreamListener(mInput);
-
-  // Register a listener for camera events.
-  mListener = new DOMCameraControlListener(this, mInput);
-  mCameraControl->AddListener(mListener);
-
-#ifdef MOZ_WIDGET_GONK
-  if (!gotCached || NS_FAILED(sCachedCameraControlStartResult)) {
-#endif
-    // Start the camera...
-    if (haveInitialConfig) {
-      rv = mCameraControl->Start(&config);
-      if (NS_SUCCEEDED(rv)) {
-        mSetInitialConfig = true;
-      }
-    } else {
-      rv = mCameraControl->Start();
-    }
-#ifdef MOZ_WIDGET_GONK
-  } else {
-    if (haveInitialConfig) {
-      rv = mCameraControl->SetConfiguration(config);
-      if (NS_SUCCEEDED(rv)) {
-        mSetInitialConfig = true;
-      }
-    } else {
-      rv = NS_OK;
-    }
-  }
-#endif
-  if (NS_FAILED(rv)) {
-    mListener->OnUserError(DOMCameraControlListener::kInStartCamera, rv);
-  }
-}
-
-nsDOMCameraControl::~nsDOMCameraControl()
-{
-  DOM_CAMERA_LOGT("%s:%d : this=%p\n", __func__, __LINE__, this);
-  /*invoke DOMMediaStream destroy*/
-  Destroy();
-
-  if (mInput) {
-    mInput->Destroy();
-    mInput = nullptr;
-  }
-  if (mTrackCreatedListener) {
-    mTrackCreatedListener->Forget();
-    mTrackCreatedListener = nullptr;
-  }
-}
-
-JSObject*
-nsDOMCameraControl::WrapObject(JSContext* aCx, JS::Handle<JSObject*> aGivenProto)
-{
-  return CameraControlBinding::Wrap(aCx, this, aGivenProto);
-}
-
-bool
-nsDOMCameraControl::IsWindowStillActive()
-{
-  return nsDOMCameraManager::IsWindowStillActive(mWindow->WindowID());
-}
-
-nsresult
-nsDOMCameraControl::SelectPreviewSize(const CameraSize& aRequestedPreviewSize, ICameraControl::Size& aSelectedPreviewSize)
-{
-  if (aRequestedPreviewSize.mWidth && aRequestedPreviewSize.mHeight) {
-    aSelectedPreviewSize.width = aRequestedPreviewSize.mWidth;
-    aSelectedPreviewSize.height = aRequestedPreviewSize.mHeight;
-  } else {
-    /* Use the window width and height if no preview size is provided.
-       Note that the width and height are actually reversed from the
-       camera perspective. */
-    int32_t width = 0;
-    int32_t height = 0;
-    float ratio = 0.0;
-    nsresult rv;
-
-    rv = mWindow->GetDevicePixelRatio(&ratio);
-    if (NS_WARN_IF(NS_FAILED(rv))) {
-      return rv;
-    }
-
-    rv = mWindow->GetInnerWidth(&height);
-    if (NS_WARN_IF(NS_FAILED(rv))) {
-      return rv;
-    }
-
-    rv = mWindow->GetInnerHeight(&width);
-    if (NS_WARN_IF(NS_FAILED(rv))) {
-      return rv;
-    }
-
-    MOZ_ASSERT(width > 0);
-    MOZ_ASSERT(height > 0);
-    MOZ_ASSERT(ratio > 0.0);
-    aSelectedPreviewSize.width = std::ceil(width * ratio);
-    aSelectedPreviewSize.height = std::ceil(height * ratio);
-  }
-
-  return NS_OK;
-}
-
-// Setter for weighted regions: { top, bottom, left, right, weight }
-nsresult
-nsDOMCameraControl::Set(uint32_t aKey, const Optional<Sequence<CameraRegion> >& aValue, uint32_t aLimit)
-{
-  if (aLimit == 0) {
-    DOM_CAMERA_LOGI("%s:%d : aLimit = 0, nothing to do\n", __func__, __LINE__);
-    return NS_OK;
-  }
-
-  nsTArray<ICameraControl::Region> regionArray;
-  if (aValue.WasPassed()) {
-    const Sequence<CameraRegion>& regions = aValue.Value();
-    uint32_t length = regions.Length();
-
-    DOM_CAMERA_LOGI("%s:%d : got %d regions (limited to %d)\n", __func__, __LINE__, length, aLimit);
-    if (length > aLimit) {
-      length = aLimit;
-    }
-
-    // aLimit supplied by camera library provides sane ceiling (i.e. <10)
-    regionArray.SetCapacity(length);
-
-    for (uint32_t i = 0; i < length; ++i) {
-      ICameraControl::Region* r = regionArray.AppendElement();
-      const CameraRegion &region = regions[i];
-      r->top = region.mTop;
-      r->left = region.mLeft;
-      r->bottom = region.mBottom;
-      r->right = region.mRight;
-      r->weight = region.mWeight;
-
-      DOM_CAMERA_LOGI("region %d: top=%d, left=%d, bottom=%d, right=%d, weight=%u\n",
-        i,
-        r->top,
-        r->left,
-        r->bottom,
-        r->right,
-        r->weight
-      );
-    }
-  } else {
-    DOM_CAMERA_LOGI("%s:%d : clear regions\n", __func__, __LINE__);
-  }
-  return mCameraControl->Set(aKey, regionArray);
-}
-
-// Getter for weighted regions: { top, bottom, left, right, weight }
-nsresult
-nsDOMCameraControl::Get(uint32_t aKey, nsTArray<CameraRegion>& aValue)
-{
-  nsTArray<ICameraControl::Region> regionArray;
-
-  nsresult rv = mCameraControl->Get(aKey, regionArray);
-  NS_ENSURE_SUCCESS(rv, rv);
-
-  uint32_t length = regionArray.Length();
-  DOM_CAMERA_LOGI("%s:%d : got %d regions\n", __func__, __LINE__, length);
-  aValue.SetLength(length);
-
-  for (uint32_t i = 0; i < length; ++i) {
-    ICameraControl::Region& r = regionArray[i];
-    CameraRegion& v = aValue[i];
-    v.mTop = r.top;
-    v.mLeft = r.left;
-    v.mBottom = r.bottom;
-    v.mRight = r.right;
-    v.mWeight = r.weight;
-
-    DOM_CAMERA_LOGI("region %d: top=%d, left=%d, bottom=%d, right=%d, weight=%u\n",
-      i,
-      v.mTop,
-      v.mLeft,
-      v.mBottom,
-      v.mRight,
-      v.mWeight
-    );
-  }
-
-  return NS_OK;
-}
-
-MediaStream*
-nsDOMCameraControl::GetCameraStream() const
-{
-  return mInput;
-}
-
-void
-nsDOMCameraControl::TrackCreated(TrackID aTrackID) {
-  MOZ_ASSERT(NS_IsMainThread());
-  MOZ_RELEASE_ASSERT(mWindow, "Shouldn't have been created with a null window!");
-  nsIPrincipal* principal = mWindow->GetExtantDoc()
-                          ? mWindow->GetExtantDoc()->NodePrincipal()
-                          : nullptr;
-
-  // This track is not connected through a port.
-  MediaInputPort* inputPort = nullptr;
-  dom::VideoStreamTrack* track =
-    new dom::VideoStreamTrack(this, aTrackID, aTrackID,
-                              new BasicUnstoppableTrackSource(principal));
-  RefPtr<TrackPort> port =
-    new TrackPort(inputPort, track,
-                  TrackPort::InputPortOwnership::OWNED);
-  mTracks.AppendElement(port.forget());
-  NotifyTrackAdded(track);
-}
-
-#define THROW_IF_NO_CAMERACONTROL(...)                                          \
-  do {                                                                          \
-    if (!mCameraControl) {                                                      \
-      DOM_CAMERA_LOGW("mCameraControl is null at %s:%d\n", __func__, __LINE__); \
-      aRv = NS_ERROR_NOT_AVAILABLE;                                             \
-      return __VA_ARGS__;                                                       \
-    }                                                                           \
-  } while (0)
-
-void
-nsDOMCameraControl::GetEffect(nsString& aEffect, ErrorResult& aRv)
-{
-  THROW_IF_NO_CAMERACONTROL();
-  aRv = mCameraControl->Get(CAMERA_PARAM_EFFECT, aEffect);
-}
-void
-nsDOMCameraControl::SetEffect(const nsAString& aEffect, ErrorResult& aRv)
-{
-  THROW_IF_NO_CAMERACONTROL();
-  aRv = mCameraControl->Set(CAMERA_PARAM_EFFECT, aEffect);
-}
-
-void
-nsDOMCameraControl::GetWhiteBalanceMode(nsString& aWhiteBalanceMode, ErrorResult& aRv)
-{
-  THROW_IF_NO_CAMERACONTROL();
-  aRv = mCameraControl->Get(CAMERA_PARAM_WHITEBALANCE, aWhiteBalanceMode);
-}
-void
-nsDOMCameraControl::SetWhiteBalanceMode(const nsAString& aWhiteBalanceMode, ErrorResult& aRv)
-{
-  THROW_IF_NO_CAMERACONTROL();
-  aRv = mCameraControl->Set(CAMERA_PARAM_WHITEBALANCE, aWhiteBalanceMode);
-}
-
-void
-nsDOMCameraControl::GetSceneMode(nsString& aSceneMode, ErrorResult& aRv)
-{
-  THROW_IF_NO_CAMERACONTROL();
-  aRv = mCameraControl->Get(CAMERA_PARAM_SCENEMODE, aSceneMode);
-}
-void
-nsDOMCameraControl::SetSceneMode(const nsAString& aSceneMode, ErrorResult& aRv)
-{
-  THROW_IF_NO_CAMERACONTROL();
-  aRv = mCameraControl->Set(CAMERA_PARAM_SCENEMODE, aSceneMode);
-}
-
-void
-nsDOMCameraControl::GetFlashMode(nsString& aFlashMode, ErrorResult& aRv)
-{
-  THROW_IF_NO_CAMERACONTROL();
-  aRv = mCameraControl->Get(CAMERA_PARAM_FLASHMODE, aFlashMode);
-}
-void
-nsDOMCameraControl::SetFlashMode(const nsAString& aFlashMode, ErrorResult& aRv)
-{
-  THROW_IF_NO_CAMERACONTROL();
-  aRv = mCameraControl->Set(CAMERA_PARAM_FLASHMODE, aFlashMode);
-}
-
-void
-nsDOMCameraControl::GetFocusMode(nsString& aFocusMode, ErrorResult& aRv)
-{
-  THROW_IF_NO_CAMERACONTROL();
-  aRv = mCameraControl->Get(CAMERA_PARAM_FOCUSMODE, aFocusMode);
-}
-void
-nsDOMCameraControl::SetFocusMode(const nsAString& aFocusMode, ErrorResult& aRv)
-{
-  THROW_IF_NO_CAMERACONTROL();
-  aRv = mCameraControl->Set(CAMERA_PARAM_FOCUSMODE, aFocusMode);
-}
-
-void
-nsDOMCameraControl::GetIsoMode(nsString& aIsoMode, ErrorResult& aRv)
-{
-  THROW_IF_NO_CAMERACONTROL();
-  aRv = mCameraControl->Get(CAMERA_PARAM_ISOMODE, aIsoMode);
-}
-void
-nsDOMCameraControl::SetIsoMode(const nsAString& aIsoMode, ErrorResult& aRv)
-{
-  THROW_IF_NO_CAMERACONTROL();
-  aRv = mCameraControl->Set(CAMERA_PARAM_ISOMODE, aIsoMode);
-}
-
-double
-nsDOMCameraControl::GetPictureQuality(ErrorResult& aRv)
-{
-  THROW_IF_NO_CAMERACONTROL(1.0);
-
-  double quality;
-  aRv = mCameraControl->Get(CAMERA_PARAM_PICTURE_QUALITY, quality);
-  return quality;
-}
-void
-nsDOMCameraControl::SetPictureQuality(double aQuality, ErrorResult& aRv)
-{
-  THROW_IF_NO_CAMERACONTROL();
-  aRv = mCameraControl->Set(CAMERA_PARAM_PICTURE_QUALITY, aQuality);
-}
-
-void
-nsDOMCameraControl::GetMeteringMode(nsString& aMode, ErrorResult& aRv)
-{
-  THROW_IF_NO_CAMERACONTROL();
-  aRv = mCameraControl->Get(CAMERA_PARAM_METERINGMODE, aMode);
-}
-void
-nsDOMCameraControl::SetMeteringMode(const nsAString& aMode, ErrorResult& aRv)
-{
-  THROW_IF_NO_CAMERACONTROL();
-  aRv = mCameraControl->Set(CAMERA_PARAM_METERINGMODE, aMode);
-}
-
-double
-nsDOMCameraControl::GetZoom(ErrorResult& aRv)
-{
-  THROW_IF_NO_CAMERACONTROL(1.0);
-
-  double zoom = 1.0;
-  aRv = mCameraControl->Get(CAMERA_PARAM_ZOOM, zoom);
-  return zoom;
-}
-
-void
-nsDOMCameraControl::SetZoom(double aZoom, ErrorResult& aRv)
-{
-  THROW_IF_NO_CAMERACONTROL();
-  aRv = mCameraControl->Set(CAMERA_PARAM_ZOOM, aZoom);
-}
-
-void
-nsDOMCameraControl::GetMeteringAreas(nsTArray<CameraRegion>& aAreas, ErrorResult& aRv)
-{
-  aRv = Get(CAMERA_PARAM_METERINGAREAS, aAreas);
-}
-void
-nsDOMCameraControl::SetMeteringAreas(const Optional<Sequence<CameraRegion> >& aMeteringAreas, ErrorResult& aRv)
-{
-  aRv = Set(CAMERA_PARAM_METERINGAREAS, aMeteringAreas,
-            mCurrentConfiguration->mMaxMeteringAreas);
-}
-
-void
-nsDOMCameraControl::GetFocusAreas(nsTArray<CameraRegion>& aAreas, ErrorResult& aRv)
-{
-  aRv = Get(CAMERA_PARAM_FOCUSAREAS, aAreas);
-}
-void
-nsDOMCameraControl::SetFocusAreas(const Optional<Sequence<CameraRegion> >& aFocusAreas, ErrorResult& aRv)
-{
-  aRv = Set(CAMERA_PARAM_FOCUSAREAS, aFocusAreas,
-            mCurrentConfiguration->mMaxFocusAreas);
-}
-
-void
-nsDOMCameraControl::GetPictureSize(CameraSize& aSize, ErrorResult& aRv)
-{
-  THROW_IF_NO_CAMERACONTROL();
-
-  ICameraControl::Size size;
-  aRv = mCameraControl->Get(CAMERA_PARAM_PICTURE_SIZE, size);
-  if (aRv.Failed()) {
-    return;
-  }
-
-  aSize.mWidth = size.width;
-  aSize.mHeight = size.height;
-}
-
-void
-nsDOMCameraControl::SetPictureSize(const CameraSize& aSize, ErrorResult& aRv)
-{
-  THROW_IF_NO_CAMERACONTROL();
-  ICameraControl::Size s = { aSize.mWidth, aSize.mHeight };
-  aRv = mCameraControl->Set(CAMERA_PARAM_PICTURE_SIZE, s);
-}
-
-void
-nsDOMCameraControl::GetThumbnailSize(CameraSize& aSize, ErrorResult& aRv)
-{
-  THROW_IF_NO_CAMERACONTROL();
-  ICameraControl::Size size;
-  aRv = mCameraControl->Get(CAMERA_PARAM_THUMBNAILSIZE, size);
-  if (aRv.Failed()) {
-    return;
-  }
-
-  aSize.mWidth = size.width;
-  aSize.mHeight = size.height;
-}
-
-void
-nsDOMCameraControl::SetThumbnailSize(const CameraSize& aSize, ErrorResult& aRv)
-{
-  THROW_IF_NO_CAMERACONTROL();
-  ICameraControl::Size s = { aSize.mWidth, aSize.mHeight };
-  aRv = mCameraControl->Set(CAMERA_PARAM_THUMBNAILSIZE, s);
-}
-
-double
-nsDOMCameraControl::GetFocalLength(ErrorResult& aRv)
-{
-  THROW_IF_NO_CAMERACONTROL(0.0);
-
-  double focalLength;
-  aRv = mCameraControl->Get(CAMERA_PARAM_FOCALLENGTH, focalLength);
-  return focalLength;
-}
-
-double
-nsDOMCameraControl::GetFocusDistanceNear(ErrorResult& aRv)
-{
-  THROW_IF_NO_CAMERACONTROL(0.0);
-
-  double distance;
-  aRv = mCameraControl->Get(CAMERA_PARAM_FOCUSDISTANCENEAR, distance);
-  return distance;
-}
-
-double
-nsDOMCameraControl::GetFocusDistanceOptimum(ErrorResult& aRv)
-{
-  THROW_IF_NO_CAMERACONTROL(0.0);
-
-  double distance;
-  aRv = mCameraControl->Get(CAMERA_PARAM_FOCUSDISTANCEOPTIMUM, distance);
-  return distance;
-}
-
-double
-nsDOMCameraControl::GetFocusDistanceFar(ErrorResult& aRv)
-{
-  THROW_IF_NO_CAMERACONTROL(0.0);
-
-  double distance;
-  aRv = mCameraControl->Get(CAMERA_PARAM_FOCUSDISTANCEFAR, distance);
-  return distance;
-}
-
-void
-nsDOMCameraControl::SetExposureCompensation(double aCompensation, ErrorResult& aRv)
-{
-  THROW_IF_NO_CAMERACONTROL();
-  aRv = mCameraControl->Set(CAMERA_PARAM_EXPOSURECOMPENSATION, aCompensation);
-}
-
-double
-nsDOMCameraControl::GetExposureCompensation(ErrorResult& aRv)
-{
-  THROW_IF_NO_CAMERACONTROL(0.0);
-
-  double compensation;
-  aRv = mCameraControl->Get(CAMERA_PARAM_EXPOSURECOMPENSATION, compensation);
-  return compensation;
-}
-
-int32_t
-nsDOMCameraControl::SensorAngle()
-{
-  int32_t angle = 0;
-  if (mCameraControl) {
-    mCameraControl->Get(CAMERA_PARAM_SENSORANGLE, angle);
-  }
-  return angle;
-}
-
-already_AddRefed<dom::CameraCapabilities>
-nsDOMCameraControl::Capabilities()
-{
-  if (!mCameraControl) {
-    DOM_CAMERA_LOGW("mCameraControl is null at %s:%d\n", __func__, __LINE__);
-    return nullptr;
-  }
-
-  RefPtr<CameraCapabilities> caps = mCapabilities;
-  if (!caps) {
-    caps = new CameraCapabilities(mWindow, mCameraControl);
-    mCapabilities = caps;
-  }
-
-  return caps.forget();
-}
-
-// Methods.
-already_AddRefed<Promise>
-nsDOMCameraControl::StartRecording(const CameraStartRecordingOptions& aOptions,
-                                   nsDOMDeviceStorage& aStorageArea,
-                                   const nsAString& aFilename,
-                                   ErrorResult& aRv)
-{
-  DOM_CAMERA_LOGT("%s:%d : this=%p\n", __func__, __LINE__, this);
-
-  RefPtr<Promise> promise = CreatePromise(aRv);
-  if (aRv.Failed()) {
-    return nullptr;
-  }
-
-  // If we are trying to start recording, already recording or are still
-  // waiting for a poster to be created/fail, we need to wait
-  if (mStartRecordingPromise || mRecording ||
-      mRecordingStoppedDeferred ||
-      mOptions.mCreatePoster) {
-    promise->MaybeReject(NS_ERROR_IN_PROGRESS);
-    return promise.forget();
-  }
-
-  aRv = NotifyRecordingStatusChange(NS_LITERAL_STRING("starting"));
-  if (aRv.Failed()) {
-    return nullptr;
-  }
-
-  mDSFileDescriptor = new DeviceStorageFileDescriptor();
-  RefPtr<DOMRequest> request = aStorageArea.CreateFileDescriptor(aFilename,
-                                                                   mDSFileDescriptor.get(),
-                                                                   aRv);
-  if (aRv.Failed()) {
-    NotifyRecordingStatusChange(NS_LITERAL_STRING("shutdown"));
-    return nullptr;
-  }
-
-  nsCOMPtr<nsIDOMEventListener> listener = new StartRecordingHelper(this);
-  aRv = RegisterStorageRequestEvents(request, listener);
-  if (aRv.Failed()) {
-    NotifyRecordingStatusChange(NS_LITERAL_STRING("shutdown"));
-    return nullptr;
-  }
-
-  mStartRecordingPromise = promise;
-  mOptions = aOptions;
-  mRecording = true;
-  return promise.forget();
-}
-
-void
-nsDOMCameraControl::OnCreatedFileDescriptor(bool aSucceeded)
-{
-  nsresult rv = NS_ERROR_FAILURE;
-
-  if (!mCameraControl) {
-    rv = NS_ERROR_NOT_AVAILABLE;
-  } else if (!mRecording) {
-    // Race condition where StopRecording comes in before we issue
-    // the start recording request to Gonk
-    rv = NS_ERROR_ABORT;
-    mOptions.mCreatePoster = false;
-  } else if (aSucceeded && mDSFileDescriptor->mFileDescriptor.IsValid()) {
-    ICameraControl::StartRecordingOptions o;
-
-    o.rotation = mOptions.mRotation;
-    o.maxFileSizeBytes = mOptions.mMaxFileSizeBytes;
-    o.maxVideoLengthMs = mOptions.mMaxVideoLengthMs;
-    o.autoEnableLowLightTorch = mOptions.mAutoEnableLowLightTorch;
-    o.createPoster = mOptions.mCreatePoster;
-    rv = mCameraControl->StartRecording(mDSFileDescriptor.get(), &o);
-    if (NS_SUCCEEDED(rv)) {
-      return;
-    }
-  }
-
-  OnUserError(CameraControlListener::kInStartRecording, rv);
-
-  if (mDSFileDescriptor->mFileDescriptor.IsValid()) {
-    // An error occured. We need to manually close the file associated with the
-    // FileDescriptor, and we shouldn't do this on the main thread, so we
-    // use a little helper.
-    RefPtr<CloseFileRunnable> closer =
-      new CloseFileRunnable(mDSFileDescriptor->mFileDescriptor);
-    closer->Dispatch();
-  }
-}
-
-void
-nsDOMCameraControl::StopRecording(ErrorResult& aRv)
-{
-  DOM_CAMERA_LOGT("%s:%d : this=%p\n", __func__, __LINE__, this);
-  THROW_IF_NO_CAMERACONTROL();
-
-  ReleaseAudioChannelAgent();
-  mRecording = false;
-  aRv = mCameraControl->StopRecording();
-}
-
-void
-nsDOMCameraControl::PauseRecording(ErrorResult& aRv)
-{
-  DOM_CAMERA_LOGT("%s:%d : this=%p\n", __func__, __LINE__, this);
-  THROW_IF_NO_CAMERACONTROL();
-
-  aRv = mCameraControl->PauseRecording();
-}
-
-void
-nsDOMCameraControl::ResumeRecording(ErrorResult& aRv)
-{
-  DOM_CAMERA_LOGT("%s:%d : this=%p\n", __func__, __LINE__, this);
-  THROW_IF_NO_CAMERACONTROL();
-
-  aRv = mCameraControl->ResumeRecording();
-}
-
-void
-nsDOMCameraControl::ResumePreview(ErrorResult& aRv)
-{
-  DOM_CAMERA_LOGT("%s:%d : this=%p\n", __func__, __LINE__, this);
-  THROW_IF_NO_CAMERACONTROL();
-  aRv = mCameraControl->StartPreview();
-}
-
-already_AddRefed<Promise>
-nsDOMCameraControl::SetConfiguration(const CameraConfiguration& aConfiguration,
-                                     ErrorResult& aRv)
-{
-  DOM_CAMERA_LOGT("%s:%d : this=%p\n", __func__, __LINE__, this);
-  THROW_IF_NO_CAMERACONTROL(nullptr);
-
-  RefPtr<Promise> promise = CreatePromise(aRv);
-  if (aRv.Failed()) {
-    return nullptr;
-  }
-
-  if (mTakePicturePromise) {
-    // We're busy taking a picture, can't change modes right now.
-    promise->MaybeReject(NS_ERROR_IN_PROGRESS);
-    return promise.forget();
-  }
-
-  ICameraControl::Configuration config;
-  aRv = SelectPreviewSize(aConfiguration.mPreviewSize, config.mPreviewSize);
-  if (aRv.Failed()) {
-    return nullptr;
-  }
-
-  config.mRecorderProfile = aConfiguration.mRecorderProfile;
-  config.mPictureSize.width = aConfiguration.mPictureSize.mWidth;
-  config.mPictureSize.height = aConfiguration.mPictureSize.mHeight;
-  config.mMode = ICameraControl::kPictureMode;
-  if (aConfiguration.mMode == CameraMode::Video) {
-    config.mMode = ICameraControl::kVideoMode;
-  }
-
-  aRv = mCameraControl->SetConfiguration(config);
-  if (aRv.Failed()) {
-    return nullptr;
-  }
-
-  mSetConfigurationPromise = promise;
-  return promise.forget();
-}
-
-already_AddRefed<Promise>
-nsDOMCameraControl::AutoFocus(ErrorResult& aRv)
-{
-  DOM_CAMERA_LOGT("%s:%d : this=%p\n", __func__, __LINE__, this);
-  THROW_IF_NO_CAMERACONTROL(nullptr);
-
-  RefPtr<Promise> promise = mAutoFocusPromise.forget();
-  if (promise) {
-    // There is already a call to AutoFocus() in progress, cancel it and
-    // invoke the error callback (if one was passed in).
-    promise->MaybeReject(NS_ERROR_IN_PROGRESS);
-  }
-
-  promise = CreatePromise(aRv);
-  if (aRv.Failed()) {
-    return nullptr;
-  }
-
-  aRv = mCameraControl->AutoFocus();
-  if (aRv.Failed()) {
-    return nullptr;
-  }
-
-  DispatchStateEvent(NS_LITERAL_STRING("focus"), NS_LITERAL_STRING("focusing"));
-
-  mAutoFocusPromise = promise;
-  return promise.forget();
-}
-
-void
-nsDOMCameraControl::StartFaceDetection(ErrorResult& aRv)
-{
-  DOM_CAMERA_LOGT("%s:%d : this=%p\n", __func__, __LINE__, this);
-  THROW_IF_NO_CAMERACONTROL();
-  aRv = mCameraControl->StartFaceDetection();
-}
-
-void
-nsDOMCameraControl::StopFaceDetection(ErrorResult& aRv)
-{
-  DOM_CAMERA_LOGT("%s:%d : this=%p\n", __func__, __LINE__, this);
-  THROW_IF_NO_CAMERACONTROL();
-  aRv = mCameraControl->StopFaceDetection();
-}
-
-already_AddRefed<Promise>
-nsDOMCameraControl::TakePicture(const CameraPictureOptions& aOptions,
-                                ErrorResult& aRv)
-{
-  DOM_CAMERA_LOGT("%s:%d : this=%p\n", __func__, __LINE__, this);
-  THROW_IF_NO_CAMERACONTROL(nullptr);
-
-  RefPtr<Promise> promise = CreatePromise(aRv);
-  if (aRv.Failed()) {
-    return nullptr;
-  }
-
-  if (mTakePicturePromise) {
-    // There is already a call to TakePicture() in progress, abort this new
-    // one and invoke the error callback (if one was passed in).
-    promise->MaybeReject(NS_ERROR_IN_PROGRESS);
-    return promise.forget();
-  }
-
-  {
-    ICameraControlParameterSetAutoEnter batch(mCameraControl);
-
-    // XXXmikeh - remove this: see bug 931155
-    ICameraControl::Size s;
-    s.width = aOptions.mPictureSize.mWidth;
-    s.height = aOptions.mPictureSize.mHeight;
-
-    ICameraControl::Position p;
-    p.latitude = aOptions.mPosition.mLatitude;
-    p.longitude = aOptions.mPosition.mLongitude;
-    p.altitude = aOptions.mPosition.mAltitude;
-    p.timestamp = aOptions.mPosition.mTimestamp;
-
-    if (s.width && s.height) {
-      mCameraControl->Set(CAMERA_PARAM_PICTURE_SIZE, s);
-    }
-    if (!aOptions.mFileFormat.IsEmpty()) {
-      mCameraControl->Set(CAMERA_PARAM_PICTURE_FILEFORMAT, aOptions.mFileFormat);
-    }
-    mCameraControl->Set(CAMERA_PARAM_PICTURE_ROTATION, aOptions.mRotation);
-    mCameraControl->Set(CAMERA_PARAM_PICTURE_DATETIME, aOptions.mDateTime);
-    mCameraControl->SetLocation(p);
-  }
-
-  aRv = mCameraControl->TakePicture();
-  if (aRv.Failed()) {
-    return nullptr;
-  }
-
-  mTakePicturePromise = promise;
-  return promise.forget();
-}
-
-already_AddRefed<Promise>
-nsDOMCameraControl::ReleaseHardware(ErrorResult& aRv)
-{
-  DOM_CAMERA_LOGI("%s:%d : this=%p\n", __func__, __LINE__, this);
-
-  RefPtr<Promise> promise = CreatePromise(aRv);
-  if (aRv.Failed()) {
-    return nullptr;
-  }
-
-  if (!mCameraControl) {
-    // Always succeed if the camera instance is already closed.
-    promise->MaybeResolveWithUndefined();
-    return promise.forget();
-  }
-
-  aRv = mCameraControl->Stop();
-  if (aRv.Failed()) {
-    return nullptr;
-  }
-
-  // Once we stop the camera, there's nothing we can do with it,
-  // so we can throw away this reference. (This won't prevent us
-  // from receiving the last underlying events.)
-  mCameraControl = nullptr;
-  mReleasePromise = promise;
-
-  return promise.forget();
-}
-
-void
-nsDOMCameraControl::ResumeContinuousFocus(ErrorResult& aRv)
-{
-  DOM_CAMERA_LOGT("%s:%d : this=%p\n", __func__, __LINE__, this);
-  THROW_IF_NO_CAMERACONTROL();
-  aRv = mCameraControl->ResumeContinuousFocus();
-}
-
-void
-nsDOMCameraControl::Shutdown()
-{
-  DOM_CAMERA_LOGT("%s:%d : this=%p\n", __func__, __LINE__, this);
-
-  // Remove any pending solicited event handlers; these
-  // reference our window object, which in turn references
-  // us. If we don't remove them, we can leak DOM objects.
-  AbortPromise(mGetCameraPromise);
-  AbortPromise(mAutoFocusPromise);
-  AbortPromise(mTakePicturePromise);
-  AbortPromise(mStartRecordingPromise);
-  AbortPromise(mReleasePromise);
-  AbortPromise(mSetConfigurationPromise);
-
-  if (mCameraControl) {
-    mCameraControl->Stop();
-    mCameraControl = nullptr;
-  }
-}
-
-void
-nsDOMCameraControl::ReleaseAudioChannelAgent()
-{
-#ifdef MOZ_B2G
-  if (mAudioChannelAgent) {
-    mAudioChannelAgent->NotifyStoppedPlaying();
-    mAudioChannelAgent = nullptr;
-  }
-#endif
-}
-
-nsresult
-nsDOMCameraControl::NotifyRecordingStatusChange(const nsString& aMsg)
-{
-  NS_ENSURE_TRUE(mWindow, NS_ERROR_FAILURE);
-
-  if (aMsg.EqualsLiteral("shutdown")) {
-    ReleaseAudioChannelAgent();
-  }
-
-  nsresult rv = MediaManager::NotifyRecordingStatusChange(mWindow,
-                                                          aMsg,
-                                                          true /* aIsAudio */,
-                                                          true /* aIsVideo */);
-
-  if (NS_FAILED(rv)) {
-    return rv;
-  }
-
-#ifdef MOZ_B2G
-  if (aMsg.EqualsLiteral("starting") && !mAudioChannelAgent) {
-    mAudioChannelAgent = do_CreateInstance("@mozilla.org/audiochannelagent;1");
-    if (!mAudioChannelAgent) {
-      return NS_ERROR_UNEXPECTED;
-    }
-
-    // Camera app will stop recording when it falls to the background, so no callback is necessary.
-    mAudioChannelAgent->Init(mWindow, (int32_t)AudioChannel::Content, nullptr);
-    // Video recording doesn't output any sound, so it's not necessary to check canPlay.
-    AudioPlaybackConfig config;
-    rv = mAudioChannelAgent->NotifyStartedPlaying(&config, AudioChannelService::AudibleState::eAudible);
-    if (NS_WARN_IF(NS_FAILED(rv))) {
-      return rv;
-    }
-  }
-#endif
-  return rv;
-}
-
-already_AddRefed<Promise>
-nsDOMCameraControl::CreatePromise(ErrorResult& aRv)
-{
-  nsCOMPtr<nsIGlobalObject> global = do_QueryInterface(mWindow);
-  if (!global) {
-    aRv.Throw(NS_ERROR_FAILURE);
-    return nullptr;
-  }
-  return Promise::Create(global, aRv);
-}
-
-void
-nsDOMCameraControl::AbortPromise(RefPtr<Promise>& aPromise)
-{
-  RefPtr<Promise> promise = aPromise.forget();
-  if (promise) {
-    promise->MaybeReject(NS_ERROR_NOT_AVAILABLE);
-  }
-}
-
-void
-nsDOMCameraControl::EventListenerAdded(nsIAtom* aType)
-{
-  if (aType == nsGkAtoms::onpreviewstatechange) {
-    DispatchPreviewStateEvent(mPreviewState);
-  }
-}
-
-void
-nsDOMCameraControl::DispatchPreviewStateEvent(CameraControlListener::PreviewState aState)
-{
-  nsString state;
-  switch (aState) {
-    case CameraControlListener::kPreviewStarted:
-      state = NS_LITERAL_STRING("started");
-      break;
-
-    default:
-      state = NS_LITERAL_STRING("stopped");
-      break;
-  }
-
-  DispatchStateEvent(NS_LITERAL_STRING("previewstatechange"), state);
-}
-
-void
-nsDOMCameraControl::DispatchStateEvent(const nsString& aType, const nsString& aState)
-{
-  CameraStateChangeEventInit eventInit;
-  eventInit.mNewState = aState;
-
-  RefPtr<CameraStateChangeEvent> event =
-    CameraStateChangeEvent::Constructor(this, aType, eventInit);
-
-  DispatchTrustedEvent(event);
-}
-
-void
-nsDOMCameraControl::OnGetCameraComplete()
-{
-  // The hardware is open, so we can return a camera to JS, even if
-  // the preview hasn't started yet.
-  RefPtr<Promise> promise = mGetCameraPromise.forget();
-  if (promise) {
-    CameraGetPromiseData data;
-    data.mCamera = this;
-    data.mConfiguration = *mCurrentConfiguration;
-    promise->MaybeResolve(data);
-  }
-}
-
-// Camera Control event handlers--must only be called from the Main Thread!
-void
-nsDOMCameraControl::OnHardwareStateChange(CameraControlListener::HardwareState aState,
-                                          nsresult aReason)
-{
-  DOM_CAMERA_LOGT("%s:%d : this=%p\n", __func__, __LINE__, this);
-  MOZ_ASSERT(NS_IsMainThread());
-
-  switch (aState) {
-    case CameraControlListener::kHardwareOpen:
-      DOM_CAMERA_LOGI("DOM OnHardwareStateChange: open\n");
-      MOZ_ASSERT(aReason == NS_OK);
-      if (!mSetInitialConfig) {
-        // The hardware is open, so we can return a camera to JS, even if
-        // the preview hasn't started yet.
-        OnGetCameraComplete();
-      }
-      break;
-
-    case CameraControlListener::kHardwareClosed:
-      DOM_CAMERA_LOGI("DOM OnHardwareStateChange: closed\n");
-      if (!mSetInitialConfig) {
-        RefPtr<Promise> promise = mReleasePromise.forget();
-        if (promise) {
-          promise->MaybeResolveWithUndefined();
-        }
-
-        CameraClosedEventInit eventInit;
-        switch (aReason) {
-          case NS_OK:
-            eventInit.mReason = NS_LITERAL_STRING("HardwareReleased");
-            break;
-
-          case NS_ERROR_FAILURE:
-            eventInit.mReason = NS_LITERAL_STRING("SystemFailure");
-            break;
-
-          case NS_ERROR_NOT_AVAILABLE:
-            eventInit.mReason = NS_LITERAL_STRING("NotAvailable");
-            break;
-
-          default:
-            DOM_CAMERA_LOGE("Unhandled hardware close reason, 0x%x\n", aReason);
-            MOZ_ASSERT_UNREACHABLE("Unanticipated reason for hardware close");
-            eventInit.mReason = NS_LITERAL_STRING("SystemFailure");
-            break;
-        }
-
-        RefPtr<CameraClosedEvent> event =
-          CameraClosedEvent::Constructor(this,
-                                         NS_LITERAL_STRING("close"),
-                                         eventInit);
-        DispatchTrustedEvent(event);
-      } else {
-        // The configuration failed and we forced the camera to shutdown.
-        OnUserError(DOMCameraControlListener::kInStartCamera, NS_ERROR_NOT_AVAILABLE);
-      }
-      break;
-
-    case CameraControlListener::kHardwareOpenFailed:
-      DOM_CAMERA_LOGI("DOM OnHardwareStateChange: open failed\n");
-      MOZ_ASSERT(aReason == NS_ERROR_NOT_AVAILABLE);
-      OnUserError(DOMCameraControlListener::kInStartCamera, NS_ERROR_NOT_AVAILABLE);
-      break;
-
-    case CameraControlListener::kHardwareUninitialized:
-      break;
-
-    default:
-      DOM_CAMERA_LOGE("DOM OnHardwareStateChange: UNKNOWN=%d\n", aState);
-      MOZ_ASSERT_UNREACHABLE("Unanticipated camera hardware state");
-  }
-}
-
-void
-nsDOMCameraControl::OnShutter()
-{
-  DOM_CAMERA_LOGI("DOM ** SNAP **\n");
-  MOZ_ASSERT(NS_IsMainThread());
-  DispatchTrustedEvent(NS_LITERAL_STRING("shutter"));
-}
-
-void
-nsDOMCameraControl::OnPreviewStateChange(CameraControlListener::PreviewState aState)
-{
-  DOM_CAMERA_LOGT("%s:%d : this=%p\n", __func__, __LINE__, this);
-  MOZ_ASSERT(NS_IsMainThread());
-
-  mPreviewState = aState;
-  nsString state;
-  switch (aState) {
-    case CameraControlListener::kPreviewStarted:
-      state = NS_LITERAL_STRING("started");
-      break;
-
-    default:
-      state = NS_LITERAL_STRING("stopped");
-      break;
-  }
-
-  DispatchPreviewStateEvent(aState);
-}
-
-void
-nsDOMCameraControl::OnPoster(BlobImpl* aPoster)
-{
-  DOM_CAMERA_LOGT("%s:%d : this=%p\n", __func__, __LINE__, this);
-  MOZ_ASSERT(NS_IsMainThread());
-  MOZ_ASSERT(mOptions.mCreatePoster);
-
-  RefPtr<Blob> blob = Blob::Create(GetParentObject(), aPoster);
-  if (NS_WARN_IF(!blob)) {
-    OnRecorderStateChange(CameraControlListener::kPosterFailed, 0, 0);
-    return;
-  }
-
-  BlobEventInit eventInit;
-  eventInit.mData = blob;
-
-  RefPtr<BlobEvent> event = BlobEvent::Constructor(this,
-                                                     NS_LITERAL_STRING("poster"),
-                                                     eventInit);
-
-  DispatchTrustedEvent(event);
-  OnRecorderStateChange(CameraControlListener::kPosterCreated, 0, 0);
-}
-
-void
-nsDOMCameraControl::OnRecorderStateChange(CameraControlListener::RecorderState aState,
-                                          int32_t aArg, int32_t aTrackNum)
-{
-  // For now, we do nothing with 'aStatus' and 'aTrackNum'.
-  DOM_CAMERA_LOGT("%s:%d : this=%p, state=%u\n", __func__, __LINE__, this, aState);
-  MOZ_ASSERT(NS_IsMainThread());
-
-  nsString state;
-
-  switch (aState) {
-    case CameraControlListener::kRecorderStarted:
-      {
-        RefPtr<Promise> promise = mStartRecordingPromise.forget();
-        if (promise) {
-          promise->MaybeResolveWithUndefined();
-        }
-
-        state = NS_LITERAL_STRING("Started");
-      }
-      break;
-
-    case CameraControlListener::kRecorderStopped:
-      if (mOptions.mCreatePoster) {
-        mRecordingStoppedDeferred = true;
-        return;
-      }
-
-      NotifyRecordingStatusChange(NS_LITERAL_STRING("shutdown"));
-      state = NS_LITERAL_STRING("Stopped");
-      break;
-
-    case CameraControlListener::kPosterCreated:
-      state = NS_LITERAL_STRING("PosterCreated");
-      mOptions.mCreatePoster = false;
-      break;
-
-    case CameraControlListener::kPosterFailed:
-      state = NS_LITERAL_STRING("PosterFailed");
-      mOptions.mCreatePoster = false;
-      break;
-
-    case CameraControlListener::kRecorderPaused:
-      state = NS_LITERAL_STRING("Paused");
-      break;
-
-    case CameraControlListener::kRecorderResumed:
-      state = NS_LITERAL_STRING("Resumed");
-      break;
-
-    default:
-      MOZ_ASSERT_UNREACHABLE("Unanticipated video recorder error");
-      return;
-  }
-
-  DispatchStateEvent(NS_LITERAL_STRING("recorderstatechange"), state);
-
-  if (mRecordingStoppedDeferred && !mOptions.mCreatePoster) {
-    mRecordingStoppedDeferred = false;
-    OnRecorderStateChange(CameraControlListener::kRecorderStopped, 0, 0);
-  }
-}
-
-void
-nsDOMCameraControl::OnConfigurationChange(DOMCameraConfiguration* aConfiguration)
-{
-  DOM_CAMERA_LOGT("%s:%d : this=%p\n", __func__, __LINE__, this);
-  MOZ_ASSERT(NS_IsMainThread());
-  MOZ_ASSERT(aConfiguration != nullptr);
-
-  // Update our record of the current camera configuration
-  mCurrentConfiguration = aConfiguration;
-
-  DOM_CAMERA_LOGI("DOM OnConfigurationChange: this=%p\n", this);
-  DOM_CAMERA_LOGI("    mode                   : %s\n",
-    mCurrentConfiguration->mMode == CameraMode::Video ? "video" : "picture");
-  DOM_CAMERA_LOGI("    maximum focus areas    : %d\n",
-    mCurrentConfiguration->mMaxFocusAreas);
-  DOM_CAMERA_LOGI("    maximum metering areas : %d\n",
-    mCurrentConfiguration->mMaxMeteringAreas);
-  DOM_CAMERA_LOGI("    preview size (w x h)   : %d x %d\n",
-    mCurrentConfiguration->mPreviewSize.mWidth, mCurrentConfiguration->mPreviewSize.mHeight);
-  DOM_CAMERA_LOGI("    picture size (w x h)   : %d x %d\n",
-    mCurrentConfiguration->mPictureSize.mWidth, mCurrentConfiguration->mPictureSize.mHeight);
-  DOM_CAMERA_LOGI("    recorder profile       : %s\n",
-    NS_ConvertUTF16toUTF8(mCurrentConfiguration->mRecorderProfile).get());
-
-  if (mSetInitialConfig) {
-    OnGetCameraComplete();
-    mSetInitialConfig = false;
-    return;
-  }
-
-  RefPtr<Promise> promise = mSetConfigurationPromise.forget();
-  if (promise) {
-    promise->MaybeResolve(*aConfiguration);
-  }
-
-  CameraConfigurationEventInit eventInit;
-  eventInit.mMode = mCurrentConfiguration->mMode;
-  eventInit.mRecorderProfile = mCurrentConfiguration->mRecorderProfile;
-  eventInit.mPreviewSize = new DOMRect(static_cast<DOMMediaStream*>(this), 0, 0,
-                                       mCurrentConfiguration->mPreviewSize.mWidth,
-                                       mCurrentConfiguration->mPreviewSize.mHeight);
-  eventInit.mPictureSize = new DOMRect(static_cast<DOMMediaStream*>(this), 0, 0,
-                                       mCurrentConfiguration->mPictureSize.mWidth,
-                                       mCurrentConfiguration->mPictureSize.mHeight);
-
-  RefPtr<CameraConfigurationEvent> event =
-    CameraConfigurationEvent::Constructor(this,
-                                          NS_LITERAL_STRING("configurationchanged"),
-                                          eventInit);
-
-  DispatchTrustedEvent(event);
-}
-
-void
-nsDOMCameraControl::OnAutoFocusComplete(bool aAutoFocusSucceeded)
-{
-  DOM_CAMERA_LOGT("%s:%d : this=%p\n", __func__, __LINE__, this);
-  MOZ_ASSERT(NS_IsMainThread());
-
-  RefPtr<Promise> promise = mAutoFocusPromise.forget();
-  if (promise) {
-    promise->MaybeResolve(aAutoFocusSucceeded);
-  }
-
-  if (aAutoFocusSucceeded) {
-    DispatchStateEvent(NS_LITERAL_STRING("focus"), NS_LITERAL_STRING("focused"));
-  } else {
-    DispatchStateEvent(NS_LITERAL_STRING("focus"), NS_LITERAL_STRING("unfocused"));
-  }
-}
-
-void
-nsDOMCameraControl::OnAutoFocusMoving(bool aIsMoving)
-{
-  DOM_CAMERA_LOGT("%s:%d : this=%p\n", __func__, __LINE__, this);
-  MOZ_ASSERT(NS_IsMainThread());
-
-  if (aIsMoving) {
-    DispatchStateEvent(NS_LITERAL_STRING("focus"), NS_LITERAL_STRING("focusing"));
-  }
-}
-
-void
-nsDOMCameraControl::OnFacesDetected(const nsTArray<ICameraControl::Face>& aFaces)
-{
-  DOM_CAMERA_LOGI("DOM OnFacesDetected %zu face(s)\n", aFaces.Length());
-  MOZ_ASSERT(NS_IsMainThread());
-
-  Sequence<OwningNonNull<DOMCameraDetectedFace> > faces;
-  uint32_t len = aFaces.Length();
-
-  if (faces.SetCapacity(len, fallible)) {
-    for (uint32_t i = 0; i < len; ++i) {
-      *faces.AppendElement(fallible) =
-        new DOMCameraDetectedFace(static_cast<DOMMediaStream*>(this), aFaces[i]);
-    }
-  }
-
-  CameraFacesDetectedEventInit eventInit;
-  eventInit.mFaces.SetValue(faces);
-
-  RefPtr<CameraFacesDetectedEvent> event =
-    CameraFacesDetectedEvent::Constructor(this,
-                                          NS_LITERAL_STRING("facesdetected"),
-                                          eventInit);
-
-  DispatchTrustedEvent(event);
-}
-
-void
-nsDOMCameraControl::OnTakePictureComplete(nsIDOMBlob* aPicture)
-{
-  DOM_CAMERA_LOGT("%s:%d : this=%p\n", __func__, __LINE__, this);
-  MOZ_ASSERT(NS_IsMainThread());
-  MOZ_ASSERT(aPicture);
-
-  RefPtr<Promise> promise = mTakePicturePromise.forget();
-  if (promise) {
-    nsCOMPtr<nsIDOMBlob> picture = aPicture;
-    promise->MaybeResolve(picture);
-  }
-
-  RefPtr<Blob> blob = static_cast<Blob*>(aPicture);
-  BlobEventInit eventInit;
-  eventInit.mData = blob;
-
-  RefPtr<BlobEvent> event = BlobEvent::Constructor(this,
-                                                     NS_LITERAL_STRING("picture"),
-                                                     eventInit);
-
-  DispatchTrustedEvent(event);
-}
-
-void
-nsDOMCameraControl::OnUserError(CameraControlListener::UserContext aContext, nsresult aError)
-{
-  DOM_CAMERA_LOGI("DOM OnUserError : this=%p, aContext=%u, aError=0x%x\n",
-    this, aContext, aError);
-  MOZ_ASSERT(NS_IsMainThread());
-
-  RefPtr<Promise> promise;
-
-  switch (aContext) {
-    case CameraControlListener::kInStartCamera:
-      promise = mGetCameraPromise.forget();
-      // If we failed to open the camera, we never actually provided a reference
-      // for the application to release explicitly. Thus we must clear our handle
-      // here to ensure everything is freed.
-      mCameraControl = nullptr;
-      break;
-
-    case CameraControlListener::kInStopCamera:
-      promise = mReleasePromise.forget();
-      if (aError == NS_ERROR_NOT_INITIALIZED) {
-        // This value indicates that the hardware is already closed; which for
-        // kInStopCamera, is not actually an error.
-        if (promise) {
-          promise->MaybeResolveWithUndefined();
-        }
-
-        return;
-      }
-      break;
-
-    case CameraControlListener::kInSetConfiguration:
-      if (mSetInitialConfig && mCameraControl) {
-        // If the SetConfiguration() call in the constructor fails, there
-        // is nothing we can do except release the camera hardware. This
-        // will trigger a hardware state change, and when the flag that
-        // got us here is set in that handler, we replace the normal reason
-        // code with one that indicates the hardware isn't available.
-        DOM_CAMERA_LOGI("Failed to configure cached camera, stopping\n");
-        mCameraControl->Stop();
-        return;
-      }
-      promise = mSetConfigurationPromise.forget();
-      break;
-
-    case CameraControlListener::kInAutoFocus:
-      promise = mAutoFocusPromise.forget();
-      DispatchStateEvent(NS_LITERAL_STRING("focus"), NS_LITERAL_STRING("unfocused"));
-      break;
-
-    case CameraControlListener::kInTakePicture:
-      promise = mTakePicturePromise.forget();
-      break;
-
-    case CameraControlListener::kInStartRecording:
-      promise = mStartRecordingPromise.forget();
-      mRecording = false;
-      NotifyRecordingStatusChange(NS_LITERAL_STRING("shutdown"));
-      break;
-
-    case CameraControlListener::kInStartFaceDetection:
-      // This method doesn't have any callbacks, so all we can do is log the
-      // failure. This only happens after the hardware has been released.
-      NS_WARNING("Failed to start face detection");
-      return;
-
-    case CameraControlListener::kInStopFaceDetection:
-      // This method doesn't have any callbacks, so all we can do is log the
-      // failure. This only happens after the hardware has been released.
-      NS_WARNING("Failed to stop face detection");
-      return;
-
-    case CameraControlListener::kInResumeContinuousFocus:
-      // This method doesn't have any callbacks, so all we can do is log the
-      // failure. This only happens after the hardware has been released.
-      NS_WARNING("Failed to resume continuous focus");
-      return;
-
-    case CameraControlListener::kInStopRecording:
-      // This method doesn't have any callbacks, so all we can do is log the
-      // failure. This only happens after the hardware has been released.
-      NS_WARNING("Failed to stop recording");
-      return;
-
-    case CameraControlListener::kInPauseRecording:
-      // This method doesn't have any callbacks, so all we can do is log the
-      // failure. This only happens after the hardware has been released.
-      NS_WARNING("Failed to pause recording");
-      return;
-
-    case CameraControlListener::kInResumeRecording:
-      // This method doesn't have any callbacks, so all we can do is log the
-      // failure. This only happens after the hardware has been released.
-      NS_WARNING("Failed to resume recording");
-      return;
-
-    case CameraControlListener::kInStartPreview:
-      // This method doesn't have any callbacks, so all we can do is log the
-      // failure. This only happens after the hardware has been released.
-      NS_WARNING("Failed to (re)start preview");
-      return;
-
-    case CameraControlListener::kInStopPreview:
-      // This method doesn't have any callbacks, so all we can do is log the
-      // failure. This only happens after the hardware has been released.
-      NS_WARNING("Failed to stop preview");
-      return;
-
-    case CameraControlListener::kInSetPictureSize:
-      // This method doesn't have any callbacks, so all we can do is log the
-      // failure. This only happens after the hardware has been released.
-      NS_WARNING("Failed to set picture size");
-      return;
-
-    case CameraControlListener::kInSetThumbnailSize:
-      // This method doesn't have any callbacks, so all we can do is log the
-      // failure. This only happens after the hardware has been released.
-      NS_WARNING("Failed to set thumbnail size");
-      return;
-
-    default:
-      {
-        nsPrintfCString msg("Unhandled aContext=%u, aError=0x%x\n", aContext, aError);
-        NS_WARNING(msg.get());
-      }
-      MOZ_ASSERT_UNREACHABLE("Unhandled user error");
-      return;
-  }
-
-  if (!promise) {
-    DOM_CAMERA_LOGW("DOM No error handler for aError=0x%x in aContext=%u\n",
-      aError, aContext);
-    return;
-  }
-
-  promise->MaybeReject(aError);
-}
deleted file mode 100644
--- a/dom/camera/DOMCameraControl.h
+++ /dev/null
@@ -1,262 +0,0 @@
-/* This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this file,
- * You can obtain one at http://mozilla.org/MPL/2.0/. */
-
-#ifndef DOM_CAMERA_DOMCAMERACONTROL_H
-#define DOM_CAMERA_DOMCAMERACONTROL_H
-
-#include "nsCOMPtr.h"
-#include "nsCycleCollectionParticipant.h"
-#include "mozilla/dom/CameraControlBinding.h"
-#include "mozilla/dom/Promise.h"
-#include "ICameraControl.h"
-#include "CameraCommon.h"
-#include "DOMMediaStream.h"
-#include "AudioChannelAgent.h"
-#include "nsProxyRelease.h"
-#include "nsHashPropertyBag.h"
-#include "DeviceStorage.h"
-#include "DOMCameraControlListener.h"
-#include "nsWeakReference.h"
-#ifdef MOZ_WIDGET_GONK
-#include "nsITimer.h"
-#endif
-
-class nsDOMDeviceStorage;
-class nsPIDOMWindowInner;
-class nsIDOMBlob;
-
-namespace mozilla {
-
-namespace dom {
-  class CameraCapabilities;
-  struct CameraPictureOptions;
-  struct CameraStartRecordingOptions;
-  struct CameraRegion;
-  struct CameraSize;
-  template<typename T> class Optional;
-} // namespace dom
-class ErrorResult;
-class StartRecordingHelper;
-class RecorderPosterHelper;
-class TrackCreatedListener;
-
-#define NS_DOM_CAMERA_CONTROL_CID \
-{ 0x3700c096, 0xf920, 0x438d, \
-  { 0x8b, 0x3f, 0x15, 0xb3, 0xc9, 0x96, 0x23, 0x62 } }
-
-// Main camera control.
-class nsDOMCameraControl final : public DOMMediaStream
-                               , public nsSupportsWeakReference
-{
-public:
-  NS_DECLARE_STATIC_IID_ACCESSOR(NS_DOM_CAMERA_CONTROL_CID)
-
-  NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(nsDOMCameraControl, DOMMediaStream)
-  NS_DECL_ISUPPORTS_INHERITED
-
-  // Because this header's filename doesn't match its C++ or DOM-facing
-  // classname, we can't rely on the [Func="..."] WebIDL tag to implicitly
-  // include the right header for us; instead we must explicitly include a
-  // HasSupport() method in each header. We can get rid of these with the
-  // Great Renaming proposed in bug 983177.
-  static bool HasSupport(JSContext* aCx, JSObject* aGlobal);
-
-  nsDOMCameraControl(uint32_t aCameraId,
-                     const dom::CameraConfiguration& aInitialConfig,
-                     dom::Promise* aPromise,
-                     nsPIDOMWindowInner* aWindow);
-
-  void Shutdown();
-
-  nsPIDOMWindowInner* GetParentObject() const { return mWindow; }
-
-  MediaStream* GetCameraStream() const override;
-
-  // Called by TrackCreatedListener when the underlying track has been created.
-  // XXX Bug 1124630. This can be removed with CameraPreviewMediaStream.
-  void TrackCreated(TrackID aTrackID);
-
-  // Attributes.
-  void GetEffect(nsString& aEffect, ErrorResult& aRv);
-  void SetEffect(const nsAString& aEffect, ErrorResult& aRv);
-  void GetWhiteBalanceMode(nsString& aMode, ErrorResult& aRv);
-  void SetWhiteBalanceMode(const nsAString& aMode, ErrorResult& aRv);
-  void GetSceneMode(nsString& aMode, ErrorResult& aRv);
-  void SetSceneMode(const nsAString& aMode, ErrorResult& aRv);
-  void GetFlashMode(nsString& aMode, ErrorResult& aRv);
-  void SetFlashMode(const nsAString& aMode, ErrorResult& aRv);
-  void GetFocusMode(nsString& aMode, ErrorResult& aRv);
-  void SetFocusMode(const nsAString& aMode, ErrorResult& aRv);
-  double GetZoom(ErrorResult& aRv);
-  void SetZoom(double aZoom, ErrorResult& aRv);
-  double GetFocalLength(ErrorResult& aRv);
-  double GetFocusDistanceNear(ErrorResult& aRv);
-  double GetFocusDistanceOptimum(ErrorResult& aRv);
-  double GetFocusDistanceFar(ErrorResult& aRv);
-  void SetExposureCompensation(double aCompensation, ErrorResult& aRv);
-  double GetExposureCompensation(ErrorResult& aRv);
-  int32_t SensorAngle();
-  already_AddRefed<dom::CameraCapabilities> Capabilities();
-  void GetIsoMode(nsString& aMode, ErrorResult& aRv);
-  void SetIsoMode(const nsAString& aMode, ErrorResult& aRv);
-  double GetPictureQuality(ErrorResult& aRv);
-  void SetPictureQuality(double aQuality, ErrorResult& aRv);
-  void GetMeteringMode(nsString& aMode, ErrorResult& aRv);
-  void SetMeteringMode(const nsAString& aMode, ErrorResult& aRv);
-
-  // Methods.
-  already_AddRefed<dom::Promise> SetConfiguration(const dom::CameraConfiguration& aConfiguration,
-                                                  ErrorResult& aRv);
-  void GetMeteringAreas(nsTArray<dom::CameraRegion>& aAreas, ErrorResult& aRv);
-  void SetMeteringAreas(const dom::Optional<dom::Sequence<dom::CameraRegion> >& aAreas, ErrorResult& aRv);
-  void GetFocusAreas(nsTArray<dom::CameraRegion>& aAreas, ErrorResult& aRv);
-  void SetFocusAreas(const dom::Optional<dom::Sequence<dom::CameraRegion> >& aAreas, ErrorResult& aRv);
-  void GetPictureSize(dom::CameraSize& aSize, ErrorResult& aRv);
-  void SetPictureSize(const dom::CameraSize& aSize, ErrorResult& aRv);
-  void GetThumbnailSize(dom::CameraSize& aSize, ErrorResult& aRv);
-  void SetThumbnailSize(const dom::CameraSize& aSize, ErrorResult& aRv);
-  already_AddRefed<dom::Promise> AutoFocus(ErrorResult& aRv);
-  void StartFaceDetection(ErrorResult& aRv);
-  void StopFaceDetection(ErrorResult& aRv);
-  already_AddRefed<dom::Promise> TakePicture(const dom::CameraPictureOptions& aOptions,
-                                             ErrorResult& aRv);
-  already_AddRefed<dom::Promise> StartRecording(const dom::CameraStartRecordingOptions& aOptions,
-                                                nsDOMDeviceStorage& storageArea,
-                                                const nsAString& filename,
-                                                ErrorResult& aRv);
-  void StopRecording(ErrorResult& aRv);
-  void PauseRecording(ErrorResult& aRv);
-  void ResumeRecording(ErrorResult& aRv);
-  void ResumePreview(ErrorResult& aRv);
-  already_AddRefed<dom::Promise> ReleaseHardware(ErrorResult& aRv);
-  void ResumeContinuousFocus(ErrorResult& aRv);
-
-  virtual JSObject* WrapObject(JSContext* aCx, JS::Handle<JSObject*> aGivenProto) override;
-
-  operator nsISupports*() { return static_cast<DOMMediaStream*>(this); }
-
-#ifdef MOZ_WIDGET_GONK
-  static void PreinitCameraHardware();
-  static void DiscardCachedCameraInstance(nsITimer* aTimer, void* aClosure);
-#endif
-
-  IMPL_EVENT_HANDLER(facesdetected)
-  IMPL_EVENT_HANDLER(shutter)
-  IMPL_EVENT_HANDLER(close)
-  IMPL_EVENT_HANDLER(recorderstatechange)
-  IMPL_EVENT_HANDLER(previewstatechange)
-  IMPL_EVENT_HANDLER(focus)
-  IMPL_EVENT_HANDLER(picture)
-  IMPL_EVENT_HANDLER(configurationchange)
-  IMPL_EVENT_HANDLER(poster)
-
-protected:
-  virtual ~nsDOMCameraControl();
-
-  class DOMCameraConfiguration final : public dom::CameraConfiguration
-  {
-  public:
-    NS_INLINE_DECL_REFCOUNTING(DOMCameraConfiguration)
-
-    DOMCameraConfiguration();
-    explicit DOMCameraConfiguration(const dom::CameraConfiguration& aConfiguration);
-
-    // Additional configuration options that aren't exposed to the DOM
-    uint32_t mMaxFocusAreas;
-    uint32_t mMaxMeteringAreas;
-
-  private:
-    // Private destructor, to discourage deletion outside of Release():
-    ~DOMCameraConfiguration();
-  };
-
-  friend class DOMCameraControlListener;
-  friend class mozilla::StartRecordingHelper;
-  friend class mozilla::RecorderPosterHelper;
-
-  void OnCreatedFileDescriptor(bool aSucceeded);
-
-  void OnAutoFocusComplete(bool aAutoFocusSucceeded);
-  void OnAutoFocusMoving(bool aIsMoving);
-  void OnTakePictureComplete(nsIDOMBlob* aPicture);
-  void OnFacesDetected(const nsTArray<ICameraControl::Face>& aFaces);
-  void OnPoster(dom::BlobImpl* aPoster);
-
-  void OnGetCameraComplete();
-  void OnHardwareStateChange(DOMCameraControlListener::HardwareState aState, nsresult aReason);
-  void OnPreviewStateChange(DOMCameraControlListener::PreviewState aState);
-  void OnRecorderStateChange(CameraControlListener::RecorderState aState, int32_t aStatus, int32_t aTrackNum);
-  void OnConfigurationChange(DOMCameraConfiguration* aConfiguration);
-  void OnShutter();
-  void OnUserError(CameraControlListener::UserContext aContext, nsresult aError);
-
-  bool IsWindowStillActive();
-  nsresult SelectPreviewSize(const dom::CameraSize& aRequestedPreviewSize, ICameraControl::Size& aSelectedPreviewSize);
-
-  void ReleaseAudioChannelAgent();
-  nsresult NotifyRecordingStatusChange(const nsString& aMsg);
-
-  already_AddRefed<dom::Promise> CreatePromise(ErrorResult& aRv);
-  void AbortPromise(RefPtr<dom::Promise>& aPromise);
-  virtual void EventListenerAdded(nsIAtom* aType) override;
-  void DispatchPreviewStateEvent(DOMCameraControlListener::PreviewState aState);
-  void DispatchStateEvent(const nsString& aType, const nsString& aState);
-
-  RefPtr<ICameraControl> mCameraControl; // non-DOM camera control
-
-  // An agent used to join audio channel service.
-  nsCOMPtr<nsIAudioChannelAgent> mAudioChannelAgent;
-
-  nsresult Set(uint32_t aKey, const dom::Optional<dom::Sequence<dom::CameraRegion> >& aValue, uint32_t aLimit);
-  nsresult Get(uint32_t aKey, nsTArray<dom::CameraRegion>& aValue);
-
-  RefPtr<DOMCameraConfiguration>              mCurrentConfiguration;
-  RefPtr<dom::CameraCapabilities>             mCapabilities;
-
-  // camera control pending promises
-  RefPtr<dom::Promise>                        mGetCameraPromise;
-  RefPtr<dom::Promise>                        mAutoFocusPromise;
-  RefPtr<dom::Promise>                        mTakePicturePromise;
-  RefPtr<dom::Promise>                        mStartRecordingPromise;
-  RefPtr<dom::Promise>                        mReleasePromise;
-  RefPtr<dom::Promise>                        mSetConfigurationPromise;
-
-  // Camera event listener; we only need this weak reference so that
-  //  we can remove the listener from the camera when we're done
-  //  with it.
-  DOMCameraControlListener* mListener;
-
-  // our viewfinder stream
-  RefPtr<CameraPreviewMediaStream> mInput;
-
-  // A listener on mInput for adding tracks to the DOM side.
-  RefPtr<TrackCreatedListener> mTrackCreatedListener;
-
-  // set once when this object is created
-  nsCOMPtr<nsPIDOMWindowInner>   mWindow;
-
-  dom::CameraStartRecordingOptions mOptions;
-  RefPtr<DeviceStorageFileDescriptor> mDSFileDescriptor;
-  DOMCameraControlListener::PreviewState mPreviewState;
-  bool mRecording;
-  bool mRecordingStoppedDeferred;
-  bool mSetInitialConfig;
-
-#ifdef MOZ_WIDGET_GONK
-  // cached camera control, to improve start-up time
-  static StaticRefPtr<ICameraControl> sCachedCameraControl;
-  static nsresult sCachedCameraControlStartResult;
-  static nsCOMPtr<nsITimer> sDiscardCachedCameraControlTimer;
-#endif
-
-private:
-  nsDOMCameraControl(const nsDOMCameraControl&) = delete;
-  nsDOMCameraControl& operator=(const nsDOMCameraControl&) = delete;
-};
-
-NS_DEFINE_STATIC_IID_ACCESSOR(nsDOMCameraControl, NS_DOM_CAMERA_CONTROL_CID)
-
-} // namespace mozilla
-
-#endif // DOM_CAMERA_DOMCAMERACONTROL_H
deleted file mode 100644
--- a/dom/camera/DOMCameraControlListener.cpp
+++ /dev/null
@@ -1,436 +0,0 @@
-/* This Source Code Form is subject to the terms of the Mozilla Public
-* License, v. 2.0. If a copy of the MPL was not distributed with this file,
-* You can obtain one at http://mozilla.org/MPL/2.0/. */
-
-#include "DOMCameraControlListener.h"
-#include "nsThreadUtils.h"
-#include "CameraCommon.h"
-#include "DOMCameraControl.h"
-#include "CameraPreviewMediaStream.h"
-#include "mozilla/dom/CameraManagerBinding.h"
-#include "mozilla/dom/File.h"
-#include "nsQueryObject.h"
-
-using namespace mozilla;
-using namespace mozilla::dom;
-
-DOMCameraControlListener::DOMCameraControlListener(nsDOMCameraControl* aDOMCameraControl,
-                                                   CameraPreviewMediaStream* aStream)
-  : mDOMCameraControl(
-      new nsMainThreadPtrHolder<nsISupports>(static_cast<DOMMediaStream*>(aDOMCameraControl)))
-  , mStream(aStream)
-{
-  DOM_CAMERA_LOGT("%s:%d : this=%p, camera=%p, stream=%p\n",
-    __func__, __LINE__, this, aDOMCameraControl, aStream);
-}
-
-DOMCameraControlListener::~DOMCameraControlListener()
-{
-  DOM_CAMERA_LOGT("%s:%d : this=%p\n", __func__, __LINE__, this);
-}
-
-// Boilerplate callback runnable
-class DOMCameraControlListener::DOMCallback : public Runnable
-{
-public:
-  explicit DOMCallback(nsMainThreadPtrHandle<nsISupports> aDOMCameraControl)
-    : mDOMCameraControl(aDOMCameraControl)
-  {
-    MOZ_COUNT_CTOR(DOMCameraControlListener::DOMCallback);
-  }
-
-protected:
-  virtual ~DOMCallback()
-  {
-    MOZ_COUNT_DTOR(DOMCameraControlListener::DOMCallback);
-  }
-
-public:
-  virtual void RunCallback(nsDOMCameraControl* aDOMCameraControl) = 0;
-
-  NS_IMETHOD
-  Run() override
-  {
-    MOZ_ASSERT(NS_IsMainThread());
-
-    RefPtr<nsDOMCameraControl> camera = do_QueryObject(mDOMCameraControl.get());
-    if (!camera) {
-      DOM_CAMERA_LOGE("do_QueryObject failed to get an nsDOMCameraControl\n");
-      return NS_ERROR_INVALID_ARG;
-    }
-    RunCallback(camera);
-    return NS_OK;
-  }
-
-protected:
-  nsMainThreadPtrHandle<nsISupports> mDOMCameraControl;
-};
-
-// Specific callback handlers
-void
-DOMCameraControlListener::OnHardwareStateChange(HardwareState aState,
-                                                nsresult aReason)
-{
-  class Callback : public DOMCallback
-  {
-  public:
-    Callback(nsMainThreadPtrHandle<nsISupports> aDOMCameraControl,
-             HardwareState aState, nsresult aReason)
-      : DOMCallback(aDOMCameraControl)
-      , mState(aState)
-      , mReason(aReason)
-    { }
-
-    void
-    RunCallback(nsDOMCameraControl* aDOMCameraControl) override
-    {
-      aDOMCameraControl->OnHardwareStateChange(mState, mReason);
-    }
-
-  protected:
-    HardwareState mState;
-    nsresult mReason;
-  };
-
-  NS_DispatchToMainThread(new Callback(mDOMCameraControl, aState, aReason));
-}
-
-void
-DOMCameraControlListener::OnPreviewStateChange(PreviewState aState)
-{
-  class Callback : public DOMCallback
-  {
-  public:
-    Callback(nsMainThreadPtrHandle<nsISupports> aDOMCameraControl,
-             PreviewState aState)
-      : DOMCallback(aDOMCameraControl)
-      , mState(aState)
-    { }
-
-    void
-    RunCallback(nsDOMCameraControl* aDOMCameraControl) override
-    {
-      aDOMCameraControl->OnPreviewStateChange(mState);
-    }
-
-  protected:
-    PreviewState mState;
-  };
-
-  switch (aState) {
-    case kPreviewStopped:
-      // Clear the current frame right away, without dispatching a
-      //  runnable. This is an ugly coupling between the camera's
-      //  SurfaceTextureClient and the MediaStream/ImageContainer,
-      //  but without it, the preview can fail to start.
-      DOM_CAMERA_LOGI("Preview stopped, clearing current frame\n");
-      mStream->ClearCurrentFrame();
-      break;
-
-    case kPreviewPaused:
-      // In the paused state, we still want to reflect the change
-      //  in preview state, but we don't want to clear the current
-      //  frame as above, since doing so seems to cause genlock
-      //  problems when we restart the preview. See bug 957749.
-      DOM_CAMERA_LOGI("Preview paused\n");
-      break;
-
-    case kPreviewStarted:
-      DOM_CAMERA_LOGI("Preview started\n");
-      break;
-
-    default:
-      DOM_CAMERA_LOGE("Unknown preview state %d\n", aState);
-      MOZ_ASSERT_UNREACHABLE("Invalid preview state");
-      return;
-  }
-  mStream->OnPreviewStateChange(aState == kPreviewStarted);
-  NS_DispatchToMainThread(new Callback(mDOMCameraControl, aState));
-}
-
-void
-DOMCameraControlListener::OnRecorderStateChange(RecorderState aState,
-                                                int32_t aStatus, int32_t aTrackNum)
-{
-  class Callback : public DOMCallback
-  {
-  public:
-    Callback(nsMainThreadPtrHandle<nsISupports> aDOMCameraControl,
-             RecorderState aState,
-             int32_t aStatus,
-             int32_t aTrackNum)
-      : DOMCallback(aDOMCameraControl)
-      , mState(aState)
-      , mStatus(aStatus)
-      , mTrackNum(aTrackNum)
-    { }
-
-    void
-    RunCallback(nsDOMCameraControl* aDOMCameraControl) override
-    {
-      aDOMCameraControl->OnRecorderStateChange(mState, mStatus, mTrackNum);
-    }
-
-  protected:
-    RecorderState mState;
-    int32_t mStatus;
-    int32_t mTrackNum;
-  };
-
-  NS_DispatchToMainThread(new Callback(mDOMCameraControl, aState, aStatus, aTrackNum));
-}
-
-void
-DOMCameraControlListener::OnConfigurationChange(const CameraListenerConfiguration& aConfiguration)
-{
-  class Callback : public DOMCallback
-  {
-  public:
-    Callback(nsMainThreadPtrHandle<nsISupports> aDOMCameraControl,
-             const CameraListenerConfiguration& aConfiguration)
-      : DOMCallback(aDOMCameraControl)
-      , mConfiguration(aConfiguration)
-    { }
-
-    void
-    RunCallback(nsDOMCameraControl* aDOMCameraControl) override
-    {
-      RefPtr<nsDOMCameraControl::DOMCameraConfiguration> config =
-        new nsDOMCameraControl::DOMCameraConfiguration();
-
-      switch (mConfiguration.mMode) {
-        case ICameraControl::kVideoMode:
-          config->mMode = CameraMode::Video;
-          break;
-
-        case ICameraControl::kPictureMode:
-          config->mMode = CameraMode::Picture;
-          break;
-
-        default:
-          DOM_CAMERA_LOGI("Camera mode still unspecified, nothing to do\n");
-          return;
-      }
-
-      // Map CameraControl parameters to their DOM-facing equivalents
-      config->mRecorderProfile = mConfiguration.mRecorderProfile;
-      config->mPreviewSize.mWidth = mConfiguration.mPreviewSize.width;
-      config->mPreviewSize.mHeight = mConfiguration.mPreviewSize.height;
-      config->mPictureSize.mWidth = mConfiguration.mPictureSize.width;
-      config->mPictureSize.mHeight = mConfiguration.mPictureSize.height;
-      config->mMaxMeteringAreas = mConfiguration.mMaxMeteringAreas;
-      config->mMaxFocusAreas = mConfiguration.mMaxFocusAreas;
-
-      aDOMCameraControl->OnConfigurationChange(config);
-    }
-
-  protected:
-    const CameraListenerConfiguration mConfiguration;
-  };
-
-  NS_DispatchToMainThread(new Callback(mDOMCameraControl, aConfiguration));
-}
-
-void
-DOMCameraControlListener::OnAutoFocusMoving(bool aIsMoving)
-{
-  class Callback : public DOMCallback
-  {
-  public:
-    Callback(nsMainThreadPtrHandle<nsISupports> aDOMCameraControl, bool aIsMoving)
-      : DOMCallback(aDOMCameraControl)
-      , mIsMoving(aIsMoving)
-    { }
-
-    void
-    RunCallback(nsDOMCameraControl* aDOMCameraControl) override
-    {
-      aDOMCameraControl->OnAutoFocusMoving(mIsMoving);
-    }
-
-  protected:
-    bool mIsMoving;
-  };
-
-  NS_DispatchToMainThread(new Callback(mDOMCameraControl, aIsMoving));
-}
-
-void
-DOMCameraControlListener::OnFacesDetected(const nsTArray<ICameraControl::Face>& aFaces)
-{
-  class Callback : public DOMCallback
-  {
-  public:
-    Callback(nsMainThreadPtrHandle<nsISupports> aDOMCameraControl,
-             const nsTArray<ICameraControl::Face>& aFaces)
-      : DOMCallback(aDOMCameraControl)
-      , mFaces(aFaces)
-    { }
-
-    void
-    RunCallback(nsDOMCameraControl* aDOMCameraControl) override
-    {
-      aDOMCameraControl->OnFacesDetected(mFaces);
-    }
-
-  protected:
-    const nsTArray<ICameraControl::Face> mFaces;
-  };
-
-  NS_DispatchToMainThread(new Callback(mDOMCameraControl, aFaces));
-}
-
-void
-DOMCameraControlListener::OnShutter()
-{
-  class Callback : public DOMCallback
-  {
-  public:
-    explicit Callback(nsMainThreadPtrHandle<nsISupports> aDOMCameraControl)
-      : DOMCallback(aDOMCameraControl)
-    { }
-
-    void
-    RunCallback(nsDOMCameraControl* aDOMCameraControl) override
-    {
-      aDOMCameraControl->OnShutter();
-    }
-  };
-
-  NS_DispatchToMainThread(new Callback(mDOMCameraControl));
-}
-
-void
-DOMCameraControlListener::OnRateLimitPreview(bool aLimit)
-{
-  mStream->RateLimit(aLimit);
-}
-
-bool
-DOMCameraControlListener::OnNewPreviewFrame(layers::Image* aImage, uint32_t aWidth, uint32_t aHeight)
-{
-  DOM_CAMERA_LOGI("OnNewPreviewFrame: got %d x %d frame\n", aWidth, aHeight);
-
-  mStream->SetCurrentFrame(gfx::IntSize(aWidth, aHeight), aImage);
-  return true;
-}
-
-void
-DOMCameraControlListener::OnAutoFocusComplete(bool aAutoFocusSucceeded)
-{
-  class Callback : public DOMCallback
-  {
-  public:
-    Callback(nsMainThreadPtrHandle<nsISupports> aDOMCameraControl,
-             bool aAutoFocusSucceeded)
-      : DOMCallback(aDOMCameraControl)
-      , mAutoFocusSucceeded(aAutoFocusSucceeded)
-    { }
-
-    void
-    RunCallback(nsDOMCameraControl* aDOMCameraControl) override
-    {
-      aDOMCameraControl->OnAutoFocusComplete(mAutoFocusSucceeded);
-    }
-
-  protected:
-    bool mAutoFocusSucceeded;
-  };
-
-  NS_DispatchToMainThread(new Callback(mDOMCameraControl, aAutoFocusSucceeded));
-}
-
-void
-DOMCameraControlListener::OnTakePictureComplete(const uint8_t* aData, uint32_t aLength, const nsAString& aMimeType)
-{
-  class Callback : public DOMCallback
-  {
-  public:
-    Callback(nsMainThreadPtrHandle<nsISupports> aDOMCameraControl,
-             const uint8_t* aData, uint32_t aLength, const nsAString& aMimeType)
-      : DOMCallback(aDOMCameraControl)
-      , mLength(aLength)
-      , mMimeType(aMimeType)
-    {
-        mData = (uint8_t*) malloc(aLength);
-        memcpy(mData, aData, aLength);
-    }
-
-    void
-    RunCallback(nsDOMCameraControl* aDOMCameraControl) override
-    {
-      nsCOMPtr<nsIDOMBlob> picture =
-        Blob::CreateMemoryBlob(mDOMCameraControl.get(),
-                               static_cast<void*>(mData),
-                               static_cast<uint64_t>(mLength),
-                               mMimeType);
-      aDOMCameraControl->OnTakePictureComplete(picture);
-      mData = NULL;
-    }
-
-  protected:
-    virtual
-    ~Callback()
-    {
-        free(mData);
-    }
-
-    uint8_t* mData;
-    uint32_t mLength;
-    nsString mMimeType;
-  };
-
-  NS_DispatchToMainThread(new Callback(mDOMCameraControl, aData, aLength, aMimeType));
-}
-
-void
-DOMCameraControlListener::OnUserError(UserContext aContext, nsresult aError)
-{
-  class Callback : public DOMCallback
-  {
-  public:
-    Callback(nsMainThreadPtrHandle<nsISupports> aDOMCameraControl,
-             UserContext aContext,
-             nsresult aError)
-      : DOMCallback(aDOMCameraControl)
-      , mContext(aContext)
-      , mError(aError)
-    { }
-
-    virtual void
-    RunCallback(nsDOMCameraControl* aDOMCameraControl) override
-    {
-      aDOMCameraControl->OnUserError(mContext, mError);
-    }
-
-  protected:
-    UserContext mContext;
-    nsresult mError;
-  };
-
-  NS_DispatchToMainThread(new Callback(mDOMCameraControl, aContext, aError));
-}
-
-void
-DOMCameraControlListener::OnPoster(BlobImpl* aBlobImpl)
-{
-  class Callback : public DOMCallback
-  {
-  public:
-    Callback(nsMainThreadPtrHandle<nsISupports> aDOMCameraControl, BlobImpl* aBlobImpl)
-      : DOMCallback(aDOMCameraControl)
-      , mBlobImpl(aBlobImpl)
-    { }
-
-    void
-    RunCallback(nsDOMCameraControl* aDOMCameraControl) override
-    {
-      aDOMCameraControl->OnPoster(mBlobImpl);
-    }
-
-  protected:
-    RefPtr<BlobImpl> mBlobImpl;
-  };
-
-  NS_DispatchToMainThread(new Callback(mDOMCameraControl, aBlobImpl));
-}
deleted file mode 100644
--- a/dom/camera/DOMCameraControlListener.h
+++ /dev/null
@@ -1,51 +0,0 @@
-/* This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this file,
- * You can obtain one at http://mozilla.org/MPL/2.0/. */
-
-#ifndef DOM_CAMERA_DOMCAMERACONTROLLISTENER_H
-#define DOM_CAMERA_DOMCAMERACONTROLLISTENER_H
-
-#include "nsProxyRelease.h"
-#include "CameraControlListener.h"
-
-namespace mozilla {
-
-class nsDOMCameraControl;
-class CameraPreviewMediaStream;
-
-class DOMCameraControlListener : public CameraControlListener
-{
-public:
-  DOMCameraControlListener(nsDOMCameraControl* aDOMCameraControl, CameraPreviewMediaStream* aStream);
-
-  virtual void OnAutoFocusComplete(bool aAutoFocusSucceeded) override;
-  virtual void OnAutoFocusMoving(bool aIsMoving) override;
-  virtual void OnFacesDetected(const nsTArray<ICameraControl::Face>& aFaces) override;
-  virtual void OnTakePictureComplete(const uint8_t* aData, uint32_t aLength, const nsAString& aMimeType) override;
-
-  virtual void OnHardwareStateChange(HardwareState aState, nsresult aReason) override;
-  virtual void OnPreviewStateChange(PreviewState aState) override;
-  virtual void OnRecorderStateChange(RecorderState aState, int32_t aStatus, int32_t aTrackNum) override;
-  virtual void OnConfigurationChange(const CameraListenerConfiguration& aConfiguration) override;
-  virtual void OnShutter() override;
-  virtual void OnRateLimitPreview(bool aLimit) override;
-  virtual bool OnNewPreviewFrame(layers::Image* aImage, uint32_t aWidth, uint32_t aHeight) override;
-  virtual void OnUserError(UserContext aContext, nsresult aError) override;
-  virtual void OnPoster(dom::BlobImpl* aBlobImpl) override;
-
-protected:
-  virtual ~DOMCameraControlListener();
-
-  nsMainThreadPtrHandle<nsISupports> mDOMCameraControl;
-  CameraPreviewMediaStream* mStream;
-
-  class DOMCallback;
-
-private:
-  DOMCameraControlListener(const DOMCameraControlListener&) = delete;
-  DOMCameraControlListener& operator=(const DOMCameraControlListener&) = delete;
-};
-
-} // namespace mozilla
-
-#endif // DOM_CAMERA_DOMCAMERACONTROLLISTENER_H
deleted file mode 100644
--- a/dom/camera/DOMCameraDetectedFace.cpp
+++ /dev/null
@@ -1,89 +0,0 @@
-/* This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this file,
- * You can obtain one at http://mozilla.org/MPL/2.0/. */
-
-#include "DOMCameraDetectedFace.h"
-#include "Navigator.h"
-
-using namespace mozilla;
-using namespace mozilla::dom;
-
-NS_IMPL_CYCLE_COLLECTION_WRAPPERCACHE(DOMCameraDetectedFace, mParent,
-                                      mBounds, mLeftEye, mRightEye, mMouth)
-
-NS_IMPL_CYCLE_COLLECTING_ADDREF(DOMCameraDetectedFace)
-NS_IMPL_CYCLE_COLLECTING_RELEASE(DOMCameraDetectedFace)
-NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(DOMCameraDetectedFace)
-  NS_WRAPPERCACHE_INTERFACE_MAP_ENTRY
-  NS_INTERFACE_MAP_ENTRY(nsISupports)
-NS_INTERFACE_MAP_END
-
-/* static */
-bool
-DOMCameraDetectedFace::HasSupport(JSContext* aCx, JSObject* aGlobal)
-{
-  return Navigator::HasCameraSupport(aCx, aGlobal);
-}
-
-JSObject*
-DOMCameraDetectedFace::WrapObject(JSContext* aCx, JS::Handle<JSObject*> aGivenProto)
-{
-  return CameraDetectedFaceBinding::Wrap(aCx, this, aGivenProto);
-}
-
-/* static */
-already_AddRefed<DOMCameraDetectedFace>
-DOMCameraDetectedFace::Constructor(const GlobalObject& aGlobal,
-                                   const dom::CameraDetectedFaceInit& aFace,
-                                   ErrorResult& aRv)
-{
-  RefPtr<DOMCameraDetectedFace> face =
-    new DOMCameraDetectedFace(aGlobal.GetAsSupports(), aFace);
-  return face.forget();
-}
-
-DOMCameraDetectedFace::DOMCameraDetectedFace(nsISupports* aParent,
-                                             const dom::CameraDetectedFaceInit& aFace)
-  : mParent(aParent)
-  , mId(aFace.mId)
-  , mScore(aFace.mScore)
-  , mBounds(new DOMRect(this))
-{
-  mBounds->SetRect(aFace.mBounds.mLeft,
-                   aFace.mBounds.mTop,
-                   aFace.mBounds.mRight - aFace.mBounds.mLeft,
-                   aFace.mBounds.mBottom - aFace.mBounds.mTop);
-
-  if (aFace.mHasLeftEye) {
-    mLeftEye = new DOMPoint(this, aFace.mLeftEye.mX, aFace.mLeftEye.mY);
-  }
-  if (aFace.mHasRightEye) {
-    mRightEye = new DOMPoint(this, aFace.mRightEye.mX, aFace.mRightEye.mY);
-  }
-  if (aFace.mHasMouth) {
-    mMouth = new DOMPoint(this, aFace.mMouth.mX, aFace.mMouth.mY);
-  }
-}
-
-DOMCameraDetectedFace::DOMCameraDetectedFace(nsISupports* aParent,
-                                             const ICameraControl::Face& aFace)
-  : mParent(aParent)
-  , mId(aFace.id)
-  , mScore(aFace.score)
-  , mBounds(new DOMRect(this))
-{
-  mBounds->SetRect(aFace.bound.left,
-                   aFace.bound.top,
-                   aFace.bound.right - aFace.bound.left,
-                   aFace.bound.bottom - aFace.bound.top);
-
-  if (aFace.hasLeftEye) {
-    mLeftEye = new DOMPoint(this, aFace.leftEye.x, aFace.leftEye.y);
-  }
-  if (aFace.hasRightEye) {
-    mRightEye = new DOMPoint(this, aFace.rightEye.x, aFace.rightEye.y);
-  }
-  if (aFace.hasMouth) {
-    mMouth = new DOMPoint(this, aFace.mouth.x, aFace.mouth.y);
-  }
-}
deleted file mode 100644
--- a/dom/camera/DOMCameraDetectedFace.h
+++ /dev/null
@@ -1,80 +0,0 @@
-/* This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this file,
- * You can obtain one at http://mozilla.org/MPL/2.0/. */
-
-#ifndef DOM_CAMERA_DOMCAMERADETECTEDFACE_H
-#define DOM_CAMERA_DOMCAMERADETECTEDFACE_H
-
-#include "mozilla/dom/CameraControlBinding.h"
-#include "nsCycleCollectionParticipant.h"
-#include "nsWrapperCache.h"
-#include "mozilla/dom/DOMRect.h"
-#include "mozilla/dom/DOMPoint.h"
-#include "ICameraControl.h"
-
-namespace mozilla {
-
-namespace dom {
-
-class DOMCameraDetectedFace final : public nsISupports
-                                  , public nsWrapperCache
-{
-public:
-  NS_DECL_CYCLE_COLLECTING_ISUPPORTS
-  NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS(DOMCameraDetectedFace)
-
-  // Because this header's filename doesn't match its C++ or DOM-facing
-  // classname, we can't rely on the [Func="..."] WebIDL tag to implicitly
-  // include the right header for us; instead we must explicitly include a
-  // HasSupport() method in each header. We can get rid of these with the
-  // Great Renaming proposed in bug 983177.
-  static bool HasSupport(JSContext* aCx, JSObject* aGlobal);
-
-  static already_AddRefed<DOMCameraDetectedFace> Constructor(const GlobalObject& aGlobal,
-                                                             const dom::CameraDetectedFaceInit& aFace,
-                                                             ErrorResult& aRv);
-
-  DOMCameraDetectedFace(nsISupports* aParent, const ICameraControl::Face& aFace);
-
-  uint32_t Id()       { return mId; }
-  uint32_t Score()    { return mScore; }
-  bool HasLeftEye()   { return mLeftEye; }
-  bool HasRightEye()  { return mRightEye; }
-  bool HasMouth()     { return mMouth; }
-
-  dom::DOMRect* Bounds()        { return mBounds; }
-
-  dom::DOMPoint* GetLeftEye()  { return mLeftEye; }
-  dom::DOMPoint* GetRightEye() { return mRightEye; }
-  dom::DOMPoint* GetMouth()    { return mMouth; }
-
-  nsISupports*
-  GetParentObject() const
-  {
-    MOZ_ASSERT(mParent);
-    return mParent;
-  }
-
-  virtual JSObject* WrapObject(JSContext* aCx, JS::Handle<JSObject*> aGivenProto) override;
-
-protected:
-  DOMCameraDetectedFace(nsISupports* aParent, const dom::CameraDetectedFaceInit& aFace);
-  virtual ~DOMCameraDetectedFace() { }
-
-  nsCOMPtr<nsISupports> mParent;
-
-  uint32_t mId;
-  uint32_t mScore;
-
-  RefPtr<dom::DOMRect> mBounds;
-
-  RefPtr<dom::DOMPoint> mLeftEye;
-  RefPtr<dom::DOMPoint> mRightEye;
-  RefPtr<dom::DOMPoint> mMouth;
-};
-
-} // namespace dom
-
-} // namespace mozilla
-
-#endif // DOM_CAMERA_DOMCAMERADETECTEDFACE_H
deleted file mode 100644
--- a/dom/camera/DOMCameraManager.cpp
+++ /dev/null
@@ -1,451 +0,0 @@
-/* This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this file,
- * You can obtain one at http://mozilla.org/MPL/2.0/. */
-
-#include "DOMCameraManager.h"
-#include "nsDebug.h"
-#include "jsapi.h"
-#include "Navigator.h"
-#include "nsPIDOMWindow.h"
-#include "mozilla/Services.h"
-#include "nsContentPermissionHelper.h"
-#include "nsIContentPermissionPrompt.h"
-#include "nsIObserverService.h"
-#include "nsIPermissionManager.h"
-#include "nsIScriptObjectPrincipal.h"
-#include "DOMCameraControl.h"
-#include "nsDOMClassInfo.h"
-#include "CameraCommon.h"
-#include "CameraPreferences.h"
-#include "mozilla/dom/BindingUtils.h"
-#include "mozilla/dom/PermissionMessageUtils.h"
-#include "nsQueryObject.h"
-
-using namespace mozilla;
-using namespace mozilla::dom;
-
-NS_IMPL_CYCLE_COLLECTION_WRAPPERCACHE(nsDOMCameraManager, mWindow)
-
-NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(nsDOMCameraManager)
-  NS_WRAPPERCACHE_INTERFACE_MAP_ENTRY
-  NS_INTERFACE_MAP_ENTRY_AMBIGUOUS(nsISupports, nsIObserver)
-  NS_INTERFACE_MAP_ENTRY(nsISupportsWeakReference)
-  NS_INTERFACE_MAP_ENTRY(nsIObserver)
-NS_INTERFACE_MAP_END
-
-NS_IMPL_CYCLE_COLLECTING_ADDREF(nsDOMCameraManager)
-NS_IMPL_CYCLE_COLLECTING_RELEASE(nsDOMCameraManager)
-
-/**
- * Global camera logging object
- *
- * Set the MOZ_LOG environment variable to enable logging
- * in a debug build, e.g. MOZ_LOG=Camera:5
- */
-LogModule*
-GetCameraLog()
-{
-  static LazyLogModule sLog("Camera");
-  return sLog;
-}
-
-::WindowTable* nsDOMCameraManager::sActiveWindows = nullptr;
-
-nsDOMCameraManager::nsDOMCameraManager(nsPIDOMWindowInner* aWindow)
-  : mWindowId(aWindow->WindowID())
-  , mPermission(nsIPermissionManager::DENY_ACTION)
-  , mWindow(aWindow)
-{
-  /* member initializers and constructor code */
-  DOM_CAMERA_LOGT("%s:%d : this=%p, windowId=%" PRIx64 "\n", __func__, __LINE__, this, mWindowId);
-  MOZ_COUNT_CTOR(nsDOMCameraManager);
-}
-
-nsDOMCameraManager::~nsDOMCameraManager()
-{
-  /* destructor code */
-  MOZ_COUNT_DTOR(nsDOMCameraManager);
-  DOM_CAMERA_LOGT("%s:%d : this=%p\n", __func__, __LINE__, this);
-}
-
-/* static */
-void
-nsDOMCameraManager::GetListOfCameras(nsTArray<nsString>& aList, ErrorResult& aRv)
-{
-  aRv = ICameraControl::GetListOfCameras(aList);
-}
-
-/* static */
-bool
-nsDOMCameraManager::HasSupport(JSContext* aCx, JSObject* aGlobal)
-{
-  return Navigator::HasCameraSupport(aCx, aGlobal);
-}
-
-/* static */
-bool
-nsDOMCameraManager::CheckPermission(nsPIDOMWindowInner* aWindow)
-{
-  nsCOMPtr<nsIPermissionManager> permMgr =
-    services::GetPermissionManager();
-  NS_ENSURE_TRUE(permMgr, false);
-
-  uint32_t permission = nsIPermissionManager::DENY_ACTION;
-  permMgr->TestPermissionFromWindow(aWindow, "camera", &permission);
-  if (permission != nsIPermissionManager::ALLOW_ACTION &&
-      permission != nsIPermissionManager::PROMPT_ACTION) {
-    return false;
-  }
-
-  return true;
-}
-
-/* static */
-already_AddRefed<nsDOMCameraManager>
-nsDOMCameraManager::CreateInstance(nsPIDOMWindowInner* aWindow)
-{
-  // Initialize the shared active window tracker
-  if (!sActiveWindows) {
-    sActiveWindows = new ::WindowTable();
-  }
-
-  RefPtr<nsDOMCameraManager> cameraManager =
-    new nsDOMCameraManager(aWindow);
-
-  nsCOMPtr<nsIObserverService> obs = services::GetObserverService();
-  if (!obs) {
-    DOM_CAMERA_LOGE("Camera manager failed to get observer service\n");
-    return nullptr;
-  }
-
-  nsresult rv = obs->AddObserver(cameraManager, "xpcom-shutdown", true);
-  if (NS_FAILED(rv)) {
-    DOM_CAMERA_LOGE("Camera manager failed to add 'xpcom-shutdown' observer (0x%x)\n", rv);
-    return nullptr;
-  }
-
-  return cameraManager.forget();
-}
-
-class CameraPermissionRequest : public nsIContentPermissionRequest
-                              , public nsIRunnable
-{
-public:
-  NS_DECL_CYCLE_COLLECTING_ISUPPORTS
-  NS_DECL_NSICONTENTPERMISSIONREQUEST
-  NS_DECL_NSIRUNNABLE
-  NS_DECL_CYCLE_COLLECTION_CLASS_AMBIGUOUS(CameraPermissionRequest,
-                                           nsIContentPermissionRequest)
-
-  CameraPermissionRequest(nsIPrincipal* aPrincipal,
-                          nsPIDOMWindowInner* aWindow,
-                          RefPtr<nsDOMCameraManager> aManager,
-                          uint32_t aCameraId,
-                          const CameraConfiguration& aInitialConfig,
-                          RefPtr<Promise> aPromise)
-    : mPrincipal(aPrincipal)
-    , mWindow(aWindow)
-    , mCameraManager(aManager)
-    , mCameraId(aCameraId)
-    , mInitialConfig(aInitialConfig)
-    , mPromise(aPromise)
-    , mRequester(new nsContentPermissionRequester(mWindow))
-  { }
-
-protected:
-  virtual ~CameraPermissionRequest() { }
-
-  nsresult DispatchCallback(uint32_t aPermission);
-  void CallAllow();
-  void CallCancel();
-  nsCOMPtr<nsIPrincipal> mPrincipal;
-  nsCOMPtr<nsPIDOMWindowInner> mWindow;
-  RefPtr<nsDOMCameraManager> mCameraManager;
-  uint32_t mCameraId;
-  CameraConfiguration mInitialConfig;
-  RefPtr<Promise> mPromise;
-  nsCOMPtr<nsIContentPermissionRequester> mRequester;
-};
-
-NS_IMPL_CYCLE_COLLECTION(CameraPermissionRequest, mWindow, mPromise)
-
-NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(CameraPermissionRequest)
-  NS_INTERFACE_MAP_ENTRY(nsIContentPermissionRequest)
-  NS_INTERFACE_MAP_ENTRY(nsIRunnable)
-  NS_INTERFACE_MAP_ENTRY_AMBIGUOUS(nsISupports, nsIContentPermissionRequest)
-NS_INTERFACE_MAP_END
-
-NS_IMPL_CYCLE_COLLECTING_ADDREF(CameraPermissionRequest)
-NS_IMPL_CYCLE_COLLECTING_RELEASE(CameraPermissionRequest)
-
-NS_IMETHODIMP
-CameraPermissionRequest::Run()
-{
-  return nsContentPermissionUtils::AskPermission(this, mWindow);
-}
-
-NS_IMETHODIMP
-CameraPermissionRequest::GetPrincipal(nsIPrincipal** aRequestingPrincipal)
-{
-  NS_ADDREF(*aRequestingPrincipal = mPrincipal);
-  return NS_OK;
-}
-
-NS_IMETHODIMP
-CameraPermissionRequest::GetWindow(mozIDOMWindow** aRequestingWindow)
-{
-  NS_ADDREF(*aRequestingWindow = mWindow);
-  return NS_OK;
-}
-
-NS_IMETHODIMP
-CameraPermissionRequest::GetElement(nsIDOMElement** aElement)
-{
-  *aElement = nullptr;
-  return NS_OK;
-}
-
-NS_IMETHODIMP
-CameraPermissionRequest::Cancel()
-{
-  return DispatchCallback(nsIPermissionManager::DENY_ACTION);
-}
-
-NS_IMETHODIMP
-CameraPermissionRequest::Allow(JS::HandleValue aChoices)
-{
-  MOZ_ASSERT(aChoices.isUndefined());
-  return DispatchCallback(nsIPermissionManager::ALLOW_ACTION);
-}
-
-NS_IMETHODIMP
-CameraPermissionRequest::GetRequester(nsIContentPermissionRequester** aRequester)
-{
-  NS_ENSURE_ARG_POINTER(aRequester);
-
-  nsCOMPtr<nsIContentPermissionRequester> requester = mRequester;
-  requester.forget(aRequester);
-  return NS_OK;
-}
-
-nsresult
-CameraPermissionRequest::DispatchCallback(uint32_t aPermission)
-{
-  nsCOMPtr<nsIRunnable> callbackRunnable;
-  if (aPermission == nsIPermissionManager::ALLOW_ACTION) {
-    callbackRunnable = NewRunnableMethod(this, &CameraPermissionRequest::CallAllow);
-  } else {
-    callbackRunnable = NewRunnableMethod(this, &CameraPermissionRequest::CallCancel);
-  }
-  return NS_DispatchToMainThread(callbackRunnable.forget());
-}
-
-void
-CameraPermissionRequest::CallAllow()
-{
-  mCameraManager->PermissionAllowed(mCameraId, mInitialConfig, mPromise);
-}
-
-void
-CameraPermissionRequest::CallCancel()
-{
-  mCameraManager->PermissionCancelled(mCameraId, mInitialConfig, mPromise);
-}
-
-NS_IMETHODIMP
-CameraPermissionRequest::GetTypes(nsIArray** aTypes)
-{
-  nsTArray<nsString> emptyOptions;
-  return nsContentPermissionUtils::CreatePermissionArray(NS_LITERAL_CSTRING("camera"),
-                                                         NS_LITERAL_CSTRING("unused"),
-                                                         emptyOptions,
-                                                         aTypes);
-}
-
-#ifdef MOZ_WIDGET_GONK
-/* static */ void
-nsDOMCameraManager::PreinitCameraHardware()
-{
-  nsDOMCameraControl::PreinitCameraHardware();
-}
-#endif
-
-already_AddRefed<Promise>
-nsDOMCameraManager::GetCamera(const nsAString& aCamera,
-                              const CameraConfiguration& aInitialConfig,
-                              ErrorResult& aRv)
-{
-  DOM_CAMERA_LOGT("%s:%d\n", __func__, __LINE__);
-
-  uint32_t cameraId = 0;  // back (or forward-facing) camera by default
-  if (aCamera.EqualsLiteral("front")) {
-    cameraId = 1;
-  }
-
-  nsCOMPtr<nsIGlobalObject> global = do_QueryInterface(mWindow);
-  if (!global) {
-    aRv.Throw(NS_ERROR_FAILURE);
-    return nullptr;
-  }
-
-  RefPtr<Promise> promise = Promise::Create(global, aRv);
-  if (aRv.Failed()) {
-    return nullptr;
-  }
-
-  if (mPermission == nsIPermissionManager::ALLOW_ACTION) {
-    PermissionAllowed(cameraId, aInitialConfig, promise);
-    return promise.forget();
-  }
-
-  nsCOMPtr<nsIScriptObjectPrincipal> sop = do_QueryInterface(mWindow);
-  if (!sop) {
-    aRv.Throw(NS_ERROR_UNEXPECTED);
-    return nullptr;
-  }
-
-  nsCOMPtr<nsIPrincipal> principal = sop->GetPrincipal();
-  // If we are a CERTIFIED app, we can short-circuit the permission check,
-  // which gets us a performance win.
-  // Unprivileged mochitests always fail the dispatched permission check,
-  // even if permission to the camera has been granted.
-  bool immediateCheck = false;
-  CameraPreferences::GetPref("camera.control.test.permission", immediateCheck);
-  if ((principal->GetAppStatus() == nsIPrincipal::APP_STATUS_CERTIFIED || immediateCheck) &&
-      CheckPermission(mWindow)) {
-    PermissionAllowed(cameraId, aInitialConfig, promise);
-    return promise.forget();
-  }
-
-  nsCOMPtr<nsIRunnable> permissionRequest =
-    new CameraPermissionRequest(principal, mWindow, this, cameraId,
-                                aInitialConfig, promise);
-
-  NS_DispatchToMainThread(permissionRequest);
-  return promise.forget();
-}
-
-void
-nsDOMCameraManager::PermissionAllowed(uint32_t aCameraId,
-                                      const CameraConfiguration& aInitialConfig,
-                                      Promise* aPromise)
-{
-  mPermission = nsIPermissionManager::ALLOW_ACTION;
-
-  // Creating this object will trigger the aOnSuccess callback
-  //  (or the aOnError one, if it fails).
-  RefPtr<nsDOMCameraControl> cameraControl =
-    new nsDOMCameraControl(aCameraId, aInitialConfig, aPromise, mWindow);
-
-  Register(cameraControl);
-}
-
-void
-nsDOMCameraManager::PermissionCancelled(uint32_t aCameraId,
-                                        const CameraConfiguration& aInitialConfig,
-                                        Promise* aPromise)
-{
-  mPermission = nsIPermissionManager::DENY_ACTION;
-  aPromise->MaybeReject(NS_ERROR_DOM_SECURITY_ERR);
-}
-
-void
-nsDOMCameraManager::Register(nsDOMCameraControl* aDOMCameraControl)
-{
-  DOM_CAMERA_LOGI(">>> Register( aDOMCameraControl = %p ) mWindowId = 0x%" PRIx64 "\n", aDOMCameraControl, mWindowId);
-  MOZ_ASSERT(NS_IsMainThread());
-
-  CameraControls* controls = sActiveWindows->Get(mWindowId);
-  if (!controls) {
-    controls = new CameraControls();
-    sActiveWindows->Put(mWindowId, controls);
-  }
-
-  // Remove any stale CameraControl objects to limit our memory usage
-  uint32_t i = controls->Length();
-  while (i > 0) {
-    --i;
-    RefPtr<nsDOMCameraControl> cameraControl =
-      do_QueryObject(controls->ElementAt(i));
-    if (!cameraControl) {
-      controls->RemoveElementAt(i);
-    }
-  }
-
-  // Put the camera control into the hash table
-  nsWeakPtr cameraControl =
-    do_GetWeakReference(static_cast<DOMMediaStream*>(aDOMCameraControl));
-  controls->AppendElement(cameraControl);
-}
-
-void
-nsDOMCameraManager::Shutdown(uint64_t aWindowId)
-{
-  DOM_CAMERA_LOGI(">>> Shutdown( aWindowId = 0x%" PRIx64 " )\n", aWindowId);
-  MOZ_ASSERT(NS_IsMainThread());
-
-  CameraControls* controls = sActiveWindows->Get(aWindowId);
-  if (!controls) {
-    return;
-  }
-
-  uint32_t i = controls->Length();
-  while (i > 0) {
-    --i;
-    RefPtr<nsDOMCameraControl> cameraControl =
-      do_QueryObject(controls->ElementAt(i));
-    if (cameraControl) {
-      cameraControl->Shutdown();
-    }
-  }
-  controls->Clear();
-
-  sActiveWindows->Remove(aWindowId);
-}
-
-void
-nsDOMCameraManager::XpComShutdown()
-{
-  DOM_CAMERA_LOGI(">>> XPCOM Shutdown\n");
-  MOZ_ASSERT(NS_IsMainThread());
-
-  nsCOMPtr<nsIObserverService> obs = services::GetObserverService();
-  obs->RemoveObserver(this, "xpcom-shutdown");
-
-  delete sActiveWindows;
-  sActiveWindows = nullptr;
-}
-
-nsresult
-nsDOMCameraManager::Observe(nsISupports* aSubject, const char* aTopic, const char16_t* aData)
-{
-  if (strcmp(aTopic, "xpcom-shutdown") == 0) {
-    XpComShutdown();
-  }
-  return NS_OK;
-}
-
-void
-nsDOMCameraManager::OnNavigation(uint64_t aWindowId)
-{
-  DOM_CAMERA_LOGI(">>> OnNavigation event\n");
-  Shutdown(aWindowId);
-}
-
-bool
-nsDOMCameraManager::IsWindowStillActive(uint64_t aWindowId)
-{
-  MOZ_ASSERT(NS_IsMainThread());
-
-  if (!sActiveWindows) {
-    return false;
-  }
-
-  return !!sActiveWindows->Get(aWindowId);
-}
-
-JSObject*
-nsDOMCameraManager::WrapObject(JSContext* aCx, JS::Handle<JSObject*> aGivenProto)
-{
-  return CameraManagerBinding::Wrap(aCx, this, aGivenProto);
-}
deleted file mode 100644
--- a/dom/camera/DOMCameraManager.h
+++ /dev/null
@@ -1,104 +0,0 @@
-/* -*- Mode: c++; c-basic-offset: 2; indent-tabs-mode: nil; tab-width: 40 -*- */
-/* vim: set ts=2 et sw=2 tw=40: */
-/* This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this file,
- * You can obtain one at http://mozilla.org/MPL/2.0/. */
-
-#ifndef DOM_CAMERA_DOMCAMERAMANAGER_H
-#define DOM_CAMERA_DOMCAMERAMANAGER_H
-
-#include "mozilla/dom/BindingDeclarations.h"
-#include "mozilla/dom/Promise.h"
-#include "nsCOMPtr.h"
-#include "nsIObserver.h"
-#include "nsHashKeys.h"
-#include "nsWrapperCache.h"
-#include "nsWeakReference.h"
-#include "nsClassHashtable.h"
-#include "nsCycleCollectionParticipant.h"
-#include "mozilla/Attributes.h"
-
-class nsPIDOMWindowInner;
-
-namespace mozilla {
-  class ErrorResult;
-  class nsDOMCameraControl;
-  namespace dom {
-    struct CameraConfiguration;
-  } // namespace dom
-} // namespace mozilla
-
-typedef nsTArray<nsWeakPtr> CameraControls;
-typedef nsClassHashtable<nsUint64HashKey, CameraControls> WindowTable;
-
-class nsDOMCameraManager final
-  : public nsIObserver
-  , public nsSupportsWeakReference
-  , public nsWrapperCache
-{
-public:
-  NS_DECL_CYCLE_COLLECTING_ISUPPORTS
-  NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS_AMBIGUOUS(nsDOMCameraManager,
-                                                         nsIObserver)
-  NS_DECL_NSIOBSERVER
-
-  // Because this header's filename doesn't match its C++ or DOM-facing
-  // classname, we can't rely on the [Func="..."] WebIDL tag to implicitly
-  // include the right header for us; instead we must explicitly include a
-  // HasSupport() method in each header. We can get rid of these with the
-  // Great Renaming proposed in bug 983177.
-  static bool HasSupport(JSContext* aCx, JSObject* aGlobal);
-
-  static bool CheckPermission(nsPIDOMWindowInner* aWindow);
-  static already_AddRefed<nsDOMCameraManager>
-    CreateInstance(nsPIDOMWindowInner* aWindow);
-  static bool IsWindowStillActive(uint64_t aWindowId);
-
-  void Register(mozilla::nsDOMCameraControl* aDOMCameraControl);
-  void OnNavigation(uint64_t aWindowId);
-
-  void PermissionAllowed(uint32_t aCameraId,
-                         const mozilla::dom::CameraConfiguration& aOptions,
-                         mozilla::dom::Promise* aPromise);
-
-  void PermissionCancelled(uint32_t aCameraId,
-                           const mozilla::dom::CameraConfiguration& aOptions,
-                           mozilla::dom::Promise* aPromise);
-
-  // WebIDL
-  already_AddRefed<mozilla::dom::Promise>
-  GetCamera(const nsAString& aCamera,
-            const mozilla::dom::CameraConfiguration& aOptions,
-            mozilla::ErrorResult& aRv);
-  void GetListOfCameras(nsTArray<nsString>& aList, mozilla::ErrorResult& aRv);
-
-  nsPIDOMWindowInner* GetParentObject() const { return mWindow; }
-  virtual JSObject* WrapObject(JSContext* aCx, JS::Handle<JSObject*> aGivenProto) override;
-
-#ifdef MOZ_WIDGET_GONK
-  static void PreinitCameraHardware();
-#endif
-
-protected:
-  void XpComShutdown();
-  void Shutdown(uint64_t aWindowId);
-  ~nsDOMCameraManager();
-
-private:
-  nsDOMCameraManager() = delete;
-  explicit nsDOMCameraManager(nsPIDOMWindowInner* aWindow);
-  nsDOMCameraManager(const nsDOMCameraManager&) = delete;
-  nsDOMCameraManager& operator=(const nsDOMCameraManager&) = delete;
-
-protected:
-  uint64_t mWindowId;
-  uint32_t mPermission;
-  nsCOMPtr<nsPIDOMWindowInner> mWindow;
-  /**
-   * 'sActiveWindows' is only ever accessed while in the Main Thread,
-   * so it is not otherwise protected.
-   */
-  static ::WindowTable* sActiveWindows;
-};
-
-#endif // DOM_CAMERA_DOMCAMERAMANAGER_H
deleted file mode 100644
--- a/dom/camera/FallbackCameraControl.cpp
+++ /dev/null
@@ -1,73 +0,0 @@
-/* This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this file,
- * You can obtain one at http://mozilla.org/MPL/2.0/. */
-
-#include "CameraControlImpl.h"
-
-using namespace mozilla;
-using namespace mozilla::dom;
-
-namespace mozilla {
-  class RecorderProfileManager;
-
-  namespace layers {
-    class GraphicBufferLocked;
-  } // namespace layers
-} // namespace mozilla
-
-/**
- * Fallback camera control subclass. Can be used as a template for the
- * definition of new camera support classes.
- */
-class FallbackCameraControl : public CameraControlImpl
-{
-public:
-  explicit FallbackCameraControl() : CameraControlImpl() { }
-
-  virtual nsresult Set(uint32_t aKey, const nsAString& aValue) override { return NS_ERROR_NOT_IMPLEMENTED; }
-  virtual nsresult Get(uint32_t aKey, nsAString& aValue) override { return NS_ERROR_NOT_IMPLEMENTED; }
-  virtual nsresult Set(uint32_t aKey, double aValue) override { return NS_ERROR_NOT_IMPLEMENTED; }
-  virtual nsresult Get(uint32_t aKey, double& aValue) override { return NS_ERROR_NOT_IMPLEMENTED; }
-  virtual nsresult Set(uint32_t aKey, int32_t aValue) override { return NS_ERROR_NOT_IMPLEMENTED; }
-  virtual nsresult Get(uint32_t aKey, int32_t& aValue) override { return NS_ERROR_NOT_IMPLEMENTED; }
-  virtual nsresult Set(uint32_t aKey, int64_t aValue) override { return NS_ERROR_NOT_IMPLEMENTED; }
-  virtual nsresult Get(uint32_t aKey, int64_t& aValue) override { return NS_ERROR_NOT_IMPLEMENTED; }
-  virtual nsresult Set(uint32_t aKey, bool aValue) override { return NS_ERROR_NOT_IMPLEMENTED; }
-  virtual nsresult Get(uint32_t aKey, bool& aValue) override { return NS_ERROR_NOT_IMPLEMENTED; }
-  virtual nsresult Set(uint32_t aKey, const Size& aValue) override { return NS_ERROR_NOT_IMPLEMENTED; }
-  virtual nsresult Get(uint32_t aKey, Size& aValue) override { return NS_ERROR_NOT_IMPLEMENTED; }
-  virtual nsresult Set(uint32_t aKey, const nsTArray<Region>& aRegions) override { return NS_ERROR_NOT_IMPLEMENTED; }
-  virtual nsresult Get(uint32_t aKey, nsTArray<Region>& aRegions) override { return NS_ERROR_NOT_IMPLEMENTED; }
-
-  virtual nsresult SetLocation(const Position& aLocation) override { return NS_ERROR_NOT_IMPLEMENTED; }
-
-  virtual nsresult Get(uint32_t aKey, nsTArray<Size>& aSizes) override { return NS_ERROR_NOT_IMPLEMENTED; }
-  virtual nsresult Get(uint32_t aKey, nsTArray<nsString>& aValues) override { return NS_ERROR_NOT_IMPLEMENTED; }
-  virtual nsresult Get(uint32_t aKey, nsTArray<double>& aValues) override { return NS_ERROR_NOT_IMPLEMENTED; }
-
-  virtual nsresult GetRecorderProfiles(nsTArray<nsString>& aProfiles) override { return NS_ERROR_NOT_IMPLEMENTED; }
-  virtual RecorderProfile* GetProfileInfo(const nsAString& aProfile) override { return nullptr; }
-
-  nsresult PushParameters() { return NS_ERROR_NOT_INITIALIZED; }
-  nsresult PullParameters() { return NS_ERROR_NOT_INITIALIZED; }
-
-protected:
-  ~FallbackCameraControl();
-
-  virtual nsresult StartPreviewImpl() override { return NS_ERROR_NOT_INITIALIZED; }
-  virtual nsresult StopPreviewImpl() override { return NS_ERROR_NOT_INITIALIZED; }
-  virtual nsresult AutoFocusImpl() override { return NS_ERROR_NOT_INITIALIZED; }
-  virtual nsresult StartFaceDetectionImpl() override { return NS_ERROR_NOT_INITIALIZED; }
-  virtual nsresult StopFaceDetectionImpl() override { return NS_ERROR_NOT_INITIALIZED; }
-  virtual nsresult TakePictureImpl() override { return NS_ERROR_NOT_INITIALIZED; }
-  virtual nsresult StartRecordingImpl(DeviceStorageFileDescriptor* aFileDescriptor,
-                                      const StartRecordingOptions* aOptions = nullptr) override
-                                        { return NS_ERROR_NOT_INITIALIZED; }
-  virtual nsresult StopRecordingImpl() override { return NS_ERROR_NOT_INITIALIZED; }
-  virtual nsresult PushParametersImpl() override { return NS_ERROR_NOT_INITIALIZED; }
-  virtual nsresult PullParametersImpl() override { return NS_ERROR_NOT_INITIALIZED; }
-
-private:
-  FallbackCameraControl(const FallbackCameraControl&) = delete;
-  FallbackCameraControl& operator=(const FallbackCameraControl&) = delete;
-};
deleted file mode 100644
--- a/dom/camera/FallbackCameraManager.cpp
+++ /dev/null
@@ -1,32 +0,0 @@
-/* This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this file,
- * You can obtain one at http://mozilla.org/MPL/2.0/. */
-
-#include "ICameraControl.h"
-
-using namespace mozilla;
-
-// From ICameraControl.
-nsresult
-ICameraControl::GetNumberOfCameras(int32_t& aDeviceCount)
-{
-  return NS_ERROR_NOT_IMPLEMENTED;
-};
-
-nsresult
-ICameraControl::GetCameraName(uint32_t aDeviceNum, nsCString& aDeviceName)
-{
-  return NS_ERROR_NOT_IMPLEMENTED;
-}
-
-nsresult
-ICameraControl::GetListOfCameras(nsTArray<nsString>& aList)
-{
-  return NS_ERROR_NOT_IMPLEMENTED;
-}
-
-already_AddRefed<ICameraControl>
-ICameraControl::Create(uint32_t aCameraId)
-{
-  return nullptr;
-}
deleted file mode 100644
--- a/dom/camera/FallbackCameraPlatform.cpp
+++ /dev/null
@@ -1,91 +0,0 @@
-/*
- * Copyright (C) 2008 The Android Open Source Project
- * Copyright (C) 2015 Mozilla Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#include "FallbackCameraPlatform.h"
-
-using namespace android;
-
-MediaProfiles* MediaProfiles::sMediaProfiles = nullptr;
-
-const char CameraParameters::KEY_PREVIEW_SIZE[] = "preview-size";
-const char CameraParameters::KEY_SUPPORTED_PREVIEW_SIZES[] = "preview-size-values";
-const char CameraParameters::KEY_PREVIEW_FORMAT[] = "preview-format";
-const char CameraParameters::KEY_SUPPORTED_PREVIEW_FORMATS[] = "preview-format-values";
-const char CameraParameters::KEY_PREVIEW_FRAME_RATE[] = "preview-frame-rate";
-const char CameraParameters::KEY_SUPPORTED_PREVIEW_FRAME_RATES[] = "preview-frame-rate-values";
-const char CameraParameters::KEY_PREVIEW_FPS_RANGE[] = "preview-fps-range";
-const char CameraParameters::KEY_SUPPORTED_PREVIEW_FPS_RANGE[] = "preview-fps-range-values";
-const char CameraParameters::KEY_PICTURE_SIZE[] = "picture-size";
-const char CameraParameters::KEY_SUPPORTED_PICTURE_SIZES[] = "picture-size-values";
-const char CameraParameters::KEY_PICTURE_FORMAT[] = "picture-format";
-const char CameraParameters::KEY_SUPPORTED_PICTURE_FORMATS[] = "picture-format-values";
-const char CameraParameters::KEY_JPEG_THUMBNAIL_WIDTH[] = "jpeg-thumbnail-width";
-const char CameraParameters::KEY_JPEG_THUMBNAIL_HEIGHT[] = "jpeg-thumbnail-height";
-const char CameraParameters::KEY_SUPPORTED_JPEG_THUMBNAIL_SIZES[] = "jpeg-thumbnail-size-values";
-const char CameraParameters::KEY_JPEG_THUMBNAIL_QUALITY[] = "jpeg-thumbnail-quality";
-const char CameraParameters::KEY_JPEG_QUALITY[] = "jpeg-quality";
-const char CameraParameters::KEY_ROTATION[] = "rotation";
-const char CameraParameters::KEY_GPS_LATITUDE[] = "gps-latitude";
-const char CameraParameters::KEY_GPS_LONGITUDE[] = "gps-longitude";
-const char CameraParameters::KEY_GPS_ALTITUDE[] = "gps-altitude";
-const char CameraParameters::KEY_GPS_TIMESTAMP[] = "gps-timestamp";
-const char CameraParameters::KEY_GPS_PROCESSING_METHOD[] = "gps-processing-method";
-const char CameraParameters::KEY_WHITE_BALANCE[] = "whitebalance";
-const char CameraParameters::KEY_SUPPORTED_WHITE_BALANCE[] = "whitebalance-values";
-const char CameraParameters::KEY_EFFECT[] = "effect";
-const char CameraParameters::KEY_SUPPORTED_EFFECTS[] = "effect-values";
-const char CameraParameters::KEY_ANTIBANDING[] = "antibanding";
-const char CameraParameters::KEY_SUPPORTED_ANTIBANDING[] = "antibanding-values";
-const char CameraParameters::KEY_SCENE_MODE[] = "scene-mode";
-const char CameraParameters::KEY_SUPPORTED_SCENE_MODES[] = "scene-mode-values";
-const char CameraParameters::KEY_FLASH_MODE[] = "flash-mode";
-const char CameraParameters::KEY_SUPPORTED_FLASH_MODES[] = "flash-mode-values";
-const char CameraParameters::KEY_FOCUS_MODE[] = "focus-mode";
-const char CameraParameters::KEY_SUPPORTED_FOCUS_MODES[] = "focus-mode-values";
-const char CameraParameters::KEY_MAX_NUM_FOCUS_AREAS[] = "max-num-focus-areas";
-const char CameraParameters::KEY_FOCUS_AREAS[] = "focus-areas";
-const char CameraParameters::KEY_FOCAL_LENGTH[] = "focal-length";
-const char CameraParameters::KEY_HORIZONTAL_VIEW_ANGLE[] = "horizontal-view-angle";
-const char CameraParameters::KEY_VERTICAL_VIEW_ANGLE[] = "vertical-view-angle";
-const char CameraParameters::KEY_EXPOSURE_COMPENSATION[] = "exposure-compensation";
-const char CameraParameters::KEY_MAX_EXPOSURE_COMPENSATION[] = "max-exposure-compensation";
-const char CameraParameters::KEY_MIN_EXPOSURE_COMPENSATION[] = "min-exposure-compensation";
-const char CameraParameters::KEY_EXPOSURE_COMPENSATION_STEP[] = "exposure-compensation-step";
-const char CameraParameters::KEY_AUTO_EXPOSURE_LOCK[] = "auto-exposure-lock";
-const char CameraParameters::KEY_AUTO_EXPOSURE_LOCK_SUPPORTED[] = "auto-exposure-lock-supported";
-const char CameraParameters::KEY_AUTO_WHITEBALANCE_LOCK[] = "auto-whitebalance-lock";
-const char CameraParameters::KEY_AUTO_WHITEBALANCE_LOCK_SUPPORTED[] = "auto-whitebalance-lock-supported";
-const char CameraParameters::KEY_MAX_NUM_METERING_AREAS[] = "max-num-metering-areas";
-const char CameraParameters::KEY_METERING_AREAS[] = "metering-areas";
-const char CameraParameters::KEY_ZOOM[] = "zoom";
-const char CameraParameters::KEY_MAX_ZOOM[] = "max-zoom";
-const char CameraParameters::KEY_ZOOM_RATIOS[] = "zoom-ratios";
-const char CameraParameters::KEY_ZOOM_SUPPORTED[] = "zoom-supported";
-const char CameraParameters::KEY_SMOOTH_ZOOM_SUPPORTED[] = "smooth-zoom-supported";
-const char CameraParameters::KEY_FOCUS_DISTANCES[] = "focus-distances";
-const char CameraParameters::KEY_VIDEO_FRAME_FORMAT[] = "video-frame-format";
-const char CameraParameters::KEY_VIDEO_SIZE[] = "video-size";
-const char CameraParameters::KEY_SUPPORTED_VIDEO_SIZES[] = "video-size-values";
-const char CameraParameters::KEY_PREFERRED_PREVIEW_SIZE_FOR_VIDEO[] = "preferred-preview-size-for-video";
-const char CameraParameters::KEY_MAX_NUM_DETECTED_FACES_HW[] = "max-num-detected-faces-hw";
-const char CameraParameters::KEY_MAX_NUM_DETECTED_FACES_SW[] = "max-num-detected-faces-sw";
-const char CameraParameters::KEY_RECORDING_HINT[] = "recording-hint";
-const char CameraParameters::KEY_VIDEO_SNAPSHOT_SUPPORTED[] = "video-snapshot-supported";
-const char CameraParameters::KEY_VIDEO_STABILIZATION[] = "video-stabilization";
-const char CameraParameters::KEY_VIDEO_STABILIZATION_SUPPORTED[] = "video-stabilization-supported";
-const char CameraParameters::KEY_LIGHTFX[] = "light-fx";
-
deleted file mode 100644
--- a/dom/camera/FallbackCameraPlatform.h
+++ /dev/null
@@ -1,304 +0,0 @@
-/*
- * Copyright (C) 2008 The Android Open Source Project
- * Copyright (C) 2015 Mozilla Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#ifndef DOM_CAMERA_FALLBACKCAMERAPLATFORM_H
-#define DOM_CAMERA_FALLBACKCAMERAPLATFORM_H
-
-#include <inttypes.h>
-#include <string.h>
-
-typedef struct {
-  int32_t id;
-  int32_t score;
-  int32_t rect[4];
-  int32_t left_eye[2];
-  int32_t right_eye[2];
-  int32_t mouth[2];
-} camera_face_t;
-
-typedef struct {
-  uint32_t number_of_faces;
-  camera_face_t* faces;
-} camera_frame_metadata_t;
-
-namespace android {
-  enum camcorder_quality {
-    CAMCORDER_QUALITY_LOW,
-    CAMCORDER_QUALITY_HIGH,
-    CAMCORDER_QUALITY_QCIF,
-    CAMCORDER_QUALITY_CIF,
-    CAMCORDER_QUALITY_480P,
-    CAMCORDER_QUALITY_720P,
-    CAMCORDER_QUALITY_1080P,
-    CAMCORDER_QUALITY_QVGA,
-    CAMCORDER_QUALITY_VGA,
-    CAMCORDER_QUALITY_LIST_START = CAMCORDER_QUALITY_LOW,
-    CAMCORDER_QUALITY_LIST_END = CAMCORDER_QUALITY_VGA
-  };
-
-  enum output_format {
-    OUTPUT_FORMAT_THREE_GPP,
-    OUTPUT_FORMAT_MPEG_4
-  };
-
-  enum video_encoder {
-    VIDEO_ENCODER_H263,
-    VIDEO_ENCODER_H264,
-    VIDEO_ENCODER_MPEG_4_SP
-  };
-
-  enum audio_encoder {
-    AUDIO_ENCODER_AMR_WB,
-    AUDIO_ENCODER_AMR_NB,
-    AUDIO_ENCODER_AAC
-  };
-
-  template <class T>
-  class sp final
-  {
-  public:
-    sp()
-      : mPtr(nullptr)
-    { }
-
-    sp(T *aPtr)
-      : mPtr(aPtr)
-    { }
-
-    virtual ~sp()         { }
-    T* get() const        { return mPtr; }
-    void clear()          { mPtr = nullptr; }
-    T* operator->() const { return get(); }
-
-  private:
-    RefPtr<T> mPtr;
-  };
-
-  typedef uint64_t nsecs_t;
-
-  enum error_t {
-    OK = 0,
-    UNKNOWN_ERROR,
-    INVALID_OPERATION
-  };
-
-  enum camera_msg_t {
-    CAMERA_MSG_SHUTTER,
-    CAMERA_MSG_COMPRESSED_IMAGE
-  };
-
-  class String8 final
-  {
-  public:
-    String8()                  { }
-    String8(const char* aData) { mData.AssignASCII(aData); }
-    virtual ~String8()         { }
-    const char* string() const { return mData.Data(); }
-
-  private:
-    nsCString mData;
-  };
-
-  enum camera_facing_t {
-    CAMERA_FACING_BACK,
-    CAMERA_FACING_FRONT
-  };
-
-  struct CameraInfo {
-    camera_facing_t facing;
-  };
-
-  class Camera final : public nsISupports
-  {
-  public:
-    NS_DECL_ISUPPORTS;
-
-    void disconnect()                         { }
-    String8 getParameters()                   { return String8(); }
-    int setParameters(const String8& aParams) { return UNKNOWN_ERROR; }
-    int storeMetaDataInBuffers(bool aEnabled) { return UNKNOWN_ERROR; }
-    int autoFocus()                           { return UNKNOWN_ERROR; }
-    int cancelAutoFocus()                     { return UNKNOWN_ERROR; }
-    int takePicture(uint32_t flags)           { return UNKNOWN_ERROR; }
-    int startPreview()                        { return UNKNOWN_ERROR; }
-    int stopPreview()                         { return UNKNOWN_ERROR; }
-    int startRecording()                      { return UNKNOWN_ERROR; }
-    int stopRecording()                       { return UNKNOWN_ERROR; }
-    int startFaceDetection()                  { return UNKNOWN_ERROR; }
-    int stopFaceDetection()                   { return UNKNOWN_ERROR; }
-    static int32_t getNumberOfCameras()       { return 2; }
-
-    static int getCameraInfo(int32_t aDevice, CameraInfo* aInfo)
-    {
-      switch (aDevice) {
-        case 0:
-          aInfo->facing = CAMERA_FACING_BACK;
-          break;
-        case 1:
-          aInfo->facing = CAMERA_FACING_FRONT;
-          break;
-        default:
-          return UNKNOWN_ERROR;
-      }
-      return OK;
-    }
-
-  protected:
-    Camera()          { }
-    virtual ~Camera() { }
-
-  private:
-    Camera(const Camera&) = delete;
-    Camera& operator=(const Camera&) = delete;
-  };
-
-  class CameraParameters final
-  {
-  public:
-    static const char KEY_PREVIEW_SIZE[];
-    static const char KEY_SUPPORTED_PREVIEW_SIZES[];
-    static const char KEY_PREVIEW_FPS_RANGE[];
-    static const char KEY_SUPPORTED_PREVIEW_FPS_RANGE[];
-    static const char KEY_PREVIEW_FORMAT[];
-    static const char KEY_SUPPORTED_PREVIEW_FORMATS[];
-    static const char KEY_PREVIEW_FRAME_RATE[];
-    static const char KEY_SUPPORTED_PREVIEW_FRAME_RATES[];
-    static const char KEY_PICTURE_SIZE[];
-    static const char KEY_SUPPORTED_PICTURE_SIZES[];
-    static const char KEY_PICTURE_FORMAT[];
-    static const char KEY_SUPPORTED_PICTURE_FORMATS[];
-    static const char KEY_JPEG_THUMBNAIL_WIDTH[];
-    static const char KEY_JPEG_THUMBNAIL_HEIGHT[];
-    static const char KEY_SUPPORTED_JPEG_THUMBNAIL_SIZES[];
-    static const char KEY_JPEG_THUMBNAIL_QUALITY[];
-    static const char KEY_JPEG_QUALITY[];
-    static const char KEY_ROTATION[];
-    static const char KEY_GPS_LATITUDE[];
-    static const char KEY_GPS_LONGITUDE[];
-    static const char KEY_GPS_ALTITUDE[];
-    static const char KEY_GPS_TIMESTAMP[];
-    static const char KEY_GPS_PROCESSING_METHOD[];
-    static const char KEY_WHITE_BALANCE[];
-    static const char KEY_SUPPORTED_WHITE_BALANCE[];
-    static const char KEY_EFFECT[];
-    static const char KEY_SUPPORTED_EFFECTS[];
-    static const char KEY_ANTIBANDING[];
-    static const char KEY_SUPPORTED_ANTIBANDING[];
-    static const char KEY_SCENE_MODE[];
-    static const char KEY_SUPPORTED_SCENE_MODES[];
-    static const char KEY_FLASH_MODE[];
-    static const char KEY_SUPPORTED_FLASH_MODES[];
-    static const char KEY_FOCUS_MODE[];
-    static const char KEY_SUPPORTED_FOCUS_MODES[];
-    static const char KEY_MAX_NUM_FOCUS_AREAS[];
-    static const char KEY_FOCUS_AREAS[];
-    static const char KEY_FOCAL_LENGTH[];
-    static const char KEY_HORIZONTAL_VIEW_ANGLE[];
-    static const char KEY_VERTICAL_VIEW_ANGLE[];
-    static const char KEY_EXPOSURE_COMPENSATION[];
-    static const char KEY_MAX_EXPOSURE_COMPENSATION[];
-    static const char KEY_MIN_EXPOSURE_COMPENSATION[];
-    static const char KEY_EXPOSURE_COMPENSATION_STEP[];
-    static const char KEY_AUTO_EXPOSURE_LOCK[];
-    static const char KEY_AUTO_EXPOSURE_LOCK_SUPPORTED[];
-    static const char KEY_AUTO_WHITEBALANCE_LOCK[];
-    static const char KEY_AUTO_WHITEBALANCE_LOCK_SUPPORTED[];
-    static const char KEY_MAX_NUM_METERING_AREAS[];
-    static const char KEY_METERING_AREAS[];
-    static const char KEY_ZOOM[];
-    static const char KEY_MAX_ZOOM[];
-    static const char KEY_ZOOM_RATIOS[];
-    static const char KEY_ZOOM_SUPPORTED[];
-    static const char KEY_SMOOTH_ZOOM_SUPPORTED[];
-    static const char KEY_FOCUS_DISTANCES[];
-    static const char KEY_VIDEO_SIZE[];
-    static const char KEY_SUPPORTED_VIDEO_SIZES[];
-    static const char KEY_MAX_NUM_DETECTED_FACES_HW[];
-    static const char KEY_MAX_NUM_DETECTED_FACES_SW[];
-    static const char KEY_PREFERRED_PREVIEW_SIZE_FOR_VIDEO[];
-    static const char KEY_VIDEO_FRAME_FORMAT[];
-    static const char KEY_RECORDING_HINT[];
-    static const char KEY_VIDEO_SNAPSHOT_SUPPORTED[];
-    static const char KEY_VIDEO_STABILIZATION[];
-    static const char KEY_VIDEO_STABILIZATION_SUPPORTED[];
-    static const char KEY_LIGHTFX[];
-  };
-
-  class MediaProfiles final
-  {
-  public:
-    static MediaProfiles* getInstance() {
-      if (!sMediaProfiles) {
-        sMediaProfiles = new MediaProfiles();
-      }
-      return sMediaProfiles;
-    }
-
-    bool hasCamcorderProfile(int aCameraId, camcorder_quality aQuality) const {
-      switch (aQuality) {
-        case CAMCORDER_QUALITY_LOW:
-        case CAMCORDER_QUALITY_HIGH:
-        case CAMCORDER_QUALITY_QVGA:
-        case CAMCORDER_QUALITY_VGA:
-          return true;
-        default:
-          break;
-      }
-      return false;
-    }
-
-    int getCamcorderProfileParamByName(const char* aParameter, int aCameraId, camcorder_quality aQuality) const {
-      switch (aQuality) {
-        case CAMCORDER_QUALITY_LOW:
-        case CAMCORDER_QUALITY_QVGA:
-          if (strcmp(aParameter, "vid.width") == 0) {
-            return 320;
-          } else if (strcmp(aParameter, "vid.height") == 0) {
-            return 240;
-          } else if (strcmp(aParameter, "vid.fps") == 0) {
-            return 30;
-          }
-          return 0;
-        case CAMCORDER_QUALITY_HIGH:
-        case CAMCORDER_QUALITY_VGA:
-          if (strcmp(aParameter, "vid.width") == 0) {
-            return 640;
-          } else if (strcmp(aParameter, "vid.height") == 0) {
-            return 480;
-          } else if (strcmp(aParameter, "vid.fps") == 0) {
-            return 30;
-          }
-          return 0;
-        default:
-          break;
-      }
-      return -1;
-    }
-
-  protected:
-    MediaProfiles()          { }
-    virtual ~MediaProfiles() { }
-
-  private:
-    MediaProfiles(const MediaProfiles&) = delete;
-    MediaProfiles& operator=(const MediaProfiles&) = delete;
-
-    static MediaProfiles* sMediaProfiles;
-  };
-}
-
-#endif
deleted file mode 100644
--- a/dom/camera/GonkCameraHwMgr.cpp
+++ /dev/null
@@ -1,520 +0,0 @@
-/*
- * Copyright (C) 2012-2015 Mozilla Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#include "GonkCameraHwMgr.h"
-#include "TestGonkCameraHardware.h"
-
-#ifdef MOZ_WIDGET_GONK
-#include <binder/IPCThreadState.h>
-#include <sys/system_properties.h>
-#include "GonkNativeWindow.h"
-#endif
-
-#include "base/basictypes.h"
-#include "nsDebug.h"
-#include "mozilla/layers/TextureClient.h"
-#include "CameraPreferences.h"
-#include "mozilla/RefPtr.h"
-#if defined(MOZ_WIDGET_GONK) && ANDROID_VERSION >= 21
-#include "GonkBufferQueueProducer.h"
-#endif
-#include "GonkCameraControl.h"
-#include "CameraCommon.h"
-
-using namespace mozilla;
-using namespace mozilla::layers;
-using namespace android;
-
-#ifndef MOZ_WIDGET_GONK
-NS_IMPL_ISUPPORTS0(GonkCameraHardware);
-NS_IMPL_ISUPPORTS0(android::Camera);
-#endif
-
-GonkCameraHardware::GonkCameraHardware(mozilla::nsGonkCameraControl* aTarget, uint32_t aCameraId, const sp<Camera>& aCamera)
-  : mCameraId(aCameraId)
-  , mClosing(false)
-  , mNumFrames(0)
-#ifdef MOZ_WIDGET_GONK
-  , mCamera(aCamera)
-#endif
-  , mTarget(aTarget)
-  , mRawSensorOrientation(0)
-  , mSensorOrientation(0)
-  , mEmulated(false)
-{
-  DOM_CAMERA_LOGT("%s:%d : this=%p (aTarget=%p)\n", __func__, __LINE__, (void*)this, (void*)aTarget);
-}
-
-void
-GonkCameraHardware::OnRateLimitPreview(bool aLimit)
-{
-  ::OnRateLimitPreview(mTarget, aLimit);
-}
-
-#ifdef MOZ_WIDGET_GONK
-void
-GonkCameraHardware::OnNewFrame()
-{
-  if (mClosing) {
-    return;
-  }
-  RefPtr<TextureClient> buffer = mNativeWindow->getCurrentBuffer();
-  if (!buffer) {
-    DOM_CAMERA_LOGE("received null frame");
-    return;
-  }
-  OnNewPreviewFrame(mTarget, buffer);
-}
-
-// Android data callback
-void
-GonkCameraHardware::postData(int32_t aMsgType, const sp<IMemory>& aDataPtr, camera_frame_metadata_t* metadata)
-{
-  if (mClosing) {
-    return;
-  }
-
-  switch (aMsgType) {
-    case CAMERA_MSG_PREVIEW_FRAME:
-      // Do nothing
-      break;
-
-    case CAMERA_MSG_COMPRESSED_IMAGE:
-      if (aDataPtr != nullptr) {
-        OnTakePictureComplete(mTarget, static_cast<uint8_t*>(aDataPtr->pointer()), aDataPtr->size());
-      } else {
-        OnTakePictureError(mTarget);
-      }
-      break;
-
-    case CAMERA_MSG_PREVIEW_METADATA:
-      OnFacesDetected(mTarget, metadata);
-      break;
-
-    default:
-      DOM_CAMERA_LOGE("Unhandled data callback event %d\n", aMsgType);
-      break;
-  }
-}
-
-// Android notify callback
-void
-GonkCameraHardware::notify(int32_t aMsgType, int32_t ext1, int32_t ext2)
-{
-  if (mClosing) {
-    return;
-  }
-
-  switch (aMsgType) {
-    case CAMERA_MSG_FOCUS:
-      OnAutoFocusComplete(mTarget, !!ext1);
-      break;
-
-#if ANDROID_VERSION >= 16
-    case CAMERA_MSG_FOCUS_MOVE:
-      OnAutoFocusMoving(mTarget, !!ext1);
-      break;
-#endif
-
-    case CAMERA_MSG_SHUTTER:
-      OnShutter(mTarget);
-      break;
-
-    case CAMERA_MSG_ERROR:
-      OnSystemError(mTarget, CameraControlListener::kSystemService, ext1, ext2);
-      break;
-
-    default:
-      DOM_CAMERA_LOGE("Unhandled notify callback event %d\n", aMsgType);
-      break;
-  }
-}
-
-void
-GonkCameraHardware::postDataTimestamp(nsecs_t aTimestamp, int32_t aMsgType, const sp<IMemory>& aDataPtr)
-{
-  DOM_CAMERA_LOGI("%s",__func__);
-  if (mClosing) {
-    return;
-  }
-
-  if (mListener.get()) {
-    DOM_CAMERA_LOGI("Listener registered, posting recording frame!");
-    if (!mListener->postDataTimestamp(aTimestamp, aMsgType, aDataPtr)) {
-      DOM_CAMERA_LOGW("Listener unable to process. Drop a recording frame.");
-      mCamera->releaseRecordingFrame(aDataPtr);
-    }
-  } else {
-    DOM_CAMERA_LOGW("No listener was set. Drop a recording frame.");
-    mCamera->releaseRecordingFrame(aDataPtr);
-  }
-}
-#endif
-
-nsresult
-GonkCameraHardware::Init()
-{
-  DOM_CAMERA_LOGT("%s: this=%p\n", __func__, (void* )this);
-
-#ifdef MOZ_WIDGET_GONK
-  CameraInfo info;
-  int rv = Camera::getCameraInfo(mCameraId, &info);
-  if (rv != 0) {
-    DOM_CAMERA_LOGE("%s: failed to get CameraInfo mCameraId %d\n", __func__, mCameraId);
-    return NS_ERROR_NOT_INITIALIZED;
-   }
-
-  mRawSensorOrientation = info.orientation;
-  mSensorOrientation = mRawSensorOrientation;
-
-  /**
-   * Non-V4L2-based camera driver adds extra offset onto picture orientation
-   * set by gecko, so we have to adjust it back.
-   */
-  char propname[PROP_NAME_MAX];
-  char prop[PROP_VALUE_MAX];
-  int offset = 0;
-  snprintf(propname, sizeof(propname), "ro.moz.cam.%d.sensor_offset", mCameraId);
-  if (__system_property_get(propname, prop) > 0) {
-    offset = clamped(atoi(prop), 0, 270);
-    mSensorOrientation += offset;
-    mSensorOrientation %= 360;
-  }
-  DOM_CAMERA_LOGI("Sensor orientation: base=%d, offset=%d, final=%d\n", info.orientation, offset, mSensorOrientation);
-
-  if (__system_property_get("ro.kernel.qemu", prop) > 0 && atoi(prop)) {
-    DOM_CAMERA_LOGI("Using emulated camera\n");
-    mEmulated = true;
-  }
-
-  // Disable shutter sound in android CameraService because gaia camera app will play it
-  mCamera->sendCommand(CAMERA_CMD_ENABLE_SHUTTER_SOUND, 0, 0);
-
-#if ANDROID_VERSION >= 21
-  sp<IGraphicBufferProducer> producer;
-  sp<IGonkGraphicBufferConsumer> consumer;
-  GonkBufferQueue::createBufferQueue(&producer, &consumer);
-  static_cast<GonkBufferQueueProducer*>(producer.get())->setSynchronousMode(false);
-  mNativeWindow = new GonkNativeWindow(consumer, GonkCameraHardware::MIN_UNDEQUEUED_BUFFERS);
-  mCamera->setPreviewTarget(producer);
-#elif ANDROID_VERSION >= 19
-  mNativeWindow = new GonkNativeWindow(GonkCameraHardware::MIN_UNDEQUEUED_BUFFERS);
-  sp<GonkBufferQueue> bq = mNativeWindow->getBufferQueue();
-  bq->setSynchronousMode(false);
-  mCamera->setPreviewTarget(mNativeWindow->getBufferQueue());
-#elif ANDROID_VERSION >= 17
-  mNativeWindow = new GonkNativeWindow(GonkCameraHardware::MIN_UNDEQUEUED_BUFFERS);
-  sp<GonkBufferQueue> bq = mNativeWindow->getBufferQueue();
-  bq->setSynchronousMode(false);
-  mCamera->setPreviewTexture(mNativeWindow->getBufferQueue());
-#else
-  mNativeWindow = new GonkNativeWindow();
-  mCamera->setPreviewTexture(mNativeWindow);
-#endif
-  mNativeWindow->setNewFrameCallback(this);
-  mCamera->setListener(this);
-
-#if ANDROID_VERSION >= 16
-  rv = mCamera->sendCommand(CAMERA_CMD_ENABLE_FOCUS_MOVE_MSG, 1, 0);
-  if (rv != OK) {
-    NS_WARNING("Failed to send command CAMERA_CMD_ENABLE_FOCUS_MOVE_MSG");
-  }
-#endif
-
-#endif
-
-  return NS_OK;
-}
-
-sp<GonkCameraHardware>
-GonkCameraHardware::Connect(mozilla::nsGonkCameraControl* aTarget, uint32_t aCameraId)
-{
-  sp<Camera> camera;
-
-  nsCString test;
-  CameraPreferences::GetPref("camera.control.test.enabled", test);
-
-  if (!test.EqualsASCII("hardware")) {
-#ifdef MOZ_WIDGET_GONK
-#if ANDROID_VERSION >= 18
-    camera = Camera::connect(aCameraId, /* clientPackageName */String16("gonk.camera"), Camera::USE_CALLING_UID);
-#else
-    camera = Camera::connect(aCameraId);
-#endif
-#endif
-
-    if (camera.get() == nullptr) {
-      return nullptr;
-    }
-  }
-
-  sp<GonkCameraHardware> cameraHardware;
-  if (test.EqualsASCII("hardware")) {
-    NS_WARNING("Using test Gonk hardware layer");
-    cameraHardware = new TestGonkCameraHardware(aTarget, aCameraId, camera);
-  } else {
-    cameraHardware = new GonkCameraHardware(aTarget, aCameraId, camera);
-  }
-
-  nsresult rv = cameraHardware->Init();
-  if (NS_FAILED(rv)) {
-    DOM_CAMERA_LOGE("Failed to initialize camera hardware (0x%X)\n", rv);
-    cameraHardware->Close();
-    return nullptr;
-  }
-
-  return cameraHardware;
-}
-
-void
-GonkCameraHardware::Close()
-{
-  DOM_CAMERA_LOGT("%s:%d : this=%p\n", __func__, __LINE__, (void*)this);
-
-  mClosing = true;
-  if (mCamera.get()) {
-    mCamera->stopPreview();
-    mCamera->disconnect();
-  }
-  mCamera.clear();
-#ifdef MOZ_WIDGET_GONK
-  if (mNativeWindow.get()) {
-    mNativeWindow->abandon();
-  }
-  mNativeWindow.clear();
-
-  // Ensure that ICamera's destructor is actually executed
-  IPCThreadState::self()->flushCommands();
-#endif
-}
-
-GonkCameraHardware::~GonkCameraHardware()
-{
-  DOM_CAMERA_LOGT("%s:%d : this=%p\n", __func__, __LINE__, (void*)this);
-  mCamera.clear();
-#ifdef MOZ_WIDGET_GONK
-  mNativeWindow.clear();
-#endif
-}
-
-int
-GonkCameraHardware::GetSensorOrientation(uint32_t aType)
-{
-  DOM_CAMERA_LOGI("%s\n", __func__);
-
-  switch (aType) {
-    case OFFSET_SENSOR_ORIENTATION:
-      return mSensorOrientation;
-
-    case RAW_SENSOR_ORIENTATION:
-      return mRawSensorOrientation;
-
-    default:
-      DOM_CAMERA_LOGE("%s:%d : unknown aType=%d\n", __func__, __LINE__, aType);
-      return 0;
-  }
-}
-
-bool
-GonkCameraHardware::IsEmulated()
-{
-  return mEmulated;
-}
-
-int
-GonkCameraHardware::AutoFocus()
-{
-  DOM_CAMERA_LOGI("%s\n", __func__);
-  if (NS_WARN_IF(mClosing)) {
-    return DEAD_OBJECT;
-  }
-  return mCamera->autoFocus();
-}
-
-int
-GonkCameraHardware::CancelAutoFocus()
-{
-  DOM_CAMERA_LOGI("%s\n", __func__);
-  if (NS_WARN_IF(mClosing)) {
-    return DEAD_OBJECT;
-  }
-  return mCamera->cancelAutoFocus();
-}
-
-int
-GonkCameraHardware::StartFaceDetection()
-{
-  DOM_CAMERA_LOGI("%s\n", __func__);
-  if (NS_WARN_IF(mClosing)) {
-    return DEAD_OBJECT;
-  }
-
-  int rv = INVALID_OPERATION;
-#if ANDROID_VERSION >= 15
-  rv = mCamera->sendCommand(CAMERA_CMD_START_FACE_DETECTION, CAMERA_FACE_DETECTION_HW, 0);
-#endif
-  if (rv != OK) {
-    DOM_CAMERA_LOGE("Start face detection failed with status %d", rv);
-  }
-
-  return rv;
-}
-
-int
-GonkCameraHardware::StopFaceDetection()
-{
-  DOM_CAMERA_LOGI("%s\n", __func__);
-  if (mClosing) {
-    return DEAD_OBJECT;
-  }
-
-  int rv = INVALID_OPERATION;
-#if ANDROID_VERSION >= 15
-  rv = mCamera->sendCommand(CAMERA_CMD_STOP_FACE_DETECTION, 0, 0);
-#endif
-  if (rv != OK) {
-    DOM_CAMERA_LOGE("Stop face detection failed with status %d", rv);
-  }
-
-  return rv;
-}
-
-int
-GonkCameraHardware::TakePicture()
-{
-  if (NS_WARN_IF(mClosing)) {
-    return DEAD_OBJECT;
-  }
-  return mCamera->takePicture(CAMERA_MSG_SHUTTER | CAMERA_MSG_COMPRESSED_IMAGE);
-}
-
-void
-GonkCameraHardware::CancelTakePicture()
-{
-  DOM_CAMERA_LOGW("%s: android::Camera do not provide this capability\n", __func__);
-}
-
-int
-GonkCameraHardware::PushParameters(const GonkCameraParameters& aParams)
-{
-  if (NS_WARN_IF(mClosing)) {
-    return DEAD_OBJECT;
-  }
-  const String8 s = aParams.Flatten();
-  return mCamera->setParameters(s);
-}
-
-nsresult
-GonkCameraHardware::PullParameters(GonkCameraParameters& aParams)
-{
-  if (NS_WARN_IF(mClosing)) {
-    return NS_ERROR_NOT_AVAILABLE;
-  }
-  const String8 s = mCamera->getParameters();
-  return aParams.Unflatten(s);
-}
-
-#ifdef MOZ_WIDGET_GONK
-int
-GonkCameraHardware::PushParameters(const CameraParameters& aParams)
-{
-  if (NS_WARN_IF(mClosing)) {
-    return DEAD_OBJECT;
-  }
-  String8 s = aParams.flatten();
-  return mCamera->setParameters(s);
-}
-
-void
-GonkCameraHardware::PullParameters(CameraParameters& aParams)
-{
-  if (!NS_WARN_IF(mClosing)) {
-    const String8 s = mCamera->getParameters();
-    aParams.unflatten(s);
-  }
-}
-#endif
-
-int
-GonkCameraHardware::StartPreview()
-{
-  DOM_CAMERA_LOGT("%s:%d : this=%p\n", __func__, __LINE__, this);
-  if (NS_WARN_IF(mClosing)) {
-    return DEAD_OBJECT;
-  }
-  return mCamera->startPreview();
-}
-
-void
-GonkCameraHardware::StopPreview()
-{
-  DOM_CAMERA_LOGT("%s:%d : this=%p\n", __func__, __LINE__, this);
-  if (!mClosing) {
-    mCamera->stopPreview();
-  }
-}
-
-int
-GonkCameraHardware::StartRecording()
-{
-  DOM_CAMERA_LOGT("%s:%d : this=%p\n", __func__, __LINE__, this);
-  if (NS_WARN_IF(mClosing)) {
-    return DEAD_OBJECT;
-  }
-
-  int rv = mCamera->startRecording();
-  if (rv != OK) {
-    DOM_CAMERA_LOGE("mHardware->startRecording() failed with status %d", rv);
-  }
-  return rv;
-}
-
-int
-GonkCameraHardware::StopRecording()
-{
-  DOM_CAMERA_LOGT("%s:%d : this=%p\n", __func__, __LINE__, this);
-  if (mClosing) {
-    return DEAD_OBJECT;
-  }
-  mCamera->stopRecording();
-  return OK;
-}
-
-#ifdef MOZ_WIDGET_GONK
-int
-GonkCameraHardware::SetListener(const sp<GonkCameraListener>& aListener)
-{
-  mListener = aListener;
-  return OK;
-}
-
-void
-GonkCameraHardware::ReleaseRecordingFrame(const sp<IMemory>& aFrame)
-{
-  if (!NS_WARN_IF(mClosing)) {
-    mCamera->releaseRecordingFrame(aFrame);
-  }
-}
-#endif
-
-int
-GonkCameraHardware::StoreMetaDataInBuffers(bool aEnabled)
-{
-  if (NS_WARN_IF(mClosing)) {
-    return DEAD_OBJECT;
-  }
-  return mCamera->storeMetaDataInBuffers(aEnabled);
-}
deleted file mode 100644
--- a/dom/camera/GonkCameraHwMgr.h
+++ /dev/null
@@ -1,154 +0,0 @@
-/*
- * Copyright (C) 2012-2014 Mozilla Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#ifndef DOM_CAMERA_GONKCAMERAHWMGR_H
-#define DOM_CAMERA_GONKCAMERAHWMGR_H
-
-#include "GonkCameraControl.h"
-#include "CameraCommon.h"
-#include "GonkCameraParameters.h"
-#include "mozilla/ReentrantMonitor.h"
-
-#ifdef MOZ_WIDGET_GONK
-#include <binder/IMemory.h>
-#include <camera/Camera.h>
-#include <camera/CameraParameters.h>
-#include <utils/threads.h>
-#include "GonkCameraListener.h"
-#include "GonkNativeWindow.h"
-#else
-#include "FallbackCameraPlatform.h"
-#endif
-
-namespace mozilla {
-  class nsGonkCameraControl;
-  class GonkCameraParameters;
-}
-
-namespace android {
-
-class GonkCameraHardware
-#ifdef MOZ_WIDGET_GONK
-  : public GonkNativeWindowNewFrameCallback
-  , public CameraListener
-#else
-  : public nsISupports
-#endif
-{
-#ifndef MOZ_WIDGET_GONK
-  NS_DECL_ISUPPORTS
-#endif
-
-protected:
-  GonkCameraHardware(mozilla::nsGonkCameraControl* aTarget, uint32_t aCameraId, const sp<Camera>& aCamera);
-  virtual ~GonkCameraHardware();
-
-  // Initialize the AOSP camera interface.
-  //
-  // Return values:
-  //  - NS_OK on success;
-  //  - NS_ERROR_NOT_INITIALIZED if the interface could not be initialized.
-  virtual nsresult Init();
-
-public:
-  static sp<GonkCameraHardware> Connect(mozilla::nsGonkCameraControl* aTarget, uint32_t aCameraId);
-  virtual void Close();
-
-  virtual void OnRateLimitPreview(bool aLimit);
-
-#ifdef MOZ_WIDGET_GONK
-  // derived from GonkNativeWindowNewFrameCallback
-  virtual void OnNewFrame() override;
-
-  // derived from CameraListener
-  virtual void notify(int32_t aMsgType, int32_t ext1, int32_t ext2);
-  virtual void postData(int32_t aMsgType, const sp<IMemory>& aDataPtr, camera_frame_metadata_t* metadata);
-  virtual void postDataTimestamp(nsecs_t aTimestamp, int32_t aMsgType, const sp<IMemory>& aDataPtr);
-#endif
-
-  /**
-   * The physical orientation of the camera sensor: 0, 90, 180, or 270.
-   *
-   * For example, suppose a device has a naturally tall screen. The
-   * back-facing camera sensor is mounted in landscape. You are looking at
-   * the screen. If the top side of the camera sensor is aligned with the
-   * right edge of the screen in natural orientation, the value should be
-   * 90. If the top side of a front-facing camera sensor is aligned with the
-   * right of the screen, the value should be 270.
-   *
-   * RAW_SENSOR_ORIENTATION is the uncorrected orientation returned directly
-   * by get_camera_info(); OFFSET_SENSOR_ORIENTATION is the offset adjusted
-   * orientation.
-   */
-  enum {
-    RAW_SENSOR_ORIENTATION,
-    OFFSET_SENSOR_ORIENTATION
-  };
-  virtual int      GetSensorOrientation(uint32_t aType = RAW_SENSOR_ORIENTATION);
-
-  virtual bool     IsEmulated();
-
-  /**
-   * MIN_UNDEQUEUED_BUFFERS has increased to 4 since Android JB. For FFOS, more
-   * than 3 gralloc buffers are necessary between ImageHost and GonkBufferQueue
-   * for consuming preview stream. To keep the stability for older platform, we
-   * set MIN_UNDEQUEUED_BUFFERS to 4 only in Android KK base.
-   * See also bug 988704.
-   */
-  enum { MIN_UNDEQUEUED_BUFFERS = 4};
-
-  virtual int      AutoFocus();
-  virtual int      CancelAutoFocus();
-  virtual int      StartFaceDetection();
-  virtual int      StopFaceDetection();
-  virtual int      TakePicture();
-  virtual void     CancelTakePicture();
-  virtual int      StartPreview();
-  virtual void     StopPreview();
-  virtual int      PushParameters(const mozilla::GonkCameraParameters& aParams);
-  virtual nsresult PullParameters(mozilla::GonkCameraParameters& aParams);
-#ifdef MOZ_WIDGET_GONK
-  virtual int      PushParameters(const CameraParameters& aParams);
-  virtual void     PullParameters(CameraParameters& aParams);
-  virtual int      SetListener(const sp<GonkCameraListener>& aListener);
-  virtual void     ReleaseRecordingFrame(const sp<IMemory>& aFrame);
-#endif
-  virtual int      StartRecording();
-  virtual int      StopRecording();
-  virtual int      StoreMetaDataInBuffers(bool aEnabled);
-
-protected:
-  uint32_t                      mCameraId;
-  bool                          mClosing;
-  uint32_t                      mNumFrames;
-  sp<Camera>                    mCamera;
-  mozilla::nsGonkCameraControl* mTarget;
-#ifdef MOZ_WIDGET_GONK
-  sp<GonkNativeWindow>          mNativeWindow;
-  sp<GonkCameraListener>        mListener;
-#endif
-  int                           mRawSensorOrientation;
-  int                           mSensorOrientation;
-  bool                          mEmulated;
-
-private:
-  GonkCameraHardware(const GonkCameraHardware&) = delete;
-  GonkCameraHardware& operator=(const GonkCameraHardware&) = delete;
-};
-
-} // namespace android
-
-#endif // GONK_IMPL_HW_MGR_H
deleted file mode 100644
--- a/dom/camera/GonkCameraListener.h
+++ /dev/null
@@ -1,37 +0,0 @@
-/*
- * Copyright (C) 2008 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#ifndef GONK_CAMERA_LISTENER_H
-#define GONK_CAMERA_LISTENER_H
-
-#include <utils/Timers.h>
-#include <camera/Camera.h>
-
-namespace android {
-
-// ref-counted object for callbacks
-class GonkCameraListener: virtual public RefBase
-{
-public:
-    virtual void notify(int32_t msgType, int32_t ext1, int32_t ext2) = 0;
-    virtual bool postData(int32_t msgType, const sp<IMemory>& dataPtr,
-                          camera_frame_metadata_t *metadata) = 0;
-    virtual bool postDataTimestamp(nsecs_t timestamp, int32_t msgType, const sp<IMemory>& dataPtr) = 0;
-};
-
-}; // namespace android
-
-#endif
deleted file mode 100644
--- a/dom/camera/GonkCameraManager.cpp
+++ /dev/null
@@ -1,137 +0,0 @@
-/*
- * Copyright (C) 2012-2014 Mozilla Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#include "ICameraControl.h"
-#include "CameraCommon.h"
-#include "GonkCameraControl.h"
-#include "CameraPreferences.h"
-#include "TestGonkCameraControl.h"
-
-#ifdef MOZ_WIDGET_GONK
-#include <camera/Camera.h>
-#else
-#include "FallbackCameraPlatform.h"
-#endif
-
-using namespace mozilla;
-
-// From ICameraControl, gonk-specific management functions
-nsresult
-ICameraControl::GetNumberOfCameras(int32_t& aDeviceCount)
-{
-  aDeviceCount = android::Camera::getNumberOfCameras();
-  return NS_OK;
-}
-
-nsresult
-ICameraControl::GetCameraName(uint32_t aDeviceNum, nsCString& aDeviceName)
-{
-  int32_t count = android::Camera::getNumberOfCameras();
-  int32_t deviceNum = static_cast<int32_t>(aDeviceNum);
-
-  DOM_CAMERA_LOGI("GetCameraName : getNumberOfCameras() returned %d\n", count);
-  if (deviceNum < 0 || deviceNum > count) {
-    DOM_CAMERA_LOGE("GetCameraName : invalid device number (%u)\n", aDeviceNum);
-    return NS_ERROR_INVALID_ARG;
-  }
-
-  android::CameraInfo info;
-  int rv = android::Camera::getCameraInfo(deviceNum, &info);
-  if (rv != 0) {
-    DOM_CAMERA_LOGE("GetCameraName : get_camera_info(%d) failed: %d\n", deviceNum, rv);
-    return NS_ERROR_NOT_AVAILABLE;
-  }
-
-  switch (info.facing) {
-    case CAMERA_FACING_BACK:
-      aDeviceName.AssignLiteral("back");
-      break;
-
-    case CAMERA_FACING_FRONT:
-      aDeviceName.AssignLiteral("front");
-      break;
-
-    default:
-      aDeviceName.AssignLiteral("extra-camera-");
-      aDeviceName.AppendInt(deviceNum);
-      break;
-  }
-  return NS_OK;
-}
-
-nsresult
-ICameraControl::GetListOfCameras(nsTArray<nsString>& aList)
-{
-  int32_t count = android::Camera::getNumberOfCameras();
-  DOM_CAMERA_LOGI("getListOfCameras : getNumberOfCameras() returned %d\n", count);
-  if (count <= 0) {
-    aList.Clear();
-    return NS_OK;
-  }
-
-  // Allocate 2 extra slots to reserve space for 'front' and 'back' cameras
-  // at the front of the array--we will collapse any empty slots below.
-  aList.SetLength(2);
-  uint32_t extraIdx = 2;
-  bool gotFront = false;
-  bool gotBack = false;
-  while (count--) {
-    nsCString cameraName;
-    nsresult result = GetCameraName(count, cameraName);
-    if (result != NS_OK) {
-      continue;
-    }
-
-    // The first camera we find named 'back' gets slot 0; and the first
-    // we find named 'front' gets slot 1.  All others appear after these.
-    if (cameraName.EqualsLiteral("back")) {
-      CopyUTF8toUTF16(cameraName, aList[0]);
-      gotBack = true;
-    } else if (cameraName.EqualsLiteral("front")) {
-      CopyUTF8toUTF16(cameraName, aList[1]);
-      gotFront = true;
-    } else {
-      CopyUTF8toUTF16(cameraName, *aList.InsertElementAt(extraIdx));
-      extraIdx++;
-    }
-  }
-
-  if (!gotFront) {
-    aList.RemoveElementAt(1);
-  }
-
-  if (!gotBack) {
-    aList.RemoveElementAt(0);
-  }
-
-  return NS_OK;
-}
-
-// implementation-specific camera factory
-already_AddRefed<ICameraControl>
-ICameraControl::Create(uint32_t aCameraId)
-{
-  nsCString test;
-  CameraPreferences::GetPref("camera.control.test.enabled", test);
-  RefPtr<nsGonkCameraControl> control;
-  if (test.EqualsASCII("control")) {
-    NS_WARNING("Using test CameraControl layer");
-    control = new TestGonkCameraControl(aCameraId);
-  } else {
-    control = new nsGonkCameraControl(aCameraId);
-  }
-  return control.forget();
-}
deleted file mode 100644
--- a/dom/camera/GonkCameraParameters.cpp
+++ /dev/null
@@ -1,1071 +0,0 @@
-/*
- * Copyright (C) 2013-2015 Mozilla Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#include "GonkCameraParameters.h"
-#include "CameraPreferences.h"
-#include "ICameraControl.h"
-#include "CameraCommon.h"
-#include "mozilla/Hal.h"
-#include "nsDataHashtable.h"
-#include "nsPrintfCString.h"
-
-using namespace mozilla;
-using namespace android;
-
-/* static */ bool
-GonkCameraParameters::IsLowMemoryPlatform()
-{
-  bool testIsLowMem = false;
-  CameraPreferences::GetPref("camera.control.test.is_low_memory", testIsLowMem);
-  if (testIsLowMem) {
-    NS_WARNING("Forcing low-memory platform camera preferences");
-    return true;
-  }
-
-  uint32_t lowMemoryThresholdBytes = 0;
-  CameraPreferences::GetPref("camera.control.low_memory_thresholdMB",
-                             lowMemoryThresholdBytes);
-  lowMemoryThresholdBytes *= 1024 * 1024;
-  if (lowMemoryThresholdBytes) {
-    uint32_t totalMemoryBytes = hal::GetTotalSystemMemory();
-    if (totalMemoryBytes < lowMemoryThresholdBytes) {
-      DOM_CAMERA_LOGI("Low-memory platform with %d bytes of RAM (threshold: <%d bytes)\n",
-        totalMemoryBytes, lowMemoryThresholdBytes);
-      return true;
-    }
-  }
-
-  return false;
-}
-
-const char*
-GonkCameraParameters::FindVendorSpecificKey(const char* aPotentialKeys[],
-                                            size_t aPotentialKeyCount)
-{
-  const char* val;
-
-  for (size_t i = 0; i < aPotentialKeyCount; ++i) {
-    GetImpl(aPotentialKeys[i], val);
-    if (val) {
-      // We received a value (potentially an empty-string one),
-      // which indicates that this key exists.
-      return aPotentialKeys[i];
-    }
-  }
-
-  return nullptr;
-}
-
-String8
-GonkCameraParameters::Flatten() const
-{
-  MutexAutoLock lock(mLock);
-  nsCString data;
-  for (auto iter = mParams.ConstIter(); !iter.Done(); iter.Next()) {
-    if (!data.IsEmpty()) {
-      data.Append(';');
-    }
-    data.Append(iter.Key());
-    data.Append('=');
-    data.Append(*iter.UserData());
-  }
-  return String8(data.Data());
-}
-
-nsresult
-GonkCameraParameters::Unflatten(const String8& aFlatParameters)
-{
-  MutexAutoLock lock(mLock);
-  mParams.Clear();
-
-  const char* data = aFlatParameters.string();
-  while (data && *data) {
-    const char* pos = strchr(data, '=');
-    if (!pos) {
-      break;
-    }
-
-    nsDependentCSubstring key(data, pos - data);
-    data = pos + 1;
-
-    nsCString* value;
-    pos = strchr(data, ';');
-    if (pos) {
-      value = new nsCString(data, pos - data);
-      data = pos + 1;
-    } else {
-      value = new nsCString(data);
-      data = nullptr;
-    }
-
-    mParams.Put(key, value);
-  }
-
-  if (mInitialized) {
-    return NS_OK;
-  }
-
-  // We call Initialize() once when the parameter set is first loaded,
-  // to set up any constant values this class requires internally,
-  // e.g. the exposure compensation step and limits.
-  return Initialize();
-}
-
-const char*
-GonkCameraParameters::GetTextKey(uint32_t aKey)
-{
-  switch (aKey) {
-    case CAMERA_PARAM_PREVIEWSIZE:
-      return CameraParameters::KEY_PREVIEW_SIZE;
-    case CAMERA_PARAM_PREVIEWFORMAT:
-      return CameraParameters::KEY_PREVIEW_FORMAT;
-    case CAMERA_PARAM_PREVIEWFRAMERATE:
-      return CameraParameters::KEY_PREVIEW_FRAME_RATE;
-    case CAMERA_PARAM_EFFECT:
-      return CameraParameters::KEY_EFFECT;
-    case CAMERA_PARAM_WHITEBALANCE:
-      return CameraParameters::KEY_WHITE_BALANCE;
-    case CAMERA_PARAM_SCENEMODE:
-      return CameraParameters::KEY_SCENE_MODE;
-    case CAMERA_PARAM_FLASHMODE:
-      return CameraParameters::KEY_FLASH_MODE;
-    case CAMERA_PARAM_FOCUSMODE:
-      return CameraParameters::KEY_FOCUS_MODE;
-    case CAMERA_PARAM_ZOOM:
-      return CameraParameters::KEY_ZOOM;
-    case CAMERA_PARAM_METERINGAREAS:
-      return CameraParameters::KEY_METERING_AREAS;
-    case CAMERA_PARAM_FOCUSAREAS:
-      return CameraParameters::KEY_FOCUS_AREAS;
-    case CAMERA_PARAM_FOCALLENGTH:
-      return CameraParameters::KEY_FOCAL_LENGTH;
-    case CAMERA_PARAM_FOCUSDISTANCENEAR:
-      return CameraParameters::KEY_FOCUS_DISTANCES;
-    case CAMERA_PARAM_FOCUSDISTANCEOPTIMUM:
-      return CameraParameters::KEY_FOCUS_DISTANCES;
-    case CAMERA_PARAM_FOCUSDISTANCEFAR:
-      return CameraParameters::KEY_FOCUS_DISTANCES;
-    case CAMERA_PARAM_EXPOSURECOMPENSATION:
-      return CameraParameters::KEY_EXPOSURE_COMPENSATION;
-    case CAMERA_PARAM_THUMBNAILQUALITY:
-      return CameraParameters::KEY_JPEG_THUMBNAIL_QUALITY;
-    case CAMERA_PARAM_PICTURE_SIZE:
-      return CameraParameters::KEY_PICTURE_SIZE;
-    case CAMERA_PARAM_PICTURE_FILEFORMAT:
-      return CameraParameters::KEY_PICTURE_FORMAT;
-    case CAMERA_PARAM_PICTURE_ROTATION:
-      return CameraParameters::KEY_ROTATION;
-    case CAMERA_PARAM_PICTURE_DATETIME:
-      // Not every platform defines a CameraParameters::EXIF_DATETIME;
-      // for those that don't, we use the raw string key, and if the platform
-      // doesn't support it, it will be ignored.
-      //
-      // See bug 832494.
-      return "exif-datetime";
-    case CAMERA_PARAM_VIDEOSIZE:
-      return CameraParameters::KEY_VIDEO_SIZE;
-    case CAMERA_PARAM_ISOMODE:
-      if (!mVendorSpecificKeyIsoMode) {
-        const char* isoModeKeys[] = {
-          "iso",
-          "sony-iso"
-        };
-        mVendorSpecificKeyIsoMode =
-          FindVendorSpecificKey(isoModeKeys, MOZ_ARRAY_LENGTH(isoModeKeys));
-      }
-      return mVendorSpecificKeyIsoMode;
-    case CAMERA_PARAM_LUMINANCE:
-      return "luminance-condition";
-    case CAMERA_PARAM_SCENEMODE_HDR_RETURNNORMALPICTURE:
-      // Not every platform defines CameraParameters::QC_HDR_NEED_1X;
-      // for those that don't, we use the raw string key.
-      return "hdr-need-1x";
-    case CAMERA_PARAM_RECORDINGHINT:
-      return CameraParameters::KEY_RECORDING_HINT;
-    case CAMERA_PARAM_PICTURE_QUALITY:
-      return CameraParameters::KEY_JPEG_QUALITY;
-    case CAMERA_PARAM_PREFERRED_PREVIEWSIZE_FOR_VIDEO:
-      return CameraParameters::KEY_PREFERRED_PREVIEW_SIZE_FOR_VIDEO;
-    case CAMERA_PARAM_METERINGMODE:
-      // Not every platform defines CameraParameters::AUTO_EXPOSURE.
-      return "auto-exposure";
-
-    case CAMERA_PARAM_SUPPORTED_PREVIEWSIZES:
-      return CameraParameters::KEY_SUPPORTED_PREVIEW_SIZES;
-    case CAMERA_PARAM_SUPPORTED_PICTURESIZES:
-      return CameraParameters::KEY_SUPPORTED_PICTURE_SIZES;
-    case CAMERA_PARAM_SUPPORTED_VIDEOSIZES:
-      return CameraParameters::KEY_SUPPORTED_VIDEO_SIZES;
-    case CAMERA_PARAM_SUPPORTED_PICTUREFORMATS:
-      return CameraParameters::KEY_SUPPORTED_PICTURE_FORMATS;
-    case CAMERA_PARAM_SUPPORTED_WHITEBALANCES:
-      return CameraParameters::KEY_SUPPORTED_WHITE_BALANCE;
-    case CAMERA_PARAM_SUPPORTED_SCENEMODES:
-      return CameraParameters::KEY_SUPPORTED_SCENE_MODES;
-    case CAMERA_PARAM_SUPPORTED_EFFECTS:
-      return CameraParameters::KEY_SUPPORTED_EFFECTS;
-    case CAMERA_PARAM_SUPPORTED_FLASHMODES:
-      return CameraParameters::KEY_SUPPORTED_FLASH_MODES;
-    case CAMERA_PARAM_SUPPORTED_FOCUSMODES:
-      return CameraParameters::KEY_SUPPORTED_FOCUS_MODES;
-    case CAMERA_PARAM_SUPPORTED_MAXFOCUSAREAS:
-      return CameraParameters::KEY_MAX_NUM_FOCUS_AREAS;
-    case CAMERA_PARAM_SUPPORTED_MAXMETERINGAREAS:
-      return CameraParameters::KEY_MAX_NUM_METERING_AREAS;
-    case CAMERA_PARAM_SUPPORTED_MINEXPOSURECOMPENSATION:
-      return CameraParameters::KEY_MIN_EXPOSURE_COMPENSATION;
-    case CAMERA_PARAM_SUPPORTED_MAXEXPOSURECOMPENSATION:
-      return CameraParameters::KEY_MAX_EXPOSURE_COMPENSATION;
-    case CAMERA_PARAM_SUPPORTED_EXPOSURECOMPENSATIONSTEP:
-      return CameraParameters::KEY_EXPOSURE_COMPENSATION_STEP;
-    case CAMERA_PARAM_SUPPORTED_ZOOM:
-      return CameraParameters::KEY_ZOOM_SUPPORTED;
-    case CAMERA_PARAM_SUPPORTED_ZOOMRATIOS:
-      return CameraParameters::KEY_ZOOM_RATIOS;
-    case CAMERA_PARAM_SUPPORTED_MAXDETECTEDFACES:
-      return CameraParameters::KEY_MAX_NUM_DETECTED_FACES_HW;
-    case CAMERA_PARAM_SUPPORTED_JPEG_THUMBNAIL_SIZES:
-      return CameraParameters::KEY_SUPPORTED_JPEG_THUMBNAIL_SIZES;
-    case CAMERA_PARAM_SUPPORTED_ISOMODES:
-      if (!mVendorSpecificKeySupportedIsoModes) {
-        const char* supportedIsoModesKeys[] = {
-          "iso-values",
-          "sony-iso-values"
-        };
-        mVendorSpecificKeySupportedIsoModes =
-          FindVendorSpecificKey(supportedIsoModesKeys,
-                                MOZ_ARRAY_LENGTH(supportedIsoModesKeys));
-      }
-      return mVendorSpecificKeySupportedIsoModes;
-    case CAMERA_PARAM_SUPPORTED_METERINGMODES:
-      // Not every platform defines CameraParameters::SUPPORTED_AUTO_EXPOSURE.
-      return "auto-exposure-values";
-    default:
-      DOM_CAMERA_LOGE("Unhandled camera parameter value %u\n", aKey);
-      return nullptr;
-  }
-}
-
-GonkCameraParameters::GonkCameraParameters()
-  : mLock("mozilla::camera::GonkCameraParameters")
-  , mDirty(false)
-  , mInitialized(false)
-  , mExposureCompensationStep(0.0)
-  , mVendorSpecificKeyIsoMode(nullptr)
-  , mVendorSpecificKeySupportedIsoModes(nullptr)
-{
-  MOZ_COUNT_CTOR(GonkCameraParameters);
-}
-
-GonkCameraParameters::~GonkCameraParameters()
-{
-  MOZ_COUNT_DTOR(GonkCameraParameters);
-  mIsoModeMap.Clear();
-}
-
-nsresult
-GonkCameraParameters::MapIsoToGonk(const nsAString& aIso, nsACString& aIsoOut)
-{
-  nsCString* s;
-  if (mIsoModeMap.Get(aIso, &s)) {
-    if (!s) {
-      DOM_CAMERA_LOGE("ISO mode '%s' maps to null Gonk ISO value\n",
-        NS_LossyConvertUTF16toASCII(aIso).get());
-      return NS_ERROR_FAILURE;
-    }
-
-    aIsoOut = *s;
-    return NS_OK;
-  }
-
-  return NS_ERROR_INVALID_ARG;
-}
-
-nsresult
-GonkCameraParameters::MapIsoFromGonk(const char* aIso, nsAString& aIsoOut)
-{
-  if (!aIso) {
-    return NS_ERROR_NOT_AVAILABLE;
-  }
-
-  if (strcmp(aIso, "ISO_HJR") == 0) {
-    aIsoOut.AssignASCII("hjr");
-  } else if (strcmp(aIso, "auto") == 0) {
-    aIsoOut.AssignASCII("auto");
-  } else {
-    unsigned int iso;
-    char ignored;
-    // Some camera libraries return ISO modes as "ISO100", others as "100".
-    if (sscanf(aIso, "ISO%u%c", &iso, &ignored) != 1 &&
-        sscanf(aIso, "%u%c", &iso, &ignored) != 1) {
-      return NS_ERROR_INVALID_ARG;
-    }
-    aIsoOut.Truncate(0);
-    aIsoOut.AppendInt(iso);
-  }
-
-  return NS_OK;
-}
-
-// Any members that need to be initialized on the first parameter pull
-// need to get handled in here.
-nsresult
-GonkCameraParameters::Initialize()
-{
-  nsresult rv;
-
-  rv = GetImpl(CameraParameters::KEY_EXPOSURE_COMPENSATION_STEP, mExposureCompensationStep);
-  if (NS_FAILED(rv)) {
-    NS_WARNING("Failed to initialize exposure compensation step size");
-    mExposureCompensationStep = 0.0;
-  }
-  rv = GetImpl(CameraParameters::KEY_MIN_EXPOSURE_COMPENSATION, mExposureCompensationMinIndex);
-  if (NS_FAILED(rv)) {
-    NS_WARNING("Failed to initialize minimum exposure compensation index");
-    mExposureCompensationMinIndex = 0;
-  }
-  rv = GetImpl(CameraParameters::KEY_MAX_EXPOSURE_COMPENSATION, mExposureCompensationMaxIndex);
-  if (NS_FAILED(rv)) {
-    NS_WARNING("Failed to initialize maximum exposure compensation index");
-    mExposureCompensationMaxIndex = 0;
-  }
-
-  rv = GetListAsArray(CAMERA_PARAM_SUPPORTED_ZOOMRATIOS, mZoomRatios);
-  if (NS_FAILED(rv)) {
-    // zoom is not supported
-    mZoomRatios.Clear();
-  }
-  for (uint32_t i = 1; i < mZoomRatios.Length(); ++i) {
-    // Make sure the camera gave us a properly sorted zoom ratio list!
-    if (mZoomRatios[i] < mZoomRatios[i - 1]) {
-      NS_WARNING("Zoom ratios list is out of order, discarding");
-      DOM_CAMERA_LOGE("zoom[%d]=%fx < zoom[%d]=%fx is out of order\n",
-        i, mZoomRatios[i] / 100.0, i - 1, mZoomRatios[i - 1] / 100.0);
-      mZoomRatios.Clear();
-      break;
-    }
-  }
-  if (mZoomRatios.Length() == 0) {
-    // Always report that we support at least 1.0x zoom.
-    *mZoomRatios.AppendElement() = 100;
-  }
-
-  // The return code from GetListAsArray() doesn't matter. If it fails,
-  // the isoModes array will be empty, and the subsequent loop won't
-  // execute.
-  nsString s;
-  nsTArray<nsCString> isoModes;
-  GetListAsArray(CAMERA_PARAM_SUPPORTED_ISOMODES, isoModes);
-  for (nsTArray<nsCString>::index_type i = 0; i < isoModes.Length(); ++i) {
-    rv = MapIsoFromGonk(isoModes[i].get(), s);
-    if (NS_FAILED(rv)) {
-      DOM_CAMERA_LOGW("Unrecognized ISO mode value '%s'\n", isoModes[i].get());
-      continue;
-    }
-    *mIsoModes.AppendElement() = s;
-    mIsoModeMap.Put(s, new nsCString(isoModes[i]));
-  }
-
-  GetListAsArray(CAMERA_PARAM_SUPPORTED_SCENEMODES, mSceneModes);
-  if (IsLowMemoryPlatform()) {
-    bool hdrRemoved = false;
-    while (mSceneModes.RemoveElement(NS_LITERAL_STRING("hdr"))) {
-      hdrRemoved = true;
-    }
-    if (hdrRemoved) {
-      DOM_CAMERA_LOGI("Disabling HDR support due to low memory\n");
-    }
-  }
-
-  // Some platforms have strange duplicate metering mode values.
-  // We filter any out here.
-  nsDataHashtable<nsStringHashKey, bool> uniqueModes;
-  GetListAsArray(CAMERA_PARAM_SUPPORTED_METERINGMODES, mMeteringModes);
-  nsTArray<nsCString>::index_type i = mMeteringModes.Length();
-  while (i > 0) {
-    --i;
-    if (!uniqueModes.Get(mMeteringModes[i])) {
-      uniqueModes.Put(mMeteringModes[i], true);
-    } else {
-      DOM_CAMERA_LOGW("Dropped duplicate metering mode '%s' (index=%u)\n",
-        NS_ConvertUTF16toUTF8(mMeteringModes[i]).get(), i);
-      mMeteringModes.RemoveElementAt(i);
-    }
-  }
-  
-  mInitialized = true;
-  return NS_OK;
-}
-
-// Handle nsAStrings
-nsresult
-GonkCameraParameters::SetTranslated(uint32_t aKey, const nsAString& aValue)
-{
-  switch (aKey) {
-    case CAMERA_PARAM_ISOMODE:
-      {
-        nsAutoCString v;
-        nsresult rv = MapIsoToGonk(aValue, v);
-        if (NS_FAILED(rv)) {
-          return rv;
-        }
-        return SetImpl(aKey, v.get());
-      }
-
-    case CAMERA_PARAM_SCENEMODE:
-      if (mSceneModes.IndexOf(aValue) == nsTArray<nsString>::NoIndex) {
-        return NS_ERROR_INVALID_ARG;
-      }
-      // fallthrough
-
-    default:
-      return SetImpl(aKey, NS_ConvertUTF16toUTF8(aValue).get());
-  }
-}
-
-nsresult
-GonkCameraParameters::GetTranslated(uint32_t aKey, nsAString& aValue)
-{
-  const char* val;
-  nsresult rv = GetImpl(aKey, val);
-  if (NS_FAILED(rv)) {
-    return rv;
-  }
-  if (val) {
-    if (aKey == CAMERA_PARAM_ISOMODE) {
-      rv = MapIsoFromGonk(val, aValue);
-    } else {
-      aValue.AssignASCII(val);
-    }
-  } else {
-    aValue.Truncate(0);
-  }
-  return rv;
-}
-
-// Handle ICameraControl::Sizes
-nsresult
-GonkCameraParameters::SetTranslated(uint32_t aKey, const ICameraControl::Size& aSize)
-{
-  if (aSize.width > INT_MAX || aSize.height > INT_MAX) {
-    // AOSP can only handle signed ints.
-    DOM_CAMERA_LOGE("Camera parameter aKey=%d out of bounds (width=%u, height=%u)\n",
-      aKey, aSize.width, aSize.height);
-    return NS_ERROR_INVALID_ARG;
-  }
-
-  nsresult rv;
-
-  switch (aKey) {
-    case CAMERA_PARAM_THUMBNAILSIZE:
-      // This is a special case--for some reason the thumbnail size
-      // is accessed as two separate values instead of a tuple.
-      // XXXmikeh - make this restore the original values on error
-      rv = SetImpl(CameraParameters::KEY_JPEG_THUMBNAIL_WIDTH, static_cast<int>(aSize.width));
-      if (NS_SUCCEEDED(rv)) {
-        rv = SetImpl(CameraParameters::KEY_JPEG_THUMBNAIL_HEIGHT, static_cast<int>(aSize.height));
-      }
-      break;
-
-    case CAMERA_PARAM_VIDEOSIZE:
-      // "record-size" is probably deprecated in later ICS;
-      // might need to set "video-size" instead of "record-size";
-      // for the time being, set both. See bug 795332.
-      rv = SetImpl("record-size", nsPrintfCString("%ux%u", aSize.width, aSize.height).get());
-      if (NS_FAILED(rv)) {
-        break;
-      }
-      // intentional fallthrough
-
-    default:
-      rv = SetImpl(aKey, nsPrintfCString("%ux%u", aSize.width, aSize.height).get());
-      break;
-  }
-
-  if (NS_FAILED(rv)) {
-    DOM_CAMERA_LOGE("Camera parameter aKey=%d failed to set (0x%x)\n", aKey, rv);
-  }
-  return rv;
-}
-
-nsresult
-GonkCameraParameters::GetTranslated(uint32_t aKey, ICameraControl::Size& aSize)
-{
-  nsresult rv;
-
-  if (aKey == CAMERA_PARAM_THUMBNAILSIZE) {
-    int width;
-    int height;
-
-    rv = GetImpl(CameraParameters::KEY_JPEG_THUMBNAIL_WIDTH, width);
-    if (NS_FAILED(rv)) {
-      return rv;
-    }
-    if (width < 0) {
-      return NS_ERROR_NOT_AVAILABLE;
-    }
-    rv = GetImpl(CameraParameters::KEY_JPEG_THUMBNAIL_HEIGHT, height);
-    if (NS_FAILED(rv)) {
-      return rv;
-    }
-    if (height < 0) {
-      return NS_ERROR_NOT_AVAILABLE;
-    }
-
-    aSize.width = static_cast<uint32_t>(width);
-    aSize.height = static_cast<uint32_t>(height);
-    return NS_OK;
-  }
-
-  const char* value;
-  rv = GetImpl(aKey, value);
-  if (NS_FAILED(rv)) {
-    return rv;
-  }
-  if (!value || *value == '\0') {
-    DOM_CAMERA_LOGW("Camera parameter aKey=%d not available\n", aKey);
-    return NS_ERROR_NOT_AVAILABLE;
-  }
-  if (sscanf(value, "%ux%u", &aSize.width, &aSize.height) != 2) {
-    DOM_CAMERA_LOGE("Camera parameter aKey=%d size tuple '%s' is invalid\n", aKey, value);
-    return NS_ERROR_NOT_AVAILABLE;
-  }
-
-  return NS_OK;
-}
-
-// Handle arrays of ICameraControl::Regions
-nsresult
-GonkCameraParameters::SetTranslated(uint32_t aKey, const nsTArray<ICameraControl::Region>& aRegions)
-{
-  uint32_t length = aRegions.Length();
-
-  if (!length) {
-    // This tells the camera driver to revert to automatic regioning.
-    return SetImpl(aKey, "(0,0,0,0,0)");
-  }
-
-  nsCString s;
-
-  for (uint32_t i = 0; i < length; ++i) {
-    const ICameraControl::Region* r = &aRegions[i];
-    s.AppendPrintf("(%d,%d,%d,%d,%d),", r->left, r->top, r->right, r->bottom, r->weight);
-  }
-
-  // remove the trailing comma
-  s.Trim(",", false, true, true);
-
-  return SetImpl(aKey, s.get());
-}
-
-nsresult
-GonkCameraParameters::GetTranslated(uint32_t aKey, nsTArray<ICameraControl::Region>& aRegions)
-{
-  aRegions.Clear();
-
-  const char* value;
-  nsresult rv = GetImpl(aKey, value);
-  if (NS_FAILED(rv)) {
-    return rv;
-  }
-  if (!value || *value == '\0') {
-    DOM_CAMERA_LOGW("Camera parameter aKey=%d not available\n", aKey);
-    return NS_ERROR_NOT_AVAILABLE;
-  }
-
-  const char* p = value;
-  uint32_t count = 1;
-
-  // count the number of regions in the string
-  while ((p = strstr(p, "),("))) {
-    ++count;
-    p += 3;
-  }
-
-  aRegions.SetCapacity(count);
-  ICameraControl::Region* r;
-
-  // parse all of the region sets
-  uint32_t i;
-  for (i = 0, p = value; p && i < count; ++i, p = strchr(p + 1, '(')) {
-    r = aRegions.AppendElement();
-    if (sscanf(p, "(%d,%d,%d,%d,%u)", &r->left, &r->top, &r->right, &r->bottom, &r->weight) != 5) {
-      DOM_CAMERA_LOGE("Camera parameter aKey=%d region tuple has bad format: '%s'\n", aKey, p);
-      aRegions.Clear();
-      return NS_ERROR_NOT_AVAILABLE;
-    }
-  }
-
-  return NS_OK;
-}
-
-// Handle ICameraControl::Positions
-nsresult
-GonkCameraParameters::SetTranslated(uint32_t aKey, const ICameraControl::Position& aPosition)
-{
-  MOZ_ASSERT(aKey == CAMERA_PARAM_PICTURE_LOCATION);
-
-  // Add any specified location information -- we don't care if these fail.
-  if (!isnan(aPosition.latitude) &&
-      !isnan(aPosition.longitude) &&
-      !isnan(aPosition.altitude) &&
-      !isnan(aPosition.timestamp)) {
-    DOM_CAMERA_LOGI("setting picture gps coordinates to (%lf, %lf, %lf, %lf)\n",
-      aPosition.latitude, aPosition.longitude, aPosition.altitude, aPosition.timestamp);
-    SetImpl(CameraParameters::KEY_GPS_LATITUDE, aPosition.latitude);
-    SetImpl(CameraParameters::KEY_GPS_LONGITUDE, aPosition.longitude);
-    SetImpl(CameraParameters::KEY_GPS_ALTITUDE, aPosition.altitude);
-    SetImpl(CameraParameters::KEY_GPS_TIMESTAMP, aPosition.timestamp);
-    SetImpl(CameraParameters::KEY_GPS_PROCESSING_METHOD, "UNKNOWN");
-  } else {
-    DOM_CAMERA_LOGI("clear incomplete gps information\n");
-    ClearImpl(CameraParameters::KEY_GPS_LATITUDE);
-    ClearImpl(CameraParameters::KEY_GPS_LONGITUDE);
-    ClearImpl(CameraParameters::KEY_GPS_ALTITUDE);
-    ClearImpl(CameraParameters::KEY_GPS_TIMESTAMP);
-    ClearImpl(CameraParameters::KEY_GPS_PROCESSING_METHOD);
-  }
-
-  return NS_OK;
-}
-
-// Handle int64_ts
-nsresult
-GonkCameraParameters::SetTranslated(uint32_t aKey, const int64_t& aValue)
-{
-  switch (aKey) {
-    case CAMERA_PARAM_PICTURE_DATETIME:
-      {
-        // Add the non-GPS timestamp.  The EXIF date/time field is formatted as
-        // "YYYY:MM:DD HH:MM:SS", without room for a time-zone; as such, the time
-        // is meant to be stored as a local time.  Since we are given seconds from
-        // Epoch GMT, we use localtime_r() to handle the conversion.
-        time_t time = aValue;
-        if (time != aValue) {
-          DOM_CAMERA_LOGE("picture date/time '%llu' is too far in the future\n", aValue);
-          return NS_ERROR_INVALID_ARG;
-        }
-
-        struct tm t;
-        if (!localtime_r(&time, &t)) {
-          DOM_CAMERA_LOGE("picture date/time couldn't be converted to local time: (%d) %s\n", errno, strerror(errno));
-          return NS_ERROR_FAILURE;
-        }
-
-        char dateTime[20];
-        if (!strftime(dateTime, sizeof(dateTime), "%Y:%m:%d %T", &t)) {
-          DOM_CAMERA_LOGE("picture date/time couldn't be converted to string\n");
-          return NS_ERROR_FAILURE;
-        }
-
-        DOM_CAMERA_LOGI("setting picture date/time to %s\n", dateTime);
-
-        return SetImpl(CAMERA_PARAM_PICTURE_DATETIME, dateTime);
-      }
-
-    case CAMERA_PARAM_ISOMODE:
-      {
-        if (aValue > INT32_MAX) {
-          DOM_CAMERA_LOGW("Can't set ISO mode = %lld, too big\n", aValue);
-          return NS_ERROR_INVALID_ARG;
-        }
-
-        nsString s;
-        s.AppendInt(aValue);
-        return SetTranslated(CAMERA_PARAM_ISOMODE, s);
-      }
-  }
-
-  // You can't actually pass 64-bit parameters to Gonk. :(
-  int32_t v = static_cast<int32_t>(aValue);
-  if (static_cast<int64_t>(v) != aValue) {
-    return NS_ERROR_INVALID_ARG;;
-  }
-  return SetImpl(aKey, v);
-}
-
-nsresult
-GonkCameraParameters::GetTranslated(uint32_t aKey, int64_t& aValue)
-{
-  int val;
-  nsresult rv = GetImpl(aKey, val);
-  if (NS_FAILED(rv)) {
-    return rv;
-  }
-  aValue = val;
-  return NS_OK;
-}
-
-// Handle doubles
-nsresult
-GonkCameraParameters::SetTranslated(uint32_t aKey, const double& aValue)
-{
-  int index;
-  int value;
-
-  switch (aKey) {
-    case CAMERA_PARAM_EXPOSURECOMPENSATION:
-      if (mExposureCompensationStep == 0.0) {
-        DOM_CAMERA_LOGE("Exposure compensation not supported, can't set EV=%f\n", aValue);
-        return NS_ERROR_NOT_AVAILABLE;
-      }
-
-      /**
-       * Convert from real value to a Gonk index, round
-       * to the nearest step; index is 1-based.
-       */
-      {
-        double i = round(aValue / mExposureCompensationStep);
-        if (i < mExposureCompensationMinIndex) {
-          index = mExposureCompensationMinIndex;
-        } else if (i > mExposureCompensationMaxIndex) {
-          index = mExposureCompensationMaxIndex;
-        } else {
-          index = i;
-        }
-      }
-      DOM_CAMERA_LOGI("Exposure compensation = %f --> index = %d\n", aValue, index);
-      return SetImpl(CAMERA_PARAM_EXPOSURECOMPENSATION, index);
-
-    case CAMERA_PARAM_ZOOM:
-      {
-        /**
-         * Convert from a real zoom multipler (e.g. 2.5x) to
-         * the index of the nearest supported value.
-         */
-        value = aValue * 100.0;
-
-        if (value <= mZoomRatios[0]) {
-          index = 0;
-        } else if (value >= mZoomRatios.LastElement()) {
-          index = mZoomRatios.Length() - 1;
-        } else {
-          // mZoomRatios is sorted, so we can binary search it
-          int bottom = 0;
-          int top = mZoomRatios.Length() - 1;
-
-          while (top >= bottom) {
-            index = (top + bottom) / 2;
-            if (value == mZoomRatios[index]) {
-              // exact match
-              break;
-            }
-            if (value > mZoomRatios[index] && value < mZoomRatios[index + 1]) {
-              // the specified zoom value lies in this interval
-              break;
-            }
-            if (value > mZoomRatios[index]) {
-              bottom = index + 1;
-            } else {
-              top = index - 1;
-            }
-          }
-        }
-        DOM_CAMERA_LOGI("Zoom = %fx --> index = %d\n", aValue, index);
-      }
-      return SetImpl(CAMERA_PARAM_ZOOM, index);
-
-    case CAMERA_PARAM_PICTURE_QUALITY:
-      {
-        // Convert aValue [0.0..1.0] to nearest index in the range [1..100].
-        index = (aValue + 0.005) * 99.0 + 1.0;
-        if (aValue < 0.0) {
-          index = 1;
-        } else if (aValue > 1.0) {
-          index = 100;
-        }
-        DOM_CAMERA_LOGI("Picture quality = %f --> index = %d\n", aValue, index);
-      }
-      return SetImpl(CAMERA_PARAM_PICTURE_QUALITY, index);
-  }
-
-  return SetImpl(aKey, aValue);
-}
-
-nsresult
-GonkCameraParameters::GetTranslated(uint32_t aKey, double& aValue)
-{
-  double val = 0.0; // initialize to keep the compiler happy [-Wmaybe-uninitialized]
-  int index = 0;
-  double focusDistance[3];
-  const char* s;
-  nsresult rv;
-
-  switch (aKey) {
-    case CAMERA_PARAM_ZOOM:
-      rv = GetImpl(aKey, index);
-      if (NS_SUCCEEDED(rv) && index >= 0) {
-        val = mZoomRatios[index] / 100.0;
-      } else {
-        // return 1x when zooming is not supported
-        val = 1.0;
-        rv = NS_OK;
-      }
-      break;
-
-    /**
-     * The gonk camera parameters API only exposes one focus distance property
-     * that contains "Near,Optimum,Far" distances, in metres, where 'Far' may
-     * be 'Infinity'.
-     */
-    case CAMERA_PARAM_FOCUSDISTANCEFAR:
-      ++index;
-      // intentional fallthrough
-
-    case CAMERA_PARAM_FOCUSDISTANCEOPTIMUM:
-      ++index;
-      // intentional fallthrough
-
-    case CAMERA_PARAM_FOCUSDISTANCENEAR:
-      rv = GetImpl(aKey, s);
-      if (NS_SUCCEEDED(rv)) {
-        if (sscanf(s, "%lf,%lf,%lf", &focusDistance[0], &focusDistance[1], &focusDistance[2]) == 3) {
-          val = focusDistance[index];
-        } else {
-          val = 0.0;
-        }
-      }
-      break;
-
-    case CAMERA_PARAM_EXPOSURECOMPENSATION:
-    case CAMERA_PARAM_SUPPORTED_MINEXPOSURECOMPENSATION:
-    case CAMERA_PARAM_SUPPORTED_MAXEXPOSURECOMPENSATION:
-      if (mExposureCompensationStep == 0.0) {
-        DOM_CAMERA_LOGE("Exposure compensation not supported, can't get EV\n");
-        return NS_ERROR_NOT_AVAILABLE;
-      }
-      rv = GetImpl(aKey, index);
-      if (NS_SUCCEEDED(rv)) {
-        val = index * mExposureCompensationStep;
-        DOM_CAMERA_LOGI("exposure compensation (aKey=%d): index=%d --> EV=%f\n", aKey, index, val);
-      }
-      break;
-
-    case CAMERA_PARAM_PICTURE_QUALITY:
-      // Convert index [1..100] to a quality value [0.0..1.0].
-      rv = GetImpl(aKey, index);
-      if (index < 2) {
-        val = 0.0;
-      } else if (index > 99) {
-        val = 1.0;
-      } else {
-        val = static_cast<double>(index - 1) / 99.0;
-      }
-      DOM_CAMERA_LOGI("index = %d --> picture quality = %f\n", index, val);
-      break;
-
-    default:
-      rv = GetImpl(aKey, val);
-      break;
-  }
-
-  if (NS_SUCCEEDED(rv)) {
-    aValue = val;
-  }
-  return rv;
-}
-
-// Handle ints
-nsresult
-GonkCameraParameters::SetTranslated(uint32_t aKey, const int& aValue)
-{
-  return SetImpl(aKey, aValue);
-}
-
-nsresult
-GonkCameraParameters::GetTranslated(uint32_t aKey, int& aValue)
-{
-  return GetImpl(aKey, aValue);
-}
-
-// Handle uint32_ts -- Gonk only speaks int
-nsresult
-GonkCameraParameters::SetTranslated(uint32_t aKey, const uint32_t& aValue)
-{
-  if (aValue > INT_MAX) {
-    return NS_ERROR_INVALID_ARG;
-  }
-
-  int val = static_cast<int>(aValue);
-  return SetImpl(aKey, val);
-}
-
-nsresult
-GonkCameraParameters::GetTranslated(uint32_t aKey, uint32_t& aValue)
-{
-  int val;
-  nsresult rv = GetImpl(aKey, val);
-  if (NS_FAILED(rv)) {
-    return rv;
-  }
-  if (val < 0) {
-    return NS_ERROR_NOT_AVAILABLE;
-  }
-
-  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", aStart);
-  return NS_ERROR_NOT_AVAILABLE;
-}
-
-nsresult
-ParseItem(const char* aStart, const char* aEnd, nsAString* aItem)
-{
-  if (aEnd) {
-    aItem->AssignASCII(aStart, aEnd - aStart);
-  } else {
-    aItem->AssignASCII(aStart);
-  }
-  return NS_OK;
-}
-
-nsresult
-ParseItem(const char* aStart, const char* aEnd, nsACString* aItem)
-{
-  if (aEnd) {
-    aItem->AssignASCII(aStart, aEnd - aStart);
-  } else {
-    aItem->AssignASCII(aStart);
-  }
-  return NS_OK;
-}
-
-nsresult
-ParseItem(const char* aStart, const char* aEnd, double* aItem)
-{
-  if (sscanf(aStart, "%lf", aItem) == 1) {
-    return NS_OK;
-  }
-
-  return NS_ERROR_NOT_AVAILABLE;
-}
-
-nsresult
-ParseItem(const char* aStart, const char* aEnd, int* aItem)
-{
-  if (sscanf(aStart, "%d", aItem) == 1) {
-    return NS_OK;
-  }
-
-  return NS_ERROR_NOT_AVAILABLE;
-}
-
-template<class T> nsresult
-GonkCameraParameters::GetListAsArray(uint32_t aKey, nsTArray<T>& aArray)
-{
-  const char* p;
-  nsresult rv = GetImpl(aKey, p);
-  if (NS_FAILED(rv)) {
-    return rv;
-  }
-
-  aArray.Clear();
-
-  // If there is no value available, just return the empty array.
-  if (!p) {
-    DOM_CAMERA_LOGI("Camera parameter %d not available (value is null)\n", aKey);
-    return NS_OK;
-  }
-  if (*p == '\0') {
-    DOM_CAMERA_LOGI("Camera parameter %d not available (value is empty string)\n", aKey);
-    return NS_OK;
-  }
-
-  const char* comma;
-
-  while (p) {
-    // nsTArray::AppendElement() is infallible
-    T* v = aArray.AppendElement();
-    comma = strchr(p, ',');
-    if (comma != p) {
-      rv = ParseItem(p, comma, v);
-      if (NS_FAILED(rv)) {
-        aArray.Clear();
-        return rv;
-      }
-      p = comma;
-    }
-    if (p) {
-      ++p;
-    }
-  }
-
-  return NS_OK;
-}
-
-nsresult
-GonkCameraParameters::GetTranslated(uint32_t aKey, nsTArray<nsString>& aValues)
-{
-  switch (aKey) {
-    case CAMERA_PARAM_SUPPORTED_ISOMODES:
-      aValues = mIsoModes;
-      return NS_OK;
-
-    case CAMERA_PARAM_SUPPORTED_SCENEMODES:
-      aValues = mSceneModes;
-      return NS_OK;
-
-    case CAMERA_PARAM_SUPPORTED_METERINGMODES:
-      aValues = mMeteringModes;
-      return NS_OK;
-
-    default:
-      return GetListAsArray(aKey, aValues);
-  }
-}
-
-nsresult
-GonkCameraParameters::GetTranslated(uint32_t aKey, nsTArray<double>& aValues)
-{
-  if (aKey == CAMERA_PARAM_SUPPORTED_ZOOMRATIOS) {
-    aValues.Clear();
-    for (uint32_t i = 0; i < mZoomRatios.Length(); ++i) {
-      *aValues.AppendElement() = mZoomRatios[i] / 100.0;
-    }
-    return NS_OK;
-  }
-
-  return GetListAsArray(aKey, aValues);
-}
-
-nsresult
-GonkCameraParameters::GetTranslated(uint32_t aKey, nsTArray<ICameraControl::Size>& aSizes)
-{
-  return GetListAsArray(aKey, aSizes);
-}
-
deleted file mode 100644
--- a/dom/camera/GonkCameraParameters.h
+++ /dev/null
@@ -1,301 +0,0 @@
-/*
- * Copyright (C) 2013-2015 Mozilla Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#ifndef DOM_CAMERA_GONKCAMERAPARAMETERS_H
-#define DOM_CAMERA_GONKCAMERAPARAMETERS_H
-
-#include <math.h>
-#include "nsTArray.h"
-#include "nsString.h"
-#include "mozilla/Mutex.h"
-#include "nsClassHashtable.h"
-#include "ICameraControl.h"
-
-#ifdef MOZ_WIDGET_GONK
-#include <camera/CameraParameters.h>
-#else
-#include "FallbackCameraPlatform.h"
-#endif
-
-namespace mozilla {
-
-class GonkCameraParameters
-{
-public:
-  GonkCameraParameters();
-  virtual ~GonkCameraParameters();
-
-  // IMPORTANT: This class is read and written by multiple threads --
-  // ALL public methods must hold mLock, for either reading or writing,
-  // for the life of their operation. Not doing so was the cause of
-  // bug 928856, which was -painful- to track down.
-  //
-  // Return values:
-  //  - see return values for GetTranslated() and SetTranslated() below.
-  template<class T> nsresult
-  Set(uint32_t aKey, const T& aValue)
-  {
-    MutexAutoLock lock(mLock);
-    nsresult rv = SetTranslated(aKey, aValue);
-    mDirty = mDirty || NS_SUCCEEDED(rv);
-    return rv;
-  }
-
-  template<class T> nsresult
-  Get(uint32_t aKey, T& aValue)
-  {
-    MutexAutoLock lock(mLock);
-    return GetTranslated(aKey, aValue);
-  }
-
-  bool
-  TestAndClearDirtyFlag()
-  {
-    bool dirty;
-
-    MutexAutoLock lock(mLock);
-    dirty = mDirty;
-    mDirty = false;
-    return dirty;
-  }
-
-  android::String8 Flatten() const;
-  nsresult Unflatten(const android::String8& aFlatParameters);
-
-protected:
-  mutable Mutex mLock;
-  bool mDirty;
-  bool mInitialized;
-
-  // Required internal properties
-  double mExposureCompensationStep;
-  int32_t mExposureCompensationMinIndex;
-  int32_t mExposureCompensationMaxIndex;
-  const char* mVendorSpecificKeyIsoMode;
-  const char* mVendorSpecificKeySupportedIsoModes;
-  nsTArray<int> mZoomRatios;
-  nsTArray<nsString> mIsoModes;
-  nsTArray<nsString> mSceneModes;
-  nsTArray<nsString> mMeteringModes;
-  nsClassHashtable<nsStringHashKey, nsCString> mIsoModeMap;
-  nsClassHashtable<nsCStringHashKey, nsCString> mParams;
-
-  nsresult SetImpl(const char* aKey, const char* aValue)
-  {
-    if (!aValue || strchr(aValue, ';') || strchr(aValue, '=')) {
-      return NS_ERROR_ILLEGAL_VALUE;
-    }
-    nsDependentCString key(aKey);
-    mParams.Put(key, new nsCString(aValue));
-    return NS_OK;
-  }
-
-  nsresult SetImpl(const char* aKey, int aValue)
-  {
-    nsDependentCString key(aKey);
-    nsCString* value = new nsCString();
-    value->AppendInt(aValue);
-    mParams.Put(key, value);
-    return NS_OK;
-  }
-
-  nsresult SetImpl(const char* aKey, double aValue)
-  {
-    nsDependentCString key(aKey);
-    nsCString* value = new nsCString();
-    value->AppendFloat(aValue);
-    mParams.Put(key, value);
-    return NS_OK;
-  }
-
-  nsresult SetImpl(const char* aKey, float aValue)
-  {
-    nsDependentCString key(aKey);
-    nsCString* value = new nsCString();
-    value->AppendFloat(aValue);
-    mParams.Put(key, value);
-    return NS_OK;
-  }
-
-  nsresult SetImpl(const char* aKey, bool aValue)
-  {
-    nsDependentCString key(aKey);
-    mParams.Put(key, new nsCString(aValue ? "true" : "false"));
-    return NS_OK;
-  }
-
-  nsresult GetImpl(const char* aKey, const char*& aRet)
-  {
-    nsDependentCString key(aKey);
-    nsCString* value;
-    if (!mParams.Get(key, &value)) {
-      aRet = nullptr;
-      return NS_ERROR_FAILURE;
-    }
-    aRet = value->Data();
-    return NS_OK;
-  }
-
-  nsresult GetImpl(const char* aKey, float& aRet)
-  {
-    nsDependentCString key(aKey);
-    nsCString* value;
-    nsresult rv = NS_ERROR_FAILURE;
-    if (mParams.Get(key, &value)) {
-      aRet = value->ToFloat(&rv);
-    } else {
-      aRet = 0.0;
-    }
-    return rv;
-  }
-
-  nsresult GetImpl(const char* aKey, double& aRet)
-  {
-    nsDependentCString key(aKey);
-    nsCString* value;
-    nsresult rv = NS_ERROR_FAILURE;
-    if (mParams.Get(key, &value)) {
-      aRet = value->ToFloat(&rv);
-    } else {
-      aRet = 0.0;
-    }
-    return rv;
-  }
-
-  nsresult GetImpl(const char* aKey, int& aRet)
-  {
-    nsDependentCString key(aKey);
-    nsCString* value;
-    nsresult rv = NS_ERROR_FAILURE;
-    if (mParams.Get(key, &value)) {
-      aRet = value->ToInteger(&rv);
-    } else {
-      aRet = 0.0;
-    }
-    return rv;
-  }
-
-  nsresult GetImpl(const char* aKey, bool& aRet)
-  {
-    nsDependentCString key(aKey);
-    nsCString* value;
-    if (!mParams.Get(key, &value)) {
-      aRet = false;
-      return NS_ERROR_FAILURE;
-    }
-    aRet = value->EqualsLiteral("true");
-    return NS_OK;
-  }
-
-  const char* GetTextKey(uint32_t aKey);
-  const char* FindVendorSpecificKey(const char* aPotentialKeys[], size_t aPotentialKeyCount);
-
-  // The *Impl() templates handle converting the parameter keys from
-  // their enum values to string types, if necessary. These are the
-  // bottom layer accessors to mParams.
-  //
-  // Return values:
-  //  - NS_OK on success;
-  //  - NS_ERROR_NOT_IMPLEMENTED if the numeric 'aKey' value is invalid.
-  template<typename T> nsresult
-  SetImpl(uint32_t aKey, const T& aValue)
-  {
-    const char* key = GetTextKey(aKey);
-    NS_ENSURE_TRUE(key, NS_ERROR_NOT_IMPLEMENTED);
-    return SetImpl(key, aValue);
-  }
-
-  template<typename T> nsresult
-  GetImpl(uint32_t aKey, T& aValue)
-  {
-    const char* key = GetTextKey(aKey);
-    NS_ENSURE_TRUE(key, NS_ERROR_NOT_IMPLEMENTED);
-    return GetImpl(key, aValue);
-  }
-
-  nsresult
-  ClearImpl(const char* aKey)
-  {
-    nsDependentCString key(aKey);
-    mParams.Remove(key);
-    return NS_OK;
-  }
-
-  // The *Translated() functions allow us to handle special cases;
-  // for example, where the thumbnail size setting is exposed as an
-  // ICameraControl::Size object, but is handled by the AOSP layer
-  // as two separate parameters.
-  //
-  // Return values:
-  //  - NS_OK on success;
-  //  - NS_ERROR_INVALID_ARG if 'aValue' contains an invalid value;
-  //  - NS_ERROR_NOT_IMPLEMENTED if 'aKey' is invalid;
-  //  - NS_ERROR_NOT_AVAILABLE if the getter fails to retrieve a valid value,
-  //      or if a setter fails because it requires one or more values that
-  //      could not be retrieved;
-  //  - NS_ERROR_FAILURE on unexpected internal failures.
-  nsresult SetTranslated(uint32_t aKey, const nsAString& aValue);
-  nsresult GetTranslated(uint32_t aKey, nsAString& aValue);
-  nsresult SetTranslated(uint32_t aKey, const ICameraControl::Size& aSize);
-  nsresult GetTranslated(uint32_t aKey, ICameraControl::Size& aSize);
-  nsresult GetTranslated(uint32_t aKey, nsTArray<ICameraControl::Size>& aSizes);
-  nsresult SetTranslated(uint32_t aKey, const nsTArray<ICameraControl::Region>& aRegions);
-  nsresult GetTranslated(uint32_t aKey, nsTArray<ICameraControl::Region>& aRegions);
-  nsresult SetTranslated(uint32_t aKey, const ICameraControl::Position& aPosition);
-  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);
-
-  // Converts a string of multiple, comma-separated values into an array
-  // of the appropriate type.
-  //
-  // Return values:
-  //  - NS_OK on success;
-  //  - NS_ERROR_NOT_IMPLEMENTED if 'aKey' is invalid;
-  //  - NS_ERROR_NOT_AVAILABLE if a valid value could not be returned.
-  template<class T> nsresult GetListAsArray(uint32_t aKey, nsTArray<T>& aArray);
-
-  // Converts ISO values (e.g., "auto", "hjr", "100", "200", etc.) to and from
-  // values understood by Gonk (e.g., "auto", "ISO_HJR", "ISO100", "ISO200",
-  // respectively).
-  //
-  // Return values:
-  //  - NS_OK on success;
-  //  - NS_ERROR_INVALID_ARG if the 'aIso' argument is not a valid form.
-  nsresult MapIsoToGonk(const nsAString& aIso, nsACString& aIsoOut);
-  nsresult MapIsoFromGonk(const char* aIso, nsAString& aIsoOut);
-
-  // Call once to initialize local cached values used in translating other
-  // arguments between Gecko and Gonk. Always returns NS_OK.
-  nsresult Initialize();
-
-  // Returns true if we're a memory-constrained platform that requires
-  // certain features to be disabled; returns false otherwise.
-  static bool IsLowMemoryPlatform();
-};
-
-} // namespace mozilla
-
-#endif // DOM_CAMERA_GONKCAMERAPARAMETERS_H
deleted file mode 100644
--- a/dom/camera/GonkCameraSource.cpp
+++ /dev/null
@@ -1,803 +0,0 @@
-/*
- * Copyright (C) 2009 The Android Open Source Project
- * Copyright (C) 2013 Mozilla Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#include <base/basictypes.h>
-#include "nsDebug.h"
-#define DOM_CAMERA_LOG_LEVEL        3
-#include "CameraCommon.h"
-/*
-#define CS_LOGD(...) DOM_CAMERA_LOGA(__VA_ARGS__)
-#define CS_LOGV(...) DOM_CAMERA_LOGI(__VA_ARGS__)
-#define CS_LOGI(...) DOM_CAMERA_LOGI(__VA_ARGS__)
-#define CS_LOGW(...) DOM_CAMERA_LOGW(__VA_ARGS__)
-#define CS_LOGE(...) DOM_CAMERA_LOGE(__VA_ARGS__)
-*/
-
-#define CS_LOGD(fmt, ...) DOM_CAMERA_LOGA("[%s:%d]" fmt,__FILE__,__LINE__, ## __VA_ARGS__)
-#define CS_LOGV(fmt, ...) DOM_CAMERA_LOGI("[%s:%d]" fmt,__FILE__,__LINE__, ## __VA_ARGS__)
-#define CS_LOGI(fmt, ...) DOM_CAMERA_LOGI("[%s:%d]" fmt,__FILE__,__LINE__, ## __VA_ARGS__)
-#define CS_LOGW(fmt, ...) DOM_CAMERA_LOGW("[%s:%d]" fmt,__FILE__,__LINE__, ## __VA_ARGS__)
-#define CS_LOGE(fmt, ...) DOM_CAMERA_LOGE("[%s:%d]" fmt,__FILE__,__LINE__, ## __VA_ARGS__)
-
-#include <OMX_Component.h>
-#include <binder/IPCThreadState.h>
-#include <media/stagefright/foundation/ADebug.h>
-#include <media/stagefright/MediaDefs.h>
-#include <media/stagefright/MediaErrors.h>
-#include <media/stagefright/MetaData.h>
-#include <camera/CameraParameters.h>
-#include <utils/String8.h>
-#include <cutils/properties.h>
-
-#include "GonkCameraSource.h"
-#include "GonkCameraListener.h"
-#include "GonkCameraHwMgr.h"
-#include "ICameraControl.h"
-
-using namespace mozilla;
-
-namespace android {
-
-static const int64_t CAMERA_SOURCE_TIMEOUT_NS = 3000000000LL;
-
-struct GonkCameraSourceListener : public GonkCameraListener {
-    GonkCameraSourceListener(const sp<GonkCameraSource> &source);
-
-    virtual void notify(int32_t msgType, int32_t ext1, int32_t ext2);
-    virtual bool postData(int32_t msgType, const sp<IMemory> &dataPtr,
-                          camera_frame_metadata_t *metadata);
-
-    virtual bool postDataTimestamp(
-            nsecs_t timestamp, int32_t msgType, const sp<IMemory>& dataPtr);
-
-protected:
-    virtual ~GonkCameraSourceListener();
-
-private:
-    wp<GonkCameraSource> mSource;
-
-    GonkCameraSourceListener(const GonkCameraSourceListener &);
-    GonkCameraSourceListener &operator=(const GonkCameraSourceListener &);
-};
-
-GonkCameraSourceListener::GonkCameraSourceListener(const sp<GonkCameraSource> &source)
-    : mSource(source) {
-}
-
-GonkCameraSourceListener::~GonkCameraSourceListener() {
-}
-
-void GonkCameraSourceListener::notify(int32_t msgType, int32_t ext1, int32_t ext2) {
-    CS_LOGV("notify(%d, %d, %d)", msgType, ext1, ext2);
-}
-
-bool GonkCameraSourceListener::postData(int32_t msgType, const sp<IMemory> &dataPtr,
-                                    camera_frame_metadata_t *metadata) {
-    CS_LOGV("postData(%d, ptr:%p, size:%d)",
-         msgType, dataPtr->pointer(), dataPtr->size());
-
-    sp<GonkCameraSource> source = mSource.promote();
-    if (source.get() != NULL) {
-        source->dataCallback(msgType, dataPtr);
-        return true;
-    }
-    return false;
-}
-
-bool GonkCameraSourceListener::postDataTimestamp(
-        nsecs_t timestamp, int32_t msgType, const sp<IMemory>& dataPtr) {
-
-    sp<GonkCameraSource> source = mSource.promote();
-    if (source.get() != NULL) {
-        source->dataCallbackTimestamp(timestamp/1000, msgType, dataPtr);
-        return true;
-    }
-    return false;
-}
-
-static int32_t getColorFormat(const char* colorFormat) {
-    return OMX_COLOR_FormatYUV420SemiPlanar; //XXX nsGonkCameraControl uses only YUV420SemiPlanar
-
-    if (!strcmp(colorFormat, CameraParameters::PIXEL_FORMAT_YUV420P)) {
-       return OMX_COLOR_FormatYUV420Planar;
-    }
-
-    if (!strcmp(colorFormat, CameraParameters::PIXEL_FORMAT_YUV422SP)) {
-       return OMX_COLOR_FormatYUV422SemiPlanar;
-    }
-
-    if (!strcmp(colorFormat, CameraParameters::PIXEL_FORMAT_YUV420SP)) {
-        return OMX_COLOR_FormatYUV420SemiPlanar;
-    }
-
-    if (!strcmp(colorFormat, CameraParameters::PIXEL_FORMAT_YUV422I)) {
-        return OMX_COLOR_FormatYCbYCr;
-    }
-
-    if (!strcmp(colorFormat, CameraParameters::PIXEL_FORMAT_RGB565)) {
-       return OMX_COLOR_Format16bitRGB565;
-    }
-
-    if (!strcmp(colorFormat, "OMX_TI_COLOR_FormatYUV420PackedSemiPlanar")) {
-       return OMX_TI_COLOR_FormatYUV420PackedSemiPlanar;
-    }
-#if defined(MOZ_WIDGET_GONK) && ANDROID_VERSION >= 17
-    if (!strcmp(colorFormat, CameraParameters::PIXEL_FORMAT_ANDROID_OPAQUE)) {
-        return OMX_COLOR_FormatAndroidOpaque;
-    }
-#endif
-    CS_LOGE("Uknown color format (%s), please add it to "
-         "GonkCameraSource::getColorFormat", colorFormat);
-
-    CHECK(!"Unknown color format");
-}
-
-GonkCameraSource *GonkCameraSource::Create(
-    const sp<GonkCameraHardware>& aCameraHw,
-    Size videoSize,
-    int32_t frameRate,
-    bool storeMetaDataInVideoBuffers) {
-
-    GonkCameraSource *source = new GonkCameraSource(aCameraHw,
-                    videoSize, frameRate,
-                    storeMetaDataInVideoBuffers);
-    return source;
-}
-
-GonkCameraSource *GonkCameraSource::Create(
-    ICameraControl* aControl,
-    Size videoSize,
-    int32_t frameRate)
-{
-    mozilla::nsGonkCameraControl* control =
-        static_cast<mozilla::nsGonkCameraControl*>(aControl);
-    return Create(control->GetCameraHw(), videoSize, frameRate, false);
-}
-
-GonkCameraSource::GonkCameraSource(
-    const sp<GonkCameraHardware>& aCameraHw,
-    Size videoSize,
-    int32_t frameRate,
-    bool storeMetaDataInVideoBuffers)
-    : mCameraFlags(0),
-      mNumInputBuffers(0),
-      mVideoFrameRate(-1),
-      mNumFramesReceived(0),
-      mLastFrameTimestampUs(0),
-      mStarted(false),
-      mNumFramesEncoded(0),
-      mTimeBetweenFrameCaptureUs(0),
-      mRateLimit(false),
-      mFirstFrameTimeUs(0),
-      mNumFramesDropped(0),
-      mNumGlitches(0),
-      mGlitchDurationThresholdUs(200000),
-      mCollectStats(false),
-      mCameraHw(aCameraHw) {
-    mVideoSize.width  = -1;
-    mVideoSize.height = -1;
-
-    mInitCheck = init(
-                    videoSize, frameRate,
-                    storeMetaDataInVideoBuffers);
-    if (mInitCheck != OK) releaseCamera();
-}
-
-status_t GonkCameraSource::initCheck() const {
-    return mInitCheck;
-}
-
-//TODO: Do we need to reimplement isCameraAvailable?
-
-/*
- * Check to see whether the requested video width and height is one
- * of the supported sizes.
- * @param width the video frame width in pixels
- * @param height the video frame height in pixels
- * @param suppportedSizes the vector of sizes that we check against
- * @return true if the dimension (width and height) is supported.
- */
-static bool isVideoSizeSupported(
-    int32_t width, int32_t height,
-    const Vector<Size>& supportedSizes) {
-
-    CS_LOGV("isVideoSizeSupported");
-    for (size_t i = 0; i < supportedSizes.size(); ++i) {
-        if (width  == supportedSizes[i].width &&
-            height == supportedSizes[i].height) {
-            return true;
-        }
-    }
-    return false;
-}
-
-/*
- * If the preview and video output is separate, we only set the
- * the video size, and applications should set the preview size
- * to some proper value, and the recording framework will not
- * change the preview size; otherwise, if the video and preview
- * output is the same, we need to set the preview to be the same
- * as the requested video size.
- *
- */
-/*
- * Query the camera to retrieve the supported video frame sizes
- * and also to see whether CameraParameters::setVideoSize()
- * is supported or not.
- * @param params CameraParameters to retrieve the information
- * @@param isSetVideoSizeSupported retunrs whether method
- *      CameraParameters::setVideoSize() is supported or not.
- * @param sizes returns the vector of Size objects for the
- *      supported video frame sizes advertised by the camera.
- */
-static void getSupportedVideoSizes(
-    const CameraParameters& params,
-    bool *isSetVideoSizeSupported,
-    Vector<Size>& sizes) {
-
-    *isSetVideoSizeSupported = true;
-    params.getSupportedVideoSizes(sizes);
-    if (sizes.size() == 0) {
-        CS_LOGD("Camera does not support setVideoSize()");
-        params.getSupportedPreviewSizes(sizes);
-        *isSetVideoSizeSupported = false;
-    }
-}
-
-/*
- * Check whether the camera has the supported color format
- * @param params CameraParameters to retrieve the information
- * @return OK if no error.
- */
-status_t GonkCameraSource::isCameraColorFormatSupported(
-        const CameraParameters& params) {
-    mColorFormat = getColorFormat(params.get(
-            CameraParameters::KEY_VIDEO_FRAME_FORMAT));
-    if (mColorFormat == -1) {
-        return BAD_VALUE;
-    }
-    return OK;
-}
-
-/*
- * Configure the camera to use the requested video size
- * (width and height) and/or frame rate. If both width and
- * height are -1, configuration on the video size is skipped.
- * if frameRate is -1, configuration on the frame rate
- * is skipped. Skipping the configuration allows one to
- * use the current camera setting without the need to
- * actually know the specific values (see Create() method).
- *
- * @param params the CameraParameters to be configured
- * @param width the target video frame width in pixels
- * @param height the target video frame height in pixels
- * @param frameRate the target frame rate in frames per second.
- * @return OK if no error.
- */
-status_t GonkCameraSource::configureCamera(
-        CameraParameters* params,
-        int32_t width, int32_t height,
-        int32_t frameRate) {
-    CS_LOGV("configureCamera");
-    Vector<Size> sizes;
-    bool isSetVideoSizeSupportedByCamera = true;
-    getSupportedVideoSizes(*params, &isSetVideoSizeSupportedByCamera, sizes);
-    bool isCameraParamChanged = false;
-    if (width != -1 && height != -1) {
-        if (!isVideoSizeSupported(width, height, sizes)) {
-            CS_LOGE("Video dimension (%dx%d) is unsupported", width, height);
-            return BAD_VALUE;