2003-11-03 09:10:07 +00:00
|
|
|
/* GStreamer
|
|
|
|
* Copyright (C) 2003 David A. Schleef <ds@schleef.org>
|
|
|
|
*
|
|
|
|
* gststructure.c: lists of { GQuark, GValue } tuples
|
|
|
|
*
|
|
|
|
* 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.
|
|
|
|
*/
|
2005-10-15 16:01:57 +00:00
|
|
|
|
2005-09-02 16:17:23 +00:00
|
|
|
/**
|
|
|
|
* SECTION:gststructure
|
|
|
|
* @short_description: Generic structure containing fields of names and values
|
2005-11-09 15:10:32 +00:00
|
|
|
* @see_also: #GstCaps, #GstMessage, #GstEvent, #GstQuery
|
2005-09-02 16:17:23 +00:00
|
|
|
*
|
2006-08-14 12:35:06 +00:00
|
|
|
* A #GstStructure is a collection of key/value pairs. The keys are expressed
|
|
|
|
* as GQuarks and the values can be of any GType.
|
2005-11-09 15:10:32 +00:00
|
|
|
*
|
2007-10-16 13:58:43 +00:00
|
|
|
* In addition to the key/value pairs, a #GstStructure also has a name. The name
|
|
|
|
* starts with a letter and can be folled by letters, numbers and any of "/-_.:".
|
2005-11-09 15:10:32 +00:00
|
|
|
*
|
2006-08-14 12:35:06 +00:00
|
|
|
* #GstStructure is used by various GStreamer subsystems to store information
|
|
|
|
* in a flexible and extensible way. A #GstStructure does not have a refcount
|
|
|
|
* because it usually is part of a higher level object such as #GstCaps. It
|
|
|
|
* provides a means to enforce mutability using the refcount of the parent
|
|
|
|
* with the gst_structure_set_parent_refcount() method.
|
|
|
|
*
|
|
|
|
* A #GstStructure can be created with gst_structure_empty_new() or
|
|
|
|
* gst_structure_new(), which both take a name and an optional set of
|
|
|
|
* key/value pairs along with the types of the values.
|
2005-11-09 15:10:32 +00:00
|
|
|
*
|
2006-08-14 12:35:06 +00:00
|
|
|
* Field values can be changed with gst_structure_set_value() or
|
|
|
|
* gst_structure_set().
|
2005-11-09 15:10:32 +00:00
|
|
|
*
|
2006-08-14 12:35:06 +00:00
|
|
|
* Field values can be retrieved with gst_structure_get_value() or the more
|
|
|
|
* convenient gst_structure_get_*() functions.
|
2005-11-09 15:10:32 +00:00
|
|
|
*
|
2006-08-14 12:35:06 +00:00
|
|
|
* Fields can be removed with gst_structure_remove_field() or
|
|
|
|
* gst_structure_remove_fields().
|
2005-11-09 15:10:32 +00:00
|
|
|
*
|
2007-10-16 13:58:43 +00:00
|
|
|
* Last reviewed on 2007-10-16 (0.10.15)
|
2005-09-02 16:17:23 +00:00
|
|
|
*/
|
2003-11-03 09:10:07 +00:00
|
|
|
|
|
|
|
#ifdef HAVE_CONFIG_H
|
|
|
|
#include "config.h"
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#include <string.h>
|
|
|
|
|
2004-05-07 02:36:28 +00:00
|
|
|
#include "gst_private.h"
|
2003-11-03 09:10:07 +00:00
|
|
|
#include <gst/gst.h>
|
|
|
|
#include <gobject/gvaluecollector.h>
|
|
|
|
|
2003-12-22 01:39:35 +00:00
|
|
|
typedef struct _GstStructureField GstStructureField;
|
2004-03-12 19:35:40 +00:00
|
|
|
|
2004-03-13 15:27:01 +00:00
|
|
|
struct _GstStructureField
|
|
|
|
{
|
2003-12-22 01:39:35 +00:00
|
|
|
GQuark name;
|
|
|
|
GValue value;
|
|
|
|
};
|
|
|
|
|
|
|
|
#define GST_STRUCTURE_FIELD(structure, index) \
|
|
|
|
&g_array_index((structure)->fields, GstStructureField, (index))
|
|
|
|
|
2005-03-07 18:27:42 +00:00
|
|
|
#define IS_MUTABLE(structure) \
|
|
|
|
(!(structure)->parent_refcount || \
|
2005-04-24 22:49:45 +00:00
|
|
|
g_atomic_int_get ((structure)->parent_refcount) == 1)
|
2005-03-07 18:27:42 +00:00
|
|
|
|
2004-03-13 15:27:01 +00:00
|
|
|
static void gst_structure_set_field (GstStructure * structure,
|
|
|
|
GstStructureField * field);
|
|
|
|
static GstStructureField *gst_structure_get_field (const GstStructure *
|
|
|
|
structure, const gchar * fieldname);
|
|
|
|
static GstStructureField *gst_structure_id_get_field (const GstStructure *
|
|
|
|
structure, GQuark field);
|
|
|
|
static void gst_structure_transform_to_string (const GValue * src_value,
|
|
|
|
GValue * dest_value);
|
|
|
|
static GstStructure *gst_structure_copy_conditional (const GstStructure *
|
|
|
|
structure);
|
|
|
|
static gboolean gst_structure_parse_value (gchar * str, gchar ** after,
|
|
|
|
GValue * value, GType default_type);
|
|
|
|
static gboolean gst_structure_parse_simple_string (gchar * s, gchar ** end);
|
2003-11-03 09:10:07 +00:00
|
|
|
|
2004-03-12 19:35:40 +00:00
|
|
|
GType
|
2004-03-13 15:27:01 +00:00
|
|
|
gst_structure_get_type (void)
|
2003-11-03 09:10:07 +00:00
|
|
|
{
|
2005-03-21 17:34:02 +00:00
|
|
|
static GType gst_structure_type = 0;
|
2003-11-03 09:10:07 +00:00
|
|
|
|
2006-02-28 10:52:02 +00:00
|
|
|
if (G_UNLIKELY (gst_structure_type == 0)) {
|
2004-03-13 15:27:01 +00:00
|
|
|
gst_structure_type = g_boxed_type_register_static ("GstStructure",
|
2004-03-15 19:27:17 +00:00
|
|
|
(GBoxedCopyFunc) gst_structure_copy_conditional,
|
|
|
|
(GBoxedFreeFunc) gst_structure_free);
|
2004-03-13 15:27:01 +00:00
|
|
|
|
|
|
|
g_value_register_transform_func (gst_structure_type, G_TYPE_STRING,
|
2004-03-15 19:27:17 +00:00
|
|
|
gst_structure_transform_to_string);
|
2004-03-12 19:35:40 +00:00
|
|
|
}
|
2004-03-13 15:27:01 +00:00
|
|
|
|
2004-03-12 19:35:40 +00:00
|
|
|
return gst_structure_type;
|
2003-11-03 09:10:07 +00:00
|
|
|
}
|
|
|
|
|
2004-08-13 13:31:22 +00:00
|
|
|
static GstStructure *
|
2004-08-04 12:39:12 +00:00
|
|
|
gst_structure_id_empty_new_with_size (GQuark quark, guint prealloc)
|
|
|
|
{
|
|
|
|
GstStructure *structure;
|
|
|
|
|
2008-04-01 13:55:20 +00:00
|
|
|
structure = g_slice_new0 (GstStructure);
|
2004-08-04 12:39:12 +00:00
|
|
|
structure->type = gst_structure_get_type ();
|
|
|
|
structure->name = quark;
|
|
|
|
structure->fields =
|
|
|
|
g_array_sized_new (FALSE, TRUE, sizeof (GstStructureField), prealloc);
|
|
|
|
|
|
|
|
return structure;
|
|
|
|
}
|
|
|
|
|
2003-11-24 02:09:23 +00:00
|
|
|
/**
|
|
|
|
* gst_structure_id_empty_new:
|
2004-01-30 19:06:13 +00:00
|
|
|
* @quark: name of new structure
|
2003-11-24 02:09:23 +00:00
|
|
|
*
|
2005-11-09 15:10:32 +00:00
|
|
|
* Creates a new, empty #GstStructure with the given name as a GQuark.
|
2003-11-24 02:09:23 +00:00
|
|
|
*
|
|
|
|
* Returns: a new, empty #GstStructure
|
|
|
|
*/
|
2004-03-12 19:35:40 +00:00
|
|
|
GstStructure *
|
|
|
|
gst_structure_id_empty_new (GQuark quark)
|
2003-11-24 02:09:23 +00:00
|
|
|
{
|
2004-03-13 15:27:01 +00:00
|
|
|
g_return_val_if_fail (quark != 0, NULL);
|
2003-11-24 02:09:23 +00:00
|
|
|
|
2004-08-04 12:39:12 +00:00
|
|
|
return gst_structure_id_empty_new_with_size (quark, 0);
|
2003-11-24 02:09:23 +00:00
|
|
|
}
|
|
|
|
|
2007-10-16 13:58:43 +00:00
|
|
|
static gboolean
|
|
|
|
gst_structure_validate_name (const gchar * name)
|
|
|
|
{
|
|
|
|
const gchar *s;
|
|
|
|
|
|
|
|
g_return_val_if_fail (name != NULL, FALSE);
|
|
|
|
|
2007-12-08 12:54:53 +00:00
|
|
|
/* FIXME 0.11: use g_ascii_isalpha() */
|
|
|
|
if (!g_ascii_isalnum (*name)) {
|
2007-10-16 13:58:43 +00:00
|
|
|
GST_WARNING ("Invalid character '%c' at offset 0 in structure name: %s",
|
|
|
|
*name, name);
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2007-10-24 13:00:58 +00:00
|
|
|
/* FIXME 0.11: don't allow spaces */
|
2007-10-16 13:58:43 +00:00
|
|
|
/* FIXME: test name string more */
|
|
|
|
s = &name[1];
|
2007-10-24 13:00:58 +00:00
|
|
|
while (*s && (g_ascii_isalnum (*s) || strchr ("/-_.:+ ", *s) != NULL))
|
2007-10-16 13:58:43 +00:00
|
|
|
s++;
|
|
|
|
if (*s != '\0') {
|
|
|
|
GST_WARNING ("Invalid character '%c' at offset %lu in structure name: %s",
|
|
|
|
*s, ((gulong) s - (gulong) name), name);
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2003-11-03 09:10:07 +00:00
|
|
|
/**
|
|
|
|
* gst_structure_empty_new:
|
|
|
|
* @name: name of new structure
|
|
|
|
*
|
2007-10-16 13:58:43 +00:00
|
|
|
* Creates a new, empty #GstStructure with the given @name.
|
|
|
|
*
|
|
|
|
* See gst_structure_set_name() for constraints on the @name parameter.
|
2003-11-03 09:10:07 +00:00
|
|
|
*
|
|
|
|
* Returns: a new, empty #GstStructure
|
|
|
|
*/
|
2004-03-12 19:35:40 +00:00
|
|
|
GstStructure *
|
2004-03-13 15:27:01 +00:00
|
|
|
gst_structure_empty_new (const gchar * name)
|
2003-11-03 09:10:07 +00:00
|
|
|
{
|
2007-10-16 13:58:43 +00:00
|
|
|
g_return_val_if_fail (gst_structure_validate_name (name), NULL);
|
2003-11-03 09:10:07 +00:00
|
|
|
|
2004-08-04 12:39:12 +00:00
|
|
|
return gst_structure_id_empty_new_with_size (g_quark_from_string (name), 0);
|
2003-11-03 09:10:07 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* gst_structure_new:
|
|
|
|
* @name: name of new structure
|
|
|
|
* @firstfield: name of first field to set
|
|
|
|
* @...: additional arguments
|
|
|
|
*
|
|
|
|
* Creates a new #GstStructure with the given name. Parses the
|
|
|
|
* list of variable arguments and sets fields to the values listed.
|
|
|
|
* Variable arguments should be passed as field name, field type,
|
|
|
|
* and value. Last variable argument should be NULL.
|
|
|
|
*
|
|
|
|
* Returns: a new #GstStructure
|
|
|
|
*/
|
2004-03-13 15:27:01 +00:00
|
|
|
GstStructure *
|
|
|
|
gst_structure_new (const gchar * name, const gchar * firstfield, ...)
|
2003-11-03 09:10:07 +00:00
|
|
|
{
|
|
|
|
GstStructure *structure;
|
|
|
|
va_list varargs;
|
|
|
|
|
2004-03-13 15:27:01 +00:00
|
|
|
g_return_val_if_fail (name != NULL, NULL);
|
2003-11-03 09:10:07 +00:00
|
|
|
|
2004-03-13 15:27:01 +00:00
|
|
|
va_start (varargs, firstfield);
|
2003-11-03 09:10:07 +00:00
|
|
|
|
2004-03-13 15:27:01 +00:00
|
|
|
structure = gst_structure_new_valist (name, firstfield, varargs);
|
2003-11-03 09:10:07 +00:00
|
|
|
|
2004-03-13 15:27:01 +00:00
|
|
|
va_end (varargs);
|
2003-11-03 09:10:07 +00:00
|
|
|
|
|
|
|
return structure;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* gst_structure_new_valist:
|
|
|
|
* @name: name of new structure
|
|
|
|
* @firstfield: name of first field to set
|
2004-01-30 19:06:13 +00:00
|
|
|
* @varargs: variable argument list
|
2003-11-03 09:10:07 +00:00
|
|
|
*
|
2007-10-16 13:58:43 +00:00
|
|
|
* Creates a new #GstStructure with the given @name. Structure fields
|
2003-11-03 09:10:07 +00:00
|
|
|
* are set according to the varargs in a manner similar to
|
2007-10-16 13:58:43 +00:00
|
|
|
* gst_structure_new().
|
|
|
|
*
|
|
|
|
* See gst_structure_set_name() for constraints on the @name parameter.
|
2003-11-03 09:10:07 +00:00
|
|
|
*
|
|
|
|
* Returns: a new #GstStructure
|
|
|
|
*/
|
2004-03-12 19:35:40 +00:00
|
|
|
GstStructure *
|
2004-03-13 15:27:01 +00:00
|
|
|
gst_structure_new_valist (const gchar * name,
|
|
|
|
const gchar * firstfield, va_list varargs)
|
2003-11-03 09:10:07 +00:00
|
|
|
{
|
|
|
|
GstStructure *structure;
|
|
|
|
|
2004-03-13 15:27:01 +00:00
|
|
|
g_return_val_if_fail (name != NULL, NULL);
|
2003-11-03 09:10:07 +00:00
|
|
|
|
2004-03-13 15:27:01 +00:00
|
|
|
structure = gst_structure_empty_new (name);
|
2007-12-08 12:54:53 +00:00
|
|
|
|
|
|
|
if (structure)
|
|
|
|
gst_structure_set_valist (structure, firstfield, varargs);
|
2003-11-03 09:10:07 +00:00
|
|
|
|
|
|
|
return structure;
|
|
|
|
}
|
|
|
|
|
2005-03-07 18:27:42 +00:00
|
|
|
/**
|
|
|
|
* gst_structure_set_parent_refcount:
|
|
|
|
* @structure: a #GstStructure
|
2005-04-24 22:49:45 +00:00
|
|
|
* @refcount: a pointer to the parent's refcount
|
2005-03-07 18:27:42 +00:00
|
|
|
*
|
|
|
|
* Sets the parent_refcount field of #GstStructure. This field is used to
|
|
|
|
* determine whether a structure is mutable or not. This function should only be
|
2005-11-09 15:10:32 +00:00
|
|
|
* called by code implementing parent objects of #GstStructure, as described in
|
2005-03-07 18:27:42 +00:00
|
|
|
* the MT Refcounting section of the design documents.
|
|
|
|
*/
|
|
|
|
void
|
2005-04-24 22:49:45 +00:00
|
|
|
gst_structure_set_parent_refcount (GstStructure * structure, int *refcount)
|
2005-03-07 18:27:42 +00:00
|
|
|
{
|
2005-04-21 09:33:31 +00:00
|
|
|
g_return_if_fail (structure != NULL);
|
|
|
|
|
|
|
|
/* if we have a parent_refcount already, we can only clear
|
|
|
|
* if with a NULL refcount */
|
2005-03-07 18:27:42 +00:00
|
|
|
if (structure->parent_refcount)
|
|
|
|
g_return_if_fail (refcount == NULL);
|
|
|
|
else
|
|
|
|
g_return_if_fail (refcount != NULL);
|
|
|
|
|
|
|
|
structure->parent_refcount = refcount;
|
|
|
|
}
|
|
|
|
|
2003-11-03 09:10:07 +00:00
|
|
|
/**
|
2003-11-04 05:54:24 +00:00
|
|
|
* gst_structure_copy:
|
2003-11-03 09:10:07 +00:00
|
|
|
* @structure: a #GstStructure to duplicate
|
|
|
|
*
|
|
|
|
* Duplicates a #GstStructure and all its fields and values.
|
|
|
|
*
|
|
|
|
* Returns: a new #GstStructure.
|
|
|
|
*/
|
2004-03-12 19:35:40 +00:00
|
|
|
GstStructure *
|
2004-03-13 15:27:01 +00:00
|
|
|
gst_structure_copy (const GstStructure * structure)
|
2003-11-03 09:10:07 +00:00
|
|
|
{
|
|
|
|
GstStructure *new_structure;
|
|
|
|
GstStructureField *field;
|
2005-10-15 00:22:02 +00:00
|
|
|
guint i;
|
2003-11-03 09:10:07 +00:00
|
|
|
|
2004-03-13 15:27:01 +00:00
|
|
|
g_return_val_if_fail (structure != NULL, NULL);
|
2003-11-03 09:10:07 +00:00
|
|
|
|
2004-08-04 12:39:12 +00:00
|
|
|
new_structure =
|
|
|
|
gst_structure_id_empty_new_with_size (structure->name,
|
|
|
|
structure->fields->len);
|
2003-11-03 09:10:07 +00:00
|
|
|
|
2004-03-13 15:27:01 +00:00
|
|
|
for (i = 0; i < structure->fields->len; i++) {
|
2003-11-03 09:10:07 +00:00
|
|
|
GstStructureField new_field = { 0 };
|
|
|
|
|
2004-03-13 15:27:01 +00:00
|
|
|
field = GST_STRUCTURE_FIELD (structure, i);
|
2003-11-03 09:10:07 +00:00
|
|
|
|
|
|
|
new_field.name = field->name;
|
2003-12-22 07:00:25 +00:00
|
|
|
gst_value_init_and_copy (&new_field.value, &field->value);
|
2004-03-13 15:27:01 +00:00
|
|
|
g_array_append_val (new_structure->fields, new_field);
|
2003-11-03 09:10:07 +00:00
|
|
|
}
|
|
|
|
|
2003-12-30 04:59:48 +00:00
|
|
|
return new_structure;
|
2003-11-03 09:10:07 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2005-10-15 15:30:24 +00:00
|
|
|
* gst_structure_free:
|
2003-11-03 09:10:07 +00:00
|
|
|
* @structure: the #GstStructure to free
|
|
|
|
*
|
2005-03-07 18:27:42 +00:00
|
|
|
* Frees a #GstStructure and all its fields and values. The structure must not
|
2005-04-21 09:33:31 +00:00
|
|
|
* have a parent when this function is called.
|
2003-11-03 09:10:07 +00:00
|
|
|
*/
|
2004-03-12 19:35:40 +00:00
|
|
|
void
|
2004-03-13 15:27:01 +00:00
|
|
|
gst_structure_free (GstStructure * structure)
|
2003-11-03 09:10:07 +00:00
|
|
|
{
|
|
|
|
GstStructureField *field;
|
2005-10-15 00:22:02 +00:00
|
|
|
guint i;
|
2003-11-03 09:10:07 +00:00
|
|
|
|
2004-03-13 15:27:01 +00:00
|
|
|
g_return_if_fail (structure != NULL);
|
2005-03-07 18:27:42 +00:00
|
|
|
g_return_if_fail (structure->parent_refcount == NULL);
|
2003-11-03 09:10:07 +00:00
|
|
|
|
2004-03-13 15:27:01 +00:00
|
|
|
for (i = 0; i < structure->fields->len; i++) {
|
|
|
|
field = GST_STRUCTURE_FIELD (structure, i);
|
2003-11-03 09:10:07 +00:00
|
|
|
|
2004-03-13 15:27:01 +00:00
|
|
|
if (G_IS_VALUE (&field->value)) {
|
|
|
|
g_value_unset (&field->value);
|
2003-11-03 09:10:07 +00:00
|
|
|
}
|
|
|
|
}
|
2004-04-02 23:14:42 +00:00
|
|
|
g_array_free (structure->fields, TRUE);
|
2003-12-22 01:39:35 +00:00
|
|
|
#ifdef USE_POISONING
|
2004-03-13 15:27:01 +00:00
|
|
|
memset (structure, 0xff, sizeof (GstStructure));
|
2003-12-22 01:39:35 +00:00
|
|
|
#endif
|
2008-04-01 13:55:20 +00:00
|
|
|
g_slice_free (GstStructure, structure);
|
2003-11-03 09:10:07 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* gst_structure_get_name:
|
|
|
|
* @structure: a #GstStructure
|
|
|
|
*
|
2005-11-09 15:10:32 +00:00
|
|
|
* Get the name of @structure as a string.
|
2003-11-03 09:10:07 +00:00
|
|
|
*
|
|
|
|
* Returns: the name of the structure.
|
|
|
|
*/
|
2004-03-12 19:35:40 +00:00
|
|
|
const gchar *
|
2004-03-13 15:27:01 +00:00
|
|
|
gst_structure_get_name (const GstStructure * structure)
|
2003-11-03 09:10:07 +00:00
|
|
|
{
|
2004-03-13 15:27:01 +00:00
|
|
|
g_return_val_if_fail (structure != NULL, NULL);
|
2003-11-03 09:10:07 +00:00
|
|
|
|
2004-03-13 15:27:01 +00:00
|
|
|
return g_quark_to_string (structure->name);
|
2003-11-03 09:10:07 +00:00
|
|
|
}
|
|
|
|
|
gst/gstcaps.c: check for ANY caps before appending/unioning
Original commit message from CVS:
* gst/gstcaps.c: (gst_caps_append), (gst_caps_union):
check for ANY caps before appending/unioning
* gst/gstcaps.c: (gst_caps_is_subset),
(gst_caps_is_equal), (gst_caps_structure_subtract_field),
(gst_caps_structure_subtract), (gst_caps_subtract):
* gst/gstcaps.h:
add gst_caps_is_equal, gst_caps_is_subset and gst_caps_subtract to
the API. deprecate gst_caps_is_equal_fixed
* gst/gstpad.c: (gst_pad_try_set_caps):
* gst/gstqueue.c: (gst_queue_link):
s/gst_caps_is_equal_fixed/gst_caps_is_equal/
* gst/gststructure.c: (gst_structure_get_name_id):
* gst/gststructure.h:
add function gst_structure_get_name_id
* gst/gstvalue.c: (gst_value_subtract_int_int_range),
(gst_value_create_new_range), (gst_value_subtract_int_range_int),
(gst_value_subtract_int_range_int_range),
(gst_value_subtract_double_double_range),
(gst_value_subtract_double_range_double),
(gst_value_subtract_double_range_double_range),
(gst_value_subtract_from_list), (gst_value_subtract_list),
(gst_value_can_intersect), (gst_value_subtract),
(gst_value_can_subtract), (gst_value_register_subtract_func),
(_gst_value_initialize):
* gst/gstvalue.h:
add support for subtracting values from each other. Note that
subtracting means subtracting as in set theory. Required for caps
stuff above.
* testsuite/caps/.cvsignore:
* testsuite/caps/Makefile.am:
* testsuite/caps/erathostenes.c: (erathostenes), (main):
* testsuite/caps/sets.c: (check_caps), (main):
* testsuite/caps/subtract.c: (check_caps), (main):
add tests for subtraction and equality code.
2004-04-21 03:25:13 +00:00
|
|
|
/**
|
2005-07-31 11:59:33 +00:00
|
|
|
* gst_structure_has_name:
|
|
|
|
* @structure: a #GstStructure
|
|
|
|
* @name: structure name to check for
|
|
|
|
*
|
2005-10-20 21:08:47 +00:00
|
|
|
* Checks if the structure has the given name
|
|
|
|
*
|
2005-07-31 11:59:33 +00:00
|
|
|
* Returns: TRUE if @name matches the name of the structure.
|
|
|
|
*/
|
|
|
|
gboolean
|
|
|
|
gst_structure_has_name (const GstStructure * structure, const gchar * name)
|
|
|
|
{
|
|
|
|
const gchar *structure_name;
|
|
|
|
|
|
|
|
g_return_val_if_fail (structure != NULL, FALSE);
|
|
|
|
g_return_val_if_fail (name != NULL, FALSE);
|
|
|
|
|
2007-10-16 13:58:43 +00:00
|
|
|
/* getting the string is cheap and comparing short strings is too
|
|
|
|
* should be faster than getting the quark for name and comparing the quarks
|
|
|
|
*/
|
2005-07-31 11:59:33 +00:00
|
|
|
structure_name = g_quark_to_string (structure->name);
|
|
|
|
|
|
|
|
return (structure_name && strcmp (structure_name, name) == 0);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* gst_structure_get_name_id:
|
gst/gstcaps.c: check for ANY caps before appending/unioning
Original commit message from CVS:
* gst/gstcaps.c: (gst_caps_append), (gst_caps_union):
check for ANY caps before appending/unioning
* gst/gstcaps.c: (gst_caps_is_subset),
(gst_caps_is_equal), (gst_caps_structure_subtract_field),
(gst_caps_structure_subtract), (gst_caps_subtract):
* gst/gstcaps.h:
add gst_caps_is_equal, gst_caps_is_subset and gst_caps_subtract to
the API. deprecate gst_caps_is_equal_fixed
* gst/gstpad.c: (gst_pad_try_set_caps):
* gst/gstqueue.c: (gst_queue_link):
s/gst_caps_is_equal_fixed/gst_caps_is_equal/
* gst/gststructure.c: (gst_structure_get_name_id):
* gst/gststructure.h:
add function gst_structure_get_name_id
* gst/gstvalue.c: (gst_value_subtract_int_int_range),
(gst_value_create_new_range), (gst_value_subtract_int_range_int),
(gst_value_subtract_int_range_int_range),
(gst_value_subtract_double_double_range),
(gst_value_subtract_double_range_double),
(gst_value_subtract_double_range_double_range),
(gst_value_subtract_from_list), (gst_value_subtract_list),
(gst_value_can_intersect), (gst_value_subtract),
(gst_value_can_subtract), (gst_value_register_subtract_func),
(_gst_value_initialize):
* gst/gstvalue.h:
add support for subtracting values from each other. Note that
subtracting means subtracting as in set theory. Required for caps
stuff above.
* testsuite/caps/.cvsignore:
* testsuite/caps/Makefile.am:
* testsuite/caps/erathostenes.c: (erathostenes), (main):
* testsuite/caps/sets.c: (check_caps), (main):
* testsuite/caps/subtract.c: (check_caps), (main):
add tests for subtraction and equality code.
2004-04-21 03:25:13 +00:00
|
|
|
* @structure: a #GstStructure
|
|
|
|
*
|
2005-11-09 15:10:32 +00:00
|
|
|
* Get the name of @structure as a GQuark.
|
gst/gstcaps.c: check for ANY caps before appending/unioning
Original commit message from CVS:
* gst/gstcaps.c: (gst_caps_append), (gst_caps_union):
check for ANY caps before appending/unioning
* gst/gstcaps.c: (gst_caps_is_subset),
(gst_caps_is_equal), (gst_caps_structure_subtract_field),
(gst_caps_structure_subtract), (gst_caps_subtract):
* gst/gstcaps.h:
add gst_caps_is_equal, gst_caps_is_subset and gst_caps_subtract to
the API. deprecate gst_caps_is_equal_fixed
* gst/gstpad.c: (gst_pad_try_set_caps):
* gst/gstqueue.c: (gst_queue_link):
s/gst_caps_is_equal_fixed/gst_caps_is_equal/
* gst/gststructure.c: (gst_structure_get_name_id):
* gst/gststructure.h:
add function gst_structure_get_name_id
* gst/gstvalue.c: (gst_value_subtract_int_int_range),
(gst_value_create_new_range), (gst_value_subtract_int_range_int),
(gst_value_subtract_int_range_int_range),
(gst_value_subtract_double_double_range),
(gst_value_subtract_double_range_double),
(gst_value_subtract_double_range_double_range),
(gst_value_subtract_from_list), (gst_value_subtract_list),
(gst_value_can_intersect), (gst_value_subtract),
(gst_value_can_subtract), (gst_value_register_subtract_func),
(_gst_value_initialize):
* gst/gstvalue.h:
add support for subtracting values from each other. Note that
subtracting means subtracting as in set theory. Required for caps
stuff above.
* testsuite/caps/.cvsignore:
* testsuite/caps/Makefile.am:
* testsuite/caps/erathostenes.c: (erathostenes), (main):
* testsuite/caps/sets.c: (check_caps), (main):
* testsuite/caps/subtract.c: (check_caps), (main):
add tests for subtraction and equality code.
2004-04-21 03:25:13 +00:00
|
|
|
*
|
|
|
|
* Returns: the quark representing the name of the structure.
|
|
|
|
*/
|
|
|
|
GQuark
|
|
|
|
gst_structure_get_name_id (const GstStructure * structure)
|
|
|
|
{
|
|
|
|
g_return_val_if_fail (structure != NULL, 0);
|
|
|
|
|
|
|
|
return structure->name;
|
|
|
|
}
|
|
|
|
|
2003-11-03 09:10:07 +00:00
|
|
|
/**
|
|
|
|
* gst_structure_set_name:
|
|
|
|
* @structure: a #GstStructure
|
|
|
|
* @name: the new name of the structure
|
|
|
|
*
|
2007-10-16 13:58:43 +00:00
|
|
|
* Sets the name of the structure to the given @name. The string
|
2007-10-24 13:00:58 +00:00
|
|
|
* provided is copied before being used. It must not be empty, start with a
|
|
|
|
* letter and can be followed by letters, numbers and any of "/-_.:".
|
2003-11-03 09:10:07 +00:00
|
|
|
*/
|
2004-03-12 19:35:40 +00:00
|
|
|
void
|
2004-03-13 15:27:01 +00:00
|
|
|
gst_structure_set_name (GstStructure * structure, const gchar * name)
|
2003-11-03 09:10:07 +00:00
|
|
|
{
|
2004-03-13 15:27:01 +00:00
|
|
|
g_return_if_fail (structure != NULL);
|
2005-03-07 18:27:42 +00:00
|
|
|
g_return_if_fail (IS_MUTABLE (structure));
|
2007-10-16 13:58:43 +00:00
|
|
|
g_return_if_fail (gst_structure_validate_name (name));
|
2003-11-03 09:10:07 +00:00
|
|
|
|
2004-03-13 15:27:01 +00:00
|
|
|
structure->name = g_quark_from_string (name);
|
2003-11-03 09:10:07 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* gst_structure_id_set_value:
|
|
|
|
* @structure: a #GstStructure
|
2004-01-30 19:06:13 +00:00
|
|
|
* @field: a #GQuark representing a field
|
2003-11-03 09:10:07 +00:00
|
|
|
* @value: the new value of the field
|
|
|
|
*
|
2005-11-09 15:10:32 +00:00
|
|
|
* Sets the field with the given GQuark @field to @value. If the field
|
2003-11-03 09:10:07 +00:00
|
|
|
* does not exist, it is created. If the field exists, the previous
|
2005-11-09 15:10:32 +00:00
|
|
|
* value is replaced and freed.
|
2003-11-03 09:10:07 +00:00
|
|
|
*/
|
2004-03-12 19:35:40 +00:00
|
|
|
void
|
2004-03-13 15:27:01 +00:00
|
|
|
gst_structure_id_set_value (GstStructure * structure,
|
|
|
|
GQuark field, const GValue * value)
|
2003-11-03 09:10:07 +00:00
|
|
|
{
|
2004-03-13 15:27:01 +00:00
|
|
|
GstStructureField gsfield = { 0, {0,} };
|
2003-11-03 09:10:07 +00:00
|
|
|
|
2004-03-13 15:27:01 +00:00
|
|
|
g_return_if_fail (structure != NULL);
|
|
|
|
g_return_if_fail (G_IS_VALUE (value));
|
2005-03-07 18:27:42 +00:00
|
|
|
g_return_if_fail (IS_MUTABLE (structure));
|
2003-11-03 09:10:07 +00:00
|
|
|
|
2006-03-21 14:24:41 +00:00
|
|
|
if (G_VALUE_HOLDS_STRING (value)) {
|
|
|
|
const gchar *s;
|
|
|
|
|
|
|
|
s = g_value_get_string (value);
|
2008-01-09 15:05:21 +00:00
|
|
|
if (G_UNLIKELY (s != NULL && !g_utf8_validate (s, -1, NULL))) {
|
2006-03-21 14:24:41 +00:00
|
|
|
g_warning ("Trying to set string field '%s' on structure, but string is "
|
|
|
|
"not valid UTF-8. Please file a bug.", g_quark_to_string (field));
|
2006-10-26 08:49:52 +00:00
|
|
|
return;
|
2006-03-21 14:24:41 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2004-01-30 19:11:50 +00:00
|
|
|
gsfield.name = field;
|
|
|
|
gst_value_init_and_copy (&gsfield.value, value);
|
2003-11-03 09:10:07 +00:00
|
|
|
|
2004-03-13 15:27:01 +00:00
|
|
|
gst_structure_set_field (structure, &gsfield);
|
2003-11-03 09:10:07 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* gst_structure_set_value:
|
|
|
|
* @structure: a #GstStructure
|
2004-01-30 19:06:13 +00:00
|
|
|
* @fieldname: the name of the field to set
|
2003-11-03 09:10:07 +00:00
|
|
|
* @value: the new value of the field
|
|
|
|
*
|
2005-11-09 15:10:32 +00:00
|
|
|
* Sets the field with the given name @field to @value. If the field
|
2003-11-03 09:10:07 +00:00
|
|
|
* does not exist, it is created. If the field exists, the previous
|
2005-11-09 15:10:32 +00:00
|
|
|
* value is replaced and freed.
|
2003-11-03 09:10:07 +00:00
|
|
|
*/
|
2004-03-12 19:35:40 +00:00
|
|
|
void
|
2004-03-13 15:27:01 +00:00
|
|
|
gst_structure_set_value (GstStructure * structure,
|
|
|
|
const gchar * fieldname, const GValue * value)
|
2003-11-03 09:10:07 +00:00
|
|
|
{
|
2004-03-13 15:27:01 +00:00
|
|
|
g_return_if_fail (structure != NULL);
|
|
|
|
g_return_if_fail (fieldname != NULL);
|
|
|
|
g_return_if_fail (G_IS_VALUE (value));
|
2005-03-07 18:27:42 +00:00
|
|
|
g_return_if_fail (IS_MUTABLE (structure));
|
2003-11-03 09:10:07 +00:00
|
|
|
|
2004-03-13 15:27:01 +00:00
|
|
|
gst_structure_id_set_value (structure, g_quark_from_string (fieldname),
|
|
|
|
value);
|
2003-11-03 09:10:07 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* gst_structure_set:
|
|
|
|
* @structure: a #GstStructure
|
2004-01-30 19:06:13 +00:00
|
|
|
* @fieldname: the name of the field to set
|
2003-11-03 09:10:07 +00:00
|
|
|
* @...: variable arguments
|
|
|
|
*
|
|
|
|
* Parses the variable arguments and sets fields accordingly.
|
|
|
|
* Variable arguments should be in the form field name, field type
|
2005-11-09 15:10:32 +00:00
|
|
|
* (as a GType), value(s). The last variable argument should be NULL.
|
2003-11-03 09:10:07 +00:00
|
|
|
*/
|
2004-03-12 19:35:40 +00:00
|
|
|
void
|
2004-03-13 15:27:01 +00:00
|
|
|
gst_structure_set (GstStructure * structure, const gchar * field, ...)
|
2003-11-03 09:10:07 +00:00
|
|
|
{
|
|
|
|
va_list varargs;
|
|
|
|
|
2004-03-13 15:27:01 +00:00
|
|
|
g_return_if_fail (structure != NULL);
|
2003-11-03 09:10:07 +00:00
|
|
|
|
2004-03-13 15:27:01 +00:00
|
|
|
va_start (varargs, field);
|
2003-11-03 09:10:07 +00:00
|
|
|
|
2004-03-13 15:27:01 +00:00
|
|
|
gst_structure_set_valist (structure, field, varargs);
|
2003-11-03 09:10:07 +00:00
|
|
|
|
2004-03-13 15:27:01 +00:00
|
|
|
va_end (varargs);
|
2003-11-03 09:10:07 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2003-12-22 01:39:35 +00:00
|
|
|
* gst_structure_set_valist:
|
2003-11-03 09:10:07 +00:00
|
|
|
* @structure: a #GstStructure
|
2004-01-30 19:06:13 +00:00
|
|
|
* @fieldname: the name of the field to set
|
2003-11-03 09:10:07 +00:00
|
|
|
* @varargs: variable arguments
|
|
|
|
*
|
2006-01-27 22:34:51 +00:00
|
|
|
* va_list form of gst_structure_set().
|
2003-11-03 09:10:07 +00:00
|
|
|
*/
|
2004-03-12 19:35:40 +00:00
|
|
|
void
|
2004-03-13 15:27:01 +00:00
|
|
|
gst_structure_set_valist (GstStructure * structure,
|
|
|
|
const gchar * fieldname, va_list varargs)
|
2003-11-03 09:10:07 +00:00
|
|
|
{
|
2005-05-09 06:21:10 +00:00
|
|
|
gchar *err = NULL;
|
2003-11-03 09:10:07 +00:00
|
|
|
GType type;
|
|
|
|
|
2004-03-13 15:27:01 +00:00
|
|
|
g_return_if_fail (structure != NULL);
|
2005-03-07 18:27:42 +00:00
|
|
|
g_return_if_fail (IS_MUTABLE (structure));
|
2003-11-03 09:10:07 +00:00
|
|
|
|
2004-03-13 15:27:01 +00:00
|
|
|
while (fieldname) {
|
2003-11-03 09:10:07 +00:00
|
|
|
GstStructureField field = { 0 };
|
|
|
|
|
2004-03-13 15:27:01 +00:00
|
|
|
field.name = g_quark_from_string (fieldname);
|
2003-11-03 09:10:07 +00:00
|
|
|
|
2004-03-13 15:27:01 +00:00
|
|
|
type = va_arg (varargs, GType);
|
Add GST_TYPE_DATE, a boxed type that wraps GDate, and the usual bunch of utility functions along with a hack that che...
Original commit message from CVS:
* docs/gst/gstreamer-sections.txt:
* gst/gststructure.c: (gst_structure_set_valist),
(gst_structure_get_date):
* gst/gststructure.h:
* gst/gstvalue.c: (gst_value_set_date), (gst_value_get_date),
(gst_date_copy), (gst_value_compare_date),
(gst_value_serialize_date), (gst_value_deserialize_date),
(gst_value_transform_date_string),
(gst_value_transform_string_date), (_gst_value_initialize):
* gst/gstvalue.h:
Add GST_TYPE_DATE, a boxed type that wraps GDate, and the usual
bunch of utility functions along with a hack that checks that
developers don't accidentally use G_TYPE_DATE where GST_TYPE_DATE
is required. Part of the grand scheme in #170777.
2005-09-22 15:08:02 +00:00
|
|
|
|
|
|
|
if (type == G_TYPE_DATE) {
|
|
|
|
g_warning ("Don't use G_TYPE_DATE, use GST_TYPE_DATE instead\n");
|
|
|
|
type = GST_TYPE_DATE;
|
|
|
|
}
|
|
|
|
|
2005-05-09 06:21:10 +00:00
|
|
|
g_value_init (&field.value, type);
|
|
|
|
G_VALUE_COLLECT (&field.value, varargs, 0, &err);
|
|
|
|
if (err) {
|
|
|
|
g_critical ("%s", err);
|
|
|
|
return;
|
2003-11-03 09:10:07 +00:00
|
|
|
}
|
2004-03-13 15:27:01 +00:00
|
|
|
gst_structure_set_field (structure, &field);
|
2003-11-03 09:10:07 +00:00
|
|
|
|
|
|
|
fieldname = va_arg (varargs, gchar *);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
gst/gststructure.*: Add API for setting values into structures without performing a quark lookup, if the appropriate ...
Original commit message from CVS:
* gst/gststructure.c: (gst_structure_id_set),
(gst_structure_id_set_valist):
* gst/gststructure.h:
Add API for setting values into structures without performing
a quark lookup, if the appropriate quark is already known.
API: gst_structure_id_set
API: gst_structure_id_set_valist
* gst/parse/grammar.y:
* gst/parse/parse.l:
Remove some dead code shown by the coverage information.
Don't throw a critical g_warning when encountering a syntax error,
just warn and let the normal error path handle it.
* plugins/elements/gstelements.c:
Bump the rank of filesink up to PRIMARY so that it is preferred over
gnomevfssink for file:// sink uri's
* tests/check/pipelines/parse-launch.c: (expected_fail_pipe),
(GST_START_TEST), (run_delayed_test),
(gst_parse_test_element_base_init),
(gst_parse_test_element_class_init), (gst_parse_test_element_init),
(gst_parse_test_element_change_state),
(gst_register_parse_element), (parse_suite):
Beef up the tests for parse syntax to check that more error cases
fail as they are supposed to. Increases the test coverage a bit.
2006-07-26 17:04:45 +00:00
|
|
|
/**
|
|
|
|
* gst_structure_id_set:
|
|
|
|
* @structure: a #GstStructure
|
|
|
|
* @fieldname: the GQuark for the name of the field to set
|
|
|
|
* @...: variable arguments
|
|
|
|
*
|
|
|
|
* Identical to gst_structure_set, except that field names are
|
|
|
|
* passed using the GQuark for the field name. This allows more efficient
|
|
|
|
* setting of the structure if the caller already knows the associated
|
|
|
|
* quark values.
|
|
|
|
* The last variable argument must be NULL.
|
2006-09-14 20:08:14 +00:00
|
|
|
*
|
|
|
|
* Since: 0.10.10
|
gst/gststructure.*: Add API for setting values into structures without performing a quark lookup, if the appropriate ...
Original commit message from CVS:
* gst/gststructure.c: (gst_structure_id_set),
(gst_structure_id_set_valist):
* gst/gststructure.h:
Add API for setting values into structures without performing
a quark lookup, if the appropriate quark is already known.
API: gst_structure_id_set
API: gst_structure_id_set_valist
* gst/parse/grammar.y:
* gst/parse/parse.l:
Remove some dead code shown by the coverage information.
Don't throw a critical g_warning when encountering a syntax error,
just warn and let the normal error path handle it.
* plugins/elements/gstelements.c:
Bump the rank of filesink up to PRIMARY so that it is preferred over
gnomevfssink for file:// sink uri's
* tests/check/pipelines/parse-launch.c: (expected_fail_pipe),
(GST_START_TEST), (run_delayed_test),
(gst_parse_test_element_base_init),
(gst_parse_test_element_class_init), (gst_parse_test_element_init),
(gst_parse_test_element_change_state),
(gst_register_parse_element), (parse_suite):
Beef up the tests for parse syntax to check that more error cases
fail as they are supposed to. Increases the test coverage a bit.
2006-07-26 17:04:45 +00:00
|
|
|
*/
|
|
|
|
void
|
|
|
|
gst_structure_id_set (GstStructure * structure, GQuark field, ...)
|
|
|
|
{
|
|
|
|
va_list varargs;
|
|
|
|
|
|
|
|
g_return_if_fail (structure != NULL);
|
|
|
|
|
|
|
|
va_start (varargs, field);
|
|
|
|
gst_structure_id_set_valist (structure, field, varargs);
|
|
|
|
va_end (varargs);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* gst_structure_id_set_valist:
|
|
|
|
* @structure: a #GstStructure
|
|
|
|
* @fieldname: the name of the field to set
|
|
|
|
* @varargs: variable arguments
|
|
|
|
*
|
|
|
|
* va_list form of gst_structure_id_set().
|
2006-09-14 20:08:14 +00:00
|
|
|
*
|
|
|
|
* Since: 0.10.10
|
gst/gststructure.*: Add API for setting values into structures without performing a quark lookup, if the appropriate ...
Original commit message from CVS:
* gst/gststructure.c: (gst_structure_id_set),
(gst_structure_id_set_valist):
* gst/gststructure.h:
Add API for setting values into structures without performing
a quark lookup, if the appropriate quark is already known.
API: gst_structure_id_set
API: gst_structure_id_set_valist
* gst/parse/grammar.y:
* gst/parse/parse.l:
Remove some dead code shown by the coverage information.
Don't throw a critical g_warning when encountering a syntax error,
just warn and let the normal error path handle it.
* plugins/elements/gstelements.c:
Bump the rank of filesink up to PRIMARY so that it is preferred over
gnomevfssink for file:// sink uri's
* tests/check/pipelines/parse-launch.c: (expected_fail_pipe),
(GST_START_TEST), (run_delayed_test),
(gst_parse_test_element_base_init),
(gst_parse_test_element_class_init), (gst_parse_test_element_init),
(gst_parse_test_element_change_state),
(gst_register_parse_element), (parse_suite):
Beef up the tests for parse syntax to check that more error cases
fail as they are supposed to. Increases the test coverage a bit.
2006-07-26 17:04:45 +00:00
|
|
|
*/
|
|
|
|
void
|
|
|
|
gst_structure_id_set_valist (GstStructure * structure,
|
|
|
|
GQuark fieldname, va_list varargs)
|
|
|
|
{
|
|
|
|
gchar *err = NULL;
|
|
|
|
GType type;
|
|
|
|
|
|
|
|
g_return_if_fail (structure != NULL);
|
|
|
|
g_return_if_fail (IS_MUTABLE (structure));
|
|
|
|
|
|
|
|
while (fieldname) {
|
|
|
|
GstStructureField field = { 0 };
|
|
|
|
|
|
|
|
field.name = fieldname;
|
|
|
|
|
|
|
|
type = va_arg (varargs, GType);
|
|
|
|
|
|
|
|
if (type == G_TYPE_DATE) {
|
|
|
|
g_warning ("Don't use G_TYPE_DATE, use GST_TYPE_DATE instead\n");
|
|
|
|
type = GST_TYPE_DATE;
|
|
|
|
}
|
|
|
|
|
|
|
|
g_value_init (&field.value, type);
|
|
|
|
G_VALUE_COLLECT (&field.value, varargs, 0, &err);
|
|
|
|
if (err) {
|
|
|
|
g_critical ("%s", err);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
gst_structure_set_field (structure, &field);
|
|
|
|
|
|
|
|
fieldname = va_arg (varargs, GQuark);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2005-03-07 18:27:42 +00:00
|
|
|
/* If the structure currently contains a field with the same name, it is
|
|
|
|
* replaced with the provided field. Otherwise, the field is added to the
|
|
|
|
* structure. The field's value is not deeply copied.
|
2003-11-03 09:10:07 +00:00
|
|
|
*/
|
2004-03-12 19:35:40 +00:00
|
|
|
static void
|
2004-03-13 15:27:01 +00:00
|
|
|
gst_structure_set_field (GstStructure * structure, GstStructureField * field)
|
2003-11-03 09:10:07 +00:00
|
|
|
{
|
|
|
|
GstStructureField *f;
|
2005-10-15 00:22:02 +00:00
|
|
|
guint i;
|
2003-11-03 09:10:07 +00:00
|
|
|
|
2004-03-13 15:27:01 +00:00
|
|
|
for (i = 0; i < structure->fields->len; i++) {
|
|
|
|
f = GST_STRUCTURE_FIELD (structure, i);
|
2003-11-03 09:10:07 +00:00
|
|
|
|
2004-03-13 15:27:01 +00:00
|
|
|
if (f->name == field->name) {
|
|
|
|
g_value_unset (&f->value);
|
|
|
|
memcpy (f, field, sizeof (GstStructureField));
|
2003-11-03 09:10:07 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2004-03-13 15:27:01 +00:00
|
|
|
g_array_append_val (structure->fields, *field);
|
2003-11-03 09:10:07 +00:00
|
|
|
}
|
|
|
|
|
2005-03-07 18:27:42 +00:00
|
|
|
/* If there is no field with the given ID, NULL is returned.
|
2003-11-03 09:10:07 +00:00
|
|
|
*/
|
2004-03-12 19:35:40 +00:00
|
|
|
static GstStructureField *
|
2004-03-13 15:27:01 +00:00
|
|
|
gst_structure_id_get_field (const GstStructure * structure, GQuark field_id)
|
2003-11-03 09:10:07 +00:00
|
|
|
{
|
|
|
|
GstStructureField *field;
|
2005-10-15 00:22:02 +00:00
|
|
|
guint i;
|
2003-11-03 09:10:07 +00:00
|
|
|
|
2004-03-13 15:27:01 +00:00
|
|
|
g_return_val_if_fail (structure != NULL, NULL);
|
2003-11-03 09:10:07 +00:00
|
|
|
|
2004-03-13 15:27:01 +00:00
|
|
|
for (i = 0; i < structure->fields->len; i++) {
|
|
|
|
field = GST_STRUCTURE_FIELD (structure, i);
|
2003-11-03 09:10:07 +00:00
|
|
|
|
2004-03-13 15:27:01 +00:00
|
|
|
if (field->name == field_id)
|
|
|
|
return field;
|
2003-11-03 09:10:07 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2005-03-07 18:27:42 +00:00
|
|
|
/* If there is no field with the given ID, NULL is returned.
|
2003-11-03 09:10:07 +00:00
|
|
|
*/
|
2003-12-22 01:39:35 +00:00
|
|
|
static GstStructureField *
|
2004-03-13 15:27:01 +00:00
|
|
|
gst_structure_get_field (const GstStructure * structure,
|
|
|
|
const gchar * fieldname)
|
2003-11-03 09:10:07 +00:00
|
|
|
{
|
2004-03-13 15:27:01 +00:00
|
|
|
g_return_val_if_fail (structure != NULL, NULL);
|
|
|
|
g_return_val_if_fail (fieldname != NULL, NULL);
|
2003-11-03 09:10:07 +00:00
|
|
|
|
2004-03-13 15:27:01 +00:00
|
|
|
return gst_structure_id_get_field (structure,
|
|
|
|
g_quark_from_string (fieldname));
|
2003-11-03 09:10:07 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2003-11-04 05:54:24 +00:00
|
|
|
* gst_structure_get_value:
|
2003-11-03 09:10:07 +00:00
|
|
|
* @structure: a #GstStructure
|
|
|
|
* @fieldname: the name of the field to get
|
|
|
|
*
|
2005-11-09 15:10:32 +00:00
|
|
|
* Get the value of the field with name @fieldname.
|
2003-11-03 09:10:07 +00:00
|
|
|
*
|
|
|
|
* Returns: the #GValue corresponding to the field with the given name.
|
|
|
|
*/
|
|
|
|
const GValue *
|
2004-03-13 15:27:01 +00:00
|
|
|
gst_structure_get_value (const GstStructure * structure,
|
|
|
|
const gchar * fieldname)
|
2003-11-03 09:10:07 +00:00
|
|
|
{
|
|
|
|
GstStructureField *field;
|
|
|
|
|
2004-03-13 15:27:01 +00:00
|
|
|
g_return_val_if_fail (structure != NULL, NULL);
|
|
|
|
g_return_val_if_fail (fieldname != NULL, NULL);
|
2003-11-03 09:10:07 +00:00
|
|
|
|
2004-03-13 15:27:01 +00:00
|
|
|
field = gst_structure_get_field (structure, fieldname);
|
|
|
|
if (field == NULL)
|
|
|
|
return NULL;
|
2003-11-03 09:10:07 +00:00
|
|
|
|
|
|
|
return &field->value;
|
|
|
|
}
|
|
|
|
|
2003-12-22 01:39:35 +00:00
|
|
|
/**
|
|
|
|
* gst_structure_id_get_value:
|
|
|
|
* @structure: a #GstStructure
|
2004-01-30 19:06:13 +00:00
|
|
|
* @field: the #GQuark of the field to get
|
2003-12-22 01:39:35 +00:00
|
|
|
*
|
2005-11-09 15:10:32 +00:00
|
|
|
* Get the value of the field with GQuark @field.
|
2003-12-22 01:39:35 +00:00
|
|
|
*
|
2005-10-15 15:30:24 +00:00
|
|
|
* Returns: the #GValue corresponding to the field with the given name
|
2003-12-22 01:39:35 +00:00
|
|
|
* identifier.
|
|
|
|
*/
|
|
|
|
const GValue *
|
2004-03-13 15:27:01 +00:00
|
|
|
gst_structure_id_get_value (const GstStructure * structure, GQuark field)
|
2003-12-22 01:39:35 +00:00
|
|
|
{
|
2004-01-30 19:11:50 +00:00
|
|
|
GstStructureField *gsfield;
|
2003-12-22 01:39:35 +00:00
|
|
|
|
2004-03-13 15:27:01 +00:00
|
|
|
g_return_val_if_fail (structure != NULL, NULL);
|
2003-12-22 01:39:35 +00:00
|
|
|
|
2004-03-13 15:27:01 +00:00
|
|
|
gsfield = gst_structure_id_get_field (structure, field);
|
|
|
|
if (gsfield == NULL)
|
|
|
|
return NULL;
|
2003-12-22 01:39:35 +00:00
|
|
|
|
2004-01-30 19:11:50 +00:00
|
|
|
return &gsfield->value;
|
2003-12-22 01:39:35 +00:00
|
|
|
}
|
|
|
|
|
2003-11-03 09:10:07 +00:00
|
|
|
/**
|
|
|
|
* gst_structure_remove_field:
|
|
|
|
* @structure: a #GstStructure
|
|
|
|
* @fieldname: the name of the field to remove
|
|
|
|
*
|
|
|
|
* Removes the field with the given name. If the field with the given
|
|
|
|
* name does not exist, the structure is unchanged.
|
|
|
|
*/
|
|
|
|
void
|
2004-03-13 15:27:01 +00:00
|
|
|
gst_structure_remove_field (GstStructure * structure, const gchar * fieldname)
|
2003-11-03 09:10:07 +00:00
|
|
|
{
|
|
|
|
GstStructureField *field;
|
|
|
|
GQuark id;
|
2005-10-15 00:22:02 +00:00
|
|
|
guint i;
|
2003-11-03 09:10:07 +00:00
|
|
|
|
2004-03-13 15:27:01 +00:00
|
|
|
g_return_if_fail (structure != NULL);
|
|
|
|
g_return_if_fail (fieldname != NULL);
|
2005-03-07 18:27:42 +00:00
|
|
|
g_return_if_fail (IS_MUTABLE (structure));
|
2003-11-03 09:10:07 +00:00
|
|
|
|
2004-03-13 15:27:01 +00:00
|
|
|
id = g_quark_from_string (fieldname);
|
2003-11-03 09:10:07 +00:00
|
|
|
|
2004-03-13 15:27:01 +00:00
|
|
|
for (i = 0; i < structure->fields->len; i++) {
|
|
|
|
field = GST_STRUCTURE_FIELD (structure, i);
|
2003-11-03 09:10:07 +00:00
|
|
|
|
2004-03-13 15:27:01 +00:00
|
|
|
if (field->name == id) {
|
|
|
|
if (G_IS_VALUE (&field->value)) {
|
2004-03-15 19:27:17 +00:00
|
|
|
g_value_unset (&field->value);
|
2003-11-03 09:10:07 +00:00
|
|
|
}
|
2004-03-13 15:27:01 +00:00
|
|
|
structure->fields = g_array_remove_index (structure->fields, i);
|
2003-11-03 09:10:07 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2004-01-29 02:24:52 +00:00
|
|
|
/**
|
|
|
|
* gst_structure_remove_fields:
|
|
|
|
* @structure: a #GstStructure
|
|
|
|
* @fieldname: the name of the field to remove
|
|
|
|
* @...: NULL-terminated list of more fieldnames to remove
|
|
|
|
*
|
2005-11-09 15:10:32 +00:00
|
|
|
* Removes the fields with the given names. If a field does not exist, the
|
2004-01-29 02:24:52 +00:00
|
|
|
* argument is ignored.
|
|
|
|
*/
|
2004-03-13 15:27:01 +00:00
|
|
|
void
|
|
|
|
gst_structure_remove_fields (GstStructure * structure,
|
|
|
|
const gchar * fieldname, ...)
|
2004-01-29 02:24:52 +00:00
|
|
|
{
|
|
|
|
va_list varargs;
|
|
|
|
|
|
|
|
g_return_if_fail (structure != NULL);
|
|
|
|
g_return_if_fail (fieldname != NULL);
|
2005-03-07 18:27:42 +00:00
|
|
|
/* mutability checked in remove_field */
|
2004-01-29 02:24:52 +00:00
|
|
|
|
2004-03-13 15:27:01 +00:00
|
|
|
va_start (varargs, fieldname);
|
2004-01-29 02:24:52 +00:00
|
|
|
|
|
|
|
gst_structure_remove_fields_valist (structure, fieldname, varargs);
|
|
|
|
|
2004-03-13 15:27:01 +00:00
|
|
|
va_end (varargs);
|
2004-01-29 02:24:52 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* gst_structure_remove_fields_valist:
|
|
|
|
* @structure: a #GstStructure
|
|
|
|
* @fieldname: the name of the field to remove
|
|
|
|
* @varargs: NULL-terminated list of more fieldnames to remove
|
|
|
|
*
|
2006-01-27 22:34:51 +00:00
|
|
|
* va_list form of gst_structure_remove_fields().
|
2004-01-29 02:24:52 +00:00
|
|
|
*/
|
2004-03-13 15:27:01 +00:00
|
|
|
void
|
|
|
|
gst_structure_remove_fields_valist (GstStructure * structure,
|
|
|
|
const gchar * fieldname, va_list varargs)
|
2004-01-29 02:24:52 +00:00
|
|
|
{
|
|
|
|
gchar *field = (gchar *) fieldname;
|
2004-03-13 15:27:01 +00:00
|
|
|
|
2004-01-29 02:24:52 +00:00
|
|
|
g_return_if_fail (structure != NULL);
|
|
|
|
g_return_if_fail (fieldname != NULL);
|
2005-03-07 18:27:42 +00:00
|
|
|
/* mutability checked in remove_field */
|
2004-01-29 02:24:52 +00:00
|
|
|
|
|
|
|
while (field) {
|
|
|
|
gst_structure_remove_field (structure, field);
|
2004-03-13 15:27:01 +00:00
|
|
|
field = va_arg (varargs, char *);
|
2004-01-29 02:24:52 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2003-11-24 02:09:23 +00:00
|
|
|
/**
|
|
|
|
* gst_structure_remove_all_fields:
|
|
|
|
* @structure: a #GstStructure
|
|
|
|
*
|
2005-10-15 15:30:24 +00:00
|
|
|
* Removes all fields in a GstStructure.
|
2003-11-24 02:09:23 +00:00
|
|
|
*/
|
|
|
|
void
|
2004-03-13 15:27:01 +00:00
|
|
|
gst_structure_remove_all_fields (GstStructure * structure)
|
2003-11-24 02:09:23 +00:00
|
|
|
{
|
|
|
|
GstStructureField *field;
|
|
|
|
int i;
|
|
|
|
|
2004-03-13 15:27:01 +00:00
|
|
|
g_return_if_fail (structure != NULL);
|
2005-03-07 18:27:42 +00:00
|
|
|
g_return_if_fail (IS_MUTABLE (structure));
|
2003-11-24 02:09:23 +00:00
|
|
|
|
2004-03-13 15:27:01 +00:00
|
|
|
for (i = structure->fields->len - 1; i >= 0; i--) {
|
|
|
|
field = GST_STRUCTURE_FIELD (structure, i);
|
2003-11-24 02:09:23 +00:00
|
|
|
|
|
|
|
if (G_IS_VALUE (&field->value)) {
|
2004-03-13 15:27:01 +00:00
|
|
|
g_value_unset (&field->value);
|
2003-11-24 02:09:23 +00:00
|
|
|
}
|
|
|
|
structure->fields = g_array_remove_index (structure->fields, i);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2003-11-03 09:10:07 +00:00
|
|
|
/**
|
|
|
|
* gst_structure_get_field_type:
|
|
|
|
* @structure: a #GstStructure
|
|
|
|
* @fieldname: the name of the field
|
|
|
|
*
|
|
|
|
* Finds the field with the given name, and returns the type of the
|
2003-11-29 06:31:10 +00:00
|
|
|
* value it contains. If the field is not found, G_TYPE_INVALID is
|
2003-11-03 09:10:07 +00:00
|
|
|
* returned.
|
|
|
|
*
|
|
|
|
* Returns: the #GValue of the field
|
|
|
|
*/
|
|
|
|
GType
|
2004-03-13 15:27:01 +00:00
|
|
|
gst_structure_get_field_type (const GstStructure * structure,
|
|
|
|
const gchar * fieldname)
|
2003-11-03 09:10:07 +00:00
|
|
|
{
|
|
|
|
GstStructureField *field;
|
|
|
|
|
2004-03-13 15:27:01 +00:00
|
|
|
g_return_val_if_fail (structure != NULL, G_TYPE_INVALID);
|
|
|
|
g_return_val_if_fail (fieldname != NULL, G_TYPE_INVALID);
|
2003-11-03 09:10:07 +00:00
|
|
|
|
2004-03-13 15:27:01 +00:00
|
|
|
field = gst_structure_get_field (structure, fieldname);
|
|
|
|
if (field == NULL)
|
|
|
|
return G_TYPE_INVALID;
|
2003-11-03 09:10:07 +00:00
|
|
|
|
2004-03-13 15:27:01 +00:00
|
|
|
return G_VALUE_TYPE (&field->value);
|
2003-11-03 09:10:07 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* gst_structure_n_fields:
|
|
|
|
* @structure: a #GstStructure
|
|
|
|
*
|
2005-11-09 15:10:32 +00:00
|
|
|
* Get the number of fields in the structure.
|
2003-11-03 09:10:07 +00:00
|
|
|
*
|
|
|
|
* Returns: the number of fields in the structure
|
|
|
|
*/
|
|
|
|
gint
|
2004-03-13 15:27:01 +00:00
|
|
|
gst_structure_n_fields (const GstStructure * structure)
|
2003-11-03 09:10:07 +00:00
|
|
|
{
|
2004-03-13 15:27:01 +00:00
|
|
|
g_return_val_if_fail (structure != NULL, 0);
|
2003-11-03 09:10:07 +00:00
|
|
|
|
|
|
|
return structure->fields->len;
|
|
|
|
}
|
|
|
|
|
2005-06-22 19:22:34 +00:00
|
|
|
/**
|
|
|
|
* gst_structure_nth_field_name:
|
|
|
|
* @structure: a #GstStructure
|
2005-09-23 18:08:59 +00:00
|
|
|
* @index: the index to get the name of
|
2005-06-22 19:22:34 +00:00
|
|
|
*
|
2005-10-20 21:08:47 +00:00
|
|
|
* Get the name of the given field number, counting from 0 onwards.
|
|
|
|
*
|
|
|
|
* Returns: the name of the given field number
|
2005-06-22 19:22:34 +00:00
|
|
|
*/
|
|
|
|
const gchar *
|
|
|
|
gst_structure_nth_field_name (const GstStructure * structure, guint index)
|
|
|
|
{
|
|
|
|
GstStructureField *field;
|
|
|
|
|
2006-07-27 11:00:21 +00:00
|
|
|
g_return_val_if_fail (structure != NULL, NULL);
|
|
|
|
g_return_val_if_fail (index < structure->fields->len, NULL);
|
|
|
|
|
2005-06-22 19:22:34 +00:00
|
|
|
field = GST_STRUCTURE_FIELD (structure, index);
|
2006-07-27 11:00:21 +00:00
|
|
|
|
2005-06-22 19:22:34 +00:00
|
|
|
return g_quark_to_string (field->name);
|
|
|
|
}
|
|
|
|
|
2003-11-04 19:00:54 +00:00
|
|
|
/**
|
2003-12-22 01:39:35 +00:00
|
|
|
* gst_structure_foreach:
|
2003-11-04 19:00:54 +00:00
|
|
|
* @structure: a #GstStructure
|
|
|
|
* @func: a function to call for each field
|
|
|
|
* @user_data: private data
|
|
|
|
*
|
2005-03-07 18:27:42 +00:00
|
|
|
* Calls the provided function once for each field in the #GstStructure. The
|
|
|
|
* function must not modify the fields. Also see gst_structure_map_in_place().
|
2004-01-30 19:06:13 +00:00
|
|
|
*
|
|
|
|
* Returns: TRUE if the supplied function returns TRUE For each of the fields,
|
|
|
|
* FALSE otherwise.
|
2003-11-04 19:00:54 +00:00
|
|
|
*/
|
2003-12-22 01:39:35 +00:00
|
|
|
gboolean
|
2005-03-07 18:27:42 +00:00
|
|
|
gst_structure_foreach (const GstStructure * structure,
|
2004-03-13 15:27:01 +00:00
|
|
|
GstStructureForeachFunc func, gpointer user_data)
|
2003-11-04 19:00:54 +00:00
|
|
|
{
|
2005-10-15 00:22:02 +00:00
|
|
|
guint i;
|
2003-11-04 19:00:54 +00:00
|
|
|
GstStructureField *field;
|
2003-12-22 01:39:35 +00:00
|
|
|
gboolean ret;
|
2003-11-04 19:00:54 +00:00
|
|
|
|
2005-03-07 18:27:42 +00:00
|
|
|
g_return_val_if_fail (structure != NULL, FALSE);
|
2006-07-27 11:00:21 +00:00
|
|
|
g_return_val_if_fail (func != NULL, FALSE);
|
2005-03-07 18:27:42 +00:00
|
|
|
|
|
|
|
for (i = 0; i < structure->fields->len; i++) {
|
|
|
|
field = GST_STRUCTURE_FIELD (structure, i);
|
|
|
|
|
|
|
|
ret = func (field->name, &field->value, user_data);
|
|
|
|
if (!ret)
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* gst_structure_map_in_place:
|
|
|
|
* @structure: a #GstStructure
|
|
|
|
* @func: a function to call for each field
|
|
|
|
* @user_data: private data
|
|
|
|
*
|
|
|
|
* Calls the provided function once for each field in the #GstStructure. In
|
2007-01-09 15:38:58 +00:00
|
|
|
* contrast to gst_structure_foreach(), the function may modify but not delete the
|
|
|
|
* fields. The structure must be mutable.
|
2005-03-07 18:27:42 +00:00
|
|
|
*
|
|
|
|
* Returns: TRUE if the supplied function returns TRUE For each of the fields,
|
|
|
|
* FALSE otherwise.
|
|
|
|
*/
|
|
|
|
gboolean
|
|
|
|
gst_structure_map_in_place (GstStructure * structure,
|
|
|
|
GstStructureMapFunc func, gpointer user_data)
|
|
|
|
{
|
2005-10-15 00:22:02 +00:00
|
|
|
guint i;
|
2005-03-07 18:27:42 +00:00
|
|
|
GstStructureField *field;
|
|
|
|
gboolean ret;
|
|
|
|
|
|
|
|
g_return_val_if_fail (structure != NULL, FALSE);
|
|
|
|
g_return_val_if_fail (IS_MUTABLE (structure), FALSE);
|
2006-07-27 11:00:21 +00:00
|
|
|
g_return_val_if_fail (func != NULL, FALSE);
|
2005-03-07 18:27:42 +00:00
|
|
|
|
2004-03-13 15:27:01 +00:00
|
|
|
for (i = 0; i < structure->fields->len; i++) {
|
|
|
|
field = GST_STRUCTURE_FIELD (structure, i);
|
2003-11-04 19:00:54 +00:00
|
|
|
|
2003-12-22 01:39:35 +00:00
|
|
|
ret = func (field->name, &field->value, user_data);
|
2004-03-13 15:27:01 +00:00
|
|
|
if (!ret)
|
|
|
|
return FALSE;
|
2003-11-04 19:00:54 +00:00
|
|
|
}
|
2003-12-22 01:39:35 +00:00
|
|
|
|
|
|
|
return TRUE;
|
2003-11-04 19:00:54 +00:00
|
|
|
}
|
|
|
|
|
2003-11-03 09:10:07 +00:00
|
|
|
/**
|
|
|
|
* gst_structure_has_field:
|
|
|
|
* @structure: a #GstStructure
|
|
|
|
* @fieldname: the name of a field
|
|
|
|
*
|
2005-11-09 15:10:32 +00:00
|
|
|
* Check if @structure contains a field named @fieldname.
|
2003-11-03 09:10:07 +00:00
|
|
|
*
|
|
|
|
* Returns: TRUE if the structure contains a field with the given name
|
|
|
|
*/
|
|
|
|
gboolean
|
2004-03-13 15:27:01 +00:00
|
|
|
gst_structure_has_field (const GstStructure * structure,
|
|
|
|
const gchar * fieldname)
|
2003-11-03 09:10:07 +00:00
|
|
|
{
|
|
|
|
GstStructureField *field;
|
|
|
|
|
2004-03-13 15:27:01 +00:00
|
|
|
g_return_val_if_fail (structure != NULL, 0);
|
|
|
|
g_return_val_if_fail (fieldname != NULL, 0);
|
2003-11-03 09:10:07 +00:00
|
|
|
|
2004-03-13 15:27:01 +00:00
|
|
|
field = gst_structure_get_field (structure, fieldname);
|
2003-11-03 09:10:07 +00:00
|
|
|
|
|
|
|
return (field != NULL);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2004-01-30 19:06:13 +00:00
|
|
|
* gst_structure_has_field_typed:
|
2003-11-03 09:10:07 +00:00
|
|
|
* @structure: a #GstStructure
|
|
|
|
* @fieldname: the name of a field
|
|
|
|
* @type: the type of a value
|
|
|
|
*
|
2005-11-09 15:10:32 +00:00
|
|
|
* Check if @structure contains a field named @fieldname and with GType @type.
|
2003-11-03 09:10:07 +00:00
|
|
|
*
|
|
|
|
* Returns: TRUE if the structure contains a field with the given name and type
|
|
|
|
*/
|
|
|
|
gboolean
|
2004-03-13 15:27:01 +00:00
|
|
|
gst_structure_has_field_typed (const GstStructure * structure,
|
|
|
|
const gchar * fieldname, GType type)
|
2003-11-03 09:10:07 +00:00
|
|
|
{
|
|
|
|
GstStructureField *field;
|
|
|
|
|
2004-03-13 15:27:01 +00:00
|
|
|
g_return_val_if_fail (structure != NULL, 0);
|
|
|
|
g_return_val_if_fail (fieldname != NULL, 0);
|
2003-11-03 09:10:07 +00:00
|
|
|
|
2004-03-13 15:27:01 +00:00
|
|
|
field = gst_structure_get_field (structure, fieldname);
|
|
|
|
if (field == NULL)
|
|
|
|
return FALSE;
|
2003-11-03 09:10:07 +00:00
|
|
|
|
2004-03-13 15:27:01 +00:00
|
|
|
return (G_VALUE_TYPE (&field->value) == type);
|
2003-11-03 09:10:07 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/* utility functions */
|
|
|
|
|
|
|
|
/**
|
|
|
|
* gst_structure_get_boolean:
|
|
|
|
* @structure: a #GstStructure
|
|
|
|
* @fieldname: the name of a field
|
2004-01-30 19:06:13 +00:00
|
|
|
* @value: a pointer to a #gboolean to set
|
2003-11-03 09:10:07 +00:00
|
|
|
*
|
2004-01-30 19:06:13 +00:00
|
|
|
* Sets the boolean pointed to by @value corresponding to the value of the
|
2003-11-03 09:10:07 +00:00
|
|
|
* given field. Caller is responsible for making sure the field exists
|
|
|
|
* and has the correct type.
|
|
|
|
*
|
2005-11-09 15:10:32 +00:00
|
|
|
* Returns: TRUE if the value could be set correctly. If there was no field
|
2006-08-14 12:35:06 +00:00
|
|
|
* with @fieldname or the existing field did not contain a boolean, this
|
|
|
|
* function returns FALSE.
|
2003-11-03 09:10:07 +00:00
|
|
|
*/
|
|
|
|
gboolean
|
2004-03-13 15:27:01 +00:00
|
|
|
gst_structure_get_boolean (const GstStructure * structure,
|
|
|
|
const gchar * fieldname, gboolean * value)
|
2003-11-03 09:10:07 +00:00
|
|
|
{
|
|
|
|
GstStructureField *field;
|
|
|
|
|
2004-03-13 15:27:01 +00:00
|
|
|
g_return_val_if_fail (structure != NULL, FALSE);
|
|
|
|
g_return_val_if_fail (fieldname != NULL, FALSE);
|
2003-11-03 09:10:07 +00:00
|
|
|
|
2004-03-13 15:27:01 +00:00
|
|
|
field = gst_structure_get_field (structure, fieldname);
|
2003-11-03 09:10:07 +00:00
|
|
|
|
2004-03-13 15:27:01 +00:00
|
|
|
if (field == NULL)
|
|
|
|
return FALSE;
|
|
|
|
if (!G_VALUE_HOLDS_BOOLEAN (&field->value))
|
|
|
|
return FALSE;
|
2003-11-03 09:10:07 +00:00
|
|
|
|
2004-03-13 15:27:01 +00:00
|
|
|
*value = g_value_get_boolean (&field->value);
|
2003-11-03 09:10:07 +00:00
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* gst_structure_get_int:
|
|
|
|
* @structure: a #GstStructure
|
|
|
|
* @fieldname: the name of a field
|
2004-01-30 19:06:13 +00:00
|
|
|
* @value: a pointer to an int to set
|
2003-11-03 09:10:07 +00:00
|
|
|
*
|
2004-01-30 19:06:13 +00:00
|
|
|
* Sets the int pointed to by @value corresponding to the value of the
|
2003-11-03 09:10:07 +00:00
|
|
|
* given field. Caller is responsible for making sure the field exists
|
|
|
|
* and has the correct type.
|
|
|
|
*
|
2006-12-21 15:00:08 +00:00
|
|
|
* Returns: %TRUE if the value could be set correctly. If there was no field
|
2005-11-09 15:10:32 +00:00
|
|
|
* with @fieldname or the existing field did not contain an int, this function
|
2006-12-21 15:00:08 +00:00
|
|
|
* returns %FALSE.
|
2003-11-03 09:10:07 +00:00
|
|
|
*/
|
|
|
|
gboolean
|
2004-03-13 15:27:01 +00:00
|
|
|
gst_structure_get_int (const GstStructure * structure,
|
|
|
|
const gchar * fieldname, gint * value)
|
2003-11-03 09:10:07 +00:00
|
|
|
{
|
|
|
|
GstStructureField *field;
|
|
|
|
|
2004-03-13 15:27:01 +00:00
|
|
|
g_return_val_if_fail (structure != NULL, FALSE);
|
|
|
|
g_return_val_if_fail (fieldname != NULL, FALSE);
|
|
|
|
g_return_val_if_fail (value != NULL, FALSE);
|
2003-11-03 09:10:07 +00:00
|
|
|
|
2004-03-13 15:27:01 +00:00
|
|
|
field = gst_structure_get_field (structure, fieldname);
|
2003-11-03 09:10:07 +00:00
|
|
|
|
2004-03-13 15:27:01 +00:00
|
|
|
if (field == NULL)
|
|
|
|
return FALSE;
|
|
|
|
if (!G_VALUE_HOLDS_INT (&field->value))
|
|
|
|
return FALSE;
|
2003-11-03 09:10:07 +00:00
|
|
|
|
2004-03-13 15:27:01 +00:00
|
|
|
*value = g_value_get_int (&field->value);
|
2003-11-03 09:10:07 +00:00
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2007-08-12 16:40:59 +00:00
|
|
|
/**
|
|
|
|
* gst_structure_get_uint:
|
|
|
|
* @structure: a #GstStructure
|
|
|
|
* @fieldname: the name of a field
|
|
|
|
* @value: a pointer to a uint to set
|
|
|
|
*
|
|
|
|
* Sets the uint pointed to by @value corresponding to the value of the
|
|
|
|
* given field. Caller is responsible for making sure the field exists
|
|
|
|
* and has the correct type.
|
|
|
|
*
|
|
|
|
* Returns: %TRUE if the value could be set correctly. If there was no field
|
|
|
|
* with @fieldname or the existing field did not contain a uint, this function
|
|
|
|
* returns %FALSE.
|
2007-08-12 16:44:07 +00:00
|
|
|
*
|
|
|
|
* Since: 0.10.15
|
2007-08-12 16:40:59 +00:00
|
|
|
*/
|
|
|
|
gboolean
|
|
|
|
gst_structure_get_uint (const GstStructure * structure,
|
|
|
|
const gchar * fieldname, guint * value)
|
|
|
|
{
|
|
|
|
GstStructureField *field;
|
|
|
|
|
|
|
|
g_return_val_if_fail (structure != NULL, FALSE);
|
|
|
|
g_return_val_if_fail (fieldname != NULL, FALSE);
|
|
|
|
g_return_val_if_fail (value != NULL, FALSE);
|
|
|
|
|
|
|
|
field = gst_structure_get_field (structure, fieldname);
|
|
|
|
|
|
|
|
if (field == NULL)
|
|
|
|
return FALSE;
|
|
|
|
if (!G_VALUE_HOLDS_UINT (&field->value))
|
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
*value = g_value_get_uint (&field->value);
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2003-11-03 09:10:07 +00:00
|
|
|
/**
|
|
|
|
* gst_structure_get_fourcc:
|
|
|
|
* @structure: a #GstStructure
|
|
|
|
* @fieldname: the name of a field
|
2004-01-30 19:06:13 +00:00
|
|
|
* @value: a pointer to a #GstFourcc to set
|
2003-11-03 09:10:07 +00:00
|
|
|
*
|
2004-01-30 19:06:13 +00:00
|
|
|
* Sets the #GstFourcc pointed to by @value corresponding to the value of the
|
2003-11-03 09:10:07 +00:00
|
|
|
* given field. Caller is responsible for making sure the field exists
|
|
|
|
* and has the correct type.
|
|
|
|
*
|
2005-11-09 15:10:32 +00:00
|
|
|
* Returns: TRUE if the value could be set correctly. If there was no field
|
|
|
|
* with @fieldname or the existing field did not contain a fourcc, this function
|
|
|
|
* returns FALSE.
|
2003-11-03 09:10:07 +00:00
|
|
|
*/
|
|
|
|
gboolean
|
2004-03-13 15:27:01 +00:00
|
|
|
gst_structure_get_fourcc (const GstStructure * structure,
|
|
|
|
const gchar * fieldname, guint32 * value)
|
2003-11-03 09:10:07 +00:00
|
|
|
{
|
|
|
|
GstStructureField *field;
|
|
|
|
|
2004-03-13 15:27:01 +00:00
|
|
|
g_return_val_if_fail (structure != NULL, FALSE);
|
|
|
|
g_return_val_if_fail (fieldname != NULL, FALSE);
|
|
|
|
g_return_val_if_fail (value != NULL, FALSE);
|
2003-11-03 09:10:07 +00:00
|
|
|
|
2004-03-13 15:27:01 +00:00
|
|
|
field = gst_structure_get_field (structure, fieldname);
|
2003-11-03 09:10:07 +00:00
|
|
|
|
2004-03-13 15:27:01 +00:00
|
|
|
if (field == NULL)
|
|
|
|
return FALSE;
|
|
|
|
if (!GST_VALUE_HOLDS_FOURCC (&field->value))
|
|
|
|
return FALSE;
|
2003-11-03 09:10:07 +00:00
|
|
|
|
2003-12-22 01:39:35 +00:00
|
|
|
*value = gst_value_get_fourcc (&field->value);
|
2003-11-03 09:10:07 +00:00
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
Add GST_TYPE_DATE, a boxed type that wraps GDate, and the usual bunch of utility functions along with a hack that che...
Original commit message from CVS:
* docs/gst/gstreamer-sections.txt:
* gst/gststructure.c: (gst_structure_set_valist),
(gst_structure_get_date):
* gst/gststructure.h:
* gst/gstvalue.c: (gst_value_set_date), (gst_value_get_date),
(gst_date_copy), (gst_value_compare_date),
(gst_value_serialize_date), (gst_value_deserialize_date),
(gst_value_transform_date_string),
(gst_value_transform_string_date), (_gst_value_initialize):
* gst/gstvalue.h:
Add GST_TYPE_DATE, a boxed type that wraps GDate, and the usual
bunch of utility functions along with a hack that checks that
developers don't accidentally use G_TYPE_DATE where GST_TYPE_DATE
is required. Part of the grand scheme in #170777.
2005-09-22 15:08:02 +00:00
|
|
|
/**
|
|
|
|
* gst_structure_get_date:
|
|
|
|
* @structure: a #GstStructure
|
|
|
|
* @fieldname: the name of a field
|
|
|
|
* @value: a pointer to a #GDate to set
|
|
|
|
*
|
2005-09-23 17:46:06 +00:00
|
|
|
* Sets the date pointed to by @value corresponding to the date of the
|
Add GST_TYPE_DATE, a boxed type that wraps GDate, and the usual bunch of utility functions along with a hack that che...
Original commit message from CVS:
* docs/gst/gstreamer-sections.txt:
* gst/gststructure.c: (gst_structure_set_valist),
(gst_structure_get_date):
* gst/gststructure.h:
* gst/gstvalue.c: (gst_value_set_date), (gst_value_get_date),
(gst_date_copy), (gst_value_compare_date),
(gst_value_serialize_date), (gst_value_deserialize_date),
(gst_value_transform_date_string),
(gst_value_transform_string_date), (_gst_value_initialize):
* gst/gstvalue.h:
Add GST_TYPE_DATE, a boxed type that wraps GDate, and the usual
bunch of utility functions along with a hack that checks that
developers don't accidentally use G_TYPE_DATE where GST_TYPE_DATE
is required. Part of the grand scheme in #170777.
2005-09-22 15:08:02 +00:00
|
|
|
* given field. Caller is responsible for making sure the field exists
|
|
|
|
* and has the correct type.
|
|
|
|
*
|
2005-11-09 15:10:32 +00:00
|
|
|
* Returns: TRUE if the value could be set correctly. If there was no field
|
|
|
|
* with @fieldname or the existing field did not contain a data, this function
|
|
|
|
* returns FALSE.
|
Add GST_TYPE_DATE, a boxed type that wraps GDate, and the usual bunch of utility functions along with a hack that che...
Original commit message from CVS:
* docs/gst/gstreamer-sections.txt:
* gst/gststructure.c: (gst_structure_set_valist),
(gst_structure_get_date):
* gst/gststructure.h:
* gst/gstvalue.c: (gst_value_set_date), (gst_value_get_date),
(gst_date_copy), (gst_value_compare_date),
(gst_value_serialize_date), (gst_value_deserialize_date),
(gst_value_transform_date_string),
(gst_value_transform_string_date), (_gst_value_initialize):
* gst/gstvalue.h:
Add GST_TYPE_DATE, a boxed type that wraps GDate, and the usual
bunch of utility functions along with a hack that checks that
developers don't accidentally use G_TYPE_DATE where GST_TYPE_DATE
is required. Part of the grand scheme in #170777.
2005-09-22 15:08:02 +00:00
|
|
|
*/
|
|
|
|
gboolean
|
|
|
|
gst_structure_get_date (const GstStructure * structure, const gchar * fieldname,
|
2005-09-23 16:35:43 +00:00
|
|
|
GDate ** value)
|
Add GST_TYPE_DATE, a boxed type that wraps GDate, and the usual bunch of utility functions along with a hack that che...
Original commit message from CVS:
* docs/gst/gstreamer-sections.txt:
* gst/gststructure.c: (gst_structure_set_valist),
(gst_structure_get_date):
* gst/gststructure.h:
* gst/gstvalue.c: (gst_value_set_date), (gst_value_get_date),
(gst_date_copy), (gst_value_compare_date),
(gst_value_serialize_date), (gst_value_deserialize_date),
(gst_value_transform_date_string),
(gst_value_transform_string_date), (_gst_value_initialize):
* gst/gstvalue.h:
Add GST_TYPE_DATE, a boxed type that wraps GDate, and the usual
bunch of utility functions along with a hack that checks that
developers don't accidentally use G_TYPE_DATE where GST_TYPE_DATE
is required. Part of the grand scheme in #170777.
2005-09-22 15:08:02 +00:00
|
|
|
{
|
|
|
|
GstStructureField *field;
|
|
|
|
|
|
|
|
g_return_val_if_fail (structure != NULL, FALSE);
|
|
|
|
g_return_val_if_fail (fieldname != NULL, FALSE);
|
2005-09-23 16:35:43 +00:00
|
|
|
g_return_val_if_fail (value != NULL, FALSE);
|
Add GST_TYPE_DATE, a boxed type that wraps GDate, and the usual bunch of utility functions along with a hack that che...
Original commit message from CVS:
* docs/gst/gstreamer-sections.txt:
* gst/gststructure.c: (gst_structure_set_valist),
(gst_structure_get_date):
* gst/gststructure.h:
* gst/gstvalue.c: (gst_value_set_date), (gst_value_get_date),
(gst_date_copy), (gst_value_compare_date),
(gst_value_serialize_date), (gst_value_deserialize_date),
(gst_value_transform_date_string),
(gst_value_transform_string_date), (_gst_value_initialize):
* gst/gstvalue.h:
Add GST_TYPE_DATE, a boxed type that wraps GDate, and the usual
bunch of utility functions along with a hack that checks that
developers don't accidentally use G_TYPE_DATE where GST_TYPE_DATE
is required. Part of the grand scheme in #170777.
2005-09-22 15:08:02 +00:00
|
|
|
|
|
|
|
field = gst_structure_get_field (structure, fieldname);
|
|
|
|
|
|
|
|
if (field == NULL)
|
|
|
|
return FALSE;
|
|
|
|
if (!GST_VALUE_HOLDS_DATE (&field->value))
|
|
|
|
return FALSE;
|
|
|
|
|
2005-09-23 16:35:43 +00:00
|
|
|
*value = g_value_dup_boxed (&field->value);
|
Add GST_TYPE_DATE, a boxed type that wraps GDate, and the usual bunch of utility functions along with a hack that che...
Original commit message from CVS:
* docs/gst/gstreamer-sections.txt:
* gst/gststructure.c: (gst_structure_set_valist),
(gst_structure_get_date):
* gst/gststructure.h:
* gst/gstvalue.c: (gst_value_set_date), (gst_value_get_date),
(gst_date_copy), (gst_value_compare_date),
(gst_value_serialize_date), (gst_value_deserialize_date),
(gst_value_transform_date_string),
(gst_value_transform_string_date), (_gst_value_initialize):
* gst/gstvalue.h:
Add GST_TYPE_DATE, a boxed type that wraps GDate, and the usual
bunch of utility functions along with a hack that checks that
developers don't accidentally use G_TYPE_DATE where GST_TYPE_DATE
is required. Part of the grand scheme in #170777.
2005-09-22 15:08:02 +00:00
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2005-09-23 17:46:06 +00:00
|
|
|
/**
|
|
|
|
* gst_structure_get_clock_time:
|
|
|
|
* @structure: a #GstStructure
|
|
|
|
* @fieldname: the name of a field
|
|
|
|
* @value: a pointer to a #GstClockTime to set
|
|
|
|
*
|
|
|
|
* Sets the clock time pointed to by @value corresponding to the clock time
|
|
|
|
* of the given field. Caller is responsible for making sure the field exists
|
|
|
|
* and has the correct type.
|
|
|
|
*
|
2005-11-09 15:10:32 +00:00
|
|
|
* Returns: TRUE if the value could be set correctly. If there was no field
|
|
|
|
* with @fieldname or the existing field did not contain a #GstClockTime, this
|
|
|
|
* function returns FALSE.
|
2005-09-23 17:46:06 +00:00
|
|
|
*/
|
|
|
|
gboolean
|
|
|
|
gst_structure_get_clock_time (const GstStructure * structure,
|
|
|
|
const gchar * fieldname, GstClockTime * value)
|
|
|
|
{
|
|
|
|
GstStructureField *field;
|
|
|
|
|
|
|
|
g_return_val_if_fail (structure != NULL, FALSE);
|
|
|
|
g_return_val_if_fail (fieldname != NULL, FALSE);
|
|
|
|
g_return_val_if_fail (value != NULL, FALSE);
|
|
|
|
|
|
|
|
field = gst_structure_get_field (structure, fieldname);
|
|
|
|
|
|
|
|
if (field == NULL)
|
|
|
|
return FALSE;
|
|
|
|
if (!G_VALUE_HOLDS_UINT64 (&field->value))
|
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
*value = g_value_get_uint64 (&field->value);
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2003-11-03 09:10:07 +00:00
|
|
|
/**
|
|
|
|
* gst_structure_get_double:
|
|
|
|
* @structure: a #GstStructure
|
|
|
|
* @fieldname: the name of a field
|
2004-01-30 19:06:13 +00:00
|
|
|
* @value: a pointer to a #GstFourcc to set
|
2003-11-03 09:10:07 +00:00
|
|
|
*
|
2004-01-30 19:06:13 +00:00
|
|
|
* Sets the double pointed to by @value corresponding to the value of the
|
2003-11-03 09:10:07 +00:00
|
|
|
* given field. Caller is responsible for making sure the field exists
|
|
|
|
* and has the correct type.
|
|
|
|
*
|
2005-11-09 15:10:32 +00:00
|
|
|
* Returns: TRUE if the value could be set correctly. If there was no field
|
|
|
|
* with @fieldname or the existing field did not contain a double, this
|
|
|
|
* function returns FALSE.
|
2003-11-03 09:10:07 +00:00
|
|
|
*/
|
2004-03-12 19:35:40 +00:00
|
|
|
gboolean
|
2004-03-13 15:27:01 +00:00
|
|
|
gst_structure_get_double (const GstStructure * structure,
|
|
|
|
const gchar * fieldname, gdouble * value)
|
2003-11-03 09:10:07 +00:00
|
|
|
{
|
|
|
|
GstStructureField *field;
|
|
|
|
|
2004-03-13 15:27:01 +00:00
|
|
|
g_return_val_if_fail (structure != NULL, FALSE);
|
|
|
|
g_return_val_if_fail (fieldname != NULL, FALSE);
|
|
|
|
g_return_val_if_fail (value != NULL, FALSE);
|
2003-11-03 09:10:07 +00:00
|
|
|
|
2004-03-13 15:27:01 +00:00
|
|
|
field = gst_structure_get_field (structure, fieldname);
|
2003-11-03 09:10:07 +00:00
|
|
|
|
2004-03-13 15:27:01 +00:00
|
|
|
if (field == NULL)
|
|
|
|
return FALSE;
|
|
|
|
if (!G_VALUE_HOLDS_DOUBLE (&field->value))
|
|
|
|
return FALSE;
|
2003-11-03 09:10:07 +00:00
|
|
|
|
2004-03-13 15:27:01 +00:00
|
|
|
*value = g_value_get_double (&field->value);
|
2003-11-03 09:10:07 +00:00
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* gst_structure_get_string:
|
|
|
|
* @structure: a #GstStructure
|
|
|
|
* @fieldname: the name of a field
|
|
|
|
*
|
|
|
|
* Finds the field corresponding to @fieldname, and returns the string
|
|
|
|
* contained in the field's value. Caller is responsible for making
|
|
|
|
* sure the field exists and has the correct type.
|
|
|
|
*
|
|
|
|
* The string should not be modified, and remains valid until the next
|
|
|
|
* call to a gst_structure_*() function with the given structure.
|
|
|
|
*
|
2005-11-09 15:10:32 +00:00
|
|
|
* Returns: a pointer to the string or NULL when the field did not exist
|
|
|
|
* or did not contain a string.
|
2003-11-03 09:10:07 +00:00
|
|
|
*/
|
|
|
|
const gchar *
|
2004-03-13 15:27:01 +00:00
|
|
|
gst_structure_get_string (const GstStructure * structure,
|
|
|
|
const gchar * fieldname)
|
2003-11-03 09:10:07 +00:00
|
|
|
{
|
|
|
|
GstStructureField *field;
|
|
|
|
|
2004-03-13 15:27:01 +00:00
|
|
|
g_return_val_if_fail (structure != NULL, NULL);
|
|
|
|
g_return_val_if_fail (fieldname != NULL, NULL);
|
2003-11-03 09:10:07 +00:00
|
|
|
|
2004-03-13 15:27:01 +00:00
|
|
|
field = gst_structure_get_field (structure, fieldname);
|
2003-11-03 09:10:07 +00:00
|
|
|
|
2004-03-13 15:27:01 +00:00
|
|
|
if (field == NULL)
|
gst/: Aplied part of patch #157127: Cleanup of issues reported by sparse.
Original commit message from CVS:
reviewed by: Wim Taymans, Ronald Bultje.
* gst/cothreads.c: (cothread_create):
* gst/gstbin.c: (gst_bin_add_func), (gst_bin_remove_func),
(gst_bin_child_state_change_func):
* gst/gstbuffer.c: (gst_buffer_span):
* gst/gstelement.c: (gst_element_get_index),
(gst_element_get_event_masks), (gst_element_get_query_types),
(gst_element_get_formats):
* gst/gsterror.c: (_gst_core_errors_init),
(_gst_library_errors_init), (_gst_resource_errors_init),
(_gst_stream_errors_init):
* gst/gstobject.c: (gst_object_default_deep_notify):
* gst/gstpad.c: (gst_pad_get_event_masks),
(gst_pad_get_internal_links_default):
* gst/gstplugin.c: (gst_plugin_register_func),
(gst_plugin_get_module):
* gst/gststructure.c: (gst_structure_get_string),
(gst_structure_get_abbrs), (gst_structure_from_abbr),
(gst_structure_to_abbr):
* gst/gstutils.c: (gst_print_element_args):
* gst/schedulers/gstoptimalscheduler.c: (add_to_group),
(setup_group_scheduler), (gst_opt_scheduler_iterate):
Aplied part of patch #157127: Cleanup of issues reported by
sparse.
Also do not try to use cothreads when there is no cothread
context yet.
2004-11-02 15:02:12 +00:00
|
|
|
return NULL;
|
2004-03-13 15:27:01 +00:00
|
|
|
if (!G_VALUE_HOLDS_STRING (&field->value))
|
gst/: Aplied part of patch #157127: Cleanup of issues reported by sparse.
Original commit message from CVS:
reviewed by: Wim Taymans, Ronald Bultje.
* gst/cothreads.c: (cothread_create):
* gst/gstbin.c: (gst_bin_add_func), (gst_bin_remove_func),
(gst_bin_child_state_change_func):
* gst/gstbuffer.c: (gst_buffer_span):
* gst/gstelement.c: (gst_element_get_index),
(gst_element_get_event_masks), (gst_element_get_query_types),
(gst_element_get_formats):
* gst/gsterror.c: (_gst_core_errors_init),
(_gst_library_errors_init), (_gst_resource_errors_init),
(_gst_stream_errors_init):
* gst/gstobject.c: (gst_object_default_deep_notify):
* gst/gstpad.c: (gst_pad_get_event_masks),
(gst_pad_get_internal_links_default):
* gst/gstplugin.c: (gst_plugin_register_func),
(gst_plugin_get_module):
* gst/gststructure.c: (gst_structure_get_string),
(gst_structure_get_abbrs), (gst_structure_from_abbr),
(gst_structure_to_abbr):
* gst/gstutils.c: (gst_print_element_args):
* gst/schedulers/gstoptimalscheduler.c: (add_to_group),
(setup_group_scheduler), (gst_opt_scheduler_iterate):
Aplied part of patch #157127: Cleanup of issues reported by
sparse.
Also do not try to use cothreads when there is no cothread
context yet.
2004-11-02 15:02:12 +00:00
|
|
|
return NULL;
|
2003-11-03 09:10:07 +00:00
|
|
|
|
2004-03-13 15:27:01 +00:00
|
|
|
return g_value_get_string (&field->value);
|
2003-11-03 09:10:07 +00:00
|
|
|
}
|
|
|
|
|
2005-09-29 02:32:37 +00:00
|
|
|
/**
|
|
|
|
* gst_structure_get_enum:
|
|
|
|
* @structure: a #GstStructure
|
|
|
|
* @fieldname: the name of a field
|
|
|
|
* @enumtype: the enum type of a field
|
|
|
|
* @value: a pointer to an int to set
|
|
|
|
*
|
|
|
|
* Sets the int pointed to by @value corresponding to the value of the
|
|
|
|
* given field. Caller is responsible for making sure the field exists,
|
|
|
|
* has the correct type and that the enumtype is correct.
|
|
|
|
*
|
2005-11-09 15:10:32 +00:00
|
|
|
* Returns: TRUE if the value could be set correctly. If there was no field
|
|
|
|
* with @fieldname or the existing field did not contain an enum of the given
|
|
|
|
* type, this function returns FALSE.
|
2005-09-29 02:32:37 +00:00
|
|
|
*/
|
|
|
|
gboolean
|
|
|
|
gst_structure_get_enum (const GstStructure * structure,
|
|
|
|
const gchar * fieldname, GType enumtype, gint * value)
|
|
|
|
{
|
|
|
|
GstStructureField *field;
|
|
|
|
|
|
|
|
g_return_val_if_fail (structure != NULL, FALSE);
|
|
|
|
g_return_val_if_fail (fieldname != NULL, FALSE);
|
|
|
|
g_return_val_if_fail (enumtype != G_TYPE_INVALID, FALSE);
|
|
|
|
g_return_val_if_fail (value != NULL, FALSE);
|
|
|
|
|
|
|
|
field = gst_structure_get_field (structure, fieldname);
|
|
|
|
|
|
|
|
if (field == NULL)
|
|
|
|
return FALSE;
|
|
|
|
if (!G_VALUE_HOLDS_ENUM (&field->value))
|
|
|
|
return FALSE;
|
|
|
|
if (!G_TYPE_CHECK_VALUE_TYPE (&field->value, enumtype))
|
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
*value = g_value_get_enum (&field->value);
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2005-11-23 13:22:21 +00:00
|
|
|
/**
|
|
|
|
* gst_structure_get_fraction:
|
|
|
|
* @structure: a #GstStructure
|
|
|
|
* @fieldname: the name of a field
|
|
|
|
* @value_numerator: a pointer to an int to set
|
|
|
|
* @value_denominator: a pointer to an int to set
|
|
|
|
*
|
|
|
|
* Sets the integers pointed to by @value_numerator and @value_denominator
|
|
|
|
* corresponding to the value of the given field. Caller is responsible
|
|
|
|
* for making sure the field exists and has the correct type.
|
|
|
|
*
|
|
|
|
* Returns: TRUE if the values could be set correctly. If there was no field
|
|
|
|
* with @fieldname or the existing field did not contain a GstFraction, this
|
|
|
|
* function returns FALSE.
|
|
|
|
*/
|
|
|
|
gboolean
|
|
|
|
gst_structure_get_fraction (const GstStructure * structure,
|
|
|
|
const gchar * fieldname, gint * value_numerator, gint * value_denominator)
|
|
|
|
{
|
|
|
|
GstStructureField *field;
|
|
|
|
|
|
|
|
g_return_val_if_fail (structure != NULL, FALSE);
|
|
|
|
g_return_val_if_fail (fieldname != NULL, FALSE);
|
|
|
|
g_return_val_if_fail (value_numerator != NULL, FALSE);
|
|
|
|
g_return_val_if_fail (value_denominator != NULL, FALSE);
|
|
|
|
|
|
|
|
field = gst_structure_get_field (structure, fieldname);
|
|
|
|
|
|
|
|
if (field == NULL)
|
|
|
|
return FALSE;
|
|
|
|
if (!GST_VALUE_HOLDS_FRACTION (&field->value))
|
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
*value_numerator = gst_value_get_fraction_numerator (&field->value);
|
|
|
|
*value_denominator = gst_value_get_fraction_denominator (&field->value);
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2004-03-13 15:27:01 +00:00
|
|
|
typedef struct _GstStructureAbbreviation
|
|
|
|
{
|
2003-11-29 06:31:10 +00:00
|
|
|
char *type_name;
|
|
|
|
GType type;
|
2004-03-15 19:27:17 +00:00
|
|
|
}
|
|
|
|
GstStructureAbbreviation;
|
2003-11-29 06:31:10 +00:00
|
|
|
|
2006-05-10 14:12:14 +00:00
|
|
|
/* return a copy of an array of GstStructureAbbreviation containing all the
|
|
|
|
* known type_string, GType maps, including abbreviations for common types */
|
2004-11-02 12:39:27 +00:00
|
|
|
static GstStructureAbbreviation *
|
|
|
|
gst_structure_get_abbrs (gint * n_abbrs)
|
|
|
|
{
|
|
|
|
static GstStructureAbbreviation *abbrs = NULL;
|
|
|
|
static gint num = 0;
|
|
|
|
|
|
|
|
if (abbrs == NULL) {
|
|
|
|
/* dynamically generate the array */
|
|
|
|
GstStructureAbbreviation dyn_abbrs[] = {
|
|
|
|
{"int", G_TYPE_INT}
|
|
|
|
,
|
|
|
|
{"i", G_TYPE_INT}
|
|
|
|
,
|
|
|
|
{"float", G_TYPE_FLOAT}
|
|
|
|
,
|
|
|
|
{"f", G_TYPE_FLOAT}
|
|
|
|
,
|
|
|
|
{"double", G_TYPE_DOUBLE}
|
|
|
|
,
|
|
|
|
{"d", G_TYPE_DOUBLE}
|
|
|
|
,
|
|
|
|
{"buffer", GST_TYPE_BUFFER}
|
|
|
|
,
|
|
|
|
{"fourcc", GST_TYPE_FOURCC}
|
|
|
|
,
|
|
|
|
{"4", GST_TYPE_FOURCC}
|
|
|
|
,
|
|
|
|
{"fraction", GST_TYPE_FRACTION}
|
|
|
|
,
|
|
|
|
{"boolean", G_TYPE_BOOLEAN}
|
|
|
|
,
|
|
|
|
{"bool", G_TYPE_BOOLEAN}
|
|
|
|
,
|
|
|
|
{"b", G_TYPE_BOOLEAN}
|
|
|
|
,
|
|
|
|
{"string", G_TYPE_STRING}
|
|
|
|
,
|
|
|
|
{"str", G_TYPE_STRING}
|
|
|
|
,
|
|
|
|
{"s", G_TYPE_STRING}
|
2007-10-22 08:53:26 +00:00
|
|
|
,
|
|
|
|
{"structure", GST_TYPE_STRUCTURE}
|
2004-11-02 12:39:27 +00:00
|
|
|
};
|
|
|
|
num = G_N_ELEMENTS (dyn_abbrs);
|
|
|
|
/* permanently allocate and copy the array now */
|
|
|
|
abbrs = g_new0 (GstStructureAbbreviation, num);
|
|
|
|
memcpy (abbrs, dyn_abbrs, sizeof (GstStructureAbbreviation) * num);
|
|
|
|
}
|
|
|
|
*n_abbrs = num;
|
|
|
|
|
|
|
|
return abbrs;
|
|
|
|
}
|
2003-11-29 06:31:10 +00:00
|
|
|
|
2006-05-10 14:12:14 +00:00
|
|
|
/* given a type_name that could be a type abbreviation or a registered GType,
|
|
|
|
* return a matching GType */
|
2004-03-12 19:35:40 +00:00
|
|
|
static GType
|
2006-05-10 14:12:14 +00:00
|
|
|
gst_structure_gtype_from_abbr (const char *type_name)
|
2003-11-29 06:31:10 +00:00
|
|
|
{
|
2004-02-07 15:51:39 +00:00
|
|
|
int i;
|
2004-11-02 12:39:27 +00:00
|
|
|
GstStructureAbbreviation *abbrs;
|
|
|
|
gint n_abbrs;
|
2003-11-29 06:31:10 +00:00
|
|
|
|
2004-03-13 15:27:01 +00:00
|
|
|
g_return_val_if_fail (type_name != NULL, G_TYPE_INVALID);
|
2003-11-29 06:31:10 +00:00
|
|
|
|
2004-11-02 12:39:27 +00:00
|
|
|
abbrs = gst_structure_get_abbrs (&n_abbrs);
|
2003-11-29 06:31:10 +00:00
|
|
|
|
2004-11-02 12:39:27 +00:00
|
|
|
for (i = 0; i < n_abbrs; i++) {
|
|
|
|
if (strcmp (type_name, abbrs[i].type_name) == 0) {
|
|
|
|
return abbrs[i].type;
|
|
|
|
}
|
2004-07-15 20:27:20 +00:00
|
|
|
}
|
2003-11-29 06:31:10 +00:00
|
|
|
|
2004-11-02 12:39:27 +00:00
|
|
|
/* this is the fallback */
|
2003-11-29 06:31:10 +00:00
|
|
|
return g_type_from_name (type_name);
|
|
|
|
}
|
|
|
|
|
2004-03-12 19:35:40 +00:00
|
|
|
static const char *
|
|
|
|
gst_structure_to_abbr (GType type)
|
2003-11-29 06:31:10 +00:00
|
|
|
{
|
2004-02-07 15:51:39 +00:00
|
|
|
int i;
|
2004-11-02 12:39:27 +00:00
|
|
|
GstStructureAbbreviation *abbrs;
|
|
|
|
gint n_abbrs;
|
2003-11-29 06:31:10 +00:00
|
|
|
|
2004-03-13 15:27:01 +00:00
|
|
|
g_return_val_if_fail (type != G_TYPE_INVALID, NULL);
|
2003-11-29 06:31:10 +00:00
|
|
|
|
2004-11-02 12:39:27 +00:00
|
|
|
abbrs = gst_structure_get_abbrs (&n_abbrs);
|
2003-11-29 06:31:10 +00:00
|
|
|
|
2004-11-02 12:39:27 +00:00
|
|
|
for (i = 0; i < n_abbrs; i++) {
|
|
|
|
if (type == abbrs[i].type) {
|
|
|
|
return abbrs[i].type_name;
|
|
|
|
}
|
2004-07-15 20:27:20 +00:00
|
|
|
}
|
2003-11-29 06:31:10 +00:00
|
|
|
|
2004-03-13 15:27:01 +00:00
|
|
|
return g_type_name (type);
|
2003-11-29 06:31:10 +00:00
|
|
|
}
|
|
|
|
|
2004-04-22 16:39:23 +00:00
|
|
|
static GType
|
|
|
|
gst_structure_value_get_generic_type (GValue * val)
|
|
|
|
{
|
2004-05-20 17:03:02 +00:00
|
|
|
if (G_VALUE_TYPE (val) == GST_TYPE_LIST
|
GstElement::new-pad -> pad-added, GstElement::state-change -> state-changed, GstValueFixedList -> GstValueArray, add ...
Original commit message from CVS:
* docs/manual/advanced-autoplugging.xml:
* docs/manual/basics-helloworld.xml:
* docs/manual/basics-pads.xml:
* docs/random/ds/0.9-suggested-changes:
* gst/gstelement.c: (gst_element_class_init), (gst_element_seek):
* gst/gstelement.h:
* gst/gstevent.h:
* gst/gstformat.h:
* gst/gstquery.h:
* gst/gststructure.c: (gst_structure_value_get_generic_type),
(gst_structure_parse_array), (gst_structure_parse_value):
* gst/gstvalue.c: (gst_type_is_fixed),
(gst_value_list_prepend_value), (gst_value_list_append_value),
(gst_value_list_get_size), (gst_value_list_get_value),
(gst_value_transform_array_string), (gst_value_serialize_array),
(gst_value_deserialize_array), (gst_value_intersect_array),
(gst_value_is_fixed), (_gst_value_initialize):
* gst/gstvalue.h:
GstElement::new-pad -> pad-added, GstElement::state-change ->
state-changed, GstValueFixedList -> GstValueArray, add format and
flags as their own arguments in gst_element_seek() (should improve
"bindeability"), remove function generators since they don't work
under a whole bunch of compilers (they were deprecated already
anyway).
2005-07-20 17:16:44 +00:00
|
|
|
|| G_VALUE_TYPE (val) == GST_TYPE_ARRAY) {
|
2004-04-22 16:39:23 +00:00
|
|
|
GArray *array = g_value_peek_pointer (val);
|
|
|
|
|
|
|
|
if (array->len > 0) {
|
|
|
|
GValue *value = &g_array_index (array, GValue, 0);
|
|
|
|
|
|
|
|
return gst_structure_value_get_generic_type (value);
|
|
|
|
} else {
|
|
|
|
return G_TYPE_INT;
|
|
|
|
}
|
|
|
|
} else if (G_VALUE_TYPE (val) == GST_TYPE_INT_RANGE) {
|
|
|
|
return G_TYPE_INT;
|
|
|
|
} else if (G_VALUE_TYPE (val) == GST_TYPE_DOUBLE_RANGE) {
|
|
|
|
return G_TYPE_DOUBLE;
|
2005-11-22 11:56:01 +00:00
|
|
|
} else if (G_VALUE_TYPE (val) == GST_TYPE_FRACTION_RANGE) {
|
|
|
|
return GST_TYPE_FRACTION;
|
2004-04-22 16:39:23 +00:00
|
|
|
}
|
|
|
|
return G_VALUE_TYPE (val);
|
|
|
|
}
|
|
|
|
|
2007-10-15 11:19:36 +00:00
|
|
|
/* keep in sync with gstvalue.c */
|
2003-12-22 01:39:35 +00:00
|
|
|
#define GST_ASCII_IS_STRING(c) (g_ascii_isalnum((c)) || ((c) == '_') || \
|
|
|
|
((c) == '-') || ((c) == '+') || ((c) == '/') || ((c) == ':') || \
|
|
|
|
((c) == '.'))
|
|
|
|
|
2008-01-09 16:36:34 +00:00
|
|
|
gboolean
|
|
|
|
priv_gst_structure_append_to_gstring (const GstStructure * structure,
|
|
|
|
GString * s)
|
|
|
|
{
|
|
|
|
GstStructureField *field;
|
|
|
|
guint i;
|
|
|
|
|
|
|
|
g_return_val_if_fail (s != NULL, FALSE);
|
|
|
|
|
|
|
|
g_string_append (s, g_quark_to_string (structure->name));
|
|
|
|
for (i = 0; i < structure->fields->len; i++) {
|
|
|
|
char *t;
|
|
|
|
GType type;
|
|
|
|
|
|
|
|
field = GST_STRUCTURE_FIELD (structure, i);
|
|
|
|
|
|
|
|
t = gst_value_serialize (&field->value);
|
|
|
|
type = gst_structure_value_get_generic_type (&field->value);
|
|
|
|
|
|
|
|
g_string_append_len (s, ", ", 2);
|
|
|
|
/* FIXME: do we need to escape fieldnames? */
|
|
|
|
g_string_append (s, g_quark_to_string (field->name));
|
|
|
|
g_string_append_len (s, "=(", 2);
|
|
|
|
g_string_append (s, gst_structure_to_abbr (type));
|
|
|
|
g_string_append_c (s, ')');
|
|
|
|
g_string_append (s, GST_STR_NULL (t));
|
|
|
|
g_free (t);
|
|
|
|
}
|
|
|
|
|
|
|
|
g_string_append_c (s, ';');
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2003-11-03 09:10:07 +00:00
|
|
|
/**
|
|
|
|
* gst_structure_to_string:
|
|
|
|
* @structure: a #GstStructure
|
|
|
|
*
|
2005-11-09 15:10:32 +00:00
|
|
|
* Converts @structure to a human-readable string representation.
|
2005-10-15 15:30:24 +00:00
|
|
|
*
|
2005-11-27 22:43:08 +00:00
|
|
|
* Returns: a pointer to string allocated by g_malloc(). g_free() after
|
2005-11-09 15:10:32 +00:00
|
|
|
* usage.
|
2003-11-03 09:10:07 +00:00
|
|
|
*/
|
|
|
|
gchar *
|
2004-03-13 15:27:01 +00:00
|
|
|
gst_structure_to_string (const GstStructure * structure)
|
2003-11-03 09:10:07 +00:00
|
|
|
{
|
|
|
|
GString *s;
|
2004-03-13 15:27:01 +00:00
|
|
|
|
configure.ac: Add detection for HAVE_PRINTF_EXTENSION and
Original commit message from CVS:
* configure.ac: Add detection for HAVE_PRINTF_EXTENSION and
GST_PRINTF_EXTENSION_FORMAT_DEFINE.
* docs/random/ds/0.9-suggested-changes: Notes from Company.
* gst/gstcaps.c: (gst_caps_to_string): Add comment.
* gst/gstconfig.h.in: Add define for GST_PTR_FORMAT
* gst/gstinfo.c: (_gst_debug_init), (gst_debug_print_object),
(gst_debug_log_default), (_gst_info_printf_extension),
(_gst_info_printf_extension_arginfo): Add printf extension.
* gst/gstinfo.h: remove G_GNUC_PRINTF, because it doesn't work with %P
* gst/gststructure.c: (gst_structure_to_string),
(_gst_structure_parse_value): Use gst_value_deserialize() and
remove old code.
* gst/gstvalue.c: (gst_value_deserialize_fourcc),
(gst_value_deserialize_boolean), (gst_strtoi),
(gst_value_deserialize_int), (gst_value_deserialize_double),
(gst_value_deserialize_string), (gst_value_deserialize): Implement
a bunch of deserialize functions and gst_value_deserialize.
* gst/gstvalue.h: er, _de_serialize, not unserialize
* testsuite/caps/string-conversions.c: (main): We don't currently
handle (float) in caps, so convert these to (double).
* testsuite/debug/Makefile.am: Add new test for the printf extension
* testsuite/debug/printf_extension.c: (main): same
2004-01-29 01:20:23 +00:00
|
|
|
/* NOTE: This function is potentially called by the debug system,
|
|
|
|
* so any calls to gst_log() (and GST_DEBUG(), GST_LOG(), etc.)
|
|
|
|
* should be careful to avoid recursion. This includes any functions
|
|
|
|
* called by gst_structure_to_string. In particular, calls should
|
|
|
|
* not use the GST_PTR_FORMAT extension. */
|
2003-11-03 09:10:07 +00:00
|
|
|
|
2004-03-13 15:27:01 +00:00
|
|
|
g_return_val_if_fail (structure != NULL, NULL);
|
2003-11-03 09:10:07 +00:00
|
|
|
|
2008-01-09 16:36:34 +00:00
|
|
|
/* we estimate a minimum size based on the number of fields in order to
|
|
|
|
* avoid unnecessary reallocs within GString */
|
|
|
|
s = g_string_sized_new (STRUCTURE_ESTIMATED_STRING_LEN (structure));
|
|
|
|
priv_gst_structure_append_to_gstring (structure, s);
|
2004-03-13 15:27:01 +00:00
|
|
|
return g_string_free (s, FALSE);
|
2003-11-03 09:10:07 +00:00
|
|
|
}
|
|
|
|
|
2003-11-29 06:31:10 +00:00
|
|
|
/*
|
2005-10-15 15:30:24 +00:00
|
|
|
* r will still point to the string. if end == next, the string will not be
|
2003-11-29 06:31:10 +00:00
|
|
|
* null-terminated. In all other cases it will be.
|
|
|
|
* end = pointer to char behind end of string, next = pointer to start of
|
|
|
|
* unread data.
|
2005-10-15 15:30:24 +00:00
|
|
|
* THIS FUNCTION MODIFIES THE STRING AND DETECTS INSIDE A NONTERMINATED STRING
|
2003-11-29 06:31:10 +00:00
|
|
|
*/
|
|
|
|
static gboolean
|
2004-03-13 15:27:01 +00:00
|
|
|
gst_structure_parse_string (gchar * s, gchar ** end, gchar ** next)
|
2003-11-29 06:31:10 +00:00
|
|
|
{
|
|
|
|
gchar *w;
|
|
|
|
|
2004-03-13 15:27:01 +00:00
|
|
|
if (*s == 0)
|
|
|
|
return FALSE;
|
2003-11-29 06:31:10 +00:00
|
|
|
|
2003-12-22 01:39:35 +00:00
|
|
|
if (*s != '"') {
|
|
|
|
int ret;
|
2003-11-29 06:31:10 +00:00
|
|
|
|
2004-03-12 19:35:40 +00:00
|
|
|
ret = gst_structure_parse_simple_string (s, end);
|
2003-12-22 01:39:35 +00:00
|
|
|
*next = *end;
|
2003-11-29 06:31:10 +00:00
|
|
|
|
2003-12-22 01:39:35 +00:00
|
|
|
return ret;
|
|
|
|
}
|
2003-11-29 06:31:10 +00:00
|
|
|
|
2003-12-22 01:39:35 +00:00
|
|
|
w = s;
|
|
|
|
s++;
|
|
|
|
while (*s != '"') {
|
2004-03-13 15:27:01 +00:00
|
|
|
if (*s == 0)
|
|
|
|
return FALSE;
|
2003-12-22 01:39:35 +00:00
|
|
|
|
|
|
|
if (*s == '\\') {
|
|
|
|
s++;
|
2003-11-29 06:31:10 +00:00
|
|
|
}
|
2003-12-22 01:39:35 +00:00
|
|
|
|
|
|
|
*w = *s;
|
|
|
|
w++;
|
|
|
|
s++;
|
2003-11-29 06:31:10 +00:00
|
|
|
}
|
2003-12-22 01:39:35 +00:00
|
|
|
s++;
|
2003-11-29 06:31:10 +00:00
|
|
|
|
|
|
|
*end = w;
|
2003-12-22 01:39:35 +00:00
|
|
|
*next = s;
|
2003-11-29 06:31:10 +00:00
|
|
|
|
2003-12-22 01:39:35 +00:00
|
|
|
return TRUE;
|
2003-11-29 06:31:10 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static gboolean
|
2004-03-13 15:27:01 +00:00
|
|
|
gst_structure_parse_range (gchar * s, gchar ** after, GValue * value,
|
|
|
|
GType type)
|
2003-11-29 06:31:10 +00:00
|
|
|
{
|
|
|
|
GValue value1 = { 0 };
|
|
|
|
GValue value2 = { 0 };
|
|
|
|
GType range_type;
|
|
|
|
gboolean ret;
|
|
|
|
|
2004-03-13 15:27:01 +00:00
|
|
|
if (*s != '[')
|
|
|
|
return FALSE;
|
2003-11-29 06:31:10 +00:00
|
|
|
s++;
|
|
|
|
|
2004-03-13 15:27:01 +00:00
|
|
|
ret = gst_structure_parse_value (s, &s, &value1, type);
|
|
|
|
if (ret == FALSE)
|
|
|
|
return FALSE;
|
2003-11-29 06:31:10 +00:00
|
|
|
|
2004-03-13 15:27:01 +00:00
|
|
|
while (g_ascii_isspace (*s))
|
|
|
|
s++;
|
|
|
|
|
|
|
|
if (*s != ',')
|
|
|
|
return FALSE;
|
2003-11-29 06:31:10 +00:00
|
|
|
s++;
|
|
|
|
|
2004-03-13 15:27:01 +00:00
|
|
|
while (g_ascii_isspace (*s))
|
|
|
|
s++;
|
2003-11-29 06:31:10 +00:00
|
|
|
|
2004-03-13 15:27:01 +00:00
|
|
|
ret = gst_structure_parse_value (s, &s, &value2, type);
|
|
|
|
if (ret == FALSE)
|
|
|
|
return FALSE;
|
2003-11-29 06:31:10 +00:00
|
|
|
|
2004-03-13 15:27:01 +00:00
|
|
|
while (g_ascii_isspace (*s))
|
|
|
|
s++;
|
2003-11-29 06:31:10 +00:00
|
|
|
|
2004-03-13 15:27:01 +00:00
|
|
|
if (*s != ']')
|
|
|
|
return FALSE;
|
2003-11-29 06:31:10 +00:00
|
|
|
s++;
|
|
|
|
|
2004-03-13 15:27:01 +00:00
|
|
|
if (G_VALUE_TYPE (&value1) != G_VALUE_TYPE (&value2))
|
|
|
|
return FALSE;
|
|
|
|
|
2003-12-22 01:39:35 +00:00
|
|
|
if (G_VALUE_TYPE (&value1) == G_TYPE_DOUBLE) {
|
|
|
|
range_type = GST_TYPE_DOUBLE_RANGE;
|
Implement fraction ranges and extend GstFraction to support arithmetic subtraction, as well as deserialization from i...
Original commit message from CVS:
* check/gst/capslist.h:
* check/gst/gstcaps.c: (GST_START_TEST):
* check/gst/gstvalue.c: (GST_START_TEST), (gst_value_suite):
* gst/gststructure.c: (gst_structure_parse_range),
(gst_structure_fixate_field_nearest_fraction):
* gst/gststructure.h:
* gst/gstvalue.c: (gst_value_init_fraction_range),
(gst_value_free_fraction_range), (gst_value_copy_fraction_range),
(gst_value_collect_fraction_range),
(gst_value_lcopy_fraction_range), (gst_value_set_fraction_range),
(gst_value_set_fraction_range_full),
(gst_value_get_fraction_range_min),
(gst_value_get_fraction_range_max),
(gst_value_serialize_fraction_range),
(gst_value_transform_fraction_range_string),
(gst_value_compare_fraction_range),
(gst_value_deserialize_fraction_range),
(gst_value_intersect_fraction_fraction_range),
(gst_value_intersect_fraction_range_fraction_range),
(gst_value_subtract_fraction_fraction_range),
(gst_value_subtract_fraction_range_fraction),
(gst_value_subtract_fraction_range_fraction_range),
(gst_value_collect_fraction), (gst_value_fraction_multiply),
(gst_value_fraction_subtract), (gst_value_deserialize_fraction),
(gst_value_transform_string_fraction), (_gst_value_initialize):
* gst/gstvalue.h:
Implement fraction ranges and extend GstFraction to support
arithmetic subtraction, as well as deserialization from integer
strings such as "100"
Add a testsuite as for int and double range set operations
2005-11-21 23:54:59 +00:00
|
|
|
g_value_init (value, range_type);
|
2004-03-13 15:27:01 +00:00
|
|
|
gst_value_set_double_range (value, g_value_get_double (&value1),
|
2004-03-15 19:27:17 +00:00
|
|
|
g_value_get_double (&value2));
|
Implement fraction ranges and extend GstFraction to support arithmetic subtraction, as well as deserialization from i...
Original commit message from CVS:
* check/gst/capslist.h:
* check/gst/gstcaps.c: (GST_START_TEST):
* check/gst/gstvalue.c: (GST_START_TEST), (gst_value_suite):
* gst/gststructure.c: (gst_structure_parse_range),
(gst_structure_fixate_field_nearest_fraction):
* gst/gststructure.h:
* gst/gstvalue.c: (gst_value_init_fraction_range),
(gst_value_free_fraction_range), (gst_value_copy_fraction_range),
(gst_value_collect_fraction_range),
(gst_value_lcopy_fraction_range), (gst_value_set_fraction_range),
(gst_value_set_fraction_range_full),
(gst_value_get_fraction_range_min),
(gst_value_get_fraction_range_max),
(gst_value_serialize_fraction_range),
(gst_value_transform_fraction_range_string),
(gst_value_compare_fraction_range),
(gst_value_deserialize_fraction_range),
(gst_value_intersect_fraction_fraction_range),
(gst_value_intersect_fraction_range_fraction_range),
(gst_value_subtract_fraction_fraction_range),
(gst_value_subtract_fraction_range_fraction),
(gst_value_subtract_fraction_range_fraction_range),
(gst_value_collect_fraction), (gst_value_fraction_multiply),
(gst_value_fraction_subtract), (gst_value_deserialize_fraction),
(gst_value_transform_string_fraction), (_gst_value_initialize):
* gst/gstvalue.h:
Implement fraction ranges and extend GstFraction to support
arithmetic subtraction, as well as deserialization from integer
strings such as "100"
Add a testsuite as for int and double range set operations
2005-11-21 23:54:59 +00:00
|
|
|
} else if (G_VALUE_TYPE (&value1) == G_TYPE_INT) {
|
|
|
|
range_type = GST_TYPE_INT_RANGE;
|
|
|
|
g_value_init (value, range_type);
|
2004-03-13 15:27:01 +00:00
|
|
|
gst_value_set_int_range (value, g_value_get_int (&value1),
|
2004-03-15 19:27:17 +00:00
|
|
|
g_value_get_int (&value2));
|
Implement fraction ranges and extend GstFraction to support arithmetic subtraction, as well as deserialization from i...
Original commit message from CVS:
* check/gst/capslist.h:
* check/gst/gstcaps.c: (GST_START_TEST):
* check/gst/gstvalue.c: (GST_START_TEST), (gst_value_suite):
* gst/gststructure.c: (gst_structure_parse_range),
(gst_structure_fixate_field_nearest_fraction):
* gst/gststructure.h:
* gst/gstvalue.c: (gst_value_init_fraction_range),
(gst_value_free_fraction_range), (gst_value_copy_fraction_range),
(gst_value_collect_fraction_range),
(gst_value_lcopy_fraction_range), (gst_value_set_fraction_range),
(gst_value_set_fraction_range_full),
(gst_value_get_fraction_range_min),
(gst_value_get_fraction_range_max),
(gst_value_serialize_fraction_range),
(gst_value_transform_fraction_range_string),
(gst_value_compare_fraction_range),
(gst_value_deserialize_fraction_range),
(gst_value_intersect_fraction_fraction_range),
(gst_value_intersect_fraction_range_fraction_range),
(gst_value_subtract_fraction_fraction_range),
(gst_value_subtract_fraction_range_fraction),
(gst_value_subtract_fraction_range_fraction_range),
(gst_value_collect_fraction), (gst_value_fraction_multiply),
(gst_value_fraction_subtract), (gst_value_deserialize_fraction),
(gst_value_transform_string_fraction), (_gst_value_initialize):
* gst/gstvalue.h:
Implement fraction ranges and extend GstFraction to support
arithmetic subtraction, as well as deserialization from integer
strings such as "100"
Add a testsuite as for int and double range set operations
2005-11-21 23:54:59 +00:00
|
|
|
} else if (G_VALUE_TYPE (&value1) == GST_TYPE_FRACTION) {
|
|
|
|
range_type = GST_TYPE_FRACTION_RANGE;
|
|
|
|
g_value_init (value, range_type);
|
|
|
|
gst_value_set_fraction_range (value, &value1, &value2);
|
|
|
|
} else {
|
|
|
|
return FALSE;
|
2003-11-29 06:31:10 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
*after = s;
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static gboolean
|
2004-05-20 17:03:02 +00:00
|
|
|
gst_structure_parse_any_list (gchar * s, gchar ** after, GValue * value,
|
|
|
|
GType type, GType list_type, char begin, char end)
|
2003-11-29 06:31:10 +00:00
|
|
|
{
|
|
|
|
GValue list_value = { 0 };
|
|
|
|
gboolean ret;
|
2003-12-22 01:39:35 +00:00
|
|
|
GArray *array;
|
2003-11-29 06:31:10 +00:00
|
|
|
|
2004-05-20 17:03:02 +00:00
|
|
|
g_value_init (value, list_type);
|
2003-12-22 01:39:35 +00:00
|
|
|
array = g_value_peek_pointer (value);
|
2003-11-29 06:31:10 +00:00
|
|
|
|
2004-05-20 17:03:02 +00:00
|
|
|
if (*s != begin)
|
2004-03-13 15:27:01 +00:00
|
|
|
return FALSE;
|
2003-11-29 06:31:10 +00:00
|
|
|
s++;
|
|
|
|
|
2004-03-13 15:27:01 +00:00
|
|
|
while (g_ascii_isspace (*s))
|
|
|
|
s++;
|
2004-05-20 17:03:02 +00:00
|
|
|
if (*s == end) {
|
2003-11-29 06:31:10 +00:00
|
|
|
s++;
|
|
|
|
*after = s;
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2004-03-13 15:27:01 +00:00
|
|
|
ret = gst_structure_parse_value (s, &s, &list_value, type);
|
|
|
|
if (ret == FALSE)
|
|
|
|
return FALSE;
|
|
|
|
|
2003-12-22 01:39:35 +00:00
|
|
|
g_array_append_val (array, list_value);
|
2003-11-29 06:31:10 +00:00
|
|
|
|
2004-03-13 15:27:01 +00:00
|
|
|
while (g_ascii_isspace (*s))
|
|
|
|
s++;
|
|
|
|
|
2004-05-20 17:03:02 +00:00
|
|
|
while (*s != end) {
|
2004-03-13 15:27:01 +00:00
|
|
|
if (*s != ',')
|
|
|
|
return FALSE;
|
2003-11-29 06:31:10 +00:00
|
|
|
s++;
|
|
|
|
|
2004-03-13 15:27:01 +00:00
|
|
|
while (g_ascii_isspace (*s))
|
|
|
|
s++;
|
2003-11-29 06:31:10 +00:00
|
|
|
|
|
|
|
memset (&list_value, 0, sizeof (list_value));
|
2004-03-13 15:27:01 +00:00
|
|
|
ret = gst_structure_parse_value (s, &s, &list_value, type);
|
|
|
|
if (ret == FALSE)
|
|
|
|
return FALSE;
|
2003-11-29 06:31:10 +00:00
|
|
|
|
2003-12-22 01:39:35 +00:00
|
|
|
g_array_append_val (array, list_value);
|
2004-03-13 15:27:01 +00:00
|
|
|
while (g_ascii_isspace (*s))
|
|
|
|
s++;
|
2003-11-29 06:31:10 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
s++;
|
|
|
|
|
|
|
|
*after = s;
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2004-05-20 17:03:02 +00:00
|
|
|
static gboolean
|
|
|
|
gst_structure_parse_list (gchar * s, gchar ** after, GValue * value, GType type)
|
|
|
|
{
|
|
|
|
return gst_structure_parse_any_list (s, after, value, type, GST_TYPE_LIST,
|
|
|
|
'{', '}');
|
|
|
|
}
|
|
|
|
|
|
|
|
static gboolean
|
GstElement::new-pad -> pad-added, GstElement::state-change -> state-changed, GstValueFixedList -> GstValueArray, add ...
Original commit message from CVS:
* docs/manual/advanced-autoplugging.xml:
* docs/manual/basics-helloworld.xml:
* docs/manual/basics-pads.xml:
* docs/random/ds/0.9-suggested-changes:
* gst/gstelement.c: (gst_element_class_init), (gst_element_seek):
* gst/gstelement.h:
* gst/gstevent.h:
* gst/gstformat.h:
* gst/gstquery.h:
* gst/gststructure.c: (gst_structure_value_get_generic_type),
(gst_structure_parse_array), (gst_structure_parse_value):
* gst/gstvalue.c: (gst_type_is_fixed),
(gst_value_list_prepend_value), (gst_value_list_append_value),
(gst_value_list_get_size), (gst_value_list_get_value),
(gst_value_transform_array_string), (gst_value_serialize_array),
(gst_value_deserialize_array), (gst_value_intersect_array),
(gst_value_is_fixed), (_gst_value_initialize):
* gst/gstvalue.h:
GstElement::new-pad -> pad-added, GstElement::state-change ->
state-changed, GstValueFixedList -> GstValueArray, add format and
flags as their own arguments in gst_element_seek() (should improve
"bindeability"), remove function generators since they don't work
under a whole bunch of compilers (they were deprecated already
anyway).
2005-07-20 17:16:44 +00:00
|
|
|
gst_structure_parse_array (gchar * s, gchar ** after, GValue * value,
|
2004-05-20 17:03:02 +00:00
|
|
|
GType type)
|
|
|
|
{
|
|
|
|
return gst_structure_parse_any_list (s, after, value, type,
|
GstElement::new-pad -> pad-added, GstElement::state-change -> state-changed, GstValueFixedList -> GstValueArray, add ...
Original commit message from CVS:
* docs/manual/advanced-autoplugging.xml:
* docs/manual/basics-helloworld.xml:
* docs/manual/basics-pads.xml:
* docs/random/ds/0.9-suggested-changes:
* gst/gstelement.c: (gst_element_class_init), (gst_element_seek):
* gst/gstelement.h:
* gst/gstevent.h:
* gst/gstformat.h:
* gst/gstquery.h:
* gst/gststructure.c: (gst_structure_value_get_generic_type),
(gst_structure_parse_array), (gst_structure_parse_value):
* gst/gstvalue.c: (gst_type_is_fixed),
(gst_value_list_prepend_value), (gst_value_list_append_value),
(gst_value_list_get_size), (gst_value_list_get_value),
(gst_value_transform_array_string), (gst_value_serialize_array),
(gst_value_deserialize_array), (gst_value_intersect_array),
(gst_value_is_fixed), (_gst_value_initialize):
* gst/gstvalue.h:
GstElement::new-pad -> pad-added, GstElement::state-change ->
state-changed, GstValueFixedList -> GstValueArray, add format and
flags as their own arguments in gst_element_seek() (should improve
"bindeability"), remove function generators since they don't work
under a whole bunch of compilers (they were deprecated already
anyway).
2005-07-20 17:16:44 +00:00
|
|
|
GST_TYPE_ARRAY, '<', '>');
|
2004-05-20 17:03:02 +00:00
|
|
|
}
|
|
|
|
|
2003-12-22 01:39:35 +00:00
|
|
|
static gboolean
|
2004-03-13 15:27:01 +00:00
|
|
|
gst_structure_parse_simple_string (gchar * str, gchar ** end)
|
2003-12-22 01:39:35 +00:00
|
|
|
{
|
|
|
|
char *s = str;
|
|
|
|
|
2004-03-13 15:27:01 +00:00
|
|
|
while (GST_ASCII_IS_STRING (*s)) {
|
2003-12-22 01:39:35 +00:00
|
|
|
s++;
|
|
|
|
}
|
|
|
|
|
|
|
|
*end = s;
|
|
|
|
|
|
|
|
return (s != str);
|
|
|
|
}
|
|
|
|
|
2003-11-29 06:31:10 +00:00
|
|
|
static gboolean
|
2004-03-13 15:27:01 +00:00
|
|
|
gst_structure_parse_field (gchar * str,
|
|
|
|
gchar ** after, GstStructureField * field)
|
2003-11-29 06:31:10 +00:00
|
|
|
{
|
|
|
|
gchar *name;
|
2003-12-22 01:39:35 +00:00
|
|
|
gchar *name_end;
|
|
|
|
gchar *s;
|
|
|
|
gchar c;
|
2003-11-29 06:31:10 +00:00
|
|
|
|
2003-12-22 01:39:35 +00:00
|
|
|
s = str;
|
|
|
|
|
2005-11-10 12:32:57 +00:00
|
|
|
while (g_ascii_isspace (*s) || (s[0] == '\\' && g_ascii_isspace (s[1])))
|
2004-03-13 15:27:01 +00:00
|
|
|
s++;
|
2003-12-22 01:39:35 +00:00
|
|
|
name = s;
|
2004-03-13 15:27:01 +00:00
|
|
|
if (!gst_structure_parse_simple_string (s, &name_end))
|
|
|
|
return FALSE;
|
2003-12-22 01:39:35 +00:00
|
|
|
|
|
|
|
s = name_end;
|
2005-11-10 12:32:57 +00:00
|
|
|
while (g_ascii_isspace (*s) || (s[0] == '\\' && g_ascii_isspace (s[1])))
|
2004-03-13 15:27:01 +00:00
|
|
|
s++;
|
2003-12-22 01:39:35 +00:00
|
|
|
|
2004-03-13 15:27:01 +00:00
|
|
|
if (*s != '=')
|
|
|
|
return FALSE;
|
2003-11-29 06:31:10 +00:00
|
|
|
s++;
|
|
|
|
|
2003-12-22 01:39:35 +00:00
|
|
|
c = *name_end;
|
|
|
|
*name_end = 0;
|
2003-11-29 06:31:10 +00:00
|
|
|
field->name = g_quark_from_string (name);
|
2003-12-22 01:39:35 +00:00
|
|
|
*name_end = c;
|
2003-11-29 06:31:10 +00:00
|
|
|
|
2004-03-12 19:35:40 +00:00
|
|
|
if (!gst_structure_parse_value (s, &s, &field->value, G_TYPE_INVALID))
|
2003-12-22 01:39:35 +00:00
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
*after = s;
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static gboolean
|
2004-03-13 15:27:01 +00:00
|
|
|
gst_structure_parse_value (gchar * str,
|
|
|
|
gchar ** after, GValue * value, GType default_type)
|
2003-12-22 01:39:35 +00:00
|
|
|
{
|
|
|
|
gchar *type_name;
|
|
|
|
gchar *type_end;
|
|
|
|
gchar *value_s;
|
|
|
|
gchar *value_end;
|
|
|
|
gchar *s;
|
|
|
|
gchar c;
|
2004-01-07 13:13:03 +00:00
|
|
|
int ret = 0;
|
2003-12-22 01:39:35 +00:00
|
|
|
GType type = default_type;
|
|
|
|
|
|
|
|
|
|
|
|
s = str;
|
2004-03-13 15:27:01 +00:00
|
|
|
while (g_ascii_isspace (*s))
|
|
|
|
s++;
|
2003-12-22 01:39:35 +00:00
|
|
|
|
2006-05-10 14:12:14 +00:00
|
|
|
/* check if there's a (type_name) 'cast' */
|
2003-12-22 01:39:35 +00:00
|
|
|
type_name = NULL;
|
|
|
|
if (*s == '(') {
|
|
|
|
type = G_TYPE_INVALID;
|
|
|
|
|
|
|
|
s++;
|
2004-03-13 15:27:01 +00:00
|
|
|
while (g_ascii_isspace (*s))
|
|
|
|
s++;
|
2003-11-29 06:31:10 +00:00
|
|
|
type_name = s;
|
2004-03-13 15:27:01 +00:00
|
|
|
if (!gst_structure_parse_simple_string (s, &type_end))
|
|
|
|
return FALSE;
|
2003-12-22 01:39:35 +00:00
|
|
|
s = type_end;
|
2004-03-13 15:27:01 +00:00
|
|
|
while (g_ascii_isspace (*s))
|
|
|
|
s++;
|
|
|
|
if (*s != ')')
|
|
|
|
return FALSE;
|
2003-11-29 06:31:10 +00:00
|
|
|
s++;
|
2004-03-13 15:27:01 +00:00
|
|
|
while (g_ascii_isspace (*s))
|
|
|
|
s++;
|
2003-12-22 01:39:35 +00:00
|
|
|
|
|
|
|
c = *type_end;
|
|
|
|
*type_end = 0;
|
2006-05-10 14:12:14 +00:00
|
|
|
type = gst_structure_gtype_from_abbr (type_name);
|
2003-12-22 01:39:35 +00:00
|
|
|
*type_end = c;
|
2003-11-29 06:31:10 +00:00
|
|
|
|
2004-03-13 15:27:01 +00:00
|
|
|
if (type == G_TYPE_INVALID)
|
|
|
|
return FALSE;
|
2003-11-29 06:31:10 +00:00
|
|
|
}
|
|
|
|
|
2004-03-13 15:27:01 +00:00
|
|
|
while (g_ascii_isspace (*s))
|
|
|
|
s++;
|
2003-11-29 06:31:10 +00:00
|
|
|
if (*s == '[') {
|
2004-03-12 19:35:40 +00:00
|
|
|
ret = gst_structure_parse_range (s, &s, value, type);
|
2003-12-22 01:39:35 +00:00
|
|
|
} else if (*s == '{') {
|
2004-03-12 19:35:40 +00:00
|
|
|
ret = gst_structure_parse_list (s, &s, value, type);
|
2004-05-20 17:03:02 +00:00
|
|
|
} else if (*s == '<') {
|
GstElement::new-pad -> pad-added, GstElement::state-change -> state-changed, GstValueFixedList -> GstValueArray, add ...
Original commit message from CVS:
* docs/manual/advanced-autoplugging.xml:
* docs/manual/basics-helloworld.xml:
* docs/manual/basics-pads.xml:
* docs/random/ds/0.9-suggested-changes:
* gst/gstelement.c: (gst_element_class_init), (gst_element_seek):
* gst/gstelement.h:
* gst/gstevent.h:
* gst/gstformat.h:
* gst/gstquery.h:
* gst/gststructure.c: (gst_structure_value_get_generic_type),
(gst_structure_parse_array), (gst_structure_parse_value):
* gst/gstvalue.c: (gst_type_is_fixed),
(gst_value_list_prepend_value), (gst_value_list_append_value),
(gst_value_list_get_size), (gst_value_list_get_value),
(gst_value_transform_array_string), (gst_value_serialize_array),
(gst_value_deserialize_array), (gst_value_intersect_array),
(gst_value_is_fixed), (_gst_value_initialize):
* gst/gstvalue.h:
GstElement::new-pad -> pad-added, GstElement::state-change ->
state-changed, GstValueFixedList -> GstValueArray, add format and
flags as their own arguments in gst_element_seek() (should improve
"bindeability"), remove function generators since they don't work
under a whole bunch of compilers (they were deprecated already
anyway).
2005-07-20 17:16:44 +00:00
|
|
|
ret = gst_structure_parse_array (s, &s, value, type);
|
2003-11-29 06:31:10 +00:00
|
|
|
} else {
|
2003-12-22 01:39:35 +00:00
|
|
|
value_s = s;
|
2004-03-13 15:27:01 +00:00
|
|
|
if (!gst_structure_parse_string (s, &value_end, &s))
|
|
|
|
return FALSE;
|
2003-12-22 01:39:35 +00:00
|
|
|
|
|
|
|
c = *value_end;
|
|
|
|
*value_end = 0;
|
|
|
|
if (type == G_TYPE_INVALID) {
|
2005-11-22 12:35:42 +00:00
|
|
|
GType try_types[] =
|
2007-07-08 14:11:53 +00:00
|
|
|
{ G_TYPE_INT, G_TYPE_DOUBLE, GST_TYPE_FRACTION, G_TYPE_BOOLEAN,
|
|
|
|
G_TYPE_STRING
|
|
|
|
};
|
2003-12-22 01:39:35 +00:00
|
|
|
int i;
|
|
|
|
|
2007-07-08 14:11:53 +00:00
|
|
|
for (i = 0; i < G_N_ELEMENTS (try_types); i++) {
|
2004-03-15 19:27:17 +00:00
|
|
|
g_value_init (value, try_types[i]);
|
|
|
|
ret = gst_value_deserialize (value, value_s);
|
|
|
|
if (ret)
|
|
|
|
break;
|
|
|
|
g_value_unset (value);
|
2003-12-22 01:39:35 +00:00
|
|
|
}
|
|
|
|
} else {
|
2004-03-13 15:27:01 +00:00
|
|
|
g_value_init (value, type);
|
2003-12-22 01:39:35 +00:00
|
|
|
|
configure.ac: Add detection for HAVE_PRINTF_EXTENSION and
Original commit message from CVS:
* configure.ac: Add detection for HAVE_PRINTF_EXTENSION and
GST_PRINTF_EXTENSION_FORMAT_DEFINE.
* docs/random/ds/0.9-suggested-changes: Notes from Company.
* gst/gstcaps.c: (gst_caps_to_string): Add comment.
* gst/gstconfig.h.in: Add define for GST_PTR_FORMAT
* gst/gstinfo.c: (_gst_debug_init), (gst_debug_print_object),
(gst_debug_log_default), (_gst_info_printf_extension),
(_gst_info_printf_extension_arginfo): Add printf extension.
* gst/gstinfo.h: remove G_GNUC_PRINTF, because it doesn't work with %P
* gst/gststructure.c: (gst_structure_to_string),
(_gst_structure_parse_value): Use gst_value_deserialize() and
remove old code.
* gst/gstvalue.c: (gst_value_deserialize_fourcc),
(gst_value_deserialize_boolean), (gst_strtoi),
(gst_value_deserialize_int), (gst_value_deserialize_double),
(gst_value_deserialize_string), (gst_value_deserialize): Implement
a bunch of deserialize functions and gst_value_deserialize.
* gst/gstvalue.h: er, _de_serialize, not unserialize
* testsuite/caps/string-conversions.c: (main): We don't currently
handle (float) in caps, so convert these to (double).
* testsuite/debug/Makefile.am: Add new test for the printf extension
* testsuite/debug/printf_extension.c: (main): same
2004-01-29 01:20:23 +00:00
|
|
|
ret = gst_value_deserialize (value, value_s);
|
2003-12-22 01:39:35 +00:00
|
|
|
}
|
|
|
|
*value_end = c;
|
2003-11-29 06:31:10 +00:00
|
|
|
}
|
2004-03-13 15:27:01 +00:00
|
|
|
|
2003-11-29 06:31:10 +00:00
|
|
|
*after = s;
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2003-11-03 09:10:07 +00:00
|
|
|
/**
|
|
|
|
* gst_structure_from_string:
|
2004-01-30 19:06:13 +00:00
|
|
|
* @string: a string representation of a #GstStructure.
|
2005-06-22 19:22:34 +00:00
|
|
|
* @end: pointer to store the end of the string in.
|
2003-11-03 09:10:07 +00:00
|
|
|
*
|
|
|
|
* Creates a #GstStructure from a string representation.
|
2005-06-22 19:22:34 +00:00
|
|
|
* If end is not NULL, a pointer to the place inside the given string
|
|
|
|
* where parsing ended will be returned.
|
|
|
|
*
|
2005-11-09 15:10:32 +00:00
|
|
|
* Returns: a new #GstStructure or NULL when the string could not
|
2007-12-08 12:54:53 +00:00
|
|
|
* be parsed. Free with gst_structure_free() after use.
|
2003-11-03 09:10:07 +00:00
|
|
|
*/
|
|
|
|
GstStructure *
|
2004-03-13 15:27:01 +00:00
|
|
|
gst_structure_from_string (const gchar * string, gchar ** end)
|
2003-11-03 09:10:07 +00:00
|
|
|
{
|
2003-11-29 06:31:10 +00:00
|
|
|
char *name;
|
|
|
|
char *copy;
|
|
|
|
char *w;
|
|
|
|
char *r;
|
|
|
|
char save;
|
2004-02-05 23:46:13 +00:00
|
|
|
GstStructure *structure = NULL;
|
2003-11-29 06:31:10 +00:00
|
|
|
GstStructureField field = { 0 };
|
2003-11-03 09:10:07 +00:00
|
|
|
|
2004-03-13 15:27:01 +00:00
|
|
|
g_return_val_if_fail (string != NULL, NULL);
|
2003-11-03 09:10:07 +00:00
|
|
|
|
2004-03-13 15:27:01 +00:00
|
|
|
copy = g_strdup (string);
|
2003-11-29 06:31:10 +00:00
|
|
|
r = copy;
|
2003-11-03 09:10:07 +00:00
|
|
|
|
2007-12-08 12:54:53 +00:00
|
|
|
/* skip spaces (FIXME: _isspace treats tabs and newlines as space!) */
|
2007-10-22 08:53:26 +00:00
|
|
|
while (*r && (g_ascii_isspace (*r) || (r[0] == '\\'
|
|
|
|
&& g_ascii_isspace (r[1]))))
|
|
|
|
r++;
|
|
|
|
|
2003-11-29 06:31:10 +00:00
|
|
|
name = r;
|
2007-10-15 11:19:36 +00:00
|
|
|
if (!gst_structure_parse_string (r, &w, &r)) {
|
|
|
|
GST_WARNING ("Failed to parse structure string");
|
2004-02-05 23:46:13 +00:00
|
|
|
goto error;
|
2007-10-15 11:19:36 +00:00
|
|
|
}
|
2004-03-13 15:27:01 +00:00
|
|
|
|
2003-11-29 06:31:10 +00:00
|
|
|
save = *w;
|
|
|
|
*w = 0;
|
2004-03-13 15:27:01 +00:00
|
|
|
structure = gst_structure_empty_new (name);
|
2003-11-29 06:31:10 +00:00
|
|
|
*w = save;
|
|
|
|
|
2007-12-08 12:54:53 +00:00
|
|
|
if (structure == NULL)
|
|
|
|
goto error;
|
|
|
|
|
2007-10-22 08:53:26 +00:00
|
|
|
do {
|
|
|
|
while (*r && (g_ascii_isspace (*r) || (r[0] == '\\'
|
|
|
|
&& g_ascii_isspace (r[1]))))
|
|
|
|
r++;
|
|
|
|
if (*r == ';') {
|
|
|
|
/* end of structure, get the next char and finish */
|
|
|
|
r++;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
if (*r == '\0') {
|
|
|
|
/* accept \0 as end delimiter */
|
|
|
|
break;
|
|
|
|
}
|
2007-10-15 11:19:36 +00:00
|
|
|
if (*r != ',') {
|
|
|
|
GST_WARNING ("Failed to find delimiter, r=%s", r);
|
2004-02-05 23:46:13 +00:00
|
|
|
goto error;
|
2007-10-15 11:19:36 +00:00
|
|
|
}
|
2003-11-29 06:31:10 +00:00
|
|
|
r++;
|
2005-11-10 12:32:57 +00:00
|
|
|
while (*r && (g_ascii_isspace (*r) || (r[0] == '\\'
|
|
|
|
&& g_ascii_isspace (r[1]))))
|
2004-03-13 15:27:01 +00:00
|
|
|
r++;
|
2003-11-29 06:31:10 +00:00
|
|
|
|
2004-03-13 15:27:01 +00:00
|
|
|
memset (&field, 0, sizeof (field));
|
2004-03-12 19:35:40 +00:00
|
|
|
if (!gst_structure_parse_field (r, &r, &field))
|
2004-02-05 23:46:13 +00:00
|
|
|
goto error;
|
2004-03-13 15:27:01 +00:00
|
|
|
gst_structure_set_field (structure, &field);
|
2007-10-22 08:53:26 +00:00
|
|
|
|
|
|
|
} while (TRUE);
|
2003-11-29 06:31:10 +00:00
|
|
|
|
2004-03-13 15:27:01 +00:00
|
|
|
if (end)
|
|
|
|
*end = (char *) string + (r - copy);
|
2008-03-03 10:07:21 +00:00
|
|
|
else if (*r)
|
|
|
|
g_warning ("gst_structure_from_string did not consume whole string,"
|
|
|
|
" but caller did not provide end pointer (\"%s\")", string);
|
2004-02-05 23:46:13 +00:00
|
|
|
|
|
|
|
g_free (copy);
|
2003-11-29 06:31:10 +00:00
|
|
|
return structure;
|
2004-02-05 23:46:13 +00:00
|
|
|
|
|
|
|
error:
|
|
|
|
if (structure)
|
|
|
|
gst_structure_free (structure);
|
|
|
|
g_free (copy);
|
|
|
|
return NULL;
|
2003-11-03 09:10:07 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2004-03-13 15:27:01 +00:00
|
|
|
gst_structure_transform_to_string (const GValue * src_value,
|
|
|
|
GValue * dest_value)
|
2003-11-03 09:10:07 +00:00
|
|
|
{
|
2004-03-13 15:27:01 +00:00
|
|
|
g_return_if_fail (src_value != NULL);
|
|
|
|
g_return_if_fail (dest_value != NULL);
|
2003-11-03 09:10:07 +00:00
|
|
|
|
|
|
|
dest_value->data[0].v_pointer =
|
2004-03-13 15:27:01 +00:00
|
|
|
gst_structure_to_string (src_value->data[0].v_pointer);
|
2003-11-03 09:10:07 +00:00
|
|
|
}
|
|
|
|
|
2004-03-12 19:35:40 +00:00
|
|
|
static GstStructure *
|
2004-03-13 15:27:01 +00:00
|
|
|
gst_structure_copy_conditional (const GstStructure * structure)
|
2003-11-03 09:10:07 +00:00
|
|
|
{
|
2004-03-13 15:27:01 +00:00
|
|
|
if (structure)
|
|
|
|
return gst_structure_copy (structure);
|
2004-02-18 05:26:59 +00:00
|
|
|
return NULL;
|
2003-11-03 09:10:07 +00:00
|
|
|
}
|
2005-03-07 18:27:42 +00:00
|
|
|
|
|
|
|
/* fixate utility functions */
|
|
|
|
|
|
|
|
/**
|
2005-11-21 14:28:21 +00:00
|
|
|
* gst_structure_fixate_field_nearest_int:
|
2005-03-07 18:27:42 +00:00
|
|
|
* @structure: a #GstStructure
|
|
|
|
* @field_name: a field in @structure
|
|
|
|
* @target: the target value of the fixation
|
|
|
|
*
|
|
|
|
* Fixates a #GstStructure by changing the given field to the nearest
|
|
|
|
* integer to @target that is a subset of the existing field.
|
|
|
|
*
|
|
|
|
* Returns: TRUE if the structure could be fixated
|
|
|
|
*/
|
|
|
|
gboolean
|
2005-11-21 14:28:21 +00:00
|
|
|
gst_structure_fixate_field_nearest_int (GstStructure * structure,
|
2005-03-07 18:27:42 +00:00
|
|
|
const char *field_name, int target)
|
|
|
|
{
|
|
|
|
const GValue *value;
|
|
|
|
|
|
|
|
g_return_val_if_fail (gst_structure_has_field (structure, field_name), FALSE);
|
|
|
|
g_return_val_if_fail (IS_MUTABLE (structure), FALSE);
|
|
|
|
|
|
|
|
value = gst_structure_get_value (structure, field_name);
|
|
|
|
|
|
|
|
if (G_VALUE_TYPE (value) == G_TYPE_INT) {
|
|
|
|
/* already fixed */
|
|
|
|
return FALSE;
|
|
|
|
} else if (G_VALUE_TYPE (value) == GST_TYPE_INT_RANGE) {
|
|
|
|
int x;
|
|
|
|
|
|
|
|
x = gst_value_get_int_range_min (value);
|
|
|
|
if (target < x)
|
|
|
|
target = x;
|
|
|
|
x = gst_value_get_int_range_max (value);
|
|
|
|
if (target > x)
|
|
|
|
target = x;
|
|
|
|
gst_structure_set (structure, field_name, G_TYPE_INT, target, NULL);
|
|
|
|
return TRUE;
|
|
|
|
} else if (G_VALUE_TYPE (value) == GST_TYPE_LIST) {
|
|
|
|
const GValue *list_value;
|
|
|
|
int i, n;
|
|
|
|
int best = 0;
|
|
|
|
int best_index = -1;
|
|
|
|
|
|
|
|
n = gst_value_list_get_size (value);
|
|
|
|
for (i = 0; i < n; i++) {
|
|
|
|
list_value = gst_value_list_get_value (value, i);
|
|
|
|
if (G_VALUE_TYPE (list_value) == G_TYPE_INT) {
|
|
|
|
int x = g_value_get_int (list_value);
|
|
|
|
|
|
|
|
if (best_index == -1 || (ABS (target - x) < ABS (target - best))) {
|
|
|
|
best_index = i;
|
|
|
|
best = x;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (best_index != -1) {
|
|
|
|
gst_structure_set (structure, field_name, G_TYPE_INT, best, NULL);
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2005-11-21 14:28:21 +00:00
|
|
|
* gst_structure_fixate_field_nearest_double:
|
2005-03-07 18:27:42 +00:00
|
|
|
* @structure: a #GstStructure
|
|
|
|
* @field_name: a field in @structure
|
|
|
|
* @target: the target value of the fixation
|
|
|
|
*
|
|
|
|
* Fixates a #GstStructure by changing the given field to the nearest
|
|
|
|
* double to @target that is a subset of the existing field.
|
|
|
|
*
|
|
|
|
* Returns: TRUE if the structure could be fixated
|
|
|
|
*/
|
|
|
|
gboolean
|
2005-11-21 14:28:21 +00:00
|
|
|
gst_structure_fixate_field_nearest_double (GstStructure * structure,
|
2005-03-07 18:27:42 +00:00
|
|
|
const char *field_name, double target)
|
|
|
|
{
|
|
|
|
const GValue *value;
|
|
|
|
|
|
|
|
g_return_val_if_fail (gst_structure_has_field (structure, field_name), FALSE);
|
|
|
|
g_return_val_if_fail (IS_MUTABLE (structure), FALSE);
|
|
|
|
|
|
|
|
value = gst_structure_get_value (structure, field_name);
|
|
|
|
|
|
|
|
if (G_VALUE_TYPE (value) == G_TYPE_DOUBLE) {
|
|
|
|
/* already fixed */
|
|
|
|
return FALSE;
|
|
|
|
} else if (G_VALUE_TYPE (value) == GST_TYPE_DOUBLE_RANGE) {
|
|
|
|
double x;
|
|
|
|
|
|
|
|
x = gst_value_get_double_range_min (value);
|
|
|
|
if (target < x)
|
|
|
|
target = x;
|
|
|
|
x = gst_value_get_double_range_max (value);
|
|
|
|
if (target > x)
|
|
|
|
target = x;
|
|
|
|
gst_structure_set (structure, field_name, G_TYPE_DOUBLE, target, NULL);
|
|
|
|
return TRUE;
|
|
|
|
} else if (G_VALUE_TYPE (value) == GST_TYPE_LIST) {
|
|
|
|
const GValue *list_value;
|
|
|
|
int i, n;
|
|
|
|
double best = 0;
|
|
|
|
int best_index = -1;
|
|
|
|
|
|
|
|
n = gst_value_list_get_size (value);
|
|
|
|
for (i = 0; i < n; i++) {
|
|
|
|
list_value = gst_value_list_get_value (value, i);
|
|
|
|
if (G_VALUE_TYPE (list_value) == G_TYPE_DOUBLE) {
|
|
|
|
double x = g_value_get_double (list_value);
|
|
|
|
|
|
|
|
if (best_index == -1 || (ABS (target - x) < ABS (target - best))) {
|
|
|
|
best_index = i;
|
|
|
|
best = x;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (best_index != -1) {
|
|
|
|
gst_structure_set (structure, field_name, G_TYPE_DOUBLE, best, NULL);
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
}
|
2005-08-23 11:38:28 +00:00
|
|
|
|
|
|
|
/**
|
2005-11-21 14:28:21 +00:00
|
|
|
* gst_structure_fixate_field_boolean:
|
2005-08-23 11:38:28 +00:00
|
|
|
* @structure: a #GstStructure
|
|
|
|
* @field_name: a field in @structure
|
|
|
|
* @target: the target value of the fixation
|
|
|
|
*
|
|
|
|
* Fixates a #GstStructure by changing the given @field_name field to the given
|
|
|
|
* @target boolean if that field is not fixed yet.
|
|
|
|
*
|
|
|
|
* Returns: TRUE if the structure could be fixated
|
|
|
|
*/
|
|
|
|
gboolean
|
2005-11-21 14:28:21 +00:00
|
|
|
gst_structure_fixate_field_boolean (GstStructure * structure,
|
2005-08-23 11:38:28 +00:00
|
|
|
const char *field_name, gboolean target)
|
|
|
|
{
|
|
|
|
const GValue *value;
|
|
|
|
|
|
|
|
g_return_val_if_fail (gst_structure_has_field (structure, field_name), FALSE);
|
|
|
|
g_return_val_if_fail (IS_MUTABLE (structure), FALSE);
|
|
|
|
|
|
|
|
value = gst_structure_get_value (structure, field_name);
|
|
|
|
|
|
|
|
if (G_VALUE_TYPE (value) == G_TYPE_BOOLEAN) {
|
|
|
|
/* already fixed */
|
|
|
|
return FALSE;
|
|
|
|
} else if (G_VALUE_TYPE (value) == GST_TYPE_LIST) {
|
|
|
|
const GValue *list_value;
|
|
|
|
int i, n;
|
|
|
|
int best = 0;
|
|
|
|
int best_index = -1;
|
|
|
|
|
|
|
|
n = gst_value_list_get_size (value);
|
|
|
|
for (i = 0; i < n; i++) {
|
|
|
|
list_value = gst_value_list_get_value (value, i);
|
|
|
|
if (G_VALUE_TYPE (list_value) == G_TYPE_BOOLEAN) {
|
|
|
|
gboolean x = g_value_get_boolean (list_value);
|
|
|
|
|
|
|
|
if (best_index == -1 || x == target) {
|
|
|
|
best_index = i;
|
|
|
|
best = x;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (best_index != -1) {
|
|
|
|
gst_structure_set (structure, field_name, G_TYPE_BOOLEAN, best, NULL);
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
return FALSE;
|
|
|
|
}
|
Implement fraction ranges and extend GstFraction to support arithmetic subtraction, as well as deserialization from i...
Original commit message from CVS:
* check/gst/capslist.h:
* check/gst/gstcaps.c: (GST_START_TEST):
* check/gst/gstvalue.c: (GST_START_TEST), (gst_value_suite):
* gst/gststructure.c: (gst_structure_parse_range),
(gst_structure_fixate_field_nearest_fraction):
* gst/gststructure.h:
* gst/gstvalue.c: (gst_value_init_fraction_range),
(gst_value_free_fraction_range), (gst_value_copy_fraction_range),
(gst_value_collect_fraction_range),
(gst_value_lcopy_fraction_range), (gst_value_set_fraction_range),
(gst_value_set_fraction_range_full),
(gst_value_get_fraction_range_min),
(gst_value_get_fraction_range_max),
(gst_value_serialize_fraction_range),
(gst_value_transform_fraction_range_string),
(gst_value_compare_fraction_range),
(gst_value_deserialize_fraction_range),
(gst_value_intersect_fraction_fraction_range),
(gst_value_intersect_fraction_range_fraction_range),
(gst_value_subtract_fraction_fraction_range),
(gst_value_subtract_fraction_range_fraction),
(gst_value_subtract_fraction_range_fraction_range),
(gst_value_collect_fraction), (gst_value_fraction_multiply),
(gst_value_fraction_subtract), (gst_value_deserialize_fraction),
(gst_value_transform_string_fraction), (_gst_value_initialize):
* gst/gstvalue.h:
Implement fraction ranges and extend GstFraction to support
arithmetic subtraction, as well as deserialization from integer
strings such as "100"
Add a testsuite as for int and double range set operations
2005-11-21 23:54:59 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* gst_structure_fixate_field_nearest_fraction:
|
|
|
|
* @structure: a #GstStructure
|
|
|
|
* @field_name: a field in @structure
|
2005-11-23 13:22:21 +00:00
|
|
|
* @target_numerator: The numerator of the target value of the fixation
|
|
|
|
* @target_denominator: The denominator of the target value of the fixation
|
Implement fraction ranges and extend GstFraction to support arithmetic subtraction, as well as deserialization from i...
Original commit message from CVS:
* check/gst/capslist.h:
* check/gst/gstcaps.c: (GST_START_TEST):
* check/gst/gstvalue.c: (GST_START_TEST), (gst_value_suite):
* gst/gststructure.c: (gst_structure_parse_range),
(gst_structure_fixate_field_nearest_fraction):
* gst/gststructure.h:
* gst/gstvalue.c: (gst_value_init_fraction_range),
(gst_value_free_fraction_range), (gst_value_copy_fraction_range),
(gst_value_collect_fraction_range),
(gst_value_lcopy_fraction_range), (gst_value_set_fraction_range),
(gst_value_set_fraction_range_full),
(gst_value_get_fraction_range_min),
(gst_value_get_fraction_range_max),
(gst_value_serialize_fraction_range),
(gst_value_transform_fraction_range_string),
(gst_value_compare_fraction_range),
(gst_value_deserialize_fraction_range),
(gst_value_intersect_fraction_fraction_range),
(gst_value_intersect_fraction_range_fraction_range),
(gst_value_subtract_fraction_fraction_range),
(gst_value_subtract_fraction_range_fraction),
(gst_value_subtract_fraction_range_fraction_range),
(gst_value_collect_fraction), (gst_value_fraction_multiply),
(gst_value_fraction_subtract), (gst_value_deserialize_fraction),
(gst_value_transform_string_fraction), (_gst_value_initialize):
* gst/gstvalue.h:
Implement fraction ranges and extend GstFraction to support
arithmetic subtraction, as well as deserialization from integer
strings such as "100"
Add a testsuite as for int and double range set operations
2005-11-21 23:54:59 +00:00
|
|
|
*
|
|
|
|
* Fixates a #GstStructure by changing the given field to the nearest
|
2005-11-23 13:22:21 +00:00
|
|
|
* fraction to @target_numerator/@target_denominator that is a subset
|
|
|
|
* of the existing field.
|
Implement fraction ranges and extend GstFraction to support arithmetic subtraction, as well as deserialization from i...
Original commit message from CVS:
* check/gst/capslist.h:
* check/gst/gstcaps.c: (GST_START_TEST):
* check/gst/gstvalue.c: (GST_START_TEST), (gst_value_suite):
* gst/gststructure.c: (gst_structure_parse_range),
(gst_structure_fixate_field_nearest_fraction):
* gst/gststructure.h:
* gst/gstvalue.c: (gst_value_init_fraction_range),
(gst_value_free_fraction_range), (gst_value_copy_fraction_range),
(gst_value_collect_fraction_range),
(gst_value_lcopy_fraction_range), (gst_value_set_fraction_range),
(gst_value_set_fraction_range_full),
(gst_value_get_fraction_range_min),
(gst_value_get_fraction_range_max),
(gst_value_serialize_fraction_range),
(gst_value_transform_fraction_range_string),
(gst_value_compare_fraction_range),
(gst_value_deserialize_fraction_range),
(gst_value_intersect_fraction_fraction_range),
(gst_value_intersect_fraction_range_fraction_range),
(gst_value_subtract_fraction_fraction_range),
(gst_value_subtract_fraction_range_fraction),
(gst_value_subtract_fraction_range_fraction_range),
(gst_value_collect_fraction), (gst_value_fraction_multiply),
(gst_value_fraction_subtract), (gst_value_deserialize_fraction),
(gst_value_transform_string_fraction), (_gst_value_initialize):
* gst/gstvalue.h:
Implement fraction ranges and extend GstFraction to support
arithmetic subtraction, as well as deserialization from integer
strings such as "100"
Add a testsuite as for int and double range set operations
2005-11-21 23:54:59 +00:00
|
|
|
*
|
|
|
|
* Returns: TRUE if the structure could be fixated
|
|
|
|
*/
|
|
|
|
gboolean
|
|
|
|
gst_structure_fixate_field_nearest_fraction (GstStructure * structure,
|
2005-11-23 13:22:21 +00:00
|
|
|
const char *field_name, const gint target_numerator,
|
|
|
|
const gint target_denominator)
|
Implement fraction ranges and extend GstFraction to support arithmetic subtraction, as well as deserialization from i...
Original commit message from CVS:
* check/gst/capslist.h:
* check/gst/gstcaps.c: (GST_START_TEST):
* check/gst/gstvalue.c: (GST_START_TEST), (gst_value_suite):
* gst/gststructure.c: (gst_structure_parse_range),
(gst_structure_fixate_field_nearest_fraction):
* gst/gststructure.h:
* gst/gstvalue.c: (gst_value_init_fraction_range),
(gst_value_free_fraction_range), (gst_value_copy_fraction_range),
(gst_value_collect_fraction_range),
(gst_value_lcopy_fraction_range), (gst_value_set_fraction_range),
(gst_value_set_fraction_range_full),
(gst_value_get_fraction_range_min),
(gst_value_get_fraction_range_max),
(gst_value_serialize_fraction_range),
(gst_value_transform_fraction_range_string),
(gst_value_compare_fraction_range),
(gst_value_deserialize_fraction_range),
(gst_value_intersect_fraction_fraction_range),
(gst_value_intersect_fraction_range_fraction_range),
(gst_value_subtract_fraction_fraction_range),
(gst_value_subtract_fraction_range_fraction),
(gst_value_subtract_fraction_range_fraction_range),
(gst_value_collect_fraction), (gst_value_fraction_multiply),
(gst_value_fraction_subtract), (gst_value_deserialize_fraction),
(gst_value_transform_string_fraction), (_gst_value_initialize):
* gst/gstvalue.h:
Implement fraction ranges and extend GstFraction to support
arithmetic subtraction, as well as deserialization from integer
strings such as "100"
Add a testsuite as for int and double range set operations
2005-11-21 23:54:59 +00:00
|
|
|
{
|
|
|
|
const GValue *value;
|
|
|
|
|
|
|
|
g_return_val_if_fail (gst_structure_has_field (structure, field_name), FALSE);
|
|
|
|
g_return_val_if_fail (IS_MUTABLE (structure), FALSE);
|
|
|
|
|
|
|
|
value = gst_structure_get_value (structure, field_name);
|
|
|
|
|
|
|
|
if (G_VALUE_TYPE (value) == GST_TYPE_FRACTION) {
|
|
|
|
/* already fixed */
|
|
|
|
return FALSE;
|
|
|
|
} else if (G_VALUE_TYPE (value) == GST_TYPE_FRACTION_RANGE) {
|
2005-11-23 13:22:21 +00:00
|
|
|
const GValue *x, *new_value;
|
|
|
|
GValue target = { 0 };
|
|
|
|
g_value_init (&target, GST_TYPE_FRACTION);
|
|
|
|
gst_value_set_fraction (&target, target_numerator, target_denominator);
|
Implement fraction ranges and extend GstFraction to support arithmetic subtraction, as well as deserialization from i...
Original commit message from CVS:
* check/gst/capslist.h:
* check/gst/gstcaps.c: (GST_START_TEST):
* check/gst/gstvalue.c: (GST_START_TEST), (gst_value_suite):
* gst/gststructure.c: (gst_structure_parse_range),
(gst_structure_fixate_field_nearest_fraction):
* gst/gststructure.h:
* gst/gstvalue.c: (gst_value_init_fraction_range),
(gst_value_free_fraction_range), (gst_value_copy_fraction_range),
(gst_value_collect_fraction_range),
(gst_value_lcopy_fraction_range), (gst_value_set_fraction_range),
(gst_value_set_fraction_range_full),
(gst_value_get_fraction_range_min),
(gst_value_get_fraction_range_max),
(gst_value_serialize_fraction_range),
(gst_value_transform_fraction_range_string),
(gst_value_compare_fraction_range),
(gst_value_deserialize_fraction_range),
(gst_value_intersect_fraction_fraction_range),
(gst_value_intersect_fraction_range_fraction_range),
(gst_value_subtract_fraction_fraction_range),
(gst_value_subtract_fraction_range_fraction),
(gst_value_subtract_fraction_range_fraction_range),
(gst_value_collect_fraction), (gst_value_fraction_multiply),
(gst_value_fraction_subtract), (gst_value_deserialize_fraction),
(gst_value_transform_string_fraction), (_gst_value_initialize):
* gst/gstvalue.h:
Implement fraction ranges and extend GstFraction to support
arithmetic subtraction, as well as deserialization from integer
strings such as "100"
Add a testsuite as for int and double range set operations
2005-11-21 23:54:59 +00:00
|
|
|
|
2005-11-23 13:22:21 +00:00
|
|
|
new_value = ⌖
|
Implement fraction ranges and extend GstFraction to support arithmetic subtraction, as well as deserialization from i...
Original commit message from CVS:
* check/gst/capslist.h:
* check/gst/gstcaps.c: (GST_START_TEST):
* check/gst/gstvalue.c: (GST_START_TEST), (gst_value_suite):
* gst/gststructure.c: (gst_structure_parse_range),
(gst_structure_fixate_field_nearest_fraction):
* gst/gststructure.h:
* gst/gstvalue.c: (gst_value_init_fraction_range),
(gst_value_free_fraction_range), (gst_value_copy_fraction_range),
(gst_value_collect_fraction_range),
(gst_value_lcopy_fraction_range), (gst_value_set_fraction_range),
(gst_value_set_fraction_range_full),
(gst_value_get_fraction_range_min),
(gst_value_get_fraction_range_max),
(gst_value_serialize_fraction_range),
(gst_value_transform_fraction_range_string),
(gst_value_compare_fraction_range),
(gst_value_deserialize_fraction_range),
(gst_value_intersect_fraction_fraction_range),
(gst_value_intersect_fraction_range_fraction_range),
(gst_value_subtract_fraction_fraction_range),
(gst_value_subtract_fraction_range_fraction),
(gst_value_subtract_fraction_range_fraction_range),
(gst_value_collect_fraction), (gst_value_fraction_multiply),
(gst_value_fraction_subtract), (gst_value_deserialize_fraction),
(gst_value_transform_string_fraction), (_gst_value_initialize):
* gst/gstvalue.h:
Implement fraction ranges and extend GstFraction to support
arithmetic subtraction, as well as deserialization from integer
strings such as "100"
Add a testsuite as for int and double range set operations
2005-11-21 23:54:59 +00:00
|
|
|
x = gst_value_get_fraction_range_min (value);
|
2005-11-23 13:22:21 +00:00
|
|
|
if (gst_value_compare (&target, x) == GST_VALUE_LESS_THAN)
|
|
|
|
new_value = x;
|
Implement fraction ranges and extend GstFraction to support arithmetic subtraction, as well as deserialization from i...
Original commit message from CVS:
* check/gst/capslist.h:
* check/gst/gstcaps.c: (GST_START_TEST):
* check/gst/gstvalue.c: (GST_START_TEST), (gst_value_suite):
* gst/gststructure.c: (gst_structure_parse_range),
(gst_structure_fixate_field_nearest_fraction):
* gst/gststructure.h:
* gst/gstvalue.c: (gst_value_init_fraction_range),
(gst_value_free_fraction_range), (gst_value_copy_fraction_range),
(gst_value_collect_fraction_range),
(gst_value_lcopy_fraction_range), (gst_value_set_fraction_range),
(gst_value_set_fraction_range_full),
(gst_value_get_fraction_range_min),
(gst_value_get_fraction_range_max),
(gst_value_serialize_fraction_range),
(gst_value_transform_fraction_range_string),
(gst_value_compare_fraction_range),
(gst_value_deserialize_fraction_range),
(gst_value_intersect_fraction_fraction_range),
(gst_value_intersect_fraction_range_fraction_range),
(gst_value_subtract_fraction_fraction_range),
(gst_value_subtract_fraction_range_fraction),
(gst_value_subtract_fraction_range_fraction_range),
(gst_value_collect_fraction), (gst_value_fraction_multiply),
(gst_value_fraction_subtract), (gst_value_deserialize_fraction),
(gst_value_transform_string_fraction), (_gst_value_initialize):
* gst/gstvalue.h:
Implement fraction ranges and extend GstFraction to support
arithmetic subtraction, as well as deserialization from integer
strings such as "100"
Add a testsuite as for int and double range set operations
2005-11-21 23:54:59 +00:00
|
|
|
x = gst_value_get_fraction_range_max (value);
|
2005-11-23 13:22:21 +00:00
|
|
|
if (gst_value_compare (&target, x) == GST_VALUE_GREATER_THAN)
|
|
|
|
new_value = x;
|
|
|
|
|
|
|
|
gst_structure_set_value (structure, field_name, new_value);
|
|
|
|
g_value_unset (&target);
|
Implement fraction ranges and extend GstFraction to support arithmetic subtraction, as well as deserialization from i...
Original commit message from CVS:
* check/gst/capslist.h:
* check/gst/gstcaps.c: (GST_START_TEST):
* check/gst/gstvalue.c: (GST_START_TEST), (gst_value_suite):
* gst/gststructure.c: (gst_structure_parse_range),
(gst_structure_fixate_field_nearest_fraction):
* gst/gststructure.h:
* gst/gstvalue.c: (gst_value_init_fraction_range),
(gst_value_free_fraction_range), (gst_value_copy_fraction_range),
(gst_value_collect_fraction_range),
(gst_value_lcopy_fraction_range), (gst_value_set_fraction_range),
(gst_value_set_fraction_range_full),
(gst_value_get_fraction_range_min),
(gst_value_get_fraction_range_max),
(gst_value_serialize_fraction_range),
(gst_value_transform_fraction_range_string),
(gst_value_compare_fraction_range),
(gst_value_deserialize_fraction_range),
(gst_value_intersect_fraction_fraction_range),
(gst_value_intersect_fraction_range_fraction_range),
(gst_value_subtract_fraction_fraction_range),
(gst_value_subtract_fraction_range_fraction),
(gst_value_subtract_fraction_range_fraction_range),
(gst_value_collect_fraction), (gst_value_fraction_multiply),
(gst_value_fraction_subtract), (gst_value_deserialize_fraction),
(gst_value_transform_string_fraction), (_gst_value_initialize):
* gst/gstvalue.h:
Implement fraction ranges and extend GstFraction to support
arithmetic subtraction, as well as deserialization from integer
strings such as "100"
Add a testsuite as for int and double range set operations
2005-11-21 23:54:59 +00:00
|
|
|
return TRUE;
|
|
|
|
} else if (G_VALUE_TYPE (value) == GST_TYPE_LIST) {
|
|
|
|
const GValue *list_value;
|
|
|
|
int i, n;
|
|
|
|
const GValue *best = NULL;
|
2008-08-05 15:03:27 +00:00
|
|
|
gdouble target;
|
|
|
|
gdouble cur_diff;
|
|
|
|
gdouble best_diff = G_MAXDOUBLE;
|
Implement fraction ranges and extend GstFraction to support arithmetic subtraction, as well as deserialization from i...
Original commit message from CVS:
* check/gst/capslist.h:
* check/gst/gstcaps.c: (GST_START_TEST):
* check/gst/gstvalue.c: (GST_START_TEST), (gst_value_suite):
* gst/gststructure.c: (gst_structure_parse_range),
(gst_structure_fixate_field_nearest_fraction):
* gst/gststructure.h:
* gst/gstvalue.c: (gst_value_init_fraction_range),
(gst_value_free_fraction_range), (gst_value_copy_fraction_range),
(gst_value_collect_fraction_range),
(gst_value_lcopy_fraction_range), (gst_value_set_fraction_range),
(gst_value_set_fraction_range_full),
(gst_value_get_fraction_range_min),
(gst_value_get_fraction_range_max),
(gst_value_serialize_fraction_range),
(gst_value_transform_fraction_range_string),
(gst_value_compare_fraction_range),
(gst_value_deserialize_fraction_range),
(gst_value_intersect_fraction_fraction_range),
(gst_value_intersect_fraction_range_fraction_range),
(gst_value_subtract_fraction_fraction_range),
(gst_value_subtract_fraction_range_fraction),
(gst_value_subtract_fraction_range_fraction_range),
(gst_value_collect_fraction), (gst_value_fraction_multiply),
(gst_value_fraction_subtract), (gst_value_deserialize_fraction),
(gst_value_transform_string_fraction), (_gst_value_initialize):
* gst/gstvalue.h:
Implement fraction ranges and extend GstFraction to support
arithmetic subtraction, as well as deserialization from integer
strings such as "100"
Add a testsuite as for int and double range set operations
2005-11-21 23:54:59 +00:00
|
|
|
|
2008-08-05 15:03:27 +00:00
|
|
|
target = (gdouble) target_numerator / (gdouble) target_denominator;
|
2005-11-23 13:22:21 +00:00
|
|
|
|
2008-08-05 15:03:27 +00:00
|
|
|
GST_DEBUG ("target %g, best %g", target, best_diff);
|
Implement fraction ranges and extend GstFraction to support arithmetic subtraction, as well as deserialization from i...
Original commit message from CVS:
* check/gst/capslist.h:
* check/gst/gstcaps.c: (GST_START_TEST):
* check/gst/gstvalue.c: (GST_START_TEST), (gst_value_suite):
* gst/gststructure.c: (gst_structure_parse_range),
(gst_structure_fixate_field_nearest_fraction):
* gst/gststructure.h:
* gst/gstvalue.c: (gst_value_init_fraction_range),
(gst_value_free_fraction_range), (gst_value_copy_fraction_range),
(gst_value_collect_fraction_range),
(gst_value_lcopy_fraction_range), (gst_value_set_fraction_range),
(gst_value_set_fraction_range_full),
(gst_value_get_fraction_range_min),
(gst_value_get_fraction_range_max),
(gst_value_serialize_fraction_range),
(gst_value_transform_fraction_range_string),
(gst_value_compare_fraction_range),
(gst_value_deserialize_fraction_range),
(gst_value_intersect_fraction_fraction_range),
(gst_value_intersect_fraction_range_fraction_range),
(gst_value_subtract_fraction_fraction_range),
(gst_value_subtract_fraction_range_fraction),
(gst_value_subtract_fraction_range_fraction_range),
(gst_value_collect_fraction), (gst_value_fraction_multiply),
(gst_value_fraction_subtract), (gst_value_deserialize_fraction),
(gst_value_transform_string_fraction), (_gst_value_initialize):
* gst/gstvalue.h:
Implement fraction ranges and extend GstFraction to support
arithmetic subtraction, as well as deserialization from integer
strings such as "100"
Add a testsuite as for int and double range set operations
2005-11-21 23:54:59 +00:00
|
|
|
|
2007-09-05 01:00:50 +00:00
|
|
|
best = NULL;
|
|
|
|
|
Implement fraction ranges and extend GstFraction to support arithmetic subtraction, as well as deserialization from i...
Original commit message from CVS:
* check/gst/capslist.h:
* check/gst/gstcaps.c: (GST_START_TEST):
* check/gst/gstvalue.c: (GST_START_TEST), (gst_value_suite):
* gst/gststructure.c: (gst_structure_parse_range),
(gst_structure_fixate_field_nearest_fraction):
* gst/gststructure.h:
* gst/gstvalue.c: (gst_value_init_fraction_range),
(gst_value_free_fraction_range), (gst_value_copy_fraction_range),
(gst_value_collect_fraction_range),
(gst_value_lcopy_fraction_range), (gst_value_set_fraction_range),
(gst_value_set_fraction_range_full),
(gst_value_get_fraction_range_min),
(gst_value_get_fraction_range_max),
(gst_value_serialize_fraction_range),
(gst_value_transform_fraction_range_string),
(gst_value_compare_fraction_range),
(gst_value_deserialize_fraction_range),
(gst_value_intersect_fraction_fraction_range),
(gst_value_intersect_fraction_range_fraction_range),
(gst_value_subtract_fraction_fraction_range),
(gst_value_subtract_fraction_range_fraction),
(gst_value_subtract_fraction_range_fraction_range),
(gst_value_collect_fraction), (gst_value_fraction_multiply),
(gst_value_fraction_subtract), (gst_value_deserialize_fraction),
(gst_value_transform_string_fraction), (_gst_value_initialize):
* gst/gstvalue.h:
Implement fraction ranges and extend GstFraction to support
arithmetic subtraction, as well as deserialization from integer
strings such as "100"
Add a testsuite as for int and double range set operations
2005-11-21 23:54:59 +00:00
|
|
|
n = gst_value_list_get_size (value);
|
|
|
|
for (i = 0; i < n; i++) {
|
|
|
|
list_value = gst_value_list_get_value (value, i);
|
|
|
|
if (G_VALUE_TYPE (list_value) == GST_TYPE_FRACTION) {
|
2008-08-05 15:03:27 +00:00
|
|
|
gint num, denom;
|
|
|
|
gdouble list_double;
|
|
|
|
|
|
|
|
num = gst_value_get_fraction_numerator (list_value);
|
|
|
|
denom = gst_value_get_fraction_denominator (list_value);
|
|
|
|
|
|
|
|
list_double = ((gdouble) num / (gdouble) denom);
|
|
|
|
cur_diff = target - list_double;
|
2007-09-05 01:00:50 +00:00
|
|
|
|
2008-08-05 15:03:27 +00:00
|
|
|
GST_DEBUG ("curr diff %g, list %g", cur_diff, list_double);
|
2007-09-05 01:00:50 +00:00
|
|
|
|
2008-08-05 15:03:27 +00:00
|
|
|
if (cur_diff < 0)
|
|
|
|
cur_diff = -cur_diff;
|
|
|
|
|
|
|
|
if (!best || cur_diff < best_diff) {
|
|
|
|
GST_DEBUG ("new best %g", list_double);
|
Implement fraction ranges and extend GstFraction to support arithmetic subtraction, as well as deserialization from i...
Original commit message from CVS:
* check/gst/capslist.h:
* check/gst/gstcaps.c: (GST_START_TEST):
* check/gst/gstvalue.c: (GST_START_TEST), (gst_value_suite):
* gst/gststructure.c: (gst_structure_parse_range),
(gst_structure_fixate_field_nearest_fraction):
* gst/gststructure.h:
* gst/gstvalue.c: (gst_value_init_fraction_range),
(gst_value_free_fraction_range), (gst_value_copy_fraction_range),
(gst_value_collect_fraction_range),
(gst_value_lcopy_fraction_range), (gst_value_set_fraction_range),
(gst_value_set_fraction_range_full),
(gst_value_get_fraction_range_min),
(gst_value_get_fraction_range_max),
(gst_value_serialize_fraction_range),
(gst_value_transform_fraction_range_string),
(gst_value_compare_fraction_range),
(gst_value_deserialize_fraction_range),
(gst_value_intersect_fraction_fraction_range),
(gst_value_intersect_fraction_range_fraction_range),
(gst_value_subtract_fraction_fraction_range),
(gst_value_subtract_fraction_range_fraction),
(gst_value_subtract_fraction_range_fraction_range),
(gst_value_collect_fraction), (gst_value_fraction_multiply),
(gst_value_fraction_subtract), (gst_value_deserialize_fraction),
(gst_value_transform_string_fraction), (_gst_value_initialize):
* gst/gstvalue.h:
Implement fraction ranges and extend GstFraction to support
arithmetic subtraction, as well as deserialization from integer
strings such as "100"
Add a testsuite as for int and double range set operations
2005-11-21 23:54:59 +00:00
|
|
|
best = list_value;
|
2008-08-05 15:03:27 +00:00
|
|
|
best_diff = cur_diff;
|
Implement fraction ranges and extend GstFraction to support arithmetic subtraction, as well as deserialization from i...
Original commit message from CVS:
* check/gst/capslist.h:
* check/gst/gstcaps.c: (GST_START_TEST):
* check/gst/gstvalue.c: (GST_START_TEST), (gst_value_suite):
* gst/gststructure.c: (gst_structure_parse_range),
(gst_structure_fixate_field_nearest_fraction):
* gst/gststructure.h:
* gst/gstvalue.c: (gst_value_init_fraction_range),
(gst_value_free_fraction_range), (gst_value_copy_fraction_range),
(gst_value_collect_fraction_range),
(gst_value_lcopy_fraction_range), (gst_value_set_fraction_range),
(gst_value_set_fraction_range_full),
(gst_value_get_fraction_range_min),
(gst_value_get_fraction_range_max),
(gst_value_serialize_fraction_range),
(gst_value_transform_fraction_range_string),
(gst_value_compare_fraction_range),
(gst_value_deserialize_fraction_range),
(gst_value_intersect_fraction_fraction_range),
(gst_value_intersect_fraction_range_fraction_range),
(gst_value_subtract_fraction_fraction_range),
(gst_value_subtract_fraction_range_fraction),
(gst_value_subtract_fraction_range_fraction_range),
(gst_value_collect_fraction), (gst_value_fraction_multiply),
(gst_value_fraction_subtract), (gst_value_deserialize_fraction),
(gst_value_transform_string_fraction), (_gst_value_initialize):
* gst/gstvalue.h:
Implement fraction ranges and extend GstFraction to support
arithmetic subtraction, as well as deserialization from integer
strings such as "100"
Add a testsuite as for int and double range set operations
2005-11-21 23:54:59 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (best != NULL) {
|
|
|
|
gst_structure_set_value (structure, field_name, best);
|
2008-08-05 15:03:27 +00:00
|
|
|
return TRUE;
|
Implement fraction ranges and extend GstFraction to support arithmetic subtraction, as well as deserialization from i...
Original commit message from CVS:
* check/gst/capslist.h:
* check/gst/gstcaps.c: (GST_START_TEST):
* check/gst/gstvalue.c: (GST_START_TEST), (gst_value_suite):
* gst/gststructure.c: (gst_structure_parse_range),
(gst_structure_fixate_field_nearest_fraction):
* gst/gststructure.h:
* gst/gstvalue.c: (gst_value_init_fraction_range),
(gst_value_free_fraction_range), (gst_value_copy_fraction_range),
(gst_value_collect_fraction_range),
(gst_value_lcopy_fraction_range), (gst_value_set_fraction_range),
(gst_value_set_fraction_range_full),
(gst_value_get_fraction_range_min),
(gst_value_get_fraction_range_max),
(gst_value_serialize_fraction_range),
(gst_value_transform_fraction_range_string),
(gst_value_compare_fraction_range),
(gst_value_deserialize_fraction_range),
(gst_value_intersect_fraction_fraction_range),
(gst_value_intersect_fraction_range_fraction_range),
(gst_value_subtract_fraction_fraction_range),
(gst_value_subtract_fraction_range_fraction),
(gst_value_subtract_fraction_range_fraction_range),
(gst_value_collect_fraction), (gst_value_fraction_multiply),
(gst_value_fraction_subtract), (gst_value_deserialize_fraction),
(gst_value_transform_string_fraction), (_gst_value_initialize):
* gst/gstvalue.h:
Implement fraction ranges and extend GstFraction to support
arithmetic subtraction, as well as deserialization from integer
strings such as "100"
Add a testsuite as for int and double range set operations
2005-11-21 23:54:59 +00:00
|
|
|
}
|
|
|
|
}
|
2008-08-05 15:03:27 +00:00
|
|
|
|
Implement fraction ranges and extend GstFraction to support arithmetic subtraction, as well as deserialization from i...
Original commit message from CVS:
* check/gst/capslist.h:
* check/gst/gstcaps.c: (GST_START_TEST):
* check/gst/gstvalue.c: (GST_START_TEST), (gst_value_suite):
* gst/gststructure.c: (gst_structure_parse_range),
(gst_structure_fixate_field_nearest_fraction):
* gst/gststructure.h:
* gst/gstvalue.c: (gst_value_init_fraction_range),
(gst_value_free_fraction_range), (gst_value_copy_fraction_range),
(gst_value_collect_fraction_range),
(gst_value_lcopy_fraction_range), (gst_value_set_fraction_range),
(gst_value_set_fraction_range_full),
(gst_value_get_fraction_range_min),
(gst_value_get_fraction_range_max),
(gst_value_serialize_fraction_range),
(gst_value_transform_fraction_range_string),
(gst_value_compare_fraction_range),
(gst_value_deserialize_fraction_range),
(gst_value_intersect_fraction_fraction_range),
(gst_value_intersect_fraction_range_fraction_range),
(gst_value_subtract_fraction_fraction_range),
(gst_value_subtract_fraction_range_fraction),
(gst_value_subtract_fraction_range_fraction_range),
(gst_value_collect_fraction), (gst_value_fraction_multiply),
(gst_value_fraction_subtract), (gst_value_deserialize_fraction),
(gst_value_transform_string_fraction), (_gst_value_initialize):
* gst/gstvalue.h:
Implement fraction ranges and extend GstFraction to support
arithmetic subtraction, as well as deserialization from integer
strings such as "100"
Add a testsuite as for int and double range set operations
2005-11-21 23:54:59 +00:00
|
|
|
return FALSE;
|
|
|
|
}
|