gst/: Implement accept_caps.
authorWim Taymans <wim.taymans@gmail.com>
Mon, 9 May 2005 14:47:15 +0000 (14:47 +0000)
committerWim Taymans <wim.taymans@gmail.com>
Mon, 9 May 2005 14:47:15 +0000 (14:47 +0000)
Original commit message from CVS:
* gst/base/gstbasetransform.c: (gst_base_transform_proxy_getcaps),
(gst_base_transform_event):
* gst/gstpad.c: (gst_pad_accept_caps), (gst_pad_query):
Implement accept_caps.
Fix silly lock/unlock mismatch in base class.

ChangeLog
gst/base/gstbasetransform.c
gst/gstpad.c
libs/gst/base/gstbasetransform.c

index aa23ce1..b284660 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,13 @@
 2005-05-09  Wim Taymans  <wim@fluendo.com>
 
+       * gst/base/gstbasetransform.c: (gst_base_transform_proxy_getcaps),
+       (gst_base_transform_event):
+       * gst/gstpad.c: (gst_pad_accept_caps), (gst_pad_query):
+       Implement accept_caps.
+       Fix silly lock/unlock mismatch in base class.
+
+2005-05-09  Wim Taymans  <wim@fluendo.com>
+
        * docs/design/draft-push-pull.txt:
        * gst/base/gstbasesrc.c: (gst_basesrc_init), (gst_basesrc_query):
        * gst/elements/gstfilesink.c: (gst_filesink_init),
index 5947067..abfbcd6 100644 (file)
@@ -216,6 +216,7 @@ gst_base_transform_event (GstPad * pad, GstEvent * event)
   GstBaseTransform *trans;
   GstBaseTransformClass *bclass;
   gboolean ret = FALSE;
+  gboolean unlock;
 
   trans = GST_BASE_TRANSFORM (GST_PAD_PARENT (pad));
   bclass = GST_BASE_TRANSFORM_GET_CLASS (trans);
@@ -223,20 +224,25 @@ gst_base_transform_event (GstPad * pad, GstEvent * event)
   if (bclass->event)
     bclass->event (trans, event);
 
+  unlock = FALSE;
+
   switch (GST_EVENT_TYPE (event)) {
     case GST_EVENT_FLUSH:
       if (GST_EVENT_FLUSH_DONE (event)) {
       }
       GST_STREAM_LOCK (pad);
+      unlock = TRUE;
       break;
     case GST_EVENT_EOS:
       GST_STREAM_LOCK (pad);
+      unlock = TRUE;
       break;
     default:
       break;
   }
   ret = gst_pad_event_default (pad, event);
-  GST_STREAM_UNLOCK (pad);
+  if (unlock)
+    GST_STREAM_UNLOCK (pad);
 
   return ret;
 }
index 8981c38..3aa9ef4 100644 (file)
@@ -1791,8 +1791,22 @@ gst_pad_accept_caps (GstPad * pad, GstCaps * caps)
   GST_CAT_DEBUG (GST_CAT_CAPS, "pad accept caps of %s:%s (%p)",
       GST_DEBUG_PAD_NAME (realpad), realpad);
 
-  /* FIXME, call accept function */
-  result = FALSE;
+  if (GST_RPAD_ACCEPTCAPSFUNC (pad)) {
+    /* we can call the function */
+    result = GST_RPAD_ACCEPTCAPSFUNC (realpad) (pad, caps);
+  } else {
+    /* else see get the caps and see if it intersects to something
+     * not empty */
+    GstCaps *intersect;
+    GstCaps *allowed;
+
+    allowed = gst_real_pad_get_caps_unlocked (realpad);
+    intersect = gst_caps_intersect (allowed, caps);
+    if (gst_caps_is_empty (intersect))
+      result = FALSE;
+    else
+      result = TRUE;
+  }
   GST_UNLOCK (realpad);
 
   return result;
index 5947067..abfbcd6 100644 (file)
@@ -216,6 +216,7 @@ gst_base_transform_event (GstPad * pad, GstEvent * event)
   GstBaseTransform *trans;
   GstBaseTransformClass *bclass;
   gboolean ret = FALSE;
+  gboolean unlock;
 
   trans = GST_BASE_TRANSFORM (GST_PAD_PARENT (pad));
   bclass = GST_BASE_TRANSFORM_GET_CLASS (trans);
@@ -223,20 +224,25 @@ gst_base_transform_event (GstPad * pad, GstEvent * event)
   if (bclass->event)
     bclass->event (trans, event);
 
+  unlock = FALSE;
+
   switch (GST_EVENT_TYPE (event)) {
     case GST_EVENT_FLUSH:
       if (GST_EVENT_FLUSH_DONE (event)) {
       }
       GST_STREAM_LOCK (pad);
+      unlock = TRUE;
       break;
     case GST_EVENT_EOS:
       GST_STREAM_LOCK (pad);
+      unlock = TRUE;
       break;
     default:
       break;
   }
   ret = gst_pad_event_default (pad, event);
-  GST_STREAM_UNLOCK (pad);
+  if (unlock)
+    GST_STREAM_UNLOCK (pad);
 
   return ret;
 }