Class: Gst::Element

Inherits:
Object
  • Object
show all
Defined in:
lib/gst/element.rb

Overview

GStreamer element class. Override the vmethods to implement the element functionality.

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Object

#add_control_binding, check_uniqueness, #control_bindings_disabled=, #control_rate, #control_rate=, default_deep_notify, #default_error, #get_control_binding, #get_g_value_array, #get_value, #get_value_array, #has_active_control_bindings, #has_ancestor, #has_as_ancestor, #has_as_parent, #name, #name=, #parent, #parent=, #path_string, #ref, ref_sink, #remove_control_binding, replace, #set_control_binding_disabled, #suggest_next_sync, #sync_values, #unparent, #unref

Class Method Details

.[](name) ⇒ Object



20
21
22
# File 'lib/gst/element.rb', line 20

def [](name)
  ElementFactory.make(name)
end

.make_from_uri(type, uri, elementname) ⇒ Gst::Element

Creates an element for handling the given URI. could be created

Parameters:

  • type (Gst::URIType)

    Whether to create a source or a sink

  • uri (String)

    URI to create an element for

  • elementname (String)

    Name of created element, can be nil.

Returns:

.register(plugin, name, rank, type) ⇒ Boolean

Create a new elementfactory capable of instantiating objects of the type and add the factory to plugin.

Parameters:

  • plugin (Gst::Plugin)

    Gst::Plugin to register the element with, or nil for a static element.

  • name (String)

    name of elements of this type

  • rank (Integer)

    rank of element (higher rank means more importance when autoplugging)

  • type (GLib::Type)

    GType of element to register

Returns:

  • (Boolean)

    true, if the registering succeeded, false on error

.state_change_return_get_name(state_ret) ⇒ String

Gets a string representing the given state change result.

Parameters:

Returns:

  • (String)

    a string with the name of the state result.

.state_get_name(state) ⇒ String

Gets a string representing the given state.

Parameters:

  • state (Gst::State)

    a Gst::State to get the name of.

Returns:

  • (String)

    a string with the name of the state.

.type_set_skip_documentation(type) ⇒ nil

Marks type as "documentation should be skipped". Can be useful for dynamically registered element to be excluded from plugin documentation system.

Example:

GType my_type;
GTypeInfo my_type_info;

// Fill "my_type_info"
...

my_type = g_type_register_static (GST_TYPE_MY_ELEMENT, "my-type-name",
   &my_type_info, 0);
gst_element_type_set_skip_documentation (my_type);
gst_element_register (plugin, "my-plugin-feature-name", rank, my_type);

Parameters:

  • type (GLib::Type)

    a #GType of element

Returns:

  • (nil)

Instance Method Details

#>>(element) ⇒ Object



49
50
51
52
# File 'lib/gst/element.rb', line 49

def >>(element)
  link_element(element)
  element
end

#abort_statenil

Abort the state change of the element. This function is used by elements that do asynchronous state changes and find out something is wrong.

This function should be called with the STATE_LOCK held.

MT safe.

Returns:

  • (nil)

#add_metadata(key, value) ⇒ nil

Set key with value as metadata in klass.

Parameters:

  • key (String)

    the key to set

  • value (String)

    the value to set

Returns:

  • (nil)

#add_pad(pad) ⇒ Boolean

Adds a pad (link point) to element. pad's parent will be set to element; see gst_object_set_parent() for refcounting information.

Pads are automatically activated when added in the PAUSED or PLAYING state.

The pad and the element should be unlocked when calling this function.

This function will emit the Gst::Element::pad-added signal on the element. a pad with the same name already existed or the pad already had another parent.

MT safe.

Parameters:

  • pad (Gst::Pad)

    the Gst::Pad to add to the element.

Returns:

  • (Boolean)

    true if the pad could be added. This function can fail when

#add_pad_template(templ) ⇒ nil

Adds a padtemplate to an element class. This is mainly used in the _class_init functions of classes. If a pad template with the same name as an already existing one is added the old one is replaced by the new one.

templ's reference count will be incremented, and any floating reference will be removed (see gst_object_ref_sink())

Parameters:

Returns:

  • (nil)

#add_property_deep_notify_watch(property_name, include_value) ⇒ Gst::gulong

Returns a watch id, which can be used in connection with gst_element_remove_property_notify_watch() to remove the watch again.

Parameters:

  • property_name (String)

    name of property to watch for changes, or NULL to watch all properties

  • include_value (Boolean)

    whether to include the new property value in the message

Returns:

  • (Gst::gulong)

    a watch id, which can be used in connection with gst_element_remove_property_notify_watch() to remove the watch again.

#add_property_notify_watch(property_name, include_value) ⇒ Gst::gulong

Returns a watch id, which can be used in connection with gst_element_remove_property_notify_watch() to remove the watch again.

Parameters:

  • property_name (String)

    name of property to watch for changes, or NULL to watch all properties

  • include_value (Boolean)

    whether to include the new property value in the message

Returns:

  • (Gst::gulong)

    a watch id, which can be used in connection with gst_element_remove_property_notify_watch() to remove the watch again.

