Top |
struct | GstElement |
struct | GstElementClass |
enum | GstElementFlags |
enum | GstState |
enum | GstStateChange |
enum | GstStateChangeReturn |
#define | GST_ELEMENT_METADATA_AUTHOR |
#define | GST_ELEMENT_METADATA_DESCRIPTION |
#define | GST_ELEMENT_METADATA_DOC_URI |
#define | GST_ELEMENT_METADATA_ICON_NAME |
#define | GST_ELEMENT_METADATA_KLASS |
#define | GST_ELEMENT_METADATA_LONGNAME |
GstElement is the abstract base class needed to construct an element that can be used in a GStreamer pipeline. Please refer to the plugin writers guide for more information on creating GstElement subclasses.
The name of a GstElement can be get with gst_element_get_name()
and set with
gst_element_set_name()
. For speed, GST_ELEMENT_NAME()
can be used in the
core when using the appropriate locking. Do not use this in plug-ins or
applications in order to retain ABI compatibility.
Elements can have pads (of the type GstPad). These pads link to pads on
other elements. GstBuffer flow between these linked pads.
A GstElement has a GList of GstPad structures for all their input (or sink)
and output (or source) pads.
Core and plug-in writers can add and remove pads with gst_element_add_pad()
and gst_element_remove_pad()
.
An existing pad of an element can be retrieved by name with
gst_element_get_static_pad()
. A new dynamic pad can be created using
gst_element_request_pad()
with a GstPadTemplate.
An iterator of all pads can be retrieved with gst_element_iterate_pads()
.
Elements can be linked through their pads.
If the link is straightforward, use the gst_element_link()
convenience function to link two elements, or gst_element_link_many()
for more elements in a row.
Use gst_element_link_filtered()
to link two elements constrained by
a specified set of GstCaps.
For finer control, use gst_element_link_pads()
and
gst_element_link_pads_filtered()
to specify the pads to link on
each element by name.
Each element has a state (see GstState). You can get and set the state
of an element with gst_element_get_state()
and gst_element_set_state()
.
Setting a state triggers a GstStateChange. To get a string representation
of a GstState, use gst_element_state_get_name()
.
You can get and set a GstClock on an element using gst_element_get_clock()
and gst_element_set_clock()
.
Some elements can provide a clock for the pipeline if
the GST_ELEMENT_FLAG_PROVIDE_CLOCK flag is set. With the
gst_element_provide_clock()
method one can retrieve the clock provided by
such an element.
Not all elements require a clock to operate correctly. If the
GST_ELEMENT_FLAG_REQUIRE_CLOCK()
flag is set, a clock should be set on the
element with gst_element_set_clock()
.
Note that clock selection and distribution is normally handled by the toplevel GstPipeline so the clock functions are only to be used in very specific situations.
#define GST_STATE(elem) (GST_ELEMENT_CAST(elem)->current_state)
This macro returns the current GstState of the element.
#define GST_STATE_GET_NEXT(cur,pending) ((GstState)((cur) + __GST_SIGN ((gint)(pending) - (gint)(cur))))
Given a current state cur
and a target state pending
, calculate the next (intermediate)
GstState.
#define GST_STATE_NEXT(elem) (GST_ELEMENT_CAST(elem)->next_state)
This macro returns the next GstState of the element.
#define GST_STATE_PENDING(elem) (GST_ELEMENT_CAST(elem)->pending_state)
This macro returns the currently pending GstState of the element.
#define GST_STATE_RETURN(elem) (GST_ELEMENT_CAST(elem)->last_return)
This macro returns the last GstStateChangeReturn value.
#define GST_STATE_TARGET(elem) (GST_ELEMENT_CAST(elem)->target_state)
This macro returns the target GstState of the element.
#define GST_STATE_TRANSITION(cur,next) ((GstStateChange)(((cur)<<3)|(next)))
Given a current state cur
and a next state next
, calculate the associated
GstStateChange transition.
#define GST_STATE_TRANSITION_CURRENT(trans) ((GstState)((trans)>>3))
Given a state transition trans
, extract the current GstState.
#define GST_STATE_TRANSITION_NEXT(trans) ((GstState)((trans)&0x7))
Given a state transition trans
, extract the next GstState.
#define GST_STATE_GET_LOCK(elem) (&(GST_ELEMENT_CAST(elem)->state_lock))
Get a reference to the state lock of elem
.
This lock is used by the core. It is taken while getting or setting
the state, during state changes, and while finalizing.
#define GST_STATE_GET_COND(elem) (&GST_ELEMENT_CAST(elem)->state_cond)
Get the conditional used to signal the completion of a state change.
#define GST_ELEMENT_NAME(elem) (GST_OBJECT_NAME(elem))
Gets the name of this element. This is not thread-safe by default
(i.e. you will have to make sure the object lock is taken yourself).
If in doubt use gst_element_get_name()
instead.
#define GST_ELEMENT_PARENT(elem) (GST_ELEMENT_CAST(GST_OBJECT_PARENT(elem)))
Get the parent object of this element. This is not thread-safe by default
(i.e. you will have to make sure the object lock is taken yourself).
If in doubt use gst_object_get_parent()
instead.
#define GST_ELEMENT_BUS(elem) (GST_ELEMENT_CAST(elem)->bus)
Get the message bus of this element. This is not thread-safe by default
(i.e. you will have to make sure the object lock is taken yourself).
If in doubt use gst_element_get_bus()
instead.
#define GST_ELEMENT_CLOCK(elem) (GST_ELEMENT_CAST(elem)->clock)
Get the clock of this element.This is not thread-safe by default
(i.e. you will have to make sure it is safe yourself).
If in doubt use gst_element_get_clock()
instead.
#define GST_ELEMENT_PADS(elem) (GST_ELEMENT_CAST(elem)->pads)
Get the pads of this elements.
#define GST_ELEMENT_START_TIME(elem) (GST_ELEMENT_CAST(elem)->start_time)
This macro returns the start_time of the elem
. The start_time is the
running_time of the pipeline when the element went to PAUSED.
#define GST_ELEMENT_ERROR(el,domain,code,text,debug)
Utility function that elements can use in case they encountered a fatal data processing error. The pipeline will post an error message and the application will be requested to stop further media processing.
el |
the element that generates the error |
|
domain |
like CORE, LIBRARY, RESOURCE or STREAM (see gstreamer-GstGError) |
|
code |
error code defined for that domain (see gstreamer-GstGError) |
|
text |
the message to display (format string and args enclosed in parentheses) |
|
debug |
debugging information for the message (format string and args enclosed in parentheses) |
#define GST_ELEMENT_ERROR_WITH_DETAILS(el,domain,code,text,debug,args)
Utility function that elements can use in case they encountered a fatal data processing error. The pipeline will post an error message and the application will be requested to stop further media processing.
el |
the element that generates the error |
|
domain |
like CORE, LIBRARY, RESOURCE or STREAM (see gstreamer-GstGError) |
|
code |
error code defined for that domain (see gstreamer-GstGError) |
|
text |
the message to display (format string and args enclosed in parentheses) |
|
debug |
debugging information for the message (format string and args enclosed in parentheses) |
|
args |
optional name, type, value triplets, which will be stored in the associated GstStructure. NULL terminator required. Must be enclosed within parentheses. |
Since: 1.10
#define GST_ELEMENT_FLOW_ERROR(el,flow_return)
Utility function that elements can use in case they encountered a fatal data processing error due to wrong flow processing.
el |
the element that generates the error |
|
flow_return |
the GstFlowReturn leading to that ERROR message |
Since: 1.10
#define GST_ELEMENT_WARNING(el, domain, code, text, debug)
Utility function that elements can use in case they encountered a non-fatal data processing problem. The pipeline will post a warning message and the application will be informed.
el |
the element that generates the warning |
|
domain |
like CORE, LIBRARY, RESOURCE or STREAM (see gstreamer-GstGError) |
|
code |
error code defined for that domain (see gstreamer-GstGError) |
|
text |
the message to display (format string and args enclosed in parentheses) |
|
debug |
debugging information for the message (format string and args enclosed in parentheses) |
#define GST_ELEMENT_WARNING_WITH_DETAILS(el, domain, code, text, debug, args)
Utility function that elements can use in case they encountered a non-fatal data processing problem. The pipeline will post a warning message and the application will be informed.
el |
the element that generates the warning |
|
domain |
like CORE, LIBRARY, RESOURCE or STREAM (see gstreamer-GstGError) |
|
code |
error code defined for that domain (see gstreamer-GstGError) |
|
text |
the message to display (format string and args enclosed in parentheses) |
|
debug |
debugging information for the message (format string and args enclosed in parentheses) |
|
args |
optional name, type, value triplets, which will be stored in the associated GstStructure. NULL terminator required. Must be enclosed within parentheses. |
Since: 1.10
#define GST_ELEMENT_INFO(el, domain, code, text, debug)
Utility function that elements can use in case they want to inform the application of something noteworthy that is not an error. The pipeline will post a info message and the application will be informed.
el |
the element that generates the information |
|
domain |
like CORE, LIBRARY, RESOURCE or STREAM (see gstreamer-GstGError) |
|
code |
error code defined for that domain (see gstreamer-GstGError) |
|
text |
the message to display (format string and args enclosed in parentheses) |
|
debug |
debugging information for the message (format string and args enclosed in parentheses) |
#define GST_ELEMENT_INFO_WITH_DETAILS(el, domain, code, text, debug, args)
Utility function that elements can use in case they want to inform the application of something noteworthy that is not an error. The pipeline will post a info message and the application will be informed. Optional name, type, value triplets may be supplied, and will be stored in the associated GstStructure. NULL terminator required.
el |
the element that generates the information |
|
domain |
like CORE, LIBRARY, RESOURCE or STREAM (see gstreamer-GstGError) |
|
code |
error code defined for that domain (see gstreamer-GstGError) |
|
text |
the message to display (format string and args enclosed in parentheses) |
|
debug |
debugging information for the message (format string and args enclosed in parentheses) |
|
args |
optional name, type, value triplets, which will be stored in the associated GstStructure. NULL terminator required. Must be enclosed within parentheses. |
Since: 1.10
#define GST_ELEMENT_IS_LOCKED_STATE(elem) (GST_OBJECT_FLAG_IS_SET(elem,GST_ELEMENT_FLAG_LOCKED_STATE))
Check if the element is in the locked state and therefore will ignore state changes from its parent object.
void gst_element_class_add_pad_template (GstElementClass *klass
,GstPadTemplate *templ
);
Adds a padtemplate to an element class. This is mainly used in the _class_init functions of classes. If a pad template with the same name as an already existing one is added the old one is replaced by the new one.
klass |
the GstElementClass to add the pad template to. |
|
templ |
a GstPadTemplate to add to the element class. |
[transfer full] |
void gst_element_class_add_static_pad_template (GstElementClass *klass
,GstStaticPadTemplate *static_templ
);
Adds a pad template to an element class based on the static pad template
templ
. This is mainly used in the _class_init functions of element
implementations. If a pad template with the same name already exists,
the old one is replaced by the new one.
klass |
the GstElementClass to add the pad template to. |
|
static_templ |
GstStaticPadTemplate to add as pad template to the element class. |
Since: 1.8
GstPadTemplate * gst_element_class_get_pad_template (GstElementClass *element_class
,const gchar *name
);
Retrieves a padtemplate from element_class
with the given name.
If you use this function in the GInstanceInitFunc of an object class that has subclasses, make sure to pass the g_class parameter of the GInstanceInitFunc here.
element_class |
a GstElementClass to get the pad template of. |
|
name |
the name of the GstPadTemplate to get. |
the GstPadTemplate with the
given name, or NULL
if none was found. No unreferencing is
necessary.
[transfer none][nullable]
GList *
gst_element_class_get_pad_template_list
(GstElementClass *element_class
);
Retrieves a list of the pad templates associated with element_class
. The
list must not be modified by the calling code.
If you use this function in the GInstanceInitFunc of an object class that has subclasses, make sure to pass the g_class parameter of the GInstanceInitFunc here.
void gst_element_class_set_metadata (GstElementClass *klass
,const gchar *longname
,const gchar *classification
,const gchar *description
,const gchar *author
);
Sets the detailed information for a GstElementClass.
This function is for use in _class_init functions only.
klass |
class to set metadata for |
|
longname |
The long English name of the element. E.g. "File Sink" |
|
classification |
String describing the type of element, as an unordered list separated with slashes ('/'). See draft-klass.txt of the design docs for more details and common types. E.g: "Sink/File" |
|
description |
Sentence describing the purpose of the element. E.g: "Write stream to a file" |
|
author |
Name and contact details of the author(s). Use \n to separate multiple author metadata. E.g: "Joe Bloggs <joe.blogs at foo.com>" |
void gst_element_class_set_static_metadata (GstElementClass *klass
,const gchar *longname
,const gchar *classification
,const gchar *description
,const gchar *author
);
Sets the detailed information for a GstElementClass.
This function is for use in _class_init functions only.
Same as gst_element_class_set_metadata()
, but longname
, classification
,
description
, and author
must be static strings or inlined strings, as
they will not be copied. (GStreamer plugins will be made resident once
loaded, so this function can be used even from dynamically loaded plugins.)
klass |
class to set metadata for |
|
longname |
The long English name of the element. E.g. "File Sink" |
|
classification |
String describing the type of element, as an unordered list separated with slashes ('/'). See draft-klass.txt of the design docs for more details and common types. E.g: "Sink/File" |
|
description |
Sentence describing the purpose of the element. E.g: "Write stream to a file" |
|
author |
Name and contact details of the author(s). Use \n to separate multiple author metadata. E.g: "Joe Bloggs <joe.blogs at foo.com>" |
void gst_element_class_add_metadata (GstElementClass *klass
,const gchar *key
,const gchar *value
);
Set key
with value
as metadata in klass
.
void gst_element_class_add_static_metadata (GstElementClass *klass
,const gchar *key
,const gchar *value
);
Set key
with value
as metadata in klass
.
Same as gst_element_class_add_metadata()
, but value
must be a static string
or an inlined string, as it will not be copied. (GStreamer plugins will
be made resident once loaded, so this function can be used even from
dynamically loaded plugins.)
gboolean gst_element_add_pad (GstElement *element
,GstPad *pad
);
Adds a pad (link point) to element
. pad
's parent will be set to element
;
see gst_object_set_parent()
for refcounting information.
Pads are not automatically activated so elements should perform the needed
steps to activate the pad in case this pad is added in the PAUSED or PLAYING
state. See gst_pad_set_active()
for more information about activating pads.
The pad and the element should be unlocked when calling this function.
This function will emit the “pad-added” signal on the element.
element |
a GstElement to add the pad to. |
|
pad |
the GstPad to add to the element. |
[transfer full] |
TRUE
if the pad could be added. This function can fail when
a pad with the same name already existed or the pad already had another
parent.
MT safe.
void
gst_element_create_all_pads (GstElement *element
);
Creates a pad for each pad template that is always available. This function is only useful during object initialization of subclasses of GstElement.
GstPad * gst_element_get_compatible_pad (GstElement *element
,GstPad *pad
,GstCaps *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.
This function will first attempt to find a compatible unlinked ALWAYS pad,
and if none can be found, it will request a compatible REQUEST pad by looking
at the templates of element
.
element |
a GstElement in which the pad should be found. |
[transfer none] |
pad |
the GstPad to find a compatible one for. |
[transfer none] |
caps |
the GstCaps to use as a filter. |
[allow-none] |
the GstPad to which a link
can be made, or NULL
if one cannot be found. gst_object_unref()
after usage.
[transfer full][nullable]
GstPadTemplate * gst_element_get_compatible_pad_template (GstElement *element
,GstPadTemplate *compattempl
);
Retrieves a pad template from element
that is compatible with compattempl
.
Pads from compatible templates can be linked together.
element |
a GstElement to get a compatible pad template for. |
[transfer none] |
compattempl |
the GstPadTemplate to find a compatible template for. |
[transfer none] |
a compatible GstPadTemplate,
or NULL
if none was found. No unreferencing is necessary.
[transfer none][nullable]
GstPad * gst_element_get_request_pad (GstElement *element
,const gchar *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()
.
This method is slower than manually getting the pad template and calling
gst_element_request_pad()
if the pads should have a specific name (e.g.
name
is "src_1" instead of "src_%u").
element |
a GstElement to find a request pad of. |
|
name |
the name of the request GstPad to retrieve. |
GstPad * gst_element_get_static_pad (GstElement *element
,const gchar *name
);
Retrieves a pad from element
by name. This version only retrieves
already-existing (i.e. 'static') pads.
element |
a GstElement to find a static pad of. |
|
name |
the name of the static GstPad to retrieve. |
GstPad * gst_element_request_pad (GstElement *element
,GstPadTemplate *templ
,const gchar *name
,const GstCaps *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()
.
The pad should be released with gst_element_release_request_pad()
.
[virtual request_new_pad]
element |
a GstElement to find a request pad of. |
|
templ |
a GstPadTemplate of which we want a pad of. |
|
name |
[transfer none][allow-none] | |
caps |
the caps of the pad we want to
request. Can be |
[transfer none][allow-none] |
void
gst_element_no_more_pads (GstElement *element
);
Use this function to signal that the element does not expect any more pads to show up in the current pipeline. This function should be called whenever pads have been added by the element itself. Elements with GST_PAD_SOMETIMES pad templates use this in combination with autopluggers to figure out that the element is done initializing its pads.
This function emits the “no-more-pads” signal.
MT safe.
void gst_element_release_request_pad (GstElement *element
,GstPad *pad
);
Makes the element free the previously requested pad as obtained
with gst_element_request_pad()
.
This does not unref the pad. If the pad was created by using
gst_element_request_pad()
, gst_element_release_request_pad()
needs to be
followed by gst_object_unref()
to free the pad
.
MT safe.
gboolean gst_element_remove_pad (GstElement *element
,GstPad *pad
);
Removes pad
from element
. pad
will be destroyed if it has not been
referenced elsewhere using gst_object_unparent()
.
This function is used by plugin developers and should not be used
by applications. Pads that were dynamically requested from elements
with gst_element_request_pad()
should be released with the
gst_element_release_request_pad()
function instead.
Pads are not automatically deactivated so elements should perform the needed
steps to deactivate the pad in case this pad is removed in the PAUSED or
PLAYING state. See gst_pad_set_active()
for more information about
deactivating pads.
The pad and the element should be unlocked when calling this function.
This function will emit the “pad-removed” signal on the element.
element |
a GstElement to remove pad from. |
|
pad |
the GstPad to remove from the element. |
[transfer full] |
GstIterator *
gst_element_iterate_pads (GstElement *element
);
Retrieves an iterator of element
's pads. The iterator should
be freed after usage. Also more specialized iterators exists such as
gst_element_iterate_src_pads()
or gst_element_iterate_sink_pads()
.
The order of pads returned by the iterator will be the order in which the pads were added to the element.
GstIterator *
gst_element_iterate_sink_pads (GstElement *element
);
Retrieves an iterator of element
's sink pads.
The order of pads returned by the iterator will be the order in which the pads were added to the element.
GstIterator *
gst_element_iterate_src_pads (GstElement *element
);
Retrieves an iterator of element
's source pads.
The order of pads returned by the iterator will be the order in which the pads were added to the element.
gboolean gst_element_link (GstElement *src
,GstElement *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.
Make sure you have added your elements to a bin or pipeline with
gst_bin_add()
before trying to link them.
src |
a GstElement containing the source pad. |
[transfer none] |
dest |
the GstElement containing the destination pad. |
[transfer none] |
void gst_element_unlink (GstElement *src
,GstElement *dest
);
Unlinks all source pads of the source element with all sink pads of the sink element to which they are linked.
If the link has been made using gst_element_link()
, it could have created an
requestpad, which has to be released using gst_element_release_request_pad()
.
src |
the source GstElement to unlink. |
[transfer none] |
dest |
the sink GstElement to unlink. |
[transfer none] |
gboolean gst_element_link_many (GstElement *element_1
,GstElement *element_2
,...
);
Chain together a series of elements. Uses gst_element_link()
.
Make sure you have added your elements to a bin or pipeline with
gst_bin_add()
before trying to link them.
element_1 |
the first GstElement in the link chain. |
[transfer none] |
element_2 |
the second GstElement in the link chain. |
[transfer none] |
... |
the |
void gst_element_unlink_many (GstElement *element_1
,GstElement *element_2
,...
);
Unlinks a series of elements. Uses gst_element_unlink()
.
element_1 |
the first GstElement in the link chain. |
[transfer none] |
element_2 |
the second GstElement in the link chain. |
[transfer none] |
... |
the |
gboolean gst_element_link_pads (GstElement *src
,const gchar *srcpadname
,GstElement *dest
,const gchar *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.
src |
a GstElement containing the source pad. |
|
srcpadname |
the name of the GstPad in source element
or |
[allow-none] |
dest |
the GstElement containing the destination pad. |
[transfer none] |
destpadname |
the name of the GstPad in destination element,
or |
[allow-none] |
gboolean gst_element_link_pads_full (GstElement *src
,const gchar *srcpadname
,GstElement *dest
,const gchar *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.
Calling gst_element_link_pads_full()
with flags
== GST_PAD_LINK_CHECK_DEFAULT
is the same as calling gst_element_link_pads()
and the recommended way of
linking pads with safety checks applied.
This is a convenience function for gst_pad_link_full()
.
src |
a GstElement containing the source pad. |
|
srcpadname |
the name of the GstPad in source element
or |
[allow-none] |
dest |
the GstElement containing the destination pad. |
[transfer none] |
destpadname |
the name of the GstPad in destination element,
or |
[allow-none] |
flags |
the GstPadLinkCheck to be performed when linking pads. |
void gst_element_unlink_pads (GstElement *src
,const gchar *srcpadname
,GstElement *dest
,const gchar *destpadname
);
Unlinks the two named pads of the source and destination elements.
This is a convenience function for gst_pad_unlink()
.
src |
a (transfer none): GstElement containing the source pad. |
|
srcpadname |
the name of the GstPad in source element. |
|
dest |
a GstElement containing the destination pad. |
[transfer none] |
destpadname |
the name of the GstPad in destination element. |
gboolean gst_element_link_pads_filtered (GstElement *src
,const gchar *srcpadname
,GstElement *dest
,const gchar *destpadname
,GstCaps *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
.
src |
a GstElement containing the source pad. |
|
srcpadname |
the name of the GstPad in source element
or |
[allow-none] |
dest |
the GstElement containing the destination pad. |
[transfer none] |
destpadname |
the name of the GstPad in destination element
or |
[allow-none] |
filter |
[transfer none][allow-none] |
gboolean gst_element_link_filtered (GstElement *src
,GstElement *dest
,GstCaps *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.
Make sure you have added your elements to a bin or pipeline with
gst_bin_add()
before trying to link them.
src |
a GstElement containing the source pad. |
|
dest |
the GstElement containing the destination pad. |
[transfer none] |
filter |
[transfer none][allow-none] |
const gchar * gst_element_class_get_metadata (GstElementClass *klass
,const gchar *key
);
Get metadata with key
in klass
.
void gst_element_set_base_time (GstElement *element
,GstClockTime time
);
Set the base time of an element. See gst_element_get_base_time()
.
MT safe.
GstClockTime
gst_element_get_base_time (GstElement *element
);
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.
void gst_element_set_start_time (GstElement *element
,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.
Toplevel elements like GstPipeline will manage the start_time and base_time on its children. Setting the start_time to GST_CLOCK_TIME_NONE on such a toplevel element will disable the distribution of the base_time to the children and can be useful if the application manages the base_time itself, for example if you want to synchronize capture from multiple pipelines, and you can also ensure that the pipelines have the same clock.
MT safe.
GstClockTime
gst_element_get_start_time (GstElement *element
);
Returns the start time of the element. The start time is the running time of the clock when this element was last put to PAUSED.
Usually the start_time is managed by a toplevel element such as GstPipeline.
MT safe.
void gst_element_set_bus (GstElement *element
,GstBus *bus
);
Sets the bus of the element. Increases the refcount on the bus. For internal use only, unless you're testing elements.
MT safe.
GstBus *
gst_element_get_bus (GstElement *element
);
Returns the bus of the element. Note that only a GstPipeline will provide a bus for the application.
void gst_element_set_context (GstElement *element
,GstContext *context
);
Sets the context of the element. Increases the refcount of the context.
MT safe.
element |
a GstElement to set the context of. |
|
context |
the GstContext to set. |
[transfer none] |
GstContext * gst_element_get_context (GstElement *element
,const gchar *context_type
);
Gets the context with context_type
set on the element or NULL.
MT safe.
Since: 1.8
GstContext * gst_element_get_context_unlocked (GstElement *element
,const gchar *context_type
);
Gets the context with context_type
set on the element or NULL.
Since: 1.8
GList *
gst_element_get_contexts (GstElement *element
);
Gets the contexts set on the element.
MT safe.
Since: 1.8
GstElementFactory *
gst_element_get_factory (GstElement *element
);
Retrieves the factory that was used to create this element.
the GstElementFactory used for creating this element. no refcounting is needed.
[transfer none]
#define gst_element_set_name(elem,name) gst_object_set_name(GST_OBJECT_CAST(elem),name)
Sets the name of the element, getting rid of the old name if there was one.
#define gst_element_get_name(elem) gst_object_get_name(GST_OBJECT_CAST(elem))
Returns a copy of the name of elem
.
Caller should g_free()
the return value after usage.
For a nameless element, this returns NULL
, which you can safely g_free()
as well.
#define gst_element_set_parent(elem,parent) gst_object_set_parent(GST_OBJECT_CAST(elem),parent)
Sets the parent of an element.
#define gst_element_get_parent(elem) gst_object_get_parent(GST_OBJECT_CAST(elem))
Get the parent of an element.
gboolean gst_element_set_clock (GstElement *element
,GstClock *clock
);
Sets the clock for the element. This function increases the refcount on the clock. Any previously set clock on the object is unreffed.
TRUE
if the element accepted the clock. An element can refuse a
clock when it, for example, is not able to slave its internal clock to the
clock
or when it requires a specific clock to operate.
MT safe.
GstClock *
gst_element_get_clock (GstElement *element
);
Gets the currently configured clock of the element. This is the clock as was
last set with gst_element_set_clock()
.
Elements in a pipeline will only have their clock set when the pipeline is in the PLAYING state.
GstClock *
gst_element_provide_clock (GstElement *element
);
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.
the GstClock provided by the
element or NULL
if no clock could be provided. Unref after usage.
MT safe.
[transfer full][nullable]
GstStateChangeReturn gst_element_set_state (GstElement *element
,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.
This function can return GST_STATE_CHANGE_ASYNC, in which case the
element will perform the remainder of the state change asynchronously in
another thread.
An application can use gst_element_get_state()
to wait for the completion
of the state change or it can wait for a GST_MESSAGE_ASYNC_DONE
or
GST_MESSAGE_STATE_CHANGED
on the bus.
State changes to GST_STATE_READY
or GST_STATE_NULL
never return
GST_STATE_CHANGE_ASYNC.
GstStateChangeReturn gst_element_get_state (GstElement *element
,GstState *state
,GstState *pending
,GstClockTime timeout
);
Gets the state of the element.
For elements that performed an ASYNC state change, as reported by
gst_element_set_state()
, this function will block up to the
specified timeout value for the state change to complete.
If the element completes the state change or goes into
an error, this function returns immediately with a return value of
GST_STATE_CHANGE_SUCCESS
or GST_STATE_CHANGE_FAILURE
respectively.
For elements that did not return GST_STATE_CHANGE_ASYNC
, this function
returns the current and pending state immediately.
This function returns GST_STATE_CHANGE_NO_PREROLL
if the element
successfully changed its state but is not able to provide data yet.
This mostly happens for live sources that only produce data in
GST_STATE_PLAYING
. While the state change return is equivalent to
GST_STATE_CHANGE_SUCCESS
, it is returned to the application to signal that
some sink elements might not be able to complete their state change because
an element is not producing data to complete the preroll. When setting the
element to playing, the preroll will complete and playback will start.
element |
a GstElement to get the state of. |
|
state |
[out][allow-none] | |
pending |
a pointer to GstState to hold the pending
state. Can be |
[out][allow-none] |
timeout |
a GstClockTime to specify the timeout for an async
state change or |
GST_STATE_CHANGE_SUCCESS
if the element has no more pending state
and the last state change succeeded, GST_STATE_CHANGE_ASYNC
if the
element is still performing a state change or
GST_STATE_CHANGE_FAILURE
if the last state change failed.
MT safe.
gboolean gst_element_set_locked_state (GstElement *element
,gboolean locked_state
);
Locks the state of an element, so state changes of the parent don't affect this element anymore.
MT safe.
gboolean
gst_element_is_locked_state (GstElement *element
);
Checks if the state of an element is locked. If the state of an element is locked, state changes of the parent don't affect the element. This way you can leave currently unused elements inside bins. Just lock their state before changing the state from GST_STATE_NULL.
MT safe.
void
gst_element_abort_state (GstElement *element
);
Abort the state change of the element. This function is used by elements that do asynchronous state changes and find out something is wrong.
This function should be called with the STATE_LOCK held.
MT safe.
GstStateChangeReturn gst_element_continue_state (GstElement *element
,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.
If after calling this method the element still has not reached the pending state, the next state change is performed.
This method is used internally and should normally not be called by plugins or applications.
element |
a GstElement to continue the state change of. |
|
ret |
The previous state return value |
void
gst_element_lost_state (GstElement *element
);
Brings the element to the lost state. The current state of the
element is copied to the pending state so that any call to
gst_element_get_state()
will return GST_STATE_CHANGE_ASYNC
.
An ASYNC_START message is posted. If the element was PLAYING, it will go to PAUSED. The element will be restored to its PLAYING state by the parent pipeline when it prerolls again.
This is mostly used for elements that lost their preroll buffer
in the GST_STATE_PAUSED
or GST_STATE_PLAYING
state after a flush,
they will go to their pending state again when a new preroll buffer is
queued. This function can only be called when the element is currently
not in error or an async state change.
This function is used internally and should normally not be called from plugins or applications.
const gchar *
gst_element_state_get_name (GstState state
);
Gets a string representing the given state.
const gchar *
gst_element_state_change_return_get_name
(GstStateChangeReturn state_ret
);
Gets a string representing the given state change result.
gboolean
gst_element_sync_state_with_parent (GstElement *element
);
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.
GstStateChangeReturn gst_element_change_state (GstElement *element
,GstStateChange transition
);
Perform transition
on element
.
This function must be called with STATE_LOCK held and is mainly used internally.
void gst_element_message_full (GstElement *element
,GstMessageType type
,GQuark domain
,gint code
,gchar *text
,gchar *debug
,const gchar *file
,const gchar *function
,gint line
);
Post an error, warning or info message on the bus from inside an element.
type
must be of GST_MESSAGE_ERROR, GST_MESSAGE_WARNING or
GST_MESSAGE_INFO.
MT safe.
element |
a GstElement to send message from |
|
type |
the GstMessageType |
|
domain |
the GStreamer GError domain this message belongs to |
|
code |
the GError code belonging to the domain |
|
text |
an allocated text string to be used
as a replacement for the default message connected to code,
or |
[allow-none][transfer full] |
debug |
an allocated debug message to be
used as a replacement for the default debugging information,
or |
[allow-none][transfer full] |
file |
the source code file where the error was generated |
|
function |
the source code function where the error was generated |
|
line |
the source code line where the error was generated |
void gst_element_message_full_with_details (GstElement *element
,GstMessageType type
,GQuark domain
,gint code
,gchar *text
,gchar *debug
,const gchar *file
,const gchar *function
,gint line
,GstStructure *structure
);
Post an error, warning or info message on the bus from inside an element.
type
must be of GST_MESSAGE_ERROR, GST_MESSAGE_WARNING or
GST_MESSAGE_INFO.
element |
a GstElement to send message from |
|
type |
the GstMessageType |
|
domain |
the GStreamer GError domain this message belongs to |
|
code |
the GError code belonging to the domain |
|
text |
an allocated text string to be used
as a replacement for the default message connected to code,
or |
[allow-none][transfer full] |
debug |
an allocated debug message to be
used as a replacement for the default debugging information,
or |
[allow-none][transfer full] |
file |
the source code file where the error was generated |
|
function |
the source code function where the error was generated |
|
line |
the source code line where the error was generated |
|
structure |
optional details structure. |
[transfer full] |
Since: 1.10
GstStructure * gst_make_element_message_details (const char *name
,...
);
gboolean gst_element_post_message (GstElement *element
,GstMessage *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.
gboolean gst_element_query (GstElement *element
,GstQuery *query
);
Performs a query on the given element.
For elements that don't implement a query handler, this function forwards the query to a random srcpad or to the peer of a random linked sinkpad of this element.
Please note that some queries might need a running pipeline to work.
gboolean gst_element_query_convert (GstElement *element
,GstFormat src_format
,gint64 src_val
,GstFormat dest_format
,gint64 *dest_val
);
Queries an element to convert src_val
in src_format
to dest_format
.
element |
a GstElement to invoke the convert query on. |
|
src_format |
a GstFormat to convert from. |
|
src_val |
a value to convert. |
|
dest_format |
the GstFormat to convert to. |
|
dest_val |
a pointer to the result. |
[out] |
gboolean gst_element_query_position (GstElement *element
,GstFormat format
,gint64 *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.
If one repeatedly calls this function one can also create a query and reuse
it in gst_element_query()
.
element |
a GstElement to invoke the position query on. |
|
format |
the GstFormat requested |
|
cur |
a location in which to store the current
position, or |
[out][allow-none] |
gboolean gst_element_query_duration (GstElement *element
,GstFormat format
,gint64 *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.
If the duration changes for some reason, you will get a DURATION_CHANGED message on the pipeline bus, in which case you should re-query the duration using this function.
element |
a GstElement to invoke the duration query on. |
|
format |
the GstFormat requested |
|
duration |
A location in which to store the total duration, or |
[out][allow-none] |
gboolean gst_element_send_event (GstElement *element
,GstEvent *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.
This function takes ownership of the provided event so you should
gst_event_ref()
it if you want to reuse the event after this call.
MT safe.
element |
a GstElement to send the event to. |
|
event |
the GstEvent to send to the element. |
[transfer full] |
TRUE
if the event was handled. Events that trigger a preroll (such
as flushing seeks and steps) will emit GST_MESSAGE_ASYNC_DONE
.
gboolean gst_element_seek_simple (GstElement *element
,GstFormat format
,GstSeekFlags 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. For more complex
operations like segment seeks (e.g. for looping) or changing the playback
rate or seeking relative to the last configured playback segment you should
use gst_element_seek()
.
In a completely prerolled PAUSED or PLAYING pipeline, seeking is always
guaranteed to return TRUE
on a seekable media type or FALSE
when the media
type is certainly not seekable (such as a live stream).
Some elements allow for seeking in the READY state, in this
case they will store the seek event and execute it when they are put to
PAUSED. If the element supports seek in READY, it will always return TRUE
when
it receives the event in the READY state.
element |
a GstElement to seek on |
|
format |
a GstFormat to execute the seek in, such as GST_FORMAT_TIME |
|
seek_flags |
seek options; playback applications will usually want to use GST_SEEK_FLAG_FLUSH | GST_SEEK_FLAG_KEY_UNIT here |
|
seek_pos |
position to seek to (relative to the start); if you are doing a seek in GST_FORMAT_TIME this value is in nanoseconds - multiply with GST_SECOND to convert seconds to nanoseconds or with GST_MSECOND to convert milliseconds to nanoseconds. |
TRUE
if the seek operation succeeded. Flushing seeks will trigger a
preroll, which will emit GST_MESSAGE_ASYNC_DONE
.
gboolean gst_element_seek (GstElement *element
,gdouble rate
,GstFormat format
,GstSeekFlags flags
,GstSeekType start_type
,gint64 start
,GstSeekType stop_type
,gint64 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()
.
MT safe.
element |
a GstElement to send the event to. |
|
rate |
The new playback rate |
|
format |
The format of the seek values |
|
flags |
The optional seek flags. |
|
start_type |
The type and flags for the new start position |
|
start |
The value of the new start position |
|
stop_type |
The type and flags for the new stop position |
|
stop |
The value of the new stop position |
TRUE
if the event was handled. Flushing seeks will trigger a
preroll, which will emit GST_MESSAGE_ASYNC_DONE
.
gulong gst_element_add_property_notify_watch (GstElement *element
,const gchar *property_name
,gboolean include_value
);
element |
a GstElement to watch for property changes |
|
property_name |
name of property to watch for changes, or NULL to watch all properties. |
[allow-none] |
include_value |
whether to include the new property value in the message |
a watch id, which can be used in connection with
gst_element_remove_property_notify_watch()
to remove the watch again.
Since: 1.10
gulong gst_element_add_property_deep_notify_watch (GstElement *element
,const gchar *property_name
,gboolean include_value
);
element |
a GstElement to watch (recursively) for property changes |
|
property_name |
name of property to watch for changes, or NULL to watch all properties. |
[allow-none] |
include_value |
whether to include the new property value in the message |
a watch id, which can be used in connection with
gst_element_remove_property_notify_watch()
to remove the watch again.
Since: 1.10
void gst_element_remove_property_notify_watch (GstElement *element
,gulong watch_id
);
Since: 1.10
void (*GstElementCallAsyncFunc) (GstElement *element
,gpointer user_data
);
void gst_element_call_async (GstElement *element
,GstElementCallAsyncFunc func
,gpointer user_data
,GDestroyNotify destroy_notify
);
Calls func
from another thread and passes user_data
to it. This is to be
used for cases when a state change has to be performed from a streaming
thread, directly via gst_element_set_state()
or indirectly e.g. via SEEK
events.
Calling those functions directly from the streaming thread will cause deadlocks in many situations, as they might involve waiting for the streaming thread to shut down from this very streaming thread.
MT safe.
element |
||
func |
Function to call asynchronously from another thread |
|
user_data |
Data to pass to |
|
destroy_notify |
GDestroyNotify for |
Since: 1.10
struct GstElement { GRecMutex state_lock; /* element state */ GCond state_cond; guint32 state_cookie; GstState target_state; GstState current_state; GstState next_state; GstState pending_state; GstStateChangeReturn last_return; GstBus *bus; /* allocated clock */ GstClock *clock; GstClockTimeDiff base_time; /* NULL/READY: 0 - PAUSED: current time - PLAYING: difference to clock */ GstClockTime start_time; /* element pads, these lists can only be iterated while holding * the LOCK or checking the cookie after each LOCK. */ guint16 numpads; GList *pads; guint16 numsrcpads; GList *srcpads; guint16 numsinkpads; GList *sinkpads; guint32 pads_cookie; /* with object LOCK */ GList *contexts; };
GStreamer element abstract base class.
GRecMutex |
Used to serialize execution of |
|
GCond |
Used to signal completion of a state change |
|
guint32 |
Used to detect concurrent execution of
|
|
GstState |
the target state of an element as set by the application |
|
GstState |
the current state of an element |
|
GstState |
the next state of an element, can be GST_STATE_VOID_PENDING if the element is in the correct state. |
|
GstState |
the final state the element should go to, can be GST_STATE_VOID_PENDING if the element is in the correct state |
|
GstStateChangeReturn |
the last return value of an element state change |
|
GstBus * |
the bus of the element. This bus is provided to the element by the parent element or the application. A GstPipeline has a bus of its own. |
|
GstClock * |
the clock of the element. This clock is usually provided to the element by the toplevel GstPipeline. |
|
GstClockTimeDiff |
the time of the clock right before the element is set to
PLAYING. Subtracting |
|
GstClockTime |
the running_time of the last PAUSED state |
|
guint16 |
number of pads of the element, includes both source and sink pads. |
|
GList * |
list of pads. |
[element-type Gst.Pad] |
guint16 |
number of source pads of the element. |
|
GList * |
list of source pads. |
[element-type Gst.Pad] |
guint16 |
number of sink pads of the element. |
|
GList * |
list of sink pads. |
[element-type Gst.Pad] |
guint32 |
updated whenever the a pad is added or removed |
|
GList * |
list of contexts. |
[element-type Gst.Context] |
struct GstElementClass { GstObjectClass parent_class; /* the element metadata */ gpointer metadata; /* factory that the element was created from */ GstElementFactory *elementfactory; /* templates for our pads */ GList *padtemplates; gint numpadtemplates; guint32 pad_templ_cookie; /* virtual methods for subclasses */ /* request/release pads */ /* FIXME 2.0 harmonize naming with gst_element_request_pad */ GstPad* (*request_new_pad) (GstElement *element, GstPadTemplate *templ, const gchar* name, const GstCaps *caps); void (*release_pad) (GstElement *element, GstPad *pad); /* state changes */ GstStateChangeReturn (*get_state) (GstElement * element, GstState * state, GstState * pending, GstClockTime timeout); GstStateChangeReturn (*set_state) (GstElement *element, GstState state); GstStateChangeReturn (*change_state) (GstElement *element, GstStateChange transition); void (*state_changed) (GstElement *element, GstState oldstate, GstState newstate, GstState pending); /* bus */ void (*set_bus) (GstElement * element, GstBus * bus); /* set/get clocks */ GstClock* (*provide_clock) (GstElement *element); gboolean (*set_clock) (GstElement *element, GstClock *clock); /* query functions */ gboolean (*send_event) (GstElement *element, GstEvent *event); gboolean (*query) (GstElement *element, GstQuery *query); gboolean (*post_message) (GstElement *element, GstMessage *message); void (*set_context) (GstElement *element, GstContext *context); };
GStreamer element class. Override the vmethods to implement the element functionality.
gpointer |
metadata for elements of this class |
|
GstElementFactory * |
the GstElementFactory that creates these elements |
|
GList * |
a GList of GstPadTemplate |
|
gint |
the number of padtemplates |
|
guint32 |
changed whenever the padtemplates change |
|
called when a new pad is requested |
||
called when a request pad is to be released |
||
get the state of the element |
||
set a new state on the element |
||
called by |
||
called immediately after a new state was set. |
||
set a GstBus on the element |
||
gets the GstClock provided by the element |
||
set the GstClock on the element |
||
send a GstEvent to the element |
||
perform a GstQuery on the element |
||
called when a message is posted on the element. Chain up to the parent class' handler to have it posted on the bus. |
||
set a GstContext on the element |
The standard flags that an element may have.
The possible states an element can be in. States can be changed using
gst_element_set_state()
and checked using gst_element_get_state()
.
no pending state. |
||
the NULL state or initial state of an element. |
||
the element is ready to go to PAUSED. |
||
the element is PAUSED, it is ready to accept and process data. Sink elements however only accept one buffer and then block. |
||
the element is PLAYING, the GstClock is running and the data is flowing. |
These are the different state changes an element goes through.
GST_STATE_NULL
⇒ GST_STATE_PLAYING
is called an upwards state change
and GST_STATE_PLAYING
⇒ GST_STATE_NULL
a downwards state change.
state change from NULL to READY.
|
||
state change from READY to PAUSED.
|
||
state change from PAUSED to PLAYING.
|
||
state change from PLAYING to PAUSED.
|
||
state change from PAUSED to READY.
|
||
state change from READY to NULL.
|
The possible return values from a state change function such as
gst_element_set_state()
. Only GST_STATE_CHANGE_FAILURE
is a real failure.
the state change failed |
||
the state change succeeded |
||
the state change will happen asynchronously |
||
the state change succeeded but the element
cannot produce data in |
#define GST_ELEMENT_METADATA_AUTHOR "author"
Name and contact details of the author(s). Use \n to separate multiple author details. E.g: "Joe Bloggs <joe.blogs at foo.com>"
#define GST_ELEMENT_METADATA_DESCRIPTION "description"
Sentence describing the purpose of the element. E.g: "Write stream to a file"
#define GST_ELEMENT_METADATA_DOC_URI "doc-uri"
Set uri pointing to user documentation. Applications can use this to show help for e.g. effects to users.
#define GST_ELEMENT_METADATA_ICON_NAME "icon-name"
Elements that bridge to certain other products can include an icon of that used product. Application can show the icon in menus/selectors to help identifying specific elements.
#define GST_ELEMENT_METADATA_KLASS "klass"
String describing the type of element, as an unordered list separated with slashes ('/'). See draft-klass.txt of the design docs for more details and common types. E.g: "Sink/File"
“no-more-pads”
signalvoid user_function (GstElement *gstelement, gpointer user_data)
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.
gstelement |
the object which received the signal |
|
user_data |
user data set when the signal handler was connected. |
Flags: Run Last
“pad-added”
signalvoid user_function (GstElement *gstelement, GstPad *new_pad, gpointer user_data)
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()
.
gstelement |
the object which received the signal |
|
new_pad |
the pad that has been added |
|
user_data |
user data set when the signal handler was connected. |
Flags: Run Last
“pad-removed”
signalvoid user_function (GstElement *gstelement, GstPad *old_pad, gpointer user_data)
a GstPad has been removed from the element
gstelement |
the object which received the signal |
|
old_pad |
the pad that has been removed |
|
user_data |
user data set when the signal handler was connected. |
Flags: Run Last