From 7905744a832a71aa9f30e8744742a6abd8468488 Mon Sep 17 00:00:00 2001 From: ibaker Date: Thu, 10 Nov 2022 09:58:57 +0000 Subject: [PATCH] Fix Dackka/Metalava errors in the ExoPlayer module This makes two types of fix: 1. Align parameter names on overridden methods where the superclass has `@param` javadoc. 2. Use `@hide` on `protected final` methods that refer to package-private types. This will hide these symbols from Dackka javadoc generation but not (currently) from the artefacts distributed on Maven. These methods are currently unusable outside their package anyway (e.g. by external developers) because of the dependency on a package-private type. This also changes some HLS, SmoothStreaming, and IMA code where I've renamed parameters of overridden methods to be consistent across the type hierarchy. #minor-release PiperOrigin-RevId: 487472665 --- .../exoplayer/source/ClippingMediaSource.java | 4 ++-- .../exoplayer/source/CompositeMediaSource.java | 18 +++++++++--------- .../source/ConcatenatingMediaSource.java | 15 +++++++++++++++ .../exoplayer/source/LoopingMediaSource.java | 6 +++--- .../exoplayer/source/MergingMediaSource.java | 12 ++++++------ .../exoplayer/source/WrappingMediaSource.java | 16 ++++++++-------- .../exoplayer/source/ads/AdsMediaSource.java | 18 +++++++++--------- .../exoplayer/hls/offline/HlsDownloader.java | 8 ++++---- .../ImaServerSideAdInsertionMediaSource.java | 2 +- .../smoothstreaming/offline/SsDownloader.java | 2 +- 10 files changed, 58 insertions(+), 43 deletions(-) diff --git a/libraries/exoplayer/src/main/java/androidx/media3/exoplayer/source/ClippingMediaSource.java b/libraries/exoplayer/src/main/java/androidx/media3/exoplayer/source/ClippingMediaSource.java index 20b0fb649f..f11d117f72 100644 --- a/libraries/exoplayer/src/main/java/androidx/media3/exoplayer/source/ClippingMediaSource.java +++ b/libraries/exoplayer/src/main/java/androidx/media3/exoplayer/source/ClippingMediaSource.java @@ -228,11 +228,11 @@ public final class ClippingMediaSource extends WrappingMediaSource { } @Override - protected void onChildSourceInfoRefreshed(Timeline timeline) { + protected void onChildSourceInfoRefreshed(Timeline newTimeline) { if (clippingError != null) { return; } - refreshClippedTimeline(timeline); + refreshClippedTimeline(newTimeline); } private void refreshClippedTimeline(Timeline timeline) { diff --git a/libraries/exoplayer/src/main/java/androidx/media3/exoplayer/source/CompositeMediaSource.java b/libraries/exoplayer/src/main/java/androidx/media3/exoplayer/source/CompositeMediaSource.java index 0cfc5f3654..7ce915d86a 100644 --- a/libraries/exoplayer/src/main/java/androidx/media3/exoplayer/source/CompositeMediaSource.java +++ b/libraries/exoplayer/src/main/java/androidx/media3/exoplayer/source/CompositeMediaSource.java @@ -92,12 +92,12 @@ public abstract class CompositeMediaSource extends BaseMediaSource { /** * Called when the source info of a child source has been refreshed. * - * @param id The unique id used to prepare the child source. + * @param childSourceId The unique id used to prepare the child source. * @param mediaSource The child source whose source info has been refreshed. - * @param timeline The timeline of the child source. + * @param newTimeline The timeline of the child source. */ protected abstract void onChildSourceInfoRefreshed( - @UnknownNull T id, MediaSource mediaSource, Timeline timeline); + @UnknownNull T childSourceId, MediaSource mediaSource, Timeline newTimeline); /** * Prepares a child source. @@ -161,11 +161,11 @@ public abstract class CompositeMediaSource extends BaseMediaSource { * Returns the window index in the composite source corresponding to the specified window index in * a child source. The default implementation does not change the window index. * - * @param id The unique id used to prepare the child source. + * @param childSourceId The unique id used to prepare the child source. * @param windowIndex A window index of the child source. * @return The corresponding window index in the composite source. */ - protected int getWindowIndexForChildWindowIndex(@UnknownNull T id, int windowIndex) { + protected int getWindowIndexForChildWindowIndex(@UnknownNull T childSourceId, int windowIndex) { return windowIndex; } @@ -174,14 +174,14 @@ public abstract class CompositeMediaSource extends BaseMediaSource { * MediaPeriodId} in a child source. The default implementation does not change the media period * id. * - * @param id The unique id used to prepare the child source. + * @param childSourceId The unique id used to prepare the child source. * @param mediaPeriodId A {@link MediaPeriodId} of the child source. * @return The corresponding {@link MediaPeriodId} in the composite source. Null if no * corresponding media period id can be determined. */ @Nullable protected MediaPeriodId getMediaPeriodIdForChildMediaPeriodId( - @UnknownNull T id, MediaPeriodId mediaPeriodId) { + @UnknownNull T childSourceId, MediaPeriodId mediaPeriodId) { return mediaPeriodId; } @@ -190,13 +190,13 @@ public abstract class CompositeMediaSource extends BaseMediaSource { * specified media time in the {@link MediaPeriod} of the child source. The default implementation * does not change the media time. * - * @param id The unique id used to prepare the child source. + * @param childSourceId The unique id used to prepare the child source. * @param mediaTimeMs A media time in the {@link MediaPeriod} of the child source, in * milliseconds. * @return The corresponding media time in the {@link MediaPeriod} of the composite source, in * milliseconds. */ - protected long getMediaTimeForChildMediaTime(@UnknownNull T id, long mediaTimeMs) { + protected long getMediaTimeForChildMediaTime(@UnknownNull T childSourceId, long mediaTimeMs) { return mediaTimeMs; } diff --git a/libraries/exoplayer/src/main/java/androidx/media3/exoplayer/source/ConcatenatingMediaSource.java b/libraries/exoplayer/src/main/java/androidx/media3/exoplayer/source/ConcatenatingMediaSource.java index 4e6749ee51..b2f005c47d 100644 --- a/libraries/exoplayer/src/main/java/androidx/media3/exoplayer/source/ConcatenatingMediaSource.java +++ b/libraries/exoplayer/src/main/java/androidx/media3/exoplayer/source/ConcatenatingMediaSource.java @@ -528,12 +528,22 @@ public final class ConcatenatingMediaSource extends CompositeMediaSource { @Override protected void onChildSourceInfoRefreshed( - Integer id, MediaSource mediaSource, Timeline timeline) { + Integer childSourceId, MediaSource mediaSource, Timeline newTimeline) { if (mergeError != null) { return; } if (periodCount == PERIOD_COUNT_UNSET) { - periodCount = timeline.getPeriodCount(); - } else if (timeline.getPeriodCount() != periodCount) { + periodCount = newTimeline.getPeriodCount(); + } else if (newTimeline.getPeriodCount() != periodCount) { mergeError = new IllegalMergeException(IllegalMergeException.REASON_PERIOD_COUNT_MISMATCH); return; } @@ -252,7 +252,7 @@ public final class MergingMediaSource extends CompositeMediaSource { periodTimeOffsetsUs = new long[periodCount][timelines.length]; } pendingTimelineSources.remove(mediaSource); - timelines[id] = timeline; + timelines[childSourceId] = newTimeline; if (pendingTimelineSources.isEmpty()) { if (adjustPeriodTimeOffsets) { computePeriodTimeOffsets(); @@ -269,8 +269,8 @@ public final class MergingMediaSource extends CompositeMediaSource { @Override @Nullable protected MediaPeriodId getMediaPeriodIdForChildMediaPeriodId( - Integer id, MediaPeriodId mediaPeriodId) { - return id == 0 ? mediaPeriodId : null; + Integer childSourceId, MediaPeriodId mediaPeriodId) { + return childSourceId == 0 ? mediaPeriodId : null; } private void computePeriodTimeOffsets() { diff --git a/libraries/exoplayer/src/main/java/androidx/media3/exoplayer/source/WrappingMediaSource.java b/libraries/exoplayer/src/main/java/androidx/media3/exoplayer/source/WrappingMediaSource.java index 99a367d944..215d90433e 100644 --- a/libraries/exoplayer/src/main/java/androidx/media3/exoplayer/source/WrappingMediaSource.java +++ b/libraries/exoplayer/src/main/java/androidx/media3/exoplayer/source/WrappingMediaSource.java @@ -128,8 +128,8 @@ public abstract class WrappingMediaSource extends CompositeMediaSource { @Override protected final void onChildSourceInfoRefreshed( - Void id, MediaSource mediaSource, Timeline timeline) { - onChildSourceInfoRefreshed(timeline); + Void childSourceId, MediaSource mediaSource, Timeline newTimeline) { + onChildSourceInfoRefreshed(newTimeline); } /** @@ -139,14 +139,14 @@ public abstract class WrappingMediaSource extends CompositeMediaSource { * ForwardingTimeline}. The {@link Timeline} for the wrapping source needs to be published with * {@link #refreshSourceInfo(Timeline)}. * - * @param timeline The timeline of the child source. + * @param newTimeline The timeline of the child source. */ - protected void onChildSourceInfoRefreshed(Timeline timeline) { - refreshSourceInfo(timeline); + protected void onChildSourceInfoRefreshed(Timeline newTimeline) { + refreshSourceInfo(newTimeline); } @Override - protected final int getWindowIndexForChildWindowIndex(Void id, int windowIndex) { + protected final int getWindowIndexForChildWindowIndex(Void childSourceId, int windowIndex) { return getWindowIndexForChildWindowIndex(windowIndex); } @@ -164,7 +164,7 @@ public abstract class WrappingMediaSource extends CompositeMediaSource { @Nullable @Override protected final MediaPeriodId getMediaPeriodIdForChildMediaPeriodId( - Void id, MediaPeriodId mediaPeriodId) { + Void childSourceId, MediaPeriodId mediaPeriodId) { return getMediaPeriodIdForChildMediaPeriodId(mediaPeriodId); } @@ -183,7 +183,7 @@ public abstract class WrappingMediaSource extends CompositeMediaSource { } @Override - protected final long getMediaTimeForChildMediaTime(Void id, long mediaTimeMs) { + protected final long getMediaTimeForChildMediaTime(Void childSourceId, long mediaTimeMs) { return getMediaTimeForChildMediaTime(mediaTimeMs); } diff --git a/libraries/exoplayer/src/main/java/androidx/media3/exoplayer/source/ads/AdsMediaSource.java b/libraries/exoplayer/src/main/java/androidx/media3/exoplayer/source/ads/AdsMediaSource.java index 74b3093156..1098bd23ec 100644 --- a/libraries/exoplayer/src/main/java/androidx/media3/exoplayer/source/ads/AdsMediaSource.java +++ b/libraries/exoplayer/src/main/java/androidx/media3/exoplayer/source/ads/AdsMediaSource.java @@ -259,25 +259,25 @@ public final class AdsMediaSource extends CompositeMediaSource { @Override protected void onChildSourceInfoRefreshed( - MediaPeriodId mediaPeriodId, MediaSource mediaSource, Timeline timeline) { - if (mediaPeriodId.isAd()) { - int adGroupIndex = mediaPeriodId.adGroupIndex; - int adIndexInAdGroup = mediaPeriodId.adIndexInAdGroup; + MediaPeriodId childSourceId, MediaSource mediaSource, Timeline newTimeline) { + if (childSourceId.isAd()) { + int adGroupIndex = childSourceId.adGroupIndex; + int adIndexInAdGroup = childSourceId.adIndexInAdGroup; checkNotNull(adMediaSourceHolders[adGroupIndex][adIndexInAdGroup]) - .handleSourceInfoRefresh(timeline); + .handleSourceInfoRefresh(newTimeline); } else { - Assertions.checkArgument(timeline.getPeriodCount() == 1); - contentTimeline = timeline; + Assertions.checkArgument(newTimeline.getPeriodCount() == 1); + contentTimeline = newTimeline; } maybeUpdateSourceInfo(); } @Override protected MediaPeriodId getMediaPeriodIdForChildMediaPeriodId( - MediaPeriodId childId, MediaPeriodId mediaPeriodId) { + MediaPeriodId childSourceId, MediaPeriodId mediaPeriodId) { // The child id for the content period is just CHILD_SOURCE_MEDIA_PERIOD_ID. That's why // we need to forward the reported mediaPeriodId in this case. - return childId.isAd() ? childId : mediaPeriodId; + return childSourceId.isAd() ? childSourceId : mediaPeriodId; } // Internal methods. diff --git a/libraries/exoplayer_hls/src/main/java/androidx/media3/exoplayer/hls/offline/HlsDownloader.java b/libraries/exoplayer_hls/src/main/java/androidx/media3/exoplayer/hls/offline/HlsDownloader.java index 8f8b08bcbc..777694e9f6 100644 --- a/libraries/exoplayer_hls/src/main/java/androidx/media3/exoplayer/hls/offline/HlsDownloader.java +++ b/libraries/exoplayer_hls/src/main/java/androidx/media3/exoplayer/hls/offline/HlsDownloader.java @@ -112,15 +112,15 @@ public final class HlsDownloader extends SegmentDownloader { } @Override - protected List getSegments(DataSource dataSource, HlsPlaylist playlist, boolean removing) + protected List getSegments(DataSource dataSource, HlsPlaylist manifest, boolean removing) throws IOException, InterruptedException { ArrayList mediaPlaylistDataSpecs = new ArrayList<>(); - if (playlist instanceof HlsMultivariantPlaylist) { - HlsMultivariantPlaylist multivariantPlaylist = (HlsMultivariantPlaylist) playlist; + if (manifest instanceof HlsMultivariantPlaylist) { + HlsMultivariantPlaylist multivariantPlaylist = (HlsMultivariantPlaylist) manifest; addMediaPlaylistDataSpecs(multivariantPlaylist.mediaPlaylistUrls, mediaPlaylistDataSpecs); } else { mediaPlaylistDataSpecs.add( - SegmentDownloader.getCompressibleDataSpec(Uri.parse(playlist.baseUri))); + SegmentDownloader.getCompressibleDataSpec(Uri.parse(manifest.baseUri))); } ArrayList segments = new ArrayList<>(); diff --git a/libraries/exoplayer_ima/src/main/java/androidx/media3/exoplayer/ima/ImaServerSideAdInsertionMediaSource.java b/libraries/exoplayer_ima/src/main/java/androidx/media3/exoplayer/ima/ImaServerSideAdInsertionMediaSource.java index 9929003b58..822c8cf872 100644 --- a/libraries/exoplayer_ima/src/main/java/androidx/media3/exoplayer/ima/ImaServerSideAdInsertionMediaSource.java +++ b/libraries/exoplayer_ima/src/main/java/androidx/media3/exoplayer/ima/ImaServerSideAdInsertionMediaSource.java @@ -533,7 +533,7 @@ public final class ImaServerSideAdInsertionMediaSource extends CompositeMediaSou @Override protected void onChildSourceInfoRefreshed( - Void id, MediaSource mediaSource, Timeline newTimeline) { + Void childSourceId, MediaSource mediaSource, Timeline newTimeline) { refreshSourceInfo( new ForwardingTimeline(newTimeline) { @Override diff --git a/libraries/exoplayer_smoothstreaming/src/main/java/androidx/media3/exoplayer/smoothstreaming/offline/SsDownloader.java b/libraries/exoplayer_smoothstreaming/src/main/java/androidx/media3/exoplayer/smoothstreaming/offline/SsDownloader.java index 443fea1d46..4ca632271b 100644 --- a/libraries/exoplayer_smoothstreaming/src/main/java/androidx/media3/exoplayer/smoothstreaming/offline/SsDownloader.java +++ b/libraries/exoplayer_smoothstreaming/src/main/java/androidx/media3/exoplayer/smoothstreaming/offline/SsDownloader.java @@ -117,7 +117,7 @@ public final class SsDownloader extends SegmentDownloader { @Override protected List getSegments( - DataSource dataSource, SsManifest manifest, boolean allowIncompleteList) { + DataSource dataSource, SsManifest manifest, boolean removing) { ArrayList segments = new ArrayList<>(); for (StreamElement streamElement : manifest.streamElements) { for (int i = 0; i < streamElement.formats.length; i++) {