GStreamer 1.0 Core Reference Manual: GstUtils

## GstUtils GstUtils — Various utility functions |

## Functions

#define | GST_CALL_PARENT()
#define | GST_CALL_PARENT_WITH_DEFAULT()
#define | GST_READ_UINT8()
#define | GST_READ_UINT16_LE()
#define | GST_READ_UINT16_BE()
#define | GST_READ_UINT24_LE()
#define | GST_READ_UINT24_BE()
#define | GST_READ_UINT32_LE()
#define | GST_READ_UINT32_BE()
#define | GST_READ_UINT64_LE()
#define | GST_READ_UINT64_BE()
gfloat | GST_READ_FLOAT_LE ()
gfloat | GST_READ_FLOAT_BE ()
gdouble | GST_READ_DOUBLE_LE ()
gdouble | GST_READ_DOUBLE_BE ()
#define | GST_WRITE_UINT8()
#define | GST_WRITE_UINT16_LE()
#define | GST_WRITE_UINT16_BE()
#define | GST_WRITE_UINT24_LE()
#define | GST_WRITE_UINT24_BE()
#define | GST_WRITE_UINT32_LE()
#define | GST_WRITE_UINT32_BE()
#define | GST_WRITE_UINT64_LE()
#define | GST_WRITE_UINT64_BE()
void | GST_WRITE_FLOAT_LE ()
void | GST_WRITE_FLOAT_BE ()
void | GST_WRITE_DOUBLE_LE ()
void | GST_WRITE_DOUBLE_BE ()
#define | GST_ROUND_UP_2()
#define | GST_ROUND_UP_4()
#define | GST_ROUND_UP_8()
#define | GST_ROUND_UP_16()
#define | GST_ROUND_UP_32()
#define | GST_ROUND_UP_64()
#define | GST_ROUND_UP_128()
#define | GST_ROUND_UP_N()
#define | GST_ROUND_DOWN_2()
#define | GST_ROUND_DOWN_4()
#define | GST_ROUND_DOWN_8()
#define | GST_ROUND_DOWN_16()
#define | GST_ROUND_DOWN_32()
#define | GST_ROUND_DOWN_64()
#define | GST_ROUND_DOWN_128()
#define | GST_ROUND_DOWN_N()
#define | GDOUBLE_FROM_BE()
#define | GDOUBLE_FROM_LE()
gdouble | GDOUBLE_SWAP_LE_BE ()
#define | GDOUBLE_TO_BE()
#define | GDOUBLE_TO_LE()
#define | GFLOAT_FROM_BE()
#define | GFLOAT_FROM_LE()
gfloat | GFLOAT_SWAP_LE_BE ()
#define | GFLOAT_TO_BE()
#define | GFLOAT_TO_LE()
#define | gst_guint64_to_gdouble()
#define | gst_gdouble_to_guint64()
void | gst_util_dump_mem ()
guint64 | gst_util_uint64_scale ()
guint64 | gst_util_uint64_scale_round ()
guint64 | gst_util_uint64_scale_ceil ()
guint64 | gst_util_uint64_scale_int ()
guint64 | gst_util_uint64_scale_int_round ()
guint64 | gst_util_uint64_scale_int_ceil ()
gint | gst_util_greatest_common_divisor ()
gint64 | gst_util_greatest_common_divisor_int64 ()
void | gst_util_fraction_to_double ()
void | gst_util_double_to_fraction ()
gboolean | gst_util_fraction_multiply ()
gboolean | gst_util_fraction_add ()
gint | gst_util_fraction_compare ()
guint32 | gst_util_seqnum_next ()
gint32 | gst_util_seqnum_compare ()
guint | gst_util_group_id_next ()
void | gst_util_set_object_arg ()
void | gst_util_set_value_from_string ()
GstClockTime | gst_util_get_timestamp ()
gpointer | gst_util_array_binary_search ()

## Types and Values

enum | GstSearchMode

## Object Hierarchy

## Includes

    #include <gst/gst.h>

## Description

## Functions

### 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

#### Parameters

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

#### Parameters

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)            (_GST_GET (data, 0,  8,  0))

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

#### Parameters

data | memory location |

