summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThiago Santos <thiago.sousa.santos@collabora.co.uk>2010-01-22 09:19:31 -0300
committerThiago Santos <thiago.sousa.santos@collabora.co.uk>2010-02-12 17:23:29 -0300
commitbfff7a1b4ece0c0b5ca30dd93392707fc097f7a9 (patch)
treeafc907467bf6fb7bbf1c3cef231b6c881cbfe153
parent51d382e2eef0ed6aea6319403a33dfd7abcd235e (diff)
bytewriter: add _fill function
Adds a new function to GstByteWriter that writes a constant value to a memory area (aka memset). Useful for adding padding to buffers. Also updates .def file and docs. API: gst_byte_writer_fill()
-rw-r--r--docs/libs/gstreamer-libs-sections.txt1
-rw-r--r--libs/gst/base/gstbytewriter.c27
-rw-r--r--libs/gst/base/gstbytewriter.h1
-rw-r--r--win32/common/libgstbase.def1
4 files changed, 30 insertions, 0 deletions
diff --git a/docs/libs/gstreamer-libs-sections.txt b/docs/libs/gstreamer-libs-sections.txt
index 855ceb1691..97086ec482 100644
--- a/docs/libs/gstreamer-libs-sections.txt
+++ b/docs/libs/gstreamer-libs-sections.txt
@@ -595,6 +595,7 @@ gst_byte_writer_put_string_utf32
gst_byte_writer_put_string_utf8
gst_byte_writer_put_data
+gst_byte_writer_fill
<SUBSECTION Private>
GST_BYTE_WRITER
diff --git a/libs/gst/base/gstbytewriter.c b/libs/gst/base/gstbytewriter.c
index 375c41055c..b76ffe3e6f 100644
--- a/libs/gst/base/gstbytewriter.c
+++ b/libs/gst/base/gstbytewriter.c
@@ -492,6 +492,21 @@ gst_byte_writer_put_data (GstByteWriter * writer, const guint8 * data,
return TRUE;
}
+gboolean
+gst_byte_writer_fill (GstByteWriter * writer, const guint8 value, guint size)
+{
+ g_return_val_if_fail (writer != NULL, FALSE);
+
+ if (G_UNLIKELY (!gst_byte_writer_ensure_free_space (writer, size)))
+ return FALSE;
+
+ memset ((guint8 *) & writer->parent.data[writer->parent.byte], value, size);
+ writer->parent.byte += size;
+ writer->parent.size = MAX (writer->parent.size, writer->parent.byte);
+
+ return TRUE;
+}
+
#define CREATE_WRITE_STRING_FUNC(bits,type) \
gboolean \
gst_byte_writer_put_string_utf##bits (GstByteWriter *writer, const type * data) \
@@ -806,3 +821,15 @@ CREATE_WRITE_STRING_FUNC (32, guint32);
*
* Since: 0.10.26
*/
+/**
+ * gst_byte_writer_fill:
+ * @writer: #GstByteWriter instance
+ * @value: Value to be writen
+ * @size: Number of bytes to be writen
+ *
+ * Writes @size bytes containing @value to @writer.
+ *
+ * Returns: %TRUE if the value could be written
+ *
+ * Since: 0.10.26
+ */
diff --git a/libs/gst/base/gstbytewriter.h b/libs/gst/base/gstbytewriter.h
index df5dad218d..87658e55b2 100644
--- a/libs/gst/base/gstbytewriter.h
+++ b/libs/gst/base/gstbytewriter.h
@@ -144,6 +144,7 @@ gboolean gst_byte_writer_put_double_be (GstByteWriter *writer, gdouble val);
gboolean gst_byte_writer_put_double_le (GstByteWriter *writer, gdouble val);
gboolean gst_byte_writer_put_data (GstByteWriter *writer, const guint8 *data, guint size);
+gboolean gst_byte_writer_fill (GstByteWriter *writer, const guint8 value, guint size);
gboolean gst_byte_writer_put_string_utf8 (GstByteWriter *writer, const gchar *data);
gboolean gst_byte_writer_put_string_utf16 (GstByteWriter *writer, const guint16 *data);
gboolean gst_byte_writer_put_string_utf32 (GstByteWriter *writer, const guint32 *data);
diff --git a/win32/common/libgstbase.def b/win32/common/libgstbase.def
index 7e0ba98718..68af7f5652 100644
--- a/win32/common/libgstbase.def
+++ b/win32/common/libgstbase.def
@@ -142,6 +142,7 @@ EXPORTS
gst_byte_reader_skip_string_utf32
gst_byte_reader_skip_string_utf8
gst_byte_writer_ensure_free_space
+ gst_byte_writer_fill
gst_byte_writer_free
gst_byte_writer_free_and_get_buffer
gst_byte_writer_free_and_get_data