Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
youennf authored and Gabisampaio committed Nov 18, 2021
1 parent ab81027 commit 1c31ac5
Show file tree
Hide file tree
Showing 9 changed files with 50 additions and 24 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,9 @@
t.add_cleanup(() => pc1.close());
const pc2 = new RTCPeerConnection();
t.add_cleanup(() => pc2.close());
pc1.addTransceiver('audio', { direction: 'recvonly' });
await initialOfferAnswerWithIceGatheringStateTransitions(
pc1, pc2, {offerToReceiveAudio: true});
pc1, pc2);
await pc1.setLocalDescription(await pc1.createOffer({iceRestart: true}));
await iceGatheringStateTransitions(pc1, 'gathering', 'complete');
expectNoMoreGatheringStateChanges(t, pc1);
Expand All @@ -24,8 +25,9 @@
promise_test(async t => {
const pc = new RTCPeerConnection();
t.add_cleanup(() => pc.close());
pc.addTransceiver('audio', { direction: 'recvonly' });
await pc.setLocalDescription(
await pc.createOffer({offerToReceiveAudio: true}));
await pc.createOffer());
await iceGatheringStateTransitions(pc, 'gathering', 'complete');
await pc.setLocalDescription({type: 'rollback'});
await iceGatheringStateTransitions(pc, 'new');
Expand All @@ -34,8 +36,9 @@
promise_test(async t => {
const pc = new RTCPeerConnection();
t.add_cleanup(() => pc.close());
pc.addTransceiver('audio', { direction: 'recvonly' });
await pc.setLocalDescription(
await pc.createOffer({offerToReceiveAudio: true}));
await pc.createOffer());
await iceGatheringStateTransitions(pc, 'gathering');
await pc.setLocalDescription({type: 'rollback'});
// We might go directly to 'new', or we might go to 'complete' first,
Expand Down
12 changes: 8 additions & 4 deletions webrtc/RTCPeerConnection-iceGatheringState.html
Original file line number Diff line number Diff line change
Expand Up @@ -91,8 +91,9 @@
t.add_cleanup(() => pc1.close());
const pc2 = new RTCPeerConnection();
t.add_cleanup(() => pc2.close());
pc1.addTransceiver('audio', { direction: 'recvonly' });
await initialOfferAnswerWithIceGatheringStateTransitions(
pc1, pc2, {offerToReceiveAudio: true});
pc1, pc2);

expectNoMoreGatheringStateChanges(t, pc1);
expectNoMoreGatheringStateChanges(t, pc2);
Expand All @@ -119,8 +120,9 @@
t.add_cleanup(() => pc1.close());
const pc2 = new RTCPeerConnection();
t.add_cleanup(() => pc2.close());
pc1.addTransceiver('audio', { direction: 'recvonly' });
await initialOfferAnswerWithIceGatheringStateTransitions(
pc1, pc2, {offerToReceiveAudio:true});
pc1, pc2);
await pc1.setLocalDescription(await pc1.createOffer({iceRestart: true}));
await iceGatheringStateTransitions(pc1, 'gathering', 'complete');
}, 'setLocalDescription(reoffer) with a new transport should cause iceGatheringState to go to "checking" and then "complete"');
Expand All @@ -131,7 +133,8 @@
const pc2 = new RTCPeerConnection();
t.add_cleanup(() => pc2.close());
expectNoMoreGatheringStateChanges(t, pc2);
const offer = await pc1.createOffer({offerToReceiveAudio: true});
pc1.addTransceiver('audio', { direction: 'recvonly' });
const offer = await pc1.createOffer();
await pc2.setRemoteDescription(offer);
await pc2.setRemoteDescription(offer);
await pc2.setRemoteDescription({type: 'rollback'});
Expand All @@ -143,8 +146,9 @@
t.add_cleanup(() => pc1.close());
const pc2 = new RTCPeerConnection();
t.add_cleanup(() => pc2.close());
pc1.addTransceiver('audio', { direction: 'recvonly' });
await initialOfferAnswerWithIceGatheringStateTransitions(
pc1, pc2, {offerToReceiveAudio: true});
pc1, pc2);

const pc1waiter = iceGatheringStateTransitions(pc1, 'new');
const pc2waiter = iceGatheringStateTransitions(pc2, 'new');
Expand Down
9 changes: 6 additions & 3 deletions webrtc/RTCPeerConnection-setLocalDescription-answer.html
Original file line number Diff line number Diff line change
Expand Up @@ -177,11 +177,13 @@
const pc2 = new RTCPeerConnection();
t.add_cleanup(() => pc2.close());

