use of androidx.media3.exoplayer.upstream.Allocator in project media by androidx.
the class SsMediaSource method createPeriod.
@Override
public MediaPeriod createPeriod(MediaPeriodId id, Allocator allocator, long startPositionUs) {
MediaSourceEventListener.EventDispatcher mediaSourceEventDispatcher = createEventDispatcher(id);
DrmSessionEventListener.EventDispatcher drmEventDispatcher = createDrmEventDispatcher(id);
SsMediaPeriod period = new SsMediaPeriod(manifest, chunkSourceFactory, mediaTransferListener, compositeSequenceableLoaderFactory, drmSessionManager, drmEventDispatcher, loadErrorHandlingPolicy, mediaSourceEventDispatcher, manifestLoaderErrorThrower, allocator);
mediaPeriods.add(period);
return period;
}
use of androidx.media3.exoplayer.upstream.Allocator in project media by androidx.
the class MediaSourceList method createPeriod.
/**
* Returns a new {@link MediaPeriod} identified by {@code periodId}.
*
* @param id The identifier of the period.
* @param allocator An {@link Allocator} from which to obtain media buffer allocations.
* @param startPositionUs The expected start position, in microseconds.
* @return A new {@link MediaPeriod}.
*/
public MediaPeriod createPeriod(MediaSource.MediaPeriodId id, Allocator allocator, long startPositionUs) {
Object mediaSourceHolderUid = getMediaSourceHolderUid(id.periodUid);
MediaSource.MediaPeriodId childMediaPeriodId = id.copyWithPeriodUid(getChildPeriodUid(id.periodUid));
MediaSourceHolder holder = Assertions.checkNotNull(mediaSourceByUid.get(mediaSourceHolderUid));
enableMediaSource(holder);
holder.activeMediaPeriodIds.add(childMediaPeriodId);
MediaPeriod mediaPeriod = holder.mediaSource.createPeriod(childMediaPeriodId, allocator, startPositionUs);
mediaSourceByMediaPeriod.put(mediaPeriod, holder);
disableUnusedMediaSources();
return mediaPeriod;
}
use of androidx.media3.exoplayer.upstream.Allocator in project media by androidx.
the class ExoPlayerTest method seekDiscontinuityWithAdjustment.
@Test
public void seekDiscontinuityWithAdjustment() throws Exception {
FakeTimeline timeline = new FakeTimeline(1);
FakeMediaSource mediaSource = new FakeMediaSource(timeline, ExoPlayerTestRunner.VIDEO_FORMAT) {
@Override
protected MediaPeriod createMediaPeriod(MediaPeriodId id, TrackGroupArray trackGroupArray, Allocator allocator, MediaSourceEventListener.EventDispatcher mediaSourceEventDispatcher, DrmSessionManager drmSessionManager, DrmSessionEventListener.EventDispatcher drmEventDispatcher, @Nullable TransferListener transferListener) {
FakeMediaPeriod mediaPeriod = new FakeMediaPeriod(trackGroupArray, allocator, TimelineWindowDefinition.DEFAULT_WINDOW_OFFSET_IN_FIRST_PERIOD_US, mediaSourceEventDispatcher, drmSessionManager, drmEventDispatcher, /* deferOnPrepared= */
false);
mediaPeriod.setSeekToUsOffset(10);
return mediaPeriod;
}
};
ActionSchedule actionSchedule = new ActionSchedule.Builder(TAG).pause().waitForPlaybackState(Player.STATE_READY).seek(10).play().build();
ExoPlayerTestRunner testRunner = new ExoPlayerTestRunner.Builder(context).setMediaSources(mediaSource).setActionSchedule(actionSchedule).build().start().blockUntilEnded(TIMEOUT_MS);
testRunner.assertPositionDiscontinuityReasonsEqual(Player.DISCONTINUITY_REASON_SEEK, Player.DISCONTINUITY_REASON_SEEK_ADJUSTMENT);
}
use of androidx.media3.exoplayer.upstream.Allocator in project media by androidx.
the class ConcatenatingMediaSourceTest method childSourceIsPreparedWithLazyPreparationAfterPeriodCreation.
@Test
public void childSourceIsPreparedWithLazyPreparationAfterPeriodCreation() throws IOException {
FakeMediaSource[] childSources = createMediaSources(/* count= */
2);
mediaSource = new ConcatenatingMediaSource(/* isAtomic= */
false, /* useLazyPreparation= */
true, new DefaultShuffleOrder(0), childSources);
testRunner = new MediaSourceTestRunner(mediaSource, /* allocator= */
null);
Timeline timeline = testRunner.prepareSource();
testRunner.createPeriod(new MediaPeriodId(timeline.getUidOfPeriod(/* periodIndex= */
0), /* windowSequenceNumber= */
0));
assertThat(childSources[0].isPrepared()).isTrue();
assertThat(childSources[1].isPrepared()).isFalse();
}
use of androidx.media3.exoplayer.upstream.Allocator in project media by androidx.
the class ConcatenatingMediaSourceTest method removeUnpreparedChildSourceWithLazyPreparation.
@Test
public void removeUnpreparedChildSourceWithLazyPreparation() throws IOException {
FakeMediaSource[] childSources = createMediaSources(/* count= */
2);
mediaSource = new ConcatenatingMediaSource(/* isAtomic= */
false, /* useLazyPreparation= */
true, new DefaultShuffleOrder(0), childSources);
testRunner = new MediaSourceTestRunner(mediaSource, /* allocator= */
null);
testRunner.prepareSource();
// Check that removal doesn't throw even though the child sources are unprepared.
mediaSource.removeMediaSource(0);
}
Aggregations