Class Stream

  • All Implemented Interfaces:
    java.io.Serializable
    Direct Known Subclasses:
    AudioStream, SubtitlesStream, VideoStream

    public abstract class Stream
    extends java.lang.Object
    implements java.io.Serializable
    Abstract class which represents streams in the extractor.
    See Also:
    Serialized Form
    • Field Detail

      • 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:
        Constant Field Values
    • Constructor Detail

      • Stream

        public Stream​(java.lang.String id,
                      java.lang.String content,
                      boolean isUrl,
                      @Nullable
                      MediaFormat format,
                      DeliveryMethod deliveryMethod,
                      @Nullable
                      java.lang.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 Detail

      • containSimilarStream

        public static boolean containSimilarStream​(Stream stream,
                                                   java.util.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 java.lang.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 java.lang.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

        public java.lang.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
      • getManifestUrl

        @Nullable
        public java.lang.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