tor-browser

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

RTCRtpCapabilities-helper.js (1515B)


      1 'use strict'
      2 
      3 // Test is based on the following editor draft:
      4 // https://w3c.github.io/webrtc-pc/archives/20170605/webrtc.html
      5 
      6 // This file depends on dictionary-helper.js which should
      7 // be loaded from the main HTML file.
      8 
      9 /*
     10  5.2.  RTCRtpSender Interface
     11    dictionary RTCRtpCapabilities {
     12      sequence<RTCRtpCodecCapability>           codecs;
     13      sequence<RTCRtpHeaderExtensionCapability> headerExtensions;
     14    };
     15 
     16    dictionary RTCRtpCodecCapability {
     17      DOMString      mimeType;
     18      unsigned long  clockRate;
     19      unsigned short channels;
     20      DOMString      sdpFmtpLine;
     21    };
     22 
     23    dictionary RTCRtpHeaderExtensionCapability {
     24      DOMString uri;
     25    };
     26 */
     27 
     28 function validateRtpCapabilities(capabilities) {
     29  assert_array_field(capabilities, 'codecs');
     30  for(const codec of capabilities.codecs) {
     31    validateCodecCapability(codec);
     32  }
     33 
     34  assert_greater_than(capabilities.codecs.length, 0,
     35    'Expect at least one codec capability available');
     36 
     37  assert_array_field(capabilities, 'headerExtensions');
     38  for(const headerExt of capabilities.headerExtensions) {
     39    validateHeaderExtensionCapability(headerExt);
     40  }
     41 }
     42 
     43 function validateCodecCapability(codec) {
     44  assert_optional_string_field(codec, 'mimeType');
     45  assert_optional_unsigned_int_field(codec, 'clockRate');
     46  assert_optional_unsigned_int_field(codec, 'channels');
     47  assert_optional_string_field(codec, 'sdpFmtpLine');
     48 }
     49 
     50 function validateHeaderExtensionCapability(headerExt) {
     51  assert_optional_string_field(headerExt, 'uri');
     52 }