mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-11-27 04:01:08 +00:00
Remove GstImplementsInterface
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.
This commit is contained in:
parent
0aa1465bbc
commit
3dbcb73b11
18 changed files with 5 additions and 369 deletions
|
@ -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" />
|
||||
|
|
|
@ -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>
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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.
|
||||
|
||||
|
|
|
@ -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 \
|
||||
|
|
|
@ -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>
|
||||
|
|
|
@ -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;
|
||||
}
|
|
@ -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__ */
|
|
@ -67,7 +67,6 @@ REGISTRY_CHECKS = \
|
|||
gst/gstevent \
|
||||
gst/gstghostpad \
|
||||
gst/gstindex \
|
||||
gst/gstinterface \
|
||||
gst/gstplugin \
|
||||
gst/gstpreset \
|
||||
gst/gstquery \
|
||||
|
|
1
tests/check/gst/.gitignore
vendored
1
tests/check/gst/.gitignore
vendored
|
@ -17,7 +17,6 @@ gstevent
|
|||
gstghostpad
|
||||
gstiterator
|
||||
gstindex
|
||||
gstinterface
|
||||
gstmessage
|
||||
gstmeta
|
||||
gstminiobject
|
||||
|
|
|
@ -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);
|
|
@ -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},
|
||||
|
|
|
@ -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},
|
||||
|
|
|
@ -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},
|
||||
|
|
|
@ -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},
|
||||
|
|
|
@ -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} ,
|
||||
|
|
|
@ -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},
|
||||
|
|
|
@ -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},
|
||||
|
|
Loading…
Reference in a new issue