DXR is a code search and navigation tool aimed at making sense of large projects. It supports full-text and regex searches as well as structural queries.

Mercurial (2aa33873a0c7)

VCS Links

Line Code
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87
<!doctype html>
<meta charset=utf-8>
<title>RTCRtpParameters degradationPreference</title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="dictionary-helper.js"></script>
<script src="RTCRtpParameters-helper.js"></script>
<script>
  'use strict';

  // Test is based on the following editor draft:
  // https://w3c.github.io/webrtc-pc/archives/20170605/webrtc.html

  // The following helper functions are called from RTCRtpParameters-helper.js:
  //   validateSenderRtpParameters

  /*
    5.2.  RTCRtpSender Interface
      interface RTCRtpSender {
        Promise<void>           setParameters(optional RTCRtpParameters parameters);
        RTCRtpParameters        getParameters();
      };

      dictionary RTCRtpParameters {
        DOMString                                 transactionId;
        sequence<RTCRtpEncodingParameters>        encodings;
        sequence<RTCRtpHeaderExtensionParameters> headerExtensions;
        RTCRtcpParameters                         rtcp;
        sequence<RTCRtpCodecParameters>           codecs;
        RTCDegradationPreference                  degradationPreference;
      };

      enum RTCDegradationPreference {
        "maintain-framerate",
        "maintain-resolution",
        "balanced"
      };

      - degradationPreference is set to the last value passed into setParameters,
        or the default value of "balanced" if setParameters hasn't been called.
   */

  promise_test(t => {
    const pc = new RTCPeerConnection();
    t.add_cleanup(() => pc.close());
    const { sender } = pc.addTransceiver('audio');

    const param = sender.getParameters();
    validateSenderRtpParameters(param);

    assert_equals(param.degradationPreference, 'balanced',
      'Expect initial param.degradationPreference to be balanced');

    param.degradationPreference = 'maintain-framerate';

    return pc.setParameters(param)
    .then(() => {
      const param = sender.getParameters();
      validateSenderRtpParameters(param);

      assert_equals(param.degradationPreference, 'maintain-framerate');
    });
  }, 'setParameters with degradationPreference set should succeed');

  promise_test(t => {
    const pc = new RTCPeerConnection();
    t.add_cleanup(() => pc.close());
    const { sender } = pc.addTransceiver('audio');

    const param = sender.getParameters();
    validateSenderRtpParameters(param);

    assert_equals(param.degradationPreference, 'balanced',
      'Expect initial param.degradationPreference to be balanced');

    param.degradationPreference = undefined;

    return pc.setParameters(param)
    .then(() => {
      const param = sender.getParameters();
      validateSenderRtpParameters(param);

      assert_equals(param.degradationPreference, undefined);
    });
  }, 'setParameters with degradationPreference unset should succeed');

</script>