Skip to content

Commit

Permalink
Add tests for if codec info surfaces at the right time.
Browse files Browse the repository at this point in the history
In support of landing this spec PR:
w3c/webrtc-pc#2972

Bug: None
Change-Id: I698276ccf739a872d791fc0923c2725ec303fbd3
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/5642762
Commit-Queue: Harald Alvestrand <[email protected]>
Reviewed-by: Florent Castelli <[email protected]>
Cr-Commit-Position: refs/heads/main@{#1317347}
  • Loading branch information
alvestrand authored and sadym-chromium committed Jul 18, 2024
1 parent d20b639 commit 495533c
Show file tree
Hide file tree
Showing 2 changed files with 68 additions and 0 deletions.
28 changes: 28 additions & 0 deletions webrtc/RTCRtpReceiver-getParameters.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="dictionary-helper.js"></script>
<script src="RTCPeerConnection-helper.js"></script>
<script src="RTCRtpParameters-helper.js"></script>
<script>
'use strict';
Expand Down Expand Up @@ -70,4 +71,31 @@
assert_greater_than(param.headerExtensions.length, 0);
assert_greater_than(param.codecs.length, 0);
}, 'getParameters() with simulcast video receiver');

promise_test(async t => {
const stream = await getNoiseStream({video: true});
t.add_cleanup(() => stream.getTracks().forEach(track => track.stop()));
const [track] = stream.getTracks();
const caller = new RTCPeerConnection();
t.add_cleanup(() => caller.close());
caller.addTrack(track);
const callee = new RTCPeerConnection();
t.add_cleanup(() => callee.close());
callee.addTrack(track);
var callerReceiver = caller.getTransceivers()[0].receiver;
assert_equals(callerReceiver.getParameters().codecs.length, 0);
const offer = await caller.createOffer();
await caller.setLocalDescription(offer);
await callee.setRemoteDescription(offer);
var calleeReceiver = callee.getTransceivers()[0].receiver;
assert_equals(calleeReceiver.getParameters().codecs.length, 0);
const answer = await callee.createAnswer();
await callee.setLocalDescription(answer);
assert_greater_than(calleeReceiver.getParameters().codecs.length, 0,
"callee codecs after answer");
await caller.setRemoteDescription(answer);
assert_greater_than(callerReceiver.getParameters().codecs.length, 0,
"caller codecs after answer");
}, 'getParameters() surfaces codecs on two-way receiver at the right time');

</script>
40 changes: 40 additions & 0 deletions webrtc/RTCRtpSender-getParameters.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
<!doctype html>
<meta charset=utf-8>
<title>RTCRtpSender.prototype.getParameters</title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="dictionary-helper.js"></script>
<script src="RTCPeerConnection-helper.js"></script>
<script src="RTCRtpParameters-helper.js"></script>
<script>
'use strict';

promise_test(async t => {
const stream = await getNoiseStream({video: true});
t.add_cleanup(() => stream.getTracks().forEach(track => track.stop()));
const [track] = stream.getTracks();
const caller = new RTCPeerConnection();
t.add_cleanup(() => caller.close());
caller.addTrack(track);
const callee = new RTCPeerConnection();
t.add_cleanup(() => callee.close());
callee.addTrack(track);
var callerSender = caller.getTransceivers()[0].sender;
assert_equals(callerSender.getParameters().codecs.length, 0);
const offer = await caller.createOffer();
await caller.setLocalDescription(offer);
await callee.setRemoteDescription(offer);
// Check that it is a single 2-way transceiver.
assert_equals(callee.getTransceivers().length, 1);
var calleeSender = callee.getTransceivers()[0].sender;
assert_equals(calleeSender.getParameters().codecs.length, 0);
const answer = await callee.createAnswer();
await callee.setLocalDescription(answer);
assert_greater_than(calleeSender.getParameters().codecs.length, 0,
"callee codecs after answer");
await caller.setRemoteDescription(answer);
assert_greater_than(callerSender.getParameters().codecs.length, 0,
"caller codecs after answer");
}, 'getParameters() surfaces codecs on two-way sender with addTrack at the right time');

</script>

0 comments on commit 495533c

Please sign in to comment.