Search in sources :

Example 11 with EVENT_RENDERED_FIRST_FRAME

use of com.google.android.exoplayer2.analytics.AnalyticsListener.EVENT_RENDERED_FIRST_FRAME in project ExoPlayer by google.

the class DefaultAnalyticsCollectorTest method reprepareAfterError.

@Test
public void reprepareAfterError() throws Exception {
    MediaSource mediaSource = new FakeMediaSource(SINGLE_PERIOD_TIMELINE, ExoPlayerTestRunner.VIDEO_FORMAT);
    ActionSchedule actionSchedule = new ActionSchedule.Builder(TAG).pause().waitForPlaybackState(Player.STATE_READY).throwPlaybackException(ExoPlaybackException.createForSource(new IOException(), PlaybackException.ERROR_CODE_IO_UNSPECIFIED)).waitForPlaybackState(Player.STATE_IDLE).seek(/* positionMs= */
    0).prepare().waitForIsLoading(true).play().waitForPlaybackState(Player.STATE_ENDED).build();
    TestAnalyticsListener listener = runAnalyticsTest(mediaSource, actionSchedule);
    populateEventIds(listener.lastReportedTimeline);
    assertThat(listener.getEvents(EVENT_PLAYER_STATE_CHANGED)).containsExactly(WINDOW_0, /* setPlayWhenReady=true */
    WINDOW_0, /* setPlayWhenReady=false */
    WINDOW_0, /* BUFFERING */
    period0Seq0, /* READY */
    period0Seq0, /* IDLE */
    period0Seq0, /* BUFFERING */
    period0Seq0, /* setPlayWhenReady=true */
    period0Seq0, /* READY */
    period0Seq0).inOrder();
    assertThat(listener.getEvents(EVENT_TIMELINE_CHANGED)).containsExactly(WINDOW_0, /* prepared */
    period0Seq0);
    assertThat(listener.getEvents(EVENT_POSITION_DISCONTINUITY)).containsExactly(period0Seq0);
    assertThat(listener.getEvents(EVENT_SEEK_STARTED)).containsExactly(period0Seq0);
    assertThat(listener.getEvents(EVENT_SEEK_PROCESSED)).containsExactly(period0Seq0);
    assertThat(listener.getEvents(EVENT_IS_LOADING_CHANGED)).containsExactly(period0Seq0, period0Seq0, period0Seq0, period0Seq0);
    assertThat(listener.getEvents(EVENT_PLAYER_ERROR)).containsExactly(period0Seq0);
    assertThat(listener.getEvents(EVENT_TRACKS_CHANGED)).containsExactly(period0Seq0, period0Seq0);
    assertThat(listener.getEvents(EVENT_LOAD_STARTED)).containsExactly(WINDOW_0, /* manifest */
    period0Seq0, /* media */
    WINDOW_0, /* manifest */
    period0Seq0).inOrder();
    assertThat(listener.getEvents(EVENT_LOAD_COMPLETED)).containsExactly(WINDOW_0, /* manifest */
    period0Seq0, /* media */
    WINDOW_0, /* manifest */
    period0Seq0).inOrder();
    assertThat(listener.getEvents(EVENT_DOWNSTREAM_FORMAT_CHANGED)).containsExactly(period0Seq0, period0Seq0);
    assertThat(listener.getEvents(EVENT_DECODER_ENABLED)).containsExactly(period0Seq0, period0Seq0);
    assertThat(listener.getEvents(EVENT_DECODER_INIT)).containsExactly(period0Seq0, period0Seq0);
    assertThat(listener.getEvents(EVENT_DECODER_FORMAT_CHANGED)).containsExactly(period0Seq0, period0Seq0);
    assertThat(listener.getEvents(EVENT_DECODER_DISABLED)).containsExactly(period0Seq0);
    assertThat(listener.getEvents(EVENT_VIDEO_ENABLED)).containsExactly(period0Seq0, period0Seq0);
    assertThat(listener.getEvents(EVENT_VIDEO_DECODER_INITIALIZED)).containsExactly(period0Seq0, period0Seq0);
    assertThat(listener.getEvents(EVENT_VIDEO_INPUT_FORMAT_CHANGED)).containsExactly(period0Seq0, period0Seq0);
    assertThat(listener.getEvents(EVENT_VIDEO_DISABLED)).containsExactly(period0Seq0);
    assertThat(listener.getEvents(EVENT_DROPPED_VIDEO_FRAMES)).containsExactly(period0Seq0);
    assertThat(listener.getEvents(EVENT_VIDEO_SIZE_CHANGED)).containsExactly(period0Seq0, period0Seq0);
    assertThat(listener.getEvents(EVENT_RENDERED_FIRST_FRAME)).containsExactly(period0Seq0, period0Seq0);
    assertThat(listener.getEvents(EVENT_VIDEO_FRAME_PROCESSING_OFFSET)).containsExactly(period0Seq0);
    listener.assertNoMoreEvents();
}
Also used : ConcatenatingMediaSource(com.google.android.exoplayer2.source.ConcatenatingMediaSource) MediaSource(com.google.android.exoplayer2.source.MediaSource) FakeMediaSource(com.google.android.exoplayer2.testutil.FakeMediaSource) FakeMediaSource(com.google.android.exoplayer2.testutil.FakeMediaSource) ActionSchedule(com.google.android.exoplayer2.testutil.ActionSchedule) TestExoPlayerBuilder(com.google.android.exoplayer2.testutil.TestExoPlayerBuilder) IOException(java.io.IOException) Test(org.junit.Test)

