Search in sources :

Example 1 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 adPlayback.

@Test
public void adPlayback() throws Exception {
    long contentDurationsUs = 11 * C.MICROS_PER_SECOND;
    long windowOffsetInFirstPeriodUs = TimelineWindowDefinition.DEFAULT_WINDOW_OFFSET_IN_FIRST_PERIOD_US;
    AtomicReference<AdPlaybackState> adPlaybackState = new AtomicReference<>(FakeTimeline.createAdPlaybackState(/* adsPerAdGroup= */
    1, /* adGroupTimesUs...= */
    windowOffsetInFirstPeriodUs, windowOffsetInFirstPeriodUs + 5 * C.MICROS_PER_SECOND, C.TIME_END_OF_SOURCE));
    AtomicInteger playedAdCount = new AtomicInteger(0);
    Timeline adTimeline = new FakeTimeline(new TimelineWindowDefinition(/* periodCount= */
    1, /* id= */
    0, /* isSeekable= */
    true, /* isDynamic= */
    false, contentDurationsUs, adPlaybackState.get()));
    FakeMediaSource fakeMediaSource = new FakeMediaSource(adTimeline, DrmSessionManager.DRM_UNSUPPORTED, (unusedFormat, mediaPeriodId) -> {
        if (mediaPeriodId.isAd()) {
            return ImmutableList.of(oneByteSample(/* timeUs= */
            0, C.BUFFER_FLAG_KEY_FRAME), END_OF_STREAM_ITEM);
        } else {
            // postroll.
            return ImmutableList.of(oneByteSample(windowOffsetInFirstPeriodUs + C.MICROS_PER_SECOND, C.BUFFER_FLAG_KEY_FRAME), oneByteSample(windowOffsetInFirstPeriodUs + 6 * C.MICROS_PER_SECOND, C.BUFFER_FLAG_KEY_FRAME), oneByteSample(windowOffsetInFirstPeriodUs + contentDurationsUs, C.BUFFER_FLAG_KEY_FRAME), END_OF_STREAM_ITEM);
        }
    }, ExoPlayerTestRunner.VIDEO_FORMAT);
    ActionSchedule actionSchedule = new ActionSchedule.Builder(TAG).executeRunnable(new PlayerRunnable() {

        @Override
        public void run(ExoPlayer player) {
            player.addListener(new Player.Listener() {

                @Override
                public void onPositionDiscontinuity(Player.PositionInfo oldPosition, Player.PositionInfo newPosition, @Player.DiscontinuityReason int reason) {
                    if (!player.isPlayingAd() && reason == Player.DISCONTINUITY_REASON_AUTO_TRANSITION) {
                        // Finished playing ad. Marked as played.
                        adPlaybackState.set(adPlaybackState.get().withPlayedAd(/* adGroupIndex= */
                        playedAdCount.getAndIncrement(), /* adIndexInAdGroup= */
                        0));
                        fakeMediaSource.setNewSourceInfo(new FakeTimeline(new TimelineWindowDefinition(/* periodCount= */
                        1, /* id= */
                        0, /* isSeekable= */
                        true, /* isDynamic= */
                        false, contentDurationsUs, adPlaybackState.get())), /* sendManifestLoadEvents= */
                        false);
                    }
                }
            });
        }
    }).pause().waitForIsLoading(true).waitForIsLoading(false).waitForPlaybackState(Player.STATE_READY).playUntilPosition(/* mediaItemIndex= */
    0, /* positionMs= */
    3_000).waitForPendingPlayerCommands().playUntilPosition(/* mediaItemIndex= */
    0, /* positionMs= */
    8_000).waitForPendingPlayerCommands().play().waitForPlaybackState(Player.STATE_ENDED).waitForTimelineChanged().build();
    TestAnalyticsListener listener = runAnalyticsTest(fakeMediaSource, actionSchedule);
    Object periodUid = listener.lastReportedTimeline.getUidOfPeriod(/* periodIndex= */
    0);
    EventWindowAndPeriodId prerollAd = new EventWindowAndPeriodId(/* windowIndex= */
    0, new MediaPeriodId(periodUid, /* adGroupIndex= */
    0, /* adIndexInAdGroup= */
    0, /* windowSequenceNumber= */
    0));
    EventWindowAndPeriodId midrollAd = new EventWindowAndPeriodId(/* windowIndex= */
    0, new MediaPeriodId(periodUid, /* adGroupIndex= */
    1, /* adIndexInAdGroup= */
    0, /* windowSequenceNumber= */
    0));
    EventWindowAndPeriodId postrollAd = new EventWindowAndPeriodId(/* windowIndex= */
    0, new MediaPeriodId(periodUid, /* adGroupIndex= */
    2, /* adIndexInAdGroup= */
    0, /* windowSequenceNumber= */
    0));
    EventWindowAndPeriodId contentAfterPreroll = new EventWindowAndPeriodId(/* windowIndex= */
    0, new MediaPeriodId(periodUid, /* windowSequenceNumber= */
    0, /* nextAdGroupIndex= */
    1));
    EventWindowAndPeriodId contentAfterMidroll = new EventWindowAndPeriodId(/* windowIndex= */
    0, new MediaPeriodId(periodUid, /* windowSequenceNumber= */
    0, /* nextAdGroupIndex= */
    2));
    EventWindowAndPeriodId contentAfterPostroll = new EventWindowAndPeriodId(/* windowIndex= */
    0, new MediaPeriodId(periodUid, /* windowSequenceNumber= */
    0, /* nextAdGroupIndex= */
    C.INDEX_UNSET));
    assertThat(listener.getEvents(EVENT_PLAYER_STATE_CHANGED)).containsExactly(WINDOW_0, /* setPlayWhenReady=true */
    WINDOW_0, /* setPlayWhenReady=false */
    WINDOW_0, /* BUFFERING */
    prerollAd, /* READY */
    prerollAd, /* setPlayWhenReady=true */
    contentAfterPreroll, /* setPlayWhenReady=false */
    contentAfterPreroll, /* setPlayWhenReady=true */
    contentAfterMidroll, /* setPlayWhenReady=false */
    contentAfterMidroll, /* setPlayWhenReady=true */
    contentAfterPostroll).inOrder();
    assertThat(listener.getEvents(EVENT_TIMELINE_CHANGED)).containsExactly(WINDOW_0, /* PLAYLIST_CHANGED */
    prerollAd, /* SOURCE_UPDATE (initial) */
    contentAfterPreroll, /* SOURCE_UPDATE (played preroll) */
    contentAfterMidroll, /* SOURCE_UPDATE (played midroll) */
    contentAfterPostroll).inOrder();
    assertThat(listener.getEvents(EVENT_POSITION_DISCONTINUITY)).containsExactly(contentAfterPreroll, midrollAd, contentAfterMidroll, postrollAd, contentAfterPostroll).inOrder();
    assertThat(listener.getEvents(EVENT_IS_LOADING_CHANGED)).containsExactly(prerollAd, prerollAd).inOrder();
    assertThat(listener.getEvents(EVENT_TRACKS_CHANGED)).containsExactly(prerollAd, contentAfterPreroll, midrollAd, contentAfterMidroll, postrollAd, contentAfterPostroll).inOrder();
    assertThat(listener.getEvents(EVENT_LOAD_STARTED)).containsExactly(WINDOW_0, /* content manifest */
    prerollAd, contentAfterPreroll, midrollAd, contentAfterMidroll, postrollAd, contentAfterPostroll).inOrder();
    assertThat(listener.getEvents(EVENT_LOAD_COMPLETED)).containsExactly(WINDOW_0, /* content manifest */
    prerollAd, contentAfterPreroll, midrollAd, contentAfterMidroll, postrollAd, contentAfterPostroll).inOrder();
    assertThat(listener.getEvents(EVENT_DOWNSTREAM_FORMAT_CHANGED)).containsExactly(prerollAd, contentAfterPreroll, midrollAd, contentAfterMidroll, postrollAd, contentAfterPostroll).inOrder();
    assertThat(listener.getEvents(EVENT_DECODER_ENABLED)).containsExactly(prerollAd);
    assertThat(listener.getEvents(EVENT_DECODER_INIT)).containsExactly(prerollAd, contentAfterPreroll, midrollAd, contentAfterMidroll, postrollAd, contentAfterPostroll).inOrder();
    assertThat(listener.getEvents(EVENT_DECODER_FORMAT_CHANGED)).containsExactly(prerollAd, contentAfterPreroll, midrollAd, contentAfterMidroll, postrollAd, contentAfterPostroll).inOrder();
    assertThat(listener.getEvents(EVENT_VIDEO_ENABLED)).containsExactly(prerollAd);
    assertThat(listener.getEvents(EVENT_VIDEO_DECODER_INITIALIZED)).containsExactly(prerollAd, contentAfterPreroll, midrollAd, contentAfterMidroll, postrollAd, contentAfterPostroll).inOrder();
    assertThat(listener.getEvents(EVENT_VIDEO_INPUT_FORMAT_CHANGED)).containsExactly(prerollAd, contentAfterPreroll, midrollAd, contentAfterMidroll, postrollAd, contentAfterPostroll).inOrder();
    assertThat(listener.getEvents(EVENT_DROPPED_VIDEO_FRAMES)).containsExactly(contentAfterPreroll, contentAfterMidroll, contentAfterPostroll).inOrder();
    assertThat(listener.getEvents(EVENT_VIDEO_SIZE_CHANGED)).containsExactly(prerollAd, contentAfterPreroll, midrollAd, contentAfterMidroll, postrollAd, contentAfterPostroll).inOrder();
    assertThat(listener.getEvents(EVENT_RENDERED_FIRST_FRAME)).containsExactly(prerollAd, contentAfterPreroll, midrollAd, contentAfterMidroll, postrollAd, contentAfterPostroll).inOrder();
    assertThat(listener.getEvents(EVENT_VIDEO_FRAME_PROCESSING_OFFSET)).containsExactly(contentAfterPreroll, contentAfterMidroll, contentAfterPostroll).inOrder();
    listener.assertNoMoreEvents();
}
Also used : FakeMediaSource(com.google.android.exoplayer2.testutil.FakeMediaSource) ActionSchedule(com.google.android.exoplayer2.testutil.ActionSchedule) PlayerRunnable(com.google.android.exoplayer2.testutil.ActionSchedule.PlayerRunnable) AtomicReference(java.util.concurrent.atomic.AtomicReference) ExoPlayer(com.google.android.exoplayer2.ExoPlayer) Timeline(com.google.android.exoplayer2.Timeline) FakeTimeline(com.google.android.exoplayer2.testutil.FakeTimeline) AdPlaybackState(com.google.android.exoplayer2.source.ads.AdPlaybackState) AtomicInteger(java.util.concurrent.atomic.AtomicInteger) FakeTimeline(com.google.android.exoplayer2.testutil.FakeTimeline) TimelineWindowDefinition(com.google.android.exoplayer2.testutil.FakeTimeline.TimelineWindowDefinition) MediaPeriodId(com.google.android.exoplayer2.source.MediaSource.MediaPeriodId) Test(org.junit.Test)

