summaryrefslogtreecommitdiff
path: root/res
diff options
context:
space:
mode:
authorMark Michelson <mmichelson@digium.com>2016-11-16 15:42:39 -0600
committerMark Michelson <mmichelson@digium.com>2016-11-16 15:42:39 -0600
commit2c031b67d3c7da83bab914bcdaad45d2a0bc9ff8 (patch)
tree2ca3db534d3d8778116855aff6b2159dc5beb9d7 /res
parenta58d3597019f8cc5a503f140671232ae3f8d9119 (diff)
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
Diffstat (limited to 'res')
-rw-r--r--res/res_format_attr_opus.c10
1 files changed, 6 insertions, 4 deletions
diff --git a/res/res_format_attr_opus.c b/res/res_format_attr_opus.c
index 12b910593..49382f6aa 100644
--- a/res/res_format_attr_opus.c
+++ b/res/res_format_attr_opus.c
@@ -158,7 +158,8 @@ static struct ast_format *opus_parse_sdp_fmtp(const struct ast_format *format, c
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) {
/*
@@ -169,7 +170,8 @@ static void opus_generate_sdp_fmtp(const struct ast_format *format, unsigned int
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;",
@@ -211,8 +213,8 @@ static void opus_generate_sdp_fmtp(const struct ast_format *format, unsigned int
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");