Search in sources :

Example 1 with FakeMediaClockRenderer

use of com.google.android.exoplayer2.testutil.FakeMediaClockRenderer in project ExoPlayer by google.

the class ExoPlayerTest method testReadAheadToEndDoesNotResetRenderer.

/**
   * Tests that the player does not unnecessarily reset renderers when playing a multi-period
   * source.
   */
public void testReadAheadToEndDoesNotResetRenderer() throws Exception {
    final PlayerWrapper playerWrapper = new PlayerWrapper();
    Timeline timeline = new FakeTimeline(new TimelineWindowDefinition(false, false, 10), new TimelineWindowDefinition(false, false, 10), new TimelineWindowDefinition(false, false, 10));
    MediaSource mediaSource = new FakeMediaSource(timeline, null, TEST_VIDEO_FORMAT, TEST_AUDIO_FORMAT);
    FakeRenderer videoRenderer = new FakeRenderer(TEST_VIDEO_FORMAT);
    FakeMediaClockRenderer audioRenderer = new FakeMediaClockRenderer(TEST_AUDIO_FORMAT) {

        @Override
        public long getPositionUs() {
            // TODO: Avoid hard-coding ExoPlayerImplInternal.RENDERER_TIMESTAMP_OFFSET_US.
            return isCurrentStreamFinal() ? 60000030 : 60000000;
        }

        @Override
        public boolean isEnded() {
            // Allow playback to end once the final period is playing.
            return playerWrapper.positionDiscontinuityCount == 2;
        }
    };
    playerWrapper.setup(mediaSource, videoRenderer, audioRenderer);
    playerWrapper.blockUntilEnded(TIMEOUT_MS);
    assertEquals(2, playerWrapper.positionDiscontinuityCount);
    assertEquals(1, audioRenderer.positionResetCount);
    assertTrue(videoRenderer.isEnded);
    assertTrue(audioRenderer.isEnded);
    assertEquals(timeline, playerWrapper.timeline);
    assertNull(playerWrapper.manifest);
}
Also used : MediaSource(com.google.android.exoplayer2.source.MediaSource)

Example 2 with FakeMediaClockRenderer

use of com.google.android.exoplayer2.testutil.FakeMediaClockRenderer in project ExoPlayer by google.

the class DefaultMediaClockTest method rendererClockSetPlaybackSpeed_shouldNotTriggerCallback.

@Test
public void rendererClockSetPlaybackSpeed_shouldNotTriggerCallback() throws ExoPlaybackException {
    FakeMediaClockRenderer mediaClockRenderer = new MediaClockRenderer(PlaybackParameters.DEFAULT, /* playbackParametersAreMutable= */
    true);
    mediaClock.onRendererEnabled(mediaClockRenderer);
    mediaClock.syncAndGetPositionUs(/* isReadingAhead= */
    false);
    mediaClock.setPlaybackParameters(TEST_PLAYBACK_PARAMETERS);
    verifyNoMoreInteractions(listener);
}
Also used : FakeMediaClockRenderer(com.google.android.exoplayer2.testutil.FakeMediaClockRenderer) FakeMediaClockRenderer(com.google.android.exoplayer2.testutil.FakeMediaClockRenderer) Test(org.junit.Test)

Example 3 with FakeMediaClockRenderer

use of com.google.android.exoplayer2.testutil.FakeMediaClockRenderer in project ExoPlayer by google.

the class DefaultMediaClockTest method enableRendererMediaClockWithFixedPlaybackSpeed_shouldTriggerCallback.

@Test
public void enableRendererMediaClockWithFixedPlaybackSpeed_shouldTriggerCallback() throws ExoPlaybackException {
    FakeMediaClockRenderer mediaClockRenderer = new MediaClockRenderer(TEST_PLAYBACK_PARAMETERS, /* playbackParametersAreMutable= */
    false);
    mediaClock.onRendererEnabled(mediaClockRenderer);
    mediaClock.syncAndGetPositionUs(/* isReadingAhead= */
    false);
    verify(listener).onPlaybackParametersChanged(TEST_PLAYBACK_PARAMETERS);
}
Also used : FakeMediaClockRenderer(com.google.android.exoplayer2.testutil.FakeMediaClockRenderer) FakeMediaClockRenderer(com.google.android.exoplayer2.testutil.FakeMediaClockRenderer) Test(org.junit.Test)

