Roc Toolkit internal modules
Roc Toolkit: real-time audio streaming
|
Receiver session router. More...
#include <receiver_session_router.h>
Public Member Functions | |
ReceiverSessionRouter (core::IArena &arena) | |
Initialize. More... | |
~ReceiverSessionRouter () | |
Deinitialize. More... | |
size_t | num_routes () |
Get number of know routes. More... | |
core::SharedPtr< ReceiverSession > | find_by_source (packet::stream_source_t source_id) |
Find registered session by source id of sender's stream. More... | |
core::SharedPtr< ReceiverSession > | find_by_address (const address::SocketAddr &source_addr) |
Find registered session by source address of sender's stream. More... | |
bool | has_session (const core::SharedPtr< ReceiverSession > &session) |
Check if there is a route for given session. More... | |
ROC_ATTR_NODISCARD status::StatusCode | add_session (const core::SharedPtr< ReceiverSession > &session, packet::stream_source_t source_id, const address::SocketAddr &source_addr) |
Register session in router. More... | |
void | remove_session (const core::SharedPtr< ReceiverSession > &session) |
Unregister session from router. More... | |
ROC_ATTR_NODISCARD status::StatusCode | link_source (packet::stream_source_t source_id, const char *cname) |
Link source id with unique CNAME. More... | |
void | unlink_source (packet::stream_source_t source_id) |
Unlink source id from session. More... | |
Receiver session router.
Helps routing packets to sessions within session group.
Session group corresponds to all sessions handled by one receiver slot - a set of related complementary endpoints, e.g. one endpoint for audio, one for repair, and one for control packets.
For each remote sender, receiver creates a session inside session group. All audio, repair, and control packets from same sender are then routed to same session.
Session management is implemented in ReceiverSessionGroup, and algorithm for selecting session for a packet is implemented in ReceiverSessionRouter (this class).
Session router provides two methods to select session:
By source id.
Sender can assign unique source id (SSRC) to each stream (audio, repair), and then transmit RTCP SDES packet that associate all sender's SSRCs with the same unique (randomly generated) CNAME string.
Session router will remember that these SSRCs are related and will route packets from those streams to same session.
By source address.
As a fallback for the case when RTCP is not used, session router will assume that packets with same source address belong to the same session.
To make it work, sender should ensure that it sends all streams (audio, repair) from the same socket, and that there are no proxies or retranslators that combine multiple senders on the same socket.
Definition at line 67 of file receiver_session_router.h.
roc::pipeline::ReceiverSessionRouter::ReceiverSessionRouter | ( | core::IArena & | arena | ) |
Initialize.
roc::pipeline::ReceiverSessionRouter::~ReceiverSessionRouter | ( | ) |
Deinitialize.
ROC_ATTR_NODISCARD status::StatusCode roc::pipeline::ReceiverSessionRouter::add_session | ( | const core::SharedPtr< ReceiverSession > & | session, |
packet::stream_source_t | source_id, | ||
const address::SocketAddr & | source_addr | ||
) |
Register session in router.
session
defines session where to route packets.source_id
defines SSRC of stream which will be routed to the session. Additional streams may be associated with same session via link_source() call.source_addr
defines source address which will be routed to the session. If other streams share the same source address, they will be routed to it. core::SharedPtr<ReceiverSession> roc::pipeline::ReceiverSessionRouter::find_by_address | ( | const address::SocketAddr & | source_addr | ) |
Find registered session by source address of sender's stream.
core::SharedPtr<ReceiverSession> roc::pipeline::ReceiverSessionRouter::find_by_source | ( | packet::stream_source_t | source_id | ) |
Find registered session by source id of sender's stream.
bool roc::pipeline::ReceiverSessionRouter::has_session | ( | const core::SharedPtr< ReceiverSession > & | session | ) |
Check if there is a route for given session.
ROC_ATTR_NODISCARD status::StatusCode roc::pipeline::ReceiverSessionRouter::link_source | ( | packet::stream_source_t | source_id, |
const char * | cname | ||
) |
Link source id with unique CNAME.
size_t roc::pipeline::ReceiverSessionRouter::num_routes | ( | ) |
Get number of know routes.
void roc::pipeline::ReceiverSessionRouter::remove_session | ( | const core::SharedPtr< ReceiverSession > & | session | ) |
Unregister session from router.
void roc::pipeline::ReceiverSessionRouter::unlink_source | ( | packet::stream_source_t | source_id | ) |
Unlink source id from session.