Package com.castlabs.sdk.base.subtitles.utilities

# Class MimeTypes

java.lang.Object
com.castlabs.sdk.base.subtitles.utilities.MimeTypes

public final class MimeTypes extends Object
Defines common MIME types and helper methods.

- ## Field Summary

  Fields
  Modifier and Type
  Field
  Description
  `static final String`
  `APPLICATION_CAMERA_MOTION`
  `static final String`
  `APPLICATION_CEA608`
  `static final String`
  `APPLICATION_CEA708`
  `static final String`
  `APPLICATION_DVBSUBS`
  `static final String`
  `APPLICATION_DVBTTX`
  `static final String`
  `APPLICATION_EMSG`
  `static final String`
  `APPLICATION_EXIF`
  `static final String`
  `APPLICATION_ICY`
  `static final String`
  `APPLICATION_ID3`
  `static final String`
  `APPLICATION_M3U8`
  `static final String`
  `APPLICATION_MP4`
  `static final String`
  `APPLICATION_MP4CEA608`
  `static final String`
  `APPLICATION_MP4VTT`
  `static final String`
  `APPLICATION_MPD`
  `static final String`
  `APPLICATION_PGS`
  `static final String`
  `APPLICATION_RAWCC`
  `static final String`
  `APPLICATION_SCTE35`
  `static final String`
  `APPLICATION_SS`
  `static final String`
  `APPLICATION_SUBRIP`
  `static final String`
  `APPLICATION_TTML`
  `static final String`
  `APPLICATION_TX3G`
  `static final String`
  `APPLICATION_VOBSUB`
  `static final String`
  `APPLICATION_WEBM`
  `static final String`
  `AUDIO_AAC`
  `static final String`
  `AUDIO_AC3`
  `static final String`
  `AUDIO_AC4`
  `static final String`
  `AUDIO_ALAC`
  `static final String`
  `AUDIO_ALAW`
  `static final String`
  `AUDIO_AMR_NB`
  `static final String`
  `AUDIO_AMR_WB`
  `static final String`
  `AUDIO_DTS`
  `static final String`
  `AUDIO_DTS_EXPRESS`
  `static final String`
  `AUDIO_DTS_HD`
  `static final String`
  `AUDIO_E_AC3`
  `static final String`
  `AUDIO_E_AC3_JOC`
  `static final String`
  `AUDIO_FLAC`
  `static final String`
  `AUDIO_MLAW`
  `static final String`
  `AUDIO_MP4`
  `static final String`
  `AUDIO_MPEG`
  `static final String`
  `AUDIO_MPEG_L1`
  `static final String`
  `AUDIO_MPEG_L2`
  `static final String`
  `AUDIO_MSGSM`
  `static final String`
  `AUDIO_OPUS`
  `static final String`
  `AUDIO_RAW`
  `static final String`
  `AUDIO_TRUEHD`
  `static final String`
  `AUDIO_UNKNOWN`
  `static final String`
  `AUDIO_VORBIS`
  `static final String`
  `AUDIO_WEBM`
  `static final String`
  `BASE_TYPE_APPLICATION`
  `static final String`
  `BASE_TYPE_AUDIO`
  `static final String`
  `BASE_TYPE_IMAGE`
  `static final String`
  `BASE_TYPE_TEXT`
  `static final String`
  `BASE_TYPE_VIDEO`
  `static final String`
  `TEXT_SSA`
  `static final String`
  `TEXT_VTT`
  `static final String`
  `VIDEO_AV1`
  `static final String`
  `VIDEO_DIVX`
  `static final String`
  `VIDEO_DOLBY_VISION`
  `static final String`
  `VIDEO_H263`
  `static final String`
  `VIDEO_H264`
  `static final String`
  `VIDEO_H265`
  `static final String`
  `VIDEO_MP4`
  `static final String`
  `VIDEO_MP4V`
  `static final String`
  `VIDEO_MPEG`
  `static final String`
  `VIDEO_MPEG2`
  `static final String`
  `VIDEO_UNKNOWN`
  `static final String`
  `VIDEO_VC1`
  `static final String`
  `VIDEO_VP8`
  `static final String`
  `VIDEO_VP9`
  `static final String`
  `VIDEO_WEBM`

