webrtc_private: Get mlineindex from source index 30/280130/3
authorSangchul Lee <sc11.lee@samsung.com>
Wed, 24 Aug 2022 07:07:08 +0000 (16:07 +0900)
committerSangchul Lee <sc11.lee@samsung.com>
Thu, 25 Aug 2022 05:45:53 +0000 (14:45 +0900)
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 <sc11.lee@samsung.com>
include/webrtc_private.h
packaging/capi-media-webrtc.spec
src/webrtc_private.c

index cca62f22f864b61530c5194e5de97ca1d3d0aa36..e947bbe0dbfe57cf34bc7e543475274c828ffd80 100644 (file)
@@ -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 */
index 715e9d4155561d9aca1dede25da133a568cfcabe..fc49e7ce11f34e9aeaea51735db640dc6cfd78d3 100644 (file)
@@ -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
index ed60b3d3cc06b17a6df23e7442d7507e8d0c0a30..db6057c962390762b1235a8b85de0cd6c988720b 100644 (file)
@@ -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);
                        }