Skip to content

Commit 937c463

Browse files
icbakermicrokatz
authored andcommitted
Fix Dackka/Metalava errors in the HLS and RTSP modules
This makes two fixes: 1. Remove `HlsSampleStreamWrapper.Callback` (package-private) from the list of interfaces implemented by `HlsMediaPeriod` (`public`) and move the implementation to a private inner class instead. This avoids Metalava complaining about a public class that inherits from a package-private type. 2. Reduce the visibility of `RtpPayloadFormat.isFormatSupported(MediaDescription)` from `public` to package-private. The `MediaDescription` type is already package-private, so this method was already unusable outside the package. #minor-release PiperOrigin-RevId: 487472781 (cherry picked from commit dbfc0cc)
1 parent c2c9feb commit 937c463

File tree

2 files changed

+44
-43
lines changed

2 files changed

+44
-43
lines changed

libraries/exoplayer_hls/src/main/java/androidx/media3/exoplayer/hls/HlsMediaPeriod.java

Lines changed: 43 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -63,10 +63,7 @@
6363

6464
/** A {@link MediaPeriod} that loads an HLS stream. */
6565
@UnstableApi
66-
public final class HlsMediaPeriod
67-
implements MediaPeriod,
68-
HlsSampleStreamWrapper.Callback,
69-
HlsPlaylistTracker.PlaylistEventListener {
66+
public final class HlsMediaPeriod implements MediaPeriod, HlsPlaylistTracker.PlaylistEventListener {
7067

7168
private final HlsExtractorFactory extractorFactory;
7269
private final HlsPlaylistTracker playlistTracker;
@@ -84,8 +81,9 @@ public final class HlsMediaPeriod
8481
private final @HlsMediaSource.MetadataType int metadataType;
8582
private final boolean useSessionKeys;
8683
private final PlayerId playerId;
84+
private final HlsSampleStreamWrapper.Callback sampleStreamWrapperCallback;
8785

88-
@Nullable private Callback callback;
86+
@Nullable private MediaPeriod.Callback mediaPeriodCallback;
8987
private int pendingPrepareCount;
9088
private @MonotonicNonNull TrackGroupArray trackGroups;
9189
private HlsSampleStreamWrapper[] sampleStreamWrappers;
@@ -143,6 +141,7 @@ public HlsMediaPeriod(
143141
this.metadataType = metadataType;
144142
this.useSessionKeys = useSessionKeys;
145143
this.playerId = playerId;
144+
sampleStreamWrapperCallback = new SampleStreamWrapperCallback();
146145
compositeSequenceableLoader =
147146
compositeSequenceableLoaderFactory.createCompositeSequenceableLoader();
148147
streamWrapperIndices = new IdentityHashMap<>();
@@ -157,12 +156,12 @@ public void release() {
157156
for (HlsSampleStreamWrapper sampleStreamWrapper : sampleStreamWrappers) {
158157
sampleStreamWrapper.release();
159158
}
160-
callback = null;
159+
mediaPeriodCallback = null;
161160
}
162161

163162
@Override
164163
public void prepare(Callback callback, long positionUs) {
165-
this.callback = callback;
164+
this.mediaPeriodCallback = callback;
166165
playlistTracker.addListener(this);
167166
buildAndPrepareSampleStreamWrappers(positionUs);
168167
}
@@ -439,46 +438,14 @@ public long getAdjustedSeekPositionUs(long positionUs, SeekParameters seekParame
439438

440439
// HlsSampleStreamWrapper.Callback implementation.
441440

442-
@Override
443-
public void onPrepared() {
444-
if (--pendingPrepareCount > 0) {
445-
return;
446-
}
447-
448-
int totalTrackGroupCount = 0;
449-
for (HlsSampleStreamWrapper sampleStreamWrapper : sampleStreamWrappers) {
450-
totalTrackGroupCount += sampleStreamWrapper.getTrackGroups().length;
451-
}
452-
TrackGroup[] trackGroupArray = new TrackGroup[totalTrackGroupCount];
453-
int trackGroupIndex = 0;
454-
for (HlsSampleStreamWrapper sampleStreamWrapper : sampleStreamWrappers) {
455-
int wrapperTrackGroupCount = sampleStreamWrapper.getTrackGroups().length;
456-
for (int j = 0; j < wrapperTrackGroupCount; j++) {
457-
trackGroupArray[trackGroupIndex++] = sampleStreamWrapper.getTrackGroups().get(j);
458-
}
459-
}
460-
trackGroups = new TrackGroupArray(trackGroupArray);
461-
callback.onPrepared(this);
462-
}
463-
464-
@Override
465-
public void onPlaylistRefreshRequired(Uri url) {
466-
playlistTracker.refreshPlaylist(url);
467-
}
468-
469-
@Override
470-
public void onContinueLoadingRequested(HlsSampleStreamWrapper sampleStreamWrapper) {
471-
callback.onContinueLoadingRequested(this);
472-
}
473-
474441
// PlaylistListener implementation.
475442

476443
@Override
477444
public void onPlaylistChanged() {
478445
for (HlsSampleStreamWrapper streamWrapper : sampleStreamWrappers) {
479446
streamWrapper.onPlaylistUpdated();
480447
}
481-
callback.onContinueLoadingRequested(this);
448+
mediaPeriodCallback.onContinueLoadingRequested(this);
482449
}
483450

484451
@Override
@@ -488,7 +455,7 @@ public boolean onPlaylistError(
488455
for (HlsSampleStreamWrapper streamWrapper : sampleStreamWrappers) {
489456
exclusionSucceeded &= streamWrapper.onPlaylistError(url, loadErrorInfo, forceRetry);
490457
}
491-
callback.onContinueLoadingRequested(this);
458+
mediaPeriodCallback.onContinueLoadingRequested(this);
492459
return exclusionSucceeded;
493460
}
494461

@@ -810,7 +777,7 @@ private HlsSampleStreamWrapper buildSampleStreamWrapper(
810777
return new HlsSampleStreamWrapper(
811778
uid,
812779
trackType,
813-
/* callback= */ this,
780+
/* callback= */ sampleStreamWrapperCallback,
814781
defaultChunkSource,
815782
overridingDrmInitData,
816783
allocator,
@@ -915,4 +882,38 @@ private static Format deriveAudioFormat(
915882
.setLanguage(language)
916883
.build();
917884
}
885+
886+
private class SampleStreamWrapperCallback implements HlsSampleStreamWrapper.Callback {
887+
@Override
888+
public void onPrepared() {
889+
if (--pendingPrepareCount > 0) {
890+
return;
891+
}
892+
893+
int totalTrackGroupCount = 0;
894+
for (HlsSampleStreamWrapper sampleStreamWrapper : sampleStreamWrappers) {
895+
totalTrackGroupCount += sampleStreamWrapper.getTrackGroups().length;
896+
}
897+
TrackGroup[] trackGroupArray = new TrackGroup[totalTrackGroupCount];
898+
int trackGroupIndex = 0;
899+
for (HlsSampleStreamWrapper sampleStreamWrapper : sampleStreamWrappers) {
900+
int wrapperTrackGroupCount = sampleStreamWrapper.getTrackGroups().length;
901+
for (int j = 0; j < wrapperTrackGroupCount; j++) {
902+
trackGroupArray[trackGroupIndex++] = sampleStreamWrapper.getTrackGroups().get(j);
903+
}
904+
}
905+
trackGroups = new TrackGroupArray(trackGroupArray);
906+
mediaPeriodCallback.onPrepared(HlsMediaPeriod.this);
907+
}
908+
909+
@Override
910+
public void onPlaylistRefreshRequired(Uri url) {
911+
playlistTracker.refreshPlaylist(url);
912+
}
913+
914+
@Override
915+
public void onContinueLoadingRequested(HlsSampleStreamWrapper sampleStreamWrapper) {
916+
mediaPeriodCallback.onContinueLoadingRequested(HlsMediaPeriod.this);
917+
}
918+
}
918919
}

libraries/exoplayer_rtsp/src/main/java/androidx/media3/exoplayer/rtsp/RtpPayloadFormat.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ public final class RtpPayloadFormat {
5858
public static final String RTP_MEDIA_VP9 = "VP9";
5959

6060
/** Returns whether the format of a {@link MediaDescription} is supported. */
61-
public static boolean isFormatSupported(MediaDescription mediaDescription) {
61+
/* package */ static boolean isFormatSupported(MediaDescription mediaDescription) {
6262
switch (Ascii.toUpperCase(mediaDescription.rtpMapAttribute.mediaEncoding)) {
6363
case RTP_MEDIA_AC3:
6464
case RTP_MEDIA_AMR:

0 commit comments

Comments
 (0)