src/rtpsignaltable.c

00001 /*
00002   The oRTP library is an RTP (Realtime Transport Protocol - rfc1889) stack.
00003   Copyright (C) 2001  Simon MORLAT simon.morlat@linphone.org
00004 
00005   This library is free software; you can redistribute it and/or
00006   modify it under the terms of the GNU Lesser General Public
00007   License as published by the Free Software Foundation; either
00008   version 2.1 of the License, or (at your option) any later version.
00009 
00010   This library is distributed in the hope that it will be useful,
00011   but WITHOUT ANY WARRANTY; without even the implied warranty of
00012   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00013   Lesser General Public License for more details.
00014 
00015   You should have received a copy of the GNU Lesser General Public
00016   License along with this library; if not, write to the Free Software
00017   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00018 */
00019 
00020 
00021 
00022 #include <ortp/rtpsession.h>
00023 #include "utils.h"
00024 
00025 
00026 void rtp_signal_table_init(RtpSignalTable *table,RtpSession *session, const char *signal_name)
00027 {
00028         memset(table,0,sizeof(RtpSignalTable));
00029         table->session=session;
00030         table->signal_name=signal_name;
00031         session->signal_tables=o_list_append(session->signal_tables,(void*)table);
00032 }
00033 
00034 int rtp_signal_table_add(RtpSignalTable *table,RtpCallback cb, unsigned long user_data)
00035 {
00036         int i;
00037         
00038         for (i=0;i<RTP_CALLBACK_TABLE_MAX_ENTRIES;i++){
00039                 if (table->callback[i]==NULL){
00040                         table->callback[i]=cb;
00041                         table->user_data[i]=user_data;
00042                         table->count++;
00043                         return 0;
00044                 }
00045         }
00046         return -1;
00047 }
00048 
00049 void rtp_signal_table_emit(RtpSignalTable *table)
00050 {
00051         int i,c;
00052         
00053         for (i=0,c=0;c<table->count;i++){
00054                 if (table->callback[i]!=NULL){
00055                         c++;    /*I like it*/
00056                         table->callback[i](table->session,table->user_data[i]);
00057                 }
00058         }
00059 }
00060 
00061 void rtp_signal_table_emit2(RtpSignalTable *table,unsigned long arg)
00062 {
00063         int i,c;
00064         
00065         for (i=0,c=0;c<table->count;i++){
00066                 if (table->callback[i]!=NULL){
00067                         c++;    /*I like it*/
00068                         table->callback[i](table->session,arg,table->user_data[i]);
00069                 }
00070         }
00071 }
00072 
00073 void rtp_signal_table_emit3(RtpSignalTable *table, unsigned long arg1, unsigned long arg2)
00074 {
00075         int i,c;
00076         
00077         for (i=0,c=0;c<table->count;i++){
00078                 if (table->callback[i]!=NULL){
00079                         c++;    /*I like it*/
00080                         table->callback[i](table->session,arg1,arg2,table->user_data[i]);
00081                 }
00082         }
00083 }
00084 
00085 int rtp_signal_table_remove_by_callback(RtpSignalTable *table,RtpCallback cb)
00086 {
00087         int i;
00088         
00089         for (i=0;i<RTP_CALLBACK_TABLE_MAX_ENTRIES;i++){
00090                 if (table->callback[i]==cb){
00091                         table->callback[i]=NULL;
00092                         table->user_data[i]=0;
00093                         table->count--;
00094                         return 0;
00095                 }
00096         }
00097         return -1;
00098 }

Generated on Fri Feb 15 00:08:47 2008 for oRTP by  doxygen 1.5.4