Example 4 with FakeMediaClockRenderer

use of com.google.android.exoplayer2.testutil.FakeMediaClockRenderer in project ExoPlayer by google.

the class DefaultMediaClockTest method enableRendererMediaClockWithFixedPlaybackSpeed_usesRendererPlaybackSpeed.

@Test
public void enableRendererMediaClockWithFixedPlaybackSpeed_usesRendererPlaybackSpeed() throws ExoPlaybackException {
    FakeMediaClockRenderer mediaClockRenderer = new MediaClockRenderer(TEST_PLAYBACK_PARAMETERS, /* playbackParametersAreMutable= */
    false);
    mediaClock.onRendererEnabled(mediaClockRenderer);
    assertThat(mediaClock.getPlaybackParameters()).isEqualTo(TEST_PLAYBACK_PARAMETERS);
}
Also used : FakeMediaClockRenderer(com.google.android.exoplayer2.testutil.FakeMediaClockRenderer) FakeMediaClockRenderer(com.google.android.exoplayer2.testutil.FakeMediaClockRenderer) Test(org.junit.Test)

Example 5 with FakeMediaClockRenderer

use of com.google.android.exoplayer2.testutil.FakeMediaClockRenderer in project ExoPlayer by google.

the class DefaultMediaClockTest method enableRendererMediaClock_shouldOverwriteRendererPlaybackParametersIfPossible.

@Test
public void enableRendererMediaClock_shouldOverwriteRendererPlaybackParametersIfPossible() throws ExoPlaybackException {
    FakeMediaClockRenderer mediaClockRenderer = new MediaClockRenderer(TEST_PLAYBACK_PARAMETERS, /* playbackParametersAreMutable= */
    true);
    mediaClock.onRendererEnabled(mediaClockRenderer);
    assertThat(mediaClock.getPlaybackParameters()).isEqualTo(PlaybackParameters.DEFAULT);
    verifyNoMoreInteractions(listener);
}
Also used : FakeMediaClockRenderer(com.google.android.exoplayer2.testutil.FakeMediaClockRenderer) FakeMediaClockRenderer(com.google.android.exoplayer2.testutil.FakeMediaClockRenderer) Test(org.junit.Test)

Aggregations

FakeMediaClockRenderer (com.google.android.exoplayer2.testutil.FakeMediaClockRenderer)11 Test (org.junit.Test)11 Listener (com.google.android.exoplayer2.Player.Listener)3 FakeMediaSource (com.google.android.exoplayer2.testutil.FakeMediaSource)2 FakeRenderer (com.google.android.exoplayer2.testutil.FakeRenderer)2 FakeTimeline (com.google.android.exoplayer2.testutil.FakeTimeline)2 TimelineWindowDefinition (com.google.android.exoplayer2.testutil.FakeTimeline.TimelineWindowDefinition)2 TestExoPlayerBuilder (com.google.android.exoplayer2.testutil.TestExoPlayerBuilder)2 ArrayList (java.util.ArrayList)2 AnalyticsListener (com.google.android.exoplayer2.analytics.AnalyticsListener)1 DrmSessionEventListener (com.google.android.exoplayer2.drm.DrmSessionEventListener)1 MediaSource (com.google.android.exoplayer2.source.MediaSource)1 MediaSourceEventListener (com.google.android.exoplayer2.source.MediaSourceEventListener)1 SinglePeriodTimeline (com.google.android.exoplayer2.source.SinglePeriodTimeline)1 AdPlaybackState (com.google.android.exoplayer2.source.ads.AdPlaybackState)1 ServerSideAdInsertionUtil.addAdGroupToAdPlaybackState (com.google.android.exoplayer2.source.ads.ServerSideAdInsertionUtil.addAdGroupToAdPlaybackState)1 ActionSchedule (com.google.android.exoplayer2.testutil.ActionSchedule)1 ExoPlayerTestRunner (com.google.android.exoplayer2.testutil.ExoPlayerTestRunner)1 FakeVideoRenderer (com.google.android.exoplayer2.testutil.FakeVideoRenderer)1 NoUidTimeline (com.google.android.exoplayer2.testutil.NoUidTimeline)1