Tristan Matthews | 0a329cc | 2013-07-17 13:20:14 -0400 | [diff] [blame] | 1 | /* $Id: silk.h 4264 2012-09-24 06:58:16Z nanang $ */ |
| 2 | /* |
| 3 | * Copyright (C) 2012-2012 Teluu Inc. (http://www.teluu.com) |
| 4 | * Contributed by Regis Montoya (aka r3gis - www.r3gis.fr) |
| 5 | * |
| 6 | * This program is free software; you can redistribute it and/or modify |
| 7 | * it under the terms of the GNU General Public License as published by |
| 8 | * the Free Software Foundation; either version 2 of the License, or |
| 9 | * (at your option) any later version. |
| 10 | * |
| 11 | * This program is distributed in the hope that it will be useful, |
| 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 14 | * GNU General Public License for more details. |
| 15 | * |
| 16 | * You should have received a copy of the GNU General Public License |
| 17 | * along with this program; if not, write to the Free Software |
| 18 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
| 19 | */ |
| 20 | #ifndef __PJMEDIA_CODEC_SILK_H__ |
| 21 | #define __PJMEDIA_CODEC_SILK_H__ |
| 22 | |
| 23 | /** |
| 24 | * @file silk.h |
| 25 | * @brief SILK codec. |
| 26 | */ |
| 27 | |
| 28 | #include <pjmedia-codec/types.h> |
| 29 | |
| 30 | /** |
| 31 | * @defgroup PJMED_SILK SILK Codec Family |
| 32 | * @ingroup PJMEDIA_CODEC_CODECS |
| 33 | * @brief Implementation of SILK codecs (narrow/medium/wide/superwide-band). |
| 34 | * @{ |
| 35 | * |
| 36 | * This section describes functions to initialize and register SILK codec |
| 37 | * factory to the codec manager. After the codec factory has been registered, |
| 38 | * application can use @ref PJMEDIA_CODEC API to manipulate the codec. |
| 39 | * |
| 40 | * The SILK codec uses multiple bit rates, and supports super wideband |
| 41 | * (24 kHz sampling rate), wideband (16 kHz sampling rate), medium (12kHz |
| 42 | * sampling rate), and narrowband (telephone quality, 8 kHz sampling rate). |
| 43 | * |
| 44 | * By default, the SILK codec factory registers two SILK codecs: |
| 45 | * "SILK/8000" narrowband codec and "SILK/16000" wideband codec. This behavior |
| 46 | * can be changed by specifying #pjmedia_codec_silk_options flags during |
| 47 | * initialization. |
| 48 | * |
| 49 | * |
| 50 | * \section codec_setting Codec Settings |
| 51 | * |
| 52 | * \subsection general_setting General Settings |
| 53 | * |
| 54 | * General codec settings for this codec such as VAD and PLC can be |
| 55 | * manipulated through the <tt>setting</tt> field in #pjmedia_codec_param. |
| 56 | * Please see the documentation of #pjmedia_codec_param for more info. |
| 57 | * |
| 58 | * \subsection specific_setting Codec Specific Settings |
| 59 | * |
| 60 | * The following settings are applicable for this codec. |
| 61 | * |
| 62 | * \subsubsection quality_vs_complexity Quality vs Complexity |
| 63 | * |
| 64 | * The SILK codec quality versus computational complexity and bandwidth |
| 65 | * requirement can be adjusted by modifying the quality and complexity |
| 66 | * setting, by calling #pjmedia_codec_silk_set_config(). |
| 67 | * |
| 68 | * The default setting of quality is specified in |
| 69 | * #PJMEDIA_CODEC_SILK_DEFAULT_QUALITY. And the default setting of |
| 70 | * complexity is specified in #PJMEDIA_CODEC_SILK_DEFAULT_COMPLEXITY. |
| 71 | */ |
| 72 | |
| 73 | PJ_BEGIN_DECL |
| 74 | |
| 75 | typedef struct pjmedia_codec_silk_setting |
| 76 | { |
| 77 | pj_bool_t enabled; /**< Enable/disable. */ |
| 78 | int quality; /**< Encoding quality, or use -1 for default |
| 79 | (@see PJMEDIA_CODEC_SILK_DEFAULT_QUALITY). */ |
| 80 | int complexity; /**< Encoding complexity, or use -1 for default |
| 81 | (@see PJMEDIA_CODEC_SILK_DEFAULT_COMPLEXITY)*/ |
| 82 | } pjmedia_codec_silk_setting; |
| 83 | |
| 84 | |
| 85 | /** |
| 86 | * Initialize and register SILK codec factory to pjmedia endpoint. By default, |
| 87 | * only narrowband (8kHz sampling rate) and wideband (16kHz sampling rate) |
| 88 | * will be enabled. Quality and complexity for those sampling rate modes |
| 89 | * will be set to the default values (see #PJMEDIA_CODEC_SILK_DEFAULT_QUALITY |
| 90 | * and #PJMEDIA_CODEC_SILK_DEFAULT_COMPLEXITY), application may modify these |
| 91 | * settings via #pjmedia_codec_silk_set_config(). |
| 92 | * |
| 93 | * @param endpt The pjmedia endpoint. |
| 94 | * |
| 95 | * @return PJ_SUCCESS on success. |
| 96 | */ |
| 97 | PJ_DECL(pj_status_t) pjmedia_codec_silk_init(pjmedia_endpt *endpt); |
| 98 | |
| 99 | |
| 100 | /** |
| 101 | * Change the configuration setting of the SILK codec for the specified |
| 102 | * clock rate. |
| 103 | * |
| 104 | * @param clock_rate PCM sampling rate, in Hz, valid values are 8000, |
| 105 | * 12000, 16000 and 24000. |
| 106 | * @param opt The setting to be applied for the specified |
| 107 | * clock rate. |
| 108 | * |
| 109 | * @return PJ_SUCCESS on success. |
| 110 | */ |
| 111 | PJ_DECL(pj_status_t) pjmedia_codec_silk_set_config( |
| 112 | unsigned clock_rate, |
| 113 | const pjmedia_codec_silk_setting *opt); |
| 114 | |
| 115 | |
| 116 | /** |
| 117 | * Unregister SILK codec factory from pjmedia endpoint and deinitialize |
| 118 | * the SILK codec library. |
| 119 | * |
| 120 | * @return PJ_SUCCESS on success. |
| 121 | */ |
| 122 | PJ_DECL(pj_status_t) pjmedia_codec_silk_deinit(void); |
| 123 | |
| 124 | |
| 125 | PJ_END_DECL |
| 126 | |
| 127 | |
| 128 | /** |
| 129 | * @} |
| 130 | */ |
| 131 | |
| 132 | #endif /* __PJMEDIA_CODEC_SILK_H__ */ |
| 133 | |