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 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/units.h"
16 #include "roc_core/noncopyable.h"
17 
18 namespace roc {
19 namespace audio {
20 
21 //! Audio frame.
22 class Frame : public core::NonCopyable<> {
23 public:
24  //! Construct frame from samples.
25  //! @remarks
26  //! The pointer is saved in the frame, no copying is performed.
27  Frame(sample_t* data, size_t size);
28 
29  //! Frame flags.
30  enum {
31  //! Set if the frame is fully filled with zeros instead of data from packets.
32  FlagBlank = (1 << 0),
33 
34  //! Set if the frame is partially filled with zeros instead of data from packets.
35  FlagIncomplete = (1 << 1),
36 
37  //! Set if some late packets were dropped while the frame was being built.
38  FlagDrops = (1 << 2)
39  };
40 
41  //! Set flags.
42  void set_flags(unsigned flags);
43 
44  //! Get flags.
45  unsigned flags() const;
46 
47  //! Get frame data.
48  sample_t* data() const;
49 
50  //! Get frame data size.
51  size_t size() const;
52 
53 private:
54  sample_t* data_;
55  size_t size_;
56  unsigned flags_;
57 };
58 
59 } // namespace audio
60 } // namespace roc
61 
62 #endif // ROC_AUDIO_FRAME_H_
void set_flags(unsigned flags)
Set flags.
unsigned flags() const
Get flags.
Various units used in audio processing.
Root namespace.
float sample_t
Audio sample.
Definition: units.h:21
Frame(sample_t *data, size_t size)
Construct frame from samples.
size_t size() const
Get frame data size.
Audio frame.
Definition: frame.h:22
Set if the frame is fully filled with zeros instead of data from packets.
Definition: frame.h:32
Base class for non-copyable objects.
Definition: noncopyable.h:23
sample_t * data() const
Get frame data.
Set if some late packets were dropped while the frame was being built.
Definition: frame.h:38
Non-copyable object.
Set if the frame is partially filled with zeros instead of data from packets.
Definition: frame.h:35