Roc Toolkit internal modules
Roc Toolkit: real-time audio streaming
receiver_session.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2017 Roc 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 
15 #include "roc_audio/depacketizer.h"
17 #include "roc_audio/ireader.h"
21 #include "roc_audio/watchdog.h"
22 #include "roc_core/buffer_pool.h"
23 #include "roc_core/iallocator.h"
24 #include "roc_core/list_node.h"
25 #include "roc_core/refcnt.h"
26 #include "roc_core/unique_ptr.h"
27 #include "roc_fec/codec_map.h"
28 #include "roc_fec/iblock_decoder.h"
29 #include "roc_fec/reader.h"
30 #include "roc_packet/address.h"
32 #include "roc_packet/iparser.h"
33 #include "roc_packet/ireader.h"
34 #include "roc_packet/packet.h"
35 #include "roc_packet/packet_pool.h"
36 #include "roc_packet/router.h"
38 #include "roc_pipeline/config.h"
39 #include "roc_rtp/format_map.h"
40 #include "roc_rtp/parser.h"
41 #include "roc_rtp/validator.h"
42 
43 namespace roc {
44 namespace pipeline {
45 
46 //! Receiver session pipeline.
47 //! @remarks
48 //! Created at the receiver side for every connected sender.
49 class ReceiverSession : public core::RefCnt<ReceiverSession>, public core::ListNode {
50 public:
51  //! Initialize.
52  ReceiverSession(const ReceiverSessionConfig& session_config,
53  const ReceiverCommonConfig& common_config,
54  const packet::Address& src_address,
55  const fec::CodecMap& codec_map,
56  const rtp::FormatMap& format_map,
57  packet::PacketPool& packet_pool,
58  core::BufferPool<uint8_t>& byte_buffer_pool,
59  core::BufferPool<audio::sample_t>& sample_buffer_pool,
60  core::IAllocator& allocator);
61 
62  //! Check if the session pipeline was succefully constructed.
63  bool valid() const;
64 
65  //! Try to route a packet to this session.
66  //! @returns
67  //! true if the packet is dedicated for this session
68  bool handle(const packet::PacketPtr& packet);
69 
70  //! Update session.
71  //! @returns
72  //! false if the session is terminated
74 
75  //! Get audio reader.
77 
78 private:
79  friend class core::RefCnt<ReceiverSession>;
80 
81  void destroy();
82 
83  const packet::Address src_address_;
84 
85  core::IAllocator& allocator_;
86 
87  audio::IReader* audio_reader_;
88 
89  core::UniquePtr<packet::Router> queue_router_;
90 
93 
97 
98  core::UniquePtr<rtp::Parser> fec_parser_;
100  core::UniquePtr<fec::Reader> fec_reader_;
101  core::UniquePtr<rtp::Validator> fec_validator_;
102 
103  core::UniquePtr<audio::IFrameDecoder> payload_decoder_;
105 
106  core::UniquePtr<audio::PoisonReader> resampler_poisoner_;
108 
109  core::UniquePtr<audio::PoisonReader> session_poisoner_;
110 
112 };
113 
114 } // namespace pipeline
115 } // namespace roc
116 
117 #endif // ROC_PIPELINE_RECEIVER_SESSION_H_
Network address.
Buffer pool.
Audio reader interface.
Definition: ireader.h:22
Memory allocator interface.
Definition: iallocator.h:23
Base class for list element.
Definition: list_node.h:26
Base class for reference countable objects.
Definition: refcnt.h:25
Unique ownrship pointer.
Definition: unique_ptr.h:27
FEC codec map.
Definition: codec_map.h:26
Network address.
Definition: address.h:24
Receiver session pipeline.
bool valid() const
Check if the session pipeline was succefully constructed.
bool update(packet::timestamp_t time)
Update session.
audio::IReader & reader()
Get audio reader.
bool handle(const packet::PacketPtr &packet)
Try to route a packet to this session.
ReceiverSession(const ReceiverSessionConfig &session_config, const ReceiverCommonConfig &common_config, const packet::Address &src_address, const fec::CodecMap &codec_map, const rtp::FormatMap &format_map, packet::PacketPool &packet_pool, core::BufferPool< uint8_t > &byte_buffer_pool, core::BufferPool< audio::sample_t > &sample_buffer_pool, core::IAllocator &allocator)
Initialize.
RTP payload format map.
Definition: format_map.h:22
FEC codec map.
Delayed reader.
Depacketizer.
RTP payload format map.
Memory allocator interface.
FEC block decoder interface.
Audio frame decoder interface.
Packet parser interface.
Latency monitor.
Linked list node.
uint32_t timestamp_t
Audio packet timestamp.
Definition: units.h:46
Root namespace.
Packet.
Packet pool.
Poison reader.
FEC reader.
Base class for reference countable objects.
Audio reader interface.
Packet reader interface.
Pipeline config.
RTP packet parser.
Route packets to writers.
Sorted packet queue.
Receiver common parameters.
Definition: config.h:162
Receiver session parameters.
Definition: config.h:122
Unique ownrship pointer.
RTP validator.
Watchdog.