[Freeswitch-svn] [commit] r1957 - in freeswitch/trunk/src: . mod/codecs/mod_speex mod/endpoints/mod_dingaling mod/endpoints/mod_exosip mod/endpoints/mod_iax

Freeswitch SVN anthm at freeswitch.org
Tue Jul 18 14:34:43 EDT 2006


Author: anthm
Date: Tue Jul 18 14:34:42 2006
New Revision: 1957

Modified:
   freeswitch/trunk/src/mod/codecs/mod_speex/mod_speex.c
   freeswitch/trunk/src/mod/endpoints/mod_dingaling/mod_dingaling.c
   freeswitch/trunk/src/mod/endpoints/mod_exosip/mod_exosip.c
   freeswitch/trunk/src/mod/endpoints/mod_iax/mod_iax.c
   freeswitch/trunk/src/switch_rtp.c

Log:
codec tweak

Modified: freeswitch/trunk/src/mod/codecs/mod_speex/mod_speex.c
==============================================================================
--- freeswitch/trunk/src/mod/codecs/mod_speex/mod_speex.c	(original)
+++ freeswitch/trunk/src/mod/codecs/mod_speex/mod_speex.c	Tue Jul 18 14:34:42 2006
@@ -202,8 +202,6 @@
 	}
 
 
-
-
 	speex_bits_pack(&context->encoder_bits, 15, 5);
 	*encoded_data_len = speex_bits_write(&context->encoder_bits, (char *) encoded_data, context->encoder_frame_size);
 	speex_bits_reset(&context->encoder_bits);
@@ -226,6 +224,7 @@
 		return SWITCH_STATUS_FALSE;
 	}
 
+
 	buf = decoded_data;
 	if (*flag & SWITCH_CODEC_FLAG_SILENCE) {
 		speex_decode_int(context->decoder_state, NULL, buf);
@@ -276,7 +275,7 @@
 	/*.nanoseconds_per_frame */ 20000,
 	/*.samples_per_frame */ 640,
 	/*.bytes_per_frame */ 1280,
-	/*.encoded_bytes_per_frame */ 43,
+	/*.encoded_bytes_per_frame */ 0,
 	/*.number_of_channels */ 1,
 	/*.pref_frames_per_packet */ 1,
 	/*.max_frames_per_packet */ 1,
@@ -295,7 +294,7 @@
 	/*.nanoseconds_per_frame */ 20000,
 	/*.samples_per_frame */ 320,
 	/*.bytes_per_frame */ 640,
-	/*.encoded_bytes_per_frame */ 43,
+	/*.encoded_bytes_per_frame */ 0,
 	/*.number_of_channels */ 1,
 	/*.pref_frames_per_packet */ 1,
 	/*.max_frames_per_packet */ 1,
@@ -315,7 +314,7 @@
 	/*.nanoseconds_per_frame */ 20000,
 	/*.samples_per_frame */ 160,
 	/*.bytes_per_frame */ 320,
-	/*.encoded_bytes_per_frame */ 29,
+	/*.encoded_bytes_per_frame */ 0,
 	/*.number_of_channels */ 1,
 	/*.pref_frames_per_packet */ 1,
 	/*.max_frames_per_packet */ 1,

Modified: freeswitch/trunk/src/mod/endpoints/mod_dingaling/mod_dingaling.c
==============================================================================
--- freeswitch/trunk/src/mod/endpoints/mod_dingaling/mod_dingaling.c	(original)
+++ freeswitch/trunk/src/mod/endpoints/mod_dingaling/mod_dingaling.c	Tue Jul 18 14:34:42 2006
@@ -291,15 +291,15 @@
 	}
 
 	if (!(tech_pvt->rtp_session = switch_rtp_new(tech_pvt->profile->ip,
-						     tech_pvt->local_port,
-						     tech_pvt->remote_ip,
-						     tech_pvt->remote_port,
-						     tech_pvt->codec_num,
-						     tech_pvt->read_codec.implementation->encoded_bytes_per_frame,
-						     tech_pvt->read_codec.implementation->microseconds_per_frame,
-						     flags,
-						     NULL,
-						     &err, switch_core_session_get_pool(tech_pvt->session)))) {
+												 tech_pvt->local_port,
+												 tech_pvt->remote_ip,
+												 tech_pvt->remote_port,
+												 tech_pvt->codec_num,
+												 0,
+												 tech_pvt->read_codec.implementation->microseconds_per_frame,
+												 flags,
+												 NULL,
+												 &err, switch_core_session_get_pool(tech_pvt->session)))) {
 		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "RTP ERROR %s\n", err);
 		switch_channel_hangup(channel, SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER);
 		return -1;
