Skip to content

Commit 50272db

Browse files
StypoxAudricV
authored andcommitted
Apply reviews: improve comments, remove FILE, remove Stream#equals(Stream)
1 parent 07b045f commit 50272db

7 files changed

Lines changed: 42 additions & 103 deletions

File tree

extractor/src/main/java/org/schabi/newpipe/extractor/services/media_ccc/extractors/MediaCCCLiveStreamExtractor.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -210,7 +210,7 @@ private <T extends Stream> List<T> getStreams(
210210
// Ensure that we use only process JsonObjects
211211
.filter(JsonObject.class::isInstance)
212212
.map(JsonObject.class::cast)
213-
// Only process audio streams
213+
// Only process streams of requested type
214214
.filter(streamJsonObj -> streamType.equals(streamJsonObj.getString("type")))
215215
// Flatmap Urls and ensure that we use only process JsonObjects
216216
.flatMap(streamJsonObj -> streamJsonObj.getObject(URLS).entrySet().stream()

extractor/src/main/java/org/schabi/newpipe/extractor/services/media_ccc/extractors/MediaCCCStreamExtractor.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -147,8 +147,8 @@ public List<VideoStream> getVideoStreams() throws ExtractionException {
147147
mediaFormat = null;
148148
}
149149

150-
// Don't use the containsSimilarStream method because it will remove the
151-
// extraction of some video versions (mostly languages). So if there are multiple
150+
// Don't use the containsSimilarStream method because it will prevent the
151+
// extraction of some video variations (mostly languages). So if there are multiple
152152
// video streams available, only the first one will be extracted in this case.
153153
videoStreams.add(new VideoStream.Builder()
154154
.setId(recording.getString("filename", ID_UNKNOWN))

extractor/src/main/java/org/schabi/newpipe/extractor/services/youtube/YoutubeParsingHelper.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1264,8 +1264,8 @@ public static String getAndroidUserAgent(@Nullable final Localization localizati
12641264
// Spoofing an Android 12 device with the hardcoded version of the Android app
12651265
return "com.google.android.youtube/" + MOBILE_YOUTUBE_CLIENT_VERSION
12661266
+ " (Linux; U; Android 12; "
1267-
+ (localization != null ? localization.getCountryCode()
1268-
: Localization.DEFAULT.getCountryCode())
1267+
+ (localization == null ? Localization.DEFAULT.getCountryCode()
1268+
: localization.getCountryCode())
12691269
+ ") gzip";
12701270
}
12711271

extractor/src/main/java/org/schabi/newpipe/extractor/stream/DeliveryMethod.java

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,13 @@
77
public enum DeliveryMethod {
88

99
/**
10-
* Enum constant which represents the use of the progressive HTTP streaming method to fetch a
11-
* {@link Stream stream}.
10+
* Used for {@link Stream}s served using the progressive HTTP streaming method.
1211
*/
1312
PROGRESSIVE_HTTP,
1413

1514
/**
16-
* Enum constant which represents the use of the DASH (Dynamic Adaptive Streaming over HTTP)
17-
* adaptive streaming method to fetch a {@link Stream stream}.
15+
* Used for {@link Stream}s served using the DASH (Dynamic Adaptive Streaming over HTTP)
16+
* adaptive streaming method.
1817
*
1918
* @see <a href="https://en.wikipedia.org/wiki/Dynamic_Adaptive_Streaming_over_HTTP">the
2019
* Dynamic Adaptive Streaming over HTTP Wikipedia page</a> and <a href="https://dashif.org/">
@@ -23,8 +22,8 @@ public enum DeliveryMethod {
2322
DASH,
2423

2524
/**
26-
* Enum constant which represents the use of the HLS (HTTP Live Streaming) adaptive streaming
27-
* method to fetch a {@link Stream stream}.
25+
* Used for {@link Stream}s served using the HLS (HTTP Live Streaming) adaptive streaming
26+
* method.
2827
*
2928
* @see <a href="https://en.wikipedia.org/wiki/HTTP_Live_Streaming">the HTTP Live Streaming
3029
* page</a> and <a href="https://developer.apple.com/streaming">Apple's developers website page
@@ -33,8 +32,7 @@ public enum DeliveryMethod {
3332
HLS,
3433

3534
/**
36-
* Enum constant which represents the use of the SmoothStreaming adaptive streaming method to
37-
* fetch a {@link Stream stream}.
35+
* Used for {@link Stream}s served using the SmoothStreaming adaptive streaming method.
3836
*
3937
* @see <a href="https://en.wikipedia.org/wiki/Adaptive_bitrate_streaming
4038
* #Microsoft_Smooth_Streaming_(MSS)">Wikipedia's page about adaptive bitrate streaming,
@@ -44,7 +42,7 @@ public enum DeliveryMethod {
4442
SS,
4543

4644
/**
47-
* Enum constant which represents the use of a torrent file to fetch a {@link Stream stream}.
45+
* Used for {@link Stream}s served via a torrent file.
4846
*
4947
* @see <a href="https://en.wikipedia.org/wiki/BitTorrent">Wikipedia's BitTorrent's page</a>,
5048
* <a href="https://en.wikipedia.org/wiki/Torrent_file">Wikipedia's page about torrent files

extractor/src/main/java/org/schabi/newpipe/extractor/stream/Stream.java

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -115,19 +115,6 @@ public boolean equalStats(@Nullable final Stream cmp) {
115115
: areUsingSameDeliveryMethodAndAreUrlStreams;
116116
}
117117

118-
/**
119-
* Reveals whether two streams are equal.
120-
*
121-
* @param cmp a {@link Stream} object to be compared to this {@link Stream} instance.
122-
* @return whether the compared streams are equal
123-
* @deprecated Use {@link #equalStats(Stream)} to compare statistics of two streams and
124-
* {@link #equals(Object)} to compare the equality of two streams instead.
125-
*/
126-
@Deprecated
127-
public boolean equals(final Stream cmp) {
128-
return equalStats(cmp) && content.equals(cmp.content);
129-
}
130-
131118
/**
132119
* Gets the identifier of this stream, e.g. the itag for YouTube.
133120
*
Lines changed: 28 additions & 68 deletions
Original file line numberDiff line numberDiff line change
@@ -1,114 +1,74 @@
11
package org.schabi.newpipe.extractor.stream;
22

33
/**
4-
* An enum representing the stream types of stream contents returned by the extractor.
4+
* An enum representing the stream type of a {@link StreamInfo} extracted by a {@link
5+
* StreamExtractor}.
56
*/
67
public enum StreamType {
78

89
/**
9-
* Placeholder to check if the stream type of stream content was checked or not.
10-
*
11-
* <p>
12-
* It doesn't make sense to use this enum constant outside of the extractor as it will never be
13-
* returned by an {@link org.schabi.newpipe.extractor.Extractor extractor} and is only used
14-
* internally.
15-
* </p>
10+
* Placeholder to check if the stream type was checked or not. It doesn't make sense to use this
11+
* enum constant outside of the extractor as it will never be returned by an {@link
12+
* org.schabi.newpipe.extractor.Extractor} and is only used internally.
1613
*/
1714
NONE,
1815

1916
/**
20-
* Enum constant to indicate that the stream type of stream content is a live video.
21-
*
22-
* <p>
23-
* Note that contents <strong>may contain audio streams</strong> even if they also contain
24-
* video streams (video-only or video with audio, depending of the stream/the content/the
25-
* service).
26-
* </p>
17+
* A normal video stream, usually with audio. Note that the {@link StreamInfo} <strong>can also
18+
* provide audio-only {@link AudioStream}s</strong> in addition to video or video-only {@link
19+
* VideoStream}s.
2720
*/
2821
VIDEO_STREAM,
2922

3023
/**
31-
* Enum constant to indicate that the stream type of stream content is an audio.
32-
*
33-
* <p>
34-
* Note that contents returned as audio streams should not return video streams.
35-
* </p>
36-
*
37-
* <p>
38-
* So, in order to prevent unexpected behaviors, stream extractors which are returning this
39-
* stream type for a content should ensure that no video stream is returned for this content.
40-
* </p>
24+
* An audio-only stream. There should be no {@link VideoStream}s available! In order to prevent
25+
* unexpected behaviors, when {@link StreamExtractor}s return this stream type, they should
26+
* ensure that no video stream is returned in {@link StreamExtractor#getVideoStreams()} and
27+
* {@link StreamExtractor#getVideoOnlyStreams()}.
4128
*/
4229
AUDIO_STREAM,
4330

4431
/**
45-
* Enum constant to indicate that the stream type of stream content is a video.
46-
*
47-
* <p>
48-
* Note that contents <strong>can contain audio live streams</strong> even if they also contain
49-
* live video streams (so video-only or video with audio, depending on the stream/the content/
50-
* the service).
51-
* </p>
32+
* A video live stream, usually with audio. Note that the {@link StreamInfo} <strong>can also
33+
* provide audio-only {@link AudioStream}s</strong> in addition to video or video-only {@link
34+
* VideoStream}s.
5235
*/
5336
LIVE_STREAM,
5437

5538
/**
56-
* Enum constant to indicate that the stream type of stream content is a live audio.
57-
*
58-
* <p>
59-
* Note that contents returned as live audio streams should not return live video streams.
60-
* </p>
61-
*
62-
* <p>
63-
* To prevent unexpected behavior, stream extractors which are returning this stream type for a
64-
* content should ensure that no live video stream is returned along with it.
65-
* </p>
39+
* An audio-only live stream. There should be no {@link VideoStream}s available! In order to
40+
* prevent unexpected behaviors, when {@link StreamExtractor}s return this stream type, they
41+
* should ensure that no video stream is returned in {@link StreamExtractor#getVideoStreams()}
42+
* and {@link StreamExtractor#getVideoOnlyStreams()}.
6643
*/
6744
AUDIO_LIVE_STREAM,
6845

6946
/**
70-
* Enum constant to indicate that the stream type of stream content is a video content of an
71-
* ended live video stream.
47+
* A video live stream that has just ended but has not yet been encoded into a normal video
48+
* stream. Note that the {@link StreamInfo} <strong>can also provide audio-only {@link
49+
* AudioStream}s</strong> in addition to video or video-only {@link VideoStream}s.
7250
*
7351
* <p>
7452
* Note that most of the content of an ended live video (or audio) may be extracted as {@link
7553
* #VIDEO_STREAM regular video contents} (or {@link #AUDIO_STREAM regular audio contents})
7654
* later, because the service may encode them again later as normal video/audio streams. That's
7755
* the case on YouTube, for example.
7856
* </p>
79-
*
80-
* <p>
81-
* Note that contents <strong>can contain post-live audio streams</strong> even if they also
82-
* contain post-live video streams (video-only or video with audio, depending of the stream/the
83-
* content/the service).
84-
* </p>
8557
*/
8658
POST_LIVE_STREAM,
8759

8860
/**
89-
* Enum constant to indicate that the stream type of stream content is an audio content of an
90-
* ended live audio stream.
61+
* An audio live stream that has just ended but has not yet been encoded into a normal audio
62+
* stream. There should be no {@link VideoStream}s available! In order to prevent unexpected
63+
* behaviors, when {@link StreamExtractor}s return this stream type, they should ensure that no
64+
* video stream is returned in {@link StreamExtractor#getVideoStreams()} and
65+
* {@link StreamExtractor#getVideoOnlyStreams()}.
9166
*
9267
* <p>
9368
* Note that most of ended live audio streams extracted with this value are processed as
9469
* {@link #AUDIO_STREAM regular audio streams} later, because the service may encode them
9570
* again later.
9671
* </p>
97-
*
98-
* <p>
99-
* Contents returned as post-live audio streams should not return post-live video streams.
100-
* </p>
101-
*
102-
* <p>
103-
* So, in order to prevent unexpected behaviors, stream extractors which are returning this
104-
* stream type for a content should ensure that no post-live video stream is returned for this
105-
* content.
106-
* </p>
107-
*/
108-
POST_LIVE_AUDIO_STREAM,
109-
110-
/**
111-
* Enum constant to indicate that the stream type of stream content is a file.
11272
*/
113-
FILE
73+
POST_LIVE_AUDIO_STREAM
11474
}

extractor/src/main/java/org/schabi/newpipe/extractor/utils/ManifestCreatorCache.java

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -141,17 +141,13 @@ public void reset() {
141141
}
142142

143143
/**
144-
* Returns the number of cached manifests in the cache.
145-
*
146-
* @return the number of cached manifests
144+
* @return the number of cached manifests in the cache
147145
*/
148146
public int size() {
149147
return concurrentHashMap.size();
150148
}
151149

152150
/**
153-
* Gets the maximum size of the cache.
154-
*
155151
* @return the maximum size of the cache
156152
*/
157153
public long getMaximumSize() {
@@ -188,9 +184,7 @@ public void resetMaximumSize() {
188184
}
189185

190186
/**
191-
* Gets the current clear factor of the cache, used when the cache limit size is reached.
192-
*
193-
* @return the current clear factor of the cache
187+
* @return the current clear factor of the cache, used when the cache limit size is reached
194188
*/
195189
public double getClearFactor() {
196190
return clearFactor;

0 commit comments

Comments
 (0)