API: Add gst_byte_reader_get_data and gst_byte_reader_peek_data to get a pointer to the data at the current position ...

Original commit message from CVS:
* docs/libs/gstreamer-libs-sections.txt:
* libs/gst/base/gstbytereader.c: (gst_byte_reader_get_data),
(gst_byte_reader_peek_data):
* libs/gst/base/gstbytereader.h:
* win32/common/libgstbase.def:
API: Add gst_byte_reader_get_data and gst_byte_reader_peek_data
to get a pointer to the data at the current position and have
a guaranteed size.
This commit is contained in:
Sebastian Dröge 2008-10-22 14:47:04 +00:00
parent d2c33f6d79
commit 61ee0f414a
5 changed files with 80 additions and 0 deletions

View file

@ -1,3 +1,14 @@
2008-10-22 Sebastian Dröge <slomo@circular-chaos.org>
* docs/libs/gstreamer-libs-sections.txt:
* libs/gst/base/gstbytereader.c: (gst_byte_reader_get_data),
(gst_byte_reader_peek_data):
* libs/gst/base/gstbytereader.h:
* win32/common/libgstbase.def:
API: Add gst_byte_reader_get_data and gst_byte_reader_peek_data
to get a pointer to the data at the current position and have
a guaranteed size.
2008-10-22 Jan Schmidt <jan.schmidt@sun.com> 2008-10-22 Jan Schmidt <jan.schmidt@sun.com>
* configure.ac: * configure.ac:

View file

@ -440,6 +440,9 @@ gst_byte_reader_peek_float32_le
gst_byte_reader_peek_float32_be gst_byte_reader_peek_float32_be
gst_byte_reader_peek_float64_le gst_byte_reader_peek_float64_le
gst_byte_reader_peek_float64_be gst_byte_reader_peek_float64_be
gst_byte_reader_get_data
gst_byte_reader_peek_data
</SECTION> </SECTION>
<SECTION> <SECTION>

View file

@ -1211,3 +1211,64 @@ gst_byte_reader_peek_float##bits##_be (GstByteReader *reader, g##type *val) \
GST_BYTE_READER_READ_FLOATS (32, float, FLOAT); GST_BYTE_READER_READ_FLOATS (32, float, FLOAT);
GST_BYTE_READER_READ_FLOATS (64, double, DOUBLE); GST_BYTE_READER_READ_FLOATS (64, double, DOUBLE);
/**
* gst_byte_reader_get_data:
* @reader: a #GstByteReader instance
* @size: Size in bytes
* @val: Pointer to a #guint8 to store the result
*
* Returns a constant pointer to the current data
* position if at least @size bytes are left and
* updates the current position.
*
*
* Returns: %TRUE if successful, %FALSE otherwise.
*
* Since: 0.10.22
*/
/**
* gst_byte_reader_peek_data:
* @reader: a #GstByteReader instance
* @size: Size in bytes
* @val: Pointer to a #guint8 to store the result
*
* Returns a constant pointer to the current data
* position if at least @size bytes are left and
* keeps the current position.
*
*
* Returns: %TRUE if successful, %FALSE otherwise.
*
* Since: 0.10.22
*/
gboolean
gst_byte_reader_get_data (GstByteReader * reader, guint size,
const guint8 ** val)
{
g_return_val_if_fail (reader != NULL, FALSE);
g_return_val_if_fail (val != NULL, FALSE);
if (reader->byte + size > reader->size)
return FALSE;
*val = reader->data + reader->byte;
reader->byte += size;
return TRUE;
}
gboolean
gst_byte_reader_peek_data (GstByteReader * reader, guint size,
const guint8 ** val)
{
g_return_val_if_fail (reader != NULL, FALSE);
g_return_val_if_fail (val != NULL, FALSE);
if (reader->byte + size > reader->size)
return FALSE;
*val = reader->data + reader->byte;
return TRUE;
}

View file

@ -102,6 +102,9 @@ gboolean gst_byte_reader_peek_float32_be (GstByteReader *reader, gfloat *val);
gboolean gst_byte_reader_peek_float64_le (GstByteReader *reader, gdouble *val); gboolean gst_byte_reader_peek_float64_le (GstByteReader *reader, gdouble *val);
gboolean gst_byte_reader_peek_float64_be (GstByteReader *reader, gdouble *val); gboolean gst_byte_reader_peek_float64_be (GstByteReader *reader, gdouble *val);
gboolean gst_byte_reader_get_data (GstByteReader *reader, guint size, const guint8 **val);
gboolean gst_byte_reader_peek_data (GstByteReader *reader, guint size, const guint8 **val);
/** /**
* GST_BYTE_READER_INIT: * GST_BYTE_READER_INIT:
* @data: Data from which the #GstByteReader should read * @data: Data from which the #GstByteReader should read

View file

@ -72,6 +72,7 @@ EXPORTS
gst_bit_reader_skip gst_bit_reader_skip
gst_bit_reader_skip_to_byte gst_bit_reader_skip_to_byte
gst_byte_reader_free gst_byte_reader_free
gst_byte_reader_get_data
gst_byte_reader_get_float32_be gst_byte_reader_get_float32_be
gst_byte_reader_get_float32_le gst_byte_reader_get_float32_le
gst_byte_reader_get_float64_be gst_byte_reader_get_float64_be
@ -100,6 +101,7 @@ EXPORTS
gst_byte_reader_init_from_buffer gst_byte_reader_init_from_buffer
gst_byte_reader_new gst_byte_reader_new
gst_byte_reader_new_from_buffer gst_byte_reader_new_from_buffer
gst_byte_reader_peek_data
gst_byte_reader_peek_float32_be gst_byte_reader_peek_float32_be
gst_byte_reader_peek_float32_le gst_byte_reader_peek_float32_le
gst_byte_reader_peek_float64_be gst_byte_reader_peek_float64_be