Class ConfigurationParser
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
SampleRate
Gets the sample rate parsed from the AAC configuration.
public int SampleRate { get; }
Property Value
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
bufferbyte[]The buffer to search.
offsetintThe offset to start searching from.
lengthintThe 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
bufferVersatileBufferThe buffer to search.
startPositionintThe 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
mtMediaTypeThe 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
inputPacketVersatileBufferThe input AAC packet without ADTS header.
outputPacketVersatileBufferThe 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
bufferVersatileBufferThe buffer containing the ADTS header.
mtMediaTypeThe 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
inputPacketVersatileBufferThe input packet potentially containing an ADTS header.
outputPacketVersatileBufferThe 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
mtMediaTypeThe 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
mtMediaTypeThe 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
bufferbyte[]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
bufferbyte[]The buffer containing the AudioSpecificConfig data.
offsetintThe offset within the buffer to start parsing.
lengthintThe 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
mtMediaTypeThe media type containing AAC audio parameters.
Returns
- bool
True if parsing succeeded; otherwise, false.