commit de lancement : 2.0.1-1
[asterisk-app-conference.git] / app_conference.c
CommitLineData
c575c500
TN
1/*
2 * app_conference
3 *
4 * A channel independent conference application for Asterisk
5 *
6 * Copyright (C) 2002, 2003 Junghanns.NET GmbH
7 * Copyright (C) 2003, 2004 HorizonLive.com, Inc.
8 * Copyright (C) 2005, 2006 HorizonWimba, Inc.
9 * Copyright (C) 2007 Wimba, Inc.
10 *
11 * Klaus-Peter Junghanns <kapejod@ns1.jnetdns.de>
12 *
13 * Video Conferencing support added by
14 * Neil Stratford <neils@vipadia.com>
15 * Copyright (C) 2005, 2005 Vipadia Limited
16 *
17 * VAD driven video conferencing, text message support
18 * and miscellaneous enhancements added by
19 * Mihai Balea <mihai at hates dot ms>
20 *
21 * This program may be modified and distributed under the
22 * terms of the GNU General Public License. You should have received
23 * a copy of the GNU General Public License along with this
24 * program; if not, write to the Free Software Foundation, Inc.
25 * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
26 */
27
28#include "asterisk.h"
29
30// SVN revision number, provided by make
31#ifndef REVISION
32#define REVISION "unknown"
33#endif
34
35static char *revision = REVISION;
36
37ASTERISK_FILE_VERSION(__FILE__, REVISION)
38
39#include "app_conference.h"
40#include "common.h"
41
42/*
43 * a conference has n + 1 threads, where n is the number of
44 * members and 1 is a conference thread which sends audio
45 * back to the members.
46 *
47 * each member thread reads frames from the channel and
48 * add's them to the member's frame queue.
49 *
50 * the conference thread reads frames from each speaking members
51 * queue, mixes them, and then re-queues them for the member thread
52 * to send back to the user.
53 */
54
55static char *app = "Conference";
56static char *synopsis = "Channel Independent Conference";
57static char *descrip = "Channel Independent Conference Application";
58
59static int app_conference_main(struct ast_channel* chan, void* data)
60{
61 int res ;
62 struct ast_module_user *u ;
63
64 u = ast_module_user_add(chan);
65
66 // call member thread function
67 res = member_exec( chan, data ) ;
68
69 ast_module_user_remove(u);
70
71 return res ;
72}
73
74static int unload_module( void )
75{
76 ast_log( LOG_NOTICE, "unloading app_conference module\n" ) ;
77
78 ast_module_user_hangup_all();
79
80 unregister_conference_cli() ;
81
82 return ast_unregister_application( app ) ;
83}
84
85static int load_module( void )
86{
87 ast_log( LOG_NOTICE, "Loading app_conference module, revision=%s\n", revision) ;
88
89 init_conference() ;
90
91 register_conference_cli() ;
92
93 return ast_register_application( app, app_conference_main, synopsis, descrip ) ;
94}
95
96// increment a timeval by ms milliseconds
97void add_milliseconds(struct timeval* tv, long ms)
98{
99 // add the microseconds to the microseconds field
100 tv->tv_usec += ( ms * 1000 ) ;
101
102 // calculate the number of seconds to increment
103 long s = ( tv->tv_usec / 1000000 ) ;
104
105 // adjust the microsends field
106 if ( s > 0 ) tv->tv_usec -= ( s * 1000000 ) ;
107
108 // increment the seconds field
109 tv->tv_sec += s ;
110}
111
112#define AST_MODULE "Conference"
113AST_MODULE_INFO_STANDARD(ASTERISK_GPL_KEY,
114 "Channel Independent Conference Application");
115#undef AST_MODULE
116