summaryrefslogtreecommitdiffstats
path: root/xbmc/addons/kodi-addon-dev-kit/include/kodi
diff options
context:
space:
mode:
Diffstat (limited to 'xbmc/addons/kodi-addon-dev-kit/include/kodi')
-rw-r--r--xbmc/addons/kodi-addon-dev-kit/include/kodi/AddonBase.h39
-rw-r--r--xbmc/addons/kodi-addon-dev-kit/include/kodi/AudioEngine.h597
-rw-r--r--xbmc/addons/kodi-addon-dev-kit/include/kodi/CMakeLists.txt5
-rw-r--r--xbmc/addons/kodi-addon-dev-kit/include/kodi/addon-instance/AudioDSP.h1288
-rw-r--r--xbmc/addons/kodi-addon-dev-kit/include/kodi/addon-instance/CMakeLists.txt3
-rw-r--r--xbmc/addons/kodi-addon-dev-kit/include/kodi/addon-instance/Peripheral.h162
-rw-r--r--xbmc/addons/kodi-addon-dev-kit/include/kodi/addon-instance/PeripheralUtils.h220
-rw-r--r--xbmc/addons/kodi-addon-dev-kit/include/kodi/addon-instance/VFS.h6
-rw-r--r--xbmc/addons/kodi-addon-dev-kit/include/kodi/addon-instance/VideoCodec.h2
-rw-r--r--xbmc/addons/kodi-addon-dev-kit/include/kodi/addon-instance/Visualization.h2
-rw-r--r--xbmc/addons/kodi-addon-dev-kit/include/kodi/kodi_game_dll.h99
-rw-r--r--xbmc/addons/kodi-addon-dev-kit/include/kodi/kodi_game_types.h116
-rw-r--r--xbmc/addons/kodi-addon-dev-kit/include/kodi/libKODI_game.h22
-rw-r--r--xbmc/addons/kodi-addon-dev-kit/include/kodi/libKODI_guilib.h2
-rw-r--r--xbmc/addons/kodi-addon-dev-kit/include/kodi/libXBMC_addon.h6
-rw-r--r--xbmc/addons/kodi-addon-dev-kit/include/kodi/libXBMC_pvr.h2
-rw-r--r--xbmc/addons/kodi-addon-dev-kit/include/kodi/platform/android/System.h107
-rw-r--r--xbmc/addons/kodi-addon-dev-kit/include/kodi/versions.h28
-rw-r--r--xbmc/addons/kodi-addon-dev-kit/include/kodi/xbmc_epg_types.h4
-rw-r--r--xbmc/addons/kodi-addon-dev-kit/include/kodi/xbmc_pvr_dll.h13
-rw-r--r--xbmc/addons/kodi-addon-dev-kit/include/kodi/xbmc_pvr_types.h4
21 files changed, 671 insertions, 2056 deletions
diff --git a/xbmc/addons/kodi-addon-dev-kit/include/kodi/AddonBase.h b/xbmc/addons/kodi-addon-dev-kit/include/kodi/AddonBase.h
index 432a1c3..7abd8e1 100644
--- a/xbmc/addons/kodi-addon-dev-kit/include/kodi/AddonBase.h
+++ b/xbmc/addons/kodi-addon-dev-kit/include/kodi/AddonBase.h
@@ -40,13 +40,9 @@
40#undef PRAGMA_PACK_END 40#undef PRAGMA_PACK_END
41 41
42#if defined(__GNUC__) 42#if defined(__GNUC__)
43 #if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 95) 43 #define ATTRIBUTE_PACKED __attribute__ ((packed))
44 #define ATTRIBUTE_PACKED __attribute__ ((packed)) 44 #define PRAGMA_PACK 0
45 #define PRAGMA_PACK 0 45 #define ATTRIBUTE_HIDDEN __attribute__ ((visibility ("hidden")))
46 #if __GNUC__ >= 4
47 #define ATTRIBUTE_HIDDEN __attribute__ ((visibility ("hidden")))
48 #endif
49 #endif
50#endif 46#endif
51 47
52#if !defined(ATTRIBUTE_PACKED) 48#if !defined(ATTRIBUTE_PACKED)
@@ -180,6 +176,8 @@ typedef struct AddonToKodiFuncTable_Addon
180 AddonToKodiFuncTable_kodi_filesystem* kodi_filesystem; 176 AddonToKodiFuncTable_kodi_filesystem* kodi_filesystem;
181 AddonToKodiFuncTable_kodi_gui* kodi_gui; 177 AddonToKodiFuncTable_kodi_gui* kodi_gui;
182 AddonToKodiFuncTable_kodi_network *kodi_network; 178 AddonToKodiFuncTable_kodi_network *kodi_network;
179
180 void* (*get_interface)(void* kodiBase, const char *name, const char *version);
183} AddonToKodiFuncTable_Addon; 181} AddonToKodiFuncTable_Addon;
184 182
185/* 183/*
@@ -605,6 +603,33 @@ inline std::string TranslateAddonStatus(ADDON_STATUS status)
605} /* namespace kodi */ 603} /* namespace kodi */
606//---------------------------------------------------------------------------- 604//----------------------------------------------------------------------------
607 605
606//==============================================================================
607namespace kodi {
608///
609/// \ingroup cpp_kodi
610/// @brief Returns a function table to a named interface
611///
612/// @return pointer to struct containing interface functions
613///
614///
615/// ------------------------------------------------------------------------
616///
617/// **Example:**
618/// ~~~~~~~~~~~~~{.cpp}
619/// #include <kodi/General.h>
620/// #include <kodi/platform/foo.h>
621/// ...
622/// FuncTable_foo *table = kodi::GetPlatformInfo(foo_name, foo_version);
623/// ...
624/// ~~~~~~~~~~~~~
625///
626inline void* GetInterface(const std::string &name, const std::string &version)
627{
628 AddonToKodiFuncTable_Addon* toKodi = ::kodi::addon::CAddonBase::m_interface->toKodi;
629
630 return toKodi->get_interface(toKodi->kodiBase, name.c_str(), version.c_str());
631}
632} /* namespace kodi */
608 633
609/*! addon creation macro 634/*! addon creation macro
610 * @todo cleanup this stupid big macro 635 * @todo cleanup this stupid big macro
diff --git a/xbmc/addons/kodi-addon-dev-kit/include/kodi/AudioEngine.h b/xbmc/addons/kodi-addon-dev-kit/include/kodi/AudioEngine.h
deleted file mode 100644
index 02faf86..0000000
--- a/xbmc/addons/kodi-addon-dev-kit/include/kodi/AudioEngine.h
+++ /dev/null
@@ -1,597 +0,0 @@
1#pragma once
2/*
3 * Copyright (C) 2005-2017 Team KODI
4 * http://kodi.tv
5 *
6 * This Program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2, or (at your option)
9 * any later version.
10 *
11 * This Program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with Kodi; see the file COPYING. If not, see
18 * <http://www.gnu.org/licenses/>.
19 *
20 */
21
22#include "AddonBase.h"
23
24#ifdef BUILD_KODI_ADDON
25#include "AEChannelData.h"
26#else
27#include "cores/AudioEngine/Utils/AEChannelData.h"
28#endif
29
30//==============================================================================
31///
32/// \defgroup cpp_kodi_audioengine Interface - kodi::audioengine
33/// \ingroup cpp
34/// @brief **Audio engine functions**
35///
36///
37/// It has the header \ref AudioEngine.h "#include <kodi/AudioEngine.h>" be included
38/// to enjoy it.
39///
40//------------------------------------------------------------------------------
41
42//==============================================================================
43///
44/// \defgroup cpp_kodi_audioengine_Defs Definitions, structures and enumerators
45/// \ingroup cpp_kodi_audioengine
46/// @brief **Library definition values**
47///
48//------------------------------------------------------------------------------
49
50extern "C"
51{
52
53 //============================================================================
54 /// \ingroup cpp_kodi_audioengine_Defs
55 /// @brief Bit options to pass to CAddonAEStream
56 ///
57 typedef enum AudioEngineStreamOptions
58 {
59 /// force resample even if rates match
60 AUDIO_STREAM_FORCE_RESAMPLE = 1 << 0,
61 /// create the stream paused
62 AUDIO_STREAM_PAUSED = 1 << 1,
63 /// autostart the stream when enough data is buffered
64 AUDIO_STREAM_AUTOSTART = 1 << 2,
65 /// if this option is set the ADSP-System is bypassed and the raw stream
66 /// will be passed through IAESink
67 AUDIO_STREAM_BYPASS_ADSP = 1 << 3
68 } AudioEngineStreamOptions;
69 //----------------------------------------------------------------------------
70
71 //============================================================================
72 /// \defgroup cpp_kodi_audioengine_Defs_AudioEngineFormat struct AudioEngineFormat
73 /// \ingroup cpp_kodi_audioengine_Defs
74 /// @brief The audio format structure that fully defines a stream's audio
75 /// information
76 ///
77 //@{
78 struct AudioEngineFormat
79 {
80 /// The stream's data format (eg, AE_FMT_S16LE)
81 enum AEDataFormat m_dataFormat;
82
83 /// The stream's sample rate (eg, 48000)
84 unsigned int m_sampleRate;
85
86 /// The encoded streams sample rate if a bitstream, otherwise undefined
87 unsigned int m_encodedRate;
88
89 /// The amount of used speaker channels
90 unsigned int m_channelCount;
91
92 /// The stream's channel layout
93 enum AEChannel m_channels[AE_CH_MAX];
94
95 /// The number of frames per period
96 unsigned int m_frames;
97
98 /// The size of one frame in bytes
99 unsigned int m_frameSize;
100
101 AudioEngineFormat()
102 {
103 m_dataFormat = AE_FMT_INVALID;
104 m_sampleRate = 0;
105 m_encodedRate = 0;
106 m_frames = 0;
107 m_frameSize = 0;
108 m_channelCount = 0;
109
110 for (unsigned int ch = 0; ch < AE_CH_MAX; ++ch)
111 {
112 m_channels[ch] = AE_CH_MAX;
113 }
114 }
115
116 /// Function to compare the format structure with another
117 bool compareFormat(const AudioEngineFormat *fmt)
118 {
119 if (!fmt)
120 {
121 return false;
122 }
123
124 if (m_dataFormat != fmt->m_dataFormat ||
125 m_sampleRate != fmt->m_sampleRate ||
126 m_encodedRate != fmt->m_encodedRate ||
127 m_frames != fmt->m_frames ||
128 m_frameSize != fmt->m_frameSize ||
129 m_channelCount != fmt->m_channelCount)
130 {
131 return false;
132 }
133
134 for (unsigned int ch = 0; ch < AE_CH_MAX; ++ch)
135 {
136 if (fmt->m_channels[ch] != m_channels[ch])
137 {
138 return false;
139 }
140 }
141
142 return true;
143 }
144 };
145 //@}
146 //----------------------------------------------------------------------------
147
148 /* A stream handle pointer, which is only used internally by the addon stream handle */
149 typedef void AEStreamHandle;
150
151 /*
152 * Function address structure, not need to visible on dev kit doxygen
153 * documentation
154 */
155 typedef struct AddonToKodiFuncTable_kodi_audioengine
156 {
157 AEStreamHandle* (*make_stream)(void *kodiBase, AudioEngineFormat* format, unsigned int options);
158 void (*free_stream)(void *kodiBase, AEStreamHandle *stream);
159 bool (*get_current_sink_format)(void *kodiBase, AudioEngineFormat* sink_format);
160
161 // Audio Engine Stream definitions
162 unsigned int (*aestream_get_space)(void *kodiBase, AEStreamHandle *handle);
163 unsigned int (*aestream_add_data)(void *kodiBase, AEStreamHandle *handle, uint8_t* const *data,
164 unsigned int offset, unsigned int frames, double pts);
165 double (*aestream_get_delay)(void *kodiBase, AEStreamHandle *handle);
166 bool (*aestream_is_buffering)(void *kodiBase, AEStreamHandle *handle);
167 double (*aestream_get_cache_time)(void *kodiBase, AEStreamHandle *handle);
168 double (*aestream_get_cache_total)(void *kodiBase, AEStreamHandle *handle);
169 void (*aestream_pause)(void *kodiBase, AEStreamHandle *handle);
170 void (*aestream_resume)(void *kodiBase, AEStreamHandle *handle);
171 void (*aestream_drain)(void *kodiBase, AEStreamHandle *handle, bool wait);
172 bool (*aestream_is_draining)(void *kodiBase, AEStreamHandle *handle);
173 bool (*aestream_is_drained)(void *kodiBase, AEStreamHandle *handle);
174 void (*aestream_flush)(void *kodiBase, AEStreamHandle *handle);
175 float (*aestream_get_volume)(void *kodiBase, AEStreamHandle *handle);
176 void (*aestream_set_volume)(void *kodiBase, AEStreamHandle *handle, float volume);
177 float (*aestream_get_amplification)(void *kodiBase, AEStreamHandle *handle);
178 void (*aestream_set_amplification)(void *kodiBase, AEStreamHandle *handle, float amplify);
179 unsigned int (*aestream_get_frame_size)(void *kodiBase, AEStreamHandle *handle);
180 unsigned int (*aestream_get_channel_count)(void *kodiBase, AEStreamHandle *handle);
181 unsigned int (*aestream_get_sample_rate)(void *kodiBase, AEStreamHandle *handle);
182 AEDataFormat (*aestream_get_data_format)(void *kodiBase, AEStreamHandle *handle);
183 double (*aestream_get_resample_ratio)(void *kodiBase, AEStreamHandle *handle);
184 void (*aestream_set_resample_ratio)(void *kodiBase, AEStreamHandle *handle, double ratio);
185 } AddonToKodiFuncTable_kodi_audioengine;
186
187} /* extern "C" */
188
189namespace kodi
190{
191namespace audioengine
192{
193
194 //============================================================================
195 ///
196 /// \defgroup cpp_kodi_audioengine_CAddonAEStream class CAddonAEStream
197 /// \ingroup cpp_kodi_audioengine
198 /// @brief **Audio Engine Stream Class**
199 ///
200 ///
201 /// It has the header \ref AudioEngine.h "#include <kodi/AudioEngine.h>" be
202 /// included to enjoy it.
203 ///
204 //----------------------------------------------------------------------------
205 class CAddonAEStream
206 {
207 public:
208 //==========================================================================
209 /// @ingroup cpp_kodi_audioengine_CAddonAEStream
210 /// @brief Contructs new class to an Kodi IAEStream in the format specified.
211 ///
212 /// @param[in] format The data format the incoming audio will be in
213 /// (e.g. \ref AE_FMT_S16LE)
214 /// @param[in] options [opt] A bit field of stream options (see: enum \ref AudioEngineStreamOptions)
215 ///
216 ///
217 /// ------------------------------------------------------------------------
218 ///
219 /// **Audio engine format information:**
220 /// @code
221 /// /*
222 /// * Audio engine format information
223 /// *
224 /// * Only as example shown here! See always the original structure on related header.
225 /// */
226 /// typedef struct AudioEngineFormat
227 /// {
228 /// enum AEDataFormat m_dataFormat; /* The stream's data format (eg, AE_FMT_S16LE) */
229 /// unsigned int m_sampleRate; /* The stream's sample rate (eg, 48000) */
230 /// unsigned int m_encodedRate; /* The encoded streams sample rate if a bitstream, otherwise undefined */
231 /// unsigned int m_channelCount; /* The amount of used speaker channels */
232 /// enum AEChannel m_channels[AE_CH_MAX]; /* The stream's channel layout */
233 /// unsigned int m_frames; /* The number of frames per period */
234 /// unsigned int m_frameSamples; /* The number of samples in one frame */
235 /// unsigned int m_frameSize; /* The size of one frame in bytes */
236 ///
237 /// /* Function to compare the format structure with another */
238 /// bool compareFormat(const AudioEngineFormat *fmt);
239 /// } AudioEngineFormat;
240 /// @endcode
241 ///
242 /// ------------------------------------------------------------------------
243 ///
244 /// **Bit options to pass to CAELib_Stream (on Kodi by <c>IAE::MakeStream</c>)**
245 ///
246 /// | enum AEStreamOptions | Value: | Description:
247 /// |----------------------------:|:------:|:-----------------------------------
248 /// | AUDIO_STREAM_FORCE_RESAMPLE | 1 << 0 | Force resample even if rates match
249 /// | AUDIO_STREAM_PAUSED | 1 << 1 | Create the stream paused
250 /// | AUDIO_STREAM_AUTOSTART | 1 << 2 | Autostart the stream when enough data is buffered
251 /// | AUDIO_STREAM_BYPASS_ADSP | 1 << 3 | if this option is set the ADSP-System is bypassed and the raw stream will be passed through IAESink.
252 ///
253 ///
254 /// ------------------------------------------------------------------------
255 ///
256 /// **Example:**
257 /// ~~~~~~~~~~~~~{.cpp}
258 ///
259 /// #include <kodi/AudioEngine.h>
260 ///
261 /// using namespace kodi::audioengine;
262 ///
263 /// ...
264 ///
265 /// AudioEngineFormat format;
266 /// format.m_dataFormat = AE_FMT_FLOAT;
267 /// format.m_channelCount = 2;
268 /// format.m_channels[0] = AE_CH_FL;
269 /// format.m_channels[1] = AE_CH_FR;
270 /// format.m_channels[2] = AE_CH_NULL;
271 /// format.m_sampleRate = 48000;
272 /// format.m_frameSize = sizeof(float)*format.m_channelCount;
273 /// format.m_frames = 512;
274 /// CAddonAEStream* stream = new CAddonAEStream(format, AE_STREAM_AUTOSTART | AE_STREAM_BYPASS_ADSP);
275 ///
276 /// ~~~~~~~~~~~~~
277 ///
278 CAddonAEStream(AudioEngineFormat format, unsigned int options = 0)
279 : m_kodiBase(::kodi::addon::CAddonBase::m_interface->toKodi->kodiBase),
280 m_cb(::kodi::addon::CAddonBase::m_interface->toKodi->kodi_audioengine)
281 {
282 m_StreamHandle = m_cb->make_stream(m_kodiBase, &format, options);
283 if (m_StreamHandle == nullptr)
284 {
285 kodi::Log(ADDON_LOG_FATAL, "CAddonAEStream: make_stream failed!");
286 }
287 }
288 //--------------------------------------------------------------------------
289
290 //==========================================================================
291 /// @ingroup cpp_kodi_audioengine_CAddonAEStream
292 /// @brief Class destructor
293 ///
294 ~CAddonAEStream()
295 {
296 if (m_StreamHandle)
297 {
298 m_cb->free_stream(m_kodiBase, m_StreamHandle);
299 m_StreamHandle = nullptr;
300 }
301 }
302 //--------------------------------------------------------------------------
303
304 //==========================================================================
305 /// @ingroup cpp_kodi_audioengine_CAddonAEStream
306 /// @brief Returns the amount of space available in the stream
307 ///
308 /// @return The number of bytes AddData will consume
309 ///
310 unsigned int GetSpace()
311 {
312 return m_cb->aestream_get_space(m_kodiBase, m_StreamHandle);
313 }
314 //--------------------------------------------------------------------------
315
316 //==========================================================================
317 /// @ingroup cpp_kodi_audioengine_CAddonAEStream
318 /// @brief Add planar or interleaved PCM data to the stream
319 ///
320 /// @param[in] data array of pointers to the planes
321 /// @param[in] offset to frame in frames
322 /// @param[in] frames number of frames
323 /// @param[in] pts presentation timestamp
324 /// @return The number of frames consumed
325 ///
326 unsigned int AddData(uint8_t* const *data, unsigned int offset, unsigned int frames, double pts = 0.0)
327 {
328 return m_cb->aestream_add_data(m_kodiBase, m_StreamHandle, data, offset, frames, pts);
329 }
330 //--------------------------------------------------------------------------
331
332 //==========================================================================
333 /// @ingroup cpp_kodi_audioengine_CAddonAEStream
334 /// @brief Returns the time in seconds that it will take for the next added
335 /// packet to be heard from the speakers.
336 ///
337 /// @return seconds
338 ///
339 double GetDelay()
340 {
341 return m_cb->aestream_get_delay(m_kodiBase, m_StreamHandle);
342 }
343 //--------------------------------------------------------------------------
344
345 //==========================================================================
346 /// @ingroup cpp_kodi_audioengine_CAddonAEStream
347 /// @brief Returns if the stream is buffering
348 ///
349 /// @return True if the stream is buffering
350 ///
351 bool IsBuffering()
352 {
353 return m_cb->aestream_is_buffering(m_kodiBase, m_StreamHandle);
354 }
355 //--------------------------------------------------------------------------
356
357 //==========================================================================
358 /// @ingroup cpp_kodi_audioengine_CAddonAEStream
359 /// @brief Returns the time in seconds of the stream's cached audio samples.
360 /// Engine buffers excluded.
361 ///
362 /// @return seconds
363 ///
364 double GetCacheTime()
365 {
366 return m_cb->aestream_get_cache_time(m_kodiBase, m_StreamHandle);
367 }
368 //--------------------------------------------------------------------------
369
370 //==========================================================================
371 /// @ingroup cpp_kodi_audioengine_CAddonAEStream
372 /// @brief Returns the total time in seconds of the cache
373 ///
374 /// @return seconds
375 ///
376 double GetCacheTotal()
377 {
378 return m_cb->aestream_get_cache_total(m_kodiBase, m_StreamHandle);
379 }
380 //--------------------------------------------------------------------------
381
382 //==========================================================================
383 /// @ingroup cpp_kodi_audioengine_CAddonAEStream
384 /// @brief Pauses the stream playback
385 ///
386 void Pause()
387 {
388 return m_cb->aestream_pause(m_kodiBase, m_StreamHandle);
389 }
390 //--------------------------------------------------------------------------
391
392 //==========================================================================
393 /// @ingroup cpp_kodi_audioengine_CAddonAEStream
394 /// @brief Resumes the stream after pausing
395 ///
396 void Resume()
397 {
398 return m_cb->aestream_resume(m_kodiBase, m_StreamHandle);
399 }
400 //--------------------------------------------------------------------------
401
402 //==========================================================================
403 /// @ingroup cpp_kodi_audioengine_CAddonAEStream
404 /// @brief Start draining the stream
405 ///
406 /// @param[in] wait [opt] Wait until drain is finished if set to
407 /// true, otherwise it returns direct
408 ///
409 /// @note Once called AddData will not consume more data.
410 ///
411 void Drain(bool wait = true)
412 {
413 return m_cb->aestream_drain(m_kodiBase, m_StreamHandle, wait);
414 }
415 //--------------------------------------------------------------------------
416
417 //==========================================================================
418 /// @ingroup cpp_kodi_audioengine_CAddonAEStream
419 /// @brief Returns true if the is stream draining
420 ///
421 bool IsDraining()
422 {
423 return m_cb->aestream_is_draining(m_kodiBase, m_StreamHandle);
424 }
425 //--------------------------------------------------------------------------
426
427 //==========================================================================
428 /// @ingroup cpp_kodi_audioengine_CAddonAEStream
429 /// @brief Returns true if the is stream has finished draining
430 ///
431 bool IsDrained()
432 {
433 return m_cb->aestream_is_drained(m_kodiBase, m_StreamHandle);
434 }
435 //--------------------------------------------------------------------------
436
437 //==========================================================================
438 /// @ingroup cpp_kodi_audioengine_CAddonAEStream
439 /// @brief Flush all buffers dropping the audio data
440 ///
441 void Flush()
442 {
443 return m_cb->aestream_flush(m_kodiBase, m_StreamHandle);
444 }
445 //--------------------------------------------------------------------------
446
447 //==========================================================================
448 /// @ingroup cpp_kodi_audioengine_CAddonAEStream
449 /// @brief Return the stream's current volume level
450 ///
451 /// @return The volume level between 0.0 and 1.0
452 ///
453 float GetVolume()
454 {
455 return m_cb->aestream_get_volume(m_kodiBase, m_StreamHandle);
456 }
457 //--------------------------------------------------------------------------
458
459 //==========================================================================
460 /// @ingroup cpp_kodi_audioengine_CAddonAEStream
461 /// @brief Set the stream's volume level
462 ///
463 /// @param[in] volume The new volume level between 0.0 and 1.0
464 ///
465 void SetVolume(float volume)
466 {
467 return m_cb->aestream_set_volume(m_kodiBase, m_StreamHandle, volume);
468 }
469 //--------------------------------------------------------------------------
470
471 //==========================================================================
472 /// @ingroup cpp_kodi_audioengine_CAddonAEStream
473 /// @brief Gets the stream's volume amplification in linear units.
474 ///
475 /// @return The volume amplification factor between 1.0 and 1000.0
476 ///
477 float GetAmplification()
478 {
479 return m_cb->aestream_get_amplification(m_kodiBase, m_StreamHandle);
480 }
481 //--------------------------------------------------------------------------
482
483 //==========================================================================
484 /// @ingroup cpp_kodi_audioengine_CAddonAEStream
485 /// @brief Sets the stream's volume amplification in linear units.
486 ///
487 /// @param[in] amplify The volume amplification factor between
488 /// 1.0 and 1000.0
489 ///
490 void SetAmplification(float amplify)
491 {
492 return m_cb->aestream_set_amplification(m_kodiBase, m_StreamHandle, amplify);
493 }
494 //--------------------------------------------------------------------------
495
496 //==========================================================================
497 /// @ingroup cpp_kodi_audioengine_CAddonAEStream
498 /// @brief Returns the size of one audio frame in bytes (channelCount * resolution)
499 ///
500 /// @return The size in bytes of one frame
501 ///
502 unsigned int GetFrameSize() const
503 {
504 return m_cb->aestream_get_frame_size(m_kodiBase, m_StreamHandle);
505 }
506 //--------------------------------------------------------------------------
507
508 //==========================================================================
509 /// @ingroup cpp_kodi_audioengine_CAddonAEStream
510 /// @brief Returns the number of channels the stream is configured to accept
511 ///
512 /// @return The channel count
513 ///
514 unsigned int GetChannelCount() const
515 {
516 return m_cb->aestream_get_channel_count(m_kodiBase, m_StreamHandle);
517 }
518 //--------------------------------------------------------------------------
519
520 //==========================================================================
521 /// @ingroup cpp_kodi_audioengine_CAddonAEStream
522 /// @brief Returns the stream's sample rate, if the stream is using a dynamic
523 /// sample rate, this value will NOT reflect any changes made by calls to
524 /// SetResampleRatio()
525 ///
526 /// @return The stream's sample rate (eg, 48000)
527 ///
528 unsigned int GetSampleRate() const
529 {
530 return m_cb->aestream_get_sample_rate(m_kodiBase, m_StreamHandle);
531 }
532 //--------------------------------------------------------------------------
533
534 //==========================================================================
535 /// @ingroup cpp_kodi_audioengine_CAddonAEStream
536 /// @brief Return the data format the stream has been configured with
537 ///
538 /// @return The stream's data format (eg, AUDIOENGINE_FMT_S16LE)
539 ///
540 AEDataFormat GetDataFormat() const
541 {
542 return m_cb->aestream_get_data_format(m_kodiBase, m_StreamHandle);
543 }
544 //--------------------------------------------------------------------------
545
546 //==========================================================================
547 /// @ingroup cpp_kodi_audioengine_CAddonAEStream
548 /// @brief Return the resample ratio
549 ///
550 /// @note This will return an undefined value if the stream is not resampling
551 ///
552 /// @return the current resample ratio or undefined if the stream is not resampling
553 ///
554 double GetResampleRatio()
555 {
556 return m_cb->aestream_get_resample_ratio(m_kodiBase, m_StreamHandle);
557 }
558 //--------------------------------------------------------------------------
559
560 //==========================================================================
561 /// @ingroup cpp_kodi_audioengine_CAddonAEStream
562 /// @brief Sets the resample ratio
563 ///
564 /// @note This function may return false if the stream is not resampling, if
565 /// you wish to use this be sure to set the AESTREAM_FORCE_RESAMPLE option
566 ///
567 /// @param[in] ratio the new sample rate ratio, calculated by
568 /// ((double)desiredRate / (double)GetSampleRate())
569 ///
570 void SetResampleRatio(double ratio)
571 {
572 m_cb->aestream_set_resample_ratio(m_kodiBase, m_StreamHandle, ratio);
573 }
574 //--------------------------------------------------------------------------
575
576 private:
577 void* m_kodiBase;
578 AddonToKodiFuncTable_kodi_audioengine* m_cb;
579 AEStreamHandle *m_StreamHandle;
580 };
581
582 //============================================================================
583 /// @ingroup cpp_kodi_audioengine
584 /// @brief Get the current sink data format
585 ///
586 /// @param[in] format Current sink data format. For more details see AudioEngineFormat.
587 /// @return Returns true on success, else false.
588 ///
589 inline bool GetCurrentSinkFormat(AudioEngineFormat &format)
590 {
591 using namespace kodi::addon;
592 return CAddonBase::m_interface->toKodi->kodi_audioengine->get_current_sink_format(CAddonBase::m_interface->toKodi->kodiBase, &format);
593 }
594 //----------------------------------------------------------------------------
595
596} /* audioengine */
597} /* kodi */
diff --git a/xbmc/addons/kodi-addon-dev-kit/include/kodi/CMakeLists.txt b/xbmc/addons/kodi-addon-dev-kit/include/kodi/CMakeLists.txt
index 80e9275..2b98154 100644
--- a/xbmc/addons/kodi-addon-dev-kit/include/kodi/CMakeLists.txt
+++ b/xbmc/addons/kodi-addon-dev-kit/include/kodi/CMakeLists.txt
@@ -1,5 +1,4 @@
1set(HEADERS AddonBase.h 1set(HEADERS AddonBase.h
2 AudioEngine.h
3 Filesystem.h 2 Filesystem.h
4 General.h 3 General.h
5 Network.h 4 Network.h
@@ -19,6 +18,10 @@ set(HEADERS AddonBase.h
19 xbmc_pvr_dll.h 18 xbmc_pvr_dll.h
20 xbmc_pvr_types.h) 19 xbmc_pvr_types.h)
21 20
21if(CORE_SYSTEM_NAME STREQUAL android)
22 list(APPEND SOURCES platform/android/System.h)
23endif()
24
22if(NOT ENABLE_STATIC_LIBS) 25if(NOT ENABLE_STATIC_LIBS)
23 core_add_library(addons_kodi-addon-dev-kit_include_kodi) 26 core_add_library(addons_kodi-addon-dev-kit_include_kodi)
24endif() 27endif()
diff --git a/xbmc/addons/kodi-addon-dev-kit/include/kodi/addon-instance/AudioDSP.h b/xbmc/addons/kodi-addon-dev-kit/include/kodi/addon-instance/AudioDSP.h
deleted file mode 100644
index 3587a33..0000000
--- a/xbmc/addons/kodi-addon-dev-kit/include/kodi/addon-instance/AudioDSP.h
+++ /dev/null
@@ -1,1288 +0,0 @@
1#pragma once
2
3/*
4 * Copyright (C) 2005-2015 Team Kodi
5 * http://kodi.tv
6 *
7 * This Program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2, or (at your option)
10 * any later version.
11 *
12 * This Program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with Kodi; see the file COPYING. If not, see
19 * <http://www.gnu.org/licenses/>.
20 *
21 */
22
23#include "../AddonBase.h"
24
25#define AE_DSP_STREAM_MAX_STREAMS 8
26#define AE_DSP_STREAM_MAX_MODES 32
27
28/*!
29 * @file Addon.h
30 * @section sec1 Basic audio dsp addon interface description
31 * @author Team Kodi
32 * @date 10. May 2014
33 * @version 0.1.5
34 *
35 * @subsection sec1_1 General
36 * @li The basic support on the addon is supplied with the
37 * AE_DSP_ADDON_CAPABILITIES data which becomes asked over
38 * GetCapabilities(...), further the addon must register his available
39 * modes on startup with the RegisterMode(...) callback function.
40 * If one of this two points is not set the addon becomes
41 * ignored for the chain step.
42 *
43 * @subsection sec1_2 Processing
44 * @li On start of new stream the addon becomes called with StreamCreate(...)
45 * to check about given values that it support it basically and can create
46 * his structure, if nothing is supported it can return AE_DSP_ERROR_IGNORE_ME.
47 *
48 * @li As next step StreamIsModeSupported(...) becomes called for every
49 * available and enabled modes, is separated due to more as one available mode
50 * on the addon is possible, if the mode is not supported it can also be return
51 * AE_DSP_ERROR_IGNORE_ME.
52 * - If mode is a resample mode and returns no error it becomes asked with
53 * InputResampleSampleRate(...) or OutputResampleSampleRate(...) (relevant
54 * to his type) about his given sample rate.
55 * - About the from user selected master processing mode the related addon
56 * becomes called now with MasterProcessSetMode(...) to handle it's
57 * selectionon the addon given by the own addon type identifier or by
58 * KODI's useddatabase id, also the currently used stream type (e.g.
59 * Music or Video) is send.
60 * - If the addon supports only one master mode it can ignore this function
61 * and return always AE_DSP_ERROR_NO_ERROR.
62 * - If the master mode is set the addon becomes asked about the from him
63 * given output channel layout related to up- or downmix modes, if
64 * nothing becomes changed on the layout it can return -1.
65 * - The MasterProcessSetMode(...) is also called if from user a another
66 * mode becomes selected.
67 *
68 * @li Then as last step shortly before the first process call becomes executed
69 * the addon is called one time with StreamInitialize(...) to inform that
70 * processing is started on the given settings.
71 * - This function becomes also called on all add-ons if the master process
72 * becomes changed.
73 * - Also every process after StreamInitialize on the addon mode becomes asked
74 * with _..._ProcessNeededSamplesize(...) about required memory size for the
75 * output of his data, if no other size is required it can return 0.
76 *
77 * @li From now the processing becomes handled for the different steps with
78 * _..._Process(...).
79 * - Further it becomes asked with _..._GetDelay(...) about his processing
80 * time as float value in seconds, needed for video and audio alignment.
81 *
82 * @li On the end of the processing if the source becomes stopped the
83 * StreamDestroy(...) function becomes called on all active processing add-ons.
84 *
85 * @note
86 * The StreamCreate(...) can be becomes called for a new stream before the
87 * previous was closed with StreamDestroy(...) ! To have a speed improve.
88 */
89
90namespace kodi { namespace addon { class CInstanceAudioDSP; }}
91
92extern "C" {
93
94 typedef void* ADSPHANDLE;
95
96 typedef unsigned int AE_DSP_STREAM_ID;
97
98 /*!
99 * @brief Audio DSP add-on error codes
100 */
101 typedef enum
102 {
103 AE_DSP_ERROR_NO_ERROR = 0, /*!< @brief no error occurred */
104 AE_DSP_ERROR_UNKNOWN = -1, /*!< @brief an unknown error occurred */
105 AE_DSP_ERROR_IGNORE_ME = -2, /*!< @brief the used input stream can not processed and add-on want to ignore */
106 AE_DSP_ERROR_NOT_IMPLEMENTED = -3, /*!< @brief the method that KODI called is not implemented by the add-on */
107 AE_DSP_ERROR_REJECTED = -4, /*!< @brief the command was rejected by the DSP */
108 AE_DSP_ERROR_INVALID_PARAMETERS = -5, /*!< @brief the parameters of the method that was called are invalid for this operation */
109 AE_DSP_ERROR_INVALID_SAMPLERATE = -6, /*!< @brief the processed samplerate is not supported */
110 AE_DSP_ERROR_INVALID_IN_CHANNELS = -7, /*!< @brief the processed input channel format is not supported */
111 AE_DSP_ERROR_INVALID_OUT_CHANNELS = -8, /*!< @brief the processed output channel format is not supported */
112 AE_DSP_ERROR_FAILED = -9, /*!< @brief the command failed */
113 } AE_DSP_ERROR;
114
115 /*!
116 * @brief The possible DSP channels (used as pointer inside arrays)
117 */
118 typedef enum
119 {
120 AE_DSP_CH_INVALID = -1,
121 AE_DSP_CH_FL = 0,
122 AE_DSP_CH_FR,
123 AE_DSP_CH_FC,
124 AE_DSP_CH_LFE,
125 AE_DSP_CH_BL,
126 AE_DSP_CH_BR,
127 AE_DSP_CH_FLOC,
128 AE_DSP_CH_FROC,
129 AE_DSP_CH_BC,
130 AE_DSP_CH_SL,
131 AE_DSP_CH_SR,
132 AE_DSP_CH_TFL,
133 AE_DSP_CH_TFR,
134 AE_DSP_CH_TFC,
135 AE_DSP_CH_TC,
136 AE_DSP_CH_TBL,
137 AE_DSP_CH_TBR,
138 AE_DSP_CH_TBC,
139 AE_DSP_CH_BLOC,
140 AE_DSP_CH_BROC,
141
142 AE_DSP_CH_MAX
143 } AE_DSP_CHANNEL;
144
145 /*!
146 * @brief Present channel flags
147 */
148 typedef enum
149 {
150 AE_DSP_PRSNT_CH_UNDEFINED = 0,
151 AE_DSP_PRSNT_CH_FL = 1<<AE_DSP_CH_FL,
152 AE_DSP_PRSNT_CH_FR = 1<<AE_DSP_CH_FR,
153 AE_DSP_PRSNT_CH_FC = 1<<AE_DSP_CH_FC,
154 AE_DSP_PRSNT_CH_LFE = 1<<AE_DSP_CH_LFE,
155 AE_DSP_PRSNT_CH_BL = 1<<AE_DSP_CH_BL,
156 AE_DSP_PRSNT_CH_BR = 1<<AE_DSP_CH_BR,
157 AE_DSP_PRSNT_CH_FLOC = 1<<AE_DSP_CH_FLOC,
158 AE_DSP_PRSNT_CH_FROC = 1<<AE_DSP_CH_FROC,
159 AE_DSP_PRSNT_CH_BC = 1<<AE_DSP_CH_BC,
160 AE_DSP_PRSNT_CH_SL = 1<<AE_DSP_CH_SL,
161 AE_DSP_PRSNT_CH_SR = 1<<AE_DSP_CH_SR,
162 AE_DSP_PRSNT_CH_TFL = 1<<AE_DSP_CH_TFL,
163 AE_DSP_PRSNT_CH_TFR = 1<<AE_DSP_CH_TFR,
164 AE_DSP_PRSNT_CH_TFC = 1<<AE_DSP_CH_TFC,
165 AE_DSP_PRSNT_CH_TC = 1<<AE_DSP_CH_TC,
166 AE_DSP_PRSNT_CH_TBL = 1<<AE_DSP_CH_TBL,
167 AE_DSP_PRSNT_CH_TBR = 1<<AE_DSP_CH_TBR,
168 AE_DSP_PRSNT_CH_TBC = 1<<AE_DSP_CH_TBC,
169 AE_DSP_PRSNT_CH_BLOC = 1<<AE_DSP_CH_BLOC,
170 AE_DSP_PRSNT_CH_BROC = 1<<AE_DSP_CH_BROC
171 } AE_DSP_CHANNEL_PRESENT;
172
173 /**
174 * @brief The various stream type formats
175 * Used for audio DSP processing to know input audio type
176 */
177 typedef enum
178 {
179 AE_DSP_ASTREAM_INVALID = -1,
180 AE_DSP_ASTREAM_BASIC = 0,
181 AE_DSP_ASTREAM_MUSIC,
182 AE_DSP_ASTREAM_MOVIE,
183 AE_DSP_ASTREAM_GAME,
184 AE_DSP_ASTREAM_APP,
185 AE_DSP_ASTREAM_PHONE,
186 AE_DSP_ASTREAM_MESSAGE,
187
188 AE_DSP_ASTREAM_AUTO,
189 AE_DSP_ASTREAM_MAX
190 } AE_DSP_STREAMTYPE;
191
192 /*!
193 * @brief Add-ons supported audio stream type flags
194 * used on master mode information on AE_DSP_MODES to know
195 * on which audio stream the master mode is supported
196 */
197 typedef enum
198 {
199 AE_DSP_PRSNT_ASTREAM_BASIC = 1<<AE_DSP_ASTREAM_BASIC,
200 AE_DSP_PRSNT_ASTREAM_MUSIC = 1<<AE_DSP_ASTREAM_MUSIC,
201 AE_DSP_PRSNT_ASTREAM_MOVIE = 1<<AE_DSP_ASTREAM_MOVIE,
202 AE_DSP_PRSNT_ASTREAM_GAME = 1<<AE_DSP_ASTREAM_GAME,
203 AE_DSP_PRSNT_ASTREAM_APP = 1<<AE_DSP_ASTREAM_APP,
204 AE_DSP_PRSNT_ASTREAM_PHONE = 1<<AE_DSP_ASTREAM_PHONE,
205 AE_DSP_PRSNT_ASTREAM_MESSAGE = 1<<AE_DSP_ASTREAM_MESSAGE,
206 } AE_DSP_ASTREAM_PRESENT;
207
208 /**
209 * @brief The various base type formats
210 * Used for audio DSP processing to know input audio source
211 */
212 typedef enum
213 {
214 AE_DSP_ABASE_INVALID = -1,
215 AE_DSP_ABASE_STEREO = 0,
216 AE_DSP_ABASE_MONO,
217 AE_DSP_ABASE_MULTICHANNEL,
218 AE_DSP_ABASE_AC3,
219 AE_DSP_ABASE_EAC3,
220 AE_DSP_ABASE_DTS,
221 AE_DSP_ABASE_DTSHD_MA,
222 AE_DSP_ABASE_DTSHD_HRA,
223 AE_DSP_ABASE_TRUEHD,
224 AE_DSP_ABASE_MLP,
225 AE_DSP_ABASE_FLAC,
226
227 AE_DSP_ABASE_MAX
228 } AE_DSP_BASETYPE;
229
230
231 /**
232 * @brief The from KODI in settings requested audio process quality.
233 * The KODI internal used quality levels is translated to this values
234 * for usage on DSP processing add-ons. Is present on iQualityLevel
235 * inside AE_DSP_SETTINGS.
236 */
237 typedef enum
238 {
239 AE_DSP_QUALITY_UNKNOWN = -1, /*!< @brief Unset, unknown or incorrect quality level */
240 AE_DSP_QUALITY_DEFAULT = 0, /*!< @brief Engine's default quality level */
241
242 /* Basic quality levels */
243 AE_DSP_QUALITY_LOW = 20, /*!< @brief Low quality level */
244 AE_DSP_QUALITY_MID = 30, /*!< @brief Standard quality level */
245 AE_DSP_QUALITY_HIGH = 50, /*!< @brief Best sound processing quality */
246
247 /* Optional quality levels */
248 AE_DSP_QUALITY_REALLYHIGH = 100 /*!< @brief Uncompromising optional quality level, usually with unmeasurable and unnoticeable improvement */
249 } AE_DSP_QUALITY;
250
251 /*!
252 * @brief Audio DSP menu hook categories.
253 * Used to identify on AE_DSP_MENUHOOK given add-on related skin dialog/windows.
254 * Except AE_DSP_MENUHOOK_ALL and AE_DSP_MENUHOOK_SETTING are the menus available
255 * from DSP playback dialogue which can be opened over KODI file context menu and over
256 * button on full screen OSD window.
257 *
258 * Menu hook AE_DSP_MENUHOOK_SETTING is available from DSP processing setup dialogue.
259 */
260 typedef enum
261 {
262 AE_DSP_MENUHOOK_UNKNOWN =-1, /*!< @brief unknown menu hook */
263 AE_DSP_MENUHOOK_ALL = 0, /*!< @brief all categories */
264 AE_DSP_MENUHOOK_PRE_PROCESS = 1, /*!< @brief for pre processing */
265 AE_DSP_MENUHOOK_MASTER_PROCESS = 2, /*!< @brief for master processing */
266 AE_DSP_MENUHOOK_POST_PROCESS = 3, /*!< @brief for post processing */
267 AE_DSP_MENUHOOK_RESAMPLE = 4, /*!< @brief for re sample */
268 AE_DSP_MENUHOOK_MISCELLANEOUS = 5, /*!< @brief for miscellaneous dialogues */
269 AE_DSP_MENUHOOK_INFORMATION = 6, /*!< @brief dialogue to show processing information */
270 AE_DSP_MENUHOOK_SETTING = 7, /*!< @brief for settings */
271 } AE_DSP_MENUHOOK_CAT;
272
273 /*!
274 * @brief Menu hooks that are available in the menus while playing a stream via this add-on.
275 */
276 typedef struct AE_DSP_MENUHOOK
277 {
278 unsigned int iHookId; /*!< @brief (required) this hook's identifier */
279 unsigned int iLocalizedStringId; /*!< @brief (required) the id of the label for this hook in g_localizeStrings */
280 AE_DSP_MENUHOOK_CAT category; /*!< @brief (required) category of menu hook */
281 unsigned int iRelevantModeId; /*!< @brief (required) except category AE_DSP_MENUHOOK_SETTING and AE_DSP_MENUHOOK_ALL must be the related mode id present here */
282 bool bNeedPlayback; /*!< @brief (required) set to true if menu hook need playback and active processing */
283 } ATTRIBUTE_PACKED AE_DSP_MENUHOOK;
284
285 /*!
286 * @brief Audio DSP add-on capabilities. All capabilities are set to "false" as default.
287 * If a capability is set to true, then the corresponding methods from kodi_audiodsp_dll.h need to be implemented.
288 */
289 typedef struct AE_DSP_ADDON_CAPABILITIES
290 {
291 bool bSupportsInputProcess; /*!< @brief true if this add-on provides audio input processing */
292 bool bSupportsInputResample; /*!< @brief true if this add-on provides audio resample before master handling */
293 bool bSupportsPreProcess; /*!< @brief true if this add-on provides audio pre processing */
294 bool bSupportsMasterProcess; /*!< @brief true if this add-on provides audio master processing */
295 bool bSupportsPostProcess; /*!< @brief true if this add-on provides audio post processing */
296 bool bSupportsOutputResample; /*!< @brief true if this add-on provides audio re sample after master handling */
297 } ATTRIBUTE_PACKED AE_DSP_ADDON_CAPABILITIES;
298
299 /*!
300 * @brief Audio processing settings for in and out arrays
301 * Send on creation and before first processed audio packet to add-on
302 */
303 typedef struct AE_DSP_SETTINGS
304 {
305 AE_DSP_STREAM_ID iStreamID; /*!< @brief id of the audio stream packets */
306 AE_DSP_STREAMTYPE iStreamType; /*!< @brief the input stream type source eg, Movie or Music */
307 int iInChannels; /*!< @brief the amount of input channels */
308 unsigned long lInChannelPresentFlags; /*!< @brief the exact channel mapping flags of input */
309 int iInFrames; /*!< @brief the input frame size from KODI */
310 unsigned int iInSamplerate; /*!< @brief the basic sample rate of the audio packet */
311 int iProcessFrames; /*!< @brief the processing frame size inside add-on's */
312 unsigned int iProcessSamplerate; /*!< @brief the sample rate after input resample present in master processing */
313 int iOutChannels; /*!< @brief the amount of output channels */
314 unsigned long lOutChannelPresentFlags; /*!< @brief the exact channel mapping flags for output */
315 int iOutFrames; /*!< @brief the final out frame size for KODI */
316 unsigned int iOutSamplerate; /*!< @brief the final sample rate of the audio packet */
317 bool bInputResamplingActive; /*!< @brief if a re-sampling is performed before master processing this flag is set to true */
318 bool bStereoUpmix; /*!< @brief true if the stereo upmix setting on kodi is set */
319 int iQualityLevel; /*!< @brief the from KODI selected quality level for signal processing */
320 /*!
321 * @note about "iProcessSamplerate" and "iProcessFrames" is set from KODI after call of StreamCreate on input re sample add-on, if re-sampling
322 * and processing is handled inside the same add-on, this value must be ignored!
323 */
324 } ATTRIBUTE_PACKED AE_DSP_SETTINGS;
325
326 /*!
327 * @brief Stream profile properties
328 * Can be used to detect best master processing mode and for post processing methods.
329 */
330//@{
331
332 /*!
333 * @brief Dolby profile types. Given from several formats, e.g. Dolby Digital or TrueHD
334 * Used on AE_DSP_PROFILE_AC3_EAC3 and AE_DSP_PROFILE_MLP_TRUEHD
335 */
336 #define AE_DSP_PROFILE_DOLBY_NONE 0
337 #define AE_DSP_PROFILE_DOLBY_SURROUND 1
338 #define AE_DSP_PROFILE_DOLBY_PLII 2
339 #define AE_DSP_PROFILE_DOLBY_PLIIX 3
340 #define AE_DSP_PROFILE_DOLBY_PLIIZ 4
341 #define AE_DSP_PROFILE_DOLBY_EX 5
342 #define AE_DSP_PROFILE_DOLBY_HEADPHONE 6
343
344 /*!
345 * @brief DTS/DTS HD profile types
346 * Used on AE_DSP_PROFILE_DTS_DTSHD
347 */
348 #define AE_DSP_PROFILE_DTS 0
349 #define AE_DSP_PROFILE_DTS_ES 1
350 #define AE_DSP_PROFILE_DTS_96_24 2
351 #define AE_DSP_PROFILE_DTS_HD_HRA 3
352 #define AE_DSP_PROFILE_DTS_HD_MA 4
353
354 /*!
355 * @brief AC3/EAC3 based service types
356 * Used on AE_DSP_PROFILE_AC3_EAC3
357 */
358 #define AE_DSP_SERVICE_TYPE_MAIN 0
359 #define AE_DSP_SERVICE_TYPE_EFFECTS 1
360 #define AE_DSP_SERVICE_TYPE_VISUALLY_IMPAIRED 2
361 #define AE_DSP_SERVICE_TYPE_HEARING_IMPAIRED 3
362 #define AE_DSP_SERVICE_TYPE_DIALOGUE 4
363 #define AE_DSP_SERVICE_TYPE_COMMENTARY 5
364 #define AE_DSP_SERVICE_TYPE_EMERGENCY 6
365 #define AE_DSP_SERVICE_TYPE_VOICE_OVER 7
366 #define AE_DSP_SERVICE_TYPE_KARAOKE 8
367
368 /*!
369 * @brief AC3/EAC3 based room types
370 * Present on AE_DSP_PROFILE_AC3_EAC3 and can be used for frequency corrections
371 * at post processing, e.g. THX Re-Equalization
372 */
373 #define AE_DSP_ROOM_TYPE_UNDEFINED 0
374 #define AE_DSP_ROOM_TYPE_SMALL 1
375 #define AE_DSP_ROOM_TYPE_LARGE 2
376
377 /*!
378 * @brief AC3/EAC3 stream profile properties
379 */
380 //! @todo add handling for it (currently never becomes set)
381 typedef struct AE_DSP_PROFILE_AC3_EAC3
382 {
383 unsigned int iProfile; /*!< defined by AE_DSP_PROFILE_DOLBY_* */
384 unsigned int iServiceType; /*!< defined by AE_DSP_SERVICE_TYPE_* */
385 unsigned int iRoomType; /*!< defined by AE_DSP_ROOM_TYPE_* (NOTICE: Information about it currently not supported from ffmpeg and must be implemented) */
386 } ATTRIBUTE_PACKED AE_DSP_PROFILE_AC3_EAC3;
387
388 /*!
389 * @brief MLP/Dolby TrueHD stream profile properties
390 */
391 //! @todo add handling for it (currently never becomes set)
392 typedef struct AE_DSP_PROFILE_MLP_TRUEHD
393 {
394 unsigned int iProfile; /*!< defined by AE_DSP_PROFILE_DOLBY_* */
395 } ATTRIBUTE_PACKED AE_DSP_PROFILE_MLP_TRUEHD;
396
397 /*!
398 * @brief DTS/DTS HD stream profile properties
399 */
400 //! @todo add handling for it (currently never becomes set)
401 typedef struct AE_DSP_PROFILE_DTS_DTSHD
402 {
403 unsigned int iProfile; /*!< defined by AE_DSP_PROFILE_DTS* */
404 bool bSurroundMatrix; /*!< if set to true given 2.0 stream is surround encoded */
405 } ATTRIBUTE_PACKED AE_DSP_PROFILE_DTS_DTSHD;
406
407 union AE_DSP_PROFILE
408 {
409 AE_DSP_PROFILE_AC3_EAC3 ac3_eac3; /*!< Dolby Digital/Digital+ profile data */
410 AE_DSP_PROFILE_MLP_TRUEHD mlp_truehd; /*!< MLP or Dolby TrueHD profile data */
411 AE_DSP_PROFILE_DTS_DTSHD dts_dtshd; /*!< DTS/DTS-HD profile data */
412 };
413 //@}
414
415 /*!
416 * @brief Audio DSP stream properties
417 * Used to check for the DSP add-on that the stream is supported,
418 * as example Dolby Digital Ex processing is only required on Dolby Digital with 5.1 layout
419 */
420 typedef struct AE_DSP_STREAM_PROPERTIES
421 {
422 AE_DSP_STREAM_ID iStreamID; /*!< @brief stream id of the audio stream packets */
423 AE_DSP_STREAMTYPE iStreamType; /*!< @brief the input stream type source eg, Movie or Music */
424 int iBaseType; /*!< @brief the input stream base type source eg, Dolby Digital */
425 const char* strName; /*!< @brief the audio stream name */
426 const char* strCodecId; /*!< @brief codec id string of the audio stream */
427 const char* strLanguage; /*!< @brief language id of the audio stream */
428 int iIdentifier; /*!< @brief audio stream id inside player */
429 int iChannels; /*!< @brief amount of basic channels */
430 int iSampleRate; /*!< @brief sample rate */
431 AE_DSP_PROFILE Profile; /*!< @brief current running stream profile data */
432 } ATTRIBUTE_PACKED AE_DSP_STREAM_PROPERTIES;
433
434 /*!
435 * @brief Audio DSP mode categories
436 */
437 typedef enum
438 {
439 AE_DSP_MODE_TYPE_UNDEFINED = -1, /*!< @brief undefined type, never be used from add-on! */
440 AE_DSP_MODE_TYPE_INPUT_RESAMPLE = 0, /*!< @brief for input re sample */
441 AE_DSP_MODE_TYPE_PRE_PROCESS = 1, /*!< @brief for preprocessing */
442 AE_DSP_MODE_TYPE_MASTER_PROCESS = 2, /*!< @brief for master processing */
443 AE_DSP_MODE_TYPE_POST_PROCESS = 3, /*!< @brief for post processing */
444 AE_DSP_MODE_TYPE_OUTPUT_RESAMPLE = 4, /*!< @brief for output re sample */
445 AE_DSP_MODE_TYPE_MAX = 5
446 } AE_DSP_MODE_TYPE;
447
448 /*!
449 * @brief Audio DSP master mode information
450 * Used to get all available modes for current input stream
451 */
452 typedef struct AE_DSP_MODES
453 {
454 unsigned int iModesCount; /*!< @brief (required) count of how much modes are in AE_DSP_MODES */
455 struct AE_DSP_MODE
456 {
457 int iUniqueDBModeId; /*!< @brief (required) the inside add-on used identifier for the mode, set by KODI's audio DSP database */
458 AE_DSP_MODE_TYPE iModeType; /*!< @brief (required) the processong mode type, see AE_DSP_MODE_TYPE */
459 char strModeName[ADDON_STANDARD_STRING_LENGTH]; /*!< @brief (required) the addon name of the mode, used on KODI's logs */
460
461 unsigned int iModeNumber; /*!< @brief (required) number of this mode on the add-on, is used on process functions with value "mode_id" */
462 unsigned int iModeSupportTypeFlags; /*!< @brief (required) flags about supported input types for this mode, see AE_DSP_ASTREAM_PRESENT */
463 bool bHasSettingsDialog; /*!< @brief (required) if setting dialog(s) are available it must be set to true */
464 bool bIsDisabled; /*!< @brief (optional) true if this mode is marked as disabled and not enabled default, only relevant for master processes, all other types always disabled as default */
465
466 unsigned int iModeName; /*!< @brief (required) the name id of the mode for this hook in g_localizeStrings */
467 unsigned int iModeSetupName; /*!< @brief (optional) the name id of the mode inside settings for this hook in g_localizeStrings */
468 unsigned int iModeDescription; /*!< @brief (optional) the description id of the mode for this hook in g_localizeStrings */
469 unsigned int iModeHelp; /*!< @brief (optional) help string id for inside DSP settings dialog of the mode for this hook in g_localizeStrings */
470
471 char strOwnModeImage[ADDON_STANDARD_STRING_LENGTH]; /*!< @brief (optional) flag image for the mode */
472 char strOverrideModeImage[ADDON_STANDARD_STRING_LENGTH];/*!< @brief (optional) image to override KODI Image for the mode, eg. Dolby Digital with Dolby Digital Ex (only used on master modes) */
473 } mode[AE_DSP_STREAM_MAX_MODES]; /*!< @brief Modes array storage */
474 } ATTRIBUTE_PACKED AE_DSP_MODES;
475
476 /*!
477 * @brief Audio DSP menu hook data
478 */
479 typedef struct AE_DSP_MENUHOOK_DATA
480 {
481 AE_DSP_MENUHOOK_CAT category; /*!< @brief (required) related menuhook data category */
482 union data {
483 AE_DSP_STREAM_ID iStreamId; /*!< @brief currently only stream id is used, is used as union to have extension possibility */
484 } data; /*!< @brief related category related data */
485 } ATTRIBUTE_PACKED AE_DSP_MENUHOOK_DATA;
486
487 /*!
488 * @brief Properties passed to the Create() method of an add-on.
489 */
490 typedef struct AddonProps_AudioDSP
491 {
492 const char* strUserPath; /*!< @brief path to the user profile */
493 const char* strAddonPath; /*!< @brief path to this add-on */
494 } AddonProps_AudioDSP;
495
496 typedef struct AddonToKodiFuncTable_AudioDSP
497 {
498 void* kodiInstance;
499 void (*add_menu_hook)(void* kodiInstance, AE_DSP_MENUHOOK *hook);
500 void (*remove_menu_hook)(void* kodiInstance, AE_DSP_MENUHOOK *hook);
501 void (*register_mode)(void* kodiInstance, AE_DSP_MODES::AE_DSP_MODE *mode);
502 void (*unregister_mode)(void* kodiInstance, AE_DSP_MODES::AE_DSP_MODE *mode);
503 } AddonToKodiFuncTable_AudioDSP;
504
505 struct AddonInstance_AudioDSP;
506 typedef struct KodiToAddonFuncTable_AudioDSP
507 {
508 kodi::addon::CInstanceAudioDSP* addonInstance;
509 void (__cdecl* get_capabilities)(AddonInstance_AudioDSP const* addonInstance, AE_DSP_ADDON_CAPABILITIES*);
510 const char* (__cdecl* get_dsp_name)(AddonInstance_AudioDSP const* addonInstance);
511 const char* (__cdecl* get_dsp_version)(AddonInstance_AudioDSP const* addonInstance);
512 AE_DSP_ERROR (__cdecl* menu_hook)(AddonInstance_AudioDSP const* addonInstance, const AE_DSP_MENUHOOK*, const AE_DSP_MENUHOOK_DATA*);
513
514 AE_DSP_ERROR (__cdecl* stream_create)(AddonInstance_AudioDSP const* addonInstance, const AE_DSP_SETTINGS*, const AE_DSP_STREAM_PROPERTIES*, ADDON_HANDLE);
515 AE_DSP_ERROR (__cdecl* stream_destroy)(AddonInstance_AudioDSP const* addonInstance, const ADDON_HANDLE);
516 AE_DSP_ERROR (__cdecl* stream_is_mode_supported)(AddonInstance_AudioDSP const* addonInstance, const ADDON_HANDLE, AE_DSP_MODE_TYPE, unsigned int, int);
517 AE_DSP_ERROR (__cdecl* stream_initialize)(AddonInstance_AudioDSP const* addonInstance, const ADDON_HANDLE, const AE_DSP_SETTINGS*);
518
519 bool (__cdecl* input_process)(AddonInstance_AudioDSP const* addonInstance, const ADDON_HANDLE, const float**, unsigned int);
520
521 unsigned int (__cdecl* input_resample_process_needed_samplesize)(AddonInstance_AudioDSP const* addonInstance, const ADDON_HANDLE);
522 unsigned int (__cdecl* input_resample_process)(AddonInstance_AudioDSP const* addonInstance, const ADDON_HANDLE, const float**, float**, unsigned int);
523 float (__cdecl* input_resample_get_delay)(AddonInstance_AudioDSP const* addonInstance, const ADDON_HANDLE);
524 int (__cdecl* input_resample_samplerate)(AddonInstance_AudioDSP const* addonInstance, const ADDON_HANDLE);
525
526 unsigned int (__cdecl* pre_process_needed_samplesize)(AddonInstance_AudioDSP const* addonInstance, const ADDON_HANDLE, unsigned int);
527 float (__cdecl* pre_process_get_delay)(AddonInstance_AudioDSP const* addonInstance, const ADDON_HANDLE, unsigned int);
528 unsigned int (__cdecl* pre_process)(AddonInstance_AudioDSP const* addonInstance, const ADDON_HANDLE, unsigned int, const float**, float**, unsigned int);
529
530 AE_DSP_ERROR (__cdecl* master_process_set_mode)(AddonInstance_AudioDSP const* addonInstance, const ADDON_HANDLE, AE_DSP_STREAMTYPE, unsigned int, int);
531 unsigned int (__cdecl* master_process_needed_samplesize)(AddonInstance_AudioDSP const* addonInstance, const ADDON_HANDLE);
532 float (__cdecl* master_process_get_delay)(AddonInstance_AudioDSP const* addonInstance, const ADDON_HANDLE);
533 int (__cdecl* master_process_get_out_channels)(AddonInstance_AudioDSP const* addonInstance, const ADDON_HANDLE, unsigned long*);
534 unsigned int (__cdecl* master_process)(AddonInstance_AudioDSP const* addonInstance, const ADDON_HANDLE, const float**, float**, unsigned int);
535 const char* (__cdecl* master_process_get_stream_info_string)(AddonInstance_AudioDSP const* addonInstance, const ADDON_HANDLE);
536
537 unsigned int (__cdecl* post_process_needed_samplesize)(AddonInstance_AudioDSP const* addonInstance, const ADDON_HANDLE, unsigned int);
538 float (__cdecl* post_process_get_delay)(AddonInstance_AudioDSP const* addonInstance, const ADDON_HANDLE, unsigned int);
539 unsigned int (__cdecl* post_process)(AddonInstance_AudioDSP const* addonInstance, const ADDON_HANDLE, unsigned int, const float**, float**, unsigned int);
540
541 unsigned int (__cdecl* output_resample_process_needed_samplesize)(AddonInstance_AudioDSP const* addonInstance, const ADDON_HANDLE);
542 unsigned int (__cdecl* output_resample_process)(AddonInstance_AudioDSP const* addonInstance, const ADDON_HANDLE, const float**, float**, unsigned int);
543 float (__cdecl* output_resample_get_delay)(AddonInstance_AudioDSP const* addonInstance, const ADDON_HANDLE);
544 int (__cdecl* output_resample_samplerate)(AddonInstance_AudioDSP const* addonInstance, const ADDON_HANDLE);
545 } KodiToAddonFuncTable_AudioDSP;
546
547 typedef struct AddonInstance_AudioDSP
548 {
549 AddonProps_AudioDSP props;
550 AddonToKodiFuncTable_AudioDSP toKodi;
551 KodiToAddonFuncTable_AudioDSP toAddon;
552 } AddonInstance_AudioDSP;
553
554} /* extern "C" */
555
556namespace kodi {
557namespace addon {
558
559 class CInstanceAudioDSP : public IAddonInstance
560 {
561 public:
562 //==========================================================================
563 /// @brief Class constructor
564 ///
565 CInstanceAudioDSP()
566 : IAddonInstance(ADDON_INSTANCE_ADSP)
567 {
568 if (CAddonBase::m_interface->globalSingleInstance != nullptr)
569 throw std::logic_error("kodi::addon::CInstanceAudioDSP: Creation of more as one in single instance way is not allowed!");
570
571 SetAddonStruct(CAddonBase::m_interface->firstKodiInstance);
572 CAddonBase::m_interface->globalSingleInstance = this;
573 }
574 //--------------------------------------------------------------------------
575
576 //==========================================================================
577 /// @brief Class constructor
578 ///
579 /// @param[in] instance The from Kodi given instance given be
580 /// add-on CreateInstance call with instance
581 /// id ADDON_INSTANCE_ADSP.
582 ///
583 explicit CInstanceAudioDSP(KODI_HANDLE instance)
584 : IAddonInstance(ADDON_INSTANCE_ADSP)
585 {
586 if (CAddonBase::m_interface->globalSingleInstance != nullptr)
587 throw std::logic_error("kodi::addon::CInstanceAudioDSP: Creation of multiple together with single instance way is not allowed!");
588
589 SetAddonStruct(instance);
590 }
591 //--------------------------------------------------------------------------
592
593 /*! @name Audio DSP add-on methods */
594 //@{
595 //==========================================================================
596 ///
597 /// @brief Get the list of features that this add-on provides.
598 /// Called by KODI to query the add-ons capabilities.
599 /// Used to check which options should be presented in the DSP, which methods
600 /// to call, etc.
601 /// All capabilities that the add-on supports should be set to true.
602 /// @param capabilities The add-ons capabilities.
603 /// @remarks Valid implementation required.
604 ///
605 virtual void GetCapabilities(AE_DSP_ADDON_CAPABILITIES& capabilities) = 0;
606 //--------------------------------------------------------------------------
607
608 //==========================================================================
609 ///
610 /// @return The name reported by the back end that will be displayed in the
611 /// UI.
612 /// @remarks Valid implementation required.
613 ///
614 virtual std::string GetDSPName() = 0;
615 //--------------------------------------------------------------------------
616
617 //==========================================================================
618 ///
619 /// @return The version string reported by the back end that will be displayed
620 /// in the UI.
621 /// @remarks Valid implementation required.
622 ///
623 virtual std::string GetDSPVersion() = 0;
624 //--------------------------------------------------------------------------
625
626 //==========================================================================
627 ///
628 /// @brief Call one of the menu hooks (if supported).
629 /// Supported AE_DSP_MENUHOOK instances have to be added in ADDON_Create(),
630 /// by calling AddMenuHook() on the callback.
631 /// @param menuhook The hook to call.
632 /// @param item The selected item for which the hook was called.
633 /// @return AE_DSP_ERROR_NO_ERROR if the hook was called successfully.
634 /// @remarks Optional. Return AE_DSP_ERROR_NOT_IMPLEMENTED if this add-on
635 /// won't provide this function.
636 ///
637 virtual AE_DSP_ERROR MenuHook(const AE_DSP_MENUHOOK& menuhook, const AE_DSP_MENUHOOK_DATA& item) { return AE_DSP_ERROR_NOT_IMPLEMENTED; }
638 //--------------------------------------------------------------------------
639 //@}
640
641 //==========================================================================
642 /// @name DSP processing control, used to open and close a stream
643 /// @remarks Valid implementation required.
644 ///
645 //@{
646 ///
647 /// @brief Set up Audio DSP with selected audio settings (use the basic
648 /// present audio stream data format).
649 /// Used to detect available add-ons for present stream, as example stereo
650 /// surround upmix not needed on 5.1 audio stream.
651 /// @param addonSettings The add-ons audio settings.
652 /// @param properties The properties of the currently playing stream.
653 /// @param handle On this becomes addon informated about stream id and can set function addresses which need on calls
654 /// @return AE_DSP_ERROR_NO_ERROR if the properties were fetched successfully
655 /// and data can be performed. AE_DSP_ERROR_IGNORE_ME if format is not
656 /// supported, but without fault.
657 /// @remarks Valid implementation required.
658 ///
659 virtual AE_DSP_ERROR StreamCreate(const AE_DSP_SETTINGS& addonSettings, const AE_DSP_STREAM_PROPERTIES& properties, ADDON_HANDLE handle) = 0;
660 //--------------------------------------------------------------------------
661
662 //==========================================================================
663 ///
664 /// Remove the selected id from currently used DSP processes
665 /// @param handle identification data for stream
666 /// @return AE_DSP_ERROR_NO_ERROR if the becomes found and removed
667 /// @remarks Valid implementation required.
668 ///
669 virtual AE_DSP_ERROR StreamDestroy(const ADDON_HANDLE handle) = 0;
670 //--------------------------------------------------------------------------
671
672 //==========================================================================
673 ///
674 /// @brief Ask the add-on about a requested processing mode that it is
675 /// supported on the current stream. Is called about every add-on mode after
676 /// successed StreamCreate.
677 /// @param handle identification data for stream
678 /// @param type The processing mode type, see AE_DSP_MODE_TYPE for definitions
679 /// @param mode_id The mode inside add-on which must be performed on call. Id
680 /// is set from add-on by iModeNumber on AE_DSP_MODE structure during
681 /// RegisterMode callback,
682 /// @param unique_db_mode_id The Mode unique id generated from dsp database.
683 /// @return AE_DSP_ERROR_NO_ERROR if the properties were fetched successfully
684 /// or if the stream is not supported the add-on must return
685 /// AE_DSP_ERROR_IGNORE_ME.
686 /// @remarks Valid implementation required.
687 ///
688 virtual AE_DSP_ERROR StreamIsModeSupported(const ADDON_HANDLE handle, AE_DSP_MODE_TYPE type, unsigned int mode_id, int unique_db_mode_id) = 0;
689 //--------------------------------------------------------------------------
690
691 //==========================================================================
692 ///
693 /// @brief Set up Audio DSP with selected audio settings (detected on data of
694 /// first present audio packet)
695 /// @param addonSettings The add-ons audio settings.
696 /// @return AE_DSP_ERROR_NO_ERROR if the properties were fetched successfully.
697 /// @remarks Valid implementation required.
698 ///
699 virtual AE_DSP_ERROR StreamInitialize(const ADDON_HANDLE handle, const AE_DSP_SETTINGS& addonSettings) = 0;
700 //--------------------------------------------------------------------------
701
702 //@}
703
704 /// @name DSP input processing
705 /// @remarks Only used by KODI if bSupportsInputProcess is set to true.
706 ///
707 //@{
708 //==========================================================================
709 ///
710 /// @brief DSP input processing
711 /// Can be used to have unchanged stream..
712 /// All DSP add-ons allowed to-do this.
713 /// @param handle identification data for stream
714 /// @param array_in Pointer to data memory
715 /// @param samples Amount of samples inside array_in
716 /// @return true if work was OK
717 /// @remarks Optional. Is set by AE_DSP_ADDON_CAPABILITIES and asked with
718 /// GetCapabilities
719 ///
720 virtual bool InputProcess(const ADDON_HANDLE handle, const float** array_in, unsigned int samples) { return true; }
721 //--------------------------------------------------------------------------
722 //@}
723
724 /// @name DSP pre-resampling
725 /// @remarks Only used by KODI if bSupportsInputResample is set to true.
726 ///
727 //@{
728 //==========================================================================
729 ///
730 /// @brief If the add-on operate with buffered arrays and the output size can
731 /// be higher as the input it becomes asked about needed size before any
732 /// InputResampleProcess call.
733 /// @param handle identification data for stream
734 /// @return The needed size of output array or 0 if no changes within it
735 /// @remarks Optional. Is set by AE_DSP_ADDON_CAPABILITIES and asked with
736 /// GetCapabilities
737 ///
738 virtual unsigned int InputResampleProcessNeededSamplesize(const ADDON_HANDLE handle) { return 0; }
739 //--------------------------------------------------------------------------
740
741 //==========================================================================
742 ///
743 /// @brief DSP re sample processing before master.
744 /// Here a high quality resample can be performed.
745 /// Only one DSP add-on is allowed to-do this!
746 /// @param handle identification data for stream
747 /// @param array_in Pointer to input data memory
748 /// @param array_out Pointer to output data memory
749 /// @param samples Amount of samples inside array_in
750 /// @return Amount of samples processed
751 /// @remarks Optional. Is set by AE_DSP_ADDON_CAPABILITIES and asked with
752 /// GetCapabilities
753 ///
754 virtual unsigned int InputResampleProcess(const ADDON_HANDLE handle, const float** array_in, float** array_out, unsigned int samples) { return 0; }
755 //--------------------------------------------------------------------------
756
757 //==========================================================================
758 ///
759 /// @brief Returns the re-sampling generated new sample rate used before the
760 /// master process
761 /// @param handle identification data for stream
762 /// @return The new sample rate
763 /// @remarks Optional. Is set by AE_DSP_ADDON_CAPABILITIES and asked with
764 /// GetCapabilities
765 ///
766 virtual int InputResampleSampleRate(const ADDON_HANDLE handle) { return 0; }
767 //--------------------------------------------------------------------------
768
769 //==========================================================================
770 ///
771 /// @brief Returns the time in seconds that it will take
772 /// for the next added packet to be returned to KODI.
773 /// @param handle identification data for stream
774 /// @return the delay in seconds
775 /// @remarks Optional. Is set by AE_DSP_ADDON_CAPABILITIES and asked with
776 /// GetCapabilities
777 ///
778 virtual float InputResampleGetDelay(const ADDON_HANDLE handle) { return 0.0f; }
779 //--------------------------------------------------------------------------
780 //@}
781
782 /** @name DSP Pre processing
783 * @remarks Only used by KODI if bSupportsPreProcess is set to true.
784 */
785 //@{
786 //==========================================================================
787 ///
788 /// @brief If the addon operate with buffered arrays and the output size can
789 /// be higher as the input it becomes asked about needed size before any
790 /// PreProcess call.
791 /// @param handle identification data for stream
792 /// @param mode_id The mode inside add-on which must be performed on call. Id
793 /// is set from add-on by iModeNumber on AE_DSP_MODE structure during
794 /// RegisterMode callback and can be defined from add-on as a structure
795 /// pointer or anything else what is needed to find it.
796 /// @return The needed size of output array or 0 if no changes within it
797 /// @remarks Optional. Is set by AE_DSP_ADDON_CAPABILITIES and asked with
798 /// GetCapabilities
799 ///
800 virtual unsigned int PreProcessNeededSamplesize(const ADDON_HANDLE handle, unsigned int mode_id) { return 0; }
801 //--------------------------------------------------------------------------
802
803 //==========================================================================
804 ///
805 /// @brief Returns the time in seconds that it will take
806 /// for the next added packet to be returned to KODI.
807 /// @param handle identification data for stream
808 /// @param mode_id The mode inside add-on which must be performed on call. Id
809 /// is set from add-on by iModeNumber on AE_DSP_MODE structure during
810 /// RegisterMode callback and can be defined from add-on as a structure
811 /// pointer or anything else what is needed to find it.
812 /// @return the delay in seconds
813 /// @remarks Optional. Is set by AE_DSP_ADDON_CAPABILITIES and asked with
814 /// GetCapabilities
815 ///
816 virtual float PreProcessGetDelay(const ADDON_HANDLE handle, unsigned int mode_id) { return 0.0f; }
817 //--------------------------------------------------------------------------
818
819 //==========================================================================
820 ///
821 /// @brief DSP preprocessing
822 /// All DSP add-ons allowed to-do this.
823 /// @param handle identification data for stream
824 /// @param mode_id The mode inside add-on which must be performed on call. Id
825 /// is set from add-on by iModeNumber on AE_DSP_MODE structure during
826 /// RegisterMode callback and can be defined from add-on as a structure
827 /// pointer or anything else what is needed to find it.
828 /// @param array_in Pointer to input data memory
829 /// @param array_out Pointer to output data memory
830 /// @param samples Amount of samples inside array_in
831 /// @return Amount of samples processed
832 /// @remarks Optional. Is set by AE_DSP_ADDON_CAPABILITIES and asked with
833 /// GetCapabilities
834 ///
835 virtual unsigned int PreProcess(const ADDON_HANDLE handle, unsigned int mode_id, const float** array_in, float** array_out, unsigned int samples) { return 0; }
836 //--------------------------------------------------------------------------
837 //@}
838
839 /** @name DSP Master processing
840 * @remarks Only used by KODI if bSupportsMasterProcess is set to true.
841 */
842 //@{
843 //==========================================================================
844 ///
845 /// @brief Set the active master process mode
846 /// @param handle identification data for stream
847 /// @param type Requested stream type for the selected master mode
848 /// @param mode_id The Mode identifier.
849 /// @param unique_db_mode_id The Mode unique id generated from DSP database.
850 /// @return AE_DSP_ERROR_NO_ERROR if the setup was successful
851 /// @remarks Optional. Is set by AE_DSP_ADDON_CAPABILITIES and asked with
852 /// GetCapabilities
853 ///
854 virtual AE_DSP_ERROR MasterProcessSetMode(const ADDON_HANDLE handle, AE_DSP_STREAMTYPE type, unsigned int mode_id, int unique_db_mode_id) { return AE_DSP_ERROR_NOT_IMPLEMENTED; }
855 //--------------------------------------------------------------------------
856
857 //==========================================================================
858 ///
859 /// @brief If the add-on operate with buffered arrays and the output size can
860 /// be higher as the input it becomes asked about needed size before any
861 /// MasterProcess call.
862 /// @param handle identification data for stream
863 /// @return The needed size of output array or 0 if no changes within it
864 /// @remarks Optional. Is set by AE_DSP_ADDON_CAPABILITIES and asked with
865 /// GetCapabilities
866 ///
867 virtual unsigned int MasterProcessNeededSamplesize(const ADDON_HANDLE handle) { return 0; }
868 //--------------------------------------------------------------------------
869
870 //==========================================================================
871 ///
872 /// @brief Returns the time in seconds that it will take
873 /// for the next added packet to be returned to KODI.
874 /// @param handle identification data for stream
875 /// @return the delay in seconds
876 /// @remarks Optional. Is set by AE_DSP_ADDON_CAPABILITIES and asked with
877 /// GetCapabilities
878 ///
879 virtual float MasterProcessGetDelay(const ADDON_HANDLE handle) { return 0.0f; }
880 //--------------------------------------------------------------------------
881
882 //==========================================================================
883 ///
884 /// @brief Returns the from selected master mode performed channel alignment
885 /// @param handle identification data for stream
886 /// @retval out_channel_present_flags the exact channel present flags after
887 /// performed up-/downmix
888 /// @return the amount channels
889 /// @remarks Optional. Must be used and set if a channel up- or downmix is
890 /// processed from the active master mode
891 ///
892 virtual int MasterProcessGetOutChannels(const ADDON_HANDLE handle, unsigned long& out_channel_present_flags) { return 0; }
893 //--------------------------------------------------------------------------
894
895 //==========================================================================
896 ///
897 /// @brief Master processing becomes performed with it
898 /// Here a channel up-mix/down-mix for stereo surround sound can be performed
899 /// Only one DSP add-on is allowed to-do this!
900 /// @param handle identification data for stream
901 /// @param array_in Pointer to input data memory
902 /// @param array_out Pointer to output data memory
903 /// @param samples Amount of samples inside array_in
904 /// @return Amount of samples processed
905 /// @remarks Optional. Is set by AE_DSP_ADDON_CAPABILITIES and asked with
906 /// GetCapabilities
907 ///
908 virtual unsigned int MasterProcess(const ADDON_HANDLE handle, const float** array_in, float** array_out, unsigned int samples) { return 0; }
909 //--------------------------------------------------------------------------
910
911 //==========================================================================
912 ///
913 /// Used to get a information string about the processed work to show on skin
914 /// @return A string to show
915 /// @remarks Optional. Is set by AE_DSP_ADDON_CAPABILITIES and asked with
916 /// GetCapabilities
917 ///
918 virtual std::string MasterProcessGetStreamInfoString(const ADDON_HANDLE handle) { return ""; }
919 //--------------------------------------------------------------------------
920 //@}
921
922 /** @name DSP Post processing
923 * @remarks Only used by KODI if bSupportsPostProcess is set to true.
924 */
925 //@{
926 //==========================================================================
927 ///
928 /// If the add-on operate with buffered arrays and the output size can be
929 /// higher as the input it becomes asked about needed size before any
930 /// PostProcess call.
931 /// @param handle identification data for stream
932 /// @param mode_id The mode inside add-on which must be performed on call. Id
933 /// is set from add-on by iModeNumber on AE_DSP_MODE structure during
934 /// RegisterMode callback, and can be defined from add-on as a structure
935 /// pointer or anything else what is needed to find it.
936 /// @return The needed size of output array or 0 if no changes within it
937 /// @remarks Optional. Is set by AE_DSP_ADDON_CAPABILITIES and asked with
938 /// GetCapabilities
939 ///
940 virtual unsigned int PostProcessNeededSamplesize(const ADDON_HANDLE handle, unsigned int mode_id) { return 0; }
941 //--------------------------------------------------------------------------
942
943 //==========================================================================
944 ///
945 /// Returns the time in seconds that it will take
946 /// for the next added packet to be returned to KODI.
947 /// @param handle identification data for stream
948 /// @param mode_id The mode inside add-on which must be performed on call. Id
949 /// is set from add-on by iModeNumber on AE_DSP_MODE structure during
950 /// RegisterMode callback, and can be defined from add-on as a structure
951 /// pointer or anything else what is needed to find it.
952 /// @return the delay in seconds
953 /// @remarks Optional. Is set by AE_DSP_ADDON_CAPABILITIES and asked with
954 /// GetCapabilities
955 ///
956 virtual float PostProcessGetDelay(const ADDON_HANDLE handle, unsigned int mode_id) { return 0.0f; }
957 //--------------------------------------------------------------------------
958
959 //==========================================================================
960
961 ///
962 /// @brief DSP post processing
963 /// On the post processing can be things performed with additional channel
964 /// upmix like 6.1 to 7.1
965 /// or frequency/volume corrections, speaker distance handling, equalizer... .
966 /// All DSP add-ons allowed to-do this.
967 /// @param handle identification data for stream
968 /// @param mode_id The mode inside add-on which must be performed on call. Id
969 /// is set from add-on by iModeNumber on AE_DSP_MODE structure during
970 /// RegisterMode callback, and can be defined from add-on as a structure
971 /// pointer or anything else what is needed to find it.
972 /// @param array_in Pointer to input data memory
973 /// @param array_out Pointer to output data memory
974 /// @param samples Amount of samples inside array_in
975 /// @return Amount of samples processed
976 /// @remarks Optional. Is set by AE_DSP_ADDON_CAPABILITIES and asked with
977 /// GetCapabilities
978 ///
979 virtual unsigned int PostProcess(const ADDON_HANDLE handle, unsigned int mode_id, const float** array_in, float** array_out, unsigned int samples) { return 0; }
980
981 //--------------------------------------------------------------------------
982 //@}
983
984 /** @name DSP Post re-sampling
985 * @remarks Only used by KODI if bSupportsOutputResample is set to true.
986 */
987 //@{
988 //==========================================================================
989 ///
990 /// @brief If the add-on operate with buffered arrays and the output size
991 /// can be higher as the input
992 /// it becomes asked about needed size before any OutputResampleProcess call.
993 /// @param handle identification data for stream
994 /// @return The needed size of output array or 0 if no changes within it
995 /// @remarks Optional. Is set by AE_DSP_ADDON_CAPABILITIES and asked with
996 /// GetCapabilities
997 ///
998 virtual unsigned int OutputResampleProcessNeededSamplesize(const ADDON_HANDLE handle) { return 0; }
999 //--------------------------------------------------------------------------
1000
1001 //==========================================================================
1002 ///
1003 /// @brief Re-sampling after master processing becomes performed with it if
1004 /// needed, only
1005 /// one add-on can perform it.
1006 /// @param handle identification data for stream
1007 /// @param array_in Pointer to input data memory
1008 /// @param array_out Pointer to output data memory
1009 /// @param samples Amount of samples inside array_in
1010 /// @return Amount of samples processed
1011 /// @remarks Optional. Is set by AE_DSP_ADDON_CAPABILITIES and asked with
1012 /// GetCapabilities
1013 ///
1014 virtual unsigned int OutputResampleProcess(const ADDON_HANDLE handle, const float** array_in, float** array_out, unsigned int samples) { return 0; }
1015 //--------------------------------------------------------------------------
1016
1017 //==========================================================================
1018 ///
1019 /// @brief Returns the re-sampling generated new sample rate used after the
1020 /// master process.
1021 /// @param handle identification data for stream
1022 /// @return The new sample rate
1023 /// @remarks Optional. Is set by AE_DSP_ADDON_CAPABILITIES and asked with
1024 /// GetCapabilities
1025 ///
1026 virtual int OutputResampleSampleRate(const ADDON_HANDLE handle) { return 0; }
1027 //--------------------------------------------------------------------------
1028
1029 //==========================================================================
1030 ///
1031 /// @brief Returns the time in seconds that it will take for the next added
1032 /// packet to be returned to KODI.
1033 /// @param handle identification data for stream
1034 /// @return the delay in seconds
1035 /// @remarks Optional. Is set by AE_DSP_ADDON_CAPABILITIES and asked with
1036 /// GetCapabilities
1037 ///
1038 virtual float OutputResampleGetDelay(const ADDON_HANDLE handle) { return 0.0f; }
1039 //--------------------------------------------------------------------------
1040 //@}
1041
1042 //==========================================================================
1043 ///
1044 /// @brief Add or replace a menu hook for the context menu for this add-on
1045 /// @param hook The hook to add
1046 ///
1047 void AddMenuHook(AE_DSP_MENUHOOK* hook)
1048 {
1049 return m_instanceData->toKodi.add_menu_hook(m_instanceData->toKodi.kodiInstance, hook);
1050 }
1051 //--------------------------------------------------------------------------
1052
1053 //==========================================================================
1054 ///
1055 /// @brief Remove a menu hook for the context menu for this add-on
1056 /// @param hook The hook to remove
1057 ///
1058 void RemoveMenuHook(AE_DSP_MENUHOOK* hook)
1059 {
1060 return m_instanceData->toKodi.remove_menu_hook(m_instanceData->toKodi.kodiInstance, hook);
1061 }
1062 //--------------------------------------------------------------------------
1063
1064 //==========================================================================
1065 ///
1066 /// @brief Add or replace master mode information inside audio dsp database.
1067 /// Becomes identifier written inside mode to iModeID if it was 0 (undefined)
1068 /// @param mode The master mode to add or update inside database
1069 ///
1070 void RegisterMode(AE_DSP_MODES::AE_DSP_MODE* mode)
1071 {
1072 return m_instanceData->toKodi.register_mode(m_instanceData->toKodi.kodiInstance, mode);
1073 }
1074 //--------------------------------------------------------------------------
1075
1076 //==========================================================================
1077 ///
1078 /// @brief Remove a master mode from audio dsp database
1079 /// @param mode The Mode to remove
1080 ///
1081 void UnregisterMode(AE_DSP_MODES::AE_DSP_MODE* mode)
1082 {
1083 return m_instanceData->toKodi.unregister_mode(m_instanceData->toKodi.kodiInstance, mode);
1084 }
1085 //--------------------------------------------------------------------------
1086
1087 private:
1088 void SetAddonStruct(KODI_HANDLE instance)
1089 {
1090 if (instance == nullptr)
1091 throw std::logic_error("kodi::addon::CInstanceAudioDSP: Null pointer instance passed.");
1092
1093 m_instanceData = static_cast<AddonInstance_AudioDSP*>(instance);
1094
1095 m_instanceData->toAddon.get_capabilities = ADDON_GetCapabilities;
1096 m_instanceData->toAddon.get_dsp_name = ADDON_GetDSPName;
1097 m_instanceData->toAddon.get_dsp_version = ADDON_GetDSPVersion;
1098 m_instanceData->toAddon.menu_hook = ADDON_MenuHook;
1099
1100 m_instanceData->toAddon.stream_create = ADDON_StreamCreate;
1101 m_instanceData->toAddon.stream_destroy = ADDON_StreamDestroy;
1102 m_instanceData->toAddon.stream_is_mode_supported = ADDON_StreamIsModeSupported;
1103 m_instanceData->toAddon.stream_initialize = ADDON_StreamInitialize;
1104
1105 m_instanceData->toAddon.input_process = ADDON_InputProcess;
1106
1107 m_instanceData->toAddon.input_resample_process_needed_samplesize = ADDON_InputResampleProcessNeededSamplesize;
1108 m_instanceData->toAddon.input_resample_process = ADDON_InputResampleProcess;
1109 m_instanceData->toAddon.input_resample_get_delay = ADDON_InputResampleGetDelay;
1110 m_instanceData->toAddon.input_resample_samplerate = ADDON_InputResampleSampleRate;
1111
1112 m_instanceData->toAddon.pre_process_needed_samplesize = ADDON_PreProcessNeededSamplesize;
1113 m_instanceData->toAddon.pre_process_get_delay = ADDON_PreProcessGetDelay;
1114 m_instanceData->toAddon.pre_process = ADDON_PreProcess;
1115
1116 m_instanceData->toAddon.master_process_set_mode = ADDON_MasterProcessSetMode;
1117 m_instanceData->toAddon.master_process_needed_samplesize = ADDON_MasterProcessNeededSamplesize;
1118 m_instanceData->toAddon.master_process_get_delay = ADDON_MasterProcessGetDelay;
1119 m_instanceData->toAddon.master_process_get_out_channels = ADDON_MasterProcessGetOutChannels;
1120 m_instanceData->toAddon.master_process = ADDON_MasterProcess;
1121 m_instanceData->toAddon.master_process_get_stream_info_string = ADDON_MasterProcessGetStreamInfoString;
1122
1123 m_instanceData->toAddon.post_process_needed_samplesize = ADDON_PostProcessNeededSamplesize;
1124 m_instanceData->toAddon.post_process_get_delay = ADDON_PostProcessGetDelay;
1125 m_instanceData->toAddon.post_process = ADDON_PostProcess;
1126
1127 m_instanceData->toAddon.output_resample_process_needed_samplesize = ADDON_OutputResampleProcessNeededSamplesize;
1128 m_instanceData->toAddon.output_resample_process = ADDON_OutputResampleProcess;
1129 m_instanceData->toAddon.output_resample_get_delay = ADDON_OutputResampleGetDelay;
1130 m_instanceData->toAddon.output_resample_samplerate = ADDON_OutputResampleSampleRate;
1131 }
1132
1133 static inline void ADDON_GetCapabilities(AddonInstance_AudioDSP const* instance, AE_DSP_ADDON_CAPABILITIES *capabilities)
1134 {
1135 instance->toAddon.addonInstance->GetCapabilities(*capabilities);
1136 }
1137
1138 static inline const char* ADDON_GetDSPName(AddonInstance_AudioDSP const* instance)
1139 {
1140 instance->toAddon.addonInstance->m_dspName = instance->toAddon.addonInstance->GetDSPName();
1141 return instance->toAddon.addonInstance->m_dspName.c_str();
1142 }
1143
1144 static inline const char* ADDON_GetDSPVersion(AddonInstance_AudioDSP const* instance)
1145 {
1146 instance->toAddon.addonInstance->m_dspVersion = instance->toAddon.addonInstance->GetDSPVersion();
1147 return instance->toAddon.addonInstance->m_dspVersion.c_str();
1148 }
1149
1150 static inline AE_DSP_ERROR ADDON_MenuHook(AddonInstance_AudioDSP const* instance, const AE_DSP_MENUHOOK* menuhook, const AE_DSP_MENUHOOK_DATA* item)
1151 {
1152 return instance->toAddon.addonInstance->MenuHook(*menuhook, *item);
1153 }
1154
1155 static inline AE_DSP_ERROR ADDON_StreamCreate(AddonInstance_AudioDSP const* instance, const AE_DSP_SETTINGS *addonSettings, const AE_DSP_STREAM_PROPERTIES* properties, ADDON_HANDLE handle)
1156 {
1157 return instance->toAddon.addonInstance->StreamCreate(*addonSettings, *properties, handle);
1158 }
1159
1160 static inline AE_DSP_ERROR ADDON_StreamDestroy(AddonInstance_AudioDSP const* instance, const ADDON_HANDLE handle)
1161 {
1162 return instance->toAddon.addonInstance->StreamDestroy(handle);
1163 }
1164
1165 static inline AE_DSP_ERROR ADDON_StreamIsModeSupported(AddonInstance_AudioDSP const* instance, const ADDON_HANDLE handle, AE_DSP_MODE_TYPE type, unsigned int mode_id, int unique_db_mode_id)
1166 {
1167 return instance->toAddon.addonInstance->StreamIsModeSupported(handle, type, mode_id, unique_db_mode_id);
1168 }
1169
1170 static inline AE_DSP_ERROR ADDON_StreamInitialize(AddonInstance_AudioDSP const* instance, const ADDON_HANDLE handle, const AE_DSP_SETTINGS *addonSettings)
1171 {
1172 return instance->toAddon.addonInstance->StreamInitialize(handle, *addonSettings);
1173 }
1174
1175 static inline bool ADDON_InputProcess(AddonInstance_AudioDSP const* instance, const ADDON_HANDLE handle, const float** array_in, unsigned int samples)
1176 {
1177 return instance->toAddon.addonInstance->InputProcess(handle, array_in, samples);
1178 }
1179
1180 static inline unsigned int ADDON_InputResampleProcessNeededSamplesize(AddonInstance_AudioDSP const* instance, const ADDON_HANDLE handle)
1181 {
1182 return instance->toAddon.addonInstance->InputResampleProcessNeededSamplesize(handle);
1183 }
1184
1185 static inline unsigned int ADDON_InputResampleProcess(AddonInstance_AudioDSP const* instance, const ADDON_HANDLE handle, const float** array_in, float** array_out, unsigned int samples)
1186 {
1187 return instance->toAddon.addonInstance->InputResampleProcess(handle, array_in, array_out, samples);
1188 }
1189
1190 static inline int ADDON_InputResampleSampleRate(AddonInstance_AudioDSP const* instance, const ADDON_HANDLE handle)
1191 {
1192 return instance->toAddon.addonInstance->InputResampleSampleRate(handle);
1193 }
1194
1195 static inline float ADDON_InputResampleGetDelay(AddonInstance_AudioDSP const* instance, const ADDON_HANDLE handle)
1196 {
1197 return instance->toAddon.addonInstance->InputResampleGetDelay(handle);
1198 }
1199
1200 static inline unsigned int ADDON_PreProcessNeededSamplesize(AddonInstance_AudioDSP const* instance, const ADDON_HANDLE handle, unsigned int mode_id)
1201 {
1202 return instance->toAddon.addonInstance->PreProcessNeededSamplesize(handle, mode_id);
1203 }
1204
1205 static inline float ADDON_PreProcessGetDelay(AddonInstance_AudioDSP const* instance, const ADDON_HANDLE handle, unsigned int mode_id)
1206 {
1207 return instance->toAddon.addonInstance->PreProcessGetDelay(handle, mode_id);
1208 }
1209
1210 static inline unsigned int ADDON_PreProcess(AddonInstance_AudioDSP const* instance, const ADDON_HANDLE handle, unsigned int mode_id, const float** array_in, float** array_out, unsigned int samples)
1211 {
1212 return instance->toAddon.addonInstance->PreProcess(handle, mode_id, array_in, array_out, samples);
1213 }
1214
1215 static inline AE_DSP_ERROR ADDON_MasterProcessSetMode(AddonInstance_AudioDSP const* instance, const ADDON_HANDLE handle, AE_DSP_STREAMTYPE type, unsigned int mode_id, int unique_db_mode_id)
1216 {
1217 return instance->toAddon.addonInstance->MasterProcessSetMode(handle, type, mode_id, unique_db_mode_id);
1218 }
1219
1220 static inline unsigned int ADDON_MasterProcessNeededSamplesize(AddonInstance_AudioDSP const* instance, const ADDON_HANDLE handle)
1221 {
1222 return instance->toAddon.addonInstance->MasterProcessNeededSamplesize(handle);
1223 }
1224
1225 static inline float ADDON_MasterProcessGetDelay(AddonInstance_AudioDSP const* instance, const ADDON_HANDLE handle)
1226 {
1227 return instance->toAddon.addonInstance->MasterProcessGetDelay(handle);
1228 }
1229
1230 static inline int ADDON_MasterProcessGetOutChannels(AddonInstance_AudioDSP const* instance, const ADDON_HANDLE handle, unsigned long* out_channel_present_flags)
1231 {
1232 return instance->toAddon.addonInstance->MasterProcessGetOutChannels(handle, *out_channel_present_flags);
1233 }
1234
1235 static inline unsigned int ADDON_MasterProcess(AddonInstance_AudioDSP const* instance, const ADDON_HANDLE handle, const float** array_in, float** array_out, unsigned int samples)
1236 {
1237 return instance->toAddon.addonInstance->MasterProcess(handle, array_in, array_out, samples);
1238 }
1239
1240 static inline const char* ADDON_MasterProcessGetStreamInfoString(AddonInstance_AudioDSP const* instance, const ADDON_HANDLE handle)
1241 {
1242 instance->toAddon.addonInstance->m_streamInfoString = instance->toAddon.addonInstance->MasterProcessGetStreamInfoString(handle);
1243 return instance->toAddon.addonInstance->m_streamInfoString.c_str();
1244 }
1245
1246 static inline unsigned int ADDON_PostProcessNeededSamplesize(AddonInstance_AudioDSP const* instance, const ADDON_HANDLE handle, unsigned int mode_id)
1247 {
1248 return instance->toAddon.addonInstance->PostProcessNeededSamplesize(handle, mode_id);
1249 }
1250
1251 static inline float ADDON_PostProcessGetDelay(AddonInstance_AudioDSP const* instance, const ADDON_HANDLE handle, unsigned int mode_id)
1252 {
1253 return instance->toAddon.addonInstance->PostProcessGetDelay(handle, mode_id);
1254 }
1255
1256 static inline unsigned int ADDON_PostProcess(AddonInstance_AudioDSP const* instance, const ADDON_HANDLE handle, unsigned int mode_id, const float** array_in, float** array_out, unsigned int samples)
1257 {
1258 return instance->toAddon.addonInstance->PostProcess(handle, mode_id, array_in, array_out, samples);
1259 }
1260
1261 static inline unsigned int ADDON_OutputResampleProcessNeededSamplesize(AddonInstance_AudioDSP const* instance, const ADDON_HANDLE handle)
1262 {
1263 return instance->toAddon.addonInstance->OutputResampleProcessNeededSamplesize(handle);
1264 }
1265
1266 static inline unsigned int ADDON_OutputResampleProcess(AddonInstance_AudioDSP const* instance, const ADDON_HANDLE handle, const float** array_in, float** array_out, unsigned int samples)
1267 {
1268 return instance->toAddon.addonInstance->OutputResampleProcess(handle, array_in, array_out, samples);
1269 }
1270
1271 static inline int ADDON_OutputResampleSampleRate(AddonInstance_AudioDSP const* instance, const ADDON_HANDLE handle)
1272 {
1273 return instance->toAddon.addonInstance->OutputResampleSampleRate(handle);
1274 }
1275
1276 static inline float ADDON_OutputResampleGetDelay(AddonInstance_AudioDSP const* instance, const ADDON_HANDLE handle)
1277 {
1278 return instance->toAddon.addonInstance->OutputResampleGetDelay(handle);
1279 }
1280
1281 std::string m_dspName;
1282 std::string m_dspVersion;
1283 std::string m_streamInfoString;
1284 AddonInstance_AudioDSP* m_instanceData;
1285 };
1286
1287} /* namespace addon */
1288} /* namespace kodi */
diff --git a/xbmc/addons/kodi-addon-dev-kit/include/kodi/addon-instance/CMakeLists.txt b/xbmc/addons/kodi-addon-dev-kit/include/kodi/addon-instance/CMakeLists.txt
index ba4f889..44aaf05 100644
--- a/xbmc/addons/kodi-addon-dev-kit/include/kodi/addon-instance/CMakeLists.txt
+++ b/xbmc/addons/kodi-addon-dev-kit/include/kodi/addon-instance/CMakeLists.txt
@@ -1,5 +1,4 @@
1set(HEADERS AudioDSP.h 1set(HEADERS AudioDecoder.h
2 AudioDecoder.h
3 AudioEncoder.h 2 AudioEncoder.h
4 ImageDecoder.h 3 ImageDecoder.h
5 Inputstream.h 4 Inputstream.h
diff --git a/xbmc/addons/kodi-addon-dev-kit/include/kodi/addon-instance/Peripheral.h b/xbmc/addons/kodi-addon-dev-kit/include/kodi/addon-instance/Peripheral.h
index 0dae06c..75be27e 100644
--- a/xbmc/addons/kodi-addon-dev-kit/include/kodi/addon-instance/Peripheral.h
+++ b/xbmc/addons/kodi-addon-dev-kit/include/kodi/addon-instance/Peripheral.h
@@ -34,6 +34,10 @@ extern "C"
34 34
35 /// @name Peripheral types 35 /// @name Peripheral types
36 ///{ 36 ///{
37
38 /*!
39 * @brief API error codes
40 */
37 typedef enum PERIPHERAL_ERROR 41 typedef enum PERIPHERAL_ERROR
38 { 42 {
39 PERIPHERAL_NO_ERROR = 0, // no error occurred 43 PERIPHERAL_NO_ERROR = 0, // no error occurred
@@ -45,6 +49,9 @@ extern "C"
45 PERIPHERAL_ERROR_CONNECTION_FAILED = -6, // peripherals are connected, but command was interrupted 49 PERIPHERAL_ERROR_CONNECTION_FAILED = -6, // peripherals are connected, but command was interrupted
46 } PERIPHERAL_ERROR; 50 } PERIPHERAL_ERROR;
47 51
52 /*!
53 * @brief Peripheral types
54 */
48 typedef enum PERIPHERAL_TYPE 55 typedef enum PERIPHERAL_TYPE
49 { 56 {
50 PERIPHERAL_TYPE_UNKNOWN, 57 PERIPHERAL_TYPE_UNKNOWN,
@@ -52,6 +59,9 @@ extern "C"
52 PERIPHERAL_TYPE_KEYBOARD, 59 PERIPHERAL_TYPE_KEYBOARD,
53 } PERIPHERAL_TYPE; 60 } PERIPHERAL_TYPE;
54 61
62 /*!
63 * @brief Information shared between peripherals
64 */
55 typedef struct PERIPHERAL_INFO 65 typedef struct PERIPHERAL_INFO
56 { 66 {
57 PERIPHERAL_TYPE type; /*!< @brief type of peripheral */ 67 PERIPHERAL_TYPE type; /*!< @brief type of peripheral */
@@ -63,8 +73,6 @@ extern "C"
63 73
64 /*! 74 /*!
65 * @brief Peripheral add-on capabilities. 75 * @brief Peripheral add-on capabilities.
66 * If a capability is set to true, then the corresponding methods from
67 * kodi_peripheral_dll.h need to be implemented.
68 */ 76 */
69 typedef struct PERIPHERAL_CAPABILITIES 77 typedef struct PERIPHERAL_CAPABILITIES
70 { 78 {
@@ -77,6 +85,10 @@ extern "C"
77 85
78 /// @name Event types 86 /// @name Event types
79 ///{ 87 ///{
88
89 /*!
90 * @brief Types of events that can be sent and received
91 */
80 typedef enum PERIPHERAL_EVENT_TYPE 92 typedef enum PERIPHERAL_EVENT_TYPE
81 { 93 {
82 PERIPHERAL_EVENT_TYPE_NONE, /*!< @brief unknown event */ 94 PERIPHERAL_EVENT_TYPE_NONE, /*!< @brief unknown event */
@@ -86,12 +98,18 @@ extern "C"
86 PERIPHERAL_EVENT_TYPE_SET_MOTOR, /*!< @brief set the state for joystick rumble motor */ 98 PERIPHERAL_EVENT_TYPE_SET_MOTOR, /*!< @brief set the state for joystick rumble motor */
87 } PERIPHERAL_EVENT_TYPE; 99 } PERIPHERAL_EVENT_TYPE;
88 100
101 /*!
102 * @brief States a button can have
103 */
89 typedef enum JOYSTICK_STATE_BUTTON 104 typedef enum JOYSTICK_STATE_BUTTON
90 { 105 {
91 JOYSTICK_STATE_BUTTON_UNPRESSED = 0x0, /*!< @brief button is released */ 106 JOYSTICK_STATE_BUTTON_UNPRESSED = 0x0, /*!< @brief button is released */
92 JOYSTICK_STATE_BUTTON_PRESSED = 0x1, /*!< @brief button is pressed */ 107 JOYSTICK_STATE_BUTTON_PRESSED = 0x1, /*!< @brief button is pressed */
93 } JOYSTICK_STATE_BUTTON; 108 } JOYSTICK_STATE_BUTTON;
94 109
110 /*!
111 * @brief States a D-pad (also called a hat) can have
112 */
95 typedef enum JOYSTICK_STATE_HAT 113 typedef enum JOYSTICK_STATE_HAT
96 { 114 {
97 JOYSTICK_STATE_HAT_UNPRESSED = 0x0, /*!< @brief no directions are pressed */ 115 JOYSTICK_STATE_HAT_UNPRESSED = 0x0, /*!< @brief no directions are pressed */
@@ -106,7 +124,7 @@ extern "C"
106 } JOYSTICK_STATE_HAT; 124 } JOYSTICK_STATE_HAT;
107 125
108 /*! 126 /*!
109 * @brief value in the closed interval [-1.0, 1.0] 127 * @brief Axis value in the closed interval [-1.0, 1.0]
110 * 128 *
111 * The axis state uses the XInput coordinate system: 129 * The axis state uses the XInput coordinate system:
112 * - Negative values signify down or to the left 130 * - Negative values signify down or to the left
@@ -114,13 +132,25 @@ extern "C"
114 */ 132 */
115 typedef float JOYSTICK_STATE_AXIS; 133 typedef float JOYSTICK_STATE_AXIS;
116 134
135 /*!
136 * @brief Motor value in the closed interval [0.0, 1.0]
137 */
117 typedef float JOYSTICK_STATE_MOTOR; 138 typedef float JOYSTICK_STATE_MOTOR;
118 139
140 /*!
141 * @brief Event information
142 */
119 typedef struct PERIPHERAL_EVENT 143 typedef struct PERIPHERAL_EVENT
120 { 144 {
121 unsigned int peripheral_index; 145 /*! @brief Index of the peripheral handling/receiving the event */
122 PERIPHERAL_EVENT_TYPE type; 146 unsigned int peripheral_index;
123 unsigned int driver_index; 147
148 /*! @brief Type of the event used to determine which enum field to access below */
149 PERIPHERAL_EVENT_TYPE type;
150
151 /*! @brief The index of the event source */
152 unsigned int driver_index;
153
124 JOYSTICK_STATE_BUTTON driver_button_state; 154 JOYSTICK_STATE_BUTTON driver_button_state;
125 JOYSTICK_STATE_HAT driver_hat_state; 155 JOYSTICK_STATE_HAT driver_hat_state;
126 JOYSTICK_STATE_AXIS driver_axis_state; 156 JOYSTICK_STATE_AXIS driver_axis_state;
@@ -130,6 +160,10 @@ extern "C"
130 160
131 /// @name Joystick types 161 /// @name Joystick types
132 ///{ 162 ///{
163
164 /*!
165 * @brief Info specific to joystick peripherals
166 */
133 typedef struct JOYSTICK_INFO 167 typedef struct JOYSTICK_INFO
134 { 168 {
135 PERIPHERAL_INFO peripheral; /*!< @brief peripheral info for this joystick */ 169 PERIPHERAL_INFO peripheral; /*!< @brief peripheral info for this joystick */
@@ -142,6 +176,15 @@ extern "C"
142 bool supports_poweroff; /*!< @brief whether the joystick supports being powered off */ 176 bool supports_poweroff; /*!< @brief whether the joystick supports being powered off */
143 } ATTRIBUTE_PACKED JOYSTICK_INFO; 177 } ATTRIBUTE_PACKED JOYSTICK_INFO;
144 178
179 /*!
180 * @brief Driver input primitives
181 *
182 * Mapping lower-level driver values to higher-level controller features is
183 * non-injective; two triggers can share a single axis.
184 *
185 * To handle this, driver values are subdivided into "primitives" that map
186 * injectively to higher-level features.
187 */
145 typedef enum JOYSTICK_DRIVER_PRIMITIVE_TYPE 188 typedef enum JOYSTICK_DRIVER_PRIMITIVE_TYPE
146 { 189 {
147 JOYSTICK_DRIVER_PRIMITIVE_TYPE_UNKNOWN, 190 JOYSTICK_DRIVER_PRIMITIVE_TYPE_UNKNOWN,
@@ -149,13 +192,22 @@ extern "C"
149 JOYSTICK_DRIVER_PRIMITIVE_TYPE_HAT_DIRECTION, 192 JOYSTICK_DRIVER_PRIMITIVE_TYPE_HAT_DIRECTION,
150 JOYSTICK_DRIVER_PRIMITIVE_TYPE_SEMIAXIS, 193 JOYSTICK_DRIVER_PRIMITIVE_TYPE_SEMIAXIS,
151 JOYSTICK_DRIVER_PRIMITIVE_TYPE_MOTOR, 194 JOYSTICK_DRIVER_PRIMITIVE_TYPE_MOTOR,
195 JOYSTICK_DRIVER_PRIMITIVE_TYPE_KEY,
196 JOYSTICK_DRIVER_PRIMITIVE_TYPE_MOUSE_BUTTON,
197 JOYSTICK_DRIVER_PRIMITIVE_TYPE_RELPOINTER_DIRECTION,
152 } JOYSTICK_DRIVER_PRIMITIVE_TYPE; 198 } JOYSTICK_DRIVER_PRIMITIVE_TYPE;
153 199
200 /*!
201 * @brief Button primitive
202 */
154 typedef struct JOYSTICK_DRIVER_BUTTON 203 typedef struct JOYSTICK_DRIVER_BUTTON
155 { 204 {
156 int index; 205 int index;
157 } ATTRIBUTE_PACKED JOYSTICK_DRIVER_BUTTON; 206 } ATTRIBUTE_PACKED JOYSTICK_DRIVER_BUTTON;
158 207
208 /*!
209 * @brief Hat direction
210 */
159 typedef enum JOYSTICK_DRIVER_HAT_DIRECTION 211 typedef enum JOYSTICK_DRIVER_HAT_DIRECTION
160 { 212 {
161 JOYSTICK_DRIVER_HAT_UNKNOWN, 213 JOYSTICK_DRIVER_HAT_UNKNOWN,
@@ -165,12 +217,18 @@ extern "C"
165 JOYSTICK_DRIVER_HAT_DOWN, 217 JOYSTICK_DRIVER_HAT_DOWN,
166 } JOYSTICK_DRIVER_HAT_DIRECTION; 218 } JOYSTICK_DRIVER_HAT_DIRECTION;
167 219
220 /*!
221 * @brief Hat direction primitive
222 */
168 typedef struct JOYSTICK_DRIVER_HAT 223 typedef struct JOYSTICK_DRIVER_HAT
169 { 224 {
170 int index; 225 int index;
171 JOYSTICK_DRIVER_HAT_DIRECTION direction; 226 JOYSTICK_DRIVER_HAT_DIRECTION direction;
172 } ATTRIBUTE_PACKED JOYSTICK_DRIVER_HAT; 227 } ATTRIBUTE_PACKED JOYSTICK_DRIVER_HAT;
173 228
229 /*!
230 * @brief Semiaxis direction
231 */
174 typedef enum JOYSTICK_DRIVER_SEMIAXIS_DIRECTION 232 typedef enum JOYSTICK_DRIVER_SEMIAXIS_DIRECTION
175 { 233 {
176 JOYSTICK_DRIVER_SEMIAXIS_NEGATIVE = -1, /*!< @brief negative half of the axis */ 234 JOYSTICK_DRIVER_SEMIAXIS_NEGATIVE = -1, /*!< @brief negative half of the axis */
@@ -178,6 +236,9 @@ extern "C"
178 JOYSTICK_DRIVER_SEMIAXIS_POSITIVE = 1, /*!< @brief positive half of the axis */ 236 JOYSTICK_DRIVER_SEMIAXIS_POSITIVE = 1, /*!< @brief positive half of the axis */
179 } JOYSTICK_DRIVER_SEMIAXIS_DIRECTION; 237 } JOYSTICK_DRIVER_SEMIAXIS_DIRECTION;
180 238
239 /*!
240 * @brief Semiaxis primitive
241 */
181 typedef struct JOYSTICK_DRIVER_SEMIAXIS 242 typedef struct JOYSTICK_DRIVER_SEMIAXIS
182 { 243 {
183 int index; 244 int index;
@@ -186,11 +247,70 @@ extern "C"
186 unsigned int range; 247 unsigned int range;
187 } ATTRIBUTE_PACKED JOYSTICK_DRIVER_SEMIAXIS; 248 } ATTRIBUTE_PACKED JOYSTICK_DRIVER_SEMIAXIS;
188 249
250 /*!
251 * @brief Motor primitive
252 */
189 typedef struct JOYSTICK_DRIVER_MOTOR 253 typedef struct JOYSTICK_DRIVER_MOTOR
190 { 254 {
191 int index; 255 int index;
192 } ATTRIBUTE_PACKED JOYSTICK_DRIVER_MOTOR; 256 } ATTRIBUTE_PACKED JOYSTICK_DRIVER_MOTOR;
193 257
258 /*!
259 * @brief Keyboard key primitive
260 */
261 typedef struct JOYSTICK_DRIVER_KEY
262 {
263 char keycode[16];
264 } ATTRIBUTE_PACKED JOYSTICK_DRIVER_KEY;
265
266 /*!
267 * @brief Mouse buttons
268 */
269 typedef enum JOYSTICK_DRIVER_MOUSE_INDEX
270 {
271 JOYSTICK_DRIVER_MOUSE_INDEX_UNKNOWN,
272 JOYSTICK_DRIVER_MOUSE_INDEX_LEFT,
273 JOYSTICK_DRIVER_MOUSE_INDEX_RIGHT,
274 JOYSTICK_DRIVER_MOUSE_INDEX_MIDDLE,
275 JOYSTICK_DRIVER_MOUSE_INDEX_BUTTON4,
276 JOYSTICK_DRIVER_MOUSE_INDEX_BUTTON5,
277 JOYSTICK_DRIVER_MOUSE_INDEX_WHEEL_UP,
278 JOYSTICK_DRIVER_MOUSE_INDEX_WHEEL_DOWN,
279 JOYSTICK_DRIVER_MOUSE_INDEX_HORIZ_WHEEL_LEFT,
280 JOYSTICK_DRIVER_MOUSE_INDEX_HORIZ_WHEEL_RIGHT,
281 } JOYSTICK_DRIVER_MOUSE_INDEX;
282
283 /*!
284 * @brief Mouse button primitive
285 */
286 typedef struct JOYSTICK_DRIVER_MOUSE_BUTTON
287 {
288 JOYSTICK_DRIVER_MOUSE_INDEX button;
289 } ATTRIBUTE_PACKED JOYSTICK_DRIVER_MOUSE_BUTTON;
290
291 /*!
292 * @brief Relative pointer direction
293 */
294 typedef enum JOYSTICK_DRIVER_RELPOINTER_DIRECTION
295 {
296 JOYSTICK_DRIVER_RELPOINTER_UNKNOWN,
297 JOYSTICK_DRIVER_RELPOINTER_LEFT,
298 JOYSTICK_DRIVER_RELPOINTER_RIGHT,
299 JOYSTICK_DRIVER_RELPOINTER_UP,
300 JOYSTICK_DRIVER_RELPOINTER_DOWN,
301 } JOYSTICK_DRIVER_RELPOINTER_DIRECTION;
302
303 /*!
304 * @brief Relative pointer direction primitive
305 */
306 typedef struct JOYSTICK_DRIVER_RELPOINTER
307 {
308 JOYSTICK_DRIVER_RELPOINTER_DIRECTION direction;
309 } ATTRIBUTE_PACKED JOYSTICK_DRIVER_RELPOINTER;
310
311 /*!
312 * @brief Driver primitive struct
313 */
194 typedef struct JOYSTICK_DRIVER_PRIMITIVE 314 typedef struct JOYSTICK_DRIVER_PRIMITIVE
195 { 315 {
196 JOYSTICK_DRIVER_PRIMITIVE_TYPE type; 316 JOYSTICK_DRIVER_PRIMITIVE_TYPE type;
@@ -200,9 +320,18 @@ extern "C"
200 struct JOYSTICK_DRIVER_HAT hat; 320 struct JOYSTICK_DRIVER_HAT hat;
201 struct JOYSTICK_DRIVER_SEMIAXIS semiaxis; 321 struct JOYSTICK_DRIVER_SEMIAXIS semiaxis;
202 struct JOYSTICK_DRIVER_MOTOR motor; 322 struct JOYSTICK_DRIVER_MOTOR motor;
323 struct JOYSTICK_DRIVER_KEY key;
324 struct JOYSTICK_DRIVER_MOUSE_BUTTON mouse;
325 struct JOYSTICK_DRIVER_RELPOINTER relpointer;
203 }; 326 };
204 } ATTRIBUTE_PACKED JOYSTICK_DRIVER_PRIMITIVE; 327 } ATTRIBUTE_PACKED JOYSTICK_DRIVER_PRIMITIVE;
205 328
329 /*!
330 * @brief Controller feature
331 *
332 * Controller features are an abstraction over driver values. Each feature
333 * maps to one or more driver primitives.
334 */
206 typedef enum JOYSTICK_FEATURE_TYPE 335 typedef enum JOYSTICK_FEATURE_TYPE
207 { 336 {
208 JOYSTICK_FEATURE_TYPE_UNKNOWN, 337 JOYSTICK_FEATURE_TYPE_UNKNOWN,
@@ -214,11 +343,15 @@ extern "C"
214 JOYSTICK_FEATURE_TYPE_ABSPOINTER, 343 JOYSTICK_FEATURE_TYPE_ABSPOINTER,
215 JOYSTICK_FEATURE_TYPE_WHEEL, 344 JOYSTICK_FEATURE_TYPE_WHEEL,
216 JOYSTICK_FEATURE_TYPE_THROTTLE, 345 JOYSTICK_FEATURE_TYPE_THROTTLE,
346 JOYSTICK_FEATURE_TYPE_KEY,
217 } JOYSTICK_FEATURE_TYPE; 347 } JOYSTICK_FEATURE_TYPE;
218 348
349 /*!
350 * @brief Indices used to access a feature's driver primitives
351 */
219 typedef enum JOYSTICK_FEATURE_PRIMITIVE 352 typedef enum JOYSTICK_FEATURE_PRIMITIVE
220 { 353 {
221 // Scalar feature 354 // Scalar feature (a button, hat direction or semiaxis)
222 JOYSTICK_SCALAR_PRIMITIVE = 0, 355 JOYSTICK_SCALAR_PRIMITIVE = 0,
223 356
224 // Analog stick 357 // Analog stick
@@ -243,10 +376,25 @@ extern "C"
243 JOYSTICK_THROTTLE_UP = 0, 376 JOYSTICK_THROTTLE_UP = 0,
244 JOYSTICK_THROTTLE_DOWN = 1, 377 JOYSTICK_THROTTLE_DOWN = 1,
245 378
379 // Key
380 JOYSTICK_KEY_PRIMITIVE = 0,
381
382 // Mouse button
383 JOYSTICK_MOUSE_BUTTON = 0,
384
385 // Relative pointer direction
386 JOYSTICK_RELPOINTER_UP = 0,
387 JOYSTICK_RELPOINTER_DOWN = 1,
388 JOYSTICK_RELPOINTER_RIGHT = 2,
389 JOYSTICK_RELPOINTER_LEFT = 3,
390
246 // Maximum number of primitives 391 // Maximum number of primitives
247 JOYSTICK_PRIMITIVE_MAX = 4, 392 JOYSTICK_PRIMITIVE_MAX = 4,
248 } JOYSTICK_FEATURE_PRIMITIVE; 393 } JOYSTICK_FEATURE_PRIMITIVE;
249 394
395 /*!
396 * @brief Mapping between higher-level controller feature and its driver primitives
397 */
250 typedef struct JOYSTICK_FEATURE 398 typedef struct JOYSTICK_FEATURE
251 { 399 {
252 char* name; 400 char* name;
diff --git a/xbmc/addons/kodi-addon-dev-kit/include/kodi/addon-instance/PeripheralUtils.h b/xbmc/addons/kodi-addon-dev-kit/include/kodi/addon-instance/PeripheralUtils.h
index 3c4cab3..c2efc05 100644
--- a/xbmc/addons/kodi-addon-dev-kit/include/kodi/addon-instance/PeripheralUtils.h
+++ b/xbmc/addons/kodi-addon-dev-kit/include/kodi/addon-instance/PeripheralUtils.h
@@ -23,8 +23,8 @@
23 23
24#include <array> // Requires c++11 24#include <array> // Requires c++11
25#include <cstring> 25#include <cstring>
26#include <map>
27#include <string> 26#include <string>
27#include <utility>
28#include <vector> 28#include <vector>
29 29
30#define PERIPHERAL_SAFE_DELETE(x) do { delete (x); (x) = NULL; } while (0) 30#define PERIPHERAL_SAFE_DELETE(x) do { delete (x); (x) = NULL; } while (0)
@@ -164,62 +164,70 @@ namespace addon
164 class PeripheralEvent 164 class PeripheralEvent
165 { 165 {
166 public: 166 public:
167 PeripheralEvent(void) : 167 PeripheralEvent(void)
168 m_event()
169 { 168 {
170 } 169 }
171 170
172 PeripheralEvent(unsigned int peripheralIndex, unsigned int buttonIndex, JOYSTICK_STATE_BUTTON state) : 171 PeripheralEvent(unsigned int peripheralIndex, unsigned int buttonIndex, JOYSTICK_STATE_BUTTON state) :
173 m_event() 172 m_type(PERIPHERAL_EVENT_TYPE_DRIVER_BUTTON),
173 m_peripheralIndex(peripheralIndex),
174 m_driverIndex(buttonIndex),
175 m_buttonState(state)
174 { 176 {
175 SetType(PERIPHERAL_EVENT_TYPE_DRIVER_BUTTON);
176 SetPeripheralIndex(peripheralIndex);
177 SetDriverIndex(buttonIndex);
178 SetButtonState(state);
179 } 177 }
180 178
181 PeripheralEvent(unsigned int peripheralIndex, unsigned int hatIndex, JOYSTICK_STATE_HAT state) : 179 PeripheralEvent(unsigned int peripheralIndex, unsigned int hatIndex, JOYSTICK_STATE_HAT state) :
182 m_event() 180 m_type(PERIPHERAL_EVENT_TYPE_DRIVER_HAT),
181 m_peripheralIndex(peripheralIndex),
182 m_driverIndex(hatIndex),
183 m_hatState(state)
183 { 184 {
184 SetType(PERIPHERAL_EVENT_TYPE_DRIVER_HAT);
185 SetPeripheralIndex(peripheralIndex);
186 SetDriverIndex(hatIndex);
187 SetHatState(state);
188 } 185 }
189 186
190 PeripheralEvent(unsigned int peripheralIndex, unsigned int axisIndex, JOYSTICK_STATE_AXIS state) : 187 PeripheralEvent(unsigned int peripheralIndex, unsigned int axisIndex, JOYSTICK_STATE_AXIS state) :
191 m_event() 188 m_type(PERIPHERAL_EVENT_TYPE_DRIVER_AXIS),
189 m_peripheralIndex(peripheralIndex),
190 m_driverIndex(axisIndex),
191 m_axisState(state)
192 { 192 {
193 SetType(PERIPHERAL_EVENT_TYPE_DRIVER_AXIS);
194 SetPeripheralIndex(peripheralIndex);
195 SetDriverIndex(axisIndex);
196 SetAxisState(state);
197 } 193 }
198 194
199 explicit PeripheralEvent(const PERIPHERAL_EVENT& event) : 195 explicit PeripheralEvent(const PERIPHERAL_EVENT& event) :
200 m_event(event) 196 m_type(event.type),
201 { 197 m_peripheralIndex(event.peripheral_index),
202 } 198 m_driverIndex(event.driver_index),
203 199 m_buttonState(event.driver_button_state),
204 PERIPHERAL_EVENT_TYPE Type(void) const { return m_event.type; } 200 m_hatState(event.driver_hat_state),
205 unsigned int PeripheralIndex(void) const { return m_event.peripheral_index; } 201 m_axisState(event.driver_axis_state),
206 unsigned int DriverIndex(void) const { return m_event.driver_index; } 202 m_motorState(event.motor_state)
207 JOYSTICK_STATE_BUTTON ButtonState(void) const { return m_event.driver_button_state; } 203 {
208 JOYSTICK_STATE_HAT HatState(void) const { return m_event.driver_hat_state; } 204 }
209 JOYSTICK_STATE_AXIS AxisState(void) const { return m_event.driver_axis_state; } 205
210 JOYSTICK_STATE_MOTOR MotorState(void) const { return m_event.motor_state; } 206 PERIPHERAL_EVENT_TYPE Type(void) const { return m_type; }
211 207 unsigned int PeripheralIndex(void) const { return m_peripheralIndex; }
212 void SetType(PERIPHERAL_EVENT_TYPE type) { m_event.type = type; } 208 unsigned int DriverIndex(void) const { return m_driverIndex; }
213 void SetPeripheralIndex(unsigned int index) { m_event.peripheral_index = index; } 209 JOYSTICK_STATE_BUTTON ButtonState(void) const { return m_buttonState; }
214 void SetDriverIndex(unsigned int index) { m_event.driver_index = index; } 210 JOYSTICK_STATE_HAT HatState(void) const { return m_hatState; }
215 void SetButtonState(JOYSTICK_STATE_BUTTON state) { m_event.driver_button_state = state; } 211 JOYSTICK_STATE_AXIS AxisState(void) const { return m_axisState; }
216 void SetHatState(JOYSTICK_STATE_HAT state) { m_event.driver_hat_state = state; } 212 JOYSTICK_STATE_MOTOR MotorState(void) const { return m_motorState; }
217 void SetAxisState(JOYSTICK_STATE_AXIS state) { m_event.driver_axis_state = state; } 213
218 void SetMotorState(JOYSTICK_STATE_MOTOR state) { m_event.motor_state = state; } 214 void SetType(PERIPHERAL_EVENT_TYPE type) { m_type = type; }
215 void SetPeripheralIndex(unsigned int index) { m_peripheralIndex = index; }
216 void SetDriverIndex(unsigned int index) { m_driverIndex = index; }
217 void SetButtonState(JOYSTICK_STATE_BUTTON state) { m_buttonState = state; }
218 void SetHatState(JOYSTICK_STATE_HAT state) { m_hatState = state; }
219 void SetAxisState(JOYSTICK_STATE_AXIS state) { m_axisState = state; }
220 void SetMotorState(JOYSTICK_STATE_MOTOR state) { m_motorState = state; }
219 221
220 void ToStruct(PERIPHERAL_EVENT& event) const 222 void ToStruct(PERIPHERAL_EVENT& event) const
221 { 223 {
222 event = m_event; 224 event.type = m_type;
225 event.peripheral_index = m_peripheralIndex;
226 event.driver_index = m_driverIndex;
227 event.driver_button_state = m_buttonState;
228 event.driver_hat_state = m_hatState;
229 event.driver_axis_state = m_axisState;
230 event.motor_state = m_motorState;
223 } 231 }
224 232
225 static void FreeStruct(PERIPHERAL_EVENT& event) 233 static void FreeStruct(PERIPHERAL_EVENT& event)
@@ -228,7 +236,13 @@ namespace addon
228 } 236 }
229 237
230 private: 238 private:
231 PERIPHERAL_EVENT m_event; 239 PERIPHERAL_EVENT_TYPE m_type = PERIPHERAL_EVENT_TYPE_NONE;
240 unsigned int m_peripheralIndex = 0;
241 unsigned int m_driverIndex = 0;
242 JOYSTICK_STATE_BUTTON m_buttonState = JOYSTICK_STATE_BUTTON_UNPRESSED;
243 JOYSTICK_STATE_HAT m_hatState = JOYSTICK_STATE_HAT_UNPRESSED;
244 JOYSTICK_STATE_AXIS m_axisState = 0.0f;
245 JOYSTICK_STATE_MOTOR m_motorState = 0.0f;
232 }; 246 };
233 247
234 typedef PeripheralVector<PeripheralEvent, PERIPHERAL_EVENT> PeripheralEvents; 248 typedef PeripheralVector<PeripheralEvent, PERIPHERAL_EVENT> PeripheralEvents;
@@ -298,9 +312,6 @@ namespace addon
298 unsigned int MotorCount(void) const { return m_motorCount; } 312 unsigned int MotorCount(void) const { return m_motorCount; }
299 bool SupportsPowerOff(void) const { return m_supportsPowerOff; } 313 bool SupportsPowerOff(void) const { return m_supportsPowerOff; }
300 314
301 // Derived property: Counts are unknown if all are zero
302 bool AreElementCountsKnown(void) const { return m_buttonCount != 0 || m_hatCount != 0 || m_axisCount != 0; }
303
304 void SetProvider(const std::string& provider) { m_provider = provider; } 315 void SetProvider(const std::string& provider) { m_provider = provider; }
305 void SetRequestedPort(int requestedPort) { m_requestedPort = requestedPort; } 316 void SetRequestedPort(int requestedPort) { m_requestedPort = requestedPort; }
306 void SetButtonCount(unsigned int buttonCount) { m_buttonCount = buttonCount; } 317 void SetButtonCount(unsigned int buttonCount) { m_buttonCount = buttonCount; }
@@ -352,6 +363,9 @@ namespace addon
352 * 2) a hat direction 363 * 2) a hat direction
353 * 3) a semiaxis (either the positive or negative half of an axis) 364 * 3) a semiaxis (either the positive or negative half of an axis)
354 * 4) a motor 365 * 4) a motor
366 * 5) a keyboard key
367 * 6) a mouse button
368 * 7) a relative pointer direction
355 * 369 *
356 * The type determines the fields in use: 370 * The type determines the fields in use:
357 * 371 *
@@ -370,6 +384,15 @@ namespace addon
370 * 384 *
371 * Motor: 385 * Motor:
372 * - driver index 386 * - driver index
387 *
388 * Key:
389 * - key code
390 *
391 * Mouse button:
392 * - driver index
393 *
394 * Relative pointer direction:
395 * - relative pointer direction
373 */ 396 */
374 struct DriverPrimitive 397 struct DriverPrimitive
375 { 398 {
@@ -383,7 +406,8 @@ namespace addon
383 m_hatDirection(JOYSTICK_DRIVER_HAT_UNKNOWN), 406 m_hatDirection(JOYSTICK_DRIVER_HAT_UNKNOWN),
384 m_center(0), 407 m_center(0),
385 m_semiAxisDirection(JOYSTICK_DRIVER_SEMIAXIS_UNKNOWN), 408 m_semiAxisDirection(JOYSTICK_DRIVER_SEMIAXIS_UNKNOWN),
386 m_range(1) 409 m_range(1),
410 m_relPointerDirection(JOYSTICK_DRIVER_RELPOINTER_UNKNOWN)
387 { 411 {
388 } 412 }
389 413
@@ -397,12 +421,13 @@ namespace addon
397 m_hatDirection(JOYSTICK_DRIVER_HAT_UNKNOWN), 421 m_hatDirection(JOYSTICK_DRIVER_HAT_UNKNOWN),
398 m_center(0), 422 m_center(0),
399 m_semiAxisDirection(JOYSTICK_DRIVER_SEMIAXIS_UNKNOWN), 423 m_semiAxisDirection(JOYSTICK_DRIVER_SEMIAXIS_UNKNOWN),
400 m_range(1) 424 m_range(1),
425 m_relPointerDirection(JOYSTICK_DRIVER_RELPOINTER_UNKNOWN)
401 { 426 {
402 } 427 }
403 428
404 /*! 429 /*!
405 * \brief Construct a driver primitive representing a button 430 * \brief Construct a driver primitive representing a joystick button
406 */ 431 */
407 static DriverPrimitive CreateButton(unsigned int buttonIndex) 432 static DriverPrimitive CreateButton(unsigned int buttonIndex)
408 { 433 {
@@ -419,7 +444,8 @@ namespace addon
419 m_hatDirection(direction), 444 m_hatDirection(direction),
420 m_center(0), 445 m_center(0),
421 m_semiAxisDirection(JOYSTICK_DRIVER_SEMIAXIS_UNKNOWN), 446 m_semiAxisDirection(JOYSTICK_DRIVER_SEMIAXIS_UNKNOWN),
422 m_range(1) 447 m_range(1),
448 m_relPointerDirection(JOYSTICK_DRIVER_RELPOINTER_UNKNOWN)
423 { 449 {
424 } 450 }
425 451
@@ -433,7 +459,8 @@ namespace addon
433 m_hatDirection(JOYSTICK_DRIVER_HAT_UNKNOWN), 459 m_hatDirection(JOYSTICK_DRIVER_HAT_UNKNOWN),
434 m_center(center), 460 m_center(center),
435 m_semiAxisDirection(direction), 461 m_semiAxisDirection(direction),
436 m_range(range) 462 m_range(range),
463 m_relPointerDirection(JOYSTICK_DRIVER_RELPOINTER_UNKNOWN)
437 { 464 {
438 } 465 }
439 466
@@ -445,13 +472,52 @@ namespace addon
445 return DriverPrimitive(JOYSTICK_DRIVER_PRIMITIVE_TYPE_MOTOR, motorIndex); 472 return DriverPrimitive(JOYSTICK_DRIVER_PRIMITIVE_TYPE_MOTOR, motorIndex);
446 } 473 }
447 474
475 /*!
476 * \brief Construct a driver primitive representing a key on a keyboard
477 */
478 DriverPrimitive(std::string keycode) :
479 m_type(JOYSTICK_DRIVER_PRIMITIVE_TYPE_KEY),
480 m_driverIndex(0),
481 m_hatDirection(JOYSTICK_DRIVER_HAT_UNKNOWN),
482 m_center(0),
483 m_semiAxisDirection(JOYSTICK_DRIVER_SEMIAXIS_UNKNOWN),
484 m_range(1),
485 m_keycode(std::move(keycode)),
486 m_relPointerDirection(JOYSTICK_DRIVER_RELPOINTER_UNKNOWN)
487 {
488 }
489
490 /*!
491 * \brief Construct a driver primitive representing a mouse button
492 */
493 static DriverPrimitive CreateMouseButton(JOYSTICK_DRIVER_MOUSE_INDEX buttonIndex)
494 {
495 return DriverPrimitive(JOYSTICK_DRIVER_PRIMITIVE_TYPE_MOUSE_BUTTON, static_cast<unsigned int>(buttonIndex));
496 }
497
498 /*!
499 * \brief Construct a driver primitive representing one of the four
500 * direction in which a relative pointer can move
501 */
502 DriverPrimitive(JOYSTICK_DRIVER_RELPOINTER_DIRECTION direction) :
503 m_type(JOYSTICK_DRIVER_PRIMITIVE_TYPE_RELPOINTER_DIRECTION),
504 m_driverIndex(0),
505 m_hatDirection(JOYSTICK_DRIVER_HAT_UNKNOWN),
506 m_center(0),
507 m_semiAxisDirection(JOYSTICK_DRIVER_SEMIAXIS_UNKNOWN),
508 m_range(1),
509 m_relPointerDirection(direction)
510 {
511 }
512
448 explicit DriverPrimitive(const JOYSTICK_DRIVER_PRIMITIVE& primitive) : 513 explicit DriverPrimitive(const JOYSTICK_DRIVER_PRIMITIVE& primitive) :
449 m_type(primitive.type), 514 m_type(primitive.type),
450 m_driverIndex(0), 515 m_driverIndex(0),
451 m_hatDirection(JOYSTICK_DRIVER_HAT_UNKNOWN), 516 m_hatDirection(JOYSTICK_DRIVER_HAT_UNKNOWN),
452 m_center(0), 517 m_center(0),
453 m_semiAxisDirection(JOYSTICK_DRIVER_SEMIAXIS_UNKNOWN), 518 m_semiAxisDirection(JOYSTICK_DRIVER_SEMIAXIS_UNKNOWN),
454 m_range(1) 519 m_range(1),
520 m_relPointerDirection(JOYSTICK_DRIVER_RELPOINTER_UNKNOWN)
455 { 521 {
456 switch (m_type) 522 switch (m_type)
457 { 523 {
@@ -479,6 +545,21 @@ namespace addon
479 m_driverIndex = primitive.motor.index; 545 m_driverIndex = primitive.motor.index;
480 break; 546 break;
481 } 547 }
548 case JOYSTICK_DRIVER_PRIMITIVE_TYPE_KEY:
549 {
550 m_keycode = primitive.key.keycode;
551 break;
552 }
553 case JOYSTICK_DRIVER_PRIMITIVE_TYPE_MOUSE_BUTTON:
554 {
555 m_driverIndex = primitive.mouse.button;
556 break;
557 }
558 case JOYSTICK_DRIVER_PRIMITIVE_TYPE_RELPOINTER_DIRECTION:
559 {
560 m_relPointerDirection = primitive.relpointer.direction;
561 break;
562 }
482 default: 563 default:
483 break; 564 break;
484 } 565 }
@@ -490,6 +571,9 @@ namespace addon
490 int Center(void) const { return m_center; } 571 int Center(void) const { return m_center; }
491 JOYSTICK_DRIVER_SEMIAXIS_DIRECTION SemiAxisDirection(void) const { return m_semiAxisDirection; } 572 JOYSTICK_DRIVER_SEMIAXIS_DIRECTION SemiAxisDirection(void) const { return m_semiAxisDirection; }
492 unsigned int Range(void) const { return m_range; } 573 unsigned int Range(void) const { return m_range; }
574 const std::string& Keycode(void) const { return m_keycode; }
575 JOYSTICK_DRIVER_MOUSE_INDEX MouseIndex(void) const { return static_cast<JOYSTICK_DRIVER_MOUSE_INDEX>(m_driverIndex); }
576 JOYSTICK_DRIVER_RELPOINTER_DIRECTION RelPointerDirection(void) const { return m_relPointerDirection; }
493 577
494 bool operator==(const DriverPrimitive& other) const 578 bool operator==(const DriverPrimitive& other) const
495 { 579 {
@@ -498,7 +582,6 @@ namespace addon
498 switch (m_type) 582 switch (m_type)
499 { 583 {
500 case JOYSTICK_DRIVER_PRIMITIVE_TYPE_BUTTON: 584 case JOYSTICK_DRIVER_PRIMITIVE_TYPE_BUTTON:
501 case JOYSTICK_DRIVER_PRIMITIVE_TYPE_MOTOR:
502 { 585 {
503 return m_driverIndex == other.m_driverIndex; 586 return m_driverIndex == other.m_driverIndex;
504 } 587 }
@@ -514,6 +597,22 @@ namespace addon
514 m_semiAxisDirection == other.m_semiAxisDirection && 597 m_semiAxisDirection == other.m_semiAxisDirection &&
515 m_range == other.m_range; 598 m_range == other.m_range;
516 } 599 }
600 case JOYSTICK_DRIVER_PRIMITIVE_TYPE_KEY:
601 {
602 return m_keycode == other.m_keycode;
603 }
604 case JOYSTICK_DRIVER_PRIMITIVE_TYPE_MOTOR:
605 {
606 return m_driverIndex == other.m_driverIndex;
607 }
608 case JOYSTICK_DRIVER_PRIMITIVE_TYPE_MOUSE_BUTTON:
609 {
610 return m_driverIndex == other.m_driverIndex;
611 }
612 case JOYSTICK_DRIVER_PRIMITIVE_TYPE_RELPOINTER_DIRECTION:
613 {
614 return m_relPointerDirection == other.m_relPointerDirection;
615 }
517 default: 616 default:
518 break; 617 break;
519 } 618 }
@@ -550,6 +649,23 @@ namespace addon
550 driver_primitive.motor.index = m_driverIndex; 649 driver_primitive.motor.index = m_driverIndex;
551 break; 650 break;
552 } 651 }
652 case JOYSTICK_DRIVER_PRIMITIVE_TYPE_KEY:
653 {
654 const size_t size = sizeof(driver_primitive.key.keycode);
655 std::strncpy(driver_primitive.key.keycode, m_keycode.c_str(), size - 1);
656 driver_primitive.key.keycode[size - 1] = '\0';
657 break;
658 }
659 case JOYSTICK_DRIVER_PRIMITIVE_TYPE_MOUSE_BUTTON:
660 {
661 driver_primitive.mouse.button = static_cast<JOYSTICK_DRIVER_MOUSE_INDEX>(m_driverIndex);
662 break;
663 }
664 case JOYSTICK_DRIVER_PRIMITIVE_TYPE_RELPOINTER_DIRECTION:
665 {
666 driver_primitive.relpointer.direction = m_relPointerDirection;
667 break;
668 }
553 default: 669 default:
554 break; 670 break;
555 } 671 }
@@ -567,6 +683,8 @@ namespace addon
567 int m_center; 683 int m_center;
568 JOYSTICK_DRIVER_SEMIAXIS_DIRECTION m_semiAxisDirection; 684 JOYSTICK_DRIVER_SEMIAXIS_DIRECTION m_semiAxisDirection;
569 unsigned int m_range; 685 unsigned int m_range;
686 std::string m_keycode;
687 JOYSTICK_DRIVER_RELPOINTER_DIRECTION m_relPointerDirection;
570 }; 688 };
571 689
572 typedef PeripheralVector<DriverPrimitive, JOYSTICK_DRIVER_PRIMITIVE> DriverPrimitives; 690 typedef PeripheralVector<DriverPrimitive, JOYSTICK_DRIVER_PRIMITIVE> DriverPrimitives;
@@ -584,6 +702,7 @@ namespace addon
584 * 6) absolute pointer 702 * 6) absolute pointer
585 * 7) wheel 703 * 7) wheel
586 * 8) throttle 704 * 8) throttle
705 * 9) keyboard key
587 * 706 *
588 * [1] All three driver primitives (buttons, hats and axes) have a state that 707 * [1] All three driver primitives (buttons, hats and axes) have a state that
589 * can be represented using a single scalar value. For this reason, 708 * can be represented using a single scalar value. For this reason,
@@ -598,7 +717,7 @@ namespace addon
598 JoystickFeature(const std::string& name = "", JOYSTICK_FEATURE_TYPE type = JOYSTICK_FEATURE_TYPE_UNKNOWN) : 717 JoystickFeature(const std::string& name = "", JOYSTICK_FEATURE_TYPE type = JOYSTICK_FEATURE_TYPE_UNKNOWN) :
599 m_name(name), 718 m_name(name),
600 m_type(type), 719 m_type(type),
601 m_primitives() 720 m_primitives{}
602 { 721 {
603 } 722 }
604 723
@@ -672,4 +791,3 @@ namespace addon
672 791
673} /* namespace addon */ 792} /* namespace addon */
674} /* namespace kodi */ 793} /* namespace kodi */
675
diff --git a/xbmc/addons/kodi-addon-dev-kit/include/kodi/addon-instance/VFS.h b/xbmc/addons/kodi-addon-dev-kit/include/kodi/addon-instance/VFS.h
index 8e688d7..637a991 100644
--- a/xbmc/addons/kodi-addon-dev-kit/include/kodi/addon-instance/VFS.h
+++ b/xbmc/addons/kodi-addon-dev-kit/include/kodi/addon-instance/VFS.h
@@ -547,7 +547,7 @@ namespace addon
547 entries[i].properties = nullptr; 547 entries[i].properties = nullptr;
548 } 548 }
549 *retEntries = entries; 549 *retEntries = entries;
550 *num_entries = addonEntries.size(); 550 *num_entries = static_cast<int>(addonEntries.size());
551 } 551 }
552 return ret; 552 return ret;
553 } 553 }
@@ -586,7 +586,7 @@ namespace addon
586 strncpy(rootpath, cppRootPath.c_str(), ADDON_STANDARD_STRING_LENGTH); 586 strncpy(rootpath, cppRootPath.c_str(), ADDON_STANDARD_STRING_LENGTH);
587 587
588 VFSDirEntry* entries = static_cast<VFSDirEntry*>(malloc(sizeof(VFSDirEntry) * addonEntries.size())); 588 VFSDirEntry* entries = static_cast<VFSDirEntry*>(malloc(sizeof(VFSDirEntry) * addonEntries.size()));
589 for (unsigned int i = 0; i < addonEntries.size(); ++i) 589 for (size_t i = 0; i < addonEntries.size(); ++i)
590 { 590 {
591 entries[i].label = strdup(addonEntries[i].Label().c_str()); 591 entries[i].label = strdup(addonEntries[i].Label().c_str());
592 entries[i].title = strdup(addonEntries[i].Title().c_str()); 592 entries[i].title = strdup(addonEntries[i].Title().c_str());
@@ -610,7 +610,7 @@ namespace addon
610 entries[i].properties = nullptr; 610 entries[i].properties = nullptr;
611 } 611 }
612 *retEntries = entries; 612 *retEntries = entries;
613 *num_entries = addonEntries.size(); 613 *num_entries = static_cast<int>(addonEntries.size());
614 } 614 }
615 return ret; 615 return ret;
616 } 616 }
diff --git a/xbmc/addons/kodi-addon-dev-kit/include/kodi/addon-instance/VideoCodec.h b/xbmc/addons/kodi-addon-dev-kit/include/kodi/addon-instance/VideoCodec.h
index eb4351e..8a8779a 100644
--- a/xbmc/addons/kodi-addon-dev-kit/include/kodi/addon-instance/VideoCodec.h
+++ b/xbmc/addons/kodi-addon-dev-kit/include/kodi/addon-instance/VideoCodec.h
@@ -1,6 +1,6 @@
1/* 1/*
2 * Copyright (C) 2017 Team XBMC 2 * Copyright (C) 2017 Team XBMC
3 * http://xbmc.org 3 * http://kodi.tv
4 * 4 *
5 * This Program is free software; you can redistribute it and/or modify 5 * This Program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by 6 * it under the terms of the GNU General Public License as published by
diff --git a/xbmc/addons/kodi-addon-dev-kit/include/kodi/addon-instance/Visualization.h b/xbmc/addons/kodi-addon-dev-kit/include/kodi/addon-instance/Visualization.h
index 452085a..a2bef15 100644
--- a/xbmc/addons/kodi-addon-dev-kit/include/kodi/addon-instance/Visualization.h
+++ b/xbmc/addons/kodi-addon-dev-kit/include/kodi/addon-instance/Visualization.h
@@ -745,7 +745,7 @@ namespace addon
745 addon->toAddon.addonInstance->m_instanceData->toKodi.transfer_preset(addon->toKodi.kodiInstance, it.c_str()); 745 addon->toAddon.addonInstance->m_instanceData->toKodi.transfer_preset(addon->toKodi.kodiInstance, it.c_str());
746 } 746 }
747 747
748 return presets.size(); 748 return static_cast<unsigned int>(presets.size());
749 } 749 }
750 750
751 inline static int ADDON_GetActivePreset(const AddonInstance_Visualization* addon) 751 inline static int ADDON_GetActivePreset(const AddonInstance_Visualization* addon)
diff --git a/xbmc/addons/kodi-addon-dev-kit/include/kodi/kodi_game_dll.h b/xbmc/addons/kodi-addon-dev-kit/include/kodi/kodi_game_dll.h
index 4ce5bbc..79ca778 100644
--- a/xbmc/addons/kodi-addon-dev-kit/include/kodi/kodi_game_dll.h
+++ b/xbmc/addons/kodi-addon-dev-kit/include/kodi/kodi_game_dll.h
@@ -131,17 +131,6 @@ GAME_ERROR HwContextDestroy(void);
131// --- Input operations -------------------------------------------------------- 131// --- Input operations --------------------------------------------------------
132 132
133/*! 133/*!
134 * \brief Notify the add-on of a status change on an open port
135 *
136 * Ports can be opened using the OpenPort() callback
137 *
138 * \param port Non-negative for a joystick port, or GAME_INPUT_PORT value otherwise
139 * \param collected True if a controller was connected, false if disconnected
140 * \param controller The connected controller
141 */
142void UpdatePort(int port, bool connected, const game_controller* controller);
143
144/*!
145 * \brief Check if input is accepted for a feature on the controller 134 * \brief Check if input is accepted for a feature on the controller
146 * 135 *
147 * If only a subset of the controller profile is used, this can return false 136 * If only a subset of the controller profile is used, this can return false
@@ -156,6 +145,88 @@ void UpdatePort(int port, bool connected, const game_controller* controller);
156bool HasFeature(const char* controller_id, const char* feature_name); 145bool HasFeature(const char* controller_id, const char* feature_name);
157 146
158/*! 147/*!
148 * \brief Get the input topolgy that specifies which controllers can be connected
149 *
150 * \return The input topology, or null to use the default
151 *
152 * If this returns non-null, topology must be freed using FreeTopology().
153 *
154 * If this returns null, the topology will default to a single port that can
155 * accept all controllers imported by addon.xml. The port ID is set to
156 * the DEFAULT_PORT_ID constant.
157 */
158game_input_topology* GetTopology();
159
160/*!
161 * \brief Free the topology's resources
162 *
163 * \param topology The topology returned by GetTopology()
164 */
165void FreeTopology(game_input_topology* topology);
166
167/*!
168 * \brief Enable/disable keyboard input using the specified controller
169 *
170 * \param enable True to enable input, false otherwise
171 * \param controller The controller info if enabling, or unused if disabling
172 *
173 * \return True if keyboard input was enabled, false otherwise
174 */
175bool EnableKeyboard(bool enable, const game_controller* controller);
176
177/*!
178 * \brief Enable/disable mouse input using the specified controller
179 *
180 * \param enable True to enable input, false otherwise
181 * \param controller The controller info if enabling, or unused if disabling
182 *
183 * \return True if mouse input was enabled, false otherwise
184 */
185bool EnableMouse(bool enable, const game_controller* controller);
186
187/*!
188 * \brief Connect/disconnect a controller to a port on the virtual game console
189 *
190 * \param connect True to connect a controller, false to disconnect
191 * \param address The address of the port
192 * \param controller The controller info if connecting, or unused if disconnecting
193 *
194 * The address is a string that allows traversal of the controller topology.
195 * It is formed by alternating port IDs and controller IDs separated by "/".
196 *
197 * For example, assume that the topology represented in XML for Snes9x is:
198 *
199 * <logicaltopology>
200 * <port type="controller" id="1">
201 * <accepts controller="game.controller.snes"/>
202 * <accepts controller="game.controller.snes.multitap">
203 * <port type="controller" id="1">
204 * <accepts controller="game.controller.snes"/>
205 * </port>
206 * <port type="controller" id="2">
207 * <accepts controller="game.controller.snes"/>
208 * </port>
209 * ...
210 * </accepts>
211 * </port>
212 * </logicaltopology>
213 *
214 * To connect a multitap to the console's first port, the multitap's controller
215 * info is set using the port address:
216 *
217 * 1
218 *
219 * To connect a SNES controller to the second port of the multitap, the
220 * controller info is next set using the address:
221 *
222 * 1/game.controller.multitap/2
223 *
224 * Any attempts to connect a controller to a port on a disconnected multitap
225 * will return false.
226 */
227bool ConnectController(bool connect, const char* port_address, const game_controller* controller);
228
229/*!
159 * \brief Notify the add-on of an input event 230 * \brief Notify the add-on of an input event
160 * 231 *
161 * \param event The input event 232 * \param event The input event
@@ -247,8 +318,12 @@ void __declspec(dllexport) get_addon(void* ptr)
247 pClient->toAddon.Reset = Reset; 318 pClient->toAddon.Reset = Reset;
248 pClient->toAddon.HwContextReset = HwContextReset; 319 pClient->toAddon.HwContextReset = HwContextReset;
249 pClient->toAddon.HwContextDestroy = HwContextDestroy; 320 pClient->toAddon.HwContextDestroy = HwContextDestroy;
250 pClient->toAddon.UpdatePort = UpdatePort;
251 pClient->toAddon.HasFeature = HasFeature; 321 pClient->toAddon.HasFeature = HasFeature;
322 pClient->toAddon.GetTopology = GetTopology;
323 pClient->toAddon.FreeTopology = FreeTopology;
324 pClient->toAddon.EnableKeyboard = EnableKeyboard;
325 pClient->toAddon.EnableMouse = EnableMouse;
326 pClient->toAddon.ConnectController = ConnectController;
252 pClient->toAddon.InputEvent = InputEvent; 327 pClient->toAddon.InputEvent = InputEvent;
253 pClient->toAddon.SerializeSize = SerializeSize; 328 pClient->toAddon.SerializeSize = SerializeSize;
254 pClient->toAddon.Serialize = Serialize; 329 pClient->toAddon.Serialize = Serialize;
diff --git a/xbmc/addons/kodi-addon-dev-kit/include/kodi/kodi_game_types.h b/xbmc/addons/kodi-addon-dev-kit/include/kodi/kodi_game_types.h
index d4568e7..758b0fa 100644
--- a/xbmc/addons/kodi-addon-dev-kit/include/kodi/kodi_game_types.h
+++ b/xbmc/addons/kodi-addon-dev-kit/include/kodi/kodi_game_types.h
@@ -40,10 +40,8 @@
40#undef PRAGMA_PACK_END 40#undef PRAGMA_PACK_END
41 41
42#if defined(__GNUC__) 42#if defined(__GNUC__)
43 #if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 95) 43 #define ATTRIBUTE_PACKED __attribute__ ((packed))
44 #define ATTRIBUTE_PACKED __attribute__ ((packed)) 44 #define PRAGMA_PACK 0
45 #define PRAGMA_PACK 0
46 #endif
47#endif 45#endif
48 46
49#if !defined(ATTRIBUTE_PACKED) 47#if !defined(ATTRIBUTE_PACKED)
@@ -57,6 +55,9 @@
57#include "input/XBMC_vkeys.h" 55#include "input/XBMC_vkeys.h"
58#endif 56#endif
59 57
58/*! Port ID used when topology is unknown */
59#define DEFAULT_PORT_ID "1"
60
60#ifdef __cplusplus 61#ifdef __cplusplus
61extern "C" { 62extern "C" {
62#endif 63#endif
@@ -159,13 +160,6 @@ typedef enum GAME_HW_CONTEXT_TYPE
159 GAME_HW_CONTEXT_OPENGLES3, // GLES 3.0 160 GAME_HW_CONTEXT_OPENGLES3, // GLES 3.0
160} GAME_HW_CONTEXT_TYPE; 161} GAME_HW_CONTEXT_TYPE;
161 162
162typedef enum GAME_INPUT_PORT
163{
164 GAME_INPUT_PORT_JOYSTICK_START = 0, // Non-negative values are for joystick ports
165 GAME_INPUT_PORT_KEYBOARD = -1,
166 GAME_INPUT_PORT_MOUSE = -2,
167} GAME_INPUT_PORT;
168
169typedef enum GAME_INPUT_EVENT_SOURCE 163typedef enum GAME_INPUT_EVENT_SOURCE
170{ 164{
171 GAME_INPUT_EVENT_DIGITAL_BUTTON, 165 GAME_INPUT_EVENT_DIGITAL_BUTTON,
@@ -181,17 +175,17 @@ typedef enum GAME_INPUT_EVENT_SOURCE
181 175
182typedef enum GAME_KEY_MOD 176typedef enum GAME_KEY_MOD
183{ 177{
184 GAME_KEY_MOD_NONE = 0x00, 178 GAME_KEY_MOD_NONE = 0x0000,
185 179
186 GAME_KEY_MOD_SHIFT = 0x01, 180 GAME_KEY_MOD_SHIFT = 0x0001,
187 GAME_KEY_MOD_CTRL = 0x02, 181 GAME_KEY_MOD_CTRL = 0x0002,
188 GAME_KEY_MOD_ALT = 0x04, 182 GAME_KEY_MOD_ALT = 0x0004,
189 GAME_KEY_MOD_RALT = 0x08, 183 GAME_KEY_MOD_META = 0x0008,
190 GAME_KEY_MOD_META = 0x10, 184 GAME_KEY_MOD_SUPER = 0x0010,
191 185
192 GAME_KEY_MOD_NUMLOCK = 0x20, 186 GAME_KEY_MOD_NUMLOCK = 0x0100,
193 GAME_KEY_MOD_CAPSLOCK = 0x40, 187 GAME_KEY_MOD_CAPSLOCK = 0x0200,
194 GAME_KEY_MOD_SCROLLOCK = 0x80, 188 GAME_KEY_MOD_SCROLLOCK = 0x0400,
195} GAME_KEY_MOD; 189} GAME_KEY_MOD;
196 190
197/*! Returned from game_get_region() */ 191/*! Returned from game_get_region() */
@@ -203,9 +197,9 @@ typedef enum GAME_REGION
203} GAME_REGION; 197} GAME_REGION;
204 198
205/*! 199/*!
206* Special game types passed into game_load_game_special(). Only used when 200 * Special game types passed into game_load_game_special(). Only used when
207* multiple ROMs are required. 201 * multiple ROMs are required.
208*/ 202 */
209typedef enum SPECIAL_GAME_TYPE 203typedef enum SPECIAL_GAME_TYPE
210{ 204{
211 SPECIAL_GAME_TYPE_BSX, 205 SPECIAL_GAME_TYPE_BSX,
@@ -277,9 +271,21 @@ typedef enum GAME_ROTATION
277 GAME_ROTATION_270_CW, 271 GAME_ROTATION_270_CW,
278} GAME_ROTATION; 272} GAME_ROTATION;
279 273
274/*!
275 * \brief Type of port on the virtual game console
276 */
277typedef enum GAME_PORT_TYPE
278{
279 GAME_PORT_UNKNOWN,
280 GAME_PORT_KEYBOARD,
281 GAME_PORT_MOUSE,
282 GAME_PORT_CONTROLLER,
283} GAME_PORT_TYPE;
284
280typedef struct game_controller 285typedef struct game_controller
281{ 286{
282 const char* controller_id; 287 const char* controller_id;
288 bool provides_input; // False for multitaps
283 unsigned int digital_button_count; 289 unsigned int digital_button_count;
284 unsigned int analog_button_count; 290 unsigned int analog_button_count;
285 unsigned int analog_stick_count; 291 unsigned int analog_stick_count;
@@ -290,6 +296,48 @@ typedef struct game_controller
290 unsigned int motor_count; 296 unsigned int motor_count;
291} ATTRIBUTE_PACKED game_controller; 297} ATTRIBUTE_PACKED game_controller;
292 298
299struct game_input_port;
300
301/*!
302 * \brief Device that can provide input
303 */
304typedef struct game_input_device
305{
306 const char* controller_id; // ID used in the Kodi controller API
307 const char* port_address;
308 game_input_port* available_ports;
309 unsigned int port_count;
310} ATTRIBUTE_PACKED game_input_device;
311
312/*!
313 * \brief Port that can provide input
314 *
315 * Ports can accept multiple devices and devices can have multiple ports, so
316 * the topology of possible configurations is a tree structure of alternating
317 * port and device nodes.
318 */
319typedef struct game_input_port
320{
321 GAME_PORT_TYPE type;
322 const char* port_id; // Required for GAME_PORT_CONTROLLER type
323 game_input_device* accepted_devices;
324 unsigned int device_count;
325} ATTRIBUTE_PACKED game_input_port;
326
327/*!
328 * \brief The input topology is the possible ways to connect input devices
329 *
330 * This represents the logical topology, which is the possible connections that
331 * the game client's logic can handle. It is strictly a subset of the physical
332 * topology. Loops are not allowed.
333 */
334typedef struct game_input_topology
335{
336 game_input_port *ports; //! The list of ports on the virtual game console
337 unsigned int port_count; //! The number of ports
338 int player_limit; //! A limit on the number of input-providing devices, or -1 for no limit
339} ATTRIBUTE_PACKED game_input_topology;
340
293typedef struct game_digital_button_event 341typedef struct game_digital_button_event
294{ 342{
295 bool pressed; 343 bool pressed;
@@ -321,7 +369,14 @@ typedef struct game_accelerometer_event
321typedef struct game_key_event 369typedef struct game_key_event
322{ 370{
323 bool pressed; 371 bool pressed;
324 XBMCVKey character; 372
373 /*!
374 * If the keypress generates a printing character, the unicode value
375 * contains the character generated. If the key is a non-printing character,
376 * e.g. a function or arrow key, the unicode value is zero.
377 */
378 uint32_t unicode;
379
325 GAME_KEY_MOD modifiers; 380 GAME_KEY_MOD modifiers;
326} ATTRIBUTE_PACKED game_key_event; 381} ATTRIBUTE_PACKED game_key_event;
327 382
@@ -346,8 +401,9 @@ typedef struct game_motor_event
346typedef struct game_input_event 401typedef struct game_input_event
347{ 402{
348 GAME_INPUT_EVENT_SOURCE type; 403 GAME_INPUT_EVENT_SOURCE type;
349 int port;
350 const char* controller_id; 404 const char* controller_id;
405 GAME_PORT_TYPE port_type;
406 const char* port_address;
351 const char* feature_name; 407 const char* feature_name;
352 union 408 union
353 { 409 {
@@ -474,8 +530,6 @@ typedef struct AddonToKodiFuncTable_Game
474 uintptr_t (*HwGetCurrentFramebuffer)(void* kodiInstance); 530 uintptr_t (*HwGetCurrentFramebuffer)(void* kodiInstance);
475 game_proc_address_t (*HwGetProcAddress)(void* kodiInstance, const char* symbol); 531 game_proc_address_t (*HwGetProcAddress)(void* kodiInstance, const char* symbol);
476 void (*RenderFrame)(void* kodiInstance); 532 void (*RenderFrame)(void* kodiInstance);
477 bool (*OpenPort)(void* kodiInstance, unsigned int port);
478 void (*ClosePort)(void* kodiInstance, unsigned int port);
479 bool (*InputEvent)(void* kodiInstance, const game_input_event* event); 533 bool (*InputEvent)(void* kodiInstance, const game_input_event* event);
480 534
481} AddonToKodiFuncTable_Game; 535} AddonToKodiFuncTable_Game;
@@ -493,8 +547,12 @@ typedef struct KodiToAddonFuncTable_Game
493 GAME_ERROR (__cdecl* Reset)(void); 547 GAME_ERROR (__cdecl* Reset)(void);
494 GAME_ERROR (__cdecl* HwContextReset)(void); 548 GAME_ERROR (__cdecl* HwContextReset)(void);
495 GAME_ERROR (__cdecl* HwContextDestroy)(void); 549 GAME_ERROR (__cdecl* HwContextDestroy)(void);
496 void (__cdecl* UpdatePort)(int, bool, const game_controller*); 550 bool (__cdecl* HasFeature)(const char*, const char*);
497 bool (__cdecl* HasFeature)(const char* controller_id, const char* feature_name); 551 game_input_topology* (__cdecl* GetTopology)();
552 void (__cdecl* FreeTopology)(game_input_topology*);
553 bool (__cdecl* EnableKeyboard)(bool, const game_controller*);
554 bool (__cdecl* EnableMouse)(bool, const game_controller*);
555 bool (__cdecl* ConnectController)(bool, const char*, const game_controller*);
498 bool (__cdecl* InputEvent)(const game_input_event*); 556 bool (__cdecl* InputEvent)(const game_input_event*);
499 size_t (__cdecl* SerializeSize)(void); 557 size_t (__cdecl* SerializeSize)(void);
500 GAME_ERROR (__cdecl* Serialize)(uint8_t*, size_t); 558 GAME_ERROR (__cdecl* Serialize)(uint8_t*, size_t);
diff --git a/xbmc/addons/kodi-addon-dev-kit/include/kodi/libKODI_game.h b/xbmc/addons/kodi-addon-dev-kit/include/kodi/libKODI_game.h
index 1ca91a4..2774afd 100644
--- a/xbmc/addons/kodi-addon-dev-kit/include/kodi/libKODI_game.h
+++ b/xbmc/addons/kodi-addon-dev-kit/include/kodi/libKODI_game.h
@@ -188,28 +188,6 @@ public:
188 // --- Input callbacks ------------------------------------------------------- 188 // --- Input callbacks -------------------------------------------------------
189 189
190 /*! 190 /*!
191 * \brief Begin reporting events for the specified joystick port
192 *
193 * \param port The zero-indexed port number
194 *
195 * \return true if the port was opened, false otherwise
196 */
197 bool OpenPort(unsigned int port)
198 {
199 return m_callbacks->toKodi.OpenPort(m_callbacks->toKodi.kodiInstance, port);
200 }
201
202 /*!
203 * \brief End reporting events for the specified port
204 *
205 * \param port The port number passed to OpenPort()
206 */
207 void ClosePort(unsigned int port)
208 {
209 return m_callbacks->toKodi.ClosePort(m_callbacks->toKodi.kodiInstance, port);
210 }
211
212 /*!
213 * \brief Notify the port of an input event 191 * \brief Notify the port of an input event
214 * 192 *
215 * \param event The input event 193 * \param event The input event
diff --git a/xbmc/addons/kodi-addon-dev-kit/include/kodi/libKODI_guilib.h b/xbmc/addons/kodi-addon-dev-kit/include/kodi/libKODI_guilib.h
index c844c73..045d5fe 100644
--- a/xbmc/addons/kodi-addon-dev-kit/include/kodi/libKODI_guilib.h
+++ b/xbmc/addons/kodi-addon-dev-kit/include/kodi/libKODI_guilib.h
@@ -1,7 +1,7 @@
1#pragma once 1#pragma once
2/* 2/*
3 * Copyright (C) 2005-2013 Team XBMC 3 * Copyright (C) 2005-2013 Team XBMC
4 * http://xbmc.org 4 * http://kodi.tv
5 * 5 *
6 * This Program is free software; you can redistribute it and/or modify 6 * This Program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by 7 * it under the terms of the GNU General Public License as published by
diff --git a/xbmc/addons/kodi-addon-dev-kit/include/kodi/libXBMC_addon.h b/xbmc/addons/kodi-addon-dev-kit/include/kodi/libXBMC_addon.h
index 5ef6bdc..271df98 100644
--- a/xbmc/addons/kodi-addon-dev-kit/include/kodi/libXBMC_addon.h
+++ b/xbmc/addons/kodi-addon-dev-kit/include/kodi/libXBMC_addon.h
@@ -1,7 +1,7 @@
1#pragma once 1#pragma once
2/* 2/*
3 * Copyright (C) 2005-2013 Team XBMC 3 * Copyright (C) 2005-2013 Team XBMC
4 * http://xbmc.org 4 * http://kodi.tv
5 * 5 *
6 * This Program is free software; you can redistribute it and/or modify 6 * This Program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by 7 * it under the terms of the GNU General Public License as published by
@@ -71,8 +71,6 @@ typedef void* (*KODIGUILib_RegisterMe)(void *addonData);
71typedef void (*KODIGUILib_UnRegisterMe)(void *addonData, void *cbTable); 71typedef void (*KODIGUILib_UnRegisterMe)(void *addonData, void *cbTable);
72typedef void* (*KODIPVRLib_RegisterMe)(void *addonData); 72typedef void* (*KODIPVRLib_RegisterMe)(void *addonData);
73typedef void (*KODIPVRLib_UnRegisterMe)(void *addonData, void *cbTable); 73typedef void (*KODIPVRLib_UnRegisterMe)(void *addonData, void *cbTable);
74typedef void* (*KODIADSPLib_RegisterMe)(void *addonData);
75typedef void (*KODIADSPLib_UnRegisterMe)(void *addonData, void *cbTable);
76typedef void* (*KODICodecLib_RegisterMe)(void *addonData); 74typedef void* (*KODICodecLib_RegisterMe)(void *addonData);
77typedef void (*KODICodecLib_UnRegisterMe)(void *addonData, void *cbTable); 75typedef void (*KODICodecLib_UnRegisterMe)(void *addonData, void *cbTable);
78typedef void* (*KODIINPUTSTREAMLib_RegisterMe)(void *addonData); 76typedef void* (*KODIINPUTSTREAMLib_RegisterMe)(void *addonData);
@@ -96,8 +94,6 @@ typedef struct AddonCB
96 KODIGUILib_UnRegisterMe GUILib_UnRegisterMe; 94 KODIGUILib_UnRegisterMe GUILib_UnRegisterMe;
97 KODIPVRLib_RegisterMe PVRLib_RegisterMe; 95 KODIPVRLib_RegisterMe PVRLib_RegisterMe;
98 KODIPVRLib_UnRegisterMe PVRLib_UnRegisterMe; 96 KODIPVRLib_UnRegisterMe PVRLib_UnRegisterMe;
99 KODIADSPLib_RegisterMe ADSPLib_RegisterMe;
100 KODIADSPLib_UnRegisterMe ADSPLib_UnRegisterMe;
101 KODIINPUTSTREAMLib_RegisterMe INPUTSTREAMLib_RegisterMe; 97 KODIINPUTSTREAMLib_RegisterMe INPUTSTREAMLib_RegisterMe;
102 KODIINPUTSTREAMLib_UnRegisterMe INPUTSTREAMLib_UnRegisterMe; 98 KODIINPUTSTREAMLib_UnRegisterMe INPUTSTREAMLib_UnRegisterMe;
103 KODIPeripheralLib_RegisterMe PeripheralLib_RegisterMe; 99 KODIPeripheralLib_RegisterMe PeripheralLib_RegisterMe;
diff --git a/xbmc/addons/kodi-addon-dev-kit/include/kodi/libXBMC_pvr.h b/xbmc/addons/kodi-addon-dev-kit/include/kodi/libXBMC_pvr.h
index f470566..11ea50c 100644
--- a/xbmc/addons/kodi-addon-dev-kit/include/kodi/libXBMC_pvr.h
+++ b/xbmc/addons/kodi-addon-dev-kit/include/kodi/libXBMC_pvr.h
@@ -1,7 +1,7 @@
1#pragma once 1#pragma once
2/* 2/*
3 * Copyright (C) 2005-2013 Team XBMC 3 * Copyright (C) 2005-2013 Team XBMC
4 * http://xbmc.org 4 * http://kodi.tv
5 * 5 *
6 * This Program is free software; you can redistribute it and/or modify 6 * This Program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by 7 * it under the terms of the GNU General Public License as published by
diff --git a/xbmc/addons/kodi-addon-dev-kit/include/kodi/platform/android/System.h b/xbmc/addons/kodi-addon-dev-kit/include/kodi/platform/android/System.h
new file mode 100644
index 0000000..bee00ef
--- /dev/null
+++ b/xbmc/addons/kodi-addon-dev-kit/include/kodi/platform/android/System.h
@@ -0,0 +1,107 @@
1#pragma once
2/*
3 * Copyright (C) 2005-2018 Team Kodi
4 * http://kodi.tv
5 *
6 * This Program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2, or (at your option)
9 * any later version.
10 *
11 * This Program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with KODI; see the file COPYING. If not, see
18 * <http://www.gnu.org/licenses/>.
19 *
20 */
21
22#include "../../AddonBase.h"
23
24/*
25 * For interface between add-on and kodi.
26 *
27 * This structure defines the addresses of functions stored inside Kodi which
28 * are then available for the add-on to call
29 *
30 * All function pointers there are used by the C++ interface functions below.
31 * You find the set of them on xbmc/addons/interfaces/General.cpp
32 *
33 * Note: For add-on development itself this is not needed
34 */
35
36static const char* INTERFACE_ANDROID_SYSTEM_NAME = "ANDROID_SYSTEM";
37static const char* INTERFACE_ANDROID_SYSTEM_VERSION = "1.0.0";
38static const char* INTERFACE_ANDROID_SYSTEM_VERSION_MIN = "1.0.0";
39
40struct AddonToKodiFuncTable_android_system
41{
42 void* (*get_jni_env)();
43 int (*get_sdk_version)();
44};
45
46//==============================================================================
47///
48/// \defgroup cpp_kodi_platform Interface - kodi::platform
49/// \ingroup cpp
50/// @brief **Android platform specific functions**
51///
52/// #include <kodi/platform/android/System.h>"
53///
54//------------------------------------------------------------------------------
55
56namespace kodi
57{
58namespace platform
59{
60 class CInterfaceAndroidSystem
61 {
62 public:
63 CInterfaceAndroidSystem()
64 : m_interface(static_cast<AddonToKodiFuncTable_android_system*>(GetInterface(INTERFACE_ANDROID_SYSTEM_NAME, INTERFACE_ANDROID_SYSTEM_VERSION)))
65 {};
66
67 //============================================================================
68 ///
69 /// \ingroup cpp_kodi_platform
70 /// @brief request an JNI env pointer for the calling thread.
71 /// JNI env has to be controlled by kodi because of the underlying
72 /// threading concep.
73 ///
74 /// @param[in]:
75 /// @return JNI env pointer for the calling thread
76 ///
77 inline void * GetJNIEnv()
78 {
79 if (m_interface)
80 return m_interface->get_jni_env();
81
82 return nullptr;
83 }
84 //----------------------------------------------------------------------------
85
86 //============================================================================
87 ///
88 /// \ingroup cpp_kodi_platform
89 /// @brief request the android sdk version to e.g. initialize JNIBase.
90 ///
91 /// @param[in]:
92 /// @return Android SDK version
93 ///
94 inline int GetSDKVersion()
95 {
96 if (m_interface)
97 return m_interface->get_sdk_version();
98
99 return 0;
100 }
101
102 private:
103 AddonToKodiFuncTable_android_system *m_interface;
104 };
105 //----------------------------------------------------------------------------
106} /* namespace platform */
107} /* namespace kodi */
diff --git a/xbmc/addons/kodi-addon-dev-kit/include/kodi/versions.h b/xbmc/addons/kodi-addon-dev-kit/include/kodi/versions.h
index db8508e..b61cb35 100644
--- a/xbmc/addons/kodi-addon-dev-kit/include/kodi/versions.h
+++ b/xbmc/addons/kodi-addon-dev-kit/include/kodi/versions.h
@@ -41,7 +41,7 @@
41 * overview. 41 * overview.
42 */ 42 */
43 43
44#define ADDON_GLOBAL_VERSION_MAIN "1.0.12" 44#define ADDON_GLOBAL_VERSION_MAIN "1.0.13"
45#define ADDON_GLOBAL_VERSION_MAIN_MIN "1.0.12" 45#define ADDON_GLOBAL_VERSION_MAIN_MIN "1.0.12"
46#define ADDON_GLOBAL_VERSION_MAIN_XML_ID "kodi.binary.global.main" 46#define ADDON_GLOBAL_VERSION_MAIN_XML_ID "kodi.binary.global.main"
47#define ADDON_GLOBAL_VERSION_MAIN_DEPENDS "AddonBase.h" \ 47#define ADDON_GLOBAL_VERSION_MAIN_DEPENDS "AddonBase.h" \
@@ -76,11 +76,6 @@
76#define ADDON_GLOBAL_VERSION_NETWORK_XML_ID "kodi.binary.global.network" 76#define ADDON_GLOBAL_VERSION_NETWORK_XML_ID "kodi.binary.global.network"
77#define ADDON_GLOBAL_VERSION_NETWORK_DEPENDS "Network.h" 77#define ADDON_GLOBAL_VERSION_NETWORK_DEPENDS "Network.h"
78 78
79#define ADDON_INSTANCE_VERSION_ADSP "0.2.0"
80#define ADDON_INSTANCE_VERSION_ADSP_MIN "0.2.0"
81#define ADDON_INSTANCE_VERSION_ADSP_XML_ID "kodi.binary.instance.adsp"
82#define ADDON_INSTANCE_VERSION_ADSP_DEPENDS "addon-instance/AudioDSP.h"
83
84#define ADDON_INSTANCE_VERSION_AUDIODECODER "2.0.0" 79#define ADDON_INSTANCE_VERSION_AUDIODECODER "2.0.0"
85#define ADDON_INSTANCE_VERSION_AUDIODECODER_MIN "2.0.0" 80#define ADDON_INSTANCE_VERSION_AUDIODECODER_MIN "2.0.0"
86#define ADDON_INSTANCE_VERSION_AUDIODECODER_XML_ID "kodi.binary.instance.audiodecoder" 81#define ADDON_INSTANCE_VERSION_AUDIODECODER_XML_ID "kodi.binary.instance.audiodecoder"
@@ -91,8 +86,8 @@
91#define ADDON_INSTANCE_VERSION_AUDIOENCODER_XML_ID "kodi.binary.instance.audioencoder" 86#define ADDON_INSTANCE_VERSION_AUDIOENCODER_XML_ID "kodi.binary.instance.audioencoder"
92#define ADDON_INSTANCE_VERSION_AUDIOENCODER_DEPENDS "addon-instance/AudioEncoder.h" 87#define ADDON_INSTANCE_VERSION_AUDIOENCODER_DEPENDS "addon-instance/AudioEncoder.h"
93 88
94#define ADDON_INSTANCE_VERSION_GAME "1.0.33" 89#define ADDON_INSTANCE_VERSION_GAME "1.0.36"
95#define ADDON_INSTANCE_VERSION_GAME_MIN "1.0.33" 90#define ADDON_INSTANCE_VERSION_GAME_MIN "1.0.36"
96#define ADDON_INSTANCE_VERSION_GAME_XML_ID "kodi.binary.instance.game" 91#define ADDON_INSTANCE_VERSION_GAME_XML_ID "kodi.binary.instance.game"
97#define ADDON_INSTANCE_VERSION_GAME_DEPENDS "kodi_game_dll.h" \ 92#define ADDON_INSTANCE_VERSION_GAME_DEPENDS "kodi_game_dll.h" \
98 "kodi_game_types.h" \ 93 "kodi_game_types.h" \
@@ -108,14 +103,14 @@
108#define ADDON_INSTANCE_VERSION_INPUTSTREAM_XML_ID "kodi.binary.instance.inputstream" 103#define ADDON_INSTANCE_VERSION_INPUTSTREAM_XML_ID "kodi.binary.instance.inputstream"
109#define ADDON_INSTANCE_VERSION_INPUTSTREAM_DEPENDS "addon-instance/Inputstream.h" 104#define ADDON_INSTANCE_VERSION_INPUTSTREAM_DEPENDS "addon-instance/Inputstream.h"
110 105
111#define ADDON_INSTANCE_VERSION_PERIPHERAL "1.3.5" 106#define ADDON_INSTANCE_VERSION_PERIPHERAL "1.3.7"
112#define ADDON_INSTANCE_VERSION_PERIPHERAL_MIN "1.3.4" 107#define ADDON_INSTANCE_VERSION_PERIPHERAL_MIN "1.3.4"
113#define ADDON_INSTANCE_VERSION_PERIPHERAL_XML_ID "kodi.binary.instance.peripheral" 108#define ADDON_INSTANCE_VERSION_PERIPHERAL_XML_ID "kodi.binary.instance.peripheral"
114#define ADDON_INSTANCE_VERSION_PERIPHERAL_DEPENDS "addon-instance/Peripheral.h" \ 109#define ADDON_INSTANCE_VERSION_PERIPHERAL_DEPENDS "addon-instance/Peripheral.h" \
115 "addon-instance/PeripheralUtils.h" 110 "addon-instance/PeripheralUtils.h"
116 111
117#define ADDON_INSTANCE_VERSION_PVR "5.8.0" 112#define ADDON_INSTANCE_VERSION_PVR "5.9.0"
118#define ADDON_INSTANCE_VERSION_PVR_MIN "5.8.0" 113#define ADDON_INSTANCE_VERSION_PVR_MIN "5.9.0"
119#define ADDON_INSTANCE_VERSION_PVR_XML_ID "kodi.binary.instance.pvr" 114#define ADDON_INSTANCE_VERSION_PVR_XML_ID "kodi.binary.instance.pvr"
120#define ADDON_INSTANCE_VERSION_PVR_DEPENDS "xbmc_pvr_dll.h" \ 115#define ADDON_INSTANCE_VERSION_PVR_DEPENDS "xbmc_pvr_dll.h" \
121 "xbmc_pvr_types.h" \ 116 "xbmc_pvr_types.h" \
@@ -164,7 +159,6 @@ typedef enum ADDON_TYPE
164 ADDON_GLOBAL_MAX = 5, // Last used global id, used in loops to check versions. Need to change if new global type becomes added. 159 ADDON_GLOBAL_MAX = 5, // Last used global id, used in loops to check versions. Need to change if new global type becomes added.
165 160
166 /* addon type instances */ 161 /* addon type instances */
167 ADDON_INSTANCE_ADSP = 101,
168 ADDON_INSTANCE_AUDIODECODER = 102, 162 ADDON_INSTANCE_AUDIODECODER = 102,
169 ADDON_INSTANCE_AUDIOENCODER = 103, 163 ADDON_INSTANCE_AUDIOENCODER = 103,
170 ADDON_INSTANCE_GAME = 104, 164 ADDON_INSTANCE_GAME = 104,
@@ -224,10 +218,6 @@ inline const char* GetTypeVersion(int type)
224#endif 218#endif
225 219
226 /* addon type instances */ 220 /* addon type instances */
227#if !defined(BUILD_KODI_ADDON) || defined(ADDON_INSTANCE_VERSION_ADSP_USED)
228 case ADDON_INSTANCE_ADSP:
229 return ADDON_INSTANCE_VERSION_ADSP;
230#endif
231#if !defined(BUILD_KODI_ADDON) || defined(ADDON_INSTANCE_VERSION_AUDIODECODER_USED) 221#if !defined(BUILD_KODI_ADDON) || defined(ADDON_INSTANCE_VERSION_AUDIODECODER_USED)
232 case ADDON_INSTANCE_AUDIODECODER: 222 case ADDON_INSTANCE_AUDIODECODER:
233 return ADDON_INSTANCE_VERSION_AUDIODECODER; 223 return ADDON_INSTANCE_VERSION_AUDIODECODER;
@@ -303,8 +293,6 @@ inline const char* GetTypeMinVersion(int type)
303 return ADDON_GLOBAL_VERSION_NETWORK_MIN; 293 return ADDON_GLOBAL_VERSION_NETWORK_MIN;
304 294
305 /* addon type instances */ 295 /* addon type instances */
306 case ADDON_INSTANCE_ADSP:
307 return ADDON_INSTANCE_VERSION_ADSP_MIN;
308 case ADDON_INSTANCE_AUDIODECODER: 296 case ADDON_INSTANCE_AUDIODECODER:
309 return ADDON_INSTANCE_VERSION_AUDIODECODER_MIN; 297 return ADDON_INSTANCE_VERSION_AUDIODECODER_MIN;
310 case ADDON_INSTANCE_AUDIOENCODER: 298 case ADDON_INSTANCE_AUDIOENCODER:
@@ -357,8 +345,6 @@ inline const char* GetTypeName(int type)
357 return "Network"; 345 return "Network";
358 346
359 /* addon type instances */ 347 /* addon type instances */
360 case ADDON_INSTANCE_ADSP:
361 return "ADSP";
362 case ADDON_INSTANCE_AUDIODECODER: 348 case ADDON_INSTANCE_AUDIODECODER:
363 return "AudioDecoder"; 349 return "AudioDecoder";
364 case ADDON_INSTANCE_AUDIOENCODER: 350 case ADDON_INSTANCE_AUDIOENCODER:
@@ -408,8 +394,6 @@ inline int GetTypeId(const char* name)
408 return ADDON_GLOBAL_FILESYSTEM; 394 return ADDON_GLOBAL_FILESYSTEM;
409 else if (strcmp(name, "network") == 0) 395 else if (strcmp(name, "network") == 0)
410 return ADDON_GLOBAL_NETWORK; 396 return ADDON_GLOBAL_NETWORK;
411 else if (strcmp(name, "adsp") == 0)
412 return ADDON_INSTANCE_ADSP;
413 else if (strcmp(name, "audiodecoder") == 0) 397 else if (strcmp(name, "audiodecoder") == 0)
414 return ADDON_INSTANCE_AUDIODECODER; 398 return ADDON_INSTANCE_AUDIODECODER;
415 else if (strcmp(name, "audioencoder") == 0) 399 else if (strcmp(name, "audioencoder") == 0)
diff --git a/xbmc/addons/kodi-addon-dev-kit/include/kodi/xbmc_epg_types.h b/xbmc/addons/kodi-addon-dev-kit/include/kodi/xbmc_epg_types.h
index 1ba12bd..c0a900b 100644
--- a/xbmc/addons/kodi-addon-dev-kit/include/kodi/xbmc_epg_types.h
+++ b/xbmc/addons/kodi-addon-dev-kit/include/kodi/xbmc_epg_types.h
@@ -1,7 +1,7 @@
1#pragma once 1#pragma once
2/* 2/*
3 * Copyright (C) 2005-2013 Team XBMC 3 * Copyright (C) 2005-2013 Team XBMC
4 * http://xbmc.org 4 * http://kodi.tv
5 * 5 *
6 * This Program is free software; you can redistribute it and/or modify 6 * This Program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by 7 * it under the terms of the GNU General Public License as published by
@@ -27,11 +27,9 @@
27#undef PRAGMA_PACK_END 27#undef PRAGMA_PACK_END
28 28
29#if defined(__GNUC__) 29#if defined(__GNUC__)
30#if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 95)
31#define ATTRIBUTE_PACKED __attribute__ ((packed)) 30#define ATTRIBUTE_PACKED __attribute__ ((packed))
32#define PRAGMA_PACK 0 31#define PRAGMA_PACK 0
33#endif 32#endif
34#endif
35 33
36#if !defined(ATTRIBUTE_PACKED) 34#if !defined(ATTRIBUTE_PACKED)
37#define ATTRIBUTE_PACKED 35#define ATTRIBUTE_PACKED
diff --git a/xbmc/addons/kodi-addon-dev-kit/include/kodi/xbmc_pvr_dll.h b/xbmc/addons/kodi-addon-dev-kit/include/kodi/xbmc_pvr_dll.h
index 25cacb4..d36effa 100644
--- a/xbmc/addons/kodi-addon-dev-kit/include/kodi/xbmc_pvr_dll.h
+++ b/xbmc/addons/kodi-addon-dev-kit/include/kodi/xbmc_pvr_dll.h
@@ -115,6 +115,16 @@ extern "C"
115 * @remarks Required if add-on supports playing epg tags. Return PVR_ERROR_NOT_IMPLEMENTED if this add-on won't provide this function. 115 * @remarks Required if add-on supports playing epg tags. Return PVR_ERROR_NOT_IMPLEMENTED if this add-on won't provide this function.
116 */ 116 */
117 PVR_ERROR IsEPGTagPlayable(const EPG_TAG* tag, bool* bIsPlayable); 117 PVR_ERROR IsEPGTagPlayable(const EPG_TAG* tag, bool* bIsPlayable);
118
119 /*!
120 * Retrieve the edit decision list (EDL) of an EPG tag on the backend.
121 * @param epgTag The EPG tag.
122 * @param edl out: The function has to write the EDL list into this array.
123 * @param size in: The maximum size of the EDL, out: the actual size of the EDL.
124 * @return PVR_ERROR_NO_ERROR if the EDL was successfully read.
125 * @remarks Required if bSupportsEpgEdl is set to true. Return PVR_ERROR_NOT_IMPLEMENTED if this add-on won't provide this function.
126 */
127 PVR_ERROR GetEPGTagEdl(const EPG_TAG* epgTag, PVR_EDL_ENTRY edl[], int *size);
118 128
119 /*! 129 /*!
120 * Get the stream properties for an epg tag from the backend. 130 * Get the stream properties for an epg tag from the backend.
@@ -324,7 +334,7 @@ extern "C"
324 * @return PVR_ERROR_NO_ERROR if the EDL was successfully read. 334 * @return PVR_ERROR_NO_ERROR if the EDL was successfully read.
325 * @remarks Required if bSupportsRecordingEdl is set to true. Return PVR_ERROR_NOT_IMPLEMENTED if this add-on won't provide this function. 335 * @remarks Required if bSupportsRecordingEdl is set to true. Return PVR_ERROR_NOT_IMPLEMENTED if this add-on won't provide this function.
326 */ 336 */
327 PVR_ERROR GetRecordingEdl(const PVR_RECORDING&, PVR_EDL_ENTRY edl[], int *size); 337 PVR_ERROR GetRecordingEdl(const PVR_RECORDING& recording, PVR_EDL_ENTRY edl[], int *size);
328 338
329 /*! 339 /*!
330 * Retrieve the timer types supported by the backend. 340 * Retrieve the timer types supported by the backend.
@@ -650,6 +660,7 @@ extern "C"
650 pClient->toAddon.GetEPGForChannel = GetEPGForChannel; 660 pClient->toAddon.GetEPGForChannel = GetEPGForChannel;
651 pClient->toAddon.IsEPGTagRecordable = IsEPGTagRecordable; 661 pClient->toAddon.IsEPGTagRecordable = IsEPGTagRecordable;
652 pClient->toAddon.IsEPGTagPlayable = IsEPGTagPlayable; 662 pClient->toAddon.IsEPGTagPlayable = IsEPGTagPlayable;
663 pClient->toAddon.GetEPGTagEdl = GetEPGTagEdl;
653 pClient->toAddon.GetEPGTagStreamProperties = GetEPGTagStreamProperties; 664 pClient->toAddon.GetEPGTagStreamProperties = GetEPGTagStreamProperties;
654 665
655 pClient->toAddon.GetChannelGroupsAmount = GetChannelGroupsAmount; 666 pClient->toAddon.GetChannelGroupsAmount = GetChannelGroupsAmount;
diff --git a/xbmc/addons/kodi-addon-dev-kit/include/kodi/xbmc_pvr_types.h b/xbmc/addons/kodi-addon-dev-kit/include/kodi/xbmc_pvr_types.h
index 623cb03..32303d4 100644
--- a/xbmc/addons/kodi-addon-dev-kit/include/kodi/xbmc_pvr_types.h
+++ b/xbmc/addons/kodi-addon-dev-kit/include/kodi/xbmc_pvr_types.h
@@ -50,11 +50,9 @@ struct DemuxPacket;
50#undef PRAGMA_PACK_END 50#undef PRAGMA_PACK_END
51 51
52#if defined(__GNUC__) 52#if defined(__GNUC__)
53#if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 95)
54#define ATTRIBUTE_PACKED __attribute__ ((packed)) 53#define ATTRIBUTE_PACKED __attribute__ ((packed))
55#define PRAGMA_PACK 0 54#define PRAGMA_PACK 0
56#endif 55#endif
57#endif
58 56
59#if !defined(ATTRIBUTE_PACKED) 57#if !defined(ATTRIBUTE_PACKED)
60#define ATTRIBUTE_PACKED 58#define ATTRIBUTE_PACKED
@@ -305,6 +303,7 @@ extern "C" {
305 typedef struct PVR_ADDON_CAPABILITIES 303 typedef struct PVR_ADDON_CAPABILITIES
306 { 304 {
307 bool bSupportsEPG; /*!< @brief true if the add-on provides EPG information */ 305 bool bSupportsEPG; /*!< @brief true if the add-on provides EPG information */
306 bool bSupportsEPGEdl; /*!< @brief true if the backend supports retrieving an edit decision list for an EPG tag. */
308 bool bSupportsTV; /*!< @brief true if this add-on provides TV channels */ 307 bool bSupportsTV; /*!< @brief true if this add-on provides TV channels */
309 bool bSupportsRadio; /*!< @brief true if this add-on supports radio channels */ 308 bool bSupportsRadio; /*!< @brief true if this add-on supports radio channels */
310 bool bSupportsRecordings; /*!< @brief true if this add-on supports playback of recordings stored on the backend */ 309 bool bSupportsRecordings; /*!< @brief true if this add-on supports playback of recordings stored on the backend */
@@ -645,6 +644,7 @@ extern "C" {
645 PVR_ERROR (__cdecl* GetEPGForChannel)(ADDON_HANDLE, const PVR_CHANNEL&, time_t, time_t); 644 PVR_ERROR (__cdecl* GetEPGForChannel)(ADDON_HANDLE, const PVR_CHANNEL&, time_t, time_t);
646 PVR_ERROR (__cdecl* IsEPGTagRecordable)(const EPG_TAG*, bool*); 645 PVR_ERROR (__cdecl* IsEPGTagRecordable)(const EPG_TAG*, bool*);
647 PVR_ERROR (__cdecl* IsEPGTagPlayable)(const EPG_TAG*, bool*); 646 PVR_ERROR (__cdecl* IsEPGTagPlayable)(const EPG_TAG*, bool*);
647 PVR_ERROR (__cdecl* GetEPGTagEdl)(const EPG_TAG*, PVR_EDL_ENTRY[], int*);
648 PVR_ERROR (__cdecl* GetEPGTagStreamProperties)(const EPG_TAG*, PVR_NAMED_VALUE*, unsigned int*); 648 PVR_ERROR (__cdecl* GetEPGTagStreamProperties)(const EPG_TAG*, PVR_NAMED_VALUE*, unsigned int*);
649 int (__cdecl* GetChannelGroupsAmount)(void); 649 int (__cdecl* GetChannelGroupsAmount)(void);
650 PVR_ERROR (__cdecl* GetChannelGroups)(ADDON_HANDLE, bool); 650 PVR_ERROR (__cdecl* GetChannelGroups)(ADDON_HANDLE, bool);