libpromeki main
PROfessional MEdia toolKIt
 
Loading...
Searching...
No Matches
RtpAudioSinkNode Class Reference

Terminal sink node that sends audio samples over RTP. More...

#include <rtpaudiosinknode.h>

Inheritance diagram for RtpAudioSinkNode:
Collaboration diagram for RtpAudioSinkNode:

Public Member Functions

 RtpAudioSinkNode (ObjectBase *parent=nullptr)
 Constructs an RtpAudioSinkNode.
 
 ~RtpAudioSinkNode () override
 Destructor.
 
void setPayloadType (uint8_t pt)
 Sets the RTP payload type number.
 
uint8_t payloadType () const
 Returns the RTP payload type.
 
void setClockRate (uint32_t hz)
 Sets the RTP timestamp clock rate.
 
uint32_t clockRate () const
 Returns the RTP clock rate.
 
void setPacketTime (double ptime)
 Sets the packet time in milliseconds.
 
double packetTime () const
 Returns the packet time in milliseconds.
 
void setOutputFormat (AudioDesc::DataType fmt)
 Sets the output sample format for RTP transmission.
 
AudioDesc::DataType outputFormat () const
 Returns the output sample format.
 
void setDscp (uint8_t dscp)
 Sets the DSCP value for QoS marking.
 
uint8_t dscp () const
 Returns the DSCP value.
 
Error configure () override
 Validates configuration and creates the RTP session.
 
Error start () override
 Starts the RTP session and begins accepting audio.
 
void stop () override
 Flushes remaining audio and stops the RTP session.
 
void process () override
 Accumulates audio samples and sends complete RTP packets.
 
void starvation () override
 Records an audio underrun event.
 
Map< String, VariantextendedStats () const override
 Returns audio sink statistics.
 
- Public Member Functions inherited from MediaNode
 MediaNode (ObjectBase *parent=nullptr)
 Constructs a MediaNode.
 
virtual ~MediaNode ()
 Virtual destructor.
 
State state () const
 Returns the current state.
 
const Stringname () const
 Returns the node name.
 
void setName (const String &name)
 Sets the node name.
 
const MediaPort::PtrListinputPorts () const
 Returns the list of input ports.
 
const MediaPort::PtrListoutputPorts () const
 Returns the list of output ports.
 
MediaPort::Ptr inputPort (int index) const
 Returns the input port at the given index.
 
MediaPort::Ptr outputPort (int index) const
 Returns the output port at the given index.
 
MediaPort::Ptr inputPort (const String &name) const
 Returns the input port with the given name.
 
MediaPort::Ptr outputPort (const String &name) const
 Returns the output port with the given name.
 
int inputPortCount () const
 Returns the number of input ports.
 
int outputPortCount () const
 Returns the number of output ports.
 
void setThreadingPolicy (ThreadingPolicy policy)
 Sets the threading policy.
 
void setThreadingPolicy (ThreadPool *pool)
 Sets a custom thread pool and switches policy to CustomPool.
 
ThreadingPolicy threadingPolicy () const
 Returns the current threading policy.
 
ThreadPoolcustomThreadPool () const
 Returns the custom thread pool, or nullptr if not using CustomPool.
 
void setIdealQueueSize (int size)
 Sets the ideal input queue depth.
 
int idealQueueSize () const
 Returns the ideal input queue size.
 
int queuedFrameCount () const
 Returns the current input queue depth.
 
virtual Map< String, Variantproperties () const
 Returns all configurable properties as key-value pairs.
 
virtual Error setProperty (const String &name, const Variant &value)
 Sets a property by name.
 
Variant property (const String &name) const
 Gets a single property value by name.
 
NodeStats stats () const
 Returns a snapshot of the node's performance statistics.
 
void resetStats ()
 Resets all statistics counters to zero.
 
 PROMEKI_SIGNAL (stateChanged, State)
 Emitted when the node's state changes.
 
 PROMEKI_SIGNAL (errorOccurred, Error)
 Emitted when an error occurs.
 
 PROMEKI_SIGNAL (messageEmitted, NodeMessage)
 Emitted when the node produces a message.
 
- Public Member Functions inherited from ObjectBase
 ObjectBase (ObjectBase *p=nullptr)
 Default ObjectBase constructor.
 
virtual ~ObjectBase ()
 Destructor. Emits aboutToDestroy, detaches from parent, and destroys children.
 
ObjectBaseparent () 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 ObjectBaseListchildList () 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.
 
EventLoopeventLoop () 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 MediaNode
enum  State { Idle , Configured , Running , ErrorState }
 Node lifecycle state. More...
 
enum  ThreadingPolicy { UseGraphPool , DedicatedThread , CustomPool }
 Threading policy for this node. More...
 
- 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 MediaNode
static void registerNodeType (const String &typeName, std::function< MediaNode *()> factory)
 Registers a node type for runtime creation.
 
static MediaNodecreateNode (const String &typeName)
 Creates a node by registered type name.
 
static List< StringregisteredNodeTypes ()
 Returns the list of all registered node type names.
 
- Static Public Member Functions inherited from ObjectBase
static const MetaInfometaInfo ()
 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 charaboutToDestroySignalName = PROMEKI_STRINGIFY( aboutToDestroy ) "(" PROMEKI_STRINGIFY_ARGS( ObjectBase * ) ")"
 
static SignalMeta aboutToDestroySignalMeta = SignalMeta(metaInfo(), aboutToDestroySignalName)
 
