00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
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++;
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++;
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++;
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 }