Remove some occurrences of dummy in core library

Remove occurrences in comments and private fields.

ISSUE: #7565
PiperOrigin-RevId: 320606558
This commit is contained in:
kimvde 2020-07-10 16:23:35 +01:00 committed by kim-vde
parent a0703cb716
commit 702568c3b6
26 changed files with 228 additions and 216 deletions

View File

@ -54,7 +54,7 @@ import com.google.android.exoplayer2.Player;
import com.google.android.exoplayer2.Timeline;
import com.google.android.exoplayer2.Timeline.Period;
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.AdsLoader;
import com.google.android.exoplayer2.source.ads.AdsMediaSource.AdLoadException;
@ -170,7 +170,7 @@ public final class ImaAdsLoaderTest {
@Test
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);
imaAdsLoader.start(adsLoaderListener, adViewProvider);

View File

@ -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
// timeline has changed or is not ready and a suitable seek position could not be resolved.
Pair<MediaPeriodId, Long> firstPeriodAndPosition =
getDummyFirstMediaPeriodPosition(playbackInfo.timeline);
getPlaceholderFirstMediaPeriodPosition(playbackInfo.timeline);
periodId = firstPeriodAndPosition.first;
periodPositionUs = firstPeriodAndPosition.second;
requestedContentPosition = C.TIME_UNSET;
@ -1267,7 +1267,8 @@ import java.util.concurrent.atomic.AtomicBoolean;
boolean resetTrackInfo = clearMediaSourceList;
if (resetPosition) {
pendingInitialSeekPosition = null;
Pair<MediaPeriodId, Long> firstPeriodAndPosition = getDummyFirstMediaPeriodPosition(timeline);
Pair<MediaPeriodId, Long> firstPeriodAndPosition =
getPlaceholderFirstMediaPeriodPosition(timeline);
mediaPeriodId = firstPeriodAndPosition.first;
startPositionUs = firstPeriodAndPosition.second;
requestedContentPositionUs = C.TIME_UNSET;
@ -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()) {
return Pair.create(PlaybackInfo.getDummyPeriodForEmptyTimeline(), 0L);
}

View File

