Search in sources :

Example 56 with MediaSource

use of com.google.android.exoplayer2.source.MediaSource in project ExoPlayer by google.

the class DashMediaSourceTest method prepare_withCompleteServiceDescription_withMediaItemLiveProperties_usesMediaItem.

@Test
public void prepare_withCompleteServiceDescription_withMediaItemLiveProperties_usesMediaItem() throws InterruptedException {
    MediaItem mediaItem = new MediaItem.Builder().setUri(Uri.EMPTY).setLiveConfiguration(new MediaItem.LiveConfiguration.Builder().setTargetOffsetMs(876L).setMinPlaybackSpeed(23f).setMaxPlaybackSpeed(42f).setMinOffsetMs(100L).setMaxOffsetMs(999L).build()).build();
    DashMediaSource mediaSource = new DashMediaSource.Factory(() -> createSampleMpdDataSource(SAMPLE_MPD_LIVE_WITH_COMPLETE_SERVICE_DESCRIPTION)).setFallbackTargetLiveOffsetMs(1234L).createMediaSource(mediaItem);
    MediaItem.LiveConfiguration liveConfiguration = prepareAndWaitForTimelineRefresh(mediaSource).liveConfiguration;
    assertThat(liveConfiguration.targetOffsetMs).isEqualTo(876L);
    assertThat(liveConfiguration.minOffsetMs).isEqualTo(100L);
    assertThat(liveConfiguration.maxOffsetMs).isEqualTo(999L);
    assertThat(liveConfiguration.minPlaybackSpeed).isEqualTo(23f);
    assertThat(liveConfiguration.maxPlaybackSpeed).isEqualTo(42f);
}
Also used : LiveConfiguration(com.google.android.exoplayer2.MediaItem.LiveConfiguration) MediaItem(com.google.android.exoplayer2.MediaItem) Test(org.junit.Test)

Example 57 with MediaSource

use of com.google.android.exoplayer2.source.MediaSource in project ExoPlayer by google.

the class DashMediaSourceTest method prepare_withoutLiveConfiguration_withOnlyMediaItemTargetOffset_usesUnitSpeed.

@Test
public void prepare_withoutLiveConfiguration_withOnlyMediaItemTargetOffset_usesUnitSpeed() throws InterruptedException {
    DashMediaSource mediaSource = new DashMediaSource.Factory(() -> createSampleMpdDataSource(SAMPLE_MPD_LIVE_WITHOUT_LIVE_CONFIGURATION)).createMediaSource(new MediaItem.Builder().setUri(Uri.EMPTY).setLiveConfiguration(new LiveConfiguration.Builder().setTargetOffsetMs(10_000L).build()).build());
    MediaItem.LiveConfiguration liveConfiguration = prepareAndWaitForTimelineRefresh(mediaSource).liveConfiguration;
    assertThat(liveConfiguration.targetOffsetMs).isEqualTo(10_000L);
    assertThat(liveConfiguration.minOffsetMs).isEqualTo(0L);
    assertThat(liveConfiguration.maxOffsetMs).isEqualTo(58_000L);
    assertThat(liveConfiguration.minPlaybackSpeed).isEqualTo(1f);
    assertThat(liveConfiguration.maxPlaybackSpeed).isEqualTo(1f);
}
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 58 with MediaSource

use of com.google.android.exoplayer2.source.MediaSource in project ExoPlayer by google.

the class DashMediaSourceTest method prepare_withoutLiveConfiguration_withoutMediaItemTargetOffset_usesDefinedFallbackTargetOffset.

@Test
public void prepare_withoutLiveConfiguration_withoutMediaItemTargetOffset_usesDefinedFallbackTargetOffset() throws InterruptedException {
    DashMediaSource mediaSource = new DashMediaSource.Factory(() -> createSampleMpdDataSource(SAMPLE_MPD_LIVE_WITHOUT_LIVE_CONFIGURATION)).setFallbackTargetLiveOffsetMs(1234L).createMediaSource(new MediaItem.Builder().setUri(Uri.EMPTY).setLiveConfiguration(new LiveConfiguration.Builder().setMinPlaybackSpeed(0.95f).build()).build());
    MediaItem.LiveConfiguration liveConfiguration = prepareAndWaitForTimelineRefresh(mediaSource).liveConfiguration;
    assertThat(liveConfiguration.targetOffsetMs).isEqualTo(1234L);
    assertThat(liveConfiguration.minOffsetMs).isEqualTo(0L);
    assertThat(liveConfiguration.maxOffsetMs).isEqualTo(58_000L);
    assertThat(liveConfiguration.minPlaybackSpeed).isEqualTo(0.95f);
    assertThat(liveConfiguration.maxPlaybackSpeed).isEqualTo(C.RATE_UNSET);
}
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 59 with MediaSource

use of com.google.android.exoplayer2.source.MediaSource in project ExoPlayer by google.

the class DashMediaSourceTest method prepareAndWaitForTimelineRefresh.

private static Window prepareAndWaitForTimelineRefresh(MediaSource mediaSource) throws InterruptedException {
    AtomicReference<Window> windowReference = new AtomicReference<>();
    CountDownLatch countDownLatch = new CountDownLatch(/* count= */
    1);
    MediaSourceCaller caller = (MediaSource source, Timeline timeline) -> {
        if (windowReference.get() == null) {
            windowReference.set(timeline.getWindow(0, new Timeline.Window()));
            countDownLatch.countDown();
        }
    };
    mediaSource.prepareSource(caller, /* mediaTransferListener= */
    null, PlayerId.UNSET);
    while (!countDownLatch.await(/* timeout= */
    10, MILLISECONDS)) {
        ShadowLooper.idleMainLooper();
    }
    return windowReference.get();
}
Also used : Window(com.google.android.exoplayer2.Timeline.Window) MediaSourceCaller(com.google.android.exoplayer2.source.MediaSource.MediaSourceCaller) Timeline(com.google.android.exoplayer2.Timeline) Window(com.google.android.exoplayer2.Timeline.Window) MediaSource(com.google.android.exoplayer2.source.MediaSource) AtomicReference(java.util.concurrent.atomic.AtomicReference) CountDownLatch(java.util.concurrent.CountDownLatch)

Example 60 with MediaSource

use of com.google.android.exoplayer2.source.MediaSource in project ExoPlayer by google.

the class DashMediaSourceTest method prepare_withoutLiveConfiguration_withMediaItemLiveProperties_usesMediaItem.

@Test
public void prepare_withoutLiveConfiguration_withMediaItemLiveProperties_usesMediaItem() throws InterruptedException {
    MediaItem mediaItem = new MediaItem.Builder().setUri(Uri.EMPTY).setLiveConfiguration(new MediaItem.LiveConfiguration.Builder().setTargetOffsetMs(876L).setMinPlaybackSpeed(23f).setMaxPlaybackSpeed(42f).setMinOffsetMs(500L).setMaxOffsetMs(20_000L).build()).build();
    DashMediaSource mediaSource = new DashMediaSource.Factory(() -> createSampleMpdDataSource(SAMPLE_MPD_LIVE_WITHOUT_LIVE_CONFIGURATION)).setFallbackTargetLiveOffsetMs(1234L).createMediaSource(mediaItem);
    MediaItem.LiveConfiguration liveConfiguration = prepareAndWaitForTimelineRefresh(mediaSource).liveConfiguration;
    assertThat(liveConfiguration).isEqualTo(mediaItem.liveConfiguration);
}
Also used : LiveConfiguration(com.google.android.exoplayer2.MediaItem.LiveConfiguration) 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