mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-12-24 17:20:36 +00:00
pwg: add section about query function
This commit is contained in:
parent
3f3473772f
commit
626fcb3707
3 changed files with 82 additions and 2 deletions
|
@ -378,6 +378,7 @@ gst_my_filter_init (GstMyFilter * filter)
|
|||
correct template would look like this:
|
||||
</para>
|
||||
<programlisting>
|
||||
<![CDATA[
|
||||
static GstStaticPadTemplate sink_factory =
|
||||
GST_STATIC_PAD_TEMPLATE (
|
||||
"sink",
|
||||
|
@ -390,6 +391,7 @@ GST_STATIC_PAD_TEMPLATE (
|
|||
"rate = (int) [ 8000, 96000 ]"
|
||||
)
|
||||
);
|
||||
]]>
|
||||
</programlisting>
|
||||
<para>
|
||||
Values surrounded by curly brackets (<quote>{</quote> and
|
||||
|
@ -428,7 +430,9 @@ GST_STATIC_PAD_TEMPLATE (
|
|||
Also, in this function, any supported element type in the plugin should
|
||||
be registered.
|
||||
</para>
|
||||
<programlisting><!-- example-begin register.func -->
|
||||
<programlisting>
|
||||
<!-- example-begin register.func -->
|
||||
<![CDATA[
|
||||
static gboolean
|
||||
plugin_init (GstPlugin *plugin)
|
||||
{
|
||||
|
@ -448,7 +452,9 @@ GST_PLUGIN_DEFINE (
|
|||
"GStreamer",
|
||||
"http://gstreamer.net/"
|
||||
)
|
||||
<!-- example-end register.func --></programlisting>
|
||||
]]>
|
||||
<!-- example-end register.func -->
|
||||
</programlisting>
|
||||
<para>
|
||||
Note that the information returned by the plugin_init() function will be
|
||||
cached in a central registry. For this reason, it is important that the
|
||||
|
|
72
docs/pwg/building-queryfn.xml
Normal file
72
docs/pwg/building-queryfn.xml
Normal file
|
@ -0,0 +1,72 @@
|
|||
|
||||
<!-- ############ chapter ############# -->
|
||||
|
||||
<chapter id="chapter-building-queryfn">
|
||||
<title>The query function</title>
|
||||
<para>
|
||||
Through the query function, your element will receive queries that it
|
||||
has to reply to. These are queries like position, duration but also
|
||||
about the supported formats and scheduling modes your element supports.
|
||||
Queries can travel both upstream and downstream, so you can receive them
|
||||
on sink pads as well as source pads.
|
||||
</para>
|
||||
<para>
|
||||
Below follows a very simple query function that we install on the source
|
||||
pad of our element.
|
||||
</para>
|
||||
<programlisting>
|
||||
<![CDATA[
|
||||
static gboolean gst_my_filter_src_query (GstPad *pad,
|
||||
GstObject *parent,
|
||||
GstQuery *query);
|
||||
|
||||
[..]
|
||||
|
||||
static void
|
||||
gst_my_filter_init (GstMyFilter * filter)
|
||||
{
|
||||
[..]
|
||||
/* configure event function on the pad before adding
|
||||
* the pad to the element */
|
||||
gst_pad_set_event_function (filter->srcpad,
|
||||
gst_my_filter_src_event);
|
||||
[..]
|
||||
}
|
||||
|
||||
static gboolean
|
||||
gst_my_filter_src_query (GstPad *pad,
|
||||
GstObject *parent,
|
||||
GstQuery *query)
|
||||
{
|
||||
gboolean ret;
|
||||
GstMyFilter *filter = GST_MY_FILTER (parent);
|
||||
|
||||
switch (GST_QUERY_TYPE (query)) {
|
||||
case GST_QUERY_POSITION:
|
||||
/* we should report the current position */
|
||||
[...]
|
||||
break;
|
||||
case GST_QUERY_DURATION:
|
||||
/* we should report the duration here */
|
||||
[...]
|
||||
break;
|
||||
case GST_QUERY_CAPS:
|
||||
/* we should report the supported caps here */
|
||||
[...]
|
||||
break;
|
||||
default:
|
||||
/* just call the default handler */
|
||||
ret = gst_pad_query_default (pad, parent, query);
|
||||
break;
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
]]>
|
||||
</programlisting>
|
||||
<para>
|
||||
It is a good idea to call the default query handler
|
||||
<function>gst_pad_query_default ()</function> for unknown queries.
|
||||
Depending on the query type, the default handler will forward
|
||||
the query or simply unref it.
|
||||
</para>
|
||||
</chapter>
|
|
@ -18,6 +18,7 @@
|
|||
<!ENTITY BUILDING_PADS SYSTEM "building-pads.xml">
|
||||
<!ENTITY BUILDING_CHAINFN SYSTEM "building-chainfn.xml">
|
||||
<!ENTITY BUILDING_EVENTFN SYSTEM "building-eventfn.xml">
|
||||
<!ENTITY BUILDING_QUERYFN SYSTEM "building-queryfn.xml">
|
||||
<!ENTITY BUILDING_STATE SYSTEM "building-state.xml">
|
||||
<!ENTITY BUILDING_PROPS SYSTEM "building-props.xml">
|
||||
<!ENTITY BUILDING_SIGNALS SYSTEM "building-signals.xml">
|
||||
|
@ -120,6 +121,7 @@
|
|||
&BUILDING_PADS;
|
||||
&BUILDING_CHAINFN;
|
||||
&BUILDING_EVENTFN;
|
||||
&BUILDING_QUERYFN;
|
||||
&BUILDING_STATE;
|
||||
&BUILDING_PROPS;
|
||||
&BUILDING_SIGNALS;
|
||||
|
|
Loading…
Reference in a new issue