From: hj kim Date: Mon, 5 Sep 2022 03:27:58 +0000 (+0900) Subject: webrtc_source_private: Add function to release request pad X-Git-Tag: accepted/tizen/unified/20220908.124830~1 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=ed6140f03e73e1b32a9b7e7144a216a043f85cb5;p=platform%2Fcore%2Fapi%2Fwebrtc.git webrtc_source_private: Add function to release request pad _release_request_pad() [Version] 0.3.234 [Issue Type] Refactoring Change-Id: Id6837eb82fae01c28a02c14f71c1e3fa47427488 --- diff --git a/include/webrtc_source_private.h b/include/webrtc_source_private.h index 34d77a9e..95ae4abd 100644 --- a/include/webrtc_source_private.h +++ b/include/webrtc_source_private.h @@ -89,5 +89,6 @@ int _set_encoder_element_bitrate(GstElement *encoder, int target_bitrate); int _get_encoder_element_bitrate(GstElement *encoder, int *target_bitrate); void _set_video_src_resolution(webrtc_gst_slot_s *source, int width, int height); GstCaps *_make_video_raw_caps_with_resolution(webrtc_gst_slot_s *source, webrtc_ini_s *ini, int width, int height); +void _release_request_pad(webrtc_gst_slot_s *source); #endif /* __TIZEN_MEDIA_WEBRTC_SOURCE_COMMON_H__ */ diff --git a/packaging/capi-media-webrtc.spec b/packaging/capi-media-webrtc.spec index f5e61018..bbbb2c10 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.233 +Version: 0.3.234 Release: 0 Group: Multimedia/API License: Apache-2.0 diff --git a/src/webrtc_source.c b/src/webrtc_source.c index f1fb369f..c763e0a8 100644 --- a/src/webrtc_source.c +++ b/src/webrtc_source.c @@ -676,29 +676,6 @@ static int __build_source_bin(webrtc_s *webrtc, webrtc_gst_slot_s *source) return WEBRTC_ERROR_NONE; } -static gboolean __foreach_src_pad_cb(GstElement *element, GstPad *pad, gpointer user_data) -{ - webrtc_gst_slot_s *source = (webrtc_gst_slot_s *)user_data; - GstPad *peer = gst_pad_get_peer(pad); - - RET_VAL_IF(source == NULL, FALSE, "source is NULL"); - RET_VAL_IF(source->webrtc == NULL, FALSE, "webrtc is NULL"); - if (!peer) { - LOG_DEBUG("peer pad is NULL"); - return TRUE; - } - - LOG_DEBUG("about to release request pad[%s]", GST_PAD_NAME(peer)); - - gst_element_release_request_pad(source->webrtc->gst.webrtcbin, peer); - - /* Two unrefing here, one for getting request pad, another one for getting peer pad */ - gst_object_unref(peer); - gst_object_unref(peer); - - return TRUE; -} - void _source_slot_destroy_cb(gpointer data) { webrtc_gst_slot_s *source = (webrtc_gst_slot_s *)data; @@ -715,8 +692,7 @@ void _source_slot_destroy_cb(gpointer data) source->webrtc->gst.sources[i] = NULL; } - if (source->bin) - gst_element_foreach_src_pad(GST_ELEMENT(source->bin), __foreach_src_pad_cb, source); + _release_request_pad(source); for (i = 0; i < AV_IDX_MAX; i++) { _remove_probe_from_pad_for_pause(source, i); @@ -1232,7 +1208,7 @@ static void __release_filesrc_resources(webrtc_gst_slot_s *source) RET_IF(source->bin == NULL, "bin is NULL"); RET_IF(source->filesrc_pipeline == NULL, "filesrc_pipeline is NULL"); - gst_element_foreach_src_pad(GST_ELEMENT(source->bin), __foreach_src_pad_cb, source); + _release_request_pad(source); for (av_idx = 0; av_idx < AV_IDX_MAX; av_idx++) { GList *element_list = NULL; diff --git a/src/webrtc_source_private.c b/src/webrtc_source_private.c index 8a13824d..b2535dc0 100644 --- a/src/webrtc_source_private.c +++ b/src/webrtc_source_private.c @@ -864,3 +864,36 @@ GstCaps *_make_video_raw_caps_with_resolution(webrtc_gst_slot_s *source, webrtc_ return caps; } + +static gboolean __foreach_src_pad_cb(GstElement *element, GstPad *pad, gpointer user_data) +{ + webrtc_gst_slot_s *source = (webrtc_gst_slot_s *)user_data; + GstPad *peer = gst_pad_get_peer(pad); + + RET_VAL_IF(source == NULL, FALSE, "source is NULL"); + RET_VAL_IF(source->webrtc == NULL, FALSE, "webrtc is NULL"); + if (!peer) { + LOG_DEBUG("peer pad is NULL"); + return TRUE; + } + + LOG_DEBUG("about to release request pad[%s]", GST_PAD_NAME(peer)); + + gst_element_release_request_pad(source->webrtc->gst.webrtcbin, peer); + + /* Two unrefing here, one for getting request pad, another one for getting peer pad */ + gst_object_unref(peer); + gst_object_unref(peer); + + return TRUE; +} + +void _release_request_pad(webrtc_gst_slot_s *source) +{ + RET_IF(source == NULL, "source is NULL"); + + if (!source->bin) + return; + + gst_element_foreach_src_pad(GST_ELEMENT(source->bin), __foreach_src_pad_cb, source); +}