[Freeswitch-svn] [commit] r11289 - in freeswitch/trunk/src: . mod/endpoints/mod_loopback

FreeSWITCH SVN anthm at freeswitch.org
Mon Jan 19 11:32:44 PST 2009


Author: anthm
Date: Mon Jan 19 13:32:44 2009
New Revision: 11289

Log:
more cleanup from refactor of originate code

Modified:
   freeswitch/trunk/src/mod/endpoints/mod_loopback/mod_loopback.c
   freeswitch/trunk/src/switch_ivr_originate.c

Modified: freeswitch/trunk/src/mod/endpoints/mod_loopback/mod_loopback.c
==============================================================================
--- freeswitch/trunk/src/mod/endpoints/mod_loopback/mod_loopback.c	(original)
+++ freeswitch/trunk/src/mod/endpoints/mod_loopback/mod_loopback.c	Mon Jan 19 13:32:44 2009
@@ -50,7 +50,8 @@
 	TFLAG_WRITE = (1 << 2),
 	TFLAG_CNG = (1 << 3),
 	TFLAG_BRIDGE = (1 << 4),
-	TFLAG_BOWOUT = (1 << 5)
+	TFLAG_BOWOUT = (1 << 5),
+	TFLAG_BLEG = (1 << 6)
 } TFLAGS;
 
 struct private_object {
@@ -210,8 +211,8 @@
 
 	channel = switch_core_session_get_channel(session);
 	switch_assert(channel != NULL);
-
-	if (!switch_test_flag(tech_pvt, TFLAG_OUTBOUND)) {
+	
+	if (switch_test_flag(tech_pvt, TFLAG_OUTBOUND) && !switch_test_flag(tech_pvt, TFLAG_BLEG)) {
 		
 		if (!(b_session = switch_core_session_request(loopback_endpoint_interface, NULL))) {
 			switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "Failure.\n");
@@ -247,7 +248,8 @@
 		
 		switch_set_flag_locked(tech_pvt, TFLAG_LINKED);
 		switch_set_flag_locked(b_tech_pvt, TFLAG_LINKED);
-		switch_set_flag_locked(b_tech_pvt, TFLAG_OUTBOUND);
+		switch_set_flag_locked(b_tech_pvt, TFLAG_BLEG);
+
 		
 		switch_channel_set_flag(channel, CF_ACCEPT_CNG);	
 		//switch_ivr_transfer_variable(session, tech_pvt->other_session, "process_cdr");
@@ -608,17 +610,13 @@
 	
 	switch (msg->message_id) {
 	case SWITCH_MESSAGE_INDICATE_ANSWER:
-		if (tech_pvt->other_channel) {
-			if (switch_test_flag(tech_pvt, TFLAG_OUTBOUND)) {
-				switch_channel_mark_answered(tech_pvt->other_channel);
-			}
+		if (tech_pvt->other_channel && !switch_test_flag(tech_pvt, TFLAG_OUTBOUND)) {
+			switch_channel_mark_answered(tech_pvt->other_channel);
 		}
 		break;
 	case SWITCH_MESSAGE_INDICATE_PROGRESS:
-		if (tech_pvt->other_channel) {
-			if (switch_test_flag(tech_pvt, TFLAG_OUTBOUND)) {
-				switch_channel_mark_pre_answered(tech_pvt->other_channel);
-			}
+		if (tech_pvt->other_channel && !switch_test_flag(tech_pvt, TFLAG_OUTBOUND)) {
+			switch_channel_mark_pre_answered(tech_pvt->other_channel);
 		}
 		break;
 	case SWITCH_MESSAGE_INDICATE_BRIDGE:
@@ -703,7 +701,7 @@
 			switch_snprintf(name, sizeof(name), "loopback/%s-a", caller_profile->destination_number);
 			switch_channel_set_name(channel, name);
 			switch_channel_set_flag(channel, CF_OUTBOUND);
-
+			switch_set_flag_locked(tech_pvt, TFLAG_OUTBOUND);
 			switch_channel_set_caller_profile(channel, caller_profile);
 			tech_pvt->caller_profile = caller_profile;
 		} else {

Modified: freeswitch/trunk/src/switch_ivr_originate.c
==============================================================================
--- freeswitch/trunk/src/switch_ivr_originate.c	(original)
+++ freeswitch/trunk/src/switch_ivr_originate.c	Mon Jan 19 13:32:44 2009
@@ -560,7 +560,7 @@
 				message = NULL;
 			}
 		}
-
+		
 		if (switch_channel_media_ready(caller_channel)) {
 			status = switch_core_session_read_frame(session, &read_frame, SWITCH_IO_FLAG_NONE, 0);
 			if (!SWITCH_READ_ACCEPTABLE(status)) {
@@ -569,8 +569,9 @@
 		} else {
 			read_frame = NULL;
 		}
-
+		
 		if (read_frame && !pass) {
+
 			if (ringback.fh) {
 				switch_size_t mlen, olen;
 				unsigned int pos = 0;
@@ -711,7 +712,6 @@
 	switch_event_t *var_event = NULL;
 	uint8_t fail_on_single_reject = 0;
 	char *fail_on_single_reject_var = NULL;
-	uint8_t ring_ready = 0;
 	char *loop_data = NULL;
 	uint32_t progress_timelimit_sec = 0;
 	uint32_t per_channel_timelimit_sec[MAX_PEERS] = { 0 };
@@ -941,7 +941,7 @@
 	}
 
 	if ((var_val = switch_event_get_header(var_event, "ring_ready")) && switch_true(var_val)) {
-		ring_ready = 1;
+		oglobals.ring_ready = 1;
 	}
 
 	if ((var_val = switch_event_get_header(var_event, "originate_timeout"))) {
@@ -1471,7 +1471,7 @@
 
 			while ((!caller_channel || switch_channel_ready(caller_channel)) && check_channel_status(&oglobals, originate_status, and_argc)) {
 				time_t elapsed = switch_timestamp(NULL) - start;
-				if (caller_channel && !oglobals.sent_ring && ring_ready && !oglobals.return_ring_ready) {
+				if (caller_channel && !oglobals.sent_ring && oglobals.ring_ready && !oglobals.return_ring_ready) {
 					switch_channel_ring_ready(caller_channel);
 					oglobals.sent_ring = 1;
 				}
@@ -1519,7 +1519,8 @@
 
 				if (originate_status[0].peer_session
 					&& switch_core_session_dequeue_message(originate_status[0].peer_session, &message) == SWITCH_STATUS_SUCCESS) {
-					if (oglobals.session && !ringback_data && or_argc == 1 && and_argc == 1) {	/* when there is only 1 channel to call and bridge and no ringback */
+					if (oglobals.session && !ringback_data && or_argc == 1 && and_argc == 1) {	
+						/* when there is only 1 channel to call and bridge and no ringback */
 						switch_core_session_receive_message(oglobals.session, message);
 					}
 
@@ -1542,15 +1543,14 @@
 
 					if (switch_channel_media_ready(caller_channel)) {
 						tstatus = switch_core_session_read_frame(oglobals.session, &read_frame, SWITCH_IO_FLAG_NONE, 0);
-
 						if (!SWITCH_READ_ACCEPTABLE(tstatus)) {
 							break;
 						}
 					} else {
 						read_frame = NULL;
 					}
-
-					if (ring_ready && read_frame && !pass) {
+					
+					if (oglobals.ring_ready && read_frame && !pass) {
 						if (ringback.fh) {
 							switch_size_t mlen, olen;
 							unsigned int pos = 0;



More information about the Freeswitch-svn mailing list