[Freeswitch-svn] [commit] r3516 - freeswitch/branches/mishehu/src/mod/event_handlers/mod_cdr

Freeswitch SVN mishehu at freeswitch.org
Sat Dec 2 03:08:12 EST 2006


Author: mishehu
Date: Sat Dec  2 03:08:12 2006
New Revision: 3516

Modified:
   freeswitch/branches/mishehu/src/mod/event_handlers/mod_cdr/basecdr.cpp
   freeswitch/branches/mishehu/src/mod/event_handlers/mod_cdr/basecdr.h
   freeswitch/branches/mishehu/src/mod/event_handlers/mod_cdr/mod_cdr.cpp

Log:
Fixed up mod_cdr so at least it compiles.  Am getting a segfault because switch_channel_t::caller_extension seems to be coming back null for some reason even on normal bridged calls.

Modified: freeswitch/branches/mishehu/src/mod/event_handlers/mod_cdr/basecdr.cpp
==============================================================================
--- freeswitch/branches/mishehu/src/mod/event_handlers/mod_cdr/basecdr.cpp	(original)
+++ freeswitch/branches/mishehu/src/mod/event_handlers/mod_cdr/basecdr.cpp	Sat Dec  2 03:08:12 2006
@@ -77,16 +77,17 @@
 		memset(lastapp,0,80);
 		memset(lastdata,0,255);
 		
-		switch_channel_timetable_t *timetable;
+		// switch_channel_timetable_t *timetable = switch_channel_get_timetable(newchannel->channel->caller_profile);
 		
 		coresession = newchannel->session;
