| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
|
| 18 |
#include <pjmedia-codec.h> |
| 19 |
#include <pjmedia/g711.h> |
| 20 |
|
| 21 |
PJ_DEF(void) pjmedia_audio_codec_config_default(pjmedia_audio_codec_config*cfg) |
| 22 |
{ |
| 23 |
pj_bzero(cfg, sizeof(*cfg)); |
| 24 |
cfg->speex.option = 0; |
| 25 |
cfg->speex.quality = PJMEDIA_CODEC_SPEEX_DEFAULT_QUALITY; |
| 26 |
cfg->speex.complexity = PJMEDIA_CODEC_SPEEX_DEFAULT_COMPLEXITY; |
| 27 |
cfg->ilbc.mode = 30; |
| 28 |
cfg->passthrough.setting.ilbc_mode = cfg->ilbc.mode; |
| 29 |
} |
| 30 |
|
| 31 |
PJ_DEF(pj_status_t) |
| 32 |
pjmedia_codec_register_audio_codecs(pjmedia_endpt *endpt, |
| 33 |
const pjmedia_audio_codec_config *c) |
| 34 |
{ |
| 35 |
pjmedia_audio_codec_config default_cfg; |
| 36 |
pj_status_t status = PJ_SUCCESS; |
| 37 |
|
| 38 |
PJ_ASSERT_RETURN(endpt, PJ_EINVAL); |
| 39 |
if (!c) { |
| 40 |
pjmedia_audio_codec_config_default(&default_cfg); |
| 41 |
c = &default_cfg; |
| 42 |
} |
| 43 |
|
| 44 |
PJ_ASSERT_RETURN(c->ilbc.mode==20 || c->ilbc.mode==30, PJ_EINVAL); |
| 45 |
|
| 46 |
#if PJMEDIA_HAS_ANDROID_MEDIACODEC |
| 47 |
|
| 48 |
status = pjmedia_codec_and_media_aud_init(endpt); |
| 49 |
if (status != PJ_SUCCESS) { |
| 50 |
return status; |
| 51 |
} |
| 52 |
#endif |
| 53 |
|
| 54 |
#if PJMEDIA_HAS_PASSTHROUGH_CODECS |
| 55 |
status = pjmedia_codec_passthrough_init2(endpt, &c->passthrough.setting); |
| 56 |
if (status != PJ_SUCCESS) |
| 57 |
return status; |
| 58 |
#endif |
| 59 |
|
| 60 |
#if PJMEDIA_HAS_SPEEX_CODEC |
| 61 |
|
| 62 |
status = pjmedia_codec_speex_init(endpt, c->speex.option, |
| 63 |
c->speex.quality, |
| 64 |
c->speex.complexity); |
| 65 |
if (status != PJ_SUCCESS) |
| 66 |
return status; |
| 67 |
#endif |
| 68 |
|
| 69 |
#if PJMEDIA_HAS_ILBC_CODEC |
| 70 |
|
| 71 |
status = pjmedia_codec_ilbc_init( endpt, c->ilbc.mode); |
| 72 |
if (status != PJ_SUCCESS) |
| 73 |
return status; |
| 74 |
#endif |
| 75 |
|
| 76 |
#if PJMEDIA_HAS_GSM_CODEC |
| 77 |
|
| 78 |
status = pjmedia_codec_gsm_init(endpt); |
| 79 |
if (status != PJ_SUCCESS) |
| 80 |
return status; |
| 81 |
#endif |
| 82 |
|
| 83 |
#if PJMEDIA_HAS_G711_CODEC |
| 84 |
|
| 85 |
status = pjmedia_codec_g711_init(endpt); |
| 86 |
if (status != PJ_SUCCESS) |
| 87 |
return status; |
| 88 |
#endif |
| 89 |
|
| 90 |
#if PJMEDIA_HAS_G722_CODEC |
| 91 |
status = pjmedia_codec_g722_init(endpt ); |
| 92 |
if (status != PJ_SUCCESS) |
| 93 |
return status; |
| 94 |
#endif |
| 95 |
|
| 96 |
#if PJMEDIA_HAS_INTEL_IPP |
| 97 |
|
| 98 |
status = pjmedia_codec_ipp_init(endpt); |
| 99 |
if (status != PJ_SUCCESS) |
| 100 |
return status; |
| 101 |
#endif |
| 102 |
|
| 103 |
#if PJMEDIA_HAS_G7221_CODEC |
| 104 |
|
| 105 |
status = pjmedia_codec_g7221_init(endpt); |
| 106 |
if (status != PJ_SUCCESS) |
| 107 |
return status; |
| 108 |
#endif |
| 109 |
|
| 110 |
#if PJMEDIA_HAS_L16_CODEC |
| 111 |
|
| 112 |
status = pjmedia_codec_l16_init(endpt, 0); |
| 113 |
if (status != PJ_SUCCESS) |
| 114 |
return status; |
| 115 |
#endif |
| 116 |
|
| 117 |
#if PJMEDIA_HAS_OPENCORE_AMRNB_CODEC || PJMEDIA_HAS_OPENCORE_AMRWB_CODEC |
| 118 |
|
| 119 |
status = pjmedia_codec_opencore_amr_init(endpt, 0); |
| 120 |
if (status != PJ_SUCCESS) |
| 121 |
return status; |
| 122 |
#endif |
| 123 |
|
| 124 |
#if PJMEDIA_HAS_SILK_CODEC |
| 125 |
|
| 126 |
status = pjmedia_codec_silk_init(endpt); |
| 127 |
if (status != PJ_SUCCESS) |
| 128 |
return status; |
| 129 |
#endif |
| 130 |
|
| 131 |
#if PJMEDIA_HAS_OPUS_CODEC |
| 132 |
|
| 133 |
status = pjmedia_codec_opus_init(endpt); |
| 134 |
if (status != PJ_SUCCESS) |
| 135 |
return status; |
| 136 |
#endif |
| 137 |
|
| 138 |
#if PJMEDIA_HAS_BCG729 |
| 139 |
|
| 140 |
status = pjmedia_codec_bcg729_init(endpt); |
| 141 |
if (status != PJ_SUCCESS) |
| 142 |
return status; |
| 143 |
#endif |
| 144 |
|
| 145 |
#if PJMEDIA_HAS_LYRA_CODEC |
| 146 |
|
| 147 |
status = pjmedia_codec_lyra_init(endpt); |
| 148 |
if (status != PJ_SUCCESS) |
| 149 |
return status; |
| 150 |
#endif |
| 151 |
|
| 152 |
return PJ_SUCCESS; |
| 153 |
} |
| 154 |
|