return true;
}
-static void __remove_filesrc_element(webrtc_gst_slot_s *source)
+static void __release_filesrc_resources(webrtc_gst_slot_s *source)
{
- GstBin *bin = NULL;
- GstElement *payload = NULL;
+ GstElement *appsrc = NULL;
+ GstElement *queue = NULL;
GstElement *capsfilter = NULL;
- GstElement *fakesink = NULL;
+ int av_idx = 0;
RET_IF(source == NULL, "source is NULL");
+ RET_IF(source->bin == NULL, "bin is NULL");
RET_IF(source->filesrc_pipeline == NULL, "filesrc_pipeline is NULL");
- bin = GST_BIN(source->filesrc_pipeline);
+ gst_element_foreach_src_pad(GST_ELEMENT(source->bin), __foreach_src_pad_cb, source);
- payload = gst_bin_get_by_name(bin, DEFAULT_NAME_AUDIO_PAYLOAD);
- if (payload) {
- capsfilter = gst_bin_get_by_name(bin, DEFAULT_NAME_AUDIO_CAPSFILTER);
- fakesink = gst_bin_get_by_name(bin, DEFAULT_NAME_AUDIO_FAKESINK);
- gst_bin_remove_many(bin, payload, capsfilter, fakesink, NULL);
+ for (av_idx = 0; av_idx < AV_IDX_MAX; av_idx++) {
+ if (source->av[av_idx].src_pad_probe_id == 0)
+ continue;
- if (source->av[AV_IDX_AUDIO].payload_id > 0)
- __return_payload_id(source->webrtc, source->av[AV_IDX_AUDIO].payload_id);
+ __remove_probe_from_pad_for_pause(source, av_idx);
+ __remove_probe_from_pad_for_render(source, av_idx);
- __remove_probe_from_pad_for_pause(source, AV_IDX_AUDIO);
- }
+ if (source->av[av_idx].payload_id > 0)
+ __return_payload_id(source->webrtc, source->av[av_idx].payload_id);
- payload = gst_bin_get_by_name(bin, DEFAULT_NAME_VIDEO_PAYLOAD);
- if (payload) {
- capsfilter = gst_bin_get_by_name(bin, DEFAULT_NAME_VIDEO_CAPSFILTER);
- fakesink = gst_bin_get_by_name(bin, DEFAULT_NAME_VIDEO_FAKESINK);
- gst_bin_remove_many(bin, payload, capsfilter, fakesink, NULL);
+ if (source->av[av_idx].render.pipeline) {
+ gst_element_set_state(source->av[av_idx].render.pipeline, GST_STATE_NULL);
+ SAFE_GST_OBJECT_UNREF(source->av[av_idx].render.pipeline);
+ }
+
+ __remove_rest_of_elements_for_filesrc_pipeline(source, (av_idx == AV_IDX_AUDIO));
+
+ appsrc = gst_bin_get_by_name(source->bin, _av_tbl[av_idx].appsrc_name);
+ if (!appsrc)
+ LOG_ERROR("appsrc is NULL");
- if (source->av[AV_IDX_VIDEO].payload_id > 0)
- __return_payload_id(source->webrtc, source->av[AV_IDX_VIDEO].payload_id);
+ queue = gst_bin_get_by_name(source->bin, _av_tbl[av_idx].queue_name);
+ if (!queue)
+ LOG_ERROR("queue is NULL");
- __remove_probe_from_pad_for_pause(source, AV_IDX_VIDEO);
+ capsfilter = gst_bin_get_by_name(source->bin, _av_tbl[av_idx].capsfilter_name);
+ if (!capsfilter)
+ LOG_ERROR("capsfilter is NULL");
+
+ gst_bin_remove_many(source->bin, appsrc, queue, capsfilter, NULL);
}
- /* FIXME: filesrc_bin should be updated as well */
+ if (source->display)
+ _release_display(source->display);
+
+ if (source->sound_stream_info.type) {
+ free(source->sound_stream_info.type);
+ source->sound_stream_info.type = NULL;
+ }
source->media_types = 0;
}
g_object_get(G_OBJECT(filesrc), "location", &location, NULL);
if (location) {
- __remove_filesrc_element(source);
+ __release_filesrc_resources(source);
g_free(location);
}