Gst::BaseSrc Class Reference
gstreamermm Base Classes

A base class for getrange based source elements. More...

`#include <gstreamermm/basesrc.h>`

Inheritance diagram for Gst::BaseSrc:
[legend]

## Public Member Functions

| BaseSrc (BaseSrc&& src) noexcept
BaseSrc& | operator= (BaseSrc&& src) noexcept
| ~BaseSrc () noexcept override
GstBaseSrc* | gobj ()
| Provides access to the underlying C GObject. More...
const GstBaseSrc* | gobj () const
| Provides access to the underlying C GObject. More...
GstBaseSrc* | gobj_copy ()
| Provides access to the underlying C instance. The caller is responsible for unrefing it. Use when directly setting fields in structs. More...
FlowReturn | wait_playing ()
| If the Gst::BaseSrcClass.create() method performs its own synchronisation against the clock it must unblock when going from PLAYING to the PAUSED state and call this method before continuing to produce the remaining data. More...
bool | is_live () const
| Check if an element is in live mode. More...
void | set_live (bool live)
| If the element listens to a live source, live should be set to `true`. More...
void | set_format (Format format)
| Sets the default format of the source. More...
bool | query_latency (bool& live, Gst::ClockTime& min_latency, Gst::ClockTime& max_latency) const
| Query the source for the latency parameters. More...
guint | get_blocksize () const
| Get the number of bytes that src will push out with each buffer. More...
void | set_blocksize (guint blocksize)
| Set the number of bytes that src will push out with each buffer. More...
bool | get_do_timestamp () const
| Query if src timestamps outgoing buffers based on the current running_time. More...
void | set_do_timestamp (bool timestamp)
| Configure src to automatically timestamp outgoing buffers based on the current running_time of the pipeline. More...
bool | new_seamless_segment (gint64 start, gint64 stop, gint64 position)
| Prepare a new seamless segment for emission downstream. More...
bool | set_caps (const Glib::RefPtr< Gst::Caps >& caps)
| Set new caps on the basesrc source pad. More...
Gst::FlowReturn | start_wait ()
| Wait until the start operation completes. More...
void | set_dynamic_size (bool dynamic_size)
| If not dynamic_size, size is only updated when needed, such as when trying to read past current tracked size. More...
void | set_async (bool async)
| Configure async behaviour in src, no state change will block. More...
bool | is_async () const
| Get the current async behaviour of src. More...
void | start_complete (Gst::FlowReturn ret)
| Complete an asynchronous start operation. More...
void | set_automatic_eos (bool automatic_eos)
| If automatic_eos is `true`, src will automatically go EOS if a buffer after the total size is returned. More...
Glib::RefPtr< Gst::Allocator > | get_allocator (Gst::AllocationParams& params)
| Returns the memory allocator used by the base class and its params. More...
Glib::RefPtr< Gst::Pad > | get_src_pad ()
| Gets the source Gst::Pad object of the element. More...
Glib::RefPtr< const Gst::Pad > | get_src_pad () const
Glib::PropertyProxy< gulong > | property_blocksize ()
| Size in bytes to read per buffer (-1 = default). More...
Glib::PropertyProxy_ReadOnly< gulong > | property_blocksize () const
| Size in bytes to read per buffer (-1 = default). More...
Glib::PropertyProxy< bool > | property_do_timestamp ()
| Apply current stream time to buffers. More...
Glib::PropertyProxy_ReadOnly< bool > | property_do_timestamp () const
| Apply current stream time to buffers. More...
Glib::PropertyProxy< int > | property_num_buffers ()
| Number of buffers to output before sending EOS (-1 = unlimited). More...
Glib::PropertyProxy_ReadOnly< int > | property_num_buffers () const
| Number of buffers to output before sending EOS (-1 = unlimited). More...
Glib::PropertyProxy< bool > | property_typefind ()
| Run typefind before negotiating. More...
Glib::PropertyProxy_ReadOnly< bool > | property_typefind () const
| Run typefind before negotiating. More...
virtual Glib::RefPtr< Gst::Caps > | get_caps_vfunc (const Glib::RefPtr< Gst::Caps >& caps) const
| Called to get the caps to report. More...
virtual bool | set_caps_vfunc (const Glib::RefPtr< Gst::Caps >& caps)
| Notify subclass of changed output caps. More...
virtual bool | negotiate_vfunc ()
| Negotiated the caps with the peer. More...
virtual bool | stop_vfunc ()
| Stop processing. More...
virtual bool | start_vfunc ()
| Start processing. More...
virtual void | get_times_vfunc (const Glib::RefPtr< Gst::Buffer >& buffer, Gst::ClockTime&start, Gst::ClockTime&end) const
| Given a buffer, return the start and stop time when it should be pushed out. More...
virtual bool | get_size_vfunc (guint64&size) const
| Return the total size of the resource, in the configured format. More...
virtual bool | is_seekable_vfunc () const
| Check if the source can seek. More...
virtual bool | unlock_vfunc ()
| Unlock any pending access to the resource. More...
virtual bool | event_vfunc (const Glib::RefPtr< Gst::Event >& event)
| Override this to implement custom event handling. More...
virtual FlowReturn | create_vfunc (guint64 offset, guint size, Glib::RefPtr< Gst::Buffer >& buffer)
virtual bool | do_seek_vfunc (Gst::Segment& segment)
| Perform seeking on the resource to the indicated segment. More...
virtual bool | base_src_query_vfunc (const Glib::RefPtr< Gst::Query >&query)
| Handle a requested query. More...
virtual Glib::RefPtr< Gst::Caps > | fixate_vfunc (const Glib::RefPtr< Gst::Caps >& caps)
| Called during negotiation if caps need fixating. More...
virtual bool | unlock_stop_vfunc ()
| Clear the previous unlock request. More...
virtual bool | prepare_seek_segment_vfunc (const Glib::RefPtr< Gst::Event >&seek, Gst::Segment& segment)
| Prepare the Gst::Segment that will be passed to the do_seek_vfunc() vmethod for executing a seek request. More...
virtual bool | decide_allocation_vfunc (const Glib::RefPtr< Gst::Query >&query)
| Configure the allocation query. More...
Gst::FlowReturn | alloc_vfunc (guint64 offset, guint size, Glib::RefPtr< Gst::Buffer >& buffer)
| Ask the subclass to allocate a buffer with for offset and size. More...
virtual Gst::FlowReturn | fill_vfunc (guint64 offset, guint size, const Glib::RefPtr< Gst::Buffer >& buffer)
| Ask the subclass to fill the buffer with data for offset and size. More...
Public Member Functions inherited from Gst::Element
| Element (Element&& src) noexcept
Element& | operator= (Element&& src) noexcept
| ~Element () noexcept override
GstElement* | gobj ()
| Provides access to the underlying C GObject. More...
const GstElement* | gobj () const
| Provides access to the underlying C GObject. More...
GstElement* | gobj_copy ()
| Provides access to the underlying C instance. The caller is responsible for unrefing it. Use when directly setting fields in structs. More...
Glib::RefPtr< Gst::Element > | link (const Glib::RefPtr< Gst::Element >& dest)
| Links this source element to the dest element. More...
bool | add_pad (const Glib::RefPtr< Gst::Pad >& pad)
| Adds a pad (link point) to element. More...
void | create_all_pads ()
| Creates a pad for each pad template that is always available. More...
Glib::RefPtr< Gst::Pad > | create_compatible_pad (const Glib::RefPtr< const Gst::Pad >& pad, const Glib::RefPtr< const Gst::Caps >& caps)
| Looks for an unlinked pad to which the given pad can link. More...
Glib::RefPtr< Gst::PadTemplate > | get_compatible_pad_template (const Glib::RefPtr< const Gst::PadTemplate >& compattempl)
| Retrieves a pad template from element that is compatible with compattempl. More...
Glib::RefPtr< const Gst::PadTemplate > | get_compatible_pad_template (const Glib::RefPtr< const Gst::PadTemplate >& compattempl) const
| Retrieves a pad template from element that is compatible with compattempl. More...
Glib::RefPtr< Gst::Pad > | get_request_pad (const Glib::ustring& name)
| Retrieves a pad from the element by name (e.g. "src_\\%d"). More...
Glib::RefPtr< Gst::Pad > | request_pad (const Glib::RefPtr< Gst::PadTemplate >& templ, const Glib::ustring& name, const Glib::RefPtr< const Gst::Caps >& caps)
| Retrieves a request pad from the element according to the provided template. More...
Glib::RefPtr< Gst::Pad > | request_pad (const Glib::RefPtr< Gst::PadTemplate >& templ, const Glib::ustring& name)
| A request_pad() convenience overload. More...
Glib::RefPtr< Gst::Pad > | request_pad (const Glib::RefPtr< Gst::PadTemplate >& templ, const Glib::RefPtr< const Gst::Caps >& caps)
| A request_pad() convenience overload. More...
Glib::RefPtr< Gst::Pad > | request_pad (const Glib::RefPtr< Gst::PadTemplate >& templ)
| A request_pad() convenience overload. More...
Glib::RefPtr< Gst::Pad > | get_static_pad (const Glib::ustring& name)
| Retrieves a pad from element by name. More...
Glib::RefPtr< const Gst::Pad > | get_static_pad (const Glib::ustring& name) const
| Retrieves a pad from element by name. More...
void | no_more_pads ()
| Use this function to signal that the element does not expect any more pads to show up in the current pipeline. More...
void | release_request_pad (const Glib::RefPtr< Gst::Pad >& pad)
| Makes the element free the previously requested pad as obtained with get_request_pad(). More...
bool | remove_pad (const Glib::RefPtr< Gst::Pad >& pad)
| Removes pad from element. More...
Gst::Iterator< Gst::Pad > | iterate_pads ()
| Retrieves an iterator of element's pads. More...
Gst::Iterator< const Gst::Pad > | iterate_pads () const
| Retrieves an iterator of element's pads. More...
Gst::Iterator< Gst::Pad > | iterate_sink_pads ()
| Retrieves an iterator of element's sink pads. More...
Gst::Iterator< const Gst::Pad > | iterate_sink_pads () const
| Retrieves an iterator of element's sink pads. More...
Gst::Iterator< Gst::Pad > | iterate_src_pads ()
| Retrieves an iterator of element's source pads. More...
Gst::Iterator< const Gst::Pad > | iterate_src_pads () const
| Retrieves an iterator of element's source pads. More...
void | unlink (const Glib::RefPtr< Gst::Element >& dest)
| Unlinks all source pads of the source element with all sink pads of the sink element to which they are linked. More...
void | set_context (const Glib::RefPtr< Gst::Context >& context)
| Sets the context of the element. More...
bool | link_pads (const Glib::ustring& srcpadname, const Glib::RefPtr< Gst::Element >& dest, const Glib::ustring& destpadname)
| Links the two named pads of the source and destination elements. More...
void | unlink_pads (const Glib::ustring& srcpadname, const Glib::RefPtr< Gst::Element >& dest, const Glib::ustring& destpadname)
| Unlinks the two named pads of the source and destination elements. More...
bool | link_pads (const Glib::ustring& srcpadname, const Glib::RefPtr< Gst::Element >& dest, const Glib::ustring& destpadname, const Glib::RefPtr< Gst::Caps >& filter)
| Links the two named pads of the source and destination elements. More...
bool | link_pads (const Glib::ustring& srcpadname, const Glib::RefPtr< Gst::Element >& dest, const Glib::ustring& destpadname, PadLinkCheck flags)
| Links the two named pads of the source and destination elements. More...
Glib::RefPtr< Gst::Element > | link (const Glib::RefPtr< Gst::Element >& dest, const Glib::RefPtr< Gst::Caps >& filter)
| Links src to dest using the given caps as filtercaps. More...
void | set_base_time (ClockTime time)
| Set the base time of an element. More...
ClockTime | get_base_time () const
| Returns the base time of the element. More...
void | set_start_time (Gst::ClockTime time)
| Set the start time of an element. More...
Gst::ClockTime | get_start_time () const
| Returns the start time of the element. More...
void | set_bus (const Glib::RefPtr< Gst::Bus >& bus)
| Sets the bus of the element. More...
Glib::RefPtr< Gst::Bus > | get_bus ()
| Returns the bus of the element. More...
Glib::RefPtr< const Gst::Bus > | get_bus () const
| Returns the bus of the element. More...
Glib::RefPtr< Gst::ElementFactory > | get_factory ()
| Retrieves the factory that was used to create this element. More...
Glib::RefPtr< const Gst::ElementFactory > | get_factory () const
| Retrieves the factory that was used to create this element. More...
bool | set_clock (const Glib::RefPtr< Gst::Clock >& clock)
| Sets the clock for the element. More...
Glib::RefPtr< Gst::Clock > | get_clock ()
| Gets the currently configured clock of the element. More...
Glib::RefPtr< const Gst::Clock > | get_clock () const
| Gets the currently configured clock of the element. More...
Glib::RefPtr< Gst::Clock > | provide_clock ()
| Get the clock provided by the given element. More...
Glib::RefPtr< const Gst::Clock > | provide_clock () const
| Get the clock provided by the given element. More...
StateChangeReturn | set_state (State state)
| Sets the state of the element. More...
StateChangeReturn | get_state (State& state, State& pending, ClockTime timeout) const
| Gets the state of the element. More...
bool | set_locked_state (gboolean locked_state)
| Locks the state of an element, so state changes of the parent don't affect this element anymore. More...
bool | is_locked_state () const
| Checks if the state of an element is locked. More...
void | abort_state ()
| Abort the state change of the element. More...
StateChangeReturn | continue_state (StateChangeReturn ret)
| Commit the state change of the element and proceed to the next pending state if any. More...
void | lost_state ()
| Brings the element to the lost state. More...
bool | sync_state_with_parent ()
| Tries to change the state of the element to the same as its parent. More...
StateChangeReturn | change_state (StateChange transition)
| Perform transition on element. More...
void | post_message (int code, int line, MessageType type=Gst::MESSAGE_INFO, const Glib::QueryQuark& domain=get_core_error_quark(), const Glib::ustring& text=Glib::ustring(), const Glib::ustring& debug=Glib::ustring(), const Glib::ustring& file=Glib::ustring(), const Glib::ustring& function=Glib::ustring())
| Post an error, warning or info message on the bus from inside an element. More...
bool | post_message (Glib::RefPtr< Gst::Message >&& message)
| Post a message on the element's Gst::Bus. More...
bool | query (const Glib::RefPtr< Gst::Query >& query) const
| Performs a query on the given element. More...
bool | query_convert (Gst::Format src_format, gint64 src_val, Format dest_format, gint64& dest_val) const
| Queries an element to convert src_val in src_format to dest_format. More...
bool | query_position (Gst::Format format, gint64& cur) const
| Queries an element (usually top-level pipeline or playbin element) for the stream position in nanoseconds. More...
bool | query_position (Gst::Format format) const
| A query_position() convenience overload. More...
bool | query_duration (Gst::Format format, gint64& duration) const
| Queries an element (usually top-level pipeline or playbin element) for the total stream duration in nanoseconds. More...
bool | query_duration (Gst::Format format) const
| A query_duration() convenience overload. More...
bool | seek (Format format, SeekFlags seek_flags, gint64 seek_pos)
| 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. More...
bool | seek (double rate, Format format, SeekFlags flags, SeekType cur_type, gint64 cur, SeekType stop_type, gint64 stop)
| Sends a seek event to an element. More...
bool | send_event (Glib::RefPtr< Gst::Event >&& event)
| Sends an event to an element. More...
bool | send_event (const Glib::RefPtr< Gst::Event >& event)
| A send_event() convenience overload. Allows to re-use event parameter after function call. More...
Glib::RefPtr< Gst::Context > | get_context (const Glib::ustring& context_type)
| Gets the context with context_type set on the element or `nullptr`. More...
Glib::RefPtr< Gst::Context > | get_context_unlocked (const Glib::ustring& context_type)
| Gets the context with context_type set on the element or `nullptr`. More...
std::vector< Glib::RefPtr< Gst::Context > > | get_contexts ()
| Gets the contexts set on the element. More...
Glib::SignalProxy< void > | signal_no_more_pads ()
Glib::SignalProxy< void, const Glib::RefPtr< Gst::Pad >&> | signal_pad_added ()
Glib::SignalProxy< void, const Glib::RefPtr< Gst::Pad >&> | signal_pad_removed ()
virtual void | release_pad_vfunc (const Glib::RefPtr< Gst::Pad >& pad)
| Called when a request pad is to be released. More...
virtual Glib::RefPtr< Gst::Pad > | request_new_pad_vfunc (Glib::RefPtr< Gst::PadTemplate > templ, const Glib::ustring& name, const Glib::RefPtr< const Gst::Caps >& caps)
| Called when a new pad is requested. More...
virtual StateChangeReturn | get_state_vfunc (State& state, State& pending, ClockTime timeout) const
| Get the state of the element. More...
virtual StateChangeReturn | set_state_vfunc (State state)
| Set a new state on the element. More...
virtual StateChangeReturn | change_state_vfunc (StateChange transition)
| Called by set_state to perform an incremental state change. More...
virtual void | state_changed_vfunc (Gst::State oldstate, Gst::State newstate, Gst::State pending)
| Called immediately after a new state was set. More...
virtual void | set_bus_vfunc (const Glib::RefPtr< Gst::Bus >& bus)
| Set a Gst::Bus on the element. More...
virtual Glib::RefPtr< Gst::Clock > | provide_clock_vfunc ()
| Gets the Gst::Clock provided by the element. More...
virtual bool | set_clock_vfunc (const Glib::RefPtr< Gst::Clock >& clock)
| Set the Gst::Clock on the element. More...
virtual bool | send_event_vfunc (const Glib::RefPtr< Gst::Event >& event)
| Send a Gst::Event to the element. More...
virtual bool | query_vfunc (const Glib::RefPtr< Gst::Query >&query) const
| Perform a Gst::Query on the element. More...
virtual void | set_context_vfunc (const Glib::RefPtr< Gst::Context >& context)
| Set a Gst::Context on the element. More...
virtual bool | post_message_vfunc (const Glib::RefPtr< Gst::Message >& message)
| Called when a message is posted on the element. More...
Glib::RefPtr< Gst::PadTemplate > | get_pad_template (const Glib::ustring& factory_name) const
template<typename T >
Glib::RefPtr< Gst::Element > | property (const Glib::ustring& name, const T& value)
| Sets specified property. More...
Public Member Functions inherited from Gst::Object
| Object (Object&& src) noexcept
Object& | operator= (Object&& src) noexcept
| ~Object () noexcept override
GstObject* | gobj ()
| Provides access to the underlying C GObject. More...
const GstObject* | gobj () const
| Provides access to the underlying C GObject. More...
GstObject* | gobj_copy ()
| Provides access to the underlying C instance. The caller is responsible for unrefing it. Use when directly setting fields in structs. More...
bool | is_element () const
bool | is_element_factory () const
bool | is_pad () const
bool | is_pad_template () const
bool | is_bin () const
guint32 | get_flags () const
| Returns the entire set of flags for the object. More...
bool | set_name (const Glib::ustring& name)
| Sets the name of object, or gives object a guaranteed unique name (if name is `nullptr`). More...
Glib::ustring | get_name () const
| Returns a copy of the name of object. More...
bool | set_parent (const Glib::RefPtr< Gst::Object >& parent)
| Sets the parent of object to parent. More...
Glib::RefPtr< Gst::Object > | get_parent ()
| Returns the parent of object. More...
Glib::RefPtr< const Gst::Object > | get_parent () const
| Returns the parent of object. More...
void | unparent ()
| Clear the parent of object, removing the associated reference. More...
void | set_control_rate (Gst::ClockTime control_rate)
| Change the control-rate for this object. More...
Gst::ClockTime | get_control_rate () const
| Obtain the control-rate for this object. More...
Gst::ClockTime | suggest_next_sync () const
| Returns a suggestion for timestamps where buffers should be split to get best controller results. More...
bool | sync_values (Gst::ClockTime timestamp)
| Sets the properties of the object, according to the Gst::ControlSources that (maybe) handle them and for the given timestamp. More...
void | set_control_bindings_disabled (bool disabled)
| This function is used to disable all controlled properties of the object for some time, i.e. sync_values() will do nothing. More...
bool | has_asctive_control_bindings () const
| Check if the object has an active controlled properties. More...
bool | has_ancestor (const Glib::RefPtr< const Gst::Object >& ancestor) const
| Check if object has an ancestor ancestor somewhere up in the hierarchy. More...
bool | has_as_ancestor (const Glib::RefPtr< Gst::Object >& ancestor) const
| Check if object has an ancestor ancestor somewhere up in the hierarchy. More...
bool | has_as_parent (const Glib::RefPtr< Gst::Object >& parent) const
| Check if parent is the parent of object. More...
Glib::ustring | get_path_string ()
| Generates a string describing the path of object in the object hierarchy. More...
Glib::PropertyProxy< Glib::ustring > | property_name ()
| The name of the object. More...
Glib::PropertyProxy_ReadOnly< Glib::ustring > | property_name () const
| The name of the object. More...
Glib::PropertyProxy< Glib::RefPtr< Gst::Object > > | property_parent ()
| The parent of the object. More...
Glib::PropertyProxy_ReadOnly< Glib::RefPtr< Gst::Object > > | property_parent () const
| The parent of the object. More...
Glib::SignalProxy< void, const Glib::RefPtr< Gst::Object >&, GParamSpec*> | signal_deep_notify ()
int | get_refcount () const

