GstUtils

GstUtils — Various utility functions

Synopsis


#include <gst/gst.h>


#define     GST_BOILERPLATE_WITH_INTERFACE  (type, type_as_function,		\
    parent_type, parent_type_as_macro, interface_type,			\
    interface_type_as_macro, interface_as_function)
#define     GST_BOILERPLATE_FULL            (type, type_as_function, parent_type, parent_type_macro, additional_initializations)
#define     GST_BOILERPLATE                 (type,type_as_function,parent_type,parent_type_macro)
#define     GST_CALL_PARENT                 (parent_class_cast, name, args)
#define     GST_CALL_PARENT_WITH_DEFAULT    (parent_class_cast, name, args, def_return)
#define     GST_READ_UINT8                  (data)
#define     GST_READ_UINT16_LE              (data)
#define     GST_READ_UINT16_BE              (data)
#define     GST_READ_UINT32_LE              (data)
#define     GST_READ_UINT32_BE              (data)
#define     GST_READ_UINT64_LE              (data)
#define     GST_READ_UINT64_BE              (data)
#define     GST_WRITE_UINT8                 (data, num)
#define     GST_WRITE_UINT16_LE             (data, num)
#define     GST_WRITE_UINT16_BE             (data, num)
#define     GST_WRITE_UINT32_LE             (data, num)
#define     GST_WRITE_UINT32_BE             (data, num)
#define     GST_WRITE_UINT64_LE             (data, num)
#define     GST_WRITE_UINT64_BE             (data, num)
#define     GST_ROUND_UP_2                  (num)
#define     GST_ROUND_UP_4                  (num)
#define     GST_ROUND_UP_8                  (num)
#define     GST_ROUND_UP_16                 (num)
#define     GST_ROUND_UP_32                 (num)
#define     GST_ROUND_UP_64                 (num)
void        gst_atomic_int_set              (gint *atomic_int,
                                             gint value);
const gchar* gst_flow_get_name              (GstFlowReturn ret);
GQuark      gst_flow_to_quark               (GstFlowReturn ret);
void        gst_print_element_args          (GString *buf,
                                             gint indent,
                                             GstElement *element);
void        gst_print_pad_caps              (GString *buf,
                                             gint indent,
                                             GstPad *pad);
#define     gst_guint64_to_gdouble          (value)
#define     gst_gdouble_to_guint64          (value)
void        gst_util_dump_mem               (const guchar *mem,
                                             guint size);
guint64     gst_util_uint64_scale           (guint64 val,
                                             guint64 num,
                                             guint64 denom);
guint64     gst_util_uint64_scale_int       (guint64 val,
                                             gint num,
                                             gint denom);
void        gst_util_set_object_arg         (GObject *object,
                                             const gchar *name,
                                             const gchar *value);
void        gst_util_set_value_from_string  (GValue *value,
                                             const gchar *value_str);

Description

When defining own plugins, use the GST_BOILERPLATE ease gobject creation.

Details

GST_BOILERPLATE_WITH_INTERFACE()

#define     GST_BOILERPLATE_WITH_INTERFACE(type, type_as_function,		\
    parent_type, parent_type_as_macro, interface_type,			\
    interface_type_as_macro, interface_as_function)

Like GST_BOILERPLATE, but makes the type 1) implement an interface, and 2) implement GstImplementsInterface for that type.

After this you will need to implement interface_as_function ## _supported and interface_as_function ## _interface_init

type :type the name of the type struct the name of the type struct type_as_function :type_as_function the prefix for the functions the prefix for the functions parent_type :parent_type the parent type struct name the parent type struct name parent_type_as_macro :parent_type_as_macro the parent type macro the parent type macro interface_type :interface_type the name of the interface type struct the name of the interface type struct interface_type_as_macro :interface_type_as_macro the interface type macro the interface type macro interface_as_function :interface_as_function the interface function name prefix the interface function name prefix
type : the name of the type struct
type_as_function : the prefix for the functions
parent_type : the parent type struct name
parent_type_as_macro : the parent type macro
interface_type : the name of the interface type struct
interface_type_as_macro : the interface type macro
interface_as_function : the interface function name prefix

GST_BOILERPLATE_FULL()

#define     GST_BOILERPLATE_FULL(type, type_as_function, parent_type, parent_type_macro, additional_initializations)

