QGroundControl
Ground Control Station for MAVLink Drones
Loading...
Searching...
No Matches
GstBusPump Class Reference

A pipeline's bus, handled from the thread the pump lives on. More...

#include <GstBusPump.h>

Inheritance diagram for GstBusPump:
Collaboration diagram for GstBusPump:

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)

Detailed Description

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.

Member Typedef Documentation

◆ Handler

using GstBusPump::Handler = std::function<void(GstMessage* message)>

The pump's thread.

Definition at line 27 of file GstBusPump.h.

◆ SyncHandler

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.

Constructor & Destructor Documentation

◆ GstBusPump()

GstBusPump::GstBusPump ( QObject * parent = nullptr)
explicit

Definition at line 14 of file GstBusPump.cc.

◆ ~GstBusPump()

GstBusPump::~GstBusPump ( )
override

detach()es.

Definition at line 18 of file GstBusPump.cc.

References detach().

Member Function Documentation

◆ attach()

bool GstBusPump::attach ( GstElement * pipeline,
SyncHandler syncHandler,
Handler handler )
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().

◆ detach()

void GstBusPump::detach ( )

Idempotent.

Definition at line 52 of file GstBusPump.cc.

Referenced by attach(), and ~GstBusPump().

◆ drain()

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

◆ pop()

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

◆ pumpUntil()

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


The documentation for this class was generated from the following files: