+2005-07-11 Thomas Vander Stichele <thomas at apestaart dot org>
+
+ * check/Makefile.am:
+ add two more tests for valgrinding
+ * check/gst/gstvalue.c: (GST_START_TEST):
+ test refcount of deserialized buffer, found a leak
+ * docs/gst/gstreamer-docs.sgml:
+ * docs/gst/gstreamer-sections.txt:
+ * docs/gst/gstreamer.types:
+ * docs/gst/tmpl/gstminiobject.sgml:
+ add miniobject to docs
+ * gst/gstminiobject.c:
+ add some docs
+ * gst/gstvalue.c: (gst_value_deserialize_buffer),
+ (gst_string_unwrap):
+ fix a hard-to-find invalid write for one of the tests
+ fix a leak for deserialized buffers
+
2005-07-11 Ronald S. Bultje <rbultje@ronald.bitfreak.net>
* docs/pwg/advanced-events.xml:
TESTS_TO_FIX = \
gst/gstghostpad \
gst/gstiterator \
- gst/gstmessage \
gst/gstpad \
gst/gstsystemclock \
gst/gststructure \
gst/gsttag \
- gst/gstvalue \
elements/gstfakesrc \
pipelines/cleanup \
pipelines/simple_launch_lines \
gstbus
gstcaps
gstdata
+gstelement
gstghostpad
gstiterator
gstmessage
+gstminiobject
gstobject
gstpad
gststructure
GST_START_TEST (test_deserialize_buffer)
{
GValue value = { 0 };
+ GstBuffer *buf;
g_value_init (&value, GST_TYPE_BUFFER);
fail_unless (gst_value_deserialize (&value, "1234567890abcdef"));
+ buf = GST_BUFFER (gst_value_get_mini_object (&value));
+
+ ASSERT_MINI_OBJECT_REFCOUNT (buf, "buffer", 1);
+
+ /* cleanup */
+ gst_buffer_unref (buf);
}
GST_END_TEST;
gchar *to;
} tests[] = {
{
- "", ""}, {
- "\"\"", ""},
- /* FAILURES */
+ "", ""}, /* empty strings */
+ {
+ "\"\"", ""}, /* FAILURES */
{
"\"", NULL}, /* missing second quote */
{
} G_STMT_END
#define ASSERT_CAPS_REFCOUNT(caps, name, value) \
+ ASSERT_MINI_OBJECT_REFCOUNT(caps, name, value)
+
+#define ASSERT_MINI_OBJECT_REFCOUNT(caps, name, value) \
G_STMT_START { \
int rc; \
rc = GST_MINI_OBJECT_REFCOUNT_VALUE (caps); \
<!ENTITY GstIterator SYSTEM "xml/gstiterator.xml">
<!ENTITY GstMacros SYSTEM "xml/gstmacros.xml">
<!ENTITY GstMemChunk SYSTEM "xml/gstmemchunk.xml">
+<!ENTITY GstMiniObject SYSTEM "xml/gstminiobject.xml">
<!ENTITY GstObject SYSTEM "xml/gstobject.xml">
<!ENTITY GstPad SYSTEM "xml/gstpad.xml">
<!ENTITY GstPadTemplate SYSTEM "xml/gstpadtemplate.xml">
&GstIndexFactory;
&GstInfo;
&GstIterator;
+ &GstMiniObject;
&GstObject;
&GstPad;
&GstPadTemplate;
</SECTION>
<SECTION>
+<FILE>gstminiobject</FILE>
+<TITLE>GstMiniObject</TITLE>
+GstMiniObject
+GstMiniObjectFlags
+GST_MINI_OBJECT_FLAGS
+GST_MINI_OBJECT_FLAG_IS_SET
+GST_MINI_OBJECT_FLAG_SET
+GST_MINI_OBJECT_FLAG_UNSET
+
+gst_mini_object_new
+gst_mini_object_copy
+gst_mini_object_is_writable
+gst_mini_object_make_writable
+
+gst_mini_object_ref
+gst_mini_object_unref
+gst_mini_object_replace
+
+gst_param_spec_mini_object
+gst_value_set_mini_object
+gst_value_take_mini_object
+gst_value_get_mini_object
+
+<SUBSECTION Standard>
+GstMiniObjectClass
+GST_MINI_OBJECT
+GST_IS_MINI_OBJECT
+GST_MINI_OBJECT_CLASS
+GST_IS_MINI_OBJECT_CLASS
+GST_MINI_OBJECT_GET_CLASS
+GST_TYPE_MINI_OBJECT
+GST_TYPE_MINI_OBJECT_FLAGS
+<SUBSECTION Private>
+gst_mini_object_get_type
+gst_mini_object_flags_get_type
+</SECTION>
+
+<SECTION>
<FILE>gstobject</FILE>
<TITLE>GstObject</TITLE>
GstObject
gst_implements_interface_get_type
gst_index_factory_get_type
gst_index_get_type
+
+% GstMiniObject is not a GObject !
+% gst_mini_object_get_type
+
gst_object_get_type
gst_pad_get_type
gst_pad_template_get_type
--- /dev/null
+<!-- ##### SECTION Title ##### -->
+GstMiniObject
+
+<!-- ##### SECTION Short_Description ##### -->
+
+
+<!-- ##### SECTION Long_Description ##### -->
+<para>
+
+</para>
+
+
+<!-- ##### SECTION See_Also ##### -->
+<para>
+
+</para>
+
+
+<!-- ##### STRUCT GstMiniObject ##### -->
+<para>
+
+</para>
+
+@instance:
+@refcount:
+@flags:
+@_gst_reserved:
+
+<!-- ##### ENUM GstMiniObjectFlags ##### -->
+<para>
+
+</para>
+
+@GST_MINI_OBJECT_FLAG_READONLY:
+@GST_MINI_OBJECT_FLAG_STATIC:
+@GST_MINI_OBJECT_FLAG_LAST:
+
+<!-- ##### MACRO GST_MINI_OBJECT_FLAGS ##### -->
+<para>
+
+</para>
+
+@obj:
+
+
+<!-- ##### MACRO GST_MINI_OBJECT_FLAG_IS_SET ##### -->
+<para>
+
+</para>
+
+@obj:
+@flag:
+
+
+<!-- ##### MACRO GST_MINI_OBJECT_FLAG_SET ##### -->
+<para>
+
+</para>
+
+@obj:
+@flag:
+
+
+<!-- ##### MACRO GST_MINI_OBJECT_FLAG_UNSET ##### -->
+<para>
+
+</para>
+
+@obj:
+@flag:
+
+
+<!-- ##### FUNCTION gst_mini_object_new ##### -->
+<para>
+
+</para>
+
+@type:
+@Returns:
+
+
+<!-- ##### FUNCTION gst_mini_object_copy ##### -->
+<para>
+
+</para>
+
+@mini_object:
+@Returns:
+
+
+<!-- ##### FUNCTION gst_mini_object_is_writable ##### -->
+<para>
+
+</para>
+
+@mini_object:
+@Returns:
+
+
+<!-- ##### FUNCTION gst_mini_object_make_writable ##### -->
+<para>
+
+</para>
+
+@mini_object:
+@Returns:
+
+
+<!-- ##### FUNCTION gst_mini_object_ref ##### -->
+<para>
+
+</para>
+
+@mini_object:
+@Returns:
+
+
+<!-- ##### FUNCTION gst_mini_object_unref ##### -->
+<para>
+
+</para>
+
+@mini_object:
+
+
+<!-- ##### FUNCTION gst_mini_object_replace ##### -->
+<para>
+
+</para>
+
+@olddata:
+@newdata:
+
+
+<!-- ##### FUNCTION gst_param_spec_mini_object ##### -->
+<para>
+
+</para>
+
+@name:
+@nick:
+@blurb:
+@object_type:
+@flags:
+@Returns:
+
+
+<!-- ##### FUNCTION gst_value_set_mini_object ##### -->
+<para>
+
+</para>
+
+@value:
+@mini_object:
+
+
+<!-- ##### FUNCTION gst_value_take_mini_object ##### -->
+<para>
+
+</para>
+
+@value:
+@mini_object:
+
+
+<!-- ##### FUNCTION gst_value_get_mini_object ##### -->
+<para>
+
+</para>
+
+@value:
+@Returns:
+
+
return NULL;
}
+/**
+ * gst_value_set_mini_object:
+ * @value: a valid #GValue of %GST_TYPE_MINI_OBJECT derived type
+ * @mini_object: mini object value to set
+ *
+ * Set the contents of a %GST_TYPE_MINI_OBJECT derived #GValue to
+ * @mini_object.
+ * The caller retains ownership of the reference.
+ */
void
gst_value_set_mini_object (GValue * value, GstMiniObject * mini_object)
{
mini_object);
}
+/**
+ * gst_value_take_mini_object:
+ * @value: a valid #GValue of %GST_TYPE_MINI_OBJECT derived type
+ * @mini_object: mini object value to take
+ *
+ * Set the contents of a %GST_TYPE_MINI_OBJECT derived #GValue to
+ * @mini_object.
+ * Takes over the ownership of the caller's reference to @mini_object;
+ * the caller doesn't have to unref it any more.
+ */
void
gst_value_take_mini_object (GValue * value, GstMiniObject * mini_object)
{
gst_mini_object_unref (mini_object);
}
+/**
+ * gst_value_get_mini_object:
+ * @value: a valid #GValue of %GST_TYPE_MINI_OBJECT derived type
+ *
+ * Get the contents of a %GST_TYPE_MINI_OBJECT derived #GValue.
+ * Does not increase the refcount of the returned object.
+ *
+ * @Returns: mini object contents of @value
+ */
GstMiniObject *
gst_value_get_mini_object (const GValue * value)
{
}
if (ret) {
- gst_value_set_mini_object (dest, GST_MINI_OBJECT (buffer));
+ gst_value_take_mini_object (dest, GST_MINI_OBJECT (buffer));
return TRUE;
} else {
gst_buffer_unref (buffer);
return d;
}
+/* FIXME: wouldn't it be nice if this function
+ * were documented ? Alphabet spaghetti is easier to digest.
+ */
static char *
gst_string_unwrap (const gchar * s)
{
- /* FIXME: do better memory management? */
- gchar *ret = g_strdup (s);
- gchar *read = ret, *write = ret;
+ gchar *ret;
+ gchar *read, *write;
- if (*read++ != '"') {
- g_free (ret);
+ if (s == NULL)
return NULL;
- }
+
+ ret = g_strdup (s);
+ read = ret;
+ write = ret;
+
+ if (*read++ != '"')
+ goto beach;
+
while (*read) {
if (GST_ASCII_IS_STRING (*read)) {
*write++ = *read++;
} else if (*read == '\\') {
read++;
if (*read >= '0' && *read <= '7') {
- if (read[1] < '0' || read[1] > '7' || read[2] < '0' || read[2] > '7') {
- g_free (ret);
- return NULL;
- }
+ if (read[1] < '0' || read[1] > '7' || read[2] < '0' || read[2] > '7')
+ goto beach;
+
*write++ = ((read[0] - '0') << 6) +
((read[1] - '0') << 3) + (read[2] - '0');
read += 3;
} else {
+ /* if we run into a \0 here, we definately won't get a quote later */
+ if (*read == 0)
+ goto beach;
+
*write++ = *read++;
}
} else {
- g_free (ret);
- return NULL;
+ goto beach;
}
}
- if (*read != '"' || read[1] != '\0') {
- g_free (ret);
- return NULL;
- }
+ if (*read != '"' || read[1] != '\0')
+ goto beach;
+
*write++ = '\0';
return ret;
+
+beach:
+ g_free (ret);
+ return NULL;
}
static char *
TESTS_TO_FIX = \
gst/gstghostpad \
gst/gstiterator \
- gst/gstmessage \
gst/gstpad \
gst/gstsystemclock \
gst/gststructure \
gst/gsttag \
- gst/gstvalue \
elements/gstfakesrc \
pipelines/cleanup \
pipelines/simple_launch_lines \
gstbus
gstcaps
gstdata
+gstelement
gstghostpad
gstiterator
gstmessage
+gstminiobject
gstobject
gstpad
gststructure
GST_START_TEST (test_deserialize_buffer)
{
GValue value = { 0 };
+ GstBuffer *buf;
g_value_init (&value, GST_TYPE_BUFFER);
fail_unless (gst_value_deserialize (&value, "1234567890abcdef"));
+ buf = GST_BUFFER (gst_value_get_mini_object (&value));
+
+ ASSERT_MINI_OBJECT_REFCOUNT (buf, "buffer", 1);
+
+ /* cleanup */
+ gst_buffer_unref (buf);
}
GST_END_TEST;
gchar *to;
} tests[] = {
{
- "", ""}, {
- "\"\"", ""},
- /* FAILURES */
+ "", ""}, /* empty strings */
+ {
+ "\"\"", ""}, /* FAILURES */
{
"\"", NULL}, /* missing second quote */
{
} G_STMT_END
#define ASSERT_CAPS_REFCOUNT(caps, name, value) \
+ ASSERT_MINI_OBJECT_REFCOUNT(caps, name, value)
+
+#define ASSERT_MINI_OBJECT_REFCOUNT(caps, name, value) \
G_STMT_START { \
int rc; \
rc = GST_MINI_OBJECT_REFCOUNT_VALUE (caps); \