blob: 16a5e0385899c023173cd71c4a09fc98a2db4e65 [file] [log] [blame]
Alexandre Lision8af73cb2013-12-10 14:11:20 -05001/* $Id$ */
2/*
3 * Copyright (C) 2008-2011 Teluu Inc. (http://www.teluu.com)
4 * Copyright (C) 2003-2008 Benny Prijono <benny@prijono.org>
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_CODECS_G7221_H__
21#define __PJMEDIA_CODECS_G7221_H__
22
23/**
24 * @file pjmedia-codec/g7221.h
25 * @brief G722.1 codec.
26 */
27
28#include <pjmedia-codec/types.h>
29
30/**
31 * @defgroup PJMED_G7221_CODEC G.722.1 Codec (Siren7/Siren14)
32 * @ingroup PJMEDIA_CODEC_CODECS
33 * @brief Implementation of G.722.1 codec
34 * @{
35 *
36 * <b>G.722.1 licensed from Polycom®</b><br />
37 * <b>G.722.1 Annex C licensed from Polycom®</b>
38 *
39 * This section describes functions to initialize and register G.722.1 codec
40 * factory to the codec manager. After the codec factory has been registered,
41 * application can use @ref PJMEDIA_CODEC API to manipulate the codec.
42 *
43 * PJMEDIA G722.1 codec implementation is based on ITU-T Recommendation
44 * G.722.1 (05/2005) C fixed point implementation including its Annex C.
45 *
46 * G.722.1 is a low complexity codec that supports 7kHz and 14kHz audio
47 * bandwidth working at bitrates ranging from 16kbps to 48kbps. It may be
48 * used with speech or music inputs.
49 *
50 *
51 * \section codec_setting Codec Settings
52 *
53 * \subsection general_setting General Settings
54 *
55 * General codec settings for this codec such as VAD and PLC can be
56 * manipulated through the <tt>setting</tt> field in #pjmedia_codec_param.
57 * Please see the documentation of #pjmedia_codec_param for more info.
58 *
59 * \subsection specific_setting Codec Specific Settings
60 *
61 * The following settings are applicable for this codec.
62 *
63 * \subsubsection bitrate Bitrate
64 *
65 * The codec implementation supports standard and non-standard bitrates.
66 * Use #pjmedia_codec_g7221_set_mode() to enable or disable the bitrates.
67 *
68 * By default, only standard bitrates are enabled upon initialization:
69 * - for 7kHz audio bandwidth (16kHz sampling rate): 24kbps and 32kbps,
70 * - for 14kHz audio bandwidth (32kHz sampling rate): 24kbps, 32kbps, and
71 * 48kbps.
72 *
73 * The usage of non-standard bitrates must follow these requirements:
74 * - for 7kHz audio bandwidth (16kHz sampling rate): 16000 to 32000 bps,
75 * multiplication of 400
76 * - for 14kHz audio bandwidth (32kHz sampling rate): 24000 to 48000 bps,
77 * multiplication of 400
78 *
79 * \note
80 * Currently only up to two non-standard modes can be enabled.
81 *
82 * \remark
83 * There is a flaw in the codec manager as currently it could not
84 * differentiate G.722.1 codecs by bitrates, hence invoking
85 * #pjmedia_codec_mgr_set_default_param() may only affect a G.722.1 codec
86 * with the highest priority (or first index found in codec enumeration
87 * when they have same priority) and invoking
88 * #pjmedia_codec_mgr_set_codec_priority() will set priority of all G.722.1
89 * codecs with sampling rate as specified.
90 */
91
92PJ_BEGIN_DECL
93
94/**
95 * Initialize and register G.722.1 codec factory to pjmedia endpoint.
96 *
97 * @param endpt The pjmedia endpoint.
98 *
99 * @return PJ_SUCCESS on success.
100 */
101PJ_DECL(pj_status_t) pjmedia_codec_g7221_init( pjmedia_endpt *endpt );
102
103
104/**
105 * Enable and disable G.722.1 mode. By default, the standard modes are
106 * enabled upon initialization, i.e.:
107 * - sampling rate 16kHz, bitrate 24kbps and 32kbps.
108 * - sampling rate 32kHz, bitrate 24kbps, 32kbps, and 48kbps.
109 * This function can also be used for enabling non-standard modes.
110 * Note that currently only up to two non-standard modes can be enabled
111 * at one time.
112 *
113 * @param sample_rate PCM sampling rate, in Hz, valid values are only
114 * 16000 and 32000.
115 * @param bitrate G722.1 bitrate, in bps, the valid values are
116 * standard and non-standard bitrates as described
117 * above.
118 * @param enabled PJ_TRUE for enabling specified mode.
119 *
120 * @return PJ_SUCCESS on success.
121 */
122PJ_DECL(pj_status_t) pjmedia_codec_g7221_set_mode(unsigned sample_rate,
123 unsigned bitrate,
124 pj_bool_t enabled);
125
126/**
127 * Set the G.722.1 codec encoder and decoder level adjustment.
128 * If the value is non-zero, then PCM input samples to the encoder will
129 * be shifted right by this value, and similarly PCM output samples from
130 * the decoder will be shifted left by this value.
131 *
132 * \note
133 * This function is also applicable for G722.1 implementation with IPP
134 * back-end.
135 *
136 * Default value is PJMEDIA_G7221_DEFAULT_PCM_SHIFT.
137 *
138 * @param val The value
139 *
140 * @return PJ_SUCCESS on success.
141 */
142PJ_DECL(pj_status_t) pjmedia_codec_g7221_set_pcm_shift(int val);
143
144
145
146/**
147 * Unregister G.722.1 codecs factory from pjmedia endpoint.
148 *
149 * @return PJ_SUCCESS on success.
150 */
151PJ_DECL(pj_status_t) pjmedia_codec_g7221_deinit(void);
152
153
154PJ_END_DECL
155
156
157/**
158 * @}
159 */
160
161#endif /* __PJMEDIA_CODECS_G7221_H__ */
162