#add_static_metadata(key, value) ⇒ nil

Set key with value as metadata in klass.

Same as gst_element_class_add_metadata(), but value must be a static string or an inlined string, as it will not be copied. (GStreamer plugins will be made resident once loaded, so this function can be used even from dynamically loaded plugins.)

Parameters:

  • key (String)

    the key to set

  • value (String)

    the value to set

Returns:

  • (nil)

#add_static_pad_template(static_templ) ⇒ nil

Adds a pad template to an element class based on the static pad template templ. This is mainly used in the _class_init functions of element implementations. If a pad template with the same name already exists, the old one is replaced by the new one.

Parameters:

  • static_templ (Gst::StaticPadTemplate)

    Gst::StaticPadTemplate to add as pad template to the element class.

Returns:

  • (nil)

#add_static_pad_template_with_gtype(static_templ, pad_type) ⇒ nil

Adds a pad template to an element class based on the static pad template templ. This is mainly used in the _class_init functions of element implementations. If a pad template with the same name already exists, the old one is replaced by the new one.

Parameters:

  • static_templ (Gst::StaticPadTemplate)

    Gst::StaticPadTemplate to add as pad template to the element class.

  • pad_type (GLib::Type)

    The #GType of the pad to create

Returns:

  • (nil)

#base_timeGst::ClockTime

Returns the base time of the element. The base time is the absolute time of the clock when this element was last put to PLAYING. Subtracting the base time from the clock time gives the running time of the element. MT safe.

Returns:

  • (Gst::ClockTime)

    the base time of the element.

#base_time=(time) ⇒ nil

Set the base time of an element. See gst_element_get_base_time().

MT safe.

Parameters:

  • time (Gst::ClockTime)

    the base time to set.

Returns:

  • (nil)

#busGst::Bus

Returns the bus of the element. Note that only a Gst::Pipeline will provide a bus for the application. usage.

MT safe.

Returns:

  • (Gst::Bus)

    the element's Gst::Bus. unref after

#bus=(bus) ⇒ nil

Sets the bus of the element. Increases the refcount on the bus. For internal use only, unless you're testing elements.

MT safe.

Parameters:

  • bus (Gst::Bus)

    the Gst::Bus to set.

Returns:

  • (nil)

#call_async(func, user_data, destroy_notify) ⇒ nil

Calls func from another thread and passes user_data to it. This is to be used for cases when a state change has to be performed from a streaming thread, directly via gst_element_set_state() or indirectly e.g. via SEEK events.

Calling those functions directly from the streaming thread will cause deadlocks in many situations, as they might involve waiting for the streaming thread to shut down from this very streaming thread.

MT safe.

Parameters:

  • func (Gst::ElementCallAsyncFunc)

    Function to call asynchronously from another thread

  • user_data (GObject)

    Data to pass to func

  • destroy_notify (GLib::DestroyNotify)

    GDestroyNotify for user_data

Returns:

  • (nil)

#change_state(transition) ⇒ Gst::StateChangeReturn

Perform transition on element.

This function must be called with STATE_LOCK held and is mainly used internally.

Parameters:

Returns:

#clockGst::Clock

Gets the currently configured clock of the element. This is the clock as was last set with gst_element_set_clock().

Elements in a pipeline will only have their clock set when the pipeline is in the PLAYING state. MT safe.

Returns:

  • (Gst::Clock)

    the Gst::Clock of the element. unref after usage.

#clock=(clock) ⇒ Boolean

Sets the clock for the element. This function increases the refcount on the clock. Any previously set clock on the object is unreffed. clock when it, for example, is not able to slave its internal clock to the clock or when it requires a specific clock to operate.

MT safe.

Parameters:

  • clock (Gst::Clock)

    the Gst::Clock to set for the element.

Returns:

  • (Boolean)

    true if the element accepted the clock. An element can refuse a

#context=(context) ⇒ nil

Sets the context of the element. Increases the refcount of the context.

MT safe.

Parameters:

  • context (Gst::Context)

    the Gst::Context to set.

Returns:

  • (nil)

#contextsGLib::List<Gst::Context>

Gets the contexts set on the element.

MT safe.

Returns:

  • (GLib::List<Gst::Context>)

    List of Gst::Context

#continue_state(ret) ⇒ Gst::StateChangeReturn

Commit the state change of the element and proceed to the next pending state if any. This function is used by elements that do asynchronous state changes. The core will normally call this method automatically when an element returned %GST_STATE_CHANGE_SUCCESS from the state change function.

If after calling this method the element still has not reached the pending state, the next state change is performed.

This method is used internally and should normally not be called by plugins or applications.

This function must be called with STATE_LOCK held. MT safe.

Parameters:

Returns:

#create_all_padsnil

Creates a pad for each pad template that is always available. This function is only useful during object initialization of subclasses of Gst::Element.

Returns:

  • (nil)

#current_clock_timeGst::ClockTime

Returns the current clock time of the element, as in, the time of the element's clock, or GST_CLOCK_TIME_NONE if there is no clock. no clock.

