Roc Toolkit internal modules
Roc Toolkit: real-time audio streaming
sender.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/sender.h
10 //! @brief Sender pipeline.
11 
12 #ifndef ROC_PIPELINE_SENDER_H_
13 #define ROC_PIPELINE_SENDER_H_
14 
16 #include "roc_audio/packetizer.h"
19 #include "roc_core/buffer_pool.h"
20 #include "roc_core/iallocator.h"
21 #include "roc_core/noncopyable.h"
22 #include "roc_core/ticker.h"
23 #include "roc_core/unique_ptr.h"
24 #include "roc_fec/codec_map.h"
25 #include "roc_fec/iblock_encoder.h"
26 #include "roc_fec/writer.h"
27 #include "roc_packet/interleaver.h"
28 #include "roc_packet/packet_pool.h"
29 #include "roc_packet/router.h"
30 #include "roc_pipeline/config.h"
32 #include "roc_rtp/format_map.h"
33 #include "roc_sndio/isink.h"
34 
35 namespace roc {
36 namespace pipeline {
37 
38 //! Sender pipeline.
39 class Sender : public sndio::ISink, public core::NonCopyable<> {
40 public:
41  //! Initialize.
42  Sender(const SenderConfig& config,
43  const PortConfig& source_port,
44  packet::IWriter& source_writer,
45  const PortConfig& repair_port,
46  packet::IWriter& repair_writer,
47  const fec::CodecMap& codec_map,
48  const rtp::FormatMap& format_map,
49  packet::PacketPool& packet_pool,
50  core::BufferPool<uint8_t>& byte_buffer_pool,
51  core::BufferPool<audio::sample_t>& sample_buffer_pool,
52  core::IAllocator& allocator);
53 
54  //! Check if the pipeline was successfully constructed.
55  bool valid();
56 
57  //! Get sink sample rate.
58  virtual size_t sample_rate() const;
59 
60  //! Check if the sink has own clock.
61  virtual bool has_clock() const;
62 
63  //! Write audio frame.
64  virtual void write(audio::Frame& frame);
65 
66 private:
67  core::UniquePtr<SenderPort> source_port_;
68  core::UniquePtr<SenderPort> repair_port_;
69 
71 
73 
75  core::UniquePtr<fec::Writer> fec_writer_;
76 
79 
80  core::UniquePtr<audio::PoisonWriter> resampler_poisoner_;
82 
83  core::UniquePtr<audio::PoisonWriter> pipeline_poisoner_;
84 
86 
87  audio::IWriter* audio_writer_;
88 
89  SenderConfig config_;
90 
91  packet::timestamp_t timestamp_;
92  size_t num_channels_;
93 };
94 
95 } // namespace pipeline
96 } // namespace roc
97 
98 #endif // ROC_PIPELINE_SENDER_H_
Audio frame encoder interface.
Port parameters.
Definition: config.h:56
Audio writer interface.
Definition: iwriter.h:21
Sink interface.
Definition: isink.h:21
Memory allocator interface.
Definition: iallocator.h:23
Pipeline config.
Sink interface.
Unique ownrship pointer.
Definition: unique_ptr.h:27
RTP payload format map.
Sender port pipeline.
bool valid()
Check if the pipeline was successfully constructed.
Packet pool.
virtual bool has_clock() const
Check if the sink has own clock.
Root namespace.
Sender pipeline.
Definition: sender.h:39
uint32_t timestamp_t
Audio packet timestamp.
Definition: units.h:46
virtual size_t sample_rate() const
Get sink sample rate.
Audio frame.
Definition: frame.h:22
Interleaves packets before transmit.
Packet writer interface.
Definition: iwriter.h:21
Sender parameters.
Definition: config.h:69
virtual void write(audio::Frame &frame)
Write audio frame.
Ticker.
Base class for non-copyable objects.
Definition: noncopyable.h:23
FEC codec map.
FEC writer.
RTP payload format map.
Definition: format_map.h:22
Sender(const SenderConfig &config, const PortConfig &source_port, packet::IWriter &source_writer, const PortConfig &repair_port, packet::IWriter &repair_writer, 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.
Route packets to writers.
Packetizer.
Buffer pool.
Unique ownrship pointer.
Non-copyable object.
FEC codec map.
Definition: codec_map.h:26
FEC block encoder interface.
Memory allocator interface.
Poison writer.