Remove GstImplementsInterface
authorTim-Philipp Müller <tim.muller@collabora.co.uk>
Mon, 20 Jun 2011 22:28:07 +0000 (23:28 +0100)
committerTim-Philipp Müller <tim.muller@collabora.co.uk>
Sun, 26 Jun 2011 21:59:26 +0000 (22:59 +0100)
It was a bit too clever, and didn't really work as an API,
confusing people to no end. Better implement specific methods
whether an interface is usable/available/ready on the interface
itself, or even add GError arguments, rather than try to have
per-instance interfaces.

18 files changed:
docs/gst/gstreamer-docs.sgml
docs/gst/gstreamer-sections.txt
docs/gst/gstreamer.types.in
docs/random/porting-to-0.11.txt
gst/Makefile.am
gst/gst.h
gst/gstinterface.c [deleted file]
gst/gstinterface.h [deleted file]
tests/check/Makefile.am
tests/check/gst/.gitignore
tests/check/gst/gstinterface.c [deleted file]
tests/check/gst/struct_arm.h
tests/check/gst/struct_hppa.h
tests/check/gst/struct_i386.h
tests/check/gst/struct_ppc32.h
tests/check/gst/struct_ppc64.h
tests/check/gst/struct_sparc.h
tests/check/gst/struct_x86_64.h

index dc4bef3..7f69328 100644 (file)
@@ -75,7 +75,6 @@ Windows.  It is released under the GNU Library General Public License
     <xi:include href="xml/gstfilter.xml" />
     <xi:include href="xml/gstformat.xml" />
     <xi:include href="xml/gstghostpad.xml" />
-    <xi:include href="xml/gstimplementsinterface.xml" />
     <xi:include href="xml/gstindex.xml" />
     <xi:include href="xml/gstindexfactory.xml" />
     <xi:include href="xml/gstiterator.xml" />
index f02d03e..e0e6f57 100644 (file)
@@ -1203,27 +1203,6 @@ gst_debug_graph_details_get_type
 GST_CAT_LEVEL_LOG_valist
 </SECTION>
 
-
-<SECTION>
-<FILE>gstimplementsinterface</FILE>
-<TITLE>GstImplementsInterface</TITLE>
-GstImplementsInterface
-gst_element_implements_interface
-gst_implements_interface_cast
-gst_implements_interface_check
-<SUBSECTION Standard>
-GstImplementsInterfaceClass
-GST_IMPLEMENTS_INTERFACE
-GST_IS_IMPLEMENTS_INTERFACE
-GST_IMPLEMENTS_INTERFACE_GET_CLASS
-GST_TYPE_IMPLEMENTS_INTERFACE
-GST_IMPLEMENTS_INTERFACE_CHECK_INSTANCE_CAST
-GST_IMPLEMENTS_INTERFACE_CHECK_INSTANCE_TYPE
-<SUBSECTION Private>
-gst_implements_interface_get_type
-</SECTION>
-
-
 <SECTION>
 <FILE>gstiterator</FILE>
 <TITLE>GstIterator</TITLE>
index 3ac4043..efd6e2d 100644 (file)
@@ -15,7 +15,6 @@ gst_clock_get_type
 gst_element_factory_get_type
 gst_element_get_type
 gst_ghost_pad_get_type
-gst_implements_interface_get_type
 gst_index_factory_get_type
 gst_index_get_type
 gst_object_get_type
index 828aaf5..ad166ce 100644 (file)
@@ -318,4 +318,9 @@ The 0.11 porting guide
     GstBaseTransform::transform_caps() now gets the complete caps passed
     instead of getting it passed structure by structure.
 
+* GstImplementsInterface
+    has been removed. Interfaces need to be updated to either have
+    is_ready/usable/available() methods, or have GError arguments
+    to their methods so we can return an appropriate error if a
+    particular interface isn't supported for a particular device.
 
index 8988efe..cfff0a9 100644 (file)
@@ -68,7 +68,6 @@ libgstreamer_@GST_MAJORMINOR@_la_SOURCES = \
        gstindex.c              \
        gstindexfactory.c       \
        gstinfo.c               \
-       gstinterface.c          \
        gstiterator.c           \
        gstatomicqueue.c        \
        gstmessage.c            \
@@ -163,7 +162,6 @@ gst_headers =                       \
        gstindex.h              \
        gstindexfactory.h       \
        gstinfo.h               \
