CodecSpecificDataUtil


@UnstableApi
class CodecSpecificDataUtil


Provides utilities for handling various types of codec-specific data.

Summary

Public functions

java-static String!
buildAvcCodecString(
    profileIdc: Int,
    constraintsFlagsAndReservedZero2Bits: Int,
    levelIdc: Int
)

Builds an RFC 6381 AVC codec string using the provided parameters.

java-static (Mutable)List<ByteArray<Byte>!>!

Returns initialization data for formats with MIME type APPLICATION_CEA708.

java-static String!
buildDolbyVisionCodecString(profile: Int, level: Int)

Builds a Dolby Vision codec string using profile and level.

java-static ByteArray<Byte>!

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(
    generalProfileSpace: Int,
    generalTierFlag: Boolean,
    generalProfileIdc: Int,
    generalProfileCompatibilityFlags: Int,
    constraintBytes: IntArray!,
    generalLevelIdc: Int
)

Builds an RFC 6381 HEVC codec string using the provided parameters.

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 ImmutableList<ByteArray<Byte>!>!
buildVp9CodecPrivateInitializationData(
    profile: Byte,
    level: Byte,
    bitDepth: Byte,
    chromaSubsampling: Byte
)

Returns initialization data in CodecPrivate format of VP9.

java-static Int

Returns Dolby Vision level number corresponding to the level constant.

java-static Int

Returns Dolby Vision profile number corresponding to the profile constant.

java-static 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.

java-static Pair<Int!, Int!>?
getHevcProfileAndLevel(
    codec: String!,
    parts: Array<String!>!,
    colorInfo: ColorInfo?
)

Returns Hevc profile and level corresponding to the codec description string (as defined by RFC 6381) and it ColorInfo.

java-static Pair<Int!, Int!>!

Parses an MPEG-4 Visual configuration information, as defined in ISO/IEC14496-2.

java-static Pair<Int!, Int!>!
parseAlacAudioSpecificConfig(audioSpecificConfig: ByteArray!)

Parses an ALAC AudioSpecificConfig (i.e. an ALACSpecificConfig).

java-static Boolean
parseCea708InitializationData(
    initializationData: (Mutable)List<ByteArray!>!
)

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>!>?

Splits an array of NAL units.

Public functions

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 APPLICATION_CEA708.

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.

level: Int

The Dolby Vision codec level.

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.

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.

Parameters
data: ByteArray!

An array containing the data that should follow the NAL start code.

offset: Int

The start offset into data.

length: Int

The number of bytes to copy from data

Returns
ByteArray<Byte>!

The constructed NAL unit.

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.

Parameters
profile: Byte

The VP9 codec profile.

level: Byte

The VP9 codec level.

bitDepth: Byte

The bit depth of the luma and color components.

chromaSubsampling: Byte

The chroma subsampling.

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.

Parameters
format: Format!

Media format with a codec description string, as defined by RFC 6381.

Returns
Pair<Int!, Int!>?

A pair (profile constant, level constant) if the codec of the format is well-formed and recognized, or null otherwise.

getHevcProfileAndLevel

java-static fun getHevcProfileAndLevel(
    codec: String!,
    parts: Array<String!>!,
    colorInfo: ColorInfo?
): Pair<Int!, Int!>?

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 ColorInfo.

Returns
Pair<Int!, Int!>?

A pair (profile constant, level constant) if profile and level are recognized, or null otherwise.

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.

Returns
Pair<Int!, Int!>!

A pair of the video's width and height.

parseAlacAudioSpecificConfig

java-static fun parseAlacAudioSpecificConfig(audioSpecificConfig: ByteArray!): Pair<Int!, Int!>!

Parses an ALAC AudioSpecificConfig (i.e. an ALACSpecificConfig).

Parameters
audioSpecificConfig: ByteArray!

A byte array containing the AudioSpecificConfig to parse.

Returns
Pair<Int!, Int!>!

A pair consisting of the sample rate in Hz and the channel count.

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.

Parameters
initializationData: (Mutable)List<ByteArray!>!

The initialization data to parse.

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.

Returns
Array<ByteArray<Byte>!>?

The individual NAL units, or null if the input did not consist of NAL start code delimited units.