Fri Aug 24 02:22:10 2007

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  *
00012  * Klaus-Peter Junghanns <kapejod@ns1.jnetdns.de>
00013  *
00014  * Video Conferencing support added by 
00015  * Neil Stratford <neils@vipadia.com>
00016  * Copyright (C) 2005, 2005 Vipadia Limited
00017  *
00018  * This program may be modified and distributed under the 
00019  * terms of the GNU Public License.
00020  *
00021  */
00022 /*** MODULEINFO
00023       <depend>speex</depend>
00024 ***/
00025 
00026 #include "asterisk/autoconfig.h"
00027 #include "app_conference.h"
00028 #include "common.h"
00029 #include "asterisk/module.h"
00030 
00031 /*
00032 
00033 a conference has n + 1 threads, where n is the number of 
00034 members and 1 is a conference thread which sends audio
00035 back to the members. 
00036 
00037 each member thread reads frames from the channel and
00038 add's them to the member's frame queue. 
00039 
00040 the conference thread reads frames from each speaking members
00041 queue, mixes them, and then re-queues them for the member thread
00042 to send back to the user.
00043 
00044 */
00045 
00046 //
00047 // app_conference text descriptions
00048 //
00049 
00050 static char *app = "Conference" ;
00051 static char *synopsis = "Channel Independent Conference" ;
00052 static char *descrip = "  Conference():  returns 0\n"
00053 "if the user exits with the '#' key, or -1 if the user hangs up.\n" ;
00054 
00055 //
00056 // functions defined in asterisk/module.h
00057 //
00058 
00059 
00060 static int unload_module( void *mod )
00061 {
00062    ast_log( LOG_NOTICE, "unloading app_conference module\n" ) ;
00063 
00064    ast_module_user_hangup_all();
00065    //STANDARD_HANGUP_LOCALUSERS ; // defined in asterisk/module.h
00066 
00067    // register conference cli functions
00068    unregister_conference_cli() ;
00069 
00070    return ast_unregister_application( app ) ;
00071 }
00072 
00073 static int load_module( void *mod )
00074 {
00075    ast_log( LOG_NOTICE, "loading app_conference module [ $Revision: 693 $ ]\n" ) ;
00076 
00077    // intialize conference
00078    init_conference() ;
00079 
00080    // register conference cli functions
00081    register_conference_cli() ;
00082 
00083    return ast_register_application( app, app_conference_main, synopsis, descrip ) ;
00084 }
00085 
00086 //
00087 // main app_conference function
00088 //
00089 
00090 int app_conference_main( struct ast_channel* chan, void* data ) 
00091 {
00092    int res = 0 ;
00093    struct ast_module_user *u ;
00094    
00095    // defined in asterisk/module.h
00096    //LOCAL_USER_ADD( u ) ; 
00097    u = ast_module_user_add(chan);
00098 
00099    // call member thread function
00100    res = member_exec( chan, data ) ;
00101 
00102    // defined in asterisk/module.h
00103    //LOCAL_USER_REMOVE( u ) ;
00104    ast_module_user_remove (u);
00105 
00106    return res ;
00107 }
00108 
00109 //
00110 // utility functions
00111 //
00112 
00113 // now returns milliseconds
00114 long usecdiff( struct timeval* timeA, struct timeval* timeB )
00115 {
00116    long a_secs = timeA->tv_sec - timeB->tv_sec ;
00117    long b_secs = (long)( timeA->tv_usec / 1000 ) - (long)( timeB->tv_usec / 1000 ) ;
00118    long u_secs = ( a_secs * 1000 ) + b_secs ;
00119    return u_secs ;
00120 }
00121 
00122 // increment a timeval by ms milliseconds
00123 void add_milliseconds( struct timeval* tv, long ms )
00124 {
00125    // add the microseconds to the microseconds field
00126    tv->tv_usec += ( ms * 1000 ) ;
00127 
00128    // calculate the number of seconds to increment
00129    long s = ( tv->tv_usec / 1000000 ) ;
00130 
00131    // adjust the microsends field
00132    if ( s > 0 ) tv->tv_usec -= ( s * 1000000 ) ;
00133 
00134    // increment the seconds field
00135    tv->tv_sec += s ;
00136 
00137    return ;
00138 }
00139 
00140 AST_MODULE_INFO_STANDARD(ASTERISK_GPL_KEY, "Conference");
00141 

Generated on Fri Aug 24 02:22:10 2007 for Asterisk - the Open Source PBX by  doxygen 1.5.1