mirror of
https://github.com/androidx/media.git
synced 2025-04-30 06:46:50 +08:00
Remove backwards-compat onLoadStarted from MediaSourceEventListener
This commit is contained in:
parent
5581529bfb
commit
e7f5d4d441
@ -559,23 +559,6 @@ import java.util.Set;
|
||||
|
||||
// MediaSourceEventListener implementation
|
||||
|
||||
@Override
|
||||
public void onLoadStarted(
|
||||
int windowIndex,
|
||||
@Nullable MediaSource.MediaPeriodId mediaPeriodId,
|
||||
LoadEventInfo loadEventData,
|
||||
MediaLoadData mediaLoadData) {
|
||||
@Nullable
|
||||
Pair<Integer, MediaSource.@NullableType MediaPeriodId> eventParameters =
|
||||
getEventParameters(windowIndex, mediaPeriodId);
|
||||
if (eventParameters != null) {
|
||||
eventHandler.post(
|
||||
() ->
|
||||
eventListener.onLoadStarted(
|
||||
eventParameters.first, eventParameters.second, loadEventData, mediaLoadData));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onLoadStarted(
|
||||
int windowIndex,
|
||||
|
@ -397,19 +397,6 @@ public class DefaultAnalyticsCollector implements AnalyticsCollector {
|
||||
|
||||
// MediaSourceEventListener implementation.
|
||||
|
||||
@Override
|
||||
public final void onLoadStarted(
|
||||
int windowIndex,
|
||||
@Nullable MediaPeriodId mediaPeriodId,
|
||||
LoadEventInfo loadEventInfo,
|
||||
MediaLoadData mediaLoadData) {
|
||||
EventTime eventTime = generateMediaPeriodEventTime(windowIndex, mediaPeriodId);
|
||||
sendEvent(
|
||||
eventTime,
|
||||
C.INDEX_UNSET,
|
||||
listener -> listener.onLoadStarted(eventTime, loadEventInfo, mediaLoadData));
|
||||
}
|
||||
|
||||
@Override
|
||||
public final void onLoadStarted(
|
||||
int windowIndex,
|
||||
|
@ -234,18 +234,6 @@ public abstract class CompositeMediaSource<T> extends BaseMediaSource {
|
||||
|
||||
// MediaSourceEventListener implementation
|
||||
|
||||
@Override
|
||||
public void onLoadStarted(
|
||||
int windowIndex,
|
||||
@Nullable MediaPeriodId mediaPeriodId,
|
||||
LoadEventInfo loadEventData,
|
||||
MediaLoadData mediaLoadData) {
|
||||
if (maybeUpdateEventDispatcher(windowIndex, mediaPeriodId)) {
|
||||
mediaSourceEventDispatcher.loadStarted(
|
||||
loadEventData, maybeUpdateMediaLoadData(mediaLoadData, mediaPeriodId));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onLoadStarted(
|
||||
int windowIndex,
|
||||
|
@ -46,25 +46,7 @@ public interface MediaSourceEventListener {
|
||||
* LoadEventInfo#uri} won't reflect potential redirection yet and {@link
|
||||
* LoadEventInfo#responseHeaders} will be empty.
|
||||
* @param mediaLoadData The {@link MediaLoadData} defining the data being loaded.
|
||||
*/
|
||||
@Deprecated
|
||||
default void onLoadStarted(
|
||||
int windowIndex,
|
||||
@Nullable MediaPeriodId mediaPeriodId,
|
||||
LoadEventInfo loadEventInfo,
|
||||
MediaLoadData mediaLoadData) {}
|
||||
|
||||
/**
|
||||
* Called when a load begins.
|
||||
*
|
||||
* @param windowIndex The window index in the timeline of the media source this load belongs to.
|
||||
* @param mediaPeriodId The {@link MediaPeriodId} this load belongs to. Null if the load does not
|
||||
* belong to a specific media period.
|
||||
* @param loadEventInfo The {@link LoadEventInfo} corresponding to the event. The value of {@link
|
||||
* LoadEventInfo#uri} won't reflect potential redirection yet and {@link
|
||||
* LoadEventInfo#responseHeaders} will be empty.
|
||||
* @param mediaLoadData The {@link MediaLoadData} defining the data being loaded.
|
||||
* @param retryCount The number of failed attempts since {@link #onLoadStarted} was called (this
|
||||
* @param retryCount The number of failed attempts since this method was first called (this
|
||||
* is zero for the first load attempt).
|
||||
*/
|
||||
default void onLoadStarted(
|
||||
@ -82,7 +64,7 @@ public interface MediaSourceEventListener {
|
||||
* belong to a specific media period.
|
||||
* @param loadEventInfo The {@link LoadEventInfo} corresponding to the event. The values of {@link
|
||||
* LoadEventInfo#elapsedRealtimeMs} and {@link LoadEventInfo#bytesLoaded} are relative to the
|
||||
* corresponding {@link #onLoadStarted(int, MediaPeriodId, LoadEventInfo, MediaLoadData)}
|
||||
* corresponding {@link #onLoadStarted}
|
||||
* event.
|
||||
* @param mediaLoadData The {@link MediaLoadData} defining the data being loaded.
|
||||
*/
|
||||
@ -100,7 +82,7 @@ public interface MediaSourceEventListener {
|
||||
* belong to a specific media period.
|
||||
* @param loadEventInfo The {@link LoadEventInfo} corresponding to the event. The values of {@link
|
||||
* LoadEventInfo#elapsedRealtimeMs} and {@link LoadEventInfo#bytesLoaded} are relative to the
|
||||
* corresponding {@link #onLoadStarted(int, MediaPeriodId, LoadEventInfo, MediaLoadData)}
|
||||
* corresponding {@link #onLoadStarted}
|
||||
* event.
|
||||
* @param mediaLoadData The {@link MediaLoadData} defining the data being loaded.
|
||||
*/
|
||||
@ -129,7 +111,7 @@ public interface MediaSourceEventListener {
|
||||
* belong to a specific media period.
|
||||
* @param loadEventInfo The {@link LoadEventInfo} corresponding to the event. The values of {@link
|
||||
* LoadEventInfo#elapsedRealtimeMs} and {@link LoadEventInfo#bytesLoaded} are relative to the
|
||||
* corresponding {@link #onLoadStarted(int, MediaPeriodId, LoadEventInfo, MediaLoadData)}
|
||||
* corresponding {@link #onLoadStarted}
|
||||
* event.
|
||||
* @param mediaLoadData The {@link MediaLoadData} defining the data being loaded.
|
||||
* @param error The load error.
|
||||
@ -244,20 +226,6 @@ public interface MediaSourceEventListener {
|
||||
}
|
||||
}
|
||||
|
||||
/** Dispatches {@link #onLoadStarted(int, MediaPeriodId, LoadEventInfo, MediaLoadData)}. */
|
||||
@Deprecated
|
||||
public void loadStarted(LoadEventInfo loadEventInfo, @DataType int dataType) {
|
||||
loadStarted(
|
||||
loadEventInfo,
|
||||
dataType,
|
||||
/* trackType= */ C.TRACK_TYPE_UNKNOWN,
|
||||
/* trackFormat= */ null,
|
||||
/* trackSelectionReason= */ C.SELECTION_REASON_UNKNOWN,
|
||||
/* trackSelectionData= */ null,
|
||||
/* mediaStartTimeUs= */ C.TIME_UNSET,
|
||||
/* mediaEndTimeUs= */ C.TIME_UNSET);
|
||||
}
|
||||
|
||||
/** Dispatches {@link #onLoadStarted(int, MediaPeriodId, LoadEventInfo, MediaLoadData, int)}. */
|
||||
public void loadStarted(LoadEventInfo loadEventInfo, @DataType int dataType, int retryCount) {
|
||||
loadStarted(
|
||||
@ -272,29 +240,6 @@ public interface MediaSourceEventListener {
|
||||
/* retryCount= */ retryCount);
|
||||
}
|
||||
|
||||
/** Dispatches {@link #onLoadStarted(int, MediaPeriodId, LoadEventInfo, MediaLoadData)}. */
|
||||
@Deprecated
|
||||
public void loadStarted(
|
||||
LoadEventInfo loadEventInfo,
|
||||
@DataType int dataType,
|
||||
@C.TrackType int trackType,
|
||||
@Nullable Format trackFormat,
|
||||
@C.SelectionReason int trackSelectionReason,
|
||||
@Nullable Object trackSelectionData,
|
||||
long mediaStartTimeUs,
|
||||
long mediaEndTimeUs) {
|
||||
loadStarted(
|
||||
loadEventInfo,
|
||||
new MediaLoadData(
|
||||
dataType,
|
||||
trackType,
|
||||
trackFormat,
|
||||
trackSelectionReason,
|
||||
trackSelectionData,
|
||||
usToMs(mediaStartTimeUs),
|
||||
usToMs(mediaEndTimeUs)));
|
||||
}
|
||||
|
||||
/** Dispatches {@link #onLoadStarted(int, MediaPeriodId, LoadEventInfo, MediaLoadData, int)}. */
|
||||
public void loadStarted(
|
||||
LoadEventInfo loadEventInfo,
|
||||
@ -319,15 +264,6 @@ public interface MediaSourceEventListener {
|
||||
retryCount);
|
||||
}
|
||||
|
||||
/** Dispatches {@link #onLoadStarted(int, MediaPeriodId, LoadEventInfo, MediaLoadData)}. */
|
||||
@Deprecated
|
||||
public void loadStarted(LoadEventInfo loadEventInfo, MediaLoadData mediaLoadData) {
|
||||
dispatchEvent(
|
||||
(listener) ->
|
||||
listener.onLoadStarted(
|
||||
windowIndex, mediaPeriodId, loadEventInfo, mediaLoadData));
|
||||
}
|
||||
|
||||
/** Dispatches {@link #onLoadStarted(int, MediaPeriodId, LoadEventInfo, MediaLoadData, int)}. */
|
||||
public void loadStarted(
|
||||
LoadEventInfo loadEventInfo,
|
||||
|
@ -920,7 +920,7 @@ import org.checkerframework.checker.nullness.qual.MonotonicNonNull;
|
||||
C.SELECTION_REASON_UNKNOWN,
|
||||
/* trackSelectionData= */ null,
|
||||
/* mediaStartTimeUs= */ loadable.seekTimeUs,
|
||||
durationUs);
|
||||
durationUs, /* retryCount= */ 0);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -168,7 +168,7 @@ import org.checkerframework.checker.nullness.qual.MonotonicNonNull;
|
||||
C.SELECTION_REASON_UNKNOWN,
|
||||
/* trackSelectionData= */ null,
|
||||
/* mediaStartTimeUs= */ 0,
|
||||
durationUs);
|
||||
durationUs, /* retryCount= */ 0);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -427,12 +427,14 @@ public final class ServerSideAdInsertionMediaSource extends BaseMediaSource
|
||||
int windowIndex,
|
||||
@Nullable MediaPeriodId mediaPeriodId,
|
||||
LoadEventInfo loadEventInfo,
|
||||
MediaLoadData mediaLoadData) {
|
||||
MediaLoadData mediaLoadData, int retryCount) {
|
||||
// TODO file a bug to track updating this.
|
||||
if (retryCount == 0) {
|
||||
@Nullable
|
||||
MediaPeriodImpl mediaPeriod =
|
||||
getMediaPeriodForEvent(mediaPeriodId, mediaLoadData, /* useLoadingPeriod= */ true);
|
||||
if (mediaPeriod == null) {
|
||||
mediaSourceEventDispatcherWithoutId.loadStarted(loadEventInfo, mediaLoadData);
|
||||
mediaSourceEventDispatcherWithoutId.loadStarted(loadEventInfo, mediaLoadData, /* retryCount= */ 0);
|
||||
} else {
|
||||
mediaPeriod.sharedPeriod.onLoadStarted(loadEventInfo, mediaLoadData);
|
||||
mediaPeriod.mediaSourceEventDispatcher.loadStarted(
|
||||
@ -440,7 +442,9 @@ public final class ServerSideAdInsertionMediaSource extends BaseMediaSource
|
||||
correctMediaLoadData(
|
||||
mediaPeriod,
|
||||
mediaLoadData,
|
||||
checkNotNull(adPlaybackStates.get(mediaPeriod.mediaPeriodId.periodUid))));
|
||||
checkNotNull(adPlaybackStates.get(mediaPeriod.mediaPeriodId.periodUid))), /* retryCount= */ 0);
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -750,7 +754,7 @@ public final class ServerSideAdInsertionMediaSource extends BaseMediaSource
|
||||
loadData.first,
|
||||
correctMediaLoadData(loadingPeriod, loadData.second, adPlaybackState));
|
||||
mediaPeriod.mediaSourceEventDispatcher.loadStarted(
|
||||
loadData.first, correctMediaLoadData(mediaPeriod, loadData.second, adPlaybackState));
|
||||
loadData.first, correctMediaLoadData(mediaPeriod, loadData.second, adPlaybackState), /* retryCount= */ 0);
|
||||
}
|
||||
}
|
||||
this.loadingPeriod = mediaPeriod;
|
||||
|
@ -663,7 +663,7 @@ public class ChunkSampleStream<T extends ChunkSource>
|
||||
loadable.trackSelectionReason,
|
||||
loadable.trackSelectionData,
|
||||
loadable.startTimeUs,
|
||||
loadable.endTimeUs);
|
||||
loadable.endTimeUs, /* retryCount= */ 0);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -1106,7 +1106,7 @@ public final class DashMediaSource extends BaseMediaSource {
|
||||
long elapsedRealtimeMs = loader.startLoading(loadable, callback, minRetryCount);
|
||||
manifestEventDispatcher.loadStarted(
|
||||
new LoadEventInfo(loadable.loadTaskId, loadable.dataSpec, elapsedRealtimeMs),
|
||||
loadable.type);
|
||||
loadable.type, /* retryCount= */ 0);
|
||||
}
|
||||
|
||||
private static long getIntervalUntilNextManifestRefreshMs(
|
||||
|
@ -811,6 +811,7 @@ import org.checkerframework.checker.nullness.qual.RequiresNonNull;
|
||||
long elapsedRealtimeMs =
|
||||
loader.startLoading(
|
||||
loadable, this, loadErrorHandlingPolicy.getMinimumLoadableRetryCount(loadable.type));
|
||||
// DO NOT SUBMIT is this duplicated with the line in onLoadStarted below on L868?
|
||||
mediaSourceEventDispatcher.loadStarted(
|
||||
new LoadEventInfo(loadable.loadTaskId, loadable.dataSpec, elapsedRealtimeMs),
|
||||
loadable.type,
|
||||
@ -819,7 +820,7 @@ import org.checkerframework.checker.nullness.qual.RequiresNonNull;
|
||||
loadable.trackSelectionReason,
|
||||
loadable.trackSelectionData,
|
||||
loadable.startTimeUs,
|
||||
loadable.endTimeUs);
|
||||
loadable.endTimeUs, /* retryCount= */ 0);
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -872,7 +873,7 @@ import org.checkerframework.checker.nullness.qual.RequiresNonNull;
|
||||
loadable.trackSelectionReason,
|
||||
loadable.trackSelectionData,
|
||||
loadable.startTimeUs,
|
||||
loadable.endTimeUs);
|
||||
loadable.endTimeUs, retryCount);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -152,7 +152,7 @@ public final class DefaultHlsPlaylistTracker
|
||||
multivariantPlaylistLoadable.loadTaskId,
|
||||
multivariantPlaylistLoadable.dataSpec,
|
||||
elapsedRealtime),
|
||||
multivariantPlaylistLoadable.type);
|
||||
multivariantPlaylistLoadable.type, /* retryCount= */ 0);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -759,7 +759,7 @@ public final class DefaultHlsPlaylistTracker
|
||||
eventDispatcher.loadStarted(
|
||||
new LoadEventInfo(
|
||||
mediaPlaylistLoadable.loadTaskId, mediaPlaylistLoadable.dataSpec, elapsedRealtime),
|
||||
mediaPlaylistLoadable.type);
|
||||
mediaPlaylistLoadable.type, /* retryCount= */ 0);
|
||||
}
|
||||
|
||||
private void processLoadedPlaylist(
|
||||
|
@ -673,6 +673,6 @@ public final class SsMediaSource extends BaseMediaSource
|
||||
loadable, this, loadErrorHandlingPolicy.getMinimumLoadableRetryCount(loadable.type));
|
||||
manifestEventDispatcher.loadStarted(
|
||||
new LoadEventInfo(loadable.loadTaskId, loadable.dataSpec, elapsedRealtimeMs),
|
||||
loadable.type);
|
||||
loadable.type, /* retryCount= */ 0);
|
||||
}
|
||||
}
|
||||
|
@ -108,15 +108,6 @@ public class FakeAdaptiveMediaPeriod
|
||||
|
||||
@Override
|
||||
public void prepare(Callback callback, long positionUs) {
|
||||
mediaSourceEventDispatcher.loadStarted(
|
||||
new LoadEventInfo(fakePreparationLoadTaskId, FAKE_DATA_SPEC, SystemClock.elapsedRealtime()),
|
||||
C.DATA_TYPE_MEDIA,
|
||||
C.TRACK_TYPE_UNKNOWN,
|
||||
/* trackFormat= */ null,
|
||||
C.SELECTION_REASON_UNKNOWN,
|
||||
/* trackSelectionData= */ null,
|
||||
/* mediaStartTimeUs= */ 0,
|
||||
/* mediaEndTimeUs= */ C.TIME_UNSET);
|
||||
mediaSourceEventDispatcher.loadStarted(
|
||||
new LoadEventInfo(fakePreparationLoadTaskId, FAKE_DATA_SPEC, SystemClock.elapsedRealtime()),
|
||||
C.DATA_TYPE_MEDIA,
|
||||
|
@ -227,15 +227,6 @@ public class FakeMediaPeriod implements MediaPeriod {
|
||||
|
||||
@Override
|
||||
public synchronized void prepare(Callback callback, long positionUs) {
|
||||
mediaSourceEventDispatcher.loadStarted(
|
||||
new LoadEventInfo(fakePreparationLoadTaskId, FAKE_DATA_SPEC, SystemClock.elapsedRealtime()),
|
||||
C.DATA_TYPE_MEDIA,
|
||||
C.TRACK_TYPE_UNKNOWN,
|
||||
/* trackFormat= */ null,
|
||||
C.SELECTION_REASON_UNKNOWN,
|
||||
/* trackSelectionData= */ null,
|
||||
/* mediaStartTimeUs= */ 0,
|
||||
/* mediaEndTimeUs= */ C.TIME_UNSET);
|
||||
mediaSourceEventDispatcher.loadStarted(
|
||||
new LoadEventInfo(fakePreparationLoadTaskId, FAKE_DATA_SPEC, SystemClock.elapsedRealtime()),
|
||||
C.DATA_TYPE_MEDIA,
|
||||
|
@ -446,16 +446,6 @@ public class FakeMediaSource extends BaseMediaSource {
|
||||
MediaSourceEventListener.EventDispatcher eventDispatcher =
|
||||
createEventDispatcher(/* mediaPeriodId= */ null);
|
||||
long loadTaskId = LoadEventInfo.getNewId();
|
||||
eventDispatcher.loadStarted(
|
||||
new LoadEventInfo(
|
||||
loadTaskId,
|
||||
FAKE_DATA_SPEC,
|
||||
FAKE_DATA_SPEC.uri,
|
||||
/* responseHeaders= */ ImmutableMap.of(),
|
||||
elapsedRealTimeMs,
|
||||
/* loadDurationMs= */ 0,
|
||||
/* bytesLoaded= */ 0),
|
||||
mediaLoadData);
|
||||
eventDispatcher.loadStarted(
|
||||
new LoadEventInfo(
|
||||
loadTaskId,
|
||||
|
@ -359,15 +359,6 @@ public class MediaSourceTestRunner {
|
||||
|
||||
// MediaSourceEventListener methods.
|
||||
|
||||
@Override
|
||||
public void onLoadStarted(
|
||||
int windowIndex,
|
||||
@Nullable MediaPeriodId mediaPeriodId,
|
||||
LoadEventInfo loadEventInfo,
|
||||
MediaLoadData mediaLoadData) {
|
||||
Assertions.checkState(Looper.myLooper() == playbackThread.getLooper());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onLoadStarted(
|
||||
int windowIndex,
|
||||
|
Loading…
x
Reference in New Issue
Block a user