summaryrefslogtreecommitdiffstats
path: root/xbmc/addons/kodi-addon-dev-kit/include/kodi/addon-instance
diff options
context:
space:
mode:
authormanuel <manuel@mausz.at>2018-04-17 00:15:38 +0200
committermanuel <manuel@mausz.at>2018-04-17 00:15:38 +0200
commitb3d195f0188758a14875a5a2f270e4fd190a679f (patch)
treecbe6a2d51afd7be095e29fd612107044cf1f391e /xbmc/addons/kodi-addon-dev-kit/include/kodi/addon-instance
parenta51f51db67e3eab80ac2ed28d403a6d77f7acc45 (diff)
downloadkodi-pvr-build-b3d195f0188758a14875a5a2f270e4fd190a679f.tar.gz
kodi-pvr-build-b3d195f0188758a14875a5a2f270e4fd190a679f.tar.bz2
kodi-pvr-build-b3d195f0188758a14875a5a2f270e4fd190a679f.zip
sync with upstream
Diffstat (limited to 'xbmc/addons/kodi-addon-dev-kit/include/kodi/addon-instance')
-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
7 files changed, 330 insertions, 1353 deletions
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)