Example 12 with EVENT_RENDERED_FIRST_FRAME

use of com.google.android.exoplayer2.analytics.AnalyticsListener.EVENT_RENDERED_FIRST_FRAME in project ExoPlayer by google.

the class DefaultAnalyticsCollectorTest method playlistOperations.

@Test
public void playlistOperations() throws Exception {
    MediaSource fakeMediaSource = new FakeMediaSource(SINGLE_PERIOD_TIMELINE, ExoPlayerTestRunner.VIDEO_FORMAT);
    ActionSchedule actionSchedule = new ActionSchedule.Builder(TAG).pause().waitForPlaybackState(Player.STATE_READY).addMediaSources(fakeMediaSource).waitForIsLoading(true).waitForIsLoading(false).removeMediaItem(/* index= */
    0).waitForPlaybackState(Player.STATE_BUFFERING).waitForPlaybackState(Player.STATE_READY).play().build();
    TestAnalyticsListener listener = runAnalyticsTest(fakeMediaSource, actionSchedule);
    // Populate event ids with second to last timeline that still contained both periods.
    populateEventIds(listener.reportedTimelines.get(listener.reportedTimelines.size() - 2));
    // Expect the second period with window index 0 and increased window sequence after the removal
    // moved the period to another window index.
    period0Seq1 = new EventWindowAndPeriodId(/* windowIndex= */
    0, new MediaPeriodId(listener.lastReportedTimeline.getUidOfPeriod(/* periodIndex= */
    0), /* windowSequenceNumber= */
    1));
    assertThat(listener.getEvents(EVENT_PLAYER_STATE_CHANGED)).containsExactly(WINDOW_0, /* setPlayWhenReady=true */
    WINDOW_0, /* setPlayWhenReady=false */
    WINDOW_0, /* BUFFERING */
    period0Seq0, /* READY */
    period0Seq1, /* BUFFERING */
    period0Seq1, /* READY */
    period0Seq1, /* setPlayWhenReady=true */
    period0Seq1).inOrder();
    assertThat(listener.getEvents(EVENT_TIMELINE_CHANGED)).containsExactly(WINDOW_0, /* PLAYLIST_CHANGED */
    period0Seq0, /* SOURCE_UPDATE (first item) */
    period0Seq0, /* PLAYLIST_CHANGED (add) */
    period0Seq0, /* SOURCE_UPDATE (second item) */
    period0Seq1).inOrder();
    assertThat(listener.getEvents(EVENT_POSITION_DISCONTINUITY)).containsExactly(period0Seq1).inOrder();
    assertThat(listener.getEvents(EVENT_IS_LOADING_CHANGED)).containsExactly(period0Seq0, period0Seq0, period0Seq0, period0Seq0);
    assertThat(listener.getEvents(EVENT_TRACKS_CHANGED)).containsExactly(period0Seq0, period0Seq1, period0Seq1).inOrder();
    assertThat(listener.getEvents(EVENT_LOAD_STARTED)).containsExactly(WINDOW_0, /* manifest */
    period0Seq0, /* media */
    period1Seq1).inOrder();
    assertThat(listener.getEvents(EVENT_LOAD_COMPLETED)).containsExactly(WINDOW_0, /* manifest */
    period0Seq0, /* media */
    period1Seq1).inOrder();
    assertThat(listener.getEvents(EVENT_DOWNSTREAM_FORMAT_CHANGED)).containsExactly(period0Seq0, period1Seq1).inOrder();
    assertThat(listener.getEvents(EVENT_DECODER_ENABLED)).containsExactly(period0Seq0, period0Seq1).inOrder();
    assertThat(listener.getEvents(EVENT_DECODER_INIT)).containsExactly(period0Seq0, period1Seq1).inOrder();
    assertThat(listener.getEvents(EVENT_DECODER_FORMAT_CHANGED)).containsExactly(period0Seq0, period1Seq1).inOrder();
    assertThat(listener.getEvents(EVENT_DECODER_DISABLED)).containsExactly(period0Seq0);
    assertThat(listener.getEvents(EVENT_VIDEO_ENABLED)).containsExactly(period0Seq0, period0Seq1).inOrder();
    assertThat(listener.getEvents(EVENT_VIDEO_DECODER_INITIALIZED)).containsExactly(period0Seq0, period1Seq1).inOrder();
    assertThat(listener.getEvents(EVENT_VIDEO_INPUT_FORMAT_CHANGED)).containsExactly(period0Seq0, period1Seq1).inOrder();
    assertThat(listener.getEvents(EVENT_VIDEO_DISABLED)).containsExactly(period0Seq0);
    assertThat(listener.getEvents(EVENT_DROPPED_VIDEO_FRAMES)).containsExactly(period0Seq1);
    assertThat(listener.getEvents(EVENT_VIDEO_SIZE_CHANGED)).containsExactly(period0Seq0, period1Seq1, period0Seq1).inOrder();
    assertThat(listener.getEvents(EVENT_RENDERED_FIRST_FRAME)).containsExactly(period0Seq0, period1Seq1, period0Seq1);
    assertThat(listener.getEvents(EVENT_VIDEO_FRAME_PROCESSING_OFFSET)).containsExactly(period0Seq1);
    listener.assertNoMoreEvents();
}
Also used : ConcatenatingMediaSource(com.google.android.exoplayer2.source.ConcatenatingMediaSource) MediaSource(com.google.android.exoplayer2.source.MediaSource) FakeMediaSource(com.google.android.exoplayer2.testutil.FakeMediaSource) FakeMediaSource(com.google.android.exoplayer2.testutil.FakeMediaSource) ActionSchedule(com.google.android.exoplayer2.testutil.ActionSchedule) TestExoPlayerBuilder(com.google.android.exoplayer2.testutil.TestExoPlayerBuilder) MediaPeriodId(com.google.android.exoplayer2.source.MediaSource.MediaPeriodId) Test(org.junit.Test)