@ -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.
*/
private void disassociateNoSampleRenderersWithEmptySampleStream(
@ -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
* a dummy {@link EmptySampleStream}.
* an {@link EmptySampleStream}.
*/
private void associateNoSampleRenderersWithEmptySampleStream(
@NullableType SampleStream[] sampleStreams) {

View File

@ -28,10 +28,10 @@ import com.google.android.exoplayer2.trackselection.TrackSelectorResult;
/* package */ final class PlaybackInfo {
/**
* Dummy media period id used while the timeline is empty and no period id is specified. This id
* is used when playback infos are created with {@link #createDummy(TrackSelectorResult)}.
* Placeholder media period id used while the timeline is empty and no period id is specified.
* 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());
/** The current {@link Timeline}. */
@ -81,24 +81,24 @@ import com.google.android.exoplayer2.trackselection.TrackSelectorResult;
public volatile long positionUs;
/**
* Creates empty dummy playback info which can be used for masking as long as no real playback
* info is available.
* Creates an empty placeholder playback info which can be used for masking as long as no real
* playback info is available.
*
* @param emptyTrackSelectorResult An empty track selector result with null entries for each
* renderer.
* @return A dummy playback info.
* @return A placeholder playback info.
*/
public static PlaybackInfo createDummy(TrackSelectorResult emptyTrackSelectorResult) {
return new PlaybackInfo(
Timeline.EMPTY,
DUMMY_MEDIA_PERIOD_ID,
PLACEHOLDER_MEDIA_PERIOD_ID,
/* requestedContentPositionUs= */ C.TIME_UNSET,
Player.STATE_IDLE,
/* playbackError= */ null,
/* isLoading= */ false,
TrackGroupArray.EMPTY,
emptyTrackSelectorResult,
DUMMY_MEDIA_PERIOD_ID,
PLACEHOLDER_MEDIA_PERIOD_ID,
/* playWhenReady= */ false,
Player.PLAYBACK_SUPPRESSION_REASON_NONE,
/* bufferedPositionUs= */ 0,
@ -152,9 +152,9 @@ import com.google.android.exoplayer2.trackselection.TrackSelectorResult;
this.positionUs = positionUs;
}
/** Returns dummy period id for an empty timeline. */
/** Returns a placeholder period id for an empty timeline. */
public static MediaPeriodId getDummyPeriodForEmptyTimeline() {
return DUMMY_MEDIA_PERIOD_ID;
return PLACEHOLDER_MEDIA_PERIOD_ID;
}
/**

View File

@ -124,7 +124,7 @@ public abstract class Timeline {
*/
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()
.setMediaId("com.google.android.exoplayer2.Timeline")
.setUri(Uri.EMPTY)
@ -222,7 +222,7 @@ public abstract class Timeline {
/** Creates window. */
public Window() {
uid = SINGLE_WINDOW_UID;
mediaItem = DUMMY_MEDIA_ITEM;
mediaItem = EMPTY_MEDIA_ITEM;
}
/** Sets the data held by this window. */
@ -243,7 +243,7 @@ public abstract class Timeline {
int lastPeriodIndex,
long positionInFirstPeriodUs) {
this.uid = uid;
this.mediaItem = mediaItem != null ? mediaItem : DUMMY_MEDIA_ITEM;
this.mediaItem = mediaItem != null ? mediaItem : EMPTY_MEDIA_ITEM;
this.tag =
mediaItem != null && mediaItem.playbackProperties != null
? mediaItem.playbackProperties.tag

View File

@ -150,7 +150,7 @@ public final class PlaybackStatsListener
// 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
// separately from the player.
EventTime dummyEventTime =
sessionManager.finishAllSessions(
new EventTime(
SystemClock.elapsedRealtime(),
Timeline.EMPTY,
@ -161,8 +161,7 @@ public final class PlaybackStatsListener
/* currentWindowIndex= */ 0,
/* currentMediaPeriodId= */ null,
/* currentPlaybackPositionMs= */ 0,
/* totalBufferedDurationMs= */ 0);
sessionManager.finishAllSessions(dummyEventTime);
/* totalBufferedDurationMs= */ 0));
}
// PlaybackSessionManager.Listener implementation.

View File

@ -98,12 +98,12 @@ public interface AudioRendererEventListener {
@Nullable private final AudioRendererEventListener listener;
/**
* @param handler A handler for dispatching events, or null if creating a dummy instance.
* @param listener The listener to which events should be dispatched, 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 events should
* not be dispatched.
*/
public EventDispatcher(@Nullable Handler handler,
@Nullable AudioRendererEventListener listener) {
public EventDispatcher(
@Nullable Handler handler, @Nullable AudioRendererEventListener listener) {
this.handler = listener != null ? Assertions.checkNotNull(handler) : null;
this.listener = listener;
}

View File

@ -34,7 +34,7 @@ import java.util.UUID;
@RequiresApi(18)
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 DefaultDrmSessionManager drmSessionManager;
@ -202,7 +202,7 @@ public final class OfflineLicenseHelper {
throws DrmSessionException {
Assertions.checkNotNull(offlineLicenseKeySetId);
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 {
throws DrmSessionException {
Assertions.checkNotNull(offlineLicenseKeySetId);
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 {
drmSessionManager.prepare();
DrmSession drmSession =
openBlockingKeyRequest(
DefaultDrmSessionManager.MODE_QUERY, offlineLicenseKeySetId, DUMMY_DRM_INIT_DATA);
DefaultDrmSessionManager.MODE_QUERY, offlineLicenseKeySetId, EMPTY_DRM_INIT_DATA);
DrmSessionException error = drmSession.getError();
Pair<Long, Long> licenseDurationRemainingSec =
WidevineUtil.getLicenseDurationRemainingSec(drmSession);

View File

@ -500,7 +500,7 @@ public final class DownloadHelper {
new DefaultTrackSelector(trackSelectorParameters, new DownloadTrackSelection.Factory());
this.rendererCapabilities = rendererCapabilities;
this.scratchSet = new SparseIntArray();
trackSelector.init(/* listener= */ () -> {}, new DummyBandwidthMeter());
trackSelector.init(/* listener= */ () -> {}, new FakeBandwidthMeter());
callbackHandler = Util.createHandlerForCurrentOrMainLooper();
window = new Timeline.Window();
}
@ -1152,7 +1152,7 @@ public final class DownloadHelper {
}
}
private static final class DummyBandwidthMeter implements BandwidthMeter {
private static final class FakeBandwidthMeter implements BandwidthMeter {
@Override
public long getBitrateEstimate() {

View File

@ -56,7 +56,7 @@ public final class ConcatenatingMediaSource extends CompositeMediaSource<MediaSo
private static final int MSG_UPDATE_TIMELINE = 4;
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();
// Accessed on any thread.
@ -445,8 +445,8 @@ public final class ConcatenatingMediaSource extends CompositeMediaSource<MediaSo
@Override
public MediaItem getMediaItem() {
// 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.
return DUMMY_MEDIA_ITEM;
// MaskingMediaSource does not need to create a placeholder timeline for this media source.
return EMPTY_MEDIA_ITEM;
}
@Override
@ -476,7 +476,7 @@ public final class ConcatenatingMediaSource extends CompositeMediaSource<MediaSo
@Nullable MediaSourceHolder holder = mediaSourceByUid.get(mediaSourceHolderUid);
if (holder == null) {
// Stale event. The media source has already been removed.
holder = new MediaSourceHolder(new DummyMediaSource(), useLazyPreparation);
holder = new MediaSourceHolder(new FakeMediaSource(), useLazyPreparation);
holder.isRemoved = true;
prepareChildSource(holder, holder.mediaSource);
}
@ -988,8 +988,8 @@ public final class ConcatenatingMediaSource extends CompositeMediaSource<MediaSo
}
}
/** Dummy media source which does nothing and does not support creating periods. */
private static final class DummyMediaSource extends BaseMediaSource {
/** A media source which does nothing and does not support creating periods. */
private static final class FakeMediaSource extends BaseMediaSource {
@Override
protected void prepareSourceInternal(@Nullable TransferListener mediaTransferListener) {
@ -998,7 +998,7 @@ public final class ConcatenatingMediaSource extends CompositeMediaSource<MediaSo
@Override
public MediaItem getMediaItem() {
return DUMMY_MEDIA_ITEM;
return EMPTY_MEDIA_ITEM;
}
@Override

View File

@ -67,7 +67,7 @@ public final class MaskingMediaSource extends CompositeMediaSource<Void> {
initialTimeline, /* firstWindowUid= */ null, /* firstPeriodUid= */ null);
hasRealTimeline = true;
} else {
timeline = MaskingTimeline.createWithDummyTimeline(mediaSource.getMediaItem());
timeline = MaskingTimeline.createWithPlaceholderTimeline(mediaSource.getMediaItem());
}
}
@ -165,7 +165,9 @@ public final class MaskingMediaSource extends CompositeMediaSource<Void> {
hasRealTimeline
? timeline.cloneWithUpdatedTimeline(newTimeline)
: MaskingTimeline.createWithRealTimeline(
newTimeline, Window.SINGLE_WINDOW_UID, MaskingTimeline.DUMMY_EXTERNAL_PERIOD_UID);
newTimeline,
Window.SINGLE_WINDOW_UID,
MaskingTimeline.MASKING_EXTERNAL_PERIOD_UID);
} else {
// Determine first period and the start position.
// This will be:
@ -174,7 +176,7 @@ public final class MaskingMediaSource extends CompositeMediaSource<Void> {
// 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
// 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
// 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
@ -230,7 +232,7 @@ public final class MaskingMediaSource extends CompositeMediaSource<Void> {
private Object getInternalPeriodUid(Object externalPeriodUid) {
return timeline.replacedInternalPeriodUid != null
&& externalPeriodUid.equals(MaskingTimeline.DUMMY_EXTERNAL_PERIOD_UID)
&& externalPeriodUid.equals(MaskingTimeline.MASKING_EXTERNAL_PERIOD_UID)
? timeline.replacedInternalPeriodUid
: externalPeriodUid;
}
@ -238,7 +240,7 @@ public final class MaskingMediaSource extends CompositeMediaSource<Void> {
private Object getExternalPeriodUid(Object internalPeriodUid) {
return timeline.replacedInternalPeriodUid != null
&& timeline.replacedInternalPeriodUid.equals(internalPeriodUid)
? MaskingTimeline.DUMMY_EXTERNAL_PERIOD_UID
? MaskingTimeline.MASKING_EXTERNAL_PERIOD_UID
: internalPeriodUid;
}
@ -265,34 +267,36 @@ public final class MaskingMediaSource extends CompositeMediaSource<Void> {
/**
* 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 {
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 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}.
*/
public static MaskingTimeline createWithDummyTimeline(MediaItem mediaItem) {
public static MaskingTimeline createWithPlaceholderTimeline(MediaItem mediaItem) {
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
* assigned dummy period ID.
* assigned masking period ID.
*
* @param timeline The real timeline.
* @param firstWindowUid The window UID in the timeline which will be replaced by the already
* assigned {@link Window#SINGLE_WINDOW_UID}.
* @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(
Timeline timeline, @Nullable Object firstWindowUid, @Nullable Object firstPeriodUid) {
@ -335,7 +339,7 @@ public final class MaskingMediaSource extends CompositeMediaSource<Void> {
public Period getPeriod(int periodIndex, Period period, boolean setIds) {
timeline.getPeriod(periodIndex, period, setIds);
if (Util.areEqual(period.uid, replacedInternalPeriodUid) && setIds) {
period.uid = DUMMY_EXTERNAL_PERIOD_UID;
period.uid = MASKING_EXTERNAL_PERIOD_UID;
}
return period;
}
@ -343,7 +347,7 @@ public final class MaskingMediaSource extends CompositeMediaSource<Void> {
@Override
public int getIndexOfPeriod(Object uid) {
return timeline.getIndexOfPeriod(
DUMMY_EXTERNAL_PERIOD_UID.equals(uid) && replacedInternalPeriodUid != null
MASKING_EXTERNAL_PERIOD_UID.equals(uid) && replacedInternalPeriodUid != null
? replacedInternalPeriodUid
: uid);
}
@ -351,18 +355,18 @@ public final class MaskingMediaSource extends CompositeMediaSource<Void> {
@Override
public Object getUidOfPeriod(int 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
public static final class DummyTimeline extends Timeline {
public static final class PlaceholderTimeline extends Timeline {
private final MediaItem mediaItem;
/** Creates a new instance with the given media item. */
public DummyTimeline(MediaItem mediaItem) {
public PlaceholderTimeline(MediaItem mediaItem) {
this.mediaItem = mediaItem;
}
@ -402,7 +406,7 @@ public final class MaskingMediaSource extends CompositeMediaSource<Void> {
public Period getPeriod(int periodIndex, Period period, boolean setIds) {
return period.set(
/* id= */ setIds ? 0 : null,
/* uid= */ setIds ? MaskingTimeline.DUMMY_EXTERNAL_PERIOD_UID : null,
/* uid= */ setIds ? MaskingTimeline.MASKING_EXTERNAL_PERIOD_UID : null,
/* windowIndex= */ 0,
/* durationUs = */ C.TIME_UNSET,
/* positionInWindowUs= */ 0);
@ -410,12 +414,12 @@ public final class MaskingMediaSource extends CompositeMediaSource<Void> {
@Override
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
public Object getUidOfPeriod(int periodIndex) {
return MaskingTimeline.DUMMY_EXTERNAL_PERIOD_UID;
return MaskingTimeline.MASKING_EXTERNAL_PERIOD_UID;
}
}
}

View File

@ -93,8 +93,8 @@ public interface MediaSource {
public final int nextAdGroupIndex;
/**
* Creates a media period identifier for a dummy period which is not part of a buffered sequence
* of windows.
* Creates a media period identifier for a period which is not part of a buffered sequence of
* windows.
*
* @param periodUid The unique id of the timeline period.
*/
@ -248,8 +248,8 @@ public interface MediaSource {
void removeDrmEventListener(DrmSessionEventListener eventListener);
/**
* Returns the initial dummy timeline that is returned immediately when the real timeline is not
* yet known, or null to let the player create an initial timeline.
* Returns the initial placeholder timeline that is returned immediately when the real timeline is
* 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
* will use. It also must provide windows which are marked as dynamic to indicate that the window

View File

@ -66,7 +66,7 @@ public final class MergingMediaSource extends CompositeMediaSource<Integer> {
}
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();
private final boolean adjustPeriodTimeOffsets;
@ -137,7 +137,7 @@ public final class MergingMediaSource extends CompositeMediaSource<Integer> {
@Override
public MediaItem getMediaItem() {
return mediaSources.length > 0 ? mediaSources[0].getMediaItem() : DUMMY_MEDIA_ITEM;
return mediaSources.length > 0 ? mediaSources[0].getMediaItem() : EMPTY_MEDIA_ITEM;
}
@Override

View File

@ -121,7 +121,7 @@ public final class AdsMediaSource extends CompositeMediaSource<MediaPeriodId> {
}
// 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());
private final MediaSource contentMediaSource;
@ -203,7 +203,7 @@ public final class AdsMediaSource extends CompositeMediaSource<MediaPeriodId> {
super.prepareSourceInternal(mediaTransferListener);
ComponentListener componentListener = new ComponentListener();
this.componentListener = componentListener;
prepareChildSource(DUMMY_CONTENT_MEDIA_PERIOD_ID, contentMediaSource);
prepareChildSource(CHILD_SOURCE_MEDIA_PERIOD_ID, contentMediaSource);
mainHandler.post(() -> adsLoader.start(componentListener, adViewProvider));
}
@ -284,8 +284,8 @@ public final class AdsMediaSource extends CompositeMediaSource<MediaPeriodId> {
@Override
protected MediaPeriodId getMediaPeriodIdForChildMediaPeriodId(
MediaPeriodId childId, MediaPeriodId mediaPeriodId) {
// The child id for the content period is just DUMMY_CONTENT_MEDIA_PERIOD_ID. That's why we need
// to forward the reported mediaPeriodId in this case.
// The child id for the content period is just CHILD_SOURCE_MEDIA_PERIOD_ID. That's why
// we need to forward the reported mediaPeriodId in this case.
return childId.isAd() ? childId : mediaPeriodId;
}

View File

@ -41,7 +41,7 @@ import org.checkerframework.checker.nullness.qual.MonotonicNonNull;
*/
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 int primaryTrackType;
@ -106,7 +106,7 @@ public final class BundledChunkExtractor implements ExtractorOutput, ChunkExtrac
@Override
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);
return result == Extractor.RESULT_CONTINUE;
}
@ -149,7 +149,7 @@ public final class BundledChunkExtractor implements ExtractorOutput, ChunkExtrac
private final int id;
private final int type;
@Nullable private final Format manifestFormat;
private final DummyTrackOutput dummyTrackOutput;
private final DummyTrackOutput fakeTrackOutput;
public @MonotonicNonNull Format sampleFormat;
private @MonotonicNonNull TrackOutput trackOutput;
@ -159,12 +159,12 @@ public final class BundledChunkExtractor implements ExtractorOutput, ChunkExtrac
this.id = id;
this.type = type;
this.manifestFormat = manifestFormat;
dummyTrackOutput = new DummyTrackOutput();
fakeTrackOutput = new DummyTrackOutput();
}
public void bind(@Nullable TrackOutputProvider trackOutputProvider, long endTimeUs) {
if (trackOutputProvider == null) {
trackOutput = dummyTrackOutput;
trackOutput = fakeTrackOutput;
return;
}
this.endTimeUs = endTimeUs;
@ -201,7 +201,7 @@ public final class BundledChunkExtractor implements ExtractorOutput, ChunkExtrac
int offset,
@Nullable CryptoData cryptoData) {
if (endTimeUs != C.TIME_UNSET && timeUs >= endTimeUs) {
trackOutput = dummyTrackOutput;
trackOutput = fakeTrackOutput;
}
castNonNull(trackOutput).sampleMetadata(timeUs, flags, size, offset, cryptoData);
}

View File

@ -19,9 +19,7 @@ import android.net.Uri;
import androidx.annotation.Nullable;
import java.io.IOException;
/**
* A dummy DataSource which provides no data. {@link #open(DataSpec)} throws {@link IOException}.
*/
/** A DataSource which provides no data. {@link #open(DataSpec)} throws {@link IOException}. */
public final class DummyDataSource implements DataSource {
public static final DummyDataSource INSTANCE = new DummyDataSource();
@ -38,7 +36,7 @@ public final class DummyDataSource implements DataSource {
@Override
public long open(DataSpec dataSpec) throws IOException {
throw new IOException("Dummy source");
throw new IOException("DummyDataSource cannot be opened");
}
@Override

View File

@ -22,7 +22,6 @@ import static com.google.android.exoplayer2.util.EGLSurfaceTexture.SECURE_MODE_S
import android.content.Context;
import android.graphics.SurfaceTexture;
import android.os.Handler;
import android.os.Handler.Callback;
import android.os.HandlerThread;
import android.os.Message;
import android.view.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}
* 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 secure Whether a secure surface is required. Must only be requested if
* {@link #isSecureSupported(Context)} returns {@code true}.
* @throws IllegalStateException If a secure surface is requested on a device for which
* {@link #isSecureSupported(Context)} returns {@code false}.
* @param secure Whether a secure surface is required. Must only be requested if {@link
* #isSecureSupported(Context)} returns {@code true}.
* @throws IllegalStateException If a secure surface is requested on a device for which {@link
* #isSecureSupported(Context)} returns {@code false}.
*/
public static DummySurface newInstanceV17(Context context, boolean secure) {
Assertions.checkState(!secure || isSecureSupported(context));
@ -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_RELEASE = 2;

View File

@ -138,12 +138,12 @@ public interface VideoRendererEventListener {
@Nullable private final VideoRendererEventListener listener;
/**
* @param handler A handler for dispatching events, or null if creating a dummy instance.
* @param listener The listener to which events should be dispatched, 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 events should
* not be dispatched.
*/
public EventDispatcher(@Nullable Handler handler,
@Nullable VideoRendererEventListener listener) {
public EventDispatcher(
@Nullable Handler handler, @Nullable VideoRendererEventListener listener) {
this.handler = listener != null ? Assertions.checkNotNull(handler) : null;
this.listener = listener;
}

View File

@ -126,13 +126,13 @@ public final class ExoPlayerTest {
private static final int TIMEOUT_MS = 10_000;
private Context context;
private Timeline dummyTimeline;
private Timeline placeholderTimeline;
@Before
public void setUp() {
context = ApplicationProvider.getApplicationContext();
dummyTimeline =
new MaskingMediaSource.DummyTimeline(
placeholderTimeline =
new MaskingMediaSource.PlaceholderTimeline(
FakeTimeline.FAKE_MEDIA_ITEM.buildUpon().setTag(0).build());
}
@ -144,7 +144,7 @@ public final class ExoPlayerTest {
public void playEmptyTimeline() throws Exception {
Timeline timeline = Timeline.EMPTY;
Timeline expectedMaskingTimeline =
new MaskingMediaSource.DummyTimeline(FakeMediaSource.FAKE_MEDIA_ITEM);
new MaskingMediaSource.PlaceholderTimeline(FakeMediaSource.FAKE_MEDIA_ITEM);
FakeRenderer renderer = new FakeRenderer(C.TRACK_TYPE_UNKNOWN);
ExoPlayerTestRunner testRunner =
new ExoPlayerTestRunner.Builder(context)
@ -178,7 +178,7 @@ public final class ExoPlayerTest {
.start()
.blockUntilEnded(TIMEOUT_MS);
testRunner.assertNoPositionDiscontinuities();
testRunner.assertTimelinesSame(dummyTimeline, timeline);
testRunner.assertTimelinesSame(placeholderTimeline, timeline);
testRunner.assertTimelineChangeReasonsEqual(
Player.TIMELINE_CHANGE_REASON_PLAYLIST_CHANGED,
Player.TIMELINE_CHANGE_REASON_SOURCE_UPDATE);
@ -234,7 +234,7 @@ public final class ExoPlayerTest {
Integer[] expectedReasons = new Integer[99];
Arrays.fill(expectedReasons, Player.DISCONTINUITY_REASON_PERIOD_TRANSITION);
testRunner.assertPositionDiscontinuityReasonsEqual(expectedReasons);
testRunner.assertTimelinesSame(dummyTimeline, timeline);
testRunner.assertTimelinesSame(placeholderTimeline, timeline);
testRunner.assertTimelineChangeReasonsEqual(
Player.TIMELINE_CHANGE_REASON_PLAYLIST_CHANGED,
Player.TIMELINE_CHANGE_REASON_SOURCE_UPDATE);
@ -382,11 +382,15 @@ public final class ExoPlayerTest {
.blockUntilEnded(TIMEOUT_MS);
testRunner.assertNoPositionDiscontinuities();
// The first source's preparation completed with a real timeline. When the second source was
// prepared, it immediately exposed a dummy timeline, but the source info refresh from the
// prepared, it immediately exposed a placeholder timeline, but the source info refresh from the
// second source was suppressed as we replace it with the third source before the update
// arrives.
testRunner.assertTimelinesSame(
dummyTimeline, firstTimeline, dummyTimeline, dummyTimeline, thirdTimeline);
placeholderTimeline,
firstTimeline,
placeholderTimeline,
placeholderTimeline,
thirdTimeline);
testRunner.assertTimelineChangeReasonsEqual(
Player.TIMELINE_CHANGE_REASON_PLAYLIST_CHANGED,
Player.TIMELINE_CHANGE_REASON_SOURCE_UPDATE,
@ -881,7 +885,7 @@ public final class ExoPlayerTest {
.build()
.start()
.blockUntilEnded(TIMEOUT_MS);
testRunner.assertTimelinesSame(dummyTimeline, timeline, timeline2);
testRunner.assertTimelinesSame(placeholderTimeline, timeline, timeline2);
testRunner.assertTimelineChangeReasonsEqual(
Player.TIMELINE_CHANGE_REASON_PLAYLIST_CHANGED,
Player.TIMELINE_CHANGE_REASON_SOURCE_UPDATE,
@ -1083,7 +1087,7 @@ public final class ExoPlayerTest {
.start()
.blockUntilActionScheduleFinished(TIMEOUT_MS)
.blockUntilEnded(TIMEOUT_MS);
testRunner.assertTimelinesSame(dummyTimeline, timeline);
testRunner.assertTimelinesSame(placeholderTimeline, timeline);
testRunner.assertTimelineChangeReasonsEqual(
Player.TIMELINE_CHANGE_REASON_PLAYLIST_CHANGED,
Player.TIMELINE_CHANGE_REASON_SOURCE_UPDATE);
@ -1117,7 +1121,7 @@ public final class ExoPlayerTest {
.start()
.blockUntilActionScheduleFinished(TIMEOUT_MS)
.blockUntilEnded(TIMEOUT_MS);
testRunner.assertTimelinesSame(dummyTimeline, timeline);
testRunner.assertTimelinesSame(placeholderTimeline, timeline);
testRunner.assertTimelineChangeReasonsEqual(
Player.TIMELINE_CHANGE_REASON_PLAYLIST_CHANGED,
Player.TIMELINE_CHANGE_REASON_SOURCE_UPDATE);
@ -1151,7 +1155,7 @@ public final class ExoPlayerTest {
.start()
.blockUntilActionScheduleFinished(TIMEOUT_MS)
.blockUntilEnded(TIMEOUT_MS);
testRunner.assertTimelinesSame(dummyTimeline, timeline, Timeline.EMPTY);
testRunner.assertTimelinesSame(placeholderTimeline, timeline, Timeline.EMPTY);
testRunner.assertTimelineChangeReasonsEqual(
Player.TIMELINE_CHANGE_REASON_PLAYLIST_CHANGED,
Player.TIMELINE_CHANGE_REASON_SOURCE_UPDATE,
@ -1244,7 +1248,7 @@ public final class ExoPlayerTest {
Player.STATE_READY,
Player.STATE_ENDED);
testRunner.assertTimelinesSame(
dummyTimeline,
placeholderTimeline,
timeline,
Timeline.EMPTY,
new FakeMediaSource.InitialTimeline(secondTimeline),
@ -1267,14 +1271,14 @@ public final class ExoPlayerTest {
new FakeTimeline(
new TimelineWindowDefinition(/* periodCount= */ 1, /* id= */ firstWindowId));
Timeline firstExpectedMaskingTimeline =
new MaskingMediaSource.DummyTimeline(
new MaskingMediaSource.PlaceholderTimeline(
FakeTimeline.FAKE_MEDIA_ITEM.buildUpon().setTag(firstWindowId).build());
Object secondWindowId = new Object();
Timeline secondTimeline =
new FakeTimeline(
new TimelineWindowDefinition(/* periodCount= */ 1, /* id= */ secondWindowId));
Timeline secondExpectedMaskingTimeline =
new MaskingMediaSource.DummyTimeline(
new MaskingMediaSource.PlaceholderTimeline(
FakeTimeline.FAKE_MEDIA_ITEM.buildUpon().setTag(secondWindowId).build());
MediaSource secondSource = new FakeMediaSource(secondTimeline);
AtomicLong positionAfterReprepare = new AtomicLong();
@ -1320,15 +1324,15 @@ public final class ExoPlayerTest {
Timeline timeline =
new FakeTimeline(
new TimelineWindowDefinition(/* periodCount= */ 1, /* id= */ firstWindowId));
Timeline firstExpectedDummyTimeline =
new MaskingMediaSource.DummyTimeline(
Timeline firstExpectedPlaceholderTimeline =
new MaskingMediaSource.PlaceholderTimeline(
FakeTimeline.FAKE_MEDIA_ITEM.buildUpon().setTag(firstWindowId).build());
Object secondWindowId = new Object();
Timeline secondTimeline =
new FakeTimeline(
new TimelineWindowDefinition(/* periodCount= */ 1, /* id= */ secondWindowId));
Timeline secondExpectedDummyTimeline =
new MaskingMediaSource.DummyTimeline(
Timeline secondExpectedPlaceholderTimeline =
new MaskingMediaSource.PlaceholderTimeline(
FakeTimeline.FAKE_MEDIA_ITEM.buildUpon().setTag(secondWindowId).build());
MediaSource secondSource = new FakeMediaSource(secondTimeline);
AtomicLong positionAfterReprepare = new AtomicLong();
@ -1359,7 +1363,10 @@ public final class ExoPlayerTest {
.blockUntilEnded(TIMEOUT_MS);
testRunner.assertTimelinesSame(
firstExpectedDummyTimeline, timeline, secondExpectedDummyTimeline, secondTimeline);
firstExpectedPlaceholderTimeline,
timeline,
secondExpectedPlaceholderTimeline,
secondTimeline);
testRunner.assertTimelineChangeReasonsEqual(
Player.TIMELINE_CHANGE_REASON_PLAYLIST_CHANGED,
Player.TIMELINE_CHANGE_REASON_SOURCE_UPDATE,
@ -1374,15 +1381,15 @@ public final class ExoPlayerTest {
Timeline timeline =
new FakeTimeline(
new TimelineWindowDefinition(/* periodCount= */ 1, /* id= */ firstWindowId));
Timeline firstExpectedDummyTimeline =
new MaskingMediaSource.DummyTimeline(
Timeline firstExpectedPlaceholderTimeline =
new MaskingMediaSource.PlaceholderTimeline(
FakeTimeline.FAKE_MEDIA_ITEM.buildUpon().setTag(firstWindowId).build());
Object secondWindowId = new Object();
Timeline secondTimeline =
new FakeTimeline(
new TimelineWindowDefinition(/* periodCount= */ 1, /* id= */ secondWindowId));
Timeline secondExpectedDummyTimeline =
new MaskingMediaSource.DummyTimeline(
Timeline secondExpectedPlaceholderTimeline =
new MaskingMediaSource.PlaceholderTimeline(
FakeTimeline.FAKE_MEDIA_ITEM.buildUpon().setTag(secondWindowId).build());
MediaSource secondSource = new FakeMediaSource(secondTimeline);
AtomicLong positionAfterReprepare = new AtomicLong();
@ -1413,7 +1420,10 @@ public final class ExoPlayerTest {
.blockUntilEnded(TIMEOUT_MS);
testRunner.assertTimelinesSame(
firstExpectedDummyTimeline, timeline, secondExpectedDummyTimeline, secondTimeline);
firstExpectedPlaceholderTimeline,
timeline,
secondExpectedPlaceholderTimeline,
secondTimeline);
testRunner.assertTimelineChangeReasonsEqual(
Player.TIMELINE_CHANGE_REASON_PLAYLIST_CHANGED,
Player.TIMELINE_CHANGE_REASON_SOURCE_UPDATE,
@ -1439,7 +1449,7 @@ public final class ExoPlayerTest {
.start()
.blockUntilActionScheduleFinished(TIMEOUT_MS)
.blockUntilEnded(TIMEOUT_MS);
testRunner.assertTimelinesSame(dummyTimeline, Timeline.EMPTY);
testRunner.assertTimelinesSame(placeholderTimeline, Timeline.EMPTY);
testRunner.assertTimelineChangeReasonsEqual(
Player.TIMELINE_CHANGE_REASON_PLAYLIST_CHANGED,
Player.TIMELINE_CHANGE_REASON_PLAYLIST_CHANGED);
@ -1465,7 +1475,7 @@ public final class ExoPlayerTest {
.start()
.blockUntilActionScheduleFinished(TIMEOUT_MS)
.blockUntilEnded(TIMEOUT_MS);
testRunner.assertTimelinesSame(dummyTimeline, timeline);
testRunner.assertTimelinesSame(placeholderTimeline, timeline);
testRunner.assertTimelineChangeReasonsEqual(
Player.TIMELINE_CHANGE_REASON_PLAYLIST_CHANGED,
Player.TIMELINE_CHANGE_REASON_SOURCE_UPDATE);
@ -1493,7 +1503,7 @@ public final class ExoPlayerTest {
} catch (ExoPlaybackException e) {
// Expected exception.
}
testRunner.assertTimelinesSame(dummyTimeline, timeline);
testRunner.assertTimelinesSame(placeholderTimeline, timeline);
testRunner.assertTimelineChangeReasonsEqual(
Player.TIMELINE_CHANGE_REASON_PLAYLIST_CHANGED,
Player.TIMELINE_CHANGE_REASON_SOURCE_UPDATE);
@ -1542,7 +1552,7 @@ public final class ExoPlayerTest {
.start()
.blockUntilActionScheduleFinished(TIMEOUT_MS)
.blockUntilEnded(TIMEOUT_MS));
testRunner.assertTimelinesSame(dummyTimeline, timeline);
testRunner.assertTimelinesSame(placeholderTimeline, timeline);
testRunner.assertTimelineChangeReasonsEqual(
Player.TIMELINE_CHANGE_REASON_PLAYLIST_CHANGED,
Player.TIMELINE_CHANGE_REASON_SOURCE_UPDATE);
@ -1821,7 +1831,7 @@ public final class ExoPlayerTest {
} catch (ExoPlaybackException e) {
// Expected exception.
}
testRunner.assertTimelinesSame(dummyTimeline, timeline, dummyTimeline, timeline);
testRunner.assertTimelinesSame(placeholderTimeline, timeline, placeholderTimeline, timeline);
testRunner.assertTimelineChangeReasonsEqual(
Player.TIMELINE_CHANGE_REASON_PLAYLIST_CHANGED,
Player.TIMELINE_CHANGE_REASON_SOURCE_UPDATE,
@ -3840,7 +3850,7 @@ public final class ExoPlayerTest {
Timeline timeline2 = new FakeTimeline(secondWindowDefinition);
MediaSource mediaSource1 = new FakeMediaSource(timeline1);
MediaSource mediaSource2 = new FakeMediaSource(timeline2);
Timeline expectedDummyTimeline =
Timeline expectedPlaceholderTimeline =
new FakeTimeline(
TimelineWindowDefinition.createDummy(/* tag= */ 1),
TimelineWindowDefinition.createDummy(/* tag= */ 2));
@ -3867,7 +3877,7 @@ public final class ExoPlayerTest {
Player.TIMELINE_CHANGE_REASON_SOURCE_UPDATE,
Player.TIMELINE_CHANGE_REASON_PLAYLIST_CHANGED);
exoPlayerTestRunner.assertTimelinesSame(
expectedDummyTimeline, expectedRealTimeline, expectedRealTimelineAfterMove);
expectedPlaceholderTimeline, expectedRealTimeline, expectedRealTimelineAfterMove);
}
@Test
@ -3913,7 +3923,7 @@ public final class ExoPlayerTest {
.blockUntilActionScheduleFinished(TIMEOUT_MS)
.blockUntilEnded(TIMEOUT_MS);
Timeline expectedDummyTimeline =
Timeline expectedPlaceholderTimeline =
new FakeTimeline(
TimelineWindowDefinition.createDummy(/* tag= */ 1),
TimelineWindowDefinition.createDummy(/* tag= */ 2),
@ -3927,7 +3937,7 @@ public final class ExoPlayerTest {
Player.TIMELINE_CHANGE_REASON_SOURCE_UPDATE,
Player.TIMELINE_CHANGE_REASON_PLAYLIST_CHANGED);
exoPlayerTestRunner.assertTimelinesSame(
expectedDummyTimeline, expectedRealTimeline, expectedRealTimelineAfterRemove);
expectedPlaceholderTimeline, expectedRealTimeline, expectedRealTimelineAfterRemove);
}
@Test
@ -3973,7 +3983,7 @@ public final class ExoPlayerTest {
.blockUntilActionScheduleFinished(TIMEOUT_MS)
.blockUntilEnded(TIMEOUT_MS);
Timeline expectedDummyTimeline =
Timeline expectedPlaceholderTimeline =
new FakeTimeline(
TimelineWindowDefinition.createDummy(/* tag= */ 1),
TimelineWindowDefinition.createDummy(/* tag= */ 2),
@ -3986,7 +3996,7 @@ public final class ExoPlayerTest {
Player.TIMELINE_CHANGE_REASON_SOURCE_UPDATE,
Player.TIMELINE_CHANGE_REASON_PLAYLIST_CHANGED);
exoPlayerTestRunner.assertTimelinesSame(
expectedDummyTimeline, expectedRealTimeline, expectedRealTimelineAfterRemove);
expectedPlaceholderTimeline, expectedRealTimeline, expectedRealTimelineAfterRemove);
}
@Test
@ -4010,7 +4020,7 @@ public final class ExoPlayerTest {
exoPlayerTestRunner.assertPlaybackStatesEqual(
Player.STATE_BUFFERING, Player.STATE_READY, Player.STATE_ENDED);
exoPlayerTestRunner.assertTimelinesSame(dummyTimeline, timeline, Timeline.EMPTY);
exoPlayerTestRunner.assertTimelinesSame(placeholderTimeline, timeline, Timeline.EMPTY);
exoPlayerTestRunner.assertTimelineChangeReasonsEqual(
Player.TIMELINE_CHANGE_REASON_PLAYLIST_CHANGED /* media item set (masked timeline) */,
Player.TIMELINE_CHANGE_REASON_SOURCE_UPDATE /* source prepared */,
@ -4040,7 +4050,7 @@ public final class ExoPlayerTest {
.blockUntilEnded(TIMEOUT_MS);
exoPlayerTestRunner.assertTimelinesSame(
dummyTimeline,
placeholderTimeline,
timeline,
Timeline.EMPTY,
new FakeMediaSource.InitialTimeline(secondTimeline),
@ -4064,7 +4074,8 @@ public final class ExoPlayerTest {
int[] maskingPlaybackState = {C.INDEX_UNSET};
ActionSchedule actionSchedule =
new ActionSchedule.Builder(TAG)
.waitForTimelineChanged(dummyTimeline, Player.TIMELINE_CHANGE_REASON_PLAYLIST_CHANGED)
.waitForTimelineChanged(
placeholderTimeline, Player.TIMELINE_CHANGE_REASON_PLAYLIST_CHANGED)
.executeRunnable(
new PlaybackStateCollector(/* index= */ 0, playbackStates, timelineWindowCounts))
.clearMediaItems()
@ -4113,7 +4124,7 @@ public final class ExoPlayerTest {
Player.TIMELINE_CHANGE_REASON_PLAYLIST_CHANGED /* set media items */,
Player.TIMELINE_CHANGE_REASON_PLAYLIST_CHANGED /* add media items */,
Player.TIMELINE_CHANGE_REASON_SOURCE_UPDATE /* source update after prepare */);
Timeline expectedSecondDummyTimeline =
Timeline expectedSecondPlaceholderTimeline =
new FakeTimeline(
TimelineWindowDefinition.createDummy(/* tag= */ 0),
TimelineWindowDefinition.createDummy(/* tag= */ 0));
@ -4132,10 +4143,10 @@ public final class ExoPlayerTest {
/* isDynamic= */ false,
/* durationUs= */ 10_000_000));
exoPlayerTestRunner.assertTimelinesSame(
dummyTimeline,
placeholderTimeline,
Timeline.EMPTY,
dummyTimeline,
expectedSecondDummyTimeline,
placeholderTimeline,
expectedSecondPlaceholderTimeline,
expectedSecondRealTimeline);
assertArrayEquals(new int[] {Player.STATE_IDLE}, maskingPlaybackState);
}
@ -4179,13 +4190,13 @@ public final class ExoPlayerTest {
Player.STATE_READY,
Player.STATE_ENDED);
exoPlayerTestRunner.assertTimelinesSame(
dummyTimeline,
placeholderTimeline,
timeline,
Timeline.EMPTY,
dummyTimeline,
placeholderTimeline,
timeline,
Timeline.EMPTY,
dummyTimeline,
placeholderTimeline,
timeline);
exoPlayerTestRunner.assertTimelineChangeReasonsEqual(
Player.TIMELINE_CHANGE_REASON_PLAYLIST_CHANGED /* media item set (masked timeline) */,
@ -4242,7 +4253,7 @@ public final class ExoPlayerTest {
Player.STATE_READY,
Player.STATE_ENDED);
exoPlayerTestRunner.assertTimelinesSame(
dummyTimeline, timeline, Timeline.EMPTY, dummyTimeline, timeline);
placeholderTimeline, timeline, Timeline.EMPTY, placeholderTimeline, timeline);
exoPlayerTestRunner.assertTimelineChangeReasonsEqual(
Player.TIMELINE_CHANGE_REASON_PLAYLIST_CHANGED /* media item set (masked timeline) */,
Player.TIMELINE_CHANGE_REASON_SOURCE_UPDATE, /* source prepared */
@ -4298,7 +4309,7 @@ public final class ExoPlayerTest {
exoPlayerTestRunner.assertPlaybackStatesEqual(
Player.STATE_BUFFERING, Player.STATE_READY, Player.STATE_ENDED);
exoPlayerTestRunner.assertTimelinesSame(dummyTimeline, timeline);
exoPlayerTestRunner.assertTimelinesSame(placeholderTimeline, timeline);
exoPlayerTestRunner.assertTimelineChangeReasonsEqual(
Player.TIMELINE_CHANGE_REASON_PLAYLIST_CHANGED /* media item set (masked timeline) */,
Player.TIMELINE_CHANGE_REASON_SOURCE_UPDATE /* source prepared */);
@ -4558,8 +4569,8 @@ public final class ExoPlayerTest {
new FakeMediaSource(new FakeTimeline(/* windowCount= */ 1)),
new DefaultDataSourceFactory(
context, Util.getUserAgent(context, ExoPlayerLibraryInfo.VERSION_SLASHY)),
new DummyAdsLoader(),
new DummyAdViewProvider());
new FakeAdsLoader(),
new FakeAdViewProvider());
Exception[] exception = {null};
ActionSchedule actionSchedule =
new ActionSchedule.Builder(TAG)
@ -4596,8 +4607,8 @@ public final class ExoPlayerTest {
mediaSource,
new DefaultDataSourceFactory(
context, Util.getUserAgent(context, ExoPlayerLibraryInfo.VERSION_SLASHY)),
new DummyAdsLoader(),
new DummyAdViewProvider());
new FakeAdsLoader(),
new FakeAdViewProvider());
final Exception[] exception = {null};
ActionSchedule actionSchedule =
new ActionSchedule.Builder(TAG)
@ -4636,8 +4647,8 @@ public final class ExoPlayerTest {
mediaSource,
new DefaultDataSourceFactory(
context, Util.getUserAgent(context, ExoPlayerLibraryInfo.VERSION_SLASHY)),
new DummyAdsLoader(),
new DummyAdViewProvider());
new FakeAdsLoader(),
new FakeAdViewProvider());
final Exception[] exception = {null};
ActionSchedule actionSchedule =
new ActionSchedule.Builder(TAG)
@ -6471,7 +6482,7 @@ public final class ExoPlayerTest {
@Override
public boolean continueLoading(long positionUs) {
loader.startLoading(
loadable, new DummyLoaderCallback(), /* defaultMinRetryCount= */ 1);
loadable, new FakeLoaderCallback(), /* defaultMinRetryCount= */ 1);
return true;
}
@ -6862,7 +6873,7 @@ public final class ExoPlayerTest {
}
}
private static final class DummyLoaderCallback implements Loader.Callback<Loader.Loadable> {
private static final class FakeLoaderCallback implements Loader.Callback<Loader.Loadable> {
@Override
public void onLoadCompleted(
Loader.Loadable loadable, long elapsedRealtimeMs, long loadDurationMs) {}
@ -6882,7 +6893,7 @@ public final class ExoPlayerTest {
}
}
private static class DummyAdsLoader implements AdsLoader {
private static class FakeAdsLoader implements AdsLoader {
@Override
public void setPlayer(@Nullable Player player) {}
@ -6903,7 +6914,7 @@ public final class ExoPlayerTest {
public void handlePrepareError(int adGroupIndex, int adIndexInAdGroup, IOException exception) {}
}
private static class DummyAdViewProvider implements AdsLoader.AdViewProvider {
private static class FakeAdViewProvider implements AdsLoader.AdViewProvider {
@Override
public ViewGroup getAdViewGroup() {

View File

@ -786,7 +786,7 @@ public final class AnalyticsCollectorTest {
assertThat(listener.getEvents(EVENT_TIMELINE_CHANGED))
.containsExactly(
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) */)
.inOrder();
assertThat(listener.getEvents(EVENT_LOADING_CHANGED))

View File

@ -94,7 +94,7 @@ public class VersionTableTest {
@Test
public void doesTableExist_existingTable_returnsTrue() {
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();
}
}

View File

@ -56,7 +56,7 @@ public class DownloadManagerTest {
private static final int APP_STOP_REASON = 1;
/** The minimum number of times a download must be retried before failing. */
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 String ID1 = "id1";
@ -68,19 +68,19 @@ public class DownloadManagerTest {
private DownloadManager downloadManager;
private TestDownloadManagerListener downloadManagerListener;
private DummyMainThread dummyMainThread;
private DummyMainThread testThread;
@Before
public void setUp() throws Exception {
ShadowLog.stream = System.out;
dummyMainThread = new DummyMainThread();
testThread = new DummyMainThread();
setupDownloadManager(/* maxParallelDownloads= */ 100);
}
@After
public void tearDown() throws Exception {
releaseDownloadManager();
dummyMainThread.release();
testThread.release();
}
@Test
@ -728,7 +728,7 @@ public class DownloadManagerTest {
}
private void runOnMainThread(TestRunnable r) {
dummyMainThread.runTestOnMainThread(r);
testThread.runTestOnMainThread(r);
}
private FakeDownloader getDownloaderAt(int index) throws InterruptedException {

View File

@ -30,7 +30,7 @@ import com.google.android.exoplayer2.Timeline.Window;
import com.google.android.exoplayer2.drm.DrmSessionEventListener;
import com.google.android.exoplayer2.drm.DrmSessionManager;
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.testutil.FakeMediaPeriod;
import com.google.android.exoplayer2.testutil.FakeMediaSource;
@ -173,7 +173,7 @@ public final class ClippingMediaSourceTest {
// 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
// should not result in clipping failure.
Timeline timeline = new DummyTimeline(MediaItem.fromUri(Uri.EMPTY));
Timeline timeline = new PlaceholderTimeline(MediaItem.fromUri(Uri.EMPTY));
Timeline clippedTimeline =
getClippedTimeline(

View File

@ -408,15 +408,15 @@ public final class ConcatenatingMediaSourceTest {
public void customCallbackBeforePreparationAddSingle() throws Exception {
CountDownLatch runnableInvoked = new CountDownLatch(1);
DummyMainThread dummyMainThread = new DummyMainThread();
dummyMainThread.runOnMainThread(
DummyMainThread testThread = new DummyMainThread();
testThread.runOnMainThread(
() ->
mediaSource.addMediaSource(
createFakeMediaSource(),
Util.createHandlerForCurrentLooper(),
runnableInvoked::countDown));
runnableInvoked.await(MediaSourceTestRunner.TIMEOUT_MS, TimeUnit.MILLISECONDS);
dummyMainThread.release();
testThread.release();
assertThat(runnableInvoked.getCount()).isEqualTo(0);
}
@ -425,15 +425,15 @@ public final class ConcatenatingMediaSourceTest {
public void customCallbackBeforePreparationAddMultiple() throws Exception {
CountDownLatch runnableInvoked = new CountDownLatch(1);
DummyMainThread dummyMainThread = new DummyMainThread();
dummyMainThread.runOnMainThread(
DummyMainThread testThread = new DummyMainThread();
testThread.runOnMainThread(
() ->
mediaSource.addMediaSources(
Arrays.asList(new MediaSource[] {createFakeMediaSource(), createFakeMediaSource()}),
Util.createHandlerForCurrentLooper(),
runnableInvoked::countDown));
runnableInvoked.await(MediaSourceTestRunner.TIMEOUT_MS, TimeUnit.MILLISECONDS);
dummyMainThread.release();
testThread.release();
assertThat(runnableInvoked.getCount()).isEqualTo(0);
}
@ -442,8 +442,8 @@ public final class ConcatenatingMediaSourceTest {
public void customCallbackBeforePreparationAddSingleWithIndex() throws Exception {
CountDownLatch runnableInvoked = new CountDownLatch(1);
DummyMainThread dummyMainThread = new DummyMainThread();
dummyMainThread.runOnMainThread(
DummyMainThread testThread = new DummyMainThread();
testThread.runOnMainThread(
() ->
mediaSource.addMediaSource(
/* index */ 0,
@ -451,7 +451,7 @@ public final class ConcatenatingMediaSourceTest {
Util.createHandlerForCurrentLooper(),
runnableInvoked::countDown));
runnableInvoked.await(MediaSourceTestRunner.TIMEOUT_MS, TimeUnit.MILLISECONDS);
dummyMainThread.release();
testThread.release();
assertThat(runnableInvoked.getCount()).isEqualTo(0);
}
@ -460,8 +460,8 @@ public final class ConcatenatingMediaSourceTest {
public void customCallbackBeforePreparationAddMultipleWithIndex() throws Exception {
CountDownLatch runnableInvoked = new CountDownLatch(1);
DummyMainThread dummyMainThread = new DummyMainThread();
dummyMainThread.runOnMainThread(
DummyMainThread testThread = new DummyMainThread();
testThread.runOnMainThread(
() ->
mediaSource.addMediaSources(
/* index */ 0,
@ -469,7 +469,7 @@ public final class ConcatenatingMediaSourceTest {
Util.createHandlerForCurrentLooper(),
runnableInvoked::countDown));
runnableInvoked.await(MediaSourceTestRunner.TIMEOUT_MS, TimeUnit.MILLISECONDS);
dummyMainThread.release();
testThread.release();
assertThat(runnableInvoked.getCount()).isEqualTo(0);
}
@ -478,15 +478,15 @@ public final class ConcatenatingMediaSourceTest {
public void customCallbackBeforePreparationRemove() throws Exception {
CountDownLatch runnableInvoked = new CountDownLatch(1);
DummyMainThread dummyMainThread = new DummyMainThread();
dummyMainThread.runOnMainThread(
DummyMainThread testThread = new DummyMainThread();
testThread.runOnMainThread(
() -> {
mediaSource.addMediaSource(createFakeMediaSource());
mediaSource.removeMediaSource(
/* index */ 0, Util.createHandlerForCurrentLooper(), runnableInvoked::countDown);
});
runnableInvoked.await(MediaSourceTestRunner.TIMEOUT_MS, TimeUnit.MILLISECONDS);
dummyMainThread.release();
testThread.release();
assertThat(runnableInvoked.getCount()).isEqualTo(0);
}
@ -495,8 +495,8 @@ public final class ConcatenatingMediaSourceTest {
public void customCallbackBeforePreparationMove() throws Exception {
CountDownLatch runnableInvoked = new CountDownLatch(1);
DummyMainThread dummyMainThread = new DummyMainThread();
dummyMainThread.runOnMainThread(
DummyMainThread testThread = new DummyMainThread();
testThread.runOnMainThread(
() -> {
mediaSource.addMediaSources(
Arrays.asList(new MediaSource[] {createFakeMediaSource(), createFakeMediaSource()}));
@ -507,35 +507,35 @@ public final class ConcatenatingMediaSourceTest {
runnableInvoked::countDown);
});
runnableInvoked.await(MediaSourceTestRunner.TIMEOUT_MS, TimeUnit.MILLISECONDS);
dummyMainThread.release();
testThread.release();
assertThat(runnableInvoked.getCount()).isEqualTo(0);
}
@Test
public void customCallbackAfterPreparationAddSingle() throws Exception {
DummyMainThread dummyMainThread = new DummyMainThread();
DummyMainThread testThread = new DummyMainThread();
try {
testRunner.prepareSource();
final TimelineGrabber timelineGrabber = new TimelineGrabber(testRunner);
dummyMainThread.runOnMainThread(
testThread.runOnMainThread(
() ->
mediaSource.addMediaSource(
createFakeMediaSource(), Util.createHandlerForCurrentLooper(), timelineGrabber));
Timeline timeline = timelineGrabber.assertTimelineChangeBlocking();
assertThat(timeline.getWindowCount()).isEqualTo(1);
} finally {
dummyMainThread.release();
testThread.release();
}
}
@Test
public void customCallbackAfterPreparationAddMultiple() throws Exception {
DummyMainThread dummyMainThread = new DummyMainThread();
DummyMainThread testThread = new DummyMainThread();
try {
testRunner.prepareSource();
final TimelineGrabber timelineGrabber = new TimelineGrabber(testRunner);
dummyMainThread.runOnMainThread(
testThread.runOnMainThread(
() ->
mediaSource.addMediaSources(
Arrays.asList(
@ -545,17 +545,17 @@ public final class ConcatenatingMediaSourceTest {
Timeline timeline = timelineGrabber.assertTimelineChangeBlocking();
assertThat(timeline.getWindowCount()).isEqualTo(2);
} finally {
dummyMainThread.release();
testThread.release();
}
}
@Test
public void customCallbackAfterPreparationAddSingleWithIndex() throws Exception {
DummyMainThread dummyMainThread = new DummyMainThread();
DummyMainThread testThread = new DummyMainThread();
try {
testRunner.prepareSource();
final TimelineGrabber timelineGrabber = new TimelineGrabber(testRunner);
dummyMainThread.runOnMainThread(
testThread.runOnMainThread(
() ->
mediaSource.addMediaSource(
/* index */ 0,
@ -565,17 +565,17 @@ public final class ConcatenatingMediaSourceTest {
Timeline timeline = timelineGrabber.assertTimelineChangeBlocking();
assertThat(timeline.getWindowCount()).isEqualTo(1);
} finally {
dummyMainThread.release();
testThread.release();
}
}
@Test
public void customCallbackAfterPreparationAddMultipleWithIndex() throws Exception {
DummyMainThread dummyMainThread = new DummyMainThread();
DummyMainThread testThread = new DummyMainThread();
try {
testRunner.prepareSource();
final TimelineGrabber timelineGrabber = new TimelineGrabber(testRunner);
dummyMainThread.runOnMainThread(
testThread.runOnMainThread(
() ->
mediaSource.addMediaSources(
/* index */ 0,
@ -586,36 +586,36 @@ public final class ConcatenatingMediaSourceTest {
Timeline timeline = timelineGrabber.assertTimelineChangeBlocking();
assertThat(timeline.getWindowCount()).isEqualTo(2);
} finally {
dummyMainThread.release();
testThread.release();
}
}
@Test
public void customCallbackAfterPreparationRemove() throws Exception {
DummyMainThread dummyMainThread = new DummyMainThread();
DummyMainThread testThread = new DummyMainThread();
try {
testRunner.prepareSource();
dummyMainThread.runOnMainThread(() -> mediaSource.addMediaSource(createFakeMediaSource()));
testThread.runOnMainThread(() -> mediaSource.addMediaSource(createFakeMediaSource()));
testRunner.assertTimelineChangeBlocking();
final TimelineGrabber timelineGrabber = new TimelineGrabber(testRunner);
dummyMainThread.runOnMainThread(
testThread.runOnMainThread(
() ->
mediaSource.removeMediaSource(
/* index */ 0, Util.createHandlerForCurrentLooper(), timelineGrabber));
Timeline timeline = timelineGrabber.assertTimelineChangeBlocking();
assertThat(timeline.getWindowCount()).isEqualTo(0);
} finally {
dummyMainThread.release();
testThread.release();
}
}
@Test
public void customCallbackAfterPreparationMove() throws Exception {
DummyMainThread dummyMainThread = new DummyMainThread();
DummyMainThread testThread = new DummyMainThread();
try {
testRunner.prepareSource();
dummyMainThread.runOnMainThread(
testThread.runOnMainThread(
() ->
mediaSource.addMediaSources(
Arrays.asList(
@ -623,7 +623,7 @@ public final class ConcatenatingMediaSourceTest {
testRunner.assertTimelineChangeBlocking();
final TimelineGrabber timelineGrabber = new TimelineGrabber(testRunner);
dummyMainThread.runOnMainThread(
testThread.runOnMainThread(
() ->
mediaSource.moveMediaSource(
/* fromIndex */ 1, /* toIndex */
@ -633,16 +633,16 @@ public final class ConcatenatingMediaSourceTest {
Timeline timeline = timelineGrabber.assertTimelineChangeBlocking();
assertThat(timeline.getWindowCount()).isEqualTo(2);
} finally {
dummyMainThread.release();
testThread.release();
}
}
@Test
public void customCallbackIsCalledAfterRelease() throws Exception {
DummyMainThread dummyMainThread = new DummyMainThread();
DummyMainThread testThread = new DummyMainThread();
CountDownLatch callbackCalledCondition = new CountDownLatch(1);
try {
dummyMainThread.runOnMainThread(
testThread.runOnMainThread(
() -> {
MediaSourceCaller caller = mock(MediaSourceCaller.class);
mediaSource.addMediaSources(Arrays.asList(createMediaSources(2)));
@ -659,7 +659,7 @@ public final class ConcatenatingMediaSourceTest {
MediaSourceTestRunner.TIMEOUT_MS, TimeUnit.MILLISECONDS))
.isTrue();
} finally {
dummyMainThread.release();
testThread.release();
}
}
@ -891,10 +891,10 @@ public final class ConcatenatingMediaSourceTest {
@Test
public void clear() throws Exception {
DummyMainThread dummyMainThread = new DummyMainThread();
DummyMainThread testThread = new DummyMainThread();
final FakeMediaSource preparedChildSource = createFakeMediaSource();
final FakeMediaSource unpreparedChildSource = new FakeMediaSource(/* timeline= */ null);
dummyMainThread.runOnMainThread(
testThread.runOnMainThread(
() -> {
mediaSource.addMediaSource(preparedChildSource);
mediaSource.addMediaSource(unpreparedChildSource);
@ -902,7 +902,7 @@ public final class ConcatenatingMediaSourceTest {
testRunner.prepareSource();
final TimelineGrabber timelineGrabber = new TimelineGrabber(testRunner);
dummyMainThread.runOnMainThread(
testThread.runOnMainThread(
() -> mediaSource.clear(Util.createHandlerForCurrentLooper(), timelineGrabber));
Timeline timeline = timelineGrabber.assertTimelineChangeBlocking();
@ -1050,28 +1050,28 @@ public final class ConcatenatingMediaSourceTest {
public void customCallbackBeforePreparationSetShuffleOrder() throws Exception {
CountDownLatch runnableInvoked = new CountDownLatch(1);
DummyMainThread dummyMainThread = new DummyMainThread();
dummyMainThread.runOnMainThread(
DummyMainThread testThread = new DummyMainThread();
testThread.runOnMainThread(
() ->
mediaSource.setShuffleOrder(
new ShuffleOrder.UnshuffledShuffleOrder(/* length= */ 0),
Util.createHandlerForCurrentLooper(),
runnableInvoked::countDown));
runnableInvoked.await(MediaSourceTestRunner.TIMEOUT_MS, TimeUnit.MILLISECONDS);
dummyMainThread.release();
testThread.release();
assertThat(runnableInvoked.getCount()).isEqualTo(0);
}
@Test
public void customCallbackAfterPreparationSetShuffleOrder() throws Exception {
DummyMainThread dummyMainThread = new DummyMainThread();
DummyMainThread testThread = new DummyMainThread();
try {
mediaSource.addMediaSources(
Arrays.asList(createFakeMediaSource(), createFakeMediaSource(), createFakeMediaSource()));
testRunner.prepareSource();
TimelineGrabber timelineGrabber = new TimelineGrabber(testRunner);
dummyMainThread.runOnMainThread(
testThread.runOnMainThread(
() ->
mediaSource.setShuffleOrder(
new ShuffleOrder.UnshuffledShuffleOrder(/* length= */ 3),
@ -1080,7 +1080,7 @@ public final class ConcatenatingMediaSourceTest {
Timeline timeline = timelineGrabber.assertTimelineChangeBlocking();
assertThat(timeline.getFirstWindowIndex(/* shuffleModeEnabled= */ true)).isEqualTo(0);
} finally {
dummyMainThread.release();
testThread.release();
}
}

View File

@ -123,7 +123,7 @@ public final class SampleQueueTest {
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 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);
private Allocator allocator;
@ -1205,7 +1205,7 @@ public final class SampleQueueTest {
sampleFlags[i],
sampleSizes[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 {
sampleFlags,
data.length,
/* offset= */ 0,
(sampleFlags & C.BUFFER_FLAG_ENCRYPTED) != 0 ? DUMMY_CRYPTO_DATA : null);
(sampleFlags & C.BUFFER_FLAG_ENCRYPTED) != 0 ? CRYPTO_DATA : null);
}
/**

View File

@ -569,7 +569,7 @@ public final class DefaultBandwidthMeterTest {
long[] bitrateEstimates = new long[SIMULATED_TRANSFER_COUNT];
Random random = new Random(/* seed= */ 0);
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++) {
bandwidthMeter.onTransferStart(dataSource, dataSpec, /* isNetwork= */ true);
clock.advanceTime(random.nextInt(/* bound= */ 5000));