public ChunkSampleSource(ChunkSource chunkSource, LoadControl loadControl, int bufferSizeContribution, Handler eventHandler, EventListener eventListener, int eventSourceId, int minLoadableRetryCount) { this.chunkSource = chunkSource; this.loadControl = loadControl; this.bufferSizeContribution = bufferSizeContribution; this.eventHandler = eventHandler; this.eventListener = eventListener; this.eventSourceId = eventSourceId; this.minLoadableRetryCount = minLoadableRetryCount; currentLoadableHolder = new ChunkOperationHolder(); mediaChunks = new LinkedList<>(); readOnlyMediaChunks = Collections.unmodifiableList(mediaChunks); sampleQueue = new DefaultTrackOutput(loadControl.getAllocator()); state = STATE_IDLE; pendingResetPositionUs = NO_RESET_PENDING; }
/** * @param chunkSource A {@link ChunkSource} from which chunks to load are obtained. * @param loadControl Controls when the source is permitted to load data. * @param bufferSizeContribution The contribution of this source to the media buffer, in bytes. * @param eventHandler A handler to use when delivering events to {@code eventListener}. 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. * @param eventSourceId An identifier that gets passed to {@code eventListener} methods. * @param minLoadableRetryCount The minimum number of times that the source should retry a load * before propagating an error. */ public ChunkSampleSource(ChunkSource chunkSource, LoadControl loadControl, int bufferSizeContribution, Handler eventHandler, EventListener eventListener, int eventSourceId, int minLoadableRetryCount) { this.chunkSource = chunkSource; this.loadControl = loadControl; this.bufferSizeContribution = bufferSizeContribution; this.eventHandler = eventHandler; this.eventListener = eventListener; this.eventSourceId = eventSourceId; this.minLoadableRetryCount = minLoadableRetryCount; currentLoadableHolder = new ChunkOperationHolder(); mediaChunks = new LinkedList<>(); readOnlyMediaChunks = Collections.unmodifiableList(mediaChunks); sampleQueue = new DefaultTrackOutput(loadControl.getAllocator()); state = STATE_IDLE; pendingResetPositionUs = NO_RESET_PENDING; }
@Override public TrackOutput track(int id) { DefaultTrackOutput sampleQueue = new DefaultTrackOutput(allocator); sampleQueues.put(id, sampleQueue); return sampleQueue; }
/** * Returns the output most recently passed to {@link #init(DefaultTrackOutput)}. */ protected final DefaultTrackOutput getOutput() { return output; }
/** * Initializes the chunk for loading, setting the {@link DefaultTrackOutput} that will receive * samples as they are loaded. * * @param output The output that will receive the loaded samples. */ public void init(DefaultTrackOutput output) { this.output = output; this.firstSampleIndex = output.getWriteIndex(); }