### GST_READ_UINT16_LE()

    #  define GST_READ_UINT16_LE(data)      _GST_FAST_READ_SWAP (16, data)

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

#### Parameters

data | memory location |

### GST_READ_UINT16_BE()

    #  define GST_READ_UINT16_BE(data)      _GST_FAST_READ (16, data)

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

#### Parameters

data | memory location |

### GST_READ_UINT24_LE()

    #define GST_READ_UINT24_LE(data) __gst_slow_read24_le((const guint8 *)(data))

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

#### Parameters

data | memory location |

### GST_READ_UINT24_BE()

    #define GST_READ_UINT24_BE(data) __gst_slow_read24_be((const guint8 *)(data))

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

#### Parameters

data | memory location |

### GST_READ_UINT32_LE()

    #  define GST_READ_UINT32_LE(data)      _GST_FAST_READ_SWAP (32, data)

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

#### Parameters

data | memory location |

### GST_READ_UINT32_BE()

    #  define GST_READ_UINT32_BE(data)      _GST_FAST_READ (32, data)

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

#### Parameters

data | memory location |

### GST_READ_UINT64_LE()

    #  define GST_READ_UINT64_LE(data)      _GST_FAST_READ_SWAP (64, data)

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

#### Parameters

data | memory location |

### GST_READ_UINT64_BE()

    #  define GST_READ_UINT64_BE(data)      _GST_FAST_READ (64, data)

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

#### Parameters

data | memory location |

### GST_READ_FLOAT_LE ()

    gfloat
    GST_READ_FLOAT_LE (const guint8 *data);

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

#### Parameters

data | memory location |

#### Returns

The floating point value read from `data`

### GST_READ_FLOAT_BE ()

    gfloat
    GST_READ_FLOAT_BE (const guint8 *data);

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

#### Parameters

data | memory location |

#### Returns

The floating point value read from `data`

### GST_READ_DOUBLE_LE ()

    gdouble
    GST_READ_DOUBLE_LE (const guint8 *data);

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

#### Parameters

data | memory location |

#### Returns

The double-precision floating point value read from `data`

### GST_READ_DOUBLE_BE ()

    gdouble
    GST_READ_DOUBLE_BE (const guint8 *data);

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

#### Parameters

data | memory location |

#### Returns

The double-precision floating point value read from `data`

### GST_WRITE_UINT8()

    #define             GST_WRITE_UINT8(data, num)

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

#### Parameters

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.

#### Parameters

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.

#### Parameters

data | memory location |
num | value to store |

### GST_WRITE_UINT24_LE()

    #define             GST_WRITE_UINT24_LE(data, num)

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

#### Parameters

data | memory location |
num | value to store |

### GST_WRITE_UINT24_BE()

    #define             GST_WRITE_UINT24_BE(data, num)

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

#### Parameters

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.

#### Parameters

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.

#### Parameters

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.

#### Parameters

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.

#### Parameters

data | memory location |
num | value to store |

### GST_WRITE_FLOAT_LE ()

    void
    GST_WRITE_FLOAT_LE (guint8 *data,
                        gfloat num);

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

#### Parameters

data | memory location |
num | value to store |

### GST_WRITE_FLOAT_BE ()

    void
    GST_WRITE_FLOAT_BE (guint8 *data,
                        gfloat num);

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

#### Parameters

data | memory location |
num | value to store |

### GST_WRITE_DOUBLE_LE ()

    void
    GST_WRITE_DOUBLE_LE (guint8 *data,
                         gdouble num);

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

#### Parameters

data | memory location |
num | value to store |

### GST_WRITE_DOUBLE_BE ()

    void
    GST_WRITE_DOUBLE_BE (guint8 *data,
                         gdouble num);

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

#### Parameters

data | memory location |
num | value to store |

### GST_ROUND_UP_2()

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

Rounds an integer value up to the next multiple of 2.

#### Parameters

num | integer value to round up |

### GST_ROUND_UP_4()

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

Rounds an integer value up to the next multiple of 4.

#### Parameters

num | integer value to round up |

### GST_ROUND_UP_8()

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

Rounds an integer value up to the next multiple of 8.

#### Parameters

