*
* You should have received a copy of the GNU Library General Public
* License along with this library; if not, write to the
- * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
- * Boston, MA 02111-1307, USA.
+ * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
*/
#ifdef HAVE_CONFIG_H
/**
* SECTION:gstbytewriter
+ * @title: GstByteWriter
* @short_description: Writes different integer, string and floating point
* types to a memory buffer and allows reading
*
*/
/**
- * gst_byte_writer_new:
+ * gst_byte_writer_new: (skip)
*
* Creates a new, empty #GstByteWriter instance
*
* Free-function: gst_byte_writer_free
*
* Returns: (transfer full): a new, empty #GstByteWriter instance
- *
- * Since: 0.10.26
*/
GstByteWriter *
gst_byte_writer_new (void)
}
/**
- * gst_byte_writer_new_with_size:
+ * gst_byte_writer_new_with_size: (skip)
* @size: Initial size of data
* @fixed: If %TRUE the data can't be reallocated
*
* Free-function: gst_byte_writer_free
*
* Returns: (transfer full): a new #GstByteWriter instance
- *
- * Since: 0.10.26
*/
GstByteWriter *
gst_byte_writer_new_with_size (guint size, gboolean fixed)
}
/**
- * gst_byte_writer_new_with_data:
+ * gst_byte_writer_new_with_data: (skip)
* @data: Memory area for writing
* @size: Size of @data in bytes
* @initialized: If %TRUE the complete data can be read from the beginning
* Free-function: gst_byte_writer_free
*
* Returns: (transfer full): a new #GstByteWriter instance
- *
- * Since: 0.10.26
*/
GstByteWriter *
gst_byte_writer_new_with_data (guint8 * data, guint size, gboolean initialized)
* @writer: #GstByteWriter instance
*
* Initializes @writer to an empty instance
- *
- * Since: 0.10.26
*/
void
gst_byte_writer_init (GstByteWriter * writer)
* @fixed: If %TRUE the data can't be reallocated
*
* Initializes @writer with the given initial data size.
- *
- * Since: 0.10.26
*/
void
gst_byte_writer_init_with_size (GstByteWriter * writer, guint size,
/**
* gst_byte_writer_init_with_data:
* @writer: #GstByteWriter instance
- * @data: (in callee-allocated) (array length=size) (transfer none): Memory
- * area for writing
+ * @data: (array length=size) (transfer none): Memory area for writing
* @size: Size of @data in bytes
* @initialized: If %TRUE the complete data can be read from the beginning
*
* Initializes @writer with the given
* memory area. If @initialized is %TRUE it is possible to
* read @size bytes from the #GstByteWriter from the beginning.
- *
- * Since: 0.10.26
*/
void
gst_byte_writer_init_with_data (GstByteWriter * writer, guint8 * data,
*
* Resets @writer and frees the data if it's
* owned by @writer.
- *
- * Since: 0.10.26
*/
void
gst_byte_writer_reset (GstByteWriter * writer)
*
* Free-function: g_free
*
- * Returns: (transfer full): the current data. g_free() after usage.
- *
- * Since: 0.10.26
+ * Returns: (array) (transfer full): the current data. g_free() after
+ * usage.
*/
guint8 *
gst_byte_writer_reset_and_get_data (GstByteWriter * writer)
*
* Returns: (transfer full): the current data as buffer. gst_buffer_unref()
* after usage.
- *
- * Since: 0.10.26
*/
GstBuffer *
gst_byte_writer_reset_and_get_buffer (GstByteWriter * writer)
buffer = gst_buffer_new ();
if (data != NULL) {
- gst_buffer_take_memory (buffer, -1,
- gst_memory_new_wrapped (0, data, g_free, size, 0, size));
+ gst_buffer_append_memory (buffer,
+ gst_memory_new_wrapped (0, data, size, 0, size, data, g_free));
}
return buffer;
* @writer: (in) (transfer full): #GstByteWriter instance
*
* Frees @writer and all memory allocated by it.
- *
- * Since: 0.10.26
*/
void
gst_byte_writer_free (GstByteWriter * writer)
* Free-function: g_free
*
* Returns: (transfer full): the current data. g_free() after usage.
- *
- * Since: 0.10.26
*/
guint8 *
gst_byte_writer_free_and_get_data (GstByteWriter * writer)
*
* Returns: (transfer full): the current data as buffer. gst_buffer_unref()
* after usage.
- *
- * Since: 0.10.26
*/
GstBuffer *
gst_byte_writer_free_and_get_buffer (GstByteWriter * writer)
* -1 is returned the remaining size is only limited by system resources.
*
* Returns: the remaining size of data that can still be written
- *
- * Since: 0.10.26
*/
guint
gst_byte_writer_get_remaining (const GstByteWriter * writer)
* available and reallocates if necessary.
*
* Returns: %TRUE if at least @size bytes are still available
- *
- * Since: 0.10.26
*/
gboolean
gst_byte_writer_ensure_free_space (GstByteWriter * writer, guint size)
* Writes a unsigned 8 bit integer to @writer.
*
* Returns: %TRUE if the value could be written
- *
- * Since: 0.10.26
*/
/**
* gst_byte_writer_put_uint16_be:
* Writes a unsigned big endian 16 bit integer to @writer.
*
* Returns: %TRUE if the value could be written
- *
- * Since: 0.10.26
*/
/**
* gst_byte_writer_put_uint24_be:
* Writes a unsigned big endian 24 bit integer to @writer.
*
* Returns: %TRUE if the value could be written
- *
- * Since: 0.10.26
*/
/**
* gst_byte_writer_put_uint32_be:
* Writes a unsigned big endian 32 bit integer to @writer.
*
* Returns: %TRUE if the value could be written
- *
- * Since: 0.10.26
*/
/**
* gst_byte_writer_put_uint64_be:
* Writes a unsigned big endian 64 bit integer to @writer.
*
* Returns: %TRUE if the value could be written
- *
- * Since: 0.10.26
*/
/**
* gst_byte_writer_put_uint16_le:
* Writes a unsigned little endian 16 bit integer to @writer.
*
* Returns: %TRUE if the value could be written
- *
- * Since: 0.10.26
*/
/**
* gst_byte_writer_put_uint24_le:
* Writes a unsigned little endian 24 bit integer to @writer.
*
* Returns: %TRUE if the value could be written
- *
- * Since: 0.10.26
*/
/**
* gst_byte_writer_put_uint32_le:
* Writes a unsigned little endian 32 bit integer to @writer.
*
* Returns: %TRUE if the value could be written
- *
- * Since: 0.10.26
*/
/**
* gst_byte_writer_put_uint64_le:
* Writes a unsigned little endian 64 bit integer to @writer.
*
* Returns: %TRUE if the value could be written
- *
- * Since: 0.10.26
*/
/**
* gst_byte_writer_put_int8:
* Writes a signed 8 bit integer to @writer.
*
* Returns: %TRUE if the value could be written
- *
- * Since: 0.10.26
*/
/**
* gst_byte_writer_put_int16_be:
* Writes a signed big endian 16 bit integer to @writer.
*
* Returns: %TRUE if the value could be written
- *
- * Since: 0.10.26
*/
/**
* gst_byte_writer_put_int24_be:
* Writes a signed big endian 24 bit integer to @writer.
*
* Returns: %TRUE if the value could be written
- *
- * Since: 0.10.26
*/
/**
* gst_byte_writer_put_int32_be:
* Writes a signed big endian 32 bit integer to @writer.
*
* Returns: %TRUE if the value could be written
- *
- * Since: 0.10.26
*/
/**
* gst_byte_writer_put_int64_be:
* Writes a signed big endian 64 bit integer to @writer.
*
* Returns: %TRUE if the value could be written
- *
- * Since: 0.10.26
*/
/**
* gst_byte_writer_put_int16_le:
* Writes a signed little endian 16 bit integer to @writer.
*
* Returns: %TRUE if the value could be written
- *
- * Since: 0.10.26
*/
/**
* gst_byte_writer_put_int24_le:
* Writes a signed little endian 24 bit integer to @writer.
*
* Returns: %TRUE if the value could be written
- *
- * Since: 0.10.26
*/
/**
* gst_byte_writer_put_int32_le:
* Writes a signed little endian 32 bit integer to @writer.
*
* Returns: %TRUE if the value could be written
- *
- * Since: 0.10.26
*/
/**
* gst_byte_writer_put_int64_le:
* Writes a signed little endian 64 bit integer to @writer.
*
* Returns: %TRUE if the value could be written
- *
- * Since: 0.10.26
*/
/**
* gst_byte_writer_put_float32_be:
* Writes a big endian 32 bit float to @writer.
*
* Returns: %TRUE if the value could be written
- *
- * Since: 0.10.27
*/
/**
* gst_byte_writer_put_float64_be:
* Writes a big endian 64 bit float to @writer.
*
* Returns: %TRUE if the value could be written
- *
- * Since: 0.10.27
*/
/**
* gst_byte_writer_put_float32_le:
* Writes a little endian 32 bit float to @writer.
*
* Returns: %TRUE if the value could be written
- *
- * Since: 0.10.27
*/
/**
* gst_byte_writer_put_float64_le:
* Writes a little endian 64 bit float to @writer.
*
* Returns: %TRUE if the value could be written
- *
- * Since: 0.10.27
*/
/**
* gst_byte_writer_put_string_utf8:
* @writer: #GstByteWriter instance
- * @data: (transfer none) (array zero-terminated=1) (type utf8): UTF8 string to
- * write
+ * @data: (transfer none): UTF8 string to write
*
* Writes a NUL-terminated UTF8 string to @writer (including the terminator).
*
* Returns: %TRUE if the value could be written
- *
- * Since: 0.10.26
*/
/**
* gst_byte_writer_put_string_utf16:
* Writes a NUL-terminated UTF16 string to @writer (including the terminator).
*
* Returns: %TRUE if the value could be written
- *
- * Since: 0.10.26
*/
/**
* gst_byte_writer_put_string_utf32:
* Writes a NUL-terminated UTF32 string to @writer (including the terminator).
*
* Returns: %TRUE if the value could be written
- *
- * Since: 0.10.26
*/
/**
* gst_byte_writer_put_data:
* Writes @size bytes of @data to @writer.
*
* Returns: %TRUE if the value could be written
- *
- * Since: 0.10.26
*/
/**
* gst_byte_writer_fill:
* @writer: #GstByteWriter instance
- * @value: Value to be writen
- * @size: Number of bytes to be writen
+ * @value: Value to be written
+ * @size: Number of bytes to be written
*
* Writes @size bytes containing @value to @writer.
*
* Returns: %TRUE if the value could be written
- *
- * Since: 0.10.27
*/
/**
* Returns: %TRUE if the data could be written
*
*/
-gboolean
-gst_byte_writer_put_buffer (GstByteWriter * writer, GstBuffer * buffer,
- gsize offset, gssize size)
-{
- g_return_val_if_fail (writer != NULL, FALSE);
- g_return_val_if_fail (size >= -1, FALSE);
-
- if (size == -1) {
- size = gst_buffer_get_size (buffer);
-
- if (offset >= (gsize) size)
- return TRUE;
-
- size -= offset;
- }
-
- if (G_UNLIKELY (!_gst_byte_writer_ensure_free_space_inline (writer, size)))
- return FALSE;
-
- gst_buffer_extract (buffer, offset,
- (guint8 *) & writer->parent.data[writer->parent.byte], size);
- writer->parent.byte += size;
- writer->parent.size = MAX (writer->parent.size, writer->parent.byte);
-
- return TRUE;
-}