[Freeswitch-svn] [commit] r5465 - in freeswitch/trunk: scripts/socket src src/include src/mod/applications/mod_dptools

Freeswitch SVN anthm at freeswitch.org
Mon Jun 25 17:25:33 EDT 2007


Author: anthm
Date: Mon Jun 25 17:25:33 2007
New Revision: 5465

Modified:
   freeswitch/trunk/scripts/socket/sock.pl
   freeswitch/trunk/src/include/switch_types.h
   freeswitch/trunk/src/mod/applications/mod_dptools/mod_dptools.c
   freeswitch/trunk/src/switch_channel.c
   freeswitch/trunk/src/switch_core_session.c
   freeswitch/trunk/src/switch_event.c
   freeswitch/trunk/src/switch_ivr.c
   freeswitch/trunk/src/switch_ivr_async.c
   freeswitch/trunk/src/switch_ivr_bridge.c
   freeswitch/trunk/src/switch_ivr_play_say.c

Log:
update

Modified: freeswitch/trunk/scripts/socket/sock.pl
==============================================================================
--- freeswitch/trunk/scripts/socket/sock.pl	(original)
+++ freeswitch/trunk/scripts/socket/sock.pl	Mon Jun 25 17:25:33 2007
@@ -23,7 +23,7 @@
 #to turn on events when in async mode
 $o = $fs->raw_command("myevents");
 $o = $fs->call_command("playback", "/ram/swimp.raw");
-$o = $fs->call_command("hangup");
+
 
 #comment exit in async mode
 #exit;
@@ -36,7 +36,11 @@
   if ($r->{has_event}) {
     print Dumper $r->{event};
   }
-
+  if ($r->{event}->{'event-name'} !~ /execute/i) {
+    printf "wtf $data->{'unique-id'}\n";
+    $o = $fs->call_command("break");
+    $o = $fs->call_command("hangup");
+  }
 }
 
 $fs->disconnect();

Modified: freeswitch/trunk/src/include/switch_types.h
==============================================================================
--- freeswitch/trunk/src/include/switch_types.h	(original)
+++ freeswitch/trunk/src/include/switch_types.h	Mon Jun 25 17:25:33 2007
@@ -573,6 +573,7 @@
 CF_BROADCAST    = (1 << 20) - Channel is broadcasting
 CF_UNICAST      = (1 << 21) - Channel has a unicast connection
 CF_VIDEO		= (1 << 22) - Channel has video
+CF_EVENT_LOCK   = (1 << 23) - Don't parse events
 </pre>
  */
 
@@ -599,7 +600,8 @@
 	CF_BREAK = (1 << 19),
 	CF_BROADCAST = (1 << 20),
 	CF_UNICAST = (1 << 21),
-	CF_VIDEO = (1 << 22)
+	CF_VIDEO = (1 << 22),
+	CF_EVENT_LOCK = (1 << 23)
 } switch_channel_flag_t;
 
 

Modified: freeswitch/trunk/src/mod/applications/mod_dptools/mod_dptools.c
==============================================================================
--- freeswitch/trunk/src/mod/applications/mod_dptools/mod_dptools.c	(original)
+++ freeswitch/trunk/src/mod/applications/mod_dptools/mod_dptools.c	Mon Jun 25 17:25:33 2007
@@ -94,6 +94,14 @@
 	switch_channel_ring_ready(channel);
 }
 