Returns:

  • (Gst::ClockTime)

    the clock time of the element, or GST_CLOCK_TIME_NONE if there is

#current_running_timeGst::ClockTime

Returns the running time of the element. The running time is the element's clock time minus its base time. Will return GST_CLOCK_TIME_NONE if the element has no clock, or if its base time has not been set. element has no clock or its base time has not been set.

Returns:

  • (Gst::ClockTime)

    the running time of the element, or GST_CLOCK_TIME_NONE if the

#decorate_stream_id(stream_id) ⇒ String

Creates a stream-id for element by combining the upstream information with the stream_id.

This function generates an unique stream-id by getting the upstream stream-start event stream ID and appending stream_id to it. If the element has no sinkpad it will generate an upstream stream-id by doing an URI query on the element and in the worst case just uses a random number. Source elements that don't implement the URI handler interface should ideally generate a unique, deterministic stream-id manually instead.

Since stream IDs are sorted alphabetically, any numbers in the stream ID should be printed with a fixed number of characters, preceded by 0's, such as by using the format %03u instead of %u.

Parameters:

  • stream_id (String)

    The stream-id

Returns:

  • (String)

    A stream-id for element.

#decorate_stream_id_printf(format, array) ⇒ String

Creates a stream-id for element by combining the upstream information with the format.

This function generates an unique stream-id by getting the upstream stream-start event stream ID and appending the stream-id to it. If the element has no sinkpad it will generate an upstream stream-id by doing an URI query on the element and in the worst case just uses a random number. Source elements that don't implement the URI handler interface should ideally generate a unique, deterministic stream-id manually instead.

Since stream IDs are sorted alphabetically, any numbers in the stream ID should be printed with a fixed number of characters, preceded by 0's, such as by using the format %03u instead of %u.

Parameters:

  • format (String)

    The stream-id

  • array (Array)

Returns:

  • (String)

    A stream-id for element.

#decorate_stream_id_printf_valist(format, var_args) ⇒ String

Creates a stream-id for element by combining the upstream information with the format.

This function generates an unique stream-id by getting the upstream stream-start event stream ID and appending format to it. If the element has no sinkpad it will generate an upstream stream-id by doing an URI query on the element and in the worst case just uses a random number. Source elements that don't implement the URI handler interface should ideally generate a unique, deterministic stream-id manually instead.

Since stream IDs are sorted alphabetically, any numbers in the stream ID should be printed with a fixed number of characters, preceded by 0's, such as by using the format %03u instead of %u.

Parameters:

  • format (String)

    The stream-id

  • var_args (Gst::va_list)

    parameters for the format string

Returns:

  • (String)

    A stream-id for element.

#factoryGst::ElementFactory

Retrieves the factory that was used to create this element.

Returns:

  • (Gst::ElementFactory)

    the Gst::ElementFactory used for creating this element or nil if element has not been registered (static element). no refcounting is needed.

#flagsObject



55
56
57
# File 'lib/gst/element.rb', line 55

def flags
  ElementFlags.new(flags_raw)
end

#flags_rawObject



54
# File 'lib/gst/element.rb', line 54

alias_method :flags_raw, :flags

#foreach_pad(func, user_data) ⇒ Boolean

Call func with user_data for each of element's pads. func will be called exactly once for each pad that exists at the time of this call, unless one of the calls to func returns false in which case we will stop iterating pads and return early. If new pads are added or pads are removed while pads are being iterated, this will not be taken into account until next time this function is used.

Parameters:

  • func (Gst::ElementForeachPadFunc)

    function to call for each pad

  • user_data (GObject)

    user data passed to func

Returns:

  • (Boolean)

    false if element had no pads or if one of the calls to func returned false.

#foreach_sink_pad(func, user_data) ⇒ Boolean

Call func with user_data for each of element's sink pads. func will be called exactly once for each sink pad that exists at the time of this call, unless one of the calls to func returns false in which case we will stop iterating pads and return early. If new sink pads are added or sink pads are removed while the sink pads are being iterated, this will not be taken into account until next time this function is used.

Parameters:

  • func (Gst::ElementForeachPadFunc)

    function to call for each sink pad

  • user_data (GObject)

    user data passed to func

Returns:

  • (Boolean)

    false if element had no sink pads or if one of the calls to func returned false.

#foreach_src_pad(func, user_data) ⇒ Boolean

Call func with user_data for each of element's source pads. func will be called exactly once for each source pad that exists at the time of this call, unless one of the calls to func returns false in which case we will stop iterating pads and return early. If new source pads are added or source pads are removed while the source pads are being iterated, this will not be taken into account until next time this function is used.

Parameters:

  • func (Gst::ElementForeachPadFunc)

    function to call for each source pad

  • user_data (GObject)

    user data passed to func

Returns:

  • (Boolean)

    false if element had no source pads or if one of the calls to func returned false.

#get_compatible_pad(pad, caps) ⇒ Gst::Pad

Looks for an unlinked pad to which the given pad can link. It is not guaranteed that linking the pads will work, though it should work in most cases.

This function will first attempt to find a compatible unlinked ALWAYS pad, and if none can be found, it will request a compatible REQUEST pad by looking at the templates of element.

