Commit 5539c318 authored by David Schleef's avatar David Schleef
Browse files

Add GstStructure and GstValue

Original commit message from CVS:
Add GstStructure and GstValue
parent 9abb3e06
......@@ -112,6 +112,7 @@ libgstreamer_@GST_MAJORMINOR@_la_SOURCES = \
gstqueue.c \
gstquery.c \
gstscheduler.c \
gststructure.c \
gstsystemclock.c \
gstthread.c \
gstthreaddummy.c \
......@@ -121,6 +122,7 @@ libgstreamer_@GST_MAJORMINOR@_la_SOURCES = \
$(GST_URI_SRC) \
gsturitype.c \
gstutils.c \
gstvalue.c \
$(GST_REGISTRY_SRC) \
gstregistrypool.c \
$(GST_PARSE_SRC) \
......@@ -173,6 +175,7 @@ gst_headers = \
gstqueue.h \
gstquery.h \
gstscheduler.h \
gststructure.h \
gstsystemclock.h \
gstthread.h \
gsttrace.h \
......@@ -182,6 +185,7 @@ gst_headers = \
gsturi.h \
gsturitype.h \
gstutils.h \
gstvalue.h \
gstregistry.h \
gstregistrypool.h \
gstparse.h \
......
......@@ -526,6 +526,8 @@ init_post (void)
_gst_plugin_register_static (&plugin_desc);
_gst_cpu_initialize (_gst_enable_cpu_opt);
_gst_structure_initialize ();
_gst_value_initialize ();
_gst_props_initialize ();
_gst_caps_initialize ();
_gst_plugin_initialize ();
......
......@@ -44,6 +44,7 @@
#include <gst/gsttypefind.h>
#include <gst/gstautoplug.h>
#include <gst/gstcaps.h>
#include <gst/gststructure.h>
#include <gst/gstprops.h>
#include <gst/gstplugin.h>
#include <gst/gsturi.h>
......@@ -56,6 +57,7 @@
#include <gst/gstclock.h>
#include <gst/gstsystemclock.h>
#include <gst/gstinterface.h>
#include <gst/gstvalue.h>
#include <gst/gstparse.h>
#include <gst/gstregistry.h>
......
This diff is collapsed.
/* GStreamer
* Copyright (C) <2003> David A. Schleef <ds@schleef.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.
*/
#ifndef __GST_STRUCTURE_H__
#define __GST_STRUCTURE_H__
#include <gst/gstconfig.h>
#include <glib-object.h>
G_BEGIN_DECLS
typedef struct _GstStructure GstStructure;
typedef struct _GstStructureField GstStructureField;
struct _GstStructure {
int len;
GQuark name;
GArray *fields;
};
struct _GstStructureField {
GQuark name;
GValue value;
};
#define GST_STRUCTURE_FIELD(structure, index) \
&g_array_index((structure)->fields, GstStructureField, (index))
GType gst_structure_get_type(void);
void _gst_structure_initialize(void);
GstStructure *gst_structure_empty_new(const gchar *name);
GstStructure *gst_structure_new(const gchar *name,
const gchar *firstfield, ...);
GstStructure *gst_structure_new_valist(const gchar *name,
const gchar *firstfield, va_list varargs);
GstStructure *gst_structure_dup(GstStructure *structure);
void gst_structure_free(GstStructure *structure);
const gchar *gst_structure_get_name(GstStructure *structure);
void gst_structure_set_name(GstStructure *structure, const gchar *name);
void gst_structure_set_field(GstStructure *structure,
GstStructureField *field);
void gst_structure_id_set_value(GstStructure *structure, GQuark field,
GValue *value);
void gst_structure_set_value(GstStructure *structure, const gchar *field,
GValue *value);
void gst_structure_set(GstStructure *structure, const gchar *field, ...);
void gst_structure_set_valist(GstStructure *structure, const gchar *field,
va_list varargs);
const GValue *gst_structure_get(GstStructure *structure, const gchar *field);
GstStructureField *gst_structure_get_field(GstStructure *structure,
const gchar *fieldname);
GstStructureField *gst_structure_id_get_field(GstStructure *structure,
GQuark fieldname);
void gst_structure_remove_field(GstStructure *structure, const gchar *field);
GType gst_structure_get_field_type(GstStructure *structure,
const gchar *field);
gint gst_structure_n_fields(GstStructure *structure);
gboolean gst_structure_has_field(GstStructure *structure, const gchar *field);
gboolean gst_structure_has_field_typed(GstStructure *structure,
const gchar *field, GType type);
/* utility functions */
gboolean gst_structure_get_boolean(GstStructure *structure, const gchar *field,
gboolean *value);
gboolean gst_structure_get_int(GstStructure *structure, const gchar *field,
gint *value);
gboolean gst_structure_get_fourcc(GstStructure *structure, const gchar *field,
guint32 *value);
gboolean gst_structure_get_double(GstStructure *structure, const gchar *field,
gdouble *value);
const gchar *gst_structure_get_string(GstStructure *structure,
const gchar *field);
gchar * gst_structure_to_string(GstStructure *structure);
GstStructure * gst_structure_from_string (const gchar *string);
G_END_DECLS
#endif
/* GStreamer
* Copyright (C) <2003> David A. Schleef <ds@schleef.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.
*/
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include <gst/gst.h>
#include <gobject/gvaluecollector.h>
GType gst_type_fourcc;
GType gst_type_int_range;
GType gst_type_double_range;
static void
gst_value_init_fourcc (GValue *value)
{
value->data[0].v_long = 0;
}
static void
gst_value_copy_fourcc (const GValue *src_value, GValue *dest_value)
{
dest_value->data[0].v_long = src_value->data[0].v_long;
}
static gchar *
gst_value_collect_fourcc (GValue *value, guint n_collect_values,
GTypeCValue *collect_values, guint collect_flags)
{
value->data[0].v_long = collect_values[0].v_long;
return NULL;
}
static gchar *
gst_value_lcopy_fourcc (const GValue *value, guint n_collect_values,
GTypeCValue *collect_values, guint collect_flags)
{
guint32 *fourcc_p = collect_values[0].v_pointer;
if (!fourcc_p)
return g_strdup_printf ("value location for `%s' passed as NULL",
G_VALUE_TYPE_NAME (value));
*fourcc_p = value->data[0].v_long;
return NULL;
}
void
gst_value_set_fourcc (GValue *value, guint32 fourcc)
{
g_return_if_fail (GST_VALUE_HOLDS_FOURCC (value));
value->data[0].v_long = fourcc;
}
guint32
gst_value_get_fourcc (const GValue *value)
{
g_return_val_if_fail (GST_VALUE_HOLDS_FOURCC (value), 0);
return value->data[0].v_long;
}
/* int range */
static void
gst_value_init_int_range (GValue *value)
{
value->data[0].v_long = 0;
}
static void
gst_value_copy_int_range (const GValue *src_value, GValue *dest_value)
{
dest_value->data[0].v_long = src_value->data[0].v_long;
}
static gchar *
gst_value_collect_int_range (GValue *value, guint n_collect_values,
GTypeCValue *collect_values, guint collect_flags)
{
value->data[0].v_long = collect_values[0].v_long;
return NULL;
}
static gchar *
gst_value_lcopy_int_range (const GValue *value, guint n_collect_values,
GTypeCValue *collect_values, guint collect_flags)
{
guint32 *int_range_p = collect_values[0].v_pointer;
if (!int_range_p)
return g_strdup_printf ("value location for `%s' passed as NULL",
G_VALUE_TYPE_NAME (value));
*int_range_p = value->data[0].v_long;
return NULL;
}
void
gst_value_set_int_range (GValue *value, int start, int end)
{
g_return_if_fail (GST_VALUE_HOLDS_FOURCC (value));
value->data[0].v_long = start;
value->data[1].v_long = end;
}
int
gst_value_get_int_range_start (const GValue *value)
{
g_return_val_if_fail (GST_VALUE_HOLDS_FOURCC (value), 0);
return value->data[0].v_long;
}
int
gst_value_get_int_range_end (const GValue *value)
{
g_return_val_if_fail (GST_VALUE_HOLDS_FOURCC (value), 0);
return value->data[1].v_long;
}
static void
gst_value_transform_fourcc_string (const GValue *src_value,
GValue *dest_value)
{
dest_value->data[0].v_pointer = g_strdup_printf(GST_FOURCC_FORMAT,
GST_FOURCC_ARGS(src_value->data[0].v_long));
}
static void
gst_value_transform_int_range_string (const GValue *src_value,
GValue *dest_value)
{
dest_value->data[0].v_pointer = g_strdup_printf("[%d,%d]",
(int)src_value->data[0].v_long, (int)src_value->data[1].v_long);
}
void
_gst_value_initialize (void)
{
GTypeInfo info = {
0,
NULL,
NULL,
NULL,
NULL,
NULL,
0,
0,
NULL,
NULL,
};
//const GTypeFundamentalInfo finfo = { G_TYPE_FLAG_DERIVABLE, };
{
static const GTypeValueTable value_table = {
gst_value_init_fourcc,
NULL,
gst_value_copy_fourcc,
NULL,
"i",
gst_value_collect_fourcc,
"p",
gst_value_lcopy_fourcc
};
info.value_table = &value_table;
gst_type_fourcc = g_type_register_static (G_TYPE_BOXED, "GstFourcc", &info, 0);
}
{
static const GTypeValueTable value_table = {
gst_value_init_int_range,
NULL,
gst_value_copy_int_range,
NULL,
"i",
gst_value_collect_int_range,
"p",
gst_value_lcopy_int_range
};
info.value_table = &value_table;
gst_type_int_range = g_type_register_static (G_TYPE_BOXED, "GstIntRange", &info, 0);
}
g_value_register_transform_func (GST_TYPE_FOURCC, G_TYPE_STRING,
gst_value_transform_fourcc_string);
g_value_register_transform_func (GST_TYPE_INT_RANGE, G_TYPE_STRING,
gst_value_transform_int_range_string);
}
/* GStreamer
* Copyright (C) <2003> David A. Schleef <ds@schleef.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.
*/
#ifndef __GST_VALUE_H__
#define __GST_VALUE_H__
#include <gst/gstconfig.h>
G_BEGIN_DECLS
#define GST_VALUE_HOLDS_FOURCC(x) TRUE
#define GST_TYPE_FOURCC gst_type_fourcc
#define GST_TYPE_INT_RANGE gst_type_int_range
#define GST_TYPE_DOUBLE_RANGE gst_type_double_range
extern GType gst_type_fourcc;
extern GType gst_type_int_range;
extern GType gst_type_double_range;
void gst_value_set_fourcc (GValue *value, guint32 fourcc);
guint32 gst_value_get_fourcc (const GValue *value);
void gst_value_set_int_range (GValue *value, int start, int end);
int gst_value_get_int_range_start (const GValue *value);
int gst_value_get_int_range_end (const GValue *value);
void gst_value_set_double_range (GValue *value, double start, double end);
double gst_value_get_double_range_start (const GValue *value);
double gst_value_get_double_range_end (const GValue *value);
void _gst_value_initialize (void);
G_END_DECLS
#endif
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment