This commit is contained in:
mofeng-git
2025-02-01 14:40:28 +00:00
parent c711683c63
commit f032b8c798
8 changed files with 54 additions and 22 deletions

View File

@@ -117,11 +117,6 @@ export function Streamer() {
//hidden stream-record-stop-button
document.getElementById('stream-record-stop-button').disabled = true;
// 修改这里:设置默认模式为 mjpeg
let defaultMode = "mjpeg";
let mode = tools.storage.get("stream.mode", defaultMode);
tools.radio.clickValue("stream-mode-radio", mode);
};
/************************************************************************/
@@ -230,7 +225,7 @@ export function Streamer() {
tools.feature.setEnabled($("stream-mic"), false);
}
let mode = tools.storage.get("stream.mode", "mjpeg"); // 这里也改为默认 mjpeg
let mode = tools.storage.get("stream.mode", "mjpeg");
if (mode === "janus" && !has_janus) {
mode = "media";
}

View File

@@ -3,6 +3,7 @@
# KVMD - The main PiKVM daemon. #
# #
# Copyright (C) 2018-2024 Maxim Devaev <mdevaev@gmail.com> #
# Copyright (C) 2023-2025 SilentWind <mofeng654321@hotmail.com> #
# #
# This program is free software: you can redistribute it and/or modify #
# it under the terms of the GNU General Public License as published by #
@@ -311,6 +312,50 @@ export function JanusStreamer(__setActive, __setInactive, __setInfo, __orient, _
}
},
// 添加对 Janus 0.x 的支持
"onremotestream": function(stream) {
if (stream === null) {
// https://github.com/pikvm/pikvm/issues/1084
// 这种情况不应该发生,但有时 Janus 在 unmute 时可能会收到 null 事件
// 作为解决方案,我们重启 Janus
__logError("Got invalid onremotestream(null). Restarting Janus...");
__destroyJanus();
return;
}
let tracks = stream.getTracks();
__logInfo("Got a remote stream changes:", stream, tracks);
let has_video = false;
for (let track of tracks) {
if (track.kind == "video") {
has_video = true;
break;
}
}
if (!has_video && __isOnline()) {
// Chrome 在 ICE 状态为 disconnected 时会发送 muted 通知
// Janus.js 会从可用轨道列表中移除已静音的轨道
// 但轨道实际上仍然存在,所以可以安全地忽略这种情况
return;
}
_Janus.attachMediaStream($("stream-video"), stream);
__sendKeyRequired();
__startInfoInterval();
// FIXME: 延迟减少但在关键帧上会出现卡顿
// - https://github.com/Glimesh/janus-ftl-plugin/issues/101
/*if (__handle && __handle.webrtcStuff && __handle.webrtcStuff.pc) {
for (let receiver of __handle.webrtcStuff.pc.getReceivers()) {
if (receiver.track && receiver.track.kind === "video" && receiver.playoutDelayHint !== undefined) {
receiver.playoutDelayHint = 0;
}
}
}*/
},
"oncleanup": function() {
__logInfo("Got a cleanup notification");
__stopInfoInterval();