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.
42
43private:
44 status::StatusCode fetch_packets_();
45 status::StatusCode read_queued_packet_(PacketPtr&);
46
47 stream_timestamp_t queue_size_() const;
48
49 IReader& reader_;
50 SortedQueue queue_;
51
52 const stream_timestamp_t delay_;
53 bool started_;
54};
55
56} // namespace packet
57} // namespace roc
58
59#endif // ROC_PACKET_DELAYED_READER_H_
#define ROC_ATTR_NODISCARD
Emit warning if function result is not checked.
Definition attributes.h:31
Sample specification. Describes sample rate and channels.
Definition sample_spec.h:26
Base class for non-copyable objects.
Definition noncopyable.h:23
Shared ownership intrusive pointer.
Definition shared_ptr.h:32
DelayedReader(IReader &reader, core::nanoseconds_t delay, const audio::SampleSpec &sample_spec)
Initialize.
virtual ROC_ATTR_NODISCARD status::StatusCode read(PacketPtr &)
Read packet.
Packet reader interface.
Definition ireader.h:23
Sorted packet queue.
Packet reader interface.
uint32_t stream_timestamp_t
Packet stream timestamp.
Definition units.h:36
Root namespace.
Non-copyable object.
Sample specifications.
Sorted packet queue.
StatusCode
Status code.
Definition status_code.h:19
Time definitions.
Various units used in packets.