Table of Contents

Class ConfigurationParser

Namespace
VAST.Codecs.AAC
Assembly
VAST.Common.dll

Provides parsing functionality for AAC audio configuration data (ADTS headers, AudioSpecificConfig).

public class ConfigurationParser
Inheritance
ConfigurationParser
Inherited Members

Constructors

ConfigurationParser()

Initializes a new instance of the ConfigurationParser class.

public ConfigurationParser()

Fields

AacFrameDurations

AAC frame durations in samples for different configurations.

public static readonly int[] AacFrameDurations

Field Value

int[]

AdtsSyncWord

ADTS frame synchronization word pattern.

public static readonly int[] AdtsSyncWord

Field Value

int[]

Properties

AdtsHeader

Gets the generated ADTS header bytes, or null if not yet generated.

public byte[] AdtsHeader { get; }

Property Value

byte[]

Channels

Gets the number of audio channels parsed from the AAC configuration.

public int Channels { get; }

Property Value

int

SampleRate

Gets the sample rate parsed from the AAC configuration.

public int SampleRate { get; }

Property Value

int

Methods

AdtsFindSync(byte[], int, int)

Finds the position of the next ADTS sync word in a byte array.

public static int AdtsFindSync(byte[] buffer, int offset, int length)

Parameters

buffer byte[]

The buffer to search.

offset int

The offset to start searching from.

length int

The number of bytes to search.

Returns

int

The position of the sync word, or -1 if not found.

AdtsFindSync(VersatileBuffer, int)

Finds the position of the next ADTS sync word in a VersatileBuffer.

public static int AdtsFindSync(VersatileBuffer buffer, int startPosition)

Parameters

buffer VersatileBuffer

The buffer to search.

startPosition int

The position to start searching from.

Returns

int

The position of the sync word, or -1 if not found.

AdtsGenerateHeader(MediaType)

Generates an ADTS header for the specified media type.

public static byte[] AdtsGenerateHeader(MediaType mt)

Parameters

mt MediaType

The media type containing AAC audio parameters.

Returns

byte[]

A 7-byte ADTS header array.

AdtsInsertHeader(VersatileBuffer, ref VersatileBuffer)

Inserts an ADTS header into an AAC packet if not already present.

public void AdtsInsertHeader(VersatileBuffer inputPacket, ref VersatileBuffer outputPacket)

Parameters

inputPacket VersatileBuffer

The input AAC packet without ADTS header.

outputPacket VersatileBuffer

The output packet with the ADTS header inserted, or the original packet if a header was already present.

Exceptions

InvalidOperationException

Thrown when the ADTS header has not been initialized by calling Parse with a MediaType.

AdtsReadMediaType(VersatileBuffer, MediaType)

Reads AAC audio parameters from an ADTS header and populates the media type.

public static void AdtsReadMediaType(VersatileBuffer buffer, MediaType mt)

Parameters

buffer VersatileBuffer

The buffer containing the ADTS header.

mt MediaType

The media type to populate with parsed parameters.

AdtsRemoveHeader(VersatileBuffer, ref VersatileBuffer)

Removes the ADTS header from an AAC packet if present.

public static void AdtsRemoveHeader(VersatileBuffer inputPacket, ref VersatileBuffer outputPacket)

Parameters

inputPacket VersatileBuffer

The input packet potentially containing an ADTS header.

outputPacket VersatileBuffer

The output packet with the ADTS header removed, or the original packet if no header was present.

ConvertCodecPrivateData(MediaType)

Converts codec private data from Media Foundation format (with WAVE_FORMAT_EX header) to standard AudioSpecificConfig format.

public static void ConvertCodecPrivateData(MediaType mt)

Parameters

mt MediaType

The media type containing the codec private data to convert.

GenerateCodecPrivateData(MediaType)

Generates AAC codec private data (AudioSpecificConfig) in a media type.

public static void GenerateCodecPrivateData(MediaType mt)

Parameters

mt MediaType

The media type to generate codec private data in. The CodecPrivateData property will be populated.

Parse(byte[])

Parses AAC AudioSpecificConfig data from a byte array.

public bool Parse(byte[] buffer)

Parameters

buffer byte[]

The buffer containing the AudioSpecificConfig data.

Returns

bool

True if parsing succeeded; otherwise, false.

Parse(byte[], int, int)

Parses AAC AudioSpecificConfig data from a portion of a byte array.

public bool Parse(byte[] buffer, int offset, int length)

Parameters

buffer byte[]

The buffer containing the AudioSpecificConfig data.

offset int

The offset within the buffer to start parsing.

length int

The number of bytes to parse.

Returns

bool

True if parsing succeeded; otherwise, false.

Parse(MediaType)

Parses AAC configuration from a media type and generates the ADTS header.

public bool Parse(MediaType mt)

Parameters

mt MediaType

The media type containing AAC audio parameters.

Returns

bool

True if parsing succeeded; otherwise, false.