From f9d2e747e35968d1d1cae06a451a7eec001068ad Mon Sep 17 00:00:00 2001 From: Devaev Maxim Date: Thu, 10 Jun 2021 16:27:58 +0300 Subject: show streamer name in window title --- web/share/js/kvm/stream.js | 38 +++++++++++++++++++++++--------------- 1 file changed, 23 insertions(+), 15 deletions(-) (limited to 'web/share') diff --git a/web/share/js/kvm/stream.js b/web/share/js/kvm/stream.js index 92f1cd69..b4633d4c 100644 --- a/web/share/js/kvm/stream.js +++ b/web/share/js/kvm/stream.js @@ -45,6 +45,9 @@ function _JanusStreamer(__setActive, __setInactive, __setInfo) { var __state = null; + self.getName = () => "WebRTC"; + self.getMode = () => "janus"; + self.getResolution = function() { let el_video = $("stream-video"); return { @@ -292,6 +295,9 @@ function _MjpegStreamer(__setActive, __setInactive, __setInfo) { /************************************************************************/ + self.getName = () => "MJPEG"; + self.getMode = () => "mjpeg"; + self.getResolution = function() { let el_image = $("stream-image"); return { @@ -557,10 +563,10 @@ export function Streamer() { $("stream-box").classList.toggle("stream-box-offline", !online); let el_grab = document.querySelector("#stream-window-header .window-grab"); let el_info = $("stream-info"); - let title = "Stream – "; + let title = `${__streamer.getName()} – `; if (is_active) { if (!online) { - title += "no signal / "; + title += "No signal / "; } title += __makeStringResolution(__resolution); if (text.length > 0) { @@ -570,7 +576,7 @@ export function Streamer() { if (text.length > 0) { title += text; } else { - title += "inactive"; + title += "Inactive"; } } el_grab.innerHTML = el_info.innerHTML = title; @@ -603,18 +609,20 @@ export function Streamer() { var __clickModeRadio = function() { if (_Janus !== null) { let mode = tools.radioGetValue("stream-mode-radio"); - setTimeout(() => tools.radioSetValue("stream-mode-radio", mode), 100); - tools.hiddenSetVisible($("stream-image"), (mode === "mjpeg")); - tools.hiddenSetVisible($("stream-video"), (mode !== "mjpeg")); - if (mode === "mjpeg") { - __streamer.stopStream(); - __streamer = new _MjpegStreamer(__setActive, __setInactive, __setInfo); - } else { // janus - __streamer.stopStream(); - __streamer = new _JanusStreamer(__setActive, __setInactive, __setInfo); - } - if (wm.isWindowVisible($("stream-window"))) { - __streamer.ensureStream(__state); + if (mode !== __streamer.getMode()) { + setTimeout(() => tools.radioSetValue("stream-mode-radio", mode), 100); + tools.hiddenSetVisible($("stream-image"), (mode === "mjpeg")); + tools.hiddenSetVisible($("stream-video"), (mode !== "mjpeg")); + if (mode === "mjpeg") { + __streamer.stopStream(); + __streamer = new _MjpegStreamer(__setActive, __setInactive, __setInfo); + } else { // janus + __streamer.stopStream(); + __streamer = new _JanusStreamer(__setActive, __setInactive, __setInfo); + } + if (wm.isWindowVisible($("stream-window"))) { + __streamer.ensureStream(__state); + } } } }; -- cgit v1.2.3