From: Sangchul Lee Date: Wed, 24 Aug 2022 07:07:08 +0000 (+0900) Subject: webrtc_private: Get mlineindex from source index X-Git-Tag: submit/tizen/20220826.010121~2 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=refs%2Fchanges%2F30%2F280130%2F3;p=platform%2Fcore%2Fapi%2Fwebrtc.git webrtc_private: Get mlineindex from source index It fixes an issue that FEC is not applied when webrtc handle with source(s) is operated as an answerer. Due to the implementation of webrtcbin, only a transceiver created by webrtcbin itself has a valid prop value of mlineindex. Others have -1 value for this. Hence, _update_transceivers_fec() is now using an index of sources as a mlineindex. [Version] 0.3.212 [Issue Type] Bug fix Change-Id: I4e3ead3413effe202e3034d88ec6bf7f2aa0f221 Signed-off-by: Sangchul Lee --- diff --git a/include/webrtc_private.h b/include/webrtc_private.h index cca62f22..e947bbe0 100644 --- a/include/webrtc_private.h +++ b/include/webrtc_private.h @@ -271,7 +271,7 @@ do { \ #define WEBRTC_DISPLAY_TYPE_ECORE_WL 2 #define PAYLOAD_TYPE_BITS 32 /* 96 ~ 127 */ #define TRACK_ID_THRESHOLD_OF_LOOPBACK 100 -#define MAX_MLINE_NUM 16 +#define MAX_MLINE_NUM 32 #define MAX_SOURCE_NUM 32 /* See webrtc_transceiver_codec_e */ diff --git a/packaging/capi-media-webrtc.spec b/packaging/capi-media-webrtc.spec index 715e9d41..fc49e7ce 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.211 +Version: 0.3.212 Release: 0 Group: Multimedia/API License: Apache-2.0 diff --git a/src/webrtc_private.c b/src/webrtc_private.c index ed60b3d3..db6057c9 100644 --- a/src/webrtc_private.c +++ b/src/webrtc_private.c @@ -1519,12 +1519,12 @@ static void __webrtcbin_on_new_transceiver_cb(GstElement *webrtcbin, GstWebRTCRT webrtc, transceiver, mlineindex, mid, direction, kind, user_data); PRINT_CAPS(caps, "codec preferences"); + /* Code below is for the scenario of an answerer without any added media sources. */ if (g_hash_table_size(webrtc->gst.source_slots) == 0) { if (mlineindex >= MAX_MLINE_NUM) { LOG_ERROR("mlineindex[%u] exceeds the max value", mlineindex); return; } - /* In this case, it might be an answerer without setting any media source. */ if (webrtc->data_recovery_types[mlineindex].red && webrtc->data_recovery_types[mlineindex].ulpfec) __webrtcbin_transceiver_set_ulpfec_red(webrtc, transceiver); @@ -1555,28 +1555,22 @@ void _update_transceivers_fec(webrtc_s *webrtc, bool is_offer) { const ini_item_media_source_s *ini_source; GstWebRTCRTPTransceiver *transceiver; - GHashTableIter iter; - gpointer key, value; webrtc_gst_slot_s *source; - int i; - guint mlineindex; + int i, j; GstWebRTCRTPTransceiverDirection direction; RET_IF(webrtc == NULL, "webrtc is NULL"); - g_hash_table_iter_init(&iter, webrtc->gst.source_slots); - while (g_hash_table_iter_next(&iter, &key, &value)) { - source = (webrtc_gst_slot_s *)value; - for (i = AV_IDX_AUDIO; i < AV_IDX_MAX; i++) { - if (!(source->media_types & (i == AV_IDX_AUDIO ? MEDIA_TYPE_AUDIO : MEDIA_TYPE_VIDEO))) + for (i = 0; i < MAX_SOURCE_NUM; i++) { + if (!(source = webrtc->gst.sources[i])) + continue; + for (j = AV_IDX_AUDIO; j < AV_IDX_MAX; j++) { + if (!(source->media_types & (j == AV_IDX_AUDIO ? MEDIA_TYPE_AUDIO : MEDIA_TYPE_VIDEO))) continue; - if (!(transceiver = source->av[i].transceiver)) + if (!(transceiver = source->av[j].transceiver)) continue; - g_object_get(G_OBJECT(transceiver), - "mlineindex", &mlineindex, - "direction", &direction, - NULL); + g_object_get(G_OBJECT(transceiver), "direction", &direction, NULL); ini_source = _ini_get_source_by_type(&webrtc->ini, source->type); if (ini_source == NULL) @@ -1587,14 +1581,8 @@ void _update_transceivers_fec(webrtc_s *webrtc, bool is_offer) continue; __webrtcbin_transceiver_set_ulpfec_red(webrtc, transceiver); } else { - /* NOTE that this maximum value exists only for data_recovery_types due to the scenario an answerer - * without any added media sources. It would be moved to the source slot without this scenario. */ - if (mlineindex >= MAX_MLINE_NUM) { - LOG_ERROR("mline[%u] exceeds the max value", mlineindex); - continue; - } - if (!webrtc->data_recovery_types[mlineindex].red || - !webrtc->data_recovery_types[mlineindex].ulpfec) + if (!webrtc->data_recovery_types[i].red || + !webrtc->data_recovery_types[i].ulpfec) continue; __webrtcbin_transceiver_set_ulpfec_red(webrtc, transceiver); }