- ## Method Summary

  Modifier and Type
  Method
  Description
  `static boolean`
  `allSamplesAreSyncSamples(String mimeType)`
  Returns true if it is known that all samples in a stream of the given sample MIME type are guaranteed to be sync samples (i.e., `Constants.BUFFER_FLAG_KEY_FRAME` is guaranteed to be set on every sample).
  `static String`
  `getAudioMediaMimeType(String codecs)`
  Derives a audio sample mimeType from a codecs attribute.
  `static String`
  `getMediaMimeType(String codec)`
  Derives a mimeType from a codec identifier, as defined in RFC 6381.
  `static String`
  `getMimeTypeFromMp4ObjectType(int objectType)`
  Derives a mimeType from MP4 object type identifier, as defined in RFC 6381 and https://mp4ra.org/#/object_types.
  `static int`
  `getTrackType(String mimeType)`
  Returns the `Constants``.TRACK_TYPE_*` constant that corresponds to a specified MIME type.
  `static int`
  `getTrackTypeOfCodec(String codec)`
  Equivalent to `getTrackType(getMediaMimeType(codec))`.
  `static String`
  `getVideoMediaMimeType(String codecs)`
  Derives a video sample mimeType from a codecs attribute.
  `static boolean`
  `isApplication(String mimeType)`
  Returns whether the given string is an application MIME type.
  `static boolean`
  `isAudio(String mimeType)`
  Returns whether the given string is an audio MIME type.
  `static boolean`
  `isImage(String mimeType)`
  Whether the top-level type of `mimeType` is image.
  `static boolean`
  `isText(String mimeType)`
  Returns whether the given string is a text MIME type.
  `static boolean`
  `isVideo(String mimeType)`
  Returns whether the given string is a video MIME type.
  `static void`
  `registerCustomMimeType(String mimeType, String codecPrefix, int trackType)`
  Registers a custom MIME type.

  ### Methods inherited from class java.lang.Object

  `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- ## Field Details

  - ### BASE_TYPE_VIDEO

    public static final String BASE_TYPE_VIDEO
    See Also:
      - Constant Field Values

  - ### BASE_TYPE_AUDIO

    public static final String BASE_TYPE_AUDIO
    See Also:
      - Constant Field Values

  - ### BASE_TYPE_TEXT

    public static final String BASE_TYPE_TEXT
    See Also:
      - Constant Field Values

  - ### BASE_TYPE_APPLICATION

    public static final String BASE_TYPE_APPLICATION
    See Also:
      - Constant Field Values

  - ### BASE_TYPE_IMAGE

    public static final String BASE_TYPE_IMAGE
    See Also:
      - Constant Field Values

  - ### VIDEO_MP4

    public static final String VIDEO_MP4
    See Also:
      - Constant Field Values

  - ### VIDEO_WEBM

    public static final String VIDEO_WEBM
    See Also:
      - Constant Field Values

  - ### VIDEO_H263

    public static final String VIDEO_H263
    See Also:
      - Constant Field Values

  - ### VIDEO_H264

    public static final String VIDEO_H264
    See Also:
      - Constant Field Values

  - ### VIDEO_H265

    public static final String VIDEO_H265
    See Also:
      - Constant Field Values

  - ### VIDEO_VP8

    public static final String VIDEO_VP8
    See Also:
      - Constant Field Values

  - ### VIDEO_VP9

    public static final String VIDEO_VP9
    See Also:
      - Constant Field Values

  - ### VIDEO_AV1

    public static final String VIDEO_AV1
    See Also:
      - Constant Field Values

  - ### VIDEO_MP4V

    public static final String VIDEO_MP4V
    See Also:
      - Constant Field Values

  - ### VIDEO_MPEG

    public static final String VIDEO_MPEG
    See Also:
      - Constant Field Values

  - ### VIDEO_MPEG2

    public static final String VIDEO_MPEG2
    See Also:
      - Constant Field Values

  - ### VIDEO_VC1

    public static final String VIDEO_VC1
    See Also:
      - Constant Field Values

  - ### VIDEO_DIVX

    public static final String VIDEO_DIVX
    See Also:
      - Constant Field Values

  - ### VIDEO_DOLBY_VISION

    public static final String VIDEO_DOLBY_VISION
    See Also:
      - Constant Field Values

  - ### VIDEO_UNKNOWN

    public static final String VIDEO_UNKNOWN
    See Also:
      - Constant Field Values

  - ### AUDIO_MP4

    public static final String AUDIO_MP4
    See Also:
      - Constant Field Values

  - ### AUDIO_AAC

    public static final String AUDIO_AAC
    See Also:
      - Constant Field Values

  - ### AUDIO_WEBM

    public static final String AUDIO_WEBM
    See Also:
      - Constant Field Values

  - ### AUDIO_MPEG

    public static final String AUDIO_MPEG
    See Also:
      - Constant Field Values

  - ### AUDIO_MPEG_L1

    public static final String AUDIO_MPEG_L1
    See Also:
      - Constant Field Values

  - ### AUDIO_MPEG_L2

    public static final String AUDIO_MPEG_L2
    See Also:
      - Constant Field Values

  - ### AUDIO_RAW

    public static final String AUDIO_RAW
    See Also:
      - Constant Field Values

  - ### AUDIO_ALAW

    public static final String AUDIO_ALAW
    See Also:
      - Constant Field Values

  - ### AUDIO_MLAW

    public static final String AUDIO_MLAW
    See Also:
      - Constant Field Values

  - ### AUDIO_AC3

    public static final String AUDIO_AC3
    See Also:
      - Constant Field Values

  - ### AUDIO_E_AC3

    public static final String AUDIO_E_AC3
    See Also:
      - Constant Field Values

  - ### AUDIO_E_AC3_JOC

    public static final String AUDIO_E_AC3_JOC
    See Also:
      - Constant Field Values

  - ### AUDIO_AC4

    public static final String AUDIO_AC4
    See Also:
      - Constant Field Values

  - ### AUDIO_TRUEHD

    public static final String AUDIO_TRUEHD
    See Also:
      - Constant Field Values

  - ### AUDIO_DTS

    public static final String AUDIO_DTS
    See Also:
      - Constant Field Values

  - ### AUDIO_DTS_HD

    public static final String AUDIO_DTS_HD
    See Also:
      - Constant Field Values

  - ### AUDIO_DTS_EXPRESS

    public static final String AUDIO_DTS_EXPRESS
    See Also:
      - Constant Field Values

  - ### AUDIO_VORBIS

    public static final String AUDIO_VORBIS
    See Also:
      - Constant Field Values

  - ### AUDIO_OPUS

    public static final String AUDIO_OPUS
    See Also:
      - Constant Field Values

  - ### AUDIO_AMR_NB

    public static final String AUDIO_AMR_NB
    See Also:
      - Constant Field Values

  - ### AUDIO_AMR_WB

    public static final String AUDIO_AMR_WB
    See Also:
      - Constant Field Values

  - ### AUDIO_FLAC

    public static final String AUDIO_FLAC
    See Also:
      - Constant Field Values

  - ### AUDIO_ALAC

    public static final String AUDIO_ALAC
    See Also:
      - Constant Field Values

  - ### AUDIO_MSGSM

    public static final String AUDIO_MSGSM
    See Also:
      - Constant Field Values

  - ### AUDIO_UNKNOWN

    public static final String AUDIO_UNKNOWN
    See Also:
      - Constant Field Values

  - ### TEXT_VTT

    public static final String TEXT_VTT
    See Also:
      - Constant Field Values

  - ### TEXT_SSA

    public static final String TEXT_SSA
    See Also:
      - Constant Field Values

  - ### APPLICATION_MP4

    public static final String APPLICATION_MP4
    See Also:
      - Constant Field Values

  - ### APPLICATION_WEBM

    public static final String APPLICATION_WEBM
    See Also:
      - Constant Field Values

  - ### APPLICATION_MPD

    public static final String APPLICATION_MPD
    See Also:
      - Constant Field Values

  - ### APPLICATION_M3U8

    public static final String APPLICATION_M3U8
    See Also:
      - Constant Field Values

  - ### APPLICATION_SS

    public static final String APPLICATION_SS
    See Also:
      - Constant Field Values

  - ### APPLICATION_ID3

    public static final String APPLICATION_ID3
    See Also:
      - Constant Field Values

  - ### APPLICATION_CEA608

    public static final String APPLICATION_CEA608
    See Also:
      - Constant Field Values

  - ### APPLICATION_CEA708

    public static final String APPLICATION_CEA708
    See Also:
      - Constant Field Values

  - ### APPLICATION_SUBRIP

    public static final String APPLICATION_SUBRIP
    See Also:
      - Constant Field Values

  - ### APPLICATION_TTML

    public static final String APPLICATION_TTML
    See Also:
      - Constant Field Values

  - ### APPLICATION_TX3G

    public static final String APPLICATION_TX3G
    See Also:
      - Constant Field Values

  - ### APPLICATION_MP4VTT

    public static final String APPLICATION_MP4VTT
    See Also:
      - Constant Field Values

  - ### APPLICATION_MP4CEA608

    public static final String APPLICATION_MP4CEA608
    See Also:
      - Constant Field Values

  - ### APPLICATION_RAWCC

    public static final String APPLICATION_RAWCC
    See Also:
      - Constant Field Values

  - ### APPLICATION_VOBSUB

    public static final String APPLICATION_VOBSUB
    See Also:
      - Constant Field Values

  - ### APPLICATION_PGS

    public static final String APPLICATION_PGS
    See Also:
      - Constant Field Values

  - ### APPLICATION_SCTE35

    public static final String APPLICATION_SCTE35
    See Also:
      - Constant Field Values

  - ### APPLICATION_CAMERA_MOTION

    public static final String APPLICATION_CAMERA_MOTION
    See Also:
      - Constant Field Values

  - ### APPLICATION_EMSG

    public static final String APPLICATION_EMSG
    See Also:
      - Constant Field Values

  - ### APPLICATION_DVBSUBS

    public static final String APPLICATION_DVBSUBS
    See Also:
      - Constant Field Values

  - ### APPLICATION_EXIF

    public static final String APPLICATION_EXIF
    See Also:
      - Constant Field Values

  - ### APPLICATION_ICY

    public static final String APPLICATION_ICY
    See Also:
      - Constant Field Values

  - ### APPLICATION_DVBTTX

    public static final String APPLICATION_DVBTTX
    See Also:
      - Constant Field Values

- ## Method Details

  - ### registerCustomMimeType

    public static void registerCustomMimeType(String mimeType, String codecPrefix, int trackType)
    Registers a custom MIME type. Most applications do not need to call this method, as handling of standard MIME types is built in. These built-in MIME types take precedence over any registered via this method. If this method is used, it must be called before creating any player(s).
    Parameters:
      `mimeType` - The custom MIME type to register.
      `codecPrefix` - The RFC 6381-style codec string prefix associated with the MIME type.
      `trackType` - The `Constants``.TRACK_TYPE_*` constant associated with the MIME type. This value is ignored if the top-level type of `mimeType` is audio, video or text.

  - ### isAudio

    public static boolean isAudio(@Nullable String mimeType)
    Returns whether the given string is an audio MIME type.

  - ### isVideo

    public static boolean isVideo(@Nullable String mimeType)
    Returns whether the given string is a video MIME type.

  - ### isText

    public static boolean isText(@Nullable String mimeType)
    Returns whether the given string is a text MIME type.

  - ### isApplication

    public static boolean isApplication(@Nullable String mimeType)
    Returns whether the given string is an application MIME type.

  - ### allSamplesAreSyncSamples

    public static boolean allSamplesAreSyncSamples(@Nullable String mimeType)
    Returns true if it is known that all samples in a stream of the given sample MIME type are guaranteed to be sync samples (i.e., `Constants.BUFFER_FLAG_KEY_FRAME` is guaranteed to be set on every sample).
    Parameters:
      `mimeType` - The sample MIME type.
    Returns:
      True if it is known that all samples in a stream of the given sample MIME type are guaranteed to be sync samples. False otherwise, including if `null` is passed.

  - ### isImage

    public static boolean isImage(String mimeType)
    Whether the top-level type of `mimeType` is image.
    Parameters:
      `mimeType` - The mimeType to test.
    Returns:
      Whether the top level type is image.

  - ### getVideoMediaMimeType

    @Nullable public static String getVideoMediaMimeType(@Nullable String codecs)
    Derives a video sample mimeType from a codecs attribute.
    Parameters:
      `codecs` - The codecs attribute.
    Returns:
      The derived video mimeType, or null if it could not be derived.

  - ### getAudioMediaMimeType

    @Nullable public static String getAudioMediaMimeType(@Nullable String codecs)
    Derives a audio sample mimeType from a codecs attribute.
    Parameters:
      `codecs` - The codecs attribute.
    Returns:
      The derived audio mimeType, or null if it could not be derived.

  - ### getMediaMimeType

    @Nullable public static String getMediaMimeType(@Nullable String codec)
    Derives a mimeType from a codec identifier, as defined in RFC 6381.
    Parameters:
      `codec` - The codec identifier to derive.
    Returns:
      The mimeType, or null if it could not be derived.

  - ### getMimeTypeFromMp4ObjectType

    @Nullable public static String getMimeTypeFromMp4ObjectType(int objectType)
    Derives a mimeType from MP4 object type identifier, as defined in RFC 6381 and https://mp4ra.org/#/object_types.
    Parameters:
      `objectType` - The objectType identifier to derive.
    Returns:
      The mimeType, or null if it could not be derived.

  - ### getTrackType

    public static int getTrackType(@Nullable String mimeType)
    Returns the `Constants``.TRACK_TYPE_*` constant that corresponds to a specified MIME type. `Constants.TRACK_TYPE_UNKNOWN` if the MIME type is not known or the mapping cannot be established.
    Parameters:
      `mimeType` - The MIME type.
    Returns:
      The `Constants``.TRACK_TYPE_*` constant that corresponds to a specified MIME type.

  - ### getTrackTypeOfCodec

    public static int getTrackTypeOfCodec(String codec)
    Equivalent to `getTrackType(getMediaMimeType(codec))`.
    Parameters:
      `codec` - The codec.
    Returns:
      The `Constants``.TRACK_TYPE_*` constant that corresponds to a specified codec.