summaryrefslogtreecommitdiffstats
path: root/mobile/android/exoplayer2/src/main/java/org/mozilla/thirdparty/com/google/android/exoplayer2/source/hls/HlsExtractorFactory.java
diff options
context:
space:
mode:
Diffstat (limited to 'mobile/android/exoplayer2/src/main/java/org/mozilla/thirdparty/com/google/android/exoplayer2/source/hls/HlsExtractorFactory.java')
-rw-r--r--mobile/android/exoplayer2/src/main/java/org/mozilla/thirdparty/com/google/android/exoplayer2/source/hls/HlsExtractorFactory.java92
1 files changed, 92 insertions, 0 deletions
diff --git a/mobile/android/exoplayer2/src/main/java/org/mozilla/thirdparty/com/google/android/exoplayer2/source/hls/HlsExtractorFactory.java b/mobile/android/exoplayer2/src/main/java/org/mozilla/thirdparty/com/google/android/exoplayer2/source/hls/HlsExtractorFactory.java
new file mode 100644
index 0000000000..8f445f97ed
--- /dev/null
+++ b/mobile/android/exoplayer2/src/main/java/org/mozilla/thirdparty/com/google/android/exoplayer2/source/hls/HlsExtractorFactory.java
@@ -0,0 +1,92 @@
+/*
+ * Copyright (C) 2017 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.mozilla.thirdparty.com.google.android.exoplayer2.source.hls;
+
+import android.net.Uri;
+import androidx.annotation.Nullable;
+import org.mozilla.thirdparty.com.google.android.exoplayer2.Format;
+import org.mozilla.thirdparty.com.google.android.exoplayer2.extractor.Extractor;
+import org.mozilla.thirdparty.com.google.android.exoplayer2.extractor.ExtractorInput;
+import org.mozilla.thirdparty.com.google.android.exoplayer2.extractor.PositionHolder;
+import org.mozilla.thirdparty.com.google.android.exoplayer2.util.TimestampAdjuster;
+import java.io.IOException;
+import java.util.List;
+import java.util.Map;
+
+/**
+ * Factory for HLS media chunk extractors.
+ */
+public interface HlsExtractorFactory {
+
+ /** Holds an {@link Extractor} and associated parameters. */
+ final class Result {
+
+ /** The created extractor; */
+ public final Extractor extractor;
+ /** Whether the segments for which {@link #extractor} is created are packed audio segments. */
+ public final boolean isPackedAudioExtractor;
+ /**
+ * Whether {@link #extractor} may be reused for following continuous (no immediately preceding
+ * discontinuities) segments of the same variant.
+ */
+ public final boolean isReusable;
+
+ /**
+ * Creates a result.
+ *
+ * @param extractor See {@link #extractor}.
+ * @param isPackedAudioExtractor See {@link #isPackedAudioExtractor}.
+ * @param isReusable See {@link #isReusable}.
+ */
+ public Result(Extractor extractor, boolean isPackedAudioExtractor, boolean isReusable) {
+ this.extractor = extractor;
+ this.isPackedAudioExtractor = isPackedAudioExtractor;
+ this.isReusable = isReusable;
+ }
+ }
+
+ HlsExtractorFactory DEFAULT = new DefaultHlsExtractorFactory();
+
+ /**
+ * Creates an {@link Extractor} for extracting HLS media chunks.
+ *
+ * @param previousExtractor A previously used {@link Extractor} which can be reused if the current
+ * chunk is a continuation of the previously extracted chunk, or null otherwise. It is the
+ * responsibility of implementers to only reuse extractors that are suited for reusage.
+ * @param uri The URI of the media chunk.
+ * @param format A {@link Format} associated with the chunk to extract.
+ * @param muxedCaptionFormats List of muxed caption {@link Format}s. Null if no closed caption
+ * information is available in the master playlist.
+ * @param timestampAdjuster Adjuster corresponding to the provided discontinuity sequence number.
+ * @param responseHeaders The HTTP response headers associated with the media segment or
+ * initialization section to extract.
+ * @param sniffingExtractorInput The first extractor input that will be passed to the returned
+ * extractor's {@link Extractor#read(ExtractorInput, PositionHolder)}. Must only be used to
+ * call {@link Extractor#sniff(ExtractorInput)}.
+ * @return A {@link Result}.
+ * @throws InterruptedException If the thread is interrupted while sniffing.
+ * @throws IOException If an I/O error is encountered while sniffing.
+ */
+ Result createExtractor(
+ @Nullable Extractor previousExtractor,
+ Uri uri,
+ Format format,
+ @Nullable List<Format> muxedCaptionFormats,
+ TimestampAdjuster timestampAdjuster,
+ Map<String, List<String>> responseHeaders,
+ ExtractorInput sniffingExtractorInput)
+ throws InterruptedException, IOException;
+}