From 74c2b599826ebe3711932342bfb29a3dc924e179 Mon Sep 17 00:00:00 2001 From: Jack Hogan Date: Sun, 18 Jun 2023 12:27:14 -0400 Subject: [PATCH] Added audio_ssrc from op 5, forced speaking = 1 --- bd/release/Tuxphones.plugin.js | 17 +++++++++++++---- bd/src/Tuxphones/index.jsx | 16 +++++++++++++--- 2 files changed, 26 insertions(+), 7 deletions(-) diff --git a/bd/release/Tuxphones.plugin.js b/bd/release/Tuxphones.plugin.js index bf41361..afe3f79 100644 --- a/bd/release/Tuxphones.plugin.js +++ b/bd/release/Tuxphones.plugin.js @@ -126,6 +126,7 @@ module.exports = !global.ZeresPluginLibrary ? Dummy : (([Plugin, Api]) => { this.wsOnMessage = this.wsOnMessage.bind(this); this._onmessage = null; this._ws = null; + this.voice_ssrc = null; } onOpen() { Patcher.before(WebSocket.prototype, "send", (that, args) => { @@ -147,7 +148,13 @@ module.exports = !global.ZeresPluginLibrary ? Dummy : (([Plugin, Api]) => { json.d.mode = "xsalsa20_poly1305_lite"; args[0] = JSON.stringify(json); } else if (json.op == 5) { - this.voice_ssrc = json.d.ssrc; + if (this.voice_ssrc) { + this.audio_ssrc = json.d.ssrc; + json.d.speaking = 1; + args[0] = JSON.stringify(json); + } else { + this.voice_ssrc = json.d.ssrc; + } } Logger.log(json); console.log("%cWS END SEND FRAME ============================", "color: green; font-size: large; margin-bottom: 20px;"); @@ -235,7 +242,7 @@ module.exports = !global.ZeresPluginLibrary ? Dummy : (([Plugin, Api]) => { Logger.log("Secret key:"); Logger.log(json.d.secret_key); this.secret_key = json.d.secret_key; - this.startStream(this.currentSoundProfile.pid, this.currentSoundProfile.xid, this.selectedResolution, this.selectedFPS, this.ip, this.port, this.secret_key, this.voice_ssrc, this.base_ssrc); + this.startStream(this.currentSoundProfile.pid, this.currentSoundProfile.xid, this.selectedResolution, this.selectedFPS, this.ip, this.port, this.secret_key, this.voice_ssrc, this.base_ssrc, this.audio_ssrc); return; } else if (json.op == 2) { this.base_ssrc = json.d.ssrc; @@ -255,6 +262,7 @@ module.exports = !global.ZeresPluginLibrary ? Dummy : (([Plugin, Api]) => { this.interceptNextStreamServerUpdate = false; this.base_ssrc = null; this.voice_ssrc = null; + this.audio_ssrc = null; } patchGoLive(m) { Patcher.after(m, "default", (_, __, ret) => { @@ -308,7 +316,7 @@ module.exports = !global.ZeresPluginLibrary ? Dummy : (([Plugin, Api]) => { Logger.err(`Received unknown command type: ${obj.type}`); } } - startStream(pid, xid, selectedResolution, framerate, ip, port, secret_key, voice_ssrc, base_ssrc) { + startStream(pid, xid, selectedResolution, framerate, ip, port, secret_key, voice_ssrc, base_ssrc, audio_ssrc) { let resolution = null; switch (selectedResolution) { case 720: @@ -344,7 +352,8 @@ module.exports = !global.ZeresPluginLibrary ? Dummy : (([Plugin, Api]) => { voice_ssrc, base_ssrc, ip, - port + port, + audio_ssrc })); } endStream() { diff --git a/bd/src/Tuxphones/index.jsx b/bd/src/Tuxphones/index.jsx index aba1962..f115987 100644 --- a/bd/src/Tuxphones/index.jsx +++ b/bd/src/Tuxphones/index.jsx @@ -56,6 +56,8 @@ return class extends Plugin { this.wsOnMessage = this.wsOnMessage.bind(this); this._onmessage = null; this._ws = null; + + this.voice_ssrc = null; } onOpen() { @@ -87,7 +89,13 @@ return class extends Plugin { // WARNING WARNING WARNING ========================================================================== // This is a hack, it may not always work! // Still need to test this in multi-person VC - this.voice_ssrc = json.d.ssrc; + if (this.voice_ssrc) { + this.audio_ssrc = json.d.ssrc; + json.d.speaking = 1; + args[0] = JSON.stringify(json); + } else { + this.voice_ssrc = json.d.ssrc; + } } // else if (json.op === 12 && json.d.video_ssrc !== 0 && json.d.rtx_ssrc !== 0) { // console.log('%cRECEIVED SSRC INFORMATION', 'color: aqua; font-size: xx-large;'); @@ -271,7 +279,7 @@ return class extends Plugin { Logger.log('Secret key:'); Logger.log(json.d.secret_key); this.secret_key = json.d.secret_key; - this.startStream(this.currentSoundProfile.pid, this.currentSoundProfile.xid, this.selectedResolution, this.selectedFPS, this.ip, this.port, this.secret_key, this.voice_ssrc, this.base_ssrc); + this.startStream(this.currentSoundProfile.pid, this.currentSoundProfile.xid, this.selectedResolution, this.selectedFPS, this.ip, this.port, this.secret_key, this.voice_ssrc, this.base_ssrc, this.audio_ssrc); return; // Disallow encryption information, stopping the stream from being created } else if (json.op == 2) { this.base_ssrc = json.d.ssrc; @@ -295,6 +303,7 @@ return class extends Plugin { this.interceptNextStreamServerUpdate = false; this.base_ssrc = null; this.voice_ssrc = null; + this.audio_ssrc = null; } patchGoLive(m) { @@ -361,7 +370,7 @@ return class extends Plugin { // server_id PRIORITY: RTC Server ID -> Guild ID -> Channel ID // Guild ID will always exist, so get RTC Server ID - startStream(pid, xid, selectedResolution, framerate, ip, port, secret_key, voice_ssrc, base_ssrc) { + startStream(pid, xid, selectedResolution, framerate, ip, port, secret_key, voice_ssrc, base_ssrc, audio_ssrc) { let resolution = null; switch (selectedResolution) { case 720: resolution = { @@ -400,6 +409,7 @@ return class extends Plugin { base_ssrc: base_ssrc, ip: ip, port: port, + audio_ssrc: audio_ssrc, })); }