Search in sources :

Example 61 with MediaSource

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);
}
Also used : LiveConfiguration(com.google.android.exoplayer2.MediaItem.LiveConfiguration) LiveConfiguration(com.google.android.exoplayer2.MediaItem.LiveConfiguration) MediaItem(com.google.android.exoplayer2.MediaItem) Test(org.junit.Test)

Example 62 with MediaSource

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);
}
Also used : Window(com.google.android.exoplayer2.Timeline.Window) Test(org.junit.Test)

Example 63 with MediaSource

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);
}
Also used : LiveConfiguration(com.google.android.exoplayer2.MediaItem.LiveConfiguration) MediaItem(com.google.android.exoplayer2.MediaItem) Test(org.junit.Test)

Example 64 with MediaSource

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);
}
Also used : Window(com.google.android.exoplayer2.Timeline.Window) Test(org.junit.Test)

Example 65 with MediaSource

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();
}
Also used : MediaSource(com.google.android.exoplayer2.source.MediaSource) DefaultMediaSourceFactory(com.google.android.exoplayer2.source.DefaultMediaSourceFactory) MediaItem(com.google.android.exoplayer2.MediaItem) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)182 MediaSource (com.google.android.exoplayer2.source.MediaSource)122 FakeMediaSource (com.google.android.exoplayer2.testutil.FakeMediaSource)117 FakeTimeline (com.google.android.exoplayer2.testutil.FakeTimeline)74 MediaItem (com.google.android.exoplayer2.MediaItem)72 ConcatenatingMediaSource (com.google.android.exoplayer2.source.ConcatenatingMediaSource)70 TestExoPlayerBuilder (com.google.android.exoplayer2.testutil.TestExoPlayerBuilder)70 ActionSchedule (com.google.android.exoplayer2.testutil.ActionSchedule)60 ClippingMediaSource (com.google.android.exoplayer2.source.ClippingMediaSource)52 CompositeMediaSource (com.google.android.exoplayer2.source.CompositeMediaSource)51 MaskingMediaSource (com.google.android.exoplayer2.source.MaskingMediaSource)51 ServerSideAdInsertionMediaSource (com.google.android.exoplayer2.source.ads.ServerSideAdInsertionMediaSource)50 FakeAdaptiveMediaSource (com.google.android.exoplayer2.testutil.FakeAdaptiveMediaSource)50 ExoPlayerTestRunner (com.google.android.exoplayer2.testutil.ExoPlayerTestRunner)45 SinglePeriodTimeline (com.google.android.exoplayer2.source.SinglePeriodTimeline)39 NoUidTimeline (com.google.android.exoplayer2.testutil.NoUidTimeline)39 Timeline (com.google.android.exoplayer2.Timeline)35 PlayerRunnable (com.google.android.exoplayer2.testutil.ActionSchedule.PlayerRunnable)34 TimelineWindowDefinition (com.google.android.exoplayer2.testutil.FakeTimeline.TimelineWindowDefinition)28 TransferListener (com.google.android.exoplayer2.upstream.TransferListener)25