## Static Public Member Functions

static GType | get_type ()
| Get the GType for this class, for use with the underlying GObject type system. More...
Static Public Member Functions inherited from Gst::Element
static GType | get_type ()
| Get the GType for this class, for use with the underlying GObject type system. More...
Static Public Member Functions inherited from Gst::Object
static GType | get_type ()
| Get the GType for this class, for use with the underlying GObject type system. More...
static bool | check_uniqueness (const Glib::ListHandle< const Gst::Object >& list, const Glib::ustring& name)
| Checks to see if there is any object named name in list. More...

## Related Functions

(Note that these are not member functions.)
Glib::RefPtr< Gst::BaseSrc > | wrap (GstBaseSrc* object, bool take_copy=false)
| A Glib::wrap() method for this object. More...
Related Functions inherited from Gst::Element
Glib::RefPtr< Gst::Element > | wrap (GstElement* object, bool take_copy=false)
| A Glib::wrap() method for this object. More...
Related Functions inherited from Gst::Object
Glib::RefPtr< Gst::Object > | wrap (GstObject* object, bool take_copy=false)
| A Glib::wrap() method for this object. More...

## Additional Inherited Members

Protected Member Functions inherited from Gst::Element
virtual void | on_no_more_pads ()
| This is a default handler for the signal signal_no_more_pads(). More...
virtual void | on_pad_added (const Glib::RefPtr< Gst::Pad >& new_pad)
| This is a default handler for the signal signal_pad_added(). More...
virtual void | on_pad_removed (const Glib::RefPtr< Gst::Pad >& old_pad)
| This is a default handler for the signal signal_pad_removed(). More...
Protected Member Functions inherited from Gst::Object
virtual void | on_deep_notify (const Glib::RefPtr< Gst::Object >& prop_object, GParamSpec* prop)
| This is a default handler for the signal signal_deep_notify(). More...

