use of com.google.android.exoplayer2.decoder.DecoderCounters in project ExoPlayer by google.
the class DefaultAnalyticsCollectorTest method release_withCallbacksArrivingAfterRelease_onPlayerReleasedForwardedLast.
@Test
public void release_withCallbacksArrivingAfterRelease_onPlayerReleasedForwardedLast() throws Exception {
FakeClock fakeClock = new FakeClock(/* initialTimeMs= */
0, /* isAutoAdvancing= */
true);
ExoPlayer exoPlayer = new TestExoPlayerBuilder(ApplicationProvider.getApplicationContext()).setClock(fakeClock).build();
AnalyticsListener analyticsListener = spy(new AnalyticsListener() {
@Override
public void onVideoDisabled(EventTime eventTime, DecoderCounters decoderCounters) {
// Add delay in callback to test whether event timestamp and release timestamp are
// in the correct order.
fakeClock.advanceTime(1);
}
});
exoPlayer.addAnalyticsListener(analyticsListener);
// Prepare with media to ensure video renderer is enabled.
exoPlayer.setMediaSource(new FakeMediaSource(new FakeTimeline(), ExoPlayerTestRunner.VIDEO_FORMAT));
exoPlayer.prepare();
TestPlayerRunHelper.runUntilPlaybackState(exoPlayer, Player.STATE_READY);
// Release and add delay on releasing thread to verify timestamps of events.
exoPlayer.release();
long releaseTimeMs = fakeClock.currentTimeMillis();
fakeClock.advanceTime(1);
ShadowLooper.idleMainLooper();
// Verify video disable events and release events arrived in order.
ArgumentCaptor<AnalyticsListener.EventTime> videoDisabledEventTime = ArgumentCaptor.forClass(AnalyticsListener.EventTime.class);
ArgumentCaptor<AnalyticsListener.EventTime> releasedEventTime = ArgumentCaptor.forClass(AnalyticsListener.EventTime.class);
InOrder inOrder = inOrder(analyticsListener);
inOrder.verify(analyticsListener).onVideoDisabled(videoDisabledEventTime.capture(), any());
inOrder.verify(analyticsListener).onEvents(same(exoPlayer), argThat(events -> events.contains(EVENT_VIDEO_DISABLED)));
inOrder.verify(analyticsListener).onPlayerReleased(releasedEventTime.capture());
inOrder.verify(analyticsListener).onEvents(same(exoPlayer), argThat(events -> events.contains(EVENT_PLAYER_RELEASED)));
// Verify order of timestamps of these events.
// This verification is needed as a regression test against [internal ref: b/195396384]. The
// root cause of the regression was an onPlayerReleased timestamp that was less than the
// previously reported timestamps for other events triggered as part of the release.
long videoDisableTimeMs = videoDisabledEventTime.getValue().realtimeMs;
assertThat(videoDisableTimeMs).isGreaterThan(releaseTimeMs);
assertThat(releasedEventTime.getValue().realtimeMs).isGreaterThan(videoDisableTimeMs);
}
use of com.google.android.exoplayer2.decoder.DecoderCounters in project ExoPlayer by google.
the class SimpleDecoderAudioRenderer method onEnabled.
@Override
protected void onEnabled(boolean joining) throws ExoPlaybackException {
decoderCounters = new DecoderCounters();
eventDispatcher.enabled(decoderCounters);
int tunnelingAudioSessionId = getConfiguration().tunnelingAudioSessionId;
if (tunnelingAudioSessionId != C.AUDIO_SESSION_ID_UNSET) {
audioTrack.enableTunnelingV21(tunnelingAudioSessionId);
} else {
audioTrack.disableTunneling();
}
}
use of com.google.android.exoplayer2.decoder.DecoderCounters in project ExoPlayer by google.
the class LibvpxVideoRenderer method onEnabled.
@Override
protected void onEnabled(boolean joining) throws ExoPlaybackException {
decoderCounters = new DecoderCounters();
eventDispatcher.enabled(decoderCounters);
}
use of com.google.android.exoplayer2.decoder.DecoderCounters in project ExoPlayer by google.
the class DefaultAnalyticsCollector method onAudioDisabled.
@Override
// Calling deprecated listener method.
@SuppressWarnings("deprecation")
public final void onAudioDisabled(DecoderCounters counters) {
EventTime eventTime = generatePlayingMediaPeriodEventTime();
sendEvent(eventTime, AnalyticsListener.EVENT_AUDIO_DISABLED, listener -> {
listener.onAudioDisabled(eventTime, counters);
listener.onDecoderDisabled(eventTime, C.TRACK_TYPE_AUDIO, counters);
});
}
use of com.google.android.exoplayer2.decoder.DecoderCounters in project ExoPlayer by google.
the class DebugTextViewHelper method getVideoString.
/**
* Returns a string containing video debugging information.
*/
protected String getVideoString() {
Format format = player.getVideoFormat();
DecoderCounters decoderCounters = player.getVideoDecoderCounters();
if (format == null || decoderCounters == null) {
return "";
}
return "\n" + format.sampleMimeType + "(id:" + format.id + " r:" + format.width + "x" + format.height + getPixelAspectRatioString(format.pixelWidthHeightRatio) + getDecoderCountersBufferCountString(decoderCounters) + " vfpo: " + getVideoFrameProcessingOffsetAverageString(decoderCounters.totalVideoFrameProcessingOffsetUs, decoderCounters.videoFrameProcessingOffsetCount) + ")";
}
Aggregations