Define the boilerplate type stuff to reduce typos and code size. Defines the get_type method and the parent_class static variable.

  GST_BOILERPLATE_FULL (GstFdSink, gst_fdsink, GstElement, GST_TYPE_ELEMENT, _do_init);

type :type the name of the type struct the name of the type struct type_as_function :type_as_function the prefix for the functions the prefix for the functions parent_type :parent_type the parent type struct name the parent type struct name parent_type_macro :parent_type_macro the parent type macro the parent type macro additional_initializations :additional_initializations function pointer in the form of void additional_initializations (GType type) that can be used for initializing interfaces and the like function pointer in the form of void additional_initializations (GType type) that can be used for initializing interfaces and the like
type : the name of the type struct
type_as_function : the prefix for the functions
parent_type : the parent type struct name
parent_type_macro : the parent type macro
additional_initializations : function pointer in the form of void additional_initializations (GType type) that can be used for initializing interfaces and the like

GST_BOILERPLATE()

#define     GST_BOILERPLATE(type,type_as_function,parent_type,parent_type_macro)

Define the boilerplate type stuff to reduce typos and code size. Defines the get_type method and the parent_class static variable.

  GST_BOILERPLATE (GstFdSink, gst_fdsink, GstElement, GST_TYPE_ELEMENT);

type :type the name of the type struct the name of the type struct type_as_function :type_as_function the prefix for the functions the prefix for the functions parent_type :parent_type the parent type struct name the parent type struct name parent_type_macro :parent_type_macro the parent type macro the parent type macro
type : the name of the type struct
type_as_function : the prefix for the functions
parent_type : the parent type struct name
parent_type_macro : the parent type macro

GST_CALL_PARENT()

#define     GST_CALL_PARENT(parent_class_cast, name, args)

Just call the parent handler. This assumes that there is a variable named parent_class that points to the (duh!) parent class. Note that this macro is not to be used with things that return something, use the _WITH_DEFAULT version for that

parent_class_cast :parent_class_cast the name of the class cast macro for the parent type the name of the class cast macro for the parent type name :name name of the function to call name of the function to call args :args arguments enclosed in '( )' arguments enclosed in '( )'
parent_class_cast : the name of the class cast macro for the parent type
name : name of the function to call
args : arguments enclosed in '( )'

GST_CALL_PARENT_WITH_DEFAULT()

#define     GST_CALL_PARENT_WITH_DEFAULT(parent_class_cast, name, args, def_return)

Same as GST_CALL_PARENT(), but in case there is no implementation, it evaluates to def_return.

parent_class_cast :parent_class_cast the name of the class cast macro for the parent type the name of the class cast macro for the parent type name :name name of the function to call name of the function to call args :args arguments enclosed in '( )' arguments enclosed in '( )' def_return :def_return default result default result
parent_class_cast : the name of the class cast macro for the parent type
name : name of the function to call
args : arguments enclosed in '( )'
def_return : default result

GST_READ_UINT8()

#define     GST_READ_UINT8(data)

Read an 8 bit unsigned integer value from the memory buffer.

data :data memory location memory location
data : memory location

GST_READ_UINT16_LE()

#define     GST_READ_UINT16_LE(data)

Read a 16 bit unsigned integer value in little endian format from the memory buffer.

data :data memory location memory location
data : memory location

GST_READ_UINT16_BE()

#define     GST_READ_UINT16_BE(data)

Read a 16 bit unsigned integer value in big endian format from the memory buffer.

data :data memory location memory location
data : memory location

GST_READ_UINT32_LE()

#define     GST_READ_UINT32_LE(data)

Read a 32 bit unsigned integer value in little endian format from the memory buffer.

data :data memory location memory location
data : memory location

GST_READ_UINT32_BE()

#define     GST_READ_UINT32_BE(data)

Read a 32 bit unsigned integer value in big endian format from the memory buffer.

data :data memory location memory location
data : memory location

GST_READ_UINT64_LE()

#define     GST_READ_UINT64_LE(data)

Read a 64 bit unsigned integer value in little endian format from the memory buffer.

data :data memory location memory location
data : memory location

GST_READ_UINT64_BE()

#define     GST_READ_UINT64_BE(data)

Read a 64 bit unsigned integer value in big endian format from the memory buffer.

