Roc Toolkit internal modules
Roc Toolkit: real-time audio streaming
roc::packet::Router Class Reference

Route packets to packet writers. More...

#include <router.h>

Inheritance diagram for roc::packet::Router:
Collaboration diagram for roc::packet::Router:

Public Member Functions

 Router (core::IArena &arena)
 Initialize. More...
 
ROC_ATTR_NODISCARD bool add_route (IWriter &writer, unsigned flags)
 Add route. More...
 
bool has_source_id (unsigned flags)
 Check if there is detected source id for given route. More...
 
stream_source_t get_source_id (unsigned flags)
 Get detected source id for given route. More...
 
virtual ROC_ATTR_NODISCARD status::StatusCode write (const PacketPtr &packet)
 Write next packet. More...
 

Detailed Description

Route packets to packet writers.

To create a route, user provides packet writer and packet flags. Packets that include specified flags will be routed to given writer.

When the very first packet is routed to a writer, router remembers which source id (SSRC) that packet has, or that the packet doesn't have any source id. Then router ensures that only packets with that source id are passed to same writer.

The user can query which source id were detected for which routes.

Definition at line 38 of file router.h.

Constructor & Destructor Documentation

◆ Router()

roc::packet::Router::Router ( core::IArena arena)

Initialize.

Member Function Documentation

◆ add_route()

ROC_ATTR_NODISCARD bool roc::packet::Router::add_route ( IWriter writer,
unsigned  flags 
)

Add route.

Remarks
Packets that has given flags set will be routed to writer.

◆ get_source_id()

stream_source_t roc::packet::Router::get_source_id ( unsigned  flags)

Get detected source id for given route.

Remarks
If has_source_id() returns true, this method returns source id for the route.

◆ has_source_id()

bool roc::packet::Router::has_source_id ( unsigned  flags)

Check if there is detected source id for given route.

Remarks
Returns true if there is route for given flags, and packets were already written to that route, and those packets have source id.

◆ write()

virtual ROC_ATTR_NODISCARD status::StatusCode roc::packet::Router::write ( const PacketPtr packet)
virtual

Write next packet.

Remarks
Route packet to a writer or drop it if no routes found.

Implements roc::packet::IWriter.


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