Revision
16898
Author
anthm
Date
2010-03-04 11:16:19 -0600 (Thu, 04 Mar 2010)

Log Message

move exception for iLBC hack to sdp up to sofia (see Moc if anything breaks)

Modified Paths

Diff

Modified: freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia_glue.c (16897 => 16898)


--- freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia_glue.c	2010-03-04 16:51:24 UTC (rev 16897)
+++ freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia_glue.c	2010-03-04 17:16:19 UTC (rev 16898)
@@ -3222,6 +3222,7 @@
 	sdp_attribute_t *attr;
 	int first = 0, last = 0;
 	int ptime = 0, dptime = 0, maxptime = 0, dmaxptime = 0;
+	int codec_ms = 0;
 	int sendonly = 0;
 	int greedy = 0, x = 0, skip = 0, mine = 0;
 	switch_channel_t *channel = switch_core_session_get_channel(session);
@@ -3523,6 +3524,21 @@
 					ptime = 20;
 				}
 
+				if (!strcasecmp((char *) rm_encoding, "ilbc")) {
+					char *mode = NULL;
+					if ((mode = strstr(map->rm_fmtp, "mode=")) && mode) {
+						codec_ms = atoi(mode + 5);
+					}
+					if (!codec_ms) {
+						/* default to 30 when no mode is defined for ilbc ONLY */
+						codec_ms = 30;
+					}
+				} else {
+					codec_ms = ptime;
+				}
+				
+
+
 				for (i = first; i < last && i < tech_pvt->num_codecs; i++) {
 					const switch_codec_implementation_t *imp = tech_pvt->codecs[i];
 					uint32_t codec_rate = imp->samples_per_second;
@@ -3531,7 +3547,7 @@
 					}
 
 					switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "Audio Codec Compare [%s:%d:%u:%d]/[%s:%d:%u:%d]\n",
-									  rm_encoding, map->rm_pt, (int) map->rm_rate, ptime,
+									  rm_encoding, map->rm_pt, (int) map->rm_rate, codec_ms,
 									  imp->iananame, imp->ianacode, codec_rate, imp->microseconds_per_packet / 1000);
 					if ((zstr(map->rm_encoding) || (tech_pvt->profile->ndlb & PFLAG_NDLB_ALLOW_BAD_IANANAME)) && map->rm_pt < 96) {
 						match = (map->rm_pt == imp->ianacode) ? 1 : 0;
@@ -3545,7 +3561,7 @@
 											  "Bah HUMBUG! Sticking with %s@%uh@%ui\n",
 											  imp->iananame, imp->samples_per_second, imp->microseconds_per_packet / 1000);
 						} else {
-							if ((ptime && ptime * 1000 != imp->microseconds_per_packet) || map->rm_rate != codec_rate) {
+							if ((codec_ms && codec_ms * 1000 != imp->microseconds_per_packet) || map->rm_rate != codec_rate) {
 								near_rate = map->rm_rate;
 								near_match = imp;
 								match = 0;
@@ -3565,7 +3581,7 @@
 					char tmp[80];
 					int num;
 
-					switch_snprintf(tmp, sizeof(tmp), "%s@%uh@%ui", near_match->iananame, near_rate ? near_rate : near_match->samples_per_second, ptime);
+					switch_snprintf(tmp, sizeof(tmp), "%s@%uh@%ui", near_match->iananame, near_rate ? near_rate : near_match->samples_per_second, codec_ms);
 
 					prefs[0] = tmp;
 					num = switch_loadable_module_get_codecs_sorted(search, 1, prefs, 1);
@@ -3598,12 +3614,7 @@
 					tech_pvt->iananame = switch_core_session_strdup(session, (char *) mimp->iananame);
 					tech_pvt->pt = (switch_payload_t) map->rm_pt;
 					tech_pvt->rm_rate = map->rm_rate;
-					if (!strcasecmp((char *) mimp->iananame, "ilbc") && zstr((char *) map->rm_fmtp)) {
-						/* default to 30 when no mode is defined for ilbc ONLY */
-						tech_pvt->codec_ms = 30;
-					} else {
-						tech_pvt->codec_ms = mimp->microseconds_per_packet / 1000;
-					}
+					tech_pvt->codec_ms = mimp->microseconds_per_packet / 1000;
 					tech_pvt->remote_sdp_audio_ip = switch_core_session_strdup(session, (char *) connection->c_address);
 					tech_pvt->rm_fmtp = switch_core_session_strdup(session, (char *) map->rm_fmtp);
 					tech_pvt->remote_sdp_audio_port = (switch_port_t) m->m_port;

Modified: freeswitch/trunk/src/switch_core_codec.c (16897 => 16898)


--- freeswitch/trunk/src/switch_core_codec.c	2010-03-04 16:51:24 UTC (rev 16897)
+++ freeswitch/trunk/src/switch_core_codec.c	2010-03-04 17:16:19 UTC (rev 16898)
@@ -507,19 +507,6 @@
 		return SWITCH_STATUS_GENERR;
 	}
 
-	if (!strcasecmp(codec_name, "ilbc") && mode && !strncasecmp(mode, "mode=", 5)) {
-		int mms;
-		mode += 5;
-		if (mode) {
-			mms = atoi(mode);
-			if (mms == 20 || mms == 30) {
-				ms = mms;
-			}
-		}
-	} else if (!strcasecmp(codec_name, "ilbc")) {
-		ms = 30;
-	}
-
 	/* If no specific codec interval is requested opt for 20ms above all else because lots of stuff assumes it */
 	if (!ms) {
 		for (iptr = codec_interface->implementations; iptr; iptr = iptr->next) {