Class AmrWb
Class for encoding and decoding Advanced Multi-Rate Wide Band data.
Inherited Members
Namespace: AmrWbLib
Assembly: SipLib.dll
Syntax
public class AmrWb
Methods
| Edit this page View SourceCreateAsDecoder()
Creates a new AmrWb object that can be used to decode AMR-WB encoded data into voice data.
Declaration
public static AmrWb CreateAsDecoder()
Returns
Type | Description |
---|---|
AmrWb | Returns a new AmrWb object that can be used to decode AMR-WB encoded data into voice data. |
CreateAsEncoder(short, short)
Creates a new AmrWb object that can be used to encode voice data into AMR-WB encoded data.
Declaration
public static AmrWb CreateAsEncoder(short Mode, short AllowDtx)
Parameters
Type | Name | Description |
---|---|---|
short | Mode | Specifies the codec encoding mode. Allowable values are in the range of 0 - 8 which correspond to bit rates: 6.60 kb/s, 8.85 kb/s, 12.65 kb/s, 14.25 kb/s, 15.85 kb/s, 18.25 kb/s, 19.85 kb/s, 23.05 kb/s and 23.85 kb/s. |
short | AllowDtx | Enables or disables Discontinuous Transmit (TX). A value of 0 disables DTX and a value of 1 enables it. If DTX is enabled then the encoder will not produce speech packets during periods of silence. |
Returns
Type | Description |
---|---|
AmrWb | Returns a new AmrWb object that can be used to encode voice packets into AMR-WB binary arrays that can be sent as the payload of RTP packets. |
DecodeCodFile(string)
Reads a *.cod file containing AMR-WB encoded audio data, decodes it and returns a list of audio samples.
A *.cod file is a binary file containing AMR-WB encoded binary parameter data. The file format is the default file format for the decoder test files provided by the 3GPP organization for the AMR-WB codec.
This function is for testing only.
Declaration
public List<short> DecodeCodFile(string InputCodFile)
Parameters
Type | Name | Description |
---|---|---|
string | InputCodFile | Input *.cod file containing AMR-WB encoded audio data. |
Returns
Type | Description |
---|---|
List<short> | Returns a list of audio samples. The format is 16-bit linear PCM. The list will be empty if the input *.cod file does not exist. |
DecodePacketPayload(byte[])
Decodes the AMR-WB encoded bytes from the payload of a RTP packet into an array of linear 16-bit PCM samples with a sample rate of 16k samples/sec. Each RTP packet contains 20 millseconds of audio data.
Declaration
public short[]? DecodePacketPayload(byte[] PacketPayloadBytes)
Parameters
Type | Name | Description |
---|---|---|
byte[] | PacketPayloadBytes | Input payload from a RTP packet. |
Returns
Type | Description |
---|---|
short[] | Returns an array of 16-bit audio samples. Returns null if an error occurred. |
Remarks
This function can only handle a single AMR-WB voice frame in the RTP packet payload bytes. If the application receives RTP packets containing multiple voice frames, then it must split the voice frame up and then send them one at a time to this function.
EncodePacketSamples(short[])
Encodes an array of 16-bit PCM samples into an AMR-WB encoded packet payload that can be sent as the payload of a RTP packet. The input samples sample rate must be 16k samples/second and the sample period must be 20 milliseconds. This means that the input array must be 320 16-bit words in length. The output format is octet aligned with a payload header and a Table of Contents (TOC) byte as specified in Section 4.4.1 of RFC 4867.
Declaration
public byte[]? EncodePacketSamples(short[] Samples)
Parameters
Type | Name | Description |
---|---|---|
short[] | Samples | Input sample array. Must be 320 short values in length. |
Returns
Type | Description |
---|---|
byte[] | Returns a payload that can be attached to an RTP packet. The length of the returned byte array depends upon the encoder mode specified in the call to the InitializeEncoder() function. Returns null if an error occurred. |
EncodeToPacketParams(short[])
Converts an array of audio samples to an array of AMR-WB parameter values. This method is for testing only.
Declaration
public short[]? EncodeToPacketParams(short[] Samples)
Parameters
Type | Name | Description |
---|---|---|
short[] | Samples | Input audio samples. The sample format must be linear 16-bit PCM. The length of the array must be 320 samples. |
Returns
Type | Description |
---|---|
short[] | Returns an array of parameter values. Each parameter value is either 127 or -127. The length of the array depends on the mode value that was passed to the CreateAsEncoder() method used to create this AmrWb object. Returns null if the input array is not 320 samples long. |
GetPacketSize(short)
Gets the packed size of the encoded data given the encoding mode.
Declaration
public int GetPacketSize(short Mode)
Parameters
Type | Name | Description |
---|---|---|
short | Mode | Encoding mode. Must be 0 - 15 inclusive. |
Returns
Type | Description |
---|---|
int | Returns the packed size of the encoded data. The size may be 0. |