data :data memory location memory location
data : memory location

GST_WRITE_UINT8()

#define     GST_WRITE_UINT8(data, num)

Store an 8 bit unsigned integer value into the memory buffer.

data :data memory location memory location num :num value to store value to store
data : memory location
num : value to store

GST_WRITE_UINT16_LE()

#define     GST_WRITE_UINT16_LE(data, num)

Store a 16 bit unsigned integer value in little endian format into the memory buffer.

data :data memory location memory location num :num value to store value to store
data : memory location
num : value to store

GST_WRITE_UINT16_BE()

#define     GST_WRITE_UINT16_BE(data, num)

Store a 16 bit unsigned integer value in big endian format into the memory buffer.

data :data memory location memory location num :num value to store value to store
data : memory location
num : value to store

GST_WRITE_UINT32_LE()

#define     GST_WRITE_UINT32_LE(data, num)

Store a 32 bit unsigned integer value in little endian format into the memory buffer.

data :data memory location memory location num :num value to store value to store
data : memory location
num : value to store

GST_WRITE_UINT32_BE()

#define     GST_WRITE_UINT32_BE(data, num)

Store a 32 bit unsigned integer value in big endian format into the memory buffer.

data :data memory location memory location num :num value to store value to store
data : memory location
num : value to store

GST_WRITE_UINT64_LE()

#define     GST_WRITE_UINT64_LE(data, num)

Store a 64 bit unsigned integer value in little endian format into the memory buffer.

data :data memory location memory location num :num value to store value to store
data : memory location
num : value to store

GST_WRITE_UINT64_BE()

#define     GST_WRITE_UINT64_BE(data, num)

Store a 64 bit unsigned integer value in big endian format into the memory buffer.

data :data memory location memory location num :num value to store value to store
data : memory location
num : value to store

GST_ROUND_UP_2()

#define GST_ROUND_UP_2(num)  (((num)+1)&~1)

Make number divideable by two without a rest.

num :num value round up value round up
num : value round up

GST_ROUND_UP_4()

#define GST_ROUND_UP_4(num)  (((num)+3)&~3)

Make number divideable by four without a rest.

num :num value round up value round up
num : value round up

GST_ROUND_UP_8()

#define GST_ROUND_UP_8(num)  (((num)+7)&~7)

Make number divideable by eight without a rest.

num :num value round up value round up
num : value round up

GST_ROUND_UP_16()

#define GST_ROUND_UP_16(num) (((num)+15)&~15)

Make number divideable by 16 without a rest.

num :num value round up value round up
num : value round up

GST_ROUND_UP_32()

#define GST_ROUND_UP_32(num) (((num)+31)&~31)

Make number divideable by 32 without a rest.

num :num value round up value round up
num : value round up

GST_ROUND_UP_64()

#define GST_ROUND_UP_64(num) (((num)+63)&~63)

Make number divideable by 64 without a rest.

num :num value round up value round up
num : value round up

gst_atomic_int_set ()

void        gst_atomic_int_set              (gint *atomic_int,
                                             gint value);

Unconditionally sets the atomic integer to value.

atomic_int :atomic_int pointer to an atomic integer pointer to an atomic integer value :value value to set value to set
atomic_int : pointer to an atomic integer
value : value to set

gst_flow_get_name ()

const gchar* gst_flow_get_name              (GstFlowReturn ret);

Gets a string representing the given flow return.

ret :ret a GstFlowReturn to get the name of. a GstFlowReturn to get the name of. GstFlowReturnGstFlowReturnReturns :Returns a static string with the name of the flow return. a static string with the name of the flow return.
ret : a GstFlowReturn to get the name of.
Returns : a static string with the name of the flow return.

gst_flow_to_quark ()

GQuark      gst_flow_to_quark               (GstFlowReturn ret);

Get the unique quark for the given GstFlowReturn.

ret :ret a GstFlowReturn to get the quark of. a GstFlowReturn to get the quark of. GstFlowReturnGstFlowReturnReturns :Returns the quark associated with the flow return or 0 if an invalid return was specified. the quark associated with the flow return or 0 if an invalid return was specified.
ret : a GstFlowReturn to get the quark of.
Returns : the quark associated with the flow return or 0 if an invalid return was specified.

gst_print_element_args ()

