[Freeswitch-svn] [commit] r5968 - in freeswitch/trunk/src/mod: codecs/mod_g722 endpoints/mod_sofia

Freeswitch SVN anthm at freeswitch.org
Thu Oct 18 12:32:32 EDT 2007


Author: anthm
Date: Thu Oct 18 12:32:32 2007
New Revision: 5968

Modified:
   freeswitch/trunk/src/mod/codecs/mod_g722/mod_g722.c
   freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia_glue.c

Log:
stupid g722

Modified: freeswitch/trunk/src/mod/codecs/mod_g722/mod_g722.c
==============================================================================
--- freeswitch/trunk/src/mod/codecs/mod_g722/mod_g722.c	(original)
+++ freeswitch/trunk/src/mod/codecs/mod_g722/mod_g722.c	Thu Oct 18 12:32:32 2007
@@ -143,7 +143,7 @@
 	/*.ianacode */ 9,
 	/*.iananame */ "G722",
 	/*.fmtp */ NULL,
-	/*.samples_per_second */ 8000,
+	/*.samples_per_second */ 16000,
 	/*.bits_per_second */ 64000,
 	/*.microseconds_per_frame */ 20000,
 	/*.samples_per_frame */ 160,

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	Thu Oct 18 12:32:32 2007
@@ -87,12 +87,19 @@
 		snprintf(buf + strlen(buf), sizeof(buf) - strlen(buf), " %d", tech_pvt->pt);
 	} else if (tech_pvt->num_codecs) {
 		int i;
+		int already_did[256] = { 0 };
 		for (i = 0; i < tech_pvt->num_codecs; i++) {
 			const switch_codec_implementation_t *imp = tech_pvt->codecs[i];
 
 			if (imp->codec_type != SWITCH_CODEC_TYPE_AUDIO) {
 				continue;
 			}
+			
+			if (already_did[imp->ianacode]) {
+				continue;
+			}
+
+			already_did[imp->ianacode] = 1;
 
 			snprintf(buf + strlen(buf), sizeof(buf) - strlen(buf), " %d", imp->ianacode);
 			if (!ptime) {
@@ -113,6 +120,9 @@
 
 	if (tech_pvt->rm_encoding) {
 		rate = tech_pvt->rm_rate;
+		if (tech_pvt->pt == 9) {
+			rate = 8000;
+		}
 		snprintf(buf + strlen(buf), sizeof(buf) - strlen(buf), "a=rtpmap:%d %s/%d\n", tech_pvt->pt, tech_pvt->rm_encoding, rate);
 		if (tech_pvt->fmtp_out) {
 			snprintf(buf + strlen(buf), sizeof(buf) - strlen(buf), "a=fmtp:%d %s\n", tech_pvt->pt, tech_pvt->fmtp_out);
@@ -123,6 +133,7 @@
 
 	} else if (tech_pvt->num_codecs) {
 		int i;
+		int already_did[256] = { 0 };
 		for (i = 0; i < tech_pvt->num_codecs; i++) {
 			const switch_codec_implementation_t *imp = tech_pvt->codecs[i];
 
@@ -130,12 +141,20 @@
 				continue;
 			}
 
+			if (already_did[imp->ianacode]) {
+				continue;
+			}
+
+			already_did[imp->ianacode] = 1;
+			
 			rate = imp->samples_per_second;
 			
 			if (ptime && ptime != imp->microseconds_per_frame / 1000) {
 				switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "ptime %u != advertised ptime %u\n", imp->microseconds_per_frame / 1000, ptime);
 			}
-
+			if (imp->ianacode == 9) {
+				rate = 8000;
+			}
 			snprintf(buf + strlen(buf), sizeof(buf) - strlen(buf), "a=rtpmap:%d %s/%d\n", imp->ianacode, imp->iananame, rate);
 			if (imp->fmtp) {
 				snprintf(buf + strlen(buf), sizeof(buf) - strlen(buf), "a=fmtp:%d %s\n", imp->ianacode, imp->fmtp);
@@ -170,6 +189,7 @@
 				snprintf(buf + strlen(buf), sizeof(buf) - strlen(buf), " %d", tech_pvt->video_pt);
 			} else if (tech_pvt->num_codecs) {
 				int i;
+				int already_did[256] = { 0 };
 				for (i = 0; i < tech_pvt->num_codecs; i++) {
 					const switch_codec_implementation_t *imp = tech_pvt->codecs[i];
 				
@@ -177,6 +197,12 @@
 						continue;
 					}
 				
+					if (already_did[imp->ianacode]) {
+						continue;
+					}
+
+					already_did[imp->ianacode] = 1;
+
 					snprintf(buf + strlen(buf), sizeof(buf) - strlen(buf), " %d", imp->ianacode);
 					if (!ptime) {
 						ptime = imp->microseconds_per_frame / 1000;
@@ -194,6 +220,7 @@
 				}
 			} else if (tech_pvt->num_codecs) {
 				int i;
+				int already_did[256] = { 0 };
 				for (i = 0; i < tech_pvt->num_codecs; i++) {
 					const switch_codec_implementation_t *imp = tech_pvt->codecs[i];
 				
@@ -201,6 +228,12 @@
 						continue;
 					}
 
+					if (already_did[imp->ianacode]) {
+						continue;
+					}
+					
+					already_did[imp->ianacode] = 1;
+
 					if (!rate) {
 						rate = imp->samples_per_second;
 					}



More information about the Freeswitch-svn mailing list