From eae294707f8b7d7f013862ae98f0d69f85eaf60c Mon Sep 17 00:00:00 2001 From: Lorenzo Miniero Date: Thu, 17 Feb 2022 17:34:48 +0100 Subject: [PATCH] Remove distinction between simulcast and simulcast2 in janus.js (#2887) --- html/canvas.js | 2 -- html/devicetest.js | 2 -- html/e2etest.js | 2 -- html/echotest.js | 2 -- html/janus.js | 27 +++++++++++---------------- html/multiopus.js | 2 -- html/mvideoroomtest.js | 2 -- html/recordplaytest.js | 1 - html/videocalltest.js | 1 - html/videoroomtest.js | 2 -- 10 files changed, 11 insertions(+), 32 deletions(-) diff --git a/html/canvas.js b/html/canvas.js index f2c4fb333d..d48f584c9e 100644 --- a/html/canvas.js +++ b/html/canvas.js @@ -60,7 +60,6 @@ var audioenabled = false; var videoenabled = false; var doSimulcast = (getQueryStringValue("simulcast") === "yes" || getQueryStringValue("simulcast") === "true"); -var doSimulcast2 = (getQueryStringValue("simulcast2") === "yes" || getQueryStringValue("simulcast2") === "true"); var acodec = (getQueryStringValue("acodec") !== "" ? getQueryStringValue("acodec") : null); var vcodec = (getQueryStringValue("vcodec") !== "" ? getQueryStringValue("vcodec") : null); var vprofile = (getQueryStringValue("vprofile") !== "" ? getQueryStringValue("vprofile") : null); @@ -465,7 +464,6 @@ function createCanvas() { // pass a ?simulcast=true when opening this demo page: it will turn // the following 'simulcast' property to pass to janus.js to true simulcast: doSimulcast, - simulcast2: doSimulcast2, success: function(jsep) { Janus.debug("Got SDP!", jsep); echotest.send({ message: body, jsep: jsep }); diff --git a/html/devicetest.js b/html/devicetest.js index 893c138963..634f9ca3a8 100644 --- a/html/devicetest.js +++ b/html/devicetest.js @@ -64,7 +64,6 @@ var audioenabled = false; var videoenabled = false; var doSimulcast = (getQueryStringValue("simulcast") === "yes" || getQueryStringValue("simulcast") === "true"); -var doSimulcast2 = (getQueryStringValue("simulcast2") === "yes" || getQueryStringValue("simulcast2") === "true"); var acodec = (getQueryStringValue("acodec") !== "" ? getQueryStringValue("acodec") : null); var vcodec = (getQueryStringValue("vcodec") !== "" ? getQueryStringValue("vcodec") : null); var vprofile = (getQueryStringValue("vprofile") !== "" ? getQueryStringValue("vprofile") : null); @@ -175,7 +174,6 @@ function restartCapture() { // pass a ?simulcast=true when opening this demo page: it will turn // the following 'simulcast' property to pass to janus.js to true simulcast: doSimulcast, - simulcast2: doSimulcast2, success: function(jsep) { Janus.debug("Got SDP!", jsep); echotest.send({ message: body, jsep: jsep }); diff --git a/html/e2etest.js b/html/e2etest.js index 68ba97dd9b..db5b2195ca 100644 --- a/html/e2etest.js +++ b/html/e2etest.js @@ -61,7 +61,6 @@ var audioenabled = false; var videoenabled = false; var doSimulcast = (getQueryStringValue("simulcast") === "yes" || getQueryStringValue("simulcast") === "true"); -var doSimulcast2 = (getQueryStringValue("simulcast2") === "yes" || getQueryStringValue("simulcast2") === "true"); var acodec = (getQueryStringValue("acodec") !== "" ? getQueryStringValue("acodec") : null); var vcodec = (getQueryStringValue("vcodec") !== "" ? getQueryStringValue("vcodec") : null); var simulcastStarted = false; @@ -643,7 +642,6 @@ function promptCryptoKey() { // pass a ?simulcast=true when opening this demo page: it will turn // the following 'simulcast' property to pass to janus.js to true. simulcast: doSimulcast, - simulcast2: doSimulcast2, // Since we want to use Insertable Streams, // we specify the transform functions to use senderTransforms: senderTransforms, diff --git a/html/echotest.js b/html/echotest.js index f1a058b18c..d04aec1584 100644 --- a/html/echotest.js +++ b/html/echotest.js @@ -61,7 +61,6 @@ var audioenabled = false; var videoenabled = false; var doSimulcast = (getQueryStringValue("simulcast") === "yes" || getQueryStringValue("simulcast") === "true"); -var doSimulcast2 = (getQueryStringValue("simulcast2") === "yes" || getQueryStringValue("simulcast2") === "true"); var doSvc = getQueryStringValue("svc"); if(doSvc === "") doSvc = null; @@ -132,7 +131,6 @@ $(document).ready(function() { // pass a ?simulcast=true when opening this demo page: it will turn // the following 'simulcast' property to pass to janus.js to true simulcast: doSimulcast, - simulcast2: doSimulcast2, svc: (vcodec === 'av1' && doSvc) ? doSvc : null, customizeSdp: function(jsep) { // If DTX is enabled, munge the SDP diff --git a/html/janus.js b/html/janus.js index 2ee3189a86..cf682d6559 100644 --- a/html/janus.js +++ b/html/janus.js @@ -1978,14 +1978,14 @@ function Janus(gatewayCallbacks) { } if(addTracks && stream) { Janus.log('Adding local stream'); - var simulcast2 = (callbacks.simulcast2 === true); + var simulcast = (callbacks.simulcast === true || callbacks.simulcast2 === true) && Janus.unifiedPlan; var svc = callbacks.svc; stream.getTracks().forEach(function(track) { Janus.log('Adding local track:', track); var sender = null; - if((!simulcast2 && !svc) || track.kind === 'audio') { + if((!simulcast && !svc) || track.kind === 'audio') { sender = config.pc.addTrack(track, stream); - } else if(simulcast2) { + } else if(simulcast) { Janus.log('Enabling rid-based simulcasting:', track); let maxBitrates = getMaxBitrates(callbacks.simulcastMaxBitrates); let tr = config.pc.addTransceiver(track, { @@ -2353,10 +2353,9 @@ function Janus(gatewayCallbacks) { audioSupport = media.audio; var videoSupport = isVideoSendEnabled(media); if(videoSupport && media) { - var simulcast = (callbacks.simulcast === true); - var simulcast2 = (callbacks.simulcast2 === true); + var simulcast = (callbacks.simulcast === true || callbacks.simulcast2 === true); var svc = callbacks.svc; - if((simulcast || simulcast2 || svc) && !jsep && !media.video) + if((simulcast || svc) && !jsep && !media.video) media.video = "hires"; if(media.video && media.video != 'screen' && media.video != 'window') { if(typeof media.video === 'object') { @@ -2678,7 +2677,7 @@ function Janus(gatewayCallbacks) { return; } var config = pluginHandle.webrtcStuff; - var simulcast = (callbacks.simulcast === true); + var simulcast = (callbacks.simulcast === true || callbacks.simulcast2 === true); if(!simulcast) { Janus.log("Creating offer (iceDone=" + config.iceDone + ")"); } else { @@ -2845,14 +2844,12 @@ function Janus(gatewayCallbacks) { callbacks.customizeSdp(jsep); offer.sdp = jsep.sdp; Janus.log("Setting local description"); - if(sendVideo && simulcast) { - // This SDP munging only works with Chrome (Safari STP may support it too) + if(sendVideo && simulcast && !Janus.unifiedPlan) { + // We only do simulcast via SDP munging on older versions of Chrome and Safari if(Janus.webRTCAdapter.browserDetails.browser === "chrome" || Janus.webRTCAdapter.browserDetails.browser === "safari") { Janus.log("Enabling Simulcasting for Chrome (SDP munging)"); offer.sdp = mungeSdpForSimulcasting(offer.sdp); - } else if(Janus.webRTCAdapter.browserDetails.browser !== "firefox") { - Janus.warn("simulcast=true, but this is not Chrome nor Firefox, ignoring"); } } config.mySdp = { @@ -2887,7 +2884,7 @@ function Janus(gatewayCallbacks) { return; } var config = pluginHandle.webrtcStuff; - var simulcast = (callbacks.simulcast === true); + var simulcast = (callbacks.simulcast === true || callbacks.simulcast2 === true); if(!simulcast) { Janus.log("Creating answer (iceDone=" + config.iceDone + ")"); } else { @@ -3088,15 +3085,13 @@ function Janus(gatewayCallbacks) { callbacks.customizeSdp(jsep); answer.sdp = jsep.sdp; Janus.log("Setting local description"); - if(sendVideo && simulcast) { - // This SDP munging only works with Chrome + if(sendVideo && simulcast && !Janus.unifiedPlan) { + // We only do simulcast via SDP munging on older versions of Chrome and Safari if(Janus.webRTCAdapter.browserDetails.browser === "chrome") { // FIXME Apparently trying to simulcast when answering breaks video in Chrome... //~ Janus.log("Enabling Simulcasting for Chrome (SDP munging)"); //~ answer.sdp = mungeSdpForSimulcasting(answer.sdp); Janus.warn("simulcast=true, but this is an answer, and video breaks in Chrome if we enable it"); - } else if(Janus.webRTCAdapter.browserDetails.browser !== "firefox") { - Janus.warn("simulcast=true, but this is not Chrome nor Firefox, ignoring"); } } config.mySdp = { diff --git a/html/multiopus.js b/html/multiopus.js index e41b5d9653..3e29c84ccd 100644 --- a/html/multiopus.js +++ b/html/multiopus.js @@ -60,7 +60,6 @@ var audioenabled = false; var videoenabled = false; var doSimulcast = (getQueryStringValue("simulcast") === "yes" || getQueryStringValue("simulcast") === "true"); -var doSimulcast2 = (getQueryStringValue("simulcast2") === "yes" || getQueryStringValue("simulcast2") === "true"); var acodec = "multiopus"; var vcodec = (getQueryStringValue("vcodec") !== "" ? getQueryStringValue("vcodec") : null); var vprofile = (getQueryStringValue("vprofile") !== "" ? getQueryStringValue("vprofile") : null); @@ -139,7 +138,6 @@ $(document).ready(function() { // pass a ?simulcast=true when opening this demo page: it will turn // the following 'simulcast' property to pass to janus.js to true simulcast: doSimulcast, - simulcast2: doSimulcast2, customizeSdp(jsep) { // Offer multiopus jsep.sdp = jsep.sdp diff --git a/html/mvideoroomtest.js b/html/mvideoroomtest.js index 5d47349ae1..cfcebc1f5a 100644 --- a/html/mvideoroomtest.js +++ b/html/mvideoroomtest.js @@ -67,7 +67,6 @@ var localTracks = {}, localVideos = 0, remoteTracks = {}; var bitrateTimer = [], simulcastStarted = {}; var doSimulcast = (getQueryStringValue("simulcast") === "yes" || getQueryStringValue("simulcast") === "true"); -var doSimulcast2 = (getQueryStringValue("simulcast2") === "yes" || getQueryStringValue("simulcast2") === "true"); var acodec = (getQueryStringValue("acodec") !== "" ? getQueryStringValue("acodec") : null); var vcodec = (getQueryStringValue("vcodec") !== "" ? getQueryStringValue("vcodec") : null); var subscriber_mode = (getQueryStringValue("subscriber-mode") === "yes" || getQueryStringValue("subscriber-mode") === "true"); @@ -481,7 +480,6 @@ function publishOwnFeed(useAudio) { // pass a ?simulcast=true when opening this demo page: it will turn // the following 'simulcast' property to pass to janus.js to true simulcast: doSimulcast, - simulcast2: doSimulcast2, success: function(jsep) { Janus.debug("Got publisher SDP!"); Janus.debug(jsep); diff --git a/html/recordplaytest.js b/html/recordplaytest.js index ffc6c83571..6ddbd5d3e7 100644 --- a/html/recordplaytest.js +++ b/html/recordplaytest.js @@ -68,7 +68,6 @@ var acodec = (getQueryStringValue("acodec") !== "" ? getQueryStringValue("acodec var vcodec = (getQueryStringValue("vcodec") !== "" ? getQueryStringValue("vcodec") : null); var vprofile = (getQueryStringValue("vprofile") !== "" ? getQueryStringValue("vprofile") : null); var doSimulcast = (getQueryStringValue("simulcast") === "yes" || getQueryStringValue("simulcast") === "true"); -var doSimulcast2 = (getQueryStringValue("simulcast2") === "yes" || getQueryStringValue("simulcast2") === "true"); var doOpusred = (getQueryStringValue("opusred") === "yes" || getQueryStringValue("opusred") === "true"); var recordData = (getQueryStringValue("data") !== "" ? getQueryStringValue("data") : null); if(recordData !== "text" && recordData !== "binary") diff --git a/html/videocalltest.js b/html/videocalltest.js index a4e1aef865..67732366b1 100644 --- a/html/videocalltest.js +++ b/html/videocalltest.js @@ -64,7 +64,6 @@ var myusername = null; var yourusername = null; var doSimulcast = (getQueryStringValue("simulcast") === "yes" || getQueryStringValue("simulcast") === "true"); -var doSimulcast2 = (getQueryStringValue("simulcast2") === "yes" || getQueryStringValue("simulcast2") === "true"); var simulcastStarted = false; $(document).ready(function() { diff --git a/html/videoroomtest.js b/html/videoroomtest.js index 84a5e306a9..8550463170 100644 --- a/html/videoroomtest.js +++ b/html/videoroomtest.js @@ -66,7 +66,6 @@ var feeds = [], feedStreams = {}; var bitrateTimer = []; var doSimulcast = (getQueryStringValue("simulcast") === "yes" || getQueryStringValue("simulcast") === "true"); -var doSimulcast2 = (getQueryStringValue("simulcast2") === "yes" || getQueryStringValue("simulcast2") === "true"); var acodec = (getQueryStringValue("acodec") !== "" ? getQueryStringValue("acodec") : null); var vcodec = (getQueryStringValue("vcodec") !== "" ? getQueryStringValue("vcodec") : null); var doDtx = (getQueryStringValue("dtx") === "yes" || getQueryStringValue("dtx") === "true"); @@ -485,7 +484,6 @@ function publishOwnFeed(useAudio) { // pass a ?simulcast=true when opening this demo page: it will turn // the following 'simulcast' property to pass to janus.js to true simulcast: doSimulcast, - simulcast2: doSimulcast2, customizeSdp: function(jsep) { // If DTX is enabled, munge the SDP if(doDtx) {