dom/camera/DOMCameraControl.cpp
author Carsten "Tomcat" Book <cbook@mozilla.com>
Tue, 20 Oct 2015 12:00:53 +0200
changeset 268496 f7b746b4e91307448cb0746a41f677bfc23908b0
parent 268184 e8c7dfe727cd970e2c3294934e2927b14143c205
child 269187 cfd7882e6f70d4d824e4af91fa3ac0591c884ebb
permissions -rwxr-xr-x
merge mozilla-inbound to mozilla-central a=merge
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
104262
244bba751ce4ae586d66d28c8e9a1f0b41e872c5 Bug 779139 - Make DOM-facing camera objects cycle collection participants. r=jst
Mike Habicher <mikeh@mozilla.com>
parents:
diff changeset
     1
/* This Source Code Form is subject to the terms of the Mozilla Public
244bba751ce4ae586d66d28c8e9a1f0b41e872c5 Bug 779139 - Make DOM-facing camera objects cycle collection participants. r=jst
Mike Habicher <mikeh@mozilla.com>
parents:
diff changeset
     2
 * License, v. 2.0. If a copy of the MPL was not distributed with this file,
244bba751ce4ae586d66d28c8e9a1f0b41e872c5 Bug 779139 - Make DOM-facing camera objects cycle collection participants. r=jst
Mike Habicher <mikeh@mozilla.com>
parents:
diff changeset
     3
 * You can obtain one at http://mozilla.org/MPL/2.0/. */
244bba751ce4ae586d66d28c8e9a1f0b41e872c5 Bug 779139 - Make DOM-facing camera objects cycle collection participants. r=jst
Mike Habicher <mikeh@mozilla.com>
parents:
diff changeset
     4
168993
e93e96ed8a5ad4999e272e2a3180a32e1ffdf94d Bug 909542 - refactor CameraControl API, r=dhylands,jst,jesup,onecyrenus
Mike Habicher <mikeh@mozilla.com>
parents: 168958
diff changeset
     5
#include "DOMCameraControl.h"
104262
244bba751ce4ae586d66d28c8e9a1f0b41e872c5 Bug 779139 - Make DOM-facing camera objects cycle collection participants. r=jst
Mike Habicher <mikeh@mozilla.com>
parents:
diff changeset
     6
#include "base/basictypes.h"
244bba751ce4ae586d66d28c8e9a1f0b41e872c5 Bug 779139 - Make DOM-facing camera objects cycle collection participants. r=jst
Mike Habicher <mikeh@mozilla.com>
parents:
diff changeset
     7
#include "nsCOMPtr.h"
244bba751ce4ae586d66d28c8e9a1f0b41e872c5 Bug 779139 - Make DOM-facing camera objects cycle collection participants. r=jst
Mike Habicher <mikeh@mozilla.com>
parents:
diff changeset
     8
#include "nsDOMClassInfo.h"
152317
8f125ace663169b472dfb6f64fe3e0cdef963109 Bug 926289 - Part 3, Carry recording type and request URL in recording-device-events in Camera API. r=mikeh.
Shih-Chiang Chien <schien@mozilla.com>
parents: 151619
diff changeset
     9
#include "nsHashPropertyBag.h"
104262
244bba751ce4ae586d66d28c8e9a1f0b41e872c5 Bug 779139 - Make DOM-facing camera objects cycle collection participants. r=jst
Mike Habicher <mikeh@mozilla.com>
parents:
diff changeset
    10
#include "nsThread.h"
144403
614052b6cbcc905dc1e07cb1f40b02c668da7cb5 bug 899210 - convert camera control to WebIDL r=bz
Trevor Saunders <trev.saunders@gmail.com>
parents: 141384
diff changeset
    11
#include "DeviceStorage.h"
164521
2b74b0de04a4c7244ea1b53afe92bbb269a3b59c Bug 910498 - Camera changes to use CreateFd. r=mikeh
Dave Hylands <dhylands@mozilla.com>
parents: 164063
diff changeset
    12
#include "DeviceStorageFileDescriptor.h"
209366
c0ce357af3dbadb845c18bd79c68dcfba84ee93f Bug 1047483 - patch 3 - Renaming DOMFile to File, r=ehsan
Andrea Marchesini <amarchesini@mozilla.com>
parents: 209364
diff changeset
    13
#include "mozilla/dom/File.h"
152317
8f125ace663169b472dfb6f64fe3e0cdef963109 Bug 926289 - Part 3, Carry recording type and request URL in recording-device-events in Camera API. r=mikeh.
Shih-Chiang Chien <schien@mozilla.com>
parents: 151619
diff changeset
    14
#include "mozilla/dom/TabChild.h"
172425
f8bf9630b972b5cf8e7631a142e83ad4cb3e6d69 Bug 977372 - Close IPC'd filedescriptor from device descriptor when finished with it. r=mikeh
Dave Hylands <dhylands@mozilla.com>
parents: 172215
diff changeset
    15
#include "mozilla/ipc/FileDescriptorUtils.h"
158599
f6675487604f2460f3bba2a7d01bd6308483f4ea Bug 940045 - Part 3: Send requestURL from content process. r=mikeh
Shih-Chiang Chien <schien@mozilla.com>
parents: 152770
diff changeset
    16
#include "mozilla/MediaManager.h"
104262
244bba751ce4ae586d66d28c8e9a1f0b41e872c5 Bug 779139 - Make DOM-facing camera objects cycle collection participants. r=jst
Mike Habicher <mikeh@mozilla.com>
parents:
diff changeset
    17
#include "mozilla/Services.h"
119845
ef08d673ef2068d76fe0a1c0174bda639c3f63f5 Bug 833521 - forward "recording-device-events" event to parent process, r=dougt
Sotaro Ikeda <sikeda@mozilla.com>
parents: 119791
diff changeset
    18
#include "mozilla/unused.h"
152317
8f125ace663169b472dfb6f64fe3e0cdef963109 Bug 926289 - Part 3, Carry recording type and request URL in recording-device-events in Camera API. r=mikeh.
Shih-Chiang Chien <schien@mozilla.com>
parents: 151619
diff changeset
    19
#include "nsIAppsService.h"
104262
244bba751ce4ae586d66d28c8e9a1f0b41e872c5 Bug 779139 - Make DOM-facing camera objects cycle collection participants. r=jst
Mike Habicher <mikeh@mozilla.com>
parents:
diff changeset
    20
#include "nsIObserverService.h"
168993
e93e96ed8a5ad4999e272e2a3180a32e1ffdf94d Bug 909542 - refactor CameraControl API, r=dhylands,jst,jesup,onecyrenus
Mike Habicher <mikeh@mozilla.com>
parents: 168958
diff changeset
    21
#include "nsIDOMEventListener.h"
152317
8f125ace663169b472dfb6f64fe3e0cdef963109 Bug 926289 - Part 3, Carry recording type and request URL in recording-device-events in Camera API. r=mikeh.
Shih-Chiang Chien <schien@mozilla.com>
parents: 151619
diff changeset
    22
#include "nsIScriptSecurityManager.h"
177875
72a05425a854e7b482b61101a52ed3cb8551eb8f Bug 983180 - hide camera objects behind Navigator::HasCameraSupport(), r=bz
Mike Habicher <mikeh@mozilla.com>
parents: 177874
diff changeset
    23
#include "Navigator.h"
119845
ef08d673ef2068d76fe0a1c0174bda639c3f63f5 Bug 833521 - forward "recording-device-events" event to parent process, r=dougt
Sotaro Ikeda <sikeda@mozilla.com>
parents: 119791
diff changeset
    24
#include "nsXULAppAPI.h"
104262
244bba751ce4ae586d66d28c8e9a1f0b41e872c5 Bug 779139 - Make DOM-facing camera objects cycle collection participants. r=jst
Mike Habicher <mikeh@mozilla.com>
parents:
diff changeset
    25
#include "DOMCameraManager.h"
244bba751ce4ae586d66d28c8e9a1f0b41e872c5 Bug 779139 - Make DOM-facing camera objects cycle collection participants. r=jst
Mike Habicher <mikeh@mozilla.com>
parents:
diff changeset
    26
#include "DOMCameraCapabilities.h"
244bba751ce4ae586d66d28c8e9a1f0b41e872c5 Bug 779139 - Make DOM-facing camera objects cycle collection participants. r=jst
Mike Habicher <mikeh@mozilla.com>
parents:
diff changeset
    27
#include "CameraCommon.h"
168993
e93e96ed8a5ad4999e272e2a3180a32e1ffdf94d Bug 909542 - refactor CameraControl API, r=dhylands,jst,jesup,onecyrenus
Mike Habicher <mikeh@mozilla.com>
parents: 168958
diff changeset
    28
#include "nsGlobalWindow.h"
e93e96ed8a5ad4999e272e2a3180a32e1ffdf94d Bug 909542 - refactor CameraControl API, r=dhylands,jst,jesup,onecyrenus
Mike Habicher <mikeh@mozilla.com>
parents: 168958
diff changeset
    29
#include "CameraPreviewMediaStream.h"
208669
05df8323b82079743e8af61b83625739bbadf905 Bug 994912 - Add support for promises and event-based notifications to camera. r=mikeh, r=bz
Andrew Osmond <aosmond@mozilla.com>
parents: 207338
diff changeset
    30
#include "mozilla/dom/CameraUtilBinding.h"
168993
e93e96ed8a5ad4999e272e2a3180a32e1ffdf94d Bug 909542 - refactor CameraControl API, r=dhylands,jst,jesup,onecyrenus
Mike Habicher <mikeh@mozilla.com>
parents: 168958
diff changeset
    31
#include "mozilla/dom/CameraControlBinding.h"
132297
9fcdf0c1c59816aefd92fa9381da07a621d0ba37 Bug 868312 finale: finish rooting dom/ code. r=smaug
Boris Zbarsky <bzbarsky@mit.edu>
parents: 132114
diff changeset
    32
#include "mozilla/dom/CameraManagerBinding.h"
168993
e93e96ed8a5ad4999e272e2a3180a32e1ffdf94d Bug 909542 - refactor CameraControl API, r=dhylands,jst,jesup,onecyrenus
Mike Habicher <mikeh@mozilla.com>
parents: 168958
diff changeset
    33
#include "mozilla/dom/CameraCapabilitiesBinding.h"
208669
05df8323b82079743e8af61b83625739bbadf905 Bug 994912 - Add support for promises and event-based notifications to camera. r=mikeh, r=bz
Andrew Osmond <aosmond@mozilla.com>
parents: 207338
diff changeset
    34
#include "mozilla/dom/CameraConfigurationEvent.h"
05df8323b82079743e8af61b83625739bbadf905 Bug 994912 - Add support for promises and event-based notifications to camera. r=mikeh, r=bz
Andrew Osmond <aosmond@mozilla.com>
parents: 207338
diff changeset
    35
#include "mozilla/dom/CameraConfigurationEventBinding.h"
05df8323b82079743e8af61b83625739bbadf905 Bug 994912 - Add support for promises and event-based notifications to camera. r=mikeh, r=bz
Andrew Osmond <aosmond@mozilla.com>
parents: 207338
diff changeset
    36
#include "mozilla/dom/CameraFacesDetectedEvent.h"
05df8323b82079743e8af61b83625739bbadf905 Bug 994912 - Add support for promises and event-based notifications to camera. r=mikeh, r=bz
Andrew Osmond <aosmond@mozilla.com>
parents: 207338
diff changeset
    37
#include "mozilla/dom/CameraFacesDetectedEventBinding.h"
05df8323b82079743e8af61b83625739bbadf905 Bug 994912 - Add support for promises and event-based notifications to camera. r=mikeh, r=bz
Andrew Osmond <aosmond@mozilla.com>
parents: 207338
diff changeset
    38
#include "mozilla/dom/CameraStateChangeEvent.h"
217490
63b54f5f6877f71d1549c5436691ec25e6ce2a8e Bug 1099390 - add reason to onClosed event, r=aosmond,bz
Mike Habicher <mikeh@mozilla.com>
parents: 215389
diff changeset
    39
#include "mozilla/dom/CameraClosedEvent.h"
208669
05df8323b82079743e8af61b83625739bbadf905 Bug 994912 - Add support for promises and event-based notifications to camera. r=mikeh, r=bz
Andrew Osmond <aosmond@mozilla.com>
parents: 207338
diff changeset
    40
#include "mozilla/dom/BlobEvent.h"
177874
e6ac52f874d097648fcf91fd2db247af3a297d6b Bug 965420 - camera face-tracking, r=bz,dhylands
Mike Habicher <mikeh@mozilla.com>
parents: 177873
diff changeset
    41
#include "DOMCameraDetectedFace.h"
132297
9fcdf0c1c59816aefd92fa9381da07a621d0ba37 Bug 868312 finale: finish rooting dom/ code. r=smaug
Boris Zbarsky <bzbarsky@mit.edu>
parents: 132114
diff changeset
    42
#include "mozilla/dom/BindingUtils.h"
180888
c26966635e9c0c028e4360f2175563f9ef62df80 Bug 985496 - rationalize camera error reporting, r=dhylands
Mike Habicher <mikeh@mozilla.com>
parents: 180485
diff changeset
    43
#include "nsPrintfCString.h"
104262
244bba751ce4ae586d66d28c8e9a1f0b41e872c5 Bug 779139 - Make DOM-facing camera objects cycle collection participants. r=jst
Mike Habicher <mikeh@mozilla.com>
parents:
diff changeset
    44
244bba751ce4ae586d66d28c8e9a1f0b41e872c5 Bug 779139 - Make DOM-facing camera objects cycle collection participants. r=jst
Mike Habicher <mikeh@mozilla.com>
parents:
diff changeset
    45
using namespace mozilla;
132297
9fcdf0c1c59816aefd92fa9381da07a621d0ba37 Bug 868312 finale: finish rooting dom/ code. r=smaug
Boris Zbarsky <bzbarsky@mit.edu>
parents: 132114
diff changeset
    46
using namespace mozilla::dom;
172425
f8bf9630b972b5cf8e7631a142e83ad4cb3e6d69 Bug 977372 - Close IPC'd filedescriptor from device descriptor when finished with it. r=mikeh
Dave Hylands <dhylands@mozilla.com>
parents: 172215
diff changeset
    47
using namespace mozilla::ipc;
104262
244bba751ce4ae586d66d28c8e9a1f0b41e872c5 Bug 779139 - Make DOM-facing camera objects cycle collection participants. r=jst
Mike Habicher <mikeh@mozilla.com>
parents:
diff changeset
    48
214202
036de9b00df6162467e598260eef951f18f37014 Bug 1090501 - pre-emptively open the camera hardware for certified apps with 'camera' permission, r=fabrice
Fabrice Desre <fabrice@mozilla.com>
parents: 213736
diff changeset
    49
#ifdef MOZ_WIDGET_GONK
036de9b00df6162467e598260eef951f18f37014 Bug 1090501 - pre-emptively open the camera hardware for certified apps with 'camera' permission, r=fabrice
Fabrice Desre <fabrice@mozilla.com>
parents: 213736
diff changeset
    50
StaticRefPtr<ICameraControl> nsDOMCameraControl::sCachedCameraControl;
036de9b00df6162467e598260eef951f18f37014 Bug 1090501 - pre-emptively open the camera hardware for certified apps with 'camera' permission, r=fabrice
Fabrice Desre <fabrice@mozilla.com>
parents: 213736
diff changeset
    51
/* static */ nsresult nsDOMCameraControl::sCachedCameraControlStartResult = NS_OK;
036de9b00df6162467e598260eef951f18f37014 Bug 1090501 - pre-emptively open the camera hardware for certified apps with 'camera' permission, r=fabrice
Fabrice Desre <fabrice@mozilla.com>
parents: 213736
diff changeset
    52
/* static */ nsCOMPtr<nsITimer> nsDOMCameraControl::sDiscardCachedCameraControlTimer;
036de9b00df6162467e598260eef951f18f37014 Bug 1090501 - pre-emptively open the camera hardware for certified apps with 'camera' permission, r=fabrice
Fabrice Desre <fabrice@mozilla.com>
parents: 213736
diff changeset
    53
#endif
036de9b00df6162467e598260eef951f18f37014 Bug 1090501 - pre-emptively open the camera hardware for certified apps with 'camera' permission, r=fabrice
Fabrice Desre <fabrice@mozilla.com>
parents: 213736
diff changeset
    54
168993
e93e96ed8a5ad4999e272e2a3180a32e1ffdf94d Bug 909542 - refactor CameraControl API, r=dhylands,jst,jesup,onecyrenus
Mike Habicher <mikeh@mozilla.com>
parents: 168958
diff changeset
    55
NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION_INHERITED(nsDOMCameraControl)
219510
220f9cd8097a7d7b395ab0419c6aa62ae25f7058 Bug 1104055 - fix CameraControl memory leak, r=aosmond
Mike Habicher <mikeh@mozilla.com>
parents: 219181
diff changeset
    56
  NS_INTERFACE_MAP_ENTRY(nsISupportsWeakReference)
220f9cd8097a7d7b395ab0419c6aa62ae25f7058 Bug 1104055 - fix CameraControl memory leak, r=aosmond
Mike Habicher <mikeh@mozilla.com>
parents: 219181
diff changeset
    57
  // nsISupports is an ambiguous base of nsDOMCameraControl
220f9cd8097a7d7b395ab0419c6aa62ae25f7058 Bug 1104055 - fix CameraControl memory leak, r=aosmond
Mike Habicher <mikeh@mozilla.com>
parents: 219181
diff changeset
    58
  // so we have to work around that.
220f9cd8097a7d7b395ab0419c6aa62ae25f7058 Bug 1104055 - fix CameraControl memory leak, r=aosmond
Mike Habicher <mikeh@mozilla.com>
parents: 219181
diff changeset
    59
  if ( aIID.Equals(NS_GET_IID(nsDOMCameraControl)) )
220f9cd8097a7d7b395ab0419c6aa62ae25f7058 Bug 1104055 - fix CameraControl memory leak, r=aosmond
Mike Habicher <mikeh@mozilla.com>
parents: 219181
diff changeset
    60
    foundInterface = static_cast<nsISupports*>(static_cast<void*>(this));
220f9cd8097a7d7b395ab0419c6aa62ae25f7058 Bug 1104055 - fix CameraControl memory leak, r=aosmond
Mike Habicher <mikeh@mozilla.com>
parents: 219181
diff changeset
    61
  else
168993
e93e96ed8a5ad4999e272e2a3180a32e1ffdf94d Bug 909542 - refactor CameraControl API, r=dhylands,jst,jesup,onecyrenus
Mike Habicher <mikeh@mozilla.com>
parents: 168958
diff changeset
    62
NS_INTERFACE_MAP_END_INHERITING(DOMMediaStream)
e93e96ed8a5ad4999e272e2a3180a32e1ffdf94d Bug 909542 - refactor CameraControl API, r=dhylands,jst,jesup,onecyrenus
Mike Habicher <mikeh@mozilla.com>
parents: 168958
diff changeset
    63
e93e96ed8a5ad4999e272e2a3180a32e1ffdf94d Bug 909542 - refactor CameraControl API, r=dhylands,jst,jesup,onecyrenus
Mike Habicher <mikeh@mozilla.com>
parents: 168958
diff changeset
    64
NS_IMPL_ADDREF_INHERITED(nsDOMCameraControl, DOMMediaStream)
e93e96ed8a5ad4999e272e2a3180a32e1ffdf94d Bug 909542 - refactor CameraControl API, r=dhylands,jst,jesup,onecyrenus
Mike Habicher <mikeh@mozilla.com>
parents: 168958
diff changeset
    65
NS_IMPL_RELEASE_INHERITED(nsDOMCameraControl, DOMMediaStream)
e93e96ed8a5ad4999e272e2a3180a32e1ffdf94d Bug 909542 - refactor CameraControl API, r=dhylands,jst,jesup,onecyrenus
Mike Habicher <mikeh@mozilla.com>
parents: 168958
diff changeset
    66
180435
a9a093d2881a59be843a506b15ee6841facddae3 Bug 900903 - Part 2: Change uses of numbered macros in nsCycleCollectionParticipant.h to the variadic variants. r=smaug
Birunthan Mohanathas <birunthan@mohanathas.com>
parents: 178627
diff changeset
    67
NS_IMPL_CYCLE_COLLECTION_INHERITED(nsDOMCameraControl, DOMMediaStream,
219510
220f9cd8097a7d7b395ab0419c6aa62ae25f7058 Bug 1104055 - fix CameraControl memory leak, r=aosmond
Mike Habicher <mikeh@mozilla.com>
parents: 219181
diff changeset
    68
                                   mAudioChannelAgent,
180435
a9a093d2881a59be843a506b15ee6841facddae3 Bug 900903 - Part 2: Change uses of numbered macros in nsCycleCollectionParticipant.h to the variadic variants. r=smaug
Birunthan Mohanathas <birunthan@mohanathas.com>
parents: 178627
diff changeset
    69
                                   mCapabilities,
a9a093d2881a59be843a506b15ee6841facddae3 Bug 900903 - Part 2: Change uses of numbered macros in nsCycleCollectionParticipant.h to the variadic variants. r=smaug
Birunthan Mohanathas <birunthan@mohanathas.com>
parents: 178627
diff changeset
    70
                                   mWindow,
208669
05df8323b82079743e8af61b83625739bbadf905 Bug 994912 - Add support for promises and event-based notifications to camera. r=mikeh, r=bz
Andrew Osmond <aosmond@mozilla.com>
parents: 207338
diff changeset
    71
                                   mGetCameraPromise,
05df8323b82079743e8af61b83625739bbadf905 Bug 994912 - Add support for promises and event-based notifications to camera. r=mikeh, r=bz
Andrew Osmond <aosmond@mozilla.com>
parents: 207338
diff changeset
    72
                                   mAutoFocusPromise,
05df8323b82079743e8af61b83625739bbadf905 Bug 994912 - Add support for promises and event-based notifications to camera. r=mikeh, r=bz
Andrew Osmond <aosmond@mozilla.com>
parents: 207338
diff changeset
    73
                                   mTakePicturePromise,
05df8323b82079743e8af61b83625739bbadf905 Bug 994912 - Add support for promises and event-based notifications to camera. r=mikeh, r=bz
Andrew Osmond <aosmond@mozilla.com>
parents: 207338
diff changeset
    74
                                   mStartRecordingPromise,
05df8323b82079743e8af61b83625739bbadf905 Bug 994912 - Add support for promises and event-based notifications to camera. r=mikeh, r=bz
Andrew Osmond <aosmond@mozilla.com>
parents: 207338
diff changeset
    75
                                   mReleasePromise,
219181
12c5cc6e88b326e2e4006fc6573bf01e0fea54c2 Bug 1107683 - remove method callbacks from CameraControl, r=aosmond,bz
Mike Habicher <mikeh@mozilla.com>
parents: 217721
diff changeset
    76
                                   mSetConfigurationPromise)
168993
e93e96ed8a5ad4999e272e2a3180a32e1ffdf94d Bug 909542 - refactor CameraControl API, r=dhylands,jst,jesup,onecyrenus
Mike Habicher <mikeh@mozilla.com>
parents: 168958
diff changeset
    77
177875
72a05425a854e7b482b61101a52ed3cb8551eb8f Bug 983180 - hide camera objects behind Navigator::HasCameraSupport(), r=bz
Mike Habicher <mikeh@mozilla.com>
parents: 177874
diff changeset
    78
/* static */
72a05425a854e7b482b61101a52ed3cb8551eb8f Bug 983180 - hide camera objects behind Navigator::HasCameraSupport(), r=bz
Mike Habicher <mikeh@mozilla.com>
parents: 177874
diff changeset
    79
bool
72a05425a854e7b482b61101a52ed3cb8551eb8f Bug 983180 - hide camera objects behind Navigator::HasCameraSupport(), r=bz
Mike Habicher <mikeh@mozilla.com>
parents: 177874
diff changeset
    80
nsDOMCameraControl::HasSupport(JSContext* aCx, JSObject* aGlobal)
72a05425a854e7b482b61101a52ed3cb8551eb8f Bug 983180 - hide camera objects behind Navigator::HasCameraSupport(), r=bz
Mike Habicher <mikeh@mozilla.com>
parents: 177874
diff changeset
    81
{
72a05425a854e7b482b61101a52ed3cb8551eb8f Bug 983180 - hide camera objects behind Navigator::HasCameraSupport(), r=bz
Mike Habicher <mikeh@mozilla.com>
parents: 177874
diff changeset
    82
  return Navigator::HasCameraSupport(aCx, aGlobal);
72a05425a854e7b482b61101a52ed3cb8551eb8f Bug 983180 - hide camera objects behind Navigator::HasCameraSupport(), r=bz
Mike Habicher <mikeh@mozilla.com>
parents: 177874
diff changeset
    83
}
72a05425a854e7b482b61101a52ed3cb8551eb8f Bug 983180 - hide camera objects behind Navigator::HasCameraSupport(), r=bz
Mike Habicher <mikeh@mozilla.com>
parents: 177874
diff changeset
    84
249644
e3b6829af1896d0010bf09db32c4f10f6e186479 Bug 1175656 - Implement generation of recording posters in Gecko. r=dhylands,bz
Andrew Osmond <aosmond@mozilla.com>
parents: 249622
diff changeset
    85
static nsresult
e3b6829af1896d0010bf09db32c4f10f6e186479 Bug 1175656 - Implement generation of recording posters in Gecko. r=dhylands,bz
Andrew Osmond <aosmond@mozilla.com>
parents: 249622
diff changeset
    86
RegisterStorageRequestEvents(DOMRequest* aRequest, nsIDOMEventListener* aListener)
e3b6829af1896d0010bf09db32c4f10f6e186479 Bug 1175656 - Implement generation of recording posters in Gecko. r=dhylands,bz
Andrew Osmond <aosmond@mozilla.com>
parents: 249622
diff changeset
    87
{
e3b6829af1896d0010bf09db32c4f10f6e186479 Bug 1175656 - Implement generation of recording posters in Gecko. r=dhylands,bz
Andrew Osmond <aosmond@mozilla.com>
parents: 249622
diff changeset
    88
  EventListenerManager* elm = aRequest->GetOrCreateListenerManager();
e3b6829af1896d0010bf09db32c4f10f6e186479 Bug 1175656 - Implement generation of recording posters in Gecko. r=dhylands,bz
Andrew Osmond <aosmond@mozilla.com>
parents: 249622
diff changeset
    89
  if (NS_WARN_IF(!elm)) {
e3b6829af1896d0010bf09db32c4f10f6e186479 Bug 1175656 - Implement generation of recording posters in Gecko. r=dhylands,bz
Andrew Osmond <aosmond@mozilla.com>
parents: 249622
diff changeset
    90
    return NS_ERROR_UNEXPECTED;
e3b6829af1896d0010bf09db32c4f10f6e186479 Bug 1175656 - Implement generation of recording posters in Gecko. r=dhylands,bz
Andrew Osmond <aosmond@mozilla.com>
parents: 249622
diff changeset
    91
  }
e3b6829af1896d0010bf09db32c4f10f6e186479 Bug 1175656 - Implement generation of recording posters in Gecko. r=dhylands,bz
Andrew Osmond <aosmond@mozilla.com>
parents: 249622
diff changeset
    92
e3b6829af1896d0010bf09db32c4f10f6e186479 Bug 1175656 - Implement generation of recording posters in Gecko. r=dhylands,bz
Andrew Osmond <aosmond@mozilla.com>
parents: 249622
diff changeset
    93
  elm->AddEventListener(NS_LITERAL_STRING("success"), aListener, false, false);
e3b6829af1896d0010bf09db32c4f10f6e186479 Bug 1175656 - Implement generation of recording posters in Gecko. r=dhylands,bz
Andrew Osmond <aosmond@mozilla.com>
parents: 249622
diff changeset
    94
  elm->AddEventListener(NS_LITERAL_STRING("error"), aListener, false, false);
e3b6829af1896d0010bf09db32c4f10f6e186479 Bug 1175656 - Implement generation of recording posters in Gecko. r=dhylands,bz
Andrew Osmond <aosmond@mozilla.com>
parents: 249622
diff changeset
    95
  return NS_OK;
e3b6829af1896d0010bf09db32c4f10f6e186479 Bug 1175656 - Implement generation of recording posters in Gecko. r=dhylands,bz
Andrew Osmond <aosmond@mozilla.com>
parents: 249622
diff changeset
    96
}
e3b6829af1896d0010bf09db32c4f10f6e186479 Bug 1175656 - Implement generation of recording posters in Gecko. r=dhylands,bz
Andrew Osmond <aosmond@mozilla.com>
parents: 249622
diff changeset
    97
168993
e93e96ed8a5ad4999e272e2a3180a32e1ffdf94d Bug 909542 - refactor CameraControl API, r=dhylands,jst,jesup,onecyrenus
Mike Habicher <mikeh@mozilla.com>
parents: 168958
diff changeset
    98
class mozilla::StartRecordingHelper : public nsIDOMEventListener
e93e96ed8a5ad4999e272e2a3180a32e1ffdf94d Bug 909542 - refactor CameraControl API, r=dhylands,jst,jesup,onecyrenus
Mike Habicher <mikeh@mozilla.com>
parents: 168958
diff changeset
    99
{
e93e96ed8a5ad4999e272e2a3180a32e1ffdf94d Bug 909542 - refactor CameraControl API, r=dhylands,jst,jesup,onecyrenus
Mike Habicher <mikeh@mozilla.com>
parents: 168958
diff changeset
   100
public:
e93e96ed8a5ad4999e272e2a3180a32e1ffdf94d Bug 909542 - refactor CameraControl API, r=dhylands,jst,jesup,onecyrenus
Mike Habicher <mikeh@mozilla.com>
parents: 168958
diff changeset
   101
  NS_DECL_ISUPPORTS
e93e96ed8a5ad4999e272e2a3180a32e1ffdf94d Bug 909542 - refactor CameraControl API, r=dhylands,jst,jesup,onecyrenus
Mike Habicher <mikeh@mozilla.com>
parents: 168958
diff changeset
   102
  NS_DECL_NSIDOMEVENTLISTENER
e93e96ed8a5ad4999e272e2a3180a32e1ffdf94d Bug 909542 - refactor CameraControl API, r=dhylands,jst,jesup,onecyrenus
Mike Habicher <mikeh@mozilla.com>
parents: 168958
diff changeset
   103
203085
ce5ae34c751b99d0cb3eb2eeb21cc1d5a72429e5 Bug 1061023 - Fix more bad implicit constructors in DOM; r=baku
Ehsan Akhgari <ehsan@mozilla.com>
parents: 201444
diff changeset
   104
  explicit StartRecordingHelper(nsDOMCameraControl* aDOMCameraControl)
168993
e93e96ed8a5ad4999e272e2a3180a32e1ffdf94d Bug 909542 - refactor CameraControl API, r=dhylands,jst,jesup,onecyrenus
Mike Habicher <mikeh@mozilla.com>
parents: 168958
diff changeset
   105
    : mDOMCameraControl(aDOMCameraControl)
249644
e3b6829af1896d0010bf09db32c4f10f6e186479 Bug 1175656 - Implement generation of recording posters in Gecko. r=dhylands,bz
Andrew Osmond <aosmond@mozilla.com>
parents: 249622
diff changeset
   106
    , mState(false)
168993
e93e96ed8a5ad4999e272e2a3180a32e1ffdf94d Bug 909542 - refactor CameraControl API, r=dhylands,jst,jesup,onecyrenus
Mike Habicher <mikeh@mozilla.com>
parents: 168958
diff changeset
   107
  {
e93e96ed8a5ad4999e272e2a3180a32e1ffdf94d Bug 909542 - refactor CameraControl API, r=dhylands,jst,jesup,onecyrenus
Mike Habicher <mikeh@mozilla.com>
parents: 168958
diff changeset
   108
    MOZ_COUNT_CTOR(StartRecordingHelper);
e93e96ed8a5ad4999e272e2a3180a32e1ffdf94d Bug 909542 - refactor CameraControl API, r=dhylands,jst,jesup,onecyrenus
Mike Habicher <mikeh@mozilla.com>
parents: 168958
diff changeset
   109
  }
e93e96ed8a5ad4999e272e2a3180a32e1ffdf94d Bug 909542 - refactor CameraControl API, r=dhylands,jst,jesup,onecyrenus
Mike Habicher <mikeh@mozilla.com>
parents: 168958
diff changeset
   110
e93e96ed8a5ad4999e272e2a3180a32e1ffdf94d Bug 909542 - refactor CameraControl API, r=dhylands,jst,jesup,onecyrenus
Mike Habicher <mikeh@mozilla.com>
parents: 168958
diff changeset
   111
protected:
e93e96ed8a5ad4999e272e2a3180a32e1ffdf94d Bug 909542 - refactor CameraControl API, r=dhylands,jst,jesup,onecyrenus
Mike Habicher <mikeh@mozilla.com>
parents: 168958
diff changeset
   112
  virtual ~StartRecordingHelper()
e93e96ed8a5ad4999e272e2a3180a32e1ffdf94d Bug 909542 - refactor CameraControl API, r=dhylands,jst,jesup,onecyrenus
Mike Habicher <mikeh@mozilla.com>
parents: 168958
diff changeset
   113
  {
e93e96ed8a5ad4999e272e2a3180a32e1ffdf94d Bug 909542 - refactor CameraControl API, r=dhylands,jst,jesup,onecyrenus
Mike Habicher <mikeh@mozilla.com>
parents: 168958
diff changeset
   114
    MOZ_COUNT_DTOR(StartRecordingHelper);
249644
e3b6829af1896d0010bf09db32c4f10f6e186479 Bug 1175656 - Implement generation of recording posters in Gecko. r=dhylands,bz
Andrew Osmond <aosmond@mozilla.com>
parents: 249622
diff changeset
   115
    mDOMCameraControl->OnCreatedFileDescriptor(mState);
168993
e93e96ed8a5ad4999e272e2a3180a32e1ffdf94d Bug 909542 - refactor CameraControl API, r=dhylands,jst,jesup,onecyrenus
Mike Habicher <mikeh@mozilla.com>
parents: 168958
diff changeset
   116
  }
e93e96ed8a5ad4999e272e2a3180a32e1ffdf94d Bug 909542 - refactor CameraControl API, r=dhylands,jst,jesup,onecyrenus
Mike Habicher <mikeh@mozilla.com>
parents: 168958
diff changeset
   117
e93e96ed8a5ad4999e272e2a3180a32e1ffdf94d Bug 909542 - refactor CameraControl API, r=dhylands,jst,jesup,onecyrenus
Mike Habicher <mikeh@mozilla.com>
parents: 168958
diff changeset
   118
protected:
268184
e8c7dfe727cd970e2c3294934e2927b14143c205 Bug 1207245 - part 6 - rename nsRefPtr<T> to RefPtr<T>; r=ehsan; a=Tomcat
Nathan Froyd <froydnj@mozilla.com>
parents: 266718
diff changeset
   119
  RefPtr<nsDOMCameraControl> mDOMCameraControl;
249644
e3b6829af1896d0010bf09db32c4f10f6e186479 Bug 1175656 - Implement generation of recording posters in Gecko. r=dhylands,bz
Andrew Osmond <aosmond@mozilla.com>
parents: 249622
diff changeset
   120
  bool mState;
168993
e93e96ed8a5ad4999e272e2a3180a32e1ffdf94d Bug 909542 - refactor CameraControl API, r=dhylands,jst,jesup,onecyrenus
Mike Habicher <mikeh@mozilla.com>
parents: 168958
diff changeset
   121
};
e93e96ed8a5ad4999e272e2a3180a32e1ffdf94d Bug 909542 - refactor CameraControl API, r=dhylands,jst,jesup,onecyrenus
Mike Habicher <mikeh@mozilla.com>
parents: 168958
diff changeset
   122
e93e96ed8a5ad4999e272e2a3180a32e1ffdf94d Bug 909542 - refactor CameraControl API, r=dhylands,jst,jesup,onecyrenus
Mike Habicher <mikeh@mozilla.com>
parents: 168958
diff changeset
   123
NS_IMETHODIMP
e93e96ed8a5ad4999e272e2a3180a32e1ffdf94d Bug 909542 - refactor CameraControl API, r=dhylands,jst,jesup,onecyrenus
Mike Habicher <mikeh@mozilla.com>
parents: 168958
diff changeset
   124
StartRecordingHelper::HandleEvent(nsIDOMEvent* aEvent)
e93e96ed8a5ad4999e272e2a3180a32e1ffdf94d Bug 909542 - refactor CameraControl API, r=dhylands,jst,jesup,onecyrenus
Mike Habicher <mikeh@mozilla.com>
parents: 168958
diff changeset
   125
{
e93e96ed8a5ad4999e272e2a3180a32e1ffdf94d Bug 909542 - refactor CameraControl API, r=dhylands,jst,jesup,onecyrenus
Mike Habicher <mikeh@mozilla.com>
parents: 168958
diff changeset
   126
  nsString eventType;
e93e96ed8a5ad4999e272e2a3180a32e1ffdf94d Bug 909542 - refactor CameraControl API, r=dhylands,jst,jesup,onecyrenus
Mike Habicher <mikeh@mozilla.com>
parents: 168958
diff changeset
   127
  aEvent->GetType(eventType);
249644
e3b6829af1896d0010bf09db32c4f10f6e186479 Bug 1175656 - Implement generation of recording posters in Gecko. r=dhylands,bz
Andrew Osmond <aosmond@mozilla.com>
parents: 249622
diff changeset
   128
  mState = eventType.EqualsLiteral("success");
168993
e93e96ed8a5ad4999e272e2a3180a32e1ffdf94d Bug 909542 - refactor CameraControl API, r=dhylands,jst,jesup,onecyrenus
Mike Habicher <mikeh@mozilla.com>
parents: 168958
diff changeset
   129
  return NS_OK;
e93e96ed8a5ad4999e272e2a3180a32e1ffdf94d Bug 909542 - refactor CameraControl API, r=dhylands,jst,jesup,onecyrenus
Mike Habicher <mikeh@mozilla.com>
parents: 168958
diff changeset
   130
}
e93e96ed8a5ad4999e272e2a3180a32e1ffdf94d Bug 909542 - refactor CameraControl API, r=dhylands,jst,jesup,onecyrenus
Mike Habicher <mikeh@mozilla.com>
parents: 168958
diff changeset
   131
180485
6c1c7e45c90289a0875b74f82f39e7ecf6a65af3 Bug 900908 - Part 3: Change uses of numbered macros in nsIClassInfoImpl.h/nsISupportsImpl.h to the variadic variants. r=froydnj
Birunthan Mohanathas <birunthan@mohanathas.com>
parents: 180452
diff changeset
   132
NS_IMPL_ISUPPORTS(mozilla::StartRecordingHelper, nsIDOMEventListener)
104262
244bba751ce4ae586d66d28c8e9a1f0b41e872c5 Bug 779139 - Make DOM-facing camera objects cycle collection participants. r=jst
Mike Habicher <mikeh@mozilla.com>
parents:
diff changeset
   133
168993
e93e96ed8a5ad4999e272e2a3180a32e1ffdf94d Bug 909542 - refactor CameraControl API, r=dhylands,jst,jesup,onecyrenus
Mike Habicher <mikeh@mozilla.com>
parents: 168958
diff changeset
   134
nsDOMCameraControl::DOMCameraConfiguration::DOMCameraConfiguration()
e93e96ed8a5ad4999e272e2a3180a32e1ffdf94d Bug 909542 - refactor CameraControl API, r=dhylands,jst,jesup,onecyrenus
Mike Habicher <mikeh@mozilla.com>
parents: 168958
diff changeset
   135
  : CameraConfiguration()
e93e96ed8a5ad4999e272e2a3180a32e1ffdf94d Bug 909542 - refactor CameraControl API, r=dhylands,jst,jesup,onecyrenus
Mike Habicher <mikeh@mozilla.com>
parents: 168958
diff changeset
   136
  , mMaxFocusAreas(0)
e93e96ed8a5ad4999e272e2a3180a32e1ffdf94d Bug 909542 - refactor CameraControl API, r=dhylands,jst,jesup,onecyrenus
Mike Habicher <mikeh@mozilla.com>
parents: 168958
diff changeset
   137
  , mMaxMeteringAreas(0)
e93e96ed8a5ad4999e272e2a3180a32e1ffdf94d Bug 909542 - refactor CameraControl API, r=dhylands,jst,jesup,onecyrenus
Mike Habicher <mikeh@mozilla.com>
parents: 168958
diff changeset
   138
{
e93e96ed8a5ad4999e272e2a3180a32e1ffdf94d Bug 909542 - refactor CameraControl API, r=dhylands,jst,jesup,onecyrenus
Mike Habicher <mikeh@mozilla.com>
parents: 168958
diff changeset
   139
  MOZ_COUNT_CTOR(nsDOMCameraControl::DOMCameraConfiguration);
e93e96ed8a5ad4999e272e2a3180a32e1ffdf94d Bug 909542 - refactor CameraControl API, r=dhylands,jst,jesup,onecyrenus
Mike Habicher <mikeh@mozilla.com>
parents: 168958
diff changeset
   140
}
e93e96ed8a5ad4999e272e2a3180a32e1ffdf94d Bug 909542 - refactor CameraControl API, r=dhylands,jst,jesup,onecyrenus
Mike Habicher <mikeh@mozilla.com>
parents: 168958
diff changeset
   141
e93e96ed8a5ad4999e272e2a3180a32e1ffdf94d Bug 909542 - refactor CameraControl API, r=dhylands,jst,jesup,onecyrenus
Mike Habicher <mikeh@mozilla.com>
parents: 168958
diff changeset
   142
nsDOMCameraControl::DOMCameraConfiguration::DOMCameraConfiguration(const CameraConfiguration& aConfiguration)
e93e96ed8a5ad4999e272e2a3180a32e1ffdf94d Bug 909542 - refactor CameraControl API, r=dhylands,jst,jesup,onecyrenus
Mike Habicher <mikeh@mozilla.com>
parents: 168958
diff changeset
   143
  : CameraConfiguration(aConfiguration)
e93e96ed8a5ad4999e272e2a3180a32e1ffdf94d Bug 909542 - refactor CameraControl API, r=dhylands,jst,jesup,onecyrenus
Mike Habicher <mikeh@mozilla.com>
parents: 168958
diff changeset
   144
  , mMaxFocusAreas(0)
e93e96ed8a5ad4999e272e2a3180a32e1ffdf94d Bug 909542 - refactor CameraControl API, r=dhylands,jst,jesup,onecyrenus
Mike Habicher <mikeh@mozilla.com>
parents: 168958
diff changeset
   145
  , mMaxMeteringAreas(0)
e93e96ed8a5ad4999e272e2a3180a32e1ffdf94d Bug 909542 - refactor CameraControl API, r=dhylands,jst,jesup,onecyrenus
Mike Habicher <mikeh@mozilla.com>
parents: 168958
diff changeset
   146
{
e93e96ed8a5ad4999e272e2a3180a32e1ffdf94d Bug 909542 - refactor CameraControl API, r=dhylands,jst,jesup,onecyrenus
Mike Habicher <mikeh@mozilla.com>
parents: 168958
diff changeset
   147
  MOZ_COUNT_CTOR(nsDOMCameraControl::DOMCameraConfiguration);
e93e96ed8a5ad4999e272e2a3180a32e1ffdf94d Bug 909542 - refactor CameraControl API, r=dhylands,jst,jesup,onecyrenus
Mike Habicher <mikeh@mozilla.com>
parents: 168958
diff changeset
   148
}
e93e96ed8a5ad4999e272e2a3180a32e1ffdf94d Bug 909542 - refactor CameraControl API, r=dhylands,jst,jesup,onecyrenus
Mike Habicher <mikeh@mozilla.com>
parents: 168958
diff changeset
   149
e93e96ed8a5ad4999e272e2a3180a32e1ffdf94d Bug 909542 - refactor CameraControl API, r=dhylands,jst,jesup,onecyrenus
Mike Habicher <mikeh@mozilla.com>
parents: 168958
diff changeset
   150
nsDOMCameraControl::DOMCameraConfiguration::~DOMCameraConfiguration()
e93e96ed8a5ad4999e272e2a3180a32e1ffdf94d Bug 909542 - refactor CameraControl API, r=dhylands,jst,jesup,onecyrenus
Mike Habicher <mikeh@mozilla.com>
parents: 168958
diff changeset
   151
{
e93e96ed8a5ad4999e272e2a3180a32e1ffdf94d Bug 909542 - refactor CameraControl API, r=dhylands,jst,jesup,onecyrenus
Mike Habicher <mikeh@mozilla.com>
parents: 168958
diff changeset
   152
  MOZ_COUNT_DTOR(nsDOMCameraControl::DOMCameraConfiguration);
e93e96ed8a5ad4999e272e2a3180a32e1ffdf94d Bug 909542 - refactor CameraControl API, r=dhylands,jst,jesup,onecyrenus
Mike Habicher <mikeh@mozilla.com>
parents: 168958
diff changeset
   153
}
e93e96ed8a5ad4999e272e2a3180a32e1ffdf94d Bug 909542 - refactor CameraControl API, r=dhylands,jst,jesup,onecyrenus
Mike Habicher <mikeh@mozilla.com>
parents: 168958
diff changeset
   154
214202
036de9b00df6162467e598260eef951f18f37014 Bug 1090501 - pre-emptively open the camera hardware for certified apps with 'camera' permission, r=fabrice
Fabrice Desre <fabrice@mozilla.com>
parents: 213736
diff changeset
   155
#ifdef MOZ_WIDGET_GONK
219510
220f9cd8097a7d7b395ab0419c6aa62ae25f7058 Bug 1104055 - fix CameraControl memory leak, r=aosmond
Mike Habicher <mikeh@mozilla.com>
parents: 219181
diff changeset
   156
// This should be long enough for even our slowest platforms.
214202
036de9b00df6162467e598260eef951f18f37014 Bug 1090501 - pre-emptively open the camera hardware for certified apps with 'camera' permission, r=fabrice
Fabrice Desre <fabrice@mozilla.com>
parents: 213736
diff changeset
   157
static const unsigned long kCachedCameraTimeoutMs = 3500;
036de9b00df6162467e598260eef951f18f37014 Bug 1090501 - pre-emptively open the camera hardware for certified apps with 'camera' permission, r=fabrice
Fabrice Desre <fabrice@mozilla.com>
parents: 213736
diff changeset
   158
036de9b00df6162467e598260eef951f18f37014 Bug 1090501 - pre-emptively open the camera hardware for certified apps with 'camera' permission, r=fabrice
Fabrice Desre <fabrice@mozilla.com>
parents: 213736
diff changeset
   159
// Open the battery-door-facing camera by default.
036de9b00df6162467e598260eef951f18f37014 Bug 1090501 - pre-emptively open the camera hardware for certified apps with 'camera' permission, r=fabrice
Fabrice Desre <fabrice@mozilla.com>
parents: 213736
diff changeset
   160
static const uint32_t kDefaultCameraId = 0;
036de9b00df6162467e598260eef951f18f37014 Bug 1090501 - pre-emptively open the camera hardware for certified apps with 'camera' permission, r=fabrice
Fabrice Desre <fabrice@mozilla.com>
parents: 213736
diff changeset
   161
036de9b00df6162467e598260eef951f18f37014 Bug 1090501 - pre-emptively open the camera hardware for certified apps with 'camera' permission, r=fabrice
Fabrice Desre <fabrice@mozilla.com>
parents: 213736
diff changeset
   162
/* static */ void
036de9b00df6162467e598260eef951f18f37014 Bug 1090501 - pre-emptively open the camera hardware for certified apps with 'camera' permission, r=fabrice
Fabrice Desre <fabrice@mozilla.com>
parents: 213736
diff changeset
   163
nsDOMCameraControl::PreinitCameraHardware()
036de9b00df6162467e598260eef951f18f37014 Bug 1090501 - pre-emptively open the camera hardware for certified apps with 'camera' permission, r=fabrice
Fabrice Desre <fabrice@mozilla.com>
parents: 213736
diff changeset
   164
{
036de9b00df6162467e598260eef951f18f37014 Bug 1090501 - pre-emptively open the camera hardware for certified apps with 'camera' permission, r=fabrice
Fabrice Desre <fabrice@mozilla.com>
parents: 213736
diff changeset
   165
  // Assume a default, minimal configuration. This should initialize the
036de9b00df6162467e598260eef951f18f37014 Bug 1090501 - pre-emptively open the camera hardware for certified apps with 'camera' permission, r=fabrice
Fabrice Desre <fabrice@mozilla.com>
parents: 213736
diff changeset
   166
  // hardware, but won't (can't) start the preview.
268184
e8c7dfe727cd970e2c3294934e2927b14143c205 Bug 1207245 - part 6 - rename nsRefPtr<T> to RefPtr<T>; r=ehsan; a=Tomcat
Nathan Froyd <froydnj@mozilla.com>
parents: 266718
diff changeset
   167
  RefPtr<ICameraControl> cameraControl = ICameraControl::Create(kDefaultCameraId);
214202
036de9b00df6162467e598260eef951f18f37014 Bug 1090501 - pre-emptively open the camera hardware for certified apps with 'camera' permission, r=fabrice
Fabrice Desre <fabrice@mozilla.com>
parents: 213736
diff changeset
   168
  if (NS_WARN_IF(!cameraControl)) {
036de9b00df6162467e598260eef951f18f37014 Bug 1090501 - pre-emptively open the camera hardware for certified apps with 'camera' permission, r=fabrice
Fabrice Desre <fabrice@mozilla.com>
parents: 213736
diff changeset
   169
    return;
036de9b00df6162467e598260eef951f18f37014 Bug 1090501 - pre-emptively open the camera hardware for certified apps with 'camera' permission, r=fabrice
Fabrice Desre <fabrice@mozilla.com>
parents: 213736
diff changeset
   170
  }
036de9b00df6162467e598260eef951f18f37014 Bug 1090501 - pre-emptively open the camera hardware for certified apps with 'camera' permission, r=fabrice
Fabrice Desre <fabrice@mozilla.com>
parents: 213736
diff changeset
   171
036de9b00df6162467e598260eef951f18f37014 Bug 1090501 - pre-emptively open the camera hardware for certified apps with 'camera' permission, r=fabrice
Fabrice Desre <fabrice@mozilla.com>
parents: 213736
diff changeset
   172
  sCachedCameraControlStartResult = cameraControl->Start();
036de9b00df6162467e598260eef951f18f37014 Bug 1090501 - pre-emptively open the camera hardware for certified apps with 'camera' permission, r=fabrice
Fabrice Desre <fabrice@mozilla.com>
parents: 213736
diff changeset
   173
  if (NS_WARN_IF(NS_FAILED(sCachedCameraControlStartResult))) {
036de9b00df6162467e598260eef951f18f37014 Bug 1090501 - pre-emptively open the camera hardware for certified apps with 'camera' permission, r=fabrice
Fabrice Desre <fabrice@mozilla.com>
parents: 213736
diff changeset
   174
    return;
036de9b00df6162467e598260eef951f18f37014 Bug 1090501 - pre-emptively open the camera hardware for certified apps with 'camera' permission, r=fabrice
Fabrice Desre <fabrice@mozilla.com>
parents: 213736
diff changeset
   175
  }
036de9b00df6162467e598260eef951f18f37014 Bug 1090501 - pre-emptively open the camera hardware for certified apps with 'camera' permission, r=fabrice
Fabrice Desre <fabrice@mozilla.com>
parents: 213736
diff changeset
   176
036de9b00df6162467e598260eef951f18f37014 Bug 1090501 - pre-emptively open the camera hardware for certified apps with 'camera' permission, r=fabrice
Fabrice Desre <fabrice@mozilla.com>
parents: 213736
diff changeset
   177
  sCachedCameraControl = cameraControl;
036de9b00df6162467e598260eef951f18f37014 Bug 1090501 - pre-emptively open the camera hardware for certified apps with 'camera' permission, r=fabrice
Fabrice Desre <fabrice@mozilla.com>
parents: 213736
diff changeset
   178
036de9b00df6162467e598260eef951f18f37014 Bug 1090501 - pre-emptively open the camera hardware for certified apps with 'camera' permission, r=fabrice
Fabrice Desre <fabrice@mozilla.com>
parents: 213736
diff changeset
   179
  nsCOMPtr<nsITimer> timer = do_CreateInstance(NS_TIMER_CONTRACTID);
036de9b00df6162467e598260eef951f18f37014 Bug 1090501 - pre-emptively open the camera hardware for certified apps with 'camera' permission, r=fabrice
Fabrice Desre <fabrice@mozilla.com>
parents: 213736
diff changeset
   180
  if (NS_WARN_IF(!timer)) {
036de9b00df6162467e598260eef951f18f37014 Bug 1090501 - pre-emptively open the camera hardware for certified apps with 'camera' permission, r=fabrice
Fabrice Desre <fabrice@mozilla.com>
parents: 213736
diff changeset
   181
    return;
036de9b00df6162467e598260eef951f18f37014 Bug 1090501 - pre-emptively open the camera hardware for certified apps with 'camera' permission, r=fabrice
Fabrice Desre <fabrice@mozilla.com>
parents: 213736
diff changeset
   182
  }
036de9b00df6162467e598260eef951f18f37014 Bug 1090501 - pre-emptively open the camera hardware for certified apps with 'camera' permission, r=fabrice
Fabrice Desre <fabrice@mozilla.com>
parents: 213736
diff changeset
   183
036de9b00df6162467e598260eef951f18f37014 Bug 1090501 - pre-emptively open the camera hardware for certified apps with 'camera' permission, r=fabrice
Fabrice Desre <fabrice@mozilla.com>
parents: 213736
diff changeset
   184
  nsresult rv = timer->InitWithFuncCallback(DiscardCachedCameraInstance,
036de9b00df6162467e598260eef951f18f37014 Bug 1090501 - pre-emptively open the camera hardware for certified apps with 'camera' permission, r=fabrice
Fabrice Desre <fabrice@mozilla.com>
parents: 213736
diff changeset
   185
                                            nullptr,
036de9b00df6162467e598260eef951f18f37014 Bug 1090501 - pre-emptively open the camera hardware for certified apps with 'camera' permission, r=fabrice
Fabrice Desre <fabrice@mozilla.com>
parents: 213736
diff changeset
   186
                                            kCachedCameraTimeoutMs,
036de9b00df6162467e598260eef951f18f37014 Bug 1090501 - pre-emptively open the camera hardware for certified apps with 'camera' permission, r=fabrice
Fabrice Desre <fabrice@mozilla.com>
parents: 213736
diff changeset
   187
                                            nsITimer::TYPE_ONE_SHOT);
036de9b00df6162467e598260eef951f18f37014 Bug 1090501 - pre-emptively open the camera hardware for certified apps with 'camera' permission, r=fabrice
Fabrice Desre <fabrice@mozilla.com>
parents: 213736
diff changeset
   188
  if (NS_WARN_IF(NS_FAILED(rv))) {
036de9b00df6162467e598260eef951f18f37014 Bug 1090501 - pre-emptively open the camera hardware for certified apps with 'camera' permission, r=fabrice
Fabrice Desre <fabrice@mozilla.com>
parents: 213736
diff changeset
   189
    // If we can't start the timer, it's possible for an app to never grab the
036de9b00df6162467e598260eef951f18f37014 Bug 1090501 - pre-emptively open the camera hardware for certified apps with 'camera' permission, r=fabrice
Fabrice Desre <fabrice@mozilla.com>
parents: 213736
diff changeset
   190
    // camera, leaving the hardware tied up indefinitely. Better to take the
036de9b00df6162467e598260eef951f18f37014 Bug 1090501 - pre-emptively open the camera hardware for certified apps with 'camera' permission, r=fabrice
Fabrice Desre <fabrice@mozilla.com>
parents: 213736
diff changeset
   191
    // performance hit.
036de9b00df6162467e598260eef951f18f37014 Bug 1090501 - pre-emptively open the camera hardware for certified apps with 'camera' permission, r=fabrice
Fabrice Desre <fabrice@mozilla.com>
parents: 213736
diff changeset
   192
    sCachedCameraControl = nullptr;
036de9b00df6162467e598260eef951f18f37014 Bug 1090501 - pre-emptively open the camera hardware for certified apps with 'camera' permission, r=fabrice
Fabrice Desre <fabrice@mozilla.com>
parents: 213736
diff changeset
   193
    return;
036de9b00df6162467e598260eef951f18f37014 Bug 1090501 - pre-emptively open the camera hardware for certified apps with 'camera' permission, r=fabrice
Fabrice Desre <fabrice@mozilla.com>
parents: 213736
diff changeset
   194
  }
036de9b00df6162467e598260eef951f18f37014 Bug 1090501 - pre-emptively open the camera hardware for certified apps with 'camera' permission, r=fabrice
Fabrice Desre <fabrice@mozilla.com>
parents: 213736
diff changeset
   195
036de9b00df6162467e598260eef951f18f37014 Bug 1090501 - pre-emptively open the camera hardware for certified apps with 'camera' permission, r=fabrice
Fabrice Desre <fabrice@mozilla.com>
parents: 213736
diff changeset
   196
  sDiscardCachedCameraControlTimer = timer;
036de9b00df6162467e598260eef951f18f37014 Bug 1090501 - pre-emptively open the camera hardware for certified apps with 'camera' permission, r=fabrice
Fabrice Desre <fabrice@mozilla.com>
parents: 213736
diff changeset
   197
}
036de9b00df6162467e598260eef951f18f37014 Bug 1090501 - pre-emptively open the camera hardware for certified apps with 'camera' permission, r=fabrice
Fabrice Desre <fabrice@mozilla.com>
parents: 213736
diff changeset
   198
036de9b00df6162467e598260eef951f18f37014 Bug 1090501 - pre-emptively open the camera hardware for certified apps with 'camera' permission, r=fabrice
Fabrice Desre <fabrice@mozilla.com>
parents: 213736
diff changeset
   199
/* static */ void
036de9b00df6162467e598260eef951f18f37014 Bug 1090501 - pre-emptively open the camera hardware for certified apps with 'camera' permission, r=fabrice
Fabrice Desre <fabrice@mozilla.com>
parents: 213736
diff changeset
   200
nsDOMCameraControl::DiscardCachedCameraInstance(nsITimer* aTimer, void* aClosure)
036de9b00df6162467e598260eef951f18f37014 Bug 1090501 - pre-emptively open the camera hardware for certified apps with 'camera' permission, r=fabrice
Fabrice Desre <fabrice@mozilla.com>
parents: 213736
diff changeset
   201
{
036de9b00df6162467e598260eef951f18f37014 Bug 1090501 - pre-emptively open the camera hardware for certified apps with 'camera' permission, r=fabrice
Fabrice Desre <fabrice@mozilla.com>
parents: 213736
diff changeset
   202
  MOZ_ASSERT(NS_IsMainThread());
036de9b00df6162467e598260eef951f18f37014 Bug 1090501 - pre-emptively open the camera hardware for certified apps with 'camera' permission, r=fabrice
Fabrice Desre <fabrice@mozilla.com>
parents: 213736
diff changeset
   203
036de9b00df6162467e598260eef951f18f37014 Bug 1090501 - pre-emptively open the camera hardware for certified apps with 'camera' permission, r=fabrice
Fabrice Desre <fabrice@mozilla.com>
parents: 213736
diff changeset
   204
  sDiscardCachedCameraControlTimer = nullptr;
036de9b00df6162467e598260eef951f18f37014 Bug 1090501 - pre-emptively open the camera hardware for certified apps with 'camera' permission, r=fabrice
Fabrice Desre <fabrice@mozilla.com>
parents: 213736
diff changeset
   205
  sCachedCameraControl = nullptr;
036de9b00df6162467e598260eef951f18f37014 Bug 1090501 - pre-emptively open the camera hardware for certified apps with 'camera' permission, r=fabrice
Fabrice Desre <fabrice@mozilla.com>
parents: 213736
diff changeset
   206
}
036de9b00df6162467e598260eef951f18f37014 Bug 1090501 - pre-emptively open the camera hardware for certified apps with 'camera' permission, r=fabrice
Fabrice Desre <fabrice@mozilla.com>
parents: 213736
diff changeset
   207
#endif
036de9b00df6162467e598260eef951f18f37014 Bug 1090501 - pre-emptively open the camera hardware for certified apps with 'camera' permission, r=fabrice
Fabrice Desre <fabrice@mozilla.com>
parents: 213736
diff changeset
   208
168993
e93e96ed8a5ad4999e272e2a3180a32e1ffdf94d Bug 909542 - refactor CameraControl API, r=dhylands,jst,jesup,onecyrenus
Mike Habicher <mikeh@mozilla.com>
parents: 168958
diff changeset
   209
nsDOMCameraControl::nsDOMCameraControl(uint32_t aCameraId,
e93e96ed8a5ad4999e272e2a3180a32e1ffdf94d Bug 909542 - refactor CameraControl API, r=dhylands,jst,jesup,onecyrenus
Mike Habicher <mikeh@mozilla.com>
parents: 168958
diff changeset
   210
                                       const CameraConfiguration& aInitialConfig,
208669
05df8323b82079743e8af61b83625739bbadf905 Bug 994912 - Add support for promises and event-based notifications to camera. r=mikeh, r=bz
Andrew Osmond <aosmond@mozilla.com>
parents: 207338
diff changeset
   211
                                       Promise* aPromise,
168993
e93e96ed8a5ad4999e272e2a3180a32e1ffdf94d Bug 909542 - refactor CameraControl API, r=dhylands,jst,jesup,onecyrenus
Mike Habicher <mikeh@mozilla.com>
parents: 168958
diff changeset
   212
                                       nsPIDOMWindow* aWindow)
e93e96ed8a5ad4999e272e2a3180a32e1ffdf94d Bug 909542 - refactor CameraControl API, r=dhylands,jst,jesup,onecyrenus
Mike Habicher <mikeh@mozilla.com>
parents: 168958
diff changeset
   213
  : DOMMediaStream()
e93e96ed8a5ad4999e272e2a3180a32e1ffdf94d Bug 909542 - refactor CameraControl API, r=dhylands,jst,jesup,onecyrenus
Mike Habicher <mikeh@mozilla.com>
parents: 168958
diff changeset
   214
  , mCameraControl(nullptr)
e93e96ed8a5ad4999e272e2a3180a32e1ffdf94d Bug 909542 - refactor CameraControl API, r=dhylands,jst,jesup,onecyrenus
Mike Habicher <mikeh@mozilla.com>
parents: 168958
diff changeset
   215
  , mAudioChannelAgent(nullptr)
208669
05df8323b82079743e8af61b83625739bbadf905 Bug 994912 - Add support for promises and event-based notifications to camera. r=mikeh, r=bz
Andrew Osmond <aosmond@mozilla.com>
parents: 207338
diff changeset
   216
  , mGetCameraPromise(aPromise)
168993
e93e96ed8a5ad4999e272e2a3180a32e1ffdf94d Bug 909542 - refactor CameraControl API, r=dhylands,jst,jesup,onecyrenus
Mike Habicher <mikeh@mozilla.com>
parents: 168958
diff changeset
   217
  , mWindow(aWindow)
208669
05df8323b82079743e8af61b83625739bbadf905 Bug 994912 - Add support for promises and event-based notifications to camera. r=mikeh, r=bz
Andrew Osmond <aosmond@mozilla.com>
parents: 207338
diff changeset
   218
  , mPreviewState(CameraControlListener::kPreviewStopped)
249187
9ba890d2ba081ceea82be94530b3fafffa51b766 Bug 1152500 - Fix how stop recording may be handled out-of-order. r=dhylands
Andrew Osmond <aosmond@mozilla.com>
parents: 246249
diff changeset
   219
  , mRecording(false)
249644
e3b6829af1896d0010bf09db32c4f10f6e186479 Bug 1175656 - Implement generation of recording posters in Gecko. r=dhylands,bz
Andrew Osmond <aosmond@mozilla.com>
parents: 249622
diff changeset
   220
  , mRecordingStoppedDeferred(false)
220237
ce9707a48002c8fd80f1c921b13e8f6e40d54f43 Bug 1104913 - Update selection algorithms for preview, picture and video sizes to have sane defaults. r=mikeh, r=bz
Andrew Osmond <aosmond@gmail.com>
parents: 219511
diff changeset
   221
  , mSetInitialConfig(false)
168993
e93e96ed8a5ad4999e272e2a3180a32e1ffdf94d Bug 909542 - refactor CameraControl API, r=dhylands,jst,jesup,onecyrenus
Mike Habicher <mikeh@mozilla.com>
parents: 168958
diff changeset
   222
{
e93e96ed8a5ad4999e272e2a3180a32e1ffdf94d Bug 909542 - refactor CameraControl API, r=dhylands,jst,jesup,onecyrenus
Mike Habicher <mikeh@mozilla.com>
parents: 168958
diff changeset
   223
  DOM_CAMERA_LOGT("%s:%d : this=%p\n", __func__, __LINE__, this);
e93e96ed8a5ad4999e272e2a3180a32e1ffdf94d Bug 909542 - refactor CameraControl API, r=dhylands,jst,jesup,onecyrenus
Mike Habicher <mikeh@mozilla.com>
parents: 168958
diff changeset
   224
  mInput = new CameraPreviewMediaStream(this);
e93e96ed8a5ad4999e272e2a3180a32e1ffdf94d Bug 909542 - refactor CameraControl API, r=dhylands,jst,jesup,onecyrenus
Mike Habicher <mikeh@mozilla.com>
parents: 168958
diff changeset
   225
208669
05df8323b82079743e8af61b83625739bbadf905 Bug 994912 - Add support for promises and event-based notifications to camera. r=mikeh, r=bz
Andrew Osmond <aosmond@mozilla.com>
parents: 207338
diff changeset
   226
  BindToOwner(aWindow);
168993
e93e96ed8a5ad4999e272e2a3180a32e1ffdf94d Bug 909542 - refactor CameraControl API, r=dhylands,jst,jesup,onecyrenus
Mike Habicher <mikeh@mozilla.com>
parents: 168958
diff changeset
   227
268184
e8c7dfe727cd970e2c3294934e2927b14143c205 Bug 1207245 - part 6 - rename nsRefPtr<T> to RefPtr<T>; r=ehsan; a=Tomcat
Nathan Froyd <froydnj@mozilla.com>
parents: 266718
diff changeset
   228
  RefPtr<DOMCameraConfiguration> initialConfig =
168993
e93e96ed8a5ad4999e272e2a3180a32e1ffdf94d Bug 909542 - refactor CameraControl API, r=dhylands,jst,jesup,onecyrenus
Mike Habicher <mikeh@mozilla.com>
parents: 168958
diff changeset
   229
    new DOMCameraConfiguration(aInitialConfig);
e93e96ed8a5ad4999e272e2a3180a32e1ffdf94d Bug 909542 - refactor CameraControl API, r=dhylands,jst,jesup,onecyrenus
Mike Habicher <mikeh@mozilla.com>
parents: 168958
diff changeset
   230
e93e96ed8a5ad4999e272e2a3180a32e1ffdf94d Bug 909542 - refactor CameraControl API, r=dhylands,jst,jesup,onecyrenus
Mike Habicher <mikeh@mozilla.com>
parents: 168958
diff changeset
   231
  // Create and initialize the underlying camera.
e93e96ed8a5ad4999e272e2a3180a32e1ffdf94d Bug 909542 - refactor CameraControl API, r=dhylands,jst,jesup,onecyrenus
Mike Habicher <mikeh@mozilla.com>
parents: 168958
diff changeset
   232
  ICameraControl::Configuration config;
197900
a278dc70b5f89426926502066fbedc41c1314513 Bug 1037322 - change CameraConfiguration default mode to 'unspecified' r=dhylands,khuey
Mike Habicher <mikeh@mozilla.com>
parents: 188522
diff changeset
   233
  bool haveInitialConfig = false;
a278dc70b5f89426926502066fbedc41c1314513 Bug 1037322 - change CameraConfiguration default mode to 'unspecified' r=dhylands,khuey
Mike Habicher <mikeh@mozilla.com>
parents: 188522
diff changeset
   234
  nsresult rv;
168993
e93e96ed8a5ad4999e272e2a3180a32e1ffdf94d Bug 909542 - refactor CameraControl API, r=dhylands,jst,jesup,onecyrenus
Mike Habicher <mikeh@mozilla.com>
parents: 168958
diff changeset
   235
e93e96ed8a5ad4999e272e2a3180a32e1ffdf94d Bug 909542 - refactor CameraControl API, r=dhylands,jst,jesup,onecyrenus
Mike Habicher <mikeh@mozilla.com>
parents: 168958
diff changeset
   236
  switch (aInitialConfig.mMode) {
e93e96ed8a5ad4999e272e2a3180a32e1ffdf94d Bug 909542 - refactor CameraControl API, r=dhylands,jst,jesup,onecyrenus
Mike Habicher <mikeh@mozilla.com>
parents: 168958
diff changeset
   237
    case CameraMode::Picture:
e93e96ed8a5ad4999e272e2a3180a32e1ffdf94d Bug 909542 - refactor CameraControl API, r=dhylands,jst,jesup,onecyrenus
Mike Habicher <mikeh@mozilla.com>
parents: 168958
diff changeset
   238
      config.mMode = ICameraControl::kPictureMode;
197900
a278dc70b5f89426926502066fbedc41c1314513 Bug 1037322 - change CameraConfiguration default mode to 'unspecified' r=dhylands,khuey
Mike Habicher <mikeh@mozilla.com>
parents: 188522
diff changeset
   239
      haveInitialConfig = true;
168993
e93e96ed8a5ad4999e272e2a3180a32e1ffdf94d Bug 909542 - refactor CameraControl API, r=dhylands,jst,jesup,onecyrenus
Mike Habicher <mikeh@mozilla.com>
parents: 168958
diff changeset
   240
      break;
e93e96ed8a5ad4999e272e2a3180a32e1ffdf94d Bug 909542 - refactor CameraControl API, r=dhylands,jst,jesup,onecyrenus
Mike Habicher <mikeh@mozilla.com>
parents: 168958
diff changeset
   241
e93e96ed8a5ad4999e272e2a3180a32e1ffdf94d Bug 909542 - refactor CameraControl API, r=dhylands,jst,jesup,onecyrenus
Mike Habicher <mikeh@mozilla.com>
parents: 168958
diff changeset
   242
    case CameraMode::Video:
e93e96ed8a5ad4999e272e2a3180a32e1ffdf94d Bug 909542 - refactor CameraControl API, r=dhylands,jst,jesup,onecyrenus
Mike Habicher <mikeh@mozilla.com>
parents: 168958
diff changeset
   243
      config.mMode = ICameraControl::kVideoMode;
197900
a278dc70b5f89426926502066fbedc41c1314513 Bug 1037322 - change CameraConfiguration default mode to 'unspecified' r=dhylands,khuey
Mike Habicher <mikeh@mozilla.com>
parents: 188522
diff changeset
   244
      haveInitialConfig = true;
a278dc70b5f89426926502066fbedc41c1314513 Bug 1037322 - change CameraConfiguration default mode to 'unspecified' r=dhylands,khuey
Mike Habicher <mikeh@mozilla.com>
parents: 188522
diff changeset
   245
      break;
a278dc70b5f89426926502066fbedc41c1314513 Bug 1037322 - change CameraConfiguration default mode to 'unspecified' r=dhylands,khuey
Mike Habicher <mikeh@mozilla.com>
parents: 188522
diff changeset
   246
a278dc70b5f89426926502066fbedc41c1314513 Bug 1037322 - change CameraConfiguration default mode to 'unspecified' r=dhylands,khuey
Mike Habicher <mikeh@mozilla.com>
parents: 188522
diff changeset
   247
    case CameraMode::Unspecified:
168993
e93e96ed8a5ad4999e272e2a3180a32e1ffdf94d Bug 909542 - refactor CameraControl API, r=dhylands,jst,jesup,onecyrenus
Mike Habicher <mikeh@mozilla.com>
parents: 168958
diff changeset
   248
      break;
e93e96ed8a5ad4999e272e2a3180a32e1ffdf94d Bug 909542 - refactor CameraControl API, r=dhylands,jst,jesup,onecyrenus
Mike Habicher <mikeh@mozilla.com>
parents: 168958
diff changeset
   249
e93e96ed8a5ad4999e272e2a3180a32e1ffdf94d Bug 909542 - refactor CameraControl API, r=dhylands,jst,jesup,onecyrenus
Mike Habicher <mikeh@mozilla.com>
parents: 168958
diff changeset
   250
    default:
182301
db13bb9473cc40c42900c1d0afd841fe6ea378e2 Bug 990764 - Replace MOZ_ASSUME_UNREACHABLE in dom. r=smaug
Chris Peterson <cpeterson@mozilla.com>
parents: 181171
diff changeset
   251
      MOZ_ASSERT_UNREACHABLE("Unanticipated camera mode!");
197900
a278dc70b5f89426926502066fbedc41c1314513 Bug 1037322 - change CameraConfiguration default mode to 'unspecified' r=dhylands,khuey
Mike Habicher <mikeh@mozilla.com>
parents: 188522
diff changeset
   252
      break;
168993
e93e96ed8a5ad4999e272e2a3180a32e1ffdf94d Bug 909542 - refactor CameraControl API, r=dhylands,jst,jesup,onecyrenus
Mike Habicher <mikeh@mozilla.com>
parents: 168958
diff changeset
   253
  }
e93e96ed8a5ad4999e272e2a3180a32e1ffdf94d Bug 909542 - refactor CameraControl API, r=dhylands,jst,jesup,onecyrenus
Mike Habicher <mikeh@mozilla.com>
parents: 168958
diff changeset
   254
197900
a278dc70b5f89426926502066fbedc41c1314513 Bug 1037322 - change CameraConfiguration default mode to 'unspecified' r=dhylands,khuey
Mike Habicher <mikeh@mozilla.com>
parents: 188522
diff changeset
   255
  if (haveInitialConfig) {
220237
ce9707a48002c8fd80f1c921b13e8f6e40d54f43 Bug 1104913 - Update selection algorithms for preview, picture and video sizes to have sane defaults. r=mikeh, r=bz
Andrew Osmond <aosmond@gmail.com>
parents: 219511
diff changeset
   256
    rv = SelectPreviewSize(aInitialConfig.mPreviewSize, config.mPreviewSize);
ce9707a48002c8fd80f1c921b13e8f6e40d54f43 Bug 1104913 - Update selection algorithms for preview, picture and video sizes to have sane defaults. r=mikeh, r=bz
Andrew Osmond <aosmond@gmail.com>
parents: 219511
diff changeset
   257
    if (NS_FAILED(rv)) {
ce9707a48002c8fd80f1c921b13e8f6e40d54f43 Bug 1104913 - Update selection algorithms for preview, picture and video sizes to have sane defaults. r=mikeh, r=bz
Andrew Osmond <aosmond@gmail.com>
parents: 219511
diff changeset
   258
      mListener->OnUserError(DOMCameraControlListener::kInStartCamera, rv);
ce9707a48002c8fd80f1c921b13e8f6e40d54f43 Bug 1104913 - Update selection algorithms for preview, picture and video sizes to have sane defaults. r=mikeh, r=bz
Andrew Osmond <aosmond@gmail.com>
parents: 219511
diff changeset
   259
      return;
ce9707a48002c8fd80f1c921b13e8f6e40d54f43 Bug 1104913 - Update selection algorithms for preview, picture and video sizes to have sane defaults. r=mikeh, r=bz
Andrew Osmond <aosmond@gmail.com>
parents: 219511
diff changeset
   260
    }
ce9707a48002c8fd80f1c921b13e8f6e40d54f43 Bug 1104913 - Update selection algorithms for preview, picture and video sizes to have sane defaults. r=mikeh, r=bz
Andrew Osmond <aosmond@gmail.com>
parents: 219511
diff changeset
   261
ce9707a48002c8fd80f1c921b13e8f6e40d54f43 Bug 1104913 - Update selection algorithms for preview, picture and video sizes to have sane defaults. r=mikeh, r=bz
Andrew Osmond <aosmond@gmail.com>
parents: 219511
diff changeset
   262
    config.mPictureSize.width = aInitialConfig.mPictureSize.mWidth;
ce9707a48002c8fd80f1c921b13e8f6e40d54f43 Bug 1104913 - Update selection algorithms for preview, picture and video sizes to have sane defaults. r=mikeh, r=bz
Andrew Osmond <aosmond@gmail.com>
parents: 219511
diff changeset
   263
    config.mPictureSize.height = aInitialConfig.mPictureSize.mHeight;
197900
a278dc70b5f89426926502066fbedc41c1314513 Bug 1037322 - change CameraConfiguration default mode to 'unspecified' r=dhylands,khuey
Mike Habicher <mikeh@mozilla.com>
parents: 188522
diff changeset
   264
    config.mRecorderProfile = aInitialConfig.mRecorderProfile;
a278dc70b5f89426926502066fbedc41c1314513 Bug 1037322 - change CameraConfiguration default mode to 'unspecified' r=dhylands,khuey
Mike Habicher <mikeh@mozilla.com>
parents: 188522
diff changeset
   265
  }
168993
e93e96ed8a5ad4999e272e2a3180a32e1ffdf94d Bug 909542 - refactor CameraControl API, r=dhylands,jst,jesup,onecyrenus
Mike Habicher <mikeh@mozilla.com>
parents: 168958
diff changeset
   266
214202
036de9b00df6162467e598260eef951f18f37014 Bug 1090501 - pre-emptively open the camera hardware for certified apps with 'camera' permission, r=fabrice
Fabrice Desre <fabrice@mozilla.com>
parents: 213736
diff changeset
   267
#ifdef MOZ_WIDGET_GONK
036de9b00df6162467e598260eef951f18f37014 Bug 1090501 - pre-emptively open the camera hardware for certified apps with 'camera' permission, r=fabrice
Fabrice Desre <fabrice@mozilla.com>
parents: 213736
diff changeset
   268
  bool gotCached = false;
036de9b00df6162467e598260eef951f18f37014 Bug 1090501 - pre-emptively open the camera hardware for certified apps with 'camera' permission, r=fabrice
Fabrice Desre <fabrice@mozilla.com>
parents: 213736
diff changeset
   269
  if (sCachedCameraControl && aCameraId == kDefaultCameraId) {
036de9b00df6162467e598260eef951f18f37014 Bug 1090501 - pre-emptively open the camera hardware for certified apps with 'camera' permission, r=fabrice
Fabrice Desre <fabrice@mozilla.com>
parents: 213736
diff changeset
   270
    mCameraControl = sCachedCameraControl;
036de9b00df6162467e598260eef951f18f37014 Bug 1090501 - pre-emptively open the camera hardware for certified apps with 'camera' permission, r=fabrice
Fabrice Desre <fabrice@mozilla.com>
parents: 213736
diff changeset
   271
    sCachedCameraControl = nullptr;
036de9b00df6162467e598260eef951f18f37014 Bug 1090501 - pre-emptively open the camera hardware for certified apps with 'camera' permission, r=fabrice
Fabrice Desre <fabrice@mozilla.com>
parents: 213736
diff changeset
   272
    gotCached = true;
036de9b00df6162467e598260eef951f18f37014 Bug 1090501 - pre-emptively open the camera hardware for certified apps with 'camera' permission, r=fabrice
Fabrice Desre <fabrice@mozilla.com>
parents: 213736
diff changeset
   273
  } else {
036de9b00df6162467e598260eef951f18f37014 Bug 1090501 - pre-emptively open the camera hardware for certified apps with 'camera' permission, r=fabrice
Fabrice Desre <fabrice@mozilla.com>
parents: 213736
diff changeset
   274
    sCachedCameraControl = nullptr;
036de9b00df6162467e598260eef951f18f37014 Bug 1090501 - pre-emptively open the camera hardware for certified apps with 'camera' permission, r=fabrice
Fabrice Desre <fabrice@mozilla.com>
parents: 213736
diff changeset
   275
#endif
036de9b00df6162467e598260eef951f18f37014 Bug 1090501 - pre-emptively open the camera hardware for certified apps with 'camera' permission, r=fabrice
Fabrice Desre <fabrice@mozilla.com>
parents: 213736
diff changeset
   276
    mCameraControl = ICameraControl::Create(aCameraId);
036de9b00df6162467e598260eef951f18f37014 Bug 1090501 - pre-emptively open the camera hardware for certified apps with 'camera' permission, r=fabrice
Fabrice Desre <fabrice@mozilla.com>
parents: 213736
diff changeset
   277
#ifdef MOZ_WIDGET_GONK
036de9b00df6162467e598260eef951f18f37014 Bug 1090501 - pre-emptively open the camera hardware for certified apps with 'camera' permission, r=fabrice
Fabrice Desre <fabrice@mozilla.com>
parents: 213736
diff changeset
   278
  }
036de9b00df6162467e598260eef951f18f37014 Bug 1090501 - pre-emptively open the camera hardware for certified apps with 'camera' permission, r=fabrice
Fabrice Desre <fabrice@mozilla.com>
parents: 213736
diff changeset
   279
#endif
168993
e93e96ed8a5ad4999e272e2a3180a32e1ffdf94d Bug 909542 - refactor CameraControl API, r=dhylands,jst,jesup,onecyrenus
Mike Habicher <mikeh@mozilla.com>
parents: 168958
diff changeset
   280
  mCurrentConfiguration = initialConfig.forget();
e93e96ed8a5ad4999e272e2a3180a32e1ffdf94d Bug 909542 - refactor CameraControl API, r=dhylands,jst,jesup,onecyrenus
Mike Habicher <mikeh@mozilla.com>
parents: 168958
diff changeset
   281
265193
55e96325f4c107d21794c96aa82a1b7a3524e920 Bug 1170958 - Refactor DOMMediaStream to contain a 3-stage track chain. r=roc
Andreas Pehrson <pehrsons@gmail.com>
parents: 264595
diff changeset
   282
  // Register the playback listener directly on the camera input stream.
55e96325f4c107d21794c96aa82a1b7a3524e920 Bug 1170958 - Refactor DOMMediaStream to contain a 3-stage track chain. r=roc
Andreas Pehrson <pehrsons@gmail.com>
parents: 264595
diff changeset
   283
  // We want as low latency as possible for the camera, thus avoiding
55e96325f4c107d21794c96aa82a1b7a3524e920 Bug 1170958 - Refactor DOMMediaStream to contain a 3-stage track chain. r=roc
Andreas Pehrson <pehrsons@gmail.com>
parents: 264595
diff changeset
   284
  // MediaStreamGraph altogether. Don't do the regular InitStreamCommon()
55e96325f4c107d21794c96aa82a1b7a3524e920 Bug 1170958 - Refactor DOMMediaStream to contain a 3-stage track chain. r=roc
Andreas Pehrson <pehrsons@gmail.com>
parents: 264595
diff changeset
   285
  // to avoid initializing the Owned and Playback streams. This is OK since
55e96325f4c107d21794c96aa82a1b7a3524e920 Bug 1170958 - Refactor DOMMediaStream to contain a 3-stage track chain. r=roc
Andreas Pehrson <pehrsons@gmail.com>
parents: 264595
diff changeset
   286
  // we are not user/DOM facing anyway.
55e96325f4c107d21794c96aa82a1b7a3524e920 Bug 1170958 - Refactor DOMMediaStream to contain a 3-stage track chain. r=roc
Andreas Pehrson <pehrsons@gmail.com>
parents: 264595
diff changeset
   287
  CreateAndAddPlaybackStreamListener(mInput);
55e96325f4c107d21794c96aa82a1b7a3524e920 Bug 1170958 - Refactor DOMMediaStream to contain a 3-stage track chain. r=roc
Andreas Pehrson <pehrsons@gmail.com>
parents: 264595
diff changeset
   288
168993
e93e96ed8a5ad4999e272e2a3180a32e1ffdf94d Bug 909542 - refactor CameraControl API, r=dhylands,jst,jesup,onecyrenus
Mike Habicher <mikeh@mozilla.com>
parents: 168958
diff changeset
   289
  MOZ_ASSERT(mWindow, "Shouldn't be created with a null window!");
e93e96ed8a5ad4999e272e2a3180a32e1ffdf94d Bug 909542 - refactor CameraControl API, r=dhylands,jst,jesup,onecyrenus
Mike Habicher <mikeh@mozilla.com>
parents: 168958
diff changeset
   290
  if (mWindow->GetExtantDoc()) {
e93e96ed8a5ad4999e272e2a3180a32e1ffdf94d Bug 909542 - refactor CameraControl API, r=dhylands,jst,jesup,onecyrenus
Mike Habicher <mikeh@mozilla.com>
parents: 168958
diff changeset
   291
    CombineWithPrincipal(mWindow->GetExtantDoc()->NodePrincipal());
e93e96ed8a5ad4999e272e2a3180a32e1ffdf94d Bug 909542 - refactor CameraControl API, r=dhylands,jst,jesup,onecyrenus
Mike Habicher <mikeh@mozilla.com>
parents: 168958
diff changeset
   292
  }
e93e96ed8a5ad4999e272e2a3180a32e1ffdf94d Bug 909542 - refactor CameraControl API, r=dhylands,jst,jesup,onecyrenus
Mike Habicher <mikeh@mozilla.com>
parents: 168958
diff changeset
   293
e93e96ed8a5ad4999e272e2a3180a32e1ffdf94d Bug 909542 - refactor CameraControl API, r=dhylands,jst,jesup,onecyrenus
Mike Habicher <mikeh@mozilla.com>
parents: 168958
diff changeset
   294
  // Register a listener for camera events.
e93e96ed8a5ad4999e272e2a3180a32e1ffdf94d Bug 909542 - refactor CameraControl API, r=dhylands,jst,jesup,onecyrenus
Mike Habicher <mikeh@mozilla.com>
parents: 168958
diff changeset
   295
  mListener = new DOMCameraControlListener(this, mInput);
e93e96ed8a5ad4999e272e2a3180a32e1ffdf94d Bug 909542 - refactor CameraControl API, r=dhylands,jst,jesup,onecyrenus
Mike Habicher <mikeh@mozilla.com>
parents: 168958
diff changeset
   296
  mCameraControl->AddListener(mListener);
169639
4ab6a5b763d8221dd2a189b106bba60b202fd6c2 Bug 940424 - add a failable test shim to the Gonk hardware wrapper, r=dclarke,dhylands,jesup
Mike Habicher <mikeh@mozilla.com>
parents: 168993
diff changeset
   297
214202
036de9b00df6162467e598260eef951f18f37014 Bug 1090501 - pre-emptively open the camera hardware for certified apps with 'camera' permission, r=fabrice
Fabrice Desre <fabrice@mozilla.com>
parents: 213736
diff changeset
   298
#ifdef MOZ_WIDGET_GONK
036de9b00df6162467e598260eef951f18f37014 Bug 1090501 - pre-emptively open the camera hardware for certified apps with 'camera' permission, r=fabrice
Fabrice Desre <fabrice@mozilla.com>
parents: 213736
diff changeset
   299
  if (!gotCached || NS_FAILED(sCachedCameraControlStartResult)) {
036de9b00df6162467e598260eef951f18f37014 Bug 1090501 - pre-emptively open the camera hardware for certified apps with 'camera' permission, r=fabrice
Fabrice Desre <fabrice@mozilla.com>
parents: 213736
diff changeset
   300
#endif
036de9b00df6162467e598260eef951f18f37014 Bug 1090501 - pre-emptively open the camera hardware for certified apps with 'camera' permission, r=fabrice
Fabrice Desre <fabrice@mozilla.com>
parents: 213736
diff changeset
   301
    // Start the camera...
036de9b00df6162467e598260eef951f18f37014 Bug 1090501 - pre-emptively open the camera hardware for certified apps with 'camera' permission, r=fabrice
Fabrice Desre <fabrice@mozilla.com>
parents: 213736
diff changeset
   302
    if (haveInitialConfig) {
036de9b00df6162467e598260eef951f18f37014 Bug 1090501 - pre-emptively open the camera hardware for certified apps with 'camera' permission, r=fabrice
Fabrice Desre <fabrice@mozilla.com>
parents: 213736
diff changeset
   303
      rv = mCameraControl->Start(&config);
220237
ce9707a48002c8fd80f1c921b13e8f6e40d54f43 Bug 1104913 - Update selection algorithms for preview, picture and video sizes to have sane defaults. r=mikeh, r=bz
Andrew Osmond <aosmond@gmail.com>
parents: 219511
diff changeset
   304
      if (NS_SUCCEEDED(rv)) {
ce9707a48002c8fd80f1c921b13e8f6e40d54f43 Bug 1104913 - Update selection algorithms for preview, picture and video sizes to have sane defaults. r=mikeh, r=bz
Andrew Osmond <aosmond@gmail.com>
parents: 219511
diff changeset
   305
        mSetInitialConfig = true;
ce9707a48002c8fd80f1c921b13e8f6e40d54f43 Bug 1104913 - Update selection algorithms for preview, picture and video sizes to have sane defaults. r=mikeh, r=bz
Andrew Osmond <aosmond@gmail.com>
parents: 219511
diff changeset
   306
      }
214202
036de9b00df6162467e598260eef951f18f37014 Bug 1090501 - pre-emptively open the camera hardware for certified apps with 'camera' permission, r=fabrice
Fabrice Desre <fabrice@mozilla.com>
parents: 213736
diff changeset
   307
    } else {
036de9b00df6162467e598260eef951f18f37014 Bug 1090501 - pre-emptively open the camera hardware for certified apps with 'camera' permission, r=fabrice
Fabrice Desre <fabrice@mozilla.com>
parents: 213736
diff changeset
   308
      rv = mCameraControl->Start();
036de9b00df6162467e598260eef951f18f37014 Bug 1090501 - pre-emptively open the camera hardware for certified apps with 'camera' permission, r=fabrice
Fabrice Desre <fabrice@mozilla.com>
parents: 213736
diff changeset
   309
    }
036de9b00df6162467e598260eef951f18f37014 Bug 1090501 - pre-emptively open the camera hardware for certified apps with 'camera' permission, r=fabrice
Fabrice Desre <fabrice@mozilla.com>
parents: 213736
diff changeset
   310
#ifdef MOZ_WIDGET_GONK
197900
a278dc70b5f89426926502066fbedc41c1314513 Bug 1037322 - change CameraConfiguration default mode to 'unspecified' r=dhylands,khuey
Mike Habicher <mikeh@mozilla.com>
parents: 188522
diff changeset
   311
  } else {
214446
3c8491fb2572c73f79c34484dddc557b389a5788 Bug 1090501 - Properly handle no initial camera configuration. r=aosmond
Mike Habicher <mikeh@mozilla.com>
parents: 214202
diff changeset
   312
    if (haveInitialConfig) {
3c8491fb2572c73f79c34484dddc557b389a5788 Bug 1090501 - Properly handle no initial camera configuration. r=aosmond
Mike Habicher <mikeh@mozilla.com>
parents: 214202
diff changeset
   313
      rv = mCameraControl->SetConfiguration(config);
220237
ce9707a48002c8fd80f1c921b13e8f6e40d54f43 Bug 1104913 - Update selection algorithms for preview, picture and video sizes to have sane defaults. r=mikeh, r=bz
Andrew Osmond <aosmond@gmail.com>
parents: 219511
diff changeset
   314
      if (NS_SUCCEEDED(rv)) {
ce9707a48002c8fd80f1c921b13e8f6e40d54f43 Bug 1104913 - Update selection algorithms for preview, picture and video sizes to have sane defaults. r=mikeh, r=bz
Andrew Osmond <aosmond@gmail.com>
parents: 219511
diff changeset
   315
        mSetInitialConfig = true;
ce9707a48002c8fd80f1c921b13e8f6e40d54f43 Bug 1104913 - Update selection algorithms for preview, picture and video sizes to have sane defaults. r=mikeh, r=bz
Andrew Osmond <aosmond@gmail.com>
parents: 219511
diff changeset
   316
      }
214446
3c8491fb2572c73f79c34484dddc557b389a5788 Bug 1090501 - Properly handle no initial camera configuration. r=aosmond
Mike Habicher <mikeh@mozilla.com>
parents: 214202
diff changeset
   317
    } else {
3c8491fb2572c73f79c34484dddc557b389a5788 Bug 1090501 - Properly handle no initial camera configuration. r=aosmond
Mike Habicher <mikeh@mozilla.com>
parents: 214202
diff changeset
   318
      rv = NS_OK;
3c8491fb2572c73f79c34484dddc557b389a5788 Bug 1090501 - Properly handle no initial camera configuration. r=aosmond
Mike Habicher <mikeh@mozilla.com>
parents: 214202
diff changeset
   319
    }
197900
a278dc70b5f89426926502066fbedc41c1314513 Bug 1037322 - change CameraConfiguration default mode to 'unspecified' r=dhylands,khuey
Mike Habicher <mikeh@mozilla.com>
parents: 188522
diff changeset
   320
  }
214202
036de9b00df6162467e598260eef951f18f37014 Bug 1090501 - pre-emptively open the camera hardware for certified apps with 'camera' permission, r=fabrice
Fabrice Desre <fabrice@mozilla.com>
parents: 213736
diff changeset
   321
#endif
169639
4ab6a5b763d8221dd2a189b106bba60b202fd6c2 Bug 940424 - add a failable test shim to the Gonk hardware wrapper, r=dclarke,dhylands,jesup
Mike Habicher <mikeh@mozilla.com>
parents: 168993
diff changeset
   322
  if (NS_FAILED(rv)) {
180888
c26966635e9c0c028e4360f2175563f9ef62df80 Bug 985496 - rationalize camera error reporting, r=dhylands
Mike Habicher <mikeh@mozilla.com>
parents: 180485
diff changeset
   323
    mListener->OnUserError(DOMCameraControlListener::kInStartCamera, rv);
169639
4ab6a5b763d8221dd2a189b106bba60b202fd6c2 Bug 940424 - add a failable test shim to the Gonk hardware wrapper, r=dclarke,dhylands,jesup
Mike Habicher <mikeh@mozilla.com>
parents: 168993
diff changeset
   324
  }
168993
e93e96ed8a5ad4999e272e2a3180a32e1ffdf94d Bug 909542 - refactor CameraControl API, r=dhylands,jst,jesup,onecyrenus
Mike Habicher <mikeh@mozilla.com>
parents: 168958
diff changeset
   325
}
104262
244bba751ce4ae586d66d28c8e9a1f0b41e872c5 Bug 779139 - Make DOM-facing camera objects cycle collection participants. r=jst
Mike Habicher <mikeh@mozilla.com>
parents:
diff changeset
   326
244bba751ce4ae586d66d28c8e9a1f0b41e872c5 Bug 779139 - Make DOM-facing camera objects cycle collection participants. r=jst
Mike Habicher <mikeh@mozilla.com>
parents:
diff changeset
   327
nsDOMCameraControl::~nsDOMCameraControl()
244bba751ce4ae586d66d28c8e9a1f0b41e872c5 Bug 779139 - Make DOM-facing camera objects cycle collection participants. r=jst
Mike Habicher <mikeh@mozilla.com>
parents:
diff changeset
   328
{
244bba751ce4ae586d66d28c8e9a1f0b41e872c5 Bug 779139 - Make DOM-facing camera objects cycle collection participants. r=jst
Mike Habicher <mikeh@mozilla.com>
parents:
diff changeset
   329
  DOM_CAMERA_LOGT("%s:%d : this=%p\n", __func__, __LINE__, this);
239558
7a458d7e3e4f9e8a91b6c48445c12acd4abebaf4 Bug 1139721 - Fix camera memory leaks for onfacedetected events, failed initializations and capabilities. r=mikeh
Andrew Osmond <aosmond@mozilla.com>
parents: 234479
diff changeset
   330
  /*invoke DOMMediaStream destroy*/
233505
Becker Hsieh <behsieh@mozilla.com>
parents: 231544
diff changeset
   331
  Destroy();
265193
55e96325f4c107d21794c96aa82a1b7a3524e920 Bug 1170958 - Refactor DOMMediaStream to contain a 3-stage track chain. r=roc
Andreas Pehrson <pehrsons@gmail.com>
parents: 264595
diff changeset
   332
55e96325f4c107d21794c96aa82a1b7a3524e920 Bug 1170958 - Refactor DOMMediaStream to contain a 3-stage track chain. r=roc
Andreas Pehrson <pehrsons@gmail.com>
parents: 264595
diff changeset
   333
  if (mInput) {
55e96325f4c107d21794c96aa82a1b7a3524e920 Bug 1170958 - Refactor DOMMediaStream to contain a 3-stage track chain. r=roc
Andreas Pehrson <pehrsons@gmail.com>
parents: 264595
diff changeset
   334
    mInput->Destroy();
55e96325f4c107d21794c96aa82a1b7a3524e920 Bug 1170958 - Refactor DOMMediaStream to contain a 3-stage track chain. r=roc
Andreas Pehrson <pehrsons@gmail.com>
parents: 264595
diff changeset
   335
    mInput = nullptr;
55e96325f4c107d21794c96aa82a1b7a3524e920 Bug 1170958 - Refactor DOMMediaStream to contain a 3-stage track chain. r=roc
Andreas Pehrson <pehrsons@gmail.com>
parents: 264595
diff changeset
   336
  }
104262
244bba751ce4ae586d66d28c8e9a1f0b41e872c5 Bug 779139 - Make DOM-facing camera objects cycle collection participants. r=jst
Mike Habicher <mikeh@mozilla.com>
parents:
diff changeset
   337
}
244bba751ce4ae586d66d28c8e9a1f0b41e872c5 Bug 779139 - Make DOM-facing camera objects cycle collection participants. r=jst
Mike Habicher <mikeh@mozilla.com>
parents:
diff changeset
   338
144403
614052b6cbcc905dc1e07cb1f40b02c668da7cb5 bug 899210 - convert camera control to WebIDL r=bz
Trevor Saunders <trev.saunders@gmail.com>
parents: 141384
diff changeset
   339
JSObject*
234479
0b0c492a33b545fb9daa9b041969e17b5dcbe00e Bug 1117172 part 3. Change the wrappercached WrapObject methods to allow passing in aGivenProto. r=peterv
Boris Zbarsky <bzbarsky@mit.edu>
parents: 233791
diff changeset
   340
nsDOMCameraControl::WrapObject(JSContext* aCx, JS::Handle<JSObject*> aGivenProto)
144403
614052b6cbcc905dc1e07cb1f40b02c668da7cb5 bug 899210 - convert camera control to WebIDL r=bz
Trevor Saunders <trev.saunders@gmail.com>
parents: 141384
diff changeset
   341
{
234479
0b0c492a33b545fb9daa9b041969e17b5dcbe00e Bug 1117172 part 3. Change the wrappercached WrapObject methods to allow passing in aGivenProto. r=peterv
Boris Zbarsky <bzbarsky@mit.edu>
parents: 233791
diff changeset
   342
  return CameraControlBinding::Wrap(aCx, this, aGivenProto);
144403
614052b6cbcc905dc1e07cb1f40b02c668da7cb5 bug 899210 - convert camera control to WebIDL r=bz
Trevor Saunders <trev.saunders@gmail.com>
parents: 141384
diff changeset
   343
}
614052b6cbcc905dc1e07cb1f40b02c668da7cb5 bug 899210 - convert camera control to WebIDL r=bz
Trevor Saunders <trev.saunders@gmail.com>
parents: 141384
diff changeset
   344
168993
e93e96ed8a5ad4999e272e2a3180a32e1ffdf94d Bug 909542 - refactor CameraControl API, r=dhylands,jst,jesup,onecyrenus
Mike Habicher <mikeh@mozilla.com>
parents: 168958
diff changeset
   345
bool
e93e96ed8a5ad4999e272e2a3180a32e1ffdf94d Bug 909542 - refactor CameraControl API, r=dhylands,jst,jesup,onecyrenus
Mike Habicher <mikeh@mozilla.com>
parents: 168958
diff changeset
   346
nsDOMCameraControl::IsWindowStillActive()
e93e96ed8a5ad4999e272e2a3180a32e1ffdf94d Bug 909542 - refactor CameraControl API, r=dhylands,jst,jesup,onecyrenus
Mike Habicher <mikeh@mozilla.com>
parents: 168958
diff changeset
   347
{
e93e96ed8a5ad4999e272e2a3180a32e1ffdf94d Bug 909542 - refactor CameraControl API, r=dhylands,jst,jesup,onecyrenus
Mike Habicher <mikeh@mozilla.com>
parents: 168958
diff changeset
   348
  return nsDOMCameraManager::IsWindowStillActive(mWindow->WindowID());
e93e96ed8a5ad4999e272e2a3180a32e1ffdf94d Bug 909542 - refactor CameraControl API, r=dhylands,jst,jesup,onecyrenus
Mike Habicher <mikeh@mozilla.com>
parents: 168958
diff changeset
   349
}
e93e96ed8a5ad4999e272e2a3180a32e1ffdf94d Bug 909542 - refactor CameraControl API, r=dhylands,jst,jesup,onecyrenus
Mike Habicher <mikeh@mozilla.com>
parents: 168958
diff changeset
   350
220237
ce9707a48002c8fd80f1c921b13e8f6e40d54f43 Bug 1104913 - Update selection algorithms for preview, picture and video sizes to have sane defaults. r=mikeh, r=bz
Andrew Osmond <aosmond@gmail.com>
parents: 219511
diff changeset
   351
nsresult
ce9707a48002c8fd80f1c921b13e8f6e40d54f43 Bug 1104913 - Update selection algorithms for preview, picture and video sizes to have sane defaults. r=mikeh, r=bz
Andrew Osmond <aosmond@gmail.com>
parents: 219511
diff changeset
   352
nsDOMCameraControl::SelectPreviewSize(const CameraSize& aRequestedPreviewSize, ICameraControl::Size& aSelectedPreviewSize)
ce9707a48002c8fd80f1c921b13e8f6e40d54f43 Bug 1104913 - Update selection algorithms for preview, picture and video sizes to have sane defaults. r=mikeh, r=bz
Andrew Osmond <aosmond@gmail.com>
parents: 219511
diff changeset
   353
{
ce9707a48002c8fd80f1c921b13e8f6e40d54f43 Bug 1104913 - Update selection algorithms for preview, picture and video sizes to have sane defaults. r=mikeh, r=bz
Andrew Osmond <aosmond@gmail.com>
parents: 219511
diff changeset
   354
  if (aRequestedPreviewSize.mWidth && aRequestedPreviewSize.mHeight) {
ce9707a48002c8fd80f1c921b13e8f6e40d54f43 Bug 1104913 - Update selection algorithms for preview, picture and video sizes to have sane defaults. r=mikeh, r=bz
Andrew Osmond <aosmond@gmail.com>
parents: 219511
diff changeset
   355
    aSelectedPreviewSize.width = aRequestedPreviewSize.mWidth;
ce9707a48002c8fd80f1c921b13e8f6e40d54f43 Bug 1104913 - Update selection algorithms for preview, picture and video sizes to have sane defaults. r=mikeh, r=bz
Andrew Osmond <aosmond@gmail.com>
parents: 219511
diff changeset
   356
    aSelectedPreviewSize.height = aRequestedPreviewSize.mHeight;
ce9707a48002c8fd80f1c921b13e8f6e40d54f43 Bug 1104913 - Update selection algorithms for preview, picture and video sizes to have sane defaults. r=mikeh, r=bz
Andrew Osmond <aosmond@gmail.com>
parents: 219511
diff changeset
   357
  } else {
ce9707a48002c8fd80f1c921b13e8f6e40d54f43 Bug 1104913 - Update selection algorithms for preview, picture and video sizes to have sane defaults. r=mikeh, r=bz
Andrew Osmond <aosmond@gmail.com>
parents: 219511
diff changeset
   358
    /* Use the window width and height if no preview size is provided.
ce9707a48002c8fd80f1c921b13e8f6e40d54f43 Bug 1104913 - Update selection algorithms for preview, picture and video sizes to have sane defaults. r=mikeh, r=bz
Andrew Osmond <aosmond@gmail.com>
parents: 219511
diff changeset
   359
       Note that the width and height are actually reversed from the
ce9707a48002c8fd80f1c921b13e8f6e40d54f43 Bug 1104913 - Update selection algorithms for preview, picture and video sizes to have sane defaults. r=mikeh, r=bz
Andrew Osmond <aosmond@gmail.com>
parents: 219511
diff changeset
   360
       camera perspective. */
ce9707a48002c8fd80f1c921b13e8f6e40d54f43 Bug 1104913 - Update selection algorithms for preview, picture and video sizes to have sane defaults. r=mikeh, r=bz
Andrew Osmond <aosmond@gmail.com>
parents: 219511
diff changeset
   361
    int32_t width = 0;
ce9707a48002c8fd80f1c921b13e8f6e40d54f43 Bug 1104913 - Update selection algorithms for preview, picture and video sizes to have sane defaults. r=mikeh, r=bz
Andrew Osmond <aosmond@gmail.com>
parents: 219511
diff changeset
   362
    int32_t height = 0;
ce9707a48002c8fd80f1c921b13e8f6e40d54f43 Bug 1104913 - Update selection algorithms for preview, picture and video sizes to have sane defaults. r=mikeh, r=bz
Andrew Osmond <aosmond@gmail.com>
parents: 219511
diff changeset
   363
    float ratio = 0.0;
ce9707a48002c8fd80f1c921b13e8f6e40d54f43 Bug 1104913 - Update selection algorithms for preview, picture and video sizes to have sane defaults. r=mikeh, r=bz
Andrew Osmond <aosmond@gmail.com>
parents: 219511
diff changeset
   364
    nsresult rv;
ce9707a48002c8fd80f1c921b13e8f6e40d54f43 Bug 1104913 - Update selection algorithms for preview, picture and video sizes to have sane defaults. r=mikeh, r=bz
Andrew Osmond <aosmond@gmail.com>
parents: 219511
diff changeset
   365
ce9707a48002c8fd80f1c921b13e8f6e40d54f43 Bug 1104913 - Update selection algorithms for preview, picture and video sizes to have sane defaults. r=mikeh, r=bz
Andrew Osmond <aosmond@gmail.com>
parents: 219511
diff changeset
   366
    rv = mWindow->GetDevicePixelRatio(&ratio);
ce9707a48002c8fd80f1c921b13e8f6e40d54f43 Bug 1104913 - Update selection algorithms for preview, picture and video sizes to have sane defaults. r=mikeh, r=bz
Andrew Osmond <aosmond@gmail.com>
parents: 219511
diff changeset
   367
    if (NS_WARN_IF(NS_FAILED(rv))) {
ce9707a48002c8fd80f1c921b13e8f6e40d54f43 Bug 1104913 - Update selection algorithms for preview, picture and video sizes to have sane defaults. r=mikeh, r=bz
Andrew Osmond <aosmond@gmail.com>
parents: 219511
diff changeset
   368
      return rv;
ce9707a48002c8fd80f1c921b13e8f6e40d54f43 Bug 1104913 - Update selection algorithms for preview, picture and video sizes to have sane defaults. r=mikeh, r=bz
Andrew Osmond <aosmond@gmail.com>
parents: 219511
diff changeset
   369
    }
ce9707a48002c8fd80f1c921b13e8f6e40d54f43 Bug 1104913 - Update selection algorithms for preview, picture and video sizes to have sane defaults. r=mikeh, r=bz
Andrew Osmond <aosmond@gmail.com>
parents: 219511
diff changeset
   370
ce9707a48002c8fd80f1c921b13e8f6e40d54f43 Bug 1104913 - Update selection algorithms for preview, picture and video sizes to have sane defaults. r=mikeh, r=bz
Andrew Osmond <aosmond@gmail.com>
parents: 219511
diff changeset
   371
    rv = mWindow->GetInnerWidth(&height);
ce9707a48002c8fd80f1c921b13e8f6e40d54f43 Bug 1104913 - Update selection algorithms for preview, picture and video sizes to have sane defaults. r=mikeh, r=bz
Andrew Osmond <aosmond@gmail.com>
parents: 219511
diff changeset
   372
    if (NS_WARN_IF(NS_FAILED(rv))) {
ce9707a48002c8fd80f1c921b13e8f6e40d54f43 Bug 1104913 - Update selection algorithms for preview, picture and video sizes to have sane defaults. r=mikeh, r=bz
Andrew Osmond <aosmond@gmail.com>
parents: 219511
diff changeset
   373
      return rv;
ce9707a48002c8fd80f1c921b13e8f6e40d54f43 Bug 1104913 - Update selection algorithms for preview, picture and video sizes to have sane defaults. r=mikeh, r=bz
Andrew Osmond <aosmond@gmail.com>
parents: 219511
diff changeset
   374
    }
ce9707a48002c8fd80f1c921b13e8f6e40d54f43 Bug 1104913 - Update selection algorithms for preview, picture and video sizes to have sane defaults. r=mikeh, r=bz
Andrew Osmond <aosmond@gmail.com>
parents: 219511
diff changeset
   375
ce9707a48002c8fd80f1c921b13e8f6e40d54f43 Bug 1104913 - Update selection algorithms for preview, picture and video sizes to have sane defaults. r=mikeh, r=bz
Andrew Osmond <aosmond@gmail.com>
parents: 219511
diff changeset
   376
    rv = mWindow->GetInnerHeight(&width);
ce9707a48002c8fd80f1c921b13e8f6e40d54f43 Bug 1104913 - Update selection algorithms for preview, picture and video sizes to have sane defaults. r=mikeh, r=bz
Andrew Osmond <aosmond@gmail.com>
parents: 219511
diff changeset
   377
    if (NS_WARN_IF(NS_FAILED(rv))) {
ce9707a48002c8fd80f1c921b13e8f6e40d54f43 Bug 1104913 - Update selection algorithms for preview, picture and video sizes to have sane defaults. r=mikeh, r=bz
Andrew Osmond <aosmond@gmail.com>
parents: 219511
diff changeset
   378
      return rv;
ce9707a48002c8fd80f1c921b13e8f6e40d54f43 Bug 1104913 - Update selection algorithms for preview, picture and video sizes to have sane defaults. r=mikeh, r=bz
Andrew Osmond <aosmond@gmail.com>
parents: 219511
diff changeset
   379
    }
ce9707a48002c8fd80f1c921b13e8f6e40d54f43 Bug 1104913 - Update selection algorithms for preview, picture and video sizes to have sane defaults. r=mikeh, r=bz
Andrew Osmond <aosmond@gmail.com>
parents: 219511
diff changeset
   380
ce9707a48002c8fd80f1c921b13e8f6e40d54f43 Bug 1104913 - Update selection algorithms for preview, picture and video sizes to have sane defaults. r=mikeh, r=bz
Andrew Osmond <aosmond@gmail.com>
parents: 219511
diff changeset
   381
    MOZ_ASSERT(width > 0);
ce9707a48002c8fd80f1c921b13e8f6e40d54f43 Bug 1104913 - Update selection algorithms for preview, picture and video sizes to have sane defaults. r=mikeh, r=bz
Andrew Osmond <aosmond@gmail.com>
parents: 219511
diff changeset
   382
    MOZ_ASSERT(height > 0);
ce9707a48002c8fd80f1c921b13e8f6e40d54f43 Bug 1104913 - Update selection algorithms for preview, picture and video sizes to have sane defaults. r=mikeh, r=bz
Andrew Osmond <aosmond@gmail.com>
parents: 219511
diff changeset
   383
    MOZ_ASSERT(ratio > 0.0);
ce9707a48002c8fd80f1c921b13e8f6e40d54f43 Bug 1104913 - Update selection algorithms for preview, picture and video sizes to have sane defaults. r=mikeh, r=bz
Andrew Osmond <aosmond@gmail.com>
parents: 219511
diff changeset
   384
    aSelectedPreviewSize.width = std::ceil(width * ratio);
ce9707a48002c8fd80f1c921b13e8f6e40d54f43 Bug 1104913 - Update selection algorithms for preview, picture and video sizes to have sane defaults. r=mikeh, r=bz
Andrew Osmond <aosmond@gmail.com>
parents: 219511
diff changeset
   385
    aSelectedPreviewSize.height = std::ceil(height * ratio);
ce9707a48002c8fd80f1c921b13e8f6e40d54f43 Bug 1104913 - Update selection algorithms for preview, picture and video sizes to have sane defaults. r=mikeh, r=bz
Andrew Osmond <aosmond@gmail.com>
parents: 219511
diff changeset
   386
  }
ce9707a48002c8fd80f1c921b13e8f6e40d54f43 Bug 1104913 - Update selection algorithms for preview, picture and video sizes to have sane defaults. r=mikeh, r=bz
Andrew Osmond <aosmond@gmail.com>
parents: 219511
diff changeset
   387
ce9707a48002c8fd80f1c921b13e8f6e40d54f43 Bug 1104913 - Update selection algorithms for preview, picture and video sizes to have sane defaults. r=mikeh, r=bz
Andrew Osmond <aosmond@gmail.com>
parents: 219511
diff changeset
   388
  return NS_OK;
ce9707a48002c8fd80f1c921b13e8f6e40d54f43 Bug 1104913 - Update selection algorithms for preview, picture and video sizes to have sane defaults. r=mikeh, r=bz
Andrew Osmond <aosmond@gmail.com>
parents: 219511
diff changeset
   389
}
ce9707a48002c8fd80f1c921b13e8f6e40d54f43 Bug 1104913 - Update selection algorithms for preview, picture and video sizes to have sane defaults. r=mikeh, r=bz
Andrew Osmond <aosmond@gmail.com>
parents: 219511
diff changeset
   390
168993
e93e96ed8a5ad4999e272e2a3180a32e1ffdf94d Bug 909542 - refactor CameraControl API, r=dhylands,jst,jesup,onecyrenus
Mike Habicher <mikeh@mozilla.com>
parents: 168958
diff changeset
   391
// Setter for weighted regions: { top, bottom, left, right, weight }
e93e96ed8a5ad4999e272e2a3180a32e1ffdf94d Bug 909542 - refactor CameraControl API, r=dhylands,jst,jesup,onecyrenus
Mike Habicher <mikeh@mozilla.com>
parents: 168958
diff changeset
   392
nsresult
181171
3be37517e25971e3220499fe7f78649b7f8024ac Bug 987954 - Change camera control size/region attributes to methods to remove direct JS_*() calls, r=bz,mikeh
Andrew Osmond <aosmond@gmail.com>
parents: 180888
diff changeset
   393
nsDOMCameraControl::Set(uint32_t aKey, const Optional<Sequence<CameraRegion> >& aValue, uint32_t aLimit)
104262
244bba751ce4ae586d66d28c8e9a1f0b41e872c5 Bug 779139 - Make DOM-facing camera objects cycle collection participants. r=jst
Mike Habicher <mikeh@mozilla.com>
parents:
diff changeset
   394
{
168993
e93e96ed8a5ad4999e272e2a3180a32e1ffdf94d Bug 909542 - refactor CameraControl API, r=dhylands,jst,jesup,onecyrenus
Mike Habicher <mikeh@mozilla.com>
parents: 168958
diff changeset
   395
  if (aLimit == 0) {
e93e96ed8a5ad4999e272e2a3180a32e1ffdf94d Bug 909542 - refactor CameraControl API, r=dhylands,jst,jesup,onecyrenus
Mike Habicher <mikeh@mozilla.com>
parents: 168958
diff changeset
   396
    DOM_CAMERA_LOGI("%s:%d : aLimit = 0, nothing to do\n", __func__, __LINE__);
e93e96ed8a5ad4999e272e2a3180a32e1ffdf94d Bug 909542 - refactor CameraControl API, r=dhylands,jst,jesup,onecyrenus
Mike Habicher <mikeh@mozilla.com>
parents: 168958
diff changeset
   397
    return NS_OK;
e93e96ed8a5ad4999e272e2a3180a32e1ffdf94d Bug 909542 - refactor CameraControl API, r=dhylands,jst,jesup,onecyrenus
Mike Habicher <mikeh@mozilla.com>
parents: 168958
diff changeset
   398
  }
e93e96ed8a5ad4999e272e2a3180a32e1ffdf94d Bug 909542 - refactor CameraControl API, r=dhylands,jst,jesup,onecyrenus
Mike Habicher <mikeh@mozilla.com>
parents: 168958
diff changeset
   399
181171
3be37517e25971e3220499fe7f78649b7f8024ac Bug 987954 - Change camera control size/region attributes to methods to remove direct JS_*() calls, r=bz,mikeh
Andrew Osmond <aosmond@gmail.com>
parents: 180888
diff changeset
   400
  nsTArray<ICameraControl::Region> regionArray;
3be37517e25971e3220499fe7f78649b7f8024ac Bug 987954 - Change camera control size/region attributes to methods to remove direct JS_*() calls, r=bz,mikeh
Andrew Osmond <aosmond@gmail.com>
parents: 180888
diff changeset
   401
  if (aValue.WasPassed()) {
3be37517e25971e3220499fe7f78649b7f8024ac Bug 987954 - Change camera control size/region attributes to methods to remove direct JS_*() calls, r=bz,mikeh
Andrew Osmond <aosmond@gmail.com>
parents: 180888
diff changeset
   402
    const Sequence<CameraRegion>& regions = aValue.Value();
3be37517e25971e3220499fe7f78649b7f8024ac Bug 987954 - Change camera control size/region attributes to methods to remove direct JS_*() calls, r=bz,mikeh
Andrew Osmond <aosmond@gmail.com>
parents: 180888
diff changeset
   403
    uint32_t length = regions.Length();
180299
33a615530ab17a6068f45a7ead9ec1f25ef01774 Backed out changeset 27b41f71ccd4 (bug 987954) for mochitest-5 orange
Wes Kocher <wkocher@mozilla.com>
parents: 180288
diff changeset
   404
181171
3be37517e25971e3220499fe7f78649b7f8024ac Bug 987954 - Change camera control size/region attributes to methods to remove direct JS_*() calls, r=bz,mikeh
Andrew Osmond <aosmond@gmail.com>
parents: 180888
diff changeset
   405
    DOM_CAMERA_LOGI("%s:%d : got %d regions (limited to %d)\n", __func__, __LINE__, length, aLimit);
3be37517e25971e3220499fe7f78649b7f8024ac Bug 987954 - Change camera control size/region attributes to methods to remove direct JS_*() calls, r=bz,mikeh
Andrew Osmond <aosmond@gmail.com>
parents: 180888
diff changeset
   406
    if (length > aLimit) {
3be37517e25971e3220499fe7f78649b7f8024ac Bug 987954 - Change camera control size/region attributes to methods to remove direct JS_*() calls, r=bz,mikeh
Andrew Osmond <aosmond@gmail.com>
parents: 180888
diff changeset
   407
      length = aLimit;
168993
e93e96ed8a5ad4999e272e2a3180a32e1ffdf94d Bug 909542 - refactor CameraControl API, r=dhylands,jst,jesup,onecyrenus
Mike Habicher <mikeh@mozilla.com>
parents: 168958
diff changeset
   408
    }
e93e96ed8a5ad4999e272e2a3180a32e1ffdf94d Bug 909542 - refactor CameraControl API, r=dhylands,jst,jesup,onecyrenus
Mike Habicher <mikeh@mozilla.com>
parents: 168958
diff changeset
   409
181171
3be37517e25971e3220499fe7f78649b7f8024ac Bug 987954 - Change camera control size/region attributes to methods to remove direct JS_*() calls, r=bz,mikeh
Andrew Osmond <aosmond@gmail.com>
parents: 180888
diff changeset
   410
    // aLimit supplied by camera library provides sane ceiling (i.e. <10)
3be37517e25971e3220499fe7f78649b7f8024ac Bug 987954 - Change camera control size/region attributes to methods to remove direct JS_*() calls, r=bz,mikeh
Andrew Osmond <aosmond@gmail.com>
parents: 180888
diff changeset
   411
    regionArray.SetCapacity(length);
3be37517e25971e3220499fe7f78649b7f8024ac Bug 987954 - Change camera control size/region attributes to methods to remove direct JS_*() calls, r=bz,mikeh
Andrew Osmond <aosmond@gmail.com>
parents: 180888
diff changeset
   412
3be37517e25971e3220499fe7f78649b7f8024ac Bug 987954 - Change camera control size/region attributes to methods to remove direct JS_*() calls, r=bz,mikeh
Andrew Osmond <aosmond@gmail.com>
parents: 180888
diff changeset
   413
    for (uint32_t i = 0; i < length; ++i) {
3be37517e25971e3220499fe7f78649b7f8024ac Bug 987954 - Change camera control size/region attributes to methods to remove direct JS_*() calls, r=bz,mikeh
Andrew Osmond <aosmond@gmail.com>
parents: 180888
diff changeset
   414
      ICameraControl::Region* r = regionArray.AppendElement();
3be37517e25971e3220499fe7f78649b7f8024ac Bug 987954 - Change camera control size/region attributes to methods to remove direct JS_*() calls, r=bz,mikeh
Andrew Osmond <aosmond@gmail.com>
parents: 180888
diff changeset
   415
      const CameraRegion &region = regions[i];
3be37517e25971e3220499fe7f78649b7f8024ac Bug 987954 - Change camera control size/region attributes to methods to remove direct JS_*() calls, r=bz,mikeh
Andrew Osmond <aosmond@gmail.com>
parents: 180888
diff changeset
   416
      r->top = region.mTop;
3be37517e25971e3220499fe7f78649b7f8024ac Bug 987954 - Change camera control size/region attributes to methods to remove direct JS_*() calls, r=bz,mikeh
Andrew Osmond <aosmond@gmail.com>
parents: 180888
diff changeset
   417
      r->left = region.mLeft;
3be37517e25971e3220499fe7f78649b7f8024ac Bug 987954 - Change camera control size/region attributes to methods to remove direct JS_*() calls, r=bz,mikeh
Andrew Osmond <aosmond@gmail.com>
parents: 180888
diff changeset
   418
      r->bottom = region.mBottom;
3be37517e25971e3220499fe7f78649b7f8024ac Bug 987954 - Change camera control size/region attributes to methods to remove direct JS_*() calls, r=bz,mikeh
Andrew Osmond <aosmond@gmail.com>
parents: 180888
diff changeset
   419
      r->right = region.mRight;
3be37517e25971e3220499fe7f78649b7f8024ac Bug 987954 - Change camera control size/region attributes to methods to remove direct JS_*() calls, r=bz,mikeh
Andrew Osmond <aosmond@gmail.com>
parents: 180888
diff changeset
   420
      r->weight = region.mWeight;
168993
e93e96ed8a5ad4999e272e2a3180a32e1ffdf94d Bug 909542 - refactor CameraControl API, r=dhylands,jst,jesup,onecyrenus
Mike Habicher <mikeh@mozilla.com>
parents: 168958
diff changeset
   421
181171
3be37517e25971e3220499fe7f78649b7f8024ac Bug 987954 - Change camera control size/region attributes to methods to remove direct JS_*() calls, r=bz,mikeh
Andrew Osmond <aosmond@gmail.com>
parents: 180888
diff changeset
   422
      DOM_CAMERA_LOGI("region %d: top=%d, left=%d, bottom=%d, right=%d, weight=%u\n",
3be37517e25971e3220499fe7f78649b7f8024ac Bug 987954 - Change camera control size/region attributes to methods to remove direct JS_*() calls, r=bz,mikeh
Andrew Osmond <aosmond@gmail.com>
parents: 180888
diff changeset
   423
        i,
3be37517e25971e3220499fe7f78649b7f8024ac Bug 987954 - Change camera control size/region attributes to methods to remove direct JS_*() calls, r=bz,mikeh
Andrew Osmond <aosmond@gmail.com>
parents: 180888
diff changeset
   424
        r->top,
3be37517e25971e3220499fe7f78649b7f8024ac Bug 987954 - Change camera control size/region attributes to methods to remove direct JS_*() calls, r=bz,mikeh
Andrew Osmond <aosmond@gmail.com>
parents: 180888
diff changeset
   425
        r->left,
3be37517e25971e3220499fe7f78649b7f8024ac Bug 987954 - Change camera control size/region attributes to methods to remove direct JS_*() calls, r=bz,mikeh
Andrew Osmond <aosmond@gmail.com>
parents: 180888
diff changeset
   426
        r->bottom,
3be37517e25971e3220499fe7f78649b7f8024ac Bug 987954 - Change camera control size/region attributes to methods to remove direct JS_*() calls, r=bz,mikeh
Andrew Osmond <aosmond@gmail.com>
parents: 180888
diff changeset
   427
        r->right,
3be37517e25971e3220499fe7f78649b7f8024ac Bug 987954 - Change camera control size/region attributes to methods to remove direct JS_*() calls, r=bz,mikeh
Andrew Osmond <aosmond@gmail.com>
parents: 180888
diff changeset
   428
        r->weight
3be37517e25971e3220499fe7f78649b7f8024ac Bug 987954 - Change camera control size/region attributes to methods to remove direct JS_*() calls, r=bz,mikeh
Andrew Osmond <aosmond@gmail.com>
parents: 180888
diff changeset
   429
      );
3be37517e25971e3220499fe7f78649b7f8024ac Bug 987954 - Change camera control size/region attributes to methods to remove direct JS_*() calls, r=bz,mikeh
Andrew Osmond <aosmond@gmail.com>
parents: 180888
diff changeset
   430
    }
3be37517e25971e3220499fe7f78649b7f8024ac Bug 987954 - Change camera control size/region attributes to methods to remove direct JS_*() calls, r=bz,mikeh
Andrew Osmond <aosmond@gmail.com>
parents: 180888
diff changeset
   431
  } else {
3be37517e25971e3220499fe7f78649b7f8024ac Bug 987954 - Change camera control size/region attributes to methods to remove direct JS_*() calls, r=bz,mikeh
Andrew Osmond <aosmond@gmail.com>
parents: 180888
diff changeset
   432
    DOM_CAMERA_LOGI("%s:%d : clear regions\n", __func__, __LINE__);
168993
e93e96ed8a5ad4999e272e2a3180a32e1ffdf94d Bug 909542 - refactor CameraControl API, r=dhylands,jst,jesup,onecyrenus
Mike Habicher <mikeh@mozilla.com>
parents: 168958
diff changeset
   433
  }
e93e96ed8a5ad4999e272e2a3180a32e1ffdf94d Bug 909542 - refactor CameraControl API, r=dhylands,jst,jesup,onecyrenus
Mike Habicher <mikeh@mozilla.com>
parents: 168958
diff changeset
   434
  return mCameraControl->Set(aKey, regionArray);
e93e96ed8a5ad4999e272e2a3180a32e1ffdf94d Bug 909542 - refactor CameraControl API, r=dhylands,jst,jesup,onecyrenus
Mike Habicher <mikeh@mozilla.com>
parents: 168958
diff changeset
   435
}
e93e96ed8a5ad4999e272e2a3180a32e1ffdf94d Bug 909542 - refactor CameraControl API, r=dhylands,jst,jesup,onecyrenus
Mike Habicher <mikeh@mozilla.com>
parents: 168958
diff changeset
   436
e93e96ed8a5ad4999e272e2a3180a32e1ffdf94d Bug 909542 - refactor CameraControl API, r=dhylands,jst,jesup,onecyrenus
Mike Habicher <mikeh@mozilla.com>
parents: 168958
diff changeset
   437
// Getter for weighted regions: { top, bottom, left, right, weight }
e93e96ed8a5ad4999e272e2a3180a32e1ffdf94d Bug 909542 - refactor CameraControl API, r=dhylands,jst,jesup,onecyrenus
Mike Habicher <mikeh@mozilla.com>
parents: 168958
diff changeset
   438
nsresult
181171
3be37517e25971e3220499fe7f78649b7f8024ac Bug 987954 - Change camera control size/region attributes to methods to remove direct JS_*() calls, r=bz,mikeh
Andrew Osmond <aosmond@gmail.com>
parents: 180888
diff changeset
   439
nsDOMCameraControl::Get(uint32_t aKey, nsTArray<CameraRegion>& aValue)
168993
e93e96ed8a5ad4999e272e2a3180a32e1ffdf94d Bug 909542 - refactor CameraControl API, r=dhylands,jst,jesup,onecyrenus
Mike Habicher <mikeh@mozilla.com>
parents: 168958
diff changeset
   440
{
e93e96ed8a5ad4999e272e2a3180a32e1ffdf94d Bug 909542 - refactor CameraControl API, r=dhylands,jst,jesup,onecyrenus
Mike Habicher <mikeh@mozilla.com>
parents: 168958
diff changeset
   441
  nsTArray<ICameraControl::Region> regionArray;
e93e96ed8a5ad4999e272e2a3180a32e1ffdf94d Bug 909542 - refactor CameraControl API, r=dhylands,jst,jesup,onecyrenus
Mike Habicher <mikeh@mozilla.com>
parents: 168958
diff changeset
   442
e93e96ed8a5ad4999e272e2a3180a32e1ffdf94d Bug 909542 - refactor CameraControl API, r=dhylands,jst,jesup,onecyrenus
Mike Habicher <mikeh@mozilla.com>
parents: 168958
diff changeset
   443
  nsresult rv = mCameraControl->Get(aKey, regionArray);
e93e96ed8a5ad4999e272e2a3180a32e1ffdf94d Bug 909542 - refactor CameraControl API, r=dhylands,jst,jesup,onecyrenus
Mike Habicher <mikeh@mozilla.com>
parents: 168958
diff changeset
   444
  NS_ENSURE_SUCCESS(rv, rv);
e93e96ed8a5ad4999e272e2a3180a32e1ffdf94d Bug 909542 - refactor CameraControl API, r=dhylands,jst,jesup,onecyrenus
Mike Habicher <mikeh@mozilla.com>
parents: 168958
diff changeset
   445
e93e96ed8a5ad4999e272e2a3180a32e1ffdf94d Bug 909542 - refactor CameraControl API, r=dhylands,jst,jesup,onecyrenus
Mike Habicher <mikeh@mozilla.com>
parents: 168958
diff changeset
   446
  uint32_t length = regionArray.Length();
e93e96ed8a5ad4999e272e2a3180a32e1ffdf94d Bug 909542 - refactor CameraControl API, r=dhylands,jst,jesup,onecyrenus
Mike Habicher <mikeh@mozilla.com>
parents: 168958
diff changeset
   447
  DOM_CAMERA_LOGI("%s:%d : got %d regions\n", __func__, __LINE__, length);
181171
3be37517e25971e3220499fe7f78649b7f8024ac Bug 987954 - Change camera control size/region attributes to methods to remove direct JS_*() calls, r=bz,mikeh
Andrew Osmond <aosmond@gmail.com>
parents: 180888
diff changeset
   448
  aValue.SetLength(length);
168993
e93e96ed8a5ad4999e272e2a3180a32e1ffdf94d Bug 909542 - refactor CameraControl API, r=dhylands,jst,jesup,onecyrenus
Mike Habicher <mikeh@mozilla.com>
parents: 168958
diff changeset
   449
e93e96ed8a5ad4999e272e2a3180a32e1ffdf94d Bug 909542 - refactor CameraControl API, r=dhylands,jst,jesup,onecyrenus
Mike Habicher <mikeh@mozilla.com>
parents: 168958
diff changeset
   450
  for (uint32_t i = 0; i < length; ++i) {
181171
3be37517e25971e3220499fe7f78649b7f8024ac Bug 987954 - Change camera control size/region attributes to methods to remove direct JS_*() calls, r=bz,mikeh
Andrew Osmond <aosmond@gmail.com>
parents: 180888
diff changeset
   451
    ICameraControl::Region& r = regionArray[i];
3be37517e25971e3220499fe7f78649b7f8024ac Bug 987954 - Change camera control size/region attributes to methods to remove direct JS_*() calls, r=bz,mikeh
Andrew Osmond <aosmond@gmail.com>
parents: 180888
diff changeset
   452
    CameraRegion& v = aValue[i];
3be37517e25971e3220499fe7f78649b7f8024ac Bug 987954 - Change camera control size/region attributes to methods to remove direct JS_*() calls, r=bz,mikeh
Andrew Osmond <aosmond@gmail.com>
parents: 180888
diff changeset
   453
    v.mTop = r.top;
3be37517e25971e3220499fe7f78649b7f8024ac Bug 987954 - Change camera control size/region attributes to methods to remove direct JS_*() calls, r=bz,mikeh
Andrew Osmond <aosmond@gmail.com>
parents: 180888
diff changeset
   454
    v.mLeft = r.left;
3be37517e25971e3220499fe7f78649b7f8024ac Bug 987954 - Change camera control size/region attributes to methods to remove direct JS_*() calls, r=bz,mikeh
Andrew Osmond <aosmond@gmail.com>
parents: 180888
diff changeset
   455
    v.mBottom = r.bottom;
3be37517e25971e3220499fe7f78649b7f8024ac Bug 987954 - Change camera control size/region attributes to methods to remove direct JS_*() calls, r=bz,mikeh
Andrew Osmond <aosmond@gmail.com>
parents: 180888
diff changeset
   456
    v.mRight = r.right;
3be37517e25971e3220499fe7f78649b7f8024ac Bug 987954 - Change camera control size/region attributes to methods to remove direct JS_*() calls, r=bz,mikeh
Andrew Osmond <aosmond@gmail.com>
parents: 180888
diff changeset
   457
    v.mWeight = r.weight;
168993
e93e96ed8a5ad4999e272e2a3180a32e1ffdf94d Bug 909542 - refactor CameraControl API, r=dhylands,jst,jesup,onecyrenus
Mike Habicher <mikeh@mozilla.com>
parents: 168958
diff changeset
   458
181171
3be37517e25971e3220499fe7f78649b7f8024ac Bug 987954 - Change camera control size/region attributes to methods to remove direct JS_*() calls, r=bz,mikeh
Andrew Osmond <aosmond@gmail.com>
parents: 180888
diff changeset
   459
    DOM_CAMERA_LOGI("region %d: top=%d, left=%d, bottom=%d, right=%d, weight=%u\n",
3be37517e25971e3220499fe7f78649b7f8024ac Bug 987954 - Change camera control size/region attributes to methods to remove direct JS_*() calls, r=bz,mikeh
Andrew Osmond <aosmond@gmail.com>
parents: 180888
diff changeset
   460
      i,
3be37517e25971e3220499fe7f78649b7f8024ac Bug 987954 - Change camera control size/region attributes to methods to remove direct JS_*() calls, r=bz,mikeh
Andrew Osmond <aosmond@gmail.com>
parents: 180888
diff changeset
   461
      v.mTop,
3be37517e25971e3220499fe7f78649b7f8024ac Bug 987954 - Change camera control size/region attributes to methods to remove direct JS_*() calls, r=bz,mikeh
Andrew Osmond <aosmond@gmail.com>
parents: 180888
diff changeset
   462
      v.mLeft,
3be37517e25971e3220499fe7f78649b7f8024ac Bug 987954 - Change camera control size/region attributes to methods to remove direct JS_*() calls, r=bz,mikeh
Andrew Osmond <aosmond@gmail.com>
parents: 180888
diff changeset
   463
      v.mBottom,
3be37517e25971e3220499fe7f78649b7f8024ac Bug 987954 - Change camera control size/region attributes to methods to remove direct JS_*() calls, r=bz,mikeh
Andrew Osmond <aosmond@gmail.com>
parents: 180888
diff changeset
   464
      v.mRight,
3be37517e25971e3220499fe7f78649b7f8024ac Bug 987954 - Change camera control size/region attributes to methods to remove direct JS_*() calls, r=bz,mikeh
Andrew Osmond <aosmond@gmail.com>
parents: 180888
diff changeset
   465
      v.mWeight
3be37517e25971e3220499fe7f78649b7f8024ac Bug 987954 - Change camera control size/region attributes to methods to remove direct JS_*() calls, r=bz,mikeh
Andrew Osmond <aosmond@gmail.com>
parents: 180888
diff changeset
   466
    );
168993
e93e96ed8a5ad4999e272e2a3180a32e1ffdf94d Bug 909542 - refactor CameraControl API, r=dhylands,jst,jesup,onecyrenus
Mike Habicher <mikeh@mozilla.com>
parents: 168958
diff changeset
   467
  }
e93e96ed8a5ad4999e272e2a3180a32e1ffdf94d Bug 909542 - refactor CameraControl API, r=dhylands,jst,jesup,onecyrenus
Mike Habicher <mikeh@mozilla.com>
parents: 168958
diff changeset
   468
e93e96ed8a5ad4999e272e2a3180a32e1ffdf94d Bug 909542 - refactor CameraControl API, r=dhylands,jst,jesup,onecyrenus
Mike Habicher <mikeh@mozilla.com>
parents: 168958
diff changeset
   469
  return NS_OK;
104262
244bba751ce4ae586d66d28c8e9a1f0b41e872c5 Bug 779139 - Make DOM-facing camera objects cycle collection participants. r=jst
Mike Habicher <mikeh@mozilla.com>
parents:
diff changeset
   470
}
244bba751ce4ae586d66d28c8e9a1f0b41e872c5 Bug 779139 - Make DOM-facing camera objects cycle collection participants. r=jst
Mike Habicher <mikeh@mozilla.com>
parents:
diff changeset
   471
265193
55e96325f4c107d21794c96aa82a1b7a3524e920 Bug 1170958 - Refactor DOMMediaStream to contain a 3-stage track chain. r=roc
Andreas Pehrson <pehrsons@gmail.com>
parents: 264595
diff changeset
   472
MediaStream*
55e96325f4c107d21794c96aa82a1b7a3524e920 Bug 1170958 - Refactor DOMMediaStream to contain a 3-stage track chain. r=roc
Andreas Pehrson <pehrsons@gmail.com>
parents: 264595
diff changeset
   473
nsDOMCameraControl::GetCameraStream() const
55e96325f4c107d21794c96aa82a1b7a3524e920 Bug 1170958 - Refactor DOMMediaStream to contain a 3-stage track chain. r=roc
Andreas Pehrson <pehrsons@gmail.com>
parents: 264595
diff changeset
   474
{
55e96325f4c107d21794c96aa82a1b7a3524e920 Bug 1170958 - Refactor DOMMediaStream to contain a 3-stage track chain. r=roc
Andreas Pehrson <pehrsons@gmail.com>
parents: 264595
diff changeset
   475
  return mInput;
55e96325f4c107d21794c96aa82a1b7a3524e920 Bug 1170958 - Refactor DOMMediaStream to contain a 3-stage track chain. r=roc
Andreas Pehrson <pehrsons@gmail.com>
parents: 264595
diff changeset
   476
}
55e96325f4c107d21794c96aa82a1b7a3524e920 Bug 1170958 - Refactor DOMMediaStream to contain a 3-stage track chain. r=roc
Andreas Pehrson <pehrsons@gmail.com>
parents: 264595
diff changeset
   477
219510
220f9cd8097a7d7b395ab0419c6aa62ae25f7058 Bug 1104055 - fix CameraControl memory leak, r=aosmond
Mike Habicher <mikeh@mozilla.com>
parents: 219181
diff changeset
   478
#define THROW_IF_NO_CAMERACONTROL(...)                                          \
220f9cd8097a7d7b395ab0419c6aa62ae25f7058 Bug 1104055 - fix CameraControl memory leak, r=aosmond
Mike Habicher <mikeh@mozilla.com>
parents: 219181
diff changeset
   479
  do {                                                                          \
220f9cd8097a7d7b395ab0419c6aa62ae25f7058 Bug 1104055 - fix CameraControl memory leak, r=aosmond
Mike Habicher <mikeh@mozilla.com>
parents: 219181
diff changeset
   480
    if (!mCameraControl) {                                                      \
220f9cd8097a7d7b395ab0419c6aa62ae25f7058 Bug 1104055 - fix CameraControl memory leak, r=aosmond
Mike Habicher <mikeh@mozilla.com>
parents: 219181
diff changeset
   481
      DOM_CAMERA_LOGW("mCameraControl is null at %s:%d\n", __func__, __LINE__); \
220f9cd8097a7d7b395ab0419c6aa62ae25f7058 Bug 1104055 - fix CameraControl memory leak, r=aosmond
Mike Habicher <mikeh@mozilla.com>
parents: 219181
diff changeset
   482
      aRv = NS_ERROR_NOT_AVAILABLE;                                             \
220f9cd8097a7d7b395ab0419c6aa62ae25f7058 Bug 1104055 - fix CameraControl memory leak, r=aosmond
Mike Habicher <mikeh@mozilla.com>
parents: 219181
diff changeset
   483
      return __VA_ARGS__;                                                       \
220f9cd8097a7d7b395ab0419c6aa62ae25f7058 Bug 1104055 - fix CameraControl memory leak, r=aosmond
Mike Habicher <mikeh@mozilla.com>
parents: 219181
diff changeset
   484
    }                                                                           \
220f9cd8097a7d7b395ab0419c6aa62ae25f7058 Bug 1104055 - fix CameraControl memory leak, r=aosmond
Mike Habicher <mikeh@mozilla.com>
parents: 219181
diff changeset
   485
  } while (0)
220f9cd8097a7d7b395ab0419c6aa62ae25f7058 Bug 1104055 - fix CameraControl memory leak, r=aosmond
Mike Habicher <mikeh@mozilla.com>
parents: 219181
diff changeset
   486
144403
614052b6cbcc905dc1e07cb1f40b02c668da7cb5 bug 899210 - convert camera control to WebIDL r=bz
Trevor Saunders <trev.saunders@gmail.com>
parents: 141384
diff changeset
   487
void
614052b6cbcc905dc1e07cb1f40b02c668da7cb5 bug 899210 - convert camera control to WebIDL r=bz
Trevor Saunders <trev.saunders@gmail.com>
parents: 141384
diff changeset
   488
nsDOMCameraControl::GetEffect(nsString& aEffect, ErrorResult& aRv)
104262
244bba751ce4ae586d66d28c8e9a1f0b41e872c5 Bug 779139 - Make DOM-facing camera objects cycle collection participants. r=jst
Mike Habicher <mikeh@mozilla.com>
parents:
diff changeset
   489
{
219510
220f9cd8097a7d7b395ab0419c6aa62ae25f7058 Bug 1104055 - fix CameraControl memory leak, r=aosmond
Mike Habicher <mikeh@mozilla.com>
parents: 219181
diff changeset
   490
  THROW_IF_NO_CAMERACONTROL();
144403
614052b6cbcc905dc1e07cb1f40b02c668da7cb5 bug 899210 - convert camera control to WebIDL r=bz
Trevor Saunders <trev.saunders@gmail.com>
parents: 141384
diff changeset
   491
  aRv = mCameraControl->Get(CAMERA_PARAM_EFFECT, aEffect);
104262
244bba751ce4ae586d66d28c8e9a1f0b41e872c5 Bug 779139 - Make DOM-facing camera objects cycle collection participants. r=jst
Mike Habicher <mikeh@mozilla.com>
parents:
diff changeset
   492
}
144403
614052b6cbcc905dc1e07cb1f40b02c668da7cb5 bug 899210 - convert camera control to WebIDL r=bz
Trevor Saunders <trev.saunders@gmail.com>
parents: 141384
diff changeset
   493
void
614052b6cbcc905dc1e07cb1f40b02c668da7cb5 bug 899210 - convert camera control to WebIDL r=bz
Trevor Saunders <trev.saunders@gmail.com>
parents: 141384
diff changeset
   494
nsDOMCameraControl::SetEffect(const nsAString& aEffect, ErrorResult& aRv)
104262
244bba751ce4ae586d66d28c8e9a1f0b41e872c5 Bug 779139 - Make DOM-facing camera objects cycle collection participants. r=jst
Mike Habicher <mikeh@mozilla.com>
parents:
diff changeset
   495
{
219510
220f9cd8097a7d7b395ab0419c6aa62ae25f7058 Bug 1104055 - fix CameraControl memory leak, r=aosmond
Mike Habicher <mikeh@mozilla.com>
parents: 219181
diff changeset
   496
  THROW_IF_NO_CAMERACONTROL();
144403
614052b6cbcc905dc1e07cb1f40b02c668da7cb5 bug 899210 - convert camera control to WebIDL r=bz
Trevor Saunders <trev.saunders@gmail.com>
parents: 141384
diff changeset
   497
  aRv = mCameraControl->Set(CAMERA_PARAM_EFFECT, aEffect);
104262
244bba751ce4ae586d66d28c8e9a1f0b41e872c5 Bug 779139 - Make DOM-facing camera objects cycle collection participants. r=jst
Mike Habicher <mikeh@mozilla.com>
parents:
diff changeset
   498
}
244bba751ce4ae586d66d28c8e9a1f0b41e872c5 Bug 779139 - Make DOM-facing camera objects cycle collection participants. r=jst
Mike Habicher <mikeh@mozilla.com>
parents:
diff changeset
   499
144403
614052b6cbcc905dc1e07cb1f40b02c668da7cb5 bug 899210 - convert camera control to WebIDL r=bz
Trevor Saunders <trev.saunders@gmail.com>
parents: 141384
diff changeset
   500
void
614052b6cbcc905dc1e07cb1f40b02c668da7cb5 bug 899210 - convert camera control to WebIDL r=bz
Trevor Saunders <trev.saunders@gmail.com>
parents: 141384
diff changeset
   501
nsDOMCameraControl::GetWhiteBalanceMode(nsString& aWhiteBalanceMode, ErrorResult& aRv)
104262
244bba751ce4ae586d66d28c8e9a1f0b41e872c5 Bug 779139 - Make DOM-facing camera objects cycle collection participants. r=jst
Mike Habicher <mikeh@mozilla.com>
parents:
diff changeset
   502
{
219510
220f9cd8097a7d7b395ab0419c6aa62ae25f7058 Bug 1104055 - fix CameraControl memory leak, r=aosmond
Mike Habicher <mikeh@mozilla.com>
parents: 219181
diff changeset
   503
  THROW_IF_NO_CAMERACONTROL();
144403
614052b6cbcc905dc1e07cb1f40b02c668da7cb5 bug 899210 - convert camera control to WebIDL r=bz
Trevor Saunders <trev.saunders@gmail.com>
parents: 141384
diff changeset
   504
  aRv = mCameraControl->Get(CAMERA_PARAM_WHITEBALANCE, aWhiteBalanceMode);
104262
244bba751ce4ae586d66d28c8e9a1f0b41e872c5 Bug 779139 - Make DOM-facing camera objects cycle collection participants. r=jst
Mike Habicher <mikeh@mozilla.com>
parents:
diff changeset
   505
}
144403
614052b6cbcc905dc1e07cb1f40b02c668da7cb5 bug 899210 - convert camera control to WebIDL r=bz
Trevor Saunders <trev.saunders@gmail.com>
parents: 141384
diff changeset
   506
void
614052b6cbcc905dc1e07cb1f40b02c668da7cb5 bug 899210 - convert camera control to WebIDL r=bz
Trevor Saunders <trev.saunders@gmail.com>
parents: 141384
diff changeset
   507
nsDOMCameraControl::SetWhiteBalanceMode(const nsAString& aWhiteBalanceMode, ErrorResult& aRv)
104262
244bba751ce4ae586d66d28c8e9a1f0b41e872c5 Bug 779139 - Make DOM-facing camera objects cycle collection participants. r=jst
Mike Habicher <mikeh@mozilla.com>
parents:
diff changeset
   508
{
219510
220f9cd8097a7d7b395ab0419c6aa62ae25f7058 Bug 1104055 - fix CameraControl memory leak, r=aosmond
Mike Habicher <mikeh@mozilla.com>
parents: 219181
diff changeset
   509
  THROW_IF_NO_CAMERACONTROL();
144403
614052b6cbcc905dc1e07cb1f40b02c668da7cb5 bug 899210 - convert camera control to WebIDL r=bz
Trevor Saunders <trev.saunders@gmail.com>
parents: 141384
diff changeset
   510
  aRv = mCameraControl->Set(CAMERA_PARAM_WHITEBALANCE, aWhiteBalanceMode);
104262
244bba751ce4ae586d66d28c8e9a1f0b41e872c5 Bug 779139 - Make DOM-facing camera objects cycle collection participants. r=jst
Mike Habicher <mikeh@mozilla.com>
parents:
diff changeset
   511
}
244bba751ce4ae586d66d28c8e9a1f0b41e872c5 Bug 779139 - Make DOM-facing camera objects cycle collection participants. r=jst
Mike Habicher <mikeh@mozilla.com>
parents:
diff changeset
   512
144403
614052b6cbcc905dc1e07cb1f40b02c668da7cb5 bug 899210 - convert camera control to WebIDL r=bz
Trevor Saunders <trev.saunders@gmail.com>
parents: 141384
diff changeset
   513
void
614052b6cbcc905dc1e07cb1f40b02c668da7cb5 bug 899210 - convert camera control to WebIDL r=bz
Trevor Saunders <trev.saunders@gmail.com>
parents: 141384
diff changeset
   514
nsDOMCameraControl::GetSceneMode(nsString& aSceneMode, ErrorResult& aRv)
614052b6cbcc905dc1e07cb1f40b02c668da7cb5 bug 899210 - convert camera control to WebIDL r=bz
Trevor Saunders <trev.saunders@gmail.com>
parents: 141384
diff changeset
   515
{
219510
220f9cd8097a7d7b395ab0419c6aa62ae25f7058 Bug 1104055 - fix CameraControl memory leak, r=aosmond
Mike Habicher <mikeh@mozilla.com>
parents: 219181
diff changeset
   516
  THROW_IF_NO_CAMERACONTROL();
144403
614052b6cbcc905dc1e07cb1f40b02c668da7cb5 bug 899210 - convert camera control to WebIDL r=bz
Trevor Saunders <trev.saunders@gmail.com>
parents: 141384
diff changeset
   517
  aRv = mCameraControl->Get(CAMERA_PARAM_SCENEMODE, aSceneMode);
614052b6cbcc905dc1e07cb1f40b02c668da7cb5 bug 899210 - convert camera control to WebIDL r=bz
Trevor Saunders <trev.saunders@gmail.com>
parents: 141384
diff changeset
   518
}
614052b6cbcc905dc1e07cb1f40b02c668da7cb5 bug 899210 - convert camera control to WebIDL r=bz
Trevor Saunders <trev.saunders@gmail.com>
parents: 141384
diff changeset
   519
void
614052b6cbcc905dc1e07cb1f40b02c668da7cb5 bug 899210 - convert camera control to WebIDL r=bz
Trevor Saunders <trev.saunders@gmail.com>
parents: 141384
diff changeset
   520
nsDOMCameraControl::SetSceneMode(const nsAString& aSceneMode, ErrorResult& aRv)
104262
244bba751ce4ae586d66d28c8e9a1f0b41e872c5 Bug 779139 - Make DOM-facing camera objects cycle collection participants. r=jst
Mike Habicher <mikeh@mozilla.com>
parents:
diff changeset
   521
{
219510
220f9cd8097a7d7b395ab0419c6aa62ae25f7058 Bug 1104055 - fix CameraControl memory leak, r=aosmond
Mike Habicher <mikeh@mozilla.com>
parents: 219181
diff changeset
   522
  THROW_IF_NO_CAMERACONTROL();
144403
614052b6cbcc905dc1e07cb1f40b02c668da7cb5 bug 899210 - convert camera control to WebIDL r=bz
Trevor Saunders <trev.saunders@gmail.com>
parents: 141384
diff changeset
   523
  aRv = mCameraControl->Set(CAMERA_PARAM_SCENEMODE, aSceneMode);
104262
244bba751ce4ae586d66d28c8e9a1f0b41e872c5 Bug 779139 - Make DOM-facing camera objects cycle collection participants. r=jst
Mike Habicher <mikeh@mozilla.com>
parents:
diff changeset
   524
}
144403
614052b6cbcc905dc1e07cb1f40b02c668da7cb5 bug 899210 - convert camera control to WebIDL r=bz
Trevor Saunders <trev.saunders@gmail.com>
parents: 141384
diff changeset
   525
614052b6cbcc905dc1e07cb1f40b02c668da7cb5 bug 899210 - convert camera control to WebIDL r=bz
Trevor Saunders <trev.saunders@gmail.com>
parents: 141384
diff changeset
   526
void
614052b6cbcc905dc1e07cb1f40b02c668da7cb5 bug 899210 - convert camera control to WebIDL r=bz
Trevor Saunders <trev.saunders@gmail.com>
parents: 141384
diff changeset
   527
nsDOMCameraControl::GetFlashMode(nsString& aFlashMode, ErrorResult& aRv)
104262
244bba751ce4ae586d66d28c8e9a1f0b41e872c5 Bug 779139 - Make DOM-facing camera objects cycle collection participants. r=jst
Mike Habicher <mikeh@mozilla.com>
parents:
diff changeset
   528
{
219510
220f9cd8097a7d7b395ab0419c6aa62ae25f7058 Bug 1104055 - fix CameraControl memory leak, r=aosmond
Mike Habicher <mikeh@mozilla.com>
parents: 219181
diff changeset
   529
  THROW_IF_NO_CAMERACONTROL();
144403
614052b6cbcc905dc1e07cb1f40b02c668da7cb5 bug 899210 - convert camera control to WebIDL r=bz
Trevor Saunders <trev.saunders@gmail.com>
parents: 141384
diff changeset
   530
  aRv = mCameraControl->Get(CAMERA_PARAM_FLASHMODE, aFlashMode);
614052b6cbcc905dc1e07cb1f40b02c668da7cb5 bug 899210 - convert camera control to WebIDL r=bz
Trevor Saunders <trev.saunders@gmail.com>
parents: 141384
diff changeset
   531
}
614052b6cbcc905dc1e07cb1f40b02c668da7cb5 bug 899210 - convert camera control to WebIDL r=bz
Trevor Saunders <trev.saunders@gmail.com>
parents: 141384
diff changeset
   532
void
614052b6cbcc905dc1e07cb1f40b02c668da7cb5 bug 899210 - convert camera control to WebIDL r=bz
Trevor Saunders <trev.saunders@gmail.com>
parents: 141384
diff changeset
   533
nsDOMCameraControl::SetFlashMode(const nsAString& aFlashMode, ErrorResult& aRv)
614052b6cbcc905dc1e07cb1f40b02c668da7cb5 bug 899210 - convert camera control to WebIDL r=bz
Trevor Saunders <trev.saunders@gmail.com>
parents: 141384
diff changeset
   534
{
219510
220f9cd8097a7d7b395ab0419c6aa62ae25f7058 Bug 1104055 - fix CameraControl memory leak, r=aosmond
Mike Habicher <mikeh@mozilla.com>
parents: 219181
diff changeset
   535
  THROW_IF_NO_CAMERACONTROL();
144403
614052b6cbcc905dc1e07cb1f40b02c668da7cb5 bug 899210 - convert camera control to WebIDL r=bz
Trevor Saunders <trev.saunders@gmail.com>
parents: 141384
diff changeset
   536
  aRv = mCameraControl->Set(CAMERA_PARAM_FLASHMODE, aFlashMode);
104262
244bba751ce4ae586d66d28c8e9a1f0b41e872c5 Bug 779139 - Make DOM-facing camera objects cycle collection participants. r=jst
Mike Habicher <mikeh@mozilla.com>
parents:
diff changeset
   537
}
244bba751ce4ae586d66d28c8e9a1f0b41e872c5 Bug 779139 - Make DOM-facing camera objects cycle collection participants. r=jst
Mike Habicher <mikeh@mozilla.com>
parents:
diff changeset
   538
144403
614052b6cbcc905dc1e07cb1f40b02c668da7cb5 bug 899210 - convert camera control to WebIDL r=bz
Trevor Saunders <trev.saunders@gmail.com>
parents: 141384
diff changeset
   539
void
614052b6cbcc905dc1e07cb1f40b02c668da7cb5 bug 899210 - convert camera control to WebIDL r=bz
Trevor Saunders <trev.saunders@gmail.com>
parents: 141384
diff changeset
   540
nsDOMCameraControl::GetFocusMode(nsString& aFocusMode, ErrorResult& aRv)
104262
244bba751ce4ae586d66d28c8e9a1f0b41e872c5 Bug 779139 - Make DOM-facing camera objects cycle collection participants. r=jst
Mike Habicher <mikeh@mozilla.com>
parents:
diff changeset
   541
{
219510
220f9cd8097a7d7b395ab0419c6aa62ae25f7058 Bug 1104055 - fix CameraControl memory leak, r=aosmond
Mike Habicher <mikeh@mozilla.com>
parents: 219181
diff changeset
   542
  THROW_IF_NO_CAMERACONTROL();
144403
614052b6cbcc905dc1e07cb1f40b02c668da7cb5 bug 899210 - convert camera control to WebIDL r=bz
Trevor Saunders <trev.saunders@gmail.com>
parents: 141384
diff changeset
   543
  aRv = mCameraControl->Get(CAMERA_PARAM_FOCUSMODE, aFocusMode);
104262
244bba751ce4ae586d66d28c8e9a1f0b41e872c5 Bug 779139 - Make DOM-facing camera objects cycle collection participants. r=jst
Mike Habicher <mikeh@mozilla.com>
parents:
diff changeset
   544
}
144403
614052b6cbcc905dc1e07cb1f40b02c668da7cb5 bug 899210 - convert camera control to WebIDL r=bz
Trevor Saunders <trev.saunders@gmail.com>
parents: 141384
diff changeset
   545
void
614052b6cbcc905dc1e07cb1f40b02c668da7cb5 bug 899210 - convert camera control to WebIDL r=bz
Trevor Saunders <trev.saunders@gmail.com>
parents: 141384
diff changeset
   546
nsDOMCameraControl::SetFocusMode(const nsAString& aFocusMode, ErrorResult& aRv)
104262
244bba751ce4ae586d66d28c8e9a1f0b41e872c5 Bug 779139 - Make DOM-facing camera objects cycle collection participants. r=jst
Mike Habicher <mikeh@mozilla.com>
parents:
diff changeset
   547
{
219510
220f9cd8097a7d7b395ab0419c6aa62ae25f7058 Bug 1104055 - fix CameraControl memory leak, r=aosmond
Mike Habicher <mikeh@mozilla.com>
parents: 219181
diff changeset
   548
  THROW_IF_NO_CAMERACONTROL();
144403
614052b6cbcc905dc1e07cb1f40b02c668da7cb5 bug 899210 - convert camera control to WebIDL r=bz
Trevor Saunders <trev.saunders@gmail.com>
parents: 141384
diff changeset
   549
  aRv = mCameraControl->Set(CAMERA_PARAM_FOCUSMODE, aFocusMode);
104262
244bba751ce4ae586d66d28c8e9a1f0b41e872c5 Bug 779139 - Make DOM-facing camera objects cycle collection participants. r=jst
Mike Habicher <mikeh@mozilla.com>
parents:
diff changeset
   550
}
244bba751ce4ae586d66d28c8e9a1f0b41e872c5 Bug 779139 - Make DOM-facing camera objects cycle collection participants. r=jst
Mike Habicher <mikeh@mozilla.com>
parents:
diff changeset
   551
172435
26779ad44626f8566f970247758465a4fabded16 Bug 965425 - expose ISO setting, r=dhylands,jst
Mike Habicher <mikeh@mozilla.com>
parents: 172425
diff changeset
   552
void
26779ad44626f8566f970247758465a4fabded16 Bug 965425 - expose ISO setting, r=dhylands,jst
Mike Habicher <mikeh@mozilla.com>
parents: 172425
diff changeset
   553
nsDOMCameraControl::GetIsoMode(nsString& aIsoMode, ErrorResult& aRv)
26779ad44626f8566f970247758465a4fabded16 Bug 965425 - expose ISO setting, r=dhylands,jst
Mike Habicher <mikeh@mozilla.com>
parents: 172425
diff changeset
   554
{
219510
220f9cd8097a7d7b395ab0419c6aa62ae25f7058 Bug 1104055 - fix CameraControl memory leak, r=aosmond
Mike Habicher <mikeh@mozilla.com>
parents: 219181
diff changeset
   555
  THROW_IF_NO_CAMERACONTROL();
172435
26779ad44626f8566f970247758465a4fabded16 Bug 965425 - expose ISO setting, r=dhylands,jst
Mike Habicher <mikeh@mozilla.com>
parents: 172425
diff changeset
   556
  aRv = mCameraControl->Get(CAMERA_PARAM_ISOMODE, aIsoMode);
26779ad44626f8566f970247758465a4fabded16 Bug 965425 - expose ISO setting, r=dhylands,jst
Mike Habicher <mikeh@mozilla.com>
parents: 172425
diff changeset
   557
}
26779ad44626f8566f970247758465a4fabded16 Bug 965425 - expose ISO setting, r=dhylands,jst
Mike Habicher <mikeh@mozilla.com>
parents: 172425
diff changeset
   558
void
26779ad44626f8566f970247758465a4fabded16 Bug 965425 - expose ISO setting, r=dhylands,jst
Mike Habicher <mikeh@mozilla.com>
parents: 172425
diff changeset
   559
nsDOMCameraControl::SetIsoMode(const nsAString& aIsoMode, ErrorResult& aRv)
26779ad44626f8566f970247758465a4fabded16 Bug 965425 - expose ISO setting, r=dhylands,jst
Mike Habicher <mikeh@mozilla.com>
parents: 172425
diff changeset
   560
{
219510
220f9cd8097a7d7b395ab0419c6aa62ae25f7058 Bug 1104055 - fix CameraControl memory leak, r=aosmond
Mike Habicher <mikeh@mozilla.com>
parents: 219181
diff changeset
   561
  THROW_IF_NO_CAMERACONTROL();
172435
26779ad44626f8566f970247758465a4fabded16 Bug 965425 - expose ISO setting, r=dhylands,jst
Mike Habicher <mikeh@mozilla.com>
parents: 172425
diff changeset
   562
  aRv = mCameraControl->Set(CAMERA_PARAM_ISOMODE, aIsoMode);
26779ad44626f8566f970247758465a4fabded16 Bug 965425 - expose ISO setting, r=dhylands,jst
Mike Habicher <mikeh@mozilla.com>
parents: 172425
diff changeset
   563
}
26779ad44626f8566f970247758465a4fabded16 Bug 965425 - expose ISO setting, r=dhylands,jst
Mike Habicher <mikeh@mozilla.com>
parents: 172425
diff changeset
   564
144403
614052b6cbcc905dc1e07cb1f40b02c668da7cb5 bug 899210 - convert camera control to WebIDL r=bz
Trevor Saunders <trev.saunders@gmail.com>
parents: 141384
diff changeset
   565
double
201444
10412cc35ca4a8a925c4fbf159c13dd74e0b3d62 Bug 981318 - expose compressed image quality setting, r=dhylands,khuey
Mike Habicher <mikeh@mozilla.com>
parents: 197900
diff changeset
   566
nsDOMCameraControl::GetPictureQuality(ErrorResult& aRv)
10412cc35ca4a8a925c4fbf159c13dd74e0b3d62 Bug 981318 - expose compressed image quality setting, r=dhylands,khuey
Mike Habicher <mikeh@mozilla.com>
parents: 197900
diff changeset
   567
{
219510
220f9cd8097a7d7b395ab0419c6aa62ae25f7058 Bug 1104055 - fix CameraControl memory leak, r=aosmond
Mike Habicher <mikeh@mozilla.com>
parents: 219181
diff changeset
   568
  THROW_IF_NO_CAMERACONTROL(1.0);
201444
10412cc35ca4a8a925c4fbf159c13dd74e0b3d62 Bug 981318 - expose compressed image quality setting, r=dhylands,khuey
Mike Habicher <mikeh@mozilla.com>
parents: 197900
diff changeset
   569
10412cc35ca4a8a925c4fbf159c13dd74e0b3d62 Bug 981318 - expose compressed image quality setting, r=dhylands,khuey
Mike Habicher <mikeh@mozilla.com>
parents: 197900
diff changeset
   570
  double quality;
10412cc35ca4a8a925c4fbf159c13dd74e0b3d62 Bug 981318 - expose compressed image quality setting, r=dhylands,khuey
Mike Habicher <mikeh@mozilla.com>
parents: 197900
diff changeset
   571
  aRv = mCameraControl->Get(CAMERA_PARAM_PICTURE_QUALITY, quality);
10412cc35ca4a8a925c4fbf159c13dd74e0b3d62 Bug 981318 - expose compressed image quality setting, r=dhylands,khuey
Mike Habicher <mikeh@mozilla.com>
parents: 197900
diff changeset
   572
  return quality;
10412cc35ca4a8a925c4fbf159c13dd74e0b3d62 Bug 981318 - expose compressed image quality setting, r=dhylands,khuey
Mike Habicher <mikeh@mozilla.com>
parents: 197900
diff changeset
   573
}
10412cc35ca4a8a925c4fbf159c13dd74e0b3d62 Bug 981318 - expose compressed image quality setting, r=dhylands,khuey
Mike Habicher <mikeh@mozilla.com>
parents: 197900
diff changeset
   574
void
10412cc35ca4a8a925c4fbf159c13dd74e0b3d62 Bug 981318 - expose compressed image quality setting, r=dhylands,khuey
Mike Habicher <mikeh@mozilla.com>
parents: 197900
diff changeset
   575
nsDOMCameraControl::SetPictureQuality(double aQuality, ErrorResult& aRv)
10412cc35ca4a8a925c4fbf159c13dd74e0b3d62 Bug 981318 - expose compressed image quality setting, r=dhylands,khuey
Mike Habicher <mikeh@mozilla.com>
parents: 197900
diff changeset
   576
{
219510
220f9cd8097a7d7b395ab0419c6aa62ae25f7058 Bug 1104055 - fix CameraControl memory leak, r=aosmond
Mike Habicher <mikeh@mozilla.com>
parents: 219181
diff changeset
   577
  THROW_IF_NO_CAMERACONTROL();
201444
10412cc35ca4a8a925c4fbf159c13dd74e0b3d62 Bug 981318 - expose compressed image quality setting, r=dhylands,khuey
Mike Habicher <mikeh@mozilla.com>
parents: 197900
diff changeset
   578
  aRv = mCameraControl->Set(CAMERA_PARAM_PICTURE_QUALITY, aQuality);
10412cc35ca4a8a925c4fbf159c13dd74e0b3d62 Bug 981318 - expose compressed image quality setting, r=dhylands,khuey
Mike Habicher <mikeh@mozilla.com>
parents: 197900
diff changeset
   579
}
10412cc35ca4a8a925c4fbf159c13dd74e0b3d62 Bug 981318 - expose compressed image quality setting, r=dhylands,khuey
Mike Habicher <mikeh@mozilla.com>
parents: 197900
diff changeset
   580
219511
cf975e8c033d40aaac9c6bd0c09fac6e3cc305a6 Bug 1052821 - expose exposure metering modes to JS, r=aosmond,bz
Mike Habicher <mikeh@mozilla.com>
parents: 219510
diff changeset
   581
void
cf975e8c033d40aaac9c6bd0c09fac6e3cc305a6 Bug 1052821 - expose exposure metering modes to JS, r=aosmond,bz
Mike Habicher <mikeh@mozilla.com>
parents: 219510
diff changeset
   582
nsDOMCameraControl::GetMeteringMode(nsString& aMode, ErrorResult& aRv)
cf975e8c033d40aaac9c6bd0c09fac6e3cc305a6 Bug 1052821 - expose exposure metering modes to JS, r=aosmond,bz
Mike Habicher <mikeh@mozilla.com>
parents: 219510
diff changeset
   583
{
cf975e8c033d40aaac9c6bd0c09fac6e3cc305a6 Bug 1052821 - expose exposure metering modes to JS, r=aosmond,bz
Mike Habicher <mikeh@mozilla.com>
parents: 219510
diff changeset
   584
  THROW_IF_NO_CAMERACONTROL();
cf975e8c033d40aaac9c6bd0c09fac6e3cc305a6 Bug 1052821 - expose exposure metering modes to JS, r=aosmond,bz
Mike Habicher <mikeh@mozilla.com>
parents: 219510
diff changeset
   585
  aRv = mCameraControl->Get(CAMERA_PARAM_METERINGMODE, aMode);
cf975e8c033d40aaac9c6bd0c09fac6e3cc305a6 Bug 1052821 - expose exposure metering modes to JS, r=aosmond,bz
Mike Habicher <mikeh@mozilla.com>
parents: 219510
diff changeset
   586
}
cf975e8c033d40aaac9c6bd0c09fac6e3cc305a6 Bug 1052821 - expose exposure metering modes to JS, r=aosmond,bz
Mike Habicher <mikeh@mozilla.com>
parents: 219510
diff changeset
   587
void
cf975e8c033d40aaac9c6bd0c09fac6e3cc305a6 Bug 1052821 - expose exposure metering modes to JS, r=aosmond,bz
Mike Habicher <mikeh@mozilla.com>
parents: 219510
diff changeset
   588
nsDOMCameraControl::SetMeteringMode(const nsAString& aMode, ErrorResult& aRv)
cf975e8c033d40aaac9c6bd0c09fac6e3cc305a6 Bug 1052821 - expose exposure metering modes to JS, r=aosmond,bz
Mike Habicher <mikeh@mozilla.com>
parents: 219510
diff changeset
   589
{
cf975e8c033d40aaac9c6bd0c09fac6e3cc305a6 Bug 1052821 - expose exposure metering modes to JS, r=aosmond,bz
Mike Habicher <mikeh@mozilla.com>
parents: 219510
diff changeset
   590
  THROW_IF_NO_CAMERACONTROL();
cf975e8c033d40aaac9c6bd0c09fac6e3cc305a6 Bug 1052821 - expose exposure metering modes to JS, r=aosmond,bz
Mike Habicher <mikeh@mozilla.com>
parents: 219510
diff changeset
   591
  aRv = mCameraControl->Set(CAMERA_PARAM_METERINGMODE, aMode);
cf975e8c033d40aaac9c6bd0c09fac6e3cc305a6 Bug 1052821 - expose exposure metering modes to JS, r=aosmond,bz
Mike Habicher <mikeh@mozilla.com>
parents: 219510
diff changeset
   592
}
cf975e8c033d40aaac9c6bd0c09fac6e3cc305a6 Bug 1052821 - expose exposure metering modes to JS, r=aosmond,bz
Mike Habicher <mikeh@mozilla.com>
parents: 219510
diff changeset
   593
201444
10412cc35ca4a8a925c4fbf159c13dd74e0b3d62 Bug 981318 - expose compressed image quality setting, r=dhylands,khuey
Mike Habicher <mikeh@mozilla.com>
parents: 197900
diff changeset
   594
double
144403
614052b6cbcc905dc1e07cb1f40b02c668da7cb5 bug 899210 - convert camera control to WebIDL r=bz
Trevor Saunders <trev.saunders@gmail.com>
parents: 141384
diff changeset
   595
nsDOMCameraControl::GetZoom(ErrorResult& aRv)
104262
244bba751ce4ae586d66d28c8e9a1f0b41e872c5 Bug 779139 - Make DOM-facing camera objects cycle collection participants. r=jst
Mike Habicher <mikeh@mozilla.com>
parents:
diff changeset
   596
{
219510
220f9cd8097a7d7b395ab0419c6aa62ae25f7058 Bug 1104055 - fix CameraControl memory leak, r=aosmond
Mike Habicher <mikeh@mozilla.com>
parents: 219181
diff changeset
   597
  THROW_IF_NO_CAMERACONTROL(1.0);
168993
e93e96ed8a5ad4999e272e2a3180a32e1ffdf94d Bug 909542 - refactor CameraControl API, r=dhylands,jst,jesup,onecyrenus
Mike Habicher <mikeh@mozilla.com>
parents: 168958
diff changeset
   598
201444
10412cc35ca4a8a925c4fbf159c13dd74e0b3d62 Bug 981318 - expose compressed image quality setting, r=dhylands,khuey
Mike Habicher <mikeh@mozilla.com>
parents: 197900
diff changeset
   599
  double zoom = 1.0;
168993
e93e96ed8a5ad4999e272e2a3180a32e1ffdf94d Bug 909542 - refactor CameraControl API, r=dhylands,jst,jesup,onecyrenus
Mike Habicher <mikeh@mozilla.com>
parents: 168958
diff changeset
   600
  aRv = mCameraControl->Get(CAMERA_PARAM_ZOOM, zoom);
144403
614052b6cbcc905dc1e07cb1f40b02c668da7cb5 bug 899210 - convert camera control to WebIDL r=bz
Trevor Saunders <trev.saunders@gmail.com>
parents: 141384
diff changeset
   601
  return zoom;
104262
244bba751ce4ae586d66d28c8e9a1f0b41e872c5 Bug 779139 - Make DOM-facing camera objects cycle collection participants. r=jst
Mike Habicher <mikeh@mozilla.com>
parents:
diff changeset
   602
}
244bba751ce4ae586d66d28c8e9a1f0b41e872c5 Bug 779139 - Make DOM-facing camera objects cycle collection participants. r=jst
Mike Habicher <mikeh@mozilla.com>
parents:
diff changeset
   603
144403
614052b6cbcc905dc1e07cb1f40b02c668da7cb5 bug 899210 - convert camera control to WebIDL r=bz
Trevor Saunders <trev.saunders@gmail.com>
parents: 141384
diff changeset
   604
void
614052b6cbcc905dc1e07cb1f40b02c668da7cb5 bug 899210 - convert camera control to WebIDL r=bz
Trevor Saunders <trev.saunders@gmail.com>
parents: 141384
diff changeset
   605
nsDOMCameraControl::SetZoom(double aZoom, ErrorResult& aRv)
104262
244bba751ce4ae586d66d28c8e9a1f0b41e872c5 Bug 779139 - Make DOM-facing camera objects cycle collection participants. r=jst
Mike Habicher <mikeh@mozilla.com>
parents:
diff changeset
   606
{
219510
220f9cd8097a7d7b395ab0419c6aa62ae25f7058 Bug 1104055 - fix CameraControl memory leak, r=aosmond
Mike Habicher <mikeh@mozilla.com>
parents: 219181
diff changeset
   607
  THROW_IF_NO_CAMERACONTROL();
144403
614052b6cbcc905dc1e07cb1f40b02c668da7cb5 bug 899210 - convert camera control to WebIDL r=bz
Trevor Saunders <trev.saunders@gmail.com>
parents: 141384
diff changeset
   608
  aRv = mCameraControl->Set(CAMERA_PARAM_ZOOM, aZoom);
104262
244bba751ce4ae586d66d28c8e9a1f0b41e872c5 Bug 779139 - Make DOM-facing camera objects cycle collection participants. r=jst
Mike Habicher <mikeh@mozilla.com>
parents:
diff changeset
   609
}
244bba751ce4ae586d66d28c8e9a1f0b41e872c5 Bug 779139 - Make DOM-facing camera objects cycle collection participants. r=jst
Mike Habicher <mikeh@mozilla.com>
parents:
diff changeset
   610
181171
3be37517e25971e3220499fe7f78649b7f8024ac Bug 987954 - Change camera control size/region attributes to methods to remove direct JS_*() calls, r=bz,mikeh
Andrew Osmond <aosmond@gmail.com>
parents: 180888
diff changeset
   611
void
3be37517e25971e3220499fe7f78649b7f8024ac Bug 987954 - Change camera control size/region attributes to methods to remove direct JS_*() calls, r=bz,mikeh
Andrew Osmond <aosmond@gmail.com>
parents: 180888
diff changeset
   612
nsDOMCameraControl::GetMeteringAreas(nsTArray<CameraRegion>& aAreas, ErrorResult& aRv)
104262
244bba751ce4ae586d66d28c8e9a1f0b41e872c5 Bug 779139 - Make DOM-facing camera objects cycle collection participants. r=jst
Mike Habicher <mikeh@mozilla.com>
parents:
diff changeset
   613
{
181171
3be37517e25971e3220499fe7f78649b7f8024ac Bug 987954 - Change camera control size/region attributes to methods to remove direct JS_*() calls, r=bz,mikeh
Andrew Osmond <aosmond@gmail.com>
parents: 180888
diff changeset
   614
  aRv = Get(CAMERA_PARAM_METERINGAREAS, aAreas);
3be37517e25971e3220499fe7f78649b7f8024ac Bug 987954 - Change camera control size/region attributes to methods to remove direct JS_*() calls, r=bz,mikeh
Andrew Osmond <aosmond@gmail.com>
parents: 180888
diff changeset
   615
}
3be37517e25971e3220499fe7f78649b7f8024ac Bug 987954 - Change camera control size/region attributes to methods to remove direct JS_*() calls, r=bz,mikeh
Andrew Osmond <aosmond@gmail.com>
parents: 180888
diff changeset
   616
void
3be37517e25971e3220499fe7f78649b7f8024ac Bug 987954 - Change camera control size/region attributes to methods to remove direct JS_*() calls, r=bz,mikeh
Andrew Osmond <aosmond@gmail.com>
parents: 180888
diff changeset
   617
nsDOMCameraControl::SetMeteringAreas(const Optional<Sequence<CameraRegion> >& aMeteringAreas, ErrorResult& aRv)
3be37517e25971e3220499fe7f78649b7f8024ac Bug 987954 - Change camera control size/region attributes to methods to remove direct JS_*() calls, r=bz,mikeh
Andrew Osmond <aosmond@gmail.com>
parents: 180888
diff changeset
   618
{
3be37517e25971e3220499fe7f78649b7f8024ac Bug 987954 - Change camera control size/region attributes to methods to remove direct JS_*() calls, r=bz,mikeh
Andrew Osmond <aosmond@gmail.com>
parents: 180888
diff changeset
   619
  aRv = Set(CAMERA_PARAM_METERINGAREAS, aMeteringAreas,
3be37517e25971e3220499fe7f78649b7f8024ac Bug 987954 - Change camera control size/region attributes to methods to remove direct JS_*() calls, r=bz,mikeh
Andrew Osmond <aosmond@gmail.com>
parents: 180888
diff changeset
   620
            mCurrentConfiguration->mMaxMeteringAreas);
180288
27b41f71ccd4475f9fac798e9604b4b5271d5ce8 Bug 987954 - Change camera control size/region attributes to methods to remove direct JS_*() calls, r=bz,mikeh
Andrew Osmond <aosmond@gmail.com>
parents: 180287
diff changeset
   621
}
180299
33a615530ab17a6068f45a7ead9ec1f25ef01774 Backed out changeset 27b41f71ccd4 (bug 987954) for mochitest-5 orange
Wes Kocher <wkocher@mozilla.com>
parents: 180288
diff changeset
   622
180288
27b41f71ccd4475f9fac798e9604b4b5271d5ce8 Bug 987954 - Change camera control size/region attributes to methods to remove direct JS_*() calls, r=bz,mikeh
Andrew Osmond <aosmond@gmail.com>
parents: 180287
diff changeset
   623
void
181171
3be37517e25971e3220499fe7f78649b7f8024ac Bug 987954 - Change camera control size/region attributes to methods to remove direct JS_*() calls, r=bz,mikeh
Andrew Osmond <aosmond@gmail.com>
parents: 180888
diff changeset
   624
nsDOMCameraControl::GetFocusAreas(nsTArray<CameraRegion>& aAreas, ErrorResult& aRv)
180288
27b41f71ccd4475f9fac798e9604b4b5271d5ce8 Bug 987954 - Change camera control size/region attributes to methods to remove direct JS_*() calls, r=bz,mikeh
Andrew Osmond <aosmond@gmail.com>
parents: 180287
diff changeset
   625
{
181171
3be37517e25971e3220499fe7f78649b7f8024ac Bug 987954 - Change camera control size/region attributes to methods to remove direct JS_*() calls, r=bz,mikeh
Andrew Osmond <aosmond@gmail.com>
parents: 180888
diff changeset
   626
  aRv = Get(CAMERA_PARAM_FOCUSAREAS, aAreas);
104262
244bba751ce4ae586d66d28c8e9a1f0b41e872c5 Bug 779139 - Make DOM-facing camera objects cycle collection participants. r=jst
Mike Habicher <mikeh@mozilla.com>
parents:
diff changeset
   627
}
144403
614052b6cbcc905dc1e07cb1f40b02c668da7cb5 bug 899210 - convert camera control to WebIDL r=bz
Trevor Saunders <trev.saunders@gmail.com>
parents: 141384
diff changeset
   628
void
181171
3be37517e25971e3220499fe7f78649b7f8024ac Bug 987954 - Change camera control size/region attributes to methods to remove direct JS_*() calls, r=bz,mikeh
Andrew Osmond <aosmond@gmail.com>
parents: 180888
diff changeset
   629
nsDOMCameraControl::SetFocusAreas(const Optional<Sequence<CameraRegion> >& aFocusAreas, ErrorResult& aRv)
104262
244bba751ce4ae586d66d28c8e9a1f0b41e872c5 Bug 779139 - Make DOM-facing camera objects cycle collection participants. r=jst
Mike Habicher <mikeh@mozilla.com>
parents:
diff changeset
   630
{
181171
3be37517e25971e3220499fe7f78649b7f8024ac Bug 987954 - Change camera control size/region attributes to methods to remove direct JS_*() calls, r=bz,mikeh
Andrew Osmond <aosmond@gmail.com>
parents: 180888
diff changeset
   631
  aRv = Set(CAMERA_PARAM_FOCUSAREAS, aFocusAreas,
168993
e93e96ed8a5ad4999e272e2a3180a32e1ffdf94d Bug 909542 - refactor CameraControl API, r=dhylands,jst,jesup,onecyrenus
Mike Habicher <mikeh@mozilla.com>
parents: 168958
diff changeset
   632
            mCurrentConfiguration->mMaxFocusAreas);
104262
244bba751ce4ae586d66d28c8e9a1f0b41e872c5 Bug 779139 - Make DOM-facing camera objects cycle collection participants. r=jst
Mike Habicher <mikeh@mozilla.com>
parents:
diff changeset
   633
}
244bba751ce4ae586d66d28c8e9a1f0b41e872c5 Bug 779139 - Make DOM-facing camera objects cycle collection participants. r=jst
Mike Habicher <mikeh@mozilla.com>
parents:
diff changeset
   634
181171
3be37517e25971e3220499fe7f78649b7f8024ac Bug 987954 - Change camera control size/region attributes to methods to remove direct JS_*() calls, r=bz,mikeh
Andrew Osmond <aosmond@gmail.com>
parents: 180888
diff changeset
   635
void
3be37517e25971e3220499fe7f78649b7f8024ac Bug 987954 - Change camera control size/region attributes to methods to remove direct JS_*() calls, r=bz,mikeh
Andrew Osmond <aosmond@gmail.com>
parents: 180888
diff changeset
   636
nsDOMCameraControl::GetPictureSize(CameraSize& aSize, ErrorResult& aRv)
3be37517e25971e3220499fe7f78649b7f8024ac Bug 987954 - Change camera control size/region attributes to methods to remove direct JS_*() calls, r=bz,mikeh
Andrew Osmond <aosmond@gmail.com>
parents: 180888
diff changeset
   637
{
219510
220f9cd8097a7d7b395ab0419c6aa62ae25f7058 Bug 1104055 - fix CameraControl memory leak, r=aosmond
Mike Habicher <mikeh@mozilla.com>
parents: 219181
diff changeset
   638
  THROW_IF_NO_CAMERACONTROL();
220f9cd8097a7d7b395ab0419c6aa62ae25f7058 Bug 1104055 - fix CameraControl memory leak, r=aosmond
Mike Habicher <mikeh@mozilla.com>
parents: 219181
diff changeset
   639
181171
3be37517e25971e3220499fe7f78649b7f8024ac Bug 987954 - Change camera control size/region attributes to methods to remove direct JS_*() calls, r=bz,mikeh
Andrew Osmond <aosmond@gmail.com>
parents: 180888
diff changeset
   640
  ICameraControl::Size size;
3be37517e25971e3220499fe7f78649b7f8024ac Bug 987954 - Change camera control size/region attributes to methods to remove direct JS_*() calls, r=bz,mikeh
Andrew Osmond <aosmond@gmail.com>
parents: 180888
diff changeset
   641
  aRv = mCameraControl->Get(CAMERA_PARAM_PICTURE_SIZE, size);
3be37517e25971e3220499fe7f78649b7f8024ac Bug 987954 - Change camera control size/region attributes to methods to remove direct JS_*() calls, r=bz,mikeh
Andrew Osmond <aosmond@gmail.com>
parents: 180888
diff changeset
   642
  if (aRv.Failed()) {
3be37517e25971e3220499fe7f78649b7f8024ac Bug 987954 - Change camera control size/region attributes to methods to remove direct JS_*() calls, r=bz,mikeh
Andrew Osmond <aosmond@gmail.com>
parents: 180888
diff changeset
   643
    return;
3be37517e25971e3220499fe7f78649b7f8024ac Bug 987954 - Change camera control size/region attributes to methods to remove direct JS_*() calls, r=bz,mikeh
Andrew Osmond <aosmond@gmail.com>
parents: 180888
diff changeset
   644
  }
3be37517e25971e3220499fe7f78649b7f8024ac Bug 987954 - Change camera control size/region attributes to methods to remove direct JS_*() calls, r=bz,mikeh
Andrew Osmond <aosmond@gmail.com>
parents: 180888
diff changeset
   645
3be37517e25971e3220499fe7f78649b7f8024ac Bug 987954 - Change camera control size/region attributes to methods to remove direct JS_*() calls, r=bz,mikeh
Andrew Osmond <aosmond@gmail.com>
parents: 180888
diff changeset
   646
  aSize.mWidth = size.width;
3be37517e25971e3220499fe7f78649b7f8024ac Bug 987954 - Change camera control size/region attributes to methods to remove direct JS_*() calls, r=bz,mikeh
Andrew Osmond <aosmond@gmail.com>
parents: 180888
diff changeset
   647
  aSize.mHeight = size.height;
3be37517e25971e3220499fe7f78649b7f8024ac Bug 987954 - Change camera control size/region attributes to methods to remove direct JS_*() calls, r=bz,mikeh
Andrew Osmond <aosmond@gmail.com>
parents: 180888
diff changeset
   648
}
186910
4cffd9f9279181e1f4467f532b2c1f494de5d4ab Bug 1004588 - remove deprecated and unused ICameraControl::Size attributes, r=bz
Mike Habicher <mikeh@mozilla.com>
parents: 185695
diff changeset
   649
181171
3be37517e25971e3220499fe7f78649b7f8024ac Bug 987954 - Change camera control size/region attributes to methods to remove direct JS_*() calls, r=bz,mikeh
Andrew Osmond <aosmond@gmail.com>
parents: 180888
diff changeset
   650
void
3be37517e25971e3220499fe7f78649b7f8024ac Bug 987954 - Change camera control size/region attributes to methods to remove direct JS_*() calls, r=bz,mikeh
Andrew Osmond <aosmond@gmail.com>
parents: 180888
diff changeset
   651
nsDOMCameraControl::SetPictureSize(const CameraSize& aSize, ErrorResult& aRv)
3be37517e25971e3220499fe7f78649b7f8024ac Bug 987954 - Change camera control size/region attributes to methods to remove direct JS_*() calls, r=bz,mikeh
Andrew Osmond <aosmond@gmail.com>
parents: 180888
diff changeset
   652
{
219510
220f9cd8097a7d7b395ab0419c6aa62ae25f7058 Bug 1104055 - fix CameraControl memory leak, r=aosmond
Mike Habicher <mikeh@mozilla.com>
parents: 219181
diff changeset
   653
  THROW_IF_NO_CAMERACONTROL();
181171
3be37517e25971e3220499fe7f78649b7f8024ac Bug 987954 - Change camera control size/region attributes to methods to remove direct JS_*() calls, r=bz,mikeh
Andrew Osmond <aosmond@gmail.com>
parents: 180888
diff changeset
   654
  ICameraControl::Size s = { aSize.mWidth, aSize.mHeight };
3be37517e25971e3220499fe7f78649b7f8024ac Bug 987954 - Change camera control size/region attributes to methods to remove direct JS_*() calls, r=bz,mikeh
Andrew Osmond <aosmond@gmail.com>
parents: 180888
diff changeset
   655
  aRv = mCameraControl->Set(CAMERA_PARAM_PICTURE_SIZE, s);
3be37517e25971e3220499fe7f78649b7f8024ac Bug 987954 - Change camera control size/region attributes to methods to remove direct JS_*() calls, r=bz,mikeh
Andrew Osmond <aosmond@gmail.com>
parents: 180888
diff changeset
   656
}
3be37517e25971e3220499fe7f78649b7f8024ac Bug 987954 - Change camera control size/region attributes to methods to remove direct JS_*() calls, r=bz,mikeh
Andrew Osmond <aosmond@gmail.com>
parents: 180888
diff changeset
   657
3be37517e25971e3220499fe7f78649b7f8024ac Bug 987954 - Change camera control size/region attributes to methods to remove direct JS_*() calls, r=bz,mikeh
Andrew Osmond <aosmond@gmail.com>
parents: 180888
diff changeset
   658
void
3be37517e25971e3220499fe7f78649b7f8024ac Bug 987954 - Change camera control size/region attributes to methods to remove direct JS_*() calls, r=bz,mikeh
Andrew Osmond <aosmond@gmail.com>
parents: 180888
diff changeset
   659
nsDOMCameraControl::GetThumbnailSize(CameraSize& aSize, ErrorResult& aRv)
3be37517e25971e3220499fe7f78649b7f8024ac Bug 987954 - Change camera control size/region attributes to methods to remove direct JS_*() calls, r=bz,mikeh
Andrew Osmond <aosmond@gmail.com>
parents: 180888
diff changeset
   660
{
219510
220f9cd8097a7d7b395ab0419c6aa62ae25f7058 Bug 1104055 - fix CameraControl memory leak, r=aosmond
Mike Habicher <mikeh@mozilla.com>
parents: 219181
diff changeset
   661
  THROW_IF_NO_CAMERACONTROL();
181171
3be37517e25971e3220499fe7f78649b7f8024ac Bug 987954 - Change camera control size/region attributes to methods to remove direct JS_*() calls, r=bz,mikeh
Andrew Osmond <aosmond@gmail.com>
parents: 180888
diff changeset
   662
  ICameraControl::Size size;
3be37517e25971e3220499fe7f78649b7f8024ac Bug 987954 - Change camera control size/region attributes to methods to remove direct JS_*() calls, r=bz,mikeh
Andrew Osmond <aosmond@gmail.com>
parents: 180888
diff changeset
   663
  aRv = mCameraControl->Get(CAMERA_PARAM_THUMBNAILSIZE, size);
3be37517e25971e3220499fe7f78649b7f8024ac Bug 987954 - Change camera control size/region attributes to methods to remove direct JS_*() calls, r=bz,mikeh
Andrew Osmond <aosmond@gmail.com>
parents: 180888
diff changeset
   664
  if (aRv.Failed()) {
3be37517e25971e3220499fe7f78649b7f8024ac Bug 987954 - Change camera control size/region attributes to methods to remove direct JS_*() calls, r=bz,mikeh
Andrew Osmond <aosmond@gmail.com>
parents: 180888
diff changeset
   665
    return;
3be37517e25971e3220499fe7f78649b7f8024ac Bug 987954 - Change camera control size/region attributes to methods to remove direct JS_*() calls, r=bz,mikeh
Andrew Osmond <aosmond@gmail.com>
parents: 180888
diff changeset
   666
  }
3be37517e25971e3220499fe7f78649b7f8024ac Bug 987954 - Change camera control size/region attributes to methods to remove direct JS_*() calls, r=bz,mikeh
Andrew Osmond <aosmond@gmail.com>
parents: 180888
diff changeset
   667
3be37517e25971e3220499fe7f78649b7f8024ac Bug 987954 - Change camera control size/region attributes to methods to remove direct JS_*() calls, r=bz,mikeh
Andrew Osmond <aosmond@gmail.com>
parents: 180888
diff changeset
   668
  aSize.mWidth = size.width;
3be37517e25971e3220499fe7f78649b7f8024ac Bug 987954 - Change camera control size/region attributes to methods to remove direct JS_*() calls, r=bz,mikeh
Andrew Osmond <aosmond@gmail.com>
parents: 180888
diff changeset
   669
  aSize.mHeight = size.height;
3be37517e25971e3220499fe7f78649b7f8024ac Bug 987954 - Change camera control size/region attributes to methods to remove direct JS_*() calls, r=bz,mikeh
Andrew Osmond <aosmond@gmail.com>
parents: 180888
diff changeset
   670
}
186910
4cffd9f9279181e1f4467f532b2c1f494de5d4ab Bug 1004588 - remove deprecated and unused ICameraControl::Size attributes, r=bz
Mike Habicher <mikeh@mozilla.com>
parents: 185695
diff changeset
   671
181171
3be37517e25971e3220499fe7f78649b7f8024ac Bug 987954 - Change camera control size/region attributes to methods to remove direct JS_*() calls, r=bz,mikeh
Andrew Osmond <aosmond@gmail.com>
parents: 180888
diff changeset
   672
void
3be37517e25971e3220499fe7f78649b7f8024ac Bug 987954 - Change camera control size/region attributes to methods to remove direct JS_*() calls, r=bz,mikeh
Andrew Osmond <aosmond@gmail.com>
parents: 180888
diff changeset
   673
nsDOMCameraControl::SetThumbnailSize(const CameraSize& aSize, ErrorResult& aRv)
3be37517e25971e3220499fe7f78649b7f8024ac Bug 987954 - Change camera control size/region attributes to methods to remove direct JS_*() calls, r=bz,mikeh
Andrew Osmond <aosmond@gmail.com>
parents: 180888
diff changeset
   674
{
219510
220f9cd8097a7d7b395ab0419c6aa62ae25f7058 Bug 1104055 - fix CameraControl memory leak, r=aosmond
Mike Habicher <mikeh@mozilla.com>
parents: 219181
diff changeset
   675
  THROW_IF_NO_CAMERACONTROL();
181171
3be37517e25971e3220499fe7f78649b7f8024ac Bug 987954 - Change camera control size/region attributes to methods to remove direct JS_*() calls, r=bz,mikeh
Andrew Osmond <aosmond@gmail.com>
parents: 180888
diff changeset
   676
  ICameraControl::Size s = { aSize.mWidth, aSize.mHeight };
3be37517e25971e3220499fe7f78649b7f8024ac Bug 987954 - Change camera control size/region attributes to methods to remove direct JS_*() calls, r=bz,mikeh
Andrew Osmond <aosmond@gmail.com>
parents: 180888
diff changeset
   677
  aRv = mCameraControl->Set(CAMERA_PARAM_THUMBNAILSIZE, s);
3be37517e25971e3220499fe7f78649b7f8024ac Bug 987954 - Change camera control size/region attributes to methods to remove direct JS_*() calls, r=bz,mikeh
Andrew Osmond <aosmond@gmail.com>
parents: 180888
diff changeset
   678
}
3be37517e25971e3220499fe7f78649b7f8024ac Bug 987954 - Change camera control size/region attributes to methods to remove direct JS_*() calls, r=bz,mikeh
Andrew Osmond <aosmond@gmail.com>
parents: 180888
diff changeset
   679
144403
614052b6cbcc905dc1e07cb1f40b02c668da7cb5 bug 899210 - convert camera control to WebIDL r=bz
Trevor Saunders <trev.saunders@gmail.com>
parents: 141384
diff changeset
   680
double
614052b6cbcc905dc1e07cb1f40b02c668da7cb5 bug 899210 - convert camera control to WebIDL r=bz
Trevor Saunders <trev.saunders@gmail.com>
parents: 141384
diff changeset
   681
nsDOMCameraControl::GetFocalLength(ErrorResult& aRv)
104262
244bba751ce4ae586d66d28c8e9a1f0b41e872c5 Bug 779139 - Make DOM-facing camera objects cycle collection participants. r=jst
Mike Habicher <mikeh@mozilla.com>
parents:
diff changeset
   682
{
219510
220f9cd8097a7d7b395ab0419c6aa62ae25f7058 Bug 1104055 - fix CameraControl memory leak, r=aosmond
Mike Habicher <mikeh@mozilla.com>
parents: 219181
diff changeset
   683
  THROW_IF_NO_CAMERACONTROL(0.0);
168993
e93e96ed8a5ad4999e272e2a3180a32e1ffdf94d Bug 909542 - refactor CameraControl API, r=dhylands,jst,jesup,onecyrenus
Mike Habicher <mikeh@mozilla.com>
parents: 168958
diff changeset
   684
144403
614052b6cbcc905dc1e07cb1f40b02c668da7cb5 bug 899210 - convert camera control to WebIDL r=bz
Trevor Saunders <trev.saunders@gmail.com>
parents: 141384
diff changeset
   685
  double focalLength;
168993
e93e96ed8a5ad4999e272e2a3180a32e1ffdf94d Bug 909542 - refactor CameraControl API, r=dhylands,jst,jesup,onecyrenus
Mike Habicher <mikeh@mozilla.com>
parents: 168958
diff changeset
   686
  aRv = mCameraControl->Get(CAMERA_PARAM_FOCALLENGTH, focalLength);
144403
614052b6cbcc905dc1e07cb1f40b02c668da7cb5 bug 899210 - convert camera control to WebIDL r=bz
Trevor Saunders <trev.saunders@gmail.com>
parents: 141384
diff changeset
   687
  return focalLength;
104262
244bba751ce4ae586d66d28c8e9a1f0b41e872c5 Bug 779139 - Make DOM-facing camera objects cycle collection participants. r=jst
Mike Habicher <mikeh@mozilla.com>
parents:
diff changeset
   688
}
244bba751ce4ae586d66d28c8e9a1f0b41e872c5 Bug 779139 - Make DOM-facing camera objects cycle collection participants. r=jst
Mike Habicher <mikeh@mozilla.com>
parents:
diff changeset
   689
144403
614052b6cbcc905dc1e07cb1f40b02c668da7cb5 bug 899210 - convert camera control to WebIDL r=bz
Trevor Saunders <trev.saunders@gmail.com>
parents: 141384
diff changeset
   690
double
614052b6cbcc905dc1e07cb1f40b02c668da7cb5 bug 899210 - convert camera control to WebIDL r=bz
Trevor Saunders <trev.saunders@gmail.com>
parents: 141384
diff changeset
   691
nsDOMCameraControl::GetFocusDistanceNear(ErrorResult& aRv)
104262
244bba751ce4ae586d66d28c8e9a1f0b41e872c5 Bug 779139 - Make DOM-facing camera objects cycle collection participants. r=jst
Mike Habicher <mikeh@mozilla.com>
parents:
diff changeset
   692
{
219510
220f9cd8097a7d7b395ab0419c6aa62ae25f7058 Bug 1104055 - fix CameraControl memory leak, r=aosmond
Mike Habicher <mikeh@mozilla.com>
parents: 219181
diff changeset
   693
  THROW_IF_NO_CAMERACONTROL(0.0);
168993
e93e96ed8a5ad4999e272e2a3180a32e1ffdf94d Bug 909542 - refactor CameraControl API, r=dhylands,jst,jesup,onecyrenus
Mike Habicher <mikeh@mozilla.com>
parents: 168958
diff changeset
   694
144403
614052b6cbcc905dc1e07cb1f40b02c668da7cb5 bug 899210 - convert camera control to WebIDL r=bz
Trevor Saunders <trev.saunders@gmail.com>
parents: 141384
diff changeset
   695
  double distance;
168993
e93e96ed8a5ad4999e272e2a3180a32e1ffdf94d Bug 909542 - refactor CameraControl API, r=dhylands,jst,jesup,onecyrenus
Mike Habicher <mikeh@mozilla.com>
parents: 168958
diff changeset
   696
  aRv = mCameraControl->Get(CAMERA_PARAM_FOCUSDISTANCENEAR, distance);
144403
614052b6cbcc905dc1e07cb1f40b02c668da7cb5 bug 899210 - convert camera control to WebIDL r=bz
Trevor Saunders <trev.saunders@gmail.com>
parents: 141384
diff changeset
   697
  return distance;
104262
244bba751ce4ae586d66d28c8e9a1f0b41e872c5 Bug 779139 - Make DOM-facing camera objects cycle collection participants. r=jst
Mike Habicher <mikeh@mozilla.com>
parents:
diff changeset
   698
}
244bba751ce4ae586d66d28c8e9a1f0b41e872c5 Bug 779139 - Make DOM-facing camera objects cycle collection participants. r=jst
Mike Habicher <mikeh@mozilla.com>
parents:
diff changeset
   699
144403
614052b6cbcc905dc1e07cb1f40b02c668da7cb5 bug 899210 - convert camera control to WebIDL r=bz
Trevor Saunders <trev.saunders@gmail.com>
parents: 141384
diff changeset
   700
double
614052b6cbcc905dc1e07cb1f40b02c668da7cb5 bug 899210 - convert camera control to WebIDL r=bz
Trevor Saunders <trev.saunders@gmail.com>
parents: 141384
diff changeset
   701
nsDOMCameraControl::GetFocusDistanceOptimum(ErrorResult& aRv)
104262
244bba751ce4ae586d66d28c8e9a1f0b41e872c5 Bug 779139 - Make DOM-facing camera objects cycle collection participants. r=jst
Mike Habicher <mikeh@mozilla.com>
parents:
diff changeset
   702
{
219510
220f9cd8097a7d7b395ab0419c6aa62ae25f7058 Bug 1104055 - fix CameraControl memory leak, r=aosmond
Mike Habicher <mikeh@mozilla.com>
parents: 219181
diff changeset
   703
  THROW_IF_NO_CAMERACONTROL(0.0);
168993
e93e96ed8a5ad4999e272e2a3180a32e1ffdf94d Bug 909542 - refactor CameraControl API, r=dhylands,jst,jesup,onecyrenus
Mike Habicher <mikeh@mozilla.com>
parents: 168958
diff changeset
   704
144403
614052b6cbcc905dc1e07cb1f40b02c668da7cb5 bug 899210 - convert camera control to WebIDL r=bz
Trevor Saunders <trev.saunders@gmail.com>
parents: 141384
diff changeset
   705
  double distance;
168993
e93e96ed8a5ad4999e272e2a3180a32e1ffdf94d Bug 909542 - refactor CameraControl API, r=dhylands,jst,jesup,onecyrenus
Mike Habicher <mikeh@mozilla.com>
parents: 168958
diff changeset
   706
  aRv = mCameraControl->Get(CAMERA_PARAM_FOCUSDISTANCEOPTIMUM, distance);
144403
614052b6cbcc905dc1e07cb1f40b02c668da7cb5 bug 899210 - convert camera control to WebIDL r=bz
Trevor Saunders <trev.saunders@gmail.com>
parents: 141384
diff changeset
   707
  return distance;
104262
244bba751ce4ae586d66d28c8e9a1f0b41e872c5 Bug 779139 - Make DOM-facing camera objects cycle collection participants. r=jst
Mike Habicher <mikeh@mozilla.com>
parents:
diff changeset
   708
}
244bba751ce4ae586d66d28c8e9a1f0b41e872c5 Bug 779139 - Make DOM-facing camera objects cycle collection participants. r=jst
Mike Habicher <mikeh@mozilla.com>
parents:
diff changeset
   709
144403
614052b6cbcc905dc1e07cb1f40b02c668da7cb5 bug 899210 - convert camera control to WebIDL r=bz
Trevor Saunders <trev.saunders@gmail.com>
parents: 141384
diff changeset
   710
double
614052b6cbcc905dc1e07cb1f40b02c668da7cb5 bug 899210 - convert camera control to WebIDL r=bz
Trevor Saunders <trev.saunders@gmail.com>
parents: 141384
diff changeset
   711
nsDOMCameraControl::GetFocusDistanceFar(ErrorResult& aRv)
104262
244bba751ce4ae586d66d28c8e9a1f0b41e872c5 Bug 779139 - Make DOM-facing camera objects cycle collection participants. r=jst
Mike Habicher <mikeh@mozilla.com>
parents:
diff changeset
   712
{
219510
220f9cd8097a7d7b395ab0419c6aa62ae25f7058 Bug 1104055 - fix CameraControl memory leak, r=aosmond
Mike Habicher <mikeh@mozilla.com>
parents: 219181
diff changeset
   713
  THROW_IF_NO_CAMERACONTROL(0.0);
168993
e93e96ed8a5ad4999e272e2a3180a32e1ffdf94d Bug 909542 - refactor CameraControl API, r=dhylands,jst,jesup,onecyrenus
Mike Habicher <mikeh@mozilla.com>
parents: 168958
diff changeset
   714
144403
614052b6cbcc905dc1e07cb1f40b02c668da7cb5 bug 899210 - convert camera control to WebIDL r=bz
Trevor Saunders <trev.saunders@gmail.com>
parents: 141384
diff changeset
   715
  double distance;
168993
e93e96ed8a5ad4999e272e2a3180a32e1ffdf94d Bug 909542 - refactor CameraControl API, r=dhylands,jst,jesup,onecyrenus
Mike Habicher <mikeh@mozilla.com>
parents: 168958
diff changeset
   716
  aRv = mCameraControl->Get(CAMERA_PARAM_FOCUSDISTANCEFAR, distance);
144403
614052b6cbcc905dc1e07cb1f40b02c668da7cb5 bug 899210 - convert camera control to WebIDL r=bz
Trevor Saunders <trev.saunders@gmail.com>
parents: 141384
diff changeset
   717
  return distance;
104262
244bba751ce4ae586d66d28c8e9a1f0b41e872c5 Bug 779139 - Make DOM-facing camera objects cycle collection participants. r=jst
Mike Habicher <mikeh@mozilla.com>
parents:
diff changeset
   718
}
244bba751ce4ae586d66d28c8e9a1f0b41e872c5 Bug 779139 - Make DOM-facing camera objects cycle collection participants. r=jst
Mike Habicher <mikeh@mozilla.com>
parents:
diff changeset
   719
144403
614052b6cbcc905dc1e07cb1f40b02c668da7cb5 bug 899210 - convert camera control to WebIDL r=bz
Trevor Saunders <trev.saunders@gmail.com>
parents: 141384
diff changeset
   720
void
187969
6ae8548ce144ae151dbf7d21d83d23222eb4a390 Bug 1020497 - collapse exposureCompensation to single attribute, r=bz
Mike Habicher <mikeh@mozilla.com>
parents: 187276
diff changeset
   721
nsDOMCameraControl::SetExposureCompensation(double aCompensation, ErrorResult& aRv)
104262
244bba751ce4ae586d66d28c8e9a1f0b41e872c5 Bug 779139 - Make DOM-facing camera objects cycle collection participants. r=jst
Mike Habicher <mikeh@mozilla.com>
parents:
diff changeset
   722
{
219510
220f9cd8097a7d7b395ab0419c6aa62ae25f7058 Bug 1104055 - fix CameraControl memory leak, r=aosmond
Mike Habicher <mikeh@mozilla.com>
parents: 219181
diff changeset
   723
  THROW_IF_NO_CAMERACONTROL();
187969
6ae8548ce144ae151dbf7d21d83d23222eb4a390 Bug 1020497 - collapse exposureCompensation to single attribute, r=bz
Mike Habicher <mikeh@mozilla.com>
parents: 187276
diff changeset
   724
  aRv = mCameraControl->Set(CAMERA_PARAM_EXPOSURECOMPENSATION, aCompensation);
144403
614052b6cbcc905dc1e07cb1f40b02c668da7cb5 bug 899210 - convert camera control to WebIDL r=bz
Trevor Saunders <trev.saunders@gmail.com>
parents: 141384
diff changeset
   725
}
614052b6cbcc905dc1e07cb1f40b02c668da7cb5 bug 899210 - convert camera control to WebIDL r=bz
Trevor Saunders <trev.saunders@gmail.com>
parents: 141384
diff changeset
   726
614052b6cbcc905dc1e07cb1f40b02c668da7cb5 bug 899210 - convert camera control to WebIDL r=bz
Trevor Saunders <trev.saunders@gmail.com>
parents: 141384
diff changeset
   727
double
614052b6cbcc905dc1e07cb1f40b02c668da7cb5 bug 899210 - convert camera control to WebIDL r=bz
Trevor Saunders <trev.saunders@gmail.com>
parents: 141384
diff changeset
   728
nsDOMCameraControl::GetExposureCompensation(ErrorResult& aRv)
614052b6cbcc905dc1e07cb1f40b02c668da7cb5 bug 899210 - convert camera control to WebIDL r=bz
Trevor Saunders <trev.saunders@gmail.com>
parents: 141384
diff changeset
   729
{
219510
220f9cd8097a7d7b395ab0419c6aa62ae25f7058 Bug 1104055 - fix CameraControl memory leak, r=aosmond
Mike Habicher <mikeh@mozilla.com>
parents: 219181
diff changeset
   730
  THROW_IF_NO_CAMERACONTROL(0.0);
168993
e93e96ed8a5ad4999e272e2a3180a32e1ffdf94d Bug 909542 - refactor CameraControl API, r=dhylands,jst,jesup,onecyrenus
Mike Habicher <mikeh@mozilla.com>
parents: 168958
diff changeset
   731
104262
244bba751ce4ae586d66d28c8e9a1f0b41e872c5 Bug 779139 - Make DOM-facing camera objects cycle collection participants. r=jst
Mike Habicher <mikeh@mozilla.com>
parents:
diff changeset
   732
  double compensation;
168993
e93e96ed8a5ad4999e272e2a3180a32e1ffdf94d Bug 909542 - refactor CameraControl API, r=dhylands,jst,jesup,onecyrenus
Mike Habicher <mikeh@mozilla.com>
parents: 168958
diff changeset
   733
  aRv = mCameraControl->Get(CAMERA_PARAM_EXPOSURECOMPENSATION, compensation);
144403
614052b6cbcc905dc1e07cb1f40b02c668da7cb5 bug 899210 - convert camera control to WebIDL r=bz
Trevor Saunders <trev.saunders@gmail.com>
parents: 141384
diff changeset
   734
  return compensation;
104262
244bba751ce4ae586d66d28c8e9a1f0b41e872c5 Bug 779139 - Make DOM-facing camera objects cycle collection participants. r=jst
Mike Habicher <mikeh@mozilla.com>
parents:
diff changeset
   735
}
244bba751ce4ae586d66d28c8e9a1f0b41e872c5 Bug 779139 - Make DOM-facing camera objects cycle collection participants. r=jst
Mike Habicher <mikeh@mozilla.com>
parents:
diff changeset
   736
159206
b4d9c56e18a8ce319b04150a06c34ee9e67af257 Bug 932669 - Expose sensor rotation offset to JS. r=dhylands
Mike Habicher <mikeh@mozilla.com>
parents: 158599
diff changeset
   737
int32_t
b4d9c56e18a8ce319b04150a06c34ee9e67af257 Bug 932669 - Expose sensor rotation offset to JS. r=dhylands
Mike Habicher <mikeh@mozilla.com>
parents: 158599
diff changeset
   738
nsDOMCameraControl::SensorAngle()
b4d9c56e18a8ce319b04150a06c34ee9e67af257 Bug 932669 - Expose sensor rotation offset to JS. r=dhylands
Mike Habicher <mikeh@mozilla.com>
parents: 158599
diff changeset
   739
{
170205
4b6103d24d1eeace490a82002e734c1cb73922ee Bug 975472 - fix crash in DOM error handler, r=dhylands
Mike Habicher <mikeh@mozilla.com>
parents: 169639
diff changeset
   740
  int32_t angle = 0;
219510
220f9cd8097a7d7b395ab0419c6aa62ae25f7058 Bug 1104055 - fix CameraControl memory leak, r=aosmond
Mike Habicher <mikeh@mozilla.com>
parents: 219181
diff changeset
   741
  if (mCameraControl) {
220f9cd8097a7d7b395ab0419c6aa62ae25f7058 Bug 1104055 - fix CameraControl memory leak, r=aosmond
Mike Habicher <mikeh@mozilla.com>
parents: 219181
diff changeset
   742
    mCameraControl->Get(CAMERA_PARAM_SENSORANGLE, angle);
220f9cd8097a7d7b395ab0419c6aa62ae25f7058 Bug 1104055 - fix CameraControl memory leak, r=aosmond
Mike Habicher <mikeh@mozilla.com>
parents: 219181
diff changeset
   743
  }
159206
b4d9c56e18a8ce319b04150a06c34ee9e67af257 Bug 932669 - Expose sensor rotation offset to JS. r=dhylands
Mike Habicher <mikeh@mozilla.com>
parents: 158599
diff changeset
   744
  return angle;
b4d9c56e18a8ce319b04150a06c34ee9e67af257 Bug 932669 - Expose sensor rotation offset to JS. r=dhylands
Mike Habicher <mikeh@mozilla.com>
parents: 158599
diff changeset
   745
}
b4d9c56e18a8ce319b04150a06c34ee9e67af257 Bug 932669 - Expose sensor rotation offset to JS. r=dhylands
Mike Habicher <mikeh@mozilla.com>
parents: 158599
diff changeset
   746
168993
e93e96ed8a5ad4999e272e2a3180a32e1ffdf94d Bug 909542 - refactor CameraControl API, r=dhylands,jst,jesup,onecyrenus
Mike Habicher <mikeh@mozilla.com>
parents: 168958
diff changeset
   747
already_AddRefed<dom::CameraCapabilities>
e93e96ed8a5ad4999e272e2a3180a32e1ffdf94d Bug 909542 - refactor CameraControl API, r=dhylands,jst,jesup,onecyrenus
Mike Habicher <mikeh@mozilla.com>
parents: 168958
diff changeset
   748
nsDOMCameraControl::Capabilities()
e93e96ed8a5ad4999e272e2a3180a32e1ffdf94d Bug 909542 - refactor CameraControl API, r=dhylands,jst,jesup,onecyrenus
Mike Habicher <mikeh@mozilla.com>
parents: 168958
diff changeset
   749
{
219510
220f9cd8097a7d7b395ab0419c6aa62ae25f7058 Bug 1104055 - fix CameraControl memory leak, r=aosmond
Mike Habicher <mikeh@mozilla.com>
parents: 219181
diff changeset
   750
  if (!mCameraControl) {
220f9cd8097a7d7b395ab0419c6aa62ae25f7058 Bug 1104055 - fix CameraControl memory leak, r=aosmond
Mike Habicher <mikeh@mozilla.com>
parents: 219181
diff changeset
   751
    DOM_CAMERA_LOGW("mCameraControl is null at %s:%d\n", __func__, __LINE__);
220f9cd8097a7d7b395ab0419c6aa62ae25f7058 Bug 1104055 - fix CameraControl memory leak, r=aosmond
Mike Habicher <mikeh@mozilla.com>
parents: 219181
diff changeset
   752
    return nullptr;
220f9cd8097a7d7b395ab0419c6aa62ae25f7058 Bug 1104055 - fix CameraControl memory leak, r=aosmond
Mike Habicher <mikeh@mozilla.com>
parents: 219181
diff changeset
   753
  }
220f9cd8097a7d7b395ab0419c6aa62ae25f7058 Bug 1104055 - fix CameraControl memory leak, r=aosmond
Mike Habicher <mikeh@mozilla.com>
parents: 219181
diff changeset
   754
268184
e8c7dfe727cd970e2c3294934e2927b14143c205 Bug 1207245 - part 6 - rename nsRefPtr<T> to RefPtr<T>; r=ehsan; a=Tomcat
Nathan Froyd <froydnj@mozilla.com>
parents: 266718
diff changeset
   755
  RefPtr<CameraCapabilities> caps = mCapabilities;
168993
e93e96ed8a5ad4999e272e2a3180a32e1ffdf94d Bug 909542 - refactor CameraControl API, r=dhylands,jst,jesup,onecyrenus
Mike Habicher <mikeh@mozilla.com>
parents: 168958
diff changeset
   756
  if (!caps) {
213736
95be75403d706081b8508b91f6e60c7846af125d Bug 1020368 - remove direct JS_*() calls from CameraRecorderProfiles, r=aosmond,bz
Mike Habicher <mikeh@mozilla.com>
parents: 213549
diff changeset
   757
    caps = new CameraCapabilities(mWindow, mCameraControl);
168993
e93e96ed8a5ad4999e272e2a3180a32e1ffdf94d Bug 909542 - refactor CameraControl API, r=dhylands,jst,jesup,onecyrenus
Mike Habicher <mikeh@mozilla.com>
parents: 168958
diff changeset
   758
    mCapabilities = caps;
e93e96ed8a5ad4999e272e2a3180a32e1ffdf94d Bug 909542 - refactor CameraControl API, r=dhylands,jst,jesup,onecyrenus
Mike Habicher <mikeh@mozilla.com>
parents: 168958
diff changeset
   759
  }
e93e96ed8a5ad4999e272e2a3180a32e1ffdf94d Bug 909542 - refactor CameraControl API, r=dhylands,jst,jesup,onecyrenus
Mike Habicher <mikeh@mozilla.com>
parents: 168958
diff changeset
   760
e93e96ed8a5ad4999e272e2a3180a32e1ffdf94d Bug 909542 - refactor CameraControl API, r=dhylands,jst,jesup,onecyrenus
Mike Habicher <mikeh@mozilla.com>
parents: 168958
diff changeset
   761
  return caps.forget();
e93e96ed8a5ad4999e272e2a3180a32e1ffdf94d Bug 909542 - refactor CameraControl API, r=dhylands,jst,jesup,onecyrenus
Mike Habicher <mikeh@mozilla.com>
parents: 168958
diff changeset
   762
}
e93e96ed8a5ad4999e272e2a3180a32e1ffdf94d Bug 909542 - refactor CameraControl API, r=dhylands,jst,jesup,onecyrenus
Mike Habicher <mikeh@mozilla.com>
parents: 168958
diff changeset
   763
e93e96ed8a5ad4999e272e2a3180a32e1ffdf94d Bug 909542 - refactor CameraControl API, r=dhylands,jst,jesup,onecyrenus
Mike Habicher <mikeh@mozilla.com>
parents: 168958
diff changeset
   764
// Methods.
208669
05df8323b82079743e8af61b83625739bbadf905 Bug 994912 - Add support for promises and event-based notifications to camera. r=mikeh, r=bz
Andrew Osmond <aosmond@mozilla.com>
parents: 207338
diff changeset
   765
already_AddRefed<Promise>
168993
e93e96ed8a5ad4999e272e2a3180a32e1ffdf94d Bug 909542 - refactor CameraControl API, r=dhylands,jst,jesup,onecyrenus
Mike Habicher <mikeh@mozilla.com>
parents: 168958
diff changeset
   766
nsDOMCameraControl::StartRecording(const CameraStartRecordingOptions& aOptions,
e93e96ed8a5ad4999e272e2a3180a32e1ffdf94d Bug 909542 - refactor CameraControl API, r=dhylands,jst,jesup,onecyrenus
Mike Habicher <mikeh@mozilla.com>
parents: 168958
diff changeset
   767
                                   nsDOMDeviceStorage& aStorageArea,
e93e96ed8a5ad4999e272e2a3180a32e1ffdf94d Bug 909542 - refactor CameraControl API, r=dhylands,jst,jesup,onecyrenus
Mike Habicher <mikeh@mozilla.com>
parents: 168958
diff changeset
   768
                                   const nsAString& aFilename,
168958
b47b10e405a5831013e362918519a1e7f3bb4dd3 Backed out changeset 6e588c56764b (bug 909542) for Gaia unit test perma-fail.
Ryan VanderMeulen <ryanvm@gmail.com>
parents: 168933
diff changeset
   769
                                   ErrorResult& aRv)
b47b10e405a5831013e362918519a1e7f3bb4dd3 Backed out changeset 6e588c56764b (bug 909542) for Gaia unit test perma-fail.
Ryan VanderMeulen <ryanvm@gmail.com>
parents: 168933
diff changeset
   770
{
219510
220f9cd8097a7d7b395ab0419c6aa62ae25f7058 Bug 1104055 - fix CameraControl memory leak, r=aosmond
Mike Habicher <mikeh@mozilla.com>
parents: 219181
diff changeset
   771
  DOM_CAMERA_LOGT("%s:%d : this=%p\n", __func__, __LINE__, this);
168958
b47b10e405a5831013e362918519a1e7f3bb4dd3 Backed out changeset 6e588c56764b (bug 909542) for Gaia unit test perma-fail.
Ryan VanderMeulen <ryanvm@gmail.com>
parents: 168933
diff changeset
   772
268184
e8c7dfe727cd970e2c3294934e2927b14143c205 Bug 1207245 - part 6 - rename nsRefPtr<T> to RefPtr<T>; r=ehsan; a=Tomcat
Nathan Froyd <froydnj@mozilla.com>
parents: 266718
diff changeset
   773
  RefPtr<Promise> promise = CreatePromise(aRv);
208669
05df8323b82079743e8af61b83625739bbadf905 Bug 994912 - Add support for promises and event-based notifications to camera. r=mikeh, r=bz
Andrew Osmond <aosmond@mozilla.com>
parents: 207338
diff changeset
   774
  if (aRv.Failed()) {
05df8323b82079743e8af61b83625739bbadf905 Bug 994912 - Add support for promises and event-based notifications to camera. r=mikeh, r=bz
Andrew Osmond <aosmond@mozilla.com>
parents: 207338
diff changeset
   775
    return nullptr;
05df8323b82079743e8af61b83625739bbadf905 Bug 994912 - Add support for promises and event-based notifications to camera. r=mikeh, r=bz
Andrew Osmond <aosmond@mozilla.com>
parents: 207338
diff changeset
   776
  }
05df8323b82079743e8af61b83625739bbadf905 Bug 994912 - Add support for promises and event-based notifications to camera. r=mikeh, r=bz
Andrew Osmond <aosmond@mozilla.com>
parents: 207338
diff changeset
   777
249644
e3b6829af1896d0010bf09db32c4f10f6e186479 Bug 1175656 - Implement generation of recording posters in Gecko. r=dhylands,bz
Andrew Osmond <aosmond@mozilla.com>
parents: 249622
diff changeset
   778
  // If we are trying to start recording, already recording or are still
e3b6829af1896d0010bf09db32c4f10f6e186479 Bug 1175656 - Implement generation of recording posters in Gecko. r=dhylands,bz
Andrew Osmond <aosmond@mozilla.com>
parents: 249622
diff changeset
   779
  // waiting for a poster to be created/fail, we need to wait
e3b6829af1896d0010bf09db32c4f10f6e186479 Bug 1175656 - Implement generation of recording posters in Gecko. r=dhylands,bz
Andrew Osmond <aosmond@mozilla.com>
parents: 249622
diff changeset
   780
  if (mStartRecordingPromise || mRecording ||
e3b6829af1896d0010bf09db32c4f10f6e186479 Bug 1175656 - Implement generation of recording posters in Gecko. r=dhylands,bz
Andrew Osmond <aosmond@mozilla.com>
parents: 249622
diff changeset
   781
      mRecordingStoppedDeferred ||
263518
378958ae220f4de9fd3934fffe2561f53e7727b0 Bug 1191731 - Update poster API to allow application control over when poster is saved. r=bz, r=dhylands
Andrew Osmond <aosmond@mozilla.com>
parents: 258070
diff changeset
   782
      mOptions.mCreatePoster) {
208669
05df8323b82079743e8af61b83625739bbadf905 Bug 994912 - Add support for promises and event-based notifications to camera. r=mikeh, r=bz
Andrew Osmond <aosmond@mozilla.com>
parents: 207338
diff changeset
   783
    promise->MaybeReject(NS_ERROR_IN_PROGRESS);
05df8323b82079743e8af61b83625739bbadf905 Bug 994912 - Add support for promises and event-based notifications to camera. r=mikeh, r=bz
Andrew Osmond <aosmond@mozilla.com>
parents: 207338
diff changeset
   784
    return promise.forget();
205177
7c8b3cd5e57e0bd5ede643ce3e04b384091c0359 Bug 1065866 - Abort StartRecording while previous call is in progress. r=mikeh
Shinuk Lee <shinuk153@gmail.com>
parents: 203085
diff changeset
   785
  }
7c8b3cd5e57e0bd5ede643ce3e04b384091c0359 Bug 1065866 - Abort StartRecording while previous call is in progress. r=mikeh
Shinuk Lee <shinuk153@gmail.com>
parents: 203085
diff changeset
   786
249187
9ba890d2ba081ceea82be94530b3fafffa51b766 Bug 1152500 - Fix how stop recording may be handled out-of-order. r=dhylands
Andrew Osmond <aosmond@mozilla.com>
parents: 246249
diff changeset
   787
  aRv = NotifyRecordingStatusChange(NS_LITERAL_STRING("starting"));
9ba890d2ba081ceea82be94530b3fafffa51b766 Bug 1152500 - Fix how stop recording may be handled out-of-order. r=dhylands
Andrew Osmond <aosmond@mozilla.com>
parents: 246249
diff changeset
   788
  if (aRv.Failed()) {
9ba890d2ba081ceea82be94530b3fafffa51b766 Bug 1152500 - Fix how stop recording may be handled out-of-order. r=dhylands
Andrew Osmond <aosmond@mozilla.com>
parents: 246249
diff changeset
   789
    return nullptr;
115614
97c5efcc211540fdf1282e08d540f52d69fd74c5 Bug 811649 - Mute other audio when video recording is started by using an AudioChannelAgent to integrate with AudioChannelService. r=mhabicher a=blocking-basecamp
Marco Chen <mchen@mozilla.com>
parents: 114710
diff changeset
   790
  }
97c5efcc211540fdf1282e08d540f52d69fd74c5 Bug 811649 - Mute other audio when video recording is started by using an AudioChannelAgent to integrate with AudioChannelService. r=mhabicher a=blocking-basecamp
Marco Chen <mchen@mozilla.com>
parents: 114710
diff changeset
   791
164521
2b74b0de04a4c7244ea1b53afe92bbb269a3b59c Bug 910498 - Camera changes to use CreateFd. r=mikeh
Dave Hylands <dhylands@mozilla.com>
parents: 164063
diff changeset
   792
  mDSFileDescriptor = new DeviceStorageFileDescriptor();
268184
e8c7dfe727cd970e2c3294934e2927b14143c205 Bug 1207245 - part 6 - rename nsRefPtr<T> to RefPtr<T>; r=ehsan; a=Tomcat
Nathan Froyd <froydnj@mozilla.com>
parents: 266718
diff changeset
   793
  RefPtr<DOMRequest> request = aStorageArea.CreateFileDescriptor(aFilename,
246043
4820fb6d8eb7397c834db16cf97b50bfbca5364c Bug 1169342 - Remove nsIDOMDeviceStorage. Cleanup nsDOMDeviceStorage event wrappers. r=dhylands
Andrew Osmond <aosmond@mozilla.com>
parents: 244447
diff changeset
   794
                                                                   mDSFileDescriptor.get(),
4820fb6d8eb7397c834db16cf97b50bfbca5364c Bug 1169342 - Remove nsIDOMDeviceStorage. Cleanup nsDOMDeviceStorage event wrappers. r=dhylands
Andrew Osmond <aosmond@mozilla.com>
parents: 244447
diff changeset
   795
                                                                   aRv);
144403
614052b6cbcc905dc1e07cb1f40b02c668da7cb5 bug 899210 - convert camera control to WebIDL r=bz
Trevor Saunders <trev.saunders@gmail.com>
parents: 141384
diff changeset
   796
  if (aRv.Failed()) {
249187
9ba890d2ba081ceea82be94530b3fafffa51b766 Bug 1152500 - Fix how stop recording may be handled out-of-order. r=dhylands
Andrew Osmond <aosmond@mozilla.com>
parents: 246249
diff changeset
   797
    NotifyRecordingStatusChange(NS_LITERAL_STRING("shutdown"));
208669
05df8323b82079743e8af61b83625739bbadf905 Bug 994912 - Add support for promises and event-based notifications to camera. r=mikeh, r=bz
Andrew Osmond <aosmond@mozilla.com>
parents: 207338
diff changeset
   798
    return nullptr;
144403
614052b6cbcc905dc1e07cb1f40b02c668da7cb5 bug 899210 - convert camera control to WebIDL r=bz
Trevor Saunders <trev.saunders@gmail.com>
parents: 141384
diff changeset
   799
  }
164521
2b74b0de04a4c7244ea1b53afe92bbb269a3b59c Bug 910498 - Camera changes to use CreateFd. r=mikeh
Dave Hylands <dhylands@mozilla.com>
parents: 164063
diff changeset
   800
249644
e3b6829af1896d0010bf09db32c4f10f6e186479 Bug 1175656 - Implement generation of recording posters in Gecko. r=dhylands,bz
Andrew Osmond <aosmond@mozilla.com>
parents: 249622
diff changeset
   801
  nsCOMPtr<nsIDOMEventListener> listener = new StartRecordingHelper(this);
e3b6829af1896d0010bf09db32c4f10f6e186479 Bug 1175656 - Implement generation of recording posters in Gecko. r=dhylands,bz
Andrew Osmond <aosmond@mozilla.com>
parents: 249622
diff changeset
   802
  aRv = RegisterStorageRequestEvents(request, listener);
e3b6829af1896d0010bf09db32c4f10f6e186479 Bug 1175656 - Implement generation of recording posters in Gecko. r=dhylands,bz
Andrew Osmond <aosmond@mozilla.com>
parents: 249622
diff changeset
   803
  if (aRv.Failed()) {
249187
9ba890d2ba081ceea82be94530b3fafffa51b766 Bug 1152500 - Fix how stop recording may be handled out-of-order. r=dhylands
Andrew Osmond <aosmond@mozilla.com>
parents: 246249
diff changeset
   804
    NotifyRecordingStatusChange(NS_LITERAL_STRING("shutdown"));
246043
4820fb6d8eb7397c834db16cf97b50bfbca5364c Bug 1169342 - Remove nsIDOMDeviceStorage. Cleanup nsDOMDeviceStorage event wrappers. r=dhylands
Andrew Osmond <aosmond@mozilla.com>
parents: 244447
diff changeset
   805
    return nullptr;
4820fb6d8eb7397c834db16cf97b50bfbca5364c Bug 1169342 - Remove nsIDOMDeviceStorage. Cleanup nsDOMDeviceStorage event wrappers. r=dhylands
Andrew Osmond <aosmond@mozilla.com>
parents: 244447
diff changeset
   806
  }
4820fb6d8eb7397c834db16cf97b50bfbca5364c Bug 1169342 - Remove nsIDOMDeviceStorage. Cleanup nsDOMDeviceStorage event wrappers. r=dhylands
Andrew Osmond <aosmond@mozilla.com>
parents: 244447
diff changeset
   807
249644
e3b6829af1896d0010bf09db32c4f10f6e186479 Bug 1175656 - Implement generation of recording posters in Gecko. r=dhylands,bz
Andrew Osmond <aosmond@mozilla.com>
parents: 249622
diff changeset
   808
  mStartRecordingPromise = promise;
e3b6829af1896d0010bf09db32c4f10f6e186479 Bug 1175656 - Implement generation of recording posters in Gecko. r=dhylands,bz
Andrew Osmond <aosmond@mozilla.com>
parents: 249622
diff changeset
   809
  mOptions = aOptions;
249187
9ba890d2ba081ceea82be94530b3fafffa51b766 Bug 1152500 - Fix how stop recording may be handled out-of-order. r=dhylands
Andrew Osmond <aosmond@mozilla.com>
parents: 246249
diff changeset
   810
  mRecording = true;
208669
05df8323b82079743e8af61b83625739bbadf905 Bug 994912 - Add support for promises and event-based notifications to camera. r=mikeh, r=bz
Andrew Osmond <aosmond@mozilla.com>
parents: 207338
diff changeset
   811
  return promise.forget();
164521
2b74b0de04a4c7244ea1b53afe92bbb269a3b59c Bug 910498 - Camera changes to use CreateFd. r=mikeh
Dave Hylands <dhylands@mozilla.com>
parents: 164063
diff changeset
   812
}
2b74b0de04a4c7244ea1b53afe92bbb269a3b59c Bug 910498 - Camera changes to use CreateFd. r=mikeh
Dave Hylands <dhylands@mozilla.com>
parents: 164063
diff changeset
   813
168993
e93e96ed8a5ad4999e272e2a3180a32e1ffdf94d Bug 909542 - refactor CameraControl API, r=dhylands,jst,jesup,onecyrenus
Mike Habicher <mikeh@mozilla.com>
parents: 168958
diff changeset
   814
void
e93e96ed8a5ad4999e272e2a3180a32e1ffdf94d Bug 909542 - refactor CameraControl API, r=dhylands,jst,jesup,onecyrenus
Mike Habicher <mikeh@mozilla.com>
parents: 168958
diff changeset
   815
nsDOMCameraControl::OnCreatedFileDescriptor(bool aSucceeded)
164521
2b74b0de04a4c7244ea1b53afe92bbb269a3b59c Bug 910498 - Camera changes to use CreateFd. r=mikeh
Dave Hylands <dhylands@mozilla.com>
parents: 164063
diff changeset
   816
{
180888
c26966635e9c0c028e4360f2175563f9ef62df80 Bug 985496 - rationalize camera error reporting, r=dhylands
Mike Habicher <mikeh@mozilla.com>
parents: 180485
diff changeset
   817
  nsresult rv = NS_ERROR_FAILURE;
c26966635e9c0c028e4360f2175563f9ef62df80 Bug 985496 - rationalize camera error reporting, r=dhylands
Mike Habicher <mikeh@mozilla.com>
parents: 180485
diff changeset
   818
219510
220f9cd8097a7d7b395ab0419c6aa62ae25f7058 Bug 1104055 - fix CameraControl memory leak, r=aosmond
Mike Habicher <mikeh@mozilla.com>
parents: 219181
diff changeset
   819
  if (!mCameraControl) {
220f9cd8097a7d7b395ab0419c6aa62ae25f7058 Bug 1104055 - fix CameraControl memory leak, r=aosmond
Mike Habicher <mikeh@mozilla.com>
parents: 219181
diff changeset
   820
    rv = NS_ERROR_NOT_AVAILABLE;
249187
9ba890d2ba081ceea82be94530b3fafffa51b766 Bug 1152500 - Fix how stop recording may be handled out-of-order. r=dhylands
Andrew Osmond <aosmond@mozilla.com>
parents: 246249
diff changeset
   821
  } else if (!mRecording) {
9ba890d2ba081ceea82be94530b3fafffa51b766 Bug 1152500 - Fix how stop recording may be handled out-of-order. r=dhylands
Andrew Osmond <aosmond@mozilla.com>
parents: 246249
diff changeset
   822
    // Race condition where StopRecording comes in before we issue
9ba890d2ba081ceea82be94530b3fafffa51b766 Bug 1152500 - Fix how stop recording may be handled out-of-order. r=dhylands
Andrew Osmond <aosmond@mozilla.com>
parents: 246249
diff changeset
   823
    // the start recording request to Gonk
9ba890d2ba081ceea82be94530b3fafffa51b766 Bug 1152500 - Fix how stop recording may be handled out-of-order. r=dhylands
Andrew Osmond <aosmond@mozilla.com>
parents: 246249
diff changeset
   824
    rv = NS_ERROR_ABORT;
263518
378958ae220f4de9fd3934fffe2561f53e7727b0 Bug 1191731 - Update poster API to allow application control over when poster is saved. r=bz, r=dhylands
Andrew Osmond <aosmond@mozilla.com>
parents: 258070
diff changeset
   825
    mOptions.mCreatePoster = false;
219510
220f9cd8097a7d7b395ab0419c6aa62ae25f7058 Bug 1104055 - fix CameraControl memory leak, r=aosmond
Mike Habicher <mikeh@mozilla.com>
parents: 219181
diff changeset
   826
  } else if (aSucceeded && mDSFileDescriptor->mFileDescriptor.IsValid()) {
168993
e93e96ed8a5ad4999e272e2a3180a32e1ffdf94d Bug 909542 - refactor CameraControl API, r=dhylands,jst,jesup,onecyrenus
Mike Habicher <mikeh@mozilla.com>
parents: 168958
diff changeset
   827
    ICameraControl::StartRecordingOptions o;
164521
2b74b0de04a4c7244ea1b53afe92bbb269a3b59c Bug 910498 - Camera changes to use CreateFd. r=mikeh
Dave Hylands <dhylands@mozilla.com>
parents: 164063
diff changeset
   828
168993
e93e96ed8a5ad4999e272e2a3180a32e1ffdf94d Bug 909542 - refactor CameraControl API, r=dhylands,jst,jesup,onecyrenus
Mike Habicher <mikeh@mozilla.com>
parents: 168958
diff changeset
   829
    o.rotation = mOptions.mRotation;
e93e96ed8a5ad4999e272e2a3180a32e1ffdf94d Bug 909542 - refactor CameraControl API, r=dhylands,jst,jesup,onecyrenus
Mike Habicher <mikeh@mozilla.com>
parents: 168958
diff changeset
   830
    o.maxFileSizeBytes = mOptions.mMaxFileSizeBytes;
e93e96ed8a5ad4999e272e2a3180a32e1ffdf94d Bug 909542 - refactor CameraControl API, r=dhylands,jst,jesup,onecyrenus
Mike Habicher <mikeh@mozilla.com>
parents: 168958
diff changeset
   831
    o.maxVideoLengthMs = mOptions.mMaxVideoLengthMs;
177876
958d209e788e0f45fa3dc73b52699c3f4b811043 Bug 981047 - enable torch mode in low light when video recording, r=dhylands,ehsan
Mike Habicher <mikeh@mozilla.com>
parents: 177875
diff changeset
   832
    o.autoEnableLowLightTorch = mOptions.mAutoEnableLowLightTorch;
263518
378958ae220f4de9fd3934fffe2561f53e7727b0 Bug 1191731 - Update poster API to allow application control over when poster is saved. r=bz, r=dhylands
Andrew Osmond <aosmond@mozilla.com>
parents: 258070
diff changeset
   833
    o.createPoster = mOptions.mCreatePoster;
180888
c26966635e9c0c028e4360f2175563f9ef62df80 Bug 985496 - rationalize camera error reporting, r=dhylands
Mike Habicher <mikeh@mozilla.com>
parents: 180485
diff changeset
   834
    rv = mCameraControl->StartRecording(mDSFileDescriptor.get(), &o);
168993
e93e96ed8a5ad4999e272e2a3180a32e1ffdf94d Bug 909542 - refactor CameraControl API, r=dhylands,jst,jesup,onecyrenus
Mike Habicher <mikeh@mozilla.com>
parents: 168958
diff changeset
   835
    if (NS_SUCCEEDED(rv)) {
e93e96ed8a5ad4999e272e2a3180a32e1ffdf94d Bug 909542 - refactor CameraControl API, r=dhylands,jst,jesup,onecyrenus
Mike Habicher <mikeh@mozilla.com>
parents: 168958
diff changeset
   836
      return;
164521
2b74b0de04a4c7244ea1b53afe92bbb269a3b59c Bug 910498 - Camera changes to use CreateFd. r=mikeh
Dave Hylands <dhylands@mozilla.com>
parents: 164063
diff changeset
   837
    }
2b74b0de04a4c7244ea1b53afe92bbb269a3b59c Bug 910498 - Camera changes to use CreateFd. r=mikeh
Dave Hylands <dhylands@mozilla.com>
parents: 164063
diff changeset
   838
  }
180888
c26966635e9c0c028e4360f2175563f9ef62df80 Bug 985496 - rationalize camera error reporting, r=dhylands
Mike Habicher <mikeh@mozilla.com>
parents: 180485
diff changeset
   839
c26966635e9c0c028e4360f2175563f9ef62df80 Bug 985496 - rationalize camera error reporting, r=dhylands
Mike Habicher <mikeh@mozilla.com>
parents: 180485
diff changeset
   840
  OnUserError(CameraControlListener::kInStartRecording, rv);
172215
ea47af24d9a78cfef60e6656883c5f027cea0b30 Backed out changeset 4fb349c12a63 (bug 977372) for b2g ics emulator debug m8 test failure
Carsten "Tomcat" Book <cbook@mozilla.com>
parents: 172210
diff changeset
   841
172425
f8bf9630b972b5cf8e7631a142e83ad4cb3e6d69 Bug 977372 - Close IPC'd filedescriptor from device descriptor when finished with it. r=mikeh
Dave Hylands <dhylands@mozilla.com>
parents: 172215
diff changeset
   842
  if (mDSFileDescriptor->mFileDescriptor.IsValid()) {
f8bf9630b972b5cf8e7631a142e83ad4cb3e6d69 Bug 977372 - Close IPC'd filedescriptor from device descriptor when finished with it. r=mikeh
Dave Hylands <dhylands@mozilla.com>
parents: 172215
diff changeset
   843
    // An error occured. We need to manually close the file associated with the
f8bf9630b972b5cf8e7631a142e83ad4cb3e6d69 Bug 977372 - Close IPC'd filedescriptor from device descriptor when finished with it. r=mikeh
Dave Hylands <dhylands@mozilla.com>
parents: 172215
diff changeset
   844
    // FileDescriptor, and we shouldn't do this on the main thread, so we
f8bf9630b972b5cf8e7631a142e83ad4cb3e6d69 Bug 977372 - Close IPC'd filedescriptor from device descriptor when finished with it. r=mikeh
Dave Hylands <dhylands@mozilla.com>
parents: 172215
diff changeset
   845
    // use a little helper.
268184
e8c7dfe727cd970e2c3294934e2927b14143c205 Bug 1207245 - part 6 - rename nsRefPtr<T> to RefPtr<T>; r=ehsan; a=Tomcat
Nathan Froyd <froydnj@mozilla.com>
parents: 266718
diff changeset
   846
    RefPtr<CloseFileRunnable> closer =
172425
f8bf9630b972b5cf8e7631a142e83ad4cb3e6d69 Bug 977372 - Close IPC'd filedescriptor from device descriptor when finished with it. r=mikeh
Dave Hylands <dhylands@mozilla.com>
parents: 172215
diff changeset
   847
      new CloseFileRunnable(mDSFileDescriptor->mFileDescriptor);
f8bf9630b972b5cf8e7631a142e83ad4cb3e6d69 Bug 977372 - Close IPC'd filedescriptor from device descriptor when finished with it. r=mikeh
Dave Hylands <dhylands@mozilla.com>
parents: 172215
diff changeset
   848
    closer->Dispatch();
f8bf9630b972b5cf8e7631a142e83ad4cb3e6d69 Bug 977372 - Close IPC'd filedescriptor from device descriptor when finished with it. r=mikeh
Dave Hylands <dhylands@mozilla.com>
parents: 172215
diff changeset
   849
  }
104262
244bba751ce4ae586d66d28c8e9a1f0b41e872c5 Bug 779139 - Make DOM-facing camera objects cycle collection participants. r=jst
Mike Habicher <mikeh@mozilla.com>
parents:
diff changeset
   850
}
244bba751ce4ae586d66d28c8e9a1f0b41e872c5 Bug 779139 - Make DOM-facing camera objects cycle collection participants. r=jst
Mike Habicher <mikeh@mozilla.com>
parents:
diff changeset
   851
144403
614052b6cbcc905dc1e07cb1f40b02c668da7cb5 bug 899210 - convert camera control to WebIDL r=bz
Trevor Saunders <trev.saunders@gmail.com>
parents: 141384
diff changeset
   852
void
614052b6cbcc905dc1e07cb1f40b02c668da7cb5 bug 899210 - convert camera control to WebIDL r=bz
Trevor Saunders <trev.saunders@gmail.com>
parents: 141384
diff changeset
   853
nsDOMCameraControl::StopRecording(ErrorResult& aRv)
104262
244bba751ce4ae586d66d28c8e9a1f0b41e872c5 Bug 779139 - Make DOM-facing camera objects cycle collection participants. r=jst
Mike Habicher <mikeh@mozilla.com>
parents:
diff changeset
   854
{
219510
220f9cd8097a7d7b395ab0419c6aa62ae25f7058 Bug 1104055 - fix CameraControl memory leak, r=aosmond
Mike Habicher <mikeh@mozilla.com>
parents: 219181
diff changeset
   855
  DOM_CAMERA_LOGT("%s:%d : this=%p\n", __func__, __LINE__, this);
220f9cd8097a7d7b395ab0419c6aa62ae25f7058 Bug 1104055 - fix CameraControl memory leak, r=aosmond
Mike Habicher <mikeh@mozilla.com>
parents: 219181
diff changeset
   856
  THROW_IF_NO_CAMERACONTROL();
104262
244bba751ce4ae586d66d28c8e9a1f0b41e872c5 Bug 779139 - Make DOM-facing camera objects cycle collection participants. r=jst
Mike Habicher <mikeh@mozilla.com>
parents:
diff changeset
   857
249187
9ba890d2ba081ceea82be94530b3fafffa51b766 Bug 1152500 - Fix how stop recording may be handled out-of-order. r=dhylands
Andrew Osmond <aosmond@mozilla.com>
parents: 246249
diff changeset
   858
  ReleaseAudioChannelAgent();
9ba890d2ba081ceea82be94530b3fafffa51b766 Bug 1152500 - Fix how stop recording may be handled out-of-order. r=dhylands
Andrew Osmond <aosmond@mozilla.com>
parents: 246249
diff changeset
   859
  mRecording = false;
144403
614052b6cbcc905dc1e07cb1f40b02c668da7cb5 bug 899210 - convert camera control to WebIDL r=bz
Trevor Saunders <trev.saunders@gmail.com>
parents: 141384
diff changeset
   860
  aRv = mCameraControl->StopRecording();
104262
244bba751ce4ae586d66d28c8e9a1f0b41e872c5 Bug 779139 - Make DOM-facing camera objects cycle collection participants. r=jst
Mike Habicher <mikeh@mozilla.com>
parents:
diff changeset
   861
}
244bba751ce4ae586d66d28c8e9a1f0b41e872c5 Bug 779139 - Make DOM-facing camera objects cycle collection participants. r=jst
Mike Habicher <mikeh@mozilla.com>
parents:
diff changeset
   862
144403
614052b6cbcc905dc1e07cb1f40b02c668da7cb5 bug 899210 - convert camera control to WebIDL r=bz
Trevor Saunders <trev.saunders@gmail.com>
parents: 141384
diff changeset
   863
void
258070
5aa09eb27b71f1a03f8afa3901c4c64d0d0208e4 Bug 1187364 - Part 1. Add ability for camera to pause/resume recording. r=dhylands,bz
Andrew Osmond <aosmond@mozilla.com>
parents: 256549
diff changeset
   864
nsDOMCameraControl::PauseRecording(ErrorResult& aRv)
5aa09eb27b71f1a03f8afa3901c4c64d0d0208e4 Bug 1187364 - Part 1. Add ability for camera to pause/resume recording. r=dhylands,bz
Andrew Osmond <aosmond@mozilla.com>
parents: 256549
diff changeset
   865
{
5aa09eb27b71f1a03f8afa3901c4c64d0d0208e4 Bug 1187364 - Part 1. Add ability for camera to pause/resume recording. r=dhylands,bz
Andrew Osmond <aosmond@mozilla.com>
parents: 256549
diff changeset
   866
  DOM_CAMERA_LOGT("%s:%d : this=%p\n", __func__, __LINE__, this);
5aa09eb27b71f1a03f8afa3901c4c64d0d0208e4 Bug 1187364 - Part 1. Add ability for camera to pause/resume recording. r=dhylands,bz
Andrew Osmond <aosmond@mozilla.com>
parents: 256549
diff changeset
   867
  THROW_IF_NO_CAMERACONTROL();
5aa09eb27b71f1a03f8afa3901c4c64d0d0208e4 Bug 1187364 - Part 1. Add ability for camera to pause/resume recording. r=dhylands,bz
Andrew Osmond <aosmond@mozilla.com>
parents: 256549
diff changeset
   868
5aa09eb27b71f1a03f8afa3901c4c64d0d0208e4 Bug 1187364 - Part 1. Add ability for camera to pause/resume recording. r=dhylands,bz
Andrew Osmond <aosmond@mozilla.com>
parents: 256549
diff changeset
   869
  aRv = mCameraControl->PauseRecording();
5aa09eb27b71f1a03f8afa3901c4c64d0d0208e4 Bug 1187364 - Part 1. Add ability for camera to pause/resume recording. r=dhylands,bz
Andrew Osmond <aosmond@mozilla.com>
parents: 256549
diff changeset
   870
}
5aa09eb27b71f1a03f8afa3901c4c64d0d0208e4 Bug 1187364 - Part 1. Add ability for camera to pause/resume recording. r=dhylands,bz
Andrew Osmond <aosmond@mozilla.com>
parents: 256549
diff changeset
   871
5aa09eb27b71f1a03f8afa3901c4c64d0d0208e4 Bug 1187364 - Part 1. Add ability for camera to pause/resume recording. r=dhylands,bz
Andrew Osmond <aosmond@mozilla.com>
parents: 256549
diff changeset
   872
void
5aa09eb27b71f1a03f8afa3901c4c64d0d0208e4 Bug 1187364 - Part 1. Add ability for camera to pause/resume recording. r=dhylands,bz
Andrew Osmond <aosmond@mozilla.com>
parents: 256549
diff changeset
   873
nsDOMCameraControl::ResumeRecording(ErrorResult& aRv)
5aa09eb27b71f1a03f8afa3901c4c64d0d0208e4 Bug 1187364 - Part 1. Add ability for camera to pause/resume recording. r=dhylands,bz
Andrew Osmond <aosmond@mozilla.com>
parents: 256549
diff changeset
   874
{
5aa09eb27b71f1a03f8afa3901c4c64d0d0208e4 Bug 1187364 - Part 1. Add ability for camera to pause/resume recording. r=dhylands,bz
Andrew Osmond <aosmond@mozilla.com>
parents: 256549
diff changeset
   875
  DOM_CAMERA_LOGT("%s:%d : this=%p\n", __func__, __LINE__, this);
5aa09eb27b71f1a03f8afa3901c4c64d0d0208e4 Bug 1187364 - Part 1. Add ability for camera to pause/resume recording. r=dhylands,bz
Andrew Osmond <aosmond@mozilla.com>
parents: 256549
diff changeset
   876
  THROW_IF_NO_CAMERACONTROL();
5aa09eb27b71f1a03f8afa3901c4c64d0d0208e4 Bug 1187364 - Part 1. Add ability for camera to pause/resume recording. r=dhylands,bz
Andrew Osmond <aosmond@mozilla.com>
parents: 256549
diff changeset
   877
5aa09eb27b71f1a03f8afa3901c4c64d0d0208e4 Bug 1187364 - Part 1. Add ability for camera to pause/resume recording. r=dhylands,bz
Andrew Osmond <aosmond@mozilla.com>
parents: 256549
diff changeset
   878
  aRv = mCameraControl->ResumeRecording();
5aa09eb27b71f1a03f8afa3901c4c64d0d0208e4 Bug 1187364 - Part 1. Add ability for camera to pause/resume recording. r=dhylands,bz
Andrew Osmond <aosmond@mozilla.com>
parents: 256549
diff changeset
   879
}
5aa09eb27b71f1a03f8afa3901c4c64d0d0208e4 Bug 1187364 - Part 1. Add ability for camera to pause/resume recording. r=dhylands,bz
Andrew Osmond <aosmond@mozilla.com>
parents: 256549
diff changeset
   880
5aa09eb27b71f1a03f8afa3901c4c64d0d0208e4 Bug 1187364 - Part 1. Add ability for camera to pause/resume recording. r=dhylands,bz
Andrew Osmond <aosmond@mozilla.com>
parents: 256549
diff changeset
   881
void
144403
614052b6cbcc905dc1e07cb1f40b02c668da7cb5 bug 899210 - convert camera control to WebIDL r=bz
Trevor Saunders <trev.saunders@gmail.com>
parents: 141384
diff changeset
   882
nsDOMCameraControl::ResumePreview(ErrorResult& aRv)
614052b6cbcc905dc1e07cb1f40b02c668da7cb5 bug 899210 - convert camera control to WebIDL r=bz
Trevor Saunders <trev.saunders@gmail.com>
parents: 141384
diff changeset
   883
{
219510
220f9cd8097a7d7b395ab0419c6aa62ae25f7058 Bug 1104055 - fix CameraControl memory leak, r=aosmond
Mike Habicher <mikeh@mozilla.com>
parents: 219181
diff changeset
   884
  DOM_CAMERA_LOGT("%s:%d : this=%p\n", __func__, __LINE__, this);
220f9cd8097a7d7b395ab0419c6aa62ae25f7058 Bug 1104055 - fix CameraControl memory leak, r=aosmond
Mike Habicher <mikeh@mozilla.com>
parents: 219181
diff changeset
   885
  THROW_IF_NO_CAMERACONTROL();
168993
e93e96ed8a5ad4999e272e2a3180a32e1ffdf94d Bug 909542 - refactor CameraControl API, r=dhylands,jst,jesup,onecyrenus
Mike Habicher <mikeh@mozilla.com>
parents: 168958
diff changeset
   886
  aRv = mCameraControl->StartPreview();
104262
244bba751ce4ae586d66d28c8e9a1f0b41e872c5 Bug 779139 - Make DOM-facing camera objects cycle collection participants. r=jst
Mike Habicher <mikeh@mozilla.com>
parents:
diff changeset
   887
}
244bba751ce4ae586d66d28c8e9a1f0b41e872c5 Bug 779139 - Make DOM-facing camera objects cycle collection participants. r=jst
Mike Habicher <mikeh@mozilla.com>
parents:
diff changeset
   888
208669
05df8323b82079743e8af61b83625739bbadf905 Bug 994912 - Add support for promises and event-based notifications to camera. r=mikeh, r=bz
Andrew Osmond <aosmond@mozilla.com>
parents: 207338
diff changeset
   889
already_AddRefed<Promise>
168993
e93e96ed8a5ad4999e272e2a3180a32e1ffdf94d Bug 909542 - refactor CameraControl API, r=dhylands,jst,jesup,onecyrenus
Mike Habicher <mikeh@mozilla.com>
parents: 168958
diff changeset
   890
nsDOMCameraControl::SetConfiguration(const CameraConfiguration& aConfiguration,
e93e96ed8a5ad4999e272e2a3180a32e1ffdf94d Bug 909542 - refactor CameraControl API, r=dhylands,jst,jesup,onecyrenus
Mike Habicher <mikeh@mozilla.com>
parents: 168958
diff changeset
   891
                                     ErrorResult& aRv)
104262
244bba751ce4ae586d66d28c8e9a1f0b41e872c5 Bug 779139 - Make DOM-facing camera objects cycle collection participants. r=jst
Mike Habicher <mikeh@mozilla.com>
parents:
diff changeset
   892
{
219510
220f9cd8097a7d7b395ab0419c6aa62ae25f7058 Bug 1104055 - fix CameraControl memory leak, r=aosmond
Mike Habicher <mikeh@mozilla.com>
parents: 219181
diff changeset
   893
  DOM_CAMERA_LOGT("%s:%d : this=%p\n", __func__, __LINE__, this);
220f9cd8097a7d7b395ab0419c6aa62ae25f7058 Bug 1104055 - fix CameraControl memory leak, r=aosmond
Mike Habicher <mikeh@mozilla.com>
parents: 219181
diff changeset
   894
  THROW_IF_NO_CAMERACONTROL(nullptr);
167937
f03664765359813c5427e78f9ff7d2202cc06915 Bug 909542 - refactor CameraControl API, r=dhylands,jst,jesup,onecyrenus
Mike Habicher <mikeh@mozilla.com>
parents: 164521
diff changeset
   895
268184
e8c7dfe727cd970e2c3294934e2927b14143c205 Bug 1207245 - part 6 - rename nsRefPtr<T> to RefPtr<T>; r=ehsan; a=Tomcat
Nathan Froyd <froydnj@mozilla.com>
parents: 266718
diff changeset
   896
  RefPtr<Promise> promise = CreatePromise(aRv);
208669
05df8323b82079743e8af61b83625739bbadf905 Bug 994912 - Add support for promises and event-based notifications to camera. r=mikeh, r=bz
Andrew Osmond <aosmond@mozilla.com>
parents: 207338
diff changeset
   897
  if (aRv.Failed()) {
05df8323b82079743e8af61b83625739bbadf905 Bug 994912 - Add support for promises and event-based notifications to camera. r=mikeh, r=bz
Andrew Osmond <aosmond@mozilla.com>
parents: 207338
diff changeset
   898
    return nullptr;
05df8323b82079743e8af61b83625739bbadf905 Bug 994912 - Add support for promises and event-based notifications to camera. r=mikeh, r=bz
Andrew Osmond <aosmond@mozilla.com>
parents: 207338
diff changeset
   899
  }
05df8323b82079743e8af61b83625739bbadf905 Bug 994912 - Add support for promises and event-based notifications to camera. r=mikeh, r=bz
Andrew Osmond <aosmond@mozilla.com>
parents: 207338
diff changeset
   900
05df8323b82079743e8af61b83625739bbadf905 Bug 994912 - Add support for promises and event-based notifications to camera. r=mikeh, r=bz
Andrew Osmond <aosmond@mozilla.com>
parents: 207338
diff changeset
   901
  if (mTakePicturePromise) {
219181
12c5cc6e88b326e2e4006fc6573bf01e0fea54c2 Bug 1107683 - remove method callbacks from CameraControl, r=aosmond,bz
Mike Habicher <mikeh@mozilla.com>
parents: 217721
diff changeset
   902
    // We're busy taking a picture, can't change modes right now.
208669
05df8323b82079743e8af61b83625739bbadf905 Bug 994912 - Add support for promises and event-based notifications to camera. r=mikeh, r=bz
Andrew Osmond <aosmond@mozilla.com>
parents: 207338
diff changeset
   903
    promise->MaybeReject(NS_ERROR_IN_PROGRESS);
05df8323b82079743e8af61b83625739bbadf905 Bug 994912 - Add support for promises and event-based notifications to camera. r=mikeh, r=bz
Andrew Osmond <aosmond@mozilla.com>
parents: 207338
diff changeset
   904
    return promise.forget();
168933
6e588c56764b60b96ed24af813b955db02a3f936 Bug 909542 - refactor CameraControl API, r=dhylands,jst,jesup,onecyrenus
Mike Habicher <mikeh@mozilla.com>
parents: 167944
diff changeset
   905
  }
6e588c56764b60b96ed24af813b955db02a3f936 Bug 909542 - refactor CameraControl API, r=dhylands,jst,jesup,onecyrenus
Mike Habicher <mikeh@mozilla.com>
parents: 167944
diff changeset
   906
168993
e93e96ed8a5ad4999e272e2a3180a32e1ffdf94d Bug 909542 - refactor CameraControl API, r=dhylands,jst,jesup,onecyrenus
Mike Habicher <mikeh@mozilla.com>
parents: 168958
diff changeset
   907
  ICameraControl::Configuration config;
220237
ce9707a48002c8fd80f1c921b13e8f6e40d54f43 Bug 1104913 - Update selection algorithms for preview, picture and video sizes to have sane defaults. r=mikeh, r=bz
Andrew Osmond <aosmond@gmail.com>
parents: 219511
diff changeset
   908
  aRv = SelectPreviewSize(aConfiguration.mPreviewSize, config.mPreviewSize);
ce9707a48002c8fd80f1c921b13e8f6e40d54f43 Bug 1104913 - Update selection algorithms for preview, picture and video sizes to have sane defaults. r=mikeh, r=bz
Andrew Osmond <aosmond@gmail.com>
parents: 219511
diff changeset
   909
  if (aRv.Failed()) {
ce9707a48002c8fd80f1c921b13e8f6e40d54f43 Bug 1104913 - Update selection algorithms for preview, picture and video sizes to have sane defaults. r=mikeh, r=bz
Andrew Osmond <aosmond@gmail.com>
parents: 219511
diff changeset
   910
    return nullptr;
ce9707a48002c8fd80f1c921b13e8f6e40d54f43 Bug 1104913 - Update selection algorithms for preview, picture and video sizes to have sane defaults. r=mikeh, r=bz
Andrew Osmond <aosmond@gmail.com>
parents: 219511
diff changeset
   911
  }
ce9707a48002c8fd80f1c921b13e8f6e40d54f43 Bug 1104913 - Update selection algorithms for preview, picture and video sizes to have sane defaults. r=mikeh, r=bz
Andrew Osmond <aosmond@gmail.com>
parents: 219511
diff changeset
   912
168993
e93e96ed8a5ad4999e272e2a3180a32e1ffdf94d Bug 909542 - refactor CameraControl API, r=dhylands,jst,jesup,onecyrenus
Mike Habicher <mikeh@mozilla.com>
parents: 168958
diff changeset
   913
  config.mRecorderProfile = aConfiguration.mRecorderProfile;
220237
ce9707a48002c8fd80f1c921b13e8f6e40d54f43 Bug 1104913 - Update selection algorithms for preview, picture and video sizes to have sane defaults. r=mikeh, r=bz
Andrew Osmond <aosmond@gmail.com>
parents: 219511
diff changeset
   914
  config.mPictureSize.width = aConfiguration.mPictureSize.mWidth;
ce9707a48002c8fd80f1c921b13e8f6e40d54f43 Bug 1104913 - Update selection algorithms for preview, picture and video sizes to have sane defaults. r=mikeh, r=bz
Andrew Osmond <aosmond@gmail.com>
parents: 219511
diff changeset
   915
  config.mPictureSize.height = aConfiguration.mPictureSize.mHeight;
168993
e93e96ed8a5ad4999e272e2a3180a32e1ffdf94d Bug 909542 - refactor CameraControl API, r=dhylands,jst,jesup,onecyrenus
Mike Habicher <mikeh@mozilla.com>
parents: 168958
diff changeset
   916
  config.mMode = ICameraControl::kPictureMode;
e93e96ed8a5ad4999e272e2a3180a32e1ffdf94d Bug 909542 - refactor CameraControl API, r=dhylands,jst,jesup,onecyrenus
Mike Habicher <mikeh@mozilla.com>
parents: 168958
diff changeset
   917
  if (aConfiguration.mMode == CameraMode::Video) {
e93e96ed8a5ad4999e272e2a3180a32e1ffdf94d Bug 909542 - refactor CameraControl API, r=dhylands,jst,jesup,onecyrenus
Mike Habicher <mikeh@mozilla.com>
parents: 168958
diff changeset
   918
    config.mMode = ICameraControl::kVideoMode;
e93e96ed8a5ad4999e272e2a3180a32e1ffdf94d Bug 909542 - refactor CameraControl API, r=dhylands,jst,jesup,onecyrenus
Mike Habicher <mikeh@mozilla.com>
parents: 168958
diff changeset
   919
  }
e93e96ed8a5ad4999e272e2a3180a32e1ffdf94d Bug 909542 - refactor CameraControl API, r=dhylands,jst,jesup,onecyrenus
Mike Habicher <mikeh@mozilla.com>
parents: 168958
diff changeset
   920
208669
05df8323b82079743e8af61b83625739bbadf905 Bug 994912 - Add support for promises and event-based notifications to camera. r=mikeh, r=bz
Andrew Osmond <aosmond@mozilla.com>
parents: 207338
diff changeset
   921
  aRv = mCameraControl->SetConfiguration(config);
05df8323b82079743e8af61b83625739bbadf905 Bug 994912 - Add support for promises and event-based notifications to camera. r=mikeh, r=bz
Andrew Osmond <aosmond@mozilla.com>
parents: 207338
diff changeset
   922
  if (aRv.Failed()) {
05df8323b82079743e8af61b83625739bbadf905 Bug 994912 - Add support for promises and event-based notifications to camera. r=mikeh, r=bz
Andrew Osmond <aosmond@mozilla.com>
parents: 207338
diff changeset
   923
    return nullptr;
05df8323b82079743e8af61b83625739bbadf905 Bug 994912 - Add support for promises and event-based notifications to camera. r=mikeh, r=bz
Andrew Osmond <aosmond@mozilla.com>
parents: 207338
diff changeset
   924
  }
05df8323b82079743e8af61b83625739bbadf905 Bug 994912 - Add support for promises and event-based notifications to camera. r=mikeh, r=bz
Andrew Osmond <aosmond@mozilla.com>
parents: 207338
diff changeset
   925
05df8323b82079743e8af61b83625739bbadf905 Bug 994912 - Add support for promises and event-based notifications to camera. r=mikeh, r=bz
Andrew Osmond <aosmond@mozilla.com>
parents: 207338
diff changeset
   926
  mSetConfigurationPromise = promise;
05df8323b82079743e8af61b83625739bbadf905 Bug 994912 - Add support for promises and event-based notifications to camera. r=mikeh, r=bz
Andrew Osmond <aosmond@mozilla.com>
parents: 207338
diff changeset
   927
  return promise.forget();
168993
e93e96ed8a5ad4999e272e2a3180a32e1ffdf94d Bug 909542 - refactor CameraControl API, r=dhylands,jst,jesup,onecyrenus
Mike Habicher <mikeh@mozilla.com>
parents: 168958
diff changeset
   928
}
e93e96ed8a5ad4999e272e2a3180a32e1ffdf94d Bug 909542 - refactor CameraControl API, r=dhylands,jst,jesup,onecyrenus
Mike Habicher <mikeh@mozilla.com>
parents: 168958
diff changeset
   929
208669
05df8323b82079743e8af61b83625739bbadf905 Bug 994912 - Add support for promises and event-based notifications to camera. r=mikeh, r=bz
Andrew Osmond <aosmond@mozilla.com>
parents: 207338
diff changeset
   930
already_AddRefed<Promise>
219181
12c5cc6e88b326e2e4006fc6573bf01e0fea54c2 Bug 1107683 - remove method callbacks from CameraControl, r=aosmond,bz
Mike Habicher <mikeh@mozilla.com>
parents: 217721
diff changeset
   931
nsDOMCameraControl::AutoFocus(ErrorResult& aRv)
168993
e93e96ed8a5ad4999e272e2a3180a32e1ffdf94d Bug 909542 - refactor CameraControl API, r=dhylands,jst,jesup,onecyrenus
Mike Habicher <mikeh@mozilla.com>
parents: 168958
diff changeset
   932
{
219510
220f9cd8097a7d7b395ab0419c6aa62ae25f7058 Bug 1104055 - fix CameraControl memory leak, r=aosmond
Mike Habicher <mikeh@mozilla.com>
parents: 219181
diff changeset
   933
  DOM_CAMERA_LOGT("%s:%d : this=%p\n", __func__, __LINE__, this);
220f9cd8097a7d7b395ab0419c6aa62ae25f7058 Bug 1104055 - fix CameraControl memory leak, r=aosmond
Mike Habicher <mikeh@mozilla.com>
parents: 219181
diff changeset
   934
  THROW_IF_NO_CAMERACONTROL(nullptr);
168993
e93e96ed8a5ad4999e272e2a3180a32e1ffdf94d Bug 909542 - refactor CameraControl API, r=dhylands,jst,jesup,onecyrenus
Mike Habicher <mikeh@mozilla.com>
parents: 168958
diff changeset
   935
268184
e8c7dfe727cd970e2c3294934e2927b14143c205 Bug 1207245 - part 6 - rename nsRefPtr<T> to RefPtr<T>; r=ehsan; a=Tomcat
Nathan Froyd <froydnj@mozilla.com>
parents: 266718
diff changeset
   936
  RefPtr<Promise> promise = mAutoFocusPromise.forget();
208669
05df8323b82079743e8af61b83625739bbadf905 Bug 994912 - Add support for promises and event-based notifications to camera. r=mikeh, r=bz
Andrew Osmond <aosmond@mozilla.com>
parents: 207338
diff changeset
   937
  if (promise) {
188522
583635fb7525917c498ea3504e8ae23ed50e2de7 Bug 1022766 - allow autoFocus() to interrupt earlier calls, r=dhylands
Mike Habicher <mikeh@mozilla.com>
parents: 187969
diff changeset
   938
    // There is already a call to AutoFocus() in progress, cancel it and
583635fb7525917c498ea3504e8ae23ed50e2de7 Bug 1022766 - allow autoFocus() to interrupt earlier calls, r=dhylands
Mike Habicher <mikeh@mozilla.com>
parents: 187969
diff changeset
   939
    // invoke the error callback (if one was passed in).
208669
05df8323b82079743e8af61b83625739bbadf905 Bug 994912 - Add support for promises and event-based notifications to camera. r=mikeh, r=bz
Andrew Osmond <aosmond@mozilla.com>
parents: 207338
diff changeset
   940
    promise->MaybeReject(NS_ERROR_IN_PROGRESS);
168993
e93e96ed8a5ad4999e272e2a3180a32e1ffdf94d Bug 909542 - refactor CameraControl API, r=dhylands,jst,jesup,onecyrenus
Mike Habicher <mikeh@mozilla.com>
parents: 168958
diff changeset
   941
  }
e93e96ed8a5ad4999e272e2a3180a32e1ffdf94d Bug 909542 - refactor CameraControl API, r=dhylands,jst,jesup,onecyrenus
Mike Habicher <mikeh@mozilla.com>
parents: 168958
diff changeset
   942
208669
05df8323b82079743e8af61b83625739bbadf905 Bug 994912 - Add support for promises and event-based notifications to camera. r=mikeh, r=bz
Andrew Osmond <aosmond@mozilla.com>
parents: 207338
diff changeset
   943
  promise = CreatePromise(aRv);
05df8323b82079743e8af61b83625739bbadf905 Bug 994912 - Add support for promises and event-based notifications to camera. r=mikeh, r=bz
Andrew Osmond <aosmond@mozilla.com>
parents: 207338
diff changeset
   944
  if (aRv.Failed()) {
05df8323b82079743e8af61b83625739bbadf905 Bug 994912 - Add support for promises and event-based notifications to camera. r=mikeh, r=bz
Andrew Osmond <aosmond@mozilla.com>
parents: 207338
diff changeset
   945
    return nullptr;
05df8323b82079743e8af61b83625739bbadf905 Bug 994912 - Add support for promises and event-based notifications to camera. r=mikeh, r=bz
Andrew Osmond <aosmond@mozilla.com>
parents: 207338
diff changeset
   946
  }
05df8323b82079743e8af61b83625739bbadf905 Bug 994912 - Add support for promises and event-based notifications to camera. r=mikeh, r=bz
Andrew Osmond <aosmond@mozilla.com>
parents: 207338
diff changeset
   947
05df8323b82079743e8af61b83625739bbadf905 Bug 994912 - Add support for promises and event-based notifications to camera. r=mikeh, r=bz
Andrew Osmond <aosmond@mozilla.com>
parents: 207338
diff changeset
   948
  aRv = mCameraControl->AutoFocus();
05df8323b82079743e8af61b83625739bbadf905 Bug 994912 - Add support for promises and event-based notifications to camera. r=mikeh, r=bz
Andrew Osmond <aosmond@mozilla.com>
parents: 207338
diff changeset
   949
  if (aRv.Failed()) {
05df8323b82079743e8af61b83625739bbadf905 Bug 994912 - Add support for promises and event-based notifications to camera. r=mikeh, r=bz
Andrew Osmond <aosmond@mozilla.com>
parents: 207338
diff changeset
   950
    return nullptr;
05df8323b82079743e8af61b83625739bbadf905 Bug 994912 - Add support for promises and event-based notifications to camera. r=mikeh, r=bz
Andrew Osmond <aosmond@mozilla.com>
parents: 207338
diff changeset
   951
  }
05df8323b82079743e8af61b83625739bbadf905 Bug 994912 - Add support for promises and event-based notifications to camera. r=mikeh, r=bz
Andrew Osmond <aosmond@mozilla.com>
parents: 207338
diff changeset
   952
05df8323b82079743e8af61b83625739bbadf905 Bug 994912 - Add support for promises and event-based notifications to camera. r=mikeh, r=bz
Andrew Osmond <aosmond@mozilla.com>
parents: 207338
diff changeset
   953
  DispatchStateEvent(NS_LITERAL_STRING("focus"), NS_LITERAL_STRING("focusing"));
05df8323b82079743e8af61b83625739bbadf905 Bug 994912 - Add support for promises and event-based notifications to camera. r=mikeh, r=bz
Andrew Osmond <aosmond@mozilla.com>
parents: 207338
diff changeset
   954
05df8323b82079743e8af61b83625739bbadf905 Bug 994912 - Add support for promises and event-based notifications to camera. r=mikeh, r=bz
Andrew Osmond <aosmond@mozilla.com>
parents: 207338
diff changeset
   955
  mAutoFocusPromise = promise;
05df8323b82079743e8af61b83625739bbadf905 Bug 994912 - Add support for promises and event-based notifications to camera. r=mikeh, r=bz
Andrew Osmond <aosmond@mozilla.com>
parents: 207338
diff changeset
   956
  return promise.forget();
167944
f6db7c7f226f29a0904558938c6aed96f0c8853b Back out f03664765359 (bug 909542) for unexpected assertions and lack of expected assertions
Phil Ringnalda <philringnalda@gmail.com>
parents: 167937
diff changeset
   957
}
f6db7c7f226f29a0904558938c6aed96f0c8853b Back out f03664765359 (bug 909542) for unexpected assertions and lack of expected assertions
Phil Ringnalda <philringnalda@gmail.com>
parents: 167937
diff changeset
   958
168933
6e588c56764b60b96ed24af813b955db02a3f936 Bug 909542 - refactor CameraControl API, r=dhylands,jst,jesup,onecyrenus
Mike Habicher <mikeh@mozilla.com>
parents: 167944
diff changeset
   959
void
177874
e6ac52f874d097648fcf91fd2db247af3a297d6b Bug 965420 - camera face-tracking, r=bz,dhylands
Mike Habicher <mikeh@mozilla.com>
parents: 177873
diff changeset
   960
nsDOMCameraControl::StartFaceDetection(ErrorResult& aRv)
e6ac52f874d097648fcf91fd2db247af3a297d6b Bug 965420 - camera face-tracking, r=bz,dhylands
Mike Habicher <mikeh@mozilla.com>
parents: 177873
diff changeset
   961
{
219510
220f9cd8097a7d7b395ab0419c6aa62ae25f7058 Bug 1104055 - fix CameraControl memory leak, r=aosmond
Mike Habicher <mikeh@mozilla.com>
parents: 219181
diff changeset
   962
  DOM_CAMERA_LOGT("%s:%d : this=%p\n", __func__, __LINE__, this);
220f9cd8097a7d7b395ab0419c6aa62ae25f7058 Bug 1104055 - fix CameraControl memory leak, r=aosmond
Mike Habicher <mikeh@mozilla.com>
parents: 219181
diff changeset
   963
  THROW_IF_NO_CAMERACONTROL();
177874
e6ac52f874d097648fcf91fd2db247af3a297d6b Bug 965420 - camera face-tracking, r=bz,dhylands
Mike Habicher <mikeh@mozilla.com>
parents: 177873
diff changeset
   964
  aRv = mCameraControl->StartFaceDetection();
e6ac52f874d097648fcf91fd2db247af3a297d6b Bug 965420 - camera face-tracking, r=bz,dhylands
Mike Habicher <mikeh@mozilla.com>
parents: 177873
diff changeset
   965
}
e6ac52f874d097648fcf91fd2db247af3a297d6b Bug 965420 - camera face-tracking, r=bz,dhylands
Mike Habicher <mikeh@mozilla.com>
parents: 177873
diff changeset
   966
e6ac52f874d097648fcf91fd2db247af3a297d6b Bug 965420 - camera face-tracking, r=bz,dhylands
Mike Habicher <mikeh@mozilla.com>
parents: 177873
diff changeset
   967
void
e6ac52f874d097648fcf91fd2db247af3a297d6b Bug 965420 - camera face-tracking, r=bz,dhylands
Mike Habicher <mikeh@mozilla.com>
parents: 177873
diff changeset
   968
nsDOMCameraControl::StopFaceDetection(ErrorResult& aRv)
e6ac52f874d097648fcf91fd2db247af3a297d6b Bug 965420 - camera face-tracking, r=bz,dhylands
Mike Habicher <mikeh@mozilla.com>
parents: 177873
diff changeset
   969
{
219510
220f9cd8097a7d7b395ab0419c6aa62ae25f7058 Bug 1104055 - fix CameraControl memory leak, r=aosmond
Mike Habicher <mikeh@mozilla.com>
parents: 219181
diff changeset
   970
  DOM_CAMERA_LOGT("%s:%d : this=%p\n", __func__, __LINE__, this);
220f9cd8097a7d7b395ab0419c6aa62ae25f7058 Bug 1104055 - fix CameraControl memory leak, r=aosmond
Mike Habicher <mikeh@mozilla.com>
parents: 219181
diff changeset
   971
  THROW_IF_NO_CAMERACONTROL();
177874
e6ac52f874d097648fcf91fd2db247af3a297d6b Bug 965420 - camera face-tracking, r=bz,dhylands
Mike Habicher <mikeh@mozilla.com>
parents: 177873
diff changeset
   972
  aRv = mCameraControl->StopFaceDetection();
e6ac52f874d097648fcf91fd2db247af3a297d6b Bug 965420 - camera face-tracking, r=bz,dhylands
Mike Habicher <mikeh@mozilla.com>
parents: 177873
diff changeset
   973
}
e6ac52f874d097648fcf91fd2db247af3a297d6b Bug 965420 - camera face-tracking, r=bz,dhylands
Mike Habicher <mikeh@mozilla.com>
parents: 177873
diff changeset
   974
208669
05df8323b82079743e8af61b83625739bbadf905 Bug 994912 - Add support for promises and event-based notifications to camera. r=mikeh, r=bz
Andrew Osmond <aosmond@mozilla.com>
parents: 207338
diff changeset
   975
already_AddRefed<Promise>
168993
e93e96ed8a5ad4999e272e2a3180a32e1ffdf94d Bug 909542 - refactor CameraControl API, r=dhylands,jst,jesup,onecyrenus
Mike Habicher <mikeh@mozilla.com>
parents: 168958
diff changeset
   976
nsDOMCameraControl::TakePicture(const CameraPictureOptions& aOptions,
e93e96ed8a5ad4999e272e2a3180a32e1ffdf94d Bug 909542 - refactor CameraControl API, r=dhylands,jst,jesup,onecyrenus
Mike Habicher <mikeh@mozilla.com>
parents: 168958
diff changeset
   977
                                ErrorResult& aRv)
167944
f6db7c7f226f29a0904558938c6aed96f0c8853b Back out f03664765359 (bug 909542) for unexpected assertions and lack of expected assertions
Phil Ringnalda <philringnalda@gmail.com>
parents: 167937
diff changeset
   978
{
219510
220f9cd8097a7d7b395ab0419c6aa62ae25f7058 Bug 1104055 - fix CameraControl memory leak, r=aosmond
Mike Habicher <mikeh@mozilla.com>
parents: 219181
diff changeset
   979
  DOM_CAMERA_LOGT("%s:%d : this=%p\n", __func__, __LINE__, this);
220f9cd8097a7d7b395ab0419c6aa62ae25f7058 Bug 1104055 - fix CameraControl memory leak, r=aosmond
Mike Habicher <mikeh@mozilla.com>
parents: 219181
diff changeset
   980
  THROW_IF_NO_CAMERACONTROL(nullptr);
168993
e93e96ed8a5ad4999e272e2a3180a32e1ffdf94d Bug 909542 - refactor CameraControl API, r=dhylands,jst,jesup,onecyrenus
Mike Habicher <mikeh@mozilla.com>
parents: 168958
diff changeset
   981
268184
e8c7dfe727cd970e2c3294934e2927b14143c205 Bug 1207245 - part 6 - rename nsRefPtr<T> to RefPtr<T>; r=ehsan; a=Tomcat
Nathan Froyd <froydnj@mozilla.com>
parents: 266718
diff changeset
   982
  RefPtr<Promise> promise = CreatePromise(aRv);
208669
05df8323b82079743e8af61b83625739bbadf905 Bug 994912 - Add support for promises and event-based notifications to camera. r=mikeh, r=bz
Andrew Osmond <aosmond@mozilla.com>
parents: 207338
diff changeset
   983
  if (aRv.Failed()) {
05df8323b82079743e8af61b83625739bbadf905 Bug 994912 - Add support for promises and event-based notifications to camera. r=mikeh, r=bz
Andrew Osmond <aosmond@mozilla.com>
parents: 207338
diff changeset
   984
    return nullptr;
05df8323b82079743e8af61b83625739bbadf905 Bug 994912 - Add support for promises and event-based notifications to camera. r=mikeh, r=bz
Andrew Osmond <aosmond@mozilla.com>
parents: 207338
diff changeset
   985
  }
05df8323b82079743e8af61b83625739bbadf905 Bug 994912 - Add support for promises and event-based notifications to camera. r=mikeh, r=bz
Andrew Osmond <aosmond@mozilla.com>
parents: 207338
diff changeset
   986
05df8323b82079743e8af61b83625739bbadf905 Bug 994912 - Add support for promises and event-based notifications to camera. r=mikeh, r=bz
Andrew Osmond <aosmond@mozilla.com>
parents: 207338
diff changeset
   987
  if (mTakePicturePromise) {
05df8323b82079743e8af61b83625739bbadf905 Bug 994912 - Add support for promises and event-based notifications to camera. r=mikeh, r=bz
Andrew Osmond <aosmond@mozilla.com>
parents: 207338
diff changeset
   988
    // There is already a call to TakePicture() in progress, abort this new
05df8323b82079743e8af61b83625739bbadf905 Bug 994912 - Add support for promises and event-based notifications to camera. r=mikeh, r=bz
Andrew Osmond <aosmond@mozilla.com>
parents: 207338
diff changeset
   989
    // one and invoke the error callback (if one was passed in).
05df8323b82079743e8af61b83625739bbadf905 Bug 994912 - Add support for promises and event-based notifications to camera. r=mikeh, r=bz
Andrew Osmond <aosmond@mozilla.com>
parents: 207338
diff changeset
   990
    promise->MaybeReject(NS_ERROR_IN_PROGRESS);
05df8323b82079743e8af61b83625739bbadf905 Bug 994912 - Add support for promises and event-based notifications to camera. r=mikeh, r=bz
Andrew Osmond <aosmond@mozilla.com>
parents: 207338
diff changeset
   991
    return promise.forget();
168993
e93e96ed8a5ad4999e272e2a3180a32e1ffdf94d Bug 909542 - refactor CameraControl API, r=dhylands,jst,jesup,onecyrenus
Mike Habicher <mikeh@mozilla.com>
parents: 168958
diff changeset
   992
  }
e93e96ed8a5ad4999e272e2a3180a32e1ffdf94d Bug 909542 - refactor CameraControl API, r=dhylands,jst,jesup,onecyrenus
Mike Habicher <mikeh@mozilla.com>
parents: 168958
diff changeset
   993
e93e96ed8a5ad4999e272e2a3180a32e1ffdf94d Bug 909542 - refactor CameraControl API, r=dhylands,jst,jesup,onecyrenus
Mike Habicher <mikeh@mozilla.com>
parents: 168958
diff changeset
   994
  {
e93e96ed8a5ad4999e272e2a3180a32e1ffdf94d Bug 909542 - refactor CameraControl API, r=dhylands,jst,jesup,onecyrenus
Mike Habicher <mikeh@mozilla.com>
parents: 168958
diff changeset
   995
    ICameraControlParameterSetAutoEnter batch(mCameraControl);
e93e96ed8a5ad4999e272e2a3180a32e1ffdf94d Bug 909542 - refactor CameraControl API, r=dhylands,jst,jesup,onecyrenus
Mike Habicher <mikeh@mozilla.com>
parents: 168958
diff changeset
   996
e93e96ed8a5ad4999e272e2a3180a32e1ffdf94d Bug 909542 - refactor CameraControl API, r=dhylands,jst,jesup,onecyrenus
Mike Habicher <mikeh@mozilla.com>
parents: 168958
diff changeset
   997
    // XXXmikeh - remove this: see bug 931155
e93e96ed8a5ad4999e272e2a3180a32e1ffdf94d Bug 909542 - refactor CameraControl API, r=dhylands,jst,jesup,onecyrenus
Mike Habicher <mikeh@mozilla.com>
parents: 168958
diff changeset
   998
    ICameraControl::Size s;
e93e96ed8a5ad4999e272e2a3180a32e1ffdf94d Bug 909542 - refactor CameraControl API, r=dhylands,jst,jesup,onecyrenus
Mike Habicher <mikeh@mozilla.com>
parents: 168958
diff changeset
   999
    s.width = aOptions.mPictureSize.mWidth;
e93e96ed8a5ad4999e272e2a3180a32e1ffdf94d Bug 909542 - refactor CameraControl API, r=dhylands,jst,jesup,onecyrenus
Mike Habicher <mikeh@mozilla.com>
parents: 168958
diff changeset
  1000
    s.height = aOptions.mPictureSize.mHeight;
e93e96ed8a5ad4999e272e2a3180a32e1ffdf94d Bug 909542 - refactor CameraControl API, r=dhylands,jst,jesup,onecyrenus
Mike Habicher <mikeh@mozilla.com>
parents: 168958
diff changeset
  1001
e93e96ed8a5ad4999e272e2a3180a32e1ffdf94d Bug 909542 - refactor CameraControl API, r=dhylands,jst,jesup,onecyrenus
Mike Habicher <mikeh@mozilla.com>
parents: 168958
diff changeset
  1002
    ICameraControl::Position p;
e93e96ed8a5ad4999e272e2a3180a32e1ffdf94d Bug 909542 - refactor CameraControl API, r=dhylands,jst,jesup,onecyrenus
Mike Habicher <mikeh@mozilla.com>
parents: 168958
diff changeset
  1003
    p.latitude = aOptions.mPosition.mLatitude;
e93e96ed8a5ad4999e272e2a3180a32e1ffdf94d Bug 909542 - refactor CameraControl API, r=dhylands,jst,jesup,onecyrenus
Mike Habicher <mikeh@mozilla.com>
parents: 168958
diff changeset
  1004
    p.longitude = aOptions.mPosition.mLongitude;
e93e96ed8a5ad4999e272e2a3180a32e1ffdf94d Bug 909542 - refactor CameraControl API, r=dhylands,jst,jesup,onecyrenus
Mike Habicher <mikeh@mozilla.com>
parents: 168958
diff changeset
  1005
    p.altitude = aOptions.mPosition.mAltitude;
e93e96ed8a5ad4999e272e2a3180a32e1ffdf94d Bug 909542 - refactor CameraControl API, r=dhylands,jst,jesup,onecyrenus
Mike Habicher <mikeh@mozilla.com>
parents: 168958
diff changeset
  1006
    p.timestamp = aOptions.mPosition.mTimestamp;
e93e96ed8a5ad4999e272e2a3180a32e1ffdf94d Bug 909542 - refactor CameraControl API, r=dhylands,jst,jesup,onecyrenus
Mike Habicher <mikeh@mozilla.com>
parents: 168958
diff changeset
  1007
e93e96ed8a5ad4999e272e2a3180a32e1ffdf94d Bug 909542 - refactor CameraControl API, r=dhylands,jst,jesup,onecyrenus
Mike Habicher <mikeh@mozilla.com>
parents: 168958
diff changeset
  1008
    if (s.width && s.height) {
e93e96ed8a5ad4999e272e2a3180a32e1ffdf94d Bug 909542 - refactor CameraControl API, r=dhylands,jst,jesup,onecyrenus
Mike Habicher <mikeh@mozilla.com>
parents: 168958
diff changeset
  1009
      mCameraControl->Set(CAMERA_PARAM_PICTURE_SIZE, s);
e93e96ed8a5ad4999e272e2a3180a32e1ffdf94d Bug 909542 - refactor CameraControl API, r=dhylands,jst,jesup,onecyrenus
Mike Habicher <mikeh@mozilla.com>
parents: 168958
diff changeset
  1010
    }
239875
be44c0a5cf9ec6a188e2cc3f11ab82925f78767c Bug 1144211 - Improve code coverage of camera mochitests. r=mikeh
Andrew Osmond <aosmond@gmail.com>
parents: 239558
diff changeset
  1011
    if (!aOptions.mFileFormat.IsEmpty()) {
be44c0a5cf9ec6a188e2cc3f11ab82925f78767c Bug 1144211 - Improve code coverage of camera mochitests. r=mikeh
Andrew Osmond <aosmond@gmail.com>
parents: 239558
diff changeset
  1012
      mCameraControl->Set(CAMERA_PARAM_PICTURE_FILEFORMAT, aOptions.mFileFormat);
be44c0a5cf9ec6a188e2cc3f11ab82925f78767c Bug 1144211 - Improve code coverage of camera mochitests. r=mikeh
Andrew Osmond <aosmond@gmail.com>
parents: 239558
diff changeset
  1013
    }
168993
e93e96ed8a5ad4999e272e2a3180a32e1ffdf94d Bug 909542 - refactor CameraControl API, r=dhylands,jst,jesup,onecyrenus
Mike Habicher <mikeh@mozilla.com>
parents: 168958
diff changeset
  1014
    mCameraControl->Set(CAMERA_PARAM_PICTURE_ROTATION, aOptions.mRotation);
e93e96ed8a5ad4999e272e2a3180a32e1ffdf94d Bug 909542 - refactor CameraControl API, r=dhylands,jst,jesup,onecyrenus
Mike Habicher <mikeh@mozilla.com>
parents: 168958
diff changeset
  1015
    mCameraControl->Set(CAMERA_PARAM_PICTURE_DATETIME, aOptions.mDateTime);
e93e96ed8a5ad4999e272e2a3180a32e1ffdf94d Bug 909542 - refactor CameraControl API, r=dhylands,jst,jesup,onecyrenus
Mike Habicher <mikeh@mozilla.com>
parents: 168958
diff changeset
  1016
    mCameraControl->SetLocation(p);
e93e96ed8a5ad4999e272e2a3180a32e1ffdf94d Bug 909542 - refactor CameraControl API, r=dhylands,jst,jesup,onecyrenus
Mike Habicher <mikeh@mozilla.com>
parents: 168958
diff changeset
  1017
  }
e93e96ed8a5ad4999e272e2a3180a32e1ffdf94d Bug 909542 - refactor CameraControl API, r=dhylands,jst,jesup,onecyrenus
Mike Habicher <mikeh@mozilla.com>
parents: 168958
diff changeset
  1018
208669
05df8323b82079743e8af61b83625739bbadf905 Bug 994912 - Add support for promises and event-based notifications to camera. r=mikeh, r=bz
Andrew Osmond <aosmond@mozilla.com>
parents: 207338
diff changeset
  1019
  aRv = mCameraControl->TakePicture();
05df8323b82079743e8af61b83625739bbadf905 Bug 994912 - Add support for promises and event-based notifications to camera. r=mikeh, r=bz
Andrew Osmond <aosmond@mozilla.com>
parents: 207338
diff changeset
  1020
  if (aRv.Failed()) {
05df8323b82079743e8af61b83625739bbadf905 Bug 994912 - Add support for promises and event-based notifications to camera. r=mikeh, r=bz
Andrew Osmond <aosmond@mozilla.com>
parents: 207338
diff changeset
  1021
    return nullptr;
05df8323b82079743e8af61b83625739bbadf905 Bug 994912 - Add support for promises and event-based notifications to camera. r=mikeh, r=bz
Andrew Osmond <aosmond@mozilla.com>
parents: 207338
diff changeset
  1022
  }
05df8323b82079743e8af61b83625739bbadf905 Bug 994912 - Add support for promises and event-based notifications to camera. r=mikeh, r=bz
Andrew Osmond <aosmond@mozilla.com>
parents: 207338
diff changeset
  1023
05df8323b82079743e8af61b83625739bbadf905 Bug 994912 - Add support for promises and event-based notifications to camera. r=mikeh, r=bz
Andrew Osmond <aosmond@mozilla.com>
parents: 207338
diff changeset
  1024
  mTakePicturePromise = promise;
05df8323b82079743e8af61b83625739bbadf905 Bug 994912 - Add support for promises and event-based notifications to camera. r=mikeh, r=bz
Andrew Osmond <aosmond@mozilla.com>
parents: 207338
diff changeset
  1025
  return promise.forget();
168958
b47b10e405a5831013e362918519a1e7f3bb4dd3 Backed out changeset 6e588c56764b (bug 909542) for Gaia unit test perma-fail.
Ryan VanderMeulen <ryanvm@gmail.com>
parents: 168933
diff changeset
  1026
}
b47b10e405a5831013e362918519a1e7f3bb4dd3 Backed out changeset 6e588c56764b (bug 909542) for Gaia unit test perma-fail.
Ryan VanderMeulen <ryanvm@gmail.com>
parents: 168933
diff changeset
  1027
208669
05df8323b82079743e8af61b83625739bbadf905 Bug 994912 - Add support for promises and event-based notifications to camera. r=mikeh, r=bz
Andrew Osmond <aosmond@mozilla.com>
parents: 207338
diff changeset
  1028
already_AddRefed<Promise>
219181
12c5cc6e88b326e2e4006fc6573bf01e0fea54c2 Bug 1107683 - remove method callbacks from CameraControl, r=aosmond,bz
Mike Habicher <mikeh@mozilla.com>
parents: 217721
diff changeset
  1029
nsDOMCameraControl::ReleaseHardware(ErrorResult& aRv)
168958
b47b10e405a5831013e362918519a1e7f3bb4dd3 Backed out changeset 6e588c56764b (bug 909542) for Gaia unit test perma-fail.
Ryan VanderMeulen <ryanvm@gmail.com>
parents: 168933
diff changeset
  1030
{
219510
220f9cd8097a7d7b395ab0419c6aa62ae25f7058 Bug 1104055 - fix CameraControl memory leak, r=aosmond
Mike Habicher <mikeh@mozilla.com>
parents: 219181
diff changeset
  1031
  DOM_CAMERA_LOGI("%s:%d : this=%p\n", __func__, __LINE__, this);
168958
b47b10e405a5831013e362918519a1e7f3bb4dd3 Backed out changeset 6e588c56764b (bug 909542) for Gaia unit test perma-fail.
Ryan VanderMeulen <ryanvm@gmail.com>
parents: 168933
diff changeset
  1032
268184
e8c7dfe727cd970e2c3294934e2927b14143c205 Bug 1207245 - part 6 - rename nsRefPtr<T> to RefPtr<T>; r=ehsan; a=Tomcat
Nathan Froyd <froydnj@mozilla.com>
parents: 266718
diff changeset
  1033
  RefPtr<Promise> promise = CreatePromise(aRv);
208669
05df8323b82079743e8af61b83625739bbadf905 Bug 994912 - Add support for promises and event-based notifications to camera. r=mikeh, r=bz
Andrew Osmond <aosmond@mozilla.com>
parents: 207338
diff changeset
  1034
  if (aRv.Failed()) {
05df8323b82079743e8af61b83625739bbadf905 Bug 994912 - Add support for promises and event-based notifications to camera. r=mikeh, r=bz
Andrew Osmond <aosmond@mozilla.com>
parents: 207338
diff changeset
  1035
    return nullptr;
05df8323b82079743e8af61b83625739bbadf905 Bug 994912 - Add support for promises and event-based notifications to camera. r=mikeh, r=bz
Andrew Osmond <aosmond@mozilla.com>
parents: 207338
diff changeset
  1036
  }
05df8323b82079743e8af61b83625739bbadf905 Bug 994912 - Add support for promises and event-based notifications to camera. r=mikeh, r=bz
Andrew Osmond <aosmond@mozilla.com>
parents: 207338
diff changeset
  1037
219510
220f9cd8097a7d7b395ab0419c6aa62ae25f7058 Bug 1104055 - fix CameraControl memory leak, r=aosmond
Mike Habicher <mikeh@mozilla.com>
parents: 219181
diff changeset
  1038
  if (!mCameraControl) {
220f9cd8097a7d7b395ab0419c6aa62ae25f7058 Bug 1104055 - fix CameraControl memory leak, r=aosmond
Mike Habicher <mikeh@mozilla.com>
parents: 219181
diff changeset
  1039
    // Always succeed if the camera instance is already closed.
220f9cd8097a7d7b395ab0419c6aa62ae25f7058 Bug 1104055 - fix CameraControl memory leak, r=aosmond
Mike Habicher <mikeh@mozilla.com>
parents: 219181
diff changeset
  1040
    promise->MaybeResolve(JS::UndefinedHandleValue);
220f9cd8097a7d7b395ab0419c6aa62ae25f7058 Bug 1104055 - fix CameraControl memory leak, r=aosmond
Mike Habicher <mikeh@mozilla.com>
parents: 219181
diff changeset
  1041
    return promise.forget();
220f9cd8097a7d7b395ab0419c6aa62ae25f7058 Bug 1104055 - fix CameraControl memory leak, r=aosmond
Mike Habicher <mikeh@mozilla.com>
parents: 219181
diff changeset
  1042
  }
220f9cd8097a7d7b395ab0419c6aa62ae25f7058 Bug 1104055 - fix CameraControl memory leak, r=aosmond
Mike Habicher <mikeh@mozilla.com>
parents: 219181
diff changeset
  1043
208669
05df8323b82079743e8af61b83625739bbadf905 Bug 994912 - Add support for promises and event-based notifications to camera. r=mikeh, r=bz
Andrew Osmond <aosmond@mozilla.com>
parents: 207338
diff changeset
  1044
  aRv = mCameraControl->Stop();
05df8323b82079743e8af61b83625739bbadf905 Bug 994912 - Add support for promises and event-based notifications to camera. r=mikeh, r=bz
Andrew Osmond <aosmond@mozilla.com>
parents: 207338
diff changeset
  1045
  if (aRv.Failed()) {
05df8323b82079743e8af61b83625739bbadf905 Bug 994912 - Add support for promises and event-based notifications to camera. r=mikeh, r=bz
Andrew Osmond <aosmond@mozilla.com>
parents: 207338
diff changeset
  1046
    return nullptr;
05df8323b82079743e8af61b83625739bbadf905 Bug 994912 - Add support for promises and event-based notifications to camera. r=mikeh, r=bz
Andrew Osmond <aosmond@mozilla.com>
parents: 207338
diff changeset
  1047
  }
05df8323b82079743e8af61b83625739bbadf905 Bug 994912 - Add support for promises and event-based notifications to camera. r=mikeh, r=bz
Andrew Osmond <aosmond@mozilla.com>
parents: 207338
diff changeset
  1048
219510
220f9cd8097a7d7b395ab0419c6aa62ae25f7058 Bug 1104055 - fix CameraControl memory leak, r=aosmond
Mike Habicher <mikeh@mozilla.com>
parents: 219181
diff changeset
  1049
  // Once we stop the camera, there's nothing we can do with it,
220f9cd8097a7d7b395ab0419c6aa62ae25f7058 Bug 1104055 - fix CameraControl memory leak, r=aosmond
Mike Habicher <mikeh@mozilla.com>
parents: 219181
diff changeset
  1050
  // so we can throw away this reference. (This won't prevent us
220f9cd8097a7d7b395ab0419c6aa62ae25f7058 Bug 1104055 - fix CameraControl memory leak, r=aosmond
Mike Habicher <mikeh@mozilla.com>
parents: 219181
diff changeset
  1051
  // from receiving the last underlying events.)
220f9cd8097a7d7b395ab0419c6aa62ae25f7058 Bug 1104055 - fix CameraControl memory leak, r=aosmond
Mike Habicher <mikeh@mozilla.com>
parents: 219181
diff changeset
  1052
  mCameraControl = nullptr;
208669
05df8323b82079743e8af61b83625739bbadf905 Bug 994912 - Add support for promises and event-based notifications to camera. r=mikeh, r=bz
Andrew Osmond <aosmond@mozilla.com>
parents: 207338
diff changeset
  1053
  mReleasePromise = promise;
219510
220f9cd8097a7d7b395ab0419c6aa62ae25f7058 Bug 1104055 - fix CameraControl memory leak, r=aosmond
Mike Habicher <mikeh@mozilla.com>
parents: 219181
diff changeset
  1054
208669
05df8323b82079743e8af61b83625739bbadf905 Bug 994912 - Add support for promises and event-based notifications to camera. r=mikeh, r=bz
Andrew Osmond <aosmond@mozilla.com>
parents: 207338
diff changeset
  1055
  return promise.forget();
104262
244bba751ce4ae586d66d28c8e9a1f0b41e872c5 Bug 779139 - Make DOM-facing camera objects cycle collection participants. r=jst
Mike Habicher <mikeh@mozilla.com>
parents:
diff changeset
  1056
}
108708
5245844b645d4aa943e5e3ea9accd4c4345309df Bug 779145 - Add support for unsoliciated onShutter and onClosed callbacks, handle OnNavigation to clean-up. r=jst
Mike Habicher <mikeh@mozilla.com>
parents: 108674
diff changeset
  1057
5245844b645d4aa943e5e3ea9accd4c4345309df Bug 779145 - Add support for unsoliciated onShutter and onClosed callbacks, handle OnNavigation to clean-up. r=jst
Mike Habicher <mikeh@mozilla.com>
parents: 108674
diff changeset
  1058
void
178627
7151a7e50317a81940263785b1674f850c99a307 Bug 986024 - expose resumeContinuousFocus() method to DOM/JS, r=bz,dhylands
Mike Habicher <mikeh@mozilla.com>
parents: 178290
diff changeset
  1059
nsDOMCameraControl::ResumeContinuousFocus(ErrorResult& aRv)
7151a7e50317a81940263785b1674f850c99a307 Bug 986024 - expose resumeContinuousFocus() method to DOM/JS, r=bz,dhylands
Mike Habicher <mikeh@mozilla.com>
parents: 178290
diff changeset
  1060
{
219510
220f9cd8097a7d7b395ab0419c6aa62ae25f7058 Bug 1104055 - fix CameraControl memory leak, r=aosmond
Mike Habicher <mikeh@mozilla.com>
parents: 219181
diff changeset
  1061
  DOM_CAMERA_LOGT("%s:%d : this=%p\n", __func__, __LINE__, this);
220f9cd8097a7d7b395ab0419c6aa62ae25f7058 Bug 1104055 - fix CameraControl memory leak, r=aosmond
Mike Habicher <mikeh@mozilla.com>
parents: 219181
diff changeset
  1062
  THROW_IF_NO_CAMERACONTROL();
178627
7151a7e50317a81940263785b1674f850c99a307 Bug 986024 - expose resumeContinuousFocus() method to DOM/JS, r=bz,dhylands
Mike Habicher <mikeh@mozilla.com>
parents: 178290
diff changeset
  1063
  aRv = mCameraControl->ResumeContinuousFocus();
7151a7e50317a81940263785b1674f850c99a307 Bug 986024 - expose resumeContinuousFocus() method to DOM/JS, r=bz,dhylands
Mike Habicher <mikeh@mozilla.com>
parents: 178290
diff changeset
  1064
}
7151a7e50317a81940263785b1674f850c99a307 Bug 986024 - expose resumeContinuousFocus() method to DOM/JS, r=bz,dhylands
Mike Habicher <mikeh@mozilla.com>
parents: 178290
diff changeset
  1065
7151a7e50317a81940263785b1674f850c99a307 Bug 986024 - expose resumeContinuousFocus() method to DOM/JS, r=bz,dhylands
Mike Habicher <mikeh@mozilla.com>
parents: 178290
diff changeset
  1066
void
108708
5245844b645d4aa943e5e3ea9accd4c4345309df Bug 779145 - Add support for unsoliciated onShutter and onClosed callbacks, handle OnNavigation to clean-up. r=jst
Mike Habicher <mikeh@mozilla.com>
parents: 108674
diff changeset
  1067
nsDOMCameraControl::Shutdown()
5245844b645d4aa943e5e3ea9accd4c4345309df Bug 779145 - Add support for unsoliciated onShutter and onClosed callbacks, handle OnNavigation to clean-up. r=jst
Mike Habicher <mikeh@mozilla.com>
parents: 108674
diff changeset
  1068
{
219510
220f9cd8097a7d7b395ab0419c6aa62ae25f7058 Bug 1104055 - fix CameraControl memory leak, r=aosmond
Mike Habicher <mikeh@mozilla.com>
parents: 219181
diff changeset
  1069
  DOM_CAMERA_LOGT("%s:%d : this=%p\n", __func__, __LINE__, this);
168993
e93e96ed8a5ad4999e272e2a3180a32e1ffdf94d Bug 909542 - refactor CameraControl API, r=dhylands,jst,jesup,onecyrenus
Mike Habicher <mikeh@mozilla.com>
parents: 168958
diff changeset
  1070
e93e96ed8a5ad4999e272e2a3180a32e1ffdf94d Bug 909542 - refactor CameraControl API, r=dhylands,jst,jesup,onecyrenus
Mike Habicher <mikeh@mozilla.com>
parents: 168958
diff changeset
  1071
  // Remove any pending solicited event handlers; these
e93e96ed8a5ad4999e272e2a3180a32e1ffdf94d Bug 909542 - refactor CameraControl API, r=dhylands,jst,jesup,onecyrenus
Mike Habicher <mikeh@mozilla.com>
parents: 168958
diff changeset
  1072
  // reference our window object, which in turn references
e93e96ed8a5ad4999e272e2a3180a32e1ffdf94d Bug 909542 - refactor CameraControl API, r=dhylands,jst,jesup,onecyrenus
Mike Habicher <mikeh@mozilla.com>
parents: 168958
diff changeset
  1073
  // us. If we don't remove them, we can leak DOM objects.
208669
05df8323b82079743e8af61b83625739bbadf905 Bug 994912 - Add support for promises and event-based notifications to camera. r=mikeh, r=bz
Andrew Osmond <aosmond@mozilla.com>
parents: 207338
diff changeset
  1074
  AbortPromise(mGetCameraPromise);
05df8323b82079743e8af61b83625739bbadf905 Bug 994912 - Add support for promises and event-based notifications to camera. r=mikeh, r=bz
Andrew Osmond <aosmond@mozilla.com>
parents: 207338
diff changeset
  1075
  AbortPromise(mAutoFocusPromise);
05df8323b82079743e8af61b83625739bbadf905 Bug 994912 - Add support for promises and event-based notifications to camera. r=mikeh, r=bz
Andrew Osmond <aosmond@mozilla.com>
parents: 207338
diff changeset
  1076
  AbortPromise(mTakePicturePromise);
05df8323b82079743e8af61b83625739bbadf905 Bug 994912 - Add support for promises and event-based notifications to camera. r=mikeh, r=bz
Andrew Osmond <aosmond@mozilla.com>
parents: 207338
diff changeset
  1077
  AbortPromise(mStartRecordingPromise);
05df8323b82079743e8af61b83625739bbadf905 Bug 994912 - Add support for promises and event-based notifications to camera. r=mikeh, r=bz
Andrew Osmond <aosmond@mozilla.com>
parents: 207338
diff changeset
  1078
  AbortPromise(mReleasePromise);
05df8323b82079743e8af61b83625739bbadf905 Bug 994912 - Add support for promises and event-based notifications to camera. r=mikeh, r=bz
Andrew Osmond <aosmond@mozilla.com>
parents: 207338
diff changeset
  1079
  AbortPromise(mSetConfigurationPromise);
168993
e93e96ed8a5ad4999e272e2a3180a32e1ffdf94d Bug 909542 - refactor CameraControl API, r=dhylands,jst,jesup,onecyrenus
Mike Habicher <mikeh@mozilla.com>
parents: 168958
diff changeset
  1080
219510
220f9cd8097a7d7b395ab0419c6aa62ae25f7058 Bug 1104055 - fix CameraControl memory leak, r=aosmond
Mike Habicher <mikeh@mozilla.com>
parents: 219181
diff changeset
  1081
  if (mCameraControl) {
220f9cd8097a7d7b395ab0419c6aa62ae25f7058 Bug 1104055 - fix CameraControl memory leak, r=aosmond
Mike Habicher <mikeh@mozilla.com>
parents: 219181
diff changeset
  1082
    mCameraControl->Stop();
220f9cd8097a7d7b395ab0419c6aa62ae25f7058 Bug 1104055 - fix CameraControl memory leak, r=aosmond
Mike Habicher <mikeh@mozilla.com>
parents: 219181
diff changeset
  1083
    mCameraControl = nullptr;
220f9cd8097a7d7b395ab0419c6aa62ae25f7058 Bug 1104055 - fix CameraControl memory leak, r=aosmond
Mike Habicher <mikeh@mozilla.com>
parents: 219181
diff changeset
  1084
  }
108708
5245844b645d4aa943e5e3ea9accd4c4345309df Bug 779145 - Add support for unsoliciated onShutter and onClosed callbacks, handle OnNavigation to clean-up. r=jst
Mike Habicher <mikeh@mozilla.com>
parents: 108674
diff changeset
  1085
}
130612
88b09f034e9ff9c7e1a0a6a5ff31b3123e85bc4f Bug 825110 - Part 1: Camera changes for B2G WebRTC video module. r=mhabicher
Chiajung Hung <chung@mozilla.com>
parents: 121510
diff changeset
  1086
249187
9ba890d2ba081ceea82be94530b3fafffa51b766 Bug 1152500 - Fix how stop recording may be handled out-of-order. r=dhylands
Andrew Osmond <aosmond@mozilla.com>
parents: 246249
diff changeset
  1087
void
9ba890d2ba081ceea82be94530b3fafffa51b766 Bug 1152500 - Fix how stop recording may be handled out-of-order. r=dhylands
Andrew Osmond <aosmond@mozilla.com>
parents: 246249
diff changeset
  1088
nsDOMCameraControl::ReleaseAudioChannelAgent()
9ba890d2ba081ceea82be94530b3fafffa51b766 Bug 1152500 - Fix how stop recording may be handled out-of-order. r=dhylands
Andrew Osmond <aosmond@mozilla.com>
parents: 246249
diff changeset
  1089
{
9ba890d2ba081ceea82be94530b3fafffa51b766 Bug 1152500 - Fix how stop recording may be handled out-of-order. r=dhylands
Andrew Osmond <aosmond@mozilla.com>
parents: 246249
diff changeset
  1090
#ifdef MOZ_B2G
9ba890d2ba081ceea82be94530b3fafffa51b766 Bug 1152500 - Fix how stop recording may be handled out-of-order. r=dhylands
Andrew Osmond <aosmond@mozilla.com>
parents: 246249
diff changeset
  1091
  if (mAudioChannelAgent) {
266718
1418f98468c37f5631a35739268dbfef5b4d4f26 Bug 1211511 - AudioChannelAgent::NotifyStartedPlaying and NotifyStoppedPlaying should use the same level of playback notification, r=roc
Andrea Marchesini <amarchesini@mozilla.com>
parents: 266562
diff changeset
  1092
    mAudioChannelAgent->NotifyStoppedPlaying();
249187
9ba890d2ba081ceea82be94530b3fafffa51b766 Bug 1152500 - Fix how stop recording may be handled out-of-order. r=dhylands
Andrew Osmond <aosmond@mozilla.com>
parents: 246249
diff changeset
  1093
    mAudioChannelAgent = nullptr;
9ba890d2ba081ceea82be94530b3fafffa51b766 Bug 1152500 - Fix how stop recording may be handled out-of-order. r=dhylands
Andrew Osmond <aosmond@mozilla.com>
parents: 246249
diff changeset
  1094
  }
9ba890d2ba081ceea82be94530b3fafffa51b766 Bug 1152500 - Fix how stop recording may be handled out-of-order. r=dhylands
Andrew Osmond <aosmond@mozilla.com>
parents: 246249
diff changeset
  1095
#endif
9ba890d2ba081ceea82be94530b3fafffa51b766 Bug 1152500 - Fix how stop recording may be handled out-of-order. r=dhylands
Andrew Osmond <aosmond@mozilla.com>
parents: 246249
diff changeset
  1096
}
9ba890d2ba081ceea82be94530b3fafffa51b766 Bug 1152500 - Fix how stop recording may be handled out-of-order. r=dhylands
Andrew Osmond <aosmond@mozilla.com>
parents: 246249
diff changeset
  1097
158599
f6675487604f2460f3bba2a7d01bd6308483f4ea Bug 940045 - Part 3: Send requestURL from content process. r=mikeh
Shih-Chiang Chien <schien@mozilla.com>
parents: 152770
diff changeset
  1098
nsresult
f6675487604f2460f3bba2a7d01bd6308483f4ea Bug 940045 - Part 3: Send requestURL from content process. r=mikeh
Shih-Chiang Chien <schien@mozilla.com>
parents: 152770
diff changeset
  1099
nsDOMCameraControl::NotifyRecordingStatusChange(const nsString& aMsg)
152317
8f125ace663169b472dfb6f64fe3e0cdef963109 Bug 926289 - Part 3, Carry recording type and request URL in recording-device-events in Camera API. r=mikeh.
Shih-Chiang Chien <schien@mozilla.com>
parents: 151619
diff changeset
  1100
{
158599
f6675487604f2460f3bba2a7d01bd6308483f4ea Bug 940045 - Part 3: Send requestURL from content process. r=mikeh
Shih-Chiang Chien <schien@mozilla.com>
parents: 152770
diff changeset
  1101
  NS_ENSURE_TRUE(mWindow, NS_ERROR_FAILURE);
152317
8f125ace663169b472dfb6f64fe3e0cdef963109 Bug 926289 - Part 3, Carry recording type and request URL in recording-device-events in Camera API. r=mikeh.
Shih-Chiang Chien <schien@mozilla.com>
parents: 151619
diff changeset
  1102
249187
9ba890d2ba081ceea82be94530b3fafffa51b766 Bug 1152500 - Fix how stop recording may be handled out-of-order. r=dhylands
Andrew Osmond <aosmond@mozilla.com>
parents: 246249
diff changeset
  1103
  if (aMsg.EqualsLiteral("shutdown")) {
9ba890d2ba081ceea82be94530b3fafffa51b766 Bug 1152500 - Fix how stop recording may be handled out-of-order. r=dhylands
Andrew Osmond <aosmond@mozilla.com>
parents: 246249
diff changeset
  1104
    ReleaseAudioChannelAgent();
9ba890d2ba081ceea82be94530b3fafffa51b766 Bug 1152500 - Fix how stop recording may be handled out-of-order. r=dhylands
Andrew Osmond <aosmond@mozilla.com>
parents: 246249
diff changeset
  1105
  }
9ba890d2ba081ceea82be94530b3fafffa51b766 Bug 1152500 - Fix how stop recording may be handled out-of-order. r=dhylands
Andrew Osmond <aosmond@mozilla.com>
parents: 246249
diff changeset
  1106
9ba890d2ba081ceea82be94530b3fafffa51b766 Bug 1152500 - Fix how stop recording may be handled out-of-order. r=dhylands
Andrew Osmond <aosmond@mozilla.com>
parents: 246249
diff changeset
  1107
  nsresult rv = MediaManager::NotifyRecordingStatusChange(mWindow,
9ba890d2ba081ceea82be94530b3fafffa51b766 Bug 1152500 - Fix how stop recording may be handled out-of-order. r=dhylands
Andrew Osmond <aosmond@mozilla.com>
parents: 246249
diff changeset
  1108
                                                          aMsg,
9ba890d2ba081ceea82be94530b3fafffa51b766 Bug 1152500 - Fix how stop recording may be handled out-of-order. r=dhylands
Andrew Osmond <aosmond@mozilla.com>
parents: 246249
diff changeset
  1109
                                                          true /* aIsAudio */,
9ba890d2ba081ceea82be94530b3fafffa51b766 Bug 1152500 - Fix how stop recording may be handled out-of-order. r=dhylands
Andrew Osmond <aosmond@mozilla.com>
parents: 246249
diff changeset
  1110
                                                          true /* aIsVideo */);
9ba890d2ba081ceea82be94530b3fafffa51b766 Bug 1152500 - Fix how stop recording may be handled out-of-order. r=dhylands
Andrew Osmond <aosmond@mozilla.com>
parents: 246249
diff changeset
  1111
9ba890d2ba081ceea82be94530b3fafffa51b766 Bug 1152500 - Fix how stop recording may be handled out-of-order. r=dhylands
Andrew Osmond <aosmond@mozilla.com>
parents: 246249
diff changeset
  1112
  if (NS_FAILED(rv)) {
9ba890d2ba081ceea82be94530b3fafffa51b766 Bug 1152500 - Fix how stop recording may be handled out-of-order. r=dhylands
Andrew Osmond <aosmond@mozilla.com>
parents: 246249
diff changeset
  1113
    return rv;
9ba890d2ba081ceea82be94530b3fafffa51b766 Bug 1152500 - Fix how stop recording may be handled out-of-order. r=dhylands
Andrew Osmond <aosmond@mozilla.com>
parents: 246249
diff changeset
  1114
  }
9ba890d2ba081ceea82be94530b3fafffa51b766 Bug 1152500 - Fix how stop recording may be handled out-of-order. r=dhylands
Andrew Osmond <aosmond@mozilla.com>
parents: 246249
diff changeset
  1115
9ba890d2ba081ceea82be94530b3fafffa51b766 Bug 1152500 - Fix how stop recording may be handled out-of-order. r=dhylands
Andrew Osmond <aosmond@mozilla.com>
parents: 246249
diff changeset
  1116
#ifdef MOZ_B2G
9ba890d2ba081ceea82be94530b3fafffa51b766 Bug 1152500 - Fix how stop recording may be handled out-of-order. r=dhylands
Andrew Osmond <aosmond@mozilla.com>
parents: 246249
diff changeset
  1117
  if (aMsg.EqualsLiteral("starting") && !mAudioChannelAgent) {
9ba890d2ba081ceea82be94530b3fafffa51b766 Bug 1152500 - Fix how stop recording may be handled out-of-order. r=dhylands
Andrew Osmond <aosmond@mozilla.com>
parents: 246249
diff changeset
  1118
    mAudioChannelAgent = do_CreateInstance("@mozilla.org/audiochannelagent;1");
9ba890d2ba081ceea82be94530b3fafffa51b766 Bug 1152500 - Fix how stop recording may be handled out-of-order. r=dhylands
Andrew Osmond <aosmond@mozilla.com>
parents: 246249
diff changeset
  1119
    if (!mAudioChannelAgent) {
9ba890d2ba081ceea82be94530b3fafffa51b766 Bug 1152500 - Fix how stop recording may be handled out-of-order. r=dhylands
Andrew Osmond <aosmond@mozilla.com>
parents: 246249
diff changeset
  1120
      return NS_ERROR_UNEXPECTED;
9ba890d2ba081ceea82be94530b3fafffa51b766 Bug 1152500 - Fix how stop recording may be handled out-of-order. r=dhylands
Andrew Osmond <aosmond@mozilla.com>
parents: 246249
diff changeset
  1121
    }
9ba890d2ba081ceea82be94530b3fafffa51b766 Bug 1152500 - Fix how stop recording may be handled out-of-order. r=dhylands
Andrew Osmond <aosmond@mozilla.com>
parents: 246249
diff changeset
  1122
9ba890d2ba081ceea82be94530b3fafffa51b766 Bug 1152500 - Fix how stop recording may be handled out-of-order. r=dhylands
Andrew Osmond <aosmond@mozilla.com>
parents: 246249
diff changeset
  1123
    // Camera app will stop recording when it falls to the background, so no callback is necessary.
9ba890d2ba081ceea82be94530b3fafffa51b766 Bug 1152500 - Fix how stop recording may be handled out-of-order. r=dhylands
Andrew Osmond <aosmond@mozilla.com>
parents: 246249
diff changeset
  1124
    mAudioChannelAgent->Init(mWindow, (int32_t)AudioChannel::Content, nullptr);
9ba890d2ba081ceea82be94530b3fafffa51b766 Bug 1152500 - Fix how stop recording may be handled out-of-order. r=dhylands
Andrew Osmond <aosmond@mozilla.com>
parents: 246249
diff changeset
  1125
    // Video recording doesn't output any sound, so it's not necessary to check canPlay.
252492
4120dbd77a5dd1fc8399833752f4d1ce38294485 Bug 1113086 - AudioChannel policy in Browser API - patch 1 - BrowserElementAudioChannel, r=ehsan
Andrea Marchesini <amarchesini@mozilla.com>
parents: 252491
diff changeset
  1126
    float volume = 0.0;
4120dbd77a5dd1fc8399833752f4d1ce38294485 Bug 1113086 - AudioChannel policy in Browser API - patch 1 - BrowserElementAudioChannel, r=ehsan
Andrea Marchesini <amarchesini@mozilla.com>
parents: 252491
diff changeset
  1127
    bool muted = true;
256549
f7bb505664efc43a89d54aa2defed3fca53b9ee9 Bug 1190040 - Part 2: Teach the audio channel service how to not notify audio-playback, and do that when a media element has no audio track; r=padenot
Ehsan Akhgari <ehsan@mozilla.com>
parents: 252500
diff changeset
  1128
    rv = mAudioChannelAgent->NotifyStartedPlaying(nsIAudioChannelAgent::AUDIO_AGENT_DONT_NOTIFY,
f7bb505664efc43a89d54aa2defed3fca53b9ee9 Bug 1190040 - Part 2: Teach the audio channel service how to not notify audio-playback, and do that when a media element has no audio track; r=padenot
Ehsan Akhgari <ehsan@mozilla.com>
parents: 252500
diff changeset
  1129
                                                  &volume, &muted);
252492
4120dbd77a5dd1fc8399833752f4d1ce38294485 Bug 1113086 - AudioChannel policy in Browser API - patch 1 - BrowserElementAudioChannel, r=ehsan
Andrea Marchesini <amarchesini@mozilla.com>
parents: 252491
diff changeset
  1130
    if (NS_WARN_IF(NS_FAILED(rv))) {
4120dbd77a5dd1fc8399833752f4d1ce38294485 Bug 1113086 - AudioChannel policy in Browser API - patch 1 - BrowserElementAudioChannel, r=ehsan
Andrea Marchesini <amarchesini@mozilla.com>
parents: 252491
diff changeset
  1131
      return rv;
4120dbd77a5dd1fc8399833752f4d1ce38294485 Bug 1113086 - AudioChannel policy in Browser API - patch 1 - BrowserElementAudioChannel, r=ehsan
Andrea Marchesini <amarchesini@mozilla.com>
parents: 252491
diff changeset
  1132
    }
249187
9ba890d2ba081ceea82be94530b3fafffa51b766 Bug 1152500 - Fix how stop recording may be handled out-of-order. r=dhylands
Andrew Osmond <aosmond@mozilla.com>
parents: 246249
diff changeset
  1133
  }
9ba890d2ba081ceea82be94530b3fafffa51b766 Bug 1152500 - Fix how stop recording may be handled out-of-order. r=dhylands
Andrew Osmond <aosmond@mozilla.com>
parents: 246249
diff changeset
  1134
#endif
9ba890d2ba081ceea82be94530b3fafffa51b766 Bug 1152500 - Fix how stop recording may be handled out-of-order. r=dhylands
Andrew Osmond <aosmond@mozilla.com>
parents: 246249
diff changeset
  1135
  return rv;
158599
f6675487604f2460f3bba2a7d01bd6308483f4ea Bug 940045 - Part 3: Send requestURL from content process. r=mikeh
Shih-Chiang Chien <schien@mozilla.com>
parents: 152770
diff changeset
  1136
}
152317
8f125ace663169b472dfb6f64fe3e0cdef963109 Bug 926289 - Part 3, Carry recording type and request URL in recording-device-events in Camera API. r=mikeh.
Shih-Chiang Chien <schien@mozilla.com>
parents: 151619
diff changeset
  1137
208669
05df8323b82079743e8af61b83625739bbadf905 Bug 994912 - Add support for promises and event-based notifications to camera. r=mikeh, r=bz
Andrew Osmond <aosmond@mozilla.com>
parents: 207338
diff changeset
  1138
already_AddRefed<Promise>
05df8323b82079743e8af61b83625739bbadf905 Bug 994912 - Add support for promises and event-based notifications to camera. r=mikeh, r=bz
Andrew Osmond <aosmond@mozilla.com>
parents: 207338
diff changeset
  1139
nsDOMCameraControl::CreatePromise(ErrorResult& aRv)
05df8323b82079743e8af61b83625739bbadf905 Bug 994912 - Add support for promises and event-based notifications to camera. r=mikeh, r=bz
Andrew Osmond <aosmond@mozilla.com>
parents: 207338
diff changeset
  1140
{
05df8323b82079743e8af61b83625739bbadf905 Bug 994912 - Add support for promises and event-based notifications to camera. r=mikeh, r=bz
Andrew Osmond <aosmond@mozilla.com>
parents: 207338
diff changeset
  1141
  nsCOMPtr<nsIGlobalObject> global = do_QueryInterface(mWindow);
05df8323b82079743e8af61b83625739bbadf905 Bug 994912 - Add support for promises and event-based notifications to camera. r=mikeh, r=bz
Andrew Osmond <aosmond@mozilla.com>
parents: 207338
diff changeset
  1142
  if (!global) {
05df8323b82079743e8af61b83625739bbadf905 Bug 994912 - Add support for promises and event-based notifications to camera. r=mikeh, r=bz
Andrew Osmond <aosmond@mozilla.com>
parents: 207338
diff changeset
  1143
    aRv.Throw(NS_ERROR_FAILURE);
05df8323b82079743e8af61b83625739bbadf905 Bug 994912 - Add support for promises and event-based notifications to camera. r=mikeh, r=bz
Andrew Osmond <aosmond@mozilla.com>
parents: 207338
diff changeset
  1144
    return nullptr;
05df8323b82079743e8af61b83625739bbadf905 Bug 994912 - Add support for promises and event-based notifications to camera. r=mikeh, r=bz
Andrew Osmond <aosmond@mozilla.com>
parents: 207338
diff changeset
  1145
  }
05df8323b82079743e8af61b83625739bbadf905 Bug 994912 - Add support for promises and event-based notifications to camera. r=mikeh, r=bz
Andrew Osmond <aosmond@mozilla.com>
parents: 207338
diff changeset
  1146
  return Promise::Create(global, aRv);
05df8323b82079743e8af61b83625739bbadf905 Bug 994912 - Add support for promises and event-based notifications to camera. r=mikeh, r=bz
Andrew Osmond <aosmond@mozilla.com>
parents: 207338
diff changeset
  1147
}
05df8323b82079743e8af61b83625739bbadf905 Bug 994912 - Add support for promises and event-based notifications to camera. r=mikeh, r=bz
Andrew Osmond <aosmond@mozilla.com>
parents: 207338
diff changeset
  1148
05df8323b82079743e8af61b83625739bbadf905 Bug 994912 - Add support for promises and event-based notifications to camera. r=mikeh, r=bz
Andrew Osmond <aosmond@mozilla.com>
parents: 207338
diff changeset
  1149
void
268184
e8c7dfe727cd970e2c3294934e2927b14143c205 Bug 1207245 - part 6 - rename nsRefPtr<T> to RefPtr<T>; r=ehsan; a=Tomcat
Nathan Froyd <froydnj@mozilla.com>
parents: 266718
diff changeset
  1150
nsDOMCameraControl::AbortPromise(RefPtr<Promise>& aPromise)
208669
05df8323b82079743e8af61b83625739bbadf905 Bug 994912 - Add support for promises and event-based notifications to camera. r=mikeh, r=bz
Andrew Osmond <aosmond@mozilla.com>
parents: 207338
diff changeset
  1151
{
268184
e8c7dfe727cd970e2c3294934e2927b14143c205 Bug 1207245 - part 6 - rename nsRefPtr<T> to RefPtr<T>; r=ehsan; a=Tomcat
Nathan Froyd <froydnj@mozilla.com>
parents: 266718
diff changeset
  1152
  RefPtr<Promise> promise = aPromise.forget();
208669
05df8323b82079743e8af61b83625739bbadf905 Bug 994912 - Add support for promises and event-based notifications to camera. r=mikeh, r=bz
Andrew Osmond <aosmond@mozilla.com>
parents: 207338
diff changeset
  1153
  if (promise) {
05df8323b82079743e8af61b83625739bbadf905 Bug 994912 - Add support for promises and event-based notifications to camera. r=mikeh, r=bz
Andrew Osmond <aosmond@mozilla.com>
parents: 207338
diff changeset
  1154
    promise->MaybeReject(NS_ERROR_NOT_AVAILABLE);
05df8323b82079743e8af61b83625739bbadf905 Bug 994912 - Add support for promises and event-based notifications to camera. r=mikeh, r=bz
Andrew Osmond <aosmond@mozilla.com>
parents: 207338
diff changeset
  1155
  }
05df8323b82079743e8af61b83625739bbadf905 Bug 994912 - Add support for promises and event-based notifications to camera. r=mikeh, r=bz
Andrew Osmond <aosmond@mozilla.com>
parents: 207338
diff changeset
  1156
}
05df8323b82079743e8af61b83625739bbadf905 Bug 994912 - Add support for promises and event-based notifications to camera. r=mikeh, r=bz
Andrew Osmond <aosmond@mozilla.com>
parents: 207338
diff changeset
  1157
05df8323b82079743e8af61b83625739bbadf905 Bug 994912 - Add support for promises and event-based notifications to camera. r=mikeh, r=bz
Andrew Osmond <aosmond@mozilla.com>
parents: 207338
diff changeset
  1158
void
05df8323b82079743e8af61b83625739bbadf905 Bug 994912 - Add support for promises and event-based notifications to camera. r=mikeh, r=bz
Andrew Osmond <aosmond@mozilla.com>
parents: 207338
diff changeset
  1159
nsDOMCameraControl::EventListenerAdded(nsIAtom* aType)
05df8323b82079743e8af61b83625739bbadf905 Bug 994912 - Add support for promises and event-based notifications to camera. r=mikeh, r=bz
Andrew Osmond <aosmond@mozilla.com>
parents: 207338
diff changeset
  1160
{
05df8323b82079743e8af61b83625739bbadf905 Bug 994912 - Add support for promises and event-based notifications to camera. r=mikeh, r=bz
Andrew Osmond <aosmond@mozilla.com>
parents: 207338
diff changeset
  1161
  if (aType == nsGkAtoms::onpreviewstatechange) {
05df8323b82079743e8af61b83625739bbadf905 Bug 994912 - Add support for promises and event-based notifications to camera. r=mikeh, r=bz
Andrew Osmond <aosmond@mozilla.com>
parents: 207338
diff changeset
  1162
    DispatchPreviewStateEvent(mPreviewState);
05df8323b82079743e8af61b83625739bbadf905 Bug 994912 - Add support for promises and event-based notifications to camera. r=mikeh, r=bz
Andrew Osmond <aosmond@mozilla.com>
parents: 207338
diff changeset
  1163
  }
05df8323b82079743e8af61b83625739bbadf905 Bug 994912 - Add support for promises and event-based notifications to camera. r=mikeh, r=bz
Andrew Osmond <aosmond@mozilla.com>
parents: 207338
diff changeset
  1164
}
05df8323b82079743e8af61b83625739bbadf905 Bug 994912 - Add support for promises and event-based notifications to camera. r=mikeh, r=bz
Andrew Osmond <aosmond@mozilla.com>
parents: 207338
diff changeset
  1165
05df8323b82079743e8af61b83625739bbadf905 Bug 994912 - Add support for promises and event-based notifications to camera. r=mikeh, r=bz
Andrew Osmond <aosmond@mozilla.com>
parents: 207338
diff changeset
  1166
void
05df8323b82079743e8af61b83625739bbadf905 Bug 994912 - Add support for promises and event-based notifications to camera. r=mikeh, r=bz
Andrew Osmond <aosmond@mozilla.com>
parents: 207338
diff changeset
  1167
nsDOMCameraControl::DispatchPreviewStateEvent(CameraControlListener::PreviewState aState)
05df8323b82079743e8af61b83625739bbadf905 Bug 994912 - Add support for promises and event-based notifications to camera. r=mikeh, r=bz
Andrew Osmond <aosmond@mozilla.com>
parents: 207338
diff changeset
  1168
{
05df8323b82079743e8af61b83625739bbadf905 Bug 994912 - Add support for promises and event-based notifications to camera. r=mikeh, r=bz
Andrew Osmond <aosmond@mozilla.com>
parents: 207338
diff changeset
  1169
  nsString state;
05df8323b82079743e8af61b83625739bbadf905 Bug 994912 - Add support for promises and event-based notifications to camera. r=mikeh, r=bz
Andrew Osmond <aosmond@mozilla.com>
parents: 207338
diff changeset
  1170
  switch (aState) {
05df8323b82079743e8af61b83625739bbadf905 Bug 994912 - Add support for promises and event-based notifications to camera. r=mikeh, r=bz
Andrew Osmond <aosmond@mozilla.com>
parents: 207338
diff changeset
  1171
    case CameraControlListener::kPreviewStarted:
05df8323b82079743e8af61b83625739bbadf905 Bug 994912 - Add support for promises and event-based notifications to camera. r=mikeh, r=bz
Andrew Osmond <aosmond@mozilla.com>
parents: 207338
diff changeset
  1172
      state = NS_LITERAL_STRING("started");
05df8323b82079743e8af61b83625739bbadf905 Bug 994912 - Add support for promises and event-based notifications to camera. r=mikeh, r=bz
Andrew Osmond <aosmond@mozilla.com>
parents: 207338
diff changeset
  1173
      break;
05df8323b82079743e8af61b83625739bbadf905 Bug 994912 - Add support for promises and event-based notifications to camera. r=mikeh, r=bz
Andrew Osmond <aosmond@mozilla.com>
parents: 207338
diff changeset
  1174
05df8323b82079743e8af61b83625739bbadf905 Bug 994912 - Add support for promises and event-based notifications to camera. r=mikeh, r=bz
Andrew Osmond <aosmond@mozilla.com>
parents: 207338
diff changeset
  1175
    default:
05df8323b82079743e8af61b83625739bbadf905 Bug 994912 - Add support for promises and event-based notifications to camera. r=mikeh, r=bz
Andrew Osmond <aosmond@mozilla.com>
parents: 207338
diff changeset
  1176
      state = NS_LITERAL_STRING("stopped");
05df8323b82079743e8af61b83625739bbadf905 Bug 994912 - Add support for promises and event-based notifications to camera. r=mikeh, r=bz
Andrew Osmond <aosmond@mozilla.com>
parents: 207338
diff changeset
  1177
      break;
05df8323b82079743e8af61b83625739bbadf905 Bug 994912 - Add support for promises and event-based notifications to camera. r=mikeh, r=bz
Andrew Osmond <aosmond@mozilla.com>
parents: 207338
diff changeset
  1178
  }
05df8323b82079743e8af61b83625739bbadf905 Bug 994912 - Add support for promises and event-based notifications to camera. r=mikeh, r=bz
Andrew Osmond <aosmond@mozilla.com>
parents: 207338
diff changeset
  1179
05df8323b82079743e8af61b83625739bbadf905 Bug 994912 - Add support for promises and event-based notifications to camera. r=mikeh, r=bz
Andrew Osmond <aosmond@mozilla.com>
parents: 207338
diff changeset
  1180
  DispatchStateEvent(NS_LITERAL_STRING("previewstatechange"), state);
05df8323b82079743e8af61b83625739bbadf905 Bug 994912 - Add support for promises and event-based notifications to camera. r=mikeh, r=bz
Andrew Osmond <aosmond@mozilla.com>
parents: 207338
diff changeset
  1181
}
05df8323b82079743e8af61b83625739bbadf905 Bug 994912 - Add support for promises and event-based notifications to camera. r=mikeh, r=bz
Andrew Osmond <aosmond@mozilla.com>
parents: 207338
diff changeset
  1182
05df8323b82079743e8af61b83625739bbadf905 Bug 994912 - Add support for promises and event-based notifications to camera. r=mikeh, r=bz
Andrew Osmond <aosmond@mozilla.com>
parents: 207338
diff changeset
  1183
void
05df8323b82079743e8af61b83625739bbadf905 Bug 994912 - Add support for promises and event-based notifications to camera. r=mikeh, r=bz
Andrew Osmond <aosmond@mozilla.com>
parents: 207338
diff changeset
  1184
nsDOMCameraControl::DispatchStateEvent(const nsString& aType, const nsString& aState)
05df8323b82079743e8af61b83625739bbadf905 Bug 994912 - Add support for promises and event-based notifications to camera. r=mikeh, r=bz
Andrew Osmond <aosmond@mozilla.com>
parents: 207338
diff changeset
  1185
{
05df8323b82079743e8af61b83625739bbadf905 Bug 994912 - Add support for promises and event-based notifications to camera. r=mikeh, r=bz
Andrew Osmond <aosmond@mozilla.com>
parents: 207338
diff changeset
  1186
  CameraStateChangeEventInit eventInit;
05df8323b82079743e8af61b83625739bbadf905 Bug 994912 - Add support for promises and event-based notifications to camera. r=mikeh, r=bz
Andrew Osmond <aosmond@mozilla.com>
parents: 207338
diff changeset
  1187
  eventInit.mNewState = aState;
05df8323b82079743e8af61b83625739bbadf905 Bug 994912 - Add support for promises and event-based notifications to camera. r=mikeh, r=bz
Andrew Osmond <aosmond@mozilla.com>
parents: 207338
diff changeset
  1188
268184
e8c7dfe727cd970e2c3294934e2927b14143c205 Bug 1207245 - part 6 - rename nsRefPtr<T> to RefPtr<T>; r=ehsan; a=Tomcat
Nathan Froyd <froydnj@mozilla.com>
parents: 266718
diff changeset
  1189
  RefPtr<CameraStateChangeEvent> event =
208669
05df8323b82079743e8af61b83625739bbadf905 Bug 994912 - Add support for promises and event-based notifications to camera. r=mikeh, r=bz
Andrew Osmond <aosmond@mozilla.com>
parents: 207338
diff changeset
  1190
    CameraStateChangeEvent::Constructor(this, aType, eventInit);
05df8323b82079743e8af61b83625739bbadf905 Bug 994912 - Add support for promises and event-based notifications to camera. r=mikeh, r=bz
Andrew Osmond <aosmond@mozilla.com>
parents: 207338
diff changeset
  1191
05df8323b82079743e8af61b83625739bbadf905 Bug 994912 - Add support for promises and event-based notifications to camera. r=mikeh, r=bz
Andrew Osmond <aosmond@mozilla.com>
parents: 207338
diff changeset
  1192
  DispatchTrustedEvent(event);
05df8323b82079743e8af61b83625739bbadf905 Bug 994912 - Add support for promises and event-based notifications to camera. r=mikeh, r=bz
Andrew Osmond <aosmond@mozilla.com>
parents: 207338
diff changeset
  1193
}
05df8323b82079743e8af61b83625739bbadf905 Bug 994912 - Add support for promises and event-based notifications to camera. r=mikeh, r=bz
Andrew Osmond <aosmond@mozilla.com>
parents: 207338
diff changeset
  1194
220237
ce9707a48002c8fd80f1c921b13e8f6e40d54f43 Bug 1104913 - Update selection algorithms for preview, picture and video sizes to have sane defaults. r=mikeh, r=bz
Andrew Osmond <aosmond@gmail.com>
parents: 219511
diff changeset
  1195
void
ce9707a48002c8fd80f1c921b13e8f6e40d54f43 Bug 1104913 - Update selection algorithms for preview, picture and video sizes to have sane defaults. r=mikeh, r=bz
Andrew Osmond <aosmond@gmail.com>
parents: 219511
diff changeset
  1196
nsDOMCameraControl::OnGetCameraComplete()
ce9707a48002c8fd80f1c921b13e8f6e40d54f43 Bug 1104913 - Update selection algorithms for preview, picture and video sizes to have sane defaults. r=mikeh, r=bz
Andrew Osmond <aosmond@gmail.com>
parents: 219511
diff changeset
  1197
{
ce9707a48002c8fd80f1c921b13e8f6e40d54f43 Bug 1104913 - Update selection algorithms for preview, picture and video sizes to have sane defaults. r=mikeh, r=bz
Andrew Osmond <aosmond@gmail.com>
parents: 219511
diff changeset
  1198
  // The hardware is open, so we can return a camera to JS, even if
ce9707a48002c8fd80f1c921b13e8f6e40d54f43 Bug 1104913 - Update selection algorithms for preview, picture and video sizes to have sane defaults. r=mikeh, r=bz
Andrew Osmond <aosmond@gmail.com>
parents: 219511
diff changeset
  1199
  // the preview hasn't started yet.
268184
e8c7dfe727cd970e2c3294934e2927b14143c205 Bug 1207245 - part 6 - rename nsRefPtr<T> to RefPtr<T>; r=ehsan; a=Tomcat
Nathan Froyd <froydnj@mozilla.com>
parents: 266718
diff changeset
  1200
  RefPtr<Promise> promise = mGetCameraPromise.forget();
220237
ce9707a48002c8fd80f1c921b13e8f6e40d54f43 Bug 1104913 - Update selection algorithms for preview, picture and video sizes to have sane defaults. r=mikeh, r=bz
Andrew Osmond <aosmond@gmail.com>
parents: 219511
diff changeset
  1201
  if (promise) {
ce9707a48002c8fd80f1c921b13e8f6e40d54f43 Bug 1104913 - Update selection algorithms for preview, picture and video sizes to have sane defaults. r=mikeh, r=bz
Andrew Osmond <aosmond@gmail.com>
parents: 219511
diff changeset
  1202
    CameraGetPromiseData data;
ce9707a48002c8fd80f1c921b13e8f6e40d54f43 Bug 1104913 - Update selection algorithms for preview, picture and video sizes to have sane defaults. r=mikeh, r=bz
Andrew Osmond <aosmond@gmail.com>
parents: 219511
diff changeset
  1203
    data.mCamera = this;
ce9707a48002c8fd80f1c921b13e8f6e40d54f43 Bug 1104913 - Update selection algorithms for preview, picture and video sizes to have sane defaults. r=mikeh, r=bz
Andrew Osmond <aosmond@gmail.com>
parents: 219511
diff changeset
  1204
    data.mConfiguration = *mCurrentConfiguration;
ce9707a48002c8fd80f1c921b13e8f6e40d54f43 Bug 1104913 - Update selection algorithms for preview, picture and video sizes to have sane defaults. r=mikeh, r=bz
Andrew Osmond <aosmond@gmail.com>
parents: 219511
diff changeset
  1205
    promise->MaybeResolve(data);
ce9707a48002c8fd80f1c921b13e8f6e40d54f43 Bug 1104913 - Update selection algorithms for preview, picture and video sizes to have sane defaults. r=mikeh, r=bz
Andrew Osmond <aosmond@gmail.com>
parents: 219511
diff changeset
  1206
  }
ce9707a48002c8fd80f1c921b13e8f6e40d54f43 Bug 1104913 - Update selection algorithms for preview, picture and video sizes to have sane defaults. r=mikeh, r=bz
Andrew Osmond <aosmond@gmail.com>
parents: 219511
diff changeset
  1207
}
ce9707a48002c8fd80f1c921b13e8f6e40d54f43 Bug 1104913 - Update selection algorithms for preview, picture and video sizes to have sane defaults. r=mikeh, r=bz
Andrew Osmond <aosmond@gmail.com>
parents: 219511
diff changeset
  1208
168993
e93e96ed8a5ad4999e272e2a3180a32e1ffdf94d Bug 909542 - refactor CameraControl API, r=dhylands,jst,jesup,onecyrenus
Mike Habicher <mikeh@mozilla.com>
parents: 168958
diff changeset
  1209
// Camera Control event handlers--must only be called from the Main Thread!
e93e96ed8a5ad4999e272e2a3180a32e1ffdf94d Bug 909542 - refactor CameraControl API, r=dhylands,jst,jesup,onecyrenus
Mike Habicher <mikeh@mozilla.com>
parents: 168958
diff changeset
  1210
void
217490
63b54f5f6877f71d1549c5436691ec25e6ce2a8e Bug 1099390 - add reason to onClosed event, r=aosmond,bz
Mike Habicher <mikeh@mozilla.com>
parents: 215389
diff changeset
  1211
nsDOMCameraControl::OnHardwareStateChange(CameraControlListener::HardwareState aState,
63b54f5f6877f71d1549c5436691ec25e6ce2a8e Bug 1099390 - add reason to onClosed event, r=aosmond,bz
Mike Habicher <mikeh@mozilla.com>
parents: 215389
diff changeset
  1212
                                          nsresult aReason)
168993
e93e96ed8a5ad4999e272e2a3180a32e1ffdf94d Bug 909542 - refactor CameraControl API, r=dhylands,jst,jesup,onecyrenus
Mike Habicher <mikeh@mozilla.com>
parents: 168958
diff changeset
  1213
{
219510
220f9cd8097a7d7b395ab0419c6aa62ae25f7058 Bug 1104055 - fix CameraControl memory leak, r=aosmond
Mike Habicher <mikeh@mozilla.com>
parents: 219181
diff changeset
  1214
  DOM_CAMERA_LOGT("%s:%d : this=%p\n", __func__, __LINE__, this);
168993
e93e96ed8a5ad4999e272e2a3180a32e1ffdf94d Bug 909542 - refactor CameraControl API, r=dhylands,jst,jesup,onecyrenus
Mike Habicher <mikeh@mozilla.com>
parents: 168958
diff changeset
  1215
  MOZ_ASSERT(NS_IsMainThread());
219510
220f9cd8097a7d7b395ab0419c6aa62ae25f7058 Bug 1104055 - fix CameraControl memory leak, r=aosmond
Mike Habicher <mikeh@mozilla.com>
parents: 219181
diff changeset
  1216
168993
e93e96ed8a5ad4999e272e2a3180a32e1ffdf94d Bug 909542 - refactor CameraControl API, r=dhylands,jst,jesup,onecyrenus
Mike Habicher <mikeh@mozilla.com>
parents: 168958
diff changeset
  1217
  ErrorResult ignored;
e93e96ed8a5ad4999e272e2a3180a32e1ffdf94d Bug 909542 - refactor CameraControl API, r=dhylands,jst,jesup,onecyrenus
Mike Habicher <mikeh@mozilla.com>
parents: 168958
diff changeset
  1218
e93e96ed8a5ad4999e272e2a3180a32e1ffdf94d Bug 909542 - refactor CameraControl API, r=dhylands,jst,jesup,onecyrenus
Mike Habicher <mikeh@mozilla.com>
parents: 168958
diff changeset
  1219
  switch (aState) {
e93e96ed8a5ad4999e272e2a3180a32e1ffdf94d Bug 909542 - refactor CameraControl API, r=dhylands,jst,jesup,onecyrenus
Mike Habicher <mikeh@mozilla.com>
parents: 168958
diff changeset
  1220
    case CameraControlListener::kHardwareOpen:
213736
95be75403d706081b8508b91f6e60c7846af125d Bug 1020368 - remove direct JS_*() calls from CameraRecorderProfiles, r=aosmond,bz
Mike Habicher <mikeh@mozilla.com>
parents: 213549
diff changeset
  1221
      DOM_CAMERA_LOGI("DOM OnHardwareStateChange: open\n");
217490
63b54f5f6877f71d1549c5436691ec25e6ce2a8e Bug 1099390 - add reason to onClosed event, r=aosmond,bz
Mike Habicher <mikeh@mozilla.com>
parents: 215389
diff changeset
  1222
      MOZ_ASSERT(aReason == NS_OK);
220237
ce9707a48002c8fd80f1c921b13e8f6e40d54f43 Bug 1104913 - Update selection algorithms for preview, picture and video sizes to have sane defaults. r=mikeh, r=bz
Andrew Osmond <aosmond@gmail.com>
parents: 219511
diff changeset
  1223
      if (!mSetInitialConfig) {
208669
05df8323b82079743e8af61b83625739bbadf905 Bug 994912 - Add support for promises and event-based notifications to camera. r=mikeh, r=bz
Andrew Osmond <aosmond@mozilla.com>
parents: 207338
diff changeset
  1224
        // The hardware is open, so we can return a camera to JS, even if
05df8323b82079743e8af61b83625739bbadf905 Bug 994912 - Add support for promises and event-based notifications to camera. r=mikeh, r=bz
Andrew Osmond <aosmond@mozilla.com>
parents: 207338
diff changeset
  1225
        // the preview hasn't started yet.
220237
ce9707a48002c8fd80f1c921b13e8f6e40d54f43 Bug 1104913 - Update selection algorithms for preview, picture and video sizes to have sane defaults. r=mikeh, r=bz
Andrew Osmond <aosmond@gmail.com>
parents: 219511
diff changeset
  1226
        OnGetCameraComplete();
168993
e93e96ed8a5ad4999e272e2a3180a32e1ffdf94d Bug 909542 - refactor CameraControl API, r=dhylands,jst,jesup,onecyrenus
Mike Habicher <mikeh@mozilla.com>
parents: 168958
diff changeset
  1227
      }
e93e96ed8a5ad4999e272e2a3180a32e1ffdf94d Bug 909542 - refactor CameraControl API, r=dhylands,jst,jesup,onecyrenus
Mike Habicher <mikeh@mozilla.com>
parents: 168958
diff changeset
  1228
      break;
e93e96ed8a5ad4999e272e2a3180a32e1ffdf94d Bug 909542 - refactor CameraControl API, r=dhylands,jst,jesup,onecyrenus
Mike Habicher <mikeh@mozilla.com>
parents: 168958
diff changeset
  1229
e93e96ed8a5ad4999e272e2a3180a32e1ffdf94d Bug 909542 - refactor CameraControl API, r=dhylands,jst,jesup,onecyrenus
Mike Habicher <mikeh@mozilla.com>
parents: 168958
diff changeset
  1230
    case CameraControlListener::kHardwareClosed:
213736
95be75403d706081b8508b91f6e60c7846af125d Bug 1020368 - remove direct JS_*() calls from CameraRecorderProfiles, r=aosmond,bz
Mike Habicher <mikeh@mozilla.com>
parents: 213549
diff changeset
  1231
      DOM_CAMERA_LOGI("DOM OnHardwareStateChange: closed\n");
220237
ce9707a48002c8fd80f1c921b13e8f6e40d54f43 Bug 1104913 - Update selection algorithms for preview, picture and video sizes to have sane defaults. r=mikeh, r=bz
Andrew Osmond <aosmond@gmail.com>
parents: 219511
diff changeset
  1232
      if (!mSetInitialConfig) {
268184
e8c7dfe727cd970e2c3294934e2927b14143c205 Bug 1207245 - part 6 - rename nsRefPtr<T> to RefPtr<T>; r=ehsan; a=Tomcat
Nathan Froyd <froydnj@mozilla.com>
parents: 266718
diff changeset
  1233
        RefPtr<Promise> promise = mReleasePromise.forget();
217490
63b54f5f6877f71d1549c5436691ec25e6ce2a8e Bug 1099390 - add reason to onClosed event, r=aosmond,bz
Mike Habicher <mikeh@mozilla.com>
parents: 215389
diff changeset
  1234
        if (promise) {
63b54f5f6877f71d1549c5436691ec25e6ce2a8e Bug 1099390 - add reason to onClosed event, r=aosmond,bz
Mike Habicher <mikeh@mozilla.com>
parents: 215389
diff changeset
  1235
          promise->MaybeResolve(JS::UndefinedHandleValue);
63b54f5f6877f71d1549c5436691ec25e6ce2a8e Bug 1099390 - add reason to onClosed event, r=aosmond,bz
Mike Habicher <mikeh@mozilla.com>
parents: 215389
diff changeset
  1236
        }
63b54f5f6877f71d1549c5436691ec25e6ce2a8e Bug 1099390 - add reason to onClosed event, r=aosmond,bz
Mike Habicher <mikeh@mozilla.com>
parents: 215389
diff changeset
  1237
63b54f5f6877f71d1549c5436691ec25e6ce2a8e Bug 1099390 - add reason to onClosed event, r=aosmond,bz
Mike Habicher <mikeh@mozilla.com>
parents: 215389
diff changeset
  1238
        CameraClosedEventInit eventInit;
63b54f5f6877f71d1549c5436691ec25e6ce2a8e Bug 1099390 - add reason to onClosed event, r=aosmond,bz
Mike Habicher <mikeh@mozilla.com>
parents: 215389
diff changeset
  1239
        switch (aReason) {
63b54f5f6877f71d1549c5436691ec25e6ce2a8e Bug 1099390 - add reason to onClosed event, r=aosmond,bz
Mike Habicher <mikeh@mozilla.com>
parents: 215389
diff changeset
  1240
          case NS_OK:
63b54f5f6877f71d1549c5436691ec25e6ce2a8e Bug 1099390 - add reason to onClosed event, r=aosmond,bz
Mike Habicher <mikeh@mozilla.com>
parents: 215389
diff changeset
  1241
            eventInit.mReason = NS_LITERAL_STRING("HardwareReleased");
63b54f5f6877f71d1549c5436691ec25e6ce2a8e Bug 1099390 - add reason to onClosed event, r=aosmond,bz
Mike Habicher <mikeh@mozilla.com>
parents: 215389
diff changeset
  1242
            break;
63b54f5f6877f71d1549c5436691ec25e6ce2a8e Bug 1099390 - add reason to onClosed event, r=aosmond,bz
Mike Habicher <mikeh@mozilla.com>
parents: 215389
diff changeset
  1243
63b54f5f6877f71d1549c5436691ec25e6ce2a8e Bug 1099390 - add reason to onClosed event, r=aosmond,bz
Mike Habicher <mikeh@mozilla.com>
parents: 215389
diff changeset
  1244
          case NS_ERROR_FAILURE:
63b54f5f6877f71d1549c5436691ec25e6ce2a8e Bug 1099390 - add reason to onClosed event, r=aosmond,bz
Mike Habicher <mikeh@mozilla.com>
parents: 215389
diff changeset
  1245
            eventInit.mReason = NS_LITERAL_STRING("SystemFailure");
63b54f5f6877f71d1549c5436691ec25e6ce2a8e Bug 1099390 - add reason to onClosed event, r=aosmond,bz
Mike Habicher <mikeh@mozilla.com>
parents: 215389
diff changeset
  1246
            break;
63b54f5f6877f71d1549c5436691ec25e6ce2a8e Bug 1099390 - add reason to onClosed event, r=aosmond,bz
Mike Habicher <mikeh@mozilla.com>
parents: 215389
diff changeset
  1247
63b54f5f6877f71d1549c5436691ec25e6ce2a8e Bug 1099390 - add reason to onClosed event, r=aosmond,bz
Mike Habicher <mikeh@mozilla.com>
parents: 215389
diff changeset
  1248
          case NS_ERROR_NOT_AVAILABLE:
63b54f5f6877f71d1549c5436691ec25e6ce2a8e Bug 1099390 - add reason to onClosed event, r=aosmond,bz
Mike Habicher <mikeh@mozilla.com>
parents: 215389
diff changeset
  1249
            eventInit.mReason = NS_LITERAL_STRING("NotAvailable");
63b54f5f6877f71d1549c5436691ec25e6ce2a8e Bug 1099390 - add reason to onClosed event, r=aosmond,bz
Mike Habicher <mikeh@mozilla.com>
parents: 215389
diff changeset
  1250
            break;
63b54f5f6877f71d1549c5436691ec25e6ce2a8e Bug 1099390 - add reason to onClosed event, r=aosmond,bz
Mike Habicher <mikeh@mozilla.com>
parents: 215389
diff changeset
  1251
63b54f5f6877f71d1549c5436691ec25e6ce2a8e Bug 1099390 - add reason to onClosed event, r=aosmond,bz
Mike Habicher <mikeh@mozilla.com>
parents: 215389
diff changeset
  1252
          default:
63b54f5f6877f71d1549c5436691ec25e6ce2a8e Bug 1099390 - add reason to onClosed event, r=aosmond,bz
Mike Habicher <mikeh@mozilla.com>
parents: 215389
diff changeset
  1253
            DOM_CAMERA_LOGE("Unhandled hardware close reason, 0x%x\n", aReason);
63b54f5f6877f71d1549c5436691ec25e6ce2a8e Bug 1099390 - add reason to onClosed event, r=aosmond,bz
Mike Habicher <mikeh@mozilla.com>
parents: 215389
diff changeset
  1254
            MOZ_ASSERT_UNREACHABLE("Unanticipated reason for hardware close");
63b54f5f6877f71d1549c5436691ec25e6ce2a8e Bug 1099390 - add reason to onClosed event, r=aosmond,bz
Mike Habicher <mikeh@mozilla.com>
parents: 215389
diff changeset
  1255
            eventInit.mReason = NS_LITERAL_STRING("SystemFailure");
63b54f5f6877f71d1549c5436691ec25e6ce2a8e Bug 1099390 - add reason to onClosed event, r=aosmond,bz
Mike Habicher <mikeh@mozilla.com>
parents: 215389
diff changeset
  1256
            break;
63b54f5f6877f71d1549c5436691ec25e6ce2a8e Bug 1099390 - add reason to onClosed event, r=aosmond,bz
Mike Habicher <mikeh@mozilla.com>
parents: 215389
diff changeset
  1257
        }
63b54f5f6877f71d1549c5436691ec25e6ce2a8e Bug 1099390 - add reason to onClosed event, r=aosmond,bz
Mike Habicher <mikeh@mozilla.com>
parents: 215389
diff changeset
  1258
268184
e8c7dfe727cd970e2c3294934e2927b14143c205 Bug 1207245 - part 6 - rename nsRefPtr<T> to RefPtr<T>; r=ehsan; a=Tomcat
Nathan Froyd <froydnj@mozilla.com>
parents: 266718
diff changeset
  1259
        RefPtr<CameraClosedEvent> event =
217490
63b54f5f6877f71d1549c5436691ec25e6ce2a8e Bug 1099390 - add reason to onClosed event, r=aosmond,bz
Mike Habicher <mikeh@mozilla.com>
parents: 215389
diff changeset
  1260
          CameraClosedEvent::Constructor(this,
63b54f5f6877f71d1549c5436691ec25e6ce2a8e Bug 1099390 - add reason to onClosed event, r=aosmond,bz
Mike Habicher <mikeh@mozilla.com>
parents: 215389
diff changeset
  1261
                                         NS_LITERAL_STRING("close"),
63b54f5f6877f71d1549c5436691ec25e6ce2a8e Bug 1099390 - add reason to onClosed event, r=aosmond,bz
Mike Habicher <mikeh@mozilla.com>
parents: 215389
diff changeset
  1262
                                         eventInit);
63b54f5f6877f71d1549c5436691ec25e6ce2a8e Bug 1099390 - add reason to onClosed event, r=aosmond,bz
Mike Habicher <mikeh@mozilla.com>
parents: 215389
diff changeset
  1263
        DispatchTrustedEvent(event);
220237
ce9707a48002c8fd80f1c921b13e8f6e40d54f43 Bug 1104913 - Update selection algorithms for preview, picture and video sizes to have sane defaults. r=mikeh, r=bz
Andrew Osmond <aosmond@gmail.com>
parents: 219511
diff changeset
  1264
      } else {
ce9707a48002c8fd80f1c921b13e8f6e40d54f43 Bug 1104913 - Update selection algorithms for preview, picture and video sizes to have sane defaults. r=mikeh, r=bz
Andrew Osmond <aosmond@gmail.com>
parents: 219511
diff changeset
  1265
        // The configuration failed and we forced the camera to shutdown.
ce9707a48002c8fd80f1c921b13e8f6e40d54f43 Bug 1104913 - Update selection algorithms for preview, picture and video sizes to have sane defaults. r=mikeh, r=bz
Andrew Osmond <aosmond@gmail.com>
parents: 219511
diff changeset
  1266
        OnUserError(DOMCameraControlListener::kInStartCamera, NS_ERROR_NOT_AVAILABLE);
168993
e93e96ed8a5ad4999e272e2a3180a32e1ffdf94d Bug 909542 - refactor CameraControl API, r=dhylands,jst,jesup,onecyrenus
Mike Habicher <mikeh@mozilla.com>
parents: 168958
diff changeset
  1267
      }
e93e96ed8a5ad4999e272e2a3180a32e1ffdf94d Bug 909542 - refactor CameraControl API, r=dhylands,jst,jesup,onecyrenus
Mike Habicher <mikeh@mozilla.com>
parents: 168958
diff changeset
  1268
      break;
e93e96ed8a5ad4999e272e2a3180a32e1ffdf94d Bug 909542 - refactor CameraControl API, r=dhylands,jst,jesup,onecyrenus
Mike Habicher <mikeh@mozilla.com>
parents: 168958
diff changeset
  1269
215389
ab6a050eccb912356ab9da9f27a1387a067d5f5a Bug 1079543 - handle camera hardware busy when prelaunching, r=aosmond
Mike Habicher <mikeh@mozilla.com>
parents: 214446
diff changeset
  1270
    case CameraControlListener::kHardwareOpenFailed:
ab6a050eccb912356ab9da9f27a1387a067d5f5a Bug 1079543 - handle camera hardware busy when prelaunching, r=aosmond
Mike Habicher <mikeh@mozilla.com>
parents: 214446
diff changeset
  1271
      DOM_CAMERA_LOGI("DOM OnHardwareStateChange: open failed\n");
217490
63b54f5f6877f71d1549c5436691ec25e6ce2a8e Bug 1099390 - add reason to onClosed event, r=aosmond,bz
Mike Habicher <mikeh@mozilla.com>
parents: 215389
diff changeset
  1272
      MOZ_ASSERT(aReason == NS_ERROR_NOT_AVAILABLE);
215389
ab6a050eccb912356ab9da9f27a1387a067d5f5a Bug 1079543 - handle camera hardware busy when prelaunching, r=aosmond
Mike Habicher <mikeh@mozilla.com>
parents: 214446
diff changeset
  1273
      OnUserError(DOMCameraControlListener::kInStartCamera, NS_ERROR_NOT_AVAILABLE);
ab6a050eccb912356ab9da9f27a1387a067d5f5a Bug 1079543 - handle camera hardware busy when prelaunching, r=aosmond
Mike Habicher <mikeh@mozilla.com>
parents: 214446
diff changeset
  1274
      break;
ab6a050eccb912356ab9da9f27a1387a067d5f5a Bug 1079543 - handle camera hardware busy when prelaunching, r=aosmond
Mike Habicher <mikeh@mozilla.com>
parents: 214446
diff changeset
  1275
220237
ce9707a48002c8fd80f1c921b13e8f6e40d54f43 Bug 1104913 - Update selection algorithms for preview, picture and video sizes to have sane defaults. r=mikeh, r=bz
Andrew Osmond <aosmond@gmail.com>
parents: 219511
diff changeset
  1276
    case CameraControlListener::kHardwareUninitialized:
ce9707a48002c8fd80f1c921b13e8f6e40d54f43 Bug 1104913 - Update selection algorithms for preview, picture and video sizes to have sane defaults. r=mikeh, r=bz
Andrew Osmond <aosmond@gmail.com>
parents: 219511
diff changeset
  1277
      break;
ce9707a48002c8fd80f1c921b13e8f6e40d54f43 Bug 1104913 - Update selection algorithms for preview, picture and video sizes to have sane defaults. r=mikeh, r=bz
Andrew Osmond <aosmond@gmail.com>
parents: 219511
diff changeset
  1278
168993
e93e96ed8a5ad4999e272e2a3180a32e1ffdf94d Bug 909542 - refactor CameraControl API, r=dhylands,jst,jesup,onecyrenus
Mike Habicher <mikeh@mozilla.com>
parents: 168958
diff changeset
  1279
    default:
213736
95be75403d706081b8508b91f6e60c7846af125d Bug 1020368 - remove direct JS_*() calls from CameraRecorderProfiles, r=aosmond,bz
Mike Habicher <mikeh@mozilla.com>
parents: 213549
diff changeset
  1280
      DOM_CAMERA_LOGE("DOM OnHardwareStateChange: UNKNOWN=%d\n", aState);
182301
db13bb9473cc40c42900c1d0afd841fe6ea378e2 Bug 990764 - Replace MOZ_ASSUME_UNREACHABLE in dom. r=smaug
Chris Peterson <cpeterson@mozilla.com>
parents: 181171
diff changeset
  1281
      MOZ_ASSERT_UNREACHABLE("Unanticipated camera hardware state");
168993
e93e96ed8a5ad4999e272e2a3180a32e1ffdf94d Bug 909542 - refactor CameraControl API, r=dhylands,jst,jesup,onecyrenus
Mike Habicher <mikeh@mozilla.com>
parents: 168958
diff changeset
  1282
  }
e93e96ed8a5ad4999e272e2a3180a32e1ffdf94d Bug 909542 - refactor CameraControl API, r=dhylands,jst,jesup,onecyrenus
Mike Habicher <mikeh@mozilla.com>
parents: 168958
diff changeset
  1283
}
e93e96ed8a5ad4999e272e2a3180a32e1ffdf94d Bug 909542 - refactor CameraControl API, r=dhylands,jst,jesup,onecyrenus
Mike Habicher <mikeh@mozilla.com>
parents: 168958
diff changeset
  1284
e93e96ed8a5ad4999e272e2a3180a32e1ffdf94d Bug 909542 - refactor CameraControl API, r=dhylands,jst,jesup,onecyrenus
Mike Habicher <mikeh@mozilla.com>
parents: 168958
diff changeset
  1285
void
e93e96ed8a5ad4999e272e2a3180a32e1ffdf94d Bug 909542 - refactor CameraControl API, r=dhylands,jst,jesup,onecyrenus
Mike Habicher <mikeh@mozilla.com>
parents: 168958
diff changeset
  1286
nsDOMCameraControl::OnShutter()
e93e96ed8a5ad4999e272e2a3180a32e1ffdf94d Bug 909542 - refactor CameraControl API, r=dhylands,jst,jesup,onecyrenus
Mike Habicher <mikeh@mozilla.com>
parents: 168958
diff changeset
  1287
{
219510
220f9cd8097a7d7b395ab0419c6aa62ae25f7058 Bug 1104055 - fix CameraControl memory leak, r=aosmond
Mike Habicher <mikeh@mozilla.com>
parents: 219181
diff changeset
  1288
  DOM_CAMERA_LOGI("DOM ** SNAP **\n");
168993
e93e96ed8a5ad4999e272e2a3180a32e1ffdf94d Bug 909542 - refactor CameraControl API, r=dhylands,jst,jesup,onecyrenus
Mike Habicher <mikeh@mozilla.com>
parents: 168958
diff changeset
  1289
  MOZ_ASSERT(NS_IsMainThread());
208669
05df8323b82079743e8af61b83625739bbadf905 Bug 994912 - Add support for promises and event-based notifications to camera. r=mikeh, r=bz
Andrew Osmond <aosmond@mozilla.com>
parents: 207338
diff changeset
  1290
  DispatchTrustedEvent(NS_LITERAL_STRING("shutter"));
168993
e93e96ed8a5ad4999e272e2a3180a32e1ffdf94d Bug 909542 - refactor CameraControl API, r=dhylands,jst,jesup,onecyrenus
Mike Habicher <mikeh@mozilla.com>
parents: 168958
diff changeset
  1291
}
e93e96ed8a5ad4999e272e2a3180a32e1ffdf94d Bug 909542 - refactor CameraControl API, r=dhylands,jst,jesup,onecyrenus
Mike Habicher <mikeh@mozilla.com>
parents: 168958
diff changeset
  1292
e93e96ed8a5ad4999e272e2a3180a32e1ffdf94d Bug 909542 - refactor CameraControl API, r=dhylands,jst,jesup,onecyrenus
Mike Habicher <mikeh@mozilla.com>
parents: 168958
diff changeset
  1293
void
e93e96ed8a5ad4999e272e2a3180a32e1ffdf94d Bug 909542 - refactor CameraControl API, r=dhylands,jst,jesup,onecyrenus
Mike Habicher <mikeh@mozilla.com>
parents: 168958
diff changeset
  1294
nsDOMCameraControl::OnPreviewStateChange(CameraControlListener::PreviewState aState)
e93e96ed8a5ad4999e272e2a3180a32e1ffdf94d Bug 909542 - refactor CameraControl API, r=dhylands,jst,jesup,onecyrenus
Mike Habicher <mikeh@mozilla.com>
parents: 168958
diff changeset
  1295
{
219510
220f9cd8097a7d7b395ab0419c6aa62ae25f7058 Bug 1104055 - fix CameraControl memory leak, r=aosmond
Mike Habicher <mikeh@mozilla.com>
parents: 219181
diff changeset
  1296
  DOM_CAMERA_LOGT("%s:%d : this=%p\n", __func__, __LINE__, this);
168993
e93e96ed8a5ad4999e272e2a3180a32e1ffdf94d Bug 909542 - refactor CameraControl API, r=dhylands,jst,jesup,onecyrenus
Mike Habicher <mikeh@mozilla.com>
parents: 168958
diff changeset
  1297
  MOZ_ASSERT(NS_IsMainThread());
e93e96ed8a5ad4999e272e2a3180a32e1ffdf94d Bug 909542 - refactor CameraControl API, r=dhylands,jst,jesup,onecyrenus
Mike Habicher <mikeh@mozilla.com>
parents: 168958
diff changeset
  1298
208669
05df8323b82079743e8af61b83625739bbadf905 Bug 994912 - Add support for promises and event-based notifications to camera. r=mikeh, r=bz
Andrew Osmond <aosmond@mozilla.com>
parents: 207338
diff changeset
  1299
  mPreviewState = aState;
168993
e93e96ed8a5ad4999e272e2a3180a32e1ffdf94d Bug 909542 - refactor CameraControl API, r=dhylands,jst,jesup,onecyrenus
Mike Habicher <mikeh@mozilla.com>
parents: 168958
diff changeset
  1300
  nsString state;
e93e96ed8a5ad4999e272e2a3180a32e1ffdf94d Bug 909542 - refactor CameraControl API, r=dhylands,jst,jesup,onecyrenus
Mike Habicher <mikeh@mozilla.com>
parents: 168958
diff changeset
  1301
  switch (aState) {
e93e96ed8a5ad4999e272e2a3180a32e1ffdf94d Bug 909542 - refactor CameraControl API, r=dhylands,jst,jesup,onecyrenus
Mike Habicher <mikeh@mozilla.com>
parents: 168958
diff changeset
  1302
    case CameraControlListener::kPreviewStarted:
e93e96ed8a5ad4999e272e2a3180a32e1ffdf94d Bug 909542 - refactor CameraControl API, r=dhylands,jst,jesup,onecyrenus
Mike Habicher <mikeh@mozilla.com>
parents: 168958
diff changeset
  1303
      state = NS_LITERAL_STRING("started");
e93e96ed8a5ad4999e272e2a3180a32e1ffdf94d Bug 909542 - refactor CameraControl API, r=dhylands,jst,jesup,onecyrenus
Mike Habicher <mikeh@mozilla.com>
parents: 168958
diff changeset
  1304
      break;
e93e96ed8a5ad4999e272e2a3180a32e1ffdf94d Bug 909542 - refactor CameraControl API, r=dhylands,jst,jesup,onecyrenus
Mike Habicher <mikeh@mozilla.com>
parents: 168958
diff changeset
  1305
e93e96ed8a5ad4999e272e2a3180a32e1ffdf94d Bug 909542 - refactor CameraControl API, r=dhylands,jst,jesup,onecyrenus
Mike Habicher <mikeh@mozilla.com>
parents: 168958
diff changeset
  1306
    default:
e93e96ed8a5ad4999e272e2a3180a32e1ffdf94d Bug 909542 - refactor CameraControl API, r=dhylands,jst,jesup,onecyrenus
Mike Habicher <mikeh@mozilla.com>
parents: 168958
diff changeset
  1307
      state = NS_LITERAL_STRING("stopped");
e93e96ed8a5ad4999e272e2a3180a32e1ffdf94d Bug 909542 - refactor CameraControl API, r=dhylands,jst,jesup,onecyrenus
Mike Habicher <mikeh@mozilla.com>
parents: 168958
diff changeset
  1308
      break;
e93e96ed8a5ad4999e272e2a3180a32e1ffdf94d Bug 909542 - refactor CameraControl API, r=dhylands,jst,jesup,onecyrenus
Mike Habicher <mikeh@mozilla.com>
parents: 168958
diff changeset
  1309
  }
e93e96ed8a5ad4999e272e2a3180a32e1ffdf94d Bug 909542 - refactor CameraControl API, r=dhylands,jst,jesup,onecyrenus
Mike Habicher <mikeh@mozilla.com>
parents: 168958
diff changeset
  1310
208669
05df8323b82079743e8af61b83625739bbadf905 Bug 994912 - Add support for promises and event-based notifications to camera. r=mikeh, r=bz
Andrew Osmond <aosmond@mozilla.com>
parents: 207338
diff changeset
  1311
  DispatchPreviewStateEvent(aState);
168993
e93e96ed8a5ad4999e272e2a3180a32e1ffdf94d Bug 909542 - refactor CameraControl API, r=dhylands,jst,jesup,onecyrenus
Mike Habicher <mikeh@mozilla.com>
parents: 168958
diff changeset
  1312
}
e93e96ed8a5ad4999e272e2a3180a32e1ffdf94d Bug 909542 - refactor CameraControl API, r=dhylands,jst,jesup,onecyrenus
Mike Habicher <mikeh@mozilla.com>
parents: 168958
diff changeset
  1313
e93e96ed8a5ad4999e272e2a3180a32e1ffdf94d Bug 909542 - refactor CameraControl API, r=dhylands,jst,jesup,onecyrenus
Mike Habicher <mikeh@mozilla.com>
parents: 168958
diff changeset
  1314
void
249644
e3b6829af1896d0010bf09db32c4f10f6e186479 Bug 1175656 - Implement generation of recording posters in Gecko. r=dhylands,bz
Andrew Osmond <aosmond@mozilla.com>
parents: 249622
diff changeset
  1315
nsDOMCameraControl::OnPoster(BlobImpl* aPoster)
e3b6829af1896d0010bf09db32c4f10f6e186479 Bug 1175656 - Implement generation of recording posters in Gecko. r=dhylands,bz
Andrew Osmond <aosmond@mozilla.com>
parents: 249622
diff changeset
  1316
{
e3b6829af1896d0010bf09db32c4f10f6e186479 Bug 1175656 - Implement generation of recording posters in Gecko. r=dhylands,bz
Andrew Osmond <aosmond@mozilla.com>
parents: 249622
diff changeset
  1317
  DOM_CAMERA_LOGT("%s:%d : this=%p\n", __func__, __LINE__, this);
e3b6829af1896d0010bf09db32c4f10f6e186479 Bug 1175656 - Implement generation of recording posters in Gecko. r=dhylands,bz
Andrew Osmond <aosmond@mozilla.com>
parents: 249622
diff changeset
  1318
  MOZ_ASSERT(NS_IsMainThread());
263518
378958ae220f4de9fd3934fffe2561f53e7727b0 Bug 1191731 - Update poster API to allow application control over when poster is saved. r=bz, r=dhylands
Andrew Osmond <aosmond@mozilla.com>
parents: 258070
diff changeset
  1319
  MOZ_ASSERT(mOptions.mCreatePoster);
249644
e3b6829af1896d0010bf09db32c4f10f6e186479 Bug 1175656 - Implement generation of recording posters in Gecko. r=dhylands,bz
Andrew Osmond <aosmond@mozilla.com>
parents: 249622
diff changeset
  1320
268184
e8c7dfe727cd970e2c3294934e2927b14143c205 Bug 1207245 - part 6 - rename nsRefPtr<T> to RefPtr<T>; r=ehsan; a=Tomcat
Nathan Froyd <froydnj@mozilla.com>
parents: 266718
diff changeset
  1321
  RefPtr<Blob> blob = Blob::Create(GetParentObject(), aPoster);
249644
e3b6829af1896d0010bf09db32c4f10f6e186479 Bug 1175656 - Implement generation of recording posters in Gecko. r=dhylands,bz
Andrew Osmond <aosmond@mozilla.com>
parents: 249622
diff changeset
  1322
  if (NS_WARN_IF(!blob)) {
263518
378958ae220f4de9fd3934fffe2561f53e7727b0 Bug 1191731 - Update poster API to allow application control over when poster is saved. r=bz, r=dhylands
Andrew Osmond <aosmond@mozilla.com>
parents: 258070
diff changeset
  1323
    OnRecorderStateChange(CameraControlListener::kPosterFailed, 0, 0);
249644
e3b6829af1896d0010bf09db32c4f10f6e186479 Bug 1175656 - Implement generation of recording posters in Gecko. r=dhylands,bz
Andrew Osmond <aosmond@mozilla.com>
parents: 249622
diff changeset
  1324
    return;
e3b6829af1896d0010bf09db32c4f10f6e186479 Bug 1175656 - Implement generation of recording posters in Gecko. r=dhylands,bz
Andrew Osmond <aosmond@mozilla.com>
parents: 249622
diff changeset
  1325
  }
e3b6829af1896d0010bf09db32c4f10f6e186479 Bug 1175656 - Implement generation of recording posters in Gecko. r=dhylands,bz
Andrew Osmond <aosmond@mozilla.com>
parents: 249622
diff changeset
  1326
263518
378958ae220f4de9fd3934fffe2561f53e7727b0 Bug 1191731 - Update poster API to allow application control over when poster is saved. r=bz, r=dhylands
Andrew Osmond <aosmond@mozilla.com>
parents: 258070
diff changeset
  1327
  BlobEventInit eventInit;
378958ae220f4de9fd3934fffe2561f53e7727b0 Bug 1191731 - Update poster API to allow application control over when poster is saved. r=bz, r=dhylands
Andrew Osmond <aosmond@mozilla.com>
parents: 258070
diff changeset
  1328
  eventInit.mData = blob;
249644
e3b6829af1896d0010bf09db32c4f10f6e186479 Bug 1175656 - Implement generation of recording posters in Gecko. r=dhylands,bz
Andrew Osmond <aosmond@mozilla.com>
parents: 249622
diff changeset
  1329
268184
e8c7dfe727cd970e2c3294934e2927b14143c205 Bug 1207245 - part 6 - rename nsRefPtr<T> to RefPtr<T>; r=ehsan; a=Tomcat
Nathan Froyd <froydnj@mozilla.com>
parents: 266718
diff changeset
  1330
  RefPtr<BlobEvent> event = BlobEvent::Constructor(this,
263518
378958ae220f4de9fd3934fffe2561f53e7727b0 Bug 1191731 - Update poster API to allow application control over when poster is saved. r=bz, r=dhylands
Andrew Osmond <aosmond@mozilla.com>
parents: 258070
diff changeset
  1331
                                                     NS_LITERAL_STRING("poster"),
378958ae220f4de9fd3934fffe2561f53e7727b0 Bug 1191731 - Update poster API to allow application control over when poster is saved. r=bz, r=dhylands
Andrew Osmond <aosmond@mozilla.com>
parents: 258070
diff changeset
  1332
                                                     eventInit);
249644
e3b6829af1896d0010bf09db32c4f10f6e186479 Bug 1175656 - Implement generation of recording posters in Gecko. r=dhylands,bz
Andrew Osmond <aosmond@mozilla.com>
parents: 249622
diff changeset
  1333
263518
378958ae220f4de9fd3934fffe2561f53e7727b0 Bug 1191731 - Update poster API to allow application control over when poster is saved. r=bz, r=dhylands
Andrew Osmond <aosmond@mozilla.com>
parents: 258070
diff changeset
  1334
  DispatchTrustedEvent(event);
378958ae220f4de9fd3934fffe2561f53e7727b0 Bug 1191731 - Update poster API to allow application control over when poster is saved. r=bz, r=dhylands
Andrew Osmond <aosmond@mozilla.com>
parents: 258070
diff changeset
  1335
  OnRecorderStateChange(CameraControlListener::kPosterCreated, 0, 0);
249644
e3b6829af1896d0010bf09db32c4f10f6e186479 Bug 1175656 - Implement generation of recording posters in Gecko. r=dhylands,bz
Andrew Osmond <aosmond@mozilla.com>
parents: 249622
diff changeset
  1336
}
e3b6829af1896d0010bf09db32c4f10f6e186479 Bug 1175656 - Implement generation of recording posters in Gecko. r=dhylands,bz
Andrew Osmond <aosmond@mozilla.com>
parents: 249622
diff changeset
  1337
e3b6829af1896d0010bf09db32c4f10f6e186479 Bug 1175656 - Implement generation of recording posters in Gecko. r=dhylands,bz
Andrew Osmond <aosmond@mozilla.com>
parents: 249622
diff changeset
  1338
void
168993
e93e96ed8a5ad4999e272e2a3180a32e1ffdf94d Bug 909542 - refactor CameraControl API, r=dhylands,jst,jesup,onecyrenus
Mike Habicher <mikeh@mozilla.com>
parents: 168958
diff changeset
  1339
nsDOMCameraControl::OnRecorderStateChange(CameraControlListener::RecorderState aState,
e93e96ed8a5ad4999e272e2a3180a32e1ffdf94d Bug 909542 - refactor CameraControl API, r=dhylands,jst,jesup,onecyrenus
Mike Habicher <mikeh@mozilla.com>
parents: 168958
diff changeset
  1340
                                          int32_t aArg, int32_t aTrackNum)
e93e96ed8a5ad4999e272e2a3180a32e1ffdf94d Bug 909542 - refactor CameraControl API, r=dhylands,jst,jesup,onecyrenus
Mike Habicher <mikeh@mozilla.com>
parents: 168958
diff changeset
  1341
{
e93e96ed8a5ad4999e272e2a3180a32e1ffdf94d Bug 909542 - refactor CameraControl API, r=dhylands,jst,jesup,onecyrenus
Mike Habicher <mikeh@mozilla.com>
parents: 168958
diff changeset
  1342
  // For now, we do nothing with 'aStatus' and 'aTrackNum'.
249187
9ba890d2ba081ceea82be94530b3fafffa51b766 Bug 1152500 - Fix how stop recording may be handled out-of-order. r=dhylands
Andrew Osmond <aosmond@mozilla.com>
parents: 246249
diff changeset
  1343
  DOM_CAMERA_LOGT("%s:%d : this=%p, state=%u\n", __func__, __LINE__, this, aState);
168993
e93e96ed8a5ad4999e272e2a3180a32e1ffdf94d Bug 909542 - refactor CameraControl API, r=dhylands,jst,jesup,onecyrenus
Mike Habicher <mikeh@mozilla.com>
parents: 168958
diff changeset
  1344
  MOZ_ASSERT(NS_IsMainThread());
e93e96ed8a5ad4999e272e2a3180a32e1ffdf94d Bug 909542 - refactor CameraControl API, r=dhylands,jst,jesup,onecyrenus
Mike Habicher <mikeh@mozilla.com>
parents: 168958
diff changeset
  1345
e93e96ed8a5ad4999e272e2a3180a32e1ffdf94d Bug 909542 - refactor CameraControl API, r=dhylands,jst,jesup,onecyrenus
Mike Habicher <mikeh@mozilla.com>
parents: 168958
diff changeset
  1346
  ErrorResult ignored;
e93e96ed8a5ad4999e272e2a3180a32e1ffdf94d Bug 909542 - refactor CameraControl API, r=dhylands,jst,jesup,onecyrenus
Mike Habicher <mikeh@mozilla.com>
parents: 168958
diff changeset
  1347
  nsString state;
e93e96ed8a5ad4999e272e2a3180a32e1ffdf94d Bug 909542 - refactor CameraControl API, r=dhylands,jst,jesup,onecyrenus
Mike Habicher <mikeh@mozilla.com>
parents: 168958
diff changeset
  1348
e93e96ed8a5ad4999e272e2a3180a32e1ffdf94d Bug 909542 - refactor CameraControl API, r=dhylands,jst,jesup,onecyrenus
Mike Habicher <mikeh@mozilla.com>
parents: 168958
diff changeset
  1349
  switch (aState) {
e93e96ed8a5ad4999e272e2a3180a32e1ffdf94d Bug 909542 - refactor CameraControl API, r=dhylands,jst,jesup,onecyrenus
Mike Habicher <mikeh@mozilla.com>
parents: 168958
diff changeset
  1350
    case CameraControlListener::kRecorderStarted:
208669
05df8323b82079743e8af61b83625739bbadf905 Bug 994912 - Add support for promises and event-based notifications to camera. r=mikeh, r=bz
Andrew Osmond <aosmond@mozilla.com>
parents: 207338
diff changeset
  1351
      {
268184
e8c7dfe727cd970e2c3294934e2927b14143c205 Bug 1207245 - part 6 - rename nsRefPtr<T> to RefPtr<T>; r=ehsan; a=Tomcat
Nathan Froyd <froydnj@mozilla.com>
parents: 266718
diff changeset
  1352
        RefPtr<Promise> promise = mStartRecordingPromise.forget();
208669
05df8323b82079743e8af61b83625739bbadf905 Bug 994912 - Add support for promises and event-based notifications to camera. r=mikeh, r=bz
Andrew Osmond <aosmond@mozilla.com>
parents: 207338
diff changeset
  1353
        if (promise) {
05df8323b82079743e8af61b83625739bbadf905 Bug 994912 - Add support for promises and event-based notifications to camera. r=mikeh, r=bz
Andrew Osmond <aosmond@mozilla.com>
parents: 207338
diff changeset
  1354
          promise->MaybeResolve(JS::UndefinedHandleValue);
05df8323b82079743e8af61b83625739bbadf905 Bug 994912 - Add support for promises and event-based notifications to camera. r=mikeh, r=bz
Andrew Osmond <aosmond@mozilla.com>
parents: 207338
diff changeset
  1355
        }
05df8323b82079743e8af61b83625739bbadf905 Bug 994912 - Add support for promises and event-based notifications to camera. r=mikeh, r=bz
Andrew Osmond <aosmond@mozilla.com>
parents: 207338
diff changeset
  1356
05df8323b82079743e8af61b83625739bbadf905 Bug 994912 - Add support for promises and event-based notifications to camera. r=mikeh, r=bz
Andrew Osmond <aosmond@mozilla.com>
parents: 207338
diff changeset
  1357
        state = NS_LITERAL_STRING("Started");
168993
e93e96ed8a5ad4999e272e2a3180a32e1ffdf94d Bug 909542 - refactor CameraControl API, r=dhylands,jst,jesup,onecyrenus
Mike Habicher <mikeh@mozilla.com>
parents: 168958
diff changeset
  1358
      }
170778
cc5288f6ab2a4ac0ce1f768725625e05fc55bff7 Bug 977313 - exposed "Started" and "Stopped" recorder states, r=dhylands
Mike Habicher <mikeh@mozilla.com>
parents: 170501
diff changeset
  1359
      break;
168993
e93e96ed8a5ad4999e272e2a3180a32e1ffdf94d Bug 909542 - refactor CameraControl API, r=dhylands,jst,jesup,onecyrenus
Mike Habicher <mikeh@mozilla.com>
parents: 168958
diff changeset
  1360
e93e96ed8a5ad4999e272e2a3180a32e1ffdf94d Bug 909542 - refactor CameraControl API, r=dhylands,jst,jesup,onecyrenus
Mike Habicher <mikeh@mozilla.com>
parents: 168958
diff changeset
  1361
    case CameraControlListener::kRecorderStopped:
263518
378958ae220f4de9fd3934fffe2561f53e7727b0 Bug 1191731 - Update poster API to allow application control over when poster is saved. r=bz, r=dhylands
Andrew Osmond <aosmond@mozilla.com>
parents: 258070
diff changeset
  1362
      if (mOptions.mCreatePoster) {
249644
e3b6829af1896d0010bf09db32c4f10f6e186479 Bug 1175656 - Implement generation of recording posters in Gecko. r=dhylands,bz
Andrew Osmond <aosmond@mozilla.com>
parents: 249622
diff changeset
  1363
        mRecordingStoppedDeferred = true;
e3b6829af1896d0010bf09db32c4f10f6e186479 Bug 1175656 - Implement generation of recording posters in Gecko. r=dhylands,bz
Andrew Osmond <aosmond@mozilla.com>
parents: 249622
diff changeset
  1364
        return;
e3b6829af1896d0010bf09db32c4f10f6e186479 Bug 1175656 - Implement generation of recording posters in Gecko. r=dhylands,bz
Andrew Osmond <aosmond@mozilla.com>
parents: 249622
diff changeset
  1365
      }
e3b6829af1896d0010bf09db32c4f10f6e186479 Bug 1175656 - Implement generation of recording posters in Gecko. r=dhylands,bz
Andrew Osmond <aosmond@mozilla.com>
parents: 249622
diff changeset
  1366
168993
e93e96ed8a5ad4999e272e2a3180a32e1ffdf94d Bug 909542 - refactor CameraControl API, r=dhylands,jst,jesup,onecyrenus
Mike Habicher <mikeh@mozilla.com>
parents: 168958
diff changeset
  1367
      NotifyRecordingStatusChange(NS_LITERAL_STRING("shutdown"));
170778
cc5288f6ab2a4ac0ce1f768725625e05fc55bff7 Bug 977313 - exposed "Started" and "Stopped" recorder states, r=dhylands
Mike Habicher <mikeh@mozilla.com>
parents: 170501
diff changeset
  1368
      state = NS_LITERAL_STRING("Stopped");
cc5288f6ab2a4ac0ce1f768725625e05fc55bff7 Bug 977313 - exposed "Started" and "Stopped" recorder states, r=dhylands
Mike Habicher <mikeh@mozilla.com>
parents: 170501
diff changeset
  1369
      break;
168993
e93e96ed8a5ad4999e272e2a3180a32e1ffdf94d Bug 909542 - refactor CameraControl API, r=dhylands,jst,jesup,onecyrenus
Mike Habicher <mikeh@mozilla.com>
parents: 168958
diff changeset
  1370
249644
e3b6829af1896d0010bf09db32c4f10f6e186479 Bug 1175656 - Implement generation of recording posters in Gecko. r=dhylands,bz
Andrew Osmond <aosmond@mozilla.com>
parents: 249622
diff changeset
  1371
    case CameraControlListener::kPosterCreated:
e3b6829af1896d0010bf09db32c4f10f6e186479 Bug 1175656 - Implement generation of recording posters in Gecko. r=dhylands,bz
Andrew Osmond <aosmond@mozilla.com>
parents: 249622
diff changeset
  1372
      state = NS_LITERAL_STRING("PosterCreated");
263518
378958ae220f4de9fd3934fffe2561f53e7727b0 Bug 1191731 - Update poster API to allow application control over when poster is saved. r=bz, r=dhylands
Andrew Osmond <aosmond@mozilla.com>
parents: 258070
diff changeset
  1373
      mOptions.mCreatePoster = false;
249644
e3b6829af1896d0010bf09db32c4f10f6e186479 Bug 1175656 - Implement generation of recording posters in Gecko. r=dhylands,bz
Andrew Osmond <aosmond@mozilla.com>
parents: 249622
diff changeset
  1374
      break;
e3b6829af1896d0010bf09db32c4f10f6e186479 Bug 1175656 - Implement generation of recording posters in Gecko. r=dhylands,bz
Andrew Osmond <aosmond@mozilla.com>
parents: 249622
diff changeset
  1375
e3b6829af1896d0010bf09db32c4f10f6e186479 Bug 1175656 - Implement generation of recording posters in Gecko. r=dhylands,bz
Andrew Osmond <aosmond@mozilla.com>
parents: 249622
diff changeset
  1376
    case CameraControlListener::kPosterFailed:
e3b6829af1896d0010bf09db32c4f10f6e186479 Bug 1175656 - Implement generation of recording posters in Gecko. r=dhylands,bz
Andrew Osmond <aosmond@mozilla.com>
parents: 249622
diff changeset
  1377
      state = NS_LITERAL_STRING("PosterFailed");
263518
378958ae220f4de9fd3934fffe2561f53e7727b0 Bug 1191731 - Update poster API to allow application control over when poster is saved. r=bz, r=dhylands
Andrew Osmond <aosmond@mozilla.com>
parents: 258070
diff changeset
  1378
      mOptions.mCreatePoster = false;
249644
e3b6829af1896d0010bf09db32c4f10f6e186479 Bug 1175656 - Implement generation of recording posters in Gecko. r=dhylands,bz
Andrew Osmond <aosmond@mozilla.com>
parents: 249622
diff changeset
  1379
      break;
e3b6829af1896d0010bf09db32c4f10f6e186479 Bug 1175656 - Implement generation of recording posters in Gecko. r=dhylands,bz
Andrew Osmond <aosmond@mozilla.com>
parents: 249622
diff changeset
  1380
258070
5aa09eb27b71f1a03f8afa3901c4c64d0d0208e4 Bug 1187364 - Part 1. Add ability for camera to pause/resume recording. r=dhylands,bz
Andrew Osmond <aosmond@mozilla.com>
parents: 256549
diff changeset
  1381
    case CameraControlListener::kRecorderPaused:
5aa09eb27b71f1a03f8afa3901c4c64d0d0208e4 Bug 1187364 - Part 1. Add ability for camera to pause/resume recording. r=dhylands,bz
Andrew Osmond <aosmond@mozilla.com>
parents: 256549
diff changeset
  1382
      state = NS_LITERAL_STRING("Paused");
5aa09eb27b71f1a03f8afa3901c4c64d0d0208e4 Bug 1187364 - Part 1. Add ability for camera to pause/resume recording. r=dhylands,bz
Andrew Osmond <aosmond@mozilla.com>
parents: 256549
diff changeset
  1383
      break;
5aa09eb27b71f1a03f8afa3901c4c64d0d0208e4 Bug 1187364 - Part 1. Add ability for camera to pause/resume recording. r=dhylands,bz
Andrew Osmond <aosmond@mozilla.com>
parents: 256549
diff changeset
  1384
5aa09eb27b71f1a03f8afa3901c4c64d0d0208e4 Bug 1187364 - Part 1. Add ability for camera to pause/resume recording. r=dhylands,bz
Andrew Osmond <aosmond@mozilla.com>
parents: 256549
diff changeset
  1385
    case CameraControlListener::kRecorderResumed:
5aa09eb27b71f1a03f8afa3901c4c64d0d0208e4 Bug 1187364 - Part 1. Add ability for camera to pause/resume recording. r=dhylands,bz
Andrew Osmond <aosmond@mozilla.com>
parents: 256549
diff changeset
  1386
      state = NS_LITERAL_STRING("Resumed");
5aa09eb27b71f1a03f8afa3901c4c64d0d0208e4 Bug 1187364 - Part 1. Add ability for camera to pause/resume recording. r=dhylands,bz
Andrew Osmond <aosmond@mozilla.com>
parents: 256549
diff changeset
  1387
      break;
5aa09eb27b71f1a03f8afa3901c4c64d0d0208e4 Bug 1187364 - Part 1. Add ability for camera to pause/resume recording. r=dhylands,bz
Andrew Osmond <aosmond@mozilla.com>
parents: 256549
diff changeset
  1388
168993
e93e96ed8a5ad4999e272e2a3180a32e1ffdf94d Bug 909542 - refactor CameraControl API, r=dhylands,jst,jesup,onecyrenus
Mike Habicher <mikeh@mozilla.com>
parents: 168958
diff changeset
  1389
#ifdef MOZ_B2G_CAMERA
e93e96ed8a5ad4999e272e2a3180a32e1ffdf94d Bug 909542 - refactor CameraControl API, r=dhylands,jst,jesup,onecyrenus
Mike Habicher <mikeh@mozilla.com>
parents: 168958
diff changeset
  1390
    case CameraControlListener::kFileSizeLimitReached:
e93e96ed8a5ad4999e272e2a3180a32e1ffdf94d Bug 909542 - refactor CameraControl API, r=dhylands,jst,jesup,onecyrenus
Mike Habicher <mikeh@mozilla.com>
parents: 168958
diff changeset
  1391
      state = NS_LITERAL_STRING("FileSizeLimitReached");
e93e96ed8a5ad4999e272e2a3180a32e1ffdf94d Bug 909542 - refactor CameraControl API, r=dhylands,jst,jesup,onecyrenus
Mike Habicher <mikeh@mozilla.com>
parents: 168958
diff changeset
  1392
      break;
e93e96ed8a5ad4999e272e2a3180a32e1ffdf94d Bug 909542 - refactor CameraControl API, r=dhylands,jst,jesup,onecyrenus
Mike Habicher <mikeh@mozilla.com>
parents: 168958
diff changeset
  1393
e93e96ed8a5ad4999e272e2a3180a32e1ffdf94d Bug 909542 - refactor CameraControl API, r=dhylands,jst,jesup,onecyrenus
Mike Habicher <mikeh@mozilla.com>
parents: 168958
diff changeset
  1394
    case CameraControlListener::kVideoLengthLimitReached:
e93e96ed8a5ad4999e272e2a3180a32e1ffdf94d Bug 909542 - refactor CameraControl API, r=dhylands,jst,jesup,onecyrenus
Mike Habicher <mikeh@mozilla.com>
parents: 168958
diff changeset
  1395
      state = NS_LITERAL_STRING("VideoLengthLimitReached");
e93e96ed8a5ad4999e272e2a3180a32e1ffdf94d Bug 909542 - refactor CameraControl API, r=dhylands,jst,jesup,onecyrenus
Mike Habicher <mikeh@mozilla.com>
parents: 168958
diff changeset
  1396
      break;
e93e96ed8a5ad4999e272e2a3180a32e1ffdf94d Bug 909542 - refactor CameraControl API, r=dhylands,jst,jesup,onecyrenus
Mike Habicher <mikeh@mozilla.com>
parents: 168958
diff changeset
  1397
e93e96ed8a5ad4999e272e2a3180a32e1ffdf94d Bug 909542 - refactor CameraControl API, r=dhylands,jst,jesup,onecyrenus
Mike Habicher <mikeh@mozilla.com>
parents: 168958
diff changeset
  1398
    case CameraControlListener::kTrackCompleted:
e93e96ed8a5ad4999e272e2a3180a32e1ffdf94d Bug 909542 - refactor CameraControl API, r=dhylands,jst,jesup,onecyrenus
Mike Habicher <mikeh@mozilla.com>
parents: 168958
diff changeset
  1399
      state = NS_LITERAL_STRING("TrackCompleted");
e93e96ed8a5ad4999e272e2a3180a32e1ffdf94d Bug 909542 - refactor CameraControl API, r=dhylands,jst,jesup,onecyrenus
Mike Habicher <mikeh@mozilla.com>
parents: 168958
diff changeset
  1400
      break;
e93e96ed8a5ad4999e272e2a3180a32e1ffdf94d Bug 909542 - refactor CameraControl API, r=dhylands,jst,jesup,onecyrenus
Mike Habicher <mikeh@mozilla.com>
parents: 168958
diff changeset
  1401
e93e96ed8a5ad4999e272e2a3180a32e1ffdf94d Bug 909542 - refactor CameraControl API, r=dhylands,jst,jesup,onecyrenus
Mike Habicher <mikeh@mozilla.com>
parents: 168958
diff changeset
  1402
    case CameraControlListener::kTrackFailed:
e93e96ed8a5ad4999e272e2a3180a32e1ffdf94d Bug 909542 - refactor CameraControl API, r=dhylands,jst,jesup,onecyrenus
Mike Habicher <mikeh@mozilla.com>
parents: 168958
diff changeset
  1403
      state = NS_LITERAL_STRING("TrackFailed");
e93e96ed8a5ad4999e272e2a3180a32e1ffdf94d Bug 909542 - refactor CameraControl API, r=dhylands,jst,jesup,onecyrenus
Mike Habicher <mikeh@mozilla.com>
parents: 168958
diff changeset
  1404
      break;
e93e96ed8a5ad4999e272e2a3180a32e1ffdf94d Bug 909542 - refactor CameraControl API, r=dhylands,jst,jesup,onecyrenus
Mike Habicher <mikeh@mozilla.com>
parents: 168958
diff changeset
  1405
e93e96ed8a5ad4999e272e2a3180a32e1ffdf94d Bug 909542 - refactor CameraControl API, r=dhylands,jst,jesup,onecyrenus
Mike Habicher <mikeh@mozilla.com>
parents: 168958
diff changeset
  1406
    case CameraControlListener::kMediaRecorderFailed:
e93e96ed8a5ad4999e272e2a3180a32e1ffdf94d Bug 909542 - refactor CameraControl API, r=dhylands,jst,jesup,onecyrenus
Mike Habicher <mikeh@mozilla.com>
parents: 168958
diff changeset
  1407
      state = NS_LITERAL_STRING("MediaRecorderFailed");
e93e96ed8a5ad4999e272e2a3180a32e1ffdf94d Bug 909542 - refactor CameraControl API, r=dhylands,jst,jesup,onecyrenus
Mike Habicher <mikeh@mozilla.com>
parents: 168958
diff changeset
  1408
      break;
e93e96ed8a5ad4999e272e2a3180a32e1ffdf94d Bug 909542 - refactor CameraControl API, r=dhylands,jst,jesup,onecyrenus
Mike Habicher <mikeh@mozilla.com>
parents: 168958
diff changeset
  1409
e93e96ed8a5ad4999e272e2a3180a32e1ffdf94d Bug 909542 - refactor CameraControl API, r=dhylands,jst,jesup,onecyrenus
Mike Habicher <mikeh@mozilla.com>
parents: 168958
diff changeset
  1410
    case CameraControlListener::kMediaServerFailed:
e93e96ed8a5ad4999e272e2a3180a32e1ffdf94d Bug 909542 - refactor CameraControl API, r=dhylands,jst,jesup,onecyrenus
Mike Habicher <mikeh@mozilla.com>
parents: 168958
diff changeset
  1411
      state = NS_LITERAL_STRING("MediaServerFailed");
e93e96ed8a5ad4999e272e2a3180a32e1ffdf94d Bug 909542 - refactor CameraControl API, r=dhylands,jst,jesup,onecyrenus
Mike Habicher <mikeh@mozilla.com>
parents: 168958
diff changeset
  1412
      break;
e93e96ed8a5ad4999e272e2a3180a32e1ffdf94d Bug 909542 - refactor CameraControl API, r=dhylands,jst,jesup,onecyrenus
Mike Habicher <mikeh@mozilla.com>
parents: 168958
diff changeset
  1413
#endif
e93e96ed8a5ad4999e272e2a3180a32e1ffdf94d Bug 909542 - refactor CameraControl API, r=dhylands,jst,jesup,onecyrenus
Mike Habicher <mikeh@mozilla.com>
parents: 168958
diff changeset
  1414
e93e96ed8a5ad4999e272e2a3180a32e1ffdf94d Bug 909542 - refactor CameraControl API, r=dhylands,jst,jesup,onecyrenus
Mike Habicher <mikeh@mozilla.com>
parents: 168958
diff changeset
  1415
    default:
182301
db13bb9473cc40c42900c1d0afd841fe6ea378e2 Bug 990764 - Replace MOZ_ASSUME_UNREACHABLE in dom. r=smaug
Chris Peterson <cpeterson@mozilla.com>
parents: 181171
diff changeset
  1416
      MOZ_ASSERT_UNREACHABLE("Unanticipated video recorder error");
168993
e93e96ed8a5ad4999e272e2a3180a32e1ffdf94d Bug 909542 - refactor CameraControl API, r=dhylands,jst,jesup,onecyrenus
Mike Habicher <mikeh@mozilla.com>
parents: 168958
diff changeset
  1417
      return;
e93e96ed8a5ad4999e272e2a3180a32e1ffdf94d Bug 909542 - refactor CameraControl API, r=dhylands,jst,jesup,onecyrenus
Mike Habicher <mikeh@mozilla.com>
parents: 168958
diff changeset
  1418
  }
e93e96ed8a5ad4999e272e2a3180a32e1ffdf94d Bug 909542 - refactor CameraControl API, r=dhylands,jst,jesup,onecyrenus
Mike Habicher <mikeh@mozilla.com>
parents: 168958
diff changeset
  1419
208669
05df8323b82079743e8af61b83625739bbadf905 Bug 994912 - Add support for promises and event-based notifications to camera. r=mikeh, r=bz
Andrew Osmond <aosmond@mozilla.com>
parents: 207338
diff changeset
  1420
  DispatchStateEvent(NS_LITERAL_STRING("recorderstatechange"), state);
249644
e3b6829af1896d0010bf09db32c4f10f6e186479 Bug 1175656 - Implement generation of recording posters in Gecko. r=dhylands,bz
Andrew Osmond <aosmond@mozilla.com>
parents: 249622
diff changeset
  1421
263518
378958ae220f4de9fd3934fffe2561f53e7727b0 Bug 1191731 - Update poster API to allow application control over when poster is saved. r=bz, r=dhylands
Andrew Osmond <aosmond@mozilla.com>
parents: 258070
diff changeset
  1422
  if (mRecordingStoppedDeferred && !mOptions.mCreatePoster) {
249644
e3b6829af1896d0010bf09db32c4f10f6e186479 Bug 1175656 - Implement generation of recording posters in Gecko. r=dhylands,bz
Andrew Osmond <aosmond@mozilla.com>
parents: 249622
diff changeset
  1423
    mRecordingStoppedDeferred = false;
e3b6829af1896d0010bf09db32c4f10f6e186479 Bug 1175656 - Implement generation of recording posters in Gecko. r=dhylands,bz
Andrew Osmond <aosmond@mozilla.com>
parents: 249622
diff changeset
  1424
    OnRecorderStateChange(CameraControlListener::kRecorderStopped, 0, 0);
e3b6829af1896d0010bf09db32c4f10f6e186479 Bug 1175656 - Implement generation of recording posters in Gecko. r=dhylands,bz
Andrew Osmond <aosmond@mozilla.com>
parents: 249622
diff changeset
  1425
  }
168993
e93e96ed8a5ad4999e272e2a3180a32e1ffdf94d Bug 909542 - refactor CameraControl API, r=dhylands,jst,jesup,onecyrenus
Mike Habicher <mikeh@mozilla.com>
parents: 168958
diff changeset
  1426
}
e93e96ed8a5ad4999e272e2a3180a32e1ffdf94d Bug 909542 - refactor CameraControl API, r=dhylands,jst,jesup,onecyrenus
Mike Habicher <mikeh@mozilla.com>
parents: 168958
diff changeset
  1427
e93e96ed8a5ad4999e272e2a3180a32e1ffdf94d Bug 909542 - refactor CameraControl API, r=dhylands,jst,jesup,onecyrenus
Mike Habicher <mikeh@mozilla.com>
parents: 168958
diff changeset
  1428
void
e93e96ed8a5ad4999e272e2a3180a32e1ffdf94d Bug 909542 - refactor CameraControl API, r=dhylands,jst,jesup,onecyrenus
Mike Habicher <mikeh@mozilla.com>
parents: 168958
diff changeset
  1429
nsDOMCameraControl::OnConfigurationChange(DOMCameraConfiguration* aConfiguration)
e93e96ed8a5ad4999e272e2a3180a32e1ffdf94d Bug 909542 - refactor CameraControl API, r=dhylands,jst,jesup,onecyrenus
Mike Habicher <mikeh@mozilla.com>
parents: 168958
diff changeset
  1430
{
219510
220f9cd8097a7d7b395ab0419c6aa62ae25f7058 Bug 1104055 - fix CameraControl memory leak, r=aosmond
Mike Habicher <mikeh@mozilla.com>
parents: 219181
diff changeset
  1431
  DOM_CAMERA_LOGT("%s:%d : this=%p\n", __func__, __LINE__, this);
168993
e93e96ed8a5ad4999e272e2a3180a32e1ffdf94d Bug 909542 - refactor CameraControl API, r=dhylands,jst,jesup,onecyrenus
Mike Habicher <mikeh@mozilla.com>
parents: 168958
diff changeset
  1432
  MOZ_ASSERT(NS_IsMainThread());
208669
05df8323b82079743e8af61b83625739bbadf905 Bug 994912 - Add support for promises and event-based notifications to camera. r=mikeh, r=bz
Andrew Osmond <aosmond@mozilla.com>
parents: 207338
diff changeset
  1433
  MOZ_ASSERT(aConfiguration != nullptr);
168993
e93e96ed8a5ad4999e272e2a3180a32e1ffdf94d Bug 909542 - refactor CameraControl API, r=dhylands,jst,jesup,onecyrenus
Mike Habicher <mikeh@mozilla.com>
parents: 168958
diff changeset
  1434
e93e96ed8a5ad4999e272e2a3180a32e1ffdf94d Bug 909542 - refactor CameraControl API, r=dhylands,jst,jesup,onecyrenus
Mike Habicher <mikeh@mozilla.com>
parents: 168958
diff changeset
  1435
  // Update our record of the current camera configuration
e93e96ed8a5ad4999e272e2a3180a32e1ffdf94d Bug 909542 - refactor CameraControl API, r=dhylands,jst,jesup,onecyrenus
Mike Habicher <mikeh@mozilla.com>
parents: 168958
diff changeset
  1436
  mCurrentConfiguration = aConfiguration;
e93e96ed8a5ad4999e272e2a3180a32e1ffdf94d Bug 909542 - refactor CameraControl API, r=dhylands,jst,jesup,onecyrenus
Mike Habicher <mikeh@mozilla.com>
parents: 168958
diff changeset
  1437
e93e96ed8a5ad4999e272e2a3180a32e1ffdf94d Bug 909542 - refactor CameraControl API, r=dhylands,jst,jesup,onecyrenus
Mike Habicher <mikeh@mozilla.com>
parents: 168958
diff changeset
  1438
  DOM_CAMERA_LOGI("DOM OnConfigurationChange: this=%p\n", this);
e93e96ed8a5ad4999e272e2a3180a32e1ffdf94d Bug 909542 - refactor CameraControl API, r=dhylands,jst,jesup,onecyrenus
Mike Habicher <mikeh@mozilla.com>
parents: 168958
diff changeset
  1439
  DOM_CAMERA_LOGI("    mode                   : %s\n",
e93e96ed8a5ad4999e272e2a3180a32e1ffdf94d Bug 909542 - refactor CameraControl API, r=dhylands,jst,jesup,onecyrenus
Mike Habicher <mikeh@mozilla.com>
parents: 168958
diff changeset
  1440
    mCurrentConfiguration->mMode == CameraMode::Video ? "video" : "picture");
e93e96ed8a5ad4999e272e2a3180a32e1ffdf94d Bug 909542 - refactor CameraControl API, r=dhylands,jst,jesup,onecyrenus
Mike Habicher <mikeh@mozilla.com>
parents: 168958
diff changeset
  1441
  DOM_CAMERA_LOGI("    maximum focus areas    : %d\n",
e93e96ed8a5ad4999e272e2a3180a32e1ffdf94d Bug 909542 - refactor CameraControl API, r=dhylands,jst,jesup,onecyrenus
Mike Habicher <mikeh@mozilla.com>
parents: 168958
diff changeset
  1442
    mCurrentConfiguration->mMaxFocusAreas);
e93e96ed8a5ad4999e272e2a3180a32e1ffdf94d Bug 909542 - refactor CameraControl API, r=dhylands,jst,jesup,onecyrenus
Mike Habicher <mikeh@mozilla.com>
parents: 168958
diff changeset
  1443
  DOM_CAMERA_LOGI("    maximum metering areas : %d\n",
e93e96ed8a5ad4999e272e2a3180a32e1ffdf94d Bug 909542 - refactor CameraControl API, r=dhylands,jst,jesup,onecyrenus
Mike Habicher <mikeh@mozilla.com>
parents: 168958
diff changeset
  1444
    mCurrentConfiguration->mMaxMeteringAreas);
e93e96ed8a5ad4999e272e2a3180a32e1ffdf94d Bug 909542 - refactor CameraControl API, r=dhylands,jst,jesup,onecyrenus
Mike Habicher <mikeh@mozilla.com>
parents: 168958
diff changeset
  1445
  DOM_CAMERA_LOGI("    preview size (w x h)   : %d x %d\n",
e93e96ed8a5ad4999e272e2a3180a32e1ffdf94d Bug 909542 - refactor CameraControl API, r=dhylands,jst,jesup,onecyrenus
Mike Habicher <mikeh@mozilla.com>
parents: 168958
diff changeset
  1446
    mCurrentConfiguration->mPreviewSize.mWidth, mCurrentConfiguration->mPreviewSize.mHeight);
220237
ce9707a48002c8fd80f1c921b13e8f6e40d54f43 Bug 1104913 - Update selection algorithms for preview, picture and video sizes to have sane defaults. r=mikeh, r=bz
Andrew Osmond <aosmond@gmail.com>
parents: 219511
diff changeset
  1447
  DOM_CAMERA_LOGI("    picture size (w x h)   : %d x %d\n",
ce9707a48002c8fd80f1c921b13e8f6e40d54f43 Bug 1104913 - Update selection algorithms for preview, picture and video sizes to have sane defaults. r=mikeh, r=bz
Andrew Osmond <aosmond@gmail.com>
parents: 219511
diff changeset
  1448
    mCurrentConfiguration->mPictureSize.mWidth, mCurrentConfiguration->mPictureSize.mHeight);
168993
e93e96ed8a5ad4999e272e2a3180a32e1ffdf94d Bug 909542 - refactor CameraControl API, r=dhylands,jst,jesup,onecyrenus
Mike Habicher <mikeh@mozilla.com>
parents: 168958
diff changeset
  1449
  DOM_CAMERA_LOGI("    recorder profile       : %s\n",
e93e96ed8a5ad4999e272e2a3180a32e1ffdf94d Bug 909542 - refactor CameraControl API, r=dhylands,jst,jesup,onecyrenus
Mike Habicher <mikeh@mozilla.com>
parents: 168958
diff changeset
  1450
    NS_ConvertUTF16toUTF8(mCurrentConfiguration->mRecorderProfile).get());
e93e96ed8a5ad4999e272e2a3180a32e1ffdf94d Bug 909542 - refactor CameraControl API, r=dhylands,jst,jesup,onecyrenus
Mike Habicher <mikeh@mozilla.com>
parents: 168958
diff changeset
  1451
220237
ce9707a48002c8fd80f1c921b13e8f6e40d54f43 Bug 1104913 - Update selection algorithms for preview, picture and video sizes to have sane defaults. r=mikeh, r=bz
Andrew Osmond <aosmond@gmail.com>
parents: 219511
diff changeset
  1452
  if (mSetInitialConfig) {
ce9707a48002c8fd80f1c921b13e8f6e40d54f43 Bug 1104913 - Update selection algorithms for preview, picture and video sizes to have sane defaults. r=mikeh, r=bz
Andrew Osmond <aosmond@gmail.com>
parents: 219511
diff changeset
  1453
    OnGetCameraComplete();
ce9707a48002c8fd80f1c921b13e8f6e40d54f43 Bug 1104913 - Update selection algorithms for preview, picture and video sizes to have sane defaults. r=mikeh, r=bz
Andrew Osmond <aosmond@gmail.com>
parents: 219511
diff changeset
  1454
    mSetInitialConfig = false;
ce9707a48002c8fd80f1c921b13e8f6e40d54f43 Bug 1104913 - Update selection algorithms for preview, picture and video sizes to have sane defaults. r=mikeh, r=bz
Andrew Osmond <aosmond@gmail.com>
parents: 219511
diff changeset
  1455
    return;
ce9707a48002c8fd80f1c921b13e8f6e40d54f43 Bug 1104913 - Update selection algorithms for preview, picture and video sizes to have sane defaults. r=mikeh, r=bz
Andrew Osmond <aosmond@gmail.com>
parents: 219511
diff changeset
  1456
  }
ce9707a48002c8fd80f1c921b13e8f6e40d54f43 Bug 1104913 - Update selection algorithms for preview, picture and video sizes to have sane defaults. r=mikeh, r=bz
Andrew Osmond <aosmond@gmail.com>
parents: 219511
diff changeset
  1457
268184
e8c7dfe727cd970e2c3294934e2927b14143c205 Bug 1207245 - part 6 - rename nsRefPtr<T> to RefPtr<T>; r=ehsan; a=Tomcat
Nathan Froyd <froydnj@mozilla.com>
parents: 266718
diff changeset
  1458
  RefPtr<Promise> promise = mSetConfigurationPromise.forget();
208669
05df8323b82079743e8af61b83625739bbadf905 Bug 994912 - Add support for promises and event-based notifications to camera. r=mikeh, r=bz
Andrew Osmond <aosmond@mozilla.com>
parents: 207338
diff changeset
  1459
  if (promise) {
05df8323b82079743e8af61b83625739bbadf905 Bug 994912 - Add support for promises and event-based notifications to camera. r=mikeh, r=bz
Andrew Osmond <aosmond@mozilla.com>
parents: 207338
diff changeset
  1460
    promise->MaybeResolve(*aConfiguration);
05df8323b82079743e8af61b83625739bbadf905 Bug 994912 - Add support for promises and event-based notifications to camera. r=mikeh, r=bz
Andrew Osmond <aosmond@mozilla.com>
parents: 207338
diff changeset
  1461
  }
05df8323b82079743e8af61b83625739bbadf905 Bug 994912 - Add support for promises and event-based notifications to camera. r=mikeh, r=bz
Andrew Osmond <aosmond@mozilla.com>
parents: 207338
diff changeset
  1462
05df8323b82079743e8af61b83625739bbadf905 Bug 994912 - Add support for promises and event-based notifications to camera. r=mikeh, r=bz
Andrew Osmond <aosmond@mozilla.com>
parents: 207338
diff changeset
  1463
  CameraConfigurationEventInit eventInit;
05df8323b82079743e8af61b83625739bbadf905 Bug 994912 - Add support for promises and event-based notifications to camera. r=mikeh, r=bz
Andrew Osmond <aosmond@mozilla.com>
parents: 207338
diff changeset
  1464
  eventInit.mMode = mCurrentConfiguration->mMode;
05df8323b82079743e8af61b83625739bbadf905 Bug 994912 - Add support for promises and event-based notifications to camera. r=mikeh, r=bz
Andrew Osmond <aosmond@mozilla.com>
parents: 207338
diff changeset
  1465
  eventInit.mRecorderProfile = mCurrentConfiguration->mRecorderProfile;
219510
220f9cd8097a7d7b395ab0419c6aa62ae25f7058 Bug 1104055 - fix CameraControl memory leak, r=aosmond
Mike Habicher <mikeh@mozilla.com>
parents: 219181
diff changeset
  1466
  eventInit.mPreviewSize = new DOMRect(static_cast<DOMMediaStream*>(this), 0, 0,
208669
05df8323b82079743e8af61b83625739bbadf905 Bug 994912 - Add support for promises and event-based notifications to camera. r=mikeh, r=bz
Andrew Osmond <aosmond@mozilla.com>
parents: 207338
diff changeset
  1467
                                       mCurrentConfiguration->mPreviewSize.mWidth,
05df8323b82079743e8af61b83625739bbadf905 Bug 994912 - Add support for promises and event-based notifications to camera. r=mikeh, r=bz
Andrew Osmond <aosmond@mozilla.com>
parents: 207338
diff changeset
  1468
                                       mCurrentConfiguration->mPreviewSize.mHeight);
220237
ce9707a48002c8fd80f1c921b13e8f6e40d54f43 Bug 1104913 - Update selection algorithms for preview, picture and video sizes to have sane defaults. r=mikeh, r=bz
Andrew Osmond <aosmond@gmail.com>
parents: 219511
diff changeset
  1469
  eventInit.mPictureSize = new DOMRect(static_cast<DOMMediaStream*>(this), 0, 0,
ce9707a48002c8fd80f1c921b13e8f6e40d54f43 Bug 1104913 - Update selection algorithms for preview, picture and video sizes to have sane defaults. r=mikeh, r=bz
Andrew Osmond <aosmond@gmail.com>
parents: 219511
diff changeset
  1470
                                       mCurrentConfiguration->mPictureSize.mWidth,
ce9707a48002c8fd80f1c921b13e8f6e40d54f43 Bug 1104913 - Update selection algorithms for preview, picture and video sizes to have sane defaults. r=mikeh, r=bz
Andrew Osmond <aosmond@gmail.com>
parents: 219511
diff changeset
  1471
                                       mCurrentConfiguration->mPictureSize.mHeight);
208669
05df8323b82079743e8af61b83625739bbadf905 Bug 994912 - Add support for promises and event-based notifications to camera. r=mikeh, r=bz
Andrew Osmond <aosmond@mozilla.com>
parents: 207338
diff changeset
  1472
268184
e8c7dfe727cd970e2c3294934e2927b14143c205 Bug 1207245 - part 6 - rename nsRefPtr<T> to RefPtr<T>; r=ehsan; a=Tomcat
Nathan Froyd <froydnj@mozilla.com>
parents: 266718
diff changeset
  1473
  RefPtr<CameraConfigurationEvent> event =
208669
05df8323b82079743e8af61b83625739bbadf905 Bug 994912 - Add support for promises and event-based notifications to camera. r=mikeh, r=bz
Andrew Osmond <aosmond@mozilla.com>
parents: 207338
diff changeset
  1474
    CameraConfigurationEvent::Constructor(this,
05df8323b82079743e8af61b83625739bbadf905 Bug 994912 - Add support for promises and event-based notifications to camera. r=mikeh, r=bz
Andrew Osmond <aosmond@mozilla.com>
parents: 207338
diff changeset
  1475
                                          NS_LITERAL_STRING("configurationchanged"),
05df8323b82079743e8af61b83625739bbadf905 Bug 994912 - Add support for promises and event-based notifications to camera. r=mikeh, r=bz
Andrew Osmond <aosmond@mozilla.com>
parents: 207338
diff changeset
  1476
                                          eventInit);
05df8323b82079743e8af61b83625739bbadf905 Bug 994912 - Add support for promises and event-based notifications to camera. r=mikeh, r=bz
Andrew Osmond <aosmond@mozilla.com>
parents: 207338
diff changeset
  1477
05df8323b82079743e8af61b83625739bbadf905 Bug 994912 - Add support for promises and event-based notifications to camera. r=mikeh, r=bz
Andrew Osmond <aosmond@mozilla.com>
parents: 207338
diff changeset
  1478
  DispatchTrustedEvent(event);
168993
e93e96ed8a5ad4999e272e2a3180a32e1ffdf94d Bug 909542 - refactor CameraControl API, r=dhylands,jst,jesup,onecyrenus
Mike Habicher <mikeh@mozilla.com>
parents: 168958
diff changeset
  1479
}
e93e96ed8a5ad4999e272e2a3180a32e1ffdf94d Bug 909542 - refactor CameraControl API, r=dhylands,jst,jesup,onecyrenus
Mike Habicher <mikeh@mozilla.com>
parents: 168958
diff changeset
  1480
e93e96ed8a5ad4999e272e2a3180a32e1ffdf94d Bug 909542 - refactor CameraControl API, r=dhylands,jst,jesup,onecyrenus
Mike Habicher <mikeh@mozilla.com>
parents: 168958
diff changeset
  1481
void
e93e96ed8a5ad4999e272e2a3180a32e1ffdf94d Bug 909542 - refactor CameraControl API, r=dhylands,jst,jesup,onecyrenus
Mike Habicher <mikeh@mozilla.com>
parents: 168958
diff changeset
  1482
nsDOMCameraControl::OnAutoFocusComplete(bool aAutoFocusSucceeded)
e93e96ed8a5ad4999e272e2a3180a32e1ffdf94d Bug 909542 - refactor CameraControl API, r=dhylands,jst,jesup,onecyrenus
Mike Habicher <mikeh@mozilla.com>
parents: 168958
diff changeset
  1483
{
219510
220f9cd8097a7d7b395ab0419c6aa62ae25f7058 Bug 1104055 - fix CameraControl memory leak, r=aosmond
Mike Habicher <mikeh@mozilla.com>
parents: 219181
diff changeset
  1484
  DOM_CAMERA_LOGT("%s:%d : this=%p\n", __func__, __LINE__, this);
168993
e93e96ed8a5ad4999e272e2a3180a32e1ffdf94d Bug 909542 - refactor CameraControl API, r=dhylands,jst,jesup,onecyrenus
Mike Habicher <mikeh@mozilla.com>
parents: 168958
diff changeset
  1485
  MOZ_ASSERT(NS_IsMainThread());
e93e96ed8a5ad4999e272e2a3180a32e1ffdf94d Bug 909542 - refactor CameraControl API, r=dhylands,jst,jesup,onecyrenus
Mike Habicher <mikeh@mozilla.com>
parents: 168958
diff changeset
  1486
268184
e8c7dfe727cd970e2c3294934e2927b14143c205 Bug 1207245 - part 6 - rename nsRefPtr<T> to RefPtr<T>; r=ehsan; a=Tomcat
Nathan Froyd <froydnj@mozilla.com>
parents: 266718
diff changeset
  1487
  RefPtr<Promise> promise = mAutoFocusPromise.forget();
208669
05df8323b82079743e8af61b83625739bbadf905 Bug 994912 - Add support for promises and event-based notifications to camera. r=mikeh, r=bz
Andrew Osmond <aosmond@mozilla.com>
parents: 207338
diff changeset
  1488
  if (promise) {
05df8323b82079743e8af61b83625739bbadf905 Bug 994912 - Add support for promises and event-based notifications to camera. r=mikeh, r=bz
Andrew Osmond <aosmond@mozilla.com>
parents: 207338
diff changeset
  1489
    promise->MaybeResolve(aAutoFocusSucceeded);
05df8323b82079743e8af61b83625739bbadf905 Bug 994912 - Add support for promises and event-based notifications to camera. r=mikeh, r=bz
Andrew Osmond <aosmond@mozilla.com>
parents: 207338
diff changeset
  1490
  }
05df8323b82079743e8af61b83625739bbadf905 Bug 994912 - Add support for promises and event-based notifications to camera. r=mikeh, r=bz
Andrew Osmond <aosmond@mozilla.com>
parents: 207338
diff changeset
  1491
05df8323b82079743e8af61b83625739bbadf905 Bug 994912 - Add support for promises and event-based notifications to camera. r=mikeh, r=bz
Andrew Osmond <aosmond@mozilla.com>
parents: 207338
diff changeset
  1492
  if (aAutoFocusSucceeded) {
05df8323b82079743e8af61b83625739bbadf905 Bug 994912 - Add support for promises and event-based notifications to camera. r=mikeh, r=bz
Andrew Osmond <aosmond@mozilla.com>
parents: 207338
diff changeset
  1493
    DispatchStateEvent(NS_LITERAL_STRING("focus"), NS_LITERAL_STRING("focused"));
05df8323b82079743e8af61b83625739bbadf905 Bug 994912 - Add support for promises and event-based notifications to camera. r=mikeh, r=bz
Andrew Osmond <aosmond@mozilla.com>
parents: 207338
diff changeset
  1494
  } else {
05df8323b82079743e8af61b83625739bbadf905 Bug 994912 - Add support for promises and event-based notifications to camera. r=mikeh, r=bz
Andrew Osmond <aosmond@mozilla.com>
parents: 207338
diff changeset
  1495
    DispatchStateEvent(NS_LITERAL_STRING("focus"), NS_LITERAL_STRING("unfocused"));
05df8323b82079743e8af61b83625739bbadf905 Bug 994912 - Add support for promises and event-based notifications to camera. r=mikeh, r=bz
Andrew Osmond <aosmond@mozilla.com>
parents: 207338
diff changeset
  1496
  }
168993
e93e96ed8a5ad4999e272e2a3180a32e1ffdf94d Bug 909542 - refactor CameraControl API, r=dhylands,jst,jesup,onecyrenus
Mike Habicher <mikeh@mozilla.com>
parents: 168958
diff changeset
  1497
}
e93e96ed8a5ad4999e272e2a3180a32e1ffdf94d Bug 909542 - refactor CameraControl API, r=dhylands,jst,jesup,onecyrenus
Mike Habicher <mikeh@mozilla.com>
parents: 168958
diff changeset
  1498
e93e96ed8a5ad4999e272e2a3180a32e1ffdf94d Bug 909542 - refactor CameraControl API, r=dhylands,jst,jesup,onecyrenus
Mike Habicher <mikeh@mozilla.com>
parents: 168958
diff changeset
  1499
void
177873
3f481b3c3e7120b8c2a708b9b477f7180c23d356 Bug 965421 - camera continuous autofocus status callback, r=jst,mikeh
Youngwoo Jo <hiro7998@gmail.com>
parents: 177628
diff changeset
  1500
nsDOMCameraControl::OnAutoFocusMoving(bool aIsMoving)
3f481b3c3e7120b8c2a708b9b477f7180c23d356 Bug 965421 - camera continuous autofocus status callback, r=jst,mikeh
Youngwoo Jo <hiro7998@gmail.com>
parents: 177628
diff changeset
  1501
{
219510
220f9cd8097a7d7b395ab0419c6aa62ae25f7058 Bug 1104055 - fix CameraControl memory leak, r=aosmond
Mike Habicher <mikeh@mozilla.com>
parents: 219181
diff changeset
  1502
  DOM_CAMERA_LOGT("%s:%d : this=%p\n", __func__, __LINE__, this);
177873
3f481b3c3e7120b8c2a708b9b477f7180c23d356 Bug 965421 - camera continuous autofocus status callback, r=jst,mikeh
Youngwoo Jo <hiro7998@gmail.com>
parents: 177628
diff changeset
  1503
  MOZ_ASSERT(NS_IsMainThread());
3f481b3c3e7120b8c2a708b9b477f7180c23d356 Bug 965421 - camera continuous autofocus status callback, r=jst,mikeh
Youngwoo Jo <hiro7998@gmail.com>
parents: 177628
diff changeset
  1504
208669
05df8323b82079743e8af61b83625739bbadf905 Bug 994912 - Add support for promises and event-based notifications to camera. r=mikeh, r=bz
Andrew Osmond <aosmond@mozilla.com>
parents: 207338
diff changeset
  1505
  if (aIsMoving) {
05df8323b82079743e8af61b83625739bbadf905 Bug 994912 - Add support for promises and event-based notifications to camera. r=mikeh, r=bz
Andrew Osmond <aosmond@mozilla.com>
parents: 207338
diff changeset
  1506
    DispatchStateEvent(NS_LITERAL_STRING("focus"), NS_LITERAL_STRING("focusing"));
05df8323b82079743e8af61b83625739bbadf905 Bug 994912 - Add support for promises and event-based notifications to camera. r=mikeh, r=bz
Andrew Osmond <aosmond@mozilla.com>
parents: 207338
diff changeset
  1507
  }
177873
3f481b3c3e7120b8c2a708b9b477f7180c23d356 Bug 965421 - camera continuous autofocus status callback, r=jst,mikeh
Youngwoo Jo <hiro7998@gmail.com>
parents: 177628
diff changeset
  1508
}
3f481b3c3e7120b8c2a708b9b477f7180c23d356 Bug 965421 - camera continuous autofocus status callback, r=jst,mikeh
Youngwoo Jo <hiro7998@gmail.com>
parents: 177628
diff changeset
  1509
3f481b3c3e7120b8c2a708b9b477f7180c23d356 Bug 965421 - camera continuous autofocus status callback, r=jst,mikeh
Youngwoo Jo <hiro7998@gmail.com>
parents: 177628
diff changeset
  1510
void
177874
e6ac52f874d097648fcf91fd2db247af3a297d6b Bug 965420 - camera face-tracking, r=bz,dhylands
Mike Habicher <mikeh@mozilla.com>
parents: 177873
diff changeset
  1511
nsDOMCameraControl::OnFacesDetected(const nsTArray<ICameraControl::Face>& aFaces)
e6ac52f874d097648fcf91fd2db247af3a297d6b Bug 965420 - camera face-tracking, r=bz,dhylands
Mike Habicher <mikeh@mozilla.com>
parents: 177873
diff changeset
  1512
{
213736
95be75403d706081b8508b91f6e60c7846af125d Bug 1020368 - remove direct JS_*() calls from CameraRecorderProfiles, r=aosmond,bz
Mike Habicher <mikeh@mozilla.com>
parents: 213549
diff changeset
  1513
  DOM_CAMERA_LOGI("DOM OnFacesDetected %zu face(s)\n", aFaces.Length());
177874
e6ac52f874d097648fcf91fd2db247af3a297d6b Bug 965420 - camera face-tracking, r=bz,dhylands
Mike Habicher <mikeh@mozilla.com>
parents: 177873
diff changeset
  1514
  MOZ_ASSERT(NS_IsMainThread());
e6ac52f874d097648fcf91fd2db247af3a297d6b Bug 965420 - camera face-tracking, r=bz,dhylands
Mike Habicher <mikeh@mozilla.com>
parents: 177873
diff changeset
  1515
e6ac52f874d097648fcf91fd2db247af3a297d6b Bug 965420 - camera face-tracking, r=bz,dhylands
Mike Habicher <mikeh@mozilla.com>
parents: 177873
diff changeset
  1516
  Sequence<OwningNonNull<DOMCameraDetectedFace> > faces;
e6ac52f874d097648fcf91fd2db247af3a297d6b Bug 965420 - camera face-tracking, r=bz,dhylands
Mike Habicher <mikeh@mozilla.com>
parents: 177873
diff changeset
  1517
  uint32_t len = aFaces.Length();
e6ac52f874d097648fcf91fd2db247af3a297d6b Bug 965420 - camera face-tracking, r=bz,dhylands
Mike Habicher <mikeh@mozilla.com>
parents: 177873
diff changeset
  1518
244447
b589dae2c2930a5fefb9ed5cb4df7232e3e8251b Bug 968520 - Add mozilla::fallible to Fallible{Auto,}TArray::SetCapacity calls. r=froydnj
Birunthan Mohanathas <birunthan@mohanathas.com>
parents: 243535
diff changeset
  1519
  if (faces.SetCapacity(len, fallible)) {
177874
e6ac52f874d097648fcf91fd2db247af3a297d6b Bug 965420 - camera face-tracking, r=bz,dhylands
Mike Habicher <mikeh@mozilla.com>
parents: 177873
diff changeset
  1520
    for (uint32_t i = 0; i < len; ++i) {
246193
2e84ad186322885a3cef208e5a3ebaa2235be7e6 Bug 968520 - Add mozilla::fallible to FallibleTArray::AppendElement calls. r=froydnj
Birunthan Mohanathas <birunthan@mohanathas.com>
parents: 244447
diff changeset
  1521
      *faces.AppendElement(fallible) =
239558
7a458d7e3e4f9e8a91b6c48445c12acd4abebaf4 Bug 1139721 - Fix camera memory leaks for onfacedetected events, failed initializations and capabilities. r=mikeh
Andrew Osmond <aosmond@mozilla.com>
parents: 234479
diff changeset
  1522
        new DOMCameraDetectedFace(static_cast<DOMMediaStream*>(this), aFaces[i]);
177874
e6ac52f874d097648fcf91fd2db247af3a297d6b Bug 965420 - camera face-tracking, r=bz,dhylands
Mike Habicher <mikeh@mozilla.com>
parents: 177873
diff changeset
  1523
    }
e6ac52f874d097648fcf91fd2db247af3a297d6b Bug 965420 - camera face-tracking, r=bz,dhylands
Mike Habicher <mikeh@mozilla.com>
parents: 177873
diff changeset
  1524
  }
e6ac52f874d097648fcf91fd2db247af3a297d6b Bug 965420 - camera face-tracking, r=bz,dhylands
Mike Habicher <mikeh@mozilla.com>
parents: 177873
diff changeset
  1525
208669
05df8323b82079743e8af61b83625739bbadf905 Bug 994912 - Add support for promises and event-based notifications to camera. r=mikeh, r=bz
Andrew Osmond <aosmond@mozilla.com>
parents: 207338
diff changeset
  1526
  CameraFacesDetectedEventInit eventInit;
05df8323b82079743e8af61b83625739bbadf905 Bug 994912 - Add support for promises and event-based notifications to camera. r=mikeh, r=bz
Andrew Osmond <aosmond@mozilla.com>
parents: 207338
diff changeset
  1527
  eventInit.mFaces.SetValue(faces);
05df8323b82079743e8af61b83625739bbadf905 Bug 994912 - Add support for promises and event-based notifications to camera. r=mikeh, r=bz
Andrew Osmond <aosmond@mozilla.com>
parents: 207338
diff changeset
  1528
268184
e8c7dfe727cd970e2c3294934e2927b14143c205 Bug 1207245 - part 6 - rename nsRefPtr<T> to RefPtr<T>; r=ehsan; a=Tomcat
Nathan Froyd <froydnj@mozilla.com>
parents: 266718
diff changeset
  1529
  RefPtr<CameraFacesDetectedEvent> event =
208669
05df8323b82079743e8af61b83625739bbadf905 Bug 994912 - Add support for promises and event-based notifications to camera. r=mikeh, r=bz
Andrew Osmond <aosmond@mozilla.com>
parents: 207338
diff changeset
  1530
    CameraFacesDetectedEvent::Constructor(this,
05df8323b82079743e8af61b83625739bbadf905 Bug 994912 - Add support for promises and event-based notifications to camera. r=mikeh, r=bz
Andrew Osmond <aosmond@mozilla.com>
parents: 207338
diff changeset
  1531
                                          NS_LITERAL_STRING("facesdetected"),
05df8323b82079743e8af61b83625739bbadf905 Bug 994912 - Add support for promises and event-based notifications to camera. r=mikeh, r=bz
Andrew Osmond <aosmond@mozilla.com>
parents: 207338
diff changeset
  1532
                                          eventInit);
05df8323b82079743e8af61b83625739bbadf905 Bug 994912 - Add support for promises and event-based notifications to camera. r=mikeh, r=bz
Andrew Osmond <aosmond@mozilla.com>
parents: 207338
diff changeset
  1533
05df8323b82079743e8af61b83625739bbadf905 Bug 994912 - Add support for promises and event-based notifications to camera. r=mikeh, r=bz
Andrew Osmond <aosmond@mozilla.com>
parents: 207338
diff changeset
  1534
  DispatchTrustedEvent(event);
177874
e6ac52f874d097648fcf91fd2db247af3a297d6b Bug 965420 - camera face-tracking, r=bz,dhylands
Mike Habicher <mikeh@mozilla.com>
parents: 177873
diff changeset
  1535
}
e6ac52f874d097648fcf91fd2db247af3a297d6b Bug 965420 - camera face-tracking, r=bz,dhylands
Mike Habicher <mikeh@mozilla.com>
parents: 177873
diff changeset
  1536
e6ac52f874d097648fcf91fd2db247af3a297d6b Bug 965420 - camera face-tracking, r=bz,dhylands
Mike Habicher <mikeh@mozilla.com>
parents: 177873
diff changeset
  1537
void
168993
e93e96ed8a5ad4999e272e2a3180a32e1ffdf94d Bug 909542 - refactor CameraControl API, r=dhylands,jst,jesup,onecyrenus
Mike Habicher <mikeh@mozilla.com>
parents: 168958
diff changeset
  1538
nsDOMCameraControl::OnTakePictureComplete(nsIDOMBlob* aPicture)
e93e96ed8a5ad4999e272e2a3180a32e1ffdf94d Bug 909542 - refactor CameraControl API, r=dhylands,jst,jesup,onecyrenus
Mike Habicher <mikeh@mozilla.com>
parents: 168958
diff changeset
  1539
{
219510
220f9cd8097a7d7b395ab0419c6aa62ae25f7058 Bug 1104055 - fix CameraControl memory leak, r=aosmond
Mike Habicher <mikeh@mozilla.com>
parents: 219181
diff changeset
  1540
  DOM_CAMERA_LOGT("%s:%d : this=%p\n", __func__, __LINE__, this);
168993
e93e96ed8a5ad4999e272e2a3180a32e1ffdf94d Bug 909542 - refactor CameraControl API, r=dhylands,jst,jesup,onecyrenus
Mike Habicher <mikeh@mozilla.com>
parents: 168958
diff changeset
  1541
  MOZ_ASSERT(NS_IsMainThread());
209364
53a14a9129608b450da3e2b45c863f2e5ad79be6 Bug 1047483 - patch 1 - Porting DOMFile/DOMBlob to WebIDL, r=bz, r=bkelly, r=bholley
Andrea Marchesini <amarchesini@mozilla.com>
parents: 209196
diff changeset
  1542
  MOZ_ASSERT(aPicture);
208669
05df8323b82079743e8af61b83625739bbadf905 Bug 994912 - Add support for promises and event-based notifications to camera. r=mikeh, r=bz
Andrew Osmond <aosmond@mozilla.com>
parents: 207338
diff changeset
  1543
268184
e8c7dfe727cd970e2c3294934e2927b14143c205 Bug 1207245 - part 6 - rename nsRefPtr<T> to RefPtr<T>; r=ehsan; a=Tomcat
Nathan Froyd <froydnj@mozilla.com>
parents: 266718
diff changeset
  1544
  RefPtr<Promise> promise = mTakePicturePromise.forget();
208669
05df8323b82079743e8af61b83625739bbadf905 Bug 994912 - Add support for promises and event-based notifications to camera. r=mikeh, r=bz
Andrew Osmond <aosmond@mozilla.com>
parents: 207338
diff changeset
  1545
  if (promise) {
05df8323b82079743e8af61b83625739bbadf905 Bug 994912 - Add support for promises and event-based notifications to camera. r=mikeh, r=bz
Andrew Osmond <aosmond@mozilla.com>
parents: 207338
diff changeset
  1546
    nsCOMPtr<nsIDOMBlob> picture = aPicture;
05df8323b82079743e8af61b83625739bbadf905 Bug 994912 - Add support for promises and event-based notifications to camera. r=mikeh, r=bz
Andrew Osmond <aosmond@mozilla.com>
parents: 207338
diff changeset
  1547
    promise->MaybeResolve(picture);
05df8323b82079743e8af61b83625739bbadf905 Bug 994912 - Add support for promises and event-based notifications to camera. r=mikeh, r=bz
Andrew Osmond <aosmond@mozilla.com>
parents: 207338
diff changeset
  1548
  }
168993
e93e96ed8a5ad4999e272e2a3180a32e1ffdf94d Bug 909542 - refactor CameraControl API, r=dhylands,jst,jesup,onecyrenus
Mike Habicher <mikeh@mozilla.com>
parents: 168958
diff changeset
  1549
268184
e8c7dfe727cd970e2c3294934e2927b14143c205 Bug 1207245 - part 6 - rename nsRefPtr<T> to RefPtr<T>; r=ehsan; a=Tomcat
Nathan Froyd <froydnj@mozilla.com>
parents: 266718
diff changeset
  1550
  RefPtr<Blob> blob = static_cast<Blob*>(aPicture);
208669
05df8323b82079743e8af61b83625739bbadf905 Bug 994912 - Add support for promises and event-based notifications to camera. r=mikeh, r=bz
Andrew Osmond <aosmond@mozilla.com>
parents: 207338
diff changeset
  1551
  BlobEventInit eventInit;
209364
53a14a9129608b450da3e2b45c863f2e5ad79be6 Bug 1047483 - patch 1 - Porting DOMFile/DOMBlob to WebIDL, r=bz, r=bkelly, r=bholley
Andrea Marchesini <amarchesini@mozilla.com>
parents: 209196
diff changeset
  1552
  eventInit.mData = blob;
208669
05df8323b82079743e8af61b83625739bbadf905 Bug 994912 - Add support for promises and event-based notifications to camera. r=mikeh, r=bz
Andrew Osmond <aosmond@mozilla.com>
parents: 207338
diff changeset
  1553
268184
e8c7dfe727cd970e2c3294934e2927b14143c205 Bug 1207245 - part 6 - rename nsRefPtr<T> to RefPtr<T>; r=ehsan; a=Tomcat
Nathan Froyd <froydnj@mozilla.com>
parents: 266718
diff changeset
  1554
  RefPtr<BlobEvent> event = BlobEvent::Constructor(this,
208669
05df8323b82079743e8af61b83625739bbadf905 Bug 994912 - Add support for promises and event-based notifications to camera. r=mikeh, r=bz
Andrew Osmond <aosmond@mozilla.com>
parents: 207338
diff changeset
  1555
                                                     NS_LITERAL_STRING("picture"),
05df8323b82079743e8af61b83625739bbadf905 Bug 994912 - Add support for promises and event-based notifications to camera. r=mikeh, r=bz
Andrew Osmond <aosmond@mozilla.com>
parents: 207338
diff changeset
  1556
                                                     eventInit);
05df8323b82079743e8af61b83625739bbadf905 Bug 994912 - Add support for promises and event-based notifications to camera. r=mikeh, r=bz
Andrew Osmond <aosmond@mozilla.com>
parents: 207338
diff changeset
  1557
05df8323b82079743e8af61b83625739bbadf905 Bug 994912 - Add support for promises and event-based notifications to camera. r=mikeh, r=bz
Andrew Osmond <aosmond@mozilla.com>
parents: 207338
diff changeset
  1558
  DispatchTrustedEvent(event);
168993
e93e96ed8a5ad4999e272e2a3180a32e1ffdf94d Bug 909542 - refactor CameraControl API, r=dhylands,jst,jesup,onecyrenus
Mike Habicher <mikeh@mozilla.com>
parents: 168958
diff changeset
  1559
}
e93e96ed8a5ad4999e272e2a3180a32e1ffdf94d Bug 909542 - refactor CameraControl API, r=dhylands,jst,jesup,onecyrenus
Mike Habicher <mikeh@mozilla.com>
parents: 168958
diff changeset
  1560
e93e96ed8a5ad4999e272e2a3180a32e1ffdf94d Bug 909542 - refactor CameraControl API, r=dhylands,jst,jesup,onecyrenus
Mike Habicher <mikeh@mozilla.com>
parents: 168958
diff changeset
  1561
void
180888
c26966635e9c0c028e4360f2175563f9ef62df80 Bug 985496 - rationalize camera error reporting, r=dhylands
Mike Habicher <mikeh@mozilla.com>
parents: 180485
diff changeset
  1562
nsDOMCameraControl::OnUserError(CameraControlListener::UserContext aContext, nsresult aError)
168993
e93e96ed8a5ad4999e272e2a3180a32e1ffdf94d Bug 909542 - refactor CameraControl API, r=dhylands,jst,jesup,onecyrenus
Mike Habicher <mikeh@mozilla.com>
parents: 168958
diff changeset
  1563
{
249187
9ba890d2ba081ceea82be94530b3fafffa51b766 Bug 1152500 - Fix how stop recording may be handled out-of-order. r=dhylands
Andrew Osmond <aosmond@mozilla.com>
parents: 246249
diff changeset
  1564
  DOM_CAMERA_LOGI("DOM OnUserError : this=%p, aContext=%u, aError=0x%x\n",
219510
220f9cd8097a7d7b395ab0419c6aa62ae25f7058 Bug 1104055 - fix CameraControl memory leak, r=aosmond
Mike Habicher <mikeh@mozilla.com>
parents: 219181
diff changeset
  1565
    this, aContext, aError);
168993
e93e96ed8a5ad4999e272e2a3180a32e1ffdf94d Bug 909542 - refactor CameraControl API, r=dhylands,jst,jesup,onecyrenus
Mike Habicher <mikeh@mozilla.com>
parents: 168958
diff changeset
  1566
  MOZ_ASSERT(NS_IsMainThread());
e93e96ed8a5ad4999e272e2a3180a32e1ffdf94d Bug 909542 - refactor CameraControl API, r=dhylands,jst,jesup,onecyrenus
Mike Habicher <mikeh@mozilla.com>
parents: 168958
diff changeset
  1567
268184
e8c7dfe727cd970e2c3294934e2927b14143c205 Bug 1207245 - part 6 - rename nsRefPtr<T> to RefPtr<T>; r=ehsan; a=Tomcat
Nathan Froyd <froydnj@mozilla.com>
parents: 266718
diff changeset
  1568
  RefPtr<Promise> promise;
175153
7d1c71bfc76ab804934edbbc013630836105fb37 Bug 985125 - remove unnecessary indirection from DOM error handler, r=dhylands
Mike Habicher <mikeh@mozilla.com>
parents: 173981
diff changeset
  1569
168993
e93e96ed8a5ad4999e272e2a3180a32e1ffdf94d Bug 909542 - refactor CameraControl API, r=dhylands,jst,jesup,onecyrenus
Mike Habicher <mikeh@mozilla.com>
parents: 168958
diff changeset
  1570
  switch (aContext) {
169639
4ab6a5b763d8221dd2a189b106bba60b202fd6c2 Bug 940424 - add a failable test shim to the Gonk hardware wrapper, r=dclarke,dhylands,jesup
Mike Habicher <mikeh@mozilla.com>
parents: 168993
diff changeset
  1571
    case CameraControlListener::kInStartCamera:
208669
05df8323b82079743e8af61b83625739bbadf905 Bug 994912 - Add support for promises and event-based notifications to camera. r=mikeh, r=bz
Andrew Osmond <aosmond@mozilla.com>
parents: 207338
diff changeset
  1572
      promise = mGetCameraPromise.forget();
239558
7a458d7e3e4f9e8a91b6c48445c12acd4abebaf4 Bug 1139721 - Fix camera memory leaks for onfacedetected events, failed initializations and capabilities. r=mikeh
Andrew Osmond <aosmond@mozilla.com>
parents: 234479
diff changeset
  1573
      // If we failed to open the camera, we never actually provided a reference
7a458d7e3e4f9e8a91b6c48445c12acd4abebaf4 Bug 1139721 - Fix camera memory leaks for onfacedetected events, failed initializations and capabilities. r=mikeh
Andrew Osmond <aosmond@mozilla.com>
parents: 234479
diff changeset
  1574
      // for the application to release explicitly. Thus we must clear our handle
7a458d7e3e4f9e8a91b6c48445c12acd4abebaf4 Bug 1139721 - Fix camera memory leaks for onfacedetected events, failed initializations and capabilities. r=mikeh
Andrew Osmond <aosmond@mozilla.com>
parents: 234479
diff changeset
  1575
      // here to ensure everything is freed.
7a458d7e3e4f9e8a91b6c48445c12acd4abebaf4 Bug 1139721 - Fix camera memory leaks for onfacedetected events, failed initializations and capabilities. r=mikeh
Andrew Osmond <aosmond@mozilla.com>
parents: 234479
diff changeset
  1576
      mCameraControl = nullptr;
168993
e93e96ed8a5ad4999e272e2a3180a32e1ffdf94d Bug 909542 - refactor CameraControl API, r=dhylands,jst,jesup,onecyrenus
Mike Habicher <mikeh@mozilla.com>
parents: 168958
diff changeset
  1577
      break;
e93e96ed8a5ad4999e272e2a3180a32e1ffdf94d Bug 909542 - refactor CameraControl API, r=dhylands,jst,jesup,onecyrenus
Mike Habicher <mikeh@mozilla.com>
parents: 168958
diff changeset
  1578
169639
4ab6a5b763d8221dd2a189b106bba60b202fd6c2 Bug 940424 - add a failable test shim to the Gonk hardware wrapper, r=dclarke,dhylands,jesup
Mike Habicher <mikeh@mozilla.com>
parents: 168993
diff changeset
  1579
    case CameraControlListener::kInStopCamera:
208669
05df8323b82079743e8af61b83625739bbadf905 Bug 994912 - Add support for promises and event-based notifications to camera. r=mikeh, r=bz
Andrew Osmond <aosmond@mozilla.com>
parents: 207338
diff changeset
  1580
      promise = mReleasePromise.forget();
217490
63b54f5f6877f71d1549c5436691ec25e6ce2a8e Bug 1099390 - add reason to onClosed event, r=aosmond,bz
Mike Habicher <mikeh@mozilla.com>
parents: 215389
diff changeset
  1581
      if (aError == NS_ERROR_NOT_INITIALIZED) {
63b54f5f6877f71d1549c5436691ec25e6ce2a8e Bug 1099390 - add reason to onClosed event, r=aosmond,bz
Mike Habicher <mikeh@mozilla.com>
parents: 215389
diff changeset
  1582
        // This value indicates that the hardware is already closed; which for
63b54f5f6877f71d1549c5436691ec25e6ce2a8e Bug 1099390 - add reason to onClosed event, r=aosmond,bz
Mike Habicher <mikeh@mozilla.com>
parents: 215389
diff changeset
  1583
        // kInStopCamera, is not actually an error.
63b54f5f6877f71d1549c5436691ec25e6ce2a8e Bug 1099390 - add reason to onClosed event, r=aosmond,bz
Mike Habicher <mikeh@mozilla.com>
parents: 215389
diff changeset
  1584
        if (promise) {
63b54f5f6877f71d1549c5436691ec25e6ce2a8e Bug 1099390 - add reason to onClosed event, r=aosmond,bz
Mike Habicher <mikeh@mozilla.com>
parents: 215389
diff changeset
  1585
          promise->MaybeResolve(JS::UndefinedHandleValue);
63b54f5f6877f71d1549c5436691ec25e6ce2a8e Bug 1099390 - add reason to onClosed event, r=aosmond,bz
Mike Habicher <mikeh@mozilla.com>
parents: 215389
diff changeset
  1586
        }
63b54f5f6877f71d1549c5436691ec25e6ce2a8e Bug 1099390 - add reason to onClosed event, r=aosmond,bz
Mike Habicher <mikeh@mozilla.com>
parents: 215389
diff changeset
  1587
63b54f5f6877f71d1549c5436691ec25e6ce2a8e Bug 1099390 - add reason to onClosed event, r=aosmond,bz
Mike Habicher <mikeh@mozilla.com>
parents: 215389
diff changeset
  1588
        return;
63b54f5f6877f71d1549c5436691ec25e6ce2a8e Bug 1099390 - add reason to onClosed event, r=aosmond,bz
Mike Habicher <mikeh@mozilla.com>
parents: 215389
diff changeset
  1589
      }
169639
4ab6a5b763d8221dd2a189b106bba60b202fd6c2 Bug 940424 - add a failable test shim to the Gonk hardware wrapper, r=dclarke,dhylands,jesup
Mike Habicher <mikeh@mozilla.com>
parents: 168993
diff changeset
  1590
      break;
4ab6a5b763d8221dd2a189b106bba60b202fd6c2 Bug 940424 - add a failable test shim to the Gonk hardware wrapper, r=dclarke,dhylands,jesup
Mike Habicher <mikeh@mozilla.com>
parents: 168993
diff changeset
  1591
168993
e93e96ed8a5ad4999e272e2a3180a32e1ffdf94d Bug 909542 - refactor CameraControl API, r=dhylands,jst,jesup,onecyrenus
Mike Habicher <mikeh@mozilla.com>
parents: 168958
diff changeset
  1592
    case CameraControlListener::kInSetConfiguration:
243102
2f8b7d236713cfd93f76434bfc52f9eee5004a75 Bug 1158378 - Fix how a failed set configuration call would try to shutdown the camera after release.
Andrew Osmond <aosmond@mozilla.com>
parents: 239875
diff changeset
  1593
      if (mSetInitialConfig && mCameraControl) {
220237
ce9707a48002c8fd80f1c921b13e8f6e40d54f43 Bug 1104913 - Update selection algorithms for preview, picture and video sizes to have sane defaults. r=mikeh, r=bz
Andrew Osmond <aosmond@gmail.com>
parents: 219511
diff changeset
  1594
        // If the SetConfiguration() call in the constructor fails, there
ce9707a48002c8fd80f1c921b13e8f6e40d54f43 Bug 1104913 - Update selection algorithms for preview, picture and video sizes to have sane defaults. r=mikeh, r=bz
Andrew Osmond <aosmond@gmail.com>
parents: 219511
diff changeset
  1595
        // is nothing we can do except release the camera hardware. This
ce9707a48002c8fd80f1c921b13e8f6e40d54f43 Bug 1104913 - Update selection algorithms for preview, picture and video sizes to have sane defaults. r=mikeh, r=bz
Andrew Osmond <aosmond@gmail.com>
parents: 219511
diff changeset
  1596
        // will trigger a hardware state change, and when the flag that
ce9707a48002c8fd80f1c921b13e8f6e40d54f43 Bug 1104913 - Update selection algorithms for preview, picture and video sizes to have sane defaults. r=mikeh, r=bz
Andrew Osmond <aosmond@gmail.com>
parents: 219511
diff changeset
  1597
        // got us here is set in that handler, we replace the normal reason
ce9707a48002c8fd80f1c921b13e8f6e40d54f43 Bug 1104913 - Update selection algorithms for preview, picture and video sizes to have sane defaults. r=mikeh, r=bz
Andrew Osmond <aosmond@gmail.com>
parents: 219511
diff changeset
  1598
        // code with one that indicates the hardware isn't available.
ce9707a48002c8fd80f1c921b13e8f6e40d54f43 Bug 1104913 - Update selection algorithms for preview, picture and video sizes to have sane defaults. r=mikeh, r=bz
Andrew Osmond <aosmond@gmail.com>
parents: 219511
diff changeset
  1599
        DOM_CAMERA_LOGI("Failed to configure cached camera, stopping\n");
ce9707a48002c8fd80f1c921b13e8f6e40d54f43 Bug 1104913 - Update selection algorithms for preview, picture and video sizes to have sane defaults. r=mikeh, r=bz
Andrew Osmond <aosmond@gmail.com>
parents: 219511
diff changeset
  1600
        mCameraControl->Stop();
ce9707a48002c8fd80f1c921b13e8f6e40d54f43 Bug 1104913 - Update selection algorithms for preview, picture and video sizes to have sane defaults. r=mikeh, r=bz
Andrew Osmond <aosmond@gmail.com>
parents: 219511
diff changeset
  1601
        return;
ce9707a48002c8fd80f1c921b13e8f6e40d54f43 Bug 1104913 - Update selection algorithms for preview, picture and video sizes to have sane defaults. r=mikeh, r=bz
Andrew Osmond <aosmond@gmail.com>
parents: 219511
diff changeset
  1602
      }
208669
05df8323b82079743e8af61b83625739bbadf905 Bug 994912 - Add support for promises and event-based notifications to camera. r=mikeh, r=bz
Andrew Osmond <aosmond@mozilla.com>
parents: 207338
diff changeset
  1603
      promise = mSetConfigurationPromise.forget();
168993
e93e96ed8a5ad4999e272e2a3180a32e1ffdf94d Bug 909542 - refactor CameraControl API, r=dhylands,jst,jesup,onecyrenus
Mike Habicher <mikeh@mozilla.com>
parents: 168958
diff changeset
  1604
      break;
e93e96ed8a5ad4999e272e2a3180a32e1ffdf94d Bug 909542 - refactor CameraControl API, r=dhylands,jst,jesup,onecyrenus
Mike Habicher <mikeh@mozilla.com>
parents: 168958
diff changeset
  1605
e93e96ed8a5ad4999e272e2a3180a32e1ffdf94d Bug 909542 - refactor CameraControl API, r=dhylands,jst,jesup,onecyrenus
Mike Habicher <mikeh@mozilla.com>
parents: 168958
diff changeset
  1606
    case CameraControlListener::kInAutoFocus:
208669
05df8323b82079743e8af61b83625739bbadf905 Bug 994912 - Add support for promises and event-based notifications to camera. r=mikeh, r=bz
Andrew Osmond <aosmond@mozilla.com>
parents: 207338
diff changeset
  1607
      promise = mAutoFocusPromise.forget();
05df8323b82079743e8af61b83625739bbadf905 Bug 994912 - Add support for promises and event-based notifications to camera. r=mikeh, r=bz
Andrew Osmond <aosmond@mozilla.com>
parents: 207338
diff changeset
  1608
      DispatchStateEvent(NS_LITERAL_STRING("focus"), NS_LITERAL_STRING("unfocused"));
168993
e93e96ed8a5ad4999e272e2a3180a32e1ffdf94d Bug 909542 - refactor CameraControl API, r=dhylands,jst,jesup,onecyrenus
Mike Habicher <mikeh@mozilla.com>
parents: 168958
diff changeset
  1609
      break;
e93e96ed8a5ad4999e272e2a3180a32e1ffdf94d Bug 909542 - refactor CameraControl API, r=dhylands,jst,jesup,onecyrenus
Mike Habicher <mikeh@mozilla.com>
parents: 168958
diff changeset
  1610
e93e96ed8a5ad4999e272e2a3180a32e1ffdf94d Bug 909542 - refactor CameraControl API, r=dhylands,jst,jesup,onecyrenus
Mike Habicher <mikeh@mozilla.com>
parents: 168958
diff changeset
  1611
    case CameraControlListener::kInTakePicture:
208669
05df8323b82079743e8af61b83625739bbadf905 Bug 994912 - Add support for promises and event-based notifications to camera. r=mikeh, r=bz
Andrew Osmond <aosmond@mozilla.com>
parents: 207338
diff changeset
  1612
      promise = mTakePicturePromise.forget();
168993
e93e96ed8a5ad4999e272e2a3180a32e1ffdf94d Bug 909542 - refactor CameraControl API, r=dhylands,jst,jesup,onecyrenus
Mike Habicher <mikeh@mozilla.com>
parents: 168958
diff changeset
  1613
      break;
e93e96ed8a5ad4999e272e2a3180a32e1ffdf94d Bug 909542 - refactor CameraControl API, r=dhylands,jst,jesup,onecyrenus
Mike Habicher <mikeh@mozilla.com>
parents: 168958
diff changeset
  1614
e93e96ed8a5ad4999e272e2a3180a32e1ffdf94d Bug 909542 - refactor CameraControl API, r=dhylands,jst,jesup,onecyrenus
Mike Habicher <mikeh@mozilla.com>
parents: 168958
diff changeset
  1615
    case CameraControlListener::kInStartRecording:
208669
05df8323b82079743e8af61b83625739bbadf905 Bug 994912 - Add support for promises and event-based notifications to camera. r=mikeh, r=bz
Andrew Osmond <aosmond@mozilla.com>
parents: 207338
diff changeset
  1616
      promise = mStartRecordingPromise.forget();
249187
9ba890d2ba081ceea82be94530b3fafffa51b766 Bug 1152500 - Fix how stop recording may be handled out-of-order. r=dhylands
Andrew Osmond <aosmond@mozilla.com>
parents: 246249
diff changeset
  1617
      mRecording = false;
9ba890d2ba081ceea82be94530b3fafffa51b766 Bug 1152500 - Fix how stop recording may be handled out-of-order. r=dhylands
Andrew Osmond <aosmond@mozilla.com>
parents: 246249
diff changeset
  1618
      NotifyRecordingStatusChange(NS_LITERAL_STRING("shutdown"));
168993
e93e96ed8a5ad4999e272e2a3180a32e1ffdf94d Bug 909542 - refactor CameraControl API, r=dhylands,jst,jesup,onecyrenus
Mike Habicher <mikeh@mozilla.com>
parents: 168958
diff changeset
  1619
      break;
e93e96ed8a5ad4999e272e2a3180a32e1ffdf94d Bug 909542 - refactor CameraControl API, r=dhylands,jst,jesup,onecyrenus
Mike Habicher <mikeh@mozilla.com>
parents: 168958
diff changeset
  1620
185695
a1b5c50d2695198f2201fda35c3d996f4fe9e6b7 Bug 1015368 - add missing cases to OnUserError() switch, r=aosmond
Mike Habicher <mikeh@mozilla.com>
parents: 182301
diff changeset
  1621
    case CameraControlListener::kInStartFaceDetection:
a1b5c50d2695198f2201fda35c3d996f4fe9e6b7 Bug 1015368 - add missing cases to OnUserError() switch, r=aosmond
Mike Habicher <mikeh@mozilla.com>
parents: 182301
diff changeset
  1622
      // This method doesn't have any callbacks, so all we can do is log the
a1b5c50d2695198f2201fda35c3d996f4fe9e6b7 Bug 1015368 - add missing cases to OnUserError() switch, r=aosmond
Mike Habicher <mikeh@mozilla.com>
parents: 182301
diff changeset
  1623
      // failure. This only happens after the hardware has been released.
a1b5c50d2695198f2201fda35c3d996f4fe9e6b7 Bug 1015368 - add missing cases to OnUserError() switch, r=aosmond
Mike Habicher <mikeh@mozilla.com>
parents: 182301
diff changeset
  1624
      NS_WARNING("Failed to start face detection");
a1b5c50d2695198f2201fda35c3d996f4fe9e6b7 Bug 1015368 - add missing cases to OnUserError() switch, r=aosmond
Mike Habicher <mikeh@mozilla.com>
parents: 182301
diff changeset
  1625
      return;
a1b5c50d2695198f2201fda35c3d996f4fe9e6b7 Bug 1015368 - add missing cases to OnUserError() switch, r=aosmond
Mike Habicher <mikeh@mozilla.com>
parents: 182301
diff changeset
  1626
a1b5c50d2695198f2201fda35c3d996f4fe9e6b7 Bug 1015368 - add missing cases to OnUserError() switch, r=aosmond
Mike Habicher <mikeh@mozilla.com>
parents: 182301
diff changeset
  1627
    case CameraControlListener::kInStopFaceDetection:
a1b5c50d2695198f2201fda35c3d996f4fe9e6b7 Bug 1015368 - add missing cases to OnUserError() switch, r=aosmond
Mike Habicher <mikeh@mozilla.com>
parents: 182301
diff changeset
  1628
      // This method doesn't have any callbacks, so all we can do is log the
a1b5c50d2695198f2201fda35c3d996f4fe9e6b7 Bug 1015368 - add missing cases to OnUserError() switch, r=aosmond
Mike Habicher <mikeh@mozilla.com>
parents: 182301
diff changeset
  1629
      // failure. This only happens after the hardware has been released.
a1b5c50d2695198f2201fda35c3d996f4fe9e6b7 Bug 1015368 - add missing cases to OnUserError() switch, r=aosmond
Mike Habicher <mikeh@mozilla.com>
parents: 182301
diff changeset
  1630
      NS_WARNING("Failed to stop face detection");
a1b5c50d2695198f2201fda35c3d996f4fe9e6b7 Bug 1015368 - add missing cases to OnUserError() switch, r=aosmond
Mike Habicher <mikeh@mozilla.com>
parents: 182301
diff changeset
  1631
      return;
a1b5c50d2695198f2201fda35c3d996f4fe9e6b7 Bug 1015368 - add missing cases to OnUserError() switch, r=aosmond
Mike Habicher <mikeh@mozilla.com>
parents: 182301
diff changeset
  1632
a1b5c50d2695198f2201fda35c3d996f4fe9e6b7 Bug 1015368 - add missing cases to OnUserError() switch, r=aosmond
Mike Habicher <mikeh@mozilla.com>
parents: 182301
diff changeset
  1633
    case CameraControlListener::kInResumeContinuousFocus:
a1b5c50d2695198f2201fda35c3d996f4fe9e6b7 Bug 1015368 - add missing cases to OnUserError() switch, r=aosmond
Mike Habicher <mikeh@mozilla.com>
parents: 182301
diff changeset
  1634
      // This method doesn't have any callbacks, so all we can do is log the
a1b5c50d2695198f2201fda35c3d996f4fe9e6b7 Bug 1015368 - add missing cases to OnUserError() switch, r=aosmond
Mike Habicher <mikeh@mozilla.com>
parents: 182301
diff changeset
  1635
      // failure. This only happens after the hardware has been released.
a1b5c50d2695198f2201fda35c3d996f4fe9e6b7 Bug 1015368 - add missing cases to OnUserError() switch, r=aosmond
Mike Habicher <mikeh@mozilla.com>
parents: 182301
diff changeset
  1636
      NS_WARNING("Failed to resume continuous focus");
a1b5c50d2695198f2201fda35c3d996f4fe9e6b7 Bug 1015368 - add missing cases to OnUserError() switch, r=aosmond
Mike Habicher <mikeh@mozilla.com>
parents: 182301
diff changeset
  1637
      return;
a1b5c50d2695198f2201fda35c3d996f4fe9e6b7 Bug 1015368 - add missing cases to OnUserError() switch, r=aosmond
Mike Habicher <mikeh@mozilla.com>
parents: 182301
diff changeset
  1638
168993
e93e96ed8a5ad4999e272e2a3180a32e1ffdf94d Bug 909542 - refactor CameraControl API, r=dhylands,jst,jesup,onecyrenus
Mike Habicher <mikeh@mozilla.com>
parents: 168958
diff changeset
  1639
    case CameraControlListener::kInStopRecording:
170205
4b6103d24d1eeace490a82002e734c1cb73922ee Bug 975472 - fix crash in DOM error handler, r=dhylands
Mike Habicher <mikeh@mozilla.com>
parents: 169639
diff changeset
  1640
      // This method doesn't have any callbacks, so all we can do is log the
4b6103d24d1eeace490a82002e734c1cb73922ee Bug 975472 - fix crash in DOM error handler, r=dhylands
Mike Habicher <mikeh@mozilla.com>
parents: 169639
diff changeset
  1641
      // failure. This only happens after the hardware has been released.
4b6103d24d1eeace490a82002e734c1cb73922ee Bug 975472 - fix crash in DOM error handler, r=dhylands
Mike Habicher <mikeh@mozilla.com>
parents: 169639
diff changeset
  1642
      NS_WARNING("Failed to stop recording");
4b6103d24d1eeace490a82002e734c1cb73922ee Bug 975472 - fix crash in DOM error handler, r=dhylands
Mike Habicher <mikeh@mozilla.com>
parents: 169639
diff changeset
  1643
      return;
168993
e93e96ed8a5ad4999e272e2a3180a32e1ffdf94d Bug 909542 - refactor CameraControl API, r=dhylands,jst,jesup,onecyrenus
Mike Habicher <mikeh@mozilla.com>
parents: 168958
diff changeset
  1644
258070
5aa09eb27b71f1a03f8afa3901c4c64d0d0208e4 Bug 1187364 - Part 1. Add ability for camera to pause/resume recording. r=dhylands,bz
Andrew Osmond <aosmond@mozilla.com>
parents: 256549
diff changeset
  1645
    case CameraControlListener::kInPauseRecording:
5aa09eb27b71f1a03f8afa3901c4c64d0d0208e4 Bug 1187364 - Part 1. Add ability for camera to pause/resume recording. r=dhylands,bz
Andrew Osmond <aosmond@mozilla.com>
parents: 256549
diff changeset
  1646
      // This method doesn't have any callbacks, so all we can do is log the
5aa09eb27b71f1a03f8afa3901c4c64d0d0208e4 Bug 1187364 - Part 1. Add ability for camera to pause/resume recording. r=dhylands,bz
Andrew Osmond <aosmond@mozilla.com>
parents: 256549
diff changeset
  1647
      // failure. This only happens after the hardware has been released.
5aa09eb27b71f1a03f8afa3901c4c64d0d0208e4 Bug 1187364 - Part 1. Add ability for camera to pause/resume recording. r=dhylands,bz
Andrew Osmond <aosmond@mozilla.com>
parents: 256549
diff changeset
  1648
      NS_WARNING("Failed to pause recording");
5aa09eb27b71f1a03f8afa3901c4c64d0d0208e4 Bug 1187364 - Part 1. Add ability for camera to pause/resume recording. r=dhylands,bz
Andrew Osmond <aosmond@mozilla.com>
parents: 256549
diff changeset
  1649
      return;
5aa09eb27b71f1a03f8afa3901c4c64d0d0208e4 Bug 1187364 - Part 1. Add ability for camera to pause/resume recording. r=dhylands,bz
Andrew Osmond <aosmond@mozilla.com>
parents: 256549
diff changeset
  1650
5aa09eb27b71f1a03f8afa3901c4c64d0d0208e4 Bug 1187364 - Part 1. Add ability for camera to pause/resume recording. r=dhylands,bz
Andrew Osmond <aosmond@mozilla.com>
parents: 256549
diff changeset
  1651
    case CameraControlListener::kInResumeRecording:
5aa09eb27b71f1a03f8afa3901c4c64d0d0208e4 Bug 1187364 - Part 1. Add ability for camera to pause/resume recording. r=dhylands,bz
Andrew Osmond <aosmond@mozilla.com>
parents: 256549
diff changeset
  1652
      // This method doesn't have any callbacks, so all we can do is log the
5aa09eb27b71f1a03f8afa3901c4c64d0d0208e4 Bug 1187364 - Part 1. Add ability for camera to pause/resume recording. r=dhylands,bz
Andrew Osmond <aosmond@mozilla.com>
parents: 256549
diff changeset
  1653
      // failure. This only happens after the hardware has been released.
5aa09eb27b71f1a03f8afa3901c4c64d0d0208e4 Bug 1187364 - Part 1. Add ability for camera to pause/resume recording. r=dhylands,bz
Andrew Osmond <aosmond@mozilla.com>
parents: 256549
diff changeset
  1654
      NS_WARNING("Failed to resume recording");
5aa09eb27b71f1a03f8afa3901c4c64d0d0208e4 Bug 1187364 - Part 1. Add ability for camera to pause/resume recording. r=dhylands,bz
Andrew Osmond <aosmond@mozilla.com>
parents: 256549
diff changeset
  1655
      return;
5aa09eb27b71f1a03f8afa3901c4c64d0d0208e4 Bug 1187364 - Part 1. Add ability for camera to pause/resume recording. r=dhylands,bz
Andrew Osmond <aosmond@mozilla.com>
parents: 256549
diff changeset
  1656
168993
e93e96ed8a5ad4999e272e2a3180a32e1ffdf94d Bug 909542 - refactor CameraControl API, r=dhylands,jst,jesup,onecyrenus
Mike Habicher <mikeh@mozilla.com>
parents: 168958
diff changeset
  1657
    case CameraControlListener::kInStartPreview:
170205
4b6103d24d1eeace490a82002e734c1cb73922ee Bug 975472 - fix crash in DOM error handler, r=dhylands
Mike Habicher <mikeh@mozilla.com>
parents: 169639
diff changeset
  1658
      // This method doesn't have any callbacks, so all we can do is log the
4b6103d24d1eeace490a82002e734c1cb73922ee Bug 975472 - fix crash in DOM error handler, r=dhylands
Mike Habicher <mikeh@mozilla.com>
parents: 169639
diff changeset
  1659
      // failure. This only happens after the hardware has been released.
4b6103d24d1eeace490a82002e734c1cb73922ee Bug 975472 - fix crash in DOM error handler, r=dhylands
Mike Habicher <mikeh@mozilla.com>
parents: 169639
diff changeset
  1660
      NS_WARNING("Failed to (re)start preview");
4b6103d24d1eeace490a82002e734c1cb73922ee Bug 975472 - fix crash in DOM error handler, r=dhylands
Mike Habicher <mikeh@mozilla.com>
parents: 169639
diff changeset
  1661
      return;
168993
e93e96ed8a5ad4999e272e2a3180a32e1ffdf94d Bug 909542 - refactor CameraControl API, r=dhylands,jst,jesup,onecyrenus
Mike Habicher <mikeh@mozilla.com>
parents: 168958
diff changeset
  1662
180888
c26966635e9c0c028e4360f2175563f9ef62df80 Bug 985496 - rationalize camera error reporting, r=dhylands
Mike Habicher <mikeh@mozilla.com>
parents: 180485
diff changeset
  1663
    case CameraControlListener::kInStopPreview:
c26966635e9c0c028e4360f2175563f9ef62df80 Bug 985496 - rationalize camera error reporting, r=dhylands
Mike Habicher <mikeh@mozilla.com>
parents: 180485
diff changeset
  1664
      // This method doesn't have any callbacks, so all we can do is log the
c26966635e9c0c028e4360f2175563f9ef62df80 Bug 985496 - rationalize camera error reporting, r=dhylands
Mike Habicher <mikeh@mozilla.com>
parents: 180485
diff changeset
  1665
      // failure. This only happens after the hardware has been released.
c26966635e9c0c028e4360f2175563f9ef62df80 Bug 985496 - rationalize camera error reporting, r=dhylands
Mike Habicher <mikeh@mozilla.com>
parents: 180485
diff changeset
  1666
      NS_WARNING("Failed to stop preview");
c26966635e9c0c028e4360f2175563f9ef62df80 Bug 985496 - rationalize camera error reporting, r=dhylands
Mike Habicher <mikeh@mozilla.com>
parents: 180485
diff changeset
  1667
      return;
c26966635e9c0c028e4360f2175563f9ef62df80 Bug 985496 - rationalize camera error reporting, r=dhylands
Mike Habicher <mikeh@mozilla.com>
parents: 180485
diff changeset
  1668
c26966635e9c0c028e4360f2175563f9ef62df80 Bug 985496 - rationalize camera error reporting, r=dhylands
Mike Habicher <mikeh@mozilla.com>
parents: 180485
diff changeset
  1669
    case CameraControlListener::kInSetPictureSize:
c26966635e9c0c028e4360f2175563f9ef62df80 Bug 985496 - rationalize camera error reporting, r=dhylands
Mike Habicher <mikeh@mozilla.com>
parents: 180485
diff changeset
  1670
      // This method doesn't have any callbacks, so all we can do is log the
c26966635e9c0c028e4360f2175563f9ef62df80 Bug 985496 - rationalize camera error reporting, r=dhylands
Mike Habicher <mikeh@mozilla.com>
parents: 180485
diff changeset
  1671
      // failure. This only happens after the hardware has been released.
c26966635e9c0c028e4360f2175563f9ef62df80 Bug 985496 - rationalize camera error reporting, r=dhylands
Mike Habicher <mikeh@mozilla.com>
parents: 180485
diff changeset
  1672
      NS_WARNING("Failed to set picture size");
c26966635e9c0c028e4360f2175563f9ef62df80 Bug 985496 - rationalize camera error reporting, r=dhylands
Mike Habicher <mikeh@mozilla.com>
parents: 180485
diff changeset
  1673
      return;
c26966635e9c0c028e4360f2175563f9ef62df80 Bug 985496 - rationalize camera error reporting, r=dhylands
Mike Habicher <mikeh@mozilla.com>
parents: 180485
diff changeset
  1674
c26966635e9c0c028e4360f2175563f9ef62df80 Bug 985496 - rationalize camera error reporting, r=dhylands
Mike Habicher <mikeh@mozilla.com>
parents: 180485
diff changeset
  1675
    case CameraControlListener::kInSetThumbnailSize:
c26966635e9c0c028e4360f2175563f9ef62df80 Bug 985496 - rationalize camera error reporting, r=dhylands
Mike Habicher <mikeh@mozilla.com>
parents: 180485
diff changeset
  1676
      // This method doesn't have any callbacks, so all we can do is log the
c26966635e9c0c028e4360f2175563f9ef62df80 Bug 985496 - rationalize camera error reporting, r=dhylands
Mike Habicher <mikeh@mozilla.com>
parents: 180485
diff changeset
  1677
      // failure. This only happens after the hardware has been released.
c26966635e9c0c028e4360f2175563f9ef62df80 Bug 985496 - rationalize camera error reporting, r=dhylands
Mike Habicher <mikeh@mozilla.com>
parents: 180485
diff changeset
  1678
      NS_WARNING("Failed to set thumbnail size");
c26966635e9c0c028e4360f2175563f9ef62df80 Bug 985496 - rationalize camera error reporting, r=dhylands
Mike Habicher <mikeh@mozilla.com>
parents: 180485
diff changeset
  1679
      return;
168993
e93e96ed8a5ad4999e272e2a3180a32e1ffdf94d Bug 909542 - refactor CameraControl API, r=dhylands,jst,jesup,onecyrenus
Mike Habicher <mikeh@mozilla.com>
parents: 168958
diff changeset
  1680
e93e96ed8a5ad4999e272e2a3180a32e1ffdf94d Bug 909542 - refactor CameraControl API, r=dhylands,jst,jesup,onecyrenus
Mike Habicher <mikeh@mozilla.com>
parents: 168958
diff changeset
  1681
    default:
180888
c26966635e9c0c028e4360f2175563f9ef62df80 Bug 985496 - rationalize camera error reporting, r=dhylands
Mike Habicher <mikeh@mozilla.com>
parents: 180485
diff changeset
  1682
      {
c26966635e9c0c028e4360f2175563f9ef62df80 Bug 985496 - rationalize camera error reporting, r=dhylands
Mike Habicher <mikeh@mozilla.com>
parents: 180485
diff changeset
  1683
        nsPrintfCString msg("Unhandled aContext=%u, aError=0x%x\n", aContext, aError);
c26966635e9c0c028e4360f2175563f9ef62df80 Bug 985496 - rationalize camera error reporting, r=dhylands
Mike Habicher <mikeh@mozilla.com>
parents: 180485
diff changeset
  1684
        NS_WARNING(msg.get());
c26966635e9c0c028e4360f2175563f9ef62df80 Bug 985496 - rationalize camera error reporting, r=dhylands
Mike Habicher <mikeh@mozilla.com>
parents: 180485
diff changeset
  1685
      }
182301
db13bb9473cc40c42900c1d0afd841fe6ea378e2 Bug 990764 - Replace MOZ_ASSUME_UNREACHABLE in dom. r=smaug
Chris Peterson <cpeterson@mozilla.com>
parents: 181171
diff changeset
  1686
      MOZ_ASSERT_UNREACHABLE("Unhandled user error");
168993
e93e96ed8a5ad4999e272e2a3180a32e1ffdf94d Bug 909542 - refactor CameraControl API, r=dhylands,jst,jesup,onecyrenus
Mike Habicher <mikeh@mozilla.com>
parents: 168958
diff changeset
  1687
      return;
e93e96ed8a5ad4999e272e2a3180a32e1ffdf94d Bug 909542 - refactor CameraControl API, r=dhylands,jst,jesup,onecyrenus
Mike Habicher <mikeh@mozilla.com>
parents: 168958
diff changeset
  1688
  }
e93e96ed8a5ad4999e272e2a3180a32e1ffdf94d Bug 909542 - refactor CameraControl API, r=dhylands,jst,jesup,onecyrenus
Mike Habicher <mikeh@mozilla.com>
parents: 168958
diff changeset
  1689
219181
12c5cc6e88b326e2e4006fc6573bf01e0fea54c2 Bug 1107683 - remove method callbacks from CameraControl, r=aosmond,bz
Mike Habicher <mikeh@mozilla.com>
parents: 217721
diff changeset
  1690
  if (!promise) {
180888
c26966635e9c0c028e4360f2175563f9ef62df80 Bug 985496 - rationalize camera error reporting, r=dhylands
Mike Habicher <mikeh@mozilla.com>
parents: 180485
diff changeset
  1691
    DOM_CAMERA_LOGW("DOM No error handler for aError=0x%x in aContext=%u\n",
c26966635e9c0c028e4360f2175563f9ef62df80 Bug 985496 - rationalize camera error reporting, r=dhylands
Mike Habicher <mikeh@mozilla.com>
parents: 180485
diff changeset
  1692
      aError, aContext);
168993
e93e96ed8a5ad4999e272e2a3180a32e1ffdf94d Bug 909542 - refactor CameraControl API, r=dhylands,jst,jesup,onecyrenus
Mike Habicher <mikeh@mozilla.com>
parents: 168958
diff changeset
  1693
    return;
e93e96ed8a5ad4999e272e2a3180a32e1ffdf94d Bug 909542 - refactor CameraControl API, r=dhylands,jst,jesup,onecyrenus
Mike Habicher <mikeh@mozilla.com>
parents: 168958
diff changeset
  1694
  }
e93e96ed8a5ad4999e272e2a3180a32e1ffdf94d Bug 909542 - refactor CameraControl API, r=dhylands,jst,jesup,onecyrenus
Mike Habicher <mikeh@mozilla.com>
parents: 168958
diff changeset
  1695
219181
12c5cc6e88b326e2e4006fc6573bf01e0fea54c2 Bug 1107683 - remove method callbacks from CameraControl, r=aosmond,bz
Mike Habicher <mikeh@mozilla.com>
parents: 217721
diff changeset
  1696
  promise->MaybeReject(aError);
180300
5d6a3571f1abd8dd38973ee29c2a894acfd8a196 Backed out changeset a73dece39b01 (bug 985496) for mochitest-5 orange
Wes Kocher <wkocher@mozilla.com>
parents: 180299
diff changeset
  1697
}