Search in sources :

Example 6 with AudioFrame

use of com.sedmelluq.discord.lavaplayer.track.playback.AudioFrame in project lavaplayer by sedmelluq.

the class PlayingTrackManager method handleTrackDataRequest.

@MessageHandler
private void handleTrackDataRequest(TrackFrameRequestMessage message, MessageOutput output) {
    List<AudioFrame> frames = new ArrayList<>();
    PlayingTrack track = tracks.get(message.executorId);
    boolean finished = false;
    if (track != null) {
        submitPendingMessages(track, output);
        track.lastFrameRequestTime = System.currentTimeMillis();
        track.volume.set(message.volume);
        if (message.seekPosition >= 0) {
            track.audioTrack.setPosition(message.seekPosition);
        }
        if (message.maximumFrames > 0) {
            track.lastNonZeroFrameRequestTime = track.lastFrameRequestTime;
        }
        finished = consumeFramesFromTrack(frames, track.audioTrack, message.maximumFrames);
        if (finished) {
            log.info("Clearing ended track {} (context {})", track.audioTrack.getIdentifier(), message.executorId);
            tracks.remove(message.executorId);
        }
    }
    output.send(new TrackFrameDataMessage(message.executorId, frames, finished, message.seekPosition));
}
Also used : ArrayList(java.util.ArrayList) TrackFrameDataMessage(com.sedmelluq.discord.lavaplayer.remote.message.TrackFrameDataMessage) AudioFrame(com.sedmelluq.discord.lavaplayer.track.playback.AudioFrame) MessageHandler(com.sedmelluq.discord.lavaplayer.node.message.MessageHandler)

Example 7 with AudioFrame

use of com.sedmelluq.discord.lavaplayer.track.playback.AudioFrame in project lavaplayer by sedmelluq.

the class RemoteAudioTrackExecutor method provide.

@Override
public AudioFrame provide(long timeout, TimeUnit unit) throws TimeoutException, InterruptedException {
    AudioFrame frame = frameBuffer.provide(timeout, unit);
    processProvidedFrame(frame);
    return frame;
}
Also used : AudioFrame(com.sedmelluq.discord.lavaplayer.track.playback.AudioFrame)

Example 8 with AudioFrame

use of com.sedmelluq.discord.lavaplayer.track.playback.AudioFrame 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);
        }
    }
}
Also used : AudioDataFormat(com.sedmelluq.discord.lavaplayer.format.AudioDataFormat) AudioFrameBuffer(com.sedmelluq.discord.lavaplayer.track.playback.AudioFrameBuffer) AudioFrame(com.sedmelluq.discord.lavaplayer.track.playback.AudioFrame)

Example 9 with AudioFrame

use of com.sedmelluq.discord.lavaplayer.track.playback.AudioFrame in project lavaplayer by sedmelluq.

the class AudioPlayer method provideShadowFrame.

private AudioFrame provideShadowFrame() {
    InternalAudioTrack shadow = shadowTrack;
    AudioFrame frame = null;
    if (shadow != null) {
        frame = shadow.provide();
        if (frame != null && frame.isTerminator()) {
            shadowTrack = null;
            frame = null;
        }
    }
    return frame;
}
Also used : InternalAudioTrack(com.sedmelluq.discord.lavaplayer.track.InternalAudioTrack) AudioFrame(com.sedmelluq.discord.lavaplayer.track.playback.AudioFrame)

Aggregations

AudioFrame (com.sedmelluq.discord.lavaplayer.track.playback.AudioFrame)9 InternalAudioTrack (com.sedmelluq.discord.lavaplayer.track.InternalAudioTrack)2 ArrayList (java.util.ArrayList)2 AudioDataFormat (com.sedmelluq.discord.lavaplayer.format.AudioDataFormat)1 MessageHandler (com.sedmelluq.discord.lavaplayer.node.message.MessageHandler)1 TrackFrameDataMessage (com.sedmelluq.discord.lavaplayer.remote.message.TrackFrameDataMessage)1 AudioFrameBuffer (com.sedmelluq.discord.lavaplayer.track.playback.AudioFrameBuffer)1