Commit 24c21a29 by tonihei Committed by Oliver Woodman

Deprecate DefaultAnalyticsListener in favor of default no-ops in interface.

The DefaultAnalyticsListener was added for selective overrides. Now that Java 8
support is enabled, these selective listener overrides can be implemented
more easily and more flexible using default methods.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=201931770
parent a407c028
......@@ -42,6 +42,8 @@
([#4403](https://github.com/google/ExoPlayer/issues/4403)).
* Deprecate `Player.DefaultEventListener` as selective listener overrides can
be directly made with the `Player.EventListener` interface.
* Deprecate `DefaultAnalyticsListener` as selective listener overrides can be
directly made with the `AnalyticsListener` interface.
### 2.8.2 ###
......
......@@ -40,6 +40,8 @@ import java.io.IOException;
*
* <p>All events are recorded with an {@link EventTime} specifying the elapsed real time and media
* time at the time of the event.
*
* <p>All methods have no-op default implementations to allow selective overrides.
*/
public interface AnalyticsListener {
......@@ -126,7 +128,8 @@ public interface AnalyticsListener {
* @param playWhenReady Whether the playback will proceed when ready.
* @param playbackState One of the {@link Player}.STATE constants.
*/
void onPlayerStateChanged(EventTime eventTime, boolean playWhenReady, int playbackState);
default void onPlayerStateChanged(
EventTime eventTime, boolean playWhenReady, int playbackState) {}
/**
* Called when the timeline changed.
......@@ -134,7 +137,7 @@ public interface AnalyticsListener {
* @param eventTime The event time.
* @param reason The reason for the timeline change.
*/
void onTimelineChanged(EventTime eventTime, @TimelineChangeReason int reason);
default void onTimelineChanged(EventTime eventTime, @TimelineChangeReason int reason) {}
/**
* Called when a position discontinuity occurred.
......@@ -142,21 +145,21 @@ public interface AnalyticsListener {
* @param eventTime The event time.
* @param reason The reason for the position discontinuity.
*/
void onPositionDiscontinuity(EventTime eventTime, @DiscontinuityReason int reason);
default void onPositionDiscontinuity(EventTime eventTime, @DiscontinuityReason int reason) {}
/**
* Called when a seek operation started.
*
* @param eventTime The event time.
*/
void onSeekStarted(EventTime eventTime);
default void onSeekStarted(EventTime eventTime) {}
/**
* Called when a seek operation was processed.
*
* @param eventTime The event time.
*/
void onSeekProcessed(EventTime eventTime);
default void onSeekProcessed(EventTime eventTime) {}
/**
* Called when the playback parameters changed.
......@@ -164,7 +167,8 @@ public interface AnalyticsListener {
* @param eventTime The event time.
* @param playbackParameters The new playback parameters.
*/
void onPlaybackParametersChanged(EventTime eventTime, PlaybackParameters playbackParameters);
default void onPlaybackParametersChanged(
EventTime eventTime, PlaybackParameters playbackParameters) {}
/**
* Called when the repeat mode changed.
......@@ -172,7 +176,7 @@ public interface AnalyticsListener {
* @param eventTime The event time.
* @param repeatMode The new repeat mode.
*/
void onRepeatModeChanged(EventTime eventTime, @Player.RepeatMode int repeatMode);
default void onRepeatModeChanged(EventTime eventTime, @Player.RepeatMode int repeatMode) {}
/**
* Called when the shuffle mode changed.
......@@ -180,7 +184,7 @@ public interface AnalyticsListener {
* @param eventTime The event time.
* @param shuffleModeEnabled Whether the shuffle mode is enabled.
*/
void onShuffleModeChanged(EventTime eventTime, boolean shuffleModeEnabled);
default void onShuffleModeChanged(EventTime eventTime, boolean shuffleModeEnabled) {}
/**
* Called when the player starts or stops loading data from a source.
......@@ -188,7 +192,7 @@ public interface AnalyticsListener {
* @param eventTime The event time.
* @param isLoading Whether the player is loading.
*/
void onLoadingChanged(EventTime eventTime, boolean isLoading);
default void onLoadingChanged(EventTime eventTime, boolean isLoading) {}
/**
* Called when a fatal player error occurred.
......@@ -196,7 +200,7 @@ public interface AnalyticsListener {
* @param eventTime The event time.
* @param error The error.
*/
void onPlayerError(EventTime eventTime, ExoPlaybackException error);
default void onPlayerError(EventTime eventTime, ExoPlaybackException error) {}
/**
* Called when the available or selected tracks for the renderers changed.
......@@ -205,8 +209,8 @@ public interface AnalyticsListener {
* @param trackGroups The available tracks. May be empty.
* @param trackSelections The track selections for each renderer. May contain null elements.
*/
void onTracksChanged(
EventTime eventTime, TrackGroupArray trackGroups, TrackSelectionArray trackSelections);
default void onTracksChanged(
EventTime eventTime, TrackGroupArray trackGroups, TrackSelectionArray trackSelections) {}
/**
* Called when a media source started loading data.
......@@ -215,7 +219,8 @@ public interface AnalyticsListener {
* @param loadEventInfo The {@link LoadEventInfo} defining the load event.
* @param mediaLoadData The {@link MediaLoadData} defining the data being loaded.
*/
void onLoadStarted(EventTime eventTime, LoadEventInfo loadEventInfo, MediaLoadData mediaLoadData);
default void onLoadStarted(
EventTime eventTime, LoadEventInfo loadEventInfo, MediaLoadData mediaLoadData) {}
/**
* Called when a media source completed loading data.
......@@ -224,8 +229,8 @@ public interface AnalyticsListener {
* @param loadEventInfo The {@link LoadEventInfo} defining the load event.
* @param mediaLoadData The {@link MediaLoadData} defining the data being loaded.
*/
void onLoadCompleted(
EventTime eventTime, LoadEventInfo loadEventInfo, MediaLoadData mediaLoadData);
default void onLoadCompleted(
EventTime eventTime, LoadEventInfo loadEventInfo, MediaLoadData mediaLoadData) {}
/**
* Called when a media source canceled loading data.
......@@ -234,8 +239,8 @@ public interface AnalyticsListener {
* @param loadEventInfo The {@link LoadEventInfo} defining the load event.
* @param mediaLoadData The {@link MediaLoadData} defining the data being loaded.
*/
void onLoadCanceled(
EventTime eventTime, LoadEventInfo loadEventInfo, MediaLoadData mediaLoadData);
default void onLoadCanceled(
EventTime eventTime, LoadEventInfo loadEventInfo, MediaLoadData mediaLoadData) {}
/**
* Called when a media source loading error occurred. These errors are just for informational
......@@ -247,12 +252,12 @@ public interface AnalyticsListener {
* @param error The load error.
* @param wasCanceled Whether the load was canceled as a result of the error.
*/
void onLoadError(
default void onLoadError(
EventTime eventTime,
LoadEventInfo loadEventInfo,
MediaLoadData mediaLoadData,
IOException error,
boolean wasCanceled);
boolean wasCanceled) {}
/**
* Called when the downstream format sent to the renderers changed.
......@@ -260,7 +265,7 @@ public interface AnalyticsListener {
* @param eventTime The event time.
* @param mediaLoadData The {@link MediaLoadData} defining the newly selected media data.
*/
void onDownstreamFormatChanged(EventTime eventTime, MediaLoadData mediaLoadData);
default void onDownstreamFormatChanged(EventTime eventTime, MediaLoadData mediaLoadData) {}
/**
* Called when data is removed from the back of a media buffer, typically so that it can be
......@@ -269,28 +274,28 @@ public interface AnalyticsListener {
* @param eventTime The event time.
* @param mediaLoadData The {@link MediaLoadData} defining the media being discarded.
*/
void onUpstreamDiscarded(EventTime eventTime, MediaLoadData mediaLoadData);
default void onUpstreamDiscarded(EventTime eventTime, MediaLoadData mediaLoadData) {}
/**
* Called when a media source created a media period.
*
* @param eventTime The event time.
*/
void onMediaPeriodCreated(EventTime eventTime);
default void onMediaPeriodCreated(EventTime eventTime) {}
/**
* Called when a media source released a media period.
*
* @param eventTime The event time.
*/
void onMediaPeriodReleased(EventTime eventTime);
default void onMediaPeriodReleased(EventTime eventTime) {}
/**
* Called when the player started reading a media period.
*
* @param eventTime The event time.
*/
void onReadingStarted(EventTime eventTime);
default void onReadingStarted(EventTime eventTime) {}
/**
* Called when the bandwidth estimate for the current data source has been updated.
......@@ -300,8 +305,8 @@ public interface AnalyticsListener {
* @param totalBytesLoaded The total bytes loaded this update is based on.
* @param bitrateEstimate The bandwidth estimate, in bits per second.
*/
void onBandwidthEstimate(
EventTime eventTime, int totalLoadTimeMs, long totalBytesLoaded, long bitrateEstimate);
default void onBandwidthEstimate(
EventTime eventTime, int totalLoadTimeMs, long totalBytesLoaded, long bitrateEstimate) {}
/**
* Called when the output surface size changed.
......@@ -312,7 +317,7 @@ public interface AnalyticsListener {
* @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.
*/
void onSurfaceSizeChanged(EventTime eventTime, int width, int height);
default void onSurfaceSizeChanged(EventTime eventTime, int width, int height) {}
/**
* Called when there is {@link Metadata} associated with the current playback time.
......@@ -320,7 +325,7 @@ public interface AnalyticsListener {
* @param eventTime The event time.
* @param metadata The metadata.
*/
void onMetadata(EventTime eventTime, Metadata metadata);
default void onMetadata(EventTime eventTime, Metadata metadata) {}
/**
* Called when an audio or video decoder has been enabled.
......@@ -330,7 +335,8 @@ public interface AnalyticsListener {
* {@link C#TRACK_TYPE_VIDEO}.
* @param decoderCounters The accumulated event counters associated with this decoder.
*/
void onDecoderEnabled(EventTime eventTime, int trackType, DecoderCounters decoderCounters);
default void onDecoderEnabled(
EventTime eventTime, int trackType, DecoderCounters decoderCounters) {}
/**
* Called when an audio or video decoder has been initialized.
......@@ -341,8 +347,8 @@ public interface AnalyticsListener {
* @param decoderName The decoder that was created.
* @param initializationDurationMs Time taken to initialize the decoder, in milliseconds.
*/
void onDecoderInitialized(
EventTime eventTime, int trackType, String decoderName, long initializationDurationMs);
default void onDecoderInitialized(
EventTime eventTime, int trackType, String decoderName, long initializationDurationMs) {}
/**
* Called when an audio or video decoder input format changed.
......@@ -352,7 +358,7 @@ public interface AnalyticsListener {
* C#TRACK_TYPE_AUDIO} or {@link C#TRACK_TYPE_VIDEO}.
* @param format The new input format for the decoder.
*/
void onDecoderInputFormatChanged(EventTime eventTime, int trackType, Format format);
default void onDecoderInputFormatChanged(EventTime eventTime, int trackType, Format format) {}
/**
* Called when an audio or video decoder has been disabled.
......@@ -362,7 +368,8 @@ public interface AnalyticsListener {
* {@link C#TRACK_TYPE_VIDEO}.
* @param decoderCounters The accumulated event counters associated with this decoder.
*/
void onDecoderDisabled(EventTime eventTime, int trackType, DecoderCounters decoderCounters);
default void onDecoderDisabled(
EventTime eventTime, int trackType, DecoderCounters decoderCounters) {}
/**
* Called when the audio session id is set.
......@@ -370,7 +377,7 @@ public interface AnalyticsListener {
* @param eventTime The event time.
* @param audioSessionId The audio session id.
*/
void onAudioSessionId(EventTime eventTime, int audioSessionId);
default void onAudioSessionId(EventTime eventTime, int audioSessionId) {}
/**
* Called when an audio underrun occurred.
......@@ -382,8 +389,8 @@ public interface AnalyticsListener {
* 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.
*/
void onAudioUnderrun(
EventTime eventTime, int bufferSize, long bufferSizeMs, long elapsedSinceLastFeedMs);
default void onAudioUnderrun(
EventTime eventTime, int bufferSize, long bufferSizeMs, long elapsedSinceLastFeedMs) {}
/**
* Called after video frames have been dropped.
......@@ -394,7 +401,7 @@ public interface AnalyticsListener {
* is timed from when the renderer was started or from when dropped frames were last reported
* (whichever was more recent), and not from when the first of the reported drops occurred.
*/
void onDroppedVideoFrames(EventTime eventTime, int droppedFrames, long elapsedMs);
default void onDroppedVideoFrames(EventTime eventTime, int droppedFrames, long elapsedMs) {}
/**
* Called before a frame is rendered for the first time since setting the surface, and each time
......@@ -409,12 +416,12 @@ public interface AnalyticsListener {
* since the renderer will apply all necessary rotations internally.
* @param pixelWidthHeightRatio The width to height ratio of each pixel.
*/
void onVideoSizeChanged(
default void onVideoSizeChanged(
EventTime eventTime,
int width,
int height,
int unappliedRotationDegrees,
float pixelWidthHeightRatio);
float pixelWidthHeightRatio) {}
/**
* Called when a frame is rendered for the first time since setting the surface, and when a frame
......@@ -424,14 +431,14 @@ public interface AnalyticsListener {
* @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}.
*/
void onRenderedFirstFrame(EventTime eventTime, Surface surface);
default void onRenderedFirstFrame(EventTime eventTime, Surface surface) {}
/**
* Called each time drm keys are loaded.
*
* @param eventTime The event time.
*/
void onDrmKeysLoaded(EventTime eventTime);
default void onDrmKeysLoaded(EventTime eventTime) {}
/**
* Called when a drm error occurs. These errors are just for informational purposes and the player
......@@ -440,19 +447,19 @@ public interface AnalyticsListener {
* @param eventTime The event time.
* @param error The error.
*/
void onDrmSessionManagerError(EventTime eventTime, Exception error);
default void onDrmSessionManagerError(EventTime eventTime, Exception error) {}
/**
* Called each time offline drm keys are restored.
*
* @param eventTime The event time.
*/
void onDrmKeysRestored(EventTime eventTime);
default void onDrmKeysRestored(EventTime eventTime) {}
/**
* Called each time offline drm keys are removed.
*
* @param eventTime The event time.
*/
void onDrmKeysRemoved(EventTime eventTime);
default void onDrmKeysRemoved(EventTime eventTime) {}
}
......@@ -15,148 +15,9 @@
*/
package com.google.android.exoplayer2.analytics;
import android.view.Surface;
import com.google.android.exoplayer2.ExoPlaybackException;
import com.google.android.exoplayer2.Format;
import com.google.android.exoplayer2.PlaybackParameters;
import com.google.android.exoplayer2.decoder.DecoderCounters;
import com.google.android.exoplayer2.metadata.Metadata;
import com.google.android.exoplayer2.source.MediaSourceEventListener.LoadEventInfo;
import com.google.android.exoplayer2.source.MediaSourceEventListener.MediaLoadData;
import com.google.android.exoplayer2.source.TrackGroupArray;
import com.google.android.exoplayer2.trackselection.TrackSelectionArray;
import java.io.IOException;
/**
* {@link AnalyticsListener} allowing selective overrides. All methods are implemented as no-ops.
* @deprecated Use {@link AnalyticsListener} directly for selective overrides as all methods are
* implemented as no-op default methods.
*/
public abstract class DefaultAnalyticsListener implements AnalyticsListener {
@Override
public void onPlayerStateChanged(EventTime eventTime, boolean playWhenReady, int playbackState) {}
@Override
public void onTimelineChanged(EventTime eventTime, int reason) {}
@Override
public void onPositionDiscontinuity(EventTime eventTime, int reason) {}
@Override
public void onSeekStarted(EventTime eventTime) {}
@Override
public void onSeekProcessed(EventTime eventTime) {}
@Override
public void onPlaybackParametersChanged(
EventTime eventTime, PlaybackParameters playbackParameters) {}
@Override
public void onRepeatModeChanged(EventTime eventTime, int repeatMode) {}
@Override
public void onShuffleModeChanged(EventTime eventTime, boolean shuffleModeEnabled) {}
@Override
public void onLoadingChanged(EventTime eventTime, boolean isLoading) {}
@Override
public void onPlayerError(EventTime eventTime, ExoPlaybackException error) {}
@Override
public void onTracksChanged(
EventTime eventTime, TrackGroupArray trackGroups, TrackSelectionArray trackSelections) {}
@Override
public void onLoadStarted(
EventTime eventTime, LoadEventInfo loadEventInfo, MediaLoadData mediaLoadData) {}
@Override
public void onLoadCompleted(
EventTime eventTime, LoadEventInfo loadEventInfo, MediaLoadData mediaLoadData) {}
@Override
public void onLoadCanceled(
EventTime eventTime, LoadEventInfo loadEventInfo, MediaLoadData mediaLoadData) {}
@Override
public void onLoadError(
EventTime eventTime,
LoadEventInfo loadEventInfo,
MediaLoadData mediaLoadData,
IOException error,
boolean wasCanceled) {}
@Override
public void onDownstreamFormatChanged(EventTime eventTime, MediaLoadData mediaLoadData) {}
@Override
public void onUpstreamDiscarded(EventTime eventTime, MediaLoadData mediaLoadData) {}
@Override
public void onMediaPeriodCreated(EventTime eventTime) {}
@Override
public void onMediaPeriodReleased(EventTime eventTime) {}
@Override
public void onReadingStarted(EventTime eventTime) {}
@Override
public void onBandwidthEstimate(
EventTime eventTime, int totalLoadTimeMs, long totalBytesLoaded, long bitrateEstimate) {}
@Override
public void onSurfaceSizeChanged(EventTime eventTime, int width, int height) {}
@Override
public void onMetadata(EventTime eventTime, Metadata metadata) {}
@Override
public void onDecoderEnabled(
EventTime eventTime, int trackType, DecoderCounters decoderCounters) {}
@Override
public void onDecoderInitialized(
EventTime eventTime, int trackType, String decoderName, long initializationDurationMs) {}
@Override
public void onDecoderInputFormatChanged(EventTime eventTime, int trackType, Format format) {}
@Override
public void onDecoderDisabled(
EventTime eventTime, int trackType, DecoderCounters decoderCounters) {}
@Override
public void onAudioSessionId(EventTime eventTime, int audioSessionId) {}
@Override
public void onAudioUnderrun(
EventTime eventTime, int bufferSize, long bufferSizeMs, long elapsedSinceLastFeedMs) {}
@Override
public void onDroppedVideoFrames(EventTime eventTime, int droppedFrames, long elapsedMs) {}
@Override
public void onVideoSizeChanged(
EventTime eventTime,
int width,
int height,
int unappliedRotationDegrees,
float pixelWidthHeightRatio) {}
@Override
public void onRenderedFirstFrame(EventTime eventTime, Surface surface) {}
@Override
public void onDrmKeysLoaded(EventTime eventTime) {}
@Override
public void onDrmSessionManagerError(EventTime eventTime, Exception error) {}
@Override
public void onDrmKeysRestored(EventTime eventTime) {}
@Override
public void onDrmKeysRemoved(EventTime eventTime) {}
}
@Deprecated
public abstract class DefaultAnalyticsListener implements AnalyticsListener {}
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