Aggregations

FakeMediaSource (com.google.android.exoplayer2.testutil.FakeMediaSource)12 Test (org.junit.Test)12 ConcatenatingMediaSource (com.google.android.exoplayer2.source.ConcatenatingMediaSource)8 MediaSource (com.google.android.exoplayer2.source.MediaSource)8 ActionSchedule (com.google.android.exoplayer2.testutil.ActionSchedule)8 TestExoPlayerBuilder (com.google.android.exoplayer2.testutil.TestExoPlayerBuilder)7 MediaPeriodId (com.google.android.exoplayer2.source.MediaSource.MediaPeriodId)4 FakeTimeline (com.google.android.exoplayer2.testutil.FakeTimeline)3 ExoPlayer (com.google.android.exoplayer2.ExoPlayer)2 Timeline (com.google.android.exoplayer2.Timeline)2 Window (com.google.android.exoplayer2.Timeline.Window)2 TimelineWindowDefinition (com.google.android.exoplayer2.testutil.FakeTimeline.TimelineWindowDefinition)2 SurfaceTexture (android.graphics.SurfaceTexture)1 SparseArray (android.util.SparseArray)1 Surface (android.view.Surface)1 Format (com.google.android.exoplayer2.Format)1 PlaybackParameters (com.google.android.exoplayer2.PlaybackParameters)1 AdPlaybackState (com.google.android.exoplayer2.source.ads.AdPlaybackState)1 PlayerRunnable (com.google.android.exoplayer2.testutil.ActionSchedule.PlayerRunnable)1 ImmutableList (com.google.common.collect.ImmutableList)1