-		timetable = switch_channel_get_timetable(newchannel->channel->caller_profile);
-		callstartdate= timetable->created;
-		callanswerdate = timetable->answered;
-		callenddate = timetable->hungup;
 	
 		if (newchannel->callerprofile)
 		{
+			callstartdate= newchannel->callerprofile->times->created;
+			callanswerdate = newchannel->callerprofile->times->answered;
+			calltransferdate = newchannel->callerprofile->times->transferred;
+			callenddate = newchannel->callerprofile->times->hungup;
+
 			if(newchannel->callerprofile->caller_id_name != 0)
 			{
 				strncpy(clid,newchannel->callerprofile->caller_id_name,strlen(newchannel->callerprofile->caller_id_name));
@@ -109,14 +110,14 @@
 				strncpy(network_addr,newchannel->callerprofile->network_addr,strlen(newchannel->callerprofile->network_addr));
 		}
 		
-		switch_caller_profile_t *originateprofile = switch_channel_get_originator_caller_profile(newchannel->channel->callerprofile);
+		//switch_caller_profile_t *originateprofile = switch_channel_get_originator_caller_profile(newchannel->channel->callerprofile);
 		
 		// Were we the receiver of the call?
-		if(originateprofile)
+		if(newchannel->callerprofile->originator_caller_profile)
 		{
 			originated = 0;
-			if(newchannel->originateprofile->uuid != 0)
-				strncpy(destuuid,originateprofile->uuid,strlen(originateprofile->uuid));
+			if(newchannel->callerprofile->originator_caller_profile->uuid != 0)
+				strncpy(destuuid,newchannel->callerprofile->originator_caller_profile->uuid,strlen(newchannel->callerprofile->originator_caller_profile->uuid));
 			if(newchannel->callerprofile)
 			{
 				if(newchannel->callerprofile->destination_number)
@@ -127,9 +128,9 @@
 		}
 		else
 		{
-			originateprofile = switch_channel_get_originatee_profile(newchannel->channel->callerprofile);
+			//originateprofile = switch_channel_get_originatee_profile(newchannel->channel->callerprofile);
 			// Or were we maybe we were the caller?
-			if(originateprofile)
+			if(newchannel->callerprofile->originatee_caller_profile)
 			{
 				originated = 1;
 				if (newchannel->callerprofile) {
@@ -138,8 +139,8 @@
 					if(newchannel->callerprofile->destination_number != 0)
 						strncpy(dst,newchannel->callerprofile->destination_number,strlen(newchannel->callerprofile->destination_number));
 				}
-				if(originateprofile->chan_name != 0)
-					strncpy(dstchannel,newchannel->originateprofile->chan_name,strlen(newchannel->originateprofile->chan_name));
+				if(newchannel->callerprofile->originatee_caller_profile->chan_name != 0)
+					strncpy(dstchannel,newchannel->callerprofile->originatee_caller_profile->chan_name,strlen(newchannel->callerprofile->originatee_caller_profile->chan_name));
 			}
 		}
 		
@@ -149,7 +150,15 @@
 		if(switch_channel_test_flag(newchannel->channel,CF_ANSWERED))
 		{
 			disposition=1;
-			billusec = timetable->hungup - timetable->answered;
+			if(callstartdate)
+				billusec = callenddate - callanswerdate;
+			else
+				billusec = callenddate - calltransferdate;
+		}
+		else if(switch_channel_test_flag(newchannel->channel,CF_TRANSFER))
+		{
+			disposition=1;
+			billusec = callenddate - calltransferdate;
 		}
 		else
 		{

Modified: freeswitch/branches/mishehu/src/mod/event_handlers/mod_cdr/basecdr.h
==============================================================================
--- freeswitch/branches/mishehu/src/mod/event_handlers/mod_cdr/basecdr.h	(original)
+++ freeswitch/branches/mishehu/src/mod/event_handlers/mod_cdr/basecdr.h	Sat Dec  2 03:08:12 2006
@@ -78,6 +78,7 @@
 		switch_time_t callstartdate;
 		switch_time_t callanswerdate;
 		switch_time_t callenddate;
+		switch_time_t calltransferdate;
 		switch_call_cause_t hangupcause;
 		char *hangupcause_text;
 		char clid[80];

Modified: freeswitch/branches/mishehu/src/mod/event_handlers/mod_cdr/mod_cdr.cpp
==============================================================================
--- freeswitch/branches/mishehu/src/mod/event_handlers/mod_cdr/mod_cdr.cpp	(original)
+++ freeswitch/branches/mishehu/src/mod/event_handlers/mod_cdr/mod_cdr.cpp	Sat Dec  2 03:08:12 2006
@@ -45,6 +45,8 @@
 static switch_memory_pool_t *module_pool;
 static switch_status_t my_on_hangup(switch_core_session_t *session);
 static switch_status_t modcdr_reload(char *dest, switch_core_session_t *isession, switch_stream_handle_t *stream);
+static switch_status_t modcdr_queue_pause(char *dest, switch_core_session_t *isession, switch_stream_handle_t *stream);
+static switch_status_t modcdr_queue_resume(char *dest, switch_core_session_t *isession, switch_stream_handle_t *stream);
 static switch_thread_rwlock_t *cdr_rwlock;
 
 /* Now begins the glue that will tie this into the system.
@@ -59,28 +61,28 @@
 	/*.on_transmit */ NULL
 };
 
-static switch_api_interface_t modcdr_reload_interface = {
-	/*.interface_name */ "modcdr_reload",
-	/*.desc */ "Reload mod_cdr's configuration",
-	/*.function */ modcdr_reload,
-	/*.syntax */ "modcdr_reload",
-	/*.next */ &modcdr_queue_pause
+static switch_api_interface_t modcdr_queue_resume_api = {
+	/*.interface_name */ "modcdr_queue_resume",
+	/*.desc */ "Manually resumes the popping of objects from the queue.",
+	/*.function */ modcdr_queue_resume,
+	/*.syntax */ "modcdr_queue_resume",
+	/*.next */ 0
 };
 
-static switch_api_interface_t modcdr_queue_pause = {
+static switch_api_interface_t modcdr_queue_pause_api = {
 	/*.interface_name */ "modcdr_queue_pause",
 	/*.desc */ "Manually pauses the popping of objects from the queue. (DANGER: Can suck your memory away rather quickly.)",
 	/*.function */ modcdr_queue_pause,
 	/*.syntax */ "modcdr_queue_pause",
-	/*.next */ &modcdr_queue_resume
+	/*.next */ &modcdr_queue_resume_api
 };
 
-static switch_api_interface_t modcdr_queue_resume = {
-	/*.interface_name */ "modcdr_queue_pause",
-	/*.desc */ "Manually resumes the popping of objects from the queue.",
-	/*.function */ modcdr_queue_resume,
-	/*.syntax */ "modcdr_queue_resume",
-	/*.next */ 0
+static switch_api_interface_t modcdr_reload_interface_api = {
+	/*.interface_name */ "modcdr_reload",
+	/*.desc */ "Reload mod_cdr's configuration",
+	/*.function */ modcdr_reload,
+	/*.syntax */ "modcdr_reload",
+	/*.next */ &modcdr_queue_pause_api
 };
 
 static const switch_loadable_module_interface_t cdr_module_interface = {
@@ -90,7 +92,7 @@
 	/*.dialplan_interface */ NULL,
 	/*.codec_interface */ NULL,
 	/*.application_interface */ NULL,
-	/* api_interface */ &modcdr_reload_interface
+	/* api_interface */ &modcdr_reload_interface_api
 };
 
 static switch_status_t my_on_hangup(switch_core_session_t *session)



More information about the Freeswitch-svn mailing list