summaryrefslogtreecommitdiffstats
path: root/xbmc/addons/kodi-addon-dev-kit/include/kodi/c-api/audio_engine.h
diff options
context:
space:
mode:
Diffstat (limited to 'xbmc/addons/kodi-addon-dev-kit/include/kodi/c-api/audio_engine.h')
-rw-r--r--xbmc/addons/kodi-addon-dev-kit/include/kodi/c-api/audio_engine.h308
1 files changed, 308 insertions, 0 deletions
diff --git a/xbmc/addons/kodi-addon-dev-kit/include/kodi/c-api/audio_engine.h b/xbmc/addons/kodi-addon-dev-kit/include/kodi/c-api/audio_engine.h
new file mode 100644
index 0000000..02e96ac
--- /dev/null
+++ b/xbmc/addons/kodi-addon-dev-kit/include/kodi/c-api/audio_engine.h
@@ -0,0 +1,308 @@
1/*
2 * Copyright (C) 2005-2019 Team Kodi
3 * This file is part of Kodi - https://kodi.tv
4 *
5 * SPDX-License-Identifier: GPL-2.0-or-later
6 * See LICENSES/README.md for more information.
7 */
8
9#pragma once
10
11#include "stdint.h"
12
13#ifdef __cplusplus
14extern "C"
15{
16#endif /* __cplusplus */
17
18 //¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯
19 // "C" Definitions, structures and enumerators of audio engine
20 //{{{
21
22 //============================================================================
23 /// @defgroup cpp_kodi_audioengine_Defs_AudioEngineStreamOptions enum AudioEngineStreamOptions
24 /// @ingroup cpp_kodi_audioengine_Defs
25 /// @brief **Bit options to pass to CAEStream**\n
26 /// A bit field of stream options.
27 ///
28 ///
29 /// ------------------------------------------------------------------------
30 ///
31 /// **Usage example:**
32 /// ~~~~~~~~~~~~~{.cpp}
33 /// // Here only as minimal, "format" must be set to wanted types
34 /// kodi::audioengine::AudioEngineFormat format;
35 /// m_audioengine = new kodi::audioengine::CAEStream(format, AUDIO_STREAM_FORCE_RESAMPLE | AUDIO_STREAM_AUTOSTART);
36 /// ~~~~~~~~~~~~~
37 ///
38 //@{
39 typedef enum AudioEngineStreamOptions
40 {
41 /// force resample even if rates match
42 AUDIO_STREAM_FORCE_RESAMPLE = 1 << 0,
43 /// create the stream paused
44 AUDIO_STREAM_PAUSED = 1 << 1,
45 /// autostart the stream when enough data is buffered
46 AUDIO_STREAM_AUTOSTART = 1 << 2,
47 } AudioEngineStreamOptions;
48 //@}
49 //----------------------------------------------------------------------------
50
51 //============================================================================
52 /// @defgroup cpp_kodi_audioengine_Defs_AudioEngineChannel enum AudioEngineChannel
53 /// @ingroup cpp_kodi_audioengine_Defs
54 /// @brief **The possible channels**\n
55 /// Used to set available or used channels on stream.
56 ///
57 ///
58 /// ------------------------------------------------------------------------
59 ///
60 /// **Usage example:**
61 /// ~~~~~~~~~~~~~{.cpp}
62 /// kodi::audioengine::AudioEngineFormat format;
63 /// format.SetChannelLayout(std::vector<AudioEngineChannel>(AUDIOENGINE_CH_FL, AUDIOENGINE_CH_FR));
64 /// ~~~~~~~~~~~~~
65 ///
66 //@{
67 enum AudioEngineChannel
68 {
69 /// Used inside to indicate the end of a list and not for addon use directly.
70 AUDIOENGINE_CH_NULL = -1,
71 /// RAW Audio format
72 AUDIOENGINE_CH_RAW,
73 /// Front left
74 AUDIOENGINE_CH_FL,
75 /// Front right
76 AUDIOENGINE_CH_FR,
77 /// Front center
78 AUDIOENGINE_CH_FC,
79 /// LFE / Subwoofer
80 AUDIOENGINE_CH_LFE,
81 /// Back left
82 AUDIOENGINE_CH_BL,
83 /// Back right
84 AUDIOENGINE_CH_BR,
85 /// Front left over center
86 AUDIOENGINE_CH_FLOC,
87 /// Front right over center
88 AUDIOENGINE_CH_FROC,
89 /// Back center
90 AUDIOENGINE_CH_BC,
91 /// Side left
92 AUDIOENGINE_CH_SL,
93 /// Side right
94 AUDIOENGINE_CH_SR,
95 /// Top front left
96 AUDIOENGINE_CH_TFL,
97 /// Top front right
98 AUDIOENGINE_CH_TFR,
99 /// Top front center
100 AUDIOENGINE_CH_TFC,
101 /// Top center
102 AUDIOENGINE_CH_TC,
103 /// Top back left
104 AUDIOENGINE_CH_TBL,
105 /// Top back right
106 AUDIOENGINE_CH_TBR,
107 /// Top back center
108 AUDIOENGINE_CH_TBC,
109 /// Back left over center
110 AUDIOENGINE_CH_BLOC,
111 /// Back right over center
112 AUDIOENGINE_CH_BROC,
113 /// Maximum possible value, to use e.g. as size inside list
114 AUDIOENGINE_CH_MAX
115 };
116 //@}
117 //----------------------------------------------------------------------------
118
119 //============================================================================
120 /// @defgroup cpp_kodi_audioengine_Defs_AudioEngineDataFormat enum AudioEngineDataFormat
121 /// @ingroup cpp_kodi_audioengine_Defs
122 /// @brief **Audio sample formats**\n
123 /// The bit layout of the audio data.
124 ///
125 /// LE = Little Endian, BE = Big Endian, NE = Native Endian
126 ///
127 /// For planar sample formats, each audio channel is in a separate data plane,
128 /// and linesize is the buffer size, in bytes, for a single plane. All data
129 /// planes must be the same size. For packed sample formats, only the first
130 /// data plane is used, and samples for each channel are interleaved. In this
131 /// case, linesize is the buffer size, in bytes, for the 1 plane.
132 ///
133 /// @note This is ordered from the worst to best preferred formats
134 ///
135 ///
136 /// ------------------------------------------------------------------------
137 ///
138 /// **Usage example:**
139 /// ~~~~~~~~~~~~~{.cpp}
140 /// kodi::audioengine::AudioEngineFormat format;
141 /// format.SetDataFormat(AUDIOENGINE_FMT_FLOATP);
142 /// ~~~~~~~~~~~~~
143 ///
144 //@{
145 enum AudioEngineDataFormat
146 {
147 /// To define format as invalid
148 AUDIOENGINE_FMT_INVALID = -1,
149
150 /// Unsigned integer 8 bit
151 AUDIOENGINE_FMT_U8,
152
153 /// Big Endian signed integer 16 bit
154 AUDIOENGINE_FMT_S16BE,
155 /// Little Endian signed integer 16 bit
156 AUDIOENGINE_FMT_S16LE,
157 /// Native Endian signed integer 16 bit
158 AUDIOENGINE_FMT_S16NE,
159
160 /// Big Endian signed integer 32 bit
161 AUDIOENGINE_FMT_S32BE,
162 /// Little Endian signed integer 32 bit
163 AUDIOENGINE_FMT_S32LE,
164 /// Native Endian signed integer 32 bit
165 AUDIOENGINE_FMT_S32NE,
166
167 /// Big Endian signed integer 24 bit (in 4 bytes)
168 AUDIOENGINE_FMT_S24BE4,
169 /// Little Endian signed integer 24 bit (in 4 bytes)
170 AUDIOENGINE_FMT_S24LE4,
171 /// Native Endian signed integer 24 bit (in 4 bytes)
172 AUDIOENGINE_FMT_S24NE4,
173 /// S32 with bits_per_sample < 32
174 AUDIOENGINE_FMT_S24NE4MSB,
175
176 /// Big Endian signed integer 24 bit (3 bytes)
177 AUDIOENGINE_FMT_S24BE3,
178 /// Little Endian signed integer 24 bit (3 bytes)
179 AUDIOENGINE_FMT_S24LE3,
180 /// Native Endian signed integer 24 bit (3 bytes)
181 AUDIOENGINE_FMT_S24NE3,
182
183 /// Double floating point
184 AUDIOENGINE_FMT_DOUBLE,
185 /// Floating point
186 AUDIOENGINE_FMT_FLOAT,
187
188 /// **Bitstream**\n
189 /// RAW Audio format
190 AUDIOENGINE_FMT_RAW,
191
192 /// **Planar format**\n
193 /// Unsigned byte
194 AUDIOENGINE_FMT_U8P,
195 /// **Planar format**\n
196 /// Native Endian signed 16 bit
197 AUDIOENGINE_FMT_S16NEP,
198 /// **Planar format**\n
199 /// Native Endian signed 32 bit
200 AUDIOENGINE_FMT_S32NEP,
201 /// **Planar format**\n
202 /// Native Endian signed integer 24 bit (in 4 bytes)
203 AUDIOENGINE_FMT_S24NE4P,
204 /// **Planar format**\n
205 /// S32 with bits_per_sample < 32
206 AUDIOENGINE_FMT_S24NE4MSBP,
207 /// **Planar format**\n
208 /// Native Endian signed integer 24 bit (in 3 bytes)
209 AUDIOENGINE_FMT_S24NE3P,
210 /// **Planar format**\n
211 /// Double floating point
212 AUDIOENGINE_FMT_DOUBLEP,
213 /// **Planar format**\n
214 /// Floating point
215 AUDIOENGINE_FMT_FLOATP,
216
217 /// Amount of sample formats.
218 AUDIOENGINE_FMT_MAX
219 };
220 //@}
221 //----------------------------------------------------------------------------
222
223 /*!
224 * @brief Internal API structure which are used for data exchange between
225 * Kodi and addon.
226 */
227 struct AUDIO_ENGINE_FORMAT
228 {
229 /*! The stream's data format (eg, AUDIOENGINE_FMT_S16LE) */
230 enum AudioEngineDataFormat m_dataFormat;
231
232 /*! The stream's sample rate (eg, 48000) */
233 unsigned int m_sampleRate;
234
235 /*! The encoded streams sample rate if a bitstream, otherwise undefined */
236 unsigned int m_encodedRate;
237
238 /*! The amount of used speaker channels */
239 unsigned int m_channelCount;
240
241 /*! The stream's channel layout */
242 enum AudioEngineChannel m_channels[AUDIOENGINE_CH_MAX];
243
244 /*! The number of frames per period */
245 unsigned int m_frames;
246
247 /*! The size of one frame in bytes */
248 unsigned int m_frameSize;
249 };
250
251 /* A stream handle pointer, which is only used internally by the addon stream handle */
252 typedef void AEStreamHandle;
253
254 //}}}
255
256 //¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯
257 // "C" Internal interface tables for intercommunications between addon and kodi
258 //{{{
259
260 /*
261 * Function address structure, not need to visible on dev kit doxygen
262 * documentation
263 */
264 typedef struct AddonToKodiFuncTable_kodi_audioengine
265 {
266 AEStreamHandle* (*make_stream)(void* kodiBase,
267 struct AUDIO_ENGINE_FORMAT* format,
268 unsigned int options);
269 void (*free_stream)(void* kodiBase, AEStreamHandle* stream);
270 bool (*get_current_sink_format)(void* kodiBase, struct AUDIO_ENGINE_FORMAT* sink_format);
271
272 // Audio Engine Stream definitions
273 unsigned int (*aestream_get_space)(void* kodiBase, AEStreamHandle* handle);
274 unsigned int (*aestream_add_data)(void* kodiBase,
275 AEStreamHandle* handle,
276 uint8_t* const* data,
277 unsigned int offset,
278 unsigned int frames,
279 double pts,
280 bool hasDownmix,
281 double centerMixLevel);
282 double (*aestream_get_delay)(void* kodiBase, AEStreamHandle* handle);
283 bool (*aestream_is_buffering)(void* kodiBase, AEStreamHandle* handle);
284 double (*aestream_get_cache_time)(void* kodiBase, AEStreamHandle* handle);
285 double (*aestream_get_cache_total)(void* kodiBase, AEStreamHandle* handle);
286 void (*aestream_pause)(void* kodiBase, AEStreamHandle* handle);
287 void (*aestream_resume)(void* kodiBase, AEStreamHandle* handle);
288 void (*aestream_drain)(void* kodiBase, AEStreamHandle* handle, bool wait);
289 bool (*aestream_is_draining)(void* kodiBase, AEStreamHandle* handle);
290 bool (*aestream_is_drained)(void* kodiBase, AEStreamHandle* handle);
291 void (*aestream_flush)(void* kodiBase, AEStreamHandle* handle);
292 float (*aestream_get_volume)(void* kodiBase, AEStreamHandle* handle);
293 void (*aestream_set_volume)(void* kodiBase, AEStreamHandle* handle, float volume);
294 float (*aestream_get_amplification)(void* kodiBase, AEStreamHandle* handle);
295 void (*aestream_set_amplification)(void* kodiBase, AEStreamHandle* handle, float amplify);
296 unsigned int (*aestream_get_frame_size)(void* kodiBase, AEStreamHandle* handle);
297 unsigned int (*aestream_get_channel_count)(void* kodiBase, AEStreamHandle* handle);
298 unsigned int (*aestream_get_sample_rate)(void* kodiBase, AEStreamHandle* handle);
299 enum AudioEngineDataFormat (*aestream_get_data_format)(void* kodiBase, AEStreamHandle* handle);
300 double (*aestream_get_resample_ratio)(void* kodiBase, AEStreamHandle* handle);
301 void (*aestream_set_resample_ratio)(void* kodiBase, AEStreamHandle* handle, double ratio);
302 } AddonToKodiFuncTable_kodi_audioengine;
303
304 //}}}
305
306#ifdef __cplusplus
307}
308#endif /* __cplusplus */