From 4b570026aa2e674d5a60dae114cd5cf73767312a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Peter=20K=C3=B6rner?= Date: Wed, 3 Oct 2018 16:17:22 +0200 Subject: [PATCH] splitmuxsink: accept pads named 'sink' on the muxer, handle static pads as well https://bugzilla.gnome.org/show_bug.cgi?id=797241 --- gst/multifile/gstsplitmuxsink.c | 49 +++++++++++++++++++++++++++++++-- 1 file changed, 46 insertions(+), 3 deletions(-) diff --git a/gst/multifile/gstsplitmuxsink.c b/gst/multifile/gstsplitmuxsink.c index 8dddf71091..b4c835a468 100644 --- a/gst/multifile/gstsplitmuxsink.c +++ b/gst/multifile/gstsplitmuxsink.c @@ -2557,12 +2557,16 @@ gst_splitmux_sink_request_new_pad (GstElement * element, goto already_have_video; /* FIXME: Look for a pad template with matching caps, rather than by name */ + GST_DEBUG_OBJECT (element, + "searching for pad-template with name 'video_%%u'"); mux_template = gst_element_class_get_pad_template (GST_ELEMENT_GET_CLASS (splitmux->muxer), "video_%u"); /* Fallback to find sink pad templates named 'video' (flvmux) */ if (!mux_template) { + GST_DEBUG_OBJECT (element, + "searching for pad-template with name 'video'"); mux_template = gst_element_class_get_pad_template (GST_ELEMENT_GET_CLASS (splitmux->muxer), "video"); @@ -2570,30 +2574,69 @@ gst_splitmux_sink_request_new_pad (GstElement * element, is_video = TRUE; name = NULL; } else { + GST_DEBUG_OBJECT (element, "searching for pad-template with name '%s'", + templ->name_template); mux_template = gst_element_class_get_pad_template (GST_ELEMENT_GET_CLASS (splitmux->muxer), templ->name_template); /* Fallback to find sink pad templates named 'audio' (flvmux) */ if (!mux_template) { + GST_DEBUG_OBJECT (element, + "searching for pad-template with name 'audio'"); mux_template = gst_element_class_get_pad_template (GST_ELEMENT_GET_CLASS (splitmux->muxer), "audio"); name = NULL; } } + if (mux_template == NULL) { - /* Fallback to find sink pad templates named 'sink_%d' (mpegtsmux) */ + GST_DEBUG_OBJECT (element, + "searching for pad-template with name 'sink_%%d'"); mux_template = gst_element_class_get_pad_template (GST_ELEMENT_GET_CLASS (splitmux->muxer), "sink_%d"); name = NULL; } + if (mux_template == NULL) { + GST_DEBUG_OBJECT (element, "searching for pad-template with name 'sink'"); + mux_template = + gst_element_class_get_pad_template (GST_ELEMENT_GET_CLASS + (splitmux->muxer), "sink"); + name = NULL; + } } - res = gst_element_request_pad (splitmux->muxer, mux_template, name, caps); - if (res == NULL) + if (mux_template == NULL) { + GST_ERROR_OBJECT (element, + "unable to find a suitable sink pad-template on the muxer"); + goto fail; + } + GST_DEBUG_OBJECT (element, "found sink pad-template '%s' on the muxer", + mux_template->name_template); + + if (mux_template->presence == GST_PAD_REQUEST) { + GST_DEBUG_OBJECT (element, "requesting pad from pad-template"); + + res = gst_element_request_pad (splitmux->muxer, mux_template, name, caps); + if (res == NULL) + goto fail; + } else if (mux_template->presence == GST_PAD_ALWAYS) { + GST_DEBUG_OBJECT (element, "accessing always pad from pad-template"); + + res = + gst_element_get_static_pad (splitmux->muxer, + mux_template->name_template); + if (res == NULL) + goto fail; + } else { + GST_ERROR_OBJECT (element, + "unexpected pad presence %d", mux_template->presence); + + goto fail; + } if (is_video) gname = g_strdup ("video");