:right-sidebar: True BitWriter =================================================================== .. currentmodule:: gi.repository.GstBase .. versionadded:: 1.16 .. class:: BitWriter(*args, **kwargs) :no-contents-entry: :obj:`~gi.repository.GstBase.BitWriter` provides a bit writer that can write any number of bits into a memory buffer. It provides functions for writing any number of bits into 8, 16, 32 and 64 bit variables. Methods ------- .. rst-class:: interim-class .. class:: BitWriter :no-index: .. method:: align_bytes(trailing_bit: int) -> bool Write trailing bit to align last byte of ``data``\. ``trailing_bit`` can only be 1 or 0. :param trailing_bit: trailing bits of last byte, 0 or 1 .. method:: free() -> None Frees ``bitwriter`` and the allocated data inside. .. method:: free_and_get_buffer() -> ~gi.repository.Gst.Buffer Frees ``bitwriter`` without destroying the internal data, which is returned as :obj:`~gi.repository.Gst.Buffer`\. Free-function: gst_buffer_unref .. method:: free_and_get_data() -> list[int] Frees ``bitwriter`` without destroying the internal data, which is returned. Free-function: g_free .. method:: get_data() -> list[int] Get written data pointer .. method:: get_remaining() -> int .. method:: get_size() -> int Get size of written ``data`` .. method:: put_bits_uint16(value: int, nbits: int) -> bool Write ``nbits`` bits of ``value`` to :obj:`~gi.repository.GstBase.BitWriter`\. :param value: value of :obj:`int` to write :param nbits: number of bits to write .. method:: put_bits_uint32(value: int, nbits: int) -> bool Write ``nbits`` bits of ``value`` to :obj:`~gi.repository.GstBase.BitWriter`\. :param value: value of :obj:`int` to write :param nbits: number of bits to write .. method:: put_bits_uint64(value: int, nbits: int) -> bool Write ``nbits`` bits of ``value`` to :obj:`~gi.repository.GstBase.BitWriter`\. :param value: value of :obj:`int` to write :param nbits: number of bits to write .. method:: put_bits_uint8(value: int, nbits: int) -> bool Write ``nbits`` bits of ``value`` to :obj:`~gi.repository.GstBase.BitWriter`\. :param value: value of :obj:`int` to write :param nbits: number of bits to write .. method:: put_bytes(data: list[int], nbytes: int) -> bool Write ``nbytes`` bytes of ``data`` to :obj:`~gi.repository.GstBase.BitWriter`\. :param data: pointer of data to write :param nbytes: number of bytes to write .. method:: reset() -> None Resets ``bitwriter`` and frees the data if it's owned by ``bitwriter``\. .. method:: reset_and_get_buffer() -> ~gi.repository.Gst.Buffer Resets ``bitwriter`` and returns the current data as :obj:`~gi.repository.Gst.Buffer`\. Free-function: gst_buffer_unref .. method:: reset_and_get_data() -> list[int] Resets ``bitwriter`` and returns the current data. Free-function: g_free .. method:: set_pos(pos: int) -> bool :param pos: Fields ------ .. rst-class:: interim-class .. class:: BitWriter :no-index: .. attribute:: auto_grow .. attribute:: bit_capacity .. attribute:: bit_size Size of written ``data`` in bits .. attribute:: data Allocated ``data`` for bit writer to write .. attribute:: owned