const offer = await pc1.createOffer({offerToReceiveAudio: true});
pc1.addTransceiver('audio', { direction: 'recvonly' });
const offer = await pc1.createOffer();
await pc2.setRemoteDescription(offer);
const answer = await pc2.createAnswer(); // [[LastAnswer]] slot set
await pc2.setRemoteDescription({type: "rollback"});
await pc2.createOffer({offerToReceiveVideo: true}); // [[LastOffer]] slot set
pc2.addTransceiver('video', { direction: 'recvonly' });
await pc2.createOffer(); // [[LastOffer]] slot set
await pc2.setRemoteDescription(offer);
await pc2.setLocalDescription(answer); // Should check against [[LastAnswer]], not [[LastOffer]]
}, "Setting previously generated answer after a call to createOffer should work");
Expand All @@ -192,7 +194,8 @@
const pc2 = new RTCPeerConnection();
t.add_cleanup(() => pc2.close());

await pc2.setRemoteDescription(await pc1.createOffer({offerToReceiveAudio: true}));
pc1.addTransceiver('audio', { direction: 'recvonly' });
await pc2.setRemoteDescription(await pc1.createOffer());
const answer = await pc2.createAnswer();
const sldPromise = pc2.setLocalDescription(answer);

Expand Down
12 changes: 8 additions & 4 deletions webrtc/RTCPeerConnection-setLocalDescription-offer.html
Original file line number Diff line number Diff line change
Expand Up @@ -163,8 +163,10 @@
const pc2 = new RTCPeerConnection();
t.add_cleanup(() => pc2.close());

const offer = await pc1.createOffer({offerToReceiveAudio: true}); // [[LastOffer]] set
const offer2 = await pc2.createOffer({offerToReceiveVideo: true});
pc1.addTransceiver('audio', { direction: 'recvonly' });
const offer = await pc1.createOffer(); // [[LastOffer]] set
pc2.addTransceiver('video', { direction: 'recvonly' });
const offer2 = await pc2.createOffer();
await pc1.setRemoteDescription(offer2);
await pc1.createAnswer(); // [[LastAnswer]] set
await pc1.setRemoteDescription({type: "rollback"});
Expand All @@ -177,7 +179,8 @@
const pc2 = new RTCPeerConnection();
t.add_cleanup(() => pc2.close());

await pc1.setLocalDescription(await pc1.createOffer({offerToReceiveAudio: true}));
pc1.addTransceiver('audio', { direction: 'recvonly' });
await pc1.setLocalDescription(await pc1.createOffer());

const offer = await pc1.createOffer();
await pc1.setLocalDescription(offer);
Expand All @@ -196,7 +199,8 @@
const pc = new RTCPeerConnection();
t.add_cleanup(() => pc.close());

const sldPromise = pc.setLocalDescription(await pc.createOffer({offerToReceiveAudio: true}));
pc.addTransceiver('audio', { direction: 'recvonly' });
const sldPromise = pc.setLocalDescription(await pc.createOffer());

assert_equals(pc.signalingState, "stable", "signalingState should not be set synchronously after a call to sLD");

Expand Down
3 changes: 2 additions & 1 deletion webrtc/RTCPeerConnection-setLocalDescription-rollback.html
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,8 @@
const pc = new RTCPeerConnection();
t.add_cleanup(() => pc.close());

await pc.setLocalDescription(await pc.createOffer({offerToReceiveAudio: true}));
pc.addTransceiver('audio', { direction: 'recvonly' });
await pc.setLocalDescription(await pc.createOffer());
const sldPromise = pc.setLocalDescription({type: "rollback"});

assert_equals(pc.signalingState, "have-local-offer", "signalingState should not be set synchronously after a call to sLD");
Expand Down
9 changes: 6 additions & 3 deletions webrtc/RTCPeerConnection-setRemoteDescription-offer.html
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,8 @@
const pc2 = new RTCPeerConnection();
t.add_cleanup(() => pc2.close());

const srdPromise = pc2.setRemoteDescription(await pc1.createOffer({offerToReceiveAudio: true}));
pc1.addTransceiver('audio', { direction: 'recvonly' });
const srdPromise = pc2.setRemoteDescription(await pc1.createOffer());

