AudioCodecpublic class AudioCodec extends Object This class defines a collection of audio codecs to be used with
{@link 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
{@link #getCodec(int, String, 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");
|
Fields Summary |
---|
public final int | typeThe RTP payload type of the encoding. | public final String | rtpmapThe encoding parameters to be used in the corresponding SDP attribute. | public final String | fmtpThe format parameters to be used in the corresponding SDP attribute. | public static final AudioCodec | PCMUG.711 u-law audio codec. | public static final AudioCodec | PCMAG.711 a-law audio codec. | public static final AudioCodec | GSMGSM Full-Rate audio codec, also known as GSM-FR, GSM 06.10, GSM, or
simply FR. | public static final AudioCodec | GSM_EFRGSM Enhanced Full-Rate audio codec, also known as GSM-EFR, GSM 06.60, or
simply EFR. | public static final AudioCodec | AMRAdaptive 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. | private static final AudioCodec[] | sCodecs |
Constructors Summary |
---|
private AudioCodec(int type, String rtpmap, String fmtp)
this.type = type;
this.rtpmap = rtpmap;
this.fmtp = fmtp;
|
Methods Summary |
---|
public static android.net.rtp.AudioCodec | getCodec(int type, java.lang.String rtpmap, java.lang.String fmtp)Creates an AudioCodec according to the given configuration.
if (type < 0 || type > 127) {
return null;
}
AudioCodec hint = null;
if (rtpmap != null) {
String clue = rtpmap.trim().toUpperCase();
for (AudioCodec codec : sCodecs) {
if (clue.startsWith(codec.rtpmap)) {
String channels = clue.substring(codec.rtpmap.length());
if (channels.length() == 0 || channels.equals("/1")) {
hint = codec;
}
break;
}
}
} else if (type < 96) {
for (AudioCodec codec : sCodecs) {
if (type == codec.type) {
hint = codec;
rtpmap = codec.rtpmap;
break;
}
}
}
if (hint == null) {
return null;
}
if (hint == AMR && fmtp != null) {
String clue = fmtp.toLowerCase();
if (clue.contains("crc=1") || clue.contains("robust-sorting=1") ||
clue.contains("interleaving=")) {
return null;
}
}
return new AudioCodec(type, rtpmap, fmtp);
| public static android.net.rtp.AudioCodec[] | getCodecs()Returns system supported audio codecs.
return Arrays.copyOf(sCodecs, sCodecs.length);
|
|