CodecSpecificDataUtil
@UnstableApi
class CodecSpecificDataUtil
Provides utilities for handling various types of codec-specific data.
Summary
Nested types |
|---|
|
A tuple of profile and level constants for |
Public functions |
|
|---|---|
java-static String! |
buildApvCodecString(initializationData: ByteArray!)Returns an APV codec string based on the provided initialization data. |
java-static String! |
buildAvcCodecString(Builds an RFC 6381 AVC codec string using the provided parameters. |
java-static (Mutable)List<ByteArray<Byte>!>! |
buildCea708InitializationData(isWideAspectRatio: Boolean)Returns initialization data for formats with MIME type |
java-static String! |
buildDolbyVisionCodecString(profile: Int, level: Int)Builds a Dolby Vision codec string using profile and level. |
java-static ByteArray<Byte>! |
buildDolbyVisionInitializationData(profile: Int, level: Int)Returns initialization data for Dolby Vision according to Dolby Vision ISO MediaFormat (section 2.2) specification. |
java-static String! |
buildH263CodecString(profile: Int, level: Int)Builds an RFC 6381 H263 codec string using profile and level. |
java-static String! |
buildHevcCodecString(Builds an RFC 6381 HEVC codec string using the provided parameters. |
java-static String? |
buildIamfCodecString(initializationData: ByteArray!)Builds an RFC 6381 IAMF codec string from the given |
java-static ByteArray<Byte>! |
buildNalUnit(data: ByteArray!, offset: Int, length: Int)Constructs a NAL unit consisting of the NAL start code followed by the specified data. |
java-static ByteArray<Byte>? |
Builds VP9 CodecPrivate from the uncompressed header of the first frame. |
java-static ImmutableList<ByteArray<Byte>!>! |
buildVp9CodecPrivateInitializationData(Returns initialization data in CodecPrivate format of VP9. |
java-static Int |
calculateMediaCodecDolbyVisionLevel(Calculates the Dolby Vision level based on resolution and frame rate. |
java-static Int |
dolbyVisionConstantToLevelNumber(levelConstant: Int)Returns Dolby Vision level number corresponding to the level constant. |
java-static Int |
dolbyVisionConstantToProfileNumber(profileConstant: Int)Returns Dolby Vision profile number corresponding to the profile constant. |
java-static Pair<Int!, Int!>? |
getCodecProfileAndLevel(format: Format!)Returns profile and level (as defined by |
java-static String? |
getDolbyVisionBaseLayerMimeType(format: Format!)Returns a Dolby Vision base layer codec MIME type of the provided |
java-static CodecSpecificDataUtil.MediaCodecProfileAndLevel? |
getHevcProfileAndLevel(Returns Hevc profile and level corresponding to the codec description string (as defined by RFC 6381) and it |
java-static CodecSpecificDataUtil.MediaCodecProfileAndLevel? |
getMediaCodecProfileAndLevel(format: Format!)Returns the profile and level corresponding to the codec description string (as defined by RFC 6381) of the given format. |
java-static ByteArray<Byte>! |
getOpusInitializationData(format: Format!)Returns initialization data for Opus according to RFC 7845: 5.1. |
java-static Pair<Int!, Int!>! |
getVideoResolutionFromMpeg4VideoConfig(videoSpecificConfig: ByteArray!)Parses an MPEG-4 Visual configuration information, as defined in ISO/IEC14496-2. |
java-static ByteBuffer! |
getVorbisInitializationData(format: Format!)Creates the Vorbis initialization data (CodecPrivate). |
java-static Int |
h263ConstToLevelNumber(levelConst: Int)Maps Android MediaCodec constants to H.263 Level numbers. |
java-static Int |
h263ConstToProfileNumber(profileConst: Int)Maps Android MediaCodec constants to H.263 Profile numbers. |
java-static IntArray<Int>! |
parseAlacAudioSpecificConfig(audioSpecificConfig: ByteArray!)Parses an ALAC AudioSpecificConfig (i.e. an ALACSpecificConfig). |
java-static Boolean |
parseCea708InitializationData(Returns whether the CEA-708 closed caption service with the given initialization data is formatted for displays with 16:9 aspect ratio. |
java-static Array<ByteArray<Byte>!>? |
splitNalUnits(data: ByteArray!)Splits an array of NAL units. |
Public functions
buildApvCodecString
java-static fun buildApvCodecString(initializationData: ByteArray!): String!
Returns an APV codec string based on the provided initialization data.
Reference: Codecs Parameter in APV ISO Base Media File Format
| Parameters | |
|---|---|
initializationData: ByteArray! |
The initialization data containing profile, level, and band information. |
| Returns | |
|---|---|
String! |
The generated APV codec string. |
buildAvcCodecString
java-static fun buildAvcCodecString(
profileIdc: Int,
constraintsFlagsAndReservedZero2Bits: Int,
levelIdc: Int
): String!
Builds an RFC 6381 AVC codec string using the provided parameters.
| Parameters | |
|---|---|
profileIdc: Int |
The encoding profile. |
constraintsFlagsAndReservedZero2Bits: Int |
The constraint flags followed by the reserved zero 2 bits, all contained in the least significant byte of the integer. |
levelIdc: Int |
The encoding level. |
| Returns | |
|---|---|
String! |
An RFC 6381 AVC codec string built using the provided parameters. |
buildCea708InitializationData
java-static fun buildCea708InitializationData(isWideAspectRatio: Boolean): (Mutable)List<ByteArray<Byte>!>!
Returns initialization data for formats with MIME type APPLICATION_CEA708.
| Parameters | |
|---|---|
isWideAspectRatio: Boolean |
Whether the CEA-708 closed caption service is formatted for displays with 16:9 aspect ratio. |
| Returns | |
|---|---|
(Mutable)List<ByteArray<Byte>!>! |
Initialization data for formats with MIME type |
buildDolbyVisionCodecString
java-static fun buildDolbyVisionCodecString(profile: Int, level: Int): String!
Builds a Dolby Vision codec string using profile and level.
Reference: href="https://professionalsupport.dolby.com/s/article/What-is-Dolby-Vision-Profile?language=en_US", >, Dolby Vision Profile and Level (section 2.3)
buildDolbyVisionInitializationData
java-static fun buildDolbyVisionInitializationData(profile: Int, level: Int): ByteArray<Byte>!
Returns initialization data for Dolby Vision according to Dolby Vision ISO MediaFormat (section 2.2) specification.
| Parameters | |
|---|---|
profile: Int |
The Dolby Vision codec profile. This is the integer profile, not the |
level: Int |
The Dolby Vision codec level. This is the integer level, not the |
buildH263CodecString
java-static fun buildH263CodecString(profile: Int, level: Int): String!
Builds an RFC 6381 H263 codec string using profile and level.
buildHevcCodecString
java-static fun buildHevcCodecString(
generalProfileSpace: Int,
generalTierFlag: Boolean,
generalProfileIdc: Int,
generalProfileCompatibilityFlags: Int,
constraintBytes: IntArray!,
generalLevelIdc: Int
): String!
Builds an RFC 6381 HEVC codec string using the provided parameters.
buildIamfCodecString
java-static fun buildIamfCodecString(initializationData: ByteArray!): String?
Builds an RFC 6381 IAMF codec string from the given initializationData.
The format is defined by the IAMF Codec Parameters String specification.
buildNalUnit
java-static fun buildNalUnit(data: ByteArray!, offset: Int, length: Int): ByteArray<Byte>!
Constructs a NAL unit consisting of the NAL start code followed by the specified data.
buildVp9CodecPrivateFromUncompressedHeader
java-static fun buildVp9CodecPrivateFromUncompressedHeader(sample: ByteBuffer!): ByteArray<Byte>?
Builds VP9 CodecPrivate from the uncompressed header of the first frame.
This method parses the uncompressed header of the first frame to extract the VP9 profile, bit depth, and chroma subsampling.
Refer to 6.2 of the VP9 bitstream specification and VP9 in ISO Media File Format for more details.
| Parameters | |
|---|---|
sample: ByteBuffer! |
The first frame's data. |
buildVp9CodecPrivateInitializationData
java-static fun buildVp9CodecPrivateInitializationData(
profile: Byte,
level: Byte,
bitDepth: Byte,
chromaSubsampling: Byte
): ImmutableList<ByteArray<Byte>!>!
Returns initialization data in CodecPrivate format of VP9.
Each feature of VP9 CodecPrivate is defined by the binary format of ID (1 byte), length (1 byte), and data (1 byte). See href="https://www.webmproject.org/docs/container/#vp9-codec-feature-metadata-codecprivate", >, CodecPrivate format of VP9 for more details.
calculateMediaCodecDolbyVisionLevel
java-static fun calculateMediaCodecDolbyVisionLevel(
width: Int,
height: Int,
frameRate: Float
): Int
Calculates the Dolby Vision level based on resolution and frame rate.
Refer to Dolby Vision profiles and levels for more details.
| Parameters | |
|---|---|
width: Int |
The video width in pixels. |
height: Int |
The video height in pixels. |
frameRate: Float |
The video frame rate in frames per second. |
| Returns | |
|---|---|
Int |
The Android MediaCodec constants for the Dolby Vision level, or -1 if it could not be determined. |
dolbyVisionConstantToLevelNumber
java-static fun dolbyVisionConstantToLevelNumber(levelConstant: Int): Int
Returns Dolby Vision level number corresponding to the level constant.
| Parameters | |
|---|---|
levelConstant: Int |
The Dolby Vision level constant. |
| Returns | |
|---|---|
Int |
The Dolby Vision level number. |
| Throws | |
|---|---|
java.lang.IllegalArgumentException |
if the level constant is not recognized. |
dolbyVisionConstantToProfileNumber
java-static fun dolbyVisionConstantToProfileNumber(profileConstant: Int): Int
Returns Dolby Vision profile number corresponding to the profile constant.
| Parameters | |
|---|---|
profileConstant: Int |
The Dolby Vision profile constant. |
| Returns | |
|---|---|
Int |
The Dolby Vision profile number. |
| Throws | |
|---|---|
java.lang.IllegalArgumentException |
if the profile constant is not recognized. |
getCodecProfileAndLevel
java-static fun getCodecProfileAndLevel(format: Format!): Pair<Int!, Int!>?
Returns profile and level (as defined by MediaCodecInfo.CodecProfileLevel) corresponding to the codec description string (as defined by RFC 6381) of the given format.
Consider using getMediaCodecProfileAndLevel instead in order to distinguish between:
- The
formatdoesn't contain profile and level info, or it is malformed. - The
formatcontains profile and level info, but it cannot be represented with constants fromMediaCodecInfo.CodecProfileLevel.
| Parameters | |
|---|---|
format: Format! |
Media format with a codec description string, as defined by RFC 6381. |
getDolbyVisionBaseLayerMimeType
java-static fun getDolbyVisionBaseLayerMimeType(format: Format!): String?
Returns a Dolby Vision base layer codec MIME type of the provided Format.
| Parameters | |
|---|---|
format: Format! |
The media format. |
| Returns | |
|---|---|
String? |
A Dolby Vision base layer MIME type, or |
getHevcProfileAndLevel
java-static fun getHevcProfileAndLevel(
codec: String!,
parts: Array<String!>!,
colorInfo: ColorInfo?
): CodecSpecificDataUtil.MediaCodecProfileAndLevel?
Returns Hevc profile and level corresponding to the codec description string (as defined by RFC 6381) and it ColorInfo.
| Parameters | |
|---|---|
codec: String! |
The codec description string (as defined by RFC 6381). |
parts: Array<String!>! |
The codec string split by ".". |
colorInfo: ColorInfo? |
The |
| Returns | |
|---|---|
CodecSpecificDataUtil.MediaCodecProfileAndLevel? |
A pair (profile constant, level constant) if profile and level are recognized, or |
getMediaCodecProfileAndLevel
java-static fun getMediaCodecProfileAndLevel(format: Format!): CodecSpecificDataUtil.MediaCodecProfileAndLevel?
Returns the profile and level corresponding to the codec description string (as defined by RFC 6381) of the given format.
| Parameters | |
|---|---|
format: Format! |
Media format with a codec description string, as defined by RFC 6381. |
| Returns | |
|---|---|
CodecSpecificDataUtil.MediaCodecProfileAndLevel? |
|
getOpusInitializationData
java-static fun getOpusInitializationData(format: Format!): ByteArray<Byte>!
Returns initialization data for Opus according to RFC 7845: 5.1.
getVideoResolutionFromMpeg4VideoConfig
java-static fun getVideoResolutionFromMpeg4VideoConfig(videoSpecificConfig: ByteArray!): Pair<Int!, Int!>!
Parses an MPEG-4 Visual configuration information, as defined in ISO/IEC14496-2.
| Parameters | |
|---|---|
videoSpecificConfig: ByteArray! |
A byte array containing the MPEG-4 Visual configuration information to parse. |
getVorbisInitializationData
java-static fun getVorbisInitializationData(format: Format!): ByteBuffer!
Creates the Vorbis initialization data (CodecPrivate).
The format is as follows:
- Byte 1: The number of packets minus one. This is 2 for Vorbis, representing the Identification, Comment, and Setup headers.
- Bytes 2..n: The lengths of the first two packets (Identification and Comment headers), encoded using Xiph lacing. The length of the final packet (Setup header) is not explicitly stored.
- Bytes n+1 onwards: The Vorbis identification header, Vorbis comment header and the codec setup header.
| Returns | |
|---|---|
ByteBuffer! |
A |
h263ConstToLevelNumber
java-static fun h263ConstToLevelNumber(levelConst: Int): Int
Maps Android MediaCodec constants to H.263 Level numbers.
| Parameters | |
|---|---|
levelConst: Int |
The MediaCodec H.263 level constant. |
| Returns | |
|---|---|
Int |
The H.263 level number, or -1 if the constant is not recognized. |
h263ConstToProfileNumber
java-static fun h263ConstToProfileNumber(profileConst: Int): Int
Maps Android MediaCodec constants to H.263 Profile numbers.
| Parameters | |
|---|---|
profileConst: Int |
The MediaCodec H.263 profile constant. |
| Returns | |
|---|---|
Int |
The H.263 profile number, or -1 if the constant is not recognized. |
parseAlacAudioSpecificConfig
java-static fun parseAlacAudioSpecificConfig(audioSpecificConfig: ByteArray!): IntArray<Int>!
Parses an ALAC AudioSpecificConfig (i.e. an ALACSpecificConfig).
| Parameters | |
|---|---|
audioSpecificConfig: ByteArray! |
A byte array containing the AudioSpecificConfig to parse. |
parseCea708InitializationData
java-static fun parseCea708InitializationData(
initializationData: (Mutable)List<ByteArray!>!
): Boolean
Returns whether the CEA-708 closed caption service with the given initialization data is formatted for displays with 16:9 aspect ratio.
| Returns | |
|---|---|
Boolean |
Whether the CEA-708 closed caption service is formatted for displays with 16:9 aspect ratio. |
splitNalUnits
java-static fun splitNalUnits(data: ByteArray!): Array<ByteArray<Byte>!>?
Splits an array of NAL units.
If the input consists of NAL start code delimited units, then the returned array consists of the split NAL units, each of which is still prefixed with the NAL start code. For any other input, null is returned.
| Parameters | |
|---|---|
data: ByteArray! |
An array of data. |