Roc Toolkit internal modules
Roc Toolkit: real-time audio streaming
pcm_encoder.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2015 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/pcm_encoder.h
10 //! @brief PCM encoder.
11 
12 #ifndef ROC_AUDIO_PCM_ENCODER_H_
13 #define ROC_AUDIO_PCM_ENCODER_H_
14 
16 #include "roc_audio/pcm_funcs.h"
17 #include "roc_core/noncopyable.h"
18 
19 namespace roc {
20 namespace audio {
21 
22 //! PCM encoder.
23 class PCMEncoder : public IFrameEncoder, public core::NonCopyable<> {
24 public:
25  //! Initialize.
26  explicit PCMEncoder(const PCMFuncs& funcs);
27 
28  //! Calculate encoded frame size for given number of samples per channel.
29  virtual size_t encoded_size(size_t num_samples) const;
30 
31  //! Start encoding a new frame.
32  virtual void begin(void* frame, size_t frame_size);
33 
34  //! Encode samples.
35  virtual size_t
36  write(const sample_t* samples, size_t n_samples, packet::channel_mask_t channels);
37 
38  //! Finish encoding frame.
39  virtual void end();
40 
41 private:
42  const PCMFuncs& funcs_;
43 
44  void* frame_data_;
45  size_t frame_size_;
46  size_t frame_pos_;
47 };
48 
49 } // namespace audio
50 } // namespace roc
51 
52 #endif // ROC_AUDIO_PCM_ENCODER_H_
Audio frame encoder interface.
Root namespace.
float sample_t
Audio sample.
Definition: units.h:21
virtual void begin(void *frame, size_t frame_size)
Start encoding a new frame.
uint32_t channel_mask_t
Bitmask of channels present in audio packet.
Definition: units.h:77
virtual size_t encoded_size(size_t num_samples) const
Calculate encoded frame size for given number of samples per channel.
PCM function table.
Definition: pcm_funcs.h:23
Base class for non-copyable objects.
Definition: noncopyable.h:23
Audio frame encoder interface.
virtual void end()
Finish encoding frame.
PCMEncoder(const PCMFuncs &funcs)
Initialize.
Non-copyable object.
RTP PCM functions.
virtual size_t write(const sample_t *samples, size_t n_samples, packet::channel_mask_t channels)
Encode samples.