## Detailed Description

A base class for getrange based source elements.

This is a generice base class for source elements. The following types of sources are supported:

- random access sources like files,
- seekable sources,
- live sources.

The source can be configured to operate in any Gst::Format with the set_format() method. The currently set format determines the format of the internal Gst::Segment and any Gst::EVENT_NEWSEGMENT events. The default format for Gst::BaseSrc is Gst::FORMAT_BYTES.

Gst::BaseSrc always supports push mode scheduling. If the following conditions are met, it also supports pull mode scheduling:

- The format is set to Gst::FORMAT_BYTES (default).
- Gst::BaseSrc::is_seekable_vfunc() returns TRUE.

Since GStreamer 0.10.9, any Gst::BaseSrc can enable pull based scheduling at any time by overriding Gst::BaseSrc::check_get_range_vfunc() so that it returns TRUE.

If all the conditions are met for operating in pull mode, Gst::BaseSrc is automatically seekable in push mode as well. The following conditions must be met to make the element seekable in push mode when the format is not Gst::FORMAT_BYTES:

- Gst::BaseSrc::is_seekable_vfunc() returns TRUE.
- Gst::BaseSrc::query_vfunc() can convert all supported seek formats to the internal format as set with set_format().
- Gst::BaseSrc::do_seek_vfunc() is implemented, performs the seek and returns TRUE.

