Roc Toolkit internal modules
Roc Toolkit: real-time audio streaming
config.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/config.h
10 //! @brief Pipeline config.
11 
12 #ifndef ROC_PIPELINE_CONFIG_H_
13 #define ROC_PIPELINE_CONFIG_H_
14 
16 #include "roc_audio/resampler.h"
17 #include "roc_audio/watchdog.h"
18 #include "roc_core/stddefs.h"
19 #include "roc_core/time.h"
20 #include "roc_fec/codec_config.h"
21 #include "roc_fec/reader.h"
22 #include "roc_fec/writer.h"
23 #include "roc_packet/units.h"
24 #include "roc_pipeline/port.h"
25 #include "roc_rtp/headers.h"
26 #include "roc_rtp/validator.h"
27 
28 namespace roc {
29 namespace pipeline {
30 
31 //! Default sample rate, number of samples per second.
32 const size_t DefaultSampleRate = 44100;
33 
34 //! Default channel mask.
36 
37 //! Default packet length.
39 
40 //! Default latency.
42 
43 //! Default internal frame size.
44 const size_t DefaultInternalFrameSize = 640;
45 
46 //! Default minum latency relative to target latency.
47 const int DefaultMinLatencyFactor = -1;
48 
49 //! Default maximum latency relative to target latency.
51 
52 //! Port parameters.
53 //! @remarks
54 //! On receiver, defines a listened port parameters. On sender,
55 //! defines a destination port parameters.
56 struct PortConfig {
57  //! Port address.
59 
60  //! Port protocol.
62 
63  PortConfig()
64  : protocol(Proto_None) {
65  }
66 };
67 
68 //! Sender parameters.
69 struct SenderConfig {
70  //! Resampler parameters.
72 
73  //! FEC writer parameters.
75 
76  //! FEC encoder parameters.
78 
79  //! Number of samples per second per channel.
81 
82  //! Channel mask.
84 
85  //! Number of samples for internal frames.
87 
88  //! Packet length, in nanoseconds.
90 
91  //! RTP payload type for audio packets.
93 
94  //! Resample frames with a constant ratio.
95  bool resampling;
96 
97  //! Interleave packets.
99 
100  //! Constrain receiver speed using a CPU timer according to the sample rate.
101  bool timing;
102 
103  //! Fill unitialized data with large values to make them more noticable.
104  bool poisoning;
105 
106  SenderConfig()
107  : input_sample_rate(DefaultSampleRate)
108  , input_channels(DefaultChannelMask)
109  , internal_frame_size(DefaultInternalFrameSize)
110  , packet_length(DefaultPacketLength)
111  , payload_type(rtp::PayloadType_L16_Stereo)
112  , resampling(false)
113  , interleaving(false)
114  , timing(false)
115  , poisoning(false) {
116  }
117 };
118 
119 //! Receiver session parameters.
120 //! @remarks
121 //! Defines per-session receiver parameters.
123  //! Target latency, nanoseconds.
125 
126  //! Channel mask.
128 
129  //! Packet payload type.
130  unsigned int payload_type;
131 
132  //! FEC reader parameters.
134 
135  //! FEC decoder parameters.
137 
138  //! RTP validator parameters.
140 
141  //! LatencyMonitor parameters.
143 
144  //! Watchdog parameters.
146 
147  //! Resampler parameters.
149 
151  : target_latency(DefaultLatency)
152  , channels(DefaultChannelMask)
153  , payload_type(0) {
154  latency_monitor.min_latency = target_latency * DefaultMinLatencyFactor;
155  latency_monitor.max_latency = target_latency * DefaultMaxLatencyFactor;
156  }
157 };
158 
159 //! Receiver common parameters.
160 //! @remarks
161 //! Defines receiver parameters common for all sessions.
163  //! Number of samples per second per channel.
165 
166  //! Channel mask.
168 
169  //! Number of samples for internal frames.
171 
172  //! Perform resampling to compensate sender and receiver frequency difference.
174 
175  //! Constrain receiver speed using a CPU timer according to the sample rate.
176  bool timing;
177 
178  //! Fill uninitialized data with large values to make them more noticeable.
179  bool poisoning;
180 
181  //! Insert weird beeps instead of silence on packet loss.
182  bool beeping;
183 
185  : output_sample_rate(DefaultSampleRate)
186  , output_channels(DefaultChannelMask)
187  , internal_frame_size(DefaultInternalFrameSize)
188  , resampling(false)
189  , timing(false)
190  , poisoning(false)
191  , beeping(false) {
192  }
193 };
194 
195 //! Receiver parameters.
197  //! Default parameters for receiver session.
199 
200  //! Parameters common for all sessions.
202 };
203 
204 //! Converter parameters.
206  //! Resampler parameters.
208 
209  //! Number of samples per second per channel.
211 
212  //! Number of samples per second per channel.
214 
215  //! Input channel mask.
217 
218  //! Output channel mask.
220 
221  //! Number of samples for internal frames.
223 
224  //! Resample frames with a constant ratio.
226 
227  //! Fill unitialized data with large values to make them more noticable.
228  bool poisoning;
229 
231  : input_sample_rate(DefaultSampleRate)
232  , output_sample_rate(DefaultSampleRate)
233  , input_channels(DefaultChannelMask)
234  , output_channels(DefaultChannelMask)
235  , internal_frame_size(DefaultInternalFrameSize)
236  , resampling(false)
237  , poisoning(false) {
238  }
239 };
240 
241 } // namespace pipeline
242 } // namespace roc
243 
244 #endif // ROC_PIPELINE_CONFIG_H_
Receiver parameters.
Definition: config.h:196
const nanoseconds_t Millisecond
One millisecond represented in nanoseconds.
Definition: time.h:30
Port parameters.
Definition: config.h:56
const core::nanoseconds_t DefaultPacketLength
Default packet length.
Definition: config.h:38
Validator parameters.
Definition: validator.h:23
FEC writer parameters.
Definition: writer.h:30
PortProtocol
Port protocol.
Definition: port.h:28
FEC reader parameters.
Definition: reader.h:30
ReceiverCommonConfig common
Parameters common for all sessions.
Definition: config.h:201
size_t internal_frame_size
Number of samples for internal frames.
Definition: config.h:222
Time definitions.
FEC reader.
const core::nanoseconds_t DefaultLatency
Default latency.
Definition: config.h:41
fec::CodecConfig fec_encoder
FEC encoder parameters.
Definition: config.h:77
bool poisoning
Fill uninitialized data with large values to make them more noticeable.
Definition: config.h:179
Converter parameters.
Definition: config.h:205
size_t internal_frame_size
Number of samples for internal frames.
Definition: config.h:170
packet::channel_mask_t channels
Channel mask.
Definition: config.h:127
Root namespace.
bool poisoning
Fill unitialized data with large values to make them more noticable.
Definition: config.h:228
fec::WriterConfig fec_writer
FEC writer parameters.
Definition: config.h:74
size_t input_sample_rate
Number of samples per second per channel.
Definition: config.h:210
Watchdog.
Resampler parameters.
Definition: resampler.h:28
ReceiverSessionConfig default_session
Default parameters for receiver session.
Definition: config.h:198
Latency monitor.
bool resampling
Resample frames with a constant ratio.
Definition: config.h:225
bool interleaving
Interleave packets.
Definition: config.h:98
bool resampling
Resample frames with a constant ratio.
Definition: config.h:95
PortProtocol protocol
Port protocol.
Definition: config.h:61
packet::channel_mask_t output_channels
Channel mask.
Definition: config.h:167
rtp::PayloadType payload_type
RTP payload type for audio packets.
Definition: config.h:92
int64_t nanoseconds_t
Nanoseconds.
Definition: time.h:21
RTP validator.
uint32_t channel_mask_t
Bitmask of channels present in audio packet.
Definition: units.h:77
Watchdog parameters.
Definition: watchdog.h:26
RTP headers.
fec::ReaderConfig fec_reader
FEC reader parameters.
Definition: config.h:133
bool poisoning
Fill unitialized data with large values to make them more noticable.
Definition: config.h:104
Network address.
Definition: address.h:24
Commonly used types and functions.
size_t internal_frame_size
Number of samples for internal frames.
Definition: config.h:86
Sender parameters.
Definition: config.h:69
bool timing
Constrain receiver speed using a CPU timer according to the sample rate.
Definition: config.h:176
Receiver common parameters.
Definition: config.h:162
audio::LatencyMonitorConfig latency_monitor
LatencyMonitor parameters.
Definition: config.h:142
Resampler.
packet::Address address
Port address.
Definition: config.h:58
size_t input_sample_rate
Number of samples per second per channel.
Definition: config.h:80
Protocol is not set.
Definition: port.h:30
FEC writer.
Receiver session parameters.
Definition: config.h:122
Parameters for latency monitor.
audio::WatchdogConfig watchdog
Watchdog parameters.
Definition: config.h:145
FEC codec parameters.
Port constants.
const size_t DefaultSampleRate
Default sample rate, number of samples per second.
Definition: config.h:32
packet::channel_mask_t input_channels
Input channel mask.
Definition: config.h:216
size_t output_sample_rate
Number of samples per second per channel.
Definition: config.h:164
bool timing
Constrain receiver speed using a CPU timer according to the sample rate.
Definition: config.h:101
const int DefaultMinLatencyFactor
Default minum latency relative to target latency.
Definition: config.h:47
core::nanoseconds_t min_latency
Minimum allowed latency, nanoseconds. If the latency goes out of bounds, the session is terminated...
audio::ResamplerConfig resampler
Resampler parameters.
Definition: config.h:207
bool resampling
Perform resampling to compensate sender and receiver frequency difference.
Definition: config.h:173
const size_t DefaultInternalFrameSize
Default internal frame size.
Definition: config.h:44
Various units used in packets.
core::nanoseconds_t packet_length
Packet length, in nanoseconds.
Definition: config.h:89
packet::channel_mask_t output_channels
Output channel mask.
Definition: config.h:219
PayloadType
RTP payload type.
Definition: headers.h:29
unsigned int payload_type
Packet payload type.
Definition: config.h:130
packet::channel_mask_t input_channels
Channel mask.
Definition: config.h:83
size_t output_sample_rate
Number of samples per second per channel.
Definition: config.h:213
const packet::channel_mask_t DefaultChannelMask
Default channel mask.
Definition: config.h:35
const int DefaultMaxLatencyFactor
Default maximum latency relative to target latency.
Definition: config.h:50
bool beeping
Insert weird beeps instead of silence on packet loss.
Definition: config.h:182
core::nanoseconds_t max_latency
Maximum allowed latency, nanoseconds. If the latency goes out of bounds, the session is terminated...
audio::ResamplerConfig resampler
Resampler parameters.
Definition: config.h:71
Audio, 16-bit samples, 2 channels, 44100 Hz.
Definition: headers.h:30
audio::ResamplerConfig resampler
Resampler parameters.
Definition: config.h:148
rtp::ValidatorConfig rtp_validator
RTP validator parameters.
Definition: config.h:139
FEC codec parameters.
Definition: codec_config.h:22
fec::CodecConfig fec_decoder
FEC decoder parameters.
Definition: config.h:136
core::nanoseconds_t target_latency
Target latency, nanoseconds.
Definition: config.h:124