1
/* $Id: passthrough.h 3553 2011-05-05 06:14:19Z nanang $ */
3
* Copyright (C) 2008-2011 Teluu Inc. (http://www.teluu.com)
4
* Copyright (C) 2003-2008 Benny Prijono <benny@prijono.org>
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.
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.
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
20
#ifndef __PJMEDIA_CODECS_PASSTHROUGH_H__
21
#define __PJMEDIA_CODECS_PASSTHROUGH_H__
24
* @file pjmedia-codec/passthrough.h
25
* @brief Passthrough codecs.
28
#include <pjmedia-codec/types.h>
31
* @defgroup PJMED_PASSTHROUGH_CODEC Passthrough Codecs
32
* @ingroup PJMEDIA_CODEC_CODECS
33
* @brief Implementation of passthrough codecs
36
* This section describes functions to initialize and register passthrough
37
* codecs factory to the codec manager. After the codec factory has been
38
* registered, application can use @ref PJMEDIA_CODEC API to manipulate
41
* Passthrough codecs are codecs wrapper that does NOT perform encoding
42
* or decoding, it just PACK and PARSE encoded audio data from/into RTP
43
* payload. This will accomodate pjmedia ports which work with encoded
44
* audio data, e.g: encoded audio files, sound device with capability
45
* of playing/recording encoded audio data.
47
* This codec factory contains various codecs, i.e: G.729, iLBC,
51
* \section pjmedia_codec_passthrough_g729 Passthrough G.729
53
* G.729 supports 16-bit PCM audio signal with sampling rate 8000Hz,
54
* frame length 10ms, and resulting in bitrate 8000bps.
56
* \subsection codec_setting Codec Settings
58
* General codec settings for this codec such as VAD and PLC can be
59
* manipulated through the <tt>setting</tt> field in #pjmedia_codec_param.
60
* Please see the documentation of #pjmedia_codec_param for more info.
62
* Note that G.729 VAD status should be signalled in SDP, see more
65
* \subsubsection annexb Annex B
67
* The capability of VAD/DTX is specified in Annex B.
69
* By default, Annex B is enabled. This default setting of Annex B can
70
* be modified using #pjmedia_codec_mgr_set_default_param().
72
* In #pjmedia_codec_param, Annex B is configured via VAD setting and
73
* format parameter "annexb" in the SDP "a=fmtp" attribute in
74
* decoding fmtp field. Valid values are "yes" and "no",
75
* the implementation default is "yes". When this parameter is omitted
76
* in the SDP, the value will be "yes" (RFC 4856 Section 2.1.9).
78
* Here is an example of modifying default setting of Annex B to
79
* be disabled using #pjmedia_codec_mgr_set_default_param():
81
pjmedia_codec_param param;
83
pjmedia_codec_mgr_get_default_param(.., ¶m);
86
param.setting.vad = 0;
87
// Set SDP format parameter
88
param.setting.dec_fmtp.cnt = 1;
89
param.setting.dec_fmtp.param[0].name = pj_str("annexb");
90
param.setting.dec_fmtp.param[0].val = pj_str("no");
92
pjmedia_codec_mgr_set_default_param(.., ¶m);
96
* The difference of Annex B status in SDP offer/answer may be considered as
97
* incompatible codec in SDP negotiation.
100
* \section pjmedia_codec_passthrough_ilbc Passthrough iLBC
102
* The iLBC codec is developed by Global IP Solutions (GIPS), formerly
103
* Global IP Sound. The iLBC offers low bitrate and graceful audio quality
104
* degradation on frame losses.
106
* The iLBC codec supports 16-bit PCM audio signal with sampling rate of
107
* 8000Hz operating at two modes: 20ms and 30ms frame length modes, resulting
108
* in bitrates of 15.2kbps for 20ms mode and 13.33kbps for 30ms mode.
110
* \subsection codec_setting Codec Settings
112
* General codec settings for this codec such as VAD and PLC can be
113
* manipulated through the <tt>setting</tt> field in #pjmedia_codec_param.
114
* Please see the documentation of #pjmedia_codec_param for more info.
116
* \subsubsection mode Mode
118
* The default mode should be set upon initialization, see
119
* #pjmedia_codec_passthrough_init2(). After the codec is initialized, the
120
* default mode can be modified using #pjmedia_codec_mgr_set_default_param().
122
* In #pjmedia_codec_param, iLBC mode can be set by specifying SDP
123
* format parameter "mode" in the SDP "a=fmtp" attribute for decoding
124
* direction. Valid values are "20" and "30" (for 20ms and 30ms mode
127
* Here is an example to set up #pjmedia_codec_param to use mode 20ms:
129
pjmedia_codec_param param;
131
// setting iLBC mode in SDP
132
param.setting.dec_fmtp.cnt = 1;
133
param.setting.dec_fmtp.param[0].name = pj_str("mode");
134
param.setting.dec_fmtp.param[0].val = pj_str("20");
139
* \section pjmedia_codec_passthrough_amr Passthrough AMR
141
* IPP AMR supports 16-bit PCM audio signal with sampling rate 8000Hz,
142
* 20ms frame length and producing various bitrates that ranges from 4.75kbps
145
* \subsection codec_setting Codec Settings
147
* General codec settings for this codec such as VAD and PLC can be
148
* manipulated through the <tt>setting</tt> field in #pjmedia_codec_param.
149
* Please see the documentation of #pjmedia_codec_param for more info.
151
* \subsubsection bitrate Bitrate
153
* By default, encoding bitrate is 7400bps. This default setting can be
154
* modified using #pjmedia_codec_mgr_set_default_param() by specifying
155
* prefered AMR bitrate in field <tt>info::avg_bps</tt> of
156
* #pjmedia_codec_param. Valid bitrates could be seen in
157
* #pjmedia_codec_amrnb_bitrates.
159
* \subsubsection payload_format Payload Format
161
* There are two AMR payload format types, bandwidth-efficient and
162
* octet-aligned. Default setting is using octet-aligned. This default payload
163
* format can be modified using #pjmedia_codec_mgr_set_default_param().
165
* In #pjmedia_codec_param, payload format can be set by specifying SDP
166
* format parameters "octet-align" in the SDP "a=fmtp" attribute for
167
* decoding direction. Valid values are "0" (for bandwidth efficient mode)
168
* and "1" (for octet-aligned mode).
170
* \subsubsection mode_set Mode-Set
172
* Mode-set is used for restricting AMR modes in decoding direction.
174
* By default, no mode-set restriction applied. This default setting can be
175
* be modified using #pjmedia_codec_mgr_set_default_param().
177
* In #pjmedia_codec_param, mode-set could be specified via format parameters
178
* "mode-set" in the SDP "a=fmtp" attribute for decoding direction. Valid
179
* value is a comma separated list of modes from the set 0 - 7, e.g:
180
* "4,5,6,7". When this parameter is omitted, no mode-set restrictions applied.
182
* Here is an example of modifying AMR default codec param:
184
pjmedia_codec_param param;
186
pjmedia_codec_mgr_get_default_param(.., ¶m);
188
// set default encoding bitrate to the highest 12.2kbps
189
param.info.avg_bps = 12200;
191
// restrict decoding bitrate to 10.2kbps and 12.2kbps only
192
param.setting.dec_fmtp.param[0].name = pj_str("mode-set");
193
param.setting.dec_fmtp.param[0].val = pj_str("6,7");
195
// also set to use bandwidth-efficient payload format
196
param.setting.dec_fmtp.param[1].name = pj_str("octet-align");
197
param.setting.dec_fmtp.param[1].val = pj_str("0");
199
param.setting.dec_fmtp.cnt = 2;
201
pjmedia_codec_mgr_set_default_param(.., ¶m);
205
* \section pjmedia_codec_passthrough_g711 Passthrough G.711
207
* The G.711 is an ultra low complexity codecs and in trade-off it results
208
* in high bitrate, i.e: 64kbps for 16-bit PCM with sampling rate 8000Hz.
210
* The factory contains two main compression algorithms, PCMU/u-Law and
213
* \subsection codec_setting Codec Settings
215
* General codec settings for this codec such as VAD and PLC can be
216
* manipulated through the <tt>setting</tt> field in #pjmedia_codec_param.
217
* Please see the documentation of #pjmedia_codec_param for more info.
224
* Codec passthrough configuration settings.
226
typedef struct pjmedia_codec_passthrough_setting
228
unsigned fmt_cnt; /**< Number of encoding formats
230
pjmedia_format *fmts; /**< Encoding formats to be
232
unsigned ilbc_mode; /**< iLBC default mode. */
233
} pjmedia_codec_passthrough_setting;
237
* Initialize and register passthrough codecs factory to pjmedia endpoint,
238
* all supported encoding formats will be enabled.
240
* @param endpt The pjmedia endpoint.
242
* @return PJ_SUCCESS on success.
244
PJ_DECL(pj_status_t) pjmedia_codec_passthrough_init( pjmedia_endpt *endpt );
248
* Initialize and register passthrough codecs factory to pjmedia endpoint
249
* with only specified encoding formats enabled.
251
* @param endpt The pjmedia endpoint.
252
* @param setting The settings.
254
* @return PJ_SUCCESS on success.
256
PJ_DECL(pj_status_t) pjmedia_codec_passthrough_init2(
257
pjmedia_endpt *endpt,
258
const pjmedia_codec_passthrough_setting *setting);
262
* Unregister passthrough codecs factory from pjmedia endpoint.
264
* @return PJ_SUCCESS on success.
266
PJ_DECL(pj_status_t) pjmedia_codec_passthrough_deinit(void);
276
#endif /* __PJMEDIA_CODECS_PASSTHROUGH_H__ */