Parameters:

  • pad (Gst::Pad)

    the Gst::Pad to find a compatible one for.

  • caps (Gst::Caps)

    the Gst::Caps to use as a filter.

Returns:

  • (Gst::Pad)

    the Gst::Pad to which a link can be made, or nil if one cannot be found. gst_object_unref() after usage.

#get_compatible_pad_template(compattempl) ⇒ Gst::PadTemplate

Retrieves a pad template from element that is compatible with compattempl. Pads from compatible templates can be linked together.

Parameters:

  • compattempl (Gst::PadTemplate)

    the Gst::PadTemplate to find a compatible template for

Returns:

  • (Gst::PadTemplate)

    a compatible Gst::PadTemplate, or nil if none was found. No unreferencing is necessary.

#get_context(context_type) ⇒ Gst::Context

Gets the context with context_type set on the element or NULL.

MT safe.

Parameters:

  • context_type (String)

    a name of a context to retrieve

Returns:

  • (Gst::Context)

    A Gst::Context or NULL

#get_context_unlocked(context_type) ⇒ Gst::Context

Gets the context with context_type set on the element or NULL.

Parameters:

  • context_type (String)

    a name of a context to retrieve

Returns:

  • (Gst::Context)

    A Gst::Context or NULL

#get_metadata(key) ⇒ String

Get metadata with key in klass.

Parameters:

  • key (String)

    the key to get

Returns:

  • (String)

    the metadata for key.

#get_pad_template(name) ⇒ Gst::PadTemplate

Retrieves a padtemplate from element_class with the given name.

If you use this function in the GInstanceInitFunc of an object class that has subclasses, make sure to pass the g_class parameter of the GInstanceInitFunc here.

Parameters:

  • name (String)

    the name of the Gst::PadTemplate to get.

Returns:

  • (Gst::PadTemplate)

    the Gst::PadTemplate with the given name, or nil if none was found. No unreferencing is necessary.

#get_request_pad(name) ⇒ Gst::Pad

The name of this function is confusing to people learning GStreamer. gst_element_request_pad_simple() aims at making it more explicit it is a simplified gst_element_request_pad().

Parameters:

  • name (String)

    the name of the request Gst::Pad to retrieve.

Returns:

  • (Gst::Pad)

    requested Gst::Pad if found, otherwise nil. Release after usage.

#get_state(state, pending, timeout) ⇒ Gst::StateChangeReturn

Gets the state of the element.

For elements that performed an ASYNC state change, as reported by gst_element_set_state(), this function will block up to the specified timeout value for the state change to complete. If the element completes the state change or goes into an error, this function returns immediately with a return value of %GST_STATE_CHANGE_SUCCESS or %GST_STATE_CHANGE_FAILURE respectively.

For elements that did not return %GST_STATE_CHANGE_ASYNC, this function returns the current and pending state immediately.

This function returns %GST_STATE_CHANGE_NO_PREROLL if the element successfully changed its state but is not able to provide data yet. This mostly happens for live sources that only produce data in %GST_STATE_PLAYING. While the state change return is equivalent to %GST_STATE_CHANGE_SUCCESS, it is returned to the application to signal that some sink elements might not be able to complete their state change because an element is not producing data to complete the preroll. When setting the element to playing, the preroll will complete and playback will start. MT safe.

Parameters:

  • state (Gst::State)

    a pointer to Gst::State to hold the state. Can be nil.

  • pending (Gst::State)

    a pointer to Gst::State to hold the pending state. Can be nil.

  • timeout (Gst::ClockTime)

    a Gst::ClockTime to specify the timeout for an async state change or %GST_CLOCK_TIME_NONE for infinite timeout.

Returns:

  • (Gst::StateChangeReturn)

    %GST_STATE_CHANGE_SUCCESS if the element has no more pending state and the last state change succeeded, %GST_STATE_CHANGE_ASYNC if the element is still performing a state change or %GST_STATE_CHANGE_FAILURE if the last state change failed.

#get_static_pad(name) ⇒ Gst::Pad

Retrieves a pad from element by name. This version only retrieves already-existing (i.e. 'static') pads. MT safe.

Parameters:

  • name (String)

    the name of the static Gst::Pad to retrieve.

Returns:

  • (Gst::Pad)

    the requested Gst::Pad if found, otherwise nil. unref after usage.

#is_locked_stateBoolean

Checks if the state of an element is locked. If the state of an element is locked, state changes of the parent don't affect the element. This way you can leave currently unused elements inside bins. Just lock their state before changing the state from #GST_STATE_NULL.

MT safe.

Returns:

  • (Boolean)

    true, if the element's state is locked.

#iterate_padsGst::Iterator

Retrieves an iterator of element's pads. The iterator should be freed after usage. Also more specialized iterators exists such as gst_element_iterate_src_pads() or gst_element_iterate_sink_pads().

The order of pads returned by the iterator will be the order in which the pads were added to the element. MT safe.

Returns:

  • (Gst::Iterator)

    the Gst::Iterator of #GstPad.

