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.

  • 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:
      getPosition in class com.sedmelluq.discord.lavaplayer.tools.io.SeekableInputStream
    • seekHard

      protected void seekHard(long position) throws IOException
      Specified by:
      seekHard in class com.sedmelluq.discord.lavaplayer.tools.io.SeekableInputStream
      Throws:
      IOException
    • canSeekHard

      public boolean canSeekHard()
      Specified by:
      canSeekHard in class com.sedmelluq.discord.lavaplayer.tools.io.SeekableInputStream
    • getTrackInfoProviders

      public List<com.sedmelluq.discord.lavaplayer.track.info.AudioTrackInfoProvider> getTrackInfoProviders()
      Specified by:
      getTrackInfoProviders in class com.sedmelluq.discord.lavaplayer.tools.io.SeekableInputStream
    • read

      public int read() throws IOException
      Specified by:
      read in class InputStream
      Throws:
      IOException
    • read

      public int read(@NotNull @org.jetbrains.annotations.NotNull byte[] b, int off, int len) throws IOException
      Overrides:
      read in class InputStream
      Throws:
      IOException
    • skip

      public long skip(long n) throws IOException
      Overrides:
      skip in class InputStream
      Throws:
      IOException
    • close

      public void close()
      Specified by:
      close in interface AutoCloseable
      Specified by:
      close in interface Closeable
      Overrides:
      close in class InputStream