From: David Schleef Date: Tue, 27 Jan 2004 02:06:02 +0000 (+0000) Subject: gst/gstpad.*: Add new function to allow element to (somewhat) specify non-fixed caps... X-Git-Tag: BRANCH-RELEASE-0_7_4-ROOT~87 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=3607f4f0242e6364798d40cca621829dc8dc1ae8;p=platform%2Fupstream%2Fgstreamer.git gst/gstpad.*: Add new function to allow element to (somewhat) specify non-fixed caps on a pad. Original commit message from CVS: * gst/gstpad.c: (gst_pad_try_set_caps_nonfixed): * gst/gstpad.h: Add new function to allow element to (somewhat) specify non-fixed caps on a pad. * gst/gstqueue.c: (gst_queue_chain): Remove noisy g_object_notify() that I added a few weeks ago. --- diff --git a/ChangeLog b/ChangeLog index f69837f..be8370a 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,13 @@ 2004-01-26 David Schleef + * gst/gstpad.c: (gst_pad_try_set_caps_nonfixed): + * gst/gstpad.h: Add new function to allow element to (somewhat) + specify non-fixed caps on a pad. + * gst/gstqueue.c: (gst_queue_chain): Remove noisy g_object_notify() + that I added a few weeks ago. + +2004-01-26 David Schleef + * gst/gstpad.c: (gst_pad_try_set_caps): Revert last change making try_set_caps() work with non-fixed caps. diff --git a/gst/gstpad.c b/gst/gstpad.c index db6d0d7..a3d4fe4 100644 --- a/gst/gstpad.c +++ b/gst/gstpad.c @@ -1378,13 +1378,66 @@ gst_pad_try_set_caps (GstPad *pad, const GstCaps *caps) return ret; } +GstPadLinkReturn +gst_pad_try_set_caps_nonfixed (GstPad *pad, const GstCaps *caps) +{ + GstPadLink *link; + GstPadLink *oldlink; + GstPadLinkReturn ret; + g_return_val_if_fail (pad != NULL, GST_PAD_LINK_REFUSED); + g_return_val_if_fail (GST_IS_REAL_PAD (pad), GST_PAD_LINK_REFUSED); + g_return_val_if_fail (!GST_FLAG_IS_SET (pad, GST_PAD_NEGOTIATING), + GST_PAD_LINK_REFUSED); + /* we allow setting caps on non-linked pads. It's ignored */ + if (!GST_PAD_PEER (pad)) { + return GST_PAD_LINK_OK; + } + /* if the link is already negotiated and the caps are compatible + * with what we're setting, it's trivially OK. */ + if (GST_PAD_CAPS (pad)) { + GstCaps *intersection; + intersection = gst_caps_intersect (caps, GST_PAD_CAPS (pad)); + if (!gst_caps_is_empty (intersection)) { + gst_caps_free (intersection); + return GST_PAD_LINK_OK; + } + gst_caps_free (intersection); + } + g_return_val_if_fail (GST_PAD_LINK_SRC (pad), GST_PAD_LINK_REFUSED); + g_return_val_if_fail (GST_PAD_LINK_SINK (pad), GST_PAD_LINK_REFUSED); + link = gst_pad_link_new (); + link->srcpad = GST_PAD_LINK_SRC (pad); + link->sinkpad = GST_PAD_LINK_SINK (pad); + if (!gst_pad_link_ready_for_negotiation (link)) { + gst_pad_link_free (link); + return GST_PAD_LINK_DELAYED; + } + + oldlink = GST_REAL_PAD(pad)->link; + if (oldlink && oldlink->filtercaps) { + link->filtercaps = gst_caps_copy (oldlink->filtercaps); + } + if (link->srcpad == pad) { + link->srccaps = gst_caps_copy(caps); + link->sinkcaps = gst_pad_get_caps (link->sinkpad); + link->srcnotify = FALSE; + } else { + link->srccaps = gst_pad_get_caps (link->srcpad); + link->sinkcaps = gst_caps_copy(caps); + link->sinknotify = FALSE; + } + + ret = gst_pad_link_try (link); + + return ret; +} /** * gst_pad_can_link_filtered: diff --git a/gst/gstpad.h b/gst/gstpad.h index 2b96c3b..07582d1 100644 --- a/gst/gstpad.h +++ b/gst/gstpad.h @@ -410,6 +410,7 @@ gboolean gst_pad_is_negotiated (GstPad *pad); GstCaps* gst_pad_get_caps (GstPad *pad); G_CONST_RETURN GstCaps* gst_pad_get_pad_template_caps (GstPad *pad); GstPadLinkReturn gst_pad_try_set_caps (GstPad *pad, const GstCaps *caps); +GstPadLinkReturn gst_pad_try_set_caps_nonfixed (GstPad *pad, const GstCaps *caps); gboolean gst_pad_check_compatibility (GstPad *srcpad, GstPad *sinkpad); void gst_pad_set_getcaps_function (GstPad *pad, GstPadGetCapsFunction getcaps); diff --git a/gst/gstqueue.c b/gst/gstqueue.c index d9a2155..3f81a98 100644 --- a/gst/gstqueue.c +++ b/gst/gstqueue.c @@ -510,7 +510,6 @@ restart: * to make things read-only. Also keep our list uptodate. */ queue->cur_level.bytes -= GST_BUFFER_SIZE (data); queue->cur_level.buffers --; - g_object_notify (G_OBJECT (queue), "current-level-buffers"); if (GST_BUFFER_DURATION (data) != GST_CLOCK_TIME_NONE) queue->cur_level.time -= GST_BUFFER_DURATION (data); @@ -606,7 +605,6 @@ restart: /* Note that we only add buffers (not events) to the statistics */ if (GST_IS_BUFFER (data)) { queue->cur_level.buffers++; - g_object_notify (G_OBJECT (queue), "current-level-buffers"); queue->cur_level.bytes += GST_BUFFER_SIZE (data); if (GST_BUFFER_DURATION (data) != GST_CLOCK_TIME_NONE) queue->cur_level.time += GST_BUFFER_DURATION (data); diff --git a/plugins/elements/gstqueue.c b/plugins/elements/gstqueue.c index d9a2155..3f81a98 100644 --- a/plugins/elements/gstqueue.c +++ b/plugins/elements/gstqueue.c @@ -510,7 +510,6 @@ restart: * to make things read-only. Also keep our list uptodate. */ queue->cur_level.bytes -= GST_BUFFER_SIZE (data); queue->cur_level.buffers --; - g_object_notify (G_OBJECT (queue), "current-level-buffers"); if (GST_BUFFER_DURATION (data) != GST_CLOCK_TIME_NONE) queue->cur_level.time -= GST_BUFFER_DURATION (data); @@ -606,7 +605,6 @@ restart: /* Note that we only add buffers (not events) to the statistics */ if (GST_IS_BUFFER (data)) { queue->cur_level.buffers++; - g_object_notify (G_OBJECT (queue), "current-level-buffers"); queue->cur_level.bytes += GST_BUFFER_SIZE (data); if (GST_BUFFER_DURATION (data) != GST_CLOCK_TIME_NONE) queue->cur_level.time += GST_BUFFER_DURATION (data);