#iterate_sink_padsGst::Iterator

Retrieves an iterator of element's sink pads.

The order of pads returned by the iterator will be the order in which the pads were added to the element. MT safe.

Returns:

  • (Gst::Iterator)

    the Gst::Iterator of #GstPad.

#iterate_src_padsGst::Iterator

Retrieves an iterator of element's source pads.

The order of pads returned by the iterator will be the order in which the pads were added to the element. MT safe.

Returns:

  • (Gst::Iterator)

    the Gst::Iterator of #GstPad.



42
43
44
45
46
# File 'lib/gst/element.rb', line 42

def link_elements(*elements)
  elements.each do |element|
    link_element(element)
  end
end

Links src to dest using the given caps as filtercaps. The link must be from source to destination; the other direction will not be tried. The function looks for existing pads that aren't linked yet. It will request new pads if necessary. If multiple links are possible, only one is established.

Make sure you have added your elements to a bin or pipeline with gst_bin_add() before trying to link them.

Parameters:

  • dest (Gst::Element)

    the Gst::Element containing the destination pad.

  • filter (Gst::Caps)

    the Gst::Caps to filter the link, or nil for no filter.

Returns:

  • (Boolean)

    true if the pads could be linked, false otherwise.

Chain together a series of elements. Uses gst_element_link(). Make sure you have added your elements to a bin or pipeline with gst_bin_add() before trying to link them.

Parameters:

  • element_2 (Gst::Element)

    the second Gst::Element in the link chain.

  • array (Array)

    the nil-terminated list of elements to link in order.

Returns:

  • (Boolean)

    true on success, false otherwise.

Links the two named pads of the source and destination elements. Side effect is that if one of the pads has no parent, it becomes a child of the parent of the other element. If they have different parents, the link fails. or nil for any pad.

Parameters:

  • srcpadname (String)

    the name of the Gst::Pad in source element or nil for any pad.

  • dest (Gst::Element)

    the Gst::Element containing the destination pad.

  • destpadname (String)

    the name of the Gst::Pad in destination element,

Returns:

  • (Boolean)

    true if the pads could be linked, false otherwise.

Links the two named pads of the source and destination elements. Side effect is that if one of the pads has no parent, it becomes a child of the parent of the other element. If they have different parents, the link fails. If caps is not nil, makes sure that the caps of the link is a subset of caps.

Parameters:

  • srcpadname (String)

    the name of the Gst::Pad in source element or nil for any pad.

  • dest (Gst::Element)

    the Gst::Element containing the destination pad.

  • destpadname (String)

    the name of the Gst::Pad in destination element or nil for any pad.

  • filter (Gst::Caps)

    the Gst::Caps to filter the link, or nil for no filter.

Returns:

  • (Boolean)

    true if the pads could be linked, false otherwise.

Links the two named pads of the source and destination elements. Side effect is that if one of the pads has no parent, it becomes a child of the parent of the other element. If they have different parents, the link fails.

Calling gst_element_link_pads_full() with flags == %GST_PAD_LINK_CHECK_DEFAULT is the same as calling gst_element_link_pads() and the recommended way of linking pads with safety checks applied.

This is a convenience function for gst_pad_link_full(). or nil for any pad.

Parameters:

  • srcpadname (String)

    the name of the Gst::Pad in source element or nil for any pad.

  • dest (Gst::Element)

    the Gst::Element containing the destination pad.

  • destpadname (String)

    the name of the Gst::Pad in destination element,

  • flags (Gst::PadLinkCheck)

    the Gst::PadLinkCheck to be performed when linking pads.

Returns:

  • (Boolean)

    true if the pads could be linked, false otherwise.

#locked_state=(locked_state) ⇒ Boolean

Locks the state of an element, so state changes of the parent don't affect this element anymore.

Note that this is racy if the state lock of the parent bin is not taken. The parent bin might've just checked the flag in another thread and as the next step proceed to change the child element's state.

MT safe. or the elements state-locking needed no change.

Parameters:

  • locked_state (Boolean)

    true to lock the element's state

Returns:

  • (Boolean)

    true if the state was changed, false if bad parameters were given

#lost_statenil

Brings the element to the lost state. The current state of the element is copied to the pending state so that any call to gst_element_get_state() will return %GST_STATE_CHANGE_ASYNC.

An ASYNC_START message is posted. If the element was PLAYING, it will go to PAUSED. The element will be restored to its PLAYING state by the parent pipeline when it prerolls again.

This is mostly used for elements that lost their preroll buffer in the %GST_STATE_PAUSED or %GST_STATE_PLAYING state after a flush, they will go to their pending state again when a new preroll buffer is queued. This function can only be called when the element is currently not in error or an async state change.

This function is used internally and should normally not be called from plugins or applications.

Returns:

  • (nil)

#message_full(type, domain, code, text, debug, file, function, line) ⇒ nil

Post an error, warning or info message on the bus from inside an element.

type must be of #GST_MESSAGE_ERROR, #GST_MESSAGE_WARNING or #GST_MESSAGE_INFO.

MT safe.

