Roc Toolkit internal modules
Roc Toolkit: real-time audio streaming
Toggle main menu visibility
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
15
#include "
roc_audio/sample_spec.h
"
16
#include "
roc_core/noncopyable.h
"
17
#include "
roc_core/time.h
"
18
#include "
roc_packet/ireader.h
"
19
#include "
roc_packet/sorted_queue.h
"
20
#include "
roc_packet/units.h
"
21
22
namespace
roc
{
23
namespace
packet
{
24
25
//! Delayed reader.
26
//! @remarks
27
//! Delays audio packet reader for given amount of samples.
28
class
DelayedReader
:
public
IReader
,
public
core::NonCopyable
<> {
29
public
:
30
//! Initialize.
31
//!
32
//! @b Parameters
33
//! - @p reader is used to read packets
34
//! - @p target_delay is the delay to insert before first packet
35
//! - @p sample_spec is the specifications of incoming packets
36
DelayedReader
(
IReader
& reader,
37
core::nanoseconds_t
target_delay,
38
const
audio::SampleSpec
& sample_spec);
39
40
//! Check if object was constructed successfully.
41
bool
is_valid
()
const
;
42
43
//! Read packet.
44
virtual
ROC_ATTR_NODISCARD
status::StatusCode
read
(
PacketPtr
&);
45
46
private
:
47
status::StatusCode
fetch_packets_();
48
status::StatusCode
read_queued_packet_(
PacketPtr
&);
49
50
stream_timestamp_t
queue_size_()
const
;
51
52
IReader
& reader_;
53
SortedQueue
queue_;
54
55
stream_timestamp_t
delay_;
56
bool
started_;
57
58
const
audio::SampleSpec
sample_spec_;
59
60
bool
valid_;
61
};
62
63
}
// namespace packet
64
}
// namespace roc
65
66
#endif
// ROC_PACKET_DELAYED_READER_H_
ROC_ATTR_NODISCARD
#define ROC_ATTR_NODISCARD
Emit warning if function result is not checked.
Definition
attributes.h:31
roc::audio::SampleSpec
Sample specification. Describes sample rate and channels.
Definition
sample_spec.h:30
roc::core::NonCopyable
Base class for non-copyable objects.
Definition
noncopyable.h:23
roc::packet::DelayedReader::read
virtual ROC_ATTR_NODISCARD status::StatusCode read(PacketPtr &)
Read packet.
roc::packet::DelayedReader::DelayedReader
DelayedReader(IReader &reader, core::nanoseconds_t target_delay, const audio::SampleSpec &sample_spec)
Initialize.
roc::packet::DelayedReader::is_valid
bool is_valid() const
Check if object was constructed successfully.
roc::packet::IReader
Packet reader interface.
Definition
ireader.h:23
roc::packet::SortedQueue
Sorted packet queue.
Definition
sorted_queue.h:27
ireader.h
Packet reader interface.
roc::core::nanoseconds_t
int64_t nanoseconds_t
Nanoseconds.
Definition
time.h:58
roc::packet
Network packets and packet processing.
roc::packet::PacketPtr
core::SharedPtr< Packet > PacketPtr
Packet smart pointer.
Definition
packet.h:34
roc::packet::stream_timestamp_t
uint32_t stream_timestamp_t
Packet stream timestamp.
Definition
units.h:36
roc
Root namespace.
noncopyable.h
Non-copyable object.
sample_spec.h
Sample specifications.
sorted_queue.h
Sorted packet queue.
roc::status::StatusCode
StatusCode
Status code.
Definition
status_code.h:19
time.h
Time definitions.
units.h
Various units used in packets.
roc_packet
delayed_reader.h
Generated by
1.17.0