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.
This commit is contained in:
David Schleef 2004-01-27 02:06:02 +00:00
parent e02c8aae61
commit 3607f4f024
5 changed files with 62 additions and 4 deletions

View file

@ -1,3 +1,11 @@
2004-01-26 David Schleef <ds@schleef.org>
* 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 <ds@schleef.org> 2004-01-26 David Schleef <ds@schleef.org>
* gst/gstpad.c: (gst_pad_try_set_caps): Revert last change * gst/gstpad.c: (gst_pad_try_set_caps): Revert last change

View file

@ -1378,13 +1378,66 @@ gst_pad_try_set_caps (GstPad *pad, const GstCaps *caps)
return ret; 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: * gst_pad_can_link_filtered:

View file

@ -410,6 +410,7 @@ gboolean gst_pad_is_negotiated (GstPad *pad);
GstCaps* gst_pad_get_caps (GstPad *pad); GstCaps* gst_pad_get_caps (GstPad *pad);
G_CONST_RETURN GstCaps* gst_pad_get_pad_template_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 (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); gboolean gst_pad_check_compatibility (GstPad *srcpad, GstPad *sinkpad);
void gst_pad_set_getcaps_function (GstPad *pad, GstPadGetCapsFunction getcaps); void gst_pad_set_getcaps_function (GstPad *pad, GstPadGetCapsFunction getcaps);

View file

@ -510,7 +510,6 @@ restart:
* to make things read-only. Also keep our list uptodate. */ * to make things read-only. Also keep our list uptodate. */
queue->cur_level.bytes -= GST_BUFFER_SIZE (data); queue->cur_level.bytes -= GST_BUFFER_SIZE (data);
queue->cur_level.buffers --; queue->cur_level.buffers --;
g_object_notify (G_OBJECT (queue), "current-level-buffers");
if (GST_BUFFER_DURATION (data) != GST_CLOCK_TIME_NONE) if (GST_BUFFER_DURATION (data) != GST_CLOCK_TIME_NONE)
queue->cur_level.time -= GST_BUFFER_DURATION (data); queue->cur_level.time -= GST_BUFFER_DURATION (data);
@ -606,7 +605,6 @@ restart:
/* Note that we only add buffers (not events) to the statistics */ /* Note that we only add buffers (not events) to the statistics */
if (GST_IS_BUFFER (data)) { if (GST_IS_BUFFER (data)) {
queue->cur_level.buffers++; queue->cur_level.buffers++;
g_object_notify (G_OBJECT (queue), "current-level-buffers");
queue->cur_level.bytes += GST_BUFFER_SIZE (data); queue->cur_level.bytes += GST_BUFFER_SIZE (data);
if (GST_BUFFER_DURATION (data) != GST_CLOCK_TIME_NONE) if (GST_BUFFER_DURATION (data) != GST_CLOCK_TIME_NONE)
queue->cur_level.time += GST_BUFFER_DURATION (data); queue->cur_level.time += GST_BUFFER_DURATION (data);

View file

@ -510,7 +510,6 @@ restart:
* to make things read-only. Also keep our list uptodate. */ * to make things read-only. Also keep our list uptodate. */
queue->cur_level.bytes -= GST_BUFFER_SIZE (data); queue->cur_level.bytes -= GST_BUFFER_SIZE (data);
queue->cur_level.buffers --; queue->cur_level.buffers --;
g_object_notify (G_OBJECT (queue), "current-level-buffers");
if (GST_BUFFER_DURATION (data) != GST_CLOCK_TIME_NONE) if (GST_BUFFER_DURATION (data) != GST_CLOCK_TIME_NONE)
queue->cur_level.time -= GST_BUFFER_DURATION (data); queue->cur_level.time -= GST_BUFFER_DURATION (data);
@ -606,7 +605,6 @@ restart:
/* Note that we only add buffers (not events) to the statistics */ /* Note that we only add buffers (not events) to the statistics */
if (GST_IS_BUFFER (data)) { if (GST_IS_BUFFER (data)) {
queue->cur_level.buffers++; queue->cur_level.buffers++;
g_object_notify (G_OBJECT (queue), "current-level-buffers");
queue->cur_level.bytes += GST_BUFFER_SIZE (data); queue->cur_level.bytes += GST_BUFFER_SIZE (data);
if (GST_BUFFER_DURATION (data) != GST_CLOCK_TIME_NONE) if (GST_BUFFER_DURATION (data) != GST_CLOCK_TIME_NONE)
queue->cur_level.time += GST_BUFFER_DURATION (data); queue->cur_level.time += GST_BUFFER_DURATION (data);