[svn-commits] file: branch file/media-attrib-sdp r369301 - in /team/file/media-attrib-sdp: ...

SVN commits to the Digium repositories svn-commits at lists.digium.com
Sat Jun 23 13:42:56 CDT 2012


Author: file
Date: Sat Jun 23 13:42:52 2012
New Revision: 369301

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=369301
Log:
Move CELT and SILK SDP logic out into their respective format attribute modules.

Modified:
    team/file/media-attrib-sdp/channels/chan_sip.c
    team/file/media-attrib-sdp/res/res_format_attr_celt.c
    team/file/media-attrib-sdp/res/res_format_attr_silk.c

Modified: team/file/media-attrib-sdp/channels/chan_sip.c
URL: http://svnview.digium.com/svn/asterisk/team/file/media-attrib-sdp/channels/chan_sip.c?view=diff&rev=369301&r1=369300&r2=369301
==============================================================================
--- team/file/media-attrib-sdp/channels/chan_sip.c (original)
+++ team/file/media-attrib-sdp/channels/chan_sip.c Sat Jun 23 13:42:52 2012
@@ -10082,21 +10082,6 @@
 					}
 				}
 				break;
-			case AST_FORMAT_CELT:
-				if (sscanf(fmtp_string, "framesize=%30u", &val) == 1) {
-					ast_format_append(format, CELT_ATTR_KEY_FRAME_SIZE, val, AST_FORMAT_ATTR_END);
-				}
-			case AST_FORMAT_SILK:
-				if (sscanf(fmtp_string, "maxaveragebitrate=%30u", &val) == 1) {
-					ast_format_append(format, SILK_ATTR_KEY_MAX_BITRATE, val, AST_FORMAT_ATTR_END);
-				}
-				if (sscanf(fmtp_string, "usedtx=%30u", &val) == 1) {
-					ast_format_append(format, SILK_ATTR_KEY_DTX, val ? 1 : 0, AST_FORMAT_ATTR_END);
-				}
-				if (sscanf(fmtp_string, "useinbandfec=%30u", &val) == 1) {
-					ast_format_append(format, SILK_ATTR_KEY_FEC, val ? 1 : 0, AST_FORMAT_ATTR_END);
-				}
-				break;
 			}
 		}
 	}
@@ -11564,22 +11549,6 @@
 	case AST_FORMAT_G719:
 		/* 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_CELT:
-		if (!ast_format_get_value(format, CELT_ATTR_KEY_FRAME_SIZE, &val) && val > 0) {
-			ast_str_append(a_buf, 0, "a=fmtp:%d framesize=%u\r\n", rtp_code, val);
-		}
-		break;
-	case AST_FORMAT_SILK:
-		if (!ast_format_get_value(format, SILK_ATTR_KEY_MAX_BITRATE, &val) && val > 5000 && val < 40000) {
-			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);
-		}
-		if (!ast_format_get_value(format, SILK_ATTR_KEY_FEC, &val)) {
-			ast_str_append(a_buf, 0, "a=fmtp:%d useinbandfec=%u\r\n", rtp_code, val ? 1 : 0);
-		}
 		break;
 	}
 

Modified: team/file/media-attrib-sdp/res/res_format_attr_celt.c
URL: http://svnview.digium.com/svn/asterisk/team/file/media-attrib-sdp/res/res_format_attr_celt.c?view=diff&rev=369301&r1=369300&r2=369301
==============================================================================
--- team/file/media-attrib-sdp/res/res_format_attr_celt.c (original)
+++ team/file/media-attrib-sdp/res/res_format_attr_celt.c Sat Jun 23 13:42:52 2012
@@ -44,6 +44,29 @@
 	unsigned int maxbitrate;
 	unsigned int framesize;
 };
+
+static int celt_sdp_parse(struct ast_format_attr *format_attr, const char *attributes)
+{
+	struct celt_attr *attr = (struct celt_attr *) format_attr;
+	unsigned int val;
+
+	if (sscanf(attributes, "framesize=%30u", &val) == 1) {
+		attr->framesize = val;
+	}
+
+	return 0;
+}
+
+static void celt_sdp_generate(const struct ast_format_attr *format_attr, unsigned int payload, struct ast_str **str)
+{
+	struct celt_attr *attr = (struct celt_attr *) format_attr;
+
+	if (!attr->framesize) {
+		return;
+	}
+
+	ast_str_append(str, 0, "a=fmtp:%d framesize=%d\r\n", payload, attr->framesize);
+}
 
 static enum ast_format_cmp_res celt_cmp(const struct ast_format_attr *fattr1, const struct ast_format_attr *fattr2)
 {
@@ -161,6 +184,8 @@
 	.format_attr_set = celt_set,
 	.format_attr_isset = celt_isset,
 	.format_attr_get_val = celt_get_val,
+	.format_attr_sdp_parse = celt_sdp_parse,
+	.format_attr_sdp_generate = celt_sdp_generate,
 };
 
 static int load_module(void)

Modified: team/file/media-attrib-sdp/res/res_format_attr_silk.c
URL: http://svnview.digium.com/svn/asterisk/team/file/media-attrib-sdp/res/res_format_attr_silk.c?view=diff&rev=369301&r1=369300&r2=369301
==============================================================================
--- team/file/media-attrib-sdp/res/res_format_attr_silk.c (original)
+++ team/file/media-attrib-sdp/res/res_format_attr_silk.c Sat Jun 23 13:42:52 2012
@@ -47,6 +47,36 @@
 	unsigned int packetloss_percentage;
 };
 
+static int silk_sdp_parse(struct ast_format_attr *format_attr, const char *attributes)
+{
+	struct silk_attr *attr = (struct silk_attr *) format_attr;
+	unsigned int val;
+
+	if (sscanf(attributes, "maxaveragebitrate=%30u", &val) == 1) {
+		attr->maxbitrate = val;
+	}
+	if (sscanf(attributes, "usedtx=%30u", &val) == 1) {
+		attr->dtx = val;
+	}
+	if (sscanf(attributes, "useinbandfec=%30u", &val) == 1) {
+		attr->fec = val;
+	}
+
+	return 0;
+}
+
+static void silk_sdp_generate(const struct ast_format_attr *format_attr, unsigned int payload, struct ast_str **str)
+{
+	struct silk_attr *attr = (struct silk_attr *) format_attr;
+
+	if ((attr->maxbitrate > 5000) && (attr->maxbitrate < 40000)) { 
+		ast_str_append(str, 0, "a=fmtp:%d maxaveragebitrate=%d\r\n", payload, attr->maxbitrate);
+	}
+
+	ast_str_append(str, 0, "a=fmtp:%d usedtx=%d\r\n", payload, attr->dtx);
+	ast_str_append(str, 0, "a=fmtp:%d useinbandfec=%d\r\n", payload, attr->fec);
+}
+
 static enum ast_format_cmp_res silk_cmp(const struct ast_format_attr *fattr1, const struct ast_format_attr *fattr2)
 {
 	struct silk_attr *attr1 = (struct silk_attr *) fattr1;
@@ -195,6 +225,8 @@
 	.format_attr_set = silk_set,
 	.format_attr_isset = silk_isset,
 	.format_attr_get_val = silk_get_val,
+	.format_attr_sdp_parse = silk_sdp_parse,
+	.format_attr_sdp_generate = silk_sdp_generate,
 };
 
 static int load_module(void)




More information about the svn-commits mailing list