Move positionUs parameter from createPeriod to prepare

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=158494794
This commit is contained in:
andrewlewis 2017-06-09 01:52:54 -07:00 committed by Oliver Woodman
parent 047e0eb645
commit 4e006a9616
22 changed files with 59 additions and 64 deletions

View File

@ -159,12 +159,12 @@ public final class ImaAdsMediaSource implements MediaSource {
} }
@Override @Override
public MediaPeriod createPeriod(int index, Allocator allocator, long positionUs) { public MediaPeriod createPeriod(int index, Allocator allocator) {
if (timeline.isPeriodAd(index)) { if (timeline.isPeriodAd(index)) {
int adBreakIndex = timeline.getAdBreakIndex(index); int adBreakIndex = timeline.getAdBreakIndex(index);
int adIndexInAdBreak = timeline.getAdIndexInAdBreak(index); int adIndexInAdBreak = timeline.getAdIndexInAdBreak(index);
if (adIndexInAdBreak >= adBreakMediaSources[adBreakIndex].length) { if (adIndexInAdBreak >= adBreakMediaSources[adBreakIndex].length) {
DeferredMediaPeriod deferredPeriod = new DeferredMediaPeriod(0, allocator, positionUs); DeferredMediaPeriod deferredPeriod = new DeferredMediaPeriod(0, allocator);
if (adIndexInAdBreak >= adBreakDeferredMediaPeriods[adBreakIndex].length) { if (adIndexInAdBreak >= adBreakDeferredMediaPeriods[adBreakIndex].length) {
adBreakDeferredMediaPeriods[adBreakIndex] = Arrays.copyOf( adBreakDeferredMediaPeriods[adBreakIndex] = Arrays.copyOf(
adBreakDeferredMediaPeriods[adBreakIndex], adIndexInAdBreak + 1); adBreakDeferredMediaPeriods[adBreakIndex], adIndexInAdBreak + 1);
@ -174,15 +174,13 @@ public final class ImaAdsMediaSource implements MediaSource {
} }
MediaSource adBreakMediaSource = adBreakMediaSources[adBreakIndex][adIndexInAdBreak]; MediaSource adBreakMediaSource = adBreakMediaSources[adBreakIndex][adIndexInAdBreak];
MediaPeriod adBreakMediaPeriod = adBreakMediaSource.createPeriod(0, allocator, positionUs); MediaPeriod adBreakMediaPeriod = adBreakMediaSource.createPeriod(0, allocator);
mediaSourceByMediaPeriod.put(adBreakMediaPeriod, adBreakMediaSource); mediaSourceByMediaPeriod.put(adBreakMediaPeriod, adBreakMediaSource);
return adBreakMediaPeriod; return adBreakMediaPeriod;
} else { } else {
long startUs = timeline.getContentStartTimeUs(index); long startUs = timeline.getContentStartTimeUs(index);
long endUs = timeline.getContentEndTimeUs(index); long endUs = timeline.getContentEndTimeUs(index);
long contentStartUs = startUs + positionUs; MediaPeriod contentMediaPeriod = contentMediaSource.createPeriod(0, allocator);
MediaPeriod contentMediaPeriod = contentMediaSource.createPeriod(0, allocator,
contentStartUs);
ClippingMediaPeriod clippingPeriod = new ClippingMediaPeriod(contentMediaPeriod); ClippingMediaPeriod clippingPeriod = new ClippingMediaPeriod(contentMediaPeriod);
clippingPeriod.setClipping(startUs, endUs == C.TIME_UNSET ? C.TIME_END_OF_SOURCE : endUs); clippingPeriod.setClipping(startUs, endUs == C.TIME_UNSET ? C.TIME_END_OF_SOURCE : endUs);
mediaSourceByMediaPeriod.put(contentMediaPeriod, contentMediaSource); mediaSourceByMediaPeriod.put(contentMediaPeriod, contentMediaSource);
@ -436,29 +434,29 @@ public final class ImaAdsMediaSource implements MediaSource {
private final int index; private final int index;
private final Allocator allocator; private final Allocator allocator;
private final long positionUs;
public MediaPeriod mediaPeriod; public MediaPeriod mediaPeriod;
private MediaPeriod.Callback callback; private MediaPeriod.Callback callback;
private long positionUs;
public DeferredMediaPeriod(int index, Allocator allocator, long positionUs) { public DeferredMediaPeriod(int index, Allocator allocator) {
this.index = index; this.index = index;
this.allocator = allocator; this.allocator = allocator;
this.positionUs = positionUs;
} }
public void setMediaSource(MediaSource mediaSource) { public void setMediaSource(MediaSource mediaSource) {
mediaPeriod = mediaSource.createPeriod(index, allocator, positionUs); mediaPeriod = mediaSource.createPeriod(index, allocator);
if (callback != null) { if (callback != null) {
mediaPeriod.prepare(this); mediaPeriod.prepare(this, positionUs);
} }
} }
@Override @Override
public void prepare(Callback callback) { public void prepare(Callback callback, long positionUs) {
this.callback = callback; this.callback = callback;
this.positionUs = positionUs;
if (mediaPeriod != null) { if (mediaPeriod != null) {
mediaPeriod.prepare(this); mediaPeriod.prepare(this, positionUs);
} }
} }

View File

@ -535,11 +535,10 @@ public final class ExoPlayerTest extends TestCase {
} }
@Override @Override
public MediaPeriod createPeriod(int index, Allocator allocator, long positionUs) { public MediaPeriod createPeriod(int index, Allocator allocator) {
Assertions.checkIndex(index, 0, timeline.getPeriodCount()); Assertions.checkIndex(index, 0, timeline.getPeriodCount());
assertTrue(preparedSource); assertTrue(preparedSource);
assertFalse(releasedSource); assertFalse(releasedSource);
assertEquals(0, positionUs);
FakeMediaPeriod mediaPeriod = new FakeMediaPeriod(trackGroupArray); FakeMediaPeriod mediaPeriod = new FakeMediaPeriod(trackGroupArray);
activeMediaPeriods.add(mediaPeriod); activeMediaPeriods.add(mediaPeriod);
return mediaPeriod; return mediaPeriod;
@ -583,8 +582,9 @@ public final class ExoPlayerTest extends TestCase {
} }
@Override @Override
public void prepare(Callback callback) { public void prepare(Callback callback, long positionUs) {
assertFalse(preparedPeriod); assertFalse(preparedPeriod);
assertEquals(0, positionUs);
preparedPeriod = true; preparedPeriod = true;
callback.onPrepared(this); callback.onPrepared(this);
} }

View File

@ -87,7 +87,7 @@ public class TimelineTest extends TestCase {
} }
@Override @Override
public MediaPeriod createPeriod(int index, Allocator allocator, long positionUs) { public MediaPeriod createPeriod(int index, Allocator allocator) {
return null; return null;
} }

View File

@ -1352,7 +1352,7 @@ import java.io.IOException;
loadingPeriodHolder.next = newPeriodHolder; loadingPeriodHolder.next = newPeriodHolder;
} }
loadingPeriodHolder = newPeriodHolder; loadingPeriodHolder = newPeriodHolder;
loadingPeriodHolder.mediaPeriod.prepare(this); loadingPeriodHolder.mediaPeriod.prepare(this, newLoadingPeriodStartPositionUs);
setIsLoading(true); setIsLoading(true);
} }
@ -1528,8 +1528,7 @@ import java.io.IOException;
this.startPositionUs = startPositionUs; this.startPositionUs = startPositionUs;
sampleStreams = new SampleStream[renderers.length]; sampleStreams = new SampleStream[renderers.length];
mayRetainStreamFlags = new boolean[renderers.length]; mayRetainStreamFlags = new boolean[renderers.length];
mediaPeriod = mediaSource.createPeriod(periodIndex, loadControl.getAllocator(), mediaPeriod = mediaSource.createPeriod(periodIndex, loadControl.getAllocator());
startPositionUs);
} }
public long toRendererTime(long periodTimeUs) { public long toRendererTime(long periodTimeUs) {

View File

@ -68,9 +68,9 @@ public final class ClippingMediaPeriod implements MediaPeriod, MediaPeriod.Callb
} }
@Override @Override
public void prepare(MediaPeriod.Callback callback) { public void prepare(MediaPeriod.Callback callback, long positionUs) {
this.callback = callback; this.callback = callback;
mediaPeriod.prepare(this); mediaPeriod.prepare(this, startUs + positionUs);
} }
@Override @Override

View File

@ -69,9 +69,9 @@ public final class ClippingMediaSource implements MediaSource, MediaSource.Liste
} }
@Override @Override
public MediaPeriod createPeriod(int index, Allocator allocator, long positionUs) { public MediaPeriod createPeriod(int index, Allocator allocator) {
ClippingMediaPeriod mediaPeriod = new ClippingMediaPeriod( ClippingMediaPeriod mediaPeriod =
mediaSource.createPeriod(index, allocator, startUs + positionUs)); new ClippingMediaPeriod(mediaSource.createPeriod(index, allocator));
mediaPeriods.add(mediaPeriod); mediaPeriods.add(mediaPeriod);
mediaPeriod.setClipping(clippingTimeline.startUs, clippingTimeline.endUs); mediaPeriod.setClipping(clippingTimeline.startUs, clippingTimeline.endUs);
return mediaPeriod; return mediaPeriod;

View File

@ -91,11 +91,11 @@ public final class ConcatenatingMediaSource implements MediaSource {
} }
@Override @Override
public MediaPeriod createPeriod(int index, Allocator allocator, long positionUs) { public MediaPeriod createPeriod(int index, Allocator allocator) {
int sourceIndex = timeline.getChildIndexForPeriod(index); int sourceIndex = timeline.getChildIndexForPeriod(index);
int periodIndexInSource = index - timeline.getFirstPeriodIndexInChild(sourceIndex); int periodIndexInSource = index - timeline.getFirstPeriodIndexInChild(sourceIndex);
MediaPeriod mediaPeriod = mediaSources[sourceIndex].createPeriod(periodIndexInSource, allocator, MediaPeriod mediaPeriod =
positionUs); mediaSources[sourceIndex].createPeriod(periodIndexInSource, allocator);
sourceIndexByMediaPeriod.put(mediaPeriod, sourceIndex); sourceIndexByMediaPeriod.put(mediaPeriod, sourceIndex);
return mediaPeriod; return mediaPeriod;
} }

View File

@ -159,7 +159,7 @@ import java.io.IOException;
} }
@Override @Override
public void prepare(Callback callback) { public void prepare(Callback callback, long positionUs) {
this.callback = callback; this.callback = callback;
loadCondition.open(); loadCondition.open();
startLoading(); startLoading();

View File

@ -156,7 +156,7 @@ public final class ExtractorMediaSource implements MediaSource, MediaSource.List
} }
@Override @Override
public MediaPeriod createPeriod(int index, Allocator allocator, long positionUs) { public MediaPeriod createPeriod(int index, Allocator allocator) {
Assertions.checkArgument(index == 0); Assertions.checkArgument(index == 0);
return new ExtractorMediaPeriod(uri, dataSourceFactory.createDataSource(), return new ExtractorMediaPeriod(uri, dataSourceFactory.createDataSource(),
extractorsFactory.createExtractors(), minLoadableRetryCount, eventHandler, eventListener, extractorsFactory.createExtractors(), minLoadableRetryCount, eventHandler, eventListener,

View File

@ -76,10 +76,10 @@ public final class LoopingMediaSource implements MediaSource {
} }
@Override @Override
public MediaPeriod createPeriod(int index, Allocator allocator, long positionUs) { public MediaPeriod createPeriod(int index, Allocator allocator) {
return loopCount != Integer.MAX_VALUE return loopCount != Integer.MAX_VALUE
? childSource.createPeriod(index % childPeriodCount, allocator, positionUs) ? childSource.createPeriod(index % childPeriodCount, allocator)
: childSource.createPeriod(index, allocator, positionUs); : childSource.createPeriod(index, allocator);
} }
@Override @Override

View File

@ -55,8 +55,10 @@ public interface MediaPeriod extends SequenceableLoader {
* *
* @param callback Callback to receive updates from this period, including being notified when * @param callback Callback to receive updates from this period, including being notified when
* preparation completes. * preparation completes.
* @param positionUs The position in microseconds relative to the start of the period at which to
* start loading data.
*/ */
void prepare(Callback callback); void prepare(Callback callback, long positionUs);
/** /**
* Throws an error that's preventing the period from becoming prepared. Does nothing if no such * Throws an error that's preventing the period from becoming prepared. Does nothing if no such
@ -162,9 +164,9 @@ public interface MediaPeriod extends SequenceableLoader {
* This method may be called both during and after the period has been prepared. * This method may be called both during and after the period has been prepared.
* <p> * <p>
* A period may call {@link Callback#onContinueLoadingRequested(SequenceableLoader)} on the * A period may call {@link Callback#onContinueLoadingRequested(SequenceableLoader)} on the
* {@link Callback} passed to {@link #prepare(Callback)} to request that this method be called * {@link Callback} passed to {@link #prepare(Callback, long)} to request that this method be
* when the period is permitted to continue loading data. A period may do this both during and * called when the period is permitted to continue loading data. A period may do this both during
* after preparation. * and after preparation.
* *
* @param positionUs The current playback position. * @param positionUs The current playback position.
* @return True if progress was made, meaning that {@link #getNextLoadPositionUs()} will return * @return True if progress was made, meaning that {@link #getNextLoadPositionUs()} will return

View File

@ -64,10 +64,9 @@ public interface MediaSource {
* *
* @param index The index of the period. * @param index The index of the period.
* @param allocator An {@link Allocator} from which to obtain media buffer allocations. * @param allocator An {@link Allocator} from which to obtain media buffer allocations.
* @param positionUs The player's current playback position.
* @return A new {@link MediaPeriod}. * @return A new {@link MediaPeriod}.
*/ */
MediaPeriod createPeriod(int index, Allocator allocator, long positionUs); MediaPeriod createPeriod(int index, Allocator allocator);
/** /**
* Releases the period. * Releases the period.

View File

@ -44,11 +44,11 @@ import java.util.IdentityHashMap;
} }
@Override @Override
public void prepare(Callback callback) { public void prepare(Callback callback, long positionUs) {
this.callback = callback; this.callback = callback;
pendingChildPrepareCount = periods.length; pendingChildPrepareCount = periods.length;
for (MediaPeriod period : periods) { for (MediaPeriod period : periods) {
period.prepare(this); period.prepare(this, positionUs);
} }
} }

View File

@ -116,10 +116,10 @@ public final class MergingMediaSource implements MediaSource {
} }
@Override @Override
public MediaPeriod createPeriod(int index, Allocator allocator, long positionUs) { public MediaPeriod createPeriod(int index, Allocator allocator) {
MediaPeriod[] periods = new MediaPeriod[mediaSources.length]; MediaPeriod[] periods = new MediaPeriod[mediaSources.length];
for (int i = 0; i < periods.length; i++) { for (int i = 0; i < periods.length; i++) {
periods[i] = mediaSources[i].createPeriod(index, allocator, positionUs); periods[i] = mediaSources[i].createPeriod(index, allocator);
} }
return new MergingMediaPeriod(periods); return new MergingMediaPeriod(periods);
} }

View File

@ -79,7 +79,7 @@ import java.util.Arrays;
} }
@Override @Override
public void prepare(Callback callback) { public void prepare(Callback callback, long positionUs) {
callback.onPrepared(this); callback.onPrepared(this);
} }

View File

@ -95,7 +95,7 @@ public final class SingleSampleMediaSource implements MediaSource {
} }
@Override @Override
public MediaPeriod createPeriod(int index, Allocator allocator, long positionUs) { public MediaPeriod createPeriod(int index, Allocator allocator) {
Assertions.checkArgument(index == 0); Assertions.checkArgument(index == 0);
return new SingleSampleMediaPeriod(uri, dataSourceFactory, format, minLoadableRetryCount, return new SingleSampleMediaPeriod(uri, dataSourceFactory, format, minLoadableRetryCount,
eventHandler, eventListener, eventSourceId); eventHandler, eventListener, eventSourceId);

View File

@ -106,7 +106,7 @@ import java.util.List;
} }
@Override @Override
public void prepare(Callback callback) { public void prepare(Callback callback, long positionUs) {
this.callback = callback; this.callback = callback;
callback.onPrepared(this); callback.onPrepared(this);
} }

View File

@ -281,7 +281,7 @@ public final class DashMediaSource implements MediaSource {
} }
@Override @Override
public MediaPeriod createPeriod(int periodIndex, Allocator allocator, long positionUs) { public MediaPeriod createPeriod(int periodIndex, Allocator allocator) {
EventDispatcher periodEventDispatcher = eventDispatcher.copyWithMediaTimeOffsetMs( EventDispatcher periodEventDispatcher = eventDispatcher.copyWithMediaTimeOffsetMs(
manifest.getPeriod(periodIndex).startMs); manifest.getPeriod(periodIndex).startMs);
DashMediaPeriod mediaPeriod = new DashMediaPeriod(firstPeriodId + periodIndex, manifest, DashMediaPeriod mediaPeriod = new DashMediaPeriod(firstPeriodId + periodIndex, manifest,

View File

@ -51,7 +51,6 @@ public final class HlsMediaPeriod implements MediaPeriod, HlsSampleStreamWrapper
private final IdentityHashMap<SampleStream, Integer> streamWrapperIndices; private final IdentityHashMap<SampleStream, Integer> streamWrapperIndices;
private final TimestampAdjusterProvider timestampAdjusterProvider; private final TimestampAdjusterProvider timestampAdjusterProvider;
private final Handler continueLoadingHandler; private final Handler continueLoadingHandler;
private final long preparePositionUs;
private Callback callback; private Callback callback;
private int pendingPrepareCount; private int pendingPrepareCount;
@ -62,8 +61,7 @@ public final class HlsMediaPeriod implements MediaPeriod, HlsSampleStreamWrapper
private CompositeSequenceableLoader sequenceableLoader; private CompositeSequenceableLoader sequenceableLoader;
public HlsMediaPeriod(HlsPlaylistTracker playlistTracker, HlsDataSourceFactory dataSourceFactory, public HlsMediaPeriod(HlsPlaylistTracker playlistTracker, HlsDataSourceFactory dataSourceFactory,
int minLoadableRetryCount, EventDispatcher eventDispatcher, Allocator allocator, int minLoadableRetryCount, EventDispatcher eventDispatcher, Allocator allocator) {
long positionUs) {
this.playlistTracker = playlistTracker; this.playlistTracker = playlistTracker;
this.dataSourceFactory = dataSourceFactory; this.dataSourceFactory = dataSourceFactory;
this.minLoadableRetryCount = minLoadableRetryCount; this.minLoadableRetryCount = minLoadableRetryCount;
@ -72,7 +70,6 @@ public final class HlsMediaPeriod implements MediaPeriod, HlsSampleStreamWrapper
streamWrapperIndices = new IdentityHashMap<>(); streamWrapperIndices = new IdentityHashMap<>();
timestampAdjusterProvider = new TimestampAdjusterProvider(); timestampAdjusterProvider = new TimestampAdjusterProvider();
continueLoadingHandler = new Handler(); continueLoadingHandler = new Handler();
preparePositionUs = positionUs;
} }
public void release() { public void release() {
@ -86,10 +83,10 @@ public final class HlsMediaPeriod implements MediaPeriod, HlsSampleStreamWrapper
} }
@Override @Override
public void prepare(Callback callback) { public void prepare(Callback callback, long positionUs) {
playlistTracker.addListener(this); playlistTracker.addListener(this);
this.callback = callback; this.callback = callback;
buildAndPrepareSampleStreamWrappers(); buildAndPrepareSampleStreamWrappers(positionUs);
} }
@Override @Override
@ -285,7 +282,7 @@ public final class HlsMediaPeriod implements MediaPeriod, HlsSampleStreamWrapper
// Internal methods. // Internal methods.
private void buildAndPrepareSampleStreamWrappers() { private void buildAndPrepareSampleStreamWrappers(long positionUs) {
HlsMasterPlaylist masterPlaylist = playlistTracker.getMasterPlaylist(); HlsMasterPlaylist masterPlaylist = playlistTracker.getMasterPlaylist();
// Build the default stream wrapper. // Build the default stream wrapper.
List<HlsUrl> selectedVariants = new ArrayList<>(masterPlaylist.variants); List<HlsUrl> selectedVariants = new ArrayList<>(masterPlaylist.variants);
@ -322,7 +319,7 @@ public final class HlsMediaPeriod implements MediaPeriod, HlsSampleStreamWrapper
HlsUrl[] variants = new HlsMasterPlaylist.HlsUrl[selectedVariants.size()]; HlsUrl[] variants = new HlsMasterPlaylist.HlsUrl[selectedVariants.size()];
selectedVariants.toArray(variants); selectedVariants.toArray(variants);
HlsSampleStreamWrapper sampleStreamWrapper = buildSampleStreamWrapper(C.TRACK_TYPE_DEFAULT, HlsSampleStreamWrapper sampleStreamWrapper = buildSampleStreamWrapper(C.TRACK_TYPE_DEFAULT,
variants, masterPlaylist.muxedAudioFormat, masterPlaylist.muxedCaptionFormats); variants, masterPlaylist.muxedAudioFormat, masterPlaylist.muxedCaptionFormats, positionUs);
sampleStreamWrappers[currentWrapperIndex++] = sampleStreamWrapper; sampleStreamWrappers[currentWrapperIndex++] = sampleStreamWrapper;
sampleStreamWrapper.setIsTimestampMaster(true); sampleStreamWrapper.setIsTimestampMaster(true);
sampleStreamWrapper.continuePreparing(); sampleStreamWrapper.continuePreparing();
@ -332,7 +329,7 @@ public final class HlsMediaPeriod implements MediaPeriod, HlsSampleStreamWrapper
// Build audio stream wrappers. // Build audio stream wrappers.
for (int i = 0; i < audioRenditions.size(); i++) { for (int i = 0; i < audioRenditions.size(); i++) {
sampleStreamWrapper = buildSampleStreamWrapper(C.TRACK_TYPE_AUDIO, sampleStreamWrapper = buildSampleStreamWrapper(C.TRACK_TYPE_AUDIO,
new HlsUrl[] {audioRenditions.get(i)}, null, Collections.<Format>emptyList()); new HlsUrl[] {audioRenditions.get(i)}, null, Collections.<Format>emptyList(), positionUs);
sampleStreamWrappers[currentWrapperIndex++] = sampleStreamWrapper; sampleStreamWrappers[currentWrapperIndex++] = sampleStreamWrapper;
sampleStreamWrapper.continuePreparing(); sampleStreamWrapper.continuePreparing();
} }
@ -341,18 +338,18 @@ public final class HlsMediaPeriod implements MediaPeriod, HlsSampleStreamWrapper
for (int i = 0; i < subtitleRenditions.size(); i++) { for (int i = 0; i < subtitleRenditions.size(); i++) {
HlsUrl url = subtitleRenditions.get(i); HlsUrl url = subtitleRenditions.get(i);
sampleStreamWrapper = buildSampleStreamWrapper(C.TRACK_TYPE_TEXT, new HlsUrl[] {url}, null, sampleStreamWrapper = buildSampleStreamWrapper(C.TRACK_TYPE_TEXT, new HlsUrl[] {url}, null,
Collections.<Format>emptyList()); Collections.<Format>emptyList(), positionUs);
sampleStreamWrapper.prepareSingleTrack(url.format); sampleStreamWrapper.prepareSingleTrack(url.format);
sampleStreamWrappers[currentWrapperIndex++] = sampleStreamWrapper; sampleStreamWrappers[currentWrapperIndex++] = sampleStreamWrapper;
} }
} }
private HlsSampleStreamWrapper buildSampleStreamWrapper(int trackType, HlsUrl[] variants, private HlsSampleStreamWrapper buildSampleStreamWrapper(int trackType, HlsUrl[] variants,
Format muxedAudioFormat, List<Format> muxedCaptionFormats) { Format muxedAudioFormat, List<Format> muxedCaptionFormats, long positionUs) {
HlsChunkSource defaultChunkSource = new HlsChunkSource(playlistTracker, variants, HlsChunkSource defaultChunkSource = new HlsChunkSource(playlistTracker, variants,
dataSourceFactory, timestampAdjusterProvider, muxedCaptionFormats); dataSourceFactory, timestampAdjusterProvider, muxedCaptionFormats);
return new HlsSampleStreamWrapper(trackType, this, defaultChunkSource, allocator, return new HlsSampleStreamWrapper(trackType, this, defaultChunkSource, allocator, positionUs,
preparePositionUs, muxedAudioFormat, minLoadableRetryCount, eventDispatcher); muxedAudioFormat, minLoadableRetryCount, eventDispatcher);
} }
private void continuePreparingOrLoading() { private void continuePreparingOrLoading() {

View File

@ -88,10 +88,10 @@ public final class HlsMediaSource implements MediaSource,
} }
@Override @Override
public MediaPeriod createPeriod(int index, Allocator allocator, long positionUs) { public MediaPeriod createPeriod(int index, Allocator allocator) {
Assertions.checkArgument(index == 0); Assertions.checkArgument(index == 0);
return new HlsMediaPeriod(playlistTracker, dataSourceFactory, minLoadableRetryCount, return new HlsMediaPeriod(playlistTracker, dataSourceFactory, minLoadableRetryCount,
eventDispatcher, allocator, positionUs); eventDispatcher, allocator);
} }
@Override @Override

View File

@ -93,7 +93,7 @@ import java.util.ArrayList;
} }
@Override @Override
public void prepare(Callback callback) { public void prepare(Callback callback, long positionUs) {
this.callback = callback; this.callback = callback;
callback.onPrepared(this); callback.onPrepared(this);
} }

View File

@ -222,7 +222,7 @@ public final class SsMediaSource implements MediaSource,
} }
@Override @Override
public MediaPeriod createPeriod(int index, Allocator allocator, long positionUs) { public MediaPeriod createPeriod(int index, Allocator allocator) {
Assertions.checkArgument(index == 0); Assertions.checkArgument(index == 0);
SsMediaPeriod period = new SsMediaPeriod(manifest, chunkSourceFactory, minLoadableRetryCount, SsMediaPeriod period = new SsMediaPeriod(manifest, chunkSourceFactory, minLoadableRetryCount,
eventDispatcher, manifestLoaderErrorThrower, allocator); eventDispatcher, manifestLoaderErrorThrower, allocator);