This class defines a collection of audio codecs to be used with AudioStreams. 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). For example, one can use the following snippet to create a mode-1-only AMR codec.
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.
Content and code samples on this page are subject to the licenses described in the Content License. Java and OpenJDK are trademarks or registered trademarks of Oracle and/or its affiliates.
Last updated 2025-02-10 UTC.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Missing the information I need","missingTheInformationINeed","thumb-down"],["Too complicated / too many steps","tooComplicatedTooManySteps","thumb-down"],["Out of date","outOfDate","thumb-down"],["Samples / code issue","samplesCodeIssue","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2025-02-10 UTC."],[],[],null,["# AudioCodec\n\nAdded in [API level 12](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels) \nDeprecated in [API level 31](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)\n\nAudioCodec\n==========\n\n*** ** * ** ***\n\nKotlin \\|[Java](/reference/android/net/rtp/AudioCodec \"View this page in Java\") \n\n```\nopen class AudioCodec\n```\n\n|---|---------------------------------|\n| [kotlin.Any](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-any/index.html) ||\n| ↳ | [android.net.rtp.AudioCodec](#) |\n\n*** ** * ** ***\n\n| **This class was deprecated in API level 31.**\n|\n| [android.net.sip.SipManager](../sip/SipManager.html#) and associated classes are no longer supported and should not be used as the basis of future VOIP apps.\n\nThis class defines a collection of audio codecs to be used with [AudioStream](/reference/kotlin/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.\n\nFew 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)](#getCodec(kotlin.Int,%20kotlin.String,%20kotlin.String)). For example, one can use the following snippet to create a mode-1-only AMR codec. \n\n```kotlin\nAudioCodec codec = AudioCodec.getCodec(100, \"AMR/8000\", \"mode-set=1\");\n \n```\n\nSummary\n-------\n\n| Public methods ||\n|-----------------------------------------------------------------------------------------------------------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| open static [AudioCodec](#)! | [getCodec](#getCodec(kotlin.Int,%20kotlin.String,%20kotlin.String))`(`type:` `[Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html)`, `rtpmap:` `[String](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html)!`, `fmtp:` `[String](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html)!`)` Creates an AudioCodec according to the given configuration. |\n| open static [Array](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-array/index.html)\\\u003c[AudioCodec](#)!\\\u003e! | [getCodecs](#getCodecs())`()` Returns system supported audio codecs. |\n\n| Properties ||\n|-----------------------------------------------------------------------------------|-------------------------------------------------------------------------------------------------------------------|\n| static [AudioCodec](#)! | [AMR](#AMR:android.net.rtp.AudioCodec) Adaptive Multi-Rate narrowband audio codec, also known as AMR or AMR-NB. |\n| static [AudioCodec](#)! | [GSM](#GSM:android.net.rtp.AudioCodec) GSM Full-Rate audio codec, also known as GSM-FR, GSM 06. |\n| static [AudioCodec](#)! | [GSM_EFR](#GSM_EFR:android.net.rtp.AudioCodec) GSM Enhanced Full-Rate audio codec, also known as GSM-EFR, GSM 06. |\n| static [AudioCodec](#)! | [PCMA](#PCMA:android.net.rtp.AudioCodec) G. |\n| static [AudioCodec](#)! | [PCMU](#PCMU:android.net.rtp.AudioCodec) G. |\n| [String](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html)! | [fmtp](#fmtp:kotlin.String) The format parameters to be used in the corresponding SDP attribute. |\n| [String](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html)! | [rtpmap](#rtpmap:kotlin.String) The encoding parameters to be used in the corresponding SDP attribute. |\n| [Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html) | [type](#type:kotlin.Int) The RTP payload type of the encoding. |\n\nPublic methods\n--------------\n\n### getCodec\n\nAdded in [API level 12](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels) \n\n```\nopen static fun getCodec(\n type: Int, \n rtpmap: String!, \n fmtp: String!\n): AudioCodec!\n```\n\n**Deprecated:** *Deprecated in Java.*\n\nCreates an AudioCodec according to the given configuration.\n\n| Parameters ||\n|----------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| `type` | [Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html): The payload type of the encoding defined in RTP/AVP. |\n| `rtpmap` | [String](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html)!: The encoding parameters specified in the corresponding SDP attribute, or null if it is not available. |\n| `fmtp` | [String](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html)!: The format parameters specified in the corresponding SDP attribute, or null if it is not available. |\n\n| Return ||\n|------------------|-------------------------------------------------------------|\n| [AudioCodec](#)! | The configured AudioCodec or `null` if it is not supported. |\n\n### getCodecs\n\nAdded in [API level 12](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels) \n\n```\nopen static fun getCodecs(): Array\u003cAudioCodec!\u003e!\n```\n\n**Deprecated:** *Deprecated in Java.*\n\nReturns system supported audio codecs.\n\nProperties\n----------\n\n### AMR\n\nAdded in [API level 12](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels) \n\n```\nstatic val AMR: AudioCodec!\n```\n\n**Deprecated:** *Deprecated in Java.*\n\nAdaptive 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. \n\n### GSM\n\nAdded in [API level 12](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels) \n\n```\nstatic val GSM: AudioCodec!\n```\n\n**Deprecated:** *Deprecated in Java.*\n\nGSM Full-Rate audio codec, also known as GSM-FR, GSM 06.10, GSM, or simply FR. \n\n### GSM_EFR\n\nAdded in [API level 12](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels) \n\n```\nstatic val GSM_EFR: AudioCodec!\n```\n\n**Deprecated:** *Deprecated in Java.*\n\nGSM Enhanced Full-Rate audio codec, also known as GSM-EFR, GSM 06.60, or simply EFR. \n\n### PCMA\n\nAdded in [API level 12](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels) \n\n```\nstatic val PCMA: AudioCodec!\n```\n\n**Deprecated:** *Deprecated in Java.*\n\nG.711 a-law audio codec. \n\n### PCMU\n\nAdded in [API level 12](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels) \n\n```\nstatic val PCMU: AudioCodec!\n```\n\n**Deprecated:** *Deprecated in Java.*\n\nG.711 u-law audio codec. \n\n### fmtp\n\nAdded in [API level 12](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels) \n\n```\nval fmtp: String!\n```\n\n**Deprecated:** *Deprecated in Java.*\n\nThe format parameters to be used in the corresponding SDP attribute. \n\n### rtpmap\n\nAdded in [API level 12](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels) \n\n```\nval rtpmap: String!\n```\n\n**Deprecated:** *Deprecated in Java.*\n\nThe encoding parameters to be used in the corresponding SDP attribute. \n\n### type\n\nAdded in [API level 12](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels) \n\n```\nval type: Int\n```\n\n**Deprecated:** *Deprecated in Java.*\n\nThe RTP payload type of the encoding."]]