Search in sources :

Example 1 with MediaContainerDescriptor

use of com.sedmelluq.discord.lavaplayer.container.MediaContainerDescriptor in project lavaplayer by sedmelluq.

the class ProbingAudioSourceManager method decodeTrackFactory.

protected MediaContainerDescriptor decodeTrackFactory(DataInput input) throws IOException {
    String probeInfo = input.readUTF();
    int separatorPosition = probeInfo.indexOf(PARAMETERS_SEPARATOR);
    String probeName = separatorPosition < 0 ? probeInfo : probeInfo.substring(0, separatorPosition);
    String parameters = separatorPosition < 0 ? null : probeInfo.substring(separatorPosition + 1);
    MediaContainerProbe probe = containerRegistry.find(probeName);
    if (probe != null) {
        return new MediaContainerDescriptor(probe, parameters);
    }
    return null;
}
Also used : MediaContainerProbe(com.sedmelluq.discord.lavaplayer.container.MediaContainerProbe) MediaContainerDescriptor(com.sedmelluq.discord.lavaplayer.container.MediaContainerDescriptor)

Example 2 with MediaContainerDescriptor

use of com.sedmelluq.discord.lavaplayer.container.MediaContainerDescriptor 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

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