Roc Toolkit internal modules
Roc Toolkit: real-time audio streaming
Loading...
Searching...
No Matches
receiver_session.h
Go to the documentation of this file.
1/*
2 * Copyright (c) 2017 Roc Streaming authors
3 *
4 * This Source Code Form is subject to the terms of the Mozilla Public
5 * License, v. 2.0. If a copy of the MPL was not distributed with this
6 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
7 */
8
9//! @file roc_pipeline/receiver_session.h
10//! @brief Receiver session pipeline.
11
12#ifndef ROC_PIPELINE_RECEIVER_SESSION_H_
13#define ROC_PIPELINE_RECEIVER_SESSION_H_
14
24#include "roc_audio/watchdog.h"
26#include "roc_core/iallocator.h"
27#include "roc_core/list_node.h"
28#include "roc_core/optional.h"
30#include "roc_core/scoped_ptr.h"
32#include "roc_fec/reader.h"
34#include "roc_packet/iparser.h"
35#include "roc_packet/ireader.h"
36#include "roc_packet/packet.h"
38#include "roc_packet/router.h"
40#include "roc_pipeline/config.h"
41#include "roc_rtcp/metrics.h"
42#include "roc_rtp/format_map.h"
43#include "roc_rtp/parser.h"
44#include "roc_rtp/populator.h"
45#include "roc_rtp/validator.h"
46
47namespace roc {
48namespace pipeline {
49
50//! Receiver session sub-pipeline.
51//!
52//! Contains:
53//! - a pipeline for processing packets from single sender and converting
54//! them into audio frames
56 : public core::RefCounted<ReceiverSession, core::StandardAllocation>,
57 public core::ListNode {
59
60public:
61 //! Initialize.
63 const ReceiverCommonConfig& common_config,
64 const address::SocketAddr& src_address,
65 const rtp::FormatMap& format_map,
66 packet::PacketFactory& packet_factory,
67 core::BufferFactory<uint8_t>& byte_buffer_factory,
68 core::BufferFactory<audio::sample_t>& sample_buffer_factory,
70
71 //! Check if the session pipeline was succefully constructed.
72 bool valid() const;
73
74 //! Try to route a packet to this session.
75 //! @returns
76 //! true if the packet is dedicated for this session
77 bool handle(const packet::PacketPtr& packet);
78
79 //! Advance session timestamp.
80 //! @returns
81 //! false if the session is ended
83
84 //! Adjust session clock to match consumer clock.
85 //! @returns
86 //! false if the session is ended
88
89 //! Get audio reader.
91
92 //! Handle metrics obtained from sender.
94
95 //! Handle estimated link metrics.
96 void add_link_metrics(const rtcp::LinkMetrics& metrics);
97
98private:
99 const address::SocketAddr src_address_;
100
101 audio::IFrameReader* audio_reader_;
102
103 core::Optional<packet::Router> queue_router_;
104
107
109
114
115 core::Optional<rtp::Parser> fec_parser_;
117 core::Optional<fec::Reader> fec_reader_;
118 core::Optional<rtp::Validator> fec_validator_;
119
121
122 core::Optional<audio::ChannelMapperReader> channel_mapper_reader_;
123
124 core::Optional<audio::PoisonReader> resampler_poisoner_;
127
128 core::Optional<audio::PoisonReader> session_poisoner_;
129
131};
132
133} // namespace pipeline
134} // namespace roc
135
136#endif // ROC_PIPELINE_RECEIVER_SESSION_H_
Buffer factory.
Channel mapper reader.
Socket address.
Definition: socket_addr.h:25
Frame reader interface.
Definition: iframe_reader.h:22
Memory allocator interface.
Definition: iallocator.h:23
Base class for list element.
Definition: list_node.h:26
Optionally constructed object.
Definition: optional.h:25
Base class for reference counted object.
Definition: ref_counted.h:39
Unique ownrship pointer.
Definition: scoped_ptr.h:32
IAllocator & allocator() const
Get allocator.
Receiver session sub-pipeline.
audio::IFrameReader & reader()
Get audio reader.
void add_link_metrics(const rtcp::LinkMetrics &metrics)
Handle estimated link metrics.
bool valid() const
Check if the session pipeline was succefully constructed.
void add_sending_metrics(const rtcp::SendingMetrics &metrics)
Handle metrics obtained from sender.
bool handle(const packet::PacketPtr &packet)
Try to route a packet to this session.
bool reclock(packet::ntp_timestamp_t timestamp)
Adjust session clock to match consumer clock.
bool advance(packet::timestamp_t timestamp)
Advance session timestamp.
ReceiverSession(const ReceiverSessionConfig &session_config, const ReceiverCommonConfig &common_config, const address::SocketAddr &src_address, const rtp::FormatMap &format_map, packet::PacketFactory &packet_factory, core::BufferFactory< uint8_t > &byte_buffer_factory, core::BufferFactory< audio::sample_t > &sample_buffer_factory, core::IAllocator &allocator)
Initialize.
RTP payload format map.
Definition: format_map.h:22
Delayed reader.
Depacketizer.
RTP payload format map.
Memory allocator interface.
FEC block decoder interface.
Audio frame decoder interface.
Frame reader interface.
Packet parser interface.
Packet reader interface.
Audio resampler interface.
Latency monitor.
Linked list node.
RTCP-derived metrics.
uint32_t timestamp_t
Audio packet timestamp.
Definition: units.h:25
uint64_t ntp_timestamp_t
NTP timestamp.
Definition: units.h:91
Root namespace.
Optionally constructed object.
Packet.
Packet factory.
Poison reader.
RTP populator.
FEC reader.
Base class for reference counted object.
Pipeline config.
RTP packet parser.
Route packets to writers.
Unique ownrship pointer.
Socket address.
Sorted packet queue.
Receiver common parameters.
Definition: config.h:210
Receiver session parameters.
Definition: config.h:165
Metrics for network link. Calculated independently on both sender and receiver.
Definition: metrics.h:52
Metrics sent from sender to receiver.
Definition: metrics.h:23
RTP validator.
Watchdog.