From: Sangchul Lee Date: Fri, 27 Aug 2021 06:23:51 +0000 (+0900) Subject: webrtc_private: Apply FEC in case of answerer without setting any media source X-Git-Tag: submit/tizen/20210831.023615^0 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=cc06531a0035b122f7f3efeda01c99b5d10dc2f0;p=platform%2Fcore%2Fapi%2Fwebrtc.git webrtc_private: Apply FEC in case of answerer without setting any media source 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 --- diff --git a/packaging/capi-media-webrtc.spec b/packaging/capi-media-webrtc.spec index 9a64aa85..f9e01af3 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.2.86 +Version: 0.2.87 Release: 0 Group: Multimedia/API License: Apache-2.0 diff --git a/src/webrtc_private.c b/src/webrtc_private.c index 0c8e9d68..e9471bfd 100644 --- a/src/webrtc_private.c +++ b/src/webrtc_private.c @@ -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; } } }