Roc Toolkit internal modules
Roc Toolkit: real-time audio streaming
Loading...
Searching...
No Matches
delayed_reader.h
Go to the documentation of this file.
1/*
2 * Copyright (c) 2015 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_packet/delayed_reader.h
10//! @brief Delayed reader.
11
12#ifndef ROC_PACKET_DELAYED_READER_H_
13#define ROC_PACKET_DELAYED_READER_H_
14
17#include "roc_core/time.h"
18#include "roc_packet/ireader.h"
20#include "roc_packet/units.h"
21
22namespace roc {
23namespace packet {
24
25//! Delayed reader.
26//! @remarks
27//! Delays audio packet reader for given amount of samples.
28class DelayedReader : public IReader, public core::NonCopyable<> {
29public:
30 //! Initialize.
31 //!
32 //! @b Parameters
33 //! - @p reader is used to read packets
34 //! - @p delay is the delay to insert before first packet
35 //! - @p sample_spec is the specifications of incoming packets
38 const audio::SampleSpec& sample_spec);
39
40 //! Read packet.
41 virtual PacketPtr read();
42
43private:
44 bool fetch_packets_();
45 PacketPtr read_queued_packet_();
46
47 timestamp_t queue_size_() const;
48
49 IReader& reader_;
50 SortedQueue queue_;
51
52 const timestamp_t delay_;
53 bool started_;
54};
55
56} // namespace packet
57} // namespace roc
58
59#endif // ROC_PACKET_DELAYED_READER_H_
Sample stream specification. Defines sample rate and channel layout.
Definition: sample_spec.h:24
Base class for non-copyable objects.
Definition: noncopyable.h:23
DelayedReader(IReader &reader, core::nanoseconds_t delay, const audio::SampleSpec &sample_spec)
Initialize.
virtual PacketPtr read()
Read packet.
Packet reader interface.
Definition: ireader.h:21
Sorted packet queue.
Definition: sorted_queue.h:27
Packet reader interface.
int64_t nanoseconds_t
Nanoseconds.
Definition: time.h:58
uint32_t timestamp_t
Audio packet timestamp.
Definition: units.h:25
Root namespace.
Non-copyable object.
Sample specifications.
Sorted packet queue.
Time definitions.
Various units used in packets.