private ExtractingLoadable createLoadableFromPositionUs(long positionUs) { return new ExtractingLoadable(uri, dataSource, extractorHolder, allocator, requestedBufferSize, seekMap.getPosition(positionUs)); }
@Override public void maybeThrowError() throws IOException { if (currentLoadableException == null) { return; } if (isCurrentLoadableExceptionFatal()) { throw currentLoadableException; } int minLoadableRetryCountForMedia; if (minLoadableRetryCount != MIN_RETRY_COUNT_DEFAULT_FOR_MEDIA) { minLoadableRetryCountForMedia = minLoadableRetryCount; } else { minLoadableRetryCountForMedia = seekMap != null && !seekMap.isSeekable() ? DEFAULT_MIN_LOADABLE_RETRY_COUNT_LIVE : DEFAULT_MIN_LOADABLE_RETRY_COUNT_ON_DEMAND; } if (currentLoadableExceptionCount > minLoadableRetryCountForMedia) { throw currentLoadableException; } }
@Override public void enable(int track, long positionUs) { Assertions.checkState(prepared); Assertions.checkState(!trackEnabledStates[track]); enabledTrackCount++; trackEnabledStates[track] = true; pendingMediaFormat[track] = true; pendingDiscontinuities[track] = false; if (enabledTrackCount == 1) { // Treat all enables in non-seekable media as being from t=0. positionUs = !seekMap.isSeekable() ? 0 : positionUs; downstreamPositionUs = positionUs; lastSeekPositionUs = positionUs; restartFrom(positionUs); } }
@Override public void seekToUs(long positionUs) { Assertions.checkState(prepared); Assertions.checkState(enabledTrackCount > 0); // Treat all seeks into non-seekable media as being to t=0. positionUs = !seekMap.isSeekable() ? 0 : positionUs; long currentPositionUs = isPendingReset() ? pendingResetPositionUs : downstreamPositionUs; downstreamPositionUs = positionUs; lastSeekPositionUs = positionUs; if (currentPositionUs == positionUs) { return; } // If we're not pending a reset, see if we can seek within the sample queues. boolean seekInsideBuffer = !isPendingReset(); for (int i = 0; seekInsideBuffer && i < sampleQueues.size(); i++) { seekInsideBuffer &= sampleQueues.valueAt(i).skipToKeyframeBefore(positionUs); } // If we failed to seek within the sample queues, we need to restart. if (!seekInsideBuffer) { restartFrom(positionUs); } // Either way, we need to send discontinuities to the downstream components. for (int i = 0; i < pendingDiscontinuities.length; i++) { pendingDiscontinuities[i] = true; } }
} else if (!seekMap.isSeekable() && maxTrackDurationUs == C.UNKNOWN_TIME_US) {