mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 1152381 - implement mediaDevices.getSupportedConstraints. r=smaug, r=jesup
This commit is contained in:
parent
6d43ab4967
commit
eece65fcc3
@ -7,6 +7,7 @@
|
||||
#include "mozilla/dom/MediaDevicesBinding.h"
|
||||
#include "mozilla/dom/Promise.h"
|
||||
#include "mozilla/MediaManager.h"
|
||||
#include "MediaTrackConstraints.h"
|
||||
#include "nsIEventTarget.h"
|
||||
#include "nsIScriptGlobalObject.h"
|
||||
#include "nsIPermissionManager.h"
|
||||
|
@ -16,6 +16,7 @@ namespace dom {
|
||||
|
||||
class Promise;
|
||||
struct MediaStreamConstraints;
|
||||
struct MediaTrackSupportedConstraints;
|
||||
|
||||
#define MOZILLA_DOM_MEDIADEVICES_IMPLEMENTATION_IID \
|
||||
{ 0x2f784d8a, 0x7485, 0x4280, \
|
||||
@ -32,6 +33,9 @@ public:
|
||||
|
||||
JSObject* WrapObject(JSContext* cx, JS::Handle<JSObject*> aGivenProto) override;
|
||||
|
||||
// No code needed, as MediaTrackSupportedConstraints members default to true.
|
||||
void GetSupportedConstraints(MediaTrackSupportedConstraints& aResult) {};
|
||||
|
||||
already_AddRefed<Promise>
|
||||
GetUserMedia(const MediaStreamConstraints& aConstraints, ErrorResult &aRv);
|
||||
|
||||
|
@ -65,12 +65,40 @@ var tests = [
|
||||
error: null },
|
||||
];
|
||||
|
||||
var mustSupport = [
|
||||
'width', 'height', 'frameRate', 'facingMode', 'deviceId',
|
||||
// Yet to add:
|
||||
// 'aspectRatio', 'frameRate', 'volume', 'sampleRate', 'sampleSize',
|
||||
// 'echoCancellation', 'latency', 'groupId'
|
||||
|
||||
// http://fluffy.github.io/w3c-screen-share/#screen-based-video-constraints
|
||||
// OBE by http://w3c.github.io/mediacapture-screen-share
|
||||
'mediaSource',
|
||||
|
||||
// Experimental https://bugzilla.mozilla.org/show_bug.cgi?id=1131568#c3
|
||||
'browserWindow', 'scrollWithPage',
|
||||
];
|
||||
|
||||
/**
|
||||
* Starts the test run by running through each constraint
|
||||
* test by verifying that the right resolution and rejection is fired.
|
||||
*/
|
||||
|
||||
runTest(function() {
|
||||
|
||||
// Check supported constraints first.
|
||||
var dict = navigator.mediaDevices.getSupportedConstraints();
|
||||
var supported = Object.keys(dict);
|
||||
|
||||
mustSupport.forEach(key => ok(supported.includes(key) && dict[key],
|
||||
"Supports " + key));
|
||||
|
||||
var unexpected = supported.filter(key => !mustSupport.includes(key));
|
||||
is(unexpected.length, 0,
|
||||
"Unexpected support (please update test): " + unexpected);
|
||||
|
||||
// Run constraint tests
|
||||
|
||||
var p = new Promise(resolve => SpecialPowers.pushPrefEnv({
|
||||
set : [ ['media.getusermedia.browser.enabled', false],
|
||||
['media.getusermedia.screensharing.enabled', false] ]
|
||||
|
@ -10,6 +10,7 @@
|
||||
#include "mozilla/Attributes.h"
|
||||
#include "mozilla/dom/MediaStreamTrackBinding.h"
|
||||
#include "mozilla/dom/MediaTrackConstraintSetBinding.h"
|
||||
#include "mozilla/dom/MediaTrackSupportedConstraintsBinding.h"
|
||||
|
||||
namespace mozilla {
|
||||
|
||||
|
@ -13,7 +13,7 @@
|
||||
[Func="Navigator::HasUserMediaSupport"]
|
||||
interface MediaDevices : EventTarget {
|
||||
// attribute EventHandler ondevicechange;
|
||||
// static Dictionary getSupportedConstraints (DOMString kind);
|
||||
MediaTrackSupportedConstraints getSupportedConstraints();
|
||||
|
||||
[Throws]
|
||||
Promise<sequence<MediaDeviceInfo>> enumerateDevices();
|
||||
|
35
dom/webidl/MediaTrackSupportedConstraints.webidl
Normal file
35
dom/webidl/MediaTrackSupportedConstraints.webidl
Normal file
@ -0,0 +1,35 @@
|
||||
/* -*- Mode: IDL; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
|
||||
* You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
*
|
||||
* The origin of this IDL file is
|
||||
* http://dev.w3.org/2011/webrtc/editor/getusermedia.html
|
||||
*/
|
||||
|
||||
dictionary MediaTrackSupportedConstraints {
|
||||
boolean width = true;
|
||||
boolean height = true;
|
||||
boolean aspectRatio; // to be supported
|
||||
boolean frameRate = true;
|
||||
boolean facingMode = true;
|
||||
boolean volume; // to be supported
|
||||
boolean sampleRate; // to be supported
|
||||
boolean sampleSize; // to be supported
|
||||
boolean echoCancellation; // to be supported
|
||||
boolean latency; // to be supported
|
||||
boolean deviceId = true;
|
||||
boolean groupId; // to be supported
|
||||
|
||||
// Mozilla-specific extensions:
|
||||
|
||||
// http://fluffy.github.io/w3c-screen-share/#screen-based-video-constraints
|
||||
// OBE by http://w3c.github.io/mediacapture-screen-share
|
||||
|
||||
boolean mediaSource = true;
|
||||
|
||||
// Experimental https://bugzilla.mozilla.org/show_bug.cgi?id=1131568#c3
|
||||
|
||||
boolean browserWindow = true;
|
||||
boolean scrollWithPage = true;
|
||||
};
|
@ -289,6 +289,7 @@ WEBIDL_FILES = [
|
||||
'MediaStreamError.webidl',
|
||||
'MediaStreamTrack.webidl',
|
||||
'MediaTrackConstraintSet.webidl',
|
||||
'MediaTrackSupportedConstraints.webidl',
|
||||
'MenuBoxObject.webidl',
|
||||
'MessageChannel.webidl',
|
||||
'MessageEvent.webidl',
|
||||
|
Loading…
Reference in New Issue
Block a user