Class Stream

java.lang.Object
org.schabi.newpipe.extractor.stream.Stream
All Implemented Interfaces:
Serializable
Direct Known Subclasses:
AudioStream, SubtitlesStream, VideoStream

public abstract class Stream extends Object implements Serializable
Abstract class which represents streams in the extractor.
See Also:
  • Field Details

    • FORMAT_ID_UNKNOWN

      public static final int FORMAT_ID_UNKNOWN
      See Also:
    • ID_UNKNOWN

      public static final String ID_UNKNOWN
      See Also:
    • ITAG_NOT_AVAILABLE_OR_NOT_APPLICABLE

      public static final int ITAG_NOT_AVAILABLE_OR_NOT_APPLICABLE
      An integer to represent that the itag ID returned is not available (only for YouTube; this should never happen) or not applicable (for other services than YouTube).

      An itag should not have a negative value, so -1 is used for this constant.

      See Also:
  • Constructor Details

    • Stream

      public Stream(String id, String content, boolean isUrl, @Nullable MediaFormat format, DeliveryMethod deliveryMethod, @Nullable String manifestUrl)
      Instantiates a new Stream object.
      Parameters:
      id - the identifier which uniquely identifies the file, e.g. for YouTube this would be the itag
      content - the content or URL, depending on whether isUrl is true
      isUrl - whether content is the URL or the actual content of e.g. a DASH manifest
      format - the MediaFormat, which can be null
      deliveryMethod - the delivery method of the stream
      manifestUrl - the URL of the manifest this stream comes from (if applicable, otherwise null)
  • Method Details

    • containSimilarStream

      public static boolean containSimilarStream(@Nonnull Stream stream, List<? extends Stream> streamList)
      Checks if the list already contains a stream with the same statistics.
      Parameters:
      stream - the stream to be compared against the streams in the stream list
      streamList - the list of Streams which will be compared
      Returns:
      whether the list already contains one stream with equals stats
    • equalStats

      public boolean equalStats(@Nullable Stream other)
      Reveals whether two streams have the same statistics (media format and delivery method).

      If the media format of the stream is unknown, the streams are compared by using only the delivery method and their ID.

      Note: This method always returns false if the stream passed is null.

      Parameters:
      other - the stream object to be compared to this stream object
      Returns:
      whether the stream have the same stats or not, based on the criteria above
    • getId

      public String getId()
      Gets the identifier of this stream, e.g. the itag for YouTube.

      It should normally be unique, but ID_UNKNOWN may be returned as the identifier if the one used by the stream extractor cannot be extracted, which could happen if the extractor uses a value from a streaming service.

      Returns:
      the identifier (which may be ID_UNKNOWN)
    • getUrl

      @Deprecated @Nullable public String getUrl()
      Deprecated.
      Use getContent() instead.
      Gets the URL of this stream if the content is a URL, or null otherwise.
      Returns:
      the URL if the content is a URL, null otherwise
    • getContent

      @Nonnull public String getContent()
      Gets the content or URL.
      Returns:
      the content or URL
    • isUrl

      public boolean isUrl()
      Returns whether the content is a URL or not.
      Returns:
      true if the content of this stream is a URL, false if it's the actual content
    • getFormat

      @Nullable public MediaFormat getFormat()
      Gets the MediaFormat, which can be null.
      Returns:
      the format
    • getFormatId

      public int getFormatId()
      Gets the format ID, which can be unknown.
      Returns:
      the format ID or FORMAT_ID_UNKNOWN
    • getDeliveryMethod

      @Nonnull public DeliveryMethod getDeliveryMethod()
      Gets the DeliveryMethod.
      Returns:
      the delivery method
    • getManifestUrl

      @Nullable public String getManifestUrl()
      Gets the URL of the manifest this stream comes from (if applicable, otherwise null).
      Returns:
      the URL of the manifest this stream comes from or null
    • getItagItem

      @Nullable public abstract ItagItem getItagItem()
      Gets the ItagItem of a stream.

      If the stream is not from YouTube, this value will always be null.

      Returns:
      the ItagItem of the stream or null