num | integer value to round up |

### GST_ROUND_UP_16()

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

Rounds an integer value up to the next multiple of 16.

#### Parameters

num | integer value to round up |

### GST_ROUND_UP_32()

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

Rounds an integer value up to the next multiple of 32.

#### Parameters

num | integer value to round up |

### GST_ROUND_UP_64()

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

Rounds an integer value up to the next multiple of 64.

#### Parameters

num | integer value to round up |

### GST_ROUND_UP_128()

    #define GST_ROUND_UP_128(num) (((num)+127)&~127)

Rounds an integer value up to the next multiple of 128.

#### Parameters

num | integer value to round up |

Since 1.4

### GST_ROUND_UP_N()

    #define GST_ROUND_UP_N(num,align) ((((num) + ((align) - 1)) & ~((align) - 1)))

Rounds an integer value up to the next multiple of `align` . `align` MUST be a power of two.

#### Parameters

num | integrer value to round up |
align | a power of two to round up to |

### GST_ROUND_DOWN_2()

    #define GST_ROUND_DOWN_2(num)  ((num)&(~1))

Rounds an integer value down to the next multiple of 2.

#### Parameters

num | integer value to round down |

### GST_ROUND_DOWN_4()

    #define GST_ROUND_DOWN_4(num)  ((num)&(~3))

Rounds an integer value down to the next multiple of 4.

#### Parameters

num | integer value to round down |

### GST_ROUND_DOWN_8()

    #define GST_ROUND_DOWN_8(num)  ((num)&(~7))

Rounds an integer value down to the next multiple of 8.

#### Parameters

num | integer value to round down |

### GST_ROUND_DOWN_16()

    #define GST_ROUND_DOWN_16(num) ((num)&(~15))

Rounds an integer value down to the next multiple of 16.

#### Parameters

num | integer value to round down |

### GST_ROUND_DOWN_32()

    #define GST_ROUND_DOWN_32(num) ((num)&(~31))

Rounds an integer value down to the next multiple of 32.

#### Parameters

num | integer value to round down |

### GST_ROUND_DOWN_64()

    #define GST_ROUND_DOWN_64(num) ((num)&(~63))

Rounds an integer value down to the next multiple of 64.

#### Parameters

num | integer value to round down |

### GST_ROUND_DOWN_128()

    #define GST_ROUND_DOWN_128(num) ((num)&(~127))

Rounds an integer value down to the next multiple of 128.

#### Parameters

num | integer value to round down |

Since 1.4

### GST_ROUND_DOWN_N()

    #define GST_ROUND_DOWN_N(num,align) (((num) & ~((align) - 1)))

Rounds an integer value down to the next multiple of `align` . `align` MUST be a power of two.

#### Parameters

num | integrer value to round down |
align | a power of two to round down to |

### GDOUBLE_FROM_BE()

    #define GDOUBLE_FROM_BE(val) (GDOUBLE_TO_BE (val))

Convert 64-bit floating point value (double) from big endian byte order into native byte order.

#### Parameters

val | value |

### GDOUBLE_FROM_LE()

    #define GDOUBLE_FROM_LE(val) (GDOUBLE_TO_LE (val))

Convert 64-bit floating point value (double) from little endian byte order into native byte order.

#### Parameters

val | value |

### GDOUBLE_SWAP_LE_BE ()

    gdouble
    GDOUBLE_SWAP_LE_BE (gdouble in);

Swap byte order of a 64-bit floating point value (double).

#### Parameters

in | input value |

#### Returns

`in` byte-swapped.

### GDOUBLE_TO_BE()

    #define GDOUBLE_TO_BE(val)   (GDOUBLE_SWAP_LE_BE (val))

Convert 64-bit floating point value (double) from native byte order into big endian byte order.

#### Parameters

val | value |

### GDOUBLE_TO_LE()

    #define GDOUBLE_TO_LE(val)   ((gdouble) (val))

Convert 64-bit floating point value (double) from native byte order into little endian byte order.

#### Parameters

val | value |

### GFLOAT_FROM_BE()

    #define GFLOAT_FROM_BE(val)  (GFLOAT_TO_BE (val))

Convert 32-bit floating point value (float) from big endian byte order into native byte order.

