Skip to content

Commit

Permalink
Handle onremotetrack metadata in demos
Browse files Browse the repository at this point in the history
  • Loading branch information
marekpiechut committed Jan 23, 2023
1 parent 55c5c52 commit b1e6c3f
Show file tree
Hide file tree
Showing 13 changed files with 92 additions and 27 deletions.
8 changes: 6 additions & 2 deletions html/audiobridgetest.js
Original file line number Diff line number Diff line change
Expand Up @@ -298,8 +298,12 @@ $(document).ready(function() {
$('#room').removeClass('hide').show();
$('#participant').removeClass('hide').html(myusername).show();
},
onremotetrack: function(track, mid, on) {
Janus.debug("Remote track (mid=" + mid + ") " + (on ? "added" : "removed") + ":", track);
onremotetrack: function(track, mid, on, metadata) {
Janus.debug(
"Remote track (mid=" + mid + ") " +
(on ? "added" : "removed") +
(metadata ? " (" + metadata.reason + ") ": "") + ":", track
);
if(remoteStream || track.kind !== "audio")
return;
if(!on) {
Expand Down
8 changes: 6 additions & 2 deletions html/canvas.js
Original file line number Diff line number Diff line change
Expand Up @@ -169,8 +169,12 @@ $(document).ready(function() {
});
}
},
onremotetrack: function(track, mid, on) {
Janus.debug("Remote track (mid=" + mid + ") " + (on ? "added" : "removed") + ":", track);
onremotetrack: function(track, mid, on, metadata) {
Janus.debug(
"Remote track (mid=" + mid + ") " +
(on ? "added" : "removed") +
(metadata? " (" + metadata.reason + ") ": "") + ":", track
);
if(!on) {
// Track removed, get rid of the stream and the rendering
$('#peervideo' + mid).remove();
Expand Down
8 changes: 6 additions & 2 deletions html/echotest.js
Original file line number Diff line number Diff line change
Expand Up @@ -281,8 +281,12 @@ $(document).ready(function() {
});
}
},
onremotetrack: function(track, mid, on) {
Janus.debug("Remote track (mid=" + mid + ") " + (on ? "added" : "removed") + ":", track);
onremotetrack: function(track, mid, on, metadata) {
Janus.debug(
"Remote track (mid=" + mid + ") " +
(on ? "added" : "removed") +
(metadata ? " (" + metadata.reason + ") ": "") + ":", track
);
if(!on) {
// Track removed, get rid of the stream and the rendering
$('#peervideo' + mid).remove();
Expand Down
8 changes: 6 additions & 2 deletions html/multiopus.js
Original file line number Diff line number Diff line change
Expand Up @@ -204,8 +204,12 @@ $(document).ready(function() {
});
}
},
onremotetrack: function(track, mid, on) {
Janus.debug("Remote track (mid=" + mid + ") " + (on ? "added" : "removed") + ":", track);
onremotetrack: function(track, mid, on, metadata) {
Janus.debug(
"Remote track (mid=" + mid + ") " +
(on ? "added" : "removed") +
(metadata? " (" + metadata.reason + ") ": "") + ":", track
);
if(!on) {
// Track removed, get rid of the stream and the rendering
$('#peervideo' + mid).remove();
Expand Down
8 changes: 6 additions & 2 deletions html/mvideoroomtest.js
Original file line number Diff line number Diff line change
Expand Up @@ -744,8 +744,12 @@ function subscribeTo(sources) {
onlocaltrack: function(track, on) {
// The subscriber stream is recvonly, we don't expect anything here
},
onremotetrack: function(track, mid, on) {
Janus.debug("Remote track (mid=" + mid + ") " + (on ? "added" : "removed") + ":", track);
onremotetrack: function(track, mid, on, metadata) {
Janus.debug(
"Remote track (mid=" + mid + ") " +
(on ? "added" : "removed") +
(metadata ? " (" + metadata.reason + ") ": "") + ":", track
);
// Which publisher are we getting on this mid?
let sub = subStreams[mid];
let feed = feedStreams[sub.feed_id];
Expand Down
8 changes: 6 additions & 2 deletions html/recordplaytest.js
Original file line number Diff line number Diff line change
Expand Up @@ -276,10 +276,14 @@ $(document).ready(function() {
});
}
},
onremotetrack: function(track, mid, on) {
onremotetrack: function(track, mid, on, metadata) {
if(playing === false)
return;
Janus.debug("Remote track (mid=" + mid + ") " + (on ? "added" : "removed") + ":", track);
Janus.debug(
"Remote track (mid=" + mid + ") " +
(on ? "added" : "removed") +
(metadata? " (" + metadata.reason + ") ": "") + ":", track
);
if(!on) {
// Track removed, get rid of the stream and the rendering
$('#thevideo' + mid).remove();
Expand Down
19 changes: 17 additions & 2 deletions html/screensharingtest.js
Original file line number Diff line number Diff line change
Expand Up @@ -511,8 +511,23 @@ function newRemoteFeed(id, display) {
onlocaltrack: function(track, on) {
// The subscriber stream is recvonly, we don't expect anything here
},
onremotetrack: function(track, mid, on) {
Janus.debug("Remote track (mid=" + mid + ") " + (on ? "added" : "removed") + ":", track);
onremotetrack: function(track, mid, on, metadata) {
Janus.debug(
"Remote track (mid=" + mid + ") " +
(on ? "added" : "removed") +
(metadata? " (" + metadata.reason + ") ": "") + ":", track
);
// Screen sharing tracks are sometimes muted/unmuted by browser
// when data is not flowing fast enough, this can make streams blink,
// we can ignore these
if(
track.kind === "video"
&& metadata
&& (metadata.reason === "mute" || metadata.reason === "unmute")
) {
Janus.log("Ignoring mute/unmute on screen-sharing track.")
return
}
if(!on) {
// Track removed, get rid of the stream and the rendering
$('#screenvideo' + mid).remove();
Expand Down
8 changes: 6 additions & 2 deletions html/streamingtest.js
Original file line number Diff line number Diff line change
Expand Up @@ -152,8 +152,12 @@ $(document).ready(function() {
});
}
},
onremotetrack: function(track, mid, on) {
Janus.debug("Remote track (mid=" + mid + ") " + (on ? "added" : "removed") + ":", track);
onremotetrack: function(track, mid, on, metadata) {
Janus.debug(
"Remote track (mid=" + mid + ") " +
(on ? "added" : "removed") +
(metadata ? " (" + metadata.reason + ") ": "") + ":", track
);
var mstreamId = "mstream"+mid;
if(streamsList[selectedStream] && streamsList[selectedStream].legacy)
mstreamId = "mstream0";
Expand Down
8 changes: 6 additions & 2 deletions html/videocalltest.js
Original file line number Diff line number Diff line change
Expand Up @@ -358,8 +358,12 @@ $(document).ready(function() {
});
}
},
onremotetrack: function(track, mid, on) {
Janus.debug("Remote track (mid=" + mid + ") " + (on ? "added" : "removed") + ":", track);
onremotetrack: function(track, mid, on, metadata) {
Janus.debug(
"Remote track (mid=" + mid + ") " +
(on ? "added" : "removed") +
(metadata ? " (" + metadata.reason + ") ": "") + ":", track
);
if(!on) {
// Track removed, get rid of the stream and the rendering
$('#peervideo' + mid).remove();
Expand Down
9 changes: 7 additions & 2 deletions html/videoroomtest.js
Original file line number Diff line number Diff line change
Expand Up @@ -647,8 +647,13 @@ function newRemoteFeed(id, display, streams) {
onlocaltrack: function(track, on) {
// The subscriber stream is recvonly, we don't expect anything here
},
onremotetrack: function(track, mid, on) {
Janus.debug("Remote feed #" + remoteFeed.rfindex + ", remote track (mid=" + mid + ") " + (on ? "added" : "removed") + ":", track);
onremotetrack: function(track, mid, on, metadata) {
Janus.debug(
"Remote feed #" + remoteFeed.rfindex +
", remote track (mid=" + mid + ") " +
(on ? "added" : "removed") +
(metadata? " (" + metadata.reason + ") ": "") + ":", track
);
if(!on) {
// Track removed, get rid of the stream and the rendering
$('#remotevideo'+remoteFeed.rfindex + '-' + mid).remove();
Expand Down
8 changes: 6 additions & 2 deletions html/virtualbg.js
Original file line number Diff line number Diff line change
Expand Up @@ -232,8 +232,12 @@ $(document).ready(function() {
});
}
},
onremotetrack: function(track, mid, on) {
Janus.debug("Remote track (mid=" + mid + ") " + (on ? "added" : "removed") + ":", track);
onremotetrack: function(track, mid, on, metadata) {
Janus.debug(
"Remote track (mid=" + mid + ") " +
(on ? "added" : "removed") +
(metadata? " (" + metadata.reason + ") ": "") + ":", track
);
if(!on) {
// Track removed, get rid of the stream and the rendering
$('#peervideo' + mid).remove();
Expand Down
11 changes: 8 additions & 3 deletions html/vp9svctest.js
Original file line number Diff line number Diff line change
Expand Up @@ -434,7 +434,7 @@ function publishOwnFeed(useAudio) {
let tracks = [];
if(useAudio)
tracks.push({ type: 'audio', capture: true, recv: false });
tracks.push({ type: 'video', capture: true, recv: false, simulcast: doSimulcast });
tracks.push({ type: 'video', capture: true, recv: false, simulcast: false});
//~ tracks.push({ type: 'data' });

sfutest.createOffer(
Expand Down Expand Up @@ -604,8 +604,13 @@ function newRemoteFeed(id, display, streams) {
onlocaltrack: function(track, on) {
// The subscriber stream is recvonly, we don't expect anything here
},
onremotetrack: function(track, mid, on) {
Janus.debug("Remote feed #" + remoteFeed.rfindex + ", remote track (mid=" + mid + ") " + (on ? "added" : "removed") + ":", track);
onremotetrack: function(track, mid, on, metadata) {
Janus.debug(
"Remote feed #" + remoteFeed.rfindex +
", remote track (mid=" + mid + ") " +
(on ? "added" : "removed") +
(metadata? " (" + metadata.reason + ") ": "") + ":", track
);
if(!on) {
// Track removed, get rid of the stream and the rendering
$('#remotevideo'+remoteFeed.rfindex + '-' + mid).remove();
Expand Down
8 changes: 6 additions & 2 deletions html/webaudio.js
Original file line number Diff line number Diff line change
Expand Up @@ -144,8 +144,12 @@ $(document).ready(function() {
Janus.debug("Local track " + (on ? "added" : "removed") + ":", track);
// We don't do anything here, since we captured the stream ourselves
},
onremotetrack: function(track, mid, on) {
Janus.debug("Remote track (mid=" + mid + ") " + (on ? "added" : "removed") + ":", track);
onremotetrack: function(track, mid, on, metadata) {
Janus.debug(
"Remote track (mid=" + mid + ") " +
(on ? "added" : "removed") +
(metadata? " (" + metadata.reason + ") ": "") + ":", track
);
// Now that we're aware of the remote stream, we process it to visualize it
if(!on) {
// Track removed, get rid of the stream and the rendering
Expand Down

0 comments on commit b1e6c3f

Please sign in to comment.