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);
}
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();
}
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();
}
}
Aggregations