Roc Toolkit internal modules
Roc Toolkit: real-time audio streaming
Loading...
Searching...
No Matches
config.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/config.h
10//! @brief Pipeline config.
11
12#ifndef ROC_PIPELINE_CONFIG_H_
13#define ROC_PIPELINE_CONFIG_H_
14
18#include "roc_audio/profiler.h"
22#include "roc_audio/watchdog.h"
23#include "roc_core/stddefs.h"
24#include "roc_core/time.h"
26#include "roc_fec/reader.h"
27#include "roc_fec/writer.h"
28#include "roc_packet/units.h"
29#include "roc_rtp/headers.h"
30#include "roc_rtp/validator.h"
31
32namespace roc {
33namespace pipeline {
34
35//! Default sample rate, number of samples per second.
36const size_t DefaultSampleRate = 44100;
37
38//! Default channel mask.
40
41//! Default packet length.
43
44//! Default latency.
46
47//! Default internal frame length.
49
50//! Default minum latency relative to target latency.
52
53//! Default maximum latency relative to target latency.
55
56//! Task processing parameters.
57struct TaskConfig {
58 //! Enable precise task scheduling mode (default).
59 //! The other settings have effect only when this is set to true.
60 //! When enabled, pipeline processes tasks in dedicated time intervals between
61 //! sub-frame and between frames, trying to prevent time collisions between
62 //! task and frame processing.
64
65 //! Minimum frame duration between processing tasks.
66 //! In-frame task processing does not happen until at least given number
67 //! of samples is processed.
68 //! Set to zero to allow task processing between frames of any size.
70
71 //! Maximum frame duration between processing tasks.
72 //! If the frame is larger than this size, it is split into multiple subframes
73 //! to allow task processing between the sub-frames.
74 //! Set to zero to disable frame splitting.
76
77 //! Mximum task processing duration happening immediatelly after processing a frame.
78 //! If this period expires and there are still pending tasks, asynchronous
79 //! task processing is scheduled.
80 //! At least one task is always processed after each frame, even if this
81 //! setting is too small.
83
84 //! Time interval during which no task processing is allowed.
85 //! This setting is used to prohibit task processing during the time when
86 //! next read() or write() call is expected.
87 //! Since it can not be calculated abolutely precisely, and there is always
88 //! thread switch overhead, scheduler jitter clock drift, we use a wide interval.
90
93 , min_frame_length_between_tasks(200 * core::Microsecond)
95 , max_inframe_task_processing(20 * core::Microsecond)
96 , task_processing_prohibited_interval(200 * core::Microsecond) {
97 }
98};
99
100//! Sender parameters.
102 //! Task processing parameters.
104
105 //! To specify which resampling backend will be used.
107
108 //! Resampler profile.
110
111 //! FEC writer parameters.
113
114 //! FEC encoder parameters.
116
117 //! Input sample spec
119
120 //! Duration of the internal frames, in nanoseconds.
122
123 //! Packet length, in nanoseconds.
125
126 //! RTP payload type for audio packets.
128
129 //! Resample frames with a constant ratio.
131
132 //! Interleave packets.
134
135 //! Constrain receiver speed using a CPU timer according to the sample rate.
136 bool timing;
137
138 //! Fill unitialized data with large values to make them more noticable.
140
141 //! Profile moving average of frames being written.
143
144 //! Profiler configuration.
146
148 : resampler_backend(audio::ResamplerBackend_Default)
149 , resampler_profile(audio::ResamplerProfile_Medium)
153 , payload_type(rtp::PayloadType_L16_Stereo)
154 , resampling(false)
155 , interleaving(false)
156 , timing(false)
157 , poisoning(false)
158 , profiling(false) {
159 }
160};
161
162//! Receiver session parameters.
163//! @remarks
164//! Defines per-session receiver parameters.
166 //! Target latency, nanoseconds.
168
169 //! Packet payload type.
170 unsigned int payload_type;
171
172 //! FEC reader parameters.
174
175 //! FEC decoder parameters.
177
178 //! RTP validator parameters.
180
181 //! FreqEstimator config.
183
184 //! LatencyMonitor parameters.
186
187 //! Watchdog parameters.
189
190 //! To specify which resampling backend will be used.
192
193 //! Resampler profile.
195
198 , payload_type(0)
200 , resampler_backend(audio::ResamplerBackend_Default)
201 , resampler_profile(audio::ResamplerProfile_Medium) {
204 }
205};
206
207//! Receiver common parameters.
208//! @remarks
209//! Defines receiver parameters common for all sessions.
211 //! Output sample spec
213
214 //! Duration of the internal frames, in nanoseconds.
216
217 //! Perform resampling to compensate sender and receiver frequency difference.
219
220 //! Constrain receiver speed using a CPU timer according to the sample rate.
221 bool timing;
222
223 //! Fill uninitialized data with large values to make them more noticeable.
225
226 //! Profile moving average of frames being written.
228
229 //! Profiler configuration.
231
232 //! Insert weird beeps instead of silence on packet loss.
234
238 , resampling(false)
239 , timing(false)
240 , poisoning(false)
241 , profiling(false)
242 , beeping(false) {
243 }
244};
245
246//! Receiver parameters.
248 //! Default parameters for receiver session.
250
251 //! Parameters common for all sessions.
253
254 //! Task processing parameters.
256};
257
258//! Converter parameters.
260 //! To specify which resampling backend will be used.
262
263 //! Resampler profile.
265
266 //! Input sample spec
268
269 //! Output sample spec
271
272 //! Duration of the internal frames, in nanoseconds.
274
275 //! Resample frames with a constant ratio.
277
278 //! Fill unitialized data with large values to make them more noticable.
280
281 //! Profile moving average of frames being written.
283
284 //! Profiler configuration.
286
288 : resampler_backend(audio::ResamplerBackend_Default)
289 , resampler_profile(audio::ResamplerProfile_Medium)
293 , resampling(false)
294 , poisoning(false)
295 , profiling(false) {
296 }
297};
298
299} // namespace pipeline
300} // namespace roc
301
302#endif // ROC_PIPELINE_CONFIG_H_
Sample stream specification. Defines sample rate and channel layout.
Definition: sample_spec.h:24
FEC codec parameters.
Frequency estimator.
Latency monitor.
ResamplerBackend
Resampler backends.
ResamplerProfile
Resampler parameters presets.
const nanoseconds_t Millisecond
One millisecond represented in nanoseconds.
Definition: time.h:67
int64_t nanoseconds_t
Nanoseconds.
Definition: time.h:58
uint32_t channel_mask_t
Bitmask of channels present in audio packet.
Definition: units.h:94
const core::nanoseconds_t DefaultInternalFrameLength
Default internal frame length.
Definition: config.h:48
const int DefaultMinLatencyFactor
Default minum latency relative to target latency.
Definition: config.h:51
const int DefaultMaxLatencyFactor
Default maximum latency relative to target latency.
Definition: config.h:54
const core::nanoseconds_t DefaultPacketLength
Default packet length.
Definition: config.h:42
const packet::channel_mask_t DefaultChannelMask
Default channel mask.
Definition: config.h:39
const core::nanoseconds_t DefaultLatency
Default latency.
Definition: config.h:45
const size_t DefaultSampleRate
Default sample rate, number of samples per second.
Definition: config.h:36
PayloadType
RTP payload type.
Definition: headers.h:29
Root namespace.
Profiler.
Protocol ID.
FEC reader.
Resampler backend.
Resampler profile.
RTP headers.
Sample specifications.
Commonly used types and functions.
FreqEstimator tunable parameters.
Parameters for latency monitor.
core::nanoseconds_t max_latency
Maximum allowed latency, nanoseconds. If the latency goes out of bounds, the session is terminated.
core::nanoseconds_t min_latency
Minimum allowed latency, nanoseconds. If the latency goes out of bounds, the session is terminated.
Profiler Configuration Parameters. Controls profiling interval and duration of each circular buffer c...
Definition: profiler.h:30
Watchdog parameters.
Definition: watchdog.h:27
FEC codec parameters.
Definition: codec_config.h:22
FEC reader parameters.
Definition: reader.h:30
FEC writer parameters.
Definition: writer.h:30
Converter parameters.
Definition: config.h:259
core::nanoseconds_t internal_frame_length
Duration of the internal frames, in nanoseconds.
Definition: config.h:273
bool profiling
Profile moving average of frames being written.
Definition: config.h:282
audio::SampleSpec input_sample_spec
Input sample spec.
Definition: config.h:267
audio::ResamplerProfile resampler_profile
Resampler profile.
Definition: config.h:264
bool poisoning
Fill unitialized data with large values to make them more noticable.
Definition: config.h:279
audio::SampleSpec output_sample_spec
Output sample spec.
Definition: config.h:270
bool resampling
Resample frames with a constant ratio.
Definition: config.h:276
audio::ResamplerBackend resampler_backend
To specify which resampling backend will be used.
Definition: config.h:261
audio::ProfilerConfig profiler_config
Profiler configuration.
Definition: config.h:285
Receiver common parameters.
Definition: config.h:210
bool beeping
Insert weird beeps instead of silence on packet loss.
Definition: config.h:233
bool poisoning
Fill uninitialized data with large values to make them more noticeable.
Definition: config.h:224
bool timing
Constrain receiver speed using a CPU timer according to the sample rate.
Definition: config.h:221
bool resampling
Perform resampling to compensate sender and receiver frequency difference.
Definition: config.h:218
core::nanoseconds_t internal_frame_length
Duration of the internal frames, in nanoseconds.
Definition: config.h:215
bool profiling
Profile moving average of frames being written.
Definition: config.h:227
audio::SampleSpec output_sample_spec
Output sample spec.
Definition: config.h:212
audio::ProfilerConfig profiler_config
Profiler configuration.
Definition: config.h:230
Receiver parameters.
Definition: config.h:247
TaskConfig tasks
Task processing parameters.
Definition: config.h:255
ReceiverCommonConfig common
Parameters common for all sessions.
Definition: config.h:252
ReceiverSessionConfig default_session
Default parameters for receiver session.
Definition: config.h:249
Receiver session parameters.
Definition: config.h:165
core::nanoseconds_t target_latency
Target latency, nanoseconds.
Definition: config.h:167
audio::LatencyMonitorConfig latency_monitor
LatencyMonitor parameters.
Definition: config.h:185
fec::ReaderConfig fec_reader
FEC reader parameters.
Definition: config.h:173
audio::ResamplerBackend resampler_backend
To specify which resampling backend will be used.
Definition: config.h:191
audio::FreqEstimatorConfig freq_estimator_config
FreqEstimator config.
Definition: config.h:182
unsigned int payload_type
Packet payload type.
Definition: config.h:170
audio::ResamplerProfile resampler_profile
Resampler profile.
Definition: config.h:194
fec::CodecConfig fec_decoder
FEC decoder parameters.
Definition: config.h:176
rtp::ValidatorConfig rtp_validator
RTP validator parameters.
Definition: config.h:179
audio::WatchdogConfig watchdog
Watchdog parameters.
Definition: config.h:188
Sender parameters.
Definition: config.h:101
audio::SampleSpec input_sample_spec
Input sample spec.
Definition: config.h:118
TaskConfig tasks
Task processing parameters.
Definition: config.h:103
bool resampling
Resample frames with a constant ratio.
Definition: config.h:130
audio::ProfilerConfig profiler_config
Profiler configuration.
Definition: config.h:145
bool timing
Constrain receiver speed using a CPU timer according to the sample rate.
Definition: config.h:136
core::nanoseconds_t packet_length
Packet length, in nanoseconds.
Definition: config.h:124
rtp::PayloadType payload_type
RTP payload type for audio packets.
Definition: config.h:127
bool interleaving
Interleave packets.
Definition: config.h:133
bool poisoning
Fill unitialized data with large values to make them more noticable.
Definition: config.h:139
bool profiling
Profile moving average of frames being written.
Definition: config.h:142
audio::ResamplerProfile resampler_profile
Resampler profile.
Definition: config.h:109
audio::ResamplerBackend resampler_backend
To specify which resampling backend will be used.
Definition: config.h:106
fec::CodecConfig fec_encoder
FEC encoder parameters.
Definition: config.h:115
fec::WriterConfig fec_writer
FEC writer parameters.
Definition: config.h:112
core::nanoseconds_t internal_frame_length
Duration of the internal frames, in nanoseconds.
Definition: config.h:121
Task processing parameters.
Definition: config.h:57
core::nanoseconds_t task_processing_prohibited_interval
Time interval during which no task processing is allowed. This setting is used to prohibit task proce...
Definition: config.h:89
bool enable_precise_task_scheduling
Enable precise task scheduling mode (default). The other settings have effect only when this is set t...
Definition: config.h:63
core::nanoseconds_t max_inframe_task_processing
Mximum task processing duration happening immediatelly after processing a frame. If this period expir...
Definition: config.h:82
core::nanoseconds_t max_frame_length_between_tasks
Maximum frame duration between processing tasks. If the frame is larger than this size,...
Definition: config.h:75
core::nanoseconds_t min_frame_length_between_tasks
Minimum frame duration between processing tasks. In-frame task processing does not happen until at le...
Definition: config.h:69
Validator parameters.
Definition: validator.h:24
Time definitions.
Various units used in packets.
RTP validator.
Watchdog.
FEC writer.