Package dev.lavalink.youtube.sabr
Class SabrStream
java.lang.Object
java.io.InputStream
com.sedmelluq.discord.lavaplayer.tools.io.SeekableInputStream
dev.lavalink.youtube.sabr.SabrStream
- All Implemented Interfaces:
Closeable,AutoCloseable
public class SabrStream
extends com.sedmelluq.discord.lavaplayer.tools.io.SeekableInputStream
A
SeekableInputStream that plays a YouTube SABR (Server Adaptive Bitrate) audio stream.
SABR formats do not expose a plain progressive download URL. Instead, media is retrieved by
POSTing a protobuf VideoPlaybackAbrRequest to a server ABR streaming URL and parsing the
UMP-formatted response into media segments. This class runs that request loop lazily as bytes are
consumed, concatenating the initialization segment followed by each media segment in order to
reconstruct a continuous (fragmented MP4 or WebM) byte stream that Lavaplayer's container readers
can consume.
The reconstructed bytes are retained in memory so that arbitrary (including backwards) seeks are supported without re-downloading. For audio this is a few megabytes at most.
-
Field Summary
Fields inherited from class com.sedmelluq.discord.lavaplayer.tools.io.SeekableInputStream
contentLength -
Constructor Summary
ConstructorsConstructorDescriptionSabrStream(@NotNull com.sedmelluq.discord.lavaplayer.tools.io.HttpInterface httpInterface, @NotNull URI serverAbrStreamingUrl, @org.jetbrains.annotations.NotNull byte[] ustreamerConfig, @org.jetbrains.annotations.Nullable byte[] poToken, @NotNull SabrClientInfo clientInfo, @NotNull FormatId audioFormatId, boolean drcEnabled, long contentLength, long durationMs) -
Method Summary
Methods inherited from class com.sedmelluq.discord.lavaplayer.tools.io.SeekableInputStream
getContentLength, getMaxSkipDistance, seek, skipFullyMethods inherited from class java.io.InputStream
available, mark, markSupported, nullInputStream, read, readAllBytes, readNBytes, readNBytes, reset, skipNBytes, transferTo
-
Constructor Details
-
SabrStream
public SabrStream(@NotNull @NotNull com.sedmelluq.discord.lavaplayer.tools.io.HttpInterface httpInterface, @NotNull @NotNull URI serverAbrStreamingUrl, @NotNull @org.jetbrains.annotations.NotNull byte[] ustreamerConfig, @Nullable @org.jetbrains.annotations.Nullable byte[] poToken, @NotNull @NotNull SabrClientInfo clientInfo, @NotNull @NotNull FormatId audioFormatId, boolean drcEnabled, long contentLength, long durationMs)
-
-
Method Details
-
getPosition
public long getPosition()- Specified by:
getPositionin classcom.sedmelluq.discord.lavaplayer.tools.io.SeekableInputStream
-
seekHard
- Specified by:
seekHardin classcom.sedmelluq.discord.lavaplayer.tools.io.SeekableInputStream- Throws:
IOException
-
canSeekHard
public boolean canSeekHard()- Specified by:
canSeekHardin classcom.sedmelluq.discord.lavaplayer.tools.io.SeekableInputStream
-
getTrackInfoProviders
public List<com.sedmelluq.discord.lavaplayer.track.info.AudioTrackInfoProvider> getTrackInfoProviders()- Specified by:
getTrackInfoProvidersin classcom.sedmelluq.discord.lavaplayer.tools.io.SeekableInputStream
-
read
- Specified by:
readin classInputStream- Throws:
IOException
-
read
public int read(@NotNull @org.jetbrains.annotations.NotNull byte[] b, int off, int len) throws IOException - Overrides:
readin classInputStream- Throws:
IOException
-
skip
- Overrides:
skipin classInputStream- Throws:
IOException
-
close
public void close()- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable- Overrides:
closein classInputStream
-