use of com.sedmelluq.discord.lavaplayer.remote.message.TrackFrameRequestMessage 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();
}
Aggregations