Example 2 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 prepareNewSource.

@Test
public void prepareNewSource() throws Exception {
    MediaSource mediaSource1 = new FakeMediaSource(SINGLE_PERIOD_TIMELINE, ExoPlayerTestRunner.VIDEO_FORMAT);
    MediaSource mediaSource2 = new FakeMediaSource(SINGLE_PERIOD_TIMELINE, ExoPlayerTestRunner.VIDEO_FORMAT);
    ActionSchedule actionSchedule = new ActionSchedule.Builder(TAG).pause().waitForPlaybackState(Player.STATE_READY).setMediaSources(/* resetPosition= */
    false, mediaSource2).waitForTimelineChanged().waitForIsLoading(true).play().build();
    TestAnalyticsListener listener = runAnalyticsTest(mediaSource1, actionSchedule);
    // Populate all event ids with last timeline (after second prepare).
    populateEventIds(listener.lastReportedTimeline);
    // Populate event id of period 0, sequence 0 with timeline of initial preparation.
    period0Seq0 = new EventWindowAndPeriodId(/* windowIndex= */
    0, new MediaPeriodId(listener.reportedTimelines.get(1).getUidOfPeriod(/* periodIndex= */
    0), /* windowSequenceNumber= */
    0));
    assertThat(listener.getEvents(EVENT_PLAYER_STATE_CHANGED)).containsExactly(WINDOW_0, /* setPlayWhenReady=true */
    WINDOW_0, /* BUFFERING */
    WINDOW_0, /* setPlayWhenReady=false */
    period0Seq0, /* READY */
    WINDOW_0, /* BUFFERING */
    period0Seq1, /* setPlayWhenReady=true */
    period0Seq1, /* READY */
    period0Seq1).inOrder();
    assertThat(listener.getEvents(EVENT_TIMELINE_CHANGED)).containsExactly(WINDOW_0, /* PLAYLIST_CHANGE */
    period0Seq0, /* SOURCE_UPDATE */
    WINDOW_0, /* PLAYLIST_CHANGE */
    period0Seq1);
    assertThat(listener.getEvents(EVENT_POSITION_DISCONTINUITY)).containsExactly(WINDOW_0);
    assertThat(listener.getEvents(EVENT_IS_LOADING_CHANGED)).containsExactly(period0Seq0, period0Seq0, period0Seq1, period0Seq1).inOrder();
    assertThat(listener.getEvents(EVENT_TRACKS_CHANGED)).containsExactly(period0Seq0, /* prepared */
    WINDOW_0, /* setMediaSources */
    period0Seq1).inOrder();
    assertThat(listener.getEvents(EVENT_LOAD_STARTED)).containsExactly(WINDOW_0, /* manifest */
    period0Seq0, /* media */
    WINDOW_0, /* manifest */
    period0Seq1).inOrder();
    assertThat(listener.getEvents(EVENT_LOAD_COMPLETED)).containsExactly(WINDOW_0, /* manifest */
    period0Seq0, /* media */
    WINDOW_0, /* manifest */
    period0Seq1).inOrder();
    assertThat(listener.getEvents(EVENT_DOWNSTREAM_FORMAT_CHANGED)).containsExactly(period0Seq0, period0Seq1).inOrder();
    assertThat(listener.getEvents(EVENT_DECODER_ENABLED)).containsExactly(period0Seq0, period0Seq1).inOrder();
    assertThat(listener.getEvents(EVENT_DECODER_INIT)).containsExactly(period0Seq0, period0Seq1).inOrder();
    assertThat(listener.getEvents(EVENT_DECODER_FORMAT_CHANGED)).containsExactly(period0Seq0, period0Seq1).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, period0Seq1).inOrder();
    assertThat(listener.getEvents(EVENT_VIDEO_INPUT_FORMAT_CHANGED)).containsExactly(period0Seq0, period0Seq1).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, period0Seq1).inOrder();
    assertThat(listener.getEvents(EVENT_RENDERED_FIRST_FRAME)).containsExactly(period0Seq0, period0Seq1).inOrder();
    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) MediaPeriodId(com.google.android.exoplayer2.source.MediaSource.MediaPeriodId) Test(org.junit.Test)

