[Asterisk-code-review] bridge: Don't try to match audio formats. (asterisk[master])

Friendly Automation asteriskteam at digium.com
Thu May 21 10:34:34 CDT 2020


Friendly Automation has submitted this change. ( https://gerrit.asterisk.org/c/asterisk/+/14440 )

Change subject: bridge: Don't try to match audio formats.
......................................................................

bridge: Don't try to match audio formats.

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
---
M bridges/bridge_native_rtp.c
M bridges/bridge_simple.c
2 files changed, 4 insertions(+), 24 deletions(-)

Approvals:
  Kevin Harwell: Looks good to me, but someone else must approve
  George Joseph: Looks good to me, approved
  Friendly Automation: Approved for Submit



diff --git a/bridges/bridge_native_rtp.c b/bridges/bridge_native_rtp.c
index 19c6ab5..efe476e 100644
--- a/bridges/bridge_native_rtp.c
+++ b/bridges/bridge_native_rtp.c
@@ -886,8 +886,6 @@
 
 	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 @@
 				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);
 		}
 	}
 
diff --git a/bridges/bridge_simple.c b/bridges/bridge_simple.c
index abda774..1e224f7 100644
--- a/bridges/bridge_simple.c
+++ b/bridges/bridge_simple.c
@@ -90,8 +90,6 @@
 
 	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 @@
 				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);
 		}
 	}
 

-- 
To view, visit https://gerrit.asterisk.org/c/asterisk/+/14440
To unsubscribe, or for help writing mail filters, visit https://gerrit.asterisk.org/settings

Gerrit-Project: asterisk
Gerrit-Branch: master
Gerrit-Change-Id: I22f5a3e7db29e00c165e74d05d10856f6086fe47
Gerrit-Change-Number: 14440
Gerrit-PatchSet: 2
Gerrit-Owner: Joshua Colp <jcolp at sangoma.com>
Gerrit-Reviewer: Friendly Automation
Gerrit-Reviewer: George Joseph <gjoseph at digium.com>
Gerrit-Reviewer: Kevin Harwell <kharwell at digium.com>
Gerrit-MessageType: merged
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.digium.com/pipermail/asterisk-code-review/attachments/20200521/c91a349c/attachment.html>


More information about the asterisk-code-review mailing list