assert_equals(pc2.signalingState, "stable", "signalingState should not be set synchronously after a call to sRD");

Expand Down Expand Up @@ -222,10 +223,12 @@
const pc2 = new RTCPeerConnection();
t.add_cleanup(() => pc2.close());

await pc2.setLocalDescription(await pc2.createOffer({offerToReceiveAudio: true}));
pc2.addTransceiver('audio', { direction: 'recvonly' });
await pc2.setLocalDescription(await pc2.createOffer());

// Implicit rollback!
const srdPromise = pc2.setRemoteDescription(await pc1.createOffer({offerToReceiveAudio: true}));
pc1.addTransceiver('audio', { direction: 'recvonly' });
const srdPromise = pc2.setRemoteDescription(await pc1.createOffer());

assert_equals(pc2.signalingState, "have-local-offer", "signalingState should not be set synchronously after a call to sRD");

Expand Down
10 changes: 7 additions & 3 deletions webrtc/RTCPeerConnection-setRemoteDescription-rollback.html
Original file line number Diff line number Diff line change
Expand Up @@ -121,10 +121,12 @@
t.add_cleanup(() => pc2.close());

// We don't use this right away
const offer1 = await pc1.createOffer({offerToReceiveAudio: true});
pc1.addTransceiver('audio', { direction: 'recvonly' });
const offer1 = await pc1.createOffer();

// Create offer from pc2, apply and rollback on pc1
const offer2 = await pc2.createOffer({offerToReceiveAudio: true});
pc2.addTransceiver('audio', { direction: 'recvonly' });
const offer2 = await pc2.createOffer();
await pc1.setRemoteDescription(offer2);
await pc1.setRemoteDescription({type: "rollback"});

Expand All @@ -147,7 +149,9 @@
const offer1 = await pc1.createOffer();

// Create offer from pc2, apply and rollback on pc1
const offer2 = await pc2.createOffer({offerToReceiveAudio: true, offerToReceiveVideo: true});
pc2.addTransceiver('audio', { direction: 'recvonly' });
pc2.addTransceiver('video', { direction: 'recvonly' });
const offer2 = await pc2.createOffer();
// pc1 now should change its mind about what level its video transceiver is
// bound to. It was 0, now it is 1.
await pc1.setRemoteDescription(offer2);
Expand Down
6 changes: 4 additions & 2 deletions webrtc/RTCPeerConnection-transceivers.https.html
Original file line number Diff line number Diff line change
Expand Up @@ -479,7 +479,8 @@
.then((offer) => { return pc1.setRemoteDescription(offer); })
.then(() => { return pc1.createAnswer(); })
.then((answer) => { return pc1.setLocalDescription(answer); });
const pc1Promise = pc1.createOffer({ offerToReceiveAudio: true})
pc1.addTransceiver('audio', { direction: 'recvonly' });
const pc1Promise = pc1.createOffer()
.then(() => { pc1.addTrack(pc1.getReceivers()[0].track); });
await Promise.all([pc1Promise, pc2Promise]);
assert_equals(pc1.getSenders()[0].track, pc1.getReceivers()[0].track);
Expand All @@ -494,7 +495,8 @@
const pc2Promise = pc2.createOffer()
.then((offer) => { return pc1.setRemoteDescription(offer); })
.then(() => { return pc1.createAnswer(); });
const pc1Promise = pc1.createOffer({ offerToReceiveAudio: true})
pc1.addTransceiver('audio', { direction: 'recvonly' });
const pc1Promise = pc1.createOffer()
.then(() => { pc1.getTransceivers()[0].direction = 'inactive'; });
await Promise.all([pc1Promise, pc2Promise]);
assert_equals(pc1.getTransceivers()[0].direction, 'inactive');
Expand Down
4 changes: 3 additions & 1 deletion webrtc/protocol/RTCPeerConnection-payloadTypes.html
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,9 @@
const pc1 = new RTCPeerConnection();
t.add_cleanup(() => pc1.close());

const offer = await pc1.createOffer({offerToReceiveAudio: true, offerToReceiveVideo: true});
pc1.addTransceiver('audio', { direction: 'recvonly' });
pc1.addTransceiver('video', { direction: 'recvonly' });
const offer = await pc1.createOffer();

// Extract all payload types from the m= lines.
const payloadTypes = offer.sdp.split('\n')
Expand Down

0 comments on commit 1c31ac5

Please sign in to comment.