]> git.ipfire.org Git - thirdparty/asterisk.git/commitdiff
bridge: Don't try to match audio formats.
authorJoshua C. Colp <jcolp@sangoma.com>
Mon, 18 May 2020 14:05:56 +0000 (11:05 -0300)
committerJoshua Colp <jcolp@sangoma.com>
Thu, 21 May 2020 15:36:45 +0000 (10:36 -0500)
When bridging channels we were trying to match the audio
formats of both sides in combination with the configured
formats. While this is allowed in SDP in practice this
causes extra reinvites and problems. This change ensures
that audio streams use the formats of the first existing
active audio stream. It is only when other stream types
(like video) exist that this will result in re-negotiation
occurring for those streams only.

ASTERISK-28871

Change-Id: I22f5a3e7db29e00c165e74d05d10856f6086fe47

bridges/bridge_native_rtp.c
bridges/bridge_simple.c

index 19c6ab525b42058c9fe1c51fbb65c2d946b1acb0..efe476ecb221eb0a938a8ec57d0633ef870915d7 100644 (file)
@@ -886,8 +886,6 @@ static struct ast_stream_topology *native_rtp_request_stream_topology_update(
 
        if (audio_formats) {
                for (i = 0; i < ast_stream_topology_get_count(new_topology); ++i) {
-                       struct ast_format_cap *joint;
-
                        stream = ast_stream_topology_get_stream(new_topology, i);
 
                        if (ast_stream_get_type(stream) != AST_MEDIA_TYPE_AUDIO ||
@@ -895,16 +893,8 @@ static struct ast_stream_topology *native_rtp_request_stream_topology_update(
                                continue;
                        }
 
-                       joint = ast_format_cap_alloc(AST_FORMAT_CAP_FLAG_DEFAULT);
-                       if (!joint) {
-                               continue;
-                       }
-
-                       ast_format_cap_append_from_cap(joint, ast_stream_get_formats(stream),
-                               AST_MEDIA_TYPE_AUDIO);
-                       ast_format_cap_append_from_cap(joint, audio_formats, AST_MEDIA_TYPE_AUDIO);
-                       ast_stream_set_formats(stream, joint);
-                       ao2_ref(joint, -1);
+                       /* We haven't actually modified audio_formats so this is safe */
+                       ast_stream_set_formats(stream, (struct ast_format_cap *)audio_formats);
                }
        }
 
index abda774dd58a02d8f579e9b0c241600b739d5930..1e224f782b0d1c8ad0749b6af6c0a9f6f5d4877d 100644 (file)
@@ -90,8 +90,6 @@ static struct ast_stream_topology *simple_bridge_request_stream_topology_update(
 
        if (audio_formats) {
                for (i = 0; i < ast_stream_topology_get_count(new_topology); ++i) {
-                       struct ast_format_cap *joint;
-
                        stream = ast_stream_topology_get_stream(new_topology, i);
 
                        if (ast_stream_get_type(stream) != AST_MEDIA_TYPE_AUDIO ||
@@ -99,16 +97,8 @@ static struct ast_stream_topology *simple_bridge_request_stream_topology_update(
                                continue;
                        }
 
-                       joint = ast_format_cap_alloc(AST_FORMAT_CAP_FLAG_DEFAULT);
-                       if (!joint) {
-                               continue;
-                       }
-
-                       ast_format_cap_append_from_cap(joint, ast_stream_get_formats(stream),
-                               AST_MEDIA_TYPE_AUDIO);
-                       ast_format_cap_append_from_cap(joint, audio_formats, AST_MEDIA_TYPE_AUDIO);
-                       ast_stream_set_formats(stream, joint);
-                       ao2_ref(joint, -1);
+                       /* We haven't actually modified audio_formats so this is safe */
+                       ast_stream_set_formats(stream, (struct ast_format_cap *)audio_formats);
                }
        }