When the element does not meet the requirements to operate in pull mode, the offset and length in the Gst::BaseSrc::create_vfunc() method should be ignored. It is recommended to subclass Gst::PushSrc instead, in this situation. If the element can operate in pull mode but only with specific offsets and lengths, it is allowed to generate an error when the wrong values are passed to the Gst::BaseSrc::create_vfunc() function.

Gst::BaseSrc has support for live sources. Live sources are sources that when paused discard data, such as audio or video capture devices. A typical live source also produces data at a fixed rate and thus provides a clock to publish this rate. Use set_live() to activate the live source mode.

A live source does not produce data in the PAUSED state. This means that the Gst::BaseSrc::create_vfunc() method will not be called in PAUSED but only in PLAYING. To signal the pipeline that the element will not produce data, the return value from the READY to PAUSED state will be Gst::STATE_CHANGE_NO_PREROLL.

A typical live source will timestamp the buffers it creates with the current running time of the pipeline. This is one reason why a live source can only produce data in the PLAYING state, when the clock is actually distributed and running.

Live sources that synchronize and block on the clock (an audio source, for example) can since GStreamer 0.10.12 use wait_playing() when the create_vfunc() function was interrupted by a state change to PAUSED.

The Gst::BaseSrc::get_times_vfunc() method can be used to implement pseudo-live sources. It only makes sense to implement the get_times_vfunc() function if the source is a live source. The get_times_vfunc() function should return timestamps starting from 0, as if it were a non-live source. The base class will make sure that the timestamps are transformed into the current running_time. The base source will then wait for the calculated running_time before pushing out the buffer.

