[Freeswitch-svn] [commit] r5114 - freeswitch/trunk/src/mod/endpoints/mod_sofia

Freeswitch SVN anthm at freeswitch.org
Wed May 9 15:30:41 EDT 2007


Author: anthm
Date: Wed May  9 15:30:41 2007
New Revision: 5114

Modified:
   freeswitch/trunk/src/mod/endpoints/mod_sofia/mod_sofia.c
   freeswitch/trunk/src/mod/endpoints/mod_sofia/mod_sofia.h
   freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia.c
   freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia_glue.c

Log:
change some log levels

Modified: freeswitch/trunk/src/mod/endpoints/mod_sofia/mod_sofia.c
==============================================================================
--- freeswitch/trunk/src/mod/endpoints/mod_sofia/mod_sofia.c	(original)
+++ freeswitch/trunk/src/mod/endpoints/mod_sofia/mod_sofia.c	Wed May  9 15:30:41 2007
@@ -74,9 +74,9 @@
 */
 static switch_status_t sofia_on_init(switch_core_session_t *session)
 {
-	private_object_t *tech_pvt;
 	switch_channel_t *channel = NULL;
-
+	private_object_t *tech_pvt;
+	
 	channel = switch_core_session_get_channel(session);
 	assert(channel != NULL);
 
@@ -86,8 +86,7 @@
 	tech_pvt->read_frame.buflen = SWITCH_RTP_MAX_BUF_LEN;
 
 	switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "SOFIA INIT\n");
