Tristan Matthews | 0a329cc | 2013-07-17 13:20:14 -0400 | [diff] [blame] | 1 | /* $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 | |
| 22 | PJ_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 | |
| 32 | PJ_DEF(pj_status_t) |
| 33 | pjmedia_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->passthrough.setting); |
| 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 | |
| 110 | #if PJMEDIA_HAS_OPENCORE_AMRNB_CODEC || PJMEDIA_HAS_OPENCORE_AMRWB_CODEC |
| 111 | /* Register OpenCORE AMR */ |
| 112 | status = pjmedia_codec_opencore_amr_init(endpt, 0); |
| 113 | if (status != PJ_SUCCESS) |
| 114 | return status; |
| 115 | #endif |
| 116 | |
| 117 | #if PJMEDIA_HAS_SILK_CODEC |
| 118 | /* Register SILK */ |
| 119 | status = pjmedia_codec_silk_init(endpt); |
| 120 | if (status != PJ_SUCCESS) |
| 121 | return status; |
| 122 | #endif |
| 123 | |
| 124 | return PJ_SUCCESS; |
| 125 | } |
| 126 | |