use of com.google.android.exoplayer2.source.MediaSource in project ExoPlayer by google.
the class DashMediaSourceTest method prepare_withSuggestedPresentationDelayAndMinBufferTime_usesManifestValue.
@Test
public void prepare_withSuggestedPresentationDelayAndMinBufferTime_usesManifestValue() throws InterruptedException {
DashMediaSource mediaSource = new DashMediaSource.Factory(() -> createSampleMpdDataSource(SAMPLE_MPD_LIVE_WITH_SUGGESTED_PRESENTATION_DELAY_2S_MIN_BUFFER_TIME_500MS)).setFallbackTargetLiveOffsetMs(1234L).createMediaSource(new MediaItem.Builder().setUri(Uri.EMPTY).setLiveConfiguration(new LiveConfiguration.Builder().setMaxPlaybackSpeed(1.05f).build()).build());
MediaItem.LiveConfiguration liveConfiguration = prepareAndWaitForTimelineRefresh(mediaSource).liveConfiguration;
assertThat(liveConfiguration.targetOffsetMs).isEqualTo(2_000L);
assertThat(liveConfiguration.minOffsetMs).isEqualTo(500L);
assertThat(liveConfiguration.maxOffsetMs).isEqualTo(58_000L);
assertThat(liveConfiguration.minPlaybackSpeed).isEqualTo(C.RATE_UNSET);
assertThat(liveConfiguration.maxPlaybackSpeed).isEqualTo(1.05f);
}
use of com.google.android.exoplayer2.source.MediaSource in project ExoPlayer by google.
the class DashMediaSourceTest method prepare_targetLiveOffsetInWindow_manifestTargetOffsetAndAlignedWindowStartPosition.
@Test
public void prepare_targetLiveOffsetInWindow_manifestTargetOffsetAndAlignedWindowStartPosition() throws InterruptedException {
DashMediaSource mediaSource = new DashMediaSource.Factory(() -> createSampleMpdDataSource(SAMPLE_MPD_LIVE_WITH_OFFSET_INSIDE_WINDOW)).createMediaSource(MediaItem.fromUri(Uri.EMPTY));
Window window = prepareAndWaitForTimelineRefresh(mediaSource);
// Expect the target live offset as defined in the manifest.
assertThat(window.liveConfiguration.targetOffsetMs).isEqualTo(3000);
// Expect the default position at the first segment start before the live edge.
assertThat(window.getDefaultPositionMs()).isEqualTo(2_000);
}
use of com.google.android.exoplayer2.source.MediaSource in project ExoPlayer by google.
the class DashMediaSourceTest method prepare_withCompleteServiceDescription_usesManifestValue.
@Test
public void prepare_withCompleteServiceDescription_usesManifestValue() throws InterruptedException {
DashMediaSource mediaSource = new DashMediaSource.Factory(() -> createSampleMpdDataSource(SAMPLE_MPD_LIVE_WITH_COMPLETE_SERVICE_DESCRIPTION)).setFallbackTargetLiveOffsetMs(1234L).createMediaSource(MediaItem.fromUri(Uri.EMPTY));
MediaItem.LiveConfiguration liveConfiguration = prepareAndWaitForTimelineRefresh(mediaSource).liveConfiguration;
assertThat(liveConfiguration.targetOffsetMs).isEqualTo(4_000L);
assertThat(liveConfiguration.minOffsetMs).isEqualTo(2_000L);
assertThat(liveConfiguration.maxOffsetMs).isEqualTo(6_000L);
assertThat(liveConfiguration.minPlaybackSpeed).isEqualTo(0.96f);
assertThat(liveConfiguration.maxPlaybackSpeed).isEqualTo(1.04f);
}
use of com.google.android.exoplayer2.source.MediaSource in project ExoPlayer by google.
the class DashMediaSourceTest method prepare_targetLiveOffsetTooShort_correctedTargetOffsetAndAlignedWindowStartPosition.
@Test
public void prepare_targetLiveOffsetTooShort_correctedTargetOffsetAndAlignedWindowStartPosition() throws InterruptedException {
// Load manifest with now time far behind the start of the window.
DashMediaSource mediaSource = new DashMediaSource.Factory(() -> createSampleMpdDataSource(SAMPLE_MPD_LIVE_WITH_OFFSET_TOO_SHORT)).createMediaSource(MediaItem.fromUri(Uri.EMPTY));
Window window = prepareAndWaitForTimelineRefresh(mediaSource);
// Expect the default position at the start of the last segment.
assertThat(window.getDefaultPositionMs()).isEqualTo(12_000);
// Expect the target live offset reaching from now time to the end of the window.
assertThat(window.liveConfiguration.targetOffsetMs).isEqualTo(60_000 - 16_000);
}
use of com.google.android.exoplayer2.source.MediaSource in project ExoPlayer by google.
the class DefaultMediaSourceFactoryTest method createMediaSource_withNull_usesNonNullDefaults.
@Test
public void createMediaSource_withNull_usesNonNullDefaults() {
DefaultMediaSourceFactory defaultMediaSourceFactory = new DefaultMediaSourceFactory((Context) ApplicationProvider.getApplicationContext());
MediaItem mediaItem = new MediaItem.Builder().setUri(URI_MEDIA + "/file.ism").build();
MediaSource mediaSource = defaultMediaSourceFactory.setDrmSessionManagerProvider(null).setLoadErrorHandlingPolicy(null).createMediaSource(mediaItem);
assertThat(mediaSource).isNotNull();
}
Aggregations