Rename Listener for timeline update to avoid confusion with MediaSourceEventListener.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=187313128
This commit is contained in:
tonihei 2018-02-28 05:46:18 -08:00 committed by Andrew Lewis
parent fcb796a80c
commit 75c3bfb55c
8 changed files with 35 additions and 30 deletions

View File

@ -38,7 +38,7 @@ public final class ImaAdsMediaSource extends BaseMediaSource {
private final AdsMediaSource adsMediaSource; private final AdsMediaSource adsMediaSource;
private Listener adsMediaSourceListener; private SourceInfoRefreshListener adsMediaSourceListener;
/** /**
* Constructs a new source that inserts ads linearly with the content specified by * Constructs a new source that inserts ads linearly with the content specified by
@ -79,7 +79,7 @@ public final class ImaAdsMediaSource extends BaseMediaSource {
@Override @Override
public void prepareSourceInternal(final ExoPlayer player, boolean isTopLevelSource) { public void prepareSourceInternal(final ExoPlayer player, boolean isTopLevelSource) {
adsMediaSourceListener = adsMediaSourceListener =
new Listener() { new SourceInfoRefreshListener() {
@Override @Override
public void onSourceInfoRefreshed( public void onSourceInfoRefreshed(
MediaSource source, Timeline timeline, @Nullable Object manifest) { MediaSource source, Timeline timeline, @Nullable Object manifest) {

View File

@ -48,7 +48,7 @@ import java.util.Collections;
implements Handler.Callback, implements Handler.Callback,
MediaPeriod.Callback, MediaPeriod.Callback,
TrackSelector.InvalidationListener, TrackSelector.InvalidationListener,
MediaSource.Listener, MediaSource.SourceInfoRefreshListener,
PlaybackParameterListener, PlaybackParameterListener,
PlayerMessage.Sender { PlayerMessage.Sender {
@ -243,7 +243,7 @@ import java.util.Collections;
return internalPlaybackThread.getLooper(); return internalPlaybackThread.getLooper();
} }
// MediaSource.Listener implementation. // MediaSource.SourceInfoRefreshListener implementation.
@Override @Override
public void onSourceInfoRefreshed(MediaSource source, Timeline timeline, Object manifest) { public void onSourceInfoRefreshed(MediaSource source, Timeline timeline, Object manifest) {

View File

@ -29,7 +29,7 @@ import java.util.ArrayList;
*/ */
public abstract class BaseMediaSource implements MediaSource { public abstract class BaseMediaSource implements MediaSource {
private final ArrayList<Listener> sourceInfoListeners; private final ArrayList<SourceInfoRefreshListener> sourceInfoListeners;
private ExoPlayer player; private ExoPlayer player;
private Timeline timeline; private Timeline timeline;
@ -65,13 +65,14 @@ public abstract class BaseMediaSource implements MediaSource {
protected final void refreshSourceInfo(Timeline timeline, @Nullable Object manifest) { protected final void refreshSourceInfo(Timeline timeline, @Nullable Object manifest) {
this.timeline = timeline; this.timeline = timeline;
this.manifest = manifest; this.manifest = manifest;
for (Listener listener : sourceInfoListeners) { for (SourceInfoRefreshListener listener : sourceInfoListeners) {
listener.onSourceInfoRefreshed(/* source= */ this, timeline, manifest); listener.onSourceInfoRefreshed(/* source= */ this, timeline, manifest);
} }
} }
@Override @Override
public final void prepareSource(ExoPlayer player, boolean isTopLevelSource, Listener listener) { public final void prepareSource(
ExoPlayer player, boolean isTopLevelSource, SourceInfoRefreshListener listener) {
Assertions.checkArgument(this.player == null || this.player == player); Assertions.checkArgument(this.player == null || this.player == player);
sourceInfoListeners.add(listener); sourceInfoListeners.add(listener);
if (this.player == null) { if (this.player == null) {
@ -83,7 +84,7 @@ public abstract class BaseMediaSource implements MediaSource {
} }
@Override @Override
public final void releaseSource(Listener listener) { public final void releaseSource(SourceInfoRefreshListener listener) {
sourceInfoListeners.remove(listener); sourceInfoListeners.remove(listener);
if (sourceInfoListeners.isEmpty()) { if (sourceInfoListeners.isEmpty()) {
player = null; player = null;

View File

@ -88,8 +88,8 @@ public abstract class CompositeMediaSource<T> extends BaseMediaSource {
*/ */
protected final void prepareChildSource(@Nullable final T id, MediaSource mediaSource) { protected final void prepareChildSource(@Nullable final T id, MediaSource mediaSource) {
Assertions.checkArgument(!childSources.containsKey(id)); Assertions.checkArgument(!childSources.containsKey(id));
Listener sourceListener = SourceInfoRefreshListener sourceListener =
new Listener() { new SourceInfoRefreshListener() {
@Override @Override
public void onSourceInfoRefreshed( public void onSourceInfoRefreshed(
MediaSource source, Timeline timeline, @Nullable Object manifest) { MediaSource source, Timeline timeline, @Nullable Object manifest) {
@ -113,9 +113,9 @@ public abstract class CompositeMediaSource<T> extends BaseMediaSource {
private static final class MediaSourceAndListener { private static final class MediaSourceAndListener {
public final MediaSource mediaSource; public final MediaSource mediaSource;
public final Listener listener; public final SourceInfoRefreshListener listener;
public MediaSourceAndListener(MediaSource mediaSource, Listener listener) { public MediaSourceAndListener(MediaSource mediaSource, SourceInfoRefreshListener listener) {
this.mediaSource = mediaSource; this.mediaSource = mediaSource;
this.listener = listener; this.listener = listener;
} }

View File

@ -53,8 +53,9 @@ public interface MediaPeriod extends SequenceableLoader {
* {@link #maybeThrowPrepareError()} will throw an {@link IOException}. * {@link #maybeThrowPrepareError()} will throw an {@link IOException}.
* *
* <p>If preparation succeeds and results in a source timeline change (e.g. the period duration * <p>If preparation succeeds and results in a source timeline change (e.g. the period duration
* becoming known), {@link MediaSource.Listener#onSourceInfoRefreshed(MediaSource, Timeline, * becoming known), {@link
* Object)} will be called before {@code callback.onPrepared}. * MediaSource.SourceInfoRefreshListener#onSourceInfoRefreshed(MediaSource, Timeline, Object)}
* will be called before {@code callback.onPrepared}.
* *
* @param callback Callback to receive updates from this period, including being notified when * @param callback Callback to receive updates from this period, including being notified when
* preparation completes. * preparation completes.

View File

@ -29,8 +29,9 @@ import java.io.IOException;
* <ul> * <ul>
* <li>To provide the player with a {@link Timeline} defining the structure of its media, and to * <li>To provide the player with a {@link Timeline} defining the structure of its media, and to
* provide a new timeline whenever the structure of the media changes. The MediaSource * provide a new timeline whenever the structure of the media changes. The MediaSource
* provides these timelines by calling {@link Listener#onSourceInfoRefreshed} on the {@link * provides these timelines by calling {@link SourceInfoRefreshListener#onSourceInfoRefreshed}
* Listener}s passed to {@link #prepareSource(ExoPlayer, boolean, Listener)}. * on the {@link SourceInfoRefreshListener}s passed to {@link #prepareSource(ExoPlayer,
* boolean, SourceInfoRefreshListener)}.
* <li>To provide {@link MediaPeriod} instances for the periods in its timeline. MediaPeriods are * <li>To provide {@link MediaPeriod} instances for the periods in its timeline. MediaPeriods are
* obtained by calling {@link #createPeriod(MediaPeriodId, Allocator)}, and provide a way for * obtained by calling {@link #createPeriod(MediaPeriodId, Allocator)}, and provide a way for
* the player to load and read the media. * the player to load and read the media.
@ -42,10 +43,8 @@ import java.io.IOException;
*/ */
public interface MediaSource { public interface MediaSource {
/** /** Listener for source events. */
* Listener for source events. interface SourceInfoRefreshListener {
*/
interface Listener {
/** /**
* Called when manifest and/or timeline has been refreshed. * Called when manifest and/or timeline has been refreshed.
@ -180,17 +179,18 @@ public interface MediaSource {
* *
* <p>The listener will be also be notified if the source already has a timeline and/or manifest. * <p>The listener will be also be notified if the source already has a timeline and/or manifest.
* *
* <p>For each call to this method, a call to {@link #releaseSource(Listener)} is needed to remove * <p>For each call to this method, a call to {@link #releaseSource(SourceInfoRefreshListener)} is
* the listener and to release the source if no longer required. * needed to remove the listener and to release the source if no longer required.
* *
* @param player The player for which this source is being prepared. * @param player The player for which this source is being prepared.
* @param isTopLevelSource Whether this source has been passed directly to {@link * @param isTopLevelSource Whether this source has been passed directly to {@link
* ExoPlayer#prepare(MediaSource)} or {@link ExoPlayer#prepare(MediaSource, boolean, * ExoPlayer#prepare(MediaSource)} or {@link ExoPlayer#prepare(MediaSource, boolean,
* boolean)}. If {@code false}, this source is being prepared by another source (e.g. {@link * boolean)}. If {@code false}, this source is being prepared by another source (e.g. {@link
* ConcatenatingMediaSource}) for composition. * ConcatenatingMediaSource}) for composition.
* @param listener The listener for source info updates to be added. * @param listener The listener to be added.
*/ */
void prepareSource(ExoPlayer player, boolean isTopLevelSource, Listener listener); void prepareSource(
ExoPlayer player, boolean isTopLevelSource, SourceInfoRefreshListener listener);
/** /**
* Throws any pending error encountered while loading or refreshing source information. * Throws any pending error encountered while loading or refreshing source information.
@ -227,7 +227,7 @@ public interface MediaSource {
* *
* <p>Should not be called directly from application code. * <p>Should not be called directly from application code.
* *
* @param listener The listener for source info updates to be removed. * @param listener The listener to be removed.
*/ */
void releaseSource(Listener listener); void releaseSource(SourceInfoRefreshListener listener);
} }

View File

@ -256,8 +256,8 @@ public final class DashMediaSource extends BaseMediaSource {
public static final long DEFAULT_LIVE_PRESENTATION_DELAY_FIXED_MS = 30000; public static final long DEFAULT_LIVE_PRESENTATION_DELAY_FIXED_MS = 30000;
/** /**
* The interval in milliseconds between invocations of * The interval in milliseconds between invocations of {@link
* {@link MediaSource.Listener#onSourceInfoRefreshed(MediaSource, Timeline, Object)} when the * SourceInfoRefreshListener#onSourceInfoRefreshed(MediaSource, Timeline, Object)} when the
* source's {@link Timeline} is changing dynamically (for example, for incomplete live streams). * source's {@link Timeline} is changing dynamically (for example, for incomplete live streams).
*/ */
private static final int NOTIFY_MANIFEST_INTERVAL_MS = 5000; private static final int NOTIFY_MANIFEST_INTERVAL_MS = 5000;

View File

@ -193,7 +193,10 @@ public class MediaSourceTestRunner {
}); });
} }
/** Calls {@link MediaSource#releaseSource(Listener)} on the playback thread. */ /**
* Calls {@link MediaSource#releaseSource(MediaSource.SourceInfoRefreshListener)} on the playback
* thread.
*/
public void releaseSource() { public void releaseSource() {
runOnPlaybackThread( runOnPlaybackThread(
new Runnable() { new Runnable() {
@ -282,7 +285,7 @@ public class MediaSourceTestRunner {
playbackThread.quit(); playbackThread.quit();
} }
private class MediaSourceListener implements MediaSource.Listener { private class MediaSourceListener implements MediaSource.SourceInfoRefreshListener {
@Override @Override
public void onSourceInfoRefreshed(MediaSource source, Timeline timeline, Object manifest) { public void onSourceInfoRefreshed(MediaSource source, Timeline timeline, Object manifest) {