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");
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",
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);
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;
}