| <!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> |