Example 3 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 singlePeriod.

@Test
public void singlePeriod() throws Exception {
    FakeMediaSource mediaSource = new FakeMediaSource(SINGLE_PERIOD_TIMELINE, ExoPlayerTestRunner.VIDEO_FORMAT, ExoPlayerTestRunner.AUDIO_FORMAT);
    TestAnalyticsListener listener = runAnalyticsTest(mediaSource);
    populateEventIds(listener.lastReportedTimeline);
    assertThat(listener.getEvents(EVENT_PLAYER_STATE_CHANGED)).containsExactly(WINDOW_0, /* setPlayWhenReady */
    WINDOW_0, /* BUFFERING */
    period0, /* READY */
    period0).inOrder();
    assertThat(listener.getEvents(EVENT_TIMELINE_CHANGED)).containsExactly(WINDOW_0, /* PLAYLIST_CHANGED */
    period0).inOrder();
    assertThat(listener.getEvents(EVENT_IS_LOADING_CHANGED)).containsExactly(period0, /* started */
    period0).inOrder();
    assertThat(listener.getEvents(EVENT_TRACKS_CHANGED)).containsExactly(period0);
    assertThat(listener.getEvents(EVENT_LOAD_STARTED)).containsExactly(WINDOW_0, /* manifest */
    period0).inOrder();
    assertThat(listener.getEvents(EVENT_LOAD_COMPLETED)).containsExactly(WINDOW_0, /* manifest */
    period0).inOrder();
    assertThat(listener.getEvents(EVENT_DOWNSTREAM_FORMAT_CHANGED)).containsExactly(period0, /* audio */
    period0).inOrder();
    assertThat(listener.getEvents(EVENT_DECODER_ENABLED)).containsExactly(period0, /* audio */
    period0).inOrder();
    assertThat(listener.getEvents(EVENT_DECODER_INIT)).containsExactly(period0, /* audio */
    period0).inOrder();
    assertThat(listener.getEvents(EVENT_DECODER_FORMAT_CHANGED)).containsExactly(period0, /* audio */
    period0).inOrder();
    assertThat(listener.getEvents(EVENT_AUDIO_ENABLED)).containsExactly(period0);
    assertThat(listener.getEvents(EVENT_AUDIO_DECODER_INITIALIZED)).containsExactly(period0);
    assertThat(listener.getEvents(EVENT_AUDIO_INPUT_FORMAT_CHANGED)).containsExactly(period0);
    assertThat(listener.getEvents(EVENT_AUDIO_POSITION_ADVANCING)).containsExactly(period0);
    assertThat(listener.getEvents(EVENT_VIDEO_ENABLED)).containsExactly(period0);
    assertThat(listener.getEvents(EVENT_VIDEO_DECODER_INITIALIZED)).containsExactly(period0);
    assertThat(listener.getEvents(EVENT_VIDEO_INPUT_FORMAT_CHANGED)).containsExactly(period0);
    assertThat(listener.getEvents(EVENT_DROPPED_VIDEO_FRAMES)).containsExactly(period0);
    assertThat(listener.getEvents(EVENT_VIDEO_SIZE_CHANGED)).containsExactly(period0);
    assertThat(listener.getEvents(EVENT_RENDERED_FIRST_FRAME)).containsExactly(period0);
    assertThat(listener.getEvents(EVENT_VIDEO_FRAME_PROCESSING_OFFSET)).containsExactly(period0);
    listener.assertNoMoreEvents();
}
Also used : FakeMediaSource(com.google.android.exoplayer2.testutil.FakeMediaSource) Test(org.junit.Test)

