Make some listener methods default
PiperOrigin-RevId: 281050034
This commit is contained in:
parent
6b03ce8f12
commit
7f19b88506
@ -24,7 +24,7 @@ public interface DefaultDrmSessionEventListener {
|
||||
default void onDrmSessionAcquired() {}
|
||||
|
||||
/** Called each time keys are loaded. */
|
||||
void onDrmKeysLoaded();
|
||||
default void onDrmKeysLoaded() {}
|
||||
|
||||
/**
|
||||
* Called when a drm error occurs.
|
||||
@ -38,13 +38,13 @@ public interface DefaultDrmSessionEventListener {
|
||||
*
|
||||
* @param error The corresponding exception.
|
||||
*/
|
||||
void onDrmSessionManagerError(Exception error);
|
||||
default void onDrmSessionManagerError(Exception error) {}
|
||||
|
||||
/** Called each time offline keys are restored. */
|
||||
void onDrmKeysRestored();
|
||||
default void onDrmKeysRestored() {}
|
||||
|
||||
/** Called each time offline keys are removed. */
|
||||
void onDrmKeysRemoved();
|
||||
default void onDrmKeysRemoved() {}
|
||||
|
||||
/** Called each time a drm session is released. */
|
||||
default void onDrmSessionReleased() {}
|
||||
|
@ -15,78 +15,9 @@
|
||||
*/
|
||||
package com.google.android.exoplayer2.source;
|
||||
|
||||
import androidx.annotation.Nullable;
|
||||
import com.google.android.exoplayer2.source.MediaSource.MediaPeriodId;
|
||||
import java.io.IOException;
|
||||
|
||||
/**
|
||||
* A {@link MediaSourceEventListener} allowing selective overrides. All methods are implemented as
|
||||
* no-ops.
|
||||
* @deprecated Use {@link MediaSourceEventListener} interface directly for selective overrides as
|
||||
* all methods are implemented as no-op default methods.
|
||||
*/
|
||||
public abstract class DefaultMediaSourceEventListener implements MediaSourceEventListener {
|
||||
|
||||
@Override
|
||||
public void onMediaPeriodCreated(int windowIndex, MediaPeriodId mediaPeriodId) {
|
||||
// Do nothing.
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onMediaPeriodReleased(int windowIndex, MediaPeriodId mediaPeriodId) {
|
||||
// Do nothing.
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onLoadStarted(
|
||||
int windowIndex,
|
||||
@Nullable MediaPeriodId mediaPeriodId,
|
||||
LoadEventInfo loadEventInfo,
|
||||
MediaLoadData mediaLoadData) {
|
||||
// Do nothing.
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onLoadCompleted(
|
||||
int windowIndex,
|
||||
@Nullable MediaPeriodId mediaPeriodId,
|
||||
LoadEventInfo loadEventInfo,
|
||||
MediaLoadData mediaLoadData) {
|
||||
// Do nothing.
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onLoadCanceled(
|
||||
int windowIndex,
|
||||
@Nullable MediaPeriodId mediaPeriodId,
|
||||
LoadEventInfo loadEventInfo,
|
||||
MediaLoadData mediaLoadData) {
|
||||
// Do nothing.
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onLoadError(
|
||||
int windowIndex,
|
||||
@Nullable MediaPeriodId mediaPeriodId,
|
||||
LoadEventInfo loadEventInfo,
|
||||
MediaLoadData mediaLoadData,
|
||||
IOException error,
|
||||
boolean wasCanceled) {
|
||||
// Do nothing.
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onReadingStarted(int windowIndex, MediaPeriodId mediaPeriodId) {
|
||||
// Do nothing.
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onUpstreamDiscarded(
|
||||
int windowIndex, @Nullable MediaPeriodId mediaPeriodId, MediaLoadData mediaLoadData) {
|
||||
// Do nothing.
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDownstreamFormatChanged(
|
||||
int windowIndex, @Nullable MediaPeriodId mediaPeriodId, MediaLoadData mediaLoadData) {
|
||||
// Do nothing.
|
||||
}
|
||||
}
|
||||
@Deprecated
|
||||
public abstract class DefaultMediaSourceEventListener implements MediaSourceEventListener {}
|
||||
|
@ -365,7 +365,7 @@ public final class ExtractorMediaSource extends CompositeMediaSource<Void> {
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
private static final class EventListenerWrapper extends DefaultMediaSourceEventListener {
|
||||
private static final class EventListenerWrapper implements MediaSourceEventListener {
|
||||
|
||||
private final EventListener eventListener;
|
||||
|
||||
|
@ -164,7 +164,7 @@ public interface MediaSourceEventListener {
|
||||
* @param windowIndex The window index in the timeline this media period belongs to.
|
||||
* @param mediaPeriodId The {@link MediaPeriodId} of the created media period.
|
||||
*/
|
||||
void onMediaPeriodCreated(int windowIndex, MediaPeriodId mediaPeriodId);
|
||||
default void onMediaPeriodCreated(int windowIndex, MediaPeriodId mediaPeriodId) {}
|
||||
|
||||
/**
|
||||
* Called when a media period is released by the media source.
|
||||
@ -172,7 +172,7 @@ public interface MediaSourceEventListener {
|
||||
* @param windowIndex The window index in the timeline this media period belongs to.
|
||||
* @param mediaPeriodId The {@link MediaPeriodId} of the released media period.
|
||||
*/
|
||||
void onMediaPeriodReleased(int windowIndex, MediaPeriodId mediaPeriodId);
|
||||
default void onMediaPeriodReleased(int windowIndex, MediaPeriodId mediaPeriodId) {}
|
||||
|
||||
/**
|
||||
* Called when a load begins.
|
||||
@ -185,11 +185,11 @@ public interface MediaSourceEventListener {
|
||||
* LoadEventInfo#responseHeaders} will be empty.
|
||||
* @param mediaLoadData The {@link MediaLoadData} defining the data being loaded.
|
||||
*/
|
||||
void onLoadStarted(
|
||||
default void onLoadStarted(
|
||||
int windowIndex,
|
||||
@Nullable MediaPeriodId mediaPeriodId,
|
||||
LoadEventInfo loadEventInfo,
|
||||
MediaLoadData mediaLoadData);
|
||||
MediaLoadData mediaLoadData) {}
|
||||
|
||||
/**
|
||||
* Called when a load ends.
|
||||
@ -203,11 +203,11 @@ public interface MediaSourceEventListener {
|
||||
* event.
|
||||
* @param mediaLoadData The {@link MediaLoadData} defining the data being loaded.
|
||||
*/
|
||||
void onLoadCompleted(
|
||||
default void onLoadCompleted(
|
||||
int windowIndex,
|
||||
@Nullable MediaPeriodId mediaPeriodId,
|
||||
LoadEventInfo loadEventInfo,
|
||||
MediaLoadData mediaLoadData);
|
||||
MediaLoadData mediaLoadData) {}
|
||||
|
||||
/**
|
||||
* Called when a load is canceled.
|
||||
@ -221,11 +221,11 @@ public interface MediaSourceEventListener {
|
||||
* event.
|
||||
* @param mediaLoadData The {@link MediaLoadData} defining the data being loaded.
|
||||
*/
|
||||
void onLoadCanceled(
|
||||
default void onLoadCanceled(
|
||||
int windowIndex,
|
||||
@Nullable MediaPeriodId mediaPeriodId,
|
||||
LoadEventInfo loadEventInfo,
|
||||
MediaLoadData mediaLoadData);
|
||||
MediaLoadData mediaLoadData) {}
|
||||
|
||||
/**
|
||||
* Called when a load error occurs.
|
||||
@ -252,13 +252,13 @@ public interface MediaSourceEventListener {
|
||||
* @param error The load error.
|
||||
* @param wasCanceled Whether the load was canceled as a result of the error.
|
||||
*/
|
||||
void onLoadError(
|
||||
default void onLoadError(
|
||||
int windowIndex,
|
||||
@Nullable MediaPeriodId mediaPeriodId,
|
||||
LoadEventInfo loadEventInfo,
|
||||
MediaLoadData mediaLoadData,
|
||||
IOException error,
|
||||
boolean wasCanceled);
|
||||
boolean wasCanceled) {}
|
||||
|
||||
/**
|
||||
* Called when a media period is first being read from.
|
||||
@ -266,7 +266,7 @@ public interface MediaSourceEventListener {
|
||||
* @param windowIndex The window index in the timeline this media period belongs to.
|
||||
* @param mediaPeriodId The {@link MediaPeriodId} of the media period being read from.
|
||||
*/
|
||||
void onReadingStarted(int windowIndex, MediaPeriodId mediaPeriodId);
|
||||
default void onReadingStarted(int windowIndex, MediaPeriodId mediaPeriodId) {}
|
||||
|
||||
/**
|
||||
* Called when data is removed from the back of a media buffer, typically so that it can be
|
||||
@ -276,8 +276,8 @@ public interface MediaSourceEventListener {
|
||||
* @param mediaPeriodId The {@link MediaPeriodId} the media belongs to.
|
||||
* @param mediaLoadData The {@link MediaLoadData} defining the media being discarded.
|
||||
*/
|
||||
void onUpstreamDiscarded(
|
||||
int windowIndex, MediaPeriodId mediaPeriodId, MediaLoadData mediaLoadData);
|
||||
default void onUpstreamDiscarded(
|
||||
int windowIndex, MediaPeriodId mediaPeriodId, MediaLoadData mediaLoadData) {}
|
||||
|
||||
/**
|
||||
* Called when a downstream format change occurs (i.e. when the format of the media being read
|
||||
@ -287,8 +287,8 @@ public interface MediaSourceEventListener {
|
||||
* @param mediaPeriodId The {@link MediaPeriodId} the media belongs to.
|
||||
* @param mediaLoadData The {@link MediaLoadData} defining the newly selected downstream data.
|
||||
*/
|
||||
void onDownstreamFormatChanged(
|
||||
int windowIndex, @Nullable MediaPeriodId mediaPeriodId, MediaLoadData mediaLoadData);
|
||||
default void onDownstreamFormatChanged(
|
||||
int windowIndex, @Nullable MediaPeriodId mediaPeriodId, MediaLoadData mediaLoadData) {}
|
||||
|
||||
/** Dispatches events to {@link MediaSourceEventListener}s. */
|
||||
final class EventDispatcher {
|
||||
|
@ -347,7 +347,7 @@ public final class SingleSampleMediaSource extends BaseMediaSource {
|
||||
*/
|
||||
@Deprecated
|
||||
@SuppressWarnings("deprecation")
|
||||
private static final class EventListenerWrapper extends DefaultMediaSourceEventListener {
|
||||
private static final class EventListenerWrapper implements MediaSourceEventListener {
|
||||
|
||||
private final EventListener eventListener;
|
||||
private final int eventSourceId;
|
||||
|
@ -555,7 +555,7 @@ public final class ClippingMediaSourceTest {
|
||||
() ->
|
||||
clippingMediaSource.addEventListener(
|
||||
new Handler(),
|
||||
new DefaultMediaSourceEventListener() {
|
||||
new MediaSourceEventListener() {
|
||||
@Override
|
||||
public void onDownstreamFormatChanged(
|
||||
int windowIndex,
|
||||
|
Loading…
x
Reference in New Issue
Block a user