diff options
author | Thiago Santos <thiago.sousa.santos@collabora.co.uk> | 2010-01-22 09:19:31 -0300 |
---|---|---|
committer | Thiago Santos <thiago.sousa.santos@collabora.co.uk> | 2010-02-12 17:23:29 -0300 |
commit | bfff7a1b4ece0c0b5ca30dd93392707fc097f7a9 (patch) | |
tree | afc907467bf6fb7bbf1c3cef231b6c881cbfe153 /libs | |
parent | 51d382e2eef0ed6aea6319403a33dfd7abcd235e (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()
Diffstat (limited to 'libs')
-rw-r--r-- | libs/gst/base/gstbytewriter.c | 27 | ||||
-rw-r--r-- | libs/gst/base/gstbytewriter.h | 1 |
2 files changed, 28 insertions, 0 deletions
diff --git a/libs/gst/base/gstbytewriter.c b/libs/gst/base/gstbytewriter.c index 375c41055..b76ffe3e6 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 df5dad218..87658e55b 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); |