Search in sources :

Example 1 with AudioFrame

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

Example 2 with AudioFrame

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

Example 3 with AudioFrame

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());
}
Also used : ArrayList(java.util.ArrayList) AudioFrame(com.sedmelluq.discord.lavaplayer.track.playback.AudioFrame)

Example 4 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() {
    AudioFrame frame = frameBuffer.provide();
    processProvidedFrame(frame);
    return frame;
}
Also used : AudioFrame(com.sedmelluq.discord.lavaplayer.track.playback.AudioFrame)

Example 5 with AudioFrame

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;
}
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