Fri Jul 3 20:35:31 2009

Asterisk developer's documentation


app_conference.c

Go to the documentation of this file.
00001 /*
00002  * app_conference
00003  *
00004  * A channel independent conference application for Asterisk
00005  *
00006  * Copyright (C) 2002, 2003 Junghanns.NET GmbH
00007  * Copyright (C) 2003, 2004 HorizonLive.com, Inc.
00008  * Copyright (C) 2005, 2006 HorizonWimba, Inc.
00009  * Copyright (C) 2007 Wimba, Inc.
00010  *
00011  * Klaus-Peter Junghanns <kapejod@ns1.jnetdns.de>
00012  *
00013  * Video Conferencing support added by
00014  * Neil Stratford <neils@vipadia.com>
00015  * Copyright (C) 2005, 2005 Vipadia Limited
00016  *
00017  * VAD driven video conferencing, text message support
00018  * and miscellaneous enhancements added by
00019  * Mihai Balea <mihai at hates dot ms>
00020  *
00021  * This program may be modified and distributed under the
00022  * terms of the GNU General Public License. You should have received
00023  * a copy of the GNU General Public License along with this
00024  * program; if not, write to the Free Software Foundation, Inc.
00025  * 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00026  */
00027 
00028 #include "asterisk.h"
00029 
00030 // SVN revision number, provided by make
00031 #ifndef REVISION
00032 #define REVISION "unknown"
00033 #endif
00034 
00035 static char *revision = REVISION;
00036 
00037 ASTERISK_FILE_VERSION(__FILE__, REVISION)
00038 
00039 #include "app_conference.h"
00040 #include "common.h"
00041 
00042 /*
00043  * a conference has n + 1 threads, where n is the number of
00044  * members and 1 is a conference thread which sends audio
00045  * back to the members.
00046  *
00047  * each member thread reads frames from the channel and
00048  * add's them to the member's frame queue.
00049  *
00050  * the conference thread reads frames from each speaking members
00051  * queue, mixes them, and then re-queues them for the member thread
00052  * to send back to the user.
00053  */
00054 
00055 static char *app = "Conference";
00056 static char *synopsis = "Channel Independent Conference";
00057 static char *descrip = "Channel Independent Conference Application";
00058 
00059 static int app_conference_main(struct ast_channel* chan, void* data)
00060 {
00061    int res ;
00062    struct ast_module_user *u ;
00063 
00064    u = ast_module_user_add(chan);
00065 
00066    // call member thread function
00067    res = member_exec( chan, data ) ;
00068 
00069    ast_module_user_remove(u);
00070 
00071    return res ;
00072 }
00073 
00074 static int unload_module( void )
00075 {
00076    ast_log( LOG_NOTICE, "unloading app_conference module\n" ) ;
00077 
00078    ast_module_user_hangup_all();
00079 
00080    unregister_conference_cli() ;
00081 
00082    return ast_unregister_application( app ) ;
00083 }
00084 
00085 static int load_module( void )
00086 {
00087    ast_log( LOG_NOTICE, "Loading app_conference module, revision=%s\n", revision) ;
00088 
00089    init_conference() ;
00090 
00091    register_conference_cli() ;
00092 
00093    return ast_register_application( app, app_conference_main, synopsis, descrip ) ;
00094 }
00095 
00096 // increment a timeval by ms milliseconds
00097 void add_milliseconds(struct timeval* tv, long ms)
00098 {
00099    // add the microseconds to the microseconds field
00100    tv->tv_usec += ( ms * 1000 ) ;
00101 
00102    // calculate the number of seconds to increment
00103    long s = ( tv->tv_usec / 1000000 ) ;
00104 
00105    // adjust the microsends field
00106    if ( s > 0 ) tv->tv_usec -= ( s * 1000000 ) ;
00107 
00108    // increment the seconds field
00109    tv->tv_sec += s ;
00110 }
00111 
00112 #define AST_MODULE "Conference"
00113 AST_MODULE_INFO_STANDARD(ASTERISK_GPL_KEY,
00114       "Channel Independent Conference Application");
00115 #undef AST_MODULE
00116 

Generated on Fri Jul 3 20:35:31 2009 for Asterisk - the Open Source PBX by  doxygen 1.5.9