Search in sources :

Example 1 with DashMediaSource

use of androidx.media3.exoplayer.dash.DashMediaSource in project media by androidx.

the class DashMediaSource method prepareSourceInternal.

@Override
protected void prepareSourceInternal(@Nullable TransferListener mediaTransferListener) {
    this.mediaTransferListener = mediaTransferListener;
    drmSessionManager.prepare();
    drmSessionManager.setPlayer(/* playbackLooper= */
    Looper.myLooper(), getPlayerId());
    if (sideloadedManifest) {
        processManifest(false);
    } else {
        dataSource = manifestDataSourceFactory.createDataSource();
        loader = new Loader("DashMediaSource");
        handler = Util.createHandlerForCurrentLooper();
        startLoadingManifest();
    }
}
Also used : Loader(androidx.media3.exoplayer.upstream.Loader) SequenceableLoader(androidx.media3.exoplayer.source.SequenceableLoader)

Example 2 with DashMediaSource

use of androidx.media3.exoplayer.dash.DashMediaSource in project media by androidx.

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(androidx.media3.common.MediaItem.LiveConfiguration) MediaItem(androidx.media3.common.MediaItem) Test(org.junit.Test)

Example 3 with DashMediaSource

use of androidx.media3.exoplayer.dash.DashMediaSource in project media by androidx.

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(androidx.media3.common.MediaItem.LiveConfiguration) LiveConfiguration(androidx.media3.common.MediaItem.LiveConfiguration) MediaItem(androidx.media3.common.MediaItem) Test(org.junit.Test)

Example 4 with DashMediaSource

use of androidx.media3.exoplayer.dash.DashMediaSource in project media by androidx.

the class DashMediaSourceTest method replaceManifestUri_doesNotChangeMediaItem.

@Test
public void replaceManifestUri_doesNotChangeMediaItem() {
    DashMediaSource.Factory factory = new DashMediaSource.Factory(new FileDataSource.Factory());
    MediaItem mediaItem = MediaItem.fromUri("http://www.google.com");
    DashMediaSource mediaSource = factory.createMediaSource(mediaItem);
    mediaSource.replaceManifestUri(Uri.EMPTY);
    assertThat(mediaSource.getMediaItem()).isEqualTo(mediaItem);
}
Also used : MediaItem(androidx.media3.common.MediaItem) FileDataSource(androidx.media3.datasource.FileDataSource) Test(org.junit.Test)

Example 5 with DashMediaSource

use of androidx.media3.exoplayer.dash.DashMediaSource in project media by androidx.

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(androidx.media3.common.Timeline.Window) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)14 MediaItem (androidx.media3.common.MediaItem)11 LiveConfiguration (androidx.media3.common.MediaItem.LiveConfiguration)10 Window (androidx.media3.common.Timeline.Window)3 FileDataSource (androidx.media3.datasource.FileDataSource)1 SequenceableLoader (androidx.media3.exoplayer.source.SequenceableLoader)1 Loader (androidx.media3.exoplayer.upstream.Loader)1