Debian Codegraph @

Xpjproject/pjmedia/include/pjmedia-codec/passthrough.h

raw symbols SCIP
1 /*
2 * Copyright (C) 2008-2011 Teluu Inc. (http://www.teluu.com)
3 * Copyright (C) 2003-2008 Benny Prijono <[email protected]>
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 #ifndef __PJMEDIA_CODECS_PASSTHROUGH_H__
20 #define __PJMEDIA_CODECS_PASSTHROUGH_H__
21
22 /**
23 * @file pjmedia-codec/passthrough.h
24 * @brief Passthrough codecs.
25 */
26
27 #include <pjmedia-codec/types.h>
28
29 /**
30 * @defgroup PJMED_PASSTHROUGH_CODEC Passthrough Codecs
31 * @ingroup PJMEDIA_CODEC_CODECS
32 * @brief Implementation of passthrough codecs
33 * @{
34 *
35 * This section describes functions to initialize and register passthrough
36 * codecs factory to the codec manager. After the codec factory has been
37 * registered, application can use @ref PJMEDIA_CODEC API to manipulate
38 * the codec.
39 *
40 * Passthrough codecs are codecs wrapper that does NOT perform encoding
41 * or decoding, it just PACK and PARSE encoded audio data from/into RTP
42 * payload. This will accomodate pjmedia ports which work with encoded
43 * audio data, e.g: encoded audio files, sound device with capability
44 * of playing/recording encoded audio data.
45 *
46 * This codec factory contains various codecs, i.e: G.729, iLBC,
47 * AMR, and G.711.
48 *
49 *
50 * \section pjmedia_codec_passthrough_g729 Passthrough G.729
51 *
52 * G.729 supports 16-bit PCM audio signal with sampling rate 8000Hz,
53 * frame length 10ms, and resulting in bitrate 8000bps.
54 *
55 * \subsection passthrough_codec_setting Codec Settings
56 *
57 * General codec settings for this codec such as VAD and PLC can be
58 * manipulated through the <tt>setting</tt> field in #pjmedia_codec_param.
59 * Please see the documentation of #pjmedia_codec_param for more info.
60 *
61 * Note that G.729 VAD status should be signalled in SDP, see more
62 * description below.
63 *
64 * \subsubsection passthrough_g729_annexb Annex B
65 *
66 * The capability of VAD/DTX is specified in Annex B.
67 *
68 * By default, Annex B is enabled. This default setting of Annex B can
69 * be modified using #pjmedia_codec_mgr_set_default_param().
70 *
71 * In #pjmedia_codec_param, Annex B is configured via VAD setting and
72 * format parameter "annexb" in the SDP "a=fmtp" attribute in
73 * decoding fmtp field. Valid values are "yes" and "no",
74 * the implementation default is "yes". When this parameter is omitted
75 * in the SDP, the value will be "yes" (RFC 4856 Section 2.1.9).
76 *
77 * Here is an example of modifying default setting of Annex B to
78 * be disabled using #pjmedia_codec_mgr_set_default_param():
79 \code
80 pjmedia_codec_param param;
81
82 pjmedia_codec_mgr_get_default_param(.., &param);
83 ...
84 // Set VAD
85 param.setting.vad = 0;
86 // Set SDP format parameter
87 param.setting.dec_fmtp.cnt = 1;
88 param.setting.dec_fmtp.param[0].name = pj_str("annexb");
89 param.setting.dec_fmtp.param[0].val = pj_str("no");
90 ...
91 pjmedia_codec_mgr_set_default_param(.., &param);
92 \endcode
93 *
94 * \note
95 * The difference of Annex B status in SDP offer/answer may be considered as
96 * incompatible codec in SDP negotiation.
97 *
98 *
99 * \section pjmedia_codec_passthrough_ilbc Passthrough iLBC
100 *
101 * The iLBC codec is developed by Global IP Solutions (GIPS), formerly
102 * Global IP Sound. The iLBC offers low bitrate and graceful audio quality
103 * degradation on frame losses.
104 *
105 * The iLBC codec supports 16-bit PCM audio signal with sampling rate of
106 * 8000Hz operating at two modes: 20ms and 30ms frame length modes, resulting
107 * in bitrates of 15.2kbps for 20ms mode and 13.33kbps for 30ms mode.
108 *
109 * \subsection passthrough_ilbc_codec_setting Codec Settings
110 *
111 * General codec settings for this codec such as VAD and PLC can be
112 * manipulated through the <tt>setting</tt> field in #pjmedia_codec_param.
113 * Please see the documentation of #pjmedia_codec_param for more info.
114 *
115 * \subsubsection passthrough_ilbc_mode Mode
116 *
117 * The default mode should be set upon initialization, see
118 * #pjmedia_codec_passthrough_init2(). After the codec is initialized, the
119 * default mode can be modified using #pjmedia_codec_mgr_set_default_param().
120 *
121 * In #pjmedia_codec_param, iLBC mode can be set by specifying SDP
122 * format parameter "mode" in the SDP "a=fmtp" attribute for decoding
123 * direction. Valid values are "20" and "30" (for 20ms and 30ms mode
124 * respectively).
125 *
126 * Here is an example to set up #pjmedia_codec_param to use mode 20ms:
127 * \code
128 pjmedia_codec_param param;
129 ...
130 // setting iLBC mode in SDP
131 param.setting.dec_fmtp.cnt = 1;
132 param.setting.dec_fmtp.param[0].name = pj_str("mode");
133 param.setting.dec_fmtp.param[0].val = pj_str("20");
134 ...
135 \endcode
136 *
137 *
138 * \section pjmedia_codec_passthrough_amr Passthrough AMR
139 *
140 * IPP AMR supports 16-bit PCM audio signal with sampling rate 8000Hz,
141 * 20ms frame length and producing various bitrates that ranges from 4.75kbps
142 * to 12.2kbps.
143 *
144 * \subsection passthrough_amr_codec_setting Codec Settings
145 *
146 * General codec settings for this codec such as VAD and PLC can be
147 * manipulated through the <tt>setting</tt> field in #pjmedia_codec_param.
148 * Please see the documentation of #pjmedia_codec_param for more info.
149 *
150 * \subsubsection passthrough_amr_bitrate Bitrate
151 *
152 * By default, encoding bitrate is 7400bps. This default setting can be
153 * modified using #pjmedia_codec_mgr_set_default_param() by specifying
154 * prefered AMR bitrate in field <tt>info::avg_bps</tt> of
155 * #pjmedia_codec_param. Valid bitrates could be seen in
156 * #pjmedia_codec_amrnb_bitrates.
157 *
158 * \subsubsection passthrough_amr_payload_format Payload Format
159 *
160 * There are two AMR payload format types, bandwidth-efficient and
161 * octet-aligned. Default setting is using octet-aligned. This default payload
162 * format can be modified using #pjmedia_codec_mgr_set_default_param().
163 *
164 * In #pjmedia_codec_param, payload format can be set by specifying SDP
165 * format parameters "octet-align" in the SDP "a=fmtp" attribute for
166 * decoding direction. Valid values are "0" (for bandwidth efficient mode)
167 * and "1" (for octet-aligned mode).
168 *
169 * \subsubsection passthrough_amr_mode_set Mode-Set
170 *
171 * Mode-set is used for restricting AMR modes in decoding direction.
172 *
173 * By default, no mode-set restriction applied. This default setting can be
174 * be modified using #pjmedia_codec_mgr_set_default_param().
175 *
176 * In #pjmedia_codec_param, mode-set could be specified via format parameters
177 * "mode-set" in the SDP "a=fmtp" attribute for decoding direction. Valid
178 * value is a comma separated list of modes from the set 0 - 7, e.g:
179 * "4,5,6,7". When this parameter is omitted, no mode-set restrictions applied.
180 *
181 * Here is an example of modifying AMR default codec param:
182 \code
183 pjmedia_codec_param param;
184
185 pjmedia_codec_mgr_get_default_param(.., &param);
186 ...
187 // set default encoding bitrate to the highest 12.2kbps
188 param.info.avg_bps = 12200;
189
190 // restrict decoding bitrate to 10.2kbps and 12.2kbps only
191 param.setting.dec_fmtp.param[0].name = pj_str("mode-set");
192 param.setting.dec_fmtp.param[0].val = pj_str("6,7");
193
194 // also set to use bandwidth-efficient payload format
195 param.setting.dec_fmtp.param[1].name = pj_str("octet-align");
196 param.setting.dec_fmtp.param[1].val = pj_str("0");
197
198 param.setting.dec_fmtp.cnt = 2;
199 ...
200 pjmedia_codec_mgr_set_default_param(.., &param);
201 \endcode
202 *
203 *
204 * \section pjmedia_codec_passthrough_g711 Passthrough G.711
205 *
206 * The G.711 is an ultra low complexity codecs and in trade-off it results
207 * in high bitrate, i.e: 64kbps for 16-bit PCM with sampling rate 8000Hz.
208 *
209 * The factory contains two main compression algorithms, PCMU/u-Law and
210 * PCMA/A-Law.
211 *
212 * \subsection passthrough_g711_codec_setting Codec Settings
213 *
214 * General codec settings for this codec such as VAD and PLC can be
215 * manipulated through the <tt>setting</tt> field in #pjmedia_codec_param.
216 * Please see the documentation of #pjmedia_codec_param for more info.
217 */
218
219 PJ_BEGIN_DECL
220
221
222 /**
223 * Codec passthrough configuration settings.
224 */
225 typedef struct pjmedia_codec_passthrough_setting
226 {
227 unsigned fmt_cnt; /**< Number of encoding formats
228 to be enabled. */
229 pjmedia_format *fmts; /**< Encoding formats to be
230 enabled. */
231 unsigned ilbc_mode; /**< iLBC default mode. */
232 } pjmedia_codec_passthrough_setting;
233
234
235 /**
236 * Initialize and register passthrough codecs factory to pjmedia endpoint,
237 * all supported encoding formats will be enabled.
238 *
239 * @param endpt The pjmedia endpoint.
240 *
241 * @return PJ_SUCCESS on success.
242 */
243 PJ_DECL(pj_status_t) pjmedia_codec_passthrough_init( pjmedia_endpt *endpt );
244
245
246 /**
247 * Initialize and register passthrough codecs factory to pjmedia endpoint
248 * with only specified encoding formats enabled.
249 *
250 * @param endpt The pjmedia endpoint.
251 * @param setting The settings.
252 *
253 * @return PJ_SUCCESS on success.
254 */
255 PJ_DECL(pj_status_t) pjmedia_codec_passthrough_init2(
256 pjmedia_endpt *endpt,
257 const pjmedia_codec_passthrough_setting *setting);
258
259
260 /**
261 * Unregister passthrough codecs factory from pjmedia endpoint.
262 *
263 * @return PJ_SUCCESS on success.
264 */
265 PJ_DECL(pj_status_t) pjmedia_codec_passthrough_deinit(void);
266
267
268 PJ_END_DECL
269
270
271 /**
272 * @}
273 */
274
275 #endif /* __PJMEDIA_CODECS_PASSTHROUGH_H__ */
276