#include <basesrc.h>
Public Member Functions | |
virtual | ~BaseSrc () |
GstBaseSrc* | gobj () |
Provides access to the underlying C GObject. | |
const GstBaseSrc* | gobj () const |
Provides access to the underlying C GObject. | |
GstBaseSrc* | gobj_copy () |
Provides access to the underlying C instance. The caller is responsible for unrefing it. Use when directly setting fields in structs. | |
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. | |
bool | is_live () |
Check if an element is in live mode. | |
void | set_live (bool live) |
If the element listens to a live source, live should be set to true . | |
void | set_format (Format format) |
Sets the default format of the source. | |
bool | query_latency (bool& live, ClockTime& min_latency, ClockTime& max_latency) |
Query the source for the latency parameters. | |
bool | get_do_timestamp () |
Query if src timestamps outgoing buffers based on the current running_time. | |
void | set_do_timestamp (bool timestamp) |
Configure src to automatically timestamp outgoing buffers based on the current running_time of the pipeline. | |
Glib::RefPtr<Gst::Pad> | get_src_pad () const |
Gets the source Gst::Pad object of the element. | |
Glib::PropertyProxy<gulong> | property_blocksize () |
Size in bytes to read per buffer (-1 = default). | |
Glib::PropertyProxy_ReadOnly <gulong> | property_blocksize () const |
Size in bytes to read per buffer (-1 = default). | |
Glib::PropertyProxy<bool> | property_do_timestamp () |
Apply current stream time to buffers. | |
Glib::PropertyProxy_ReadOnly <bool> | property_do_timestamp () const |
Apply current stream time to buffers. | |
Glib::PropertyProxy<int> | property_num_buffers () |
Number of buffers to output before sending EOS (-1 = unlimited). | |
Glib::PropertyProxy_ReadOnly<int> | property_num_buffers () const |
Number of buffers to output before sending EOS (-1 = unlimited). | |
Glib::PropertyProxy<bool> | property_typefind () |
Run typefind before negotiating. | |
Glib::PropertyProxy_ReadOnly <bool> | property_typefind () const |
Run typefind before negotiating. | |
virtual Glib::RefPtr<Gst::Caps> | get_caps_vfunc () |
Called to get the caps to report. | |
virtual void | get_times_vfunc (const Glib::RefPtr<Gst::Buffer>& buffer, ClockTime& start, ClockTime& end) |
Notify subclass of changed output caps. | |
virtual void | fixate_vfunc (const Glib::RefPtr<Gst::Caps>& caps) |
Return the total size of the resource, in the configured format. | |
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. |
This is a generice base class for source elements. The following types of sources are supported:
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:
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:
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:
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 2007-12-19 (0.10.16).
virtual Gst::BaseSrc::~BaseSrc | ( | ) | [virtual] |
virtual void Gst::BaseSrc::fixate_vfunc | ( | const Glib::RefPtr<Gst::Caps>& | caps | ) | [virtual] |
Return the total size of the resource, in the configured format.
Check if the source can seek. Unlock any pending access to the resource. Subclasses should unblock any blocked function ASAP. Override this to implement custom event handling. Perform seeking on the resource to the indicated segment. Handle a requested query. Check whether the source would support pull-based operation if it were to be opened now. This vfunc is optional, but should be implemented if possible to avoid unnecessary start/stop cycles. The default implementation will open and close the resource to find out whether get_range() is supported, and that is usually undesirable. Called during negotiation if caps need fixating. Implement instead of setting a fixate function on the source pad.
virtual Glib::RefPtr<Gst::Caps> Gst::BaseSrc::get_caps_vfunc | ( | ) | [virtual] |
Called to get the caps to report.
bool Gst::BaseSrc::get_do_timestamp | ( | ) |
Query if src timestamps outgoing buffers based on the current running_time.
true
if the base class will automatically timestamp outgoing buffers.Glib::RefPtr<Gst::Pad> Gst::BaseSrc::get_src_pad | ( | ) | const |
Gets the source Gst::Pad object of the element.
virtual void Gst::BaseSrc::get_times_vfunc | ( | const Glib::RefPtr<Gst::Buffer>& | buffer, | |
ClockTime& | start, | |||
ClockTime& | end | |||
) | [virtual] |
Notify subclass of changed output caps.
Negotiated the caps with the peer. Generate and send a new_segment event (UNUSED). Start processing. Subclasses should open resources and prepare to produce data. Stop processing. Subclasses should use this to close resources. 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.
const GstBaseSrc* Gst::BaseSrc::gobj | ( | ) | const [inline] |
Provides access to the underlying C GObject.
Reimplemented from Gst::Element.
Reimplemented in Gst::FakeSrc, Gst::FdSrc, Gst::FileSrc, Gst::PushSrc, GstBase::AlsaSrc, GstBase::AudioSrc, GstBase::AudioTestSrc, GstBase::BaseAudioSrc, GstBase::CddaBaseSrc, GstBase::CdParanoiaSrc, GstBase::GioSrc, GstBase::GioStreamSrc, and GstBase::VideoTestSrc.
GstBaseSrc* Gst::BaseSrc::gobj | ( | ) | [inline] |
Provides access to the underlying C GObject.
Reimplemented from Gst::Element.
Reimplemented in Gst::FakeSrc, Gst::FdSrc, Gst::FileSrc, Gst::PushSrc, GstBase::AlsaSrc, GstBase::AudioSrc, GstBase::AudioTestSrc, GstBase::BaseAudioSrc, GstBase::CddaBaseSrc, GstBase::CdParanoiaSrc, GstBase::GioSrc, GstBase::GioStreamSrc, and GstBase::VideoTestSrc.
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.
Reimplemented from Gst::Element.
Reimplemented in Gst::FakeSrc, Gst::FdSrc, Gst::FileSrc, Gst::PushSrc, GstBase::AlsaSrc, GstBase::AudioSrc, GstBase::AudioTestSrc, GstBase::BaseAudioSrc, GstBase::CddaBaseSrc, GstBase::CdParanoiaSrc, GstBase::GioSrc, GstBase::GioStreamSrc, and GstBase::VideoTestSrc.
bool Gst::BaseSrc::is_live | ( | ) |
Check if an element is in live mode.
true
if element is in live mode. Glib::PropertyProxy_ReadOnly<gulong> Gst::BaseSrc::property_blocksize | ( | ) | const |
Size in bytes to read per buffer (-1 = default).
You rarely need to use properties because there are get_ and set_ methods for almost all of them.
Glib::PropertyProxy<gulong> Gst::BaseSrc::property_blocksize | ( | ) |
Size in bytes to read per buffer (-1 = default).
You rarely need to use properties because there are get_ and set_ methods for almost all of them.
Glib::PropertyProxy_ReadOnly<bool> Gst::BaseSrc::property_do_timestamp | ( | ) | const |
Apply current stream time to buffers.
You rarely need to use properties because there are get_ and set_ methods for almost all of them.
Glib::PropertyProxy<bool> Gst::BaseSrc::property_do_timestamp | ( | ) |
Apply current stream time to buffers.
You rarely need to use properties because there are get_ and set_ methods for almost all of them.
Glib::PropertyProxy_ReadOnly<int> Gst::BaseSrc::property_num_buffers | ( | ) | const |
Number of buffers to output before sending EOS (-1 = unlimited).
You rarely need to use properties because there are get_ and set_ methods for almost all of them.
Glib::PropertyProxy<int> Gst::BaseSrc::property_num_buffers | ( | ) |
Number of buffers to output before sending EOS (-1 = unlimited).
You rarely need to use properties because there are get_ and set_ methods for almost all of them.
Glib::PropertyProxy_ReadOnly<bool> Gst::BaseSrc::property_typefind | ( | ) | const |
Run typefind before negotiating.
You rarely need to use properties because there are get_ and set_ methods for almost all of them.
Glib::PropertyProxy<bool> Gst::BaseSrc::property_typefind | ( | ) |
Run typefind before negotiating.
You rarely need to use properties because there are get_ and set_ methods for almost all of them.
Query the source for the latency parameters.
live will be true
when src is configured as a live source. min_latency will be set to the difference between the running time and the timestamp of the first buffer. max_latency is always the undefined value of -1.
This function is mostly used by subclasses.
live | If the source is live. | |
min_latency | The min latency of the source. | |
max_latency | The max latency of the source. |
true
if the query succeeded.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.
Since: 0.10.15
timestamp | Enable or disable timestamping. |
void Gst::BaseSrc::set_format | ( | Format | format | ) |
Sets the default format of the source.
This will be the format used for sending NEW_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::BaseSrc::is_seekable returns true
.
Since: 0.10.1
format | The format to use. |
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.
live | New live-mode. |
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_OK if src is PLAYING and processing can
Glib::RefPtr<Gst::BaseSrc> wrap | ( | GstBaseSrc * | object, | |
bool | take_copy = false | |||
) | [related] |
A Glib::wrap() method for this object.
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. |