blob: ba66c229be6e544c3e49cbdc658a643ef39249cf [file] [log] [blame]
Nanang Izzuddin57b88572009-04-01 12:05:34 +00001/* $Id$ */
2/*
3 * Copyright (C) 2008-2009 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 G722.1 Codec
Benny Prijono2e8cf632009-08-13 15:57:26 +000032 * @ingroup PJMEDIA_CODEC_CODECS
Nanang Izzuddin57b88572009-04-01 12:05:34 +000033 * @brief Implementation of G722.1 codec
34 * @{
35 *
36 * <b>G722.1 licensed from Polycom®</b>
37 * <b>G722.1 Annex C licensed from Polycom®</b>
38 *
39 * This section describes functions to register and register G722.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 * G722.1 is a low complexity codec that supports for 7kHz and 14kHz bandwidth
47 * audio signals working at bitrates ranging from 16kbps to 48kbps. It may be
48 * used with speech or music inputs.
49 *
50 * The codec implementation supports for standard and non-standard bitrates.
51 * By default, the standard bitrates are enabled upon initialization, i.e.:
52 * - 24kbps and 32kbps for audio bandwidth 7 kHz (16kHz sampling rate),
53 * - 24kbps, 32kbps, and 48kbps for audio bandwidth 14 kHz (32kHz sampling
54 * rate).
55 * The usage of non-standard bitrates must follow this requirements:
56 * - for sampling rate 16kHz: 16000 to 32000 bps, it must be a multiple of 400
57 * - for sampling rate 32kHz: 24000 to 48000 bps, it must be a multiple of 400
58 * Note that currently it is only up to two non-standard modes can be enabled
59 * at one time.
60 */
61
62PJ_BEGIN_DECL
63
64/**
65 * Initialize and register G722.1 codec factory to pjmedia endpoint.
66 *
67 * @param endpt The pjmedia endpoint.
68 *
69 * @return PJ_SUCCESS on success.
70 */
71PJ_DECL(pj_status_t) pjmedia_codec_g7221_init( pjmedia_endpt *endpt );
72
73
74/**
75 * Enable and disable G722.1 mode. By default, the standard modes are
76 * enabled upon initialization, i.e.:
77 * - sampling rate 16kHz, bitrate 24kbps and 32kbps.
78 * - sampling rate 32kHz, bitrate 24kbps, 32kbps, and 48kbps.
79 * This function can also be used for enabling non-standard modes.
80 * Note that currently it is only up to two non-standard modes can be
81 * enabled at one time.
82 *
83 * @param sample_rate PCM sampling rate, in Hz, valid values are only
84 * 16000 and 32000.
85 * @param bitrate G722.1 bitrate, in bps, the valid values are
86 * standard and non-standard bitrates as described
87 * above.
88 * @param enabled PJ_TRUE for enabling specified mode.
89 *
90 * @return PJ_SUCCESS on success.
91 */
92PJ_DECL(pj_status_t) pjmedia_codec_g7221_set_mode(unsigned sample_rate,
93 unsigned bitrate,
94 pj_bool_t enabled);
95
Benny Prijono8496b932009-04-20 14:19:11 +000096/**
97 * Set the G.722.1 codec encoder and decoder level adjustment.
98 * If the value is non-zero, then PCM input samples to the encoder will
99 * be shifted right by this value, and similarly PCM output samples from
100 * the decoder will be shifted left by this value.
101 *
102 * Default value is PJMEDIA_G7221_DEFAULT_PCM_SHIFT.
103 *
104 * @param val The value
105 *
106 * @return PJ_SUCCESS on success.
107 */
108PJ_DECL(pj_status_t) pjmedia_codec_g7221_set_pcm_shift(int val);
109
110
Nanang Izzuddin57b88572009-04-01 12:05:34 +0000111
112/**
113 * Unregister G722.1 codecs factory from pjmedia endpoint.
114 *
115 * @return PJ_SUCCESS on success.
116 */
117PJ_DECL(pj_status_t) pjmedia_codec_g7221_deinit(void);
118
119
120PJ_END_DECL
121
122
123/**
124 * @}
125 */
126
127#endif /* __PJMEDIA_CODECS_G7221_H__ */
128