Commit 45433869 by olly Committed by Oliver Woodman

Rename ExtractorMediaSource to ProgressiveMediaSource

It better describes what the class does. More importantly, we've had
inconsistent class names since we added offline support, for which we
added ProgressiveDownloader ("ExtractorDownloader" doesn't make any
sense). We could really do with aligning the names for clarity.

(Sorry)

PiperOrigin-RevId: 231387268
parent ef8335fc
...@@ -2,6 +2,7 @@ ...@@ -2,6 +2,7 @@
### dev-v2 (not yet released) ### ### dev-v2 (not yet released) ###
* `ExtractorMediaSource` renamed to `ProgressiveMediaSource`.
* HLS: * HLS:
* Parse CHANNELS attribute from EXT-X-MEDIA. * Parse CHANNELS attribute from EXT-X-MEDIA.
* Support for playing spherical videos on Daydream. * Support for playing spherical videos on Daydream.
......
...@@ -35,8 +35,8 @@ import com.google.android.exoplayer2.ext.cast.CastPlayer; ...@@ -35,8 +35,8 @@ import com.google.android.exoplayer2.ext.cast.CastPlayer;
import com.google.android.exoplayer2.ext.cast.MediaItem; import com.google.android.exoplayer2.ext.cast.MediaItem;
import com.google.android.exoplayer2.ext.cast.SessionAvailabilityListener; import com.google.android.exoplayer2.ext.cast.SessionAvailabilityListener;
import com.google.android.exoplayer2.source.ConcatenatingMediaSource; import com.google.android.exoplayer2.source.ConcatenatingMediaSource;
import com.google.android.exoplayer2.source.ExtractorMediaSource;
import com.google.android.exoplayer2.source.MediaSource; import com.google.android.exoplayer2.source.MediaSource;
import com.google.android.exoplayer2.source.ProgressiveMediaSource;
import com.google.android.exoplayer2.source.dash.DashMediaSource; import com.google.android.exoplayer2.source.dash.DashMediaSource;
import com.google.android.exoplayer2.source.hls.HlsMediaSource; import com.google.android.exoplayer2.source.hls.HlsMediaSource;
import com.google.android.exoplayer2.source.smoothstreaming.SsMediaSource; import com.google.android.exoplayer2.source.smoothstreaming.SsMediaSource;
...@@ -373,7 +373,7 @@ import java.util.ArrayList; ...@@ -373,7 +373,7 @@ import java.util.ArrayList;
case DemoUtil.MIME_TYPE_HLS: case DemoUtil.MIME_TYPE_HLS:
return new HlsMediaSource.Factory(DATA_SOURCE_FACTORY).createMediaSource(uri); return new HlsMediaSource.Factory(DATA_SOURCE_FACTORY).createMediaSource(uri);
case DemoUtil.MIME_TYPE_VIDEO_MP4: case DemoUtil.MIME_TYPE_VIDEO_MP4:
return new ExtractorMediaSource.Factory(DATA_SOURCE_FACTORY).createMediaSource(uri); return new ProgressiveMediaSource.Factory(DATA_SOURCE_FACTORY).createMediaSource(uri);
default: { default: {
throw new IllegalStateException("Unsupported type: " + item.mimeType); throw new IllegalStateException("Unsupported type: " + item.mimeType);
} }
......
...@@ -23,8 +23,8 @@ import com.google.android.exoplayer2.ExoPlayer; ...@@ -23,8 +23,8 @@ import com.google.android.exoplayer2.ExoPlayer;
import com.google.android.exoplayer2.ExoPlayerFactory; import com.google.android.exoplayer2.ExoPlayerFactory;
import com.google.android.exoplayer2.SimpleExoPlayer; import com.google.android.exoplayer2.SimpleExoPlayer;
import com.google.android.exoplayer2.ext.ima.ImaAdsLoader; import com.google.android.exoplayer2.ext.ima.ImaAdsLoader;
import com.google.android.exoplayer2.source.ExtractorMediaSource;
import com.google.android.exoplayer2.source.MediaSource; import com.google.android.exoplayer2.source.MediaSource;
import com.google.android.exoplayer2.source.ProgressiveMediaSource;
import com.google.android.exoplayer2.source.ads.AdsMediaSource; import com.google.android.exoplayer2.source.ads.AdsMediaSource;
import com.google.android.exoplayer2.source.dash.DashMediaSource; import com.google.android.exoplayer2.source.dash.DashMediaSource;
import com.google.android.exoplayer2.source.hls.HlsMediaSource; import com.google.android.exoplayer2.source.hls.HlsMediaSource;
...@@ -125,7 +125,7 @@ import com.google.android.exoplayer2.util.Util; ...@@ -125,7 +125,7 @@ import com.google.android.exoplayer2.util.Util;
case C.TYPE_HLS: case C.TYPE_HLS:
return new HlsMediaSource.Factory(dataSourceFactory).createMediaSource(uri); return new HlsMediaSource.Factory(dataSourceFactory).createMediaSource(uri);
case C.TYPE_OTHER: case C.TYPE_OTHER:
return new ExtractorMediaSource.Factory(dataSourceFactory).createMediaSource(uri); return new ProgressiveMediaSource.Factory(dataSourceFactory).createMediaSource(uri);
default: default:
throw new IllegalStateException("Unsupported type: " + type); throw new IllegalStateException("Unsupported type: " + type);
} }
......
...@@ -51,8 +51,8 @@ import com.google.android.exoplayer2.mediacodec.MediaCodecUtil.DecoderQueryExcep ...@@ -51,8 +51,8 @@ import com.google.android.exoplayer2.mediacodec.MediaCodecUtil.DecoderQueryExcep
import com.google.android.exoplayer2.offline.StreamKey; import com.google.android.exoplayer2.offline.StreamKey;
import com.google.android.exoplayer2.source.BehindLiveWindowException; import com.google.android.exoplayer2.source.BehindLiveWindowException;
import com.google.android.exoplayer2.source.ConcatenatingMediaSource; import com.google.android.exoplayer2.source.ConcatenatingMediaSource;
import com.google.android.exoplayer2.source.ExtractorMediaSource;
import com.google.android.exoplayer2.source.MediaSource; import com.google.android.exoplayer2.source.MediaSource;
import com.google.android.exoplayer2.source.ProgressiveMediaSource;
import com.google.android.exoplayer2.source.TrackGroupArray; import com.google.android.exoplayer2.source.TrackGroupArray;
import com.google.android.exoplayer2.source.ads.AdsLoader; import com.google.android.exoplayer2.source.ads.AdsLoader;
import com.google.android.exoplayer2.source.ads.AdsMediaSource; import com.google.android.exoplayer2.source.ads.AdsMediaSource;
...@@ -483,7 +483,7 @@ public class PlayerActivity extends Activity ...@@ -483,7 +483,7 @@ public class PlayerActivity extends Activity
.setStreamKeys(offlineStreamKeys) .setStreamKeys(offlineStreamKeys)
.createMediaSource(uri); .createMediaSource(uri);
case C.TYPE_OTHER: case C.TYPE_OTHER:
return new ExtractorMediaSource.Factory(dataSourceFactory).createMediaSource(uri); return new ProgressiveMediaSource.Factory(dataSourceFactory).createMediaSource(uri);
default: { default: {
throw new IllegalStateException("Unsupported type: " + type); throw new IllegalStateException("Unsupported type: " + type);
} }
......
...@@ -28,8 +28,8 @@ import com.google.android.exoplayer2.ExoPlayerFactory; ...@@ -28,8 +28,8 @@ import com.google.android.exoplayer2.ExoPlayerFactory;
import com.google.android.exoplayer2.Player; import com.google.android.exoplayer2.Player;
import com.google.android.exoplayer2.Renderer; import com.google.android.exoplayer2.Renderer;
import com.google.android.exoplayer2.extractor.mkv.MatroskaExtractor; import com.google.android.exoplayer2.extractor.mkv.MatroskaExtractor;
import com.google.android.exoplayer2.source.ExtractorMediaSource;
import com.google.android.exoplayer2.source.MediaSource; import com.google.android.exoplayer2.source.MediaSource;
import com.google.android.exoplayer2.source.ProgressiveMediaSource;
import com.google.android.exoplayer2.trackselection.DefaultTrackSelector; import com.google.android.exoplayer2.trackselection.DefaultTrackSelector;
import com.google.android.exoplayer2.upstream.DefaultDataSourceFactory; import com.google.android.exoplayer2.upstream.DefaultDataSourceFactory;
import org.junit.Before; import org.junit.Before;
...@@ -86,7 +86,7 @@ public class FlacPlaybackTest { ...@@ -86,7 +86,7 @@ public class FlacPlaybackTest {
player = ExoPlayerFactory.newInstance(context, new Renderer[] {audioRenderer}, trackSelector); player = ExoPlayerFactory.newInstance(context, new Renderer[] {audioRenderer}, trackSelector);
player.addListener(this); player.addListener(this);
MediaSource mediaSource = MediaSource mediaSource =
new ExtractorMediaSource.Factory( new ProgressiveMediaSource.Factory(
new DefaultDataSourceFactory(context, "ExoPlayerExtFlacTest")) new DefaultDataSourceFactory(context, "ExoPlayerExtFlacTest"))
.setExtractorsFactory(MatroskaExtractor.FACTORY) .setExtractorsFactory(MatroskaExtractor.FACTORY)
.createMediaSource(uri); .createMediaSource(uri);
......
...@@ -28,8 +28,8 @@ import com.google.android.exoplayer2.ExoPlayerFactory; ...@@ -28,8 +28,8 @@ import com.google.android.exoplayer2.ExoPlayerFactory;
import com.google.android.exoplayer2.Player; import com.google.android.exoplayer2.Player;
import com.google.android.exoplayer2.Renderer; import com.google.android.exoplayer2.Renderer;
import com.google.android.exoplayer2.extractor.mkv.MatroskaExtractor; import com.google.android.exoplayer2.extractor.mkv.MatroskaExtractor;
import com.google.android.exoplayer2.source.ExtractorMediaSource;
import com.google.android.exoplayer2.source.MediaSource; import com.google.android.exoplayer2.source.MediaSource;
import com.google.android.exoplayer2.source.ProgressiveMediaSource;
import com.google.android.exoplayer2.trackselection.DefaultTrackSelector; import com.google.android.exoplayer2.trackselection.DefaultTrackSelector;
import com.google.android.exoplayer2.upstream.DefaultDataSourceFactory; import com.google.android.exoplayer2.upstream.DefaultDataSourceFactory;
import org.junit.Before; import org.junit.Before;
...@@ -86,7 +86,7 @@ public class OpusPlaybackTest { ...@@ -86,7 +86,7 @@ public class OpusPlaybackTest {
player = ExoPlayerFactory.newInstance(context, new Renderer[] {audioRenderer}, trackSelector); player = ExoPlayerFactory.newInstance(context, new Renderer[] {audioRenderer}, trackSelector);
player.addListener(this); player.addListener(this);
MediaSource mediaSource = MediaSource mediaSource =
new ExtractorMediaSource.Factory( new ProgressiveMediaSource.Factory(
new DefaultDataSourceFactory(context, "ExoPlayerExtOpusTest")) new DefaultDataSourceFactory(context, "ExoPlayerExtOpusTest"))
.setExtractorsFactory(MatroskaExtractor.FACTORY) .setExtractorsFactory(MatroskaExtractor.FACTORY)
.createMediaSource(uri); .createMediaSource(uri);
......
...@@ -29,8 +29,8 @@ import com.google.android.exoplayer2.ExoPlayerFactory; ...@@ -29,8 +29,8 @@ import com.google.android.exoplayer2.ExoPlayerFactory;
import com.google.android.exoplayer2.Player; import com.google.android.exoplayer2.Player;
import com.google.android.exoplayer2.Renderer; import com.google.android.exoplayer2.Renderer;
import com.google.android.exoplayer2.extractor.mkv.MatroskaExtractor; import com.google.android.exoplayer2.extractor.mkv.MatroskaExtractor;
import com.google.android.exoplayer2.source.ExtractorMediaSource;
import com.google.android.exoplayer2.source.MediaSource; import com.google.android.exoplayer2.source.MediaSource;
import com.google.android.exoplayer2.source.ProgressiveMediaSource;
import com.google.android.exoplayer2.trackselection.DefaultTrackSelector; import com.google.android.exoplayer2.trackselection.DefaultTrackSelector;
import com.google.android.exoplayer2.upstream.DefaultDataSourceFactory; import com.google.android.exoplayer2.upstream.DefaultDataSourceFactory;
import com.google.android.exoplayer2.util.Log; import com.google.android.exoplayer2.util.Log;
...@@ -119,7 +119,7 @@ public class VpxPlaybackTest { ...@@ -119,7 +119,7 @@ public class VpxPlaybackTest {
player = ExoPlayerFactory.newInstance(context, new Renderer[] {videoRenderer}, trackSelector); player = ExoPlayerFactory.newInstance(context, new Renderer[] {videoRenderer}, trackSelector);
player.addListener(this); player.addListener(this);
MediaSource mediaSource = MediaSource mediaSource =
new ExtractorMediaSource.Factory( new ProgressiveMediaSource.Factory(
new DefaultDataSourceFactory(context, "ExoPlayerExtVp9Test")) new DefaultDataSourceFactory(context, "ExoPlayerExtVp9Test"))
.setExtractorsFactory(MatroskaExtractor.FACTORY) .setExtractorsFactory(MatroskaExtractor.FACTORY)
.createMediaSource(uri); .createMediaSource(uri);
......
...@@ -21,10 +21,10 @@ import com.google.android.exoplayer2.audio.MediaCodecAudioRenderer; ...@@ -21,10 +21,10 @@ import com.google.android.exoplayer2.audio.MediaCodecAudioRenderer;
import com.google.android.exoplayer2.metadata.MetadataRenderer; import com.google.android.exoplayer2.metadata.MetadataRenderer;
import com.google.android.exoplayer2.source.ClippingMediaSource; import com.google.android.exoplayer2.source.ClippingMediaSource;
import com.google.android.exoplayer2.source.ConcatenatingMediaSource; import com.google.android.exoplayer2.source.ConcatenatingMediaSource;
import com.google.android.exoplayer2.source.ExtractorMediaSource;
import com.google.android.exoplayer2.source.LoopingMediaSource; import com.google.android.exoplayer2.source.LoopingMediaSource;
import com.google.android.exoplayer2.source.MediaSource; import com.google.android.exoplayer2.source.MediaSource;
import com.google.android.exoplayer2.source.MergingMediaSource; import com.google.android.exoplayer2.source.MergingMediaSource;
import com.google.android.exoplayer2.source.ProgressiveMediaSource;
import com.google.android.exoplayer2.source.SingleSampleMediaSource; import com.google.android.exoplayer2.source.SingleSampleMediaSource;
import com.google.android.exoplayer2.text.TextRenderer; import com.google.android.exoplayer2.text.TextRenderer;
import com.google.android.exoplayer2.trackselection.DefaultTrackSelector; import com.google.android.exoplayer2.trackselection.DefaultTrackSelector;
...@@ -48,7 +48,7 @@ import com.google.android.exoplayer2.video.MediaCodecVideoRenderer; ...@@ -48,7 +48,7 @@ import com.google.android.exoplayer2.video.MediaCodecVideoRenderer;
* <li>A <b>{@link MediaSource}</b> that defines the media to be played, loads the media, and from * <li>A <b>{@link MediaSource}</b> that defines the media to be played, loads the media, and from
* which the loaded media can be read. A MediaSource is injected via {@link * which the loaded media can be read. A MediaSource is injected via {@link
* #prepare(MediaSource)} at the start of playback. The library modules provide default * #prepare(MediaSource)} at the start of playback. The library modules provide default
* implementations for regular media files ({@link ExtractorMediaSource}), DASH * implementations for progressive media files ({@link ProgressiveMediaSource}), DASH
* (DashMediaSource), SmoothStreaming (SsMediaSource) and HLS (HlsMediaSource), an * (DashMediaSource), SmoothStreaming (SsMediaSource) and HLS (HlsMediaSource), an
* implementation for loading single media samples ({@link SingleSampleMediaSource}) that's * implementation for loading single media samples ({@link SingleSampleMediaSource}) that's
* most often used for side-loaded subtitle files, and implementations for building more * most often used for side-loaded subtitle files, and implementations for building more
......
...@@ -20,6 +20,7 @@ import android.os.Handler; ...@@ -20,6 +20,7 @@ import android.os.Handler;
import android.support.annotation.Nullable; import android.support.annotation.Nullable;
import com.google.android.exoplayer2.C; import com.google.android.exoplayer2.C;
import com.google.android.exoplayer2.Player; import com.google.android.exoplayer2.Player;
import com.google.android.exoplayer2.Timeline;
import com.google.android.exoplayer2.extractor.DefaultExtractorsFactory; import com.google.android.exoplayer2.extractor.DefaultExtractorsFactory;
import com.google.android.exoplayer2.extractor.Extractor; import com.google.android.exoplayer2.extractor.Extractor;
import com.google.android.exoplayer2.extractor.ExtractorsFactory; import com.google.android.exoplayer2.extractor.ExtractorsFactory;
...@@ -32,25 +33,13 @@ import com.google.android.exoplayer2.upstream.TransferListener; ...@@ -32,25 +33,13 @@ import com.google.android.exoplayer2.upstream.TransferListener;
import com.google.android.exoplayer2.util.Assertions; import com.google.android.exoplayer2.util.Assertions;
import java.io.IOException; import java.io.IOException;
/** /** @deprecated Use {@link ProgressiveMediaSource} instead. */
* Provides one period that loads data from a {@link Uri} and extracted using an {@link Extractor}. @Deprecated
* @SuppressWarnings("deprecation")
* <p>If the possible input stream container formats are known, pass a factory that instantiates
* extractors for them to the constructor. Otherwise, pass a {@link DefaultExtractorsFactory} to use
* the default extractors. When reading a new stream, the first {@link Extractor} in the array of
* extractors created by the factory that returns {@code true} from {@link Extractor#sniff} will be
* used to extract samples from the input stream.
*
* <p>Note that the built-in extractors for AAC, MPEG PS/TS and FLV streams do not support seeking.
*/
public final class ExtractorMediaSource extends BaseMediaSource public final class ExtractorMediaSource extends BaseMediaSource
implements ExtractorMediaPeriod.Listener { implements MediaSource.SourceInfoRefreshListener {
/** /** @deprecated Use {@link MediaSourceEventListener} instead. */
* Listener of {@link ExtractorMediaSource} events.
*
* @deprecated Use {@link MediaSourceEventListener}.
*/
@Deprecated @Deprecated
public interface EventListener { public interface EventListener {
...@@ -70,7 +59,8 @@ public final class ExtractorMediaSource extends BaseMediaSource ...@@ -70,7 +59,8 @@ public final class ExtractorMediaSource extends BaseMediaSource
} }
/** Factory for {@link ExtractorMediaSource}s. */ /** Use {@link ProgressiveMediaSource.Factory} instead. */
@Deprecated
public static final class Factory implements AdsMediaSource.MediaSourceFactory { public static final class Factory implements AdsMediaSource.MediaSourceFactory {
private final DataSource.Factory dataSourceFactory; private final DataSource.Factory dataSourceFactory;
...@@ -232,23 +222,11 @@ public final class ExtractorMediaSource extends BaseMediaSource ...@@ -232,23 +222,11 @@ public final class ExtractorMediaSource extends BaseMediaSource
} }
} }
/** @Deprecated
* The default number of bytes that should be loaded between each each invocation of {@link public static final int DEFAULT_LOADING_CHECK_INTERVAL_BYTES =
* MediaPeriod.Callback#onContinueLoadingRequested(SequenceableLoader)}. ProgressiveMediaSource.DEFAULT_LOADING_CHECK_INTERVAL_BYTES;
*/
public static final int DEFAULT_LOADING_CHECK_INTERVAL_BYTES = 1024 * 1024;
private final Uri uri;
private final DataSource.Factory dataSourceFactory;
private final ExtractorsFactory extractorsFactory;
private final LoadErrorHandlingPolicy loadableLoadErrorHandlingPolicy;
private final String customCacheKey;
private final int continueLoadingCheckIntervalBytes;
private final @Nullable Object tag;
private long timelineDurationUs; private final ProgressiveMediaSource progressiveMediaSource;
private boolean timelineIsSeekable;
private @Nullable TransferListener transferListener;
/** /**
* @param uri The {@link Uri} of the media stream. * @param uri The {@link Uri} of the media stream.
...@@ -261,7 +239,6 @@ public final class ExtractorMediaSource extends BaseMediaSource ...@@ -261,7 +239,6 @@ public final class ExtractorMediaSource extends BaseMediaSource
* @deprecated Use {@link Factory} instead. * @deprecated Use {@link Factory} instead.
*/ */
@Deprecated @Deprecated
@SuppressWarnings("deprecation")
public ExtractorMediaSource( public ExtractorMediaSource(
Uri uri, Uri uri,
DataSource.Factory dataSourceFactory, DataSource.Factory dataSourceFactory,
...@@ -284,7 +261,6 @@ public final class ExtractorMediaSource extends BaseMediaSource ...@@ -284,7 +261,6 @@ public final class ExtractorMediaSource extends BaseMediaSource
* @deprecated Use {@link Factory} instead. * @deprecated Use {@link Factory} instead.
*/ */
@Deprecated @Deprecated
@SuppressWarnings("deprecation")
public ExtractorMediaSource( public ExtractorMediaSource(
Uri uri, Uri uri,
DataSource.Factory dataSourceFactory, DataSource.Factory dataSourceFactory,
...@@ -317,7 +293,6 @@ public final class ExtractorMediaSource extends BaseMediaSource ...@@ -317,7 +293,6 @@ public final class ExtractorMediaSource extends BaseMediaSource
* @deprecated Use {@link Factory} instead. * @deprecated Use {@link Factory} instead.
*/ */
@Deprecated @Deprecated
@SuppressWarnings("deprecation")
public ExtractorMediaSource( public ExtractorMediaSource(
Uri uri, Uri uri,
DataSource.Factory dataSourceFactory, DataSource.Factory dataSourceFactory,
...@@ -347,93 +322,57 @@ public final class ExtractorMediaSource extends BaseMediaSource ...@@ -347,93 +322,57 @@ public final class ExtractorMediaSource extends BaseMediaSource
@Nullable String customCacheKey, @Nullable String customCacheKey,
int continueLoadingCheckIntervalBytes, int continueLoadingCheckIntervalBytes,
@Nullable Object tag) { @Nullable Object tag) {
this.uri = uri; progressiveMediaSource =
this.dataSourceFactory = dataSourceFactory; new ProgressiveMediaSource(
this.extractorsFactory = extractorsFactory; uri,
this.loadableLoadErrorHandlingPolicy = loadableLoadErrorHandlingPolicy; dataSourceFactory,
this.customCacheKey = customCacheKey; extractorsFactory,
this.continueLoadingCheckIntervalBytes = continueLoadingCheckIntervalBytes; loadableLoadErrorHandlingPolicy,
this.timelineDurationUs = C.TIME_UNSET; customCacheKey,
this.tag = tag; continueLoadingCheckIntervalBytes,
tag);
} }
@Override @Override
@Nullable @Nullable
public Object getTag() { public Object getTag() {
return tag; return progressiveMediaSource.getTag();
} }
@Override @Override
public void prepareSourceInternal(@Nullable TransferListener mediaTransferListener) { public void prepareSourceInternal(@Nullable TransferListener mediaTransferListener) {
transferListener = mediaTransferListener; progressiveMediaSource.prepareSource(/* listener= */ this, mediaTransferListener);
notifySourceInfoRefreshed(timelineDurationUs, timelineIsSeekable);
} }
@Override @Override
public void maybeThrowSourceInfoRefreshError() throws IOException { public void maybeThrowSourceInfoRefreshError() throws IOException {
// Do nothing. progressiveMediaSource.maybeThrowSourceInfoRefreshError();
} }
@Override @Override
public MediaPeriod createPeriod(MediaPeriodId id, Allocator allocator, long startPositionUs) { public MediaPeriod createPeriod(MediaPeriodId id, Allocator allocator, long startPositionUs) {
DataSource dataSource = dataSourceFactory.createDataSource(); return progressiveMediaSource.createPeriod(id, allocator, startPositionUs);
if (transferListener != null) {
dataSource.addTransferListener(transferListener);
}
return new ExtractorMediaPeriod(
uri,
dataSource,
extractorsFactory.createExtractors(),
loadableLoadErrorHandlingPolicy,
createEventDispatcher(id),
this,
allocator,
customCacheKey,
continueLoadingCheckIntervalBytes);
} }
@Override @Override
public void releasePeriod(MediaPeriod mediaPeriod) { public void releasePeriod(MediaPeriod mediaPeriod) {
((ExtractorMediaPeriod) mediaPeriod).release(); progressiveMediaSource.releasePeriod(mediaPeriod);
} }
@Override @Override
public void releaseSourceInternal() { public void releaseSourceInternal() {
// Do nothing. progressiveMediaSource.releaseSource(/* listener= */ this);
} }
// ExtractorMediaPeriod.Listener implementation.
@Override @Override
public void onSourceInfoRefreshed(long durationUs, boolean isSeekable) { public void onSourceInfoRefreshed(
// If we already have the duration from a previous source info refresh, use it. MediaSource source, Timeline timeline, @Nullable Object manifest) {
durationUs = durationUs == C.TIME_UNSET ? timelineDurationUs : durationUs; refreshSourceInfo(timeline, manifest);
if (timelineDurationUs == durationUs && timelineIsSeekable == isSeekable) {
// Suppress no-op source info changes.
return;
}
notifySourceInfoRefreshed(durationUs, isSeekable);
}
// Internal methods.
private void notifySourceInfoRefreshed(long durationUs, boolean isSeekable) {
timelineDurationUs = durationUs;
timelineIsSeekable = isSeekable;
// TODO: Make timeline dynamic until its duration is known. This is non-trivial. See b/69703223.
refreshSourceInfo(
new SinglePeriodTimeline(
timelineDurationUs, timelineIsSeekable, /* isDynamic= */ false, tag),
/* manifest= */ null);
} }
/**
* Wraps a deprecated {@link EventListener}, invoking its callback from the equivalent callback in
* {@link MediaSourceEventListener}.
*/
@Deprecated @Deprecated
@SuppressWarnings("deprecation")
private static final class EventListenerWrapper extends DefaultMediaSourceEventListener { private static final class EventListenerWrapper extends DefaultMediaSourceEventListener {
private final EventListener eventListener; private final EventListener eventListener;
public EventListenerWrapper(EventListener eventListener) { public EventListenerWrapper(EventListener eventListener) {
......
...@@ -54,12 +54,13 @@ import java.io.IOException; ...@@ -54,12 +54,13 @@ import java.io.IOException;
import java.util.Arrays; import java.util.Arrays;
import org.checkerframework.checker.nullness.compatqual.NullableType; import org.checkerframework.checker.nullness.compatqual.NullableType;
/** /** A {@link MediaPeriod} that extracts data using an {@link Extractor}. */
* A {@link MediaPeriod} that extracts data using an {@link Extractor}. /* package */ final class ProgressiveMediaPeriod
*/ implements MediaPeriod,
/* package */ final class ExtractorMediaPeriod implements MediaPeriod, ExtractorOutput, ExtractorOutput,
Loader.Callback<ExtractorMediaPeriod.ExtractingLoadable>, Loader.ReleaseCallback, Loader.Callback<ProgressiveMediaPeriod.ExtractingLoadable>,
UpstreamFormatChangedListener { Loader.ReleaseCallback,
UpstreamFormatChangedListener {
/** /**
* Listener for information about the period. * Listener for information about the period.
...@@ -145,7 +146,7 @@ import org.checkerframework.checker.nullness.compatqual.NullableType; ...@@ -145,7 +146,7 @@ import org.checkerframework.checker.nullness.compatqual.NullableType;
"nullness:argument.type.incompatible", "nullness:argument.type.incompatible",
"nullness:methodref.receiver.bound.invalid" "nullness:methodref.receiver.bound.invalid"
}) })
public ExtractorMediaPeriod( public ProgressiveMediaPeriod(
Uri uri, Uri uri,
DataSource dataSource, DataSource dataSource,
Extractor[] extractors, Extractor[] extractors,
...@@ -163,14 +164,15 @@ import org.checkerframework.checker.nullness.compatqual.NullableType; ...@@ -163,14 +164,15 @@ import org.checkerframework.checker.nullness.compatqual.NullableType;
this.allocator = allocator; this.allocator = allocator;
this.customCacheKey = customCacheKey; this.customCacheKey = customCacheKey;
this.continueLoadingCheckIntervalBytes = continueLoadingCheckIntervalBytes; this.continueLoadingCheckIntervalBytes = continueLoadingCheckIntervalBytes;
loader = new Loader("Loader:ExtractorMediaPeriod"); loader = new Loader("Loader:ProgressiveMediaPeriod");
extractorHolder = new ExtractorHolder(extractors); extractorHolder = new ExtractorHolder(extractors);
loadCondition = new ConditionVariable(); loadCondition = new ConditionVariable();
maybeFinishPrepareRunnable = this::maybeFinishPrepare; maybeFinishPrepareRunnable = this::maybeFinishPrepare;
onContinueLoadingRequestedRunnable = onContinueLoadingRequestedRunnable =
() -> { () -> {
if (!released) { if (!released) {
Assertions.checkNotNull(callback).onContinueLoadingRequested(ExtractorMediaPeriod.this); Assertions.checkNotNull(callback)
.onContinueLoadingRequested(ProgressiveMediaPeriod.this);
} }
}; };
handler = new Handler(); handler = new Handler();
...@@ -852,23 +854,23 @@ import org.checkerframework.checker.nullness.compatqual.NullableType; ...@@ -852,23 +854,23 @@ import org.checkerframework.checker.nullness.compatqual.NullableType;
@Override @Override
public boolean isReady() { public boolean isReady() {
return ExtractorMediaPeriod.this.isReady(track); return ProgressiveMediaPeriod.this.isReady(track);
} }
@Override @Override
public void maybeThrowError() throws IOException { public void maybeThrowError() throws IOException {
ExtractorMediaPeriod.this.maybeThrowError(); ProgressiveMediaPeriod.this.maybeThrowError();
} }
@Override @Override
public int readData(FormatHolder formatHolder, DecoderInputBuffer buffer, public int readData(FormatHolder formatHolder, DecoderInputBuffer buffer,
boolean formatRequired) { boolean formatRequired) {
return ExtractorMediaPeriod.this.readData(track, formatHolder, buffer, formatRequired); return ProgressiveMediaPeriod.this.readData(track, formatHolder, buffer, formatRequired);
} }
@Override @Override
public int skipData(long positionUs) { public int skipData(long positionUs) {
return ExtractorMediaPeriod.this.skipData(track, positionUs); return ProgressiveMediaPeriod.this.skipData(track, positionUs);
} }
} }
......
...@@ -138,12 +138,12 @@ public final class SingleSampleMediaSource extends BaseMediaSource { ...@@ -138,12 +138,12 @@ public final class SingleSampleMediaSource extends BaseMediaSource {
} }
/** /**
* Returns a new {@link ExtractorMediaSource} using the current parameters. * Returns a new {@link SingleSampleMediaSource} using the current parameters.
* *
* @param uri The {@link Uri}. * @param uri The {@link Uri}.
* @param format The {@link Format} of the media stream. * @param format The {@link Format} of the media stream.
* @param durationUs The duration of the media stream in microseconds. * @param durationUs The duration of the media stream in microseconds.
* @return The new {@link ExtractorMediaSource}. * @return The new {@link SingleSampleMediaSource}.
*/ */
public SingleSampleMediaSource createMediaSource(Uri uri, Format format, long durationUs) { public SingleSampleMediaSource createMediaSource(Uri uri, Format format, long durationUs) {
isCreateCalled = true; isCreateCalled = true;
......
...@@ -25,13 +25,13 @@ import com.google.android.exoplayer2.C; ...@@ -25,13 +25,13 @@ import com.google.android.exoplayer2.C;
import com.google.android.exoplayer2.Timeline; import com.google.android.exoplayer2.Timeline;
import com.google.android.exoplayer2.source.CompositeMediaSource; import com.google.android.exoplayer2.source.CompositeMediaSource;
import com.google.android.exoplayer2.source.DeferredMediaPeriod; import com.google.android.exoplayer2.source.DeferredMediaPeriod;
import com.google.android.exoplayer2.source.ExtractorMediaSource;
import com.google.android.exoplayer2.source.MediaPeriod; import com.google.android.exoplayer2.source.MediaPeriod;
import com.google.android.exoplayer2.source.MediaSource; import com.google.android.exoplayer2.source.MediaSource;
import com.google.android.exoplayer2.source.MediaSource.MediaPeriodId; import com.google.android.exoplayer2.source.MediaSource.MediaPeriodId;
import com.google.android.exoplayer2.source.MediaSourceEventListener; import com.google.android.exoplayer2.source.MediaSourceEventListener;
import com.google.android.exoplayer2.source.MediaSourceEventListener.LoadEventInfo; import com.google.android.exoplayer2.source.MediaSourceEventListener.LoadEventInfo;
import com.google.android.exoplayer2.source.MediaSourceEventListener.MediaLoadData; import com.google.android.exoplayer2.source.MediaSourceEventListener.MediaLoadData;
import com.google.android.exoplayer2.source.ProgressiveMediaSource;
import com.google.android.exoplayer2.upstream.Allocator; import com.google.android.exoplayer2.upstream.Allocator;
import com.google.android.exoplayer2.upstream.DataSource; import com.google.android.exoplayer2.upstream.DataSource;
import com.google.android.exoplayer2.upstream.DataSpec; import com.google.android.exoplayer2.upstream.DataSpec;
...@@ -203,7 +203,7 @@ public final class AdsMediaSource extends CompositeMediaSource<MediaPeriodId> { ...@@ -203,7 +203,7 @@ public final class AdsMediaSource extends CompositeMediaSource<MediaPeriodId> {
/** /**
* Constructs a new source that inserts ads linearly with the content specified by {@code * Constructs a new source that inserts ads linearly with the content specified by {@code
* contentMediaSource}. Ad media is loaded using {@link ExtractorMediaSource}. * contentMediaSource}. Ad media is loaded using {@link ProgressiveMediaSource}.
* *
* @param contentMediaSource The {@link MediaSource} providing the content to play. * @param contentMediaSource The {@link MediaSource} providing the content to play.
* @param dataSourceFactory Factory for data sources used to load ad media. * @param dataSourceFactory Factory for data sources used to load ad media.
...@@ -217,7 +217,7 @@ public final class AdsMediaSource extends CompositeMediaSource<MediaPeriodId> { ...@@ -217,7 +217,7 @@ public final class AdsMediaSource extends CompositeMediaSource<MediaPeriodId> {
ViewGroup adUiViewGroup) { ViewGroup adUiViewGroup) {
this( this(
contentMediaSource, contentMediaSource,
new ExtractorMediaSource.Factory(dataSourceFactory), new ProgressiveMediaSource.Factory(dataSourceFactory),
adsLoader, adsLoader,
adUiViewGroup, adUiViewGroup,
/* eventHandler= */ null, /* eventHandler= */ null,
...@@ -249,7 +249,7 @@ public final class AdsMediaSource extends CompositeMediaSource<MediaPeriodId> { ...@@ -249,7 +249,7 @@ public final class AdsMediaSource extends CompositeMediaSource<MediaPeriodId> {
/** /**
* Constructs a new source that inserts ads linearly with the content specified by {@code * Constructs a new source that inserts ads linearly with the content specified by {@code
* contentMediaSource}. Ad media is loaded using {@link ExtractorMediaSource}. * contentMediaSource}. Ad media is loaded using {@link ProgressiveMediaSource}.
* *
* @param contentMediaSource The {@link MediaSource} providing the content to play. * @param contentMediaSource The {@link MediaSource} providing the content to play.
* @param dataSourceFactory Factory for data sources used to load ad media. * @param dataSourceFactory Factory for data sources used to load ad media.
...@@ -273,7 +273,7 @@ public final class AdsMediaSource extends CompositeMediaSource<MediaPeriodId> { ...@@ -273,7 +273,7 @@ public final class AdsMediaSource extends CompositeMediaSource<MediaPeriodId> {
@Nullable EventListener eventListener) { @Nullable EventListener eventListener) {
this( this(
contentMediaSource, contentMediaSource,
new ExtractorMediaSource.Factory(dataSourceFactory), new ProgressiveMediaSource.Factory(dataSourceFactory),
adsLoader, adsLoader,
adUiViewGroup, adUiViewGroup,
eventHandler, eventHandler,
......
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