Skip to content

Commit d302c3c

Browse files
Rename baseUrl to removeQueryParameters
Remove read override as not needed anymore Remove some TODOs
1 parent 53ae046 commit d302c3c

5 files changed

Lines changed: 24 additions & 46 deletions

File tree

app/src/main/java/org/schabi/newpipe/player/Player.java

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1055,24 +1055,6 @@ private Disposable getProgressUpdateDisposable() {
10551055

10561056
//endregion
10571057

1058-
1059-
/*//////////////////////////////////////////////////////////////////////////
1060-
// Playback states
1061-
//////////////////////////////////////////////////////////////////////////*/
1062-
//region Playback states
1063-
@Override
1064-
public void onPlayWhenReadyChanged(final boolean playWhenReady, final int reason) {
1065-
if (DEBUG) {
1066-
Log.d(TAG, "ExoPlayer - onPlayWhenReadyChanged() called with: "
1067-
+ "playWhenReady = [" + playWhenReady + "], "
1068-
+ "reason = [" + reason + "]");
1069-
}
1070-
final int playbackState = exoPlayerIsNull()
1071-
? com.google.android.exoplayer2.Player.STATE_IDLE
1072-
: simpleExoPlayer.getPlaybackState();
1073-
updatePlaybackState(playWhenReady, playbackState);
1074-
}
1075-
10761058
public static String exoplayerStateToString(final int playbackState) {
10771059
return switch (playbackState) {
10781060
case com.google.android.exoplayer2.Player.STATE_IDLE -> // 1
@@ -1101,6 +1083,24 @@ public static String stateToString(final int state) {
11011083
};
11021084
}
11031085

1086+
1087+
/*//////////////////////////////////////////////////////////////////////////
1088+
// Playback states
1089+
//////////////////////////////////////////////////////////////////////////*/
1090+
//region Playback states
1091+
@Override
1092+
public void onPlayWhenReadyChanged(final boolean playWhenReady, final int reason) {
1093+
if (DEBUG) {
1094+
Log.d(TAG, "ExoPlayer - onPlayWhenReadyChanged() called with: "
1095+
+ "playWhenReady = [" + playWhenReady + "], "
1096+
+ "reason = [" + reason + "]");
1097+
}
1098+
final int playbackState = exoPlayerIsNull()
1099+
? com.google.android.exoplayer2.Player.STATE_IDLE
1100+
: simpleExoPlayer.getPlaybackState();
1101+
updatePlaybackState(playWhenReady, playbackState);
1102+
}
1103+
11041104
@Override
11051105
public void onPlaybackStateChanged(final int playbackState) {
11061106
if (DEBUG) {
@@ -1114,7 +1114,7 @@ private void updatePlaybackState(final boolean playWhenReady, final int playback
11141114
if (DEBUG) {
11151115
Log.d(TAG, "ExoPlayer - updatePlaybackState() called with: "
11161116
+ "playWhenReady = [" + playWhenReady + "], "
1117-
+ "playbackState = [" + playbackState + "]");
1117+
+ "playbackState = [" + exoplayerStateToString(playbackState) + "]");
11181118
}
11191119

11201120
if (currentState == STATE_PAUSED_SEEK) {

app/src/main/java/org/schabi/newpipe/player/datasource/RefreshableHlsHttpDataSource.java

Lines changed: 4 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,6 @@ public class RefreshableHlsHttpDataSource extends LoggingHttpDataSource {
3131
private final RefreshableStream refreshableStream;
3232
private final String originalPlaylistUrl;
3333
private final Map<String, String> chunkUrlMap = new LinkedHashMap<>();
34-
private int readsCalled;
3534
private boolean isError;
3635

3736
public RefreshableHlsHttpDataSource(final RefreshableStream refreshableStream) {
@@ -55,12 +54,6 @@ public RefreshableHlsHttpDataSource(final RefreshableStream refreshableStream,
5554
originalPlaylistUrl = refreshableStream.initialUrl();
5655
}
5756

58-
@Override
59-
public int read(@NonNull final byte[] buffer, final int offset, final int length)
60-
throws HttpDataSourceException {
61-
return super.read(buffer, offset, length);
62-
}
63-
6457
@Override
6558
public long open(final DataSpec dataSpec) throws HttpDataSourceException {
6659
final var url = dataSpec.uri.toString();
@@ -101,10 +94,6 @@ private long openInternal(final DataSpec dataSpec) throws HttpDataSourceExceptio
10194
try {
10295
refreshPlaylist();
10396
} catch (final ExtractionException | IOException ex) {
104-
// TODO: better error here
105-
// TODO: so what happens when we throw exception here
106-
// and this method gets called again in this class?
107-
// if we want to prevent open being called again we need to throw a runtime
10897
throw new HttpDataSourceException("Error refreshing Hls playlist: "
10998
+ originalPlaylistUrl,
11099
new IOException(ex), dataSpec,
@@ -139,7 +128,7 @@ private static void initializeChunkMappings(final Map<String, String> chunkMap,
139128
final List<String> newChunks) {
140129
for (int i = 0; i < newChunks.size(); ++i) {
141130
final var newUrl = newChunks.get(i);
142-
chunkMap.put(getBaseUrl(newUrl), newUrl);
131+
chunkMap.put(removeQueryParameters(newUrl), newUrl);
143132
}
144133
}
145134

@@ -158,19 +147,18 @@ private static void updateChunkMap(final Map<String, String> chunkMap,
158147
}
159148
}
160149

161-
private static String getBaseUrl(final String url) {
150+
private static String removeQueryParameters(final String url) {
162151
final int idx = url.indexOf('?');
163152
return idx == -1 ? url : url.substring(0, idx);
164153
}
165154

166-
// TODO: better name
167155
private DataSpec getUpdatedDataSpec(final DataSpec dataSpec) {
168156
final var currentUrl = dataSpec.uri.toString();
169157
if (DEBUG) {
170158
Log.d(TAG, "getUpdatedDataSpec(" + currentUrl + ')');
171159
}
172-
// Playlist has expired, so get mapping for new url
173-
final var baseUrl = getBaseUrl(currentUrl);
160+
161+
final var baseUrl = removeQueryParameters(currentUrl);
174162

175163
if (baseUrl.equals(currentUrl)) {
176164
if (DEBUG) {
@@ -181,7 +169,6 @@ private DataSpec getUpdatedDataSpec(final DataSpec dataSpec) {
181169
final var updatedUrl = chunkUrlMap.get(baseUrl);
182170
if (updatedUrl == null) {
183171
throw new IllegalStateException("baseUrl not found in mappings: " + baseUrl);
184-
// TODO: problemo
185172
}
186173
if (DEBUG) {
187174
Log.d(TAG, "updated url:" + updatedUrl);

app/src/main/java/org/schabi/newpipe/player/playback/MediaSourceManager.java

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -447,11 +447,6 @@ private Single<ManagedMediaSource> getLoadedMediaSource(@NonNull final PlayQueue
447447
MediaItemTag.from(source.getMediaItem())
448448
.map(tag -> {
449449
final int serviceId = streamInfo.getServiceId();
450-
// CHECKSTYLE:OFF
451-
// TODO: So this expiration is false. Expiration starts from when stream is extracted
452-
// But here it is giving it fresh expiration as though the stream info is new, but it's not
453-
// So cache expiration is not 1-1 with stream expiration, but is it supposed to be?
454-
// CHECKSTYLE:ON
455450
final long expiration = System.currentTimeMillis()
456451
+ getCacheExpirationMillis(serviceId);
457452
return new LoadedMediaSource(source, tag, stream,

app/src/main/java/org/schabi/newpipe/util/InfoCache.java

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,6 @@ private static Info getInfo(@NonNull final String key) {
9090
}
9191

9292
if (data.isExpired()) {
93-
// TODO: oh so we do check expiry on retrieval!
9493
LRU_CACHE.remove(key);
9594
return null;
9695
}
@@ -117,9 +116,6 @@ public void putInfo(final int serviceId,
117116
@NonNull final Info info,
118117
@NonNull final Type cacheType) {
119118
final long expirationMillis = ServiceHelper.getCacheExpirationMillis(info.getServiceId());
120-
// CHECKSTYLE:OFF
121-
// TODO: Expired items get refreshed by being put again; they are not removed when they expire
122-
// CHECKSTYLE:ON
123119
if (DEBUG) {
124120
final var expiryDateInstant = Instant.now().plusMillis(expirationMillis);
125121
final var expiryDate = LocalDateTime.ofInstant(expiryDateInstant,

app/src/main/java/org/schabi/newpipe/util/ListHelper.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -304,7 +304,7 @@ public static List<AudioStream> getFilteredAudioStreams(
304304
for (final AudioStream stream : audioStreams) {
305305
// TODO: this doesn't add HLS OPUS streams, but soundcloud has that.
306306
// Meaning it never actually plays the OPUS soundcloud streams, only
307-
// progressive and hls mp3
307+
// progressive and hls mp3. So should we change this to allow HLS OPUS?
308308
if (stream.getDeliveryMethod() == DeliveryMethod.TORRENT
309309
|| (stream.getDeliveryMethod() == DeliveryMethod.HLS
310310
&& stream.getFormat() == MediaFormat.OPUS)) {

0 commit comments

Comments
 (0)