Parameters:

  • type (Gst::MessageType)

    the Gst::MessageType

  • domain (GLib::Quark)

    the GStreamer GError domain this message belongs to

  • code (Integer)

    the GError code belonging to the domain

  • text (String)

    an allocated text string to be used as a replacement for the default message connected to code, or nil

  • debug (String)

    an allocated debug message to be used as a replacement for the default debugging information, or nil

  • file (String)

    the source code file where the error was generated

  • function (String)

    the source code function where the error was generated

  • line (Integer)

    the source code line where the error was generated

Returns:

  • (nil)

#message_full_with_details(type, domain, code, text, debug, file, function, line, structure) ⇒ nil

Post an error, warning or info message on the bus from inside an element.

type must be of #GST_MESSAGE_ERROR, #GST_MESSAGE_WARNING or #GST_MESSAGE_INFO.

Parameters:

  • type (Gst::MessageType)

    the Gst::MessageType

  • domain (GLib::Quark)

    the GStreamer GError domain this message belongs to

  • code (Integer)

    the GError code belonging to the domain

  • text (String)

    an allocated text string to be used as a replacement for the default message connected to code, or nil

  • debug (String)

    an allocated debug message to be used as a replacement for the default debugging information, or nil

  • file (String)

    the source code file where the error was generated

  • function (String)

    the source code function where the error was generated

  • line (Integer)

    the source code line where the error was generated

  • structure (Gst::Structure)

    optional details structure

Returns:

  • (nil)

#no_more_padsnil

Use this function to signal that the element does not expect any more pads to show up in the current pipeline. This function should be called whenever pads have been added by the element itself. Elements with #GST_PAD_SOMETIMES pad templates use this in combination with autopluggers to figure out that the element is done initializing its pads.

This function emits the Gst::Element::no-more-pads signal.

MT safe.

Returns:

  • (nil)

#pad_template_listGLib::List<Gst::PadTemplate>

Retrieves a list of the pad templates associated with element_class. The list must not be modified by the calling code.

If you use this function in the GInstanceInitFunc of an object class that has subclasses, make sure to pass the g_class parameter of the GInstanceInitFunc here.

Returns:

#pauseObject



33
34
35
# File 'lib/gst/element.rb', line 33

def pause
  set_state(State::PAUSED)
end

#playObject



37
38
39
# File 'lib/gst/element.rb', line 37

def play
  set_state(State::PLAYING)
end

#post_message(message) ⇒ Boolean

Post a message on the element's Gst::Bus. This function takes ownership of the message; if you want to access the message after this call, you should add an additional reference before calling. false if the element did not have a bus.

MT safe.

Parameters:

  • message (Gst::Message)

    a Gst::Message to post

Returns:

  • (Boolean)

    true if the message was successfully posted. The function returns

#provide_clockGst::Clock

Get the clock provided by the given element.

An element is only required to provide a clock in the PAUSED state. Some elements can provide a clock in other states. element or nil if no clock could be provided. Unref after usage.

MT safe.

Returns:

#query(query) ⇒ Boolean

Performs a query on the given element.

For elements that don't implement a query handler, this function forwards the query to a random srcpad or to the peer of a random linked sinkpad of this element.

Please note that some queries might need a running pipeline to work. MT safe.

Parameters:

  • query (Gst::Query)

    the Gst::Query.

Returns:

  • (Boolean)

    true if the query could be performed.

#query_convert(src_format, src_val, dest_format, dest_val) ⇒ Boolean

Queries an element to convert src_val in src_format to dest_format.

Parameters:

  • src_format (Gst::Format)

    a Gst::Format to convert from.

  • src_val (Integer)

    a value to convert.

  • dest_format (Gst::Format)

    the Gst::Format to convert to.

  • dest_val (Integer)

    a pointer to the result.

Returns:

  • (Boolean)

    true if the query could be performed.

#query_duration(format, duration) ⇒ Boolean

Queries an element (usually top-level pipeline or playbin element) for the total stream duration in nanoseconds. This query will only work once the pipeline is prerolled (i.e. reached PAUSED or PLAYING state). The application will receive an ASYNC_DONE message on the pipeline bus when that is the case.

If the duration changes for some reason, you will get a DURATION_CHANGED message on the pipeline bus, in which case you should re-query the duration using this function.

Parameters:

  • format (Gst::Format)

    the Gst::Format requested

  • duration (Integer)

    A location in which to store the total duration, or nil.

Returns:

  • (Boolean)

    true if the query could be performed.

#query_position(format, cur) ⇒ Boolean

Queries an element (usually top-level pipeline or playbin element) for the stream position in nanoseconds. This will be a value between 0 and the stream duration (if the stream duration is known). This query will usually only work once the pipeline is prerolled (i.e. reached PAUSED or PLAYING state). The application will receive an ASYNC_DONE message on the pipeline bus when that is the case.

If one repeatedly calls this function one can also create a query and reuse it in gst_element_query().

Parameters:

  • format (Gst::Format)

    the Gst::Format requested

  • cur (Integer)

    a location in which to store the current position, or nil.

Returns:

  • (Boolean)

    true if the query could be performed.

