Roc Toolkit internal modules
Roc Toolkit: real-time audio streaming
frame.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_audio/frame.h
10//! @brief Audio frame.
11
12#ifndef ROC_AUDIO_FRAME_H_
13#define ROC_AUDIO_FRAME_H_
14
15#include "roc_audio/sample.h"
18#include "roc_core/time.h"
19#include "roc_packet/units.h"
20
21namespace roc {
22namespace audio {
23
24//! Audio frame.
25class Frame : public core::NonCopyable<> {
26public:
27 //! Construct frame from samples.
28 //! @remarks
29 //! The pointer is saved in the frame, no copying is performed.
31
32 //! Frame flags.
33 enum {
34 //! Set if the frame has at least some samples from packets.
35 //! If this flag is clear, frame is completely zero because of lack of packets.
36 FlagNonblank = (1 << 0),
37
38 //! Set if the frame is not fully filled with samples from packets.
39 //! If this flag is set, frame is partially zero because of lack of packets.
40 FlagIncomplete = (1 << 1),
41
42 //! Set if some late packets were dropped while the frame was being built.
43 //! It's not necessarty that the frame itself is blank or incomplete.
44 FlagDrops = (1 << 2)
45 };
46
47 //! Set flags.
48 void set_flags(unsigned flags);
49
50 //! Get flags.
51 unsigned flags() const;
52
53 //! Get frame data.
54 sample_t* samples() const;
55
56 //! Get frame data size.
57 size_t num_samples() const;
58
59 //! Get unix-epoch timestamp in ns of the 1st sample.
61
62 //! Set unix-epoch timestamp in ns of the 1st sample.
64
65 //! Print frame to stderr.
66 void print() const;
67
68private:
69 sample_t* samples_;
70 size_t num_samples_;
71 unsigned flags_;
72 core::nanoseconds_t capture_timestamp_;
73};
74
75} // namespace audio
76} // namespace roc
77
78#endif // ROC_AUDIO_FRAME_H_
Audio frame.
Definition: frame.h:25
void set_flags(unsigned flags)
Set flags.
unsigned flags() const
Get flags.
Frame(sample_t *samples, size_t num_samples)
Construct frame from samples.
void print() const
Print frame to stderr.
void set_capture_timestamp(core::nanoseconds_t capture_ts)
Set unix-epoch timestamp in ns of the 1st sample.
size_t num_samples() const
Get frame data size.
@ FlagNonblank
Set if the frame has at least some samples from packets. If this flag is clear, frame is completely z...
Definition: frame.h:36
@ FlagDrops
Set if some late packets were dropped while the frame was being built. It's not necessarty that the f...
Definition: frame.h:44
@ FlagIncomplete
Set if the frame is not fully filled with samples from packets. If this flag is set,...
Definition: frame.h:40
sample_t * samples() const
Get frame data.
core::nanoseconds_t capture_timestamp() const
Get unix-epoch timestamp in ns of the 1st sample.
Base class for non-copyable objects.
Definition: noncopyable.h:23
float sample_t
Audio sample.
Definition: sample.h:22
int64_t nanoseconds_t
Nanoseconds.
Definition: time.h:58
Root namespace.
Non-copyable object.
Audio sample.
Sample specifications.
Time definitions.
Various units used in packets.