Functions#
- caps_features_from_string(features: str) CapsFeatures | None#
- Parameters:
features
- debug_add_log_function(func: Callable[[DebugCategory, DebugLevel, str, str, int, Object, DebugMessage, Any], None], user_data: Any = None) None#
Adds the logging function to the list of logging functions. Be sure to use
G_GNUC_NO_INSTRUMENTon that function, it is needed.- Parameters:
func – the function to use
user_data – user data
- debug_add_ring_buffer_logger(max_size_per_thread: int, thread_timeout: int) None#
Adds a memory ringbuffer based debug logger that stores up to
max_size_per_threadbytes of logs per thread and times out threads afterthread_timeoutseconds of inactivity.Logs can be fetched with
debug_ring_buffer_logger_get_logs()and the logger can be removed again withdebug_remove_ring_buffer_logger(). Only one logger at a time is possible.Added in version 1.14.
- Parameters:
max_size_per_thread – Maximum size of log per thread in bytes
thread_timeout – Timeout for threads in seconds
- debug_bin_to_dot_data(bin: Bin, details: DebugGraphDetails) str#
To aid debugging applications one can use this method to obtain the whole network of gstreamer elements that form the pipeline into a dot file. This data can be processed with graphviz to get an image.
- Parameters:
bin – the top-level pipeline that should be analyzed
details – type of
DebugGraphDetailsto use
- Returns:
a string containing the pipeline in graphviz dot format.
- debug_bin_to_dot_file(bin: Bin, details: DebugGraphDetails, file_name: str) None#
To aid debugging applications one can use this method to write out the whole network of gstreamer elements that form the pipeline into a dot file. This file can be processed with graphviz to get an image.
dot -Tpng -oimage.png graph_lowlevel.dot
- Parameters:
bin – the top-level pipeline that should be analyzed
details – type of
DebugGraphDetailsto usefile_name – output base filename (e.g. “myplayer”)
- debug_bin_to_dot_file_with_ts(bin: Bin, details: DebugGraphDetails, file_name: str) None#
This works like
debug_bin_to_dot_file(), but adds the current timestamp to the filename, so that it can be used to take multiple snapshots.- Parameters:
bin – the top-level pipeline that should be analyzed
details – type of
DebugGraphDetailsto usefile_name – output base filename (e.g. “myplayer”)
- debug_construct_term_color(colorinfo: int) str#
Constructs a string that can be used for getting the desired color in color terminals. You need to free the string after use.
- Parameters:
colorinfo – the color info
- Returns:
a string containing the color definition
- debug_construct_win_color(colorinfo: int) int#
Constructs an integer that can be used for getting the desired color in windows’ terminals (cmd.exe). As there is no mean to underline, we simply ignore this attribute.
This function returns 0 on non-windows machines.
- Parameters:
colorinfo – the color info
- Returns:
an integer containing the color definition
- debug_get_all_categories() list[DebugCategory]#
Returns a snapshot of a all categories that are currently in use . This list may change anytime. The caller has to free the list after use.
- Returns:
the list of debug categories
- debug_get_color_mode() DebugColorMode#
Changes the coloring mode for debug output.
Added in version 1.2.
- Returns:
see
GstDebugColorModefor possible values.
- debug_get_default_threshold() DebugLevel#
Returns the default threshold that is used for new categories.
- Returns:
the default threshold level
- debug_get_stack_trace(flags: StackTraceFlags) str | None#
Added in version 1.12.
- Parameters:
flags – A set of
StackTraceFlagsto determine how the stack trace should look like. PassGST_STACK_TRACE_SHOW_NONEto retrieve a minimal backtrace.- Returns:
a stack trace, if libunwind or glibc backtrace are present, else
None.
- debug_is_active() bool#
Checks if debugging output is activated.
- Returns:
True, if debugging is activated
- debug_is_colored() bool#
Checks if the debugging output should be colored.
- Returns:
True, if the debug output should be colored.
- debug_level_get_name(level: DebugLevel) str#
- Parameters:
level
- debug_log_default(category: DebugCategory, level: DebugLevel, file: str, function: str, line: int, object: Object | None, message: DebugMessage, user_data: Any = None) None#
The default logging handler used by GStreamer. Logging functions get called whenever a macro like GST_DEBUG or similar is used. By default this function is setup to output the message and additional info to stderr (or the log file specified via the GST_DEBUG_FILE environment variable) as received via
user_data.You can add other handlers by using
debug_add_log_function(). And you can remove this handler by calling gst_debug_remove_log_function(gst_debug_log_default);- Parameters:
category – category to log
level – level of the message
file – the file that emitted the message, usually the
__FILE__identifierfunction – the function that emitted the message
line – the line from that the message was emitted, usually
__LINE__object – the object this message relates to, or
Noneif nonemessage – the actual message
user_data – the FILE* to log to
- debug_log_get_line(category: DebugCategory, level: DebugLevel, file: str, function: str, line: int, object: Object | None, message: DebugMessage) str#
Returns the string representation for the specified debug log message formatted in the same way as
debug_log_default()(the default handler), without color. The purpose is to make it easy for custom log output handlers to get a log output that is identical to what the default handler would write out.Added in version 1.18.
- Parameters:
category – category to log
level – level of the message
file – the file that emitted the message, usually the
__FILE__identifierfunction – the function that emitted the message
line – the line from that the message was emitted, usually
__LINE__object – the object this message relates to, or
Noneif nonemessage – the actual message
- debug_log_id_literal(category: DebugCategory, level: DebugLevel, file: str, function: str, line: int, id: str | None, message_string: str) None#
Logs the given message using the currently registered debugging handlers.
Added in version 1.22.
- Parameters:
category – category to log
level – level of the message is in
file – the file that emitted the message, usually the
__FILE__identifierfunction – the function that emitted the message
line – the line from that the message was emitted, usually
__LINE__id – the identifier of the object this message relates to or
Noneif nonemessage_string – a message string
- debug_log_literal(category: DebugCategory, level: DebugLevel, file: str, function: str, line: int, object: Object | None, message_string: str) None#
Logs the given message using the currently registered debugging handlers.
Added in version 1.20.
- Parameters:
category – category to log
level – level of the message is in
file – the file that emitted the message, usually the
__FILE__identifierfunction – the function that emitted the message
line – the line from that the message was emitted, usually
__LINE__object – the object this message relates to, or
Noneif nonemessage_string – a message string
- debug_print_stack_trace() None#
If libunwind, glibc backtrace or DbgHelp are present a stack trace is printed.
- debug_remove_log_function(func: Callable[[DebugCategory, DebugLevel, str, str, int, Object, DebugMessage, Any], None] | None = None) int#
Removes all registered instances of the given logging functions.
- Parameters:
func – the log function to remove, or
Noneto remove the default log function- Returns:
How many instances of the function were removed
- debug_remove_log_function_by_data(data: Any = None) int#
Removes all registered instances of log functions with the given user data.
- Parameters:
data – user data of the log function to remove
- Returns:
How many instances of the function were removed
- debug_remove_ring_buffer_logger() None#
Removes any previously added ring buffer logger with
debug_add_ring_buffer_logger().Added in version 1.14.
- debug_ring_buffer_logger_get_logs() list[str]#
Fetches the current logs per thread from the ring buffer logger. See
debug_add_ring_buffer_logger()for details.Added in version 1.14.
- Returns:
NULL-terminated array of strings with the debug output per thread
- debug_set_active(active: bool) None#
If activated, debugging messages are sent to the debugging handlers. It makes sense to deactivate it for speed issues.
This function is not threadsafe. It makes sense to only call it during initialization.
- Parameters:
active – Whether to use debugging output or not
- debug_set_color_mode(mode: DebugColorMode) None#
Changes the coloring mode for debug output.
This function may be called before
init().Added in version 1.2.
- Parameters:
mode – The coloring mode for debug output. See
GstDebugColorMode.
- debug_set_color_mode_from_string(mode: str) None#
Changes the coloring mode for debug output.
This function may be called before
init().Added in version 1.2.
- Parameters:
mode – The coloring mode for debug output. One of the following: “on”, “auto”, “off”, “disable”, “unix”.
- debug_set_colored(colored: bool) None#
Sets or unsets the use of coloured debugging output. Same as gst_debug_set_color_mode () with the argument being being GST_DEBUG_COLOR_MODE_ON or GST_DEBUG_COLOR_MODE_OFF.
This function may be called before
init().- Parameters:
colored – Whether to use colored output or not
- debug_set_default_threshold(level: DebugLevel) None#
Sets the default threshold to the given level and updates all categories to use this threshold.
This function may be called before
init().- Parameters:
level – level to set
- debug_set_threshold_for_name(name: str, level: DebugLevel) None#
Sets all categories which match the given glob style pattern to the given level.
- Parameters:
name – name of the categories to set
level – level to set them to
- debug_set_threshold_from_string(list: str, reset: bool) None#
Sets the debug logging wanted in the same form as with the GST_DEBUG environment variable. You can use wildcards such as
*, but note that the order matters when you use wild cards, e.g.foosrc:6,*src:3,*:2sets everything to log level 2.Added in version 1.2.
- Parameters:
list – comma-separated list of “category:level” pairs to be used as debug logging levels
reset –
Trueto clear all previously-set debug levels before settingnew thresholds
Falseif adding the threshold described bylistto the one already set.
- debug_unset_threshold_for_name(name: str) None#
Resets all categories with the given name back to the default level.
- Parameters:
name – name of the categories to set
- deinit() None#
Clean up any resources created by GStreamer in
init().It is normally not needed to call this function in a normal application as the resources will automatically be freed when the program terminates. This function is therefore mostly used by testsuites and other memory profiling tools.
After this call GStreamer (including this method) should not be used anymore.
- dynamic_type_register(plugin: Plugin, type: GType) bool#
Registers a new
GstDynamicTypeFactoryin the registryAdded in version 1.12.
- Parameters:
plugin – The
Pluginto registerdyn_typefortype – The
Typeto register dynamically
- error_get_message(domain: int, code: int) str#
Get a string describing the error message in the current locale.
- Parameters:
domain – the GStreamer error domain this error belongs to.
code – the error code belonging to the domain.
- Returns:
a newly allocated string describing the error message (in UTF-8 encoding)
- event_type_get_flags(type: EventType) EventTypeFlags#
- Parameters:
type
- filename_to_uri(filename: str) str | None#
Similar to
filename_to_uri(), but attempts to handle relative file paths as well. Before convertingfilenameinto an URI, it will be prefixed by the current working directory if it is a relative path, and then the path will be canonicalised so that it doesn’t contain any ‘./’ or ‘../’ segments.On Windows
filenameshould be in UTF-8 encoding.- Parameters:
filename – absolute or relative file name path
- Returns:
newly-allocated URI string, or NULL on error. The caller must free the URI string with
free()when no longer needed.
- flow_get_name(ret: FlowReturn) str#
Gets a string representing the given flow return.
- Parameters:
ret – a
FlowReturnto get the name of.- Returns:
a static string with the name of the flow return.
- flow_to_quark(ret: FlowReturn) int#
Get the unique quark for the given GstFlowReturn.
- Parameters:
ret – a
FlowReturnto get the quark of.- Returns:
the quark associated with the flow return or 0 if an invalid return was specified.
- format_get_details(format: Format) FormatDefinition | None#
- Parameters:
format
- formats_contains(formats: list[Format], format: Format) bool#
See if the given format is inside the format array.
- Parameters:
formats – The format array to search
format – the format to find
- Returns:
Trueif the format is found inside the array
- get_main_executable_path() str | None#
This helper is mostly helpful for plugins that need to inspect the folder of the main executable to determine their set of features.
When a plugin is initialized from the gst-plugin-scanner external process, the returned path will be the same as from the parent process.
Added in version 1.14.
- Returns:
The path of the executable that initialized GStreamer, or
Noneif it could not be determined.
- init(argv: list[str] | None = None) list[str] | None#
Initializes the GStreamer library, setting up internal path lists, registering built-in elements, and loading standard plugins.
Unless the plugin registry is disabled at compile time, the registry will be loaded. By default this will also check if the registry cache needs to be updated and rescan all plugins if needed. See
update_registry()for details and section <link linkend=”gst-running”>Running GStreamer Applications</link> for how to disable automatic registry updates.WARNING: This function will terminate your program if it was unable to initialize GStreamer for some reason. If you want your program to fall back, use
init_check()instead.- Parameters:
argv – pointer to application’s argv
- init_check(argv: list[str] | None = None) tuple[bool, list[str] | None]#
Initializes the GStreamer library, setting up internal path lists, registering built-in elements, and loading standard plugins.
This function will return
Falseif GStreamer could not be initialized for some reason. If you want your program to fail fatally, useinit()instead.- Parameters:
argv – pointer to application’s argv
- Returns:
Trueif GStreamer could be initialized.
- is_caps_features(obj: Any = None) bool#
Checks if
objis aCapsFeatures- Parameters:
obj
- Returns:
Trueifobjis aCapsFeaturesFalseotherwise
- is_initialized() bool#
Use this function to check if GStreamer has been initialized with
init()orinit_check().- Returns:
Trueif initialization has been done,Falseotherwise.
- message_type_get_name(type: MessageType) str#
- Parameters:
type
- message_type_to_quark(type: MessageType) int#
- Parameters:
type
- meta_deserialize(buffer: Buffer, data: int, size: int) tuple[Meta | None, int]#
- Parameters:
buffer
data
size
- meta_register_custom(name: str, tags: list[str], transform_func: Callable[[Buffer, CustomMeta, Buffer, int, Any, Any], bool] | None = None, user_data: Any = None) MetaInfo#
- Parameters:
name
tags
transform_func
user_data
- mini_object_replace(olddata: MiniObject | None = None, newdata: MiniObject | None = None) tuple[bool, MiniObject | None]#
- Parameters:
olddata
newdata
- mini_object_take(olddata: MiniObject, newdata: MiniObject) tuple[bool, MiniObject]#
- Parameters:
olddata
newdata
- param_spec_array(name: str, nick: str, blurb: str, element_spec: ParamSpec, flags: ParamFlags) ParamSpec#
This function creates a GstArray GParamSpec for use by objects/elements that want to expose properties of GstArray type. This function is typically * used in connection with
install_property()in a GObjects’s instance_init function.Added in version 1.14.
- Parameters:
name – canonical name of the property specified
nick – nick name for the property specified
blurb – description of the property specified
element_spec – GParamSpec of the array
flags – flags for the property specified
- Returns:
a newly created parameter specification
- param_spec_fraction(name: str, nick: str, blurb: str, min_num: int, min_denom: int, max_num: int, max_denom: int, default_num: int, default_denom: int, flags: ParamFlags) ParamSpec | None#
This function creates a fraction GParamSpec for use by objects/elements that want to expose properties of fraction type. This function is typically used in connection with
install_property()in a GObjects’s instance_init function.- Parameters:
name – canonical name of the property specified
nick – nick name for the property specified
blurb – description of the property specified
min_num – minimum value (fraction numerator)
min_denom – minimum value (fraction denominator)
max_num – maximum value (fraction numerator)
max_denom – maximum value (fraction denominator)
default_num – default value (fraction numerator)
default_denom – default value (fraction denominator)
flags – flags for the property specified
- Returns:
a newly created parameter specification
- parent_buffer_meta_api_get_type() GType#
- parse_bin_from_description(bin_description: str, ghost_unlinked_pads: bool) Bin#
This is a convenience wrapper around
parse_launch()to create aBinfrom a gst-launch-style pipeline description. Seeparse_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
- Returns:
a newly-created bin, or
Noneif an error occurred.
- parse_bin_from_description_full(bin_description: str, ghost_unlinked_pads: bool, context: ParseContext | None, flags: ParseFlags) Element#
This is a convenience wrapper around
parse_launch()to create aBinfrom a gst-launch-style pipeline description. Seeparse_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 – a parse context allocated with
new(), orNoneflags – parsing options, or
GST_PARSE_FLAG_NONE
- Returns:
a newly-created element, which is guaranteed to be a bin unless
GST_PARSE_FLAG_NO_SINGLE_ELEMENT_BINSwas passed, orNoneif an error occurred.
- parse_launch(pipeline_description: str) Element#
Create a new pipeline based on command line syntax. Please note that you might get a return value that is not
Noneeven though theerroris set. In this case there was a recoverable parsing error and you can try to play the pipeline.To create a sub-pipeline (bin) for embedding into an existing pipeline use
parse_bin_from_description().- Parameters:
pipeline_description – the command line describing the pipeline
- Returns:
a new element on success,
Noneon failure. If more than one toplevel element is specified by thepipeline_description, all elements are put into aPipeline, which than is returned.
- parse_launch_full(pipeline_description: str, context: ParseContext | None, flags: ParseFlags) Element#
Create a new pipeline based on command line syntax. Please note that you might get a return value that is not
Noneeven though theerroris set. In this case there was a recoverable parsing error and you can try to play the pipeline.To create a sub-pipeline (bin) for embedding into an existing pipeline use
parse_bin_from_description_full().- Parameters:
pipeline_description – the command line describing the pipeline
context – a parse context allocated with
new(), orNoneflags – parsing options, or
GST_PARSE_FLAG_NONE
- Returns:
a new element on success,
Noneon failure. If more than one toplevel element is specified by thepipeline_description, all elements are put into aPipeline, which then is returned (unless the GST_PARSE_FLAG_PLACE_IN_BIN flag is set, in which case they are put in aBininstead).
- parse_launchv(argv: list[str]) Element#
Create a new element based on command line syntax.
errorwill contain an error message if an erroneous pipeline is specified. An error does not mean that the pipeline could not be constructed.- Parameters:
argv – null-terminated array of arguments
- Returns:
a new element on success and
Noneon failure.
- parse_launchv_full(argv: list[str], context: ParseContext | None, flags: ParseFlags) Element#
Create a new element based on command line syntax.
errorwill contain an error message if an erroneous pipeline is specified. An error does not mean that the pipeline could not be constructed.- Parameters:
argv – null-terminated array of arguments
context – a parse context allocated with
new(), orNoneflags – parsing options, or
GST_PARSE_FLAG_NONE
- Returns:
a new element on success; on failure, either
Noneor a partially-constructed bin or element will be returned anderrorwill be set (unless you passedGST_PARSE_FLAG_FATAL_ERRORSinflags, thenNonewill always be returned on failure)
- protection_filter_systems_by_available_decryptors(system_identifiers: list[str]) list[str] | None#
Iterates the supplied list of UUIDs and checks the GstRegistry for all the decryptors supporting one of the supplied UUIDs.
Added in version 1.14.
- Parameters:
system_identifiers – A null terminated array of strings that contains the UUID values of each protection system that is to be checked.
- Returns:
A null terminated array containing all the
system_identifierssupported by the set of available decryptors, orNoneif no matches were found.
- protection_meta_api_get_type() GType#
- protection_select_system(system_identifiers: list[str]) str | None#
Iterates the supplied list of UUIDs and checks the GstRegistry for an element that supports one of the supplied UUIDs. If more than one element matches, the system ID of the highest ranked element is selected.
Added in version 1.6.
- Parameters:
system_identifiers – A null terminated array of strings that contains the UUID values of each protection system that is to be checked.
- Returns:
One of the strings from
system_identifiersthat indicates the highest ranked element that implements the protection system indicated by that system ID, orNoneif no element has been found.
- query_type_get_flags(type: QueryType) QueryTypeFlags#
- Parameters:
type
- reference_timestamp_meta_api_get_type() GType#
- segtrap_is_enabled() bool#
Some functions in the GStreamer core might install a custom SIGSEGV handler to better catch and report errors to the application. Currently this feature is enabled by default when loading plugins.
Applications might want to disable this behaviour with the
segtrap_set_enabled()function. This is typically done if the application wants to install its own handler without GStreamer interfering.- Returns:
Trueif GStreamer is allowed to install a custom SIGSEGV handler.
- segtrap_set_enabled(enabled: bool) None#
Applications might want to disable/enable the SIGSEGV handling of the GStreamer core. See
segtrap_is_enabled()for more information.- Parameters:
enabled – whether a custom SIGSEGV handler should be installed.
- state_change_get_name(transition: StateChange) str#
- Parameters:
transition
- stream_type_get_name(stype: StreamType) str#
- Parameters:
stype
- structure_take(oldstr_ptr: Structure | None = None, newstr: Structure | None = None) tuple[bool, Structure | None]#
- Parameters:
oldstr_ptr
newstr
- tag_exists(tag: str) bool#
Checks if the given type is already registered.
- Parameters:
tag – name of the tag
- Returns:
Trueif the type is already registered
- tag_get_description(tag: str) str#
Returns the human-readable description of this tag, You must not change or free this string.
- Parameters:
tag – the tag
- Returns:
the human-readable description of this tag
- tag_get_flag(tag: str) TagFlag#
Gets the flag of
tag.- Parameters:
tag – the tag
- Returns:
the flag of this tag.
- tag_get_nick(tag: str) str#
Returns the human-readable name of this tag, You must not change or free this string.
- Parameters:
tag – the tag
- Returns:
the human-readable name of this tag
- tag_get_type(tag: str) GType#
Gets the
Typeused for this tag.- Parameters:
tag – the tag
- Returns:
the
Typeof this tag
- tag_is_fixed(tag: str) bool#
Checks if the given tag is fixed. A fixed tag can only contain one value. Unfixed tags can contain lists of values.
- Parameters:
tag – tag to check
- Returns:
True, if the given tag is fixed.
- tag_merge_strings_with_comma(src: Value) Value#
This is a convenience function for the func argument of
tag_register(). It concatenates all given strings using a comma. The tag must be registered as a G_TYPE_STRING or this function will fail.- Parameters:
src – GValue to copy from
- tag_merge_use_first(src: Value) Value#
This is a convenience function for the func argument of
tag_register(). It creates a copy of the first value from the list.- Parameters:
src – GValue to copy from
- toc_entry_type_get_nick(type: TocEntryType) str#
- Parameters:
type
- tracing_get_active_tracers() list[Tracer]#
Get a list of all active tracer objects owned by the tracing framework for the entirety of the run-time of the process or till
deinit()is called.Added in version 1.18.
- Returns:
A
GListofTracerobjects
- tracing_register_hook(tracer: Tracer, detail: str, func: Callable[[], None]) None#
Register
functo be called when the trace hookdetailis getting invoked. UseNonefordetailto register to all hooks.Added in version 1.8.
- Parameters:
tracer – the tracer
detail – the detailed hook
func – the callback
- type_find_register(plugin: Plugin | None, name: str, rank: int, func: Callable[[TypeFind, Any], None], extensions: str | None = None, possible_caps: Caps | None = None, data: Any = None) bool#
- Parameters:
plugin
name
rank
func
extensions
possible_caps
data
- type_is_plugin_api(type: GType) tuple[bool, PluginAPIFlags]#
Checks if
typeis plugin API. Seetype_mark_as_plugin_api()for details.Added in version 1.18.
- Parameters:
type – a GType
- Returns:
Trueiftypeis plugin API orFalseotherwise.
- type_mark_as_plugin_api(type: GType, flags: PluginAPIFlags) None#
Marks
typeas plugin API. This should be called inclass_initof 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.
Added in version 1.18.
- Parameters:
type – a GType
flags – a set of
PluginAPIFlagsto further inform cache generation.
- update_registry() bool#
Forces GStreamer to re-scan its plugin paths and update the default plugin registry.
Applications will almost never need to call this function, it is only useful if the application knows new plugins have been installed (or old ones removed) since the start of the application (or, to be precise, the first call to
init()) and the application wants to make use of any newly-installed plugins without restarting the application.Applications should assume that the registry update is neither atomic nor thread-safe and should therefore not have any dynamic pipelines running (including the playbin and decodebin elements) and should also not create any elements or access the GStreamer registry while the update is in progress.
Note that this function may block for a significant amount of time.
- Returns:
Trueif the registry has been updated successfully (does not imply that there were changes), otherwiseFalse.
- util_array_binary_search(array: Any, num_elements: int, element_size: int, search_func: Callable[[Any, Any, Any], int], mode: SearchMode, search_data: Any = None, user_data: Any = None) Any | None#
Searches inside
arrayforsearch_databy using the comparison functionsearch_func.arraymust be sorted ascending.As
search_datais always passed as second argument tosearch_funcit’s not required thatsearch_datahas 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_datawill always be passed as second argumentmode – search mode that should be used
search_data – element that should be found
user_data – data to pass to
search_func
- Returns:
The address of the found element or
Noneif nothing was found
- util_ceil_log2(v: int) int#
Returns smallest integral value not less than log2(v).
Added in version 1.24.
- util_double_to_fraction(src: float) tuple[int, int]#
Transforms a
floatto a fraction and simplifies the result.- Parameters:
src –
floatto transform
- util_dump_buffer(buf: Buffer) None#
Dumps the buffer memory into a hex representation. Useful for debugging.
Added in version 1.14.
- Parameters:
buf – a
Bufferwhose memory to dump
- util_dump_mem(mem: list[int]) None#
Dumps the memory block into a hex representation. Useful for debugging.
- Parameters:
mem – a pointer to the memory to dump
- util_filename_compare(a: str, b: str) int#
Compares the given filenames using natural ordering.
Added in version 1.24.
- Parameters:
a – a filename to compare with
bb – a filename to compare with
a
- util_fraction_add(a_n: int, a_d: int, b_n: int, b_d: int) tuple[bool, int, int]#
Adds the fractions
a_n/a_dandb_n/b_dand stores the result inres_nandres_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
- Returns:
Falseon overflow,Trueotherwise.
- util_fraction_compare(a_n: int, a_d: int, b_n: int, b_d: int) int#
Compares the fractions
a_n/a_dandb_n/b_dand 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.
- util_fraction_multiply(a_n: int, a_d: int, b_n: int, b_d: int) tuple[bool, int, int]#
Multiplies the fractions
a_n/a_dandb_n/b_dand stores the result inres_nandres_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
- Returns:
Falseon overflow,Trueotherwise.
- util_get_object_array(object: Object, name: str) tuple[bool, ValueArray]#
Get a property of type %GST_TYPE_ARRAY and transform it into a
ValueArray. This allow language bindings to get GST_TYPE_ARRAY properties which are otherwise not an accessible type.Added in version 1.12.
- Parameters:
object – the object to set the array to
name – the name of the property to set
- util_get_timestamp() int#
Get a timestamp as GstClockTime to be used for interval measurements. The timestamp should not be interpreted in any other way.
- Returns:
the timestamp
- util_greatest_common_divisor(a: int, b: int) int#
Calculates the greatest common divisor of
aandb.
- util_greatest_common_divisor_int64(a: int, b: int) int#
Calculates the greatest common divisor of
aandb.
- util_group_id_next() int#
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
GROUP_ID_INVALID(which is 0)- Returns:
A constantly incrementing unsigned integer, which might overflow back to 0 at some point.
- util_seqnum_compare(s1: int, s2: int) int#
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
s1is befores2, 0 if they are equal, or a positive number ifs1is afters2.
- util_seqnum_next() int#
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
SEQNUM_INVALID(which is 0).- Returns:
A constantly incrementing 32-bit unsigned integer, which might overflow at some point. Use
util_seqnum_compare()to make sure you handle wraparound correctly.
- util_set_object_arg(object: Object, name: str, value: str) None#
Converts the string value to the type of the objects argument and sets the argument with it.
Note that this function silently returns if
objecthas no property namednameor whenvaluecannot 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
- util_set_object_array(object: Object, name: str, array: ValueArray) bool#
Transfer a
ValueArrayto %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.Added in version 1.12.
- Parameters:
object – the object to set the array to
name – the name of the property to set
array – a
ValueArraycontaining the values
- util_set_value_from_string(value_str: str) Value#
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_str – the string to get the value from
- util_simplify_fraction(numerator: int, denominator: int, n_terms: int, threshold: int) None#
Calculates the simpler representation of
numeratoranddenominatorand 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_termsandthresholdrespectively seems to give nice results.Added in version 1.24.
- util_uint64_scale(val: int, num: int, denom: int) int#
Scale
valby the rational numbernum/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 alsoutil_uint64_scale_round(),util_uint64_scale_ceil(),util_uint64_scale_int(),util_uint64_scale_int_round(),util_uint64_scale_int_ceil().
- util_uint64_scale_ceil(val: int, num: int, denom: int) int#
Scale
valby the rational numbernum/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 alsoutil_uint64_scale(),util_uint64_scale_round(),util_uint64_scale_int(),util_uint64_scale_int_round(),util_uint64_scale_int_ceil().
- util_uint64_scale_int(val: int, num: int, denom: int) int#
Scale
valby the rational numbernum/denom, avoiding overflows and underflows and without loss of precision.nummust be non-negative anddenommust be positive.- Parameters:
val – guint64 (such as a
ClockTime) 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 alsoutil_uint64_scale_int_round(),util_uint64_scale_int_ceil(),util_uint64_scale(),util_uint64_scale_round(),util_uint64_scale_ceil().
- util_uint64_scale_int_ceil(val: int, num: int, denom: int) int#
Scale
valby the rational numbernum/denom, avoiding overflows and underflows and without loss of precision.nummust be non-negative anddenommust be positive.- Parameters:
val – guint64 (such as a
ClockTime) 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 alsoutil_uint64_scale_int(),util_uint64_scale_int_round(),util_uint64_scale(),util_uint64_scale_round(),util_uint64_scale_ceil().
- util_uint64_scale_int_round(val: int, num: int, denom: int) int#
Scale
valby the rational numbernum/denom, avoiding overflows and underflows and without loss of precision.nummust be non-negative anddenommust be positive.- Parameters:
val – guint64 (such as a
ClockTime) 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 alsoutil_uint64_scale_int(),util_uint64_scale_int_ceil(),util_uint64_scale(),util_uint64_scale_round(),util_uint64_scale_ceil().
- util_uint64_scale_round(val: int, num: int, denom: int) int#
Scale
valby the rational numbernum/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 alsoutil_uint64_scale(),util_uint64_scale_ceil(),util_uint64_scale_int(),util_uint64_scale_int_round(),util_uint64_scale_int_ceil().
- value_can_compare(value1: Value, value2: Value) bool#
Determines if
value1andvalue2can be compared.- Parameters:
value1 – a value to compare
value2 – another value to compare
- Returns:
Trueif the values can be compared
- value_can_intersect(value1: Value, value2: Value) bool#
Determines if intersecting two values will produce a valid result. Two values will produce a valid intersection if they have the same type.
- Parameters:
value1 – a value to intersect
value2 – another value to intersect
- Returns:
Trueif the values can intersect
- value_can_subtract(minuend: Value, subtrahend: Value) bool#
Checks if it’s possible to subtract
subtrahendfromminuend.- Parameters:
minuend – the value to subtract from
subtrahend – the value to subtract
- Returns:
Trueif a subtraction is possible
- value_can_union(value1: Value, value2: Value) bool#
Determines if
value1andvalue2can be non-trivially unioned. Any two values can be trivially unioned by adding both of them to a GstValueList. However, certain types have the possibility to be unioned in a simpler way. For example, an integer range and an integer can be unioned if the integer is a subset of the integer range. If there is the possibility that two values can be unioned, this function returnsTrue.- Parameters:
value1 – a value to union
value2 – another value to union
- Returns:
Trueif there is a function allowing the two values to be unioned.
- value_compare(value1: Value, value2: Value) int#
Compares
value1andvalue2. Ifvalue1andvalue2cannot be compared, the function returns GST_VALUE_UNORDERED. Otherwise, ifvalue1is greater thanvalue2, GST_VALUE_GREATER_THAN is returned. Ifvalue1is less thanvalue2, GST_VALUE_LESS_THAN is returned. If the values are equal, GST_VALUE_EQUAL is returned.- Parameters:
value1 – a value to compare
value2 – another value to compare
- Returns:
comparison result
- value_deserialize(src: str) tuple[bool, Value]#
Tries to deserialize a string into the type specified by the given GValue. If the operation succeeds,
Trueis returned,Falseotherwise.- Parameters:
src – string to deserialize
- Returns:
Trueon success
- value_deserialize_with_pspec(src: str, pspec: ParamSpec | None = None) tuple[bool, Value]#
Tries to deserialize a string into the type specified by the given GValue.
pspecmay be used to guide the deserializing of nested members. If the operation succeeds,Trueis returned,Falseotherwise.Added in version 1.20.
- Parameters:
src – string to deserialize
pspec – the
ParamSpecdescribing the expected value
- Returns:
Trueon success
- value_fixate(dest: Value, src: Value) bool#
Fixate
srcinto a new valuedest. For ranges, the first element is taken. For lists and arrays, the first item is fixated and returned. Ifsrcis already fixed, this function returnsFalse.
- value_fraction_multiply(product: Value, factor1: Value, factor2: Value) bool#
Multiplies the two
Valueitems containing aGST_TYPE_FRACTIONand setsproductto the product of the two fractions.- Parameters:
product – a GValue initialized to
GST_TYPE_FRACTIONfactor1 – a GValue initialized to
GST_TYPE_FRACTIONfactor2 – a GValue initialized to
GST_TYPE_FRACTION
- Returns:
Falsein case of an error (like integer overflow),Trueotherwise.
- value_fraction_subtract(dest: Value, minuend: Value, subtrahend: Value) bool#
Subtracts the
subtrahendfrom theminuendand setsdestto the result.- Parameters:
dest – a GValue initialized to
GST_TYPE_FRACTIONminuend – a GValue initialized to
GST_TYPE_FRACTIONsubtrahend – a GValue initialized to
GST_TYPE_FRACTION
- Returns:
Falsein case of an error (like integer overflow),Trueotherwise.
- value_get_bitmask(value: Value) int#
Gets the bitmask specified by
value.- Parameters:
value – a GValue initialized to
GST_TYPE_BITMASK- Returns:
the bitmask.
- value_get_caps(value: Value) Caps#
Gets the contents of
value. The reference count of the returnedCapswill not be modified, therefore the caller must take one before getting rid of thevalue.- Parameters:
value – a GValue initialized to GST_TYPE_CAPS
- Returns:
the contents of
value
- value_get_caps_features(value: Value) CapsFeatures#
Gets the contents of
value.- Parameters:
value – a GValue initialized to GST_TYPE_CAPS_FEATURES
- Returns:
the contents of
value
- value_get_double_range_max(value: Value) float#
Gets the maximum of the range specified by
value.- Parameters:
value – a GValue initialized to GST_TYPE_DOUBLE_RANGE
- Returns:
the maximum of the range
- value_get_double_range_min(value: Value) float#
Gets the minimum of the range specified by
value.- Parameters:
value – a GValue initialized to GST_TYPE_DOUBLE_RANGE
- Returns:
the minimum of the range
- value_get_flagset_flags(value: Value) int#
Retrieve the flags field of a GstFlagSet
value.Added in version 1.6.
- Parameters:
value – a GValue initialized to
GST_TYPE_FLAG_SET- Returns:
the flags field of the flagset instance.
- value_get_flagset_mask(value: Value) int#
Retrieve the mask field of a GstFlagSet
value.Added in version 1.6.
- Parameters:
value – a GValue initialized to
GST_TYPE_FLAG_SET- Returns:
the mask field of the flagset instance.
- value_get_fraction_denominator(value: Value) int#
Gets the denominator of the fraction specified by
value.- Parameters:
value – a GValue initialized to
GST_TYPE_FRACTION- Returns:
the denominator of the fraction.
- value_get_fraction_numerator(value: Value) int#
Gets the numerator of the fraction specified by
value.- Parameters:
value – a GValue initialized to
GST_TYPE_FRACTION- Returns:
the numerator of the fraction.
- value_get_fraction_range_max(value: Value) Value | None#
Gets the maximum of the range specified by
value.- Parameters:
value – a GValue initialized to GST_TYPE_FRACTION_RANGE
- Returns:
the maximum of the range
- value_get_fraction_range_min(value: Value) Value | None#
Gets the minimum of the range specified by
value.- Parameters:
value – a GValue initialized to GST_TYPE_FRACTION_RANGE
- Returns:
the minimum of the range
- value_get_int64_range_max(value: Value) int#
Gets the maximum of the range specified by
value.- Parameters:
value – a GValue initialized to GST_TYPE_INT64_RANGE
- Returns:
the maximum of the range
- value_get_int64_range_min(value: Value) int#
Gets the minimum of the range specified by
value.- Parameters:
value – a GValue initialized to GST_TYPE_INT64_RANGE
- Returns:
the minimum of the range
- value_get_int64_range_step(value: Value) int#
Gets the step of the range specified by
value.- Parameters:
value – a GValue initialized to GST_TYPE_INT64_RANGE
- Returns:
the step of the range
- value_get_int_range_max(value: Value) int#
Gets the maximum of the range specified by
value.- Parameters:
value – a GValue initialized to GST_TYPE_INT_RANGE
- Returns:
the maximum of the range
- value_get_int_range_min(value: Value) int#
Gets the minimum of the range specified by
value.- Parameters:
value – a GValue initialized to GST_TYPE_INT_RANGE
- Returns:
the minimum of the range
- value_get_int_range_step(value: Value) int#
Gets the step of the range specified by
value.- Parameters:
value – a GValue initialized to GST_TYPE_INT_RANGE
- Returns:
the step of the range
- value_get_structure(value: Value) Structure#
Gets the contents of
value.- Parameters:
value – a GValue initialized to GST_TYPE_STRUCTURE
- Returns:
the contents of
value
- value_intersect(value1: Value, value2: Value) tuple[bool, Value]#
Calculates the intersection of two values. If the values have a non-empty intersection, the value representing the intersection is placed in
dest, unlessNone. If the intersection is non-empty,destis not modified.- Parameters:
value1 – a value to intersect
value2 – another value to intersect
- Returns:
Trueif the intersection is non-empty
- value_is_fixed(value: Value) bool#
Tests if the given GValue, if available in a GstStructure (or any other container) contains a “fixed” (which means: one value) or an “unfixed” (which means: multiple possible values, such as data lists or data ranges) value.
- Parameters:
value – the
Valueto check- Returns:
true if the value is “fixed”.
- value_register(table: ValueTable) None#
Registers functions to perform calculations on
Valueitems of a given type. Each type can only be added once.- Parameters:
table – structure containing functions to register
- value_serialize(value: Value) str | None#
tries to transform the given
valueinto a string representation that allows getting back this string later on usingvalue_deserialize().Free-function: g_free
- Parameters:
value – a
Valueto serialize- Returns:
the serialization for
valueorNoneif none exists
- value_set_bitmask(value: Value, bitmask: int) None#
Sets
valueto the bitmask specified bybitmask.- Parameters:
value – a GValue initialized to
GST_TYPE_BITMASKbitmask – the bitmask
- value_set_caps(value: Value, caps: Caps) None#
Sets the contents of
valuetocaps. A reference to the providedcapswill be taken by thevalue.- Parameters:
value – a GValue initialized to GST_TYPE_CAPS
caps – the caps to set the value to
- value_set_caps_features(value: Value, features: CapsFeatures) None#
Sets the contents of
valuetofeatures.- Parameters:
value – a GValue initialized to GST_TYPE_CAPS_FEATURES
features – the features to set the value to
- value_set_double_range(value: Value, start: float, end: float) None#
Sets
valueto the range specified bystartandend.- Parameters:
value – a GValue initialized to GST_TYPE_DOUBLE_RANGE
start – the start of the range
end – the end of the range
- value_set_flagset(value: Value, flags: int, mask: int) None#
Sets
valueto the flags and mask values provided inflagsandmask. Theflagsvalue indicates the values of flags, themaskrepresents which bits in the flag value have been set, and which are “don’t care”Added in version 1.6.
- Parameters:
value – a GValue initialized to %GST_TYPE_FLAG_SET
flags – The value of the flags set or unset
mask – The mask indicate which flags bits must match for comparisons
- value_set_fraction(value: Value, numerator: int, denominator: int) None#
Sets
valueto the fraction specified bynumeratoroverdenominator. The fraction gets reduced to the smallest numerator and denominator, and if necessary the sign is moved to the numerator.- Parameters:
value – a GValue initialized to
GST_TYPE_FRACTIONnumerator – the numerator of the fraction
denominator – the denominator of the fraction
- value_set_fraction_range(value: Value, start: Value, end: Value) None#
Sets
valueto the range specified bystartandend.- Parameters:
value – a GValue initialized to GST_TYPE_FRACTION_RANGE
start – the start of the range (a GST_TYPE_FRACTION GValue)
end – the end of the range (a GST_TYPE_FRACTION GValue)
- value_set_fraction_range_full(value: Value, numerator_start: int, denominator_start: int, numerator_end: int, denominator_end: int) None#
Sets
valueto the range specified bynumerator_start/denominator_startandnumerator_end/denominator_end.- Parameters:
value – a GValue initialized to GST_TYPE_FRACTION_RANGE
numerator_start – the numerator start of the range
denominator_start – the denominator start of the range
numerator_end – the numerator end of the range
denominator_end – the denominator end of the range
- value_set_int64_range(value: Value, start: int, end: int) None#
Sets
valueto the range specified bystartandend.- Parameters:
value – a GValue initialized to GST_TYPE_INT64_RANGE
start – the start of the range
end – the end of the range
- value_set_int64_range_step(value: Value, start: int, end: int, step: int) None#
Sets
valueto the range specified bystart,endandstep.- Parameters:
value – a GValue initialized to GST_TYPE_INT64_RANGE
start – the start of the range
end – the end of the range
step – the step of the range
- value_set_int_range(value: Value, start: int, end: int) None#
Sets
valueto the range specified bystartandend.- Parameters:
value – a GValue initialized to GST_TYPE_INT_RANGE
start – the start of the range
end – the end of the range
- value_set_int_range_step(value: Value, start: int, end: int, step: int) None#
Sets
valueto the range specified bystart,endandstep.- Parameters:
value – a GValue initialized to GST_TYPE_INT_RANGE
start – the start of the range
end – the end of the range
step – the step of the range
- value_set_structure(value: Value, structure: Structure) None#
Sets the contents of
valuetostructure.- Parameters:
value – a GValue initialized to GST_TYPE_STRUCTURE
structure – the structure to set the value to
- value_subtract(minuend: Value, subtrahend: Value) tuple[bool, Value]#
Subtracts
subtrahendfromminuendand stores the result indest. Note that this means subtraction as in sets, not as in mathematics.- Parameters:
minuend – the value to subtract from
subtrahend – the value to subtract
- Returns:
Trueif the subtraction is not empty