[asterisk-commits] file: branch file/media-attrib-sdp r369407 - /team/file/media-attrib-sdp/res/

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Tue Jun 26 12:04:49 CDT 2012


Author: file
Date: Tue Jun 26 12:04:47 2012
New Revision: 369407

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=369407
Log:
Don't place unspecified attributes into SDP.

Modified:
    team/file/media-attrib-sdp/res/res_format_attr_h263.c

Modified: team/file/media-attrib-sdp/res/res_format_attr_h263.c
URL: http://svnview.digium.com/svn/asterisk/team/file/media-attrib-sdp/res/res_format_attr_h263.c?view=diff&rev=369407&r1=369406&r2=369407
==============================================================================
--- team/file/media-attrib-sdp/res/res_format_attr_h263.c (original)
+++ team/file/media-attrib-sdp/res/res_format_attr_h263.c Tue Jun 26 12:04:47 2012
@@ -131,21 +131,21 @@
 }
 
 /*! \brief Helper function which converts a key enum into a string value for SDP */
-static const char *h263_attr_key_to_str(enum h263_attr_keys key)
+static const char *h263_attr_key_to_str(enum h263_attr_keys key, const struct ast_format_attr *format_attr)
 {
 	switch (key) {
 	case H263_ATTR_KEY_SQCIF:
-		return "SQCIF";
+		return format_attr->format_attr[key] ? "SQCIF" : NULL;
 	case H263_ATTR_KEY_QCIF:
-		return "QCIF";
+		return format_attr->format_attr[key] ? "QCIF" : NULL;
 	case H263_ATTR_KEY_CIF:
-		return "CIF";
+		return format_attr->format_attr[key] ? "CIF" : NULL;
 	case H263_ATTR_KEY_CIF4:
-		return "CIF4";
+		return format_attr->format_attr[key] ? "CIF4" : NULL;
 	case H263_ATTR_KEY_CIF16:
-		return "CIF16";
+		return format_attr->format_attr[key] ? "CIF16" : NULL;
 	case H263_ATTR_KEY_VGA:
-		return "VGA";
+		return format_attr->format_attr[key] ? "VGA" : NULL;
 	case H263_ATTR_KEY_F:
 		return "F";
 	case H263_ATTR_KEY_I:
@@ -187,6 +187,11 @@
 		const char *name;
 
 		if (i == H263_ATTR_KEY_CUSTOM_XMAX) {
+			if (!format_attr->format_attr[H263_ATTR_KEY_CUSTOM_XMAX] || !format_attr->format_attr[H263_ATTR_KEY_CUSTOM_YMAX] ||
+			    !format_attr->format_attr[H263_ATTR_KEY_CUSTOM_MPI]) {
+				continue;
+			}
+
 			if (!added) {
 				ast_str_append(str, 0, "a=fmtp:%d CUSTOM=%u,%u,%u", payload, format_attr->format_attr[H263_ATTR_KEY_CUSTOM_XMAX],
 					       format_attr->format_attr[H263_ATTR_KEY_CUSTOM_YMAX], format_attr->format_attr[H263_ATTR_KEY_CUSTOM_MPI]);
@@ -196,6 +201,10 @@
 					       format_attr->format_attr[H263_ATTR_KEY_CUSTOM_YMAX], format_attr->format_attr[H263_ATTR_KEY_CUSTOM_MPI]);
 			}
 		} else if (i == H263_ATTR_KEY_PAR_WIDTH) {
+			if (!format_attr->format_attr[H263_ATTR_KEY_PAR_WIDTH] || !format_attr->format_attr[H263_ATTR_KEY_PAR_HEIGHT]) {
+				continue;
+			}
+
 			if (!added) {
 				ast_str_append(str, 0, "a=fmtp:%d PAR=%u:%u", payload, format_attr->format_attr[H263_ATTR_KEY_PAR_WIDTH],
 					       format_attr->format_attr[H263_ATTR_KEY_PAR_HEIGHT]);
@@ -205,6 +214,10 @@
 					       format_attr->format_attr[H263_ATTR_KEY_PAR_HEIGHT]);
 			}
 		} else if (i == H263_ATTR_KEY_P_SUB1) {
+			if (!format_attr->format_attr[H263_ATTR_KEY_P_SUB1]) {
+				continue;
+			}
+
 			if (!added) {
 				ast_str_append(str, 0, "a=fmtp:%d P=%u", payload, format_attr->format_attr[H263_ATTR_KEY_P_SUB1]);
 				added = 1;
@@ -222,7 +235,7 @@
                                 ast_str_append(str, 0, ",%u", format_attr->format_attr[H263_ATTR_KEY_P_SUB4]);
                         }
 
-		} else if ((name = h263_attr_key_to_str(i))) {
+		} else if ((name = h263_attr_key_to_str(i, format_attr))) {
 			if (!added) {
 				ast_str_append(str, 0, "a=fmtp:%d %s=%u", payload, name, format_attr->format_attr[i]);
 				added = 1;




More information about the asterisk-commits mailing list