Class: Gst::Bin

Inherits:
Element show all
Includes:
Enumerable
Defined in:
lib/gst/bin.rb

Overview

Subclasses can override Gst::BinClass::add_element and #GstBinClass::remove_element to update the list of children in the bin.

The Gst::BinClass::handle_message method can be overridden to implement custom message handling.

Gst::BinClass::deep_element_added will be called when a new element has been added to any bin inside this bin, so it will also be called if a new child was added to a sub-bin of this bin. Gst::Bin implementations that override this message should chain up to the parent class implementation so the Gst::Bin::deep-element-added signal is emitted on all parents.

Direct Known Subclasses

Pipeline

Instance Method Summary collapse

Methods inherited from Element

#>>, [], #abort_state, #add_metadata, #add_pad, #add_pad_template, #add_property_deep_notify_watch, #add_property_notify_watch, #add_static_metadata, #add_static_pad_template, #add_static_pad_template_with_gtype, #base_time, #base_time=, #bus, #bus=, #call_async, #change_state, #clock, #clock=, #context=, #contexts, #continue_state, #create_all_pads, #current_clock_time, #current_running_time, #decorate_stream_id, #decorate_stream_id_printf, #decorate_stream_id_printf_valist, #factory, #flags, #flags_raw, #foreach_pad, #foreach_sink_pad, #foreach_src_pad, #get_compatible_pad, #get_compatible_pad_template, #get_context, #get_context_unlocked, #get_metadata, #get_pad_template, #get_request_pad, #get_state, #get_static_pad, #is_locked_state, #iterate_pads, #iterate_sink_pads, #iterate_src_pads, #link_elements, #link_filtered, #link_many, #link_pads, #link_pads_filtered, #link_pads_full, #locked_state=, #lost_state, make_from_uri, #message_full, #message_full_with_details, #no_more_pads, #pad_template_list, #pause, #play, #post_message, #provide_clock, #query, #query_convert, #query_duration, #query_position, #ready, register, #release_request_pad, #remove_pad, #remove_property_notify_watch, #request_pad, #request_pad_simple, #seek, #seek_simple, #send_event, #set_metadata, #set_static_metadata, #start_time, #start_time=, #state=, state_change_return_get_name, state_get_name, #stop, #sync_state_with_parent, type_set_skip_documentation, #unlink, #unlink_many, #unlink_pads

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

Constructor Details

#initialize(name) ⇒ Gst::Element

Creates a new bin with the given name.

Parameters:

  • name (String)

    the name of the new bin

Instance Method Details

#<<(element) ⇒ Object



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

def <<(element)
  add_element(element)
  self
end

#add_elements(*elements) ⇒ Object Also known as: add



22
23
24
25
26
# File 'lib/gst/bin.rb', line 22

def add_elements(*elements)
  elements.each do |element|
    add_element(element)
  end
end

#add_many(element_1, array) ⇒ nil

Adds a nil-terminated list of elements to a bin. This function is equivalent to calling gst_bin_add() for each member of the list. The return value of each gst_bin_add() is ignored.

Parameters:

  • element_1 (Gst::Element)

    the Gst::Element element to add to the bin

  • array (Array)

    additional elements to add to the bin

Returns:

  • (nil)

#async_handling=(async_handling) ⇒ Boolean

If set to true, the bin will handle asynchronous state changes. This should be used only if the bin subclass is modifying the state of its children on its own.

Parameters:

  • async_handling (Boolean)

Returns:

  • (Boolean)

    async-handling

  • (Boolean)

    async-handling

#async_handling?Boolean

If set to true, the bin will handle asynchronous state changes. This should be used only if the bin subclass is modifying the state of its children on its own.

Returns:

  • (Boolean)

    async-handling

#each(options = {}) ⇒ Object



34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
# File 'lib/gst/bin.rb', line 34

def each(options={})
  return to_enum(:each, options) unless block_given?

  if options[:recurse]
    iterator = iterate_recurse
  elsif options[:sink]
    iterator = iterate_sinks
  elsif options[:sorted]
    iterator = iterate_sorted
  elsif options[:sources]
    iterator = iterate_sources
  elsif options[:interface]
    iterator = iterate_all_by_interface(options[:interface])
  else
    iterator = iterate_elements
  end

  loop do
    result, element = iterator.next
    case result
    when IteratorResult::DONE
      break
    when IteratorResult::OK
      yield(element.value)
    when IteratorResult::RESYNC
      iterator.resync
    when IteratorResult::ERROR
      raise "failed to iterate"
    end
  end
end

#find_unlinked_pad(direction) ⇒ Gst::Pad

Recursively looks for elements with an unlinked pad of the given direction within the specified bin and returns an unlinked pad if one is found, or nil otherwise. If a pad is found, the caller owns a reference to it and should use gst_object_unref() on the pad when it is not needed any longer. direction.

Parameters:

  • direction (Gst::PadDirection)

    whether to look for an unlinked source or sink pad

Returns:

  • (Gst::Pad)

    unlinked pad of the given

#get_by_interface(iface) ⇒ Gst::Element

Looks for an element inside the bin that implements the given interface. If such an element is found, it returns the element. You can cast this element to the given interface afterwards. If you want all elements that implement the interface, use gst_bin_iterate_all_by_interface(). This function recurses into child bins. implementing the interface

