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
This commit is contained in:
parent
7905744a83
commit
dbfc0cc770
@ -63,10 +63,7 @@ import org.checkerframework.checker.nullness.qual.MonotonicNonNull;
|
||||
|
||||
/** A {@link MediaPeriod} that loads an HLS stream. */
|
||||
@UnstableApi
|
||||
public final class HlsMediaPeriod
|
||||
implements MediaPeriod,
|
||||
HlsSampleStreamWrapper.Callback,
|
||||
HlsPlaylistTracker.PlaylistEventListener {
|
||||
public final class HlsMediaPeriod implements MediaPeriod, HlsPlaylistTracker.PlaylistEventListener {
|
||||
|
||||
private final HlsExtractorFactory extractorFactory;
|
||||
private final HlsPlaylistTracker playlistTracker;
|
||||
@ -84,8 +81,9 @@ public final class HlsMediaPeriod
|
||||
private final @HlsMediaSource.MetadataType int metadataType;
|
||||
private final boolean useSessionKeys;
|
||||
private final PlayerId playerId;
|
||||
private final HlsSampleStreamWrapper.Callback sampleStreamWrapperCallback;
|
||||
|
||||
@Nullable private Callback callback;
|
||||
@Nullable private MediaPeriod.Callback mediaPeriodCallback;
|
||||
private int pendingPrepareCount;
|
||||
private @MonotonicNonNull TrackGroupArray trackGroups;
|
||||
private HlsSampleStreamWrapper[] sampleStreamWrappers;
|
||||
@ -143,6 +141,7 @@ public final class HlsMediaPeriod
|
||||
this.metadataType = metadataType;
|
||||
this.useSessionKeys = useSessionKeys;
|
||||
this.playerId = playerId;
|
||||
sampleStreamWrapperCallback = new SampleStreamWrapperCallback();
|
||||
compositeSequenceableLoader =
|
||||
compositeSequenceableLoaderFactory.createCompositeSequenceableLoader();
|
||||
streamWrapperIndices = new IdentityHashMap<>();
|
||||
@ -157,12 +156,12 @@ public final class HlsMediaPeriod
|
||||
for (HlsSampleStreamWrapper sampleStreamWrapper : sampleStreamWrappers) {
|
||||
sampleStreamWrapper.release();
|
||||
}
|
||||
callback = null;
|
||||
mediaPeriodCallback = null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void prepare(Callback callback, long positionUs) {
|
||||
this.callback = callback;
|
||||
this.mediaPeriodCallback = callback;
|
||||
playlistTracker.addListener(this);
|
||||
buildAndPrepareSampleStreamWrappers(positionUs);
|
||||
}
|
||||
@ -439,38 +438,6 @@ public final class HlsMediaPeriod
|
||||
|
||||
// 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.
|
||||
|
||||
@Override
|
||||
@ -478,7 +445,7 @@ public final class HlsMediaPeriod
|
||||
for (HlsSampleStreamWrapper streamWrapper : sampleStreamWrappers) {
|
||||
streamWrapper.onPlaylistUpdated();
|
||||
}
|
||||
callback.onContinueLoadingRequested(this);
|
||||
mediaPeriodCallback.onContinueLoadingRequested(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -488,7 +455,7 @@ public final class HlsMediaPeriod
|
||||
for (HlsSampleStreamWrapper streamWrapper : sampleStreamWrappers) {
|
||||
exclusionSucceeded &= streamWrapper.onPlaylistError(url, loadErrorInfo, forceRetry);
|
||||
}
|
||||
callback.onContinueLoadingRequested(this);
|
||||
mediaPeriodCallback.onContinueLoadingRequested(this);
|
||||
return exclusionSucceeded;
|
||||
}
|
||||
|
||||
@ -810,7 +777,7 @@ public final class HlsMediaPeriod
|
||||
return new HlsSampleStreamWrapper(
|
||||
uid,
|
||||
trackType,
|
||||
/* callback= */ this,
|
||||
/* callback= */ sampleStreamWrapperCallback,
|
||||
defaultChunkSource,
|
||||
overridingDrmInitData,
|
||||
allocator,
|
||||
@ -915,4 +882,38 @@ public final class HlsMediaPeriod
|
||||
.setLanguage(language)
|
||||
.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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -58,7 +58,7 @@ public final class RtpPayloadFormat {
|
||||
public static final String RTP_MEDIA_VP9 = "VP9";
|
||||
|
||||
/** 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)) {
|
||||
case RTP_MEDIA_AC3:
|
||||
case RTP_MEDIA_AMR:
|
||||
|
Loading…
x
Reference in New Issue
Block a user