webrtc_source_private: Add function to release request pad 71/280771/3
authorhj kim <backto.kim@samsung.com>
Mon, 5 Sep 2022 03:27:58 +0000 (12:27 +0900)
committerhj kim <backto.kim@samsung.com>
Tue, 6 Sep 2022 05:05:20 +0000 (14:05 +0900)
_release_request_pad()

[Version] 0.3.234
[Issue Type] Refactoring

Change-Id: Id6837eb82fae01c28a02c14f71c1e3fa47427488

include/webrtc_source_private.h
packaging/capi-media-webrtc.spec
src/webrtc_source.c
src/webrtc_source_private.c

index 34d77a9e82350332b07db072d34833cd3d68e0e4..95ae4abd57316b6e48257eb313871ce7f995f95a 100644 (file)
@@ -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__ */
index f5e610184274ad7c0544c9d028e4243999473023..bbbb2c10fed9121e3a259960b233250b895cbcd1 100644 (file)
@@ -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
index f1fb369f50d96500885f80c75e010a577919e38b..c763e0a803e2d9f5ebbf81b02385aeb4660ea6d1 100644 (file)
@@ -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;
index 8a13824db56b6429aa9f3f8614e2c4e10001c5a4..b2535dc0e7588fa1f674daf99bf4a3ff0fc1e47d 100644 (file)
@@ -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);
+}