-	if (switch_channel_test_flag(channel, CF_NOMEDIA)) {
-		switch_set_flag_locked(tech_pvt, TFLAG_NOMEDIA);
+	if (switch_channel_test_flag(channel, CF_BYPASS_MEDIA)) {
 		sofia_glue_tech_absorb_sdp(tech_pvt);
 	}
 
@@ -283,9 +282,8 @@
 	if (!switch_test_flag(tech_pvt, TFLAG_ANS) && !switch_channel_test_flag(channel, CF_OUTBOUND)) {
 		switch_set_flag_locked(tech_pvt, TFLAG_ANS);
 
-		if (switch_channel_test_flag(channel, CF_NOMEDIA)) {
+		if (switch_channel_test_flag(channel, CF_BYPASS_MEDIA)) {
 			char *sdp = NULL;
-			switch_set_flag_locked(tech_pvt, TFLAG_NOMEDIA);
 			if ((sdp = switch_channel_get_variable(channel, SWITCH_B_SDP_VARIABLE))) {
 				tech_pvt->local_sdp_str = switch_core_session_strdup(session, sdp);
 			}
@@ -692,8 +690,7 @@
 			switch_core_session_t *other_session;
 			switch_channel_t *other_channel;
 			char *ip = NULL, *port = NULL;
-
-			switch_set_flag_locked(tech_pvt, TFLAG_NOMEDIA);
+			switch_channel_set_flag(channel, CF_BYPASS_MEDIA);
 			tech_pvt->local_sdp_str = NULL;
 			if ((uuid = switch_channel_get_variable(channel, SWITCH_SIGNAL_BOND_VARIABLE))
 				&& (other_session = switch_core_session_locate(uuid))) {
@@ -712,7 +709,8 @@
 	}
 		break;
 	case SWITCH_MESSAGE_INDICATE_MEDIA:{
-			switch_clear_flag_locked(tech_pvt, TFLAG_NOMEDIA);
+		uint32_t count = 0;
+		switch_channel_clear_flag(channel, CF_BYPASS_MEDIA);
 			tech_pvt->local_sdp_str = NULL;
 			if (!switch_rtp_ready(tech_pvt->rtp_session)) {
 				sofia_glue_tech_prepare_codecs(tech_pvt);
@@ -723,8 +721,18 @@
 			}
 			sofia_glue_set_local_sdp(tech_pvt, NULL, 0, NULL, 1);
 			sofia_glue_do_invite(session);
-			while (!switch_rtp_ready(tech_pvt->rtp_session) && switch_channel_get_state(channel) < CS_HANGUP) {
-				switch_yield(1000);
+
+			/* wait for rtp to start and first real frame to arrive */
+			tech_pvt->read_frame.datalen = 0;
+			while (switch_test_flag(tech_pvt, TFLAG_IO) && switch_channel_get_state(channel) < CS_HANGUP && !switch_rtp_ready(tech_pvt->rtp_session)) {
+				if (++count > 1000) {
+					return SWITCH_STATUS_FALSE;
+				}
+				if (!switch_rtp_ready(tech_pvt->rtp_session)) {
+					switch_yield(1000);
+					continue;
+				}
+				break;
 			}
 		}
 		break;
@@ -741,7 +749,7 @@
 		}
 		break;
 	case SWITCH_MESSAGE_INDICATE_BRIDGE:
-
+		
 		if (switch_test_flag(tech_pvt, TFLAG_XFER)) {
 			switch_clear_flag_locked(tech_pvt, TFLAG_XFER);
 			if (msg->pointer_arg) {
@@ -825,9 +833,8 @@
 				switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "Asked to send early media by %s\n", msg->from);
 
 				/* Transmit 183 Progress with SDP */
-				if (switch_channel_test_flag(channel, CF_NOMEDIA)) {
+				if (switch_channel_test_flag(channel, CF_BYPASS_MEDIA)) {
 					char *sdp = NULL;
-					switch_set_flag_locked(tech_pvt, TFLAG_NOMEDIA);
 					if ((sdp = switch_channel_get_variable(channel, SWITCH_B_SDP_VARIABLE))) {
 						tech_pvt->local_sdp_str = switch_core_session_strdup(session, sdp);
 					}

Modified: freeswitch/trunk/src/mod/endpoints/mod_sofia/mod_sofia.h
==============================================================================
--- freeswitch/trunk/src/mod/endpoints/mod_sofia/mod_sofia.h	(original)
+++ freeswitch/trunk/src/mod/endpoints/mod_sofia/mod_sofia.h	Wed May  9 15:30:41 2007
@@ -135,7 +135,7 @@
 	TFLAG_REFER = (1 << 17),
 	TFLAG_NOHUP = (1 << 18),
 	TFLAG_XFER = (1 << 19),
-	TFLAG_NOMEDIA = (1 << 20),
+	TFLAG_RESERVED = (1 << 20),
 	TFLAG_BUGGY_2833 = (1 << 21),
 	TFLAG_SIP_HOLD = (1 << 22),
 	TFLAG_INB_NOMEDIA = (1 << 23),
@@ -261,6 +261,7 @@
 	uint32_t flags;
 	switch_payload_t agreed_pt;
 	switch_core_session_t *session;
+	switch_channel_t *channel;
 	switch_frame_t read_frame;
 	char *codec_order[SWITCH_MAX_CODECS];
 	int codec_order_last;

Modified: freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia.c
==============================================================================
--- freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia.c	(original)
+++ freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia.c	Wed May  9 15:30:41 2007
@@ -56,9 +56,6 @@
 			if ((session = switch_core_session_locate(sofia_private->uuid))) {
 				tech_pvt = switch_core_session_get_private(session);
 				channel = switch_core_session_get_channel(tech_pvt->session);
-				if (switch_channel_test_flag(channel, CF_NOMEDIA)) {
-					switch_set_flag(tech_pvt, TFLAG_NOMEDIA);
-				}
 				if (!tech_pvt->call_id && sip && sip->sip_call_id && sip->sip_call_id->i_id) {
 					tech_pvt->call_id = switch_core_session_strdup(session, (char *) sip->sip_call_id->i_id);
 					switch_channel_set_variable(channel, "sip_call_id", tech_pvt->call_id);
@@ -988,10 +985,6 @@
 		
 
 
-		if (switch_channel_test_flag(channel, CF_NOMEDIA)) {
-			switch_set_flag(tech_pvt, TFLAG_NOMEDIA);
-		}
-
 		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Channel %s entering state [%s]\n",
 						  switch_channel_get_name(channel), nua_callstate_name(ss_state));
 
@@ -1000,7 +993,6 @@
 			tech_pvt->remote_sdp_str = switch_core_session_strdup(session, r_sdp);
 			switch_channel_set_variable(channel, SWITCH_R_SDP_VARIABLE, r_sdp);
 			sofia_glue_pass_sdp(tech_pvt, (char *) r_sdp);
-
 		}
 	}
 
@@ -1020,7 +1012,7 @@
 			if (status == 180) {
 				switch_channel_mark_ring_ready(channel);
 				if (!switch_channel_test_flag(channel, CF_GEN_RINGBACK)) {
-					if (switch_test_flag(tech_pvt, TFLAG_NOMEDIA)) {
+					if (switch_channel_test_flag(channel, CF_BYPASS_MEDIA)) {
 						if ((uuid = switch_channel_get_variable(channel, SWITCH_SIGNAL_BOND_VARIABLE))
 							&& (other_session = switch_core_session_locate(uuid))) {
 							switch_core_session_message_t msg;
@@ -1037,7 +1029,7 @@
 			}
 
 			if (r_sdp) {
-				if (switch_test_flag(tech_pvt, TFLAG_NOMEDIA)) {
+				if (switch_channel_test_flag(channel, CF_BYPASS_MEDIA)) {
 					switch_set_flag_locked(tech_pvt, TFLAG_EARLY_MEDIA);
 					switch_channel_mark_pre_answered(channel);
 					if (!switch_channel_test_flag(channel, CF_GEN_RINGBACK) && (uuid = switch_channel_get_variable(channel, SWITCH_SIGNAL_BOND_VARIABLE))
@@ -1072,7 +1064,7 @@
 	case nua_callstate_received:
 		if (tech_pvt && !switch_test_flag(tech_pvt, TFLAG_SDP)) {
 			if (r_sdp && !switch_test_flag(tech_pvt, TFLAG_SDP)) {
-				if (switch_test_flag(tech_pvt, TFLAG_NOMEDIA)) {
+				if (switch_channel_test_flag(channel, CF_BYPASS_MEDIA)) {
 					switch_channel_set_variable(channel, SWITCH_ENDPOINT_DISPOSITION_VARIABLE, "RECEIVED_NOMEDIA");
 					switch_set_flag_locked(tech_pvt, TFLAG_READY);
 					switch_channel_set_state(channel, CS_INIT);
@@ -1135,7 +1127,7 @@
 					switch_channel_hangup(channel, SWITCH_CAUSE_INCOMPATIBLE_DESTINATION);
 				}
 			} else {
-				if (switch_test_flag(tech_pvt, TFLAG_NOMEDIA)) {
+				if (switch_channel_test_flag(channel, CF_BYPASS_MEDIA)) {
 					goto done;
 				} else {
 					switch_channel_set_variable(channel, SWITCH_ENDPOINT_DISPOSITION_VARIABLE, "RECEIVED_NOSDP");
@@ -1155,14 +1147,14 @@
 		break;
 	case nua_callstate_completed:
 		if (tech_pvt && r_sdp) {
-			if (r_sdp) { // && !switch_test_flag(tech_pvt, TFLAG_SDP)) {
-				if (switch_test_flag(tech_pvt, TFLAG_NOMEDIA)) {
+			sdp_parser_t *parser; 
+			sdp_session_t *sdp;
+			uint8_t match = 0;
+
+			if (r_sdp) { 
+				if (switch_channel_test_flag(channel, CF_BYPASS_MEDIA)) {
 					goto done;
 				} else {
-					sdp_parser_t *parser; 
-					sdp_session_t *sdp;
-					uint8_t match = 0;
-
 					if (tech_pvt->num_codecs) {
 						if ((parser = sdp_parse(NULL, r_sdp, (int) strlen(r_sdp), 0))) {
 							if ((sdp = sdp_session(parser))) {
@@ -1222,7 +1214,7 @@
 				r_sdp = (const char *) switch_channel_get_variable(channel, SWITCH_R_SDP_VARIABLE);
 			}
 			if (r_sdp && !switch_test_flag(tech_pvt, TFLAG_SDP)) {
-				if (switch_test_flag(tech_pvt, TFLAG_NOMEDIA)) {
+				if (switch_channel_test_flag(channel, CF_BYPASS_MEDIA)) {
 					switch_set_flag_locked(tech_pvt, TFLAG_ANS);
 					switch_channel_mark_answered(channel);
 					if ((uuid = switch_channel_get_variable(channel, SWITCH_SIGNAL_BOND_VARIABLE))
@@ -1337,7 +1329,7 @@
 	}
 
 
-	if (switch_channel_test_flag(channel_a, CF_NOMEDIA)) {
+	if (switch_channel_test_flag(channel_a, CF_BYPASS_MEDIA)) {
 		nua_notify(tech_pvt->nh, SIPTAG_CONTENT_TYPE_STR("message/sipfrag"),
 				   NUTAG_SUBSTATE(nua_substate_terminated), SIPTAG_PAYLOAD_STR("SIP/2.0 403 Forbidden"), SIPTAG_EVENT_STR(etmp), TAG_END());
 		goto done;
@@ -1819,8 +1811,7 @@
 	
 
 	if (switch_test_flag(tech_pvt, TFLAG_INB_NOMEDIA)) {
-		switch_set_flag_locked(tech_pvt, TFLAG_NOMEDIA);
-		switch_channel_set_flag(channel, CF_NOMEDIA);
+		switch_channel_set_flag(channel, CF_BYPASS_MEDIA);
 	}
 
 	if (!tech_pvt->call_id && sip->sip_call_id && sip->sip_call_id->i_id) {

Modified: freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia_glue.c
==============================================================================
--- freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia_glue.c	(original)
+++ freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia_glue.c	Wed May  9 15:30:41 2007
@@ -44,7 +44,7 @@
 	int rate = 0;
 	uint32_t v_port;
 
-	if (!force && !ip && !sr && switch_test_flag(tech_pvt, TFLAG_NOMEDIA)) {
+	if (!force && !ip && !sr && switch_channel_test_flag(tech_pvt->channel, CF_BYPASS_MEDIA)) {
 		return;
 	}
 
@@ -225,11 +225,10 @@
 
 void sofia_glue_tech_prepare_codecs(private_object_t *tech_pvt)
 {
-	switch_channel_t *channel;
 	char *abs, *codec_string = NULL;
 	char *ocodec = NULL;
 
-	if (switch_test_flag(tech_pvt, TFLAG_NOMEDIA)) {
+	if (switch_channel_test_flag(tech_pvt->channel, CF_BYPASS_MEDIA)) {
 		goto end;
 	}
 
@@ -239,20 +238,17 @@
 
 	assert(tech_pvt->session != NULL);
 
-	channel = switch_core_session_get_channel(tech_pvt->session);
-	assert(channel != NULL);
-
 
-	if ((abs = switch_channel_get_variable(channel, "absolute_codec_string"))) {
+	if ((abs = switch_channel_get_variable(tech_pvt->channel, "absolute_codec_string"))) {
 		codec_string = abs;
 	} else {
-		if (!(codec_string = switch_channel_get_variable(channel, "codec_string"))) {
+		if (!(codec_string = switch_channel_get_variable(tech_pvt->channel, "codec_string"))) {
 			if (tech_pvt->profile->codec_string) {
 				codec_string = tech_pvt->profile->codec_string;
 			}
 		}
 
-		if ((ocodec = switch_channel_get_variable(channel, SWITCH_ORIGINATOR_CODEC_VARIABLE))) {
+		if ((ocodec = switch_channel_get_variable(tech_pvt->channel, SWITCH_ORIGINATOR_CODEC_VARIABLE))) {
 			if (!codec_string || (tech_pvt->profile->pflags & PFLAG_DISABLE_TRANSCODING)) {
 				codec_string = ocodec;
 			} else {
@@ -301,7 +297,6 @@
 
 void sofia_glue_attach_private(switch_core_session_t *session, sofia_profile_t *profile, private_object_t *tech_pvt, const char *channame)
 {
-	switch_channel_t *channel;
 	char name[256];
 
 	assert(session != NULL);
@@ -309,9 +304,6 @@
 	assert(tech_pvt != NULL);
 
 	switch_core_session_add_stream(session, NULL);
-	channel = switch_core_session_get_channel(session);
-
-	//switch_channel_set_flag(channel, CF_ACCEPT_CNG);
 
 
 	switch_mutex_lock(tech_pvt->flag_mutex);
@@ -335,11 +327,12 @@
 	}
 
 	tech_pvt->session = session;
+	tech_pvt->channel = switch_core_session_get_channel(session);
 	switch_core_session_set_private(session, tech_pvt);
 
 
 	snprintf(name, sizeof(name), "sofia/%s/%s", profile->name, channame);
-	switch_channel_set_name(channel, name);
+	switch_channel_set_name(tech_pvt->channel, name);
 	//sofia_glue_tech_prepare_codecs(tech_pvt);
 
 }
@@ -362,7 +355,7 @@
 			switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Stun Failed! %s:%d [%s]\n", stun_ip, SWITCH_STUN_DEFAULT_PORT, error);
 			return SWITCH_STATUS_FALSE;
 		}
-		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "Stun Success [%s]:[%d]\n", *ip, *port);
+		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Stun Success [%s]:[%d]\n", *ip, *port);
 	} else {
 		*ip = sourceip;
 	}
@@ -373,13 +366,11 @@
 switch_status_t sofia_glue_tech_choose_port(private_object_t *tech_pvt)
 {
 	char *ip = tech_pvt->profile->rtpip;
-	switch_channel_t *channel;
 	switch_port_t sdp_port;
 	char tmp[50];
 
-	channel = switch_core_session_get_channel(tech_pvt->session);
 
-	if (switch_test_flag(tech_pvt, TFLAG_NOMEDIA) || tech_pvt->adv_sdp_audio_port) {
+	if (switch_channel_test_flag(tech_pvt->channel, CF_BYPASS_MEDIA) || tech_pvt->adv_sdp_audio_port) {
 		return SWITCH_STATUS_SUCCESS;
 	}
 
@@ -398,8 +389,8 @@
 	tech_pvt->adv_sdp_audio_port = sdp_port;
 
 	snprintf(tmp, sizeof(tmp), "%d", sdp_port);
-	switch_channel_set_variable(channel, SWITCH_LOCAL_MEDIA_IP_VARIABLE, tech_pvt->adv_sdp_audio_ip);
-	switch_channel_set_variable(channel, SWITCH_LOCAL_MEDIA_PORT_VARIABLE, tmp);
+	switch_channel_set_variable(tech_pvt->channel, SWITCH_LOCAL_MEDIA_IP_VARIABLE, tech_pvt->adv_sdp_audio_ip);
+	switch_channel_set_variable(tech_pvt->channel, SWITCH_LOCAL_MEDIA_PORT_VARIABLE, tmp);
 
 
 	return SWITCH_STATUS_SUCCESS;
@@ -410,13 +401,11 @@
 switch_status_t sofia_glue_tech_choose_video_port(private_object_t *tech_pvt)
 {
 	char *ip = tech_pvt->profile->rtpip;
-	switch_channel_t *channel;
 	switch_port_t sdp_port;
 	char tmp[50];
 
-	channel = switch_core_session_get_channel(tech_pvt->session);
 
-	if (switch_test_flag(tech_pvt, TFLAG_NOMEDIA) || tech_pvt->adv_sdp_video_port) {
+	if (switch_channel_test_flag(tech_pvt->channel, CF_BYPASS_MEDIA) || tech_pvt->adv_sdp_video_port) {
 		return SWITCH_STATUS_SUCCESS;
 	}
 
@@ -434,8 +423,8 @@
 	tech_pvt->adv_sdp_video_port = sdp_port;
 
 	snprintf(tmp, sizeof(tmp), "%d", sdp_port);
-	switch_channel_set_variable(channel, SWITCH_LOCAL_VIDEO_IP_VARIABLE, tech_pvt->adv_sdp_audio_ip);
-	switch_channel_set_variable(channel, SWITCH_LOCAL_VIDEO_PORT_VARIABLE, tmp);
+	switch_channel_set_variable(tech_pvt->channel, SWITCH_LOCAL_VIDEO_IP_VARIABLE, tech_pvt->adv_sdp_audio_ip);
+	switch_channel_set_variable(tech_pvt->channel, SWITCH_LOCAL_VIDEO_PORT_VARIABLE, tmp);
 
 
 	return SWITCH_STATUS_SUCCESS;
@@ -471,6 +460,8 @@
 	tech_pvt = (private_object_t *) switch_core_session_get_private(session);
 	assert(tech_pvt != NULL);
 
+	switch_clear_flag_locked(tech_pvt, TFLAG_SDP);
+
 	caller_profile = switch_channel_get_caller_profile(channel);
 
 	cid_name = (char *) caller_profile->caller_id_name;
@@ -655,13 +646,10 @@
 
 void sofia_glue_tech_absorb_sdp(private_object_t *tech_pvt)
 {
-	switch_channel_t *channel;
 	char *sdp_str;
 
-	channel = switch_core_session_get_channel(tech_pvt->session);
-	assert(channel != NULL);
 
-	if ((sdp_str = switch_channel_get_variable(channel, SWITCH_B_SDP_VARIABLE))) {
+	if ((sdp_str = switch_channel_get_variable(tech_pvt->channel, SWITCH_B_SDP_VARIABLE))) {
 		sdp_parser_t *parser;
 		sdp_session_t *sdp;
 		sdp_media_t *m;
@@ -711,7 +699,6 @@
 
 switch_status_t sofia_glue_tech_set_video_codec(private_object_t *tech_pvt, int force)
 {
-	switch_channel_t *channel;
 
 	if (tech_pvt->video_read_codec.implementation) {
 		if (!force) {
@@ -731,8 +718,6 @@
 		}
 	}
 
-	channel = switch_core_session_get_channel(tech_pvt->session);
-	assert(channel != NULL);
 
 	if (!tech_pvt->video_rm_encoding) {
 		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Can't load codec with no name?\n");
@@ -765,8 +750,8 @@
 			int ms;
 			tech_pvt->video_read_frame.rate = tech_pvt->video_rm_rate;
 			ms = tech_pvt->video_write_codec.implementation->microseconds_per_frame / 1000;
-			switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "Set VIDEO Codec %s %s/%ld %d ms\n",
-							  switch_channel_get_name(channel), tech_pvt->video_rm_encoding, tech_pvt->video_rm_rate, tech_pvt->video_codec_ms);
+			switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Set VIDEO Codec %s %s/%ld %d ms\n",
+							  switch_channel_get_name(tech_pvt->channel), tech_pvt->video_rm_encoding, tech_pvt->video_rm_rate, tech_pvt->video_codec_ms);
 			tech_pvt->video_read_frame.codec = &tech_pvt->video_read_codec;
 			
 			//switch_core_session_set_read_codec(tech_pvt->session, &tech_pvt->read_codec);
@@ -779,7 +764,6 @@
 
 switch_status_t sofia_glue_tech_set_codec(private_object_t *tech_pvt, int force)
 {
-	switch_channel_t *channel;
 
 	if (tech_pvt->read_codec.implementation) {
 		if (!force) {
@@ -799,9 +783,6 @@
 		}
 	}
 
-	channel = switch_core_session_get_channel(tech_pvt->session);
-	assert(channel != NULL);
-
 	if (!tech_pvt->rm_encoding) {
 		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Can't load codec with no name?\n");
 		return SWITCH_STATUS_FALSE;
@@ -832,8 +813,8 @@
 			int ms;
 			tech_pvt->read_frame.rate = tech_pvt->rm_rate;
 			ms = tech_pvt->write_codec.implementation->microseconds_per_frame / 1000;
-			switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "Set Codec %s %s/%ld %d ms\n",
-							  switch_channel_get_name(channel), tech_pvt->rm_encoding, tech_pvt->rm_rate, tech_pvt->codec_ms);
+			switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Set Codec %s %s/%ld %d ms\n",
+							  switch_channel_get_name(tech_pvt->channel), tech_pvt->rm_encoding, tech_pvt->rm_rate, tech_pvt->codec_ms);
 			tech_pvt->read_frame.codec = &tech_pvt->read_codec;
 			
 			switch_core_session_set_read_codec(tech_pvt->session, &tech_pvt->read_codec);
@@ -851,7 +832,6 @@
 switch_status_t sofia_glue_activate_rtp(private_object_t *tech_pvt)
 {
 	int bw, ms;
-	switch_channel_t *channel;
 	const char *err = NULL;
 	char *val = NULL;
 	switch_rtp_flag_t flags;
@@ -859,10 +839,8 @@
 	char tmp[50];
 	assert(tech_pvt != NULL);
 
-	channel = switch_core_session_get_channel(tech_pvt->session);
-	assert(channel != NULL);
 
-	if (switch_test_flag(tech_pvt, TFLAG_NOMEDIA)) {
+	if (switch_channel_test_flag(tech_pvt->channel, CF_BYPASS_MEDIA)) {
 		return SWITCH_STATUS_SUCCESS;
 	}
 
@@ -884,12 +862,12 @@
 	}
 
 	if ((tech_pvt->profile->pflags & PFLAG_PASS_RFC2833)
-		|| ((val = switch_channel_get_variable(channel, "pass_rfc2833")) && switch_true(val))) {
+		|| ((val = switch_channel_get_variable(tech_pvt->channel, "pass_rfc2833")) && switch_true(val))) {
 		flags |= SWITCH_RTP_FLAG_PASS_RFC2833;
 	}
 
 	if (!((tech_pvt->profile->pflags & PFLAG_REWRITE_TIMESTAMPS) || 
-		  ((val = switch_channel_get_variable(channel, "rtp_rewrite_timestamps")) && switch_true(val)))) {
+		  ((val = switch_channel_get_variable(tech_pvt->channel, "rtp_rewrite_timestamps")) && switch_true(val)))) {
 		flags |= SWITCH_RTP_FLAG_RAW_WRITE;
 	}
 
@@ -897,16 +875,16 @@
 		flags |= SWITCH_RTP_FLAG_AUTO_CNG;
 	}
 
-	switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "AUDIO RTP [%s] %s:%d->%s:%d codec: %u ms: %d\n",
-					  switch_channel_get_name(channel),
+	switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "AUDIO RTP [%s] %s:%d->%s:%d codec: %u ms: %d\n",
+					  switch_channel_get_name(tech_pvt->channel),
 					  tech_pvt->local_sdp_audio_ip,
 					  tech_pvt->local_sdp_audio_port,
 					  tech_pvt->remote_sdp_audio_ip,
 					  tech_pvt->remote_sdp_audio_port, tech_pvt->agreed_pt, tech_pvt->read_codec.implementation->microseconds_per_frame / 1000);
 
 	snprintf(tmp, sizeof(tmp), "%d", tech_pvt->remote_sdp_audio_port);
-	switch_channel_set_variable(channel, SWITCH_LOCAL_MEDIA_IP_VARIABLE, tech_pvt->adv_sdp_audio_ip);
-	switch_channel_set_variable(channel, SWITCH_LOCAL_MEDIA_PORT_VARIABLE, tmp);
+	switch_channel_set_variable(tech_pvt->channel, SWITCH_LOCAL_MEDIA_IP_VARIABLE, tech_pvt->adv_sdp_audio_ip);
+	switch_channel_set_variable(tech_pvt->channel, SWITCH_LOCAL_MEDIA_PORT_VARIABLE, tmp);
 
 	if (tech_pvt->rtp_session && switch_test_flag(tech_pvt, TFLAG_REINVITE)) {
 		switch_clear_flag_locked(tech_pvt, TFLAG_REINVITE);
@@ -949,7 +927,7 @@
 							  switch_channel_get_name(switch_core_session_get_channel(tech_pvt->session)), vad_in ? "in" : "", vad_out ? "out" : "");
 		}
 
-		if ((val = switch_channel_get_variable(channel, "jitterbuffer_msec"))) {
+		if ((val = switch_channel_get_variable(tech_pvt->channel, "jitterbuffer_msec"))) {
 			int len = atoi(val);
 			
 			if (len < 100 || len > 1000) {
@@ -959,7 +937,7 @@
 
 				qlen = len / (tech_pvt->read_codec.implementation->microseconds_per_frame / 1000);
 				
-				switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "Setting Jitterbuffer to %dms (%d frames)\n", len, qlen);
+				switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Setting Jitterbuffer to %dms (%d frames)\n", len, qlen);
 				switch_rtp_activate_jitter_buffer(tech_pvt->rtp_session, qlen);
 			}
 		}
@@ -993,8 +971,8 @@
 													 &err, switch_core_session_get_pool(tech_pvt->session));
 			
 			
-			switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "VIDEO RTP [%s] %s:%d->%s:%d codec: %u ms: %d [%s]\n",
-							  switch_channel_get_name(channel),
+			switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "VIDEO RTP [%s] %s:%d->%s:%d codec: %u ms: %d [%s]\n",
+							  switch_channel_get_name(tech_pvt->channel),
 							  tech_pvt->local_sdp_audio_ip,
 							  tech_pvt->local_sdp_video_port,
 							  tech_pvt->remote_sdp_video_ip,
@@ -1004,13 +982,13 @@
 			
 
 			if (switch_rtp_ready(tech_pvt->video_rtp_session)) {
-				switch_channel_set_flag(channel, CF_VIDEO);
+				switch_channel_set_flag(tech_pvt->channel, CF_VIDEO);
 			}
 		}
 
 	} else {
 		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "RTP REPORTS ERROR: [%s]\n", err);
-		switch_channel_hangup(channel, SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER);
+		switch_channel_hangup(tech_pvt->channel, SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER);
 		switch_clear_flag_locked(tech_pvt, TFLAG_IO);
 		return SWITCH_STATUS_FALSE;
 	}
@@ -1024,7 +1002,6 @@
 	sdp_parser_t *parser = sdp_parse(NULL, r_sdp, (int) strlen(r_sdp), 0);
 	sdp_session_t *sdp;
 	uint8_t match = 0;
-	switch_channel_t *channel = switch_core_session_get_channel(tech_pvt->session);
 
 	assert(tech_pvt != NULL);
 
@@ -1049,9 +1026,9 @@
 		if (sofia_glue_activate_rtp(tech_pvt) != SWITCH_STATUS_SUCCESS) {
 			return SWITCH_STATUS_FALSE;
 		}
-		switch_channel_set_variable(channel, SWITCH_ENDPOINT_DISPOSITION_VARIABLE, "EARLY MEDIA");
+		switch_channel_set_variable(tech_pvt->channel, SWITCH_ENDPOINT_DISPOSITION_VARIABLE, "EARLY MEDIA");
 		switch_set_flag_locked(tech_pvt, TFLAG_EARLY_MEDIA);
-		switch_channel_mark_pre_answered(channel);
+		switch_channel_mark_pre_answered(tech_pvt->channel);
 		return SWITCH_STATUS_SUCCESS;
 	}
 
@@ -1065,13 +1042,12 @@
 	private_object_t *tech_pvt;
 	sdp_media_t *m;
 	sdp_attribute_t *a;
-	switch_channel_t *channel;
+
 	int ptime = 0, dptime = 0;
 
 	tech_pvt = switch_core_session_get_private(session);
 	assert(tech_pvt != NULL);
 
-	channel = switch_core_session_get_channel(session);
 
 	if ((tech_pvt->origin = switch_core_session_strdup(session, (char *) sdp->sdp_origin->o_username))) {
 		if (strstr(tech_pvt->origin, "CiscoSystemsSIP-GW-UserAgent")) {
@@ -1088,10 +1064,8 @@
 		if (!strcasecmp(a->a_name, "sendonly")) {
 			if (!switch_test_flag(tech_pvt, TFLAG_SIP_HOLD)) {
 				char *stream;
-				
 				switch_set_flag_locked(tech_pvt, TFLAG_SIP_HOLD);
-				switch_channel_set_flag(channel, CF_HOLD);
-				if (!(stream = switch_channel_get_variable(channel, SWITCH_HOLD_MUSIC_VARIABLE))) {
+				if (!(stream = switch_channel_get_variable(tech_pvt->channel, SWITCH_HOLD_MUSIC_VARIABLE))) {
 					stream = tech_pvt->profile->hold_music;
 				}
 				if (stream) {
@@ -1100,10 +1074,9 @@
 			}
 		} else if (!strcasecmp(a->a_name, "sendrecv")) {
 			if (switch_test_flag(tech_pvt, TFLAG_SIP_HOLD)) {
+				switch_channel_clear_flag_partner(tech_pvt->channel, CF_BROADCAST);
+				switch_channel_set_flag_partner(tech_pvt->channel, CF_BREAK);
 				switch_clear_flag_locked(tech_pvt, TFLAG_SIP_HOLD);
-				switch_channel_clear_flag(channel, CF_HOLD);
-				switch_channel_clear_flag_partner(channel, CF_BROADCAST);
-				switch_channel_set_flag_partner(channel, CF_BREAK);
 			}
 		} else if (!strcasecmp(a->a_name, "ptime")) {
 			dptime = atoi(a->a_value);
@@ -1230,8 +1203,8 @@
 						tech_pvt->remote_sdp_audio_port = (switch_port_t) m->m_port;
 						tech_pvt->agreed_pt = (switch_payload_t) map->rm_pt;
 						snprintf(tmp, sizeof(tmp), "%d", tech_pvt->remote_sdp_audio_port);
-						switch_channel_set_variable(channel, SWITCH_REMOTE_MEDIA_IP_VARIABLE, tech_pvt->remote_sdp_audio_ip);
-						switch_channel_set_variable(channel, SWITCH_REMOTE_MEDIA_PORT_VARIABLE, tmp);
+						switch_channel_set_variable(tech_pvt->channel, SWITCH_REMOTE_MEDIA_IP_VARIABLE, tech_pvt->remote_sdp_audio_ip);
+						switch_channel_set_variable(tech_pvt->channel, SWITCH_REMOTE_MEDIA_PORT_VARIABLE, tmp);
 					} else {
 						match = 0;
 					}
@@ -1307,8 +1280,8 @@
 						tech_pvt->remote_sdp_video_port = (switch_port_t) m->m_port;
 						tech_pvt->video_agreed_pt = (switch_payload_t) map->rm_pt;
 						snprintf(tmp, sizeof(tmp), "%d", tech_pvt->remote_sdp_video_port);
-						switch_channel_set_variable(channel, SWITCH_REMOTE_VIDEO_IP_VARIABLE, tech_pvt->remote_sdp_audio_ip);
-						switch_channel_set_variable(channel, SWITCH_REMOTE_VIDEO_PORT_VARIABLE, tmp);
+						switch_channel_set_variable(tech_pvt->channel, SWITCH_REMOTE_VIDEO_IP_VARIABLE, tech_pvt->remote_sdp_audio_ip);
+						switch_channel_set_variable(tech_pvt->channel, SWITCH_REMOTE_VIDEO_PORT_VARIABLE, tmp);
 					} else {
 						vmatch = 0;
 					}
@@ -1392,23 +1365,20 @@
 void sofia_glue_pass_sdp(private_object_t *tech_pvt, char *sdp)
 {
 	char *val;
-	switch_channel_t *channel;
 	switch_core_session_t *other_session;
 	switch_channel_t *other_channel;
 
-	channel = switch_core_session_get_channel(tech_pvt->session);
-	assert(channel != NULL);
 
-	if ((val = switch_channel_get_variable(channel, SWITCH_SIGNAL_BOND_VARIABLE))
+	if ((val = switch_channel_get_variable(tech_pvt->channel, SWITCH_SIGNAL_BOND_VARIABLE))
 		&& (other_session = switch_core_session_locate(val))) {
 		other_channel = switch_core_session_get_channel(other_session);
 		assert(other_channel != NULL);
 		switch_channel_set_variable(other_channel, SWITCH_B_SDP_VARIABLE, sdp);
 
 		if (!switch_test_flag(tech_pvt, TFLAG_CHANGE_MEDIA) && (switch_channel_test_flag(other_channel, CF_OUTBOUND) &&
-																//switch_channel_test_flag(other_channel, CF_NOMEDIA) && 
-																switch_channel_test_flag(channel, CF_OUTBOUND) &&
-																switch_channel_test_flag(channel, CF_NOMEDIA))) {
+																//switch_channel_test_flag(other_channel, CF_BYPASS_MEDIA) && 
+																switch_channel_test_flag(tech_pvt->channel, CF_OUTBOUND) &&
+																switch_channel_test_flag(tech_pvt->channel, CF_BYPASS_MEDIA))) {
 			switch_ivr_nomedia(val, SMF_FORCE);
 			switch_set_flag_locked(tech_pvt, TFLAG_CHANGE_MEDIA);
 		}



More information about the Freeswitch-svn mailing list