package androidx.media3.exoplayer; import android.os.SystemClock; import androidx.media3.common.Metadata; import androidx.media3.common.PlaybackParameters; import androidx.media3.common.Timeline; import androidx.media3.common.util.Util; import androidx.media3.exoplayer.source.MediaSource; import androidx.media3.exoplayer.source.TrackGroupArray; import androidx.media3.exoplayer.trackselection.TrackSelectorResult; import com.google.common.collect.ImmutableList; import java.util.List; /* JADX INFO: Access modifiers changed from: package-private */ /* loaded from: classes2.dex */ public final class PlaybackInfo { private static final MediaSource.MediaPeriodId PLACEHOLDER_MEDIA_PERIOD_ID = new MediaSource.MediaPeriodId(new Object()); public volatile long bufferedPositionUs; public final long discontinuityStartPositionUs; public final boolean isLoading; public final MediaSource.MediaPeriodId loadingMediaPeriodId; public final MediaSource.MediaPeriodId periodId; public final boolean playWhenReady; public final ExoPlaybackException playbackError; public final PlaybackParameters playbackParameters; public final int playbackState; public final int playbackSuppressionReason; public volatile long positionUpdateTimeMs; public volatile long positionUs; public final long requestedContentPositionUs; public final boolean sleepingForOffload; public final List staticMetadata; public final Timeline timeline; public volatile long totalBufferedDurationUs; public final TrackGroupArray trackGroups; public final TrackSelectorResult trackSelectorResult; public static MediaSource.MediaPeriodId getDummyPeriodForEmptyTimeline() { return PLACEHOLDER_MEDIA_PERIOD_ID; } public boolean isPlaying() { return this.playbackState == 3 && this.playWhenReady && this.playbackSuppressionReason == 0; } public static PlaybackInfo createDummy(TrackSelectorResult trackSelectorResult) { Timeline timeline = Timeline.EMPTY; MediaSource.MediaPeriodId mediaPeriodId = PLACEHOLDER_MEDIA_PERIOD_ID; return new PlaybackInfo(timeline, mediaPeriodId, -9223372036854775807L, 0L, 1, null, false, TrackGroupArray.EMPTY, trackSelectorResult, ImmutableList.of(), mediaPeriodId, false, 0, PlaybackParameters.DEFAULT, 0L, 0L, 0L, 0L, false); } public PlaybackInfo(Timeline timeline, MediaSource.MediaPeriodId mediaPeriodId, long j, long j2, int i, ExoPlaybackException exoPlaybackException, boolean z, TrackGroupArray trackGroupArray, TrackSelectorResult trackSelectorResult, List list, MediaSource.MediaPeriodId mediaPeriodId2, boolean z2, int i2, PlaybackParameters playbackParameters, long j3, long j4, long j5, long j6, boolean z3) { this.timeline = timeline; this.periodId = mediaPeriodId; this.requestedContentPositionUs = j; this.discontinuityStartPositionUs = j2; this.playbackState = i; this.playbackError = exoPlaybackException; this.isLoading = z; this.trackGroups = trackGroupArray; this.trackSelectorResult = trackSelectorResult; this.staticMetadata = list; this.loadingMediaPeriodId = mediaPeriodId2; this.playWhenReady = z2; this.playbackSuppressionReason = i2; this.playbackParameters = playbackParameters; this.bufferedPositionUs = j3; this.totalBufferedDurationUs = j4; this.positionUs = j5; this.positionUpdateTimeMs = j6; this.sleepingForOffload = z3; } public PlaybackInfo copyWithNewPosition(MediaSource.MediaPeriodId mediaPeriodId, long j, long j2, long j3, long j4, TrackGroupArray trackGroupArray, TrackSelectorResult trackSelectorResult, List list) { return new PlaybackInfo(this.timeline, mediaPeriodId, j2, j3, this.playbackState, this.playbackError, this.isLoading, trackGroupArray, trackSelectorResult, list, this.loadingMediaPeriodId, this.playWhenReady, this.playbackSuppressionReason, this.playbackParameters, this.bufferedPositionUs, j4, j, SystemClock.elapsedRealtime(), this.sleepingForOffload); } public PlaybackInfo copyWithTimeline(Timeline timeline) { return new PlaybackInfo(timeline, this.periodId, this.requestedContentPositionUs, this.discontinuityStartPositionUs, this.playbackState, this.playbackError, this.isLoading, this.trackGroups, this.trackSelectorResult, this.staticMetadata, this.loadingMediaPeriodId, this.playWhenReady, this.playbackSuppressionReason, this.playbackParameters, this.bufferedPositionUs, this.totalBufferedDurationUs, this.positionUs, this.positionUpdateTimeMs, this.sleepingForOffload); } public PlaybackInfo copyWithPlaybackState(int i) { return new PlaybackInfo(this.timeline, this.periodId, this.requestedContentPositionUs, this.discontinuityStartPositionUs, i, this.playbackError, this.isLoading, this.trackGroups, this.trackSelectorResult, this.staticMetadata, this.loadingMediaPeriodId, this.playWhenReady, this.playbackSuppressionReason, this.playbackParameters, this.bufferedPositionUs, this.totalBufferedDurationUs, this.positionUs, this.positionUpdateTimeMs, this.sleepingForOffload); } public PlaybackInfo copyWithPlaybackError(ExoPlaybackException exoPlaybackException) { return new PlaybackInfo(this.timeline, this.periodId, this.requestedContentPositionUs, this.discontinuityStartPositionUs, this.playbackState, exoPlaybackException, this.isLoading, this.trackGroups, this.trackSelectorResult, this.staticMetadata, this.loadingMediaPeriodId, this.playWhenReady, this.playbackSuppressionReason, this.playbackParameters, this.bufferedPositionUs, this.totalBufferedDurationUs, this.positionUs, this.positionUpdateTimeMs, this.sleepingForOffload); } public PlaybackInfo copyWithIsLoading(boolean z) { return new PlaybackInfo(this.timeline, this.periodId, this.requestedContentPositionUs, this.discontinuityStartPositionUs, this.playbackState, this.playbackError, z, this.trackGroups, this.trackSelectorResult, this.staticMetadata, this.loadingMediaPeriodId, this.playWhenReady, this.playbackSuppressionReason, this.playbackParameters, this.bufferedPositionUs, this.totalBufferedDurationUs, this.positionUs, this.positionUpdateTimeMs, this.sleepingForOffload); } public PlaybackInfo copyWithLoadingMediaPeriodId(MediaSource.MediaPeriodId mediaPeriodId) { return new PlaybackInfo(this.timeline, this.periodId, this.requestedContentPositionUs, this.discontinuityStartPositionUs, this.playbackState, this.playbackError, this.isLoading, this.trackGroups, this.trackSelectorResult, this.staticMetadata, mediaPeriodId, this.playWhenReady, this.playbackSuppressionReason, this.playbackParameters, this.bufferedPositionUs, this.totalBufferedDurationUs, this.positionUs, this.positionUpdateTimeMs, this.sleepingForOffload); } public PlaybackInfo copyWithPlayWhenReady(boolean z, int i) { return new PlaybackInfo(this.timeline, this.periodId, this.requestedContentPositionUs, this.discontinuityStartPositionUs, this.playbackState, this.playbackError, this.isLoading, this.trackGroups, this.trackSelectorResult, this.staticMetadata, this.loadingMediaPeriodId, z, i, this.playbackParameters, this.bufferedPositionUs, this.totalBufferedDurationUs, this.positionUs, this.positionUpdateTimeMs, this.sleepingForOffload); } public PlaybackInfo copyWithPlaybackParameters(PlaybackParameters playbackParameters) { return new PlaybackInfo(this.timeline, this.periodId, this.requestedContentPositionUs, this.discontinuityStartPositionUs, this.playbackState, this.playbackError, this.isLoading, this.trackGroups, this.trackSelectorResult, this.staticMetadata, this.loadingMediaPeriodId, this.playWhenReady, this.playbackSuppressionReason, playbackParameters, this.bufferedPositionUs, this.totalBufferedDurationUs, this.positionUs, this.positionUpdateTimeMs, this.sleepingForOffload); } public PlaybackInfo copyWithSleepingForOffload(boolean z) { return new PlaybackInfo(this.timeline, this.periodId, this.requestedContentPositionUs, this.discontinuityStartPositionUs, this.playbackState, this.playbackError, this.isLoading, this.trackGroups, this.trackSelectorResult, this.staticMetadata, this.loadingMediaPeriodId, this.playWhenReady, this.playbackSuppressionReason, this.playbackParameters, this.bufferedPositionUs, this.totalBufferedDurationUs, this.positionUs, this.positionUpdateTimeMs, z); } public PlaybackInfo copyWithEstimatedPosition() { return new PlaybackInfo(this.timeline, this.periodId, this.requestedContentPositionUs, this.discontinuityStartPositionUs, this.playbackState, this.playbackError, this.isLoading, this.trackGroups, this.trackSelectorResult, this.staticMetadata, this.loadingMediaPeriodId, this.playWhenReady, this.playbackSuppressionReason, this.playbackParameters, this.bufferedPositionUs, this.totalBufferedDurationUs, getEstimatedPositionUs(), SystemClock.elapsedRealtime(), this.sleepingForOffload); } public void updatePositionUs(long j) { this.positionUs = j; this.positionUpdateTimeMs = SystemClock.elapsedRealtime(); } public long getEstimatedPositionUs() { long j; long j2; if (!isPlaying()) { return this.positionUs; } do { j = this.positionUpdateTimeMs; j2 = this.positionUs; } while (j != this.positionUpdateTimeMs); return Util.msToUs(Util.usToMs(j2) + (((float) (SystemClock.elapsedRealtime() - j)) * this.playbackParameters.speed)); } }