Skip to content

Commit

Permalink
Added audio_ssrc from op 5, forced speaking = 1
Browse files Browse the repository at this point in the history
  • Loading branch information
ImTheSquid committed Jun 18, 2023
1 parent fdb1387 commit 74c2b59
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 7 deletions.
17 changes: 13 additions & 4 deletions bd/release/Tuxphones.plugin.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) => {
Expand All @@ -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;");
Expand Down Expand Up @@ -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;
Expand All @@ -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) => {
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -344,7 +352,8 @@ module.exports = !global.ZeresPluginLibrary ? Dummy : (([Plugin, Api]) => {
voice_ssrc,
base_ssrc,
ip,
port
port,
audio_ssrc
}));
}
endStream() {
Expand Down
16 changes: 13 additions & 3 deletions bd/src/Tuxphones/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down Expand Up @@ -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;');
Expand Down Expand Up @@ -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;
Expand All @@ -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) {
Expand Down Expand Up @@ -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 = {
Expand Down Expand Up @@ -400,6 +409,7 @@ return class extends Plugin {
base_ssrc: base_ssrc,
ip: ip,
port: port,
audio_ssrc: audio_ssrc,
}));
}

Expand Down

0 comments on commit 74c2b59

Please sign in to comment.