- Protected Member Functions inherited from MediaNode
void enqueueInput (Frame::Ptr frame)
 Enqueues a frame into this node's input queue.
 
void recordProcessTiming (double duration)
 Records timing for a process() call.
 
void recordStarvation ()
 Records a starvation event.
 
void addInputPort (MediaPort::Ptr port)
 Adds an input port to this node.
 
void addOutputPort (MediaPort::Ptr port)
 Adds an output port to this node.
 
void setState (State state)
 Sets the node state and emits stateChanged.
 
Frame::Ptr dequeueInput ()
 Dequeues a frame from this node's input queue.
 
void deliverOutput (int portIndex, Frame::Ptr frame)
 Delivers a frame to all outgoing links on the given output port.
 
void deliverOutput (Frame::Ptr frame)
 Delivers a frame to all outgoing links on all output ports.
 
void emitMessage (Severity severity, const String &message, uint64_t frameNumber=0)
 Emits a message with the given severity and text.
 
void emitWarning (const String &message)
 Emits a Warning-severity message.
 
void emitError (const String &message)
 Emits an Error-severity message.
 
- Protected Member Functions inherited from ObjectBase
ObjectBasesignalSender ()
 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.
 

Detailed Description

Terminal sink node that sends audio samples over RTP.

RtpAudioSinkNode is a terminal MediaNode with one Audio input and no outputs. It accumulates incoming audio samples and emits RTP packets at the configured packet time interval.

Unlike RtpVideoSinkNode, this node does not perform its own pacing. Audio packets are sent as soon as enough samples accumulate. In a typical vidgen pipeline the video sink is the timing authority, and audio flows at the rate frames arrive.

Example
RtpPayloadL24 payload(48000, 2);
sink->setDestination(SocketAddress(Ipv4Address("239.0.0.1"), 5006));
sink->setRtpPayload(&payload);
sink->setPacketTime(1.0); // 1ms AES67
sink->configure();
sink->start();
IPv4 network address.
Definition ipv4address.h:51
Terminal sink node that sends audio samples over RTP.
Definition rtpaudiosinknode.h:49
Error start() override
Starts the RTP session and begins accepting audio.
void setPacketTime(double ptime)
Sets the packet time in milliseconds.
Definition rtpaudiosinknode.h:107
Error configure() override
Validates configuration and creates the RTP session.
RTP payload handler for 24-bit linear audio (L24).
Definition rtppayload.h:96
Network address with port number.
Definition socketaddress.h:50

Constructor & Destructor Documentation

◆ RtpAudioSinkNode()

RtpAudioSinkNode::RtpAudioSinkNode ( ObjectBase parent = nullptr)

Constructs an RtpAudioSinkNode.

Parameters
parentOptional parent object.

Member Function Documentation

◆ configure()

Error RtpAudioSinkNode::configure ( )
overridevirtual

Validates configuration and creates the RTP session.

Checks that an RTP payload handler and destination address are set, computes samples-per-packet from the packet time and clock rate, and allocates the accumulation buffer.

Returns
Error::Ok on success, or Error::Invalid.

Reimplemented from MediaNode.

◆ extendedStats()

Map< String, Variant > RtpAudioSinkNode::extendedStats ( ) const
overridevirtual

Returns audio sink statistics.

Returns
A map containing packetsSent, samplesSent, and underrunCount.

Reimplemented from MediaNode.

◆ process()

void RtpAudioSinkNode::process ( )
overridevirtual

Accumulates audio samples and sends complete RTP packets.

Dequeues a Frame from the input port, optionally converts the audio to the configured output format, appends samples to the accumulation buffer, and sends packets when enough samples have accumulated.

Implements MediaNode.

◆ setClockRate()

void RtpAudioSinkNode::setClockRate ( uint32_t  hz)
inline

Sets the RTP timestamp clock rate.

Parameters
hzClock rate in Hz (default: 48000).

◆ setDscp()

void RtpAudioSinkNode::setDscp ( uint8_t  dscp)
inline

Sets the DSCP value for QoS marking.

Parameters
dscpDSCP value (default: 46, EF for real-time audio).

◆ setOutputFormat()

void RtpAudioSinkNode::setOutputFormat ( AudioDesc::DataType  fmt)
inline

Sets the output sample format for RTP transmission.

When set to a format other than AudioDesc::Invalid, incoming audio is automatically converted to this format before packing into RTP packets. For AES67/L24, use AudioDesc::PCMI_S24BE.

Parameters
fmtThe target AudioDesc::DataType.

◆ setPacketTime()

void RtpAudioSinkNode::setPacketTime ( double  ptime)
inline

Sets the packet time in milliseconds.

Parameters
ptimePacket time (default: 1.0ms for AES67).

◆ setPayloadType()

void RtpAudioSinkNode::setPayloadType ( uint8_t  pt)
inline

Sets the RTP payload type number.

Parameters
ptPayload type (default: 97).

◆ start()

Error RtpAudioSinkNode::start ( )
overridevirtual

Starts the RTP session and begins accepting audio.

Returns
Error::Ok on success, or an error if the session cannot start.

Reimplemented from MediaNode.

◆ starvation()

void RtpAudioSinkNode::starvation ( )
overridevirtual

Records an audio underrun event.

Reimplemented from MediaNode.

◆ stop()

void RtpAudioSinkNode::stop ( )
overridevirtual

Flushes remaining audio and stops the RTP session.

Reimplemented from MediaNode.


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