Add @ContentType IntDef to Util.getAdaptiveMimeTypeForContentType

Also add a case for RTSP, otherwise lint complains.

PiperOrigin-RevId: 438805903
This commit is contained in:
ibaker 2022-04-01 14:02:35 +01:00 committed by Ian Baker
parent 0370e05395
commit 80ff26b6fa
2 changed files with 9 additions and 8 deletions

View file

@ -718,17 +718,17 @@ public final class C {
@Target({FIELD, METHOD, PARAMETER, LOCAL_VARIABLE, TYPE_USE})
@IntDef({TYPE_DASH, TYPE_SS, TYPE_HLS, TYPE_RTSP, TYPE_OTHER})
public @interface ContentType {}
/** Value returned by {@link Util#inferContentType(String)} for DASH manifests. */
/** Value returned by {@link Util#inferContentType} for DASH manifests. */
public static final int TYPE_DASH = 0;
/** Value returned by {@link Util#inferContentType(String)} for Smooth Streaming manifests. */
/** Value returned by {@link Util#inferContentType} for Smooth Streaming manifests. */
public static final int TYPE_SS = 1;
/** Value returned by {@link Util#inferContentType(String)} for HLS manifests. */
/** Value returned by {@link Util#inferContentType} for HLS manifests. */
public static final int TYPE_HLS = 2;
/** Value returned by {@link Util#inferContentType(String)} for RTSP. */
/** Value returned by {@link Util#inferContentType} for RTSP. */
public static final int TYPE_RTSP = 3;
/**
* Value returned by {@link Util#inferContentType(String)} for files other than DASH, HLS or
* Smooth Streaming manifests, or RTSP URIs.
* Value returned by {@link Util#inferContentType} for files other than DASH, HLS or Smooth
* Streaming manifests, or RTSP URIs.
*/
public static final int TYPE_OTHER = 4;

View file

@ -1902,10 +1902,10 @@ public final class Util {
/**
* Returns the MIME type corresponding to the given adaptive {@link ContentType}, or {@code null}
* if the content type is {@link C#TYPE_OTHER}.
* if the content type is not adaptive.
*/
@Nullable
public static String getAdaptiveMimeTypeForContentType(int contentType) {
public static String getAdaptiveMimeTypeForContentType(@ContentType int contentType) {
switch (contentType) {
case C.TYPE_DASH:
return MimeTypes.APPLICATION_MPD;
@ -1913,6 +1913,7 @@ public final class Util {
return MimeTypes.APPLICATION_M3U8;
case C.TYPE_SS:
return MimeTypes.APPLICATION_SS;
case C.TYPE_RTSP:
case C.TYPE_OTHER:
default:
return null;