diff --git a/extensions/cast/src/main/java/com/google/android/exoplayer2/ext/cast/CastUtils.java b/extensions/cast/src/main/java/com/google/android/exoplayer2/ext/cast/CastUtils.java index 3077077616..5b96bc5846 100644 --- a/extensions/cast/src/main/java/com/google/android/exoplayer2/ext/cast/CastUtils.java +++ b/extensions/cast/src/main/java/com/google/android/exoplayer2/ext/cast/CastUtils.java @@ -18,6 +18,7 @@ package com.google.android.exoplayer2.ext.cast; import androidx.annotation.Nullable; import com.google.android.exoplayer2.C; import com.google.android.exoplayer2.Format; +import com.google.android.exoplayer2.util.Util; import com.google.android.gms.cast.CastStatusCodes; import com.google.android.gms.cast.MediaInfo; import com.google.android.gms.cast.MediaTrack; @@ -42,7 +43,7 @@ import com.google.android.gms.cast.MediaTrack; } long durationMs = mediaInfo.getStreamDuration(); return durationMs != MediaInfo.UNKNOWN_DURATION && durationMs != LIVE_STREAM_DURATION - ? C.msToUs(durationMs) + ? Util.msToUs(durationMs) : C.TIME_UNSET; } diff --git a/extensions/cast/src/test/java/com/google/android/exoplayer2/ext/cast/CastTimelineTrackerTest.java b/extensions/cast/src/test/java/com/google/android/exoplayer2/ext/cast/CastTimelineTrackerTest.java index cae117ea00..5b6c6c8511 100644 --- a/extensions/cast/src/test/java/com/google/android/exoplayer2/ext/cast/CastTimelineTrackerTest.java +++ b/extensions/cast/src/test/java/com/google/android/exoplayer2/ext/cast/CastTimelineTrackerTest.java @@ -21,6 +21,7 @@ import androidx.test.ext.junit.runners.AndroidJUnit4; import com.google.android.exoplayer2.C; import com.google.android.exoplayer2.testutil.TimelineAsserts; import com.google.android.exoplayer2.util.MimeTypes; +import com.google.android.exoplayer2.util.Util; import com.google.android.gms.cast.MediaInfo; import com.google.android.gms.cast.MediaStatus; import com.google.android.gms.cast.framework.media.MediaQueue; @@ -52,7 +53,7 @@ public class CastTimelineTrackerTest { TimelineAsserts.assertPeriodDurations( tracker.getCastTimeline(remoteMediaClient), C.TIME_UNSET, - C.msToUs(DURATION_2_MS), + Util.msToUs(DURATION_2_MS), C.TIME_UNSET, C.TIME_UNSET, C.TIME_UNSET); @@ -65,8 +66,8 @@ public class CastTimelineTrackerTest { TimelineAsserts.assertPeriodDurations( tracker.getCastTimeline(remoteMediaClient), C.TIME_UNSET, - C.msToUs(DURATION_2_MS), - C.msToUs(DURATION_3_MS)); + Util.msToUs(DURATION_2_MS), + Util.msToUs(DURATION_3_MS)); remoteMediaClient = mockRemoteMediaClient( @@ -74,7 +75,7 @@ public class CastTimelineTrackerTest { /* currentItemId= */ 3, /* currentDurationMs= */ DURATION_3_MS); TimelineAsserts.assertPeriodDurations( - tracker.getCastTimeline(remoteMediaClient), C.TIME_UNSET, C.msToUs(DURATION_3_MS)); + tracker.getCastTimeline(remoteMediaClient), C.TIME_UNSET, Util.msToUs(DURATION_3_MS)); remoteMediaClient = mockRemoteMediaClient( @@ -85,8 +86,8 @@ public class CastTimelineTrackerTest { tracker.getCastTimeline(remoteMediaClient), C.TIME_UNSET, C.TIME_UNSET, - C.msToUs(DURATION_3_MS), - C.msToUs(DURATION_4_MS), + Util.msToUs(DURATION_3_MS), + Util.msToUs(DURATION_4_MS), C.TIME_UNSET); remoteMediaClient = @@ -98,9 +99,9 @@ public class CastTimelineTrackerTest { tracker.getCastTimeline(remoteMediaClient), C.TIME_UNSET, C.TIME_UNSET, - C.msToUs(DURATION_3_MS), - C.msToUs(DURATION_4_MS), - C.msToUs(DURATION_5_MS)); + Util.msToUs(DURATION_3_MS), + Util.msToUs(DURATION_4_MS), + Util.msToUs(DURATION_5_MS)); } private static RemoteMediaClient mockRemoteMediaClient( diff --git a/extensions/ima/src/main/java/com/google/android/exoplayer2/ext/ima/AdTagLoader.java b/extensions/ima/src/main/java/com/google/android/exoplayer2/ext/ima/AdTagLoader.java index f0c4a199e1..2d446527a1 100644 --- a/extensions/ima/src/main/java/com/google/android/exoplayer2/ext/ima/AdTagLoader.java +++ b/extensions/ima/src/main/java/com/google/android/exoplayer2/ext/ima/AdTagLoader.java @@ -348,7 +348,7 @@ import java.util.Map; long contentPositionMs = getContentPeriodPositionMs(player, timeline, period); int adGroupForPositionIndex = adPlaybackState.getAdGroupIndexForPositionUs( - C.msToUs(contentPositionMs), C.msToUs(contentDurationMs)); + Util.msToUs(contentPositionMs), Util.msToUs(contentDurationMs)); if (adGroupForPositionIndex != C.INDEX_UNSET && imaAdInfo != null && imaAdInfo.adGroupIndex != adGroupForPositionIndex) { @@ -372,7 +372,7 @@ import java.util.Map; } adPlaybackState = adPlaybackState.withAdResumePositionUs( - playingAd ? C.msToUs(player.getCurrentPosition()) : 0); + playingAd ? Util.msToUs(player.getCurrentPosition()) : 0); } lastVolumePercent = getPlayerVolumePercent(); lastAdProgress = getAdVideoProgressUpdate(); @@ -456,7 +456,7 @@ import java.util.Map; this.timeline = timeline; Player player = checkNotNull(this.player); long contentDurationUs = timeline.getPeriod(player.getCurrentPeriodIndex(), period).durationUs; - contentDurationMs = C.usToMs(contentDurationUs); + contentDurationMs = Util.usToMs(contentDurationUs); if (contentDurationUs != adPlaybackState.contentDurationUs) { adPlaybackState = adPlaybackState.withContentDurationUs(contentDurationUs); updateAdPlaybackState(); @@ -602,10 +602,11 @@ import java.util.Map; // Skip ads based on the start position as required. int adGroupForPositionIndex = adPlaybackState.getAdGroupIndexForPositionUs( - C.msToUs(contentPositionMs), C.msToUs(contentDurationMs)); + Util.msToUs(contentPositionMs), Util.msToUs(contentDurationMs)); if (adGroupForPositionIndex != C.INDEX_UNSET) { boolean playAdWhenStartingPlayback = - adPlaybackState.getAdGroup(adGroupForPositionIndex).timeUs == C.msToUs(contentPositionMs) + adPlaybackState.getAdGroup(adGroupForPositionIndex).timeUs + == Util.msToUs(contentPositionMs) || configuration.playAdBeforeStartPosition; if (!playAdWhenStartingPlayback) { adGroupForPositionIndex++; @@ -790,7 +791,7 @@ import java.util.Map; // An ad is available already. return false; } - long adGroupTimeMs = C.usToMs(adGroup.timeUs); + long adGroupTimeMs = Util.usToMs(adGroup.timeUs); long contentPositionMs = getContentPeriodPositionMs(player, timeline, period); long timeUntilAdMs = adGroupTimeMs - contentPositionMs; return timeUntilAdMs < configuration.adPreloadTimeoutMs; @@ -840,7 +841,7 @@ import java.util.Map; if (!sentContentComplete && !timeline.isEmpty()) { long positionMs = getContentPeriodPositionMs(player, timeline, period); timeline.getPeriod(player.getCurrentPeriodIndex(), period); - int newAdGroupIndex = period.getAdGroupIndexForPositionUs(C.msToUs(positionMs)); + int newAdGroupIndex = period.getAdGroupIndexForPositionUs(Util.msToUs(positionMs)); if (newAdGroupIndex != C.INDEX_UNSET) { sentPendingContentPositionMs = false; pendingContentPositionMs = positionMs; @@ -880,7 +881,7 @@ import java.util.Map; } else { // IMA hasn't called playAd yet, so fake the content position. fakeContentProgressElapsedRealtimeMs = SystemClock.elapsedRealtime(); - fakeContentProgressOffsetMs = C.usToMs(adGroup.timeUs); + fakeContentProgressOffsetMs = Util.usToMs(adGroup.timeUs); if (fakeContentProgressOffsetMs == C.TIME_END_OF_SOURCE) { fakeContentProgressOffsetMs = contentDurationMs; } @@ -1091,7 +1092,7 @@ import java.util.Map; // Send IMA a content position at the ad group so that it will try to play it, at which point // we can notify that it failed to load. fakeContentProgressElapsedRealtimeMs = SystemClock.elapsedRealtime(); - fakeContentProgressOffsetMs = C.usToMs(adPlaybackState.getAdGroup(adGroupIndex).timeUs); + fakeContentProgressOffsetMs = Util.usToMs(adPlaybackState.getAdGroup(adGroupIndex).timeUs); if (fakeContentProgressOffsetMs == C.TIME_END_OF_SOURCE) { fakeContentProgressOffsetMs = contentDurationMs; } @@ -1192,13 +1193,14 @@ import java.util.Map; if (player == null) { return C.INDEX_UNSET; } - long playerPositionUs = C.msToUs(getContentPeriodPositionMs(player, timeline, period)); + long playerPositionUs = Util.msToUs(getContentPeriodPositionMs(player, timeline, period)); int adGroupIndex = - adPlaybackState.getAdGroupIndexForPositionUs(playerPositionUs, C.msToUs(contentDurationMs)); + adPlaybackState.getAdGroupIndexForPositionUs( + playerPositionUs, Util.msToUs(contentDurationMs)); if (adGroupIndex == C.INDEX_UNSET) { adGroupIndex = adPlaybackState.getAdGroupIndexAfterPositionUs( - playerPositionUs, C.msToUs(contentDurationMs)); + playerPositionUs, Util.msToUs(contentDurationMs)); } return adGroupIndex; } diff --git a/extensions/ima/src/main/java/com/google/android/exoplayer2/ext/ima/ImaAdsLoader.java b/extensions/ima/src/main/java/com/google/android/exoplayer2/ext/ima/ImaAdsLoader.java index 7f52005b68..85a39c77e8 100644 --- a/extensions/ima/src/main/java/com/google/android/exoplayer2/ext/ima/ImaAdsLoader.java +++ b/extensions/ima/src/main/java/com/google/android/exoplayer2/ext/ima/ImaAdsLoader.java @@ -703,7 +703,7 @@ public final class ImaAdsLoader implements Player.Listener, AdsLoader { timeline.getPeriodPosition( window, period, period.windowIndex, /* windowPositionUs= */ C.TIME_UNSET) .second; - nextAdTagLoader.maybePreloadAds(C.usToMs(periodPositionUs), C.usToMs(period.durationUs)); + nextAdTagLoader.maybePreloadAds(Util.usToMs(periodPositionUs), Util.usToMs(period.durationUs)); } /** diff --git a/extensions/ima/src/test/java/com/google/android/exoplayer2/ext/ima/FakePlayer.java b/extensions/ima/src/test/java/com/google/android/exoplayer2/ext/ima/FakePlayer.java index d0a9d4206b..e8f80feed0 100644 --- a/extensions/ima/src/test/java/com/google/android/exoplayer2/ext/ima/FakePlayer.java +++ b/extensions/ima/src/test/java/com/google/android/exoplayer2/ext/ima/FakePlayer.java @@ -27,6 +27,7 @@ import com.google.android.exoplayer2.trackselection.TrackSelectionArray; import com.google.android.exoplayer2.trackselection.TrackSelectionParameters; import com.google.android.exoplayer2.util.Clock; import com.google.android.exoplayer2.util.ListenerSet; +import com.google.android.exoplayer2.util.Util; /** A fake player for testing content/ad playback. */ /* package */ final class FakePlayer extends StubExoPlayer { @@ -277,7 +278,7 @@ import com.google.android.exoplayer2.util.ListenerSet; if (isPlayingAd()) { long adDurationUs = timeline.getPeriod(0, period).getAdDurationUs(adGroupIndex, adIndexInAdGroup); - return C.usToMs(adDurationUs); + return Util.usToMs(adDurationUs); } else { return timeline.getWindow(getCurrentWindowIndex(), window).getDurationMs(); } diff --git a/extensions/ima/src/test/java/com/google/android/exoplayer2/ext/ima/ImaAdsLoaderTest.java b/extensions/ima/src/test/java/com/google/android/exoplayer2/ext/ima/ImaAdsLoaderTest.java index 06711d6055..cb0deb494b 100644 --- a/extensions/ima/src/test/java/com/google/android/exoplayer2/ext/ima/ImaAdsLoaderTest.java +++ b/extensions/ima/src/test/java/com/google/android/exoplayer2/ext/ima/ImaAdsLoaderTest.java @@ -384,13 +384,13 @@ public final class ImaAdsLoaderTest { playerPositionUs + TimelineWindowDefinition.DEFAULT_WINDOW_OFFSET_IN_FIRST_PERIOD_US; long periodDurationUs = CONTENT_TIMELINE.getPeriod(/* periodIndex= */ 0, new Period()).durationUs; - fakePlayer.setPlayingContentPosition(/* periodIndex= */ 0, C.usToMs(playerPositionUs)); + fakePlayer.setPlayingContentPosition(/* periodIndex= */ 0, Util.usToMs(playerPositionUs)); // Verify the content progress is updated to reflect the new player position. assertThat(contentProgressProvider.getContentProgress()) .isEqualTo( new VideoProgressUpdate( - C.usToMs(playerPositionInPeriodUs), C.usToMs(periodDurationUs))); + Util.usToMs(playerPositionInPeriodUs), Util.usToMs(periodDurationUs))); } @Test @@ -428,7 +428,8 @@ public final class ImaAdsLoaderTest { // Advance playback to just before the midroll and simulate buffering. imaAdsLoader.start( adsMediaSource, TEST_DATA_SPEC, TEST_ADS_ID, adViewProvider, adsLoaderListener); - fakePlayer.setPlayingContentPosition(/* periodIndex= */ 0, C.usToMs(adGroupPositionInWindowUs)); + fakePlayer.setPlayingContentPosition( + /* periodIndex= */ 0, Util.usToMs(adGroupPositionInWindowUs)); fakePlayer.setState(Player.STATE_BUFFERING, /* playWhenReady= */ true); // Advance before the timeout and simulating polling content progress. ShadowSystemClock.advanceBy(Duration.ofSeconds(1)); @@ -453,7 +454,8 @@ public final class ImaAdsLoaderTest { // Advance playback to just before the midroll and simulate buffering. imaAdsLoader.start( adsMediaSource, TEST_DATA_SPEC, TEST_ADS_ID, adViewProvider, adsLoaderListener); - fakePlayer.setPlayingContentPosition(/* periodIndex= */ 0, C.usToMs(adGroupPositionInWindowUs)); + fakePlayer.setPlayingContentPosition( + /* periodIndex= */ 0, Util.usToMs(adGroupPositionInWindowUs)); fakePlayer.setState(Player.STATE_BUFFERING, /* playWhenReady= */ true); // Advance past the timeout and simulate polling content progress. ShadowSystemClock.advanceBy(Duration.ofSeconds(5)); @@ -478,7 +480,8 @@ public final class ImaAdsLoaderTest { ImmutableList cuePoints = ImmutableList.of((float) adGroupTimeUs / C.MICROS_PER_SECOND); when(mockAdsManager.getAdCuePoints()).thenReturn(cuePoints); fakePlayer.setState(Player.STATE_BUFFERING, /* playWhenReady= */ true); - fakePlayer.setPlayingContentPosition(/* periodIndex= */ 0, C.usToMs(adGroupPositionInWindowUs)); + fakePlayer.setPlayingContentPosition( + /* periodIndex= */ 0, Util.usToMs(adGroupPositionInWindowUs)); // Start ad loading while still buffering and simulate the calls from the IMA SDK to resume then // immediately pause content playback. @@ -506,7 +509,8 @@ public final class ImaAdsLoaderTest { ImmutableList cuePoints = ImmutableList.of((float) adGroupTimeUs / C.MICROS_PER_SECOND); when(mockAdsManager.getAdCuePoints()).thenReturn(cuePoints); fakePlayer.setState(Player.STATE_BUFFERING, /* playWhenReady= */ true); - fakePlayer.setPlayingContentPosition(/* periodIndex= */ 0, C.usToMs(adGroupPositionInWindowUs)); + fakePlayer.setPlayingContentPosition( + /* periodIndex= */ 0, Util.usToMs(adGroupPositionInWindowUs)); // Start ad loading while still buffering and poll progress without the ad loading. imaAdsLoader.start( @@ -597,7 +601,7 @@ public final class ImaAdsLoaderTest { verify(mockVideoAdPlayerCallback) .onAdProgress( TEST_AD_MEDIA_INFO, - new VideoProgressUpdate(newPlayerPositionMs, C.usToMs(TEST_AD_DURATION_US))); + new VideoProgressUpdate(newPlayerPositionMs, Util.usToMs(TEST_AD_DURATION_US))); } @Test @@ -610,7 +614,7 @@ public final class ImaAdsLoaderTest { when(mockAdsManager.getAdCuePoints()).thenReturn(cuePoints); fakePlayer.setPlayingContentPosition( - /* periodIndex= */ 0, C.usToMs(midrollWindowTimeUs) - 1_000); + /* periodIndex= */ 0, Util.usToMs(midrollWindowTimeUs) - 1_000); imaAdsLoader.start( adsMediaSource, TEST_DATA_SPEC, TEST_ADS_ID, adViewProvider, adsLoaderListener); @@ -630,7 +634,7 @@ public final class ImaAdsLoaderTest { ImmutableList.of(0f, (float) midrollPeriodTimeUs / C.MICROS_PER_SECOND); when(mockAdsManager.getAdCuePoints()).thenReturn(cuePoints); - fakePlayer.setPlayingContentPosition(/* periodIndex= */ 0, C.usToMs(midrollWindowTimeUs)); + fakePlayer.setPlayingContentPosition(/* periodIndex= */ 0, Util.usToMs(midrollWindowTimeUs)); imaAdsLoader.start( adsMediaSource, TEST_DATA_SPEC, TEST_ADS_ID, adViewProvider, adsLoaderListener); @@ -657,7 +661,7 @@ public final class ImaAdsLoaderTest { when(mockAdsManager.getAdCuePoints()).thenReturn(cuePoints); fakePlayer.setPlayingContentPosition( - /* periodIndex= */ 0, C.usToMs(midrollWindowTimeUs) + 1_000); + /* periodIndex= */ 0, Util.usToMs(midrollWindowTimeUs) + 1_000); imaAdsLoader.start( adsMediaSource, TEST_DATA_SPEC, TEST_ADS_ID, adViewProvider, adsLoaderListener); @@ -691,7 +695,7 @@ public final class ImaAdsLoaderTest { when(mockAdsManager.getAdCuePoints()).thenReturn(cuePoints); fakePlayer.setPlayingContentPosition( - /* periodIndex= */ 0, C.usToMs(secondMidrollWindowTimeUs) - 1_000); + /* periodIndex= */ 0, Util.usToMs(secondMidrollWindowTimeUs) - 1_000); imaAdsLoader.start( adsMediaSource, TEST_DATA_SPEC, TEST_ADS_ID, adViewProvider, adsLoaderListener); @@ -718,7 +722,8 @@ public final class ImaAdsLoaderTest { (float) secondMidrollPeriodTimeUs / C.MICROS_PER_SECOND); when(mockAdsManager.getAdCuePoints()).thenReturn(cuePoints); - fakePlayer.setPlayingContentPosition(/* periodIndex= */ 0, C.usToMs(secondMidrollWindowTimeUs)); + fakePlayer.setPlayingContentPosition( + /* periodIndex= */ 0, Util.usToMs(secondMidrollWindowTimeUs)); imaAdsLoader.start( adsMediaSource, TEST_DATA_SPEC, TEST_ADS_ID, adViewProvider, adsLoaderListener); @@ -760,7 +765,7 @@ public final class ImaAdsLoaderTest { when(mockAdsManager.getAdCuePoints()).thenReturn(cuePoints); fakePlayer.setPlayingContentPosition( - /* periodIndex= */ 0, C.usToMs(midrollWindowTimeUs) - 1_000); + /* periodIndex= */ 0, Util.usToMs(midrollWindowTimeUs) - 1_000); imaAdsLoader.start( adsMediaSource, TEST_DATA_SPEC, TEST_ADS_ID, adViewProvider, adsLoaderListener); @@ -801,7 +806,7 @@ public final class ImaAdsLoaderTest { ImmutableList.of(0f, (float) midrollPeriodTimeUs / C.MICROS_PER_SECOND); when(mockAdsManager.getAdCuePoints()).thenReturn(cuePoints); - fakePlayer.setPlayingContentPosition(/* periodIndex= */ 0, C.usToMs(midrollWindowTimeUs)); + fakePlayer.setPlayingContentPosition(/* periodIndex= */ 0, Util.usToMs(midrollWindowTimeUs)); imaAdsLoader.start( adsMediaSource, TEST_DATA_SPEC, TEST_ADS_ID, adViewProvider, adsLoaderListener); @@ -843,7 +848,7 @@ public final class ImaAdsLoaderTest { when(mockAdsManager.getAdCuePoints()).thenReturn(cuePoints); fakePlayer.setPlayingContentPosition( - /* periodIndex= */ 0, C.usToMs(midrollWindowTimeUs) + 1_000); + /* periodIndex= */ 0, Util.usToMs(midrollWindowTimeUs) + 1_000); imaAdsLoader.start( adsMediaSource, TEST_DATA_SPEC, TEST_ADS_ID, adViewProvider, adsLoaderListener); @@ -889,7 +894,7 @@ public final class ImaAdsLoaderTest { when(mockAdsManager.getAdCuePoints()).thenReturn(cuePoints); fakePlayer.setPlayingContentPosition( - /* periodIndex= */ 0, C.usToMs(secondMidrollWindowTimeUs) - 1_000); + /* periodIndex= */ 0, Util.usToMs(secondMidrollWindowTimeUs) - 1_000); imaAdsLoader.start( adsMediaSource, TEST_DATA_SPEC, TEST_ADS_ID, adViewProvider, adsLoaderListener); @@ -937,7 +942,8 @@ public final class ImaAdsLoaderTest { (float) secondMidrollPeriodTimeUs / C.MICROS_PER_SECOND); when(mockAdsManager.getAdCuePoints()).thenReturn(cuePoints); - fakePlayer.setPlayingContentPosition(/* periodIndex= */ 0, C.usToMs(secondMidrollWindowTimeUs)); + fakePlayer.setPlayingContentPosition( + /* periodIndex= */ 0, Util.usToMs(secondMidrollWindowTimeUs)); imaAdsLoader.start( adsMediaSource, TEST_DATA_SPEC, TEST_ADS_ID, adViewProvider, adsLoaderListener); diff --git a/library/common/src/main/java/com/google/android/exoplayer2/Timeline.java b/library/common/src/main/java/com/google/android/exoplayer2/Timeline.java index 945f2c5107..8b6e734e68 100644 --- a/library/common/src/main/java/com/google/android/exoplayer2/Timeline.java +++ b/library/common/src/main/java/com/google/android/exoplayer2/Timeline.java @@ -300,7 +300,7 @@ public abstract class Timeline implements Bundleable { * whilst remaining within the bounds of the window. */ public long getDefaultPositionMs() { - return C.usToMs(defaultPositionUs); + return Util.usToMs(defaultPositionUs); } /** @@ -315,7 +315,7 @@ public abstract class Timeline implements Bundleable { /** Returns the duration of the window in milliseconds, or {@link C#TIME_UNSET} if unknown. */ public long getDurationMs() { - return C.usToMs(durationUs); + return Util.usToMs(durationUs); } /** Returns the duration of this window in microseconds, or {@link C#TIME_UNSET} if unknown. */ @@ -328,7 +328,7 @@ public abstract class Timeline implements Bundleable { * belonging to it, in milliseconds. */ public long getPositionInFirstPeriodMs() { - return C.usToMs(positionInFirstPeriodUs); + return Util.usToMs(positionInFirstPeriodUs); } /** @@ -671,7 +671,7 @@ public abstract class Timeline implements Bundleable { /** Returns the duration of the period in milliseconds, or {@link C#TIME_UNSET} if unknown. */ public long getDurationMs() { - return C.usToMs(durationUs); + return Util.usToMs(durationUs); } /** Returns the duration of this period in microseconds, or {@link C#TIME_UNSET} if unknown. */ @@ -685,7 +685,7 @@ public abstract class Timeline implements Bundleable { * window. */ public long getPositionInWindowMs() { - return C.usToMs(positionInWindowUs); + return Util.usToMs(positionInWindowUs); } /** diff --git a/library/core/src/main/java/com/google/android/exoplayer2/DefaultLivePlaybackSpeedControl.java b/library/core/src/main/java/com/google/android/exoplayer2/DefaultLivePlaybackSpeedControl.java index e4fa65c436..59753448db 100644 --- a/library/core/src/main/java/com/google/android/exoplayer2/DefaultLivePlaybackSpeedControl.java +++ b/library/core/src/main/java/com/google/android/exoplayer2/DefaultLivePlaybackSpeedControl.java @@ -106,9 +106,10 @@ public final class DefaultLivePlaybackSpeedControl implements LivePlaybackSpeedC fallbackMaxPlaybackSpeed = DEFAULT_FALLBACK_MAX_PLAYBACK_SPEED; minUpdateIntervalMs = DEFAULT_MIN_UPDATE_INTERVAL_MS; proportionalControlFactorUs = DEFAULT_PROPORTIONAL_CONTROL_FACTOR / C.MICROS_PER_SECOND; - maxLiveOffsetErrorUsForUnitSpeed = C.msToUs(DEFAULT_MAX_LIVE_OFFSET_ERROR_MS_FOR_UNIT_SPEED); + maxLiveOffsetErrorUsForUnitSpeed = + Util.msToUs(DEFAULT_MAX_LIVE_OFFSET_ERROR_MS_FOR_UNIT_SPEED); targetLiveOffsetIncrementOnRebufferUs = - C.msToUs(DEFAULT_TARGET_LIVE_OFFSET_INCREMENT_ON_REBUFFER_MS); + Util.msToUs(DEFAULT_TARGET_LIVE_OFFSET_INCREMENT_ON_REBUFFER_MS); minPossibleLiveOffsetSmoothingFactor = DEFAULT_MIN_POSSIBLE_LIVE_OFFSET_SMOOTHING_FACTOR; } @@ -187,7 +188,7 @@ public final class DefaultLivePlaybackSpeedControl implements LivePlaybackSpeedC */ public Builder setMaxLiveOffsetErrorMsForUnitSpeed(long maxLiveOffsetErrorMsForUnitSpeed) { Assertions.checkArgument(maxLiveOffsetErrorMsForUnitSpeed > 0); - this.maxLiveOffsetErrorUsForUnitSpeed = C.msToUs(maxLiveOffsetErrorMsForUnitSpeed); + this.maxLiveOffsetErrorUsForUnitSpeed = Util.msToUs(maxLiveOffsetErrorMsForUnitSpeed); return this; } @@ -202,7 +203,8 @@ public final class DefaultLivePlaybackSpeedControl implements LivePlaybackSpeedC public Builder setTargetLiveOffsetIncrementOnRebufferMs( long targetLiveOffsetIncrementOnRebufferMs) { Assertions.checkArgument(targetLiveOffsetIncrementOnRebufferMs >= 0); - this.targetLiveOffsetIncrementOnRebufferUs = C.msToUs(targetLiveOffsetIncrementOnRebufferMs); + this.targetLiveOffsetIncrementOnRebufferUs = + Util.msToUs(targetLiveOffsetIncrementOnRebufferMs); return this; } @@ -295,9 +297,9 @@ public final class DefaultLivePlaybackSpeedControl implements LivePlaybackSpeedC @Override public void setLiveConfiguration(LiveConfiguration liveConfiguration) { - mediaConfigurationTargetLiveOffsetUs = C.msToUs(liveConfiguration.targetOffsetMs); - minTargetLiveOffsetUs = C.msToUs(liveConfiguration.minOffsetMs); - maxTargetLiveOffsetUs = C.msToUs(liveConfiguration.maxOffsetMs); + mediaConfigurationTargetLiveOffsetUs = Util.msToUs(liveConfiguration.targetOffsetMs); + minTargetLiveOffsetUs = Util.msToUs(liveConfiguration.minOffsetMs); + maxTargetLiveOffsetUs = Util.msToUs(liveConfiguration.maxOffsetMs); minPlaybackSpeed = liveConfiguration.minPlaybackSpeed != C.RATE_UNSET ? liveConfiguration.minPlaybackSpeed @@ -416,7 +418,7 @@ public final class DefaultLivePlaybackSpeedControl implements LivePlaybackSpeedC // There is room for decreasing the target offset towards the ideal or safe offset (whichever // is larger). We want to limit the decrease so that the playback speed delta we achieve is // the same as the maximum delta when slowing down towards the target. - long minUpdateIntervalUs = C.msToUs(minUpdateIntervalMs); + long minUpdateIntervalUs = Util.msToUs(minUpdateIntervalMs); long decrementToOffsetCurrentSpeedUs = (long) ((adjustedPlaybackSpeed - 1f) * minUpdateIntervalUs); long decrementToIncreaseSpeedUs = (long) ((maxPlaybackSpeed - 1f) * minUpdateIntervalUs); diff --git a/library/core/src/main/java/com/google/android/exoplayer2/DefaultLoadControl.java b/library/core/src/main/java/com/google/android/exoplayer2/DefaultLoadControl.java index b947755f6d..d2ea709e76 100644 --- a/library/core/src/main/java/com/google/android/exoplayer2/DefaultLoadControl.java +++ b/library/core/src/main/java/com/google/android/exoplayer2/DefaultLoadControl.java @@ -299,17 +299,17 @@ public class DefaultLoadControl implements LoadControl { assertGreaterOrEqual(backBufferDurationMs, 0, "backBufferDurationMs", "0"); this.allocator = allocator; - this.minBufferUs = C.msToUs(minBufferMs); - this.maxBufferUs = C.msToUs(maxBufferMs); - this.bufferForPlaybackUs = C.msToUs(bufferForPlaybackMs); - this.bufferForPlaybackAfterRebufferUs = C.msToUs(bufferForPlaybackAfterRebufferMs); + this.minBufferUs = Util.msToUs(minBufferMs); + this.maxBufferUs = Util.msToUs(maxBufferMs); + this.bufferForPlaybackUs = Util.msToUs(bufferForPlaybackMs); + this.bufferForPlaybackAfterRebufferUs = Util.msToUs(bufferForPlaybackAfterRebufferMs); this.targetBufferBytesOverwrite = targetBufferBytes; this.targetBufferBytes = targetBufferBytesOverwrite != C.LENGTH_UNSET ? targetBufferBytesOverwrite : DEFAULT_MIN_BUFFER_SIZE; this.prioritizeTimeOverSizeThresholds = prioritizeTimeOverSizeThresholds; - this.backBufferDurationUs = C.msToUs(backBufferDurationMs); + this.backBufferDurationUs = Util.msToUs(backBufferDurationMs); this.retainBackBufferFromKeyframe = retainBackBufferFromKeyframe; } diff --git a/library/core/src/main/java/com/google/android/exoplayer2/ExoPlaybackException.java b/library/core/src/main/java/com/google/android/exoplayer2/ExoPlaybackException.java index f78441bda1..bc342e7995 100644 --- a/library/core/src/main/java/com/google/android/exoplayer2/ExoPlaybackException.java +++ b/library/core/src/main/java/com/google/android/exoplayer2/ExoPlaybackException.java @@ -359,7 +359,7 @@ public final class ExoPlaybackException extends PlaybackException { + ", format=" + rendererFormat + ", format_supported=" - + C.getFormatSupportString(rendererFormatSupport); + + Util.getFormatSupportString(rendererFormatSupport); break; case TYPE_REMOTE: message = "Remote error"; diff --git a/library/core/src/main/java/com/google/android/exoplayer2/ExoPlayerImpl.java b/library/core/src/main/java/com/google/android/exoplayer2/ExoPlayerImpl.java index 31fb99dbc2..653135e59c 100644 --- a/library/core/src/main/java/com/google/android/exoplayer2/ExoPlayerImpl.java +++ b/library/core/src/main/java/com/google/android/exoplayer2/ExoPlayerImpl.java @@ -669,7 +669,7 @@ import java.util.concurrent.CopyOnWriteArraySet; newPlaybackInfo, timeline, getPeriodPositionOrMaskWindowPosition(timeline, mediaItemIndex, positionMs)); - internalPlayer.seekTo(timeline, mediaItemIndex, C.msToUs(positionMs)); + internalPlayer.seekTo(timeline, mediaItemIndex, Util.msToUs(positionMs)); updatePlaybackInfo( newPlaybackInfo, /* ignored */ TIMELINE_CHANGE_REASON_PLAYLIST_CHANGED, @@ -865,21 +865,21 @@ import java.util.concurrent.CopyOnWriteArraySet; MediaPeriodId periodId = playbackInfo.periodId; playbackInfo.timeline.getPeriodByUid(periodId.periodUid, period); long adDurationUs = period.getAdDurationUs(periodId.adGroupIndex, periodId.adIndexInAdGroup); - return C.usToMs(adDurationUs); + return Util.usToMs(adDurationUs); } return getContentDuration(); } @Override public long getCurrentPosition() { - return C.usToMs(getCurrentPositionUsInternal(playbackInfo)); + return Util.usToMs(getCurrentPositionUsInternal(playbackInfo)); } @Override public long getBufferedPosition() { if (isPlayingAd()) { return playbackInfo.loadingMediaPeriodId.equals(playbackInfo.periodId) - ? C.usToMs(playbackInfo.bufferedPositionUs) + ? Util.usToMs(playbackInfo.bufferedPositionUs) : getDuration(); } return getContentBufferedPosition(); @@ -887,7 +887,7 @@ import java.util.concurrent.CopyOnWriteArraySet; @Override public long getTotalBufferedDuration() { - return C.usToMs(playbackInfo.totalBufferedDurationUs); + return Util.usToMs(playbackInfo.totalBufferedDurationUs); } @Override @@ -911,7 +911,7 @@ import java.util.concurrent.CopyOnWriteArraySet; playbackInfo.timeline.getPeriodByUid(playbackInfo.periodId.periodUid, period); return playbackInfo.requestedContentPositionUs == C.TIME_UNSET ? playbackInfo.timeline.getWindow(getCurrentWindowIndex(), window).getDefaultPositionMs() - : period.getPositionInWindowMs() + C.usToMs(playbackInfo.requestedContentPositionUs); + : period.getPositionInWindowMs() + Util.usToMs(playbackInfo.requestedContentPositionUs); } else { return getCurrentPosition(); } @@ -936,7 +936,7 @@ import java.util.concurrent.CopyOnWriteArraySet; contentBufferedPositionUs = loadingPeriod.durationUs; } } - return C.usToMs( + return Util.usToMs( periodPositionUsToWindowPositionUs( playbackInfo.timeline, playbackInfo.loadingMediaPeriodId, contentBufferedPositionUs)); } @@ -1136,7 +1136,7 @@ import java.util.concurrent.CopyOnWriteArraySet; private long getCurrentPositionUsInternal(PlaybackInfo playbackInfo) { if (playbackInfo.timeline.isEmpty()) { - return C.msToUs(maskingWindowPositionMs); + return Util.msToUs(maskingWindowPositionMs); } else if (playbackInfo.periodId.isAd()) { return playbackInfo.positionUs; } else { @@ -1425,8 +1425,8 @@ import java.util.concurrent.CopyOnWriteArraySet; oldMediaItem, oldPeriodUid, oldPeriodIndex, - C.usToMs(oldPositionUs), - C.usToMs(oldContentPositionUs), + Util.usToMs(oldPositionUs), + Util.usToMs(oldContentPositionUs), oldPlaybackInfo.periodId.adGroupIndex, oldPlaybackInfo.periodId.adIndexInAdGroup); } @@ -1444,7 +1444,7 @@ import java.util.concurrent.CopyOnWriteArraySet; newWindowUid = playbackInfo.timeline.getWindow(newWindowIndex, window).uid; newMediaItem = window.mediaItem; } - long positionMs = C.usToMs(discontinuityWindowStartPositionUs); + long positionMs = Util.usToMs(discontinuityWindowStartPositionUs); return new PositionInfo( newWindowUid, newWindowIndex, @@ -1453,7 +1453,7 @@ import java.util.concurrent.CopyOnWriteArraySet; newPeriodIndex, positionMs, /* contentPositionMs= */ playbackInfo.periodId.isAd() - ? C.usToMs(getRequestedContentPositionUs(playbackInfo)) + ? Util.usToMs(getRequestedContentPositionUs(playbackInfo)) : positionMs, playbackInfo.periodId.adGroupIndex, playbackInfo.periodId.adIndexInAdGroup); @@ -1567,7 +1567,7 @@ import java.util.concurrent.CopyOnWriteArraySet; } newPlaybackInfo = newPlaybackInfo.copyWithPlaybackState(maskingPlaybackState); internalPlayer.setMediaSources( - holders, startWindowIndex, C.msToUs(startPositionMs), shuffleOrder); + holders, startWindowIndex, Util.msToUs(startPositionMs), shuffleOrder); boolean positionDiscontinuity = !playbackInfo.periodId.periodUid.equals(newPlaybackInfo.periodId.periodUid) && !playbackInfo.timeline.isEmpty(); @@ -1647,7 +1647,7 @@ import java.util.concurrent.CopyOnWriteArraySet; if (timeline.isEmpty()) { // Reset periodId and loadingPeriodId. MediaPeriodId dummyMediaPeriodId = PlaybackInfo.getDummyPeriodForEmptyTimeline(); - long positionUs = C.msToUs(maskingWindowPositionMs); + long positionUs = Util.msToUs(maskingWindowPositionMs); playbackInfo = playbackInfo.copyWithNewPosition( dummyMediaPeriodId, @@ -1668,7 +1668,7 @@ import java.util.concurrent.CopyOnWriteArraySet; MediaPeriodId newPeriodId = playingPeriodChanged ? new MediaPeriodId(periodPosition.first) : playbackInfo.periodId; long newContentPositionUs = periodPosition.second; - long oldContentPositionUs = C.msToUs(getContentPosition()); + long oldContentPositionUs = Util.msToUs(getContentPosition()); if (!oldTimeline.isEmpty()) { oldContentPositionUs -= oldTimeline.getPeriodByUid(oldPeriodUid, period).getPositionInWindowUs(); @@ -1757,7 +1757,7 @@ import java.util.concurrent.CopyOnWriteArraySet; @Nullable Pair oldPeriodPosition = oldTimeline.getPeriodPosition( - window, period, currentWindowIndex, C.msToUs(currentPositionMs)); + window, period, currentWindowIndex, Util.msToUs(currentPositionMs)); Object periodUid = castNonNull(oldPeriodPosition).first; if (newTimeline.getIndexOfPeriod(periodUid) != C.INDEX_UNSET) { // The old period position is still available in the new timeline. @@ -1798,7 +1798,7 @@ import java.util.concurrent.CopyOnWriteArraySet; windowIndex = timeline.getFirstWindowIndex(shuffleModeEnabled); windowPositionMs = timeline.getWindow(windowIndex, window).getDefaultPositionMs(); } - return timeline.getPeriodPosition(window, period, windowIndex, C.msToUs(windowPositionMs)); + return timeline.getPeriodPosition(window, period, windowIndex, Util.msToUs(windowPositionMs)); } private long periodPositionUsToWindowPositionUs( diff --git a/library/core/src/main/java/com/google/android/exoplayer2/ExoPlayerImplInternal.java b/library/core/src/main/java/com/google/android/exoplayer2/ExoPlayerImplInternal.java index 02cf785eed..30085aeb9a 100644 --- a/library/core/src/main/java/com/google/android/exoplayer2/ExoPlayerImplInternal.java +++ b/library/core/src/main/java/com/google/android/exoplayer2/ExoPlayerImplInternal.java @@ -1082,7 +1082,7 @@ import java.util.concurrent.atomic.AtomicBoolean; if (window.windowStartTimeMs == C.TIME_UNSET || !window.isLive() || !window.isDynamic) { return C.TIME_UNSET; } - return C.msToUs(window.getCurrentUnixTimeMs() - window.windowStartTimeMs) + return Util.msToUs(window.getCurrentUnixTimeMs() - window.windowStartTimeMs) - (periodPositionUs + period.getPositionInWindowUs()); } @@ -1184,7 +1184,7 @@ import java.util.concurrent.atomic.AtomicBoolean; playingPeriodHolder.mediaPeriod.getAdjustedSeekPositionUs( newPeriodPositionUs, seekParameters); } - if (C.usToMs(newPeriodPositionUs) == C.usToMs(playbackInfo.positionUs) + if (Util.usToMs(newPeriodPositionUs) == Util.usToMs(playbackInfo.positionUs) && (playbackInfo.playbackState == Player.STATE_BUFFERING || playbackInfo.playbackState == Player.STATE_READY)) { // Seek will be performed to the current position. Do nothing. @@ -2710,7 +2710,7 @@ import java.util.concurrent.atomic.AtomicBoolean; long requestPositionUs = pendingMessageInfo.message.getPositionMs() == C.TIME_END_OF_SOURCE ? C.TIME_UNSET - : C.msToUs(pendingMessageInfo.message.getPositionMs()); + : Util.msToUs(pendingMessageInfo.message.getPositionMs()); @Nullable Pair periodPosition = resolveSeekPosition( diff --git a/library/core/src/main/java/com/google/android/exoplayer2/SimpleExoPlayer.java b/library/core/src/main/java/com/google/android/exoplayer2/SimpleExoPlayer.java index 6a061bef5f..f0637df30a 100644 --- a/library/core/src/main/java/com/google/android/exoplayer2/SimpleExoPlayer.java +++ b/library/core/src/main/java/com/google/android/exoplayer2/SimpleExoPlayer.java @@ -455,7 +455,7 @@ public class SimpleExoPlayer extends BasePlayer if (Util.SDK_INT < 21) { audioSessionId = initializeKeepSessionIdAudioTrack(C.AUDIO_SESSION_ID_UNSET); } else { - audioSessionId = C.generateAudioSessionIdV21(applicationContext); + audioSessionId = Util.generateAudioSessionIdV21(applicationContext); } currentCues = Collections.emptyList(); throwsWhenUsingWrongThread = true; @@ -770,7 +770,7 @@ public class SimpleExoPlayer extends BasePlayer if (Util.SDK_INT < 21) { audioSessionId = initializeKeepSessionIdAudioTrack(C.AUDIO_SESSION_ID_UNSET); } else { - audioSessionId = C.generateAudioSessionIdV21(applicationContext); + audioSessionId = Util.generateAudioSessionIdV21(applicationContext); } } else if (Util.SDK_INT < 21) { // We need to re-initialize keepSessionIdAudioTrack to make sure the session is kept alive for diff --git a/library/core/src/main/java/com/google/android/exoplayer2/analytics/AnalyticsCollector.java b/library/core/src/main/java/com/google/android/exoplayer2/analytics/AnalyticsCollector.java index 4d1bcd457f..ae22609e29 100644 --- a/library/core/src/main/java/com/google/android/exoplayer2/analytics/AnalyticsCollector.java +++ b/library/core/src/main/java/com/google/android/exoplayer2/analytics/AnalyticsCollector.java @@ -1157,7 +1157,7 @@ public class AnalyticsCollector : playerTimeline .getPeriod(playerPeriodIndex, period) .getAdGroupIndexAfterPositionUs( - C.msToUs(player.getCurrentPosition()) - period.getPositionInWindowUs()); + Util.msToUs(player.getCurrentPosition()) - period.getPositionInWindowUs()); for (int i = 0; i < mediaPeriodQueue.size(); i++) { MediaPeriodId mediaPeriodId = mediaPeriodQueue.get(i); if (isMatchingMediaPeriod( diff --git a/library/core/src/main/java/com/google/android/exoplayer2/analytics/DefaultPlaybackSessionManager.java b/library/core/src/main/java/com/google/android/exoplayer2/analytics/DefaultPlaybackSessionManager.java index 7d4d6087dc..2403f9bf77 100644 --- a/library/core/src/main/java/com/google/android/exoplayer2/analytics/DefaultPlaybackSessionManager.java +++ b/library/core/src/main/java/com/google/android/exoplayer2/analytics/DefaultPlaybackSessionManager.java @@ -15,7 +15,6 @@ */ package com.google.android.exoplayer2.analytics; -import static com.google.android.exoplayer2.C.usToMs; import static java.lang.Math.max; import android.util.Base64; @@ -141,7 +140,7 @@ public final class DefaultPlaybackSessionManager implements PlaybackSessionManag contentSession.isCreated = true; eventTime.timeline.getPeriodByUid(eventTime.mediaPeriodId.periodUid, period); long adGroupPositionMs = - usToMs(period.getAdGroupTimeUs(eventTime.mediaPeriodId.adGroupIndex)) + Util.usToMs(period.getAdGroupTimeUs(eventTime.mediaPeriodId.adGroupIndex)) + period.getPositionInWindowMs(); // getAdGroupTimeUs may return 0 for prerolls despite period offset. adGroupPositionMs = max(0, adGroupPositionMs); diff --git a/library/core/src/main/java/com/google/android/exoplayer2/analytics/PlaybackStatsListener.java b/library/core/src/main/java/com/google/android/exoplayer2/analytics/PlaybackStatsListener.java index 343fa4ce76..868bfb617c 100644 --- a/library/core/src/main/java/com/google/android/exoplayer2/analytics/PlaybackStatsListener.java +++ b/library/core/src/main/java/com/google/android/exoplayer2/analytics/PlaybackStatsListener.java @@ -333,7 +333,7 @@ public final class PlaybackStatsListener eventTime.mediaPeriodId.periodUid, eventTime.mediaPeriodId.windowSequenceNumber, eventTime.mediaPeriodId.adGroupIndex), - /* eventPlaybackPositionMs= */ C.usToMs(contentWindowPositionUs), + /* eventPlaybackPositionMs= */ Util.usToMs(contentWindowPositionUs), eventTime.timeline, eventTime.currentWindowIndex, eventTime.currentMediaPeriodId, diff --git a/library/core/src/main/java/com/google/android/exoplayer2/audio/AudioTrackPositionTracker.java b/library/core/src/main/java/com/google/android/exoplayer2/audio/AudioTrackPositionTracker.java index 6c26d87fcf..9c8186ffa6 100644 --- a/library/core/src/main/java/com/google/android/exoplayer2/audio/AudioTrackPositionTracker.java +++ b/library/core/src/main/java/com/google/android/exoplayer2/audio/AudioTrackPositionTracker.java @@ -302,12 +302,12 @@ import java.lang.reflect.Method; if (!notifiedPositionIncreasing && positionUs > lastPositionUs) { notifiedPositionIncreasing = true; - long mediaDurationSinceLastPositionUs = C.usToMs(positionUs - lastPositionUs); + long mediaDurationSinceLastPositionUs = Util.usToMs(positionUs - lastPositionUs); long playoutDurationSinceLastPositionUs = Util.getPlayoutDurationForMediaDuration( mediaDurationSinceLastPositionUs, audioTrackPlaybackSpeed); long playoutStartSystemTimeMs = - System.currentTimeMillis() - C.usToMs(playoutDurationSinceLastPositionUs); + System.currentTimeMillis() - Util.usToMs(playoutDurationSinceLastPositionUs); listener.onPositionAdvancing(playoutStartSystemTimeMs); } @@ -357,7 +357,7 @@ import java.lang.reflect.Method; boolean hadData = hasData; hasData = hasPendingData(writtenFrames); if (hadData && !hasData && playState != PLAYSTATE_STOPPED) { - listener.onUnderrun(bufferSize, C.usToMs(bufferSizeUs)); + listener.onUnderrun(bufferSize, Util.usToMs(bufferSizeUs)); } return true; @@ -379,7 +379,7 @@ import java.lang.reflect.Method; /** Returns the duration of audio that is buffered but unplayed. */ public long getPendingBufferDurationMs(long writtenFrames) { - return C.usToMs(framesToDurationUs(writtenFrames - getPlaybackHeadPosition())); + return Util.usToMs(framesToDurationUs(writtenFrames - getPlaybackHeadPosition())); } /** Returns whether the track is in an invalid state and must be recreated. */ diff --git a/library/core/src/main/java/com/google/android/exoplayer2/drm/DrmUtil.java b/library/core/src/main/java/com/google/android/exoplayer2/drm/DrmUtil.java index bd89d2d373..1b2237bf1b 100644 --- a/library/core/src/main/java/com/google/android/exoplayer2/drm/DrmUtil.java +++ b/library/core/src/main/java/com/google/android/exoplayer2/drm/DrmUtil.java @@ -23,7 +23,6 @@ import androidx.annotation.DoNotInline; import androidx.annotation.IntDef; import androidx.annotation.Nullable; import androidx.annotation.RequiresApi; -import com.google.android.exoplayer2.C; import com.google.android.exoplayer2.PlaybackException; import com.google.android.exoplayer2.util.Util; import java.lang.annotation.Documented; @@ -122,7 +121,7 @@ public final class DrmUtil { @Nullable String diagnosticsInfo = ((MediaDrm.MediaDrmStateException) throwable).getDiagnosticInfo(); int drmErrorCode = Util.getErrorCodeFromPlatformDiagnosticsInfo(diagnosticsInfo); - return C.getErrorCodeForMediaDrmErrorCode(drmErrorCode); + return Util.getErrorCodeForMediaDrmErrorCode(drmErrorCode); } } diff --git a/library/core/src/main/java/com/google/android/exoplayer2/mediacodec/MediaCodecRenderer.java b/library/core/src/main/java/com/google/android/exoplayer2/mediacodec/MediaCodecRenderer.java index 389e675c59..3a476229e1 100644 --- a/library/core/src/main/java/com/google/android/exoplayer2/mediacodec/MediaCodecRenderer.java +++ b/library/core/src/main/java/com/google/android/exoplayer2/mediacodec/MediaCodecRenderer.java @@ -1240,7 +1240,7 @@ public abstract class MediaCodecRenderer extends BaseRenderer { } } catch (CryptoException e) { throw createRendererException( - e, inputFormat, C.getErrorCodeForMediaDrmErrorCode(e.getErrorCode())); + e, inputFormat, Util.getErrorCodeForMediaDrmErrorCode(e.getErrorCode())); } return false; } @@ -1312,7 +1312,7 @@ public abstract class MediaCodecRenderer extends BaseRenderer { } } catch (CryptoException e) { throw createRendererException( - e, inputFormat, C.getErrorCodeForMediaDrmErrorCode(e.getErrorCode())); + e, inputFormat, Util.getErrorCodeForMediaDrmErrorCode(e.getErrorCode())); } resetInputBuffer(); diff --git a/library/core/src/main/java/com/google/android/exoplayer2/source/ClippingMediaSource.java b/library/core/src/main/java/com/google/android/exoplayer2/source/ClippingMediaSource.java index b81d222221..f86b81760d 100644 --- a/library/core/src/main/java/com/google/android/exoplayer2/source/ClippingMediaSource.java +++ b/library/core/src/main/java/com/google/android/exoplayer2/source/ClippingMediaSource.java @@ -26,6 +26,7 @@ import com.google.android.exoplayer2.Timeline; import com.google.android.exoplayer2.upstream.Allocator; import com.google.android.exoplayer2.upstream.TransferListener; import com.google.android.exoplayer2.util.Assertions; +import com.google.android.exoplayer2.util.Util; import java.io.IOException; import java.lang.annotation.Documented; import java.lang.annotation.Retention; @@ -338,7 +339,7 @@ public final class ClippingMediaSource extends CompositeMediaSource { endUs == C.TIME_UNSET ? window.defaultPositionUs : min(window.defaultPositionUs, endUs); window.defaultPositionUs -= startUs; } - long startMs = C.usToMs(startUs); + long startMs = Util.usToMs(startUs); if (window.presentationStartTimeMs != C.TIME_UNSET) { window.presentationStartTimeMs += startMs; } diff --git a/library/core/src/main/java/com/google/android/exoplayer2/source/MediaSourceEventListener.java b/library/core/src/main/java/com/google/android/exoplayer2/source/MediaSourceEventListener.java index 13f7562576..d1bcf9380c 100644 --- a/library/core/src/main/java/com/google/android/exoplayer2/source/MediaSourceEventListener.java +++ b/library/core/src/main/java/com/google/android/exoplayer2/source/MediaSourceEventListener.java @@ -26,6 +26,7 @@ import com.google.android.exoplayer2.Format; import com.google.android.exoplayer2.Player; import com.google.android.exoplayer2.source.MediaSource.MediaPeriodId; import com.google.android.exoplayer2.util.Assertions; +import com.google.android.exoplayer2.util.Util; import java.io.IOException; import java.util.concurrent.CopyOnWriteArrayList; @@ -472,7 +473,7 @@ public interface MediaSourceEventListener { } private long adjustMediaTime(long mediaTimeUs) { - long mediaTimeMs = C.usToMs(mediaTimeUs); + long mediaTimeMs = Util.usToMs(mediaTimeUs); return mediaTimeMs == C.TIME_UNSET ? C.TIME_UNSET : mediaTimeOffsetMs + mediaTimeMs; } diff --git a/library/core/src/main/java/com/google/android/exoplayer2/source/ProgressiveMediaPeriod.java b/library/core/src/main/java/com/google/android/exoplayer2/source/ProgressiveMediaPeriod.java index c30476405d..4c0b795f80 100644 --- a/library/core/src/main/java/com/google/android/exoplayer2/source/ProgressiveMediaPeriod.java +++ b/library/core/src/main/java/com/google/android/exoplayer2/source/ProgressiveMediaPeriod.java @@ -641,8 +641,8 @@ import org.checkerframework.checker.nullness.qual.MonotonicNonNull; /* trackFormat= */ null, C.SELECTION_REASON_UNKNOWN, /* trackSelectionData= */ null, - /* mediaStartTimeMs= */ C.usToMs(loadable.seekTimeUs), - C.usToMs(durationUs)); + /* mediaStartTimeMs= */ Util.usToMs(loadable.seekTimeUs), + Util.usToMs(durationUs)); LoadErrorAction loadErrorAction; long retryDelayMs = loadErrorHandlingPolicy.getRetryDelayMsFor( diff --git a/library/core/src/main/java/com/google/android/exoplayer2/source/SingleSampleMediaPeriod.java b/library/core/src/main/java/com/google/android/exoplayer2/source/SingleSampleMediaPeriod.java index a018f94de2..e589e8cca4 100644 --- a/library/core/src/main/java/com/google/android/exoplayer2/source/SingleSampleMediaPeriod.java +++ b/library/core/src/main/java/com/google/android/exoplayer2/source/SingleSampleMediaPeriod.java @@ -36,6 +36,7 @@ import com.google.android.exoplayer2.upstream.TransferListener; import com.google.android.exoplayer2.util.Assertions; import com.google.android.exoplayer2.util.Log; import com.google.android.exoplayer2.util.MimeTypes; +import com.google.android.exoplayer2.util.Util; import java.io.IOException; import java.util.ArrayList; import java.util.Arrays; @@ -282,7 +283,7 @@ import org.checkerframework.checker.nullness.qual.MonotonicNonNull; C.SELECTION_REASON_UNKNOWN, /* trackSelectionData= */ null, /* mediaStartTimeMs= */ 0, - C.usToMs(durationUs)); + Util.usToMs(durationUs)); long retryDelay = loadErrorHandlingPolicy.getRetryDelayMsFor( new LoadErrorInfo(loadEventInfo, mediaLoadData, error, errorCount)); diff --git a/library/core/src/main/java/com/google/android/exoplayer2/source/ads/ServerSideInsertedAdsMediaSource.java b/library/core/src/main/java/com/google/android/exoplayer2/source/ads/ServerSideInsertedAdsMediaSource.java index 69588f504c..1a5d94ad1f 100644 --- a/library/core/src/main/java/com/google/android/exoplayer2/source/ads/ServerSideInsertedAdsMediaSource.java +++ b/library/core/src/main/java/com/google/android/exoplayer2/source/ads/ServerSideInsertedAdsMediaSource.java @@ -512,7 +512,7 @@ public final class ServerSideInsertedAdsMediaSource extends BaseMediaSource if (mediaPositionMs == C.TIME_UNSET) { return C.TIME_UNSET; } - long mediaPositionUs = C.msToUs(mediaPositionMs); + long mediaPositionUs = Util.msToUs(mediaPositionMs); MediaPeriodId id = mediaPeriod.mediaPeriodId; long correctedPositionUs = id.isAd() @@ -522,7 +522,7 @@ public final class ServerSideInsertedAdsMediaSource extends BaseMediaSource // content pieces (beyond nextAdGroupIndex). : getMediaPeriodPositionUsForContent( mediaPositionUs, /* nextAdGroupIndex= */ C.INDEX_UNSET, adPlaybackState); - return C.usToMs(correctedPositionUs); + return Util.usToMs(correctedPositionUs); } private static final class SharedMediaPeriod implements MediaPeriod.Callback { @@ -591,7 +591,7 @@ public final class ServerSideInsertedAdsMediaSource extends BaseMediaSource MediaPeriodImpl mediaPeriod = mediaPeriods.get(i); long startTimeInPeriodUs = getMediaPeriodPositionUs( - C.msToUs(mediaLoadData.mediaStartTimeMs), + Util.msToUs(mediaLoadData.mediaStartTimeMs), mediaPeriod.mediaPeriodId, adPlaybackState); long mediaPeriodEndPositionUs = getMediaPeriodEndPositionUs(mediaPeriod, adPlaybackState); diff --git a/library/core/src/main/java/com/google/android/exoplayer2/source/ads/ServerSideInsertedAdsUtil.java b/library/core/src/main/java/com/google/android/exoplayer2/source/ads/ServerSideInsertedAdsUtil.java index 65567d005b..48ba8da7aa 100644 --- a/library/core/src/main/java/com/google/android/exoplayer2/source/ads/ServerSideInsertedAdsUtil.java +++ b/library/core/src/main/java/com/google/android/exoplayer2/source/ads/ServerSideInsertedAdsUtil.java @@ -124,11 +124,12 @@ public final class ServerSideInsertedAdsUtil { if (player.isPlayingAd()) { int adGroupIndex = player.getCurrentAdGroupIndex(); int adIndexInAdGroup = player.getCurrentAdIndexInAdGroup(); - long adPositionUs = C.msToUs(player.getCurrentPosition()); + long adPositionUs = Util.msToUs(player.getCurrentPosition()); return getStreamPositionUsForAd( adPositionUs, adGroupIndex, adIndexInAdGroup, adPlaybackState); } - long periodPositionUs = C.msToUs(player.getCurrentPosition()) - period.getPositionInWindowUs(); + long periodPositionUs = + Util.msToUs(player.getCurrentPosition()) - period.getPositionInWindowUs(); return getStreamPositionUsForContent( periodPositionUs, /* nextAdGroupIndex= */ C.INDEX_UNSET, adPlaybackState); } diff --git a/library/core/src/main/java/com/google/android/exoplayer2/source/chunk/ChunkSampleStream.java b/library/core/src/main/java/com/google/android/exoplayer2/source/chunk/ChunkSampleStream.java index a44a0615c4..9df2e489f9 100644 --- a/library/core/src/main/java/com/google/android/exoplayer2/source/chunk/ChunkSampleStream.java +++ b/library/core/src/main/java/com/google/android/exoplayer2/source/chunk/ChunkSampleStream.java @@ -510,8 +510,8 @@ public class ChunkSampleStream loadable.trackFormat, loadable.trackSelectionReason, loadable.trackSelectionData, - C.usToMs(loadable.startTimeUs), - C.usToMs(loadable.endTimeUs)); + Util.usToMs(loadable.startTimeUs), + Util.usToMs(loadable.endTimeUs)); LoadErrorInfo loadErrorInfo = new LoadErrorInfo(loadEventInfo, mediaLoadData, error, errorCount); diff --git a/library/core/src/main/java/com/google/android/exoplayer2/util/EventLogger.java b/library/core/src/main/java/com/google/android/exoplayer2/util/EventLogger.java index 16801c6bab..62a78ca42e 100644 --- a/library/core/src/main/java/com/google/android/exoplayer2/util/EventLogger.java +++ b/library/core/src/main/java/com/google/android/exoplayer2/util/EventLogger.java @@ -277,7 +277,7 @@ public class EventLogger implements AnalyticsListener { for (int trackIndex = 0; trackIndex < trackGroup.length; trackIndex++) { String status = getTrackStatusString(trackSelection, trackGroup, trackIndex); String formatSupport = - C.getFormatSupportString( + Util.getFormatSupportString( mappedTrackInfo.getTrackSupport(rendererIndex, groupIndex, trackIndex)); logd( " " @@ -315,7 +315,7 @@ public class EventLogger implements AnalyticsListener { TrackGroup trackGroup = unassociatedTrackGroups.get(groupIndex); for (int trackIndex = 0; trackIndex < trackGroup.length; trackIndex++) { String status = getTrackStatusString(false); - String formatSupport = C.getFormatSupportString(C.FORMAT_UNSUPPORTED_TYPE); + String formatSupport = Util.getFormatSupportString(C.FORMAT_UNSUPPORTED_TYPE); logd( " " + status diff --git a/library/core/src/main/java/com/google/android/exoplayer2/util/StandaloneMediaClock.java b/library/core/src/main/java/com/google/android/exoplayer2/util/StandaloneMediaClock.java index 4c4d4d114b..46806cb65a 100644 --- a/library/core/src/main/java/com/google/android/exoplayer2/util/StandaloneMediaClock.java +++ b/library/core/src/main/java/com/google/android/exoplayer2/util/StandaloneMediaClock.java @@ -15,7 +15,6 @@ */ package com.google.android.exoplayer2.util; -import com.google.android.exoplayer2.C; import com.google.android.exoplayer2.PlaybackParameters; /** @@ -75,7 +74,7 @@ public final class StandaloneMediaClock implements MediaClock { if (started) { long elapsedSinceBaseMs = clock.elapsedRealtime() - baseElapsedMs; if (playbackParameters.speed == 1f) { - positionUs += C.msToUs(elapsedSinceBaseMs); + positionUs += Util.msToUs(elapsedSinceBaseMs); } else { // Add the media time in microseconds that will elapse in elapsedSinceBaseMs milliseconds of // wallclock time diff --git a/library/core/src/main/java/com/google/android/exoplayer2/video/DecoderVideoRenderer.java b/library/core/src/main/java/com/google/android/exoplayer2/video/DecoderVideoRenderer.java index e0e49d478b..b4af6cfb46 100644 --- a/library/core/src/main/java/com/google/android/exoplayer2/video/DecoderVideoRenderer.java +++ b/library/core/src/main/java/com/google/android/exoplayer2/video/DecoderVideoRenderer.java @@ -50,6 +50,7 @@ import com.google.android.exoplayer2.util.Assertions; import com.google.android.exoplayer2.util.Log; import com.google.android.exoplayer2.util.TimedValueQueue; import com.google.android.exoplayer2.util.TraceUtil; +import com.google.android.exoplayer2.util.Util; import com.google.android.exoplayer2.video.VideoRendererEventListener.EventDispatcher; import java.lang.annotation.Documented; import java.lang.annotation.Retention; @@ -558,7 +559,7 @@ public abstract class DecoderVideoRenderer extends BaseRenderer { frameMetadataListener.onVideoFrameAboutToBeRendered( presentationTimeUs, System.nanoTime(), outputFormat, /* mediaFormat= */ null); } - lastRenderTimeUs = C.msToUs(SystemClock.elapsedRealtime() * 1000); + lastRenderTimeUs = Util.msToUs(SystemClock.elapsedRealtime() * 1000); int bufferMode = outputBuffer.mode; boolean renderSurface = bufferMode == C.VIDEO_OUTPUT_MODE_SURFACE_YUV && outputSurface != null; boolean renderYuv = bufferMode == C.VIDEO_OUTPUT_MODE_YUV && outputBufferRenderer != null; diff --git a/library/core/src/test/java/com/google/android/exoplayer2/DefaultLoadControlTest.java b/library/core/src/test/java/com/google/android/exoplayer2/DefaultLoadControlTest.java index 1cebbbd011..f89e7b3f48 100644 --- a/library/core/src/test/java/com/google/android/exoplayer2/DefaultLoadControlTest.java +++ b/library/core/src/test/java/com/google/android/exoplayer2/DefaultLoadControlTest.java @@ -22,6 +22,7 @@ import com.google.android.exoplayer2.DefaultLoadControl.Builder; import com.google.android.exoplayer2.source.TrackGroupArray; import com.google.android.exoplayer2.trackselection.ExoTrackSelection; import com.google.android.exoplayer2.upstream.DefaultAllocator; +import com.google.android.exoplayer2.util.Util; import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; @@ -31,7 +32,7 @@ import org.junit.runner.RunWith; public class DefaultLoadControlTest { private static final float SPEED = 1f; - private static final long MAX_BUFFER_US = C.msToUs(DefaultLoadControl.DEFAULT_MAX_BUFFER_MS); + private static final long MAX_BUFFER_US = Util.msToUs(DefaultLoadControl.DEFAULT_MAX_BUFFER_MS); private static final long MIN_BUFFER_US = MAX_BUFFER_US / 2; private static final int TARGET_BUFFER_BYTES = C.DEFAULT_BUFFER_SEGMENT_SIZE * 2; @@ -64,8 +65,8 @@ public class DefaultLoadControlTest { @Test public void shouldNotContinueLoadingOnceBufferingStopped_untilBelowMinBuffer() { builder.setBufferDurationsMs( - /* minBufferMs= */ (int) C.usToMs(MIN_BUFFER_US), - /* maxBufferMs= */ (int) C.usToMs(MAX_BUFFER_US), + /* minBufferMs= */ (int) Util.usToMs(MIN_BUFFER_US), + /* maxBufferMs= */ (int) Util.usToMs(MAX_BUFFER_US), /* bufferForPlaybackMs= */ 0, /* bufferForPlaybackAfterRebufferMs= */ 0); build(); @@ -88,7 +89,7 @@ public class DefaultLoadControlTest { public void continueLoadingOnceBufferingStopped_andBufferAlmostEmpty_evenIfMinBufferNotReached() { builder.setBufferDurationsMs( /* minBufferMs= */ 0, - /* maxBufferMs= */ (int) C.usToMs(MAX_BUFFER_US), + /* maxBufferMs= */ (int) Util.usToMs(MAX_BUFFER_US), /* bufferForPlaybackMs= */ 0, /* bufferForPlaybackAfterRebufferMs= */ 0); build(); @@ -107,8 +108,8 @@ public class DefaultLoadControlTest { public void shouldContinueLoadingWithTargetBufferBytesReached_untilMinBufferReached() { builder.setPrioritizeTimeOverSizeThresholds(true); builder.setBufferDurationsMs( - /* minBufferMs= */ (int) C.usToMs(MIN_BUFFER_US), - /* maxBufferMs= */ (int) C.usToMs(MAX_BUFFER_US), + /* minBufferMs= */ (int) Util.usToMs(MIN_BUFFER_US), + /* maxBufferMs= */ (int) Util.usToMs(MAX_BUFFER_US), /* bufferForPlaybackMs= */ 0, /* bufferForPlaybackAfterRebufferMs= */ 0); build(); @@ -158,8 +159,8 @@ public class DefaultLoadControlTest { @Test public void shouldContinueLoadingWithMinBufferReached_inFastPlayback() { builder.setBufferDurationsMs( - /* minBufferMs= */ (int) C.usToMs(MIN_BUFFER_US), - /* maxBufferMs= */ (int) C.usToMs(MAX_BUFFER_US), + /* minBufferMs= */ (int) Util.usToMs(MIN_BUFFER_US), + /* maxBufferMs= */ (int) Util.usToMs(MAX_BUFFER_US), /* bufferForPlaybackMs= */ 0, /* bufferForPlaybackAfterRebufferMs= */ 0); build(); diff --git a/library/core/src/test/java/com/google/android/exoplayer2/DefaultMediaClockTest.java b/library/core/src/test/java/com/google/android/exoplayer2/DefaultMediaClockTest.java index 9be4c76e62..38c41b5d68 100644 --- a/library/core/src/test/java/com/google/android/exoplayer2/DefaultMediaClockTest.java +++ b/library/core/src/test/java/com/google/android/exoplayer2/DefaultMediaClockTest.java @@ -25,6 +25,7 @@ import androidx.test.ext.junit.runners.AndroidJUnit4; import com.google.android.exoplayer2.DefaultMediaClock.PlaybackParametersListener; import com.google.android.exoplayer2.testutil.FakeClock; import com.google.android.exoplayer2.testutil.FakeMediaClockRenderer; +import com.google.android.exoplayer2.util.Util; import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; @@ -263,7 +264,7 @@ public class DefaultMediaClockTest { mediaClock.onRendererDisabled(mediaClockRenderer); fakeClock.advanceTime(SLEEP_TIME_MS); assertThat(mediaClock.syncAndGetPositionUs(/* isReadingAhead= */ false)) - .isEqualTo(TEST_POSITION_US + C.msToUs(SLEEP_TIME_MS)); + .isEqualTo(TEST_POSITION_US + Util.msToUs(SLEEP_TIME_MS)); assertClockIsRunning(/* isReadingAhead= */ false); } @@ -329,7 +330,7 @@ public class DefaultMediaClockTest { mediaClockRenderer.positionUs = TEST_POSITION_US; mediaClock.onRendererDisabled(mediaClockRenderer); assertThat(mediaClock.syncAndGetPositionUs(/* isReadingAhead= */ false)) - .isEqualTo(C.msToUs(fakeClock.elapsedRealtime())); + .isEqualTo(Util.msToUs(fakeClock.elapsedRealtime())); } @Test diff --git a/library/core/src/test/java/com/google/android/exoplayer2/ExoPlayerTest.java b/library/core/src/test/java/com/google/android/exoplayer2/ExoPlayerTest.java index 07f61f4e5e..64044b2a3f 100644 --- a/library/core/src/test/java/com/google/android/exoplayer2/ExoPlayerTest.java +++ b/library/core/src/test/java/com/google/android/exoplayer2/ExoPlayerTest.java @@ -145,6 +145,7 @@ import com.google.android.exoplayer2.upstream.TransferListener; import com.google.android.exoplayer2.util.Assertions; import com.google.android.exoplayer2.util.Clock; import com.google.android.exoplayer2.util.MimeTypes; +import com.google.android.exoplayer2.util.Util; import com.google.common.collect.ImmutableList; import com.google.common.collect.Iterables; import com.google.common.collect.Range; @@ -2765,7 +2766,7 @@ public final class ExoPlayerTest { // Ensure next period is pre-buffered by playing until end of first period. .playUntilPosition( /* windowIndex= */ 0, - /* positionMs= */ C.usToMs(TimelineWindowDefinition.DEFAULT_WINDOW_DURATION_US)) + /* positionMs= */ Util.usToMs(TimelineWindowDefinition.DEFAULT_WINDOW_DURATION_US)) .executeRunnable(() -> mediaSource.setNewSourceInfo(timeline2)) .waitForTimelineChanged( timeline2, /* expectedReason */ Player.TIMELINE_CHANGE_REASON_SOURCE_UPDATE) @@ -2857,7 +2858,7 @@ public final class ExoPlayerTest { /* adsPerAdGroup= */ 1, /* adGroupTimesUs...= */ TimelineWindowDefinition .DEFAULT_WINDOW_OFFSET_IN_FIRST_PERIOD_US - + C.msToUs(adGroupWindowTimeMs)); + + Util.msToUs(adGroupWindowTimeMs)); Timeline timeline = new FakeTimeline( new TimelineWindowDefinition( @@ -2865,7 +2866,7 @@ public final class ExoPlayerTest { /* id= */ 0, /* isSeekable= */ true, /* isDynamic= */ false, - /* durationUs= */ C.msToUs(contentDurationMs), + /* durationUs= */ Util.msToUs(contentDurationMs), adPlaybackState)); AtomicBoolean hasCreatedAdMediaPeriod = new AtomicBoolean(); FakeMediaSource mediaSource = @@ -3268,7 +3269,7 @@ public final class ExoPlayerTest { assertThat(positionAtDiscontinuityMs.get()).isAtLeast(0L); assertThat(clockAtDiscontinuityMs.get() - clockAtStartMs.get()) - .isAtLeast(C.usToMs(expectedDurationUs)); + .isAtLeast(Util.usToMs(expectedDurationUs)); } @Test @@ -3487,7 +3488,8 @@ public final class ExoPlayerTest { .start() .blockUntilEnded(TIMEOUT_MS); - assertThat(bufferedPositionAtFirstDiscontinuityMs.get()).isEqualTo(C.usToMs(windowDurationUs)); + assertThat(bufferedPositionAtFirstDiscontinuityMs.get()) + .isEqualTo(Util.usToMs(windowDurationUs)); } @Test @@ -4603,7 +4605,7 @@ public final class ExoPlayerTest { ImmutableList.of( oneByteSample(windowOffsetInFirstPeriodUs, C.BUFFER_FLAG_KEY_FRAME), oneByteSample( - windowOffsetInFirstPeriodUs + C.msToUs(maxBufferedPositionMs), + windowOffsetInFirstPeriodUs + Util.msToUs(maxBufferedPositionMs), C.BUFFER_FLAG_KEY_FRAME)), mediaSourceEventDispatcher, drmSessionManager, @@ -4623,7 +4625,7 @@ public final class ExoPlayerTest { adPlaybackState = adPlaybackState.withAdUri(/* adGroupIndex= */ 0, /* adIndexInAdGroup= */ 0, Uri.EMPTY); long[][] durationsUs = new long[1][]; - durationsUs[0] = new long[] {C.msToUs(adDurationMs)}; + durationsUs[0] = new long[] {Util.msToUs(adDurationMs)}; adPlaybackState = adPlaybackState.withAdDurationsUs(durationsUs); Timeline adTimeline = new FakeTimeline( @@ -4632,7 +4634,7 @@ public final class ExoPlayerTest { /* id= */ 0, /* isSeekable= */ true, /* isDynamic= */ false, - /* durationUs= */ C.msToUs(contentDurationMs), + /* durationUs= */ Util.msToUs(contentDurationMs), adPlaybackState)); FakeMediaSource adsMediaSource = new FakeMediaSource(adTimeline); int[] windowIndex = new int[] {C.INDEX_UNSET, C.INDEX_UNSET, C.INDEX_UNSET}; @@ -4724,7 +4726,7 @@ public final class ExoPlayerTest { adPlaybackState = adPlaybackState.withAdUri(/* adGroupIndex= */ 0, /* adIndexInAdGroup= */ 0, Uri.EMPTY); long[][] durationsUs = new long[1][]; - durationsUs[0] = new long[] {C.msToUs(adDurationMs)}; + durationsUs[0] = new long[] {Util.msToUs(adDurationMs)}; adPlaybackState = adPlaybackState.withAdDurationsUs(durationsUs); Timeline adTimeline = new FakeTimeline( @@ -4733,7 +4735,7 @@ public final class ExoPlayerTest { /* id= */ 0, /* isSeekable= */ true, /* isDynamic= */ false, - /* durationUs= */ C.msToUs(contentDurationMs), + /* durationUs= */ Util.msToUs(contentDurationMs), adPlaybackState)); FakeMediaSource adsMediaSource = new FakeMediaSource(adTimeline); int[] windowIndex = new int[] {C.INDEX_UNSET, C.INDEX_UNSET}; @@ -4805,7 +4807,7 @@ public final class ExoPlayerTest { .withAdCount(/* adGroupIndex= */ 0, /* adCount= */ 1) .withAdUri(/* adGroupIndex= */ 0, /* adIndexInAdGroup= */ 0, Uri.EMPTY); long[][] durationsUs = new long[1][]; - durationsUs[0] = new long[] {C.msToUs(adDurationMs)}; + durationsUs[0] = new long[] {Util.msToUs(adDurationMs)}; adPlaybackState = adPlaybackState.withAdDurationsUs(durationsUs); Timeline adTimeline = new FakeTimeline( @@ -4814,7 +4816,7 @@ public final class ExoPlayerTest { /* id= */ 0, /* isSeekable= */ true, /* isDynamic= */ false, - /* durationUs= */ C.msToUs(contentDurationMs), + /* durationUs= */ Util.msToUs(contentDurationMs), adPlaybackState)); FakeMediaSource adsMediaSource = new FakeMediaSource(adTimeline); @@ -5037,7 +5039,7 @@ public final class ExoPlayerTest { /* id= */ 0, /* isSeekable= */ true, /* isDynamic= */ false, - /* durationUs= */ C.msToUs(10000), + /* durationUs= */ Util.msToUs(10000), adPlaybackState)); // Simulate the second ad not being prepared. FakeMediaSource mediaSource = @@ -5078,14 +5080,14 @@ public final class ExoPlayerTest { /* id= */ 1, /* isSeekable= */ true, /* isDynamic= */ false, - /* durationUs= */ C.msToUs(10000)); + /* durationUs= */ Util.msToUs(10000)); TimelineWindowDefinition secondWindowDefinition = new TimelineWindowDefinition( /* periodCount= */ 1, /* id= */ 2, /* isSeekable= */ true, /* isDynamic= */ false, - /* durationUs= */ C.msToUs(10000)); + /* durationUs= */ Util.msToUs(10000)); Timeline timeline1 = new FakeTimeline(firstWindowDefinition); Timeline timeline2 = new FakeTimeline(secondWindowDefinition); MediaSource mediaSource1 = new FakeMediaSource(timeline1); @@ -5128,21 +5130,21 @@ public final class ExoPlayerTest { /* id= */ 1, /* isSeekable= */ true, /* isDynamic= */ false, - /* durationUs= */ C.msToUs(10000)); + /* durationUs= */ Util.msToUs(10000)); TimelineWindowDefinition secondWindowDefinition = new TimelineWindowDefinition( /* periodCount= */ 1, /* id= */ 2, /* isSeekable= */ true, /* isDynamic= */ false, - /* durationUs= */ C.msToUs(10000)); + /* durationUs= */ Util.msToUs(10000)); TimelineWindowDefinition thirdWindowDefinition = new TimelineWindowDefinition( /* periodCount= */ 1, /* id= */ 3, /* isSeekable= */ true, /* isDynamic= */ false, - /* durationUs= */ C.msToUs(10000)); + /* durationUs= */ Util.msToUs(10000)); Timeline timeline1 = new FakeTimeline(firstWindowDefinition); Timeline timeline2 = new FakeTimeline(secondWindowDefinition); Timeline timeline3 = new FakeTimeline(thirdWindowDefinition); @@ -5188,21 +5190,21 @@ public final class ExoPlayerTest { /* id= */ 1, /* isSeekable= */ true, /* isDynamic= */ false, - /* durationUs= */ C.msToUs(10000)); + /* durationUs= */ Util.msToUs(10000)); TimelineWindowDefinition secondWindowDefinition = new TimelineWindowDefinition( /* periodCount= */ 1, /* id= */ 2, /* isSeekable= */ true, /* isDynamic= */ false, - /* durationUs= */ C.msToUs(10000)); + /* durationUs= */ Util.msToUs(10000)); TimelineWindowDefinition thirdWindowDefinition = new TimelineWindowDefinition( /* periodCount= */ 1, /* id= */ 3, /* isSeekable= */ true, /* isDynamic= */ false, - /* durationUs= */ C.msToUs(10000)); + /* durationUs= */ Util.msToUs(10000)); Timeline timeline1 = new FakeTimeline(firstWindowDefinition); Timeline timeline2 = new FakeTimeline(secondWindowDefinition); Timeline timeline3 = new FakeTimeline(thirdWindowDefinition); @@ -8354,7 +8356,7 @@ public final class ExoPlayerTest { new AdPlaybackState(/* adsId= */ new Object(), /* adGroupTimesUs...= */ 0) .withAdCount(/* adGroupIndex= */ 0, /* adCount= */ 1) .withAdUri(/* adGroupIndex= */ 0, /* adIndexInAdGroup= */ 0, Uri.EMPTY) - .withAdDurationsUs(/* adDurationUs= */ new long[][] {{C.msToUs(4_000)}}); + .withAdDurationsUs(/* adDurationUs= */ new long[][] {{Util.msToUs(4_000)}}); Timeline adTimeline = new FakeTimeline( new TimelineWindowDefinition( @@ -8362,7 +8364,7 @@ public final class ExoPlayerTest { /* id= */ 0, /* isSeekable= */ true, /* isDynamic= */ false, - /* durationUs= */ C.msToUs(10_000), + /* durationUs= */ Util.msToUs(10_000), adPlaybackState)); ExoPlayer player = new TestExoPlayerBuilder(context).build(); @@ -8391,7 +8393,7 @@ public final class ExoPlayerTest { new TimelineWindowDefinition( /* isSeekable= */ false, /* isDynamic= */ false, - /* durationUs= */ C.msToUs(10_000))); + /* durationUs= */ Util.msToUs(10_000))); ExoPlayer player = new TestExoPlayerBuilder(context).build(); player.addMediaSource(new FakeMediaSource(timelineWithUnseekableWindow)); @@ -9107,7 +9109,7 @@ public final class ExoPlayerTest { /* isPlaceholder= */ false, /* durationUs= */ 1000 * C.MICROS_PER_SECOND, /* defaultPositionUs= */ 8 * C.MICROS_PER_SECOND, - /* windowOffsetInFirstPeriodUs= */ C.msToUs(windowStartUnixTimeMs), + /* windowOffsetInFirstPeriodUs= */ Util.msToUs(windowStartUnixTimeMs), AdPlaybackState.NONE, new MediaItem.Builder() .setUri(Uri.EMPTY) @@ -9156,7 +9158,7 @@ public final class ExoPlayerTest { /* isPlaceholder= */ false, /* durationUs= */ 1000 * C.MICROS_PER_SECOND, /* defaultPositionUs= */ 8 * C.MICROS_PER_SECOND, - /* windowOffsetInFirstPeriodUs= */ C.msToUs(windowStartUnixTimeMs), + /* windowOffsetInFirstPeriodUs= */ Util.msToUs(windowStartUnixTimeMs), AdPlaybackState.NONE, new MediaItem.Builder() .setUri(Uri.EMPTY) @@ -9201,7 +9203,7 @@ public final class ExoPlayerTest { /* isPlaceholder= */ false, /* durationUs= */ 1000 * C.MICROS_PER_SECOND, /* defaultPositionUs= */ 8 * C.MICROS_PER_SECOND, - /* windowOffsetInFirstPeriodUs= */ C.msToUs(windowStartUnixTimeMs), + /* windowOffsetInFirstPeriodUs= */ Util.msToUs(windowStartUnixTimeMs), AdPlaybackState.NONE, new MediaItem.Builder() .setUri(Uri.EMPTY) @@ -9248,7 +9250,7 @@ public final class ExoPlayerTest { /* isPlaceholder= */ false, /* durationUs= */ 1000 * C.MICROS_PER_SECOND, /* defaultPositionUs= */ 8 * C.MICROS_PER_SECOND, - /* windowOffsetInFirstPeriodUs= */ C.msToUs(windowStartUnixTimeMs), + /* windowOffsetInFirstPeriodUs= */ Util.msToUs(windowStartUnixTimeMs), AdPlaybackState.NONE, new MediaItem.Builder() .setUri(Uri.EMPTY) @@ -9266,7 +9268,7 @@ public final class ExoPlayerTest { /* isPlaceholder= */ false, /* durationUs= */ 1000 * C.MICROS_PER_SECOND, /* defaultPositionUs= */ 8 * C.MICROS_PER_SECOND, - /* windowOffsetInFirstPeriodUs= */ C.msToUs(windowStartUnixTimeMs + 50_000), + /* windowOffsetInFirstPeriodUs= */ Util.msToUs(windowStartUnixTimeMs + 50_000), AdPlaybackState.NONE, new MediaItem.Builder() .setUri(Uri.EMPTY) @@ -9330,7 +9332,7 @@ public final class ExoPlayerTest { /* isPlaceholder= */ false, /* durationUs= */ 1000 * C.MICROS_PER_SECOND, /* defaultPositionUs= */ 20 * C.MICROS_PER_SECOND, - /* windowOffsetInFirstPeriodUs= */ C.msToUs(windowStartUnixTimeMs), + /* windowOffsetInFirstPeriodUs= */ Util.msToUs(windowStartUnixTimeMs), AdPlaybackState.NONE, new MediaItem.Builder() .setUri(Uri.EMPTY) @@ -9383,7 +9385,7 @@ public final class ExoPlayerTest { /* isPlaceholder= */ false, /* durationUs= */ 1000 * C.MICROS_PER_SECOND, /* defaultPositionUs= */ 8 * C.MICROS_PER_SECOND, - /* windowOffsetInFirstPeriodUs= */ C.msToUs(windowStartUnixTimeMs), + /* windowOffsetInFirstPeriodUs= */ Util.msToUs(windowStartUnixTimeMs), AdPlaybackState.NONE, new MediaItem.Builder() .setUri(Uri.EMPTY) @@ -9427,7 +9429,7 @@ public final class ExoPlayerTest { /* isPlaceholder= */ false, /* durationUs= */ 1000 * C.MICROS_PER_SECOND, /* defaultPositionUs= */ 8 * C.MICROS_PER_SECOND, - /* windowOffsetInFirstPeriodUs= */ C.msToUs(windowStartUnixTimeMs), + /* windowOffsetInFirstPeriodUs= */ Util.msToUs(windowStartUnixTimeMs), AdPlaybackState.NONE, new MediaItem.Builder() .setUri(Uri.EMPTY) @@ -9445,7 +9447,7 @@ public final class ExoPlayerTest { /* isPlaceholder= */ false, /* durationUs= */ 1000 * C.MICROS_PER_SECOND, /* defaultPositionUs= */ 8 * C.MICROS_PER_SECOND, - /* windowOffsetInFirstPeriodUs= */ C.msToUs(windowStartUnixTimeMs), + /* windowOffsetInFirstPeriodUs= */ Util.msToUs(windowStartUnixTimeMs), AdPlaybackState.NONE, new MediaItem.Builder() .setUri(Uri.EMPTY) @@ -9493,7 +9495,7 @@ public final class ExoPlayerTest { /* isPlaceholder= */ false, /* durationUs= */ 1000 * C.MICROS_PER_SECOND, /* defaultPositionUs= */ 8 * C.MICROS_PER_SECOND, - /* windowOffsetInFirstPeriodUs= */ C.msToUs(windowStartUnixTimeMs), + /* windowOffsetInFirstPeriodUs= */ Util.msToUs(windowStartUnixTimeMs), AdPlaybackState.NONE, new MediaItem.Builder() .setUri(Uri.EMPTY) @@ -9511,7 +9513,7 @@ public final class ExoPlayerTest { /* isPlaceholder= */ false, /* durationUs= */ 1000 * C.MICROS_PER_SECOND, /* defaultPositionUs= */ 8 * C.MICROS_PER_SECOND, - /* windowOffsetInFirstPeriodUs= */ C.msToUs(windowStartUnixTimeMs), + /* windowOffsetInFirstPeriodUs= */ Util.msToUs(windowStartUnixTimeMs), AdPlaybackState.NONE, new MediaItem.Builder() .setUri(Uri.EMPTY) @@ -9599,7 +9601,7 @@ public final class ExoPlayerTest { /* isPlaceholder= */ false, /* durationUs= */ 1000 * C.MICROS_PER_SECOND, /* defaultPositionUs= */ 8 * C.MICROS_PER_SECOND, - /* windowOffsetInFirstPeriodUs= */ C.msToUs(windowStartUnixTimeMs), + /* windowOffsetInFirstPeriodUs= */ Util.msToUs(windowStartUnixTimeMs), AdPlaybackState.NONE, new MediaItem.Builder().setUri(Uri.EMPTY).build())); player.pause(); @@ -10808,7 +10810,7 @@ public final class ExoPlayerTest { new TimelineWindowDefinition( /* isSeekable= */ true, /* isDynamic= */ true, - /* durationUs= */ C.msToUs(3 * C.DEFAULT_SEEK_BACK_INCREMENT_MS))); + /* durationUs= */ Util.msToUs(3 * C.DEFAULT_SEEK_BACK_INCREMENT_MS))); player.setMediaSource(new FakeMediaSource(fakeTimeline)); player.prepare(); @@ -10855,7 +10857,7 @@ public final class ExoPlayerTest { new TimelineWindowDefinition( /* isSeekable= */ true, /* isDynamic= */ true, - /* durationUs= */ C.msToUs(C.DEFAULT_SEEK_BACK_INCREMENT_MS))); + /* durationUs= */ Util.msToUs(C.DEFAULT_SEEK_BACK_INCREMENT_MS))); player.setMediaSource(new FakeMediaSource(fakeTimeline)); player.prepare(); @@ -10878,7 +10880,7 @@ public final class ExoPlayerTest { new TimelineWindowDefinition( /* isSeekable= */ true, /* isDynamic= */ true, - /* durationUs= */ C.msToUs(2 * C.DEFAULT_SEEK_FORWARD_INCREMENT_MS))); + /* durationUs= */ Util.msToUs(2 * C.DEFAULT_SEEK_FORWARD_INCREMENT_MS))); player.setMediaSource(new FakeMediaSource(fakeTimeline)); player.prepare(); @@ -10915,7 +10917,7 @@ public final class ExoPlayerTest { new TimelineWindowDefinition( /* isSeekable= */ true, /* isDynamic= */ true, - /* durationUs= */ C.msToUs(C.DEFAULT_SEEK_FORWARD_INCREMENT_MS / 2))); + /* durationUs= */ Util.msToUs(C.DEFAULT_SEEK_FORWARD_INCREMENT_MS / 2))); player.setMediaSource(new FakeMediaSource(fakeTimeline)); player.prepare(); diff --git a/library/dash/src/main/java/com/google/android/exoplayer2/source/dash/DashMediaSource.java b/library/dash/src/main/java/com/google/android/exoplayer2/source/dash/DashMediaSource.java index af0ee0ef22..327cbb308f 100644 --- a/library/dash/src/main/java/com/google/android/exoplayer2/source/dash/DashMediaSource.java +++ b/library/dash/src/main/java/com/google/android/exoplayer2/source/dash/DashMediaSource.java @@ -907,7 +907,7 @@ public final class DashMediaSource extends BaseMediaSource { int lastPeriodIndex = manifest.getPeriodCount() - 1; Period lastPeriod = manifest.getPeriod(lastPeriodIndex); long lastPeriodDurationUs = manifest.getPeriodDurationUs(lastPeriodIndex); - long nowUnixTimeUs = C.msToUs(Util.getNowUnixTimeMs(elapsedRealtimeOffsetMs)); + long nowUnixTimeUs = Util.msToUs(Util.getNowUnixTimeMs(elapsedRealtimeOffsetMs)); long windowStartTimeInManifestUs = getAvailableStartTimeInManifestUs( firstPeriod, manifest.getPeriodDurationUs(0), nowUnixTimeUs); @@ -917,7 +917,7 @@ public final class DashMediaSource extends BaseMediaSource { if (windowChangingImplicitly && manifest.timeShiftBufferDepthMs != C.TIME_UNSET) { // Update the available start time to reflect the manifest's time shift buffer depth. long timeShiftBufferStartTimeInManifestUs = - windowEndTimeInManifestUs - C.msToUs(manifest.timeShiftBufferDepthMs); + windowEndTimeInManifestUs - Util.msToUs(manifest.timeShiftBufferDepthMs); windowStartTimeInManifestUs = max(windowStartTimeInManifestUs, timeShiftBufferStartTimeInManifestUs); } @@ -927,11 +927,13 @@ public final class DashMediaSource extends BaseMediaSource { if (manifest.dynamic) { checkState(manifest.availabilityStartTimeMs != C.TIME_UNSET); long nowInWindowUs = - nowUnixTimeUs - C.msToUs(manifest.availabilityStartTimeMs) - windowStartTimeInManifestUs; + nowUnixTimeUs + - Util.msToUs(manifest.availabilityStartTimeMs) + - windowStartTimeInManifestUs; updateMediaItemLiveConfiguration(nowInWindowUs, windowDurationUs); windowStartUnixTimeMs = - manifest.availabilityStartTimeMs + C.usToMs(windowStartTimeInManifestUs); - windowDefaultPositionUs = nowInWindowUs - C.msToUs(liveConfiguration.targetOffsetMs); + manifest.availabilityStartTimeMs + Util.usToMs(windowStartTimeInManifestUs); + windowDefaultPositionUs = nowInWindowUs - Util.msToUs(liveConfiguration.targetOffsetMs); long minimumWindowDefaultPositionUs = min(MIN_LIVE_DEFAULT_START_POSITION_US, windowDurationUs / 2); if (windowDefaultPositionUs < minimumWindowDefaultPositionUs) { @@ -941,7 +943,7 @@ public final class DashMediaSource extends BaseMediaSource { windowDefaultPositionUs = minimumWindowDefaultPositionUs; } } - long offsetInFirstPeriodUs = windowStartTimeInManifestUs - C.msToUs(firstPeriod.startMs); + long offsetInFirstPeriodUs = windowStartTimeInManifestUs - Util.msToUs(firstPeriod.startMs); DashTimeline timeline = new DashTimeline( manifest.availabilityStartTimeMs, @@ -995,7 +997,7 @@ public final class DashMediaSource extends BaseMediaSource { && manifest.serviceDescription.maxOffsetMs != C.TIME_UNSET) { maxLiveOffsetMs = manifest.serviceDescription.maxOffsetMs; } else { - maxLiveOffsetMs = C.usToMs(nowInWindowUs); + maxLiveOffsetMs = Util.usToMs(nowInWindowUs); } long minLiveOffsetMs; if (mediaItem.liveConfiguration.minOffsetMs != C.TIME_UNSET) { @@ -1004,7 +1006,7 @@ public final class DashMediaSource extends BaseMediaSource { && manifest.serviceDescription.minOffsetMs != C.TIME_UNSET) { minLiveOffsetMs = manifest.serviceDescription.minOffsetMs; } else { - minLiveOffsetMs = C.usToMs(nowInWindowUs - windowDurationUs); + minLiveOffsetMs = Util.usToMs(nowInWindowUs - windowDurationUs); if (minLiveOffsetMs < 0 && maxLiveOffsetMs > 0) { // The current time is in the window, so assume all clocks are synchronized and set the // minimum to a live offset of zero. @@ -1033,7 +1035,7 @@ public final class DashMediaSource extends BaseMediaSource { long safeDistanceFromWindowStartUs = min(MIN_LIVE_DEFAULT_START_POSITION_US, windowDurationUs / 2); long maxTargetOffsetForSafeDistanceToWindowStartMs = - C.usToMs(nowInWindowUs - safeDistanceFromWindowStartUs); + Util.usToMs(nowInWindowUs - safeDistanceFromWindowStartUs); targetOffsetMs = Util.constrainValue( maxTargetOffsetForSafeDistanceToWindowStartMs, minLiveOffsetMs, maxLiveOffsetMs); @@ -1097,11 +1099,11 @@ public final class DashMediaSource extends BaseMediaSource { DashManifest manifest, long nowUnixTimeMs) { int periodIndex = manifest.getPeriodCount() - 1; Period period = manifest.getPeriod(periodIndex); - long periodStartUs = C.msToUs(period.startMs); + long periodStartUs = Util.msToUs(period.startMs); long periodDurationUs = manifest.getPeriodDurationUs(periodIndex); - long nowUnixTimeUs = C.msToUs(nowUnixTimeMs); - long availabilityStartTimeUs = C.msToUs(manifest.availabilityStartTimeMs); - long intervalUs = C.msToUs(DEFAULT_NOTIFY_MANIFEST_INTERVAL_MS); + long nowUnixTimeUs = Util.msToUs(nowUnixTimeMs); + long availabilityStartTimeUs = Util.msToUs(manifest.availabilityStartTimeMs); + long intervalUs = Util.msToUs(DEFAULT_NOTIFY_MANIFEST_INTERVAL_MS); for (int i = 0; i < period.adaptationSets.size(); i++) { List representations = period.adaptationSets.get(i).representations; if (representations.isEmpty()) { @@ -1127,7 +1129,7 @@ public final class DashMediaSource extends BaseMediaSource { private static long getAvailableStartTimeInManifestUs( Period period, long periodDurationUs, long nowUnixTimeUs) { - long periodStartTimeInManifestUs = C.msToUs(period.startMs); + long periodStartTimeInManifestUs = Util.msToUs(period.startMs); long availableStartTimeInManifestUs = periodStartTimeInManifestUs; boolean haveAudioVideoAdaptationSets = hasVideoOrAudioAdaptationSets(period); for (int i = 0; i < period.adaptationSets.size(); i++) { @@ -1159,7 +1161,7 @@ public final class DashMediaSource extends BaseMediaSource { private static long getAvailableEndTimeInManifestUs( Period period, long periodDurationUs, long nowUnixTimeUs) { - long periodStartTimeInManifestUs = C.msToUs(period.startMs); + long periodStartTimeInManifestUs = Util.msToUs(period.startMs); long availableEndTimeInManifestUs = Long.MAX_VALUE; boolean haveAudioVideoAdaptationSets = hasVideoOrAudioAdaptationSets(period); for (int i = 0; i < period.adaptationSets.size(); i++) { @@ -1266,7 +1268,7 @@ public final class DashMediaSource extends BaseMediaSource { uid, 0, manifest.getPeriodDurationUs(periodIndex), - C.msToUs(manifest.getPeriod(periodIndex).startMs - manifest.getPeriod(0).startMs) + Util.msToUs(manifest.getPeriod(periodIndex).startMs - manifest.getPeriod(0).startMs) - offsetInFirstPeriodUs); } diff --git a/library/dash/src/main/java/com/google/android/exoplayer2/source/dash/DefaultDashChunkSource.java b/library/dash/src/main/java/com/google/android/exoplayer2/source/dash/DefaultDashChunkSource.java index 234c0f4dfd..3d850161df 100644 --- a/library/dash/src/main/java/com/google/android/exoplayer2/source/dash/DefaultDashChunkSource.java +++ b/library/dash/src/main/java/com/google/android/exoplayer2/source/dash/DefaultDashChunkSource.java @@ -305,8 +305,8 @@ public class DefaultDashChunkSource implements DashChunkSource { long bufferedDurationUs = loadPositionUs - playbackPositionUs; long presentationPositionUs = - C.msToUs(manifest.availabilityStartTimeMs) - + C.msToUs(manifest.getPeriod(periodIndex).startMs) + Util.msToUs(manifest.availabilityStartTimeMs) + + Util.msToUs(manifest.getPeriod(periodIndex).startMs) + loadPositionUs; if (playerTrackEmsgHandler != null @@ -315,7 +315,7 @@ public class DefaultDashChunkSource implements DashChunkSource { return; } - long nowUnixTimeUs = C.msToUs(Util.getNowUnixTimeMs(elapsedRealtimeOffsetMs)); + long nowUnixTimeUs = Util.msToUs(Util.getNowUnixTimeMs(elapsedRealtimeOffsetMs)); long nowPeriodTimeUs = getNowPeriodTimeUs(nowUnixTimeUs); MediaChunk previous = queue.isEmpty() ? null : queue.get(queue.size() - 1); MediaChunkIterator[] chunkIterators = new MediaChunkIterator[trackSelection.length()]; @@ -600,7 +600,8 @@ public class DefaultDashChunkSource implements DashChunkSource { return manifest.availabilityStartTimeMs == C.TIME_UNSET ? C.TIME_UNSET : nowUnixTimeUs - - C.msToUs(manifest.availabilityStartTimeMs + manifest.getPeriod(periodIndex).startMs); + - Util.msToUs( + manifest.availabilityStartTimeMs + manifest.getPeriod(periodIndex).startMs); } protected Chunk newInitializationChunk( diff --git a/library/dash/src/main/java/com/google/android/exoplayer2/source/dash/manifest/DashManifest.java b/library/dash/src/main/java/com/google/android/exoplayer2/source/dash/manifest/DashManifest.java index c0d8a36e9d..6bdbb0d6b0 100644 --- a/library/dash/src/main/java/com/google/android/exoplayer2/source/dash/manifest/DashManifest.java +++ b/library/dash/src/main/java/com/google/android/exoplayer2/source/dash/manifest/DashManifest.java @@ -20,6 +20,7 @@ import androidx.annotation.Nullable; import com.google.android.exoplayer2.C; import com.google.android.exoplayer2.offline.FilterableManifest; import com.google.android.exoplayer2.offline.StreamKey; +import com.google.android.exoplayer2.util.Util; import java.util.ArrayList; import java.util.Collections; import java.util.LinkedList; @@ -132,7 +133,7 @@ public class DashManifest implements FilterableManifest { } public final long getPeriodDurationUs(int index) { - return C.msToUs(getPeriodDurationMs(index)); + return Util.msToUs(getPeriodDurationMs(index)); } @Override diff --git a/library/dash/src/main/java/com/google/android/exoplayer2/source/dash/manifest/DashManifestParser.java b/library/dash/src/main/java/com/google/android/exoplayer2/source/dash/manifest/DashManifestParser.java index 91bf3b2eca..d997187a9d 100644 --- a/library/dash/src/main/java/com/google/android/exoplayer2/source/dash/manifest/DashManifestParser.java +++ b/library/dash/src/main/java/com/google/android/exoplayer2/source/dash/manifest/DashManifestParser.java @@ -967,8 +967,8 @@ public class DashManifestParser extends DefaultHandler timeline, availabilityTimeOffsetUs, segments, - C.msToUs(timeShiftBufferDepthMs), - C.msToUs(periodStartUnixTimeMs)); + Util.msToUs(timeShiftBufferDepthMs), + Util.msToUs(periodStartUnixTimeMs)); } protected SegmentTemplate parseSegmentTemplate( @@ -1057,8 +1057,8 @@ public class DashManifestParser extends DefaultHandler availabilityTimeOffsetUs, initializationTemplate, mediaTemplate, - C.msToUs(timeShiftBufferDepthMs), - C.msToUs(periodStartUnixTimeMs)); + Util.msToUs(timeShiftBufferDepthMs), + Util.msToUs(periodStartUnixTimeMs)); } /** diff --git a/library/dash/src/main/java/com/google/android/exoplayer2/source/dash/offline/DashDownloader.java b/library/dash/src/main/java/com/google/android/exoplayer2/source/dash/offline/DashDownloader.java index 5bc557761d..f397b5c2be 100644 --- a/library/dash/src/main/java/com/google/android/exoplayer2/source/dash/offline/DashDownloader.java +++ b/library/dash/src/main/java/com/google/android/exoplayer2/source/dash/offline/DashDownloader.java @@ -18,7 +18,6 @@ package com.google.android.exoplayer2.source.dash.offline; import static com.google.android.exoplayer2.util.Util.castNonNull; import androidx.annotation.Nullable; -import com.google.android.exoplayer2.C; import com.google.android.exoplayer2.MediaItem; import com.google.android.exoplayer2.extractor.ChunkIndex; import com.google.android.exoplayer2.offline.DownloadException; @@ -38,6 +37,7 @@ import com.google.android.exoplayer2.upstream.DataSpec; import com.google.android.exoplayer2.upstream.ParsingLoadable.Parser; import com.google.android.exoplayer2.upstream.cache.CacheDataSource; import com.google.android.exoplayer2.util.RunnableFutureTask; +import com.google.android.exoplayer2.util.Util; import java.io.IOException; import java.util.ArrayList; import java.util.List; @@ -128,7 +128,7 @@ public final class DashDownloader extends SegmentDownloader { ArrayList segments = new ArrayList<>(); for (int i = 0; i < manifest.getPeriodCount(); i++) { Period period = manifest.getPeriod(i); - long periodStartUs = C.msToUs(period.startMs); + long periodStartUs = Util.msToUs(period.startMs); long periodDurationUs = manifest.getPeriodDurationUs(i); List adaptationSets = period.adaptationSets; for (int j = 0; j < adaptationSets.size(); j++) { diff --git a/library/dash/src/test/java/com/google/android/exoplayer2/source/dash/DefaultDashChunkSourceTest.java b/library/dash/src/test/java/com/google/android/exoplayer2/source/dash/DefaultDashChunkSourceTest.java index 88e8b3f84c..7343c07bff 100644 --- a/library/dash/src/test/java/com/google/android/exoplayer2/source/dash/DefaultDashChunkSourceTest.java +++ b/library/dash/src/test/java/com/google/android/exoplayer2/source/dash/DefaultDashChunkSourceTest.java @@ -45,6 +45,7 @@ import com.google.android.exoplayer2.upstream.HttpDataSource; import com.google.android.exoplayer2.upstream.LoadErrorHandlingPolicy; import com.google.android.exoplayer2.upstream.LoaderErrorThrower; import com.google.android.exoplayer2.util.Assertions; +import com.google.android.exoplayer2.util.Util; import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableMap; import com.google.common.collect.Lists; @@ -96,7 +97,7 @@ public class DefaultDashChunkSourceTest { /* closedCaptionFormats */ ImmutableList.of(), /* playerTrackEmsgHandler= */ null); - long nowInPeriodUs = C.msToUs(nowMs - manifest.availabilityStartTimeMs); + long nowInPeriodUs = Util.msToUs(nowMs - manifest.availabilityStartTimeMs); ChunkHolder output = new ChunkHolder(); chunkSource.getNextChunk( diff --git a/library/extractor/src/main/java/com/google/android/exoplayer2/extractor/mp3/MlltSeeker.java b/library/extractor/src/main/java/com/google/android/exoplayer2/extractor/mp3/MlltSeeker.java index f30b830249..2204cfccd7 100644 --- a/library/extractor/src/main/java/com/google/android/exoplayer2/extractor/mp3/MlltSeeker.java +++ b/library/extractor/src/main/java/com/google/android/exoplayer2/extractor/mp3/MlltSeeker.java @@ -62,7 +62,7 @@ import com.google.android.exoplayer2.util.Util; this.durationUs = durationUs != C.TIME_UNSET ? durationUs - : C.msToUs(referenceTimesMs[referenceTimesMs.length - 1]); + : Util.msToUs(referenceTimesMs[referenceTimesMs.length - 1]); } @Override @@ -74,8 +74,8 @@ import com.google.android.exoplayer2.util.Util; public SeekPoints getSeekPoints(long timeUs) { timeUs = Util.constrainValue(timeUs, 0, durationUs); Pair timeMsAndPosition = - linearlyInterpolate(C.usToMs(timeUs), referenceTimesMs, referencePositions); - timeUs = C.msToUs(timeMsAndPosition.first); + linearlyInterpolate(Util.usToMs(timeUs), referenceTimesMs, referencePositions); + timeUs = Util.msToUs(timeMsAndPosition.first); long position = timeMsAndPosition.second; return new SeekPoints(new SeekPoint(timeUs, position)); } @@ -84,7 +84,7 @@ import com.google.android.exoplayer2.util.Util; public long getTimeUs(long position) { Pair positionAndTimeMs = linearlyInterpolate(position, referencePositions, referenceTimesMs); - return C.msToUs(positionAndTimeMs.second); + return Util.msToUs(positionAndTimeMs.second); } @Override diff --git a/library/extractor/src/main/java/com/google/android/exoplayer2/extractor/mp3/Mp3Extractor.java b/library/extractor/src/main/java/com/google/android/exoplayer2/extractor/mp3/Mp3Extractor.java index 4e22637144..d70b6c2f90 100644 --- a/library/extractor/src/main/java/com/google/android/exoplayer2/extractor/mp3/Mp3Extractor.java +++ b/library/extractor/src/main/java/com/google/android/exoplayer2/extractor/mp3/Mp3Extractor.java @@ -586,7 +586,7 @@ public final class Mp3Extractor implements Extractor { Metadata.Entry entry = metadata.get(i); if (entry instanceof TextInformationFrame && ((TextInformationFrame) entry).id.equals("TLEN")) { - return C.msToUs(Long.parseLong(((TextInformationFrame) entry).value)); + return Util.msToUs(Long.parseLong(((TextInformationFrame) entry).value)); } } } diff --git a/library/hls/src/main/java/com/google/android/exoplayer2/source/hls/HlsMediaSource.java b/library/hls/src/main/java/com/google/android/exoplayer2/source/hls/HlsMediaSource.java index 45c16bb8c9..56ebfb5762 100644 --- a/library/hls/src/main/java/com/google/android/exoplayer2/source/hls/HlsMediaSource.java +++ b/library/hls/src/main/java/com/google/android/exoplayer2/source/hls/HlsMediaSource.java @@ -508,7 +508,7 @@ public final class HlsMediaSource extends BaseMediaSource @Override public void onPrimaryPlaylistRefreshed(HlsMediaPlaylist mediaPlaylist) { long windowStartTimeMs = - mediaPlaylist.hasProgramDateTime ? C.usToMs(mediaPlaylist.startTimeUs) : C.TIME_UNSET; + mediaPlaylist.hasProgramDateTime ? Util.usToMs(mediaPlaylist.startTimeUs) : C.TIME_UNSET; // For playlist types EVENT and VOD we know segments are never removed, so the presentation // started at the same time as the window. Otherwise, we don't know the presentation start time. long presentationStartTimeMs = @@ -541,7 +541,7 @@ public final class HlsMediaSource extends BaseMediaSource long targetLiveOffsetUs; if (liveConfiguration.targetOffsetMs != C.TIME_UNSET) { // Media item has a defined target offset. - targetLiveOffsetUs = C.msToUs(liveConfiguration.targetOffsetMs); + targetLiveOffsetUs = Util.msToUs(liveConfiguration.targetOffsetMs); } else { // Decide target offset from playlist. targetLiveOffsetUs = getTargetLiveOffsetUs(playlist, liveEdgeOffsetUs); @@ -607,7 +607,7 @@ public final class HlsMediaSource extends BaseMediaSource private long getLiveEdgeOffsetUs(HlsMediaPlaylist playlist) { return playlist.hasProgramDateTime - ? C.msToUs(Util.getNowUnixTimeMs(elapsedRealTimeOffsetMs)) - playlist.getEndTimeUs() + ? Util.msToUs(Util.getNowUnixTimeMs(elapsedRealTimeOffsetMs)) - playlist.getEndTimeUs() : 0; } @@ -616,7 +616,9 @@ public final class HlsMediaSource extends BaseMediaSource long startPositionUs = playlist.startOffsetUs != C.TIME_UNSET ? playlist.startOffsetUs - : playlist.durationUs + liveEdgeOffsetUs - C.msToUs(liveConfiguration.targetOffsetMs); + : playlist.durationUs + + liveEdgeOffsetUs + - Util.msToUs(liveConfiguration.targetOffsetMs); if (playlist.preciseStart) { return startPositionUs; } @@ -639,7 +641,7 @@ public final class HlsMediaSource extends BaseMediaSource } private void maybeUpdateLiveConfiguration(long targetLiveOffsetUs) { - long targetLiveOffsetMs = C.usToMs(targetLiveOffsetUs); + long targetLiveOffsetMs = Util.usToMs(targetLiveOffsetUs); if (targetLiveOffsetMs != liveConfiguration.targetOffsetMs) { liveConfiguration = liveConfiguration.buildUpon().setTargetOffsetMs(targetLiveOffsetMs).build(); diff --git a/library/hls/src/main/java/com/google/android/exoplayer2/source/hls/HlsSampleStreamWrapper.java b/library/hls/src/main/java/com/google/android/exoplayer2/source/hls/HlsSampleStreamWrapper.java index ca72c5516d..da4fbad97d 100644 --- a/library/hls/src/main/java/com/google/android/exoplayer2/source/hls/HlsSampleStreamWrapper.java +++ b/library/hls/src/main/java/com/google/android/exoplayer2/source/hls/HlsSampleStreamWrapper.java @@ -916,8 +916,8 @@ import org.checkerframework.checker.nullness.qual.RequiresNonNull; loadable.trackFormat, loadable.trackSelectionReason, loadable.trackSelectionData, - C.usToMs(loadable.startTimeUs), - C.usToMs(loadable.endTimeUs)); + Util.usToMs(loadable.startTimeUs), + Util.usToMs(loadable.endTimeUs)); LoadErrorInfo loadErrorInfo = new LoadErrorInfo(loadEventInfo, mediaLoadData, error, errorCount); LoadErrorAction loadErrorAction; diff --git a/library/hls/src/main/java/com/google/android/exoplayer2/source/hls/UnexpectedSampleTimestampException.java b/library/hls/src/main/java/com/google/android/exoplayer2/source/hls/UnexpectedSampleTimestampException.java index 50a11170a3..331af0fa7d 100644 --- a/library/hls/src/main/java/com/google/android/exoplayer2/source/hls/UnexpectedSampleTimestampException.java +++ b/library/hls/src/main/java/com/google/android/exoplayer2/source/hls/UnexpectedSampleTimestampException.java @@ -18,6 +18,7 @@ package com.google.android.exoplayer2.source.hls; import com.google.android.exoplayer2.C; import com.google.android.exoplayer2.source.SampleQueue; import com.google.android.exoplayer2.source.chunk.MediaChunk; +import com.google.android.exoplayer2.util.Util; import java.io.IOException; /** @@ -52,7 +53,7 @@ import java.io.IOException; MediaChunk mediaChunk, long lastAcceptedSampleTimeUs, long rejectedSampleTimeUs) { super( "Unexpected sample timestamp: " - + C.usToMs(rejectedSampleTimeUs) + + Util.usToMs(rejectedSampleTimeUs) + " in chunk [" + mediaChunk.startTimeUs + ", " diff --git a/library/hls/src/main/java/com/google/android/exoplayer2/source/hls/playlist/DefaultHlsPlaylistTracker.java b/library/hls/src/main/java/com/google/android/exoplayer2/source/hls/playlist/DefaultHlsPlaylistTracker.java index 0558105100..68d300966e 100644 --- a/library/hls/src/main/java/com/google/android/exoplayer2/source/hls/playlist/DefaultHlsPlaylistTracker.java +++ b/library/hls/src/main/java/com/google/android/exoplayer2/source/hls/playlist/DefaultHlsPlaylistTracker.java @@ -536,7 +536,7 @@ public final class DefaultHlsPlaylistTracker return false; } long currentTimeMs = SystemClock.elapsedRealtime(); - long snapshotValidityDurationMs = max(30000, C.usToMs(playlistSnapshot.durationUs)); + long snapshotValidityDurationMs = max(30000, Util.usToMs(playlistSnapshot.durationUs)); return playlistSnapshot.hasEndTag || playlistSnapshot.playlistType == HlsMediaPlaylist.PLAYLIST_TYPE_EVENT || playlistSnapshot.playlistType == HlsMediaPlaylist.PLAYLIST_TYPE_VOD @@ -726,7 +726,7 @@ public final class DefaultHlsPlaylistTracker forceRetry = true; playlistError = new PlaylistResetException(playlistUrl); } else if (currentTimeMs - lastSnapshotChangeMs - > C.usToMs(playlistSnapshot.targetDurationUs) + > Util.usToMs(playlistSnapshot.targetDurationUs) * playlistStuckTargetDurationCoefficient) { // TODO: Allow customization of stuck playlists handling. playlistError = new PlaylistStuckException(playlistUrl); @@ -752,7 +752,7 @@ public final class DefaultHlsPlaylistTracker ? playlistSnapshot.targetDurationUs : (playlistSnapshot.targetDurationUs / 2); } - earliestNextLoadTimeMs = currentTimeMs + C.usToMs(durationUntilNextLoadUs); + earliestNextLoadTimeMs = currentTimeMs + Util.usToMs(durationUntilNextLoadUs); // Schedule a load if this is the primary playlist or a playlist of a low-latency stream and // it doesn't have an end tag. Else the next load will be scheduled when refreshPlaylist is // called, or when this playlist becomes the primary. diff --git a/library/hls/src/main/java/com/google/android/exoplayer2/source/hls/playlist/HlsPlaylistParser.java b/library/hls/src/main/java/com/google/android/exoplayer2/source/hls/playlist/HlsPlaylistParser.java index ac8bf1e5a8..250ee72754 100644 --- a/library/hls/src/main/java/com/google/android/exoplayer2/source/hls/playlist/HlsPlaylistParser.java +++ b/library/hls/src/main/java/com/google/android/exoplayer2/source/hls/playlist/HlsPlaylistParser.java @@ -844,7 +844,7 @@ public final class HlsPlaylistParser implements ParsingLoadable.Parser { - timelineDurationUs = C.msToUs(timing.getDurationMs()); + timelineDurationUs = Util.msToUs(timing.getDurationMs()); timelineIsSeekable = !timing.isLive(); timelineIsLive = timing.isLive(); timelineIsPlaceholder = false; diff --git a/library/smoothstreaming/src/main/java/com/google/android/exoplayer2/source/smoothstreaming/SsMediaSource.java b/library/smoothstreaming/src/main/java/com/google/android/exoplayer2/source/smoothstreaming/SsMediaSource.java index aabe71ce73..fd2f3a49fe 100644 --- a/library/smoothstreaming/src/main/java/com/google/android/exoplayer2/source/smoothstreaming/SsMediaSource.java +++ b/library/smoothstreaming/src/main/java/com/google/android/exoplayer2/source/smoothstreaming/SsMediaSource.java @@ -604,7 +604,7 @@ public final class SsMediaSource extends BaseMediaSource startTimeUs = max(startTimeUs, endTimeUs - manifest.dvrWindowLengthUs); } long durationUs = endTimeUs - startTimeUs; - long defaultStartPositionUs = durationUs - C.msToUs(livePresentationDelayMs); + long defaultStartPositionUs = durationUs - Util.msToUs(livePresentationDelayMs); if (defaultStartPositionUs < MIN_LIVE_DEFAULT_START_POSITION_US) { // The default start position is too close to the start of the live window. Set it to the // minimum default start position provided the window is at least twice as big. Else set diff --git a/library/transformer/src/main/java/com/google/android/exoplayer2/transformer/MuxerWrapper.java b/library/transformer/src/main/java/com/google/android/exoplayer2/transformer/MuxerWrapper.java index e8a217f645..76e74efa95 100644 --- a/library/transformer/src/main/java/com/google/android/exoplayer2/transformer/MuxerWrapper.java +++ b/library/transformer/src/main/java/com/google/android/exoplayer2/transformer/MuxerWrapper.java @@ -26,6 +26,7 @@ import androidx.annotation.RequiresApi; import com.google.android.exoplayer2.C; import com.google.android.exoplayer2.Format; import com.google.android.exoplayer2.util.MimeTypes; +import com.google.android.exoplayer2.util.Util; import java.nio.ByteBuffer; /** @@ -42,7 +43,7 @@ import java.nio.ByteBuffer; *

The value of this constant has been chosen based on the interleaving observed in a few media * files, where continuous chunks of the same track were about 0.5 seconds long. */ - private static final long MAX_TRACK_WRITE_AHEAD_US = C.msToUs(500); + private static final long MAX_TRACK_WRITE_AHEAD_US = Util.msToUs(500); private final Muxer muxer; private final Muxer.Factory muxerFactory; diff --git a/library/transformer/src/main/java/com/google/android/exoplayer2/transformer/SefSlowMotionVideoSampleTransformer.java b/library/transformer/src/main/java/com/google/android/exoplayer2/transformer/SefSlowMotionVideoSampleTransformer.java index a232d82a52..db90f38094 100644 --- a/library/transformer/src/main/java/com/google/android/exoplayer2/transformer/SefSlowMotionVideoSampleTransformer.java +++ b/library/transformer/src/main/java/com/google/android/exoplayer2/transformer/SefSlowMotionVideoSampleTransformer.java @@ -31,6 +31,7 @@ import com.google.android.exoplayer2.metadata.Metadata; import com.google.android.exoplayer2.metadata.mp4.SlowMotionData; import com.google.android.exoplayer2.metadata.mp4.SmtaMetadataEntry; import com.google.android.exoplayer2.util.MimeTypes; +import com.google.android.exoplayer2.util.Util; import com.google.common.collect.ImmutableList; import java.nio.ByteBuffer; import java.util.Arrays; @@ -366,8 +367,8 @@ import org.checkerframework.checker.nullness.qual.RequiresNonNull; public final int maxLayer; public SegmentInfo(SlowMotionData.Segment segment, int inputMaxLayer, int normalSpeedLayer) { - this.startTimeUs = C.msToUs(segment.startTimeMs); - this.endTimeUs = C.msToUs(segment.endTimeMs); + this.startTimeUs = Util.msToUs(segment.startTimeMs); + this.endTimeUs = Util.msToUs(segment.endTimeMs); this.speedDivisor = segment.speedDivisor; this.maxLayer = getSlowMotionMaxLayer(speedDivisor, inputMaxLayer, normalSpeedLayer); } diff --git a/library/transformer/src/main/java/com/google/android/exoplayer2/transformer/SegmentSpeedProvider.java b/library/transformer/src/main/java/com/google/android/exoplayer2/transformer/SegmentSpeedProvider.java index 2320367076..91a6d49da6 100644 --- a/library/transformer/src/main/java/com/google/android/exoplayer2/transformer/SegmentSpeedProvider.java +++ b/library/transformer/src/main/java/com/google/android/exoplayer2/transformer/SegmentSpeedProvider.java @@ -25,6 +25,7 @@ import com.google.android.exoplayer2.metadata.Metadata; import com.google.android.exoplayer2.metadata.mp4.SlowMotionData; import com.google.android.exoplayer2.metadata.mp4.SlowMotionData.Segment; import com.google.android.exoplayer2.metadata.mp4.SmtaMetadataEntry; +import com.google.android.exoplayer2.util.Util; import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableSortedMap; import java.util.ArrayList; @@ -72,7 +73,7 @@ import java.util.TreeMap; for (int i = 0; i < segments.size(); i++) { Segment currentSegment = segments.get(i); speedsByStartTimeUs.put( - C.msToUs(currentSegment.startTimeMs), baseSpeed / currentSegment.speedDivisor); + Util.msToUs(currentSegment.startTimeMs), baseSpeed / currentSegment.speedDivisor); } // If the map has an entry at endTime, this is the next segments start time. If no such entry @@ -80,8 +81,8 @@ import java.util.TreeMap; // segment. for (int i = 0; i < segments.size(); i++) { Segment currentSegment = segments.get(i); - if (!speedsByStartTimeUs.containsKey(C.msToUs(currentSegment.endTimeMs))) { - speedsByStartTimeUs.put(C.msToUs(currentSegment.endTimeMs), baseSpeed); + if (!speedsByStartTimeUs.containsKey(Util.msToUs(currentSegment.endTimeMs))) { + speedsByStartTimeUs.put(Util.msToUs(currentSegment.endTimeMs), baseSpeed); } } diff --git a/library/ui/src/main/java/com/google/android/exoplayer2/ui/PlayerControlView.java b/library/ui/src/main/java/com/google/android/exoplayer2/ui/PlayerControlView.java index 824b44e1f3..6adfe54b4f 100644 --- a/library/ui/src/main/java/com/google/android/exoplayer2/ui/PlayerControlView.java +++ b/library/ui/src/main/java/com/google/android/exoplayer2/ui/PlayerControlView.java @@ -955,7 +955,7 @@ public class PlayerControlView extends FrameLayout { int lastWindowIndex = multiWindowTimeBar ? timeline.getWindowCount() - 1 : currentWindowIndex; for (int i = firstWindowIndex; i <= lastWindowIndex; i++) { if (i == currentWindowIndex) { - currentWindowOffset = C.usToMs(durationUs); + currentWindowOffset = Util.usToMs(durationUs); } timeline.getWindow(i, window); if (window.durationUs == C.TIME_UNSET) { @@ -982,7 +982,7 @@ public class PlayerControlView extends FrameLayout { adGroupTimesMs = Arrays.copyOf(adGroupTimesMs, newLength); playedAdGroups = Arrays.copyOf(playedAdGroups, newLength); } - adGroupTimesMs[adGroupCount] = C.usToMs(durationUs + adGroupTimeInWindowUs); + adGroupTimesMs[adGroupCount] = Util.usToMs(durationUs + adGroupTimeInWindowUs); playedAdGroups[adGroupCount] = period.hasPlayedAdGroup(adGroupIndex); adGroupCount++; } @@ -991,7 +991,7 @@ public class PlayerControlView extends FrameLayout { durationUs += window.durationUs; } } - long durationMs = C.usToMs(durationUs); + long durationMs = Util.usToMs(durationUs); if (durationView != null) { durationView.setText(Util.getStringForTime(formatBuilder, formatter, durationMs)); } diff --git a/library/ui/src/main/java/com/google/android/exoplayer2/ui/StyledPlayerControlView.java b/library/ui/src/main/java/com/google/android/exoplayer2/ui/StyledPlayerControlView.java index 30ca26f4f9..279e907476 100644 --- a/library/ui/src/main/java/com/google/android/exoplayer2/ui/StyledPlayerControlView.java +++ b/library/ui/src/main/java/com/google/android/exoplayer2/ui/StyledPlayerControlView.java @@ -1274,7 +1274,7 @@ public class StyledPlayerControlView extends FrameLayout { int lastWindowIndex = multiWindowTimeBar ? timeline.getWindowCount() - 1 : currentWindowIndex; for (int i = firstWindowIndex; i <= lastWindowIndex; i++) { if (i == currentWindowIndex) { - currentWindowOffset = C.usToMs(durationUs); + currentWindowOffset = Util.usToMs(durationUs); } timeline.getWindow(i, window); if (window.durationUs == C.TIME_UNSET) { @@ -1301,7 +1301,7 @@ public class StyledPlayerControlView extends FrameLayout { adGroupTimesMs = Arrays.copyOf(adGroupTimesMs, newLength); playedAdGroups = Arrays.copyOf(playedAdGroups, newLength); } - adGroupTimesMs[adGroupCount] = C.usToMs(durationUs + adGroupTimeInWindowUs); + adGroupTimesMs[adGroupCount] = Util.usToMs(durationUs + adGroupTimeInWindowUs); playedAdGroups[adGroupCount] = period.hasPlayedAdGroup(adGroupIndex); adGroupCount++; } @@ -1310,7 +1310,7 @@ public class StyledPlayerControlView extends FrameLayout { durationUs += window.durationUs; } } - long durationMs = C.usToMs(durationUs); + long durationMs = Util.usToMs(durationUs); if (durationView != null) { durationView.setText(Util.getStringForTime(formatBuilder, formatter, durationMs)); } diff --git a/testutils/src/main/java/com/google/android/exoplayer2/testutil/FakeMediaSourceFactory.java b/testutils/src/main/java/com/google/android/exoplayer2/testutil/FakeMediaSourceFactory.java index dc77ccccb6..0be568b2ef 100644 --- a/testutils/src/main/java/com/google/android/exoplayer2/testutil/FakeMediaSourceFactory.java +++ b/testutils/src/main/java/com/google/android/exoplayer2/testutil/FakeMediaSourceFactory.java @@ -26,6 +26,7 @@ import com.google.android.exoplayer2.source.ads.AdPlaybackState; import com.google.android.exoplayer2.testutil.FakeTimeline.TimelineWindowDefinition; import com.google.android.exoplayer2.upstream.HttpDataSource; import com.google.android.exoplayer2.upstream.LoadErrorHandlingPolicy; +import com.google.android.exoplayer2.util.Util; /** Fake {@link MediaSourceFactory} that creates a {@link FakeMediaSource}. */ public class FakeMediaSourceFactory implements MediaSourceFactory { @@ -81,7 +82,7 @@ public class FakeMediaSourceFactory implements MediaSourceFactory { /* isPlaceholder= */ false, /* durationUs= */ 1000 * C.MICROS_PER_SECOND, /* defaultPositionUs= */ 2 * C.MICROS_PER_SECOND, - /* windowOffsetInFirstPeriodUs= */ C.msToUs(123456789), + /* windowOffsetInFirstPeriodUs= */ Util.msToUs(123456789), AdPlaybackState.NONE, mediaItem); return new FakeMediaSource(new FakeTimeline(timelineWindowDefinition)); diff --git a/testutils/src/main/java/com/google/android/exoplayer2/testutil/FakeTimeline.java b/testutils/src/main/java/com/google/android/exoplayer2/testutil/FakeTimeline.java index 6bd498e199..720e7d550b 100644 --- a/testutils/src/main/java/com/google/android/exoplayer2/testutil/FakeTimeline.java +++ b/testutils/src/main/java/com/google/android/exoplayer2/testutil/FakeTimeline.java @@ -367,7 +367,7 @@ public final class FakeTimeline extends Timeline { manifests[windowIndex], /* presentationStartTimeMs= */ C.TIME_UNSET, /* windowStartTimeMs= */ windowDefinition.isLive - ? C.usToMs(windowDefinition.windowOffsetInFirstPeriodUs) + ? Util.usToMs(windowDefinition.windowOffsetInFirstPeriodUs) : C.TIME_UNSET, /* elapsedRealtimeEpochOffsetMs= */ windowDefinition.isLive ? 0 : C.TIME_UNSET, windowDefinition.isSeekable,