mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2025-03-30 20:59:44 +00:00
GESTimelinePipeline: Also get static pads for static pads from encodebin.
This is for the cases where the provided GstStreamEncodingProfile has a non-zero presence.
This commit is contained in:
parent
e0dcea0bd5
commit
b4e36fe853
1 changed files with 70 additions and 6 deletions
|
@ -165,6 +165,65 @@ done:
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Fetches a ocmpatible pad on the target element which isn't already
|
||||||
|
* linked */
|
||||||
|
static GstPad *
|
||||||
|
get_compatible_unlinked_pad (GstElement * element, GstPad * pad)
|
||||||
|
{
|
||||||
|
GstPad *res = NULL;
|
||||||
|
GstIterator *pads;
|
||||||
|
gboolean done = FALSE;
|
||||||
|
GstCaps *srccaps;
|
||||||
|
|
||||||
|
GST_DEBUG ("element : %s, pad %s:%s",
|
||||||
|
GST_ELEMENT_NAME (element), GST_DEBUG_PAD_NAME (pad));
|
||||||
|
|
||||||
|
if (GST_PAD_DIRECTION (pad) == GST_PAD_SRC)
|
||||||
|
pads = gst_element_iterate_sink_pads (element);
|
||||||
|
else
|
||||||
|
pads = gst_element_iterate_src_pads (element);
|
||||||
|
srccaps = gst_pad_get_caps (pad);
|
||||||
|
|
||||||
|
GST_DEBUG ("srccaps %" GST_PTR_FORMAT, srccaps);
|
||||||
|
|
||||||
|
while (!done) {
|
||||||
|
gpointer padptr;
|
||||||
|
|
||||||
|
switch (gst_iterator_next (pads, &padptr)) {
|
||||||
|
case GST_ITERATOR_OK:
|
||||||
|
{
|
||||||
|
GstPad *testpad = (GstPad *) padptr;
|
||||||
|
|
||||||
|
if (gst_pad_is_linked (testpad)) {
|
||||||
|
gst_object_unref (testpad);
|
||||||
|
} else {
|
||||||
|
GstCaps *sinkcaps = gst_pad_get_caps (testpad);
|
||||||
|
|
||||||
|
GST_DEBUG ("sinkccaps %" GST_PTR_FORMAT, sinkcaps);
|
||||||
|
|
||||||
|
if (gst_caps_can_intersect (srccaps, sinkcaps)) {
|
||||||
|
res = testpad;
|
||||||
|
done = TRUE;
|
||||||
|
} else
|
||||||
|
gst_object_unref (testpad);
|
||||||
|
gst_caps_unref (sinkcaps);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
case GST_ITERATOR_DONE:
|
||||||
|
case GST_ITERATOR_ERROR:
|
||||||
|
done = TRUE;
|
||||||
|
break;
|
||||||
|
case GST_ITERATOR_RESYNC:
|
||||||
|
gst_iterator_resync (pads);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
gst_iterator_free (pads);
|
||||||
|
gst_caps_unref (srccaps);
|
||||||
|
|
||||||
|
return res;
|
||||||
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
pad_added_cb (GstElement * timeline, GstPad * pad, GESTimelinePipeline * self)
|
pad_added_cb (GstElement * timeline, GstPad * pad, GESTimelinePipeline * self)
|
||||||
{
|
{
|
||||||
|
@ -257,12 +316,17 @@ pad_added_cb (GstElement * timeline, GstPad * pad, GESTimelinePipeline * self)
|
||||||
if (self->mode & TIMELINE_MODE_RENDER) {
|
if (self->mode & TIMELINE_MODE_RENDER) {
|
||||||
GST_DEBUG_OBJECT (self, "Connecting to encodebin");
|
GST_DEBUG_OBJECT (self, "Connecting to encodebin");
|
||||||
|
|
||||||
sinkpad = NULL;
|
/* Check for unused static pads */
|
||||||
g_signal_emit_by_name (self->encodebin, "request-pad",
|
sinkpad = get_compatible_unlinked_pad (self->encodebin, pad);
|
||||||
gst_pad_get_caps (pad), &sinkpad);
|
|
||||||
if (G_UNLIKELY (sinkpad == NULL)) {
|
if (sinkpad == NULL) {
|
||||||
GST_WARNING_OBJECT (self, "Couldn't get a pad from encodebin !");
|
/* If no compatible static pad is available, request a pad */
|
||||||
goto error;
|
g_signal_emit_by_name (self->encodebin, "request-pad",
|
||||||
|
gst_pad_get_caps (pad), &sinkpad);
|
||||||
|
if (G_UNLIKELY (sinkpad == NULL)) {
|
||||||
|
GST_WARNING_OBJECT (self, "Couldn't get a pad from encodebin !");
|
||||||
|
goto error;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (G_UNLIKELY (gst_pad_link (gst_element_get_request_pad (chain->tee,
|
if (G_UNLIKELY (gst_pad_link (gst_element_get_request_pad (chain->tee,
|
||||||
|
|
Loading…
Reference in a new issue