Add no-op defaults to Video(Audio)RendererEventListener.
This is in line with how Player.EventListener and AnalyticsListener methods are defined and helps to only implement the callbacks needed. PiperOrigin-RevId: 223991262
This commit is contained in:
parent
6b0e1758b2
commit
ddda2eef7e
@ -25,7 +25,8 @@ import com.google.android.exoplayer2.decoder.DecoderCounters;
|
|||||||
import com.google.android.exoplayer2.util.Assertions;
|
import com.google.android.exoplayer2.util.Assertions;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Listener of audio {@link Renderer} events.
|
* Listener of audio {@link Renderer} events. All methods have no-op default implementations to
|
||||||
|
* allow selective overrides.
|
||||||
*/
|
*/
|
||||||
public interface AudioRendererEventListener {
|
public interface AudioRendererEventListener {
|
||||||
|
|
||||||
@ -35,14 +36,14 @@ public interface AudioRendererEventListener {
|
|||||||
* @param counters {@link DecoderCounters} that will be updated by the renderer for as long as it
|
* @param counters {@link DecoderCounters} that will be updated by the renderer for as long as it
|
||||||
* remains enabled.
|
* remains enabled.
|
||||||
*/
|
*/
|
||||||
void onAudioEnabled(DecoderCounters counters);
|
default void onAudioEnabled(DecoderCounters counters) {}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Called when the audio session is set.
|
* Called when the audio session is set.
|
||||||
*
|
*
|
||||||
* @param audioSessionId The audio session id.
|
* @param audioSessionId The audio session id.
|
||||||
*/
|
*/
|
||||||
void onAudioSessionId(int audioSessionId);
|
default void onAudioSessionId(int audioSessionId) {}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Called when a decoder is created.
|
* Called when a decoder is created.
|
||||||
@ -52,15 +53,15 @@ public interface AudioRendererEventListener {
|
|||||||
* finished.
|
* finished.
|
||||||
* @param initializationDurationMs The time taken to initialize the decoder in milliseconds.
|
* @param initializationDurationMs The time taken to initialize the decoder in milliseconds.
|
||||||
*/
|
*/
|
||||||
void onAudioDecoderInitialized(String decoderName, long initializedTimestampMs,
|
default void onAudioDecoderInitialized(
|
||||||
long initializationDurationMs);
|
String decoderName, long initializedTimestampMs, long initializationDurationMs) {}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Called when the format of the media being consumed by the renderer changes.
|
* Called when the format of the media being consumed by the renderer changes.
|
||||||
*
|
*
|
||||||
* @param format The new format.
|
* @param format The new format.
|
||||||
*/
|
*/
|
||||||
void onAudioInputFormatChanged(Format format);
|
default void onAudioInputFormatChanged(Format format) {}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Called when an {@link AudioSink} underrun occurs.
|
* Called when an {@link AudioSink} underrun occurs.
|
||||||
@ -71,14 +72,15 @@ public interface AudioRendererEventListener {
|
|||||||
* as the buffered media can have a variable bitrate so the duration may be unknown.
|
* 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.
|
* @param elapsedSinceLastFeedMs The time since the {@link AudioSink} was last fed data.
|
||||||
*/
|
*/
|
||||||
void onAudioSinkUnderrun(int bufferSize, long bufferSizeMs, long elapsedSinceLastFeedMs);
|
default void onAudioSinkUnderrun(
|
||||||
|
int bufferSize, long bufferSizeMs, long elapsedSinceLastFeedMs) {}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Called when the renderer is disabled.
|
* Called when the renderer is disabled.
|
||||||
*
|
*
|
||||||
* @param counters {@link DecoderCounters} that were updated by the renderer.
|
* @param counters {@link DecoderCounters} that were updated by the renderer.
|
||||||
*/
|
*/
|
||||||
void onAudioDisabled(DecoderCounters counters);
|
default void onAudioDisabled(DecoderCounters counters) {}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Dispatches events to a {@link AudioRendererEventListener}.
|
* Dispatches events to a {@link AudioRendererEventListener}.
|
||||||
|
@ -26,7 +26,8 @@ import com.google.android.exoplayer2.decoder.DecoderCounters;
|
|||||||
import com.google.android.exoplayer2.util.Assertions;
|
import com.google.android.exoplayer2.util.Assertions;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Listener of video {@link Renderer} events.
|
* Listener of video {@link Renderer} events. All methods have no-op default implementations to
|
||||||
|
* allow selective overrides.
|
||||||
*/
|
*/
|
||||||
public interface VideoRendererEventListener {
|
public interface VideoRendererEventListener {
|
||||||
|
|
||||||
@ -36,7 +37,7 @@ public interface VideoRendererEventListener {
|
|||||||
* @param counters {@link DecoderCounters} that will be updated by the renderer for as long as it
|
* @param counters {@link DecoderCounters} that will be updated by the renderer for as long as it
|
||||||
* remains enabled.
|
* remains enabled.
|
||||||
*/
|
*/
|
||||||
void onVideoEnabled(DecoderCounters counters);
|
default void onVideoEnabled(DecoderCounters counters) {}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Called when a decoder is created.
|
* Called when a decoder is created.
|
||||||
@ -46,15 +47,15 @@ public interface VideoRendererEventListener {
|
|||||||
* finished.
|
* finished.
|
||||||
* @param initializationDurationMs The time taken to initialize the decoder in milliseconds.
|
* @param initializationDurationMs The time taken to initialize the decoder in milliseconds.
|
||||||
*/
|
*/
|
||||||
void onVideoDecoderInitialized(String decoderName, long initializedTimestampMs,
|
default void onVideoDecoderInitialized(
|
||||||
long initializationDurationMs);
|
String decoderName, long initializedTimestampMs, long initializationDurationMs) {}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Called when the format of the media being consumed by the renderer changes.
|
* Called when the format of the media being consumed by the renderer changes.
|
||||||
*
|
*
|
||||||
* @param format The new format.
|
* @param format The new format.
|
||||||
*/
|
*/
|
||||||
void onVideoInputFormatChanged(Format format);
|
default void onVideoInputFormatChanged(Format format) {}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Called to report the number of frames dropped by the renderer. Dropped frames are reported
|
* Called to report the number of frames dropped by the renderer. Dropped frames are reported
|
||||||
@ -62,12 +63,11 @@ public interface VideoRendererEventListener {
|
|||||||
* reaches a specified threshold whilst the renderer is started.
|
* reaches a specified threshold whilst the renderer is started.
|
||||||
*
|
*
|
||||||
* @param count The number of dropped frames.
|
* @param count The number of dropped frames.
|
||||||
* @param elapsedMs The duration in milliseconds over which the frames were dropped. This
|
* @param elapsedMs The duration in milliseconds over which the frames were dropped. This duration
|
||||||
* duration is timed from when the renderer was started or from when dropped frames were
|
* is timed from when the renderer was started or from when dropped frames were last reported
|
||||||
* last reported (whichever was more recent), and not from when the first of the reported
|
* (whichever was more recent), and not from when the first of the reported drops occurred.
|
||||||
* drops occurred.
|
|
||||||
*/
|
*/
|
||||||
void onDroppedFrames(int count, long elapsedMs);
|
default void onDroppedFrames(int count, long elapsedMs) {}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 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
|
||||||
@ -82,12 +82,12 @@ public interface VideoRendererEventListener {
|
|||||||
* this is not possible. Applications that use {@link TextureView} can apply the rotation by
|
* this is not possible. Applications that use {@link TextureView} can apply the rotation by
|
||||||
* calling {@link TextureView#setTransform}. Applications that do not expect to encounter
|
* calling {@link TextureView#setTransform}. Applications that do not expect to encounter
|
||||||
* rotated videos can safely ignore this parameter.
|
* rotated videos can safely ignore this parameter.
|
||||||
* @param pixelWidthHeightRatio The width to height ratio of each pixel. For the normal case
|
* @param pixelWidthHeightRatio The width to height ratio of each pixel. For the normal case of
|
||||||
* of square pixels this will be equal to 1.0. Different values are indicative of anamorphic
|
* square pixels this will be equal to 1.0. Different values are indicative of anamorphic
|
||||||
* content.
|
* content.
|
||||||
*/
|
*/
|
||||||
void onVideoSizeChanged(int width, int height, int unappliedRotationDegrees,
|
default void onVideoSizeChanged(
|
||||||
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, and when a frame
|
||||||
@ -96,14 +96,14 @@ public interface VideoRendererEventListener {
|
|||||||
* @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}.
|
||||||
*/
|
*/
|
||||||
void onRenderedFirstFrame(@Nullable Surface surface);
|
default void onRenderedFirstFrame(@Nullable Surface surface) {}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Called when the renderer is disabled.
|
* Called when the renderer is disabled.
|
||||||
*
|
*
|
||||||
* @param counters {@link DecoderCounters} that were updated by the renderer.
|
* @param counters {@link DecoderCounters} that were updated by the renderer.
|
||||||
*/
|
*/
|
||||||
void onVideoDisabled(DecoderCounters counters);
|
default void onVideoDisabled(DecoderCounters counters) {}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Dispatches events to a {@link VideoRendererEventListener}.
|
* Dispatches events to a {@link VideoRendererEventListener}.
|
||||||
|
Loading…
x
Reference in New Issue
Block a user