use of com.sedmelluq.discord.lavaplayer.track.playback.AudioFrame in project lavaplayer by sedmelluq.
the class OpusPacketRouter method passThrough.
private void passThrough(ByteBuffer buffer) throws InterruptedException {
byte[] bytes = new byte[buffer.remaining()];
buffer.get(bytes);
context.frameConsumer.consume(new AudioFrame(currentTimecode, bytes, 100, inputFormat));
}
use of com.sedmelluq.discord.lavaplayer.track.playback.AudioFrame in project lavaplayer by sedmelluq.
the class TrackFrameDataCodec method encode.
@Override
public void encode(DataOutput out, TrackFrameDataMessage message) throws IOException {
out.writeLong(message.executorId);
out.writeInt(message.frames.size());
for (AudioFrame frame : message.frames) {
out.writeLong(frame.timecode);
out.writeInt(frame.data.length);
out.write(frame.data);
out.writeInt(frame.volume);
}
out.writeBoolean(message.finished);
out.writeLong(message.seekedPosition);
}
use of com.sedmelluq.discord.lavaplayer.track.playback.AudioFrame in project lavaplayer by sedmelluq.
the class TrackFrameDataCodec method decode.
@Override
public TrackFrameDataMessage decode(DataInput in, int version) throws IOException {
long executorId = in.readLong();
int frameCount = in.readInt();
List<AudioFrame> frames = new ArrayList<>(frameCount);
for (int i = 0; i < frameCount; i++) {
long timecode = in.readLong();
byte[] data = new byte[in.readInt()];
in.readFully(data);
frames.add(new AudioFrame(timecode, data, in.readInt(), null));
}
return new TrackFrameDataMessage(executorId, frames, in.readBoolean(), in.readLong());
}
use of com.sedmelluq.discord.lavaplayer.track.playback.AudioFrame in project lavaplayer by sedmelluq.
the class RemoteAudioTrackExecutor method provide.
@Override
public AudioFrame provide() {
AudioFrame frame = frameBuffer.provide();
processProvidedFrame(frame);
return frame;
}
use of com.sedmelluq.discord.lavaplayer.track.playback.AudioFrame in project lavaplayer by sedmelluq.
the class AudioPlayer method provideDirectly.
/**
* Provide an audio frame bypassing hooks.
* @param timeout Specifies the maximum time to wait for data. Pass 0 for non-blocking mode.
* @param unit Specifies the time unit of the maximum wait time.
* @return An audio frame if available, otherwise null
*/
public AudioFrame provideDirectly(long timeout, TimeUnit unit) throws TimeoutException, InterruptedException {
InternalAudioTrack track;
lastRequestTime = System.currentTimeMillis();
if (timeout == 0 && paused.get()) {
return null;
}
while ((track = activeTrack) != null) {
AudioFrame frame = timeout > 0 ? track.provide(timeout, unit) : track.provide();
if (frame != null) {
lastReceiveTime = System.nanoTime();
shadowTrack = null;
if (frame.isTerminator()) {
handleTerminator(track);
continue;
}
} else if (timeout == 0) {
checkStuck(track);
frame = provideShadowFrame();
}
return frame;
}
return null;
}
Aggregations