Roc Toolkit internal modules
Roc Toolkit: real-time audio streaming
profiling_writer.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2018 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_audio/profiling_writer.h
10 //! @brief Profiling writer.
11 
12 #ifndef ROC_AUDIO_PROFILING_WRITER_H_
13 #define ROC_AUDIO_PROFILING_WRITER_H_
14 
15 #include "roc_audio/iwriter.h"
16 #include "roc_core/noncopyable.h"
17 #include "roc_core/rate_limiter.h"
18 #include "roc_core/time.h"
19 #include "roc_packet/units.h"
20 
21 namespace roc {
22 namespace audio {
23 
24 //! Profiling writer.
25 class ProfilingWriter : public IWriter, public core::NonCopyable<> {
26 public:
27  //! Initialization.
28  ProfilingWriter(IWriter& writer, packet::channel_mask_t channels, size_t sample_rate);
29 
30  //! Write audio frame.
31  virtual void write(Frame& frame);
32 
33 private:
34  core::nanoseconds_t write_(Frame& frame);
35  void update_(double speed);
36 
37  IWriter& writer_;
38 
39  core::RateLimiter rate_limiter_;
40 
41  double avg_speed_;
42  double avg_len_;
43 
44  const size_t sample_rate_;
45  const size_t num_channels_;
46 };
47 
48 } // namespace audio
49 } // namespace roc
50 
51 #endif // ROC_AUDIO_PROFILING_WRITER_H_
Audio writer interface.
Definition: iwriter.h:21
virtual void write(Frame &frame)
Write audio frame.
Time definitions.
Rate limiter.
Definition: rate_limiter.h:22
Root namespace.
Rate limiter.
ProfilingWriter(IWriter &writer, packet::channel_mask_t channels, size_t sample_rate)
Initialization.
int64_t nanoseconds_t
Nanoseconds.
Definition: time.h:21
uint32_t channel_mask_t
Bitmask of channels present in audio packet.
Definition: units.h:77
Audio frame.
Definition: frame.h:22
Audio writer interface.
Base class for non-copyable objects.
Definition: noncopyable.h:23
Various units used in packets.
Non-copyable object.