WEBRTC Technology Group: 234795279
1. Voiceengine CODEC data structure
WEBRTC, a struct struct codecinst is used to represent a specific audio codec object:
struct Codecinst
{
int pltype; Payload Type Payload
char plname[32];//payload name payload, 32 characters representing
int plfreq; Payload frequence Load Frequency
int pacsize; Packet size package
int channels; Channel
int rate; Rate or adaptive
};
parameters Detailed Description:
1, Pltype range between 1~126 is the effective value;
The value of Pltype can be judged by calling the following validpayloadtype (int payload_type) method, in ... \src\modules\audio_coding\main\source\acm_codec _database.cc definition
Checks If the payload type is in the valid range.
BOOL Acmcodecdb::validpayloadtype (int payload_type) {
if (Payload_type < 0) | | (Payload_type > 127)) {
return false;
}
return true;
}
2, Plname is the name of the codec, the possible value is defined in createcodecinstance, such as WEBRTC default "ISAC"
Voiceengine supports multiple audio codecs, specifically supported codecs defined in Createcodecinstance (const codecinst* codec_inst), such as ISAC\PCMU\PCMA\ILBC\AMR, etc., in ... \src\modules\audio_coding\main\source\acm_codec_database.cc definition
acmgenericcodec* acmcodecdb::createcodecinstance (const codecinst* codec_inst) {//All-we have the support for right now. if (! STR_CASE_CMP (Codec_inst->plname, "ISAC")) {#if (defined (WEBRTC_CODEC_ISAC) | | defined (WEBRTC_CODEC_ISACFX)) retur
N New Acmisac (KISAC); #endif} else if (!
STR_CASE_CMP (Codec_inst->plname, "PCMU")) {return new ACMPCMU (KPCMU); } else if (!
STR_CASE_CMP (Codec_inst->plname, "PCMA")) {return new ACMPCMA (KPCMA); } else if (! STR_CASE_CMP (Codec_inst->plname, "ILBC")) {#ifdef WEBRTC_CODEC_ILBC return new ACMILBC (KILBC); #endif} else if (! STR_CASE_CMP (Codec_inst->plname, "AMR")) {#ifdef WEBRTC_CODEC_AMR return new Acmamr (KGSMAMR); #endif} else if ( ! STR_CASE_CMP (Codec_inst->plname, "AMR-WB")) {#ifdef WEBRTC_CODEC_AMRWB return new ACMAMRWB (KGSMAMRWB); #endif} else if (! STR_CASE_CMP (Codec_inst->plname, "G722")) {#ifdef webrtc_codec_g722 return new ACMG722 (kG722); #endif} else if (! STR_CASE_CMP (codec_insT->plname, "G7221")) {switch (codec_inst->plfreq) {case 16000: {#ifdef webrtc_codec_g722_1 int
codec_id;
Switch (codec_inst->rate) {case 16000: {codec_id = kg722_1_16;
Break
} case 24000: {codec_id = kg722_1_24;
Break
} case 32000: {codec_id = kg722_1_32;
Break
} default: {return NULL;
} return new Acmg722_1 (codec_id);
} #endif} case 32000: {#ifdef webrtc_codec_g722_1c int codec_id;
Switch (codec_inst->rate) {case 24000: {codec_id = kg722_1c_24;
Break
} case 32000: {codec_id = kg722_1c_32;
Break
} case 48000: {codec_id = kg722_1c_48;
Break
} default: {return NULL; } return new acmg722_1c (codec_id); } #endif}}} else if (! STR_CASE_CMP (Codec_inst->plname, "cn")) {//For CN-we need to check sampling frequency-know what codec to creat
E. int codec_id;
Switch (codec_inst->plfreq) {case 8000: {codec_id = KCNNB;
Break
} case 16000: {codec_id = KCNWB;
Break
} case 32000: {codec_id = KCNSWB;
Break
} default: {return NULL;
}} return new Acmcng (codec_id); } else if (! STR_CASE_CMP (Codec_inst->plname, "G729")) {#ifdef webrtc_codec_g729 return new ACMG729 (kG729); #endif} else if (! STR_CASE_CMP (Codec_inst->plname, "G7291")) {#ifdef webrtc_codec_g729_1 return new Acmg729_1 (kg729_1); #endif} E LSE IF (!
STR_CASE_CMP (Codec_inst->plname, "Speex")) {#ifdef Webrtc_codec_speex int codec_id; Switch (codec_inst->plfreq) {case 8000: {Codec_id = kSPEEX8;
Break
} case 16000: {codec_id = kSPEEX16;
Break
} default: {return NULL;
}} return new Acmspeex (codec_id); #endif} else if (! STR_CASE_CMP (Codec_inst->plname, "cn")) {//For CN-we need to check sampling frequency-know what codec to creat
E. int codec_id;
Switch (codec_inst->plfreq) {case 8000: {codec_id = KCNNB;
Break
} case 16000: {codec_id = KCNWB;
Break
} case 32000: {codec_id = KCNSWB;
Break
} default: {return NULL;
}} return new Acmcng (codec_id); } else if (! STR_CASE_CMP (Codec_inst->plname, "L16")) {#ifdef WEBRTC_CODEC_PCM16//For L16 we need to check sampling frequency
To know what codec to create.
int codec_id;
Switch (codec_inst->plfreq) {case 8000: {codec_id = kpcm16b;
Break } Case 16000: {codec_id =KPCM16BWB;
Break
} case 32000: {codec_id = kpcm16bswb32khz;
Break
} default: {return NULL;
}} return new acmpcm16b (codec_id); #endif} else if (! STR_CASE_CMP (Codec_inst->plname, "telephone-event")) {#ifdef WEBRTC_CODEC_AVT return new Acmdtmfplayout (KAVT); #en DIF} else if (! STR_CASE_CMP (Codec_inst->plname, "red") {#ifdef webrtc_codec_red return new acmred (kred); #endif} return NUL
L
}
3, Plfreq generally take the following values (defined in common_types.h);
Load frequency value
enum payloadfrequencies
{
kfreq8000hz = 8000,
kfreq16000hz = 16000,
kfreq32000hz = 32000
};
4, Pacsize value is related to the Plfreq, the unit is Kbps , here is the calculation formula
The calculation formula is as follows:
if: Plfreq = 16000 (unit Hz)
If I need a packet size of 30ms (MS)
Then pacsize = (plfreq *30)/1000 = 480kbps;
That is: To get the packet size of k MS, you can calculate the
Pacsize = (Plfreq * k)/1000
And if Plfreq = 32000;20ms's packet size, then Pacsize = 640;
5, Channels value
Channels = 1 means mono
Channels = 2 means stereo Channel
Note: Channels =-1 indicates that only mono mode is supported at this time
6. Rate value, Unit is bps
General rate = 16000,32000,48000 These 16000 integer multiples of the value, i.e. 16KBPS,32KBPS,48KPBS
Note: When rate =-1, the adaptive channel speed is started at this time
2. See sample code for all codec information supported by Voiceengine
List (get) All codec information supported by the engine
//Support platform: Windows, Mac OS X, Linux
#include "voe_base.h"
#include "voe_codec.h
" voiceengine* ve = voiceengine::create ();
voecodec* codec = Voecodec::getinterface (ve);
for (int = 0; i < codec->numofcodecs (); i++)
{
codecinst cinst;
Codec->getcodec (i, cinst);
Display_codec_info (i, cinst);
}
Release Sub-api
codec->release ();
Delete Engine
voiceengine::D elete (VE);
3. Initialize the Voiceengine codec sample code
Initialize Voiceengine codec sample code
//Support platform: Windows, Mac OS X, Linux
#include "voe_codec.h"
codecinst cinst;
Initialize the ISAC codec parameter
strcpy (cinst.plname, "ISAC");
Cinst.plfreq = 16000;//ISAC wideband mode sampling frequency
cinst.pltype = 103;
Cinst.pacsize = 480; Use 30ms packet size,480kbps
cinst.channels = 1; Mono
Cinst.rate =-1; Channel Adaptive mode
//initialization complete
//In the channel with ID 0 activated initialized isac
codec->setsendcodec (0, Cinst);
Welcome to point out the wrong place: zengxijin@qq.com
/============================================================================================================== ====/Author:zengxijin zengxijin@qq.com Welcome reprint, please indicate the source of the original address: Http://blog.csdn.net/temotemo/================= =================================================================================================/