[asterisk-commits] res format attr opus: Fix fmtp generation. (asterisk[master])

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Wed Nov 16 23:20:05 CST 2016


Anonymous Coward #1000019 has submitted this change and it was merged. ( https://gerrit.asterisk.org/4462 )

Change subject: res_format_attr_opus: Fix fmtp generation.
......................................................................


res_format_attr_opus: Fix fmtp generation.

res_format_attr_opus assumed that the string being passed into it was
empty. It tried to determine if the only thing it had written was

a=fmtp:<num>

And if it had, it would reset the string. Its calculation was off when
working with chan_sip, though. chan_sip passes the entire built SDP
rather than an empty string. This resulted in always putting an empty
fmtp line in the SDP.

ASTERISK-26520 #close
Reported by scgm11

Change-Id: Ib2e8712d26a47067e5f36d5973577added01dbb5
---
M res/res_format_attr_opus.c
1 file changed, 6 insertions(+), 4 deletions(-)

Approvals:
  Kevin Harwell: Looks good to me, but someone else must approve
  Anonymous Coward #1000019: Verified
  Joshua Colp: Looks good to me, approved



diff --git a/res/res_format_attr_opus.c b/res/res_format_attr_opus.c
index a3e48e3..81a07a1 100644
--- a/res/res_format_attr_opus.c
+++ b/res/res_format_attr_opus.c
@@ -156,7 +156,8 @@
 static void opus_generate_sdp_fmtp(const struct ast_format *format, unsigned int payload, struct ast_str **str)
 {
 	struct opus_attr *attr = ast_format_get_attribute_data(format);
-	int size;
+	int base_fmtp_size;
+	int original_size;
 
 	if (!attr) {
 		/*
@@ -167,7 +168,8 @@
 		attr = &default_opus_attr;
 	}
 
-	size = ast_str_append(str, 0, "a=fmtp:%u ", payload);
+	original_size = ast_str_strlen(*str);
+	base_fmtp_size = ast_str_append(str, 0, "a=fmtp:%u ", payload);
 
 	if (CODEC_OPUS_DEFAULT_SAMPLE_RATE != attr->maxplayrate) {
 		ast_str_append(str, 0, "%s=%d;",
@@ -209,8 +211,8 @@
 			CODEC_OPUS_ATTR_DTX, attr->dtx);
 	}
 
-	if (size == ast_str_strlen(*str)) {
-		ast_str_reset(*str);
+	if (base_fmtp_size == ast_str_strlen(*str) - original_size) {
+		ast_str_truncate(*str, original_size);
 	} else {
 		ast_str_truncate(*str, -1);
 		ast_str_append(str, 0, "\r\n");

-- 
To view, visit https://gerrit.asterisk.org/4462
To unsubscribe, visit https://gerrit.asterisk.org/settings

Gerrit-MessageType: merged
Gerrit-Change-Id: Ib2e8712d26a47067e5f36d5973577added01dbb5
Gerrit-PatchSet: 1
Gerrit-Project: asterisk
Gerrit-Branch: master
Gerrit-Owner: Mark Michelson <mmichelson at digium.com>
Gerrit-Reviewer: Anonymous Coward #1000019
Gerrit-Reviewer: Joshua Colp <jcolp at digium.com>
Gerrit-Reviewer: Kevin Harwell <kharwell at digium.com>



More information about the asterisk-commits mailing list