commit de lancement : 2.0.1-1
[asterisk-app-conference.git] / app_conference.h
1
2 // $Id: app_conference.h 839 2007-01-17 22:32:03Z sbalea $
3
4 /*
5 * app_conference
6 *
7 * A channel independent conference application for Asterisk
8 *
9 * Copyright (C) 2002, 2003 Junghanns.NET GmbH
10 * Copyright (C) 2003, 2004 HorizonLive.com, Inc.
11 * Copyright (C) 2005, 2006 HorizonWimba, Inc.
12 * Copyright (C) 2007 Wimba, Inc.
13 *
14 * Klaus-Peter Junghanns <kapejod@ns1.jnetdns.de>
15 *
16 * Video Conferencing support added by
17 * Neil Stratford <neils@vipadia.com>
18 * Copyright (C) 2005, 2005 Vipadia Limited
19 *
20 * VAD driven video conferencing, text message support
21 * and miscellaneous enhancements added by
22 * Mihai Balea <mihai at hates dot ms>
23 *
24 * This program may be modified and distributed under the
25 * terms of the GNU General Public License. You should have received
26 * a copy of the GNU General Public License along with this
27 * program; if not, write to the Free Software Foundation, Inc.
28 * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
29 */
30
31 #ifndef _ASTERISK_CONF_H
32 #define _ASTERISK_CONF_H
33
34
35 /* standard includes */
36 #include <stdlib.h>
37 #include <unistd.h>
38 #include <string.h>
39 #include <stdlib.h>
40 #include <math.h>
41 #include <stdio.h>
42
43
44 #include <pthread.h>
45
46 /* asterisk includes */
47 #include <asterisk/utils.h>
48 #include <asterisk/pbx.h>
49 #include <asterisk/module.h>
50 #include <asterisk/logger.h>
51 #include <asterisk/lock.h>
52 #include <asterisk/frame.h>
53 #include <asterisk/manager.h>
54 #include <asterisk/dsp.h>
55 #include <asterisk/translate.h>
56 #include <asterisk/channel.h>
57 #include <asterisk/file.h>
58 //#include <asterisk/channel_pvt.h>
59 #include <asterisk/cli.h>
60
61
62 #if (SILDET == 2)
63 #include "libspeex/speex_preprocess.h"
64 #endif
65
66 //
67 // app_conference defines
68 //
69
70 // debug logging level
71
72 // LOG_NOTICE for debugging, LOG_DEBUG for production
73 #ifdef APP_CONFERENCE_DEBUG
74 #define AST_CONF_DEBUG LOG_NOTICE
75 #else
76 #define AST_CONF_DEBUG LOG_DEBUG
77 #endif
78
79 //
80 // feature defines
81 //
82
83 // number of times the last non-silent frame should be
84 // repeated after silence starts
85 #define AST_CONF_CACHE_LAST_FRAME 1
86
87 //
88 // debug defines
89 //
90
91 //#define DEBUG_USE_TIMELOG
92
93 //#define DEBUG_FRAME_TIMESTAMPS
94
95 // #define DEBUG_OUTPUT_PCM
96
97 //
98 // !!! THESE CONSTANTS SHOULD BE CLEANED UP AND CLARIFIED !!!
99 //
100
101 //
102 // sample information for AST_FORMAT_SLINEAR format
103 //
104
105 #define AST_CONF_SAMPLE_RATE 8000
106 #define AST_CONF_SAMPLE_SIZE 16
107 #define AST_CONF_FRAME_INTERVAL 20
108 //neils#define AST_CONF_FRAME_INTERVAL 30
109
110 //
111 // so, since we cycle approximately every 20ms,
112 // we can compute the following values:
113 //
114 // 160 samples per 20 ms frame -or-
115 // ( 8000 samples-per-second * ( 20 ms / 1000 ms-per-second ) ) = 160 samples
116 //
117 // 320 bytes ( 2560 bits ) of data 20 ms frame -or-
118 // ( 160 samples * 16 bits-per-sample / 8 bits-per-byte ) = 320 bytes
119 //
120
121 // 160 samples 16-bit signed linear
122 #define AST_CONF_BLOCK_SAMPLES 160
123
124 // 2 bytes per sample ( i.e. 16-bit )
125 #define AST_CONF_BYTES_PER_SAMPLE 2
126
127 // 320 bytes for each 160 sample frame of 16-bit audio
128 #define AST_CONF_FRAME_DATA_SIZE 320
129
130 // 1000 ms-per-second / 20 ms-per-frame = 50 frames-per-second
131 #define AST_CONF_FRAMES_PER_SECOND ( 1000 / AST_CONF_FRAME_INTERVAL )
132
133
134 //
135 // buffer and queue values
136 //
137
138 // account for friendly offset when allocating buffer for frame
139 #define AST_CONF_BUFFER_SIZE ( AST_CONF_FRAME_DATA_SIZE + AST_FRIENDLY_OFFSET )
140
141 // maximum number of frames queued per member
142 #define AST_CONF_MAX_QUEUE 100
143
144 // max video frames in the queue
145 #define AST_CONF_MAX_VIDEO_QUEUE 800
146
147 // max dtmf frames in the queue
148 #define AST_CONF_MAX_DTMF_QUEUE 8
149
150 // max text frames in the queue
151 #define AST_CONF_MAX_TEXT_QUEUE 8
152
153 // minimum number of frames queued per member
154 #define AST_CONF_MIN_QUEUE 0
155
156 // number of queued frames before we start dropping
157 #define AST_CONF_QUEUE_DROP_THRESHOLD 40
158
159 // number of milliseconds between frame drops
160 #define AST_CONF_QUEUE_DROP_TIME_LIMIT 750
161
162 //
163 // timer and sleep values
164 //
165
166 // milliseconds we're willing to wait for a channel
167 // event before we check for outgoing frames
168 #define AST_CONF_WAITFOR_LATENCY 40
169
170 // milliseconds to sleep before trying to process frames
171 #define AST_CONF_CONFERENCE_SLEEP 40
172
173 // milliseconds to wait between state notification updates
174 #define AST_CONF_NOTIFICATION_SLEEP 200
175
176 //
177 // warning threshold values
178 //
179
180 // number of frames behind before warning
181 #define AST_CONF_OUTGOING_FRAMES_WARN 70
182
183 // number of milliseconds off AST_CONF_FRAME_INTERVAL before warning
184 #define AST_CONF_INTERVAL_WARNING 1000
185
186 //
187 // silence detection values
188 //
189
190 // toggle silence detection
191 #define ENABLE_SILENCE_DETECTION 1
192
193 // silence threshold
194 #define AST_CONF_SILENCE_THRESHOLD 128
195
196 // speech tail (delay before dropping silent frames, in ms.
197 // #define AST_CONF_SPEECH_TAIL 180
198
199 // number of frames to ignore speex_preprocess() after speech detected
200 #define AST_CONF_SKIP_SPEEX_PREPROCESS 20
201
202 // our speex probability values
203 #define AST_CONF_PROB_START 0.05
204 #define AST_CONF_PROB_CONTINUE 0.02
205
206
207 //
208 // format translation values
209 //
210 #ifdef AC_USE_G729A
211 #define AC_SUPPORTED_FORMATS 6
212 enum { AC_SLINEAR_INDEX = 0, AC_ULAW_INDEX, AC_ALAW_INDEX, AC_GSM_INDEX, AC_SPEEX_INDEX, AC_G729A_INDEX } ;
213 #else
214 #define AC_SUPPORTED_FORMATS 5
215 enum { AC_SLINEAR_INDEX = 0, AC_ULAW_INDEX, AC_ALAW_INDEX, AC_GSM_INDEX, AC_SPEEX_INDEX } ;
216 #endif
217
218 //
219 // VAD based video switching parameters
220 // All time related values are in ms
221 //
222
223 // Amount of silence required before we decide somebody stopped talking
224 #define AST_CONF_VIDEO_STOP_TIMEOUT 2000
225
226 // Amount of audio required before we decide somebody started talking
227 #define AST_CONF_VIDEO_START_TIMEOUT 2000
228
229 //
230 // Text frame control protocol
231 //
232 #define AST_CONF_CONTROL_CAMERA_DISABLED "CONTROL:CAMERA_DISABLED"
233 #define AST_CONF_CONTROL_CAMERA_ENABLED "CONTROL:CAMERA_ENABLED"
234 #define AST_CONF_CONTROL_START_VIDEO "CONTROL:STARTVIDEO"
235 #define AST_CONF_CONTROL_STOP_VIDEO "CONTROL:STOPVIDEO"
236 #define AST_CONF_CONTROL_STOP_VIDEO_TRANSMIT "CONTROL:STOP_VIDEO_TRANSMIT"
237 #define AST_CONF_CONTROL_START_VIDEO_TRANSMIT "CONTROL:START_VIDEO_TRANSMIT"
238
239 // utility functions
240 void add_milliseconds( struct timeval* tv, long ms ) ;
241
242 #endif
243
244