#readyObject



29
30
31
# File 'lib/gst/element.rb', line 29

def ready
  set_state(State::READY)
end

#release_request_pad(pad) ⇒ nil

Makes the element free the previously requested pad as obtained with gst_element_request_pad().

This does not unref the pad. If the pad was created by using gst_element_request_pad(), gst_element_release_request_pad() needs to be followed by gst_object_unref() to free the pad.

MT safe.

Parameters:

  • pad (Gst::Pad)

    the Gst::Pad to release.

Returns:

  • (nil)

#remove_pad(pad) ⇒ Boolean

Removes pad from element. pad will be destroyed if it has not been referenced elsewhere using gst_object_unparent().

This function is used by plugin developers and should not be used by applications. Pads that were dynamically requested from elements with gst_element_request_pad() should be released with the gst_element_release_request_pad() function instead.

Pads are not automatically deactivated so elements should perform the needed steps to deactivate the pad in case this pad is removed in the PAUSED or PLAYING state. See gst_pad_set_active() for more information about deactivating pads.

The pad and the element should be unlocked when calling this function.

This function will emit the Gst::Element::pad-removed signal on the element. pad does not belong to the provided element.

MT safe.

Parameters:

  • pad (Gst::Pad)

    the Gst::Pad to remove from the element.

Returns:

  • (Boolean)

    true if the pad could be removed. Can return false if the

#remove_property_notify_watch(watch_id) ⇒ nil

Parameters:

  • watch_id (Gst::gulong)

    watch id to remove

Returns:

  • (nil)

#request_pad(templ, name, caps) ⇒ Gst::Pad

Retrieves a request pad from the element according to the provided template. Pad templates can be looked up using gst_element_factory_get_static_pad_templates().

The pad should be released with gst_element_release_request_pad(). to retrieve. Can be nil. request. Can be nil.

Parameters:

  • templ (Gst::PadTemplate)

    a Gst::PadTemplate of which we want a pad of.

  • name (String)

    the name of the request Gst::Pad

  • caps (Gst::Caps)

    the caps of the pad we want to

Returns:

  • (Gst::Pad)

    requested Gst::Pad if found, otherwise nil. Release after usage.

#request_pad_simple(name) ⇒ Gst::Pad

Retrieves a pad from the element by name (e.g. "src_%d"). This version only retrieves request pads. The pad should be released with gst_element_release_request_pad().

This method is slower than manually getting the pad template and calling gst_element_request_pad() if the pads should have a specific name (e.g. name is "src_1" instead of "src_%u").

Note that this function was introduced in GStreamer 1.20 in order to provide a better name to gst_element_get_request_pad(). Prior to 1.20, users should use gst_element_get_request_pad() which provides the same functionality.

Parameters:

  • name (String)

    the name of the request Gst::Pad to retrieve.

Returns:

  • (Gst::Pad)

    requested Gst::Pad if found, otherwise nil. Release after usage.

#seek(rate, format, flags, start_type, start, stop_type, stop) ⇒ Boolean

Sends a seek event to an element. See gst_event_new_seek() for the details of the parameters. The seek event is sent to the element using gst_element_send_event().

MT safe. preroll, which will emit %GST_MESSAGE_ASYNC_DONE.

Parameters:

  • rate (Float)

    The new playback rate

  • format (Gst::Format)

    The format of the seek values

  • flags (Gst::SeekFlags)

    The optional seek flags.

  • start_type (Gst::SeekType)

    The type and flags for the new start position

  • start (Integer)

    The value of the new start position

  • stop_type (Gst::SeekType)

    The type and flags for the new stop position

  • stop (Integer)

    The value of the new stop position

Returns:

  • (Boolean)

    true if the event was handled. Flushing seeks will trigger a

#seek_simple(format, seek_flags, seek_pos) ⇒ Boolean

Simple API to perform a seek on the given element, meaning it just seeks to the given position relative to the start of the stream. For more complex operations like segment seeks (e.g. for looping) or changing the playback rate or seeking relative to the last configured playback segment you should use gst_element_seek().

In a completely prerolled PAUSED or PLAYING pipeline, seeking is always guaranteed to return true on a seekable media type or false when the media type is certainly not seekable (such as a live stream).

Some elements allow for seeking in the READY state, in this case they will store the seek event and execute it when they are put to PAUSED. If the element supports seek in READY, it will always return true when it receives the event in the READY state. preroll, which will emit %GST_MESSAGE_ASYNC_DONE.

Parameters:

  • format (Gst::Format)

    a Gst::Format to execute the seek in, such as #GST_FORMAT_TIME

  • seek_flags (Gst::SeekFlags)

    seek options; playback applications will usually want to use GST_SEEK_FLAG_FLUSH | GST_SEEK_FLAG_KEY_UNIT here

  • seek_pos (Integer)

    position to seek to (relative to the start); if you are doing a seek in #GST_FORMAT_TIME this value is in nanoseconds - multiply with #GST_SECOND to convert seconds to nanoseconds or with #GST_MSECOND to convert milliseconds to nanoseconds.

