Bug 1306137 - remove b2g camera code: Remove dom/camera/ and code which depends on it. r?aosmond draft
authorSebastian Hengst <archaeopteryx@coole-files.de>
Tue, 04 Oct 2016 20:16:28 +0200
changeset 425390 dad8f8b7c0f119d675d7791767df053e89d6a13b
parent 425389 badaa39f6f10f3bc395cdb194c4cee6b44eb8ffd
child 533914 52854856e919207d454b0ecbbff19df71a4b4251
push id32418
push userarchaeopteryx@coole-files.de
push dateFri, 14 Oct 2016 17:55:28 +0000
reviewersaosmond
bugs1306137
milestone52.0a1
Bug 1306137 - remove b2g camera code: Remove dom/camera/ and code which depends on it. r?aosmond 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;
-        }
-        if (isSetVideoSizeSupportedByCamera) {
-            params->setVideoSize(width, height);
-        } else {
-            params->setPreviewSize(width, height);
-        }
-        isCameraParamChanged = true;
-    } else if ((width == -1 && height != -1) ||
-               (width != -1 && height == -1)) {
-        // If one and only one of the width and height is -1
-        // we reject such a request.
-        CS_LOGE("Requested video size (%dx%d) is not supported", width, height);
-        return BAD_VALUE;
-    } else {  // width == -1 && height == -1
-        // Do not configure the camera.
-        // Use the current width and height value setting from the camera.
-    }
-
-    if (frameRate != -1) {
-        CHECK(frameRate > 0 && frameRate <= 120);
-        const char* supportedFrameRates =
-                params->get(CameraParameters::KEY_SUPPORTED_PREVIEW_FRAME_RATES);
-        CHECK(supportedFrameRates != NULL);
-        CS_LOGV("Supported frame rates: %s", supportedFrameRates);
-        char buf[4];
-        snprintf(buf, 4, "%d", frameRate);
-        if (strstr(supportedFrameRates, buf) == NULL) {
-            CS_LOGE("Requested frame rate (%d) is not supported: %s",
-                frameRate, supportedFrameRates);
-            return BAD_VALUE;
-        }
-
-        // The frame rate is supported, set the camera to the requested value.
-        params->setPreviewFrameRate(frameRate);
-        isCameraParamChanged = true;
-    } else {  // frameRate == -1
-        // Do not configure the camera.
-        // Use the current frame rate value setting from the camera
-    }
-
-    if (isCameraParamChanged) {
-        // Either frame rate or frame size needs to be changed.
-        if (OK != mCameraHw->PushParameters(*params)) {
-            CS_LOGE("Could not change settings."
-                 " Someone else is using camera?");
-            return -EBUSY;
-        }
-    }
-    return OK;
-}
-
-/*
- * Check whether the requested video frame size
- * has been successfully configured or not. If both width and height
- * are -1, check on the current width and height value setting
- * is performed.
- *
- * @param params CameraParameters to retrieve the information
- * @param the target video frame width in pixels to check against
- * @param the target video frame height in pixels to check against
- * @return OK if no error
- */
-status_t GonkCameraSource::checkVideoSize(
-        const CameraParameters& params,
-        int32_t width, int32_t height) {
-
-    CS_LOGV("checkVideoSize");
-    // The actual video size is the same as the preview size
-    // if the camera hal does not support separate video and
-    // preview output. In this case, we retrieve the video
-    // size from preview.
-    int32_t frameWidthActual = -1;
-    int32_t frameHeightActual = -1;
-    Vector<Size> sizes;
-    params.getSupportedVideoSizes(sizes);
-    if (sizes.size() == 0) {
-        // video size is the same as preview size
-        params.getPreviewSize(&frameWidthActual, &frameHeightActual);
-    } else {
-        // video size may not be the same as preview
-        params.getVideoSize(&frameWidthActual, &frameHeightActual);
-    }
-    if (frameWidthActual < 0 || frameHeightActual < 0) {
-        CS_LOGE("Failed to retrieve video frame size (%dx%d)",
-                frameWidthActual, frameHeightActual);
-        return UNKNOWN_ERROR;
-    }
-
-    // Check the actual video frame size against the target/requested
-    // video frame size.
-    if (width != -1 && height != -1) {
-        if (frameWidthActual != width || frameHeightActual != height) {
-            CS_LOGE("Failed to set video frame size to %dx%d. "
-                    "The actual video size is %dx%d ", width, height,
-                    frameWidthActual, frameHeightActual);
-            return UNKNOWN_ERROR;
-        }
-    }
-
-    // Good now.
-    mVideoSize.width = frameWidthActual;
-    mVideoSize.height = frameHeightActual;
-    return OK;
-}
-
-/*
- * Check the requested frame rate has been successfully configured or not.
- * If the target frameRate is -1, check on the current frame rate value
- * setting is performed.
- *
- * @param params CameraParameters to retrieve the information
- * @param the target video frame rate to check against
- * @return OK if no error.
- */
-status_t GonkCameraSource::checkFrameRate(
-        const CameraParameters& params,
-        int32_t frameRate) {
-
-    CS_LOGV("checkFrameRate");
-    int32_t frameRateActual = params.getPreviewFrameRate();
-    if (frameRateActual < 0) {
-        CS_LOGE("Failed to retrieve preview frame rate (%d)", frameRateActual);
-        return UNKNOWN_ERROR;
-    }
-
-    // Check the actual video frame rate against the target/requested
-    // video frame rate.
-    if (frameRate != -1 && (frameRateActual - frameRate) != 0) {
-        CS_LOGE("Failed to set preview frame rate to %d fps. The actual "
-                "frame rate is %d", frameRate, frameRateActual);
-        return UNKNOWN_ERROR;
-    }
-
-    // Good now.
-    mVideoFrameRate = frameRateActual;
-    return OK;
-}
-
-/*
- * Initialize the GonkCameraSource so that it becomes
- * ready for providing the video input streams as requested.
- * @param camera the camera object used for the video source
- * @param cameraId if camera == 0, use camera with this id
- *      as the video source
- * @param videoSize the target video frame size. If both
- *      width and height in videoSize is -1, use the current
- *      width and heigth settings by the camera
- * @param frameRate the target frame rate in frames per second.
- *      if it is -1, use the current camera frame rate setting.
- * @param storeMetaDataInVideoBuffers request to store meta
- *      data or real YUV data in video buffers. Request to
- *      store meta data in video buffers may not be honored
- *      if the source does not support this feature.
- *
- * @return OK if no error.
- */
-status_t GonkCameraSource::init(
-        Size videoSize,
-        int32_t frameRate,
-        bool storeMetaDataInVideoBuffers) {
-
-    CS_LOGV("init");
-    status_t err = OK;
-    //TODO: need to do something here to check the sanity of camera
-
-    CameraParameters params;
-    mCameraHw->PullParameters(params);
-    if ((err = isCameraColorFormatSupported(params)) != OK) {
-        return err;
-    }
-
-    // Set the camera to use the requested video frame size
-    // and/or frame rate.
-    if ((err = configureCamera(&params,
-                    videoSize.width, videoSize.height,
-                    frameRate))) {
-        return err;
-    }
-
-    // Check on video frame size and frame rate.
-    CameraParameters newCameraParams;
-    mCameraHw->PullParameters(newCameraParams);
-    if ((err = checkVideoSize(newCameraParams,
-                videoSize.width, videoSize.height)) != OK) {
-        return err;
-    }
-    if ((err = checkFrameRate(newCameraParams, frameRate)) != OK) {
-        return err;
-    }
-
-    // By default, do not store metadata in video buffers
-    mIsMetaDataStoredInVideoBuffers = false;
-    mCameraHw->StoreMetaDataInBuffers(false);
-    if (storeMetaDataInVideoBuffers) {
-        if (OK == mCameraHw->StoreMetaDataInBuffers(true)) {
-            mIsMetaDataStoredInVideoBuffers = true;
-        }
-    }
-
-    int64_t glitchDurationUs = (1000000LL / mVideoFrameRate);
-    if (glitchDurationUs > mGlitchDurationThresholdUs) {
-        mGlitchDurationThresholdUs = glitchDurationUs;
-    }
-
-    // XXX: query camera for the stride and slice height
-    // when the capability becomes available.
-    mMeta = new MetaData;
-    mMeta->setCString(kKeyMIMEType,  MEDIA_MIMETYPE_VIDEO_RAW);
-    mMeta->setInt32(kKeyColorFormat, mColorFormat);
-    mMeta->setInt32(kKeyWidth,       mVideoSize.width);
-    mMeta->setInt32(kKeyHeight,      mVideoSize.height);
-    mMeta->setInt32(kKeyStride,      mVideoSize.width);
-    mMeta->setInt32(kKeySliceHeight, mVideoSize.height);
-    mMeta->setInt32(kKeyFrameRate,   mVideoFrameRate);
-    return OK;
-}
-
-GonkCameraSource::~GonkCameraSource() {
-    if (mStarted) {
-        reset();
-    } else if (mInitCheck == OK) {
-        // Camera is initialized but because start() is never called,
-        // the lock on Camera is never released(). This makes sure
-        // Camera's lock is released in this case.
-        // TODO: Don't think I need to do this
-        releaseCamera();
-    }
-}
-
-int GonkCameraSource::startCameraRecording() {
-    CS_LOGV("startCameraRecording");
-    return mCameraHw->StartRecording();
-}
-
-status_t GonkCameraSource::start(MetaData *meta) {
-    int rv;
-
-    CS_LOGV("start");
-    CHECK(!mStarted);
-    if (mInitCheck != OK) {
-        CS_LOGE("GonkCameraSource is not initialized yet");
-        return mInitCheck;
-    }
-
-    char value[PROPERTY_VALUE_MAX];
-    if (property_get("media.stagefright.record-stats", value, NULL)
-        && (!strcmp(value, "1") || !strcasecmp(value, "true"))) {
-        mCollectStats = true;
-    }
-
-    mStartTimeUs = 0;
-    mNumInputBuffers = 0;
-    if (meta) {
-        int64_t startTimeUs;
-        if (meta->findInt64(kKeyTime, &startTimeUs)) {
-            mStartTimeUs = startTimeUs;
-        }
-#if defined(MOZ_WIDGET_GONK) && ANDROID_VERSION >= 17
-        int32_t nBuffers;
-        if (meta->findInt32(kKeyNumBuffers, &nBuffers)) {
-            CHECK_GT(nBuffers, 0);
-            mNumInputBuffers = nBuffers;
-        }
-#endif
-    }
-
-    // Register a listener with GonkCameraHardware so that we can get callbacks
-    mCameraHw->SetListener(new GonkCameraSourceListener(this));
-
-    rv = startCameraRecording();
-
-    mStarted = (rv == OK);
-    return rv;
-}
-
-void GonkCameraSource::stopCameraRecording() {
-    CS_LOGV("stopCameraRecording");
-    mCameraHw->StopRecording();
-}
-
-void GonkCameraSource::releaseCamera() {
-    CS_LOGV("releaseCamera");
-}
-
-status_t GonkCameraSource::reset() {
-    CS_LOGD("reset: E");
-    Mutex::Autolock autoLock(mLock);
-    mStarted = false;
-    mFrameAvailableCondition.signal();
-
-    releaseQueuedFrames();
-    while (!mFramesBeingEncoded.empty()) {
-        if (NO_ERROR !=
-            mFrameCompleteCondition.waitRelative(mLock,
-                    mTimeBetweenFrameCaptureUs * 1000LL + CAMERA_SOURCE_TIMEOUT_NS)) {
-            CS_LOGW("Timed out waiting for outstanding frames being encoded: %d",
-                mFramesBeingEncoded.size());
-        }
-    }
-    stopCameraRecording();
-    if (mRateLimit) {
-      mRateLimit = false;
-      mCameraHw->OnRateLimitPreview(false);
-    }
-    releaseCamera();
-
-    if (mDirectBufferListener.get()) {
-      mDirectBufferListener = nullptr;
-    }
-
-    if (mCollectStats) {
-        CS_LOGI("Frames received/encoded/dropped: %d/%d/%d in %lld us",
-                mNumFramesReceived, mNumFramesEncoded, mNumFramesDropped,
-                mLastFrameTimestampUs - mFirstFrameTimeUs);
-    }
-
-    if (mNumGlitches > 0) {
-        CS_LOGW("%d long delays between neighboring video frames", mNumGlitches);
-    }
-
-    CHECK_EQ(mNumFramesReceived, mNumFramesEncoded + mNumFramesDropped);
-    CS_LOGD("reset: X");
-    return OK;
-}
-
-void GonkCameraSource::releaseRecordingFrame(const sp<IMemory>& frame) {
-    CS_LOGV("releaseRecordingFrame");
-    mCameraHw->ReleaseRecordingFrame(frame);
-}
-
-void GonkCameraSource::releaseQueuedFrames() {
-    List<sp<IMemory> >::iterator it;
-    while (!mFramesReceived.empty()) {
-        it = mFramesReceived.begin();
-        releaseRecordingFrame(*it);
-        mFramesReceived.erase(it);
-        ++mNumFramesDropped;
-    }
-}
-
-sp<MetaData> GonkCameraSource::getFormat() {
-    return mMeta;
-}
-
-void GonkCameraSource::releaseOneRecordingFrame(const sp<IMemory>& frame) {
-    releaseRecordingFrame(frame);
-}
-
-void GonkCameraSource::signalBufferReturned(MediaBuffer *buffer) {
-    CS_LOGV("signalBufferReturned: %p", buffer->data());
-    Mutex::Autolock autoLock(mLock);
-    for (List<sp<IMemory> >::iterator it = mFramesBeingEncoded.begin();
-         it != mFramesBeingEncoded.end(); ++it) {
-        if ((*it)->pointer() ==  buffer->data()) {
-            releaseOneRecordingFrame((*it));
-            mFramesBeingEncoded.erase(it);
-            ++mNumFramesEncoded;
-            buffer->setObserver(0);
-            buffer->release();
-            mFrameCompleteCondition.signal();
-            return;
-        }
-    }
-    CHECK(!"signalBufferReturned: bogus buffer");
-}
-
-status_t GonkCameraSource::AddDirectBufferListener(DirectBufferListener* aListener) {
-    if (mDirectBufferListener.get()) {
-        return UNKNOWN_ERROR;
-    }
-    mDirectBufferListener = aListener;
-    return OK;
-}
-
-status_t GonkCameraSource::read(
-        MediaBuffer **buffer, const ReadOptions *options) {
-    CS_LOGV("read");
-
-    *buffer = NULL;
-
-    int64_t seekTimeUs;
-    ReadOptions::SeekMode mode;
-    if (options && options->getSeekTo(&seekTimeUs, &mode)) {
-        return ERROR_UNSUPPORTED;
-    }
-
-    sp<IMemory> frame;
-    int64_t frameTime;
-
-    {
-        Mutex::Autolock autoLock(mLock);
-        while (mStarted && mFramesReceived.empty()) {
-            if (NO_ERROR !=
-                mFrameAvailableCondition.waitRelative(mLock,
-                    mTimeBetweenFrameCaptureUs * 1000LL + CAMERA_SOURCE_TIMEOUT_NS)) {
-                //TODO: check sanity of camera?
-                CS_LOGW("Timed out waiting for incoming camera video frames: %lld us",
-                    mLastFrameTimestampUs);
-            }
-        }
-        if (!mStarted) {
-            return OK;
-        }
-        frame = *mFramesReceived.begin();
-        mFramesReceived.erase(mFramesReceived.begin());
-
-        frameTime = *mFrameTimes.begin();
-        mFrameTimes.erase(mFrameTimes.begin());
-        mFramesBeingEncoded.push_back(frame);
-        *buffer = new MediaBuffer(frame->pointer(), frame->size());
-        (*buffer)->setObserver(this);
-        (*buffer)->add_ref();
-        (*buffer)->meta_data()->setInt64(kKeyTime, frameTime);
-    }
-    return OK;
-}
-
-void GonkCameraSource::dataCallbackTimestamp(int64_t timestampUs,
-        int32_t msgType, const sp<IMemory> &data) {
-    bool rateLimit;
-    bool prevRateLimit;
-    CS_LOGV("dataCallbackTimestamp: timestamp %lld us", timestampUs);
-    {
-        Mutex::Autolock autoLock(mLock);
-        if (!mStarted || (mNumFramesReceived == 0 && timestampUs < mStartTimeUs)) {
-            CS_LOGV("Drop frame at %lld/%lld us", timestampUs, mStartTimeUs);
-            releaseOneRecordingFrame(data);
-            return;
-        }
-
-        if (mNumFramesReceived > 0) {
-            if (timestampUs <= mLastFrameTimestampUs) {
-                CS_LOGE("Drop frame at %lld us, before last at %lld us",
-                    timestampUs, mLastFrameTimestampUs);
-                releaseOneRecordingFrame(data);
-                return;
-            }
-            if (timestampUs - mLastFrameTimestampUs > mGlitchDurationThresholdUs) {
-                ++mNumGlitches;
-            }
-        }
-
-        // May need to skip frame or modify timestamp. Currently implemented
-        // by the subclass CameraSourceTimeLapse.
-        if (skipCurrentFrame(timestampUs)) {
-            releaseOneRecordingFrame(data);
-            return;
-        }
-
-        mLastFrameTimestampUs = timestampUs;
-        if (mNumFramesReceived == 0) {
-            mFirstFrameTimeUs = timestampUs;
-            // Initial delay
-            if (mStartTimeUs > 0) {
-                if (timestampUs < mStartTimeUs) {
-                    // Frame was captured before recording was started
-                    // Drop it without updating the statistical data.
-                    releaseOneRecordingFrame(data);
-                    return;
-                }
-                mStartTimeUs = timestampUs - mStartTimeUs;
-            }
-        }
-        ++mNumFramesReceived;
-
-        // If a backlog is building up in the receive queue, we are likely
-        // resource constrained and we need to throttle
-        prevRateLimit = mRateLimit;
-        rateLimit = mFramesReceived.empty();
-        mRateLimit = rateLimit;
-
-        CHECK(data != NULL && data->size() > 0);
-        mFramesReceived.push_back(data);
-        int64_t timeUs = mStartTimeUs + (timestampUs - mFirstFrameTimeUs);
-        mFrameTimes.push_back(timeUs);
-        CS_LOGV("initial delay: %lld, current time stamp: %lld",
-            mStartTimeUs, timeUs);
-        mFrameAvailableCondition.signal();
-    }
-
-    if(prevRateLimit != rateLimit) {
-        mCameraHw->OnRateLimitPreview(rateLimit);
-    }
-
-    if (mDirectBufferListener.get()) {
-        MediaBuffer* mediaBuffer;
-        if (read(&mediaBuffer) == OK) {
-            mDirectBufferListener->BufferAvailable(mediaBuffer);
-            // read() calls MediaBuffer->add_ref() so it needs to be released here.
-            mediaBuffer->release();
-        }
-    }
-}
-
-bool GonkCameraSource::isMetaDataStoredInVideoBuffers() const {
-    CS_LOGV("isMetaDataStoredInVideoBuffers");
-    return mIsMetaDataStoredInVideoBuffers;
-}
-
-}  // namespace android
deleted file mode 100644
--- a/dom/camera/GonkCameraSource.h
+++ /dev/null
@@ -1,192 +0,0 @@
-/*
- * Copyright (C) 2009 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_SOURCE_H_
-
-#define GONK_CAMERA_SOURCE_H_
-
-#include <media/stagefright/MediaBuffer.h>
-#include <media/stagefright/MediaSource.h>
-#include <camera/CameraParameters.h>
-#include <utils/List.h>
-#include <utils/RefBase.h>
-#include <utils/String16.h>
-
-#include "GonkCameraHwMgr.h"
-
-namespace mozilla {
-class ICameraControl;
-}
-
-namespace android {
-
-class IMemory;
-
-class GonkCameraSource : public MediaSource, public MediaBufferObserver {
-public:
-
-    static GonkCameraSource *Create(const sp<GonkCameraHardware>& aCameraHw,
-                                    Size videoSize,
-                                    int32_t frameRate,
-                                    bool storeMetaDataInVideoBuffers = false);
-
-    static GonkCameraSource *Create(mozilla::ICameraControl* aControl,
-                                    Size videoSize,
-                                    int32_t frameRate);
-
-    virtual ~GonkCameraSource();
-
-    virtual status_t start(MetaData *params = NULL);
-    virtual status_t stop() { return reset(); }
-    virtual status_t read(
-            MediaBuffer **buffer, const ReadOptions *options = NULL);
-
-    /**
-     * Check whether a GonkCameraSource object is properly initialized.
-     * Must call this method before stop().
-     * @return OK if initialization has successfully completed.
-     */
-    virtual status_t initCheck() const;
-
-    /**
-     * Returns the MetaData associated with the GonkCameraSource,
-     * including:
-     * kKeyColorFormat: YUV color format of the video frames
-     * kKeyWidth, kKeyHeight: dimension (in pixels) of the video frames
-     * kKeySampleRate: frame rate in frames per second
-     * kKeyMIMEType: always fixed to be MEDIA_MIMETYPE_VIDEO_RAW
-     */
-    virtual sp<MetaData> getFormat();
-
-    /**
-     * Tell whether this camera source stores meta data or real YUV
-     * frame data in video buffers.
-     *
-     * @return true if meta data is stored in the video
-     *      buffers; false if real YUV data is stored in
-     *      the video buffers.
-     */
-    bool isMetaDataStoredInVideoBuffers() const;
-
-    virtual void signalBufferReturned(MediaBuffer* buffer);
-
-    /**
-     * It sends recording frames to listener directly in the same thread.
-     * Because recording frame is critical resource and it should not be
-     * propagated to other thread as much as possible or there could be frame
-     * rate jitter due to camera HAL waiting for resource.
-     */
-    class DirectBufferListener : public RefBase {
-    public:
-        DirectBufferListener() {};
-
-        virtual status_t BufferAvailable(MediaBuffer* aBuffer) = 0;
-
-    protected:
-        virtual ~DirectBufferListener() {}
-    };
-
-    status_t AddDirectBufferListener(DirectBufferListener* aListener);
-
-protected:
-
-    enum CameraFlags {
-        FLAGS_SET_CAMERA = 1L << 0,
-        FLAGS_HOT_CAMERA = 1L << 1,
-    };
-
-    int32_t  mCameraFlags;
-    Size     mVideoSize;
-    int32_t  mNumInputBuffers;
-    int32_t  mVideoFrameRate;
-    int32_t  mColorFormat;
-    status_t mInitCheck;
-
-    sp<MetaData> mMeta;
-
-    int64_t mStartTimeUs;
-    int32_t mNumFramesReceived;
-    int64_t mLastFrameTimestampUs;
-    bool mStarted;
-    int32_t mNumFramesEncoded;
-
-    // Time between capture of two frames.
-    int64_t mTimeBetweenFrameCaptureUs;
-
-    GonkCameraSource(const sp<GonkCameraHardware>& aCameraHw,
-                 Size videoSize, int32_t frameRate,
-                 bool storeMetaDataInVideoBuffers = false);
-
-    virtual int startCameraRecording();
-    virtual void stopCameraRecording();
-    virtual void releaseRecordingFrame(const sp<IMemory>& frame);
-
-    // Returns true if need to skip the current frame.
-    // Called from dataCallbackTimestamp.
-    virtual bool skipCurrentFrame(int64_t timestampUs) {return false;}
-
-    friend class GonkCameraSourceListener;
-    // Callback called when still camera raw data is available.
-    virtual void dataCallback(int32_t msgType, const sp<IMemory> &data) {}
-
-    virtual void dataCallbackTimestamp(int64_t timestampUs, int32_t msgType,
-            const sp<IMemory> &data);
-
-private:
-
-    Mutex mLock;
-    Condition mFrameAvailableCondition;
-    Condition mFrameCompleteCondition;
-    List<sp<IMemory> > mFramesReceived;
-    List<sp<IMemory> > mFramesBeingEncoded;
-    List<int64_t> mFrameTimes;
-    bool mRateLimit;
-
-    int64_t mFirstFrameTimeUs;
-    int32_t mNumFramesDropped;
-    int32_t mNumGlitches;
-    int64_t mGlitchDurationThresholdUs;
-    bool mCollectStats;
-    bool mIsMetaDataStoredInVideoBuffers;
-    sp<GonkCameraHardware> mCameraHw;
-    sp<DirectBufferListener> mDirectBufferListener;
-
-    void releaseQueuedFrames();
-    void releaseOneRecordingFrame(const sp<IMemory>& frame);
-
-    status_t init(Size videoSize, int32_t frameRate,
-                  bool storeMetaDataInVideoBuffers);
-    status_t isCameraColorFormatSupported(const CameraParameters& params);
-    status_t configureCamera(CameraParameters* params,
-                    int32_t width, int32_t height,
-                    int32_t frameRate);
-
-    status_t checkVideoSize(const CameraParameters& params,
-                    int32_t width, int32_t height);
-
-    status_t checkFrameRate(const CameraParameters& params,
-                    int32_t frameRate);
-
-    void releaseCamera();
-    status_t reset();
-
-    GonkCameraSource(const GonkCameraSource &);
-    GonkCameraSource &operator=(const GonkCameraSource &);
-};
-
-}  // namespace android
-
-#endif  // GONK_CAMERA_SOURCE_H_
deleted file mode 100644
--- a/dom/camera/GonkRecorder.cpp
+++ /dev/null
@@ -1,1968 +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 "nsDebug.h"
-#define DOM_CAMERA_LOG_LEVEL        3
-#include "CameraCommon.h"
-#include "GonkCameraSource.h"
-#include "GonkRecorder.h"
-#include "mozilla/CondVar.h"
-
-#define RE_LOGD(fmt, ...) DOM_CAMERA_LOGA("[%s:%d]" fmt,__FILE__,__LINE__, ## __VA_ARGS__)
-#define RE_LOGV(fmt, ...) DOM_CAMERA_LOGI("[%s:%d]" fmt,__FILE__,__LINE__, ## __VA_ARGS__)
-#define RE_LOGI(fmt, ...) DOM_CAMERA_LOGI("[%s:%d]" fmt,__FILE__,__LINE__, ## __VA_ARGS__)
-#define RE_LOGW(fmt, ...) DOM_CAMERA_LOGW("[%s:%d]" fmt,__FILE__,__LINE__, ## __VA_ARGS__)
-#define RE_LOGE(fmt, ...) DOM_CAMERA_LOGE("[%s:%d]" fmt,__FILE__,__LINE__, ## __VA_ARGS__)
-
-#include <binder/IPCThreadState.h>
-#if defined(MOZ_WIDGET_GONK) && ANDROID_VERSION >= 17
-# include <media/openmax/OMX_Audio.h>
-#endif
-#include <media/stagefright/foundation/ADebug.h>
-#include <media/stagefright/AudioSource.h>
-#include <media/stagefright/AMRWriter.h>
-#include <media/stagefright/AACWriter.h>
-#include <media/stagefright/MPEG2TSWriter.h>
-#include <media/stagefright/MPEG4Writer.h>
-#include <media/stagefright/MediaDefs.h>
-#include <media/stagefright/MetaData.h>
-#include <media/stagefright/OMXClient.h>
-#if ANDROID_VERSION >= 21
-#include <media/stagefright/MediaCodecSource.h>
-#else
-#include <media/stagefright/OMXCodec.h>
-#endif
-#include <media/MediaProfiles.h>
-
-#include <utils/Errors.h>
-#include <sys/types.h>
-#include <ctype.h>
-#include <unistd.h>
-
-#include <cutils/properties.h>
-#include <system/audio.h>
-
-#define RES_720P (720 * 1280)
-namespace android {
-
-struct GonkRecorder::WrappedMediaSource : MediaSource {
-public:
-    WrappedMediaSource(const sp<MediaSource> &encoder);
-    status_t start(MetaData *params = NULL) override;
-    status_t stop() override;
-    sp<MetaData> getFormat() override;
-    status_t read(MediaBuffer **buffer, const ReadOptions *options = NULL) override;
-    void block();
-    status_t resume();
-
-protected:
-    virtual ~WrappedMediaSource() {};
-
-private:
-    WrappedMediaSource(const WrappedMediaSource &);
-    WrappedMediaSource &operator=(const WrappedMediaSource &);
-
-    sp<MediaSource> mEncoder;
-    mozilla::Mutex mMutex;
-    mozilla::CondVar mCondVar;
-    bool mWait;
-    bool mResume;
-    status_t mResumeStatus;
-};
-
-GonkRecorder::WrappedMediaSource::WrappedMediaSource(const sp<MediaSource> &encoder)
-    : mEncoder(encoder)
-    , mMutex("GonkRecorder::WrappedMediaSource::mMutex")
-    , mCondVar(mMutex, "GonkRecorder::WrappedMediaSource::mCondVar")
-    , mWait(false)
-    , mResume(false)
-    , mResumeStatus(UNKNOWN_ERROR)
-{
-}
-
-status_t
-GonkRecorder::WrappedMediaSource::start(MetaData *params)
-{
-    return mEncoder->start(params);
-}
-
-status_t
-GonkRecorder::WrappedMediaSource::stop()
-{
-    {
-      // Ensure the writer thread is not blocked first.
-      MutexAutoLock lock(mMutex);
-      mWait = false;
-      mCondVar.Notify();
-    }
-    return mEncoder->stop();
-}
-
-sp<MetaData>
-GonkRecorder::WrappedMediaSource::getFormat()
-{
-    return mEncoder->getFormat();
-}
-
-status_t
-GonkRecorder::WrappedMediaSource::read(MediaBuffer **buffer, const ReadOptions *options)
-{
-    MutexAutoLock lock(mMutex);
-    while (mWait) {
-      mCondVar.Wait();
-    }
-
-    status_t rv = UNKNOWN_ERROR;
-    MediaBuffer *buf = NULL;
-
-    do {
-        rv = mEncoder->read(&buf, options);
-        if (!mResume) {
-            break;
-        }
-
-        if (rv != OK || !buf) {
-            mResume = false;
-            mResumeStatus = UNKNOWN_ERROR;
-            mCondVar.Notify();
-            break;
-        }
-
-        int32_t isSync = 0;
-        buf->meta_data()->findInt32(kKeyIsSyncFrame, &isSync);
-        if (isSync) {
-            mResume = false;
-            mResumeStatus = OK;
-            mCondVar.Notify();
-            break;
-        }
-
-        buf->release();
-        buf = NULL;
-    } while(true);
-
-    *buffer = buf;
-    return rv;
-}
-
-void
-GonkRecorder::WrappedMediaSource::block()
-{
-    MutexAutoLock lock(mMutex);
-    mWait = true;
-}
-
-status_t
-GonkRecorder::WrappedMediaSource::resume()
-{
-    MutexAutoLock lock(mMutex);
-    if (!mWait) {
-        return UNKNOWN_ERROR;
-    }
-
-    mWait = false;
-    mResume = true;
-    mCondVar.Notify();
-
-    do {
-        mCondVar.Wait();
-    } while(mResume);
-
-    return mResumeStatus;
-}
-
-GonkRecorder::GonkRecorder()
-    : mWriter(NULL),
-      mOutputFd(-1),
-      mAudioSource(AUDIO_SOURCE_CNT),
-      mVideoSource(VIDEO_SOURCE_LIST_END),
-      mStarted(false) {
-
-    RE_LOGV("Constructor");
-    reset();
-}
-
-GonkRecorder::~GonkRecorder() {
-    RE_LOGV("Destructor");
-    stop();
-
-#if ANDROID_VERSION >= 21
-    if (mLooper != NULL) {
-        mLooper->stop();
-    }
-#endif
-}
-
-status_t GonkRecorder::init() {
-    RE_LOGV("init");
-#if ANDROID_VERSION >= 21
-    mLooper = new ALooper;
-    mLooper->setName("recorder_looper");
-    mLooper->start();
-#endif
-    return OK;
-}
-
-status_t GonkRecorder::setAudioSource(audio_source_t as) {
-    RE_LOGV("setAudioSource: %d", as);
-    if (as < AUDIO_SOURCE_DEFAULT ||
-        as >= AUDIO_SOURCE_CNT) {
-        RE_LOGE("Invalid audio source: %d", as);
-        return BAD_VALUE;
-    }
-
-    if (as == AUDIO_SOURCE_DEFAULT) {
-        mAudioSource = AUDIO_SOURCE_MIC;
-    } else {
-        mAudioSource = as;
-    }
-
-    return OK;
-}
-
-status_t GonkRecorder::setVideoSource(video_source vs) {
-    RE_LOGV("setVideoSource: %d", vs);
-    if (vs < VIDEO_SOURCE_DEFAULT ||
-        vs >= VIDEO_SOURCE_LIST_END) {
-        RE_LOGE("Invalid video source: %d", vs);
-        return BAD_VALUE;
-    }
-
-    if (vs == VIDEO_SOURCE_DEFAULT) {
-        mVideoSource = VIDEO_SOURCE_CAMERA;
-    } else {
-        mVideoSource = vs;
-    }
-
-    return OK;
-}
-
-status_t GonkRecorder::setOutputFormat(output_format of) {
-    RE_LOGV("setOutputFormat: %d", of);
-    if (of < OUTPUT_FORMAT_DEFAULT ||
-        of >= OUTPUT_FORMAT_LIST_END) {
-        RE_LOGE("Invalid output format: %d", of);
-        return BAD_VALUE;
-    }
-
-    if (of == OUTPUT_FORMAT_DEFAULT) {
-        mOutputFormat = OUTPUT_FORMAT_THREE_GPP;
-    } else {
-        mOutputFormat = of;
-    }
-
-    return OK;
-}
-
-status_t GonkRecorder::setAudioEncoder(audio_encoder ae) {
-    RE_LOGV("setAudioEncoder: %d", ae);
-    if (ae < AUDIO_ENCODER_DEFAULT ||
-        ae >= AUDIO_ENCODER_LIST_END) {
-        RE_LOGE("Invalid audio encoder: %d", ae);
-        return BAD_VALUE;
-    }
-
-    if (ae == AUDIO_ENCODER_DEFAULT) {
-        mAudioEncoder = AUDIO_ENCODER_AMR_NB;
-    } else {
-        mAudioEncoder = ae;
-    }
-
-    return OK;
-}
-
-status_t GonkRecorder::setVideoEncoder(video_encoder ve) {
-    RE_LOGV("setVideoEncoder: %d", ve);
-    if (ve < VIDEO_ENCODER_DEFAULT ||
-        ve >= VIDEO_ENCODER_LIST_END) {
-        RE_LOGE("Invalid video encoder: %d", ve);
-        return BAD_VALUE;
-    }
-
-    if (ve == VIDEO_ENCODER_DEFAULT) {
-        mVideoEncoder = VIDEO_ENCODER_H263;
-    } else {
-        mVideoEncoder = ve;
-    }
-
-    return OK;
-}
-
-status_t GonkRecorder::setVideoSize(int width, int height) {
-    RE_LOGV("setVideoSize: %dx%d", width, height);
-    if (width <= 0 || height <= 0) {
-        RE_LOGE("Invalid video size: %dx%d", width, height);
-        return BAD_VALUE;
-    }
-
-    // Additional check on the dimension will be performed later
-    mVideoWidth = width;
-    mVideoHeight = height;
-
-    return OK;
-}
-
-status_t GonkRecorder::setVideoFrameRate(int frames_per_second) {
-    RE_LOGV("setVideoFrameRate: %d", frames_per_second);
-    if ((frames_per_second <= 0 && frames_per_second != -1) ||
-        frames_per_second > 120) {
-        RE_LOGE("Invalid video frame rate: %d", frames_per_second);
-        return BAD_VALUE;
-    }
-
-    // Additional check on the frame rate will be performed later
-    mFrameRate = frames_per_second;
-
-    return OK;
-}
-
-status_t GonkRecorder::setOutputFile(const char *path) {
-    RE_LOGE("setOutputFile(const char*) must not be called");
-    // We don't actually support this at all, as the media_server process
-    // no longer has permissions to create files.
-
-    return -EPERM;
-}
-
-status_t GonkRecorder::setOutputFile(int fd, int64_t offset, int64_t length) {
-    RE_LOGV("setOutputFile: %d, %lld, %lld", fd, offset, length);
-    // These don't make any sense, do they?
-    CHECK_EQ(offset, 0ll);
-    CHECK_EQ(length, 0ll);
-
-    if (fd < 0) {
-        RE_LOGE("Invalid file descriptor: %d", fd);
-        return -EBADF;
-    }
-
-    if (mOutputFd >= 0) {
-        ::close(mOutputFd);
-    }
-    mOutputFd = dup(fd);
-
-    return OK;
-}
-
-// Attempt to parse an int64 literal optionally surrounded by whitespace,
-// returns true on success, false otherwise.
-static bool safe_strtoi64(const char *s, int64_t *val) {
-    char *end;
-
-    // It is lame, but according to man page, we have to set errno to 0
-    // before calling strtoll().
-    errno = 0;
-    *val = strtoll(s, &end, 10);
-
-    if (end == s || errno == ERANGE) {
-        return false;
-    }
-
-    // Skip trailing whitespace
-    while (isspace(*end)) {
-        ++end;
-    }
-
-    // For a successful return, the string must contain nothing but a valid
-    // int64 literal optionally surrounded by whitespace.
-
-    return *end == '\0';
-}
-
-// Return true if the value is in [0, 0x007FFFFFFF]
-static bool safe_strtoi32(const char *s, int32_t *val) {
-    int64_t temp;
-    if (safe_strtoi64(s, &temp)) {
-        if (temp >= 0 && temp <= 0x007FFFFFFF) {
-            *val = static_cast<int32_t>(temp);
-            return true;
-        }
-    }
-    return false;
-}
-
-// Trim both leading and trailing whitespace from the given string.
-static void TrimString(String8 *s) {
-    size_t num_bytes = s->bytes();
-    const char *data = s->string();
-
-    size_t leading_space = 0;
-    while (leading_space < num_bytes && isspace(data[leading_space])) {
-        ++leading_space;
-    }
-
-    size_t i = num_bytes;
-    while (i > leading_space && isspace(data[i - 1])) {
-        --i;
-    }
-
-    s->setTo(String8(&data[leading_space], i - leading_space));
-}
-
-status_t GonkRecorder::setParamAudioSamplingRate(int32_t sampleRate) {
-    RE_LOGV("setParamAudioSamplingRate: %d", sampleRate);
-    if (sampleRate <= 0) {
-        RE_LOGE("Invalid audio sampling rate: %d", sampleRate);
-        return BAD_VALUE;
-    }
-
-    // Additional check on the sample rate will be performed later.
-    mSampleRate = sampleRate;
-    return OK;
-}
-
-status_t GonkRecorder::setParamAudioNumberOfChannels(int32_t channels) {
-    RE_LOGV("setParamAudioNumberOfChannels: %d", channels);
-    if (channels <= 0 || channels >= 3) {
-        RE_LOGE("Invalid number of audio channels: %d", channels);
-        return BAD_VALUE;
-    }
-
-    // Additional check on the number of channels will be performed later.
-    mAudioChannels = channels;
-    return OK;
-}
-
-status_t GonkRecorder::setParamAudioEncodingBitRate(int32_t bitRate) {
-    RE_LOGV("setParamAudioEncodingBitRate: %d", bitRate);
-    if (bitRate <= 0) {
-        RE_LOGE("Invalid audio encoding bit rate: %d", bitRate);
-        return BAD_VALUE;
-    }
-
-    // The target bit rate may not be exactly the same as the requested.
-    // It depends on many factors, such as rate control, and the bit rate
-    // range that a specific encoder supports. The mismatch between the
-    // the target and requested bit rate will NOT be treated as an error.
-    mAudioBitRate = bitRate;
-    return OK;
-}
-
-status_t GonkRecorder::setParamVideoEncodingBitRate(int32_t bitRate) {
-    RE_LOGV("setParamVideoEncodingBitRate: %d", bitRate);
-    if (bitRate <= 0) {
-        RE_LOGE("Invalid video encoding bit rate: %d", bitRate);
-        return BAD_VALUE;
-    }
-
-    // The target bit rate may not be exactly the same as the requested.
-    // It depends on many factors, such as rate control, and the bit rate
-    // range that a specific encoder supports. The mismatch between the
-    // the target and requested bit rate will NOT be treated as an error.
-    mVideoBitRate = bitRate;
-    return OK;
-}
-
-// Always rotate clockwise, and only support 0, 90, 180 and 270 for now.
-status_t GonkRecorder::setParamVideoRotation(int32_t degrees) {
-    RE_LOGV("setParamVideoRotation: %d", degrees);
-    if (degrees < 0 || degrees % 90 != 0) {
-        RE_LOGE("Unsupported video rotation angle: %d", degrees);
-        return BAD_VALUE;
-    }
-    mRotationDegrees = degrees % 360;
-    return OK;
-}
-
-status_t GonkRecorder::setParamMaxFileDurationUs(int64_t timeUs) {
-    RE_LOGV("setParamMaxFileDurationUs: %lld us", timeUs);
-
-    // This is meant for backward compatibility for MediaRecorder.java
-    if (timeUs <= 0) {
-        RE_LOGW("Max file duration is not positive: %lld us. Disabling duration limit.", timeUs);
-        timeUs = 0; // Disable the duration limit for zero or negative values.
-    } else if (timeUs <= 100000LL) {  // XXX: 100 milli-seconds
-        RE_LOGE("Max file duration is too short: %lld us", timeUs);
-        return BAD_VALUE;
-    }
-
-    if (timeUs <= 15 * 1000000LL) {
-        RE_LOGW("Target duration (%lld us) too short to be respected", timeUs);
-    }
-    mMaxFileDurationUs = timeUs;
-    return OK;
-}
-
-status_t GonkRecorder::setParamMaxFileSizeBytes(int64_t bytes) {
-    RE_LOGV("setParamMaxFileSizeBytes: %lld bytes", bytes);
-
-    // This is meant for backward compatibility for MediaRecorder.java
-    if (bytes <= 0) {
-        RE_LOGW("Max file size is not positive: %lld bytes. "
-             "Disabling file size limit.", bytes);
-        bytes = 0; // Disable the file size limit for zero or negative values.
-    } else if (bytes <= 1024) {  // XXX: 1 kB
-        RE_LOGE("Max file size is too small: %lld bytes", bytes);
-        return BAD_VALUE;
-    }
-
-    if (bytes <= 100 * 1024) {
-        RE_LOGW("Target file size (%lld bytes) is too small to be respected", bytes);
-    }
-
-    if (bytes >= 0xffffffffLL) {
-        RE_LOGW("Target file size (%lld bytes) too large to be respected, clipping to 4GB", bytes);
-        bytes = 0xffffffffLL;
-    }
-
-    mMaxFileSizeBytes = bytes;
-    return OK;
-}
-
-status_t GonkRecorder::setParamInterleaveDuration(int32_t durationUs) {
-    RE_LOGV("setParamInterleaveDuration: %d", durationUs);
-    if (durationUs <= 500000) {           //  500 ms
-        // If interleave duration is too small, it is very inefficient to do
-        // interleaving since the metadata overhead will count for a significant
-        // portion of the saved contents
-        RE_LOGE("Audio/video interleave duration is too small: %d us", durationUs);
-        return BAD_VALUE;
-    } else if (durationUs >= 10000000) {  // 10 seconds
-        // If interleaving duration is too large, it can cause the recording
-        // session to use too much memory since we have to save the output
-        // data before we write them out
-        RE_LOGE("Audio/video interleave duration is too large: %d us", durationUs);
-        return BAD_VALUE;
-    }
-    mInterleaveDurationUs = durationUs;
-    return OK;
-}
-
-// If seconds <  0, only the first frame is I frame, and rest are all P frames
-// If seconds == 0, all frames are encoded as I frames. No P frames
-// If seconds >  0, it is the time spacing (seconds) between 2 neighboring I frames
-status_t GonkRecorder::setParamVideoIFramesInterval(int32_t seconds) {
-    RE_LOGV("setParamVideoIFramesInterval: %d seconds", seconds);
-    mIFramesIntervalSec = seconds;
-    return OK;
-}
-
-status_t GonkRecorder::setParam64BitFileOffset(bool use64Bit) {
-    RE_LOGV("setParam64BitFileOffset: %s",
-        use64Bit? "use 64 bit file offset": "use 32 bit file offset");
-    mUse64BitFileOffset = use64Bit;
-    return OK;
-}
-
-status_t GonkRecorder::setParamVideoCameraId(int32_t cameraId) {
-    RE_LOGV("setParamVideoCameraId: %d", cameraId);
-    if (cameraId < 0) {
-        return BAD_VALUE;
-    }
-    mCameraId = cameraId;
-    return OK;
-}
-
-status_t GonkRecorder::setParamTrackTimeStatus(int64_t timeDurationUs) {
-    RE_LOGV("setParamTrackTimeStatus: %lld", timeDurationUs);
-    if (timeDurationUs < 20000) {  // Infeasible if shorter than 20 ms?
-        RE_LOGE("Tracking time duration too short: %lld us", timeDurationUs);
-        return BAD_VALUE;
-    }
-    mTrackEveryTimeDurationUs = timeDurationUs;
-    return OK;
-}
-
-status_t GonkRecorder::setParamVideoEncoderProfile(int32_t profile) {
-    RE_LOGV("setParamVideoEncoderProfile: %d", profile);
-
-    // Additional check will be done later when we load the encoder.
-    // For now, we are accepting values defined in OpenMAX IL.
-    mVideoEncoderProfile = profile;
-    return OK;
-}
-
-status_t GonkRecorder::setParamVideoEncoderLevel(int32_t level) {
-    RE_LOGV("setParamVideoEncoderLevel: %d", level);
-
-    // Additional check will be done later when we load the encoder.
-    // For now, we are accepting values defined in OpenMAX IL.
-    mVideoEncoderLevel = level;
-    return OK;
-}
-
-status_t GonkRecorder::setParamMovieTimeScale(int32_t timeScale) {
-    RE_LOGV("setParamMovieTimeScale: %d", timeScale);
-
-    // The range is set to be the same as the audio's time scale range
-    // since audio's time scale has a wider range.
-    if (timeScale < 600 || timeScale > 96000) {
-        RE_LOGE("Time scale (%d) for movie is out of range [600, 96000]", timeScale);
-        return BAD_VALUE;
-    }
-    mMovieTimeScale = timeScale;
-    return OK;
-}
-
-status_t GonkRecorder::setParamVideoTimeScale(int32_t timeScale) {
-    RE_LOGV("setParamVideoTimeScale: %d", timeScale);
-
-    // 60000 is chosen to make sure that each video frame from a 60-fps
-    // video has 1000 ticks.
-    if (timeScale < 600 || timeScale > 60000) {
-        RE_LOGE("Time scale (%d) for video is out of range [600, 60000]", timeScale);
-        return BAD_VALUE;
-    }
-    mVideoTimeScale = timeScale;
-    return OK;
-}
-
-status_t GonkRecorder::setParamAudioTimeScale(int32_t timeScale) {
-    RE_LOGV("setParamAudioTimeScale: %d", timeScale);
-
-    // 96000 Hz is the highest sampling rate support in AAC.
-    if (timeScale < 600 || timeScale > 96000) {
-        RE_LOGE("Time scale (%d) for audio is out of range [600, 96000]", timeScale);
-        return BAD_VALUE;
-    }
-    mAudioTimeScale = timeScale;
-    return OK;
-}
-
-status_t GonkRecorder::setParamGeoDataLongitude(
-    int64_t longitudex10000) {
-
-    if (longitudex10000 > 1800000 || longitudex10000 < -1800000) {
-        return BAD_VALUE;
-    }
-    mLongitudex10000 = longitudex10000;
-    return OK;
-}
-
-status_t GonkRecorder::setParamGeoDataLatitude(
-    int64_t latitudex10000) {
-
-    if (latitudex10000 > 900000 || latitudex10000 < -900000) {
-        return BAD_VALUE;
-    }
-    mLatitudex10000 = latitudex10000;
-    return OK;
-}
-
-status_t GonkRecorder::setParameter(
-        const String8 &key, const String8 &value) {
-    RE_LOGV("setParameter: key (%s) => value (%s)", key.string(), value.string());
-    if (key == "max-duration") {
-        int64_t max_duration_ms;
-        if (safe_strtoi64(value.string(), &max_duration_ms)) {
-            return setParamMaxFileDurationUs(1000LL * max_duration_ms);
-        }
-    } else if (key == "max-filesize") {
-        int64_t max_filesize_bytes;
-        if (safe_strtoi64(value.string(), &max_filesize_bytes)) {
-            return setParamMaxFileSizeBytes(max_filesize_bytes);
-        }
-    } else if (key == "interleave-duration-us") {
-        int32_t durationUs;
-        if (safe_strtoi32(value.string(), &durationUs)) {
-            return setParamInterleaveDuration(durationUs);
-        }
-    } else if (key == "param-movie-time-scale") {
-        int32_t timeScale;
-        if (safe_strtoi32(value.string(), &timeScale)) {
-            return setParamMovieTimeScale(timeScale);
-        }
-    } else if (key == "param-use-64bit-offset") {
-        int32_t use64BitOffset;
-        if (safe_strtoi32(value.string(), &use64BitOffset)) {
-            return setParam64BitFileOffset(use64BitOffset != 0);
-        }
-    } else if (key == "param-geotag-longitude") {
-        int64_t longitudex10000;
-        if (safe_strtoi64(value.string(), &longitudex10000)) {
-            return setParamGeoDataLongitude(longitudex10000);
-        }
-    } else if (key == "param-geotag-latitude") {
-        int64_t latitudex10000;
-        if (safe_strtoi64(value.string(), &latitudex10000)) {
-            return setParamGeoDataLatitude(latitudex10000);
-        }
-    } else if (key == "param-track-time-status") {
-        int64_t timeDurationUs;
-        if (safe_strtoi64(value.string(), &timeDurationUs)) {
-            return setParamTrackTimeStatus(timeDurationUs);
-        }
-    } else if (key == "audio-param-sampling-rate") {
-        int32_t sampling_rate;
-        if (safe_strtoi32(value.string(), &sampling_rate)) {
-            return setParamAudioSamplingRate(sampling_rate);
-        }
-    } else if (key == "audio-param-number-of-channels") {
-        int32_t number_of_channels;
-        if (safe_strtoi32(value.string(), &number_of_channels)) {
-            return setParamAudioNumberOfChannels(number_of_channels);
-        }
-    } else if (key == "audio-param-encoding-bitrate") {
-        int32_t audio_bitrate;
-        if (safe_strtoi32(value.string(), &audio_bitrate)) {
-            return setParamAudioEncodingBitRate(audio_bitrate);
-        }
-    } else if (key == "audio-param-time-scale") {
-        int32_t timeScale;
-        if (safe_strtoi32(value.string(), &timeScale)) {
-            return setParamAudioTimeScale(timeScale);
-        }
-    } else if (key == "video-param-encoding-bitrate") {
-        int32_t video_bitrate;
-        if (safe_strtoi32(value.string(), &video_bitrate)) {
-            return setParamVideoEncodingBitRate(video_bitrate);
-        }
-    } else if (key == "video-param-rotation-angle-degrees") {
-        int32_t degrees;
-        if (safe_strtoi32(value.string(), &degrees)) {
-            return setParamVideoRotation(degrees);
-        }
-    } else if (key == "video-param-i-frames-interval") {
-        int32_t seconds;
-        if (safe_strtoi32(value.string(), &seconds)) {
-            return setParamVideoIFramesInterval(seconds);
-        }
-    } else if (key == "video-param-encoder-profile") {
-        int32_t profile;
-        if (safe_strtoi32(value.string(), &profile)) {
-            return setParamVideoEncoderProfile(profile);
-        }
-    } else if (key == "video-param-encoder-level") {
-        int32_t level;
-        if (safe_strtoi32(value.string(), &level)) {
-            return setParamVideoEncoderLevel(level);
-        }
-    } else if (key == "video-param-camera-id") {
-        int32_t cameraId;
-        if (safe_strtoi32(value.string(), &cameraId)) {
-            return setParamVideoCameraId(cameraId);
-        }
-    } else if (key == "video-param-time-scale") {
-        int32_t timeScale;
-        if (safe_strtoi32(value.string(), &timeScale)) {
-            return setParamVideoTimeScale(timeScale);
-        }
-    } else {
-        RE_LOGE("setParameter: failed to find key %s", key.string());
-    }
-    return BAD_VALUE;
-}
-
-status_t GonkRecorder::setParameters(const String8 &params) {
-    RE_LOGV("setParameters: %s", params.string());
-    const char *cparams = params.string();
-    const char *key_start = cparams;
-    for (;;) {
-        const char *equal_pos = strchr(key_start, '=');
-        if (equal_pos == NULL) {
-            RE_LOGE("Parameters %s miss a value", cparams);
-            return BAD_VALUE;
-        }
-        String8 key(key_start, equal_pos - key_start);
-        TrimString(&key);
-        if (key.length() == 0) {
-            RE_LOGE("Parameters %s contains an empty key", cparams);
-            return BAD_VALUE;
-        }
-        const char *value_start = equal_pos + 1;
-        const char *semicolon_pos = strchr(value_start, ';');
-        String8 value;
-        if (semicolon_pos == NULL) {
-            value.setTo(value_start);
-        } else {
-            value.setTo(value_start, semicolon_pos - value_start);
-        }
-        if (setParameter(key, value) != OK) {
-            return BAD_VALUE;
-        }
-        if (semicolon_pos == NULL) {
-            break;  // Reaches the end
-        }
-        key_start = semicolon_pos + 1;
-    }
-    return OK;
-}
-
-status_t GonkRecorder::setListener(const sp<IMediaRecorderClient> &listener) {
-    mListener = listener;
-
-    return OK;
-}
-
-status_t GonkRecorder::setClientName(const String16& clientName) {
-    mClientName = clientName;
-
-    return OK;
-}
-
-status_t GonkRecorder::prepare() {
-    if (mVideoSource != VIDEO_SOURCE_LIST_END && mVideoEncoder != VIDEO_ENCODER_LIST_END &&
-        mVideoHeight && mVideoWidth &&  // Video recording
-        (mVideoHeight * mVideoWidth >= RES_720P)) {
-        // TODO: Above check needs to be updated when mMaxFileDurationUs is set from camera app
-        RE_LOGV("Video is high resolution so setting 64-bit file offsets");
-        setParam64BitFileOffset(true);
-    }
-    return OK;
-}
-
-status_t GonkRecorder::start() {
-    CHECK_GE(mOutputFd, 0);
-
-    // Get UID here for permission checking
-    mClientUid = IPCThreadState::self()->getCallingUid();
-    if (mWriter != NULL) {
-        RE_LOGE("File writer is not avaialble");
-        return UNKNOWN_ERROR;
-    }
-
-    status_t status = OK;
-
-    switch (mOutputFormat) {
-        case OUTPUT_FORMAT_DEFAULT:
-        case OUTPUT_FORMAT_THREE_GPP:
-        case OUTPUT_FORMAT_MPEG_4:
-            status = startMPEG4Recording();
-            break;
-
-        case OUTPUT_FORMAT_AMR_NB:
-        case OUTPUT_FORMAT_AMR_WB:
-            status = startAMRRecording();
-            break;
-
-#if defined(MOZ_WIDGET_GONK) && ANDROID_VERSION >= 17
-        case OUTPUT_FORMAT_AAC_ADIF:
-        case OUTPUT_FORMAT_AAC_ADTS:
-            status = startAACRecording();
-            break;
-#endif
-
-        case OUTPUT_FORMAT_RTP_AVP:
-            status = startRTPRecording();
-            break;
-
-        case OUTPUT_FORMAT_MPEG2TS:
-            status = startMPEG2TSRecording();
-            break;
-
-        default:
-            RE_LOGE("Unsupported output file format: %d", mOutputFormat);
-            status = UNKNOWN_ERROR;
-            break;
-    }
-
-    if ((status == OK) && (!mStarted)) {
-        mStarted = true;
-    }
-
-    return status;
-}
-
-#if defined(MOZ_WIDGET_GONK) && ANDROID_VERSION >= 21
-sp<MediaSource> GonkRecorder::createAudioSource() {
-    sp<AudioSource> audioSource =
-        new AudioSource(
-                mAudioSource,
-                mSampleRate,
-                mAudioChannels);
-
-    status_t err = audioSource->initCheck();
-
-    if (err != OK) {
-        RE_LOGE("audio source is not initialized");
-        return NULL;
-    }
-
-    sp<AMessage> format = new AMessage;
-    switch (mAudioEncoder) {
-        case AUDIO_ENCODER_AMR_NB:
-        case AUDIO_ENCODER_DEFAULT:
-            format->setString("mime", MEDIA_MIMETYPE_AUDIO_AMR_NB);
-            break;
-        case AUDIO_ENCODER_AMR_WB:
-            format->setString("mime", MEDIA_MIMETYPE_AUDIO_AMR_WB);
-            break;
-        case AUDIO_ENCODER_AAC:
-            format->setString("mime", MEDIA_MIMETYPE_AUDIO_AAC);
-            format->setInt32("aac-profile", OMX_AUDIO_AACObjectLC);
-            break;
-        case AUDIO_ENCODER_HE_AAC:
-            format->setString("mime", MEDIA_MIMETYPE_AUDIO_AAC);
-            format->setInt32("aac-profile", OMX_AUDIO_AACObjectHE);
-            break;
-        case AUDIO_ENCODER_AAC_ELD:
-            format->setString("mime", MEDIA_MIMETYPE_AUDIO_AAC);
-            format->setInt32("aac-profile", OMX_AUDIO_AACObjectELD);
-            break;
-
-        default:
-            RE_LOGE("Unknown audio encoder: %d", mAudioEncoder);
-            return NULL;
-    }
-
-    int32_t maxInputSize;
-    CHECK(audioSource->getFormat()->findInt32(
-                kKeyMaxInputSize, &maxInputSize));
-
-    format->setInt32("max-input-size", maxInputSize);
-    format->setInt32("channel-count", mAudioChannels);
-    format->setInt32("sample-rate", mSampleRate);
-    format->setInt32("bitrate", mAudioBitRate);
-    if (mAudioTimeScale > 0) {
-        format->setInt32("time-scale", mAudioTimeScale);
-    }
-
-    sp<MediaSource> audioEncoder =
-            MediaCodecSource::Create(mLooper, format, audioSource);
-    mAudioSourceNode = audioSource;
-
-    if (audioEncoder == NULL) {
-        RE_LOGE("Failed to create audio encoder");
-    }
-
-    return audioEncoder;
-}
-#else
-sp<MediaSource> GonkRecorder::createAudioSource() {
-    sp<AudioSource> audioSource =
-        new AudioSource(
-                mAudioSource,
-                mSampleRate,
-                mAudioChannels);
-
-    status_t err = audioSource->initCheck();
-
-    if (err != OK) {
-        RE_LOGE("audio source is not initialized");
-        return NULL;
-    }
-
-    sp<MetaData> encMeta = new MetaData;
-    const char *mime;
-    switch (mAudioEncoder) {
-        case AUDIO_ENCODER_AMR_NB:
-        case AUDIO_ENCODER_DEFAULT:
-            mime = MEDIA_MIMETYPE_AUDIO_AMR_NB;
-            break;
-        case AUDIO_ENCODER_AMR_WB:
-            mime = MEDIA_MIMETYPE_AUDIO_AMR_WB;
-            break;
-#if defined(MOZ_WIDGET_GONK) && ANDROID_VERSION >= 17
-        case AUDIO_ENCODER_AAC:
-            mime = MEDIA_MIMETYPE_AUDIO_AAC;
-            encMeta->setInt32(kKeyAACProfile, OMX_AUDIO_AACObjectLC);
-            break;
-        case AUDIO_ENCODER_HE_AAC:
-            mime = MEDIA_MIMETYPE_AUDIO_AAC;
-            encMeta->setInt32(kKeyAACProfile, OMX_AUDIO_AACObjectHE);
-            break;
-        case AUDIO_ENCODER_AAC_ELD:
-            mime = MEDIA_MIMETYPE_AUDIO_AAC;
-            encMeta->setInt32(kKeyAACProfile, OMX_AUDIO_AACObjectELD);
-            break;
-#endif
-        default:
-            RE_LOGE("Unknown audio encoder: %d", mAudioEncoder);
-            return NULL;
-    }
-    encMeta->setCString(kKeyMIMEType, mime);
-
-    int32_t maxInputSize;
-    CHECK(audioSource->getFormat()->findInt32(
-                kKeyMaxInputSize, &maxInputSize));
-
-    encMeta->setInt32(kKeyMaxInputSize, maxInputSize);
-    encMeta->setInt32(kKeyChannelCount, mAudioChannels);
-    encMeta->setInt32(kKeySampleRate, mSampleRate);
-    encMeta->setInt32(kKeyBitRate, mAudioBitRate);
-    if (mAudioTimeScale > 0) {
-        encMeta->setInt32(kKeyTimeScale, mAudioTimeScale);
-    }
-
-    // OMXClient::connect() always returns OK and abort's fatally if
-    // it can't connect.
-    OMXClient client;
-    // CHECK_EQ causes an abort if the given condition fails.
-    CHECK_EQ(client.connect(), (status_t)OK);
-    sp<MediaSource> audioEncoder =
-        OMXCodec::Create(client.interface(), encMeta,
-                         true /* createEncoder */, audioSource);
-    mAudioSourceNode = audioSource;
-
-    return audioEncoder;
-}
-#endif
-
-#if defined(MOZ_WIDGET_GONK) && ANDROID_VERSION >= 17
-status_t GonkRecorder::startAACRecording() {
-    // FIXME:
-    // Add support for OUTPUT_FORMAT_AAC_ADIF
-    CHECK_EQ(mOutputFormat, OUTPUT_FORMAT_AAC_ADTS);
-
-    CHECK(mAudioEncoder == AUDIO_ENCODER_AAC ||
-          mAudioEncoder == AUDIO_ENCODER_HE_AAC ||
-          mAudioEncoder == AUDIO_ENCODER_AAC_ELD);
-    CHECK(mAudioSource != AUDIO_SOURCE_CNT);
-
-    mWriter = new AACWriter(mOutputFd);
-    status_t status = startRawAudioRecording();
-    if (status != OK) {
-        mWriter.clear();
-        mWriter = NULL;
-    }
-
-    return status;
-}
-#endif
-
-status_t GonkRecorder::startAMRRecording() {
-    CHECK(mOutputFormat == OUTPUT_FORMAT_AMR_NB ||
-          mOutputFormat == OUTPUT_FORMAT_AMR_WB);
-
-    if (mOutputFormat == OUTPUT_FORMAT_AMR_NB) {
-        if (mAudioEncoder != AUDIO_ENCODER_DEFAULT &&
-            mAudioEncoder != AUDIO_ENCODER_AMR_NB) {
-            RE_LOGE("Invalid encoder %d used for AMRNB recording",
-                    mAudioEncoder);
-            return BAD_VALUE;
-        }
-    } else {  // mOutputFormat must be OUTPUT_FORMAT_AMR_WB
-        if (mAudioEncoder != AUDIO_ENCODER_AMR_WB) {
-            RE_LOGE("Invlaid encoder %d used for AMRWB recording",
-                    mAudioEncoder);
-            return BAD_VALUE;
-        }
-    }
-
-    mWriter = new AMRWriter(mOutputFd);
-    status_t status = startRawAudioRecording();
-    if (status != OK) {
-        mWriter.clear();
-        mWriter = NULL;
-    }
-    return status;
-}
-
-status_t GonkRecorder::startRawAudioRecording() {
-    if (mAudioSource >= AUDIO_SOURCE_CNT) {
-        RE_LOGE("Invalid audio source: %d", mAudioSource);
-        return BAD_VALUE;
-    }
-
-    status_t status = BAD_VALUE;
-    if (OK != (status = checkAudioEncoderCapabilities())) {
-        return status;
-    }
-
-    sp<MediaSource> audioEncoder = createAudioSource();
-    if (audioEncoder == NULL) {
-        return UNKNOWN_ERROR;
-    }
-
-    CHECK(mWriter != 0);
-    mWriter->addSource(audioEncoder);
-
-    if (mMaxFileDurationUs != 0) {
-        mWriter->setMaxFileDuration(mMaxFileDurationUs);
-    }
-    if (mMaxFileSizeBytes != 0) {
-        mWriter->setMaxFileSize(mMaxFileSizeBytes);
-    }
-    mWriter->setListener(mListener);
-    mWriter->start();
-
-    return OK;
-}
-
-status_t GonkRecorder::startRTPRecording() {
-    return INVALID_OPERATION;
-}
-
-status_t GonkRecorder::startMPEG2TSRecording() {
-    CHECK_EQ(mOutputFormat, OUTPUT_FORMAT_MPEG2TS);
-
-    sp<MediaWriter> writer = new MPEG2TSWriter(mOutputFd);
-
-    if (mAudioSource != AUDIO_SOURCE_CNT) {
-#if defined(MOZ_WIDGET_GONK) && ANDROID_VERSION >= 17
-        if (mAudioEncoder != AUDIO_ENCODER_AAC &&
-            mAudioEncoder != AUDIO_ENCODER_HE_AAC &&
-            mAudioEncoder != AUDIO_ENCODER_AAC_ELD) {
-            return ERROR_UNSUPPORTED;
-        }
-#endif
-        status_t err = setupAudioEncoder(writer);
-
-        if (err != OK) {
-            return err;
-        }
-    }
-
-    if (mVideoSource < VIDEO_SOURCE_LIST_END) {
-        if (mVideoEncoder != VIDEO_ENCODER_H264) {
-            return ERROR_UNSUPPORTED;
-        }
-
-        sp<MediaSource> mediaSource;
-        status_t err = setupMediaSource(&mediaSource);
-        if (err != OK) {
-            return err;
-        }
-
-        sp<MediaSource> encoder;
-        err = setupVideoEncoder(mediaSource, mVideoBitRate, &encoder);
-
-        if (err != OK) {
-            return err;
-        }
-
-        writer->addSource(encoder);
-    }
-
-    if (mMaxFileDurationUs != 0) {
-        writer->setMaxFileDuration(mMaxFileDurationUs);
-    }
-
-    if (mMaxFileSizeBytes != 0) {
-        writer->setMaxFileSize(mMaxFileSizeBytes);
-    }
-
-    mWriter = writer;
-
-    return mWriter->start();
-}
-
-void GonkRecorder::clipVideoFrameRate() {
-    RE_LOGV("clipVideoFrameRate: encoder %d", mVideoEncoder);
-    int minFrameRate = mEncoderProfiles->getVideoEncoderParamByName(
-                        "enc.vid.fps.min", mVideoEncoder);
-    int maxFrameRate = mEncoderProfiles->getVideoEncoderParamByName(
-                        "enc.vid.fps.max", mVideoEncoder);
-    if (mFrameRate < minFrameRate && minFrameRate != -1) {
-        RE_LOGW("Intended video encoding frame rate (%d fps) is too small"
-             " and will be set to (%d fps)", mFrameRate, minFrameRate);
-        mFrameRate = minFrameRate;
-    } else if (mFrameRate > maxFrameRate && maxFrameRate != -1) {
-        RE_LOGW("Intended video encoding frame rate (%d fps) is too large"
-             " and will be set to (%d fps)", mFrameRate, maxFrameRate);
-        mFrameRate = maxFrameRate;
-    }
-}
-
-void GonkRecorder::clipVideoBitRate() {
-    RE_LOGV("clipVideoBitRate: encoder %d", mVideoEncoder);
-    int minBitRate = mEncoderProfiles->getVideoEncoderParamByName(
-                        "enc.vid.bps.min", mVideoEncoder);
-    int maxBitRate = mEncoderProfiles->getVideoEncoderParamByName(
-                        "enc.vid.bps.max", mVideoEncoder);
-    if (mVideoBitRate < minBitRate && minBitRate != -1) {
-        RE_LOGW("Intended video encoding bit rate (%d bps) is too small"
-             " and will be set to (%d bps)", mVideoBitRate, minBitRate);
-        mVideoBitRate = minBitRate;
-    } else if (mVideoBitRate > maxBitRate && maxBitRate != -1) {
-        RE_LOGW("Intended video encoding bit rate (%d bps) is too large"
-             " and will be set to (%d bps)", mVideoBitRate, maxBitRate);
-        mVideoBitRate = maxBitRate;
-    }
-}
-
-void GonkRecorder::clipVideoFrameWidth() {
-    RE_LOGV("clipVideoFrameWidth: encoder %d", mVideoEncoder);
-    int minFrameWidth = mEncoderProfiles->getVideoEncoderParamByName(
-                        "enc.vid.width.min", mVideoEncoder);
-    int maxFrameWidth = mEncoderProfiles->getVideoEncoderParamByName(
-                        "enc.vid.width.max", mVideoEncoder);
-    if (mVideoWidth < minFrameWidth && minFrameWidth != -1) {
-        RE_LOGW("Intended video encoding frame width (%d) is too small"
-             " and will be set to (%d)", mVideoWidth, minFrameWidth);
-        mVideoWidth = minFrameWidth;
-    } else if (mVideoWidth > maxFrameWidth && maxFrameWidth != -1) {
-        RE_LOGW("Intended video encoding frame width (%d) is too large"
-             " and will be set to (%d)", mVideoWidth, maxFrameWidth);
-        mVideoWidth = maxFrameWidth;
-    }
-}
-
-status_t GonkRecorder::checkVideoEncoderCapabilities() {
-
-    // Dont clip for time lapse capture as encoder will have enough
-    // time to encode because of slow capture rate of time lapse.
-    clipVideoBitRate();
-    clipVideoFrameRate();
-    clipVideoFrameWidth();
-    clipVideoFrameHeight();
-    setDefaultProfileIfNecessary();
-    return OK;
-}
-
-// Set to use AVC baseline profile if the encoding parameters matches
-// CAMCORDER_QUALITY_LOW profile; this is for the sake of MMS service.
-void GonkRecorder::setDefaultProfileIfNecessary() {
-    RE_LOGV("setDefaultProfileIfNecessary");
-
-    camcorder_quality quality = CAMCORDER_QUALITY_LOW;
-
-    int64_t durationUs   = mEncoderProfiles->getCamcorderProfileParamByName(
-                                "duration", mCameraId, quality) * 1000000LL;
-
-    int fileFormat       = mEncoderProfiles->getCamcorderProfileParamByName(
-                                "file.format", mCameraId, quality);
-
-    int videoCodec       = mEncoderProfiles->getCamcorderProfileParamByName(
-                                "vid.codec", mCameraId, quality);
-
-    int videoBitRate     = mEncoderProfiles->getCamcorderProfileParamByName(
-                                "vid.bps", mCameraId, quality);
-
-    int videoFrameRate   = mEncoderProfiles->getCamcorderProfileParamByName(
-                                "vid.fps", mCameraId, quality);
-
-    int videoFrameWidth  = mEncoderProfiles->getCamcorderProfileParamByName(
-                                "vid.width", mCameraId, quality);
-
-    int videoFrameHeight = mEncoderProfiles->getCamcorderProfileParamByName(
-                                "vid.height", mCameraId, quality);
-
-    int audioCodec       = mEncoderProfiles->getCamcorderProfileParamByName(
-                                "aud.codec", mCameraId, quality);
-
-    int audioBitRate     = mEncoderProfiles->getCamcorderProfileParamByName(
-                                "aud.bps", mCameraId, quality);
-
-    int audioSampleRate  = mEncoderProfiles->getCamcorderProfileParamByName(
-                                "aud.hz", mCameraId, quality);
-
-    int audioChannels    = mEncoderProfiles->getCamcorderProfileParamByName(
-                                "aud.ch", mCameraId, quality);
-
-    if (durationUs == mMaxFileDurationUs &&
-        fileFormat == mOutputFormat &&
-        videoCodec == mVideoEncoder &&
-        videoBitRate == mVideoBitRate &&
-        videoFrameRate == mFrameRate &&
-        videoFrameWidth == mVideoWidth &&
-        videoFrameHeight == mVideoHeight &&
-        audioCodec == mAudioEncoder &&
-        audioBitRate == mAudioBitRate &&
-        audioSampleRate == mSampleRate &&
-        audioChannels == mAudioChannels) {
-        if (videoCodec == VIDEO_ENCODER_H264) {
-            RE_LOGI("Force to use AVC baseline profile");
-            setParamVideoEncoderProfile(OMX_VIDEO_AVCProfileBaseline);
-        }
-    }
-}
-
-status_t GonkRecorder::checkAudioEncoderCapabilities() {
-    clipAudioBitRate();
-    clipAudioSampleRate();
-    clipNumberOfAudioChannels();
-    return OK;
-}
-
-void GonkRecorder::clipAudioBitRate() {
-    RE_LOGV("clipAudioBitRate: encoder %d", mAudioEncoder);
-
-    int minAudioBitRate =
-            mEncoderProfiles->getAudioEncoderParamByName(
-                "enc.aud.bps.min", mAudioEncoder);
-    if (minAudioBitRate != -1 && mAudioBitRate < minAudioBitRate) {
-        RE_LOGW("Intended audio encoding bit rate (%d) is too small"
-            " and will be set to (%d)", mAudioBitRate, minAudioBitRate);
-        mAudioBitRate = minAudioBitRate;
-    }
-
-    int maxAudioBitRate =
-            mEncoderProfiles->getAudioEncoderParamByName(
-                "enc.aud.bps.max", mAudioEncoder);
-    if (maxAudioBitRate != -1 && mAudioBitRate > maxAudioBitRate) {
-        RE_LOGW("Intended audio encoding bit rate (%d) is too large"
-            " and will be set to (%d)", mAudioBitRate, maxAudioBitRate);
-        mAudioBitRate = maxAudioBitRate;
-    }
-}
-
-void GonkRecorder::clipAudioSampleRate() {
-    RE_LOGV("clipAudioSampleRate: encoder %d", mAudioEncoder);
-
-    int minSampleRate =
-            mEncoderProfiles->getAudioEncoderParamByName(
-                "enc.aud.hz.min", mAudioEncoder);
-    if (minSampleRate != -1 && mSampleRate < minSampleRate) {
-        RE_LOGW("Intended audio sample rate (%d) is too small"
-            " and will be set to (%d)", mSampleRate, minSampleRate);
-        mSampleRate = minSampleRate;
-    }
-
-    int maxSampleRate =
-            mEncoderProfiles->getAudioEncoderParamByName(
-                "enc.aud.hz.max", mAudioEncoder);
-    if (maxSampleRate != -1 && mSampleRate > maxSampleRate) {
-        RE_LOGW("Intended audio sample rate (%d) is too large"
-            " and will be set to (%d)", mSampleRate, maxSampleRate);
-        mSampleRate = maxSampleRate;
-    }
-}
-
-void GonkRecorder::clipNumberOfAudioChannels() {
-    RE_LOGV("clipNumberOfAudioChannels: encoder %d", mAudioEncoder);
-
-    int minChannels =
-            mEncoderProfiles->getAudioEncoderParamByName(
-                "enc.aud.ch.min", mAudioEncoder);
-    if (minChannels != -1 && mAudioChannels < minChannels) {
-        RE_LOGW("Intended number of audio channels (%d) is too small"
-            " and will be set to (%d)", mAudioChannels, minChannels);
-        mAudioChannels = minChannels;
-    }
-
-    int maxChannels =
-            mEncoderProfiles->getAudioEncoderParamByName(
-                "enc.aud.ch.max", mAudioEncoder);
-    if (maxChannels != -1 && mAudioChannels > maxChannels) {
-        RE_LOGW("Intended number of audio channels (%d) is too large"
-            " and will be set to (%d)", mAudioChannels, maxChannels);
-        mAudioChannels = maxChannels;
-    }
-}
-
-void GonkRecorder::clipVideoFrameHeight() {
-    RE_LOGV("clipVideoFrameHeight: encoder %d", mVideoEncoder);
-    int minFrameHeight = mEncoderProfiles->getVideoEncoderParamByName(
-                        "enc.vid.height.min", mVideoEncoder);
-    int maxFrameHeight = mEncoderProfiles->getVideoEncoderParamByName(
-                        "enc.vid.height.max", mVideoEncoder);
-    if (minFrameHeight != -1 && mVideoHeight < minFrameHeight) {
-        RE_LOGW("Intended video encoding frame height (%d) is too small"
-             " and will be set to (%d)", mVideoHeight, minFrameHeight);
-        mVideoHeight = minFrameHeight;
-    } else if (maxFrameHeight != -1 && mVideoHeight > maxFrameHeight) {
-        RE_LOGW("Intended video encoding frame height (%d) is too large"
-             " and will be set to (%d)", mVideoHeight, maxFrameHeight);
-        mVideoHeight = maxFrameHeight;
-    }
-}
-
-// Set up the appropriate MediaSource depending on the chosen option
-status_t GonkRecorder::setupMediaSource(
-                      sp<MediaSource> *mediaSource) {
-    if (mVideoSource == VIDEO_SOURCE_DEFAULT
-            || mVideoSource == VIDEO_SOURCE_CAMERA) {
-        sp<GonkCameraSource> cameraSource;
-        status_t err = setupCameraSource(&cameraSource);
-        if (err != OK) {
-            return err;
-        }
-        *mediaSource = cameraSource;
-#if ANDROID_VERSION >= 21
-    } else if (mVideoSource == VIDEO_SOURCE_SURFACE) {
-#else
-    } else if (mVideoSource == VIDEO_SOURCE_GRALLOC_BUFFER) {
-#endif
-        return BAD_VALUE;
-    } else {
-        return INVALID_OPERATION;
-    }
-    return OK;
-}
-
-status_t GonkRecorder::setupCameraSource(
-        sp<GonkCameraSource> *cameraSource) {
-    status_t err = OK;
-    if ((err = checkVideoEncoderCapabilities()) != OK) {
-        return err;
-    }
-    Size videoSize;
-    videoSize.width = mVideoWidth;
-    videoSize.height = mVideoHeight;
-    bool useMeta = true;
-    char value[PROPERTY_VALUE_MAX];
-    if (property_get("debug.camcorder.disablemeta", value, NULL) &&
-            atoi(value)) {
-      useMeta = false;
-    }
-
-    *cameraSource = GonkCameraSource::Create(
-                mCameraHw, videoSize, mFrameRate, useMeta);
-    if (*cameraSource == NULL) {
-        return UNKNOWN_ERROR;
-    }
-
-    if ((*cameraSource)->initCheck() != OK) {
-        (*cameraSource).clear();
-        *cameraSource = NULL;
-        return NO_INIT;
-    }
-
-    // When frame rate is not set, the actual frame rate will be set to
-    // the current frame rate being used.
-    if (mFrameRate == -1) {
-        int32_t frameRate = 0;
-        CHECK ((*cameraSource)->getFormat()->findInt32(
-                    kKeyFrameRate, &frameRate));
-        RE_LOGI("Frame rate is not explicitly set. Use the current frame "
-             "rate (%d fps)", frameRate);
-        mFrameRate = frameRate;
-    }
-
-    CHECK(mFrameRate != -1);
-
-    mIsMetaDataStoredInVideoBuffers =
-        (*cameraSource)->isMetaDataStoredInVideoBuffers();
-
-    return OK;
-}
-
-#if defined(MOZ_WIDGET_GONK) && ANDROID_VERSION >= 21
-status_t GonkRecorder::setupVideoEncoder(
-        sp<MediaSource> cameraSource,
-        int32_t videoBitRate,
-        sp<MediaSource> *source) {
-    source->clear();
-
-    sp<AMessage> format = new AMessage();
-
-    switch (mVideoEncoder) {
-        case VIDEO_ENCODER_H263:
-            format->setString("mime", MEDIA_MIMETYPE_VIDEO_H263);
-            break;
-
-        case VIDEO_ENCODER_MPEG_4_SP:
-            format->setString("mime", MEDIA_MIMETYPE_VIDEO_MPEG4);
-            break;
-
-        case VIDEO_ENCODER_H264:
-            format->setString("mime", MEDIA_MIMETYPE_VIDEO_AVC);
-            break;
-
-        case VIDEO_ENCODER_VP8:
-            format->setString("mime", MEDIA_MIMETYPE_VIDEO_VP8);
-            break;
-
-        default:
-            CHECK(!"Should not be here, unsupported video encoding.");
-            break;
-    }
-
-    sp<MetaData> meta = cameraSource->getFormat();
-
-    int32_t width, height, stride, sliceHeight, colorFormat;
-    CHECK(meta->findInt32(kKeyWidth, &width));
-    CHECK(meta->findInt32(kKeyHeight, &height));
-    CHECK(meta->findInt32(kKeyStride, &stride));
-    CHECK(meta->findInt32(kKeySliceHeight, &sliceHeight));
-    CHECK(meta->findInt32(kKeyColorFormat, &colorFormat));
-
-    format->setInt32("width", width);
-    format->setInt32("height", height);
-    format->setInt32("stride", stride);
-    format->setInt32("slice-height", sliceHeight);
-    format->setInt32("color-format", colorFormat);
-
-    format->setInt32("bitrate", videoBitRate);
-    format->setInt32("frame-rate", mFrameRate);
-    format->setInt32("i-frame-interval", mIFramesIntervalSec);
-
-    if (mVideoTimeScale > 0) {
-        format->setInt32("time-scale", mVideoTimeScale);
-    }
-    if (mVideoEncoderProfile != -1) {
-        format->setInt32("profile", mVideoEncoderProfile);
-    }
-    if (mVideoEncoderLevel != -1) {
-        format->setInt32("level", mVideoEncoderLevel);
-    }
-
-    uint32_t flags = 0;
-    if (mIsMetaDataStoredInVideoBuffers) {
-        flags |= MediaCodecSource::FLAG_USE_METADATA_INPUT;
-    }
-
-    sp<MediaCodecSource> encoder =
-            MediaCodecSource::Create(mLooper, format, cameraSource, flags);
-    if (encoder == NULL) {
-        RE_LOGE("Failed to create video encoder");
-        // When the encoder fails to be created, we need
-        // release the camera source due to the camera's lock
-        // and unlock mechanism.
-        cameraSource->stop();
-        return UNKNOWN_ERROR;
-    }
-
-    *source = encoder;
-
-    return OK;
-}
-#else
-status_t GonkRecorder::setupVideoEncoder(
-        sp<MediaSource> cameraSource,
-        int32_t videoBitRate,
-        sp<MediaSource> *source) {
-    source->clear();
-
-    sp<MetaData> enc_meta = new MetaData;
-    enc_meta->setInt32(kKeyBitRate, videoBitRate);
-    enc_meta->setInt32(kKeyFrameRate, mFrameRate);
-
-    switch (mVideoEncoder) {
-        case VIDEO_ENCODER_H263:
-            enc_meta->setCString(kKeyMIMEType, MEDIA_MIMETYPE_VIDEO_H263);
-            break;
-
-        case VIDEO_ENCODER_MPEG_4_SP:
-            enc_meta->setCString(kKeyMIMEType, MEDIA_MIMETYPE_VIDEO_MPEG4);
-            break;
-
-        case VIDEO_ENCODER_H264:
-            enc_meta->setCString(kKeyMIMEType, MEDIA_MIMETYPE_VIDEO_AVC);
-            break;
-
-        default:
-            CHECK(!"Should not be here, unsupported video encoding.");
-            break;
-    }
-
-    sp<MetaData> meta = cameraSource->getFormat();
-
-    int32_t width, height, stride, sliceHeight, colorFormat;
-    CHECK(meta->findInt32(kKeyWidth, &width));
-    CHECK(meta->findInt32(kKeyHeight, &height));
-    CHECK(meta->findInt32(kKeyStride, &stride));
-    CHECK(meta->findInt32(kKeySliceHeight, &sliceHeight));
-    CHECK(meta->findInt32(kKeyColorFormat, &colorFormat));
-
-    enc_meta->setInt32(kKeyWidth, width);
-    enc_meta->setInt32(kKeyHeight, height);
-    enc_meta->setInt32(kKeyIFramesInterval, mIFramesIntervalSec);
-    enc_meta->setInt32(kKeyStride, stride);
-    enc_meta->setInt32(kKeySliceHeight, sliceHeight);
-    enc_meta->setInt32(kKeyColorFormat, colorFormat);
-    if (mVideoTimeScale > 0) {
-        enc_meta->setInt32(kKeyTimeScale, mVideoTimeScale);
-    }
-    if (mVideoEncoderProfile != -1) {
-        enc_meta->setInt32(kKeyVideoProfile, mVideoEncoderProfile);
-    }
-    if (mVideoEncoderLevel != -1) {
-        enc_meta->setInt32(kKeyVideoLevel, mVideoEncoderLevel);
-    }
-
-    // OMXClient::connect() always returns OK and abort's fatally if
-    // it can't connect.
-    OMXClient client;
-    // CHECK_EQ causes an abort if the given condition fails.
-    CHECK_EQ(client.connect(), (status_t)OK);
-
-    uint32_t encoder_flags = mCameraHw->IsEmulated()
-                             ? 0
-                             : OMXCodec::kHardwareCodecsOnly;
-    if (mIsMetaDataStoredInVideoBuffers) {
-#if defined(MOZ_WIDGET_GONK) && ANDROID_VERSION >= 17
-        encoder_flags |= OMXCodec::kStoreMetaDataInVideoBuffers;
-#else
-        encoder_flags |= OMXCodec::kStoreMetaDataInVideoBuffers;
-        encoder_flags |= OMXCodec::kOnlySubmitOneInputBufferAtOneTime;
-#endif
-    }
-
-    sp<MediaSource> encoder = OMXCodec::Create(
-            client.interface(), enc_meta,
-            true /* createEncoder */, cameraSource,
-            NULL, encoder_flags);
-    if (encoder == NULL) {
-        RE_LOGW("Failed to create the encoder");
-        // When the encoder fails to be created, we need
-        // release the camera source due to the camera's lock
-        // and unlock mechanism.
-        cameraSource->stop();
-        return UNKNOWN_ERROR;
-    }
-
-    *source = encoder;
-
-    return OK;
-}
-#endif
-
-status_t GonkRecorder::setupAudioEncoder(const sp<MediaWriter>& writer) {
-    status_t status = BAD_VALUE;
-    if (OK != (status = checkAudioEncoderCapabilities())) {
-        return status;
-    }
-
-    switch(mAudioEncoder) {
-        case AUDIO_ENCODER_AMR_NB:
-        case AUDIO_ENCODER_AMR_WB:
-#if defined(MOZ_WIDGET_GONK) && ANDROID_VERSION >= 17
-        case AUDIO_ENCODER_AAC:
-        case AUDIO_ENCODER_HE_AAC:
-        case AUDIO_ENCODER_AAC_ELD:
-#endif
-            break;
-
-        default:
-            RE_LOGE("Unsupported audio encoder: %d", mAudioEncoder);
-            return UNKNOWN_ERROR;
-    }
-
-    sp<MediaSource> audioEncoder = createAudioSource();
-    if (audioEncoder == NULL) {
-        return UNKNOWN_ERROR;
-    }
-
-    writer->addSource(audioEncoder);
-    return OK;
-}
-
-status_t GonkRecorder::setupMPEG4Recording(
-        int outputFd,
-        int32_t videoWidth, int32_t videoHeight,
-        int32_t videoBitRate,
-        int32_t *totalBitRate,
-        sp<MediaWriter> *mediaWriter,
-        sp<WrappedMediaSource> *mediaSource) {
-    mediaWriter->clear();
-    *totalBitRate = 0;
-    status_t err = OK;
-    sp<MediaWriter> writer = new MPEG4Writer(outputFd);
-    sp<WrappedMediaSource> writerSource;
-
-    if (mVideoSource < VIDEO_SOURCE_LIST_END) {
-
-        sp<MediaSource> mediaSource;
-        err = setupMediaSource(&mediaSource);
-        if (err != OK) {
-            return err;
-        }
-
-        sp<MediaSource> encoder;
-        err = setupVideoEncoder(mediaSource, videoBitRate, &encoder);
-        if (err != OK) {
-            return err;
-        }
-
-        sp<GonkCameraSource> cameraSource = reinterpret_cast<GonkCameraSource *>(mediaSource.get());
-        writerSource = new WrappedMediaSource(encoder);
-
-        writer->addSource(writerSource);
-        *totalBitRate += videoBitRate;
-    }
-
-    // Audio source is added at the end if it exists.
-    // This help make sure that the "recoding" sound is suppressed for
-    // camcorder applications in the recorded files.
-    if (mAudioSource != AUDIO_SOURCE_CNT) {
-        err = setupAudioEncoder(writer);
-        if (err != OK) return err;
-        *totalBitRate += mAudioBitRate;
-    }
-
-    if (mInterleaveDurationUs > 0) {
-        reinterpret_cast<MPEG4Writer *>(writer.get())->
-            setInterleaveDuration(mInterleaveDurationUs);
-    }
-    if (mLongitudex10000 > -3600000 && mLatitudex10000 > -3600000) {
-        reinterpret_cast<MPEG4Writer *>(writer.get())->
-            setGeoData(mLatitudex10000, mLongitudex10000);
-    }
-    if (mMaxFileDurationUs != 0) {
-        writer->setMaxFileDuration(mMaxFileDurationUs);
-    }
-    if (mMaxFileSizeBytes != 0) {
-        writer->setMaxFileSize(mMaxFileSizeBytes);
-    }
-
-    mStartTimeOffsetMs = mEncoderProfiles->getStartTimeOffsetMs(mCameraId);
-    if (mStartTimeOffsetMs > 0) {
-        reinterpret_cast<MPEG4Writer *>(writer.get())->
-            setStartTimeOffsetMs(mStartTimeOffsetMs);
-    }
-
-    writer->setListener(mListener);
-    *mediaWriter = writer;
-    *mediaSource = writerSource;
-    return OK;
-}
-
-void GonkRecorder::setupMPEG4MetaData(int64_t startTimeUs, int32_t totalBitRate,
-        sp<MetaData> *meta) {
-    (*meta)->setInt64(kKeyTime, startTimeUs);
-    (*meta)->setInt32(kKeyFileType, mOutputFormat);
-    (*meta)->setInt32(kKeyBitRate, totalBitRate);
-    (*meta)->setInt32(kKey64BitFileOffset, mUse64BitFileOffset);
-    if (mMovieTimeScale > 0) {
-        (*meta)->setInt32(kKeyTimeScale, mMovieTimeScale);
-    }
-    if (mTrackEveryTimeDurationUs > 0) {
-        (*meta)->setInt64(kKeyTrackTimeStatus, mTrackEveryTimeDurationUs);
-    }
-
-    char value[PROPERTY_VALUE_MAX];
-    if (property_get("debug.camcorder.rotation", value, 0) > 0 && atoi(value) >= 0) {
-        mRotationDegrees = atoi(value);
-        RE_LOGI("Setting rotation to %d", mRotationDegrees );
-    }
-
-    if (mRotationDegrees != 0) {
-        (*meta)->setInt32(kKeyRotation, mRotationDegrees);
-    }
-}
-
-status_t GonkRecorder::startMPEG4Recording() {
-    int32_t totalBitRate;
-    status_t err = setupMPEG4Recording(
-            mOutputFd, mVideoWidth, mVideoHeight,
-            mVideoBitRate, &totalBitRate, &mWriter,
-            &mWriterSource);
-    if (err != OK) {
-        return err;
-    }
-
-    //systemTime() doesn't give correct time because
-    //HAVE_POSIX_CLOCKS is not defined for utils/Timers.cpp
-    //so, using clock_gettime directly
-#include <time.h>
-    struct timespec t;
-    clock_gettime(CLOCK_MONOTONIC, &t);
-    int64_t startTimeUs = int64_t(t.tv_sec)*1000000000LL + t.tv_nsec;
-    startTimeUs = startTimeUs / 1000;
-    sp<MetaData> meta = new MetaData;
-    setupMPEG4MetaData(startTimeUs, totalBitRate, &meta);
-
-    err = mWriter->start(meta.get());
-    if (err != OK) {
-        return err;
-    }
-
-    return OK;
-}
-
-status_t GonkRecorder::pause() {
-    RE_LOGV("pause");
-    if (mWriter == NULL) {
-        return UNKNOWN_ERROR;
-    }
-    if (!mStarted) {
-        return OK;
-    }
-    // Pause is not properly supported by all writers although
-    // for B2G we only currently use 3GPP/MPEG4
-    int err = INVALID_OPERATION;
-    switch (mOutputFormat) {
-        case OUTPUT_FORMAT_DEFAULT:
-        case OUTPUT_FORMAT_THREE_GPP:
-        case OUTPUT_FORMAT_MPEG_4:
-            err = mWriter->pause();
-            break;
-        default:
-            break;
-    }
-    if (err == OK) {
-        mStarted = false;
-    }
-    return err;
-}
-
-status_t GonkRecorder::resume() {
-    RE_LOGV("resume");
-    if (mWriter == NULL) {
-        return UNKNOWN_ERROR;
-    }
-    if (mStarted) {
-        return OK;
-    }
-    /* While the writer is paused, it will continue to pull frames
-       from the encoder. This ensures continuity on the timestamps of
-       the encoded frames, etc. When we want to resume however, we must
-       ensure that the first read frame is a key frame. */
-    mWriterSource->block();
-    int err = mWriter->start(NULL);
-    if (err != OK) {
-        return err;
-    }
-    err = mWriterSource->resume();
-    if (err == OK) {
-      mStarted = true;
-    }
-    return err;
-}
-
-status_t GonkRecorder::stop() {
-    RE_LOGV("stop");
-    status_t err = OK;
-
-    mWriterSource.clear();
-    if (mWriter != NULL) {
-        err = mWriter->stop();
-        mWriter.clear();
-    }
-
-    if (mOutputFd >= 0) {
-        ::close(mOutputFd);
-        mOutputFd = -1;
-    }
-
-    if (mStarted) {
-        mStarted = false;
-    }
-
-
-    return err;
-}
-
-status_t GonkRecorder::close() {
-    RE_LOGV("close");
-    stop();
-
-    return OK;
-}
-
-status_t GonkRecorder::reset() {
-    RE_LOGV("reset");
-    stop();
-
-    // No audio or video source by default
-    mAudioSource = AUDIO_SOURCE_CNT;
-    mVideoSource = VIDEO_SOURCE_LIST_END;
-
-    // Default parameters
-    mOutputFormat  = OUTPUT_FORMAT_THREE_GPP;
-    mAudioEncoder  = AUDIO_ENCODER_AMR_NB;
-    mVideoEncoder  = VIDEO_ENCODER_H263;
-    mVideoWidth    = 176;
-    mVideoHeight   = 144;
-    mFrameRate     = -1;
-    mVideoBitRate  = 192000;
-    mSampleRate    = 8000;
-    mAudioChannels = 1;
-    mAudioBitRate  = 12200;
-    mInterleaveDurationUs = 0;
-    mIFramesIntervalSec = 1;
-    mAudioSourceNode = 0;
-    mUse64BitFileOffset = false;
-    mMovieTimeScale  = -1;
-    mAudioTimeScale  = -1;
-    mVideoTimeScale  = -1;
-    mCameraId        = 0;
-    mStartTimeOffsetMs = -1;
-    mVideoEncoderProfile = -1;
-    mVideoEncoderLevel   = -1;
-    mMaxFileDurationUs = 0;
-    mMaxFileSizeBytes = 0;
-    mTrackEveryTimeDurationUs = 0;
-    mIsMetaDataStoredInVideoBuffers = false;
-    mEncoderProfiles = MediaProfiles::getInstance();
-    mRotationDegrees = 0;
-    mLatitudex10000 = -3600000;
-    mLongitudex10000 = -3600000;
-
-    mOutputFd = -1;
-    mCameraHw.clear();
-    //TODO: May need to register a listener eventually
-    //if someone is interested in recorder events for now
-    //default to no listener registered
-    mListener = NULL;
-
-    return OK;
-}
-
-status_t GonkRecorder::getMaxAmplitude(int *max) {
-    RE_LOGV("getMaxAmplitude");
-
-    if (max == NULL) {
-        RE_LOGE("Null pointer argument");
-        return BAD_VALUE;
-    }
-
-    if (mAudioSourceNode != 0) {
-        *max = mAudioSourceNode->getMaxAmplitude();
-    } else {
-        *max = 0;
-    }
-
-    return OK;
-}
-
-status_t GonkRecorder::dump(
-        int fd, const Vector<String16>& args) const {
-    RE_LOGV("dump");
-    const size_t SIZE = 256;
-    char buffer[SIZE];
-    String8 result;
-    if (mWriter != 0) {
-        mWriter->dump(fd, args);
-    } else {
-        snprintf(buffer, SIZE, "   No file writer\n");
-        result.append(buffer);
-    }
-    snprintf(buffer, SIZE, "   Recorder: %p\n", this);
-    snprintf(buffer, SIZE, "   Output file (fd %d):\n", mOutputFd);
-    result.append(buffer);
-    snprintf(buffer, SIZE, "     File format: %d\n", mOutputFormat);
-    result.append(buffer);
-    snprintf(buffer, SIZE, "     Max file size (bytes): %lld\n", mMaxFileSizeBytes);
-    result.append(buffer);
-    snprintf(buffer, SIZE, "     Max file duration (us): %lld\n", mMaxFileDurationUs);
-    result.append(buffer);
-    snprintf(buffer, SIZE, "     File offset length (bits): %d\n", mUse64BitFileOffset? 64: 32);
-    result.append(buffer);
-    snprintf(buffer, SIZE, "     Interleave duration (us): %d\n", mInterleaveDurationUs);
-    result.append(buffer);
-    snprintf(buffer, SIZE, "     Progress notification: %lld us\n", mTrackEveryTimeDurationUs);
-    result.append(buffer);
-    snprintf(buffer, SIZE, "   Audio\n");
-    result.append(buffer);
-    snprintf(buffer, SIZE, "     Source: %d\n", mAudioSource);
-    result.append(buffer);
-    snprintf(buffer, SIZE, "     Encoder: %d\n", mAudioEncoder);
-    result.append(buffer);
-    snprintf(buffer, SIZE, "     Bit rate (bps): %d\n", mAudioBitRate);
-    result.append(buffer);
-    snprintf(buffer, SIZE, "     Sampling rate (hz): %d\n", mSampleRate);
-    result.append(buffer);
-    snprintf(buffer, SIZE, "     Number of channels: %d\n", mAudioChannels);
-    result.append(buffer);
-    snprintf(buffer, SIZE, "     Max amplitude: %d\n", mAudioSourceNode == 0? 0: mAudioSourceNode->getMaxAmplitude());
-    result.append(buffer);
-    snprintf(buffer, SIZE, "   Video\n");
-    result.append(buffer);
-    snprintf(buffer, SIZE, "     Source: %d\n", mVideoSource);
-    result.append(buffer);
-    snprintf(buffer, SIZE, "     Camera Id: %d\n", mCameraId);
-    result.append(buffer);
-    snprintf(buffer, SIZE, "     Camera object address: %p\n", mCameraHw.get());
-    result.append(buffer);
-    snprintf(buffer, SIZE, "     Start time offset (ms): %d\n", mStartTimeOffsetMs);
-    result.append(buffer);
-    snprintf(buffer, SIZE, "     Encoder: %d\n", mVideoEncoder);
-    result.append(buffer);
-    snprintf(buffer, SIZE, "     Encoder profile: %d\n", mVideoEncoderProfile);
-    result.append(buffer);
-    snprintf(buffer, SIZE, "     Encoder level: %d\n", mVideoEncoderLevel);
-    result.append(buffer);
-    snprintf(buffer, SIZE, "     I frames interval (s): %d\n", mIFramesIntervalSec);
-    result.append(buffer);
-    snprintf(buffer, SIZE, "     Frame size (pixels): %dx%d\n", mVideoWidth, mVideoHeight);
-    result.append(buffer);
-    snprintf(buffer, SIZE, "     Frame rate (fps): %d\n", mFrameRate);
-    result.append(buffer);
-    snprintf(buffer, SIZE, "     Bit rate (bps): %d\n", mVideoBitRate);
-    result.append(buffer);
-    ::write(fd, result.string(), result.size());
-    return OK;
-}
-
-status_t GonkRecorder::setCamera(const sp<GonkCameraHardware>& aCameraHw) {
-  mCameraHw = aCameraHw;
-  return OK;
-}
-
-}  // namespace android
deleted file mode 100644
--- a/dom/camera/GonkRecorder.h
+++ /dev/null
@@ -1,198 +0,0 @@
-/*
- * Copyright (C) 2009 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_RECORDER_H_
-#define GONK_RECORDER_H_
-
-#include "nsISupportsImpl.h"
-#include "GonkCameraHwMgr.h"
-
-#include <media/MediaRecorderBase.h>
-#include <camera/CameraParameters.h>
-#include <utils/String8.h>
-#include <system/audio.h>
-#if ANDROID_VERSION >= 21
-#include <media/stagefright/foundation/ALooper.h>
-#include <media/stagefright/foundation/AMessage.h>
-#endif
-
-#include "mozilla/RefPtr.h"
-#include "GonkCameraHwMgr.h"
-
-namespace android {
-
-class GonkCameraSource;
-struct MOZ_EXPORT MediaSource;
-struct MediaWriter;
-class MOZ_EXPORT MetaData;
-struct MOZ_EXPORT AudioSource;
-class GonkCameraHardware;
-
-struct GonkRecorder {
-    NS_INLINE_DECL_THREADSAFE_REFCOUNTING(GonkRecorder)
-
-    GonkRecorder();
-
-    virtual status_t init();
-    virtual status_t setAudioSource(audio_source_t as);
-    virtual status_t setVideoSource(video_source vs);
-    virtual status_t setOutputFormat(output_format of);
-    virtual status_t setAudioEncoder(audio_encoder ae);
-    virtual status_t setVideoEncoder(video_encoder ve);
-    virtual status_t setVideoSize(int width, int height);
-    virtual status_t setVideoFrameRate(int frames_per_second);
-    virtual status_t setOutputFile(const char *path);
-    virtual status_t setOutputFile(int fd, int64_t offset, int64_t length);
-    virtual status_t setParameters(const String8& params);
-    virtual status_t setCamera(const sp<GonkCameraHardware>& aCameraHw);
-    virtual status_t setListener(const sp<IMediaRecorderClient>& listener);
-    virtual status_t setClientName(const String16& clientName);
-    virtual status_t prepare();
-    virtual status_t start();
-    virtual status_t pause();
-    virtual status_t resume();
-    virtual status_t stop();
-    virtual status_t close();
-    virtual status_t reset();
-    virtual status_t getMaxAmplitude(int *max);
-    virtual status_t dump(int fd, const Vector<String16>& args) const;
-    // Querying a SurfaceMediaSourcer
-
-protected:
-    virtual ~GonkRecorder();
-
-private:
-    struct WrappedMediaSource;
-
-    sp<IMediaRecorderClient> mListener;
-    String16 mClientName;
-    uid_t mClientUid;
-    sp<MediaWriter> mWriter;
-    sp<WrappedMediaSource> mWriterSource;
-    int mOutputFd;
-    sp<AudioSource> mAudioSourceNode;
-
-    audio_source_t mAudioSource;
-    video_source mVideoSource;
-    output_format mOutputFormat;
-    audio_encoder mAudioEncoder;
-    video_encoder mVideoEncoder;
-    bool mUse64BitFileOffset;
-    int32_t mVideoWidth, mVideoHeight;
-    int32_t mFrameRate;
-    int32_t mVideoBitRate;
-    int32_t mAudioBitRate;
-    int32_t mAudioChannels;
-    int32_t mSampleRate;
-    int32_t mInterleaveDurationUs;
-    int32_t mIFramesIntervalSec;
-    int32_t mCameraId;
-    int32_t mVideoEncoderProfile;
-    int32_t mVideoEncoderLevel;
-    int32_t mMovieTimeScale;
-    int32_t mVideoTimeScale;
-    int32_t mAudioTimeScale;
-    int64_t mMaxFileSizeBytes;
-    int64_t mMaxFileDurationUs;
-    int64_t mTrackEveryTimeDurationUs;
-    int32_t mRotationDegrees;  // Clockwise
-    int32_t mLatitudex10000;
-    int32_t mLongitudex10000;
-    int32_t mStartTimeOffsetMs;
-
-    String8 mParams;
-
-    bool mIsMetaDataStoredInVideoBuffers;
-    MediaProfiles *mEncoderProfiles;
-
-    bool mStarted;
-
-#if ANDROID_VERSION >= 21
-    sp<ALooper> mLooper;
-#endif
-
-    sp<GonkCameraHardware> mCameraHw;
-
-    status_t setupMPEG4Recording(
-        int outputFd,
-        int32_t videoWidth, int32_t videoHeight,
-        int32_t videoBitRate,
-        int32_t *totalBitRate,
-        sp<MediaWriter> *mediaWriter,
-        sp<WrappedMediaSource> *mediaSource);
-    void setupMPEG4MetaData(int64_t startTimeUs, int32_t totalBitRate,
-        sp<MetaData> *meta);
-    status_t startMPEG4Recording();
-    status_t startAMRRecording();
-#if defined(MOZ_WIDGET_GONK) && ANDROID_VERSION >= 17
-    status_t startAACRecording();
-#endif
-    status_t startRawAudioRecording();
-    status_t startRTPRecording();
-    status_t startMPEG2TSRecording();
-    sp<MediaSource> createAudioSource();
-    status_t checkVideoEncoderCapabilities();
-    status_t checkAudioEncoderCapabilities();
-    // Generic MediaSource set-up. Returns the appropriate
-    // source (CameraSource or SurfaceMediaSource)
-    // depending on the videosource type
-    status_t setupMediaSource(sp<MediaSource> *mediaSource);
-    status_t setupCameraSource(sp<GonkCameraSource> *cameraSource);
-    // setup the surfacemediasource for the encoder
-
-    status_t setupAudioEncoder(const sp<MediaWriter>& writer);
-    status_t setupVideoEncoder(
-            sp<MediaSource> cameraSource,
-            int32_t videoBitRate,
-            sp<MediaSource> *source);
-
-    // Encoding parameter handling utilities
-    status_t setParameter(const String8 &key, const String8 &value);
-    status_t setParamAudioEncodingBitRate(int32_t bitRate);
-    status_t setParamAudioNumberOfChannels(int32_t channles);
-    status_t setParamAudioSamplingRate(int32_t sampleRate);
-    status_t setParamAudioTimeScale(int32_t timeScale);
-    status_t setParamVideoEncodingBitRate(int32_t bitRate);
-    status_t setParamVideoIFramesInterval(int32_t seconds);
-    status_t setParamVideoEncoderProfile(int32_t profile);
-    status_t setParamVideoEncoderLevel(int32_t level);
-    status_t setParamVideoCameraId(int32_t cameraId);
-    status_t setParamVideoTimeScale(int32_t timeScale);
-    status_t setParamVideoRotation(int32_t degrees);
-    status_t setParamTrackTimeStatus(int64_t timeDurationUs);
-    status_t setParamInterleaveDuration(int32_t durationUs);
-    status_t setParam64BitFileOffset(bool use64BitFileOffset);
-    status_t setParamMaxFileDurationUs(int64_t timeUs);
-    status_t setParamMaxFileSizeBytes(int64_t bytes);
-    status_t setParamMovieTimeScale(int32_t timeScale);
-    status_t setParamGeoDataLongitude(int64_t longitudex10000);
-    status_t setParamGeoDataLatitude(int64_t latitudex10000);
-    void clipVideoBitRate();
-    void clipVideoFrameRate();
-    void clipVideoFrameWidth();
-    void clipVideoFrameHeight();
-    void clipAudioBitRate();
-    void clipAudioSampleRate();
-    void clipNumberOfAudioChannels();
-    void setDefaultProfileIfNecessary();
-
-    GonkRecorder(const GonkRecorder &);
-    GonkRecorder &operator=(const GonkRecorder &);
-};
-
-}  // namespace android
-
-#endif  // GONK_RECORDER_H_
deleted file mode 100644
--- a/dom/camera/GonkRecorderProfiles.cpp
+++ /dev/null
@@ -1,425 +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 "GonkRecorderProfiles.h"
-#include "nsMimeTypes.h"
-#include "CameraControlImpl.h"
-#include "CameraCommon.h"
-
-#ifdef MOZ_WIDGET_GONK
-#include "GonkRecorder.h"
-#endif
-
-using namespace mozilla;
-using namespace android;
-
-namespace mozilla {
-
-struct ProfileConfig {
-  const char* name;
-  int quality;
-  uint32_t priority;
-};
-
-#define DEF_GONK_RECORDER_PROFILE(e, n, p) { n, e, p },
-static const ProfileConfig ProfileList[] = {
-  #include "GonkRecorderProfiles.def"
-};
-
-static const size_t ProfileListSize = MOZ_ARRAY_LENGTH(ProfileList);
-
-struct ProfileConfigDetect {
-  const char* name;
-  uint32_t width;
-  uint32_t height;
-  uint32_t priority;
-};
-
-#define DEF_GONK_RECORDER_PROFILE_DETECT(n, w, h, p) { n, w, h, p },
-static const ProfileConfigDetect ProfileListDetect[] = {
-  #include "GonkRecorderProfiles.def"
-};
-
-static const size_t ProfileListDetectSize = MOZ_ARRAY_LENGTH(ProfileListDetect);
-
-};
-
-/* static */ nsClassHashtable<nsUint32HashKey, ProfileHashtable> GonkRecorderProfile::sProfiles;
-/* static */ android::MediaProfiles* sMediaProfiles = nullptr;
-
-static MediaProfiles*
-GetMediaProfiles()
-{
-  if (!sMediaProfiles) {
-    sMediaProfiles = MediaProfiles::getInstance();
-  }
-  MOZ_ASSERT(sMediaProfiles);
-  return sMediaProfiles;
-}
-
-static bool
-IsProfileSupported(uint32_t aCameraId, int aQuality)
-{
-  MediaProfiles* profiles = GetMediaProfiles();
-  return profiles->hasCamcorderProfile(static_cast<int>(aCameraId),
-                                       static_cast<camcorder_quality>(aQuality));
-}
-
-static int
-GetProfileParameter(uint32_t aCameraId, int aQuality, const char* aParameter)
-{
-  MediaProfiles* profiles = GetMediaProfiles();
-  return profiles->getCamcorderProfileParamByName(aParameter, static_cast<int>(aCameraId),
-                                                  static_cast<camcorder_quality>(aQuality));
-}
-
-/* static */ bool
-GonkRecorderVideo::Translate(video_encoder aCodec, nsAString& aCodecName)
-{
-  switch (aCodec) {
-    case VIDEO_ENCODER_H263:
-      aCodecName.AssignASCII("h263");
-      break;
-
-    case VIDEO_ENCODER_H264:
-      aCodecName.AssignASCII("h264");
-      break;
-
-    case VIDEO_ENCODER_MPEG_4_SP:
-      aCodecName.AssignASCII("mpeg4sp");
-      break;
-
-    default:
-      return false;
-  }
-
-  return true;
-}
-
-int
-GonkRecorderVideo::GetProfileParameter(const char* aParameter)
-{
-  return ::GetProfileParameter(mCameraId, mQuality, aParameter);
-}
-
-GonkRecorderVideo::GonkRecorderVideo(uint32_t aCameraId, int aQuality)
-  : mCameraId(aCameraId)
-  , mQuality(aQuality)
-  , mIsValid(false)
-{
-  mPlatformEncoder = static_cast<video_encoder>(GetProfileParameter("vid.codec"));
-  bool isValid = Translate(mPlatformEncoder, mCodec);
-
-  int v = GetProfileParameter("vid.width");
-  if (v >= 0) {
-    mSize.width = v;
-  } else {
-    isValid = false;
-  }
-  v = GetProfileParameter("vid.height");
-  if (v >= 0) {
-    mSize.height = v;
-  } else {
-    isValid = false;
-  }
-  v = GetProfileParameter("vid.bps");
-  if (v >= 0) {
-    mBitsPerSecond = v;
-  } else {
-    isValid = false;
-  }
-  v = GetProfileParameter("vid.fps");
-  if (v >= 0) {
-    mFramesPerSecond = v;
-  } else {
-    isValid = false;
-  }
-
-  mIsValid = isValid;
-}
-
-/* static */ bool
-GonkRecorderAudio::Translate(audio_encoder aCodec, nsAString& aCodecName)
-{
-  switch (aCodec) {
-    case AUDIO_ENCODER_AMR_NB:
-      aCodecName.AssignASCII("amrnb");
-      break;
-
-    case AUDIO_ENCODER_AMR_WB:
-      aCodecName.AssignASCII("amrwb");
-      break;
-
-    case AUDIO_ENCODER_AAC:
-      aCodecName.AssignASCII("aac");
-      break;
-
-    default:
-      return false;
-  }
-
-  return true;
-}
-
-int
-GonkRecorderAudio::GetProfileParameter(const char* aParameter)
-{
-  return ::GetProfileParameter(mCameraId, mQuality, aParameter);
-}
-
-GonkRecorderAudio::GonkRecorderAudio(uint32_t aCameraId, int aQuality)
-  : mCameraId(aCameraId)
-  , mQuality(aQuality)
-  , mIsValid(false)
-{
-  mPlatformEncoder = static_cast<audio_encoder>(GetProfileParameter("aud.codec"));
-  bool isValid = Translate(mPlatformEncoder, mCodec);
-
-  int v = GetProfileParameter("aud.ch");
-  if (v >= 0) {
-    mChannels = v;
-  } else {
-    isValid = false;
-  }
-  v = GetProfileParameter("aud.bps");
-  if (v >= 0) {
-    mBitsPerSecond = v;
-  } else {
-    isValid = false;
-  }
-  v = GetProfileParameter("aud.hz");
-  if (v >= 0) {
-    mSamplesPerSecond = v;
-  } else {
-    isValid = false;
-  }
-
-  mIsValid = isValid;
-}
-
-/* static */ bool
-GonkRecorderProfile::Translate(output_format aContainer, nsAString& aContainerName)
-{
-  switch (aContainer) {
-    case OUTPUT_FORMAT_THREE_GPP:
-      aContainerName.AssignASCII("3gp");
-      break;
-
-    case OUTPUT_FORMAT_MPEG_4:
-      aContainerName.AssignASCII("mp4");
-      break;
-
-    default:
-      return false;
-  }
-
-  return true;
-}
-
-/* static */ bool
-GonkRecorderProfile::GetMimeType(output_format aContainer, nsAString& aMimeType)
-{
-  switch (aContainer) {
-    case OUTPUT_FORMAT_THREE_GPP:
-      aMimeType.AssignASCII(VIDEO_3GPP);
-      break;
-
-    case OUTPUT_FORMAT_MPEG_4:
-      aMimeType.AssignASCII(VIDEO_MP4);
-      break;
-
-    default:
-      return false;
-  }
-
-  return true;
-}
-
-int
-GonkRecorderProfile::GetProfileParameter(const char* aParameter)
-{
-  return ::GetProfileParameter(mCameraId, mQuality, aParameter);
-}
-
-GonkRecorderProfile::GonkRecorderProfile(uint32_t aCameraId,
-                                         int aQuality)
-  : GonkRecorderProfileBase<GonkRecorderAudio, GonkRecorderVideo>(aCameraId,
-                                                                  aQuality)
-  , mCameraId(aCameraId)
-  , mQuality(aQuality)
-  , mIsValid(false)
-{
-  mOutputFormat = static_cast<output_format>(GetProfileParameter("file.format"));
-  bool isValid = Translate(mOutputFormat, mContainer);
-  isValid = GetMimeType(mOutputFormat, mMimeType) ? isValid : false;
-
-  mIsValid = isValid && mAudio.IsValid() && mVideo.IsValid();
-}
-
-/* static */
-already_AddRefed<GonkRecorderProfile>
-GonkRecorderProfile::CreateProfile(uint32_t aCameraId, int aQuality)
-{
-  if (!IsProfileSupported(aCameraId, aQuality)) {
-    DOM_CAMERA_LOGI("Profile %d not supported by platform\n", aQuality);
-    return nullptr;
-  }
-
-  RefPtr<GonkRecorderProfile> profile = new GonkRecorderProfile(aCameraId, aQuality);
-  if (!profile->IsValid()) {
-    DOM_CAMERA_LOGE("Profile %d is not valid\n", aQuality);
-    return nullptr;
-  }
-
-  return profile.forget();
-}
-
-/* static */
-ProfileHashtable*
-GonkRecorderProfile::GetProfileHashtable(uint32_t aCameraId)
-{
-  ProfileHashtable* profiles = sProfiles.Get(aCameraId);
-  if (!profiles) {
-    profiles = new ProfileHashtable();
-    sProfiles.Put(aCameraId, profiles);
-
-    /* First handle the profiles with a known enum. We can process those
-       efficently because MediaProfiles indexes their profiles that way. */
-    int highestKnownQuality = CAMCORDER_QUALITY_LIST_START - 1;
-    for (size_t i = 0; i < ProfileListSize; ++i) {
-      const ProfileConfig& p = ProfileList[i];
-      if (p.quality > highestKnownQuality) {
-        highestKnownQuality = p.quality;
-      }
-
-      RefPtr<GonkRecorderProfile> profile = CreateProfile(aCameraId, p.quality);
-      if (!profile) {
-        continue;
-      }
-
-      DOM_CAMERA_LOGI("Profile %d '%s' supported by platform\n", p.quality, p.name);
-      profile->mName.AssignASCII(p.name);
-      profile->mPriority = p.priority;
-      profiles->Put(profile->GetName(), profile);
-    }
-
-    /* However not all of the potentially supported profiles have a known
-       enum on all of our supported platforms because some entries may
-       be missing from MediaProfiles.h. As such, we can't rely upon
-       having the CAMCORDER_QUALITY_* enums for those profiles. We need
-       to map the profiles to a name by matching the width and height of
-       the video resolution to our configured values.
-
-       In theory there may be collisions given that there can be multiple
-       resolutions sharing the same name (e.g. 800x480 and 768x480 are both
-       wvga). In practice this should not happen because there should be
-       only one WVGA profile given there is only one enum for it. In the
-       situation there is a collision, it will merely select the last
-       detected profile. */
-    for (int q = highestKnownQuality + 1; q <= CAMCORDER_QUALITY_LIST_END; ++q) {
-      RefPtr<GonkRecorderProfile> profile = CreateProfile(aCameraId, q);
-      if (!profile) {
-        continue;
-      }
-
-      const ICameraControl::Size& s = profile->GetVideo().GetSize();
-      size_t match;
-      for (match = 0; match < ProfileListDetectSize; ++match) {
-        const ProfileConfigDetect& p = ProfileListDetect[match];
-        if (s.width == p.width && s.height == p.height) {
-          DOM_CAMERA_LOGI("Profile %d '%s' supported by platform\n", q, p.name);
-          profile->mName.AssignASCII(p.name);
-          profile->mPriority = p.priority;
-          profiles->Put(profile->GetName(), profile);
-          break;
-        }
-      }
-
-      if (match == ProfileListDetectSize) {
-        DOM_CAMERA_LOGW("Profile %d size %u x %u is not recognized\n",
-                        q, s.width, s.height);
-      }
-    }
-  }
-  return profiles;
-}
-
-/* static */ nsresult
-GonkRecorderProfile::GetAll(uint32_t aCameraId,
-                            nsTArray<RefPtr<ICameraControl::RecorderProfile>>& aProfiles)
-{
-  ProfileHashtable* profiles = GetProfileHashtable(aCameraId);
-  if (!profiles) {
-    return NS_ERROR_FAILURE;
-  }
-
-  aProfiles.Clear();
-  for (auto iter = profiles->Iter(); !iter.Done(); iter.Next()) {
-    aProfiles.AppendElement(iter.UserData());
-  }
-
-  return NS_OK;
-}
-
-#ifdef MOZ_WIDGET_GONK
-nsresult
-GonkRecorderProfile::ConfigureRecorder(GonkRecorder& aRecorder)
-{
-  static const size_t SIZE = 256;
-  char buffer[SIZE];
-
-  // set all the params
-  CHECK_SETARG(aRecorder.setAudioSource(AUDIO_SOURCE_CAMCORDER));
-  CHECK_SETARG(aRecorder.setVideoSource(VIDEO_SOURCE_CAMERA));
-  CHECK_SETARG(aRecorder.setOutputFormat(mOutputFormat));
-  CHECK_SETARG(aRecorder.setVideoFrameRate(mVideo.GetFramesPerSecond()));
-  CHECK_SETARG(aRecorder.setVideoSize(mVideo.GetSize().width, mVideo.GetSize().height));
-  CHECK_SETARG(aRecorder.setVideoEncoder(mVideo.GetPlatformEncoder()));
-  CHECK_SETARG(aRecorder.setAudioEncoder(mAudio.GetPlatformEncoder()));
-
-  snprintf(buffer, SIZE, "video-param-encoding-bitrate=%d", mVideo.GetBitsPerSecond());
-  CHECK_SETARG(aRecorder.setParameters(String8(buffer)));
-
-  snprintf(buffer, SIZE, "audio-param-encoding-bitrate=%d", mAudio.GetBitsPerSecond());
-  CHECK_SETARG(aRecorder.setParameters(String8(buffer)));
-
-  snprintf(buffer, SIZE, "audio-param-number-of-channels=%d", mAudio.GetChannels());
-  CHECK_SETARG(aRecorder.setParameters(String8(buffer)));
-
-  snprintf(buffer, SIZE, "audio-param-sampling-rate=%d", mAudio.GetSamplesPerSecond());
-  CHECK_SETARG(aRecorder.setParameters(String8(buffer)));
-
-  return NS_OK;
-}
-
-/* static */ nsresult
-GonkRecorderProfile::ConfigureRecorder(android::GonkRecorder& aRecorder,
-                                       uint32_t aCameraId,
-                                       const nsAString& aProfileName)
-{
-  ProfileHashtable* profiles = GetProfileHashtable(aCameraId);
-  if (!profiles) {
-    return NS_ERROR_FAILURE;
-  }
-
-  GonkRecorderProfile* profile;
-  if (!profiles->Get(aProfileName, &profile)) {
-    return NS_ERROR_INVALID_ARG;
-  }
-
-  return profile->ConfigureRecorder(aRecorder);
-}
-#endif
deleted file mode 100644
--- a/dom/camera/GonkRecorderProfiles.def
+++ /dev/null
@@ -1,58 +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.
- */
-
-/**
- * DO NOT PUT RE-INCLUSION GUARD MACROS AROUND THIS HEADER!!!
- */
-
-#ifndef DEF_GONK_RECORDER_PROFILE
-#define DEF_GONK_RECORDER_PROFILE(e, n, p)
-#endif
-
-#ifndef DEF_GONK_RECORDER_PROFILE_DETECT
-#define DEF_GONK_RECORDER_PROFILE_DETECT(n, w, h, p)
-#endif
-
-/* Enum value, name, and priority. The supported profile with the
- * lowest priority and then largest area is selected as the default.
- */
-
-DEF_GONK_RECORDER_PROFILE(CAMCORDER_QUALITY_LOW,   "low",   900)
-DEF_GONK_RECORDER_PROFILE(CAMCORDER_QUALITY_HIGH,  "high",  900)
-DEF_GONK_RECORDER_PROFILE(CAMCORDER_QUALITY_QCIF,  "qcif",  300)
-DEF_GONK_RECORDER_PROFILE(CAMCORDER_QUALITY_CIF,   "cif",   300)
-DEF_GONK_RECORDER_PROFILE(CAMCORDER_QUALITY_480P,  "480p",  200)
-DEF_GONK_RECORDER_PROFILE(CAMCORDER_QUALITY_720P,  "720p",  100)
-DEF_GONK_RECORDER_PROFILE(CAMCORDER_QUALITY_1080P, "1080p",   0)
-
-/**
- * The following profiles do not appear in all versions of the
- * MediaProfiles.h and must be detected at runtime. Additionally some
- * profiles may have more than one resolution, depending on the camera.
- */
-
-DEF_GONK_RECORDER_PROFILE_DETECT("4kuhd", 3840, 2160, 800)
-DEF_GONK_RECORDER_PROFILE_DETECT("fwvga",  864,  480, 200)
-DEF_GONK_RECORDER_PROFILE_DETECT("fwvga",  854,  480, 200)
-DEF_GONK_RECORDER_PROFILE_DETECT("wvga",   800,  480, 200)
-DEF_GONK_RECORDER_PROFILE_DETECT("wvga",   768,  480, 200)
-DEF_GONK_RECORDER_PROFILE_DETECT("vga",    640,  480, 200)
-DEF_GONK_RECORDER_PROFILE_DETECT("hvga",   480,  320, 300)
-DEF_GONK_RECORDER_PROFILE_DETECT("wqvga",  400,  240, 300)
-DEF_GONK_RECORDER_PROFILE_DETECT("qvga",   320,  240, 300)
-
-#undef DEF_GONK_RECORDER_PROFILE
-#undef DEF_GONK_RECORDER_PROFILE_DETECT
deleted file mode 100644
--- a/dom/camera/GonkRecorderProfiles.h
+++ /dev/null
@@ -1,159 +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_GONK_RECORDER_PROFILES_H
-#define DOM_CAMERA_GONK_RECORDER_PROFILES_H
-
-#ifdef MOZ_WIDGET_GONK
-#include <media/MediaProfiles.h>
-#else
-#include "FallbackCameraPlatform.h"
-#endif
-
-#include "ICameraControl.h"
-#include "nsClassHashtable.h"
-#include "nsRefPtrHashtable.h"
-
-#ifndef CHECK_SETARG_RETURN
-#define CHECK_SETARG_RETURN(x, rv)      \
-  do {                                  \
-    if (x) {                            \
-      DOM_CAMERA_LOGE(#x " failed\n");  \
-      return rv;                        \
-    }                                   \
-  } while(0)
-#endif
-
-#ifndef CHECK_SETARG
-#define CHECK_SETARG(x) CHECK_SETARG_RETURN(x, NS_ERROR_NOT_AVAILABLE)
-#endif
-
-namespace android {
-  class GonkRecorder;
-};
-
-namespace mozilla {
-
-/**
- * class GonkRecorderProfileBase
- */
-template<class A, class V>
-class GonkRecorderProfileBase : public ICameraControl::RecorderProfile
-{
-public:
-  GonkRecorderProfileBase(uint32_t aCameraId, int aQuality)
-    : RecorderProfile()
-    , mAudio(aCameraId, aQuality)
-    , mVideo(aCameraId, aQuality)
-  { }
-
-  virtual const Audio& GetAudio() const override { return mAudio; }
-  virtual const Video& GetVideo() const override { return mVideo; }
-
-protected:
-  virtual ~GonkRecorderProfileBase() { }
-  A mAudio;
-  V mVideo;
-};
-
-/**
- * class GonkRecorderVideo
- */
-class GonkRecorderVideo : public ICameraControl::RecorderProfile::Video
-{
-public:
-  GonkRecorderVideo(uint32_t aCameraId, int aQuality);
-  virtual ~GonkRecorderVideo() { }
-
-  android::video_encoder GetPlatformEncoder() const { return mPlatformEncoder; }
-  bool IsValid() const { return mIsValid; }
-
-protected:
-  int GetProfileParameter(const char* aParameter);
-  static bool Translate(android::video_encoder aCodec, nsAString& aCodecName);
-
-  uint32_t mCameraId;
-  int mQuality;
-  bool mIsValid;
-  android::video_encoder mPlatformEncoder;
-};
-
-/**
- * class GonkRecorderAudio
- */
-class GonkRecorderAudio : public ICameraControl::RecorderProfile::Audio
-{
-public:
-  GonkRecorderAudio(uint32_t aCameraId, int aQuality);
-  virtual ~GonkRecorderAudio() { }
-
-  android::audio_encoder GetPlatformEncoder() const { return mPlatformEncoder; }
-  bool IsValid() const { return mIsValid; }
-
-protected:
-  int GetProfileParameter(const char* aParameter);
-  static bool Translate(android::audio_encoder aCodec, nsAString& aCodecName);
-
-  uint32_t mCameraId;
-  int mQuality;
-  bool mIsValid;
-  android::audio_encoder mPlatformEncoder;
-};
-
-/**
- * class GonkRecorderProfile
- */
-class GonkRecorderProfile;
-typedef nsRefPtrHashtable<nsStringHashKey, GonkRecorderProfile> ProfileHashtable;
-
-class GonkRecorderProfile
-  : public GonkRecorderProfileBase<GonkRecorderAudio, GonkRecorderVideo>
-{
-public:
-  static nsresult GetAll(uint32_t aCameraId,
-                         nsTArray<RefPtr<ICameraControl::RecorderProfile>>& aProfiles);
-
-#ifdef MOZ_WIDGET_GONK
-  // Configures the specified recorder using the specified profile.
-  //
-  // Return values:
-  //  - NS_OK on success;
-  //  - NS_ERROR_INVALID_ARG if the profile isn't supported;
-  //  - NS_ERROR_NOT_AVAILABLE if the recorder rejected the profile.
-  static nsresult ConfigureRecorder(android::GonkRecorder& aRecorder,
-                                    uint32_t aCameraId,
-                                    const nsAString& aProfileName);
-#endif
-
-protected:
-  GonkRecorderProfile(uint32_t aCameraId,
-                      int aQuality);
-
-  int GetProfileParameter(const char* aParameter);
-
-  bool Translate(android::output_format aContainer, nsAString& aContainerName);
-  bool GetMimeType(android::output_format aContainer, nsAString& aMimeType);
-  bool IsValid() const { return mIsValid; };
-
-#ifdef MOZ_WIDGET_GONK
-  nsresult ConfigureRecorder(android::GonkRecorder& aRecorder);
-#endif
-  static already_AddRefed<GonkRecorderProfile> CreateProfile(uint32_t aCameraId,
-                                                             int aQuality);
-  static ProfileHashtable* GetProfileHashtable(uint32_t aCameraId);
-
-  uint32_t mCameraId;
-  int mQuality;
-  bool mIsValid;
-  android::output_format mOutputFormat;
-
-  static nsClassHashtable<nsUint32HashKey, ProfileHashtable> sProfiles;
-
-private:
-  DISALLOW_EVIL_CONSTRUCTORS(GonkRecorderProfile);
-};
-
-}; // namespace mozilla
-
-#endif // DOM_CAMERA_GONK_RECORDER_PROFILES_H
deleted file mode 100644
--- a/dom/camera/ICameraControl.h
+++ /dev/null
@@ -1,337 +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_ICAMERACONTROL_H
-#define DOM_CAMERA_ICAMERACONTROL_H
-
-#include "nsCOMPtr.h"
-#include "nsString.h"
-#include "nsISupportsImpl.h"
-#include "base/basictypes.h"
-
-struct DeviceStorageFileDescriptor;
-
-namespace mozilla {
-
-class CameraControlListener;
-
-// XXXmikeh - In some future patch this should move into the ICameraControl
-//  class as well, and the names updated to the 'k'-style;
-//  e.g. kParamPreviewSize, etc.
-enum {
-  // current settings
-  CAMERA_PARAM_PREVIEWSIZE,
-  CAMERA_PARAM_PREVIEWFORMAT,
-  CAMERA_PARAM_PREVIEWFRAMERATE,
-  CAMERA_PARAM_VIDEOSIZE,
-  CAMERA_PARAM_PICTURE_SIZE,
-  CAMERA_PARAM_PICTURE_FILEFORMAT,
-  CAMERA_PARAM_PICTURE_ROTATION,
-  CAMERA_PARAM_PICTURE_LOCATION,
-  CAMERA_PARAM_PICTURE_DATETIME,
-  CAMERA_PARAM_PICTURE_QUALITY,
-  CAMERA_PARAM_EFFECT,
-  CAMERA_PARAM_WHITEBALANCE,
-  CAMERA_PARAM_SCENEMODE,
-  CAMERA_PARAM_FLASHMODE,
-  CAMERA_PARAM_FOCUSMODE,
-  CAMERA_PARAM_ZOOM,
-  CAMERA_PARAM_METERINGAREAS,
-  CAMERA_PARAM_FOCUSAREAS,
-  CAMERA_PARAM_FOCALLENGTH,
-  CAMERA_PARAM_FOCUSDISTANCENEAR,
-  CAMERA_PARAM_FOCUSDISTANCEOPTIMUM,
-  CAMERA_PARAM_FOCUSDISTANCEFAR,
-  CAMERA_PARAM_EXPOSURECOMPENSATION,
-  CAMERA_PARAM_THUMBNAILSIZE,
-  CAMERA_PARAM_THUMBNAILQUALITY,
-  CAMERA_PARAM_SENSORANGLE,
-  CAMERA_PARAM_ISOMODE,
-  CAMERA_PARAM_LUMINANCE,
-  CAMERA_PARAM_SCENEMODE_HDR_RETURNNORMALPICTURE,
-  CAMERA_PARAM_RECORDINGHINT,
-  CAMERA_PARAM_PREFERRED_PREVIEWSIZE_FOR_VIDEO,
-  CAMERA_PARAM_METERINGMODE,
-
-  // supported features
-  CAMERA_PARAM_SUPPORTED_PREVIEWSIZES,
-  CAMERA_PARAM_SUPPORTED_PICTURESIZES,
-  CAMERA_PARAM_SUPPORTED_VIDEOSIZES,
-  CAMERA_PARAM_SUPPORTED_PICTUREFORMATS,
-  CAMERA_PARAM_SUPPORTED_WHITEBALANCES,
-  CAMERA_PARAM_SUPPORTED_SCENEMODES,
-  CAMERA_PARAM_SUPPORTED_EFFECTS,
-  CAMERA_PARAM_SUPPORTED_FLASHMODES,
-  CAMERA_PARAM_SUPPORTED_FOCUSMODES,
-  CAMERA_PARAM_SUPPORTED_MAXFOCUSAREAS,
-  CAMERA_PARAM_SUPPORTED_MAXMETERINGAREAS,
-  CAMERA_PARAM_SUPPORTED_MINEXPOSURECOMPENSATION,
-  CAMERA_PARAM_SUPPORTED_MAXEXPOSURECOMPENSATION,
-  CAMERA_PARAM_SUPPORTED_EXPOSURECOMPENSATIONSTEP,
-  CAMERA_PARAM_SUPPORTED_ZOOM,
-  CAMERA_PARAM_SUPPORTED_ZOOMRATIOS,
-  CAMERA_PARAM_SUPPORTED_MAXDETECTEDFACES,
-  CAMERA_PARAM_SUPPORTED_JPEG_THUMBNAIL_SIZES,
-  CAMERA_PARAM_SUPPORTED_ISOMODES,
-  CAMERA_PARAM_SUPPORTED_METERINGMODES
-};
-
-class ICameraControl
-{
-public:
-  NS_INLINE_DECL_THREADSAFE_REFCOUNTING(ICameraControl)
-
-  // Returns the number of cameras supported by the system.
-  //
-  // Return values:
-  //  - NS_OK on success;
-  //  - NS_ERROR_FAILURE if the camera count cannot be retrieved.
-  static nsresult GetNumberOfCameras(int32_t& aDeviceCount);
-
-  // Gets the (possibly-meaningful) name of a particular camera.
-  //
-  // Return values:
-  //  - NS_OK on success;
-  //  - NS_ERROR_INVALID_ARG if 'aDeviceNum' is not a valid camera number;
-  //  - NS_ERROR_NOT_AVAILABLE if 'aDeviceNum' is valid but the camera name
-  //      could still not be retrieved.
-  static nsresult GetCameraName(uint32_t aDeviceNum, nsCString& aDeviceName);
-
-  // Returns a list of names of all cameras supported by the system.
-  //
-  // Return values:
-  //  - NS_OK on success, even if no camera names are returned (in which
-  //      case 'aList' will be empty);
-  //  - NS_ERROR_NOT_AVAILABLE if the list of cameras cannot be retrieved.
-  static nsresult GetListOfCameras(nsTArray<nsString>& aList);
-
-  enum Mode {
-    kUnspecifiedMode,
-    kPictureMode,
-    kVideoMode,
-  };
-
-  struct Size {
-    uint32_t  width;
-    uint32_t  height;
-
-    bool Equals(const Size& aSize) const
-    {
-      return width == aSize.width && height == aSize.height;
-    }
-  };
-
-  struct Region {
-    int32_t   top;
-    int32_t   left;
-    int32_t   bottom;
-    int32_t   right;
-    uint32_t  weight;
-  };
-
-  struct Position {
-    double    latitude;
-    double    longitude;
-    double    altitude;
-    double    timestamp;
-  };
-
-  struct StartRecordingOptions {
-    uint32_t  rotation;
-    uint64_t  maxFileSizeBytes;
-    uint64_t  maxVideoLengthMs;
-    bool      autoEnableLowLightTorch;
-    bool      createPoster;
-  };
-
-  struct Configuration {
-    Mode      mMode;
-    Size      mPreviewSize;
-    Size      mPictureSize;
-    nsString  mRecorderProfile;
-  };
-
-  struct Point {
-    int32_t   x;
-    int32_t   y;
-  };
-
-  struct Face {
-    uint32_t  id;
-    uint32_t  score;
-    Region    bound;
-    bool      hasLeftEye;
-    Point     leftEye;
-    bool      hasRightEye;
-    Point     rightEye;
-    bool      hasMouth;
-    Point     mouth;
-  };
-
-  class RecorderProfile
-  {
-  public:
-    class Video
-    {
-    public:
-      Video() { }
-      virtual ~Video() { }
-
-      const nsString& GetCodec() const    { return mCodec; }
-      const Size& GetSize() const         { return mSize; }
-      uint32_t GetBitsPerSecond() const   { return mBitsPerSecond; }
-      uint32_t GetFramesPerSecond() const { return mFramesPerSecond; }
-
-    protected:
-      nsString  mCodec;
-      Size      mSize;
-      uint32_t  mBitsPerSecond;
-      uint32_t  mFramesPerSecond;
-
-    private:
-      DISALLOW_EVIL_CONSTRUCTORS(Video);
-    };
-
-    class Audio
-    {
-    public:
-      Audio() { }
-      virtual ~Audio() { }
-
-      const nsString& GetCodec() const    { return mCodec; }
-
-      uint32_t GetChannels() const        { return mChannels; }
-      uint32_t GetBitsPerSecond() const   { return mBitsPerSecond; }
-      uint32_t GetSamplesPerSecond() const { return mSamplesPerSecond; }
-
-    protected:
-      nsString  mCodec;
-      uint32_t  mChannels;
-      uint32_t  mBitsPerSecond;
-      uint32_t  mSamplesPerSecond;
-
-    private:
-      DISALLOW_EVIL_CONSTRUCTORS(Audio);
-    };
-
-    NS_INLINE_DECL_THREADSAFE_REFCOUNTING(RecorderProfile)
-
-    RecorderProfile()
-    { }
-
-    const nsString& GetName() const       { return mName; }
-    const nsString& GetContainer() const  { return mContainer; }
-    const nsString& GetMimeType() const   { return mMimeType; }
-    uint32_t GetPriority() const          { return mPriority; }
-
-    virtual const Video& GetVideo() const = 0;
-    virtual const Audio& GetAudio() const = 0;
-
-  protected:
-    virtual ~RecorderProfile() { }
-
-    nsString    mName;
-    nsString    mContainer;
-    nsString    mMimeType;
-    uint32_t    mPriority;
-
-  private:
-    DISALLOW_EVIL_CONSTRUCTORS(RecorderProfile);
-  };
-
-  static already_AddRefed<ICameraControl> Create(uint32_t aCameraId);
-
-  virtual void AddListener(CameraControlListener* aListener) = 0;
-  virtual void RemoveListener(CameraControlListener* aListener) = 0;
-
-  // Camera control methods.
-  //
-  // Return values:
-  //  - NS_OK on success (if the method requires an asynchronous process,
-  //      this value indicates that the process has begun successfully);
-  //  - NS_ERROR_INVALID_ARG if one or more arguments is invalid;
-  //  - NS_ERROR_FAILURE if an asynchronous method could not be dispatched.
-  virtual nsresult Start(const Configuration* aInitialConfig = nullptr) = 0;
-  virtual nsresult Stop() = 0;
-  virtual nsresult SetConfiguration(const Configuration& aConfig) = 0;
-  virtual nsresult StartPreview() = 0;
-  virtual nsresult StopPreview() = 0;
-  virtual nsresult AutoFocus() = 0;
-  virtual nsresult TakePicture() = 0;
-  virtual nsresult StartRecording(DeviceStorageFileDescriptor* aFileDescriptor,
-                                  const StartRecordingOptions* aOptions = nullptr) = 0;
-  virtual nsresult StopRecording() = 0;
-  virtual nsresult PauseRecording() = 0;
-  virtual nsresult ResumeRecording() = 0;
-  virtual nsresult StartFaceDetection() = 0;
-  virtual nsresult StopFaceDetection() = 0;
-  virtual nsresult ResumeContinuousFocus() = 0;
-
-  // Camera parameter getters and setters. 'aKey' must be one of the
-  // CAMERA_PARAM_* values enumerated above.
-  //
-  // 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.
-  virtual nsresult Set(uint32_t aKey, const nsAString& aValue) = 0;
-  virtual nsresult Get(uint32_t aKey, nsAString& aValue) = 0;
-  virtual nsresult Set(uint32_t aKey, double aValue) = 0;
-  virtual nsresult Get(uint32_t aKey, double& aValue) = 0;
-  virtual nsresult Set(uint32_t aKey, int32_t aValue) = 0;
-  virtual nsresult Get(uint32_t aKey, int32_t& aValue) = 0;
-  virtual nsresult Set(uint32_t aKey, int64_t aValue) = 0;
-  virtual nsresult Get(uint32_t aKey, int64_t& aValue) = 0;
-  virtual nsresult Set(uint32_t aKey, bool aValue) = 0;
-  virtual nsresult Get(uint32_t aKey, bool& aValue) = 0;
-  virtual nsresult Set(uint32_t aKey, const Size& aValue) = 0;
-  virtual nsresult Get(uint32_t aKey, Size& aValue) = 0;
-  virtual nsresult Set(uint32_t aKey, const nsTArray<Region>& aRegions) = 0;
-  virtual nsresult Get(uint32_t aKey, nsTArray<Region>& aRegions) = 0;
-
-  virtual nsresult SetLocation(const Position& aLocation) = 0;
-
-  virtual nsresult Get(uint32_t aKey, nsTArray<Size>& aSizes) = 0;
-  virtual nsresult Get(uint32_t aKey, nsTArray<nsString>& aValues) = 0;
-  virtual nsresult Get(uint32_t aKey, nsTArray<double>& aValues) = 0;
-
-  virtual nsresult GetRecorderProfiles(nsTArray<nsString>& aProfiles) = 0;
-  virtual RecorderProfile* GetProfileInfo(const nsAString& aProfile) = 0;
-
-protected:
-  virtual ~ICameraControl() { }
-
-  friend class ICameraControlParameterSetAutoEnter;
-
-  virtual void BeginBatchParameterSet() = 0;
-  virtual void EndBatchParameterSet() = 0;
-};
-
-// Helper class to make it easy to update a batch of camera parameters;
-// the parameters are applied atomically when this object goes out of
-// scope.
-class ICameraControlParameterSetAutoEnter
-{
-public:
-  explicit ICameraControlParameterSetAutoEnter(ICameraControl* aCameraControl)
-    : mCameraControl(aCameraControl)
-  {
-    mCameraControl->BeginBatchParameterSet();
-  }
-  virtual ~ICameraControlParameterSetAutoEnter()
-  {
-    mCameraControl->EndBatchParameterSet();
-  }
-
-protected:
-  RefPtr<ICameraControl> mCameraControl;
-};
-
-} // namespace mozilla
-
-#endif // DOM_CAMERA_ICAMERACONTROL_H
deleted file mode 100644
--- a/dom/camera/README
+++ /dev/null
@@ -1,28 +0,0 @@
-This README file details from where some of the camcorder source files were derived from and how to apply the provided patch file to get the updated files for B2G.
----------------------------------
-
-Following is the list of B2G files which were derived from an android ics_chocolate build. It also shows the corresponding locations where the original source files can be found:
-
-GonkRecoder.cpp:
-https://www.codeaurora.org/gitweb/quic/la/?p=platform/frameworks/base.git;a=blob;f=media/libmediaplayerservice/StagefrightRecorder.cpp;hb=ef1672482a9c2b88d8017927df68144fee42626c
-
-GonkRecorder.h:
-https://www.codeaurora.org/gitweb/quic/la/?p=platform/frameworks/base.git;a=blob;f=media/libmediaplayerservice/StagefrightRecorder.h;hb=e3682213bcd3fe43b059e00f0fe4dbebc3f3c35d
-
-GonkCameraSource.cpp:
-https://www.codeaurora.org/gitweb/quic/la/?p=platform/frameworks/base.git;a=blob;f=media/libstagefright/CameraSource.cpp;hb=7fa677babfee9c241a131b22c9c1c5ab512ef2d2
-
-GonkCameraSource.h:
-https://www.codeaurora.org/gitweb/quic/la/?p=platform/frameworks/base.git;a=blob;f=include/media/stagefright/CameraSource.h;hb=96af14d9b013496accf40a85a66fefcba3ac0111
-
-AudioParameter.cpp:
-https://www.codeaurora.org/gitweb/quic/la/?p=platform/frameworks/base.git;a=blob;f=media/libmedia/AudioParameter.cpp;hb=4dc22e77cfd2a1c3671e5646ee87c5e4c15596a0
-
-GonkCameraListener.h:
-https://www.codeaurora.org/gitweb/quic/la/?p=platform/frameworks/base.git;a=blob;f=include/camera/Camera.h;hb=796f35e408d9dca386f90d8fbde80471ac011fa6
-
-There were quite a few changes done to the above listed sources to support camcorder on B2G platform.
-update.patch lists the changes on top of the original files.
-update.sh shell script copies the files from an android tree and applies the patch to get updated files for B2G.
-
-
deleted file mode 100644
--- a/dom/camera/moz.build
+++ /dev/null
@@ -1,45 +0,0 @@
-# -*- Mode: python; indent-tabs-mode: nil; tab-width: 40 -*-
-# vim: set filetype=python:
-# 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/.
-
-EXPORTS += [
-    'CameraCommon.h',
-    'CameraPreferences.h',
-    'DOMCameraManager.h',
-]
-
-UNIFIED_SOURCES += [
-    'CameraControlImpl.cpp',
-    'CameraPreferences.cpp',
-    'CameraPreviewMediaStream.cpp',
-    'DOMCameraCapabilities.cpp',
-    'DOMCameraControl.cpp',
-    'DOMCameraControlListener.cpp',
-    'DOMCameraDetectedFace.cpp',
-    'DOMCameraManager.cpp',
-]
-
-UNIFIED_SOURCES += [
-    'FallbackCameraControl.cpp',
-    'FallbackCameraManager.cpp',
-]
-
-LOCAL_INCLUDES += [
-    '../base',
-    '/media/libyuv/include',
-]
-
-include('/ipc/chromium/chromium-config.mozbuild')
-
-# Suppress some GCC warnings being treated as errors:
-#  - about attributes on forward declarations for types that are already
-#    defined, which complains about an important MOZ_EXPORT for android::AString
-if CONFIG['GNU_CC']:
-    CXXFLAGS += [
-        '-Wno-error=attributes',
-        '-Wno-error=shadow',
-    ]
-
-FINAL_LIBRARY = 'xul'
deleted file mode 100644
--- a/dom/camera/update.patch
+++ /dev/null
@@ -1,2296 +0,0 @@
-diff --git a/GonkCameraListener.h b/GonkCameraListener.h
-index 67eeef3..243264c 100644
---- a/GonkCameraListener.h
-+++ b/GonkCameraListener.h
-@@ -14,49 +14,16 @@
-  * limitations under the License.
-  */
- 
--#ifndef ANDROID_HARDWARE_CAMERA_H
--#define ANDROID_HARDWARE_CAMERA_H
-+#ifndef GONK_CAMERA_LISTENER_H
-+#define GONK_CAMERA_LISTENER_H
- 
- #include <utils/Timers.h>
--#include <gui/ISurfaceTexture.h>
--#include <system/camera.h>
--#include <camera/ICameraClient.h>
--#include <camera/ICameraRecordingProxy.h>
--#include <camera/ICameraRecordingProxyListener.h>
-+#include "libcameraservice/CameraHardwareInterface.h"
- 
- namespace android {
- 
--struct CameraInfo {
--    /**
--     * The direction that the camera faces to. It should be CAMERA_FACING_BACK
--     * or CAMERA_FACING_FRONT.
--     */
--    int facing;
--
--    /**
--     * The orientation of the camera image. The value is the angle that the
--     * camera image needs to be rotated clockwise so it shows correctly on the
--     * display in its natural orientation. It should be 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.
--     */
--    int orientation;
--    int mode;
--};
--
--class ICameraService;
--class ICamera;
--class Surface;
--class Mutex;
--class String8;
--
- // ref-counted object for callbacks
--class CameraListener: virtual public RefBase
-+class GonkCameraListener: virtual public RefBase
- {
- public:
-     virtual void notify(int32_t msgType, int32_t ext1, int32_t ext2) = 0;
-@@ -65,133 +32,6 @@ public:
-     virtual void postDataTimestamp(nsecs_t timestamp, int32_t msgType, const sp<IMemory>& dataPtr) = 0;
- };
- 
--class Camera : public BnCameraClient, public IBinder::DeathRecipient
--{
--public:
--            // construct a camera client from an existing remote
--    static  sp<Camera>  create(const sp<ICamera>& camera);
--    static  int32_t     getNumberOfCameras();
--    static  status_t    getCameraInfo(int cameraId,
--                                      struct CameraInfo* cameraInfo);
--    static  sp<Camera>  connect(int cameraId);
--            virtual     ~Camera();
--            void        init();
--
--            status_t    reconnect();
--            void        disconnect();
--            status_t    lock();
--            status_t    unlock();
--
--            status_t    getStatus() { return mStatus; }
--
--            // pass the buffered Surface to the camera service
--            status_t    setPreviewDisplay(const sp<Surface>& surface);
--
--            // pass the buffered ISurfaceTexture to the camera service
--            status_t    setPreviewTexture(const sp<ISurfaceTexture>& surfaceTexture);
--
--            // start preview mode, must call setPreviewDisplay first
--            status_t    startPreview();
--
--            // stop preview mode
--            void        stopPreview();
--
--            // get preview state
--            bool        previewEnabled();
--
--            // start recording mode, must call setPreviewDisplay first
--            status_t    startRecording();
--
--            // stop recording mode
--            void        stopRecording();
--
--            // get recording state
--            bool        recordingEnabled();
--
--            // release a recording frame
--            void        releaseRecordingFrame(const sp<IMemory>& mem);
--
--            // autoFocus - status returned from callback
--            status_t    autoFocus();
--
--            // cancel auto focus
--            status_t    cancelAutoFocus();
--
--            // take a picture - picture returned from callback
--            status_t    takePicture(int msgType);
--
--            // set preview/capture parameters - key/value pairs
--            status_t    setParameters(const String8& params);
--
--            // get preview/capture parameters - key/value pairs
--            String8     getParameters() const;
--
--            // send command to camera driver
--            status_t    sendCommand(int32_t cmd, int32_t arg1, int32_t arg2);
--
--            // tell camera hal to store meta data or real YUV in video buffers.
--            status_t    storeMetaDataInBuffers(bool enabled);
--
--            void        setListener(const sp<CameraListener>& listener);
--            void        setRecordingProxyListener(const sp<ICameraRecordingProxyListener>& listener);
--            void        setPreviewCallbackFlags(int preview_callback_flag);
--
--            sp<ICameraRecordingProxy> getRecordingProxy();
--
--    // ICameraClient interface
--    virtual void        notifyCallback(int32_t msgType, int32_t ext, int32_t ext2);
--    virtual void        dataCallback(int32_t msgType, const sp<IMemory>& dataPtr,
--                                     camera_frame_metadata_t *metadata);
--    virtual void        dataCallbackTimestamp(nsecs_t timestamp, int32_t msgType, const sp<IMemory>& dataPtr);
--
--    sp<ICamera>         remote();
--
--    class RecordingProxy : public BnCameraRecordingProxy
--    {
--    public:
--        RecordingProxy(const sp<Camera>& camera);
--
--        // ICameraRecordingProxy interface
--        virtual status_t startRecording(const sp<ICameraRecordingProxyListener>& listener);
--        virtual void stopRecording();
--        virtual void releaseRecordingFrame(const sp<IMemory>& mem);
--
--    private:
--        sp<Camera>         mCamera;
--    };
--
--private:
--                        Camera();
--                        Camera(const Camera&);
--                        Camera& operator=(const Camera);
--                        virtual void binderDied(const wp<IBinder>& who);
--
--            class DeathNotifier: public IBinder::DeathRecipient
--            {
--            public:
--                DeathNotifier() {
--                }
--
--                virtual void binderDied(const wp<IBinder>& who);
--            };
--
--            static sp<DeathNotifier> mDeathNotifier;
--
--            // helper function to obtain camera service handle
--            static const sp<ICameraService>& getCameraService();
--
--            sp<ICamera>         mCamera;
--            status_t            mStatus;
--
--            sp<CameraListener>  mListener;
--            sp<ICameraRecordingProxyListener>  mRecordingProxyListener;
--
--            friend class DeathNotifier;
--
--            static  Mutex               mLock;
--            static  sp<ICameraService>  mCameraService;
--};
--
- }; // namespace android
- 
- #endif
-diff --git a/GonkCameraSource.cpp b/GonkCameraSource.cpp
-index af6b340..9dba596 100644
---- a/GonkCameraSource.cpp
-+++ b/GonkCameraSource.cpp
-@@ -14,29 +14,34 @@
-  * limitations under the License.
-  */
- 
--//#define LOG_NDEBUG 0
--#define LOG_TAG "CameraSource"
--#include <utils/Log.h>
-+#include <base/basictypes.h>
-+#include "nsDebug.h"
-+#define DOM_CAMERA_LOG_LEVEL        3
-+#include "CameraCommon.h"
-+#define LOGD DOM_CAMERA_LOGA
-+#define LOGV DOM_CAMERA_LOGI
-+#define LOGI DOM_CAMERA_LOGI
-+#define LOGW DOM_CAMERA_LOGW
-+#define LOGE DOM_CAMERA_LOGE
- 
- #include <OMX_Component.h>
--#include <binder/IPCThreadState.h>
--#include <media/stagefright/CameraSource.h>
-+#include "GonkCameraSource.h"
-+#include "GonkCameraListener.h"
-+#include "GonkCameraHwMgr.h"
- #include <media/stagefright/MediaDebug.h>
- #include <media/stagefright/MediaDefs.h>
- #include <media/stagefright/MediaErrors.h>
- #include <media/stagefright/MetaData.h>
--#include <camera/Camera.h>
--#include <camera/CameraParameters.h>
--#include <surfaceflinger/Surface.h>
- #include <utils/String8.h>
- #include <cutils/properties.h>
- 
-+using namespace mozilla;
- namespace android {
- 
- static const int64_t CAMERA_SOURCE_TIMEOUT_NS = 3000000000LL;
- 
--struct CameraSourceListener : public CameraListener {
--    CameraSourceListener(const sp<CameraSource> &source);
-+struct GonkCameraSourceListener : public GonkCameraListener {
-+    GonkCameraSourceListener(const sp<GonkCameraSource> &source);
- 
-     virtual void notify(int32_t msgType, int32_t ext1, int32_t ext2);
-     virtual void postData(int32_t msgType, const sp<IMemory> &dataPtr,
-@@ -46,41 +51,41 @@ struct CameraSourceListener : public CameraListener {
-             nsecs_t timestamp, int32_t msgType, const sp<IMemory>& dataPtr);
- 
- protected:
--    virtual ~CameraSourceListener();
-+    virtual ~GonkCameraSourceListener();
- 
- private:
--    wp<CameraSource> mSource;
-+    wp<GonkCameraSource> mSource;
- 
--    CameraSourceListener(const CameraSourceListener &);
--    CameraSourceListener &operator=(const CameraSourceListener &);
-+    GonkCameraSourceListener(const GonkCameraSourceListener &);
-+    GonkCameraSourceListener &operator=(const GonkCameraSourceListener &);
- };
- 
--CameraSourceListener::CameraSourceListener(const sp<CameraSource> &source)
-+GonkCameraSourceListener::GonkCameraSourceListener(const sp<GonkCameraSource> &source)
-     : mSource(source) {
- }
- 
--CameraSourceListener::~CameraSourceListener() {
-+GonkCameraSourceListener::~GonkCameraSourceListener() {
- }
- 
--void CameraSourceListener::notify(int32_t msgType, int32_t ext1, int32_t ext2) {
-+void GonkCameraSourceListener::notify(int32_t msgType, int32_t ext1, int32_t ext2) {
-     LOGV("notify(%d, %d, %d)", msgType, ext1, ext2);
- }
- 
--void CameraSourceListener::postData(int32_t msgType, const sp<IMemory> &dataPtr,
-+void GonkCameraSourceListener::postData(int32_t msgType, const sp<IMemory> &dataPtr,
-                                     camera_frame_metadata_t *metadata) {
-     LOGV("postData(%d, ptr:%p, size:%d)",
-          msgType, dataPtr->pointer(), dataPtr->size());
- 
--    sp<CameraSource> source = mSource.promote();
-+    sp<GonkCameraSource> source = mSource.promote();
-     if (source.get() != NULL) {
-         source->dataCallback(msgType, dataPtr);
-     }
- }
- 
--void CameraSourceListener::postDataTimestamp(
-+void GonkCameraSourceListener::postDataTimestamp(
-         nsecs_t timestamp, int32_t msgType, const sp<IMemory>& dataPtr) {
- 
--    sp<CameraSource> source = mSource.promote();
-+    sp<GonkCameraSource> source = mSource.promote();
-     if (source.get() != NULL) {
-         source->dataCallbackTimestamp(timestamp/1000, msgType, dataPtr);
-     }
-@@ -114,48 +119,30 @@ static int32_t getColorFormat(const char* colorFormat) {
-     }
- 
-     LOGE("Uknown color format (%s), please add it to "
--         "CameraSource::getColorFormat", colorFormat);
-+         "GonkCameraSource::getColorFormat", colorFormat);
- 
-     CHECK_EQ(0, "Unknown color format");
- }
- 
--CameraSource *CameraSource::Create() {
--    Size size;
--    size.width = -1;
--    size.height = -1;
--
--    sp<ICamera> camera;
--    return new CameraSource(camera, NULL, 0, size, -1, NULL, false);
--}
--
--// static
--CameraSource *CameraSource::CreateFromCamera(
--    const sp<ICamera>& camera,
--    const sp<ICameraRecordingProxy>& proxy,
--    int32_t cameraId,
-+GonkCameraSource *GonkCameraSource::Create(
-+    int32_t cameraHandle,
-     Size videoSize,
-     int32_t frameRate,
--    const sp<Surface>& surface,
-     bool storeMetaDataInVideoBuffers) {
- 
--    CameraSource *source = new CameraSource(camera, proxy, cameraId,
--                    videoSize, frameRate, surface,
-+    GonkCameraSource *source = new GonkCameraSource(cameraHandle,
-+                    videoSize, frameRate,
-                     storeMetaDataInVideoBuffers);
-     return source;
- }
- 
--CameraSource::CameraSource(
--    const sp<ICamera>& camera,
--    const sp<ICameraRecordingProxy>& proxy,
--    int32_t cameraId,
-+GonkCameraSource::GonkCameraSource(
-+    int32_t cameraHandle,
-     Size videoSize,
-     int32_t frameRate,
--    const sp<Surface>& surface,
-     bool storeMetaDataInVideoBuffers)
-     : mCameraFlags(0),
-       mVideoFrameRate(-1),
--      mCamera(0),
--      mSurface(surface),
-       mNumFramesReceived(0),
-       mLastFrameTimestampUs(0),
-       mStarted(false),
-@@ -169,43 +156,19 @@ CameraSource::CameraSource(
-     mVideoSize.width  = -1;
-     mVideoSize.height = -1;
- 
--    mInitCheck = init(camera, proxy, cameraId,
-+    mCameraHandle = cameraHandle;
-+
-+    mInitCheck = init(
-                     videoSize, frameRate,
-                     storeMetaDataInVideoBuffers);
-     if (mInitCheck != OK) releaseCamera();
- }
- 
--status_t CameraSource::initCheck() const {
-+status_t GonkCameraSource::initCheck() const {
-     return mInitCheck;
- }
- 
--status_t CameraSource::isCameraAvailable(
--    const sp<ICamera>& camera, const sp<ICameraRecordingProxy>& proxy,
--    int32_t cameraId) {
--
--    if (camera == 0) {
--        mCamera = Camera::connect(cameraId);
--        if (mCamera == 0) return -EBUSY;
--        mCameraFlags &= ~FLAGS_HOT_CAMERA;
--    } else {
--        // We get the proxy from Camera, not ICamera. We need to get the proxy
--        // to the remote Camera owned by the application. Here mCamera is a
--        // local Camera object created by us. We cannot use the proxy from
--        // mCamera here.
--        mCamera = Camera::create(camera);
--        if (mCamera == 0) return -EBUSY;
--        mCameraRecordingProxy = proxy;
--        mCameraFlags |= FLAGS_HOT_CAMERA;
--        mDeathNotifier = new DeathNotifier();
--        // isBinderAlive needs linkToDeath to work.
--        mCameraRecordingProxy->asBinder()->linkToDeath(mDeathNotifier);
--    }
--
--    mCamera->lock();
--
--    return OK;
--}
--
-+//TODO: Do we need to reimplement isCameraAvailable?
- 
- /*
-  * Check to see whether the requested video width and height is one
-@@ -267,7 +230,7 @@ static void getSupportedVideoSizes(
-  * @param params CameraParameters to retrieve the information
-  * @return OK if no error.
-  */
--status_t CameraSource::isCameraColorFormatSupported(
-+status_t GonkCameraSource::isCameraColorFormatSupported(
-         const CameraParameters& params) {
-     mColorFormat = getColorFormat(params.get(
-             CameraParameters::KEY_VIDEO_FRAME_FORMAT));
-@@ -292,7 +255,7 @@ status_t CameraSource::isCameraColorFormatSupported(
-  * @param frameRate the target frame rate in frames per second.
-  * @return OK if no error.
-  */
--status_t CameraSource::configureCamera(
-+status_t GonkCameraSource::configureCamera(
-         CameraParameters* params,
-         int32_t width, int32_t height,
-         int32_t frameRate) {
-@@ -347,10 +310,9 @@ status_t CameraSource::configureCamera(
- 
-     if (isCameraParamChanged) {
-         // Either frame rate or frame size needs to be changed.
--        String8 s = params->flatten();
--        if (OK != mCamera->setParameters(s)) {
-+        if (OK != GonkCameraHardware::PushParameters(mCameraHandle,*params)) {
-             LOGE("Could not change settings."
--                 " Someone else is using camera %p?", mCamera.get());
-+                 " Someone else is using camera ?");
-             return -EBUSY;
-         }
-     }
-@@ -368,7 +330,7 @@ status_t CameraSource::configureCamera(
-  * @param the target video frame height in pixels to check against
-  * @return OK if no error
-  */
--status_t CameraSource::checkVideoSize(
-+status_t GonkCameraSource::checkVideoSize(
-         const CameraParameters& params,
-         int32_t width, int32_t height) {
- 
-@@ -420,7 +382,7 @@ status_t CameraSource::checkVideoSize(
-  * @param the target video frame rate to check against
-  * @return OK if no error.
-  */
--status_t CameraSource::checkFrameRate(
-+status_t GonkCameraSource::checkFrameRate(
-         const CameraParameters& params,
-         int32_t frameRate) {
- 
-@@ -462,39 +424,17 @@ status_t CameraSource::checkFrameRate(
-  *
-  * @return OK if no error.
-  */
--status_t CameraSource::init(
--        const sp<ICamera>& camera,
--        const sp<ICameraRecordingProxy>& proxy,
--        int32_t cameraId,
-+status_t GonkCameraSource::init(
-         Size videoSize,
-         int32_t frameRate,
-         bool storeMetaDataInVideoBuffers) {
- 
-     LOGV("init");
-     status_t err = OK;
--    int64_t token = IPCThreadState::self()->clearCallingIdentity();
--    err = initWithCameraAccess(camera, proxy, cameraId,
--                               videoSize, frameRate,
--                               storeMetaDataInVideoBuffers);
--    IPCThreadState::self()->restoreCallingIdentity(token);
--    return err;
--}
--
--status_t CameraSource::initWithCameraAccess(
--        const sp<ICamera>& camera,
--        const sp<ICameraRecordingProxy>& proxy,
--        int32_t cameraId,
--        Size videoSize,
--        int32_t frameRate,
--        bool storeMetaDataInVideoBuffers) {
--    LOGV("initWithCameraAccess");
--    status_t err = OK;
-+    //TODO: need to do something here to check the sanity of camera
- 
--    if ((err = isCameraAvailable(camera, proxy, cameraId)) != OK) {
--        LOGE("Camera connection could not be established.");
--        return err;
--    }
--    CameraParameters params(mCamera->getParameters());
-+    CameraParameters params;
-+    GonkCameraHardware::PullParameters(mCameraHandle, params);
-     if ((err = isCameraColorFormatSupported(params)) != OK) {
-         return err;
-     }
-@@ -508,7 +448,8 @@ status_t CameraSource::initWithCameraAccess(
-     }
- 
-     // Check on video frame size and frame rate.
--    CameraParameters newCameraParams(mCamera->getParameters());
-+    CameraParameters newCameraParams;
-+    GonkCameraHardware::PullParameters(mCameraHandle, newCameraParams);
-     if ((err = checkVideoSize(newCameraParams,
-                 videoSize.width, videoSize.height)) != OK) {
-         return err;
-@@ -517,15 +458,11 @@ status_t CameraSource::initWithCameraAccess(
-         return err;
-     }
- 
--    // This CHECK is good, since we just passed the lock/unlock
--    // check earlier by calling mCamera->setParameters().
--    CHECK_EQ(OK, mCamera->setPreviewDisplay(mSurface));
--
-     // By default, do not store metadata in video buffers
-     mIsMetaDataStoredInVideoBuffers = false;
--    mCamera->storeMetaDataInBuffers(false);
-+    GonkCameraHardware::StoreMetaDataInBuffers(mCameraHandle, false);
-     if (storeMetaDataInVideoBuffers) {
--        if (OK == mCamera->storeMetaDataInBuffers(true)) {
-+        if (OK == GonkCameraHardware::StoreMetaDataInBuffers(mCameraHandle, true)) {
-             mIsMetaDataStoredInVideoBuffers = true;
-         }
-     }
-@@ -568,40 +505,28 @@ status_t CameraSource::initWithCameraAccess(
-     return OK;
- }
- 
--CameraSource::~CameraSource() {
-+GonkCameraSource::~GonkCameraSource() {
-     if (mStarted) {
-         stop();
-     } else if (mInitCheck == OK) {
-         // Camera is initialized but because start() is never called,
-         // the lock on Camera is never released(). This makes sure
-         // Camera's lock is released in this case.
-+        // TODO: Don't think I need to do this
-         releaseCamera();
-     }
- }
- 
--void CameraSource::startCameraRecording() {
-+void GonkCameraSource::startCameraRecording() {
-     LOGV("startCameraRecording");
--    // Reset the identity to the current thread because media server owns the
--    // camera and recording is started by the applications. The applications
--    // will connect to the camera in ICameraRecordingProxy::startRecording.
--    int64_t token = IPCThreadState::self()->clearCallingIdentity();
--    if (mCameraFlags & FLAGS_HOT_CAMERA) {
--        mCamera->unlock();
--        mCamera.clear();
--        CHECK_EQ(OK, mCameraRecordingProxy->startRecording(new ProxyListener(this)));
--    } else {
--        mCamera->setListener(new CameraSourceListener(this));
--        mCamera->startRecording();
--        CHECK(mCamera->recordingEnabled());
--    }
--    IPCThreadState::self()->restoreCallingIdentity(token);
-+    CHECK_EQ(OK, GonkCameraHardware::StartRecording(mCameraHandle));
- }
- 
--status_t CameraSource::start(MetaData *meta) {
-+status_t GonkCameraSource::start(MetaData *meta) {
-     LOGV("start");
-     CHECK(!mStarted);
-     if (mInitCheck != OK) {
--        LOGE("CameraSource is not initialized yet");
-+        LOGE("GonkCameraSource is not initialized yet");
-         return mInitCheck;
-     }
- 
-@@ -614,58 +539,34 @@ status_t CameraSource::start(MetaData *meta) {
-     mStartTimeUs = 0;
-     int64_t startTimeUs;
-     if (meta && meta->findInt64(kKeyTime, &startTimeUs)) {
-+        LOGV("Metadata enabled, startime: %lld us", startTimeUs);
-         mStartTimeUs = startTimeUs;
-     }
- 
-+    // Register a listener with GonkCameraHardware so that we can get callbacks
-+    GonkCameraHardware::SetListener(mCameraHandle, new GonkCameraSourceListener(this));
-+
-     startCameraRecording();
- 
-     mStarted = true;
-     return OK;
- }
- 
--void CameraSource::stopCameraRecording() {
-+void GonkCameraSource::stopCameraRecording() {
-     LOGV("stopCameraRecording");
--    if (mCameraFlags & FLAGS_HOT_CAMERA) {
--        mCameraRecordingProxy->stopRecording();
--    } else {
--        mCamera->setListener(NULL);
--        mCamera->stopRecording();
--    }
-+    GonkCameraHardware::StopRecording(mCameraHandle);
- }
- 
--void CameraSource::releaseCamera() {
-+void GonkCameraSource::releaseCamera() {
-     LOGV("releaseCamera");
--    if (mCamera != 0) {
--        int64_t token = IPCThreadState::self()->clearCallingIdentity();
--        if ((mCameraFlags & FLAGS_HOT_CAMERA) == 0) {
--            LOGV("Camera was cold when we started, stopping preview");
--            mCamera->stopPreview();
--            mCamera->disconnect();
--        }
--        mCamera->unlock();
--        mCamera.clear();
--        mCamera = 0;
--        IPCThreadState::self()->restoreCallingIdentity(token);
--    }
--    if (mCameraRecordingProxy != 0) {
--        mCameraRecordingProxy->asBinder()->unlinkToDeath(mDeathNotifier);
--        mCameraRecordingProxy.clear();
--    }
--    mCameraFlags = 0;
- }
- 
--status_t CameraSource::stop() {
--    LOGD("stop: E");
-+status_t GonkCameraSource::stop() {
-+    LOGV("stop: E");
-     Mutex::Autolock autoLock(mLock);
-     mStarted = false;
-     mFrameAvailableCondition.signal();
- 
--    int64_t token;
--    bool isTokenValid = false;
--    if (mCamera != 0) {
--        token = IPCThreadState::self()->clearCallingIdentity();
--        isTokenValid = true;
--    }
-     releaseQueuedFrames();
-     while (!mFramesBeingEncoded.empty()) {
-         if (NO_ERROR !=
-@@ -675,11 +576,9 @@ status_t CameraSource::stop() {
-                 mFramesBeingEncoded.size());
-         }
-     }
-+    LOGV("Calling stopCameraRecording");
-     stopCameraRecording();
-     releaseCamera();
--    if (isTokenValid) {
--        IPCThreadState::self()->restoreCallingIdentity(token);
--    }
- 
-     if (mCollectStats) {
-         LOGI("Frames received/encoded/dropped: %d/%d/%d in %lld us",
-@@ -692,22 +591,16 @@ status_t CameraSource::stop() {
-     }
- 
-     CHECK_EQ(mNumFramesReceived, mNumFramesEncoded + mNumFramesDropped);
--    LOGD("stop: X");
-+    LOGV("stop: X");
-     return OK;
- }
- 
--void CameraSource::releaseRecordingFrame(const sp<IMemory>& frame) {
-+void GonkCameraSource::releaseRecordingFrame(const sp<IMemory>& frame) {
-     LOGV("releaseRecordingFrame");
--    if (mCameraRecordingProxy != NULL) {
--        mCameraRecordingProxy->releaseRecordingFrame(frame);
--    } else if (mCamera != NULL) {
--        int64_t token = IPCThreadState::self()->clearCallingIdentity();
--        mCamera->releaseRecordingFrame(frame);
--        IPCThreadState::self()->restoreCallingIdentity(token);
--    }
-+    GonkCameraHardware::ReleaseRecordingFrame(mCameraHandle, frame);
- }
- 
--void CameraSource::releaseQueuedFrames() {
-+void GonkCameraSource::releaseQueuedFrames() {
-     List<sp<IMemory> >::iterator it;
-     while (!mFramesReceived.empty()) {
-         it = mFramesReceived.begin();
-@@ -717,15 +610,15 @@ void CameraSource::releaseQueuedFrames() {
-     }
- }
- 
--sp<MetaData> CameraSource::getFormat() {
-+sp<MetaData> GonkCameraSource::getFormat() {
-     return mMeta;
- }
- 
--void CameraSource::releaseOneRecordingFrame(const sp<IMemory>& frame) {
-+void GonkCameraSource::releaseOneRecordingFrame(const sp<IMemory>& frame) {
-     releaseRecordingFrame(frame);
- }
- 
--void CameraSource::signalBufferReturned(MediaBuffer *buffer) {
-+void GonkCameraSource::signalBufferReturned(MediaBuffer *buffer) {
-     LOGV("signalBufferReturned: %p", buffer->data());
-     Mutex::Autolock autoLock(mLock);
-     for (List<sp<IMemory> >::iterator it = mFramesBeingEncoded.begin();
-@@ -743,7 +636,7 @@ void CameraSource::signalBufferReturned(MediaBuffer *buffer) {
-     CHECK_EQ(0, "signalBufferReturned: bogus buffer");
- }
- 
--status_t CameraSource::read(
-+status_t GonkCameraSource::read(
-         MediaBuffer **buffer, const ReadOptions *options) {
-     LOGV("read");
- 
-@@ -764,11 +657,7 @@ status_t CameraSource::read(
-             if (NO_ERROR !=
-                 mFrameAvailableCondition.waitRelative(mLock,
-                     mTimeBetweenFrameCaptureUs * 1000LL + CAMERA_SOURCE_TIMEOUT_NS)) {
--                if (mCameraRecordingProxy != 0 &&
--                    !mCameraRecordingProxy->asBinder()->isBinderAlive()) {
--                    LOGW("camera recording proxy is gone");
--                    return ERROR_END_OF_STREAM;
--                }
-+                //TODO: check sanity of camera?
-                 LOGW("Timed out waiting for incoming camera video frames: %lld us",
-                     mLastFrameTimestampUs);
-             }
-@@ -790,9 +679,10 @@ status_t CameraSource::read(
-     return OK;
- }
- 
--void CameraSource::dataCallbackTimestamp(int64_t timestampUs,
-+void GonkCameraSource::dataCallbackTimestamp(int64_t timestampUs,
-         int32_t msgType, const sp<IMemory> &data) {
-     LOGV("dataCallbackTimestamp: timestamp %lld us", timestampUs);
-+    //LOGV("dataCallbackTimestamp: data %x size %d", data->pointer(), data->size());
-     Mutex::Autolock autoLock(mLock);
-     if (!mStarted || (mNumFramesReceived == 0 && timestampUs < mStartTimeUs)) {
-         LOGV("Drop frame at %lld/%lld us", timestampUs, mStartTimeUs);
-@@ -808,7 +698,7 @@ void CameraSource::dataCallbackTimestamp(int64_t timestampUs,
-     }
- 
-     // May need to skip frame or modify timestamp. Currently implemented
--    // by the subclass CameraSourceTimeLapse.
-+    // by the subclass GonkCameraSourceTimeLapse.
-     if (skipCurrentFrame(timestampUs)) {
-         releaseOneRecordingFrame(data);
-         return;
-@@ -839,22 +729,9 @@ void CameraSource::dataCallbackTimestamp(int64_t timestampUs,
-     mFrameAvailableCondition.signal();
- }
- 
--bool CameraSource::isMetaDataStoredInVideoBuffers() const {
-+bool GonkCameraSource::isMetaDataStoredInVideoBuffers() const {
-     LOGV("isMetaDataStoredInVideoBuffers");
-     return mIsMetaDataStoredInVideoBuffers;
- }
- 
--CameraSource::ProxyListener::ProxyListener(const sp<CameraSource>& source) {
--    mSource = source;
--}
--
--void CameraSource::ProxyListener::dataCallbackTimestamp(
--        nsecs_t timestamp, int32_t msgType, const sp<IMemory>& dataPtr) {
--    mSource->dataCallbackTimestamp(timestamp / 1000, msgType, dataPtr);
--}
--
--void CameraSource::DeathNotifier::binderDied(const wp<IBinder>& who) {
--    LOGI("Camera recording proxy died");
--}
--
--}  // namespace android
-+} // namespace android
-diff --git a/GonkCameraSource.h b/GonkCameraSource.h
-index 446720b..fe58f96 100644
---- a/GonkCameraSource.h
-+++ b/GonkCameraSource.h
-@@ -14,69 +14,31 @@
-  * limitations under the License.
-  */
- 
--#ifndef CAMERA_SOURCE_H_
-+#ifndef GONK_CAMERA_SOURCE_H_
- 
--#define CAMERA_SOURCE_H_
-+#define GONK_CAMERA_SOURCE_H_
- 
- #include <media/stagefright/MediaBuffer.h>
- #include <media/stagefright/MediaSource.h>
--#include <camera/ICamera.h>
--#include <camera/ICameraRecordingProxyListener.h>
- #include <camera/CameraParameters.h>
- #include <utils/List.h>
- #include <utils/RefBase.h>
-+#include <utils/threads.h>
- 
- namespace android {
- 
- class IMemory;
--class Camera;
--class Surface;
-+class GonkCameraSourceListener;
- 
--class CameraSource : public MediaSource, public MediaBufferObserver {
-+class GonkCameraSource : public MediaSource, public MediaBufferObserver {
- public:
--    /**
--     * Factory method to create a new CameraSource using the current
--     * settings (such as video size, frame rate, color format, etc)
--     * from the default camera.
--     *
--     * @return NULL on error.
--     */
--    static CameraSource *Create();
- 
--    /**
--     * Factory method to create a new CameraSource.
--     *
--     * @param camera the video input frame data source. If it is NULL,
--     *          we will try to connect to the camera with the given
--     *          cameraId.
--     *
--     * @param cameraId the id of the camera that the source will connect
--     *          to if camera is NULL; otherwise ignored.
--     *
--     * @param videoSize the dimension (in pixels) of the video frame
--     * @param frameRate the target frames per second
--     * @param surface the preview surface for display where preview
--     *          frames are sent to
--     * @param storeMetaDataInVideoBuffers true to request the camera
--     *          source to store meta data in video buffers; false to
--     *          request the camera source to store real YUV frame data
--     *          in the video buffers. The camera source may not support
--     *          storing meta data in video buffers, if so, a request
--     *          to do that will NOT be honored. To find out whether
--     *          meta data is actually being stored in video buffers
--     *          during recording, call isMetaDataStoredInVideoBuffers().
--     *
--     * @return NULL on error.
--     */
--    static CameraSource *CreateFromCamera(const sp<ICamera> &camera,
--                                          const sp<ICameraRecordingProxy> &proxy,
--                                          int32_t cameraId,
--                                          Size videoSize,
--                                          int32_t frameRate,
--                                          const sp<Surface>& surface,
--                                          bool storeMetaDataInVideoBuffers = false);
-+    static GonkCameraSource *Create(int32_t cameraHandle,
-+                                    Size videoSize,
-+                                    int32_t frameRate,
-+                                    bool storeMetaDataInVideoBuffers = false);
- 
--    virtual ~CameraSource();
-+    virtual ~GonkCameraSource();
- 
-     virtual status_t start(MetaData *params = NULL);
-     virtual status_t stop();
-@@ -84,14 +46,14 @@ public:
-             MediaBuffer **buffer, const ReadOptions *options = NULL);
- 
-     /**
--     * Check whether a CameraSource object is properly initialized.
-+     * Check whether a GonkCameraSource object is properly initialized.
-      * Must call this method before stop().
-      * @return OK if initialization has successfully completed.
-      */
-     virtual status_t initCheck() const;
- 
-     /**
--     * Returns the MetaData associated with the CameraSource,
-+     * Returns the MetaData associated with the GonkCameraSource,
-      * including:
-      * kKeyColorFormat: YUV color format of the video frames
-      * kKeyWidth, kKeyHeight: dimension (in pixels) of the video frames
-@@ -113,22 +75,6 @@ public:
-     virtual void signalBufferReturned(MediaBuffer* buffer);
- 
- protected:
--    class ProxyListener: public BnCameraRecordingProxyListener {
--    public:
--        ProxyListener(const sp<CameraSource>& source);
--        virtual void dataCallbackTimestamp(int64_t timestampUs, int32_t msgType,
--                const sp<IMemory> &data);
--
--    private:
--        sp<CameraSource> mSource;
--    };
--
--    // isBinderAlive needs linkToDeath to work.
--    class DeathNotifier: public IBinder::DeathRecipient {
--    public:
--        DeathNotifier() {}
--        virtual void binderDied(const wp<IBinder>& who);
--    };
- 
-     enum CameraFlags {
-         FLAGS_SET_CAMERA = 1L << 0,
-@@ -141,10 +87,6 @@ protected:
-     int32_t  mColorFormat;
-     status_t mInitCheck;
- 
--    sp<Camera>   mCamera;
--    sp<ICameraRecordingProxy>   mCameraRecordingProxy;
--    sp<DeathNotifier> mDeathNotifier;
--    sp<Surface>  mSurface;
-     sp<MetaData> mMeta;
- 
-     int64_t mStartTimeUs;
-@@ -156,11 +98,9 @@ protected:
-     // Time between capture of two frames.
-     int64_t mTimeBetweenFrameCaptureUs;
- 
--    CameraSource(const sp<ICamera>& camera, const sp<ICameraRecordingProxy>& proxy,
--                 int32_t cameraId,
-+    GonkCameraSource(int32_t cameraHandle,
-                  Size videoSize, int32_t frameRate,
--                 const sp<Surface>& surface,
--                 bool storeMetaDataInVideoBuffers);
-+                 bool storeMetaDataInVideoBuffers = false);
- 
-     virtual void startCameraRecording();
-     virtual void stopCameraRecording();
-@@ -170,6 +110,7 @@ protected:
-     // Called from dataCallbackTimestamp.
-     virtual bool skipCurrentFrame(int64_t timestampUs) {return false;}
- 
-+    friend class GonkCameraSourceListener;
-     // Callback called when still camera raw data is available.
-     virtual void dataCallback(int32_t msgType, const sp<IMemory> &data) {}
- 
-@@ -177,7 +118,6 @@ protected:
-             const sp<IMemory> &data);
- 
- private:
--    friend class CameraSourceListener;
- 
-     Mutex mLock;
-     Condition mFrameAvailableCondition;
-@@ -192,23 +132,13 @@ private:
-     int64_t mGlitchDurationThresholdUs;
-     bool mCollectStats;
-     bool mIsMetaDataStoredInVideoBuffers;
-+    int32_t mCameraHandle;
- 
-     void releaseQueuedFrames();
-     void releaseOneRecordingFrame(const sp<IMemory>& frame);
- 
--
--    status_t init(const sp<ICamera>& camera, const sp<ICameraRecordingProxy>& proxy,
--                  int32_t cameraId, Size videoSize, int32_t frameRate,
--                  bool storeMetaDataInVideoBuffers);
--
--    status_t initWithCameraAccess(
--                  const sp<ICamera>& camera, const sp<ICameraRecordingProxy>& proxy,
--                  int32_t cameraId, Size videoSize, int32_t frameRate,
-+    status_t init(Size videoSize, int32_t frameRate,
-                   bool storeMetaDataInVideoBuffers);
--
--    status_t isCameraAvailable(const sp<ICamera>& camera,
--                               const sp<ICameraRecordingProxy>& proxy,
--                               int32_t cameraId);
-     status_t isCameraColorFormatSupported(const CameraParameters& params);
-     status_t configureCamera(CameraParameters* params,
-                     int32_t width, int32_t height,
-@@ -222,10 +152,10 @@ private:
- 
-     void releaseCamera();
- 
--    CameraSource(const CameraSource &);
--    CameraSource &operator=(const CameraSource &);
-+    GonkCameraSource(const GonkCameraSource &);
-+    GonkCameraSource &operator=(const GonkCameraSource &);
- };
- 
- }  // namespace android
- 
--#endif  // CAMERA_SOURCE_H_
-+#endif  // GONK_CAMERA_SOURCE_H_
-diff --git a/GonkRecorder.cpp b/GonkRecorder.cpp
-index b20ca9d..2dc625c 100644
---- a/GonkRecorder.cpp
-+++ b/GonkRecorder.cpp
-@@ -16,35 +16,23 @@
-  */
- 
- //#define LOG_NDEBUG 0
--#define LOG_TAG "StagefrightRecorder"
-+#define LOG_TAG "GonkRecorder"
-+
- #include <utils/Log.h>
- #include <media/AudioParameter.h>
--#include "StagefrightRecorder.h"
--
--#include <binder/IPCThreadState.h>
--#include <binder/IServiceManager.h>
-+#include "GonkRecorder.h"
- 
--#include <media/IMediaPlayerService.h>
- #include <media/stagefright/AudioSource.h>
- #include <media/stagefright/AMRWriter.h>
--#include <media/stagefright/AACWriter.h>
--#include <media/stagefright/ExtendedWriter.h>
--#include <media/stagefright/FMA2DPWriter.h>
--#include <media/stagefright/CameraSource.h>
--#include <media/stagefright/CameraSourceTimeLapse.h>
- #include <media/stagefright/ExtendedWriter.h>
- #include <media/stagefright/MPEG2TSWriter.h>
- #include <media/stagefright/MPEG4Writer.h>
- #include <media/stagefright/MediaDebug.h>
- #include <media/stagefright/MediaDefs.h>
- #include <media/stagefright/MetaData.h>
--#include <media/stagefright/OMXClient.h>
-+#include <OMX.h>
- #include <media/stagefright/OMXCodec.h>
--#include <media/stagefright/SurfaceMediaSource.h>
- #include <media/MediaProfiles.h>
--#include <camera/ICamera.h>
--#include <camera/CameraParameters.h>
--#include <surfaceflinger/Surface.h>
- #include <utils/String8.h>
- 
- #include <utils/Errors.h>
-@@ -57,51 +45,41 @@
- #include "ARTPWriter.h"
- 
- #include <cutils/properties.h>
-+#include "GonkCameraSource.h"
- 
- namespace android {
- 
--// To collect the encoder usage for the battery app
--static void addBatteryData(uint32_t params) {
--    sp<IBinder> binder =
--        defaultServiceManager()->getService(String16("media.player"));
--    sp<IMediaPlayerService> service = interface_cast<IMediaPlayerService>(binder);
--    CHECK(service.get() != NULL);
--
--    service->addBatteryData(params);
-+static sp<IOMX> sOMX = NULL;
-+static sp<IOMX> GetOMX() {
-+  if(sOMX.get() == NULL) {
-+    sOMX = new OMX;
-+    }
-+  return sOMX;
- }
- 
--
--StagefrightRecorder::StagefrightRecorder()
-+GonkRecorder::GonkRecorder()
-     : mWriter(NULL),
-       mOutputFd(-1),
-       mAudioSource(AUDIO_SOURCE_CNT),
-       mVideoSource(VIDEO_SOURCE_LIST_END),
--      mStarted(false), mSurfaceMediaSource(NULL),
-+      mStarted(false),
-       mDisableAudio(false) {
- 
-     LOGV("Constructor");
-     reset();
- }
- 
--StagefrightRecorder::~StagefrightRecorder() {
-+GonkRecorder::~GonkRecorder() {
-     LOGV("Destructor");
-     stop();
- }
- 
--status_t StagefrightRecorder::init() {
-+status_t GonkRecorder::init() {
-     LOGV("init");
-     return OK;
- }
- 
--// The client side of mediaserver asks it to creat a SurfaceMediaSource
--// and return a interface reference. The client side will use that
--// while encoding GL Frames
--sp<ISurfaceTexture> StagefrightRecorder::querySurfaceMediaSource() const {
--    LOGV("Get SurfaceMediaSource");
--    return mSurfaceMediaSource;
--}
--
--status_t StagefrightRecorder::setAudioSource(audio_source_t as) {
-+status_t GonkRecorder::setAudioSource(audio_source_t as) {
-     LOGV("setAudioSource: %d", as);
-     if (as < AUDIO_SOURCE_DEFAULT ||
-         as >= AUDIO_SOURCE_CNT) {
-@@ -122,7 +100,7 @@
-     return OK;
- }
- 
--status_t StagefrightRecorder::setVideoSource(video_source vs) {
-+status_t GonkRecorder::setVideoSource(video_source vs) {
-     LOGV("setVideoSource: %d", vs);
-     if (vs < VIDEO_SOURCE_DEFAULT ||
-         vs >= VIDEO_SOURCE_LIST_END) {
-@@ -139,7 +117,7 @@
-     return OK;
- }
- 
--status_t StagefrightRecorder::setOutputFormat(output_format of) {
-+status_t GonkRecorder::setOutputFormat(output_format of) {
-     LOGV("setOutputFormat: %d", of);
-     if (of < OUTPUT_FORMAT_DEFAULT ||
-         of >= OUTPUT_FORMAT_LIST_END) {
-@@ -156,7 +134,7 @@
-     return OK;
- }
- 
--status_t StagefrightRecorder::setAudioEncoder(audio_encoder ae) {
-+status_t GonkRecorder::setAudioEncoder(audio_encoder ae) {
-     LOGV("setAudioEncoder: %d", ae);
-     if (ae < AUDIO_ENCODER_DEFAULT ||
-         ae >= AUDIO_ENCODER_LIST_END) {
-@@ -174,21 +152,10 @@
-         mAudioEncoder = ae;
-     }
- 
--    // Use default values if appropriate setparam's weren't called.
--    if(mAudioEncoder == AUDIO_ENCODER_AAC) {
--        mSampleRate = mSampleRate ? mSampleRate : 48000;
--        mAudioChannels = mAudioChannels ? mAudioChannels : 2;
--        mAudioBitRate = mAudioBitRate ? mAudioBitRate : 156000;
--    }
--    else{
--        mSampleRate = mSampleRate ? mSampleRate : 8000;
--        mAudioChannels = mAudioChannels ? mAudioChannels : 1;
--        mAudioBitRate = mAudioBitRate ? mAudioBitRate : 12200;
--    }
-     return OK;
- }
- 
--status_t StagefrightRecorder::setVideoEncoder(video_encoder ve) {
-+status_t GonkRecorder::setVideoEncoder(video_encoder ve) {
-     LOGV("setVideoEncoder: %d", ve);
-     if (ve < VIDEO_ENCODER_DEFAULT ||
-         ve >= VIDEO_ENCODER_LIST_END) {
-@@ -205,7 +172,7 @@
-     return OK;
- }
- 
--status_t StagefrightRecorder::setVideoSize(int width, int height) {
-+status_t GonkRecorder::setVideoSize(int width, int height) {
-     LOGV("setVideoSize: %dx%d", width, height);
-     if (width <= 0 || height <= 0) {
-         LOGE("Invalid video size: %dx%d", width, height);
-@@ -219,7 +186,7 @@
-     return OK;
- }
- 
--status_t StagefrightRecorder::setVideoFrameRate(int frames_per_second) {
-+status_t GonkRecorder::setVideoFrameRate(int frames_per_second) {
-     LOGV("setVideoFrameRate: %d", frames_per_second);
-     if ((frames_per_second <= 0 && frames_per_second != -1) ||
-         frames_per_second > 120) {
-@@ -233,31 +200,7 @@
-     return OK;
- }
- 
--status_t StagefrightRecorder::setCamera(const sp<ICamera> &camera,
--                                        const sp<ICameraRecordingProxy> &proxy) {
--    LOGV("setCamera");
--    if (camera == 0) {
--        LOGE("camera is NULL");
--        return BAD_VALUE;
--    }
--    if (proxy == 0) {
--        LOGE("camera proxy is NULL");
--        return BAD_VALUE;
--    }
--
--    mCamera = camera;
--    mCameraProxy = proxy;
--    return OK;
--}
--
--status_t StagefrightRecorder::setPreviewSurface(const sp<Surface> &surface) {
--    LOGV("setPreviewSurface: %p", surface.get());
--    mPreviewSurface = surface;
--
--    return OK;
--}
--
--status_t StagefrightRecorder::setOutputFile(const char *path) {
-+status_t GonkRecorder::setOutputFile(const char *path) {
-     LOGE("setOutputFile(const char*) must not be called");
-     // We don't actually support this at all, as the media_server process
-     // no longer has permissions to create files.
-@@ -265,7 +208,7 @@
-     return -EPERM;
- }
- 
--status_t StagefrightRecorder::setOutputFile(int fd, int64_t offset, int64_t length) {
-+status_t GonkRecorder::setOutputFile(int fd, int64_t offset, int64_t length) {
-     LOGV("setOutputFile: %d, %lld, %lld", fd, offset, length);
-     // These don't make any sense, do they?
-     CHECK_EQ(offset, 0);
-@@ -339,7 +282,7 @@
-     s->setTo(String8(&data[leading_space], i - leading_space));
- }
- 
--status_t StagefrightRecorder::setParamAudioSamplingRate(int32_t sampleRate) {
-+status_t GonkRecorder::setParamAudioSamplingRate(int32_t sampleRate) {
-     LOGV("setParamAudioSamplingRate: %d", sampleRate);
-     if (sampleRate <= 0) {
-         LOGE("Invalid audio sampling rate: %d", sampleRate);
-@@ -351,7 +294,7 @@
-     return OK;
- }
- 
--status_t StagefrightRecorder::setParamAudioNumberOfChannels(int32_t channels) {
-+status_t GonkRecorder::setParamAudioNumberOfChannels(int32_t channels) {
-     LOGV("setParamAudioNumberOfChannels: %d", channels);
-     if (channels <= 0 || channels >= 3) {
-         LOGE("Invalid number of audio channels: %d", channels);
-@@ -363,7 +306,7 @@
-     return OK;
- }
- 
--status_t StagefrightRecorder::setParamAudioEncodingBitRate(int32_t bitRate) {
-+status_t GonkRecorder::setParamAudioEncodingBitRate(int32_t bitRate) {
-     LOGV("setParamAudioEncodingBitRate: %d", bitRate);
-     if (bitRate <= 0) {
-         LOGE("Invalid audio encoding bit rate: %d", bitRate);
-@@ -378,7 +321,7 @@
-     return OK;
- }
- 
--status_t StagefrightRecorder::setParamVideoEncodingBitRate(int32_t bitRate) {
-+status_t GonkRecorder::setParamVideoEncodingBitRate(int32_t bitRate) {
-     LOGV("setParamVideoEncodingBitRate: %d", bitRate);
-     if (bitRate <= 0) {
-         LOGE("Invalid video encoding bit rate: %d", bitRate);
-@@ -394,7 +337,7 @@
- }
- 
- // Always rotate clockwise, and only support 0, 90, 180 and 270 for now.
--status_t StagefrightRecorder::setParamVideoRotation(int32_t degrees) {
-+status_t GonkRecorder::setParamVideoRotation(int32_t degrees) {
-     LOGV("setParamVideoRotation: %d", degrees);
-     if (degrees < 0 || degrees % 90 != 0) {
-         LOGE("Unsupported video rotation angle: %d", degrees);
-@@ -404,7 +347,7 @@
-     return OK;
- }
- 
--status_t StagefrightRecorder::setParamMaxFileDurationUs(int64_t timeUs) {
-+status_t GonkRecorder::setParamMaxFileDurationUs(int64_t timeUs) {
-     LOGV("setParamMaxFileDurationUs: %lld us", timeUs);
- 
-     // This is meant for backward compatibility for MediaRecorder.java
-@@ -423,7 +366,7 @@
-     return OK;
- }
- 
--status_t StagefrightRecorder::setParamMaxFileSizeBytes(int64_t bytes) {
-+status_t GonkRecorder::setParamMaxFileSizeBytes(int64_t bytes) {
-     LOGV("setParamMaxFileSizeBytes: %lld bytes", bytes);
- 
-     // This is meant for backward compatibility for MediaRecorder.java
-@@ -449,7 +392,7 @@
-     return OK;
- }
- 
--status_t StagefrightRecorder::setParamInterleaveDuration(int32_t durationUs) {
-+status_t GonkRecorder::setParamInterleaveDuration(int32_t durationUs) {
-     LOGV("setParamInterleaveDuration: %d", durationUs);
-     if (durationUs <= 500000) {           //  500 ms
-         // If interleave duration is too small, it is very inefficient to do
-@@ -471,20 +414,20 @@
- // If seconds <  0, only the first frame is I frame, and rest are all P frames
- // If seconds == 0, all frames are encoded as I frames. No P frames
- // If seconds >  0, it is the time spacing (seconds) between 2 neighboring I frames
--status_t StagefrightRecorder::setParamVideoIFramesInterval(int32_t seconds) {
-+status_t GonkRecorder::setParamVideoIFramesInterval(int32_t seconds) {
-     LOGV("setParamVideoIFramesInterval: %d seconds", seconds);
-     mIFramesIntervalSec = seconds;
-     return OK;
- }
- 
--status_t StagefrightRecorder::setParam64BitFileOffset(bool use64Bit) {
-+status_t GonkRecorder::setParam64BitFileOffset(bool use64Bit) {
-     LOGV("setParam64BitFileOffset: %s",
-         use64Bit? "use 64 bit file offset": "use 32 bit file offset");
-     mUse64BitFileOffset = use64Bit;
-     return OK;
- }
- 
--status_t StagefrightRecorder::setParamVideoCameraId(int32_t cameraId) {
-+status_t GonkRecorder::setParamVideoCameraId(int32_t cameraId) {
-     LOGV("setParamVideoCameraId: %d", cameraId);
-     if (cameraId < 0) {
-         return BAD_VALUE;
-@@ -493,7 +436,7 @@
-     return OK;
- }
- 
--status_t StagefrightRecorder::setParamTrackTimeStatus(int64_t timeDurationUs) {
-+status_t GonkRecorder::setParamTrackTimeStatus(int64_t timeDurationUs) {
-     LOGV("setParamTrackTimeStatus: %lld", timeDurationUs);
-     if (timeDurationUs < 20000) {  // Infeasible if shorter than 20 ms?
-         LOGE("Tracking time duration too short: %lld us", timeDurationUs);
-@@ -503,7 +446,7 @@
-     return OK;
- }
- 
--status_t StagefrightRecorder::setParamVideoEncoderProfile(int32_t profile) {
-+status_t GonkRecorder::setParamVideoEncoderProfile(int32_t profile) {
-     LOGV("setParamVideoEncoderProfile: %d", profile);
- 
-     // Additional check will be done later when we load the encoder.
-@@ -512,7 +455,7 @@
-     return OK;
- }
- 
--status_t StagefrightRecorder::setParamVideoEncoderLevel(int32_t level) {
-+status_t GonkRecorder::setParamVideoEncoderLevel(int32_t level) {
-     LOGV("setParamVideoEncoderLevel: %d", level);
- 
-     // Additional check will be done later when we load the encoder.
-@@ -521,7 +464,7 @@
-     return OK;
- }
- 
--status_t StagefrightRecorder::setParamMovieTimeScale(int32_t timeScale) {
-+status_t GonkRecorder::setParamMovieTimeScale(int32_t timeScale) {
-     LOGV("setParamMovieTimeScale: %d", timeScale);
- 
-     // The range is set to be the same as the audio's time scale range
-@@ -534,7 +477,7 @@
-     return OK;
- }
- 
--status_t StagefrightRecorder::setParamVideoTimeScale(int32_t timeScale) {
-+status_t GonkRecorder::setParamVideoTimeScale(int32_t timeScale) {
-     LOGV("setParamVideoTimeScale: %d", timeScale);
- 
-     // 60000 is chosen to make sure that each video frame from a 60-fps
-@@ -547,7 +490,7 @@
-     return OK;
- }
- 
--status_t StagefrightRecorder::setParamAudioTimeScale(int32_t timeScale) {
-+status_t GonkRecorder::setParamAudioTimeScale(int32_t timeScale) {
-     LOGV("setParamAudioTimeScale: %d", timeScale);
- 
-     // 96000 Hz is the highest sampling rate support in AAC.
-@@ -559,33 +502,7 @@
-     return OK;
- }
- 
--status_t StagefrightRecorder::setParamTimeLapseEnable(int32_t timeLapseEnable) {
--    LOGV("setParamTimeLapseEnable: %d", timeLapseEnable);
--
--    if(timeLapseEnable == 0) {
--        mCaptureTimeLapse = false;
--    } else if (timeLapseEnable == 1) {
--        mCaptureTimeLapse = true;
--    } else {
--        return BAD_VALUE;
--    }
--    return OK;
--}
--
--status_t StagefrightRecorder::setParamTimeBetweenTimeLapseFrameCapture(int64_t timeUs) {
--    LOGV("setParamTimeBetweenTimeLapseFrameCapture: %lld us", timeUs);
--
--    // Not allowing time more than a day
--    if (timeUs <= 0 || timeUs > 86400*1E6) {
--        LOGE("Time between time lapse frame capture (%lld) is out of range [0, 1 Day]", timeUs);
--        return BAD_VALUE;
--    }
--
--    mTimeBetweenTimeLapseFrameCaptureUs = timeUs;
--    return OK;
--}
--
--status_t StagefrightRecorder::setParamGeoDataLongitude(
-+status_t GonkRecorder::setParamGeoDataLongitude(
-     int64_t longitudex10000) {
- 
-     if (longitudex10000 > 1800000 || longitudex10000 < -1800000) {
-@@ -595,7 +512,7 @@
-     return OK;
- }
- 
--status_t StagefrightRecorder::setParamGeoDataLatitude(
-+status_t GonkRecorder::setParamGeoDataLatitude(
-     int64_t latitudex10000) {
- 
-     if (latitudex10000 > 900000 || latitudex10000 < -900000) {
-@@ -605,7 +522,7 @@
-     return OK;
- }
- 
--status_t StagefrightRecorder::setParameter(
-+status_t GonkRecorder::setParameter(
-         const String8 &key, const String8 &value) {
-     LOGV("setParameter: key (%s) => value (%s)", key.string(), value.string());
-     if (key == "max-duration") {
-@@ -703,24 +620,13 @@
-         if (safe_strtoi32(value.string(), &timeScale)) {
-             return setParamVideoTimeScale(timeScale);
-         }
--    } else if (key == "time-lapse-enable") {
--        int32_t timeLapseEnable;
--        if (safe_strtoi32(value.string(), &timeLapseEnable)) {
--            return setParamTimeLapseEnable(timeLapseEnable);
--        }
--    } else if (key == "time-between-time-lapse-frame-capture") {
--        int64_t timeBetweenTimeLapseFrameCaptureMs;
--        if (safe_strtoi64(value.string(), &timeBetweenTimeLapseFrameCaptureMs)) {
--            return setParamTimeBetweenTimeLapseFrameCapture(
--                    1000LL * timeBetweenTimeLapseFrameCaptureMs);
--        }
-     } else {
-         LOGE("setParameter: failed to find key %s", key.string());
-     }
-     return BAD_VALUE;
- }
- 
--status_t StagefrightRecorder::setParameters(const String8 &params) {
-+status_t GonkRecorder::setParameters(const String8 &params) {
-     LOGV("setParameters: %s", params.string());
-     const char *cparams = params.string();
-     const char *key_start = cparams;
-@@ -755,13 +661,13 @@
-     return OK;
- }
- 
--status_t StagefrightRecorder::setListener(const sp<IMediaRecorderClient> &listener) {
-+status_t GonkRecorder::setListener(const sp<IMediaRecorderClient> &listener) {
-     mListener = listener;
- 
-     return OK;
- }
- 
--status_t StagefrightRecorder::prepare() {
-+status_t GonkRecorder::prepare() {
-   LOGV(" %s E", __func__ );
- 
-   if(mVideoSource != VIDEO_SOURCE_LIST_END && mVideoEncoder != VIDEO_ENCODER_LIST_END && mVideoHeight && mVideoWidth &&             /*Video recording*/
-@@ -776,17 +682,15 @@
-   return OK;
- }
- 
--status_t StagefrightRecorder::start() {
-+status_t GonkRecorder::start() {
-     CHECK(mOutputFd >= 0);
- 
-     if (mWriter != NULL) {
--        LOGE("File writer is not avaialble");
-+        LOGE("File writer is not available");
-         return UNKNOWN_ERROR;
-     }
- 
-     status_t status = OK;
--    if(AUDIO_SOURCE_FM_RX_A2DP == mAudioSource)
--        return startFMA2DPWriter();
- 
-     switch (mOutputFormat) {
-         case OUTPUT_FORMAT_DEFAULT:
-@@ -800,22 +704,9 @@
-             status = startAMRRecording();
-             break;
- 
--        case OUTPUT_FORMAT_AAC_ADIF:
--        case OUTPUT_FORMAT_AAC_ADTS:
--            status = startAACRecording();
--            break;
--
--        case OUTPUT_FORMAT_RTP_AVP:
--            status = startRTPRecording();
--            break;
--
-         case OUTPUT_FORMAT_MPEG2TS:
-             status = startMPEG2TSRecording();
- 		    break;
--			
--        case OUTPUT_FORMAT_QCP:
--            status = startExtendedRecording( );
--		    break;
-         default:
-             LOGE("Unsupported output file format: %d", mOutputFormat);
-             status = UNKNOWN_ERROR;
-@@ -824,22 +715,12 @@
- 
-     if ((status == OK) && (!mStarted)) {
-         mStarted = true;
--
--        uint32_t params = IMediaPlayerService::kBatteryDataCodecStarted;
--        if (mAudioSource != AUDIO_SOURCE_CNT) {
--            params |= IMediaPlayerService::kBatteryDataTrackAudio;
--        }
--        if (mVideoSource != VIDEO_SOURCE_LIST_END) {
--            params |= IMediaPlayerService::kBatteryDataTrackVideo;
--        }
--
--        addBatteryData(params);
-     }
- 
-     return status;
- }
- 
--sp<MediaSource> StagefrightRecorder::createAudioSource() {
-+sp<MediaSource> GonkRecorder::createAudioSource() {
- 
-     bool tunneledSource = false;
-     const char *tunnelMime;
-@@ -907,12 +788,6 @@
-         case AUDIO_ENCODER_AAC:
-             mime = MEDIA_MIMETYPE_AUDIO_AAC;
-             break;
--        case AUDIO_ENCODER_EVRC:
--            mime = MEDIA_MIMETYPE_AUDIO_EVRC;
--            break;
--        case AUDIO_ENCODER_QCELP:
--            mime = MEDIA_MIMETYPE_AUDIO_QCELP;
--            break;
-         default:
-             LOGE("Unknown audio encoder: %d", mAudioEncoder);
-             return NULL;
-@@ -931,36 +806,17 @@
-         encMeta->setInt32(kKeyTimeScale, mAudioTimeScale);
-     }
- 
--    OMXClient client;
--    CHECK_EQ(client.connect(), OK);
--
-+    // use direct OMX interface instead of connecting to
-+    // mediaserver over binder calls
-     sp<MediaSource> audioEncoder =
--        OMXCodec::Create(client.interface(), encMeta,
-+        OMXCodec::Create(GetOMX(), encMeta,
-                          true /* createEncoder */, audioSource);
-     mAudioSourceNode = audioSource;
- 
-     return audioEncoder;
- }
- 
--status_t StagefrightRecorder::startAACRecording() {
--    // FIXME:
--    // Add support for OUTPUT_FORMAT_AAC_ADIF
--    CHECK(mOutputFormat == OUTPUT_FORMAT_AAC_ADTS);
--
--    CHECK(mAudioEncoder == AUDIO_ENCODER_AAC);
--    CHECK(mAudioSource != AUDIO_SOURCE_CNT);
--
--    mWriter = new AACWriter(mOutputFd);
--    status_t status = startRawAudioRecording();
--    if (status != OK) {
--        mWriter.clear();
--        mWriter = NULL;
--    }
--
--    return status;
--}
--
--status_t StagefrightRecorder::startAMRRecording() {
-+status_t GonkRecorder::startAMRRecording() {
-     CHECK(mOutputFormat == OUTPUT_FORMAT_AMR_NB ||
-           mOutputFormat == OUTPUT_FORMAT_AMR_WB);
- 
-@@ -971,28 +827,12 @@
-                     mAudioEncoder);
-             return BAD_VALUE;
-         }
--        if (mSampleRate != 8000) {
--            LOGE("Invalid sampling rate %d used for AMRNB recording",
--                    mSampleRate);
--            return BAD_VALUE;
--        }
-     } else {  // mOutputFormat must be OUTPUT_FORMAT_AMR_WB
-         if (mAudioEncoder != AUDIO_ENCODER_AMR_WB) {
-             LOGE("Invlaid encoder %d used for AMRWB recording",
-                     mAudioEncoder);
-             return BAD_VALUE;
-         }
--        if (mSampleRate != 16000) {
--            LOGE("Invalid sample rate %d used for AMRWB recording",
--                    mSampleRate);
--            return BAD_VALUE;
--        }
--    }
--
--    if (mAudioChannels != 1) {
--        LOGE("Invalid number of audio channels %d used for amr recording",
--                mAudioChannels);
--        return BAD_VALUE;
-     }
- 
-     mWriter = new AMRWriter(mOutputFd);
-@@ -1004,7 +844,7 @@
-     return status;
- }
- 
--status_t StagefrightRecorder::startRawAudioRecording() {
-+status_t GonkRecorder::startRawAudioRecording() {
-     if (mAudioSource >= AUDIO_SOURCE_CNT) {
-         LOGE("Invalid audio source: %d", mAudioSource);
-         return BAD_VALUE;
-@@ -1035,62 +875,7 @@
-     return OK;
- }
- 
--status_t StagefrightRecorder::startFMA2DPWriter() {
--    /* FM soc outputs at 48k */
--	mSampleRate = 48000;
--	mAudioChannels = 2;
--	
--    sp<MetaData> meta = new MetaData;
--    meta->setInt32(kKeyChannelCount, mAudioChannels);
--    meta->setInt32(kKeySampleRate, mSampleRate);
--
--    mWriter = new FMA2DPWriter();
--    mWriter->setListener(mListener);
--    mWriter->start(meta.get());
--    return OK;
--}
--
--status_t StagefrightRecorder::startRTPRecording() {
--    CHECK_EQ(mOutputFormat, OUTPUT_FORMAT_RTP_AVP);
--
--    if ((mAudioSource != AUDIO_SOURCE_CNT
--                && mVideoSource != VIDEO_SOURCE_LIST_END)
--            || (mAudioSource == AUDIO_SOURCE_CNT
--                && mVideoSource == VIDEO_SOURCE_LIST_END)) {
--        // Must have exactly one source.
--        return BAD_VALUE;
--    }
--
--    if (mOutputFd < 0) {
--        return BAD_VALUE;
--    }
--
--    sp<MediaSource> source;
--
--    if (mAudioSource != AUDIO_SOURCE_CNT) {
--        source = createAudioSource();
--    } else {
--
--        sp<MediaSource> mediaSource;
--        status_t err = setupMediaSource(&mediaSource);
--        if (err != OK) {
--            return err;
--        }
--
--        err = setupVideoEncoder(mediaSource, mVideoBitRate, &source);
--        if (err != OK) {
--            return err;
--        }
--    }
--
--    mWriter = new ARTPWriter(mOutputFd);
--    mWriter->addSource(source);
--    mWriter->setListener(mListener);
--
--    return mWriter->start();
--}
--
--status_t StagefrightRecorder::startMPEG2TSRecording() {
-+status_t GonkRecorder::startMPEG2TSRecording() {
-     CHECK_EQ(mOutputFormat, OUTPUT_FORMAT_MPEG2TS);
- 
-     sp<MediaWriter> writer = new MPEG2TSWriter(mOutputFd);
-@@ -1141,7 +926,7 @@
-     return mWriter->start();
- }
- 
--void StagefrightRecorder::clipVideoFrameRate() {
-+void GonkRecorder::clipVideoFrameRate() {
-     LOGV("clipVideoFrameRate: encoder %d", mVideoEncoder);
-     int minFrameRate = mEncoderProfiles->getVideoEncoderParamByName(
-                         "enc.vid.fps.min", mVideoEncoder);
-@@ -1158,7 +943,7 @@
-     }
- }
- 
--void StagefrightRecorder::clipVideoBitRate() {
-+void GonkRecorder::clipVideoBitRate() {
-     LOGV("clipVideoBitRate: encoder %d", mVideoEncoder);
-     int minBitRate = mEncoderProfiles->getVideoEncoderParamByName(
-                         "enc.vid.bps.min", mVideoEncoder);
-@@ -1175,7 +960,7 @@
-     }
- }
- 
--void StagefrightRecorder::clipVideoFrameWidth() {
-+void GonkRecorder::clipVideoFrameWidth() {
-     LOGV("clipVideoFrameWidth: encoder %d", mVideoEncoder);
-     int minFrameWidth = mEncoderProfiles->getVideoEncoderParamByName(
-                         "enc.vid.width.min", mVideoEncoder);
-@@ -1192,8 +977,7 @@
-     }
- }
- 
--status_t StagefrightRecorder::checkVideoEncoderCapabilities() {
--    if (!mCaptureTimeLapse) {
-+status_t GonkRecorder::checkVideoEncoderCapabilities() {
-         // Dont clip for time lapse capture as encoder will have enough
-         // time to encode because of slow capture rate of time lapse.
-         clipVideoBitRate();
-@@ -1201,13 +985,12 @@
-         clipVideoFrameWidth();
-         clipVideoFrameHeight();
-         setDefaultProfileIfNecessary();
--    }
-     return OK;
- }
- 
- // Set to use AVC baseline profile if the encoding parameters matches
- // CAMCORDER_QUALITY_LOW profile; this is for the sake of MMS service.
--void StagefrightRecorder::setDefaultProfileIfNecessary() {
-+void GonkRecorder::setDefaultProfileIfNecessary() {
-     LOGV("setDefaultProfileIfNecessary");
- 
-     camcorder_quality quality = CAMCORDER_QUALITY_LOW;
-@@ -1263,14 +1046,14 @@
-     }
- }
- 
--status_t StagefrightRecorder::checkAudioEncoderCapabilities() {
-+status_t GonkRecorder::checkAudioEncoderCapabilities() {
-     clipAudioBitRate();
-     clipAudioSampleRate();
-     clipNumberOfAudioChannels();
-     return OK;
- }
- 
--void StagefrightRecorder::clipAudioBitRate() {
-+void GonkRecorder::clipAudioBitRate() {
-     LOGV("clipAudioBitRate: encoder %d", mAudioEncoder);
- 
-     int minAudioBitRate =
-@@ -1292,7 +1075,7 @@
-     }
- }
- 
--void StagefrightRecorder::clipAudioSampleRate() {
-+void GonkRecorder::clipAudioSampleRate() {
-     LOGV("clipAudioSampleRate: encoder %d", mAudioEncoder);
- 
-     int minSampleRate =
-@@ -1314,7 +1097,7 @@
-     }
- }
- 
--void StagefrightRecorder::clipNumberOfAudioChannels() {
-+void GonkRecorder::clipNumberOfAudioChannels() {
-     LOGV("clipNumberOfAudioChannels: encoder %d", mAudioEncoder);
- 
-     int minChannels =
-@@ -1336,7 +1119,7 @@
-     }
- }
- 
--void StagefrightRecorder::clipVideoFrameHeight() {
-+void GonkRecorder::clipVideoFrameHeight() {
-     LOGV("clipVideoFrameHeight: encoder %d", mVideoEncoder);
-     int minFrameHeight = mEncoderProfiles->getVideoEncoderParamByName(
-                         "enc.vid.height.min", mVideoEncoder);
-@@ -1354,61 +1137,26 @@
- }
- 
- // Set up the appropriate MediaSource depending on the chosen option
--status_t StagefrightRecorder::setupMediaSource(
-+status_t GonkRecorder::setupMediaSource(
-                       sp<MediaSource> *mediaSource) {
-     if (mVideoSource == VIDEO_SOURCE_DEFAULT
-             || mVideoSource == VIDEO_SOURCE_CAMERA) {
--        sp<CameraSource> cameraSource;
-+        sp<GonkCameraSource> cameraSource;
-         status_t err = setupCameraSource(&cameraSource);
-         if (err != OK) {
-             return err;
-         }
-         *mediaSource = cameraSource;
-     } else if (mVideoSource == VIDEO_SOURCE_GRALLOC_BUFFER) {
--        // If using GRAlloc buffers, setup surfacemediasource.
--        // Later a handle to that will be passed
--        // to the client side when queried
--        status_t err = setupSurfaceMediaSource();
--        if (err != OK) {
--            return err;
--        }
--        *mediaSource = mSurfaceMediaSource;
-+        return BAD_VALUE;
-     } else {
-         return INVALID_OPERATION;
-     }
-     return OK;
- }
- 
--// setupSurfaceMediaSource creates a source with the given
--// width and height and framerate.
--// TODO: This could go in a static function inside SurfaceMediaSource
--// similar to that in CameraSource
--status_t StagefrightRecorder::setupSurfaceMediaSource() {
--    status_t err = OK;
--    mSurfaceMediaSource = new SurfaceMediaSource(mVideoWidth, mVideoHeight);
--    if (mSurfaceMediaSource == NULL) {
--        return NO_INIT;
--    }
--
--    if (mFrameRate == -1) {
--        int32_t frameRate = 0;
--        CHECK (mSurfaceMediaSource->getFormat()->findInt32(
--                                        kKeyFrameRate, &frameRate));
--        LOGI("Frame rate is not explicitly set. Use the current frame "
--             "rate (%d fps)", frameRate);
--        mFrameRate = frameRate;
--    } else {
--        err = mSurfaceMediaSource->setFrameRate(mFrameRate);
--    }
--    CHECK(mFrameRate != -1);
--
--    mIsMetaDataStoredInVideoBuffers =
--        mSurfaceMediaSource->isMetaDataStoredInVideoBuffers();
--    return err;
--}
--
--status_t StagefrightRecorder::setupCameraSource(
--        sp<CameraSource> *cameraSource) {
-+status_t GonkRecorder::setupCameraSource(
-+        sp<GonkCameraSource> *cameraSource) {
-     status_t err = OK;
-     if ((err = checkVideoEncoderCapabilities()) != OK) {
-         return err;
-@@ -1416,26 +1164,15 @@
-     Size videoSize;
-     videoSize.width = mVideoWidth;
-     videoSize.height = mVideoHeight;
--    if (mCaptureTimeLapse) {
--        mCameraSourceTimeLapse = CameraSourceTimeLapse::CreateFromCamera(
--                mCamera, mCameraProxy, mCameraId,
--                videoSize, mFrameRate, mPreviewSurface,
--                mTimeBetweenTimeLapseFrameCaptureUs);
--        *cameraSource = mCameraSourceTimeLapse;
--    } else {
--
--        bool useMeta = true;
--        char value[PROPERTY_VALUE_MAX];
--        if (property_get("debug.camcorder.disablemeta", value, NULL) &&
-+    bool useMeta = true;
-+    char value[PROPERTY_VALUE_MAX];
-+    if (property_get("debug.camcorder.disablemeta", value, NULL) &&
-             atoi(value)) {
--            useMeta = false;
--        }
--        *cameraSource = CameraSource::CreateFromCamera(
--                mCamera, mCameraProxy, mCameraId, videoSize, mFrameRate,
--                mPreviewSurface, useMeta);
-+      useMeta = false;
-     }
--    mCamera.clear();
--    mCameraProxy.clear();
-+
-+    *cameraSource = GonkCameraSource::Create(
-+                mCameraHandle, videoSize, mFrameRate, useMeta);
-     if (*cameraSource == NULL) {
-         return UNKNOWN_ERROR;
-     }
-@@ -1465,7 +1202,7 @@
-     return OK;
- }
- 
--status_t StagefrightRecorder::setupVideoEncoder(
-+status_t GonkRecorder::setupVideoEncoder(
-         sp<MediaSource> cameraSource,
-         int32_t videoBitRate,
-         sp<MediaSource> *source) {
-@@ -1501,10 +1238,7 @@
-     CHECK(meta->findInt32(kKeyStride, &stride));
-     CHECK(meta->findInt32(kKeySliceHeight, &sliceHeight));
-     CHECK(meta->findInt32(kKeyColorFormat, &colorFormat));
--    hfr = 0;
--    if (!meta->findInt32(kKeyHFR, &hfr)) {
--        LOGW("hfr not found, default to 0");
--    }
-+    CHECK(meta->findInt32(kKeyHFR, &hfr));
- 
-     if(hfr) {
-       mMaxFileDurationUs = mMaxFileDurationUs * (hfr/mFrameRate);
-@@ -1598,30 +1332,17 @@
-         enc_meta->setInt32(kKey3D, is3D);
-     }
- 
--    OMXClient client;
--    CHECK_EQ(client.connect(), OK);
--
-     uint32_t encoder_flags = 0;
-     if (mIsMetaDataStoredInVideoBuffers) {
-         LOGW("Camera source supports metadata mode, create OMXCodec for metadata");
-         encoder_flags |= OMXCodec::kHardwareCodecsOnly;
-         encoder_flags |= OMXCodec::kStoreMetaDataInVideoBuffers;
--        if (property_get("ro.board.platform", value, "0")
--            && (!strncmp(value, "msm7627", sizeof("msm7627") - 1))) {
--            LOGW("msm7627 family of chipsets supports, only one buffer at a time");
--            encoder_flags |= OMXCodec::kOnlySubmitOneInputBufferAtOneTime;
--        }
--    }
--
--    // Do not wait for all the input buffers to become available.
--    // This give timelapse video recording faster response in
--    // receiving output from video encoder component.
--    if (mCaptureTimeLapse) {
-         encoder_flags |= OMXCodec::kOnlySubmitOneInputBufferAtOneTime;
-     }
- 
-     sp<MediaSource> encoder = OMXCodec::Create(
--            client.interface(), enc_meta,
-+            GetOMX(),
-+            enc_meta,
-             true /* createEncoder */, cameraSource,
-             NULL, encoder_flags);
-     if (encoder == NULL) {
-@@ -1638,7 +1359,7 @@
-     return OK;
- }
- 
--status_t StagefrightRecorder::setupAudioEncoder(const sp<MediaWriter>& writer) {
-+status_t GonkRecorder::setupAudioEncoder(const sp<MediaWriter>& writer) {
-     status_t status = BAD_VALUE;
-     if (OK != (status = checkAudioEncoderCapabilities())) {
-         return status;
-@@ -1664,7 +1385,7 @@
-     return OK;
- }
- 
--status_t StagefrightRecorder::setupMPEG4Recording(
-+status_t GonkRecorder::setupMPEG4Recording(
-         int outputFd,
-         int32_t videoWidth, int32_t videoHeight,
-         int32_t videoBitRate,
-@@ -1696,7 +1417,7 @@
-     // Audio source is added at the end if it exists.
-     // This help make sure that the "recoding" sound is suppressed for
-     // camcorder applications in the recorded files.
--    if (!mCaptureTimeLapse && (mAudioSource != AUDIO_SOURCE_CNT)) {
-+    if (mAudioSource != AUDIO_SOURCE_CNT) {
-         err = setupAudioEncoder(writer);
-         if (err != OK) return err;
-         *totalBitRate += mAudioBitRate;
-@@ -1728,7 +1449,7 @@
-     return OK;
- }
- 
--void StagefrightRecorder::setupMPEG4MetaData(int64_t startTimeUs, int32_t totalBitRate,
-+void GonkRecorder::setupMPEG4MetaData(int64_t startTimeUs, int32_t totalBitRate,
-         sp<MetaData> *meta) {
-     (*meta)->setInt64(kKeyTime, startTimeUs);
-     (*meta)->setInt32(kKeyFileType, mOutputFormat);
-@@ -1752,7 +1473,7 @@
-     }
- }
- 
--status_t StagefrightRecorder::startMPEG4Recording() {
-+status_t GonkRecorder::startMPEG4Recording() {
-     int32_t totalBitRate;
-     status_t err = setupMPEG4Recording(
-             mOutputFd, mVideoWidth, mVideoHeight,
-@@ -1761,7 +1482,14 @@
-         return err;
-     }
- 
--    int64_t startTimeUs = systemTime() / 1000;
-+    //systemTime() doesn't give correct time because
-+    //HAVE_POSIX_CLOCKS is not defined for utils/Timers.cpp
-+    //so, using clock_gettime directly
-+#include <time.h>
-+    struct timespec t;
-+    clock_gettime(CLOCK_MONOTONIC, &t);
-+    int64_t startTimeUs = int64_t(t.tv_sec)*1000000000LL + t.tv_nsec;
-+    startTimeUs = startTimeUs / 1000;
-     sp<MetaData> meta = new MetaData;
-     setupMPEG4MetaData(startTimeUs, totalBitRate, &meta);
- 
-@@ -1773,7 +1501,7 @@
-     return OK;
- }
- 
--status_t StagefrightRecorder::pause() {
-+status_t GonkRecorder::pause() {
-     LOGV("pause");
-     if (mWriter == NULL) {
-         return UNKNOWN_ERROR;
-@@ -1782,31 +1510,16 @@
- 
-     if (mStarted) {
-         mStarted = false;
--
--        uint32_t params = 0;
--        if (mAudioSource != AUDIO_SOURCE_CNT) {
--            params |= IMediaPlayerService::kBatteryDataTrackAudio;
--        }
--        if (mVideoSource != VIDEO_SOURCE_LIST_END) {
--            params |= IMediaPlayerService::kBatteryDataTrackVideo;
--        }
--
--        addBatteryData(params);
-     }
- 
- 
-     return OK;
- }
- 
--status_t StagefrightRecorder::stop() {
-+status_t GonkRecorder::stop() {
-     LOGV("stop");
-     status_t err = OK;
- 
--    if (mCaptureTimeLapse && mCameraSourceTimeLapse != NULL) {
--        mCameraSourceTimeLapse->startQuickReadReturns();
--        mCameraSourceTimeLapse = NULL;
--    }
--
-     if (mWriter != NULL) {
-         err = mWriter->stop();
-         mWriter.clear();
-@@ -1819,30 +1532,20 @@
- 
-     if (mStarted) {
-         mStarted = false;
--
--        uint32_t params = 0;
--        if (mAudioSource != AUDIO_SOURCE_CNT) {
--            params |= IMediaPlayerService::kBatteryDataTrackAudio;
--        }
--        if (mVideoSource != VIDEO_SOURCE_LIST_END) {
--            params |= IMediaPlayerService::kBatteryDataTrackVideo;
--        }
--
--        addBatteryData(params);
-     }
- 
- 
-     return err;
- }
- 
--status_t StagefrightRecorder::close() {
-+status_t GonkRecorder::close() {
-     LOGV("close");
-     stop();
- 
-     return OK;
- }
- 
--status_t StagefrightRecorder::reset() {
-+status_t GonkRecorder::reset() {
-     LOGV("reset");
-     stop();
- 
-@@ -1858,9 +1561,9 @@
-     mVideoHeight   = 144;
-     mFrameRate     = -1;
-     mVideoBitRate  = 192000;
--    mSampleRate    = 0;
--    mAudioChannels = 0;
--    mAudioBitRate  = 0;
-+    mSampleRate    = 8000;
-+    mAudioChannels = 1;
-+    mAudioBitRate  = 12200;
-     mInterleaveDurationUs = 0;
-     mIFramesIntervalSec = 2;
-     mAudioSourceNode = 0;
-@@ -1875,9 +1578,6 @@
-     mMaxFileDurationUs = 0;
-     mMaxFileSizeBytes = 0;
-     mTrackEveryTimeDurationUs = 0;
--    mCaptureTimeLapse = false;
--    mTimeBetweenTimeLapseFrameCaptureUs = -1;
--    mCameraSourceTimeLapse = NULL;
-     mIsMetaDataStoredInVideoBuffers = false;
-     mEncoderProfiles = MediaProfiles::getInstance();
-     mRotationDegrees = 0;
-@@ -1885,6 +1585,11 @@
-     mLongitudex10000 = -3600000;
- 
-     mOutputFd = -1;
-+    mCameraHandle = -1;
-+    //TODO: May need to register a listener eventually
-+    //if someone is interested in recorder events for now
-+    //default to no listener registered
-+    mListener = NULL;
- 
-     // Disable Audio Encoding
-     char value[PROPERTY_VALUE_MAX];
-@@ -1894,7 +1599,7 @@
-     return OK;
- }
- 
--status_t StagefrightRecorder::getMaxAmplitude(int *max) {
-+status_t GonkRecorder::getMaxAmplitude(int *max) {
-     LOGV("getMaxAmplitude");
- 
-     if (max == NULL) {
-@@ -1911,7 +1616,7 @@
-     return OK;
- }
- 
--status_t StagefrightRecorder::dump(
-+status_t GonkRecorder::dump(
-         int fd, const Vector<String16>& args) const {
-     LOGV("dump");
-     const size_t SIZE = 256;
-@@ -1958,6 +1663,8 @@
-     result.append(buffer);
-     snprintf(buffer, SIZE, "     Camera Id: %d\n", mCameraId);
-     result.append(buffer);
-+    snprintf(buffer, SIZE, "     Camera Handle: %d\n", mCameraHandle);
-+    result.append(buffer);
-     snprintf(buffer, SIZE, "     Start time offset (ms): %d\n", mStartTimeOffsetMs);
-     result.append(buffer);
-     snprintf(buffer, SIZE, "     Encoder: %d\n", mVideoEncoder);
-@@ -1978,45 +1685,12 @@
-     return OK;
- }
- 
--status_t StagefrightRecorder::startExtendedRecording() {
--    CHECK(mOutputFormat == OUTPUT_FORMAT_QCP);
--
--    if (mSampleRate != 8000) {
--        LOGE("Invalid sampling rate %d used for recording",
--             mSampleRate);
--        return BAD_VALUE;
--    }
--    if (mAudioChannels != 1) {
--        LOGE("Invalid number of audio channels %d used for recording",
--                mAudioChannels);
--        return BAD_VALUE;
--    }
--
--    if (mAudioSource >= AUDIO_SOURCE_CNT) {
--        LOGE("Invalid audio source: %d", mAudioSource);
--        return BAD_VALUE;
--    }
--
--    sp<MediaSource> audioEncoder = createAudioSource();
--
--    if (audioEncoder == NULL) {
--        LOGE("AudioEncoder NULL");
--        return UNKNOWN_ERROR;
--    }
--
--    mWriter = new ExtendedWriter(dup(mOutputFd));
--    mWriter->addSource(audioEncoder);
--
--    if (mMaxFileDurationUs != 0) {
--        mWriter->setMaxFileDuration(mMaxFileDurationUs);
--    }
--    if (mMaxFileSizeBytes != 0) {
--        mWriter->setMaxFileSize(mMaxFileSizeBytes);
--    }
--    mWriter->setListener(mListener);
--    mWriter->start();
--
--    return OK;
-+status_t GonkRecorder::setCameraHandle(int32_t handle) {
-+  if (handle < 0) {
-+    return BAD_VALUE;
-+  }
-+  mCameraHandle = handle;
-+  return OK;
- }
- 
- }  // namespace android
-diff --git a/GonkRecorder.h b/GonkRecorder.h
-index dba6110..fa948af 100644
---- a/GonkRecorder.h
-+++ b/GonkRecorder.h
-@@ -14,11 +14,11 @@
-  * limitations under the License.
-  */
- 
--#ifndef STAGEFRIGHT_RECORDER_H_
-+#ifndef GONK_RECORDER_H_
- 
--#define STAGEFRIGHT_RECORDER_H_
-+#define GONK_RECORDER_H_
- 
--#include <media/MediaRecorderBase.h>
-+#include <media/mediarecorder.h>
- #include <camera/CameraParameters.h>
- #include <utils/String8.h>
- 
-@@ -26,21 +26,16 @@
- 
- namespace android {
- 
--class Camera;
--class ICameraRecordingProxy;
--class CameraSource;
--class CameraSourceTimeLapse;
-+class GonkCameraSource;
- struct MediaSource;
- struct MediaWriter;
- class MetaData;
- struct AudioSource;
- class MediaProfiles;
--class ISurfaceTexture;
--class SurfaceMediaSource;
- 
--struct StagefrightRecorder : public MediaRecorderBase {
--    StagefrightRecorder();
--    virtual ~StagefrightRecorder();
-+struct GonkRecorder {
-+    GonkRecorder();
-+    virtual ~GonkRecorder();
- 
-     virtual status_t init();
-     virtual status_t setAudioSource(audio_source_t as);
-@@ -50,11 +45,10 @@
-     virtual status_t setVideoEncoder(video_encoder ve);
-     virtual status_t setVideoSize(int width, int height);
-     virtual status_t setVideoFrameRate(int frames_per_second);
--    virtual status_t setCamera(const sp<ICamera>& camera, const sp<ICameraRecordingProxy>& proxy);
--    virtual status_t setPreviewSurface(const sp<Surface>& surface);
-     virtual status_t setOutputFile(const char *path);
-     virtual status_t setOutputFile(int fd, int64_t offset, int64_t length);
-     virtual status_t setParameters(const String8& params);
-+    virtual status_t setCameraHandle(int32_t handle);
-     virtual status_t setListener(const sp<IMediaRecorderClient>& listener);
-     virtual status_t prepare();
-     virtual status_t start();
-@@ -65,12 +59,8 @@
-     virtual status_t getMaxAmplitude(int *max);
-     virtual status_t dump(int fd, const Vector<String16>& args) const;
-     // Querying a SurfaceMediaSourcer
--    virtual sp<ISurfaceTexture> querySurfaceMediaSource() const;
- 
- private:
--    sp<ICamera> mCamera;
--    sp<ICameraRecordingProxy> mCameraProxy;
--    sp<Surface> mPreviewSurface;
-     sp<IMediaRecorderClient> mListener;
-     sp<MediaWriter> mWriter;
-     int mOutputFd;
-@@ -104,11 +94,6 @@
-     int32_t mLongitudex10000;
-     int32_t mStartTimeOffsetMs;
- 
--    bool mCaptureTimeLapse;
--    int64_t mTimeBetweenTimeLapseFrameCaptureUs;
--    sp<CameraSourceTimeLapse> mCameraSourceTimeLapse;
--
--
-     String8 mParams;
- 
-     bool mIsMetaDataStoredInVideoBuffers;
-@@ -119,8 +104,8 @@
-     // An <ISurfaceTexture> pointer
-     // will be sent to the client side using which the
-     // frame buffers will be queued and dequeued
--    sp<SurfaceMediaSource> mSurfaceMediaSource;
-     bool mDisableAudio;
-+    int32_t mCameraHandle;
- 
-     status_t setupMPEG4Recording(
-         int outputFd,
-@@ -132,10 +117,7 @@
-         sp<MetaData> *meta);
-     status_t startMPEG4Recording();
-     status_t startAMRRecording();
--    status_t startFMA2DPWriter();
--    status_t startAACRecording();
-     status_t startRawAudioRecording();
--    status_t startRTPRecording();
-     status_t startMPEG2TSRecording();
-     sp<MediaSource> createAudioSource();
-     status_t checkVideoEncoderCapabilities();
-@@ -144,9 +126,8 @@
-     // source (CameraSource or SurfaceMediaSource)
-     // depending on the videosource type
-     status_t setupMediaSource(sp<MediaSource> *mediaSource);
--    status_t setupCameraSource(sp<CameraSource> *cameraSource);
-+    status_t setupCameraSource(sp<GonkCameraSource> *cameraSource);
-     // setup the surfacemediasource for the encoder
--    status_t setupSurfaceMediaSource();
- 
-     status_t setupAudioEncoder(const sp<MediaWriter>& writer);
-     status_t setupVideoEncoder(
-@@ -160,8 +141,6 @@
-     status_t setParamAudioNumberOfChannels(int32_t channles);
-     status_t setParamAudioSamplingRate(int32_t sampleRate);
-     status_t setParamAudioTimeScale(int32_t timeScale);
--    status_t setParamTimeLapseEnable(int32_t timeLapseEnable);
--    status_t setParamTimeBetweenTimeLapseFrameCapture(int64_t timeUs);
-     status_t setParamVideoEncodingBitRate(int32_t bitRate);
-     status_t setParamVideoIFramesInterval(int32_t seconds);
-     status_t setParamVideoEncoderProfile(int32_t profile);
-@@ -186,14 +165,10 @@
-     void clipNumberOfAudioChannels();
-     void setDefaultProfileIfNecessary();
- 
--
--    StagefrightRecorder(const StagefrightRecorder &);
--    StagefrightRecorder &operator=(const StagefrightRecorder &);
--
--    /* extension */
--    status_t startExtendedRecording();
-+    GonkRecorder(const GonkRecorder &);
-+    GonkRecorder &operator=(const GonkRecorder &);
- };
- 
- }  // namespace android
- 
--#endif  // STAGEFRIGHT_RECORDER_H_
-+#endif  // GONK_RECORDER_H_
deleted file mode 100644
--- a/dom/camera/update.sh
+++ /dev/null
@@ -1,14 +0,0 @@
-# Usage: ./update.sh <android_ics_os_src_directory>
-#
-# Copies the needed files from the directory containing the original
-# Android ICS OS source and applies the B2G specific changes for the
-# camcorder functionality in B2G.
-cp $1/frameworks/base/media/libmediaplayerservice/StagefrightRecorder.cpp ./GonkRecorder.cpp
-cp $1/frameworks/base/media/libmediaplayerservice/StagefrightRecorder.h ./GonkRecorder.h
-cp $1/frameworks/base/media/libstagefright/CameraSource.cpp ./GonkCameraSource.cpp
-cp $1/frameworks/base/include/media/stagefright/CameraSource.h ./GonkCameraSource.h
-cp $1/frameworks/base/media/libmedia/AudioParameter.cpp ./AudioParameter.cpp
-cp $1/frameworks/base/include/camera/Camera.h ./GonkCameraListener.h
-patch -p1 <update.patch
-# If you import CAF sources, you also need to apply update2.patch
-patch -p1 <update2.patch
deleted file mode 100644
--- a/dom/camera/update2.patch
+++ /dev/null
@@ -1,163 +0,0 @@
-diff --git a/dom/camera/GonkCameraSource.cpp b/dom/camera/GonkCameraSource.cpp
---- a/dom/camera/GonkCameraSource.cpp
-+++ b/dom/camera/GonkCameraSource.cpp
-@@ -492,21 +492,17 @@ status_t GonkCameraSource::init(
-     mMeta = new MetaData;
-     mMeta->setCString(kKeyMIMEType,  MEDIA_MIMETYPE_VIDEO_RAW);
-     mMeta->setInt32(kKeyColorFormat, mColorFormat);
-     mMeta->setInt32(kKeyWidth,       mVideoSize.width);
-     mMeta->setInt32(kKeyHeight,      mVideoSize.height);
-     mMeta->setInt32(kKeyStride,      mVideoSize.width);
-     mMeta->setInt32(kKeySliceHeight, mVideoSize.height);
-     mMeta->setInt32(kKeyFrameRate,   mVideoFrameRate);
--    mMeta->setInt32(kKeyHFR, hfr);
- 
--    if (want3D) {
--        mMeta->setInt32(kKey3D, !0);
--    }
-     return OK;
- }
- 
- GonkCameraSource::~GonkCameraSource() {
-     if (mStarted) {
-         stop();
-     } else if (mInitCheck == OK) {
-         // Camera is initialized but because start() is never called,
-diff --git a/dom/camera/GonkRecorder.cpp b/dom/camera/GonkRecorder.cpp
---- a/dom/camera/GonkRecorder.cpp
-+++ b/dom/camera/GonkRecorder.cpp
-@@ -716,56 +716,16 @@ status_t GonkRecorder::start() {
-         mStarted = true;
-     }
- 
-     return status;
- }
- 
- sp<MediaSource> GonkRecorder::createAudioSource() {
- 
--    bool tunneledSource = false;
--    const char *tunnelMime;
--    {
--        AudioParameter param;
--        String8 key("tunneled-input-formats");
--        param.add( key, String8("get") );
--        String8 valueStr = AudioSystem::getParameters( 0, param.toString());
--        AudioParameter result(valueStr);
--        int value;
--        if ( mAudioEncoder == AUDIO_ENCODER_AMR_NB &&
--            result.getInt(String8("AMR"),value) == NO_ERROR ) {
--            tunneledSource = true;
--            tunnelMime = MEDIA_MIMETYPE_AUDIO_AMR_NB;
--        }
--        else if ( mAudioEncoder == AUDIO_ENCODER_QCELP &&
--            result.getInt(String8("QCELP"),value) == NO_ERROR ) {
--            tunneledSource = true;
--            tunnelMime = MEDIA_MIMETYPE_AUDIO_QCELP;
--        }
--        else if ( mAudioEncoder == AUDIO_ENCODER_EVRC &&
--            result.getInt(String8("EVRC"),value) == NO_ERROR ) {
--            tunneledSource = true;
--            tunnelMime = MEDIA_MIMETYPE_AUDIO_EVRC;
--        }
--    }
--
--    if ( tunneledSource ) {
--        sp<AudioSource> audioSource = NULL;
--        sp<MetaData> meta = new MetaData;
--        meta->setInt32(kKeyChannelCount, mAudioChannels);
--        meta->setInt32(kKeySampleRate, mSampleRate);
--        meta->setInt32(kKeyBitRate, mAudioBitRate);
--        if (mAudioTimeScale > 0) {
--            meta->setInt32(kKeyTimeScale, mAudioTimeScale);
--        }
--        meta->setCString( kKeyMIMEType, tunnelMime );
--        audioSource = new AudioSource( mAudioSource, meta);
--        return audioSource->initCheck( ) == OK ? audioSource : NULL;
--    }
--
-     sp<AudioSource> audioSource =
-         new AudioSource(
-                 mAudioSource,
-                 mSampleRate,
-                 mAudioChannels);
- 
-     status_t err = audioSource->initCheck();
- 
-@@ -1226,56 +1186,33 @@ status_t GonkRecorder::setupVideoEncoder
- 
-         default:
-             CHECK(!"Should not be here, unsupported video encoding.");
-             break;
-     }
- 
-     sp<MetaData> meta = cameraSource->getFormat();
- 
--    int32_t width, height, stride, sliceHeight, colorFormat, hfr, is3D;
-+    int32_t width, height, stride, sliceHeight, colorFormat;
-     CHECK(meta->findInt32(kKeyWidth, &width));
-     CHECK(meta->findInt32(kKeyHeight, &height));
-     CHECK(meta->findInt32(kKeyStride, &stride));
-     CHECK(meta->findInt32(kKeySliceHeight, &sliceHeight));
-     CHECK(meta->findInt32(kKeyColorFormat, &colorFormat));
--    CHECK(meta->findInt32(kKeyHFR, &hfr));
--
--    if(hfr) {
--      mMaxFileDurationUs = mMaxFileDurationUs * (hfr/mFrameRate);
--    }
--
- 
-     enc_meta->setInt32(kKeyWidth, width);
-     enc_meta->setInt32(kKeyHeight, height);
-     enc_meta->setInt32(kKeyIFramesInterval, mIFramesIntervalSec);
-     enc_meta->setInt32(kKeyStride, stride);
-     enc_meta->setInt32(kKeySliceHeight, sliceHeight);
-     enc_meta->setInt32(kKeyColorFormat, colorFormat);
--    enc_meta->setInt32(kKeyHFR, hfr);
-     if (mVideoTimeScale > 0) {
-         enc_meta->setInt32(kKeyTimeScale, mVideoTimeScale);
-     }
- 
--    char mDeviceName[100];
--    property_get("ro.board.platform",mDeviceName,"0");
--    if(!strncmp(mDeviceName, "msm7627a", 8)) {
--      if(hfr && (width * height > 432*240)) {
--        LOGE("HFR mode is supported only upto WQVGA resolution");
--        return INVALID_OPERATION;
--      }
--    }
--    else {
--      if(hfr && ((mVideoEncoder != VIDEO_ENCODER_H264) || (width * height > 800*480))) {
--        LOGE("HFR mode is supported only upto WVGA and H264 codec.");
--        return INVALID_OPERATION;
--      }
--    }
--
--
-     /*
-      * can set profile from the app as a parameter.
-      * For the mean time, set from shell
-      */
- 
-     char value[PROPERTY_VALUE_MAX];
-     bool customProfile = false;
- 
-@@ -1322,19 +1259,16 @@ status_t GonkRecorder::setupVideoEncoder
-     }
- 
-     if (mVideoEncoderProfile != -1) {
-         enc_meta->setInt32(kKeyVideoProfile, mVideoEncoderProfile);
-     }
-     if (mVideoEncoderLevel != -1) {
-         enc_meta->setInt32(kKeyVideoLevel, mVideoEncoderLevel);
-     }
--    if (meta->findInt32(kKey3D, &is3D)) {
--        enc_meta->setInt32(kKey3D, is3D);
--    }
- 
-     uint32_t encoder_flags = 0;
-     if (mIsMetaDataStoredInVideoBuffers) {
-         LOGW("Camera source supports metadata mode, create OMXCodec for metadata");
-         encoder_flags |= OMXCodec::kHardwareCodecsOnly;
-         encoder_flags |= OMXCodec::kStoreMetaDataInVideoBuffers;
-         encoder_flags |= OMXCodec::kOnlySubmitOneInputBufferAtOneTime;
-     }
--- a/dom/events/KeyNameList.h
+++ b/dom/events/KeyNameList.h
@@ -29,17 +29,16 @@ DEFINE_KEYNAME_WITH_SAME_NAME(Unidentifi
  * Our Internal Key Values (must have "Moz" prefix)
  *****************************************************************************/
 DEFINE_KEYNAME_INTERNAL(PrintableKey, "MozPrintableKey")
 DEFINE_KEYNAME_INTERNAL(SoftLeft, "MozSoftLeft")
 DEFINE_KEYNAME_INTERNAL(SoftRight, "MozSoftRight")
 
 #ifdef MOZ_B2G
 DEFINE_KEYNAME_INTERNAL(HomeScreen, "MozHomeScreen")
-DEFINE_KEYNAME_INTERNAL(CameraFocusAdjust, "MozCameraFocusAdjust")
 #endif // #ifdef MOZ_B2G
 
 /******************************************************************************
  * Modifier Keys
  *****************************************************************************/
 DEFINE_KEYNAME_WITH_SAME_NAME(Alt)
 DEFINE_KEYNAME_WITH_SAME_NAME(AltGraph)
 DEFINE_KEYNAME_WITH_SAME_NAME(CapsLock)
--- a/dom/events/test/test_all_synthetic_events.html
+++ b/dom/events/test/test_all_synthetic_events.html
@@ -127,32 +127,16 @@ const kEventConstructors = {
   CallEvent:                                 { create: function (aName, aProps) {
                                                           return new CallEvent(aName, aProps);
                                                        },
                                              },
   CallGroupErrorEvent:                       { create: function (aName, aProps) {
                                                           return new CallGroupErrorEvent(aName, aProps);
                                                        },
                                              },
-  CameraClosedEvent:                        { create: function (aName, aProps) {
-                                                          return new CameraClosedEvent(aName, aProps);
-                                                       },
-                                             },
-  CameraConfigurationEvent:                  { create: function (aName, aProps) {
-                                                          return new CameraConfigurationEvent(aName, aProps);
-                                                       },
-                                             },
-  CameraFacesDetectedEvent:                  { create: function (aName, aProps) {
-                                                          return new CameraFacesDetectedEvent(aName, aProps);
-                                                       },
-                                             },
-  CameraStateChangeEvent:                    { create: function (aName, aProps) {
-                                                          return new CameraStateChangeEvent(aName, aProps);
-                                                       },
-                                             },
   CFStateChangeEvent:                        { create: function (aName, aProps) {
                                                           return new CFStateChangeEvent(aName, aProps);
                                                        },
                                              },
   CloseEvent:                                { create: function (aName, aProps) {
                                                          return new CloseEvent(aName, aProps);
                                                        },
                                              },
--- a/dom/html/HTMLMediaElement.cpp
+++ b/dom/html/HTMLMediaElement.cpp
@@ -5563,20 +5563,16 @@ void HTMLMediaElement::FireTimeUpdate(bo
   }
 }
 
 MediaStream* HTMLMediaElement::GetSrcMediaStream() const
 {
   if (!mSrcStream) {
     return nullptr;
   }
-  if (mSrcStream->GetCameraStream()) {
-    // XXX Remove this check with CameraPreviewMediaStream per bug 1124630.
-    return mSrcStream->GetCameraStream();
-  }
   return mSrcStream->GetPlaybackStream();
 }
 
 void HTMLMediaElement::GetCurrentSpec(nsCString& aString)
 {
   if (mLoadingSrc) {
     mLoadingSrc->GetSpec(aString);
   } else {
--- a/dom/ipc/TabChild.cpp
+++ b/dom/ipc/TabChild.cpp
@@ -1548,71 +1548,16 @@ TabChild::ApplyShowInfo(const ShowInfo& 
     }
   }
   mDPI = aInfo.dpi();
   mRounding = aInfo.widgetRounding();
   mDefaultScale = aInfo.defaultScale();
   mIsTransparent = aInfo.isTransparent();
 }
 
-#ifdef MOZ_WIDGET_GONK
-void
-TabChild::MaybeRequestPreinitCamera()
-{
-    // Check if this tab is an app (not a browser frame) and will use the
-    // `camera` permission,
-    if (IsIsolatedMozBrowserElement()) {
-      return;
-    }
-
-    nsCOMPtr<nsIAppsService> appsService = do_GetService("@mozilla.org/AppsService;1");
-    if (NS_WARN_IF(!appsService)) {
-      return;
-    }
-
-    nsCOMPtr<mozIApplication> app;
-    nsresult rv = appsService->GetAppByLocalId(OwnAppId(), getter_AddRefs(app));
-    if (NS_WARN_IF(NS_FAILED(rv)) || !app) {
-      return;
-    }
-
-    nsCOMPtr<nsIPrincipal> principal;
-    app->GetPrincipal(getter_AddRefs(principal));
-    if (NS_WARN_IF(!principal)) {
-      return;
-    }
-
-    uint16_t status = nsIPrincipal::APP_STATUS_NOT_INSTALLED;
-    principal->GetAppStatus(&status);
-    bool isCertified = status == nsIPrincipal::APP_STATUS_CERTIFIED;
-    if (!isCertified) {
-      return;
-    }
-
-    nsCOMPtr<nsIPermissionManager> permMgr = services::GetPermissionManager();
-    if (NS_WARN_IF(!permMgr)) {
-      return;
-    }
-
-    uint32_t permission = nsIPermissionManager::DENY_ACTION;
-    permMgr->TestPermissionFromPrincipal(principal, "camera", &permission);
-    bool hasPermission = permission == nsIPermissionManager::ALLOW_ACTION;
-    if (!hasPermission) {
-      return;
-    }
-
-    nsCOMPtr<nsIObserverService> observerService = services::GetObserverService();
-    if (NS_WARN_IF(!observerService)) {
-      return;
-    }
-
-    observerService->NotifyObservers(nullptr, "init-camera-hw", nullptr);
-}
-#endif
-
 bool
 TabChild::RecvShow(const ScreenIntSize& aSize,
                    const ShowInfo& aInfo,
                    const TextureFactoryIdentifier& aTextureFactoryIdentifier,
                    const uint64_t& aLayersId,
                    PRenderFrameChild* aRenderFrame,
                    const bool& aParentIsActive,
                    const nsSizeMode& aSizeMode)
@@ -1637,20 +1582,16 @@ TabChild::RecvShow(const ScreenIntSize& 
         // remote> has already been destroyed, and we couldn't hook
         // into the parent-process's layer system.  That's not a fatal
         // error.
         return true;
     }
 
     baseWindow->SetVisibility(true);
 
-#ifdef MOZ_WIDGET_GONK
-    MaybeRequestPreinitCamera();
-#endif
-
     bool res = InitTabChildGlobal();
     ApplyShowInfo(aInfo);
     RecvParentActivated(aParentIsActive);
 
     return res;
 }
 
 bool
--- a/dom/ipc/TabChild.h
+++ b/dom/ipc/TabChild.h
@@ -679,20 +679,16 @@ protected:
   virtual bool RecvSetKeyboardIndicators(const UIStateChangeType& aShowAccelerators,
                                          const UIStateChangeType& aShowFocusRings) override;
 
   virtual bool RecvStopIMEStateManagement() override;
 
   virtual bool RecvMenuKeyboardListenerInstalled(
                  const bool& aInstalled) override;
 
-#ifdef MOZ_WIDGET_GONK
-  void MaybeRequestPreinitCamera();
-#endif
-
 private:
   void HandleDoubleTap(const CSSPoint& aPoint, const Modifiers& aModifiers,
                        const ScrollableLayerGuid& aGuid);
 
   // Notify others that our TabContext has been updated.
   //
   // You should call this after calling TabContext::SetTabContext().  We also
   // call this during Init().
--- a/dom/media/DOMMediaStream.cpp
+++ b/dom/media/DOMMediaStream.cpp
@@ -55,19 +55,17 @@ const TrackID TRACK_VIDEO_PRIMARY = 1;
 
 DOMMediaStream::TrackPort::TrackPort(MediaInputPort* aInputPort,
                                      MediaStreamTrack* aTrack,
                                      const InputPortOwnership aOwnership)
   : mInputPort(aInputPort)
   , mTrack(aTrack)
   , mOwnership(aOwnership)
 {
-  // XXX Bug 1124630. nsDOMCameraControl requires adding a track without and
-  // input port.
-  // MOZ_ASSERT(mInputPort);
+  MOZ_ASSERT(mInputPort);
   MOZ_ASSERT(mTrack);
 
   MOZ_COUNT_CTOR(TrackPort);
 }
 
 DOMMediaStream::TrackPort::~TrackPort()
 {
   MOZ_COUNT_DTOR(TrackPort);
@@ -1275,24 +1273,16 @@ DOMMediaStream::DispatchTrackEvent(const
 
   RefPtr<MediaStreamTrackEvent> event =
     MediaStreamTrackEvent::Constructor(this, aName, init);
 
   return DispatchTrustedEvent(event);
 }
 
 void
-DOMMediaStream::CreateAndAddPlaybackStreamListener(MediaStream* aStream)
-{
-  MOZ_ASSERT(GetCameraStream(), "I'm a hack. Only DOMCameraControl may use me.");
-  mPlaybackListener = new PlaybackStreamListener(this);
-  aStream->AddListener(mPlaybackListener);
-}
-
-void
 DOMMediaStream::BlockPlaybackTrack(TrackPort* aTrack)
 {
   MOZ_ASSERT(aTrack);
   ++mTracksPendingRemoval;
   RefPtr<Pledge<bool>> p =
     aTrack->BlockSourceTrackId(aTrack->GetTrack()->mTrackID,
                                BlockingMode::CREATION);
   RefPtr<DOMMediaStream> self = this;
--- a/dom/media/DOMMediaStream.h
+++ b/dom/media/DOMMediaStream.h
@@ -610,19 +610,16 @@ protected:
                               const RefPtr<MediaStreamTrack>& aTrack);
 
   class OwnedStreamListener;
   friend class OwnedStreamListener;
 
   class PlaybackStreamListener;
   friend class PlaybackStreamListener;
 
-  // XXX Bug 1124630. Remove with CameraPreviewMediaStream.
-  void CreateAndAddPlaybackStreamListener(MediaStream*);
-
   /**
    * Block a track in our playback stream. Calls NotifyPlaybackTrackBlocked()
    * after the MediaStreamGraph has applied the block and the track is no longer
    * live.
    */
   void BlockPlaybackTrack(TrackPort* aTrack);
 
   /**
--- a/dom/media/MediaManager.h
+++ b/dom/media/MediaManager.h
@@ -38,20 +38,16 @@
 #ifdef MOZ_WEBRTC
 #include "mtransport/runnable_utils.h"
 #endif
 
 // Note, these suck in Windows headers, unfortunately.
 #include "base/thread.h"
 #include "base/task.h"
 
-#ifdef MOZ_WIDGET_GONK
-#include "DOMCameraManager.h"
-#endif
-
 namespace mozilla {
 namespace dom {
 struct MediaStreamConstraints;
 struct MediaTrackConstraints;
 struct MediaTrackConstraintSet;
 } // namespace dom
 
 class MediaManager;
--- a/dom/media/MediaStreamGraph.h
+++ b/dom/media/MediaStreamGraph.h
@@ -75,17 +75,16 @@ namespace media {
  *
  * When the graph is changed, we may need to throw out buffered data and
  * reprocess it. This is triggered automatically by the MediaStreamGraph.
  */
 
 class AudioNodeEngine;
 class AudioNodeExternalInputStream;
 class AudioNodeStream;
-class CameraPreviewMediaStream;
 class MediaInputPort;
 class MediaStream;
 class MediaStreamGraph;
 class MediaStreamGraphImpl;
 class ProcessedMediaStream;
 class SourceMediaStream;
 
 class AudioDataListenerInterface {
@@ -154,17 +153,16 @@ struct AudioNodeSizes
   size_t mEngine;
   const char* mNodeType;
 };
 
 class AudioNodeEngine;
 class AudioNodeExternalInputStream;
 class AudioNodeStream;
 class AudioSegment;
-class CameraPreviewMediaStream;
 class DirectMediaStreamListener;
 class DirectMediaStreamTrackListener;
 class MediaInputPort;
 class MediaStreamGraphImpl;
 class MediaStreamListener;
 class MediaStreamTrackListener;
 class MediaStreamVideoSink;
 class ProcessedMediaStream;
--- a/dom/media/imagecapture/ImageCapture.h
+++ b/dom/media/imagecapture/ImageCapture.h
@@ -27,18 +27,18 @@ class VideoStreamTrack;
  *  Implementation of https://dvcs.w3.org/hg/dap/raw-file/default/media-stream-
  *  capture/ImageCapture.html.
  *  The ImageCapture accepts a VideoStreamTrack as input source. The image will
  *  be sent back as a JPG format via Blob event.
  *
  *  All the functions in ImageCapture are run in main thread.
  *
  *  There are two ways to capture image, MediaEngineSource and MediaStreamGraph.
- *  When the implementation of MediaEngineSource supports TakePhoto() in platform
- *  like B2G, it uses the platform camera to grab image. Otherwise, it falls back
+ *  When the implementation of MediaEngineSource supports TakePhoto(),
+ *  it uses the platform camera to grab image. Otherwise, it falls back
  *  to the MediaStreamGraph way.
  */
 
 class ImageCapture final : public DOMEventTargetHelper
 {
 public:
   NS_DECL_ISUPPORTS_INHERITED
   NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(ImageCapture, DOMEventTargetHelper)
--- a/dom/media/moz.build
+++ b/dom/media/moz.build
@@ -295,17 +295,16 @@ EXTRA_JS_MODULES.media += [
     'IdpSandbox.jsm',
     'PeerConnectionIdp.jsm',
     'RTCStatsReport.jsm',
 ]
 
 LOCAL_INCLUDES += [
     '/caps',
     '/dom/base',
-    '/dom/camera',
     '/layout/generic',
     '/layout/xul',
     '/netwerk/base',
 ]
 
 if CONFIG['MOZ_DIRECTSHOW']:
     LOCAL_INCLUDES += [
         '/media/webrtc/trunk/webrtc/modules/video_capture/windows',
--- a/dom/media/standalone/moz.build
+++ b/dom/media/standalone/moz.build
@@ -15,17 +15,16 @@ UNIFIED_SOURCES += [
 ]
 
 if CONFIG['MOZ_WIDGET_TOOLKIT'] == 'cocoa':
     UNIFIED_SOURCES += ['../systemservices/OSXRunLoopSingleton.cpp']
 
 LOCAL_INCLUDES += [
     '/caps',
     '/dom/base',
-    '/dom/camera',
     '/layout/generic',
     '/layout/xul',
     '/netwerk/base',
 ]
 
 if CONFIG['MOZ_WEBRTC']:
     LOCAL_INCLUDES += [
         '/media/webrtc/signaling/src/common',
--- a/dom/media/test/test_imagecapture.html
+++ b/dom/media/test/test_imagecapture.html
@@ -107,27 +107,18 @@ function trackTest(track) {
 
     track.enabled = false;
     imageCapture.takePhoto()
   });
 }
 
 function init() {
   return new Promise(function(resolve, reject) {
-    var constraints;
-    if (SpecialPowers.Services.appinfo.widgetToolkit == "gonk") {
-      info("B2G ImageCapture test");
-      // Reduce repeat count due to b2g emulator is very slow.
-      repeat = 20;
-      // Use gonk camera, MedieEngine will be the backend of ImageCapture.
-      constraints = {video: true};
-    } else {
-      // use fake camera, MediaStreamGraph will be the backend of ImageCapture.
-      constraints = {video: true, fake: true}
-    }
+    // use fake camera, MediaStreamGraph will be the backend of ImageCapture.
+    var constraints = {video: true, fake: true}
 
     window.navigator.mozGetUserMedia(
       constraints,
       function(stream) {
         var track = stream.getVideoTracks()[0];
         resolve(track);
       },
       function(err) {
--- a/dom/media/webrtc/moz.build
+++ b/dom/media/webrtc/moz.build
@@ -37,17 +37,16 @@ if CONFIG['MOZ_WEBRTC']:
         'RTCIdentityProviderRegistrar.cpp',
     ]
     # MediaEngineWebRTC.cpp needs to be built separately.
     SOURCES += [
         'MediaEngineWebRTC.cpp',
     ]
     LOCAL_INCLUDES += [
         '/dom/base',
-        '/dom/camera',
         '/media/libyuv/include',
         '/media/webrtc/signaling/src/common',
         '/media/webrtc/signaling/src/common/browser_logging',
         '/media/webrtc/trunk',
     ]
 
 XPIDL_SOURCES += [
     'nsITabSource.idl'
--- a/dom/moz.build
+++ b/dom/moz.build
@@ -84,17 +84,16 @@ DIRS += [
     'network',
     'permission',
     'plugins/base',
     'plugins/ipc',
     'indexedDB',
     'system',
     'ipc',
     'workers',
-    'camera',
     'audiochannel',
     'broadcastchannel',
     'messagechannel',
     'promise',
     'smil',
     'telephony',
     'url',
     'voicemail',
--- a/dom/permission/tests/mochitest.ini
+++ b/dom/permission/tests/mochitest.ini
@@ -16,18 +16,16 @@ skip-if = true
 skip-if = true
 [test_presentation-device-manage.html]
 skip-if = true
 [test_systemXHR.html]
 [test_tcp-socket.html]
 skip-if = true
 [test_udp-socket.html]
 skip-if = true
-[test_camera.html]
-disabled = disabled until bug 859593 is fixed
 [test_keyboard.html]
 # skip-if = toolkit == 'android'
 skip-if = true
 [test_input-manage.html]
 # skip-if = toolkit == 'android'
 skip-if = true
 [test_wifi-manage.html]
 # skip-if = (buildapp != 'b2g') || (buildapp == 'mulet') || (buildapp == 'b2g' && toolkit != 'gonk') #b2g-desktop(Bug 931116, b2g desktop specific, initial triage)
deleted file mode 100644
--- a/dom/permission/tests/test_camera.html
+++ /dev/null
@@ -1,30 +0,0 @@
-<!DOCTYPE HTML>
-<html>
-<!--
-https://bugzilla.mozilla.org/show_bug.cgi?id=815105
--->
-<head>
-  <meta charset="utf-8">
-  <title>Test for Bug 815105 </title>
-  <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
-  <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
-</head>
-<body>
-<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=815105">Mozilla Bug 815105 </a>
-<p id="display"></p>
-<div id="content" style="display: none"></div>
-<pre id="test">
-<script type="application/javascript;version=1.8" src="file_framework.js"></script>
-<script type="application/javascript;version=1.8">
-var gData = [
-  {
-    perm: ["camera"],
-    obj: "mozCameras",
-    idl: "nsIDOMCameraManager",
-  },
-]
-</script>
-</pre>
-</body>
-</html>
-
deleted file mode 100644
--- a/dom/webidl/CameraCapabilities.webidl
+++ /dev/null
@@ -1,92 +0,0 @@
-/* -*- Mode: IDL; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
-/* vim: set ts=2 et sw=2 tw=80: */
-/* 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/.
- */
-
-/* The capabilities of the video recorder. These are guaranteed not to change
-   over the lifetime of that partcicular instance.
-*/
-[Func="CameraCapabilities::HasSupport"]
-interface CameraRecorderAudioProfile
-{
-  [Constant, Cached] readonly attribute DOMString codec;
-  [Constant, Cached] readonly attribute unsigned long bitsPerSecond;
-  [Constant, Cached] readonly attribute unsigned long samplesPerSecond;
-  [Constant, Cached] readonly attribute unsigned long channels;
-
-  jsonifier;
-};
-
-[Func="CameraCapabilities::HasSupport"]
-interface CameraRecorderVideoProfile
-{
-  [Constant, Cached] readonly attribute DOMString codec;
-  [Constant, Cached] readonly attribute unsigned long bitsPerSecond;
-  [Constant, Cached] readonly attribute unsigned long framesPerSecond;
-  [Constant, Cached] readonly attribute CameraSize size;
-
-  [Constant, Cached] readonly attribute unsigned long width;
-  [Constant, Cached] readonly attribute unsigned long height;
-
-  jsonifier;
-};
-
-[Func="CameraCapabilities::HasSupport"]
-interface CameraRecorderProfile
-{
-  [Constant, Cached] readonly attribute DOMString name;
-  [Constant, Cached] readonly attribute DOMString containerFormat;
-  [Constant, Cached] readonly attribute DOMString mimeType;
-
-  [Constant, Cached] readonly attribute CameraRecorderAudioProfile audio;
-  [Constant, Cached] readonly attribute CameraRecorderVideoProfile video;
-
-  jsonifier;
-};
-
-[Func="CameraCapabilities::HasSupport"]
-interface CameraRecorderProfiles
-{
-  getter CameraRecorderProfile(DOMString profile);
-
-  jsonifier;
-};
-
-/* The capabilities of a CameraControl instance. These are guaranteed
-   not to change over the lifetime of that particular instance.
-*/
-[Func="CameraCapabilities::HasSupport"]
-interface CameraCapabilities
-{
-  [Constant, Cached] readonly attribute sequence<CameraSize> previewSizes;
-  [Constant, Cached] readonly attribute sequence<CameraSize> pictureSizes;
-  [Constant, Cached] readonly attribute sequence<CameraSize> thumbnailSizes;
-  [Constant, Cached] readonly attribute sequence<CameraSize> videoSizes;
-
-  [Constant, Cached] readonly attribute sequence<DOMString> fileFormats;
-
-  [Constant, Cached] readonly attribute sequence<DOMString> whiteBalanceModes;
-  [Constant, Cached] readonly attribute sequence<DOMString> sceneModes;
-  [Constant, Cached] readonly attribute sequence<DOMString> effects;
-  [Constant, Cached] readonly attribute sequence<DOMString> flashModes;
-  [Constant, Cached] readonly attribute sequence<DOMString> focusModes;
-
-  [Constant, Cached] readonly attribute sequence<double> zoomRatios;
-
-  [Constant, Cached] readonly attribute unsigned long maxFocusAreas;
-  [Constant, Cached] readonly attribute unsigned long maxMeteringAreas;
-  [Constant, Cached] readonly attribute unsigned long maxDetectedFaces;
-
-  [Constant, Cached] readonly attribute double minExposureCompensation;
-  [Constant, Cached] readonly attribute double maxExposureCompensation;
-  [Constant, Cached] readonly attribute double exposureCompensationStep;
-
-  [Constant, Cached] readonly attribute CameraRecorderProfiles recorderProfiles;
-
-  [Constant, Cached] readonly attribute sequence<DOMString> isoModes;
-  [Constant, Cached] readonly attribute sequence<DOMString> meteringModes;
-
-  jsonifier;
-};
deleted file mode 100644
--- a/dom/webidl/CameraClosedEvent.webidl
+++ /dev/null
@@ -1,16 +0,0 @@
-/* -*- Mode: IDL; 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/. */
-
-[Func="Navigator::HasCameraSupport",
- Constructor(DOMString type, optional CameraClosedEventInit eventInitDict)]
-interface CameraClosedEvent : Event
-{
-  readonly attribute DOMString reason;
-};
-
-dictionary CameraClosedEventInit : EventInit
-{
-  DOMString reason = "HardwareReleased";
-};
deleted file mode 100644
--- a/dom/webidl/CameraConfigurationEvent.webidl
+++ /dev/null
@@ -1,22 +0,0 @@
-/* -*- Mode: IDL; 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/. */
-
-[Func="Navigator::HasCameraSupport",
- Constructor(DOMString type, optional CameraConfigurationEventInit eventInitDict)]
-interface CameraConfigurationEvent : Event
-{
-  readonly attribute CameraMode mode;
-  readonly attribute DOMString recorderProfile;
-  readonly attribute DOMRectReadOnly? previewSize;
-  readonly attribute DOMRectReadOnly? pictureSize;
-};
-
-dictionary CameraConfigurationEventInit : EventInit
-{
-  CameraMode mode = "picture";
-  DOMString recorderProfile = "cif";
-  DOMRectReadOnly? previewSize = null;
-  DOMRectReadOnly? pictureSize = null;
-};
deleted file mode 100644
--- a/dom/webidl/CameraControl.webidl
+++ /dev/null
@@ -1,515 +0,0 @@
-/* -*- Mode: IDL; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
-/* vim: set ts=2 et sw=2 tw=80: */
-/* 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/.
- */
-
-/* Camera regions are used to set focus and metering areas;
-   the coordinates are referenced to the sensor:
-     (-1000, -1000) is the top-left corner
-     (1000, 1000) is the bottom-right corner
-   The weight of the region can range from 0 to 1000. */
-dictionary CameraRegion
-{
-  long top = -1000;
-  long left = -1000;
-  long bottom = 1000;
-  long right = 1000;
-  unsigned long weight = 1000;
-};
-
-/* The position information to record in the image header.
-   'NaN' indicates the information is not available. */
-dictionary CameraPosition
-{
-  unrestricted double latitude = NaN;
-  unrestricted double longitude = NaN;
-  unrestricted double altitude = NaN;
-  unrestricted double timestamp = NaN;
-};
-
-/*
-  Options for takePicture().
-*/
-dictionary CameraPictureOptions
-{
-  /* an object with a combination of 'height' and 'width' properties
-     chosen from CameraCapabilities.pictureSizes */
-  CameraSize pictureSize = null;
-
-  /* one of the file formats chosen from
-     CameraCapabilities.fileFormats */
-  DOMString fileFormat = "";
-
-  /* the rotation of the image in degrees, from 0 to 270 in
-     steps of 90; this doesn't affect the image, only the
-     rotation recorded in the image header.*/
-  long rotation = 0;
-
-  /* an object containing any or all of 'latitude', 'longitude',
-     'altitude', and 'timestamp', used to record when and where
-     the image was taken.  e.g.
-     {
-         latitude:  43.647118,
-         longitude: -79.3943,
-         altitude:  500
-         // timestamp not specified, in this case, and
-         // won't be included in the image header
-     }
-
-     can be null in the case where position information isn't
-     available/desired.
-
-     'altitude' is in metres; 'timestamp' is UTC, in seconds from
-     January 1, 1970.
-  */
-  CameraPosition position = null;
-
-  /* the number of seconds from January 1, 1970 UTC.  This can be
-     different from the positional timestamp (above). */
-  // XXXbz this should really accept a date too, no?
-  long long dateTime = 0;
-};
-
-/* These properties affect the actual video recording, e.g.
-      {
-         rotation: 0,
-         maxFileSizeBytes: 1024 * 1024,
-         maxVideoLengthMs: 0
-      }
-
-   'rotation' is the degrees clockwise to rotate the recorded video; if
-   this options is not supported, it will be ignored; if this option is
-   missing, the default is 0.
-
-   'maxFileSizeBytes' is the maximum size in bytes to which the recorded
-   video file will be allowed to grow.
-
-   'maxVideoLengthMs' is the maximum length in milliseconds to which the
-   recorded video will be allowed to grow.
-
-   if either 'maxFileSizeBytes' or 'maxVideoLengthMs' is missing or zero,
-   that limit will be disabled; if either value is out of range, it will
-   be clamped from 0 to the upper limit for an 'unsigned long long'.
-*/
-dictionary CameraStartRecordingOptions
-{
-  long rotation = 0;
-  [Clamp]
-  unsigned long long maxFileSizeBytes = 0;
-  [Clamp]
-  unsigned long long maxVideoLengthMs = 0;
-
-  /* If startRecording() is called with flashMode set to "auto" and the
-     camera has determined that the scene is poorly lit, the flash mode
-     will be automatically changed to "torch" until stopRecording() is
-     called. During this time, flashMode will reflect the new setting. If
-     flashMode is changed while recording is in progress, the new setting
-     will be left as-is on stopRecording(). If the camera does not
-     support this setting, it will be ignored. */
-  boolean autoEnableLowLightTorch = false;
-
-  /* If true, a poster JPG will be created from the recording and issued
-     via the poster event. PosterCreated or PosterFailed recording state
-     changes will indicate whether or not it was created. */
-  boolean createPoster = false;
-};
-
-/*
-    attributes here affect the preview, any pictures taken, and/or
-    any video recorded by the camera.
-*/
-[Func="nsDOMCameraControl::HasSupport"]
-interface CameraControl : MediaStream
-{
-  [Constant, Cached]
-  readonly attribute CameraCapabilities capabilities;
-
-  /* one of the values chosen from capabilities.effects;
-     default is "none" */
-  [Throws]
-  attribute DOMString       effect;
-
-  /* one of the values chosen from capabilities.whiteBalanceModes;
-     default is "auto" */
-  [Throws]
-  attribute DOMString       whiteBalanceMode;
-
-  /* one of the values chosen from capabilities.sceneModes;
-     default is "auto" */
-  [Throws]
-  attribute DOMString       sceneMode;
-
-  /* one of the values chosen from capabilities.flashModes;
-     default is "auto" */
-  [Throws]
-  attribute DOMString       flashMode;
-
-  /* one of the values chosen from capabilities.focusModes;
-     default is "auto", if supported, or "fixed" */
-  [Throws]
-  attribute DOMString       focusMode;
-
-  /* one of the values chosen from capabilities.zoomRatios; other
-     values will be rounded to the nearest supported value;
-     default is 1.0 */
-  [Throws]
-  attribute double          zoom;
-
-  /* an array of one or more objects that define where the
-     camera will perform light metering, each defining the properties:
-      {
-          top: -1000,
-          left: -1000,
-          bottom: 1000,
-          right: 1000,
-          weight: 1000
-      }
-
-     'top', 'left', 'bottom', and 'right' all range from -1000 at
-     the top-/leftmost of the sensor to 1000 at the bottom-/rightmost
-     of the sensor.
-
-     objects missing one or more of these properties will be ignored;
-     if the array contains more than capabilities.maxMeteringAreas,
-     extra areas will be ignored.
-
-     if this setter is called with no arguments, the camera will
-     determine metering areas on its own. */
-  [Throws]
-  sequence<CameraRegion> getMeteringAreas();
-  [Throws]
-  void setMeteringAreas(optional sequence<CameraRegion> meteringAreas);
-
-  /* an array of one or more objects that define where the camera will
-     perform auto-focusing, with the same definition as meteringAreas.
-
-     if the array contains more than capabilities.maxFocusAreas, extra
-     areas will be ignored.
-
-     if this setter is called with no arguments, the camera will
-     determine focus areas on its own. */
-  [Throws]
-  sequence<CameraRegion> getFocusAreas();
-  [Throws]
-  void setFocusAreas(optional sequence<CameraRegion> focusAreas);
-
-  /* focal length in millimetres */
-  [Throws]
-  readonly attribute double focalLength;
-
-  /* the distances in metres to where the image subject appears to be
-     in focus.  'focusDistanceOptimum' is where the subject will appear
-     sharpest; the difference between 'focusDistanceFar' and
-     'focusDistanceNear' is the image's depth of field.
-
-     'focusDistanceFar' may be infinity. */
-  [Throws]
-  readonly attribute double focusDistanceNear;
-  [Throws]
-  readonly attribute double focusDistanceOptimum;
-  [Throws]
-  readonly attribute unrestricted double focusDistanceFar;
-
-  /* over- or under-expose the image; acceptable values must range from
-     minExposureCompensation to maxExposureCompensation in steps of
-     stepExposureCompensation. Invalid values will be rounded to the nearest
-     valid value; out-of-bounds values will be limited to the range
-     supported by the camera. */
-  [Throws]
-  attribute double          exposureCompensation;
-
-  /* one of the values chosen from capabilities.isoModes; default
-     value is "auto" if supported. */
-  [Throws]
-  attribute DOMString       isoMode;
-
-  /* the event dispatched on the camera's shutter event, to trigger
-     a shutter sound and/or a visual shutter indicator.
-
-     contains no event-specific data. */
-  attribute EventHandler    onshutter;
-
-  /* the event dispatched when the camera hardware is closed; this may
-     be due to a system failure, another process taking over the camera,
-     or a call to release().
-
-     The event has a 'reason' attribute that will be one of the following
-     string values:
-       - SystemFailure    : the camera subsystem failed and was closed;
-       - HardwareReleased : a call to release() was successful;
-       - NotAvailable     : the camera hardware is in use by another process.
-  */
-  attribute EventHandler    onclose;
-
-  /* the event dispatched when the recorder changes state, either because
-     the recording process encountered an error, or because one of the
-     recording limits (see CameraStartRecordingOptions) was reached.
-
-     event type is CameraStateChangeEvent where:
-         'newState' is one of the following states:
-             'Started' if the recording has begun capturing data
-             'Stopped' when the recording has completed (success and failure)
-             'Paused' if the recording is paused
-             'Resumed' if the recording is resumed after pausing
-             'PosterCreated' if a poster was requested and created
-             'PosterFailed' if a poster was requested and failed to create
-             'FileSizeLimitReached' if stopped due to file size limit
-             'VideoLengthLimitReached' if stopped due to a time limit
-             'TrackCompleted' if audio or video track complete when stopping
-             'TrackFailed' if audio or video track incomplete when stopping
-             'MediaRecorderFailed' if failed due to local error
-             'MediaServerFailed' if failed due to media server */
-  attribute EventHandler    onrecorderstatechange;
-
-  /* the event dispatched when a poster is successfully captured; it is of the
-     type BlobEvent, where the data attribute contains the poster. */
-  attribute EventHandler    onposter;
-
-  /* the event dispatched when the viewfinder stops or starts,
-     useful for synchronizing other UI elements.
-
-     event type is CameraStateChangeEvent where:
-         'newState' is the new preview state */
-  attribute EventHandler    onpreviewstatechange;
-
-  /* the size of the picture to be returned by a call to takePicture();
-     an object with 'height' and 'width' properties that corresponds to
-     one of the options returned by capabilities.pictureSizes.
-
-     note that unlike when one uses setConfiguration instead to update the
-     picture size, this will not recalculate the ideal preview size. */
-  [Throws]
-  CameraSize getPictureSize();
-  [Throws]
-  void setPictureSize(optional CameraSize size);
-
-  /* if the image blob to be returned by takePicture() supports lossy
-     compression, this setting controls the quality-size trade-off;
-     valid values range from 0.0 for smallest size/worst quality to 1.0
-     for largest size/best quality. Note that depending on the range of
-     values supported by the underlying platform, this attribute may not
-     'get' the exact value that was previously 'set'. If this setting is
-     not supported, it is ignored. */
-  [Throws]
-  attribute double          pictureQuality;
-
-  /* the size of the thumbnail to be included in the picture returned
-     by a call to takePicture(), assuming the chosen fileFormat supports
-     one; an object with 'height' and 'width' properties that corresponds
-     to one of the options returned by capabilities.pictureSizes.
-
-     this setting should be considered a hint: the implementation will
-     respect it when possible, and override it if necessary. */
-  [Throws]
-  CameraSize getThumbnailSize();
-  [Throws]
-  void setThumbnailSize(optional CameraSize size);
-
-  /* the angle, in degrees, that the image sensor is mounted relative
-     to the display; e.g. if 'sensorAngle' is 270 degrees (or -90 degrees),
-     then the preview stream needs to be rotated +90 degrees to have the
-     same orientation as the real world. */
-  [Constant, Cached]
-  readonly attribute long   sensorAngle;
-
-  /* the mode the camera will use to determine the correct exposure of
-     the scene; supported modes are exposed by capabilities.meteringModes. */
-  [Throws]
-  attribute DOMString       meteringMode;
-
-  /* tell the camera to attempt to focus the image */
-  [Throws]
-  Promise<boolean> autoFocus();
-
-  /* the event dispatched whenever the focus state changes due to calling
-     autoFocus or due to continuous autofocus.
-
-     if continuous autofocus is supported and focusMode is set to enable it,
-     then this event is dispatched whenever the camera decides to start and
-     stop moving the focus position; it can be used to update a UI element to
-     indicate that the camera is still trying to focus, or has finished. Some
-     platforms do not support this event, in which case the callback is never
-     invoked.
-
-     event type is CameraStateChangeEvent where:
-         'newState' is one of the following states:
-             'focused' if the focus is now set
-             'focusing' if the focus is moving
-             'unfocused' if last attempt to focus failed */
-  attribute EventHandler    onfocus;
-
-  /* capture an image and return it as a blob to the 'onSuccess' callback;
-     if the camera supports it, this may be invoked while the camera is
-     already recording video.
-
-     invoking this function will stop the preview stream, which must be
-     manually restarted by calling resumePreview(). */
-  [Throws]
-  Promise<Blob> takePicture(optional CameraPictureOptions options);
-
-  /* the event dispatched when a picture is successfully taken; it is of the
-     type BlobEvent, where the data attribute contains the picture. */
-  attribute EventHandler    onpicture;
-
-  /* start recording video; 'options' is a CameraStartRecordingOptions object.
-     If the success/error callbacks are not used, one may determine success by
-     waiting for the recorderstatechange event. */
-  [Throws]
-  Promise<void> startRecording(CameraStartRecordingOptions options,
-                               DeviceStorage storageArea,
-                               DOMString filename);
-
-  /* stop recording video. */
-  [Throws]
-  void stopRecording();
-
-  /* pause recording video. The camera remains active but audio and video
-     frames are no longer saved in the output file. If called when not
-     recording or already paused, it fails silently. */
-  [Throws]
-  void pauseRecording();
-
-  /* resume recording video while paused. If called when not recording or
-     not paused, it fails silently. */
-  [Throws]
-  void resumeRecording();
-
-  /* call in or after the takePicture() onSuccess callback to
-     resume the camera preview stream. */
-  [Throws]
-  void resumePreview();
-
-  /* release the camera so that other applications can use it; you should
-     probably call this whenever the camera is not longer in the foreground
-     (depending on your usage model).
-
-     once this is called, the camera control object is to be considered
-     defunct; a new instance will need to be created to access the camera. */
-  [Throws]
-  Promise<void> release();
-
-  /* changes the camera configuration on the fly. */
-  [Throws]
-  Promise<CameraConfiguration> setConfiguration(optional CameraConfiguration configuration);
-
-  /* the event dispatched when the camera is successfully configured.
-
-     event type is CameraConfigurationEvent which has the same members as
-     CameraConfiguration. */
-  attribute EventHandler onconfigurationchange;
-
-  /* if focusMode is set to either 'continuous-picture' or 'continuous-video',
-     then calling autoFocus() will trigger its onSuccess callback immediately
-     if the camera was either successfully focused, or if no focus could be
-     acquired; if the focus acquisition is still in progress, the onSuccess
-     callback will be invoked later, its argument indicating success or
-     failure.
-
-     once autoFocus() is called with a continuous autofocus mode set, the
-     continuous autofocus process is stopped and focus is locked in the
-     current state until this method is called.
-  */
-  [Throws]
-  void resumeContinuousFocus();
-};
-
-/* The information of the each face detected by a camera device, e.g.
-     {
-       id: 1,
-       score: 80,
-       bound: { left:   -203,
-                top:    -400,
-                right:   300,
-                bottom:  250 },
-       leftEye:  { x:  -100,
-                   y:  -200 },
-       rightEye: { x:   100,
-                   y:   100 },
-       mouth:    { x:   150,
-                   y:   150 } }
-
-   'id' is an unique value per face while the face is visible to the tracker.
-   If the face leaves the viewfinder and then returns, it will be assigned
-   a new value.
-
-   'score' is the confidence level for the detection of the face.
-   This range is 1 to 100, where 100 is the highest confidence.
-
-   'bounds' is the bounds of the face. It is guaranteed left < right and
-   top < bottom. The coordinates can be smaller than -1000 or bigger than 1000.
-   But at least one vertex will be within (-1000, -1000) and (1000, 1000).
-
-   'leftEye' is the coordinates of the centre of the left eye. The coordinates
-   are in the same space as the ones for 'bounds'. This is an optional field
-   and may not be supported on all devices. If it is not supported or detected,
-   the value will be set to null. The x and y coordinates are bounded by the
-   range (-1000, 1000) where:
-       { x: -1000, y: -1000 } is the top-left corner
-       { x:  1000, y:  1000 } is the bottom-right corner
-
-   'rightEye' is the coordinates of the detected right eye; null if not
-   supported or detected. Same boundary conditions as 'leftEye'.
-
-   'mouth' is the coordinates of the detected mouth; null if not supported or
-   detected. Same boundary conditions as 'leftEye'.
-*/
-[Pref="camera.control.face_detection.enabled",
- Func="DOMCameraDetectedFace::HasSupport",
- Constructor(optional CameraDetectedFaceInit initDict)]
-interface CameraDetectedFace
-{
-  readonly attribute unsigned long id;
-
-  readonly attribute unsigned long score;
-
-  readonly attribute DOMRect bounds;
-
-  readonly attribute boolean hasLeftEye;
-  readonly attribute DOMPoint? leftEye;
-
-  readonly attribute boolean hasRightEye;
-  readonly attribute DOMPoint? rightEye;
-
-  readonly attribute boolean hasMouth;
-  readonly attribute DOMPoint? mouth;
-};
-
-dictionary CameraDetectedFaceInit
-{
-  unsigned long id = 0;
-  unsigned long score = 100;
-  CameraRegion bounds;
-  boolean hasLeftEye = false;
-  DOMPointInit leftEye;
-  boolean hasRightEye = false;
-  DOMPointInit rightEye;
-  boolean hasMouth = false;
-  DOMPointInit mouth;
-};
-
-partial interface CameraControl
-{
-  /* Starts the face detection. This should be called after the preview is
-     started. The camera will periodically call 'onFacesDetected' with a
-     sequence of zero or one or more detected faces in the preview frame.
-
-     How often the callback is invoked is implementation dependent.
-
-     This method throws an exception if face detection fails to start.
-  */
-  [Throws, Pref="camera.control.face_detection.enabled"]
-  void startFaceDetection();
-
-  /* Stops the face detection.
-
-     This method throws an exception if face detection can't be stopped.
-  */
-  [Throws, Pref="camera.control.face_detection.enabled"]
-  void stopFaceDetection();
-
-  /* CameraFacesDetectedEvent */
-  [Pref="camera.control.face_detection.enabled"]
-  attribute EventHandler    onfacesdetected;
-};
deleted file mode 100644
--- a/dom/webidl/CameraFacesDetectedEvent.webidl
+++ /dev/null
@@ -1,18 +0,0 @@
-/* -*- Mode: IDL; 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/. */
-
-[Pref="camera.control.face_detection.enabled",
- Func="Navigator::HasCameraSupport",
- Constructor(DOMString type, optional CameraFacesDetectedEventInit eventInitDict)]
-interface CameraFacesDetectedEvent : Event
-{
-  [Pure, Cached]
-  readonly attribute sequence<CameraDetectedFace>? faces;
-};
-
-dictionary CameraFacesDetectedEventInit : EventInit
-{
-  sequence<CameraDetectedFace>? faces = null;
-};
deleted file mode 100644
--- a/dom/webidl/CameraManager.webidl
+++ /dev/null
@@ -1,63 +0,0 @@
-/* -*- Mode: IDL; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
-/* vim: set ts=2 et sw=2 tw=80: */
-/* 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/.
- */
-
-enum CameraMode { "unspecified", "picture", "video" };
-
-/* Used for the dimensions of a captured picture,
-   a preview stream, a video capture stream, etc. */
-dictionary CameraSize
-{
-  unsigned long width = 0;
-  unsigned long height = 0;
-};
-
-/* Pre-emptive camera configuration options. If 'mode' is set to "unspecified",
-   the camera will not be configured immediately. If the 'mode' is set to
-   "video" or "picture", then the camera automatically configures itself and
-   will be ready for use upon return.
-
-   The remaining parameters are optional and are considered hints by the
-   camera. The application should use the values returned in the
-   GetCameraCallback configuration because while the camera makes a best effort
-   to adhere to the requested values, it may need to change them to ensure
-   optimal behavior.
-
-   If not specified, 'pictureSize' and 'recorderProfile' default to the best or
-   highest resolutions supported by the camera hardware.
-
-   To determine 'previewSize', one should generally provide the size of the
-   element which will contain the preview rather than guess which supported
-   preview size is the best. If not specified, 'previewSize' defaults to the
-   inner window size. */
-dictionary CameraConfiguration
-{
-  CameraMode mode = "picture";
-  CameraSize previewSize = null;
-  CameraSize pictureSize = null;
-
-  /* one of the profiles reported by
-     CameraControl.capabilities.recorderProfiles
-  */
-  DOMString recorderProfile = "default";
-};
-
-[Func="nsDOMCameraManager::HasSupport"]
-interface CameraManager
-{
-  /* get a camera instance; 'camera' is one of the camera
-     identifiers returned by getListOfCameras() below.
-  */
-  [Throws]
-  Promise<CameraGetPromiseData> getCamera(DOMString camera,
-                                          optional CameraConfiguration initialConfiguration);
-
-  /* return an array of camera identifiers, e.g.
-       [ "front", "back" ]
-   */
-  [Throws]
-  sequence<DOMString> getListOfCameras();
-};
deleted file mode 100644
--- a/dom/webidl/CameraStateChangeEvent.webidl
+++ /dev/null
@@ -1,16 +0,0 @@
-/* -*- Mode: IDL; 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/. */
-
-[Func="Navigator::HasCameraSupport",
- Constructor(DOMString type, optional CameraStateChangeEventInit eventInitDict)]
-interface CameraStateChangeEvent : Event
-{
-  readonly attribute DOMString newState;
-};
-
-dictionary CameraStateChangeEventInit : EventInit
-{
-  DOMString newState = "";
-};
deleted file mode 100644
--- a/dom/webidl/CameraUtil.webidl
+++ /dev/null
@@ -1,12 +0,0 @@
-/* -*- Mode: IDL; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
-/* vim: set ts=2 et sw=2 tw=80: */
-/* 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/.
- */
-
-dictionary CameraGetPromiseData
-{
-  CameraControl? camera = null;
-  CameraConfiguration configuration;
-};
--- a/dom/webidl/Navigator.webidl
+++ b/dom/webidl/Navigator.webidl
@@ -265,22 +265,16 @@ partial interface Navigator {
 #endif
 
 // NetworkInformation
 partial interface Navigator {
   [Throws, Pref="dom.netinfo.enabled"]
   readonly attribute NetworkInformation connection;
 };
 
-// nsIDOMNavigatorCamera
-partial interface Navigator {
-  [Throws, Func="Navigator::HasCameraSupport", UnsafeInPrerendering]
-  readonly attribute CameraManager mozCameras;
-};
-
 #ifdef MOZ_B2G_RIL
 partial interface Navigator {
   [Throws, Pref="dom.mobileconnection.enabled", ChromeOnly, UnsafeInPrerendering]
   readonly attribute MozMobileConnectionArray mozMobileConnections;
 };
 
 partial interface Navigator {
   [Throws, Pref="dom.voicemail.enabled", ChromeOnly,
--- a/dom/webidl/moz.build
+++ b/dom/webidl/moz.build
@@ -59,20 +59,16 @@ WEBIDL_FILES = [
     'BroadcastChannel.webidl',
     'BrowserElement.webidl',
     'BrowserElementAudioChannel.webidl',
     'BrowserElementDictionaries.webidl',
     'BrowserElementProxy.webidl',
     'Cache.webidl',
     'CacheStorage.webidl',
     'CallsList.webidl',
-    'CameraCapabilities.webidl',
-    'CameraControl.webidl',
-    'CameraManager.webidl',
-    'CameraUtil.webidl',
     'CanvasCaptureMediaStream.webidl',
     'CanvasRenderingContext2D.webidl',
     'CaretPosition.webidl',
     'CDATASection.webidl',
     'ChannelMergerNode.webidl',
     'ChannelSplitterNode.webidl',
     'CharacterData.webidl',
     'CheckerboardReportService.webidl',
@@ -765,20 +761,16 @@ else:
 
 GENERATED_EVENTS_WEBIDL_FILES = [
     'AddonEvent.webidl',
     'AnimationPlaybackEvent.webidl',
     'AutocompleteErrorEvent.webidl',
     'BlobEvent.webidl',
     'CallEvent.webidl',
     'CallGroupErrorEvent.webidl',
-    'CameraClosedEvent.webidl',
-    'CameraConfigurationEvent.webidl',
-    'CameraFacesDetectedEvent.webidl',
-    'CameraStateChangeEvent.webidl',
     'CaretStateChangedEvent.webidl',
     'CFStateChangeEvent.webidl',
     'CloseEvent.webidl',
     'DataErrorEvent.webidl',
     'DeviceLightEvent.webidl',
     'DeviceOrientationEvent.webidl',
     'DeviceProximityEvent.webidl',
     'DeviceStorageAreaChangedEvent.webidl',
--- a/layout/build/moz.build
+++ b/layout/build/moz.build
@@ -31,17 +31,16 @@ LOCAL_INCLUDES += [
     '../mathml',
     '../style',
     '../tables',
     '../xul',
     '/caps',
     '/docshell/base',
     '/dom/audiochannel',
     '/dom/base',
-    '/dom/camera',
     '/dom/canvas',
     '/dom/filesystem',
     '/dom/geolocation',
     '/dom/html',
     '/dom/json',
     '/dom/jsurl',
     '/dom/media',
     '/dom/offline',
--- a/layout/build/nsLayoutStatics.cpp
+++ b/layout/build/nsLayoutStatics.cpp
@@ -117,17 +117,16 @@ using namespace mozilla::system;
 #include "nsPermissionManager.h"
 #include "nsCookieService.h"
 #include "nsApplicationCacheService.h"
 #include "mozilla/dom/CustomElementsRegistry.h"
 #include "mozilla/dom/time/DateCacheCleaner.h"
 #include "mozilla/EventDispatcher.h"
 #include "mozilla/IMEStateManager.h"
 #include "mozilla/dom/HTMLVideoElement.h"
-#include "CameraPreferences.h"
 #include "TouchManager.h"
 #include "MediaDecoder.h"
 #include "MediaPrefs.h"
 #include "mozilla/dom/devicestorage/DeviceStorageStatics.h"
 #include "mozilla/ServoBindings.h"
 #include "mozilla/StaticPresData.h"
 #include "mozilla/dom/WebIDLGlobalNameHash.h"
 
@@ -290,18 +289,16 @@ nsLayoutStatics::Initialize()
 #ifdef MOZ_XUL
   nsMenuBarListener::InitializeStatics();
 #endif
 
   CacheObserver::Init();
 
   CounterStyleManager::InitializeBuiltinCounterStyles();
 
-  CameraPreferences::Initialize();
-
   IMEStateManager::Init();
 
   ServiceWorkerRegistrar::Initialize();
 
 #ifdef DEBUG
   nsStyleContext::Initialize();
   mozilla::LayerAnimationInfo::Initialize();
 #endif
@@ -437,16 +434,14 @@ nsLayoutStatics::Shutdown()
   ContentParent::ShutDown();
 
   DisplayItemClip::Shutdown();
 
   CustomElementsRegistry::XPCOMShutdown();
 
   CacheObserver::Shutdown();
 
-  CameraPreferences::Shutdown();
-
   PromiseDebugging::Shutdown();
 
 #ifdef MOZ_B2G_BT
   BluetoothUUID::HandleShutdown();
 #endif
 }
--- a/widget/NativeKeyToDOMKeyName.h
+++ b/widget/NativeKeyToDOMKeyName.h
@@ -1034,17 +1034,16 @@ KEY_MAP_GTK     (BrowserStop, GDK_Stop)
 // Call
 KEY_MAP_ANDROID (Call, AKEYCODE_CALL)
 
 // Camera
 KEY_MAP_ANDROID (Camera, AKEYCODE_CAMERA)
 
 // CameraFocus
 KEY_MAP_ANDROID_EXCEPT_B2G(CameraFocus,       AKEYCODE_FOCUS)
-KEY_MAP_B2G               (CameraFocusAdjust, AKEYCODE_FOCUS)
 
 // GoHome
 KEY_MAP_ANDROID_EXCEPT_B2G(GoHome,     AKEYCODE_HOME)
 KEY_MAP_B2G               (HomeScreen, AKEYCODE_HOME)
 
 /******************************************************************************
  * TV Keys
  ******************************************************************************/
--- a/widget/gonk/nativewindow/GonkNativeWindowJB.h
+++ b/widget/gonk/nativewindow/GonkNativeWindowJB.h
@@ -18,17 +18,16 @@
 #ifndef NATIVEWINDOW_GONKNATIVEWINDOW_JB_H
 #define NATIVEWINDOW_GONKNATIVEWINDOW_JB_H
 
 #include <ui/GraphicBuffer.h>
 #include <utils/String8.h>
 #include <utils/Vector.h>
 #include <utils/threads.h>
 
-#include "CameraCommon.h"
 #include "GonkConsumerBaseJB.h"
 #include "GrallocImages.h"
 #include "mozilla/layers/LayersSurfaces.h"
 
 namespace mozilla {
 namespace layers {
     class PGrallocBufferChild;
 }
--- a/widget/gonk/nativewindow/GonkNativeWindowKK.h
+++ b/widget/gonk/nativewindow/GonkNativeWindowKK.h
@@ -18,17 +18,16 @@
 #ifndef NATIVEWINDOW_GONKNATIVEWINDOW_KK_H
 #define NATIVEWINDOW_GONKNATIVEWINDOW_KK_H
 
 #include <ui/GraphicBuffer.h>
 #include <utils/String8.h>
 #include <utils/Vector.h>
 #include <utils/threads.h>
 
-#include "CameraCommon.h"
 #include "GonkConsumerBaseKK.h"
 #include "GrallocImages.h"
 #include "IGonkGraphicBufferConsumer.h"
 #include "mozilla/layers/ImageBridgeChild.h"
 #include "mozilla/layers/LayersSurfaces.h"
 
 namespace mozilla {
 namespace layers {