--- res/res_format_attr_h264.c (Asterisk 13.6.0) +++ res/res_format_attr_h264.c (working copy) @@ -235,9 +235,9 @@ #define APPEND_IF_NOT_H264_UNSET(field, str, name) do { \ if (field != H264_ATTR_KEY_UNSET) { \ if (added) { \ ast_str_append(str, 0, ";"); \ - } else { \ + } else if (0 < ast_str_append(str, 0, "a=fmtp:%u ", payload)) { \ added = 1; \ } \ ast_str_append(str, 0, "%s=%u", name, field); \ } \ @@ -246,9 +246,9 @@ #define APPEND_IF_NONZERO(field, str, name) do { \ if (field) { \ if (added) { \ ast_str_append(str, 0, ";"); \ - } else { \ + } else if (0 < ast_str_append(str, 0, "a=fmtp:%u ", payload)) { \ added = 1; \ } \ ast_str_append(str, 0, "%s=%u", name, field); \ } \ @@ -262,10 +262,8 @@ if (!attr) { return; } - ast_str_append(str, 0, "a=fmtp:%u ", payload); - APPEND_IF_NONZERO(attr->MAX_MBPS, str, "max-mbps"); APPEND_IF_NONZERO(attr->MAX_FS, str, "max-fs"); APPEND_IF_NONZERO(attr->MAX_CPB, str, "max-cpb"); APPEND_IF_NONZERO(attr->MAX_DPB, str, "max-dpb"); @@ -286,26 +284,24 @@ if (attr->PROFILE_IDC && attr->PROFILE_IOP && attr->LEVEL) { if (added) { ast_str_append(str, 0, ";"); - } else { + } else if (0 < ast_str_append(str, 0, "a=fmtp:%u ", payload)) { added = 1; } ast_str_append(str, 0, "profile-level-id=%02X%02X%02X", attr->PROFILE_IDC, attr->PROFILE_IOP, attr->LEVEL); } if (!ast_strlen_zero(attr->SPS) && !ast_strlen_zero(attr->PPS)) { if (added) { ast_str_append(str, 0, ";"); - } else { + } else if (0 < ast_str_append(str, 0, "a=fmtp:%u ", payload)) { added = 1; } - ast_str_append(str, 0, ";sprop-parameter-sets=%s,%s", attr->SPS, attr->PPS); + ast_str_append(str, 0, "sprop-parameter-sets=%s,%s", attr->SPS, attr->PPS); } - if (!added) { - ast_str_reset(*str); - } else { + if (added) { ast_str_append(str, 0, "\r\n"); } return;