webrtc_private: Parse fmtp attribute and save useinbandfec value to the handle 19/267919/7 accepted/tizen/unified/20211223.215722 submit/tizen/20211222.143709
authorSangchul Lee <sc11.lee@samsung.com>
Mon, 13 Dec 2021 08:17:34 +0000 (17:17 +0900)
committerSangchul Lee <sc11.lee@samsung.com>
Wed, 22 Dec 2021 08:03:50 +0000 (17:03 +0900)
It is parsed from a remote description. This information will be used
to set related property to a decoder.

[Version] 0.3.26
[Issue Type] New feature

Change-Id: Ieef7a244405c617d64b28c069f5f55cbc65fde69
Signed-off-by: Sangchul Lee <sc11.lee@samsung.com>
include/webrtc_private.h
packaging/capi-media-webrtc.spec
src/webrtc_private.c

index 6ee9f38f62ecd4c76d90d8a075c9a91452f1f6c1..ada0e61a5afa7ff90f60aeeddda010f86cf3ae74 100644 (file)
@@ -399,6 +399,10 @@ typedef struct _webrtc_gst_s {
 typedef struct _webrtc_data_recovery_type_s {
        bool red;
        bool ulpfec;
+       struct {
+               int pt;
+               bool use;
+       } inbandfec;
 } webrtc_data_recovery_type_s;
 
 typedef struct _webrtc_negotiation_states_s {
index e609588c580da7823574ba4f09238e8de25fa55e..b6dca19805c479330bafd9353bd16402790a1c4f 100644 (file)
@@ -1,6 +1,6 @@
 Name:       capi-media-webrtc
 Summary:    A WebRTC library in Tizen Native API
-Version:    0.3.25
+Version:    0.3.26
 Release:    0
 Group:      Multimedia/API
 License:    Apache-2.0
index c78ba563415e24e06d7031ae5e396112e9423fe8..921f782baff06ead33937955ee8fc3a32631c656 100644 (file)
@@ -258,14 +258,22 @@ static int __parse_attribute_value(const gchar *value, int *pt, gchar **attr_par
 
 static int __get_pt_and_encoding_info_from_rtpmap_attribute(const gchar *key, const gchar *value, int *pt, gchar **encoding_info)
 {
-       RET_VAL_IF(key == NULL, -1, "key is NULL");
+       RET_VAL_IF(g_strcmp0(key, "rtpmap") != 0, -1, "invalid key[%s]", key);
        RET_VAL_IF(value == NULL, -1, "value is NULL");
        RET_VAL_IF(pt == NULL, -1, "pt is NULL");
        RET_VAL_IF(encoding_info == NULL, -1, "encoding_info is NULL");
-       RET_VAL_IF(strcmp(key, "rtpmap"), -1, "invalid key[%s]", key);
-       RET_VAL_IF(__parse_attribute_value(value, pt, encoding_info), -1, "failed to __parse_attribute_value()");
 
-       return 0;
+       return __parse_attribute_value(value, pt, encoding_info);
+}
+
+static int __get_pt_and_fmt_info_from_fmtp_attribute(const gchar *key, const gchar *value, int *pt, gchar **fmt_info)
+{
+       RET_VAL_IF(g_strcmp0(key, "fmtp") != 0, -1, "invalid key[%s]", key);
+       RET_VAL_IF(value == NULL, -1, "value is NULL");
+       RET_VAL_IF(pt == NULL, -1, "pt is NULL");
+       RET_VAL_IF(fmt_info == NULL, -1, "fmt_info is NULL");
+
+       return __parse_attribute_value(value, pt, fmt_info);
 }
 
 static void __update_data_recovery_type_from_remote_description(webrtc_s *webrtc)
@@ -282,10 +290,13 @@ static void __update_data_recovery_type_from_remote_description(webrtc_s *webrtc
        RET_IF(msg == NULL, "msg is NULL");
 
        for (i = 0; i < gst_sdp_message_medias_len(msg); i++) {
+               int pt = -1;
+
                if (i == MAX_MLINE_NUM) {
                        LOG_ERROR("reach to max mline num[%u]", i);
                        break;
                }
+
                media = gst_sdp_message_get_media(msg, i);
                LOG_DEBUG("mline[%u] media[%s, protocol:%s]", i, media->media, media->proto);
                memset(&webrtc->data_recovery_types[i], 0, sizeof(webrtc_data_recovery_type_s));
@@ -296,7 +307,6 @@ static void __update_data_recovery_type_from_remote_description(webrtc_s *webrtc
                        LOG_VERBOSE(" attr[key:%s, value:%s]", attr->key, attr->value);
 
                        if (!strcmp(attr->key, "rtpmap")) {
-                               int pt;
                                gchar *encoding_info;
 
                                if (__get_pt_and_encoding_info_from_rtpmap_attribute(attr->key, attr->value, &pt, &encoding_info) == -1)
@@ -312,8 +322,22 @@ static void __update_data_recovery_type_from_remote_description(webrtc_s *webrtc
                                }
 
                                g_free(encoding_info);
+
+                       } else if (!strcmp(attr->key, "fmtp")) {
+                               gchar *fmt_info;
+                               int current_pt;
+
+                               if (__get_pt_and_fmt_info_from_fmtp_attribute(attr->key, attr->value, &current_pt, &fmt_info) == -1)
+                                       continue;
+
+                               if ((pt == current_pt) && g_strrstr(fmt_info, "useinbandfec=1")) {
+                                       webrtc->data_recovery_types[i].inbandfec.pt = current_pt;
+                                       webrtc->data_recovery_types[i].inbandfec.use = true;
+                                       LOG_INFO(" inbandfec is set [key:%s, pt:%d, fmt_info:%s]", attr->key, current_pt, fmt_info);
+                               }
+
+                               g_free(fmt_info);
                        }
-                       /* TODO: parsing 'fmtp' */
                }
        }
 }