Commit 8e0354c0 by olly Committed by Oliver Woodman

Finalize class naming

SampleSourceProvider -> MediaSource
SampleSource -> MediaPeriod
-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=126914964
parent c9ec7beb
Showing with 256 additions and 288 deletions
...@@ -15,7 +15,7 @@ ...@@ -15,7 +15,7 @@
*/ */
package com.google.android.exoplayer2.demo; package com.google.android.exoplayer2.demo;
import com.google.android.exoplayer2.AdaptiveSourceEventListener; import com.google.android.exoplayer2.AdaptiveMediaSourceEventListener;
import com.google.android.exoplayer2.CodecCounters; import com.google.android.exoplayer2.CodecCounters;
import com.google.android.exoplayer2.DefaultTrackSelector; import com.google.android.exoplayer2.DefaultTrackSelector;
import com.google.android.exoplayer2.DefaultTrackSelector.TrackInfo; import com.google.android.exoplayer2.DefaultTrackSelector.TrackInfo;
...@@ -28,7 +28,7 @@ import com.google.android.exoplayer2.TrackGroupArray; ...@@ -28,7 +28,7 @@ import com.google.android.exoplayer2.TrackGroupArray;
import com.google.android.exoplayer2.TrackRenderer; import com.google.android.exoplayer2.TrackRenderer;
import com.google.android.exoplayer2.TrackSelection; import com.google.android.exoplayer2.TrackSelection;
import com.google.android.exoplayer2.drm.StreamingDrmSessionManager; import com.google.android.exoplayer2.drm.StreamingDrmSessionManager;
import com.google.android.exoplayer2.extractor.ExtractorSampleSource; import com.google.android.exoplayer2.extractor.ExtractorMediaSource;
import com.google.android.exoplayer2.upstream.DataSpec; import com.google.android.exoplayer2.upstream.DataSpec;
import android.os.SystemClock; import android.os.SystemClock;
...@@ -42,7 +42,7 @@ import java.util.Locale; ...@@ -42,7 +42,7 @@ import java.util.Locale;
* Logs player events using {@link Log}. * Logs player events using {@link Log}.
*/ */
public class EventLogger implements ExoPlayer.EventListener, SimpleExoPlayer.DebugListener, public class EventLogger implements ExoPlayer.EventListener, SimpleExoPlayer.DebugListener,
AdaptiveSourceEventListener, ExtractorSampleSource.EventListener, AdaptiveMediaSourceEventListener, ExtractorMediaSource.EventListener,
StreamingDrmSessionManager.EventListener, DefaultTrackSelector.EventListener { StreamingDrmSessionManager.EventListener, DefaultTrackSelector.EventListener {
private static final String TAG = "EventLogger"; private static final String TAG = "EventLogger";
...@@ -78,8 +78,8 @@ public class EventLogger implements ExoPlayer.EventListener, SimpleExoPlayer.Deb ...@@ -78,8 +78,8 @@ public class EventLogger implements ExoPlayer.EventListener, SimpleExoPlayer.Deb
} }
@Override @Override
public void onPositionDiscontinuity(int sourceIndex, long positionMs) { public void onPositionDiscontinuity(int periodIndex, long positionMs) {
Log.d(TAG, "discontinuity [" + sourceIndex + ", " + positionMs + "]"); Log.d(TAG, "discontinuity [" + periodIndex + ", " + positionMs + "]");
} }
@Override @Override
...@@ -211,14 +211,14 @@ public class EventLogger implements ExoPlayer.EventListener, SimpleExoPlayer.Deb ...@@ -211,14 +211,14 @@ public class EventLogger implements ExoPlayer.EventListener, SimpleExoPlayer.Deb
Log.d(TAG, "drmKeysLoaded [" + getSessionTimeString() + "]"); Log.d(TAG, "drmKeysLoaded [" + getSessionTimeString() + "]");
} }
// ExtractorSampleSource.EventListener // ExtractorMediaSource.EventListener
@Override @Override
public void onLoadError(IOException error) { public void onLoadError(IOException error) {
printInternalError("loadError", error); printInternalError("loadError", error);
} }
// AdaptiveSourceEventListener // AdaptiveMediaSourceEventListener
@Override @Override
public void onLoadStarted(DataSpec dataSpec, int dataType, int trackType, Format format, public void onLoadStarted(DataSpec dataSpec, int dataType, int trackType, Format format,
......
...@@ -17,7 +17,7 @@ package com.google.android.exoplayer2.demo; ...@@ -17,7 +17,7 @@ package com.google.android.exoplayer2.demo;
import com.google.android.exoplayer2.AspectRatioFrameLayout; import com.google.android.exoplayer2.AspectRatioFrameLayout;
import com.google.android.exoplayer2.C; import com.google.android.exoplayer2.C;
import com.google.android.exoplayer2.ConcatenatingSampleSourceProvider; import com.google.android.exoplayer2.ConcatenatingMediaSource;
import com.google.android.exoplayer2.DefaultLoadControl; import com.google.android.exoplayer2.DefaultLoadControl;
import com.google.android.exoplayer2.DefaultTrackSelectionPolicy; import com.google.android.exoplayer2.DefaultTrackSelectionPolicy;
import com.google.android.exoplayer2.DefaultTrackSelector; import com.google.android.exoplayer2.DefaultTrackSelector;
...@@ -27,23 +27,23 @@ import com.google.android.exoplayer2.ExoPlayer; ...@@ -27,23 +27,23 @@ import com.google.android.exoplayer2.ExoPlayer;
import com.google.android.exoplayer2.ExoPlayerFactory; import com.google.android.exoplayer2.ExoPlayerFactory;
import com.google.android.exoplayer2.MediaCodecTrackRenderer.DecoderInitializationException; import com.google.android.exoplayer2.MediaCodecTrackRenderer.DecoderInitializationException;
import com.google.android.exoplayer2.MediaCodecUtil.DecoderQueryException; import com.google.android.exoplayer2.MediaCodecUtil.DecoderQueryException;
import com.google.android.exoplayer2.SampleSourceProvider; import com.google.android.exoplayer2.MediaSource;
import com.google.android.exoplayer2.SimpleExoPlayer; import com.google.android.exoplayer2.SimpleExoPlayer;
import com.google.android.exoplayer2.TrackGroupArray; import com.google.android.exoplayer2.TrackGroupArray;
import com.google.android.exoplayer2.dash.DashSampleSource; import com.google.android.exoplayer2.dash.DashMediaSource;
import com.google.android.exoplayer2.drm.DrmSessionManager; import com.google.android.exoplayer2.drm.DrmSessionManager;
import com.google.android.exoplayer2.drm.StreamingDrmSessionManager; import com.google.android.exoplayer2.drm.StreamingDrmSessionManager;
import com.google.android.exoplayer2.drm.UnsupportedDrmException; import com.google.android.exoplayer2.drm.UnsupportedDrmException;
import com.google.android.exoplayer2.extractor.DefaultExtractorsFactory; import com.google.android.exoplayer2.extractor.DefaultExtractorsFactory;
import com.google.android.exoplayer2.extractor.ExtractorSampleSource; import com.google.android.exoplayer2.extractor.ExtractorMediaSource;
import com.google.android.exoplayer2.hls.HlsSampleSource; import com.google.android.exoplayer2.hls.HlsMediaSource;
import com.google.android.exoplayer2.metadata.id3.ApicFrame; import com.google.android.exoplayer2.metadata.id3.ApicFrame;
import com.google.android.exoplayer2.metadata.id3.GeobFrame; import com.google.android.exoplayer2.metadata.id3.GeobFrame;
import com.google.android.exoplayer2.metadata.id3.Id3Frame; import com.google.android.exoplayer2.metadata.id3.Id3Frame;
import com.google.android.exoplayer2.metadata.id3.PrivFrame; import com.google.android.exoplayer2.metadata.id3.PrivFrame;
import com.google.android.exoplayer2.metadata.id3.TextInformationFrame; import com.google.android.exoplayer2.metadata.id3.TextInformationFrame;
import com.google.android.exoplayer2.metadata.id3.TxxxFrame; import com.google.android.exoplayer2.metadata.id3.TxxxFrame;
import com.google.android.exoplayer2.smoothstreaming.SmoothStreamingSampleSource; import com.google.android.exoplayer2.smoothstreaming.SmoothStreamingMediaSource;
import com.google.android.exoplayer2.text.CaptionStyleCompat; import com.google.android.exoplayer2.text.CaptionStyleCompat;
import com.google.android.exoplayer2.text.Cue; import com.google.android.exoplayer2.text.Cue;
import com.google.android.exoplayer2.text.SubtitleLayout; import com.google.android.exoplayer2.text.SubtitleLayout;
...@@ -320,34 +320,33 @@ public class PlayerActivity extends Activity implements SurfaceHolder.Callback, ...@@ -320,34 +320,33 @@ public class PlayerActivity extends Activity implements SurfaceHolder.Callback,
return; return;
} }
SampleSourceProvider[] providers = new SampleSourceProvider[uris.length]; MediaSource[] mediaSources = new MediaSource[uris.length];
for (int i = 0; i < uris.length; i++) { for (int i = 0; i < uris.length; i++) {
providers[i] = getSampleSourceProvider(uris[i], extensions[i]); mediaSources[i] = getMediaSource(uris[i], extensions[i]);
} }
SampleSourceProvider sourceProvider = providers.length == 1 ? providers[0] MediaSource mediaSource = mediaSources.length == 1 ? mediaSources[0]
: new ConcatenatingSampleSourceProvider(providers); : new ConcatenatingMediaSource(mediaSources);
player.setSourceProvider(sourceProvider); player.setMediaSource(mediaSource);
playerNeedsSource = false; playerNeedsSource = false;
updateButtonVisibilities(); updateButtonVisibilities();
} }
} }
private SampleSourceProvider getSampleSourceProvider(Uri uri, String overrideExtension) { private MediaSource getMediaSource(Uri uri, String overrideExtension) {
String lastPathSegment = !TextUtils.isEmpty(overrideExtension) ? "." + overrideExtension String lastPathSegment = !TextUtils.isEmpty(overrideExtension) ? "." + overrideExtension
: uri.getLastPathSegment(); : uri.getLastPathSegment();
int type = Util.inferContentType(lastPathSegment); int type = Util.inferContentType(lastPathSegment);
switch (type) { switch (type) {
case Util.TYPE_SS: case Util.TYPE_SS:
return new SmoothStreamingSampleSource(uri, dataSourceFactory, bandwidthMeter, mainHandler, return new SmoothStreamingMediaSource(uri, dataSourceFactory, bandwidthMeter, mainHandler,
eventLogger); eventLogger);
case Util.TYPE_DASH: case Util.TYPE_DASH:
return new DashSampleSource(uri, dataSourceFactory, bandwidthMeter, mainHandler, return new DashMediaSource(uri, dataSourceFactory, bandwidthMeter, mainHandler,
eventLogger); eventLogger);
case Util.TYPE_HLS: case Util.TYPE_HLS:
return new HlsSampleSource(uri, dataSourceFactory, bandwidthMeter, mainHandler, return new HlsMediaSource(uri, dataSourceFactory, bandwidthMeter, mainHandler, eventLogger);
eventLogger);
case Util.TYPE_OTHER: case Util.TYPE_OTHER:
return new ExtractorSampleSource(uri, dataSourceFactory, bandwidthMeter, return new ExtractorMediaSource(uri, dataSourceFactory, bandwidthMeter,
new DefaultExtractorsFactory(), mainHandler, eventLogger); new DefaultExtractorsFactory(), mainHandler, eventLogger);
default: default:
throw new IllegalStateException("Unsupported type: " + type); throw new IllegalStateException("Unsupported type: " + type);
...@@ -437,7 +436,7 @@ public class PlayerActivity extends Activity implements SurfaceHolder.Callback, ...@@ -437,7 +436,7 @@ public class PlayerActivity extends Activity implements SurfaceHolder.Callback,
} }
@Override @Override
public void onPositionDiscontinuity(int sourceIndex, long positionMs) { public void onPositionDiscontinuity(int periodIndex, long positionMs) {
if (mediaController.isShowing()) { if (mediaController.isShowing()) {
// The MediaController is visible, so force it to show the updated position immediately. // The MediaController is visible, so force it to show the updated position immediately.
mediaController.show(); mediaController.show();
......
...@@ -21,7 +21,7 @@ import com.google.android.exoplayer2.ExoPlaybackException; ...@@ -21,7 +21,7 @@ import com.google.android.exoplayer2.ExoPlaybackException;
import com.google.android.exoplayer2.ExoPlayer; import com.google.android.exoplayer2.ExoPlayer;
import com.google.android.exoplayer2.ExoPlayerFactory; import com.google.android.exoplayer2.ExoPlayerFactory;
import com.google.android.exoplayer2.TrackRenderer; import com.google.android.exoplayer2.TrackRenderer;
import com.google.android.exoplayer2.extractor.ExtractorSampleSource; import com.google.android.exoplayer2.extractor.ExtractorMediaSource;
import com.google.android.exoplayer2.extractor.mkv.MatroskaExtractor; import com.google.android.exoplayer2.extractor.mkv.MatroskaExtractor;
import com.google.android.exoplayer2.upstream.DefaultDataSourceFactory; import com.google.android.exoplayer2.upstream.DefaultDataSourceFactory;
...@@ -76,14 +76,14 @@ public class FlacPlaybackTest extends InstrumentationTestCase { ...@@ -76,14 +76,14 @@ public class FlacPlaybackTest extends InstrumentationTestCase {
new DefaultTrackSelectionPolicy(), null); new DefaultTrackSelectionPolicy(), null);
player = ExoPlayerFactory.newInstance(new TrackRenderer[] {audioRenderer}, trackSelector); player = ExoPlayerFactory.newInstance(new TrackRenderer[] {audioRenderer}, trackSelector);
player.addListener(this); player.addListener(this);
ExtractorSampleSource sampleSource = new ExtractorSampleSource( ExtractorMediaSource mediaSource = new ExtractorMediaSource(
uri, uri,
new DefaultDataSourceFactory(context, "ExoPlayerExtFlacTest"), new DefaultDataSourceFactory(context, "ExoPlayerExtFlacTest"),
null, null,
new MatroskaExtractor.Factory(), new MatroskaExtractor.Factory(),
null, null,
null); null);
player.setSourceProvider(sampleSource); player.setMediaSource(mediaSource);
player.setPlayWhenReady(true); player.setPlayWhenReady(true);
Looper.loop(); Looper.loop();
} }
...@@ -99,7 +99,7 @@ public class FlacPlaybackTest extends InstrumentationTestCase { ...@@ -99,7 +99,7 @@ public class FlacPlaybackTest extends InstrumentationTestCase {
} }
@Override @Override
public void onPositionDiscontinuity(int sourceIndex, long positionMs) { public void onPositionDiscontinuity(int periodIndex, long positionMs) {
// Do nothing. // Do nothing.
} }
......
...@@ -21,7 +21,7 @@ import com.google.android.exoplayer2.ExoPlaybackException; ...@@ -21,7 +21,7 @@ import com.google.android.exoplayer2.ExoPlaybackException;
import com.google.android.exoplayer2.ExoPlayer; import com.google.android.exoplayer2.ExoPlayer;
import com.google.android.exoplayer2.ExoPlayerFactory; import com.google.android.exoplayer2.ExoPlayerFactory;
import com.google.android.exoplayer2.TrackRenderer; import com.google.android.exoplayer2.TrackRenderer;
import com.google.android.exoplayer2.extractor.ExtractorSampleSource; import com.google.android.exoplayer2.extractor.ExtractorMediaSource;
import com.google.android.exoplayer2.extractor.mkv.MatroskaExtractor; import com.google.android.exoplayer2.extractor.mkv.MatroskaExtractor;
import com.google.android.exoplayer2.upstream.DefaultDataSourceFactory; import com.google.android.exoplayer2.upstream.DefaultDataSourceFactory;
...@@ -76,14 +76,14 @@ public class OpusPlaybackTest extends InstrumentationTestCase { ...@@ -76,14 +76,14 @@ public class OpusPlaybackTest extends InstrumentationTestCase {
new DefaultTrackSelectionPolicy(), null); new DefaultTrackSelectionPolicy(), null);
player = ExoPlayerFactory.newInstance(new TrackRenderer[] {audioRenderer}, trackSelector); player = ExoPlayerFactory.newInstance(new TrackRenderer[] {audioRenderer}, trackSelector);
player.addListener(this); player.addListener(this);
ExtractorSampleSource sampleSource = new ExtractorSampleSource( ExtractorMediaSource mediaSource = new ExtractorMediaSource(
uri, uri,
new DefaultDataSourceFactory(context, "ExoPlayerExtOpusTest"), new DefaultDataSourceFactory(context, "ExoPlayerExtOpusTest"),
null, null,
new MatroskaExtractor.Factory(), new MatroskaExtractor.Factory(),
null, null,
null); null);
player.setSourceProvider(sampleSource); player.setMediaSource(mediaSource);
player.setPlayWhenReady(true); player.setPlayWhenReady(true);
Looper.loop(); Looper.loop();
} }
...@@ -99,7 +99,7 @@ public class OpusPlaybackTest extends InstrumentationTestCase { ...@@ -99,7 +99,7 @@ public class OpusPlaybackTest extends InstrumentationTestCase {
} }
@Override @Override
public void onPositionDiscontinuity(int sourceIndex, long positionMs) { public void onPositionDiscontinuity(int periodIndex, long positionMs) {
// Do nothing. // Do nothing.
} }
......
eclipse.preferences.version=1
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
org.eclipse.jdt.core.compiler.codegen.methodParameters=do not generate
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.7
org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
org.eclipse.jdt.core.compiler.compliance=1.7
org.eclipse.jdt.core.compiler.debug.lineNumber=generate
org.eclipse.jdt.core.compiler.debug.localVariable=generate
org.eclipse.jdt.core.compiler.debug.sourceFile=generate
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
org.eclipse.jdt.core.compiler.source=1.7
...@@ -21,7 +21,7 @@ import com.google.android.exoplayer2.ExoPlaybackException; ...@@ -21,7 +21,7 @@ import com.google.android.exoplayer2.ExoPlaybackException;
import com.google.android.exoplayer2.ExoPlayer; import com.google.android.exoplayer2.ExoPlayer;
import com.google.android.exoplayer2.ExoPlayerFactory; import com.google.android.exoplayer2.ExoPlayerFactory;
import com.google.android.exoplayer2.TrackRenderer; import com.google.android.exoplayer2.TrackRenderer;
import com.google.android.exoplayer2.extractor.ExtractorSampleSource; import com.google.android.exoplayer2.extractor.ExtractorMediaSource;
import com.google.android.exoplayer2.extractor.mkv.MatroskaExtractor; import com.google.android.exoplayer2.extractor.mkv.MatroskaExtractor;
import com.google.android.exoplayer2.upstream.DefaultDataSourceFactory; import com.google.android.exoplayer2.upstream.DefaultDataSourceFactory;
...@@ -92,7 +92,7 @@ public class VpxPlaybackTest extends InstrumentationTestCase { ...@@ -92,7 +92,7 @@ public class VpxPlaybackTest extends InstrumentationTestCase {
new DefaultTrackSelectionPolicy(), null); new DefaultTrackSelectionPolicy(), null);
player = ExoPlayerFactory.newInstance(new TrackRenderer[] {videoRenderer}, trackSelector); player = ExoPlayerFactory.newInstance(new TrackRenderer[] {videoRenderer}, trackSelector);
player.addListener(this); player.addListener(this);
ExtractorSampleSource sampleSource = new ExtractorSampleSource( ExtractorMediaSource mediaSource = new ExtractorMediaSource(
uri, uri,
new DefaultDataSourceFactory(context, "ExoPlayerExtVp9Test"), new DefaultDataSourceFactory(context, "ExoPlayerExtVp9Test"),
null, null,
...@@ -102,7 +102,7 @@ public class VpxPlaybackTest extends InstrumentationTestCase { ...@@ -102,7 +102,7 @@ public class VpxPlaybackTest extends InstrumentationTestCase {
player.sendMessages(new ExoPlayer.ExoPlayerMessage(videoRenderer, player.sendMessages(new ExoPlayer.ExoPlayerMessage(videoRenderer,
LibvpxVideoTrackRenderer.MSG_SET_OUTPUT_BUFFER_RENDERER, LibvpxVideoTrackRenderer.MSG_SET_OUTPUT_BUFFER_RENDERER,
new VpxVideoSurfaceView(context))); new VpxVideoSurfaceView(context)));
player.setSourceProvider(sampleSource); player.setMediaSource(mediaSource);
player.setPlayWhenReady(true); player.setPlayWhenReady(true);
Looper.loop(); Looper.loop();
} }
...@@ -118,7 +118,7 @@ public class VpxPlaybackTest extends InstrumentationTestCase { ...@@ -118,7 +118,7 @@ public class VpxPlaybackTest extends InstrumentationTestCase {
} }
@Override @Override
public void onPositionDiscontinuity(int sourceIndex, long positionMs) { public void onPositionDiscontinuity(int periodIndex, long positionMs) {
// Do nothing. // Do nothing.
} }
......
eclipse.preferences.version=1
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
org.eclipse.jdt.core.compiler.codegen.methodParameters=do not generate
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.7
org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
org.eclipse.jdt.core.compiler.compliance=1.7
org.eclipse.jdt.core.compiler.debug.lineNumber=generate
org.eclipse.jdt.core.compiler.debug.localVariable=generate
org.eclipse.jdt.core.compiler.debug.sourceFile=generate
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
org.eclipse.jdt.core.compiler.source=1.7
...@@ -25,9 +25,9 @@ import android.os.SystemClock; ...@@ -25,9 +25,9 @@ import android.os.SystemClock;
import java.io.IOException; import java.io.IOException;
/** /**
* Interface for callbacks to be notified about events during adaptive playbacks. * Interface for callbacks to be notified of adaptive {@link MediaSource} events.
*/ */
public interface AdaptiveSourceEventListener { public interface AdaptiveMediaSourceEventListener {
/** /**
* Invoked when a load begins. * Invoked when a load begins.
...@@ -171,14 +171,14 @@ public interface AdaptiveSourceEventListener { ...@@ -171,14 +171,14 @@ public interface AdaptiveSourceEventListener {
Object formatEvaluatorData, long mediaTimeMs); Object formatEvaluatorData, long mediaTimeMs);
/** /**
* Dispatches events to a {@link AdaptiveSourceEventListener}. * Dispatches events to a {@link AdaptiveMediaSourceEventListener}.
*/ */
final class EventDispatcher { final class EventDispatcher {
private final Handler handler; private final Handler handler;
private final AdaptiveSourceEventListener listener; private final AdaptiveMediaSourceEventListener listener;
public EventDispatcher(Handler handler, AdaptiveSourceEventListener listener) { public EventDispatcher(Handler handler, AdaptiveMediaSourceEventListener listener) {
this.handler = listener != null ? Assertions.checkNotNull(handler) : null; this.handler = listener != null ? Assertions.checkNotNull(handler) : null;
this.listener = listener; this.listener = listener;
} }
......
...@@ -16,26 +16,26 @@ ...@@ -16,26 +16,26 @@
package com.google.android.exoplayer2; package com.google.android.exoplayer2;
/** /**
* A {@link SampleSourceProvider} that concatenates multiple {@link SampleSourceProvider}s. * A {@link MediaSource} that concatenates multiple {@link MediaSource}s.
*/ */
public final class ConcatenatingSampleSourceProvider implements SampleSourceProvider { public final class ConcatenatingMediaSource implements MediaSource {
private final SampleSourceProvider[] sampleSourceProviders; private final MediaSource[] mediaSources;
/** /**
* @param sampleSourcePoviders The {@link SampleSourceProvider}s to concatenate. * @param mediaSources The {@link MediaSource}s to concatenate.
*/ */
public ConcatenatingSampleSourceProvider(SampleSourceProvider... sampleSourcePoviders) { public ConcatenatingMediaSource(MediaSource... mediaSources) {
this.sampleSourceProviders = sampleSourcePoviders; this.mediaSources = mediaSources;
} }
@Override @Override
public int getSourceCount() { public int getPeriodCount() {
int sourceCount = 0; int sourceCount = 0;
for (SampleSourceProvider sampleSourceProvider : sampleSourceProviders) { for (MediaSource mediaSource : mediaSources) {
int count = sampleSourceProvider.getSourceCount(); int count = mediaSource.getPeriodCount();
if (count == SampleSourceProvider.UNKNOWN_SOURCE_COUNT) { if (count == MediaSource.UNKNOWN_PERIOD_COUNT) {
return UNKNOWN_SOURCE_COUNT; return UNKNOWN_PERIOD_COUNT;
} }
sourceCount += count; sourceCount += count;
} }
...@@ -43,12 +43,12 @@ public final class ConcatenatingSampleSourceProvider implements SampleSourceProv ...@@ -43,12 +43,12 @@ public final class ConcatenatingSampleSourceProvider implements SampleSourceProv
} }
@Override @Override
public SampleSource createSource(int index) { public MediaPeriod createPeriod(int index) {
int sourceCount = 0; int sourceCount = 0;
for (SampleSourceProvider sampleSourceProvider : sampleSourceProviders) { for (MediaSource mediaSource : mediaSources) {
int count = sampleSourceProvider.getSourceCount(); int count = mediaSource.getPeriodCount();
if (count == SampleSourceProvider.UNKNOWN_SOURCE_COUNT || index < sourceCount + count) { if (count == MediaSource.UNKNOWN_PERIOD_COUNT || index < sourceCount + count) {
return sampleSourceProvider.createSource(index - sourceCount); return mediaSource.createPeriod(index - sourceCount);
} }
sourceCount += count; sourceCount += count;
} }
......
...@@ -25,7 +25,7 @@ import java.io.IOException; ...@@ -25,7 +25,7 @@ import java.io.IOException;
public final class ExoPlaybackException extends Exception { public final class ExoPlaybackException extends Exception {
/** /**
* The error occurred loading data from a {@link SampleSource}. * The error occurred loading data from a {@link MediaSource}.
* <p> * <p>
* Call {@link #getSourceException()} to retrieve the underlying cause. * Call {@link #getSourceException()} to retrieve the underlying cause.
*/ */
......
...@@ -38,11 +38,11 @@ package com.google.android.exoplayer2; ...@@ -38,11 +38,11 @@ package com.google.android.exoplayer2;
* *
* <p>{@link MediaCodecAudioTrackRenderer} and {@link MediaCodecVideoTrackRenderer} can be used for * <p>{@link MediaCodecAudioTrackRenderer} and {@link MediaCodecVideoTrackRenderer} can be used for
* the common cases of rendering audio and video. These components in turn require an * the common cases of rendering audio and video. These components in turn require an
* <i>upstream</i> {@link SampleSource} to be injected through their constructors, where upstream * <i>upstream</i> {@link MediaPeriod} to be injected through their constructors, where upstream
* is defined to denote a component that is closer to the source of the media. This pattern of * is defined to denote a component that is closer to the source of the media. This pattern of
* upstream dependency injection is actively encouraged, since it means that the functionality of * upstream dependency injection is actively encouraged, since it means that the functionality of
* the player is built up through the composition of components that can easily be exchanged for * the player is built up through the composition of components that can easily be exchanged for
* alternate implementations. For example a {@link SampleSource} implementation may require a * alternate implementations. For example a {@link MediaPeriod} implementation may require a
* further upstream data loading component to be injected through its constructor, with different * further upstream data loading component to be injected through its constructor, with different
* implementations enabling the loading of data from various sources. * implementations enabling the loading of data from various sources.
* *
...@@ -84,8 +84,7 @@ package com.google.android.exoplayer2; ...@@ -84,8 +84,7 @@ package com.google.android.exoplayer2;
* *
* <p>The possible playback state transitions are shown below. Transitions can be triggered either * <p>The possible playback state transitions are shown below. Transitions can be triggered either
* by changes in the state of the {@link TrackRenderer}s being used, or as a result of * by changes in the state of the {@link TrackRenderer}s being used, or as a result of
* {@link #setSource(SampleSource)}, {@link #setSourceProvider(SampleSourceProvider)}, * {@link #setMediaSource(MediaSource)}, {@link #stop()} or {@link #release()} being invoked.</p>
* {@link #stop()} or {@link #release()} being invoked.</p>
* <p align="center"><img src="../../../../../images/exoplayer_playbackstate.png" * <p align="center"><img src="../../../../../images/exoplayer_playbackstate.png"
* alt="ExoPlayer playback state transitions" * alt="ExoPlayer playback state transitions"
* border="0"/></p> * border="0"/></p>
...@@ -128,12 +127,12 @@ public interface ExoPlayer { ...@@ -128,12 +127,12 @@ public interface ExoPlayer {
// TODO[playlists]: Should source-initiated resets also cause this to be invoked? // TODO[playlists]: Should source-initiated resets also cause this to be invoked?
/** /**
* Invoked when the player's position changes due to a discontinuity (seeking or playback * Invoked when the player's position changes due to a discontinuity (seeking or playback
* transitioning to the next source). * transitioning to the next period).
* *
* @param sourceIndex The index of the source being played. * @param periodIndex The index of the period being played.
* @param positionMs The playback position in that source, in milliseconds. * @param positionMs The playback position in that period, in milliseconds.
*/ */
void onPositionDiscontinuity(int sourceIndex, long positionMs); void onPositionDiscontinuity(int periodIndex, long positionMs);
/** /**
* Invoked when an error occurs. The playback state will transition to * Invoked when an error occurs. The playback state will transition to
...@@ -189,7 +188,7 @@ public interface ExoPlayer { ...@@ -189,7 +188,7 @@ public interface ExoPlayer {
} }
/** /**
* The player does not have a source to load, so it is neither buffering nor ready to play. * The player does not have a source to play, so it is neither buffering nor ready to play.
*/ */
int STATE_IDLE = 1; int STATE_IDLE = 1;
/** /**
...@@ -236,17 +235,18 @@ public interface ExoPlayer { ...@@ -236,17 +235,18 @@ public interface ExoPlayer {
int getPlaybackState(); int getPlaybackState();
/** /**
* Sets the player's source provider. The player's position will be reset to the start of the * Sets the {@link MediaSource} to play.
* first source and the player will transition to {@link #STATE_BUFFERING} until it is ready to * <p>
* play it. * The player's position will be reset to the start of the source.
* *
* @param sourceProvider The provider of {@link SampleSource}s to play. * @param mediaSource The {@link MediaSource} to play.
*/ */
void setSourceProvider(SampleSourceProvider sourceProvider); void setMediaSource(MediaSource mediaSource);
/** /**
* Sets whether playback should proceed when {@link #getPlaybackState()} == {@link #STATE_READY}. * Sets whether playback should proceed when {@link #getPlaybackState()} == {@link #STATE_READY}.
* If the player is already in this state, then this method can be used to pause and resume * <p>
* If the player is already in the ready state then this method can be used to pause and resume
* playback. * playback.
* *
* @param playWhenReady Whether playback should proceed when ready. * @param playWhenReady Whether playback should proceed when ready.
...@@ -276,19 +276,19 @@ public interface ExoPlayer { ...@@ -276,19 +276,19 @@ public interface ExoPlayer {
boolean isLoading(); boolean isLoading();
/** /**
* Seeks to a position specified in milliseconds in the current source. * Seeks to a position specified in milliseconds in the current period.
* *
* @param positionMs The seek position. * @param positionMs The seek position.
*/ */
void seekTo(long positionMs); void seekTo(long positionMs);
/** /**
* Seeks to a position specified in milliseconds in the specified source. * Seeks to a position specified in milliseconds in the specified period.
* *
* @param sourceIndex The index of the source to seek to. * @param periodIndex The index of the period to seek to.
* @param positionMs The seek position relative to the start of the specified source. * @param positionMs The seek position relative to the start of the specified period.
*/ */
void seekTo(int sourceIndex, long positionMs); void seekTo(int periodIndex, long positionMs);
/** /**
* Stops playback. Use {@code setPlayWhenReady(false)} rather than this method if the intention * Stops playback. Use {@code setPlayWhenReady(false)} rather than this method if the intention
...@@ -298,9 +298,7 @@ public interface ExoPlayer { ...@@ -298,9 +298,7 @@ public interface ExoPlayer {
* {@link ExoPlayer#STATE_IDLE}. The player instance can still be used, and * {@link ExoPlayer#STATE_IDLE}. The player instance can still be used, and
* {@link ExoPlayer#release()} must still be called on the player if it's no longer required. * {@link ExoPlayer#release()} must still be called on the player if it's no longer required.
* <p> * <p>
* Calling this method does not reset the playback position. If this player instance will be used * Calling this method does not reset the playback position.
* to play another video from its start, then {@code seekTo(0)} should be called after stopping
* the player and before setting the next source.
*/ */
void stop(); void stop();
...@@ -337,18 +335,18 @@ public interface ExoPlayer { ...@@ -337,18 +335,18 @@ public interface ExoPlayer {
long getDuration(); long getDuration();
/** /**
* Gets the playback position in the current source, in milliseconds. * Gets the playback position in the current period, in milliseconds.
* *
* @return The playback position in the current source, in milliseconds. * @return The playback position in the current period, in milliseconds.
*/ */
long getCurrentPosition(); long getCurrentPosition();
/** /**
* Gets the index of the current source. * Gets the index of the current period.
* *
* @return The index of the current source. * @return The index of the current period.
*/ */
int getCurrentSourceIndex(); int getCurrentPeriodIndex();
/** /**
* Gets an estimate of the absolute position in milliseconds up to which data is buffered. * Gets an estimate of the absolute position in milliseconds up to which data is buffered.
......
...@@ -40,14 +40,14 @@ import java.util.concurrent.CopyOnWriteArraySet; ...@@ -40,14 +40,14 @@ import java.util.concurrent.CopyOnWriteArraySet;
private boolean playWhenReady; private boolean playWhenReady;
private int playbackState; private int playbackState;
private int pendingPlayWhenReadyAcks; private int pendingPlayWhenReadyAcks;
private int pendingSetSourceProviderAndSeekAcks; private int pendingSetMediaSourceAndSeekAcks;
private boolean isLoading; private boolean isLoading;
// Playback information when there is no pending seek/set source operation. // Playback information when there is no pending seek/set source operation.
private PlaybackInfo playbackInfo; private PlaybackInfo playbackInfo;
// Playback information when there is a pending seek/set source operation. // Playback information when there is a pending seek/set source operation.
private int maskingSourceIndex; private int maskingPeriodIndex;
private long maskingPositionMs; private long maskingPositionMs;
private long maskingDurationMs; private long maskingDurationMs;
...@@ -94,13 +94,13 @@ import java.util.concurrent.CopyOnWriteArraySet; ...@@ -94,13 +94,13 @@ import java.util.concurrent.CopyOnWriteArraySet;
} }
@Override @Override
public void setSourceProvider(SampleSourceProvider sourceProvider) { public void setMediaSource(MediaSource mediaSource) {
maskingSourceIndex = 0; maskingPeriodIndex = 0;
maskingPositionMs = 0; maskingPositionMs = 0;
maskingDurationMs = ExoPlayer.UNKNOWN_TIME; maskingDurationMs = ExoPlayer.UNKNOWN_TIME;
pendingSetSourceProviderAndSeekAcks++; pendingSetMediaSourceAndSeekAcks++;
internalPlayer.setSourceProvider(sourceProvider); internalPlayer.setMediaSource(mediaSource);
for (EventListener listener : listeners) { for (EventListener listener : listeners) {
listener.onPositionDiscontinuity(0, 0); listener.onPositionDiscontinuity(0, 0);
} }
...@@ -135,20 +135,20 @@ import java.util.concurrent.CopyOnWriteArraySet; ...@@ -135,20 +135,20 @@ import java.util.concurrent.CopyOnWriteArraySet;
@Override @Override
public void seekTo(long positionMs) { public void seekTo(long positionMs) {
seekTo(getCurrentSourceIndex(), positionMs); seekTo(getCurrentPeriodIndex(), positionMs);
} }
@Override @Override
public void seekTo(int sourceIndex, long positionMs) { public void seekTo(int periodIndex, long positionMs) {
boolean sourceChanging = sourceIndex != getCurrentSourceIndex(); boolean periodChanging = periodIndex != getCurrentPeriodIndex();
maskingSourceIndex = sourceIndex; maskingPeriodIndex = periodIndex;
maskingPositionMs = positionMs; maskingPositionMs = positionMs;
maskingDurationMs = sourceChanging ? ExoPlayer.UNKNOWN_TIME : getDuration(); maskingDurationMs = periodChanging ? ExoPlayer.UNKNOWN_TIME : getDuration();
pendingSetSourceProviderAndSeekAcks++; pendingSetMediaSourceAndSeekAcks++;
internalPlayer.seekTo(sourceIndex, positionMs * 1000); internalPlayer.seekTo(periodIndex, positionMs * 1000);
for (EventListener listener : listeners) { for (EventListener listener : listeners) {
listener.onPositionDiscontinuity(sourceIndex, positionMs); listener.onPositionDiscontinuity(periodIndex, positionMs);
} }
} }
...@@ -175,7 +175,7 @@ import java.util.concurrent.CopyOnWriteArraySet; ...@@ -175,7 +175,7 @@ import java.util.concurrent.CopyOnWriteArraySet;
@Override @Override
public long getDuration() { public long getDuration() {
if (pendingSetSourceProviderAndSeekAcks == 0) { if (pendingSetMediaSourceAndSeekAcks == 0) {
long durationUs = playbackInfo.durationUs; long durationUs = playbackInfo.durationUs;
return durationUs == C.UNSET_TIME_US ? ExoPlayer.UNKNOWN_TIME : durationUs / 1000; return durationUs == C.UNSET_TIME_US ? ExoPlayer.UNKNOWN_TIME : durationUs / 1000;
} else { } else {
...@@ -185,18 +185,18 @@ import java.util.concurrent.CopyOnWriteArraySet; ...@@ -185,18 +185,18 @@ import java.util.concurrent.CopyOnWriteArraySet;
@Override @Override
public long getCurrentPosition() { public long getCurrentPosition() {
return pendingSetSourceProviderAndSeekAcks == 0 ? playbackInfo.positionUs / 1000 return pendingSetMediaSourceAndSeekAcks == 0 ? playbackInfo.positionUs / 1000
: maskingPositionMs; : maskingPositionMs;
} }
@Override @Override
public int getCurrentSourceIndex() { public int getCurrentPeriodIndex() {
return pendingSetSourceProviderAndSeekAcks == 0 ? playbackInfo.sourceIndex : maskingSourceIndex; return pendingSetMediaSourceAndSeekAcks == 0 ? playbackInfo.periodIndex : maskingPeriodIndex;
} }
@Override @Override
public long getBufferedPosition() { public long getBufferedPosition() {
if (pendingSetSourceProviderAndSeekAcks == 0) { if (pendingSetMediaSourceAndSeekAcks == 0) {
long bufferedPositionUs = playbackInfo.bufferedPositionUs; long bufferedPositionUs = playbackInfo.bufferedPositionUs;
return bufferedPositionUs == C.END_OF_SOURCE_US ? getDuration() : bufferedPositionUs / 1000; return bufferedPositionUs == C.END_OF_SOURCE_US ? getDuration() : bufferedPositionUs / 1000;
} else { } else {
...@@ -238,16 +238,16 @@ import java.util.concurrent.CopyOnWriteArraySet; ...@@ -238,16 +238,16 @@ import java.util.concurrent.CopyOnWriteArraySet;
} }
break; break;
} }
case ExoPlayerImplInternal.MSG_SET_SOURCE_PROVIDER_ACK: // Fall through. case ExoPlayerImplInternal.MSG_SET_MEDIA_SOURCE_ACK: // Fall through.
case ExoPlayerImplInternal.MSG_SEEK_ACK: { case ExoPlayerImplInternal.MSG_SEEK_ACK: {
pendingSetSourceProviderAndSeekAcks--; pendingSetMediaSourceAndSeekAcks--;
break; break;
} }
case ExoPlayerImplInternal.MSG_SOURCE_CHANGED: { case ExoPlayerImplInternal.MSG_PERIOD_CHANGED: {
playbackInfo = (ExoPlayerImplInternal.PlaybackInfo) msg.obj; playbackInfo = (ExoPlayerImplInternal.PlaybackInfo) msg.obj;
if (pendingSetSourceProviderAndSeekAcks == 0) { if (pendingSetMediaSourceAndSeekAcks == 0) {
for (EventListener listener : listeners) { for (EventListener listener : listeners) {
listener.onPositionDiscontinuity(playbackInfo.sourceIndex, 0); listener.onPositionDiscontinuity(playbackInfo.periodIndex, 0);
} }
} }
break; break;
......
...@@ -652,7 +652,7 @@ public abstract class MediaCodecTrackRenderer extends TrackRenderer { ...@@ -652,7 +652,7 @@ public abstract class MediaCodecTrackRenderer extends TrackRenderer {
} }
/** /**
* Invoked when a new format is read from the upstream {@link SampleSource}. * Invoked when a new format is read from the upstream {@link MediaPeriod}.
* *
* @param newFormat The new format. * @param newFormat The new format.
* @throws ExoPlaybackException If an error occurs reinitializing the {@link MediaCodec}. * @throws ExoPlaybackException If an error occurs reinitializing the {@link MediaCodec}.
......
...@@ -21,67 +21,67 @@ import java.io.IOException; ...@@ -21,67 +21,67 @@ import java.io.IOException;
import java.util.List; import java.util.List;
/** /**
* A source of media. * A source of a single period of media.
*/ */
public interface SampleSource extends SequenceableLoader { public interface MediaPeriod extends SequenceableLoader {
/** /**
* A callback to be notified of {@link SampleSource} events. * A callback to be notified of {@link MediaPeriod} events.
*/ */
interface Callback extends SequenceableLoader.Callback<SampleSource> { interface Callback extends SequenceableLoader.Callback<MediaPeriod> {
/** /**
* Invoked by the source when preparation completes. * Invoked when preparation completes.
* <p> * <p>
* May be called from any thread. After invoking this method, the source can expect * May be called from any thread. After invoking this method, the {@link MediaPeriod} can expect
* {@link #selectTracks(List, List, long)} to be invoked when the initial track selection. * for {@link #selectTracks(List, List, long)} to be invoked with the initial track selection.
* *
* @param source The prepared source. * @param mediaPeriod The prepared {@link MediaPeriod}.
*/ */
void onSourcePrepared(SampleSource source); void onPeriodPrepared(MediaPeriod mediaPeriod);
} }
/** /**
* Starts preparation of the source. * Starts preparation of the period.
* <p> * <p>
* {@link Callback#onSourcePrepared(SampleSource)} is invoked when preparation completes. If * {@link Callback#onPeriodPrepared(MediaPeriod)} is invoked when preparation completes. If
* preparation fails, {@link #maybeThrowPrepareError()} will throw an {@link IOException} if * preparation fails, {@link #maybeThrowPrepareError()} will throw an {@link IOException} if
* invoked. * invoked.
* *
* @param callback A callback to receive updates from the source. * @param callback A callback to receive updates from the period.
* @param allocator An {@link Allocator} from which to obtain media buffer allocations. * @param allocator An {@link Allocator} from which to obtain media buffer allocations.
* @param positionUs The player's current playback position. * @param positionUs The player's current playback position.
*/ */
void prepare(Callback callback, Allocator allocator, long positionUs); void prepare(Callback callback, Allocator allocator, long positionUs);
/** /**
* Throws an error that's preventing the source from becoming prepared. Does nothing if no such * Throws an error that's preventing the period from becoming prepared. Does nothing if no such
* error exists. * error exists.
* <p> * <p>
* This method should only be called before the source has completed preparation. * This method should only be called before the period has completed preparation.
* *
* @throws IOException The underlying error. * @throws IOException The underlying error.
*/ */
void maybeThrowPrepareError() throws IOException; void maybeThrowPrepareError() throws IOException;
/** /**
* Returns the duration of the source in microseconds, or {@link C#UNSET_TIME_US} if not known. * Returns the duration of the period in microseconds, or {@link C#UNSET_TIME_US} if not known.
* <p> * <p>
* If {@link #getBufferedPositionUs()} returns {@link C#END_OF_SOURCE_US}, the duration is * If {@link #getBufferedPositionUs()} returns {@link C#END_OF_SOURCE_US}, the duration is
* guaranteed to be known. * guaranteed to be known.
* <p> * <p>
* This method should only be called after the source has been prepared. * This method should only be called after the period has been prepared.
* *
* @return The duration of the source in microseconds, or {@link C#UNSET_TIME_US} if the duration * @return The duration of the period in microseconds, or {@link C#UNSET_TIME_US} if the duration
* is not known. * is not known.
*/ */
long getDurationUs(); long getDurationUs();
/** /**
* Returns the {@link TrackGroup}s exposed by the source. * Returns the {@link TrackGroup}s exposed by the period.
* <p> * <p>
* This method should only be called after the source has been prepared. * This method should only be called after the period has been prepared.
* *
* @return The {@link TrackGroup}s. * @return The {@link TrackGroup}s.
*/ */
...@@ -95,7 +95,7 @@ public interface SampleSource extends SequenceableLoader { ...@@ -95,7 +95,7 @@ public interface SampleSource extends SequenceableLoader {
* must have a {@link TrackSelection#group} index distinct from those of currently enabled tracks, * must have a {@link TrackSelection#group} index distinct from those of currently enabled tracks,
* except for those being unselected. * except for those being unselected.
* <p> * <p>
* This method should only be called after the source has been prepared. * This method should only be called after the period has been prepared.
* *
* @param oldStreams {@link TrackStream}s corresponding to tracks being unselected. May be empty * @param oldStreams {@link TrackStream}s corresponding to tracks being unselected. May be empty
* but must not be null. * but must not be null.
...@@ -111,7 +111,7 @@ public interface SampleSource extends SequenceableLoader { ...@@ -111,7 +111,7 @@ public interface SampleSource extends SequenceableLoader {
* Attempts to read a discontinuity. * Attempts to read a discontinuity.
* <p> * <p>
* After this method has returned a value other than {@link C#UNSET_TIME_US}, all * After this method has returned a value other than {@link C#UNSET_TIME_US}, all
* {@link TrackStream}s provided by the source are guaranteed to start from a key frame. * {@link TrackStream}s provided by the period are guaranteed to start from a key frame.
* *
* @return If a discontinuity was read then the playback position in microseconds after the * @return If a discontinuity was read then the playback position in microseconds after the
* discontinuity. Else {@link C#UNSET_TIME_US}. * discontinuity. Else {@link C#UNSET_TIME_US}.
...@@ -131,20 +131,20 @@ public interface SampleSource extends SequenceableLoader { ...@@ -131,20 +131,20 @@ public interface SampleSource extends SequenceableLoader {
/** /**
* Attempts to seek to the specified position in microseconds. * Attempts to seek to the specified position in microseconds.
* <p> * <p>
* After this method has been called, all {@link TrackStream}s provided by the source are * After this method has been called, all {@link TrackStream}s provided by the period are
* guaranteed to start from a key frame. * guaranteed to start from a key frame.
* <p> * <p>
* This method should only be called when at least one track is selected. * This method should only be called when at least one track is selected.
* *
* @param positionUs The seek position in microseconds. * @param positionUs The seek position in microseconds.
* @return The actual position to which the source was seeked, in microseconds. * @return The actual position to which the period was seeked, in microseconds.
*/ */
long seekToUs(long positionUs); long seekToUs(long positionUs);
/** /**
* Releases the source. * Releases the period.
* <p> * <p>
* This method should be called when the source is no longer required. It may be called in any * This method should be called when the period is no longer required. It may be called in any
* state. * state.
*/ */
void release(); void release();
......
...@@ -15,32 +15,31 @@ ...@@ -15,32 +15,31 @@
*/ */
package com.google.android.exoplayer2; package com.google.android.exoplayer2;
// TODO[playlists]: Rename this and maybe change the interface once we support multi-period DASH.
/** /**
* Provides a sequence of {@link SampleSource}s to play back. * A source of media consisting of one or more {@link MediaPeriod}s.
*/ */
public interface SampleSourceProvider { public interface MediaSource {
/** /**
* Returned by {@link #getSourceCount()} if the number of sources is not known. * Returned by {@link #getPeriodCount()} if the number of periods is not known.
*/ */
int UNKNOWN_SOURCE_COUNT = -1; int UNKNOWN_PERIOD_COUNT = -1;
/** /**
* Returns the number of sources in the sequence, or {@link #UNKNOWN_SOURCE_COUNT} if the number * Returns the number of periods in the source, or {@link #UNKNOWN_PERIOD_COUNT} if the number
* of sources is not yet known. * of periods is not yet known.
*/ */
int getSourceCount(); int getPeriodCount();
/** /**
* Returns a new {@link SampleSource} providing media at the specified index in the sequence, or * Returns a {@link MediaPeriod} corresponding to the period at the specified index, or
* {@code null} if the source at the specified index is not yet available. * {@code null} if the period at the specified index is not yet available.
* *
* @param index The index of the source to create, which must be less than the count returned by * @param index The index of the period. Must be less than {@link #getPeriodCount()} unless the
* {@link #getSourceCount()}. * period count is {@link #UNKNOWN_PERIOD_COUNT}.
* @return A new {@link SampleSource}, or {@code null} if the source at the specified index is not * @return A {@link MediaPeriod}, or {@code null} if the source at the specified index is not yet
* yet available. * available.
*/ */
SampleSource createSource(int index); MediaPeriod createPeriod(int index);
} }
...@@ -314,8 +314,8 @@ public final class SimpleExoPlayer implements ExoPlayer { ...@@ -314,8 +314,8 @@ public final class SimpleExoPlayer implements ExoPlayer {
} }
@Override @Override
public void setSourceProvider(SampleSourceProvider sourceProvider) { public void setMediaSource(MediaSource mediaSource) {
player.setSourceProvider(sourceProvider); player.setMediaSource(mediaSource);
} }
@Override @Override
...@@ -344,8 +344,8 @@ public final class SimpleExoPlayer implements ExoPlayer { ...@@ -344,8 +344,8 @@ public final class SimpleExoPlayer implements ExoPlayer {
} }
@Override @Override
public void seekTo(int sourceIndex, long positionMs) { public void seekTo(int periodIndex, long positionMs) {
player.seekTo(sourceIndex, positionMs); player.seekTo(periodIndex, positionMs);
} }
@Override @Override
...@@ -379,8 +379,8 @@ public final class SimpleExoPlayer implements ExoPlayer { ...@@ -379,8 +379,8 @@ public final class SimpleExoPlayer implements ExoPlayer {
} }
@Override @Override
public int getCurrentSourceIndex() { public int getCurrentPeriodIndex() {
return player.getCurrentSourceIndex(); return player.getCurrentPeriodIndex();
} }
@Override @Override
......
...@@ -31,21 +31,20 @@ import java.util.Arrays; ...@@ -31,21 +31,20 @@ import java.util.Arrays;
import java.util.List; import java.util.List;
/** /**
* A {@link SampleSource} that loads the data at a given {@link Uri} as a single sample. Also acts * Loads data at a given {@link Uri} as a single sample belonging to a single {@link MediaPeriod}.
* as a {@link SampleSourceProvider} providing {@link SingleSampleSource} instances.
*/ */
public final class SingleSampleSource implements SampleSource, SampleSourceProvider, TrackStream, public final class SingleSampleMediaSource implements MediaPeriod, MediaSource, TrackStream,
Loader.Callback<SingleSampleSource.SourceLoadable> { Loader.Callback<SingleSampleMediaSource.SourceLoadable> {
/** /**
* Interface definition for a callback to be notified of {@link SingleSampleSource} events. * Interface definition for a callback to be notified of {@link SingleSampleMediaSource} events.
*/ */
public interface EventListener { public interface EventListener {
/** /**
* Invoked when an error occurs loading media data. * Invoked when an error occurs loading media data.
* *
* @param sourceId The id of the reporting {@link SampleSource}. * @param sourceId The id of the reporting {@link SingleSampleMediaSource}.
* @param e The cause of the failure. * @param e The cause of the failure.
*/ */
void onLoadError(int sourceId, IOException e); void onLoadError(int sourceId, IOException e);
...@@ -83,17 +82,17 @@ public final class SingleSampleSource implements SampleSource, SampleSourceProvi ...@@ -83,17 +82,17 @@ public final class SingleSampleSource implements SampleSource, SampleSourceProvi
private byte[] sampleData; private byte[] sampleData;
private int sampleSize; private int sampleSize;
public SingleSampleSource(Uri uri, DataSourceFactory dataSourceFactory, Format format, public SingleSampleMediaSource(Uri uri, DataSourceFactory dataSourceFactory, Format format,
long durationUs) { long durationUs) {
this(uri, dataSourceFactory, format, durationUs, DEFAULT_MIN_LOADABLE_RETRY_COUNT); this(uri, dataSourceFactory, format, durationUs, DEFAULT_MIN_LOADABLE_RETRY_COUNT);
} }
public SingleSampleSource(Uri uri, DataSourceFactory dataSourceFactory, Format format, public SingleSampleMediaSource(Uri uri, DataSourceFactory dataSourceFactory, Format format,
long durationUs, int minLoadableRetryCount) { long durationUs, int minLoadableRetryCount) {
this(uri, dataSourceFactory, format, durationUs, minLoadableRetryCount, null, null, 0); this(uri, dataSourceFactory, format, durationUs, minLoadableRetryCount, null, null, 0);
} }
public SingleSampleSource(Uri uri, DataSourceFactory dataSourceFactory, Format format, public SingleSampleMediaSource(Uri uri, DataSourceFactory dataSourceFactory, Format format,
long durationUs, int minLoadableRetryCount, Handler eventHandler, EventListener eventListener, long durationUs, int minLoadableRetryCount, Handler eventHandler, EventListener eventListener,
int eventSourceId) { int eventSourceId) {
this.uri = uri; this.uri = uri;
...@@ -109,25 +108,25 @@ public final class SingleSampleSource implements SampleSource, SampleSourceProvi ...@@ -109,25 +108,25 @@ public final class SingleSampleSource implements SampleSource, SampleSourceProvi
streamState = STREAM_STATE_SEND_FORMAT; streamState = STREAM_STATE_SEND_FORMAT;
} }
// SampleSourceProvider implementation. // MediaSource implementation.
@Override @Override
public int getSourceCount() { public int getPeriodCount() {
return 1; return 1;
} }
@Override @Override
public SampleSource createSource(int index) { public MediaPeriod createPeriod(int index) {
Assertions.checkArgument(index == 0); Assertions.checkArgument(index == 0);
return this; return this;
} }
// SampleSource implementation. // MediaPeriod implementation.
@Override @Override
public void prepare(Callback callback, Allocator allocator, long positionUs) { public void prepare(Callback callback, Allocator allocator, long positionUs) {
loader = new Loader("Loader:SingleSampleSource"); loader = new Loader("Loader:SingleSampleMediaSource");
callback.onSourcePrepared(this); callback.onPeriodPrepared(this);
} }
@Override @Override
......
...@@ -20,9 +20,9 @@ import com.google.android.exoplayer2.util.Assertions; ...@@ -20,9 +20,9 @@ import com.google.android.exoplayer2.util.Assertions;
import java.util.Arrays; import java.util.Arrays;
/** /**
* Defines a group of tracks exposed by a {@link SampleSource}. * Defines a group of tracks exposed by a {@link MediaPeriod}.
* <p> * <p>
* A {@link SampleSource} is only able to provide one {@link TrackStream} corresponding to a group * A {@link MediaPeriod} is only able to provide one {@link TrackStream} corresponding to a group
* at any given time. If {@link #adaptive} is true this {@link TrackStream} can adapt between * at any given time. If {@link #adaptive} is true this {@link TrackStream} can adapt between
* multiple tracks within the group. If {@link #adaptive} is false then it's only possible to * multiple tracks within the group. If {@link #adaptive} is false then it's only possible to
* consume one track from the group at a given time. * consume one track from the group at a given time.
......
...@@ -18,7 +18,7 @@ package com.google.android.exoplayer2; ...@@ -18,7 +18,7 @@ package com.google.android.exoplayer2;
import java.util.Arrays; import java.util.Arrays;
/** /**
* An array of {@link TrackGroup}s exposed by a {@link SampleSource}. * An array of {@link TrackGroup}s exposed by a {@link MediaPeriod}.
*/ */
public final class TrackGroupArray { public final class TrackGroupArray {
......
...@@ -15,7 +15,7 @@ ...@@ -15,7 +15,7 @@
*/ */
package com.google.android.exoplayer2.chunk; package com.google.android.exoplayer2.chunk;
import com.google.android.exoplayer2.AdaptiveSourceEventListener.EventDispatcher; import com.google.android.exoplayer2.AdaptiveMediaSourceEventListener.EventDispatcher;
import com.google.android.exoplayer2.C; import com.google.android.exoplayer2.C;
import com.google.android.exoplayer2.DecoderInputBuffer; import com.google.android.exoplayer2.DecoderInputBuffer;
import com.google.android.exoplayer2.Format; import com.google.android.exoplayer2.Format;
......
...@@ -15,14 +15,14 @@ ...@@ -15,14 +15,14 @@
*/ */
package com.google.android.exoplayer2.dash; package com.google.android.exoplayer2.dash;
import com.google.android.exoplayer2.AdaptiveSourceEventListener; import com.google.android.exoplayer2.AdaptiveMediaSourceEventListener;
import com.google.android.exoplayer2.AdaptiveSourceEventListener.EventDispatcher; import com.google.android.exoplayer2.AdaptiveMediaSourceEventListener.EventDispatcher;
import com.google.android.exoplayer2.C; import com.google.android.exoplayer2.C;
import com.google.android.exoplayer2.CompositeSequenceableLoader; import com.google.android.exoplayer2.CompositeSequenceableLoader;
import com.google.android.exoplayer2.Format; import com.google.android.exoplayer2.Format;
import com.google.android.exoplayer2.MediaPeriod;
import com.google.android.exoplayer2.MediaSource;
import com.google.android.exoplayer2.ParserException; import com.google.android.exoplayer2.ParserException;
import com.google.android.exoplayer2.SampleSource;
import com.google.android.exoplayer2.SampleSourceProvider;
import com.google.android.exoplayer2.SequenceableLoader; import com.google.android.exoplayer2.SequenceableLoader;
import com.google.android.exoplayer2.TrackGroup; import com.google.android.exoplayer2.TrackGroup;
import com.google.android.exoplayer2.TrackGroupArray; import com.google.android.exoplayer2.TrackGroupArray;
...@@ -63,10 +63,9 @@ import java.util.Locale; ...@@ -63,10 +63,9 @@ import java.util.Locale;
import java.util.TimeZone; import java.util.TimeZone;
/** /**
* A {@link SampleSource} for DASH media. Also acts as a {@link SampleSourceProvider} providing * A DASH {@link MediaSource}.
* {@link DashSampleSource} instances.
*/ */
public final class DashSampleSource implements SampleSource, SampleSourceProvider, public final class DashMediaSource implements MediaPeriod, MediaSource,
SequenceableLoader.Callback<ChunkTrackStream<DashChunkSource>> { SequenceableLoader.Callback<ChunkTrackStream<DashChunkSource>> {
/** /**
...@@ -74,7 +73,7 @@ public final class DashSampleSource implements SampleSource, SampleSourceProvide ...@@ -74,7 +73,7 @@ public final class DashSampleSource implements SampleSource, SampleSourceProvide
*/ */
public static final int DEFAULT_MIN_LOADABLE_RETRY_COUNT = 3; public static final int DEFAULT_MIN_LOADABLE_RETRY_COUNT = 3;
private static final String TAG = "DashSampleSource"; private static final String TAG = "DashMediaSource";
private final DataSourceFactory dataSourceFactory; private final DataSourceFactory dataSourceFactory;
private final BandwidthMeter bandwidthMeter; private final BandwidthMeter bandwidthMeter;
...@@ -102,16 +101,16 @@ public final class DashSampleSource implements SampleSource, SampleSourceProvide ...@@ -102,16 +101,16 @@ public final class DashSampleSource implements SampleSource, SampleSourceProvide
private TrackGroupArray trackGroups; private TrackGroupArray trackGroups;
private int[] trackGroupAdaptationSetIndices; private int[] trackGroupAdaptationSetIndices;
public DashSampleSource(Uri manifestUri, DataSourceFactory dataSourceFactory, public DashMediaSource(Uri manifestUri, DataSourceFactory dataSourceFactory,
BandwidthMeter bandwidthMeter, Handler eventHandler, BandwidthMeter bandwidthMeter, Handler eventHandler,
AdaptiveSourceEventListener eventListener) { AdaptiveMediaSourceEventListener eventListener) {
this(manifestUri, dataSourceFactory, bandwidthMeter, DEFAULT_MIN_LOADABLE_RETRY_COUNT, this(manifestUri, dataSourceFactory, bandwidthMeter, DEFAULT_MIN_LOADABLE_RETRY_COUNT,
eventHandler, eventListener); eventHandler, eventListener);
} }
public DashSampleSource(Uri manifestUri, DataSourceFactory dataSourceFactory, public DashMediaSource(Uri manifestUri, DataSourceFactory dataSourceFactory,
BandwidthMeter bandwidthMeter, int minLoadableRetryCount, Handler eventHandler, BandwidthMeter bandwidthMeter, int minLoadableRetryCount, Handler eventHandler,
AdaptiveSourceEventListener eventListener) { AdaptiveMediaSourceEventListener eventListener) {
this.manifestUri = manifestUri; this.manifestUri = manifestUri;
this.dataSourceFactory = dataSourceFactory; this.dataSourceFactory = dataSourceFactory;
this.bandwidthMeter = bandwidthMeter; this.bandwidthMeter = bandwidthMeter;
...@@ -121,20 +120,20 @@ public final class DashSampleSource implements SampleSource, SampleSourceProvide ...@@ -121,20 +120,20 @@ public final class DashSampleSource implements SampleSource, SampleSourceProvide
manifestCallback = new ManifestCallback(); manifestCallback = new ManifestCallback();
} }
// SampleSourceProvider implementation. // MediaSource implementation.
@Override @Override
public int getSourceCount() { public int getPeriodCount() {
return 1; return 1;
} }
@Override @Override
public SampleSource createSource(int index) { public MediaPeriod createPeriod(int index) {
Assertions.checkArgument(index == 0); Assertions.checkArgument(index == 0);
return this; return this;
} }
// SampleSource implementation. // MediaPeriod implementation.
@Override @Override
public void prepare(Callback callback, Allocator allocator, long positionUs) { public void prepare(Callback callback, Allocator allocator, long positionUs) {
...@@ -143,7 +142,7 @@ public final class DashSampleSource implements SampleSource, SampleSourceProvide ...@@ -143,7 +142,7 @@ public final class DashSampleSource implements SampleSource, SampleSourceProvide
trackStreams = newTrackStreamArray(0); trackStreams = newTrackStreamArray(0);
sequenceableLoader = new CompositeSequenceableLoader(trackStreams); sequenceableLoader = new CompositeSequenceableLoader(trackStreams);
dataSource = dataSourceFactory.createDataSource(); dataSource = dataSourceFactory.createDataSource();
loader = new Loader("Loader:DashSampleSource"); loader = new Loader("Loader:DashMediaSource");
manifestRefreshHandler = new Handler(); manifestRefreshHandler = new Handler();
startLoadingManifest(); startLoadingManifest();
} }
...@@ -373,7 +372,7 @@ public final class DashSampleSource implements SampleSource, SampleSourceProvide ...@@ -373,7 +372,7 @@ public final class DashSampleSource implements SampleSource, SampleSourceProvide
private void finishPrepare() { private void finishPrepare() {
prepared = true; prepared = true;
callback.onSourcePrepared(this); callback.onPeriodPrepared(this);
scheduleManifestRefresh(); scheduleManifestRefresh();
} }
...@@ -467,7 +466,7 @@ public final class DashSampleSource implements SampleSource, SampleSourceProvide ...@@ -467,7 +466,7 @@ public final class DashSampleSource implements SampleSource, SampleSourceProvide
@Override @Override
public void onLoadCanceled(ParsingLoadable<MediaPresentationDescription> loadable, public void onLoadCanceled(ParsingLoadable<MediaPresentationDescription> loadable,
long elapsedRealtimeMs, long loadDurationMs, boolean released) { long elapsedRealtimeMs, long loadDurationMs, boolean released) {
DashSampleSource.this.onLoadCanceled(loadable, elapsedRealtimeMs, loadDurationMs); DashMediaSource.this.onLoadCanceled(loadable, elapsedRealtimeMs, loadDurationMs);
} }
@Override @Override
...@@ -489,7 +488,7 @@ public final class DashSampleSource implements SampleSource, SampleSourceProvide ...@@ -489,7 +488,7 @@ public final class DashSampleSource implements SampleSource, SampleSourceProvide
@Override @Override
public void onLoadCanceled(ParsingLoadable<Long> loadable, long elapsedRealtimeMs, public void onLoadCanceled(ParsingLoadable<Long> loadable, long elapsedRealtimeMs,
long loadDurationMs, boolean released) { long loadDurationMs, boolean released) {
DashSampleSource.this.onLoadCanceled(loadable, elapsedRealtimeMs, loadDurationMs); DashMediaSource.this.onLoadCanceled(loadable, elapsedRealtimeMs, loadDurationMs);
} }
@Override @Override
......
...@@ -19,9 +19,9 @@ import com.google.android.exoplayer2.C; ...@@ -19,9 +19,9 @@ import com.google.android.exoplayer2.C;
import com.google.android.exoplayer2.DecoderInputBuffer; import com.google.android.exoplayer2.DecoderInputBuffer;
import com.google.android.exoplayer2.Format; import com.google.android.exoplayer2.Format;
import com.google.android.exoplayer2.FormatHolder; import com.google.android.exoplayer2.FormatHolder;
import com.google.android.exoplayer2.MediaPeriod;
import com.google.android.exoplayer2.MediaSource;
import com.google.android.exoplayer2.ParserException; import com.google.android.exoplayer2.ParserException;
import com.google.android.exoplayer2.SampleSource;
import com.google.android.exoplayer2.SampleSourceProvider;
import com.google.android.exoplayer2.SequenceableLoader; import com.google.android.exoplayer2.SequenceableLoader;
import com.google.android.exoplayer2.TrackGroup; import com.google.android.exoplayer2.TrackGroup;
import com.google.android.exoplayer2.TrackGroupArray; import com.google.android.exoplayer2.TrackGroupArray;
...@@ -48,10 +48,10 @@ import java.util.Arrays; ...@@ -48,10 +48,10 @@ import java.util.Arrays;
import java.util.List; import java.util.List;
/** /**
* A {@link SampleSource} that extracts sample data using an {@link Extractor}. Also acts as a * Provides a single {@link MediaPeriod} whose data is loaded from a {@link Uri} and extracted using
* {@link SampleSourceProvider} providing {@link ExtractorSampleSource} instances. * an {@link Extractor}.
* * <p>
* <p>If the possible input stream container formats are known, pass a factory that instantiates * 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 * 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 * 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 * of extractors created by the factory that returns {@code true} from
...@@ -59,12 +59,12 @@ import java.util.List; ...@@ -59,12 +59,12 @@ import java.util.List;
* *
* <p>Note that the built-in extractors for AAC, MPEG TS and FLV streams do not support seeking. * <p>Note that the built-in extractors for AAC, MPEG TS and FLV streams do not support seeking.
*/ */
public final class ExtractorSampleSource implements SampleSource, SampleSourceProvider, public final class ExtractorMediaSource implements MediaPeriod, MediaSource,
ExtractorOutput, Loader.Callback<ExtractorSampleSource.ExtractingLoadable>, ExtractorOutput, Loader.Callback<ExtractorMediaSource.ExtractingLoadable>,
UpstreamFormatChangedListener { UpstreamFormatChangedListener {
/** /**
* Interface definition for a callback to be notified of {@link ExtractorSampleSource} events. * Interface definition for a callback to be notified of {@link ExtractorMediaSource} events.
*/ */
public interface EventListener { public interface EventListener {
...@@ -150,7 +150,7 @@ public final class ExtractorSampleSource implements SampleSource, SampleSourcePr ...@@ -150,7 +150,7 @@ public final class ExtractorSampleSource implements SampleSource, SampleSourcePr
* Otherwise, pass a {@link DefaultExtractorsFactory} to use default extractors. * Otherwise, pass a {@link DefaultExtractorsFactory} to use default extractors.
* @param eventListener A listener of events. May be null if delivery of events is not required. * @param eventListener A listener of events. May be null if delivery of events is not required.
*/ */
public ExtractorSampleSource(Uri uri, DataSourceFactory dataSourceFactory, public ExtractorMediaSource(Uri uri, DataSourceFactory dataSourceFactory,
BandwidthMeter bandwidthMeter, ExtractorsFactory extractorsFactory, Handler eventHandler, BandwidthMeter bandwidthMeter, ExtractorsFactory extractorsFactory, Handler eventHandler,
EventListener eventListener) { EventListener eventListener) {
this(uri, dataSourceFactory, bandwidthMeter, extractorsFactory, this(uri, dataSourceFactory, bandwidthMeter, extractorsFactory,
...@@ -168,7 +168,7 @@ public final class ExtractorSampleSource implements SampleSource, SampleSourcePr ...@@ -168,7 +168,7 @@ public final class ExtractorSampleSource implements SampleSource, SampleSourcePr
* if a loading error occurs. * if a loading error occurs.
* @param eventListener A listener of events. May be null if delivery of events is not required. * @param eventListener A listener of events. May be null if delivery of events is not required.
*/ */
public ExtractorSampleSource(Uri uri, DataSourceFactory dataSourceFactory, public ExtractorMediaSource(Uri uri, DataSourceFactory dataSourceFactory,
BandwidthMeter bandwidthMeter, ExtractorsFactory extractorsFactory, int minLoadableRetryCount, BandwidthMeter bandwidthMeter, ExtractorsFactory extractorsFactory, int minLoadableRetryCount,
Handler eventHandler, EventListener eventListener) { Handler eventHandler, EventListener eventListener) {
this.uri = uri; this.uri = uri;
...@@ -180,20 +180,20 @@ public final class ExtractorSampleSource implements SampleSource, SampleSourcePr ...@@ -180,20 +180,20 @@ public final class ExtractorSampleSource implements SampleSource, SampleSourcePr
this.eventListener = eventListener; this.eventListener = eventListener;
} }
// SampleSourceProvider implementation. // MediaSource implementation.
@Override @Override
public int getSourceCount() { public int getPeriodCount() {
return 1; return 1;
} }
@Override @Override
public SampleSource createSource(int index) { public MediaPeriod createPeriod(int index) {
Assertions.checkArgument(index == 0); Assertions.checkArgument(index == 0);
return this; return this;
} }
// SampleSource implementation. // MediaPeriod implementation.
@Override @Override
public void prepare(Callback callback, Allocator allocator, long positionUs) { public void prepare(Callback callback, Allocator allocator, long positionUs) {
...@@ -202,7 +202,7 @@ public final class ExtractorSampleSource implements SampleSource, SampleSourcePr ...@@ -202,7 +202,7 @@ public final class ExtractorSampleSource implements SampleSource, SampleSourcePr
dataSource = dataSourceFactory.createDataSource(bandwidthMeter); dataSource = dataSourceFactory.createDataSource(bandwidthMeter);
extractorHolder = new ExtractorHolder(extractorsFactory.createExtractors(), this); extractorHolder = new ExtractorHolder(extractorsFactory.createExtractors(), this);
loader = new Loader("Loader:ExtractorSampleSource", extractorHolder); loader = new Loader("Loader:ExtractorMediaSource", extractorHolder);
loadCondition = new ConditionVariable(); loadCondition = new ConditionVariable();
pendingResetPositionUs = C.UNSET_TIME_US; pendingResetPositionUs = C.UNSET_TIME_US;
sampleQueues = new DefaultTrackOutput[0]; sampleQueues = new DefaultTrackOutput[0];
...@@ -483,7 +483,7 @@ public final class ExtractorSampleSource implements SampleSource, SampleSourcePr ...@@ -483,7 +483,7 @@ public final class ExtractorSampleSource implements SampleSource, SampleSourcePr
} }
tracks = new TrackGroupArray(trackArray); tracks = new TrackGroupArray(trackArray);
prepared = true; prepared = true;
callback.onSourcePrepared(this); callback.onPeriodPrepared(this);
} }
private void copyLengthFromLoader(ExtractingLoadable loadable) { private void copyLengthFromLoader(ExtractingLoadable loadable) {
...@@ -584,17 +584,17 @@ public final class ExtractorSampleSource implements SampleSource, SampleSourcePr ...@@ -584,17 +584,17 @@ public final class ExtractorSampleSource implements SampleSource, SampleSourcePr
@Override @Override
public boolean isReady() { public boolean isReady() {
return ExtractorSampleSource.this.isReady(track); return ExtractorMediaSource.this.isReady(track);
} }
@Override @Override
public void maybeThrowError() throws IOException { public void maybeThrowError() throws IOException {
ExtractorSampleSource.this.maybeThrowError(); ExtractorMediaSource.this.maybeThrowError();
} }
@Override @Override
public int readData(FormatHolder formatHolder, DecoderInputBuffer buffer) { public int readData(FormatHolder formatHolder, DecoderInputBuffer buffer) {
return ExtractorSampleSource.this.readData(track, formatHolder, buffer); return ExtractorMediaSource.this.readData(track, formatHolder, buffer);
} }
} }
...@@ -670,7 +670,7 @@ public final class ExtractorSampleSource implements SampleSource, SampleSourcePr ...@@ -670,7 +670,7 @@ public final class ExtractorSampleSource implements SampleSource, SampleSourcePr
if (input.getPosition() > position + CONTINUE_LOADING_CHECK_INTERVAL_BYTES) { if (input.getPosition() > position + CONTINUE_LOADING_CHECK_INTERVAL_BYTES) {
position = input.getPosition(); position = input.getPosition();
loadCondition.close(); loadCondition.close();
callback.onContinueLoadingRequested(ExtractorSampleSource.this); callback.onContinueLoadingRequested(ExtractorMediaSource.this);
} }
} }
} finally { } finally {
......
...@@ -15,14 +15,14 @@ ...@@ -15,14 +15,14 @@
*/ */
package com.google.android.exoplayer2.hls; package com.google.android.exoplayer2.hls;
import com.google.android.exoplayer2.AdaptiveSourceEventListener; import com.google.android.exoplayer2.AdaptiveMediaSourceEventListener;
import com.google.android.exoplayer2.AdaptiveSourceEventListener.EventDispatcher; import com.google.android.exoplayer2.AdaptiveMediaSourceEventListener.EventDispatcher;
import com.google.android.exoplayer2.C; import com.google.android.exoplayer2.C;
import com.google.android.exoplayer2.CompositeSequenceableLoader; import com.google.android.exoplayer2.CompositeSequenceableLoader;
import com.google.android.exoplayer2.Format; import com.google.android.exoplayer2.Format;
import com.google.android.exoplayer2.MediaPeriod;
import com.google.android.exoplayer2.MediaSource;
import com.google.android.exoplayer2.ParserException; import com.google.android.exoplayer2.ParserException;
import com.google.android.exoplayer2.SampleSource;
import com.google.android.exoplayer2.SampleSourceProvider;
import com.google.android.exoplayer2.TrackGroup; import com.google.android.exoplayer2.TrackGroup;
import com.google.android.exoplayer2.TrackGroupArray; import com.google.android.exoplayer2.TrackGroupArray;
import com.google.android.exoplayer2.TrackSelection; import com.google.android.exoplayer2.TrackSelection;
...@@ -53,10 +53,9 @@ import java.util.IdentityHashMap; ...@@ -53,10 +53,9 @@ import java.util.IdentityHashMap;
import java.util.List; import java.util.List;
/** /**
* A {@link SampleSource} for HLS streams. Also acts as a {@link SampleSourceProvider} providing * An HLS {@link MediaSource}.
* {@link HlsSampleSource} instances.
*/ */
public final class HlsSampleSource implements SampleSource, SampleSourceProvider, public final class HlsMediaSource implements MediaPeriod, MediaSource,
Loader.Callback<ParsingLoadable<HlsPlaylist>>, HlsTrackStreamWrapper.Callback { Loader.Callback<ParsingLoadable<HlsPlaylist>>, HlsTrackStreamWrapper.Callback {
/** /**
...@@ -90,16 +89,16 @@ public final class HlsSampleSource implements SampleSource, SampleSourceProvider ...@@ -90,16 +89,16 @@ public final class HlsSampleSource implements SampleSource, SampleSourceProvider
private HlsTrackStreamWrapper[] enabledTrackStreamWrappers; private HlsTrackStreamWrapper[] enabledTrackStreamWrappers;
private CompositeSequenceableLoader sequenceableLoader; private CompositeSequenceableLoader sequenceableLoader;
public HlsSampleSource(Uri manifestUri, DataSourceFactory dataSourceFactory, public HlsMediaSource(Uri manifestUri, DataSourceFactory dataSourceFactory,
BandwidthMeter bandwidthMeter, Handler eventHandler, BandwidthMeter bandwidthMeter, Handler eventHandler,
AdaptiveSourceEventListener eventListener) { AdaptiveMediaSourceEventListener eventListener) {
this(manifestUri, dataSourceFactory, bandwidthMeter, DEFAULT_MIN_LOADABLE_RETRY_COUNT, this(manifestUri, dataSourceFactory, bandwidthMeter, DEFAULT_MIN_LOADABLE_RETRY_COUNT,
eventHandler, eventListener); eventHandler, eventListener);
} }
public HlsSampleSource(Uri manifestUri, DataSourceFactory dataSourceFactory, public HlsMediaSource(Uri manifestUri, DataSourceFactory dataSourceFactory,
BandwidthMeter bandwidthMeter, int minLoadableRetryCount, Handler eventHandler, BandwidthMeter bandwidthMeter, int minLoadableRetryCount, Handler eventHandler,
AdaptiveSourceEventListener eventListener) { AdaptiveMediaSourceEventListener eventListener) {
this.manifestUri = manifestUri; this.manifestUri = manifestUri;
this.dataSourceFactory = dataSourceFactory; this.dataSourceFactory = dataSourceFactory;
this.bandwidthMeter = bandwidthMeter; this.bandwidthMeter = bandwidthMeter;
...@@ -111,20 +110,20 @@ public final class HlsSampleSource implements SampleSource, SampleSourceProvider ...@@ -111,20 +110,20 @@ public final class HlsSampleSource implements SampleSource, SampleSourceProvider
manifestParser = new HlsPlaylistParser(); manifestParser = new HlsPlaylistParser();
} }
// SampleSourceProvider implementation. // MediaSource implementation.
@Override @Override
public int getSourceCount() { public int getPeriodCount() {
return 1; return 1;
} }
@Override @Override
public SampleSource createSource(int index) { public MediaPeriod createPeriod(int index) {
Assertions.checkArgument(index == 0); Assertions.checkArgument(index == 0);
return this; return this;
} }
// SampleSource implementation. // MediaPeriod implementation.
@Override @Override
public void prepare(Callback callback, Allocator allocator, long positionUs) { public void prepare(Callback callback, Allocator allocator, long positionUs) {
...@@ -314,7 +313,7 @@ public final class HlsSampleSource implements SampleSource, SampleSourceProvider ...@@ -314,7 +313,7 @@ public final class HlsSampleSource implements SampleSource, SampleSourceProvider
} }
} }
trackGroups = new TrackGroupArray(trackGroupArray); trackGroups = new TrackGroupArray(trackGroupArray);
callback.onSourcePrepared(this); callback.onPeriodPrepared(this);
} }
@Override @Override
......
...@@ -15,7 +15,7 @@ ...@@ -15,7 +15,7 @@
*/ */
package com.google.android.exoplayer2.hls; package com.google.android.exoplayer2.hls;
import com.google.android.exoplayer2.AdaptiveSourceEventListener.EventDispatcher; import com.google.android.exoplayer2.AdaptiveMediaSourceEventListener.EventDispatcher;
import com.google.android.exoplayer2.C; import com.google.android.exoplayer2.C;
import com.google.android.exoplayer2.DecoderInputBuffer; import com.google.android.exoplayer2.DecoderInputBuffer;
import com.google.android.exoplayer2.Format; import com.google.android.exoplayer2.Format;
......
...@@ -15,14 +15,14 @@ ...@@ -15,14 +15,14 @@
*/ */
package com.google.android.exoplayer2.smoothstreaming; package com.google.android.exoplayer2.smoothstreaming;
import com.google.android.exoplayer2.AdaptiveSourceEventListener; import com.google.android.exoplayer2.AdaptiveMediaSourceEventListener;
import com.google.android.exoplayer2.AdaptiveSourceEventListener.EventDispatcher; import com.google.android.exoplayer2.AdaptiveMediaSourceEventListener.EventDispatcher;
import com.google.android.exoplayer2.C; import com.google.android.exoplayer2.C;
import com.google.android.exoplayer2.CompositeSequenceableLoader; import com.google.android.exoplayer2.CompositeSequenceableLoader;
import com.google.android.exoplayer2.Format; import com.google.android.exoplayer2.Format;
import com.google.android.exoplayer2.MediaPeriod;
import com.google.android.exoplayer2.MediaSource;
import com.google.android.exoplayer2.ParserException; import com.google.android.exoplayer2.ParserException;
import com.google.android.exoplayer2.SampleSource;
import com.google.android.exoplayer2.SampleSourceProvider;
import com.google.android.exoplayer2.SequenceableLoader; import com.google.android.exoplayer2.SequenceableLoader;
import com.google.android.exoplayer2.TrackGroup; import com.google.android.exoplayer2.TrackGroup;
import com.google.android.exoplayer2.TrackGroupArray; import com.google.android.exoplayer2.TrackGroupArray;
...@@ -53,10 +53,9 @@ import java.util.Arrays; ...@@ -53,10 +53,9 @@ import java.util.Arrays;
import java.util.List; import java.util.List;
/** /**
* A {@link SampleSource} for SmoothStreaming media. Also acts as a {@link SampleSourceProvider} * A SmoothStreaming {@link MediaSource}.
* providing {@link SmoothStreamingSampleSource} instances.
*/ */
public final class SmoothStreamingSampleSource implements SampleSource, SampleSourceProvider, public final class SmoothStreamingMediaSource implements MediaPeriod, MediaSource,
SequenceableLoader.Callback<ChunkTrackStream<SmoothStreamingChunkSource>>, SequenceableLoader.Callback<ChunkTrackStream<SmoothStreamingChunkSource>>,
Loader.Callback<ParsingLoadable<SmoothStreamingManifest>> { Loader.Callback<ParsingLoadable<SmoothStreamingManifest>> {
...@@ -92,16 +91,16 @@ public final class SmoothStreamingSampleSource implements SampleSource, SampleSo ...@@ -92,16 +91,16 @@ public final class SmoothStreamingSampleSource implements SampleSource, SampleSo
private TrackGroupArray trackGroups; private TrackGroupArray trackGroups;
private int[] trackGroupElementIndices; private int[] trackGroupElementIndices;
public SmoothStreamingSampleSource(Uri manifestUri, DataSourceFactory dataSourceFactory, public SmoothStreamingMediaSource(Uri manifestUri, DataSourceFactory dataSourceFactory,
BandwidthMeter bandwidthMeter, Handler eventHandler, BandwidthMeter bandwidthMeter, Handler eventHandler,
AdaptiveSourceEventListener eventListener) { AdaptiveMediaSourceEventListener eventListener) {
this(manifestUri, dataSourceFactory, bandwidthMeter, DEFAULT_MIN_LOADABLE_RETRY_COUNT, this(manifestUri, dataSourceFactory, bandwidthMeter, DEFAULT_MIN_LOADABLE_RETRY_COUNT,
eventHandler, eventListener); eventHandler, eventListener);
} }
public SmoothStreamingSampleSource(Uri manifestUri, DataSourceFactory dataSourceFactory, public SmoothStreamingMediaSource(Uri manifestUri, DataSourceFactory dataSourceFactory,
BandwidthMeter bandwidthMeter, int minLoadableRetryCount, Handler eventHandler, BandwidthMeter bandwidthMeter, int minLoadableRetryCount, Handler eventHandler,
AdaptiveSourceEventListener eventListener) { AdaptiveMediaSourceEventListener eventListener) {
this.manifestUri = Util.toLowerInvariant(manifestUri.getLastPathSegment()).equals("manifest") this.manifestUri = Util.toLowerInvariant(manifestUri.getLastPathSegment()).equals("manifest")
? manifestUri : Uri.withAppendedPath(manifestUri, "Manifest"); ? manifestUri : Uri.withAppendedPath(manifestUri, "Manifest");
this.dataSourceFactory = dataSourceFactory; this.dataSourceFactory = dataSourceFactory;
...@@ -111,20 +110,20 @@ public final class SmoothStreamingSampleSource implements SampleSource, SampleSo ...@@ -111,20 +110,20 @@ public final class SmoothStreamingSampleSource implements SampleSource, SampleSo
manifestParser = new SmoothStreamingManifestParser(); manifestParser = new SmoothStreamingManifestParser();
} }
// SampleSourceProvider implementation. // MediaSource implementation.
@Override @Override
public int getSourceCount() { public int getPeriodCount() {
return 1; return 1;
} }
@Override @Override
public SampleSource createSource(int index) { public MediaPeriod createPeriod(int index) {
Assertions.checkArgument(index == 0); Assertions.checkArgument(index == 0);
return this; return this;
} }
// SampleSource implementation. // MediaPeriod implementation.
@Override @Override
public void prepare(Callback callback, Allocator allocator, long positionUs) { public void prepare(Callback callback, Allocator allocator, long positionUs) {
...@@ -273,7 +272,7 @@ public final class SmoothStreamingSampleSource implements SampleSource, SampleSo ...@@ -273,7 +272,7 @@ public final class SmoothStreamingSampleSource implements SampleSource, SampleSo
new TrackEncryptionBox(true, INITIALIZATION_VECTOR_SIZE, keyId)}; new TrackEncryptionBox(true, INITIALIZATION_VECTOR_SIZE, keyId)};
} }
prepared = true; prepared = true;
callback.onSourcePrepared(this); callback.onPeriodPrepared(this);
} else { } else {
for (ChunkTrackStream<SmoothStreamingChunkSource> trackStream : trackStreams) { for (ChunkTrackStream<SmoothStreamingChunkSource> trackStream : trackStreams) {
trackStream.getChunkSource().updateManifest(manifest); trackStream.getChunkSource().updateManifest(manifest);
......
...@@ -81,7 +81,7 @@ public final class DebugTextViewHelper implements Runnable, ExoPlayer.EventListe ...@@ -81,7 +81,7 @@ public final class DebugTextViewHelper implements Runnable, ExoPlayer.EventListe
} }
private void updateTextView() { private void updateTextView() {
textView.setText(getPlayerStateString() + getPlayerSourceIndexString() + getBandwidthString() textView.setText(getPlayerStateString() + getPlayerPeriodIndexString() + getBandwidthString()
+ getVideoString() + getAudioString()); + getVideoString() + getAudioString());
} }
...@@ -107,8 +107,8 @@ public final class DebugTextViewHelper implements Runnable, ExoPlayer.EventListe ...@@ -107,8 +107,8 @@ public final class DebugTextViewHelper implements Runnable, ExoPlayer.EventListe
return text; return text;
} }
private String getPlayerSourceIndexString() { private String getPlayerPeriodIndexString() {
return " source:" + player.getCurrentSourceIndex(); return " period:" + player.getCurrentPeriodIndex();
} }
private String getBandwidthString() { private String getBandwidthString() {
...@@ -169,7 +169,7 @@ public final class DebugTextViewHelper implements Runnable, ExoPlayer.EventListe ...@@ -169,7 +169,7 @@ public final class DebugTextViewHelper implements Runnable, ExoPlayer.EventListe
} }
@Override @Override
public void onPositionDiscontinuity(int sourceIndex, long positionMs) { public void onPositionDiscontinuity(int periodIndex, long positionMs) {
updateTextView(); updateTextView();
} }
......
...@@ -22,13 +22,13 @@ import com.google.android.exoplayer2.ExoPlaybackException; ...@@ -22,13 +22,13 @@ import com.google.android.exoplayer2.ExoPlaybackException;
import com.google.android.exoplayer2.ExoPlayer; import com.google.android.exoplayer2.ExoPlayer;
import com.google.android.exoplayer2.MediaCodecUtil; import com.google.android.exoplayer2.MediaCodecUtil;
import com.google.android.exoplayer2.MediaCodecUtil.DecoderQueryException; import com.google.android.exoplayer2.MediaCodecUtil.DecoderQueryException;
import com.google.android.exoplayer2.SampleSourceProvider; import com.google.android.exoplayer2.MediaSource;
import com.google.android.exoplayer2.TrackGroup; import com.google.android.exoplayer2.TrackGroup;
import com.google.android.exoplayer2.TrackGroupArray; import com.google.android.exoplayer2.TrackGroupArray;
import com.google.android.exoplayer2.TrackRenderer; import com.google.android.exoplayer2.TrackRenderer;
import com.google.android.exoplayer2.TrackSelection; import com.google.android.exoplayer2.TrackSelection;
import com.google.android.exoplayer2.TrackSelectionPolicy; import com.google.android.exoplayer2.TrackSelectionPolicy;
import com.google.android.exoplayer2.dash.DashSampleSource; import com.google.android.exoplayer2.dash.DashMediaSource;
import com.google.android.exoplayer2.playbacktests.util.ActionSchedule; import com.google.android.exoplayer2.playbacktests.util.ActionSchedule;
import com.google.android.exoplayer2.playbacktests.util.CodecCountersUtil; import com.google.android.exoplayer2.playbacktests.util.CodecCountersUtil;
import com.google.android.exoplayer2.playbacktests.util.ExoHostedTest; import com.google.android.exoplayer2.playbacktests.util.ExoHostedTest;
...@@ -418,9 +418,9 @@ public final class DashTest extends ActivityInstrumentationTestCase2<HostActivit ...@@ -418,9 +418,9 @@ public final class DashTest extends ActivityInstrumentationTestCase2<HostActivit
} }
@Override @Override
public SampleSourceProvider buildSource(HostActivity host, DataSourceFactory dataSourceFactory, public MediaSource buildSource(HostActivity host, DataSourceFactory dataSourceFactory,
BandwidthMeter bandwidthMeter) { BandwidthMeter bandwidthMeter) {
return new DashSampleSource(manifestUri, dataSourceFactory, bandwidthMeter, return new DashMediaSource(manifestUri, dataSourceFactory, bandwidthMeter,
MIN_LOADABLE_RETRY_COUNT, null, null); MIN_LOADABLE_RETRY_COUNT, null, null);
} }
......
...@@ -22,7 +22,7 @@ import com.google.android.exoplayer2.ExoPlaybackException; ...@@ -22,7 +22,7 @@ import com.google.android.exoplayer2.ExoPlaybackException;
import com.google.android.exoplayer2.ExoPlayer; import com.google.android.exoplayer2.ExoPlayer;
import com.google.android.exoplayer2.ExoPlayerFactory; import com.google.android.exoplayer2.ExoPlayerFactory;
import com.google.android.exoplayer2.Format; import com.google.android.exoplayer2.Format;
import com.google.android.exoplayer2.SampleSourceProvider; import com.google.android.exoplayer2.MediaSource;
import com.google.android.exoplayer2.SimpleExoPlayer; import com.google.android.exoplayer2.SimpleExoPlayer;
import com.google.android.exoplayer2.TrackSelectionPolicy; import com.google.android.exoplayer2.TrackSelectionPolicy;
import com.google.android.exoplayer2.audio.AudioTrack; import com.google.android.exoplayer2.audio.AudioTrack;
...@@ -128,7 +128,7 @@ public abstract class ExoHostedTest implements HostedTest, ExoPlayer.EventListen ...@@ -128,7 +128,7 @@ public abstract class ExoHostedTest implements HostedTest, ExoPlayer.EventListen
player = buildExoPlayer(host, surface, trackSelector); player = buildExoPlayer(host, surface, trackSelector);
DataSourceFactory dataSourceFactory = new DefaultDataSourceFactory(host, Util DataSourceFactory dataSourceFactory = new DefaultDataSourceFactory(host, Util
.getUserAgent(host, "ExoPlayerPlaybackTests")); .getUserAgent(host, "ExoPlayerPlaybackTests"));
player.setSourceProvider(buildSource(host, dataSourceFactory, player.getBandwidthMeter())); player.setMediaSource(buildSource(host, dataSourceFactory, player.getBandwidthMeter()));
player.addListener(this); player.addListener(this);
player.setDebugListener(this); player.setDebugListener(this);
player.setPlayWhenReady(true); player.setPlayWhenReady(true);
...@@ -210,7 +210,7 @@ public abstract class ExoHostedTest implements HostedTest, ExoPlayer.EventListen ...@@ -210,7 +210,7 @@ public abstract class ExoHostedTest implements HostedTest, ExoPlayer.EventListen
} }
@Override @Override
public final void onPositionDiscontinuity(int sourceIndex, long positionMs) { public final void onPositionDiscontinuity(int periodIndex, long positionMs) {
// Do nothing. // Do nothing.
} }
...@@ -287,8 +287,8 @@ public abstract class ExoHostedTest implements HostedTest, ExoPlayer.EventListen ...@@ -287,8 +287,8 @@ public abstract class ExoHostedTest implements HostedTest, ExoPlayer.EventListen
} }
@SuppressWarnings("unused") @SuppressWarnings("unused")
protected abstract SampleSourceProvider buildSource(HostActivity host, protected abstract MediaSource buildSource(HostActivity host, DataSourceFactory dataSourceFactory,
DataSourceFactory dataSourceFactory, BandwidthMeter bandwidthMeter); BandwidthMeter bandwidthMeter);
@SuppressWarnings("unused") @SuppressWarnings("unused")
protected void onPlayerErrorInternal(ExoPlaybackException error) { protected void onPlayerErrorInternal(ExoPlaybackException error) {
......
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