Debian Codegraph @

Xpjproject/pjmedia/src/pjmedia-codec/audio_codecs.c

raw symbols SCIP
1 /*
2 * Copyright (C) 2011-2011 Teluu Inc. (http://www.teluu.com)
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 2 of the License, or
7 * (at your option) any later version.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
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 /* Register Android MediaCodec */
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 /* Register speex. */
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 /* Register iLBC. */
71 status = pjmedia_codec_ilbc_init( endpt, c->ilbc.mode);
72 if (status != PJ_SUCCESS)
73 return status;
74 #endif /* PJMEDIA_HAS_ILBC_CODEC */
75
76 #if PJMEDIA_HAS_GSM_CODEC
77 /* Register GSM */
78 status = pjmedia_codec_gsm_init(endpt);
79 if (status != PJ_SUCCESS)
80 return status;
81 #endif /* PJMEDIA_HAS_GSM_CODEC */
82
83 #if PJMEDIA_HAS_G711_CODEC
84 /* Register PCMA and PCMU */
85 status = pjmedia_codec_g711_init(endpt);
86 if (status != PJ_SUCCESS)
87 return status;
88 #endif /* PJMEDIA_HAS_G711_CODEC */
89
90 #if PJMEDIA_HAS_G722_CODEC
91 status = pjmedia_codec_g722_init(endpt );
92 if (status != PJ_SUCCESS)
93 return status;
94 #endif /* PJMEDIA_HAS_G722_CODEC */
95
96 #if PJMEDIA_HAS_INTEL_IPP
97 /* Register IPP codecs */
98 status = pjmedia_codec_ipp_init(endpt);
99 if (status != PJ_SUCCESS)
100 return status;
101 #endif /* PJMEDIA_HAS_INTEL_IPP */
102
103 #if PJMEDIA_HAS_G7221_CODEC
104 /* Register G722.1 codecs */
105 status = pjmedia_codec_g7221_init(endpt);
106 if (status != PJ_SUCCESS)
107 return status;
108 #endif /* PJMEDIA_HAS_G7221_CODEC */
109
110 #if PJMEDIA_HAS_L16_CODEC
111 /* Register L16 family codecs */
112 status = pjmedia_codec_l16_init(endpt, 0);
113 if (status != PJ_SUCCESS)
114 return status;
115 #endif /* PJMEDIA_HAS_L16_CODEC */
116
117 #if PJMEDIA_HAS_OPENCORE_AMRNB_CODEC || PJMEDIA_HAS_OPENCORE_AMRWB_CODEC
118 /* Register OpenCORE AMR */
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 /* Register SILK */
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 /* Register OPUS */
133 status = pjmedia_codec_opus_init(endpt);
134 if (status != PJ_SUCCESS)
135 return status;
136 #endif
137
138 #if PJMEDIA_HAS_BCG729
139 /* Register BCG729 */
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 /* Register Lyra */
147 status = pjmedia_codec_lyra_init(endpt);
148 if (status != PJ_SUCCESS)
149 return status;
150 #endif
151
152 return PJ_SUCCESS;
153 }
154