Skip to content

Commit

Permalink
1) Adds new csi ticks:
Browse files Browse the repository at this point in the history
exp (ExoPlayer prepare)
ffr (First Frame Rendered)
psr (Player State Ready).

2) Modifies aci/acc vci/vcc to report timing from ExoPlayer Playback thread.

3) Fix to report pvri and pari for every playback.

and other minor bug fixes.

PiperOrigin-RevId: 360228206
  • Loading branch information
ojw28 committed Mar 2, 2021
1 parent b5d360c commit 3f17f5d
Show file tree
Hide file tree
Showing 5 changed files with 65 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2020,8 +2020,8 @@ public void onVideoSizeChanged(
}

@Override
public void onRenderedFirstFrame(@Nullable Surface surface) {
analyticsCollector.onRenderedFirstFrame(surface);
public void onRenderedFirstFrame(@Nullable Surface surface, long renderTimeMs) {
analyticsCollector.onRenderedFirstFrame(surface, renderTimeMs);
if (SimpleExoPlayer.this.surface == surface) {
for (VideoListener videoListener : videoListeners) {
videoListener.onRenderedFirstFrame();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -231,6 +231,8 @@ public final void onAudioDecoderInitialized(
AnalyticsListener.EVENT_AUDIO_DECODER_INITIALIZED,
listener -> {
listener.onAudioDecoderInitialized(eventTime, decoderName, initializationDurationMs);
listener.onAudioDecoderInitialized(
eventTime, decoderName, initializedTimestampMs, initializationDurationMs);
listener.onDecoderInitialized(
eventTime, C.TRACK_TYPE_AUDIO, decoderName, initializationDurationMs);
});
Expand Down Expand Up @@ -386,6 +388,8 @@ public final void onVideoDecoderInitialized(
AnalyticsListener.EVENT_VIDEO_DECODER_INITIALIZED,
listener -> {
listener.onVideoDecoderInitialized(eventTime, decoderName, initializationDurationMs);
listener.onVideoDecoderInitialized(
eventTime, decoderName, initializedTimestampMs, initializationDurationMs);
listener.onDecoderInitialized(
eventTime, C.TRACK_TYPE_VIDEO, decoderName, initializationDurationMs);
});
Expand Down Expand Up @@ -449,13 +453,17 @@ public final void onVideoSizeChanged(
eventTime, width, height, unappliedRotationDegrees, pixelWidthHeightRatio));
}

@SuppressWarnings("deprecation") // Calling deprecated listener method.
@Override
public final void onRenderedFirstFrame(@Nullable Surface surface) {
public final void onRenderedFirstFrame(@Nullable Surface surface, long renderTimeMs) {
EventTime eventTime = generateReadingMediaPeriodEventTime();
sendEvent(
eventTime,
AnalyticsListener.EVENT_RENDERED_FIRST_FRAME,
listener -> listener.onRenderedFirstFrame(eventTime, surface));
listener -> {
listener.onRenderedFirstFrame(eventTime, surface);
listener.onRenderedFirstFrame(eventTime, surface, renderTimeMs);
});
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
import android.media.MediaCodec;
import android.media.MediaCodec.CodecException;
import android.os.Looper;
import android.os.SystemClock;
import android.util.SparseArray;
import android.view.Surface;
import androidx.annotation.IntDef;
Expand Down Expand Up @@ -753,8 +754,18 @@ default void onAudioEnabled(EventTime eventTime, DecoderCounters counters) {}
*
* @param eventTime The event time.
* @param decoderName The decoder that was created.
* @param initializedTimestampMs {@link SystemClock#elapsedRealtime()} when initialization
* finished.
* @param initializationDurationMs The time taken to initialize the decoder in milliseconds.
*/
default void onAudioDecoderInitialized(
EventTime eventTime,
String decoderName,
long initializedTimestampMs,
long initializationDurationMs) {}

/** @deprecated Use {@link #onAudioDecoderInitialized(EventTime, String, long, long)}. */
@Deprecated
default void onAudioDecoderInitialized(
EventTime eventTime, String decoderName, long initializationDurationMs) {}

Expand Down Expand Up @@ -895,8 +906,18 @@ default void onVideoEnabled(EventTime eventTime, DecoderCounters counters) {}
*
* @param eventTime The event time.
* @param decoderName The decoder that was created.
* @param initializedTimestampMs {@link SystemClock#elapsedRealtime()} when initialization
* finished.
* @param initializationDurationMs The time taken to initialize the decoder in milliseconds.
*/
default void onVideoDecoderInitialized(
EventTime eventTime,
String decoderName,
long initializedTimestampMs,
long initializationDurationMs) {}

/** @deprecated Use {@link #onVideoDecoderInitialized(EventTime, String, long, long)}. */
@Deprecated
default void onVideoDecoderInitialized(
EventTime eventTime, String decoderName, long initializationDurationMs) {}

Expand Down Expand Up @@ -988,7 +1009,13 @@ default void onVideoCodecError(EventTime eventTime, Exception videoCodecError) {
* @param eventTime The event time.
* @param surface The {@link Surface} to which a frame has been rendered, or {@code null} if the
* renderer renders to something that isn't a {@link Surface}.
* @param renderTimeMs {@link SystemClock#elapsedRealtime()} when the first frame was rendered.
*/
default void onRenderedFirstFrame(
EventTime eventTime, @Nullable Surface surface, long renderTimeMs) {}

/** @deprecated Use {@link #onRenderedFirstFrame(EventTime, Surface, long)} instead. */
@Deprecated
default void onRenderedFirstFrame(EventTime eventTime, @Nullable Surface surface) {}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,12 @@ default void onVideoSizeChanged(
*
* @param surface The {@link Surface} to which a first frame has been rendered, or {@code null} if
* the renderer renders to something that isn't a {@link Surface}.
* @param renderTimeMs The {@link SystemClock#elapsedRealtime()} when the frame was rendered.
*/
default void onRenderedFirstFrame(@Nullable Surface surface, long renderTimeMs) {}

/** @deprecated Use {@link #onRenderedFirstFrame(Surface, long)}. */
@Deprecated
default void onRenderedFirstFrame(@Nullable Surface surface) {}

/**
Expand Down Expand Up @@ -246,10 +251,16 @@ public void videoSizeChanged(
}
}

/** Invokes {@link VideoRendererEventListener#onRenderedFirstFrame(Surface)}. */
/** Invokes {@link VideoRendererEventListener#onRenderedFirstFrame(Surface, long)}. */
public void renderedFirstFrame(@Nullable Surface surface) {
if (handler != null) {
handler.post(() -> castNonNull(listener).onRenderedFirstFrame(surface));
// TODO: Replace this timestamp with the actual frame release time.
long renderTimeMs = SystemClock.elapsedRealtime();
handler.post(
() -> {
castNonNull(listener).onRenderedFirstFrame(surface);
castNonNull(listener).onRenderedFirstFrame(surface, renderTimeMs);
});
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1701,12 +1701,12 @@ public void onEvents_isReportedWithCorrectEventTimes() throws Exception {
ArgumentCaptor.forClass(AnalyticsListener.EventTime.class);
verify(listener, atLeastOnce())
.onVideoDecoderInitialized(
individualVideoDecoderInitializedEventTimes.capture(), any(), anyLong());
individualVideoDecoderInitializedEventTimes.capture(), any(), anyLong(), anyLong());
ArgumentCaptor<AnalyticsListener.EventTime> individualAudioDecoderInitializedEventTimes =
ArgumentCaptor.forClass(AnalyticsListener.EventTime.class);
verify(listener, atLeastOnce())
.onAudioDecoderInitialized(
individualAudioDecoderInitializedEventTimes.capture(), any(), anyLong());
individualAudioDecoderInitializedEventTimes.capture(), any(), anyLong(), anyLong());
ArgumentCaptor<AnalyticsListener.EventTime> individualVideoDisabledEventTimes =
ArgumentCaptor.forClass(AnalyticsListener.EventTime.class);
verify(listener, atLeastOnce())
Expand All @@ -1718,7 +1718,7 @@ public void onEvents_isReportedWithCorrectEventTimes() throws Exception {
ArgumentCaptor<AnalyticsListener.EventTime> individualRenderedFirstFrameEventTimes =
ArgumentCaptor.forClass(AnalyticsListener.EventTime.class);
verify(listener, atLeastOnce())
.onRenderedFirstFrame(individualRenderedFirstFrameEventTimes.capture(), any());
.onRenderedFirstFrame(individualRenderedFirstFrameEventTimes.capture(), any(), anyLong());
ArgumentCaptor<AnalyticsListener.EventTime> individualVideoSizeChangedEventTimes =
ArgumentCaptor.forClass(AnalyticsListener.EventTime.class);
verify(listener, atLeastOnce())
Expand Down Expand Up @@ -2184,7 +2184,10 @@ public void onAudioEnabled(EventTime eventTime, DecoderCounters counters) {

@Override
public void onAudioDecoderInitialized(
EventTime eventTime, String decoderName, long initializationDurationMs) {
EventTime eventTime,
String decoderName,
long initializedTimestampMs,
long initializationDurationMs) {
reportedEvents.add(new ReportedEvent(EVENT_AUDIO_DECODER_INITIALIZED, eventTime));
}

Expand Down Expand Up @@ -2221,7 +2224,10 @@ public void onVideoEnabled(EventTime eventTime, DecoderCounters counters) {

@Override
public void onVideoDecoderInitialized(
EventTime eventTime, String decoderName, long initializationDurationMs) {
EventTime eventTime,
String decoderName,
long initializedTimestampMs,
long initializationDurationMs) {
reportedEvents.add(new ReportedEvent(EVENT_VIDEO_DECODER_INITIALIZED, eventTime));
}

Expand All @@ -2247,7 +2253,8 @@ public void onVideoFrameProcessingOffset(
}

@Override
public void onRenderedFirstFrame(EventTime eventTime, @Nullable Surface surface) {
public void onRenderedFirstFrame(
EventTime eventTime, @Nullable Surface surface, long renderTimeMs) {
reportedEvents.add(new ReportedEvent(EVENT_RENDERED_FIRST_FRAME, eventTime));
}

Expand Down

0 comments on commit 3f17f5d

Please sign in to comment.