return fakesink;
}
-static int __create_rest_of_elements_for_filesrc_pipeline(webrtc_gst_slot_s *source, GstPad *pad, bool is_audio)
+static int __create_rest_of_elements_for_filesrc_pipeline(webrtc_gst_slot_s *source, GstPad *pad, GList **element_list, bool is_audio)
{
GstBin *bin;
GstElement *queue;
GstElement *payloader;
GstElement *capsfilter;
GstElement *fakesink;
- GList *element_list = NULL;
+ GList *_element_list = NULL;
RET_VAL_IF(source == NULL, WEBRTC_ERROR_INVALID_PARAMETER, "source is NULL");
RET_VAL_IF(source->filesrc_pipeline == NULL, WEBRTC_ERROR_INVALID_OPERATION, "filesrc_pipeline is NULL");
if (!(queue = _create_element(DEFAULT_ELEMENT_QUEUE, _get_element_name(GET_AV_IDX(is_audio), ELEMENT_QUEUE))))
return WEBRTC_ERROR_INVALID_OPERATION;
- APPEND_ELEMENT(element_list, queue);
+ APPEND_ELEMENT(_element_list, queue);
if (!(payloader = __create_payloader_for_filesrc_pipeline(pad, is_audio)))
goto exit;
- APPEND_ELEMENT(element_list, payloader);
+ APPEND_ELEMENT(_element_list, payloader);
if (!(capsfilter = __prepare_capsfilter_for_filesrc_pipeline(source, is_audio)))
goto exit;
- APPEND_ELEMENT(element_list, capsfilter);
+ APPEND_ELEMENT(_element_list, capsfilter);
if (!(fakesink = __prepare_fakesink_for_filesrc_pipeline(source, is_audio)))
goto exit;
- APPEND_ELEMENT(element_list, fakesink);
+ APPEND_ELEMENT(_element_list, fakesink);
- if (!_add_elements_to_bin(bin, element_list)) {
- SAFE_G_LIST_FREE(element_list);
+ if (!_add_elements_to_bin(bin, _element_list)) {
+ SAFE_G_LIST_FREE(_element_list);
return WEBRTC_ERROR_INVALID_OPERATION;
}
- if (!_link_elements(element_list))
+ if (!_link_elements(_element_list))
goto exit_with_remove_from_bin;
- if (!_sync_elements_state_with_parent(element_list))
+ if (!_sync_elements_state_with_parent(_element_list))
goto exit_with_remove_from_bin;
- SAFE_G_LIST_FREE(element_list);
+ *element_list = _element_list;
return WEBRTC_ERROR_NONE;
exit_with_remove_from_bin:
- _remove_elements_from_bin(bin, element_list);
- SAFE_G_LIST_FREE(element_list);
+ _remove_elements_from_bin(bin, _element_list);
+ SAFE_G_LIST_FREE(_element_list);
return WEBRTC_ERROR_INVALID_OPERATION;
exit:
- SAFE_G_LIST_FREE_FULL(element_list, gst_object_unref);
+ SAFE_G_LIST_FREE_FULL(_element_list, gst_object_unref);
return WEBRTC_ERROR_INVALID_OPERATION;
}
return GST_AUTOPLUG_SELECT_TRY;
}
-static int __build_filesrc_bin(webrtc_gst_slot_s *source, media_type_e media_type)
+static int __build_filesrc_bin(webrtc_gst_slot_s *source, media_type_e media_type, GList **element_list)
{
int ret = WEBRTC_ERROR_NONE;
GstPad *src_pad = NULL;
GstElement *appsrc = NULL;
GstElement *queue = NULL;
GstElement *capsfilter = NULL;
- GList *element_list = NULL;
+ GList *_element_list = NULL;
const int av_idx = GET_AV_IDX_BY_TYPE(media_type);
RET_VAL_IF(source == NULL, WEBRTC_ERROR_INVALID_PARAMETER, "source is NULL");
if (!(appsrc = _create_element(DEFAULT_ELEMENT_APPSRC, _get_element_name(av_idx, ELEMENT_APPSRC))))
return WEBRTC_ERROR_INVALID_OPERATION;
- APPEND_ELEMENT(element_list, appsrc);
+ APPEND_ELEMENT(_element_list, appsrc);
g_object_set(G_OBJECT(appsrc),
"is-live", TRUE,
if (!(queue = _create_element(DEFAULT_ELEMENT_QUEUE, _get_element_name(av_idx, ELEMENT_QUEUE))))
goto exit;
- APPEND_ELEMENT(element_list, queue);
+ APPEND_ELEMENT(_element_list, queue);
if (!(capsfilter = _create_element(DEFAULT_ELEMENT_CAPSFILTER, _get_element_name(av_idx, ELEMENT_CAPSFILTER))))
goto exit;
- APPEND_ELEMENT(element_list, capsfilter);
+ APPEND_ELEMENT(_element_list, capsfilter);
- if (!_add_elements_to_bin(source->bin, element_list)) {
- SAFE_G_LIST_FREE(element_list);
+ if (!_add_elements_to_bin(source->bin, _element_list)) {
+ SAFE_G_LIST_FREE(_element_list);
return WEBRTC_ERROR_INVALID_OPERATION;
}
- if (!_link_elements(element_list))
+ if (!_link_elements(_element_list))
goto exit_with_remove_from_bin;
- if (!_sync_elements_state_with_parent(element_list))
+ if (!_sync_elements_state_with_parent(_element_list))
goto exit_with_remove_from_bin;
if (_set_ghost_pad_target(src_pad, capsfilter, true) != WEBRTC_ERROR_NONE)
_add_probe_to_pad_for_pause(source, av_idx, src_pad, _payloaded_data_probe_cb);
- SAFE_G_LIST_FREE(element_list);
+ *element_list = _element_list;
return WEBRTC_ERROR_NONE;
exit_with_remove_from_bin:
- _remove_elements_from_bin(source->bin, element_list);
- SAFE_G_LIST_FREE(element_list);
+ _remove_elements_from_bin(source->bin, _element_list);
+ SAFE_G_LIST_FREE(_element_list);
return WEBRTC_ERROR_INVALID_OPERATION;
exit:
- SAFE_G_LIST_FREE_FULL(element_list, gst_object_unref);
+ SAFE_G_LIST_FREE_FULL(_element_list, gst_object_unref);
return WEBRTC_ERROR_INVALID_OPERATION;
}
gchar *media_type = NULL;
bool is_audio;
int av_idx;
+ GList *filesrc_element_list = NULL;
+ GList *bin_element_list = NULL;
GstElement *queue = NULL;
RET_IF(source == NULL, "source is NULL");
return;
}
- ret = __create_rest_of_elements_for_filesrc_pipeline(source, pad, is_audio);
+ ret = __create_rest_of_elements_for_filesrc_pipeline(source, pad, &filesrc_element_list, is_audio);
if (ret != WEBRTC_ERROR_NONE) {
LOG_ERROR("failed to __create_rest_of_elements_for_filesrc_pipeline()");
return;
}
queue = gst_bin_get_by_name(GST_BIN(source->filesrc_pipeline), _get_element_name(GET_AV_IDX(is_audio), ELEMENT_QUEUE));
- RET_IF(queue == NULL, "queue is NULL");
+ if (!queue) {
+ LOG_ERROR("failed to get queue");
+ goto exit;
+ }
ret = __link_decodebin_with_queue(pad, source, is_audio);
if (ret != WEBRTC_ERROR_NONE) {
goto exit;
}
- ret = __build_filesrc_bin(source, is_audio ? MEDIA_TYPE_AUDIO : MEDIA_TYPE_VIDEO);
+ ret = __build_filesrc_bin(source, is_audio ? MEDIA_TYPE_AUDIO : MEDIA_TYPE_VIDEO, &bin_element_list);
if (ret != WEBRTC_ERROR_NONE) {
LOG_ERROR("failed to __build_filesrc_bin()");
goto exit;
ret = _link_source_with_webrtcbin(source, source->webrtc->gst.webrtcbin);
if (ret != WEBRTC_ERROR_NONE) {
LOG_ERROR("failed to _link_source_with_webrtcbin()");
- goto exit;
+ goto exit_with_remove_from_bin;
}
source->av[av_idx].render.need_decoding = true;
source->av[av_idx].render.appsrc_caps = gst_pad_get_current_caps(pad);
_add_probe_to_pad_for_render(source, av_idx, gst_element_get_static_pad(queue, "src"), _source_data_probe_cb);
+ SAFE_G_LIST_FREE(filesrc_element_list);
+ SAFE_G_LIST_FREE(bin_element_list);
+
GENERATE_DOT(source->webrtc, source->filesrc_pipeline, "%s.%s-%s",
GST_ELEMENT_NAME(source->filesrc_pipeline), GST_ELEMENT_NAME(element), GST_PAD_NAME(pad));
+ GENERATE_DOT(source->webrtc, source->webrtc->gst.pipeline, "%s.filesrc.%s-%s",
+ GST_ELEMENT_NAME(source->webrtc->gst.pipeline), GST_ELEMENT_NAME(element), GST_PAD_NAME(pad));
+
return;
+exit_with_remove_from_bin:
+ _remove_elements_from_bin(GST_BIN(source->bin), bin_element_list);
+ SAFE_G_LIST_FREE(bin_element_list);
exit:
- _remove_rest_of_elements_for_filesrc_pipeline(source, is_audio);
+ _remove_elements_from_bin(GST_BIN(source->filesrc_pipeline), filesrc_element_list);
+ SAFE_G_LIST_FREE(filesrc_element_list);
return;
}