Example 4 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 seekBackAfterReadingAhead.

@Test
public void seekBackAfterReadingAhead() throws Exception {
    MediaSource mediaSource = new ConcatenatingMediaSource(new FakeMediaSource(SINGLE_PERIOD_TIMELINE, ExoPlayerTestRunner.VIDEO_FORMAT), new FakeMediaSource(SINGLE_PERIOD_TIMELINE, ExoPlayerTestRunner.VIDEO_FORMAT, ExoPlayerTestRunner.AUDIO_FORMAT));
    long periodDurationMs = SINGLE_PERIOD_TIMELINE.getWindow(/* windowIndex= */
    0, new Window()).getDurationMs();
    ActionSchedule actionSchedule = new ActionSchedule.Builder(TAG).pause().waitForPlaybackState(Player.STATE_READY).playUntilPosition(/* mediaItemIndex= */
    0, periodDurationMs).seekAndWait(/* positionMs= */
    0).play().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 */
    period0, /* READY */
    period0, /* setPlayWhenReady=true */
    period0, /* setPlayWhenReady=false */
    period0, /* BUFFERING */
    period0, /* READY */
    period0, /* setPlayWhenReady=true */
    period1Seq2).inOrder();
    assertThat(listener.getEvents(EVENT_TIMELINE_CHANGED)).containsExactly(WINDOW_0, /* PLAYLIST_CHANGED */
    period0).inOrder();
    assertThat(listener.getEvents(EVENT_POSITION_DISCONTINUITY)).containsExactly(period0, period1Seq2).inOrder();
    assertThat(listener.getEvents(EVENT_SEEK_STARTED)).containsExactly(period0);
    assertThat(listener.getEvents(EVENT_SEEK_PROCESSED)).containsExactly(period0);
    assertThat(listener.getEvents(EVENT_IS_LOADING_CHANGED)).containsExactly(period0, period0, period0, period0).inOrder();
    assertThat(listener.getEvents(EVENT_TRACKS_CHANGED)).containsExactly(period0, period1Seq2).inOrder();
    assertThat(listener.getEvents(EVENT_LOAD_STARTED)).containsExactly(WINDOW_0, /* manifest */
    WINDOW_1, /* manifest */
    period0, /* media */
    period1Seq1, /* media */
    period1Seq2).inOrder();
    assertThat(listener.getEvents(EVENT_LOAD_COMPLETED)).containsExactly(WINDOW_0, /* manifest */
    WINDOW_1, /* manifest */
    period0, /* media */
    period1Seq1, /* media */
    period1Seq2).inOrder();
    assertThat(listener.getEvents(EVENT_DOWNSTREAM_FORMAT_CHANGED)).containsExactly(period0, period1Seq1, period1Seq1, period1Seq2, period1Seq2).inOrder();
    assertThat(listener.getEvents(EVENT_DECODER_ENABLED)).containsExactly(period0, period1, period0, period1Seq2).inOrder();
    assertThat(listener.getEvents(EVENT_DECODER_INIT)).containsExactly(period0, period1Seq1, period1Seq1, period1Seq2, period1Seq2).inOrder();
    assertThat(listener.getEvents(EVENT_DECODER_FORMAT_CHANGED)).containsExactly(period0, period1Seq1, period1Seq1, period1Seq2, period1Seq2).inOrder();
    assertThat(listener.getEvents(EVENT_DECODER_DISABLED)).containsExactly(period0, period0);
    assertThat(listener.getEvents(EVENT_AUDIO_ENABLED)).containsExactly(period1, period1Seq2).inOrder();
    assertThat(listener.getEvents(EVENT_AUDIO_DECODER_INITIALIZED)).containsExactly(period1Seq1, period1Seq2).inOrder();
    assertThat(listener.getEvents(EVENT_AUDIO_INPUT_FORMAT_CHANGED)).containsExactly(period1Seq1, period1Seq2).inOrder();
    assertThat(listener.getEvents(EVENT_AUDIO_POSITION_ADVANCING)).containsExactly(period1Seq1, period1Seq2).inOrder();
    assertThat(listener.getEvents(EVENT_AUDIO_DISABLED)).containsExactly(period0);
    assertThat(listener.getEvents(EVENT_VIDEO_ENABLED)).containsExactly(period0, period0);
    assertThat(listener.getEvents(EVENT_VIDEO_DECODER_INITIALIZED)).containsExactly(period0, period1Seq1, period1Seq2).inOrder();
    assertThat(listener.getEvents(EVENT_VIDEO_INPUT_FORMAT_CHANGED)).containsExactly(period0, period1Seq1, period1Seq2).inOrder();
    assertThat(listener.getEvents(EVENT_VIDEO_DISABLED)).containsExactly(period0);
    assertThat(listener.getEvents(EVENT_DROPPED_VIDEO_FRAMES)).containsExactly(period0, period1Seq2).inOrder();
    assertThat(listener.getEvents(EVENT_VIDEO_SIZE_CHANGED)).containsExactly(period0, period1Seq1, period0, period1Seq2).inOrder();
    assertThat(listener.getEvents(EVENT_RENDERED_FIRST_FRAME)).containsExactly(period0, period1Seq1, period0, period1Seq2).inOrder();
    assertThat(listener.getEvents(EVENT_VIDEO_FRAME_PROCESSING_OFFSET)).containsExactly(period0, period1Seq2).inOrder();
    listener.assertNoMoreEvents();
}
Also used : Window(com.google.android.exoplayer2.Timeline.Window) 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) ConcatenatingMediaSource(com.google.android.exoplayer2.source.ConcatenatingMediaSource) Test(org.junit.Test)

