[Freeswitch-branches] [commit] r1763 - in freeswitch/branches/mishehu: . src src/mod/codecs/mod_l16 src/mod/loggers/mod_cdr
Freeswitch SVN
mishehu at freeswitch.org
Thu Jul 6 02:19:22 EDT 2006
Author: mishehu
Date: Thu Jul 6 02:19:21 2006
New Revision: 1763
Added:
freeswitch/branches/mishehu/fsxs.in
- copied unchanged from r1762, /freeswitch/trunk/fsxs.in
Modified:
freeswitch/branches/mishehu/Makefile.am
freeswitch/branches/mishehu/src/mod/codecs/mod_l16/mod_l16.c
freeswitch/branches/mishehu/src/mod/loggers/mod_cdr/basecdr.cpp
freeswitch/branches/mishehu/src/mod/loggers/mod_cdr/basecdr.h
freeswitch/branches/mishehu/src/mod/loggers/mod_cdr/mysqlcdr.cpp
freeswitch/branches/mishehu/src/mod/loggers/mod_cdr/mysqlcdr.h
freeswitch/branches/mishehu/src/switch_core.c
Log:
Yes, MysqlCDR works, including the fixed channel variables! Now I need to check to see if anything else can be cleaned up, and implement reloading, and possibly MysqlCDR::temp_dump() method.
Modified: freeswitch/branches/mishehu/Makefile.am
==============================================================================
--- freeswitch/branches/mishehu/Makefile.am (original)
+++ freeswitch/branches/mishehu/Makefile.am Thu Jul 6 02:19:21 2006
@@ -1,3 +1,5 @@
+
+
EXTRA_DIST =
SUBDIRS =
AUTOMAKE_OPTS = gnu foreign
@@ -122,7 +124,7 @@
src/include/switch_xml.h
BUILT_SOURCES = version depends
-CLEANFILES = src/include/switch_version.h
+CLEANFILES = src/include/switch_version.h fsxs
lib_LTLIBRARIES = libfreeswitch.la
@@ -132,6 +134,7 @@
nodist_libfreeswitch_la_SOURCES = src/include/switch_version.h
bin_PROGRAMS = freeswitch
+bin_SCRIPTS = fsxs
freeswitch_SOURCES = src/switch.c\
src/include/switch_version.h
freeswitch_CFLAGS = $(AM_CFLAGS)
@@ -230,6 +233,27 @@
dox:
cd docs && doxygen $(PWD)/docs/Doxygen.conf
+
+fsxs: fsxs.in
+ @echo creating fsxs
+ @sed -e "s, at MODULES_DIR\@,$(PREFIX)/mod," \
+ -e "s, at LIB_DIR\@,$(PREFIX)/lib," \
+ -e "s, at BIN_DIR\@,$(PREFIX)/bin," \
+ -e "s, at INC_DIR\@,$(PREFIX)/include," \
+ -e "s, at CFG_DIR\@,$(PREFIX)/conf," \
+ -e "s, at DB_DIR\@,$(PREFIX)/db," \
+ -e "s, at PREFIX\@,$(PREFIX)," \
+ -e "s, at CC\@,$(CC)," \
+ -e "s, at LD\@,$(CC)," \
+ -e "s, at INSTALL\@,$(INSTALL)," \
+ -e "s, at MKINSTALLDIRS\@,$(mkdir_p)," \
+ \
+ -e "s|@CFLAGS\@|$(CFLAGS) -fPIC $(shell $(APR_CONFIG) --cflags --cppflags)|" \
+ -e "s|@INCLUDES\@|-I$(PREFIX)/include $(shell $(APR_CONFIG) --includes) $(shell $(APU_CONFIG) --includes)|" \
+ -e "s|@SOLINK\@|$(SOLINK)|" \
+ -e "s|@LDFLAGS\@|-L$(PREFIX)/lib|" \
+ -e "s|@LIBS\@|-lfreeswitch|" \
+ fsxs.in > fsxs
eclean: clean
rm -f `find . -type f -name \*~`
Modified: freeswitch/branches/mishehu/src/mod/codecs/mod_l16/mod_l16.c
==============================================================================
--- freeswitch/branches/mishehu/src/mod/codecs/mod_l16/mod_l16.c (original)
+++ freeswitch/branches/mishehu/src/mod/codecs/mod_l16/mod_l16.c Thu Jul 6 02:19:21 2006
@@ -185,10 +185,49 @@
};
+static const switch_codec_implementation_t raw_8k_60ms_implementation = {
+ /*.ianacode */ 10,
+ /*.iananame */ "L16",
+ /*.samples_per_second */ 8000,
+ /*.bits_per_second */ 256000,
+ /*.microseconds_per_frame */ 60000,
+ /*.samples_per_frame */ 480,
+ /*.bytes_per_frame */ 960,
+ /*.encoded_bytes_per_frame */ 960,
+ /*.number_of_channels */ 1,
+ /*.pref_frames_per_packet */ 1,
+ /*.max_frames_per_packet */ 1,
+ /*.init */ switch_raw_init,
+ /*.encode */ switch_raw_encode,
+ /*.decode */ switch_raw_decode,
+ /*.destroy */ switch_raw_destroy,
+ /*.next */ &raw_8k_30ms_implementation
+};
+
+static const switch_codec_implementation_t raw_8k_120ms_implementation = {
+ /*.ianacode */ 10,
+ /*.iananame */ "L16",
+ /*.samples_per_second */ 8000,
+ /*.bits_per_second */ 512000,
+ /*.microseconds_per_frame */ 120000,
+ /*.samples_per_frame */ 960,
+ /*.bytes_per_frame */ 1920,
+ /*.encoded_bytes_per_frame */ 1920,
+ /*.number_of_channels */ 1,
+ /*.pref_frames_per_packet */ 1,
+ /*.max_frames_per_packet */ 1,
+ /*.init */ switch_raw_init,
+ /*.encode */ switch_raw_encode,
+ /*.decode */ switch_raw_decode,
+ /*.destroy */ switch_raw_destroy,
+ /*.next */ &raw_8k_60ms_implementation
+};
+
+
static const switch_codec_interface_t raw_codec_interface = {
/*.interface_name */ "raw signed linear (16 bit)",
/*.codec_type */ SWITCH_CODEC_TYPE_AUDIO,
- /*.implementations */ &raw_8k_30ms_implementation
+ /*.implementations */ &raw_8k_120ms_implementation
};
static switch_loadable_module_interface_t raw_module_interface = {
Modified: freeswitch/branches/mishehu/src/mod/loggers/mod_cdr/basecdr.cpp
==============================================================================
--- freeswitch/branches/mishehu/src/mod/loggers/mod_cdr/basecdr.cpp (original)
+++ freeswitch/branches/mishehu/src/mod/loggers/mod_cdr/basecdr.cpp Thu Jul 6 02:19:21 2006
@@ -193,52 +193,69 @@
}
}
-void BaseCDR::parse_channel_variables_xconfig(std::string& unparsed,std::list<std::string>& chanvarlist,std::string& chanvars_fixed_types)
+void BaseCDR::parse_channel_variables_xconfig(std::string& unparsed,std::list<std::string>& chanvarlist,std::vector<switch_mod_cdr_sql_types>& chanvars_fixed_types)
{
bool fixed = 1;
- std::string tempstring;
- std::string sql_type;
+ std::string tempstring, tempstring2;
+ switch_mod_cdr_sql_types sql_type;
parse_channel_variables_xconfig(unparsed,chanvarlist,fixed);
- std::list<std::string> tempchanvarlist = chanvarlist;
+ std::list<std::string> tempchanvarlist; // = chanvarlist;
std::list<std::string>::iterator iEnd, iItr;
for(iItr = chanvarlist.begin(), iEnd = chanvarlist.end() ; iItr != iEnd ; iItr++)
{
- long j = 0;
- for(std::string::size_type i = 0; j != -1; )
+ sql_type = CDR_STRING;
+ std::string::size_type i = 0, j = 0;
+ j = iItr->find('=',i);
+ if(j > 0 )
{
- j = iItr->find('=',i);
- if(j > 0 )
+ tempstring = iItr->substr(i,(j-i));
+ i =j+1;
+ tempstring2 = iItr->substr(i);
+ if(tempstring2.size() == 1)
{
- tempstring = iItr->substr(i,(j-i));
- i =j+1;
- sql_type = iItr->substr(i);
- if(sql_type.size() == 0)
+ switch(tempstring2[0])
{
- switch_console_printf(SWITCH_CHANNEL_LOG,"For channel variable %s, using default type of string.\n",tempstring.c_str());
- sql_type = "s";
+ case 'I':
+ case 'i':
+ sql_type = CDR_INTEGER;
+ break;
+ case 'S':
+ case 's':
+ sql_type = CDR_STRING;
+ break;
+ case 'D':
+ case 'd':
+ sql_type = CDR_DOUBLE;
+ break;
+ case 'T':
+ case 't':
+ sql_type = CDR_TINY;
+ break;
+ default:
+ switch_console_printf(SWITCH_CHANNEL_LOG,"Valid fixed channel variable types are x (decimal), d (double), i (integer), t (tiny), s (string). You tried to give a type of %s to chanvar %s.\nReverting this chanvar type to a string type.\n",tempstring2.c_str(),tempstring.c_str());
+ sql_type = CDR_STRING;
}
- if((sql_type != "i" && sql_type == "s" && sql_type != "d" && sql_type != "x" && sql_type != "t") || sql_type.size() > 1)
- {
- const char *tempstring_cstr = tempstring.c_str();
- const char *temp_sql_type = sql_type.c_str();
- switch_console_printf(SWITCH_CHANNEL_LOG,"Valid fixed channel variable types are x (decimal), d (double), i (integer), t (tiny), s (string). You tried to give a type of %s to chanvar %s.\nReverting this chanvar type to a string type.\n",tempstring_cstr,temp_sql_type);
- sql_type = "s";
- }
}
else
{
- switch_console_printf(SWITCH_CHANNEL_LOG,"For channel variable %s, using default type of string.\n",iItr->c_str());
- sql_type = "s";
+ switch_console_printf(SWITCH_CHANNEL_LOG,"Valid fixed channel variable types are x (decimal), d (double), i (integer), t (tiny), s (string). You tried to give a type of %s to chanvar %s.\nReverting this chanvar type to a string type.\n",tempstring2.c_str(),tempstring.c_str());
+ sql_type = CDR_STRING;
}
-
- tempchanvarlist.push_back(tempstring);
- chanvars_fixed_types.append(sql_type);
}
+ else
+ {
+ switch_console_printf(SWITCH_CHANNEL_LOG,"No parameter set, for channel variable %s, using default type of string.\n",iItr->c_str());
+ sql_type = CDR_STRING;
+ tempstring = *iItr;
+ }
+
+ tempchanvarlist.push_back(tempstring);
+ chanvars_fixed_types.push_back(sql_type);
}
+
chanvarlist.clear();
chanvarlist = tempchanvarlist;
-
}
// This is for processing the fixed channel variables
@@ -246,7 +263,7 @@
{
std::list<std::string>::const_iterator iItr,iEnd;
iEnd = stringlist.end();
-
+
for(iItr = stringlist.begin(); iItr != iEnd; iItr++)
{
std::vector<char> tempstringvector(iItr->begin(), iItr->end());
@@ -256,14 +273,14 @@
char *tempvariable;
tempvariable = switch_channel_get_variable(channel,tempstring);
- std::pair<std::string,std::string> temppair;
- temppair.first = *iItr;
if(tempvariable != 0)
+ {
+ std::pair<std::string,std::string> temppair;
+ temppair.first = *iItr;
temppair.second = tempvariable;
-
- chanvars_fixed.push_back(temppair);
- }
-
+ chanvars_fixed.push_back(temppair);
+ }
+ }
}
// This one is for processing of supplemental chanvars
Modified: freeswitch/branches/mishehu/src/mod/loggers/mod_cdr/basecdr.h
==============================================================================
--- freeswitch/branches/mishehu/src/mod/loggers/mod_cdr/basecdr.h (original)
+++ freeswitch/branches/mishehu/src/mod/loggers/mod_cdr/basecdr.h Thu Jul 6 02:19:21 2006
@@ -34,6 +34,7 @@
bool originate;
};
+enum switch_mod_cdr_sql_types { CDR_INTEGER,CDR_STRING,CDR_DECIMAL,CDR_DOUBLE,CDR_TINY };
class BaseCDR {
public:
@@ -49,7 +50,7 @@
virtual void reread_tempdumped_records() = 0;
protected:
void parse_channel_variables_xconfig(std::string& unparsed,std::list<std::string>& chanvarslist,bool fixed);
- void parse_channel_variables_xconfig(std::string& unparsed,std::list<std::string>& chanvarslist,std::string& chanvars_fixed_types); // Typically used for SQL types
+ void parse_channel_variables_xconfig(std::string& unparsed,std::list<std::string>& chanvarslist,std::vector<switch_mod_cdr_sql_types>& chanvars_fixed_types); // Typically used for SQL types
void process_channel_variables(const std::list<std::string>& stringlist,const std::list<std::string>& fixedlist,switch_channel_t *channel,bool repeat = 1); //This is used for supplemental chanvars
void process_channel_variables(const std::list<std::string>& stringlist,switch_channel_t *channel); // This is used for fixed chanvars
switch_time_t callstartdate;
Modified: freeswitch/branches/mishehu/src/mod/loggers/mod_cdr/mysqlcdr.cpp
==============================================================================
--- freeswitch/branches/mishehu/src/mod/loggers/mod_cdr/mysqlcdr.cpp (original)
+++ freeswitch/branches/mishehu/src/mod/loggers/mod_cdr/mysqlcdr.cpp Thu Jul 6 02:19:21 2006
@@ -31,9 +31,6 @@
if(chanvars_supp_list.size() > 0)
process_channel_variables(chanvars_supp_list,chanvars_fixed_list,newchannel->channel,repeat_fixed_in_supp);
-
-
- process_channel_variables(chanvars_fixed_list,newchannel->channel);
}
}
@@ -47,7 +44,7 @@
bool MysqlCDR::repeat_fixed_in_supp = 0;
std::list<std::string> MysqlCDR::chanvars_fixed_list;
std::list<std::string> MysqlCDR::chanvars_supp_list;
-std::string MysqlCDR::chanvars_fixed_types;
+std::vector<switch_mod_cdr_sql_types> MysqlCDR::chanvars_fixed_types;
bool MysqlCDR::activated = 0;
char* MysqlCDR::sql_query = 0;
std::string MysqlCDR::tmp_sql_query;
@@ -115,7 +112,6 @@
unparsed = val;
if(unparsed.size() > 0)
{
- std::cout << std::endl << "Shall we parse the fixed chanvars list for MysqlCDR?" << std::endl;
parse_channel_variables_xconfig(unparsed,chanvars_fixed_list,chanvars_fixed_types);
//logchanvars=1;
}
@@ -127,7 +123,6 @@
std::string unparsed = val;
bool fixed = 0;
logchanvars = 1;
- std::cout << std::endl << "Shall we parse the supplementary chanvars list for MysqlCDR?" << std::endl;
parse_channel_variables_xconfig(unparsed,chanvars_supp_list,fixed);
}
}
@@ -150,13 +145,20 @@
if(activated)
{
tmp_sql_query = "INSERT INTO freeswitchcdr (callstartdate,callanswerdate,callenddate,originated,clid,src,dst,ani,ani2,dialplan,myuuid,destuuid,srcchannel,dstchannel,lastapp,lastdata,billusec,disposition,hangupcause,amaflags";
+
+ int items_appended = 0;
+
if(chanvars_fixed_list.size() > 0 )
{
std::list<std::string>::iterator iItr, iEnd;
for(iItr = chanvars_fixed_list.begin(), iEnd = chanvars_fixed_list.end(); iItr != iEnd; iItr++)
{
- tmp_sql_query.append(",");
- tmp_sql_query.append(*iItr);
+ if(iItr->size() > 0)
+ {
+ tmp_sql_query.append(",");
+ tmp_sql_query.append(*iItr);
+ items_appended++;
+ }
}
}
@@ -164,7 +166,7 @@
if(chanvars_fixed_list.size() > 0 )
{
- for(switch_size_t i = 0; i < chanvars_fixed_list.size(); i++)
+ for(int i = 0; i < items_appended; i++)
tmp_sql_query.append(",?");
}
@@ -294,66 +296,75 @@
switch_size_t i = 0; // temporary variable, i is current spot on the string of types
std::list<std::pair<std::string,std::string> >::iterator iItr, iEnd;
for(iItr = chanvars_fixed.begin(), iEnd = chanvars_fixed.end(); iItr != iEnd; iItr++)
- {
- if(chanvars_fixed_types[i] == 'i')
+ {
+ switch(chanvars_fixed_types[i])
{
- int x;
- x = 0;
- bool is_null = 0;
- if(iItr->second.size() > 0)
+ case CDR_INTEGER:
{
- std::istringstream istring(iItr->second);
- istring >> x;
+ int* x = new int;
+ *x = 0;
+ bool is_null = 0;
+ if(iItr->second.size() > 0)
+ {
+ std::istringstream istring(iItr->second);
+ istring >> *x;
+ }
+ else
+ is_null = 1;
+ temp_chanvars_holder.push_back(x);
+ add_parameter(*x,MYSQL_TYPE_LONG,is_null);
+ break;
}
- else
- is_null = 1;
- temp_chanvars_holder.push_back(&x);
- add_parameter(x,MYSQL_TYPE_LONG,is_null);
- }
- else if(chanvars_fixed_types[i] == 'd')
- {
- double x;
- x = 0;
- bool is_null = 0;
- if(iItr->second.size() > 0)
+ case CDR_DOUBLE:
{
- std::istringstream istring(iItr->second);
- istring >> x;
+ double* x = new double;
+ *x = 0;
+ bool is_null = 0;
+ if(iItr->second.size() > 0)
+ {
+ std::istringstream istring(iItr->second);
+ istring >> *x;
+ }
+ else
+ is_null = 1;
+ temp_chanvars_holder.push_back(x);
+ add_parameter(*x,MYSQL_TYPE_DOUBLE,is_null);
+ break;
}
- else
- is_null = 1;
- temp_chanvars_holder.push_back(&x);
- add_parameter(x,MYSQL_TYPE_DOUBLE,is_null);
- }
- else if(chanvars_fixed_types[i] == 't')
- {
- short x;
- x = 0;
- bool is_null = 0;
- if(iItr->second.size() > 0)
+ case CDR_TINY:
{
- std::istringstream istring(iItr->second);
- istring >> x;
+ short* x = new short;
+ *x = 0;
+ bool is_null = 0;
+ if(iItr->second.size() > 0)
+ {
+ std::istringstream istring(iItr->second);
+ istring >> *x;
+ }
+ else
+ is_null = 1;
+ temp_chanvars_holder.push_back(x);
+ add_parameter(*x,MYSQL_TYPE_TINY,is_null);
+ break;
}
- else
- is_null = 1;
- temp_chanvars_holder.push_back(&x);
- add_parameter(x,MYSQL_TYPE_TINY,is_null);
- }
- else if(chanvars_fixed_types[i] == 's' || chanvars_fixed_types[i] == 'x')
- {
- long unsigned int stringlength = iItr->second.size();
- char x[(stringlength+1)];
- strncpy(x,iItr->second.c_str(),stringlength);
+ case CDR_STRING:
+ case CDR_DECIMAL:
+ {
+ long unsigned int* stringlength = new long unsigned int;
+ *stringlength = iItr->second.size();
- temp_chanvars_holder.push_back(&stringlength);
- temp_chanvars_holder.push_back(&x);
- if(chanvars_fixed_types[i] == 's')
- add_string_parameter(x,stringlength,MYSQL_TYPE_VAR_STRING,0);
- else
- add_string_parameter(x,stringlength,MYSQL_TYPE_DECIMAL,0);
+ char* x = new char[(*stringlength+1)];
+ strncpy(x,iItr->second.c_str(),*stringlength);
+
+ add_string_parameter(x,*stringlength,MYSQL_TYPE_VAR_STRING,0);
+
+ temp_chanvars_holder.push_back(stringlength);
+ temp_chanvars_holder.push_back(x);
+ break;
+ }
+ default:
+ switch_console_printf(SWITCH_CHANNEL_LOG,"We should not get to this point in this switch/case statement.\n");
}
-
i++;
}
}
@@ -433,8 +444,50 @@
*/
delete [] bindmetemp;
- temp_chanvars_holder.clear();
-
+ if(temp_chanvars_holder.size() > 0)
+ {
+ std::string::size_type i = 0, j = chanvars_fixed_types.size();
+ for(; i < j ; i++)
+ {
+ switch(chanvars_fixed_types[i])
+ {
+ case CDR_STRING:
+ case CDR_DECIMAL:
+ {
+ long unsigned int* stringlength = (long unsigned int*)temp_chanvars_holder.front();
+ temp_chanvars_holder.pop_front();
+ delete stringlength;
+ char* tempstring = (char*) temp_chanvars_holder.front();
+ temp_chanvars_holder.pop_front();
+ delete [] tempstring;
+ break;
+ }
+ case CDR_INTEGER:
+ {
+ int* tempint = (int*) temp_chanvars_holder.front();
+ temp_chanvars_holder.pop_front();
+ delete tempint;
+ break;
+ }
+ case CDR_DOUBLE:
+ {
+ double* tempdouble = (double*) temp_chanvars_holder.front();
+ temp_chanvars_holder.pop_front();
+ delete tempdouble;
+ break;
+ }
+ case CDR_TINY:
+ {
+ short* tempshort = (short*) temp_chanvars_holder.front();
+ temp_chanvars_holder.pop_front();
+ delete tempshort;
+ break;
+ }
+ default:
+ switch_console_printf(SWITCH_CHANNEL_LOG,"We should not get to this point in this switch/case statement.\n");
+ }
+ }
+ }
return 1;
}
Modified: freeswitch/branches/mishehu/src/mod/loggers/mod_cdr/mysqlcdr.h
==============================================================================
--- freeswitch/branches/mishehu/src/mod/loggers/mod_cdr/mysqlcdr.h (original)
+++ freeswitch/branches/mishehu/src/mod/loggers/mod_cdr/mysqlcdr.h Thu Jul 6 02:19:21 2006
@@ -30,7 +30,7 @@
static bool connectionstate;
static bool logchanvars;
static std::list<std::string> chanvars_fixed_list;
- static std::string chanvars_fixed_types;
+ static std::vector<switch_mod_cdr_sql_types> chanvars_fixed_types;
static std::list<std::string> chanvars_supp_list; // The supplemental list
static bool repeat_fixed_in_supp;
static char hostname[255];
Modified: freeswitch/branches/mishehu/src/switch_core.c
==============================================================================
--- freeswitch/branches/mishehu/src/switch_core.c (original)
+++ freeswitch/branches/mishehu/src/switch_core.c Thu Jul 6 02:19:21 2006
@@ -370,7 +370,7 @@
return SWITCH_STATUS_SUCCESS;
} else {
- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "Codec %s Exists but not then desired implementation.\n",
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "Codec %s Exists but not at the desired implementation.\n",
codec_name);
}
More information about the Freeswitch-branches
mailing list