#### Parameters

val | value |

### GFLOAT_FROM_LE()

    #define GFLOAT_FROM_LE(val)  (GFLOAT_TO_LE (val))

Convert 32-bit floating point value (float) from little endian byte order into native byte order.

#### Parameters

val | value |

### GFLOAT_SWAP_LE_BE ()

    gfloat
    GFLOAT_SWAP_LE_BE (gfloat in);

Swap byte order of a 32-bit floating point value (float).

#### Parameters

in | input value |

#### Returns

`in` byte-swapped.

### GFLOAT_TO_BE()

    #define GFLOAT_TO_BE(val)    (GFLOAT_SWAP_LE_BE (val))

Convert 32-bit floating point value (float) from native byte order into big endian byte order.

#### Parameters

val | value |

### GFLOAT_TO_LE()

    #define GFLOAT_TO_LE(val)    ((gfloat) (val))

Convert 32-bit floating point value (float) from native byte order into little endian byte order.

#### Parameters

val | value |

### gst_guint64_to_gdouble()

    #define         gst_guint64_to_gdouble(value)   gst_util_guint64_to_gdouble(value)

Convert `value` to a gdouble.

#### Parameters

value | the guint64 value to convert |

#### Returns

`value` converted to a gdouble.

### gst_gdouble_to_guint64()

    #define         gst_gdouble_to_guint64(value)   gst_util_gdouble_to_guint64(value)

Convert `value` to a guint64.

#### Parameters

value | the gdouble value to convert |

#### Returns

`value` converted to a guint64.

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

#### Parameters

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 the rational number `num` / `denom` , avoiding overflows and underflows and without loss of precision.

This function can potentially be very slow if val and num are both greater than G_MAXUINT32.

#### Parameters

val | the number to scale |
num | the numerator of the scale ratio |
denom | the denominator of the scale ratio |

#### Returns

`val` * `num` / `denom` . In the case of an overflow, this function returns G_MAXUINT64. If the result is not exactly representable as an integer it is truncated. See also `gst_util_uint64_scale_round()`, `gst_util_uint64_scale_ceil()`, `gst_util_uint64_scale_int()`, `gst_util_uint64_scale_int_round()`, `gst_util_uint64_scale_int_ceil()`.

### gst_util_uint64_scale_round ()

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

Scale `val` by the rational number `num` / `denom` , avoiding overflows and underflows and without loss of precision.

This function can potentially be very slow if val and num are both greater than G_MAXUINT32.

#### Parameters

val | the number to scale |
num | the numerator of the scale ratio |
denom | the denominator of the scale ratio |

#### Returns

`val` * `num` / `denom` . In the case of an overflow, this function returns G_MAXUINT64. If the result is not exactly representable as an integer, it is rounded to the nearest integer (half-way cases are rounded up). See also `gst_util_uint64_scale()`, `gst_util_uint64_scale_ceil()`, `gst_util_uint64_scale_int()`, `gst_util_uint64_scale_int_round()`, `gst_util_uint64_scale_int_ceil()`.

### gst_util_uint64_scale_ceil ()

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

Scale `val` by the rational number `num` / `denom` , avoiding overflows and underflows and without loss of precision.

This function can potentially be very slow if val and num are both greater than G_MAXUINT32.

#### Parameters

val | the number to scale |
num | the numerator of the scale ratio |
denom | the denominator of the scale ratio |

#### Returns

`val` * `num` / `denom` . In the case of an overflow, this function returns G_MAXUINT64. If the result is not exactly representable as an integer, it is rounded up. See also `gst_util_uint64_scale()`, `gst_util_uint64_scale_round()`, `gst_util_uint64_scale_int()`, `gst_util_uint64_scale_int_round()`, `gst_util_uint64_scale_int_ceil()`.

### gst_util_uint64_scale_int ()

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

Scale `val` by the rational number `num` / `denom` , avoiding overflows and underflows and without loss of precision. `num` must be non-negative and `denom` must be positive.

#### Parameters

val | guint64 (such as a GstClockTime) to scale. |
num | numerator of the scale factor. |
denom | denominator of the scale factor. |

#### Returns

