-
Notifications
You must be signed in to change notification settings - Fork 54
/
MediaRecorder-passthrough.https.html
61 lines (54 loc) · 2.33 KB
/
MediaRecorder-passthrough.https.html
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
56
57
58
59
60
61
<!doctype html>
<html>
<head>
<title>MediaRecorder peer connection</title>
<link rel="help"
href="https://w3c.github.io/mediacapture-record/MediaRecorder.html#dom-mediarecorder-mimeType">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="../utils/peerconnection.js"></script>
</head>
<body>
<video id="remote" autoplay width="240" />
<script>
[{kind: "video", audio: false, codecPreference: "VP8", codecRegex: /.*vp8.*/},
{kind: "audio/video", audio: true, codecPreference: "VP8", codecRegex: /.*vp8.*/},
{kind: "video", audio: false, codecPreference: "VP9", codecRegex: /.*vp9.*/},
{kind: "audio/video", audio: true, codecPreference: "VP9", codecRegex: /.*vp9.*/}]
.forEach(args => {
promise_test(async t => {
const [localPc, remotePc, stream] = await startConnection(
t, args.audio, /*video=*/true, args.codecPreference);
const recorder = new MediaRecorder(stream); // Passthrough.
const onstartPromise = new Promise(resolve => {
recorder.onstart = t.step_func(() => {
assert_regexp_match(
recorder.mimeType, args.codecRegex,
"mimeType is matching " + args.codecPreference +
" in case of passthrough.");
resolve();
});
});
recorder.start();
await(onstartPromise);
}, "PeerConnection passthrough MediaRecorder receives " +
args.codecPreference + " after onstart with a " + args.kind +
" stream.");
});
promise_test(async t => {
const [localPc, remotePc, stream, transceivers] = await startConnection(
t, /*audio=*/false, /*video=*/true, /*videoCodecPreference=*/"VP8");
const recorder = new MediaRecorder(stream); // Possibly passthrough.
recorder.start();
await waitForReceivedFrames(t, remotePc, false, true, 10);
// Switch codec to VP9; we expect onerror to not be invoked.
recorder.onerror = t.step_func(() => assert_unreached(
"MediaRecorder should be prepared to handle codec switches"));
setTransceiverCodecPreference(transceivers.video, "VP9");
exchangeOfferAnswer(localPc, remotePc);
await waitForReceivedCodec(t, remotePc, "VP9");
}, "PeerConnection passthrough MediaRecorder should be prepared to handle " +
"the codec switching from VP8 to VP9");
</script>
</body>
</html>