Returns:

  • (Boolean)

    true if the seek operation succeeded. Flushing seeks will trigger a

#send_event(event) ⇒ Boolean

Sends an event to an element. If the element doesn't implement an event handler, the event will be pushed on a random linked sink pad for downstream events or a random linked source pad for upstream events.

This function takes ownership of the provided event so you should gst_event_ref() it if you want to reuse the event after this call.

MT safe. as flushing seeks and steps) will emit %GST_MESSAGE_ASYNC_DONE.

Parameters:

  • event (Gst::Event)

    the Gst::Event to send to the element.

Returns:

  • (Boolean)

    true if the event was handled. Events that trigger a preroll (such

#set_metadata(longname, classification, description, author) ⇒ nil

Sets the detailed information for a Gst::ElementClass.

This function is for use in _class_init functions only. separated with slashes ('/'). See draft-klass.txt of the design docs for more details and common types. E.g: "Sink/File" E.g: "Write stream to a file" multiple author metadata. E.g: "Joe Bloggs <joe.blogs at foo.com>"

Parameters:

  • longname (String)

    The long English name of the element. E.g. "File Sink"

  • classification (String)

    String describing the type of element, as an unordered list

  • description (String)

    Sentence describing the purpose of the element.

  • author (String)

    Name and contact details of the author(s). Use \n to separate

Returns:

  • (nil)

#set_static_metadata(longname, classification, description, author) ⇒ nil

Sets the detailed information for a Gst::ElementClass.

This function is for use in _class_init functions only.

Same as gst_element_class_set_metadata(), but longname, classification, description, and author must be static strings or inlined strings, as they will not be copied. (GStreamer plugins will be made resident once loaded, so this function can be used even from dynamically loaded plugins.) separated with slashes ('/'). See draft-klass.txt of the design docs for more details and common types. E.g: "Sink/File" E.g: "Write stream to a file" multiple author metadata. E.g: "Joe Bloggs <joe.blogs at foo.com>"

Parameters:

  • longname (String)

    The long English name of the element. E.g. "File Sink"

  • classification (String)

    String describing the type of element, as an unordered list

  • description (String)

    Sentence describing the purpose of the element.

  • author (String)

    Name and contact details of the author(s). Use \n to separate

Returns:

  • (nil)

#start_timeGst::ClockTime

Returns the start time of the element. The start time is the running time of the clock when this element was last put to PAUSED.

Usually the start_time is managed by a toplevel element such as Gst::Pipeline.

MT safe.

Returns:

  • (Gst::ClockTime)

    the start time of the element.

#start_time=(time) ⇒ nil

Set the start time of an element. The start time of the element is the running time of the element when it last went to the PAUSED state. In READY or after a flushing seek, it is set to 0.

Toplevel elements like Gst::Pipeline will manage the start_time and base_time on its children. Setting the start_time to #GST_CLOCK_TIME_NONE on such a toplevel element will disable the distribution of the base_time to the children and can be useful if the application manages the base_time itself, for example if you want to synchronize capture from multiple pipelines, and you can also ensure that the pipelines have the same clock.

MT safe.

Parameters:

  • time (Gst::ClockTime)

    the base time to set.

Returns:

  • (nil)

#state=(state) ⇒ Gst::StateChangeReturn

Sets the state of the element. This function will try to set the requested state by going through all the intermediary states and calling the class's state change function for each.

This function can return #GST_STATE_CHANGE_ASYNC, in which case the element will perform the remainder of the state change asynchronously in another thread. An application can use gst_element_get_state() to wait for the completion of the state change or it can wait for a %GST_MESSAGE_ASYNC_DONE or %GST_MESSAGE_STATE_CHANGED on the bus.

State changes to %GST_STATE_READY or %GST_STATE_NULL never return #GST_STATE_CHANGE_ASYNC. MT safe.

Parameters:

  • state (Gst::State)

    the element's new Gst::State.

Returns:

#stopObject



25
26
27
# File 'lib/gst/element.rb', line 25

def stop
  set_state(State::NULL)
end

#sync_state_with_parentBoolean

Tries to change the state of the element to the same as its parent. If this function returns false, the state of element is undefined. MT safe.

Returns:

  • (Boolean)

    true, if the element's state could be synced to the parent's state.

Unlinks all source pads of the source element with all sink pads of the sink element to which they are linked.

If the link has been made using gst_element_link(), it could have created an requestpad, which has to be released using gst_element_release_request_pad().

Parameters:

Returns:

  • (nil)

Unlinks a series of elements. Uses gst_element_unlink().

Parameters:

  • element_2 (Gst::Element)

    the second Gst::Element in the link chain.

  • array (Array)

    the nil-terminated list of elements to unlink in order.

Returns:

  • (nil)

Unlinks the two named pads of the source and destination elements.

This is a convenience function for gst_pad_unlink().

Parameters:

  • srcpadname (String)

    the name of the Gst::Pad in source element.

  • dest (Gst::Element)

    a Gst::Element containing the destination pad.

  • destpadname (String)

    the name of the Gst::Pad in destination element.

Returns:

  • (nil)