Make SsMediaSource reusable.
GitHub:#3498 ------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=183369041
This commit is contained in:
parent
677fc291cf
commit
e4a91b9e3d
@ -245,6 +245,7 @@ public final class SsMediaSource implements MediaSource,
|
|||||||
*/
|
*/
|
||||||
private static final long MIN_LIVE_DEFAULT_START_POSITION_US = 5000000;
|
private static final long MIN_LIVE_DEFAULT_START_POSITION_US = 5000000;
|
||||||
|
|
||||||
|
private final boolean sideloadedManifest;
|
||||||
private final Uri manifestUri;
|
private final Uri manifestUri;
|
||||||
private final DataSource.Factory manifestDataSourceFactory;
|
private final DataSource.Factory manifestDataSourceFactory;
|
||||||
private final SsChunkSource.Factory chunkSourceFactory;
|
private final SsChunkSource.Factory chunkSourceFactory;
|
||||||
@ -412,6 +413,7 @@ public final class SsMediaSource implements MediaSource,
|
|||||||
this.minLoadableRetryCount = minLoadableRetryCount;
|
this.minLoadableRetryCount = minLoadableRetryCount;
|
||||||
this.livePresentationDelayMs = livePresentationDelayMs;
|
this.livePresentationDelayMs = livePresentationDelayMs;
|
||||||
this.eventDispatcher = new EventDispatcher(eventHandler, eventListener);
|
this.eventDispatcher = new EventDispatcher(eventHandler, eventListener);
|
||||||
|
sideloadedManifest = manifest != null;
|
||||||
mediaPeriods = new ArrayList<>();
|
mediaPeriods = new ArrayList<>();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -419,9 +421,8 @@ public final class SsMediaSource implements MediaSource,
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void prepareSource(ExoPlayer player, boolean isTopLevelSource, Listener listener) {
|
public void prepareSource(ExoPlayer player, boolean isTopLevelSource, Listener listener) {
|
||||||
Assertions.checkState(sourceListener == null, MEDIA_SOURCE_REUSED_ERROR_MESSAGE);
|
|
||||||
sourceListener = listener;
|
sourceListener = listener;
|
||||||
if (manifest != null) {
|
if (sideloadedManifest) {
|
||||||
manifestLoaderErrorThrower = new LoaderErrorThrower.Dummy();
|
manifestLoaderErrorThrower = new LoaderErrorThrower.Dummy();
|
||||||
processManifest();
|
processManifest();
|
||||||
} else {
|
} else {
|
||||||
@ -456,7 +457,8 @@ public final class SsMediaSource implements MediaSource,
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void releaseSource() {
|
public void releaseSource() {
|
||||||
manifest = null;
|
sourceListener = null;
|
||||||
|
manifest = sideloadedManifest ? manifest : null;
|
||||||
manifestDataSource = null;
|
manifestDataSource = null;
|
||||||
manifestLoadStartTimestamp = 0;
|
manifestLoadStartTimestamp = 0;
|
||||||
if (manifestLoader != null) {
|
if (manifestLoader != null) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user