tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

simulcast-answer.html (3828B)


      1 <!doctype html>
      2 <meta charset=utf-8>
      3 <title>RTCPeerConnection Simulcast Answer</title>
      4 <script src="/resources/testharness.js"></script>
      5 <script src="/resources/testharnessreport.js"></script>
      6 <script>
      7 'use strict';
      8 
      9 const offer_sdp = `v=0
     10 o=- 3840232462471583827 2 IN IP4 127.0.0.1
     11 s=-
     12 t=0 0
     13 a=group:BUNDLE 0
     14 a=msid-semantic: WMS
     15 m=video 9 UDP/TLS/RTP/SAVPF 96
     16 c=IN IP4 0.0.0.0
     17 a=rtcp:9 IN IP4 0.0.0.0
     18 a=ice-ufrag:Li6+
     19 a=ice-pwd:3C05CTZBRQVmGCAq7hVasHlT
     20 a=ice-options:trickle
     21 a=fingerprint:sha-256 5B:D3:8E:66:0E:7D:D3:F3:8E:E6:80:28:19:FC:55:AD:58:5D:B9:3D:A8:DE:45:4A:E7:87:02:F8:3C:0B:3B:B3
     22 a=setup:actpass
     23 a=mid:0
     24 a=extmap:1 urn:ietf:params:rtp-hdrext:sdes:mid
     25 a=extmap:2 urn:ietf:params:rtp-hdrext:sdes:rtp-stream-id
     26 a=recvonly
     27 a=rtcp-mux
     28 a=rtpmap:96 VP8/90000
     29 a=rtcp-fb:96 goog-remb
     30 a=rtcp-fb:96 transport-cc
     31 a=rtcp-fb:96 ccm fir
     32 a=rid:foo recv
     33 a=rid:bar recv
     34 a=rid:baz recv
     35 a=simulcast:recv foo;bar;baz
     36 `;
     37 // Tests for the construction of answers with simulcast according to:
     38 // draft-ietf-mmusic-sdp-simulcast-13
     39 // draft-ietf-mmusic-rid-15
     40 promise_test(async t => {
     41  const pc = new RTCPeerConnection();
     42  t.add_cleanup(() => pc.close());
     43  const expected_rids = ['foo', 'bar', 'baz'];
     44 
     45  await pc.setRemoteDescription({type: 'offer', sdp: offer_sdp});
     46  const transceiver = pc.getTransceivers()[0];
     47  // The created transceiver should be in "recvonly" state. Allow it to send.
     48  transceiver.direction = 'sendonly';
     49  const answer = await pc.createAnswer();
     50  const answer_lines = answer.sdp.split('\r\n');
     51  // Check for a RID line for each layer.
     52  for (const rid of expected_rids) {
     53    const result = answer_lines.find(line => line.startsWith(`a=rid:${rid}`));
     54    assert_not_equals(result, undefined, `RID attribute for '${rid}' missing.`);
     55  }
     56 
     57  // Check for simulcast attribute with send direction and all RIDs.
     58  const result = answer_lines.find(
     59      line => line.startsWith(`a=simulcast:send ${expected_rids.join(';')}`));
     60  assert_not_equals(result, undefined, 'Could not find simulcast attribute.');
     61 }, 'createAnswer() with multiple send encodings should create simulcast answer');
     62 
     63 promise_test(async t => {
     64  const pc = new RTCPeerConnection();
     65  t.add_cleanup(() => pc.close());
     66  const expected_rids = ['foo', 'bar', 'baz'];
     67 
     68  // Try to disable the `bar` encoding in a=simulcast by prefixing it with the
     69  // `~` character.
     70  await pc.setRemoteDescription({type: 'offer', sdp: offer_sdp.replace(/(a=simulcast:.*)bar/, '$1~bar')});
     71  const transceiver = pc.getTransceivers()[0];
     72  transceiver.direction = 'sendonly';
     73  await pc.setLocalDescription();
     74 
     75  const parameters = pc.getSenders()[0].getParameters();
     76  const barEncoding = parameters.encodings.find(encoding => encoding.rid === 'bar');
     77  assert_not_equals(barEncoding, undefined);
     78  assert_not_equals(barEncoding.active, false);
     79 }, 'Using the ~rid SDP syntax in a remote offer does not control the local encodings active flag');
     80 
     81 promise_test(async t => {
     82  const pc = new RTCPeerConnection();
     83  t.add_cleanup(() => pc.close());
     84  const expected_rids = ['foo', 'bar', 'baz'];
     85 
     86  await pc.setRemoteDescription({type: 'offer', sdp: offer_sdp});
     87  const transceiver = pc.getTransceivers()[0];
     88  transceiver.direction = 'sendonly';
     89  await pc.setLocalDescription();
     90 
     91  // Disabling the encoding should not change the rid to ~rid.
     92  const parameters = pc.getSenders()[0].getParameters();
     93  parameters.encodings.forEach(e => e.active = false);
     94  await pc.getSenders()[0].setParameters(parameters);
     95  const offer = await pc.createOffer();
     96 
     97  const offer_lines = offer.sdp.split('\r\n');
     98  const result = offer_lines.find(
     99      line => line.startsWith(`a=simulcast:send ${expected_rids.join(';')}`));
    100  assert_not_equals(result, undefined, 'Could not find simulcast attribute.');
    101 }, 'Disabling encodings locally does not change the SDP');
    102 </script>