use of com.sedmelluq.discord.lavaplayer.track.playback.AudioFrameBuffer in project lavaplayer by sedmelluq.
the class RemoteNodeProcessor method buildRequestBody.
private byte[] buildRequestBody() throws IOException {
ByteArrayOutputStream outputBytes = new ByteArrayOutputStream();
DataOutputStream output = new DataOutputStream(outputBytes);
List<RemoteMessage> messages = new ArrayList<>();
int queuedCount = queuedMessages.drainTo(messages);
if (queuedCount > 0) {
log.debug("Including {} queued messages in the request to {}.", queuedCount, nodeAddress);
}
for (RemoteAudioTrackExecutor executor : playingTracks.values()) {
long pendingSeek = executor.getPendingSeek();
AudioFrameBuffer buffer = executor.getAudioBuffer();
int neededFrames = pendingSeek == -1 ? buffer.getRemainingCapacity() : buffer.getFullCapacity();
messages.add(new TrackFrameRequestMessage(executor.getExecutorId(), neededFrames, executor.getVolume(), pendingSeek));
}
for (RemoteMessage message : messages) {
mapper.encode(output, message);
}
mapper.endOutput(output);
return outputBytes.toByteArray();
}
use of com.sedmelluq.discord.lavaplayer.track.playback.AudioFrameBuffer in project lavaplayer by sedmelluq.
the class RemoteNodeProcessor method handleTrackFrameData.
private void handleTrackFrameData(TrackFrameDataMessage message) throws Exception {
RemoteAudioTrackExecutor executor = playingTracks.get(message.executorId);
if (executor != null) {
if (message.seekedPosition >= 0) {
executor.clearSeek(message.seekedPosition);
}
AudioFrameBuffer buffer = executor.getAudioBuffer();
executor.receivedData();
AudioDataFormat format = executor.getConfiguration().getOutputFormat();
for (AudioFrame frame : message.frames) {
buffer.consume(new AudioFrame(frame.timecode, frame.data, frame.volume, format));
}
if (message.finished) {
buffer.setTerminateOnEmpty();
trackEnded(executor, false);
}
}
}
Aggregations