Search in sources :

Example 1 with MpegFileTrackProvider

use of com.sedmelluq.discord.lavaplayer.container.mpeg.reader.MpegFileTrackProvider in project lavaplayer by sedmelluq.

the class MpegContainerProbe method probe.

@Override
public MediaContainerDetectionResult probe(AudioReference reference, SeekableInputStream inputStream) throws IOException {
    if (!checkNextBytes(inputStream, ISO_TAG)) {
        return null;
    }
    log.debug("Track {} is an MP4 file.", reference.identifier);
    MpegFileLoader file = new MpegFileLoader(inputStream);
    file.parseHeaders();
    MpegTrackInfo audioTrack = getSupportedAudioTrack(file);
    if (audioTrack == null) {
        return unsupportedFormat(this, "No supported audio format in the MP4 file.");
    }
    MpegTrackConsumer trackConsumer = new MpegNoopTrackConsumer(audioTrack);
    MpegFileTrackProvider fileReader = file.loadReader(trackConsumer);
    if (fileReader == null) {
        return unsupportedFormat(this, "MP4 file uses an unsupported format.");
    }
    AudioTrackInfo trackInfo = AudioTrackInfoBuilder.create(reference, inputStream).setTitle(file.getTextMetadata("Title")).setAuthor(file.getTextMetadata("Artist")).setLength(fileReader.getDuration()).build();
    return supportedFormat(this, null, trackInfo);
}
Also used : MpegFileTrackProvider(com.sedmelluq.discord.lavaplayer.container.mpeg.reader.MpegFileTrackProvider) AudioTrackInfo(com.sedmelluq.discord.lavaplayer.track.AudioTrackInfo)

Example 2 with MpegFileTrackProvider

use of com.sedmelluq.discord.lavaplayer.container.mpeg.reader.MpegFileTrackProvider in project lavaplayer by sedmelluq.

the class YoutubeMpegStreamAudioTrack method processSegmentStream.

private void processSegmentStream(SeekableInputStream stream, AudioProcessingContext context, TrackState state) throws InterruptedException {
    MpegFileLoader file = new MpegFileLoader(stream);
    file.parseHeaders();
    state.absoluteSequence = extractAbsoluteSequenceFromEvent(file.getLastEventMessage());
    if (state.trackConsumer == null) {
        state.trackConsumer = loadAudioTrack(file, context);
    }
    MpegFileTrackProvider fileReader = file.loadReader(state.trackConsumer);
    if (fileReader == null) {
        throw new FriendlyException("Unknown MP4 format.", SUSPICIOUS, null);
    }
    fileReader.provideFrames();
}
Also used : MpegFileLoader(com.sedmelluq.discord.lavaplayer.container.mpeg.MpegFileLoader) MpegFileTrackProvider(com.sedmelluq.discord.lavaplayer.container.mpeg.reader.MpegFileTrackProvider) FriendlyException(com.sedmelluq.discord.lavaplayer.tools.FriendlyException)

Example 3 with MpegFileTrackProvider

use of com.sedmelluq.discord.lavaplayer.container.mpeg.reader.MpegFileTrackProvider in project lavaplayer by sedmelluq.

the class MpegAudioTrack method process.

@Override
public void process(LocalAudioTrackExecutor localExecutor) {
    MpegFileLoader file = new MpegFileLoader(inputStream);
    file.parseHeaders();
    MpegTrackConsumer trackConsumer = loadAudioTrack(file, localExecutor.getProcessingContext());
    try {
        MpegFileTrackProvider fileReader = file.loadReader(trackConsumer);
        if (fileReader == null) {
            throw new FriendlyException("Unknown MP4 format.", SUSPICIOUS, null);
        }
        accurateDuration.set(fileReader.getDuration());
        localExecutor.executeProcessingLoop(fileReader::provideFrames, fileReader::seekToTimecode);
    } finally {
        trackConsumer.close();
    }
}
Also used : MpegFileTrackProvider(com.sedmelluq.discord.lavaplayer.container.mpeg.reader.MpegFileTrackProvider) FriendlyException(com.sedmelluq.discord.lavaplayer.tools.FriendlyException)

Aggregations

MpegFileTrackProvider (com.sedmelluq.discord.lavaplayer.container.mpeg.reader.MpegFileTrackProvider)3 FriendlyException (com.sedmelluq.discord.lavaplayer.tools.FriendlyException)2 MpegFileLoader (com.sedmelluq.discord.lavaplayer.container.mpeg.MpegFileLoader)1 AudioTrackInfo (com.sedmelluq.discord.lavaplayer.track.AudioTrackInfo)1