webrtc_private: Apply FEC in case of answerer without setting any media source 70/263170/2 accepted/tizen/unified/20210831.143733 submit/tizen/20210831.023615
authorSangchul Lee <sc11.lee@samsung.com>
Fri, 27 Aug 2021 06:23:51 +0000 (15:23 +0900)
committerSangchul Lee <sc11.lee@samsung.com>
Fri, 27 Aug 2021 08:18:30 +0000 (17:18 +0900)
If a webrtc handle that does not have any media source, so-called recvonly,
tries to create an answer SDP with the received offer SDP, FEC also should be
applied according to ini configuration if the offerer wants to use the FEC.

[Version] 0.2.87
[Issue Type] Improvement

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

index 9a64aa85f1a31fde3a6ce02c686184ff8e25f5f8..f9e01af36fdd91705f1a653efad7a83f113b0548 100644 (file)
@@ -1,6 +1,6 @@
 Name:       capi-media-webrtc
 Summary:    A WebRTC library in Tizen Native API
-Version:    0.2.86
+Version:    0.2.87
 Release:    0
 Group:      Multimedia/API
 License:    Apache-2.0
index 0c8e9d681414f5ff365569ad0a2a8b12c8a57a45..e9471bfd8b5645faf4bd677b00e4f4e28ae5309d 100644 (file)
@@ -1019,32 +1019,24 @@ int _set_ghost_pad_target(GstPad *ghost_pad, GstElement *target_element, bool is
        return WEBRTC_ERROR_NONE;
 }
 
-static void __webrtcbin_transceiver_set_ulpfec_red(webrtc_s *webrtc, int source_type, GstWebRTCRTPTransceiver *transceiver)
+static void __webrtcbin_transceiver_set_ulpfec_red(webrtc_s *webrtc, unsigned int fec_percentage, GstWebRTCRTPTransceiver *transceiver)
 {
-       ini_item_media_source_s *ini_source;
        GstElement *rtpbin;
 
        RET_IF(webrtc == NULL, "webrtc is NULL");
        RET_IF(transceiver == NULL, "transceiver is NULL");
 
-       ini_source = _ini_get_source_by_type(&webrtc->ini, source_type);
-       if (ini_source == NULL)
-               ini_source = &(webrtc->ini.media_source);
-
-       if (!ini_source->use_ulpfec_red)
+       if (!(rtpbin = gst_bin_get_by_name(GST_BIN(webrtc->gst.webrtcbin), "rtpbin"))) {
+               LOG_ERROR("failed to get rtpbin");
                return;
+       }
 
        g_object_set(transceiver,
                "fec-type", GST_WEBRTC_FEC_TYPE_ULP_RED,
-               "fec-percentage", ini_source->fec_percentage,
+               "fec-percentage", fec_percentage,
                NULL);
 
-       LOG_INFO("set ULPFEC/RED[percentage: %d] to transceiver[%p]", ini_source->fec_percentage, transceiver);
-
-       if (!(rtpbin = gst_bin_get_by_name(GST_BIN(webrtc->gst.webrtcbin), "rtpbin"))) {
-               LOG_ERROR("failed to get rtpbin");
-               return;
-       }
+       LOG_INFO("set ULPFEC/RED[percentage:%u] to transceiver[%p]", fec_percentage, transceiver);
 
        g_object_set(G_OBJECT(rtpbin), "do-lost", TRUE, NULL);
 
@@ -1127,6 +1119,7 @@ static void __webrtcbin_on_new_transceiver_cb(GstElement *webrtcbin, GstWebRTCRT
        GHashTableIter iter;
        gpointer key, value;
        webrtc_gst_slot_s *source;
+       ini_item_media_source_s *ini_source;
        int i;
 
        RET_IF(webrtcbin == NULL, "webrtcbin is NULL");
@@ -1136,6 +1129,18 @@ static void __webrtcbin_on_new_transceiver_cb(GstElement *webrtcbin, GstWebRTCRT
        LOG_INFO("new transceiver[%p, mline:%u, mid:%s, direction:%d], user_data[%p]",
                transceiver, transceiver->mline, transceiver->mid, transceiver->direction, user_data);
 
+       if (g_hash_table_size(webrtc->gst.source_slots) == 0) {
+               /* In this case, it might be an answerer without setting any media source.
+                * Check the default FEC value of media source, apply it if needed. */
+               if (!(ini_source = &(webrtc->ini.media_source)))
+                       return;
+               if (!ini_source->use_ulpfec_red)
+                       return;
+
+               __webrtcbin_transceiver_set_ulpfec_red(webrtc, ini_source->fec_percentage, transceiver);
+               return;
+       }
+
        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;
@@ -1147,7 +1152,14 @@ static void __webrtcbin_on_new_transceiver_cb(GstElement *webrtcbin, GstWebRTCRT
                                LOG_DEBUG("source[%s, id:%u, mline:%d for %s]",
                                        (gchar*)key, source->id, source->av[i].mline, i == AV_IDX_AUDIO ? "AUDIO" : "VIDEO");
 
-                               __webrtcbin_transceiver_set_ulpfec_red(webrtc, source->type, transceiver);
+                               ini_source = _ini_get_source_by_type(&webrtc->ini, source->type);
+                               if (ini_source == NULL)
+                                       ini_source = &(webrtc->ini.media_source);
+                               if (!ini_source->use_ulpfec_red)
+                                       return;
+
+                               __webrtcbin_transceiver_set_ulpfec_red(webrtc, ini_source->fec_percentage, transceiver);
+                               return;
                        }
                }
        }