blob: 16303c62db8386a2dd70d9c18fc196774d9b24d4 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
|
<!DOCTYPE html>
<html>
<head><meta charset="UTF-8"></head>
<body>
<div id="message"></div>
<script>
// Specifies whether we are using fake streams to run this automation
var useFakeStreams = true;
try {
var audioDevice = SpecialPowers.getCharPref("media.audio_loopback_dev");
var videoDevice = SpecialPowers.getCharPref("media.video_loopback_dev");
dump("TEST DEVICES: Using media devices:\n");
dump("audio: " + audioDevice + "\nvideo: " + videoDevice + "\n");
useFakeStreams = false;
} catch (e) {
dump("TEST DEVICES: No test devices found (in media.{audio,video}_loopback_dev, using fake streams.\n");
useFakeStreams = true;
}
function message(m) {
document.getElementById("message").innerHTML = m;
window.parent.postMessage(m, "*");
}
var gStream;
function requestDevice(aAudio, aVideo, aShare) {
var opts = {video: aVideo, audio: aAudio};
if (aShare) {
opts.video = {
mozMediaSource: aShare,
mediaSource: aShare
}
} else if (useFakeStreams) {
opts.fake = true;
}
window.navigator.mediaDevices.getUserMedia(opts)
.then(stream => {
gStream = stream;
message("ok");
}, err => message("error: " + err));
}
message("pending");
function closeStream() {
if (!gStream)
return;
gStream.getTracks().forEach(t => t.stop());
gStream = null;
message("closed");
}
</script>
</body>
</html>
|