blob: eea9ba7482a862ac5692ab3a46621945b39da6ba [file] [log] [blame]
Benny Prijono35fc1eb2011-07-15 09:51:46 +00001/* $Id$ */
2/*
3 * Copyright (C) 2011-2011 Teluu Inc. (http://www.teluu.com)
4 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18 */
19#include <pjmedia-codec.h>
20#include <pjmedia/g711.h>
21
22PJ_DEF(void) pjmedia_audio_codec_config_default(pjmedia_audio_codec_config*cfg)
23{
24 pj_bzero(cfg, sizeof(*cfg));
25 cfg->speex.option = 0;
26 cfg->speex.quality = PJMEDIA_CODEC_SPEEX_DEFAULT_QUALITY;
27 cfg->speex.complexity = PJMEDIA_CODEC_SPEEX_DEFAULT_COMPLEXITY;
28 cfg->ilbc.mode = 30;
29 cfg->passthrough.setting.ilbc_mode = cfg->ilbc.mode;
30}
31
32PJ_DEF(pj_status_t)
33pjmedia_codec_register_audio_codecs(pjmedia_endpt *endpt,
34 const pjmedia_audio_codec_config *c)
35{
36 pjmedia_audio_codec_config default_cfg;
37 pj_status_t status;
38
39 PJ_ASSERT_RETURN(endpt, PJ_EINVAL);
40 if (!c) {
41 pjmedia_audio_codec_config_default(&default_cfg);
42 c = &default_cfg;
43 }
44
45 PJ_ASSERT_RETURN(c->ilbc.mode==20 || c->ilbc.mode==30, PJ_EINVAL);
46
47#if PJMEDIA_HAS_PASSTHROUGH_CODECS
48 status = pjmedia_codec_passthrough_init2(endpt, &c->passthough.ilbc);
49 if (status != PJ_SUCCESS)
50 return status;
51#endif
52
53#if PJMEDIA_HAS_SPEEX_CODEC
54 /* Register speex. */
55 status = pjmedia_codec_speex_init(endpt, c->speex.option,
56 c->speex.quality,
57 c->speex.complexity);
58 if (status != PJ_SUCCESS)
59 return status;
60#endif
61
62#if PJMEDIA_HAS_ILBC_CODEC
63 /* Register iLBC. */
64 status = pjmedia_codec_ilbc_init( endpt, c->ilbc.mode);
65 if (status != PJ_SUCCESS)
66 return status;
67#endif /* PJMEDIA_HAS_ILBC_CODEC */
68
69#if PJMEDIA_HAS_GSM_CODEC
70 /* Register GSM */
71 status = pjmedia_codec_gsm_init(endpt);
72 if (status != PJ_SUCCESS)
73 return status;
74#endif /* PJMEDIA_HAS_GSM_CODEC */
75
76#if PJMEDIA_HAS_G711_CODEC
77 /* Register PCMA and PCMU */
78 status = pjmedia_codec_g711_init(endpt);
79 if (status != PJ_SUCCESS)
80 return status;
81#endif /* PJMEDIA_HAS_G711_CODEC */
82
83#if PJMEDIA_HAS_G722_CODEC
84 status = pjmedia_codec_g722_init(endpt );
85 if (status != PJ_SUCCESS)
86 return status;
87#endif /* PJMEDIA_HAS_G722_CODEC */
88
89#if PJMEDIA_HAS_INTEL_IPP
90 /* Register IPP codecs */
91 status = pjmedia_codec_ipp_init(endpt);
92 if (status != PJ_SUCCESS)
93 return status;
94#endif /* PJMEDIA_HAS_INTEL_IPP */
95
96#if PJMEDIA_HAS_G7221_CODEC
97 /* Register G722.1 codecs */
98 status = pjmedia_codec_g7221_init(endpt);
99 if (status != PJ_SUCCESS)
100 return status;
101#endif /* PJMEDIA_HAS_G7221_CODEC */
102
103#if PJMEDIA_HAS_L16_CODEC
104 /* Register L16 family codecs */
105 status = pjmedia_codec_l16_init(endpt, 0);
106 if (status != PJ_SUCCESS)
107 return status;
108#endif /* PJMEDIA_HAS_L16_CODEC */
109
Sauw Minge7dbbc82011-10-24 09:28:13 +0000110#if PJMEDIA_HAS_OPENCORE_AMRNB_CODEC
111 /* Register OpenCORE AMR-NB */
112 status = pjmedia_codec_opencore_amrnb_init(endpt);
113 if (status != PJ_SUCCESS)
114 return status;
115#endif
116
Benny Prijono35fc1eb2011-07-15 09:51:46 +0000117 return PJ_SUCCESS;
118}
119