gst/gstpad.*: Add new function to allow element to (somewhat) specify non-fixed caps...
authorDavid Schleef <ds@schleef.org>
Tue, 27 Jan 2004 02:06:02 +0000 (02:06 +0000)
committerDavid Schleef <ds@schleef.org>
Tue, 27 Jan 2004 02:06:02 +0000 (02:06 +0000)
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.

ChangeLog
gst/gstpad.c
gst/gstpad.h
gst/gstqueue.c
plugins/elements/gstqueue.c

index f69837f..be8370a 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,13 @@
 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>
+
        * gst/gstpad.c: (gst_pad_try_set_caps): Revert last change
          making try_set_caps() work with non-fixed caps.
 
index db6d0d7..a3d4fe4 100644 (file)
@@ -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:
index 2b96c3b..07582d1 100644 (file)
@@ -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);
index d9a2155..3f81a98 100644 (file)
@@ -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);
index d9a2155..3f81a98 100644 (file)
@@ -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);