For live sources, the base class will by default report a latency of 0. For pseudo live sources, the base class will by default measure the difference between the first buffer timestamp and the start time of get_times_vfunc() and will report this value as the latency. Subclasses should override the query_vfunc() function when this behaviour is not acceptable.

TODO: Edit below paragraph for C++ and include C++ example from C API (if necessary):

There is only support in Gst::BaseSrc for exactly one source pad, which should be named "src". A source implementation (subclass of Gst::BaseSrc) should install a pad template in its class_init function, like so:

// static
void SampleBaseSrc::base_init(Gst::ElementClass<SampleBaseSrc>* klass)
{
klass->add_pad_template(Gst::PadTemplate::create(
"src",
Gst::PAD_SRC,
Gst::PAD_ALWAYS,
Gst::Caps::create_from_string("x-application/x-foo1")
));
klass->set_metadata("Source name", "Source", "My source element", "The author <my.sink@my.email>");
}

## Controlled shutdown of live sources in applications

Applications that record from a live source may want to stop recording in a controlled way, so that the recording is stopped, but the data already in the pipeline is processed to the end (remember that many live sources would go on recording forever otherwise). For that to happen the application needs to make the source stop recording and send an EOS event down the pipeline. The application would then wait for an EOS message posted on the pipeline's bus to know when all data has been processed and the pipeline can safely be stopped.

