2003-09-13 01:10:12 +00:00
|
|
|
/* 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.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifdef HAVE_CONFIG_H
|
|
|
|
#include "config.h"
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#include "gstinterface.h"
|
|
|
|
#include "gstlog.h"
|
|
|
|
|
2003-12-07 12:08:44 +00:00
|
|
|
static void
|
|
|
|
gst_implements_interface_class_init (GstImplementsInterfaceClass *ifklass);
|
|
|
|
static gboolean
|
|
|
|
gst_implements_interface_supported_default (GstImplementsInterface *iface,
|
|
|
|
GType iface_type);
|
2003-09-13 01:10:12 +00:00
|
|
|
|
|
|
|
GType
|
2003-12-07 12:08:44 +00:00
|
|
|
gst_implements_interface_get_type (void)
|
2003-09-13 01:10:12 +00:00
|
|
|
{
|
|
|
|
static GType gst_interface_type = 0;
|
|
|
|
|
|
|
|
if (!gst_interface_type) {
|
|
|
|
static const GTypeInfo gst_interface_info = {
|
2003-12-07 12:08:44 +00:00
|
|
|
sizeof (GstImplementsInterfaceClass),
|
|
|
|
(GBaseInitFunc) gst_implements_interface_class_init,
|
2003-09-13 01:10:12 +00:00
|
|
|
NULL,
|
|
|
|
NULL,
|
|
|
|
NULL,
|
|
|
|
NULL,
|
|
|
|
0,
|
|
|
|
0,
|
|
|
|
NULL,
|
|
|
|
NULL
|
|
|
|
};
|
|
|
|
|
|
|
|
gst_interface_type = g_type_register_static (G_TYPE_INTERFACE,
|
2003-12-07 12:08:44 +00:00
|
|
|
"GstImplementsInterface",
|
2003-09-13 01:10:12 +00:00
|
|
|
&gst_interface_info, 0);
|
2003-11-18 19:05:39 +00:00
|
|
|
|
|
|
|
g_type_interface_add_prerequisite (gst_interface_type,
|
|
|
|
GST_TYPE_ELEMENT);
|
2003-09-13 01:10:12 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return gst_interface_type;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2003-12-07 12:08:44 +00:00
|
|
|
gst_implements_interface_class_init (GstImplementsInterfaceClass *klass)
|
2003-09-13 01:10:12 +00:00
|
|
|
{
|
2003-12-07 12:08:44 +00:00
|
|
|
klass->supported = gst_implements_interface_supported_default;
|
2003-09-13 01:10:12 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static gboolean
|
2003-12-07 12:08:44 +00:00
|
|
|
gst_implements_interface_supported_default (GstImplementsInterface *interface,
|
|
|
|
GType iface_type)
|
2003-09-13 01:10:12 +00:00
|
|
|
{
|
|
|
|
/* 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.
|
|
|
|
*/
|
|
|
|
|
|
|
|
gboolean
|
|
|
|
gst_element_implements_interface (GstElement *element,
|
|
|
|
GType iface_type)
|
|
|
|
{
|
|
|
|
if (G_TYPE_CHECK_INSTANCE_TYPE (G_OBJECT (element),
|
|
|
|
iface_type)) {
|
2003-12-07 12:08:44 +00:00
|
|
|
GstImplementsInterface *iface;
|
|
|
|
GstImplementsInterfaceClass *ifclass;
|
2003-09-13 01:10:12 +00:00
|
|
|
|
|
|
|
iface = G_TYPE_CHECK_INSTANCE_CAST (G_OBJECT (element),
|
2003-12-07 12:08:44 +00:00
|
|
|
iface_type, GstImplementsInterface);
|
|
|
|
ifclass = GST_IMPLEMENTS_INTERFACE_GET_CLASS (iface);
|
2003-09-13 01:10:12 +00:00
|
|
|
|
|
|
|
if (ifclass->supported != NULL &&
|
2003-09-13 15:47:33 +00:00
|
|
|
ifclass->supported (iface, iface_type) == TRUE) {
|
2003-09-13 01:10:12 +00:00
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2003-12-07 12:08:44 +00:00
|
|
|
* gst_implements_interface_cast:
|
2003-09-13 01:10:12 +00:00
|
|
|
* @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.
|
|
|
|
*/
|
|
|
|
|
2003-12-07 12:08:44 +00:00
|
|
|
gpointer
|
|
|
|
gst_implements_interface_cast (gpointer from,
|
|
|
|
GType iface_type)
|
2003-09-13 01:10:12 +00:00
|
|
|
{
|
2003-12-07 12:08:44 +00:00
|
|
|
GstImplementsInterface *iface;
|
2003-09-13 01:10:12 +00:00
|
|
|
|
|
|
|
/* check cast, give warning+fail if it's invalid */
|
|
|
|
if (!(iface = G_TYPE_CHECK_INSTANCE_CAST (from, iface_type,
|
2003-12-07 12:08:44 +00:00
|
|
|
GstImplementsInterface))) {
|
2003-09-13 01:10:12 +00:00
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* if we're an element, take care that this interface
|
|
|
|
* is actually implemented */
|
|
|
|
if (GST_IS_ELEMENT (from)) {
|
gst/gstcaps.c: add sanity checks
Original commit message from CVS:
2003-12-27 Benjamin Otte <in7y118@public.uni-hamburg.de>
* gst/gstcaps.c: (gst_caps_append):
add sanity checks
* gst/gstcaps.h: (gst_caps_debug):
remove, it doesn't exist anymore.
* gst/gstelement.c: (gst_element_threadsafe_properties_pre_run),
(gst_element_threadsafe_properties_post_run):
make debugging messages not clutter up THREAD debug category
(gst_element_negotiate_pads), (gst_element_clear_pad_caps),
(gst_element_change_state):
update to new caps API
* gst/gstinterface.c: (gst_implements_interface_cast):
don't put vital code in g_return_if_fail
* gst/gstpad.c: (gst_pad_link_try), (gst_pad_try_set_caps),
(gst_pad_link_filtered):
add pst_pad_try_link and use it.
(gst_pad_perform_negotiate), (gst_pad_renegotiate):
implement correctly, deprecate first one.
(gst_pad_link_unnegotiate), (gst_pad_unnegotiate):
add and implement.
(gst_pad_try_relink_filtered), (gst_pad_relink_filtered):
implement.
(gst_pad_get_negotiated_caps):
add and implement. Make GST_PAD_CAPS call this function.
(gst_pad_get_caps):
remove unneeded check..
(gst_pad_recover_caps_error):
disable, always return FALSE.
(gst_real_pad_dispose):
don't free caps and appfilter anymore, they're unused.
* gst/gstpad.h:
Reflect changes mentioned above.
* gst/gstsystemclock.c: (gst_system_clock_wait):
Make 'clock is way behind' a debugging message.
* gst/gstthread.c: (gst_thread_change_state):
Fix debugging message
2003-12-27 13:51:31 +00:00
|
|
|
g_return_val_if_fail (
|
|
|
|
gst_element_implements_interface (GST_ELEMENT (from), iface_type),
|
|
|
|
NULL);
|
2003-09-13 01:10:12 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return iface;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2003-12-07 12:08:44 +00:00
|
|
|
* gst_implements_interface_cast:
|
2003-09-13 01:10:12 +00:00
|
|
|
* @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.
|
|
|
|
*/
|
|
|
|
|
|
|
|
gboolean
|
2003-12-07 12:08:44 +00:00
|
|
|
gst_implements_interface_check (gpointer from,
|
|
|
|
GType type)
|
2003-09-13 01:10:12 +00:00
|
|
|
{
|
2003-12-07 12:08:44 +00:00
|
|
|
GstImplementsInterface *iface;
|
2003-09-13 01:10:12 +00:00
|
|
|
|
|
|
|
/* check cast, return FALSE if it fails, don't give a warning... */
|
2003-09-29 14:32:22 +00:00
|
|
|
if (!G_TYPE_CHECK_INSTANCE_TYPE (from, type)) {
|
2003-09-13 01:10:12 +00:00
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2003-12-07 12:08:44 +00:00
|
|
|
iface = G_TYPE_CHECK_INSTANCE_CAST (from, type, GstImplementsInterface);
|
2003-09-13 01:10:12 +00:00
|
|
|
|
|
|
|
/* 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;
|
|
|
|
}
|