msid-parse.html (3178B)
1 <!doctype html> 2 <meta charset=utf-8> 3 <title>RTCPeerconnection MSID parsing</title> 4 <script src="/resources/testharness.js"></script> 5 <script src="/resources/testharnessreport.js"></script> 6 <script src="../RTCPeerConnection-helper.js"></script> 7 <script> 8 'use strict'; 9 const preamble = `v=0 10 o=- 0 3 IN IP4 127.0.0.1 11 s=- 12 t=0 0 13 a=fingerprint:sha-256 A7:24:72:CA:6E:02:55:39:BA:66:DF:6E:CC:4C:D8:B0:1A:BF:1A:56:65:7D:F4:03:AD:7E:77:43:2A:29:EC:93 14 a=ice-ufrag:6HHHdzzeIhkE0CKj 15 a=ice-pwd:XYDGVpfvklQIEnZ6YnyLsAew 16 m=video 1 RTP/SAVPF 100 17 c=IN IP4 0.0.0.0 18 a=rtcp-mux 19 a=sendonly 20 a=mid:video 21 a=rtpmap:100 VP8/30 22 a=setup:actpass 23 `; 24 25 26 promise_test(async t => { 27 const pc = new RTCPeerConnection(); 28 t.add_cleanup(() => pc.close()); 29 const ontrackPromise = addEventListenerPromise(t, pc, 'track'); 30 await pc.setRemoteDescription({type: 'offer', sdp: preamble}); 31 const trackevent = await ontrackPromise; 32 assert_equals(pc.getReceivers().length, 1); 33 assert_equals(trackevent.streams.length, 1, 'Stream count'); 34 }, 'Description with no msid produces a track with a stream'); 35 36 promise_test(async t => { 37 const pc = new RTCPeerConnection(); 38 t.add_cleanup(() => pc.close()); 39 const ontrackPromise = addEventListenerPromise(t, pc, 'track'); 40 await pc.setRemoteDescription({type: 'offer', 41 sdp: preamble + 'a=msid:- foobar\n'}); 42 const trackevent = await ontrackPromise; 43 assert_equals(pc.getReceivers().length, 1); 44 assert_equals(trackevent.streams.length, 0); 45 }, 'Description with msid:- appid produces a track with no stream'); 46 47 promise_test(async t => { 48 const pc = new RTCPeerConnection(); 49 t.add_cleanup(() => pc.close()); 50 const ontrackPromise = addEventListenerPromise(t, pc, 'track'); 51 await pc.setRemoteDescription({type: 'offer', 52 sdp: preamble + 'a=msid:foo bar\n'}); 53 const trackevent = await ontrackPromise; 54 assert_equals(pc.getReceivers().length, 1); 55 assert_equals(trackevent.streams.length, 1); 56 assert_equals(trackevent.streams[0].id, 'foo'); 57 }, 'Description with msid:foo bar produces a stream with id foo'); 58 59 promise_test(async t => { 60 const pc = new RTCPeerConnection(); 61 t.add_cleanup(() => pc.close()); 62 const ontrackPromise = addEventListenerPromise(t, pc, 'track'); 63 await pc.setRemoteDescription({type: 'offer', 64 sdp: preamble + 'a=msid:foo bar\n' 65 + 'a=msid:baz bar\n'}); 66 const trackevent = await ontrackPromise; 67 assert_equals(pc.getReceivers().length, 1); 68 assert_equals(trackevent.streams.length, 2); 69 }, 'Description with two msid produces two streams'); 70 71 promise_test(async t => { 72 const pc = new RTCPeerConnection(); 73 t.add_cleanup(() => pc.close()); 74 const ontrackPromise = addEventListenerPromise(t, pc, 'track'); 75 await pc.setRemoteDescription({type: 'offer', 76 sdp: preamble + 'a=msid:foo\n'}); 77 const trackevent = await ontrackPromise; 78 assert_equals(pc.getReceivers().length, 1); 79 assert_equals(trackevent.streams.length, 1); 80 assert_equals(trackevent.streams[0].id, 'foo'); 81 }, 'Description with msid foo but no track id is accepted'); 82 83 </script>