`val` * `num` / `denom` . In the case of an overflow, this function returns G_MAXUINT64. If the result is not exactly representable as an integer, it is truncated. See also `gst_util_uint64_scale_int_round()`, `gst_util_uint64_scale_int_ceil()`, `gst_util_uint64_scale()`, `gst_util_uint64_scale_round()`, `gst_util_uint64_scale_ceil()`.

### gst_util_uint64_scale_int_round ()

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

Scale `val` by the rational number `num` / `denom` , avoiding overflows and underflows and without loss of precision. `num` must be non-negative and `denom` must be positive.

#### Parameters

val | guint64 (such as a GstClockTime) to scale. |
num | numerator of the scale factor. |
denom | denominator of the scale factor. |

#### Returns

`val` * `num` / `denom` . In the case of an overflow, this function returns G_MAXUINT64. If the result is not exactly representable as an integer, it is rounded to the nearest integer (half-way cases are rounded up). See also `gst_util_uint64_scale_int()`, `gst_util_uint64_scale_int_ceil()`, `gst_util_uint64_scale()`, `gst_util_uint64_scale_round()`, `gst_util_uint64_scale_ceil()`.

### gst_util_uint64_scale_int_ceil ()

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

Scale `val` by the rational number `num` / `denom` , avoiding overflows and underflows and without loss of precision. `num` must be non-negative and `denom` must be positive.

#### Parameters

val | guint64 (such as a GstClockTime) to scale. |
num | numerator of the scale factor. |
denom | denominator of the scale factor. |

#### Returns

`val` * `num` / `denom` . In the case of an overflow, this function returns G_MAXUINT64. If the result is not exactly representable as an integer, it is rounded up. See also `gst_util_uint64_scale_int()`, `gst_util_uint64_scale_int_round()`, `gst_util_uint64_scale()`, `gst_util_uint64_scale_round()`, `gst_util_uint64_scale_ceil()`.

### gst_util_greatest_common_divisor ()

    gint
    gst_util_greatest_common_divisor (gint a,
                                      gint b);

Calculates the greatest common divisor of `a` and `b` .

#### Parameters

a | First value as gint |
b | Second value as gint |

#### Returns

Greatest common divisor of `a` and `b`

### gst_util_greatest_common_divisor_int64 ()

    gint64
    gst_util_greatest_common_divisor_int64
                                   (gint64 a,
                                    gint64 b);

Calculates the greatest common divisor of `a` and `b` .

#### Parameters

a | First value as gint64 |
b | Second value as gint64 |

#### Returns

Greatest common divisor of `a` and `b`

### gst_util_fraction_to_double ()

    void
    gst_util_fraction_to_double (gint src_n,
                                 gint src_d,
                                 gdouble *dest);

Transforms a fraction to a gdouble.

#### Parameters

src_n | Fraction numerator as gint |
src_d | Fraction denominator gint |
dest | pointer to a gdouble for the result. | [out]

### gst_util_double_to_fraction ()

    void
    gst_util_double_to_fraction (gdouble src,
                                 gint *dest_n,
                                 gint *dest_d);

Transforms a gdouble to a fraction and simplifies the result.

#### Parameters

src | gdouble to transform |
dest_n | pointer to a gint to hold the result numerator. | [out]
dest_d | pointer to a gint to hold the result denominator. | [out]

### gst_util_fraction_multiply ()

    gboolean
    gst_util_fraction_multiply (gint a_n,
                                gint a_d,
                                gint b_n,
                                gint b_d,
                                gint *res_n,
                                gint *res_d);

Multiplies the fractions `a_n` /`a_d` and `b_n` /`b_d` and stores the result in `res_n` and `res_d` .

#### Parameters

a_n | Numerator of first value |
a_d | Denominator of first value |
b_n | Numerator of second value |
b_d | Denominator of second value |
res_n | Pointer to gint to hold the result numerator. | [out]
res_d | Pointer to gint to hold the result denominator. | [out]

#### Returns

`FALSE` on overflow, `TRUE` otherwise.

### gst_util_fraction_add ()

    gboolean
    gst_util_fraction_add (gint a_n,
                           gint a_d,
                           gint b_n,
                           gint b_d,
                           gint *res_n,
                           gint *res_d);

