mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-11-26 11:41:09 +00:00
add IN_CAPS buffer flag; add GST_TYPE_FIXED_LIST + functions
Original commit message from CVS: add IN_CAPS buffer flag; add GST_TYPE_FIXED_LIST + functions
This commit is contained in:
parent
ee5d8e7dd8
commit
3e4573c20e
7 changed files with 180 additions and 51 deletions
24
ChangeLog
24
ChangeLog
|
@ -1,3 +1,27 @@
|
|||
2004-05-20 Thomas Vander Stichele <thomas at apestaart dot org>
|
||||
|
||||
reviewed by: Wim Taymans <wim at fluendo dot com>
|
||||
|
||||
* gst/gstbuffer.h:
|
||||
add GST_BUFFER_IN_CAPS buffer flag
|
||||
* gst/gststructure.c: (gst_structure_value_get_generic_type),
|
||||
(gst_structure_parse_any_list), (gst_structure_parse_list),
|
||||
(gst_structure_parse_fixed_list), (gst_structure_parse_value):
|
||||
* gst/gstvalue.c: (gst_value_serialize_any_list),
|
||||
(gst_value_transform_any_list_string),
|
||||
(gst_value_list_prepend_value), (gst_value_list_append_value),
|
||||
(gst_value_list_get_size), (gst_value_list_get_value),
|
||||
(gst_value_transform_list_string),
|
||||
(gst_value_transform_fixed_list_string),
|
||||
(gst_value_serialize_list), (gst_value_serialize_fixed_list),
|
||||
(gst_value_deserialize_fixed_list), (gst_type_is_fixed),
|
||||
(_gst_value_initialize):
|
||||
* gst/gstvalue.h:
|
||||
add a GST_TYPE_FIXED_LIST which is fixed by definition and uses
|
||||
< , > as a format.
|
||||
* testsuite/caps/string-conversions.c: (main):
|
||||
add regression tests for < >
|
||||
|
||||
2004-05-20 Johan Dahlin <johan@gnome.org>
|
||||
|
||||
* docs/gst/Makefile.am (all-local): Re-add
|
||||
|
|
|
@ -80,6 +80,7 @@ typedef enum {
|
|||
GST_BUFFER_DONTFREE,
|
||||
GST_BUFFER_KEY_UNIT,
|
||||
GST_BUFFER_DONTKEEP,
|
||||
GST_BUFFER_IN_CAPS,
|
||||
GST_BUFFER_FLAG_LAST = GST_DATA_FLAG_LAST + 8
|
||||
} GstBufferFlag;
|
||||
|
||||
|
|
|
@ -1044,7 +1044,8 @@ gst_structure_to_abbr (GType type)
|
|||
static GType
|
||||
gst_structure_value_get_generic_type (GValue * val)
|
||||
{
|
||||
if (G_VALUE_TYPE (val) == GST_TYPE_LIST) {
|
||||
if (G_VALUE_TYPE (val) == GST_TYPE_LIST
|
||||
|| G_VALUE_TYPE (val) == GST_TYPE_FIXED_LIST) {
|
||||
GArray *array = g_value_peek_pointer (val);
|
||||
|
||||
if (array->len > 0) {
|
||||
|
@ -1218,22 +1219,23 @@ gst_structure_parse_range (gchar * s, gchar ** after, GValue * value,
|
|||
}
|
||||
|
||||
static gboolean
|
||||
gst_structure_parse_list (gchar * s, gchar ** after, GValue * value, GType type)
|
||||
gst_structure_parse_any_list (gchar * s, gchar ** after, GValue * value,
|
||||
GType type, GType list_type, char begin, char end)
|
||||
{
|
||||
GValue list_value = { 0 };
|
||||
gboolean ret;
|
||||
GArray *array;
|
||||
|
||||
g_value_init (value, GST_TYPE_LIST);
|
||||
g_value_init (value, list_type);
|
||||
array = g_value_peek_pointer (value);
|
||||
|
||||
if (*s != '{')
|
||||
if (*s != begin)
|
||||
return FALSE;
|
||||
s++;
|
||||
|
||||
while (g_ascii_isspace (*s))
|
||||
s++;
|
||||
if (*s == '}') {
|
||||
if (*s == end) {
|
||||
s++;
|
||||
*after = s;
|
||||
return TRUE;
|
||||
|
@ -1248,7 +1250,7 @@ gst_structure_parse_list (gchar * s, gchar ** after, GValue * value, GType type)
|
|||
while (g_ascii_isspace (*s))
|
||||
s++;
|
||||
|
||||
while (*s != '}') {
|
||||
while (*s != end) {
|
||||
if (*s != ',')
|
||||
return FALSE;
|
||||
s++;
|
||||
|
@ -1272,6 +1274,21 @@ gst_structure_parse_list (gchar * s, gchar ** after, GValue * value, GType type)
|
|||
return TRUE;
|
||||
}
|
||||
|
||||
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
|
||||
gst_structure_parse_fixed_list (gchar * s, gchar ** after, GValue * value,
|
||||
GType type)
|
||||
{
|
||||
return gst_structure_parse_any_list (s, after, value, type,
|
||||
GST_TYPE_FIXED_LIST, '<', '>');
|
||||
}
|
||||
|
||||
static gboolean
|
||||
gst_structure_parse_simple_string (gchar * str, gchar ** end)
|
||||
{
|
||||
|
@ -1375,6 +1392,8 @@ gst_structure_parse_value (gchar * str,
|
|||
ret = gst_structure_parse_range (s, &s, value, type);
|
||||
} else if (*s == '{') {
|
||||
ret = gst_structure_parse_list (s, &s, value, type);
|
||||
} else if (*s == '<') {
|
||||
ret = gst_structure_parse_fixed_list (s, &s, value, type);
|
||||
} else {
|
||||
value_s = s;
|
||||
if (!gst_structure_parse_string (s, &value_end, &s))
|
||||
|
|
162
gst/gstvalue.c
162
gst/gstvalue.c
|
@ -57,15 +57,73 @@ GType gst_type_fourcc;
|
|||
GType gst_type_int_range;
|
||||
GType gst_type_double_range;
|
||||
GType gst_type_list;
|
||||
GType gst_type_fixed_list;
|
||||
|
||||
static GArray *gst_value_table;
|
||||
static GArray *gst_value_union_funcs;
|
||||
static GArray *gst_value_intersect_funcs;
|
||||
static GArray *gst_value_subtract_funcs;
|
||||
|
||||
/*************************************/
|
||||
/********/
|
||||
/* list */
|
||||
/********/
|
||||
|
||||
/* two helper functions to serialize/stringify any type of list
|
||||
* regular lists are done with { }, fixed lists with < >
|
||||
*/
|
||||
static char *
|
||||
gst_value_serialize_any_list (const GValue * value, const char *begin,
|
||||
const char *end)
|
||||
{
|
||||
int i;
|
||||
GArray *array = value->data[0].v_pointer;
|
||||
GString *s;
|
||||
GValue *v;
|
||||
gchar *s_val;
|
||||
|
||||
s = g_string_new (begin);
|
||||
for (i = 0; i < array->len; i++) {
|
||||
v = &g_array_index (array, GValue, i);
|
||||
s_val = gst_value_serialize (v);
|
||||
g_string_append (s, s_val);
|
||||
g_free (s_val);
|
||||
if (i < array->len - 1) {
|
||||
g_string_append (s, ", ");
|
||||
}
|
||||
}
|
||||
g_string_append (s, end);
|
||||
return g_string_free (s, FALSE);
|
||||
}
|
||||
|
||||
static void
|
||||
gst_value_transform_any_list_string (const GValue * src_value,
|
||||
GValue * dest_value, const char *begin, const char *end)
|
||||
{
|
||||
GValue *list_value;
|
||||
GArray *array;
|
||||
GString *s;
|
||||
int i;
|
||||
char *list_s;
|
||||
|
||||
array = src_value->data[0].v_pointer;
|
||||
|
||||
s = g_string_new (begin);
|
||||
for (i = 0; i < array->len; i++) {
|
||||
list_value = &g_array_index (array, GValue, i);
|
||||
|
||||
if (i != 0) {
|
||||
g_string_append (s, ", ");
|
||||
}
|
||||
list_s = g_strdup_value_contents (list_value);
|
||||
g_string_append (s, list_s);
|
||||
g_free (list_s);
|
||||
}
|
||||
g_string_append (s, end);
|
||||
|
||||
dest_value->data[0].v_pointer = g_string_free (s, FALSE);
|
||||
}
|
||||
|
||||
/* GValue functions usable for both regular lists and fixed lists */
|
||||
static void
|
||||
gst_value_init_list (GValue * value)
|
||||
{
|
||||
|
@ -162,7 +220,8 @@ gst_value_list_prepend_value (GValue * value, const GValue * prepend_value)
|
|||
{
|
||||
GValue val = { 0, };
|
||||
|
||||
g_return_if_fail (GST_VALUE_HOLDS_LIST (value));
|
||||
g_return_if_fail (GST_VALUE_HOLDS_LIST (value)
|
||||
|| GST_VALUE_HOLDS_FIXED_LIST (value));
|
||||
|
||||
gst_value_init_and_copy (&val, prepend_value);
|
||||
g_array_prepend_vals ((GArray *) value->data[0].v_pointer, &val, 1);
|
||||
|
@ -180,7 +239,8 @@ gst_value_list_append_value (GValue * value, const GValue * append_value)
|
|||
{
|
||||
GValue val = { 0, };
|
||||
|
||||
g_return_if_fail (GST_VALUE_HOLDS_LIST (value));
|
||||
g_return_if_fail (GST_VALUE_HOLDS_LIST (value)
|
||||
|| GST_VALUE_HOLDS_FIXED_LIST (value));
|
||||
|
||||
gst_value_init_and_copy (&val, append_value);
|
||||
g_array_append_vals ((GArray *) value->data[0].v_pointer, &val, 1);
|
||||
|
@ -197,7 +257,8 @@ gst_value_list_append_value (GValue * value, const GValue * append_value)
|
|||
guint
|
||||
gst_value_list_get_size (const GValue * value)
|
||||
{
|
||||
g_return_val_if_fail (GST_VALUE_HOLDS_LIST (value), 0);
|
||||
g_return_val_if_fail (GST_VALUE_HOLDS_LIST (value)
|
||||
|| GST_VALUE_HOLDS_FIXED_LIST (value), 0);
|
||||
|
||||
return ((GArray *) value->data[0].v_pointer)->len;
|
||||
}
|
||||
|
@ -215,7 +276,8 @@ gst_value_list_get_size (const GValue * value)
|
|||
const GValue *
|
||||
gst_value_list_get_value (const GValue * value, guint index)
|
||||
{
|
||||
g_return_val_if_fail (GST_VALUE_HOLDS_LIST (value), NULL);
|
||||
g_return_val_if_fail (GST_VALUE_HOLDS_LIST (value)
|
||||
|| GST_VALUE_HOLDS_FIXED_LIST (value), NULL);
|
||||
g_return_val_if_fail (index < gst_value_list_get_size (value), NULL);
|
||||
|
||||
return (const GValue *) &g_array_index ((GArray *) value->data[0].v_pointer,
|
||||
|
@ -274,28 +336,14 @@ gst_value_list_concat (GValue * dest, const GValue * value1,
|
|||
static void
|
||||
gst_value_transform_list_string (const GValue * src_value, GValue * dest_value)
|
||||
{
|
||||
GValue *list_value;
|
||||
GArray *array;
|
||||
GString *s;
|
||||
int i;
|
||||
char *list_s;
|
||||
|
||||
array = src_value->data[0].v_pointer;
|
||||
|
||||
s = g_string_new ("{ ");
|
||||
for (i = 0; i < array->len; i++) {
|
||||
list_value = &g_array_index (array, GValue, i);
|
||||
|
||||
if (i != 0) {
|
||||
g_string_append (s, ", ");
|
||||
gst_value_transform_any_list_string (src_value, dest_value, "{ ", " }");
|
||||
}
|
||||
list_s = g_strdup_value_contents (list_value);
|
||||
g_string_append (s, list_s);
|
||||
g_free (list_s);
|
||||
}
|
||||
g_string_append (s, " }");
|
||||
|
||||
dest_value->data[0].v_pointer = g_string_free (s, FALSE);
|
||||
static void
|
||||
gst_value_transform_fixed_list_string (const GValue * src_value,
|
||||
GValue * dest_value)
|
||||
{
|
||||
gst_value_transform_any_list_string (src_value, dest_value, "< ", " >");
|
||||
}
|
||||
|
||||
static int
|
||||
|
@ -328,24 +376,7 @@ gst_value_compare_list (const GValue * value1, const GValue * value2)
|
|||
static char *
|
||||
gst_value_serialize_list (const GValue * value)
|
||||
{
|
||||
int i;
|
||||
GArray *array = value->data[0].v_pointer;
|
||||
GString *s;
|
||||
GValue *v;
|
||||
gchar *s_val;
|
||||
|
||||
s = g_string_new ("{ ");
|
||||
for (i = 0; i < array->len; i++) {
|
||||
v = &g_array_index (array, GValue, i);
|
||||
s_val = gst_value_serialize (v);
|
||||
g_string_append (s, s_val);
|
||||
g_free (s_val);
|
||||
if (i < array->len - 1) {
|
||||
g_string_append (s, ", ");
|
||||
}
|
||||
}
|
||||
g_string_append (s, " }");
|
||||
return g_string_free (s, FALSE);
|
||||
return gst_value_serialize_any_list (value, "{ ", " }");
|
||||
}
|
||||
|
||||
static gboolean
|
||||
|
@ -355,6 +386,19 @@ gst_value_deserialize_list (GValue * dest, const char *s)
|
|||
return FALSE;
|
||||
}
|
||||
|
||||
static char *
|
||||
gst_value_serialize_fixed_list (const GValue * value)
|
||||
{
|
||||
return gst_value_serialize_any_list (value, "< ", " >");
|
||||
}
|
||||
|
||||
static gboolean
|
||||
gst_value_deserialize_fixed_list (GValue * dest, const char *s)
|
||||
{
|
||||
g_warning ("unimplemented");
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
/*************************************/
|
||||
/* fourcc */
|
||||
|
||||
|
@ -2209,9 +2253,11 @@ gst_type_is_fixed (GType type)
|
|||
type < G_TYPE_MAKE_FUNDAMENTAL (G_TYPE_RESERVED_GLIB_LAST)) {
|
||||
return TRUE;
|
||||
}
|
||||
if (type == GST_TYPE_BUFFER || type == GST_TYPE_FOURCC) {
|
||||
if (type == GST_TYPE_BUFFER || type == GST_TYPE_FOURCC
|
||||
|| type == GST_TYPE_FIXED_LIST) {
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
|
@ -2346,6 +2392,32 @@ _gst_value_initialize (void)
|
|||
gst_value_register (&gst_value);
|
||||
}
|
||||
|
||||
{
|
||||
static const GTypeValueTable value_table = {
|
||||
gst_value_init_list,
|
||||
gst_value_free_list,
|
||||
gst_value_copy_list,
|
||||
gst_value_list_peek_pointer,
|
||||
"p",
|
||||
gst_value_collect_list,
|
||||
"p",
|
||||
gst_value_lcopy_list
|
||||
};
|
||||
static GstValueTable gst_value = {
|
||||
0,
|
||||
gst_value_compare_list,
|
||||
gst_value_serialize_fixed_list,
|
||||
gst_value_deserialize_fixed_list,
|
||||
};
|
||||
|
||||
info.value_table = &value_table;
|
||||
gst_type_fixed_list =
|
||||
g_type_register_fundamental (g_type_fundamental_next (),
|
||||
"GstValueFixedList", &info, &finfo, 0);
|
||||
gst_value.type = gst_type_fixed_list;
|
||||
gst_value_register (&gst_value);
|
||||
}
|
||||
|
||||
{
|
||||
#if 0
|
||||
static const GTypeValueTable value_table = {
|
||||
|
@ -2399,6 +2471,8 @@ _gst_value_initialize (void)
|
|||
gst_value_transform_double_range_string);
|
||||
g_value_register_transform_func (GST_TYPE_LIST, G_TYPE_STRING,
|
||||
gst_value_transform_list_string);
|
||||
g_value_register_transform_func (GST_TYPE_FIXED_LIST, G_TYPE_STRING,
|
||||
gst_value_transform_fixed_list_string);
|
||||
|
||||
gst_value_register_intersect_func (G_TYPE_INT, GST_TYPE_INT_RANGE,
|
||||
gst_value_intersect_int_int_range);
|
||||
|
|
|
@ -39,12 +39,14 @@ G_BEGIN_DECLS
|
|||
#define GST_VALUE_HOLDS_INT_RANGE(x) (G_VALUE_HOLDS(x, gst_type_int_range))
|
||||
#define GST_VALUE_HOLDS_DOUBLE_RANGE(x) (G_VALUE_HOLDS(x, gst_type_double_range))
|
||||
#define GST_VALUE_HOLDS_LIST(x) (G_VALUE_HOLDS(x, gst_type_list))
|
||||
#define GST_VALUE_HOLDS_FIXED_LIST(x) (G_VALUE_HOLDS(x, gst_type_fixed_list))
|
||||
#define GST_VALUE_HOLDS_CAPS(x) (G_VALUE_HOLDS(x, GST_TYPE_CAPS))
|
||||
|
||||
#define GST_TYPE_FOURCC gst_type_fourcc
|
||||
#define GST_TYPE_INT_RANGE gst_type_int_range
|
||||
#define GST_TYPE_DOUBLE_RANGE gst_type_double_range
|
||||
#define GST_TYPE_LIST gst_type_list
|
||||
#define GST_TYPE_FIXED_LIST gst_type_fixed_list
|
||||
|
||||
#define GST_VALUE_LESS_THAN (-1)
|
||||
#define GST_VALUE_EQUAL 0
|
||||
|
@ -80,6 +82,7 @@ extern GType gst_type_fourcc;
|
|||
extern GType gst_type_int_range;
|
||||
extern GType gst_type_double_range;
|
||||
extern GType gst_type_list;
|
||||
extern GType gst_type_fixed_list;
|
||||
|
||||
void gst_value_register (const GstValueTable *table);
|
||||
void gst_value_init_and_copy (GValue *dest,
|
||||
|
|
|
@ -135,9 +135,11 @@ bla:
|
|||
test_string ("audio/raw ,test =(bool) trUE");
|
||||
test_string ("audio/raw ,test=(b ) yes");
|
||||
test_string ("audio/raw ,test =( boolean)no");
|
||||
test_string ("audio/raw ,test = < 1, 2, 3 >");
|
||||
|
||||
/* buffers */
|
||||
test_string ("audio/raw ,test=(buffer)0123456789abcdef");
|
||||
test_string ("audio/raw ,test= < (buffer)0123, (buffer)4567 >");
|
||||
|
||||
/* unfixed props entries */
|
||||
test_string ("audio/raw, test= [ 1, 2 ]");
|
||||
|
@ -184,9 +186,11 @@ bla:
|
|||
test_string_fail ("audio/raw, test=(int) [1.0,2]");
|
||||
test_string_fail ("audio/raw, test=(int) [1 ,0.2]");
|
||||
test_string_fail ("audio/raw, test=(int) [1.0, 2.000]");
|
||||
test_string_fail ("audio/raw, test=(int) <1.0, 2.000>");
|
||||
/* unmatched */
|
||||
test_string_fail ("audio/raw, test=(int = [");
|
||||
test_string_fail ("audio/raw, test= {");
|
||||
test_string_fail ("audio/raw, test= <");
|
||||
test_string_fail ("audio/raw, test = \"dood'");
|
||||
test_string_fail ("audio/raw, test= '");
|
||||
|
||||
|
|
|
@ -135,9 +135,11 @@ bla:
|
|||
test_string ("audio/raw ,test =(bool) trUE");
|
||||
test_string ("audio/raw ,test=(b ) yes");
|
||||
test_string ("audio/raw ,test =( boolean)no");
|
||||
test_string ("audio/raw ,test = < 1, 2, 3 >");
|
||||
|
||||
/* buffers */
|
||||
test_string ("audio/raw ,test=(buffer)0123456789abcdef");
|
||||
test_string ("audio/raw ,test= < (buffer)0123, (buffer)4567 >");
|
||||
|
||||
/* unfixed props entries */
|
||||
test_string ("audio/raw, test= [ 1, 2 ]");
|
||||
|
@ -184,9 +186,11 @@ bla:
|
|||
test_string_fail ("audio/raw, test=(int) [1.0,2]");
|
||||
test_string_fail ("audio/raw, test=(int) [1 ,0.2]");
|
||||
test_string_fail ("audio/raw, test=(int) [1.0, 2.000]");
|
||||
test_string_fail ("audio/raw, test=(int) <1.0, 2.000>");
|
||||
/* unmatched */
|
||||
test_string_fail ("audio/raw, test=(int = [");
|
||||
test_string_fail ("audio/raw, test= {");
|
||||
test_string_fail ("audio/raw, test= <");
|
||||
test_string_fail ("audio/raw, test = \"dood'");
|
||||
test_string_fail ("audio/raw, test= '");
|
||||
|
||||
|
|
Loading…
Reference in a new issue