Commit 464f5337 by olly Committed by Ian Baker

Remove deprecated debug listener methods from SimpleExoPlayer

- Once the ability to add debug listeners is removed, analyticsCollector
  is the only component that needs to receive the events. Hence it is
  called directly.
- It seemed less confusing to do the same thing for (non-debug) video and
  audio events, and to have AnalyticsCollector no longer implement
  VideoListener and AudioListener directly. This clears up confusion that
  arises as a result of the debug and non-debug interfaces defining the
  same methods in some cases, and having to be careful not to end up
  calling the corresponding AnalyticsCollector method twice.

PiperOrigin-RevId: 351835491
parent fa94fba2
...@@ -69,6 +69,13 @@ ...@@ -69,6 +69,13 @@
`com.google.android.exoplayer2.video.VideoListener` instead. `com.google.android.exoplayer2.video.VideoListener` instead.
* `SingleSampleMediaSource.EventListener` and constructors. Use * `SingleSampleMediaSource.EventListener` and constructors. Use
`MediaSourceEventListener` and `SingleSampleMediaSource.Factory` `MediaSourceEventListener` and `SingleSampleMediaSource.Factory`
* `SimpleExoPlayer.addVideoDebugListener`,
`SimpleExoPlayer.removeVideoDebugListener`,
`SimpleExoPlayer.addAudioDebugListener`
and `SimpleExoPlayer.removeAudioDebugListener`. Use
`SimpleExoPlayer.addAnalyticsListener` and
`SimpleExoPlayer.removeAnalyticsListener` instead.
* `AdaptiveMediaSourceEventListener`. Use `MediaSourceEventListener`
instead. instead.
* Add a `LivePlaybackSpeedControl` component to control the playback speed * Add a `LivePlaybackSpeedControl` component to control the playback speed
during live playbacks. This allows the player to stay close to the during live playbacks. This allows the player to stay close to the
......
...@@ -15,6 +15,8 @@ ...@@ -15,6 +15,8 @@
*/ */
package com.google.android.exoplayer2.video; package com.google.android.exoplayer2.video;
import com.google.android.exoplayer2.C;
/** A listener for metadata corresponding to video being rendered. */ /** A listener for metadata corresponding to video being rendered. */
public interface VideoListener { public interface VideoListener {
...@@ -41,12 +43,10 @@ public interface VideoListener { ...@@ -41,12 +43,10 @@ public interface VideoListener {
* Called each time there's a change in the size of the surface onto which the video is being * Called each time there's a change in the size of the surface onto which the video is being
* rendered. * rendered.
* *
* @param width The surface width in pixels. May be {@link * @param width The surface width in pixels. May be {@link C#LENGTH_UNSET} if unknown, or 0 if the
* com.google.android.exoplayer2.C#LENGTH_UNSET} if unknown, or 0 if the video is not rendered * video is not rendered onto a surface.
* onto a surface. * @param height The surface height in pixels. May be {@link C#LENGTH_UNSET} if unknown, or 0 if
* @param height The surface height in pixels. May be {@link * the video is not rendered onto a surface.
* com.google.android.exoplayer2.C#LENGTH_UNSET} if unknown, or 0 if the video is not rendered
* onto a surface.
*/ */
default void onSurfaceSizeChanged(int width, int height) {} default void onSurfaceSizeChanged(int width, int height) {}
......
...@@ -34,13 +34,11 @@ import com.google.android.exoplayer2.Timeline.Period; ...@@ -34,13 +34,11 @@ import com.google.android.exoplayer2.Timeline.Period;
import com.google.android.exoplayer2.Timeline.Window; import com.google.android.exoplayer2.Timeline.Window;
import com.google.android.exoplayer2.analytics.AnalyticsListener.EventTime; import com.google.android.exoplayer2.analytics.AnalyticsListener.EventTime;
import com.google.android.exoplayer2.audio.AudioAttributes; import com.google.android.exoplayer2.audio.AudioAttributes;
import com.google.android.exoplayer2.audio.AudioListener;
import com.google.android.exoplayer2.audio.AudioRendererEventListener; import com.google.android.exoplayer2.audio.AudioRendererEventListener;
import com.google.android.exoplayer2.decoder.DecoderCounters; import com.google.android.exoplayer2.decoder.DecoderCounters;
import com.google.android.exoplayer2.decoder.DecoderReuseEvaluation; import com.google.android.exoplayer2.decoder.DecoderReuseEvaluation;
import com.google.android.exoplayer2.drm.DrmSessionEventListener; import com.google.android.exoplayer2.drm.DrmSessionEventListener;
import com.google.android.exoplayer2.metadata.Metadata; import com.google.android.exoplayer2.metadata.Metadata;
import com.google.android.exoplayer2.metadata.MetadataOutput;
import com.google.android.exoplayer2.source.LoadEventInfo; import com.google.android.exoplayer2.source.LoadEventInfo;
import com.google.android.exoplayer2.source.MediaLoadData; import com.google.android.exoplayer2.source.MediaLoadData;
import com.google.android.exoplayer2.source.MediaSource.MediaPeriodId; import com.google.android.exoplayer2.source.MediaSource.MediaPeriodId;
...@@ -52,7 +50,6 @@ import com.google.android.exoplayer2.util.Assertions; ...@@ -52,7 +50,6 @@ import com.google.android.exoplayer2.util.Assertions;
import com.google.android.exoplayer2.util.Clock; import com.google.android.exoplayer2.util.Clock;
import com.google.android.exoplayer2.util.ListenerSet; import com.google.android.exoplayer2.util.ListenerSet;
import com.google.android.exoplayer2.util.Util; import com.google.android.exoplayer2.util.Util;
import com.google.android.exoplayer2.video.VideoListener;
import com.google.android.exoplayer2.video.VideoRendererEventListener; import com.google.android.exoplayer2.video.VideoRendererEventListener;
import com.google.common.base.Objects; import com.google.common.base.Objects;
import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableList;
...@@ -64,19 +61,15 @@ import org.checkerframework.checker.nullness.qual.MonotonicNonNull; ...@@ -64,19 +61,15 @@ import org.checkerframework.checker.nullness.qual.MonotonicNonNull;
import org.checkerframework.checker.nullness.qual.RequiresNonNull; import org.checkerframework.checker.nullness.qual.RequiresNonNull;
/** /**
* Data collector which is able to forward analytics events to {@link AnalyticsListener}s by * Data collector that forwards analytics events to {@link AnalyticsListener AnalyticsListeners}.
* listening to all available ExoPlayer listeners.
*/ */
public class AnalyticsCollector public class AnalyticsCollector
implements Player.EventListener, implements Player.EventListener,
MetadataOutput,
AudioRendererEventListener, AudioRendererEventListener,
VideoRendererEventListener, VideoRendererEventListener,
MediaSourceEventListener, MediaSourceEventListener,
BandwidthMeter.EventListener, BandwidthMeter.EventListener,
DrmSessionEventListener, DrmSessionEventListener {
VideoListener,
AudioListener {
private final Clock clock; private final Clock clock;
private final Period period; private final Period period;
...@@ -196,9 +189,13 @@ public class AnalyticsCollector ...@@ -196,9 +189,13 @@ public class AnalyticsCollector
// TODO: remove method. // TODO: remove method.
} }
// MetadataOutput implementation. // MetadataOutput events.
@Override /**
* Called when there is metadata associated with current playback time.
*
* @param metadata The metadata.
*/
public final void onMetadata(Metadata metadata) { public final void onMetadata(Metadata metadata) {
EventTime eventTime = generateCurrentPlayerMediaPeriodEventTime(); EventTime eventTime = generateCurrentPlayerMediaPeriodEventTime();
sendEvent( sendEvent(
...@@ -294,6 +291,15 @@ public class AnalyticsCollector ...@@ -294,6 +291,15 @@ public class AnalyticsCollector
} }
@Override @Override
public final void onSkipSilenceEnabledChanged(boolean skipSilenceEnabled) {
EventTime eventTime = generateReadingMediaPeriodEventTime();
sendEvent(
eventTime,
AnalyticsListener.EVENT_SKIP_SILENCE_ENABLED_CHANGED,
listener -> listener.onSkipSilenceEnabledChanged(eventTime, skipSilenceEnabled));
}
@Override
public final void onAudioSinkError(Exception audioSinkError) { public final void onAudioSinkError(Exception audioSinkError) {
EventTime eventTime = generateReadingMediaPeriodEventTime(); EventTime eventTime = generateReadingMediaPeriodEventTime();
sendEvent( sendEvent(
...@@ -302,9 +308,13 @@ public class AnalyticsCollector ...@@ -302,9 +308,13 @@ public class AnalyticsCollector
listener -> listener.onAudioSinkError(eventTime, audioSinkError)); listener -> listener.onAudioSinkError(eventTime, audioSinkError));
} }
// AudioListener implementation. // Additional audio events.
@Override /**
* Called when the audio session ID changes.
*
* @param audioSessionId The audio session ID.
*/
public final void onAudioSessionIdChanged(int audioSessionId) { public final void onAudioSessionIdChanged(int audioSessionId) {
EventTime eventTime = generateReadingMediaPeriodEventTime(); EventTime eventTime = generateReadingMediaPeriodEventTime();
sendEvent( sendEvent(
...@@ -313,7 +323,11 @@ public class AnalyticsCollector ...@@ -313,7 +323,11 @@ public class AnalyticsCollector
listener -> listener.onAudioSessionIdChanged(eventTime, audioSessionId)); listener -> listener.onAudioSessionIdChanged(eventTime, audioSessionId));
} }
@Override /**
* Called when the audio attributes change.
*
* @param audioAttributes The audio attributes.
*/
public final void onAudioAttributesChanged(AudioAttributes audioAttributes) { public final void onAudioAttributesChanged(AudioAttributes audioAttributes) {
EventTime eventTime = generateReadingMediaPeriodEventTime(); EventTime eventTime = generateReadingMediaPeriodEventTime();
sendEvent( sendEvent(
...@@ -322,22 +336,17 @@ public class AnalyticsCollector ...@@ -322,22 +336,17 @@ public class AnalyticsCollector
listener -> listener.onAudioAttributesChanged(eventTime, audioAttributes)); listener -> listener.onAudioAttributesChanged(eventTime, audioAttributes));
} }
@Override /**
public final void onSkipSilenceEnabledChanged(boolean skipSilenceEnabled) { * Called when the volume changes.
EventTime eventTime = generateReadingMediaPeriodEventTime(); *
sendEvent( * @param volume The new volume, with 0 being silence and 1 being unity gain.
eventTime, */
AnalyticsListener.EVENT_SKIP_SILENCE_ENABLED_CHANGED, public final void onVolumeChanged(float volume) {
listener -> listener.onSkipSilenceEnabledChanged(eventTime, skipSilenceEnabled));
}
@Override
public final void onVolumeChanged(float audioVolume) {
EventTime eventTime = generateReadingMediaPeriodEventTime(); EventTime eventTime = generateReadingMediaPeriodEventTime();
sendEvent( sendEvent(
eventTime, eventTime,
AnalyticsListener.EVENT_VOLUME_CHANGED, AnalyticsListener.EVENT_VOLUME_CHANGED,
listener -> listener.onVolumeChanged(eventTime, audioVolume)); listener -> listener.onVolumeChanged(eventTime, volume));
} }
// VideoRendererEventListener implementation. // VideoRendererEventListener implementation.
...@@ -416,6 +425,18 @@ public class AnalyticsCollector ...@@ -416,6 +425,18 @@ public class AnalyticsCollector
} }
@Override @Override
public final void onVideoSizeChanged(
int width, int height, int unappliedRotationDegrees, float pixelWidthHeightRatio) {
EventTime eventTime = generateReadingMediaPeriodEventTime();
sendEvent(
eventTime,
AnalyticsListener.EVENT_VIDEO_SIZE_CHANGED,
listener ->
listener.onVideoSizeChanged(
eventTime, width, height, unappliedRotationDegrees, pixelWidthHeightRatio));
}
@Override
public final void onRenderedFirstFrame(@Nullable Surface surface) { public final void onRenderedFirstFrame(@Nullable Surface surface) {
EventTime eventTime = generateReadingMediaPeriodEventTime(); EventTime eventTime = generateReadingMediaPeriodEventTime();
sendEvent( sendEvent(
...@@ -434,26 +455,17 @@ public class AnalyticsCollector ...@@ -434,26 +455,17 @@ public class AnalyticsCollector
listener.onVideoFrameProcessingOffset(eventTime, totalProcessingOffsetUs, frameCount)); listener.onVideoFrameProcessingOffset(eventTime, totalProcessingOffsetUs, frameCount));
} }
// VideoListener implementation. // Additional video events.
@Override
public final void onRenderedFirstFrame() {
// Do nothing. Already reported in VideoRendererEventListener.onRenderedFirstFrame.
}
@Override
public final void onVideoSizeChanged(
int width, int height, int unappliedRotationDegrees, float pixelWidthHeightRatio) {
EventTime eventTime = generateReadingMediaPeriodEventTime();
sendEvent(
eventTime,
AnalyticsListener.EVENT_VIDEO_SIZE_CHANGED,
listener ->
listener.onVideoSizeChanged(
eventTime, width, height, unappliedRotationDegrees, pixelWidthHeightRatio));
}
@Override /**
* Called each time there's a change in the size of the surface onto which the video is being
* rendered.
*
* @param width The surface width in pixels. May be {@link C#LENGTH_UNSET} if unknown, or 0 if the
* 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.
*/
public void onSurfaceSizeChanged(int width, int height) { public void onSurfaceSizeChanged(int width, int height) {
EventTime eventTime = generateReadingMediaPeriodEventTime(); EventTime eventTime = generateReadingMediaPeriodEventTime();
sendEvent( sendEvent(
......
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