RTP session for sending and receiving packets (RFC 3550). More...
#include <rtpsession.h>


Public Member Functions | |
| RtpSession (ObjectBase *parent=nullptr) | |
| Constructs an RtpSession. | |
| ~RtpSession () override | |
| Destructor. Stops the session if running. | |
| Error | start (const SocketAddress &localAddr) |
| Starts the session, binding to a local address. | |
| void | stop () |
| Stops the session and closes the socket. | |
| bool | isRunning () const |
| Returns true if the session is started. | |
| Error | sendPacket (const Buffer &payload, uint32_t timestamp, uint8_t payloadType, const SocketAddress &dest, bool marker=false) |
| Sends a single RTP packet with raw payload data. | |
| Error | sendPackets (RtpPacket::List &packets, uint32_t timestamp, const SocketAddress &dest, bool markerOnLast=true) |
| Sends pre-packed RTP packets from a payload handler. | |
| uint32_t | ssrc () const |
| Returns the locally generated SSRC. | |
| void | setSsrc (uint32_t ssrc) |
| Overrides the auto-generated SSRC. | |
| uint16_t | sequenceNumber () const |
| Returns the current sequence number. | |
| void | setPayloadType (uint8_t pt) |
| Sets the default payload type. | |
| uint8_t | payloadType () const |
| Returns the default payload type. | |
| void | setClockRate (uint32_t hz) |
| Sets the RTP timestamp clock rate in Hz. | |
| uint32_t | clockRate () const |
| Returns the RTP timestamp clock rate. | |
| UdpSocket * | socket () const |
| Returns the internal UDP socket. | |
| PROMEKI_SIGNAL (packetReceived, Buffer, uint32_t, uint8_t, bool) | |
| Emitted when a packet is received. | |
| PROMEKI_SIGNAL (ssrcCollision, uint32_t) | |
| Emitted when an SSRC collision is detected. | |
Public Member Functions inherited from ObjectBase | |
| ObjectBase (ObjectBase *p=nullptr) | |
| Default ObjectBase constructor. | |
| virtual | ~ObjectBase () |
| Destructor. Emits aboutToDestroy, detaches from parent, and destroys children. | |
| ObjectBase * | parent () const |
| Returns the parent object, if one. nullptr if none. | |
| void | setParent (ObjectBase *p) |
| Sets the parent of this object. If the object already has a parent, it will be removed as a child from the old parent and added as a child to the new one. | |
| const ObjectBaseList & | childList () const |
| Returns a list of children of this object. | |
| template<typename... Args> | |
| int | registerSlot (Slot< Args... > *slot) |
| Registers a slot with this object and assigns it an ID. | |
| EventLoop * | eventLoop () const |
| Returns the EventLoop this object is affiliated with. | |
| void | moveToThread (EventLoop *loop) |
| Changes the EventLoop affinity of this object. | |
| int | startTimer (unsigned int intervalMs, bool singleShot=false) |
| Starts a timer on this object's EventLoop. | |
| void | stopTimer (int timerId) |
| Stops a timer previously started with startTimer(). | |
| template<typename... Args> | |
| PROMEKI_NAMESPACE_BEGIN void | connect (Signal< Args... > *signal, Slot< Args... > *slot) |
Additional Inherited Members | |
Public Types inherited from ObjectBase | |
| using | SlotVariantFunc = std::function< void(const VariantList &)> |
| Function type for invoking a slot with a list of Variants. | |
Static Public Member Functions inherited from ObjectBase | |
| static const MetaInfo & | metaInfo () |
| Returns the MetaInfo for the ObjectBase class. | |
| template<typename... Args> | |
| static void | connect (Signal< Args... > *signal, Slot< Args... > *slot) |
| connects a signal and slot together. This function assumes both the signal and slot exist in a ObjectBase or derived object | |
Public Attributes inherited from ObjectBase | |
| Signal< ObjectBase * > | aboutToDestroySignal = Signal< ObjectBase * >(this, aboutToDestroySignalName) |
Static Public Attributes inherited from ObjectBase | |
| static constexpr const char * | aboutToDestroySignalName = PROMEKI_STRINGIFY( aboutToDestroy ) "(" PROMEKI_STRINGIFY_ARGS( ObjectBase * ) ")" |
| static SignalMeta | aboutToDestroySignalMeta = SignalMeta(metaInfo(), aboutToDestroySignalName) |
Protected Member Functions inherited from ObjectBase | |
| ObjectBase * | signalSender () |
| Returns the ObjectBase that emitted the signal currently being handled. | |
| virtual void | event (Event *e) |
| Called by EventLoop to deliver events to this object. | |
| virtual void | timerEvent (TimerEvent *e) |
| Called when a timer fires for this object. | |
RTP session for sending and receiving packets (RFC 3550).
RtpSession manages the RTP protocol state for a single synchronization source (SSRC). It handles RTP header construction, sequence number management, and timestamp tracking.
The session operates on pre-built RtpPacket lists from RtpPayload handlers. It fills in the RTP header fields (version, payload type, sequence number, timestamp, SSRC, marker bit) and transmits via a UdpSocket.
| RtpSession::RtpSession | ( | ObjectBase * | parent = nullptr | ) |
Constructs an RtpSession.
| parent | The parent object, or nullptr. |
| RtpSession::PROMEKI_SIGNAL | ( | packetReceived | , |
| Buffer | , | ||
| uint32_t | , | ||
| uint8_t | , | ||
| bool | |||
| ) |
| RtpSession::PROMEKI_SIGNAL | ( | ssrcCollision | , |
| uint32_t | |||
| ) |
Emitted when an SSRC collision is detected.
| Error RtpSession::sendPacket | ( | const Buffer & | payload, |
| uint32_t | timestamp, | ||
| uint8_t | payloadType, | ||
| const SocketAddress & | dest, | ||
| bool | marker = false |
||
| ) |
Sends a single RTP packet with raw payload data.
Constructs a complete RTP packet with header and sends it.
| payload | The payload data. |
| timestamp | The RTP timestamp for this packet. |
| payloadType | The RTP payload type. |
| dest | The destination address. |
| marker | If true, the marker bit is set. |
| Error RtpSession::sendPackets | ( | RtpPacket::List & | packets, |
| uint32_t | timestamp, | ||
| const SocketAddress & | dest, | ||
| bool | markerOnLast = true |
||
| ) |
Sends pre-packed RTP packets from a payload handler.
Fills in the RTP header fields on each packet and transmits. The marker bit is set on the last packet in the list (end of frame/access unit).
| packets | The pre-packed packet list. Modified in-place: RTP header fields are overwritten before transmission. |
| timestamp | The RTP timestamp for this frame. |
| dest | The destination address. |
| markerOnLast | If true, set marker bit on the last packet. |
|
inline |
Returns the internal UDP socket.
Use this to configure socket options (DSCP, multicast, etc.) after calling start().
| Error RtpSession::start | ( | const SocketAddress & | localAddr | ) |
Starts the session, binding to a local address.
Creates and opens the internal UDP socket, then binds it to the specified local address. Use port 0 to let the OS assign a port.
| localAddr | The local address and port to bind to. |