BaseSrc

This is a generic 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 #GstFormat with the gst_base_src_set_format() method. The currently set format determines the format of the internal #GstSegment and any %GST_EVENT_SEGMENT events. The default format for #GstBaseSrc is %GST_FORMAT_BYTES.

#GstBaseSrc 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). * #GstBaseSrcClass.is_seekable() returns %TRUE.

If all the conditions are met for operating in pull mode, #GstBaseSrc 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:

* #GstBaseSrcClass.is_seekable() returns %TRUE. * #GstBaseSrcClass.query() can convert all supported seek formats to the internal format as set with gst_base_src_set_format(). * #GstBaseSrcClass.do_seek() 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 #GstBaseSrcClass.create() method should be ignored. It is recommended to subclass #GstPushSrc 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 #GstBaseSrcClass.create() function.

#GstBaseSrc 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 gst_base_src_set_live() to activate the live source mode.

A live source does not produce data in the PAUSED state. This means that the #GstBaseSrcClass.create() 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 use gst_base_src_wait_playing() when the #GstBaseSrcClass.create() function was interrupted by a state change to PAUSED.

The #GstBaseSrcClass.get_times() method can be used to implement pseudo-live sources. It only makes sense to implement the #GstBaseSrcClass.get_times() function if the source is a live source. The #GstBaseSrcClass.get_times() 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 and will report this value as the latency. Subclasses should override the query function when this behaviour is not acceptable.

There is only support in #GstBaseSrc for exactly one source pad, which should be named "src". A source implementation (subclass of #GstBaseSrc) should install a pad template in its class_init function, like so: |[<!-- language="C" --> static void my_element_class_init (GstMyElementClass *klass) { GstElementClass *gstelement_class = GST_ELEMENT_CLASS (klass); // srctemplate should be a #GstStaticPadTemplate with direction // %GST_PAD_SRC and name "src" gst_element_class_add_static_pad_template (gstelement_class, &amp;srctemplate);

