[svn-commits] dvossel: trunk r307433 - in /trunk: channels/ include/asterisk/ main/

SVN commits to the Digium repositories svn-commits at lists.digium.com
Thu Feb 10 11:12:14 CST 2011


Author: dvossel
Date: Thu Feb 10 11:12:10 2011
New Revision: 307433

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=307433
Log:
Fixes bug in chan_sip where nativeformats are not set correctly.

The nativeformats field was being overwritten when it should have been
appended too.  This caused some format capabilities to be lost briefly and
some log warnings to be output.

Modified:
    trunk/channels/chan_sip.c
    trunk/include/asterisk/format_cap.h
    trunk/main/format_cap.c

Modified: trunk/channels/chan_sip.c
URL: http://svnview.digium.com/svn/asterisk/trunk/channels/chan_sip.c?view=diff&rev=307433&r1=307432&r2=307433
==============================================================================
--- trunk/channels/chan_sip.c (original)
+++ trunk/channels/chan_sip.c Thu Feb 10 11:12:10 2011
@@ -8881,8 +8881,8 @@
 		ast_codec_choose(&p->prefs, p->jointcaps, 1, &tmp_fmt);
 
 		ast_format_cap_set(p->owner->nativeformats, &tmp_fmt);
-		ast_format_cap_joint_copy(p->caps, vpeercapability, p->owner->nativeformats);
-		ast_format_cap_joint_copy(p->caps, tpeercapability, p->owner->nativeformats);
+		ast_format_cap_joint_append(p->caps, vpeercapability, p->owner->nativeformats);
+		ast_format_cap_joint_append(p->caps, tpeercapability, p->owner->nativeformats);
 
 		ast_set_read_format(p->owner, &p->owner->readformat);
 		ast_set_write_format(p->owner, &p->owner->writeformat);

Modified: trunk/include/asterisk/format_cap.h
URL: http://svnview.digium.com/svn/asterisk/trunk/include/asterisk/format_cap.h?view=diff&rev=307433&r1=307432&r2=307433
==============================================================================
--- trunk/include/asterisk/format_cap.h (original)
+++ trunk/include/asterisk/format_cap.h Thu Feb 10 11:12:10 2011
@@ -192,6 +192,14 @@
 int ast_format_cap_joint_copy(const struct ast_format_cap *cap1, const struct ast_format_cap *cap2, struct ast_format_cap *result);
 
 /*!
+ * \brief Get joint capability structure, append into result capabilities structure
+ *
+ * \retval 1, joint capabilities exist
+ * \retval 0, joint capabilities do not exist
+ */
+int ast_format_cap_joint_append(const struct ast_format_cap *cap1, const struct ast_format_cap *cap2, struct ast_format_cap *result);
+
+/*!
  * \brief Find out if capability structures have any joint capabilities without
  * returning those capabilities.
  *

Modified: trunk/main/format_cap.c
URL: http://svnview.digium.com/svn/asterisk/trunk/main/format_cap.c?view=diff&rev=307433&r1=307432&r2=307433
==============================================================================
--- trunk/main/format_cap.c (original)
+++ trunk/main/format_cap.c Thu Feb 10 11:12:10 2011
@@ -409,7 +409,7 @@
 	return NULL;
 }
 
-int ast_format_cap_joint_copy(const struct ast_format_cap *cap1, const struct ast_format_cap *cap2, struct ast_format_cap *result)
+static int joint_copy_helper(const struct ast_format_cap *cap1, const struct ast_format_cap *cap2, struct ast_format_cap *result, int append)
 {
 	struct ao2_iterator it;
 	struct ast_format *tmp;
@@ -417,8 +417,9 @@
 		.joint_cap = result,
 		.joint_found = 0,
 	};
-
-	ast_format_cap_remove_all(result);
+	if (!append) {
+		ast_format_cap_remove_all(result);
+	}
 	it = ao2_iterator_init(cap1->formats, cap2->nolock ? AO2_ITERATOR_DONTLOCK : 0);
 	while ((tmp = ao2_iterator_next(&it))) {
 		data.format = tmp;
@@ -431,6 +432,16 @@
 	ao2_iterator_destroy(&it);
 
 	return ao2_container_count(result->formats) ? 1 : 0;
+}
+
+int ast_format_cap_joint_append(const struct ast_format_cap *cap1, const struct ast_format_cap *cap2, struct ast_format_cap *result)
+{
+	return joint_copy_helper(cap1, cap2, result, 1);
+}
+
+int ast_format_cap_joint_copy(const struct ast_format_cap *cap1, const struct ast_format_cap *cap2, struct ast_format_cap *result)
+{
+	return joint_copy_helper(cap1, cap2, result, 0);
 }
 
 struct ast_format_cap *ast_format_cap_get_type(const struct ast_format_cap *cap, enum ast_format_type ftype)




More information about the svn-commits mailing list