Since GStreamer 0.10.16 an application may send an EOS event to a source element to make it perform the EOS logic (send EOS event downstream or post a Gst::MESSAGE_SEGMENT_DONE on the bus). This can typically be done with the Gst::Element::send_event() function on the element or its parent bin.

After the EOS has been sent to the element, the application should wait for an EOS message to be posted on the pipeline's bus. Once this EOS message is received, it may safely shut down the entire pipeline.

The old behaviour for controlled shutdown introduced since GStreamer 0.10.3 is still available but deprecated as it is dangerous and less flexible.

Last reviewed on 2016-05-05 (1.8.0).

## Constructor & Destructor Documentation

## BaseSrc()

Gst::BaseSrc::BaseSrc | ( | BaseSrc&& | src | ) |

noexcept

## ~BaseSrc()

Gst::BaseSrc::~BaseSrc | ( |  | ) |

override noexcept

## Member Function Documentation

## alloc_vfunc()

Gst::FlowReturn Gst::BaseSrc::alloc_vfunc | ( | guint64 | offset,
|  | guint | size,
|  | Glib::RefPtr< Gst::Buffer >& | buffer
| ) |  |

Ask the subclass to allocate a buffer with for offset and size.

The default implementation will create a new buffer from the negotiated allocator.

## base_src_query_vfunc()

virtual bool Gst::BaseSrc::base_src_query_vfunc | ( | const Glib::RefPtr< Gst::Query >& | query | ) |

virtual

Handle a requested query.

## create_vfunc()

virtual FlowReturn Gst::BaseSrc::create_vfunc | ( | guint64 | offset,
|  | guint | size,
|  | Glib::RefPtr< Gst::Buffer >& | buffer
| ) |  |

virtual

## decide_allocation_vfunc()

virtual bool Gst::BaseSrc::decide_allocation_vfunc | ( | const Glib::RefPtr< Gst::Query >& | query | ) |

virtual

Configure the allocation query.

## do_seek_vfunc()

virtual bool Gst::BaseSrc::do_seek_vfunc | ( | Gst::Segment& | segment | ) |

virtual

Perform seeking on the resource to the indicated segment.

## event_vfunc()

virtual bool Gst::BaseSrc::event_vfunc | ( | const Glib::RefPtr< Gst::Event >& | event | ) |

virtual

Override this to implement custom event handling.

## fill_vfunc()

virtual Gst::FlowReturn Gst::BaseSrc::fill_vfunc | ( | guint64 | offset,
|  | guint | size,
|  | const Glib::RefPtr< Gst::Buffer >& | buffer
| ) |  |

virtual

Ask the subclass to fill the buffer with data for offset and size.

The passed buffer is guaranteed to hold the requested amount of bytes.

## fixate_vfunc()

virtual Glib::RefPtr<Gst::Caps> Gst::BaseSrc::fixate_vfunc | ( | const Glib::RefPtr< Gst::Caps >& | caps | ) |

virtual

Called during negotiation if caps need fixating.

Implement instead of setting a fixate function on the source pad.

## get_allocator()

Glib::RefPtr<Gst::Allocator> Gst::BaseSrc::get_allocator | ( | Gst::AllocationParams& | params | ) |

Returns the memory allocator used by the base class and its params.

Parameters

  params | The Gst::AllocationParams of allocator.

Returns
  The Gst::Allocator used.

## get_blocksize()

guint Gst::BaseSrc::get_blocksize | ( |  | ) | const

Get the number of bytes that src will push out with each buffer.

Returns
  The number of bytes pushed with each buffer.

## get_caps_vfunc()

virtual Glib::RefPtr<Gst::Caps> Gst::BaseSrc::get_caps_vfunc | ( | const Glib::RefPtr< Gst::Caps >& | caps | ) | const

virtual

Called to get the caps to report.

## get_do_timestamp()

bool Gst::BaseSrc::get_do_timestamp | ( |  | ) | const

Query if src timestamps outgoing buffers based on the current running_time.

Returns
  `true` if the base class will automatically timestamp outgoing buffers.

## get_size_vfunc()

virtual bool Gst::BaseSrc::get_size_vfunc | ( | guint64 & | size | ) | const

virtual

Return the total size of the resource, in the configured format.

## get_src_pad() [1/2]

Glib::RefPtr<Gst::Pad> Gst::BaseSrc::get_src_pad | ( |  | ) |

Gets the source Gst::Pad object of the element.

## get_src_pad() [2/2]

Glib::RefPtr<const Gst::Pad> Gst::BaseSrc::get_src_pad | ( |  | ) | const

## get_times_vfunc()

virtual void Gst::BaseSrc::get_times_vfunc | ( | const Glib::RefPtr< Gst::Buffer >& | buffer,
|  | Gst::ClockTime& | start,
|  | Gst::ClockTime& | end
| ) |  | const

