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);
void        gst_bin_watch_for_state_change  (GstBin *bin);
const gchar* gst_flow_get_name              (GstFlowReturn ret);
void        gst_print_element_args          (GString *buf,
                                             gint indent,
                                             GstElement *element);
void        gst_print_pad_caps              (GString *buf,
                                             gint indent,
                                             GstPad *pad);
void        gst_util_dump_mem               (const guchar *mem,
                                             guint size);
guint64     gst_util_uint64_scale           (guint64 val,
                                             guint64 num,
                                             guint64 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)

type :
type_as_function :
parent_type : @\ parent_type_as_macro: @\ parent_type_as_macro: @\ parent_type_as_macro: @\ parent_type_as_macro: @\ parent_type_as_macro: @\ parent_type_as_macro: @\ parent_type_as_macro: @\ parent_type_as_macro: @\ parent_type_as_macro: @\ parent_type_as_macro:
interface_type :
interface_type_as_macro : @\ interface_as_function: @\ interface_as_function: @\ interface_as_function: @\ interface_as_function: @\ interface_as_function: @\ interface_as_function: @\ interface_as_function: @\ interface_as_function: @\ interface_as_function: @\ interface_as_function:

GST_BOILERPLATE_FULL()

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

type :
type_as_function :
parent_type :
parent_type_macro :
additional_initializations :

GST_BOILERPLATE()

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

type :
type_as_function :
parent_type :
parent_type_macro :

GST_CALL_PARENT()

#define     GST_CALL_PARENT(parent_class_cast, name, args)

parent_class_cast :
name :
args :

GST_CALL_PARENT_WITH_DEFAULT()

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

parent_class_cast :
name :
args :
def_return :

GST_READ_UINT8()

#define     GST_READ_UINT8(data)

data :

GST_READ_UINT16_LE()

#define     GST_READ_UINT16_LE(data)

data :

GST_READ_UINT16_BE()

#define     GST_READ_UINT16_BE(data)

data :

GST_READ_UINT32_LE()

#define     GST_READ_UINT32_LE(data)

data :

GST_READ_UINT32_BE()

#define     GST_READ_UINT32_BE(data)

data :

GST_READ_UINT64_LE()

#define     GST_READ_UINT64_LE(data)

data :

GST_READ_UINT64_BE()

#define     GST_READ_UINT64_BE(data)

data :

GST_WRITE_UINT8()

#define     GST_WRITE_UINT8(data, num)

data :
num :

GST_WRITE_UINT16_LE()

#define     GST_WRITE_UINT16_LE(data, num)

data :
num :

GST_WRITE_UINT16_BE()

#define     GST_WRITE_UINT16_BE(data, num)

data :
num :

GST_WRITE_UINT32_LE()

#define     GST_WRITE_UINT32_LE(data, num)

data :
num :

GST_WRITE_UINT32_BE()

#define     GST_WRITE_UINT32_BE(data, num)

data :
num :

GST_WRITE_UINT64_LE()

#define     GST_WRITE_UINT64_LE(data, num)

data :
num :

GST_WRITE_UINT64_BE()

#define     GST_WRITE_UINT64_BE(data, num)

data :
num :

GST_ROUND_UP_2()

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

num :

GST_ROUND_UP_4()

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

num :

GST_ROUND_UP_8()

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

num :

GST_ROUND_UP_16()

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

num :

GST_ROUND_UP_32()

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

num :

GST_ROUND_UP_64()

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

num :

gst_atomic_int_set ()

void        gst_atomic_int_set              (gint *atomic_int,
                                             gint value);

Unconditionally sets the atomic integer to value.

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

gst_bin_watch_for_state_change ()

void        gst_bin_watch_for_state_change  (GstBin *bin);

Spawns a thread calling gst_element_get_state on bin with infinite timeout.

In practice this is done because if a bin returns GST_STATE_CHANGE_ASYNC from a state change it will not commit its state until someone calls gst_element_get_state() on it. Thus having another thread checking the bin's state will ensure that a state-changed message gets posted on the bus eventually.

This function is admittedly a bit of a hack. Bins should always post messages. However this behavior was broken out into this function to avoid spawning threads when scrubbing, when the bin's state is changing quickly and asynchronously.

bin : the bin to watch for state changes

gst_flow_get_name ()

const gchar* gst_flow_get_name              (GstFlowReturn ret);

Gets a string representing the given flow return.

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

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 : 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 : the buffer to print the caps in
indent : initial indentation
pad : the pad to print the caps from

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 : 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.

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.

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 : 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 : the value to set
value_str : the string to get the value from