# AudioCodec

Added in[API level 12](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  
Deprecated in[API level 31](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  
Summary:[Fields](https://developer.android.com/reference/android/net/rtp/AudioCodec#lfields)\|[Methods](https://developer.android.com/reference/android/net/rtp/AudioCodec#pubmethods)\|[Inherited Methods](https://developer.android.com/reference/android/net/rtp/AudioCodec#inhmethods)  

# AudioCodec

*** ** * ** ***

[Kotlin](https://developer.android.com/reference/kotlin/android/net/rtp/AudioCodec "View this page in Kotlin")\|Java

`
public


class
AudioCodec
`  
`

extends `[Object](https://developer.android.com/reference/java/lang/Object)`


``


`

|---|----------------------------|
| [java.lang.Object](https://developer.android.com/reference/java/lang/Object) ||
| ↳ | android.net.rtp.AudioCodec |

<br />

*** ** * ** ***

<br />

**This class was deprecated in API level 31.**   
[SipManager](https://developer.android.com/reference/android/net/sip/SipManager)and associated classes are no longer supported and should not be used as the basis of future VOIP apps.

This class defines a collection of audio codecs to be used with[AudioStream](https://developer.android.com/reference/android/net/rtp/AudioStream)s. Their parameters are designed to be exchanged using Session Description Protocol (SDP). Most of the values listed here can be found in RFC 3551, while others are described in separated standards.

Few simple configurations are defined as public static instances for the convenience of direct uses. More complicated ones could be obtained using[getCodec(int, java.lang.String, java.lang.String)](https://developer.android.com/reference/android/net/rtp/AudioCodec#getCodec(int,%20java.lang.String,%20java.lang.String)). For example, one can use the following snippet to create a mode-1-only AMR codec.  

```
 AudioCodec codec = AudioCodec.getCodec(100, "AMR/8000", "mode-set=1");
 
```

<br />

**See also:**

- [AudioStream](https://developer.android.com/reference/android/net/rtp/AudioStream)

## Summary

|                                                                                                                                     ### Fields                                                                                                                                      ||
|---------------------------------------------------------------------------------------------------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| ` public static final `[AudioCodec](https://developer.android.com/reference/android/net/rtp/AudioCodec) | [AMR](https://developer.android.com/reference/android/net/rtp/AudioCodec#AMR) Adaptive Multi-Rate narrowband audio codec, also known as AMR or AMR-NB.                     |
| ` public static final `[AudioCodec](https://developer.android.com/reference/android/net/rtp/AudioCodec) | [GSM](https://developer.android.com/reference/android/net/rtp/AudioCodec#GSM) GSM Full-Rate audio codec, also known as GSM-FR, GSM 06.10, GSM, or simply FR.               |
| ` public static final `[AudioCodec](https://developer.android.com/reference/android/net/rtp/AudioCodec) | [GSM_EFR](https://developer.android.com/reference/android/net/rtp/AudioCodec#GSM_EFR) GSM Enhanced Full-Rate audio codec, also known as GSM-EFR, GSM 06.60, or simply EFR. |
| ` public static final `[AudioCodec](https://developer.android.com/reference/android/net/rtp/AudioCodec) | [PCMA](https://developer.android.com/reference/android/net/rtp/AudioCodec#PCMA) G.711 a-law audio codec.                                                                   |
| ` public static final `[AudioCodec](https://developer.android.com/reference/android/net/rtp/AudioCodec) | [PCMU](https://developer.android.com/reference/android/net/rtp/AudioCodec#PCMU) G.711 u-law audio codec.                                                                   |
| ` public final `[String](https://developer.android.com/reference/java/lang/String)                      | [fmtp](https://developer.android.com/reference/android/net/rtp/AudioCodec#fmtp) The format parameters to be used in the corresponding SDP attribute.                       |
| ` public final `[String](https://developer.android.com/reference/java/lang/String)                      | [rtpmap](https://developer.android.com/reference/android/net/rtp/AudioCodec#rtpmap) The encoding parameters to be used in the corresponding SDP attribute.                 |
| ` public final int`                                                                                     | [type](https://developer.android.com/reference/android/net/rtp/AudioCodec#type) The RTP payload type of the encoding.                                                      |

|                                                                                                                                                                                                                           ### Public methods                                                                                                                                                                                                                           ||
|----------------------------------------------------------------------------------------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| ` static `[AudioCodec](https://developer.android.com/reference/android/net/rtp/AudioCodec)   | ` `[getCodec](https://developer.android.com/reference/android/net/rtp/AudioCodec#getCodec(int,%20java.lang.String,%20java.lang.String))`(int type, `[String](https://developer.android.com/reference/java/lang/String)` rtpmap, `[String](https://developer.android.com/reference/java/lang/String)` fmtp) ` Creates an AudioCodec according to the given configuration. |
| ` static `[AudioCodec[]](https://developer.android.com/reference/android/net/rtp/AudioCodec) | ` `[getCodecs](https://developer.android.com/reference/android/net/rtp/AudioCodec#getCodecs())`() ` Returns system supported audio codecs.                                                                                                                                                                                                                               |

| ### Inherited methods |
|-----------------------|---|
| From class` `[java.lang.Object](https://developer.android.com/reference/java/lang/Object)` ` |--------------------------------------------------------------------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| | ` `[Object](https://developer.android.com/reference/java/lang/Object)          | ` `[clone](https://developer.android.com/reference/java/lang/Object#clone())`() ` Creates and returns a copy of this object.                                                                                                                                                      | | ` boolean`                                                                     | ` `[equals](https://developer.android.com/reference/java/lang/Object#equals(java.lang.Object))`(`[Object](https://developer.android.com/reference/java/lang/Object)` obj) ` Indicates whether some other object is "equal to" this one.                                           | | ` void`                                                                        | ` `[finalize](https://developer.android.com/reference/java/lang/Object#finalize())`() ` Called by the garbage collector on an object when garbage collection determines that there are no more references to the object.                                                          | | ` final `[Class](https://developer.android.com/reference/java/lang/Class)`<?>` | ` `[getClass](https://developer.android.com/reference/java/lang/Object#getClass())`() ` Returns the runtime class of this`Object`.                                                                                                                                                | | ` int`                                                                         | ` `[hashCode](https://developer.android.com/reference/java/lang/Object#hashCode())`() ` Returns a hash code value for the object.                                                                                                                                                 | | ` final void`                                                                  | ` `[notify](https://developer.android.com/reference/java/lang/Object#notify())`() ` Wakes up a single thread that is waiting on this object's monitor.                                                                                                                            | | ` final void`                                                                  | ` `[notifyAll](https://developer.android.com/reference/java/lang/Object#notifyAll())`() ` Wakes up all threads that are waiting on this object's monitor.                                                                                                                         | | ` `[String](https://developer.android.com/reference/java/lang/String)          | ` `[toString](https://developer.android.com/reference/java/lang/Object#toString())`() ` Returns a string representation of the object.                                                                                                                                            | | ` final void`                                                                  | ` `[wait](https://developer.android.com/reference/java/lang/Object#wait(long,%20int))`(long timeoutMillis, int nanos) ` Causes the current thread to wait until it is awakened, typically by being*notified* or*interrupted*, or until a certain amount of real time has elapsed. | | ` final void`                                                                  | ` `[wait](https://developer.android.com/reference/java/lang/Object#wait(long))`(long timeoutMillis) ` Causes the current thread to wait until it is awakened, typically by being*notified* or*interrupted*, or until a certain amount of real time has elapsed.                   | | ` final void`                                                                  | ` `[wait](https://developer.android.com/reference/java/lang/Object#wait())`() ` Causes the current thread to wait until it is awakened, typically by being*notified* or*interrupted*.                                                                                             | ||

## Fields

### AMR

Added in[API level 12](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  

```
public static final AudioCodec AMR
```

Adaptive Multi-Rate narrowband audio codec, also known as AMR or AMR-NB. Currently CRC, robust sorting, and interleaving are not supported. See more details about these features in RFC 4867.

<br />

### GSM

Added in[API level 12](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  

```
public static final AudioCodec GSM
```

GSM Full-Rate audio codec, also known as GSM-FR, GSM 06.10, GSM, or simply FR.

<br />

### GSM_EFR

Added in[API level 12](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  

```
public static final AudioCodec GSM_EFR
```

GSM Enhanced Full-Rate audio codec, also known as GSM-EFR, GSM 06.60, or simply EFR.

<br />

### PCMA

Added in[API level 12](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  

```
public static final AudioCodec PCMA
```

G.711 a-law audio codec.

<br />

### PCMU

Added in[API level 12](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  

```
public static final AudioCodec PCMU
```

G.711 u-law audio codec.

<br />

### fmtp

Added in[API level 12](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  

```
public final String fmtp
```

The format parameters to be used in the corresponding SDP attribute.

<br />

### rtpmap

Added in[API level 12](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  

```
public final String rtpmap
```

The encoding parameters to be used in the corresponding SDP attribute.

<br />

### type

Added in[API level 12](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  

```
public final int type
```

The RTP payload type of the encoding.

<br />

## Public methods

### getCodec

Added in[API level 12](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  

```
public static AudioCodec getCodec (int type, 
                String rtpmap, 
                String fmtp)
```

Creates an AudioCodec according to the given configuration.

<br />

|                                                            Parameters                                                            ||
|----------|------------------------------------------------------------------------------------------------------------------------|
| `type`   | `int`: The payload type of the encoding defined in RTP/AVP. <br />                                                     |
| `rtpmap` | `String`: The encoding parameters specified in the corresponding SDP attribute, or null if it is not available. <br /> |
| `fmtp`   | `String`: The format parameters specified in the corresponding SDP attribute, or null if it is not available. <br />   |

|                                                                      Returns                                                                       ||
|----------------------------------------------------------------------------------|------------------------------------------------------------------|
| [AudioCodec](https://developer.android.com/reference/android/net/rtp/AudioCodec) | The configured AudioCodec or`null`if it is not supported. <br /> |

### getCodecs

Added in[API level 12](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  

```
public static AudioCodec[] getCodecs ()
```

Returns system supported audio codecs.

<br />

|                                          Returns                                           ||
|------------------------------------------------------------------------------------|--------|
| [AudioCodec[]](https://developer.android.com/reference/android/net/rtp/AudioCodec) | <br /> |