mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2025-03-30 12:49:40 +00:00
adding unit testing
Original commit message from CVS: * Makefile.am: * check/Makefile.am: * check/gst/.cvsignore: * check/gst/gstobject.c: * configure.ac: adding unit testing * docs/upload.mak: fixing double vars * gst/Makefile.am: disable some unused stuff * gst/gstbus.h: * gst/gsttypes.h: move typedefs for gstbus * gst/gstelement.c: * gst/gstelement.h: add getter/setter for bus and scheduler add functionality to have (non-fatal) warnings as messages * gst/gsterror.c: * gst/gsterror.h: * gst/gstmessage.c: * gst/gstmessage.h: rework API to be more general for warnings as well * gst/gstobject.c: fix docs * tools/gst-launch.c: fix macros for errors
This commit is contained in:
parent
767d9e4681
commit
a192d6d688
21 changed files with 934 additions and 360 deletions
29
ChangeLog
29
ChangeLog
|
@ -1,3 +1,32 @@
|
||||||
|
2004-12-13 Thomas Vander Stichele <thomas at apestaart dot org>
|
||||||
|
|
||||||
|
* Makefile.am:
|
||||||
|
* check/Makefile.am:
|
||||||
|
* check/gst/.cvsignore:
|
||||||
|
* check/gst/gstobject.c:
|
||||||
|
* configure.ac:
|
||||||
|
adding unit testing
|
||||||
|
* docs/upload.mak:
|
||||||
|
fixing double vars
|
||||||
|
* gst/Makefile.am:
|
||||||
|
disable some unused stuff
|
||||||
|
* gst/gstbus.h:
|
||||||
|
* gst/gsttypes.h:
|
||||||
|
move typedefs for gstbus
|
||||||
|
* gst/gstelement.c:
|
||||||
|
* gst/gstelement.h:
|
||||||
|
add getter/setter for bus and scheduler
|
||||||
|
add functionality to have (non-fatal) warnings as messages
|
||||||
|
* gst/gsterror.c:
|
||||||
|
* gst/gsterror.h:
|
||||||
|
* gst/gstmessage.c:
|
||||||
|
* gst/gstmessage.h:
|
||||||
|
rework API to be more general for warnings as well
|
||||||
|
* gst/gstobject.c:
|
||||||
|
fix docs
|
||||||
|
* tools/gst-launch.c:
|
||||||
|
fix macros for errors
|
||||||
|
|
||||||
2004-12-13 Wim Taymans <wim@fluendo.com>
|
2004-12-13 Wim Taymans <wim@fluendo.com>
|
||||||
|
|
||||||
* docs/design/part-MT-refcounting.txt:
|
* docs/design/part-MT-refcounting.txt:
|
||||||
|
|
11
Makefile.am
11
Makefile.am
|
@ -11,8 +11,14 @@ if BUILD_TESTS
|
||||||
## SUBDIRS_TESTS = tests testsuite
|
## SUBDIRS_TESTS = tests testsuite
|
||||||
## FIXME: write tests from scratch
|
## FIXME: write tests from scratch
|
||||||
SUBDIRS_TESTS =
|
SUBDIRS_TESTS =
|
||||||
|
if HAVE_CHECK
|
||||||
|
SUBDIRS_CHECK = check
|
||||||
|
else
|
||||||
|
SUBDIRS_CHECK =
|
||||||
|
endif
|
||||||
else
|
else
|
||||||
SUBDIRS_TESTS =
|
SUBDIRS_TESTS =
|
||||||
|
SUBDIRS_CHECK =
|
||||||
endif
|
endif
|
||||||
|
|
||||||
if BUILD_EXAMPLES
|
if BUILD_EXAMPLES
|
||||||
|
@ -35,7 +41,9 @@ aclocal_DATA = gst-element-check-@GST_MAJORMINOR@.m4
|
||||||
|
|
||||||
SUBDIRS = \
|
SUBDIRS = \
|
||||||
include gst libs tools \
|
include gst libs tools \
|
||||||
$(SUBDIRS_TESTS) $(SUBDIRS_EXAMPLES) \
|
$(SUBDIRS_CHECK) \
|
||||||
|
$(SUBDIRS_TESTS) \
|
||||||
|
$(SUBDIRS_EXAMPLES) \
|
||||||
pkgconfig po \
|
pkgconfig po \
|
||||||
common \
|
common \
|
||||||
$(SUBDIRS_DOCS)
|
$(SUBDIRS_DOCS)
|
||||||
|
@ -44,6 +52,7 @@ SUBDIRS = \
|
||||||
DIST_SUBDIRS = \
|
DIST_SUBDIRS = \
|
||||||
include libs gst \
|
include libs gst \
|
||||||
tools \
|
tools \
|
||||||
|
check \
|
||||||
tests testsuite \
|
tests testsuite \
|
||||||
examples \
|
examples \
|
||||||
pkgconfig \
|
pkgconfig \
|
||||||
|
|
4
check/Makefile.am
Normal file
4
check/Makefile.am
Normal file
|
@ -0,0 +1,4 @@
|
||||||
|
TESTS = gst / gstobject check_PROGRAMS = $ (TESTS)
|
||||||
|
|
||||||
|
AM_CFLAGS = $ (GST_OBJ_CFLAGS) $ (CHECK_CFLAGS)
|
||||||
|
LDADD = $ (GST_OBJ_LIBS) $ (CHECK_LIBS)
|
1
check/gst/.gitignore
vendored
Normal file
1
check/gst/.gitignore
vendored
Normal file
|
@ -0,0 +1 @@
|
||||||
|
gstobject
|
162
check/gst/gstobject.c
Normal file
162
check/gst/gstobject.c
Normal file
|
@ -0,0 +1,162 @@
|
||||||
|
/* GStreamer
|
||||||
|
*
|
||||||
|
* unit test for GstObject
|
||||||
|
*
|
||||||
|
* Copyright (C) <2004> Thomas Vander Stichele <thomas at apestaart dot org>
|
||||||
|
*
|
||||||
|
* 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 <signal.h>
|
||||||
|
#include <string.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
|
||||||
|
#include <check.h>
|
||||||
|
|
||||||
|
#include <gst/gst.h>
|
||||||
|
|
||||||
|
/*
|
||||||
|
Create a fake subclass
|
||||||
|
*/
|
||||||
|
typedef struct _GstFakeObjectClass GstFakeObjectClass;
|
||||||
|
typedef struct _GstFakeObject GstFakeObject;
|
||||||
|
|
||||||
|
struct _GstFakeObject
|
||||||
|
{
|
||||||
|
GstObject object;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct _GstFakeObjectClass
|
||||||
|
{
|
||||||
|
GstObjectClass parent_class;
|
||||||
|
};
|
||||||
|
|
||||||
|
GType _gst_fake_object_type = 0;
|
||||||
|
|
||||||
|
//static GstObjectClass *parent_class = NULL;
|
||||||
|
//static guint gst_fake_object_signals[LAST_SIGNAL] = { 0 };
|
||||||
|
|
||||||
|
GType
|
||||||
|
gst_fake_object_get_type (void)
|
||||||
|
{
|
||||||
|
if (!_gst_fake_object_type) {
|
||||||
|
static const GTypeInfo fake_object_info = {
|
||||||
|
sizeof (GstFakeObjectClass),
|
||||||
|
NULL, //gst_fake_object_base_class_init,
|
||||||
|
NULL, //gst_fake_object_base_class_finalize,
|
||||||
|
NULL, //(GClassInitFunc) gst_fake_object_class_init,
|
||||||
|
NULL,
|
||||||
|
NULL,
|
||||||
|
sizeof (GstFakeObject),
|
||||||
|
0,
|
||||||
|
NULL, //(GInstanceInitFunc) gst_fake_object_init,
|
||||||
|
NULL
|
||||||
|
};
|
||||||
|
|
||||||
|
_gst_fake_object_type = g_type_register_static (GST_TYPE_OBJECT,
|
||||||
|
"GstFakeObject", &fake_object_info, 0);
|
||||||
|
}
|
||||||
|
return _gst_fake_object_type;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* g_object_new on abstract GstObject should fail */
|
||||||
|
START_TEST (test_fail_abstract_new)
|
||||||
|
{
|
||||||
|
GstObject *object;
|
||||||
|
|
||||||
|
object = g_object_new (gst_object_get_type (), NULL);
|
||||||
|
/* this should assert and segfault, but we add fallbacks anyway */
|
||||||
|
fail_unless (object == NULL, "Created an instance of abstract GstObject");
|
||||||
|
}
|
||||||
|
|
||||||
|
END_TEST
|
||||||
|
/* g_object_new on GstFakeObject should succeed */
|
||||||
|
START_TEST (test_fake_object_new)
|
||||||
|
{
|
||||||
|
GstObject *object;
|
||||||
|
|
||||||
|
object = g_object_new (gst_fake_object_get_type (), NULL);
|
||||||
|
fail_if (object == NULL, "Failed to create instance of GstFakeObject");
|
||||||
|
fail_unless (GST_IS_OBJECT (object),
|
||||||
|
"GstFakeObject instance is not a GstObject");
|
||||||
|
}
|
||||||
|
|
||||||
|
END_TEST
|
||||||
|
/* GstFakeObject name tests */
|
||||||
|
START_TEST (test_fake_object_name)
|
||||||
|
{
|
||||||
|
GstObject *object;
|
||||||
|
gchar *name;
|
||||||
|
gchar *name2;
|
||||||
|
|
||||||
|
object = g_object_new (gst_fake_object_get_type (), NULL);
|
||||||
|
|
||||||
|
name = gst_object_get_name (object);
|
||||||
|
fail_if (name != NULL, "Newly created object has a name");
|
||||||
|
|
||||||
|
/* give a random name by setting with NULL;
|
||||||
|
* GstFakeObject class -> fakeobject%d */
|
||||||
|
gst_object_set_name (object, NULL);
|
||||||
|
name = gst_object_get_name (object);
|
||||||
|
fail_if (name == NULL, "Random name was not assigned");
|
||||||
|
fail_if (strncmp (name, "fakeobject", 10) != 0,
|
||||||
|
"Random name %s does not start with Gst", name);
|
||||||
|
g_free (name);
|
||||||
|
|
||||||
|
gst_object_set_name (object, "fake");
|
||||||
|
name = gst_object_get_name (object);
|
||||||
|
fail_if (name == NULL, "Failed to get name of GstFakeObject");
|
||||||
|
fail_if (strcmp (name, "fake") != 0, "Name of GstFakeObject is not 'fake'");
|
||||||
|
|
||||||
|
/* change the gotten name to see that it's a copy and not the original */
|
||||||
|
name[0] = 'm';
|
||||||
|
name2 = gst_object_get_name (object);
|
||||||
|
fail_if (strcmp (name2, "fake") != 0,
|
||||||
|
"Copy of object name affected actual object name");
|
||||||
|
g_free (name);
|
||||||
|
g_free (name2);
|
||||||
|
}
|
||||||
|
|
||||||
|
END_TEST Suite *
|
||||||
|
gst_object_suite (void)
|
||||||
|
{
|
||||||
|
Suite *s = suite_create ("GstObject");
|
||||||
|
TCase *tc_chain = tcase_create ("general");
|
||||||
|
|
||||||
|
suite_add_tcase (s, tc_chain);
|
||||||
|
tcase_add_test_raise_signal (tc_chain, test_fail_abstract_new, SIGSEGV);
|
||||||
|
tcase_add_test (tc_chain, test_fake_object_new);
|
||||||
|
tcase_add_test (tc_chain, test_fake_object_name);
|
||||||
|
//tcase_add_checked_fixture (tc_chain, setup, teardown);
|
||||||
|
return s;
|
||||||
|
}
|
||||||
|
|
||||||
|
int
|
||||||
|
main (int argc, char **argv)
|
||||||
|
{
|
||||||
|
int nf;
|
||||||
|
|
||||||
|
Suite *s = gst_object_suite ();
|
||||||
|
SRunner *sr = srunner_create (s);
|
||||||
|
|
||||||
|
gst_init (&argc, &argv);
|
||||||
|
|
||||||
|
srunner_run_all (sr, CK_NORMAL);
|
||||||
|
nf = srunner_ntests_failed (sr);
|
||||||
|
srunner_free (sr);
|
||||||
|
|
||||||
|
return nf;
|
||||||
|
}
|
|
@ -313,6 +313,10 @@ AC_SUBST(POPT_LIBS)
|
||||||
dnl Check for ucontext.h
|
dnl Check for ucontext.h
|
||||||
AC_CHECK_HEADER(ucontext.h, AC_DEFINE(HAVE_UCONTEXT_H, 1, [defined if we have ucontext.h]))
|
AC_CHECK_HEADER(ucontext.h, AC_DEFINE(HAVE_UCONTEXT_H, 1, [defined if we have ucontext.h]))
|
||||||
|
|
||||||
|
dnl check for "check", unit testing library/header
|
||||||
|
AM_PATH_CHECK(0.8.2, HAVE_CHECK=yes, HAVE_CHECK=no)
|
||||||
|
AM_CONDITIONAL(HAVE_CHECK, test "x$HAVE_CHECK" = "xyes")
|
||||||
|
|
||||||
dnl ######################################################################
|
dnl ######################################################################
|
||||||
dnl # Check command line parameters, and set shell variables accordingly #
|
dnl # Check command line parameters, and set shell variables accordingly #
|
||||||
dnl ######################################################################
|
dnl ######################################################################
|
||||||
|
@ -669,6 +673,7 @@ libs/gst/control/Makefile
|
||||||
libs/gst/dataprotocol/Makefile
|
libs/gst/dataprotocol/Makefile
|
||||||
libs/gst/getbits/Makefile
|
libs/gst/getbits/Makefile
|
||||||
po/Makefile.in
|
po/Makefile.in
|
||||||
|
check/Makefile
|
||||||
tests/Makefile
|
tests/Makefile
|
||||||
tests/bufspeed/Makefile
|
tests/bufspeed/Makefile
|
||||||
tests/instantiate/Makefile
|
tests/instantiate/Makefile
|
||||||
|
|
|
@ -13,8 +13,6 @@
|
||||||
# correct User entry for the Host entry for the DOC_SERVER
|
# correct User entry for the Host entry for the DOC_SERVER
|
||||||
|
|
||||||
# these variables define the location of the online docs
|
# these variables define the location of the online docs
|
||||||
DOC_SERVER=uraeus@freedesktop.org
|
|
||||||
DOC_BASE=/home/projects/gstreamer/www/data/doc
|
|
||||||
DOC_SERVER=freedesktop.org
|
DOC_SERVER=freedesktop.org
|
||||||
DOC_BASE=/srv/gstreamer.freedesktop.org/www/data/doc
|
DOC_BASE=/srv/gstreamer.freedesktop.org/www/data/doc
|
||||||
DOC_URL=$(DOC_SERVER):$(DOC_BASE)
|
DOC_URL=$(DOC_SERVER):$(DOC_BASE)
|
||||||
|
|
|
@ -214,13 +214,13 @@ noinst_HEADERS = \
|
||||||
gstarch.h \
|
gstarch.h \
|
||||||
cothreads.h
|
cothreads.h
|
||||||
|
|
||||||
if GST_DISABLE_OMEGA_COTHREADS
|
#if GST_DISABLE_OMEGA_COTHREADS
|
||||||
#libcothreads_la_SOURCES =
|
#libcothreads_la_SOURCES =
|
||||||
#libcothreads_la_CFLAGS =
|
#libcothreads_la_CFLAGS =
|
||||||
else
|
#else
|
||||||
libcothreads_la_SOURCES = cothreads.c
|
#libcothreads_la_SOURCES = cothreads.c
|
||||||
libcothreads_la_CFLAGS = $(libgstreamer_@GST_MAJORMINOR@_la_CFLAGS)
|
#libcothreads_la_CFLAGS = $(libgstreamer_@GST_MAJORMINOR@_la_CFLAGS)
|
||||||
endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
gstmarshal.h: gstmarshal.list
|
gstmarshal.h: gstmarshal.list
|
||||||
|
|
75
gst/gstbus.h
75
gst/gstbus.h
|
@ -26,7 +26,6 @@
|
||||||
#include <gst/gstmessage.h>
|
#include <gst/gstmessage.h>
|
||||||
|
|
||||||
G_BEGIN_DECLS
|
G_BEGIN_DECLS
|
||||||
|
|
||||||
/* --- standard type macros --- */
|
/* --- standard type macros --- */
|
||||||
#define GST_TYPE_BUS (gst_bus_get_type ())
|
#define GST_TYPE_BUS (gst_bus_get_type ())
|
||||||
#define GST_BUS(bus) (G_TYPE_CHECK_INSTANCE_CAST ((bus), GST_TYPE_BUS, GstBus))
|
#define GST_BUS(bus) (G_TYPE_CHECK_INSTANCE_CAST ((bus), GST_TYPE_BUS, GstBus))
|
||||||
|
@ -35,64 +34,60 @@ G_BEGIN_DECLS
|
||||||
#define GST_IS_BUS_CLASS(bclass) (G_TYPE_CHECK_CLASS_TYPE ((bclass), GST_TYPE_BUS))
|
#define GST_IS_BUS_CLASS(bclass) (G_TYPE_CHECK_CLASS_TYPE ((bclass), GST_TYPE_BUS))
|
||||||
#define GST_BUS_GET_CLASS(bus) (G_TYPE_INSTANCE_GET_CLASS ((bus), GST_TYPE_BUS, GstBusClass))
|
#define GST_BUS_GET_CLASS(bus) (G_TYPE_INSTANCE_GET_CLASS ((bus), GST_TYPE_BUS, GstBusClass))
|
||||||
#define GST_BUS_CAST(bus) ((GstBus*)(bus))
|
#define GST_BUS_CAST(bus) ((GstBus*)(bus))
|
||||||
|
typedef enum
|
||||||
typedef enum
|
|
||||||
{
|
{
|
||||||
GST_BUS_DROP = 0, /* drop message */
|
GST_BUS_DROP = 0, /* drop message */
|
||||||
GST_BUS_PASS = 1, /* pass message to async queue */
|
GST_BUS_PASS = 1, /* pass message to async queue */
|
||||||
GST_BUS_ASYNC = 2, /* pass message to async queue, continue if message is handled */
|
GST_BUS_ASYNC = 2, /* pass message to async queue, continue if message is handled */
|
||||||
} GstBusSyncReply;
|
} GstBusSyncReply;
|
||||||
|
|
||||||
typedef struct _GstBus GstBus;
|
typedef GstBusSyncReply (*GstBusSyncHandler) (GstBus * bus,
|
||||||
typedef struct _GstBusClass GstBusClass;
|
GstMessage * message, gpointer data);
|
||||||
|
typedef gboolean (*GstBusHandler) (GstBus * bus, GstMessage * message,
|
||||||
|
gpointer data);
|
||||||
|
|
||||||
typedef GstBusSyncReply (*GstBusSyncHandler) (GstBus *bus, GstMessage *message, gpointer data);
|
struct _GstBus
|
||||||
typedef gboolean (*GstBusHandler) (GstBus *bus, GstMessage *message, gpointer data);
|
{
|
||||||
|
GstObject object;
|
||||||
|
|
||||||
struct _GstBus {
|
/*< private > */
|
||||||
GstObject object;
|
GAsyncQueue *queue;
|
||||||
|
|
||||||
/*< private >*/
|
GstBusSyncHandler sync_handler;
|
||||||
GAsyncQueue *queue;
|
gpointer sync_handler_data;
|
||||||
|
|
||||||
GstBusSyncHandler sync_handler;
|
gint control_socket[2];
|
||||||
gpointer sync_handler_data;
|
GIOChannel *io_channel;
|
||||||
|
|
||||||
gint control_socket[2];
|
/*< private > */
|
||||||
GIOChannel *io_channel;
|
|
||||||
|
|
||||||
/*< private >*/
|
|
||||||
gpointer _gst_reserved[GST_PADDING];
|
gpointer _gst_reserved[GST_PADDING];
|
||||||
};
|
};
|
||||||
|
|
||||||
struct _GstBusClass {
|
struct _GstBusClass
|
||||||
GstObjectClass parent_class;
|
{
|
||||||
|
GstObjectClass parent_class;
|
||||||
|
|
||||||
/*< private >*/
|
/*< private > */
|
||||||
gpointer _gst_reserved[GST_PADDING];
|
gpointer _gst_reserved[GST_PADDING];
|
||||||
};
|
};
|
||||||
|
|
||||||
GType gst_bus_get_type (void);
|
GType gst_bus_get_type (void);
|
||||||
|
|
||||||
gboolean gst_bus_post (GstBus *bus, GstMessage *message);
|
gboolean gst_bus_post (GstBus * bus, GstMessage * message);
|
||||||
|
|
||||||
gboolean gst_bus_have_pending (GstBus *bus);
|
gboolean gst_bus_have_pending (GstBus * bus);
|
||||||
const GstMessage* gst_bus_peek (GstBus *bus);
|
const GstMessage *gst_bus_peek (GstBus * bus);
|
||||||
GstMessage* gst_bus_pop (GstBus *bus);
|
GstMessage *gst_bus_pop (GstBus * bus);
|
||||||
|
|
||||||
void gst_bus_set_sync_handler (GstBus *bus, GstBusSyncHandler func,
|
void gst_bus_set_sync_handler (GstBus * bus, GstBusSyncHandler func,
|
||||||
gpointer data);
|
gpointer data);
|
||||||
|
|
||||||
GSource* gst_bus_create_watch (GstBus *bus);
|
GSource *gst_bus_create_watch (GstBus * bus);
|
||||||
guint gst_bus_add_watch_full (GstBus *bus,
|
guint gst_bus_add_watch_full (GstBus * bus,
|
||||||
gint priority,
|
gint priority,
|
||||||
GstBusHandler handler,
|
GstBusHandler handler, gpointer user_data, GDestroyNotify notify);
|
||||||
gpointer user_data,
|
guint gst_bus_add_watch (GstBus * bus,
|
||||||
GDestroyNotify notify);
|
GstBusHandler handler, gpointer user_data);
|
||||||
guint gst_bus_add_watch (GstBus *bus,
|
|
||||||
GstBusHandler handler,
|
|
||||||
gpointer user_data);
|
|
||||||
|
|
||||||
G_END_DECLS
|
G_END_DECLS
|
||||||
|
|
||||||
#endif /* __GST_BUS_H__ */
|
#endif /* __GST_BUS_H__ */
|
||||||
|
|
235
gst/gstelement.c
235
gst/gstelement.c
|
@ -69,6 +69,9 @@ static gboolean gst_element_get_state_func (GstElement * element,
|
||||||
GstElementState * state, GstElementState * pending, GTimeVal * timeout);
|
GstElementState * state, GstElementState * pending, GTimeVal * timeout);
|
||||||
static void gst_element_set_manager_func (GstElement * element,
|
static void gst_element_set_manager_func (GstElement * element,
|
||||||
GstPipeline * manager);
|
GstPipeline * manager);
|
||||||
|
static void gst_element_set_bus_func (GstElement * element, GstBus * bus);
|
||||||
|
static void gst_element_set_scheduler_func (GstElement * element,
|
||||||
|
GstScheduler * scheduler);
|
||||||
|
|
||||||
#ifndef GST_DISABLE_LOADSAVE
|
#ifndef GST_DISABLE_LOADSAVE
|
||||||
static xmlNodePtr gst_element_save_thyself (GstObject * object,
|
static xmlNodePtr gst_element_save_thyself (GstObject * object,
|
||||||
|
@ -143,6 +146,8 @@ gst_element_class_init (GstElementClass * klass)
|
||||||
klass->change_state = GST_DEBUG_FUNCPTR (gst_element_change_state);
|
klass->change_state = GST_DEBUG_FUNCPTR (gst_element_change_state);
|
||||||
klass->get_state = GST_DEBUG_FUNCPTR (gst_element_get_state_func);
|
klass->get_state = GST_DEBUG_FUNCPTR (gst_element_get_state_func);
|
||||||
klass->set_manager = GST_DEBUG_FUNCPTR (gst_element_set_manager_func);
|
klass->set_manager = GST_DEBUG_FUNCPTR (gst_element_set_manager_func);
|
||||||
|
klass->set_bus = GST_DEBUG_FUNCPTR (gst_element_set_bus_func);
|
||||||
|
klass->set_scheduler = GST_DEBUG_FUNCPTR (gst_element_set_scheduler_func);
|
||||||
klass->numpadtemplates = 0;
|
klass->numpadtemplates = 0;
|
||||||
|
|
||||||
klass->elementfactory = NULL;
|
klass->elementfactory = NULL;
|
||||||
|
@ -444,6 +449,7 @@ gst_element_add_pad (GstElement * element, GstPad * pad)
|
||||||
/* locking pad to look at the name */
|
/* locking pad to look at the name */
|
||||||
GST_LOCK (pad);
|
GST_LOCK (pad);
|
||||||
/* then check to see if there's already a pad by that name here */
|
/* then check to see if there's already a pad by that name here */
|
||||||
|
|
||||||
if (G_UNLIKELY (!gst_object_check_uniqueness (element->pads,
|
if (G_UNLIKELY (!gst_object_check_uniqueness (element->pads,
|
||||||
GST_PAD_NAME (pad))))
|
GST_PAD_NAME (pad))))
|
||||||
goto name_exists;
|
goto name_exists;
|
||||||
|
@ -1311,24 +1317,29 @@ gst_element_convert (GstElement * element,
|
||||||
gboolean
|
gboolean
|
||||||
gst_element_post_message (GstElement * element, GstMessage * message)
|
gst_element_post_message (GstElement * element, GstMessage * message)
|
||||||
{
|
{
|
||||||
GstPipeline *manager;
|
GstBus *bus;
|
||||||
gboolean result = FALSE;
|
gboolean result = FALSE;
|
||||||
|
|
||||||
|
GST_DEBUG ("posting message %p ...", message);
|
||||||
|
|
||||||
g_return_val_if_fail (GST_IS_ELEMENT (element), FALSE);
|
g_return_val_if_fail (GST_IS_ELEMENT (element), FALSE);
|
||||||
g_return_val_if_fail (message != NULL, FALSE);
|
g_return_val_if_fail (message != NULL, FALSE);
|
||||||
|
|
||||||
GST_LOCK (element);
|
GST_LOCK (element);
|
||||||
manager = element->manager;
|
bus = element->bus;
|
||||||
if (manager == NULL) {
|
|
||||||
|
if (bus == NULL) {
|
||||||
|
GST_DEBUG ("... but I won't because I have no bus");
|
||||||
GST_UNLOCK (element);
|
GST_UNLOCK (element);
|
||||||
gst_data_unref (GST_DATA (message));
|
gst_data_unref (GST_DATA (message));
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
gst_object_ref (GST_OBJECT (manager));
|
gst_object_ref (GST_OBJECT (bus));
|
||||||
|
GST_DEBUG ("... on bus %p", bus);
|
||||||
GST_UNLOCK (element);
|
GST_UNLOCK (element);
|
||||||
|
|
||||||
result = gst_pipeline_post_message (manager, message);
|
result = gst_bus_post (bus, message);
|
||||||
gst_object_unref (GST_OBJECT (manager));
|
gst_object_unref (GST_OBJECT (bus));
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
@ -1361,77 +1372,79 @@ _gst_element_error_printf (const gchar * format, ...)
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* gst_element_error_full:
|
* gst_element_message_full:
|
||||||
* @element: a #GstElement with the error.
|
* @element: a #GstElement to send message from
|
||||||
* @domain: the GStreamer error domain this error belongs to.
|
* @type: the #GstMessageType
|
||||||
* @code: the error code belonging to the domain
|
* @domain: the GStreamer GError domain this message belongs to
|
||||||
* @message: an allocated message to be used as a replacement for the default
|
* @code: the GError code belonging to the domain
|
||||||
* message connected to code, or NULL
|
* @text: an allocated text string to be used as a replacement for the
|
||||||
* @debug: an allocated debug message to be used as a replacement for the
|
* default message connected to code, or NULL
|
||||||
* default debugging information, or NULL
|
* @debug: an allocated debug message to be used as a replacement for the
|
||||||
* @file: the source code file where the error was generated
|
* default debugging information, or NULL
|
||||||
|
* @file: the source code file where the error was generated
|
||||||
* @function: the source code function where the error was generated
|
* @function: the source code function where the error was generated
|
||||||
* @line: the source code line where the error was generated
|
* @line: the source code line where the error was generated
|
||||||
*
|
*
|
||||||
* Signals an error condition on an element.
|
* Post an error or warning message on the bus from inside an element.
|
||||||
* This function is used internally by elements.
|
|
||||||
* It results in the "error" signal.
|
|
||||||
*
|
*
|
||||||
* MT safe.
|
* MT safe.
|
||||||
*/
|
*/
|
||||||
void gst_element_error_full
|
void gst_element_message_full
|
||||||
(GstElement * element, GQuark domain, gint code, gchar * message,
|
(GstElement * element, GstMessageType type,
|
||||||
|
GQuark domain, gint code, gchar * text,
|
||||||
gchar * debug, const gchar * file, const gchar * function, gint line)
|
gchar * debug, const gchar * file, const gchar * function, gint line)
|
||||||
{
|
{
|
||||||
GError *error = NULL;
|
GError *gerror = NULL;
|
||||||
gchar *name;
|
gchar *name;
|
||||||
gchar *sent_message;
|
gchar *sent_text;
|
||||||
gchar *sent_debug;
|
gchar *sent_debug;
|
||||||
gchar *elem_name;
|
GstMessage *message = NULL;
|
||||||
|
|
||||||
/* checks */
|
/* checks */
|
||||||
|
GST_DEBUG ("start");
|
||||||
g_return_if_fail (GST_IS_ELEMENT (element));
|
g_return_if_fail (GST_IS_ELEMENT (element));
|
||||||
|
g_return_if_fail ((type == GST_MESSAGE_ERROR) ||
|
||||||
|
(type == GST_MESSAGE_WARNING));
|
||||||
|
|
||||||
elem_name = gst_element_get_name (element);
|
/* check if we send the given text or the default error text */
|
||||||
|
if ((text == NULL) || (text[0] == 0)) {
|
||||||
/* check if we send the given message or the default error message */
|
/* text could have come from g_strdup_printf (""); */
|
||||||
if ((message == NULL) || (message[0] == 0)) {
|
g_free (text);
|
||||||
/* we got this message from g_strdup_printf (""); */
|
sent_text = gst_error_get_text (domain, code);
|
||||||
g_free (message);
|
|
||||||
sent_message = gst_error_get_message (domain, code);
|
|
||||||
} else
|
} else
|
||||||
sent_message = message;
|
sent_text = text;
|
||||||
|
|
||||||
|
/* construct a sent_debug with extra information from source */
|
||||||
if ((debug == NULL) || (debug[0] == 0)) {
|
if ((debug == NULL) || (debug[0] == 0)) {
|
||||||
/* we got this debug from g_strdup_printf (""); */
|
/* debug could have come from g_strdup_printf (""); */
|
||||||
g_free (debug);
|
sent_debug = NULL;
|
||||||
debug = NULL;
|
} else {
|
||||||
}
|
name = gst_object_get_path_string (GST_OBJECT (element));
|
||||||
|
|
||||||
/* create error message */
|
|
||||||
GST_CAT_INFO (GST_CAT_ERROR_SYSTEM, "signaling error in %s: %s",
|
|
||||||
elem_name, sent_message);
|
|
||||||
error = g_error_new_literal (domain, code, sent_message);
|
|
||||||
|
|
||||||
/* emit the signal, make sure the element stays available */
|
|
||||||
name = gst_object_get_path_string (GST_OBJECT (element));
|
|
||||||
if (debug)
|
|
||||||
sent_debug = g_strdup_printf ("%s(%d): %s: %s:\n%s",
|
sent_debug = g_strdup_printf ("%s(%d): %s: %s:\n%s",
|
||||||
file, line, function, name, debug ? debug : "");
|
file, line, function, name, debug ? debug : "");
|
||||||
else
|
g_free (name);
|
||||||
sent_debug = NULL;
|
}
|
||||||
g_free (debug);
|
g_free (debug);
|
||||||
g_free (name);
|
|
||||||
|
|
||||||
gst_element_post_message (element,
|
/* create gerror and post message */
|
||||||
gst_message_new_error (GST_OBJECT (element), error, sent_debug));
|
GST_CAT_INFO_OBJECT (GST_CAT_ERROR_SYSTEM, element, "posting message: %s",
|
||||||
|
sent_text);
|
||||||
|
gerror = g_error_new_literal (domain, code, sent_text);
|
||||||
|
|
||||||
GST_CAT_INFO (GST_CAT_ERROR_SYSTEM, "signalled error in %s: %s",
|
if (type == GST_MESSAGE_ERROR) {
|
||||||
elem_name, sent_message);
|
message = gst_message_new_error (GST_OBJECT (element), gerror, sent_debug);
|
||||||
|
} else {
|
||||||
|
message = gst_message_new_warning (GST_OBJECT (element), gerror,
|
||||||
|
sent_debug);
|
||||||
|
}
|
||||||
|
gst_element_post_message (element, message);
|
||||||
|
|
||||||
|
GST_CAT_INFO_OBJECT (GST_CAT_ERROR_SYSTEM, element, "posted message: %s",
|
||||||
|
sent_text);
|
||||||
|
|
||||||
/* cleanup */
|
/* cleanup */
|
||||||
g_free (sent_message);
|
g_free (sent_text);
|
||||||
g_free (elem_name);
|
/* sent_debug is not part of the gerror, so don't free it here */
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -2073,6 +2086,33 @@ gst_element_set_manager_func (GstElement * element, GstPipeline * manager)
|
||||||
GST_UNLOCK (element);
|
GST_UNLOCK (element);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
gst_element_set_bus_func (GstElement * element, GstBus * bus)
|
||||||
|
{
|
||||||
|
g_return_if_fail (GST_IS_ELEMENT (element));
|
||||||
|
|
||||||
|
GST_CAT_DEBUG_OBJECT (GST_CAT_PARENTAGE, element, "setting bus to %p", bus);
|
||||||
|
|
||||||
|
GST_LOCK (element);
|
||||||
|
gst_object_replace ((GstObject **) & GST_ELEMENT_BUS (element),
|
||||||
|
GST_OBJECT (bus));
|
||||||
|
GST_UNLOCK (element);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
gst_element_set_scheduler_func (GstElement * element, GstScheduler * scheduler)
|
||||||
|
{
|
||||||
|
g_return_if_fail (GST_IS_ELEMENT (element));
|
||||||
|
|
||||||
|
GST_CAT_DEBUG_OBJECT (GST_CAT_PARENTAGE, element, "setting scheduler to %p",
|
||||||
|
scheduler);
|
||||||
|
|
||||||
|
GST_LOCK (element);
|
||||||
|
gst_object_replace ((GstObject **) & GST_ELEMENT_SCHEDULER (element),
|
||||||
|
GST_OBJECT (scheduler));
|
||||||
|
GST_UNLOCK (element);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* gst_element_set_manager:
|
* gst_element_set_manager:
|
||||||
* @element: a #GstElement to set the manager of.
|
* @element: a #GstElement to set the manager of.
|
||||||
|
@ -2096,6 +2136,7 @@ gst_element_set_manager (GstElement * element, GstPipeline * manager)
|
||||||
oclass->set_manager (element, manager);
|
oclass->set_manager (element, manager);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* gst_element_get_manager:
|
* gst_element_get_manager:
|
||||||
* @element: a #GstElement to get the manager of.
|
* @element: a #GstElement to get the manager of.
|
||||||
|
@ -2121,6 +2162,92 @@ gst_element_get_manager (GstElement * element)
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* gst_element_set_bus:
|
||||||
|
* @element: a #GstElement to set the bus of.
|
||||||
|
* @bus: the #GstBus to set.
|
||||||
|
*
|
||||||
|
* Sets the bus of the element. For internal use only, unless you're
|
||||||
|
* testing elements.
|
||||||
|
*/
|
||||||
|
void
|
||||||
|
gst_element_set_bus (GstElement * element, GstBus * bus)
|
||||||
|
{
|
||||||
|
GstElementClass *oclass;
|
||||||
|
|
||||||
|
g_return_if_fail (GST_IS_ELEMENT (element));
|
||||||
|
|
||||||
|
oclass = GST_ELEMENT_GET_CLASS (element);
|
||||||
|
|
||||||
|
if (oclass->set_bus)
|
||||||
|
oclass->set_bus (element, bus);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* gst_element_get_bus:
|
||||||
|
* @element: a #GstElement to get the bus of.
|
||||||
|
*
|
||||||
|
* Returns the bus of the element.
|
||||||
|
*
|
||||||
|
* Returns: the element's #GstBus.
|
||||||
|
*/
|
||||||
|
GstBus *
|
||||||
|
gst_element_get_bus (GstElement * element)
|
||||||
|
{
|
||||||
|
GstBus *result = NULL;
|
||||||
|
|
||||||
|
g_return_val_if_fail (GST_IS_ELEMENT (element), result);
|
||||||
|
|
||||||
|
GST_LOCK (element);
|
||||||
|
result = GST_ELEMENT_BUS (element);
|
||||||
|
GST_UNLOCK (element);
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* gst_element_set_scheduler:
|
||||||
|
* @element: a #GstElement to set the scheduler of.
|
||||||
|
* @scheduler: the #GstScheduler to set.
|
||||||
|
*
|
||||||
|
* Sets the scheduler of the element. For internal use only, unless you're
|
||||||
|
* testing elements.
|
||||||
|
*/
|
||||||
|
void
|
||||||
|
gst_element_set_scheduler (GstElement * element, GstScheduler * scheduler)
|
||||||
|
{
|
||||||
|
GstElementClass *oclass;
|
||||||
|
|
||||||
|
g_return_if_fail (GST_IS_ELEMENT (element));
|
||||||
|
|
||||||
|
oclass = GST_ELEMENT_GET_CLASS (element);
|
||||||
|
|
||||||
|
if (oclass->set_scheduler)
|
||||||
|
oclass->set_scheduler (element, scheduler);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* gst_element_get_scheduler:
|
||||||
|
* @element: a #GstElement to get the scheduler of.
|
||||||
|
*
|
||||||
|
* Returns the scheduler of the element.
|
||||||
|
*
|
||||||
|
* Returns: the element's #GstScheduler.
|
||||||
|
*/
|
||||||
|
GstScheduler *
|
||||||
|
gst_element_get_scheduler (GstElement * element)
|
||||||
|
{
|
||||||
|
GstScheduler *result = NULL;
|
||||||
|
|
||||||
|
g_return_val_if_fail (GST_IS_ELEMENT (element), result);
|
||||||
|
|
||||||
|
GST_LOCK (element);
|
||||||
|
result = GST_ELEMENT_SCHEDULER (element);
|
||||||
|
GST_UNLOCK (element);
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* gst_element_create_task:
|
* gst_element_create_task:
|
||||||
* @element: a #GstElement to get the manager of.
|
* @element: a #GstElement to get the manager of.
|
||||||
|
|
368
gst/gstelement.h
368
gst/gstelement.h
|
@ -34,24 +34,25 @@
|
||||||
#include <gst/gstpluginfeature.h>
|
#include <gst/gstpluginfeature.h>
|
||||||
#include <gst/gstindex.h>
|
#include <gst/gstindex.h>
|
||||||
#include <gst/gstiterator.h>
|
#include <gst/gstiterator.h>
|
||||||
|
#include <gst/gstmessage.h>
|
||||||
#include <gst/gsttask.h>
|
#include <gst/gsttask.h>
|
||||||
#include <gst/gsttag.h>
|
#include <gst/gsttag.h>
|
||||||
|
|
||||||
G_BEGIN_DECLS
|
G_BEGIN_DECLS typedef struct _GstElementDetails GstElementDetails;
|
||||||
|
|
||||||
typedef struct _GstElementDetails GstElementDetails;
|
|
||||||
|
|
||||||
/* FIXME: need translatable stuff in here (how handle in registry)? */
|
/* FIXME: need translatable stuff in here (how handle in registry)? */
|
||||||
struct _GstElementDetails {
|
struct _GstElementDetails
|
||||||
/*< public >*/
|
{
|
||||||
|
/*< public > */
|
||||||
gchar *longname; /* long, english name */
|
gchar *longname; /* long, english name */
|
||||||
gchar *klass; /* type of element, as hierarchy */
|
gchar *klass; /* type of element, as hierarchy */
|
||||||
gchar *description; /* insights of one form or another */
|
gchar *description; /* insights of one form or another */
|
||||||
gchar *author; /* who wrote this thing? */
|
gchar *author; /* who wrote this thing? */
|
||||||
|
|
||||||
/*< private >*/
|
/*< private > */
|
||||||
gpointer _gst_reserved[GST_PADDING];
|
gpointer _gst_reserved[GST_PADDING];
|
||||||
};
|
};
|
||||||
|
|
||||||
#define GST_ELEMENT_DETAILS(longname,klass,description,author) \
|
#define GST_ELEMENT_DETAILS(longname,klass,description,author) \
|
||||||
{ longname, klass, description, author, GST_PADDING_INIT }
|
{ longname, klass, description, author, GST_PADDING_INIT }
|
||||||
#define GST_IS_ELEMENT_DETAILS(details) ( \
|
#define GST_IS_ELEMENT_DETAILS(details) ( \
|
||||||
|
@ -102,7 +103,8 @@ GST_EXPORT GType _gst_element_type;
|
||||||
GST_EVENT_MASK_FUNCTION (GstElement*, functionname, a);
|
GST_EVENT_MASK_FUNCTION (GstElement*, functionname, a);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
typedef enum {
|
typedef enum
|
||||||
|
{
|
||||||
/* private flags that can be used by the scheduler */
|
/* private flags that can be used by the scheduler */
|
||||||
GST_ELEMENT_SCHEDULER_PRIVATE1,
|
GST_ELEMENT_SCHEDULER_PRIVATE1,
|
||||||
GST_ELEMENT_SCHEDULER_PRIVATE2,
|
GST_ELEMENT_SCHEDULER_PRIVATE2,
|
||||||
|
@ -111,25 +113,43 @@ typedef enum {
|
||||||
GST_ELEMENT_LOCKED_STATE,
|
GST_ELEMENT_LOCKED_STATE,
|
||||||
|
|
||||||
/* use some padding for future expansion */
|
/* use some padding for future expansion */
|
||||||
GST_ELEMENT_FLAG_LAST = GST_OBJECT_FLAG_LAST + 16
|
GST_ELEMENT_FLAG_LAST = GST_OBJECT_FLAG_LAST + 16
|
||||||
} GstElementFlags;
|
} GstElementFlags;
|
||||||
|
|
||||||
#define GST_ELEMENT_NAME(obj) (GST_OBJECT_NAME(obj))
|
#define GST_ELEMENT_NAME(obj) (GST_OBJECT_NAME(obj))
|
||||||
#define GST_ELEMENT_PARENT(obj) (GST_ELEMENT_CAST(GST_OBJECT_PARENT(obj)))
|
#define GST_ELEMENT_PARENT(obj) (GST_ELEMENT_CAST(GST_OBJECT_PARENT(obj)))
|
||||||
#define GST_ELEMENT_MANAGER(obj) (GST_ELEMENT_CAST(obj)->manager)
|
#define GST_ELEMENT_MANAGER(obj) (GST_ELEMENT_CAST(obj)->manager)
|
||||||
|
#define GST_ELEMENT_BUS(obj) (GST_ELEMENT_CAST(obj)->bus)
|
||||||
|
#define GST_ELEMENT_SCHEDULER(obj) (GST_ELEMENT_CAST(obj)->scheduler)
|
||||||
#define GST_ELEMENT_CLOCK(obj) (GST_ELEMENT_CAST(obj)->clock)
|
#define GST_ELEMENT_CLOCK(obj) (GST_ELEMENT_CAST(obj)->clock)
|
||||||
#define GST_ELEMENT_PADS(obj) (GST_ELEMENT_CAST(obj)->pads)
|
#define GST_ELEMENT_PADS(obj) (GST_ELEMENT_CAST(obj)->pads)
|
||||||
|
|
||||||
#define GST_ELEMENT_ERROR(el, domain, code, message, debug) G_STMT_START { \
|
/* log a (fatal) error message and post it on the bus */
|
||||||
gchar *__msg = _gst_element_error_printf message; \
|
#define GST_ELEMENT_ERROR(el, domain, code, text, debug) \
|
||||||
gchar *__dbg = _gst_element_error_printf debug; \
|
G_STMT_START { \
|
||||||
if (__msg) \
|
gchar *__txt = _gst_element_error_printf text; \
|
||||||
GST_ERROR_OBJECT (el, "%s", __msg); \
|
gchar *__dbg = _gst_element_error_printf debug; \
|
||||||
if (__dbg) \
|
if (__txt) \
|
||||||
GST_ERROR_OBJECT (el, "%s", __dbg); \
|
GST_ERROR_OBJECT (el, "%s", __txt); \
|
||||||
gst_element_error_full (GST_ELEMENT(el), \
|
if (__dbg) \
|
||||||
GST_ ## domain ## _ERROR, GST_ ## domain ## _ERROR_ ## code, \
|
GST_ERROR_OBJECT (el, "%s", __dbg); \
|
||||||
__msg, __dbg, __FILE__, GST_FUNCTION, __LINE__); \
|
gst_element_message_full (GST_ELEMENT(el), GST_MESSAGE_ERROR, \
|
||||||
|
GST_ ## domain ## _ERROR, GST_ ## domain ## _ERROR_ ## code, \
|
||||||
|
__txt, __dbg, __FILE__, GST_FUNCTION, __LINE__); \
|
||||||
|
} G_STMT_END
|
||||||
|
|
||||||
|
/* log a (non-fatal) warning message and post it on the bus */
|
||||||
|
#define GST_ELEMENT_WARNING(el, domain, code, text, debug) \
|
||||||
|
G_STMT_START { \
|
||||||
|
gchar *__txt = _gst_element_error_printf text; \
|
||||||
|
gchar *__dbg = _gst_element_error_printf debug; \
|
||||||
|
if (__txt) \
|
||||||
|
GST_WARNING_OBJECT (el, "%s", __txt); \
|
||||||
|
if (__dbg) \
|
||||||
|
GST_WARNING_OBJECT (el, "%s", __dbg); \
|
||||||
|
gst_element_message_full (GST_ELEMENT(el), GST_MESSAGE_WARNING, \
|
||||||
|
GST_ ## domain ## _ERROR, GST_ ## domain ## _ERROR_ ## code, \
|
||||||
|
__txt, __dbg, __FILE__, GST_FUNCTION, __LINE__); \
|
||||||
} G_STMT_END
|
} G_STMT_END
|
||||||
|
|
||||||
/* the state change mutexes and conds */
|
/* the state change mutexes and conds */
|
||||||
|
@ -140,116 +160,127 @@ typedef enum {
|
||||||
#define GST_STATE_GET_COND(elem) (GST_ELEMENT_CAST(elem)->state_cond)
|
#define GST_STATE_GET_COND(elem) (GST_ELEMENT_CAST(elem)->state_cond)
|
||||||
#define GST_STATE_WAIT(elem) g_cond_wait (GST_STATE_GET_COND (elem), GST_STATE_GET_LOCK (elem))
|
#define GST_STATE_WAIT(elem) g_cond_wait (GST_STATE_GET_COND (elem), GST_STATE_GET_LOCK (elem))
|
||||||
#define GST_STATE_TIMED_WAIT(elem, timeval) g_cond_timed_wait (GST_STATE_GET_COND (elem), GST_STATE_GET_LOCK (elem),\
|
#define GST_STATE_TIMED_WAIT(elem, timeval) g_cond_timed_wait (GST_STATE_GET_COND (elem), GST_STATE_GET_LOCK (elem),\
|
||||||
timeval)
|
timeval)
|
||||||
|
|
||||||
typedef struct _GstElementFactory GstElementFactory;
|
typedef struct _GstElementFactory GstElementFactory;
|
||||||
typedef struct _GstElementFactoryClass GstElementFactoryClass;
|
typedef struct _GstElementFactoryClass GstElementFactoryClass;
|
||||||
|
|
||||||
struct _GstElement {
|
struct _GstElement
|
||||||
GstObject object;
|
{
|
||||||
|
GstObject object;
|
||||||
|
|
||||||
/*< public >*/ /* with STATE_LOCK */
|
/*< public > *//* with STATE_LOCK */
|
||||||
/* element state */
|
/* element state */
|
||||||
GMutex *state_lock;
|
GMutex *state_lock;
|
||||||
GCond *state_cond;
|
GCond *state_cond;
|
||||||
guint8 current_state;
|
guint8 current_state;
|
||||||
guint8 pending_state;
|
guint8 pending_state;
|
||||||
|
|
||||||
/*< public >*/ /* with LOCK */
|
/*< public > *//* with LOCK */
|
||||||
/* element manager */
|
/* element manager */
|
||||||
GstPipeline *manager;
|
GstPipeline *manager;
|
||||||
|
GstBus *bus;
|
||||||
|
GstScheduler *scheduler;
|
||||||
/* private pointer for the scheduler */
|
/* private pointer for the scheduler */
|
||||||
gpointer sched_private;
|
gpointer sched_private;
|
||||||
|
|
||||||
/* allocated clock */
|
/* allocated clock */
|
||||||
GstClock *clock;
|
GstClock *clock;
|
||||||
GstClockTimeDiff base_time; /* NULL/READY: 0 - PAUSED: current time - PLAYING: difference to clock */
|
GstClockTimeDiff base_time; /* NULL/READY: 0 - PAUSED: current time - PLAYING: difference to clock */
|
||||||
|
|
||||||
/* element pads, these lists can only be iterated while holding
|
/* element pads, these lists can only be iterated while holding
|
||||||
* the LOCK or checking the cookie after each LOCK. */
|
* the LOCK or checking the cookie after each LOCK. */
|
||||||
guint16 numpads;
|
guint16 numpads;
|
||||||
GList *pads;
|
GList *pads;
|
||||||
guint16 numsrcpads;
|
guint16 numsrcpads;
|
||||||
GList *srcpads;
|
GList *srcpads;
|
||||||
guint16 numsinkpads;
|
guint16 numsinkpads;
|
||||||
GList *sinkpads;
|
GList *sinkpads;
|
||||||
guint32 pads_cookie;
|
guint32 pads_cookie;
|
||||||
|
|
||||||
/*< private >*/
|
/*< private > */
|
||||||
gpointer _gst_reserved[GST_PADDING];
|
gpointer _gst_reserved[GST_PADDING];
|
||||||
};
|
};
|
||||||
|
|
||||||
struct _GstElementClass {
|
struct _GstElementClass
|
||||||
GstObjectClass parent_class;
|
{
|
||||||
|
GstObjectClass parent_class;
|
||||||
|
|
||||||
/*< public >*/
|
/*< public > */
|
||||||
/* the element details */
|
/* the element details */
|
||||||
GstElementDetails details;
|
GstElementDetails details;
|
||||||
|
|
||||||
/* factory that the element was created from */
|
/* factory that the element was created from */
|
||||||
GstElementFactory *elementfactory;
|
GstElementFactory *elementfactory;
|
||||||
|
|
||||||
/* templates for our pads */
|
/* templates for our pads */
|
||||||
GList *padtemplates;
|
GList *padtemplates;
|
||||||
gint numpadtemplates;
|
gint numpadtemplates;
|
||||||
guint32 pad_templ_cookie;
|
guint32 pad_templ_cookie;
|
||||||
|
|
||||||
/* signal callbacks */
|
|
||||||
void (*state_change) (GstElement *element, GstElementState old, GstElementState state);
|
|
||||||
void (*new_pad) (GstElement *element, GstPad *pad);
|
|
||||||
void (*pad_removed) (GstElement *element, GstPad *pad);
|
|
||||||
void (*no_more_pads) (GstElement *element);
|
|
||||||
|
|
||||||
/*< protected >*/
|
/* signal callbacks */
|
||||||
|
void (*state_change) (GstElement * element, GstElementState old,
|
||||||
|
GstElementState state);
|
||||||
|
void (*new_pad) (GstElement * element, GstPad * pad);
|
||||||
|
void (*pad_removed) (GstElement * element, GstPad * pad);
|
||||||
|
void (*no_more_pads) (GstElement * element);
|
||||||
|
|
||||||
|
/*< protected > */
|
||||||
/* vtable */
|
/* vtable */
|
||||||
|
|
||||||
/* request/release pads */
|
/* request/release pads */
|
||||||
GstPad* (*request_new_pad) (GstElement *element, GstPadTemplate *templ, const gchar* name);
|
GstPad *(*request_new_pad) (GstElement * element, GstPadTemplate * templ,
|
||||||
void (*release_pad) (GstElement *element, GstPad *pad);
|
const gchar * name);
|
||||||
|
void (*release_pad) (GstElement * element, GstPad * pad);
|
||||||
|
|
||||||
/* state changes */
|
/* state changes */
|
||||||
gboolean (*get_state) (GstElement *element, GstElementState *state,
|
gboolean (*get_state) (GstElement * element, GstElementState * state,
|
||||||
GstElementState *pending, GTimeVal *timeout);
|
GstElementState * pending, GTimeVal * timeout);
|
||||||
GstElementStateReturn (*change_state) (GstElement *element);
|
GstElementStateReturn (*change_state) (GstElement * element);
|
||||||
|
|
||||||
/* manager */
|
/* manager */
|
||||||
void (*set_manager) (GstElement *element, GstPipeline *pipeline);
|
void (*set_manager) (GstElement * element, GstPipeline * pipeline);
|
||||||
|
void (*set_bus) (GstElement * element, GstBus * bus);
|
||||||
|
void (*set_scheduler) (GstElement * element, GstScheduler * scheduler);
|
||||||
|
|
||||||
/* set/get clocks */
|
/* set/get clocks */
|
||||||
GstClock* (*get_clock) (GstElement *element);
|
GstClock *(*get_clock) (GstElement * element);
|
||||||
void (*set_clock) (GstElement *element, GstClock *clock);
|
void (*set_clock) (GstElement * element, GstClock * clock);
|
||||||
|
|
||||||
/* index */
|
/* index */
|
||||||
GstIndex* (*get_index) (GstElement *element);
|
GstIndex *(*get_index) (GstElement * element);
|
||||||
void (*set_index) (GstElement *element, GstIndex *index);
|
void (*set_index) (GstElement * element, GstIndex * index);
|
||||||
|
|
||||||
/* query/convert/events functions */
|
/* query/convert/events functions */
|
||||||
const GstEventMask* (*get_event_masks) (GstElement *element);
|
const GstEventMask *(*get_event_masks) (GstElement * element);
|
||||||
gboolean (*send_event) (GstElement *element, GstEvent *event);
|
gboolean (*send_event) (GstElement * element, GstEvent * event);
|
||||||
const GstFormat* (*get_formats) (GstElement *element);
|
const GstFormat *(*get_formats) (GstElement * element);
|
||||||
gboolean (*convert) (GstElement *element,
|
gboolean (*convert) (GstElement * element,
|
||||||
GstFormat src_format, gint64 src_value,
|
GstFormat src_format, gint64 src_value,
|
||||||
GstFormat *dest_format, gint64 *dest_value);
|
GstFormat * dest_format, gint64 * dest_value);
|
||||||
const GstQueryType* (*get_query_types) (GstElement *element);
|
const GstQueryType *(*get_query_types) (GstElement * element);
|
||||||
gboolean (*query) (GstElement *element, GstQueryType type,
|
gboolean (*query) (GstElement * element, GstQueryType type,
|
||||||
GstFormat *format, gint64 *value);
|
GstFormat * format, gint64 * value);
|
||||||
|
|
||||||
/*< private >*/
|
/*< private > */
|
||||||
gpointer _gst_reserved[GST_PADDING - 1];
|
gpointer _gst_reserved[GST_PADDING - 1];
|
||||||
};
|
};
|
||||||
|
|
||||||
/* class stuff */
|
/* class stuff */
|
||||||
void gst_element_class_add_pad_template (GstElementClass *klass, GstPadTemplate *templ);
|
void gst_element_class_add_pad_template (GstElementClass * klass,
|
||||||
void gst_element_class_install_std_props (GstElementClass *klass,
|
GstPadTemplate * templ);
|
||||||
const gchar *first_name, ...);
|
void gst_element_class_install_std_props (GstElementClass * klass,
|
||||||
void gst_element_class_set_details (GstElementClass *klass,
|
const gchar * first_name, ...);
|
||||||
const GstElementDetails *details);
|
void gst_element_class_set_details (GstElementClass * klass,
|
||||||
GstPadTemplate* gst_element_class_get_pad_template (GstElementClass *element_class, const gchar *name);
|
const GstElementDetails * details);
|
||||||
GList* gst_element_class_get_pad_template_list (GstElementClass *element_class);
|
GstPadTemplate *gst_element_class_get_pad_template (GstElementClass *
|
||||||
|
element_class, const gchar * name);
|
||||||
|
GList *gst_element_class_get_pad_template_list (GstElementClass *
|
||||||
|
element_class);
|
||||||
|
|
||||||
/* element instance */
|
/* element instance */
|
||||||
|
|
||||||
GType gst_element_get_type (void);
|
GType gst_element_get_type (void);
|
||||||
|
|
||||||
#define gst_element_get_name(elem) gst_object_get_name(GST_OBJECT(elem))
|
#define gst_element_get_name(elem) gst_object_get_name(GST_OBJECT(elem))
|
||||||
#define gst_element_set_name(elem,name) gst_object_set_name(GST_OBJECT(elem),name)
|
#define gst_element_set_name(elem,name) gst_object_set_name(GST_OBJECT(elem),name)
|
||||||
|
@ -257,79 +288,84 @@ GType gst_element_get_type (void);
|
||||||
#define gst_element_set_parent(elem,parent) gst_object_set_parent(GST_OBJECT(elem),parent)
|
#define gst_element_set_parent(elem,parent) gst_object_set_parent(GST_OBJECT(elem),parent)
|
||||||
|
|
||||||
/* clocking */
|
/* clocking */
|
||||||
gboolean gst_element_requires_clock (GstElement *element);
|
gboolean gst_element_requires_clock (GstElement * element);
|
||||||
gboolean gst_element_provides_clock (GstElement *element);
|
gboolean gst_element_provides_clock (GstElement * element);
|
||||||
GstClock* gst_element_get_clock (GstElement *element);
|
GstClock *gst_element_get_clock (GstElement * element);
|
||||||
void gst_element_set_clock (GstElement *element, GstClock *clock);
|
void gst_element_set_clock (GstElement * element, GstClock * clock);
|
||||||
|
|
||||||
GstClockReturn gst_element_clock_wait (GstElement *element,
|
GstClockReturn gst_element_clock_wait (GstElement * element,
|
||||||
GstClockID id, GstClockTimeDiff *jitter);
|
GstClockID id, GstClockTimeDiff * jitter);
|
||||||
GstClockTime gst_element_get_time (GstElement *element);
|
GstClockTime gst_element_get_time (GstElement * element);
|
||||||
gboolean gst_element_wait (GstElement *element, GstClockTime timestamp);
|
gboolean gst_element_wait (GstElement * element, GstClockTime timestamp);
|
||||||
|
|
||||||
/* indexes */
|
/* indexes */
|
||||||
gboolean gst_element_is_indexable (GstElement *element);
|
gboolean gst_element_is_indexable (GstElement * element);
|
||||||
void gst_element_set_index (GstElement *element, GstIndex *index);
|
void gst_element_set_index (GstElement * element, GstIndex * index);
|
||||||
GstIndex* gst_element_get_index (GstElement *element);
|
GstIndex *gst_element_get_index (GstElement * element);
|
||||||
|
|
||||||
/* manager and tasks */
|
/* manager and tasks */
|
||||||
void gst_element_set_manager (GstElement *element, GstPipeline *pipeline);
|
void gst_element_set_manager (GstElement * element, GstPipeline * pipeline);
|
||||||
GstPipeline* gst_element_get_manager (GstElement *element);
|
GstPipeline *gst_element_get_manager (GstElement * element);
|
||||||
GstTask* gst_element_create_task (GstElement *element, GstTaskFunction func, gpointer data);
|
void gst_element_set_bus (GstElement * element, GstBus * bus);
|
||||||
|
GstBus *gst_element_get_bus (GstElement * element);
|
||||||
|
void gst_element_set_scheduler (GstElement * element, GstScheduler * scheduler);
|
||||||
|
GstScheduler *gst_element_get_scheduler (GstElement * element);
|
||||||
|
GstTask *gst_element_create_task (GstElement * element, GstTaskFunction func,
|
||||||
|
gpointer data);
|
||||||
|
|
||||||
/* pad management */
|
/* pad management */
|
||||||
gboolean gst_element_add_pad (GstElement *element, GstPad *pad);
|
gboolean gst_element_add_pad (GstElement * element, GstPad * pad);
|
||||||
gboolean gst_element_remove_pad (GstElement *element, GstPad *pad);
|
gboolean gst_element_remove_pad (GstElement * element, GstPad * pad);
|
||||||
GstPad * gst_element_add_ghost_pad (GstElement *element, GstPad *pad, const gchar *name);
|
GstPad *gst_element_add_ghost_pad (GstElement * element, GstPad * pad,
|
||||||
void gst_element_no_more_pads (GstElement *element);
|
const gchar * name);
|
||||||
|
void gst_element_no_more_pads (GstElement * element);
|
||||||
|
|
||||||
GstPad* gst_element_get_pad (GstElement *element, const gchar *name);
|
GstPad *gst_element_get_pad (GstElement * element, const gchar * name);
|
||||||
GstPad* gst_element_get_static_pad (GstElement *element, const gchar *name);
|
GstPad *gst_element_get_static_pad (GstElement * element, const gchar * name);
|
||||||
GstPad* gst_element_get_request_pad (GstElement *element, const gchar *name);
|
GstPad *gst_element_get_request_pad (GstElement * element, const gchar * name);
|
||||||
void gst_element_release_request_pad (GstElement *element, GstPad *pad);
|
void gst_element_release_request_pad (GstElement * element, GstPad * pad);
|
||||||
|
|
||||||
GstIterator* gst_element_iterate_pads (GstElement *element);
|
GstIterator *gst_element_iterate_pads (GstElement * element);
|
||||||
|
|
||||||
/* event/query/format stuff */
|
/* event/query/format stuff */
|
||||||
G_CONST_RETURN GstEventMask*
|
G_CONST_RETURN GstEventMask *gst_element_get_event_masks (GstElement * element);
|
||||||
gst_element_get_event_masks (GstElement *element);
|
gboolean gst_element_send_event (GstElement * element, GstEvent * event);
|
||||||
gboolean gst_element_send_event (GstElement *element, GstEvent *event);
|
gboolean gst_element_seek (GstElement * element, GstSeekType seek_type,
|
||||||
gboolean gst_element_seek (GstElement *element, GstSeekType seek_type,
|
guint64 offset);
|
||||||
guint64 offset);
|
G_CONST_RETURN GstQueryType *gst_element_get_query_types (GstElement * element);
|
||||||
G_CONST_RETURN GstQueryType*
|
gboolean gst_element_query (GstElement * element, GstQueryType type,
|
||||||
gst_element_get_query_types (GstElement *element);
|
GstFormat * format, gint64 * value);
|
||||||
gboolean gst_element_query (GstElement *element, GstQueryType type,
|
G_CONST_RETURN GstFormat *gst_element_get_formats (GstElement * element);
|
||||||
GstFormat *format, gint64 *value);
|
gboolean gst_element_convert (GstElement * element,
|
||||||
G_CONST_RETURN GstFormat*
|
GstFormat src_format, gint64 src_value,
|
||||||
gst_element_get_formats (GstElement *element);
|
GstFormat * dest_format, gint64 * dest_value);
|
||||||
gboolean gst_element_convert (GstElement *element,
|
|
||||||
GstFormat src_format, gint64 src_value,
|
|
||||||
GstFormat *dest_format, gint64 *dest_value);
|
|
||||||
|
|
||||||
/* messages */
|
/* messages */
|
||||||
gboolean gst_element_post_message (GstElement *element, GstMessage *message);
|
gboolean gst_element_post_message (GstElement * element, GstMessage * message);
|
||||||
|
|
||||||
|
|
||||||
/* error handling */
|
/* error handling */
|
||||||
gchar * _gst_element_error_printf (const gchar *format, ...);
|
gchar *_gst_element_error_printf (const gchar * format, ...);
|
||||||
void gst_element_error_full (GstElement *element, GQuark domain, gint code,
|
void gst_element_message_full (GstElement * element, GstMessageType type,
|
||||||
gchar *message, gchar *debug,
|
GQuark domain, gint code, gchar * text, gchar * debug, const gchar * file,
|
||||||
const gchar *file, const gchar *function, gint line);
|
const gchar * function, gint line);
|
||||||
|
|
||||||
/* state management */
|
/* state management */
|
||||||
gboolean gst_element_is_locked_state (GstElement *element);
|
gboolean gst_element_is_locked_state (GstElement * element);
|
||||||
gboolean gst_element_set_locked_state (GstElement *element, gboolean locked_state);
|
gboolean gst_element_set_locked_state (GstElement * element,
|
||||||
gboolean gst_element_sync_state_with_parent (GstElement *element);
|
gboolean locked_state);
|
||||||
|
gboolean gst_element_sync_state_with_parent (GstElement * element);
|
||||||
|
|
||||||
gboolean gst_element_get_state (GstElement *element, GstElementState *state,
|
gboolean gst_element_get_state (GstElement * element, GstElementState * state,
|
||||||
GstElementState *pending, GTimeVal *timeout);
|
GstElementState * pending, GTimeVal * timeout);
|
||||||
GstElementStateReturn gst_element_set_state (GstElement *element, GstElementState state);
|
GstElementStateReturn gst_element_set_state (GstElement * element,
|
||||||
|
GstElementState state);
|
||||||
|
|
||||||
void gst_element_abort_state (GstElement *element);
|
void gst_element_abort_state (GstElement * element);
|
||||||
void gst_element_commit_state (GstElement *element);
|
void gst_element_commit_state (GstElement * element);
|
||||||
|
|
||||||
/* factory management */
|
/* factory management */
|
||||||
GstElementFactory* gst_element_get_factory (GstElement *element);
|
GstElementFactory *gst_element_get_factory (GstElement * element);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
*
|
*
|
||||||
|
@ -345,54 +381,58 @@ GstElementFactory* gst_element_get_factory (GstElement *element);
|
||||||
#define GST_IS_ELEMENT_FACTORY(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_ELEMENT_FACTORY))
|
#define GST_IS_ELEMENT_FACTORY(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_ELEMENT_FACTORY))
|
||||||
#define GST_IS_ELEMENT_FACTORY_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_ELEMENT_FACTORY))
|
#define GST_IS_ELEMENT_FACTORY_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_ELEMENT_FACTORY))
|
||||||
|
|
||||||
struct _GstElementFactory {
|
struct _GstElementFactory
|
||||||
GstPluginFeature parent;
|
{
|
||||||
|
GstPluginFeature parent;
|
||||||
|
|
||||||
GType type; /* unique GType of element or 0 if not loaded */
|
GType type; /* unique GType of element or 0 if not loaded */
|
||||||
|
|
||||||
GstElementDetails details;
|
GstElementDetails details;
|
||||||
|
|
||||||
GList * padtemplates;
|
GList *padtemplates;
|
||||||
guint numpadtemplates;
|
guint numpadtemplates;
|
||||||
|
|
||||||
/* URI interface stuff */
|
/* URI interface stuff */
|
||||||
guint uri_type;
|
guint uri_type;
|
||||||
gchar ** uri_protocols;
|
gchar **uri_protocols;
|
||||||
|
|
||||||
GList * interfaces; /* interfaces this element implements */
|
GList *interfaces; /* interfaces this element implements */
|
||||||
|
|
||||||
gpointer _gst_reserved[GST_PADDING];
|
gpointer _gst_reserved[GST_PADDING];
|
||||||
};
|
};
|
||||||
|
|
||||||
struct _GstElementFactoryClass {
|
struct _GstElementFactoryClass
|
||||||
|
{
|
||||||
GstPluginFeatureClass parent_class;
|
GstPluginFeatureClass parent_class;
|
||||||
|
|
||||||
gpointer _gst_reserved[GST_PADDING];
|
gpointer _gst_reserved[GST_PADDING];
|
||||||
};
|
};
|
||||||
|
|
||||||
GType gst_element_factory_get_type (void);
|
GType gst_element_factory_get_type (void);
|
||||||
|
|
||||||
gboolean gst_element_register (GstPlugin *plugin,
|
gboolean gst_element_register (GstPlugin * plugin,
|
||||||
const gchar *name,
|
const gchar * name, guint rank, GType type);
|
||||||
guint rank,
|
|
||||||
GType type);
|
|
||||||
|
|
||||||
GstElementFactory * gst_element_factory_find (const gchar *name);
|
GstElementFactory *gst_element_factory_find (const gchar * name);
|
||||||
GType gst_element_factory_get_element_type (GstElementFactory *factory);
|
GType gst_element_factory_get_element_type (GstElementFactory * factory);
|
||||||
G_CONST_RETURN gchar * gst_element_factory_get_longname (GstElementFactory *factory);
|
G_CONST_RETURN gchar *gst_element_factory_get_longname (GstElementFactory *
|
||||||
G_CONST_RETURN gchar * gst_element_factory_get_klass (GstElementFactory *factory);
|
factory);
|
||||||
G_CONST_RETURN gchar * gst_element_factory_get_description (GstElementFactory *factory);
|
G_CONST_RETURN gchar *gst_element_factory_get_klass (GstElementFactory *
|
||||||
G_CONST_RETURN gchar * gst_element_factory_get_author (GstElementFactory *factory);
|
factory);
|
||||||
guint gst_element_factory_get_num_pad_templates (GstElementFactory *factory);
|
G_CONST_RETURN gchar *gst_element_factory_get_description (GstElementFactory *
|
||||||
G_CONST_RETURN GList * gst_element_factory_get_pad_templates (GstElementFactory *factory);
|
factory);
|
||||||
guint gst_element_factory_get_uri_type (GstElementFactory *factory);
|
G_CONST_RETURN gchar *gst_element_factory_get_author (GstElementFactory *
|
||||||
gchar ** gst_element_factory_get_uri_protocols (GstElementFactory *factory);
|
factory);
|
||||||
|
guint gst_element_factory_get_num_pad_templates (GstElementFactory * factory);
|
||||||
|
G_CONST_RETURN GList *gst_element_factory_get_pad_templates (GstElementFactory *
|
||||||
|
factory);
|
||||||
|
guint gst_element_factory_get_uri_type (GstElementFactory * factory);
|
||||||
|
gchar **gst_element_factory_get_uri_protocols (GstElementFactory * factory);
|
||||||
|
|
||||||
GstElement* gst_element_factory_create (GstElementFactory *factory,
|
GstElement *gst_element_factory_create (GstElementFactory * factory,
|
||||||
const gchar *name);
|
const gchar * name);
|
||||||
GstElement* gst_element_factory_make (const gchar *factoryname, const gchar *name);
|
GstElement *gst_element_factory_make (const gchar * factoryname,
|
||||||
|
const gchar * name);
|
||||||
|
|
||||||
G_END_DECLS
|
G_END_DECLS
|
||||||
|
|
||||||
#endif /* __GST_ELEMENT_H__ */
|
#endif /* __GST_ELEMENT_H__ */
|
||||||
|
|
||||||
|
|
|
@ -28,10 +28,11 @@
|
||||||
#define TABLE(t, d, a, b) t[GST_ ## d ## _ERROR_ ## a] = g_strdup (b)
|
#define TABLE(t, d, a, b) t[GST_ ## d ## _ERROR_ ## a] = g_strdup (b)
|
||||||
#define QUARK_FUNC(string) \
|
#define QUARK_FUNC(string) \
|
||||||
GQuark gst_ ## string ## _error_quark (void) { \
|
GQuark gst_ ## string ## _error_quark (void) { \
|
||||||
static GQuark quark; \
|
static GQuark q; \
|
||||||
if (!quark) \
|
if (!q) \
|
||||||
quark = g_quark_from_static_string ("gst-" # string "-error-quark"); \
|
q = g_quark_from_static_string ("gst-" # string "-error-quark"); \
|
||||||
return quark; }
|
return q; \
|
||||||
|
}
|
||||||
|
|
||||||
GType
|
GType
|
||||||
gst_g_error_get_type (void)
|
gst_g_error_get_type (void)
|
||||||
|
@ -161,29 +162,30 @@ _gst_stream_errors_init (void)
|
||||||
return t;
|
return t;
|
||||||
}
|
}
|
||||||
|
|
||||||
QUARK_FUNC (core)
|
QUARK_FUNC (core);
|
||||||
QUARK_FUNC (library)
|
QUARK_FUNC (library);
|
||||||
QUARK_FUNC (resource)
|
QUARK_FUNC (resource);
|
||||||
QUARK_FUNC (stream)
|
QUARK_FUNC (stream);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* gst_error_get_message:
|
* gst_error_get_text:
|
||||||
* @domain: the GStreamer error domain this error belongs to.
|
* @domain: the GStreamer error domain this error belongs to.
|
||||||
* @code: the error code belonging to the domain.
|
* @code: the error code belonging to the domain.
|
||||||
*
|
*
|
||||||
* Returns: a newly allocated string describing the error message in the
|
* Returns: a newly allocated string describing the error text in the
|
||||||
* current locale.
|
* current locale.
|
||||||
*/
|
*/
|
||||||
gchar *gst_error_get_message (GQuark domain, gint code)
|
gchar *
|
||||||
|
gst_error_get_text (GQuark domain, gint code)
|
||||||
{
|
{
|
||||||
static gchar **gst_core_errors = NULL;
|
static gchar **gst_core_errors = NULL;
|
||||||
static gchar **gst_library_errors = NULL;
|
static gchar **gst_library_errors = NULL;
|
||||||
static gchar **gst_resource_errors = NULL;
|
static gchar **gst_resource_errors = NULL;
|
||||||
static gchar **gst_stream_errors = NULL;
|
static gchar **gst_stream_errors = NULL;
|
||||||
|
|
||||||
gchar *message = NULL;
|
gchar *text = NULL;
|
||||||
|
|
||||||
/* initialize error message tables if necessary */
|
/* initialize error text tables if necessary */
|
||||||
if (gst_core_errors == NULL)
|
if (gst_core_errors == NULL)
|
||||||
gst_core_errors = _gst_core_errors_init ();
|
gst_core_errors = _gst_core_errors_init ();
|
||||||
if (gst_library_errors == NULL)
|
if (gst_library_errors == NULL)
|
||||||
|
@ -195,23 +197,23 @@ QUARK_FUNC (core)
|
||||||
|
|
||||||
|
|
||||||
if (domain == GST_CORE_ERROR)
|
if (domain == GST_CORE_ERROR)
|
||||||
message = gst_core_errors[code];
|
text = gst_core_errors[code];
|
||||||
else if (domain == GST_LIBRARY_ERROR)
|
else if (domain == GST_LIBRARY_ERROR)
|
||||||
message = gst_library_errors[code];
|
text = gst_library_errors[code];
|
||||||
else if (domain == GST_RESOURCE_ERROR)
|
else if (domain == GST_RESOURCE_ERROR)
|
||||||
message = gst_resource_errors[code];
|
text = gst_resource_errors[code];
|
||||||
else if (domain == GST_STREAM_ERROR)
|
else if (domain == GST_STREAM_ERROR)
|
||||||
message = gst_stream_errors[code];
|
text = gst_stream_errors[code];
|
||||||
else {
|
else {
|
||||||
g_warning ("No error messages for domain %s", g_quark_to_string (domain));
|
g_warning ("No error texts for domain %s", g_quark_to_string (domain));
|
||||||
return g_strdup_printf (_("No error message for domain %s."),
|
return g_strdup_printf (_("No error text for domain %s."),
|
||||||
g_quark_to_string (domain));
|
g_quark_to_string (domain));
|
||||||
}
|
}
|
||||||
if (message)
|
if (text)
|
||||||
return g_strdup (_(message));
|
return g_strdup (_(text));
|
||||||
else
|
else
|
||||||
return
|
return
|
||||||
g_strdup_printf (_
|
g_strdup_printf (_
|
||||||
("No standard error message for domain %s and code %d."),
|
("No standard error text for domain %s and code %d."),
|
||||||
g_quark_to_string (domain), code);
|
g_quark_to_string (domain), code);
|
||||||
}
|
}
|
||||||
|
|
|
@ -38,7 +38,7 @@ G_BEGIN_DECLS
|
||||||
* the core GStreamer library */
|
* the core GStreamer library */
|
||||||
/* FIXME: should we divide in numerical blocks so we can easily add
|
/* FIXME: should we divide in numerical blocks so we can easily add
|
||||||
for example PAD errors later ? */
|
for example PAD errors later ? */
|
||||||
typedef enum
|
typedef enum
|
||||||
{
|
{
|
||||||
GST_CORE_ERROR_FAILED = 1,
|
GST_CORE_ERROR_FAILED = 1,
|
||||||
GST_CORE_ERROR_TOO_LAZY,
|
GST_CORE_ERROR_TOO_LAZY,
|
||||||
|
@ -123,7 +123,7 @@ GstStreamError;
|
||||||
#define GST_ERROR_SYSTEM ("system error: %s", g_strerror (errno))
|
#define GST_ERROR_SYSTEM ("system error: %s", g_strerror (errno))
|
||||||
|
|
||||||
GType gst_g_error_get_type (void);
|
GType gst_g_error_get_type (void);
|
||||||
gchar *gst_error_get_message (GQuark domain, gint code);
|
gchar *gst_error_get_text (GQuark domain, gint code);
|
||||||
GQuark gst_stream_error_quark (void);
|
GQuark gst_stream_error_quark (void);
|
||||||
GQuark gst_core_error_quark (void);
|
GQuark gst_core_error_quark (void);
|
||||||
GQuark gst_resource_error_quark (void);
|
GQuark gst_resource_error_quark (void);
|
||||||
|
|
|
@ -102,7 +102,8 @@ _gst_message_free (GstMessage * message)
|
||||||
}
|
}
|
||||||
switch (GST_MESSAGE_TYPE (message)) {
|
switch (GST_MESSAGE_TYPE (message)) {
|
||||||
case GST_MESSAGE_ERROR:
|
case GST_MESSAGE_ERROR:
|
||||||
g_error_free (GST_MESSAGE_ERROR_ERROR (message));
|
case GST_MESSAGE_WARNING:
|
||||||
|
g_error_free (GST_MESSAGE_ERROR_GERROR (message));
|
||||||
g_free (GST_MESSAGE_ERROR_DEBUG (message));
|
g_free (GST_MESSAGE_ERROR_DEBUG (message));
|
||||||
break;
|
break;
|
||||||
case GST_MESSAGE_TAG:
|
case GST_MESSAGE_TAG:
|
||||||
|
@ -194,12 +195,31 @@ gst_message_new_error (GstObject * src, GError * error, gchar * debug)
|
||||||
GstMessage *message;
|
GstMessage *message;
|
||||||
|
|
||||||
message = gst_message_new (GST_MESSAGE_ERROR, src);
|
message = gst_message_new (GST_MESSAGE_ERROR, src);
|
||||||
GST_MESSAGE_ERROR_ERROR (message) = error;
|
GST_MESSAGE_ERROR_GERROR (message) = error;
|
||||||
GST_MESSAGE_ERROR_DEBUG (message) = debug;
|
GST_MESSAGE_ERROR_DEBUG (message) = debug;
|
||||||
|
|
||||||
return message;
|
return message;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* gst_message_new_warning:
|
||||||
|
*
|
||||||
|
* Create a new warning message.
|
||||||
|
*
|
||||||
|
* Returns: The new warning message.
|
||||||
|
*/
|
||||||
|
GstMessage *
|
||||||
|
gst_message_new_warning (GstObject * src, GError * error, gchar * debug)
|
||||||
|
{
|
||||||
|
GstMessage *message;
|
||||||
|
|
||||||
|
message = gst_message_new (GST_MESSAGE_WARNING, src);
|
||||||
|
GST_MESSAGE_WARNING_GERROR (message) = error;
|
||||||
|
GST_MESSAGE_WARNING_DEBUG (message) = debug;
|
||||||
|
|
||||||
|
return message;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* gst_message_new_tag:
|
* gst_message_new_tag:
|
||||||
*
|
*
|
||||||
|
|
|
@ -28,20 +28,19 @@
|
||||||
#include <gst/gsttag.h>
|
#include <gst/gsttag.h>
|
||||||
#include <gst/gststructure.h>
|
#include <gst/gststructure.h>
|
||||||
|
|
||||||
G_BEGIN_DECLS
|
G_BEGIN_DECLS GST_EXPORT GType _gst_message_type;
|
||||||
|
|
||||||
GST_EXPORT GType _gst_message_type;
|
typedef enum
|
||||||
|
{
|
||||||
typedef enum {
|
GST_MESSAGE_UNKNOWN = 0,
|
||||||
GST_MESSAGE_UNKNOWN = 0,
|
GST_MESSAGE_EOS = 1,
|
||||||
GST_MESSAGE_EOS = 1,
|
GST_MESSAGE_ERROR = 2,
|
||||||
GST_MESSAGE_ERROR = 2,
|
GST_MESSAGE_WARNING = 3,
|
||||||
GST_MESSAGE_WARNING = 3,
|
GST_MESSAGE_INFO = 4,
|
||||||
GST_MESSAGE_INFO = 4,
|
GST_MESSAGE_TAG = 5,
|
||||||
GST_MESSAGE_TAG = 5,
|
GST_MESSAGE_BUFFERING = 6,
|
||||||
GST_MESSAGE_BUFFERING = 6,
|
GST_MESSAGE_STATE_CHANGED = 7,
|
||||||
GST_MESSAGE_STATE_CHANGED = 7,
|
GST_MESSAGE_STEP_DONE = 8,
|
||||||
GST_MESSAGE_STEP_DONE = 8,
|
|
||||||
} GstMessageType;
|
} GstMessageType;
|
||||||
|
|
||||||
#define GST_MESSAGE_TRACE_NAME "GstMessage"
|
#define GST_MESSAGE_TRACE_NAME "GstMessage"
|
||||||
|
@ -56,42 +55,49 @@ typedef enum {
|
||||||
|
|
||||||
#define GST_MESSAGE_TAG_LIST(message) (GST_MESSAGE(message)->message_data.tag.list)
|
#define GST_MESSAGE_TAG_LIST(message) (GST_MESSAGE(message)->message_data.tag.list)
|
||||||
|
|
||||||
#define GST_MESSAGE_ERROR_ERROR(message) (GST_MESSAGE(message)->message_data.error.error)
|
#define GST_MESSAGE_ERROR_GERROR(message) (GST_MESSAGE(message)->message_data.error.gerror)
|
||||||
#define GST_MESSAGE_ERROR_DEBUG(message) (GST_MESSAGE(message)->message_data.error.debug)
|
#define GST_MESSAGE_ERROR_DEBUG(message) (GST_MESSAGE(message)->message_data.error.debug)
|
||||||
|
#define GST_MESSAGE_WARNING_GERROR(message) (GST_MESSAGE(message)->message_data.error.gerror)
|
||||||
|
#define GST_MESSAGE_WARNING_DEBUG(message) (GST_MESSAGE(message)->message_data.error.debug)
|
||||||
|
|
||||||
struct _GstMessage {
|
struct _GstMessage
|
||||||
|
{
|
||||||
GstData data;
|
GstData data;
|
||||||
|
|
||||||
/*< public >*/ /* with MESSAGE_LOCK */
|
/*< public > *//* with MESSAGE_LOCK */
|
||||||
GMutex *lock; /* lock and cond for async delivery */
|
GMutex *lock; /* lock and cond for async delivery */
|
||||||
GCond *cond;
|
GCond *cond;
|
||||||
|
|
||||||
/*< public >*/ /* with COW */
|
/*< public > *//* with COW */
|
||||||
GstMessageType type;
|
GstMessageType type;
|
||||||
guint64 timestamp;
|
guint64 timestamp;
|
||||||
GstObject *src;
|
GstObject *src;
|
||||||
|
|
||||||
union {
|
union
|
||||||
struct {
|
{
|
||||||
GError *error;
|
struct
|
||||||
|
{
|
||||||
|
GError *gerror;
|
||||||
gchar *debug;
|
gchar *debug;
|
||||||
} error;
|
} error;
|
||||||
struct {
|
struct
|
||||||
GstStructure *structure;
|
{
|
||||||
|
GstStructure *structure;
|
||||||
} structure;
|
} structure;
|
||||||
struct {
|
struct
|
||||||
GstTagList *list;
|
{
|
||||||
|
GstTagList *list;
|
||||||
} tag;
|
} tag;
|
||||||
} message_data;
|
} message_data;
|
||||||
|
|
||||||
/*< private >*/
|
/*< private > */
|
||||||
gpointer _gst_reserved[GST_PADDING];
|
gpointer _gst_reserved[GST_PADDING];
|
||||||
};
|
};
|
||||||
|
|
||||||
void _gst_message_initialize (void);
|
void _gst_message_initialize (void);
|
||||||
|
|
||||||
GType gst_message_get_type (void);
|
GType gst_message_get_type (void);
|
||||||
GstMessage* gst_message_new (GstMessageType type, GstObject *src);
|
GstMessage *gst_message_new (GstMessageType type, GstObject * src);
|
||||||
|
|
||||||
/* refcounting */
|
/* refcounting */
|
||||||
#define gst_message_ref(ev) GST_MESSAGE (gst_data_ref (GST_DATA (ev)))
|
#define gst_message_ref(ev) GST_MESSAGE (gst_data_ref (GST_DATA (ev)))
|
||||||
|
@ -100,10 +106,12 @@ GstMessage* gst_message_new (GstMessageType type, GstObject *src);
|
||||||
/* copy message */
|
/* copy message */
|
||||||
#define gst_message_copy(ev) GST_MESSAGE (gst_data_copy (GST_DATA (ev)))
|
#define gst_message_copy(ev) GST_MESSAGE (gst_data_copy (GST_DATA (ev)))
|
||||||
|
|
||||||
GstMessage* gst_message_new_eos (GstObject *src);
|
GstMessage *gst_message_new_eos (GstObject * src);
|
||||||
GstMessage* gst_message_new_error (GstObject *src, GError *error, gchar *debug);
|
GstMessage *gst_message_new_error (GstObject * src, GError * error,
|
||||||
GstMessage* gst_message_new_tag (GstObject *src, GstTagList *tag_list);
|
gchar * debug);
|
||||||
|
GstMessage *gst_message_new_warning (GstObject * src, GError * error,
|
||||||
|
gchar * debug);
|
||||||
|
GstMessage *gst_message_new_tag (GstObject * src, GstTagList * tag_list);
|
||||||
|
|
||||||
G_END_DECLS
|
G_END_DECLS
|
||||||
|
|
||||||
#endif /* __GST_MESSAGE_H__ */
|
#endif /* __GST_MESSAGE_H__ */
|
||||||
|
|
|
@ -604,12 +604,13 @@ gst_object_set_name_default (GstObject * object)
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* gst_object_set_name:
|
* gst_object_set_name:
|
||||||
* @object: GstObject to set the name of
|
* @object: a #GstObject to set the name of
|
||||||
* @name: new name of object
|
* @name: new name of object
|
||||||
*
|
*
|
||||||
* Sets the name of the object, or gives the element a guaranteed unique
|
* Sets the name of the object, or gives the object a guaranteed unique
|
||||||
* name (if @name is NULL). This function makes a copy of the provided
|
* name (if @name is NULL).
|
||||||
* name so the called must g_free() the name it sent as a parameter.
|
* This function makes a copy of the provided name, so the caller
|
||||||
|
* retains ownership of the name it sent.
|
||||||
*
|
*
|
||||||
* MT safe.
|
* MT safe.
|
||||||
*/
|
*/
|
||||||
|
@ -632,12 +633,14 @@ gst_object_set_name (GstObject * object, const gchar * name)
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* gst_object_get_name:
|
* gst_object_get_name:
|
||||||
* @object: GstObject to get the name of
|
* @object: a #GstObject to get the name of
|
||||||
*
|
*
|
||||||
* Get the name of the object. This function returns a copy
|
* Returns a copy of the name of the object.
|
||||||
* of the name, you should call g_free() on it after usage.
|
* Caller should g_free() the return value after usage.
|
||||||
|
* For a nameless object, this returns NULL, which you can safely g_free()
|
||||||
|
* as well.
|
||||||
*
|
*
|
||||||
* Returns: name of the object. g_free() after usage.
|
* Returns: the name of the object. g_free() after usage.
|
||||||
*
|
*
|
||||||
* MT safe.
|
* MT safe.
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -22,9 +22,7 @@
|
||||||
|
|
||||||
#include <glib.h>
|
#include <glib.h>
|
||||||
|
|
||||||
G_BEGIN_DECLS
|
G_BEGIN_DECLS typedef struct _GstObject GstObject;
|
||||||
|
|
||||||
typedef struct _GstObject GstObject;
|
|
||||||
typedef struct _GstObjectClass GstObjectClass;
|
typedef struct _GstObjectClass GstObjectClass;
|
||||||
typedef struct _GstPad GstPad;
|
typedef struct _GstPad GstPad;
|
||||||
typedef struct _GstPadClass GstPadClass;
|
typedef struct _GstPadClass GstPadClass;
|
||||||
|
@ -36,36 +34,42 @@ typedef struct _GstBin GstBin;
|
||||||
typedef struct _GstBinClass GstBinClass;
|
typedef struct _GstBinClass GstBinClass;
|
||||||
typedef struct _GstPipeline GstPipeline;
|
typedef struct _GstPipeline GstPipeline;
|
||||||
typedef struct _GstPipelineClass GstPipelineClass;
|
typedef struct _GstPipelineClass GstPipelineClass;
|
||||||
|
typedef struct _GstBus GstBus;
|
||||||
|
typedef struct _GstBusClass GstBusClass;
|
||||||
typedef struct _GstScheduler GstScheduler;
|
typedef struct _GstScheduler GstScheduler;
|
||||||
typedef struct _GstSchedulerClass GstSchedulerClass;
|
typedef struct _GstSchedulerClass GstSchedulerClass;
|
||||||
typedef struct _GstEvent GstEvent;
|
typedef struct _GstEvent GstEvent;
|
||||||
typedef struct _GstMessage GstMessage;
|
typedef struct _GstMessage GstMessage;
|
||||||
|
|
||||||
typedef enum {
|
typedef enum
|
||||||
GST_STATE_VOID_PENDING = 0,
|
{
|
||||||
GST_STATE_NULL = (1 << 0),
|
GST_STATE_VOID_PENDING = 0,
|
||||||
GST_STATE_READY = (1 << 1),
|
GST_STATE_NULL = (1 << 0),
|
||||||
GST_STATE_PAUSED = (1 << 2),
|
GST_STATE_READY = (1 << 1),
|
||||||
GST_STATE_PLAYING = (1 << 3)
|
GST_STATE_PAUSED = (1 << 2),
|
||||||
|
GST_STATE_PLAYING = (1 << 3)
|
||||||
} GstElementState;
|
} GstElementState;
|
||||||
|
|
||||||
typedef enum {
|
typedef enum
|
||||||
GST_STATE_FAILURE = 0,
|
{
|
||||||
GST_STATE_SUCCESS = 1,
|
GST_STATE_FAILURE = 0,
|
||||||
GST_STATE_ASYNC = 2
|
GST_STATE_SUCCESS = 1,
|
||||||
|
GST_STATE_ASYNC = 2
|
||||||
} GstElementStateReturn;
|
} GstElementStateReturn;
|
||||||
|
|
||||||
typedef enum {
|
typedef enum
|
||||||
|
{
|
||||||
GST_RESULT_OK,
|
GST_RESULT_OK,
|
||||||
GST_RESULT_NOK,
|
GST_RESULT_NOK,
|
||||||
GST_RESULT_NOT_IMPL
|
GST_RESULT_NOT_IMPL
|
||||||
} GstResult;
|
} GstResult;
|
||||||
|
|
||||||
typedef enum {
|
typedef enum
|
||||||
GST_RANK_NONE = 0,
|
{
|
||||||
GST_RANK_MARGINAL = 64,
|
GST_RANK_NONE = 0,
|
||||||
GST_RANK_SECONDARY = 128,
|
GST_RANK_MARGINAL = 64,
|
||||||
GST_RANK_PRIMARY = 256
|
GST_RANK_SECONDARY = 128,
|
||||||
|
GST_RANK_PRIMARY = 256
|
||||||
} GstRank;
|
} GstRank;
|
||||||
|
|
||||||
#define GST_PADDING 4
|
#define GST_PADDING 4
|
||||||
|
@ -73,5 +77,4 @@ typedef enum {
|
||||||
|
|
||||||
|
|
||||||
G_END_DECLS
|
G_END_DECLS
|
||||||
|
|
||||||
#endif /* __GST_TYPES_H__ */
|
#endif /* __GST_TYPES_H__ */
|
||||||
|
|
4
tests/check/Makefile.am
Normal file
4
tests/check/Makefile.am
Normal file
|
@ -0,0 +1,4 @@
|
||||||
|
TESTS = gst / gstobject check_PROGRAMS = $ (TESTS)
|
||||||
|
|
||||||
|
AM_CFLAGS = $ (GST_OBJ_CFLAGS) $ (CHECK_CFLAGS)
|
||||||
|
LDADD = $ (GST_OBJ_LIBS) $ (CHECK_LIBS)
|
1
tests/check/gst/.gitignore
vendored
Normal file
1
tests/check/gst/.gitignore
vendored
Normal file
|
@ -0,0 +1 @@
|
||||||
|
gstobject
|
162
tests/check/gst/gstobject.c
Normal file
162
tests/check/gst/gstobject.c
Normal file
|
@ -0,0 +1,162 @@
|
||||||
|
/* GStreamer
|
||||||
|
*
|
||||||
|
* unit test for GstObject
|
||||||
|
*
|
||||||
|
* Copyright (C) <2004> Thomas Vander Stichele <thomas at apestaart dot org>
|
||||||
|
*
|
||||||
|
* 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 <signal.h>
|
||||||
|
#include <string.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
|
||||||
|
#include <check.h>
|
||||||
|
|
||||||
|
#include <gst/gst.h>
|
||||||
|
|
||||||
|
/*
|
||||||
|
Create a fake subclass
|
||||||
|
*/
|
||||||
|
typedef struct _GstFakeObjectClass GstFakeObjectClass;
|
||||||
|
typedef struct _GstFakeObject GstFakeObject;
|
||||||
|
|
||||||
|
struct _GstFakeObject
|
||||||
|
{
|
||||||
|
GstObject object;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct _GstFakeObjectClass
|
||||||
|
{
|
||||||
|
GstObjectClass parent_class;
|
||||||
|
};
|
||||||
|
|
||||||
|
GType _gst_fake_object_type = 0;
|
||||||
|
|
||||||
|
//static GstObjectClass *parent_class = NULL;
|
||||||
|
//static guint gst_fake_object_signals[LAST_SIGNAL] = { 0 };
|
||||||
|
|
||||||
|
GType
|
||||||
|
gst_fake_object_get_type (void)
|
||||||
|
{
|
||||||
|
if (!_gst_fake_object_type) {
|
||||||
|
static const GTypeInfo fake_object_info = {
|
||||||
|
sizeof (GstFakeObjectClass),
|
||||||
|
NULL, //gst_fake_object_base_class_init,
|
||||||
|
NULL, //gst_fake_object_base_class_finalize,
|
||||||
|
NULL, //(GClassInitFunc) gst_fake_object_class_init,
|
||||||
|
NULL,
|
||||||
|
NULL,
|
||||||
|
sizeof (GstFakeObject),
|
||||||
|
0,
|
||||||
|
NULL, //(GInstanceInitFunc) gst_fake_object_init,
|
||||||
|
NULL
|
||||||
|
};
|
||||||
|
|
||||||
|
_gst_fake_object_type = g_type_register_static (GST_TYPE_OBJECT,
|
||||||
|
"GstFakeObject", &fake_object_info, 0);
|
||||||
|
}
|
||||||
|
return _gst_fake_object_type;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* g_object_new on abstract GstObject should fail */
|
||||||
|
START_TEST (test_fail_abstract_new)
|
||||||
|
{
|
||||||
|
GstObject *object;
|
||||||
|
|
||||||
|
object = g_object_new (gst_object_get_type (), NULL);
|
||||||
|
/* this should assert and segfault, but we add fallbacks anyway */
|
||||||
|
fail_unless (object == NULL, "Created an instance of abstract GstObject");
|
||||||
|
}
|
||||||
|
|
||||||
|
END_TEST
|
||||||
|
/* g_object_new on GstFakeObject should succeed */
|
||||||
|
START_TEST (test_fake_object_new)
|
||||||
|
{
|
||||||
|
GstObject *object;
|
||||||
|
|
||||||
|
object = g_object_new (gst_fake_object_get_type (), NULL);
|
||||||
|
fail_if (object == NULL, "Failed to create instance of GstFakeObject");
|
||||||
|
fail_unless (GST_IS_OBJECT (object),
|
||||||
|
"GstFakeObject instance is not a GstObject");
|
||||||
|
}
|
||||||
|
|
||||||
|
END_TEST
|
||||||
|
/* GstFakeObject name tests */
|
||||||
|
START_TEST (test_fake_object_name)
|
||||||
|
{
|
||||||
|
GstObject *object;
|
||||||
|
gchar *name;
|
||||||
|
gchar *name2;
|
||||||
|
|
||||||
|
object = g_object_new (gst_fake_object_get_type (), NULL);
|
||||||
|
|
||||||
|
name = gst_object_get_name (object);
|
||||||
|
fail_if (name != NULL, "Newly created object has a name");
|
||||||
|
|
||||||
|
/* give a random name by setting with NULL;
|
||||||
|
* GstFakeObject class -> fakeobject%d */
|
||||||
|
gst_object_set_name (object, NULL);
|
||||||
|
name = gst_object_get_name (object);
|
||||||
|
fail_if (name == NULL, "Random name was not assigned");
|
||||||
|
fail_if (strncmp (name, "fakeobject", 10) != 0,
|
||||||
|
"Random name %s does not start with Gst", name);
|
||||||
|
g_free (name);
|
||||||
|
|
||||||
|
gst_object_set_name (object, "fake");
|
||||||
|
name = gst_object_get_name (object);
|
||||||
|
fail_if (name == NULL, "Failed to get name of GstFakeObject");
|
||||||
|
fail_if (strcmp (name, "fake") != 0, "Name of GstFakeObject is not 'fake'");
|
||||||
|
|
||||||
|
/* change the gotten name to see that it's a copy and not the original */
|
||||||
|
name[0] = 'm';
|
||||||
|
name2 = gst_object_get_name (object);
|
||||||
|
fail_if (strcmp (name2, "fake") != 0,
|
||||||
|
"Copy of object name affected actual object name");
|
||||||
|
g_free (name);
|
||||||
|
g_free (name2);
|
||||||
|
}
|
||||||
|
|
||||||
|
END_TEST Suite *
|
||||||
|
gst_object_suite (void)
|
||||||
|
{
|
||||||
|
Suite *s = suite_create ("GstObject");
|
||||||
|
TCase *tc_chain = tcase_create ("general");
|
||||||
|
|
||||||
|
suite_add_tcase (s, tc_chain);
|
||||||
|
tcase_add_test_raise_signal (tc_chain, test_fail_abstract_new, SIGSEGV);
|
||||||
|
tcase_add_test (tc_chain, test_fake_object_new);
|
||||||
|
tcase_add_test (tc_chain, test_fake_object_name);
|
||||||
|
//tcase_add_checked_fixture (tc_chain, setup, teardown);
|
||||||
|
return s;
|
||||||
|
}
|
||||||
|
|
||||||
|
int
|
||||||
|
main (int argc, char **argv)
|
||||||
|
{
|
||||||
|
int nf;
|
||||||
|
|
||||||
|
Suite *s = gst_object_suite ();
|
||||||
|
SRunner *sr = srunner_create (s);
|
||||||
|
|
||||||
|
gst_init (&argc, &argv);
|
||||||
|
|
||||||
|
srunner_run_all (sr, CK_NORMAL);
|
||||||
|
nf = srunner_ntests_failed (sr);
|
||||||
|
srunner_free (sr);
|
||||||
|
|
||||||
|
return nf;
|
||||||
|
}
|
|
@ -337,7 +337,8 @@ message_received (GstBus * bus, GstMessage * message, GstPipeline * pipeline)
|
||||||
break;
|
break;
|
||||||
case GST_MESSAGE_ERROR:
|
case GST_MESSAGE_ERROR:
|
||||||
gst_object_default_error (GST_MESSAGE_SRC (message),
|
gst_object_default_error (GST_MESSAGE_SRC (message),
|
||||||
GST_MESSAGE_ERROR_ERROR (message), GST_MESSAGE_ERROR_DEBUG (message));
|
GST_MESSAGE_ERROR_GERROR (message),
|
||||||
|
GST_MESSAGE_ERROR_DEBUG (message));
|
||||||
caught_error = TRUE;
|
caught_error = TRUE;
|
||||||
gst_element_set_state (GST_ELEMENT (pipeline), GST_STATE_NULL);
|
gst_element_set_state (GST_ELEMENT (pipeline), GST_STATE_NULL);
|
||||||
if (g_main_loop_is_running (loop))
|
if (g_main_loop_is_running (loop))
|
||||||
|
|
Loading…
Reference in a new issue