Parameters:

  • iface (GLib::Type)

    the #GType of an interface

Returns:

#get_by_name(name) ⇒ Gst::Element

Gets the element with the given name from a bin. This function recurses into child bins. name

Parameters:

  • name (String)

    the element name to search for

Returns:

#get_by_name_recurse_up(name) ⇒ Gst::Element

Gets the element with the given name from this bin. If the element is not found, a recursion is performed on the parent bin. name

Parameters:

  • name (String)

    the element name to search for

Returns:

#iterate_all_by_element_factory_name(factory_name) ⇒ Gst::Iterator

Looks for all elements inside the bin with the given element factory name. The function recurses inside child bins. The iterator will yield a series of Gst::Element.

Parameters:

  • factory_name (String)

    the name of the Gst::ElementFactory

Returns:

  • (Gst::Iterator)

    a Gst::Iterator of #GstElement for all elements in the bin with the given element factory name

#iterate_all_by_interface(iface) ⇒ Gst::Iterator

Looks for all elements inside the bin that implements the given interface. You can safely cast all returned elements to the given interface. The function recurses inside child bins. The iterator will yield a series of Gst::Element.

Parameters:

  • iface (GLib::Type)

    the #GType of an interface

Returns:

  • (Gst::Iterator)

    a Gst::Iterator of #GstElement for all elements in the bin implementing the given interface

#iterate_elementsGst::Iterator

Gets an iterator for the elements in this bin.

Returns:

  • (Gst::Iterator)

    a Gst::Iterator of #GstElement

#iterate_recurseGst::Iterator

Gets an iterator for the elements in this bin. This iterator recurses into GstBin children.

Returns:

  • (Gst::Iterator)

    a Gst::Iterator of #GstElement

#iterate_sinksGst::Iterator

Gets an iterator for all elements in the bin that have the #GST_ELEMENT_FLAG_SINK flag set.

Returns:

  • (Gst::Iterator)

    a Gst::Iterator of #GstElement

#iterate_sortedGst::Iterator

Gets an iterator for the elements in this bin in topologically sorted order. This means that the elements are returned from the most downstream elements (sinks) to the sources.

This function is used internally to perform the state changes of the bin elements and for clock selection.

Returns:

  • (Gst::Iterator)

    a Gst::Iterator of #GstElement

#iterate_sourcesGst::Iterator

Gets an iterator for all elements in the bin that have the #GST_ELEMENT_FLAG_SOURCE flag set.

Returns:

  • (Gst::Iterator)

    a Gst::Iterator of #GstElement

#message_forward=(message_forward) ⇒ Boolean

Forward all children messages, even those that would normally be filtered by the bin. This can be interesting when one wants to be notified of the EOS state of individual elements, for example.

The messages are converted to an ELEMENT message with the bin as the source. The structure of the message is named GstBinForwarded and contains a field named message that contains the original forwarded Gst::Message.

Parameters:

  • message_forward (Boolean)

Returns:

  • (Boolean)

    message-forward

  • (Boolean)

    message-forward

#message_forward?Boolean

Forward all children messages, even those that would normally be filtered by the bin. This can be interesting when one wants to be notified of the EOS state of individual elements, for example.

The messages are converted to an ELEMENT message with the bin as the source. The structure of the message is named GstBinForwarded and contains a field named message that contains the original forwarded Gst::Message.

Returns:

  • (Boolean)

    message-forward

#recalculate_latencyBoolean

Queries bin for the current latency and reconfigures this latency on all the elements using a LATENCY event.

This method is typically called on the pipeline when a #GST_MESSAGE_LATENCY is posted on the bus.

This function simply emits the Gst::Bin::do-latency signal so any custom latency calculations will be performed.

Returns:

  • (Boolean)

    true if the latency could be queried and reconfigured.

#remove(element) ⇒ Boolean

Removes the element from the bin, unparenting it as well. Unparenting the element means that the element will be dereferenced, so if the bin holds the only reference to the element, the element will be freed in the process of removing it from the bin. If you want the element to still exist after removing, you need to call gst_object_ref() before removing it from the bin.

If the element's pads are linked to other pads, the pads will be unlinked before the element is removed from the bin. the bin does not want to remove the element.

Parameters:

Returns:

  • (Boolean)

    true if the element could be removed, false if

#remove_many(element_1, array) ⇒ nil

Removes a list of elements from a bin. This function is equivalent to calling gst_bin_remove() with each member of the list.

Parameters:

  • element_1 (Gst::Element)

    the first Gst::Element to remove from the bin

  • array (Array)

    nil-terminated list of elements to remove from the bin

Returns:

  • (nil)

#suppressed_flagsGst::ElementFlags

Returns the bin's suppressed Gst::ElementFlags.

Returns:

#suppressed_flags=(flags) ⇒ nil

Suppresses the given flags on the bin. Gst::ElementFlags of a child element are propagated when it is added to the bin. When suppressed flags are set, those specified flags will not be propagated to the bin.

Parameters:

Returns:

  • (nil)

#sync_children_statesBoolean

Synchronizes the state of every child of bin with the state of bin. See also gst_element_sync_state_with_parent().

Returns:

  • (Boolean)

    true if syncing the state was successful for all children, otherwise false.