Top |
GstByteWriterGstByteWriter — Writes different integer, string and floating point types to a memory buffer and allows reading |
GstByteWriter provides a byte writer and reader that can write/read different integer and floating point types to/from a memory buffer. It provides functions for writing/reading signed/unsigned, little/big endian integers of 8, 16, 24, 32 and 64 bits and functions for reading little/big endian floating points numbers of 32 and 64 bits. It also provides functions to write/read NUL-terminated strings in various character encodings.
GstByteWriter *
gst_byte_writer_new (void
);
Creates a new, empty GstByteWriter instance
Free-function: gst_byte_writer_free
[skip]
GstByteWriter * gst_byte_writer_new_with_data (guint8 *data
,guint size
,gboolean initialized
);
Creates a new GstByteWriter instance with the given
memory area. If initialized
is TRUE
it is possible to
read size
bytes from the GstByteWriter from the beginning.
Free-function: gst_byte_writer_free
[skip]
data |
Memory area for writing |
|
size |
Size of |
|
initialized |
If |
GstByteWriter * gst_byte_writer_new_with_size (guint size
,gboolean fixed
);
Creates a new GstByteWriter instance with the given initial data size.
Free-function: gst_byte_writer_free
[skip]
void
gst_byte_writer_init (GstByteWriter *writer
);
Initializes writer
to an empty instance
void gst_byte_writer_init_with_data (GstByteWriter *writer
,guint8 *data
,guint size
,gboolean initialized
);
Initializes writer
with the given
memory area. If initialized
is TRUE
it is possible to
read size
bytes from the GstByteWriter from the beginning.
writer |
GstByteWriter instance |
|
data |
Memory area for writing. |
[array length=size][transfer none] |
size |
Size of |
|
initialized |
If |
void gst_byte_writer_init_with_size (GstByteWriter *writer
,guint size
,gboolean fixed
);
Initializes writer
with the given initial data size.
writer |
GstByteWriter instance |
|
size |
Initial size of data |
|
fixed |
If |
void
gst_byte_writer_free (GstByteWriter *writer
);
Frees writer
and all memory allocated by it.
GstBuffer *
gst_byte_writer_free_and_get_buffer (GstByteWriter *writer
);
Frees writer
and all memory allocated by it except
the current data, which is returned as GstBuffer.
Free-function: gst_buffer_unref
guint8 *
gst_byte_writer_free_and_get_data (GstByteWriter *writer
);
Frees writer
and all memory allocated by it except
the current data, which is returned.
Free-function: g_free
void
gst_byte_writer_reset (GstByteWriter *writer
);
Resets writer
and frees the data if it's
owned by writer
.
guint8 *
gst_byte_writer_reset_and_get_data (GstByteWriter *writer
);
Resets writer
and returns the current data.
Free-function: g_free
GstBuffer *
gst_byte_writer_reset_and_get_buffer (GstByteWriter *writer
);
Resets writer
and returns the current data as buffer.
Free-function: gst_buffer_unref
gboolean gst_byte_writer_set_pos (GstByteWriter *writer
,guint pos
);
Sets the current read/write cursor of writer
. The new position
can only be between 0 and the current size.
guint
gst_byte_writer_get_remaining (const GstByteWriter *writer
);
Returns the remaining size of data that can still be written. If -1 is returned the remaining size is only limited by system resources.
gboolean gst_byte_writer_ensure_free_space (GstByteWriter *writer
,guint size
);
Checks if enough free space from the current write cursor is available and reallocates if necessary.
gboolean gst_byte_writer_put_int8 (GstByteWriter *writer
,gint8 val
);
Writes a signed 8 bit integer to writer
.
gboolean gst_byte_writer_put_int16_be (GstByteWriter *writer
,gint16 val
);
Writes a signed big endian 16 bit integer to writer
.
gboolean gst_byte_writer_put_int16_le (GstByteWriter *writer
,gint16 val
);
Writes a signed little endian 16 bit integer to writer
.
gboolean gst_byte_writer_put_int24_be (GstByteWriter *writer
,gint32 val
);
Writes a signed big endian 24 bit integer to writer
.
gboolean gst_byte_writer_put_int24_le (GstByteWriter *writer
,gint32 val
);
Writes a signed little endian 24 bit integer to writer
.
gboolean gst_byte_writer_put_int32_be (GstByteWriter *writer
,gint32 val
);
Writes a signed big endian 32 bit integer to writer
.
gboolean gst_byte_writer_put_int32_le (GstByteWriter *writer
,gint32 val
);
Writes a signed little endian 32 bit integer to writer
.
gboolean gst_byte_writer_put_int64_be (GstByteWriter *writer
,gint64 val
);
Writes a signed big endian 64 bit integer to writer
.
gboolean gst_byte_writer_put_int64_le (GstByteWriter *writer
,gint64 val
);
Writes a signed little endian 64 bit integer to writer
.
gboolean gst_byte_writer_put_uint8 (GstByteWriter *writer
,guint8 val
);
Writes a unsigned 8 bit integer to writer
.
gboolean gst_byte_writer_put_uint16_be (GstByteWriter *writer
,guint16 val
);
Writes a unsigned big endian 16 bit integer to writer
.
gboolean gst_byte_writer_put_uint16_le (GstByteWriter *writer
,guint16 val
);
Writes a unsigned little endian 16 bit integer to writer
.
gboolean gst_byte_writer_put_uint24_be (GstByteWriter *writer
,guint32 val
);
Writes a unsigned big endian 24 bit integer to writer
.
gboolean gst_byte_writer_put_uint24_le (GstByteWriter *writer
,guint32 val
);
Writes a unsigned little endian 24 bit integer to writer
.
gboolean gst_byte_writer_put_uint32_be (GstByteWriter *writer
,guint32 val
);
Writes a unsigned big endian 32 bit integer to writer
.
gboolean gst_byte_writer_put_uint32_le (GstByteWriter *writer
,guint32 val
);
Writes a unsigned little endian 32 bit integer to writer
.
gboolean gst_byte_writer_put_uint64_be (GstByteWriter *writer
,guint64 val
);
Writes a unsigned big endian 64 bit integer to writer
.
gboolean gst_byte_writer_put_uint64_le (GstByteWriter *writer
,guint64 val
);
Writes a unsigned little endian 64 bit integer to writer
.
gboolean gst_byte_writer_put_float32_be (GstByteWriter *writer
,gfloat val
);
Writes a big endian 32 bit float to writer
.
gboolean gst_byte_writer_put_float32_le (GstByteWriter *writer
,gfloat val
);
Writes a little endian 32 bit float to writer
.
gboolean gst_byte_writer_put_float64_be (GstByteWriter *writer
,gdouble val
);
Writes a big endian 64 bit float to writer
.
gboolean gst_byte_writer_put_float64_le (GstByteWriter *writer
,gdouble val
);
Writes a little endian 64 bit float to writer
.
#define gst_byte_writer_put_string(writer, data)
Write a NUL-terminated string to writer
(including the terminator). The
string is assumed to be in an 8-bit encoding (e.g. ASCII,UTF-8 or
ISO-8859-1).
gboolean gst_byte_writer_put_string_utf16 (GstByteWriter *writer
,const guint16 *data
);
Writes a NUL-terminated UTF16 string to writer
(including the terminator).
writer |
GstByteWriter instance |
|
data |
UTF16 string to write. |
[transfer none][array zero-terminated=1] |
gboolean gst_byte_writer_put_string_utf32 (GstByteWriter *writer
,const guint32 *data
);
Writes a NUL-terminated UTF32 string to writer
(including the terminator).
writer |
GstByteWriter instance |
|
data |
UTF32 string to write. |
[transfer none][array zero-terminated=1] |
gboolean gst_byte_writer_put_string_utf8 (GstByteWriter *writer
,const gchar *data
);
Writes a NUL-terminated UTF8 string to writer
(including the terminator).
gboolean gst_byte_writer_put_data (GstByteWriter *writer
,const guint8 *data
,guint size
);
Writes size
bytes of data
to writer
.
writer |
GstByteWriter instance |
|
data |
Data to write. |
[transfer none][array length=size] |
size |
Size of |
gboolean gst_byte_writer_fill (GstByteWriter *writer
,guint8 value
,guint size
);
Writes size
bytes containing value
to writer
.
writer |
GstByteWriter instance |
|
value |
Value to be written |
|
size |
Number of bytes to be written |
gboolean gst_byte_writer_put_buffer (GstByteWriter *writer
,GstBuffer *buffer
,gsize offset
,gssize size
);
Writes size
bytes of data
to writer
.
writer |
GstByteWriter instance |
|
buffer |
source GstBuffer. |
[transfer none] |
offset |
offset to copy from |
|
size |
total size to copy. If -1, all data is copied |
void gst_byte_writer_put_buffer_unchecked (GstByteWriter *writer
,GstBuffer *buffer
,gsize offset
,gssize size
);
void gst_byte_writer_put_int8_unchecked (GstByteWriter *writer
,gint8 val
);
void gst_byte_writer_put_int16_be_unchecked (GstByteWriter *writer
,gint16 val
);
Writes a signed big endian 16 bit integer to writer
without
checking if there is enough free space available in the byte writer.
void gst_byte_writer_put_int16_le_unchecked (GstByteWriter *writer
,gint16 val
);
Writes a signed little endian 16 bit integer to writer
without
checking if there is enough free space available in the byte writer.
void gst_byte_writer_put_int24_be_unchecked (GstByteWriter *writer
,gint32 val
);
Writes a signed big endian 24 bit integer to writer
without
checking if there is enough free space available in the byte writer.
void gst_byte_writer_put_int24_le_unchecked (GstByteWriter *writer
,gint32 val
);
Writes a signed little endian 24 bit integer to writer
without
checking if there is enough free space available in the byte writer.
void gst_byte_writer_put_int32_be_unchecked (GstByteWriter *writer
,gint32 val
);
Writes a signed big endian 32 bit integer to writer
without
checking if there is enough free space available in the byte writer.
void gst_byte_writer_put_int32_le_unchecked (GstByteWriter *writer
,gint32 val
);
Writes a signed little endian 32 bit integer to writer
without
checking if there is enough free space available in the byte writer.
void gst_byte_writer_put_int64_be_unchecked (GstByteWriter *writer
,gint64 val
);
Writes a signed big endian 64 bit integer to writer
without
checking if there is enough free space available in the byte writer.
void gst_byte_writer_put_int64_le_unchecked (GstByteWriter *writer
,gint64 val
);
Writes a signed little endian 64 bit integer to writer
without
checking if there is enough free space available in the byte writer.
void gst_byte_writer_put_uint8_unchecked (GstByteWriter *writer
,guint8 val
);
Writes a unsigned 8 bit integer to writer
without checking if there
is enough free space available in the byte writer.
void gst_byte_writer_put_uint16_be_unchecked (GstByteWriter *writer
,guint16 val
);
Writes a unsigned big endian 16 bit integer to writer
without
checking if there is enough free space available in the byte writer.
void gst_byte_writer_put_uint16_le_unchecked (GstByteWriter *writer
,guint16 val
);
Writes a unsigned little endian 16 bit integer to writer
without
checking if there is enough free space available in the byte writer.
void gst_byte_writer_put_uint24_be_unchecked (GstByteWriter *writer
,guint32 val
);
Writes a unsigned big endian 24 bit integer to writer
without
checking if there is enough free space available in the byte writer.
void gst_byte_writer_put_uint24_le_unchecked (GstByteWriter *writer
,guint32 val
);
Writes a unsigned little endian 24 bit integer to writer
without
checking if there is enough free space available in the byte writer.
void gst_byte_writer_put_uint32_be_unchecked (GstByteWriter *writer
,guint32 val
);
Writes a unsigned big endian 32 bit integer to writer
without
checking if there is enough free space available in the byte writer.
void gst_byte_writer_put_uint32_le_unchecked (GstByteWriter *writer
,guint32 val
);
Writes a unsigned little endian 32 bit integer to writer
without
checking if there is enough free space available in the byte writer.
void gst_byte_writer_put_uint64_be_unchecked (GstByteWriter *writer
,guint64 val
);
Writes a unsigned big endian 64 bit integer to writer
without
checking if there is enough free space available in the byte writer.
void gst_byte_writer_put_uint64_le_unchecked (GstByteWriter *writer
,guint64 val
);
Writes a unsigned little endian 64 bit integer to writer
without
checking if there is enough free space available in the byte writer.
void gst_byte_writer_put_float32_be_unchecked (GstByteWriter *writer
,gfloat val
);
Writes a big endian 32 bit float to writer
without
checking if there is enough free space available in the byte writer.
void gst_byte_writer_put_float32_le_unchecked (GstByteWriter *writer
,gfloat val
);
Writes a little endian 32 bit float to writer
without
checking if there is enough free space available in the byte writer.
void gst_byte_writer_put_float64_be_unchecked (GstByteWriter *writer
,gdouble val
);
Writes a big endian 64 bit float to writer
without
checking if there is enough free space available in the byte writer.
void gst_byte_writer_put_float64_le_unchecked (GstByteWriter *writer
,gdouble val
);
Writes a little endian 64 bit float to writer
without
checking if there is enough free space available in the byte writer.
void gst_byte_writer_put_data_unchecked (GstByteWriter *writer
,const guint8 *data
,guint size
);
Writes size
bytes of data
to writer
without
checking if there is enough free space available in the byte writer.
writer |
GstByteWriter instance |
|
data |
Data to write. |
[in][transfer none][array length=size] |
size |
Size of |
void gst_byte_writer_fill_unchecked (GstByteWriter *writer
,guint8 value
,guint size
);
Writes size
bytes containing value
to writer
without
checking if there is enough free space available in the byte writer.
writer |
GstByteWriter instance |
|
value |
Value to be written |
|
size |
Number of bytes to be written |
typedef struct { GstByteReader parent; guint alloc_size; gboolean fixed; gboolean owned; } GstByteWriter;
A byte writer instance.
GstByteReader |
GstByteReader parent |
|
guint |
Allocation size of the data |
|
gboolean |
If |
|
gboolean |
If |