A pipeline's bus, handled from the thread the pump lives on. More...
#include <GstBusPump.h>
Public Types | |
| using | SyncHandler = std::function<GstBusSyncReply(GstMessage* message)> |
| Posting threads. Returns GST_BUS_DROP for a message it took (and unreffed), GST_BUS_PASS to queue it. | |
| using | Handler = std::function<void(GstMessage* message)> |
| The pump's thread. | |
Public Member Functions | |
| GstBusPump (QObject *parent=nullptr) | |
| ~GstBusPump () override | |
| detach()es. | |
| bool | attach (GstElement *pipeline, SyncHandler syncHandler, Handler handler) |
| void | detach () |
| Idempotent. | |
| void | drain () |
| Handles the messages queued now, as the poll fd does. | |
| void | pumpUntil (GstMessageType types, const std::function< bool()> &done, const QDeadlineTimer &deadline) |
| GStreamer::GstMessagePtr | pop (GstMessageType type) |
A pipeline's bus, handled from the thread the pump lives on.
A sync handler runs on the posting thread for what can't wait; every other message is popped on the pump's thread, which the bus's poll fd wakes up, as Qt's QGstBusObserver does. detach() removes the sync handler, waits until no call into it is in flight and flushes what is still queued: nothing the pipeline posts reaches either handler afterwards.
Definition at line 19 of file GstBusPump.h.
| using GstBusPump::Handler = std::function<void(GstMessage* message)> |
The pump's thread.
Definition at line 27 of file GstBusPump.h.
| using GstBusPump::SyncHandler = std::function<GstBusSyncReply(GstMessage* message)> |
Posting threads. Returns GST_BUS_DROP for a message it took (and unreffed), GST_BUS_PASS to queue it.
Definition at line 25 of file GstBusPump.h.
|
explicit |
Definition at line 14 of file GstBusPump.cc.
|
override |
|
nodiscard |
Watches pipeline's bus. The sync handler is installed before anything can post, so it sees every message. False, logged, when the pipeline has no bus.
Definition at line 23 of file GstBusPump.cc.
References GStreamer::adoptBus(), detach(), and drain().
| void GstBusPump::detach | ( | ) |
| void GstBusPump::drain | ( | ) |
Handles the messages queued now, as the poll fd does.
Definition at line 72 of file GstBusPump.cc.
References GStreamer::adoptMessage().
Referenced by attach().
| GStreamer::GstMessagePtr GstBusPump::pop | ( | GstMessageType | type | ) |
Pops the oldest queued message of type, unhandled; null when there is none. Discards the messages of other types queued before it, or the whole queue when it holds none of type (gst_bus_pop_filtered()): only for a caller that gives up on the pipeline.
Definition at line 95 of file GstBusPump.cc.
References GStreamer::adoptMessage().
| void GstBusPump::pumpUntil | ( | GstMessageType | types, |
| const std::function< bool()> & | done, | ||
| const QDeadlineTimer & | deadline ) |
Handles the messages of types until done() or deadline, waiting for them. Messages of any other type, queued before or posted meanwhile, are discarded without reaching the handler (gst_bus_timed_pop_filtered()): only for a caller that no longer acts on them, as a session that is tearing down.
Definition at line 83 of file GstBusPump.cc.
References GStreamer::adoptMessage().