mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-11-27 12:11:13 +00:00
udpsrc: improve caps handling
Protect caps with the lock. Don't push the caps event from the set_property function but mark the pad for reconfiguration so that it will renegotiate and push the new caps event in the streaming thread.
This commit is contained in:
parent
5e44fa3e31
commit
d3c736c50f
1 changed files with 21 additions and 7 deletions
|
@ -370,15 +370,26 @@ static GstCaps *
|
||||||
gst_udpsrc_getcaps (GstBaseSrc * src, GstCaps * filter)
|
gst_udpsrc_getcaps (GstBaseSrc * src, GstCaps * filter)
|
||||||
{
|
{
|
||||||
GstUDPSrc *udpsrc;
|
GstUDPSrc *udpsrc;
|
||||||
|
GstCaps *caps, *result;
|
||||||
|
|
||||||
udpsrc = GST_UDPSRC (src);
|
udpsrc = GST_UDPSRC (src);
|
||||||
|
|
||||||
if (udpsrc->caps) {
|
GST_OBJECT_LOCK (src);
|
||||||
return (filter) ? gst_caps_intersect_full (filter, udpsrc->caps,
|
if ((caps = udpsrc->caps))
|
||||||
GST_CAPS_INTERSECT_FIRST) : gst_caps_ref (udpsrc->caps);
|
gst_caps_ref (caps);
|
||||||
|
GST_OBJECT_UNLOCK (src);
|
||||||
|
|
||||||
|
if (caps) {
|
||||||
|
if (filter) {
|
||||||
|
result = gst_caps_intersect_full (filter, caps, GST_CAPS_INTERSECT_FIRST);
|
||||||
|
gst_caps_unref (caps);
|
||||||
|
} else {
|
||||||
|
result = caps;
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
return (filter) ? gst_caps_ref (filter) : gst_caps_new_any ();
|
result = (filter) ? gst_caps_ref (filter) : gst_caps_new_any ();
|
||||||
}
|
}
|
||||||
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
static GstFlowReturn
|
static GstFlowReturn
|
||||||
|
@ -656,9 +667,7 @@ gst_udpsrc_set_property (GObject * object, guint prop_id, const GValue * value,
|
||||||
case PROP_CAPS:
|
case PROP_CAPS:
|
||||||
{
|
{
|
||||||
const GstCaps *new_caps_val = gst_value_get_caps (value);
|
const GstCaps *new_caps_val = gst_value_get_caps (value);
|
||||||
|
|
||||||
GstCaps *new_caps;
|
GstCaps *new_caps;
|
||||||
|
|
||||||
GstCaps *old_caps;
|
GstCaps *old_caps;
|
||||||
|
|
||||||
if (new_caps_val == NULL) {
|
if (new_caps_val == NULL) {
|
||||||
|
@ -667,11 +676,14 @@ gst_udpsrc_set_property (GObject * object, guint prop_id, const GValue * value,
|
||||||
new_caps = gst_caps_copy (new_caps_val);
|
new_caps = gst_caps_copy (new_caps_val);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
GST_OBJECT_LOCK (udpsrc);
|
||||||
old_caps = udpsrc->caps;
|
old_caps = udpsrc->caps;
|
||||||
udpsrc->caps = new_caps;
|
udpsrc->caps = new_caps;
|
||||||
|
GST_OBJECT_UNLOCK (udpsrc);
|
||||||
if (old_caps)
|
if (old_caps)
|
||||||
gst_caps_unref (old_caps);
|
gst_caps_unref (old_caps);
|
||||||
gst_pad_set_caps (GST_BASE_SRC (udpsrc)->srcpad, new_caps);
|
|
||||||
|
gst_pad_mark_reconfigure (GST_BASE_SRC_PAD (udpsrc));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case PROP_SOCKET:
|
case PROP_SOCKET:
|
||||||
|
@ -734,7 +746,9 @@ gst_udpsrc_get_property (GObject * object, guint prop_id, GValue * value,
|
||||||
g_value_set_string (value, udpsrc->uri);
|
g_value_set_string (value, udpsrc->uri);
|
||||||
break;
|
break;
|
||||||
case PROP_CAPS:
|
case PROP_CAPS:
|
||||||
|
GST_OBJECT_LOCK (udpsrc);
|
||||||
gst_value_set_caps (value, udpsrc->caps);
|
gst_value_set_caps (value, udpsrc->caps);
|
||||||
|
GST_OBJECT_UNLOCK (udpsrc);
|
||||||
break;
|
break;
|
||||||
case PROP_SOCKET:
|
case PROP_SOCKET:
|
||||||
g_value_set_object (value, udpsrc->socket);
|
g_value_set_object (value, udpsrc->socket);
|
||||||
|
|
Loading…
Reference in a new issue