Commit 702568c3 by kimvde Committed by kim-vde

Remove some occurrences of dummy in core library

Remove occurrences in comments and private fields.

ISSUE: #7565
PiperOrigin-RevId: 320606558
parent a0703cb7
Showing with 109 additions and 108 deletions
...@@ -54,7 +54,7 @@ import com.google.android.exoplayer2.Player; ...@@ -54,7 +54,7 @@ import com.google.android.exoplayer2.Player;
import com.google.android.exoplayer2.Timeline; import com.google.android.exoplayer2.Timeline;
import com.google.android.exoplayer2.Timeline.Period; import com.google.android.exoplayer2.Timeline.Period;
import com.google.android.exoplayer2.ext.ima.ImaAdsLoader.ImaFactory; import com.google.android.exoplayer2.ext.ima.ImaAdsLoader.ImaFactory;
import com.google.android.exoplayer2.source.MaskingMediaSource.DummyTimeline; import com.google.android.exoplayer2.source.MaskingMediaSource.PlaceholderTimeline;
import com.google.android.exoplayer2.source.ads.AdPlaybackState; import com.google.android.exoplayer2.source.ads.AdPlaybackState;
import com.google.android.exoplayer2.source.ads.AdsLoader; import com.google.android.exoplayer2.source.ads.AdsLoader;
import com.google.android.exoplayer2.source.ads.AdsMediaSource.AdLoadException; import com.google.android.exoplayer2.source.ads.AdsMediaSource.AdLoadException;
...@@ -170,7 +170,7 @@ public final class ImaAdsLoaderTest { ...@@ -170,7 +170,7 @@ public final class ImaAdsLoaderTest {
@Test @Test
public void start_withPlaceholderContent_initializedAdsLoader() { public void start_withPlaceholderContent_initializedAdsLoader() {
Timeline placeholderTimeline = new DummyTimeline(MediaItem.fromUri(Uri.EMPTY)); Timeline placeholderTimeline = new PlaceholderTimeline(MediaItem.fromUri(Uri.EMPTY));
setupPlayback(placeholderTimeline, PREROLL_CUE_POINTS_SECONDS); setupPlayback(placeholderTimeline, PREROLL_CUE_POINTS_SECONDS);
imaAdsLoader.start(adsLoaderListener, adViewProvider); imaAdsLoader.start(adsLoaderListener, adViewProvider);
......
...@@ -983,7 +983,7 @@ import java.util.concurrent.atomic.AtomicBoolean; ...@@ -983,7 +983,7 @@ import java.util.concurrent.atomic.AtomicBoolean;
// The seek position was valid for the timeline that it was performed into, but the // The seek position was valid for the timeline that it was performed into, but the
// timeline has changed or is not ready and a suitable seek position could not be resolved. // timeline has changed or is not ready and a suitable seek position could not be resolved.
Pair<MediaPeriodId, Long> firstPeriodAndPosition = Pair<MediaPeriodId, Long> firstPeriodAndPosition =
getDummyFirstMediaPeriodPosition(playbackInfo.timeline); getPlaceholderFirstMediaPeriodPosition(playbackInfo.timeline);
periodId = firstPeriodAndPosition.first; periodId = firstPeriodAndPosition.first;
periodPositionUs = firstPeriodAndPosition.second; periodPositionUs = firstPeriodAndPosition.second;
requestedContentPosition = C.TIME_UNSET; requestedContentPosition = C.TIME_UNSET;
...@@ -1267,7 +1267,8 @@ import java.util.concurrent.atomic.AtomicBoolean; ...@@ -1267,7 +1267,8 @@ import java.util.concurrent.atomic.AtomicBoolean;
boolean resetTrackInfo = clearMediaSourceList; boolean resetTrackInfo = clearMediaSourceList;
if (resetPosition) { if (resetPosition) {
pendingInitialSeekPosition = null; pendingInitialSeekPosition = null;
Pair<MediaPeriodId, Long> firstPeriodAndPosition = getDummyFirstMediaPeriodPosition(timeline); Pair<MediaPeriodId, Long> firstPeriodAndPosition =
getPlaceholderFirstMediaPeriodPosition(timeline);
mediaPeriodId = firstPeriodAndPosition.first; mediaPeriodId = firstPeriodAndPosition.first;
startPositionUs = firstPeriodAndPosition.second; startPositionUs = firstPeriodAndPosition.second;
requestedContentPositionUs = C.TIME_UNSET; requestedContentPositionUs = C.TIME_UNSET;
...@@ -1300,7 +1301,7 @@ import java.util.concurrent.atomic.AtomicBoolean; ...@@ -1300,7 +1301,7 @@ import java.util.concurrent.atomic.AtomicBoolean;
} }
} }
private Pair<MediaPeriodId, Long> getDummyFirstMediaPeriodPosition(Timeline timeline) { private Pair<MediaPeriodId, Long> getPlaceholderFirstMediaPeriodPosition(Timeline timeline) {
if (timeline.isEmpty()) { if (timeline.isEmpty()) {
return Pair.create(PlaybackInfo.getDummyPeriodForEmptyTimeline(), 0L); return Pair.create(PlaybackInfo.getDummyPeriodForEmptyTimeline(), 0L);
} }
......
...@@ -380,7 +380,7 @@ import org.checkerframework.checker.nullness.compatqual.NullableType; ...@@ -380,7 +380,7 @@ import org.checkerframework.checker.nullness.compatqual.NullableType;
} }
/** /**
* For each renderer of type {@link C#TRACK_TYPE_NONE}, we will remove the dummy {@link * For each renderer of type {@link C#TRACK_TYPE_NONE}, we will remove the {@link
* EmptySampleStream} that was associated with it. * EmptySampleStream} that was associated with it.
*/ */
private void disassociateNoSampleRenderersWithEmptySampleStream( private void disassociateNoSampleRenderersWithEmptySampleStream(
...@@ -394,7 +394,7 @@ import org.checkerframework.checker.nullness.compatqual.NullableType; ...@@ -394,7 +394,7 @@ import org.checkerframework.checker.nullness.compatqual.NullableType;
/** /**
* For each renderer of type {@link C#TRACK_TYPE_NONE} that was enabled, we will associate it with * For each renderer of type {@link C#TRACK_TYPE_NONE} that was enabled, we will associate it with
* a dummy {@link EmptySampleStream}. * an {@link EmptySampleStream}.
*/ */
private void associateNoSampleRenderersWithEmptySampleStream( private void associateNoSampleRenderersWithEmptySampleStream(
@NullableType SampleStream[] sampleStreams) { @NullableType SampleStream[] sampleStreams) {
......
...@@ -28,10 +28,10 @@ import com.google.android.exoplayer2.trackselection.TrackSelectorResult; ...@@ -28,10 +28,10 @@ import com.google.android.exoplayer2.trackselection.TrackSelectorResult;
/* package */ final class PlaybackInfo { /* package */ final class PlaybackInfo {
/** /**
* Dummy media period id used while the timeline is empty and no period id is specified. This id * Placeholder media period id used while the timeline is empty and no period id is specified.
* is used when playback infos are created with {@link #createDummy(TrackSelectorResult)}. * This id is used when playback infos are created with {@link #createDummy(TrackSelectorResult)}.
*/ */
private static final MediaPeriodId DUMMY_MEDIA_PERIOD_ID = private static final MediaPeriodId PLACEHOLDER_MEDIA_PERIOD_ID =
new MediaPeriodId(/* periodUid= */ new Object()); new MediaPeriodId(/* periodUid= */ new Object());
/** The current {@link Timeline}. */ /** The current {@link Timeline}. */
...@@ -81,24 +81,24 @@ import com.google.android.exoplayer2.trackselection.TrackSelectorResult; ...@@ -81,24 +81,24 @@ import com.google.android.exoplayer2.trackselection.TrackSelectorResult;
public volatile long positionUs; public volatile long positionUs;
/** /**
* Creates empty dummy playback info which can be used for masking as long as no real playback * Creates an empty placeholder playback info which can be used for masking as long as no real
* info is available. * playback info is available.
* *
* @param emptyTrackSelectorResult An empty track selector result with null entries for each * @param emptyTrackSelectorResult An empty track selector result with null entries for each
* renderer. * renderer.
* @return A dummy playback info. * @return A placeholder playback info.
*/ */
public static PlaybackInfo createDummy(TrackSelectorResult emptyTrackSelectorResult) { public static PlaybackInfo createDummy(TrackSelectorResult emptyTrackSelectorResult) {
return new PlaybackInfo( return new PlaybackInfo(
Timeline.EMPTY, Timeline.EMPTY,
DUMMY_MEDIA_PERIOD_ID, PLACEHOLDER_MEDIA_PERIOD_ID,
/* requestedContentPositionUs= */ C.TIME_UNSET, /* requestedContentPositionUs= */ C.TIME_UNSET,
Player.STATE_IDLE, Player.STATE_IDLE,
/* playbackError= */ null, /* playbackError= */ null,
/* isLoading= */ false, /* isLoading= */ false,
TrackGroupArray.EMPTY, TrackGroupArray.EMPTY,
emptyTrackSelectorResult, emptyTrackSelectorResult,
DUMMY_MEDIA_PERIOD_ID, PLACEHOLDER_MEDIA_PERIOD_ID,
/* playWhenReady= */ false, /* playWhenReady= */ false,
Player.PLAYBACK_SUPPRESSION_REASON_NONE, Player.PLAYBACK_SUPPRESSION_REASON_NONE,
/* bufferedPositionUs= */ 0, /* bufferedPositionUs= */ 0,
...@@ -152,9 +152,9 @@ import com.google.android.exoplayer2.trackselection.TrackSelectorResult; ...@@ -152,9 +152,9 @@ import com.google.android.exoplayer2.trackselection.TrackSelectorResult;
this.positionUs = positionUs; this.positionUs = positionUs;
} }
/** Returns dummy period id for an empty timeline. */ /** Returns a placeholder period id for an empty timeline. */
public static MediaPeriodId getDummyPeriodForEmptyTimeline() { public static MediaPeriodId getDummyPeriodForEmptyTimeline() {
return DUMMY_MEDIA_PERIOD_ID; return PLACEHOLDER_MEDIA_PERIOD_ID;
} }
/** /**
......
...@@ -124,7 +124,7 @@ public abstract class Timeline { ...@@ -124,7 +124,7 @@ public abstract class Timeline {
*/ */
public static final Object SINGLE_WINDOW_UID = new Object(); public static final Object SINGLE_WINDOW_UID = new Object();
private static final MediaItem DUMMY_MEDIA_ITEM = private static final MediaItem EMPTY_MEDIA_ITEM =
new MediaItem.Builder() new MediaItem.Builder()
.setMediaId("com.google.android.exoplayer2.Timeline") .setMediaId("com.google.android.exoplayer2.Timeline")
.setUri(Uri.EMPTY) .setUri(Uri.EMPTY)
...@@ -222,7 +222,7 @@ public abstract class Timeline { ...@@ -222,7 +222,7 @@ public abstract class Timeline {
/** Creates window. */ /** Creates window. */
public Window() { public Window() {
uid = SINGLE_WINDOW_UID; uid = SINGLE_WINDOW_UID;
mediaItem = DUMMY_MEDIA_ITEM; mediaItem = EMPTY_MEDIA_ITEM;
} }
/** Sets the data held by this window. */ /** Sets the data held by this window. */
...@@ -243,7 +243,7 @@ public abstract class Timeline { ...@@ -243,7 +243,7 @@ public abstract class Timeline {
int lastPeriodIndex, int lastPeriodIndex,
long positionInFirstPeriodUs) { long positionInFirstPeriodUs) {
this.uid = uid; this.uid = uid;
this.mediaItem = mediaItem != null ? mediaItem : DUMMY_MEDIA_ITEM; this.mediaItem = mediaItem != null ? mediaItem : EMPTY_MEDIA_ITEM;
this.tag = this.tag =
mediaItem != null && mediaItem.playbackProperties != null mediaItem != null && mediaItem.playbackProperties != null
? mediaItem.playbackProperties.tag ? mediaItem.playbackProperties.tag
......
...@@ -150,7 +150,7 @@ public final class PlaybackStatsListener ...@@ -150,7 +150,7 @@ public final class PlaybackStatsListener
// TODO: Add AnalyticsListener.onAttachedToPlayer and onDetachedFromPlayer to auto-release with // TODO: Add AnalyticsListener.onAttachedToPlayer and onDetachedFromPlayer to auto-release with
// an actual EventTime. Should also simplify other cases where the listener needs to be released // an actual EventTime. Should also simplify other cases where the listener needs to be released
// separately from the player. // separately from the player.
EventTime dummyEventTime = sessionManager.finishAllSessions(
new EventTime( new EventTime(
SystemClock.elapsedRealtime(), SystemClock.elapsedRealtime(),
Timeline.EMPTY, Timeline.EMPTY,
...@@ -161,8 +161,7 @@ public final class PlaybackStatsListener ...@@ -161,8 +161,7 @@ public final class PlaybackStatsListener
/* currentWindowIndex= */ 0, /* currentWindowIndex= */ 0,
/* currentMediaPeriodId= */ null, /* currentMediaPeriodId= */ null,
/* currentPlaybackPositionMs= */ 0, /* currentPlaybackPositionMs= */ 0,
/* totalBufferedDurationMs= */ 0); /* totalBufferedDurationMs= */ 0));
sessionManager.finishAllSessions(dummyEventTime);
} }
// PlaybackSessionManager.Listener implementation. // PlaybackSessionManager.Listener implementation.
......
...@@ -98,12 +98,12 @@ public interface AudioRendererEventListener { ...@@ -98,12 +98,12 @@ public interface AudioRendererEventListener {
@Nullable private final AudioRendererEventListener listener; @Nullable private final AudioRendererEventListener listener;
/** /**
* @param handler A handler for dispatching events, or null if creating a dummy instance. * @param handler A handler for dispatching events, or null if events should not be dispatched.
* @param listener The listener to which events should be dispatched, or null if creating a * @param listener The listener to which events should be dispatched, or null if events should
* dummy instance. * not be dispatched.
*/ */
public EventDispatcher(@Nullable Handler handler, public EventDispatcher(
@Nullable AudioRendererEventListener listener) { @Nullable Handler handler, @Nullable AudioRendererEventListener listener) {
this.handler = listener != null ? Assertions.checkNotNull(handler) : null; this.handler = listener != null ? Assertions.checkNotNull(handler) : null;
this.listener = listener; this.listener = listener;
} }
......
...@@ -34,7 +34,7 @@ import java.util.UUID; ...@@ -34,7 +34,7 @@ import java.util.UUID;
@RequiresApi(18) @RequiresApi(18)
public final class OfflineLicenseHelper { public final class OfflineLicenseHelper {
private static final DrmInitData DUMMY_DRM_INIT_DATA = new DrmInitData(); private static final DrmInitData EMPTY_DRM_INIT_DATA = new DrmInitData();
private final ConditionVariable conditionVariable; private final ConditionVariable conditionVariable;
private final DefaultDrmSessionManager drmSessionManager; private final DefaultDrmSessionManager drmSessionManager;
...@@ -202,7 +202,7 @@ public final class OfflineLicenseHelper { ...@@ -202,7 +202,7 @@ public final class OfflineLicenseHelper {
throws DrmSessionException { throws DrmSessionException {
Assertions.checkNotNull(offlineLicenseKeySetId); Assertions.checkNotNull(offlineLicenseKeySetId);
return blockingKeyRequest( return blockingKeyRequest(
DefaultDrmSessionManager.MODE_DOWNLOAD, offlineLicenseKeySetId, DUMMY_DRM_INIT_DATA); DefaultDrmSessionManager.MODE_DOWNLOAD, offlineLicenseKeySetId, EMPTY_DRM_INIT_DATA);
} }
/** /**
...@@ -215,7 +215,7 @@ public final class OfflineLicenseHelper { ...@@ -215,7 +215,7 @@ public final class OfflineLicenseHelper {
throws DrmSessionException { throws DrmSessionException {
Assertions.checkNotNull(offlineLicenseKeySetId); Assertions.checkNotNull(offlineLicenseKeySetId);
blockingKeyRequest( blockingKeyRequest(
DefaultDrmSessionManager.MODE_RELEASE, offlineLicenseKeySetId, DUMMY_DRM_INIT_DATA); DefaultDrmSessionManager.MODE_RELEASE, offlineLicenseKeySetId, EMPTY_DRM_INIT_DATA);
} }
/** /**
...@@ -231,7 +231,7 @@ public final class OfflineLicenseHelper { ...@@ -231,7 +231,7 @@ public final class OfflineLicenseHelper {
drmSessionManager.prepare(); drmSessionManager.prepare();
DrmSession drmSession = DrmSession drmSession =
openBlockingKeyRequest( openBlockingKeyRequest(
DefaultDrmSessionManager.MODE_QUERY, offlineLicenseKeySetId, DUMMY_DRM_INIT_DATA); DefaultDrmSessionManager.MODE_QUERY, offlineLicenseKeySetId, EMPTY_DRM_INIT_DATA);
DrmSessionException error = drmSession.getError(); DrmSessionException error = drmSession.getError();
Pair<Long, Long> licenseDurationRemainingSec = Pair<Long, Long> licenseDurationRemainingSec =
WidevineUtil.getLicenseDurationRemainingSec(drmSession); WidevineUtil.getLicenseDurationRemainingSec(drmSession);
......
...@@ -500,7 +500,7 @@ public final class DownloadHelper { ...@@ -500,7 +500,7 @@ public final class DownloadHelper {
new DefaultTrackSelector(trackSelectorParameters, new DownloadTrackSelection.Factory()); new DefaultTrackSelector(trackSelectorParameters, new DownloadTrackSelection.Factory());
this.rendererCapabilities = rendererCapabilities; this.rendererCapabilities = rendererCapabilities;
this.scratchSet = new SparseIntArray(); this.scratchSet = new SparseIntArray();
trackSelector.init(/* listener= */ () -> {}, new DummyBandwidthMeter()); trackSelector.init(/* listener= */ () -> {}, new FakeBandwidthMeter());
callbackHandler = Util.createHandlerForCurrentOrMainLooper(); callbackHandler = Util.createHandlerForCurrentOrMainLooper();
window = new Timeline.Window(); window = new Timeline.Window();
} }
...@@ -1152,7 +1152,7 @@ public final class DownloadHelper { ...@@ -1152,7 +1152,7 @@ public final class DownloadHelper {
} }
} }
private static final class DummyBandwidthMeter implements BandwidthMeter { private static final class FakeBandwidthMeter implements BandwidthMeter {
@Override @Override
public long getBitrateEstimate() { public long getBitrateEstimate() {
......
...@@ -56,7 +56,7 @@ public final class ConcatenatingMediaSource extends CompositeMediaSource<MediaSo ...@@ -56,7 +56,7 @@ public final class ConcatenatingMediaSource extends CompositeMediaSource<MediaSo
private static final int MSG_UPDATE_TIMELINE = 4; private static final int MSG_UPDATE_TIMELINE = 4;
private static final int MSG_ON_COMPLETION = 5; private static final int MSG_ON_COMPLETION = 5;
private static final MediaItem DUMMY_MEDIA_ITEM = private static final MediaItem EMPTY_MEDIA_ITEM =
new MediaItem.Builder().setUri(Uri.EMPTY).build(); new MediaItem.Builder().setUri(Uri.EMPTY).build();
// Accessed on any thread. // Accessed on any thread.
...@@ -445,8 +445,8 @@ public final class ConcatenatingMediaSource extends CompositeMediaSource<MediaSo ...@@ -445,8 +445,8 @@ public final class ConcatenatingMediaSource extends CompositeMediaSource<MediaSo
@Override @Override
public MediaItem getMediaItem() { public MediaItem getMediaItem() {
// This method is actually never called because getInitialTimeline is implemented and hence the // This method is actually never called because getInitialTimeline is implemented and hence the
// MaskingMediaSource does not need to create a dummy timeline for this media source. // MaskingMediaSource does not need to create a placeholder timeline for this media source.
return DUMMY_MEDIA_ITEM; return EMPTY_MEDIA_ITEM;
} }
@Override @Override
...@@ -476,7 +476,7 @@ public final class ConcatenatingMediaSource extends CompositeMediaSource<MediaSo ...@@ -476,7 +476,7 @@ public final class ConcatenatingMediaSource extends CompositeMediaSource<MediaSo
@Nullable MediaSourceHolder holder = mediaSourceByUid.get(mediaSourceHolderUid); @Nullable MediaSourceHolder holder = mediaSourceByUid.get(mediaSourceHolderUid);
if (holder == null) { if (holder == null) {
// Stale event. The media source has already been removed. // Stale event. The media source has already been removed.
holder = new MediaSourceHolder(new DummyMediaSource(), useLazyPreparation); holder = new MediaSourceHolder(new FakeMediaSource(), useLazyPreparation);
holder.isRemoved = true; holder.isRemoved = true;
prepareChildSource(holder, holder.mediaSource); prepareChildSource(holder, holder.mediaSource);
} }
...@@ -988,8 +988,8 @@ public final class ConcatenatingMediaSource extends CompositeMediaSource<MediaSo ...@@ -988,8 +988,8 @@ public final class ConcatenatingMediaSource extends CompositeMediaSource<MediaSo
} }
} }
/** Dummy media source which does nothing and does not support creating periods. */ /** A media source which does nothing and does not support creating periods. */
private static final class DummyMediaSource extends BaseMediaSource { private static final class FakeMediaSource extends BaseMediaSource {
@Override @Override
protected void prepareSourceInternal(@Nullable TransferListener mediaTransferListener) { protected void prepareSourceInternal(@Nullable TransferListener mediaTransferListener) {
...@@ -998,7 +998,7 @@ public final class ConcatenatingMediaSource extends CompositeMediaSource<MediaSo ...@@ -998,7 +998,7 @@ public final class ConcatenatingMediaSource extends CompositeMediaSource<MediaSo
@Override @Override
public MediaItem getMediaItem() { public MediaItem getMediaItem() {
return DUMMY_MEDIA_ITEM; return EMPTY_MEDIA_ITEM;
} }
@Override @Override
......
...@@ -67,7 +67,7 @@ public final class MaskingMediaSource extends CompositeMediaSource<Void> { ...@@ -67,7 +67,7 @@ public final class MaskingMediaSource extends CompositeMediaSource<Void> {
initialTimeline, /* firstWindowUid= */ null, /* firstPeriodUid= */ null); initialTimeline, /* firstWindowUid= */ null, /* firstPeriodUid= */ null);
hasRealTimeline = true; hasRealTimeline = true;
} else { } else {
timeline = MaskingTimeline.createWithDummyTimeline(mediaSource.getMediaItem()); timeline = MaskingTimeline.createWithPlaceholderTimeline(mediaSource.getMediaItem());
} }
} }
...@@ -165,7 +165,9 @@ public final class MaskingMediaSource extends CompositeMediaSource<Void> { ...@@ -165,7 +165,9 @@ public final class MaskingMediaSource extends CompositeMediaSource<Void> {
hasRealTimeline hasRealTimeline
? timeline.cloneWithUpdatedTimeline(newTimeline) ? timeline.cloneWithUpdatedTimeline(newTimeline)
: MaskingTimeline.createWithRealTimeline( : MaskingTimeline.createWithRealTimeline(
newTimeline, Window.SINGLE_WINDOW_UID, MaskingTimeline.DUMMY_EXTERNAL_PERIOD_UID); newTimeline,
Window.SINGLE_WINDOW_UID,
MaskingTimeline.MASKING_EXTERNAL_PERIOD_UID);
} else { } else {
// Determine first period and the start position. // Determine first period and the start position.
// This will be: // This will be:
...@@ -174,7 +176,7 @@ public final class MaskingMediaSource extends CompositeMediaSource<Void> { ...@@ -174,7 +176,7 @@ public final class MaskingMediaSource extends CompositeMediaSource<Void> {
// a non-zero initial seek position in the window. // a non-zero initial seek position in the window.
// 3. The default window start position if the deferred period has a prepare position of zero // 3. The default window start position if the deferred period has a prepare position of zero
// under the assumption that the prepare position of zero was used because it's the // under the assumption that the prepare position of zero was used because it's the
// default position of the DummyTimeline window. Note that this will override an // default position of the PlaceholderTimeline window. Note that this will override an
// intentional seek to zero for a window with a non-zero default position. This is // intentional seek to zero for a window with a non-zero default position. This is
// unlikely to be a problem as a non-zero default position usually only occurs for live // unlikely to be a problem as a non-zero default position usually only occurs for live
// playbacks and seeking to zero in a live window would cause BehindLiveWindowExceptions // playbacks and seeking to zero in a live window would cause BehindLiveWindowExceptions
...@@ -230,7 +232,7 @@ public final class MaskingMediaSource extends CompositeMediaSource<Void> { ...@@ -230,7 +232,7 @@ public final class MaskingMediaSource extends CompositeMediaSource<Void> {
private Object getInternalPeriodUid(Object externalPeriodUid) { private Object getInternalPeriodUid(Object externalPeriodUid) {
return timeline.replacedInternalPeriodUid != null return timeline.replacedInternalPeriodUid != null
&& externalPeriodUid.equals(MaskingTimeline.DUMMY_EXTERNAL_PERIOD_UID) && externalPeriodUid.equals(MaskingTimeline.MASKING_EXTERNAL_PERIOD_UID)
? timeline.replacedInternalPeriodUid ? timeline.replacedInternalPeriodUid
: externalPeriodUid; : externalPeriodUid;
} }
...@@ -238,7 +240,7 @@ public final class MaskingMediaSource extends CompositeMediaSource<Void> { ...@@ -238,7 +240,7 @@ public final class MaskingMediaSource extends CompositeMediaSource<Void> {
private Object getExternalPeriodUid(Object internalPeriodUid) { private Object getExternalPeriodUid(Object internalPeriodUid) {
return timeline.replacedInternalPeriodUid != null return timeline.replacedInternalPeriodUid != null
&& timeline.replacedInternalPeriodUid.equals(internalPeriodUid) && timeline.replacedInternalPeriodUid.equals(internalPeriodUid)
? MaskingTimeline.DUMMY_EXTERNAL_PERIOD_UID ? MaskingTimeline.MASKING_EXTERNAL_PERIOD_UID
: internalPeriodUid; : internalPeriodUid;
} }
...@@ -265,34 +267,36 @@ public final class MaskingMediaSource extends CompositeMediaSource<Void> { ...@@ -265,34 +267,36 @@ public final class MaskingMediaSource extends CompositeMediaSource<Void> {
/** /**
* Timeline used as placeholder for an unprepared media source. After preparation, a * Timeline used as placeholder for an unprepared media source. After preparation, a
* MaskingTimeline is used to keep the originally assigned dummy period ID. * MaskingTimeline is used to keep the originally assigned masking period ID.
*/ */
private static final class MaskingTimeline extends ForwardingTimeline { private static final class MaskingTimeline extends ForwardingTimeline {
public static final Object DUMMY_EXTERNAL_PERIOD_UID = new Object(); public static final Object MASKING_EXTERNAL_PERIOD_UID = new Object();
@Nullable private final Object replacedInternalWindowUid; @Nullable private final Object replacedInternalWindowUid;
@Nullable private final Object replacedInternalPeriodUid; @Nullable private final Object replacedInternalPeriodUid;
/** /**
* Returns an instance with a dummy timeline using the provided {@link MediaItem}. * Returns an instance with a placeholder timeline using the provided {@link MediaItem}.
* *
* @param mediaItem A {@link MediaItem}. * @param mediaItem A {@link MediaItem}.
*/ */
public static MaskingTimeline createWithDummyTimeline(MediaItem mediaItem) { public static MaskingTimeline createWithPlaceholderTimeline(MediaItem mediaItem) {
return new MaskingTimeline( return new MaskingTimeline(
new DummyTimeline(mediaItem), Window.SINGLE_WINDOW_UID, DUMMY_EXTERNAL_PERIOD_UID); new PlaceholderTimeline(mediaItem),
Window.SINGLE_WINDOW_UID,
MASKING_EXTERNAL_PERIOD_UID);
} }
/** /**
* Returns an instance with a real timeline, replacing the provided period ID with the already * Returns an instance with a real timeline, replacing the provided period ID with the already
* assigned dummy period ID. * assigned masking period ID.
* *
* @param timeline The real timeline. * @param timeline The real timeline.
* @param firstWindowUid The window UID in the timeline which will be replaced by the already * @param firstWindowUid The window UID in the timeline which will be replaced by the already
* assigned {@link Window#SINGLE_WINDOW_UID}. * assigned {@link Window#SINGLE_WINDOW_UID}.
* @param firstPeriodUid The period UID in the timeline which will be replaced by the already * @param firstPeriodUid The period UID in the timeline which will be replaced by the already
* assigned {@link #DUMMY_EXTERNAL_PERIOD_UID}. * assigned {@link #MASKING_EXTERNAL_PERIOD_UID}.
*/ */
public static MaskingTimeline createWithRealTimeline( public static MaskingTimeline createWithRealTimeline(
Timeline timeline, @Nullable Object firstWindowUid, @Nullable Object firstPeriodUid) { Timeline timeline, @Nullable Object firstWindowUid, @Nullable Object firstPeriodUid) {
...@@ -335,7 +339,7 @@ public final class MaskingMediaSource extends CompositeMediaSource<Void> { ...@@ -335,7 +339,7 @@ public final class MaskingMediaSource extends CompositeMediaSource<Void> {
public Period getPeriod(int periodIndex, Period period, boolean setIds) { public Period getPeriod(int periodIndex, Period period, boolean setIds) {
timeline.getPeriod(periodIndex, period, setIds); timeline.getPeriod(periodIndex, period, setIds);
if (Util.areEqual(period.uid, replacedInternalPeriodUid) && setIds) { if (Util.areEqual(period.uid, replacedInternalPeriodUid) && setIds) {
period.uid = DUMMY_EXTERNAL_PERIOD_UID; period.uid = MASKING_EXTERNAL_PERIOD_UID;
} }
return period; return period;
} }
...@@ -343,7 +347,7 @@ public final class MaskingMediaSource extends CompositeMediaSource<Void> { ...@@ -343,7 +347,7 @@ public final class MaskingMediaSource extends CompositeMediaSource<Void> {
@Override @Override
public int getIndexOfPeriod(Object uid) { public int getIndexOfPeriod(Object uid) {
return timeline.getIndexOfPeriod( return timeline.getIndexOfPeriod(
DUMMY_EXTERNAL_PERIOD_UID.equals(uid) && replacedInternalPeriodUid != null MASKING_EXTERNAL_PERIOD_UID.equals(uid) && replacedInternalPeriodUid != null
? replacedInternalPeriodUid ? replacedInternalPeriodUid
: uid); : uid);
} }
...@@ -351,18 +355,18 @@ public final class MaskingMediaSource extends CompositeMediaSource<Void> { ...@@ -351,18 +355,18 @@ public final class MaskingMediaSource extends CompositeMediaSource<Void> {
@Override @Override
public Object getUidOfPeriod(int periodIndex) { public Object getUidOfPeriod(int periodIndex) {
Object uid = timeline.getUidOfPeriod(periodIndex); Object uid = timeline.getUidOfPeriod(periodIndex);
return Util.areEqual(uid, replacedInternalPeriodUid) ? DUMMY_EXTERNAL_PERIOD_UID : uid; return Util.areEqual(uid, replacedInternalPeriodUid) ? MASKING_EXTERNAL_PERIOD_UID : uid;
} }
} }
/** Dummy placeholder timeline with one dynamic window with a period of indeterminate duration. */ /** A timeline with one dynamic window with a period of indeterminate duration. */
@VisibleForTesting @VisibleForTesting
public static final class DummyTimeline extends Timeline { public static final class PlaceholderTimeline extends Timeline {
private final MediaItem mediaItem; private final MediaItem mediaItem;
/** Creates a new instance with the given media item. */ /** Creates a new instance with the given media item. */
public DummyTimeline(MediaItem mediaItem) { public PlaceholderTimeline(MediaItem mediaItem) {
this.mediaItem = mediaItem; this.mediaItem = mediaItem;
} }
...@@ -402,7 +406,7 @@ public final class MaskingMediaSource extends CompositeMediaSource<Void> { ...@@ -402,7 +406,7 @@ public final class MaskingMediaSource extends CompositeMediaSource<Void> {
public Period getPeriod(int periodIndex, Period period, boolean setIds) { public Period getPeriod(int periodIndex, Period period, boolean setIds) {
return period.set( return period.set(
/* id= */ setIds ? 0 : null, /* id= */ setIds ? 0 : null,
/* uid= */ setIds ? MaskingTimeline.DUMMY_EXTERNAL_PERIOD_UID : null, /* uid= */ setIds ? MaskingTimeline.MASKING_EXTERNAL_PERIOD_UID : null,
/* windowIndex= */ 0, /* windowIndex= */ 0,
/* durationUs = */ C.TIME_UNSET, /* durationUs = */ C.TIME_UNSET,
/* positionInWindowUs= */ 0); /* positionInWindowUs= */ 0);
...@@ -410,12 +414,12 @@ public final class MaskingMediaSource extends CompositeMediaSource<Void> { ...@@ -410,12 +414,12 @@ public final class MaskingMediaSource extends CompositeMediaSource<Void> {
@Override @Override
public int getIndexOfPeriod(Object uid) { public int getIndexOfPeriod(Object uid) {
return uid == MaskingTimeline.DUMMY_EXTERNAL_PERIOD_UID ? 0 : C.INDEX_UNSET; return uid == MaskingTimeline.MASKING_EXTERNAL_PERIOD_UID ? 0 : C.INDEX_UNSET;
} }
@Override @Override
public Object getUidOfPeriod(int periodIndex) { public Object getUidOfPeriod(int periodIndex) {
return MaskingTimeline.DUMMY_EXTERNAL_PERIOD_UID; return MaskingTimeline.MASKING_EXTERNAL_PERIOD_UID;
} }
} }
} }
...@@ -93,8 +93,8 @@ public interface MediaSource { ...@@ -93,8 +93,8 @@ public interface MediaSource {
public final int nextAdGroupIndex; public final int nextAdGroupIndex;
/** /**
* Creates a media period identifier for a dummy period which is not part of a buffered sequence * Creates a media period identifier for a period which is not part of a buffered sequence of
* of windows. * windows.
* *
* @param periodUid The unique id of the timeline period. * @param periodUid The unique id of the timeline period.
*/ */
...@@ -248,8 +248,8 @@ public interface MediaSource { ...@@ -248,8 +248,8 @@ public interface MediaSource {
void removeDrmEventListener(DrmSessionEventListener eventListener); void removeDrmEventListener(DrmSessionEventListener eventListener);
/** /**
* Returns the initial dummy timeline that is returned immediately when the real timeline is not * Returns the initial placeholder timeline that is returned immediately when the real timeline is
* yet known, or null to let the player create an initial timeline. * not yet known, or null to let the player create an initial timeline.
* *
* <p>The initial timeline must use the same uids for windows and periods that the real timeline * <p>The initial timeline must use the same uids for windows and periods that the real timeline
* will use. It also must provide windows which are marked as dynamic to indicate that the window * will use. It also must provide windows which are marked as dynamic to indicate that the window
......
...@@ -66,7 +66,7 @@ public final class MergingMediaSource extends CompositeMediaSource<Integer> { ...@@ -66,7 +66,7 @@ public final class MergingMediaSource extends CompositeMediaSource<Integer> {
} }
private static final int PERIOD_COUNT_UNSET = -1; private static final int PERIOD_COUNT_UNSET = -1;
private static final MediaItem DUMMY_MEDIA_ITEM = private static final MediaItem EMPTY_MEDIA_ITEM =
new MediaItem.Builder().setMediaId("MergingMediaSource").build(); new MediaItem.Builder().setMediaId("MergingMediaSource").build();
private final boolean adjustPeriodTimeOffsets; private final boolean adjustPeriodTimeOffsets;
...@@ -137,7 +137,7 @@ public final class MergingMediaSource extends CompositeMediaSource<Integer> { ...@@ -137,7 +137,7 @@ public final class MergingMediaSource extends CompositeMediaSource<Integer> {
@Override @Override
public MediaItem getMediaItem() { public MediaItem getMediaItem() {
return mediaSources.length > 0 ? mediaSources[0].getMediaItem() : DUMMY_MEDIA_ITEM; return mediaSources.length > 0 ? mediaSources[0].getMediaItem() : EMPTY_MEDIA_ITEM;
} }
@Override @Override
......
...@@ -121,7 +121,7 @@ public final class AdsMediaSource extends CompositeMediaSource<MediaPeriodId> { ...@@ -121,7 +121,7 @@ public final class AdsMediaSource extends CompositeMediaSource<MediaPeriodId> {
} }
// Used to identify the content "child" source for CompositeMediaSource. // Used to identify the content "child" source for CompositeMediaSource.
private static final MediaPeriodId DUMMY_CONTENT_MEDIA_PERIOD_ID = private static final MediaPeriodId CHILD_SOURCE_MEDIA_PERIOD_ID =
new MediaPeriodId(/* periodUid= */ new Object()); new MediaPeriodId(/* periodUid= */ new Object());
private final MediaSource contentMediaSource; private final MediaSource contentMediaSource;
...@@ -203,7 +203,7 @@ public final class AdsMediaSource extends CompositeMediaSource<MediaPeriodId> { ...@@ -203,7 +203,7 @@ public final class AdsMediaSource extends CompositeMediaSource<MediaPeriodId> {
super.prepareSourceInternal(mediaTransferListener); super.prepareSourceInternal(mediaTransferListener);
ComponentListener componentListener = new ComponentListener(); ComponentListener componentListener = new ComponentListener();
this.componentListener = componentListener; this.componentListener = componentListener;
prepareChildSource(DUMMY_CONTENT_MEDIA_PERIOD_ID, contentMediaSource); prepareChildSource(CHILD_SOURCE_MEDIA_PERIOD_ID, contentMediaSource);
mainHandler.post(() -> adsLoader.start(componentListener, adViewProvider)); mainHandler.post(() -> adsLoader.start(componentListener, adViewProvider));
} }
...@@ -284,8 +284,8 @@ public final class AdsMediaSource extends CompositeMediaSource<MediaPeriodId> { ...@@ -284,8 +284,8 @@ public final class AdsMediaSource extends CompositeMediaSource<MediaPeriodId> {
@Override @Override
protected MediaPeriodId getMediaPeriodIdForChildMediaPeriodId( protected MediaPeriodId getMediaPeriodIdForChildMediaPeriodId(
MediaPeriodId childId, MediaPeriodId mediaPeriodId) { MediaPeriodId childId, MediaPeriodId mediaPeriodId) {
// The child id for the content period is just DUMMY_CONTENT_MEDIA_PERIOD_ID. That's why we need // The child id for the content period is just CHILD_SOURCE_MEDIA_PERIOD_ID. That's why
// to forward the reported mediaPeriodId in this case. // we need to forward the reported mediaPeriodId in this case.
return childId.isAd() ? childId : mediaPeriodId; return childId.isAd() ? childId : mediaPeriodId;
} }
......
...@@ -41,7 +41,7 @@ import org.checkerframework.checker.nullness.qual.MonotonicNonNull; ...@@ -41,7 +41,7 @@ import org.checkerframework.checker.nullness.qual.MonotonicNonNull;
*/ */
public final class BundledChunkExtractor implements ExtractorOutput, ChunkExtractor { public final class BundledChunkExtractor implements ExtractorOutput, ChunkExtractor {
private static final PositionHolder DUMMY_POSITION_HOLDER = new PositionHolder(); private static final PositionHolder POSITION_HOLDER = new PositionHolder();
private final Extractor extractor; private final Extractor extractor;
private final int primaryTrackType; private final int primaryTrackType;
...@@ -106,7 +106,7 @@ public final class BundledChunkExtractor implements ExtractorOutput, ChunkExtrac ...@@ -106,7 +106,7 @@ public final class BundledChunkExtractor implements ExtractorOutput, ChunkExtrac
@Override @Override
public boolean read(ExtractorInput input) throws IOException { public boolean read(ExtractorInput input) throws IOException {
int result = extractor.read(input, DUMMY_POSITION_HOLDER); int result = extractor.read(input, POSITION_HOLDER);
Assertions.checkState(result != Extractor.RESULT_SEEK); Assertions.checkState(result != Extractor.RESULT_SEEK);
return result == Extractor.RESULT_CONTINUE; return result == Extractor.RESULT_CONTINUE;
} }
...@@ -149,7 +149,7 @@ public final class BundledChunkExtractor implements ExtractorOutput, ChunkExtrac ...@@ -149,7 +149,7 @@ public final class BundledChunkExtractor implements ExtractorOutput, ChunkExtrac
private final int id; private final int id;
private final int type; private final int type;
@Nullable private final Format manifestFormat; @Nullable private final Format manifestFormat;
private final DummyTrackOutput dummyTrackOutput; private final DummyTrackOutput fakeTrackOutput;
public @MonotonicNonNull Format sampleFormat; public @MonotonicNonNull Format sampleFormat;
private @MonotonicNonNull TrackOutput trackOutput; private @MonotonicNonNull TrackOutput trackOutput;
...@@ -159,12 +159,12 @@ public final class BundledChunkExtractor implements ExtractorOutput, ChunkExtrac ...@@ -159,12 +159,12 @@ public final class BundledChunkExtractor implements ExtractorOutput, ChunkExtrac
this.id = id; this.id = id;
this.type = type; this.type = type;
this.manifestFormat = manifestFormat; this.manifestFormat = manifestFormat;
dummyTrackOutput = new DummyTrackOutput(); fakeTrackOutput = new DummyTrackOutput();
} }
public void bind(@Nullable TrackOutputProvider trackOutputProvider, long endTimeUs) { public void bind(@Nullable TrackOutputProvider trackOutputProvider, long endTimeUs) {
if (trackOutputProvider == null) { if (trackOutputProvider == null) {
trackOutput = dummyTrackOutput; trackOutput = fakeTrackOutput;
return; return;
} }
this.endTimeUs = endTimeUs; this.endTimeUs = endTimeUs;
...@@ -201,7 +201,7 @@ public final class BundledChunkExtractor implements ExtractorOutput, ChunkExtrac ...@@ -201,7 +201,7 @@ public final class BundledChunkExtractor implements ExtractorOutput, ChunkExtrac
int offset, int offset,
@Nullable CryptoData cryptoData) { @Nullable CryptoData cryptoData) {
if (endTimeUs != C.TIME_UNSET && timeUs >= endTimeUs) { if (endTimeUs != C.TIME_UNSET && timeUs >= endTimeUs) {
trackOutput = dummyTrackOutput; trackOutput = fakeTrackOutput;
} }
castNonNull(trackOutput).sampleMetadata(timeUs, flags, size, offset, cryptoData); castNonNull(trackOutput).sampleMetadata(timeUs, flags, size, offset, cryptoData);
} }
......
...@@ -19,9 +19,7 @@ import android.net.Uri; ...@@ -19,9 +19,7 @@ import android.net.Uri;
import androidx.annotation.Nullable; import androidx.annotation.Nullable;
import java.io.IOException; import java.io.IOException;
/** /** A DataSource which provides no data. {@link #open(DataSpec)} throws {@link IOException}. */
* A dummy DataSource which provides no data. {@link #open(DataSpec)} throws {@link IOException}.
*/
public final class DummyDataSource implements DataSource { public final class DummyDataSource implements DataSource {
public static final DummyDataSource INSTANCE = new DummyDataSource(); public static final DummyDataSource INSTANCE = new DummyDataSource();
...@@ -38,7 +36,7 @@ public final class DummyDataSource implements DataSource { ...@@ -38,7 +36,7 @@ public final class DummyDataSource implements DataSource {
@Override @Override
public long open(DataSpec dataSpec) throws IOException { public long open(DataSpec dataSpec) throws IOException {
throw new IOException("Dummy source"); throw new IOException("DummyDataSource cannot be opened");
} }
@Override @Override
......
...@@ -22,7 +22,6 @@ import static com.google.android.exoplayer2.util.EGLSurfaceTexture.SECURE_MODE_S ...@@ -22,7 +22,6 @@ import static com.google.android.exoplayer2.util.EGLSurfaceTexture.SECURE_MODE_S
import android.content.Context; import android.content.Context;
import android.graphics.SurfaceTexture; import android.graphics.SurfaceTexture;
import android.os.Handler; import android.os.Handler;
import android.os.Handler.Callback;
import android.os.HandlerThread; import android.os.HandlerThread;
import android.os.Message; import android.os.Message;
import android.view.Surface; import android.view.Surface;
...@@ -70,14 +69,14 @@ public final class DummySurface extends Surface { ...@@ -70,14 +69,14 @@ public final class DummySurface extends Surface {
/** /**
* Returns a newly created dummy surface. The surface must be released by calling {@link #release} * Returns a newly created dummy surface. The surface must be released by calling {@link #release}
* when it's no longer required. * when it's no longer required.
* <p> *
* Must only be called if {@link Util#SDK_INT} is 17 or higher. * <p>Must only be called if {@link Util#SDK_INT} is 17 or higher.
* *
* @param context Any {@link Context}. * @param context Any {@link Context}.
* @param secure Whether a secure surface is required. Must only be requested if * @param secure Whether a secure surface is required. Must only be requested if {@link
* {@link #isSecureSupported(Context)} returns {@code true}. * #isSecureSupported(Context)} returns {@code true}.
* @throws IllegalStateException If a secure surface is requested on a device for which * @throws IllegalStateException If a secure surface is requested on a device for which {@link
* {@link #isSecureSupported(Context)} returns {@code false}. * #isSecureSupported(Context)} returns {@code false}.
*/ */
public static DummySurface newInstanceV17(Context context, boolean secure) { public static DummySurface newInstanceV17(Context context, boolean secure) {
Assertions.checkState(!secure || isSecureSupported(context)); Assertions.checkState(!secure || isSecureSupported(context));
...@@ -123,7 +122,7 @@ public final class DummySurface extends Surface { ...@@ -123,7 +122,7 @@ public final class DummySurface extends Surface {
} }
} }
private static class DummySurfaceThread extends HandlerThread implements Callback { private static class DummySurfaceThread extends HandlerThread implements Handler.Callback {
private static final int MSG_INIT = 1; private static final int MSG_INIT = 1;
private static final int MSG_RELEASE = 2; private static final int MSG_RELEASE = 2;
......
...@@ -138,12 +138,12 @@ public interface VideoRendererEventListener { ...@@ -138,12 +138,12 @@ public interface VideoRendererEventListener {
@Nullable private final VideoRendererEventListener listener; @Nullable private final VideoRendererEventListener listener;
/** /**
* @param handler A handler for dispatching events, or null if creating a dummy instance. * @param handler A handler for dispatching events, or null if events should not be dispatched.
* @param listener The listener to which events should be dispatched, or null if creating a * @param listener The listener to which events should be dispatched, or null if events should
* dummy instance. * not be dispatched.
*/ */
public EventDispatcher(@Nullable Handler handler, public EventDispatcher(
@Nullable VideoRendererEventListener listener) { @Nullable Handler handler, @Nullable VideoRendererEventListener listener) {
this.handler = listener != null ? Assertions.checkNotNull(handler) : null; this.handler = listener != null ? Assertions.checkNotNull(handler) : null;
this.listener = listener; this.listener = listener;
} }
......
...@@ -786,7 +786,7 @@ public final class AnalyticsCollectorTest { ...@@ -786,7 +786,7 @@ public final class AnalyticsCollectorTest {
assertThat(listener.getEvents(EVENT_TIMELINE_CHANGED)) assertThat(listener.getEvents(EVENT_TIMELINE_CHANGED))
.containsExactly( .containsExactly(
WINDOW_0 /* PLAYLIST_CHANGED */, WINDOW_0 /* PLAYLIST_CHANGED */,
window0Period1Seq0 /* SOURCE_UPDATE (concatenated timeline replaces dummy) */, window0Period1Seq0 /* SOURCE_UPDATE (concatenated timeline replaces placeholder) */,
period1Seq0 /* SOURCE_UPDATE (child sources in concatenating source moved) */) period1Seq0 /* SOURCE_UPDATE (child sources in concatenating source moved) */)
.inOrder(); .inOrder();
assertThat(listener.getEvents(EVENT_LOADING_CHANGED)) assertThat(listener.getEvents(EVENT_LOADING_CHANGED))
......
...@@ -94,7 +94,7 @@ public class VersionTableTest { ...@@ -94,7 +94,7 @@ public class VersionTableTest {
@Test @Test
public void doesTableExist_existingTable_returnsTrue() { public void doesTableExist_existingTable_returnsTrue() {
String table = "TestTable"; String table = "TestTable";
databaseProvider.getWritableDatabase().execSQL("CREATE TABLE " + table + " (dummy INTEGER)"); databaseProvider.getWritableDatabase().execSQL("CREATE TABLE " + table + " (test INTEGER)");
assertThat(VersionTable.tableExists(database, table)).isTrue(); assertThat(VersionTable.tableExists(database, table)).isTrue();
} }
} }
...@@ -56,7 +56,7 @@ public class DownloadManagerTest { ...@@ -56,7 +56,7 @@ public class DownloadManagerTest {
private static final int APP_STOP_REASON = 1; private static final int APP_STOP_REASON = 1;
/** The minimum number of times a download must be retried before failing. */ /** The minimum number of times a download must be retried before failing. */
private static final int MIN_RETRY_COUNT = 3; private static final int MIN_RETRY_COUNT = 3;
/** Dummy value for the current time. */ /** Test value for the current time. */
private static final long NOW_MS = 1234; private static final long NOW_MS = 1234;
private static final String ID1 = "id1"; private static final String ID1 = "id1";
...@@ -68,19 +68,19 @@ public class DownloadManagerTest { ...@@ -68,19 +68,19 @@ public class DownloadManagerTest {
private DownloadManager downloadManager; private DownloadManager downloadManager;
private TestDownloadManagerListener downloadManagerListener; private TestDownloadManagerListener downloadManagerListener;
private DummyMainThread dummyMainThread; private DummyMainThread testThread;
@Before @Before
public void setUp() throws Exception { public void setUp() throws Exception {
ShadowLog.stream = System.out; ShadowLog.stream = System.out;
dummyMainThread = new DummyMainThread(); testThread = new DummyMainThread();
setupDownloadManager(/* maxParallelDownloads= */ 100); setupDownloadManager(/* maxParallelDownloads= */ 100);
} }
@After @After
public void tearDown() throws Exception { public void tearDown() throws Exception {
releaseDownloadManager(); releaseDownloadManager();
dummyMainThread.release(); testThread.release();
} }
@Test @Test
...@@ -728,7 +728,7 @@ public class DownloadManagerTest { ...@@ -728,7 +728,7 @@ public class DownloadManagerTest {
} }
private void runOnMainThread(TestRunnable r) { private void runOnMainThread(TestRunnable r) {
dummyMainThread.runTestOnMainThread(r); testThread.runTestOnMainThread(r);
} }
private FakeDownloader getDownloaderAt(int index) throws InterruptedException { private FakeDownloader getDownloaderAt(int index) throws InterruptedException {
......
...@@ -30,7 +30,7 @@ import com.google.android.exoplayer2.Timeline.Window; ...@@ -30,7 +30,7 @@ import com.google.android.exoplayer2.Timeline.Window;
import com.google.android.exoplayer2.drm.DrmSessionEventListener; import com.google.android.exoplayer2.drm.DrmSessionEventListener;
import com.google.android.exoplayer2.drm.DrmSessionManager; import com.google.android.exoplayer2.drm.DrmSessionManager;
import com.google.android.exoplayer2.source.ClippingMediaSource.IllegalClippingException; import com.google.android.exoplayer2.source.ClippingMediaSource.IllegalClippingException;
import com.google.android.exoplayer2.source.MaskingMediaSource.DummyTimeline; import com.google.android.exoplayer2.source.MaskingMediaSource.PlaceholderTimeline;
import com.google.android.exoplayer2.source.MediaSource.MediaPeriodId; import com.google.android.exoplayer2.source.MediaSource.MediaPeriodId;
import com.google.android.exoplayer2.testutil.FakeMediaPeriod; import com.google.android.exoplayer2.testutil.FakeMediaPeriod;
import com.google.android.exoplayer2.testutil.FakeMediaSource; import com.google.android.exoplayer2.testutil.FakeMediaSource;
...@@ -173,7 +173,7 @@ public final class ClippingMediaSourceTest { ...@@ -173,7 +173,7 @@ public final class ClippingMediaSourceTest {
// Timeline that's dynamic and not seekable. A child source might report such a timeline prior // Timeline that's dynamic and not seekable. A child source might report such a timeline prior
// to it having loaded sufficient data to establish its duration and seekability. Such timelines // to it having loaded sufficient data to establish its duration and seekability. Such timelines
// should not result in clipping failure. // should not result in clipping failure.
Timeline timeline = new DummyTimeline(MediaItem.fromUri(Uri.EMPTY)); Timeline timeline = new PlaceholderTimeline(MediaItem.fromUri(Uri.EMPTY));
Timeline clippedTimeline = Timeline clippedTimeline =
getClippedTimeline( getClippedTimeline(
......
...@@ -123,7 +123,7 @@ public final class SampleQueueTest { ...@@ -123,7 +123,7 @@ public final class SampleQueueTest {
private static final int[] ENCRYPTED_SAMPLE_OFFSETS = new int[] {7, 4, 3, 0}; private static final int[] ENCRYPTED_SAMPLE_OFFSETS = new int[] {7, 4, 3, 0};
private static final byte[] ENCRYPTED_SAMPLE_DATA = new byte[] {1, 1, 1, 1, 1, 1, 1, 1}; private static final byte[] ENCRYPTED_SAMPLE_DATA = new byte[] {1, 1, 1, 1, 1, 1, 1, 1};
private static final TrackOutput.CryptoData DUMMY_CRYPTO_DATA = private static final TrackOutput.CryptoData CRYPTO_DATA =
new TrackOutput.CryptoData(C.CRYPTO_MODE_AES_CTR, new byte[16], 0, 0); new TrackOutput.CryptoData(C.CRYPTO_MODE_AES_CTR, new byte[16], 0, 0);
private Allocator allocator; private Allocator allocator;
...@@ -1205,7 +1205,7 @@ public final class SampleQueueTest { ...@@ -1205,7 +1205,7 @@ public final class SampleQueueTest {
sampleFlags[i], sampleFlags[i],
sampleSizes[i], sampleSizes[i],
sampleOffsets[i], sampleOffsets[i],
(sampleFlags[i] & C.BUFFER_FLAG_ENCRYPTED) != 0 ? DUMMY_CRYPTO_DATA : null); (sampleFlags[i] & C.BUFFER_FLAG_ENCRYPTED) != 0 ? CRYPTO_DATA : null);
} }
} }
...@@ -1222,7 +1222,7 @@ public final class SampleQueueTest { ...@@ -1222,7 +1222,7 @@ public final class SampleQueueTest {
sampleFlags, sampleFlags,
data.length, data.length,
/* offset= */ 0, /* offset= */ 0,
(sampleFlags & C.BUFFER_FLAG_ENCRYPTED) != 0 ? DUMMY_CRYPTO_DATA : null); (sampleFlags & C.BUFFER_FLAG_ENCRYPTED) != 0 ? CRYPTO_DATA : null);
} }
/** /**
......
...@@ -569,7 +569,7 @@ public final class DefaultBandwidthMeterTest { ...@@ -569,7 +569,7 @@ public final class DefaultBandwidthMeterTest {
long[] bitrateEstimates = new long[SIMULATED_TRANSFER_COUNT]; long[] bitrateEstimates = new long[SIMULATED_TRANSFER_COUNT];
Random random = new Random(/* seed= */ 0); Random random = new Random(/* seed= */ 0);
DataSource dataSource = new FakeDataSource(); DataSource dataSource = new FakeDataSource();
DataSpec dataSpec = new DataSpec(Uri.parse("https://dummy.com")); DataSpec dataSpec = new DataSpec(Uri.parse("https://test.com"));
for (int i = 0; i < SIMULATED_TRANSFER_COUNT; i++) { for (int i = 0; i < SIMULATED_TRANSFER_COUNT; i++) {
bandwidthMeter.onTransferStart(dataSource, dataSpec, /* isNetwork= */ true); bandwidthMeter.onTransferStart(dataSource, dataSpec, /* isNetwork= */ true);
clock.advanceTime(random.nextInt(/* bound= */ 5000)); clock.advanceTime(random.nextInt(/* bound= */ 5000));
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment