Class Stream
- java.lang.Object
-
- org.schabi.newpipe.extractor.stream.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 Summary
Fields Modifier and Type Field Description static int
FORMAT_ID_UNKNOWN
static java.lang.String
ID_UNKNOWN
static 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).
-
Constructor Summary
Constructors Constructor Description Stream(java.lang.String id, java.lang.String content, boolean isUrl, MediaFormat format, DeliveryMethod deliveryMethod, java.lang.String manifestUrl)
Instantiates a newStream
object.
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Deprecated Methods Modifier and Type Method Description static boolean
containSimilarStream(Stream stream, java.util.List<? extends Stream> streamList)
Checks if the list already contains a stream with the same statistics.boolean
equalStats(Stream other)
Reveals whether two streams have the same statistics (media format
anddelivery method
).java.lang.String
getContent()
Gets the content or URL.DeliveryMethod
getDeliveryMethod()
Gets theDeliveryMethod
.MediaFormat
getFormat()
Gets theMediaFormat
, which can be null.int
getFormatId()
Gets the format ID, which can be unknown.java.lang.String
getId()
Gets the identifier of this stream, e.g.abstract ItagItem
getItagItem()
Gets theItagItem
of a stream.java.lang.String
getManifestUrl()
Gets the URL of the manifest this stream comes from (if applicable, otherwise null).java.lang.String
getUrl()
Deprecated.UsegetContent()
instead.boolean
isUrl()
Returns whether the content is a URL or not.
-
-
-
Field Detail
-
FORMAT_ID_UNKNOWN
public static final int FORMAT_ID_UNKNOWN
- See Also:
- Constant Field Values
-
ID_UNKNOWN
public static final java.lang.String ID_UNKNOWN
- See Also:
- Constant Field Values
-
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 newStream
object.- Parameters:
id
- the identifier which uniquely identifies the file, e.g. for YouTube this would be the itagcontent
- the content or URL, depending on whether isUrl is trueisUrl
- whether content is the URL or the actual content of e.g. a DASH manifestformat
- theMediaFormat
, which can be nulldeliveryMethod
- the delivery method of the streammanifestUrl
- 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 liststreamList
- the list ofStream
s 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
anddelivery method
).If the
media format
of the stream is unknown, the streams are compared by using only thedelivery 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.UsegetContent()
instead.Gets the URL of this stream if the content is a URL, ornull
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 theMediaFormat
, 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 theDeliveryMethod
.- Returns:
- the delivery method
-
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
-
-