Mon Mar 31 07:37:54 2008

Asterisk developer's documentation


app_conference.c

Go to the documentation of this file.
00001  
00002 // $Id: app_conference.c 693 2006-11-15 22:29:26Z sbalea $
00003 
00004 /*
00005  * app_conference
00006  *
00007  * A channel independent conference application for Asterisk
00008  *
00009  * Copyright (C) 2002, 2003 Junghanns.NET GmbH
00010  * Copyright (C) 2003, 2004 HorizonLive.com, Inc.
00011  * Copyright (C) 2005, 2006 HorizonWimba, Inc.
00012  * Copyright (C) 2007 Wimba, Inc.
00013  *
00014  * Klaus-Peter Junghanns <kapejod@ns1.jnetdns.de>
00015  *
00016  * Video Conferencing support added by 
00017  * Neil Stratford <neils@vipadia.com>
00018  * Copyright (C) 2005, 2005 Vipadia Limited
00019  *
00020  * VAD driven video conferencing, text message support 
00021  * and miscellaneous enhancements added by 
00022  * Mihai Balea <mihai at hates dot ms>
00023  *
00024  * This program may be modified and distributed under the 
00025  * terms of the GNU General Public License. You should have received 
00026  * a copy of the GNU General Public License along with this 
00027  * program; if not, write to the Free Software Foundation, Inc.
00028  * 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00029  */
00030 
00031 #include "asterisk/autoconfig.h"
00032 #include "app_conference.h"
00033 #include "common.h"
00034 #include "asterisk/module.h"
00035 
00036 /*
00037 
00038 a conference has n + 1 threads, where n is the number of 
00039 members and 1 is a conference thread which sends audio
00040 back to the members. 
00041 
00042 each member thread reads frames from the channel and
00043 add's them to the member's frame queue. 
00044 
00045 the conference thread reads frames from each speaking members
00046 queue, mixes them, and then re-queues them for the member thread
00047 to send back to the user.
00048 
00049 */
00050 
00051 //
00052 // app_conference text descriptions
00053 //
00054 
00055 static char *tdesc = "Channel Independent Conference Application" ;
00056 static char *app = "Conference" ;
00057 static char *synopsis = "Channel Independent Conference" ;
00058 static char *descrip = "  Conference():  returns 0\n"
00059 "if the user exits with the '#' key, or -1 if the user hangs up.\n" ;
00060 
00061 // SVN revision number, provided by Make
00062 #ifdef REVISION
00063 static char *revision = REVISION;
00064 #else
00065 static char *revision = "unknown";
00066 #endif
00067 
00068 //
00069 // functions defined in asterisk/module.h
00070 //
00071 
00072 
00073 int unload_module(void *mod)
00074 {
00075    ast_log( LOG_NOTICE, "unloading app_conference module\n" ) ;
00076 
00077    ast_module_user_hangup_all();
00078    //STANDARD_HANGUP_LOCALUSERS ; // defined in asterisk/module.h
00079 
00080    // register conference cli functions
00081    unregister_conference_cli() ;
00082 
00083    return ast_unregister_application( app ) ;
00084 }
00085 
00086 int load_module(void *mod)
00087 {
00088    ast_log( LOG_NOTICE, "Loading app_conference module, revision=%s\n", revision) ;
00089 
00090    // intialize conference
00091    init_conference() ;
00092 
00093    // register conference cli functions
00094    register_conference_cli() ;
00095 
00096    return ast_register_application( app, app_conference_main, synopsis, descrip ) ;
00097 }
00098 
00099 const char *description()
00100 {
00101    return tdesc ;
00102 }
00103 
00104 #if 0
00105 static int usecount( void *mod )
00106 {
00107    int res;
00108    STANDARD_USECOUNT( res ) ; // defined in asterisk/module.h
00109    return res;
00110 }
00111 #endif
00112 
00113 char *key()
00114 {
00115    return ASTERISK_GPL_KEY ;
00116 }
00117 
00118 
00119 
00120 //
00121 // main app_conference function
00122 //
00123 
00124 int app_conference_main(struct ast_channel* chan, void* data)
00125 {
00126    int res = 0 ;
00127    struct ast_module_user *u ;
00128    
00129    // defined in asterisk/module.h
00130    //LOCAL_USER_ADD( u ) ; 
00131    u = ast_module_user_add(chan);
00132 
00133    // call member thread function
00134    res = member_exec( chan, data ) ;
00135 
00136    // defined in asterisk/module.h
00137    //LOCAL_USER_REMOVE( u ) ;
00138    ast_module_user_remove (u);
00139 
00140    return res ;
00141 }
00142 
00143 //
00144 // utility functions
00145 //
00146 
00147 // now returns milliseconds
00148 long usecdiff(struct timeval* timeA, struct timeval* timeB)
00149 {
00150    long a_secs = timeA->tv_sec - timeB->tv_sec ;
00151    long b_secs = (long)( timeA->tv_usec / 1000 ) - (long)( timeB->tv_usec / 1000 ) ;
00152    long u_secs = ( a_secs * 1000 ) + b_secs ;
00153    return u_secs ;
00154 }
00155 
00156 // increment a timeval by ms milliseconds
00157 void add_milliseconds(struct timeval* tv, long ms)
00158 {
00159    // add the microseconds to the microseconds field
00160    tv->tv_usec += ( ms * 1000 ) ;
00161 
00162    // calculate the number of seconds to increment
00163    long s = ( tv->tv_usec / 1000000 ) ;
00164 
00165    // adjust the microsends field
00166    if ( s > 0 ) tv->tv_usec -= ( s * 1000000 ) ;
00167 
00168    // increment the seconds field
00169    tv->tv_sec += s ;
00170 
00171    return ;
00172 }
00173 
00174 int reload(void *mod)
00175 {
00176    return 0;   
00177 }
00178 
00179 #define AST_MODULE "conference"
00180 
00181 AST_MODULE_INFO_STANDARD(ASTERISK_GPL_KEY, "Conference");
00182 
00183 //STD_MOD(MOD_1, reload, NULL, NULL);

Generated on Mon Mar 31 07:37:54 2008 for Asterisk - the Open Source PBX by  doxygen 1.5.1