virtual

Given a buffer, return the start and stop time when it should be pushed out.

The base class will sync on the clock using these times.

## get_type()

static GType Gst::BaseSrc::get_type | ( |  | ) |

static

Get the GType for this class, for use with the underlying GObject type system.

## gobj() [1/2]

GstBaseSrc* Gst::BaseSrc::gobj | ( |  | ) |

inline

Provides access to the underlying C GObject.

## gobj() [2/2]

const GstBaseSrc* Gst::BaseSrc::gobj | ( |  | ) | const

inline

Provides access to the underlying C GObject.

## gobj_copy()

GstBaseSrc* Gst::BaseSrc::gobj_copy | ( |  | ) |

Provides access to the underlying C instance. The caller is responsible for unrefing it. Use when directly setting fields in structs.

## is_async()

bool Gst::BaseSrc::is_async | ( |  | ) | const

Get the current async behaviour of src.

See also set_async().

Returns
  `true` if src is operating in async mode.

## is_live()

bool Gst::BaseSrc::is_live | ( |  | ) | const

Check if an element is in live mode.

Returns
  `true` if element is in live mode.

## is_seekable_vfunc()

virtual bool Gst::BaseSrc::is_seekable_vfunc | ( |  | ) | const

virtual

Check if the source can seek.

## negotiate_vfunc()

virtual bool Gst::BaseSrc::negotiate_vfunc | ( |  | ) |

virtual

Negotiated the caps with the peer.

## new_seamless_segment()

bool Gst::BaseSrc::new_seamless_segment | ( | gint64 | start,
|  | gint64 | stop,
|  | gint64 | position
| ) |  |

Prepare a new seamless segment for emission downstream.

This function must only be called by derived sub-classes, and only from the create() function, as the stream-lock needs to be held.

The format for the new segment will be the current format of the source, as configured with set_format()

Parameters

  start | The new start value for the segment.
  stop | Stop value for the new segment.
  position | The new time value for the start of the new segment.

Returns
  `true` if preparation of the seamless segment succeeded.

## operator=()

BaseSrc& Gst::BaseSrc::operator= | ( | BaseSrc&& | src | ) |

noexcept

## prepare_seek_segment_vfunc()

virtual bool Gst::BaseSrc::prepare_seek_segment_vfunc | ( | const Glib::RefPtr< Gst::Event >& | seek,
|  | Gst::Segment& | segment
| ) |  |

virtual

Prepare the Gst::Segment that will be passed to the do_seek_vfunc() vmethod for executing a seek request.

Sub-classes should override this if they support seeking in formats other than the configured native format. By default, it tries to convert the seek arguments to the configured native format and prepare a segment in that format.

## property_blocksize() [1/2]

Glib::PropertyProxy< gulong > Gst::BaseSrc::property_blocksize | ( |  | ) |

Size in bytes to read per buffer (-1 = default).

Returns
  A PropertyProxy that allows you to get or set the value of the property, or receive notification when the value of the property changes.

## property_blocksize() [2/2]

Glib::PropertyProxy_ReadOnly< gulong > Gst::BaseSrc::property_blocksize | ( |  | ) | const

Size in bytes to read per buffer (-1 = default).

Returns
  A PropertyProxy_ReadOnly that allows you to get the value of the property, or receive notification when the value of the property changes.

## property_do_timestamp() [1/2]

Glib::PropertyProxy< bool > Gst::BaseSrc::property_do_timestamp | ( |  | ) |

Apply current stream time to buffers.

Returns
  A PropertyProxy that allows you to get or set the value of the property, or receive notification when the value of the property changes.

## property_do_timestamp() [2/2]

Glib::PropertyProxy_ReadOnly< bool > Gst::BaseSrc::property_do_timestamp | ( |  | ) | const

Apply current stream time to buffers.

Returns
  A PropertyProxy_ReadOnly that allows you to get the value of the property, or receive notification when the value of the property changes.

## property_num_buffers() [1/2]

Glib::PropertyProxy< int > Gst::BaseSrc::property_num_buffers | ( |  | ) |

Number of buffers to output before sending EOS (-1 = unlimited).

Returns
  A PropertyProxy that allows you to get or set the value of the property, or receive notification when the value of the property changes.

## property_num_buffers() [2/2]

Glib::PropertyProxy_ReadOnly< int > Gst::BaseSrc::property_num_buffers | ( |  | ) | const

Number of buffers to output before sending EOS (-1 = unlimited).

Returns
  A PropertyProxy_ReadOnly that allows you to get the value of the property, or receive notification when the value of the property changes.

## property_typefind() [1/2]

Glib::PropertyProxy< bool > Gst::BaseSrc::property_typefind | ( |  | ) |

Run typefind before negotiating.

Returns
  A PropertyProxy that allows you to get or set the value of the property, or receive notification when the value of the property changes.

## property_typefind() [2/2]

Glib::PropertyProxy_ReadOnly< bool > Gst::BaseSrc::property_typefind | ( |  | ) | const

Run typefind before negotiating.

Returns
  A PropertyProxy_ReadOnly that allows you to get the value of the property, or receive notification when the value of the property changes.

## query_latency()

bool Gst::BaseSrc::query_latency | ( | bool & | live,
|  | Gst::ClockTime& | min_latency,
|  | Gst::ClockTime& | max_latency
| ) |  | const

Query the source for the latency parameters.

live will be `true` when src is configured as a live source. min_latency and max_latency will be set to the difference between the running time and the timestamp of the first buffer.

