media_streamer_node: Release requested pad when failure occurs 23/254123/1
authorSangchul Lee <sc11.lee@samsung.com>
Tue, 23 Feb 2021 23:48:05 +0000 (08:48 +0900)
committerSangchul Lee <sc11.lee@samsung.com>
Tue, 23 Feb 2021 23:49:21 +0000 (08:49 +0900)
[Issue type] Improvement
[Version] 0.1.133

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

index ef84e17..18511b8 100644 (file)
@@ -1,6 +1,6 @@
 Name:       capi-media-streamer
 Summary:    A Media Streamer API
-Version:    0.1.132
+Version:    0.1.133
 Release:    0
 Group:      Multimedia/API
 License:    Apache-2.0
index ae8be39..585537a 100644 (file)
@@ -1857,8 +1857,8 @@ static int __ms_webrtc_prepare_ghost_sink_pad(GstElement *webrtc_container, GstE
        GstElement *filter;
        GstGhostPad *ghost_pad_in = NULL;
        GstPad *filter_sink_pad = NULL;
-       GstPad *req_pad;
-       gchar *req_pad_name;
+       GstPad *req_pad = NULL;
+       gchar *req_pad_name = NULL;
        const gchar *pad_name;
 
        ms_retvm_if(!webrtc_container, MEDIA_STREAMER_ERROR_INVALID_PARAMETER, "webrtc_container is NULL");
@@ -1883,8 +1883,8 @@ static int __ms_webrtc_prepare_ghost_sink_pad(GstElement *webrtc_container, GstE
 
        if (!gst_pad_is_linked((GstPad *)ghost_pad_in)) {
                ms_error("[%s] is set media format but not linked to peer node", pad_name);
-               MS_SAFE_UNREF(ghost_pad_in);
-               return MEDIA_STREAMER_ERROR_INVALID_OPERATION;
+               ret = MEDIA_STREAMER_ERROR_INVALID_OPERATION;
+               goto end;
        }
 
        ms_info("%s is found, link it with webrtcbin and export the ghost pad[%s] of webrtc_container",
@@ -1892,11 +1892,13 @@ static int __ms_webrtc_prepare_ghost_sink_pad(GstElement *webrtc_container, GstE
 
        if (!(req_pad = gst_element_get_request_pad(webrtcbin, "sink_%u"))) {
                ms_error("Failed to get request pad");
-               return MEDIA_STREAMER_ERROR_INVALID_OPERATION;
+               ret = MEDIA_STREAMER_ERROR_INVALID_OPERATION;
+               goto end;
        }
        if (!(req_pad_name = gst_pad_get_name(req_pad))) {
                ms_error("Failed to get request pad name");
-               return MEDIA_STREAMER_ERROR_INVALID_OPERATION;
+               ret = MEDIA_STREAMER_ERROR_INVALID_OPERATION;
+               goto end;
        }
        if (!gst_element_link_pads(filter, "src", webrtcbin, req_pad_name)) {
                ms_error("Failed to link pads, %s - webrtcbin", capsfilter_name);
@@ -1919,7 +1921,10 @@ end:
        MS_SAFE_GFREE(req_pad_name);
        MS_SAFE_UNREF(filter_sink_pad);
        MS_SAFE_UNREF(ghost_pad_in);
-
+       if (ret != MEDIA_STREAMER_ERROR_NONE && req_pad) {
+               gst_element_release_request_pad(webrtcbin, req_pad);
+               g_object_unref(req_pad);
+       }
        return ret;
 }