From ce77f91c6f7fc22081622595f320420a23f92582 Mon Sep 17 00:00:00 2001 From: Manevolent Date: Sat, 13 Oct 2018 01:35:09 -0400 Subject: [PATCH 1/7] I'm changing whisper and voice handlers. I think that the COMPRESSED flag is important, it may signal you to reset your decoder for each incoming packet. Not sure. --- .../handler/client/LocalClientHandlerFull.java | 8 ++++---- .../socket/client/AbstractTeamspeakClientSocket.java | 12 ++++++------ .../socket/client/LocalTeamspeakClientSocket.java | 9 ++++----- .../github/manevolent/ts3j/ServerConnectionTest.java | 2 +- 4 files changed, 15 insertions(+), 16 deletions(-) diff --git a/src/main/java/com/github/manevolent/ts3j/protocol/packet/handler/client/LocalClientHandlerFull.java b/src/main/java/com/github/manevolent/ts3j/protocol/packet/handler/client/LocalClientHandlerFull.java index 1833f0d..d47859f 100644 --- a/src/main/java/com/github/manevolent/ts3j/protocol/packet/handler/client/LocalClientHandlerFull.java +++ b/src/main/java/com/github/manevolent/ts3j/protocol/packet/handler/client/LocalClientHandlerFull.java @@ -55,12 +55,12 @@ public abstract class LocalClientHandlerFull extends LocalClientHandler { break; case VOICE: - Consumer handler = getClient().getVoiceHandler(); - if (handler != null) handler.accept((PacketBody0Voice) packet.getBody()); + Consumer handler = getClient().getVoiceHandler(); + if (handler != null) handler.accept(packet); break; case VOICE_WHISPER: - Consumer whisperConsumer = getClient().getWhisperHandler(); - if (whisperConsumer != null) whisperConsumer.accept((PacketBody1VoiceWhisper) packet.getBody()); + Consumer whisperConsumer = getClient().getWhisperHandler(); + if (whisperConsumer != null) whisperConsumer.accept(packet); break; } } diff --git a/src/main/java/com/github/manevolent/ts3j/protocol/socket/client/AbstractTeamspeakClientSocket.java b/src/main/java/com/github/manevolent/ts3j/protocol/socket/client/AbstractTeamspeakClientSocket.java index 00199a7..133b9f0 100644 --- a/src/main/java/com/github/manevolent/ts3j/protocol/socket/client/AbstractTeamspeakClientSocket.java +++ b/src/main/java/com/github/manevolent/ts3j/protocol/socket/client/AbstractTeamspeakClientSocket.java @@ -70,8 +70,8 @@ public abstract class AbstractTeamspeakClientSocket private CommandProcessor commandProcessor; - private Consumer voiceHandler; - private Consumer whisperHandler; + private Consumer voiceHandler; + private Consumer whisperHandler; private Consumer exceptionHandler = Throwable::printStackTrace; @@ -897,19 +897,19 @@ public abstract class AbstractTeamspeakClientSocket this.exceptionHandler = exceptionHandler; } - public Consumer getVoiceHandler() { + public Consumer getVoiceHandler() { return voiceHandler; } - public void setVoiceHandler(Consumer voiceHandler) { + public void setVoiceHandler(Consumer voiceHandler) { this.voiceHandler = voiceHandler; } - public Consumer getWhisperHandler() { + public Consumer getWhisperHandler() { return whisperHandler; } - public void setWhisperHandler(Consumer whisperHandler) { + public void setWhisperHandler(Consumer whisperHandler) { this.whisperHandler = whisperHandler; } diff --git a/src/main/java/com/github/manevolent/ts3j/protocol/socket/client/LocalTeamspeakClientSocket.java b/src/main/java/com/github/manevolent/ts3j/protocol/socket/client/LocalTeamspeakClientSocket.java index 2a2f23d..c3a1482 100644 --- a/src/main/java/com/github/manevolent/ts3j/protocol/socket/client/LocalTeamspeakClientSocket.java +++ b/src/main/java/com/github/manevolent/ts3j/protocol/socket/client/LocalTeamspeakClientSocket.java @@ -605,7 +605,7 @@ public class LocalTeamspeakClientSocket private void handleComplete(SingleCommand command) throws IOException, TimeoutException { try { synchronized (commandSendLock) { - awaitingCommands.remove(returnCode); + awaitingCommands.remove(getReturnCode()); acceptingReturnCode = calculateAcceptingReturnCode(); } @@ -690,12 +690,11 @@ public class LocalTeamspeakClientSocket switch (getState()) { case RETRIEVING_DATA: case CONNECTED: - Command banCommand = new SingleCommand("clientupdate", ProtocolRole.CLIENT); - - banCommand.add(new CommandSingleParameter("client_nickname", nickname)); + Command command = new SingleCommand("clientupdate", ProtocolRole.CLIENT); + command.add(new CommandSingleParameter("client_nickname", nickname)); try { - executeCommand(banCommand).complete(); + executeCommand(command).complete(); } catch (Exception e) { throw new RuntimeException(e); } diff --git a/src/test/java/com/github/manevolent/ts3j/ServerConnectionTest.java b/src/test/java/com/github/manevolent/ts3j/ServerConnectionTest.java index 907d5cf..752950c 100644 --- a/src/test/java/com/github/manevolent/ts3j/ServerConnectionTest.java +++ b/src/test/java/com/github/manevolent/ts3j/ServerConnectionTest.java @@ -24,7 +24,7 @@ public class ServerConnectionTest { Ts3Debugging.setEnabled(true); - LocalIdentity identity = LocalIdentity.generateNew(9); + LocalIdentity identity = LocalIdentity.generateNew(10); client.setIdentity(identity); client.setNickname("ts3j issue 2"); From d9ce7f21a322e152feb2c97633a74100727fc462 Mon Sep 17 00:00:00 2001 From: Manevolent Date: Sat, 13 Oct 2018 02:17:13 -0400 Subject: [PATCH 2/7] JitPack is broken. Trying one more time to get this to go through. --- .../protocol/packet/handler/client/LocalClientHandlerFull.java | 1 + 1 file changed, 1 insertion(+) diff --git a/src/main/java/com/github/manevolent/ts3j/protocol/packet/handler/client/LocalClientHandlerFull.java b/src/main/java/com/github/manevolent/ts3j/protocol/packet/handler/client/LocalClientHandlerFull.java index d47859f..af998ea 100644 --- a/src/main/java/com/github/manevolent/ts3j/protocol/packet/handler/client/LocalClientHandlerFull.java +++ b/src/main/java/com/github/manevolent/ts3j/protocol/packet/handler/client/LocalClientHandlerFull.java @@ -54,6 +54,7 @@ public abstract class LocalClientHandlerFull extends LocalClientHandler { } break; + case VOICE: Consumer handler = getClient().getVoiceHandler(); if (handler != null) handler.accept(packet); From d97b95f0218fff5303a8598c95155bc774e7573e Mon Sep 17 00:00:00 2001 From: Manevolent Date: Sat, 13 Oct 2018 16:03:51 -0400 Subject: [PATCH 3/7] When the COMPRESSED flag is set by the official Teamspeak Gbmh client on a VOICE or VOICE_WHISPER packet, which is done for the first 5 packets of any decoder session, the packet is always 1 byte longer. More importantly, the final byte is static for those 5 packets. You have to trim that last byte off, otherwise your audio will be corrupted. TS3J now does this automatically and stores it in ServerFlag0 for you, as a nullable Byte object. This way you can handle it if you need to. This has also been factored into the output/write stage. Digging into theory, I believe this ID has something to do with the opening of a new decoder to ensure that the decoder opens cleanly each time. You do NOT have to do anything to your decoder to reset states, etc., from what I can tell. In other words, COMPRESSED being on shouldn't change the behavior of your decoding. --- .../protocol/packet/PacketBody0Voice.java | 54 +++++++++++++++++-- .../packet/PacketBody1VoiceWhisper.java | 42 ++++++++++++--- .../manevolent/ts3j/ServerConnectionTest.java | 7 ++- 3 files changed, 91 insertions(+), 12 deletions(-) diff --git a/src/main/java/com/github/manevolent/ts3j/protocol/packet/PacketBody0Voice.java b/src/main/java/com/github/manevolent/ts3j/protocol/packet/PacketBody0Voice.java index 173241f..5524795 100644 --- a/src/main/java/com/github/manevolent/ts3j/protocol/packet/PacketBody0Voice.java +++ b/src/main/java/com/github/manevolent/ts3j/protocol/packet/PacketBody0Voice.java @@ -2,6 +2,8 @@ package com.github.manevolent.ts3j.protocol.packet; import com.github.manevolent.ts3j.enums.CodecType; import com.github.manevolent.ts3j.protocol.ProtocolRole; +import com.github.manevolent.ts3j.protocol.header.HeaderFlag; +import com.github.manevolent.ts3j.protocol.header.PacketHeader; import com.github.manevolent.ts3j.util.Ts3Debugging; import java.nio.ByteBuffer; @@ -12,6 +14,13 @@ public class PacketBody0Voice extends PacketBody { private CodecType codecType; private byte[] codecData; + // Unknown at this time (have seen: 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07) + // Set for the first 5 packets of a new voice session + // I believe this is related to tracking opening a new decoder + // Not all new voice sessions will change this flag + // Best to ignore it for now, but it's here if you need it or figure it out + private Byte serverFlag0; + public PacketBody0Voice(ProtocolRole role) { super(PacketBodyType.VOICE, role); } @@ -44,6 +53,12 @@ public class PacketBody0Voice extends PacketBody { return clientId; } + public Byte getServerFlag0() { return serverFlag0; } + + public void setServerFlag0(Byte flag) { + this.serverFlag0 = flag; + } + public void setClientId(int clientId) { if (getRole() != ProtocolRole.SERVER) throw new IllegalStateException("cannot set client ID field on non-server packet"); @@ -51,6 +66,32 @@ public class PacketBody0Voice extends PacketBody { this.clientId = clientId; } + @Override + public void setHeaderValues(PacketHeader header) { + if (serverFlag0 != null) // Ensure padding is signaled + header.setPacketFlag(HeaderFlag.COMPRESSED, true); + } + + @Override + public void read(PacketHeader header, ByteBuffer buffer) { + super.read(header, buffer); + + int padding = 0; + boolean compressed = header.getPacketFlag(HeaderFlag.COMPRESSED); + + if (compressed) + padding ++; + + codecData = new byte[buffer.remaining() - padding]; + buffer.get(codecData); + + // Handle trailing data + if (padding > 0) { + if (compressed) + serverFlag0 = buffer.get(); + } + } + @Override public void read(ByteBuffer buffer) { packetId = buffer.getShort() & 0x0000FFFF; @@ -59,10 +100,6 @@ public class PacketBody0Voice extends PacketBody { clientId = buffer.getShort() & 0x0000FFFF; codecType = CodecType.fromId(buffer.get() & 0xFF); - - codecData = new byte[buffer.remaining()]; - - buffer.get(codecData); } @Override @@ -75,10 +112,17 @@ public class PacketBody0Voice extends PacketBody { buffer.put((byte)(codecType.getIndex() & 0xFF)); buffer.put(codecData); + + if (serverFlag0 != null) + buffer.put(serverFlag0); } @Override public int getSize() { - return 2 + (getRole() == ProtocolRole.SERVER ? 2 : 0) + 1 + codecData.length; + return 2 + + (getRole() == ProtocolRole.SERVER ? 2 : 0) + + 1 + + codecData.length + + (serverFlag0 != null ? 1 : 0); } } diff --git a/src/main/java/com/github/manevolent/ts3j/protocol/packet/PacketBody1VoiceWhisper.java b/src/main/java/com/github/manevolent/ts3j/protocol/packet/PacketBody1VoiceWhisper.java index 2ae4cce..5e70989 100644 --- a/src/main/java/com/github/manevolent/ts3j/protocol/packet/PacketBody1VoiceWhisper.java +++ b/src/main/java/com/github/manevolent/ts3j/protocol/packet/PacketBody1VoiceWhisper.java @@ -16,20 +16,42 @@ public class PacketBody1VoiceWhisper extends PacketBody { private WhisperTarget target; private byte[] codecData; + // Unknown at this time (have seen: 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07) + // Set for the first 5 packets of a new voice session + // I believe this is related to tracking opening a new decoder + // Not all new voice sessions will change this flag + // Best to ignore it for now, but it's here if you need it or figure it out + private Byte serverFlag0; + public PacketBody1VoiceWhisper(ProtocolRole role) { super(PacketBodyType.VOICE_WHISPER, role); } + public Byte getServerFlag0() { return serverFlag0; } + + public void setServerFlag0(Byte flag) { + this.serverFlag0 = flag; + } + @Override public void setHeaderValues(PacketHeader header) { if (target instanceof WhisperTargetGroup) header.setPacketFlag(HeaderFlag.NEW_PROTOCOL, true); else header.setPacketFlag(HeaderFlag.NEW_PROTOCOL, false); + + if (serverFlag0 != null) // Ensure padding is signaled + header.setPacketFlag(HeaderFlag.COMPRESSED, true); } @Override public void read(PacketHeader header, ByteBuffer buffer) { + int padding = 0; + boolean compressed = header.getPacketFlag(HeaderFlag.COMPRESSED); + + if (compressed) + padding ++; + packetId = buffer.getShort() & 0xFFFF; if (getRole() == ProtocolRole.SERVER) @@ -37,7 +59,6 @@ public class PacketBody1VoiceWhisper extends PacketBody { codecType = CodecType.fromId((int) (buffer.get() & 0xFF)); - if (getRole() == ProtocolRole.CLIENT) { if (header.getPacketFlag(HeaderFlag.NEW_PROTOCOL)) { setTarget(new WhisperTargetGroup()); @@ -50,14 +71,20 @@ public class PacketBody1VoiceWhisper extends PacketBody { target.read(buffer); - read(buffer); + codecData = new byte[buffer.remaining() - padding]; + buffer.get(codecData); + + // Handle trailing data + if (padding > 0) { + if (compressed) + serverFlag0 = buffer.get(); + } } // We implemented the above so this is unneccessary. @Override public void read(ByteBuffer buffer) { - codecData = new byte[buffer.remaining()]; - buffer.get(codecData); + throw new UnsupportedOperationException(); } @Override @@ -73,15 +100,18 @@ public class PacketBody1VoiceWhisper extends PacketBody { target.write(buffer); buffer.put(codecData); + + if (serverFlag0 != null) + buffer.put(serverFlag0); } @Override public int getSize() { switch (getRole()) { case CLIENT: - return 2 + 1 + target.getSize() + codecData.length; + return 2 + 1 + target.getSize() + codecData.length + (serverFlag0 != null ? 1 : 0); case SERVER: - return 2 + 2 + 1 + codecData.length; + return 2 + 2 + 1 + codecData.length + (serverFlag0 != null ? 1 : 0); default: throw new IllegalArgumentException("unknown role"); } diff --git a/src/test/java/com/github/manevolent/ts3j/ServerConnectionTest.java b/src/test/java/com/github/manevolent/ts3j/ServerConnectionTest.java index 752950c..2a2cd4c 100644 --- a/src/test/java/com/github/manevolent/ts3j/ServerConnectionTest.java +++ b/src/test/java/com/github/manevolent/ts3j/ServerConnectionTest.java @@ -5,6 +5,7 @@ import com.github.manevolent.ts3j.audio.Microphone; import com.github.manevolent.ts3j.enums.CodecType; import com.github.manevolent.ts3j.event.*; import com.github.manevolent.ts3j.identity.LocalIdentity; +import com.github.manevolent.ts3j.protocol.Packet; import com.github.manevolent.ts3j.protocol.client.ClientConnectionState; import com.github.manevolent.ts3j.protocol.packet.PacketBody0Voice; import com.github.manevolent.ts3j.protocol.socket.client.LocalTeamspeakClientSocket; @@ -22,7 +23,7 @@ public class ServerConnectionTest { LocalTeamspeakClientSocket client = new LocalTeamspeakClientSocket(); - Ts3Debugging.setEnabled(true); + Ts3Debugging.setEnabled(false); LocalIdentity identity = LocalIdentity.generateNew(10); @@ -30,6 +31,10 @@ public class ServerConnectionTest { client.setNickname("ts3j issue 2"); client.setHWID("TestTestTest"); + client.setVoiceHandler(packet -> + System.out.println(((PacketBody0Voice)packet.getBody()).getServerFlag0()) + ); + while (true) { try { client.connect( From 2202b3ab9acaf4f58b238b93833cf5812c0416be Mon Sep 17 00:00:00 2001 From: Manevolent Date: Sat, 13 Oct 2018 16:08:55 -0400 Subject: [PATCH 4/7] Now that we have discerned the issue with receiving audio packets, I feel better reverting back to only providing the packet body, and not the header also, in the user callbacks. --- .../handler/client/LocalClientHandlerFull.java | 8 ++++---- .../socket/client/AbstractTeamspeakClientSocket.java | 12 ++++++------ 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/src/main/java/com/github/manevolent/ts3j/protocol/packet/handler/client/LocalClientHandlerFull.java b/src/main/java/com/github/manevolent/ts3j/protocol/packet/handler/client/LocalClientHandlerFull.java index af998ea..9e1e2be 100644 --- a/src/main/java/com/github/manevolent/ts3j/protocol/packet/handler/client/LocalClientHandlerFull.java +++ b/src/main/java/com/github/manevolent/ts3j/protocol/packet/handler/client/LocalClientHandlerFull.java @@ -56,12 +56,12 @@ public abstract class LocalClientHandlerFull extends LocalClientHandler { break; case VOICE: - Consumer handler = getClient().getVoiceHandler(); - if (handler != null) handler.accept(packet); + Consumer handler = getClient().getVoiceHandler(); + if (handler != null) handler.accept((PacketBody0Voice)packet.getBody()); break; case VOICE_WHISPER: - Consumer whisperConsumer = getClient().getWhisperHandler(); - if (whisperConsumer != null) whisperConsumer.accept(packet); + Consumer whisperConsumer = getClient().getWhisperHandler(); + if (whisperConsumer != null) whisperConsumer.accept((PacketBody1VoiceWhisper)packet.getBody()); break; } } diff --git a/src/main/java/com/github/manevolent/ts3j/protocol/socket/client/AbstractTeamspeakClientSocket.java b/src/main/java/com/github/manevolent/ts3j/protocol/socket/client/AbstractTeamspeakClientSocket.java index bf0bc26..020e1d8 100644 --- a/src/main/java/com/github/manevolent/ts3j/protocol/socket/client/AbstractTeamspeakClientSocket.java +++ b/src/main/java/com/github/manevolent/ts3j/protocol/socket/client/AbstractTeamspeakClientSocket.java @@ -70,8 +70,8 @@ public abstract class AbstractTeamspeakClientSocket private CommandProcessor commandProcessor; - private Consumer voiceHandler; - private Consumer whisperHandler; + private Consumer voiceHandler; + private Consumer whisperHandler; private Consumer exceptionHandler = Throwable::printStackTrace; @@ -897,19 +897,19 @@ public abstract class AbstractTeamspeakClientSocket this.exceptionHandler = exceptionHandler; } - public Consumer getVoiceHandler() { + public Consumer getVoiceHandler() { return voiceHandler; } - public void setVoiceHandler(Consumer voiceHandler) { + public void setVoiceHandler(Consumer voiceHandler) { this.voiceHandler = voiceHandler; } - public Consumer getWhisperHandler() { + public Consumer getWhisperHandler() { return whisperHandler; } - public void setWhisperHandler(Consumer whisperHandler) { + public void setWhisperHandler(Consumer whisperHandler) { this.whisperHandler = whisperHandler; } From 61ce9df1f83834f8ab2435660b3056cae7888810 Mon Sep 17 00:00:00 2001 From: Manevolent Date: Sat, 13 Oct 2018 16:14:07 -0400 Subject: [PATCH 5/7] Compilation issues with jitpack --- src/main/java/com/github/manevolent/ts3j/util/Ts3Crypt.java | 3 --- .../java/com/github/manevolent/ts3j/ServerConnectionTest.java | 2 +- 2 files changed, 1 insertion(+), 4 deletions(-) diff --git a/src/main/java/com/github/manevolent/ts3j/util/Ts3Crypt.java b/src/main/java/com/github/manevolent/ts3j/util/Ts3Crypt.java index 9483108..ffeb1ac 100644 --- a/src/main/java/com/github/manevolent/ts3j/util/Ts3Crypt.java +++ b/src/main/java/com/github/manevolent/ts3j/util/Ts3Crypt.java @@ -5,10 +5,8 @@ import Punisher.NaCl.Internal.Ed25519Ref10.GroupElementP3; import Punisher.NaCl.Internal.Ed25519Ref10.GroupOperations; import Punisher.NaCl.Internal.Ed25519Ref10.ScalarOperations; import Punisher.NaCl.Internal.Sha512; -import com.github.manevolent.ts3j.api.Message; import com.github.manevolent.ts3j.identity.*; import com.github.manevolent.ts3j.license.License; -import com.github.manevolent.ts3j.util.Pair; import org.bouncycastle.asn1.*; import org.bouncycastle.crypto.digests.SHA256Digest; import org.bouncycastle.crypto.params.ECDomainParameters; @@ -25,7 +23,6 @@ import java.io.IOException; import java.math.BigInteger; import java.nio.ByteBuffer; import java.security.*; -import java.util.Base64; import java.util.List; public final class Ts3Crypt { diff --git a/src/test/java/com/github/manevolent/ts3j/ServerConnectionTest.java b/src/test/java/com/github/manevolent/ts3j/ServerConnectionTest.java index 2a2cd4c..ca51b07 100644 --- a/src/test/java/com/github/manevolent/ts3j/ServerConnectionTest.java +++ b/src/test/java/com/github/manevolent/ts3j/ServerConnectionTest.java @@ -32,7 +32,7 @@ public class ServerConnectionTest { client.setHWID("TestTestTest"); client.setVoiceHandler(packet -> - System.out.println(((PacketBody0Voice)packet.getBody()).getServerFlag0()) + System.out.println(packet.getServerFlag0()) ); while (true) { From 7889dc0caf9a39bb09f7f41aa257c61e4fe4dcaa Mon Sep 17 00:00:00 2001 From: Manevolent Date: Sat, 13 Oct 2018 16:31:34 -0400 Subject: [PATCH 6/7] Send serverflag0 with new packets as a test of sorts --- .../socket/client/LocalTeamspeakClientSocket.java | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/src/main/java/com/github/manevolent/ts3j/protocol/socket/client/LocalTeamspeakClientSocket.java b/src/main/java/com/github/manevolent/ts3j/protocol/socket/client/LocalTeamspeakClientSocket.java index c3a1482..db71946 100644 --- a/src/main/java/com/github/manevolent/ts3j/protocol/socket/client/LocalTeamspeakClientSocket.java +++ b/src/main/java/com/github/manevolent/ts3j/protocol/socket/client/LocalTeamspeakClientSocket.java @@ -507,6 +507,8 @@ public class LocalTeamspeakClientSocket private class MicrophoneTask implements Runnable { private boolean wasSendingAudio = false; + private byte sessionId = 1; + private int flaggedPackets = 5; @Override public void run() { @@ -525,12 +527,17 @@ public class LocalTeamspeakClientSocket } else if (microphone.isReady()) { PacketBody0Voice voice = new PacketBody0Voice(getRole().getOut()); + if (flaggedPackets > 0) { + voice.setServerFlag0(sessionId); + } + voice.setCodecType(microphone.getCodec()); voice.setCodecData(microphone.provide()); try { writePacket(voice); + flaggedPackets --; wasSendingAudio = true; } catch (Exception e) { // All we are really concerned about here is a disconnection event, in which case the loop @@ -546,6 +553,13 @@ public class LocalTeamspeakClientSocket try { writePacket(voice); + // reset decoder flag + flaggedPackets = 5; + sessionId ++; + + if (sessionId >= 8) + sessionId = 1; + wasSendingAudio = false; } catch (Exception e) { // All we are really concerned about here is a disconnection event, in which case the loop From 99398369f18f3c3fe5e32bbf636a2cdcc0fb462b Mon Sep 17 00:00:00 2001 From: Manevolent Date: Sat, 13 Oct 2018 16:32:23 -0400 Subject: [PATCH 7/7] Move stuff around --- .../socket/client/LocalTeamspeakClientSocket.java | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/main/java/com/github/manevolent/ts3j/protocol/socket/client/LocalTeamspeakClientSocket.java b/src/main/java/com/github/manevolent/ts3j/protocol/socket/client/LocalTeamspeakClientSocket.java index db71946..cb2d7c8 100644 --- a/src/main/java/com/github/manevolent/ts3j/protocol/socket/client/LocalTeamspeakClientSocket.java +++ b/src/main/java/com/github/manevolent/ts3j/protocol/socket/client/LocalTeamspeakClientSocket.java @@ -525,14 +525,14 @@ public class LocalTeamspeakClientSocket // TODO // Set a state and send a muted event } else if (microphone.isReady()) { + byte[] data = microphone.provide(); + if (data.length <= 0) return; + PacketBody0Voice voice = new PacketBody0Voice(getRole().getOut()); - if (flaggedPackets > 0) { - voice.setServerFlag0(sessionId); - } - voice.setCodecType(microphone.getCodec()); - voice.setCodecData(microphone.provide()); + voice.setCodecData(data); + if (flaggedPackets > 0) voice.setServerFlag0(sessionId); try { writePacket(voice);