diff --git a/library/core/src/main/java/com/google/android/exoplayer2/mediacodec/MediaCodecRenderer.java b/library/core/src/main/java/com/google/android/exoplayer2/mediacodec/MediaCodecRenderer.java
index 820f9f003ea..6c405f7ceda 100644
--- a/library/core/src/main/java/com/google/android/exoplayer2/mediacodec/MediaCodecRenderer.java
+++ b/library/core/src/main/java/com/google/android/exoplayer2/mediacodec/MediaCodecRenderer.java
@@ -59,9 +59,7 @@
*/
public abstract class MediaCodecRenderer extends BaseRenderer {
- /**
- * Thrown when a failure occurs instantiating a decoder.
- */
+ /** Thrown when a failure occurs instantiating a decoder. */
public static class DecoderInitializationException extends Exception {
private static final int CUSTOM_ERROR_CODE_BASE = -50000;
diff --git a/library/core/src/main/java/com/google/android/exoplayer2/text/ssa/SsaDecoder.java b/library/core/src/main/java/com/google/android/exoplayer2/text/ssa/SsaDecoder.java
index 917ac8e36ee..eef9d2eec1e 100644
--- a/library/core/src/main/java/com/google/android/exoplayer2/text/ssa/SsaDecoder.java
+++ b/library/core/src/main/java/com/google/android/exoplayer2/text/ssa/SsaDecoder.java
@@ -300,12 +300,12 @@ private static Cue createCue(
float screenWidth,
float screenHeight) {
@SsaStyle.SsaAlignment int alignment;
- if (styleOverrides.alignment != SsaStyle.SsaAlignment.UNKNOWN) {
+ if (styleOverrides.alignment != SsaStyle.SSA_ALIGNMENT_UNKNOWN) {
alignment = styleOverrides.alignment;
} else if (style != null) {
alignment = style.alignment;
} else {
- alignment = SsaStyle.SsaAlignment.UNKNOWN;
+ alignment = SsaStyle.SSA_ALIGNMENT_UNKNOWN;
}
@Cue.AnchorType int positionAnchor = toPositionAnchor(alignment);
@Cue.AnchorType int lineAnchor = toLineAnchor(alignment);
@@ -337,19 +337,19 @@ private static Cue createCue(
@Nullable
private static Layout.Alignment toTextAlignment(@SsaStyle.SsaAlignment int alignment) {
switch (alignment) {
- case SsaStyle.SsaAlignment.BOTTOM_LEFT:
- case SsaStyle.SsaAlignment.MIDDLE_LEFT:
- case SsaStyle.SsaAlignment.TOP_LEFT:
+ case SsaStyle.SSA_ALIGNMENT_BOTTOM_LEFT:
+ case SsaStyle.SSA_ALIGNMENT_MIDDLE_LEFT:
+ case SsaStyle.SSA_ALIGNMENT_TOP_LEFT:
return Layout.Alignment.ALIGN_NORMAL;
- case SsaStyle.SsaAlignment.BOTTOM_CENTER:
- case SsaStyle.SsaAlignment.MIDDLE_CENTER:
- case SsaStyle.SsaAlignment.TOP_CENTER:
+ case SsaStyle.SSA_ALIGNMENT_BOTTOM_CENTER:
+ case SsaStyle.SSA_ALIGNMENT_MIDDLE_CENTER:
+ case SsaStyle.SSA_ALIGNMENT_TOP_CENTER:
return Layout.Alignment.ALIGN_CENTER;
- case SsaStyle.SsaAlignment.BOTTOM_RIGHT:
- case SsaStyle.SsaAlignment.MIDDLE_RIGHT:
- case SsaStyle.SsaAlignment.TOP_RIGHT:
+ case SsaStyle.SSA_ALIGNMENT_BOTTOM_RIGHT:
+ case SsaStyle.SSA_ALIGNMENT_MIDDLE_RIGHT:
+ case SsaStyle.SSA_ALIGNMENT_TOP_RIGHT:
return Layout.Alignment.ALIGN_OPPOSITE;
- case SsaStyle.SsaAlignment.UNKNOWN:
+ case SsaStyle.SSA_ALIGNMENT_UNKNOWN:
return null;
default:
Log.w(TAG, "Unknown alignment: " + alignment);
@@ -360,19 +360,19 @@ private static Layout.Alignment toTextAlignment(@SsaStyle.SsaAlignment int align
@Cue.AnchorType
private static int toLineAnchor(@SsaStyle.SsaAlignment int alignment) {
switch (alignment) {
- case SsaStyle.SsaAlignment.BOTTOM_LEFT:
- case SsaStyle.SsaAlignment.BOTTOM_CENTER:
- case SsaStyle.SsaAlignment.BOTTOM_RIGHT:
+ case SsaStyle.SSA_ALIGNMENT_BOTTOM_LEFT:
+ case SsaStyle.SSA_ALIGNMENT_BOTTOM_CENTER:
+ case SsaStyle.SSA_ALIGNMENT_BOTTOM_RIGHT:
return Cue.ANCHOR_TYPE_END;
- case SsaStyle.SsaAlignment.MIDDLE_LEFT:
- case SsaStyle.SsaAlignment.MIDDLE_CENTER:
- case SsaStyle.SsaAlignment.MIDDLE_RIGHT:
+ case SsaStyle.SSA_ALIGNMENT_MIDDLE_LEFT:
+ case SsaStyle.SSA_ALIGNMENT_MIDDLE_CENTER:
+ case SsaStyle.SSA_ALIGNMENT_MIDDLE_RIGHT:
return Cue.ANCHOR_TYPE_MIDDLE;
- case SsaStyle.SsaAlignment.TOP_LEFT:
- case SsaStyle.SsaAlignment.TOP_CENTER:
- case SsaStyle.SsaAlignment.TOP_RIGHT:
+ case SsaStyle.SSA_ALIGNMENT_TOP_LEFT:
+ case SsaStyle.SSA_ALIGNMENT_TOP_CENTER:
+ case SsaStyle.SSA_ALIGNMENT_TOP_RIGHT:
return Cue.ANCHOR_TYPE_START;
- case SsaStyle.SsaAlignment.UNKNOWN:
+ case SsaStyle.SSA_ALIGNMENT_UNKNOWN:
return Cue.TYPE_UNSET;
default:
Log.w(TAG, "Unknown alignment: " + alignment);
@@ -383,19 +383,19 @@ private static int toLineAnchor(@SsaStyle.SsaAlignment int alignment) {
@Cue.AnchorType
private static int toPositionAnchor(@SsaStyle.SsaAlignment int alignment) {
switch (alignment) {
- case SsaStyle.SsaAlignment.BOTTOM_LEFT:
- case SsaStyle.SsaAlignment.MIDDLE_LEFT:
- case SsaStyle.SsaAlignment.TOP_LEFT:
+ case SsaStyle.SSA_ALIGNMENT_BOTTOM_LEFT:
+ case SsaStyle.SSA_ALIGNMENT_MIDDLE_LEFT:
+ case SsaStyle.SSA_ALIGNMENT_TOP_LEFT:
return Cue.ANCHOR_TYPE_START;
- case SsaStyle.SsaAlignment.BOTTOM_CENTER:
- case SsaStyle.SsaAlignment.MIDDLE_CENTER:
- case SsaStyle.SsaAlignment.TOP_CENTER:
+ case SsaStyle.SSA_ALIGNMENT_BOTTOM_CENTER:
+ case SsaStyle.SSA_ALIGNMENT_MIDDLE_CENTER:
+ case SsaStyle.SSA_ALIGNMENT_TOP_CENTER:
return Cue.ANCHOR_TYPE_MIDDLE;
- case SsaStyle.SsaAlignment.BOTTOM_RIGHT:
- case SsaStyle.SsaAlignment.MIDDLE_RIGHT:
- case SsaStyle.SsaAlignment.TOP_RIGHT:
+ case SsaStyle.SSA_ALIGNMENT_BOTTOM_RIGHT:
+ case SsaStyle.SSA_ALIGNMENT_MIDDLE_RIGHT:
+ case SsaStyle.SSA_ALIGNMENT_TOP_RIGHT:
return Cue.ANCHOR_TYPE_END;
- case SsaStyle.SsaAlignment.UNKNOWN:
+ case SsaStyle.SSA_ALIGNMENT_UNKNOWN:
return Cue.TYPE_UNSET;
default:
Log.w(TAG, "Unknown alignment: " + alignment);
diff --git a/library/core/src/main/java/com/google/android/exoplayer2/text/ssa/SsaStyle.java b/library/core/src/main/java/com/google/android/exoplayer2/text/ssa/SsaStyle.java
index e8070976e72..fd2cb036b72 100644
--- a/library/core/src/main/java/com/google/android/exoplayer2/text/ssa/SsaStyle.java
+++ b/library/core/src/main/java/com/google/android/exoplayer2/text/ssa/SsaStyle.java
@@ -37,6 +37,52 @@
private static final String TAG = "SsaStyle";
+ /**
+ * The SSA/ASS alignments.
+ *
+ *
Allowed values:
+ *
+ *
+ * - {@link #SSA_ALIGNMENT_UNKNOWN}
+ *
- {@link #SSA_ALIGNMENT_BOTTOM_LEFT}
+ *
- {@link #SSA_ALIGNMENT_BOTTOM_CENTER}
+ *
- {@link #SSA_ALIGNMENT_BOTTOM_RIGHT}
+ *
- {@link #SSA_ALIGNMENT_MIDDLE_LEFT}
+ *
- {@link #SSA_ALIGNMENT_MIDDLE_CENTER}
+ *
- {@link #SSA_ALIGNMENT_MIDDLE_RIGHT}
+ *
- {@link #SSA_ALIGNMENT_TOP_LEFT}
+ *
- {@link #SSA_ALIGNMENT_TOP_CENTER}
+ *
- {@link #SSA_ALIGNMENT_TOP_RIGHT}
+ *
+ */
+ @IntDef({
+ SSA_ALIGNMENT_UNKNOWN,
+ SSA_ALIGNMENT_BOTTOM_LEFT,
+ SSA_ALIGNMENT_BOTTOM_CENTER,
+ SSA_ALIGNMENT_BOTTOM_RIGHT,
+ SSA_ALIGNMENT_MIDDLE_LEFT,
+ SSA_ALIGNMENT_MIDDLE_CENTER,
+ SSA_ALIGNMENT_MIDDLE_RIGHT,
+ SSA_ALIGNMENT_TOP_LEFT,
+ SSA_ALIGNMENT_TOP_CENTER,
+ SSA_ALIGNMENT_TOP_RIGHT,
+ })
+ @Documented
+ @Retention(SOURCE)
+ public @interface SsaAlignment {}
+
+ // The numbering follows the ASS (v4+) spec (i.e. the points on the number pad).
+ public static final int SSA_ALIGNMENT_UNKNOWN = -1;
+ public static final int SSA_ALIGNMENT_BOTTOM_LEFT = 1;
+ public static final int SSA_ALIGNMENT_BOTTOM_CENTER = 2;
+ public static final int SSA_ALIGNMENT_BOTTOM_RIGHT = 3;
+ public static final int SSA_ALIGNMENT_MIDDLE_LEFT = 4;
+ public static final int SSA_ALIGNMENT_MIDDLE_CENTER = 5;
+ public static final int SSA_ALIGNMENT_MIDDLE_RIGHT = 6;
+ public static final int SSA_ALIGNMENT_TOP_LEFT = 7;
+ public static final int SSA_ALIGNMENT_TOP_CENTER = 8;
+ public static final int SSA_ALIGNMENT_TOP_RIGHT = 9;
+
public final String name;
@SsaAlignment public final int alignment;
@@ -77,22 +123,22 @@ private static int parseAlignment(String alignmentStr) {
// Swallow the exception and return UNKNOWN below.
}
Log.w(TAG, "Ignoring unknown alignment: " + alignmentStr);
- return SsaAlignment.UNKNOWN;
+ return SSA_ALIGNMENT_UNKNOWN;
}
private static boolean isValidAlignment(@SsaAlignment int alignment) {
switch (alignment) {
- case SsaAlignment.BOTTOM_CENTER:
- case SsaAlignment.BOTTOM_LEFT:
- case SsaAlignment.BOTTOM_RIGHT:
- case SsaAlignment.MIDDLE_CENTER:
- case SsaAlignment.MIDDLE_LEFT:
- case SsaAlignment.MIDDLE_RIGHT:
- case SsaAlignment.TOP_CENTER:
- case SsaAlignment.TOP_LEFT:
- case SsaAlignment.TOP_RIGHT:
+ case SSA_ALIGNMENT_BOTTOM_CENTER:
+ case SSA_ALIGNMENT_BOTTOM_LEFT:
+ case SSA_ALIGNMENT_BOTTOM_RIGHT:
+ case SSA_ALIGNMENT_MIDDLE_CENTER:
+ case SSA_ALIGNMENT_MIDDLE_LEFT:
+ case SSA_ALIGNMENT_MIDDLE_RIGHT:
+ case SSA_ALIGNMENT_TOP_CENTER:
+ case SSA_ALIGNMENT_TOP_LEFT:
+ case SSA_ALIGNMENT_TOP_RIGHT:
return true;
- case SsaAlignment.UNKNOWN:
+ case SSA_ALIGNMENT_UNKNOWN:
default:
return false;
}
@@ -177,7 +223,7 @@ private Overrides(@SsaAlignment int alignment, @Nullable PointF position) {
}
public static Overrides parseFromDialogue(String text) {
- @SsaAlignment int alignment = SsaAlignment.UNKNOWN;
+ @SsaAlignment int alignment = SSA_ALIGNMENT_UNKNOWN;
PointF position = null;
Matcher matcher = BRACES_PATTERN.matcher(text);
while (matcher.find()) {
@@ -192,7 +238,7 @@ public static Overrides parseFromDialogue(String text) {
}
try {
@SsaAlignment int parsedAlignment = parseAlignmentOverride(braceContents);
- if (parsedAlignment != SsaAlignment.UNKNOWN) {
+ if (parsedAlignment != SSA_ALIGNMENT_UNKNOWN) {
alignment = parsedAlignment;
}
} catch (RuntimeException e) {
@@ -249,36 +295,7 @@ private static PointF parsePosition(String styleOverride) {
@SsaAlignment
private static int parseAlignmentOverride(String braceContents) {
Matcher matcher = ALIGNMENT_OVERRIDE_PATTERN.matcher(braceContents);
- return matcher.find() ? parseAlignment(matcher.group(1)) : SsaAlignment.UNKNOWN;
+ return matcher.find() ? parseAlignment(matcher.group(1)) : SSA_ALIGNMENT_UNKNOWN;
}
}
-
- /** The SSA/ASS alignments. */
- @IntDef({
- SsaAlignment.UNKNOWN,
- SsaAlignment.BOTTOM_LEFT,
- SsaAlignment.BOTTOM_CENTER,
- SsaAlignment.BOTTOM_RIGHT,
- SsaAlignment.MIDDLE_LEFT,
- SsaAlignment.MIDDLE_CENTER,
- SsaAlignment.MIDDLE_RIGHT,
- SsaAlignment.TOP_LEFT,
- SsaAlignment.TOP_CENTER,
- SsaAlignment.TOP_RIGHT,
- })
- @Documented
- @Retention(SOURCE)
- /* package */ @interface SsaAlignment {
- // The numbering follows the ASS (v4+) spec (i.e. the points on the number pad).
- int UNKNOWN = -1;
- int BOTTOM_LEFT = 1;
- int BOTTOM_CENTER = 2;
- int BOTTOM_RIGHT = 3;
- int MIDDLE_LEFT = 4;
- int MIDDLE_CENTER = 5;
- int MIDDLE_RIGHT = 6;
- int TOP_LEFT = 7;
- int TOP_CENTER = 8;
- int TOP_RIGHT = 9;
- }
}
diff --git a/library/core/src/main/java/com/google/android/exoplayer2/text/webvtt/WebvttCue.java b/library/core/src/main/java/com/google/android/exoplayer2/text/webvtt/WebvttCue.java
index bfa067e322e..55e568efa11 100644
--- a/library/core/src/main/java/com/google/android/exoplayer2/text/webvtt/WebvttCue.java
+++ b/library/core/src/main/java/com/google/android/exoplayer2/text/webvtt/WebvttCue.java
@@ -77,39 +77,40 @@ public static class Builder {
@Documented
@Retention(SOURCE)
@IntDef({
- TextAlignment.START,
- TextAlignment.CENTER,
- TextAlignment.END,
- TextAlignment.LEFT,
- TextAlignment.RIGHT
+ TEXT_ALIGNMENT_START,
+ TEXT_ALIGNMENT_CENTER,
+ TEXT_ALIGNMENT_END,
+ TEXT_ALIGNMENT_LEFT,
+ TEXT_ALIGNMENT_RIGHT
})
- public @interface TextAlignment {
- /**
- * See WebVTT's align:start.
- */
- int START = 1;
- /**
- * See WebVTT's align:center.
- */
- int CENTER = 2;
- /**
- * See WebVTT's align:end.
- */
- int END = 3;
- /**
- * See WebVTT's align:left.
- */
- int LEFT = 4;
- /**
- * See WebVTT's align:right.
- */
- int RIGHT = 5;
- }
+ public @interface TextAlignment {}
+ /**
+ * See WebVTT's align:start.
+ */
+ public static final int TEXT_ALIGNMENT_START = 1;
+
+ /**
+ * See WebVTT's align:center.
+ */
+ public static final int TEXT_ALIGNMENT_CENTER = 2;
+
+ /**
+ * See WebVTT's align:end.
+ */
+ public static final int TEXT_ALIGNMENT_END = 3;
+
+ /**
+ * See WebVTT's align:left.
+ */
+ public static final int TEXT_ALIGNMENT_LEFT = 4;
+
+ /**
+ * See WebVTT's align:right.
+ */
+ public static final int TEXT_ALIGNMENT_RIGHT = 5;
private static final String TAG = "WebvttCueBuilder";
@@ -140,7 +141,7 @@ public void reset() {
endTime = 0;
text = null;
// Default: https://www.w3.org/TR/webvtt1/#webvtt-cue-text-alignment
- textAlignment = TextAlignment.CENTER;
+ textAlignment = TEXT_ALIGNMENT_CENTER;
line = Cue.DIMEN_UNSET;
// Defaults to NUMBER (true): https://www.w3.org/TR/webvtt1/#webvtt-cue-snap-to-lines-flag
lineType = Cue.LINE_TYPE_NUMBER;
@@ -251,13 +252,13 @@ private static float computeLine(float line, @LineType int lineType) {
// https://www.w3.org/TR/webvtt1/#webvtt-cue-position
private static float derivePosition(@TextAlignment int textAlignment) {
switch (textAlignment) {
- case TextAlignment.LEFT:
+ case TEXT_ALIGNMENT_LEFT:
return 0.0f;
- case TextAlignment.RIGHT:
+ case TEXT_ALIGNMENT_RIGHT:
return 1.0f;
- case TextAlignment.START:
- case TextAlignment.CENTER:
- case TextAlignment.END:
+ case TEXT_ALIGNMENT_START:
+ case TEXT_ALIGNMENT_CENTER:
+ case TEXT_ALIGNMENT_END:
default:
return DEFAULT_POSITION;
}
@@ -267,13 +268,13 @@ private static float derivePosition(@TextAlignment int textAlignment) {
@AnchorType
private static int derivePositionAnchor(@TextAlignment int textAlignment) {
switch (textAlignment) {
- case TextAlignment.LEFT:
- case TextAlignment.START:
+ case TEXT_ALIGNMENT_LEFT:
+ case TEXT_ALIGNMENT_START:
return Cue.ANCHOR_TYPE_START;
- case TextAlignment.RIGHT:
- case TextAlignment.END:
+ case TEXT_ALIGNMENT_RIGHT:
+ case TEXT_ALIGNMENT_END:
return Cue.ANCHOR_TYPE_END;
- case TextAlignment.CENTER:
+ case TEXT_ALIGNMENT_CENTER:
default:
return Cue.ANCHOR_TYPE_MIDDLE;
}
@@ -282,13 +283,13 @@ private static int derivePositionAnchor(@TextAlignment int textAlignment) {
@Nullable
private static Alignment convertTextAlignment(@TextAlignment int textAlignment) {
switch (textAlignment) {
- case TextAlignment.START:
- case TextAlignment.LEFT:
+ case TEXT_ALIGNMENT_START:
+ case TEXT_ALIGNMENT_LEFT:
return Alignment.ALIGN_NORMAL;
- case TextAlignment.CENTER:
+ case TEXT_ALIGNMENT_CENTER:
return Alignment.ALIGN_CENTER;
- case TextAlignment.END:
- case TextAlignment.RIGHT:
+ case TEXT_ALIGNMENT_END:
+ case TEXT_ALIGNMENT_RIGHT:
return Alignment.ALIGN_OPPOSITE;
default:
Log.w(TAG, "Unknown textAlignment: " + textAlignment);
diff --git a/library/core/src/main/java/com/google/android/exoplayer2/text/webvtt/WebvttCueParser.java b/library/core/src/main/java/com/google/android/exoplayer2/text/webvtt/WebvttCueParser.java
index 6e5bd31b4b6..b6ddf89dc35 100644
--- a/library/core/src/main/java/com/google/android/exoplayer2/text/webvtt/WebvttCueParser.java
+++ b/library/core/src/main/java/com/google/android/exoplayer2/text/webvtt/WebvttCueParser.java
@@ -308,20 +308,20 @@ private static int parsePositionAnchor(String s) {
private static int parseTextAlignment(String s) {
switch (s) {
case "start":
- return WebvttCue.Builder.TextAlignment.START;
+ return WebvttCue.Builder.TEXT_ALIGNMENT_START;
case "left":
- return WebvttCue.Builder.TextAlignment.LEFT;
+ return WebvttCue.Builder.TEXT_ALIGNMENT_LEFT;
case "center":
case "middle":
- return WebvttCue.Builder.TextAlignment.CENTER;
+ return WebvttCue.Builder.TEXT_ALIGNMENT_CENTER;
case "end":
- return WebvttCue.Builder.TextAlignment.END;
+ return WebvttCue.Builder.TEXT_ALIGNMENT_END;
case "right":
- return WebvttCue.Builder.TextAlignment.RIGHT;
+ return WebvttCue.Builder.TEXT_ALIGNMENT_RIGHT;
default:
Log.w(TAG, "Invalid alignment value: " + s);
// Default value: https://www.w3.org/TR/webvtt1/#webvtt-cue-text-alignment
- return WebvttCue.Builder.TextAlignment.CENTER;
+ return WebvttCue.Builder.TEXT_ALIGNMENT_CENTER;
}
}
diff --git a/library/hls/src/main/java/com/google/android/exoplayer2/source/hls/HlsMediaPeriod.java b/library/hls/src/main/java/com/google/android/exoplayer2/source/hls/HlsMediaPeriod.java
index f74d9b0b0c9..3b723af435b 100644
--- a/library/hls/src/main/java/com/google/android/exoplayer2/source/hls/HlsMediaPeriod.java
+++ b/library/hls/src/main/java/com/google/android/exoplayer2/source/hls/HlsMediaPeriod.java
@@ -75,7 +75,7 @@ public final class HlsMediaPeriod implements MediaPeriod, HlsSampleStreamWrapper
private final TimestampAdjusterProvider timestampAdjusterProvider;
private final CompositeSequenceableLoaderFactory compositeSequenceableLoaderFactory;
private final boolean allowChunklessPreparation;
- private final @HlsMetadataType int metadataType;
+ private final @HlsMediaSource.MetadataType int metadataType;
private final boolean useSessionKeys;
@Nullable private Callback callback;
@@ -118,7 +118,7 @@ public HlsMediaPeriod(
Allocator allocator,
CompositeSequenceableLoaderFactory compositeSequenceableLoaderFactory,
boolean allowChunklessPreparation,
- @HlsMetadataType int metadataType,
+ @HlsMediaSource.MetadataType int metadataType,
boolean useSessionKeys) {
this.extractorFactory = extractorFactory;
this.playlistTracker = playlistTracker;
diff --git a/library/hls/src/main/java/com/google/android/exoplayer2/source/hls/HlsMediaSource.java b/library/hls/src/main/java/com/google/android/exoplayer2/source/hls/HlsMediaSource.java
index 4f6a0405f22..db52fa1c028 100644
--- a/library/hls/src/main/java/com/google/android/exoplayer2/source/hls/HlsMediaSource.java
+++ b/library/hls/src/main/java/com/google/android/exoplayer2/source/hls/HlsMediaSource.java
@@ -15,8 +15,11 @@
*/
package com.google.android.exoplayer2.source.hls;
+import static java.lang.annotation.RetentionPolicy.SOURCE;
+
import android.net.Uri;
import android.os.Handler;
+import androidx.annotation.IntDef;
import androidx.annotation.Nullable;
import com.google.android.exoplayer2.C;
import com.google.android.exoplayer2.ExoPlayerLibraryInfo;
@@ -47,6 +50,8 @@
import com.google.android.exoplayer2.upstream.TransferListener;
import com.google.android.exoplayer2.util.Assertions;
import java.io.IOException;
+import java.lang.annotation.Documented;
+import java.lang.annotation.Retention;
import java.util.List;
/** An HLS {@link MediaSource}. */
@@ -57,6 +62,28 @@ public final class HlsMediaSource extends BaseMediaSource
ExoPlayerLibraryInfo.registerModule("goog.exo.hls");
}
+ /**
+ * The types of metadata that can be extracted from HLS streams.
+ *
+ * Allowed values:
+ *
+ *
+ * - {@link #METADATA_TYPE_ID3}
+ *
- {@link #METADATA_TYPE_EMSG}
+ *
+ *
+ * See {@link Factory#setMetadataType(int)}.
+ */
+ @Documented
+ @Retention(SOURCE)
+ @IntDef({METADATA_TYPE_ID3, METADATA_TYPE_EMSG})
+ public @interface MetadataType {}
+
+ /** Type for ID3 metadata in HLS streams. */
+ public static final int METADATA_TYPE_ID3 = 1;
+ /** Type for ESMG metadata in HLS streams. */
+ public static final int METADATA_TYPE_EMSG = 3;
+
/** Factory for {@link HlsMediaSource}s. */
public static final class Factory implements MediaSourceFactory {
@@ -70,7 +97,7 @@ public static final class Factory implements MediaSourceFactory {
private DrmSessionManager> drmSessionManager;
private LoadErrorHandlingPolicy loadErrorHandlingPolicy;
private boolean allowChunklessPreparation;
- @HlsMetadataType private int metadataType;
+ @MetadataType private int metadataType;
private boolean useSessionKeys;
private boolean isCreateCalled;
@Nullable private Object tag;
@@ -100,7 +127,7 @@ public Factory(HlsDataSourceFactory hlsDataSourceFactory) {
drmSessionManager = DrmSessionManager.getDummyDrmSessionManager();
loadErrorHandlingPolicy = new DefaultLoadErrorHandlingPolicy();
compositeSequenceableLoaderFactory = new DefaultCompositeSequenceableLoaderFactory();
- metadataType = HlsMetadataType.ID3;
+ metadataType = METADATA_TYPE_ID3;
}
/**
@@ -246,24 +273,24 @@ public Factory setAllowChunklessPreparation(boolean allowChunklessPreparation) {
/**
* Sets the type of metadata to extract from the HLS source (defaults to {@link
- * HlsMetadataType#ID3}).
+ * #METADATA_TYPE_ID3}).
*
*
HLS supports in-band ID3 in both TS and fMP4 streams, but in the fMP4 case the data is
* wrapped in an EMSG box [spec].
*
- *
If this is set to {@link HlsMetadataType#ID3} then raw ID3 metadata of will be extracted
+ *
If this is set to {@link #METADATA_TYPE_ID3} then raw ID3 metadata of will be extracted
* from TS sources. From fMP4 streams EMSGs containing metadata of this type (in the variant
* stream only) will be unwrapped to expose the inner data. All other in-band metadata will be
* dropped.
*
- *
If this is set to {@link HlsMetadataType#EMSG} then all EMSG data from the fMP4 variant
+ *
If this is set to {@link #METADATA_TYPE_EMSG} then all EMSG data from the fMP4 variant
* stream will be extracted. No metadata will be extracted from TS streams, since they don't
* support EMSG.
*
* @param metadataType The type of metadata to extract.
* @return This factory, for convenience.
*/
- public Factory setMetadataType(@HlsMetadataType int metadataType) {
+ public Factory setMetadataType(@MetadataType int metadataType) {
Assertions.checkState(!isCreateCalled);
this.metadataType = metadataType;
return this;
@@ -347,7 +374,7 @@ public int[] getSupportedTypes() {
private final DrmSessionManager> drmSessionManager;
private final LoadErrorHandlingPolicy loadErrorHandlingPolicy;
private final boolean allowChunklessPreparation;
- private final @HlsMetadataType int metadataType;
+ private final @MetadataType int metadataType;
private final boolean useSessionKeys;
private final HlsPlaylistTracker playlistTracker;
@Nullable private final Object tag;
@@ -363,7 +390,7 @@ private HlsMediaSource(
LoadErrorHandlingPolicy loadErrorHandlingPolicy,
HlsPlaylistTracker playlistTracker,
boolean allowChunklessPreparation,
- @HlsMetadataType int metadataType,
+ @MetadataType int metadataType,
boolean useSessionKeys,
@Nullable Object tag) {
this.manifestUri = manifestUri;
diff --git a/library/hls/src/main/java/com/google/android/exoplayer2/source/hls/HlsMetadataType.java b/library/hls/src/main/java/com/google/android/exoplayer2/source/hls/HlsMetadataType.java
deleted file mode 100644
index 8fb6c220cfd..00000000000
--- a/library/hls/src/main/java/com/google/android/exoplayer2/source/hls/HlsMetadataType.java
+++ /dev/null
@@ -1,38 +0,0 @@
-/*
- * Copyright (C) 2019 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 com.google.android.exoplayer2.source.hls;
-
-import static java.lang.annotation.RetentionPolicy.SOURCE;
-
-import androidx.annotation.IntDef;
-import java.lang.annotation.Documented;
-import java.lang.annotation.Retention;
-
-/**
- * The types of metadata that can be extracted from HLS streams.
- *
- *
See {@link HlsMediaSource.Factory#setMetadataType(int)}.
- */
-@Documented
-@Retention(SOURCE)
-@IntDef({HlsMetadataType.ID3, HlsMetadataType.EMSG})
-public @interface HlsMetadataType {
- /** Type for ID3 metadata in HLS streams. */
- int ID3 = 1;
- /** Type for ESMG metadata in HLS streams. */
- int EMSG = 3;
-}
diff --git a/library/hls/src/main/java/com/google/android/exoplayer2/source/hls/HlsSampleStreamWrapper.java b/library/hls/src/main/java/com/google/android/exoplayer2/source/hls/HlsSampleStreamWrapper.java
index 18465bcaf74..77242ea0fa1 100644
--- a/library/hls/src/main/java/com/google/android/exoplayer2/source/hls/HlsSampleStreamWrapper.java
+++ b/library/hls/src/main/java/com/google/android/exoplayer2/source/hls/HlsSampleStreamWrapper.java
@@ -116,7 +116,7 @@ public interface Callback extends SequenceableLoader.Callback mediaChunks;
private final List readOnlyMediaChunks;
@@ -190,7 +190,7 @@ public HlsSampleStreamWrapper(
DrmSessionManager> drmSessionManager,
LoadErrorHandlingPolicy loadErrorHandlingPolicy,
EventDispatcher eventDispatcher,
- @HlsMetadataType int metadataType) {
+ @HlsMediaSource.MetadataType int metadataType) {
this.trackType = trackType;
this.callback = callback;
this.chunkSource = chunkSource;
@@ -1362,14 +1362,15 @@ private static class EmsgUnwrappingTrackOutput implements TrackOutput {
private byte[] buffer;
private int bufferPosition;
- public EmsgUnwrappingTrackOutput(TrackOutput delegate, @HlsMetadataType int metadataType) {
+ public EmsgUnwrappingTrackOutput(
+ TrackOutput delegate, @HlsMediaSource.MetadataType int metadataType) {
this.emsgDecoder = new EventMessageDecoder();
this.delegate = delegate;
switch (metadataType) {
- case HlsMetadataType.ID3:
+ case HlsMediaSource.METADATA_TYPE_ID3:
delegateFormat = ID3_FORMAT;
break;
- case HlsMetadataType.EMSG:
+ case HlsMediaSource.METADATA_TYPE_EMSG:
delegateFormat = EMSG_FORMAT;
break;
default:
diff --git a/library/hls/src/test/java/com/google/android/exoplayer2/source/hls/HlsMediaPeriodTest.java b/library/hls/src/test/java/com/google/android/exoplayer2/source/hls/HlsMediaPeriodTest.java
index 73ef11bda9b..820c39c197c 100644
--- a/library/hls/src/test/java/com/google/android/exoplayer2/source/hls/HlsMediaPeriodTest.java
+++ b/library/hls/src/test/java/com/google/android/exoplayer2/source/hls/HlsMediaPeriodTest.java
@@ -92,7 +92,7 @@ public void getSteamKeys_isCompatibleWithHlsMasterPlaylistFilter() {
mock(Allocator.class),
mock(CompositeSequenceableLoaderFactory.class),
/* allowChunklessPreparation =*/ true,
- HlsMetadataType.ID3,
+ HlsMediaSource.METADATA_TYPE_ID3,
/* useSessionKeys= */ false);
};