Functions
gst_calculate_linear_regression
gboolean gst_calculate_linear_regression (const GstClockTime * xy, GstClockTime * temp, guint n, GstClockTime * m_num, GstClockTime * m_denom, GstClockTime * b, GstClockTime * xbase, gdouble * r_squared)
Calculates the linear regression of the values xy and places the result in m_num, m_denom, b and xbase, representing the function y(x) = m_num/m_denom * (x - xbase) + b that has the least-square distance from all points x and y.
r_squared will contain the remaining error.
If temp is not NULL, it will be used as temporary space for the function, in which case the function works without any allocation at all. If temp is NULL, an allocation will take place. temp should have at least the same amount of memory allocated as xy, i.e. 2nsizeof(GstClockTime).
This function assumes (x,y) values with reasonable large differences between them. It will not calculate the exact results if the differences between neighbouring values are too small due to not being able to represent sub-integer values during the calculations.
Parameters:
xy
–
Pairs of (x,y) values
temp
–
Temporary scratch space used by the function
n
–
number of (x,y) pairs
m_num
(
[out])
–
numerator of calculated slope
m_denom
(
[out])
–
denominator of calculated slope
b
(
[out])
–
Offset at Y-axis
xbase
(
[out])
–
Offset at X-axis
r_squared
(
[out])
–
R-squared
TRUE if the linear regression was successfully calculated
Since : 1.12
gst_parse_bin_from_description
GstElement * gst_parse_bin_from_description (const gchar * bin_description, gboolean ghost_unlinked_pads, GError ** error)
This is a convenience wrapper around gst_parse_launch to create a GstBin from a gst-launch-style pipeline description. See gst_parse_launch and the gst-launch man page for details about the syntax. Ghost pads on the bin for unlinked source or sink pads within the bin can automatically be created (but only a maximum of one ghost pad for each direction will be created; if you expect multiple unlinked source pads or multiple unlinked sink pads and want them all ghosted, you will have to create the ghost pads yourself).
Parameters:
bin_description
–
command line describing the bin
ghost_unlinked_pads
–
whether to automatically create ghost pads for unlinked source or sink pads within the bin
error
–
a newly-created bin, or NULL if an error occurred.
gst_parse_bin_from_description_full
GstElement * gst_parse_bin_from_description_full (const gchar * bin_description, gboolean ghost_unlinked_pads, GstParseContext * context, GstParseFlags flags, GError ** error)
This is a convenience wrapper around gst_parse_launch to create a GstBin from a gst-launch-style pipeline description. See gst_parse_launch and the gst-launch man page for details about the syntax. Ghost pads on the bin for unlinked source or sink pads within the bin can automatically be created (but only a maximum of one ghost pad for each direction will be created; if you expect multiple unlinked source pads or multiple unlinked sink pads and want them all ghosted, you will have to create the ghost pads yourself).
Parameters:
bin_description
–
command line describing the bin
ghost_unlinked_pads
–
whether to automatically create ghost pads for unlinked source or sink pads within the bin
context
(
[transfer: none][nullable])
–
a parse context allocated with gst_parse_context_new, or NULL
flags
–
parsing options, or GST_PARSE_FLAG_NONE
error
–
a newly-created element, which is guaranteed to be a bin unless GST_PARSE_FLAG_NO_SINGLE_ELEMENT_BINS was passed, or NULL if an error occurred.
gst_state_change_get_name
const gchar * gst_state_change_get_name (GstStateChange transition)
Gets a string representing the given state transition.
Parameters:
transition
–
a GstStateChange to get the name of.
a string with the name of the state result.
Since : 1.14
gst_type_is_plugin_api
gboolean gst_type_is_plugin_api (GType type, GstPluginAPIFlags * flags)
Checks if type is plugin API. See gst_type_mark_as_plugin_api for details.
Parameters:
type
–
a GType
flags
(
[out][optional])
–
What GstPluginAPIFlags the plugin was marked with
Since : 1.18
gst_type_mark_as_plugin_api
gst_type_mark_as_plugin_api (GType type, GstPluginAPIFlags flags)
Marks type as plugin API. This should be called in class_init
of
elements that expose new types (i.e. enums, flags or internal GObjects) via
properties, signals or pad templates.
Types exposed by plugins are not automatically added to the documentation as they might originate from another library and should in that case be documented via that library instead.
By marking a type as plugin API it will be included in the documentation of the plugin that defines it.
Since : 1.18
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
(
[scope call][closure])
–
function to compare two elements, search_data will always be passed as second argument
mode
–
search mode that should be used
search_data
–
element that should be found
user_data
–
data to pass to search_func
The address of the found element or NULL if nothing was found
gst_util_double_to_fraction
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
(
[out])
–
pointer to a gint to hold the result numerator
dest_d
(
[out])
–
pointer to a gint to hold the result denominator
gst_util_filename_compare
gint gst_util_filename_compare (const gchar * a, const gchar * b)
Compares the given filenames using natural ordering.
Parameters:
a
(
[typefilename])
–
a filename to compare with b
b
(
[typefilename])
–
a filename to compare with a
Since : 1.24
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
(
[out])
–
Pointer to gint to hold the result numerator
res_d
(
[out])
–
Pointer to gint to hold the result denominator
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
-1 if a < b; 0 if a = b; 1 if a > b.
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
(
[out])
–
Pointer to gint to hold the result numerator
res_d
(
[out])
–
Pointer to gint to hold the result denominator
gst_util_fraction_multiply_int64
gboolean gst_util_fraction_multiply_int64 (gint64 a_n, gint64 a_d, gint64 b_n, gint64 b_d, gint64 * res_n, gint64 * 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
(
[out])
–
Pointer to gint to hold the result numerator
res_d
(
[out])
–
Pointer to gint to hold the result denominator
Since : 1.26
gst_util_get_object_array
gboolean gst_util_get_object_array (GObject * object, const gchar * name, GValueArray ** array)
Get a property of type GST_TYPE_ARRAY and transform it into a GValueArray. This allow language bindings to get GST_TYPE_ARRAY properties which are otherwise not an accessible type.
Parameters:
object
–
the object to set the array to
name
–
the name of the property to set
array
(
[out])
–
a return GValueArray
Since : 1.12
gst_util_get_timestamp
GstClockTime gst_util_get_timestamp ()
Get a timestamp as GstClockTime to be used for interval measurements. The timestamp should not be interpreted in any other way.
the timestamp
gst_util_group_id_next
guint gst_util_group_id_next ()
Return a constantly incrementing group id.
This function is used to generate a new group-id for the stream-start event.
This function never returns GST_GROUP_ID_INVALID (which is 0)
A constantly incrementing unsigned integer, which might overflow back to 0 at some point.
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.
A negative number if s1 is before s2, 0 if they are equal, or a positive number if s1 is after s2.
gst_util_seqnum_next
guint32 gst_util_seqnum_next ()
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.
This function never returns GST_SEQNUM_INVALID (which is 0).
A constantly incrementing 32-bit unsigned integer, which might overflow at some point. Use gst_util_seqnum_compare to make sure you handle wraparound correctly.
gst_util_set_object_arg
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_object_array
gboolean gst_util_set_object_array (GObject * object, const gchar * name, const GValueArray * array)
Transfer a GValueArray to GST_TYPE_ARRAY and set this value on the specified property name. This allow language bindings to set GST_TYPE_ARRAY properties which are otherwise not an accessible type.
Parameters:
object
–
the object to set the array to
name
–
the name of the property to set
array
–
a GValueArray containing the values
Since : 1.12
gst_util_set_value_from_string
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
(
[out])
–
the value to set
value_str
–
the string to get the value from
gst_util_simplify_fraction
gst_util_simplify_fraction (gint * numerator, gint * denominator, guint n_terms, guint threshold)
Calculates the simpler representation of numerator and denominator and update both values with the resulting simplified fraction.
Simplify a fraction using a simple continued fraction decomposition. The idea here is to convert fractions such as 333333/10000000 to 1/30 using 32 bit arithmetic only. The algorithm is not perfect and relies upon two arbitrary parameters to remove non-significative terms from the simple continued fraction decomposition. Using 8 and 333 for n_terms and threshold respectively seems to give nice results.
Parameters:
numerator
–
First value as gint
denominator
–
Second value as gint
n_terms
–
non-significative terms (typical value: 8)
threshold
–
threshold (typical value: 333)
Since : 1.24
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
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_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
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.
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_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.
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_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.
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_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
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.
Function Macros
GST_CALL_PARENT
#define GST_CALL_PARENT(parent_class_cast, name, args) \ ((parent_class_cast(parent_class)->name != NULL) ? \ parent_class_cast(parent_class)->name args : (void) 0)
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)\ ((parent_class_cast(parent_class)->name != NULL) ? \ parent_class_cast(parent_class)->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_WRITE_UINT24_BE
#define GST_WRITE_UINT24_BE(data, num) do { \ gpointer __put_data = data; \ guint32 __put_val = num; \ _GST_PUT (__put_data, 0, 32, 16, __put_val); \ _GST_PUT (__put_data, 1, 32, 8, __put_val); \ _GST_PUT (__put_data, 2, 32, 0, __put_val); \ } while (0)
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_UINT24_LE
#define GST_WRITE_UINT24_LE(data, num) do { \ gpointer __put_data = data; \ guint32 __put_val = num; \ _GST_PUT (__put_data, 0, 32, 0, __put_val); \ _GST_PUT (__put_data, 1, 32, 8, __put_val); \ _GST_PUT (__put_data, 2, 32, 16, __put_val); \ } while (0)
Store a 24 bit unsigned integer value in little endian format into the memory buffer.
Parameters:
data
–
memory location
num
–
value to store
Enumerations
Constants
GST_GROUP_ID_INVALID
#define GST_GROUP_ID_INVALID (0)
A value which is guaranteed to never be returned by gst_util_group_id_next.
Can be used as a default value in variables used to store group_id.
Since : 1.14
GST_SEQNUM_INVALID
#define GST_SEQNUM_INVALID (0)
A value which is guaranteed to never be returned by gst_util_seqnum_next.
Can be used as a default value in variables used to store seqnum.
Since : 1.14
The results of the search are