configure.ac: Add DATADIR for storing presets.

Original commit message from CVS:
Patch by: Stefan Kost  <ensonic@users.sf.net>
* configure.ac:
Add DATADIR for storing presets.
* docs/gst/gstreamer-docs.sgml:
* docs/gst/gstreamer-sections.txt:
* docs/gst/gstreamer.types.in:
Add GstPreset to docs.
* gst/Makefile.am:
* gst/gst.h:
* gst/gstpreset.c: (preset_get_paths), (preset_skip_property),
(preset_open_and_parse_header), (preset_parse_version),
(preset_merge), (preset_get_keyfile),
(gst_preset_default_get_preset_names),
(gst_preset_default_get_property_names),
(gst_preset_default_load_preset),
(gst_preset_default_save_presets_file),
(gst_preset_default_save_preset),
(gst_preset_default_rename_preset),
(gst_preset_default_delete_preset), (gst_preset_default_set_meta),
(gst_preset_default_get_meta), (gst_preset_default_randomize),
(gst_preset_default_reset), (gst_preset_get_preset_names),
(gst_preset_get_property_names), (gst_preset_load_preset),
(gst_preset_save_preset), (gst_preset_rename_preset),
(gst_preset_delete_preset), (gst_preset_set_meta),
(gst_preset_get_meta), (gst_preset_class_init),
(gst_preset_base_init), (gst_preset_get_type):
* gst/gstpreset.h:
Add GstPreset to core. Fixes #396779
* tests/check/Makefile.am:
* tests/check/gst/gstpreset.c: (gst_preset_test_get_property),
(gst_preset_test_set_property), (gst_preset_test_class_init),
(gst_preset_test_base_init), (gst_preset_test_get_type),
(gst_preset_test_plugin_init), (GST_START_TEST),
(remove_preset_file), (test_setup), (test_teardown),
(gst_preset_suite):
Add GstPreset unit tests.
This commit is contained in:
Stefan Kost 2008-05-27 15:11:35 +00:00 committed by Wim Taymans
parent e84afb820d
commit bedb591973
11 changed files with 1621 additions and 1 deletions

View file

@ -1,3 +1,46 @@
2008-05-27 Wim Taymans <wim.taymans@collabora.co.uk>
Patch by: Stefan Kost <ensonic@users.sf.net>
* configure.ac:
Add DATADIR for storing presets.
* docs/gst/gstreamer-docs.sgml:
* docs/gst/gstreamer-sections.txt:
* docs/gst/gstreamer.types.in:
Add GstPreset to docs.
* gst/Makefile.am:
* gst/gst.h:
* gst/gstpreset.c: (preset_get_paths), (preset_skip_property),
(preset_open_and_parse_header), (preset_parse_version),
(preset_merge), (preset_get_keyfile),
(gst_preset_default_get_preset_names),
(gst_preset_default_get_property_names),
(gst_preset_default_load_preset),
(gst_preset_default_save_presets_file),
(gst_preset_default_save_preset),
(gst_preset_default_rename_preset),
(gst_preset_default_delete_preset), (gst_preset_default_set_meta),
(gst_preset_default_get_meta), (gst_preset_default_randomize),
(gst_preset_default_reset), (gst_preset_get_preset_names),
(gst_preset_get_property_names), (gst_preset_load_preset),
(gst_preset_save_preset), (gst_preset_rename_preset),
(gst_preset_delete_preset), (gst_preset_set_meta),
(gst_preset_get_meta), (gst_preset_class_init),
(gst_preset_base_init), (gst_preset_get_type):
* gst/gstpreset.h:
Add GstPreset to core. Fixes #396779
* tests/check/Makefile.am:
* tests/check/gst/gstpreset.c: (gst_preset_test_get_property),
(gst_preset_test_set_property), (gst_preset_test_class_init),
(gst_preset_test_base_init), (gst_preset_test_get_type),
(gst_preset_test_plugin_init), (GST_START_TEST),
(remove_preset_file), (test_setup), (test_teardown),
(gst_preset_suite):
Add GstPreset unit tests.
2008-05-27 Wim Taymans <wim.taymans@collabora.co.uk>
* gst/gstpad.c: (gst_pad_event_default_dispatch):

View file