void        gst_print_element_args          (GString *buf,
                                             gint indent,
                                             GstElement *element);

Print the element argument in a human readable format in the given GString.

buf :buf the buffer to print the args in the buffer to print the args in indent :indent initial indentation initial indentation element :element the element to print the args of the element to print the args of
buf : the buffer to print the args in
indent : initial indentation
element : the element to print the args of

gst_print_pad_caps ()

void        gst_print_pad_caps              (GString *buf,
                                             gint indent,
                                             GstPad *pad);

Write the pad capabilities in a human readable format into the given GString.

buf :buf the buffer to print the caps in the buffer to print the caps in indent :indent initial indentation initial indentation pad :pad the pad to print the caps from the pad to print the caps from
buf : the buffer to print the caps in
indent : initial indentation
pad : the pad to print the caps from

gst_guint64_to_gdouble()

#define     gst_guint64_to_gdouble(value)

Convert value to a gdouble.

value :value the guint64 value to convert the guint64 value to convert guint64guint64
value : the guint64 value to convert

gst_gdouble_to_guint64()

#define     gst_gdouble_to_guint64(value)

Convert value to a guint64.

value :value the gdouble value to convert the gdouble value to convert gdoublegdouble
value : the gdouble value to convert

gst_util_dump_mem ()

void        gst_util_dump_mem               (const guchar *mem,
                                             guint size);

Dumps the memory block into a hex representation. Useful for debugging.

mem :mem a pointer to the memory to dump a pointer to the memory to dump size :size the size of the memory block to dump the size of the memory block to dump
mem : a pointer to the memory to dump
size : the size of the memory block to dump

gst_util_uint64_scale ()

guint64     gst_util_uint64_scale           (guint64 val,
                                             guint64 num,
                                             guint64 denom);

Scale val by num / denom, trying to avoid overflows.

This function can potentially be very slow if denom > G_MAXUINT32.

val :val the number to scale the number to scale num :num the numerator of the scale ratio the numerator of the scale ratio denom :denom the denominator of the scale ratio the denominator of the scale ratio Returns :Returns val * num / denom, trying to avoid overflows. In the case of an overflow, this function returns G_MAXUINT64. val * num / denom, trying to avoid overflows. In the case of an overflow, this function returns G_MAXUINT64. valnumdenom
val : the number to scale
num : the numerator of the scale ratio
denom : the denominator of the scale ratio
Returns : val * num / denom, trying to avoid overflows. In the case of an overflow, this function returns G_MAXUINT64.

gst_util_uint64_scale_int ()

guint64     gst_util_uint64_scale_int       (guint64 val,
                                             gint num,
                                             gint denom);

Scale a guint64 by a factor expressed as a fraction (num/denom), avoiding overflows and loss of precision.

num and denom must be positive integers. denom cannot be 0.

val :val guint64 (such as a GstClockTime) to scale. guint64 (such as a GstClockTime) to scale. GstClockTimeGstClockTimenum :num numerator of the scale factor. numerator of the scale factor. denom :denom denominator of the scale factor. denominator of the scale factor. Returns :Returns val * num / denom, avoiding overflow and loss of precision. In the case of an overflow, this function returns G_MAXUINT64. val * num / denom, avoiding overflow and loss of precision. In the case of an overflow, this function returns G_MAXUINT64. valnumdenom
val : guint64 (such as a GstClockTime) to scale.
num : numerator of the scale factor.
denom : denominator of the scale factor.
Returns : val * num / denom, avoiding overflow and loss of precision. In the case of an overflow, this function returns G_MAXUINT64.

gst_util_set_object_arg ()

void        gst_util_set_object_arg         (GObject *object,
                                             const gchar *name,
                                             const gchar *value);

Convertes the string value to the type of the objects argument and sets the argument with it.

object :object the object to set the argument of the object to set the argument of name :name the name of the argument to set the name of the argument to set value :value the string value to set the string value to set
object : the object to set the argument of
name : the name of the argument to set
value : the string value to set

gst_util_set_value_from_string ()

void        gst_util_set_value_from_string  (GValue *value,
                                             const gchar *value_str);

Converts the string to the type of the value and sets the value with it.

value :value the value to set the value to set value_str :value_str the string to get the value from the string to get the value from
value : the value to set
value_str : the string to get the value from