summaryrefslogtreecommitdiff
path: root/main/format_cap.c
diff options
context:
space:
mode:
authorDavid Vossel <dvossel@digium.com>2011-02-10 17:12:10 +0000
committerDavid Vossel <dvossel@digium.com>2011-02-10 17:12:10 +0000
commit08460fc094fc0defe5bf678fa6c56b4a404aa728 (patch)
treeb1178c2a1616b098ffab3d86a90daae67a464f6d /main/format_cap.c
parent707cf78c5af4ae221225a0351d79e0ddea5add26 (diff)
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. git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@307433 65c4cc65-6c06-0410-ace0-fbb531ad65f3
Diffstat (limited to 'main/format_cap.c')
-rw-r--r--main/format_cap.c17
1 files changed, 14 insertions, 3 deletions
diff --git a/main/format_cap.c b/main/format_cap.c
index 1d566050f..c8bdd4fa3 100644
--- a/main/format_cap.c
+++ b/main/format_cap.c
@@ -409,7 +409,7 @@ struct ast_format_cap *ast_format_cap_joint(const struct ast_format_cap *cap1, c
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 @@ int ast_format_cap_joint_copy(const struct ast_format_cap *cap1, const struct as
.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;
@@ -433,6 +434,16 @@ int ast_format_cap_joint_copy(const struct ast_format_cap *cap1, const struct as
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)
{
struct ao2_iterator it;