Skip to content

Commit

Permalink
Rename Listener for timeline update to avoid confusion with MediaSour…
Browse files Browse the repository at this point in the history
…ceEventListener.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=187313128
  • Loading branch information
tonihei authored and andrewlewis committed Mar 2, 2018
1 parent fcb796a commit 75c3bfb
Show file tree
Hide file tree
Showing 8 changed files with 35 additions and 30 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ public final class ImaAdsMediaSource extends BaseMediaSource {

private final AdsMediaSource adsMediaSource;

private Listener adsMediaSourceListener;
private SourceInfoRefreshListener adsMediaSourceListener;

/**
* Constructs a new source that inserts ads linearly with the content specified by
Expand Down Expand Up @@ -79,7 +79,7 @@ public ImaAdsMediaSource(
@Override
public void prepareSourceInternal(final ExoPlayer player, boolean isTopLevelSource) {
adsMediaSourceListener =
new Listener() {
new SourceInfoRefreshListener() {
@Override
public void onSourceInfoRefreshed(
MediaSource source, Timeline timeline, @Nullable Object manifest) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@
implements Handler.Callback,
MediaPeriod.Callback,
TrackSelector.InvalidationListener,
MediaSource.Listener,
MediaSource.SourceInfoRefreshListener,
PlaybackParameterListener,
PlayerMessage.Sender {

Expand Down Expand Up @@ -243,7 +243,7 @@ public Looper getPlaybackLooper() {
return internalPlaybackThread.getLooper();
}

// MediaSource.Listener implementation.
// MediaSource.SourceInfoRefreshListener implementation.

@Override
public void onSourceInfoRefreshed(MediaSource source, Timeline timeline, Object manifest) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
*/
public abstract class BaseMediaSource implements MediaSource {

private final ArrayList<Listener> sourceInfoListeners;
private final ArrayList<SourceInfoRefreshListener> sourceInfoListeners;

private ExoPlayer player;
private Timeline timeline;
Expand Down Expand Up @@ -65,13 +65,14 @@ public BaseMediaSource() {
protected final void refreshSourceInfo(Timeline timeline, @Nullable Object manifest) {
this.timeline = timeline;
this.manifest = manifest;
for (Listener listener : sourceInfoListeners) {
for (SourceInfoRefreshListener listener : sourceInfoListeners) {
listener.onSourceInfoRefreshed(/* source= */ this, timeline, manifest);
}
}

@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);
sourceInfoListeners.add(listener);
if (this.player == null) {
Expand All @@ -83,7 +84,7 @@ public final void prepareSource(ExoPlayer player, boolean isTopLevelSource, List
}

@Override
public final void releaseSource(Listener listener) {
public final void releaseSource(SourceInfoRefreshListener listener) {
sourceInfoListeners.remove(listener);
if (sourceInfoListeners.isEmpty()) {
player = null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,8 +88,8 @@ protected abstract void onChildSourceInfoRefreshed(
*/
protected final void prepareChildSource(@Nullable final T id, MediaSource mediaSource) {
Assertions.checkArgument(!childSources.containsKey(id));
Listener sourceListener =
new Listener() {
SourceInfoRefreshListener sourceListener =
new SourceInfoRefreshListener() {
@Override
public void onSourceInfoRefreshed(
MediaSource source, Timeline timeline, @Nullable Object manifest) {
Expand All @@ -113,9 +113,9 @@ protected final void releaseChildSource(@Nullable T id) {
private static final class MediaSourceAndListener {

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.listener = listener;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,9 @@ interface Callback extends SequenceableLoader.Callback<MediaPeriod> {
* {@link #maybeThrowPrepareError()} will throw an {@link IOException}.
*
* <p>If preparation succeeds and results in a source timeline change (e.g. the period duration
* becoming known), {@link MediaSource.Listener#onSourceInfoRefreshed(MediaSource, Timeline,
* Object)} will be called before {@code callback.onPrepared}.
* becoming known), {@link
* 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
* preparation completes.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,9 @@
* <ul>
* <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
* provides these timelines by calling {@link Listener#onSourceInfoRefreshed} on the {@link
* Listener}s passed to {@link #prepareSource(ExoPlayer, boolean, Listener)}.
* provides these timelines by calling {@link SourceInfoRefreshListener#onSourceInfoRefreshed}
* 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
* obtained by calling {@link #createPeriod(MediaPeriodId, Allocator)}, and provide a way for
* the player to load and read the media.
Expand All @@ -42,10 +43,8 @@
*/
public interface MediaSource {

/**
* Listener for source events.
*/
interface Listener {
/** Listener for source events. */
interface SourceInfoRefreshListener {

/**
* Called when manifest and/or timeline has been refreshed.
Expand Down Expand Up @@ -180,17 +179,18 @@ public int hashCode() {
*
* <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
* the listener and to release the source if no longer required.
* <p>For each call to this method, a call to {@link #releaseSource(SourceInfoRefreshListener)} is
* 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 isTopLevelSource Whether this source has been passed directly to {@link
* ExoPlayer#prepare(MediaSource)} or {@link ExoPlayer#prepare(MediaSource, boolean,
* boolean)}. If {@code false}, this source is being prepared by another source (e.g. {@link
* 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.
Expand Down Expand Up @@ -227,7 +227,7 @@ public int hashCode() {
*
* <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);
}
Original file line number Diff line number Diff line change
Expand Up @@ -256,8 +256,8 @@ public int[] getSupportedTypes() {
public static final long DEFAULT_LIVE_PRESENTATION_DELAY_FIXED_MS = 30000;

/**
* The interval in milliseconds between invocations of
* {@link MediaSource.Listener#onSourceInfoRefreshed(MediaSource, Timeline, Object)} when the
* The interval in milliseconds between invocations of {@link
* SourceInfoRefreshListener#onSourceInfoRefreshed(MediaSource, Timeline, Object)} when the
* source's {@link Timeline} is changing dynamically (for example, for incomplete live streams).
*/
private static final int NOTIFY_MANIFEST_INTERVAL_MS = 5000;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,10 @@ public void run() {
});
}

/** Calls {@link MediaSource#releaseSource(Listener)} on the playback thread. */
/**
* Calls {@link MediaSource#releaseSource(MediaSource.SourceInfoRefreshListener)} on the playback
* thread.
*/
public void releaseSource() {
runOnPlaybackThread(
new Runnable() {
Expand Down Expand Up @@ -282,7 +285,7 @@ public void release() {
playbackThread.quit();
}

private class MediaSourceListener implements MediaSource.Listener {
private class MediaSourceListener implements MediaSource.SourceInfoRefreshListener {

@Override
public void onSourceInfoRefreshed(MediaSource source, Timeline timeline, Object manifest) {
Expand Down

0 comments on commit 75c3bfb

Please sign in to comment.