Example 5 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 automaticPeriodTransition.

@Test
public void automaticPeriodTransition() throws Exception {
    MediaSource mediaSource = new ConcatenatingMediaSource(new FakeMediaSource(SINGLE_PERIOD_TIMELINE, ExoPlayerTestRunner.VIDEO_FORMAT, ExoPlayerTestRunner.AUDIO_FORMAT), new FakeMediaSource(SINGLE_PERIOD_TIMELINE, ExoPlayerTestRunner.VIDEO_FORMAT, ExoPlayerTestRunner.AUDIO_FORMAT));
    TestAnalyticsListener listener = runAnalyticsTest(mediaSource);
    populateEventIds(listener.lastReportedTimeline);
    assertThat(listener.getEvents(EVENT_PLAYER_STATE_CHANGED)).containsExactly(WINDOW_0, /* setPlayWhenReady */
    WINDOW_0, /* BUFFERING */
    period0, /* READY */
    period1).inOrder();
    assertThat(listener.getEvents(EVENT_TIMELINE_CHANGED)).containsExactly(WINDOW_0, /* PLAYLIST_CHANGED */
    period0).inOrder();
    assertThat(listener.getEvents(EVENT_POSITION_DISCONTINUITY)).containsExactly(period1);
    assertThat(listener.getEvents(EVENT_IS_LOADING_CHANGED)).containsExactly(period0, period0).inOrder();
    assertThat(listener.getEvents(EVENT_TRACKS_CHANGED)).containsExactly(period0, period1).inOrder();
    assertThat(listener.getEvents(EVENT_LOAD_STARTED)).containsExactly(WINDOW_0, /* manifest */
    WINDOW_1, /* manifest */
    period0, /* media */
    period1).inOrder();
    assertThat(listener.getEvents(EVENT_LOAD_COMPLETED)).containsExactly(WINDOW_0, /* manifest */
    WINDOW_1, /* manifest */
    period0, /* media */
    period1).inOrder();
    assertThat(listener.getEvents(EVENT_DOWNSTREAM_FORMAT_CHANGED)).containsExactly(period0, /* audio */
    period0, /* video */
    period1, /* audio */
    period1).inOrder();
    assertThat(listener.getEvents(EVENT_DECODER_ENABLED)).containsExactly(period0, /* audio */
    period0).inOrder();
    assertThat(listener.getEvents(EVENT_DECODER_INIT)).containsExactly(period0, /* audio */
    period0, /* video */
    period1, /* audio */
    period1).inOrder();
    assertThat(listener.getEvents(EVENT_DECODER_FORMAT_CHANGED)).containsExactly(period0, /* audio */
    period0, /* video */
    period1, /* audio */
    period1).inOrder();
    assertThat(listener.getEvents(EVENT_AUDIO_ENABLED)).containsExactly(period0);
    assertThat(listener.getEvents(EVENT_AUDIO_DECODER_INITIALIZED)).containsExactly(period0, period1).inOrder();
    assertThat(listener.getEvents(EVENT_AUDIO_INPUT_FORMAT_CHANGED)).containsExactly(period0, period1).inOrder();
    assertThat(listener.getEvents(EVENT_AUDIO_POSITION_ADVANCING)).containsExactly(period0);
    assertThat(listener.getEvents(EVENT_VIDEO_ENABLED)).containsExactly(period0);
    assertThat(listener.getEvents(EVENT_VIDEO_DECODER_INITIALIZED)).containsExactly(period0, period1).inOrder();
    assertThat(listener.getEvents(EVENT_VIDEO_INPUT_FORMAT_CHANGED)).containsExactly(period0, period1).inOrder();
    assertThat(listener.getEvents(EVENT_DROPPED_VIDEO_FRAMES)).containsExactly(period1);
    assertThat(listener.getEvents(EVENT_VIDEO_SIZE_CHANGED)).containsExactly(period0, period1).inOrder();
    assertThat(listener.getEvents(EVENT_RENDERED_FIRST_FRAME)).containsExactly(period0, period1).inOrder();
    assertThat(listener.getEvents(EVENT_VIDEO_FRAME_PROCESSING_OFFSET)).containsExactly(period1);
    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) ConcatenatingMediaSource(com.google.android.exoplayer2.source.ConcatenatingMediaSource) 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