-       gstinterface.h          \
        gstiterator.h           \
        gstatomicqueue.h        \
        gstmacros.h             \
index 954fd6c..ce86d21 100644 (file)
--- a/gst/gst.h
+++ b/gst/gst.h
@@ -48,7 +48,6 @@
 #include <gst/gstindex.h>
 #include <gst/gstindexfactory.h>
 #include <gst/gstinfo.h>
-#include <gst/gstinterface.h>
 #include <gst/gstiterator.h>
 #include <gst/gstmarshal.h>
 #include <gst/gstmessage.h>
diff --git a/gst/gstinterface.c b/gst/gstinterface.c
deleted file mode 100644 (file)
index 4214ebc..0000000
+++ /dev/null
@@ -1,191 +0,0 @@
-/* GStreamer
- *
- * Copyright (C) 1999,2000 Erik Walthinsen <omega@cse.ogi.edu>
- *                    2000 Wim Taymans <wtay@chello.be>
- *
- * gstinterface.c: Interface functions
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Library General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Library General Public License for more details.
- *
- * You should have received a copy of the GNU Library General Public
- * License along with this library; if not, write to the
- * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
- * Boston, MA 02111-1307, USA.
- */
-
-/**
- * SECTION:gstimplementsinterface
- * @short_description: Core interface implemented by #GstElement instances that
- * allows runtime querying of interface availabillity
- * @see_also: #GstElement
- *
- * Provides interface functionality on per instance basis and not per class
- * basis, which is the case for gobject.
- */
-
-#ifdef HAVE_CONFIG_H
-#include "config.h"
-#endif
-
-#include "gst_private.h"
-#include "gstinterface.h"
-
-static void
-gst_implements_interface_class_init (GstImplementsInterfaceClass * ifklass);
-static gboolean
-gst_implements_interface_supported_default (GstImplementsInterface * iface,
-    GType iface_type);
-
-GType
-gst_implements_interface_get_type (void)
-{
-  static volatile gsize gst_interface_type = 0;
-
-  if (g_once_init_enter (&gst_interface_type)) {
-    GType _type;
-    static const GTypeInfo gst_interface_info = {
-      sizeof (GstImplementsInterfaceClass),
-      (GBaseInitFunc) gst_implements_interface_class_init,
-      NULL,
-      NULL,
-      NULL,
-      NULL,
-      0,
-      0,
-      NULL,
-      NULL
-    };
-
-    _type = g_type_register_static (G_TYPE_INTERFACE,
-        "GstImplementsInterface", &gst_interface_info, 0);
-
-    g_type_interface_add_prerequisite (_type, GST_TYPE_ELEMENT);
-    g_once_init_leave (&gst_interface_type, _type);
-  }
-
-  return gst_interface_type;
-}
-
-static void
-gst_implements_interface_class_init (GstImplementsInterfaceClass * klass)
-{
-  klass->supported = gst_implements_interface_supported_default;
-}
-
-static gboolean
-gst_implements_interface_supported_default (GstImplementsInterface * interface,
-    GType iface_type)
-{
-  /* Well, if someone didn't set the virtual function,
-   * then something is clearly wrong. So big no-no here */
-
-  return FALSE;
-}
-
-/**
- * gst_element_implements_interface:
- * @element: #GstElement to check for the implementation of the interface
- * @iface_type: (final) type of the interface which we want to be implemented
- *
- * Test whether the given element implements a certain interface of type
- * iface_type, and test whether it is supported for this specific instance.
- *
- * Returns: whether or not the element implements the interface.
- */
-
-gboolean
-gst_element_implements_interface (GstElement * element, GType iface_type)
-{
-  g_return_val_if_fail (GST_IS_ELEMENT (element), FALSE);
-
-  if (G_TYPE_CHECK_INSTANCE_TYPE (G_OBJECT (element), iface_type)) {
-    GstImplementsInterface *iface;
-    GstImplementsInterfaceClass *ifclass;
-
-    iface = G_TYPE_CHECK_INSTANCE_CAST (G_OBJECT (element),
-        iface_type, GstImplementsInterface);
-    ifclass = GST_IMPLEMENTS_INTERFACE_GET_CLASS (iface);
-
-    /* element implements iface_type but not GstImplementsInterface, so
-     * just assume the other interface is implemented unconditionally */
-    if (ifclass == NULL)
-      return TRUE;
-
-    if (ifclass->supported != NULL &&
-        ifclass->supported (iface, iface_type) == TRUE) {
-      return TRUE;
-    }
-  }
-
-  return FALSE;
-}
-
-/**
- * gst_implements_interface_cast:
- * @from: the object (any sort) from which to cast to the interface
- * @type: the interface type to cast to
- *
- * cast a given object to an interface type, and check whether this
- * interface is supported for this specific instance.
- *
- * Returns: (transfer none): a gpointer to the interface type
- */
-
-gpointer
-gst_implements_interface_cast (gpointer from, GType iface_type)
-{
-  GstImplementsInterface *iface;
-
-  /* check cast, give warning+fail if it's invalid */
-  if (!(iface = G_TYPE_CHECK_INSTANCE_CAST (from, iface_type,
-              GstImplementsInterface))) {
-    return NULL;
-  }
-
-  /* if we're an element, take care that this interface
-   * is actually implemented */
-  if (GST_IS_ELEMENT (from)) {
-    g_return_val_if_fail (gst_element_implements_interface (GST_ELEMENT (from),
-            iface_type), NULL);
-  }
-
-  return iface;
-}
-
-/**
- * gst_implements_interface_check:
- * @from: the object (any sort) from which to check from for the interface
- * @type: the interface type to check for
- *
- * check a given object for an interface implementation, and check
- * whether this interface is supported for this specific instance.
- *
- * Returns: whether or not the object implements the given interface
- */
-
-gboolean
-gst_implements_interface_check (gpointer from, GType type)
-{
-  /* check cast, return FALSE if it fails, don't give a warning... */
-  if (!G_TYPE_CHECK_INSTANCE_TYPE (from, type)) {
-    return FALSE;
-  }
-
-  /* now, if we're an element (or derivative), is this thing
-   * actually implemented for real? */
-  if (GST_IS_ELEMENT (from)) {
-    if (!gst_element_implements_interface (GST_ELEMENT (from), type)) {
-      return FALSE;
-    }
-  }
-
-  return TRUE;
-}
diff --git a/gst/gstinterface.h b/gst/gstinterface.h
deleted file mode 100644 (file)
index 860d9de..0000000
+++ /dev/null
@@ -1,81 +0,0 @@
-/* GStreamer
- * Copyright (C) 1999,2000 Erik Walthinsen <omega@cse.ogi.edu>
- *                    2000 Wim Taymans <wtay@chello.be>
- *
- * gstinterface.h: Declarations of interface stuff
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Library General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Library General Public License for more details.
- *
- * You should have received a copy of the GNU Library General Public
- * License along with this library; if not, write to the
- * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
- * Boston, MA 02111-1307, USA.
- */
-
-#ifndef __GST_IMPLEMENTS_INTERFACE_H__
-#define __GST_IMPLEMENTS_INTERFACE_H__
-
-#include <gst/gstelement.h>
-
-G_BEGIN_DECLS
-
-#define GST_TYPE_IMPLEMENTS_INTERFACE \
-  (gst_implements_interface_get_type ())
-#define GST_IMPLEMENTS_INTERFACE(obj) \
-  (G_TYPE_CHECK_INSTANCE_CAST ((obj), GST_TYPE_IMPLEMENTS_INTERFACE, \
-                                     GstImplementsInterface))
-#define GST_IS_IMPLEMENTS_INTERFACE(obj) \
-  (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GST_TYPE_IMPLEMENTS_INTERFACE))
-#define GST_IMPLEMENTS_INTERFACE_GET_CLASS(inst) \
-  (G_TYPE_INSTANCE_GET_INTERFACE ((inst), GST_TYPE_IMPLEMENTS_INTERFACE, \
-                                 GstImplementsInterfaceClass))
-
-/**
- * GstImplementsInterface:
- *
- * Opaque #GstImplementsInterface structure.
- */
-typedef struct _GstImplementsInterface GstImplementsInterface;
-
-typedef struct _GstImplementsInterfaceClass GstImplementsInterfaceClass;
-
-/* This small extra virtual function is here to provide an
- * interface functionality on a per-instance basis rather
- * than a per-class basis, which is the case for glib.
- */
-struct _GstImplementsInterfaceClass {
-  GTypeInterface parent;
-
-  /* virtual functions */
-  gboolean (* supported) (GstImplementsInterface *iface,
-                         GType                   iface_type);
-
-  gpointer _gst_reserved[GST_PADDING];
-};
-
-#define GST_IMPLEMENTS_INTERFACE_CHECK_INSTANCE_CAST(obj, type, cast_t) \
-  ((cast_t *) gst_implements_interface_cast ((obj), (type)))
-#define GST_IMPLEMENTS_INTERFACE_CHECK_INSTANCE_TYPE(obj, type) \
-  (gst_implements_interface_check ((obj), (type)))
-
-GType   gst_implements_interface_get_type    (void);
-
-/* wrapper functions to check for functionality implementation */
-gboolean gst_element_implements_interface     (GstElement *element,
-                                              GType       iface_type);
-gpointer gst_implements_interface_cast       (gpointer    from,
-                                              GType       type);
-gboolean gst_implements_interface_check              (gpointer    from,
-                                              GType       type);
-
-G_END_DECLS
-
-#endif /* __GST_IMPLEMENTS_INTERFACE_H__ */
index 341e0bd..43aac86 100644 (file)
@@ -67,7 +67,6 @@ REGISTRY_CHECKS =                             \
        gst/gstevent                            \
        gst/gstghostpad                         \
        gst/gstindex                            \