@ -524,9 +524,11 @@ GST_LICENSE="LGPL"
AC_DEFINE_UNQUOTED(GST_LICENSE, "$GST_LICENSE", [GStreamer license])
AC_SUBST(GST_LICENSE)
dnl define LIBDIR so we can inform people where we live
dnl define LIBDIR, DATADIR so we can inform people where we live
AS_AC_EXPAND(LIBDIR, $libdir)
AC_DEFINE_UNQUOTED(LIBDIR, "$LIBDIR", [library dir])
AS_AC_EXPAND(DATADIR, $datadir)
AC_DEFINE_UNQUOTED(DATADIR, "$DATADIR", [data dir])
dnl set location of plugin directory
AG_GST_SET_PLUGINDIR

View file

@ -37,6 +37,7 @@
<!ENTITY GstPlugin SYSTEM "xml/gstplugin.xml">
<!ENTITY GstPluginFeature SYSTEM "xml/gstpluginfeature.xml">
<!ENTITY GstPoll SYSTEM "xml/gstpoll.xml">
<!ENTITY GstPreset SYSTEM "xml/gstpreset.xml">
<!ENTITY GstQuery SYSTEM "xml/gstquery.xml">
<!ENTITY GstRegistry SYSTEM "xml/gstregistry.xml">
<!ENTITY GstSegment SYSTEM "xml/gstsegment.xml">
@ -130,6 +131,7 @@ Windows. It is released under the GNU Library General Public License
&GstPlugin;
&GstPluginFeature;
&GstPoll;
&GstPreset;
&GstQuery;
&GstRegistry;
&GstSegment;

View file

@ -1691,6 +1691,26 @@ gst_poll_set_flushing
gst_poll_wait
</SECTION>
<SECTION>
<FILE>gstpreset</FILE>
<TITLE>GstPreset</TITLE>
GstPreset
gst_preset_get_preset_names
gst_preset_get_property_names
gst_preset_load_preset
gst_preset_save_preset
gst_preset_rename_preset
gst_preset_delete_preset
gst_preset_set_meta
gst_preset_get_meta
<SUBSECTION Standard>
GstPresetInterface
GST_PRESET
GST_IS_PRESET
GST_TYPE_PRESET
GST_PRESET_GET_INTERFACE
gst_preset_get_type
</SECTION>
<SECTION>
<FILE>gstquery</FILE>

View file

@ -23,6 +23,7 @@ gst_pad_get_type
gst_pad_template_get_type
gst_pipeline_get_type
gst_plugin_feature_get_type
gst_preset_get_type
gst_registry_get_type
gst_system_clock_get_type
gst_tag_setter_get_type

View file

@ -103,6 +103,7 @@ libgstreamer_@GST_MAJORMINOR@_la_SOURCES = \
gstplugin.c \
gstpluginfeature.c \
gstpoll.c \
gstpreset.c \
gstquark.c \
gstquery.c \
gstregistry.c \
@ -187,6 +188,7 @@ gst_headers = \
gstplugin.h \
gstpluginfeature.h \
gstpoll.h \
gstpreset.h \
gstquery.h \
gstsegment.h \
gststructure.h \

View file

@ -55,6 +55,7 @@
#include <gst/gstpipeline.h>
#include <gst/gstplugin.h>
#include <gst/gstpoll.h>
#include <gst/gstpreset.h>
#include <gst/gstquery.h>
#include <gst/gstregistry.h>
#include <gst/gstsegment.h>

1175
gst/gstpreset.c Normal file

File diff suppressed because it is too large Load diff

80
gst/gstpreset.h Normal file
View file

