Store a MediaPeriodId in PlaybackInfo
------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=160271631
This commit is contained in:
parent
675756d32d
commit
1dcad4d173
@ -281,7 +281,7 @@ import java.util.concurrent.CopyOnWriteArraySet;
|
||||
if (timeline.isEmpty() || pendingSeekAcks > 0) {
|
||||
return maskingPeriodIndex;
|
||||
} else {
|
||||
return playbackInfo.periodIndex;
|
||||
return playbackInfo.periodId.periodIndex;
|
||||
}
|
||||
}
|
||||
|
||||
@ -290,7 +290,7 @@ import java.util.concurrent.CopyOnWriteArraySet;
|
||||
if (timeline.isEmpty() || pendingSeekAcks > 0) {
|
||||
return maskingWindowIndex;
|
||||
} else {
|
||||
return timeline.getPeriod(playbackInfo.periodIndex, period).windowIndex;
|
||||
return timeline.getPeriod(playbackInfo.periodId.periodIndex, period).windowIndex;
|
||||
}
|
||||
}
|
||||
|
||||
@ -307,7 +307,7 @@ import java.util.concurrent.CopyOnWriteArraySet;
|
||||
if (timeline.isEmpty() || pendingSeekAcks > 0) {
|
||||
return maskingWindowPositionMs;
|
||||
} else {
|
||||
timeline.getPeriod(playbackInfo.periodIndex, period);
|
||||
timeline.getPeriod(playbackInfo.periodId.periodIndex, period);
|
||||
return period.getPositionInWindowMs() + C.usToMs(playbackInfo.positionUs);
|
||||
}
|
||||
}
|
||||
@ -318,7 +318,7 @@ import java.util.concurrent.CopyOnWriteArraySet;
|
||||
if (timeline.isEmpty() || pendingSeekAcks > 0) {
|
||||
return maskingWindowPositionMs;
|
||||
} else {
|
||||
timeline.getPeriod(playbackInfo.periodIndex, period);
|
||||
timeline.getPeriod(playbackInfo.periodId.periodIndex, period);
|
||||
return period.getPositionInWindowMs() + C.usToMs(playbackInfo.bufferedPositionUs);
|
||||
}
|
||||
}
|
||||
|
@ -50,21 +50,25 @@ import java.io.IOException;
|
||||
*/
|
||||
public static final class PlaybackInfo {
|
||||
|
||||
public final int periodIndex;
|
||||
public final MediaPeriodId periodId;
|
||||
public final long startPositionUs;
|
||||
|
||||
public volatile long positionUs;
|
||||
public volatile long bufferedPositionUs;
|
||||
|
||||
public PlaybackInfo(int periodIndex, long startPositionUs) {
|
||||
this.periodIndex = periodIndex;
|
||||
this(new MediaPeriodId(periodIndex), startPositionUs);
|
||||
}
|
||||
|
||||
public PlaybackInfo(MediaPeriodId periodId, long startPositionUs) {
|
||||
this.periodId = periodId;
|
||||
this.startPositionUs = startPositionUs;
|
||||
positionUs = startPositionUs;
|
||||
bufferedPositionUs = startPositionUs;
|
||||
}
|
||||
|
||||
public PlaybackInfo copyWithPeriodIndex(int periodIndex) {
|
||||
PlaybackInfo playbackInfo = new PlaybackInfo(periodIndex, startPositionUs);
|
||||
public PlaybackInfo copyWithPeriodId(MediaPeriodId periodId) {
|
||||
PlaybackInfo playbackInfo = new PlaybackInfo(periodId.periodIndex, startPositionUs);
|
||||
playbackInfo.positionUs = positionUs;
|
||||
playbackInfo.bufferedPositionUs = bufferedPositionUs;
|
||||
return playbackInfo;
|
||||
@ -654,7 +658,7 @@ import java.io.IOException;
|
||||
long periodPositionUs = periodPosition.second;
|
||||
|
||||
try {
|
||||
if (periodIndex == playbackInfo.periodIndex
|
||||
if (periodIndex == playbackInfo.periodId.periodIndex
|
||||
&& ((periodPositionUs / 1000) == (playbackInfo.positionUs / 1000))) {
|
||||
// Seek position equals the current position. Do nothing.
|
||||
return;
|
||||
@ -1017,8 +1021,8 @@ import java.io.IOException;
|
||||
|
||||
// The current period is in the new timeline. Update the holder and playbackInfo.
|
||||
periodHolder.setPeriodIndex(periodIndex, isFinalPeriod(periodIndex));
|
||||
if (periodIndex != playbackInfo.periodIndex) {
|
||||
playbackInfo = playbackInfo.copyWithPeriodIndex(periodIndex);
|
||||
if (periodIndex != playbackInfo.periodId.periodIndex) {
|
||||
playbackInfo = playbackInfo.copyWithPeriodId(new MediaPeriodId(periodIndex));
|
||||
}
|
||||
|
||||
// If there are subsequent holders, update the index for each of them. If we find a holder
|
||||
@ -1301,7 +1305,7 @@ import java.io.IOException;
|
||||
private void maybeUpdateLoadingPeriod() throws IOException {
|
||||
int newLoadingPeriodIndex;
|
||||
if (loadingPeriodHolder == null) {
|
||||
newLoadingPeriodIndex = playbackInfo.periodIndex;
|
||||
newLoadingPeriodIndex = playbackInfo.periodId.periodIndex;
|
||||
} else {
|
||||
int loadingPeriodIndex = loadingPeriodHolder.periodIndex;
|
||||
if (loadingPeriodHolder.isFinal || !loadingPeriodHolder.isFullyBuffered()
|
||||
|
@ -16,6 +16,7 @@
|
||||
package com.google.android.exoplayer2.source;
|
||||
|
||||
import android.support.annotation.Nullable;
|
||||
import com.google.android.exoplayer2.C;
|
||||
import com.google.android.exoplayer2.ExoPlayer;
|
||||
import com.google.android.exoplayer2.Timeline;
|
||||
import com.google.android.exoplayer2.upstream.Allocator;
|
||||
@ -51,13 +52,28 @@ public interface MediaSource {
|
||||
*/
|
||||
public final int periodIndex;
|
||||
|
||||
/**
|
||||
* If the media period is in an ad break, the index of the ad break in the period.
|
||||
* {@link C#INDEX_UNSET} otherwise.
|
||||
*/
|
||||
public final int adBreakIndex;
|
||||
|
||||
/**
|
||||
* If the media period is in an ad break, the index of the ad in its ad break in the period.
|
||||
* {@link C#INDEX_UNSET} otherwise.
|
||||
*/
|
||||
public final int adIndexInAdBreak;
|
||||
|
||||
/**
|
||||
* Creates a media period identifier for the specified period in the timeline.
|
||||
*
|
||||
* @param periodIndex The timeline period index.
|
||||
*/
|
||||
public MediaPeriodId(int periodIndex) {
|
||||
// TODO: Allow creation of MediaPeriodIds for ad breaks.
|
||||
this.periodIndex = periodIndex;
|
||||
adBreakIndex = C.INDEX_UNSET;
|
||||
adIndexInAdBreak = C.INDEX_UNSET;
|
||||
}
|
||||
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user