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
73  bool update(packet::timestamp_t time);
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_
Memory allocator interface.
Definition: iallocator.h:23
bool update(packet::timestamp_t time)
Update session.
Pipeline config.
RTP payload format map.
Packet reader interface.
FEC reader.
bool valid() const
Check if the session pipeline was succefully constructed.
Packet pool.
Base class for list element.
Definition: list_node.h:26
Root namespace.
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.
Delayed reader.
Linked list node.
Watchdog.
Latency monitor.
Sorted packet queue.
audio::IReader & reader()
Get audio reader.
Audio reader interface.
RTP validator.
uint32_t timestamp_t
Audio packet timestamp.
Definition: units.h:46
Network address.
Definition: address.h:24
RTP packet parser.
Network address.
Packet parser interface.
bool handle(const packet::PacketPtr &packet)
Try to route a packet to this session.
Receiver common parameters.
Definition: config.h:162
Receiver session pipeline.
FEC codec map.
RTP payload format map.
Definition: format_map.h:22
Receiver session parameters.
Definition: config.h:122
Depacketizer.
Audio reader interface.
Definition: ireader.h:22
Route packets to writers.
Base class for reference countable objects.
Definition: refcnt.h:25
Packet.
Base class for reference countable objects.
Buffer pool.
Unique ownrship pointer.
Poison reader.
FEC codec map.
Definition: codec_map.h:26
Audio frame decoder interface.
Memory allocator interface.
FEC block decoder interface.