ACMGenericCodec* ACMCodecDB::CreateCodecInstance(const CodecInst* codec_inst) {
// All we have support for right now.
if (!STR_CASE_CMP(codec_inst->plname, "ISAC")) {
#if (defined(WEBRTC_CODEC_ISAC) || defined(WEBRTC_CODEC_ISACFX))
return 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 to know what codec to create.
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
} else 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 to know what codec to create.
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);
#endif
} else if (!STR_CASE_CMP(codec_inst->plname, "red")) {
#ifdef WEBRTC_CODEC_RED
return new ACMRED(kRED);
#endif
}
return NULL;
}