From 22159673bd16d77815d99d7893c0708356b47a48 Mon Sep 17 00:00:00 2001 From: olly Date: Thu, 10 Mar 2022 13:52:51 +0000 Subject: [PATCH] Move TrackSelection back to ExoPlayer module PiperOrigin-RevId: 433729648 --- .../exoplayer2/ext/ima/FakeExoPlayer.java | 8 +++---- .../com/google/android/exoplayer2/Player.java | 22 +++++++++---------- .../AdaptiveTrackSelection.java | 3 ++- .../trackselection/TrackSelection.java | 0 .../trackselection/TrackSelectionArray.java | 0 5 files changed, 17 insertions(+), 16 deletions(-) rename library/{common => core}/src/main/java/com/google/android/exoplayer2/trackselection/TrackSelection.java (100%) rename library/{common => core}/src/main/java/com/google/android/exoplayer2/trackselection/TrackSelectionArray.java (100%) diff --git a/extensions/ima/src/test/java/com/google/android/exoplayer2/ext/ima/FakeExoPlayer.java b/extensions/ima/src/test/java/com/google/android/exoplayer2/ext/ima/FakeExoPlayer.java index f3034b56f8..5c3ae8c0ff 100644 --- a/extensions/ima/src/test/java/com/google/android/exoplayer2/ext/ima/FakeExoPlayer.java +++ b/extensions/ima/src/test/java/com/google/android/exoplayer2/ext/ima/FakeExoPlayer.java @@ -79,7 +79,7 @@ import com.google.android.exoplayer2.util.Util; PositionInfo oldPosition = new PositionInfo( windowUid, - /* windowIndex= */ 0, + /* mediaItemIndex= */ 0, mediaItem, periodUid, /* periodIndex= */ 0, @@ -97,7 +97,7 @@ import com.google.android.exoplayer2.util.Util; PositionInfo newPosition = new PositionInfo( windowUid, - /* windowIndex= */ 0, + /* mediaItemIndex= */ 0, mediaItem, periodUid, /* periodIndex= */ 0, @@ -128,7 +128,7 @@ import com.google.android.exoplayer2.util.Util; PositionInfo oldPosition = new PositionInfo( windowUid, - /* windowIndex= */ 0, + /* mediaItemIndex= */ 0, mediaItem, periodUid, /* periodIndex= */ 0, @@ -146,7 +146,7 @@ import com.google.android.exoplayer2.util.Util; PositionInfo newPosition = new PositionInfo( windowUid, - /* windowIndex= */ 0, + /* mediaItemIndex= */ 0, mediaItem, periodUid, /* periodIndex= */ 0, diff --git a/library/common/src/main/java/com/google/android/exoplayer2/Player.java b/library/common/src/main/java/com/google/android/exoplayer2/Player.java index 8bb98894e1..e15c29a922 100644 --- a/library/common/src/main/java/com/google/android/exoplayer2/Player.java +++ b/library/common/src/main/java/com/google/android/exoplayer2/Player.java @@ -34,7 +34,6 @@ import androidx.annotation.Nullable; import com.google.android.exoplayer2.audio.AudioAttributes; import com.google.android.exoplayer2.metadata.Metadata; import com.google.android.exoplayer2.text.Cue; -import com.google.android.exoplayer2.trackselection.TrackSelection; import com.google.android.exoplayer2.trackselection.TrackSelectionParameters; import com.google.android.exoplayer2.util.BundleableUtil; import com.google.android.exoplayer2.util.FlagSet; @@ -681,11 +680,12 @@ public interface Player { /** * Called when the combined {@link MediaMetadata} changes. * - *

The provided {@link MediaMetadata} is a combination of the {@link MediaItem#mediaMetadata} - * and the static and dynamic metadata from the {@link TrackSelection#getFormat(int) track - * selections' formats} and {@link Listener#onMetadata(Metadata)}. If a field is populated in - * the {@link MediaItem#mediaMetadata}, it will be prioritised above the same field coming from - * static or dynamic metadata. + *

The provided {@link MediaMetadata} is a combination of the {@link MediaItem#mediaMetadata + * MediaItem metadata}, the static metadata in the media's {@link Format#metadata Format}, and + * any timed metadata that has been parsed from the media and output via {@link + * Listener#onMetadata(Metadata)}. If a field is populated in the {@link + * MediaItem#mediaMetadata}, it will be prioritised above the same field coming from static or + * timed metadata. * *

This method may be called multiple times in quick succession. * @@ -2105,11 +2105,11 @@ public interface Player { * Returns the current combined {@link MediaMetadata}, or {@link MediaMetadata#EMPTY} if not * supported. * - *

This {@link MediaMetadata} is a combination of the {@link MediaItem#mediaMetadata} and the - * static and dynamic metadata from the {@link TrackSelection#getFormat(int) track selections' - * formats} and {@link Listener#onMetadata(Metadata)}. If a field is populated in the {@link - * MediaItem#mediaMetadata}, it will be prioritised above the same field coming from static or - * dynamic metadata. + *

This {@link MediaMetadata} is a combination of the {@link MediaItem#mediaMetadata MediaItem + * metadata}, the static metadata in the media's {@link Format#metadata Format}, and any timed + * metadata that has been parsed from the media and output via {@link + * Listener#onMetadata(Metadata)}. If a field is populated in the {@link MediaItem#mediaMetadata}, + * it will be prioritised above the same field coming from static or timed metadata. */ MediaMetadata getMediaMetadata(); diff --git a/library/core/src/main/java/com/google/android/exoplayer2/trackselection/AdaptiveTrackSelection.java b/library/core/src/main/java/com/google/android/exoplayer2/trackselection/AdaptiveTrackSelection.java index 35a56682bf..fcf11eca28 100644 --- a/library/core/src/main/java/com/google/android/exoplayer2/trackselection/AdaptiveTrackSelection.java +++ b/library/core/src/main/java/com/google/android/exoplayer2/trackselection/AdaptiveTrackSelection.java @@ -778,7 +778,8 @@ public class AdaptiveTrackSelection extends BaseTrackSelection { } double[] logBitrates = new double[trackBitrates[i].length]; for (int j = 0; j < trackBitrates[i].length; j++) { - logBitrates[j] = trackBitrates[i][j] == Format.NO_VALUE ? 0 : Math.log(trackBitrates[i][j]); + logBitrates[j] = + trackBitrates[i][j] == Format.NO_VALUE ? 0 : Math.log((double) trackBitrates[i][j]); } double totalBitrateDiff = logBitrates[logBitrates.length - 1] - logBitrates[0]; for (int j = 0; j < logBitrates.length - 1; j++) { diff --git a/library/common/src/main/java/com/google/android/exoplayer2/trackselection/TrackSelection.java b/library/core/src/main/java/com/google/android/exoplayer2/trackselection/TrackSelection.java similarity index 100% rename from library/common/src/main/java/com/google/android/exoplayer2/trackselection/TrackSelection.java rename to library/core/src/main/java/com/google/android/exoplayer2/trackselection/TrackSelection.java diff --git a/library/common/src/main/java/com/google/android/exoplayer2/trackselection/TrackSelectionArray.java b/library/core/src/main/java/com/google/android/exoplayer2/trackselection/TrackSelectionArray.java similarity index 100% rename from library/common/src/main/java/com/google/android/exoplayer2/trackselection/TrackSelectionArray.java rename to library/core/src/main/java/com/google/android/exoplayer2/trackselection/TrackSelectionArray.java