res_pjsip res_pjsip_mwi: Misc fixes and cleanups.
[asterisk/asterisk.git] / res / res_format_attr_h264.c
index 81784bb..ccf2176 100644 (file)
@@ -33,7 +33,7 @@
 
 #include "asterisk.h"
 
-ASTERISK_FILE_VERSION(__FILE__, "$Revision$")
+ASTERISK_REGISTER_FILE()
 
 #include "asterisk/module.h"
 #include "asterisk/format.h"
@@ -153,13 +153,13 @@ static struct ast_format *h264_getjoint(const struct ast_format *format1, const
        if (attr1 && !ast_strlen_zero(attr1->SPS)) {
                ast_copy_string(attr->SPS, attr1->SPS, sizeof(attr->SPS));
        } else if (attr2 && !ast_strlen_zero(attr2->SPS)) {
-               ast_copy_string(attr->SPS, attr1->SPS, sizeof(attr->SPS));
+               ast_copy_string(attr->SPS, attr2->SPS, sizeof(attr->SPS));
        }
 
        if (attr1 && !ast_strlen_zero(attr1->PPS)) {
                ast_copy_string(attr->PPS, attr1->PPS, sizeof(attr->PPS));
        } else if (attr2 && !ast_strlen_zero(attr2->PPS)) {
-               ast_copy_string(attr->PPS, attr1->PPS, sizeof(attr->PPS));
+               ast_copy_string(attr->PPS, attr2->PPS, sizeof(attr->PPS));
        }
 
        return cloned;
@@ -236,7 +236,7 @@ static struct ast_format *h264_parse_sdp_fmtp(const struct ast_format *format, c
        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);   \
@@ -247,7 +247,7 @@ static struct ast_format *h264_parse_sdp_fmtp(const struct ast_format *format, c
        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);   \
@@ -263,8 +263,6 @@ static void h264_generate_sdp_fmtp(const struct ast_format *format, unsigned int
                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");
@@ -287,7 +285,7 @@ static void h264_generate_sdp_fmtp(const struct ast_format *format, unsigned int
        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);
@@ -296,15 +294,13 @@ static void h264_generate_sdp_fmtp(const struct ast_format *format, unsigned int
        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");
        }
 
@@ -335,6 +331,7 @@ static int load_module(void)
 }
 
 AST_MODULE_INFO(ASTERISK_GPL_KEY, AST_MODFLAG_LOAD_ORDER, "H.264 Format Attribute Module",
+       .support_level = AST_MODULE_SUPPORT_CORE,
        .load = load_module,
        .unload = unload_module,
        .load_pri = AST_MODPRI_DEFAULT,