Adds the fractions `a_n` /`a_d` and `b_n` /`b_d` and stores the result in `res_n` and `res_d` .

#### Parameters

a_n | Numerator of first value |
a_d | Denominator of first value |
b_n | Numerator of second value |
b_d | Denominator of second value |
res_n | Pointer to gint to hold the result numerator. | [out]
res_d | Pointer to gint to hold the result denominator. | [out]

#### Returns

`FALSE` on overflow, `TRUE` otherwise.

### gst_util_fraction_compare ()

    gint
    gst_util_fraction_compare (gint a_n,
                               gint a_d,
                               gint b_n,
                               gint b_d);

Compares the fractions `a_n` /`a_d` and `b_n` /`b_d` and returns -1 if a < b, 0 if a = b and 1 if a > b.

#### Parameters

a_n | Numerator of first value |
a_d | Denominator of first value |
b_n | Numerator of second value |
b_d | Denominator of second value |

#### Returns

-1 if a < b; 0 if a = b; 1 if a > b.

### gst_util_seqnum_next ()

    guint32
    gst_util_seqnum_next (void);

Return a constantly incrementing sequence number.

This function is used internally to GStreamer to be able to determine which events and messages are "the same". For example, elements may set the seqnum on a segment-done message to be the same as that of the last seek event, to indicate that event and the message correspond to the same segment.

#### Returns

A constantly incrementing 32-bit unsigned integer, which might overflow back to 0 at some point. Use `gst_util_seqnum_compare()` to make sure you handle wraparound correctly.

### gst_util_seqnum_compare ()

    gint32
    gst_util_seqnum_compare (guint32 s1,
                             guint32 s2);

Compare two sequence numbers, handling wraparound.

The current implementation just returns (gint32)(`s1` - `s2` ).

#### Parameters

s1 | A sequence number. |
s2 | Another sequence number. |

#### Returns

A negative number if `s1` is before `s2` , 0 if they are equal, or a positive number if `s1` is after `s2` .

### gst_util_group_id_next ()

    guint
    gst_util_group_id_next (void);

Return a constantly incrementing group id.

This function is used to generate a new group-id for the stream-start event.

#### Returns

A constantly incrementing unsigned integer, which might overflow back to 0 at some point.

### gst_util_set_object_arg ()

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

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

Note that this function silently returns if `object` has no property named `name` or when `value` cannot be converted to the type of the property.

#### Parameters

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.

Note that this function is dangerous as it does not return any indication if the conversion worked or not.

#### Parameters

value | the value to set. | [out caller-allocates]
value_str | the string to get the value from |

### gst_util_get_timestamp ()

    GstClockTime
    gst_util_get_timestamp (void);

Get a timestamp as GstClockTime to be used for interval measurements. The timestamp should not be interpreted in any other way.

#### Returns

the timestamp

### gst_util_array_binary_search ()

    gpointer
    gst_util_array_binary_search (gpointer array,
                                  guint num_elements,
                                  gsize element_size,
                                  GCompareDataFunc search_func,
                                  GstSearchMode mode,
                                  gconstpointer search_data,
                                  gpointer user_data);

Searches inside `array` for `search_data` by using the comparison function `search_func` . `array` must be sorted ascending.

As `search_data` is always passed as second argument to `search_func` it's not required that `search_data` has the same type as the array elements.

The complexity of this search function is O(log (num_elements)).

#### Parameters

array | the sorted input array |
num_elements | number of elements in the array |
element_size | size of every element in bytes |
search_func | function to compare two elements, `search_data` will always be passed as second argument. | [scope call]
mode | search mode that should be used |
search_data | element that should be found |
user_data | data to pass to `search_func` . | [closure]

#### Returns

The address of the found element or `NULL` if nothing was found.

[transfer none][nullable]

## Types and Values

### enum GstSearchMode

The different search modes.

#### Members

GST_SEARCH_MODE_EXACT | Only search for exact matches. |
GST_SEARCH_MODE_BEFORE | Search for an exact match or the element just before. |
GST_SEARCH_MODE_AFTER | Search for an exact match or the element just after. |