Commit a6640ae3 by olly Committed by Oliver Woodman

Stop merging methods through AnalyticsCollector/AnalyticsListener

PiperOrigin-RevId: 321595514
parent 3b26c218
...@@ -2224,10 +2224,9 @@ public class SimpleExoPlayer extends BasePlayer ...@@ -2224,10 +2224,9 @@ public class SimpleExoPlayer extends BasePlayer
} }
@Override @Override
public void onAudioSinkUnderrun( public void onAudioUnderrun(int bufferSize, long bufferSizeMs, long elapsedSinceLastFeedMs) {
int bufferSize, long bufferSizeMs, long elapsedSinceLastFeedMs) {
for (AudioRendererEventListener audioDebugListener : audioDebugListeners) { for (AudioRendererEventListener audioDebugListener : audioDebugListeners) {
audioDebugListener.onAudioSinkUnderrun(bufferSize, bufferSizeMs, elapsedSinceLastFeedMs); audioDebugListener.onAudioUnderrun(bufferSize, bufferSizeMs, elapsedSinceLastFeedMs);
} }
} }
......
...@@ -172,34 +172,40 @@ public class AnalyticsCollector ...@@ -172,34 +172,40 @@ public class AnalyticsCollector
// AudioRendererEventListener implementation. // AudioRendererEventListener implementation.
@SuppressWarnings("deprecation")
@Override @Override
public final void onAudioEnabled(DecoderCounters counters) { public final void onAudioEnabled(DecoderCounters counters) {
EventTime eventTime = generateReadingMediaPeriodEventTime(); EventTime eventTime = generateReadingMediaPeriodEventTime();
for (AnalyticsListener listener : listeners) { for (AnalyticsListener listener : listeners) {
listener.onAudioEnabled(eventTime, counters);
listener.onDecoderEnabled(eventTime, C.TRACK_TYPE_AUDIO, counters); listener.onDecoderEnabled(eventTime, C.TRACK_TYPE_AUDIO, counters);
} }
} }
@SuppressWarnings("deprecation")
@Override @Override
public final void onAudioDecoderInitialized( public final void onAudioDecoderInitialized(
String decoderName, long initializedTimestampMs, long initializationDurationMs) { String decoderName, long initializedTimestampMs, long initializationDurationMs) {
EventTime eventTime = generateReadingMediaPeriodEventTime(); EventTime eventTime = generateReadingMediaPeriodEventTime();
for (AnalyticsListener listener : listeners) { for (AnalyticsListener listener : listeners) {
listener.onAudioDecoderInitialized(eventTime, decoderName, initializationDurationMs);
listener.onDecoderInitialized( listener.onDecoderInitialized(
eventTime, C.TRACK_TYPE_AUDIO, decoderName, initializationDurationMs); eventTime, C.TRACK_TYPE_AUDIO, decoderName, initializationDurationMs);
} }
} }
@SuppressWarnings("deprecation")
@Override @Override
public final void onAudioInputFormatChanged(Format format) { public final void onAudioInputFormatChanged(Format format) {
EventTime eventTime = generateReadingMediaPeriodEventTime(); EventTime eventTime = generateReadingMediaPeriodEventTime();
for (AnalyticsListener listener : listeners) { for (AnalyticsListener listener : listeners) {
listener.onAudioInputFormatChanged(eventTime, format);
listener.onDecoderInputFormatChanged(eventTime, C.TRACK_TYPE_AUDIO, format); listener.onDecoderInputFormatChanged(eventTime, C.TRACK_TYPE_AUDIO, format);
} }
} }
@Override @Override
public final void onAudioSinkUnderrun( public final void onAudioUnderrun(
int bufferSize, long bufferSizeMs, long elapsedSinceLastFeedMs) { int bufferSize, long bufferSizeMs, long elapsedSinceLastFeedMs) {
EventTime eventTime = generateReadingMediaPeriodEventTime(); EventTime eventTime = generateReadingMediaPeriodEventTime();
for (AnalyticsListener listener : listeners) { for (AnalyticsListener listener : listeners) {
...@@ -207,10 +213,12 @@ public class AnalyticsCollector ...@@ -207,10 +213,12 @@ public class AnalyticsCollector
} }
} }
@SuppressWarnings("deprecation")
@Override @Override
public final void onAudioDisabled(DecoderCounters counters) { public final void onAudioDisabled(DecoderCounters counters) {
EventTime eventTime = generatePlayingMediaPeriodEventTime(); EventTime eventTime = generatePlayingMediaPeriodEventTime();
for (AnalyticsListener listener : listeners) { for (AnalyticsListener listener : listeners) {
listener.onAudioDisabled(eventTime, counters);
listener.onDecoderDisabled(eventTime, C.TRACK_TYPE_AUDIO, counters); listener.onDecoderDisabled(eventTime, C.TRACK_TYPE_AUDIO, counters);
} }
} }
...@@ -251,28 +259,34 @@ public class AnalyticsCollector ...@@ -251,28 +259,34 @@ public class AnalyticsCollector
// VideoRendererEventListener implementation. // VideoRendererEventListener implementation.
@SuppressWarnings("deprecation")
@Override @Override
public final void onVideoEnabled(DecoderCounters counters) { public final void onVideoEnabled(DecoderCounters counters) {
EventTime eventTime = generateReadingMediaPeriodEventTime(); EventTime eventTime = generateReadingMediaPeriodEventTime();
for (AnalyticsListener listener : listeners) { for (AnalyticsListener listener : listeners) {
listener.onVideoEnabled(eventTime, counters);
listener.onDecoderEnabled(eventTime, C.TRACK_TYPE_VIDEO, counters); listener.onDecoderEnabled(eventTime, C.TRACK_TYPE_VIDEO, counters);
} }
} }
@SuppressWarnings("deprecation")
@Override @Override
public final void onVideoDecoderInitialized( public final void onVideoDecoderInitialized(
String decoderName, long initializedTimestampMs, long initializationDurationMs) { String decoderName, long initializedTimestampMs, long initializationDurationMs) {
EventTime eventTime = generateReadingMediaPeriodEventTime(); EventTime eventTime = generateReadingMediaPeriodEventTime();
for (AnalyticsListener listener : listeners) { for (AnalyticsListener listener : listeners) {
listener.onVideoDecoderInitialized(eventTime, decoderName, initializationDurationMs);
listener.onDecoderInitialized( listener.onDecoderInitialized(
eventTime, C.TRACK_TYPE_VIDEO, decoderName, initializationDurationMs); eventTime, C.TRACK_TYPE_VIDEO, decoderName, initializationDurationMs);
} }
} }
@SuppressWarnings("deprecation")
@Override @Override
public final void onVideoInputFormatChanged(Format format) { public final void onVideoInputFormatChanged(Format format) {
EventTime eventTime = generateReadingMediaPeriodEventTime(); EventTime eventTime = generateReadingMediaPeriodEventTime();
for (AnalyticsListener listener : listeners) { for (AnalyticsListener listener : listeners) {
listener.onVideoInputFormatChanged(eventTime, format);
listener.onDecoderInputFormatChanged(eventTime, C.TRACK_TYPE_VIDEO, format); listener.onDecoderInputFormatChanged(eventTime, C.TRACK_TYPE_VIDEO, format);
} }
} }
...@@ -285,10 +299,12 @@ public class AnalyticsCollector ...@@ -285,10 +299,12 @@ public class AnalyticsCollector
} }
} }
@SuppressWarnings("deprecation")
@Override @Override
public final void onVideoDisabled(DecoderCounters counters) { public final void onVideoDisabled(DecoderCounters counters) {
EventTime eventTime = generatePlayingMediaPeriodEventTime(); EventTime eventTime = generatePlayingMediaPeriodEventTime();
for (AnalyticsListener listener : listeners) { for (AnalyticsListener listener : listeners) {
listener.onVideoDisabled(eventTime, counters);
listener.onDecoderDisabled(eventTime, C.TRACK_TYPE_VIDEO, counters); listener.onDecoderDisabled(eventTime, C.TRACK_TYPE_VIDEO, counters);
} }
} }
......
...@@ -28,7 +28,6 @@ import com.google.android.exoplayer2.Player.PlaybackSuppressionReason; ...@@ -28,7 +28,6 @@ import com.google.android.exoplayer2.Player.PlaybackSuppressionReason;
import com.google.android.exoplayer2.Player.TimelineChangeReason; import com.google.android.exoplayer2.Player.TimelineChangeReason;
import com.google.android.exoplayer2.Timeline; import com.google.android.exoplayer2.Timeline;
import com.google.android.exoplayer2.audio.AudioAttributes; import com.google.android.exoplayer2.audio.AudioAttributes;
import com.google.android.exoplayer2.audio.AudioSink;
import com.google.android.exoplayer2.decoder.DecoderCounters; import com.google.android.exoplayer2.decoder.DecoderCounters;
import com.google.android.exoplayer2.metadata.Metadata; import com.google.android.exoplayer2.metadata.Metadata;
import com.google.android.exoplayer2.source.LoadEventInfo; import com.google.android.exoplayer2.source.LoadEventInfo;
...@@ -273,9 +272,8 @@ public interface AnalyticsListener { ...@@ -273,9 +272,8 @@ public interface AnalyticsListener {
default void onSeekStarted(EventTime eventTime) {} default void onSeekStarted(EventTime eventTime) {}
/** /**
* @deprecated Seeks are processed without delay. Listen to {@link * @deprecated Seeks are processed without delay. Use {@link #onPositionDiscontinuity(EventTime,
* #onPositionDiscontinuity(EventTime, int)} with reason {@link * int)} with reason {@link Player#DISCONTINUITY_REASON_SEEK} instead.
* Player#DISCONTINUITY_REASON_SEEK} instead.
*/ */
@Deprecated @Deprecated
default void onSeekProcessed(EventTime eventTime) {} default void onSeekProcessed(EventTime eventTime) {}
...@@ -443,67 +441,84 @@ public interface AnalyticsListener { ...@@ -443,67 +441,84 @@ public interface AnalyticsListener {
EventTime eventTime, int totalLoadTimeMs, long totalBytesLoaded, long bitrateEstimate) {} EventTime eventTime, int totalLoadTimeMs, long totalBytesLoaded, long bitrateEstimate) {}
/** /**
* Called when the output surface size changed. * Called when there is {@link Metadata} associated with the current playback time.
* *
* @param eventTime The event time. * @param eventTime The event time.
* @param width The surface width in pixels. May be {@link C#LENGTH_UNSET} if unknown, or 0 if the * @param metadata The metadata.
* video is not rendered onto a surface.
* @param height The surface height in pixels. May be {@link C#LENGTH_UNSET} if unknown, or 0 if
* the video is not rendered onto a surface.
*/ */
default void onSurfaceSizeChanged(EventTime eventTime, int width, int height) {} default void onMetadata(EventTime eventTime, Metadata metadata) {}
/** @deprecated Use {@link #onAudioEnabled} and {@link #onVideoEnabled} instead. */
@Deprecated
default void onDecoderEnabled(
EventTime eventTime, int trackType, DecoderCounters decoderCounters) {}
/** /**
* Called when there is {@link Metadata} associated with the current playback time. * @deprecated Use {@link #onAudioDecoderInitialized} and {@link #onVideoDecoderInitialized}
* instead.
*/
@Deprecated
default void onDecoderInitialized(
EventTime eventTime, int trackType, String decoderName, long initializationDurationMs) {}
/**
* @deprecated Use {@link #onAudioInputFormatChanged} and {@link #onVideoInputFormatChanged}
* instead.
*/
@Deprecated
default void onDecoderInputFormatChanged(EventTime eventTime, int trackType, Format format) {}
/** @deprecated Use {@link #onAudioDisabled} and {@link #onVideoDisabled} instead. */
@Deprecated
default void onDecoderDisabled(
EventTime eventTime, int trackType, DecoderCounters decoderCounters) {}
/**
* Called when an audio renderer is enabled.
* *
* @param eventTime The event time. * @param eventTime The event time.
* @param metadata The metadata. * @param counters {@link DecoderCounters} that will be updated by the renderer for as long as it
* remains enabled.
*/ */
default void onMetadata(EventTime eventTime, Metadata metadata) {} default void onAudioEnabled(EventTime eventTime, DecoderCounters counters) {}
/** /**
* Called when an audio or video decoder has been enabled. * Called when an audio renderer creates a decoder.
* *
* @param eventTime The event time. * @param eventTime The event time.
* @param trackType The track type of the enabled decoder. Either {@link C#TRACK_TYPE_AUDIO} or * @param decoderName The decoder that was created.
* {@link C#TRACK_TYPE_VIDEO}. * @param initializationDurationMs The time taken to initialize the decoder in milliseconds.
* @param decoderCounters The accumulated event counters associated with this decoder.
*/ */
default void onDecoderEnabled( default void onAudioDecoderInitialized(
EventTime eventTime, int trackType, DecoderCounters decoderCounters) {} EventTime eventTime, String decoderName, long initializationDurationMs) {}
/** /**
* Called when an audio or video decoder has been initialized. * Called when the format of the media being consumed by an audio renderer changes.
* *
* @param eventTime The event time. * @param eventTime The event time.
* @param trackType The track type of the initialized decoder. Either {@link C#TRACK_TYPE_AUDIO} * @param format The new format.
* or {@link C#TRACK_TYPE_VIDEO}.
* @param decoderName The decoder that was created.
* @param initializationDurationMs Time taken to initialize the decoder, in milliseconds.
*/ */
default void onDecoderInitialized( default void onAudioInputFormatChanged(EventTime eventTime, Format format) {}
EventTime eventTime, int trackType, String decoderName, long initializationDurationMs) {}
/** /**
* Called when an audio or video decoder input format changed. * Called when an audio underrun occurs.
* *
* @param eventTime The event time. * @param eventTime The event time.
* @param trackType The track type of the decoder whose format changed. Either {@link * @param bufferSize The size of the audio output buffer, in bytes.
* C#TRACK_TYPE_AUDIO} or {@link C#TRACK_TYPE_VIDEO}. * @param bufferSizeMs The size of the audio output buffer, in milliseconds, if it contains PCM
* @param format The new input format for the decoder. * encoded audio. {@link C#TIME_UNSET} if the output buffer contains non-PCM encoded audio.
* @param elapsedSinceLastFeedMs The time since audio was last written to the output buffer.
*/ */
default void onDecoderInputFormatChanged(EventTime eventTime, int trackType, Format format) {} default void onAudioUnderrun(
EventTime eventTime, int bufferSize, long bufferSizeMs, long elapsedSinceLastFeedMs) {}
/** /**
* Called when an audio or video decoder has been disabled. * Called when an audio renderer is disabled.
* *
* @param eventTime The event time. * @param eventTime The event time.
* @param trackType The track type of the disabled decoder. Either {@link C#TRACK_TYPE_AUDIO} or * @param counters {@link DecoderCounters} that were updated by the renderer.
* {@link C#TRACK_TYPE_VIDEO}.
* @param decoderCounters The accumulated event counters associated with this decoder.
*/ */
default void onDecoderDisabled( default void onAudioDisabled(EventTime eventTime, DecoderCounters counters) {}
EventTime eventTime, int trackType, DecoderCounters decoderCounters) {}
/** /**
* Called when the audio session id is set. * Called when the audio session id is set.
...@@ -522,6 +537,14 @@ public interface AnalyticsListener { ...@@ -522,6 +537,14 @@ public interface AnalyticsListener {
default void onAudioAttributesChanged(EventTime eventTime, AudioAttributes audioAttributes) {} default void onAudioAttributesChanged(EventTime eventTime, AudioAttributes audioAttributes) {}
/** /**
* Called when skipping silences is enabled or disabled in the audio stream.
*
* @param eventTime The event time.
* @param skipSilenceEnabled Whether skipping silences in the audio stream is enabled.
*/
default void onSkipSilenceEnabledChanged(EventTime eventTime, boolean skipSilenceEnabled) {}
/**
* Called when the volume changes. * Called when the volume changes.
* *
* @param eventTime The event time. * @param eventTime The event time.
...@@ -530,25 +553,31 @@ public interface AnalyticsListener { ...@@ -530,25 +553,31 @@ public interface AnalyticsListener {
default void onVolumeChanged(EventTime eventTime, float volume) {} default void onVolumeChanged(EventTime eventTime, float volume) {}
/** /**
* Called when an audio underrun occurred. * Called when a video renderer is enabled.
* *
* @param eventTime The event time. * @param eventTime The event time.
* @param bufferSize The size of the {@link AudioSink}'s buffer, in bytes. * @param counters {@link DecoderCounters} that will be updated by the renderer for as long as it
* @param bufferSizeMs The size of the {@link AudioSink}'s buffer, in milliseconds, if it is * remains enabled.
* configured for PCM output. {@link C#TIME_UNSET} if it is configured for passthrough output,
* as the buffered media can have a variable bitrate so the duration may be unknown.
* @param elapsedSinceLastFeedMs The time since the {@link AudioSink} was last fed data.
*/ */
default void onAudioUnderrun( default void onVideoEnabled(EventTime eventTime, DecoderCounters counters) {}
EventTime eventTime, int bufferSize, long bufferSizeMs, long elapsedSinceLastFeedMs) {}
/** /**
* Called when skipping silences is enabled or disabled in the audio stream. * Called when a video renderer creates a decoder.
* *
* @param eventTime The event time. * @param eventTime The event time.
* @param skipSilenceEnabled Whether skipping silences in the audio stream is enabled. * @param decoderName The decoder that was created.
* @param initializationDurationMs The time taken to initialize the decoder in milliseconds.
*/ */
default void onSkipSilenceEnabledChanged(EventTime eventTime, boolean skipSilenceEnabled) {} default void onVideoDecoderInitialized(
EventTime eventTime, String decoderName, long initializationDurationMs) {}
/**
* Called when the format of the media being consumed by a video renderer changes.
*
* @param eventTime The event time.
* @param format The new format.
*/
default void onVideoInputFormatChanged(EventTime eventTime, Format format) {}
/** /**
* Called after video frames have been dropped. * Called after video frames have been dropped.
...@@ -562,6 +591,14 @@ public interface AnalyticsListener { ...@@ -562,6 +591,14 @@ public interface AnalyticsListener {
default void onDroppedVideoFrames(EventTime eventTime, int droppedFrames, long elapsedMs) {} default void onDroppedVideoFrames(EventTime eventTime, int droppedFrames, long elapsedMs) {}
/** /**
* Called when a video renderer is disabled.
*
* @param eventTime The event time.
* @param counters {@link DecoderCounters} that were updated by the renderer.
*/
default void onVideoDisabled(EventTime eventTime, DecoderCounters counters) {}
/**
* Called when there is an update to the video frame processing offset reported by a video * Called when there is an update to the video frame processing offset reported by a video
* renderer. * renderer.
* *
...@@ -581,6 +618,16 @@ public interface AnalyticsListener { ...@@ -581,6 +618,16 @@ public interface AnalyticsListener {
EventTime eventTime, long totalProcessingOffsetUs, int frameCount, Format format) {} EventTime eventTime, long totalProcessingOffsetUs, int frameCount, Format format) {}
/** /**
* Called when a frame is rendered for the first time since setting the surface, or since the
* renderer was reset, or since the stream being rendered was changed.
*
* @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}.
*/
default void onRenderedFirstFrame(EventTime eventTime, @Nullable Surface surface) {}
/**
* Called before a frame is rendered for the first time since setting the surface, and each time * Called before a frame is rendered for the first time since setting the surface, and each time
* there's a change in the size or pixel aspect ratio of the video being rendered. * there's a change in the size or pixel aspect ratio of the video being rendered.
* *
...@@ -601,14 +648,15 @@ public interface AnalyticsListener { ...@@ -601,14 +648,15 @@ public interface AnalyticsListener {
float pixelWidthHeightRatio) {} float pixelWidthHeightRatio) {}
/** /**
* Called when a frame is rendered for the first time since setting the surface, and when a frame * Called when the output surface size changed.
* is rendered for the first time since the renderer was reset.
* *
* @param eventTime The event time. * @param eventTime The event time.
* @param surface The {@link Surface} to which a first frame has been rendered, or {@code null} if * @param width The surface width in pixels. May be {@link C#LENGTH_UNSET} if unknown, or 0 if the
* the renderer renders to something that isn't a {@link Surface}. * video is not rendered onto a surface.
* @param height The surface height in pixels. May be {@link C#LENGTH_UNSET} if unknown, or 0 if
* the video is not rendered onto a surface.
*/ */
default void onRenderedFirstFrame(EventTime eventTime, @Nullable Surface surface) {} default void onSurfaceSizeChanged(EventTime eventTime, int width, int height) {}
/** /**
* Called each time a drm session is acquired. * Called each time a drm session is acquired.
......
...@@ -66,16 +66,14 @@ public interface AudioRendererEventListener { ...@@ -66,16 +66,14 @@ public interface AudioRendererEventListener {
default void onAudioInputFormatChanged(Format format) {} default void onAudioInputFormatChanged(Format format) {}
/** /**
* Called when an {@link AudioSink} underrun occurs. * Called when an audio underrun occurs.
* *
* @param bufferSize The size of the {@link AudioSink}'s buffer, in bytes. * @param bufferSize The size of the audio output buffer, in bytes.
* @param bufferSizeMs The size of the {@link AudioSink}'s buffer, in milliseconds, if it is * @param bufferSizeMs The size of the audio output buffer, in milliseconds, if it contains PCM
* configured for PCM output. {@link C#TIME_UNSET} if it is configured for passthrough output, * encoded audio. {@link C#TIME_UNSET} if the output buffer contains non-PCM encoded audio.
* as the buffered media can have a variable bitrate so the duration may be unknown. * @param elapsedSinceLastFeedMs The time since audio was last written to the output buffer.
* @param elapsedSinceLastFeedMs The time since the {@link AudioSink} was last fed data.
*/ */
default void onAudioSinkUnderrun( default void onAudioUnderrun(int bufferSize, long bufferSizeMs, long elapsedSinceLastFeedMs) {}
int bufferSize, long bufferSizeMs, long elapsedSinceLastFeedMs) {}
/** /**
* Called when the renderer is disabled. * Called when the renderer is disabled.
...@@ -140,14 +138,14 @@ public interface AudioRendererEventListener { ...@@ -140,14 +138,14 @@ public interface AudioRendererEventListener {
} }
} }
/** Invokes {@link AudioRendererEventListener#onAudioSinkUnderrun(int, long, long)}. */ /** Invokes {@link AudioRendererEventListener#onAudioUnderrun(int, long, long)}. */
public void underrun( public void underrun(
final int bufferSize, final long bufferSizeMs, final long elapsedSinceLastFeedMs) { final int bufferSize, final long bufferSizeMs, final long elapsedSinceLastFeedMs) {
if (handler != null) { if (handler != null) {
handler.post( handler.post(
() -> () ->
castNonNull(listener) castNonNull(listener)
.onAudioSinkUnderrun(bufferSize, bufferSizeMs, elapsedSinceLastFeedMs)); .onAudioUnderrun(bufferSize, bufferSizeMs, elapsedSinceLastFeedMs));
} }
} }
......
...@@ -301,8 +301,34 @@ public class EventLogger implements AnalyticsListener { ...@@ -301,8 +301,34 @@ public class EventLogger implements AnalyticsListener {
} }
@Override @Override
public void onDecoderEnabled(EventTime eventTime, int trackType, DecoderCounters counters) { public void onAudioEnabled(EventTime eventTime, DecoderCounters counters) {
logd(eventTime, "decoderEnabled", Util.getTrackTypeString(trackType)); logd(eventTime, "audioEnabled");
}
@Override
public void onAudioDecoderInitialized(
EventTime eventTime, String decoderName, long initializationDurationMs) {
logd(eventTime, "audioDecoderInitialized", decoderName);
}
@Override
public void onAudioInputFormatChanged(EventTime eventTime, Format format) {
logd(eventTime, "audioInputFormat", Format.toLogString(format));
}
@Override
public void onAudioUnderrun(
EventTime eventTime, int bufferSize, long bufferSizeMs, long elapsedSinceLastFeedMs) {
loge(
eventTime,
"audioTrackUnderrun",
bufferSize + ", " + bufferSizeMs + ", " + elapsedSinceLastFeedMs + "]",
/* throwable= */ null);
}
@Override
public void onAudioDisabled(EventTime eventTime, DecoderCounters counters) {
logd(eventTime, "audioDisabled");
} }
@Override @Override
...@@ -335,37 +361,34 @@ public class EventLogger implements AnalyticsListener { ...@@ -335,37 +361,34 @@ public class EventLogger implements AnalyticsListener {
} }
@Override @Override
public void onDecoderInitialized( public void onVideoEnabled(EventTime eventTime, DecoderCounters counters) {
EventTime eventTime, int trackType, String decoderName, long initializationDurationMs) { logd(eventTime, "videoEnabled");
logd(eventTime, "decoderInitialized", Util.getTrackTypeString(trackType) + ", " + decoderName);
} }
@Override @Override
public void onDecoderInputFormatChanged(EventTime eventTime, int trackType, Format format) { public void onVideoDecoderInitialized(
logd( EventTime eventTime, String decoderName, long initializationDurationMs) {
eventTime, logd(eventTime, "videoDecoderInitialized", decoderName);
"decoderInputFormat",
Util.getTrackTypeString(trackType) + ", " + Format.toLogString(format));
} }
@Override @Override
public void onDecoderDisabled(EventTime eventTime, int trackType, DecoderCounters counters) { public void onVideoInputFormatChanged(EventTime eventTime, Format format) {
logd(eventTime, "decoderDisabled", Util.getTrackTypeString(trackType)); logd(eventTime, "videoInputFormat", Format.toLogString(format));
} }
@Override @Override
public void onAudioUnderrun( public void onDroppedVideoFrames(EventTime eventTime, int count, long elapsedMs) {
EventTime eventTime, int bufferSize, long bufferSizeMs, long elapsedSinceLastFeedMs) { logd(eventTime, "droppedFrames", Integer.toString(count));
loge(
eventTime,
"audioTrackUnderrun",
bufferSize + ", " + bufferSizeMs + ", " + elapsedSinceLastFeedMs + "]",
null);
} }
@Override @Override
public void onDroppedVideoFrames(EventTime eventTime, int count, long elapsedMs) { public void onVideoDisabled(EventTime eventTime, DecoderCounters counters) {
logd(eventTime, "droppedFrames", Integer.toString(count)); logd(eventTime, "videoDisabled");
}
@Override
public void onRenderedFirstFrame(EventTime eventTime, @Nullable Surface surface) {
logd(eventTime, "renderedFirstFrame", String.valueOf(surface));
} }
@Override @Override
...@@ -379,11 +402,6 @@ public class EventLogger implements AnalyticsListener { ...@@ -379,11 +402,6 @@ public class EventLogger implements AnalyticsListener {
} }
@Override @Override
public void onRenderedFirstFrame(EventTime eventTime, @Nullable Surface surface) {
logd(eventTime, "renderedFirstFrame", String.valueOf(surface));
}
@Override
public void onMediaPeriodCreated(EventTime eventTime) { public void onMediaPeriodCreated(EventTime eventTime) {
logd(eventTime, "mediaPeriodCreated"); logd(eventTime, "mediaPeriodCreated");
} }
......
...@@ -51,8 +51,8 @@ public interface VideoListener { ...@@ -51,8 +51,8 @@ public interface VideoListener {
default void onSurfaceSizeChanged(int width, int height) {} default void onSurfaceSizeChanged(int width, int height) {}
/** /**
* Called when a frame is rendered for the first time since setting the surface, and when a frame * Called when a frame is rendered for the first time since setting the surface, or since the
* is rendered for the first time since the renderer was reset. * renderer was reset, or since the stream being rendered was changed.
*/ */
default void onRenderedFirstFrame() {} default void onRenderedFirstFrame() {}
} }
...@@ -114,8 +114,8 @@ public interface VideoRendererEventListener { ...@@ -114,8 +114,8 @@ public interface VideoRendererEventListener {
int width, int height, int unappliedRotationDegrees, float pixelWidthHeightRatio) {} int width, int height, int unappliedRotationDegrees, float pixelWidthHeightRatio) {}
/** /**
* Called when a frame is rendered for the first time since setting the surface, and when a frame * Called when a frame is rendered for the first time since setting the surface, or since the
* is rendered for the first time since the renderer was reset. * renderer was reset, or since the stream being rendered was changed.
* *
* @param surface The {@link Surface} to which a first frame has been rendered, or {@code null} if * @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}. * the renderer renders to something that isn't a {@link Surface}.
......
...@@ -107,18 +107,26 @@ public final class AnalyticsCollectorTest { ...@@ -107,18 +107,26 @@ public final class AnalyticsCollectorTest {
private static final int EVENT_DECODER_INIT = 25; private static final int EVENT_DECODER_INIT = 25;
private static final int EVENT_DECODER_FORMAT_CHANGED = 26; private static final int EVENT_DECODER_FORMAT_CHANGED = 26;
private static final int EVENT_DECODER_DISABLED = 27; private static final int EVENT_DECODER_DISABLED = 27;
private static final int EVENT_AUDIO_SESSION_ID = 28; private static final int EVENT_AUDIO_ENABLED = 28;
private static final int EVENT_AUDIO_UNDERRUN = 29; private static final int EVENT_AUDIO_DECODER_INIT = 29;
private static final int EVENT_DROPPED_VIDEO_FRAMES = 30; private static final int EVENT_AUDIO_INPUT_FORMAT_CHANGED = 30;
private static final int EVENT_VIDEO_SIZE_CHANGED = 31; private static final int EVENT_AUDIO_DISABLED = 31;
private static final int EVENT_RENDERED_FIRST_FRAME = 32; private static final int EVENT_AUDIO_SESSION_ID = 32;
private static final int EVENT_DRM_KEYS_LOADED = 33; private static final int EVENT_AUDIO_UNDERRUN = 33;
private static final int EVENT_DRM_ERROR = 34; private static final int EVENT_VIDEO_ENABLED = 34;
private static final int EVENT_DRM_KEYS_RESTORED = 35; private static final int EVENT_VIDEO_DECODER_INIT = 35;
private static final int EVENT_DRM_KEYS_REMOVED = 36; private static final int EVENT_VIDEO_INPUT_FORMAT_CHANGED = 36;
private static final int EVENT_DRM_SESSION_ACQUIRED = 37; private static final int EVENT_DROPPED_FRAMES = 37;
private static final int EVENT_DRM_SESSION_RELEASED = 38; private static final int EVENT_VIDEO_DISABLED = 38;
private static final int EVENT_VIDEO_FRAME_PROCESSING_OFFSET = 39; private static final int EVENT_RENDERED_FIRST_FRAME = 39;
private static final int EVENT_VIDEO_FRAME_PROCESSING_OFFSET = 40;
private static final int EVENT_VIDEO_SIZE_CHANGED = 41;
private static final int EVENT_DRM_KEYS_LOADED = 42;
private static final int EVENT_DRM_ERROR = 43;
private static final int EVENT_DRM_KEYS_RESTORED = 44;
private static final int EVENT_DRM_KEYS_REMOVED = 45;
private static final int EVENT_DRM_SESSION_ACQUIRED = 46;
private static final int EVENT_DRM_SESSION_RELEASED = 47;
private static final UUID DRM_SCHEME_UUID = private static final UUID DRM_SCHEME_UUID =
UUID.nameUUIDFromBytes(TestUtil.createByteArray(7, 8, 9)); UUID.nameUUIDFromBytes(TestUtil.createByteArray(7, 8, 9));
...@@ -222,8 +230,14 @@ public final class AnalyticsCollectorTest { ...@@ -222,8 +230,14 @@ public final class AnalyticsCollectorTest {
assertThat(listener.getEvents(EVENT_DECODER_FORMAT_CHANGED)) assertThat(listener.getEvents(EVENT_DECODER_FORMAT_CHANGED))
.containsExactly(period0 /* audio */, period0 /* video */) .containsExactly(period0 /* audio */, period0 /* video */)
.inOrder(); .inOrder();
assertThat(listener.getEvents(EVENT_AUDIO_ENABLED)).containsExactly(period0);
assertThat(listener.getEvents(EVENT_AUDIO_DECODER_INIT)).containsExactly(period0);
assertThat(listener.getEvents(EVENT_AUDIO_INPUT_FORMAT_CHANGED)).containsExactly(period0);
assertThat(listener.getEvents(EVENT_AUDIO_SESSION_ID)).containsExactly(period0); assertThat(listener.getEvents(EVENT_AUDIO_SESSION_ID)).containsExactly(period0);
assertThat(listener.getEvents(EVENT_DROPPED_VIDEO_FRAMES)).containsExactly(period0); assertThat(listener.getEvents(EVENT_VIDEO_ENABLED)).containsExactly(period0);
assertThat(listener.getEvents(EVENT_VIDEO_DECODER_INIT)).containsExactly(period0);
assertThat(listener.getEvents(EVENT_VIDEO_INPUT_FORMAT_CHANGED)).containsExactly(period0);
assertThat(listener.getEvents(EVENT_DROPPED_FRAMES)).containsExactly(period0);
assertThat(listener.getEvents(EVENT_VIDEO_SIZE_CHANGED)).containsExactly(period0); assertThat(listener.getEvents(EVENT_VIDEO_SIZE_CHANGED)).containsExactly(period0);
assertThat(listener.getEvents(EVENT_RENDERED_FIRST_FRAME)).containsExactly(period0); assertThat(listener.getEvents(EVENT_RENDERED_FIRST_FRAME)).containsExactly(period0);
assertThat(listener.getEvents(EVENT_VIDEO_FRAME_PROCESSING_OFFSET)).containsExactly(period0); assertThat(listener.getEvents(EVENT_VIDEO_FRAME_PROCESSING_OFFSET)).containsExactly(period0);
...@@ -298,8 +312,22 @@ public final class AnalyticsCollectorTest { ...@@ -298,8 +312,22 @@ public final class AnalyticsCollectorTest {
.containsExactly( .containsExactly(
period0 /* audio */, period0 /* video */, period1 /* audio */, period1 /* video */) period0 /* audio */, period0 /* video */, period1 /* audio */, period1 /* video */)
.inOrder(); .inOrder();
assertThat(listener.getEvents(EVENT_AUDIO_ENABLED)).containsExactly(period0);
assertThat(listener.getEvents(EVENT_AUDIO_DECODER_INIT))
.containsExactly(period0, period1)
.inOrder();
assertThat(listener.getEvents(EVENT_AUDIO_INPUT_FORMAT_CHANGED))
.containsExactly(period0, period1)
.inOrder();
assertThat(listener.getEvents(EVENT_AUDIO_SESSION_ID)).containsExactly(period0); assertThat(listener.getEvents(EVENT_AUDIO_SESSION_ID)).containsExactly(period0);
assertThat(listener.getEvents(EVENT_DROPPED_VIDEO_FRAMES)).containsExactly(period1); assertThat(listener.getEvents(EVENT_VIDEO_ENABLED)).containsExactly(period0);
assertThat(listener.getEvents(EVENT_VIDEO_DECODER_INIT))
.containsExactly(period0, period1)
.inOrder();
assertThat(listener.getEvents(EVENT_VIDEO_INPUT_FORMAT_CHANGED))
.containsExactly(period0, period1)
.inOrder();
assertThat(listener.getEvents(EVENT_DROPPED_FRAMES)).containsExactly(period1);
assertThat(listener.getEvents(EVENT_VIDEO_SIZE_CHANGED)) assertThat(listener.getEvents(EVENT_VIDEO_SIZE_CHANGED))
.containsExactly(period0, period1) .containsExactly(period0, period1)
.inOrder(); .inOrder();
...@@ -369,9 +397,16 @@ public final class AnalyticsCollectorTest { ...@@ -369,9 +397,16 @@ public final class AnalyticsCollectorTest {
assertThat(listener.getEvents(EVENT_DECODER_FORMAT_CHANGED)) assertThat(listener.getEvents(EVENT_DECODER_FORMAT_CHANGED))
.containsExactly(period0 /* video */, period1 /* audio */) .containsExactly(period0 /* video */, period1 /* audio */)
.inOrder(); .inOrder();
assertThat(listener.getEvents(EVENT_DECODER_DISABLED)).containsExactly(period0); assertThat(listener.getEvents(EVENT_DECODER_DISABLED)).containsExactly(period0 /* video */);
assertThat(listener.getEvents(EVENT_AUDIO_ENABLED)).containsExactly(period1);
assertThat(listener.getEvents(EVENT_AUDIO_DECODER_INIT)).containsExactly(period1);
assertThat(listener.getEvents(EVENT_AUDIO_INPUT_FORMAT_CHANGED)).containsExactly(period1);
assertThat(listener.getEvents(EVENT_AUDIO_SESSION_ID)).containsExactly(period1); assertThat(listener.getEvents(EVENT_AUDIO_SESSION_ID)).containsExactly(period1);
assertThat(listener.getEvents(EVENT_DROPPED_VIDEO_FRAMES)).containsExactly(period0); assertThat(listener.getEvents(EVENT_VIDEO_ENABLED)).containsExactly(period0);
assertThat(listener.getEvents(EVENT_VIDEO_DECODER_INIT)).containsExactly(period0);
assertThat(listener.getEvents(EVENT_VIDEO_INPUT_FORMAT_CHANGED)).containsExactly(period0);
assertThat(listener.getEvents(EVENT_VIDEO_DISABLED)).containsExactly(period0);
assertThat(listener.getEvents(EVENT_DROPPED_FRAMES)).containsExactly(period0);
assertThat(listener.getEvents(EVENT_VIDEO_SIZE_CHANGED)).containsExactly(period0); assertThat(listener.getEvents(EVENT_VIDEO_SIZE_CHANGED)).containsExactly(period0);
assertThat(listener.getEvents(EVENT_RENDERED_FIRST_FRAME)).containsExactly(period0); assertThat(listener.getEvents(EVENT_RENDERED_FIRST_FRAME)).containsExactly(period0);
assertThat(listener.getEvents(EVENT_VIDEO_FRAME_PROCESSING_OFFSET)).containsExactly(period0); assertThat(listener.getEvents(EVENT_VIDEO_FRAME_PROCESSING_OFFSET)).containsExactly(period0);
...@@ -460,9 +495,21 @@ public final class AnalyticsCollectorTest { ...@@ -460,9 +495,21 @@ public final class AnalyticsCollectorTest {
assertThat(listener.getEvents(EVENT_DECODER_DISABLED)) assertThat(listener.getEvents(EVENT_DECODER_DISABLED))
.containsExactly(period0 /* video */, period0 /* audio */) .containsExactly(period0 /* video */, period0 /* audio */)
.inOrder(); .inOrder();
assertThat(listener.getEvents(EVENT_AUDIO_ENABLED)).containsExactly(period0, period1).inOrder();
assertThat(listener.getEvents(EVENT_AUDIO_DECODER_INIT))
.containsExactly(period0, period1)
.inOrder();
assertThat(listener.getEvents(EVENT_AUDIO_INPUT_FORMAT_CHANGED))
.containsExactly(period0, period1)
.inOrder();
assertThat(listener.getEvents(EVENT_AUDIO_SESSION_ID)) assertThat(listener.getEvents(EVENT_AUDIO_SESSION_ID))
.containsExactly(period0, period1) .containsExactly(period0, period1)
.inOrder(); .inOrder();
assertThat(listener.getEvents(EVENT_AUDIO_DISABLED)).containsExactly(period0);
assertThat(listener.getEvents(EVENT_VIDEO_ENABLED)).containsExactly(period0);
assertThat(listener.getEvents(EVENT_VIDEO_DECODER_INIT)).containsExactly(period0);
assertThat(listener.getEvents(EVENT_VIDEO_INPUT_FORMAT_CHANGED)).containsExactly(period0);
assertThat(listener.getEvents(EVENT_VIDEO_DISABLED)).containsExactly(period0);
assertThat(listener.getEvents(EVENT_VIDEO_SIZE_CHANGED)).containsExactly(period0); assertThat(listener.getEvents(EVENT_VIDEO_SIZE_CHANGED)).containsExactly(period0);
assertThat(listener.getEvents(EVENT_RENDERED_FIRST_FRAME)).containsExactly(period0); assertThat(listener.getEvents(EVENT_RENDERED_FIRST_FRAME)).containsExactly(period0);
listener.assertNoMoreEvents(); listener.assertNoMoreEvents();
...@@ -555,10 +602,28 @@ public final class AnalyticsCollectorTest { ...@@ -555,10 +602,28 @@ public final class AnalyticsCollectorTest {
.containsExactly(period0, period1Seq1, period1Seq1, period1Seq2, period1Seq2) .containsExactly(period0, period1Seq1, period1Seq1, period1Seq2, period1Seq2)
.inOrder(); .inOrder();
assertThat(listener.getEvents(EVENT_DECODER_DISABLED)).containsExactly(period0, period0); 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_INIT))
.containsExactly(period1Seq1, period1Seq2)
.inOrder();
assertThat(listener.getEvents(EVENT_AUDIO_INPUT_FORMAT_CHANGED))
.containsExactly(period1Seq1, period1Seq2)
.inOrder();
assertThat(listener.getEvents(EVENT_AUDIO_SESSION_ID)) assertThat(listener.getEvents(EVENT_AUDIO_SESSION_ID))
.containsExactly(period1Seq1, period1Seq2) .containsExactly(period1Seq1, period1Seq2)
.inOrder(); .inOrder();
assertThat(listener.getEvents(EVENT_DROPPED_VIDEO_FRAMES)) assertThat(listener.getEvents(EVENT_AUDIO_DISABLED)).containsExactly(period0);
assertThat(listener.getEvents(EVENT_VIDEO_ENABLED)).containsExactly(period0, period0);
assertThat(listener.getEvents(EVENT_VIDEO_DECODER_INIT))
.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_FRAMES))
.containsExactly(period0, period1Seq2) .containsExactly(period0, period1Seq2)
.inOrder(); .inOrder();
assertThat(listener.getEvents(EVENT_VIDEO_SIZE_CHANGED)) assertThat(listener.getEvents(EVENT_VIDEO_SIZE_CHANGED))
...@@ -658,7 +723,17 @@ public final class AnalyticsCollectorTest { ...@@ -658,7 +723,17 @@ public final class AnalyticsCollectorTest {
.containsExactly(period0Seq0, period0Seq1) .containsExactly(period0Seq0, period0Seq1)
.inOrder(); .inOrder();
assertThat(listener.getEvents(EVENT_DECODER_DISABLED)).containsExactly(period0Seq0); assertThat(listener.getEvents(EVENT_DECODER_DISABLED)).containsExactly(period0Seq0);
assertThat(listener.getEvents(EVENT_DROPPED_VIDEO_FRAMES)).containsExactly(period0Seq1); assertThat(listener.getEvents(EVENT_VIDEO_ENABLED))
.containsExactly(period0Seq0, period0Seq1)
.inOrder();
assertThat(listener.getEvents(EVENT_VIDEO_DECODER_INIT))
.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_FRAMES)).containsExactly(period0Seq1);
assertThat(listener.getEvents(EVENT_VIDEO_SIZE_CHANGED)) assertThat(listener.getEvents(EVENT_VIDEO_SIZE_CHANGED))
.containsExactly(period0Seq0, period0Seq1) .containsExactly(period0Seq0, period0Seq1)
.inOrder(); .inOrder();
...@@ -736,7 +811,13 @@ public final class AnalyticsCollectorTest { ...@@ -736,7 +811,13 @@ public final class AnalyticsCollectorTest {
assertThat(listener.getEvents(EVENT_DECODER_FORMAT_CHANGED)) assertThat(listener.getEvents(EVENT_DECODER_FORMAT_CHANGED))
.containsExactly(period0Seq0, period0Seq0); .containsExactly(period0Seq0, period0Seq0);
assertThat(listener.getEvents(EVENT_DECODER_DISABLED)).containsExactly(period0Seq0); assertThat(listener.getEvents(EVENT_DECODER_DISABLED)).containsExactly(period0Seq0);
assertThat(listener.getEvents(EVENT_DROPPED_VIDEO_FRAMES)).containsExactly(period0Seq0); assertThat(listener.getEvents(EVENT_VIDEO_ENABLED)).containsExactly(period0Seq0, period0Seq0);
assertThat(listener.getEvents(EVENT_VIDEO_DECODER_INIT))
.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_FRAMES)).containsExactly(period0Seq0);
assertThat(listener.getEvents(EVENT_VIDEO_SIZE_CHANGED)) assertThat(listener.getEvents(EVENT_VIDEO_SIZE_CHANGED))
.containsExactly(period0Seq0, period0Seq0); .containsExactly(period0Seq0, period0Seq0);
assertThat(listener.getEvents(EVENT_RENDERED_FIRST_FRAME)) assertThat(listener.getEvents(EVENT_RENDERED_FIRST_FRAME))
...@@ -822,7 +903,17 @@ public final class AnalyticsCollectorTest { ...@@ -822,7 +903,17 @@ public final class AnalyticsCollectorTest {
.containsExactly(window0Period1Seq0, window1Period0Seq1) .containsExactly(window0Period1Seq0, window1Period0Seq1)
.inOrder(); .inOrder();
assertThat(listener.getEvents(EVENT_DECODER_DISABLED)).containsExactly(window0Period1Seq0); assertThat(listener.getEvents(EVENT_DECODER_DISABLED)).containsExactly(window0Period1Seq0);
assertThat(listener.getEvents(EVENT_DROPPED_VIDEO_FRAMES)) assertThat(listener.getEvents(EVENT_VIDEO_ENABLED))
.containsExactly(window0Period1Seq0, window0Period1Seq0)
.inOrder();
assertThat(listener.getEvents(EVENT_VIDEO_DECODER_INIT))
.containsExactly(window0Period1Seq0, window1Period0Seq1)
.inOrder();
assertThat(listener.getEvents(EVENT_VIDEO_INPUT_FORMAT_CHANGED))
.containsExactly(window0Period1Seq0, window1Period0Seq1)
.inOrder();
assertThat(listener.getEvents(EVENT_VIDEO_DISABLED)).containsExactly(window0Period1Seq0);
assertThat(listener.getEvents(EVENT_DROPPED_FRAMES))
.containsExactly(window0Period1Seq0, period1Seq0) .containsExactly(window0Period1Seq0, period1Seq0)
.inOrder(); .inOrder();
assertThat(listener.getEvents(EVENT_VIDEO_SIZE_CHANGED)) assertThat(listener.getEvents(EVENT_VIDEO_SIZE_CHANGED))
...@@ -917,7 +1008,17 @@ public final class AnalyticsCollectorTest { ...@@ -917,7 +1008,17 @@ public final class AnalyticsCollectorTest {
.inOrder(); .inOrder();
assertThat(listener.getEvents(EVENT_DECODER_DISABLED)) assertThat(listener.getEvents(EVENT_DECODER_DISABLED))
.containsExactly(period0Seq0, period0Seq0); .containsExactly(period0Seq0, period0Seq0);
assertThat(listener.getEvents(EVENT_DROPPED_VIDEO_FRAMES)).containsExactly(period0Seq1); assertThat(listener.getEvents(EVENT_VIDEO_ENABLED))
.containsExactly(period0Seq0, period0Seq1, period0Seq1)
.inOrder();
assertThat(listener.getEvents(EVENT_VIDEO_DECODER_INIT))
.containsExactly(period0Seq0, period0Seq1)
.inOrder();
assertThat(listener.getEvents(EVENT_VIDEO_INPUT_FORMAT_CHANGED))
.containsExactly(period0Seq0, period0Seq1)
.inOrder();
assertThat(listener.getEvents(EVENT_VIDEO_DISABLED)).containsExactly(period0Seq0, period0Seq0);
assertThat(listener.getEvents(EVENT_DROPPED_FRAMES)).containsExactly(period0Seq1);
assertThat(listener.getEvents(EVENT_VIDEO_SIZE_CHANGED)) assertThat(listener.getEvents(EVENT_VIDEO_SIZE_CHANGED))
.containsExactly(period0Seq0, period0Seq1) .containsExactly(period0Seq0, period0Seq1)
.inOrder(); .inOrder();
...@@ -1177,7 +1278,26 @@ public final class AnalyticsCollectorTest { ...@@ -1177,7 +1278,26 @@ public final class AnalyticsCollectorTest {
postrollAd, postrollAd,
contentAfterPostroll) contentAfterPostroll)
.inOrder(); .inOrder();
assertThat(listener.getEvents(EVENT_DROPPED_VIDEO_FRAMES)) assertThat(listener.getEvents(EVENT_VIDEO_ENABLED)).containsExactly(prerollAd);
assertThat(listener.getEvents(EVENT_VIDEO_DECODER_INIT))
.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_FRAMES))
.containsExactly(contentAfterPreroll, contentAfterMidroll, contentAfterPostroll) .containsExactly(contentAfterPreroll, contentAfterMidroll, contentAfterPostroll)
.inOrder(); .inOrder();
assertThat(listener.getEvents(EVENT_VIDEO_SIZE_CHANGED)) assertThat(listener.getEvents(EVENT_VIDEO_SIZE_CHANGED))
...@@ -1344,7 +1464,17 @@ public final class AnalyticsCollectorTest { ...@@ -1344,7 +1464,17 @@ public final class AnalyticsCollectorTest {
.containsExactly(contentBeforeMidroll, midrollAd, contentAfterMidroll) .containsExactly(contentBeforeMidroll, midrollAd, contentAfterMidroll)
.inOrder(); .inOrder();
assertThat(listener.getEvents(EVENT_DECODER_DISABLED)).containsExactly(contentBeforeMidroll); assertThat(listener.getEvents(EVENT_DECODER_DISABLED)).containsExactly(contentBeforeMidroll);
assertThat(listener.getEvents(EVENT_DROPPED_VIDEO_FRAMES)).containsExactly(contentAfterMidroll); assertThat(listener.getEvents(EVENT_VIDEO_ENABLED))
.containsExactly(contentBeforeMidroll, midrollAd)
.inOrder();
assertThat(listener.getEvents(EVENT_VIDEO_DECODER_INIT))
.containsExactly(contentBeforeMidroll, midrollAd, contentAfterMidroll)
.inOrder();
assertThat(listener.getEvents(EVENT_VIDEO_INPUT_FORMAT_CHANGED))
.containsExactly(contentBeforeMidroll, midrollAd, contentAfterMidroll)
.inOrder();
assertThat(listener.getEvents(EVENT_VIDEO_DISABLED)).containsExactly(contentBeforeMidroll);
assertThat(listener.getEvents(EVENT_DROPPED_FRAMES)).containsExactly(contentAfterMidroll);
assertThat(listener.getEvents(EVENT_VIDEO_SIZE_CHANGED)) assertThat(listener.getEvents(EVENT_VIDEO_SIZE_CHANGED))
.containsExactly(contentBeforeMidroll, midrollAd, contentAfterMidroll) .containsExactly(contentBeforeMidroll, midrollAd, contentAfterMidroll)
.inOrder(); .inOrder();
...@@ -1847,23 +1977,27 @@ public final class AnalyticsCollectorTest { ...@@ -1847,23 +1977,27 @@ public final class AnalyticsCollectorTest {
reportedEvents.add(new ReportedEvent(EVENT_METADATA, eventTime)); reportedEvents.add(new ReportedEvent(EVENT_METADATA, eventTime));
} }
@SuppressWarnings("deprecation")
@Override @Override
public void onDecoderEnabled( public void onDecoderEnabled(
EventTime eventTime, int trackType, DecoderCounters decoderCounters) { EventTime eventTime, int trackType, DecoderCounters decoderCounters) {
reportedEvents.add(new ReportedEvent(EVENT_DECODER_ENABLED, eventTime)); reportedEvents.add(new ReportedEvent(EVENT_DECODER_ENABLED, eventTime));
} }
@SuppressWarnings("deprecation")
@Override @Override
public void onDecoderInitialized( public void onDecoderInitialized(
EventTime eventTime, int trackType, String decoderName, long initializationDurationMs) { EventTime eventTime, int trackType, String decoderName, long initializationDurationMs) {
reportedEvents.add(new ReportedEvent(EVENT_DECODER_INIT, eventTime)); reportedEvents.add(new ReportedEvent(EVENT_DECODER_INIT, eventTime));
} }
@SuppressWarnings("deprecation")
@Override @Override
public void onDecoderInputFormatChanged(EventTime eventTime, int trackType, Format format) { public void onDecoderInputFormatChanged(EventTime eventTime, int trackType, Format format) {
reportedEvents.add(new ReportedEvent(EVENT_DECODER_FORMAT_CHANGED, eventTime)); reportedEvents.add(new ReportedEvent(EVENT_DECODER_FORMAT_CHANGED, eventTime));
} }
@SuppressWarnings("deprecation")
@Override @Override
public void onDecoderDisabled( public void onDecoderDisabled(
EventTime eventTime, int trackType, DecoderCounters decoderCounters) { EventTime eventTime, int trackType, DecoderCounters decoderCounters) {
...@@ -1871,6 +2005,27 @@ public final class AnalyticsCollectorTest { ...@@ -1871,6 +2005,27 @@ public final class AnalyticsCollectorTest {
} }
@Override @Override
public void onAudioEnabled(EventTime eventTime, DecoderCounters counters) {
reportedEvents.add(new ReportedEvent(EVENT_AUDIO_ENABLED, eventTime));
}
@Override
public void onAudioDecoderInitialized(
EventTime eventTime, String decoderName, long initializationDurationMs) {
reportedEvents.add(new ReportedEvent(EVENT_AUDIO_DECODER_INIT, eventTime));
}
@Override
public void onAudioInputFormatChanged(EventTime eventTime, Format format) {
reportedEvents.add(new ReportedEvent(EVENT_AUDIO_INPUT_FORMAT_CHANGED, eventTime));
}
@Override
public void onAudioDisabled(EventTime eventTime, DecoderCounters counters) {
reportedEvents.add(new ReportedEvent(EVENT_AUDIO_DISABLED, eventTime));
}
@Override
public void onAudioSessionId(EventTime eventTime, int audioSessionId) { public void onAudioSessionId(EventTime eventTime, int audioSessionId) {
reportedEvents.add(new ReportedEvent(EVENT_AUDIO_SESSION_ID, eventTime)); reportedEvents.add(new ReportedEvent(EVENT_AUDIO_SESSION_ID, eventTime));
} }
...@@ -1882,8 +2037,40 @@ public final class AnalyticsCollectorTest { ...@@ -1882,8 +2037,40 @@ public final class AnalyticsCollectorTest {
} }
@Override @Override
public void onVideoEnabled(EventTime eventTime, DecoderCounters counters) {
reportedEvents.add(new ReportedEvent(EVENT_VIDEO_ENABLED, eventTime));
}
@Override
public void onVideoDecoderInitialized(
EventTime eventTime, String decoderName, long initializationDurationMs) {
reportedEvents.add(new ReportedEvent(EVENT_VIDEO_DECODER_INIT, eventTime));
}
@Override
public void onVideoInputFormatChanged(EventTime eventTime, Format format) {
reportedEvents.add(new ReportedEvent(EVENT_VIDEO_INPUT_FORMAT_CHANGED, eventTime));
}
@Override
public void onDroppedVideoFrames(EventTime eventTime, int droppedFrames, long elapsedMs) { public void onDroppedVideoFrames(EventTime eventTime, int droppedFrames, long elapsedMs) {
reportedEvents.add(new ReportedEvent(EVENT_DROPPED_VIDEO_FRAMES, eventTime)); reportedEvents.add(new ReportedEvent(EVENT_DROPPED_FRAMES, eventTime));
}
@Override
public void onVideoDisabled(EventTime eventTime, DecoderCounters counters) {
reportedEvents.add(new ReportedEvent(EVENT_VIDEO_DISABLED, eventTime));
}
@Override
public void onVideoFrameProcessingOffset(
EventTime eventTime, long totalProcessingOffsetUs, int frameCount, Format format) {
reportedEvents.add(new ReportedEvent(EVENT_VIDEO_FRAME_PROCESSING_OFFSET, eventTime));
}
@Override
public void onRenderedFirstFrame(EventTime eventTime, Surface surface) {
reportedEvents.add(new ReportedEvent(EVENT_RENDERED_FIRST_FRAME, eventTime));
} }
@Override @Override
...@@ -1897,11 +2084,6 @@ public final class AnalyticsCollectorTest { ...@@ -1897,11 +2084,6 @@ public final class AnalyticsCollectorTest {
} }
@Override @Override
public void onRenderedFirstFrame(EventTime eventTime, Surface surface) {
reportedEvents.add(new ReportedEvent(EVENT_RENDERED_FIRST_FRAME, eventTime));
}
@Override
public void onDrmSessionAcquired(EventTime eventTime) { public void onDrmSessionAcquired(EventTime eventTime) {
reportedEvents.add(new ReportedEvent(EVENT_DRM_SESSION_ACQUIRED, eventTime)); reportedEvents.add(new ReportedEvent(EVENT_DRM_SESSION_ACQUIRED, eventTime));
} }
...@@ -1931,12 +2113,6 @@ public final class AnalyticsCollectorTest { ...@@ -1931,12 +2113,6 @@ public final class AnalyticsCollectorTest {
reportedEvents.add(new ReportedEvent(EVENT_DRM_SESSION_RELEASED, eventTime)); reportedEvents.add(new ReportedEvent(EVENT_DRM_SESSION_RELEASED, eventTime));
} }
@Override
public void onVideoFrameProcessingOffset(
EventTime eventTime, long totalProcessingOffsetUs, int frameCount, Format format) {
reportedEvents.add(new ReportedEvent(EVENT_VIDEO_FRAME_PROCESSING_OFFSET, eventTime));
}
private static final class ReportedEvent { private static final class ReportedEvent {
public final int eventType; public final int eventType;
......
...@@ -22,7 +22,6 @@ import android.os.SystemClock; ...@@ -22,7 +22,6 @@ import android.os.SystemClock;
import android.view.Surface; import android.view.Surface;
import android.widget.FrameLayout; import android.widget.FrameLayout;
import androidx.annotation.Nullable; import androidx.annotation.Nullable;
import com.google.android.exoplayer2.C;
import com.google.android.exoplayer2.DefaultRenderersFactory; import com.google.android.exoplayer2.DefaultRenderersFactory;
import com.google.android.exoplayer2.ExoPlaybackException; import com.google.android.exoplayer2.ExoPlaybackException;
import com.google.android.exoplayer2.ExoPlayer; import com.google.android.exoplayer2.ExoPlayer;
...@@ -209,13 +208,13 @@ public abstract class ExoHostedTest implements AnalyticsListener, HostedTest { ...@@ -209,13 +208,13 @@ public abstract class ExoHostedTest implements AnalyticsListener, HostedTest {
} }
@Override @Override
public void onDecoderDisabled( public void onAudioDisabled(EventTime eventTime, DecoderCounters decoderCounters) {
EventTime eventTime, int trackType, DecoderCounters decoderCounters) { audioDecoderCounters.merge(decoderCounters);
if (trackType == C.TRACK_TYPE_AUDIO) { }
audioDecoderCounters.merge(decoderCounters);
} else if (trackType == C.TRACK_TYPE_VIDEO) { @Override
videoDecoderCounters.merge(decoderCounters); public void onVideoDisabled(EventTime eventTime, DecoderCounters decoderCounters) {
} videoDecoderCounters.merge(decoderCounters);
} }
// Internal logic // Internal logic
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment