Roc Toolkit internal modules
Roc Toolkit: real-time audio streaming
pcm_funcs.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2019 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_funcs.h
10 //! @brief RTP PCM functions.
11 
12 #ifndef ROC_AUDIO_PCM_FUNCS_H_
13 #define ROC_AUDIO_PCM_FUNCS_H_
14 
15 #include "roc_audio/units.h"
16 #include "roc_core/stddefs.h"
17 #include "roc_packet/units.h"
18 
19 namespace roc {
20 namespace audio {
21 
22 //! PCM function table.
23 struct PCMFuncs {
24  //! Get number of samples per channel from payload size in bytes.
25  size_t (*samples_from_payload_size)(size_t payload_size);
26 
27  //! Get payload size in bytes from number of samples per channel.
28  size_t (*payload_size_from_samples)(size_t num_samples);
29 
30  //! Encode samples.
31  size_t (*encode_samples)(void* out_data,
32  size_t out_size,
33  size_t out_offset,
34  const sample_t* in_samples,
35  size_t in_n_samples,
36  packet::channel_mask_t in_chan_mask);
37 
38  //! Decode samples.
39  size_t (*decode_samples)(const void* in_data,
40  size_t in_size,
41  size_t in_offset,
42  sample_t* out_samples,
43  size_t out_n_samples,
44  packet::channel_mask_t out_chan_mask);
45 };
46 
47 //! PCM functions for 16-bit 1-channel audio.
48 extern const PCMFuncs PCM_int16_1ch;
49 
50 //! PCM functions for 16-bit 2-channel audio.
51 extern const PCMFuncs PCM_int16_2ch;
52 
53 } // namespace audio
54 } // namespace roc
55 
56 #endif // ROC_AUDIO_PCM_FUNCS_H_
size_t(* decode_samples)(const void *in_data, size_t in_size, size_t in_offset, sample_t *out_samples, size_t out_n_samples, packet::channel_mask_t out_chan_mask)
Decode samples.
Definition: pcm_funcs.h:39
const PCMFuncs PCM_int16_2ch
PCM functions for 16-bit 2-channel audio.
Various units used in audio processing.
Root namespace.
float sample_t
Audio sample.
Definition: units.h:21
uint32_t channel_mask_t
Bitmask of channels present in audio packet.
Definition: units.h:77
PCM function table.
Definition: pcm_funcs.h:23
Commonly used types and functions.
size_t(* payload_size_from_samples)(size_t num_samples)
Get payload size in bytes from number of samples per channel.
Definition: pcm_funcs.h:28
size_t(* encode_samples)(void *out_data, size_t out_size, size_t out_offset, const sample_t *in_samples, size_t in_n_samples, packet::channel_mask_t in_chan_mask)
Encode samples.
Definition: pcm_funcs.h:31
const PCMFuncs PCM_int16_1ch
PCM functions for 16-bit 1-channel audio.
size_t(* samples_from_payload_size)(size_t payload_size)
Get number of samples per channel from payload size in bytes.
Definition: pcm_funcs.h:25
Various units used in packets.