Commit 9041d7b9 by ibaker Committed by microkatz

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
parent 10c4a4df
...@@ -61,10 +61,7 @@ import org.checkerframework.checker.nullness.compatqual.NullableType; ...@@ -61,10 +61,7 @@ import org.checkerframework.checker.nullness.compatqual.NullableType;
import org.checkerframework.checker.nullness.qual.MonotonicNonNull; import org.checkerframework.checker.nullness.qual.MonotonicNonNull;
/** A {@link MediaPeriod} that loads an HLS stream. */ /** A {@link MediaPeriod} that loads an HLS stream. */
public final class HlsMediaPeriod public final class HlsMediaPeriod implements MediaPeriod, HlsPlaylistTracker.PlaylistEventListener {
implements MediaPeriod,
HlsSampleStreamWrapper.Callback,
HlsPlaylistTracker.PlaylistEventListener {
private final HlsExtractorFactory extractorFactory; private final HlsExtractorFactory extractorFactory;
private final HlsPlaylistTracker playlistTracker; private final HlsPlaylistTracker playlistTracker;
...@@ -82,8 +79,9 @@ public final class HlsMediaPeriod ...@@ -82,8 +79,9 @@ public final class HlsMediaPeriod
private final @HlsMediaSource.MetadataType int metadataType; private final @HlsMediaSource.MetadataType int metadataType;
private final boolean useSessionKeys; private final boolean useSessionKeys;
private final PlayerId playerId; private final PlayerId playerId;
private final HlsSampleStreamWrapper.Callback sampleStreamWrapperCallback;
@Nullable private Callback callback; @Nullable private MediaPeriod.Callback mediaPeriodCallback;
private int pendingPrepareCount; private int pendingPrepareCount;
private @MonotonicNonNull TrackGroupArray trackGroups; private @MonotonicNonNull TrackGroupArray trackGroups;
private HlsSampleStreamWrapper[] sampleStreamWrappers; private HlsSampleStreamWrapper[] sampleStreamWrappers;
...@@ -141,6 +139,7 @@ public final class HlsMediaPeriod ...@@ -141,6 +139,7 @@ public final class HlsMediaPeriod
this.metadataType = metadataType; this.metadataType = metadataType;
this.useSessionKeys = useSessionKeys; this.useSessionKeys = useSessionKeys;
this.playerId = playerId; this.playerId = playerId;
sampleStreamWrapperCallback = new SampleStreamWrapperCallback();
compositeSequenceableLoader = compositeSequenceableLoader =
compositeSequenceableLoaderFactory.createCompositeSequenceableLoader(); compositeSequenceableLoaderFactory.createCompositeSequenceableLoader();
streamWrapperIndices = new IdentityHashMap<>(); streamWrapperIndices = new IdentityHashMap<>();
...@@ -155,12 +154,12 @@ public final class HlsMediaPeriod ...@@ -155,12 +154,12 @@ public final class HlsMediaPeriod
for (HlsSampleStreamWrapper sampleStreamWrapper : sampleStreamWrappers) { for (HlsSampleStreamWrapper sampleStreamWrapper : sampleStreamWrappers) {
sampleStreamWrapper.release(); sampleStreamWrapper.release();
} }
callback = null; mediaPeriodCallback = null;
} }
@Override @Override
public void prepare(Callback callback, long positionUs) { public void prepare(Callback callback, long positionUs) {
this.callback = callback; this.mediaPeriodCallback = callback;
playlistTracker.addListener(this); playlistTracker.addListener(this);
buildAndPrepareSampleStreamWrappers(positionUs); buildAndPrepareSampleStreamWrappers(positionUs);
} }
...@@ -437,38 +436,6 @@ public final class HlsMediaPeriod ...@@ -437,38 +436,6 @@ public final class HlsMediaPeriod
// HlsSampleStreamWrapper.Callback implementation. // HlsSampleStreamWrapper.Callback implementation.
@Override
public void onPrepared() {
if (--pendingPrepareCount > 0) {
return;
}
int totalTrackGroupCount = 0;
for (HlsSampleStreamWrapper sampleStreamWrapper : sampleStreamWrappers) {
totalTrackGroupCount += sampleStreamWrapper.getTrackGroups().length;
}
TrackGroup[] trackGroupArray = new TrackGroup[totalTrackGroupCount];
int trackGroupIndex = 0;
for (HlsSampleStreamWrapper sampleStreamWrapper : sampleStreamWrappers) {
int wrapperTrackGroupCount = sampleStreamWrapper.getTrackGroups().length;
for (int j = 0; j < wrapperTrackGroupCount; j++) {
trackGroupArray[trackGroupIndex++] = sampleStreamWrapper.getTrackGroups().get(j);
}
}
trackGroups = new TrackGroupArray(trackGroupArray);
callback.onPrepared(this);
}
@Override
public void onPlaylistRefreshRequired(Uri url) {
playlistTracker.refreshPlaylist(url);
}
@Override
public void onContinueLoadingRequested(HlsSampleStreamWrapper sampleStreamWrapper) {
callback.onContinueLoadingRequested(this);
}
// PlaylistListener implementation. // PlaylistListener implementation.
@Override @Override
...@@ -476,7 +443,7 @@ public final class HlsMediaPeriod ...@@ -476,7 +443,7 @@ public final class HlsMediaPeriod
for (HlsSampleStreamWrapper streamWrapper : sampleStreamWrappers) { for (HlsSampleStreamWrapper streamWrapper : sampleStreamWrappers) {
streamWrapper.onPlaylistUpdated(); streamWrapper.onPlaylistUpdated();
} }
callback.onContinueLoadingRequested(this); mediaPeriodCallback.onContinueLoadingRequested(this);
} }
@Override @Override
...@@ -486,7 +453,7 @@ public final class HlsMediaPeriod ...@@ -486,7 +453,7 @@ public final class HlsMediaPeriod
for (HlsSampleStreamWrapper streamWrapper : sampleStreamWrappers) { for (HlsSampleStreamWrapper streamWrapper : sampleStreamWrappers) {
exclusionSucceeded &= streamWrapper.onPlaylistError(url, loadErrorInfo, forceRetry); exclusionSucceeded &= streamWrapper.onPlaylistError(url, loadErrorInfo, forceRetry);
} }
callback.onContinueLoadingRequested(this); mediaPeriodCallback.onContinueLoadingRequested(this);
return exclusionSucceeded; return exclusionSucceeded;
} }
...@@ -808,7 +775,7 @@ public final class HlsMediaPeriod ...@@ -808,7 +775,7 @@ public final class HlsMediaPeriod
return new HlsSampleStreamWrapper( return new HlsSampleStreamWrapper(
uid, uid,
trackType, trackType,
/* callback= */ this, /* callback= */ sampleStreamWrapperCallback,
defaultChunkSource, defaultChunkSource,
overridingDrmInitData, overridingDrmInitData,
allocator, allocator,
...@@ -913,4 +880,38 @@ public final class HlsMediaPeriod ...@@ -913,4 +880,38 @@ public final class HlsMediaPeriod
.setLanguage(language) .setLanguage(language)
.build(); .build();
} }
private class SampleStreamWrapperCallback implements HlsSampleStreamWrapper.Callback {
@Override
public void onPrepared() {
if (--pendingPrepareCount > 0) {
return;
}
int totalTrackGroupCount = 0;
for (HlsSampleStreamWrapper sampleStreamWrapper : sampleStreamWrappers) {
totalTrackGroupCount += sampleStreamWrapper.getTrackGroups().length;
}
TrackGroup[] trackGroupArray = new TrackGroup[totalTrackGroupCount];
int trackGroupIndex = 0;
for (HlsSampleStreamWrapper sampleStreamWrapper : sampleStreamWrappers) {
int wrapperTrackGroupCount = sampleStreamWrapper.getTrackGroups().length;
for (int j = 0; j < wrapperTrackGroupCount; j++) {
trackGroupArray[trackGroupIndex++] = sampleStreamWrapper.getTrackGroups().get(j);
}
}
trackGroups = new TrackGroupArray(trackGroupArray);
mediaPeriodCallback.onPrepared(HlsMediaPeriod.this);
}
@Override
public void onPlaylistRefreshRequired(Uri url) {
playlistTracker.refreshPlaylist(url);
}
@Override
public void onContinueLoadingRequested(HlsSampleStreamWrapper sampleStreamWrapper) {
mediaPeriodCallback.onContinueLoadingRequested(HlsMediaPeriod.this);
}
}
} }
...@@ -56,7 +56,7 @@ public final class RtpPayloadFormat { ...@@ -56,7 +56,7 @@ public final class RtpPayloadFormat {
public static final String RTP_MEDIA_VP9 = "VP9"; public static final String RTP_MEDIA_VP9 = "VP9";
/** Returns whether the format of a {@link MediaDescription} is supported. */ /** Returns whether the format of a {@link MediaDescription} is supported. */
public static boolean isFormatSupported(MediaDescription mediaDescription) { /* package */ static boolean isFormatSupported(MediaDescription mediaDescription) {
switch (Ascii.toUpperCase(mediaDescription.rtpMapAttribute.mediaEncoding)) { switch (Ascii.toUpperCase(mediaDescription.rtpMapAttribute.mediaEncoding)) {
case RTP_MEDIA_AC3: case RTP_MEDIA_AC3:
case RTP_MEDIA_AMR: case RTP_MEDIA_AMR:
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment