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 @@
*/
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.DefaultTrackSelector;
import com.google.android.exoplayer2.DefaultTrackSelector.TrackInfo;
......@@ -28,7 +28,7 @@ import com.google.android.exoplayer2.TrackGroupArray;
import com.google.android.exoplayer2.TrackRenderer;
import com.google.android.exoplayer2.TrackSelection;
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 android.os.SystemClock;
......@@ -42,7 +42,7 @@ import java.util.Locale;
* Logs player events using {@link Log}.
*/
public class EventLogger implements ExoPlayer.EventListener, SimpleExoPlayer.DebugListener,
AdaptiveSourceEventListener, ExtractorSampleSource.EventListener,
AdaptiveMediaSourceEventListener, ExtractorMediaSource.EventListener,
StreamingDrmSessionManager.EventListener, DefaultTrackSelector.EventListener {
private static final String TAG = "EventLogger";
......@@ -78,8 +78,8 @@ public class EventLogger implements ExoPlayer.EventListener, SimpleExoPlayer.Deb
}
@Override
public void onPositionDiscontinuity(int sourceIndex, long positionMs) {
Log.d(TAG, "discontinuity [" + sourceIndex + ", " + positionMs + "]");
public void onPositionDiscontinuity(int periodIndex, long positionMs) {
Log.d(TAG, "discontinuity [" + periodIndex + ", " + positionMs + "]");
}
@Override
......@@ -211,14 +211,14 @@ public class EventLogger implements ExoPlayer.EventListener, SimpleExoPlayer.Deb
Log.d(TAG, "drmKeysLoaded [" + getSessionTimeString() + "]");
}
// ExtractorSampleSource.EventListener
// ExtractorMediaSource.EventListener
@Override
public void onLoadError(IOException error) {
printInternalError("loadError", error);
}
// AdaptiveSourceEventListener
// AdaptiveMediaSourceEventListener
@Override
public void onLoadStarted(DataSpec dataSpec, int dataType, int trackType, Format format,
......
......@@ -17,7 +17,7 @@ package com.google.android.exoplayer2.demo;
import com.google.android.exoplayer2.AspectRatioFrameLayout;
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.DefaultTrackSelectionPolicy;
import com.google.android.exoplayer2.DefaultTrackSelector;
......@@ -27,23 +27,23 @@ import com.google.android.exoplayer2.ExoPlayer;
import com.google.android.exoplayer2.ExoPlayerFactory;
import com.google.android.exoplayer2.MediaCodecTrackRenderer.DecoderInitializationException;
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.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.StreamingDrmSessionManager;
import com.google.android.exoplayer2.drm.UnsupportedDrmException;
import com.google.android.exoplayer2.extractor.DefaultExtractorsFactory;
import com.google.android.exoplayer2.extractor.ExtractorSampleSource;
import com.google.android.exoplayer2.hls.HlsSampleSource;
import com.google.android.exoplayer2.extractor.ExtractorMediaSource;
import com.google.android.exoplayer2.hls.HlsMediaSource;
import com.google.android.exoplayer2.metadata.id3.ApicFrame;
import com.google.android.exoplayer2.metadata.id3.GeobFrame;
import com.google.android.exoplayer2.metadata.id3.Id3Frame;
import com.google.android.exoplayer2.metadata.id3.PrivFrame;
import com.google.android.exoplayer2.metadata.id3.TextInformationFrame;
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.Cue;
import com.google.android.exoplayer2.text.SubtitleLayout;
......@@ -320,34 +320,33 @@ public class PlayerActivity extends Activity implements SurfaceHolder.Callback,
return;
}
SampleSourceProvider[] providers = new SampleSourceProvider[uris.length];
MediaSource[] mediaSources = new MediaSource[uris.length];
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]
: new ConcatenatingSampleSourceProvider(providers);
player.setSourceProvider(sourceProvider);
MediaSource mediaSource = mediaSources.length == 1 ? mediaSources[0]
: new ConcatenatingMediaSource(mediaSources);
player.setMediaSource(mediaSource);
playerNeedsSource = false;
updateButtonVisibilities();
}
}
private SampleSourceProvider getSampleSourceProvider(Uri uri, String overrideExtension) {
private MediaSource getMediaSource(Uri uri, String overrideExtension) {
String lastPathSegment = !TextUtils.isEmpty(overrideExtension) ? "." + overrideExtension
: uri.getLastPathSegment();
int type = Util.inferContentType(lastPathSegment);
switch (type) {
case Util.TYPE_SS:
return new SmoothStreamingSampleSource(uri, dataSourceFactory, bandwidthMeter, mainHandler,
return new SmoothStreamingMediaSource(uri, dataSourceFactory, bandwidthMeter, mainHandler,
eventLogger);
case Util.TYPE_DASH:
return new DashSampleSource(uri, dataSourceFactory, bandwidthMeter, mainHandler,
return new DashMediaSource(uri, dataSourceFactory, bandwidthMeter, mainHandler,
eventLogger);
case Util.TYPE_HLS:
return new HlsSampleSource(uri, dataSourceFactory, bandwidthMeter, mainHandler,
eventLogger);
return new HlsMediaSource(uri, dataSourceFactory, bandwidthMeter, mainHandler, eventLogger);
case Util.TYPE_OTHER:
return new ExtractorSampleSource(uri, dataSourceFactory, bandwidthMeter,
return new ExtractorMediaSource(uri, dataSourceFactory, bandwidthMeter,
new DefaultExtractorsFactory(), mainHandler, eventLogger);
default:
throw new IllegalStateException("Unsupported type: " + type);
......@@ -437,7 +436,7 @@ public class PlayerActivity extends Activity implements SurfaceHolder.Callback,
}
@Override
public void onPositionDiscontinuity(int sourceIndex, long positionMs) {
public void onPositionDiscontinuity(int periodIndex, long positionMs) {
if (mediaController.isShowing()) {
// The MediaController is visible, so force it to show the updated position immediately.
mediaController.show();
......
......@@ -21,7 +21,7 @@ import com.google.android.exoplayer2.ExoPlaybackException;
import com.google.android.exoplayer2.ExoPlayer;
import com.google.android.exoplayer2.ExoPlayerFactory;
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.upstream.DefaultDataSourceFactory;
......@@ -76,14 +76,14 @@ public class FlacPlaybackTest extends InstrumentationTestCase {
new DefaultTrackSelectionPolicy(), null);
player = ExoPlayerFactory.newInstance(new TrackRenderer[] {audioRenderer}, trackSelector);
player.addListener(this);
ExtractorSampleSource sampleSource = new ExtractorSampleSource(
ExtractorMediaSource mediaSource = new ExtractorMediaSource(
uri,
new DefaultDataSourceFactory(context, "ExoPlayerExtFlacTest"),
null,
new MatroskaExtractor.Factory(),
null,
null);
player.setSourceProvider(sampleSource);
player.setMediaSource(mediaSource);
player.setPlayWhenReady(true);
Looper.loop();
}
......@@ -99,7 +99,7 @@ public class FlacPlaybackTest extends InstrumentationTestCase {
}
@Override
public void onPositionDiscontinuity(int sourceIndex, long positionMs) {
public void onPositionDiscontinuity(int periodIndex, long positionMs) {
// Do nothing.
}
......
......@@ -21,7 +21,7 @@ import com.google.android.exoplayer2.ExoPlaybackException;
import com.google.android.exoplayer2.ExoPlayer;
import com.google.android.exoplayer2.ExoPlayerFactory;
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.upstream.DefaultDataSourceFactory;
......@@ -76,14 +76,14 @@ public class OpusPlaybackTest extends InstrumentationTestCase {
new DefaultTrackSelectionPolicy(), null);
player = ExoPlayerFactory.newInstance(new TrackRenderer[] {audioRenderer}, trackSelector);
player.addListener(this);
ExtractorSampleSource sampleSource = new ExtractorSampleSource(
ExtractorMediaSource mediaSource = new ExtractorMediaSource(
uri,
new DefaultDataSourceFactory(context, "ExoPlayerExtOpusTest"),
null,
new MatroskaExtractor.Factory(),
null,
null);
player.setSourceProvider(sampleSource);
player.setMediaSource(mediaSource);
player.setPlayWhenReady(true);
Looper.loop();
}
......@@ -99,7 +99,7 @@ public class OpusPlaybackTest extends InstrumentationTestCase {
}
@Override
public void onPositionDiscontinuity(int sourceIndex, long positionMs) {
public void onPositionDiscontinuity(int periodIndex, long positionMs) {
// 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;
import com.google.android.exoplayer2.ExoPlayer;
import com.google.android.exoplayer2.ExoPlayerFactory;
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.upstream.DefaultDataSourceFactory;
......@@ -92,7 +92,7 @@ public class VpxPlaybackTest extends InstrumentationTestCase {
new DefaultTrackSelectionPolicy(), null);
player = ExoPlayerFactory.newInstance(new TrackRenderer[] {videoRenderer}, trackSelector);
player.addListener(this);
ExtractorSampleSource sampleSource = new ExtractorSampleSource(
ExtractorMediaSource mediaSource = new ExtractorMediaSource(
uri,
new DefaultDataSourceFactory(context, "ExoPlayerExtVp9Test"),
null,
......@@ -102,7 +102,7 @@ public class VpxPlaybackTest extends InstrumentationTestCase {
player.sendMessages(new ExoPlayer.ExoPlayerMessage(videoRenderer,
LibvpxVideoTrackRenderer.MSG_SET_OUTPUT_BUFFER_RENDERER,
new VpxVideoSurfaceView(context)));
player.setSourceProvider(sampleSource);
player.setMediaSource(mediaSource);
player.setPlayWhenReady(true);
Looper.loop();
}
......@@ -118,7 +118,7 @@ public class VpxPlaybackTest extends InstrumentationTestCase {
}
@Override
public void onPositionDiscontinuity(int sourceIndex, long positionMs) {
public void onPositionDiscontinuity(int periodIndex, long positionMs) {
// 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;
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.
......@@ -171,14 +171,14 @@ public interface AdaptiveSourceEventListener {
Object formatEvaluatorData, long mediaTimeMs);
/**
* Dispatches events to a {@link AdaptiveSourceEventListener}.
* Dispatches events to a {@link AdaptiveMediaSourceEventListener}.
*/
final class EventDispatcher {
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.listener = listener;
}
......
......@@ -16,26 +16,26 @@
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) {
this.sampleSourceProviders = sampleSourcePoviders;
public ConcatenatingMediaSource(MediaSource... mediaSources) {
this.mediaSources = mediaSources;
}
@Override
public int getSourceCount() {
public int getPeriodCount() {
int sourceCount = 0;
for (SampleSourceProvider sampleSourceProvider : sampleSourceProviders) {
int count = sampleSourceProvider.getSourceCount();
if (count == SampleSourceProvider.UNKNOWN_SOURCE_COUNT) {
return UNKNOWN_SOURCE_COUNT;
for (MediaSource mediaSource : mediaSources) {
int count = mediaSource.getPeriodCount();
if (count == MediaSource.UNKNOWN_PERIOD_COUNT) {
return UNKNOWN_PERIOD_COUNT;
}
sourceCount += count;
}
......@@ -43,12 +43,12 @@ public final class ConcatenatingSampleSourceProvider implements SampleSourceProv
}
@Override
public SampleSource createSource(int index) {
public MediaPeriod createPeriod(int index) {
int sourceCount = 0;
for (SampleSourceProvider sampleSourceProvider : sampleSourceProviders) {
int count = sampleSourceProvider.getSourceCount();
if (count == SampleSourceProvider.UNKNOWN_SOURCE_COUNT || index < sourceCount + count) {
return sampleSourceProvider.createSource(index - sourceCount);
for (MediaSource mediaSource : mediaSources) {
int count = mediaSource.getPeriodCount();
if (count == MediaSource.UNKNOWN_PERIOD_COUNT || index < sourceCount + count) {
return mediaSource.createPeriod(index - sourceCount);
}
sourceCount += count;
}
......
......@@ -25,7 +25,7 @@ import java.io.IOException;
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>
* Call {@link #getSourceException()} to retrieve the underlying cause.
*/
......
......@@ -38,11 +38,11 @@ package com.google.android.exoplayer2;
*
* <p>{@link MediaCodecAudioTrackRenderer} and {@link MediaCodecVideoTrackRenderer} can be used for
* 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
* 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
* 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
* implementations enabling the loading of data from various sources.
*
......@@ -84,8 +84,7 @@ package com.google.android.exoplayer2;
*
* <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
* {@link #setSource(SampleSource)}, {@link #setSourceProvider(SampleSourceProvider)},
* {@link #stop()} or {@link #release()} being invoked.</p>
* {@link #setMediaSource(MediaSource)}, {@link #stop()} or {@link #release()} being invoked.</p>
* <p align="center"><img src="../../../../../images/exoplayer_playbackstate.png"
* alt="ExoPlayer playback state transitions"
* border="0"/></p>
......@@ -128,12 +127,12 @@ public interface ExoPlayer {
// 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
* transitioning to the next source).
* transitioning to the next period).
*
* @param sourceIndex The index of the source being played.
* @param positionMs The playback position in that source, in milliseconds.
* @param periodIndex The index of the period being played.
* @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
......@@ -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;
/**
......@@ -236,17 +235,18 @@ public interface ExoPlayer {
int getPlaybackState();
/**
* Sets the player's source provider. The player's position will be reset to the start of the
* first source and the player will transition to {@link #STATE_BUFFERING} until it is ready to
* play it.
* Sets the {@link MediaSource} to play.
* <p>
* 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}.
* 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.
*
* @param playWhenReady Whether playback should proceed when ready.
......@@ -276,19 +276,19 @@ public interface ExoPlayer {
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.
*/
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 positionMs The seek position relative to the start of the specified source.
* @param periodIndex The index of the period to seek to.
* @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
......@@ -298,9 +298,7 @@ public interface ExoPlayer {
* {@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.
* <p>
* Calling this method does not reset the playback position. If this player instance will be used
* to play another video from its start, then {@code seekTo(0)} should be called after stopping
* the player and before setting the next source.
* Calling this method does not reset the playback position.
*/
void stop();
......@@ -337,18 +335,18 @@ public interface ExoPlayer {
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();
/**
* 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.
......
......@@ -40,14 +40,14 @@ import java.util.concurrent.CopyOnWriteArraySet;
private boolean playWhenReady;
private int playbackState;
private int pendingPlayWhenReadyAcks;
private int pendingSetSourceProviderAndSeekAcks;
private int pendingSetMediaSourceAndSeekAcks;
private boolean isLoading;
// Playback information when there is no pending seek/set source operation.
private PlaybackInfo playbackInfo;
// Playback information when there is a pending seek/set source operation.
private int maskingSourceIndex;
private int maskingPeriodIndex;
private long maskingPositionMs;
private long maskingDurationMs;
......@@ -94,13 +94,13 @@ import java.util.concurrent.CopyOnWriteArraySet;
}
@Override
public void setSourceProvider(SampleSourceProvider sourceProvider) {
maskingSourceIndex = 0;
public void setMediaSource(MediaSource mediaSource) {
maskingPeriodIndex = 0;
maskingPositionMs = 0;
maskingDurationMs = ExoPlayer.UNKNOWN_TIME;
pendingSetSourceProviderAndSeekAcks++;
internalPlayer.setSourceProvider(sourceProvider);
pendingSetMediaSourceAndSeekAcks++;
internalPlayer.setMediaSource(mediaSource);
for (EventListener listener : listeners) {
listener.onPositionDiscontinuity(0, 0);
}
......@@ -135,20 +135,20 @@ import java.util.concurrent.CopyOnWriteArraySet;
@Override
public void seekTo(long positionMs) {
seekTo(getCurrentSourceIndex(), positionMs);
seekTo(getCurrentPeriodIndex(), positionMs);
}
@Override
public void seekTo(int sourceIndex, long positionMs) {
boolean sourceChanging = sourceIndex != getCurrentSourceIndex();
maskingSourceIndex = sourceIndex;
public void seekTo(int periodIndex, long positionMs) {
boolean periodChanging = periodIndex != getCurrentPeriodIndex();
maskingPeriodIndex = periodIndex;
maskingPositionMs = positionMs;
maskingDurationMs = sourceChanging ? ExoPlayer.UNKNOWN_TIME : getDuration();
maskingDurationMs = periodChanging ? ExoPlayer.UNKNOWN_TIME : getDuration();
pendingSetSourceProviderAndSeekAcks++;
internalPlayer.seekTo(sourceIndex, positionMs * 1000);
pendingSetMediaSourceAndSeekAcks++;
internalPlayer.seekTo(periodIndex, positionMs * 1000);
for (EventListener listener : listeners) {
listener.onPositionDiscontinuity(sourceIndex, positionMs);
listener.onPositionDiscontinuity(periodIndex, positionMs);
}
}
......@@ -175,7 +175,7 @@ import java.util.concurrent.CopyOnWriteArraySet;
@Override
public long getDuration() {
if (pendingSetSourceProviderAndSeekAcks == 0) {
if (pendingSetMediaSourceAndSeekAcks == 0) {
long durationUs = playbackInfo.durationUs;
return durationUs == C.UNSET_TIME_US ? ExoPlayer.UNKNOWN_TIME : durationUs / 1000;
} else {
......@@ -185,18 +185,18 @@ import java.util.concurrent.CopyOnWriteArraySet;
@Override
public long getCurrentPosition() {
return pendingSetSourceProviderAndSeekAcks == 0 ? playbackInfo.positionUs / 1000
return pendingSetMediaSourceAndSeekAcks == 0 ? playbackInfo.positionUs / 1000
: maskingPositionMs;
}
@Override
public int getCurrentSourceIndex() {
return pendingSetSourceProviderAndSeekAcks == 0 ? playbackInfo.sourceIndex : maskingSourceIndex;
public int getCurrentPeriodIndex() {
return pendingSetMediaSourceAndSeekAcks == 0 ? playbackInfo.periodIndex : maskingPeriodIndex;
}
@Override
public long getBufferedPosition() {
if (pendingSetSourceProviderAndSeekAcks == 0) {
if (pendingSetMediaSourceAndSeekAcks == 0) {
long bufferedPositionUs = playbackInfo.bufferedPositionUs;
return bufferedPositionUs == C.END_OF_SOURCE_US ? getDuration() : bufferedPositionUs / 1000;
} else {
......@@ -238,16 +238,16 @@ import java.util.concurrent.CopyOnWriteArraySet;
}
break;
}
case ExoPlayerImplInternal.MSG_SET_SOURCE_PROVIDER_ACK: // Fall through.
case ExoPlayerImplInternal.MSG_SET_MEDIA_SOURCE_ACK: // Fall through.
case ExoPlayerImplInternal.MSG_SEEK_ACK: {
pendingSetSourceProviderAndSeekAcks--;
pendingSetMediaSourceAndSeekAcks--;
break;
}
case ExoPlayerImplInternal.MSG_SOURCE_CHANGED: {
case ExoPlayerImplInternal.MSG_PERIOD_CHANGED: {
playbackInfo = (ExoPlayerImplInternal.PlaybackInfo) msg.obj;
if (pendingSetSourceProviderAndSeekAcks == 0) {
if (pendingSetMediaSourceAndSeekAcks == 0) {
for (EventListener listener : listeners) {
listener.onPositionDiscontinuity(playbackInfo.sourceIndex, 0);
listener.onPositionDiscontinuity(playbackInfo.periodIndex, 0);
}
}
break;
......
......@@ -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.
* @throws ExoPlaybackException If an error occurs reinitializing the {@link MediaCodec}.
......
......@@ -21,67 +21,67 @@ import java.io.IOException;
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>
* May be called from any thread. After invoking this method, the source can expect
* {@link #selectTracks(List, List, long)} to be invoked when the initial track selection.
* May be called from any thread. After invoking this method, the {@link MediaPeriod} can expect
* 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>
* {@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
* 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 positionUs The player's current playback position.
*/
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.
* <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.
*/
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>
* If {@link #getBufferedPositionUs()} returns {@link C#END_OF_SOURCE_US}, the duration is
* guaranteed to be known.
* <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.
*/
long getDurationUs();
/**
* Returns the {@link TrackGroup}s exposed by the source.
* Returns the {@link TrackGroup}s exposed by the period.
* <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.
*/
......@@ -95,7 +95,7 @@ public interface SampleSource extends SequenceableLoader {
* must have a {@link TrackSelection#group} index distinct from those of currently enabled tracks,
* except for those being unselected.
* <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
* but must not be null.
......@@ -111,7 +111,7 @@ public interface SampleSource extends SequenceableLoader {
* Attempts to read a discontinuity.
* <p>
* 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
* discontinuity. Else {@link C#UNSET_TIME_US}.
......@@ -131,20 +131,20 @@ public interface SampleSource extends SequenceableLoader {
/**
* Attempts to seek to the specified position in microseconds.
* <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.
* <p>
* This method should only be called when at least one track is selected.
*
* @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);
/**
* Releases the source.
* Releases the period.
* <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.
*/
void release();
......
......@@ -15,32 +15,31 @@
*/
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
* of sources is not yet known.
* Returns the number of periods in the source, or {@link #UNKNOWN_PERIOD_COUNT} if the number
* 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
* {@code null} if the source at the specified index is not yet available.
* Returns a {@link MediaPeriod} corresponding to the period at the specified index, or
* {@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
* {@link #getSourceCount()}.
* @return A new {@link SampleSource}, or {@code null} if the source at the specified index is not
* yet available.
* @param index The index of the period. Must be less than {@link #getPeriodCount()} unless the
* period count is {@link #UNKNOWN_PERIOD_COUNT}.
* @return A {@link MediaPeriod}, or {@code null} if the source at the specified index is not yet
* available.
*/
SampleSource createSource(int index);
MediaPeriod createPeriod(int index);
}
......@@ -314,8 +314,8 @@ public final class SimpleExoPlayer implements ExoPlayer {
}
@Override
public void setSourceProvider(SampleSourceProvider sourceProvider) {
player.setSourceProvider(sourceProvider);
public void setMediaSource(MediaSource mediaSource) {
player.setMediaSource(mediaSource);
}
@Override
......@@ -344,8 +344,8 @@ public final class SimpleExoPlayer implements ExoPlayer {
}
@Override
public void seekTo(int sourceIndex, long positionMs) {
player.seekTo(sourceIndex, positionMs);
public void seekTo(int periodIndex, long positionMs) {
player.seekTo(periodIndex, positionMs);
}
@Override
......@@ -379,8 +379,8 @@ public final class SimpleExoPlayer implements ExoPlayer {
}
@Override
public int getCurrentSourceIndex() {
return player.getCurrentSourceIndex();
public int getCurrentPeriodIndex() {
return player.getCurrentPeriodIndex();
}
@Override
......
......@@ -31,21 +31,20 @@ import java.util.Arrays;
import java.util.List;
/**
* A {@link SampleSource} that loads the data at a given {@link Uri} as a single sample. Also acts
* as a {@link SampleSourceProvider} providing {@link SingleSampleSource} instances.
* Loads data at a given {@link Uri} as a single sample belonging to a single {@link MediaPeriod}.
*/
public final class SingleSampleSource implements SampleSource, SampleSourceProvider, TrackStream,
Loader.Callback<SingleSampleSource.SourceLoadable> {
public final class SingleSampleMediaSource implements MediaPeriod, MediaSource, TrackStream,
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 {
/**
* 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.
*/
void onLoadError(int sourceId, IOException e);
......@@ -83,17 +82,17 @@ public final class SingleSampleSource implements SampleSource, SampleSourceProvi
private byte[] sampleData;
private int sampleSize;
public SingleSampleSource(Uri uri, DataSourceFactory dataSourceFactory, Format format,
public SingleSampleMediaSource(Uri uri, DataSourceFactory dataSourceFactory, Format format,
long durationUs) {
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) {
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,
int eventSourceId) {
this.uri = uri;
......@@ -109,25 +108,25 @@ public final class SingleSampleSource implements SampleSource, SampleSourceProvi
streamState = STREAM_STATE_SEND_FORMAT;
}
// SampleSourceProvider implementation.
// MediaSource implementation.
@Override
public int getSourceCount() {
public int getPeriodCount() {
return 1;
}
@Override
public SampleSource createSource(int index) {
public MediaPeriod createPeriod(int index) {
Assertions.checkArgument(index == 0);
return this;
}
// SampleSource implementation.
// MediaPeriod implementation.
@Override
public void prepare(Callback callback, Allocator allocator, long positionUs) {
loader = new Loader("Loader:SingleSampleSource");
callback.onSourcePrepared(this);
loader = new Loader("Loader:SingleSampleMediaSource");
callback.onPeriodPrepared(this);
}
@Override
......
......@@ -20,9 +20,9 @@ import com.google.android.exoplayer2.util.Assertions;
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>
* 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
* 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.
......
......@@ -18,7 +18,7 @@ package com.google.android.exoplayer2;
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 {
......
......@@ -15,7 +15,7 @@
*/
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.DecoderInputBuffer;
import com.google.android.exoplayer2.Format;
......
......@@ -15,14 +15,14 @@
*/
package com.google.android.exoplayer2.dash;
import com.google.android.exoplayer2.AdaptiveSourceEventListener;
import com.google.android.exoplayer2.AdaptiveSourceEventListener.EventDispatcher;
import com.google.android.exoplayer2.AdaptiveMediaSourceEventListener;
import com.google.android.exoplayer2.AdaptiveMediaSourceEventListener.EventDispatcher;
import com.google.android.exoplayer2.C;
import com.google.android.exoplayer2.CompositeSequenceableLoader;
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.SampleSource;
import com.google.android.exoplayer2.SampleSourceProvider;
import com.google.android.exoplayer2.SequenceableLoader;
import com.google.android.exoplayer2.TrackGroup;
import com.google.android.exoplayer2.TrackGroupArray;
......@@ -63,10 +63,9 @@ import java.util.Locale;
import java.util.TimeZone;
/**
* A {@link SampleSource} for DASH media. Also acts as a {@link SampleSourceProvider} providing
* {@link DashSampleSource} instances.
* A DASH {@link MediaSource}.
*/
public final class DashSampleSource implements SampleSource, SampleSourceProvider,
public final class DashMediaSource implements MediaPeriod, MediaSource,
SequenceableLoader.Callback<ChunkTrackStream<DashChunkSource>> {
/**
......@@ -74,7 +73,7 @@ public final class DashSampleSource implements SampleSource, SampleSourceProvide
*/
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 BandwidthMeter bandwidthMeter;
......@@ -102,16 +101,16 @@ public final class DashSampleSource implements SampleSource, SampleSourceProvide
private TrackGroupArray trackGroups;
private int[] trackGroupAdaptationSetIndices;
public DashSampleSource(Uri manifestUri, DataSourceFactory dataSourceFactory,
public DashMediaSource(Uri manifestUri, DataSourceFactory dataSourceFactory,
BandwidthMeter bandwidthMeter, Handler eventHandler,
AdaptiveSourceEventListener eventListener) {
AdaptiveMediaSourceEventListener eventListener) {
this(manifestUri, dataSourceFactory, bandwidthMeter, DEFAULT_MIN_LOADABLE_RETRY_COUNT,
eventHandler, eventListener);
}
public DashSampleSource(Uri manifestUri, DataSourceFactory dataSourceFactory,
public DashMediaSource(Uri manifestUri, DataSourceFactory dataSourceFactory,
BandwidthMeter bandwidthMeter, int minLoadableRetryCount, Handler eventHandler,
AdaptiveSourceEventListener eventListener) {
AdaptiveMediaSourceEventListener eventListener) {
this.manifestUri = manifestUri;
this.dataSourceFactory = dataSourceFactory;
this.bandwidthMeter = bandwidthMeter;
......@@ -121,20 +120,20 @@ public final class DashSampleSource implements SampleSource, SampleSourceProvide
manifestCallback = new ManifestCallback();
}
// SampleSourceProvider implementation.
// MediaSource implementation.
@Override
public int getSourceCount() {
public int getPeriodCount() {
return 1;
}
@Override
public SampleSource createSource(int index) {
public MediaPeriod createPeriod(int index) {
Assertions.checkArgument(index == 0);
return this;
}
// SampleSource implementation.
// MediaPeriod implementation.
@Override
public void prepare(Callback callback, Allocator allocator, long positionUs) {
......@@ -143,7 +142,7 @@ public final class DashSampleSource implements SampleSource, SampleSourceProvide
trackStreams = newTrackStreamArray(0);
sequenceableLoader = new CompositeSequenceableLoader(trackStreams);
dataSource = dataSourceFactory.createDataSource();
loader = new Loader("Loader:DashSampleSource");
loader = new Loader("Loader:DashMediaSource");
manifestRefreshHandler = new Handler();
startLoadingManifest();
}
......@@ -373,7 +372,7 @@ public final class DashSampleSource implements SampleSource, SampleSourceProvide
private void finishPrepare() {
prepared = true;
callback.onSourcePrepared(this);
callback.onPeriodPrepared(this);
scheduleManifestRefresh();
}
......@@ -467,7 +466,7 @@ public final class DashSampleSource implements SampleSource, SampleSourceProvide
@Override
public void onLoadCanceled(ParsingLoadable<MediaPresentationDescription> loadable,
long elapsedRealtimeMs, long loadDurationMs, boolean released) {
DashSampleSource.this.onLoadCanceled(loadable, elapsedRealtimeMs, loadDurationMs);
DashMediaSource.this.onLoadCanceled(loadable, elapsedRealtimeMs, loadDurationMs);
}
@Override
......@@ -489,7 +488,7 @@ public final class DashSampleSource implements SampleSource, SampleSourceProvide
@Override
public void onLoadCanceled(ParsingLoadable<Long> loadable, long elapsedRealtimeMs,
long loadDurationMs, boolean released) {
DashSampleSource.this.onLoadCanceled(loadable, elapsedRealtimeMs, loadDurationMs);
DashMediaSource.this.onLoadCanceled(loadable, elapsedRealtimeMs, loadDurationMs);
}
@Override
......
......@@ -19,9 +19,9 @@ import com.google.android.exoplayer2.C;
import com.google.android.exoplayer2.DecoderInputBuffer;
import com.google.android.exoplayer2.Format;
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.SampleSource;
import com.google.android.exoplayer2.SampleSourceProvider;
import com.google.android.exoplayer2.SequenceableLoader;
import com.google.android.exoplayer2.TrackGroup;
import com.google.android.exoplayer2.TrackGroupArray;
......@@ -48,10 +48,10 @@ import java.util.Arrays;
import java.util.List;
/**
* A {@link SampleSource} that extracts sample data using an {@link Extractor}. Also acts as a
* {@link SampleSourceProvider} providing {@link ExtractorSampleSource} instances.
*
* <p>If the possible input stream container formats are known, pass a factory that instantiates
* Provides a single {@link MediaPeriod} whose data is loaded from a {@link Uri} and extracted using
* an {@link Extractor}.
* <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
......@@ -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.
*/
public final class ExtractorSampleSource implements SampleSource, SampleSourceProvider,
ExtractorOutput, Loader.Callback<ExtractorSampleSource.ExtractingLoadable>,
public final class ExtractorMediaSource implements MediaPeriod, MediaSource,
ExtractorOutput, Loader.Callback<ExtractorMediaSource.ExtractingLoadable>,
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 {
......@@ -150,7 +150,7 @@ public final class ExtractorSampleSource implements SampleSource, SampleSourcePr
* 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.
*/
public ExtractorSampleSource(Uri uri, DataSourceFactory dataSourceFactory,
public ExtractorMediaSource(Uri uri, DataSourceFactory dataSourceFactory,
BandwidthMeter bandwidthMeter, ExtractorsFactory extractorsFactory, Handler eventHandler,
EventListener eventListener) {
this(uri, dataSourceFactory, bandwidthMeter, extractorsFactory,
......@@ -168,7 +168,7 @@ public final class ExtractorSampleSource implements SampleSource, SampleSourcePr
* if a loading error occurs.
* @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,
Handler eventHandler, EventListener eventListener) {
this.uri = uri;
......@@ -180,20 +180,20 @@ public final class ExtractorSampleSource implements SampleSource, SampleSourcePr
this.eventListener = eventListener;
}
// SampleSourceProvider implementation.
// MediaSource implementation.
@Override
public int getSourceCount() {
public int getPeriodCount() {
return 1;
}
@Override
public SampleSource createSource(int index) {
public MediaPeriod createPeriod(int index) {
Assertions.checkArgument(index == 0);
return this;
}
// SampleSource implementation.
// MediaPeriod implementation.
@Override
public void prepare(Callback callback, Allocator allocator, long positionUs) {
......@@ -202,7 +202,7 @@ public final class ExtractorSampleSource implements SampleSource, SampleSourcePr
dataSource = dataSourceFactory.createDataSource(bandwidthMeter);
extractorHolder = new ExtractorHolder(extractorsFactory.createExtractors(), this);
loader = new Loader("Loader:ExtractorSampleSource", extractorHolder);
loader = new Loader("Loader:ExtractorMediaSource", extractorHolder);
loadCondition = new ConditionVariable();
pendingResetPositionUs = C.UNSET_TIME_US;
sampleQueues = new DefaultTrackOutput[0];
......@@ -483,7 +483,7 @@ public final class ExtractorSampleSource implements SampleSource, SampleSourcePr
}
tracks = new TrackGroupArray(trackArray);
prepared = true;
callback.onSourcePrepared(this);
callback.onPeriodPrepared(this);
}
private void copyLengthFromLoader(ExtractingLoadable loadable) {
......@@ -584,17 +584,17 @@ public final class ExtractorSampleSource implements SampleSource, SampleSourcePr
@Override
public boolean isReady() {
return ExtractorSampleSource.this.isReady(track);
return ExtractorMediaSource.this.isReady(track);
}
@Override
public void maybeThrowError() throws IOException {
ExtractorSampleSource.this.maybeThrowError();
ExtractorMediaSource.this.maybeThrowError();
}
@Override
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
if (input.getPosition() > position + CONTINUE_LOADING_CHECK_INTERVAL_BYTES) {
position = input.getPosition();
loadCondition.close();
callback.onContinueLoadingRequested(ExtractorSampleSource.this);
callback.onContinueLoadingRequested(ExtractorMediaSource.this);
}
}
} finally {
......
......@@ -15,14 +15,14 @@
*/
package com.google.android.exoplayer2.hls;
import com.google.android.exoplayer2.AdaptiveSourceEventListener;
import com.google.android.exoplayer2.AdaptiveSourceEventListener.EventDispatcher;
import com.google.android.exoplayer2.AdaptiveMediaSourceEventListener;
import com.google.android.exoplayer2.AdaptiveMediaSourceEventListener.EventDispatcher;
import com.google.android.exoplayer2.C;
import com.google.android.exoplayer2.CompositeSequenceableLoader;
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.SampleSource;
import com.google.android.exoplayer2.SampleSourceProvider;
import com.google.android.exoplayer2.TrackGroup;
import com.google.android.exoplayer2.TrackGroupArray;
import com.google.android.exoplayer2.TrackSelection;
......@@ -53,10 +53,9 @@ import java.util.IdentityHashMap;
import java.util.List;
/**
* A {@link SampleSource} for HLS streams. Also acts as a {@link SampleSourceProvider} providing
* {@link HlsSampleSource} instances.
* An HLS {@link MediaSource}.
*/
public final class HlsSampleSource implements SampleSource, SampleSourceProvider,
public final class HlsMediaSource implements MediaPeriod, MediaSource,
Loader.Callback<ParsingLoadable<HlsPlaylist>>, HlsTrackStreamWrapper.Callback {
/**
......@@ -90,16 +89,16 @@ public final class HlsSampleSource implements SampleSource, SampleSourceProvider
private HlsTrackStreamWrapper[] enabledTrackStreamWrappers;
private CompositeSequenceableLoader sequenceableLoader;
public HlsSampleSource(Uri manifestUri, DataSourceFactory dataSourceFactory,
public HlsMediaSource(Uri manifestUri, DataSourceFactory dataSourceFactory,
BandwidthMeter bandwidthMeter, Handler eventHandler,
AdaptiveSourceEventListener eventListener) {
AdaptiveMediaSourceEventListener eventListener) {
this(manifestUri, dataSourceFactory, bandwidthMeter, DEFAULT_MIN_LOADABLE_RETRY_COUNT,
eventHandler, eventListener);
}
public HlsSampleSource(Uri manifestUri, DataSourceFactory dataSourceFactory,
public HlsMediaSource(Uri manifestUri, DataSourceFactory dataSourceFactory,
BandwidthMeter bandwidthMeter, int minLoadableRetryCount, Handler eventHandler,
AdaptiveSourceEventListener eventListener) {
AdaptiveMediaSourceEventListener eventListener) {
this.manifestUri = manifestUri;
this.dataSourceFactory = dataSourceFactory;
this.bandwidthMeter = bandwidthMeter;
......@@ -111,20 +110,20 @@ public final class HlsSampleSource implements SampleSource, SampleSourceProvider
manifestParser = new HlsPlaylistParser();
}
// SampleSourceProvider implementation.
// MediaSource implementation.
@Override
public int getSourceCount() {
public int getPeriodCount() {
return 1;
}
@Override
public SampleSource createSource(int index) {
public MediaPeriod createPeriod(int index) {
Assertions.checkArgument(index == 0);
return this;
}
// SampleSource implementation.
// MediaPeriod implementation.
@Override
public void prepare(Callback callback, Allocator allocator, long positionUs) {
......@@ -314,7 +313,7 @@ public final class HlsSampleSource implements SampleSource, SampleSourceProvider
}
}
trackGroups = new TrackGroupArray(trackGroupArray);
callback.onSourcePrepared(this);
callback.onPeriodPrepared(this);
}
@Override
......
......@@ -15,7 +15,7 @@
*/
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.DecoderInputBuffer;
import com.google.android.exoplayer2.Format;
......
......@@ -15,14 +15,14 @@
*/
package com.google.android.exoplayer2.smoothstreaming;
import com.google.android.exoplayer2.AdaptiveSourceEventListener;
import com.google.android.exoplayer2.AdaptiveSourceEventListener.EventDispatcher;
import com.google.android.exoplayer2.AdaptiveMediaSourceEventListener;
import com.google.android.exoplayer2.AdaptiveMediaSourceEventListener.EventDispatcher;
import com.google.android.exoplayer2.C;
import com.google.android.exoplayer2.CompositeSequenceableLoader;
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.SampleSource;
import com.google.android.exoplayer2.SampleSourceProvider;
import com.google.android.exoplayer2.SequenceableLoader;
import com.google.android.exoplayer2.TrackGroup;
import com.google.android.exoplayer2.TrackGroupArray;
......@@ -53,10 +53,9 @@ import java.util.Arrays;
import java.util.List;
/**
* A {@link SampleSource} for SmoothStreaming media. Also acts as a {@link SampleSourceProvider}
* providing {@link SmoothStreamingSampleSource} instances.
* A SmoothStreaming {@link MediaSource}.
*/
public final class SmoothStreamingSampleSource implements SampleSource, SampleSourceProvider,
public final class SmoothStreamingMediaSource implements MediaPeriod, MediaSource,
SequenceableLoader.Callback<ChunkTrackStream<SmoothStreamingChunkSource>>,
Loader.Callback<ParsingLoadable<SmoothStreamingManifest>> {
......@@ -92,16 +91,16 @@ public final class SmoothStreamingSampleSource implements SampleSource, SampleSo
private TrackGroupArray trackGroups;
private int[] trackGroupElementIndices;
public SmoothStreamingSampleSource(Uri manifestUri, DataSourceFactory dataSourceFactory,
public SmoothStreamingMediaSource(Uri manifestUri, DataSourceFactory dataSourceFactory,
BandwidthMeter bandwidthMeter, Handler eventHandler,
AdaptiveSourceEventListener eventListener) {
AdaptiveMediaSourceEventListener eventListener) {
this(manifestUri, dataSourceFactory, bandwidthMeter, DEFAULT_MIN_LOADABLE_RETRY_COUNT,
eventHandler, eventListener);
}
public SmoothStreamingSampleSource(Uri manifestUri, DataSourceFactory dataSourceFactory,
public SmoothStreamingMediaSource(Uri manifestUri, DataSourceFactory dataSourceFactory,
BandwidthMeter bandwidthMeter, int minLoadableRetryCount, Handler eventHandler,
AdaptiveSourceEventListener eventListener) {
AdaptiveMediaSourceEventListener eventListener) {
this.manifestUri = Util.toLowerInvariant(manifestUri.getLastPathSegment()).equals("manifest")
? manifestUri : Uri.withAppendedPath(manifestUri, "Manifest");
this.dataSourceFactory = dataSourceFactory;
......@@ -111,20 +110,20 @@ public final class SmoothStreamingSampleSource implements SampleSource, SampleSo
manifestParser = new SmoothStreamingManifestParser();
}
// SampleSourceProvider implementation.
// MediaSource implementation.
@Override
public int getSourceCount() {
public int getPeriodCount() {
return 1;
}
@Override
public SampleSource createSource(int index) {
public MediaPeriod createPeriod(int index) {
Assertions.checkArgument(index == 0);
return this;
}
// SampleSource implementation.
// MediaPeriod implementation.
@Override
public void prepare(Callback callback, Allocator allocator, long positionUs) {
......@@ -273,7 +272,7 @@ public final class SmoothStreamingSampleSource implements SampleSource, SampleSo
new TrackEncryptionBox(true, INITIALIZATION_VECTOR_SIZE, keyId)};
}
prepared = true;
callback.onSourcePrepared(this);
callback.onPeriodPrepared(this);
} else {
for (ChunkTrackStream<SmoothStreamingChunkSource> trackStream : trackStreams) {
trackStream.getChunkSource().updateManifest(manifest);
......
......@@ -81,7 +81,7 @@ public final class DebugTextViewHelper implements Runnable, ExoPlayer.EventListe
}
private void updateTextView() {
textView.setText(getPlayerStateString() + getPlayerSourceIndexString() + getBandwidthString()
textView.setText(getPlayerStateString() + getPlayerPeriodIndexString() + getBandwidthString()
+ getVideoString() + getAudioString());
}
......@@ -107,8 +107,8 @@ public final class DebugTextViewHelper implements Runnable, ExoPlayer.EventListe
return text;
}
private String getPlayerSourceIndexString() {
return " source:" + player.getCurrentSourceIndex();
private String getPlayerPeriodIndexString() {
return " period:" + player.getCurrentPeriodIndex();
}
private String getBandwidthString() {
......@@ -169,7 +169,7 @@ public final class DebugTextViewHelper implements Runnable, ExoPlayer.EventListe
}
@Override
public void onPositionDiscontinuity(int sourceIndex, long positionMs) {
public void onPositionDiscontinuity(int periodIndex, long positionMs) {
updateTextView();
}
......
......@@ -22,13 +22,13 @@ import com.google.android.exoplayer2.ExoPlaybackException;
import com.google.android.exoplayer2.ExoPlayer;
import com.google.android.exoplayer2.MediaCodecUtil;
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.TrackGroupArray;
import com.google.android.exoplayer2.TrackRenderer;
import com.google.android.exoplayer2.TrackSelection;
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.CodecCountersUtil;
import com.google.android.exoplayer2.playbacktests.util.ExoHostedTest;
......@@ -418,9 +418,9 @@ public final class DashTest extends ActivityInstrumentationTestCase2<HostActivit
}
@Override
public SampleSourceProvider buildSource(HostActivity host, DataSourceFactory dataSourceFactory,
public MediaSource buildSource(HostActivity host, DataSourceFactory dataSourceFactory,
BandwidthMeter bandwidthMeter) {
return new DashSampleSource(manifestUri, dataSourceFactory, bandwidthMeter,
return new DashMediaSource(manifestUri, dataSourceFactory, bandwidthMeter,
MIN_LOADABLE_RETRY_COUNT, null, null);
}
......
......@@ -22,7 +22,7 @@ import com.google.android.exoplayer2.ExoPlaybackException;
import com.google.android.exoplayer2.ExoPlayer;
import com.google.android.exoplayer2.ExoPlayerFactory;
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.TrackSelectionPolicy;
import com.google.android.exoplayer2.audio.AudioTrack;
......@@ -128,7 +128,7 @@ public abstract class ExoHostedTest implements HostedTest, ExoPlayer.EventListen
player = buildExoPlayer(host, surface, trackSelector);
DataSourceFactory dataSourceFactory = new DefaultDataSourceFactory(host, Util
.getUserAgent(host, "ExoPlayerPlaybackTests"));
player.setSourceProvider(buildSource(host, dataSourceFactory, player.getBandwidthMeter()));
player.setMediaSource(buildSource(host, dataSourceFactory, player.getBandwidthMeter()));
player.addListener(this);
player.setDebugListener(this);
player.setPlayWhenReady(true);
......@@ -210,7 +210,7 @@ public abstract class ExoHostedTest implements HostedTest, ExoPlayer.EventListen
}
@Override
public final void onPositionDiscontinuity(int sourceIndex, long positionMs) {
public final void onPositionDiscontinuity(int periodIndex, long positionMs) {
// Do nothing.
}
......@@ -287,8 +287,8 @@ public abstract class ExoHostedTest implements HostedTest, ExoPlayer.EventListen
}
@SuppressWarnings("unused")
protected abstract SampleSourceProvider buildSource(HostActivity host,
DataSourceFactory dataSourceFactory, BandwidthMeter bandwidthMeter);
protected abstract MediaSource buildSource(HostActivity host, DataSourceFactory dataSourceFactory,
BandwidthMeter bandwidthMeter);
@SuppressWarnings("unused")
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