[asterisk-commits] dvossel: branch dvossel/fixtheworld_phase2 r307271 - in /team/dvossel/fixthew...

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Wed Feb 9 14:46:51 CST 2011


Author: dvossel
Date: Wed Feb  9 14:46:47 2011
New Revision: 307271

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=307271
Log:
Make sip advertise SILK attributes correctly

Modified:
    team/dvossel/fixtheworld_phase2/channels/chan_sip.c
    team/dvossel/fixtheworld_phase2/main/format.c

Modified: team/dvossel/fixtheworld_phase2/channels/chan_sip.c
URL: http://svnview.digium.com/svn/asterisk/team/dvossel/fixtheworld_phase2/channels/chan_sip.c?view=diff&rev=307271&r1=307270&r2=307271
==============================================================================
--- team/dvossel/fixtheworld_phase2/channels/chan_sip.c (original)
+++ team/dvossel/fixtheworld_phase2/channels/chan_sip.c Wed Feb  9 14:46:47 2011
@@ -9129,6 +9129,18 @@
 						found = TRUE;
 					}
 				}
+				break;
+			case AST_FORMAT_SILK:
+				{
+					int val = 0;
+					if (sscanf(fmtp_string, "maxaveragebitrate=%30u", &val) == 1) {
+						ast_format_append(&payload.format, SILK_ATTR_KEY_MAX_BITRATE, val);
+					}
+					if (sscanf(fmtp_string, "usedtx=%30u", &val) == 1) {
+						ast_format_append(&payload.format, SILK_ATTR_KEY_DTX, val ? 1 : 0);
+					}
+					break;
+				}
 			}
 		}
 	}
@@ -10489,6 +10501,17 @@
 		/* Indicate that we only expect 64Kbps */
 		ast_str_append(a_buf, 0, "a=fmtp:%d bitrate=64000\r\n", rtp_code);
 		break;
+	case AST_FORMAT_SILK:
+		{
+			int val = 0;
+			if (!ast_format_get_value(format, SILK_ATTR_KEY_MAX_BITRATE, &val)) {
+				ast_str_append(a_buf, 0, "a=fmtp:%d maxaveragebitrate=%u\r\n", rtp_code, val);
+			}
+			if (!ast_format_get_value(format, SILK_ATTR_KEY_DTX, &val)) {
+				ast_str_append(a_buf, 0, "a=fmtp:%d usedtx=%u\r\n", rtp_code, val ? 1 : 0);
+			}
+			break;
+		}
 	}
 
 	if (fmt.cur_ms && (fmt.cur_ms < *min_packet_size))

Modified: team/dvossel/fixtheworld_phase2/main/format.c
URL: http://svnview.digium.com/svn/asterisk/team/dvossel/fixtheworld_phase2/main/format.c?view=diff&rev=307271&r1=307270&r2=307271
==============================================================================
--- team/dvossel/fixtheworld_phase2/main/format.c (original)
+++ team/dvossel/fixtheworld_phase2/main/format.c Wed Feb  9 14:46:47 2011
@@ -1039,7 +1039,7 @@
 	return -1;
 }
 
-static int custom_silk_format(struct ast_format_list *entry, unsigned int maxbitrate)
+static int custom_silk_format(struct ast_format_list *entry, unsigned int maxbitrate, int usedtx)
 {
 	if (!entry->samplespersecond) {
 		ast_log(LOG_WARNING, "Custom SILK format definition '%s' requires sample rate to be defined.\n", entry->name);
@@ -1080,6 +1080,11 @@
 			SILK_ATTR_KEY_MAX_BITRATE, maxbitrate,
 			AST_FORMAT_ATTR_END);
 	}
+	if (usedtx) {
+		ast_format_append(&entry->format,
+			SILK_ATTR_KEY_DTX, 1,
+			AST_FORMAT_ATTR_END);
+	}
 	ast_copy_string(entry->desc, "SILK Custom Format", sizeof(entry->desc));
 	entry->fr_len = 80;
 	entry->min_ms = 20;
@@ -1099,6 +1104,7 @@
 	enum ast_format_id id;
 	int add_it = 0;
 	unsigned int maxbitrate = 0;
+	int usedtx = 0;
 
 	if (cfg == CONFIG_STATUS_FILEMISSING || cfg == CONFIG_STATUS_FILEINVALID)
 		return 0;
@@ -1113,6 +1119,7 @@
 		id = 0;
 		add_it = 0;
 		maxbitrate = 0;
+		usedtx = 0;
 		if (!(ast_variable_retrieve(cfg, cat, "type"))) {
 			continue;
 		}
@@ -1148,12 +1155,14 @@
 				if (sscanf(var->value, "%30u", &maxbitrate) != 1) {
 					ast_log(LOG_WARNING, "maxbitrate '%s' at line %d of %s is not supported.\n", var->value, var->lineno, FORMAT_CONFIG);
 				}
+			} else if (!strcasecmp(var->name, "dtx")) {
+				usedtx = ast_true(var->value) ? 1 : 0;
 			}
 		}
 
 		switch (id) {
 		case AST_FORMAT_SILK:
-			if (!(custom_silk_format(&entry, maxbitrate))) {
+			if (!(custom_silk_format(&entry, maxbitrate, usedtx))) {
 				add_it = 1;
 			}
 			break;




More information about the asterisk-commits mailing list