tor-browser

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

webrtc-test-helpers.sub.js (2617B)


      1 // SDP copied from JSEP Example 7.1
      2 // It contains two media streams with different ufrags
      3 // to test if candidate is added to the correct stream
      4 const sdp = `v=0
      5 o=- 4962303333179871722 1 IN IP4 0.0.0.0
      6 s=-
      7 t=0 0
      8 a=ice-options:trickle
      9 a=group:BUNDLE a1 v1
     10 a=group:LS a1 v1
     11 m=audio 10100 UDP/TLS/RTP/SAVPF 96 0 8 97 98
     12 c=IN IP4 203.0.113.100
     13 a=mid:a1
     14 a=sendrecv
     15 a=rtpmap:96 opus/48000/2
     16 a=rtpmap:0 PCMU/8000
     17 a=rtpmap:8 PCMA/8000
     18 a=rtpmap:97 telephone-event/8000
     19 a=rtpmap:98 telephone-event/48000
     20 a=maxptime:120
     21 a=extmap:1 urn:ietf:params:rtp-hdrext:sdes:mid
     22 a=extmap:2 urn:ietf:params:rtp-hdrext:ssrc-audio-level
     23 a=msid:47017fee-b6c1-4162-929c-a25110252400 f83006c5-a0ff-4e0a-9ed9-d3e6747be7d9
     24 a=ice-ufrag:ETEn
     25 a=ice-pwd:OtSK0WpNtpUjkY4+86js7ZQl
     26 a=fingerprint:sha-256 19:E2:1C:3B:4B:9F:81:E6:B8:5C:F4:A5:A8:D8:73:04:BB:05:2F:70:9F:04:A9:0E:05:E9:26:33:E8:70:88:A2
     27 a=setup:actpass
     28 a=dtls-id:1
     29 a=rtcp:10101 IN IP4 203.0.113.100
     30 a=rtcp-mux
     31 a=rtcp-rsize
     32 m=video 10102 UDP/TLS/RTP/SAVPF 100 101
     33 c=IN IP4 203.0.113.100
     34 a=mid:v1
     35 a=sendrecv
     36 a=rtpmap:100 VP8/90000
     37 a=rtpmap:101 rtx/90000
     38 a=fmtp:101 apt=100
     39 a=extmap:1 urn:ietf:params:rtp-hdrext:sdes:mid
     40 a=rtcp-fb:100 ccm fir
     41 a=rtcp-fb:100 nack
     42 a=rtcp-fb:100 nack pli
     43 a=msid:47017fee-b6c1-4162-929c-a25110252400 f30bdb4a-5db8-49b5-bcdc-e0c9a23172e0
     44 a=ice-ufrag:BGKk
     45 a=ice-pwd:mqyWsAjvtKwTGnvhPztQ9mIf
     46 a=fingerprint:sha-256 19:E2:1C:3B:4B:9F:81:E6:B8:5C:F4:A5:A8:D8:73:04:BB:05:2F:70:9F:04:A9:0E:05:E9:26:33:E8:70:88:A2
     47 a=setup:actpass
     48 a=dtls-id:1
     49 a=rtcp:10103 IN IP4 203.0.113.100
     50 a=rtcp-mux
     51 a=rtcp-rsize
     52 `;
     53 
     54 const sessionDesc = { type: 'offer', sdp };
     55 const candidate = {
     56  candidate: 'candidate:1 1 udp 2113929471 203.0.113.100 10100 typ host',
     57  sdpMid: 'a1',
     58  sdpMLineIndex: 0,
     59  usernameFragment: 'ETEn'
     60 };
     61 
     62 // Opens a new WebRTC connection.
     63 async function openWebRTC(remoteContextHelper) {
     64  await remoteContextHelper.executeScript(async (sessionDesc, candidate) => {
     65    window.testRTCPeerConnection = new RTCPeerConnection();
     66    await window.testRTCPeerConnection.setRemoteDescription(sessionDesc);
     67    await window.testRTCPeerConnection.addIceCandidate(candidate);
     68  }, [sessionDesc, candidate]);
     69 }
     70 
     71 // Opens a new WebRTC connection and then close it.
     72 async function openThenCloseWebRTC(remoteContextHelper) {
     73  await remoteContextHelper.executeScript(async (sessionDesc, candidate) => {
     74    window.testRTCPeerConnection = new RTCPeerConnection();
     75    await window.testRTCPeerConnection.setRemoteDescription(sessionDesc);
     76    await window.testRTCPeerConnection.addIceCandidate(candidate);
     77    window.testRTCPeerConnection.close();
     78  }, [sessionDesc, candidate]);
     79 }