[svn-commits] file: branch file/mf-attributes r417739 - /team/file/mf-attributes/res/

SVN commits to the Digium repositories svn-commits at lists.digium.com
Tue Jul 1 19:54:39 CDT 2014


Author: file
Date: Tue Jul  1 19:54:34 2014
New Revision: 417739

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=417739
Log:
Move res_format_attr_h263 over.

Modified:
    team/file/mf-attributes/res/res_format_attr_h263.c

Modified: team/file/mf-attributes/res/res_format_attr_h263.c
URL: http://svnview.digium.com/svn/asterisk/team/file/mf-attributes/res/res_format_attr_h263.c?view=diff&rev=417739&r1=417738&r2=417739
==============================================================================
--- team/file/mf-attributes/res/res_format_attr_h263.c (original)
+++ team/file/mf-attributes/res/res_format_attr_h263.c Tue Jul  1 19:54:34 2014
@@ -89,24 +89,16 @@
 	return 0;
 }
 
-static int h263_format_attr_get_joint(const struct ast_format_attr *fattr1, const struct ast_format_attr *fattr2, struct ast_format_attr *result)
-{
-	int i;
-
-	/* These are all receiver options so we just copy over what they sent */
-	for (i = H263_ATTR_KEY_SQCIF; i < H263_ATTR_KEY_END; i++) {
-		result->format_attr[i] = fattr1->format_attr[i] ? fattr1->format_attr[i] : fattr2->format_attr[i];
-	}
-
-	return 0;
+static struct ast_format *h263_getjoint(const struct ast_format *format1, const struct ast_format *format2)
+{
+	return ast_format_clone(format1);
 }
 
 static struct ast_format *h263_sdp_parse(const struct ast_format *format, const char *attributes)
 {
 	char *attribs = ast_strdupa(attributes), *attrib;
 	struct ast_format *cloned;
-	struct celt_attr *attr;
-	unsigned int val;
+	struct h263_attr *attr;
 
 	cloned = ast_format_clone(format);
 	if (!cloned) {
@@ -163,109 +155,64 @@
 	return cloned;
 }
 
-static void h263_format_attr_sdp_generate(const struct ast_format_attr *format_attr, unsigned int payload, struct ast_str **str)
-{
-	int i, added = 0;
-
-	for (i = H263_ATTR_KEY_SQCIF; i < H263_ATTR_KEY_END; i++) {
-		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:%u 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]);
-				added = 1;
-			} else {
-				ast_str_append(str, 0, ";CUSTOM=%u,%u,%u", 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]);
-			}
-		} 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:%u PAR=%u:%u", payload, format_attr->format_attr[H263_ATTR_KEY_PAR_WIDTH],
-					       format_attr->format_attr[H263_ATTR_KEY_PAR_HEIGHT]);
-				added = 1;
-			} else {
-				ast_str_append(str, 0, ";PAR=%u:%u", format_attr->format_attr[H263_ATTR_KEY_PAR_WIDTH],
-					       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:%u P=%u", payload, format_attr->format_attr[H263_ATTR_KEY_P_SUB1]);
-				added = 1;
-			} else {
-				ast_str_append(str, 0, ";P=%u", format_attr->format_attr[H263_ATTR_KEY_P_SUB1]);
-			}
-
-			if (format_attr->format_attr[H263_ATTR_KEY_P_SUB2]) {
-				ast_str_append(str, 0, ",%u", format_attr->format_attr[H263_ATTR_KEY_P_SUB2]);
-			}
-                        if (format_attr->format_attr[H263_ATTR_KEY_P_SUB3]) {
-                                ast_str_append(str, 0, ",%u", format_attr->format_attr[H263_ATTR_KEY_P_SUB3]);
-                        }
-                        if (format_attr->format_attr[H263_ATTR_KEY_P_SUB4]) {
-                                ast_str_append(str, 0, ",%u", format_attr->format_attr[H263_ATTR_KEY_P_SUB4]);
-                        }
-
-		} else if ((name = h263_attr_key_to_str(i, format_attr))) {
-			if (!added) {
-				ast_str_append(str, 0, "a=fmtp:%u %s=%u", payload, name, format_attr->format_attr[i]);
-				added = 1;
-			} else {
-				ast_str_append(str, 0, ";%s=%u", name, format_attr->format_attr[i]);
-			}
-		}
-	}
-
-	if (added) {
-		ast_str_append(str, 0, "\r\n");
-	}
+static void h263_sdp_generate(const struct ast_format *format, unsigned int payload, struct ast_str **str)
+{
+	struct h263_attr *attr = ast_format_get_attribute_data(format);
+
+	if (!attr) {
+		return;
+	}
+
+	ast_str_append(str, 0, "a=fmtp:%d SQCIF=%u;QCIF=%u;CIF=%u;CIF4=%u;CIF16=%u;VGA=%u;F=%u;I=%u;J=%u;T=%u;K=%u;N=%u;BPP=%u;HRD=%u",
+		payload, attr->SQCIF, attr->QCIF, attr->CIF, attr->CIF4, attr->CIF16, attr->VGA, attr->F, attr->I, attr->J,
+		attr->T, attr->K, attr->N, attr->BPP, attr->HRD);
+
+	if (attr->CUSTOM_XMAX && attr->CUSTOM_YMAX && attr->CUSTOM_MPI) {
+		ast_str_append(str, 0, ";CUSTOM=%u,%u,%u", attr->CUSTOM_XMAX, attr->CUSTOM_YMAX, attr->CUSTOM_MPI);
+	}
+
+	if (attr->PAR_WIDTH && attr->PAR_HEIGHT) {
+		ast_str_append(str, 0, ";PAR=%u:%u", attr->PAR_WIDTH, attr->PAR_HEIGHT);
+	}
+
+	if (attr->P_SUB1) {
+		ast_str_append(str, 0, ";P=%u", attr->P_SUB1);
+		if (attr->P_SUB2) {
+			ast_str_append(str, 0, ",%u", attr->P_SUB2);
+		}
+		if (attr->P_SUB3) {
+			ast_str_append(str, 0, ",%u", attr->P_SUB3);
+		}
+		if (attr->P_SUB4) {
+			ast_str_append(str, 0, ",%u", attr->P_SUB4);
+		}
+	}
+
+	ast_str_append(str, 0, "\r\n");
 
 	return;
 }
 
