first commit
Build AsminVoicechat / prepare-release (push) Successful in 14s
Build AsminVoicechat / build-and-test (17) (push) Canceled after 0s
Build AsminVoicechat / build-and-test (18) (push) Canceled after 0s
Build AsminVoicechat / build-and-test (19) (push) Canceled after 0s
Build AsminVoicechat / build-and-test (20) (push) Canceled after 0s
Build AsminVoicechat / build-and-test (21) (push) Canceled after 0s
Build AsminVoicechat / build-and-test (22) (push) Canceled after 0s
Build AsminVoicechat / build-and-test (23) (push) Canceled after 0s
Build AsminVoicechat / build-and-test (24) (push) Canceled after 0s
Build AsminVoicechat / build-and-test (25) (push) Canceled after 0s
Build AsminVoicechat / build-and-test (26) (push) Canceled after 0s
Build AsminVoicechat / build-and-test (27-ea) (push) Canceled after 0s
Build AsminVoicechat / build-and-test (16) (push) Canceled after 38s
Build AsminVoicechat / prepare-release (push) Successful in 14s
Build AsminVoicechat / build-and-test (17) (push) Canceled after 0s
Build AsminVoicechat / build-and-test (18) (push) Canceled after 0s
Build AsminVoicechat / build-and-test (19) (push) Canceled after 0s
Build AsminVoicechat / build-and-test (20) (push) Canceled after 0s
Build AsminVoicechat / build-and-test (21) (push) Canceled after 0s
Build AsminVoicechat / build-and-test (22) (push) Canceled after 0s
Build AsminVoicechat / build-and-test (23) (push) Canceled after 0s
Build AsminVoicechat / build-and-test (24) (push) Canceled after 0s
Build AsminVoicechat / build-and-test (25) (push) Canceled after 0s
Build AsminVoicechat / build-and-test (26) (push) Canceled after 0s
Build AsminVoicechat / build-and-test (27-ea) (push) Canceled after 0s
Build AsminVoicechat / build-and-test (16) (push) Canceled after 38s
This commit is contained in:
commit
bbccd4a815
454 files changed
+45050
No files matched your search
@@ -0,0 +1,116 @@
|
||||
/*
|
||||
* Decompiled with CFR 0.152.
|
||||
*
|
||||
* Could not load the following classes:
|
||||
* javax.annotation.Nullable
|
||||
*/
|
||||
package de.maxhenkel.voicechat.plugins.impl.opus;
|
||||
|
||||
import de.maxhenkel.voicechat.Voicechat;
|
||||
import de.maxhenkel.voicechat.api.opus.OpusDecoder;
|
||||
import de.maxhenkel.voicechat.concentus.OpusException;
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
public class JavaOpusDecoderImpl
|
||||
implements OpusDecoder {
|
||||
protected de.maxhenkel.voicechat.concentus.OpusDecoder opusDecoder;
|
||||
protected short[] buffer;
|
||||
protected int sampleRate;
|
||||
|
||||
public JavaOpusDecoderImpl(int sampleRate, int frameSize) {
|
||||
this.sampleRate = sampleRate;
|
||||
this.buffer = new short[frameSize];
|
||||
this.open();
|
||||
}
|
||||
|
||||
private void open() {
|
||||
if (this.opusDecoder != null) {
|
||||
return;
|
||||
}
|
||||
try {
|
||||
this.opusDecoder = new de.maxhenkel.voicechat.concentus.OpusDecoder(this.sampleRate, 1);
|
||||
}
|
||||
catch (OpusException e) {
|
||||
throw new IllegalStateException("Failed to create Opus decoder", e);
|
||||
}
|
||||
Voicechat.LOGGER.debug("Initializing Java Opus decoder with sample rate {} Hz, frame size {} bytes", this.sampleRate, this.buffer.length);
|
||||
}
|
||||
|
||||
@Override
|
||||
public short[] decode(@Nullable byte[] data) {
|
||||
int result;
|
||||
if (this.isClosed()) {
|
||||
throw new IllegalStateException("Decoder is closed");
|
||||
}
|
||||
try {
|
||||
result = data == null || data.length == 0 ? this.opusDecoder.decode(null, 0, 0, this.buffer, 0, this.buffer.length, true) : this.opusDecoder.decode(data, 0, data.length, this.buffer, 0, this.buffer.length, false);
|
||||
}
|
||||
catch (Exception e) {
|
||||
throw new RuntimeException("Failed to decode audio", e);
|
||||
}
|
||||
short[] audio = new short[result];
|
||||
System.arraycopy(this.buffer, 0, audio, 0, result);
|
||||
return audio;
|
||||
}
|
||||
|
||||
@Override
|
||||
public short[][] decode(byte[] data, int frames) {
|
||||
if (this.isClosed()) {
|
||||
throw new IllegalStateException("Decoder is closed");
|
||||
}
|
||||
if (frames <= 0) {
|
||||
throw new IllegalArgumentException("Frames must be greater than 0");
|
||||
}
|
||||
if (data == null || data.length == 0) {
|
||||
throw new IllegalArgumentException("Data must not be null or empty");
|
||||
}
|
||||
short[][] recovered = new short[frames][];
|
||||
try {
|
||||
int result;
|
||||
if (frames > 2) {
|
||||
for (int i = 0; i < frames - 2; ++i) {
|
||||
result = this.opusDecoder.decode(null, 0, 0, this.buffer, 0, this.buffer.length, true);
|
||||
short[] audio = new short[result];
|
||||
System.arraycopy(this.buffer, 0, audio, 0, result);
|
||||
recovered[i] = audio;
|
||||
}
|
||||
}
|
||||
if (frames > 1) {
|
||||
result = this.opusDecoder.decode(data, 0, data.length, this.buffer, 0, this.buffer.length, true);
|
||||
short[] audio = new short[result];
|
||||
System.arraycopy(this.buffer, 0, audio, 0, result);
|
||||
recovered[frames - 2] = audio;
|
||||
}
|
||||
result = this.opusDecoder.decode(data, 0, data.length, this.buffer, 0, this.buffer.length, false);
|
||||
short[] audio = new short[result];
|
||||
System.arraycopy(this.buffer, 0, audio, 0, result);
|
||||
recovered[frames - 1] = audio;
|
||||
}
|
||||
catch (Exception e) {
|
||||
throw new RuntimeException("Failed to decode audio", e);
|
||||
}
|
||||
return recovered;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isClosed() {
|
||||
return this.opusDecoder == null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void close() {
|
||||
if (this.isClosed()) {
|
||||
return;
|
||||
}
|
||||
this.opusDecoder = null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void resetState() {
|
||||
if (this.isClosed()) {
|
||||
throw new IllegalStateException("Decoder is closed");
|
||||
}
|
||||
this.opusDecoder.resetState();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,82 @@
|
||||
/*
|
||||
* Decompiled with CFR 0.152.
|
||||
*/
|
||||
package de.maxhenkel.voicechat.plugins.impl.opus;
|
||||
|
||||
import de.maxhenkel.voicechat.concentus.OpusApplication;
|
||||
import de.maxhenkel.voicechat.concentus.OpusEncoder;
|
||||
|
||||
public class JavaOpusEncoderImpl
|
||||
implements de.maxhenkel.voicechat.api.opus.OpusEncoder {
|
||||
protected OpusEncoder opusEncoder;
|
||||
protected byte[] buffer;
|
||||
protected int sampleRate;
|
||||
protected int frameSize;
|
||||
protected int maxPayloadSize;
|
||||
protected OpusApplication application;
|
||||
|
||||
public JavaOpusEncoderImpl(int sampleRate, int frameSize, int maxPayloadSize, OpusApplication application) {
|
||||
this.sampleRate = sampleRate;
|
||||
this.frameSize = frameSize;
|
||||
this.maxPayloadSize = maxPayloadSize;
|
||||
this.application = application;
|
||||
this.buffer = new byte[maxPayloadSize];
|
||||
this.open();
|
||||
}
|
||||
|
||||
private void open() {
|
||||
if (this.opusEncoder != null) {
|
||||
return;
|
||||
}
|
||||
try {
|
||||
this.opusEncoder = new OpusEncoder(this.sampleRate, 1, this.application);
|
||||
this.opusEncoder.setUseInbandFEC(true);
|
||||
this.opusEncoder.setPacketLossPercent(5);
|
||||
}
|
||||
catch (Exception e) {
|
||||
throw new IllegalStateException("Opus encoder error " + e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public byte[] encode(short[] rawAudio) {
|
||||
int result;
|
||||
if (this.isClosed()) {
|
||||
throw new IllegalStateException("Encoder is closed");
|
||||
}
|
||||
try {
|
||||
result = this.opusEncoder.encode(rawAudio, 0, this.frameSize, this.buffer, 0, this.buffer.length);
|
||||
}
|
||||
catch (Exception e) {
|
||||
throw new RuntimeException("Failed to encode audio data: " + e.getMessage());
|
||||
}
|
||||
if (result < 0) {
|
||||
throw new RuntimeException("Failed to encode audio data");
|
||||
}
|
||||
byte[] audio = new byte[result];
|
||||
System.arraycopy(this.buffer, 0, audio, 0, result);
|
||||
return audio;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void resetState() {
|
||||
if (this.isClosed()) {
|
||||
throw new IllegalStateException("Encoder is closed");
|
||||
}
|
||||
this.opusEncoder.resetState();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isClosed() {
|
||||
return this.opusEncoder == null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void close() {
|
||||
if (this.isClosed()) {
|
||||
return;
|
||||
}
|
||||
this.opusEncoder = null;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,46 @@
|
||||
/*
|
||||
* Decompiled with CFR 0.152.
|
||||
*/
|
||||
package de.maxhenkel.voicechat.plugins.impl.opus;
|
||||
|
||||
import de.maxhenkel.voicechat.api.opus.OpusDecoder;
|
||||
import de.maxhenkel.voicechat.api.opus.OpusEncoder;
|
||||
import de.maxhenkel.voicechat.api.opus.OpusEncoderMode;
|
||||
import de.maxhenkel.voicechat.concentus.OpusApplication;
|
||||
import de.maxhenkel.voicechat.plugins.impl.opus.JavaOpusDecoderImpl;
|
||||
import de.maxhenkel.voicechat.plugins.impl.opus.JavaOpusEncoderImpl;
|
||||
|
||||
public class OpusManager {
|
||||
public static final int SAMPLE_RATE = 48000;
|
||||
public static final int FRAME_SIZE = 960;
|
||||
|
||||
public static OpusEncoder createEncoder(int sampleRate, int frameSize, int maxPayloadSize, OpusApplication application) {
|
||||
return new JavaOpusEncoderImpl(sampleRate, frameSize, maxPayloadSize, application);
|
||||
}
|
||||
|
||||
public static OpusEncoder createEncoder(OpusEncoderMode mode) {
|
||||
OpusApplication application = OpusApplication.OPUS_APPLICATION_VOIP;
|
||||
if (mode != null) {
|
||||
switch (mode) {
|
||||
case AUDIO: {
|
||||
application = OpusApplication.OPUS_APPLICATION_AUDIO;
|
||||
break;
|
||||
}
|
||||
case RESTRICTED_LOWDELAY: {
|
||||
application = OpusApplication.OPUS_APPLICATION_RESTRICTED_LOWDELAY;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
return OpusManager.createEncoder(48000, 960, 1024, application);
|
||||
}
|
||||
|
||||
public static OpusDecoder createDecoder(int sampleRate, int frameSize) {
|
||||
return new JavaOpusDecoderImpl(sampleRate, frameSize);
|
||||
}
|
||||
|
||||
public static OpusDecoder createDecoder() {
|
||||
return OpusManager.createDecoder(48000, 960);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user