~ubuntu-branches/ubuntu/wily/sflphone/wily

« back to all changes in this revision

Viewing changes to daemon/libs/pjproject-2.1.0/pjmedia/include/pjmedia/silencedet.h

  • Committer: Package Import Robot
  • Author(s): Francois Marier, Francois Marier, Mark Purcell
  • Date: 2014-10-18 15:08:50 UTC
  • mfrom: (1.1.12)
  • mto: This revision was merged to the branch mainline in revision 29.
  • Revision ID: package-import@ubuntu.com-20141018150850-2exfk34ckb15pcwi
Tags: 1.4.1-0.1
[ Francois Marier ]
* Non-maintainer upload
* New upstream release (closes: #759576, #741130)
  - debian/rules +PJPROJECT_VERSION := 2.2.1
  - add upstream patch to fix broken TLS support
  - add patch to fix pjproject regression

[ Mark Purcell ]
* Build-Depends:
  - sflphone-daemon + libavformat-dev, libavcodec-dev, libswscale-dev,
  libavdevice-dev, libavutil-dev
  - sflphone-gnome + libclutter-gtk-1.0-dev

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/* $Id: silencedet.h 3553 2011-05-05 06:14:19Z nanang $ */
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_SILENCE_DET_H__
21
 
#define __PJMEDIA_SILENCE_DET_H__
22
 
 
23
 
 
24
 
/**
25
 
 * @file silencedet.h
26
 
 * @brief Adaptive silence detector.
27
 
 */
28
 
#include <pjmedia/types.h>
29
 
 
30
 
 
31
 
/**
32
 
 * @defgroup PJMEDIA_SILENCEDET Adaptive Silence Detection
33
 
 * @ingroup PJMEDIA_FRAME_OP
34
 
 * @brief Adaptive Silence Detector
35
 
 * @{
36
 
 */
37
 
 
38
 
 
39
 
PJ_BEGIN_DECL
40
 
 
41
 
 
42
 
/**
43
 
 * Opaque declaration for silence detector.
44
 
 */
45
 
typedef struct pjmedia_silence_det pjmedia_silence_det;
46
 
 
47
 
 
48
 
 
49
 
/**
50
 
 * Create voice activity detector with default settings. The default settings
51
 
 * are set to adaptive silence detection with the default threshold.
52
 
 *
53
 
 * @param pool              Pool for allocating the structure.
54
 
 * @param clock_rate        Clock rate.
55
 
 * @param samples_per_frame Number of samples per frame. The clock_rate and
56
 
 *                          samples_per_frame is only used to calculate the
57
 
 *                          frame time, from which some timing parameters
58
 
 *                          are calculated from.
59
 
 * @param p_sd              Pointer to receive the silence detector instance.
60
 
 *
61
 
 * @return                  PJ_SUCCESS on success.
62
 
 */
63
 
PJ_DECL(pj_status_t) pjmedia_silence_det_create( pj_pool_t *pool,
64
 
                                                 unsigned clock_rate,
65
 
                                                 unsigned samples_per_frame,
66
 
                                                 pjmedia_silence_det **p_sd );
67
 
 
68
 
 
69
 
/**
70
 
 * Set silence detector name to identify the particular silence detector
71
 
 * instance in the log.
72
 
 *
73
 
 * @param sd                The silence detector.
74
 
 * @param name              Name.
75
 
 *
76
 
 * @return                  PJ_SUCCESS on success.
77
 
 */
78
 
PJ_DECL(pj_status_t) pjmedia_silence_det_set_name(pjmedia_silence_det *sd,
79
 
                                                  const char *name);
80
 
 
81
 
 
82
 
/**
83
 
 * Set the sd to operate in fixed threshold mode. With fixed threshold mode,
84
 
 * the threshold will not be changed adaptively.
85
 
 *
86
 
 * @param sd                The silence detector
87
 
 * @param threshold         The silence threshold, or -1 to use default
88
 
 *                          threshold.
89
 
 *
90
 
 * @return                  PJ_SUCCESS on success.
91
 
 */
92
 
PJ_DECL(pj_status_t) pjmedia_silence_det_set_fixed( pjmedia_silence_det *sd,
93
 
                                                    int threshold );
94
 
 
95
 
/**
96
 
 * Set the sd to operate in adaptive mode. This is the default mode
97
 
 * when the silence detector is created.
98
 
 *
99
 
 * @param sd                The silence detector
100
 
 * @param threshold         Initial threshold to be set, or -1 to use default
101
 
 *                          threshold.
102
 
 *
103
 
 * @return                  PJ_SUCCESS on success.
104
 
 */
105
 
PJ_DECL(pj_status_t) pjmedia_silence_det_set_adaptive(pjmedia_silence_det *sd,
106
 
                                                      int threshold);
107
 
 
108
 
/**
109
 
 * Set other silence detector parameters.
110
 
 *
111
 
 * @param sd                The silence detector
112
 
 * @param before_silence    Minimum duration of silence (in msec) before 
113
 
 *                          silence is reported. If -1 is specified, then
114
 
 *                          the default value will be used. The default is
115
 
 *                          400 msec.
116
 
 * @param recalc_time1      The interval (in msec) to recalculate threshold
117
 
 *                          in non-silence condition when adaptive silence 
118
 
 *                          detection is set. If -1 is specified, then the 
119
 
 *                          default value will be used. The default is 4000
120
 
 *                          (msec).
121
 
 * @param recalc_time2      The interval (in msec) to recalculate threshold
122
 
 *                          in silence condition when adaptive silence detection
123
 
 *                          is set. If -1 is specified, then the default value 
124
 
 *                          will be used. The default value is 2000 (msec).
125
 
 *
126
 
 * @return                  PJ_SUCCESS on success.
127
 
 */
128
 
PJ_DECL(pj_status_t) pjmedia_silence_det_set_params( pjmedia_silence_det *sd,
129
 
                                                     int before_silence,
130
 
                                                     int recalc_time1,
131
 
                                                     int recalc_time2);
132
 
 
133
 
 
134
 
/**
135
 
 * Disable the silence detector.
136
 
 *
137
 
 * @param sd            The silence detector
138
 
 *
139
 
 * @return              PJ_SUCCESS on success.
140
 
 */
141
 
PJ_DECL(pj_status_t) pjmedia_silence_det_disable( pjmedia_silence_det *sd );
142
 
 
143
 
 
144
 
/**
145
 
 * Perform voice activity detection on the given input samples. This
146
 
 * function uses #pjmedia_calc_avg_signal() and #pjmedia_silence_det_apply()
147
 
 * for its calculation.
148
 
 *
149
 
 * @param sd            The silence detector instance.
150
 
 * @param samples       Pointer to 16-bit PCM input samples.
151
 
 * @param count         Number of samples in the input.
152
 
 * @param p_level       Optional pointer to receive average signal level
153
 
 *                      of the input samples.
154
 
 *
155
 
 * @return              Non zero if signal is silence.
156
 
 */
157
 
PJ_DECL(pj_bool_t) pjmedia_silence_det_detect( pjmedia_silence_det *sd,
158
 
                                               const pj_int16_t samples[],
159
 
                                               pj_size_t count,
160
 
                                               pj_int32_t *p_level);
161
 
 
162
 
 
163
 
/**
164
 
 * Calculate average signal level for the given samples.
165
 
 *
166
 
 * @param samples       Pointer to 16-bit PCM samples.
167
 
 * @param count         Number of samples in the input.
168
 
 *
169
 
 * @return              The average signal level, which simply is total level
170
 
 *                      divided by number of samples.
171
 
 */
172
 
PJ_DECL(pj_int32_t) pjmedia_calc_avg_signal( const pj_int16_t samples[],
173
 
                                             pj_size_t count );
174
 
 
175
 
 
176
 
 
177
 
/**
178
 
 * Perform voice activity detection, given the specified average signal
179
 
 * level.
180
 
 *
181
 
 * @param sd            The silence detector instance.
182
 
 * @param level         Signal level.
183
 
 *
184
 
 * @return              Non zero if signal is silence.
185
 
 */
186
 
PJ_DECL(pj_bool_t) pjmedia_silence_det_apply( pjmedia_silence_det *sd,
187
 
                                              pj_uint32_t level);
188
 
 
189
 
 
190
 
 
191
 
PJ_END_DECL
192
 
 
193
 
 
194
 
/**
195
 
 * @}
196
 
 */
197
 
 
198
 
 
199
 
#endif  /* __PJMEDIA_SILENCE_DET_H__ */
200