What is the purpose of action signals vs. queries in gstreamer?

Viewed 840

For some informations about gstreamer elements I have to emit a query like

gst_element_query_position (data.playbin, GST_FORMAT_TIME, &current)

(from basic tutorial 4)

while for others I have to emit an action signal like

g_signal_emit_by_name (data->playbin, "get-video-tags", i, &tags)

(from playback tutorial 1).

What is the reason for that? Aren't both doing the same kind of thing, asking the element for some information and waiting for the answer (blocking/synchronously)? For me it seems that queries are exactly for that, as explained in the chapter "Foundations" and the picture below.

But how do action signals fit into that picture? Are they a combination of event (for request) and message (for response) or also just queries? And most importantly: Why do they exist when there are already queries?

Thanks for your time and knowledge.


Gstreamer Communication

1 Answers

As @vk_gst mentioned in the comment, queries are synchronous but signals (events) are not. The purpose of query is to get some information from pipeline whereas the purpose of event is to tell the pipeline to take some action for given condition/requirement. Example: You can query for bitrate of the stream. But you have to send signal (event) for playback seek.

In other words, query is for requesting some information and event is for notification. If an element sends a query, it expects some output apart from success/failure status. But if an element sends an event, it expects only success/failure status. How that event is processed is left to other element which has received it.

Related