-static struct ast_format_attr_interface h263_format_attr_interface = {
-	.id = AST_FORMAT_H263,
-	.format_attr_get_joint = h263_format_attr_get_joint,
-	.format_attr_sdp_parse = h263_format_attr_sdp_parse,
-	.format_attr_sdp_generate = h263_format_attr_sdp_generate,
+static struct ast_format_interface h263_interface = {
+	.format_destroy = h263_destroy,
+	.format_clone = h263_clone,
+	.format_get_joint = h263_getjoint,
+	.format_sdp_parse = h263_sdp_parse,
+	.format_sdp_generate = h263_sdp_generate,
 };
 
-static struct ast_format_attr_interface h263p_format_attr_interface = {
-    .id = AST_FORMAT_H263_PLUS,
-	.format_attr_get_joint = h263_format_attr_get_joint,
-    .format_attr_sdp_parse = h263_format_attr_sdp_parse,
-    .format_attr_sdp_generate = h263_format_attr_sdp_generate,
-};
-
 static int unload_module(void)
 {
-	ast_format_attr_unreg_interface(&h263_format_attr_interface);
-	ast_format_attr_unreg_interface(&h263p_format_attr_interface);
-
 	return 0;
 }
 
 static int load_module(void)
 {
-	if (ast_format_attr_reg_interface(&h263_format_attr_interface)) {
+	if (ast_format_interface_register("h263", &h263_interface)) {
 		return AST_MODULE_LOAD_DECLINE;
 	}
 
-	if (ast_format_attr_reg_interface(&h263p_format_attr_interface)) {
-		ast_format_attr_unreg_interface(&h263_format_attr_interface);
+	if (ast_format_interface_register("h263p", &h263_interface)) {
 		return AST_MODULE_LOAD_DECLINE;
 	}
 




More information about the svn-commits mailing list