Microphone changes
This commit is contained in:
+5
-4
@@ -198,7 +198,7 @@ public class LocalTeamspeakClientSocket
|
|||||||
waitForState(ClientConnectionState.CONNECTED, timeout);
|
waitForState(ClientConnectionState.CONNECTED, timeout);
|
||||||
|
|
||||||
microphoneThread = new HighPrecisionRecurrentTask(
|
microphoneThread = new HighPrecisionRecurrentTask(
|
||||||
1000,
|
20,
|
||||||
0.020F,
|
0.020F,
|
||||||
new MicrophoneTask()
|
new MicrophoneTask()
|
||||||
);
|
);
|
||||||
@@ -328,11 +328,10 @@ public class LocalTeamspeakClientSocket
|
|||||||
private class MicrophoneTask implements Runnable {
|
private class MicrophoneTask implements Runnable {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
PacketBody0Voice voice = new PacketBody0Voice(getRole().getOut());
|
|
||||||
Microphone microphone;
|
|
||||||
|
|
||||||
if (!isConnected()) return;
|
if (!isConnected()) return;
|
||||||
|
|
||||||
|
Microphone microphone;
|
||||||
|
|
||||||
// Attempt to get the current microphone instance, saving it in a variable to prevent
|
// Attempt to get the current microphone instance, saving it in a variable to prevent
|
||||||
// any race conditions by accessing the parent class' this.microphone.
|
// any race conditions by accessing the parent class' this.microphone.
|
||||||
if ((microphone = LocalTeamspeakClientSocket.this.microphone) == null)
|
if ((microphone = LocalTeamspeakClientSocket.this.microphone) == null)
|
||||||
@@ -342,6 +341,8 @@ public class LocalTeamspeakClientSocket
|
|||||||
// TODO
|
// TODO
|
||||||
// Set a state and send a muted event
|
// Set a state and send a muted event
|
||||||
} else if (microphone.isReady()) {
|
} else if (microphone.isReady()) {
|
||||||
|
PacketBody0Voice voice = new PacketBody0Voice(getRole().getOut());
|
||||||
|
|
||||||
voice.setCodecType(microphone.getCodec());
|
voice.setCodecType(microphone.getCodec());
|
||||||
voice.setCodecData(microphone.provide());
|
voice.setCodecData(microphone.provide());
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,8 @@
|
|||||||
package com.github.manevolent.ts3j;
|
package com.github.manevolent.ts3j;
|
||||||
|
|
||||||
import com.github.manevolent.ts3j.api.Client;
|
import com.github.manevolent.ts3j.api.Client;
|
||||||
|
import com.github.manevolent.ts3j.audio.Microphone;
|
||||||
|
import com.github.manevolent.ts3j.enums.CodecType;
|
||||||
import com.github.manevolent.ts3j.identity.LocalIdentity;
|
import com.github.manevolent.ts3j.identity.LocalIdentity;
|
||||||
import com.github.manevolent.ts3j.protocol.client.ClientConnectionState;
|
import com.github.manevolent.ts3j.protocol.client.ClientConnectionState;
|
||||||
import com.github.manevolent.ts3j.protocol.socket.client.LocalTeamspeakClientSocket;
|
import com.github.manevolent.ts3j.protocol.socket.client.LocalTeamspeakClientSocket;
|
||||||
@@ -25,6 +27,24 @@ public class ServerConnectionTest {
|
|||||||
|
|
||||||
LocalTeamspeakClientSocket client = new LocalTeamspeakClientSocket();
|
LocalTeamspeakClientSocket client = new LocalTeamspeakClientSocket();
|
||||||
|
|
||||||
|
client.setMicrophone(new Microphone() {
|
||||||
|
@Override
|
||||||
|
public boolean isReady() {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public CodecType getCodec() {
|
||||||
|
return CodecType.OPUS_MUSIC;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public byte[] provide() {
|
||||||
|
System.err.println("Provide.");
|
||||||
|
return new byte[0];
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
client.setIdentity(identity);
|
client.setIdentity(identity);
|
||||||
|
|
||||||
client.setNickname("Hello from Java");
|
client.setNickname("Hello from Java");
|
||||||
@@ -42,11 +62,7 @@ public class ServerConnectionTest {
|
|||||||
|
|
||||||
assertEquals(client.getState(), ClientConnectionState.CONNECTED);
|
assertEquals(client.getState(), ClientConnectionState.CONNECTED);
|
||||||
|
|
||||||
for (Client c : client.listClients()) {
|
client.setNickname("gjklsdfkjlgdsfgd2");
|
||||||
client.getClientInfo(c.getId());
|
|
||||||
}
|
|
||||||
|
|
||||||
client.disconnect();
|
|
||||||
|
|
||||||
client.waitForState(ClientConnectionState.DISCONNECTED, 10000L);
|
client.waitForState(ClientConnectionState.DISCONNECTED, 10000L);
|
||||||
} catch (Throwable ex) {
|
} catch (Throwable ex) {
|
||||||
|
|||||||
Reference in New Issue
Block a user