Migrate callers of deprecated C.java methods to Util.java
#minor-release PiperOrigin-RevId: 406166670
This commit is contained in:
parent
67640dff0e
commit
a60843ead5
@ -18,6 +18,7 @@ package androidx.media3.cast;
|
|||||||
import androidx.annotation.Nullable;
|
import androidx.annotation.Nullable;
|
||||||
import androidx.media3.common.C;
|
import androidx.media3.common.C;
|
||||||
import androidx.media3.common.Format;
|
import androidx.media3.common.Format;
|
||||||
|
import androidx.media3.common.util.Util;
|
||||||
import com.google.android.gms.cast.CastStatusCodes;
|
import com.google.android.gms.cast.CastStatusCodes;
|
||||||
import com.google.android.gms.cast.MediaInfo;
|
import com.google.android.gms.cast.MediaInfo;
|
||||||
import com.google.android.gms.cast.MediaTrack;
|
import com.google.android.gms.cast.MediaTrack;
|
||||||
@ -42,7 +43,7 @@ import com.google.android.gms.cast.MediaTrack;
|
|||||||
}
|
}
|
||||||
long durationMs = mediaInfo.getStreamDuration();
|
long durationMs = mediaInfo.getStreamDuration();
|
||||||
return durationMs != MediaInfo.UNKNOWN_DURATION && durationMs != LIVE_STREAM_DURATION
|
return durationMs != MediaInfo.UNKNOWN_DURATION && durationMs != LIVE_STREAM_DURATION
|
||||||
? C.msToUs(durationMs)
|
? Util.msToUs(durationMs)
|
||||||
: C.TIME_UNSET;
|
: C.TIME_UNSET;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -19,6 +19,7 @@ import static org.mockito.Mockito.when;
|
|||||||
|
|
||||||
import androidx.media3.common.C;
|
import androidx.media3.common.C;
|
||||||
import androidx.media3.common.MimeTypes;
|
import androidx.media3.common.MimeTypes;
|
||||||
|
import androidx.media3.common.util.Util;
|
||||||
import androidx.media3.test.utils.TimelineAsserts;
|
import androidx.media3.test.utils.TimelineAsserts;
|
||||||
import androidx.test.ext.junit.runners.AndroidJUnit4;
|
import androidx.test.ext.junit.runners.AndroidJUnit4;
|
||||||
import com.google.android.gms.cast.MediaInfo;
|
import com.google.android.gms.cast.MediaInfo;
|
||||||
@ -52,7 +53,7 @@ public class CastTimelineTrackerTest {
|
|||||||
TimelineAsserts.assertPeriodDurations(
|
TimelineAsserts.assertPeriodDurations(
|
||||||
tracker.getCastTimeline(remoteMediaClient),
|
tracker.getCastTimeline(remoteMediaClient),
|
||||||
C.TIME_UNSET,
|
C.TIME_UNSET,
|
||||||
C.msToUs(DURATION_2_MS),
|
Util.msToUs(DURATION_2_MS),
|
||||||
C.TIME_UNSET,
|
C.TIME_UNSET,
|
||||||
C.TIME_UNSET,
|
C.TIME_UNSET,
|
||||||
C.TIME_UNSET);
|
C.TIME_UNSET);
|
||||||
@ -65,8 +66,8 @@ public class CastTimelineTrackerTest {
|
|||||||
TimelineAsserts.assertPeriodDurations(
|
TimelineAsserts.assertPeriodDurations(
|
||||||
tracker.getCastTimeline(remoteMediaClient),
|
tracker.getCastTimeline(remoteMediaClient),
|
||||||
C.TIME_UNSET,
|
C.TIME_UNSET,
|
||||||
C.msToUs(DURATION_2_MS),
|
Util.msToUs(DURATION_2_MS),
|
||||||
C.msToUs(DURATION_3_MS));
|
Util.msToUs(DURATION_3_MS));
|
||||||
|
|
||||||
remoteMediaClient =
|
remoteMediaClient =
|
||||||
mockRemoteMediaClient(
|
mockRemoteMediaClient(
|
||||||
@ -74,7 +75,7 @@ public class CastTimelineTrackerTest {
|
|||||||
/* currentItemId= */ 3,
|
/* currentItemId= */ 3,
|
||||||
/* currentDurationMs= */ DURATION_3_MS);
|
/* currentDurationMs= */ DURATION_3_MS);
|
||||||
TimelineAsserts.assertPeriodDurations(
|
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 =
|
remoteMediaClient =
|
||||||
mockRemoteMediaClient(
|
mockRemoteMediaClient(
|
||||||
@ -85,8 +86,8 @@ public class CastTimelineTrackerTest {
|
|||||||
tracker.getCastTimeline(remoteMediaClient),
|
tracker.getCastTimeline(remoteMediaClient),
|
||||||
C.TIME_UNSET,
|
C.TIME_UNSET,
|
||||||
C.TIME_UNSET,
|
C.TIME_UNSET,
|
||||||
C.msToUs(DURATION_3_MS),
|
Util.msToUs(DURATION_3_MS),
|
||||||
C.msToUs(DURATION_4_MS),
|
Util.msToUs(DURATION_4_MS),
|
||||||
C.TIME_UNSET);
|
C.TIME_UNSET);
|
||||||
|
|
||||||
remoteMediaClient =
|
remoteMediaClient =
|
||||||
@ -98,9 +99,9 @@ public class CastTimelineTrackerTest {
|
|||||||
tracker.getCastTimeline(remoteMediaClient),
|
tracker.getCastTimeline(remoteMediaClient),
|
||||||
C.TIME_UNSET,
|
C.TIME_UNSET,
|
||||||
C.TIME_UNSET,
|
C.TIME_UNSET,
|
||||||
C.msToUs(DURATION_3_MS),
|
Util.msToUs(DURATION_3_MS),
|
||||||
C.msToUs(DURATION_4_MS),
|
Util.msToUs(DURATION_4_MS),
|
||||||
C.msToUs(DURATION_5_MS));
|
Util.msToUs(DURATION_5_MS));
|
||||||
}
|
}
|
||||||
|
|
||||||
private static RemoteMediaClient mockRemoteMediaClient(
|
private static RemoteMediaClient mockRemoteMediaClient(
|
||||||
|
@ -301,7 +301,7 @@ public abstract class Timeline implements Bundleable {
|
|||||||
* whilst remaining within the bounds of the window.
|
* whilst remaining within the bounds of the window.
|
||||||
*/
|
*/
|
||||||
public long getDefaultPositionMs() {
|
public long getDefaultPositionMs() {
|
||||||
return C.usToMs(defaultPositionUs);
|
return Util.usToMs(defaultPositionUs);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -316,7 +316,7 @@ public abstract class Timeline implements Bundleable {
|
|||||||
|
|
||||||
/** Returns the duration of the window in milliseconds, or {@link C#TIME_UNSET} if unknown. */
|
/** Returns the duration of the window in milliseconds, or {@link C#TIME_UNSET} if unknown. */
|
||||||
public long getDurationMs() {
|
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. */
|
/** Returns the duration of this window in microseconds, or {@link C#TIME_UNSET} if unknown. */
|
||||||
@ -329,7 +329,7 @@ public abstract class Timeline implements Bundleable {
|
|||||||
* belonging to it, in milliseconds.
|
* belonging to it, in milliseconds.
|
||||||
*/
|
*/
|
||||||
public long getPositionInFirstPeriodMs() {
|
public long getPositionInFirstPeriodMs() {
|
||||||
return C.usToMs(positionInFirstPeriodUs);
|
return Util.usToMs(positionInFirstPeriodUs);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -675,7 +675,7 @@ public abstract class Timeline implements Bundleable {
|
|||||||
|
|
||||||
/** Returns the duration of the period in milliseconds, or {@link C#TIME_UNSET} if unknown. */
|
/** Returns the duration of the period in milliseconds, or {@link C#TIME_UNSET} if unknown. */
|
||||||
public long getDurationMs() {
|
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. */
|
/** Returns the duration of this period in microseconds, or {@link C#TIME_UNSET} if unknown. */
|
||||||
@ -689,7 +689,7 @@ public abstract class Timeline implements Bundleable {
|
|||||||
* window.
|
* window.
|
||||||
*/
|
*/
|
||||||
public long getPositionInWindowMs() {
|
public long getPositionInWindowMs() {
|
||||||
return C.usToMs(positionInWindowUs);
|
return Util.usToMs(positionInWindowUs);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -109,9 +109,10 @@ public final class DefaultLivePlaybackSpeedControl implements LivePlaybackSpeedC
|
|||||||
fallbackMaxPlaybackSpeed = DEFAULT_FALLBACK_MAX_PLAYBACK_SPEED;
|
fallbackMaxPlaybackSpeed = DEFAULT_FALLBACK_MAX_PLAYBACK_SPEED;
|
||||||
minUpdateIntervalMs = DEFAULT_MIN_UPDATE_INTERVAL_MS;
|
minUpdateIntervalMs = DEFAULT_MIN_UPDATE_INTERVAL_MS;
|
||||||
proportionalControlFactorUs = DEFAULT_PROPORTIONAL_CONTROL_FACTOR / C.MICROS_PER_SECOND;
|
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 =
|
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;
|
minPossibleLiveOffsetSmoothingFactor = DEFAULT_MIN_POSSIBLE_LIVE_OFFSET_SMOOTHING_FACTOR;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -190,7 +191,7 @@ public final class DefaultLivePlaybackSpeedControl implements LivePlaybackSpeedC
|
|||||||
*/
|
*/
|
||||||
public Builder setMaxLiveOffsetErrorMsForUnitSpeed(long maxLiveOffsetErrorMsForUnitSpeed) {
|
public Builder setMaxLiveOffsetErrorMsForUnitSpeed(long maxLiveOffsetErrorMsForUnitSpeed) {
|
||||||
Assertions.checkArgument(maxLiveOffsetErrorMsForUnitSpeed > 0);
|
Assertions.checkArgument(maxLiveOffsetErrorMsForUnitSpeed > 0);
|
||||||
this.maxLiveOffsetErrorUsForUnitSpeed = C.msToUs(maxLiveOffsetErrorMsForUnitSpeed);
|
this.maxLiveOffsetErrorUsForUnitSpeed = Util.msToUs(maxLiveOffsetErrorMsForUnitSpeed);
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -205,7 +206,8 @@ public final class DefaultLivePlaybackSpeedControl implements LivePlaybackSpeedC
|
|||||||
public Builder setTargetLiveOffsetIncrementOnRebufferMs(
|
public Builder setTargetLiveOffsetIncrementOnRebufferMs(
|
||||||
long targetLiveOffsetIncrementOnRebufferMs) {
|
long targetLiveOffsetIncrementOnRebufferMs) {
|
||||||
Assertions.checkArgument(targetLiveOffsetIncrementOnRebufferMs >= 0);
|
Assertions.checkArgument(targetLiveOffsetIncrementOnRebufferMs >= 0);
|
||||||
this.targetLiveOffsetIncrementOnRebufferUs = C.msToUs(targetLiveOffsetIncrementOnRebufferMs);
|
this.targetLiveOffsetIncrementOnRebufferUs =
|
||||||
|
Util.msToUs(targetLiveOffsetIncrementOnRebufferMs);
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -298,9 +300,9 @@ public final class DefaultLivePlaybackSpeedControl implements LivePlaybackSpeedC
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setLiveConfiguration(LiveConfiguration liveConfiguration) {
|
public void setLiveConfiguration(LiveConfiguration liveConfiguration) {
|
||||||
mediaConfigurationTargetLiveOffsetUs = C.msToUs(liveConfiguration.targetOffsetMs);
|
mediaConfigurationTargetLiveOffsetUs = Util.msToUs(liveConfiguration.targetOffsetMs);
|
||||||
minTargetLiveOffsetUs = C.msToUs(liveConfiguration.minOffsetMs);
|
minTargetLiveOffsetUs = Util.msToUs(liveConfiguration.minOffsetMs);
|
||||||
maxTargetLiveOffsetUs = C.msToUs(liveConfiguration.maxOffsetMs);
|
maxTargetLiveOffsetUs = Util.msToUs(liveConfiguration.maxOffsetMs);
|
||||||
minPlaybackSpeed =
|
minPlaybackSpeed =
|
||||||
liveConfiguration.minPlaybackSpeed != C.RATE_UNSET
|
liveConfiguration.minPlaybackSpeed != C.RATE_UNSET
|
||||||
? liveConfiguration.minPlaybackSpeed
|
? liveConfiguration.minPlaybackSpeed
|
||||||
@ -419,7 +421,7 @@ public final class DefaultLivePlaybackSpeedControl implements LivePlaybackSpeedC
|
|||||||
// There is room for decreasing the target offset towards the ideal or safe offset (whichever
|
// 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
|
// 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.
|
// 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 decrementToOffsetCurrentSpeedUs =
|
||||||
(long) ((adjustedPlaybackSpeed - 1f) * minUpdateIntervalUs);
|
(long) ((adjustedPlaybackSpeed - 1f) * minUpdateIntervalUs);
|
||||||
long decrementToIncreaseSpeedUs = (long) ((maxPlaybackSpeed - 1f) * minUpdateIntervalUs);
|
long decrementToIncreaseSpeedUs = (long) ((maxPlaybackSpeed - 1f) * minUpdateIntervalUs);
|
||||||
|
@ -302,17 +302,17 @@ public class DefaultLoadControl implements LoadControl {
|
|||||||
assertGreaterOrEqual(backBufferDurationMs, 0, "backBufferDurationMs", "0");
|
assertGreaterOrEqual(backBufferDurationMs, 0, "backBufferDurationMs", "0");
|
||||||
|
|
||||||
this.allocator = allocator;
|
this.allocator = allocator;
|
||||||
this.minBufferUs = C.msToUs(minBufferMs);
|
this.minBufferUs = Util.msToUs(minBufferMs);
|
||||||
this.maxBufferUs = C.msToUs(maxBufferMs);
|
this.maxBufferUs = Util.msToUs(maxBufferMs);
|
||||||
this.bufferForPlaybackUs = C.msToUs(bufferForPlaybackMs);
|
this.bufferForPlaybackUs = Util.msToUs(bufferForPlaybackMs);
|
||||||
this.bufferForPlaybackAfterRebufferUs = C.msToUs(bufferForPlaybackAfterRebufferMs);
|
this.bufferForPlaybackAfterRebufferUs = Util.msToUs(bufferForPlaybackAfterRebufferMs);
|
||||||
this.targetBufferBytesOverwrite = targetBufferBytes;
|
this.targetBufferBytesOverwrite = targetBufferBytes;
|
||||||
this.targetBufferBytes =
|
this.targetBufferBytes =
|
||||||
targetBufferBytesOverwrite != C.LENGTH_UNSET
|
targetBufferBytesOverwrite != C.LENGTH_UNSET
|
||||||
? targetBufferBytesOverwrite
|
? targetBufferBytesOverwrite
|
||||||
: DEFAULT_MIN_BUFFER_SIZE;
|
: DEFAULT_MIN_BUFFER_SIZE;
|
||||||
this.prioritizeTimeOverSizeThresholds = prioritizeTimeOverSizeThresholds;
|
this.prioritizeTimeOverSizeThresholds = prioritizeTimeOverSizeThresholds;
|
||||||
this.backBufferDurationUs = C.msToUs(backBufferDurationMs);
|
this.backBufferDurationUs = Util.msToUs(backBufferDurationMs);
|
||||||
this.retainBackBufferFromKeyframe = retainBackBufferFromKeyframe;
|
this.retainBackBufferFromKeyframe = retainBackBufferFromKeyframe;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -372,7 +372,7 @@ public final class ExoPlaybackException extends PlaybackException {
|
|||||||
+ ", format="
|
+ ", format="
|
||||||
+ rendererFormat
|
+ rendererFormat
|
||||||
+ ", format_supported="
|
+ ", format_supported="
|
||||||
+ C.getFormatSupportString(rendererFormatSupport);
|
+ Util.getFormatSupportString(rendererFormatSupport);
|
||||||
break;
|
break;
|
||||||
case TYPE_REMOTE:
|
case TYPE_REMOTE:
|
||||||
message = "Remote error";
|
message = "Remote error";
|
||||||
|
@ -682,7 +682,7 @@ import java.util.concurrent.CopyOnWriteArraySet;
|
|||||||
newPlaybackInfo,
|
newPlaybackInfo,
|
||||||
timeline,
|
timeline,
|
||||||
getPeriodPositionOrMaskWindowPosition(timeline, mediaItemIndex, positionMs));
|
getPeriodPositionOrMaskWindowPosition(timeline, mediaItemIndex, positionMs));
|
||||||
internalPlayer.seekTo(timeline, mediaItemIndex, C.msToUs(positionMs));
|
internalPlayer.seekTo(timeline, mediaItemIndex, Util.msToUs(positionMs));
|
||||||
updatePlaybackInfo(
|
updatePlaybackInfo(
|
||||||
newPlaybackInfo,
|
newPlaybackInfo,
|
||||||
/* ignored */ TIMELINE_CHANGE_REASON_PLAYLIST_CHANGED,
|
/* ignored */ TIMELINE_CHANGE_REASON_PLAYLIST_CHANGED,
|
||||||
@ -878,21 +878,21 @@ import java.util.concurrent.CopyOnWriteArraySet;
|
|||||||
MediaPeriodId periodId = playbackInfo.periodId;
|
MediaPeriodId periodId = playbackInfo.periodId;
|
||||||
playbackInfo.timeline.getPeriodByUid(periodId.periodUid, period);
|
playbackInfo.timeline.getPeriodByUid(periodId.periodUid, period);
|
||||||
long adDurationUs = period.getAdDurationUs(periodId.adGroupIndex, periodId.adIndexInAdGroup);
|
long adDurationUs = period.getAdDurationUs(periodId.adGroupIndex, periodId.adIndexInAdGroup);
|
||||||
return C.usToMs(adDurationUs);
|
return Util.usToMs(adDurationUs);
|
||||||
}
|
}
|
||||||
return getContentDuration();
|
return getContentDuration();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public long getCurrentPosition() {
|
public long getCurrentPosition() {
|
||||||
return C.usToMs(getCurrentPositionUsInternal(playbackInfo));
|
return Util.usToMs(getCurrentPositionUsInternal(playbackInfo));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public long getBufferedPosition() {
|
public long getBufferedPosition() {
|
||||||
if (isPlayingAd()) {
|
if (isPlayingAd()) {
|
||||||
return playbackInfo.loadingMediaPeriodId.equals(playbackInfo.periodId)
|
return playbackInfo.loadingMediaPeriodId.equals(playbackInfo.periodId)
|
||||||
? C.usToMs(playbackInfo.bufferedPositionUs)
|
? Util.usToMs(playbackInfo.bufferedPositionUs)
|
||||||
: getDuration();
|
: getDuration();
|
||||||
}
|
}
|
||||||
return getContentBufferedPosition();
|
return getContentBufferedPosition();
|
||||||
@ -900,7 +900,7 @@ import java.util.concurrent.CopyOnWriteArraySet;
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public long getTotalBufferedDuration() {
|
public long getTotalBufferedDuration() {
|
||||||
return C.usToMs(playbackInfo.totalBufferedDurationUs);
|
return Util.usToMs(playbackInfo.totalBufferedDurationUs);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -924,7 +924,7 @@ import java.util.concurrent.CopyOnWriteArraySet;
|
|||||||
playbackInfo.timeline.getPeriodByUid(playbackInfo.periodId.periodUid, period);
|
playbackInfo.timeline.getPeriodByUid(playbackInfo.periodId.periodUid, period);
|
||||||
return playbackInfo.requestedContentPositionUs == C.TIME_UNSET
|
return playbackInfo.requestedContentPositionUs == C.TIME_UNSET
|
||||||
? playbackInfo.timeline.getWindow(getCurrentWindowIndex(), window).getDefaultPositionMs()
|
? playbackInfo.timeline.getWindow(getCurrentWindowIndex(), window).getDefaultPositionMs()
|
||||||
: period.getPositionInWindowMs() + C.usToMs(playbackInfo.requestedContentPositionUs);
|
: period.getPositionInWindowMs() + Util.usToMs(playbackInfo.requestedContentPositionUs);
|
||||||
} else {
|
} else {
|
||||||
return getCurrentPosition();
|
return getCurrentPosition();
|
||||||
}
|
}
|
||||||
@ -949,7 +949,7 @@ import java.util.concurrent.CopyOnWriteArraySet;
|
|||||||
contentBufferedPositionUs = loadingPeriod.durationUs;
|
contentBufferedPositionUs = loadingPeriod.durationUs;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return C.usToMs(
|
return Util.usToMs(
|
||||||
periodPositionUsToWindowPositionUs(
|
periodPositionUsToWindowPositionUs(
|
||||||
playbackInfo.timeline, playbackInfo.loadingMediaPeriodId, contentBufferedPositionUs));
|
playbackInfo.timeline, playbackInfo.loadingMediaPeriodId, contentBufferedPositionUs));
|
||||||
}
|
}
|
||||||
@ -1149,7 +1149,7 @@ import java.util.concurrent.CopyOnWriteArraySet;
|
|||||||
|
|
||||||
private long getCurrentPositionUsInternal(PlaybackInfo playbackInfo) {
|
private long getCurrentPositionUsInternal(PlaybackInfo playbackInfo) {
|
||||||
if (playbackInfo.timeline.isEmpty()) {
|
if (playbackInfo.timeline.isEmpty()) {
|
||||||
return C.msToUs(maskingWindowPositionMs);
|
return Util.msToUs(maskingWindowPositionMs);
|
||||||
} else if (playbackInfo.periodId.isAd()) {
|
} else if (playbackInfo.periodId.isAd()) {
|
||||||
return playbackInfo.positionUs;
|
return playbackInfo.positionUs;
|
||||||
} else {
|
} else {
|
||||||
@ -1438,8 +1438,8 @@ import java.util.concurrent.CopyOnWriteArraySet;
|
|||||||
oldMediaItem,
|
oldMediaItem,
|
||||||
oldPeriodUid,
|
oldPeriodUid,
|
||||||
oldPeriodIndex,
|
oldPeriodIndex,
|
||||||
C.usToMs(oldPositionUs),
|
Util.usToMs(oldPositionUs),
|
||||||
C.usToMs(oldContentPositionUs),
|
Util.usToMs(oldContentPositionUs),
|
||||||
oldPlaybackInfo.periodId.adGroupIndex,
|
oldPlaybackInfo.periodId.adGroupIndex,
|
||||||
oldPlaybackInfo.periodId.adIndexInAdGroup);
|
oldPlaybackInfo.periodId.adIndexInAdGroup);
|
||||||
}
|
}
|
||||||
@ -1457,7 +1457,7 @@ import java.util.concurrent.CopyOnWriteArraySet;
|
|||||||
newWindowUid = playbackInfo.timeline.getWindow(newWindowIndex, window).uid;
|
newWindowUid = playbackInfo.timeline.getWindow(newWindowIndex, window).uid;
|
||||||
newMediaItem = window.mediaItem;
|
newMediaItem = window.mediaItem;
|
||||||
}
|
}
|
||||||
long positionMs = C.usToMs(discontinuityWindowStartPositionUs);
|
long positionMs = Util.usToMs(discontinuityWindowStartPositionUs);
|
||||||
return new PositionInfo(
|
return new PositionInfo(
|
||||||
newWindowUid,
|
newWindowUid,
|
||||||
newWindowIndex,
|
newWindowIndex,
|
||||||
@ -1466,7 +1466,7 @@ import java.util.concurrent.CopyOnWriteArraySet;
|
|||||||
newPeriodIndex,
|
newPeriodIndex,
|
||||||
positionMs,
|
positionMs,
|
||||||
/* contentPositionMs= */ playbackInfo.periodId.isAd()
|
/* contentPositionMs= */ playbackInfo.periodId.isAd()
|
||||||
? C.usToMs(getRequestedContentPositionUs(playbackInfo))
|
? Util.usToMs(getRequestedContentPositionUs(playbackInfo))
|
||||||
: positionMs,
|
: positionMs,
|
||||||
playbackInfo.periodId.adGroupIndex,
|
playbackInfo.periodId.adGroupIndex,
|
||||||
playbackInfo.periodId.adIndexInAdGroup);
|
playbackInfo.periodId.adIndexInAdGroup);
|
||||||
@ -1580,7 +1580,7 @@ import java.util.concurrent.CopyOnWriteArraySet;
|
|||||||
}
|
}
|
||||||
newPlaybackInfo = newPlaybackInfo.copyWithPlaybackState(maskingPlaybackState);
|
newPlaybackInfo = newPlaybackInfo.copyWithPlaybackState(maskingPlaybackState);
|
||||||
internalPlayer.setMediaSources(
|
internalPlayer.setMediaSources(
|
||||||
holders, startWindowIndex, C.msToUs(startPositionMs), shuffleOrder);
|
holders, startWindowIndex, Util.msToUs(startPositionMs), shuffleOrder);
|
||||||
boolean positionDiscontinuity =
|
boolean positionDiscontinuity =
|
||||||
!playbackInfo.periodId.periodUid.equals(newPlaybackInfo.periodId.periodUid)
|
!playbackInfo.periodId.periodUid.equals(newPlaybackInfo.periodId.periodUid)
|
||||||
&& !playbackInfo.timeline.isEmpty();
|
&& !playbackInfo.timeline.isEmpty();
|
||||||
@ -1660,7 +1660,7 @@ import java.util.concurrent.CopyOnWriteArraySet;
|
|||||||
if (timeline.isEmpty()) {
|
if (timeline.isEmpty()) {
|
||||||
// Reset periodId and loadingPeriodId.
|
// Reset periodId and loadingPeriodId.
|
||||||
MediaPeriodId dummyMediaPeriodId = PlaybackInfo.getDummyPeriodForEmptyTimeline();
|
MediaPeriodId dummyMediaPeriodId = PlaybackInfo.getDummyPeriodForEmptyTimeline();
|
||||||
long positionUs = C.msToUs(maskingWindowPositionMs);
|
long positionUs = Util.msToUs(maskingWindowPositionMs);
|
||||||
playbackInfo =
|
playbackInfo =
|
||||||
playbackInfo.copyWithNewPosition(
|
playbackInfo.copyWithNewPosition(
|
||||||
dummyMediaPeriodId,
|
dummyMediaPeriodId,
|
||||||
@ -1681,7 +1681,7 @@ import java.util.concurrent.CopyOnWriteArraySet;
|
|||||||
MediaPeriodId newPeriodId =
|
MediaPeriodId newPeriodId =
|
||||||
playingPeriodChanged ? new MediaPeriodId(periodPosition.first) : playbackInfo.periodId;
|
playingPeriodChanged ? new MediaPeriodId(periodPosition.first) : playbackInfo.periodId;
|
||||||
long newContentPositionUs = periodPosition.second;
|
long newContentPositionUs = periodPosition.second;
|
||||||
long oldContentPositionUs = C.msToUs(getContentPosition());
|
long oldContentPositionUs = Util.msToUs(getContentPosition());
|
||||||
if (!oldTimeline.isEmpty()) {
|
if (!oldTimeline.isEmpty()) {
|
||||||
oldContentPositionUs -=
|
oldContentPositionUs -=
|
||||||
oldTimeline.getPeriodByUid(oldPeriodUid, period).getPositionInWindowUs();
|
oldTimeline.getPeriodByUid(oldPeriodUid, period).getPositionInWindowUs();
|
||||||
@ -1770,7 +1770,7 @@ import java.util.concurrent.CopyOnWriteArraySet;
|
|||||||
@Nullable
|
@Nullable
|
||||||
Pair<Object, Long> oldPeriodPosition =
|
Pair<Object, Long> oldPeriodPosition =
|
||||||
oldTimeline.getPeriodPosition(
|
oldTimeline.getPeriodPosition(
|
||||||
window, period, currentWindowIndex, C.msToUs(currentPositionMs));
|
window, period, currentWindowIndex, Util.msToUs(currentPositionMs));
|
||||||
Object periodUid = castNonNull(oldPeriodPosition).first;
|
Object periodUid = castNonNull(oldPeriodPosition).first;
|
||||||
if (newTimeline.getIndexOfPeriod(periodUid) != C.INDEX_UNSET) {
|
if (newTimeline.getIndexOfPeriod(periodUid) != C.INDEX_UNSET) {
|
||||||
// The old period position is still available in the new timeline.
|
// The old period position is still available in the new timeline.
|
||||||
@ -1811,7 +1811,7 @@ import java.util.concurrent.CopyOnWriteArraySet;
|
|||||||
windowIndex = timeline.getFirstWindowIndex(shuffleModeEnabled);
|
windowIndex = timeline.getFirstWindowIndex(shuffleModeEnabled);
|
||||||
windowPositionMs = timeline.getWindow(windowIndex, window).getDefaultPositionMs();
|
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(
|
private long periodPositionUsToWindowPositionUs(
|
||||||
|
@ -1090,7 +1090,7 @@ import java.util.concurrent.atomic.AtomicBoolean;
|
|||||||
if (window.windowStartTimeMs == C.TIME_UNSET || !window.isLive() || !window.isDynamic) {
|
if (window.windowStartTimeMs == C.TIME_UNSET || !window.isLive() || !window.isDynamic) {
|
||||||
return C.TIME_UNSET;
|
return C.TIME_UNSET;
|
||||||
}
|
}
|
||||||
return C.msToUs(window.getCurrentUnixTimeMs() - window.windowStartTimeMs)
|
return Util.msToUs(window.getCurrentUnixTimeMs() - window.windowStartTimeMs)
|
||||||
- (periodPositionUs + period.getPositionInWindowUs());
|
- (periodPositionUs + period.getPositionInWindowUs());
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1192,7 +1192,7 @@ import java.util.concurrent.atomic.AtomicBoolean;
|
|||||||
playingPeriodHolder.mediaPeriod.getAdjustedSeekPositionUs(
|
playingPeriodHolder.mediaPeriod.getAdjustedSeekPositionUs(
|
||||||
newPeriodPositionUs, seekParameters);
|
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_BUFFERING
|
||||||
|| playbackInfo.playbackState == Player.STATE_READY)) {
|
|| playbackInfo.playbackState == Player.STATE_READY)) {
|
||||||
// Seek will be performed to the current position. Do nothing.
|
// Seek will be performed to the current position. Do nothing.
|
||||||
@ -2718,7 +2718,7 @@ import java.util.concurrent.atomic.AtomicBoolean;
|
|||||||
long requestPositionUs =
|
long requestPositionUs =
|
||||||
pendingMessageInfo.message.getPositionMs() == C.TIME_END_OF_SOURCE
|
pendingMessageInfo.message.getPositionMs() == C.TIME_END_OF_SOURCE
|
||||||
? C.TIME_UNSET
|
? C.TIME_UNSET
|
||||||
: C.msToUs(pendingMessageInfo.message.getPositionMs());
|
: Util.msToUs(pendingMessageInfo.message.getPositionMs());
|
||||||
@Nullable
|
@Nullable
|
||||||
Pair<Object, Long> periodPosition =
|
Pair<Object, Long> periodPosition =
|
||||||
resolveSeekPosition(
|
resolveSeekPosition(
|
||||||
|
@ -466,7 +466,7 @@ public class SimpleExoPlayer extends BasePlayer
|
|||||||
if (Util.SDK_INT < 21) {
|
if (Util.SDK_INT < 21) {
|
||||||
audioSessionId = initializeKeepSessionIdAudioTrack(C.AUDIO_SESSION_ID_UNSET);
|
audioSessionId = initializeKeepSessionIdAudioTrack(C.AUDIO_SESSION_ID_UNSET);
|
||||||
} else {
|
} else {
|
||||||
audioSessionId = C.generateAudioSessionIdV21(applicationContext);
|
audioSessionId = Util.generateAudioSessionIdV21(applicationContext);
|
||||||
}
|
}
|
||||||
currentCues = Collections.emptyList();
|
currentCues = Collections.emptyList();
|
||||||
throwsWhenUsingWrongThread = true;
|
throwsWhenUsingWrongThread = true;
|
||||||
@ -781,7 +781,7 @@ public class SimpleExoPlayer extends BasePlayer
|
|||||||
if (Util.SDK_INT < 21) {
|
if (Util.SDK_INT < 21) {
|
||||||
audioSessionId = initializeKeepSessionIdAudioTrack(C.AUDIO_SESSION_ID_UNSET);
|
audioSessionId = initializeKeepSessionIdAudioTrack(C.AUDIO_SESSION_ID_UNSET);
|
||||||
} else {
|
} else {
|
||||||
audioSessionId = C.generateAudioSessionIdV21(applicationContext);
|
audioSessionId = Util.generateAudioSessionIdV21(applicationContext);
|
||||||
}
|
}
|
||||||
} else if (Util.SDK_INT < 21) {
|
} else if (Util.SDK_INT < 21) {
|
||||||
// We need to re-initialize keepSessionIdAudioTrack to make sure the session is kept alive for
|
// We need to re-initialize keepSessionIdAudioTrack to make sure the session is kept alive for
|
||||||
|
@ -15,10 +15,10 @@
|
|||||||
*/
|
*/
|
||||||
package androidx.media3.exoplayer;
|
package androidx.media3.exoplayer;
|
||||||
|
|
||||||
import androidx.media3.common.C;
|
|
||||||
import androidx.media3.common.PlaybackParameters;
|
import androidx.media3.common.PlaybackParameters;
|
||||||
import androidx.media3.common.util.Clock;
|
import androidx.media3.common.util.Clock;
|
||||||
import androidx.media3.common.util.UnstableApi;
|
import androidx.media3.common.util.UnstableApi;
|
||||||
|
import androidx.media3.common.util.Util;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A {@link MediaClock} whose position advances with real time based on the playback parameters when
|
* A {@link MediaClock} whose position advances with real time based on the playback parameters when
|
||||||
@ -78,7 +78,7 @@ public final class StandaloneMediaClock implements MediaClock {
|
|||||||
if (started) {
|
if (started) {
|
||||||
long elapsedSinceBaseMs = clock.elapsedRealtime() - baseElapsedMs;
|
long elapsedSinceBaseMs = clock.elapsedRealtime() - baseElapsedMs;
|
||||||
if (playbackParameters.speed == 1f) {
|
if (playbackParameters.speed == 1f) {
|
||||||
positionUs += C.msToUs(elapsedSinceBaseMs);
|
positionUs += Util.msToUs(elapsedSinceBaseMs);
|
||||||
} else {
|
} else {
|
||||||
// Add the media time in microseconds that will elapse in elapsedSinceBaseMs milliseconds of
|
// Add the media time in microseconds that will elapse in elapsedSinceBaseMs milliseconds of
|
||||||
// wallclock time
|
// wallclock time
|
||||||
|
@ -1159,7 +1159,7 @@ public class AnalyticsCollector
|
|||||||
: playerTimeline
|
: playerTimeline
|
||||||
.getPeriod(playerPeriodIndex, period)
|
.getPeriod(playerPeriodIndex, period)
|
||||||
.getAdGroupIndexAfterPositionUs(
|
.getAdGroupIndexAfterPositionUs(
|
||||||
C.msToUs(player.getCurrentPosition()) - period.getPositionInWindowUs());
|
Util.msToUs(player.getCurrentPosition()) - period.getPositionInWindowUs());
|
||||||
for (int i = 0; i < mediaPeriodQueue.size(); i++) {
|
for (int i = 0; i < mediaPeriodQueue.size(); i++) {
|
||||||
MediaPeriodId mediaPeriodId = mediaPeriodQueue.get(i);
|
MediaPeriodId mediaPeriodId = mediaPeriodQueue.get(i);
|
||||||
if (isMatchingMediaPeriod(
|
if (isMatchingMediaPeriod(
|
||||||
|
@ -15,7 +15,6 @@
|
|||||||
*/
|
*/
|
||||||
package androidx.media3.exoplayer.analytics;
|
package androidx.media3.exoplayer.analytics;
|
||||||
|
|
||||||
import static androidx.media3.common.C.usToMs;
|
|
||||||
import static java.lang.Math.max;
|
import static java.lang.Math.max;
|
||||||
|
|
||||||
import android.util.Base64;
|
import android.util.Base64;
|
||||||
@ -143,7 +142,7 @@ public final class DefaultPlaybackSessionManager implements PlaybackSessionManag
|
|||||||
contentSession.isCreated = true;
|
contentSession.isCreated = true;
|
||||||
eventTime.timeline.getPeriodByUid(eventTime.mediaPeriodId.periodUid, period);
|
eventTime.timeline.getPeriodByUid(eventTime.mediaPeriodId.periodUid, period);
|
||||||
long adGroupPositionMs =
|
long adGroupPositionMs =
|
||||||
usToMs(period.getAdGroupTimeUs(eventTime.mediaPeriodId.adGroupIndex))
|
Util.usToMs(period.getAdGroupTimeUs(eventTime.mediaPeriodId.adGroupIndex))
|
||||||
+ period.getPositionInWindowMs();
|
+ period.getPositionInWindowMs();
|
||||||
// getAdGroupTimeUs may return 0 for prerolls despite period offset.
|
// getAdGroupTimeUs may return 0 for prerolls despite period offset.
|
||||||
adGroupPositionMs = max(0, adGroupPositionMs);
|
adGroupPositionMs = max(0, adGroupPositionMs);
|
||||||
|
@ -335,7 +335,7 @@ public final class PlaybackStatsListener
|
|||||||
eventTime.mediaPeriodId.periodUid,
|
eventTime.mediaPeriodId.periodUid,
|
||||||
eventTime.mediaPeriodId.windowSequenceNumber,
|
eventTime.mediaPeriodId.windowSequenceNumber,
|
||||||
eventTime.mediaPeriodId.adGroupIndex),
|
eventTime.mediaPeriodId.adGroupIndex),
|
||||||
/* eventPlaybackPositionMs= */ C.usToMs(contentWindowPositionUs),
|
/* eventPlaybackPositionMs= */ Util.usToMs(contentWindowPositionUs),
|
||||||
eventTime.timeline,
|
eventTime.timeline,
|
||||||
eventTime.currentWindowIndex,
|
eventTime.currentWindowIndex,
|
||||||
eventTime.currentMediaPeriodId,
|
eventTime.currentMediaPeriodId,
|
||||||
|
@ -302,12 +302,12 @@ import java.lang.reflect.Method;
|
|||||||
|
|
||||||
if (!notifiedPositionIncreasing && positionUs > lastPositionUs) {
|
if (!notifiedPositionIncreasing && positionUs > lastPositionUs) {
|
||||||
notifiedPositionIncreasing = true;
|
notifiedPositionIncreasing = true;
|
||||||
long mediaDurationSinceLastPositionUs = C.usToMs(positionUs - lastPositionUs);
|
long mediaDurationSinceLastPositionUs = Util.usToMs(positionUs - lastPositionUs);
|
||||||
long playoutDurationSinceLastPositionUs =
|
long playoutDurationSinceLastPositionUs =
|
||||||
Util.getPlayoutDurationForMediaDuration(
|
Util.getPlayoutDurationForMediaDuration(
|
||||||
mediaDurationSinceLastPositionUs, audioTrackPlaybackSpeed);
|
mediaDurationSinceLastPositionUs, audioTrackPlaybackSpeed);
|
||||||
long playoutStartSystemTimeMs =
|
long playoutStartSystemTimeMs =
|
||||||
System.currentTimeMillis() - C.usToMs(playoutDurationSinceLastPositionUs);
|
System.currentTimeMillis() - Util.usToMs(playoutDurationSinceLastPositionUs);
|
||||||
listener.onPositionAdvancing(playoutStartSystemTimeMs);
|
listener.onPositionAdvancing(playoutStartSystemTimeMs);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -357,7 +357,7 @@ import java.lang.reflect.Method;
|
|||||||
boolean hadData = hasData;
|
boolean hadData = hasData;
|
||||||
hasData = hasPendingData(writtenFrames);
|
hasData = hasPendingData(writtenFrames);
|
||||||
if (hadData && !hasData && playState != PLAYSTATE_STOPPED) {
|
if (hadData && !hasData && playState != PLAYSTATE_STOPPED) {
|
||||||
listener.onUnderrun(bufferSize, C.usToMs(bufferSizeUs));
|
listener.onUnderrun(bufferSize, Util.usToMs(bufferSizeUs));
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
@ -379,7 +379,7 @@ import java.lang.reflect.Method;
|
|||||||
|
|
||||||
/** Returns the duration of audio that is buffered but unplayed. */
|
/** Returns the duration of audio that is buffered but unplayed. */
|
||||||
public long getPendingBufferDurationMs(long writtenFrames) {
|
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. */
|
/** Returns whether the track is in an invalid state and must be recreated. */
|
||||||
|
@ -23,7 +23,6 @@ import androidx.annotation.DoNotInline;
|
|||||||
import androidx.annotation.IntDef;
|
import androidx.annotation.IntDef;
|
||||||
import androidx.annotation.Nullable;
|
import androidx.annotation.Nullable;
|
||||||
import androidx.annotation.RequiresApi;
|
import androidx.annotation.RequiresApi;
|
||||||
import androidx.media3.common.C;
|
|
||||||
import androidx.media3.common.PlaybackException;
|
import androidx.media3.common.PlaybackException;
|
||||||
import androidx.media3.common.util.UnstableApi;
|
import androidx.media3.common.util.UnstableApi;
|
||||||
import androidx.media3.common.util.Util;
|
import androidx.media3.common.util.Util;
|
||||||
@ -124,7 +123,7 @@ public final class DrmUtil {
|
|||||||
@Nullable
|
@Nullable
|
||||||
String diagnosticsInfo = ((MediaDrm.MediaDrmStateException) throwable).getDiagnosticInfo();
|
String diagnosticsInfo = ((MediaDrm.MediaDrmStateException) throwable).getDiagnosticInfo();
|
||||||
int drmErrorCode = Util.getErrorCodeFromPlatformDiagnosticsInfo(diagnosticsInfo);
|
int drmErrorCode = Util.getErrorCodeFromPlatformDiagnosticsInfo(diagnosticsInfo);
|
||||||
return C.getErrorCodeForMediaDrmErrorCode(drmErrorCode);
|
return Util.getErrorCodeForMediaDrmErrorCode(drmErrorCode);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1242,7 +1242,7 @@ public abstract class MediaCodecRenderer extends BaseRenderer {
|
|||||||
}
|
}
|
||||||
} catch (CryptoException e) {
|
} catch (CryptoException e) {
|
||||||
throw createRendererException(
|
throw createRendererException(
|
||||||
e, inputFormat, C.getErrorCodeForMediaDrmErrorCode(e.getErrorCode()));
|
e, inputFormat, Util.getErrorCodeForMediaDrmErrorCode(e.getErrorCode()));
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -1314,7 +1314,7 @@ public abstract class MediaCodecRenderer extends BaseRenderer {
|
|||||||
}
|
}
|
||||||
} catch (CryptoException e) {
|
} catch (CryptoException e) {
|
||||||
throw createRendererException(
|
throw createRendererException(
|
||||||
e, inputFormat, C.getErrorCodeForMediaDrmErrorCode(e.getErrorCode()));
|
e, inputFormat, Util.getErrorCodeForMediaDrmErrorCode(e.getErrorCode()));
|
||||||
}
|
}
|
||||||
|
|
||||||
resetInputBuffer();
|
resetInputBuffer();
|
||||||
|
@ -25,6 +25,7 @@ import androidx.media3.common.MediaItem;
|
|||||||
import androidx.media3.common.Timeline;
|
import androidx.media3.common.Timeline;
|
||||||
import androidx.media3.common.util.Assertions;
|
import androidx.media3.common.util.Assertions;
|
||||||
import androidx.media3.common.util.UnstableApi;
|
import androidx.media3.common.util.UnstableApi;
|
||||||
|
import androidx.media3.common.util.Util;
|
||||||
import androidx.media3.datasource.TransferListener;
|
import androidx.media3.datasource.TransferListener;
|
||||||
import androidx.media3.exoplayer.upstream.Allocator;
|
import androidx.media3.exoplayer.upstream.Allocator;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
@ -340,7 +341,7 @@ public final class ClippingMediaSource extends CompositeMediaSource<Void> {
|
|||||||
endUs == C.TIME_UNSET ? window.defaultPositionUs : min(window.defaultPositionUs, endUs);
|
endUs == C.TIME_UNSET ? window.defaultPositionUs : min(window.defaultPositionUs, endUs);
|
||||||
window.defaultPositionUs -= startUs;
|
window.defaultPositionUs -= startUs;
|
||||||
}
|
}
|
||||||
long startMs = C.usToMs(startUs);
|
long startMs = Util.usToMs(startUs);
|
||||||
if (window.presentationStartTimeMs != C.TIME_UNSET) {
|
if (window.presentationStartTimeMs != C.TIME_UNSET) {
|
||||||
window.presentationStartTimeMs += startMs;
|
window.presentationStartTimeMs += startMs;
|
||||||
}
|
}
|
||||||
|
@ -26,6 +26,7 @@ import androidx.media3.common.Format;
|
|||||||
import androidx.media3.common.Player;
|
import androidx.media3.common.Player;
|
||||||
import androidx.media3.common.util.Assertions;
|
import androidx.media3.common.util.Assertions;
|
||||||
import androidx.media3.common.util.UnstableApi;
|
import androidx.media3.common.util.UnstableApi;
|
||||||
|
import androidx.media3.common.util.Util;
|
||||||
import androidx.media3.exoplayer.source.MediaSource.MediaPeriodId;
|
import androidx.media3.exoplayer.source.MediaSource.MediaPeriodId;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.concurrent.CopyOnWriteArrayList;
|
import java.util.concurrent.CopyOnWriteArrayList;
|
||||||
@ -474,7 +475,7 @@ public interface MediaSourceEventListener {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private long adjustMediaTime(long mediaTimeUs) {
|
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;
|
return mediaTimeMs == C.TIME_UNSET ? C.TIME_UNSET : mediaTimeOffsetMs + mediaTimeMs;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -643,8 +643,8 @@ import org.checkerframework.checker.nullness.qual.MonotonicNonNull;
|
|||||||
/* trackFormat= */ null,
|
/* trackFormat= */ null,
|
||||||
C.SELECTION_REASON_UNKNOWN,
|
C.SELECTION_REASON_UNKNOWN,
|
||||||
/* trackSelectionData= */ null,
|
/* trackSelectionData= */ null,
|
||||||
/* mediaStartTimeMs= */ C.usToMs(loadable.seekTimeUs),
|
/* mediaStartTimeMs= */ Util.usToMs(loadable.seekTimeUs),
|
||||||
C.usToMs(durationUs));
|
Util.usToMs(durationUs));
|
||||||
LoadErrorAction loadErrorAction;
|
LoadErrorAction loadErrorAction;
|
||||||
long retryDelayMs =
|
long retryDelayMs =
|
||||||
loadErrorHandlingPolicy.getRetryDelayMsFor(
|
loadErrorHandlingPolicy.getRetryDelayMsFor(
|
||||||
|
@ -23,6 +23,7 @@ import androidx.media3.common.TrackGroup;
|
|||||||
import androidx.media3.common.TrackGroupArray;
|
import androidx.media3.common.TrackGroupArray;
|
||||||
import androidx.media3.common.util.Assertions;
|
import androidx.media3.common.util.Assertions;
|
||||||
import androidx.media3.common.util.Log;
|
import androidx.media3.common.util.Log;
|
||||||
|
import androidx.media3.common.util.Util;
|
||||||
import androidx.media3.datasource.DataSource;
|
import androidx.media3.datasource.DataSource;
|
||||||
import androidx.media3.datasource.DataSourceUtil;
|
import androidx.media3.datasource.DataSourceUtil;
|
||||||
import androidx.media3.datasource.DataSpec;
|
import androidx.media3.datasource.DataSpec;
|
||||||
@ -284,7 +285,7 @@ import org.checkerframework.checker.nullness.qual.MonotonicNonNull;
|
|||||||
C.SELECTION_REASON_UNKNOWN,
|
C.SELECTION_REASON_UNKNOWN,
|
||||||
/* trackSelectionData= */ null,
|
/* trackSelectionData= */ null,
|
||||||
/* mediaStartTimeMs= */ 0,
|
/* mediaStartTimeMs= */ 0,
|
||||||
C.usToMs(durationUs));
|
Util.usToMs(durationUs));
|
||||||
long retryDelay =
|
long retryDelay =
|
||||||
loadErrorHandlingPolicy.getRetryDelayMsFor(
|
loadErrorHandlingPolicy.getRetryDelayMsFor(
|
||||||
new LoadErrorInfo(loadEventInfo, mediaLoadData, error, errorCount));
|
new LoadErrorInfo(loadEventInfo, mediaLoadData, error, errorCount));
|
||||||
|
@ -515,7 +515,7 @@ public final class ServerSideInsertedAdsMediaSource extends BaseMediaSource
|
|||||||
if (mediaPositionMs == C.TIME_UNSET) {
|
if (mediaPositionMs == C.TIME_UNSET) {
|
||||||
return C.TIME_UNSET;
|
return C.TIME_UNSET;
|
||||||
}
|
}
|
||||||
long mediaPositionUs = C.msToUs(mediaPositionMs);
|
long mediaPositionUs = Util.msToUs(mediaPositionMs);
|
||||||
MediaPeriodId id = mediaPeriod.mediaPeriodId;
|
MediaPeriodId id = mediaPeriod.mediaPeriodId;
|
||||||
long correctedPositionUs =
|
long correctedPositionUs =
|
||||||
id.isAd()
|
id.isAd()
|
||||||
@ -525,7 +525,7 @@ public final class ServerSideInsertedAdsMediaSource extends BaseMediaSource
|
|||||||
// content pieces (beyond nextAdGroupIndex).
|
// content pieces (beyond nextAdGroupIndex).
|
||||||
: getMediaPeriodPositionUsForContent(
|
: getMediaPeriodPositionUsForContent(
|
||||||
mediaPositionUs, /* nextAdGroupIndex= */ C.INDEX_UNSET, adPlaybackState);
|
mediaPositionUs, /* nextAdGroupIndex= */ C.INDEX_UNSET, adPlaybackState);
|
||||||
return C.usToMs(correctedPositionUs);
|
return Util.usToMs(correctedPositionUs);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static final class SharedMediaPeriod implements MediaPeriod.Callback {
|
private static final class SharedMediaPeriod implements MediaPeriod.Callback {
|
||||||
@ -594,7 +594,7 @@ public final class ServerSideInsertedAdsMediaSource extends BaseMediaSource
|
|||||||
MediaPeriodImpl mediaPeriod = mediaPeriods.get(i);
|
MediaPeriodImpl mediaPeriod = mediaPeriods.get(i);
|
||||||
long startTimeInPeriodUs =
|
long startTimeInPeriodUs =
|
||||||
getMediaPeriodPositionUs(
|
getMediaPeriodPositionUs(
|
||||||
C.msToUs(mediaLoadData.mediaStartTimeMs),
|
Util.msToUs(mediaLoadData.mediaStartTimeMs),
|
||||||
mediaPeriod.mediaPeriodId,
|
mediaPeriod.mediaPeriodId,
|
||||||
adPlaybackState);
|
adPlaybackState);
|
||||||
long mediaPeriodEndPositionUs = getMediaPeriodEndPositionUs(mediaPeriod, adPlaybackState);
|
long mediaPeriodEndPositionUs = getMediaPeriodEndPositionUs(mediaPeriod, adPlaybackState);
|
||||||
|
@ -127,11 +127,12 @@ public final class ServerSideInsertedAdsUtil {
|
|||||||
if (player.isPlayingAd()) {
|
if (player.isPlayingAd()) {
|
||||||
int adGroupIndex = player.getCurrentAdGroupIndex();
|
int adGroupIndex = player.getCurrentAdGroupIndex();
|
||||||
int adIndexInAdGroup = player.getCurrentAdIndexInAdGroup();
|
int adIndexInAdGroup = player.getCurrentAdIndexInAdGroup();
|
||||||
long adPositionUs = C.msToUs(player.getCurrentPosition());
|
long adPositionUs = Util.msToUs(player.getCurrentPosition());
|
||||||
return getStreamPositionUsForAd(
|
return getStreamPositionUsForAd(
|
||||||
adPositionUs, adGroupIndex, adIndexInAdGroup, adPlaybackState);
|
adPositionUs, adGroupIndex, adIndexInAdGroup, adPlaybackState);
|
||||||
}
|
}
|
||||||
long periodPositionUs = C.msToUs(player.getCurrentPosition()) - period.getPositionInWindowUs();
|
long periodPositionUs =
|
||||||
|
Util.msToUs(player.getCurrentPosition()) - period.getPositionInWindowUs();
|
||||||
return getStreamPositionUsForContent(
|
return getStreamPositionUsForContent(
|
||||||
periodPositionUs, /* nextAdGroupIndex= */ C.INDEX_UNSET, adPlaybackState);
|
periodPositionUs, /* nextAdGroupIndex= */ C.INDEX_UNSET, adPlaybackState);
|
||||||
}
|
}
|
||||||
|
@ -512,8 +512,8 @@ public class ChunkSampleStream<T extends ChunkSource>
|
|||||||
loadable.trackFormat,
|
loadable.trackFormat,
|
||||||
loadable.trackSelectionReason,
|
loadable.trackSelectionReason,
|
||||||
loadable.trackSelectionData,
|
loadable.trackSelectionData,
|
||||||
C.usToMs(loadable.startTimeUs),
|
Util.usToMs(loadable.startTimeUs),
|
||||||
C.usToMs(loadable.endTimeUs));
|
Util.usToMs(loadable.endTimeUs));
|
||||||
LoadErrorInfo loadErrorInfo =
|
LoadErrorInfo loadErrorInfo =
|
||||||
new LoadErrorInfo(loadEventInfo, mediaLoadData, error, errorCount);
|
new LoadErrorInfo(loadEventInfo, mediaLoadData, error, errorCount);
|
||||||
|
|
||||||
|
@ -37,6 +37,7 @@ import androidx.media3.common.TrackSelectionArray;
|
|||||||
import androidx.media3.common.VideoSize;
|
import androidx.media3.common.VideoSize;
|
||||||
import androidx.media3.common.util.Log;
|
import androidx.media3.common.util.Log;
|
||||||
import androidx.media3.common.util.UnstableApi;
|
import androidx.media3.common.util.UnstableApi;
|
||||||
|
import androidx.media3.common.util.Util;
|
||||||
import androidx.media3.exoplayer.DecoderCounters;
|
import androidx.media3.exoplayer.DecoderCounters;
|
||||||
import androidx.media3.exoplayer.DecoderReuseEvaluation;
|
import androidx.media3.exoplayer.DecoderReuseEvaluation;
|
||||||
import androidx.media3.exoplayer.RendererCapabilities;
|
import androidx.media3.exoplayer.RendererCapabilities;
|
||||||
@ -280,7 +281,7 @@ public class EventLogger implements AnalyticsListener {
|
|||||||
for (int trackIndex = 0; trackIndex < trackGroup.length; trackIndex++) {
|
for (int trackIndex = 0; trackIndex < trackGroup.length; trackIndex++) {
|
||||||
String status = getTrackStatusString(trackSelection, trackGroup, trackIndex);
|
String status = getTrackStatusString(trackSelection, trackGroup, trackIndex);
|
||||||
String formatSupport =
|
String formatSupport =
|
||||||
C.getFormatSupportString(
|
Util.getFormatSupportString(
|
||||||
mappedTrackInfo.getTrackSupport(rendererIndex, groupIndex, trackIndex));
|
mappedTrackInfo.getTrackSupport(rendererIndex, groupIndex, trackIndex));
|
||||||
logd(
|
logd(
|
||||||
" "
|
" "
|
||||||
@ -318,7 +319,7 @@ public class EventLogger implements AnalyticsListener {
|
|||||||
TrackGroup trackGroup = unassociatedTrackGroups.get(groupIndex);
|
TrackGroup trackGroup = unassociatedTrackGroups.get(groupIndex);
|
||||||
for (int trackIndex = 0; trackIndex < trackGroup.length; trackIndex++) {
|
for (int trackIndex = 0; trackIndex < trackGroup.length; trackIndex++) {
|
||||||
String status = getTrackStatusString(false);
|
String status = getTrackStatusString(false);
|
||||||
String formatSupport = C.getFormatSupportString(C.FORMAT_UNSUPPORTED_TYPE);
|
String formatSupport = Util.getFormatSupportString(C.FORMAT_UNSUPPORTED_TYPE);
|
||||||
logd(
|
logd(
|
||||||
" "
|
" "
|
||||||
+ status
|
+ status
|
||||||
|
@ -37,6 +37,7 @@ import androidx.media3.common.util.Log;
|
|||||||
import androidx.media3.common.util.TimedValueQueue;
|
import androidx.media3.common.util.TimedValueQueue;
|
||||||
import androidx.media3.common.util.TraceUtil;
|
import androidx.media3.common.util.TraceUtil;
|
||||||
import androidx.media3.common.util.UnstableApi;
|
import androidx.media3.common.util.UnstableApi;
|
||||||
|
import androidx.media3.common.util.Util;
|
||||||
import androidx.media3.decoder.CryptoConfig;
|
import androidx.media3.decoder.CryptoConfig;
|
||||||
import androidx.media3.decoder.Decoder;
|
import androidx.media3.decoder.Decoder;
|
||||||
import androidx.media3.decoder.DecoderException;
|
import androidx.media3.decoder.DecoderException;
|
||||||
@ -561,7 +562,7 @@ public abstract class DecoderVideoRenderer extends BaseRenderer {
|
|||||||
frameMetadataListener.onVideoFrameAboutToBeRendered(
|
frameMetadataListener.onVideoFrameAboutToBeRendered(
|
||||||
presentationTimeUs, System.nanoTime(), outputFormat, /* mediaFormat= */ null);
|
presentationTimeUs, System.nanoTime(), outputFormat, /* mediaFormat= */ null);
|
||||||
}
|
}
|
||||||
lastRenderTimeUs = C.msToUs(SystemClock.elapsedRealtime() * 1000);
|
lastRenderTimeUs = Util.msToUs(SystemClock.elapsedRealtime() * 1000);
|
||||||
int bufferMode = outputBuffer.mode;
|
int bufferMode = outputBuffer.mode;
|
||||||
boolean renderSurface = bufferMode == C.VIDEO_OUTPUT_MODE_SURFACE_YUV && outputSurface != null;
|
boolean renderSurface = bufferMode == C.VIDEO_OUTPUT_MODE_SURFACE_YUV && outputSurface != null;
|
||||||
boolean renderYuv = bufferMode == C.VIDEO_OUTPUT_MODE_YUV && outputBufferRenderer != null;
|
boolean renderYuv = bufferMode == C.VIDEO_OUTPUT_MODE_YUV && outputBufferRenderer != null;
|
||||||
|
@ -19,6 +19,7 @@ import static com.google.common.truth.Truth.assertThat;
|
|||||||
|
|
||||||
import androidx.media3.common.C;
|
import androidx.media3.common.C;
|
||||||
import androidx.media3.common.TrackGroupArray;
|
import androidx.media3.common.TrackGroupArray;
|
||||||
|
import androidx.media3.common.util.Util;
|
||||||
import androidx.media3.exoplayer.DefaultLoadControl.Builder;
|
import androidx.media3.exoplayer.DefaultLoadControl.Builder;
|
||||||
import androidx.media3.exoplayer.trackselection.ExoTrackSelection;
|
import androidx.media3.exoplayer.trackselection.ExoTrackSelection;
|
||||||
import androidx.media3.exoplayer.upstream.DefaultAllocator;
|
import androidx.media3.exoplayer.upstream.DefaultAllocator;
|
||||||
@ -32,7 +33,7 @@ import org.junit.runner.RunWith;
|
|||||||
public class DefaultLoadControlTest {
|
public class DefaultLoadControlTest {
|
||||||
|
|
||||||
private static final float SPEED = 1f;
|
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 long MIN_BUFFER_US = MAX_BUFFER_US / 2;
|
||||||
private static final int TARGET_BUFFER_BYTES = C.DEFAULT_BUFFER_SEGMENT_SIZE * 2;
|
private static final int TARGET_BUFFER_BYTES = C.DEFAULT_BUFFER_SEGMENT_SIZE * 2;
|
||||||
|
|
||||||
@ -65,8 +66,8 @@ public class DefaultLoadControlTest {
|
|||||||
@Test
|
@Test
|
||||||
public void shouldNotContinueLoadingOnceBufferingStopped_untilBelowMinBuffer() {
|
public void shouldNotContinueLoadingOnceBufferingStopped_untilBelowMinBuffer() {
|
||||||
builder.setBufferDurationsMs(
|
builder.setBufferDurationsMs(
|
||||||
/* minBufferMs= */ (int) C.usToMs(MIN_BUFFER_US),
|
/* minBufferMs= */ (int) Util.usToMs(MIN_BUFFER_US),
|
||||||
/* maxBufferMs= */ (int) C.usToMs(MAX_BUFFER_US),
|
/* maxBufferMs= */ (int) Util.usToMs(MAX_BUFFER_US),
|
||||||
/* bufferForPlaybackMs= */ 0,
|
/* bufferForPlaybackMs= */ 0,
|
||||||
/* bufferForPlaybackAfterRebufferMs= */ 0);
|
/* bufferForPlaybackAfterRebufferMs= */ 0);
|
||||||
build();
|
build();
|
||||||
@ -89,7 +90,7 @@ public class DefaultLoadControlTest {
|
|||||||
public void continueLoadingOnceBufferingStopped_andBufferAlmostEmpty_evenIfMinBufferNotReached() {
|
public void continueLoadingOnceBufferingStopped_andBufferAlmostEmpty_evenIfMinBufferNotReached() {
|
||||||
builder.setBufferDurationsMs(
|
builder.setBufferDurationsMs(
|
||||||
/* minBufferMs= */ 0,
|
/* minBufferMs= */ 0,
|
||||||
/* maxBufferMs= */ (int) C.usToMs(MAX_BUFFER_US),
|
/* maxBufferMs= */ (int) Util.usToMs(MAX_BUFFER_US),
|
||||||
/* bufferForPlaybackMs= */ 0,
|
/* bufferForPlaybackMs= */ 0,
|
||||||
/* bufferForPlaybackAfterRebufferMs= */ 0);
|
/* bufferForPlaybackAfterRebufferMs= */ 0);
|
||||||
build();
|
build();
|
||||||
@ -108,8 +109,8 @@ public class DefaultLoadControlTest {
|
|||||||
public void shouldContinueLoadingWithTargetBufferBytesReached_untilMinBufferReached() {
|
public void shouldContinueLoadingWithTargetBufferBytesReached_untilMinBufferReached() {
|
||||||
builder.setPrioritizeTimeOverSizeThresholds(true);
|
builder.setPrioritizeTimeOverSizeThresholds(true);
|
||||||
builder.setBufferDurationsMs(
|
builder.setBufferDurationsMs(
|
||||||
/* minBufferMs= */ (int) C.usToMs(MIN_BUFFER_US),
|
/* minBufferMs= */ (int) Util.usToMs(MIN_BUFFER_US),
|
||||||
/* maxBufferMs= */ (int) C.usToMs(MAX_BUFFER_US),
|
/* maxBufferMs= */ (int) Util.usToMs(MAX_BUFFER_US),
|
||||||
/* bufferForPlaybackMs= */ 0,
|
/* bufferForPlaybackMs= */ 0,
|
||||||
/* bufferForPlaybackAfterRebufferMs= */ 0);
|
/* bufferForPlaybackAfterRebufferMs= */ 0);
|
||||||
build();
|
build();
|
||||||
@ -159,8 +160,8 @@ public class DefaultLoadControlTest {
|
|||||||
@Test
|
@Test
|
||||||
public void shouldContinueLoadingWithMinBufferReached_inFastPlayback() {
|
public void shouldContinueLoadingWithMinBufferReached_inFastPlayback() {
|
||||||
builder.setBufferDurationsMs(
|
builder.setBufferDurationsMs(
|
||||||
/* minBufferMs= */ (int) C.usToMs(MIN_BUFFER_US),
|
/* minBufferMs= */ (int) Util.usToMs(MIN_BUFFER_US),
|
||||||
/* maxBufferMs= */ (int) C.usToMs(MAX_BUFFER_US),
|
/* maxBufferMs= */ (int) Util.usToMs(MAX_BUFFER_US),
|
||||||
/* bufferForPlaybackMs= */ 0,
|
/* bufferForPlaybackMs= */ 0,
|
||||||
/* bufferForPlaybackAfterRebufferMs= */ 0);
|
/* bufferForPlaybackAfterRebufferMs= */ 0);
|
||||||
build();
|
build();
|
||||||
|
@ -23,6 +23,7 @@ import static org.mockito.MockitoAnnotations.initMocks;
|
|||||||
|
|
||||||
import androidx.media3.common.C;
|
import androidx.media3.common.C;
|
||||||
import androidx.media3.common.PlaybackParameters;
|
import androidx.media3.common.PlaybackParameters;
|
||||||
|
import androidx.media3.common.util.Util;
|
||||||
import androidx.media3.exoplayer.DefaultMediaClock.PlaybackParametersListener;
|
import androidx.media3.exoplayer.DefaultMediaClock.PlaybackParametersListener;
|
||||||
import androidx.media3.test.utils.FakeClock;
|
import androidx.media3.test.utils.FakeClock;
|
||||||
import androidx.media3.test.utils.FakeMediaClockRenderer;
|
import androidx.media3.test.utils.FakeMediaClockRenderer;
|
||||||
@ -265,7 +266,7 @@ public class DefaultMediaClockTest {
|
|||||||
mediaClock.onRendererDisabled(mediaClockRenderer);
|
mediaClock.onRendererDisabled(mediaClockRenderer);
|
||||||
fakeClock.advanceTime(SLEEP_TIME_MS);
|
fakeClock.advanceTime(SLEEP_TIME_MS);
|
||||||
assertThat(mediaClock.syncAndGetPositionUs(/* isReadingAhead= */ false))
|
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);
|
assertClockIsRunning(/* isReadingAhead= */ false);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -331,7 +332,7 @@ public class DefaultMediaClockTest {
|
|||||||
mediaClockRenderer.positionUs = TEST_POSITION_US;
|
mediaClockRenderer.positionUs = TEST_POSITION_US;
|
||||||
mediaClock.onRendererDisabled(mediaClockRenderer);
|
mediaClock.onRendererDisabled(mediaClockRenderer);
|
||||||
assertThat(mediaClock.syncAndGetPositionUs(/* isReadingAhead= */ false))
|
assertThat(mediaClock.syncAndGetPositionUs(/* isReadingAhead= */ false))
|
||||||
.isEqualTo(C.msToUs(fakeClock.elapsedRealtime()));
|
.isEqualTo(Util.msToUs(fakeClock.elapsedRealtime()));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -108,6 +108,7 @@ import androidx.media3.common.TrackSelectionArray;
|
|||||||
import androidx.media3.common.TracksInfo;
|
import androidx.media3.common.TracksInfo;
|
||||||
import androidx.media3.common.util.Assertions;
|
import androidx.media3.common.util.Assertions;
|
||||||
import androidx.media3.common.util.Clock;
|
import androidx.media3.common.util.Clock;
|
||||||
|
import androidx.media3.common.util.Util;
|
||||||
import androidx.media3.datasource.TransferListener;
|
import androidx.media3.datasource.TransferListener;
|
||||||
import androidx.media3.exoplayer.analytics.AnalyticsListener;
|
import androidx.media3.exoplayer.analytics.AnalyticsListener;
|
||||||
import androidx.media3.exoplayer.drm.DrmSessionEventListener;
|
import androidx.media3.exoplayer.drm.DrmSessionEventListener;
|
||||||
@ -2775,7 +2776,7 @@ public final class ExoPlayerTest {
|
|||||||
// Ensure next period is pre-buffered by playing until end of first period.
|
// Ensure next period is pre-buffered by playing until end of first period.
|
||||||
.playUntilPosition(
|
.playUntilPosition(
|
||||||
/* windowIndex= */ 0,
|
/* windowIndex= */ 0,
|
||||||
/* positionMs= */ C.usToMs(TimelineWindowDefinition.DEFAULT_WINDOW_DURATION_US))
|
/* positionMs= */ Util.usToMs(TimelineWindowDefinition.DEFAULT_WINDOW_DURATION_US))
|
||||||
.executeRunnable(() -> mediaSource.setNewSourceInfo(timeline2))
|
.executeRunnable(() -> mediaSource.setNewSourceInfo(timeline2))
|
||||||
.waitForTimelineChanged(
|
.waitForTimelineChanged(
|
||||||
timeline2, /* expectedReason */ Player.TIMELINE_CHANGE_REASON_SOURCE_UPDATE)
|
timeline2, /* expectedReason */ Player.TIMELINE_CHANGE_REASON_SOURCE_UPDATE)
|
||||||
@ -2867,7 +2868,7 @@ public final class ExoPlayerTest {
|
|||||||
/* adsPerAdGroup= */ 1,
|
/* adsPerAdGroup= */ 1,
|
||||||
/* adGroupTimesUs...= */ TimelineWindowDefinition
|
/* adGroupTimesUs...= */ TimelineWindowDefinition
|
||||||
.DEFAULT_WINDOW_OFFSET_IN_FIRST_PERIOD_US
|
.DEFAULT_WINDOW_OFFSET_IN_FIRST_PERIOD_US
|
||||||
+ C.msToUs(adGroupWindowTimeMs));
|
+ Util.msToUs(adGroupWindowTimeMs));
|
||||||
Timeline timeline =
|
Timeline timeline =
|
||||||
new FakeTimeline(
|
new FakeTimeline(
|
||||||
new TimelineWindowDefinition(
|
new TimelineWindowDefinition(
|
||||||
@ -2875,7 +2876,7 @@ public final class ExoPlayerTest {
|
|||||||
/* id= */ 0,
|
/* id= */ 0,
|
||||||
/* isSeekable= */ true,
|
/* isSeekable= */ true,
|
||||||
/* isDynamic= */ false,
|
/* isDynamic= */ false,
|
||||||
/* durationUs= */ C.msToUs(contentDurationMs),
|
/* durationUs= */ Util.msToUs(contentDurationMs),
|
||||||
adPlaybackState));
|
adPlaybackState));
|
||||||
AtomicBoolean hasCreatedAdMediaPeriod = new AtomicBoolean();
|
AtomicBoolean hasCreatedAdMediaPeriod = new AtomicBoolean();
|
||||||
FakeMediaSource mediaSource =
|
FakeMediaSource mediaSource =
|
||||||
@ -3278,7 +3279,7 @@ public final class ExoPlayerTest {
|
|||||||
|
|
||||||
assertThat(positionAtDiscontinuityMs.get()).isAtLeast(0L);
|
assertThat(positionAtDiscontinuityMs.get()).isAtLeast(0L);
|
||||||
assertThat(clockAtDiscontinuityMs.get() - clockAtStartMs.get())
|
assertThat(clockAtDiscontinuityMs.get() - clockAtStartMs.get())
|
||||||
.isAtLeast(C.usToMs(expectedDurationUs));
|
.isAtLeast(Util.usToMs(expectedDurationUs));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@ -3497,7 +3498,8 @@ public final class ExoPlayerTest {
|
|||||||
.start()
|
.start()
|
||||||
.blockUntilEnded(TIMEOUT_MS);
|
.blockUntilEnded(TIMEOUT_MS);
|
||||||
|
|
||||||
assertThat(bufferedPositionAtFirstDiscontinuityMs.get()).isEqualTo(C.usToMs(windowDurationUs));
|
assertThat(bufferedPositionAtFirstDiscontinuityMs.get())
|
||||||
|
.isEqualTo(Util.usToMs(windowDurationUs));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@ -4613,7 +4615,7 @@ public final class ExoPlayerTest {
|
|||||||
ImmutableList.of(
|
ImmutableList.of(
|
||||||
oneByteSample(windowOffsetInFirstPeriodUs, C.BUFFER_FLAG_KEY_FRAME),
|
oneByteSample(windowOffsetInFirstPeriodUs, C.BUFFER_FLAG_KEY_FRAME),
|
||||||
oneByteSample(
|
oneByteSample(
|
||||||
windowOffsetInFirstPeriodUs + C.msToUs(maxBufferedPositionMs),
|
windowOffsetInFirstPeriodUs + Util.msToUs(maxBufferedPositionMs),
|
||||||
C.BUFFER_FLAG_KEY_FRAME)),
|
C.BUFFER_FLAG_KEY_FRAME)),
|
||||||
mediaSourceEventDispatcher,
|
mediaSourceEventDispatcher,
|
||||||
drmSessionManager,
|
drmSessionManager,
|
||||||
@ -4633,7 +4635,7 @@ public final class ExoPlayerTest {
|
|||||||
adPlaybackState =
|
adPlaybackState =
|
||||||
adPlaybackState.withAdUri(/* adGroupIndex= */ 0, /* adIndexInAdGroup= */ 0, Uri.EMPTY);
|
adPlaybackState.withAdUri(/* adGroupIndex= */ 0, /* adIndexInAdGroup= */ 0, Uri.EMPTY);
|
||||||
long[][] durationsUs = new long[1][];
|
long[][] durationsUs = new long[1][];
|
||||||
durationsUs[0] = new long[] {C.msToUs(adDurationMs)};
|
durationsUs[0] = new long[] {Util.msToUs(adDurationMs)};
|
||||||
adPlaybackState = adPlaybackState.withAdDurationsUs(durationsUs);
|
adPlaybackState = adPlaybackState.withAdDurationsUs(durationsUs);
|
||||||
Timeline adTimeline =
|
Timeline adTimeline =
|
||||||
new FakeTimeline(
|
new FakeTimeline(
|
||||||
@ -4642,7 +4644,7 @@ public final class ExoPlayerTest {
|
|||||||
/* id= */ 0,
|
/* id= */ 0,
|
||||||
/* isSeekable= */ true,
|
/* isSeekable= */ true,
|
||||||
/* isDynamic= */ false,
|
/* isDynamic= */ false,
|
||||||
/* durationUs= */ C.msToUs(contentDurationMs),
|
/* durationUs= */ Util.msToUs(contentDurationMs),
|
||||||
adPlaybackState));
|
adPlaybackState));
|
||||||
FakeMediaSource adsMediaSource = new FakeMediaSource(adTimeline);
|
FakeMediaSource adsMediaSource = new FakeMediaSource(adTimeline);
|
||||||
int[] windowIndex = new int[] {C.INDEX_UNSET, C.INDEX_UNSET, C.INDEX_UNSET};
|
int[] windowIndex = new int[] {C.INDEX_UNSET, C.INDEX_UNSET, C.INDEX_UNSET};
|
||||||
@ -4734,7 +4736,7 @@ public final class ExoPlayerTest {
|
|||||||
adPlaybackState =
|
adPlaybackState =
|
||||||
adPlaybackState.withAdUri(/* adGroupIndex= */ 0, /* adIndexInAdGroup= */ 0, Uri.EMPTY);
|
adPlaybackState.withAdUri(/* adGroupIndex= */ 0, /* adIndexInAdGroup= */ 0, Uri.EMPTY);
|
||||||
long[][] durationsUs = new long[1][];
|
long[][] durationsUs = new long[1][];
|
||||||
durationsUs[0] = new long[] {C.msToUs(adDurationMs)};
|
durationsUs[0] = new long[] {Util.msToUs(adDurationMs)};
|
||||||
adPlaybackState = adPlaybackState.withAdDurationsUs(durationsUs);
|
adPlaybackState = adPlaybackState.withAdDurationsUs(durationsUs);
|
||||||
Timeline adTimeline =
|
Timeline adTimeline =
|
||||||
new FakeTimeline(
|
new FakeTimeline(
|
||||||
@ -4743,7 +4745,7 @@ public final class ExoPlayerTest {
|
|||||||
/* id= */ 0,
|
/* id= */ 0,
|
||||||
/* isSeekable= */ true,
|
/* isSeekable= */ true,
|
||||||
/* isDynamic= */ false,
|
/* isDynamic= */ false,
|
||||||
/* durationUs= */ C.msToUs(contentDurationMs),
|
/* durationUs= */ Util.msToUs(contentDurationMs),
|
||||||
adPlaybackState));
|
adPlaybackState));
|
||||||
FakeMediaSource adsMediaSource = new FakeMediaSource(adTimeline);
|
FakeMediaSource adsMediaSource = new FakeMediaSource(adTimeline);
|
||||||
int[] windowIndex = new int[] {C.INDEX_UNSET, C.INDEX_UNSET};
|
int[] windowIndex = new int[] {C.INDEX_UNSET, C.INDEX_UNSET};
|
||||||
@ -4815,7 +4817,7 @@ public final class ExoPlayerTest {
|
|||||||
.withAdCount(/* adGroupIndex= */ 0, /* adCount= */ 1)
|
.withAdCount(/* adGroupIndex= */ 0, /* adCount= */ 1)
|
||||||
.withAdUri(/* adGroupIndex= */ 0, /* adIndexInAdGroup= */ 0, Uri.EMPTY);
|
.withAdUri(/* adGroupIndex= */ 0, /* adIndexInAdGroup= */ 0, Uri.EMPTY);
|
||||||
long[][] durationsUs = new long[1][];
|
long[][] durationsUs = new long[1][];
|
||||||
durationsUs[0] = new long[] {C.msToUs(adDurationMs)};
|
durationsUs[0] = new long[] {Util.msToUs(adDurationMs)};
|
||||||
adPlaybackState = adPlaybackState.withAdDurationsUs(durationsUs);
|
adPlaybackState = adPlaybackState.withAdDurationsUs(durationsUs);
|
||||||
Timeline adTimeline =
|
Timeline adTimeline =
|
||||||
new FakeTimeline(
|
new FakeTimeline(
|
||||||
@ -4824,7 +4826,7 @@ public final class ExoPlayerTest {
|
|||||||
/* id= */ 0,
|
/* id= */ 0,
|
||||||
/* isSeekable= */ true,
|
/* isSeekable= */ true,
|
||||||
/* isDynamic= */ false,
|
/* isDynamic= */ false,
|
||||||
/* durationUs= */ C.msToUs(contentDurationMs),
|
/* durationUs= */ Util.msToUs(contentDurationMs),
|
||||||
adPlaybackState));
|
adPlaybackState));
|
||||||
FakeMediaSource adsMediaSource = new FakeMediaSource(adTimeline);
|
FakeMediaSource adsMediaSource = new FakeMediaSource(adTimeline);
|
||||||
|
|
||||||
@ -5047,7 +5049,7 @@ public final class ExoPlayerTest {
|
|||||||
/* id= */ 0,
|
/* id= */ 0,
|
||||||
/* isSeekable= */ true,
|
/* isSeekable= */ true,
|
||||||
/* isDynamic= */ false,
|
/* isDynamic= */ false,
|
||||||
/* durationUs= */ C.msToUs(10000),
|
/* durationUs= */ Util.msToUs(10000),
|
||||||
adPlaybackState));
|
adPlaybackState));
|
||||||
// Simulate the second ad not being prepared.
|
// Simulate the second ad not being prepared.
|
||||||
FakeMediaSource mediaSource =
|
FakeMediaSource mediaSource =
|
||||||
@ -5088,14 +5090,14 @@ public final class ExoPlayerTest {
|
|||||||
/* id= */ 1,
|
/* id= */ 1,
|
||||||
/* isSeekable= */ true,
|
/* isSeekable= */ true,
|
||||||
/* isDynamic= */ false,
|
/* isDynamic= */ false,
|
||||||
/* durationUs= */ C.msToUs(10000));
|
/* durationUs= */ Util.msToUs(10000));
|
||||||
TimelineWindowDefinition secondWindowDefinition =
|
TimelineWindowDefinition secondWindowDefinition =
|
||||||
new TimelineWindowDefinition(
|
new TimelineWindowDefinition(
|
||||||
/* periodCount= */ 1,
|
/* periodCount= */ 1,
|
||||||
/* id= */ 2,
|
/* id= */ 2,
|
||||||
/* isSeekable= */ true,
|
/* isSeekable= */ true,
|
||||||
/* isDynamic= */ false,
|
/* isDynamic= */ false,
|
||||||
/* durationUs= */ C.msToUs(10000));
|
/* durationUs= */ Util.msToUs(10000));
|
||||||
Timeline timeline1 = new FakeTimeline(firstWindowDefinition);
|
Timeline timeline1 = new FakeTimeline(firstWindowDefinition);
|
||||||
Timeline timeline2 = new FakeTimeline(secondWindowDefinition);
|
Timeline timeline2 = new FakeTimeline(secondWindowDefinition);
|
||||||
MediaSource mediaSource1 = new FakeMediaSource(timeline1);
|
MediaSource mediaSource1 = new FakeMediaSource(timeline1);
|
||||||
@ -5138,21 +5140,21 @@ public final class ExoPlayerTest {
|
|||||||
/* id= */ 1,
|
/* id= */ 1,
|
||||||
/* isSeekable= */ true,
|
/* isSeekable= */ true,
|
||||||
/* isDynamic= */ false,
|
/* isDynamic= */ false,
|
||||||
/* durationUs= */ C.msToUs(10000));
|
/* durationUs= */ Util.msToUs(10000));
|
||||||
TimelineWindowDefinition secondWindowDefinition =
|
TimelineWindowDefinition secondWindowDefinition =
|
||||||
new TimelineWindowDefinition(
|
new TimelineWindowDefinition(
|
||||||
/* periodCount= */ 1,
|
/* periodCount= */ 1,
|
||||||
/* id= */ 2,
|
/* id= */ 2,
|
||||||
/* isSeekable= */ true,
|
/* isSeekable= */ true,
|
||||||
/* isDynamic= */ false,
|
/* isDynamic= */ false,
|
||||||
/* durationUs= */ C.msToUs(10000));
|
/* durationUs= */ Util.msToUs(10000));
|
||||||
TimelineWindowDefinition thirdWindowDefinition =
|
TimelineWindowDefinition thirdWindowDefinition =
|
||||||
new TimelineWindowDefinition(
|
new TimelineWindowDefinition(
|
||||||
/* periodCount= */ 1,
|
/* periodCount= */ 1,
|
||||||
/* id= */ 3,
|
/* id= */ 3,
|
||||||
/* isSeekable= */ true,
|
/* isSeekable= */ true,
|
||||||
/* isDynamic= */ false,
|
/* isDynamic= */ false,
|
||||||
/* durationUs= */ C.msToUs(10000));
|
/* durationUs= */ Util.msToUs(10000));
|
||||||
Timeline timeline1 = new FakeTimeline(firstWindowDefinition);
|
Timeline timeline1 = new FakeTimeline(firstWindowDefinition);
|
||||||
Timeline timeline2 = new FakeTimeline(secondWindowDefinition);
|
Timeline timeline2 = new FakeTimeline(secondWindowDefinition);
|
||||||
Timeline timeline3 = new FakeTimeline(thirdWindowDefinition);
|
Timeline timeline3 = new FakeTimeline(thirdWindowDefinition);
|
||||||
@ -5198,21 +5200,21 @@ public final class ExoPlayerTest {
|
|||||||
/* id= */ 1,
|
/* id= */ 1,
|
||||||
/* isSeekable= */ true,
|
/* isSeekable= */ true,
|
||||||
/* isDynamic= */ false,
|
/* isDynamic= */ false,
|
||||||
/* durationUs= */ C.msToUs(10000));
|
/* durationUs= */ Util.msToUs(10000));
|
||||||
TimelineWindowDefinition secondWindowDefinition =
|
TimelineWindowDefinition secondWindowDefinition =
|
||||||
new TimelineWindowDefinition(
|
new TimelineWindowDefinition(
|
||||||
/* periodCount= */ 1,
|
/* periodCount= */ 1,
|
||||||
/* id= */ 2,
|
/* id= */ 2,
|
||||||
/* isSeekable= */ true,
|
/* isSeekable= */ true,
|
||||||
/* isDynamic= */ false,
|
/* isDynamic= */ false,
|
||||||
/* durationUs= */ C.msToUs(10000));
|
/* durationUs= */ Util.msToUs(10000));
|
||||||
TimelineWindowDefinition thirdWindowDefinition =
|
TimelineWindowDefinition thirdWindowDefinition =
|
||||||
new TimelineWindowDefinition(
|
new TimelineWindowDefinition(
|
||||||
/* periodCount= */ 1,
|
/* periodCount= */ 1,
|
||||||
/* id= */ 3,
|
/* id= */ 3,
|
||||||
/* isSeekable= */ true,
|
/* isSeekable= */ true,
|
||||||
/* isDynamic= */ false,
|
/* isDynamic= */ false,
|
||||||
/* durationUs= */ C.msToUs(10000));
|
/* durationUs= */ Util.msToUs(10000));
|
||||||
Timeline timeline1 = new FakeTimeline(firstWindowDefinition);
|
Timeline timeline1 = new FakeTimeline(firstWindowDefinition);
|
||||||
Timeline timeline2 = new FakeTimeline(secondWindowDefinition);
|
Timeline timeline2 = new FakeTimeline(secondWindowDefinition);
|
||||||
Timeline timeline3 = new FakeTimeline(thirdWindowDefinition);
|
Timeline timeline3 = new FakeTimeline(thirdWindowDefinition);
|
||||||
@ -8364,7 +8366,7 @@ public final class ExoPlayerTest {
|
|||||||
new AdPlaybackState(/* adsId= */ new Object(), /* adGroupTimesUs...= */ 0)
|
new AdPlaybackState(/* adsId= */ new Object(), /* adGroupTimesUs...= */ 0)
|
||||||
.withAdCount(/* adGroupIndex= */ 0, /* adCount= */ 1)
|
.withAdCount(/* adGroupIndex= */ 0, /* adCount= */ 1)
|
||||||
.withAdUri(/* adGroupIndex= */ 0, /* adIndexInAdGroup= */ 0, Uri.EMPTY)
|
.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 =
|
Timeline adTimeline =
|
||||||
new FakeTimeline(
|
new FakeTimeline(
|
||||||
new TimelineWindowDefinition(
|
new TimelineWindowDefinition(
|
||||||
@ -8372,7 +8374,7 @@ public final class ExoPlayerTest {
|
|||||||
/* id= */ 0,
|
/* id= */ 0,
|
||||||
/* isSeekable= */ true,
|
/* isSeekable= */ true,
|
||||||
/* isDynamic= */ false,
|
/* isDynamic= */ false,
|
||||||
/* durationUs= */ C.msToUs(10_000),
|
/* durationUs= */ Util.msToUs(10_000),
|
||||||
adPlaybackState));
|
adPlaybackState));
|
||||||
ExoPlayer player = new TestExoPlayerBuilder(context).build();
|
ExoPlayer player = new TestExoPlayerBuilder(context).build();
|
||||||
|
|
||||||
@ -8401,7 +8403,7 @@ public final class ExoPlayerTest {
|
|||||||
new TimelineWindowDefinition(
|
new TimelineWindowDefinition(
|
||||||
/* isSeekable= */ false,
|
/* isSeekable= */ false,
|
||||||
/* isDynamic= */ false,
|
/* isDynamic= */ false,
|
||||||
/* durationUs= */ C.msToUs(10_000)));
|
/* durationUs= */ Util.msToUs(10_000)));
|
||||||
ExoPlayer player = new TestExoPlayerBuilder(context).build();
|
ExoPlayer player = new TestExoPlayerBuilder(context).build();
|
||||||
|
|
||||||
player.addMediaSource(new FakeMediaSource(timelineWithUnseekableWindow));
|
player.addMediaSource(new FakeMediaSource(timelineWithUnseekableWindow));
|
||||||
@ -9117,7 +9119,7 @@ public final class ExoPlayerTest {
|
|||||||
/* isPlaceholder= */ false,
|
/* isPlaceholder= */ false,
|
||||||
/* durationUs= */ 1000 * C.MICROS_PER_SECOND,
|
/* durationUs= */ 1000 * C.MICROS_PER_SECOND,
|
||||||
/* defaultPositionUs= */ 8 * C.MICROS_PER_SECOND,
|
/* defaultPositionUs= */ 8 * C.MICROS_PER_SECOND,
|
||||||
/* windowOffsetInFirstPeriodUs= */ C.msToUs(windowStartUnixTimeMs),
|
/* windowOffsetInFirstPeriodUs= */ Util.msToUs(windowStartUnixTimeMs),
|
||||||
AdPlaybackState.NONE,
|
AdPlaybackState.NONE,
|
||||||
new MediaItem.Builder()
|
new MediaItem.Builder()
|
||||||
.setUri(Uri.EMPTY)
|
.setUri(Uri.EMPTY)
|
||||||
@ -9166,7 +9168,7 @@ public final class ExoPlayerTest {
|
|||||||
/* isPlaceholder= */ false,
|
/* isPlaceholder= */ false,
|
||||||
/* durationUs= */ 1000 * C.MICROS_PER_SECOND,
|
/* durationUs= */ 1000 * C.MICROS_PER_SECOND,
|
||||||
/* defaultPositionUs= */ 8 * C.MICROS_PER_SECOND,
|
/* defaultPositionUs= */ 8 * C.MICROS_PER_SECOND,
|
||||||
/* windowOffsetInFirstPeriodUs= */ C.msToUs(windowStartUnixTimeMs),
|
/* windowOffsetInFirstPeriodUs= */ Util.msToUs(windowStartUnixTimeMs),
|
||||||
AdPlaybackState.NONE,
|
AdPlaybackState.NONE,
|
||||||
new MediaItem.Builder()
|
new MediaItem.Builder()
|
||||||
.setUri(Uri.EMPTY)
|
.setUri(Uri.EMPTY)
|
||||||
@ -9211,7 +9213,7 @@ public final class ExoPlayerTest {
|
|||||||
/* isPlaceholder= */ false,
|
/* isPlaceholder= */ false,
|
||||||
/* durationUs= */ 1000 * C.MICROS_PER_SECOND,
|
/* durationUs= */ 1000 * C.MICROS_PER_SECOND,
|
||||||
/* defaultPositionUs= */ 8 * C.MICROS_PER_SECOND,
|
/* defaultPositionUs= */ 8 * C.MICROS_PER_SECOND,
|
||||||
/* windowOffsetInFirstPeriodUs= */ C.msToUs(windowStartUnixTimeMs),
|
/* windowOffsetInFirstPeriodUs= */ Util.msToUs(windowStartUnixTimeMs),
|
||||||
AdPlaybackState.NONE,
|
AdPlaybackState.NONE,
|
||||||
new MediaItem.Builder()
|
new MediaItem.Builder()
|
||||||
.setUri(Uri.EMPTY)
|
.setUri(Uri.EMPTY)
|
||||||
@ -9258,7 +9260,7 @@ public final class ExoPlayerTest {
|
|||||||
/* isPlaceholder= */ false,
|
/* isPlaceholder= */ false,
|
||||||
/* durationUs= */ 1000 * C.MICROS_PER_SECOND,
|
/* durationUs= */ 1000 * C.MICROS_PER_SECOND,
|
||||||
/* defaultPositionUs= */ 8 * C.MICROS_PER_SECOND,
|
/* defaultPositionUs= */ 8 * C.MICROS_PER_SECOND,
|
||||||
/* windowOffsetInFirstPeriodUs= */ C.msToUs(windowStartUnixTimeMs),
|
/* windowOffsetInFirstPeriodUs= */ Util.msToUs(windowStartUnixTimeMs),
|
||||||
AdPlaybackState.NONE,
|
AdPlaybackState.NONE,
|
||||||
new MediaItem.Builder()
|
new MediaItem.Builder()
|
||||||
.setUri(Uri.EMPTY)
|
.setUri(Uri.EMPTY)
|
||||||
@ -9276,7 +9278,7 @@ public final class ExoPlayerTest {
|
|||||||
/* isPlaceholder= */ false,
|
/* isPlaceholder= */ false,
|
||||||
/* durationUs= */ 1000 * C.MICROS_PER_SECOND,
|
/* durationUs= */ 1000 * C.MICROS_PER_SECOND,
|
||||||
/* defaultPositionUs= */ 8 * C.MICROS_PER_SECOND,
|
/* defaultPositionUs= */ 8 * C.MICROS_PER_SECOND,
|
||||||
/* windowOffsetInFirstPeriodUs= */ C.msToUs(windowStartUnixTimeMs + 50_000),
|
/* windowOffsetInFirstPeriodUs= */ Util.msToUs(windowStartUnixTimeMs + 50_000),
|
||||||
AdPlaybackState.NONE,
|
AdPlaybackState.NONE,
|
||||||
new MediaItem.Builder()
|
new MediaItem.Builder()
|
||||||
.setUri(Uri.EMPTY)
|
.setUri(Uri.EMPTY)
|
||||||
@ -9340,7 +9342,7 @@ public final class ExoPlayerTest {
|
|||||||
/* isPlaceholder= */ false,
|
/* isPlaceholder= */ false,
|
||||||
/* durationUs= */ 1000 * C.MICROS_PER_SECOND,
|
/* durationUs= */ 1000 * C.MICROS_PER_SECOND,
|
||||||
/* defaultPositionUs= */ 20 * C.MICROS_PER_SECOND,
|
/* defaultPositionUs= */ 20 * C.MICROS_PER_SECOND,
|
||||||
/* windowOffsetInFirstPeriodUs= */ C.msToUs(windowStartUnixTimeMs),
|
/* windowOffsetInFirstPeriodUs= */ Util.msToUs(windowStartUnixTimeMs),
|
||||||
AdPlaybackState.NONE,
|
AdPlaybackState.NONE,
|
||||||
new MediaItem.Builder()
|
new MediaItem.Builder()
|
||||||
.setUri(Uri.EMPTY)
|
.setUri(Uri.EMPTY)
|
||||||
@ -9393,7 +9395,7 @@ public final class ExoPlayerTest {
|
|||||||
/* isPlaceholder= */ false,
|
/* isPlaceholder= */ false,
|
||||||
/* durationUs= */ 1000 * C.MICROS_PER_SECOND,
|
/* durationUs= */ 1000 * C.MICROS_PER_SECOND,
|
||||||
/* defaultPositionUs= */ 8 * C.MICROS_PER_SECOND,
|
/* defaultPositionUs= */ 8 * C.MICROS_PER_SECOND,
|
||||||
/* windowOffsetInFirstPeriodUs= */ C.msToUs(windowStartUnixTimeMs),
|
/* windowOffsetInFirstPeriodUs= */ Util.msToUs(windowStartUnixTimeMs),
|
||||||
AdPlaybackState.NONE,
|
AdPlaybackState.NONE,
|
||||||
new MediaItem.Builder()
|
new MediaItem.Builder()
|
||||||
.setUri(Uri.EMPTY)
|
.setUri(Uri.EMPTY)
|
||||||
@ -9437,7 +9439,7 @@ public final class ExoPlayerTest {
|
|||||||
/* isPlaceholder= */ false,
|
/* isPlaceholder= */ false,
|
||||||
/* durationUs= */ 1000 * C.MICROS_PER_SECOND,
|
/* durationUs= */ 1000 * C.MICROS_PER_SECOND,
|
||||||
/* defaultPositionUs= */ 8 * C.MICROS_PER_SECOND,
|
/* defaultPositionUs= */ 8 * C.MICROS_PER_SECOND,
|
||||||
/* windowOffsetInFirstPeriodUs= */ C.msToUs(windowStartUnixTimeMs),
|
/* windowOffsetInFirstPeriodUs= */ Util.msToUs(windowStartUnixTimeMs),
|
||||||
AdPlaybackState.NONE,
|
AdPlaybackState.NONE,
|
||||||
new MediaItem.Builder()
|
new MediaItem.Builder()
|
||||||
.setUri(Uri.EMPTY)
|
.setUri(Uri.EMPTY)
|
||||||
@ -9455,7 +9457,7 @@ public final class ExoPlayerTest {
|
|||||||
/* isPlaceholder= */ false,
|
/* isPlaceholder= */ false,
|
||||||
/* durationUs= */ 1000 * C.MICROS_PER_SECOND,
|
/* durationUs= */ 1000 * C.MICROS_PER_SECOND,
|
||||||
/* defaultPositionUs= */ 8 * C.MICROS_PER_SECOND,
|
/* defaultPositionUs= */ 8 * C.MICROS_PER_SECOND,
|
||||||
/* windowOffsetInFirstPeriodUs= */ C.msToUs(windowStartUnixTimeMs),
|
/* windowOffsetInFirstPeriodUs= */ Util.msToUs(windowStartUnixTimeMs),
|
||||||
AdPlaybackState.NONE,
|
AdPlaybackState.NONE,
|
||||||
new MediaItem.Builder()
|
new MediaItem.Builder()
|
||||||
.setUri(Uri.EMPTY)
|
.setUri(Uri.EMPTY)
|
||||||
@ -9503,7 +9505,7 @@ public final class ExoPlayerTest {
|
|||||||
/* isPlaceholder= */ false,
|
/* isPlaceholder= */ false,
|
||||||
/* durationUs= */ 1000 * C.MICROS_PER_SECOND,
|
/* durationUs= */ 1000 * C.MICROS_PER_SECOND,
|
||||||
/* defaultPositionUs= */ 8 * C.MICROS_PER_SECOND,
|
/* defaultPositionUs= */ 8 * C.MICROS_PER_SECOND,
|
||||||
/* windowOffsetInFirstPeriodUs= */ C.msToUs(windowStartUnixTimeMs),
|
/* windowOffsetInFirstPeriodUs= */ Util.msToUs(windowStartUnixTimeMs),
|
||||||
AdPlaybackState.NONE,
|
AdPlaybackState.NONE,
|
||||||
new MediaItem.Builder()
|
new MediaItem.Builder()
|
||||||
.setUri(Uri.EMPTY)
|
.setUri(Uri.EMPTY)
|
||||||
@ -9521,7 +9523,7 @@ public final class ExoPlayerTest {
|
|||||||
/* isPlaceholder= */ false,
|
/* isPlaceholder= */ false,
|
||||||
/* durationUs= */ 1000 * C.MICROS_PER_SECOND,
|
/* durationUs= */ 1000 * C.MICROS_PER_SECOND,
|
||||||
/* defaultPositionUs= */ 8 * C.MICROS_PER_SECOND,
|
/* defaultPositionUs= */ 8 * C.MICROS_PER_SECOND,
|
||||||
/* windowOffsetInFirstPeriodUs= */ C.msToUs(windowStartUnixTimeMs),
|
/* windowOffsetInFirstPeriodUs= */ Util.msToUs(windowStartUnixTimeMs),
|
||||||
AdPlaybackState.NONE,
|
AdPlaybackState.NONE,
|
||||||
new MediaItem.Builder()
|
new MediaItem.Builder()
|
||||||
.setUri(Uri.EMPTY)
|
.setUri(Uri.EMPTY)
|
||||||
@ -9609,7 +9611,7 @@ public final class ExoPlayerTest {
|
|||||||
/* isPlaceholder= */ false,
|
/* isPlaceholder= */ false,
|
||||||
/* durationUs= */ 1000 * C.MICROS_PER_SECOND,
|
/* durationUs= */ 1000 * C.MICROS_PER_SECOND,
|
||||||
/* defaultPositionUs= */ 8 * C.MICROS_PER_SECOND,
|
/* defaultPositionUs= */ 8 * C.MICROS_PER_SECOND,
|
||||||
/* windowOffsetInFirstPeriodUs= */ C.msToUs(windowStartUnixTimeMs),
|
/* windowOffsetInFirstPeriodUs= */ Util.msToUs(windowStartUnixTimeMs),
|
||||||
AdPlaybackState.NONE,
|
AdPlaybackState.NONE,
|
||||||
new MediaItem.Builder().setUri(Uri.EMPTY).build()));
|
new MediaItem.Builder().setUri(Uri.EMPTY).build()));
|
||||||
player.pause();
|
player.pause();
|
||||||
@ -10818,7 +10820,7 @@ public final class ExoPlayerTest {
|
|||||||
new TimelineWindowDefinition(
|
new TimelineWindowDefinition(
|
||||||
/* isSeekable= */ true,
|
/* isSeekable= */ true,
|
||||||
/* isDynamic= */ 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.setMediaSource(new FakeMediaSource(fakeTimeline));
|
||||||
|
|
||||||
player.prepare();
|
player.prepare();
|
||||||
@ -10865,7 +10867,7 @@ public final class ExoPlayerTest {
|
|||||||
new TimelineWindowDefinition(
|
new TimelineWindowDefinition(
|
||||||
/* isSeekable= */ true,
|
/* isSeekable= */ true,
|
||||||
/* isDynamic= */ 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.setMediaSource(new FakeMediaSource(fakeTimeline));
|
||||||
|
|
||||||
player.prepare();
|
player.prepare();
|
||||||
@ -10888,7 +10890,7 @@ public final class ExoPlayerTest {
|
|||||||
new TimelineWindowDefinition(
|
new TimelineWindowDefinition(
|
||||||
/* isSeekable= */ true,
|
/* isSeekable= */ true,
|
||||||
/* isDynamic= */ 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.setMediaSource(new FakeMediaSource(fakeTimeline));
|
||||||
|
|
||||||
player.prepare();
|
player.prepare();
|
||||||
@ -10925,7 +10927,7 @@ public final class ExoPlayerTest {
|
|||||||
new TimelineWindowDefinition(
|
new TimelineWindowDefinition(
|
||||||
/* isSeekable= */ true,
|
/* isSeekable= */ true,
|
||||||
/* isDynamic= */ 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.setMediaSource(new FakeMediaSource(fakeTimeline));
|
||||||
|
|
||||||
player.prepare();
|
player.prepare();
|
||||||
|
@ -909,7 +909,7 @@ public final class DashMediaSource extends BaseMediaSource {
|
|||||||
int lastPeriodIndex = manifest.getPeriodCount() - 1;
|
int lastPeriodIndex = manifest.getPeriodCount() - 1;
|
||||||
Period lastPeriod = manifest.getPeriod(lastPeriodIndex);
|
Period lastPeriod = manifest.getPeriod(lastPeriodIndex);
|
||||||
long lastPeriodDurationUs = manifest.getPeriodDurationUs(lastPeriodIndex);
|
long lastPeriodDurationUs = manifest.getPeriodDurationUs(lastPeriodIndex);
|
||||||
long nowUnixTimeUs = C.msToUs(Util.getNowUnixTimeMs(elapsedRealtimeOffsetMs));
|
long nowUnixTimeUs = Util.msToUs(Util.getNowUnixTimeMs(elapsedRealtimeOffsetMs));
|
||||||
long windowStartTimeInManifestUs =
|
long windowStartTimeInManifestUs =
|
||||||
getAvailableStartTimeInManifestUs(
|
getAvailableStartTimeInManifestUs(
|
||||||
firstPeriod, manifest.getPeriodDurationUs(0), nowUnixTimeUs);
|
firstPeriod, manifest.getPeriodDurationUs(0), nowUnixTimeUs);
|
||||||
@ -919,7 +919,7 @@ public final class DashMediaSource extends BaseMediaSource {
|
|||||||
if (windowChangingImplicitly && manifest.timeShiftBufferDepthMs != C.TIME_UNSET) {
|
if (windowChangingImplicitly && manifest.timeShiftBufferDepthMs != C.TIME_UNSET) {
|
||||||
// Update the available start time to reflect the manifest's time shift buffer depth.
|
// Update the available start time to reflect the manifest's time shift buffer depth.
|
||||||
long timeShiftBufferStartTimeInManifestUs =
|
long timeShiftBufferStartTimeInManifestUs =
|
||||||
windowEndTimeInManifestUs - C.msToUs(manifest.timeShiftBufferDepthMs);
|
windowEndTimeInManifestUs - Util.msToUs(manifest.timeShiftBufferDepthMs);
|
||||||
windowStartTimeInManifestUs =
|
windowStartTimeInManifestUs =
|
||||||
max(windowStartTimeInManifestUs, timeShiftBufferStartTimeInManifestUs);
|
max(windowStartTimeInManifestUs, timeShiftBufferStartTimeInManifestUs);
|
||||||
}
|
}
|
||||||
@ -929,11 +929,13 @@ public final class DashMediaSource extends BaseMediaSource {
|
|||||||
if (manifest.dynamic) {
|
if (manifest.dynamic) {
|
||||||
checkState(manifest.availabilityStartTimeMs != C.TIME_UNSET);
|
checkState(manifest.availabilityStartTimeMs != C.TIME_UNSET);
|
||||||
long nowInWindowUs =
|
long nowInWindowUs =
|
||||||
nowUnixTimeUs - C.msToUs(manifest.availabilityStartTimeMs) - windowStartTimeInManifestUs;
|
nowUnixTimeUs
|
||||||
|
- Util.msToUs(manifest.availabilityStartTimeMs)
|
||||||
|
- windowStartTimeInManifestUs;
|
||||||
updateMediaItemLiveConfiguration(nowInWindowUs, windowDurationUs);
|
updateMediaItemLiveConfiguration(nowInWindowUs, windowDurationUs);
|
||||||
windowStartUnixTimeMs =
|
windowStartUnixTimeMs =
|
||||||
manifest.availabilityStartTimeMs + C.usToMs(windowStartTimeInManifestUs);
|
manifest.availabilityStartTimeMs + Util.usToMs(windowStartTimeInManifestUs);
|
||||||
windowDefaultPositionUs = nowInWindowUs - C.msToUs(liveConfiguration.targetOffsetMs);
|
windowDefaultPositionUs = nowInWindowUs - Util.msToUs(liveConfiguration.targetOffsetMs);
|
||||||
long minimumWindowDefaultPositionUs =
|
long minimumWindowDefaultPositionUs =
|
||||||
min(MIN_LIVE_DEFAULT_START_POSITION_US, windowDurationUs / 2);
|
min(MIN_LIVE_DEFAULT_START_POSITION_US, windowDurationUs / 2);
|
||||||
if (windowDefaultPositionUs < minimumWindowDefaultPositionUs) {
|
if (windowDefaultPositionUs < minimumWindowDefaultPositionUs) {
|
||||||
@ -943,7 +945,7 @@ public final class DashMediaSource extends BaseMediaSource {
|
|||||||
windowDefaultPositionUs = minimumWindowDefaultPositionUs;
|
windowDefaultPositionUs = minimumWindowDefaultPositionUs;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
long offsetInFirstPeriodUs = windowStartTimeInManifestUs - C.msToUs(firstPeriod.startMs);
|
long offsetInFirstPeriodUs = windowStartTimeInManifestUs - Util.msToUs(firstPeriod.startMs);
|
||||||
DashTimeline timeline =
|
DashTimeline timeline =
|
||||||
new DashTimeline(
|
new DashTimeline(
|
||||||
manifest.availabilityStartTimeMs,
|
manifest.availabilityStartTimeMs,
|
||||||
@ -997,7 +999,7 @@ public final class DashMediaSource extends BaseMediaSource {
|
|||||||
&& manifest.serviceDescription.maxOffsetMs != C.TIME_UNSET) {
|
&& manifest.serviceDescription.maxOffsetMs != C.TIME_UNSET) {
|
||||||
maxLiveOffsetMs = manifest.serviceDescription.maxOffsetMs;
|
maxLiveOffsetMs = manifest.serviceDescription.maxOffsetMs;
|
||||||
} else {
|
} else {
|
||||||
maxLiveOffsetMs = C.usToMs(nowInWindowUs);
|
maxLiveOffsetMs = Util.usToMs(nowInWindowUs);
|
||||||
}
|
}
|
||||||
long minLiveOffsetMs;
|
long minLiveOffsetMs;
|
||||||
if (mediaItem.liveConfiguration.minOffsetMs != C.TIME_UNSET) {
|
if (mediaItem.liveConfiguration.minOffsetMs != C.TIME_UNSET) {
|
||||||
@ -1006,7 +1008,7 @@ public final class DashMediaSource extends BaseMediaSource {
|
|||||||
&& manifest.serviceDescription.minOffsetMs != C.TIME_UNSET) {
|
&& manifest.serviceDescription.minOffsetMs != C.TIME_UNSET) {
|
||||||
minLiveOffsetMs = manifest.serviceDescription.minOffsetMs;
|
minLiveOffsetMs = manifest.serviceDescription.minOffsetMs;
|
||||||
} else {
|
} else {
|
||||||
minLiveOffsetMs = C.usToMs(nowInWindowUs - windowDurationUs);
|
minLiveOffsetMs = Util.usToMs(nowInWindowUs - windowDurationUs);
|
||||||
if (minLiveOffsetMs < 0 && maxLiveOffsetMs > 0) {
|
if (minLiveOffsetMs < 0 && maxLiveOffsetMs > 0) {
|
||||||
// The current time is in the window, so assume all clocks are synchronized and set the
|
// The current time is in the window, so assume all clocks are synchronized and set the
|
||||||
// minimum to a live offset of zero.
|
// minimum to a live offset of zero.
|
||||||
@ -1035,7 +1037,7 @@ public final class DashMediaSource extends BaseMediaSource {
|
|||||||
long safeDistanceFromWindowStartUs =
|
long safeDistanceFromWindowStartUs =
|
||||||
min(MIN_LIVE_DEFAULT_START_POSITION_US, windowDurationUs / 2);
|
min(MIN_LIVE_DEFAULT_START_POSITION_US, windowDurationUs / 2);
|
||||||
long maxTargetOffsetForSafeDistanceToWindowStartMs =
|
long maxTargetOffsetForSafeDistanceToWindowStartMs =
|
||||||
C.usToMs(nowInWindowUs - safeDistanceFromWindowStartUs);
|
Util.usToMs(nowInWindowUs - safeDistanceFromWindowStartUs);
|
||||||
targetOffsetMs =
|
targetOffsetMs =
|
||||||
Util.constrainValue(
|
Util.constrainValue(
|
||||||
maxTargetOffsetForSafeDistanceToWindowStartMs, minLiveOffsetMs, maxLiveOffsetMs);
|
maxTargetOffsetForSafeDistanceToWindowStartMs, minLiveOffsetMs, maxLiveOffsetMs);
|
||||||
@ -1099,11 +1101,11 @@ public final class DashMediaSource extends BaseMediaSource {
|
|||||||
DashManifest manifest, long nowUnixTimeMs) {
|
DashManifest manifest, long nowUnixTimeMs) {
|
||||||
int periodIndex = manifest.getPeriodCount() - 1;
|
int periodIndex = manifest.getPeriodCount() - 1;
|
||||||
Period period = manifest.getPeriod(periodIndex);
|
Period period = manifest.getPeriod(periodIndex);
|
||||||
long periodStartUs = C.msToUs(period.startMs);
|
long periodStartUs = Util.msToUs(period.startMs);
|
||||||
long periodDurationUs = manifest.getPeriodDurationUs(periodIndex);
|
long periodDurationUs = manifest.getPeriodDurationUs(periodIndex);
|
||||||
long nowUnixTimeUs = C.msToUs(nowUnixTimeMs);
|
long nowUnixTimeUs = Util.msToUs(nowUnixTimeMs);
|
||||||
long availabilityStartTimeUs = C.msToUs(manifest.availabilityStartTimeMs);
|
long availabilityStartTimeUs = Util.msToUs(manifest.availabilityStartTimeMs);
|
||||||
long intervalUs = C.msToUs(DEFAULT_NOTIFY_MANIFEST_INTERVAL_MS);
|
long intervalUs = Util.msToUs(DEFAULT_NOTIFY_MANIFEST_INTERVAL_MS);
|
||||||
for (int i = 0; i < period.adaptationSets.size(); i++) {
|
for (int i = 0; i < period.adaptationSets.size(); i++) {
|
||||||
List<Representation> representations = period.adaptationSets.get(i).representations;
|
List<Representation> representations = period.adaptationSets.get(i).representations;
|
||||||
if (representations.isEmpty()) {
|
if (representations.isEmpty()) {
|
||||||
@ -1129,7 +1131,7 @@ public final class DashMediaSource extends BaseMediaSource {
|
|||||||
|
|
||||||
private static long getAvailableStartTimeInManifestUs(
|
private static long getAvailableStartTimeInManifestUs(
|
||||||
Period period, long periodDurationUs, long nowUnixTimeUs) {
|
Period period, long periodDurationUs, long nowUnixTimeUs) {
|
||||||
long periodStartTimeInManifestUs = C.msToUs(period.startMs);
|
long periodStartTimeInManifestUs = Util.msToUs(period.startMs);
|
||||||
long availableStartTimeInManifestUs = periodStartTimeInManifestUs;
|
long availableStartTimeInManifestUs = periodStartTimeInManifestUs;
|
||||||
boolean haveAudioVideoAdaptationSets = hasVideoOrAudioAdaptationSets(period);
|
boolean haveAudioVideoAdaptationSets = hasVideoOrAudioAdaptationSets(period);
|
||||||
for (int i = 0; i < period.adaptationSets.size(); i++) {
|
for (int i = 0; i < period.adaptationSets.size(); i++) {
|
||||||
@ -1161,7 +1163,7 @@ public final class DashMediaSource extends BaseMediaSource {
|
|||||||
|
|
||||||
private static long getAvailableEndTimeInManifestUs(
|
private static long getAvailableEndTimeInManifestUs(
|
||||||
Period period, long periodDurationUs, long nowUnixTimeUs) {
|
Period period, long periodDurationUs, long nowUnixTimeUs) {
|
||||||
long periodStartTimeInManifestUs = C.msToUs(period.startMs);
|
long periodStartTimeInManifestUs = Util.msToUs(period.startMs);
|
||||||
long availableEndTimeInManifestUs = Long.MAX_VALUE;
|
long availableEndTimeInManifestUs = Long.MAX_VALUE;
|
||||||
boolean haveAudioVideoAdaptationSets = hasVideoOrAudioAdaptationSets(period);
|
boolean haveAudioVideoAdaptationSets = hasVideoOrAudioAdaptationSets(period);
|
||||||
for (int i = 0; i < period.adaptationSets.size(); i++) {
|
for (int i = 0; i < period.adaptationSets.size(); i++) {
|
||||||
@ -1268,7 +1270,7 @@ public final class DashMediaSource extends BaseMediaSource {
|
|||||||
uid,
|
uid,
|
||||||
0,
|
0,
|
||||||
manifest.getPeriodDurationUs(periodIndex),
|
manifest.getPeriodDurationUs(periodIndex),
|
||||||
C.msToUs(manifest.getPeriod(periodIndex).startMs - manifest.getPeriod(0).startMs)
|
Util.msToUs(manifest.getPeriod(periodIndex).startMs - manifest.getPeriod(0).startMs)
|
||||||
- offsetInFirstPeriodUs);
|
- offsetInFirstPeriodUs);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -307,8 +307,8 @@ public class DefaultDashChunkSource implements DashChunkSource {
|
|||||||
|
|
||||||
long bufferedDurationUs = loadPositionUs - playbackPositionUs;
|
long bufferedDurationUs = loadPositionUs - playbackPositionUs;
|
||||||
long presentationPositionUs =
|
long presentationPositionUs =
|
||||||
C.msToUs(manifest.availabilityStartTimeMs)
|
Util.msToUs(manifest.availabilityStartTimeMs)
|
||||||
+ C.msToUs(manifest.getPeriod(periodIndex).startMs)
|
+ Util.msToUs(manifest.getPeriod(periodIndex).startMs)
|
||||||
+ loadPositionUs;
|
+ loadPositionUs;
|
||||||
|
|
||||||
if (playerTrackEmsgHandler != null
|
if (playerTrackEmsgHandler != null
|
||||||
@ -317,7 +317,7 @@ public class DefaultDashChunkSource implements DashChunkSource {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
long nowUnixTimeUs = C.msToUs(Util.getNowUnixTimeMs(elapsedRealtimeOffsetMs));
|
long nowUnixTimeUs = Util.msToUs(Util.getNowUnixTimeMs(elapsedRealtimeOffsetMs));
|
||||||
long nowPeriodTimeUs = getNowPeriodTimeUs(nowUnixTimeUs);
|
long nowPeriodTimeUs = getNowPeriodTimeUs(nowUnixTimeUs);
|
||||||
MediaChunk previous = queue.isEmpty() ? null : queue.get(queue.size() - 1);
|
MediaChunk previous = queue.isEmpty() ? null : queue.get(queue.size() - 1);
|
||||||
MediaChunkIterator[] chunkIterators = new MediaChunkIterator[trackSelection.length()];
|
MediaChunkIterator[] chunkIterators = new MediaChunkIterator[trackSelection.length()];
|
||||||
@ -602,7 +602,8 @@ public class DefaultDashChunkSource implements DashChunkSource {
|
|||||||
return manifest.availabilityStartTimeMs == C.TIME_UNSET
|
return manifest.availabilityStartTimeMs == C.TIME_UNSET
|
||||||
? C.TIME_UNSET
|
? C.TIME_UNSET
|
||||||
: nowUnixTimeUs
|
: nowUnixTimeUs
|
||||||
- C.msToUs(manifest.availabilityStartTimeMs + manifest.getPeriod(periodIndex).startMs);
|
- Util.msToUs(
|
||||||
|
manifest.availabilityStartTimeMs + manifest.getPeriod(periodIndex).startMs);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected Chunk newInitializationChunk(
|
protected Chunk newInitializationChunk(
|
||||||
|
@ -20,6 +20,7 @@ import androidx.annotation.Nullable;
|
|||||||
import androidx.media3.common.C;
|
import androidx.media3.common.C;
|
||||||
import androidx.media3.common.StreamKey;
|
import androidx.media3.common.StreamKey;
|
||||||
import androidx.media3.common.util.UnstableApi;
|
import androidx.media3.common.util.UnstableApi;
|
||||||
|
import androidx.media3.common.util.Util;
|
||||||
import androidx.media3.exoplayer.offline.FilterableManifest;
|
import androidx.media3.exoplayer.offline.FilterableManifest;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
@ -134,7 +135,7 @@ public class DashManifest implements FilterableManifest<DashManifest> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public final long getPeriodDurationUs(int index) {
|
public final long getPeriodDurationUs(int index) {
|
||||||
return C.msToUs(getPeriodDurationMs(index));
|
return Util.msToUs(getPeriodDurationMs(index));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -969,8 +969,8 @@ public class DashManifestParser extends DefaultHandler
|
|||||||
timeline,
|
timeline,
|
||||||
availabilityTimeOffsetUs,
|
availabilityTimeOffsetUs,
|
||||||
segments,
|
segments,
|
||||||
C.msToUs(timeShiftBufferDepthMs),
|
Util.msToUs(timeShiftBufferDepthMs),
|
||||||
C.msToUs(periodStartUnixTimeMs));
|
Util.msToUs(periodStartUnixTimeMs));
|
||||||
}
|
}
|
||||||
|
|
||||||
protected SegmentTemplate parseSegmentTemplate(
|
protected SegmentTemplate parseSegmentTemplate(
|
||||||
@ -1059,8 +1059,8 @@ public class DashManifestParser extends DefaultHandler
|
|||||||
availabilityTimeOffsetUs,
|
availabilityTimeOffsetUs,
|
||||||
initializationTemplate,
|
initializationTemplate,
|
||||||
mediaTemplate,
|
mediaTemplate,
|
||||||
C.msToUs(timeShiftBufferDepthMs),
|
Util.msToUs(timeShiftBufferDepthMs),
|
||||||
C.msToUs(periodStartUnixTimeMs));
|
Util.msToUs(periodStartUnixTimeMs));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -18,10 +18,10 @@ package androidx.media3.exoplayer.dash.offline;
|
|||||||
import static androidx.media3.common.util.Util.castNonNull;
|
import static androidx.media3.common.util.Util.castNonNull;
|
||||||
|
|
||||||
import androidx.annotation.Nullable;
|
import androidx.annotation.Nullable;
|
||||||
import androidx.media3.common.C;
|
|
||||||
import androidx.media3.common.MediaItem;
|
import androidx.media3.common.MediaItem;
|
||||||
import androidx.media3.common.util.RunnableFutureTask;
|
import androidx.media3.common.util.RunnableFutureTask;
|
||||||
import androidx.media3.common.util.UnstableApi;
|
import androidx.media3.common.util.UnstableApi;
|
||||||
|
import androidx.media3.common.util.Util;
|
||||||
import androidx.media3.datasource.DataSource;
|
import androidx.media3.datasource.DataSource;
|
||||||
import androidx.media3.datasource.DataSpec;
|
import androidx.media3.datasource.DataSpec;
|
||||||
import androidx.media3.datasource.cache.CacheDataSource;
|
import androidx.media3.datasource.cache.CacheDataSource;
|
||||||
@ -130,7 +130,7 @@ public final class DashDownloader extends SegmentDownloader<DashManifest> {
|
|||||||
ArrayList<Segment> segments = new ArrayList<>();
|
ArrayList<Segment> segments = new ArrayList<>();
|
||||||
for (int i = 0; i < manifest.getPeriodCount(); i++) {
|
for (int i = 0; i < manifest.getPeriodCount(); i++) {
|
||||||
Period period = manifest.getPeriod(i);
|
Period period = manifest.getPeriod(i);
|
||||||
long periodStartUs = C.msToUs(period.startMs);
|
long periodStartUs = Util.msToUs(period.startMs);
|
||||||
long periodDurationUs = manifest.getPeriodDurationUs(i);
|
long periodDurationUs = manifest.getPeriodDurationUs(i);
|
||||||
List<AdaptationSet> adaptationSets = period.adaptationSets;
|
List<AdaptationSet> adaptationSets = period.adaptationSets;
|
||||||
for (int j = 0; j < adaptationSets.size(); j++) {
|
for (int j = 0; j < adaptationSets.size(); j++) {
|
||||||
|
@ -26,6 +26,7 @@ import androidx.media3.common.C;
|
|||||||
import androidx.media3.common.Format;
|
import androidx.media3.common.Format;
|
||||||
import androidx.media3.common.TrackGroup;
|
import androidx.media3.common.TrackGroup;
|
||||||
import androidx.media3.common.util.Assertions;
|
import androidx.media3.common.util.Assertions;
|
||||||
|
import androidx.media3.common.util.Util;
|
||||||
import androidx.media3.datasource.DataSpec;
|
import androidx.media3.datasource.DataSpec;
|
||||||
import androidx.media3.datasource.HttpDataSource;
|
import androidx.media3.datasource.HttpDataSource;
|
||||||
import androidx.media3.exoplayer.dash.manifest.DashManifest;
|
import androidx.media3.exoplayer.dash.manifest.DashManifest;
|
||||||
@ -96,7 +97,7 @@ public class DefaultDashChunkSourceTest {
|
|||||||
/* closedCaptionFormats */ ImmutableList.of(),
|
/* closedCaptionFormats */ ImmutableList.of(),
|
||||||
/* playerTrackEmsgHandler= */ null);
|
/* playerTrackEmsgHandler= */ null);
|
||||||
|
|
||||||
long nowInPeriodUs = C.msToUs(nowMs - manifest.availabilityStartTimeMs);
|
long nowInPeriodUs = Util.msToUs(nowMs - manifest.availabilityStartTimeMs);
|
||||||
ChunkHolder output = new ChunkHolder();
|
ChunkHolder output = new ChunkHolder();
|
||||||
|
|
||||||
chunkSource.getNextChunk(
|
chunkSource.getNextChunk(
|
||||||
|
@ -510,7 +510,7 @@ public final class HlsMediaSource extends BaseMediaSource
|
|||||||
@Override
|
@Override
|
||||||
public void onPrimaryPlaylistRefreshed(HlsMediaPlaylist mediaPlaylist) {
|
public void onPrimaryPlaylistRefreshed(HlsMediaPlaylist mediaPlaylist) {
|
||||||
long windowStartTimeMs =
|
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
|
// 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.
|
// started at the same time as the window. Otherwise, we don't know the presentation start time.
|
||||||
long presentationStartTimeMs =
|
long presentationStartTimeMs =
|
||||||
@ -543,7 +543,7 @@ public final class HlsMediaSource extends BaseMediaSource
|
|||||||
long targetLiveOffsetUs;
|
long targetLiveOffsetUs;
|
||||||
if (liveConfiguration.targetOffsetMs != C.TIME_UNSET) {
|
if (liveConfiguration.targetOffsetMs != C.TIME_UNSET) {
|
||||||
// Media item has a defined target offset.
|
// Media item has a defined target offset.
|
||||||
targetLiveOffsetUs = C.msToUs(liveConfiguration.targetOffsetMs);
|
targetLiveOffsetUs = Util.msToUs(liveConfiguration.targetOffsetMs);
|
||||||
} else {
|
} else {
|
||||||
// Decide target offset from playlist.
|
// Decide target offset from playlist.
|
||||||
targetLiveOffsetUs = getTargetLiveOffsetUs(playlist, liveEdgeOffsetUs);
|
targetLiveOffsetUs = getTargetLiveOffsetUs(playlist, liveEdgeOffsetUs);
|
||||||
@ -609,7 +609,7 @@ public final class HlsMediaSource extends BaseMediaSource
|
|||||||
|
|
||||||
private long getLiveEdgeOffsetUs(HlsMediaPlaylist playlist) {
|
private long getLiveEdgeOffsetUs(HlsMediaPlaylist playlist) {
|
||||||
return playlist.hasProgramDateTime
|
return playlist.hasProgramDateTime
|
||||||
? C.msToUs(Util.getNowUnixTimeMs(elapsedRealTimeOffsetMs)) - playlist.getEndTimeUs()
|
? Util.msToUs(Util.getNowUnixTimeMs(elapsedRealTimeOffsetMs)) - playlist.getEndTimeUs()
|
||||||
: 0;
|
: 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -618,7 +618,9 @@ public final class HlsMediaSource extends BaseMediaSource
|
|||||||
long startPositionUs =
|
long startPositionUs =
|
||||||
playlist.startOffsetUs != C.TIME_UNSET
|
playlist.startOffsetUs != C.TIME_UNSET
|
||||||
? playlist.startOffsetUs
|
? playlist.startOffsetUs
|
||||||
: playlist.durationUs + liveEdgeOffsetUs - C.msToUs(liveConfiguration.targetOffsetMs);
|
: playlist.durationUs
|
||||||
|
+ liveEdgeOffsetUs
|
||||||
|
- Util.msToUs(liveConfiguration.targetOffsetMs);
|
||||||
if (playlist.preciseStart) {
|
if (playlist.preciseStart) {
|
||||||
return startPositionUs;
|
return startPositionUs;
|
||||||
}
|
}
|
||||||
@ -641,7 +643,7 @@ public final class HlsMediaSource extends BaseMediaSource
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void maybeUpdateLiveConfiguration(long targetLiveOffsetUs) {
|
private void maybeUpdateLiveConfiguration(long targetLiveOffsetUs) {
|
||||||
long targetLiveOffsetMs = C.usToMs(targetLiveOffsetUs);
|
long targetLiveOffsetMs = Util.usToMs(targetLiveOffsetUs);
|
||||||
if (targetLiveOffsetMs != liveConfiguration.targetOffsetMs) {
|
if (targetLiveOffsetMs != liveConfiguration.targetOffsetMs) {
|
||||||
liveConfiguration =
|
liveConfiguration =
|
||||||
liveConfiguration.buildUpon().setTargetOffsetMs(targetLiveOffsetMs).build();
|
liveConfiguration.buildUpon().setTargetOffsetMs(targetLiveOffsetMs).build();
|
||||||
|
@ -916,8 +916,8 @@ import org.checkerframework.checker.nullness.qual.RequiresNonNull;
|
|||||||
loadable.trackFormat,
|
loadable.trackFormat,
|
||||||
loadable.trackSelectionReason,
|
loadable.trackSelectionReason,
|
||||||
loadable.trackSelectionData,
|
loadable.trackSelectionData,
|
||||||
C.usToMs(loadable.startTimeUs),
|
Util.usToMs(loadable.startTimeUs),
|
||||||
C.usToMs(loadable.endTimeUs));
|
Util.usToMs(loadable.endTimeUs));
|
||||||
LoadErrorInfo loadErrorInfo =
|
LoadErrorInfo loadErrorInfo =
|
||||||
new LoadErrorInfo(loadEventInfo, mediaLoadData, error, errorCount);
|
new LoadErrorInfo(loadEventInfo, mediaLoadData, error, errorCount);
|
||||||
LoadErrorAction loadErrorAction;
|
LoadErrorAction loadErrorAction;
|
||||||
|
@ -16,6 +16,7 @@
|
|||||||
package androidx.media3.exoplayer.hls;
|
package androidx.media3.exoplayer.hls;
|
||||||
|
|
||||||
import androidx.media3.common.C;
|
import androidx.media3.common.C;
|
||||||
|
import androidx.media3.common.util.Util;
|
||||||
import androidx.media3.exoplayer.source.SampleQueue;
|
import androidx.media3.exoplayer.source.SampleQueue;
|
||||||
import androidx.media3.exoplayer.source.chunk.MediaChunk;
|
import androidx.media3.exoplayer.source.chunk.MediaChunk;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
@ -52,7 +53,7 @@ import java.io.IOException;
|
|||||||
MediaChunk mediaChunk, long lastAcceptedSampleTimeUs, long rejectedSampleTimeUs) {
|
MediaChunk mediaChunk, long lastAcceptedSampleTimeUs, long rejectedSampleTimeUs) {
|
||||||
super(
|
super(
|
||||||
"Unexpected sample timestamp: "
|
"Unexpected sample timestamp: "
|
||||||
+ C.usToMs(rejectedSampleTimeUs)
|
+ Util.usToMs(rejectedSampleTimeUs)
|
||||||
+ " in chunk ["
|
+ " in chunk ["
|
||||||
+ mediaChunk.startTimeUs
|
+ mediaChunk.startTimeUs
|
||||||
+ ", "
|
+ ", "
|
||||||
|
@ -538,7 +538,7 @@ public final class DefaultHlsPlaylistTracker
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
long currentTimeMs = SystemClock.elapsedRealtime();
|
long currentTimeMs = SystemClock.elapsedRealtime();
|
||||||
long snapshotValidityDurationMs = max(30000, C.usToMs(playlistSnapshot.durationUs));
|
long snapshotValidityDurationMs = max(30000, Util.usToMs(playlistSnapshot.durationUs));
|
||||||
return playlistSnapshot.hasEndTag
|
return playlistSnapshot.hasEndTag
|
||||||
|| playlistSnapshot.playlistType == HlsMediaPlaylist.PLAYLIST_TYPE_EVENT
|
|| playlistSnapshot.playlistType == HlsMediaPlaylist.PLAYLIST_TYPE_EVENT
|
||||||
|| playlistSnapshot.playlistType == HlsMediaPlaylist.PLAYLIST_TYPE_VOD
|
|| playlistSnapshot.playlistType == HlsMediaPlaylist.PLAYLIST_TYPE_VOD
|
||||||
@ -728,7 +728,7 @@ public final class DefaultHlsPlaylistTracker
|
|||||||
forceRetry = true;
|
forceRetry = true;
|
||||||
playlistError = new PlaylistResetException(playlistUrl);
|
playlistError = new PlaylistResetException(playlistUrl);
|
||||||
} else if (currentTimeMs - lastSnapshotChangeMs
|
} else if (currentTimeMs - lastSnapshotChangeMs
|
||||||
> C.usToMs(playlistSnapshot.targetDurationUs)
|
> Util.usToMs(playlistSnapshot.targetDurationUs)
|
||||||
* playlistStuckTargetDurationCoefficient) {
|
* playlistStuckTargetDurationCoefficient) {
|
||||||
// TODO: Allow customization of stuck playlists handling.
|
// TODO: Allow customization of stuck playlists handling.
|
||||||
playlistError = new PlaylistStuckException(playlistUrl);
|
playlistError = new PlaylistStuckException(playlistUrl);
|
||||||
@ -754,7 +754,7 @@ public final class DefaultHlsPlaylistTracker
|
|||||||
? playlistSnapshot.targetDurationUs
|
? playlistSnapshot.targetDurationUs
|
||||||
: (playlistSnapshot.targetDurationUs / 2);
|
: (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
|
// 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
|
// 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.
|
// called, or when this playlist becomes the primary.
|
||||||
|
@ -846,7 +846,7 @@ public final class HlsPlaylistParser implements ParsingLoadable.Parser<HlsPlayli
|
|||||||
} else if (line.startsWith(TAG_PROGRAM_DATE_TIME)) {
|
} else if (line.startsWith(TAG_PROGRAM_DATE_TIME)) {
|
||||||
if (playlistStartTimeUs == 0) {
|
if (playlistStartTimeUs == 0) {
|
||||||
long programDatetimeUs =
|
long programDatetimeUs =
|
||||||
C.msToUs(Util.parseXsDateTime(line.substring(line.indexOf(':') + 1)));
|
Util.msToUs(Util.parseXsDateTime(line.substring(line.indexOf(':') + 1)));
|
||||||
playlistStartTimeUs = programDatetimeUs - segmentStartTimeUs;
|
playlistStartTimeUs = programDatetimeUs - segmentStartTimeUs;
|
||||||
}
|
}
|
||||||
} else if (line.equals(TAG_GAP)) {
|
} else if (line.equals(TAG_GAP)) {
|
||||||
|
@ -21,7 +21,6 @@ import static org.mockito.Mockito.mock;
|
|||||||
|
|
||||||
import android.net.Uri;
|
import android.net.Uri;
|
||||||
import android.os.SystemClock;
|
import android.os.SystemClock;
|
||||||
import androidx.media3.common.C;
|
|
||||||
import androidx.media3.common.MediaItem;
|
import androidx.media3.common.MediaItem;
|
||||||
import androidx.media3.common.ParserException;
|
import androidx.media3.common.ParserException;
|
||||||
import androidx.media3.common.StreamKey;
|
import androidx.media3.common.StreamKey;
|
||||||
@ -525,7 +524,7 @@ public class HlsMediaSourceTest {
|
|||||||
|
|
||||||
Timeline.Window window = timeline.getWindow(0, new Timeline.Window());
|
Timeline.Window window = timeline.getWindow(0, new Timeline.Window());
|
||||||
assertThat(mediaItem.liveConfiguration.targetOffsetMs)
|
assertThat(mediaItem.liveConfiguration.targetOffsetMs)
|
||||||
.isGreaterThan(C.usToMs(window.durationUs));
|
.isGreaterThan(Util.usToMs(window.durationUs));
|
||||||
assertThat(window.liveConfiguration.targetOffsetMs).isEqualTo(9000);
|
assertThat(window.liveConfiguration.targetOffsetMs).isEqualTo(9000);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -348,7 +348,7 @@ import java.util.Map;
|
|||||||
long contentPositionMs = getContentPeriodPositionMs(player, timeline, period);
|
long contentPositionMs = getContentPeriodPositionMs(player, timeline, period);
|
||||||
int adGroupForPositionIndex =
|
int adGroupForPositionIndex =
|
||||||
adPlaybackState.getAdGroupIndexForPositionUs(
|
adPlaybackState.getAdGroupIndexForPositionUs(
|
||||||
C.msToUs(contentPositionMs), C.msToUs(contentDurationMs));
|
Util.msToUs(contentPositionMs), Util.msToUs(contentDurationMs));
|
||||||
if (adGroupForPositionIndex != C.INDEX_UNSET
|
if (adGroupForPositionIndex != C.INDEX_UNSET
|
||||||
&& imaAdInfo != null
|
&& imaAdInfo != null
|
||||||
&& imaAdInfo.adGroupIndex != adGroupForPositionIndex) {
|
&& imaAdInfo.adGroupIndex != adGroupForPositionIndex) {
|
||||||
@ -372,7 +372,7 @@ import java.util.Map;
|
|||||||
}
|
}
|
||||||
adPlaybackState =
|
adPlaybackState =
|
||||||
adPlaybackState.withAdResumePositionUs(
|
adPlaybackState.withAdResumePositionUs(
|
||||||
playingAd ? C.msToUs(player.getCurrentPosition()) : 0);
|
playingAd ? Util.msToUs(player.getCurrentPosition()) : 0);
|
||||||
}
|
}
|
||||||
lastVolumePercent = getPlayerVolumePercent();
|
lastVolumePercent = getPlayerVolumePercent();
|
||||||
lastAdProgress = getAdVideoProgressUpdate();
|
lastAdProgress = getAdVideoProgressUpdate();
|
||||||
@ -456,7 +456,7 @@ import java.util.Map;
|
|||||||
this.timeline = timeline;
|
this.timeline = timeline;
|
||||||
Player player = checkNotNull(this.player);
|
Player player = checkNotNull(this.player);
|
||||||
long contentDurationUs = timeline.getPeriod(player.getCurrentPeriodIndex(), period).durationUs;
|
long contentDurationUs = timeline.getPeriod(player.getCurrentPeriodIndex(), period).durationUs;
|
||||||
contentDurationMs = C.usToMs(contentDurationUs);
|
contentDurationMs = Util.usToMs(contentDurationUs);
|
||||||
if (contentDurationUs != adPlaybackState.contentDurationUs) {
|
if (contentDurationUs != adPlaybackState.contentDurationUs) {
|
||||||
adPlaybackState = adPlaybackState.withContentDurationUs(contentDurationUs);
|
adPlaybackState = adPlaybackState.withContentDurationUs(contentDurationUs);
|
||||||
updateAdPlaybackState();
|
updateAdPlaybackState();
|
||||||
@ -602,10 +602,11 @@ import java.util.Map;
|
|||||||
// Skip ads based on the start position as required.
|
// Skip ads based on the start position as required.
|
||||||
int adGroupForPositionIndex =
|
int adGroupForPositionIndex =
|
||||||
adPlaybackState.getAdGroupIndexForPositionUs(
|
adPlaybackState.getAdGroupIndexForPositionUs(
|
||||||
C.msToUs(contentPositionMs), C.msToUs(contentDurationMs));
|
Util.msToUs(contentPositionMs), Util.msToUs(contentDurationMs));
|
||||||
if (adGroupForPositionIndex != C.INDEX_UNSET) {
|
if (adGroupForPositionIndex != C.INDEX_UNSET) {
|
||||||
boolean playAdWhenStartingPlayback =
|
boolean playAdWhenStartingPlayback =
|
||||||
adPlaybackState.getAdGroup(adGroupForPositionIndex).timeUs == C.msToUs(contentPositionMs)
|
adPlaybackState.getAdGroup(adGroupForPositionIndex).timeUs
|
||||||
|
== Util.msToUs(contentPositionMs)
|
||||||
|| configuration.playAdBeforeStartPosition;
|
|| configuration.playAdBeforeStartPosition;
|
||||||
if (!playAdWhenStartingPlayback) {
|
if (!playAdWhenStartingPlayback) {
|
||||||
adGroupForPositionIndex++;
|
adGroupForPositionIndex++;
|
||||||
@ -790,7 +791,7 @@ import java.util.Map;
|
|||||||
// An ad is available already.
|
// An ad is available already.
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
long adGroupTimeMs = C.usToMs(adGroup.timeUs);
|
long adGroupTimeMs = Util.usToMs(adGroup.timeUs);
|
||||||
long contentPositionMs = getContentPeriodPositionMs(player, timeline, period);
|
long contentPositionMs = getContentPeriodPositionMs(player, timeline, period);
|
||||||
long timeUntilAdMs = adGroupTimeMs - contentPositionMs;
|
long timeUntilAdMs = adGroupTimeMs - contentPositionMs;
|
||||||
return timeUntilAdMs < configuration.adPreloadTimeoutMs;
|
return timeUntilAdMs < configuration.adPreloadTimeoutMs;
|
||||||
@ -840,7 +841,7 @@ import java.util.Map;
|
|||||||
if (!sentContentComplete && !timeline.isEmpty()) {
|
if (!sentContentComplete && !timeline.isEmpty()) {
|
||||||
long positionMs = getContentPeriodPositionMs(player, timeline, period);
|
long positionMs = getContentPeriodPositionMs(player, timeline, period);
|
||||||
timeline.getPeriod(player.getCurrentPeriodIndex(), 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) {
|
if (newAdGroupIndex != C.INDEX_UNSET) {
|
||||||
sentPendingContentPositionMs = false;
|
sentPendingContentPositionMs = false;
|
||||||
pendingContentPositionMs = positionMs;
|
pendingContentPositionMs = positionMs;
|
||||||
@ -880,7 +881,7 @@ import java.util.Map;
|
|||||||
} else {
|
} else {
|
||||||
// IMA hasn't called playAd yet, so fake the content position.
|
// IMA hasn't called playAd yet, so fake the content position.
|
||||||
fakeContentProgressElapsedRealtimeMs = SystemClock.elapsedRealtime();
|
fakeContentProgressElapsedRealtimeMs = SystemClock.elapsedRealtime();
|
||||||
fakeContentProgressOffsetMs = C.usToMs(adGroup.timeUs);
|
fakeContentProgressOffsetMs = Util.usToMs(adGroup.timeUs);
|
||||||
if (fakeContentProgressOffsetMs == C.TIME_END_OF_SOURCE) {
|
if (fakeContentProgressOffsetMs == C.TIME_END_OF_SOURCE) {
|
||||||
fakeContentProgressOffsetMs = contentDurationMs;
|
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
|
// 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.
|
// we can notify that it failed to load.
|
||||||
fakeContentProgressElapsedRealtimeMs = SystemClock.elapsedRealtime();
|
fakeContentProgressElapsedRealtimeMs = SystemClock.elapsedRealtime();
|
||||||
fakeContentProgressOffsetMs = C.usToMs(adPlaybackState.getAdGroup(adGroupIndex).timeUs);
|
fakeContentProgressOffsetMs = Util.usToMs(adPlaybackState.getAdGroup(adGroupIndex).timeUs);
|
||||||
if (fakeContentProgressOffsetMs == C.TIME_END_OF_SOURCE) {
|
if (fakeContentProgressOffsetMs == C.TIME_END_OF_SOURCE) {
|
||||||
fakeContentProgressOffsetMs = contentDurationMs;
|
fakeContentProgressOffsetMs = contentDurationMs;
|
||||||
}
|
}
|
||||||
@ -1192,13 +1193,14 @@ import java.util.Map;
|
|||||||
if (player == null) {
|
if (player == null) {
|
||||||
return C.INDEX_UNSET;
|
return C.INDEX_UNSET;
|
||||||
}
|
}
|
||||||
long playerPositionUs = C.msToUs(getContentPeriodPositionMs(player, timeline, period));
|
long playerPositionUs = Util.msToUs(getContentPeriodPositionMs(player, timeline, period));
|
||||||
int adGroupIndex =
|
int adGroupIndex =
|
||||||
adPlaybackState.getAdGroupIndexForPositionUs(playerPositionUs, C.msToUs(contentDurationMs));
|
adPlaybackState.getAdGroupIndexForPositionUs(
|
||||||
|
playerPositionUs, Util.msToUs(contentDurationMs));
|
||||||
if (adGroupIndex == C.INDEX_UNSET) {
|
if (adGroupIndex == C.INDEX_UNSET) {
|
||||||
adGroupIndex =
|
adGroupIndex =
|
||||||
adPlaybackState.getAdGroupIndexAfterPositionUs(
|
adPlaybackState.getAdGroupIndexAfterPositionUs(
|
||||||
playerPositionUs, C.msToUs(contentDurationMs));
|
playerPositionUs, Util.msToUs(contentDurationMs));
|
||||||
}
|
}
|
||||||
return adGroupIndex;
|
return adGroupIndex;
|
||||||
}
|
}
|
||||||
|
@ -705,7 +705,7 @@ public final class ImaAdsLoader implements Player.Listener, AdsLoader {
|
|||||||
timeline.getPeriodPosition(
|
timeline.getPeriodPosition(
|
||||||
window, period, period.windowIndex, /* windowPositionUs= */ C.TIME_UNSET)
|
window, period, period.windowIndex, /* windowPositionUs= */ C.TIME_UNSET)
|
||||||
.second;
|
.second;
|
||||||
nextAdTagLoader.maybePreloadAds(C.usToMs(periodPositionUs), C.usToMs(period.durationUs));
|
nextAdTagLoader.maybePreloadAds(Util.usToMs(periodPositionUs), Util.usToMs(period.durationUs));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -26,6 +26,7 @@ import androidx.media3.common.TrackSelectionParameters;
|
|||||||
import androidx.media3.common.TracksInfo;
|
import androidx.media3.common.TracksInfo;
|
||||||
import androidx.media3.common.util.Clock;
|
import androidx.media3.common.util.Clock;
|
||||||
import androidx.media3.common.util.ListenerSet;
|
import androidx.media3.common.util.ListenerSet;
|
||||||
|
import androidx.media3.common.util.Util;
|
||||||
import androidx.media3.test.utils.StubExoPlayer;
|
import androidx.media3.test.utils.StubExoPlayer;
|
||||||
|
|
||||||
/** A fake player for testing content/ad playback. */
|
/** A fake player for testing content/ad playback. */
|
||||||
@ -277,7 +278,7 @@ import androidx.media3.test.utils.StubExoPlayer;
|
|||||||
if (isPlayingAd()) {
|
if (isPlayingAd()) {
|
||||||
long adDurationUs =
|
long adDurationUs =
|
||||||
timeline.getPeriod(0, period).getAdDurationUs(adGroupIndex, adIndexInAdGroup);
|
timeline.getPeriod(0, period).getAdDurationUs(adGroupIndex, adIndexInAdGroup);
|
||||||
return C.usToMs(adDurationUs);
|
return Util.usToMs(adDurationUs);
|
||||||
} else {
|
} else {
|
||||||
return timeline.getWindow(getCurrentWindowIndex(), window).getDurationMs();
|
return timeline.getWindow(getCurrentWindowIndex(), window).getDurationMs();
|
||||||
}
|
}
|
||||||
|
@ -384,13 +384,13 @@ public final class ImaAdsLoaderTest {
|
|||||||
playerPositionUs + TimelineWindowDefinition.DEFAULT_WINDOW_OFFSET_IN_FIRST_PERIOD_US;
|
playerPositionUs + TimelineWindowDefinition.DEFAULT_WINDOW_OFFSET_IN_FIRST_PERIOD_US;
|
||||||
long periodDurationUs =
|
long periodDurationUs =
|
||||||
CONTENT_TIMELINE.getPeriod(/* periodIndex= */ 0, new Period()).durationUs;
|
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.
|
// Verify the content progress is updated to reflect the new player position.
|
||||||
assertThat(contentProgressProvider.getContentProgress())
|
assertThat(contentProgressProvider.getContentProgress())
|
||||||
.isEqualTo(
|
.isEqualTo(
|
||||||
new VideoProgressUpdate(
|
new VideoProgressUpdate(
|
||||||
C.usToMs(playerPositionInPeriodUs), C.usToMs(periodDurationUs)));
|
Util.usToMs(playerPositionInPeriodUs), Util.usToMs(periodDurationUs)));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@ -428,7 +428,8 @@ public final class ImaAdsLoaderTest {
|
|||||||
// Advance playback to just before the midroll and simulate buffering.
|
// Advance playback to just before the midroll and simulate buffering.
|
||||||
imaAdsLoader.start(
|
imaAdsLoader.start(
|
||||||
adsMediaSource, TEST_DATA_SPEC, TEST_ADS_ID, adViewProvider, adsLoaderListener);
|
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);
|
fakePlayer.setState(Player.STATE_BUFFERING, /* playWhenReady= */ true);
|
||||||
// Advance before the timeout and simulating polling content progress.
|
// Advance before the timeout and simulating polling content progress.
|
||||||
ShadowSystemClock.advanceBy(Duration.ofSeconds(1));
|
ShadowSystemClock.advanceBy(Duration.ofSeconds(1));
|
||||||
@ -453,7 +454,8 @@ public final class ImaAdsLoaderTest {
|
|||||||
// Advance playback to just before the midroll and simulate buffering.
|
// Advance playback to just before the midroll and simulate buffering.
|
||||||
imaAdsLoader.start(
|
imaAdsLoader.start(
|
||||||
adsMediaSource, TEST_DATA_SPEC, TEST_ADS_ID, adViewProvider, adsLoaderListener);
|
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);
|
fakePlayer.setState(Player.STATE_BUFFERING, /* playWhenReady= */ true);
|
||||||
// Advance past the timeout and simulate polling content progress.
|
// Advance past the timeout and simulate polling content progress.
|
||||||
ShadowSystemClock.advanceBy(Duration.ofSeconds(5));
|
ShadowSystemClock.advanceBy(Duration.ofSeconds(5));
|
||||||
@ -478,7 +480,8 @@ public final class ImaAdsLoaderTest {
|
|||||||
ImmutableList<Float> cuePoints = ImmutableList.of((float) adGroupTimeUs / C.MICROS_PER_SECOND);
|
ImmutableList<Float> cuePoints = ImmutableList.of((float) adGroupTimeUs / C.MICROS_PER_SECOND);
|
||||||
when(mockAdsManager.getAdCuePoints()).thenReturn(cuePoints);
|
when(mockAdsManager.getAdCuePoints()).thenReturn(cuePoints);
|
||||||
fakePlayer.setState(Player.STATE_BUFFERING, /* playWhenReady= */ true);
|
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
|
// Start ad loading while still buffering and simulate the calls from the IMA SDK to resume then
|
||||||
// immediately pause content playback.
|
// immediately pause content playback.
|
||||||
@ -506,7 +509,8 @@ public final class ImaAdsLoaderTest {
|
|||||||
ImmutableList<Float> cuePoints = ImmutableList.of((float) adGroupTimeUs / C.MICROS_PER_SECOND);
|
ImmutableList<Float> cuePoints = ImmutableList.of((float) adGroupTimeUs / C.MICROS_PER_SECOND);
|
||||||
when(mockAdsManager.getAdCuePoints()).thenReturn(cuePoints);
|
when(mockAdsManager.getAdCuePoints()).thenReturn(cuePoints);
|
||||||
fakePlayer.setState(Player.STATE_BUFFERING, /* playWhenReady= */ true);
|
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.
|
// Start ad loading while still buffering and poll progress without the ad loading.
|
||||||
imaAdsLoader.start(
|
imaAdsLoader.start(
|
||||||
@ -597,7 +601,7 @@ public final class ImaAdsLoaderTest {
|
|||||||
verify(mockVideoAdPlayerCallback)
|
verify(mockVideoAdPlayerCallback)
|
||||||
.onAdProgress(
|
.onAdProgress(
|
||||||
TEST_AD_MEDIA_INFO,
|
TEST_AD_MEDIA_INFO,
|
||||||
new VideoProgressUpdate(newPlayerPositionMs, C.usToMs(TEST_AD_DURATION_US)));
|
new VideoProgressUpdate(newPlayerPositionMs, Util.usToMs(TEST_AD_DURATION_US)));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@ -610,7 +614,7 @@ public final class ImaAdsLoaderTest {
|
|||||||
when(mockAdsManager.getAdCuePoints()).thenReturn(cuePoints);
|
when(mockAdsManager.getAdCuePoints()).thenReturn(cuePoints);
|
||||||
|
|
||||||
fakePlayer.setPlayingContentPosition(
|
fakePlayer.setPlayingContentPosition(
|
||||||
/* periodIndex= */ 0, C.usToMs(midrollWindowTimeUs) - 1_000);
|
/* periodIndex= */ 0, Util.usToMs(midrollWindowTimeUs) - 1_000);
|
||||||
imaAdsLoader.start(
|
imaAdsLoader.start(
|
||||||
adsMediaSource, TEST_DATA_SPEC, TEST_ADS_ID, adViewProvider, adsLoaderListener);
|
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);
|
ImmutableList.of(0f, (float) midrollPeriodTimeUs / C.MICROS_PER_SECOND);
|
||||||
when(mockAdsManager.getAdCuePoints()).thenReturn(cuePoints);
|
when(mockAdsManager.getAdCuePoints()).thenReturn(cuePoints);
|
||||||
|
|
||||||
fakePlayer.setPlayingContentPosition(/* periodIndex= */ 0, C.usToMs(midrollWindowTimeUs));
|
fakePlayer.setPlayingContentPosition(/* periodIndex= */ 0, Util.usToMs(midrollWindowTimeUs));
|
||||||
imaAdsLoader.start(
|
imaAdsLoader.start(
|
||||||
adsMediaSource, TEST_DATA_SPEC, TEST_ADS_ID, adViewProvider, adsLoaderListener);
|
adsMediaSource, TEST_DATA_SPEC, TEST_ADS_ID, adViewProvider, adsLoaderListener);
|
||||||
|
|
||||||
@ -657,7 +661,7 @@ public final class ImaAdsLoaderTest {
|
|||||||
when(mockAdsManager.getAdCuePoints()).thenReturn(cuePoints);
|
when(mockAdsManager.getAdCuePoints()).thenReturn(cuePoints);
|
||||||
|
|
||||||
fakePlayer.setPlayingContentPosition(
|
fakePlayer.setPlayingContentPosition(
|
||||||
/* periodIndex= */ 0, C.usToMs(midrollWindowTimeUs) + 1_000);
|
/* periodIndex= */ 0, Util.usToMs(midrollWindowTimeUs) + 1_000);
|
||||||
imaAdsLoader.start(
|
imaAdsLoader.start(
|
||||||
adsMediaSource, TEST_DATA_SPEC, TEST_ADS_ID, adViewProvider, adsLoaderListener);
|
adsMediaSource, TEST_DATA_SPEC, TEST_ADS_ID, adViewProvider, adsLoaderListener);
|
||||||
|
|
||||||
@ -691,7 +695,7 @@ public final class ImaAdsLoaderTest {
|
|||||||
when(mockAdsManager.getAdCuePoints()).thenReturn(cuePoints);
|
when(mockAdsManager.getAdCuePoints()).thenReturn(cuePoints);
|
||||||
|
|
||||||
fakePlayer.setPlayingContentPosition(
|
fakePlayer.setPlayingContentPosition(
|
||||||
/* periodIndex= */ 0, C.usToMs(secondMidrollWindowTimeUs) - 1_000);
|
/* periodIndex= */ 0, Util.usToMs(secondMidrollWindowTimeUs) - 1_000);
|
||||||
imaAdsLoader.start(
|
imaAdsLoader.start(
|
||||||
adsMediaSource, TEST_DATA_SPEC, TEST_ADS_ID, adViewProvider, adsLoaderListener);
|
adsMediaSource, TEST_DATA_SPEC, TEST_ADS_ID, adViewProvider, adsLoaderListener);
|
||||||
|
|
||||||
@ -718,7 +722,8 @@ public final class ImaAdsLoaderTest {
|
|||||||
(float) secondMidrollPeriodTimeUs / C.MICROS_PER_SECOND);
|
(float) secondMidrollPeriodTimeUs / C.MICROS_PER_SECOND);
|
||||||
when(mockAdsManager.getAdCuePoints()).thenReturn(cuePoints);
|
when(mockAdsManager.getAdCuePoints()).thenReturn(cuePoints);
|
||||||
|
|
||||||
fakePlayer.setPlayingContentPosition(/* periodIndex= */ 0, C.usToMs(secondMidrollWindowTimeUs));
|
fakePlayer.setPlayingContentPosition(
|
||||||
|
/* periodIndex= */ 0, Util.usToMs(secondMidrollWindowTimeUs));
|
||||||
imaAdsLoader.start(
|
imaAdsLoader.start(
|
||||||
adsMediaSource, TEST_DATA_SPEC, TEST_ADS_ID, adViewProvider, adsLoaderListener);
|
adsMediaSource, TEST_DATA_SPEC, TEST_ADS_ID, adViewProvider, adsLoaderListener);
|
||||||
|
|
||||||
@ -760,7 +765,7 @@ public final class ImaAdsLoaderTest {
|
|||||||
when(mockAdsManager.getAdCuePoints()).thenReturn(cuePoints);
|
when(mockAdsManager.getAdCuePoints()).thenReturn(cuePoints);
|
||||||
|
|
||||||
fakePlayer.setPlayingContentPosition(
|
fakePlayer.setPlayingContentPosition(
|
||||||
/* periodIndex= */ 0, C.usToMs(midrollWindowTimeUs) - 1_000);
|
/* periodIndex= */ 0, Util.usToMs(midrollWindowTimeUs) - 1_000);
|
||||||
imaAdsLoader.start(
|
imaAdsLoader.start(
|
||||||
adsMediaSource, TEST_DATA_SPEC, TEST_ADS_ID, adViewProvider, adsLoaderListener);
|
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);
|
ImmutableList.of(0f, (float) midrollPeriodTimeUs / C.MICROS_PER_SECOND);
|
||||||
when(mockAdsManager.getAdCuePoints()).thenReturn(cuePoints);
|
when(mockAdsManager.getAdCuePoints()).thenReturn(cuePoints);
|
||||||
|
|
||||||
fakePlayer.setPlayingContentPosition(/* periodIndex= */ 0, C.usToMs(midrollWindowTimeUs));
|
fakePlayer.setPlayingContentPosition(/* periodIndex= */ 0, Util.usToMs(midrollWindowTimeUs));
|
||||||
imaAdsLoader.start(
|
imaAdsLoader.start(
|
||||||
adsMediaSource, TEST_DATA_SPEC, TEST_ADS_ID, adViewProvider, adsLoaderListener);
|
adsMediaSource, TEST_DATA_SPEC, TEST_ADS_ID, adViewProvider, adsLoaderListener);
|
||||||
|
|
||||||
@ -843,7 +848,7 @@ public final class ImaAdsLoaderTest {
|
|||||||
when(mockAdsManager.getAdCuePoints()).thenReturn(cuePoints);
|
when(mockAdsManager.getAdCuePoints()).thenReturn(cuePoints);
|
||||||
|
|
||||||
fakePlayer.setPlayingContentPosition(
|
fakePlayer.setPlayingContentPosition(
|
||||||
/* periodIndex= */ 0, C.usToMs(midrollWindowTimeUs) + 1_000);
|
/* periodIndex= */ 0, Util.usToMs(midrollWindowTimeUs) + 1_000);
|
||||||
imaAdsLoader.start(
|
imaAdsLoader.start(
|
||||||
adsMediaSource, TEST_DATA_SPEC, TEST_ADS_ID, adViewProvider, adsLoaderListener);
|
adsMediaSource, TEST_DATA_SPEC, TEST_ADS_ID, adViewProvider, adsLoaderListener);
|
||||||
|
|
||||||
@ -889,7 +894,7 @@ public final class ImaAdsLoaderTest {
|
|||||||
when(mockAdsManager.getAdCuePoints()).thenReturn(cuePoints);
|
when(mockAdsManager.getAdCuePoints()).thenReturn(cuePoints);
|
||||||
|
|
||||||
fakePlayer.setPlayingContentPosition(
|
fakePlayer.setPlayingContentPosition(
|
||||||
/* periodIndex= */ 0, C.usToMs(secondMidrollWindowTimeUs) - 1_000);
|
/* periodIndex= */ 0, Util.usToMs(secondMidrollWindowTimeUs) - 1_000);
|
||||||
imaAdsLoader.start(
|
imaAdsLoader.start(
|
||||||
adsMediaSource, TEST_DATA_SPEC, TEST_ADS_ID, adViewProvider, adsLoaderListener);
|
adsMediaSource, TEST_DATA_SPEC, TEST_ADS_ID, adViewProvider, adsLoaderListener);
|
||||||
|
|
||||||
@ -937,7 +942,8 @@ public final class ImaAdsLoaderTest {
|
|||||||
(float) secondMidrollPeriodTimeUs / C.MICROS_PER_SECOND);
|
(float) secondMidrollPeriodTimeUs / C.MICROS_PER_SECOND);
|
||||||
when(mockAdsManager.getAdCuePoints()).thenReturn(cuePoints);
|
when(mockAdsManager.getAdCuePoints()).thenReturn(cuePoints);
|
||||||
|
|
||||||
fakePlayer.setPlayingContentPosition(/* periodIndex= */ 0, C.usToMs(secondMidrollWindowTimeUs));
|
fakePlayer.setPlayingContentPosition(
|
||||||
|
/* periodIndex= */ 0, Util.usToMs(secondMidrollWindowTimeUs));
|
||||||
imaAdsLoader.start(
|
imaAdsLoader.start(
|
||||||
adsMediaSource, TEST_DATA_SPEC, TEST_ADS_ID, adViewProvider, adsLoaderListener);
|
adsMediaSource, TEST_DATA_SPEC, TEST_ADS_ID, adViewProvider, adsLoaderListener);
|
||||||
|
|
||||||
|
@ -686,7 +686,7 @@ import org.checkerframework.checker.nullness.qual.MonotonicNonNull;
|
|||||||
}
|
}
|
||||||
|
|
||||||
playbackEventListener.onPlaybackStarted(
|
playbackEventListener.onPlaybackStarted(
|
||||||
C.msToUs(response.sessionTiming.startTimeMs), response.trackTimingList);
|
Util.msToUs(response.sessionTiming.startTimeMs), response.trackTimingList);
|
||||||
pendingSeekPositionUs = C.TIME_UNSET;
|
pendingSeekPositionUs = C.TIME_UNSET;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -695,7 +695,7 @@ import org.checkerframework.checker.nullness.qual.MonotonicNonNull;
|
|||||||
|
|
||||||
rtspState = RTSP_STATE_READY;
|
rtspState = RTSP_STATE_READY;
|
||||||
if (pendingSeekPositionUs != C.TIME_UNSET) {
|
if (pendingSeekPositionUs != C.TIME_UNSET) {
|
||||||
startPlayback(C.usToMs(pendingSeekPositionUs));
|
startPlayback(Util.usToMs(pendingSeekPositionUs));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -28,6 +28,7 @@ import androidx.media3.common.MediaItem;
|
|||||||
import androidx.media3.common.MediaLibraryInfo;
|
import androidx.media3.common.MediaLibraryInfo;
|
||||||
import androidx.media3.common.Timeline;
|
import androidx.media3.common.Timeline;
|
||||||
import androidx.media3.common.util.UnstableApi;
|
import androidx.media3.common.util.UnstableApi;
|
||||||
|
import androidx.media3.common.util.Util;
|
||||||
import androidx.media3.datasource.HttpDataSource;
|
import androidx.media3.datasource.HttpDataSource;
|
||||||
import androidx.media3.datasource.TransferListener;
|
import androidx.media3.datasource.TransferListener;
|
||||||
import androidx.media3.exoplayer.drm.DrmSessionManager;
|
import androidx.media3.exoplayer.drm.DrmSessionManager;
|
||||||
@ -276,7 +277,7 @@ public final class RtspMediaSource extends BaseMediaSource {
|
|||||||
rtpDataChannelFactory,
|
rtpDataChannelFactory,
|
||||||
uri,
|
uri,
|
||||||
/* listener= */ timing -> {
|
/* listener= */ timing -> {
|
||||||
timelineDurationUs = C.msToUs(timing.getDurationMs());
|
timelineDurationUs = Util.msToUs(timing.getDurationMs());
|
||||||
timelineIsSeekable = !timing.isLive();
|
timelineIsSeekable = !timing.isLive();
|
||||||
timelineIsLive = timing.isLive();
|
timelineIsLive = timing.isLive();
|
||||||
timelineIsPlaceholder = false;
|
timelineIsPlaceholder = false;
|
||||||
|
@ -606,7 +606,7 @@ public final class SsMediaSource extends BaseMediaSource
|
|||||||
startTimeUs = max(startTimeUs, endTimeUs - manifest.dvrWindowLengthUs);
|
startTimeUs = max(startTimeUs, endTimeUs - manifest.dvrWindowLengthUs);
|
||||||
}
|
}
|
||||||
long durationUs = endTimeUs - startTimeUs;
|
long durationUs = endTimeUs - startTimeUs;
|
||||||
long defaultStartPositionUs = durationUs - C.msToUs(livePresentationDelayMs);
|
long defaultStartPositionUs = durationUs - Util.msToUs(livePresentationDelayMs);
|
||||||
if (defaultStartPositionUs < MIN_LIVE_DEFAULT_START_POSITION_US) {
|
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
|
// 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
|
// minimum default start position provided the window is at least twice as big. Else set
|
||||||
|
@ -62,7 +62,7 @@ import androidx.media3.extractor.metadata.id3.MlltFrame;
|
|||||||
this.durationUs =
|
this.durationUs =
|
||||||
durationUs != C.TIME_UNSET
|
durationUs != C.TIME_UNSET
|
||||||
? durationUs
|
? durationUs
|
||||||
: C.msToUs(referenceTimesMs[referenceTimesMs.length - 1]);
|
: Util.msToUs(referenceTimesMs[referenceTimesMs.length - 1]);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -74,8 +74,8 @@ import androidx.media3.extractor.metadata.id3.MlltFrame;
|
|||||||
public SeekPoints getSeekPoints(long timeUs) {
|
public SeekPoints getSeekPoints(long timeUs) {
|
||||||
timeUs = Util.constrainValue(timeUs, 0, durationUs);
|
timeUs = Util.constrainValue(timeUs, 0, durationUs);
|
||||||
Pair<Long, Long> timeMsAndPosition =
|
Pair<Long, Long> timeMsAndPosition =
|
||||||
linearlyInterpolate(C.usToMs(timeUs), referenceTimesMs, referencePositions);
|
linearlyInterpolate(Util.usToMs(timeUs), referenceTimesMs, referencePositions);
|
||||||
timeUs = C.msToUs(timeMsAndPosition.first);
|
timeUs = Util.msToUs(timeMsAndPosition.first);
|
||||||
long position = timeMsAndPosition.second;
|
long position = timeMsAndPosition.second;
|
||||||
return new SeekPoints(new SeekPoint(timeUs, position));
|
return new SeekPoints(new SeekPoint(timeUs, position));
|
||||||
}
|
}
|
||||||
@ -84,7 +84,7 @@ import androidx.media3.extractor.metadata.id3.MlltFrame;
|
|||||||
public long getTimeUs(long position) {
|
public long getTimeUs(long position) {
|
||||||
Pair<Long, Long> positionAndTimeMs =
|
Pair<Long, Long> positionAndTimeMs =
|
||||||
linearlyInterpolate(position, referencePositions, referenceTimesMs);
|
linearlyInterpolate(position, referencePositions, referenceTimesMs);
|
||||||
return C.msToUs(positionAndTimeMs.second);
|
return Util.msToUs(positionAndTimeMs.second);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -588,7 +588,7 @@ public final class Mp3Extractor implements Extractor {
|
|||||||
Metadata.Entry entry = metadata.get(i);
|
Metadata.Entry entry = metadata.get(i);
|
||||||
if (entry instanceof TextInformationFrame
|
if (entry instanceof TextInformationFrame
|
||||||
&& ((TextInformationFrame) entry).id.equals("TLEN")) {
|
&& ((TextInformationFrame) entry).id.equals("TLEN")) {
|
||||||
return C.msToUs(Long.parseLong(((TextInformationFrame) entry).value));
|
return Util.msToUs(Long.parseLong(((TextInformationFrame) entry).value));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2610,7 +2610,7 @@ import org.checkerframework.checker.nullness.qual.NonNull;
|
|||||||
timeline.getPeriod(newPeriodIndex, newPeriod);
|
timeline.getPeriod(newPeriodIndex, newPeriod);
|
||||||
boolean playingPeriodChanged = oldPeriodIndex != newPeriodIndex;
|
boolean playingPeriodChanged = oldPeriodIndex != newPeriodIndex;
|
||||||
long newPositionUs = periodInfo.periodPositionUs;
|
long newPositionUs = periodInfo.periodPositionUs;
|
||||||
long oldPositionUs = C.msToUs(getCurrentPosition()) - oldPeriod.getPositionInWindowUs();
|
long oldPositionUs = Util.msToUs(getCurrentPosition()) - oldPeriod.getPositionInWindowUs();
|
||||||
|
|
||||||
if (!playingPeriodChanged && newPositionUs == oldPositionUs) {
|
if (!playingPeriodChanged && newPositionUs == oldPositionUs) {
|
||||||
// Period position remains unchanged.
|
// Period position remains unchanged.
|
||||||
@ -2673,7 +2673,7 @@ import org.checkerframework.checker.nullness.qual.NonNull;
|
|||||||
long maskedTotalBufferedDurationUs =
|
long maskedTotalBufferedDurationUs =
|
||||||
max(
|
max(
|
||||||
0,
|
0,
|
||||||
C.msToUs(playerInfo.sessionPositionInfo.totalBufferedDurationMs)
|
Util.msToUs(playerInfo.sessionPositionInfo.totalBufferedDurationMs)
|
||||||
- (newPositionUs - oldPositionUs));
|
- (newPositionUs - oldPositionUs));
|
||||||
long maskedBufferedPositionUs = newPositionUs + maskedTotalBufferedDurationUs;
|
long maskedBufferedPositionUs = newPositionUs + maskedTotalBufferedDurationUs;
|
||||||
|
|
||||||
@ -2708,7 +2708,7 @@ import org.checkerframework.checker.nullness.qual.NonNull;
|
|||||||
windowIndex = timeline.getFirstWindowIndex(getShuffleModeEnabled());
|
windowIndex = timeline.getFirstWindowIndex(getShuffleModeEnabled());
|
||||||
windowPositionMs = timeline.getWindow(windowIndex, window).getDefaultPositionMs();
|
windowPositionMs = timeline.getWindow(windowIndex, window).getDefaultPositionMs();
|
||||||
}
|
}
|
||||||
return getPeriodInfo(timeline, window, period, windowIndex, C.msToUs(windowPositionMs));
|
return getPeriodInfo(timeline, window, period, windowIndex, Util.msToUs(windowPositionMs));
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean isAd(Period period, long periodPosition) {
|
private boolean isAd(Period period, long periodPosition) {
|
||||||
|
@ -20,6 +20,7 @@ import static androidx.media3.common.util.Assertions.checkArgument;
|
|||||||
import androidx.media3.common.C;
|
import androidx.media3.common.C;
|
||||||
import androidx.media3.common.MediaItem;
|
import androidx.media3.common.MediaItem;
|
||||||
import androidx.media3.common.util.UnstableApi;
|
import androidx.media3.common.util.UnstableApi;
|
||||||
|
import androidx.media3.common.util.Util;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
/** A {@link PlaylistTimeline} implementation that allows setting multiple periods per window. */
|
/** A {@link PlaylistTimeline} implementation that allows setting multiple periods per window. */
|
||||||
@ -61,7 +62,7 @@ public class MultiplePeriodsPerWindowTimeline extends PlaylistTimeline {
|
|||||||
/* isDynamic= */ false,
|
/* isDynamic= */ false,
|
||||||
/* liveConfiguration= */ null,
|
/* liveConfiguration= */ null,
|
||||||
/* defaultPositionUs= */ 0,
|
/* defaultPositionUs= */ 0,
|
||||||
/* durationUs= */ C.msToUs(defaultPeriodDurationMs * periodSizesPerWindow[windowIndex]),
|
/* durationUs= */ Util.msToUs(defaultPeriodDurationMs * periodSizesPerWindow[windowIndex]),
|
||||||
firstPeriodIndex,
|
firstPeriodIndex,
|
||||||
firstPeriodIndex + periodSizesPerWindow[windowIndex] - 1,
|
firstPeriodIndex + periodSizesPerWindow[windowIndex] - 1,
|
||||||
/* positionInFirstPeriodUs= */ 0);
|
/* positionInFirstPeriodUs= */ 0);
|
||||||
@ -85,9 +86,9 @@ public class MultiplePeriodsPerWindowTimeline extends PlaylistTimeline {
|
|||||||
/* id= */ null,
|
/* id= */ null,
|
||||||
/* uid= */ null,
|
/* uid= */ null,
|
||||||
windowIndex,
|
windowIndex,
|
||||||
/* durationUs= */ C.msToUs(defaultPeriodDurationMs),
|
/* durationUs= */ Util.msToUs(defaultPeriodDurationMs),
|
||||||
/* positionInWindowUs= */ (periodIndex - getFirstPeriodIndex(windowIndex))
|
/* positionInWindowUs= */ (periodIndex - getFirstPeriodIndex(windowIndex))
|
||||||
* C.msToUs(defaultPeriodDurationMs));
|
* Util.msToUs(defaultPeriodDurationMs));
|
||||||
return period;
|
return period;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -22,6 +22,7 @@ import androidx.media3.common.MediaItem;
|
|||||||
import androidx.media3.common.Player;
|
import androidx.media3.common.Player;
|
||||||
import androidx.media3.common.Timeline;
|
import androidx.media3.common.Timeline;
|
||||||
import androidx.media3.common.util.UnstableApi;
|
import androidx.media3.common.util.UnstableApi;
|
||||||
|
import androidx.media3.common.util.Util;
|
||||||
import com.google.common.collect.ImmutableList;
|
import com.google.common.collect.ImmutableList;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@ -68,7 +69,7 @@ public class PlaylistTimeline extends Timeline {
|
|||||||
/* isDynamic= */ false,
|
/* isDynamic= */ false,
|
||||||
/* liveConfiguration= */ null,
|
/* liveConfiguration= */ null,
|
||||||
/* defaultPositionUs= */ 0,
|
/* defaultPositionUs= */ 0,
|
||||||
/* durationUs= */ C.msToUs(DEFAULT_DURATION_MS),
|
/* durationUs= */ Util.msToUs(DEFAULT_DURATION_MS),
|
||||||
/* firstPeriodIndex= */ windowIndex,
|
/* firstPeriodIndex= */ windowIndex,
|
||||||
/* lastPeriodIndex= */ windowIndex,
|
/* lastPeriodIndex= */ windowIndex,
|
||||||
/* positionInFirstPeriodUs= */ 0);
|
/* positionInFirstPeriodUs= */ 0);
|
||||||
@ -135,7 +136,7 @@ public class PlaylistTimeline extends Timeline {
|
|||||||
/* id= */ null,
|
/* id= */ null,
|
||||||
/* uid= */ null,
|
/* uid= */ null,
|
||||||
periodIndex,
|
periodIndex,
|
||||||
C.msToUs(DEFAULT_DURATION_MS),
|
Util.msToUs(DEFAULT_DURATION_MS),
|
||||||
/* positionInWindowUs= */ 0);
|
/* positionInWindowUs= */ 0);
|
||||||
return period;
|
return period;
|
||||||
}
|
}
|
||||||
|
@ -20,6 +20,7 @@ import androidx.media3.common.AdPlaybackState;
|
|||||||
import androidx.media3.common.C;
|
import androidx.media3.common.C;
|
||||||
import androidx.media3.common.MediaItem;
|
import androidx.media3.common.MediaItem;
|
||||||
import androidx.media3.common.util.UnstableApi;
|
import androidx.media3.common.util.UnstableApi;
|
||||||
|
import androidx.media3.common.util.Util;
|
||||||
import androidx.media3.datasource.HttpDataSource;
|
import androidx.media3.datasource.HttpDataSource;
|
||||||
import androidx.media3.exoplayer.drm.DrmSessionManager;
|
import androidx.media3.exoplayer.drm.DrmSessionManager;
|
||||||
import androidx.media3.exoplayer.drm.DrmSessionManagerProvider;
|
import androidx.media3.exoplayer.drm.DrmSessionManagerProvider;
|
||||||
@ -83,7 +84,7 @@ public class FakeMediaSourceFactory implements MediaSourceFactory {
|
|||||||
/* isPlaceholder= */ false,
|
/* isPlaceholder= */ false,
|
||||||
/* durationUs= */ 1000 * C.MICROS_PER_SECOND,
|
/* durationUs= */ 1000 * C.MICROS_PER_SECOND,
|
||||||
/* defaultPositionUs= */ 2 * C.MICROS_PER_SECOND,
|
/* defaultPositionUs= */ 2 * C.MICROS_PER_SECOND,
|
||||||
/* windowOffsetInFirstPeriodUs= */ C.msToUs(123456789),
|
/* windowOffsetInFirstPeriodUs= */ Util.msToUs(123456789),
|
||||||
AdPlaybackState.NONE,
|
AdPlaybackState.NONE,
|
||||||
mediaItem);
|
mediaItem);
|
||||||
return new FakeMediaSource(new FakeTimeline(timelineWindowDefinition));
|
return new FakeMediaSource(new FakeTimeline(timelineWindowDefinition));
|
||||||
|
@ -369,7 +369,7 @@ public final class FakeTimeline extends Timeline {
|
|||||||
manifests[windowIndex],
|
manifests[windowIndex],
|
||||||
/* presentationStartTimeMs= */ C.TIME_UNSET,
|
/* presentationStartTimeMs= */ C.TIME_UNSET,
|
||||||
/* windowStartTimeMs= */ windowDefinition.isLive
|
/* windowStartTimeMs= */ windowDefinition.isLive
|
||||||
? C.usToMs(windowDefinition.windowOffsetInFirstPeriodUs)
|
? Util.usToMs(windowDefinition.windowOffsetInFirstPeriodUs)
|
||||||
: C.TIME_UNSET,
|
: C.TIME_UNSET,
|
||||||
/* elapsedRealtimeEpochOffsetMs= */ windowDefinition.isLive ? 0 : C.TIME_UNSET,
|
/* elapsedRealtimeEpochOffsetMs= */ windowDefinition.isLive ? 0 : C.TIME_UNSET,
|
||||||
windowDefinition.isSeekable,
|
windowDefinition.isSeekable,
|
||||||
|
@ -26,6 +26,7 @@ import androidx.annotation.RequiresApi;
|
|||||||
import androidx.media3.common.C;
|
import androidx.media3.common.C;
|
||||||
import androidx.media3.common.Format;
|
import androidx.media3.common.Format;
|
||||||
import androidx.media3.common.MimeTypes;
|
import androidx.media3.common.MimeTypes;
|
||||||
|
import androidx.media3.common.util.Util;
|
||||||
import java.nio.ByteBuffer;
|
import java.nio.ByteBuffer;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -42,7 +43,7 @@ import java.nio.ByteBuffer;
|
|||||||
* <p>The value of this constant has been chosen based on the interleaving observed in a few media
|
* <p>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.
|
* 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 muxer;
|
||||||
private final Muxer.Factory muxerFactory;
|
private final Muxer.Factory muxerFactory;
|
||||||
|
@ -28,6 +28,7 @@ import androidx.media3.common.C;
|
|||||||
import androidx.media3.common.Format;
|
import androidx.media3.common.Format;
|
||||||
import androidx.media3.common.Metadata;
|
import androidx.media3.common.Metadata;
|
||||||
import androidx.media3.common.MimeTypes;
|
import androidx.media3.common.MimeTypes;
|
||||||
|
import androidx.media3.common.util.Util;
|
||||||
import androidx.media3.decoder.DecoderInputBuffer;
|
import androidx.media3.decoder.DecoderInputBuffer;
|
||||||
import androidx.media3.extractor.metadata.mp4.SlowMotionData;
|
import androidx.media3.extractor.metadata.mp4.SlowMotionData;
|
||||||
import androidx.media3.extractor.metadata.mp4.SmtaMetadataEntry;
|
import androidx.media3.extractor.metadata.mp4.SmtaMetadataEntry;
|
||||||
@ -366,8 +367,8 @@ import org.checkerframework.checker.nullness.qual.RequiresNonNull;
|
|||||||
public final int maxLayer;
|
public final int maxLayer;
|
||||||
|
|
||||||
public SegmentInfo(SlowMotionData.Segment segment, int inputMaxLayer, int normalSpeedLayer) {
|
public SegmentInfo(SlowMotionData.Segment segment, int inputMaxLayer, int normalSpeedLayer) {
|
||||||
this.startTimeUs = C.msToUs(segment.startTimeMs);
|
this.startTimeUs = Util.msToUs(segment.startTimeMs);
|
||||||
this.endTimeUs = C.msToUs(segment.endTimeMs);
|
this.endTimeUs = Util.msToUs(segment.endTimeMs);
|
||||||
this.speedDivisor = segment.speedDivisor;
|
this.speedDivisor = segment.speedDivisor;
|
||||||
this.maxLayer = getSlowMotionMaxLayer(speedDivisor, inputMaxLayer, normalSpeedLayer);
|
this.maxLayer = getSlowMotionMaxLayer(speedDivisor, inputMaxLayer, normalSpeedLayer);
|
||||||
}
|
}
|
||||||
|
@ -22,6 +22,7 @@ import androidx.annotation.Nullable;
|
|||||||
import androidx.media3.common.C;
|
import androidx.media3.common.C;
|
||||||
import androidx.media3.common.Format;
|
import androidx.media3.common.Format;
|
||||||
import androidx.media3.common.Metadata;
|
import androidx.media3.common.Metadata;
|
||||||
|
import androidx.media3.common.util.Util;
|
||||||
import androidx.media3.extractor.metadata.mp4.SlowMotionData;
|
import androidx.media3.extractor.metadata.mp4.SlowMotionData;
|
||||||
import androidx.media3.extractor.metadata.mp4.SlowMotionData.Segment;
|
import androidx.media3.extractor.metadata.mp4.SlowMotionData.Segment;
|
||||||
import androidx.media3.extractor.metadata.mp4.SmtaMetadataEntry;
|
import androidx.media3.extractor.metadata.mp4.SmtaMetadataEntry;
|
||||||
@ -72,7 +73,7 @@ import java.util.TreeMap;
|
|||||||
for (int i = 0; i < segments.size(); i++) {
|
for (int i = 0; i < segments.size(); i++) {
|
||||||
Segment currentSegment = segments.get(i);
|
Segment currentSegment = segments.get(i);
|
||||||
speedsByStartTimeUs.put(
|
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
|
// 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.
|
// segment.
|
||||||
for (int i = 0; i < segments.size(); i++) {
|
for (int i = 0; i < segments.size(); i++) {
|
||||||
Segment currentSegment = segments.get(i);
|
Segment currentSegment = segments.get(i);
|
||||||
if (!speedsByStartTimeUs.containsKey(C.msToUs(currentSegment.endTimeMs))) {
|
if (!speedsByStartTimeUs.containsKey(Util.msToUs(currentSegment.endTimeMs))) {
|
||||||
speedsByStartTimeUs.put(C.msToUs(currentSegment.endTimeMs), baseSpeed);
|
speedsByStartTimeUs.put(Util.msToUs(currentSegment.endTimeMs), baseSpeed);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -957,7 +957,7 @@ public class PlayerControlView extends FrameLayout {
|
|||||||
int lastWindowIndex = multiWindowTimeBar ? timeline.getWindowCount() - 1 : currentWindowIndex;
|
int lastWindowIndex = multiWindowTimeBar ? timeline.getWindowCount() - 1 : currentWindowIndex;
|
||||||
for (int i = firstWindowIndex; i <= lastWindowIndex; i++) {
|
for (int i = firstWindowIndex; i <= lastWindowIndex; i++) {
|
||||||
if (i == currentWindowIndex) {
|
if (i == currentWindowIndex) {
|
||||||
currentWindowOffset = C.usToMs(durationUs);
|
currentWindowOffset = Util.usToMs(durationUs);
|
||||||
}
|
}
|
||||||
timeline.getWindow(i, window);
|
timeline.getWindow(i, window);
|
||||||
if (window.durationUs == C.TIME_UNSET) {
|
if (window.durationUs == C.TIME_UNSET) {
|
||||||
@ -984,7 +984,7 @@ public class PlayerControlView extends FrameLayout {
|
|||||||
adGroupTimesMs = Arrays.copyOf(adGroupTimesMs, newLength);
|
adGroupTimesMs = Arrays.copyOf(adGroupTimesMs, newLength);
|
||||||
playedAdGroups = Arrays.copyOf(playedAdGroups, newLength);
|
playedAdGroups = Arrays.copyOf(playedAdGroups, newLength);
|
||||||
}
|
}
|
||||||
adGroupTimesMs[adGroupCount] = C.usToMs(durationUs + adGroupTimeInWindowUs);
|
adGroupTimesMs[adGroupCount] = Util.usToMs(durationUs + adGroupTimeInWindowUs);
|
||||||
playedAdGroups[adGroupCount] = period.hasPlayedAdGroup(adGroupIndex);
|
playedAdGroups[adGroupCount] = period.hasPlayedAdGroup(adGroupIndex);
|
||||||
adGroupCount++;
|
adGroupCount++;
|
||||||
}
|
}
|
||||||
@ -993,7 +993,7 @@ public class PlayerControlView extends FrameLayout {
|
|||||||
durationUs += window.durationUs;
|
durationUs += window.durationUs;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
long durationMs = C.usToMs(durationUs);
|
long durationMs = Util.usToMs(durationUs);
|
||||||
if (durationView != null) {
|
if (durationView != null) {
|
||||||
durationView.setText(Util.getStringForTime(formatBuilder, formatter, durationMs));
|
durationView.setText(Util.getStringForTime(formatBuilder, formatter, durationMs));
|
||||||
}
|
}
|
||||||
|
@ -1276,7 +1276,7 @@ public class StyledPlayerControlView extends FrameLayout {
|
|||||||
int lastWindowIndex = multiWindowTimeBar ? timeline.getWindowCount() - 1 : currentWindowIndex;
|
int lastWindowIndex = multiWindowTimeBar ? timeline.getWindowCount() - 1 : currentWindowIndex;
|
||||||
for (int i = firstWindowIndex; i <= lastWindowIndex; i++) {
|
for (int i = firstWindowIndex; i <= lastWindowIndex; i++) {
|
||||||
if (i == currentWindowIndex) {
|
if (i == currentWindowIndex) {
|
||||||
currentWindowOffset = C.usToMs(durationUs);
|
currentWindowOffset = Util.usToMs(durationUs);
|
||||||
}
|
}
|
||||||
timeline.getWindow(i, window);
|
timeline.getWindow(i, window);
|
||||||
if (window.durationUs == C.TIME_UNSET) {
|
if (window.durationUs == C.TIME_UNSET) {
|
||||||
@ -1303,7 +1303,7 @@ public class StyledPlayerControlView extends FrameLayout {
|
|||||||
adGroupTimesMs = Arrays.copyOf(adGroupTimesMs, newLength);
|
adGroupTimesMs = Arrays.copyOf(adGroupTimesMs, newLength);
|
||||||
playedAdGroups = Arrays.copyOf(playedAdGroups, newLength);
|
playedAdGroups = Arrays.copyOf(playedAdGroups, newLength);
|
||||||
}
|
}
|
||||||
adGroupTimesMs[adGroupCount] = C.usToMs(durationUs + adGroupTimeInWindowUs);
|
adGroupTimesMs[adGroupCount] = Util.usToMs(durationUs + adGroupTimeInWindowUs);
|
||||||
playedAdGroups[adGroupCount] = period.hasPlayedAdGroup(adGroupIndex);
|
playedAdGroups[adGroupCount] = period.hasPlayedAdGroup(adGroupIndex);
|
||||||
adGroupCount++;
|
adGroupCount++;
|
||||||
}
|
}
|
||||||
@ -1312,7 +1312,7 @@ public class StyledPlayerControlView extends FrameLayout {
|
|||||||
durationUs += window.durationUs;
|
durationUs += window.durationUs;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
long durationMs = C.usToMs(durationUs);
|
long durationMs = Util.usToMs(durationUs);
|
||||||
if (durationView != null) {
|
if (durationView != null) {
|
||||||
durationView.setText(Util.getStringForTime(formatBuilder, formatter, durationMs));
|
durationView.setText(Util.getStringForTime(formatBuilder, formatter, durationMs));
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user