+SWITCH_STANDARD_APP(break_function)
+{
+	switch_channel_t *channel;
+	channel = switch_core_session_get_channel(session);
+	assert(channel != NULL);
+	switch_channel_set_flag(channel, CF_BREAK);
+}
+
 SWITCH_STANDARD_APP(queue_dtmf_function)
 {
 	switch_channel_t *channel;
@@ -1134,6 +1142,7 @@
 	SWITCH_ADD_APP(app_interface, "set", "Set a channel varaible", SET_LONG_DESC, set_function, "<varname>=<value>", SAF_SUPPORT_NOMEDIA);
 	SWITCH_ADD_APP(app_interface, "unset", "Unset a channel varaible", UNSET_LONG_DESC, unset_function, "<varname>", SAF_SUPPORT_NOMEDIA);
 	SWITCH_ADD_APP(app_interface, "ring_ready", "Indicate Ring_Ready", "Indicate Ring_Ready on a channel.", ring_ready_function, "", SAF_SUPPORT_NOMEDIA);
+	SWITCH_ADD_APP(app_interface, "break", "Break", "Set the break flag.", break_function, "", SAF_SUPPORT_NOMEDIA);
 	SWITCH_ADD_APP(app_interface, "detect_speech", "Detect speech", "Detect speech on a channel.", detect_speech_function, DETECT_SPEECH_SYNTAX, SAF_NONE);
 	SWITCH_ADD_APP(app_interface, "ivr", "Run an ivr menu", "Run an ivr menu.", ivr_application_function, "<menu_name>", SAF_NONE);
 	SWITCH_ADD_APP(app_interface, "redirect", "Send session redirect", "Send a redirect message to a session.", redirect_function, "<redirect_data>", SAF_SUPPORT_NOMEDIA);

Modified: freeswitch/trunk/src/switch_channel.c
==============================================================================
--- freeswitch/trunk/src/switch_channel.c	(original)
+++ freeswitch/trunk/src/switch_channel.c	Mon Jun 25 17:25:33 2007
@@ -513,11 +513,6 @@
 		ret++;
 	}
 
-	if (switch_test_flag(channel, CF_BREAK)) {
-		switch_clear_flag_locked(channel, CF_BREAK);
-		ret = (uint8_t) 0;
-	}
-
 	return ret;
 }
 

Modified: freeswitch/trunk/src/switch_core_session.c
==============================================================================
--- freeswitch/trunk/src/switch_core_session.c	(original)
+++ freeswitch/trunk/src/switch_core_session.c	Mon Jun 25 17:25:33 2007
@@ -567,11 +567,11 @@
 	channel = switch_core_session_get_channel(session);
 	assert(channel != NULL);
 
