Skip to content

Commit

Permalink
Implement and ship RTCRtpTransceiver.setCodecPreferences
Browse files Browse the repository at this point in the history
Intent thread: https://groups.google.com/a/chromium.org/d/msg/blink-dev/DRz-uHqPCLw/ZNDiwL0ZAwAJ

Bug: 891556
Change-Id: I3a851ca721f6ec29971e9a9ca76df1966a6b1ad1
  • Loading branch information
Orphis authored and chromium-wpt-export-bot committed May 3, 2019
1 parent 109fe36 commit b82d428
Showing 1 changed file with 58 additions and 11 deletions.
69 changes: 58 additions & 11 deletions webrtc/RTCRtpTransceiver-setCodecPreferences.html
Expand Up @@ -26,7 +26,7 @@
RTCRtpTransceiver on which the method is called. Additionally, the
RTCRtpCodecParameters dictionary members cannot be modified. If
codecs does not fulfill these requirements, the user agent MUST throw
an InvalidAccessError.
an InvalidModificationError.
*/

test(() => {
Expand Down Expand Up @@ -81,9 +81,23 @@
const pc = new RTCPeerConnection();
const transceiver = pc.addTransceiver('audio');
const capabilities = RTCRtpSender.getCapabilities('video');
assert_throws(() => transceiver.setCodecPreferences(capabilities.codecs));
assert_throws('InvalidModificationError', () => transceiver.setCodecPreferences(capabilities.codecs));

}, `setCodecPreferences() on audio transceiver with codecs returned from getCapabilities('video') should throw InvalidAccessError`);
}, `setCodecPreferences() on audio transceiver with codecs returned from getCapabilities('video') should throw InvalidModificationError`);

test(() => {
const pc = new RTCPeerConnection();
const transceiver = pc.addTransceiver('audio');
const codecs = [{
mimeType: 'data',
clockRate: 2000,
channels: 2,
sdpFmtpLine: '0-15'
}];

assert_throws('InvalidModificationError', () => transceiver.setCodecPreferences(codecs));

}, `setCodecPreferences() with user defined codec with invalid mimeType should throw InvalidModificationError`);

test(() => {
const pc = new RTCPeerConnection();
Expand All @@ -92,12 +106,12 @@
mimeType: 'audio/piepiper',
clockRate: 2000,
channels: 2,
sdpFmtpLine: 'a=fmtp:98 0-15'
sdpFmtpLine: '0-15'
}];

assert_throws(() => transceiver.setCodecPreferences(codecs));
assert_throws('InvalidModificationError', () => transceiver.setCodecPreferences(codecs));

}, `setCodecPreferences() with user defined codec should throw InvalidAccessError`);
}, `setCodecPreferences() with user defined codec should throw InvalidModificationError`);

test(() => {
const pc = new RTCPeerConnection();
Expand All @@ -109,12 +123,45 @@
mimeType: 'audio/piepiper',
clockRate: 2000,
channels: 2,
sdpFmtpLine: 'a=fmtp:98 0-15'
sdpFmtpLine: '0-15'
}];

assert_throws(() => transceiver.setCodecPreferences(codecs));
assert_throws('InvalidModificationError', () => transceiver.setCodecPreferences(codecs));

}, `setCodecPreferences() with user defined codec together with codecs returned from getCapabilities() should throw InvalidModificationError`);

test(() => {
const pc = new RTCPeerConnection();
const transceiver = pc.addTransceiver('audio');
const capabilities = RTCRtpSender.getCapabilities('audio');
const codecs = [capabilities.codecs[0]];
codecs[0].clockRate = codecs[0].clockRate / 2;

assert_throws('InvalidModificationError', () => transceiver.setCodecPreferences(codecs));

}, `setCodecPreferences() with modified codec clock rate should throw InvalidModificationError`);

test(() => {
const pc = new RTCPeerConnection();
const transceiver = pc.addTransceiver('audio');
const capabilities = RTCRtpSender.getCapabilities('audio');
const codecs = [capabilities.codecs[0]];
codecs[0].channels = codecs[0].channels + 11;

assert_throws('InvalidModificationError', () => transceiver.setCodecPreferences(codecs));

}, `setCodecPreferences() with modified codec channel count should throw InvalidModificationError`);

test(() => {
const pc = new RTCPeerConnection();
const transceiver = pc.addTransceiver('audio');
const capabilities = RTCRtpSender.getCapabilities('audio');
const codecs = [capabilities.codecs[0]];
codecs[0].sdpFmtpLine = "modifiedparameter=1";

assert_throws('InvalidModificationError', () => transceiver.setCodecPreferences(codecs));

}, `setCodecPreferences() with user defined codec together with codecs returned from getCapabilities() should throw InvalidAccessError`);
}, `setCodecPreferences() with modified codec parameters should throw InvalidModificationError`);

test(() => {
const pc = new RTCPeerConnection();
Expand All @@ -129,8 +176,8 @@
const { channels=2 } = codec;
codec.channels = channels+1;

assert_throws(() => transceiver.setCodecPreferences(codecs));
assert_throws('InvalidModificationError', () => transceiver.setCodecPreferences(codecs));

}, `setCodecPreferences() with modified codecs returned from getCapabilities() should throw InvalidAccessError`);
}, `setCodecPreferences() with modified codecs returned from getCapabilities() should throw InvalidModificationError`);

</script>

0 comments on commit b82d428

Please sign in to comment.