From: Sangchul Lee Date: Mon, 13 Dec 2021 08:17:34 +0000 (+0900) Subject: webrtc_private: Parse fmtp attribute and save useinbandfec value to the handle X-Git-Tag: submit/tizen/20211222.143709^0 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=45fed6a72dea03edb73279def582b7ad7025c2bd;p=platform%2Fcore%2Fapi%2Fwebrtc.git webrtc_private: Parse fmtp attribute and save useinbandfec value to the handle 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 --- diff --git a/include/webrtc_private.h b/include/webrtc_private.h index 6ee9f38f..ada0e61a 100644 --- a/include/webrtc_private.h +++ b/include/webrtc_private.h @@ -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 { diff --git a/packaging/capi-media-webrtc.spec b/packaging/capi-media-webrtc.spec index e609588c..b6dca198 100644 --- a/packaging/capi-media-webrtc.spec +++ b/packaging/capi-media-webrtc.spec @@ -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 diff --git a/src/webrtc_private.c b/src/webrtc_private.c index c78ba563..921f782b 100644 --- a/src/webrtc_private.c +++ b/src/webrtc_private.c @@ -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, ¤t_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' */ } } }