Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Support groupId constrainable properties in MediaDevices.getUserMedia()
This CL also adds support in MediaStreamTrack.applyConstraints(). Drive-by: Minor lint fixes. Bug: 833333 Change-Id: I8636def42d9ed64c6f58777d44343e569e541bfb
- Loading branch information
1 parent
7a7d2e1
commit 7df2cbf
Showing
2 changed files
with
85 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
57 changes: 57 additions & 0 deletions
57
mediacapture-streams/MediaStreamTrack-applyConstraints.https.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
<!doctype html> | ||
<title>MediaStreamTrack applyConstraints</title> | ||
<p class="instructions">When prompted, accept to share your video stream.</p> | ||
<script src=/resources/testharness.js></script> | ||
<script src=/resources/testharnessreport.js></script> | ||
<script> | ||
'use strict' | ||
|
||
// https://w3c.github.io/mediacapture-main/#dom-mediastreamtrack-applyconstraints | ||
|
||
promise_test(t => { | ||
return navigator.mediaDevices.getUserMedia({ video: true }) | ||
.then(t.step_func(stream => { | ||
return stream.getVideoTracks()[0].applyConstraints( | ||
{ groupId: { exact: "INVALID" } }).then( | ||
t.unreached_func('Accepted invalid groupID'), | ||
t.step_func(e => { | ||
assert_equals(e.name, 'OverconstrainedError'); | ||
assert_equals(e.constraint, 'groupId'); | ||
})); | ||
})); | ||
}, 'applyConstraints rejects invalid groupID'); | ||
|
||
promise_test(t => { | ||
return navigator.mediaDevices.getUserMedia({ video: true }) | ||
.then(t.step_func(stream => { | ||
var track = stream.getVideoTracks()[0]; | ||
var groupId = track.getSettings().groupId; | ||
return track.applyConstraints({ groupId: "INVALID" }).then( | ||
t.step_func(() => { | ||
assert_equals(track.getSettings().groupId, groupId); | ||
})); | ||
})); | ||
}, 'applyConstraints accepts invalid ideal groupID, does not change setting'); | ||
|
||
promise_test(t => { | ||
return navigator.mediaDevices.getUserMedia({ video: true }) | ||
.then(t.step_func(stream => { | ||
var track = stream.getVideoTracks()[0]; | ||
var groupId = track.getSettings().groupId; | ||
return navigator.mediaDevices.enumerateDevices().then(devices => { | ||
var anotherDevice = devices.find(device => { | ||
return device.kind == "videoinput" && device.groupId != groupId; | ||
}); | ||
if (anotherDevice !== undefined) { | ||
return track.applyConstraints( | ||
{ groupId: { exact: anotherDevice.groupId } }).then( | ||
t.unreached_func(), | ||
t.step_func(e => { | ||
assert_equals(e.name, 'OverconstrainedError'); | ||
assert_equals(e.constraint, 'groupId'); | ||
})); | ||
} | ||
}); | ||
})); | ||
}, 'applyConstraints rejects attempt to switch device using groupId'); | ||
</script> |