gst_element_class_set_static_metadata (gstelement_class, "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.

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.

Constructors

this
this(GstBaseSrc* gstBaseSrc, bool ownedRef)

Sets our main struct and passes it to the parent class.

Members

Functions

getAllocator
void getAllocator(Allocator allocator, AllocationParams params)

Lets #GstBaseSrc sub-classes to know the memory @allocator used by the base class and its @params.

getBaseSrcStruct
GstBaseSrc* getBaseSrcStruct(bool transferOwnership)

Get the main Gtk struct

getBlocksize
uint getBlocksize()

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

getBufferPool
BufferPool getBufferPool()
getDoTimestamp
bool getDoTimestamp()

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

getStruct
void* getStruct()

the main Gtk struct as a void*

isAsync
bool isAsync()

Get the current async behaviour of @src. See also gst_base_src_set_async().

isLive
bool isLive()

Check if an element is in live mode.

newSeamlessSegment
bool newSeamlessSegment(long start, long stop, long time)

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.

queryLatency
bool queryLatency(bool live, GstClockTime minLatency, GstClockTime maxLatency)

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.

setAsync
void setAsync(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.

setAutomaticEos
void setAutomaticEos(bool automaticEos)

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.

setBlocksize
void setBlocksize(uint 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.

setCaps
bool setCaps(Caps caps)

Set new caps on the basesrc source pad.

setDoTimestamp
void setDoTimestamp(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.

setDynamicSize
void setDynamicSize(bool dynamic)

If not @dynamic, size is only updated when needed, such as when trying to read past current tracked size. Otherwise, size is checked for upon each read.

setFormat
void setFormat(GstFormat format)

Sets the default format of the source. This will be the format used for sending SEGMENT events and for performing seeks.

setLive
void setLive(bool live)

If the element listens to a live source, @live should be set to %TRUE.

setStruct
void setStruct(GObject* obj)
Undocumented in source. Be warned that the author may not have intended to support it.
startComplete
void startComplete(GstFlowReturn ret)

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

startWait
GstFlowReturn startWait()

Wait until the start operation completes.

waitPlaying
GstFlowReturn waitPlaying()

If the #GstBaseSrcClass.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.

Static functions

getType
GType getType()

Variables

gstBaseSrc
GstBaseSrc* gstBaseSrc;

the main Gtk struct

Inherited Members

From Element

gstElement
GstElement* gstElement;

the main Gtk struct

getElementStruct
GstElement* getElementStruct(bool transferOwnership)

Get the main Gtk struct

getStruct
void* getStruct()

the main Gtk struct as a void*

setStruct
void setStruct(GObject* obj)
Undocumented in source. Be warned that the author may not have intended to support it.
queryPosition
long queryPosition()

Queries an element for the stream position. This is a convenience function for gstreamerD.

queryDuration
long queryDuration()

Queries an element for the stream duration. This is a convenience function for gstreamerD.

location
void location(string set)

This set's the filename for a filesrc element.

caps
void caps(Caps cp)

Set the caps property of an Element.

seek
int seek(long time_nanoseconds)

For your convenience in gstreamerD: you can seek to the position of the pipeline measured in time_nanoseconds.

pads
Pad[] pads()

Get's all the pads from an element in a Pad[].

getType
GType getType()
makeFromUri
Element makeFromUri(GstURIType type, string uri, string elementname)

Creates an element for handling the given URI.

register
bool register(Plugin plugin, string name, uint rank, GType type)

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

stateChangeReturnGetName
string stateChangeReturnGetName(GstStateChangeReturn stateRet)

Gets a string representing the given state change result.

stateGetName
string stateGetName(GstState state)

Gets a string representing the given state.

abortState
void abortState()

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

addPad
bool addPad(Pad pad)

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

addPropertyDeepNotifyWatch
gulong addPropertyDeepNotifyWatch(string propertyName, bool includeValue)
addPropertyNotifyWatch
gulong addPropertyNotifyWatch(string propertyName, bool includeValue)
callAsync
void callAsync(GstElementCallAsyncFunc func, void* userData, GDestroyNotify destroyNotify)

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.

changeState
GstStateChangeReturn changeState(GstStateChange transition)

Perform @transition on @element.

continueState
GstStateChangeReturn continueState(GstStateChangeReturn ret)

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.

createAllPads
void createAllPads()

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

getBaseTime
GstClockTime getBaseTime()

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.

getBus
Bus getBus()

Returns the bus of the element. Note that only a #GstPipeline will provide a bus for the application.

getClock
Clock getClock()

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

getCompatiblePad
Pad getCompatiblePad(Pad pad, Caps caps)

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.

getCompatiblePadTemplate
PadTemplate getCompatiblePadTemplate(PadTemplate compattempl)

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

getContext
Context getContext(string contextType)

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

getContextUnlocked
Context getContextUnlocked(string contextType)

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

getContexts
ListG getContexts()

Gets the contexts set on the element.

getFactory
ElementFactory getFactory()

Retrieves the factory that was used to create this element.

getRequestPad
Pad getRequestPad(string name)

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().

getStartTime
GstClockTime getStartTime()

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.

getState
GstStateChangeReturn getState(GstState state, GstState pending, GstClockTime timeout)

Gets the state of the element.

getStaticPad
Pad getStaticPad(string name)

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

isLockedState
bool isLockedState()

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.

iteratePads
Iterator iteratePads()

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().

iterateSinkPads
Iterator iterateSinkPads()

Retrieves an iterator of @element's sink pads.

iterateSrcPads
Iterator iterateSrcPads()

Retrieves an iterator of @element's source pads.

link
bool link(Element dest)

Links @src to @dest. 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. Such pads need to be released manually when unlinking. If multiple links are possible, only one is established.

linkFiltered
bool linkFiltered(Element dest, Caps filter)

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.

linkPads
bool linkPads(string srcpadname, Element dest, string destpadname)

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.

linkPadsFiltered
bool linkPadsFiltered(string srcpadname, Element dest, string destpadname, Caps filter)

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 %NULL, makes sure that the caps of the link is a subset of @caps.

linkPadsFull
bool linkPadsFull(string srcpadname, Element dest, string destpadname, GstPadLinkCheck flags)

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.

lostState
void lostState()

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.

messageFull
void messageFull(GstMessageType type, GQuark domain, int code, string text, string dbg, string file, string funct, int line)

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

messageFullWithDetails
void messageFullWithDetails(GstMessageType type, GQuark domain, int code, string text, string dbg, string file, string funct, int line, Structure structure)

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

noMorePads
void noMorePads()

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.

postMessage
bool postMessage(Message message)

Post a message on the element's #GstBus. 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.

provideClock
Clock provideClock()

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.

query
bool query(Query query)

Performs a query on the given element.

queryConvert
bool queryConvert(GstFormat srcFormat, long srcVal, GstFormat destFormat, long destVal)

Queries an element to convert @src_val in @src_format to @dest_format.

queryDuration
bool queryDuration(GstFormat format, long duration)

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.

queryPosition
bool queryPosition(GstFormat format, long cur)

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.

releaseRequestPad
void releaseRequestPad(Pad pad)

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

removePad
bool removePad(Pad pad)

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

removePropertyNotifyWatch
void removePropertyNotifyWatch(gulong watchId)
requestPad
Pad requestPad(PadTemplate templ, string name, Caps caps)

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().

seek
bool seek(double rate, GstFormat format, GstSeekFlags flags, GstSeekType startType, long start, GstSeekType stopType, long stop)

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().

seekSimple
bool seekSimple(GstFormat format, GstSeekFlags seekFlags, long seekPos)

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().

sendEvent
bool sendEvent(Event event)

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.

setBaseTime
void setBaseTime(GstClockTime time)

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

setBus
void setBus(Bus bus)

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

setClock
bool setClock(Clock clock)

Sets the clock for the element. This function increases the refcount on the clock. Any previously set clock on the object is unreffed.

setContext
void setContext(Context context)

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

setLockedState
bool setLockedState(bool lockedState)

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

setStartTime
void setStartTime(GstClockTime time)

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.

setState
GstStateChangeReturn setState(GstState state)

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.

syncStateWithParent
bool syncStateWithParent()

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.

unlink
void unlink(Element dest)

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

unlinkPads
void unlinkPads(string srcpadname, Element dest, string destpadname)

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

OnNoMorePadsDelegateWrapper
class OnNoMorePadsDelegateWrapper
Undocumented in source.
onNoMorePadsListeners
OnNoMorePadsDelegateWrapper[] onNoMorePadsListeners;
Undocumented in source.
addOnNoMorePads
gulong addOnNoMorePads(void delegate(Element) dlg, ConnectFlags connectFlags)

This signals that the element will not generate more dynamic pads. Note that this signal will usually be emitted from the context of the streaming thread.

callBackNoMorePads
void callBackNoMorePads(GstElement* elementStruct, OnNoMorePadsDelegateWrapper wrapper)
Undocumented in source. Be warned that the author may not have intended to support it.
callBackNoMorePadsDestroy
void callBackNoMorePadsDestroy(OnNoMorePadsDelegateWrapper wrapper, GClosure* closure)
Undocumented in source. Be warned that the author may not have intended to support it.
OnPadAddedDelegateWrapper
class OnPadAddedDelegateWrapper
Undocumented in source.
onPadAddedListeners
OnPadAddedDelegateWrapper[] onPadAddedListeners;
Undocumented in source.
addOnPadAdded
gulong addOnPadAdded(void delegate(Pad, Element) dlg, ConnectFlags connectFlags)

a new #GstPad has been added to the element. Note that this signal will usually be emitted from the context of the streaming thread. Also keep in mind that if you add new elements to the pipeline in the signal handler you will need to set them to the desired target state with gst_element_set_state() or gst_element_sync_state_with_parent().

callBackPadAdded
void callBackPadAdded(GstElement* elementStruct, GstPad* newPad, OnPadAddedDelegateWrapper wrapper)
Undocumented in source. Be warned that the author may not have intended to support it.
callBackPadAddedDestroy
void callBackPadAddedDestroy(OnPadAddedDelegateWrapper wrapper, GClosure* closure)
Undocumented in source. Be warned that the author may not have intended to support it.
OnPadRemovedDelegateWrapper
class OnPadRemovedDelegateWrapper
Undocumented in source.
onPadRemovedListeners
OnPadRemovedDelegateWrapper[] onPadRemovedListeners;
Undocumented in source.
addOnPadRemoved
gulong addOnPadRemoved(void delegate(Pad, Element) dlg, ConnectFlags connectFlags)

a #GstPad has been removed from the element

callBackPadRemoved
void callBackPadRemoved(GstElement* elementStruct, GstPad* oldPad, OnPadRemovedDelegateWrapper wrapper)
Undocumented in source. Be warned that the author may not have intended to support it.
callBackPadRemovedDestroy
void callBackPadRemovedDestroy(OnPadRemovedDelegateWrapper wrapper, GClosure* closure)
Undocumented in source. Be warned that the author may not have intended to support it.

Meta