This function is mostly used by subclasses.

Parameters

  live | If the source is live.
  min_latency | The min latency of the source.
  max_latency | The max latency of the source.

Returns
  `true` if the query succeeded.

## set_async()

void Gst::BaseSrc::set_async | ( | bool | async | ) |

Configure async behaviour in src, no state change will block.

The open, close, start, stop, play and pause virtual methods will be executed in a different thread and are thus allowed to perform blocking operations. Any blocking operation should be unblocked with the unlock vmethod.

Parameters

  async | New async mode.

## set_automatic_eos()

void Gst::BaseSrc::set_automatic_eos | ( | bool | automatic_eos | ) |

If automatic_eos is `true`, src will automatically go EOS if a buffer after the total size is returned.

By default this is `true` but sources that can't return an authoritative size and only know that they're EOS when trying to read more should set this to `false`.

Parameters

  automatic_eos | Automatic eos.

## set_blocksize()

void Gst::BaseSrc::set_blocksize | ( | guint | blocksize | ) |

Set the number of bytes that src will push out with each buffer.

When blocksize is set to -1, a default length will be used.

Parameters

  blocksize | The new blocksize in bytes.

## set_caps()

bool Gst::BaseSrc::set_caps | ( | const Glib::RefPtr< Gst::Caps >& | caps | ) |

Set new caps on the basesrc source pad.

Parameters

  caps | A Gst::Caps.

Returns
  `true` if the caps could be set.

## set_caps_vfunc()

virtual bool Gst::BaseSrc::set_caps_vfunc | ( | const Glib::RefPtr< Gst::Caps >& | caps | ) |

virtual

Notify subclass of changed output caps.

## set_do_timestamp()

void Gst::BaseSrc::set_do_timestamp | ( | bool | timestamp | ) |

Configure src to automatically timestamp outgoing buffers based on the current running_time of the pipeline.

This property is mostly useful for live sources.

Parameters

  timestamp | Enable or disable timestamping.

## set_dynamic_size()

void Gst::BaseSrc::set_dynamic_size | ( | bool | dynamic_size | ) |

If not dynamic_size, size is only updated when needed, such as when trying to read past current tracked size.

Otherwise, size is checked for upon each read.

Parameters

  dynamic_size | New dynamic size mode.

## set_format()

void Gst::BaseSrc::set_format | ( | Format | format | ) |

Sets the default format of the source.

This will be the format used for sending SEGMENT events and for performing seeks.

If a format of GST_FORMAT_BYTES is set, the element will be able to operate in pull mode if the Gst::BaseSrcClass.is_seekable() returns `true`.

This function must only be called in states < Gst::STATE_PAUSED.

Parameters

  format | The format to use.

## set_live()

void Gst::BaseSrc::set_live | ( | bool | live | ) |

If the element listens to a live source, live should be set to `true`.

A live source will not produce data in the PAUSED state and will therefore not be able to participate in the PREROLL phase of a pipeline. To signal this fact to the application and the pipeline, the state change return value of the live source will be GST_STATE_CHANGE_NO_PREROLL.

Parameters

  live | New live-mode.

## start_complete()

void Gst::BaseSrc::start_complete | ( | Gst::FlowReturn | ret | ) |

Complete an asynchronous start operation.

When the subclass overrides the start method, it should call start_complete() when the start operation completes either from the same thread or from an asynchronous helper thread.

Parameters

  ret | A Gst::FlowReturn.

## start_vfunc()

virtual bool Gst::BaseSrc::start_vfunc | ( |  | ) |

virtual

Start processing.

Subclasses should open resources and prepare to produce data.

## start_wait()

Gst::FlowReturn Gst::BaseSrc::start_wait | ( |  | ) |

Wait until the start operation completes.

Returns
  A Gst::FlowReturn.

## stop_vfunc()

virtual bool Gst::BaseSrc::stop_vfunc | ( |  | ) |

virtual

Stop processing.

Subclasses should use this to close resources.

## unlock_stop_vfunc()

virtual bool Gst::BaseSrc::unlock_stop_vfunc | ( |  | ) |

virtual

Clear the previous unlock request.

Subclasses should clear any state they set during unlock_vfunc(), such as clearing command queues.

## unlock_vfunc()

virtual bool Gst::BaseSrc::unlock_vfunc | ( |  | ) |

virtual

Unlock any pending access to the resource.

Subclasses should unblock any blocked function ASAP.

## wait_playing()

FlowReturn Gst::BaseSrc::wait_playing | ( |  | ) |

If the Gst::BaseSrcClass.create() method performs its own synchronisation against the clock it must unblock when going from PLAYING to the PAUSED state and call this method before continuing to produce the remaining data.

This function will block until a state change to PLAYING happens (in which case this function returns Gst::FLOW_OK) or the processing must be stopped due to a state change to READY or a FLUSH event (in which case this function returns Gst::FLOW_FLUSHING).

Returns
  Gst::FLOW_OK if src is PLAYING and processing can continue. Any other return value should be returned from the create vmethod.

## Friends And Related Function Documentation

## wrap()

Glib::RefPtr< Gst::BaseSrc > wrap | ( | GstBaseSrc * | object,
|  | bool | take_copy = `false`
| ) |  |

related

A Glib::wrap() method for this object.

Parameters

  object | The C instance.
  take_copy | False if the result should take ownership of the C instance. True if it should take a new copy or ref.

Returns
  A C++ instance that wraps this C instance.