@ -0,0 +1,80 @@
/* GStreamer
* Copyright (C) 2006 Stefan Kost <ensonic@users.sf.net>
*
* gstpreset.h: helper interface header for element presets
*
* 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_PRESET_H__
#define __GST_PRESET_H__
#include <glib-object.h>
#include <gst/gst.h>
G_BEGIN_DECLS
#define GST_TYPE_PRESET (gst_preset_get_type())
#define GST_PRESET(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GST_TYPE_PRESET, GstPreset))
#define GST_IS_PRESET(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GST_TYPE_PRESET))
#define GST_PRESET_GET_INTERFACE(obj) (G_TYPE_INSTANCE_GET_INTERFACE ((obj), GST_TYPE_PRESET, GstPresetInterface))
typedef struct _GstPreset GstPreset; /* dummy object */
typedef struct _GstPresetInterface GstPresetInterface;
struct _GstPresetInterface
{
GTypeInterface parent;
gchar** (*get_preset_names) (GstPreset *preset);
gchar** (*get_property_names) (GstPreset *preset);
gboolean (*load_preset) (GstPreset *preset, const gchar *name);
gboolean (*save_preset) (GstPreset *preset, const gchar *name);
gboolean (*rename_preset) (GstPreset *preset, const gchar *old_name,
const gchar *new_name);
gboolean (*delete_preset) (GstPreset *preset, const gchar *name);
gboolean (*set_meta) (GstPreset *preset, const gchar *name,
const gchar *tag, const gchar *value);
gboolean (*get_meta) (GstPreset *preset, const gchar *name,
const gchar *tag, gchar **value);
/*< private >*/
gpointer _gst_reserved[GST_PADDING];
};
GType gst_preset_get_type(void);
gchar** gst_preset_get_preset_names (GstPreset *preset);
gchar** gst_preset_get_property_names (GstPreset *preset);
gboolean gst_preset_load_preset (GstPreset *preset, const gchar *name);
gboolean gst_preset_save_preset (GstPreset *preset, const gchar *name);
gboolean gst_preset_rename_preset (GstPreset *preset, const gchar *old_name,
const gchar *new_name);
gboolean gst_preset_delete_preset (GstPreset *preset, const gchar *name);
gboolean gst_preset_set_meta (GstPreset *preset, const gchar *name,
const gchar *tag, const gchar *value);
gboolean gst_preset_get_meta (GstPreset *preset, const gchar *name,
const gchar *tag, gchar **value);
G_END_DECLS
#endif /* __GST_PRESET_H__ */

View file

@ -52,6 +52,7 @@ REGISTRY_CHECKS = \
gst/gstindex \
gst/gstinterface \
gst/gstplugin \
gst/gstpreset \
gst/gstquery \
gst/gstregistry \
gst/gsturi \

293
tests/check/gst/gstpreset.c Normal file
View file