@@ -784,8 +784,12 @@
 		}
 
 		if (tech_pvt->read_frame.datalen > 0) {
-			bytes = tech_pvt->read_codec.implementation->encoded_bytes_per_frame;
-			frames = (tech_pvt->read_frame.datalen / bytes);
+			if (tech_pvt->read_codec.implementation->encoded_bytes_per_frame) {
+				bytes = tech_pvt->read_codec.implementation->encoded_bytes_per_frame;
+				frames = (tech_pvt->read_frame.datalen / bytes);
+			} else {
+				frames = 1;
+			}
 			samples = frames * tech_pvt->read_codec.implementation->samples_per_frame;
 			ms = frames * tech_pvt->read_codec.implementation->microseconds_per_frame;
 			tech_pvt->timestamp_recv += (int32_t) samples;
@@ -841,9 +845,13 @@
 
 	switch_set_flag_locked(tech_pvt, TFLAG_WRITING);
 
+	if (tech_pvt->read_codec.implementation->encoded_bytes_per_frame) {
+		bytes = tech_pvt->read_codec.implementation->encoded_bytes_per_frame;
+		frames = ((int) frame->datalen / bytes);
+	} else {
+		frames = 1;
+	}
 
-	bytes = tech_pvt->read_codec.implementation->encoded_bytes_per_frame;
-	frames = ((int) frame->datalen / bytes);
 	samples = frames * tech_pvt->read_codec.implementation->samples_per_frame;
 
 	//printf("%s send %d bytes %d samples in %d frames ts=%d\n", switch_channel_get_name(channel), frame->datalen, samples, frames, tech_pvt->timestamp_send);

Modified: freeswitch/trunk/src/mod/endpoints/mod_exosip/mod_exosip.c
==============================================================================
--- freeswitch/trunk/src/mod/endpoints/mod_exosip/mod_exosip.c	(original)
+++ freeswitch/trunk/src/mod/endpoints/mod_exosip/mod_exosip.c	Tue Jul 18 14:34:42 2006
@@ -562,7 +562,7 @@
 										   tech_pvt->remote_sdp_audio_ip,
 										   tech_pvt->remote_sdp_audio_port,
 										   tech_pvt->read_codec.implementation->ianacode,
-										   tech_pvt->read_codec.implementation->encoded_bytes_per_frame,
+										   0, //tech_pvt->read_codec.implementation->encoded_bytes_per_frame,
 										   ms,
 										   flags,
 										   key,
@@ -718,8 +718,12 @@
 
 			if (tech_pvt->read_frame.datalen > 0) {
 				tech_pvt->last_read = switch_time_now();
-				bytes = tech_pvt->read_codec.implementation->encoded_bytes_per_frame;
-				frames = (tech_pvt->read_frame.datalen / bytes);
+				if (tech_pvt->read_codec.implementation->encoded_bytes_per_frame) {
+					bytes = tech_pvt->read_codec.implementation->encoded_bytes_per_frame;
+					frames = (tech_pvt->read_frame.datalen / bytes);
+				} else {
+					frames = 1;
+				}
 				samples = frames * tech_pvt->read_codec.implementation->samples_per_frame;
 				ms = frames * tech_pvt->read_codec.implementation->microseconds_per_frame;
 				tech_pvt->timestamp_recv += (int32_t) samples;
@@ -776,8 +780,12 @@
 	switch_set_flag_locked(tech_pvt, TFLAG_WRITING);
 
 	if (switch_test_flag(tech_pvt, TFLAG_USING_CODEC)) {
-		bytes = tech_pvt->read_codec.implementation->encoded_bytes_per_frame;
-		frames = ((int) frame->datalen / bytes);
+		if (tech_pvt->read_codec.implementation->encoded_bytes_per_frame) {
+			bytes = tech_pvt->read_codec.implementation->encoded_bytes_per_frame;
+			frames = ((int) frame->datalen / bytes);
+		} else {
+			frames = 1;
+		}
 		samples = frames * tech_pvt->read_codec.implementation->samples_per_frame;
 	} else {
 		assert(0);

Modified: freeswitch/trunk/src/mod/endpoints/mod_iax/mod_iax.c
==============================================================================
--- freeswitch/trunk/src/mod/endpoints/mod_iax/mod_iax.c	(original)
+++ freeswitch/trunk/src/mod/endpoints/mod_iax/mod_iax.c	Tue Jul 18 14:34:42 2006
@@ -1099,8 +1099,12 @@
 							break;
 						}
 
-						bytes = tech_pvt->read_codec.implementation->encoded_bytes_per_frame;
-						frames = (int) (tech_pvt->read_frame.datalen / bytes);
+						if (tech_pvt->read_codec.implementation->encoded_bytes_per_frame) {
+							bytes = tech_pvt->read_codec.implementation->encoded_bytes_per_frame;
+							frames = (int) (tech_pvt->read_frame.datalen / bytes);
+						} else {
+							frames = 1;
+						}
 
 
 						tech_pvt->read_frame.samples = frames * tech_pvt->read_codec.implementation->samples_per_frame;

Modified: freeswitch/trunk/src/switch_rtp.c
==============================================================================
--- freeswitch/trunk/src/switch_rtp.c	(original)
+++ freeswitch/trunk/src/switch_rtp.c	Tue Jul 18 14:34:42 2006
@@ -796,10 +796,11 @@
 				
 					switch_sockaddr_ip_get(&tx_host, rtp_session->from_addr);
 					switch_sockaddr_ip_get(&old_host, rtp_session->remote_addr);
-					
-					switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "Auto Changing port from %s:%u to %s:%u\n",
-									  old_host, old, tx_host, rtp_session->from_addr->port);
-					switch_rtp_set_remote_address(rtp_session, tx_host, rtp_session->from_addr->port, &err);
+					if (!switch_strlen_zero(tx_host) && rtp_session->from_addr->port > 0) {
+						switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "Auto Changing port from %s:%u to %s:%u\n",
+										  old_host, old, tx_host, rtp_session->from_addr->port);
+						switch_rtp_set_remote_address(rtp_session, tx_host, rtp_session->from_addr->port, &err);
+					}
 				}
 				switch_clear_flag(rtp_session, SWITCH_RTP_FLAG_AUTOADJ);
 			}
@@ -1083,7 +1084,8 @@
 	
 	if (switch_test_flag(rtp_session, SWITCH_RTP_FLAG_VAD) && 
 		rtp_session->recv_msg.header.pt == rtp_session->vad_data.read_codec->implementation->ianacode &&
-		datalen == rtp_session->vad_data.read_codec->implementation->encoded_bytes_per_frame) {
+		((datalen == rtp_session->vad_data.read_codec->implementation->encoded_bytes_per_frame) || 
+		 (datalen > SWITCH_RTP_CNG_PAYLOAD && rtp_session->vad_data.read_codec->implementation->encoded_bytes_per_frame == 0))) {
 		int16_t decoded[SWITCH_RECCOMMENDED_BUFFER_SIZE/sizeof(int16_t)];
 		uint32_t rate;
 		uint32_t flags;



More information about the Freeswitch-svn mailing list