ext/gio/: Add documentation and example code for giostreamsink/giostreamsrc.

Original commit message from CVS:
* ext/gio/gstgiostreamsink.c:
* ext/gio/gstgiostreamsrc.c:
Add documentation and example code for giostreamsink/giostreamsrc.
* tests/check/pipelines/gio.c: (GST_START_TEST):
Ask the GMemoryOutputStream for the data instead of assuming that
the pointer to the data stayed the same. It could've been realloc'ed.
This commit is contained in:
Sebastian Dröge 2008-02-12 09:24:11 +00:00
parent 9313ee92fd
commit 8b9f044b70
4 changed files with 83 additions and 4 deletions

View file

@ -1,3 +1,13 @@
2008-02-12 Sebastian Dröge <slomo@circular-chaos.org>
* ext/gio/gstgiostreamsink.c:
* ext/gio/gstgiostreamsrc.c:
Add documentation and example code for giostreamsink/giostreamsrc.
* tests/check/pipelines/gio.c: (GST_START_TEST):
Ask the GMemoryOutputStream for the data instead of assuming that
the pointer to the data stayed the same. It could've been realloc'ed.
2008-02-12 Sebastian Dröge <slomo@circular-chaos.org>
* ext/gio/gstgiosink.c:

View file

@ -21,12 +21,45 @@
/**
* SECTION:element-giostreamsink
* @short_description: Write to a GIO GOutputStream
*
* <refsect2>
* <title>Example launch line</title>
* <para>
* This plugin writes incoming data to a custom GIO #GOutputStream.
* </para>
* <para>
* It can, for example, be used to write a stream to memory with a
* #GMemoryOuputStream or to write to a file with a #GFileOuputStream.
* </para>
* <title>Example code</title>
* <para>
* The following example writes the received data to a #GMemoryOutputStream.
* <programlisting>
* gst-launch audiotestsrc num-buffers=100 ! flacenc ! giosink location=file:///home/foo/bar.flac
#include &lt;gst/gst.h&gt;
#include &lt;gio/gio.h&gt;
...
GstElement *sink;
GMemoryOuputStream *stream;
// out_data will contain the received data
guint8 *out_data;
...
stream = G_MEMORY_OUTPUT_STREAM (g_memory_output_stream_new (NULL, 0,
(GReallocFunc) g_realloc, (GDestroyNotify) g_free));
sink = gst_element_factory_make ("giostreamsink", "sink");
g_object_set (G_OBJECT (sink), "stream", stream, NULL);
...
// after processing get the written data
out_data = g_memory_ouput_stream_get_data (G_MEMORY_OUTPUT_STREAM (stream));
...
* </programlisting>
* </para>
* </refsect2>

View file

@ -21,12 +21,45 @@
/**
* SECTION:element-giostreamsrc
* @short_description: Reads data from a GIO GInputStream
*
* <refsect2>
* <title>Example launch line</title>
* <para>
* This plugin reads data from a custom GIO #GInputStream.
* </para>
* <para>
* It can, for example, be used to read data from memory with a
* #GMemoryInputStream or to read from a file with a
* #GFileInputStream.
* </para>
* <title>Example code</title>
* <para>
* The following example reads data from a #GMemoryOutputStream.
* <programlisting>
* gst-launch giosrc location=file:///home/foo/bar.ext ! fakesink
#include &lt;gst/gst.h&gt;
#include &lt;gio/gio.h&gt;
...
GstElement *src;
GMemoryInputStream *stream;
// in_data will contain the data to send
guint8 *in_data;
gint i;
...
in_data = g_new (guint8, 512);
for (i = 0; i < 512; i++)
in_data[i] = i % 256;
stream = G_MEMORY_INPUT_STREAM (g_memory_input_stream_new_from_data (in_data, 512,
(GDestroyNotify) g_free));
src = gst_element_factory_make ("giostreamsrc", "src");
g_object_set (G_OBJECT (src), "stream", stream, NULL);
...
* </programlisting>
* </para>
* </refsect2>

View file

@ -86,6 +86,7 @@ GST_START_TEST (test_memory_stream)
output = G_MEMORY_OUTPUT_STREAM (g_memory_output_stream_new (out_data, 512,
(GReallocFunc) g_realloc, (GDestroyNotify) g_free));
out_data = NULL;
loop = g_main_loop_new (NULL, FALSE);
@ -121,6 +122,8 @@ GST_START_TEST (test_memory_stream)
fail_unless (got_eos);
out_data = g_memory_output_stream_get_data (G_MEMORY_OUTPUT_STREAM (output));
for (i = 0; i < 512; i++)
fail_unless_equals_int (in_data[i], out_data[i]);