@ -0,0 +1,293 @@
/* GStreamer
* Copyright (C) 2008 Nokia Corporation and its subsidary(-ies)
* contact: <stefan.kost@nokia.com>
*
* gstpreset.c: Unit test for GstPreset
*
* 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 <glib.h>
#include <glib/gstdio.h>
#include <gst/check/gstcheck.h>
static GType gst_preset_test_get_type (void);
#define GST_TYPE_PRESET_TEST (gst_preset_test_get_type ())
#define GST_PRESET_TEST(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GST_TYPE_PRESET_TEST, GstPresetTest))
#define GST_PRESET_TEST_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GST_TYPE_PRESET_TEST, GstPresetTestClass))
#define GST_IS_PRESET_TEST(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GST_TYPE_PRESET_TEST))
#define GST_IS_PRESET_TEST_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GST_TYPE_PRESET_TEST))
#define GST_PRESET_TEST_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GST_TYPE_PRESET_TEST, GstPresetTestClass))
#define GST_PRESET_TEST_NAME "preset-test"
enum
{
PROP_TEST = 1,
};
typedef struct _GstPresetTest
{
GstElement parent;
gint test;
} GstPresetTest;
typedef struct _GstPresetTestClass
{
GstElementClass parent_class;
} GstPresetTestClass;
static void
gst_preset_test_get_property (GObject * object, guint property_id,
GValue * value, GParamSpec * pspec)
{
GstPresetTest *self = GST_PRESET_TEST (object);
switch (property_id) {
case PROP_TEST:
g_value_set_int (value, self->test);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
break;
}
}
static void
gst_preset_test_set_property (GObject * object, guint property_id,
const GValue * value, GParamSpec * pspec)
{
GstPresetTest *self = GST_PRESET_TEST (object);
switch (property_id) {
case PROP_TEST:
self->test = g_value_get_int (value);
break;
}
}
static void
gst_preset_test_class_init (GObjectClass * klass)
{
klass->set_property = gst_preset_test_set_property;
klass->get_property = gst_preset_test_get_property;
g_object_class_install_property (klass, PROP_TEST,
g_param_spec_int ("test",
"test prop",
"test parameter for preset test",
G_MININT, G_MAXINT, 0, G_PARAM_READWRITE));
}
static void
gst_preset_test_base_init (GstPresetTestClass * klass)
{
static const GstElementDetails details = {
"Element for unit tests",
"Testing",
"Use in unit tests",
"Stefan Kost <stefan.kost@nokia.com>"
};
GstElementClass *element_class = GST_ELEMENT_CLASS (klass);
gst_element_class_set_details (element_class, &details);
}
static GType
gst_preset_test_get_type (void)
{
static GType type = 0;
if (type == 0) {
const GTypeInfo info = {
sizeof (GstPresetTestClass),
(GBaseInitFunc) gst_preset_test_base_init, /* base_init */
NULL, /* base_finalize */
(GClassInitFunc) gst_preset_test_class_init, /* class_init */
NULL, /* class_finalize */
NULL, /* class_data */
sizeof (GstPresetTest),
0, /* n_preallocs */
NULL, /* instance_init */
NULL /* value_table */
};
const GInterfaceInfo preset_interface_info = {
NULL, /* interface_init */
NULL, /* interface_finalize */
NULL /* interface_data */
};
type = g_type_register_static (GST_TYPE_ELEMENT, "GstPresetTest", &info, 0);
g_type_add_interface_static (type, GST_TYPE_PRESET, &preset_interface_info);
}
return type;
}
static gboolean
gst_preset_test_plugin_init (GstPlugin * plugin)
{
gst_element_register (plugin, GST_PRESET_TEST_NAME, GST_RANK_NONE,
GST_TYPE_PRESET_TEST);
return TRUE;
}
GST_START_TEST (test_check)
{
GstElement *elem;
elem = gst_element_factory_make (GST_PRESET_TEST_NAME, NULL);
fail_unless (GST_IS_PRESET (elem));
gst_object_unref (elem);
}
GST_END_TEST;
GST_START_TEST (test_load)
{
GstElement *elem;
gboolean res;
elem = gst_element_factory_make (GST_PRESET_TEST_NAME, NULL);
res = gst_preset_load_preset (GST_PRESET (elem), "does-not-exist");
fail_unless (!res);
gst_object_unref (elem);
}
GST_END_TEST;
GST_START_TEST (test_add)
{
GstElement *elem;
gboolean res;
gint val;
elem = gst_element_factory_make (GST_PRESET_TEST_NAME, NULL);
g_object_set (elem, "test", 5, NULL);
res = gst_preset_save_preset (GST_PRESET (elem), "test");
fail_unless (res);
res = gst_preset_load_preset (GST_PRESET (elem), "test");
fail_unless (res);
g_object_get (elem, "test", &val, NULL);
fail_unless (val == 5);
gst_object_unref (elem);
}
GST_END_TEST;
GST_START_TEST (test_del)
{
GstElement *elem;
gboolean res;
elem = gst_element_factory_make (GST_PRESET_TEST_NAME, NULL);
res = gst_preset_save_preset (GST_PRESET (elem), "test");
fail_unless (res);
res = gst_preset_delete_preset (GST_PRESET (elem), "test");
fail_unless (res);
res = gst_preset_load_preset (GST_PRESET (elem), "test");
fail_unless (!res);
gst_object_unref (elem);
}
GST_END_TEST;
GST_START_TEST (test_two_instances)
{
GstElement *elem1, *elem2;
gboolean res;
gint val;
elem1 = gst_element_factory_make (GST_PRESET_TEST_NAME, NULL);
g_object_set (elem1, "test", 5, NULL);
res = gst_preset_save_preset (GST_PRESET (elem1), "test");
fail_unless (res);
elem2 = gst_element_factory_make (GST_PRESET_TEST_NAME, NULL);
res = gst_preset_load_preset (GST_PRESET (elem2), "test");
fail_unless (res);
g_object_get (elem2, "test", &val, NULL);
fail_unless (val == 5);
gst_object_unref (elem1);
gst_object_unref (elem2);
}
GST_END_TEST;
static void
remove_preset_file (void)
{
gchar *preset_file_name;
preset_file_name = g_build_filename (g_get_home_dir (),
".gstreamer-" GST_MAJORMINOR, "presets", "GstPresetTest.prs", NULL);
g_unlink (preset_file_name);
g_free (preset_file_name);
}
static void
test_setup (void)
{
remove_preset_file ();
gst_plugin_register_static (GST_VERSION_MAJOR,
GST_VERSION_MINOR,
"gst-test",
"preset test plugin",
gst_preset_test_plugin_init,
VERSION, GST_LICENSE, PACKAGE, GST_PACKAGE_NAME, GST_PACKAGE_ORIGIN);
}
static void
test_teardown (void)
{
remove_preset_file ();
}
static Suite *
gst_preset_suite (void)
{
Suite *s = suite_create ("GstPreset");
TCase *tc = tcase_create ("preset");
suite_add_tcase (s, tc);
tcase_add_test (tc, test_check);
tcase_add_test (tc, test_load);
tcase_add_test (tc, test_add);
tcase_add_test (tc, test_del);
tcase_add_test (tc, test_two_instances);
tcase_add_unchecked_fixture (tc, test_setup, test_teardown);
return s;
}
GST_CHECK_MAIN (gst_preset);