summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMaxim Devaev <[email protected]>2024-03-23 13:11:34 +0200
committerMaxim Devaev <[email protected]>2024-03-23 13:11:34 +0200
commit90838fde59b53562f2f8d3ec9a384b4be5573e5e (patch)
tree1e5df9fc3cb44ae7a45316033953afadb3f66276
parent852931bb825427d198c345857c205e7e2856100e (diff)
Issue #161: Fixed periodic disconnections on bad network
Fix for Janus 1.x similar as for 0.x (see 6b0f94c78d957359e695e231800d1ddade7706e0)
-rw-r--r--web/share/js/kvm/stream_janus.js12
1 files changed, 8 insertions, 4 deletions
diff --git a/web/share/js/kvm/stream_janus.js b/web/share/js/kvm/stream_janus.js
index 9ae7bc65..21c91190 100644
--- a/web/share/js/kvm/stream_janus.js
+++ b/web/share/js/kvm/stream_janus.js
@@ -227,14 +227,18 @@ export function JanusStreamer(__setActive, __setInactive, __setInfo, __orient, _
},
// Janus 1.x
- "onremotetrack": function(changed_track, id, added) {
- __logInfo("Got onremotetrack:", changed_track, id, added);
+ "onremotetrack": function(changed_track, id, added, meta) {
+ __logInfo("Got onremotetrack:", changed_track, id, added, meta);
let el = $("stream-video");
if (!el.srcObject) {
el.srcObject = new MediaStream();
}
let stream = el.srcObject;
- if (added) {
+ // Chrome sends `muted` notifiation for tracks in `disconnected` ICE state
+ // and Janus.js just removes muted track from list of available tracks.
+ // But track still exists actually so it's safe to just ignore
+ // reason == "mute" and "unmute".
+ if (added && meta.reason == "created") {
for (let track of stream.getTracks()) {
if (track.kind === changed_track.kind && track.id !== changed_track.id) {
stream.removeTrack(track);
@@ -245,7 +249,7 @@ export function JanusStreamer(__setActive, __setInactive, __setInfo, __orient, _
__sendKeyRequired();
__startInfoInterval();
}
- } else {
+ } else if (!added && meta.reason == "ended") {
stream.removeTrack(changed_track);
}
},