mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2025-01-30 02:58:24 +00:00
outputselector: Improve get and set caps functions
Improve sink pad getcaps and setcaps by handling the case where no src pads exist yet
This commit is contained in:
parent
39b0ba827a
commit
f552659504
1 changed files with 14 additions and 10 deletions
|
@ -295,18 +295,20 @@ static GstCaps *
|
||||||
gst_output_selector_sink_getcaps (GstPad * pad)
|
gst_output_selector_sink_getcaps (GstPad * pad)
|
||||||
{
|
{
|
||||||
GstOutputSelector *sel = GST_OUTPUT_SELECTOR (GST_PAD_PARENT (pad));
|
GstOutputSelector *sel = GST_OUTPUT_SELECTOR (GST_PAD_PARENT (pad));
|
||||||
GstPad *active;
|
GstPad *active = NULL;
|
||||||
GstCaps *caps;
|
GstCaps *caps = NULL;
|
||||||
|
|
||||||
GST_OBJECT_LOCK (sel);
|
GST_OBJECT_LOCK (sel);
|
||||||
if (sel->pending_srcpad)
|
if (sel->pending_srcpad)
|
||||||
active = gst_object_ref (sel->pending_srcpad);
|
active = gst_object_ref (sel->pending_srcpad);
|
||||||
else
|
else if (sel->active_srcpad)
|
||||||
active = gst_object_ref (sel->active_srcpad);
|
active = gst_object_ref (sel->active_srcpad);
|
||||||
GST_OBJECT_UNLOCK (sel);
|
GST_OBJECT_UNLOCK (sel);
|
||||||
|
|
||||||
caps = gst_pad_peer_get_caps_reffed (active);
|
if (active) {
|
||||||
gst_object_unref (active);
|
caps = gst_pad_peer_get_caps_reffed (active);
|
||||||
|
gst_object_unref (active);
|
||||||
|
}
|
||||||
if (caps == NULL) {
|
if (caps == NULL) {
|
||||||
caps = gst_caps_new_any ();
|
caps = gst_caps_new_any ();
|
||||||
}
|
}
|
||||||
|
@ -317,18 +319,20 @@ static gboolean
|
||||||
gst_output_selector_sink_setcaps (GstPad * pad, GstCaps * caps)
|
gst_output_selector_sink_setcaps (GstPad * pad, GstCaps * caps)
|
||||||
{
|
{
|
||||||
GstOutputSelector *sel = GST_OUTPUT_SELECTOR (GST_PAD_PARENT (pad));
|
GstOutputSelector *sel = GST_OUTPUT_SELECTOR (GST_PAD_PARENT (pad));
|
||||||
GstPad *active;
|
GstPad *active = NULL;
|
||||||
gboolean ret;
|
gboolean ret = TRUE;
|
||||||
|
|
||||||
GST_OBJECT_LOCK (sel);
|
GST_OBJECT_LOCK (sel);
|
||||||
if (sel->pending_srcpad)
|
if (sel->pending_srcpad)
|
||||||
active = gst_object_ref (sel->pending_srcpad);
|
active = gst_object_ref (sel->pending_srcpad);
|
||||||
else
|
else if (sel->active_srcpad)
|
||||||
active = gst_object_ref (sel->active_srcpad);
|
active = gst_object_ref (sel->active_srcpad);
|
||||||
GST_OBJECT_UNLOCK (sel);
|
GST_OBJECT_UNLOCK (sel);
|
||||||
|
|
||||||
ret = gst_pad_set_caps (active, caps);
|
if (active) {
|
||||||
gst_object_unref (active);
|
ret = gst_pad_set_caps (active, caps);
|
||||||
|
gst_object_unref (active);
|
||||||
|
}
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue