From 4f8a55d9e06a3b303f6f2e36f1f3f9e174e10246 Mon Sep 17 00:00:00 2001 From: Maxim Devaev Date: Fri, 22 Mar 2024 23:11:45 +0200 Subject: janus 1.x compatibility --- web/share/js/kvm/stream_janus.js | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/web/share/js/kvm/stream_janus.js b/web/share/js/kvm/stream_janus.js index e7303f78..9ae7bc65 100644 --- a/web/share/js/kvm/stream_janus.js +++ b/web/share/js/kvm/stream_janus.js @@ -226,6 +226,31 @@ export function JanusStreamer(__setActive, __setInactive, __setInfo, __orient, _ } }, + // Janus 1.x + "onremotetrack": function(changed_track, id, added) { + __logInfo("Got onremotetrack:", changed_track, id, added); + let el = $("stream-video"); + if (!el.srcObject) { + el.srcObject = new MediaStream(); + } + let stream = el.srcObject; + if (added) { + for (let track of stream.getTracks()) { + if (track.kind === changed_track.kind && track.id !== changed_track.id) { + stream.removeTrack(track); + } + } + stream.addTrack(changed_track); + if (changed_track.kind == "video") { + __sendKeyRequired(); + __startInfoInterval(); + } + } else { + stream.removeTrack(changed_track); + } + }, + + // Janus 0.x "onremotestream": function(stream) { if (stream === null) { // https://github.com/pikvm/pikvm/issues/1084 -- cgit v1.2.3