MediaRecorder-passthrough.https.html (2854B)
1 <!doctype html> 2 <html> 3 4 <head> 5 <title>MediaRecorder peer connection</title> 6 <link rel="help" 7 href="https://w3c.github.io/mediacapture-record/MediaRecorder.html#dom-mediarecorder-mimeType"> 8 <script src="/resources/testharness.js"></script> 9 <script src="/resources/testharnessreport.js"></script> 10 <script src="/resources/testdriver.js"></script> 11 <script src="/resources/testdriver-vendor.js"></script> 12 <script src="../../mediacapture-streams/permission-helper.js"></script> 13 <script src="../utils/peerconnection.js"></script> 14 </head> 15 16 <body> 17 <video id="remote" autoplay width="240"></video> 18 <script> 19 20 [{kind: "video", audio: false, codecPreference: "VP8", codecRegex: /.*vp8.*/}, 21 {kind: "audio/video", audio: true, codecPreference: "VP8", codecRegex: /.*vp8.*/}, 22 {kind: "video", audio: false, codecPreference: "VP9", codecRegex: /.*vp9.*/}, 23 {kind: "audio/video", audio: true, codecPreference: "VP9", codecRegex: /.*vp9.*/}] 24 .forEach(args => { 25 promise_test(async t => { 26 const [localPc, remotePc, stream] = await startConnection( 27 t, args.audio, /*video=*/true, args.codecPreference); 28 29 // Needed for the tests to get exercised in Chrome (bug) 30 document.getElementById('remote').srcObject = stream; 31 32 const recorder = new MediaRecorder(stream); // Passthrough. 33 const onstartPromise = new Promise(resolve => { 34 recorder.onstart = t.step_func(() => { 35 assert_regexp_match( 36 recorder.mimeType, args.codecRegex, 37 "mimeType is matching " + args.codecPreference + 38 " in case of passthrough."); 39 resolve(); 40 }); 41 }); 42 recorder.start(); 43 await(onstartPromise); 44 }, "PeerConnection passthrough MediaRecorder receives " + 45 args.codecPreference + " after onstart with a " + args.kind + 46 " stream."); 47 }); 48 49 promise_test(async t => { 50 const [localPc, remotePc, stream, transceivers] = await startConnection( 51 t, /*audio=*/false, /*video=*/true, /*videoCodecPreference=*/"VP8"); 52 53 // Needed for the tests to get exercised in Chrome (bug) 54 document.getElementById('remote').srcObject = stream; 55 56 const recorder = new MediaRecorder(stream); // Possibly passthrough. 57 recorder.start(); 58 await waitForReceivedFramesOrPackets(t, remotePc, false, true, 10); 59 60 // Switch codec to VP9; we expect onerror to not be invoked. 61 recorder.onerror = t.step_func(() => assert_unreached( 62 "MediaRecorder should be prepared to handle codec switches")); 63 setTransceiverCodecPreference(transceivers.video, "VP9"); 64 await Promise.all([ 65 exchangeOfferAnswer(localPc, remotePc), 66 waitForReceivedCodec(t, remotePc, "VP9") 67 ]); 68 }, "PeerConnection passthrough MediaRecorder should be prepared to handle " + 69 "the codec switching from VP8 to VP9"); 70 71 </script> 72 </body> 73 74 </html>