One Logo Pool Ball
CoreMedia · IOS API REFERENCE

CMFormatDescription

class · iOS 4.0+ · SDK 27.1

class CMFormatDescription

Members (33)

init · iOS 4.0+

init

TypeScript
static init(object: CMFormatDescription): CMFormatDescription
Swift declaration
init(referencing object: CMFormatDescription)
get · iOS 13.0+

audioStreamBasicDescription

TypeScript
get audioStreamBasicDescription(): (_CoreAudioTypes_AudioStreamBasicDescription) | null
Swift declaration
var audioStreamBasicDescription: AudioStreamBasicDescription? { get }

Copy of the `AudioStreamBasicDescription`. See `CoreAudioTypes.h` for the definition of AudioStreamBasicDescription`. This API is specific to audio format descriptions, and will return `nil` if used with a non-audio format description.

get · iOS 13.0+

dimensions

TypeScript
get dimensions(): CMVideoDimensions
Swift declaration
var dimensions: CMVideoDimensions { get }

Dimensions in encoded pixels. This does not take into account pixel aspect ratio or clean aperture tags.

get · iOS 13.0+

extensions

TypeScript
get extensions(): CMFormatDescription_Extensions
Swift declaration
var extensions: CMFormatDescription.Extensions { get }

An immutable dictionary containing all the extensions. Extensions dictionaries are valid property list objects. This means that dictionary keys are all `CFStrings`, and the values are all either `CFNumber`, `CFString`, `CFBoolean`, `CFArray`, `CFDictionary`, `CFDate`, or `CFData`.

get · iOS 13.0+

frameQuanta

TypeScript
get frameQuanta(): number
Swift declaration
var frameQuanta: UInt32 { get }

The frames/sec for timecode (eg. `30`) OR frames/tick for counter mode.

get · iOS 13.0+

identifiers

TypeScript
get identifiers(): Array<string>
Swift declaration
var identifiers: [String] { get }

An array of metadata identifiers.

get · iOS 13.0+

magicCookie

TypeScript
get magicCookie(): (ArrayBuffer) | null
Swift declaration
var magicCookie: Data? { get }

Copy of the magic cookie.

method · iOS 13.0+

defaultStyle

TypeScript
defaultStyle(): { "localFontID": number; "bold": boolean; "italic": boolean; "underline": boolean; "fontSize": number; "colorComponents": Array<number> }
Swift declaration
func defaultStyle() throws -> (localFontID: Int, bold: Bool, italic: Bool, underline: Bool, fontSize: CGFloat, colorComponents: [CGFloat])

Returns the default style. The function throws `CMFormatDescription.Error.valueNotAvailable` for format descriptions that do not carry default style information. - Returns: - localFontID: Font number, local to the format description. - bold: `true` if style includes Bold. - italic: `true` if style includes Italic. - underline: `true` if style includes Underline. - fontSize: font size in points. - colocComponents: Components are in order red, green, blue, alpha.

method · iOS 13.0+

displayFlags

TypeScript
displayFlags(): CMFormatDescription_Extensions_Value_TextDisplayFlags
Swift declaration
func displayFlags() throws -> CMFormatDescription.Extensions.Value.TextDisplayFlags

Returns the display flags. These are the flags that control how the text appears. The function can throw `CMFormatDescription.Error.valueNotAvailable` for formats without display flags.

get · iOS 13.0+

mediaSubType

TypeScript
get mediaSubType(): CMFormatDescription_MediaSubType
Swift declaration
var mediaSubType: CMFormatDescription.MediaSubType { get }

The media subtype of the CMFormatDescription. The media subtype is defined in a media-specific way. For audio streams, the media subtype is the `asbd.mFormatID`. For video streams, the media subtype is the video codec type. For muxed streams, it is the format of the muxed stream. For example, `'aac '` is returned for a description of an AAC audio stream, `'avc1'` is returned for a description of an H.264 video stream, and `'mp2t'` is returned for a description of an MPEG-2 transport (muxed) stream. If a particular type of media stream does not have subtypes, this returns `0`.

method · iOS 13.0+

cleanAperture

TypeScript
cleanAperture(originIsAtTopLeft: boolean): { x: number; y: number; width: number; height: number }
Swift declaration
func cleanAperture(originIsAtTopLeft: Bool) -> CGRect

Returns the clean aperture. The clean aperture is a rectangle that defines the portion of the encoded pixel dimensions that represents image data valid for display. - Parameter originIsAtTopLeft: Pass `true` if the CGRect will be used in an environment where `(0, 0)` is at the top-left corner of an enclosing rectangle and y coordinates increase as you go down. Pass `false` if the `CGRect` will be used in an environment where `(0, 0)` is at the bottom-left corner of an enclosing rectangle and y coordinates increase as you go up.

get · iOS 13.0+

frameDuration

TypeScript
get frameDuration(): CMTime
Swift declaration
var frameDuration: CMTime { get }

The duration of each frame (eg. `100/2997`).

method · iOS 13.0+

justification

TypeScript
justification(): { "horizontal": CMFormatDescription_Extensions_Value_TextJustification; "vertical": CMFormatDescription_Extensions_Value_TextJustification }
Swift declaration
func justification() throws -> (horizontal: CMFormatDescription.Extensions.Value.TextJustification, vertical: CMFormatDescription.Extensions.Value.TextJustification)

Returns horizontal and vertical justification. Values are `TextJustification` constants. The function throws `CMFormatDescription.Error.valueNotAvailable` for format descriptions that do not carry text justification.

get · iOS 13.0+

parameterSets

TypeScript
get parameterSets(): CMFormatDescription_ParameterSetCollection
Swift declaration
var parameterSets: CMFormatDescription.ParameterSetCollection { get }

Parameter sets contained in a H.264 or HEVC format description. Parameter sets are parsed from NAL unit in the decoder configuration record contained in a video format description. These NAL units are typically parameter sets (e.g. VPS, SPS, PPS), but may contain others as specified by ISO/IEC 14496-15 (e.g. user-data SEI). The parameter set NAL units returned will already have any emulation prevention bytes needed.

get · iOS 13.0+

timeCodeFlags

TypeScript
get timeCodeFlags(): CMFormatDescription_TimeCode_Flag
Swift declaration
var timeCodeFlags: CMFormatDescription.TimeCode.Flag { get }

The flags for `.dropFrame`, `._24HourMax`, `.negTimesOK`.

method · iOS 13.0+

defaultTextBox

TypeScript
defaultTextBox(originIsAtTopLeft: boolean, heightOfTextTrack: number): { x: number; y: number; width: number; height: number }
Swift declaration
func defaultTextBox(originIsAtTopLeft: Bool, heightOfTextTrack: CGFloat) throws -> CGRect

Returns the default text box. Within a text track, text is rendered within a text box. There is a default text box set, which can be over-ridden by a sample. The function can throw `CMFormatDescription.Error.valueNotAvailable` for format descriptions that do not carry a default text box. - Parameters: - originIsAtTopLeft: Pass `true` if the `CGRect` will be used in an environment where `(0, 0)` is at the top-left corner of an enclosing rectangle and y coordinates increase as you go down. Pass `false` if the `CGRect` will be used in an environment where `(0, 0)` is at the bottom-left corner of an enclosing rectangle and y coordinates increase as you go up. - heightOfTextTrack: If `originIsAtTopLeft` is `false`, pass the height of the enclosing text track or destination. This value will be used to properly compute the default text box for the given origin. Ignored if `originIsAtTopLeft` is `true`.

method · iOS 13.0+

keyWithLocalID

TypeScript
keyWithLocalID(localKeyID: SDKHandle): (Record<string, unknown>) | null
Swift declaration
func keyWithLocalID(_ localKeyID: OSType) -> [String : CFPropertyList]?

Returns the key associated with the metadata for the given local ID. - Parameter localKeyID: Local ID identifying the key associated with the metadata description.

get · iOS 17.0+

tagCollections

TypeScript
get tagCollections(): (Array<Array<CMTag>>) | null
Swift declaration
var tagCollections: [[CMTag]]? { get }

Returns the tag collections. This property provides the VideoLayerIDs and LeftAndRightViewIDs from hvcC and 3D Reference Displays Info SEI in the formatDescription. The returned values can be used to enable the multi-image decoding with kVTDecompressionPropertyKey_RequestedMVHEVCVideoLayerIDs. It also gives the eye mapping information for the pixel buffers of the decoded CMTaggedBuffers.

get · iOS 13.0+

audioFormatList

TypeScript
get audioFormatList(): Array<_CoreAudioTypes_AudioFormatListItem>
Swift declaration
var audioFormatList: [AudioFormatListItem] { get }

List of `AudioFormatListItem` structs describing the audio formats contained within the format description. This property is analogous to `kAudioFormatProperty_FormatList` (See AudioFormat.h) and follows its conventions. Namely, formats are returned in order from the most to least 'rich', with channel count taking the highest precedence followed by sample rate. This API is specific to audio format descriptions, and will return an empty array if called with a non-audio format description.

method · iOS 13.0+

withMagicCookie

TypeScript
withMagicCookie(body: ((arg0: (ArrayBuffer) | null) => unknown)): unknown
Swift declaration
func withMagicCookie<R>(_ body: (UnsafeRawBufferPointer?) throws -> R) rethrows -> R

Get access to the magic cookie. The magic cookie is a completely opaque piece of data, written and read only by the codec itself. A magic cookie is only present for codecs that require it; this API will return `nil` if one does not exist. This API is specific to audio format descriptions, and will return `nil` if called with a non-audio format description. - Parameter body: A closure with an `UnsafeRawBufferPointer` parameter that points to the magic cookie in the audio format description. - Returns: The return value, if any, of the body closure parameter.

get · iOS 13.0+

audioChannelLayout

TypeScript
get audioChannelLayout(): (_CoreAudio_ManagedAudioChannelLayout) | null
Swift declaration
var audioChannelLayout: ManagedAudioChannelLayout? { get }

The `AudioChannelLayout`. See `CoreAudioTypes.h` for the definition of `AudioChannelLayout`. Audio channel layouts are optional; this API will return `nil` if one does not exist. This API is specific to audio format descriptions, and will return `nil` if called with a non-audio format description.

method · iOS 13.0+

matchesImageBuffer

TypeScript
matchesImageBuffer(imageBuffer: _CoreVideo_CVBuffer): boolean
Swift declaration
func matchesImageBuffer(_ imageBuffer: CVImageBuffer) -> Bool

Checks to see if the format description matches an image buffer. This function uses the keys returned by `extensionKeysCommonWithImageBuffers` to compares the extensions of the format description to the attachments of the given image buffer (if an attachment is absent in either it must be absent in both). It also checks `kCMFormatDescriptionExtension_BytesPerRow` against `CVPixelBufferGetBytesPerRow`, if applicable. - Parameter imageBuffer: Image buffer validate against.

get · iOS 13.0+

nalUnitHeaderLength

TypeScript
get nalUnitHeaderLength(): (number) | null
Swift declaration
var nalUnitHeaderLength: Int? { get }

Size, in bytes, of the `NALUnitLength` field in an AVC or HEVC video sample or parameter set sample.

get · iOS 13.0+

mostCompatibleFormat

TypeScript
get mostCompatibleFormat(): (_CoreAudioTypes_AudioFormatListItem) | null
Swift declaration
var mostCompatibleFormat: AudioFormatListItem? { get }

Most compatible `AudioFormatListItem` inside an audio format description. This property returns a pointer to the last `AudioFormatListItem` in the `kAudioFormatProperty_FormatList` (see `AudioFormat.h`). This API is specific to audio format descriptions, and will return `nil` if called with a non-audio format description.

method · iOS 13.0+

presentationDimensions

TypeScript
presentationDimensions(usePixelAspectRatio?: boolean, useCleanAperture?: boolean): { width: number; height: number }
Swift declaration
func presentationDimensions(usePixelAspectRatio: Bool = true, useCleanAperture: Bool = true) -> CGSize

Returns the dimensions, adjusted to take pixel aspect ratio and/or clean aperture into account. Pixel aspect ratio is used to adjust the width, leaving the height alone. - Parameters: - usePixelAspectRatio: Compute the dimensions maintaining pixel aspect ratio. - useCleanAperture: Compute the dimensions using the clean aperture.

get · iOS 13.0+

richestDecodableFormat

TypeScript
get richestDecodableFormat(): (_CoreAudioTypes_AudioFormatListItem) | null
Swift declaration
var richestDecodableFormat: AudioFormatListItem? { get }

Richest `AudioFormatListItem` inside an audio format description. This property performs validation on the formats represented by the audio in the description. It finds the first `AudioFormatListItem` for which the current system has a valid decoder. This API is specific to audio format descriptions, and will return `nil` if called with a non-audio format description. It may also return `nil` if there is no suitable decoder available on the current system for this audio format.

method · iOS 17.0+

matchesTaggedBufferGroup

TypeScript
matchesTaggedBufferGroup(taggedBuffers: Array<CMTaggedBuffer>): boolean
Swift declaration
func matchesTaggedBufferGroup(_ taggedBuffers: [CMTaggedBuffer]) -> Bool

Checks to see if the format description matches the provided tagged buffers. This function returns true if the format description matches the format description in the specified tagged buffers, false otherwise. - Parameter taggedBuffers: Tagged buffers to validate against.

get · iOS 13.0+

extensionKeysCommonWithImageBuffers

TypeScript
static get extensionKeysCommonWithImageBuffers(): Array<CMFormatDescription_Extensions_Key>
Swift declaration
static var extensionKeysCommonWithImageBuffers: [CMFormatDescription.Extensions.Key] { get }

Keys that are used both as `CMVideoFormatDescription` extensions and CVImageBuffer attachments and attributes. When specifying a format description for a `CMSampleBuffer`, the format description must be consistent with formatting information attached to the `CVImageBuffer`. The width, height, and codec type must match (for `CVPixelBuffers` the codec type is given by `CVPixelBufferGetPixelFormatType(pixelBuffer)`; for other `CVImageBuffers`, the codec type must be `0`). The format description extensions must match the image buffer attachments for all the keys in the list returned by this function (if absent in either they must be absent in both). See `CMVideoFormatDescriptionGetExtensionKeysCommonWithImageBuffers`.

get · iOS 13.0+

typeID

TypeScript
static get typeID(): number
Swift declaration
static var typeID: CFTypeID { get }

The `CFTypeID` corresponding to `CMFormatDescription`.

method · iOS 13.0+

equalTo

TypeScript
equalToExtensionKeysToIgnoreSampleDescriptionExtensionAtomKeysToIgnore(otherFormatDescription: CMFormatDescription, extensionKeysToIgnore?: Array<CMFormatDescription_Extensions_Key>, sampleDescriptionExtensionAtomKeysToIgnore?: Array<string>): boolean
Swift declaration
func equalTo(_ otherFormatDescription: CMFormatDescription, extensionKeysToIgnore: [CMFormatDescription.Extensions.Key] = [], sampleDescriptionExtensionAtomKeysToIgnore: [String] = []) -> Bool

Compares two format descriptions for equality, ignoring differences in specified lists of format description extension keys and sample description extension keys. If any keys are passed, `kCMFormatDescriptionExtension_VerbatimSampleDescription` and `kCMFormatDescriptionExtension_VerbatimISOSampleEntry` will also be automatically ignored for the purpose of comparison. - Parameters: - otherFormatDescription: A format description to compare to. - extensionKeysToIgnore: An array of format description extension keys. - sampleDescriptionExtensionAtomKeysToIgnore: An array of sample description extension atom keys. See `kCMFormatDescriptionExtension_SampleDescriptionExtensionAtoms`.

method · iOS 13.0+

equalTo

TypeScript
equalToEqualityMask(otherFormatDescription: CMFormatDescription, equalityMask?: CMFormatDescription_EqualityMask): [boolean, CMFormatDescription_EqualityMask]
Swift declaration
func equalTo(_ otherFormatDescription: CMAudioFormatDescription, equalityMask: CMFormatDescription.EqualityMask = .all) -> (Bool, equalityMask: CMFormatDescription.EqualityMask)

Evaluates equality for the specified parts of two audio format descriptions. Bits in `equalityMask` specify the caller's interest in the equality of various parts of the descriptions. If there is any sort of error that prevents the comparison from occurring, `false` will be returned, and all bits in `equalityMask` will be cleared. If you pass `.all` in `equalityMask`, and _ for `equalityMask`, this API is equivalent to CFEqual(desc1, desc2). See CMAudioFormatDescriptionEqual - Parameters: - otherFormatDescription: The CMAudioFormatDescription to which the comparison is done. - equalityMask: Mask specifying which parts of the descriptions to compare. - Returns: `true` if all parts in which the caller is interested are equal. `false` if any of the parts in which the caller is interested are not equal. Bits set and returned in `equalityMask` represent the subset of those parts that are equal.

method · iOS 13.0+

fontName

TypeScript
fontName(localFontID: number): string
Swift declaration
func fontName(localFontID: Int) throws -> String

Returns the font name for a local font ID. Some format descriptions carry a mapping from local font IDs to font names. The function returns `CMFormatDescription.Error.valueNotAvailable` for format descriptions that do not carry such a font mapping table. - Parameter localFontID: Font number, local to the format description.

get · iOS 13.0+

mediaType

TypeScript
get mediaType(): CMFormatDescription_MediaType
Swift declaration
var mediaType: CMFormatDescription.MediaType { get }

The media type. For example, returns `.audio` for a description of an audio stream.

Skipped declarations

No declarations were skipped in this snapshot.

All CoreMedia types →