-	if (switch_channel_test_flag(channel, CF_EVENT_PARSE)) {
+	
+	if (switch_channel_test_flag(channel, CF_EVENT_LOCK)) {
 		return status;
 	}
 
-
 	if (session->private_event_queue) {
 		if ((status = (switch_status_t) switch_queue_trypop(session->private_event_queue, &pop)) == SWITCH_STATUS_SUCCESS) {
 			*event = (switch_event_t *) pop;
@@ -913,6 +913,7 @@
 														 const switch_application_interface_t *application_interface, char *arg) {
 	switch_app_log_t *log, *lp;
 	switch_event_t *event;
+	switch_channel_t *channel;
 
 	log = switch_core_session_alloc(session, sizeof(*log));
 
@@ -932,10 +933,12 @@
 	if (switch_event_create(&event, SWITCH_EVENT_CHANNEL_EXECUTE) == SWITCH_STATUS_SUCCESS) {
 		switch_channel_event_set_data(session->channel, event);
 		switch_event_add_header(event, SWITCH_STACK_BOTTOM, "Application", "%s", application_interface->interface_name);
-		switch_event_add_header(event, SWITCH_STACK_BOTTOM, "Application-Data", "%s", arg);
+		switch_event_add_header(event, SWITCH_STACK_BOTTOM, "Application-Data", arg);
 		switch_event_fire(&event);
 	}
 
+	channel = switch_core_session_get_channel(session);
+	switch_channel_clear_flag(channel, CF_BREAK);
 	application_interface->application_function(session, arg);
 	
 	if (switch_event_create(&event, SWITCH_EVENT_CHANNEL_EXECUTE_COMPLETE) == SWITCH_STATUS_SUCCESS) {

Modified: freeswitch/trunk/src/switch_event.c
==============================================================================
--- freeswitch/trunk/src/switch_event.c	(original)
+++ freeswitch/trunk/src/switch_event.c	Mon Jun 25 17:25:33 2007
@@ -684,7 +684,7 @@
 			}
 		}
 
-		snprintf(buf + len, dlen - len, "%s: %s\n", hp->name, encode_buf);
+		snprintf(buf + len, dlen - len, "%s: %s\n", hp->name, switch_strlen_zero(encode_buf) ? "_undef_" : encode_buf);
 		len = strlen(buf);
 
 	}

Modified: freeswitch/trunk/src/switch_ivr.c
==============================================================================
--- freeswitch/trunk/src/switch_ivr.c	(original)
+++ freeswitch/trunk/src/switch_ivr.c	Mon Jun 25 17:25:33 2007
@@ -272,7 +272,9 @@
 	unsigned long CMD_NOMEDIA = switch_hashfunc_default("nomedia", &hlen);
 	unsigned long CMD_UNICAST = switch_hashfunc_default("unicast", &hlen);
 	char *lead_frames = switch_event_get_header(event, "lead-frames");
-	
+	char *event_lock = switch_event_get_header(event, "event-lock");
+	switch_status_t status = SWITCH_STATUS_FALSE;
+
 	assert(channel != NULL);
 	assert(event != NULL);
 
@@ -286,15 +288,19 @@
 
 	switch_channel_set_flag(channel, CF_EVENT_PARSE);
 
+	if (switch_true(event_lock)) {
+		switch_channel_set_flag(channel, CF_EVENT_LOCK);
+	}
+
+
 	if (lead_frames) {
 		switch_frame_t *read_frame;
 		int frame_count = atoi(lead_frames);
-		switch_status_t status;
 
 		while(frame_count > 0) {
 			status = switch_core_session_read_frame(session, &read_frame, -1, 0);
 			if (!SWITCH_READ_ACCEPTABLE(status)) {
-				return status;
+				goto done;
 			}
 			if (!switch_test_flag(read_frame, SFF_CNG)) {
 				frame_count--;
@@ -308,12 +314,12 @@
 		char *app_arg = switch_event_get_header(event, "execute-app-arg");
 		char *loop_h = switch_event_get_header(event, "loops");
 		int loops = 1;
-	
+
 		if (loop_h) {
 			loops = atoi(loop_h);
 		}
-
-		if (app_name && app_arg) {
+		
+		if (app_name) {
 			if ((application_interface = switch_loadable_module_get_application_interface(app_name))) {
 				if (application_interface->application_function) {
 					int x;
@@ -368,9 +374,13 @@
 		switch_ivr_nomedia(uuid, SMF_REBRIDGE);
 	}
 
+	status = SWITCH_STATUS_SUCCESS;
 
+ done:
 	switch_channel_clear_flag(channel, CF_EVENT_PARSE);
-	return SWITCH_STATUS_SUCCESS;
+	switch_channel_clear_flag(channel, CF_EVENT_LOCK);
+
+	return status;
 
 }
 
@@ -906,6 +916,7 @@
 
 		switch_channel_set_caller_profile(channel, new_profile);
 		switch_channel_set_flag(channel, CF_TRANSFER);
+
 		switch_channel_set_state(channel, CS_RING);
 
 		msg.message_id = SWITCH_MESSAGE_INDICATE_TRANSFER;

Modified: freeswitch/trunk/src/switch_ivr_async.c
==============================================================================
--- freeswitch/trunk/src/switch_ivr_async.c	(original)
+++ freeswitch/trunk/src/switch_ivr_async.c	Mon Jun 25 17:25:33 2007
@@ -1179,6 +1179,7 @@
 				switch_event_add_header(event, SWITCH_STACK_BOTTOM, "execute-app-name", "%s", app);
 				switch_event_add_header(event, SWITCH_STACK_BOTTOM, "execute-app-arg", "%s", path);
 				switch_event_add_header(event, SWITCH_STACK_BOTTOM, "lead-frames", "%d", 5);
+				switch_event_add_header(event, SWITCH_STACK_BOTTOM, "event-lock", "%s", "true");
 				if ((flags & SMF_LOOP)) {
 					switch_event_add_header(event, SWITCH_STACK_BOTTOM, "loops", "%d", -1);
 				}
@@ -1197,6 +1198,7 @@
 				switch_event_add_header(event, SWITCH_STACK_BOTTOM, "execute-app-name", "%s", app);
 				switch_event_add_header(event, SWITCH_STACK_BOTTOM, "execute-app-arg", "%s", path);
 				switch_event_add_header(event, SWITCH_STACK_BOTTOM, "lead-frames", "%d", 5);
+				switch_event_add_header(event, SWITCH_STACK_BOTTOM, "event-lock", "%s", "true");
 				if ((flags & SMF_LOOP)) {
 					switch_event_add_header(event, SWITCH_STACK_BOTTOM, "loops", "%d", -1);
 				}
@@ -1209,6 +1211,7 @@
 			if (switch_event_create(&event, SWITCH_EVENT_MESSAGE) == SWITCH_STATUS_SUCCESS) {
 				switch_event_add_header(event, SWITCH_STACK_BOTTOM, "call-command", "nomedia");
 				switch_event_add_header(event, SWITCH_STACK_BOTTOM, "nomedia-uuid", "%s", uuid);
+				switch_event_add_header(event, SWITCH_STACK_BOTTOM, "event-lock", "%s", "true");
 				switch_core_session_queue_private_event(master, &event);
 			}
 		}
@@ -1218,7 +1221,7 @@
 				switch_event_add_header(event, SWITCH_STACK_BOTTOM, "call-command", "execute");
 				switch_event_add_header(event, SWITCH_STACK_BOTTOM, "execute-app-name", "hangup");
 				switch_event_add_header(event, SWITCH_STACK_BOTTOM, "execute-app-arg", "%s", cause);
-
+				switch_event_add_header(event, SWITCH_STACK_BOTTOM, "event-lock", "%s", "true");
 				switch_core_session_queue_private_event(session, &event);
 			}
 		}

Modified: freeswitch/trunk/src/switch_ivr_bridge.c
==============================================================================
--- freeswitch/trunk/src/switch_ivr_bridge.c	(original)
+++ freeswitch/trunk/src/switch_ivr_bridge.c	Mon Jun 25 17:25:33 2007
@@ -274,6 +274,7 @@
 	switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "CUSTOM TRANSMIT\n");
 	switch_channel_clear_state_handler(channel, NULL);
 
+	switch_channel_set_flag(channel, CF_BREAK);
 
 	if (!switch_channel_test_flag(channel, CF_ORIGINATOR)) {
 		return SWITCH_STATUS_FALSE;
@@ -656,6 +657,9 @@
 			switch_channel_set_flag(originatee_channel, CF_TAGGED);
 			switch_channel_set_private(originator_channel, SWITCH_UUID_BRIDGE, originatee_session);
 
+			switch_channel_set_flag(originator_channel, CF_BREAK);
+			switch_channel_set_flag(originatee_channel, CF_BREAK);
+			
 			/* switch_channel_set_state_flag sets flags you want to be set when the next state change happens */
 			switch_channel_set_state_flag(originator_channel, CF_TRANSFER);
 			switch_channel_set_state_flag(originatee_channel, CF_TRANSFER);

Modified: freeswitch/trunk/src/switch_ivr_play_say.c
==============================================================================
--- freeswitch/trunk/src/switch_ivr_play_say.c	(original)
+++ freeswitch/trunk/src/switch_ivr_play_say.c	Mon Jun 25 17:25:33 2007
@@ -395,6 +395,11 @@
 	while (switch_channel_ready(channel)) {
 		switch_size_t len;
 
+		if (switch_channel_test_flag(channel, CF_BREAK)) {
+			switch_channel_clear_flag(channel, CF_BREAK);
+			break;
+		}
+
 		if (switch_core_session_private_event_count(session)) {
 			switch_ivr_parse_all_events(session);
 		}
@@ -537,6 +542,11 @@
 	while(switch_channel_ready(channel)) {
 		switch_status_t status = switch_core_session_read_frame(session, &read_frame, 1000, 0);
 		
+		if (switch_channel_test_flag(channel, CF_BREAK)) {
+			switch_channel_clear_flag(channel, CF_BREAK);
+			break;
+		}
+
 		if (!SWITCH_READ_ACCEPTABLE(status)) {
 			break;
 		}
@@ -782,6 +792,11 @@
 		int do_speed = 1;
 		int last_speed = -1;
 
+		if (switch_channel_test_flag(channel, CF_BREAK)) {
+			switch_channel_clear_flag(channel, CF_BREAK);
+			break;
+		}
+
 		if (switch_core_session_private_event_count(session)) {
 			switch_ivr_parse_all_events(session);
 		}
@@ -1150,6 +1165,11 @@
 	while (switch_channel_ready(channel)) {
 		switch_event_t *event;
 
+		if (switch_channel_test_flag(channel, CF_BREAK)) {
+			switch_channel_clear_flag(channel, CF_BREAK);
+			break;
+		}
+
 		if (switch_core_session_dequeue_private_event(session, &event) == SWITCH_STATUS_SUCCESS) {
 			switch_ivr_parse_event(session, event);
 			switch_event_destroy(&event);



More information about the Freeswitch-svn mailing list