use of com.sedmelluq.discord.lavaplayer.track.info.AudioTrackInfoBuilder in project lavaplayer by sedmelluq.
the class OggContainerProbe method probe.
@Override
public MediaContainerDetectionResult probe(AudioReference reference, SeekableInputStream stream) throws IOException {
if (!checkNextBytes(stream, OGG_PAGE_HEADER)) {
return null;
}
log.debug("Track {} is an OGG stream.", reference.identifier);
AudioTrackInfoBuilder infoBuilder = AudioTrackInfoBuilder.create(reference, stream).setIsStream(true);
try {
collectStreamInformation(stream, infoBuilder);
} catch (Exception e) {
log.warn("Failed to collect additional information on OGG stream.", e);
}
return supportedFormat(this, null, infoBuilder.build());
}
use of com.sedmelluq.discord.lavaplayer.track.info.AudioTrackInfoBuilder in project lavaplayer by sedmelluq.
the class M3uPlaylistContainerProbe method probe.
@Override
public MediaContainerDetectionResult probe(AudioReference reference, SeekableInputStream inputStream) throws IOException {
if (!checkNextBytes(inputStream, M3U_HEADER_TAG) && !checkNextBytes(inputStream, M3U_ENTRY_TAG)) {
return null;
}
log.debug("Track {} is an M3U playlist file.", reference.identifier);
String[] lines = DataFormatTools.streamToLines(inputStream, StandardCharsets.UTF_8);
String hlsStreamUrl = HlsStreamSegmentUrlProvider.findHlsEntryUrl(lines);
if (hlsStreamUrl != null) {
AudioTrackInfoBuilder infoBuilder = AudioTrackInfoBuilder.create(reference, inputStream);
AudioReference httpReference = HttpAudioSourceManager.getAsHttpReference(reference);
if (httpReference != null) {
return supportedFormat(this, TYPE_HLS_OUTER, infoBuilder.setIdentifier(httpReference.identifier).build());
} else {
return refer(this, new AudioReference(hlsStreamUrl, infoBuilder.getTitle(), new MediaContainerDescriptor(this, TYPE_HLS_INNER)));
}
}
MediaContainerDetectionResult result = loadSingleItemPlaylist(lines);
if (result != null) {
return result;
}
return unsupportedFormat(this, "The playlist file contains no links.");
}
Aggregations