-       gst/gstinterface                                \
        gst/gstplugin                           \
        gst/gstpreset                           \
        gst/gstquery                            \
index 6cacd55..2440d56 100644 (file)
@@ -17,7 +17,6 @@ gstevent
 gstghostpad
 gstiterator
 gstindex
-gstinterface
 gstmessage
 gstmeta
 gstminiobject
diff --git a/tests/check/gst/gstinterface.c b/tests/check/gst/gstinterface.c
deleted file mode 100644 (file)
index 4697a1f..0000000
+++ /dev/null
@@ -1,62 +0,0 @@
-/* GStreamer GstImplementsInterface check
- * Copyright (C) 2008 Tim-Philipp Müller <tim centricular net>
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Library General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Library General Public License for more details.
- *
- * You should have received a copy of the GNU Library General Public
- * License along with this library; if not, write to the
- * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
- * Boston, MA 02111-1307, USA.
- */
-
-
-#include <gst/check/gstcheck.h>
-
-GST_START_TEST (test_without_implements_interface)
-{
-  GstElement *element;
-
-  /* we shouldn't crash if someone tries to use
-   * gst_element_implements_interface() on an element which doesn't implement
-   * the GstImplementsInterface (neither if the element does implement the
-   * requested interface, nor if it doesn't) */
-  element = gst_element_factory_make ("filesrc", "filesrc");
-  fail_unless (element != NULL, "Could not create filesrc element");
-
-  /* does not implement GstImplementsInterface, but does implement the
-   * GstUriHandler interface, so should just return TRUE */
-  fail_if (!gst_element_implements_interface (element, GST_TYPE_URI_HANDLER));
-  fail_if (gst_element_implements_interface (element,
-          GST_TYPE_IMPLEMENTS_INTERFACE));
-  gst_object_unref (element);
-
-  element = gst_element_factory_make ("identity", "identity");
-  fail_unless (element != NULL, "Could not create identity element");
-  fail_if (gst_element_implements_interface (element, GST_TYPE_URI_HANDLER));
-  fail_if (gst_element_implements_interface (element,
-          GST_TYPE_IMPLEMENTS_INTERFACE));
-  gst_object_unref (element);
-}
-
-GST_END_TEST;
-
-static Suite *
-gst_interface_suite (void)
-{
-  Suite *s = suite_create ("GstImplementsInterface");
-  TCase *tc_chain = tcase_create ("correctness");
-
-  suite_add_tcase (s, tc_chain);
-  tcase_add_test (tc_chain, test_without_implements_interface);
-  return s;
-}
-
-GST_CHECK_MAIN (gst_interface);
index 3d3e133..73764c9 100644 (file)
@@ -27,7 +27,6 @@ GstCheckABIStruct list[] = {
   {"GstIndexFactory", sizeof (GstIndexFactory), 96},
   {"GstIndexFactoryClass", sizeof (GstIndexFactoryClass), 152},
   {"GstDebugCategory", sizeof (GstDebugCategory), 16},
-  {"GstImplementsInterfaceClass", sizeof (GstImplementsInterfaceClass), 28},
   {"GstIterator", sizeof (GstIterator), 52},
   {"GstMessage", sizeof (GstMessage), 64},
   {"GstMessageClass", sizeof (GstMessageClass), 32},
index b178244..7f325f3 100644 (file)
@@ -26,7 +26,6 @@ static GstCheckABIStruct list[] = {
   {"GstIndexFactory", sizeof (GstIndexFactory), 96},
   {"GstIndexFactoryClass", sizeof (GstIndexFactoryClass), 152},
   {"GstDebugCategory", sizeof (GstDebugCategory), 16},
-  {"GstImplementsInterfaceClass", sizeof (GstImplementsInterfaceClass), 28},
   {"GstIterator", sizeof (GstIterator), 52},
   {"GstMessage", sizeof (GstMessage), 64},
   {"GstMessageClass", sizeof (GstMessageClass), 32},
index 744b7f2..87868b9 100644 (file)
@@ -26,7 +26,6 @@ static GstCheckABIStruct list[] = {
  {"GstIndexFactory", sizeof(GstIndexFactory), 96},
  {"GstIndexFactoryClass", sizeof(GstIndexFactoryClass), 152},
  {"GstDebugCategory", sizeof(GstDebugCategory), 16},
- {"GstImplementsInterfaceClass", sizeof(GstImplementsInterfaceClass), 28},
  {"GstIterator", sizeof(GstIterator), 52},
  {"GstMessage", sizeof(GstMessage), 60},
  {"GstMessageClass", sizeof(GstMessageClass), 32},
index b178244..7f325f3 100644 (file)
@@ -26,7 +26,6 @@ static GstCheckABIStruct list[] = {
   {"GstIndexFactory", sizeof (GstIndexFactory), 96},
   {"GstIndexFactoryClass", sizeof (GstIndexFactoryClass), 152},
   {"GstDebugCategory", sizeof (GstDebugCategory), 16},
-  {"GstImplementsInterfaceClass", sizeof (GstImplementsInterfaceClass), 28},
   {"GstIterator", sizeof (GstIterator), 52},
   {"GstMessage", sizeof (GstMessage), 64},
   {"GstMessageClass", sizeof (GstMessageClass), 32},
index 259f902..3c3dbcd 100644 (file)
@@ -26,7 +26,6 @@ static GstCheckABIStruct list[] = {
   {"GstIndexFactory", sizeof (GstIndexFactory), 192} ,
   {"GstIndexFactoryClass", sizeof (GstIndexFactoryClass), 304} ,
   {"GstDebugCategory", sizeof (GstDebugCategory), 24} ,
-  {"GstImplementsInterfaceClass", sizeof (GstImplementsInterfaceClass), 56} ,
   {"GstIterator", sizeof (GstIterator), 104} ,
   {"GstMessage", sizeof (GstMessage), 104} ,
   {"GstMessageClass", sizeof (GstMessageClass), 64} ,
index 3d3e133..73764c9 100644 (file)
@@ -27,7 +27,6 @@ GstCheckABIStruct list[] = {
   {"GstIndexFactory", sizeof (GstIndexFactory), 96},
   {"GstIndexFactoryClass", sizeof (GstIndexFactoryClass), 152},
   {"GstDebugCategory", sizeof (GstDebugCategory), 16},
-  {"GstImplementsInterfaceClass", sizeof (GstImplementsInterfaceClass), 28},
   {"GstIterator", sizeof (GstIterator), 52},
   {"GstMessage", sizeof (GstMessage), 64},
   {"GstMessageClass", sizeof (GstMessageClass), 32},
index 51f010b..91cdcf5 100644 (file)
@@ -22,7 +22,6 @@ static GstCheckABIStruct list[] = {
   {"GstFormatDefinition", sizeof (GstFormatDefinition), 32},
   {"GstGhostPadClass", sizeof (GstGhostPadClass), 344},
   {"GstGhostPad", sizeof (GstGhostPad), 384},
-  {"GstImplementsInterfaceClass", sizeof (GstImplementsInterfaceClass), 56},
   {"GstIndexAssociation", sizeof (GstIndexAssociation), 16},
   {"GstIndexClass", sizeof (GstIndexClass), 312},
   {"GstIndexEntry", sizeof (GstIndexEntry), 32},