From 3aec2cfd4518eb67841842fe09d92efc2d6b30d9 Mon Sep 17 00:00:00 2001 From: Lukas Herman Date: Mon, 18 May 2020 14:45:09 -0400 Subject: [PATCH] Replace old APIs with explicit addTransceivers --- examples/master.js | 9 +++------ examples/viewer.js | 9 +++------ 2 files changed, 6 insertions(+), 12 deletions(-) diff --git a/examples/master.js b/examples/master.js index 359af16..70f5bad 100644 --- a/examples/master.js +++ b/examples/master.js @@ -169,12 +169,9 @@ async function startMaster(localView, remoteView, formValues, onStatsReport, onR // Create an SDP answer to send back to the client console.log('[MASTER] Creating SDP answer for client: ' + remoteClientId); - await peerConnection.setLocalDescription( - await peerConnection.createAnswer({ - offerToReceiveAudio: true, - offerToReceiveVideo: true, - }), - ); + peerConnection.addTransceiver('video', {'direction': formValues.sendVideo ? 'sendrecv' : 'recvonly'}); + peerConnection.addTransceiver('audio', {'direction': formValues.sendAudio ? 'sendrecv' : 'recvonly'}); + await peerConnection.setLocalDescription(await peerConnection.createAnswer()); // When trickle ICE is enabled, send the answer now and then send ICE candidates as they are generated. Otherwise wait on the ICE candidates. if (formValues.useTrickleICE) { diff --git a/examples/viewer.js b/examples/viewer.js index c9cfc89..bb9f3f9 100644 --- a/examples/viewer.js +++ b/examples/viewer.js @@ -122,12 +122,9 @@ async function startViewer(localView, remoteView, formValues, onStatsReport, onR // Create an SDP offer to send to the master console.log('[VIEWER] Creating SDP offer'); - await viewer.peerConnection.setLocalDescription( - await viewer.peerConnection.createOffer({ - offerToReceiveAudio: true, - offerToReceiveVideo: true, - }), - ); + viewer.peerConnection.addTransceiver('video', {'direction': formValues.sendVideo ? 'sendrecv' : 'recvonly'}); + viewer.peerConnection.addTransceiver('audio', {'direction': formValues.sendAudio ? 'sendrecv' : 'recvonly'}); + await viewer.peerConnection.setLocalDescription(await viewer.peerConnection.createOffer()); // When trickle ICE is enabled, send the offer now and then send ICE candidates as they are generated. Otherwise wait on the ICE candidates. if (formValues.useTrickleICE) {