From 37e08f3ffa4e8b97c80fa2d0bfd20f6c51ce3c9c Mon Sep 17 00:00:00 2001 From: Lorenzo Miniero Date: Mon, 8 Jun 2020 20:00:04 +0200 Subject: [PATCH] Updated demos and janus.js to use tracks instead of streams --- conf/janus.plugin.streaming.jcfg.sample.in | 1 + html/audiobridgetest.js | 40 +- html/demos.html | 4 + html/devicetest.js | 255 ++++-- html/e2etest.js | 234 +++-- html/echotest.js | 234 +++-- html/janus.js | 359 +++++--- html/multiopus.js | 232 +++-- html/mvideoroomtest.html | 159 ++++ html/mvideoroomtest.js | 992 +++++++++++++++++++++ html/navbar.html | 1 + html/nosiptest.js | 252 +++--- html/recordplaytest.js | 192 ++-- html/screensharingtest.js | 179 +++- html/siptest.js | 420 ++++++--- html/streamingtest.html | 12 +- html/streamingtest.js | 608 ++++++++----- html/videocalltest.js | 248 ++++-- html/videoroomtest.html | 6 + html/videoroomtest.js | 355 +++++--- html/voicemailtest.js | 4 +- html/vp9svctest.js | 348 +++++--- mainpage.dox | 37 +- 23 files changed, 3804 insertions(+), 1368 deletions(-) create mode 100644 html/mvideoroomtest.html create mode 100644 html/mvideoroomtest.js diff --git a/conf/janus.plugin.streaming.jcfg.sample.in b/conf/janus.plugin.streaming.jcfg.sample.in index f31d1b396a..f93bd17841 100644 --- a/conf/janus.plugin.streaming.jcfg.sample.in +++ b/conf/janus.plugin.streaming.jcfg.sample.in @@ -150,6 +150,7 @@ multistream-test: { type = "rtp" id = 123 description = "Multistream test (1 audio, 2 video)" + metadata = "This is an example of a multistream mountpoint: you'll get an audio stream and two video feeds" media = ( { type = "audio" diff --git a/html/audiobridgetest.js b/html/audiobridgetest.js index 013cc1ae00..161a4c4f14 100644 --- a/html/audiobridgetest.js +++ b/html/audiobridgetest.js @@ -52,6 +52,7 @@ var janus = null; var mixertest = null; var opaqueId = "audiobridgetest-"+Janus.randomString(12); +var remoteStream = null; var spinner = null; var myroom = 1234; // Demo room @@ -123,8 +124,8 @@ $(document).ready(function() { iceState: function(state) { Janus.log("ICE state changed to " + state); }, - mediaState: function(medium, on) { - Janus.log("Janus " + (on ? "started" : "stopped") + " receiving our " + medium); + mediaState: function(medium, mid, on) { + Janus.log("Janus " + (on ? "started" : "stopped") + " receiving our " + medium + " (mid=" + mid + ")"); }, webrtcState: function(on) { Janus.log("Janus says our WebRTC PeerConnection is " + (on ? "up" : "down") + " now"); @@ -276,23 +277,40 @@ $(document).ready(function() { mixertest.handleRemoteJsep({ jsep: jsep }); } }, - onlocalstream: function(stream) { - Janus.debug(" ::: Got a local stream :::", stream); + onlocaltrack: function(track, on) { + Janus.debug("Local track " + (on ? "added" : "removed") + ":", track); // We're not going to attach the local audio stream $('#audiojoin').hide(); $('#room').removeClass('hide').show(); $('#participant').removeClass('hide').html(myusername).show(); }, - onremotestream: function(stream) { + onremotetrack: function(track, mid, on) { + Janus.debug("Remote track (mid=" + mid + ") " + (on ? "added" : "removed") + ":", track); + if(remoteStream || track.kind !== "audio") + return; + if(!on) { + // Track removed, get rid of the stream and the rendering + if(remoteStream) { + try { + var tracks = remoteStream.getTracks(); + for(var i in tracks) { + var mst = tracks[i]; + if(mst) + mst.stop(); + } + } catch(e) {} + } + remoteStream = null; + $('#roomaudio').remove(); + return; + } + remoteStream = new MediaStream(); + remoteStream.addTrack(track.clone()); $('#room').removeClass('hide').show(); - var addButtons = false; if($('#roomaudio').length === 0) { - addButtons = true; $('#mixedaudio').append('