mirror of
https://github.com/mofeng-git/One-KVM.git
synced 2025-12-12 01:00:29 +08:00
Merge branch 'mic'
This commit is contained in:
commit
78557b0c47
@ -611,6 +611,11 @@ def _get_config_scheme() -> dict:
|
|||||||
"kvm_mac": Option("", type=valid_mac, if_empty=""),
|
"kvm_mac": Option("", type=valid_mac, if_empty=""),
|
||||||
},
|
},
|
||||||
|
|
||||||
|
"audio": {
|
||||||
|
"enabled": Option(False, type=valid_bool),
|
||||||
|
"start": Option(True, type=valid_bool),
|
||||||
|
},
|
||||||
|
|
||||||
"drives": {
|
"drives": {
|
||||||
"enabled": Option(False, type=valid_bool),
|
"enabled": Option(False, type=valid_bool),
|
||||||
"start": Option(True, type=valid_bool),
|
"start": Option(True, type=valid_bool),
|
||||||
|
|||||||
@ -112,6 +112,18 @@ class _GadgetConfig:
|
|||||||
self.__msd_instance = 0
|
self.__msd_instance = 0
|
||||||
_mkdir(meta_path)
|
_mkdir(meta_path)
|
||||||
|
|
||||||
|
def add_audio_capture(self, start: bool) -> None:
|
||||||
|
eps = 2
|
||||||
|
func = "uac2.usb0"
|
||||||
|
func_path = self.__create_function(func)
|
||||||
|
_write(join(func_path, "c_chmask"), 0)
|
||||||
|
_write(join(func_path, "p_chmask"), 0b11)
|
||||||
|
_write(join(func_path, "p_srate"), 48000)
|
||||||
|
_write(join(func_path, "p_ssize"), 2)
|
||||||
|
if start:
|
||||||
|
self.__start_function(func, eps)
|
||||||
|
self.__create_meta(func, "Audio Capture", eps)
|
||||||
|
|
||||||
def add_serial(self, start: bool) -> None:
|
def add_serial(self, start: bool) -> None:
|
||||||
eps = 3
|
eps = 3
|
||||||
func = "acm.usb0"
|
func = "acm.usb0"
|
||||||
@ -295,6 +307,10 @@ def _cmd_start(config: Section) -> None: # pylint: disable=too-many-statements,
|
|||||||
logger.info("===== Serial =====")
|
logger.info("===== Serial =====")
|
||||||
gc.add_serial(cod.serial.start)
|
gc.add_serial(cod.serial.start)
|
||||||
|
|
||||||
|
if cod.audio.enabled:
|
||||||
|
logger.info("===== Audio Capture =====")
|
||||||
|
gc.add_audio_capture(cod.audio.start)
|
||||||
|
|
||||||
logger.info("===== Preparing complete =====")
|
logger.info("===== Preparing complete =====")
|
||||||
|
|
||||||
logger.info("Enabling the gadget ...")
|
logger.info("Enabling the gadget ...")
|
||||||
|
|||||||
@ -262,6 +262,15 @@
|
|||||||
</td>
|
</td>
|
||||||
<td class="value-number" id="stream-audio-volume-value"></td>
|
<td class="value-number" id="stream-audio-volume-value"></td>
|
||||||
</tr>
|
</tr>
|
||||||
|
<tr class="feature-disabled" id="stream-mic">
|
||||||
|
<td>Microphone:</td>
|
||||||
|
<td align="right">
|
||||||
|
<div class="switch-box">
|
||||||
|
<input disabled type="checkbox" id="stream-mic-switch">
|
||||||
|
<label for="stream-mic-switch"><span class="switch-inner"></span><span class="switch"></span></label>
|
||||||
|
</div>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
</table>
|
</table>
|
||||||
<hr>
|
<hr>
|
||||||
<div class="buttons buttons-row">
|
<div class="buttons buttons-row">
|
||||||
|
|||||||
@ -67,10 +67,12 @@ li(id="system-dropdown" class="right")
|
|||||||
label(for="stream-orient-radio-180") 180°
|
label(for="stream-orient-radio-180") 180°
|
||||||
input(type="radio" id="stream-orient-radio-270" name="stream-orient-radio" value="270")
|
input(type="radio" id="stream-orient-radio-270" name="stream-orient-radio" value="270")
|
||||||
label(for="stream-orient-radio-270") 270°
|
label(for="stream-orient-radio-270") 270°
|
||||||
tr(id="stream-audio", class="feature-disabled")
|
tr(id="stream-audio" class="feature-disabled")
|
||||||
td Audio volume:
|
td Audio volume:
|
||||||
td(class="value-slider") #[input(type="range" id="stream-audio-volume-slider" class="slider")]
|
td(class="value-slider") #[input(type="range" id="stream-audio-volume-slider" class="slider")]
|
||||||
td(id="stream-audio-volume-value" class="value-number")
|
td(id="stream-audio-volume-value" class="value-number")
|
||||||
|
tr(id="stream-mic" class="feature-disabled")
|
||||||
|
+menu_switch_notable("stream-mic-switch", "Microphone", false, false)
|
||||||
hr
|
hr
|
||||||
div(class="buttons buttons-row")
|
div(class="buttons buttons-row")
|
||||||
button(data-force-hide-menu data-show-window="stream-window" class="row33") • Show stream
|
button(data-force-hide-menu data-show-window="stream-window" class="row33") • Show stream
|
||||||
|
|||||||
@ -94,6 +94,15 @@ export function Streamer() {
|
|||||||
__resetStream();
|
__resetStream();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
tools.el.setEnabled($("stream-mic-switch"), !!value);
|
||||||
|
});
|
||||||
|
|
||||||
|
tools.storage.bindSimpleSwitch($("stream-mic-switch"), "stream.mic", false, function(allow_mic) {
|
||||||
|
if (__streamer.getMode() === "janus") {
|
||||||
|
if (__streamer.isMicAllowed() !== allow_mic) {
|
||||||
|
__resetStream();
|
||||||
|
}
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
tools.el.setOnClick($("stream-screenshot-button"), __clickScreenshotButton);
|
tools.el.setOnClick($("stream-screenshot-button"), __clickScreenshotButton);
|
||||||
@ -206,6 +215,7 @@ export function Streamer() {
|
|||||||
tools.feature.setEnabled($("stream-mode"), f.h264);
|
tools.feature.setEnabled($("stream-mode"), f.h264);
|
||||||
if (!f.h264) {
|
if (!f.h264) {
|
||||||
tools.feature.setEnabled($("stream-audio"), false);
|
tools.feature.setEnabled($("stream-audio"), false);
|
||||||
|
tools.feature.setEnabled($("stream-mic"), false);
|
||||||
}
|
}
|
||||||
|
|
||||||
let mode = tools.storage.get("stream.mode", "janus");
|
let mode = tools.storage.get("stream.mode", "janus");
|
||||||
@ -291,7 +301,7 @@ export function Streamer() {
|
|||||||
__streamer.stopStream();
|
__streamer.stopStream();
|
||||||
if (mode === "janus") {
|
if (mode === "janus") {
|
||||||
__streamer = new JanusStreamer(__setActive, __setInactive, __setInfo,
|
__streamer = new JanusStreamer(__setActive, __setInactive, __setInfo,
|
||||||
tools.storage.getInt("stream.orient", 0), !$("stream-video").muted);
|
tools.storage.getInt("stream.orient", 0), !$("stream-video").muted, $("stream-mic-switch").checked);
|
||||||
// Firefox doesn't support RTP orientation:
|
// Firefox doesn't support RTP orientation:
|
||||||
// - https://bugzilla.mozilla.org/show_bug.cgi?id=1316448
|
// - https://bugzilla.mozilla.org/show_bug.cgi?id=1316448
|
||||||
tools.feature.setEnabled($("stream-orient"), !tools.browser.is_firefox);
|
tools.feature.setEnabled($("stream-orient"), !tools.browser.is_firefox);
|
||||||
@ -303,6 +313,7 @@ export function Streamer() {
|
|||||||
}
|
}
|
||||||
tools.feature.setEnabled($("stream-orient"), false);
|
tools.feature.setEnabled($("stream-orient"), false);
|
||||||
tools.feature.setEnabled($("stream-audio"), false); // Enabling in stream_janus.js
|
tools.feature.setEnabled($("stream-audio"), false); // Enabling in stream_janus.js
|
||||||
|
tools.feature.setEnabled($("stream-mic"), false); // Ditto
|
||||||
}
|
}
|
||||||
if (wm.isWindowVisible($("stream-window"))) {
|
if (wm.isWindowVisible($("stream-window"))) {
|
||||||
__streamer.ensureStream((__state && __state.streamer !== undefined) ? __state.streamer : null);
|
__streamer.ensureStream((__state && __state.streamer !== undefined) ? __state.streamer : null);
|
||||||
|
|||||||
@ -29,11 +29,13 @@ import {tools, $} from "../tools.js";
|
|||||||
var _Janus = null;
|
var _Janus = null;
|
||||||
|
|
||||||
|
|
||||||
export function JanusStreamer(__setActive, __setInactive, __setInfo, __orient, __allow_audio) {
|
export function JanusStreamer(__setActive, __setInactive, __setInfo, __orient, __allow_audio, __allow_mic) {
|
||||||
var self = this;
|
var self = this;
|
||||||
|
|
||||||
/************************************************************************/
|
/************************************************************************/
|
||||||
|
|
||||||
|
__allow_mic = (__allow_audio && __allow_mic); // XXX: Mic only with audio
|
||||||
|
|
||||||
var __stop = false;
|
var __stop = false;
|
||||||
var __ensuring = false;
|
var __ensuring = false;
|
||||||
|
|
||||||
@ -51,8 +53,18 @@ export function JanusStreamer(__setActive, __setInactive, __setInfo, __orient, _
|
|||||||
|
|
||||||
self.getOrientation = () => __orient;
|
self.getOrientation = () => __orient;
|
||||||
self.isAudioAllowed = () => __allow_audio;
|
self.isAudioAllowed = () => __allow_audio;
|
||||||
|
self.isMicAllowed = () => __allow_mic;
|
||||||
|
|
||||||
self.getName = () => (__allow_audio ? "WebRTC H.264 + Audio" : "WebRTC H.264");
|
self.getName = function() {
|
||||||
|
let name = "WebRTC H.264";
|
||||||
|
if (__allow_audio) {
|
||||||
|
name += " + Audio";
|
||||||
|
if (__allow_mic) {
|
||||||
|
name += " + Mic";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return name;
|
||||||
|
};
|
||||||
self.getMode = () => "janus";
|
self.getMode = () => "janus";
|
||||||
|
|
||||||
self.getResolution = function() {
|
self.getResolution = function() {
|
||||||
@ -229,6 +241,7 @@ export function JanusStreamer(__setActive, __setInactive, __setInfo, __orient, _
|
|||||||
__setInfo(false, false, "");
|
__setInfo(false, false, "");
|
||||||
} else if (msg.result.status === "features") {
|
} else if (msg.result.status === "features") {
|
||||||
tools.feature.setEnabled($("stream-audio"), msg.result.features.audio);
|
tools.feature.setEnabled($("stream-audio"), msg.result.features.audio);
|
||||||
|
tools.feature.setEnabled($("stream-mic"), msg.result.features.mic);
|
||||||
}
|
}
|
||||||
} else if (msg.error_code || msg.error) {
|
} else if (msg.error_code || msg.error) {
|
||||||
__logError("Got uStreamer error message:", msg.error_code, "-", msg.error);
|
__logError("Got uStreamer error message:", msg.error_code, "-", msg.error);
|
||||||
@ -251,7 +264,7 @@ export function JanusStreamer(__setActive, __setInactive, __setInfo, __orient, _
|
|||||||
__logInfo("Handling SDP:", jsep);
|
__logInfo("Handling SDP:", jsep);
|
||||||
let tracks = [{"type": "video", "capture": false, "recv": true, "add": true}];
|
let tracks = [{"type": "video", "capture": false, "recv": true, "add": true}];
|
||||||
if (__allow_audio) {
|
if (__allow_audio) {
|
||||||
tracks.push({"type": "audio", "capture": false, "recv": true, "add": true});
|
tracks.push({"type": "audio", "capture": __allow_mic, "recv": true, "add": true});
|
||||||
}
|
}
|
||||||
__handle.createAnswer({
|
__handle.createAnswer({
|
||||||
"jsep": jsep,
|
"jsep": jsep,
|
||||||
@ -354,11 +367,12 @@ export function JanusStreamer(__setActive, __setInactive, __setInfo, __orient, _
|
|||||||
|
|
||||||
var __sendWatch = function() {
|
var __sendWatch = function() {
|
||||||
if (__handle) {
|
if (__handle) {
|
||||||
__logInfo(`Sending WATCH(orient=${__orient}, audio=${__allow_audio}) + FEATURES ...`);
|
__logInfo(`Sending WATCH(orient=${__orient}, audio=${__allow_audio}, mic=${__allow_mic}) + FEATURES ...`);
|
||||||
__handle.send({"message": {"request": "features"}});
|
__handle.send({"message": {"request": "features"}});
|
||||||
__handle.send({"message": {"request": "watch", "params": {
|
__handle.send({"message": {"request": "watch", "params": {
|
||||||
"orientation": __orient,
|
"orientation": __orient,
|
||||||
"audio": __allow_audio,
|
"audio": __allow_audio,
|
||||||
|
"mic": __allow_mic,
|
||||||
}}});
|
}}});
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user