Skip to content

Commit

Permalink
Use addTransceiver and if failing, fall back to offerToReceiveVideo
Browse files Browse the repository at this point in the history
  • Loading branch information
youennf committed Nov 4, 2018
1 parent ead3edf commit c3be323
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
10 changes: 10 additions & 0 deletions webrtc/RTCPeerConnection-helper.js
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,16 @@ function generateOffer(options={}) {
});
}

async function generateVideoReceiveOnlyOffer(pc)
{
try {
pc.addTransceiver('video', { direction: 'recvonly' });
return pc.createOffer();
} catch(e) {
return pc.createOffer({ offerToReceiveVideo: true });
}
}

// Helper function to generate answer based on given offer using a freshly
// created RTCPeerConnection object
function generateAnswer(offer) {
Expand Down
4 changes: 2 additions & 2 deletions webrtc/no-media-call.html
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ <h2>iceConnectionState info</h2>
<!-- These files are in place when executing on W3C. -->
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="/webrtc/RTCPeerConnection-helper.js"></script>
<script type="text/javascript">
var test = async_test('Can set up a basic WebRTC call with no data.');

Expand Down Expand Up @@ -125,8 +126,7 @@ <h2>iceConnectionState info</h2>

// The offerToReceiveVideo is necessary and sufficient to make
// an actual connection.
gFirstConnection.addTransceiver('video', { direction: 'recvonly' });
gFirstConnection.createOffer()
generateVideoReceiveOnlyOffer(gFirstConnection)
.then(onOfferCreated, failed('createOffer'));
});
</script>
Expand Down

0 comments on commit c3be323

Please sign in to comment.