From: Sangchul Lee Date: Wed, 20 Jan 2021 07:34:35 +0000 (+0900) Subject: webrtc_source: Postpone the link timing in case of media packet source X-Git-Tag: submit/tizen/20210729.023123~157 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=a47b7d9f8cf612c38306f25fe516d46ab681bfb2;p=platform%2Fcore%2Fapi%2Fwebrtc.git webrtc_source: Postpone the link timing in case of media packet source These is an issue that could not set transceiver direction to media packet source. In case of media packet source, the media type is determined when setting the format of the source by API. It affects this issue because the media type which is not set yet is used inside of the new transceiver callback triggered by reqeust pad to the webrtcbin to link with the source. This patch postphones the link timing including trigger of new transceiver callback to avoid the fault. [Version] 0.1.84 [Issue Type] Bug fix Change-Id: I65c0d45703f825e3d200caf1b9aa739d4e442e22 Signed-off-by: Sangchul Lee --- diff --git a/packaging/capi-media-webrtc.spec b/packaging/capi-media-webrtc.spec index 9763151f..198c7725 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.1.83 +Version: 0.1.84 Release: 0 Group: Multimedia/API License: Apache-2.0 diff --git a/src/webrtc_source.c b/src/webrtc_source.c index 8a3b17ad..2a7a54ca 100644 --- a/src/webrtc_source.c +++ b/src/webrtc_source.c @@ -1096,15 +1096,51 @@ void _source_slot_destroy_cb(gpointer data) g_free(source); } +static int __link_source_with_webrtcbin(webrtc_gst_slot_s *source, GstElement *webrtcbin) +{ + int ret = WEBRTC_ERROR_NONE; + GstPad *sinkpad; + gchar *sinkpad_name = NULL; + gchar *srcpad_name = NULL; + + RET_VAL_IF(source == NULL, WEBRTC_ERROR_INVALID_PARAMETER, "source is NULL"); + RET_VAL_IF(webrtcbin == NULL, WEBRTC_ERROR_INVALID_PARAMETER, "webrtcbin is NULL"); + + if (!(sinkpad = gst_element_get_request_pad(webrtcbin, "sink_%u"))) { + LOG_ERROR("failed to gst_element_get_request_pad()"); + return WEBRTC_ERROR_INVALID_OPERATION; + } + if (!(sinkpad_name = gst_pad_get_name(sinkpad))) { + LOG_ERROR("failed to gst_pad_get_name()"); + ret = WEBRTC_ERROR_INVALID_OPERATION; + goto exit; + } + srcpad_name = g_strdup_printf("src_%u", source->id); + if (!gst_element_link_pads(source->bin, srcpad_name, webrtcbin, sinkpad_name)) { + LOG_ERROR("failed to link pads, [%s:%s] - [%s:%s]", + GST_ELEMENT_NAME(source->bin), srcpad_name, GST_ELEMENT_NAME(webrtcbin), sinkpad_name); + ret = WEBRTC_ERROR_INVALID_OPERATION; + goto exit; + } + LOG_DEBUG("link pads successfully, [%s:%s] - [%s:%s]", + GST_ELEMENT_NAME(source->bin), srcpad_name, GST_ELEMENT_NAME(webrtcbin), sinkpad_name); + +exit: + g_free(sinkpad_name); + g_free(srcpad_name); + if (ret != WEBRTC_ERROR_NONE) { + gst_element_release_request_pad(webrtcbin, sinkpad); + g_object_unref(sinkpad); + } + return ret; +} + int _add_media_source(webrtc_s *webrtc, webrtc_media_source_type_e type, unsigned int *source_id) { int ret = WEBRTC_ERROR_NONE; unsigned int id; webrtc_gst_slot_s *source = NULL; gchar *bin_name = NULL; - GstPad *webrtc_sinkpad; - gchar *webrtc_sinkpad_name; - gchar *bin_srcpad_name = NULL; RET_VAL_IF(webrtc == NULL, WEBRTC_ERROR_INVALID_PARAMETER, "webrtc is NULL"); RET_VAL_IF(webrtc->gst.source_slots == NULL, WEBRTC_ERROR_INVALID_OPERATION, "source_slots is NULL"); @@ -1138,34 +1174,20 @@ int _add_media_source(webrtc_s *webrtc, webrtc_media_source_type_e type, unsigne return WEBRTC_ERROR_INVALID_OPERATION; } - if (!(webrtc_sinkpad = gst_element_get_request_pad(webrtc->gst.webrtcbin, "sink_%u"))) { - LOG_ERROR("failed to gst_element_get_request_pad()"); - goto error_after_insert; - } - if (!(webrtc_sinkpad_name = gst_pad_get_name(webrtc_sinkpad))) { - LOG_ERROR("failed to gst_pad_get_name()"); - goto error_after_insert; - } - bin_srcpad_name = g_strdup_printf("src_%u", id); - if (!gst_element_link_pads(source->bin, bin_srcpad_name, webrtc->gst.webrtcbin, webrtc_sinkpad_name)) { - LOG_ERROR("failed to link pads, [%s:%s] - [%s:%s]", - GST_ELEMENT_NAME(source->bin), bin_srcpad_name, GST_ELEMENT_NAME(webrtc->gst.webrtcbin), webrtc_sinkpad_name); + if (type != WEBRTC_MEDIA_SOURCE_TYPE_MEDIA_PACKET && + __link_source_with_webrtcbin(source, webrtc->gst.webrtcbin) != WEBRTC_ERROR_NONE) { + LOG_ERROR("failed to __link_source_with_webrtcbin()"); goto error_after_insert; } - LOG_DEBUG("link pads successfully, [%s:%s] - [%s:%s]", - GST_ELEMENT_NAME(source->bin), bin_srcpad_name, GST_ELEMENT_NAME(webrtc->gst.webrtcbin), webrtc_sinkpad_name); *source_id = id; LOG_INFO("added a source slot[%p, id:%u]", source, source->id); - g_free(bin_srcpad_name); - return WEBRTC_ERROR_NONE; error_after_insert: g_hash_table_remove(webrtc->gst.source_slots, bin_name); - g_free(bin_srcpad_name); return WEBRTC_ERROR_INVALID_OPERATION; @@ -1244,7 +1266,7 @@ int _set_media_format(webrtc_s *webrtc, unsigned int source_id, media_format_h f return ret; } - return WEBRTC_ERROR_NONE; + return __link_source_with_webrtcbin(source, webrtc->gst.webrtcbin); } static gboolean __check_format_is_not_set_cb(gpointer key, gpointer value, gpointer user_data)