Allow custom Executor to be supplied to ChunkSampleStream
This commit is contained in:
parent
4df7216bc0
commit
f7a1b19001
@ -49,6 +49,8 @@ import java.io.IOException;
|
|||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.concurrent.Executor;
|
||||||
|
import java.util.concurrent.Executors;
|
||||||
import org.checkerframework.checker.nullness.qual.MonotonicNonNull;
|
import org.checkerframework.checker.nullness.qual.MonotonicNonNull;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -119,6 +121,7 @@ public class ChunkSampleStream<T extends ChunkSource>
|
|||||||
* events.
|
* events.
|
||||||
* @param canReportInitialDiscontinuity Whether the stream can report an initial discontinuity if
|
* @param canReportInitialDiscontinuity Whether the stream can report an initial discontinuity if
|
||||||
* the first chunk can't start at the beginning and needs to preroll data.
|
* the first chunk can't start at the beginning and needs to preroll data.
|
||||||
|
|
||||||
*/
|
*/
|
||||||
public ChunkSampleStream(
|
public ChunkSampleStream(
|
||||||
@C.TrackType int primaryTrackType,
|
@C.TrackType int primaryTrackType,
|
||||||
@ -133,6 +136,46 @@ public class ChunkSampleStream<T extends ChunkSource>
|
|||||||
LoadErrorHandlingPolicy loadErrorHandlingPolicy,
|
LoadErrorHandlingPolicy loadErrorHandlingPolicy,
|
||||||
MediaSourceEventListener.EventDispatcher mediaSourceEventDispatcher,
|
MediaSourceEventListener.EventDispatcher mediaSourceEventDispatcher,
|
||||||
boolean canReportInitialDiscontinuity) {
|
boolean canReportInitialDiscontinuity) {
|
||||||
|
this(primaryTrackType, embeddedTrackTypes, embeddedTrackFormats, chunkSource, callback,
|
||||||
|
allocator, positionUs, drmSessionManager, drmEventDispatcher, loadErrorHandlingPolicy,
|
||||||
|
mediaSourceEventDispatcher, canReportInitialDiscontinuity, null);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Constructs an instance.
|
||||||
|
*
|
||||||
|
* @param primaryTrackType The {@link C.TrackType type} of the primary track.
|
||||||
|
* @param embeddedTrackTypes The types of any embedded tracks, or null.
|
||||||
|
* @param embeddedTrackFormats The formats of the embedded tracks, or null.
|
||||||
|
* @param chunkSource A {@link ChunkSource} from which chunks to load are obtained.
|
||||||
|
* @param callback An {@link Callback} for the stream.
|
||||||
|
* @param allocator An {@link Allocator} from which allocations can be obtained.
|
||||||
|
* @param positionUs The position from which to start loading media.
|
||||||
|
* @param drmSessionManager The {@link DrmSessionManager} to obtain {@link DrmSession DrmSessions}
|
||||||
|
* from.
|
||||||
|
* @param drmEventDispatcher A dispatcher to notify of {@link DrmSessionEventListener} events.
|
||||||
|
* @param loadErrorHandlingPolicy The {@link LoadErrorHandlingPolicy}.
|
||||||
|
* @param mediaSourceEventDispatcher A dispatcher to notify of {@link MediaSourceEventListener}
|
||||||
|
* events.
|
||||||
|
* @param canReportInitialDiscontinuity Whether the stream can report an initial discontinuity if
|
||||||
|
* the first chunk can't start at the beginning and needs to preroll data.
|
||||||
|
* @param downloadExecutor An {@link Executor} for supplying the loader's thread. If null,
|
||||||
|
* a default single thread executor is used.
|
||||||
|
*/
|
||||||
|
public ChunkSampleStream(
|
||||||
|
@C.TrackType int primaryTrackType,
|
||||||
|
@Nullable int[] embeddedTrackTypes,
|
||||||
|
@Nullable Format[] embeddedTrackFormats,
|
||||||
|
T chunkSource,
|
||||||
|
Callback<ChunkSampleStream<T>> callback,
|
||||||
|
Allocator allocator,
|
||||||
|
long positionUs,
|
||||||
|
DrmSessionManager drmSessionManager,
|
||||||
|
DrmSessionEventListener.EventDispatcher drmEventDispatcher,
|
||||||
|
LoadErrorHandlingPolicy loadErrorHandlingPolicy,
|
||||||
|
MediaSourceEventListener.EventDispatcher mediaSourceEventDispatcher,
|
||||||
|
boolean canReportInitialDiscontinuity,
|
||||||
|
@Nullable Executor downloadExecutor) {
|
||||||
this.primaryTrackType = primaryTrackType;
|
this.primaryTrackType = primaryTrackType;
|
||||||
this.embeddedTrackTypes = embeddedTrackTypes == null ? new int[0] : embeddedTrackTypes;
|
this.embeddedTrackTypes = embeddedTrackTypes == null ? new int[0] : embeddedTrackTypes;
|
||||||
this.embeddedTrackFormats = embeddedTrackFormats == null ? new Format[0] : embeddedTrackFormats;
|
this.embeddedTrackFormats = embeddedTrackFormats == null ? new Format[0] : embeddedTrackFormats;
|
||||||
@ -141,7 +184,8 @@ public class ChunkSampleStream<T extends ChunkSource>
|
|||||||
this.mediaSourceEventDispatcher = mediaSourceEventDispatcher;
|
this.mediaSourceEventDispatcher = mediaSourceEventDispatcher;
|
||||||
this.loadErrorHandlingPolicy = loadErrorHandlingPolicy;
|
this.loadErrorHandlingPolicy = loadErrorHandlingPolicy;
|
||||||
this.canReportInitialDiscontinuity = canReportInitialDiscontinuity;
|
this.canReportInitialDiscontinuity = canReportInitialDiscontinuity;
|
||||||
loader = new Loader("ChunkSampleStream");
|
loader = downloadExecutor != null ?
|
||||||
|
new Loader(downloadExecutor) : new Loader("ChunkSampleStream");
|
||||||
nextChunkHolder = new ChunkHolder();
|
nextChunkHolder = new ChunkHolder();
|
||||||
mediaChunks = new ArrayList<>();
|
mediaChunks = new ArrayList<>();
|
||||||
readOnlyMediaChunks = Collections.unmodifiableList(mediaChunks);
|
readOnlyMediaChunks = Collections.unmodifiableList(mediaChunks);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user