Search in sources :

Example 1 with AudioTrackInfoBuilder

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());
}
Also used : AudioTrackInfoBuilder(com.sedmelluq.discord.lavaplayer.track.info.AudioTrackInfoBuilder) IOException(java.io.IOException)

Example 2 with AudioTrackInfoBuilder

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.");
}
Also used : AudioTrackInfoBuilder(com.sedmelluq.discord.lavaplayer.track.info.AudioTrackInfoBuilder) MediaContainerDetectionResult(com.sedmelluq.discord.lavaplayer.container.MediaContainerDetectionResult) AudioReference(com.sedmelluq.discord.lavaplayer.track.AudioReference) MediaContainerDescriptor(com.sedmelluq.discord.lavaplayer.container.MediaContainerDescriptor)

Aggregations

AudioTrackInfoBuilder (com.sedmelluq.discord.lavaplayer.track.info.AudioTrackInfoBuilder)2 MediaContainerDescriptor (com.sedmelluq.discord.lavaplayer.container.MediaContainerDescriptor)1 MediaContainerDetectionResult (com.sedmelluq.discord.lavaplayer.container.MediaContainerDetectionResult)1 AudioReference (com.sedmelluq.discord.lavaplayer.track.AudioReference)1 IOException (java.io.IOException)1