Formatting and javadoc
This commit is contained in:
parent
2f6d8bf5ba
commit
15a6906877
@ -173,7 +173,8 @@ import org.checkerframework.checker.nullness.qual.MonotonicNonNull;
|
|||||||
* @param continueLoadingCheckIntervalBytes The number of bytes that should be loaded between each
|
* @param continueLoadingCheckIntervalBytes The number of bytes that should be loaded between each
|
||||||
* invocation of {@link Callback#onContinueLoadingRequested(SequenceableLoader)}.
|
* invocation of {@link Callback#onContinueLoadingRequested(SequenceableLoader)}.
|
||||||
* @param singleSampleDurationUs The duration of media with a single sample in microseconds.
|
* @param singleSampleDurationUs The duration of media with a single sample in microseconds.
|
||||||
* @param downloadExecutor An {@link Executor} for supplying the loader's thread.
|
* @param downloadExecutor An optional externally provided {@link Executor} for loading and
|
||||||
|
* extracting media.
|
||||||
*/
|
*/
|
||||||
// maybeFinishPrepare is not posted to the handler until initialization completes.
|
// maybeFinishPrepare is not posted to the handler until initialization completes.
|
||||||
@SuppressWarnings({"nullness:argument", "nullness:methodref.receiver.bound"})
|
@SuppressWarnings({"nullness:argument", "nullness:methodref.receiver.bound"})
|
||||||
@ -201,8 +202,10 @@ import org.checkerframework.checker.nullness.qual.MonotonicNonNull;
|
|||||||
this.allocator = allocator;
|
this.allocator = allocator;
|
||||||
this.customCacheKey = customCacheKey;
|
this.customCacheKey = customCacheKey;
|
||||||
this.continueLoadingCheckIntervalBytes = continueLoadingCheckIntervalBytes;
|
this.continueLoadingCheckIntervalBytes = continueLoadingCheckIntervalBytes;
|
||||||
loader = downloadExecutor != null ?
|
loader =
|
||||||
new Loader(downloadExecutor) : new Loader("ProgressiveMediaPeriod");
|
downloadExecutor != null
|
||||||
|
? new Loader(downloadExecutor)
|
||||||
|
: new Loader("ProgressiveMediaPeriod");
|
||||||
this.progressiveMediaExtractor = progressiveMediaExtractor;
|
this.progressiveMediaExtractor = progressiveMediaExtractor;
|
||||||
this.singleSampleDurationUs = singleSampleDurationUs;
|
this.singleSampleDurationUs = singleSampleDurationUs;
|
||||||
loadCondition = new ConditionVariable();
|
loadCondition = new ConditionVariable();
|
||||||
|
@ -157,7 +157,6 @@ public final class ProgressiveMediaSource extends BaseMediaSource
|
|||||||
this.drmSessionManagerProvider = drmSessionManagerProvider;
|
this.drmSessionManagerProvider = drmSessionManagerProvider;
|
||||||
this.loadErrorHandlingPolicy = loadErrorHandlingPolicy;
|
this.loadErrorHandlingPolicy = loadErrorHandlingPolicy;
|
||||||
this.continueLoadingCheckIntervalBytes = continueLoadingCheckIntervalBytes;
|
this.continueLoadingCheckIntervalBytes = continueLoadingCheckIntervalBytes;
|
||||||
this.downloadExecutor = () -> null;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@CanIgnoreReturnValue
|
@CanIgnoreReturnValue
|
||||||
@ -202,10 +201,9 @@ public final class ProgressiveMediaSource extends BaseMediaSource
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets a supplier that can return an {@link Executor} that is used for loading the media. This
|
* Sets a supplier for an {@link Executor} that is used for loading the media.
|
||||||
* is useful if the loading thread needs to be externally managed.
|
|
||||||
*
|
*
|
||||||
* @param downloadExecutor a {@link Supplier<Executor>} that provides an externally managed
|
* @param downloadExecutor A {@link Supplier<Executor>} that provides an externally managed
|
||||||
* {@link Executor} for downloading and extraction.
|
* {@link Executor} for downloading and extraction.
|
||||||
* @return This factory, for convenience.
|
* @return This factory, for convenience.
|
||||||
*/
|
*/
|
||||||
|
@ -120,46 +120,8 @@ 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.
|
||||||
|
* @param downloadExecutor An optional externally provided {@link Executor} for loading and
|
||||||
*/
|
* extracting media.
|
||||||
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) {
|
|
||||||
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(
|
public ChunkSampleStream(
|
||||||
@C.TrackType int primaryTrackType,
|
@C.TrackType int primaryTrackType,
|
||||||
@ -183,8 +145,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 = downloadExecutor != null ?
|
loader =
|
||||||
new Loader(downloadExecutor) : new Loader("ChunkSampleStream");
|
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);
|
||||||
|
@ -86,13 +86,12 @@ public final class ProgressiveMediaPeriodTest {
|
|||||||
private static void testExtractorsUpdatesSourceInfoBeforeOnPreparedCallback(
|
private static void testExtractorsUpdatesSourceInfoBeforeOnPreparedCallback(
|
||||||
ProgressiveMediaExtractor extractor, long imageDurationUs) throws TimeoutException {
|
ProgressiveMediaExtractor extractor, long imageDurationUs) throws TimeoutException {
|
||||||
testExtractorsUpdatesSourceInfoBeforeOnPreparedCallback(
|
testExtractorsUpdatesSourceInfoBeforeOnPreparedCallback(
|
||||||
extractor, imageDurationUs, null);
|
extractor, imageDurationUs, /* executor= */ null);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void testExtractorsUpdatesSourceInfoBeforeOnPreparedCallback(
|
private static void testExtractorsUpdatesSourceInfoBeforeOnPreparedCallback(
|
||||||
ProgressiveMediaExtractor extractor,
|
ProgressiveMediaExtractor extractor, long imageDurationUs, @Nullable Executor executor)
|
||||||
long imageDurationUs,
|
throws TimeoutException {
|
||||||
@Nullable Executor executor) throws TimeoutException {
|
|
||||||
AtomicBoolean sourceInfoRefreshCalled = new AtomicBoolean(false);
|
AtomicBoolean sourceInfoRefreshCalled = new AtomicBoolean(false);
|
||||||
ProgressiveMediaPeriod.Listener sourceInfoRefreshListener =
|
ProgressiveMediaPeriod.Listener sourceInfoRefreshListener =
|
||||||
(durationUs, isSeekable, isLive) -> sourceInfoRefreshCalled.set(true);
|
(durationUs, isSeekable, isLive) -> sourceInfoRefreshCalled.set(true);
|
||||||
@ -137,7 +136,7 @@ public final class ProgressiveMediaPeriodTest {
|
|||||||
assertThat(sourceInfoRefreshCalledBeforeOnPrepared.get()).isTrue();
|
assertThat(sourceInfoRefreshCalledBeforeOnPrepared.get()).isTrue();
|
||||||
}
|
}
|
||||||
|
|
||||||
private class ExecutionTrackingThread extends Thread {
|
private static final class ExecutionTrackingThread extends Thread {
|
||||||
private final AtomicBoolean hasRun;
|
private final AtomicBoolean hasRun;
|
||||||
|
|
||||||
public ExecutionTrackingThread(Runnable runnable, AtomicBoolean hasRun) {
|
public ExecutionTrackingThread(Runnable runnable, AtomicBoolean hasRun) {
|
||||||
|
@ -837,7 +837,8 @@ import java.util.regex.Pattern;
|
|||||||
drmEventDispatcher,
|
drmEventDispatcher,
|
||||||
loadErrorHandlingPolicy,
|
loadErrorHandlingPolicy,
|
||||||
mediaSourceEventDispatcher,
|
mediaSourceEventDispatcher,
|
||||||
canReportInitialDiscontinuity);
|
canReportInitialDiscontinuity,
|
||||||
|
/* downloadExecutor= */ null);
|
||||||
synchronized (this) {
|
synchronized (this) {
|
||||||
// The map is also accessed on the loading thread so synchronize access.
|
// The map is also accessed on the loading thread so synchronize access.
|
||||||
trackEmsgHandlerBySampleStream.put(stream, trackPlayerEmsgHandler);
|
trackEmsgHandlerBySampleStream.put(stream, trackPlayerEmsgHandler);
|
||||||
|
@ -265,7 +265,8 @@ import java.util.List;
|
|||||||
drmEventDispatcher,
|
drmEventDispatcher,
|
||||||
loadErrorHandlingPolicy,
|
loadErrorHandlingPolicy,
|
||||||
mediaSourceEventDispatcher,
|
mediaSourceEventDispatcher,
|
||||||
/* canReportInitialDiscontinuity= */ false);
|
/* canReportInitialDiscontinuity= */ false,
|
||||||
|
/* downloadExecutor= */ null);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static TrackGroupArray buildTrackGroups(
|
private static TrackGroupArray buildTrackGroups(
|
||||||
|
@ -188,7 +188,8 @@ public class FakeAdaptiveMediaPeriod
|
|||||||
new DrmSessionEventListener.EventDispatcher(),
|
new DrmSessionEventListener.EventDispatcher(),
|
||||||
new DefaultLoadErrorHandlingPolicy(/* minimumLoadableRetryCount= */ 3),
|
new DefaultLoadErrorHandlingPolicy(/* minimumLoadableRetryCount= */ 3),
|
||||||
mediaSourceEventDispatcher,
|
mediaSourceEventDispatcher,
|
||||||
/* canReportInitialDiscontinuity= */ false);
|
/* canReportInitialDiscontinuity= */ false,
|
||||||
|
/* downloadExecutor= */ null);
|
||||||
streams[i] = sampleStream;
|
streams[i] = sampleStream;
|
||||||
sampleStreams.add(sampleStream);
|
sampleStreams.add(sampleStream);
|
||||||
streamResetFlags[i] = true;
|
streamResetFlags[i] = true;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user