summaryrefslogtreecommitdiffstats
path: root/xbmc/addons/kodi-dev-kit/include/kodi
diff options
context:
space:
mode:
Diffstat (limited to 'xbmc/addons/kodi-dev-kit/include/kodi')
-rw-r--r--xbmc/addons/kodi-dev-kit/include/kodi/AddonBase.h1322
-rw-r--r--xbmc/addons/kodi-dev-kit/include/kodi/AudioEngine.h619
-rw-r--r--xbmc/addons/kodi-dev-kit/include/kodi/CMakeLists.txt16
-rw-r--r--xbmc/addons/kodi-dev-kit/include/kodi/Filesystem.h2367
-rw-r--r--xbmc/addons/kodi-dev-kit/include/kodi/General.h834
-rw-r--r--xbmc/addons/kodi-dev-kit/include/kodi/Network.h282
-rw-r--r--xbmc/addons/kodi-dev-kit/include/kodi/StreamCodec.h126
-rw-r--r--xbmc/addons/kodi-dev-kit/include/kodi/StreamCrypto.h42
-rw-r--r--xbmc/addons/kodi-dev-kit/include/kodi/addon-instance/AudioDecoder.h595
-rw-r--r--xbmc/addons/kodi-dev-kit/include/kodi/addon-instance/AudioEncoder.h353
-rw-r--r--xbmc/addons/kodi-dev-kit/include/kodi/addon-instance/CMakeLists.txt15
-rw-r--r--xbmc/addons/kodi-dev-kit/include/kodi/addon-instance/Game.h1190
-rw-r--r--xbmc/addons/kodi-dev-kit/include/kodi/addon-instance/ImageDecoder.h315
-rw-r--r--xbmc/addons/kodi-dev-kit/include/kodi/addon-instance/Inputstream.h934
-rw-r--r--xbmc/addons/kodi-dev-kit/include/kodi/addon-instance/PVR.h3423
-rw-r--r--xbmc/addons/kodi-dev-kit/include/kodi/addon-instance/Peripheral.h907
-rw-r--r--xbmc/addons/kodi-dev-kit/include/kodi/addon-instance/Screensaver.h470
-rw-r--r--xbmc/addons/kodi-dev-kit/include/kodi/addon-instance/VFS.h1226
-rw-r--r--xbmc/addons/kodi-dev-kit/include/kodi/addon-instance/VideoCodec.h249
-rw-r--r--xbmc/addons/kodi-dev-kit/include/kodi/addon-instance/Visualization.h992
-rw-r--r--xbmc/addons/kodi-dev-kit/include/kodi/addon-instance/peripheral/CMakeLists.txt5
-rw-r--r--xbmc/addons/kodi-dev-kit/include/kodi/addon-instance/peripheral/PeripheralUtils.h1277
-rw-r--r--xbmc/addons/kodi-dev-kit/include/kodi/addon-instance/pvr/CMakeLists.txt13
-rw-r--r--xbmc/addons/kodi-dev-kit/include/kodi/addon-instance/pvr/ChannelGroups.h271
-rw-r--r--xbmc/addons/kodi-dev-kit/include/kodi/addon-instance/pvr/Channels.h518
-rw-r--r--xbmc/addons/kodi-dev-kit/include/kodi/addon-instance/pvr/EDL.h90
-rw-r--r--xbmc/addons/kodi-dev-kit/include/kodi/addon-instance/pvr/EPG.h500
-rw-r--r--xbmc/addons/kodi-dev-kit/include/kodi/addon-instance/pvr/General.h511
-rw-r--r--xbmc/addons/kodi-dev-kit/include/kodi/addon-instance/pvr/MenuHook.h130
-rw-r--r--xbmc/addons/kodi-dev-kit/include/kodi/addon-instance/pvr/Recordings.h520
-rw-r--r--xbmc/addons/kodi-dev-kit/include/kodi/addon-instance/pvr/Stream.h330
-rw-r--r--xbmc/addons/kodi-dev-kit/include/kodi/addon-instance/pvr/Timers.h896
-rw-r--r--xbmc/addons/kodi-dev-kit/include/kodi/c-api/CMakeLists.txt13
-rw-r--r--xbmc/addons/kodi-dev-kit/include/kodi/c-api/addon-instance/CMakeLists.txt13
-rw-r--r--xbmc/addons/kodi-dev-kit/include/kodi/c-api/addon-instance/audio_decoder.h92
-rw-r--r--xbmc/addons/kodi-dev-kit/include/kodi/c-api/addon-instance/audio_encoder.h67
-rw-r--r--xbmc/addons/kodi-dev-kit/include/kodi/c-api/addon-instance/game.h1212
-rw-r--r--xbmc/addons/kodi-dev-kit/include/kodi/c-api/addon-instance/image_decoder.h83
-rw-r--r--xbmc/addons/kodi-dev-kit/include/kodi/c-api/addon-instance/peripheral.h709
-rw-r--r--xbmc/addons/kodi-dev-kit/include/kodi/c-api/addon-instance/pvr.h332
-rw-r--r--xbmc/addons/kodi-dev-kit/include/kodi/c-api/addon-instance/pvr/CMakeLists.txt14
-rw-r--r--xbmc/addons/kodi-dev-kit/include/kodi/c-api/addon-instance/pvr/pvr_channel_groups.h59
-rw-r--r--xbmc/addons/kodi-dev-kit/include/kodi/c-api/addon-instance/pvr/pvr_channels.h109
-rw-r--r--xbmc/addons/kodi-dev-kit/include/kodi/c-api/addon-instance/pvr/pvr_defines.h66
-rw-r--r--xbmc/addons/kodi-dev-kit/include/kodi/c-api/addon-instance/pvr/pvr_edl.h67
-rw-r--r--xbmc/addons/kodi-dev-kit/include/kodi/c-api/addon-instance/pvr/pvr_epg.h658
-rw-r--r--xbmc/addons/kodi-dev-kit/include/kodi/c-api/addon-instance/pvr/pvr_general.h295
-rw-r--r--xbmc/addons/kodi-dev-kit/include/kodi/c-api/addon-instance/pvr/pvr_menu_hook.h77
-rw-r--r--xbmc/addons/kodi-dev-kit/include/kodi/c-api/addon-instance/pvr/pvr_recordings.h148
-rw-r--r--xbmc/addons/kodi-dev-kit/include/kodi/c-api/addon-instance/pvr/pvr_stream.h160
-rw-r--r--xbmc/addons/kodi-dev-kit/include/kodi/c-api/addon-instance/pvr/pvr_timers.h412
-rw-r--r--xbmc/addons/kodi-dev-kit/include/kodi/c-api/addon-instance/screensaver.h75
-rw-r--r--xbmc/addons/kodi-dev-kit/include/kodi/c-api/addon-instance/vfs.h149
-rw-r--r--xbmc/addons/kodi-dev-kit/include/kodi/c-api/addon-instance/visualization.h117
-rw-r--r--xbmc/addons/kodi-dev-kit/include/kodi/c-api/addon_base.h264
-rw-r--r--xbmc/addons/kodi-dev-kit/include/kodi/c-api/audio_engine.h314
-rw-r--r--xbmc/addons/kodi-dev-kit/include/kodi/c-api/filesystem.h325
-rw-r--r--xbmc/addons/kodi-dev-kit/include/kodi/c-api/general.h130
-rw-r--r--xbmc/addons/kodi-dev-kit/include/kodi/c-api/gui/CMakeLists.txt8
-rw-r--r--xbmc/addons/kodi-dev-kit/include/kodi/c-api/gui/controls/CMakeLists.txt16
-rw-r--r--xbmc/addons/kodi-dev-kit/include/kodi/c-api/gui/controls/button.h35
-rw-r--r--xbmc/addons/kodi-dev-kit/include/kodi/c-api/gui/controls/edit.h79
-rw-r--r--xbmc/addons/kodi-dev-kit/include/kodi/c-api/gui/controls/fade_label.h34
-rw-r--r--xbmc/addons/kodi-dev-kit/include/kodi/c-api/gui/controls/image.h37
-rw-r--r--xbmc/addons/kodi-dev-kit/include/kodi/c-api/gui/controls/label.h32
-rw-r--r--xbmc/addons/kodi-dev-kit/include/kodi/c-api/gui/controls/progress.h32
-rw-r--r--xbmc/addons/kodi-dev-kit/include/kodi/c-api/gui/controls/radio_button.h35
-rw-r--r--xbmc/addons/kodi-dev-kit/include/kodi/c-api/gui/controls/rendering.h38
-rw-r--r--xbmc/addons/kodi-dev-kit/include/kodi/c-api/gui/controls/settings_slider.h48
-rw-r--r--xbmc/addons/kodi-dev-kit/include/kodi/c-api/gui/controls/slider.h48
-rw-r--r--xbmc/addons/kodi-dev-kit/include/kodi/c-api/gui/controls/spin.h58
-rw-r--r--xbmc/addons/kodi-dev-kit/include/kodi/c-api/gui/controls/text_box.h36
-rw-r--r--xbmc/addons/kodi-dev-kit/include/kodi/c-api/gui/definitions.h106
-rw-r--r--xbmc/addons/kodi-dev-kit/include/kodi/c-api/gui/dialogs/CMakeLists.txt14
-rw-r--r--xbmc/addons/kodi-dev-kit/include/kodi/c-api/gui/dialogs/context_menu.h33
-rw-r--r--xbmc/addons/kodi-dev-kit/include/kodi/c-api/gui/dialogs/extended_progress.h43
-rw-r--r--xbmc/addons/kodi-dev-kit/include/kodi/c-api/gui/dialogs/filebrowser.h77
-rw-r--r--xbmc/addons/kodi-dev-kit/include/kodi/c-api/gui/dialogs/keyboard.h74
-rw-r--r--xbmc/addons/kodi-dev-kit/include/kodi/c-api/gui/dialogs/numeric.h54
-rw-r--r--xbmc/addons/kodi-dev-kit/include/kodi/c-api/gui/dialogs/ok.h37
-rw-r--r--xbmc/addons/kodi-dev-kit/include/kodi/c-api/gui/dialogs/progress.h45
-rw-r--r--xbmc/addons/kodi-dev-kit/include/kodi/c-api/gui/dialogs/select.h42
-rw-r--r--xbmc/addons/kodi-dev-kit/include/kodi/c-api/gui/dialogs/text_viewer.h30
-rw-r--r--xbmc/addons/kodi-dev-kit/include/kodi/c-api/gui/dialogs/yes_no.h50
-rw-r--r--xbmc/addons/kodi-dev-kit/include/kodi/c-api/gui/general.h37
-rw-r--r--xbmc/addons/kodi-dev-kit/include/kodi/c-api/gui/input/CMakeLists.txt5
-rw-r--r--xbmc/addons/kodi-dev-kit/include/kodi/c-api/gui/input/action_ids.h763
-rw-r--r--xbmc/addons/kodi-dev-kit/include/kodi/c-api/gui/list_item.h54
-rw-r--r--xbmc/addons/kodi-dev-kit/include/kodi/c-api/gui/window.h183
-rw-r--r--xbmc/addons/kodi-dev-kit/include/kodi/c-api/network.h48
-rw-r--r--xbmc/addons/kodi-dev-kit/include/kodi/c-api/platform/android/system.h34
-rw-r--r--xbmc/addons/kodi-dev-kit/include/kodi/gui/CMakeLists.txt8
-rw-r--r--xbmc/addons/kodi-dev-kit/include/kodi/gui/General.h176
-rw-r--r--xbmc/addons/kodi-dev-kit/include/kodi/gui/ListItem.h345
-rw-r--r--xbmc/addons/kodi-dev-kit/include/kodi/gui/Window.h915
-rw-r--r--xbmc/addons/kodi-dev-kit/include/kodi/gui/controls/Button.h166
-rw-r--r--xbmc/addons/kodi-dev-kit/include/kodi/gui/controls/CMakeLists.txt16
-rw-r--r--xbmc/addons/kodi-dev-kit/include/kodi/gui/controls/Edit.h217
-rw-r--r--xbmc/addons/kodi-dev-kit/include/kodi/gui/controls/FadeLabel.h148
-rw-r--r--xbmc/addons/kodi-dev-kit/include/kodi/gui/controls/Image.h112
-rw-r--r--xbmc/addons/kodi-dev-kit/include/kodi/gui/controls/Label.h118
-rw-r--r--xbmc/addons/kodi-dev-kit/include/kodi/gui/controls/Progress.h112
-rw-r--r--xbmc/addons/kodi-dev-kit/include/kodi/gui/controls/RadioButton.h214
-rw-r--r--xbmc/addons/kodi-dev-kit/include/kodi/gui/controls/Rendering.h217
-rw-r--r--xbmc/addons/kodi-dev-kit/include/kodi/gui/controls/SettingsSlider.h314
-rw-r--r--xbmc/addons/kodi-dev-kit/include/kodi/gui/controls/Slider.h326
-rw-r--r--xbmc/addons/kodi-dev-kit/include/kodi/gui/controls/Spin.h416
-rw-r--r--xbmc/addons/kodi-dev-kit/include/kodi/gui/controls/TextBox.h164
-rw-r--r--xbmc/addons/kodi-dev-kit/include/kodi/gui/dialogs/CMakeLists.txt14
-rw-r--r--xbmc/addons/kodi-dev-kit/include/kodi/gui/dialogs/ContextMenu.h186
-rw-r--r--xbmc/addons/kodi-dev-kit/include/kodi/gui/dialogs/ExtendedProgress.h242
-rw-r--r--xbmc/addons/kodi-dev-kit/include/kodi/gui/dialogs/FileBrowser.h302
-rw-r--r--xbmc/addons/kodi-dev-kit/include/kodi/gui/dialogs/Keyboard.h404
-rw-r--r--xbmc/addons/kodi-dev-kit/include/kodi/gui/dialogs/Numeric.h346
-rw-r--r--xbmc/addons/kodi-dev-kit/include/kodi/gui/dialogs/OK.h101
-rw-r--r--xbmc/addons/kodi-dev-kit/include/kodi/gui/dialogs/Progress.h244
-rw-r--r--xbmc/addons/kodi-dev-kit/include/kodi/gui/dialogs/Select.h269
-rw-r--r--xbmc/addons/kodi-dev-kit/include/kodi/gui/dialogs/TextViewer.h109
-rw-r--r--xbmc/addons/kodi-dev-kit/include/kodi/gui/dialogs/YesNo.h188
-rw-r--r--xbmc/addons/kodi-dev-kit/include/kodi/gui/gl/CMakeLists.txt7
-rw-r--r--xbmc/addons/kodi-dev-kit/include/kodi/gui/gl/GL.h112
-rw-r--r--xbmc/addons/kodi-dev-kit/include/kodi/gui/gl/GLonDX.h389
-rw-r--r--xbmc/addons/kodi-dev-kit/include/kodi/gui/gl/Shader.h571
-rw-r--r--xbmc/addons/kodi-dev-kit/include/kodi/gui/input/ActionIDs.h11
-rw-r--r--xbmc/addons/kodi-dev-kit/include/kodi/gui/input/CMakeLists.txt5
-rw-r--r--xbmc/addons/kodi-dev-kit/include/kodi/gui/renderHelper.h82
-rw-r--r--xbmc/addons/kodi-dev-kit/include/kodi/platform/android/System.h105
-rw-r--r--xbmc/addons/kodi-dev-kit/include/kodi/tools/CMakeLists.txt9
-rw-r--r--xbmc/addons/kodi-dev-kit/include/kodi/tools/DllHelper.h211
-rw-r--r--xbmc/addons/kodi-dev-kit/include/kodi/tools/EndTime.h215
-rw-r--r--xbmc/addons/kodi-dev-kit/include/kodi/tools/StringUtils.h3086
-rw-r--r--xbmc/addons/kodi-dev-kit/include/kodi/tools/Thread.h399
-rw-r--r--xbmc/addons/kodi-dev-kit/include/kodi/tools/Timer.h315
-rw-r--r--xbmc/addons/kodi-dev-kit/include/kodi/versions.h492
134 files changed, 41961 insertions, 0 deletions
diff --git a/xbmc/addons/kodi-dev-kit/include/kodi/AddonBase.h b/xbmc/addons/kodi-dev-kit/include/kodi/AddonBase.h
new file mode 100644
index 0000000..6ab4159
--- /dev/null
+++ b/xbmc/addons/kodi-dev-kit/include/kodi/AddonBase.h
@@ -0,0 +1,1322 @@
1/*
2 * Copyright (C) 2005-2018 Team Kodi
3 * This file is part of Kodi - https://kodi.tv
4 *
5 * SPDX-License-Identifier: GPL-2.0-or-later
6 * See LICENSES/README.md for more information.
7 */
8
9#pragma once
10
11#include "c-api/addon_base.h"
12#include "versions.h"
13
14#include <assert.h> /* assert */
15#include <stdarg.h> /* va_list, va_start, va_arg, va_end */
16
17#ifdef __cplusplus
18
19#include <cstdlib>
20#include <cstring>
21#include <ctime>
22#include <memory>
23#include <stdexcept>
24#include <string>
25#include <vector>
26
27#include "tools/StringUtils.h"
28
29namespace kodi
30{
31
32namespace gui
33{
34struct IRenderHelper;
35} // namespace gui
36
37//==============================================================================
38/// @ingroup cpp_kodi_Defs
39/// @defgroup cpp_kodi_Defs_HardwareContext using HardwareContext
40/// @brief **Hardware specific device context**\n
41/// This defines an independent value which is used for hardware and OS specific
42/// values.
43///
44/// This is basically a simple pointer which has to be changed to the desired
45/// format at the corresponding places using <b>`static_cast<...>(...)`</b>.
46///
47///
48///-------------------------------------------------------------------------
49///
50/// **Example:**
51/// ~~~~~~~~~~~~~{.cpp}
52/// #include <d3d11_1.h>
53/// ..
54/// // Note: Device() there is used inside addon child class about
55/// // kodi::addon::CInstanceVisualization
56/// ID3D11DeviceContext1* context = static_cast<ID3D11DeviceContext1*>(kodi::addon::CInstanceVisualization::Device());
57/// ..
58/// ~~~~~~~~~~~~~
59///
60///@{
61using HardwareContext = ADDON_HARDWARE_CONTEXT;
62///@}
63//------------------------------------------------------------------------------
64
65//==============================================================================
66/// @ingroup cpp_kodi_addon_addonbase_Defs
67/// @defgroup cpp_kodi_addon_addonbase_Defs_CSettingValue class CSettingValue
68/// @brief Inside addon main instance used helper class to give settings value.
69///
70/// This is used on @ref addon::CAddonBase::SetSetting() to inform addon about
71/// settings change by used. This becomes then used to give the related value
72/// name.
73///
74/// ----------------------------------------------------------------------------
75///
76/// @copydetails cpp_kodi_addon_addonbase_Defs_CSettingValue_Help
77///
78/// ----------------------------------------------------------------------------
79///
80/// **Here is a code example how this is used:**
81///
82/// ~~~~~~~~~~~~~{.cpp}
83/// #include <kodi/AddonBase.h>
84///
85/// enum myEnumValue
86/// {
87/// valueA,
88/// valueB,
89/// valueC
90/// };
91///
92/// std::string m_myStringValue;
93/// int m_myIntegerValue;
94/// bool m_myBooleanValue;
95/// float m_myFloatingPointValue;
96/// myEnumValue m_myEnumValue;
97///
98///
99/// ADDON_STATUS CMyAddon::SetSetting(const std::string& settingName, const kodi::CSettingValue& settingValue)
100/// {
101/// if (settingName == "my_string_value")
102/// m_myStringValue = settingValue.GetString();
103/// else if (settingName == "my_integer_value")
104/// m_myIntegerValue = settingValue.GetInt();
105/// else if (settingName == "my_boolean_value")
106/// m_myBooleanValue = settingValue.GetBoolean();
107/// else if (settingName == "my_float_value")
108/// m_myFloatingPointValue = settingValue.GetFloat();
109/// else if (settingName == "my_enum_value")
110/// m_myEnumValue = settingValue.GetEnum<myEnumValue>();
111/// }
112/// ~~~~~~~~~~~~~
113///
114/// @note The asked type should match the type used on settings.xml.
115///
116///@{
117class ATTRIBUTE_HIDDEN CSettingValue
118{
119public:
120 explicit CSettingValue(const void* settingValue) : m_settingValue(settingValue) {}
121
122 bool empty() const { return (m_settingValue == nullptr) ? true : false; }
123
124 /// @defgroup cpp_kodi_addon_addonbase_Defs_CSettingValue_Help Value Help
125 /// @ingroup cpp_kodi_addon_addonbase_Defs_CSettingValue
126 ///
127 /// <b>The following table contains values that can be set with @ref cpp_kodi_addon_addonbase_Defs_CSettingValue :</b>
128 /// | Name | Type | Get call
129 /// |------|------|----------
130 /// | **Settings value as string** | `std::string` | @ref CSettingValue::GetString "GetString"
131 /// | **Settings value as integer** | `int` | @ref CSettingValue::GetInt "GetInt"
132 /// | **Settings value as unsigned integer** | `unsigned int` | @ref CSettingValue::GetUInt "GetUInt"
133 /// | **Settings value as boolean** | `bool` | @ref CSettingValue::GetBoolean "GetBoolean"
134 /// | **Settings value as floating point** | `float` | @ref CSettingValue::GetFloat "GetFloat"
135 /// | **Settings value as enum** | `enum` | @ref CSettingValue::GetEnum "GetEnum"
136
137 /// @addtogroup cpp_kodi_addon_addonbase_Defs_CSettingValue
138 ///@{
139
140 /// @brief To get settings value as string.
141 std::string GetString() const { return (const char*)m_settingValue; }
142
143 /// @brief To get settings value as integer.
144 int GetInt() const { return *(const int*)m_settingValue; }
145
146 /// @brief To get settings value as unsigned integer.
147 unsigned int GetUInt() const { return *(const unsigned int*)m_settingValue; }
148
149 /// @brief To get settings value as boolean.
150 bool GetBoolean() const { return *(const bool*)m_settingValue; }
151
152 /// @brief To get settings value as floating point.
153 float GetFloat() const { return *(const float*)m_settingValue; }
154
155 /// @brief To get settings value as enum.
156 /// @note Inside settings.xml them stored as integer.
157 template<typename enumType>
158 enumType GetEnum() const
159 {
160 return static_cast<enumType>(*(const int*)m_settingValue);
161 }
162
163 ///@}
164
165private:
166 const void* m_settingValue;
167};
168///@}
169//------------------------------------------------------------------------------
170
171namespace addon
172{
173
174//==============================================================================
175/*
176 * Internal class to control various instance types with general parts defined
177 * here.
178 *
179 * Mainly is this currently used to identify requested instance types.
180 *
181 * @note This class is not need to know during add-on development thats why
182 * commented with "*".
183 */
184class ATTRIBUTE_HIDDEN IAddonInstance
185{
186public:
187 explicit IAddonInstance(ADDON_TYPE type, const std::string& version)
188 : m_type(type), m_kodiVersion(version)
189 {
190 }
191 virtual ~IAddonInstance() = default;
192
193 virtual ADDON_STATUS CreateInstance(int instanceType,
194 const std::string& instanceID,
195 KODI_HANDLE instance,
196 const std::string& version,
197 KODI_HANDLE& addonInstance)
198 {
199 return ADDON_STATUS_NOT_IMPLEMENTED;
200 }
201
202 const ADDON_TYPE m_type;
203 const std::string m_kodiVersion;
204 std::string m_id;
205};
206
207/*
208 * Internally used helper class to manage processing of a "C" structure in "CPP"
209 * class.
210 *
211 * At constant, the "C" structure is copied, otherwise the given pointer is
212 * superseded and is changeable.
213 *
214 * -----------------------------------------------------------------------------
215 *
216 * Example:
217 *
218 * ~~~~~~~~~~~~~{.cpp}
219 * extern "C" typedef struct C_SAMPLE_DATA
220 * {
221 * unsigned int iUniqueId;
222 * } C_SAMPLE_DATA;
223 *
224 * class CPPSampleData : public CStructHdl<CPPSampleData, C_SAMPLE_DATA>
225 * {
226 * public:
227 * CPPSampleData() = default;
228 * CPPSampleData(const CPPSampleData& sample) : CStructHdl(sample) { }
229 * CPPSampleData(const C_SAMPLE_DATA* sample) : CStructHdl(sample) { }
230 * CPPSampleData(C_SAMPLE_DATA* sample) : CStructHdl(sample) { }
231 *
232 * void SetUniqueId(unsigned int uniqueId) { m_cStructure->iUniqueId = uniqueId; }
233 * unsigned int GetUniqueId() const { return m_cStructure->iUniqueId; }
234 * };
235 *
236 * ~~~~~~~~~~~~~
237 *
238 * It also works with the following example:
239 *
240 * ~~~~~~~~~~~~~{.cpp}
241 * CPPSampleData test;
242 * // Some work
243 * C_SAMPLE_DATA* data = test;
244 * // Give "data" to Kodi
245 * ~~~~~~~~~~~~~
246 */
247template<class CPP_CLASS, typename C_STRUCT>
248class CStructHdl
249{
250public:
251 CStructHdl() : m_cStructure(new C_STRUCT()), m_owner(true) {}
252
253 CStructHdl(const CPP_CLASS& cppClass)
254 : m_cStructure(new C_STRUCT(*cppClass.m_cStructure)), m_owner(true)
255 {
256 }
257
258 CStructHdl(const C_STRUCT* cStructure) : m_cStructure(new C_STRUCT(*cStructure)), m_owner(true) {}
259
260 CStructHdl(C_STRUCT* cStructure) : m_cStructure(cStructure) { assert(cStructure); }
261
262 const CStructHdl& operator=(const CStructHdl& right)
263 {
264 assert(&right.m_cStructure);
265 if (m_cStructure && !m_owner)
266 {
267 memcpy(m_cStructure, right.m_cStructure, sizeof(C_STRUCT));
268 }
269 else
270 {
271 if (m_owner)
272 delete m_cStructure;
273 m_owner = true;
274 m_cStructure = new C_STRUCT(*right.m_cStructure);
275 }
276 return *this;
277 }
278
279 const CStructHdl& operator=(const C_STRUCT& right)
280 {
281 assert(&right);
282 if (m_cStructure && !m_owner)
283 {
284 memcpy(m_cStructure, &right, sizeof(C_STRUCT));
285 }
286 else
287 {
288 if (m_owner)
289 delete m_cStructure;
290 m_owner = true;
291 m_cStructure = new C_STRUCT(*right);
292 }
293 return *this;
294 }
295
296 virtual ~CStructHdl()
297 {
298 if (m_owner)
299 delete m_cStructure;
300 }
301
302 operator C_STRUCT*() { return m_cStructure; }
303 operator const C_STRUCT*() const { return m_cStructure; }
304
305 const C_STRUCT* GetCStructure() const { return m_cStructure; }
306
307protected:
308 C_STRUCT* m_cStructure = nullptr;
309
310private:
311 bool m_owner = false;
312};
313
314/// Add-on main instance class.
315class ATTRIBUTE_HIDDEN CAddonBase
316{
317public:
318 CAddonBase()
319 {
320 m_interface->toAddon->destroy = ADDONBASE_Destroy;
321 m_interface->toAddon->get_status = ADDONBASE_GetStatus;
322 m_interface->toAddon->create_instance = ADDONBASE_CreateInstance;
323 m_interface->toAddon->destroy_instance = ADDONBASE_DestroyInstance;
324 m_interface->toAddon->set_setting = ADDONBASE_SetSetting;
325 }
326
327 virtual ~CAddonBase() = default;
328
329 virtual ADDON_STATUS Create() { return ADDON_STATUS_OK; }
330
331 virtual ADDON_STATUS GetStatus() { return ADDON_STATUS_OK; }
332
333 //============================================================================
334 /// @ingroup cpp_kodi_addon_addonbase
335 /// @brief To inform addon about changed settings values.
336 ///
337 /// This becomes called for every entry defined inside his settings.xml and
338 /// as **last** call the one where last in xml (to identify end of calls).
339 ///
340 /// --------------------------------------------------------------------------
341 ///
342 /// @copydetails cpp_kodi_addon_addonbase_Defs_CSettingValue_Help
343 ///
344 ///
345 /// --------------------------------------------------------------------------
346 ///
347 /// **Here is a code example how this is used:**
348 ///
349 /// ~~~~~~~~~~~~~{.cpp}
350 /// #include <kodi/AddonBase.h>
351 ///
352 /// enum myEnumValue
353 /// {
354 /// valueA,
355 /// valueB,
356 /// valueC
357 /// };
358 ///
359 /// std::string m_myStringValue;
360 /// int m_myIntegerValue;
361 /// bool m_myBooleanValue;
362 /// float m_myFloatingPointValue;
363 /// myEnumValue m_myEnumValue;
364 ///
365 ///
366 /// ADDON_STATUS CMyAddon::SetSetting(const std::string& settingName, const kodi::CSettingValue& settingValue)
367 /// {
368 /// if (settingName == "my_string_value")
369 /// m_myStringValue = settingValue.GetString();
370 /// else if (settingName == "my_integer_value")
371 /// m_myIntegerValue = settingValue.GetInt();
372 /// else if (settingName == "my_boolean_value")
373 /// m_myBooleanValue = settingValue.GetBoolean();
374 /// else if (settingName == "my_float_value")
375 /// m_myFloatingPointValue = settingValue.GetFloat();
376 /// else if (settingName == "my_enum_value")
377 /// m_myEnumValue = settingValue.GetEnum<myEnumValue>();
378 /// }
379 /// ~~~~~~~~~~~~~
380 ///
381 /// @note The asked type should match the type used on settings.xml.
382 ///
383 virtual ADDON_STATUS SetSetting(const std::string& settingName,
384 const kodi::CSettingValue& settingValue)
385 {
386 return ADDON_STATUS_UNKNOWN;
387 }
388 //----------------------------------------------------------------------------
389
390 //==========================================================================
391 /// @ingroup cpp_kodi_addon_addonbase
392 /// @brief Instance created
393 ///
394 /// @param[in] instanceType The requested type of required instance, see \ref ADDON_TYPE.
395 /// @param[in] instanceID An individual identification key string given by Kodi.
396 /// @param[in] instance The instance handler used by Kodi must be passed to
397 /// the classes created here. See in the example.
398 /// @param[in] version The from Kodi used version of instance. This can be
399 /// used to allow compatibility to older versions of
400 /// them. Further is this given to the parent instance
401 /// that it can handle differences.
402 /// @param[out] addonInstance The pointer to instance class created in addon.
403 /// Needed to be able to identify them on calls.
404 /// @return \ref ADDON_STATUS_OK if correct, for possible errors
405 /// see \ref ADDON_STATUS
406 ///
407 ///
408 /// --------------------------------------------------------------------------
409 ///
410 /// **Here is a code example how this is used:**
411 ///
412 /// ~~~~~~~~~~~~~{.cpp}
413 /// #include <kodi/AddonBase.h>
414 ///
415 /// ...
416 ///
417 /// /* If you use only one instance in your add-on, can be instanceType and
418 /// * instanceID ignored */
419 /// ADDON_STATUS CMyAddon::CreateInstance(int instanceType,
420 /// const std::string& instanceID,
421 /// KODI_HANDLE instance,
422 /// const std::string& version,
423 /// KODI_HANDLE& addonInstance)
424 /// {
425 /// if (instanceType == ADDON_INSTANCE_SCREENSAVER)
426 /// {
427 /// kodi::Log(ADDON_LOG_INFO, "Creating my Screensaver");
428 /// addonInstance = new CMyScreensaver(instance);
429 /// return ADDON_STATUS_OK;
430 /// }
431 /// else if (instanceType == ADDON_INSTANCE_VISUALIZATION)
432 /// {
433 /// kodi::Log(ADDON_LOG_INFO, "Creating my Visualization");
434 /// addonInstance = new CMyVisualization(instance);
435 /// return ADDON_STATUS_OK;
436 /// }
437 /// else if (...)
438 /// {
439 /// ...
440 /// }
441 /// return ADDON_STATUS_UNKNOWN;
442 /// }
443 ///
444 /// ...
445 ///
446 /// ~~~~~~~~~~~~~
447 ///
448 virtual ADDON_STATUS CreateInstance(int instanceType,
449 const std::string& instanceID,
450 KODI_HANDLE instance,
451 const std::string& version,
452 KODI_HANDLE& addonInstance)
453 {
454 return ADDON_STATUS_NOT_IMPLEMENTED;
455 }
456 //--------------------------------------------------------------------------
457
458 //==========================================================================
459 /// @ingroup cpp_kodi_addon_addonbase
460 /// @brief Instance destroy
461 ///
462 /// This function is optional and intended to notify addon that the instance
463 /// is terminating.
464 ///
465 /// @param[in] instanceType The requested type of required instance, see \ref ADDON_TYPE.
466 /// @param[in] instanceID An individual identification key string given by Kodi.
467 /// @param[in] addonInstance The pointer to instance class created in addon.
468 ///
469 /// @warning This call is only used to inform that the associated instance
470 /// is terminated. The deletion is carried out in the background.
471 ///
472 virtual void DestroyInstance(int instanceType,
473 const std::string& instanceID,
474 KODI_HANDLE addonInstance)
475 {
476 }
477 //--------------------------------------------------------------------------
478
479 /* Background helper for GUI render systems, e.g. Screensaver or Visualization */
480 std::shared_ptr<kodi::gui::IRenderHelper> m_renderHelper;
481
482 /* Global variables of class */
483 static AddonGlobalInterface*
484 m_interface; // Interface function table to hold addresses on add-on and from kodi
485
486 /*private:*/ /* Needed public as long the old call functions becomes used! */
487 static inline void ADDONBASE_Destroy()
488 {
489 delete static_cast<CAddonBase*>(m_interface->addonBase);
490 m_interface->addonBase = nullptr;
491 }
492
493 static inline ADDON_STATUS ADDONBASE_GetStatus()
494 {
495 return static_cast<CAddonBase*>(m_interface->addonBase)->GetStatus();
496 }
497
498 static inline ADDON_STATUS ADDONBASE_SetSetting(const char* settingName, const void* settingValue)
499 {
500 return static_cast<CAddonBase*>(m_interface->addonBase)
501 ->SetSetting(settingName, CSettingValue(settingValue));
502 }
503
504private:
505 static inline ADDON_STATUS ADDONBASE_CreateInstance(int instanceType,
506 const char* instanceID,
507 KODI_HANDLE instance,
508 const char* version,
509 KODI_HANDLE* addonInstance,
510 KODI_HANDLE parent)
511 {
512 CAddonBase* base = static_cast<CAddonBase*>(m_interface->addonBase);
513
514 ADDON_STATUS status = ADDON_STATUS_NOT_IMPLEMENTED;
515
516 /* Check about single instance usage:
517 * 1. The kodi side instance pointer must be equal to first one
518 * 2. The addon side instance pointer must be set
519 * 3. And the requested type must be equal with used add-on class
520 */
521 if (m_interface->firstKodiInstance == instance && m_interface->globalSingleInstance &&
522 static_cast<IAddonInstance*>(m_interface->globalSingleInstance)->m_type == instanceType)
523 {
524 /* The handling here is intended for the case of the add-on only one
525 * instance and this is integrated in the add-on base class.
526 */
527 *addonInstance = m_interface->globalSingleInstance;
528 status = ADDON_STATUS_OK;
529 }
530 else
531 {
532 /* Here it should use the CreateInstance instance function to allow
533 * creation of several on one addon.
534 */
535
536 /* Check first a parent is defined about (e.g. Codec within inputstream) */
537 if (parent != nullptr)
538 status = static_cast<IAddonInstance*>(parent)->CreateInstance(
539 instanceType, instanceID, instance, version, *addonInstance);
540
541 /* if no parent call the main instance creation function to get it */
542 if (status == ADDON_STATUS_NOT_IMPLEMENTED)
543 {
544 status = base->CreateInstance(instanceType, instanceID, instance, version, *addonInstance);
545 }
546 }
547
548 if (*addonInstance == nullptr)
549 {
550 if (status == ADDON_STATUS_OK)
551 {
552 m_interface->toKodi->addon_log_msg(m_interface->toKodi->kodiBase, ADDON_LOG_FATAL,
553 "kodi::addon::CAddonBase CreateInstance returned an "
554 "empty instance pointer, but reported OK!");
555 return ADDON_STATUS_PERMANENT_FAILURE;
556 }
557 else
558 {
559 return status;
560 }
561 }
562
563 if (static_cast<IAddonInstance*>(*addonInstance)->m_type != instanceType)
564 {
565 m_interface->toKodi->addon_log_msg(
566 m_interface->toKodi->kodiBase, ADDON_LOG_FATAL,
567 "kodi::addon::CAddonBase CreateInstance difference between given and returned");
568 delete static_cast<IAddonInstance*>(*addonInstance);
569 *addonInstance = nullptr;
570 return ADDON_STATUS_PERMANENT_FAILURE;
571 }
572
573 // Store the used ID inside instance, to have on destroy calls by addon to identify
574 static_cast<IAddonInstance*>(*addonInstance)->m_id = instanceID;
575
576 return status;
577 }
578
579 static inline void ADDONBASE_DestroyInstance(int instanceType, KODI_HANDLE instance)
580 {
581 CAddonBase* base = static_cast<CAddonBase*>(m_interface->addonBase);
582
583 if (m_interface->globalSingleInstance == nullptr && instance != base)
584 {
585 base->DestroyInstance(instanceType, static_cast<IAddonInstance*>(instance)->m_id, instance);
586 delete static_cast<IAddonInstance*>(instance);
587 }
588 }
589};
590
591} /* namespace addon */
592
593//==============================================================================
594/// @ingroup cpp_kodi_addon
595/// @brief To get used version inside Kodi itself about asked type.
596///
597/// This thought to allow a addon a handling of newer addon versions within
598/// older Kodi until the type min version not changed.
599///
600/// @param[in] type The wanted type of @ref ADDON_TYPE to ask
601/// @return The version string about type in MAJOR.MINOR.PATCH style.
602///
603inline std::string ATTRIBUTE_HIDDEN GetKodiTypeVersion(int type)
604{
605 using namespace kodi::addon;
606
607 char* str = CAddonBase::m_interface->toKodi->get_type_version(
608 CAddonBase::m_interface->toKodi->kodiBase, type);
609 std::string ret = str;
610 CAddonBase::m_interface->toKodi->free_string(CAddonBase::m_interface->toKodi->kodiBase, str);
611 return ret;
612}
613//------------------------------------------------------------------------------
614
615//==============================================================================
616///
617inline std::string ATTRIBUTE_HIDDEN GetAddonPath(const std::string& append = "")
618{
619 using namespace kodi::addon;
620
621 char* str =
622 CAddonBase::m_interface->toKodi->get_addon_path(CAddonBase::m_interface->toKodi->kodiBase);
623 std::string ret = str;
624 CAddonBase::m_interface->toKodi->free_string(CAddonBase::m_interface->toKodi->kodiBase, str);
625 if (!append.empty())
626 {
627 if (append.at(0) != '\\' && append.at(0) != '/')
628#ifdef TARGET_WINDOWS
629 ret.append("\\");
630#else
631 ret.append("/");
632#endif
633 ret.append(append);
634 }
635 return ret;
636}
637//------------------------------------------------------------------------------
638
639//==============================================================================
640///
641inline std::string ATTRIBUTE_HIDDEN GetBaseUserPath(const std::string& append = "")
642{
643 using namespace kodi::addon;
644
645 char* str = CAddonBase::m_interface->toKodi->get_base_user_path(
646 CAddonBase::m_interface->toKodi->kodiBase);
647 std::string ret = str;
648 CAddonBase::m_interface->toKodi->free_string(CAddonBase::m_interface->toKodi->kodiBase, str);
649 if (!append.empty())
650 {
651 if (append.at(0) != '\\' && append.at(0) != '/')
652#ifdef TARGET_WINDOWS
653 ret.append("\\");
654#else
655 ret.append("/");
656#endif
657 ret.append(append);
658 }
659 return ret;
660}
661//------------------------------------------------------------------------------
662
663//==============================================================================
664///
665inline std::string ATTRIBUTE_HIDDEN GetLibPath()
666{
667 using namespace kodi::addon;
668
669 return CAddonBase::m_interface->libBasePath;
670}
671//------------------------------------------------------------------------------
672
673//==============================================================================
674/// @ingroup cpp_kodi
675/// @brief Add a message to Kodi's log.
676///
677/// @param[in] loglevel The log level of the message.
678/// @param[in] format The format of the message to pass to Kodi.
679/// @param[in] ... Additional text to insert in format text
680///
681///
682/// @note This method uses limited buffer (16k) for the formatted output.
683/// So data, which will not fit into it, will be silently discarded.
684///
685///
686/// ----------------------------------------------------------------------------
687///
688/// **Example:**
689/// ~~~~~~~~~~~~~{.cpp}
690/// #include <kodi/General.h>
691///
692/// kodi::Log(ADDON_LOG_ERROR, "%s: There is an error occurred!", __func__);
693///
694/// ~~~~~~~~~~~~~
695///
696inline void ATTRIBUTE_HIDDEN Log(const AddonLog loglevel, const char* format, ...)
697{
698 using namespace kodi::addon;
699
700 va_list args;
701 va_start(args, format);
702 const std::string str = kodi::tools::StringUtils::FormatV(format, args);
703 va_end(args);
704 CAddonBase::m_interface->toKodi->addon_log_msg(CAddonBase::m_interface->toKodi->kodiBase,
705 loglevel, str.c_str());
706}
707//------------------------------------------------------------------------------
708
709//##############################################################################
710/// @ingroup cpp_kodi
711/// @defgroup cpp_kodi_settings 1. Setting control
712/// @brief **Functions to handle settings access**\n
713/// This can be used to get and set the addon related values inside his
714/// settings.xml.
715///
716/// The settings style is given with installed part on e.g.
717/// <b>`$HOME/.kodi/addons/myspecial.addon/resources/settings.xml`</b>. The
718/// related edit becomes then stored inside
719/// <b>`$HOME/.kodi/userdata/addon_data/myspecial.addon/settings.xml`</b>.
720///
721/*!@{*/
722
723//==============================================================================
724/// @brief Check the given setting name is set to default value.
725///
726/// The setting name relate to names used in his <b>settings.xml</b> file.
727///
728/// @param[in] settingName The name of asked setting
729/// @return true if setting is the default
730///
731inline bool ATTRIBUTE_HIDDEN IsSettingUsingDefault(const std::string& settingName)
732{
733 using namespace kodi::addon;
734 return CAddonBase::m_interface->toKodi->is_setting_using_default(
735 CAddonBase::m_interface->toKodi->kodiBase, settingName.c_str());
736}
737//------------------------------------------------------------------------------
738
739//==============================================================================
740/// @brief Check and get a string setting value.
741///
742/// The setting name relate to names used in his <b>settings.xml</b> file.
743///
744/// @param[in] settingName The name of asked setting
745/// @param[out] settingValue The given setting value
746/// @return true if setting was successfully found and "settingValue" is set
747///
748/// @note If returns false, the "settingValue" is not changed.
749///
750///
751/// ----------------------------------------------------------------------------
752///
753/// **Example:**
754/// ~~~~~~~~~~~~~{.cpp}
755/// #include <kodi/General.h>
756///
757/// std::string value;
758/// if (!kodi::CheckSettingString("my_string_value", value))
759/// value = "my_default_if_setting_not_work";
760/// ~~~~~~~~~~~~~
761///
762inline bool ATTRIBUTE_HIDDEN CheckSettingString(const std::string& settingName,
763 std::string& settingValue)
764{
765 using namespace kodi::addon;
766
767 char* buffer = nullptr;
768 bool ret = CAddonBase::m_interface->toKodi->get_setting_string(
769 CAddonBase::m_interface->toKodi->kodiBase, settingName.c_str(), &buffer);
770 if (buffer)
771 {
772 if (ret)
773 settingValue = buffer;
774 CAddonBase::m_interface->toKodi->free_string(CAddonBase::m_interface->toKodi->kodiBase, buffer);
775 }
776 return ret;
777}
778//------------------------------------------------------------------------------
779
780//==============================================================================
781/// @brief Get string setting value.
782///
783/// The setting name relate to names used in his <b>settings.xml</b> file.
784///
785/// @param[in] settingName The name of asked setting
786/// @param[in] defaultValue [opt] Default value if not found
787/// @return The value of setting, empty if not found;
788///
789///
790/// ----------------------------------------------------------------------------
791///
792/// **Example:**
793/// ~~~~~~~~~~~~~{.cpp}
794/// #include <kodi/General.h>
795///
796/// std::string value = kodi::GetSettingString("my_string_value");
797/// ~~~~~~~~~~~~~
798///
799inline std::string ATTRIBUTE_HIDDEN GetSettingString(const std::string& settingName,
800 const std::string& defaultValue = "")
801{
802 std::string settingValue = defaultValue;
803 CheckSettingString(settingName, settingValue);
804 return settingValue;
805}
806//------------------------------------------------------------------------------
807
808//==============================================================================
809/// @brief Set string setting of addon.
810///
811/// The setting name relate to names used in his <b>settings.xml</b> file.
812///
813/// @param[in] settingName The name of setting
814/// @param[in] settingValue The setting value to write
815///
816///
817/// ----------------------------------------------------------------------------
818///
819/// **Example:**
820/// ~~~~~~~~~~~~~{.cpp}
821/// #include <kodi/General.h>
822///
823/// std::string value = "my_new_name for";
824/// kodi::SetSettingString("my_string_value", value);
825/// ~~~~~~~~~~~~~
826///
827inline void ATTRIBUTE_HIDDEN SetSettingString(const std::string& settingName,
828 const std::string& settingValue)
829{
830 using namespace kodi::addon;
831
832 CAddonBase::m_interface->toKodi->set_setting_string(CAddonBase::m_interface->toKodi->kodiBase,
833 settingName.c_str(), settingValue.c_str());
834}
835//------------------------------------------------------------------------------
836
837//==============================================================================
838/// @brief Check and get a integer setting value.
839///
840/// The setting name relate to names used in his <b>settings.xml</b> file.
841///
842/// @param[in] settingName The name of asked setting
843/// @param[out] settingValue The given setting value
844/// @return true if setting was successfully found and "settingValue" is set
845///
846/// @note If returns false, the "settingValue" is not changed.
847///
848///
849/// ----------------------------------------------------------------------------
850///
851/// **Example:**
852/// ~~~~~~~~~~~~~{.cpp}
853/// #include <kodi/General.h>
854///
855/// int value = 0;
856/// if (!kodi::CheckSettingInt("my_integer_value", value))
857/// value = 123; // My default of them
858/// ~~~~~~~~~~~~~
859///
860inline bool ATTRIBUTE_HIDDEN CheckSettingInt(const std::string& settingName, int& settingValue)
861{
862 using namespace kodi::addon;
863
864 return CAddonBase::m_interface->toKodi->get_setting_int(CAddonBase::m_interface->toKodi->kodiBase,
865 settingName.c_str(), &settingValue);
866}
867//------------------------------------------------------------------------------
868
869//==============================================================================
870/// @brief Get integer setting value.
871///
872/// The setting name relate to names used in his <b>settings.xml</b> file.
873///
874/// @param[in] settingName The name of asked setting
875/// @param[in] defaultValue [opt] Default value if not found
876/// @return The value of setting, <b>`0`</b> or defaultValue if not found
877///
878///
879/// ----------------------------------------------------------------------------
880///
881/// **Example:**
882/// ~~~~~~~~~~~~~{.cpp}
883/// #include <kodi/General.h>
884///
885/// int value = kodi::GetSettingInt("my_integer_value");
886/// ~~~~~~~~~~~~~
887///
888inline int ATTRIBUTE_HIDDEN GetSettingInt(const std::string& settingName, int defaultValue = 0)
889{
890 int settingValue = defaultValue;
891 CheckSettingInt(settingName, settingValue);
892 return settingValue;
893}
894//------------------------------------------------------------------------------
895
896//==============================================================================
897/// @brief Set integer setting of addon.
898///
899/// The setting name relate to names used in his <b>settings.xml</b> file.
900///
901/// @param[in] settingName The name of setting
902/// @param[in] settingValue The setting value to write
903///
904///
905/// ----------------------------------------------------------------------------
906///
907/// **Example:**
908/// ~~~~~~~~~~~~~{.cpp}
909/// #include <kodi/General.h>
910///
911/// int value = 123;
912/// kodi::SetSettingInt("my_integer_value", value);
913/// ~~~~~~~~~~~~~
914///
915inline void ATTRIBUTE_HIDDEN SetSettingInt(const std::string& settingName, int settingValue)
916{
917 using namespace kodi::addon;
918
919 CAddonBase::m_interface->toKodi->set_setting_int(CAddonBase::m_interface->toKodi->kodiBase,
920 settingName.c_str(), settingValue);
921}
922//------------------------------------------------------------------------------
923
924//==============================================================================
925/// @brief Check and get a boolean setting value.
926///
927/// The setting name relate to names used in his <b>settings.xml</b> file.
928///
929/// @param[in] settingName The name of asked setting
930/// @param[out] settingValue The given setting value
931/// @return true if setting was successfully found and "settingValue" is set
932///
933/// @note If returns false, the "settingValue" is not changed.
934///
935///
936/// ----------------------------------------------------------------------------
937///
938/// **Example:**
939/// ~~~~~~~~~~~~~{.cpp}
940/// #include <kodi/General.h>
941///
942/// bool value = false;
943/// if (!kodi::CheckSettingBoolean("my_boolean_value", value))
944/// value = true; // My default of them
945/// ~~~~~~~~~~~~~
946///
947inline bool ATTRIBUTE_HIDDEN CheckSettingBoolean(const std::string& settingName, bool& settingValue)
948{
949 using namespace kodi::addon;
950
951 return CAddonBase::m_interface->toKodi->get_setting_bool(
952 CAddonBase::m_interface->toKodi->kodiBase, settingName.c_str(), &settingValue);
953}
954//------------------------------------------------------------------------------
955
956//==============================================================================
957/// @brief Get boolean setting value.
958///
959/// The setting name relate to names used in his <b>settings.xml</b> file.
960///
961/// @param[in] settingName The name of asked setting
962/// @param[in] defaultValue [opt] Default value if not found
963/// @return The value of setting, <b>`false`</b> or defaultValue if not found
964///
965///
966/// ----------------------------------------------------------------------------
967///
968/// **Example:**
969/// ~~~~~~~~~~~~~{.cpp}
970/// #include <kodi/General.h>
971///
972/// bool value = kodi::GetSettingBoolean("my_boolean_value");
973/// ~~~~~~~~~~~~~
974///
975inline bool ATTRIBUTE_HIDDEN GetSettingBoolean(const std::string& settingName,
976 bool defaultValue = false)
977{
978 bool settingValue = defaultValue;
979 CheckSettingBoolean(settingName, settingValue);
980 return settingValue;
981}
982//------------------------------------------------------------------------------
983
984//==============================================================================
985/// @brief Set boolean setting of addon.
986///
987/// The setting name relate to names used in his <b>settings.xml</b> file.
988///
989/// @param[in] settingName The name of setting
990/// @param[in] settingValue The setting value to write
991///
992///
993/// ----------------------------------------------------------------------------
994///
995/// **Example:**
996/// ~~~~~~~~~~~~~{.cpp}
997/// #include <kodi/General.h>
998///
999/// bool value = true;
1000/// kodi::SetSettingBoolean("my_boolean_value", value);
1001/// ~~~~~~~~~~~~~
1002///
1003inline void ATTRIBUTE_HIDDEN SetSettingBoolean(const std::string& settingName, bool settingValue)
1004{
1005 using namespace kodi::addon;
1006
1007 CAddonBase::m_interface->toKodi->set_setting_bool(CAddonBase::m_interface->toKodi->kodiBase,
1008 settingName.c_str(), settingValue);
1009}
1010//------------------------------------------------------------------------------
1011
1012//==============================================================================
1013/// @brief Check and get a floating point setting value.
1014///
1015/// The setting name relate to names used in his <b>settings.xml</b> file.
1016///
1017/// @param[in] settingName The name of asked setting
1018/// @param[out] settingValue The given setting value
1019/// @return true if setting was successfully found and "settingValue" is set
1020///
1021/// @note If returns false, the "settingValue" is not changed.
1022///
1023///
1024/// ----------------------------------------------------------------------------
1025///
1026/// **Example:**
1027/// ~~~~~~~~~~~~~{.cpp}
1028/// #include <kodi/General.h>
1029///
1030/// float value = 0.0f;
1031/// if (!kodi::CheckSettingBoolean("my_float_value", value))
1032/// value = 1.0f; // My default of them
1033/// ~~~~~~~~~~~~~
1034///
1035inline bool ATTRIBUTE_HIDDEN CheckSettingFloat(const std::string& settingName, float& settingValue)
1036{
1037 using namespace kodi::addon;
1038
1039 return CAddonBase::m_interface->toKodi->get_setting_float(
1040 CAddonBase::m_interface->toKodi->kodiBase, settingName.c_str(), &settingValue);
1041}
1042//------------------------------------------------------------------------------
1043
1044//==============================================================================
1045/// @brief Get floating point setting value.
1046///
1047/// The setting name relate to names used in his <b>settings.xml</b> file.
1048///
1049/// @param[in] settingName The name of asked setting
1050/// @param[in] defaultValue [opt] Default value if not found
1051/// @return The value of setting, <b>`0.0`</b> or defaultValue if not found
1052///
1053///
1054/// ----------------------------------------------------------------------------
1055///
1056/// **Example:**
1057/// ~~~~~~~~~~~~~{.cpp}
1058/// #include <kodi/General.h>
1059///
1060/// float value = kodi::GetSettingFloat("my_float_value");
1061/// ~~~~~~~~~~~~~
1062///
1063inline float ATTRIBUTE_HIDDEN GetSettingFloat(const std::string& settingName,
1064 float defaultValue = 0.0f)
1065{
1066 float settingValue = defaultValue;
1067 CheckSettingFloat(settingName, settingValue);
1068 return settingValue;
1069}
1070//------------------------------------------------------------------------------
1071
1072//==============================================================================
1073/// @brief Set floating point setting of addon.
1074///
1075/// The setting name relate to names used in his <b>settings.xml</b> file.
1076///
1077/// @param[in] settingName The name of setting
1078/// @param[in] settingValue The setting value to write
1079///
1080///
1081/// ----------------------------------------------------------------------------
1082///
1083/// **Example:**
1084/// ~~~~~~~~~~~~~{.cpp}
1085/// #include <kodi/General.h>
1086///
1087/// float value = 1.0f;
1088/// kodi::SetSettingFloat("my_float_value", value);
1089/// ~~~~~~~~~~~~~
1090///
1091inline void ATTRIBUTE_HIDDEN SetSettingFloat(const std::string& settingName, float settingValue)
1092{
1093 using namespace kodi::addon;
1094
1095 CAddonBase::m_interface->toKodi->set_setting_float(CAddonBase::m_interface->toKodi->kodiBase,
1096 settingName.c_str(), settingValue);
1097}
1098//------------------------------------------------------------------------------
1099
1100//==============================================================================
1101/// @brief Check and get a enum setting value.
1102///
1103/// The setting name relate to names used in his <b>settings.xml</b> file.
1104///
1105/// @param[in] settingName The name of asked setting
1106/// @param[out] settingValue The given setting value
1107/// @return true if setting was successfully found and "settingValue" is set
1108///
1109/// @remark The enums are used as integer inside settings.xml.
1110/// @note If returns false, the "settingValue" is not changed.
1111///
1112///
1113/// ----------------------------------------------------------------------------
1114///
1115/// **Example:**
1116/// ~~~~~~~~~~~~~{.cpp}
1117/// #include <kodi/General.h>
1118///
1119/// enum myEnumValue
1120/// {
1121/// valueA,
1122/// valueB,
1123/// valueC
1124/// };
1125///
1126/// myEnumValue value;
1127/// if (!kodi::CheckSettingEnum<myEnumValue>("my_enum_value", value))
1128/// value = valueA; // My default of them
1129/// ~~~~~~~~~~~~~
1130///
1131template<typename enumType>
1132inline bool ATTRIBUTE_HIDDEN CheckSettingEnum(const std::string& settingName,
1133 enumType& settingValue)
1134{
1135 using namespace kodi::addon;
1136
1137 int settingValueInt = static_cast<int>(settingValue);
1138 bool ret = CAddonBase::m_interface->toKodi->get_setting_int(
1139 CAddonBase::m_interface->toKodi->kodiBase, settingName.c_str(), &settingValueInt);
1140 if (ret)
1141 settingValue = static_cast<enumType>(settingValueInt);
1142 return ret;
1143}
1144//------------------------------------------------------------------------------
1145
1146//==============================================================================
1147/// @brief Get enum setting value.
1148///
1149/// The setting name relate to names used in his <b>settings.xml</b> file.
1150///
1151/// @param[in] settingName The name of asked setting
1152/// @param[in] defaultValue [opt] Default value if not found
1153/// @return The value of setting, forced to <b>`0`</b> or defaultValue if not found
1154///
1155/// @remark The enums are used as integer inside settings.xml.
1156///
1157///
1158/// ----------------------------------------------------------------------------
1159///
1160/// **Example:**
1161/// ~~~~~~~~~~~~~{.cpp}
1162/// #include <kodi/General.h>
1163///
1164/// enum myEnumValue
1165/// {
1166/// valueA,
1167/// valueB,
1168/// valueC
1169/// };
1170///
1171/// myEnumValue value = kodi::GetSettingEnum<myEnumValue>("my_enum_value");
1172/// ~~~~~~~~~~~~~
1173///
1174template<typename enumType>
1175inline enumType ATTRIBUTE_HIDDEN GetSettingEnum(const std::string& settingName,
1176 enumType defaultValue = static_cast<enumType>(0))
1177{
1178 enumType settingValue = defaultValue;
1179 CheckSettingEnum(settingName, settingValue);
1180 return settingValue;
1181}
1182//------------------------------------------------------------------------------
1183
1184//==============================================================================
1185/// @brief Set enum setting of addon.
1186///
1187/// The setting name relate to names used in his <b>settings.xml</b> file.
1188///
1189/// @param[in] settingName The name of setting
1190/// @param[in] settingValue The setting value to write
1191///
1192/// @remark The enums are used as integer inside settings.xml.
1193///
1194///
1195/// ----------------------------------------------------------------------------
1196///
1197/// **Example:**
1198/// ~~~~~~~~~~~~~{.cpp}
1199/// #include <kodi/General.h>
1200///
1201/// enum myEnumValue
1202/// {
1203/// valueA,
1204/// valueB,
1205/// valueC
1206/// };
1207///
1208/// myEnumValue value = valueA;
1209/// kodi::SetSettingEnum<myEnumValue>("my_enum_value", value);
1210/// ~~~~~~~~~~~~~
1211///
1212template<typename enumType>
1213inline void ATTRIBUTE_HIDDEN SetSettingEnum(const std::string& settingName, enumType settingValue)
1214{
1215 using namespace kodi::addon;
1216
1217 CAddonBase::m_interface->toKodi->set_setting_int(CAddonBase::m_interface->toKodi->kodiBase,
1218 settingName.c_str(),
1219 static_cast<int>(settingValue));
1220}
1221//------------------------------------------------------------------------------
1222
1223/*!@}*/
1224
1225//============================================================================
1226///
1227inline std::string ATTRIBUTE_HIDDEN TranslateAddonStatus(ADDON_STATUS status)
1228{
1229 switch (status)
1230 {
1231 case ADDON_STATUS_OK:
1232 return "OK";
1233 case ADDON_STATUS_LOST_CONNECTION:
1234 return "Lost Connection";
1235 case ADDON_STATUS_NEED_RESTART:
1236 return "Need Restart";
1237 case ADDON_STATUS_NEED_SETTINGS:
1238 return "Need Settings";
1239 case ADDON_STATUS_UNKNOWN:
1240 return "Unknown error";
1241 case ADDON_STATUS_PERMANENT_FAILURE:
1242 return "Permanent failure";
1243 case ADDON_STATUS_NOT_IMPLEMENTED:
1244 return "Not implemented";
1245 default:
1246 break;
1247 }
1248 return "Unknown";
1249}
1250//----------------------------------------------------------------------------
1251
1252//==============================================================================
1253/// @ingroup cpp_kodi
1254/// @brief Returns a function table to a named interface
1255///
1256/// @return pointer to struct containing interface functions
1257///
1258///
1259/// ------------------------------------------------------------------------
1260///
1261/// **Example:**
1262/// ~~~~~~~~~~~~~{.cpp}
1263/// #include <kodi/General.h>
1264/// #include <kodi/platform/foo.h>
1265/// ...
1266/// FuncTable_foo *table = kodi::GetPlatformInfo(foo_name, foo_version);
1267/// ...
1268/// ~~~~~~~~~~~~~
1269///
1270inline void* GetInterface(const std::string& name, const std::string& version)
1271{
1272 using namespace kodi::addon;
1273
1274 AddonToKodiFuncTable_Addon* toKodi = CAddonBase::m_interface->toKodi;
1275
1276 return toKodi->get_interface(toKodi->kodiBase, name.c_str(), version.c_str());
1277}
1278//----------------------------------------------------------------------------
1279
1280} /* namespace kodi */
1281
1282/*! addon creation macro
1283 * @todo cleanup this stupid big macro
1284 * This macro includes now all for add-on's needed functions. This becomes a bigger
1285 * rework after everything is done on Kodi itself, currently is this way needed
1286 * to have compatibility with not reworked interfaces.
1287 *
1288 * Becomes really cleaned up soon :D
1289 */
1290#define ADDONCREATOR(AddonClass) \
1291 extern "C" __declspec(dllexport) ADDON_STATUS ADDON_Create( \
1292 KODI_HANDLE addonInterface, const char* /*globalApiVersion*/, void* /*unused*/) \
1293 { \
1294 kodi::addon::CAddonBase::m_interface = static_cast<AddonGlobalInterface*>(addonInterface); \
1295 kodi::addon::CAddonBase::m_interface->addonBase = new AddonClass; \
1296 return static_cast<kodi::addon::CAddonBase*>(kodi::addon::CAddonBase::m_interface->addonBase) \
1297 ->Create(); \
1298 } \
1299 extern "C" __declspec(dllexport) void ADDON_Destroy() \
1300 { \
1301 kodi::addon::CAddonBase::ADDONBASE_Destroy(); \
1302 } \
1303 extern "C" __declspec(dllexport) ADDON_STATUS ADDON_GetStatus() \
1304 { \
1305 return kodi::addon::CAddonBase::ADDONBASE_GetStatus(); \
1306 } \
1307 extern "C" __declspec(dllexport) ADDON_STATUS ADDON_SetSetting(const char* settingName, \
1308 const void* settingValue) \
1309 { \
1310 return kodi::addon::CAddonBase::ADDONBASE_SetSetting(settingName, settingValue); \
1311 } \
1312 extern "C" __declspec(dllexport) const char* ADDON_GetTypeVersion(int type) \
1313 { \
1314 return kodi::addon::GetTypeVersion(type); \
1315 } \
1316 extern "C" __declspec(dllexport) const char* ADDON_GetTypeMinVersion(int type) \
1317 { \
1318 return kodi::addon::GetTypeMinVersion(type); \
1319 } \
1320 AddonGlobalInterface* kodi::addon::CAddonBase::m_interface = nullptr;
1321
1322#endif /* __cplusplus */
diff --git a/xbmc/addons/kodi-dev-kit/include/kodi/AudioEngine.h b/xbmc/addons/kodi-dev-kit/include/kodi/AudioEngine.h
new file mode 100644
index 0000000..36d1dd1
--- /dev/null
+++ b/xbmc/addons/kodi-dev-kit/include/kodi/AudioEngine.h
@@ -0,0 +1,619 @@
1/*
2 * Copyright (C) 2005-2019 Team Kodi
3 * This file is part of Kodi - https://kodi.tv
4 *
5 * SPDX-License-Identifier: GPL-2.0-or-later
6 * See LICENSES/README.md for more information.
7 */
8
9#pragma once
10
11#include "AddonBase.h"
12#include "c-api/audio_engine.h"
13
14#ifdef __cplusplus
15
16namespace kodi
17{
18namespace audioengine
19{
20
21//¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯
22// Main page text for audio engine group by Doxygen.
23//{{{
24
25//==============================================================================
26///
27/// @defgroup cpp_kodi_audioengine Interface - kodi::audioengine
28/// @ingroup cpp
29/// @brief **Audio engine functions**\n
30/// This interface contains auxiliary functions and classes which allow an addon
31/// to play their own individual audio stream in Kodi.
32///
33/// Using @ref cpp_kodi_audioengine_CAEStream "kodi::audioengine::CAEStream",
34/// a class can be created in this regard, about which the necessary stream data and
35/// information are given to Kodi.
36///
37/// Via @ref kodi::audioengine::GetCurrentSinkFormat(), the audio formats currently
38/// processed in Kodi can be called up beforehand in order to adapt your own stream
39/// to them.
40///
41/// However, the created stream can also differ from this because Kodi changes
42/// it to suit it.
43///
44///
45/// ------------------------------------------------------------------------
46///
47/// **Example:**
48/// ~~~~~~~~~~~~~{.cpp}
49///
50/// #include <kodi/AudioEngine.h>
51///
52/// ...
53///
54/// kodi::audioengine::AudioEngineFormat format;
55/// if (!kodi::audioengine::GetCurrentSinkFormat(format))
56/// return false;
57///
58/// format.SetDataFormat(AUDIOENGINE_FMT_FLOATP);
59/// format.SetChannelLayout(std::vector<AudioEngineChannel>(AUDIOENGINE_CH_FL, AUDIOENGINE_CH_FR));
60///
61/// unsigned int myUsedSampleRate = format.GetSampleRate();
62///
63/// ...
64///
65/// kodi::audioengine::CAEStream* stream = new kodi::audioengine::CAEStream(format, AUDIO_STREAM_AUTOSTART);
66///
67/// ~~~~~~~~~~~~~
68///
69/// ------------------------------------------------------------------------
70///
71/// It has the header \ref AudioEngine.h "#include <kodi/AudioEngine.h>" be included
72/// to enjoy it.
73///
74//------------------------------------------------------------------------------
75
76//==============================================================================
77///
78/// @defgroup cpp_kodi_audioengine_Defs Definitions, structures and enumerators
79/// @ingroup cpp_kodi_audioengine
80/// @brief **Library definition values**\n
81/// All audio engine functions associated data structures.
82///
83//------------------------------------------------------------------------------
84
85//}}}
86
87//¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯
88// "C++" related audio engine definitions
89//{{{
90
91//==============================================================================
92/// @defgroup cpp_kodi_audioengine_Defs_AudioEngineFormat class AudioEngineFormat
93/// @ingroup cpp_kodi_audioengine_Defs
94/// @brief **Audio format structure**\n
95/// The audio format structure that fully defines a stream's audio
96/// information.
97///
98/// With the help of this format information, Kodi adjusts its processing
99/// accordingly.
100///
101///@{
102class ATTRIBUTE_HIDDEN AudioEngineFormat
103 : public addon::CStructHdl<AudioEngineFormat, AUDIO_ENGINE_FORMAT>
104{
105public:
106 /*! \cond PRIVATE */
107 AudioEngineFormat()
108 {
109 m_cStructure->m_dataFormat = AUDIOENGINE_FMT_INVALID;
110 m_cStructure->m_sampleRate = 0;
111 m_cStructure->m_encodedRate = 0;
112 m_cStructure->m_frames = 0;
113 m_cStructure->m_frameSize = 0;
114 m_cStructure->m_channelCount = 0;
115
116 for (size_t ch = 0; ch < AUDIOENGINE_CH_MAX; ++ch)
117 m_cStructure->m_channels[ch] = AUDIOENGINE_CH_NULL;
118 }
119 AudioEngineFormat(const AudioEngineFormat& channel) : CStructHdl(channel) {}
120 AudioEngineFormat(const AUDIO_ENGINE_FORMAT* channel) : CStructHdl(channel) {}
121 AudioEngineFormat(AUDIO_ENGINE_FORMAT* channel) : CStructHdl(channel) {}
122 /*! \endcond */
123
124 /// @defgroup cpp_kodi_audioengine_Defs_AudioEngineFormat_Help *Value Help*
125 /// @ingroup cpp_kodi_audioengine_Defs_AudioEngineFormat
126 ///
127 /// <b>The following table contains values that can be set with @ref cpp_kodi_audioengine_Defs_AudioEngineFormat :</b>
128 /// | Name | Type | Set call | Get call
129 /// |------|------|----------|----------
130 /// | **Data format**, see @ref AudioEngineDataFormat for available types | enum | @ref AudioEngineFormat::SetDataFormat "SetDataFormat" | @ref AudioEngineFormat::GetDataFormat "GetDataFormat"
131 /// | **Sample rate** | unsigned int | @ref AudioEngineFormat::SetSampleRate "SetSampleRate" | @ref AudioEngineFormat::GetSampleRate "GetSampleRate"
132 /// | **Encoded rate** | unsigned int | @ref AudioEngineFormat::SetEncodedRate "SetEncodedRate" | @ref AudioEngineFormat::GetEncodedRate "GetEncodedRate"
133 /// | **Channel layout**, see @ref AudioEngineChannel for available types | std::vector<enum AudioEngineChannel> | @ref AudioEngineFormat::SetChannelLayout "SetChannelLayout" | @ref AudioEngineFormat::GetChannelLayout "GetChannelLayout"
134 /// | **Frames amount** | unsigned int | @ref AudioEngineFormat::SetFramesAmount "SetFramesAmount" | @ref AudioEngineFormat::GetFramesAmount "GetFramesAmount"
135 /// | **Frame size** | unsigned int | @ref AudioEngineFormat::SetFrameSize "SetFrameSize" | @ref AudioEngineFormat::GetFrameSize "GetFrameSize"
136 ///
137 /// Further is @ref AudioEngineFormat::CompareFormat "CompareFormat" included to compare this class with another.
138 ///
139
140 /// @addtogroup cpp_kodi_audioengine_Defs_AudioEngineFormat
141 /// @copydetails cpp_kodi_audioengine_Defs_AudioEngineFormat_Help
142 ///@{
143
144 /// @brief The stream's data format (eg, AUDIOENGINE_FMT_S16LE)
145 void SetDataFormat(enum AudioEngineDataFormat format) { m_cStructure->m_dataFormat = format; }
146
147 /// @brief To get with @ref SetDataFormat changed values.
148 enum AudioEngineDataFormat GetDataFormat() const { return m_cStructure->m_dataFormat; }
149
150 /// @brief The stream's sample rate (eg, 48000)
151 void SetSampleRate(unsigned int rate) { m_cStructure->m_sampleRate = rate; }
152
153 /// @brief To get with @ref SetSampleRate changed values.
154 unsigned int GetSampleRate() const { return m_cStructure->m_sampleRate; }
155
156 /// @brief The encoded streams sample rate if a bitstream, otherwise undefined
157 void SetEncodedRate(unsigned int rate) { m_cStructure->m_encodedRate = rate; }
158
159 /// @brief To get with @ref SetEncodedRate changed values.
160 unsigned int GetEncodedRate() const { return m_cStructure->m_encodedRate; }
161
162 /// @brief The stream's channel layout
163 void SetChannelLayout(const std::vector<enum AudioEngineChannel>& layout)
164 {
165 // Reset first all to empty values to AUDIOENGINE_CH_NULL, in case given list is empty
166 m_cStructure->m_channelCount = 0;
167 for (size_t ch = 0; ch < AUDIOENGINE_CH_MAX; ++ch)
168 m_cStructure->m_channels[ch] = AUDIOENGINE_CH_NULL;
169
170 for (size_t ch = 0; ch < layout.size() && ch < AUDIOENGINE_CH_MAX; ++ch)
171 {
172 m_cStructure->m_channels[ch] = layout[ch];
173 m_cStructure->m_channelCount++;
174 }
175 }
176
177 /// @brief To get with @ref SetChannelLayout changed values.
178 std::vector<enum AudioEngineChannel> GetChannelLayout() const
179 {
180 std::vector<enum AudioEngineChannel> channels;
181 for (size_t ch = 0; ch < AUDIOENGINE_CH_MAX; ++ch)
182 {
183 if (m_cStructure->m_channels[ch] == AUDIOENGINE_CH_NULL)
184 break;
185
186 channels.push_back(m_cStructure->m_channels[ch]);
187 }
188 return channels;
189 }
190
191 /// @brief The number of frames per period
192 void SetFramesAmount(unsigned int frames) { m_cStructure->m_frames = frames; }
193
194 /// @brief To get with @ref SetFramesAmount changed values.
195 unsigned int GetFramesAmount() const { return m_cStructure->m_frames; }
196
197 /// @brief The size of one frame in bytes
198 void SetFrameSize(unsigned int frameSize) { m_cStructure->m_frameSize = frameSize; }
199
200 /// @brief To get with @ref SetFrameSize changed values.
201 unsigned int GetFrameSize() const { return m_cStructure->m_frameSize; }
202
203 /// @brief Function to compare the format structure with another
204 bool CompareFormat(const AudioEngineFormat* fmt)
205 {
206 if (!fmt)
207 {
208 return false;
209 }
210
211 if (m_cStructure->m_dataFormat != fmt->m_cStructure->m_dataFormat ||
212 m_cStructure->m_sampleRate != fmt->m_cStructure->m_sampleRate ||
213 m_cStructure->m_encodedRate != fmt->m_cStructure->m_encodedRate ||
214 m_cStructure->m_frames != fmt->m_cStructure->m_frames ||
215 m_cStructure->m_frameSize != fmt->m_cStructure->m_frameSize ||
216 m_cStructure->m_channelCount != fmt->m_cStructure->m_channelCount)
217 {
218 return false;
219 }
220
221 for (unsigned int ch = 0; ch < AUDIOENGINE_CH_MAX; ++ch)
222 {
223 if (fmt->m_cStructure->m_channels[ch] != m_cStructure->m_channels[ch])
224 {
225 return false;
226 }
227 }
228
229 return true;
230 }
231 ///@}
232};
233///@}
234//----------------------------------------------------------------------------
235
236//}}}
237
238//¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯
239// "C++" AudioEngine addon interface
240//{{{
241
242//============================================================================
243///
244/// @defgroup cpp_kodi_audioengine_CAEStream class CAEStream
245/// @ingroup cpp_kodi_audioengine
246/// @brief **Audio Engine Stream Class**\n
247/// Class that can be created by the addon in order to be able to transfer
248/// audiostream data processed on the addon to Kodi and output it audibly.
249///
250/// This can create individually several times and performed in different
251/// processes simultaneously.
252///
253/// It has the header @ref AudioEngine.h "#include <kodi/AudioEngine.h>" be
254/// included to enjoy it.
255///
256//----------------------------------------------------------------------------
257class ATTRIBUTE_HIDDEN CAEStream
258{
259public:
260 //==========================================================================
261 /// @ingroup cpp_kodi_audioengine_CAEStream
262 /// @brief Contructs new class to an Kodi IAEStream in the format specified.
263 ///
264 /// @param[in] format The data format the incoming audio will be in
265 /// (e.g. \ref AUDIOENGINE_FMT_S16LE)
266 /// @param[in] options [opt] A bit field of stream options (see: enum \ref AudioEngineStreamOptions)
267 ///
268 ///
269 /// ------------------------------------------------------------------------
270 ///
271 /// @copydetails cpp_kodi_audioengine_Defs_AudioEngineFormat_Help
272 ///
273 /// ------------------------------------------------------------------------
274 ///
275 /// **Bit options to pass (on Kodi by <c>IAE::MakeStream</c>)**
276 ///
277 /// | enum AEStreamOptions | Value: | Description:
278 /// |----------------------------:|:------:|:-----------------------------------
279 /// | AUDIO_STREAM_FORCE_RESAMPLE | 1 << 0 | Force resample even if rates match
280 /// | AUDIO_STREAM_PAUSED | 1 << 1 | Create the stream paused
281 /// | AUDIO_STREAM_AUTOSTART | 1 << 2 | Autostart the stream when enough data is buffered
282 ///
283 ///
284 /// ------------------------------------------------------------------------
285 ///
286 /// **Example:**
287 /// ~~~~~~~~~~~~~{.cpp}
288 ///
289 /// #include <kodi/AudioEngine.h>
290 ///
291 /// ...
292 ///
293 /// kodi::audioengine::AudioEngineFormat format;
294 ///
295 /// format.SetDataFormat(AUDIOENGINE_FMT_FLOATP); /* The stream's data format (eg, AUDIOENGINE_FMT_S16LE) */
296 /// format.SetChannelLayout(std::vector<AudioEngineChannel>(AUDIOENGINE_CH_FL, AUDIOENGINE_CH_FR)); /* The stream's channel layout */
297 /// format.SetSampleRate(48000); /* The stream's sample rate (eg, 48000) */
298 /// format.SetFrameSize(sizeof(float)*2); /* The size of one frame in bytes */
299 /// format.SetFramesAmount(882); /* The number of samples in one frame */
300 ///
301 /// kodi::audioengine::CAEStream* stream = new kodi::audioengine::CAEStream(format, AUDIO_STREAM_AUTOSTART);
302 ///
303 /// ~~~~~~~~~~~~~
304 ///
305 CAEStream(AudioEngineFormat& format, unsigned int options = 0)
306 : m_kodiBase(::kodi::addon::CAddonBase::m_interface->toKodi->kodiBase),
307 m_cb(::kodi::addon::CAddonBase::m_interface->toKodi->kodi_audioengine)
308 {
309 m_StreamHandle = m_cb->make_stream(m_kodiBase, format, options);
310 if (m_StreamHandle == nullptr)
311 {
312 kodi::Log(ADDON_LOG_FATAL, "CAEStream: make_stream failed!");
313 }
314 }
315 //--------------------------------------------------------------------------
316
317 //==========================================================================
318 /// @ingroup cpp_kodi_audioengine_CAEStream
319 /// @brief Class destructor.
320 ///
321 ~CAEStream()
322 {
323 if (m_StreamHandle)
324 {
325 m_cb->free_stream(m_kodiBase, m_StreamHandle);
326 m_StreamHandle = nullptr;
327 }
328 }
329 //--------------------------------------------------------------------------
330
331 //==========================================================================
332 /// @ingroup cpp_kodi_audioengine_CAEStream
333 /// @brief Returns the amount of space available in the stream.
334 ///
335 /// @return The number of bytes AddData will consume
336 ///
337 unsigned int GetSpace() { return m_cb->aestream_get_space(m_kodiBase, m_StreamHandle); }
338 //--------------------------------------------------------------------------
339
340 //==========================================================================
341 /// @ingroup cpp_kodi_audioengine_CAEStream
342 /// @brief Add planar or interleaved PCM data to the stream.
343 ///
344 /// @param[in] data array of pointers to the planes
345 /// @param[in] offset to frame in frames
346 /// @param[in] frames number of frames
347 /// @param[in] pts [opt] presentation timestamp, default is 0
348 /// @param[in] hasDownmix [opt] set true if downmix is present, default is false
349 /// @param[in] centerMixLevel [opt] level to mix left and right to center default is 1.0
350 /// @return The number of frames consumed
351 ///
352 unsigned int AddData(uint8_t* const* data,
353 unsigned int offset,
354 unsigned int frames,
355 double pts = 0,
356 bool hasDownmix = false,
357 double centerMixLevel = 1.0)
358 {
359 return m_cb->aestream_add_data(m_kodiBase, m_StreamHandle, data, offset, frames, pts,
360 hasDownmix, centerMixLevel);
361 }
362 //--------------------------------------------------------------------------
363
364 //==========================================================================
365 /// @ingroup cpp_kodi_audioengine_CAEStream
366 /// @brief Returns the time in seconds that it will take for the next added
367 /// packet to be heard from the speakers.
368 ///
369 /// @return seconds
370 ///
371 double GetDelay() { return m_cb->aestream_get_delay(m_kodiBase, m_StreamHandle); }
372 //--------------------------------------------------------------------------
373
374 //==========================================================================
375 /// @ingroup cpp_kodi_audioengine_CAEStream
376 /// @brief Returns if the stream is buffering.
377 ///
378 /// @return True if the stream is buffering
379 ///
380 bool IsBuffering() { return m_cb->aestream_is_buffering(m_kodiBase, m_StreamHandle); }
381 //--------------------------------------------------------------------------
382
383 //==========================================================================
384 /// @ingroup cpp_kodi_audioengine_CAEStream
385 /// @brief Returns the time in seconds of the stream's cached audio samples.
386 /// Engine buffers excluded.
387 ///
388 /// @return seconds
389 ///
390 double GetCacheTime() { return m_cb->aestream_get_cache_time(m_kodiBase, m_StreamHandle); }
391 //--------------------------------------------------------------------------
392
393 //==========================================================================
394 /// @ingroup cpp_kodi_audioengine_CAEStream
395 /// @brief Returns the total time in seconds of the cache.
396 ///
397 /// @return seconds
398 ///
399 double GetCacheTotal() { return m_cb->aestream_get_cache_total(m_kodiBase, m_StreamHandle); }
400 //--------------------------------------------------------------------------
401
402 //==========================================================================
403 /// @ingroup cpp_kodi_audioengine_CAEStream
404 /// @brief Pauses the stream playback.
405 ///
406 void Pause() { return m_cb->aestream_pause(m_kodiBase, m_StreamHandle); }
407 //--------------------------------------------------------------------------
408
409 //==========================================================================
410 /// @ingroup cpp_kodi_audioengine_CAEStream
411 /// @brief Resumes the stream after pausing
412 ///
413 void Resume() { return m_cb->aestream_resume(m_kodiBase, m_StreamHandle); }
414 //--------------------------------------------------------------------------
415
416 //==========================================================================
417 /// @ingroup cpp_kodi_audioengine_CAEStream
418 /// @brief Start draining the stream.
419 ///
420 /// @param[in] wait [opt] Wait until drain is finished if set to true,
421 /// otherwise it returns direct
422 ///
423 /// @note Once called AddData will not consume more data.
424 ///
425 void Drain(bool wait = true) { return m_cb->aestream_drain(m_kodiBase, m_StreamHandle, wait); }
426 //--------------------------------------------------------------------------
427
428 //==========================================================================
429 /// @ingroup cpp_kodi_audioengine_CAEStream
430 /// @brief Returns true if the is stream draining.
431 ///
432 bool IsDraining() { return m_cb->aestream_is_draining(m_kodiBase, m_StreamHandle); }
433 //--------------------------------------------------------------------------
434
435 //==========================================================================
436 /// @ingroup cpp_kodi_audioengine_CAEStream
437 /// @brief Returns true if the is stream has finished draining.
438 ///
439 bool IsDrained() { return m_cb->aestream_is_drained(m_kodiBase, m_StreamHandle); }
440 //--------------------------------------------------------------------------
441
442 //==========================================================================
443 /// @ingroup cpp_kodi_audioengine_CAEStream
444 /// @brief Flush all buffers dropping the audio data.
445 ///
446 void Flush() { return m_cb->aestream_flush(m_kodiBase, m_StreamHandle); }
447 //--------------------------------------------------------------------------
448
449 //==========================================================================
450 /// @ingroup cpp_kodi_audioengine_CAEStream
451 /// @brief Return the stream's current volume level.
452 ///
453 /// @return The volume level between 0.0 and 1.0
454 ///
455 float GetVolume() { return m_cb->aestream_get_volume(m_kodiBase, m_StreamHandle); }
456 //--------------------------------------------------------------------------
457
458 //==========================================================================
459 /// @ingroup cpp_kodi_audioengine_CAEStream
460 /// @brief Set the stream's volume level.
461 ///
462 /// @param[in] volume The new volume level between 0.0 and 1.0
463 ///
464 void SetVolume(float volume)
465 {
466 return m_cb->aestream_set_volume(m_kodiBase, m_StreamHandle, volume);
467 }
468 //--------------------------------------------------------------------------
469
470 //==========================================================================
471 /// @ingroup cpp_kodi_audioengine_CAEStream
472 /// @brief Gets the stream's volume amplification in linear units.
473 ///
474 /// @return The volume amplification factor between 1.0 and 1000.0
475 ///
476 float GetAmplification() { return m_cb->aestream_get_amplification(m_kodiBase, m_StreamHandle); }
477 //--------------------------------------------------------------------------
478
479 //==========================================================================
480 /// @ingroup cpp_kodi_audioengine_CAEStream
481 /// @brief Sets the stream's volume amplification in linear units.
482 ///
483 /// @param[in] amplify The volume amplification factor between 1.0 and 1000.0
484 ///
485 void SetAmplification(float amplify)
486 {
487 return m_cb->aestream_set_amplification(m_kodiBase, m_StreamHandle, amplify);
488 }
489 //--------------------------------------------------------------------------
490
491 //==========================================================================
492 /// @ingroup cpp_kodi_audioengine_CAEStream
493 /// @brief Returns the size of one audio frame in bytes (channelCount * resolution).
494 ///
495 /// @return The size in bytes of one frame
496 ///
497 unsigned int GetFrameSize() const
498 {
499 return m_cb->aestream_get_frame_size(m_kodiBase, m_StreamHandle);
500 }
501 //--------------------------------------------------------------------------
502
503 //==========================================================================
504 /// @ingroup cpp_kodi_audioengine_CAEStream
505 /// @brief Returns the number of channels the stream is configured to accept.
506 ///
507 /// @return The channel count
508 ///
509 unsigned int GetChannelCount() const
510 {
511 return m_cb->aestream_get_channel_count(m_kodiBase, m_StreamHandle);
512 }
513 //--------------------------------------------------------------------------
514
515 //==========================================================================
516 /// @ingroup cpp_kodi_audioengine_CAEStream
517 /// @brief Returns the stream's sample rate, if the stream is using a dynamic
518 /// sample rate, this value will NOT reflect any changes made by calls to
519 /// SetResampleRatio().
520 ///
521 /// @return The stream's sample rate (eg, 48000)
522 ///
523 unsigned int GetSampleRate() const
524 {
525 return m_cb->aestream_get_sample_rate(m_kodiBase, m_StreamHandle);
526 }
527 //--------------------------------------------------------------------------
528
529 //==========================================================================
530 /// @ingroup cpp_kodi_audioengine_CAEStream
531 /// @brief Return the data format the stream has been configured with.
532 ///
533 /// @return The stream's data format (eg, AUDIOENGINE_FMT_S16LE)
534 ///
535 AudioEngineDataFormat GetDataFormat() const
536 {
537 return m_cb->aestream_get_data_format(m_kodiBase, m_StreamHandle);
538 }
539 //--------------------------------------------------------------------------
540
541 //==========================================================================
542 /// @ingroup cpp_kodi_audioengine_CAEStream
543 /// @brief Return the resample ratio.
544 ///
545 /// @note This will return an undefined value if the stream is not resampling.
546 ///
547 /// @return the current resample ratio or undefined if the stream is not resampling
548 ///
549 double GetResampleRatio()
550 {
551 return m_cb->aestream_get_resample_ratio(m_kodiBase, m_StreamHandle);
552 }
553 //--------------------------------------------------------------------------
554
555 //==========================================================================
556 /// @ingroup cpp_kodi_audioengine_CAEStream
557 /// @brief Sets the resample ratio.
558 ///
559 /// @note This function may return false if the stream is not resampling, if
560 /// you wish to use this be sure to set the AESTREAM_FORCE_RESAMPLE option.
561 ///
562 /// @param[in] ratio the new sample rate ratio, calculated by
563 /// ((double)desiredRate / (double)GetSampleRate())
564 ///
565 void SetResampleRatio(double ratio)
566 {
567 m_cb->aestream_set_resample_ratio(m_kodiBase, m_StreamHandle, ratio);
568 }
569 //--------------------------------------------------------------------------
570
571private:
572 void* m_kodiBase;
573 AddonToKodiFuncTable_kodi_audioengine* m_cb;
574 AEStreamHandle* m_StreamHandle;
575};
576//----------------------------------------------------------------------------
577
578//============================================================================
579/// @ingroup cpp_kodi_audioengine
580/// @brief Get the current sink data format.
581///
582/// @param[in] format Current sink data format. For more details see AudioEngineFormat.
583/// @return Returns true on success, else false.
584///
585///
586/// ------------------------------------------------------------------------
587///
588/// **Example:**
589/// ~~~~~~~~~~~~~{.cpp}
590///
591/// #include <kodi/AudioEngine.h>
592///
593/// ...
594///
595/// kodi::audioengine::AudioEngineFormat format;
596/// if (!kodi::audioengine::GetCurrentSinkFormat(format))
597/// return false;
598///
599/// std::vector<AudioEngineChannel> layout = format.GetChannelLayout();
600///
601/// ...
602/// return true;
603///
604/// ~~~~~~~~~~~~~
605///
606inline bool ATTRIBUTE_HIDDEN GetCurrentSinkFormat(AudioEngineFormat& format)
607{
608 using namespace kodi::addon;
609 return CAddonBase::m_interface->toKodi->kodi_audioengine->get_current_sink_format(
610 CAddonBase::m_interface->toKodi->kodiBase, format);
611}
612//----------------------------------------------------------------------------
613
614//}}}
615
616} // namespace audioengine
617} // namespace kodi
618
619#endif /* __cplusplus */
diff --git a/xbmc/addons/kodi-dev-kit/include/kodi/CMakeLists.txt b/xbmc/addons/kodi-dev-kit/include/kodi/CMakeLists.txt
new file mode 100644
index 0000000..d37078a
--- /dev/null
+++ b/xbmc/addons/kodi-dev-kit/include/kodi/CMakeLists.txt
@@ -0,0 +1,16 @@
1set(HEADERS AddonBase.h
2 AudioEngine.h
3 Filesystem.h
4 General.h
5 Network.h
6 StreamCodec.h
7 StreamCrypto.h
8 versions.h)
9
10if(CORE_SYSTEM_NAME STREQUAL android)
11 list(APPEND SOURCES platform/android/System.h)
12endif()
13
14if(NOT ENABLE_STATIC_LIBS)
15 core_add_library(addons_kodi-dev-kit_include_kodi)
16endif()
diff --git a/xbmc/addons/kodi-dev-kit/include/kodi/Filesystem.h b/xbmc/addons/kodi-dev-kit/include/kodi/Filesystem.h
new file mode 100644
index 0000000..1cf05fe
--- /dev/null
+++ b/xbmc/addons/kodi-dev-kit/include/kodi/Filesystem.h
@@ -0,0 +1,2367 @@
1/*
2 * Copyright (C) 2005-2018 Team Kodi
3 * This file is part of Kodi - https://kodi.tv
4 *
5 * SPDX-License-Identifier: GPL-2.0-or-later
6 * See LICENSES/README.md for more information.
7 */
8
9#pragma once
10
11#include "AddonBase.h"
12#include "c-api/filesystem.h"
13
14#ifdef __cplusplus
15
16#include <cstring>
17#include <map>
18#include <vector>
19
20namespace kodi
21{
22namespace vfs
23{
24
25//¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯
26// Main page text for filesystem group by Doxygen.
27//{{{
28
29//==============================================================================
30///
31/// @defgroup cpp_kodi_vfs Interface - kodi::vfs
32/// @ingroup cpp
33/// @brief **Virtual filesystem functions**\n
34/// Offers classes and functions for access to the Virtual File Server (VFS)
35/// which you can use to manipulate files and folders.
36///
37/// This system allow the use of ["Special Protocol"](https://kodi.wiki/view/Special_protocol)
38/// where is Kodi's solution to platform dependent directories. Common directory
39/// names are assigned a <b>`special://[name]`</b> path which is passed around
40/// inside Kodi and then translated to the platform specific path before the
41/// operating system sees it. This helps keep most of the platform mess
42/// centralized in the code.\n
43/// To become a correct path back can be @ref TranslateSpecialProtocol() used.
44///
45/// It has the header @ref Filesystem.h "#include <kodi/Filesystem.h>" be
46/// included to enjoy it.
47///
48//------------------------------------------------------------------------------
49
50//==============================================================================
51/// @defgroup cpp_kodi_vfs_Defs Definitions, structures and enumerators
52/// @ingroup cpp_kodi_vfs
53/// @brief **Virtual file Server definition values**\n
54/// All to VFS system functions associated data structures.
55///
56//------------------------------------------------------------------------------
57
58//==============================================================================
59/// @defgroup cpp_kodi_vfs_Directory 1. Directory functions
60/// @ingroup cpp_kodi_vfs
61/// @brief **Globally available directories related functions**\n
62/// Used to perform typical operations with it.
63///
64//------------------------------------------------------------------------------
65
66//==============================================================================
67/// @defgroup cpp_kodi_vfs_File 2. File functions
68/// @ingroup cpp_kodi_vfs
69/// @brief **Globally available file related functions**\n
70/// Used to perform typical operations with it.
71///
72//------------------------------------------------------------------------------
73
74//==============================================================================
75/// @defgroup cpp_kodi_vfs_General 3. General functions
76/// @ingroup cpp_kodi_vfs
77/// @brief **Other globally available functions**\n
78/// Used to perform typical operations with it.
79///
80//------------------------------------------------------------------------------
81
82//}}}
83
84//¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯
85// "C++" related filesystem definitions
86//{{{
87
88//==============================================================================
89/// @defgroup cpp_kodi_vfs_Defs_FileStatus class FileStatus
90/// @ingroup cpp_kodi_vfs_Defs
91/// @brief **File information status**\n
92/// Used on kodi::vfs::StatFile() to get detailed information about a file.
93///
94//@{
95class ATTRIBUTE_HIDDEN FileStatus : public kodi::addon::CStructHdl<FileStatus, STAT_STRUCTURE>
96{
97public:
98 /*! \cond PRIVATE */
99 FileStatus() { memset(m_cStructure, 0, sizeof(STAT_STRUCTURE)); }
100 FileStatus(const FileStatus& channel) : CStructHdl(channel) {}
101 FileStatus(const STAT_STRUCTURE* channel) : CStructHdl(channel) {}
102 FileStatus(STAT_STRUCTURE* channel) : CStructHdl(channel) {}
103 /*! \endcond */
104
105 /// @defgroup cpp_kodi_vfs_Defs_FileStatus_Help *Value Help*
106 /// @ingroup cpp_kodi_vfs_Defs_FileStatus
107 /// ----------------------------------------------------------------------------
108 ///
109 /// <b>The following table contains values that can be set with @ref cpp_kodi_vfs_Defs_FileStatus :</b>
110 /// | Name | Type | Set call | Get call
111 /// |------|------|----------|----------
112 /// | **ID of device containing file** | `uint32_t` | @ref FileStatus::SetDeviceId "SetDeviceId" | @ref FileStatus::GetDeviceId "GetDeviceId"
113 /// | **Represent file serial numbers** | `uint64_t` | @ref FileStatus::SetFileSerialNumber "SetFileSerialNumber" | @ref FileStatus::GetFileSerialNumber "GetFileSerialNumber"
114 /// | **Total size, in bytes** | `uint64_t` | @ref FileStatus::SetSize "SetSize" | @ref FileStatus::GetSize "GetSize"
115 /// | **Time of last access** | `time_t` | @ref FileStatus::SetAccessTime "SetAccessTime" | @ref FileStatus::GetAccessTime "GetAccessTime"
116 /// | **Time of last modification** | `time_t` | @ref FileStatus::SetModificationTime "SetModificationTime" | @ref FileStatus::GetModificationTime "GetModificationTime"
117 /// | **Time of last status change** | `time_t` | @ref FileStatus::SetStatusTime "SetStatusTime" | @ref FileStatus::GetStatusTime "GetStatusTime"
118 /// | **Stat url is a directory** | `bool` | @ref FileStatus::SetIsDirectory "SetIsDirectory" | @ref FileStatus::GetIsDirectory "GetIsDirectory"
119 /// | **Stat url as a symbolic link** | `bool` | @ref FileStatus::SetIsSymLink "SetIsSymLink" | @ref FileStatus::GetIsSymLink "GetIsSymLink"
120 /// | **Stat url as a block special** | `bool` | @ref FileStatus::SetIsBlock "SetIsBlock" | @ref FileStatus::GetIsBlock "GetIsBlock"
121 /// | **Stat url as a character special** | `bool` | @ref FileStatus::SetIsCharacter "SetIsCharacter" | @ref FileStatus::GetIsCharacter "GetIsCharacter"
122 /// | **Stat url as a FIFO special** | `bool` | @ref FileStatus::SetIsFifo "SetIsFifo" | @ref FileStatus::GetIsFifo "GetIsFifo"
123 /// | **Stat url as a regular** | `bool` | @ref FileStatus::SetIsRegular "SetIsRegular" | @ref FileStatus::GetIsRegular "GetIsRegular"
124 /// | **Stat url as a socket** | `bool` | @ref FileStatus::SetIsSocket "SetIsSocket" | @ref FileStatus::GetIsSocket "GetIsSocket"
125 ///
126
127 /// @addtogroup cpp_kodi_vfs_Defs_FileStatus
128 /// @copydetails cpp_kodi_vfs_Defs_FileStatus_Help
129 //@{
130
131 /// @brief Set ID of device containing file.
132 void SetDeviceId(uint32_t deviceId) { m_cStructure->deviceId = deviceId; }
133
134 /// @brief Get ID of device containing file.
135 uint32_t GetDeviceId() const { return m_cStructure->deviceId; }
136
137 /// @brief Set the file serial number, which distinguishes this file from all other files on the same device.
138 void SetFileSerialNumber(uint64_t fileSerialNumber) { m_cStructure->fileSerialNumber = fileSerialNumber; }
139
140 /// @brief Get the file serial number, which distinguishes this file from all other files on the same device.
141 uint64_t GetFileSerialNumber() const { return m_cStructure->fileSerialNumber; }
142
143 /// @brief Set total size, in bytes.
144 void SetSize(uint64_t size) { m_cStructure->size = size; }
145
146 /// @brief Get total size, in bytes.
147 uint64_t GetSize() const { return m_cStructure->size; }
148
149 /// @brief Set time of last access.
150 void SetAccessTime(time_t accessTime) { m_cStructure->accessTime = accessTime; }
151
152 /// @brief Get time of last access.
153 time_t GetAccessTime() const { return m_cStructure->accessTime; }
154
155 /// @brief Set time of last modification.
156 void SetModificationTime(time_t modificationTime)
157 {
158 m_cStructure->modificationTime = modificationTime;
159 }
160
161 /// @brief Get time of last modification.
162 time_t GetModificationTime() const { return m_cStructure->modificationTime; }
163
164 /// @brief Set time of last status change.
165 void SetStatusTime(time_t statusTime) { m_cStructure->statusTime = statusTime; }
166
167 /// @brief Get time of last status change.
168 time_t GetStatusTime() const { return m_cStructure->statusTime; }
169
170 /// @brief Set the stat url is a directory.
171 void SetIsDirectory(bool isDirectory) { m_cStructure->isDirectory = isDirectory; }
172
173 /// @brief The stat url is a directory if returns true.
174 bool GetIsDirectory() const { return m_cStructure->isDirectory; }
175
176 /// @brief Set stat url as a symbolic link.
177 void SetIsSymLink(bool isSymLink) { m_cStructure->isSymLink = isSymLink; }
178
179 /// @brief Get stat url is a symbolic link.
180 bool GetIsSymLink() const { return m_cStructure->isSymLink; }
181
182 /// @brief Set stat url as a block special.
183 void SetIsBlock(bool isBlock) { m_cStructure->isBlock = isBlock; }
184
185 /// @brief Get stat url is a block special.
186 bool GetIsBlock() const { return m_cStructure->isBlock; }
187
188 /// @brief Set stat url as a character special.
189 void SetIsCharacter(bool isCharacter) { m_cStructure->isCharacter = isCharacter; }
190
191 /// @brief Get stat url is a character special.
192 bool GetIsCharacter() const { return m_cStructure->isCharacter; }
193
194 /// @brief Set stat url as a FIFO special.
195 void SetIsFifo(bool isFifo) { m_cStructure->isFifo = isFifo; }
196
197 /// @brief Get stat url is a FIFO special.
198 bool GetIsFifo() const { return m_cStructure->isFifo; }
199
200 /// @brief Set stat url as a regular.
201 void SetIsRegular(bool isRegular) { m_cStructure->isRegular = isRegular; }
202
203 /// @brief Get stat url is a regular.
204 bool GetIsRegular() const { return m_cStructure->isRegular; }
205
206 /// @brief Set stat url is a socket.
207 void SetIsSocket(bool isSocket) { m_cStructure->isSocket = isSocket; }
208
209 /// @brief Get stat url is a regular.
210 bool GetIsSocket() const { return m_cStructure->isSocket; }
211 //@}
212};
213//@}
214//------------------------------------------------------------------------------
215
216//==============================================================================
217/// @defgroup cpp_kodi_vfs_Defs_CacheStatus class CacheStatus
218/// @ingroup cpp_kodi_vfs_Defs
219/// @brief **Cache information status**\n
220/// Used on kodi::vfs::CFile::IoControlGetCacheStatus() to get running cache
221/// status of proccessed stream.
222///
223//@{
224class ATTRIBUTE_HIDDEN CacheStatus
225 : public kodi::addon::CStructHdl<CacheStatus, VFS_CACHE_STATUS_DATA>
226{
227public:
228 /*! \cond PRIVATE */
229 CacheStatus() { memset(m_cStructure, 0, sizeof(VFS_CACHE_STATUS_DATA)); }
230 CacheStatus(const CacheStatus& channel) : CStructHdl(channel) {}
231 CacheStatus(const VFS_CACHE_STATUS_DATA* channel) : CStructHdl(channel) {}
232 CacheStatus(VFS_CACHE_STATUS_DATA* channel) : CStructHdl(channel) {}
233 /*! \endcond */
234
235 /// @defgroup cpp_kodi_vfs_Defs_CacheStatus_Help *Value Help*
236 /// @ingroup cpp_kodi_vfs_Defs_CacheStatus
237 /// ----------------------------------------------------------------------------
238 ///
239 /// <b>The following table contains values that can be set with @ref cpp_kodi_vfs_Defs_CacheStatus :</b>
240 /// | Name | Type | Set call | Get call
241 /// |------|------|----------|----------
242 /// | **Number of bytes cached** | `uint64_t` | @ref CacheStatus::SetForward "SetForward" | @ref CacheStatus::GetForward "GetForward"
243 /// | **Maximum number of bytes per second** | `unsigned int` | @ref CacheStatus::SetMaxRate "SetMaxRate" | @ref CacheStatus::GetMaxRate "GetMaxRate"
244 /// | **Average read rate from source file** | `unsigned int` | @ref CacheStatus::SetCurrentRate "SetCurrentRate" | @ref CacheStatus::GetCurrentRate "GetCurrentRate"
245 /// | **Cache low speed condition detected** | `bool` | @ref CacheStatus::SetLowspeed "SetLowspeed" | @ref CacheStatus::GetLowspeed "GetLowspeed"
246 ///
247
248 /// @addtogroup cpp_kodi_vfs_Defs_CacheStatus
249 /// @copydetails cpp_kodi_vfs_Defs_CacheStatus_Help
250 //@{
251
252 /// @brief Set number of bytes cached forward of current position.
253 void SetForward(uint64_t forward) { m_cStructure->forward = forward; }
254
255 /// @brief Get number of bytes cached forward of current position.
256 uint64_t GetForward() { return m_cStructure->forward; }
257
258 /// @brief Set maximum number of bytes per second cache is allowed to fill.
259 void SetMaxRate(unsigned int maxrate) { m_cStructure->maxrate = maxrate; }
260
261 /// @brief Set maximum number of bytes per second cache is allowed to fill.
262 unsigned int GetMaxRate() { return m_cStructure->maxrate; }
263
264 /// @brief Set average read rate from source file since last position change.
265 void SetCurrentRate(unsigned int currate) { m_cStructure->currate = currate; }
266
267 /// @brief Get average read rate from source file since last position change.
268 unsigned int GetCurrentRate() { return m_cStructure->currate; }
269
270 /// @brief Set cache low speed condition detected.
271 void SetLowspeed(bool lowspeed) { m_cStructure->lowspeed = lowspeed; }
272
273 /// @brief Get cache low speed condition detected.
274 bool GetLowspeed() { return m_cStructure->lowspeed; }
275
276 //@}
277};
278//@}
279//------------------------------------------------------------------------------
280
281//==============================================================================
282/// @defgroup cpp_kodi_vfs_Defs_HttpHeader class HttpHeader
283/// @ingroup cpp_kodi_vfs_Defs
284/// @brief **HTTP header information**\n
285/// The class used to access HTTP header information and get his information.
286///
287/// Used on @ref kodi::vfs::GetHttpHeader().
288///
289/// ----------------------------------------------------------------------------
290///
291/// @copydetails cpp_kodi_vfs_Defs_HttpHeader_Help
292///
293///@{
294class ATTRIBUTE_HIDDEN HttpHeader
295{
296public:
297 //==========================================================================
298 /// @brief Http header parser class constructor.
299 ///
300 HttpHeader()
301 {
302 using namespace ::kodi::addon;
303
304 CAddonBase::m_interface->toKodi->kodi_filesystem->http_header_create(
305 CAddonBase::m_interface->toKodi->kodiBase, &m_handle);
306 }
307 //--------------------------------------------------------------------------
308
309 //==========================================================================
310 /// @brief Class destructor.
311 ///
312 ~HttpHeader()
313 {
314 using namespace ::kodi::addon;
315
316 CAddonBase::m_interface->toKodi->kodi_filesystem->http_header_free(
317 CAddonBase::m_interface->toKodi->kodiBase, &m_handle);
318 }
319 //--------------------------------------------------------------------------
320
321 /// @defgroup cpp_kodi_vfs_Defs_HttpHeader_Help *Value Help*
322 /// @ingroup cpp_kodi_vfs_Defs_HttpHeader
323 ///
324 /// <b>The following table contains values that can be get with @ref cpp_kodi_vfs_Defs_HttpHeader :</b>
325 /// | Description | Type | Get call
326 /// |-------------|------|------------
327 /// | **Get the value associated with this parameter of these HTTP headers** | `std::string` | @ref HttpHeader::GetValue "GetValue"
328 /// | **Get the values as list associated with this parameter of these HTTP headers** | `std::vector<std::string>` | @ref HttpHeader::GetValues "GetValues"
329 /// | **Get the full header string associated with these HTTP headers** | `std::string` | @ref HttpHeader::GetHeader "GetHeader"
330 /// | **Get the mime type associated with these HTTP headers** | `std::string` | @ref HttpHeader::GetMimeType "GetMimeType"
331 /// | **Get the charset associated with these HTTP headers** | `std::string` | @ref HttpHeader::GetCharset "GetCharset"
332 /// | **The protocol line associated with these HTTP headers** | `std::string` | @ref HttpHeader::GetProtoLine "GetProtoLine"
333 ///
334
335 /// @addtogroup cpp_kodi_vfs_Defs_HttpHeader
336 ///@{
337
338 //==========================================================================
339 /// @brief Get the value associated with this parameter of these HTTP
340 /// headers.
341 ///
342 /// @param[in] param The name of the parameter a value is required for
343 /// @return The value found
344 ///
345 std::string GetValue(const std::string& param) const
346 {
347 using namespace ::kodi::addon;
348
349 if (!m_handle.handle)
350 return "";
351
352 std::string protoLine;
353 char* string = m_handle.get_value(CAddonBase::m_interface->toKodi->kodiBase, m_handle.handle,
354 param.c_str());
355 if (string != nullptr)
356 {
357 protoLine = string;
358 CAddonBase::m_interface->toKodi->free_string(CAddonBase::m_interface->toKodi->kodiBase,
359 string);
360 }
361 return protoLine;
362 }
363 //--------------------------------------------------------------------------
364
365 //==========================================================================
366 /// @brief Get the values as list associated with this parameter of these
367 /// HTTP headers.
368 ///
369 /// @param[in] param The name of the parameter values are required for
370 /// @return The values found
371 ///
372 std::vector<std::string> GetValues(const std::string& param) const
373 {
374 using namespace kodi::addon;
375
376 if (!m_handle.handle)
377 return std::vector<std::string>();
378
379 int numValues = 0;
380 char** res(m_handle.get_values(CAddonBase::m_interface->toKodi->kodiBase, m_handle.handle,
381 param.c_str(), &numValues));
382 if (res)
383 {
384 std::vector<std::string> vecReturn;
385 for (int i = 0; i < numValues; ++i)
386 {
387 vecReturn.emplace_back(res[i]);
388 }
389 CAddonBase::m_interface->toKodi->free_string_array(CAddonBase::m_interface->toKodi->kodiBase,
390 res, numValues);
391 return vecReturn;
392 }
393 return std::vector<std::string>();
394 }
395 //--------------------------------------------------------------------------
396
397 //==========================================================================
398 /// @brief Get the full header string associated with these HTTP headers.
399 ///
400 /// @return The header as a string
401 ///
402 std::string GetHeader() const
403 {
404 using namespace ::kodi::addon;
405
406 if (!m_handle.handle)
407 return "";
408
409 std::string header;
410 char* string = m_handle.get_header(CAddonBase::m_interface->toKodi->kodiBase, m_handle.handle);
411 if (string != nullptr)
412 {
413 header = string;
414 CAddonBase::m_interface->toKodi->free_string(CAddonBase::m_interface->toKodi->kodiBase,
415 string);
416 }
417 return header;
418 }
419 //--------------------------------------------------------------------------
420
421 //==========================================================================
422 /// @brief Get the mime type associated with these HTTP headers.
423 ///
424 /// @return The mime type
425 ///
426 std::string GetMimeType() const
427 {
428 using namespace ::kodi::addon;
429
430 if (!m_handle.handle)
431 return "";
432
433 std::string protoLine;
434 char* string =
435 m_handle.get_mime_type(CAddonBase::m_interface->toKodi->kodiBase, m_handle.handle);
436 if (string != nullptr)
437 {
438 protoLine = string;
439 CAddonBase::m_interface->toKodi->free_string(CAddonBase::m_interface->toKodi->kodiBase,
440 string);
441 }
442 return protoLine;
443 }
444 //--------------------------------------------------------------------------
445
446 //==========================================================================
447 /// @brief Get the charset associated with these HTTP headers.
448 ///
449 /// @return The charset
450 ///
451 std::string GetCharset() const
452 {
453 using namespace ::kodi::addon;
454
455 if (!m_handle.handle)
456 return "";
457
458 std::string protoLine;
459 char* string = m_handle.get_charset(CAddonBase::m_interface->toKodi->kodiBase, m_handle.handle);
460 if (string != nullptr)
461 {
462 protoLine = string;
463 CAddonBase::m_interface->toKodi->free_string(CAddonBase::m_interface->toKodi->kodiBase,
464 string);
465 }
466 return protoLine;
467 }
468 //--------------------------------------------------------------------------
469
470 //==========================================================================
471 /// @brief The protocol line associated with these HTTP headers.
472 ///
473 /// @return The protocol line
474 ///
475 std::string GetProtoLine() const
476 {
477 using namespace ::kodi::addon;
478
479 if (!m_handle.handle)
480 return "";
481
482 std::string protoLine;
483 char* string =
484 m_handle.get_proto_line(CAddonBase::m_interface->toKodi->kodiBase, m_handle.handle);
485 if (string != nullptr)
486 {
487 protoLine = string;
488 CAddonBase::m_interface->toKodi->free_string(CAddonBase::m_interface->toKodi->kodiBase,
489 string);
490 }
491 return protoLine;
492 }
493 //--------------------------------------------------------------------------
494
495 ///@}
496
497 KODI_HTTP_HEADER m_handle;
498};
499///@}
500//----------------------------------------------------------------------------
501
502//==============================================================================
503/// @defgroup cpp_kodi_vfs_CDirEntry class CDirEntry
504/// @ingroup cpp_kodi_vfs_Defs
505///
506/// @brief **Virtual file server directory entry**\n
507/// This class is used as an entry for files and folders in
508/// kodi::vfs::GetDirectory().
509///
510///
511/// ------------------------------------------------------------------------
512///
513/// **Example:**
514/// ~~~~~~~~~~~~~{.cpp}
515/// #include <kodi/Filesystem.h>
516///
517/// ...
518///
519/// std::vector<kodi::vfs::CDirEntry> items;
520/// kodi::vfs::GetDirectory("special://temp", "", items);
521///
522/// fprintf(stderr, "Directory have %lu entries\n", items.size());
523/// for (unsigned long i = 0; i < items.size(); i++)
524/// {
525/// char buff[20];
526/// time_t now = items[i].DateTime();
527/// strftime(buff, 20, "%Y-%m-%d %H:%M:%S", gmtime(&now));
528/// fprintf(stderr, " - %04lu -- Folder: %s -- Name: %s -- Path: %s -- Time: %s\n",
529/// i+1,
530/// items[i].IsFolder() ? "yes" : "no ",
531/// items[i].Label().c_str(),
532/// items[i].Path().c_str(),
533/// buff);
534/// }
535/// ~~~~~~~~~~~~~
536///
537/// It has the header @ref Filesystem.h "#include <kodi/Filesystem.h>" be included
538/// to enjoy it.
539///
540//@{
541class ATTRIBUTE_HIDDEN CDirEntry
542{
543public:
544 //============================================================================
545 /// @ingroup cpp_kodi_vfs_CDirEntry
546 /// @brief Constructor for VFS directory entry
547 ///
548 /// @param[in] label [opt] Name to use for entry
549 /// @param[in] path [opt] Used path of the entry
550 /// @param[in] folder [opt] If set entry used as folder
551 /// @param[in] size [opt] If used as file, his size defined there
552 /// @param[in] dateTime [opt] Date time of the entry
553 ///
554 CDirEntry(const std::string& label = "",
555 const std::string& path = "",
556 bool folder = false,
557 int64_t size = -1,
558 time_t dateTime = 0)
559 : m_label(label), m_path(path), m_folder(folder), m_size(size), m_dateTime(dateTime)
560 {
561 }
562 //----------------------------------------------------------------------------
563
564 //============================================================================
565 // @note Not for addon development itself needed, thats why below is
566 // disabled for doxygen!
567 //
568 // @ingroup cpp_kodi_vfs_CDirEntry
569 // @brief Constructor to create own copy
570 //
571 // @param[in] dirEntry pointer to own class type
572 //
573 explicit CDirEntry(const VFSDirEntry& dirEntry)
574 : m_label(dirEntry.label ? dirEntry.label : ""),
575 m_path(dirEntry.path ? dirEntry.path : ""),
576 m_folder(dirEntry.folder),
577 m_size(dirEntry.size),
578 m_dateTime(dirEntry.date_time)
579 {
580 }
581 //----------------------------------------------------------------------------
582
583 /// @defgroup cpp_kodi_vfs_CDirEntry_Help *Value Help*
584 /// @ingroup cpp_kodi_vfs_CDirEntry
585 /// --------------------------------------------------------------------------
586 ///
587 /// <b>The following table contains values that can be set with @ref cpp_kodi_vfs_CDirEntry :</b>
588 /// | Name | Type | Set call | Get call | Clear call |
589 /// |------|------|----------|----------|------------|
590 /// | **Directory entry name** | `std::string` | @ref CDirEntry::SetLabel "SetLabel" | @ref CDirEntry::Label "Label" | |
591 /// | **Title of entry** | `std::string` | @ref CDirEntry::SetTitle "SetTitle" | @ref CDirEntry::Title "Title" | |
592 /// | **Path of the entry** | `std::string` | @ref CDirEntry::SetPath "SetPath" | @ref CDirEntry::Path "Path" | |
593 /// | **Entry is folder** | `bool` | @ref CDirEntry::SetFolder "SetFolder" | @ref CDirEntry::IsFolder "IsFolder" | |
594 /// | **The size of the file** | `int64_t` | @ref CDirEntry::SetSize "SetSize" | @ref CDirEntry::Size "Size" | |
595 /// | **File time and date** | `time_t` | @ref CDirEntry::SetDateTime "SetDateTime" | @ref CDirEntry::DateTime "DateTime" | |
596 /// | **Property entries** | `std::string, std::string` | @ref CDirEntry::AddProperty "AddProperty" | @ref CDirEntry::GetProperties "GetProperties" | @ref CDirEntry::ClearProperties "ClearProperties"
597 ///
598
599 /// @addtogroup cpp_kodi_vfs_CDirEntry
600 /// @copydetails cpp_kodi_vfs_CDirEntry_Help
601 //@{
602
603 //============================================================================
604 /// @brief Get the directory entry name.
605 ///
606 /// @return Name of the entry
607 ///
608 const std::string& Label(void) const { return m_label; }
609 //----------------------------------------------------------------------------
610
611 //============================================================================
612 /// @brief Get the optional title of entry.
613 ///
614 /// @return Title of the entry, if exists
615 ///
616 const std::string& Title(void) const { return m_title; }
617 //----------------------------------------------------------------------------
618
619 //============================================================================
620 /// @brief Get the path of the entry.
621 ///
622 /// @return File system path of the entry
623 ///
624 const std::string& Path(void) const { return m_path; }
625 //----------------------------------------------------------------------------
626
627 //============================================================================
628 /// @brief Used to check entry is folder.
629 ///
630 /// @return true if entry is a folder
631 ///
632 bool IsFolder(void) const { return m_folder; }
633 //----------------------------------------------------------------------------
634
635 //============================================================================
636 /// @brief If file, the size of the file.
637 ///
638 /// @return Defined file size
639 ///
640 int64_t Size(void) const { return m_size; }
641 //----------------------------------------------------------------------------
642
643 //============================================================================
644 /// @brief Get file time and date for a new entry.
645 ///
646 /// @return The with time_t defined date and time of file
647 ///
648 time_t DateTime() { return m_dateTime; }
649 //----------------------------------------------------------------------------
650
651 //============================================================================
652 /// @brief Set the label name.
653 ///
654 /// @param[in] label name of entry
655 ///
656 void SetLabel(const std::string& label) { m_label = label; }
657 //----------------------------------------------------------------------------
658
659 //============================================================================
660 /// @brief Set the title name.
661 ///
662 /// @param[in] title title name of entry
663 ///
664 void SetTitle(const std::string& title) { m_title = title; }
665 //----------------------------------------------------------------------------
666
667 //============================================================================
668 /// @brief Set the path of the entry.
669 ///
670 /// @param[in] path path of entry
671 ///
672 void SetPath(const std::string& path) { m_path = path; }
673 //----------------------------------------------------------------------------
674
675 //============================================================================
676 /// @brief Set the entry defined as folder.
677 ///
678 /// @param[in] folder If true becomes entry defined as folder
679 ///
680 void SetFolder(bool folder) { m_folder = folder; }
681 //----------------------------------------------------------------------------
682
683 //============================================================================
684 /// @brief Set a file size for a new entry.
685 ///
686 /// @param[in] size Size to set for dir entry
687 ///
688 void SetSize(int64_t size) { m_size = size; }
689 //----------------------------------------------------------------------------
690
691 //============================================================================
692 /// @brief Set file time and date for a new entry.
693 ///
694 /// @param[in] dateTime The with time_t defined date and time of file
695 ///
696 void SetDateTime(time_t dateTime) { m_dateTime = dateTime; }
697 //----------------------------------------------------------------------------
698
699 //============================================================================
700 /// @brief Add a by string defined property entry to directory entry.
701 ///
702 /// @note A property can be used to add some special information about a file
703 /// or directory entry, this can be used on other places to do the right work
704 /// of them.
705 ///
706 /// @param[in] id Identification name of property
707 /// @param[in] value The property value to add by given id
708 ///
709 void AddProperty(const std::string& id, const std::string& value) { m_properties[id] = value; }
710 //----------------------------------------------------------------------------
711
712 //============================================================================
713 /// @brief Clear all present properties.
714 ///
715 void ClearProperties() { m_properties.clear(); }
716 //----------------------------------------------------------------------------
717
718 //============================================================================
719 /// @brief Get the present properties list on directory entry.
720 ///
721 /// @return map with all present properties
722 ///
723 const std::map<std::string, std::string>& GetProperties() const { return m_properties; }
724 //----------------------------------------------------------------------------
725
726 //@}
727
728private:
729 std::string m_label;
730 std::string m_title;
731 std::string m_path;
732 std::map<std::string, std::string> m_properties;
733 bool m_folder;
734 int64_t m_size;
735 time_t m_dateTime;
736};
737//@}
738//------------------------------------------------------------------------------
739
740//}}}
741
742//¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯
743// "C++" Directory related functions
744//{{{
745
746//==============================================================================
747/// @ingroup cpp_kodi_vfs_Directory
748/// @brief Make a directory.
749///
750/// The kodi::vfs::CreateDirectory() function shall create a
751/// new directory with name path.
752///
753/// The newly created directory shall be an empty directory.
754///
755/// @param[in] path Path to the directory.
756/// @return Upon successful completion, CreateDirectory() shall return true.
757/// Otherwise false shall be returned, no directory shall be created.
758///
759///
760/// -------------------------------------------------------------------------
761///
762/// **Example:**
763/// ~~~~~~~~~~~~~{.cpp}
764/// #include <kodi/Filesystem.h>
765/// ...
766/// std::string directory = "C:\\my_dir";
767/// bool ret = kodi::vfs::CreateDirectory(directory);
768/// fprintf(stderr, "Directory '%s' successfull created: %s\n", directory.c_str(), ret ? "yes" : "no");
769/// ...
770/// ~~~~~~~~~~~~~
771///
772inline bool ATTRIBUTE_HIDDEN CreateDirectory(const std::string& path)
773{
774 using namespace kodi::addon;
775
776 return CAddonBase::m_interface->toKodi->kodi_filesystem->create_directory(
777 CAddonBase::m_interface->toKodi->kodiBase, path.c_str());
778}
779//------------------------------------------------------------------------------
780
781//==============================================================================
782/// @ingroup cpp_kodi_vfs_Directory
783/// @brief Verifying the Existence of a Directory.
784///
785/// The kodi::vfs::DirectoryExists() method determines whether
786/// a specified folder exists.
787///
788/// @param[in] path Path to the directory.
789/// @return True when it exists, false otherwise.
790///
791///
792/// -------------------------------------------------------------------------
793///
794/// **Example:**
795/// ~~~~~~~~~~~~~{.cpp}
796/// #include <kodi/Filesystem.h>
797/// ...
798/// std::string directory = "C:\\my_dir";
799/// bool ret = kodi::vfs::DirectoryExists(directory);
800/// fprintf(stderr, "Directory '%s' present: %s\n", directory.c_str(), ret ? "yes" : "no");
801/// ...
802/// ~~~~~~~~~~~~~
803///
804inline bool ATTRIBUTE_HIDDEN DirectoryExists(const std::string& path)
805{
806 using namespace kodi::addon;
807
808 return CAddonBase::m_interface->toKodi->kodi_filesystem->directory_exists(
809 CAddonBase::m_interface->toKodi->kodiBase, path.c_str());
810}
811//------------------------------------------------------------------------------
812
813//==============================================================================
814/// @ingroup cpp_kodi_vfs_Directory
815/// @brief Removes a directory.
816///
817/// The kodi::vfs::RemoveDirectory() function shall remove a
818/// directory whose name is given by path.
819///
820/// @param[in] path Path to the directory.
821/// @param[in] recursive [opt] Remove directory recursive (default is false)
822/// @return Upon successful completion, the function RemoveDirectory() shall
823/// return true. Otherwise, false shall be returned, and errno set
824/// to indicate the error. If false is returned, the named directory
825/// shall not be changed.
826///
827///
828/// -------------------------------------------------------------------------
829///
830/// **Example:**
831/// ~~~~~~~~~~~~~{.cpp}
832/// #include <kodi/Filesystem.h>
833/// ...
834/// bool ret = kodi::vfs::RemoveDirectory("C:\\my_dir");
835/// ...
836/// ~~~~~~~~~~~~~
837///
838inline bool ATTRIBUTE_HIDDEN RemoveDirectory(const std::string& path, bool recursive = false)
839{
840 using namespace kodi::addon;
841
842 if (!recursive)
843 return CAddonBase::m_interface->toKodi->kodi_filesystem->remove_directory(
844 CAddonBase::m_interface->toKodi->kodiBase, path.c_str());
845 else
846 return CAddonBase::m_interface->toKodi->kodi_filesystem->remove_directory_recursive(
847 CAddonBase::m_interface->toKodi->kodiBase, path.c_str());
848}
849//------------------------------------------------------------------------------
850
851//==============================================================================
852/// @ingroup cpp_kodi_vfs_Directory
853/// @brief Lists a directory.
854///
855/// Return the list of files and directories which have been found in the
856/// specified directory and which respect the given constraint.
857///
858/// It can handle the normal OS dependent paths and also the special virtual
859/// filesystem from Kodi what starts with \b special://.
860///
861/// @param[in] path The path in which the files and directories are located.
862/// @param[in] mask Mask to filter out requested files, e.g. "*.avi|*.mpg" to
863/// files with this ending.
864/// @param[out] items The returned list directory entries.
865/// @return True if listing was successful, false otherwise.
866///
867///
868/// -------------------------------------------------------------------------
869///
870/// **Example:**
871/// ~~~~~~~~~~~~~{.cpp}
872/// #include <kodi/Filesystem.h>
873///
874/// std::vector<kodi::vfs::CDirEntry> items;
875/// kodi::vfs::GetDirectory("special://temp", "", items);
876///
877/// fprintf(stderr, "Directory have %lu entries\n", items.size());
878/// for (unsigned long i = 0; i < items.size(); i++)
879/// {
880/// fprintf(stderr, " - %04lu -- Folder: %s -- Name: %s -- Path: %s\n",
881/// i+1,
882/// items[i].IsFolder() ? "yes" : "no ",
883/// items[i].Label().c_str(),
884/// items[i].Path().c_str());
885/// }
886/// ~~~~~~~~~~~~~
887inline bool ATTRIBUTE_HIDDEN GetDirectory(const std::string& path,
888 const std::string& mask,
889 std::vector<kodi::vfs::CDirEntry>& items)
890{
891 using namespace kodi::addon;
892
893 VFSDirEntry* dir_list = nullptr;
894 unsigned int num_items = 0;
895 if (CAddonBase::m_interface->toKodi->kodi_filesystem->get_directory(
896 CAddonBase::m_interface->toKodi->kodiBase, path.c_str(), mask.c_str(), &dir_list,
897 &num_items))
898 {
899 if (dir_list)
900 {
901 for (unsigned int i = 0; i < num_items; ++i)
902 items.emplace_back(dir_list[i]);
903
904 CAddonBase::m_interface->toKodi->kodi_filesystem->free_directory(
905 CAddonBase::m_interface->toKodi->kodiBase, dir_list, num_items);
906 }
907
908 return true;
909 }
910 return false;
911}
912//------------------------------------------------------------------------------
913
914//}}}
915
916//¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯
917// "C++" File related functions
918//{{{
919
920//==============================================================================
921/// @ingroup cpp_kodi_vfs_File
922/// @brief Check if a file exists.
923///
924/// @param[in] filename The filename to check.
925/// @param[in] usecache Check in file cache.
926/// @return true if the file exists false otherwise.
927///
928///
929/// -------------------------------------------------------------------------
930///
931/// **Example:**
932/// ~~~~~~~~~~~~~{.cpp}
933/// #include <kodi/Filesystem.h>
934/// ...
935/// bool exists = kodi::vfs::FileExists("special://temp/kodi.log");
936/// fprintf(stderr, "Log file should be always present, is it present? %s\n", exists ? "yes" : "no");
937/// ~~~~~~~~~~~~~
938///
939inline bool ATTRIBUTE_HIDDEN FileExists(const std::string& filename, bool usecache = false)
940{
941 using namespace kodi::addon;
942
943 return CAddonBase::m_interface->toKodi->kodi_filesystem->file_exists(
944 CAddonBase::m_interface->toKodi->kodiBase, filename.c_str(), usecache);
945}
946//------------------------------------------------------------------------------
947
948//==============================================================================
949/// @ingroup cpp_kodi_vfs_File
950/// @brief Get file status.
951///
952/// These function return information about a file. Execute (search)
953/// permission is required on all of the directories in path that
954/// lead to the file.
955///
956/// The call return a stat structure, which contains the on
957/// @ref cpp_kodi_vfs_Defs_FileStatus defined values.
958///
959/// @warning Not all of the OS file systems implement all of the time fields.
960///
961/// @param[in] filename The filename to read the status from.
962/// @param[out] buffer The file status is written into this buffer.
963/// @return On success, trur is returned. On error, false is returned
964///
965///
966/// @copydetails cpp_kodi_vfs_Defs_FileStatus_Help
967///
968/// -------------------------------------------------------------------------
969///
970/// **Example:**
971/// ~~~~~~~~~~~~~{.cpp}
972/// #include <kodi/Filesystem.h>
973/// ...
974/// kodi::vfs::FileStatus statFile;
975/// int ret = kodi::vfs::StatFile("special://temp/kodi.log", statFile);
976/// fprintf(stderr, "deviceId (ID of device containing file) = %u\n"
977/// "size (total size, in bytes) = %lu\n"
978/// "accessTime (time of last access) = %lu\n"
979/// "modificationTime (time of last modification) = %lu\n"
980/// "statusTime (time of last status change) = %lu\n"
981/// "isDirectory (The stat url is a directory) = %s\n"
982/// "isSymLink (The stat url is a symbolic link) = %s\n"
983/// "Return value = %i\n",
984/// statFile.GetDeviceId(),
985/// statFile.GetSize(),
986/// statFile.GetAccessTime(),
987/// statFile.GetModificationTime(),
988/// statFile.GetStatusTime(),
989/// statFile.GetIsDirectory() ? "true" : "false",
990/// statFile.GetIsSymLink() ? "true" : "false",
991/// ret);
992/// ~~~~~~~~~~~~~
993///
994inline bool ATTRIBUTE_HIDDEN StatFile(const std::string& filename, kodi::vfs::FileStatus& buffer)
995{
996 using namespace kodi::addon;
997
998 return CAddonBase::m_interface->toKodi->kodi_filesystem->stat_file(
999 CAddonBase::m_interface->toKodi->kodiBase, filename.c_str(), buffer);
1000}
1001//------------------------------------------------------------------------------
1002
1003//==============================================================================
1004/// @ingroup cpp_kodi_vfs_File
1005/// @brief Deletes a file.
1006///
1007/// @param[in] filename The filename to delete.
1008/// @return The file was successfully deleted.
1009///
1010///
1011/// -------------------------------------------------------------------------
1012///
1013/// **Example:**
1014/// ~~~~~~~~~~~~~{.cpp}
1015/// #include <kodi/Filesystem.h>
1016/// #include <kodi/gui/DialogFileBrowser.h>
1017/// #include <kodi/gui/DialogOK.h>
1018/// ...
1019/// std::string filename;
1020/// if (kodi::gui::DialogFileBrowser::ShowAndGetFile("local", "",
1021/// "Test File selection and delete of them!",
1022/// filename))
1023/// {
1024/// bool successed = kodi::vfs::DeleteFile(filename);
1025/// if (!successed)
1026/// kodi::gui::DialogOK::ShowAndGetInput("Error", "Delete of File", filename, "failed!");
1027/// else
1028/// kodi::gui::DialogOK::ShowAndGetInput("Information", "Delete of File", filename, "successfull done.");
1029/// }
1030/// ~~~~~~~~~~~~~
1031///
1032inline bool ATTRIBUTE_HIDDEN DeleteFile(const std::string& filename)
1033{
1034 using namespace kodi::addon;
1035
1036 return CAddonBase::m_interface->toKodi->kodi_filesystem->delete_file(
1037 CAddonBase::m_interface->toKodi->kodiBase, filename.c_str());
1038}
1039//------------------------------------------------------------------------------
1040
1041//==============================================================================
1042/// @ingroup cpp_kodi_vfs_File
1043/// @brief Rename a file name.
1044///
1045/// @param[in] filename The filename to copy.
1046/// @param[in] newFileName The new filename
1047/// @return true if successfully renamed
1048///
1049///
1050inline bool ATTRIBUTE_HIDDEN RenameFile(const std::string& filename, const std::string& newFileName)
1051{
1052 using namespace kodi::addon;
1053
1054 return CAddonBase::m_interface->toKodi->kodi_filesystem->rename_file(
1055 CAddonBase::m_interface->toKodi->kodiBase, filename.c_str(), newFileName.c_str());
1056}
1057//------------------------------------------------------------------------------
1058
1059//==============================================================================
1060/// @ingroup cpp_kodi_vfs_File
1061/// @brief Copy a file from source to destination.
1062///
1063/// @param[in] filename The filename to copy.
1064/// @param[in] destination The destination to copy file to
1065/// @return true if successfully copied
1066///
1067///
1068inline bool ATTRIBUTE_HIDDEN CopyFile(const std::string& filename, const std::string& destination)
1069{
1070 using namespace kodi::addon;
1071
1072 return CAddonBase::m_interface->toKodi->kodi_filesystem->copy_file(
1073 CAddonBase::m_interface->toKodi->kodiBase, filename.c_str(), destination.c_str());
1074}
1075//------------------------------------------------------------------------------
1076
1077//}}}
1078
1079//¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯
1080// "C++" General filesystem functions
1081//{{{
1082
1083//==============================================================================
1084/// @ingroup cpp_kodi_vfs_General
1085/// @brief Retrieve MD5sum of a file.
1086///
1087/// @param[in] path Path to the file to MD5sum
1088/// @return MD5 sum of the file
1089///
1090///
1091/// -------------------------------------------------------------------------
1092///
1093/// **Example:**
1094/// ~~~~~~~~~~~~~{.cpp}
1095/// #include <kodi/Filesystem.h>
1096/// #include <kodi/gui/DialogFileBrowser.h>
1097/// ...
1098/// std::string md5;
1099/// std::string filename;
1100/// if (kodi::gui::DialogFileBrowser::ShowAndGetFile("local", "*.avi|*.mpg|*.mp4",
1101/// "Test File selection to get MD5",
1102/// filename))
1103/// {
1104/// md5 = kodi::vfs::GetFileMD5(filename);
1105/// fprintf(stderr, "MD5 of file '%s' is %s\n", md5.c_str(), filename.c_str());
1106/// }
1107/// ~~~~~~~~~~~~~
1108///
1109inline std::string ATTRIBUTE_HIDDEN GetFileMD5(const std::string& path)
1110{
1111 using namespace kodi::addon;
1112
1113 std::string strReturn;
1114 char* strMd5 = CAddonBase::m_interface->toKodi->kodi_filesystem->get_file_md5(
1115 CAddonBase::m_interface->toKodi->kodiBase, path.c_str());
1116 if (strMd5 != nullptr)
1117 {
1118 if (std::strlen(strMd5))
1119 strReturn = strMd5;
1120 CAddonBase::m_interface->toKodi->free_string(CAddonBase::m_interface->toKodi->kodiBase, strMd5);
1121 }
1122 return strReturn;
1123}
1124//------------------------------------------------------------------------------
1125
1126//==============================================================================
1127/// @ingroup cpp_kodi_vfs_General
1128/// @brief Returns a thumb cache filename.
1129///
1130/// @param[in] filename Path to file
1131/// @return Cache filename
1132///
1133///
1134/// ------------------------------------------------------------------------
1135///
1136/// **Example:**
1137/// ~~~~~~~~~~~~~{.cpp}
1138/// #include <kodi/Filesystem.h>
1139/// #include <kodi/gui/DialogFileBrowser.h>
1140/// ...
1141/// std::string thumb;
1142/// std::string filename;
1143/// if (kodi::gui::DialogFileBrowser::ShowAndGetFile("local", "*.avi|*.mpg|*.mp4",
1144/// "Test File selection to get Thumnail",
1145/// filename))
1146/// {
1147/// thumb = kodi::vfs::GetCacheThumbName(filename);
1148/// fprintf(stderr, "Thumb name of file '%s' is %s\n", thumb.c_str(), filename.c_str());
1149/// }
1150/// ~~~~~~~~~~~~~
1151///
1152inline std::string ATTRIBUTE_HIDDEN GetCacheThumbName(const std::string& filename)
1153{
1154 using namespace kodi::addon;
1155
1156 std::string strReturn;
1157 char* strThumbName = CAddonBase::m_interface->toKodi->kodi_filesystem->get_cache_thumb_name(
1158 CAddonBase::m_interface->toKodi->kodiBase, filename.c_str());
1159 if (strThumbName != nullptr)
1160 {
1161 if (std::strlen(strThumbName))
1162 strReturn = strThumbName;
1163 CAddonBase::m_interface->toKodi->free_string(CAddonBase::m_interface->toKodi->kodiBase,
1164 strThumbName);
1165 }
1166 return strReturn;
1167}
1168//------------------------------------------------------------------------------
1169
1170//==============================================================================
1171/// @ingroup cpp_kodi_vfs_General
1172/// @brief Make filename valid.
1173///
1174/// Function to replace not valid characters with '_'. It can be also
1175/// compared with original before in a own loop until it is equal
1176/// (no invalid characters).
1177///
1178/// @param[in] filename Filename to check and fix
1179/// @return The legal filename
1180///
1181///
1182/// ------------------------------------------------------------------------
1183///
1184/// **Example:**
1185/// ~~~~~~~~~~~~~{.cpp}
1186/// #include <kodi/Filesystem.h>
1187/// ...
1188/// std::string fileName = "///\\jk???lj????.mpg";
1189/// std::string legalName = kodi::vfs::MakeLegalFileName(fileName);
1190/// fprintf(stderr, "Legal name of '%s' is '%s'\n", fileName.c_str(), legalName.c_str());
1191///
1192/// /* Returns as legal: 'jk___lj____.mpg' */
1193/// ~~~~~~~~~~~~~
1194///
1195inline std::string ATTRIBUTE_HIDDEN MakeLegalFileName(const std::string& filename)
1196{
1197 using namespace kodi::addon;
1198
1199 std::string strReturn;
1200 char* strLegalFileName = CAddonBase::m_interface->toKodi->kodi_filesystem->make_legal_filename(
1201 CAddonBase::m_interface->toKodi->kodiBase, filename.c_str());
1202 if (strLegalFileName != nullptr)
1203 {
1204 if (std::strlen(strLegalFileName))
1205 strReturn = strLegalFileName;
1206 CAddonBase::m_interface->toKodi->free_string(CAddonBase::m_interface->toKodi->kodiBase,
1207 strLegalFileName);
1208 }
1209 return strReturn;
1210}
1211//------------------------------------------------------------------------------
1212
1213//==============================================================================
1214/// @ingroup cpp_kodi_vfs_General
1215/// @brief Make directory name valid.
1216///
1217/// Function to replace not valid characters with '_'. It can be also
1218/// compared with original before in a own loop until it is equal
1219/// (no invalid characters).
1220///
1221/// @param[in] path Directory name to check and fix
1222/// @return The legal directory name
1223///
1224///
1225/// ------------------------------------------------------------------------
1226///
1227/// **Example:**
1228/// ~~~~~~~~~~~~~{.cpp}
1229/// #include <kodi/Filesystem.h>
1230/// ...
1231/// std::string path = "///\\jk???lj????\\hgjkg";
1232/// std::string legalPath = kodi::vfs::MakeLegalPath(path);
1233/// fprintf(stderr, "Legal name of '%s' is '%s'\n", path.c_str(), legalPath.c_str());
1234///
1235/// /* Returns as legal: '/jk___lj____/hgjkg' */
1236/// ~~~~~~~~~~~~~
1237///
1238inline std::string ATTRIBUTE_HIDDEN MakeLegalPath(const std::string& path)
1239{
1240 using namespace kodi::addon;
1241
1242 std::string strReturn;
1243 char* strLegalPath = CAddonBase::m_interface->toKodi->kodi_filesystem->make_legal_path(
1244 CAddonBase::m_interface->toKodi->kodiBase, path.c_str());
1245 if (strLegalPath != nullptr)
1246 {
1247 if (std::strlen(strLegalPath))
1248 strReturn = strLegalPath;
1249 CAddonBase::m_interface->toKodi->free_string(CAddonBase::m_interface->toKodi->kodiBase,
1250 strLegalPath);
1251 }
1252 return strReturn;
1253}
1254//------------------------------------------------------------------------------
1255
1256//==============================================================================
1257/// @ingroup cpp_kodi_vfs_General
1258/// @brief Returns the translated path.
1259///
1260/// @param[in] source String or unicode - Path to format
1261/// @return A human-readable string suitable for logging
1262///
1263/// @note Only useful if you are coding for both Linux and Windows. e.g.
1264/// Converts 'special://masterprofile/script_data' ->
1265/// '/home/user/.kodi/UserData/script_data' on Linux.
1266///
1267///
1268/// ------------------------------------------------------------------------
1269///
1270/// **Example:**
1271/// ~~~~~~~~~~~~~{.cpp}
1272/// #include <kodi/Filesystem.h>
1273/// ...
1274/// std::string path = kodi::vfs::TranslateSpecialProtocol("special://masterprofile/script_data");
1275/// fprintf(stderr, "Translated path is: %s\n", path.c_str());
1276/// ...
1277/// ~~~~~~~~~~~~~
1278/// or
1279/// ~~~~~~~~~~~~~{.cpp}
1280/// #include <kodi/Filesystem.h>
1281/// ...
1282/// fprintf(stderr, "Directory 'special://temp' is '%s'\n", kodi::vfs::TranslateSpecialProtocol("special://temp").c_str());
1283/// ...
1284/// ~~~~~~~~~~~~~
1285///
1286inline std::string ATTRIBUTE_HIDDEN TranslateSpecialProtocol(const std::string& source)
1287{
1288 using namespace kodi::addon;
1289
1290 std::string strReturn;
1291 char* protocol = CAddonBase::m_interface->toKodi->kodi_filesystem->translate_special_protocol(
1292 CAddonBase::m_interface->toKodi->kodiBase, source.c_str());
1293 if (protocol != nullptr)
1294 {
1295 if (std::strlen(protocol))
1296 strReturn = protocol;
1297 CAddonBase::m_interface->toKodi->free_string(CAddonBase::m_interface->toKodi->kodiBase,
1298 protocol);
1299 }
1300 return strReturn;
1301}
1302//------------------------------------------------------------------------------
1303
1304//==============================================================================
1305/// @ingroup cpp_kodi_vfs_General
1306/// @brief Retrieves information about the amount of space that is available on
1307/// a disk volume.
1308///
1309/// Path can be also with Kodi's special protocol.
1310///
1311/// @param[in] path Path for where to check
1312/// @param[out] capacity The total number of bytes in the file system
1313/// @param[out] free The total number of free bytes in the file system
1314/// @param[out] available The total number of free bytes available to a
1315/// non-privileged process
1316/// @return true if successfully done and set
1317///
1318/// @warning This only works with paths belonging to OS. If <b>"special://"</b>
1319/// is used, it must point to a place on your own OS.
1320///
1321///
1322/// ------------------------------------------------------------------------
1323///
1324/// **Example:**
1325/// ~~~~~~~~~~~~~{.cpp}
1326/// #include <climits> // for ULLONG_MAX
1327/// #include <kodi/Filesystem.h>
1328/// ...
1329/// std::string path = "special://temp";
1330/// uint64_t capacity = ULLONG_MAX;
1331/// uint64_t free = ULLONG_MAX;
1332/// uint64_t available = ULLONG_MAX;
1333/// kodi::vfs::GetDiskSpace(path, capacity, free, available);
1334/// fprintf(stderr, "Path '%s' sizes:\n", path.c_str());
1335/// fprintf(stderr, " - capacity: %lu MByte\n", capacity / 1024 / 1024);
1336/// fprintf(stderr, " - free: %lu MByte\n", free / 1024 / 1024);
1337/// fprintf(stderr, " - available: %lu MByte\n", available / 1024 / 1024);
1338/// ~~~~~~~~~~~~~
1339///
1340inline bool ATTRIBUTE_HIDDEN GetDiskSpace(const std::string& path,
1341 uint64_t& capacity,
1342 uint64_t& free,
1343 uint64_t& available)
1344{
1345 using namespace kodi::addon;
1346
1347 return CAddonBase::m_interface->toKodi->kodi_filesystem->get_disk_space(
1348 CAddonBase::m_interface->toKodi->kodiBase, path.c_str(), &capacity, &free, &available);
1349}
1350//------------------------------------------------------------------------------
1351
1352//==============================================================================
1353/// @ingroup cpp_kodi_vfs_General
1354/// @brief Return the file name from given complate path string.
1355///
1356/// @param[in] path The complete path include file and directory
1357/// @return Filename from path
1358///
1359///
1360/// ------------------------------------------------------------------------
1361///
1362/// **Example:**
1363/// ~~~~~~~~~~~~~{.cpp}
1364/// #include <kodi/Filesystem.h>
1365/// ...
1366/// std::string fileName = kodi::vfs::GetFileName("special://temp/kodi.log");
1367/// fprintf(stderr, "File name is '%s'\n", fileName.c_str());
1368/// ~~~~~~~~~~~~~
1369///
1370inline std::string ATTRIBUTE_HIDDEN GetFileName(const std::string& path)
1371{
1372 /* find the last slash */
1373 const size_t slash = path.find_last_of("/\\");
1374 return path.substr(slash + 1);
1375}
1376//------------------------------------------------------------------------------
1377
1378//==============================================================================
1379/// @ingroup cpp_kodi_vfs_General
1380/// @brief Return the directory name from given complate path string.
1381///
1382/// @param[in] path The complete path include file and directory
1383/// @return Directory name from path
1384///
1385///
1386/// ------------------------------------------------------------------------
1387///
1388/// **Example:**
1389/// ~~~~~~~~~~~~~{.cpp}
1390/// #include <kodi/Filesystem.h>
1391/// ...
1392/// std::string dirName = kodi::vfs::GetDirectoryName("special://temp/kodi.log");
1393/// fprintf(stderr, "Directory name is '%s'\n", dirName.c_str());
1394/// ~~~~~~~~~~~~~
1395///
1396inline std::string ATTRIBUTE_HIDDEN GetDirectoryName(const std::string& path)
1397{
1398 // Will from a full filename return the directory the file resides in.
1399 // Keeps the final slash at end and possible |option=foo options.
1400
1401 size_t iPosSlash = path.find_last_of("/\\");
1402 if (iPosSlash == std::string::npos)
1403 return ""; // No slash, so no path (ignore any options)
1404
1405 size_t iPosBar = path.rfind('|');
1406 if (iPosBar == std::string::npos)
1407 return path.substr(0, iPosSlash + 1); // Only path
1408
1409 return path.substr(0, iPosSlash + 1) + path.substr(iPosBar); // Path + options
1410}
1411//------------------------------------------------------------------------------
1412
1413//==============================================================================
1414/// @ingroup cpp_kodi_vfs_General
1415/// @brief Remove the slash on given path name.
1416///
1417/// @param[in,out] path The complete path
1418///
1419///
1420/// ------------------------------------------------------------------------
1421///
1422/// **Example:**
1423/// ~~~~~~~~~~~~~{.cpp}
1424/// #include <kodi/Filesystem.h>
1425/// ...
1426/// std::string dirName = "special://temp/";
1427/// kodi::vfs::RemoveSlashAtEnd(dirName);
1428/// fprintf(stderr, "Directory name is '%s'\n", dirName.c_str());
1429/// ~~~~~~~~~~~~~
1430///
1431inline void ATTRIBUTE_HIDDEN RemoveSlashAtEnd(std::string& path)
1432{
1433 if (!path.empty())
1434 {
1435 char last = path[path.size() - 1];
1436 if (last == '/' || last == '\\')
1437 path.erase(path.size() - 1);
1438 }
1439}
1440//------------------------------------------------------------------------------
1441
1442//==============================================================================
1443/// @ingroup cpp_kodi_vfs_General
1444/// @brief Return a size aligned to the chunk size at least as large as the
1445/// chunk size.
1446///
1447/// @param[in] chunk The chunk size
1448/// @param[in] minimum The minimum size (or maybe the minimum number of chunks?)
1449/// @return The aligned size
1450///
1451inline unsigned int ATTRIBUTE_HIDDEN GetChunkSize(unsigned int chunk, unsigned int minimum)
1452{
1453 if (chunk)
1454 return chunk * ((minimum + chunk - 1) / chunk);
1455 else
1456 return minimum;
1457}
1458//------------------------------------------------------------------------------
1459
1460//==============================================================================
1461/// @ingroup cpp_kodi_vfs_General
1462/// @brief Checks the given path contains a known internet protocol.
1463///
1464/// About following protocols are the path checked:
1465/// | Protocol | Return true condition | Protocol | Return true condition
1466/// |----------|-----------------------|----------|-----------------------
1467/// | **dav** | strictCheck = true | **rtmps** | always
1468/// | **davs** | strictCheck = true | **rtmpt** | always
1469/// | **ftp** | strictCheck = true | **rtmpte** | always
1470/// | **ftps** | strictCheck = true | **rtp** | always
1471/// | **http** | always | **rtsp** | always
1472/// | **https**| always | **sdp** | always
1473/// | **mms** | always | **sftp** | strictCheck = true
1474/// | **mmsh** | always | **stack** | always
1475/// | **mmst** | always | **tcp** | always
1476/// | **rtmp** | always | **udp** | always
1477/// | **rtmpe**| always | | |
1478///
1479/// @param[in] path To checked path/URL
1480/// @param[in] strictCheck [opt] If True the set of protocols used will be
1481/// extended to include ftp, ftps, dav, davs and sftp.
1482/// @return True if path is to a internet stream, false otherwise
1483///
1484///
1485/// ------------------------------------------------------------------------
1486///
1487/// **Example:**
1488/// ~~~~~~~~~~~~~{.cpp}
1489/// #include <kodi/Filesystem.h>
1490/// ...
1491/// // Check should return false
1492/// fprintf(stderr, "File name 1 is internet stream '%s' (should no)\n",
1493/// kodi::vfs::IsInternetStream("D:/my-file.mkv") ? "yes" : "no");
1494///
1495/// // Check should return true
1496/// fprintf(stderr, "File name 2 is internet stream '%s' (should yes)\n",
1497/// kodi::vfs::IsInternetStream("http://distribution.bbb3d.renderfarming.net/video/mp4/bbb_sunflower_1080p_30fps_normal.mp4") ? "yes" : "no");
1498///
1499/// // Check should return false
1500/// fprintf(stderr, "File name 1 is internet stream '%s' (should no)\n",
1501/// kodi::vfs::IsInternetStream("ftp://do-somewhere.com/the-file.mkv") ? "yes" : "no", false);
1502///
1503/// // Check should return true
1504/// fprintf(stderr, "File name 1 is internet stream '%s' (should yes)\n",
1505/// kodi::vfs::IsInternetStream("ftp://do-somewhere.com/the-file.mkv") ? "yes" : "no", true);
1506/// ~~~~~~~~~~~~~
1507///
1508inline bool ATTRIBUTE_HIDDEN IsInternetStream(const std::string& path, bool strictCheck = false)
1509{
1510 using namespace kodi::addon;
1511
1512 return CAddonBase::m_interface->toKodi->kodi_filesystem->is_internet_stream(
1513 CAddonBase::m_interface->toKodi->kodiBase, path.c_str(), strictCheck);
1514}
1515//------------------------------------------------------------------------------
1516
1517//==============================================================================
1518/// @ingroup cpp_kodi_vfs_General
1519/// @brief Checks whether the specified path refers to a local network.
1520///
1521/// In difference to @ref IsHostOnLAN() include this more deeper checks where
1522/// also handle Kodi's special protocol and stacks.
1523///
1524/// @param[in] path To checked path
1525/// @return True if path is on LAN, false otherwise
1526///
1527/// @note Check includes @ref IsHostOnLAN() too.
1528///
1529///
1530/// ------------------------------------------------------------------------
1531///
1532/// **Example:**
1533/// ~~~~~~~~~~~~~{.cpp}
1534/// #include <kodi/Filesystem.h>
1535/// ...
1536/// // Check should return true
1537/// bool lan = kodi::vfs::IsOnLAN("smb://path/to/file");
1538/// ~~~~~~~~~~~~~
1539///
1540inline bool ATTRIBUTE_HIDDEN IsOnLAN(const std::string& path)
1541{
1542 using namespace kodi::addon;
1543
1544 return CAddonBase::m_interface->toKodi->kodi_filesystem->is_on_lan(
1545 CAddonBase::m_interface->toKodi->kodiBase, path.c_str());
1546}
1547//------------------------------------------------------------------------------
1548
1549//==============================================================================
1550/// @ingroup cpp_kodi_vfs_General
1551/// @brief Checks specified path for external network.
1552///
1553/// @param[in] path To checked path
1554/// @return True if path is remote, false otherwise
1555///
1556/// @note This does not apply to the local network.
1557///
1558///
1559/// ------------------------------------------------------------------------
1560///
1561/// **Example:**
1562/// ~~~~~~~~~~~~~{.cpp}
1563/// #include <kodi/Filesystem.h>
1564/// ...
1565/// // Check should return true
1566/// bool remote = kodi::vfs::IsRemote("http://path/to/file");
1567/// ~~~~~~~~~~~~~
1568///
1569inline bool ATTRIBUTE_HIDDEN IsRemote(const std::string& path)
1570{
1571 using namespace kodi::addon;
1572
1573 return CAddonBase::m_interface->toKodi->kodi_filesystem->is_remote(
1574 CAddonBase::m_interface->toKodi->kodiBase, path.c_str());
1575}
1576//------------------------------------------------------------------------------
1577
1578//==============================================================================
1579/// @ingroup cpp_kodi_vfs_General
1580/// @brief Checks whether the given path refers to the own system.
1581///
1582/// @param[in] path To checked path
1583/// @return True if path is local, false otherwise
1584///
1585inline bool ATTRIBUTE_HIDDEN IsLocal(const std::string& path)
1586{
1587 using namespace kodi::addon;
1588
1589 return CAddonBase::m_interface->toKodi->kodi_filesystem->is_local(
1590 CAddonBase::m_interface->toKodi->kodiBase, path.c_str());
1591}
1592//------------------------------------------------------------------------------
1593
1594//==============================================================================
1595/// @ingroup cpp_kodi_vfs_General
1596/// @brief Checks specified path is a regular URL, e.g. "someprotocol://path/to/file"
1597///
1598/// @return True if file item is URL, false otherwise
1599///
1600///
1601/// ------------------------------------------------------------------------
1602///
1603/// **Example:**
1604/// ~~~~~~~~~~~~~{.cpp}
1605/// #include <kodi/Filesystem.h>
1606/// ...
1607///
1608/// bool isURL;
1609/// // Check should return true
1610/// isURL = kodi::vfs::IsURL("someprotocol://path/to/file");
1611///
1612/// // Check should return false
1613/// isURL = kodi::vfs::IsURL("/path/to/file");
1614/// ~~~~~~~~~~~~~
1615///
1616inline bool ATTRIBUTE_HIDDEN IsURL(const std::string& path)
1617{
1618 using namespace kodi::addon;
1619
1620 return CAddonBase::m_interface->toKodi->kodi_filesystem->is_url(
1621 CAddonBase::m_interface->toKodi->kodiBase, path.c_str());
1622}
1623//--------------------------------------------------------------------------
1624
1625//============================================================================
1626/// @ingroup cpp_kodi_vfs_General
1627/// @brief To get HTTP header information.
1628///
1629/// @param[in] url URL source of the data
1630/// @param[out] header The @ref cpp_kodi_vfs_Defs_HttpHeader
1631/// @return true if successfully done, otherwise false
1632///
1633///
1634/// ------------------------------------------------------------------------
1635///
1636/// @copydetails cpp_kodi_vfs_Defs_HttpHeader_Help
1637///
1638/// ------------------------------------------------------------------------
1639///
1640/// **Example:**
1641/// ~~~~~~~~~~~~~{.cpp}
1642/// #include <kodi/Filesystem.h>
1643/// ...
1644/// kodi::vfs::HttpHeader header;
1645/// bool ret = kodi::vfs::GetHttpHeader(url, header);
1646/// ...
1647/// ~~~~~~~~~~~~~
1648///
1649inline bool ATTRIBUTE_HIDDEN GetHttpHeader(const std::string& url, HttpHeader& header)
1650{
1651 using namespace ::kodi::addon;
1652
1653 return CAddonBase::m_interface->toKodi->kodi_filesystem->get_http_header(
1654 CAddonBase::m_interface->toKodi->kodiBase, url.c_str(), &header.m_handle);
1655}
1656//----------------------------------------------------------------------------
1657
1658//============================================================================
1659/// @ingroup cpp_kodi_vfs_General
1660/// @brief Get file mime type.
1661///
1662/// @param[in] url URL source of the data
1663/// @param[out] mimeType the mime type of the URL
1664/// @param[in] useragent to be used when retrieving the MimeType [opt]
1665/// @return true if successfully done, otherwise false
1666///
1667///
1668/// ------------------------------------------------------------------------
1669///
1670/// **Example:**
1671/// ~~~~~~~~~~~~~{.cpp}
1672/// #include <kodi/Filesystem.h>
1673/// ...
1674/// std::string mimeType;.
1675/// if (kodi::vfs::GetMimeType(url, mimeType))
1676/// fprintf(stderr, "The mime type is '%s'\n", mimeType.c_str());
1677/// ...
1678/// ~~~~~~~~~~~~~
1679///
1680inline bool ATTRIBUTE_HIDDEN GetMimeType(const std::string& url,
1681 std::string& mimeType,
1682 const std::string& useragent = "")
1683{
1684 using namespace ::kodi::addon;
1685
1686 char* cMimeType = nullptr;
1687 bool ret = CAddonBase::m_interface->toKodi->kodi_filesystem->get_mime_type(
1688 CAddonBase::m_interface->toKodi->kodiBase, url.c_str(), &cMimeType, useragent.c_str());
1689 if (cMimeType != nullptr)
1690 {
1691 mimeType = cMimeType;
1692 CAddonBase::m_interface->toKodi->free_string(CAddonBase::m_interface->toKodi->kodiBase,
1693 cMimeType);
1694 }
1695 return ret;
1696}
1697//----------------------------------------------------------------------------
1698
1699//============================================================================
1700/// @ingroup cpp_kodi_vfs_General
1701/// @brief Get file content-type.
1702///
1703/// @param[in] url URL source of the data
1704/// @param[out] content The returned type
1705/// @param[in] useragent to be used when retrieving the MimeType [opt]
1706/// @return true if successfully done, otherwise false
1707///
1708///
1709/// ------------------------------------------------------------------------
1710///
1711/// **Example:**
1712/// ~~~~~~~~~~~~~{.cpp}
1713/// #include <kodi/Filesystem.h>
1714/// ...
1715/// std::string content;.
1716/// if (kodi::vfs::GetContentType(url, content))
1717/// fprintf(stderr, "The content type is '%s'\n", content.c_str());
1718/// ...
1719/// ~~~~~~~~~~~~~
1720///
1721inline bool ATTRIBUTE_HIDDEN GetContentType(const std::string& url,
1722 std::string& content,
1723 const std::string& useragent = "")
1724{
1725 using namespace ::kodi::addon;
1726
1727 char* cContent = nullptr;
1728 bool ret = CAddonBase::m_interface->toKodi->kodi_filesystem->get_content_type(
1729 CAddonBase::m_interface->toKodi->kodiBase, url.c_str(), &cContent, useragent.c_str());
1730 if (cContent != nullptr)
1731 {
1732 content = cContent;
1733 CAddonBase::m_interface->toKodi->free_string(CAddonBase::m_interface->toKodi->kodiBase,
1734 cContent);
1735 }
1736 return ret;
1737}
1738//----------------------------------------------------------------------------
1739
1740//============================================================================
1741/// @ingroup cpp_kodi_vfs_General
1742/// @brief Get cookies stored by CURL in RFC 2109 format.
1743///
1744/// @param[in] url URL source of the data
1745/// @param[out] cookies The text list of available cookies
1746/// @return true if successfully done, otherwise false
1747///
1748///
1749/// ------------------------------------------------------------------------
1750///
1751/// **Example:**
1752/// ~~~~~~~~~~~~~{.cpp}
1753/// #include <kodi/Filesystem.h>
1754/// ...
1755/// std::string url = "";
1756/// std::string cookies;
1757/// bool ret = kodi::vfs::GetCookies(url, cookies);
1758/// fprintf(stderr, "Cookies from URL '%s' are '%s' (return was %s)\n",
1759/// url.c_str(), cookies.c_str(), ret ? "true" : "false");
1760/// ...
1761/// ~~~~~~~~~~~~~
1762///
1763inline bool ATTRIBUTE_HIDDEN GetCookies(const std::string& url, std::string& cookies)
1764{
1765 using namespace ::kodi::addon;
1766
1767 char* cCookies = nullptr;
1768 bool ret = CAddonBase::m_interface->toKodi->kodi_filesystem->get_cookies(
1769 CAddonBase::m_interface->toKodi->kodiBase, url.c_str(), &cCookies);
1770 if (cCookies != nullptr)
1771 {
1772 cookies = cCookies;
1773 CAddonBase::m_interface->toKodi->free_string(CAddonBase::m_interface->toKodi->kodiBase,
1774 cCookies);
1775 }
1776 return ret;
1777}
1778//----------------------------------------------------------------------------
1779
1780//}}}
1781
1782//¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯
1783// "C++" CFile class
1784//{{{
1785
1786//==============================================================================
1787/// @defgroup cpp_kodi_vfs_CFile 4. class CFile
1788/// @ingroup cpp_kodi_vfs
1789///
1790/// @brief **Creatable class for virtual file server control**\n
1791/// To perform file read/write with Kodi's filesystem parts.
1792///
1793/// CFile is the class used for handling Files in Kodi. This class can be used
1794/// for creating, reading, writing and modifying files. It directly provides unbuffered, binary disk input/output services
1795///
1796/// It has the header @ref Filesystem.h "#include <kodi/Filesystem.h>" be included
1797/// to enjoy it.
1798///
1799///
1800/// ------------------------------------------------------------------------
1801///
1802/// **Example:**
1803/// ~~~~~~~~~~~~~{.cpp}
1804/// #include <kodi/Filesystem.h>
1805///
1806/// ...
1807///
1808/// /* Create the needed file handle class */
1809/// kodi::vfs::CFile myFile();
1810///
1811/// /* In this example we use the user path for the add-on */
1812/// std::string file = kodi::GetUserPath() + "/myFile.txt";
1813///
1814/// /* Now create and open the file or overwrite if present */
1815/// myFile.OpenFileForWrite(file, true);
1816///
1817/// const char* str = "I love Kodi!";
1818///
1819/// /* write string */
1820/// myFile.Write(str, sizeof(str));
1821///
1822/// /* On this way the Close() is not needed to call, becomes done from destructor */
1823///
1824/// ~~~~~~~~~~~~~
1825///
1826//@{
1827class ATTRIBUTE_HIDDEN CFile
1828{
1829public:
1830 //============================================================================
1831 /// @ingroup cpp_kodi_vfs_CFile
1832 /// @brief Construct a new, unopened file.
1833 ///
1834 CFile() = default;
1835 //----------------------------------------------------------------------------
1836
1837 //============================================================================
1838 /// @ingroup cpp_kodi_vfs_CFile
1839 /// @brief <b>`Close()`</b> is called from the destructor, so explicitly
1840 /// closing the file isn't required.
1841 ///
1842 virtual ~CFile() { Close(); }
1843 //--------------------------------------------------------------------------
1844
1845 //==========================================================================
1846 /// @ingroup cpp_kodi_vfs_CFile
1847 /// @brief Open the file with filename via Kodi's @ref cpp_kodi_vfs_CFile
1848 /// "CFile". Needs to be closed by calling Close() when done.
1849 ///
1850 /// @param[in] filename The filename to open.
1851 /// @param[in] flags [opt] The flags to pass, see @ref OpenFileFlags
1852 /// @return True on success or false on failure
1853 ///
1854 bool OpenFile(const std::string& filename, unsigned int flags = 0)
1855 {
1856 using namespace kodi::addon;
1857
1858 Close();
1859 m_file = CAddonBase::m_interface->toKodi->kodi_filesystem->open_file(
1860 CAddonBase::m_interface->toKodi->kodiBase, filename.c_str(), flags);
1861 return m_file != nullptr;
1862 }
1863 //--------------------------------------------------------------------------
1864
1865 //==========================================================================
1866 /// @ingroup cpp_kodi_vfs_CFile
1867 /// @brief Open the file with filename via Kodi's @ref cpp_kodi_vfs_CFile
1868 /// "CFile" in write mode. Needs to be closed by calling Close() when
1869 /// done.
1870 ///
1871 /// @note Related folders becomes created if not present.
1872 ///
1873 /// @param[in] filename The filename to open.
1874 /// @param[in] overwrite True to overwrite, false otherwise.
1875 /// @return True on success or false on failure
1876 ///
1877 bool OpenFileForWrite(const std::string& filename, bool overwrite = false)
1878 {
1879 using namespace kodi::addon;
1880
1881 Close();
1882
1883 // Try to open the file. If it fails, check if we need to create the directory first
1884 // This way we avoid checking if the directory exists every time
1885 m_file = CAddonBase::m_interface->toKodi->kodi_filesystem->open_file_for_write(
1886 CAddonBase::m_interface->toKodi->kodiBase, filename.c_str(), overwrite);
1887 if (!m_file)
1888 {
1889 std::string cacheDirectory = kodi::vfs::GetDirectoryName(filename);
1890 if (CAddonBase::m_interface->toKodi->kodi_filesystem->directory_exists(
1891 CAddonBase::m_interface->toKodi->kodiBase, cacheDirectory.c_str()) ||
1892 CAddonBase::m_interface->toKodi->kodi_filesystem->create_directory(
1893 CAddonBase::m_interface->toKodi->kodiBase, cacheDirectory.c_str()))
1894 m_file = CAddonBase::m_interface->toKodi->kodi_filesystem->open_file_for_write(
1895 CAddonBase::m_interface->toKodi->kodiBase, filename.c_str(), overwrite);
1896 }
1897 return m_file != nullptr;
1898 }
1899 //--------------------------------------------------------------------------
1900
1901 //==========================================================================
1902 /// @ingroup cpp_kodi_vfs_CFile
1903 /// @brief Check file is opened.
1904 ///
1905 /// @return True on open or false on closed or failure
1906 ///
1907 bool IsOpen() const { return m_file != nullptr; }
1908 //--------------------------------------------------------------------------
1909
1910 //==========================================================================
1911 /// @ingroup cpp_kodi_vfs_CFile
1912 /// @brief Close an open file.
1913 ///
1914 void Close()
1915 {
1916 using namespace kodi::addon;
1917
1918 if (!m_file)
1919 return;
1920 CAddonBase::m_interface->toKodi->kodi_filesystem->close_file(
1921 CAddonBase::m_interface->toKodi->kodiBase, m_file);
1922 m_file = nullptr;
1923 }
1924 //--------------------------------------------------------------------------
1925
1926 //==========================================================================
1927 /// @ingroup cpp_kodi_vfs_CFile
1928 /// @brief Create a Curl representation
1929 ///
1930 /// @param[in] url The URL of the Type.
1931 /// @return True on success or false on failure
1932 ///
1933 bool CURLCreate(const std::string& url)
1934 {
1935 using namespace kodi::addon;
1936
1937 m_file = CAddonBase::m_interface->toKodi->kodi_filesystem->curl_create(
1938 CAddonBase::m_interface->toKodi->kodiBase, url.c_str());
1939 return m_file != nullptr;
1940 }
1941 //--------------------------------------------------------------------------
1942
1943 //==========================================================================
1944 /// @ingroup cpp_kodi_vfs_CFile
1945 /// @brief Add options to the curl file created with CURLCreate.
1946 ///
1947 /// @param[in] type Option type to set, see @ref CURLOptiontype
1948 /// @param[in] name Name of the option
1949 /// @param[in] value Value of the option
1950 /// @return True on success or false on failure
1951 ///
1952 bool CURLAddOption(CURLOptiontype type, const std::string& name, const std::string& value)
1953 {
1954 using namespace kodi::addon;
1955
1956 if (!m_file)
1957 {
1958 kodi::Log(ADDON_LOG_ERROR, "kodi::vfs::CURLCreate(...) needed to call before!");
1959 return false;
1960 }
1961 return CAddonBase::m_interface->toKodi->kodi_filesystem->curl_add_option(
1962 CAddonBase::m_interface->toKodi->kodiBase, m_file, type, name.c_str(), value.c_str());
1963 }
1964 //--------------------------------------------------------------------------
1965
1966 //==========================================================================
1967 /// @ingroup cpp_kodi_vfs_CFile
1968 /// @brief Open the curl file created with CURLCreate.
1969 ///
1970 /// @param[in] flags [opt] The flags to pass, see @ref OpenFileFlags
1971 /// @return True on success or false on failure
1972 ///
1973 bool CURLOpen(unsigned int flags = 0)
1974 {
1975 using namespace kodi::addon;
1976
1977 if (!m_file)
1978 {
1979 kodi::Log(ADDON_LOG_ERROR, "kodi::vfs::CURLCreate(...) needed to call before!");
1980 return false;
1981 }
1982 return CAddonBase::m_interface->toKodi->kodi_filesystem->curl_open(
1983 CAddonBase::m_interface->toKodi->kodiBase, m_file, flags);
1984 }
1985 //--------------------------------------------------------------------------
1986
1987 //==========================================================================
1988 /// @ingroup cpp_kodi_vfs_CFile
1989 /// @brief Read from an open file.
1990 ///
1991 /// @param[in] ptr The buffer to store the data in.
1992 /// @param[in] size The size of the buffer.
1993 /// @return number of successfully read bytes if any bytes were read and
1994 /// stored in buffer, zero if no bytes are available to read (end of
1995 /// file was reached) or undetectable error occur, -1 in case of any
1996 /// explicit error
1997 ///
1998 ssize_t Read(void* ptr, size_t size)
1999 {
2000 using namespace kodi::addon;
2001
2002 if (!m_file)
2003 return -1;
2004 return CAddonBase::m_interface->toKodi->kodi_filesystem->read_file(
2005 CAddonBase::m_interface->toKodi->kodiBase, m_file, ptr, size);
2006 }
2007 //--------------------------------------------------------------------------
2008
2009 //==========================================================================
2010 /// @ingroup cpp_kodi_vfs_CFile
2011 /// @brief Read a string from an open file.
2012 ///
2013 /// @param[out] line The buffer to store the data in.
2014 /// @return True when a line was read, false otherwise.
2015 ///
2016 bool ReadLine(std::string& line)
2017 {
2018 using namespace kodi::addon;
2019
2020 line.clear();
2021 if (!m_file)
2022 return false;
2023 // TODO: Read 1024 chars into buffer. If file position advanced that many
2024 // chars, we didn't hit a newline. Otherwise, if file position is 1 or 2
2025 // past the number of bytes read, we read (and skipped) a newline sequence.
2026 char buffer[1025];
2027 if (CAddonBase::m_interface->toKodi->kodi_filesystem->read_file_string(
2028 CAddonBase::m_interface->toKodi->kodiBase, m_file, buffer, sizeof(buffer)))
2029 {
2030 line = buffer;
2031 return !line.empty();
2032 }
2033 return false;
2034 }
2035 //--------------------------------------------------------------------------
2036
2037 //==========================================================================
2038 /// @ingroup cpp_kodi_vfs_CFile
2039 /// @brief Write to a file opened in write mode.
2040 ///
2041 /// @param[in] ptr Pointer to the data to write, converted to a <b>`const void*`</b>.
2042 /// @param[in] size Size of the data to write.
2043 /// @return number of successfully written bytes if any bytes were written,
2044 /// zero if no bytes were written and no detectable error occur,-1
2045 /// in case of any explicit error
2046 ///
2047 ssize_t Write(const void* ptr, size_t size)
2048 {
2049 using namespace kodi::addon;
2050
2051 if (!m_file)
2052 return -1;
2053 return CAddonBase::m_interface->toKodi->kodi_filesystem->write_file(
2054 CAddonBase::m_interface->toKodi->kodiBase, m_file, ptr, size);
2055 }
2056 //--------------------------------------------------------------------------
2057
2058 //==========================================================================
2059 /// @ingroup cpp_kodi_vfs_CFile
2060 /// @brief Flush buffered data.
2061 ///
2062 /// If the given stream was open for writing (or if it was open for updating
2063 /// and the last i/o operation was an output operation) any unwritten data
2064 /// in its output buffer is written to the file.
2065 ///
2066 /// The stream remains open after this call.
2067 ///
2068 /// When a file is closed, either because of a call to close or because the
2069 /// class is destructed, all the buffers associated with it are
2070 /// automatically flushed.
2071 ///
2072 void Flush()
2073 {
2074 using namespace kodi::addon;
2075
2076 if (!m_file)
2077 return;
2078 CAddonBase::m_interface->toKodi->kodi_filesystem->flush_file(
2079 CAddonBase::m_interface->toKodi->kodiBase, m_file);
2080 }
2081 //--------------------------------------------------------------------------
2082
2083 //==========================================================================
2084 /// @ingroup cpp_kodi_vfs_CFile
2085 /// @brief Set the file's current position.
2086 ///
2087 /// The whence argument is optional and defaults to SEEK_SET (0)
2088 ///
2089 /// @param[in] position the position that you want to seek to
2090 /// @param[in] whence [optional] offset relative to You can set the value of
2091 /// whence to one of three things:
2092 /// | Value | int | Description |
2093 /// |:--------:|:---:|:----------------------------------------------------|
2094 /// | SEEK_SET | 0 | position is relative to the beginning of the file. This is probably what you had in mind anyway, and is the most commonly used value for whence.
2095 /// | SEEK_CUR | 1 | position is relative to the current file pointer position. So, in effect, you can say, "Move to my current position plus 30 bytes," or, "move to my current position minus 20 bytes."
2096 /// | SEEK_END | 2 | position is relative to the end of the file. Just like SEEK_SET except from the other end of the file. Be sure to use negative values for offset if you want to back up from the end of the file, instead of going past the end into oblivion.
2097 ///
2098 /// @return Returns the resulting offset location as measured in bytes from
2099 /// the beginning of the file. On error, the value -1 is returned.
2100 ///
2101 int64_t Seek(int64_t position, int whence = SEEK_SET)
2102 {
2103 using namespace kodi::addon;
2104
2105 if (!m_file)
2106 return -1;
2107 return CAddonBase::m_interface->toKodi->kodi_filesystem->seek_file(
2108 CAddonBase::m_interface->toKodi->kodiBase, m_file, position, whence);
2109 }
2110 //--------------------------------------------------------------------------
2111
2112 //==========================================================================
2113 /// @ingroup cpp_kodi_vfs_CFile
2114 /// @brief Truncate a file to the requested size.
2115 ///
2116 /// @param[in] size The new max size.
2117 /// @return New size? On error, the value -1 is returned.
2118 ///
2119 int Truncate(int64_t size)
2120 {
2121 using namespace kodi::addon;
2122
2123 if (!m_file)
2124 return -1;
2125 return CAddonBase::m_interface->toKodi->kodi_filesystem->truncate_file(
2126 CAddonBase::m_interface->toKodi->kodiBase, m_file, size);
2127 }
2128 //--------------------------------------------------------------------------
2129
2130 //==========================================================================
2131 /// @ingroup cpp_kodi_vfs_CFile
2132 /// @brief The current offset in an open file.
2133 ///
2134 /// @return The requested offset. On error, the value -1 is returned.
2135 ///
2136 int64_t GetPosition() const
2137 {
2138 using namespace kodi::addon;
2139
2140 if (!m_file)
2141 return -1;
2142 return CAddonBase::m_interface->toKodi->kodi_filesystem->get_file_position(
2143 CAddonBase::m_interface->toKodi->kodiBase, m_file);
2144 }
2145 //--------------------------------------------------------------------------
2146
2147 //==========================================================================
2148 /// @ingroup cpp_kodi_vfs_CFile
2149 /// @brief Get the file size of an open file.
2150 ///
2151 /// @return The requested size. On error, the value -1 is returned.
2152 ///
2153 int64_t GetLength() const
2154 {
2155 using namespace kodi::addon;
2156
2157 if (!m_file)
2158 return -1;
2159 return CAddonBase::m_interface->toKodi->kodi_filesystem->get_file_length(
2160 CAddonBase::m_interface->toKodi->kodiBase, m_file);
2161 }
2162 //--------------------------------------------------------------------------
2163
2164 //==========================================================================
2165 /// @ingroup cpp_kodi_vfs_CFile
2166 /// @brief Checks the file access is on end position.
2167 ///
2168 /// @return If you've reached the end of the file, AtEnd() returns true.
2169 ///
2170 bool AtEnd() const
2171 {
2172 using namespace kodi::addon;
2173
2174 if (!m_file)
2175 return true;
2176 int64_t length = CAddonBase::m_interface->toKodi->kodi_filesystem->get_file_length(
2177 CAddonBase::m_interface->toKodi->kodiBase, m_file);
2178 int64_t position = CAddonBase::m_interface->toKodi->kodi_filesystem->get_file_position(
2179 CAddonBase::m_interface->toKodi->kodiBase, m_file);
2180 return position >= length;
2181 }
2182 //--------------------------------------------------------------------------
2183
2184 //==========================================================================
2185 /// @ingroup cpp_kodi_vfs_CFile
2186 /// @brief Get the chunk size for an open file.
2187 ///
2188 /// @return The requested size. On error, the value -1 is returned.
2189 ///
2190 int GetChunkSize() const
2191 {
2192 using namespace kodi::addon;
2193
2194 if (!m_file)
2195 return -1;
2196 return CAddonBase::m_interface->toKodi->kodi_filesystem->get_file_chunk_size(
2197 CAddonBase::m_interface->toKodi->kodiBase, m_file);
2198 }
2199 //--------------------------------------------------------------------------
2200
2201 //==========================================================================
2202 /// @ingroup cpp_kodi_vfs_CFile
2203 /// @brief To check seek possible on current stream by file.
2204 ///
2205 /// @return true if seek possible, false if not
2206 ///
2207 bool IoControlGetSeekPossible() const
2208 {
2209 using namespace kodi::addon;
2210
2211 if (!m_file)
2212 return false;
2213 return CAddonBase::m_interface->toKodi->kodi_filesystem->io_control_get_seek_possible(
2214 CAddonBase::m_interface->toKodi->kodiBase, m_file);
2215 }
2216 //--------------------------------------------------------------------------
2217
2218 //==========================================================================
2219 /// @ingroup cpp_kodi_vfs_CFile
2220 /// @brief To check a running stream on file for state of his cache.
2221 ///
2222 /// @param[in] status Information about current cache status
2223 /// @return true if successfull done, false otherwise
2224 ///
2225 ///
2226 /// @copydetails cpp_kodi_vfs_Defs_CacheStatus_Help
2227 ///
2228 bool IoControlGetCacheStatus(CacheStatus& status) const
2229 {
2230 using namespace kodi::addon;
2231
2232 if (!m_file)
2233 return false;
2234 return CAddonBase::m_interface->toKodi->kodi_filesystem->io_control_get_cache_status(
2235 CAddonBase::m_interface->toKodi->kodiBase, m_file, status);
2236 }
2237 //--------------------------------------------------------------------------
2238
2239 //==========================================================================
2240 /// @ingroup cpp_kodi_vfs_CFile
2241 /// @brief Unsigned int with speed limit for caching in bytes per second.
2242 ///
2243 /// @param[in] rate Cache rate size to use
2244 /// @return true if successfull done, false otherwise
2245 ///
2246 bool IoControlSetCacheRate(unsigned int rate)
2247 {
2248 using namespace kodi::addon;
2249
2250 if (!m_file)
2251 return false;
2252 return CAddonBase::m_interface->toKodi->kodi_filesystem->io_control_set_cache_rate(
2253 CAddonBase::m_interface->toKodi->kodiBase, m_file, rate);
2254 }
2255 //--------------------------------------------------------------------------
2256
2257 //==========================================================================
2258 /// @ingroup cpp_kodi_vfs_CFile
2259 /// @brief Enable/disable retry within the protocol handler (if supported).
2260 ///
2261 /// @param[in] retry To set the retry, true for use, false for not
2262 /// @return true if successfull done, false otherwise
2263 ///
2264 bool IoControlSetRetry(bool retry)
2265 {
2266 using namespace kodi::addon;
2267
2268 if (!m_file)
2269 return false;
2270 return CAddonBase::m_interface->toKodi->kodi_filesystem->io_control_set_retry(
2271 CAddonBase::m_interface->toKodi->kodiBase, m_file, retry);
2272 }
2273 //--------------------------------------------------------------------------
2274
2275 //==========================================================================
2276 /// @ingroup cpp_kodi_vfs_CFile
2277 /// @brief Retrieve a file property.
2278 ///
2279 /// @param[in] type The type of the file property to retrieve the value for
2280 /// @param[in] name The name of a named property value (e.g. Header)
2281 /// @return value of requested property, empty on failure / non-existance
2282 ///
2283 const std::string GetPropertyValue(FilePropertyTypes type, const std::string& name) const
2284 {
2285 using namespace kodi::addon;
2286
2287 if (!m_file)
2288 {
2289 kodi::Log(ADDON_LOG_ERROR,
2290 "kodi::vfs::CURLCreate(...) needed to call before GetPropertyValue!");
2291 return "";
2292 }
2293 std::vector<std::string> values = GetPropertyValues(type, name);
2294 if (values.empty())
2295 {
2296 return "";
2297 }
2298 return values[0];
2299 }
2300 //--------------------------------------------------------------------------
2301
2302 //==========================================================================
2303 /// @ingroup cpp_kodi_vfs_CFile
2304 /// @brief Retrieve file property values.
2305 ///
2306 /// @param[in] type The type of the file property values to retrieve the value for
2307 /// @param[in] name The name of the named property (e.g. Header)
2308 /// @return values of requested property, empty vector on failure / non-existance
2309 ///
2310 const std::vector<std::string> GetPropertyValues(FilePropertyTypes type,
2311 const std::string& name) const
2312 {
2313 using namespace kodi::addon;
2314
2315 if (!m_file)
2316 {
2317 kodi::Log(ADDON_LOG_ERROR,
2318 "kodi::vfs::CURLCreate(...) needed to call before GetPropertyValues!");
2319 return std::vector<std::string>();
2320 }
2321 int numValues = 0;
2322 char** res(CAddonBase::m_interface->toKodi->kodi_filesystem->get_property_values(
2323 CAddonBase::m_interface->toKodi->kodiBase, m_file, type, name.c_str(), &numValues));
2324 if (res)
2325 {
2326 std::vector<std::string> vecReturn;
2327 for (int i = 0; i < numValues; ++i)
2328 {
2329 vecReturn.emplace_back(res[i]);
2330 }
2331 CAddonBase::m_interface->toKodi->free_string_array(CAddonBase::m_interface->toKodi->kodiBase,
2332 res, numValues);
2333 return vecReturn;
2334 }
2335 return std::vector<std::string>();
2336 }
2337 //--------------------------------------------------------------------------
2338
2339 //==========================================================================
2340 /// @ingroup cpp_kodi_vfs_CFile
2341 /// @brief Get the current download speed of file if loaded from web.
2342 ///
2343 /// @return The current download speed.
2344 ///
2345 double GetFileDownloadSpeed() const
2346 {
2347 using namespace kodi::addon;
2348
2349 if (!m_file)
2350 return 0.0;
2351 return CAddonBase::m_interface->toKodi->kodi_filesystem->get_file_download_speed(
2352 CAddonBase::m_interface->toKodi->kodiBase, m_file);
2353 }
2354 //--------------------------------------------------------------------------
2355
2356private:
2357 void* m_file = nullptr;
2358};
2359//@}
2360//------------------------------------------------------------------------------
2361
2362//}}}
2363
2364} /* namespace vfs */
2365} /* namespace kodi */
2366
2367#endif /* __cplusplus */
diff --git a/xbmc/addons/kodi-dev-kit/include/kodi/General.h b/xbmc/addons/kodi-dev-kit/include/kodi/General.h
new file mode 100644
index 0000000..3fad5a0
--- /dev/null
+++ b/xbmc/addons/kodi-dev-kit/include/kodi/General.h
@@ -0,0 +1,834 @@
1/*
2 * Copyright (C) 2005-2018 Team Kodi
3 * This file is part of Kodi - https://kodi.tv
4 *
5 * SPDX-License-Identifier: GPL-2.0-or-later
6 * See LICENSES/README.md for more information.
7 */
8
9#pragma once
10
11#include "AddonBase.h"
12#include "c-api/general.h"
13#include "tools/StringUtils.h"
14
15#ifdef __cplusplus
16
17//==============================================================================
18/// \ingroup cpp_kodi_Defs
19/// @brief For kodi::Version used structure
20///
21typedef struct kodi_version_t
22{
23 /// Application name, normally 'Kodi'
24 std::string compile_name;
25 /// Major code version of Kodi
26 int major;
27 /// Minor code version of Kodi
28 int minor;
29 /// The Revision contains a id and the build date, e.g. 20170706-c6b22fe217-dirty
30 std::string revision;
31 /// The version canditate e.g. alpha, beta or release
32 std::string tag;
33 /// The revision of tag before
34 std::string tag_revision;
35} kodi_version_t;
36//------------------------------------------------------------------------------
37
38namespace kodi
39{
40
41//==============================================================================
42/// \ingroup cpp_kodi
43/// @brief Returns the value of an addon property as a string
44///
45/// @param[in] id id of the property that the module needs to access
46/// | | Choices are | |
47/// |:------------:|:------------:|:------------:|
48/// | author | icon | stars |
49/// | changelog | id | summary |
50/// | description | name | type |
51/// | disclaimer | path | version |
52/// | fanart | profile | |
53///
54/// @return AddOn property as a string
55///
56///
57/// ------------------------------------------------------------------------
58///
59/// **Example:**
60/// ~~~~~~~~~~~~~{.cpp}
61/// #include <kodi/General.h>
62/// ...
63/// std::string addonName = kodi::GetAddonInfo("name");
64/// ...
65/// ~~~~~~~~~~~~~
66///
67inline std::string ATTRIBUTE_HIDDEN GetAddonInfo(const std::string& id)
68{
69 using namespace kodi::addon;
70
71 AddonToKodiFuncTable_Addon* toKodi = CAddonBase::m_interface->toKodi;
72
73 std::string strReturn;
74 char* strMsg = toKodi->kodi->get_addon_info(toKodi->kodiBase, id.c_str());
75 if (strMsg != nullptr)
76 {
77 if (std::strlen(strMsg))
78 strReturn = strMsg;
79 toKodi->free_string(toKodi->kodiBase, strMsg);
80 }
81 return strReturn;
82}
83//------------------------------------------------------------------------------
84
85//==============================================================================
86/// \ingroup cpp_kodi
87/// @brief Opens this Add-Ons settings dialog.
88///
89/// @return true if settings were changed and the dialog confirmed, false otherwise.
90///
91///
92/// --------------------------------------------------------------------------
93///
94/// **Example:**
95/// ~~~~~~~~~~~~~{.cpp}
96/// #include <kodi/General.h>
97/// ..
98/// kodi::OpenSettings();
99/// ..
100/// ~~~~~~~~~~~~~
101///
102inline bool ATTRIBUTE_HIDDEN OpenSettings()
103{
104 using namespace kodi::addon;
105 return CAddonBase::m_interface->toKodi->kodi->open_settings_dialog(
106 CAddonBase::m_interface->toKodi->kodiBase);
107}
108//------------------------------------------------------------------------------
109
110//==============================================================================
111/// \ingroup cpp_kodi
112/// @brief Returns an addon's localized 'unicode string'.
113///
114/// @param[in] labelId string you want to localize
115/// @param[in] defaultStr [opt] The default message, also helps to identify
116/// the code that is used <em>(default is
117/// <b><c>empty</c></b>)</em>
118/// @return The localized message, or default if the add-on
119/// helper fails to return a message
120///
121/// @note Label id's \b 30000 to \b 30999 and \b 32000 to \b 32999 are related
122/// to the add-on's own included strings from
123/// <b>./resources/language/resource.language.??_??/strings.po</b>
124/// All other strings are from Kodi core language files.
125///
126///
127/// ------------------------------------------------------------------------
128///
129/// **Example:**
130/// ~~~~~~~~~~~~~{.cpp}
131/// #include <kodi/General.h>
132/// ...
133/// std::string str = kodi::GetLocalizedString(30005, "Use me as default");
134/// ...
135/// ~~~~~~~~~~~~~
136///
137inline std::string ATTRIBUTE_HIDDEN GetLocalizedString(uint32_t labelId,
138 const std::string& defaultStr = "")
139{
140 using namespace kodi::addon;
141
142 std::string retString = defaultStr;
143 char* strMsg = CAddonBase::m_interface->toKodi->kodi->get_localized_string(
144 CAddonBase::m_interface->toKodi->kodiBase, labelId);
145 if (strMsg != nullptr)
146 {
147 if (std::strlen(strMsg))
148 retString = strMsg;
149 CAddonBase::m_interface->toKodi->free_string(CAddonBase::m_interface->toKodi->kodiBase, strMsg);
150 }
151 return retString;
152}
153//------------------------------------------------------------------------------
154
155//==============================================================================
156/// \ingroup cpp_kodi
157/// @brief Translate a string with an unknown encoding to UTF8.
158///
159/// @param[in] stringSrc The string to translate.
160/// @param[out] utf8StringDst The translated string.
161/// @param[in] failOnBadChar [opt] returns failed if bad character is inside <em>(default is <b><c>false</c></b>)</em>
162/// @return true if OK
163///
164///
165/// ------------------------------------------------------------------------
166///
167/// **Example:**
168/// ~~~~~~~~~~~~~{.cpp}
169/// #include <kodi/General.h>
170/// ...
171/// std::string ret;
172/// if (!kodi::UnknownToUTF8("test string", ret, true))
173/// fprintf(stderr, "Translation to UTF8 failed!\n");
174/// ...
175/// ~~~~~~~~~~~~~
176///
177inline bool ATTRIBUTE_HIDDEN UnknownToUTF8(const std::string& stringSrc,
178 std::string& utf8StringDst,
179 bool failOnBadChar = false)
180{
181 using namespace kodi::addon;
182
183 bool ret = false;
184 char* retString = CAddonBase::m_interface->toKodi->kodi->unknown_to_utf8(
185 CAddonBase::m_interface->toKodi->kodiBase, stringSrc.c_str(), &ret, failOnBadChar);
186 if (retString != nullptr)
187 {
188 if (ret)
189 utf8StringDst = retString;
190 CAddonBase::m_interface->toKodi->free_string(CAddonBase::m_interface->toKodi->kodiBase,
191 retString);
192 }
193 return ret;
194}
195//------------------------------------------------------------------------------
196
197//==============================================================================
198/// \ingroup cpp_kodi
199/// @brief Returns the active language as a string.
200///
201/// @param[in] format Used format of the returned language string
202/// | enum code: | Description: |
203/// |----------------------:|------------------------------------------------------------|
204/// | LANG_FMT_ENGLISH_NAME | full language name in English (Default) |
205/// | LANG_FMT_ISO_639_1 | two letter code as defined in ISO 639-1 |
206/// | LANG_FMT_ISO_639_2 | three letter code as defined in ISO 639-2/T or ISO 639-2/B |
207/// @param[in] region [opt] append the region delimited by "-" of the language (setting) to the returned language string <em>(default is <b><c>false</c></b>)</em>
208/// @return active language
209///
210///
211/// ------------------------------------------------------------------------
212///
213/// **Example:**
214/// ~~~~~~~~~~~~~{.cpp}
215/// #include <kodi/General.h>
216/// ...
217/// std::string language = kodi::GetLanguage(LANG_FMT_ISO_639_1, false);
218/// ...
219/// ~~~~~~~~~~~~~
220///
221inline std::string ATTRIBUTE_HIDDEN GetLanguage(LangFormats format = LANG_FMT_ENGLISH_NAME,
222 bool region = false)
223{
224 using namespace kodi::addon;
225
226 std::string language;
227 char* retString = CAddonBase::m_interface->toKodi->kodi->get_language(
228 CAddonBase::m_interface->toKodi->kodiBase, format, region);
229 if (retString != nullptr)
230 {
231 if (std::strlen(retString))
232 language = retString;
233 CAddonBase::m_interface->toKodi->free_string(CAddonBase::m_interface->toKodi->kodiBase,
234 retString);
235 }
236 return language;
237}
238//------------------------------------------------------------------------------
239
240//==============================================================================
241/// \ingroup cpp_kodi
242/// @brief Writes the C string pointed by format in the GUI. If format includes
243/// format specifiers (subsequences beginning with %), the additional arguments
244/// following format are formatted and inserted in the resulting string replacing
245/// their respective specifiers.
246///
247/// After the format parameter, the function expects at least as many additional
248/// arguments as specified by format.
249///
250/// @param[in] type The message type.
251/// | enum code: | Description: |
252/// |---------------:|-----------------------------------|
253/// | QUEUE_INFO | Show info notification message |
254/// | QUEUE_WARNING | Show warning notification message |
255/// | QUEUE_ERROR | Show error notification message |
256/// @param[in] format The format of the message to pass to display in Kodi.
257/// C string that contains the text to be written to the stream.
258/// It can optionally contain embedded format specifiers that are
259/// replaced by the values specified in subsequent additional
260/// arguments and formatted as requested.
261/// | specifier | Output | Example
262/// |------------|----------------------------------------------------|------------
263/// | d or i | Signed decimal integer | 392
264/// | u | Unsigned decimal integer | 7235
265/// | o | Unsigned octal | 610
266/// | x | Unsigned hexadecimal integer | 7fa
267/// | X | Unsigned hexadecimal integer (uppercase) | 7FA
268/// | f | Decimal floating point, lowercase | 392.65
269/// | F | Decimal floating point, uppercase | 392.65
270/// | e | Scientific notation (mantissa/exponent), lowercase | 3.9265e+2
271/// | E | Scientific notation (mantissa/exponent), uppercase | 3.9265E+2
272/// | g | Use the shortest representation: %e or %f | 392.65
273/// | G | Use the shortest representation: %E or %F | 392.65
274/// | a | Hexadecimal floating point, lowercase | -0xc.90fep-2
275/// | A | Hexadecimal floating point, uppercase | -0XC.90FEP-2
276/// | c | Character | a
277/// | s | String of characters | sample
278/// | p | Pointer address | b8000000
279/// | % | A % followed by another % character will write a single % to the stream. | %
280///
281/// The length sub-specifier modifies the length of the data type. This is a chart
282/// showing the types used to interpret the corresponding arguments with and without
283/// length specifier (if a different type is used, the proper type promotion or
284/// conversion is performed, if allowed):
285/// | length| d i | u o x X | f F e E g G a A | c | s | p | n |
286/// |-------|---------------|-----------------------|-----------------|-------|---------|---------|-----------------|
287/// | (none)| int | unsigned int | double | int | char* | void* | int* |
288/// | hh | signed char | unsigned char | | | | | signed char* |
289/// | h | short int | unsigned short int | | | | | short int* |
290/// | l | long int | unsigned long int | | wint_t| wchar_t*| | long int* |
291/// | ll | long long int | unsigned long long int| | | | | long long int* |
292/// | j | intmax_t | uintmax_t | | | | | intmax_t* |
293/// | z | size_t | size_t | | | | | size_t* |
294/// | t | ptrdiff_t | ptrdiff_t | | | | | ptrdiff_t* |
295/// | L | | | long double | | | | |
296/// <b>Note:</b> that the c specifier takes an int (or wint_t) as argument, but performs the proper conversion to a char value
297/// (or a wchar_t) before formatting it for output.
298/// @param[in] ... (additional arguments) Depending on the format string, the function
299/// may expect a sequence of additional arguments, each containing a value
300/// to be used to replace a format specifier in the format string (or a pointer
301/// to a storage location, for n).
302/// There should be at least as many of these arguments as the number of values specified
303/// in the format specifiers. Additional arguments are ignored by the function.
304///
305///
306/// ------------------------------------------------------------------------
307///
308/// **Example:**
309/// ~~~~~~~~~~~~~{.cpp}
310/// #include <kodi/General.h>
311/// ...
312/// kodi::QueueFormattedNotification(QUEUE_WARNING, "I'm want to inform you, here with a test call to show '%s'", "this");
313/// ...
314/// ~~~~~~~~~~~~~
315///
316inline void ATTRIBUTE_HIDDEN QueueFormattedNotification(QueueMsg type, const char* format, ...)
317{
318 using namespace kodi::addon;
319
320 va_list args;
321 va_start(args, format);
322 const std::string str = kodi::tools::StringUtils::FormatV(format, args);
323 va_end(args);
324 CAddonBase::m_interface->toKodi->kodi->queue_notification(
325 CAddonBase::m_interface->toKodi->kodiBase, type, "", str.c_str(), "", 5000, false, 1000);
326}
327//------------------------------------------------------------------------------
328
329//==============================================================================
330/// \ingroup cpp_kodi
331/// @brief Queue a notification in the GUI.
332///
333/// @param[in] type The message type.
334/// | enum code: | Description:
335/// |----------------------:|-----------------------------------
336/// | QUEUE_INFO | Show info notification message
337/// | QUEUE_WARNING | Show warning notification message
338/// | QUEUE_ERROR | Show error notification message
339/// | QUEUE_OWN_STYLE | If used can be with imageFile the wanted image set or if leaved empty shown as info, also are the other optional values available then
340/// @param[in] header Header Name (if leaved empty becomes addon name used)
341/// @param[in] message Message to display on Kodi
342/// @param[in] imageFile [opt] The image file to show on message (to use must be type set to QUEUE_OWN_STYLE)
343/// @param[in] displayTime [opt] The time how long message is displayed <b>(default 5 sec)</b> (to use must be type set to QUEUE_OWN_STYLE)
344/// @param[in] withSound [opt] if true also warning sound becomes played <b>(default with sound)</b> (to use must be type set to QUEUE_OWN_STYLE)
345/// @param[in] messageTime [opt] how many milli seconds start show of notification <b>(default 1 sec)</b> (to use must be type set to QUEUE_OWN_STYLE)
346///
347///
348/// ------------------------------------------------------------------------
349///
350/// **Example:**
351/// ~~~~~~~~~~~~~{.cpp}
352/// #include <kodi/General.h>
353/// ...
354/// kodi::QueueNotification(QUEUE_OWN_STYLE, "I'm want to inform you", "Here with a test call", "", 3000, false, 1000);
355/// ...
356/// ~~~~~~~~~~~~~
357///
358/// **Example:**
359/// ~~~~~~~~~~~~~{.cpp}
360/// #include <kodi/General.h>
361/// ...
362/// kodi::QueueNotification(QUEUE_WARNING, "I'm want to inform you", "Here with a test call");
363/// ...
364/// ~~~~~~~~~~~~~
365///
366/// **Example:**
367/// ~~~~~~~~~~~~~{.cpp}
368/// #include <kodi/General.h>
369/// ...
370/// kodi::QueueNotification(QUEUE_OWN_STYLE, "", "Here with a test call", "./myImage.png");
371/// ...
372/// ~~~~~~~~~~~~~
373///
374inline void ATTRIBUTE_HIDDEN QueueNotification(QueueMsg type,
375 const std::string& header,
376 const std::string& message,
377 const std::string& imageFile = "",
378 unsigned int displayTime = 5000,
379 bool withSound = true,
380 unsigned int messageTime = 1000)
381{
382 using namespace kodi::addon;
383
384 CAddonBase::m_interface->toKodi->kodi->queue_notification(
385 CAddonBase::m_interface->toKodi->kodiBase, type, header.c_str(), message.c_str(),
386 imageFile.c_str(), displayTime, withSound, messageTime);
387}
388//------------------------------------------------------------------------------
389
390//============================================================================
391/// \ingroup cpp_kodi
392/// @brief Get the MD5 digest of the given text
393///
394/// @param[in] text text to compute the MD5 for
395/// @return Returned MD5 digest
396///
397///
398/// ------------------------------------------------------------------------
399///
400/// **Example:**
401/// ~~~~~~~~~~~~~{.cpp}
402/// #include <kodi/General.h>
403/// ...
404/// std::string md5 = kodi::GetMD5("Make me as md5");
405/// fprintf(stderr, "My md5 digest is: '%s'\n", md5.c_str());
406/// ...
407/// ~~~~~~~~~~~~~
408///
409inline std::string ATTRIBUTE_HIDDEN GetMD5(const std::string& text)
410{
411 using namespace kodi::addon;
412
413 char* md5ret = static_cast<char*>(malloc(40 * sizeof(char))); // md5 size normally 32 bytes
414 CAddonBase::m_interface->toKodi->kodi->get_md5(CAddonBase::m_interface->toKodi->kodiBase,
415 text.c_str(), md5ret);
416 std::string md5 = md5ret;
417 free(md5ret);
418 return md5;
419}
420//----------------------------------------------------------------------------
421
422//==============================================================================
423/// \ingroup cpp_kodi
424/// @brief To get a temporary path for the addon
425///
426/// This gives a temporary path which the addon can use individually for its things.
427///
428/// The content of this folder will be deleted when Kodi is finished!
429///
430/// @param[in] append A string to append to returned temporary path
431/// @return Individual path for the addon
432///
433inline std::string ATTRIBUTE_HIDDEN GetTempAddonPath(const std::string& append = "")
434{
435 using namespace kodi::addon;
436
437 char* str = CAddonBase::m_interface->toKodi->kodi->get_temp_path(
438 CAddonBase::m_interface->toKodi->kodiBase);
439 std::string ret = str;
440 CAddonBase::m_interface->toKodi->free_string(CAddonBase::m_interface->toKodi->kodiBase, str);
441 if (!append.empty())
442 {
443 if (append.at(0) != '\\' && append.at(0) != '/')
444#ifdef TARGET_WINDOWS
445 ret.append("\\");
446#else
447 ret.append("/");
448#endif
449 ret.append(append);
450 }
451 return ret;
452}
453//------------------------------------------------------------------------------
454
455//==============================================================================
456/// \ingroup cpp_kodi
457/// @brief Returns your regions setting as a string for the specified id
458///
459/// @param[in] id id of setting to return
460/// | | Choices are | |
461/// |:------------:|:------------:|:------------:|
462/// | dateshort | time | tempunit |
463/// | datelong | meridiem | speedunit |
464///
465/// @return settings string
466///
467///
468/// ------------------------------------------------------------------------
469///
470/// **Example:**
471/// ~~~~~~~~~~~~~{.cpp}
472/// #include <kodi/General.h>
473/// ...
474/// std::string timeFormat = kodi::GetRegion("time");
475/// ...
476/// ~~~~~~~~~~~~~
477///
478inline std::string ATTRIBUTE_HIDDEN GetRegion(const std::string& id)
479{
480 using namespace kodi::addon;
481
482 AddonToKodiFuncTable_Addon* toKodi = CAddonBase::m_interface->toKodi;
483
484 std::string strReturn;
485 char* strMsg = toKodi->kodi->get_region(toKodi->kodiBase, id.c_str());
486 if (strMsg != nullptr)
487 {
488 if (std::strlen(strMsg))
489 strReturn = strMsg;
490 toKodi->free_string(toKodi->kodiBase, strMsg);
491 }
492 return strReturn;
493}
494//------------------------------------------------------------------------------
495
496//==============================================================================
497/// \ingroup cpp_kodi
498/// @brief Returns the amount of free memory in MByte (or as bytes) as an long
499/// integer
500///
501/// @param[out] free free memory
502/// @param[out] total total memory
503/// @param[in] asBytes [opt] if set to true becomes returned as bytes, otherwise
504/// as mega bytes
505///
506///
507/// ------------------------------------------------------------------------
508///
509/// **Example:**
510/// ~~~~~~~~~~~~~{.cpp}
511/// #include <kodi/General.h>
512/// ...
513/// long freeMem;
514/// long totalMem;
515/// kodi::GetFreeMem(freeMem, totalMem);
516/// ...
517/// ~~~~~~~~~~~~~
518///
519inline void ATTRIBUTE_HIDDEN GetFreeMem(long& free, long& total, bool asBytes = false)
520{
521 using namespace kodi::addon;
522
523 free = -1;
524 total = -1;
525 AddonToKodiFuncTable_Addon* toKodi = CAddonBase::m_interface->toKodi;
526 toKodi->kodi->get_free_mem(toKodi->kodiBase, &free, &total, asBytes);
527}
528//------------------------------------------------------------------------------
529
530//==============================================================================
531/// \ingroup cpp_kodi
532/// @brief Returns the elapsed idle time in seconds as an integer
533///
534/// @return idle time
535///
536///
537/// ------------------------------------------------------------------------
538///
539/// **Example:**
540/// ~~~~~~~~~~~~~{.cpp}
541/// #include <kodi/General.h>
542/// ...
543/// int time = kodi::GetGlobalIdleTime();
544/// ...
545/// ~~~~~~~~~~~~~
546///
547inline int ATTRIBUTE_HIDDEN GetGlobalIdleTime()
548{
549 using namespace kodi::addon;
550
551 AddonToKodiFuncTable_Addon* toKodi = CAddonBase::m_interface->toKodi;
552 return toKodi->kodi->get_global_idle_time(toKodi->kodiBase);
553}
554//------------------------------------------------------------------------------
555
556//==============================================================================
557/// \ingroup cpp_kodi
558/// @brief Get the currently used skin identification name from Kodi
559///
560/// @return The active skin id name as a string
561///
562///
563/// @note This is not the full path like 'special://home/addons/MediaCenter',
564/// but only 'MediaCenter'.
565///
566///
567/// ------------------------------------------------------------------------
568///
569/// **Example:**
570/// ~~~~~~~~~~~~~{.cpp}
571/// #include <kodi/General.h>
572/// ..
573/// std::string skinid = kodi::GetCurrentSkinId();
574/// ..
575/// ~~~~~~~~~~~~~
576///
577inline std::string ATTRIBUTE_HIDDEN GetCurrentSkinId()
578{
579 using namespace kodi::addon;
580
581 AddonToKodiFuncTable_Addon* toKodi = CAddonBase::m_interface->toKodi;
582
583 std::string strReturn;
584 char* strMsg = toKodi->kodi->get_current_skin_id(toKodi->kodiBase);
585 if (strMsg != nullptr)
586 {
587 if (std::strlen(strMsg))
588 strReturn = strMsg;
589 toKodi->free_string(toKodi->kodiBase, strMsg);
590 }
591 return strReturn;
592}
593//------------------------------------------------------------------------------
594
595//==============================================================================
596/// @brief To check another addon is available and usable inside Kodi.
597///
598/// @param[in] id The wanted addon identification string to check
599/// @param[out] version Version string of addon if **installed** inside Kodi
600/// @param[out] enabled Set to true <b>`true* </b> if addon is enabled
601/// @return Returns <b>`true* </b> if addon is installed
602///
603///
604/// ------------------------------------------------------------------------
605///
606/// **Example:**
607/// ~~~~~~~~~~~~~{.cpp}
608/// #include <kodi/General.h>
609///
610/// bool enabled = false;
611/// std::string version;
612/// bool ret = kodi::IsAddonAvailable("inputstream.adaptive", version, enabled);
613/// fprintf(stderr, "Available inputstream.adaptive version '%s' and enabled '%s'\n",
614/// ret ? version.c_str() : "not installed", enabled ? "yes" : "no");
615/// ~~~~~~~~~~~~~
616///
617inline bool ATTRIBUTE_HIDDEN IsAddonAvailable(const std::string& id,
618 std::string& version,
619 bool& enabled)
620{
621 using namespace kodi::addon;
622
623 AddonToKodiFuncTable_Addon* toKodi = CAddonBase::m_interface->toKodi;
624
625 char* cVersion = nullptr;
626 bool ret = toKodi->kodi->is_addon_avilable(toKodi->kodiBase, id.c_str(), &cVersion, &enabled);
627 if (cVersion)
628 {
629 version = cVersion;
630 toKodi->free_string(toKodi->kodiBase, cVersion);
631 }
632 return ret;
633}
634//------------------------------------------------------------------------------
635
636//==============================================================================
637/// \ingroup cpp_kodi
638/// @brief Get current Kodi informations and versions, returned data from the following
639/// <b><tt>kodi_version_t version; kodi::KodiVersion(version);</tt></b>
640/// is e.g.:
641/// ~~~~~~~~~~~~~{.cpp}
642/// version.compile_name = Kodi
643/// version.major = 18
644/// version.minor = 0
645/// version.revision = 20170706-c6b22fe217-di
646/// version.tag = alpha
647/// version.tag_revision = 1
648/// ~~~~~~~~~~~~~
649///
650/// @param[out] version structure to store data from kodi
651///
652///
653/// ------------------------------------------------------------------------
654///
655/// **Example:**
656/// ~~~~~~~~~~~~~{.cpp}
657/// #include <kodi/General.h>
658/// ...
659/// kodi_version_t version;
660/// kodi::KodiVersion(version);
661/// fprintf(stderr,
662/// "kodi_version_t version;\n"
663/// "kodi::KodiVersion(version);\n"
664/// " - version.compile_name = %s\n"
665/// " - version.major = %i\n"
666/// " - version.minor = %i\n"
667/// " - version.revision = %s\n"
668/// " - version.tag = %s\n"
669/// " - version.tag_revision = %s\n",
670/// version.compile_name.c_str(), version.major, version.minor,
671/// version.revision.c_str(), version.tag.c_str(), version.tag_revision.c_str());
672/// ...
673/// ~~~~~~~~~~~~~
674///
675inline void ATTRIBUTE_HIDDEN KodiVersion(kodi_version_t& version)
676{
677 using namespace kodi::addon;
678
679 char* compile_name = nullptr;
680 char* revision = nullptr;
681 char* tag = nullptr;
682 char* tag_revision = nullptr;
683
684 AddonToKodiFuncTable_Addon* toKodi = CAddonBase::m_interface->toKodi;
685 toKodi->kodi->kodi_version(toKodi->kodiBase, &compile_name, &version.major, &version.minor,
686 &revision, &tag, &tag_revision);
687 if (compile_name != nullptr)
688 {
689 version.compile_name = compile_name;
690 toKodi->free_string(toKodi->kodiBase, compile_name);
691 }
692 if (revision != nullptr)
693 {
694 version.revision = revision;
695 toKodi->free_string(toKodi->kodiBase, revision);
696 }
697 if (tag != nullptr)
698 {
699 version.tag = tag;
700 toKodi->free_string(toKodi->kodiBase, tag);
701 }
702 if (tag_revision != nullptr)
703 {
704 version.tag_revision = tag_revision;
705 toKodi->free_string(toKodi->kodiBase, tag_revision);
706 }
707}
708//------------------------------------------------------------------------------
709
710//==============================================================================
711/// \ingroup cpp_kodi
712/// @brief To get keyboard layout characters
713///
714/// This is used to get the keyboard layout currently used from Kodi by the
715/// there set language.
716///
717/// @param[in] modifierKey the key to define the needed layout (uppercase, symbols...)
718/// @param[out] layout_name name of used layout
719/// @param[out] layout list of selected keyboard layout
720/// @return true if request successed
721///
722///
723/// ------------------------------------------------------------------------
724///
725/// **Example:**
726/// ~~~~~~~~~~~~~{.cpp}
727/// #include <kodi/General.h>
728/// ...
729/// std::string layout_name;
730/// std::vector<std::vector<std::string>> layout;
731/// kodi::GetKeyboardLayout(STD_KB_MODIFIER_KEY_SHIFT | STD_KB_MODIFIER_KEY_SYMBOL, layout_name, layout);
732/// fprintf(stderr, "Layout: '%s'\n", layout_name.c_str());
733/// for (unsigned int row = 0; row < STD_KB_BUTTONS_MAX_ROWS; row++)
734/// {
735/// for (unsigned int column = 0; column < STD_KB_BUTTONS_PER_ROW; column++)
736/// {
737/// fprintf(stderr, " - Row: '%02i'; Column: '%02i'; Text: '%s'\n", row, column, layout[row][column].c_str());
738/// }
739/// }
740/// ...
741/// ~~~~~~~~~~~~~
742///
743inline bool ATTRIBUTE_HIDDEN GetKeyboardLayout(int modifierKey,
744 std::string& layout_name,
745 std::vector<std::vector<std::string>>& layout)
746{
747 using namespace kodi::addon;
748
749 AddonToKodiFuncTable_Addon* toKodi = CAddonBase::m_interface->toKodi;
750 AddonKeyboardKeyTable c_layout;
751 char* c_layout_name = nullptr;
752 bool ret =
753 toKodi->kodi->get_keyboard_layout(toKodi->kodiBase, &c_layout_name, modifierKey, &c_layout);
754 if (ret)
755 {
756 if (c_layout_name)
757 {
758 layout_name = c_layout_name;
759 toKodi->free_string(toKodi->kodiBase, c_layout_name);
760 }
761
762 layout.resize(STD_KB_BUTTONS_MAX_ROWS);
763 for (unsigned int row = 0; row < STD_KB_BUTTONS_MAX_ROWS; row++)
764 {
765 layout[row].resize(STD_KB_BUTTONS_PER_ROW);
766 for (unsigned int column = 0; column < STD_KB_BUTTONS_PER_ROW; column++)
767 {
768 char* button = c_layout.keys[row][column];
769 if (button)
770 {
771 layout[row][column] = button;
772 toKodi->free_string(toKodi->kodiBase, button);
773 }
774 }
775 }
776 }
777 return ret;
778}
779//------------------------------------------------------------------------------
780
781//==============================================================================
782/// \ingroup cpp_kodi
783/// @brief To change keyboard layout characters
784///
785/// This is used to change the keyboard layout currently used from Kodi
786///
787/// @param[out] layout_name new name of used layout (input string not used!)
788/// @return true if request successed
789///
790/// @note \ref GetKeyboardLayout must be called afterwards.
791///
792///
793/// ------------------------------------------------------------------------
794///
795/// **Example:**
796/// ~~~~~~~~~~~~~{.cpp}
797/// #include <kodi/General.h>
798/// ...
799/// std::string layout_name;
800/// kodi::ChangeKeyboardLayout(layout_name);
801///
802/// std::vector<std::vector<std::string>> layout;
803/// kodi::GetKeyboardLayout(STD_KB_MODIFIER_KEY_SHIFT | STD_KB_MODIFIER_KEY_SYMBOL, layout_name, layout);
804/// fprintf(stderr, "Layout: '%s'\n", layout_name.c_str());
805/// for (unsigned int row = 0; row < STD_KB_BUTTONS_MAX_ROWS; row++)
806/// {
807/// for (unsigned int column = 0; column < STD_KB_BUTTONS_PER_ROW; column++)
808/// {
809/// fprintf(stderr, " - Row: '%02i'; Column: '%02i'; Text: '%s'\n", row, column, layout[row][column].c_str());
810/// }
811/// }
812/// ...
813/// ~~~~~~~~~~~~~
814///
815inline bool ATTRIBUTE_HIDDEN ChangeKeyboardLayout(std::string& layout_name)
816{
817 using namespace kodi::addon;
818
819 AddonToKodiFuncTable_Addon* toKodi = CAddonBase::m_interface->toKodi;
820 char* c_layout_name = nullptr;
821 bool ret = toKodi->kodi->change_keyboard_layout(toKodi->kodiBase, &c_layout_name);
822 if (c_layout_name)
823 {
824 layout_name = c_layout_name;
825 toKodi->free_string(toKodi->kodiBase, c_layout_name);
826 }
827
828 return ret;
829}
830//------------------------------------------------------------------------------
831
832} /* namespace kodi */
833
834#endif /* __cplusplus */
diff --git a/xbmc/addons/kodi-dev-kit/include/kodi/Network.h b/xbmc/addons/kodi-dev-kit/include/kodi/Network.h
new file mode 100644
index 0000000..910385f
--- /dev/null
+++ b/xbmc/addons/kodi-dev-kit/include/kodi/Network.h
@@ -0,0 +1,282 @@
1/*
2 * Copyright (C) 2005-2018 Team Kodi
3 * This file is part of Kodi - https://kodi.tv
4 *
5 * SPDX-License-Identifier: GPL-2.0-or-later
6 * See LICENSES/README.md for more information.
7 */
8
9#pragma once
10
11#include "AddonBase.h"
12#include "c-api/network.h"
13
14#ifdef __cplusplus
15
16//==============================================================================
17/// @defgroup cpp_kodi_network Interface - kodi::network
18/// @ingroup cpp
19/// @brief **Network functions**\n
20/// The network module offers functions that allow you to control it.
21///
22/// It has the header @ref Network.h "#include <kodi/Network.h>" be included
23/// to enjoy it.
24///
25//------------------------------------------------------------------------------
26
27namespace kodi
28{
29namespace network
30{
31
32//============================================================================
33/// @ingroup cpp_kodi_network
34/// @brief Send WakeOnLan magic packet.
35///
36/// @param[in] mac Network address of the host to wake.
37/// @return True if the magic packet was successfully sent, false otherwise.
38///
39inline bool ATTRIBUTE_HIDDEN WakeOnLan(const std::string& mac)
40{
41 using namespace ::kodi::addon;
42
43 return CAddonBase::m_interface->toKodi->kodi_network->wake_on_lan(
44 CAddonBase::m_interface->toKodi->kodiBase, mac.c_str());
45}
46//----------------------------------------------------------------------------
47
48//============================================================================
49/// @ingroup cpp_kodi_network
50/// @brief To the current own ip address as a string.
51///
52/// @return Own system ip.
53///
54///
55/// ------------------------------------------------------------------------
56///
57/// **Example:**
58/// ~~~~~~~~~~~~~{.cpp}
59/// #include <kodi/Network.h>
60/// ...
61/// std::string ipAddress = kodi::network::GetIPAddress();
62/// fprintf(stderr, "My IP is '%s'\n", ipAddress.c_str());
63/// ...
64/// ~~~~~~~~~~~~~
65///
66inline std::string ATTRIBUTE_HIDDEN GetIPAddress()
67{
68 using namespace ::kodi::addon;
69
70 std::string ip;
71 char* string = CAddonBase::m_interface->toKodi->kodi_network->get_ip_address(
72 CAddonBase::m_interface->toKodi->kodiBase);
73 if (string != nullptr)
74 {
75 ip = string;
76 CAddonBase::m_interface->toKodi->free_string(CAddonBase::m_interface->toKodi->kodiBase, string);
77 }
78 return ip;
79}
80//----------------------------------------------------------------------------
81
82//============================================================================
83/// @ingroup cpp_kodi_network
84/// @brief Return our hostname.
85///
86/// @return String about hostname, empty in case of error
87///
88///
89/// ------------------------------------------------------------------------
90///
91/// **Example:**
92/// ~~~~~~~~~~~~~{.cpp}
93/// #include <kodi/Network.h>
94/// ...
95/// std::string hostname = kodi::network::GetHostname();
96/// fprintf(stderr, "My hostname is '%s'\n", hostname.c_str());
97/// ...
98/// ~~~~~~~~~~~~~
99///
100inline std::string ATTRIBUTE_HIDDEN GetHostname()
101{
102 using namespace ::kodi::addon;
103
104 std::string ip;
105 char* string = CAddonBase::m_interface->toKodi->kodi_network->get_hostname(
106 CAddonBase::m_interface->toKodi->kodiBase);
107 if (string != nullptr)
108 {
109 ip = string;
110 CAddonBase::m_interface->toKodi->free_string(CAddonBase::m_interface->toKodi->kodiBase, string);
111 }
112 return ip;
113}
114//----------------------------------------------------------------------------
115
116//============================================================================
117/// @ingroup cpp_kodi_network
118/// @brief Returns Kodi's HTTP UserAgent string.
119///
120/// @return HTTP user agent
121///
122///
123/// ------------------------------------------------------------------------
124///
125/// **Example:**
126/// ~~~~~~~~~~~~~{.py}
127/// ..
128/// std::string agent = kodi::network::GetUserAgent()
129/// ..
130/// ~~~~~~~~~~~~~
131///
132/// example output:
133/// Kodi/19.0-ALPHA1 (X11; Linux x86_64) Ubuntu/20.04 App_Bitness/64 Version/19.0-ALPHA1-Git:20200522-0076d136d3-dirty
134///
135inline std::string ATTRIBUTE_HIDDEN GetUserAgent()
136{
137 using namespace ::kodi::addon;
138
139 std::string agent;
140 char* string = CAddonBase::m_interface->toKodi->kodi_network->get_user_agent(
141 CAddonBase::m_interface->toKodi->kodiBase);
142 if (string != nullptr)
143 {
144 agent = string;
145 CAddonBase::m_interface->toKodi->free_string(CAddonBase::m_interface->toKodi->kodiBase, string);
146 }
147 return agent;
148}
149//----------------------------------------------------------------------------
150
151//============================================================================
152/// @ingroup cpp_kodi_network
153/// @brief Check given name or ip address corresponds to localhost.
154///
155/// @param[in] hostname Hostname to check
156/// @return Return true if given name or ip address corresponds to localhost
157///
158///
159/// ------------------------------------------------------------------------
160///
161/// **Example:**
162/// ~~~~~~~~~~~~~{.cpp}
163/// #include <kodi/Network.h>
164/// ...
165/// if (kodi::network::IsLocalHost("127.0.0.1"))
166/// fprintf(stderr, "Is localhost\n");
167/// ...
168/// ~~~~~~~~~~~~~
169///
170inline bool ATTRIBUTE_HIDDEN IsLocalHost(const std::string& hostname)
171{
172 using namespace ::kodi::addon;
173
174 return CAddonBase::m_interface->toKodi->kodi_network->is_local_host(
175 CAddonBase::m_interface->toKodi->kodiBase, hostname.c_str());
176}
177//----------------------------------------------------------------------------
178
179//==============================================================================
180/// @ingroup cpp_kodi_network
181/// @brief Checks whether the specified path refers to a local network.
182///
183/// @param[in] hostname Hostname to check
184/// @param[in] offLineCheck Check if in private range, see https://en.wikipedia.org/wiki/Private_network
185/// @return True if host is on a LAN, false otherwise
186///
187inline bool ATTRIBUTE_HIDDEN IsHostOnLAN(const std::string& hostname, bool offLineCheck = false)
188{
189 using namespace kodi::addon;
190
191 return CAddonBase::m_interface->toKodi->kodi_network->is_host_on_lan(
192 CAddonBase::m_interface->toKodi->kodiBase, hostname.c_str(), offLineCheck);
193}
194//------------------------------------------------------------------------------
195
196//============================================================================
197/// @ingroup cpp_kodi_network
198/// @brief URL encodes the given string
199///
200/// This function converts the given input string to a URL encoded string and
201/// returns that as a new allocated string. All input characters that are
202/// not a-z, A-Z, 0-9, '-', '.', '_' or '~' are converted to their "URL escaped"
203/// version (%NN where NN is a two-digit hexadecimal number).
204///
205/// @param[in] url The code of the message to get.
206/// @return Encoded URL string
207///
208///
209/// ------------------------------------------------------------------------
210///
211/// **Example:**
212/// ~~~~~~~~~~~~~{.cpp}
213/// #include <kodi/Network.h>
214/// ...
215/// std::string encodedUrl = kodi::network::URLEncode("François");
216/// fprintf(stderr, "Encoded URL is '%s'\n", encodedUrl.c_str());
217/// ...
218/// ~~~~~~~~~~~~~
219/// For example, the string: François ,would be encoded as: Fran%C3%A7ois
220///
221inline std::string ATTRIBUTE_HIDDEN URLEncode(const std::string& url)
222{
223 using namespace ::kodi::addon;
224
225 std::string retString;
226 char* string = CAddonBase::m_interface->toKodi->kodi_network->url_encode(
227 CAddonBase::m_interface->toKodi->kodiBase, url.c_str());
228 if (string != nullptr)
229 {
230 retString = string;
231 CAddonBase::m_interface->toKodi->free_string(CAddonBase::m_interface->toKodi->kodiBase, string);
232 }
233 return retString;
234}
235//----------------------------------------------------------------------------
236
237//============================================================================
238/// @ingroup cpp_kodi_network
239/// @brief Lookup URL in DNS cache
240///
241/// This test will get DNS record for a domain. The DNS lookup is done directly
242/// against the domain's authoritative name server, so changes to DNS Records
243/// should show up instantly. By default, the DNS lookup tool will return an
244/// IP address if you give it a name (e.g. www.example.com)
245///
246/// @param[in] hostName The code of the message to get.
247/// @param[out] ipAddress Returned address
248/// @return true if successfull
249///
250///
251/// ------------------------------------------------------------------------
252///
253/// **Example:**
254/// ~~~~~~~~~~~~~{.cpp}
255/// #include <kodi/Network.h>
256/// ...
257/// std::string ipAddress;
258/// bool ret = kodi::network::DNSLookup("www.google.com", ipAddress);
259/// fprintf(stderr, "DNSLookup returned for www.google.com the IP '%s', call was %s\n", ipAddress.c_str(), ret ? "ok" : "failed");
260/// ...
261/// ~~~~~~~~~~~~~
262///
263inline bool ATTRIBUTE_HIDDEN DNSLookup(const std::string& hostName, std::string& ipAddress)
264{
265 using namespace ::kodi::addon;
266
267 bool ret = false;
268 char* string = CAddonBase::m_interface->toKodi->kodi_network->dns_lookup(
269 CAddonBase::m_interface->toKodi->kodiBase, hostName.c_str(), &ret);
270 if (string != nullptr)
271 {
272 ipAddress = string;
273 CAddonBase::m_interface->toKodi->free_string(CAddonBase::m_interface->toKodi->kodiBase, string);
274 }
275 return ret;
276}
277//----------------------------------------------------------------------------
278
279} /* namespace network */
280} /* namespace kodi */
281
282#endif /* __cplusplus */
diff --git a/xbmc/addons/kodi-dev-kit/include/kodi/StreamCodec.h b/xbmc/addons/kodi-dev-kit/include/kodi/StreamCodec.h
new file mode 100644
index 0000000..e030371
--- /dev/null
+++ b/xbmc/addons/kodi-dev-kit/include/kodi/StreamCodec.h
@@ -0,0 +1,126 @@
1/*
2 * Copyright (C) 2017-2018 Team Kodi
3 * This file is part of Kodi - https://kodi.tv
4 *
5 * SPDX-License-Identifier: GPL-2.0-or-later
6 * See LICENSES/README.md for more information.
7 */
8
9#pragma once
10
11#ifdef __cplusplus
12extern "C"
13{
14#endif /* __cplusplus */
15
16 //==============================================================================
17 /// @ingroup cpp_kodi_addon_videocodec_Defs_VIDEOCODEC_INITDATA
18 /// @brief The standard defines several sets of capabilities, which are referred
19 /// to as profiles, targeting specific classes of applications.
20 //@{
21 enum STREAMCODEC_PROFILE
22 {
23 /// @brief Unknown codec profile
24 CodecProfileUnknown = 0,
25
26 /// @brief If a codec profile is not required
27 CodecProfileNotNeeded,
28
29 /// @brief **H264** Baseline Profile (BP, 66)
30 ///
31 /// Primarily for low-cost applications that require additional data loss
32 /// robustness, this profile is used in some videoconferencing and mobile
33 /// applications. This profile includes all features that are supported
34 /// in the Constrained Baseline Profile, plus three additional features
35 /// that can be used for loss robustness (or for other purposes such as
36 /// low-delay multi-point video stream compositing). The importance of
37 /// this profile has faded somewhat since the definition of the Constrained
38 /// Baseline Profile in 2009. All Constrained Baseline Profile bitstreams
39 /// are also considered to be Baseline Profile bitstreams, as these two
40 /// profiles share the same profile identifier code value.
41 H264CodecProfileBaseline,
42
43 /// @brief **H264** Main Profile (MP, 77)
44 ///
45 /// This profile is used for standard-definition digital TV broadcasts that
46 /// use the MPEG-4 format as defined in the
47 /// [DVB standard](http://www.etsi.org/deliver/etsi_ts/101100_101199/101154/01.09.01_60/ts_101154v010901p.pdf).
48 /// It is not, however, used for high-definition television broadcasts, as the
49 /// importance of this profile faded when the High Profile was developed
50 /// in 2004 for that application.
51 H264CodecProfileMain,
52
53 /// @brief **H264** Extended Profile (XP, 88)
54 ///
55 /// Intended as the streaming video profile, this profile has relatively high
56 /// compression capability and some extra tricks for robustness to data losses
57 /// and server stream switching.
58 H264CodecProfileExtended,
59
60 /// @brief **H264** High Profile (HiP, 100)
61 ///
62 /// The primary profile for broadcast and disc storage applications,
63 /// particularly for high-definition television applications (for example,
64 /// this is the profile adopted by the [Blu-ray Disc](https://en.wikipedia.org/wiki/Blu-ray_Disc)
65 /// storage format and the [DVB](https://en.wikipedia.org/wiki/Digital_Video_Broadcasting)
66 /// HDTV broadcast service).
67 H264CodecProfileHigh,
68
69 /// @brief **H264** High 10 Profile (Hi10P, 110)
70 ///
71 /// Going beyond typical mainstream consumer product capabilities, this
72 /// profile builds on top of the High Profile, adding support for up to 10
73 /// bits per sample of decoded picture precision.
74 H264CodecProfileHigh10,
75
76 /// @brief **H264** High 4:2:2 Profile (Hi422P, 122)
77 ///
78 /// Primarily targeting professional applications that use interlaced video,
79 /// this profile builds on top of the High 10 Profile, adding support for the
80 /// 4:2:2 chroma sampling format while using up to 10 bits per sample of
81 /// decoded picture precision.
82 H264CodecProfileHigh422,
83
84 /// @brief **H264** High 4:4:4 Predictive Profile (Hi444PP, 244)
85 ///
86 /// This profile builds on top of the High 4:2:2 Profile, supporting up to
87 /// 4:4:4 chroma sampling, up to 14 bits per sample, and additionally
88 /// supporting efficient lossless region coding and the coding of each
89 /// picture as three separate color planes.
90 H264CodecProfileHigh444Predictive,
91
92 /// @brief **VP9** profile 0
93 ///
94 /// There are several variants of the VP9 format (known as "coding profiles"),
95 /// which successively allow more features; profile 0 is the basic variant,
96 /// requiring the least from a hardware implementation.
97 ///
98 /// [Color depth](https://en.wikipedia.org/wiki/Color_depth): 8 bit/sample,
99 /// [chroma subsampling](https://en.wikipedia.org/wiki/Chroma_subsampling): 4:2:0
100 VP9CodecProfile0 = 20,
101
102 /// @brief **VP9** profile 1
103 ///
104 /// [Color depth](https://en.wikipedia.org/wiki/Color_depth): 8 bit,
105 /// [chroma subsampling](https://en.wikipedia.org/wiki/Chroma_subsampling): 4:2:0, 4:2:2, 4:4:4
106 VP9CodecProfile1,
107
108 /// @brief **VP9** profile 2
109 ///
110 /// [Color depth](https://en.wikipedia.org/wiki/Color_depth): 10–12 bit,
111 /// [chroma subsampling](https://en.wikipedia.org/wiki/Chroma_subsampling): 4:2:0
112 VP9CodecProfile2,
113
114 /// @brief **VP9** profile 3
115 ///
116 /// [Color depth](https://en.wikipedia.org/wiki/Color_depth): 10–12 bit,
117 /// [chroma subsampling](https://en.wikipedia.org/wiki/Chroma_subsampling): 4:2:0, 4:2:2, 4:4:4,
118 /// see [VP9 Bitstream & Decoding Process Specification](https://storage.googleapis.com/downloads.webmproject.org/docs/vp9/vp9-bitstream-specification-v0.6-20160331-draft.pdf)
119 VP9CodecProfile3,
120 };
121 //@}
122 //------------------------------------------------------------------------------
123
124#ifdef __cplusplus
125} /* extern "C" */
126#endif /* __cplusplus */
diff --git a/xbmc/addons/kodi-dev-kit/include/kodi/StreamCrypto.h b/xbmc/addons/kodi-dev-kit/include/kodi/StreamCrypto.h
new file mode 100644
index 0000000..8008aa1
--- /dev/null
+++ b/xbmc/addons/kodi-dev-kit/include/kodi/StreamCrypto.h
@@ -0,0 +1,42 @@
1/*
2 * Copyright (C) 2017-2018 Team Kodi
3 * This file is part of Kodi - https://kodi.tv
4 *
5 * SPDX-License-Identifier: GPL-2.0-or-later
6 * See LICENSES/README.md for more information.
7 */
8
9#pragma once
10
11#include <inttypes.h>
12#include <string.h>
13
14#define STREAMCRYPTO_VERSION_LEVEL 1
15
16#ifdef __cplusplus
17extern "C"
18{
19#endif /* __cplusplus */
20
21 typedef struct CRYPTO_INFO
22 {
23 enum CRYPTO_KEY_SYSTEM : uint8_t
24 {
25 CRYPTO_KEY_SYSTEM_NONE = 0,
26 CRYPTO_KEY_SYSTEM_WIDEVINE,
27 CRYPTO_KEY_SYSTEM_PLAYREADY,
28 CRYPTO_KEY_SYSTEM_WISEPLAY,
29 CRYPTO_KEY_SYSTEM_COUNT
30 } m_CryptoKeySystem; /*!< @brief keysystem for encrypted media, KEY_SYSTEM_NONE for unencrypted media */
31
32 static const uint8_t FLAG_SECURE_DECODER =
33 1; /*!< @brief is set in flags if decoding has to be done in TEE environment */
34
35 uint8_t flags;
36 uint16_t m_CryptoSessionIdSize; /*!< @brief The size of the crypto session key id */
37 const char* m_CryptoSessionId; /*!< @brief The crypto session key id */
38 } CRYPTO_INFO;
39
40#ifdef __cplusplus
41} /* extern "C" */
42#endif /* __cplusplus */
diff --git a/xbmc/addons/kodi-dev-kit/include/kodi/addon-instance/AudioDecoder.h b/xbmc/addons/kodi-dev-kit/include/kodi/addon-instance/AudioDecoder.h
new file mode 100644
index 0000000..a6bea7d
--- /dev/null
+++ b/xbmc/addons/kodi-dev-kit/include/kodi/addon-instance/AudioDecoder.h
@@ -0,0 +1,595 @@
1/*
2 * Copyright (C) 2005-2018 Team Kodi
3 * This file is part of Kodi - https://kodi.tv
4 *
5 * SPDX-License-Identifier: GPL-2.0-or-later
6 * See LICENSES/README.md for more information.
7 */
8
9#pragma once
10
11#include "../AddonBase.h"
12#include "../AudioEngine.h"
13#include "../c-api/addon-instance/audio_decoder.h"
14
15#ifdef __cplusplus
16namespace kodi
17{
18namespace addon
19{
20
21class CInstanceAudioDecoder;
22
23//==============================================================================
24/// @defgroup cpp_kodi_addon_audiodecoder_Defs_AudioDecoderInfoTag class AudioDecoderInfoTag
25/// @ingroup cpp_kodi_addon_audiodecoder_Defs
26/// @brief **Info tag data structure**\n
27/// Representation of available information of processed audio file.
28///
29/// This is used to store all the necessary data of audio stream and to have on
30/// e.g. GUI for information.
31///
32/// ----------------------------------------------------------------------------
33///
34/// @copydetails cpp_kodi_addon_audiodecoder_Defs_AudioDecoderInfoTag_Help
35///
36///@{
37class AudioDecoderInfoTag : public CStructHdl<AudioDecoderInfoTag, AUDIO_DECODER_INFO_TAG>
38{
39 /*! \cond PRIVATE */
40 friend class CInstanceAudioDecoder;
41 /*! \endcond */
42
43public:
44 /*! \cond PRIVATE */
45 AudioDecoderInfoTag() { memset(m_cStructure, 0, sizeof(AUDIO_DECODER_INFO_TAG)); }
46 AudioDecoderInfoTag(const AudioDecoderInfoTag& tag) : CStructHdl(tag) {}
47 /*! \endcond */
48
49 /// @defgroup cpp_kodi_addon_audiodecoder_Defs_AudioDecoderInfoTag_Help Value Help
50 /// @ingroup cpp_kodi_addon_audiodecoder_Defs_AudioDecoderInfoTag
51 ///
52 /// <b>The following table contains values that can be set with @ref cpp_kodi_addon_audiodecoder_Defs_AudioDecoderInfoTag :</b>
53 /// | Name | Type | Set call | Get call
54 /// |------|------|----------|----------
55 /// | **Title** | `std::string` | @ref AudioDecoderInfoTag::SetTitle "SetTitle" | @ref AudioDecoderInfoTag::GetTitle "GetTitle"
56 /// | **Artist** | `std::string` | @ref AudioDecoderInfoTag::SetArtist "SetArtist" | @ref AudioDecoderInfoTag::GetArtist "GetArtist"
57 /// | **Album** | `std::string` | @ref AudioDecoderInfoTag::SetAlbum "SetAlbum" | @ref AudioDecoderInfoTag::GetAlbum "GetAlbum"
58 /// | **Album artist** | `std::string` | @ref AudioDecoderInfoTag::SetAlbumArtist "SetAlbumArtist" | @ref AudioDecoderInfoTag::GetAlbumArtist "GetAlbumArtist"
59 /// | **Media type** | `std::string` | @ref AudioDecoderInfoTag::SetMediaType "SetMediaType" | @ref AudioDecoderInfoTag::GetMediaType "GetMediaType"
60 /// | **Genre** | `std::string` | @ref AudioDecoderInfoTag::SetGenre "SetGenre" | @ref AudioDecoderInfoTag::GetGenre "GetGenre"
61 /// | **Duration** | `int` | @ref AudioDecoderInfoTag::SetDuration "SetDuration" | @ref AudioDecoderInfoTag::GetDuration "GetDuration"
62 /// | **Track number** | `int` | @ref AudioDecoderInfoTag::SetTrack "SetTrack" | @ref AudioDecoderInfoTag::GetTrack "GetTrack"
63 /// | **Disc number** | `int` | @ref AudioDecoderInfoTag::SetDisc "SetDisc" | @ref AudioDecoderInfoTag::GetDisc "GetDisc"
64 /// | **Disc subtitle name** | `std::string` | @ref AudioDecoderInfoTag::SetDiscSubtitle "SetDiscSubtitle" | @ref AudioDecoderInfoTag::GetDiscSubtitle "GetDiscSubtitle"
65 /// | **Disc total amount** | `int` | @ref AudioDecoderInfoTag::SetDiscTotal "SetDiscTotal" | @ref AudioDecoderInfoTag::GetDiscTotal "GetDiscTotal"
66 /// | **Release date** | `std::string` | @ref AudioDecoderInfoTag::SetReleaseDate "SetReleaseDate" | @ref AudioDecoderInfoTag::GetReleaseDate "GetReleaseDate"
67 /// | **Lyrics** | `std::string` | @ref AudioDecoderInfoTag::SetLyrics "SetLyrics" | @ref AudioDecoderInfoTag::GetLyrics "GetLyrics"
68 /// | **Samplerate** | `int` | @ref AudioDecoderInfoTag::SetSamplerate "SetSamplerate" | @ref AudioDecoderInfoTag::GetSamplerate "GetSamplerate"
69 /// | **Channels amount** | `int` | @ref AudioDecoderInfoTag::SetChannels "SetChannels" | @ref AudioDecoderInfoTag::GetChannels "GetChannels"
70 /// | **Bitrate** | `int` | @ref AudioDecoderInfoTag::SetBitrate "SetBitrate" | @ref AudioDecoderInfoTag::GetBitrate "GetBitrate"
71 /// | **Comment text** | `std::string` | @ref AudioDecoderInfoTag::SetComment "SetComment" | @ref AudioDecoderInfoTag::GetComment "GetComment"
72 ///
73
74 /// @addtogroup cpp_kodi_addon_audiodecoder_Defs_AudioDecoderInfoTag
75 ///@{
76
77 /// @brief Set the title from music as string on info tag.
78 void SetTitle(const std::string& title)
79 {
80 strncpy(m_cStructure->title, title.c_str(), sizeof(m_cStructure->title) - 1);
81 }
82
83 /// @brief Get title name
84 std::string GetTitle() const { return m_cStructure->title; }
85
86 /// @brief Set artist name
87 void SetArtist(const std::string& artist)
88 {
89 strncpy(m_cStructure->artist, artist.c_str(), sizeof(m_cStructure->artist) - 1);
90 }
91
92 /// @brief Get artist name
93 std::string GetArtist() const { return m_cStructure->artist; }
94
95 /// @brief Set album name
96 void SetAlbum(const std::string& album)
97 {
98 strncpy(m_cStructure->album, album.c_str(), sizeof(m_cStructure->album) - 1);
99 }
100
101 /// @brief Set album name
102 std::string GetAlbum() const { return m_cStructure->album; }
103
104 /// @brief Set album artist name
105 void SetAlbumArtist(const std::string& albumArtist)
106 {
107 strncpy(m_cStructure->album_artist, albumArtist.c_str(),
108 sizeof(m_cStructure->album_artist) - 1);
109 }
110
111 /// @brief Get album artist name
112 std::string GetAlbumArtist() const { return m_cStructure->album_artist; }
113
114 /// @brief Set the media type of the music item.
115 ///
116 /// Available strings about media type for music:
117 /// | String | Description |
118 /// |---------------:|:--------------------------------------------------|
119 /// | artist | If it is defined as an artist
120 /// | album | If it is defined as an album
121 /// | music | If it is defined as an music
122 /// | song | If it is defined as a song
123 ///
124 void SetMediaType(const std::string& mediaType)
125 {
126 strncpy(m_cStructure->media_type, mediaType.c_str(), sizeof(m_cStructure->media_type) - 1);
127 }
128
129 /// @brief Get the media type of the music item.
130 std::string GetMediaType() const { return m_cStructure->media_type; }
131
132 /// @brief Set genre name from music as string if present.
133 void SetGenre(const std::string& genre)
134 {
135 strncpy(m_cStructure->genre, genre.c_str(), sizeof(m_cStructure->genre) - 1);
136 }
137
138 /// @brief Get genre name from music as string if present.
139 std::string GetGenre() const { return m_cStructure->genre; }
140
141 /// @brief Set the duration of music as integer from info.
142 void SetDuration(int duration) { m_cStructure->duration = duration; }
143
144 /// @brief Get the duration of music as integer from info.
145 int GetDuration() const { return m_cStructure->duration; }
146
147 /// @brief Set track number (if present) from music info as integer.
148 void SetTrack(int track) { m_cStructure->track = track; }
149
150 /// @brief Get track number (if present).
151 int GetTrack() const { return m_cStructure->track; }
152
153 /// @brief Set disk number (if present) from music info as integer.
154 void SetDisc(int disc) { m_cStructure->disc = disc; }
155
156 /// @brief Get disk number (if present)
157 int GetDisc() const { return m_cStructure->disc; }
158
159 /// @brief Set disk subtitle name (if present) from music info.
160 void SetDiscSubtitle(const std::string& discSubtitle)
161 {
162 strncpy(m_cStructure->disc_subtitle, discSubtitle.c_str(),
163 sizeof(m_cStructure->disc_subtitle) - 1);
164 }
165
166 /// @brief Get disk subtitle name (if present) from music info.
167 std::string GetDiscSubtitle() const { return m_cStructure->disc_subtitle; }
168
169 /// @brief Set disks amount quantity (if present) from music info as integer.
170 void SetDiscTotal(int discTotal) { m_cStructure->disc_total = discTotal; }
171
172 /// @brief Get disks amount quantity (if present)
173 int GetDiscTotal() const { return m_cStructure->disc_total; }
174
175 /// @brief Set release date as string from music info (if present).\n
176 /// [ISO8601](https://en.wikipedia.org/wiki/ISO_8601) date YYYY, YYYY-MM or YYYY-MM-DD
177 void SetReleaseDate(const std::string& releaseDate)
178 {
179 strncpy(m_cStructure->release_date, releaseDate.c_str(),
180 sizeof(m_cStructure->release_date) - 1);
181 }
182
183 /// @brief Get release date as string from music info (if present).
184 std::string GetReleaseDate() const { return m_cStructure->release_date; }
185
186 /// @brief Set string from lyrics.
187 void SetLyrics(const std::string& lyrics)
188 {
189 strncpy(m_cStructure->lyrics, lyrics.c_str(), sizeof(m_cStructure->lyrics) - 1);
190 }
191
192 /// @brief Get string from lyrics.
193 std::string GetLyrics() const { return m_cStructure->lyrics; }
194
195 /// @brief Set related stream samplerate.
196 void SetSamplerate(int samplerate) { m_cStructure->samplerate = samplerate; }
197
198 /// @brief Get related stream samplerate.
199 int GetSamplerate() const { return m_cStructure->samplerate; }
200
201 /// @brief Set related stream channels amount.
202 void SetChannels(int channels) { m_cStructure->channels = channels; }
203
204 /// @brief Get related stream channels amount.
205 int GetChannels() const { return m_cStructure->channels; }
206
207 /// @brief Set related stream bitrate.
208 void SetBitrate(int bitrate) { m_cStructure->bitrate = bitrate; }
209
210 /// @brief Get related stream bitrate.
211 int GetBitrate() const { return m_cStructure->bitrate; }
212
213 /// @brief Set additional information comment (if present).
214 void SetComment(const std::string& comment)
215 {
216 strncpy(m_cStructure->comment, comment.c_str(), sizeof(m_cStructure->comment) - 1);
217 }
218
219 /// @brief Get additional information comment (if present).
220 std::string GetComment() const { return m_cStructure->comment; }
221
222 ///@}
223
224private:
225 AudioDecoderInfoTag(const AUDIO_DECODER_INFO_TAG* tag) : CStructHdl(tag) {}
226 AudioDecoderInfoTag(AUDIO_DECODER_INFO_TAG* tag) : CStructHdl(tag) {}
227};
228///@}
229//------------------------------------------------------------------------------
230
231//==============================================================================
232/// @defgroup cpp_kodi_addon_audiodecoder_Defs Definitions, structures and enumerators
233/// @ingroup cpp_kodi_addon_audiodecoder
234/// @brief **Audio decoder add-on instance definition values**\n
235/// All audio decoder functions associated data structures.
236///
237/// Used to exchange the available options between Kodi and addon.\n
238/// The groups described here correspond to the groups of functions on audio
239/// decoder instance class.
240///
241
242//==============================================================================
243///
244/// \addtogroup cpp_kodi_addon_audiodecoder
245/// @brief \cpp_class{ kodi::addon::CInstanceAudioDecoder }
246/// **Audio decoder add-on instance**
247///
248/// For audio decoders as binary add-ons. This class implements a way to handle
249/// special types of audio files.
250///
251/// The add-on handles loading of the source file and outputting the audio stream
252/// for consumption by the player.
253///
254/// The addon.xml defines the capabilities of this add-on.
255///
256/// @note The option to have multiple instances is possible with audio-decoder
257/// add-ons. This is useful, since some playback engines are riddled by global
258/// variables, making decoding of multiple streams using the same instance
259/// impossible.
260///
261///
262/// ----------------------------------------------------------------------------
263///
264/// **Here's an example on addon.xml:**
265/// ~~~~~~~~~~~~~{.xml}
266/// <?xml version="1.0" encoding="UTF-8"?>
267/// <addon
268/// id="audiodecoder.myspecialnamefor"
269/// version="1.0.0"
270/// name="My special audio decoder addon"
271/// provider-name="Your Name">
272/// <requires>@ADDON_DEPENDS@</requires>
273/// <extension
274/// point="kodi.audiodecoder"
275/// name="2sf"
276/// extension=".2sf|.mini2sf"
277/// tags="true"
278/// library_@PLATFORM@="@LIBRARY_FILENAME@"/>
279/// <extension point="xbmc.addon.metadata">
280/// <summary lang="en_GB">My audio decoder addon addon</summary>
281/// <description lang="en_GB">My audio decoder addon description</description>
282/// <platform>@PLATFORM@</platform>
283/// </extension>
284/// </addon>
285/// ~~~~~~~~~~~~~
286///
287/// Description to audio decoder related addon.xml values:
288/// | Name | Description
289/// |:------------------------------|----------------------------------------
290/// | <b>`point`</b> | Addon type specification<br>At all addon types and for this kind always <b>"kodi.audiodecoder"</b>.
291/// | <b>`library_@PLATFORM@`</b> | Sets the used library name, which is automatically set by cmake at addon build.
292/// | <b>`name`</b> | The name of the decoder used in Kodi for display.
293/// | <b>`extension`</b> | The file extensions / styles supported by this addon.
294/// | <b>`tags`</b> | Boolean to point out that addon can bring own information to replayed file, if <b>`false`</b> only the file name is used as info.<br>If <b>`true`</b>, \ref CInstanceAudioDecoder::ReadTag is used and must be implemented.
295///
296/// --------------------------------------------------------------------------
297///
298/// **Here is a code example how this addon is used:**
299///
300/// ~~~~~~~~~~~~~{.cpp}
301/// #include <kodi/addon-instance/AudioDecoder.h>
302///
303/// class CMyAudioDecoder : public kodi::addon::CInstanceAudioDecoder
304/// {
305/// public:
306/// CMyAudioDecoder(KODI_HANDLE instance, const std::string& version);
307///
308/// bool Init(const std::string& filename, unsigned int filecache,
309/// int& channels, int& samplerate,
310/// int& bitspersample, int64_t& totaltime,
311/// int& bitrate, AudioEngineDataFormat& format,
312/// std::vector<AudioEngineChannel>& channellist) override;
313/// int ReadPCM(uint8_t* buffer, int size, int& actualsize) override;
314/// };
315///
316/// CMyAudioDecoder::CMyAudioDecoder(KODI_HANDLE instance, const std::string& version)
317/// : kodi::addon::CInstanceAudioDecoder(instance, version)
318/// {
319/// ...
320/// }
321///
322/// bool CMyAudioDecoder::Init(const std::string& filename, unsigned int filecache,
323/// int& channels, int& samplerate,
324/// int& bitspersample, int64_t& totaltime,
325/// int& bitrate, AudioEngineDataFormat& format,
326/// std::vector<AudioEngineChannel>& channellist)
327/// {
328/// ...
329/// return true;
330/// }
331///
332/// int CMyAudioDecoder::ReadPCM(uint8_t* buffer, int size, int& actualsize)
333/// {
334/// ...
335/// return 0;
336/// }
337///
338///
339/// //----------------------------------------------------------------------
340///
341/// class CMyAddon : public kodi::addon::CAddonBase
342/// {
343/// public:
344/// CMyAddon() { }
345/// ADDON_STATUS CreateInstance(int instanceType,
346/// const std::string& instanceID,
347/// KODI_HANDLE instance,
348/// const std::string& version,
349/// KODI_HANDLE& addonInstance) override;
350/// };
351///
352/// // If you use only one instance in your add-on, can be instanceType and
353/// // instanceID ignored
354/// ADDON_STATUS CMyAddon::CreateInstance(int instanceType,
355/// const std::string& instanceID,
356/// KODI_HANDLE instance,
357/// const std::string& version,
358/// KODI_HANDLE& addonInstance)
359/// {
360/// if (instanceType == ADDON_INSTANCE_AUDIODECODER)
361/// {
362/// kodi::Log(ADDON_LOG_INFO, "Creating my audio decoder");
363/// addonInstance = new CMyAudioDecoder(instance, version);
364/// return ADDON_STATUS_OK;
365/// }
366/// else if (...)
367/// {
368/// ...
369/// }
370/// return ADDON_STATUS_UNKNOWN;
371/// }
372///
373/// ADDONCREATOR(CMyAddon)
374/// ~~~~~~~~~~~~~
375///
376/// The destruction of the example class `CMyAudioDecoder` is called from
377/// Kodi's header. Manually deleting the add-on instance is not required.
378///
379class ATTRIBUTE_HIDDEN CInstanceAudioDecoder : public IAddonInstance
380{
381public:
382 //==========================================================================
383 /// @ingroup cpp_kodi_addon_audiodecoder
384 /// @brief Audio decoder class constructor used to support multiple instance
385 /// types.
386 ///
387 /// @param[in] instance The instance value given to
388 /// <b>`kodi::addon::CAddonBase::CreateInstance(...)`</b>.
389 /// @param[in] kodiVersion [opt] Version used in Kodi for this instance, to
390 /// allow compatibility to older Kodi versions.
391 ///
392 /// @note Recommended to set <b>`kodiVersion`</b>.
393 ///
394 ///
395 /// --------------------------------------------------------------------------
396 ///
397 /// **Here's example about the use of this:**
398 /// ~~~~~~~~~~~~~{.cpp}
399 /// class CMyAudioDecoder : public kodi::addon::CInstanceAudioDecoder
400 /// {
401 /// public:
402 /// CMyAudioDecoder(KODI_HANDLE instance, const std::string& kodiVersion)
403 /// : kodi::addon::CInstanceAudioDecoder(instance, kodiVersion)
404 /// {
405 /// ...
406 /// }
407 ///
408 /// ...
409 /// };
410 ///
411 /// ADDON_STATUS CMyAddon::CreateInstance(int instanceType,
412 /// const std::string& instanceID,
413 /// KODI_HANDLE instance,
414 /// const std::string& version,
415 /// KODI_HANDLE& addonInstance)
416 /// {
417 /// kodi::Log(ADDON_LOG_INFO, "Creating my audio decoder");
418 /// addonInstance = new CMyAudioDecoder(instance, version);
419 /// return ADDON_STATUS_OK;
420 /// }
421 /// ~~~~~~~~~~~~~
422 ///
423 explicit CInstanceAudioDecoder(KODI_HANDLE instance, const std::string& kodiVersion = "")
424 : IAddonInstance(ADDON_INSTANCE_AUDIODECODER,
425 !kodiVersion.empty() ? kodiVersion
426 : GetKodiTypeVersion(ADDON_INSTANCE_AUDIODECODER))
427 {
428 if (CAddonBase::m_interface->globalSingleInstance != nullptr)
429 throw std::logic_error("kodi::addon::CInstanceAudioDecoder: Creation of multiple together with single instance way is not allowed!");
430
431 SetAddonStruct(instance);
432 }
433 //--------------------------------------------------------------------------
434
435 //==========================================================================
436 /// @ingroup cpp_kodi_addon_audiodecoder
437 /// @brief Initialize a decoder.
438 ///
439 /// @param[in] filename The file to read
440 /// @param[in] filecache The file cache size
441 /// @param[out] channels Number of channels in output stream
442 /// @param[out] samplerate Samplerate of output stream
443 /// @param[out] bitspersample Bits per sample in output stream
444 /// @param[out] totaltime Total time for stream
445 /// @param[out] bitrate Average bitrate of input stream
446 /// @param[out] format Data format for output stream, see
447 /// @ref cpp_kodi_audioengine_Defs_AudioEngineFormat for
448 /// available values
449 /// @param[out] channellist Channel mapping for output streamm, see
450 /// @ref cpp_kodi_audioengine_Defs_AudioEngineChannel
451 /// for available values
452 /// @return true if successfully done, otherwise false
453 ///
454 virtual bool Init(const std::string& filename,
455 unsigned int filecache,
456 int& channels,
457 int& samplerate,
458 int& bitspersample,
459 int64_t& totaltime,
460 int& bitrate,
461 AudioEngineDataFormat& format,
462 std::vector<AudioEngineChannel>& channellist) = 0;
463 //--------------------------------------------------------------------------
464
465 //==========================================================================
466 /// @ingroup cpp_kodi_addon_audiodecoder
467 /// @brief Produce some noise.
468 ///
469 /// @param[in] buffer Output buffer
470 /// @param[in] size Size of output buffer
471 /// @param[out] actualsize Actual number of bytes written to output buffer
472 /// @return Return with following possible values:
473 /// | Value | Description
474 /// |:-----:|:------------
475 /// | 0 | on success
476 /// | -1 | on end of stream
477 /// | 1 | on failure
478 ///
479 virtual int ReadPCM(uint8_t* buffer, int size, int& actualsize) = 0;
480 //--------------------------------------------------------------------------
481
482 //==========================================================================
483 /// @ingroup cpp_kodi_addon_audiodecoder
484 /// @brief Seek in output stream.
485 ///
486 /// @param[in] time Time position to seek to in milliseconds
487 /// @return Time position seek ended up on
488 ///
489 virtual int64_t Seek(int64_t time) { return time; }
490 //--------------------------------------------------------------------------
491
492 //==========================================================================
493 /// @ingroup cpp_kodi_addon_audiodecoder
494 /// @brief Read tag of a file.
495 ///
496 /// @param[in] file File to read tag for
497 /// @param[out] tag Information tag about
498 /// @return True on success, false on failure
499 ///
500 /// --------------------------------------------------------------------------
501 ///
502 /// @copydetails cpp_kodi_addon_audiodecoder_Defs_AudioDecoderInfoTag_Help
503 ///
504 virtual bool ReadTag(const std::string& file, kodi::addon::AudioDecoderInfoTag& tag)
505 {
506 return false;
507 }
508 //--------------------------------------------------------------------------
509
510 //==========================================================================
511 /// @ingroup cpp_kodi_addon_audiodecoder
512 /// @brief Get number of tracks in a file.
513 ///
514 /// @param[in] file File to read tag for
515 /// @return Number of tracks in file
516 ///
517 virtual int TrackCount(const std::string& file) { return 1; }
518 //--------------------------------------------------------------------------
519
520private:
521 void SetAddonStruct(KODI_HANDLE instance)
522 {
523 if (instance == nullptr)
524 throw std::logic_error("kodi::addon::CInstanceAudioDecoder: Creation with empty addon structure not allowed, table must be given from Kodi!");
525
526 m_instanceData = static_cast<AddonInstance_AudioDecoder*>(instance);
527
528 m_instanceData->toAddon->addonInstance = this;
529 m_instanceData->toAddon->init = ADDON_Init;
530 m_instanceData->toAddon->read_pcm = ADDON_ReadPCM;
531 m_instanceData->toAddon->seek = ADDON_Seek;
532 m_instanceData->toAddon->read_tag = ADDON_ReadTag;
533 m_instanceData->toAddon->track_count = ADDON_TrackCount;
534 }
535
536 inline static bool ADDON_Init(const AddonInstance_AudioDecoder* instance,
537 const char* file,
538 unsigned int filecache,
539 int* channels,
540 int* samplerate,
541 int* bitspersample,
542 int64_t* totaltime,
543 int* bitrate,
544 AudioEngineDataFormat* format,
545 const AudioEngineChannel** info)
546 {
547 CInstanceAudioDecoder* thisClass =
548 static_cast<CInstanceAudioDecoder*>(instance->toAddon->addonInstance);
549
550 thisClass->m_channelList.clear();
551 bool ret = thisClass->Init(file, filecache, *channels, *samplerate, *bitspersample, *totaltime,
552 *bitrate, *format, thisClass->m_channelList);
553 if (!thisClass->m_channelList.empty())
554 {
555 if (thisClass->m_channelList.back() != AUDIOENGINE_CH_NULL)
556 thisClass->m_channelList.push_back(AUDIOENGINE_CH_NULL);
557 *info = thisClass->m_channelList.data();
558 }
559 else
560 *info = nullptr;
561 return ret;
562 }
563
564 inline static int ADDON_ReadPCM(const AddonInstance_AudioDecoder* instance, uint8_t* buffer, int size, int* actualsize)
565 {
566 return static_cast<CInstanceAudioDecoder*>(instance->toAddon->addonInstance)
567 ->ReadPCM(buffer, size, *actualsize);
568 }
569
570 inline static int64_t ADDON_Seek(const AddonInstance_AudioDecoder* instance, int64_t time)
571 {
572 return static_cast<CInstanceAudioDecoder*>(instance->toAddon->addonInstance)->Seek(time);
573 }
574
575 inline static bool ADDON_ReadTag(const AddonInstance_AudioDecoder* instance,
576 const char* file,
577 struct AUDIO_DECODER_INFO_TAG* tag)
578 {
579 kodi::addon::AudioDecoderInfoTag cppTag(tag);
580 return static_cast<CInstanceAudioDecoder*>(instance->toAddon->addonInstance)
581 ->ReadTag(file, cppTag);
582 }
583
584 inline static int ADDON_TrackCount(const AddonInstance_AudioDecoder* instance, const char* file)
585 {
586 return static_cast<CInstanceAudioDecoder*>(instance->toAddon->addonInstance)->TrackCount(file);
587 }
588
589 std::vector<AudioEngineChannel> m_channelList;
590 AddonInstance_AudioDecoder* m_instanceData;
591};
592
593} /* namespace addon */
594} /* namespace kodi */
595#endif /* __cplusplus */
diff --git a/xbmc/addons/kodi-dev-kit/include/kodi/addon-instance/AudioEncoder.h b/xbmc/addons/kodi-dev-kit/include/kodi/addon-instance/AudioEncoder.h
new file mode 100644
index 0000000..9a869c1
--- /dev/null
+++ b/xbmc/addons/kodi-dev-kit/include/kodi/addon-instance/AudioEncoder.h
@@ -0,0 +1,353 @@
1/*
2 * Copyright (C) 2005-2018 Team Kodi
3 * This file is part of Kodi - https://kodi.tv
4 *
5 * SPDX-License-Identifier: GPL-2.0-or-later
6 * See LICENSES/README.md for more information.
7 */
8
9#pragma once
10
11#include "../AddonBase.h"
12#include "../c-api/addon-instance/audio_encoder.h"
13
14#ifdef __cplusplus
15namespace kodi
16{
17namespace addon
18{
19
20//==============================================================================
21/// @addtogroup cpp_kodi_addon_audioencoder
22/// @brief \cpp_class{ kodi::addon::CInstanceAudioEncoder }
23/// **Audio encoder add-on instance.**\n
24/// For audio encoders as binary add-ons. This class implements a way to handle
25/// the encode of given stream to a new format.
26///
27/// The addon.xml defines the capabilities of this add-on.
28///
29///
30/// ----------------------------------------------------------------------------
31///
32/// **Here's an example on addon.xml:**
33/// ~~~~~~~~~~~~~{.xml}
34/// <extension
35/// point="kodi.audioencoder"
36/// extension=".flac"
37/// library_@PLATFORM@="@LIBRARY_FILENAME@"/>
38/// ~~~~~~~~~~~~~
39///
40/// Description to audio encoder related addon.xml values:
41/// | Name | Description
42/// |:------------------------------|----------------------------------------
43/// | <b>`point`</b> | Addon type specification<br>At all addon types and for this kind always <b>"kodi.audioencoder"</b>.
44/// | <b>`library_@PLATFORM@`</b> | Sets the used library name, which is automatically set by cmake at addon build.
45/// | <b>`extension`</b> | The file extensions / styles supported by this addon.
46///
47/// --------------------------------------------------------------------------
48///
49/// --------------------------------------------------------------------------
50///
51/// **Here is a code example how this addon is used:**
52///
53/// ~~~~~~~~~~~~~{.cpp}
54/// #include <kodi/addon-instance/AudioEncoder.h>
55///
56/// class ATTRIBUTE_HIDDEN CMyAudioEncoder : public kodi::addon::CInstanceAudioEncoder
57/// {
58/// public:
59/// CMyAudioEncoder(KODI_HANDLE instance, const std::string& kodiVersion)
60/// : kodi::addon::CInstanceAudioEncoder(instance, kodiVersion)
61///
62/// bool Init(const std::string& filename, unsigned int filecache,
63/// int& channels, int& samplerate,
64/// int& bitspersample, int64_t& totaltime,
65/// int& bitrate, AEDataFormat& format,
66/// std::vector<AEChannel>& channellist) override;
67/// int Encode(int numBytesRead, const uint8_t* pbtStream) override;
68/// bool Finish() override; // Optional
69/// };
70///
71/// CMyAudioEncoder::CMyAudioEncoder(KODI_HANDLE instance)
72/// : kodi::addon::CInstanceAudioEncoder(instance)
73/// {
74/// ...
75/// }
76///
77/// bool CMyAudioEncoder::Start(int inChannels,
78/// int inRate,
79/// int inBits,
80/// const std::string& title,
81/// const std::string& artist,
82/// const std::string& albumartist,
83/// const std::string& album,
84/// const std::string& year,
85/// const std::string& track,
86/// const std::string& genre,
87/// const std::string& comment,
88/// int trackLength)
89/// {
90/// ...
91/// return true;
92/// }
93///
94/// int CMyAudioEncoder::Encode(int numBytesRead, const uint8_t* pbtStream)
95/// {
96/// uint8_t* data = nullptr;
97/// int length = 0;
98/// ...
99/// kodi::addon::CInstanceAudioEncoder::Write(data, length);
100///
101/// return 0;
102/// }
103///
104///
105/// bool CMyAudioEncoder::Finish()
106/// {
107/// ...
108/// return true;
109/// }
110///
111/// //----------------------------------------------------------------------
112///
113/// class CMyAddon : public kodi::addon::CAddonBase
114/// {
115/// public:
116/// CMyAddon() = default;
117/// ADDON_STATUS CreateInstance(int instanceType,
118/// const std::string& instanceID,
119/// KODI_HANDLE instance,
120/// const std::string& version,
121/// KODI_HANDLE& addonInstance) override;
122/// };
123///
124/// // If you use only one instance in your add-on, can be instanceType and
125/// // instanceID ignored
126/// ADDON_STATUS CMyAddon::CreateInstance(int instanceType,
127/// const std::string& instanceID,
128/// KODI_HANDLE instance,
129/// const std::string& version,
130/// KODI_HANDLE& addonInstance)
131/// {
132/// if (instanceType == ADDON_INSTANCE_AUDIOENCODER)
133/// {
134/// kodi::Log(ADDON_LOG_INFO, "Creating my audio encoder instance");
135/// addonInstance = new CMyAudioEncoder(instance, version);
136/// return ADDON_STATUS_OK;
137/// }
138/// else if (...)
139/// {
140/// ...
141/// }
142/// return ADDON_STATUS_UNKNOWN;
143/// }
144///
145/// ADDONCREATOR(CMyAddon)
146/// ~~~~~~~~~~~~~
147///
148/// The destruction of the example class `CMyAudioEncoder` is called from
149/// Kodi's header. Manually deleting the add-on instance is not required.
150///
151class ATTRIBUTE_HIDDEN CInstanceAudioEncoder : public IAddonInstance
152{
153public:
154 //============================================================================
155 /// @ingroup cpp_kodi_addon_audioencoder
156 /// @brief Audio encoder class constructor used to support multiple instances.
157 ///
158 /// @param[in] instance The instance value given to
159 /// <b>`kodi::addon::CAddonBase::CreateInstance(...)`</b>.
160 /// @param[in] kodiVersion [opt] Version used in Kodi for this instance, to
161 /// allow compatibility to older Kodi versions.
162 ///
163 /// @note Recommended to set <b>`kodiVersion`</b>.
164 ///
165 ///
166 /// --------------------------------------------------------------------------
167 ///
168 /// **Here's example about the use of this:**
169 /// ~~~~~~~~~~~~~{.cpp}
170 /// class CMyAudioEncoder : public kodi::addon::CInstanceAudioEncoder
171 /// {
172 /// public:
173 /// CMyAudioEncoder(KODI_HANDLE instance, const std::string& kodiVersion)
174 /// : kodi::addon::CInstanceAudioEncoder(instance, kodiVersion)
175 /// {
176 /// ...
177 /// }
178 ///
179 /// ...
180 /// };
181 ///
182 /// ADDON_STATUS CMyAddon::CreateInstance(int instanceType,
183 /// const std::string& instanceID,
184 /// KODI_HANDLE instance,
185 /// const std::string& version,
186 /// KODI_HANDLE& addonInstance)
187 /// {
188 /// kodi::Log(ADDON_LOG_INFO, "Creating my audio encoder instance");
189 /// addonInstance = new CMyAudioEncoder(instance, version);
190 /// return ADDON_STATUS_OK;
191 /// }
192 /// ~~~~~~~~~~~~~
193 ///
194 explicit CInstanceAudioEncoder(KODI_HANDLE instance, const std::string& kodiVersion = "")
195 : IAddonInstance(ADDON_INSTANCE_AUDIOENCODER,
196 !kodiVersion.empty() ? kodiVersion
197 : GetKodiTypeVersion(ADDON_INSTANCE_AUDIOENCODER))
198 {
199 if (CAddonBase::m_interface->globalSingleInstance != nullptr)
200 throw std::logic_error("kodi::addon::CInstanceAudioEncoder: Creation of multiple together "
201 "with single instance way is not allowed!");
202
203 SetAddonStruct(instance);
204 }
205 //----------------------------------------------------------------------------
206
207 //============================================================================
208 /// @ingroup cpp_kodi_addon_audioencoder
209 /// @brief Start encoder (**required**)
210 ///
211 /// @param[in] inChannels Number of channels
212 /// @param[in] inRate Sample rate of input data
213 /// @param[in] inBits Bits per sample in input data
214 /// @param[in] title The title of the song
215 /// @param[in] artist The artist of the song
216 /// @param[in] albumartist The albumartist of the song
217 /// @param[in] year The year of the song
218 /// @param[in] track The track number of the song
219 /// @param[in] genre The genre of the song
220 /// @param[in] comment A comment to attach to the song
221 /// @param[in] trackLength Total track length in seconds
222 /// @return True on success, false on failure.
223 ///
224 virtual bool Start(int inChannels,
225 int inRate,
226 int inBits,
227 const std::string& title,
228 const std::string& artist,
229 const std::string& albumartist,
230 const std::string& album,
231 const std::string& year,
232 const std::string& track,
233 const std::string& genre,
234 const std::string& comment,
235 int trackLength) = 0;
236 //----------------------------------------------------------------------------
237
238 //============================================================================
239 /// @ingroup cpp_kodi_addon_audioencoder
240 /// @brief Encode a chunk of audio (**required**)
241 ///
242 /// @param[in] numBytesRead Number of bytes in input buffer
243 /// @param[in] pbtStream The input buffer
244 /// @return Number of bytes consumed
245 ///
246 virtual int Encode(int numBytesRead, const uint8_t* pbtStream) = 0;
247 //----------------------------------------------------------------------------
248
249 //============================================================================
250 /// @ingroup cpp_kodi_addon_audioencoder
251 /// @brief Finalize encoding (**optional**)
252 ///
253 /// @return True on success, false on failure.
254 ///
255 virtual bool Finish() { return true; }
256 //----------------------------------------------------------------------------
257
258 //============================================================================
259 /// @ingroup cpp_kodi_addon_audioencoder
260 /// @brief Write block of data
261 ///
262 /// @param[in] data Pointer to the array of elements to be written
263 /// @param[in] length Size in bytes to be written.
264 /// @return The total number of bytes successfully written is returned.
265 ///
266 /// @remarks Only called from addon itself.
267 ///
268 int Write(const uint8_t* data, int length)
269 {
270 return m_instanceData->toKodi->write(m_instanceData->toKodi->kodiInstance, data, length);
271 }
272 //----------------------------------------------------------------------------
273
274 //============================================================================
275 /// @ingroup cpp_kodi_addon_audioencoder
276 /// @brief Set the file's current position.
277 ///
278 /// The whence argument is optional and defaults to SEEK_SET (0)
279 ///
280 /// @param[in] position The position that you want to seek to
281 /// @param[in] whence [optional] offset relative to\n
282 /// You can set the value of whence to one
283 /// of three things:
284 /// | Value | int | Description |
285 /// |:--------:|:---:|:---------------------------------------------------|
286 /// | SEEK_SET | 0 | position is relative to the beginning of the file. This is probably what you had in mind anyway, and is the most commonly used value for whence.
287 /// | SEEK_CUR | 1 | position is relative to the current file pointer position. So, in effect, you can say, "Move to my current position plus 30 bytes," or, "move to my current position minus 20 bytes."
288 /// | SEEK_END | 2 | position is relative to the end of the file. Just like SEEK_SET except from the other end of the file. Be sure to use negative values for offset if you want to back up from the end of the file, instead of going past the end into oblivion.
289 ///
290 /// @return Returns the resulting offset location as measured in bytes from
291 /// the beginning of the file. On error, the value -1 is returned.
292 ///
293 /// @remarks Only called from addon itself.
294 ///
295 int64_t Seek(int64_t position, int whence = SEEK_SET)
296 {
297 return m_instanceData->toKodi->seek(m_instanceData->toKodi->kodiInstance, position, whence);
298 }
299 //----------------------------------------------------------------------------
300
301private:
302 void SetAddonStruct(KODI_HANDLE instance)
303 {
304 if (instance == nullptr)
305 throw std::logic_error("kodi::addon::CInstanceAudioEncoder: Creation with empty addon "
306 "structure not allowed, table must be given from Kodi!");
307
308 m_instanceData = static_cast<AddonInstance_AudioEncoder*>(instance);
309 m_instanceData->toAddon->addonInstance = this;
310 m_instanceData->toAddon->start = ADDON_Start;
311 m_instanceData->toAddon->encode = ADDON_Encode;
312 m_instanceData->toAddon->finish = ADDON_Finish;
313 }
314
315 inline static bool ADDON_Start(const AddonInstance_AudioEncoder* instance,
316 int inChannels,
317 int inRate,
318 int inBits,
319 const char* title,
320 const char* artist,
321 const char* albumartist,
322 const char* album,
323 const char* year,
324 const char* track,
325 const char* genre,
326 const char* comment,
327 int trackLength)
328 {
329 return static_cast<CInstanceAudioEncoder*>(instance->toAddon->addonInstance)
330 ->Start(inChannels, inRate, inBits, title, artist, albumartist, album, year, track, genre,
331 comment, trackLength);
332 }
333
334 inline static int ADDON_Encode(const AddonInstance_AudioEncoder* instance,
335 int numBytesRead,
336 const uint8_t* pbtStream)
337 {
338 return static_cast<CInstanceAudioEncoder*>(instance->toAddon->addonInstance)
339 ->Encode(numBytesRead, pbtStream);
340 }
341
342 inline static bool ADDON_Finish(const AddonInstance_AudioEncoder* instance)
343 {
344 return static_cast<CInstanceAudioEncoder*>(instance->toAddon->addonInstance)->Finish();
345 }
346
347 AddonInstance_AudioEncoder* m_instanceData;
348};
349
350} /* namespace addon */
351} /* namespace kodi */
352
353#endif /* __cplusplus */
diff --git a/xbmc/addons/kodi-dev-kit/include/kodi/addon-instance/CMakeLists.txt b/xbmc/addons/kodi-dev-kit/include/kodi/addon-instance/CMakeLists.txt
new file mode 100644
index 0000000..a57def3
--- /dev/null
+++ b/xbmc/addons/kodi-dev-kit/include/kodi/addon-instance/CMakeLists.txt
@@ -0,0 +1,15 @@
1set(HEADERS AudioDecoder.h
2 AudioEncoder.h
3 Game.h
4 ImageDecoder.h
5 Inputstream.h
6 Peripheral.h
7 PVR.h
8 Screensaver.h
9 VFS.h
10 VideoCodec.h
11 Visualization.h)
12
13if(NOT ENABLE_STATIC_LIBS)
14 core_add_library(addons_kodi-dev-kit_include_kodi_addon-instance)
15endif()
diff --git a/xbmc/addons/kodi-dev-kit/include/kodi/addon-instance/Game.h b/xbmc/addons/kodi-dev-kit/include/kodi/addon-instance/Game.h
new file mode 100644
index 0000000..3dca94d
--- /dev/null
+++ b/xbmc/addons/kodi-dev-kit/include/kodi/addon-instance/Game.h
@@ -0,0 +1,1190 @@
1/*
2 * Copyright (C) 2014-2018 Team Kodi
3 * This file is part of Kodi - https://kodi.tv
4 *
5 * SPDX-License-Identifier: GPL-2.0-or-later
6 * See LICENSES/README.md for more information.
7 */
8
9#pragma once
10
11#include "../AddonBase.h"
12#include "../c-api/addon-instance/game.h"
13
14#ifdef __cplusplus
15
16namespace kodi
17{
18namespace addon
19{
20
21//==============================================================================
22/// @addtogroup cpp_kodi_addon_game
23///
24/// To use on Libretro and for stand-alone games or emulators that does not use
25/// the Libretro API.
26///
27/// Possible examples could be, Nvidia GameStream via Limelight or WINE capture
28/// could possible through the Game API.
29///
30
31//==============================================================================
32/// @defgroup cpp_kodi_addon_game_Defs Definitions, structures and enumerators
33/// @ingroup cpp_kodi_addon_game
34/// @brief **Game add-on instance definition values**
35///
36
37//==============================================================================
38/// @defgroup cpp_kodi_addon_game_Defs_InputTypes_GameControllerLayout class GameControllerLayout
39/// @ingroup cpp_kodi_addon_game_Defs_InputTypes
40/// @brief Data of layouts for known controllers.
41///
42/// Used on @ref kodi::addon::CInstanceGame::SetControllerLayouts().
43///@{
44class GameControllerLayout
45{
46public:
47 /*! @cond PRIVATE */
48 explicit GameControllerLayout() = default;
49 GameControllerLayout(const game_controller_layout& layout)
50 {
51 controller_id = layout.controller_id;
52 provides_input = layout.provides_input;
53 for (unsigned int i = 0; i < layout.digital_button_count; ++i)
54 digital_buttons.push_back(layout.digital_buttons[i]);
55 for (unsigned int i = 0; i < layout.analog_button_count; ++i)
56 analog_buttons.push_back(layout.analog_buttons[i]);
57 for (unsigned int i = 0; i < layout.analog_stick_count; ++i)
58 analog_sticks.push_back(layout.analog_sticks[i]);
59 for (unsigned int i = 0; i < layout.accelerometer_count; ++i)
60 accelerometers.push_back(layout.accelerometers[i]);
61 for (unsigned int i = 0; i < layout.key_count; ++i)
62 keys.push_back(layout.keys[i]);
63 for (unsigned int i = 0; i < layout.rel_pointer_count; ++i)
64 rel_pointers.push_back(layout.rel_pointers[i]);
65 for (unsigned int i = 0; i < layout.abs_pointer_count; ++i)
66 abs_pointers.push_back(layout.abs_pointers[i]);
67 for (unsigned int i = 0; i < layout.motor_count; ++i)
68 motors.push_back(layout.motors[i]);
69 }
70 /*! @endcond */
71
72 /// @brief Controller identifier.
73 std::string controller_id;
74
75 /// @brief Provides input.
76 ///
77 /// False for multitaps
78 bool provides_input;
79
80 /// @brief Digital buttons.
81 std::vector<std::string> digital_buttons;
82
83 /// @brief Analog buttons.
84 std::vector<std::string> analog_buttons;
85
86 /// @brief Analog sticks.
87 std::vector<std::string> analog_sticks;
88
89 /// @brief Accelerometers.
90 std::vector<std::string> accelerometers;
91
92 /// @brief Keys.
93 std::vector<std::string> keys;
94
95 /// @brief Relative pointers.
96 std::vector<std::string> rel_pointers;
97
98 /// @brief Absolute pointers.
99 std::vector<std::string> abs_pointers;
100
101 /// @brief Motors.
102 std::vector<std::string> motors;
103};
104///@}
105//------------------------------------------------------------------------------
106
107//==============================================================================
108/// @addtogroup cpp_kodi_addon_game
109/// @brief @cpp_class{ kodi::addon::CInstanceGame }
110/// **Game add-on instance**\n
111/// This class provides the basic game processing system for use as an add-on in
112/// Kodi.
113///
114/// This class is created at addon by Kodi.
115///
116class ATTRIBUTE_HIDDEN CInstanceGame : public IAddonInstance
117{
118public:
119 //============================================================================
120 /// @defgroup cpp_kodi_addon_game_Base 1. Basic functions
121 /// @ingroup cpp_kodi_addon_game
122 /// @brief **Functions to manage the addon and get basic information about it**
123 ///
124 ///@{
125
126 //============================================================================
127 /// @brief Game class constructor
128 ///
129 /// Used by an add-on that only supports only Game and only in one instance.
130 ///
131 /// This class is created at addon by Kodi.
132 ///
133 ///
134 /// --------------------------------------------------------------------------
135 ///
136 ///
137 /// **Here's example about the use of this:**
138 /// ~~~~~~~~~~~~~{.cpp}
139 /// #include <kodi/addon-instance/Game.h>
140 /// ...
141 ///
142 /// class ATTRIBUTE_HIDDEN CGameExample
143 /// : public kodi::addon::CAddonBase,
144 /// public kodi::addon::CInstanceGame
145 /// {
146 /// public:
147 /// CGameExample()
148 /// {
149 /// }
150 ///
151 /// virtual ~CGameExample();
152 /// {
153 /// }
154 ///
155 /// ...
156 /// };
157 ///
158 /// ADDONCREATOR(CGameExample)
159 /// ~~~~~~~~~~~~~
160 ///
161 CInstanceGame() : IAddonInstance(ADDON_INSTANCE_GAME, GetKodiTypeVersion(ADDON_INSTANCE_GAME))
162 {
163 if (CAddonBase::m_interface->globalSingleInstance != nullptr)
164 throw std::logic_error("kodi::addon::CInstanceGame: Creation of more as one in single "
165 "instance way is not allowed!");
166
167 SetAddonStruct(CAddonBase::m_interface->firstKodiInstance);
168 CAddonBase::m_interface->globalSingleInstance = this;
169 }
170 //----------------------------------------------------------------------------
171
172 //============================================================================
173 /// @brief Destructor
174 ///
175 ~CInstanceGame() override = default;
176 //----------------------------------------------------------------------------
177
178 //============================================================================
179 /// @brief **Callback to Kodi Function**\n
180 /// The path of the game client being loaded.
181 ///
182 /// @return the used game client Dll path
183 ///
184 /// @remarks Only called from addon itself
185 ///
186 std::string GameClientDllPath() const { return m_instanceData->props->game_client_dll_path; }
187 //----------------------------------------------------------------------------
188
189 //============================================================================
190 /// @brief **Callback to Kodi Function**\n
191 /// Paths to proxy DLLs used to load the game client.
192 ///
193 /// @param[out] paths vector list to store available dll paths
194 /// @return true if success and dll paths present
195 ///
196 /// @remarks Only called from addon itself
197 ///
198 bool ProxyDllPaths(std::vector<std::string>& paths)
199 {
200 for (unsigned int i = 0; i < m_instanceData->props->proxy_dll_count; ++i)
201 {
202 if (m_instanceData->props->proxy_dll_paths[i] != nullptr)
203 paths.push_back(m_instanceData->props->proxy_dll_paths[i]);
204 }
205 return !paths.empty();
206 }
207 //----------------------------------------------------------------------------
208
209 //============================================================================
210 /// @brief **Callback to Kodi Function**\n
211 /// The "system" directories of the frontend.
212 ///
213 /// These directories can be used to store system-specific ROMs such as
214 /// BIOSes, configuration data, etc.
215 ///
216 /// @return the used resource directory
217 ///
218 /// @remarks Only called from addon itself
219 ///
220 bool ResourceDirectories(std::vector<std::string>& dirs)
221 {
222 for (unsigned int i = 0; i < m_instanceData->props->resource_directory_count; ++i)
223 {
224 if (m_instanceData->props->resource_directories[i] != nullptr)
225 dirs.push_back(m_instanceData->props->resource_directories[i]);
226 }
227 return !dirs.empty();
228 }
229 //----------------------------------------------------------------------------
230
231 //============================================================================
232 /// @brief **Callback to Kodi Function**\n
233 /// The writable directory of the frontend.
234 ///
235 /// This directory can be used to store SRAM, memory cards, high scores,
236 /// etc, if the game client cannot use the regular memory interface,
237 /// GetMemoryData().
238 ///
239 /// @return the used profile directory
240 ///
241 /// @remarks Only called from addon itself
242 ///
243 std::string ProfileDirectory() const { return m_instanceData->props->profile_directory; }
244 //----------------------------------------------------------------------------
245
246 //============================================================================
247 /// @brief **Callback to Kodi Function**\n
248 /// The value of the <supports_vfs> property from addon.xml.
249 ///
250 /// @return true if VFS is supported
251 ///
252 /// @remarks Only called from addon itself
253 ///
254 bool SupportsVFS() const { return m_instanceData->props->supports_vfs; }
255 //----------------------------------------------------------------------------
256
257 //============================================================================
258 /// @brief **Callback to Kodi Function**\n
259 /// The extensions in the <extensions> property from addon.xml.
260 ///
261 /// @param[out] extensions vector list to store available extension
262 /// @return true if success and extensions present
263 ///
264 /// @remarks Only called from addon itself
265 ///
266 bool Extensions(std::vector<std::string>& extensions)
267 {
268 for (unsigned int i = 0; i < m_instanceData->props->extension_count; ++i)
269 {
270 if (m_instanceData->props->extensions[i] != nullptr)
271 extensions.push_back(m_instanceData->props->extensions[i]);
272 }
273 return !extensions.empty();
274 }
275 //----------------------------------------------------------------------------
276
277 ///@}
278
279//--==----==----==----==----==----==----==----==----==----==----==----==----==--
280
281 //============================================================================
282 ///
283 /// @defgroup cpp_kodi_addon_game_Operation 2. Game operations
284 /// @ingroup cpp_kodi_addon_game
285 /// @brief **Game operations**
286 ///
287 /// These are mandatory functions for using this addon to get the available
288 /// channels.
289 ///
290 ///
291 ///---------------------------------------------------------------------------
292 ///
293 /// **Game operation parts in interface:**\n
294 /// Copy this to your project and extend with your parts or leave functions
295 /// complete away where not used or supported.
296 ///
297 /// @copydetails cpp_kodi_addon_game_Operation_header_addon_auto_check
298 /// @copydetails cpp_kodi_addon_game_Operation_source_addon_auto_check
299 ///
300 ///@{
301
302 //============================================================================
303 /// @brief Load a game
304 ///
305 /// @param[in] url The URL to load
306 /// @return the error, or @ref GAME_ERROR_NO_ERROR if the game was loaded
307 ///
308 virtual GAME_ERROR LoadGame(const std::string& url)
309 {
310 return GAME_ERROR_NOT_IMPLEMENTED;
311 }
312 //----------------------------------------------------------------------------
313
314 //============================================================================
315 /// @brief Load a game that requires multiple files
316 ///
317 /// @param[in] type The game type
318 /// @param[in] urls An array of urls
319 /// @return the error, or @ref GAME_ERROR_NO_ERROR if the game was loaded
320 ///
321 virtual GAME_ERROR LoadGameSpecial(SPECIAL_GAME_TYPE type, const std::vector<std::string>& urls)
322 {
323 return GAME_ERROR_NOT_IMPLEMENTED;
324 }
325 //----------------------------------------------------------------------------
326
327 //============================================================================
328 /// @brief Begin playing without a game file
329 ///
330 /// If the add-on supports standalone mode, it must add the <supports_standalone>
331 /// tag to the extension point in addon.xml:
332 ///
333 /// <supports_no_game>false</supports_no_game>
334 ///
335 /// @return the error, or @ref GAME_ERROR_NO_ERROR if the game add-on was loaded
336 ///
337 virtual GAME_ERROR LoadStandalone()
338 {
339 return GAME_ERROR_NOT_IMPLEMENTED;
340 }
341 //----------------------------------------------------------------------------
342
343 //============================================================================
344 /// @brief Unload the current game
345 ///
346 /// Unloads a currently loaded game
347 ///
348 /// @return the error, or @ref GAME_ERROR_NO_ERROR if the game was unloaded
349 ///
350 virtual GAME_ERROR UnloadGame()
351 {
352 return GAME_ERROR_NOT_IMPLEMENTED;
353 }
354 //----------------------------------------------------------------------------
355
356 //============================================================================
357 /// @brief Get timing information about the loaded game
358 ///
359 /// @param[out] timing_info The info structure to fill
360 ///
361 /// @return the error, or @ref GAME_ERROR_NO_ERROR if info was filled
362 ///
363 virtual GAME_ERROR GetGameTiming(game_system_timing& timing_info)
364 {
365 return GAME_ERROR_NOT_IMPLEMENTED;
366 }
367 //----------------------------------------------------------------------------
368
369 //============================================================================
370 /// @brief Get region of the loaded game
371 ///
372 /// @return the region, or @ref GAME_REGION_UNKNOWN if unknown or no game is loaded
373 ///
374 virtual GAME_REGION GetRegion()
375 {
376 return GAME_REGION_UNKNOWN;
377 }
378 //----------------------------------------------------------------------------
379
380 //============================================================================
381 /// @brief Return true if the client requires the frontend to provide a game loop
382 ///
383 /// The game loop is a thread that calls RunFrame() in a loop at a rate
384 /// determined by the playback speed and the client's FPS.
385 ///
386 /// @return true if the frontend should provide a game loop, false otherwise
387 ///
388 virtual bool RequiresGameLoop()
389 {
390 return false;
391 }
392 //----------------------------------------------------------------------------
393
394 //============================================================================
395 /// @brief Run a single frame for add-ons that use a game loop
396 ///
397 /// @return the error, or @ref GAME_ERROR_NO_ERROR if there was no error
398 ///
399 virtual GAME_ERROR RunFrame()
400 {
401 return GAME_ERROR_NOT_IMPLEMENTED;
402 }
403 //----------------------------------------------------------------------------
404
405 //============================================================================
406 /// @brief Reset the current game
407 ///
408 /// @return the error, or @ref GAME_ERROR_NO_ERROR if the game was reset
409 ///
410 virtual GAME_ERROR Reset()
411 {
412 return GAME_ERROR_NOT_IMPLEMENTED;
413 }
414 //----------------------------------------------------------------------------
415
416 //==========================================================================
417 /// @brief **Callback to Kodi Function**\n
418 /// Requests the frontend to stop the current game
419 ///
420 /// @remarks Only called from addon itself
421 ///
422 void CloseGame(void) { m_instanceData->toKodi->CloseGame(m_instanceData->toKodi->kodiInstance); }
423 //----------------------------------------------------------------------------
424
425 //============================================================================
426 /// @defgroup cpp_kodi_addon_game_Operation_CStream Class: CStream
427 /// @ingroup cpp_kodi_addon_game_Operation
428 /// @brief @cpp_class{ kodi::addon::CInstanceGame::CStream }
429 /// **Game stream handler**
430 ///
431 /// This class will be integrated into the addon, which can then open it if
432 /// necessary for the processing of an audio or video stream.
433 ///
434 ///
435 /// @note Callback to Kodi class
436 ///@{
437 class CStream
438 {
439 public:
440 CStream() = default;
441
442 CStream(const game_stream_properties& properties)
443 {
444 Open(properties);
445 }
446
447 ~CStream()
448 {
449 Close();
450 }
451
452 //==========================================================================
453 /// @ingroup cpp_kodi_addon_game_Operation_CStream
454 /// @brief Create a stream for gameplay data
455 ///
456 /// @param[in] properties The stream properties
457 /// @return A stream handle, or `nullptr` on failure
458 ///
459 /// @remarks Only called from addon itself
460 ///
461 bool Open(const game_stream_properties& properties)
462 {
463 if (!CAddonBase::m_interface->globalSingleInstance)
464 return false;
465
466 if (m_handle)
467 {
468 kodi::Log(ADDON_LOG_INFO, "kodi::addon::CInstanceGame::CStream already becomes reopened");
469 Close();
470 }
471
472 AddonToKodiFuncTable_Game& cb =
473 *static_cast<CInstanceGame*>(CAddonBase::m_interface->globalSingleInstance)
474 ->m_instanceData->toKodi;
475 m_handle = cb.OpenStream(cb.kodiInstance, &properties);
476 return m_handle != nullptr;
477 }
478 //--------------------------------------------------------------------------
479
480 //==========================================================================
481 /// @ingroup cpp_kodi_addon_game_Operation_CStream
482 /// @brief Free the specified stream
483 ///
484 /// @remarks Only called from addon itself
485 ///
486 void Close()
487 {
488 if (!m_handle || !CAddonBase::m_interface->globalSingleInstance)
489 return;
490
491 AddonToKodiFuncTable_Game& cb =
492 *static_cast<CInstanceGame*>(CAddonBase::m_interface->globalSingleInstance)
493 ->m_instanceData->toKodi;
494 cb.CloseStream(cb.kodiInstance, m_handle);
495 m_handle = nullptr;
496 }
497 //--------------------------------------------------------------------------
498
499 //==========================================================================
500 /// @ingroup cpp_kodi_addon_game_Operation_CStream
501 /// @brief Get a buffer for zero-copy stream data
502 ///
503 /// @param[in] width The framebuffer width, or 0 for no width specified
504 /// @param[in] height The framebuffer height, or 0 for no height specified
505 /// @param[out] buffer The buffer, or unmodified if false is returned
506 /// @return True if buffer was set, false otherwise
507 ///
508 /// @note If this returns true, buffer must be freed using @ref ReleaseBuffer().
509 ///
510 /// @remarks Only called from addon itself
511 ///
512 bool GetBuffer(unsigned int width, unsigned int height, game_stream_buffer& buffer)
513 {
514 if (!m_handle || !CAddonBase::m_interface->globalSingleInstance)
515 return false;
516
517 AddonToKodiFuncTable_Game& cb =
518 *static_cast<CInstanceGame*>(CAddonBase::m_interface->globalSingleInstance)
519 ->m_instanceData->toKodi;
520 return cb.GetStreamBuffer(cb.kodiInstance, m_handle, width, height, &buffer);
521 }
522 //--------------------------------------------------------------------------
523
524 //==========================================================================
525 /// @ingroup cpp_kodi_addon_game_Operation_CStream
526 /// @brief Add a data packet to a stream
527 ///
528 /// @param[in] packet The data packet
529 ///
530 /// @remarks Only called from addon itself
531 ///
532 void AddData(const game_stream_packet& packet)
533 {
534 if (!m_handle || !CAddonBase::m_interface->globalSingleInstance)
535 return;
536
537 AddonToKodiFuncTable_Game& cb =
538 *static_cast<CInstanceGame*>(CAddonBase::m_interface->globalSingleInstance)
539 ->m_instanceData->toKodi;
540 cb.AddStreamData(cb.kodiInstance, m_handle, &packet);
541 }
542 //--------------------------------------------------------------------------
543
544 //==========================================================================
545 /// @ingroup cpp_kodi_addon_game_Operation_CStream
546 /// @brief Free an allocated buffer
547 ///
548 /// @param[in] buffer The buffer returned from GetStreamBuffer()
549 ///
550 /// @remarks Only called from addon itself
551 ///
552 void ReleaseBuffer(game_stream_buffer& buffer)
553 {
554 if (!m_handle || !CAddonBase::m_interface->globalSingleInstance)
555 return;
556
557 AddonToKodiFuncTable_Game& cb =
558 *static_cast<CInstanceGame*>(CAddonBase::m_interface->globalSingleInstance)
559 ->m_instanceData->toKodi;
560 cb.ReleaseStreamBuffer(cb.kodiInstance, m_handle, &buffer);
561 }
562 //--------------------------------------------------------------------------
563
564 //==========================================================================
565 /// @ingroup cpp_kodi_addon_game_Operation_CStream
566 /// @brief To check stream open was OK, e.g. after use of constructor
567 ///
568 /// @return true if stream was successfully opened
569 ///
570 /// @remarks Only called from addon itself
571 ///
572 bool IsOpen() const { return m_handle != nullptr; }
573 //--------------------------------------------------------------------------
574
575 private:
576 KODI_GAME_STREAM_HANDLE m_handle = nullptr;
577 };
578 ///@}
579
580 ///@}
581
582//--==----==----==----==----==----==----==----==----==----==----==----==----==--
583
584 //============================================================================
585 ///
586 /// @defgroup cpp_kodi_addon_game_HardwareRendering 3. Hardware rendering operations
587 /// @ingroup cpp_kodi_addon_game
588 /// @brief **Hardware rendering operations**
589 ///
590 ///
591 ///---------------------------------------------------------------------------
592 ///
593 /// **Hardware rendering operation parts in interface:**\n
594 /// Copy this to your project and extend with your parts or leave functions
595 /// complete away where not used or supported.
596 ///
597 /// @copydetails cpp_kodi_addon_game_HardwareRendering_header_addon_auto_check
598 /// @copydetails cpp_kodi_addon_game_HardwareRendering_source_addon_auto_check
599 ///
600 ///@{
601
602 //============================================================================
603 /// @brief Invalidates the current HW context and reinitializes GPU resources
604 ///
605 /// Any GL state is lost, and must not be deinitialized explicitly.
606 ///
607 /// @return the error, or @ref GAME_ERROR_NO_ERROR if the HW context was reset
608 ///
609 virtual GAME_ERROR HwContextReset()
610 {
611 return GAME_ERROR_NOT_IMPLEMENTED;
612 }
613 //----------------------------------------------------------------------------
614
615 //============================================================================
616 /// @brief Called before the context is destroyed
617 ///
618 /// Resources can be deinitialized at this step.
619 ///
620 /// @return the error, or @ref GAME_ERROR_NO_ERROR if the HW context was destroyed
621 ///
622 virtual GAME_ERROR HwContextDestroy()
623 {
624 return GAME_ERROR_NOT_IMPLEMENTED;
625 }
626
627 //============================================================================
628 /// @brief **Callback to Kodi Function**<br>Get a symbol from the hardware context
629 ///
630 /// @param[in] sym The symbol's name
631 ///
632 /// @return A function pointer for the specified symbol
633 ///
634 /// @remarks Only called from addon itself
635 ///
636 game_proc_address_t HwGetProcAddress(const char* sym)
637 {
638 return m_instanceData->toKodi->HwGetProcAddress(m_instanceData->toKodi->kodiInstance, sym);
639 }
640 //----------------------------------------------------------------------------
641
642 ///@}
643
644//--==----==----==----==----==----==----==----==----==----==----==----==----==--
645
646 //============================================================================
647 /// @defgroup cpp_kodi_addon_game_InputOperations 4. Input operations
648 /// @ingroup cpp_kodi_addon_game
649 /// @brief **Input operations**
650 ///
651 ///
652 ///---------------------------------------------------------------------------
653 ///
654 /// **Hardware rendering operation parts in interface:**\n
655 /// Copy this to your project and extend with your parts or leave functions
656 /// complete away where not used or supported.
657 ///
658 /// @copydetails cpp_kodi_addon_game_InputOperations_header_addon_auto_check
659 /// @copydetails cpp_kodi_addon_game_InputOperations_source_addon_auto_check
660 ///
661 ///@{
662
663 //============================================================================
664 /// @brief Check if input is accepted for a feature on the controller
665 ///
666 /// If only a subset of the controller profile is used, this can return false
667 /// for unsupported features to not absorb their input.
668 ///
669 /// If the entire controller profile is used, this should always return true.
670 ///
671 /// @param[in] controller_id The ID of the controller profile
672 /// @param[in] feature_name The name of a feature in that profile
673 /// @return true if input is accepted for the feature, false otherwise
674 ///
675 virtual bool HasFeature(const std::string& controller_id, const std::string& feature_name)
676 {
677 return false;
678 }
679 //----------------------------------------------------------------------------
680
681 //============================================================================
682 /// @brief Get the input topology that specifies which controllers can be connected
683 ///
684 /// @return The input topology, or null to use the default
685 ///
686 /// If this returns non-null, topology must be freed using FreeTopology().
687 ///
688 /// If this returns null, the topology will default to a single port that can
689 /// accept all controllers imported by addon.xml. The port ID is set to
690 /// the @ref DEFAULT_PORT_ID constant.
691 ///
692 virtual game_input_topology* GetTopology()
693 {
694 return nullptr;
695 }
696 //----------------------------------------------------------------------------
697
698 //============================================================================
699 /// @brief Free the topology's resources
700 ///
701 /// @param[in] topology The topology returned by GetTopology()
702 ///
703 virtual void FreeTopology(game_input_topology* topology)
704 {
705 }
706 //----------------------------------------------------------------------------
707
708 //============================================================================
709 /// @brief Set the layouts for known controllers
710 ///
711 /// @param[in] controllers The controller layouts
712 ///
713 /// After loading the input topology, the frontend will call this with
714 /// controller layouts for all controllers discovered in the topology.
715 ///
716 virtual void SetControllerLayouts(const std::vector<kodi::addon::GameControllerLayout>& controllers)
717 {
718 }
719 //----------------------------------------------------------------------------
720
721 //============================================================================
722 /// @brief Enable/disable keyboard input using the specified controller
723 ///
724 /// @param[in] enable True to enable input, false otherwise
725 /// @param[in] controller_id The controller ID if enabling, or unused if disabling
726 ///
727 /// @return True if keyboard input was enabled, false otherwise
728 ///
729 virtual bool EnableKeyboard(bool enable, const std::string& controller_id)
730 {
731 return false;
732 }
733 //----------------------------------------------------------------------------
734
735 //============================================================================
736 /// @brief Enable/disable mouse input using the specified controller
737 ///
738 /// @param[in] enable True to enable input, false otherwise
739 /// @param[in] controller_id The controller ID if enabling, or unused if disabling
740 ///
741 /// @return True if mouse input was enabled, false otherwise
742 ///
743 virtual bool EnableMouse(bool enable, const std::string& controller_id)
744 {
745 return false;
746 }
747 //--------------------------------------------------------------------------
748
749 //==========================================================================
750 /// @brief Connect/disconnect a controller to a port on the virtual game console
751 ///
752 /// @param[in] connect True to connect a controller, false to disconnect
753 /// @param[in] port_address The address of the port
754 /// @param[in] controller_id The controller ID if connecting, or unused if disconnecting
755 /// @return True if the \p controller was (dis-)connected to the port, false otherwise
756 ///
757 /// The address is a string that allows traversal of the controller topology.
758 /// It is formed by alternating port IDs and controller IDs separated by "/".
759 ///
760 /// For example, assume that the topology represented in XML for Snes9x is:
761 ///
762 /// ~~~~~~~~~~~~~{.xml}
763 /// <logicaltopology>
764 /// <port type="controller" id="1">
765 /// <accepts controller="game.controller.snes"/>
766 /// <accepts controller="game.controller.snes.multitap">
767 /// <port type="controller" id="1">
768 /// <accepts controller="game.controller.snes"/>
769 /// </port>
770 /// <port type="controller" id="2">
771 /// <accepts controller="game.controller.snes"/>
772 /// </port>
773 /// ...
774 /// </accepts>
775 /// </port>
776 /// </logicaltopology>
777 /// ~~~~~~~~~~~~~
778 ///
779 /// To connect a multitap to the console's first port, the multitap's controller
780 /// info is set using the port address:
781 ///
782 /// 1
783 ///
784 /// To connect a SNES controller to the second port of the multitap, the
785 /// controller info is next set using the address:
786 ///
787 /// 1/game.controller.multitap/2
788 ///
789 /// Any attempts to connect a controller to a port on a disconnected multitap
790 /// will return false.
791 ///
792 virtual bool ConnectController(bool connect,
793 const std::string& port_address,
794 const std::string& controller_id)
795 {
796 return false;
797 }
798 //----------------------------------------------------------------------------
799
800 //============================================================================
801 /// @brief Notify the add-on of an input event
802 ///
803 /// @param[in] event The input event
804 ///
805 /// @return true if the event was handled, false otherwise
806 ///
807 virtual bool InputEvent(const game_input_event& event)
808 {
809 return false;
810 }
811 //----------------------------------------------------------------------------
812
813 //============================================================================
814 /// @brief **Callback to Kodi Function**<br>Notify the port of an input event
815 ///
816 /// @param[in] event The input event
817 /// @return true if the event was handled, false otherwise
818 ///
819 /// @note Input events can arrive for the following sources:
820 /// - @ref GAME_INPUT_EVENT_MOTOR
821 ///
822 /// @remarks Only called from addon itself
823 ///
824 bool KodiInputEvent(const game_input_event& event)
825 {
826 return m_instanceData->toKodi->InputEvent(m_instanceData->toKodi->kodiInstance, &event);
827 }
828 //----------------------------------------------------------------------------
829
830 ///@}
831
832//--==----==----==----==----==----==----==----==----==----==----==----==----==--
833
834 //============================================================================
835 /// @defgroup cpp_kodi_addon_game_SerializationOperations 5. Serialization operations
836 /// @ingroup cpp_kodi_addon_game
837 /// @brief **Serialization operations**
838 ///
839 ///
840 ///---------------------------------------------------------------------------
841 ///
842 /// **Serialization operation parts in interface:**\n
843 /// Copy this to your project and extend with your parts or leave functions
844 /// complete away where not used or supported.
845 ///
846 /// @copydetails cpp_kodi_addon_game_SerializationOperations_header_addon_auto_check
847 /// @copydetails cpp_kodi_addon_game_SerializationOperations_source_addon_auto_check
848 ///
849 ///@{
850
851 //============================================================================
852 /// @brief Get the number of bytes required to serialize the game
853 ///
854 /// @return the number of bytes, or 0 if serialization is not supported
855 ///
856 virtual size_t SerializeSize()
857 {
858 return 0;
859 }
860 //----------------------------------------------------------------------------
861
862 //============================================================================
863 /// @brief Serialize the state of the game
864 ///
865 /// @param[in] data The buffer receiving the serialized game data
866 /// @param[in] size The size of the buffer
867 ///
868 /// @return the error, or @ref GAME_ERROR_NO_ERROR if the game was serialized into the buffer
869 ///
870 virtual GAME_ERROR Serialize(uint8_t* data, size_t size)
871 {
872 return GAME_ERROR_NOT_IMPLEMENTED;
873 }
874 //----------------------------------------------------------------------------
875
876 //============================================================================
877 /// @brief Deserialize the game from the given state
878 ///
879 /// @param[in] data A buffer containing the game's new state
880 /// @param[in] size The size of the buffer
881 ///
882 /// @return the error, or @ref GAME_ERROR_NO_ERROR if the game deserialized
883 ///
884 virtual GAME_ERROR Deserialize(const uint8_t* data, size_t size)
885 {
886 return GAME_ERROR_NOT_IMPLEMENTED;
887 }
888 //----------------------------------------------------------------------------
889
890 ///@}
891
892//--==----==----==----==----==----==----==----==----==----==----==----==----==--
893
894 //============================================================================
895 /// @defgroup cpp_kodi_addon_game_CheatOperations 6. Cheat operations
896 /// @ingroup cpp_kodi_addon_game
897 /// @brief **Cheat operations**
898 ///
899 ///
900 ///---------------------------------------------------------------------------
901 ///
902 /// **Cheat operation parts in interface:**\n
903 /// Copy this to your project and extend with your parts or leave functions
904 /// complete away where not used or supported.
905 ///
906 /// @copydetails cpp_kodi_addon_game_CheatOperations_header_addon_auto_check
907 /// @copydetails cpp_kodi_addon_game_CheatOperations_source_addon_auto_check
908 ///
909 ///@{
910
911 //============================================================================
912 /// @brief Reset the cheat system
913 ///
914 /// @return the error, or @ref GAME_ERROR_NO_ERROR if the cheat system was reset
915 ///
916 virtual GAME_ERROR CheatReset()
917 {
918 return GAME_ERROR_NOT_IMPLEMENTED;
919 }
920 //----------------------------------------------------------------------------
921
922 //============================================================================
923 /// @brief Get a region of memory
924 ///
925 /// @param[in] type The type of memory to retrieve
926 /// @param[in] data Set to the region of memory; must remain valid until UnloadGame() is called
927 /// @param[in] size Set to the size of the region of memory
928 ///
929 /// @return the error, or @ref GAME_ERROR_NO_ERROR if data was set to a valid buffer
930 ///
931 virtual GAME_ERROR GetMemory(GAME_MEMORY type, uint8_t*& data, size_t& size)
932 {
933 return GAME_ERROR_NOT_IMPLEMENTED;
934 }
935 //----------------------------------------------------------------------------
936
937 //============================================================================
938 /// @brief Set a cheat code
939 ///
940 /// @param[in] index
941 /// @param[in] enabled
942 /// @param[in] code
943 ///
944 /// @return the error, or @ref GAME_ERROR_NO_ERROR if the cheat was set
945 ///
946 virtual GAME_ERROR SetCheat(unsigned int index, bool enabled, const std::string& code)
947 {
948 return GAME_ERROR_NOT_IMPLEMENTED;
949 }
950 //----------------------------------------------------------------------------
951
952 ///@}
953
954private:
955 void SetAddonStruct(KODI_HANDLE instance)
956 {
957 if (instance == nullptr)
958 throw std::logic_error("kodi::addon::CInstanceGame: Creation with empty addon structure not"
959 "allowed, table must be given from Kodi!");
960
961 m_instanceData = static_cast<AddonInstance_Game*>(instance);
962 m_instanceData->toAddon->addonInstance = this;
963
964 m_instanceData->toAddon->LoadGame = ADDON_LoadGame;
965 m_instanceData->toAddon->LoadGameSpecial = ADDON_LoadGameSpecial;
966 m_instanceData->toAddon->LoadStandalone = ADDON_LoadStandalone;
967 m_instanceData->toAddon->UnloadGame = ADDON_UnloadGame;
968 m_instanceData->toAddon->GetGameTiming = ADDON_GetGameTiming;
969 m_instanceData->toAddon->GetRegion = ADDON_GetRegion;
970 m_instanceData->toAddon->RequiresGameLoop = ADDON_RequiresGameLoop;
971 m_instanceData->toAddon->RunFrame = ADDON_RunFrame;
972 m_instanceData->toAddon->Reset = ADDON_Reset;
973
974 m_instanceData->toAddon->HwContextReset = ADDON_HwContextReset;
975 m_instanceData->toAddon->HwContextDestroy = ADDON_HwContextDestroy;
976
977 m_instanceData->toAddon->HasFeature = ADDON_HasFeature;
978 m_instanceData->toAddon->GetTopology = ADDON_GetTopology;
979 m_instanceData->toAddon->FreeTopology = ADDON_FreeTopology;
980 m_instanceData->toAddon->SetControllerLayouts = ADDON_SetControllerLayouts;
981 m_instanceData->toAddon->EnableKeyboard = ADDON_EnableKeyboard;
982 m_instanceData->toAddon->EnableMouse = ADDON_EnableMouse;
983 m_instanceData->toAddon->ConnectController = ADDON_ConnectController;
984 m_instanceData->toAddon->InputEvent = ADDON_InputEvent;
985
986 m_instanceData->toAddon->SerializeSize = ADDON_SerializeSize;
987 m_instanceData->toAddon->Serialize = ADDON_Serialize;
988 m_instanceData->toAddon->Deserialize = ADDON_Deserialize;
989
990 m_instanceData->toAddon->CheatReset = ADDON_CheatReset;
991 m_instanceData->toAddon->GetMemory = ADDON_GetMemory;
992 m_instanceData->toAddon->SetCheat = ADDON_SetCheat;
993 }
994
995 // --- Game operations ---------------------------------------------------------
996
997 inline static GAME_ERROR ADDON_LoadGame(const AddonInstance_Game* instance, const char* url)
998 {
999 return static_cast<CInstanceGame*>(instance->toAddon->addonInstance)->LoadGame(url);
1000 }
1001
1002 inline static GAME_ERROR ADDON_LoadGameSpecial(const AddonInstance_Game* instance,
1003 SPECIAL_GAME_TYPE type,
1004 const char** urls,
1005 size_t urlCount)
1006 {
1007 std::vector<std::string> urlList;
1008 for (size_t i = 0; i < urlCount; ++i)
1009 {
1010 if (urls[i] != nullptr)
1011 urlList.push_back(urls[i]);
1012 }
1013
1014 return static_cast<CInstanceGame*>(instance->toAddon->addonInstance)
1015 ->LoadGameSpecial(type, urlList);
1016 }
1017
1018 inline static GAME_ERROR ADDON_LoadStandalone(const AddonInstance_Game* instance)
1019 {
1020 return static_cast<CInstanceGame*>(instance->toAddon->addonInstance)->LoadStandalone();
1021 }
1022
1023 inline static GAME_ERROR ADDON_UnloadGame(const AddonInstance_Game* instance)
1024 {
1025 return static_cast<CInstanceGame*>(instance->toAddon->addonInstance)->UnloadGame();
1026 }
1027
1028 inline static GAME_ERROR ADDON_GetGameTiming(const AddonInstance_Game* instance,
1029 game_system_timing* timing_info)
1030 {
1031 return static_cast<CInstanceGame*>(instance->toAddon->addonInstance)
1032 ->GetGameTiming(*timing_info);
1033 }
1034
1035 inline static GAME_REGION ADDON_GetRegion(const AddonInstance_Game* instance)
1036 {
1037 return static_cast<CInstanceGame*>(instance->toAddon->addonInstance)->GetRegion();
1038 }
1039
1040 inline static bool ADDON_RequiresGameLoop(const AddonInstance_Game* instance)
1041 {
1042 return static_cast<CInstanceGame*>(instance->toAddon->addonInstance)->RequiresGameLoop();
1043 }
1044
1045 inline static GAME_ERROR ADDON_RunFrame(const AddonInstance_Game* instance)
1046 {
1047 return static_cast<CInstanceGame*>(instance->toAddon->addonInstance)->RunFrame();
1048 }
1049
1050 inline static GAME_ERROR ADDON_Reset(const AddonInstance_Game* instance)
1051 {
1052 return static_cast<CInstanceGame*>(instance->toAddon->addonInstance)->Reset();
1053 }
1054
1055
1056 // --- Hardware rendering operations -------------------------------------------
1057
1058 inline static GAME_ERROR ADDON_HwContextReset(const AddonInstance_Game* instance)
1059 {
1060 return static_cast<CInstanceGame*>(instance->toAddon->addonInstance)->HwContextReset();
1061 }
1062
1063 inline static GAME_ERROR ADDON_HwContextDestroy(const AddonInstance_Game* instance)
1064 {
1065 return static_cast<CInstanceGame*>(instance->toAddon->addonInstance)->HwContextDestroy();
1066 }
1067
1068
1069 // --- Input operations --------------------------------------------------------
1070
1071 inline static bool ADDON_HasFeature(const AddonInstance_Game* instance,
1072 const char* controller_id,
1073 const char* feature_name)
1074 {
1075 return static_cast<CInstanceGame*>(instance->toAddon->addonInstance)
1076 ->HasFeature(controller_id, feature_name);
1077 }
1078
1079 inline static game_input_topology* ADDON_GetTopology(const AddonInstance_Game* instance)
1080 {
1081 return static_cast<CInstanceGame*>(instance->toAddon->addonInstance)->GetTopology();
1082 }
1083
1084 inline static void ADDON_FreeTopology(const AddonInstance_Game* instance,
1085 game_input_topology* topology)
1086 {
1087 static_cast<CInstanceGame*>(instance->toAddon->addonInstance)->FreeTopology(topology);
1088 }
1089
1090 inline static void ADDON_SetControllerLayouts(const AddonInstance_Game* instance,
1091 const game_controller_layout* controllers,
1092 unsigned int controller_count)
1093 {
1094 if (controllers == nullptr)
1095 return;
1096
1097 std::vector<GameControllerLayout> controllerList;
1098 for (unsigned int i = 0; i < controller_count; ++i)
1099 controllerList.push_back(controllers[i]);
1100
1101 static_cast<CInstanceGame*>(instance->toAddon->addonInstance)
1102 ->SetControllerLayouts(controllerList);
1103 }
1104
1105 inline static bool ADDON_EnableKeyboard(const AddonInstance_Game* instance,
1106 bool enable,
1107 const char* controller_id)
1108 {
1109 return static_cast<CInstanceGame*>(instance->toAddon->addonInstance)
1110 ->EnableKeyboard(enable, controller_id);
1111 }
1112
1113 inline static bool ADDON_EnableMouse(const AddonInstance_Game* instance,
1114 bool enable,
1115 const char* controller_id)
1116 {
1117 return static_cast<CInstanceGame*>(instance->toAddon->addonInstance)
1118 ->EnableMouse(enable, controller_id);
1119 }
1120
1121 inline static bool ADDON_ConnectController(const AddonInstance_Game* instance,
1122 bool connect,
1123 const char* port_address,
1124 const char* controller_id)
1125 {
1126 return static_cast<CInstanceGame*>(instance->toAddon->addonInstance)
1127 ->ConnectController(connect, port_address, controller_id);
1128 }
1129
1130 inline static bool ADDON_InputEvent(const AddonInstance_Game* instance,
1131 const game_input_event* event)
1132 {
1133 return static_cast<CInstanceGame*>(instance->toAddon->addonInstance)->InputEvent(*event);
1134 }
1135
1136
1137 // --- Serialization operations ------------------------------------------------
1138
1139 inline static size_t ADDON_SerializeSize(const AddonInstance_Game* instance)
1140 {
1141 return static_cast<CInstanceGame*>(instance->toAddon->addonInstance)->SerializeSize();
1142 }
1143
1144 inline static GAME_ERROR ADDON_Serialize(const AddonInstance_Game* instance,
1145 uint8_t* data,
1146 size_t size)
1147 {
1148 return static_cast<CInstanceGame*>(instance->toAddon->addonInstance)->Serialize(data, size);
1149 }
1150
1151 inline static GAME_ERROR ADDON_Deserialize(const AddonInstance_Game* instance,
1152 const uint8_t* data,
1153 size_t size)
1154 {
1155 return static_cast<CInstanceGame*>(instance->toAddon->addonInstance)->Deserialize(data, size);
1156 }
1157
1158
1159 // --- Cheat operations --------------------------------------------------------
1160
1161 inline static GAME_ERROR ADDON_CheatReset(const AddonInstance_Game* instance)
1162 {
1163 return static_cast<CInstanceGame*>(instance->toAddon->addonInstance)->CheatReset();
1164 }
1165
1166 inline static GAME_ERROR ADDON_GetMemory(const AddonInstance_Game* instance,
1167 GAME_MEMORY type,
1168 uint8_t** data,
1169 size_t* size)
1170 {
1171 return static_cast<CInstanceGame*>(instance->toAddon->addonInstance)
1172 ->GetMemory(type, *data, *size);
1173 }
1174
1175 inline static GAME_ERROR ADDON_SetCheat(const AddonInstance_Game* instance,
1176 unsigned int index,
1177 bool enabled,
1178 const char* code)
1179 {
1180 return static_cast<CInstanceGame*>(instance->toAddon->addonInstance)
1181 ->SetCheat(index, enabled, code);
1182 }
1183
1184 AddonInstance_Game* m_instanceData;
1185};
1186
1187} /* namespace addon */
1188} /* namespace kodi */
1189
1190#endif /* __cplusplus */
diff --git a/xbmc/addons/kodi-dev-kit/include/kodi/addon-instance/ImageDecoder.h b/xbmc/addons/kodi-dev-kit/include/kodi/addon-instance/ImageDecoder.h
new file mode 100644
index 0000000..7aeef7b
--- /dev/null
+++ b/xbmc/addons/kodi-dev-kit/include/kodi/addon-instance/ImageDecoder.h
@@ -0,0 +1,315 @@
1/*
2 * Copyright (C) 2005-2018 Team Kodi
3 * This file is part of Kodi - https://kodi.tv
4 *
5 * SPDX-License-Identifier: GPL-2.0-or-later
6 * See LICENSES/README.md for more information.
7 */
8
9#pragma once
10
11#include "../AddonBase.h"
12#include "../c-api/addon-instance/image_decoder.h"
13
14#ifdef __cplusplus
15namespace kodi
16{
17namespace addon
18{
19
20//##############################################################################
21/// @defgroup cpp_kodi_addon_imagedecoder_Defs Definitions, structures and enumerators
22/// @ingroup cpp_kodi_addon_imagedecoder
23/// @brief **Image decoder add-on general variables**
24///
25/// Used to exchange the available options between Kodi and addon.
26///
27///
28
29//==============================================================================
30///
31/// @addtogroup cpp_kodi_addon_imagedecoder
32/// @brief @cpp_class{ kodi::addon::CInstanceImageDecoder }
33/// **Image decoder add-on instance**\n
34/// This instance type is used to allow Kodi various additional image format
35/// types.
36///
37/// This usage can be requested under various conditions, by a Mimetype protocol
38/// defined in <b>`addon.xml`</b> or supported file extensions.
39///
40/// Include the header @ref ImageDecoder.h "#include <kodi/addon-instance/ImageDecoder.h>"
41/// to use this class.
42///
43/// ----------------------------------------------------------------------------
44///
45/// Here is an example of what the <b>`addon.xml.in`</b> would look like for an
46/// image decoder addon:
47///
48/// ~~~~~~~~~~~~~{.xml}
49/// <?xml version="1.0" encoding="UTF-8"?>
50/// <addon
51/// id="imagedecoder.myspecialnamefor"
52/// version="1.0.0"
53/// name="My image decoder addon"
54/// provider-name="Your Name">
55/// <requires>@ADDON_DEPENDS@</requires>
56/// <extension
57/// point="kodi.imagedecoder"
58/// extension=".imga|.imgb"
59/// mimetype="image/mymimea|image/mymimea"
60/// library_@PLATFORM@="@LIBRARY_FILENAME@"/>
61/// <extension point="xbmc.addon.metadata">
62/// <summary lang="en_GB">My image decoder addon summary</summary>
63/// <description lang="en_GB">My image decoder description</description>
64/// <platform>@PLATFORM@</platform>
65/// </extension>
66/// </addon>
67/// ~~~~~~~~~~~~~
68///
69/// ### Standard values that can be declared for processing in `addon.xml`.
70///
71/// These values are used by Kodi to identify associated images and file
72/// extensions and then to select the associated addon.
73///
74/// \table_start
75/// \table_h3{ Labels, Type, Description }
76/// \table_row3{ <b>`point`</b>,
77/// @anchor cpp_kodi_addon_imagedecoder_point
78/// string,
79/// The identification of the addon instance to image decoder is mandatory
80/// <b>`kodi.imagedecoder`</b>. In addition\, the instance declared in the
81/// first <b>`<extension ... />`</b> is also the main type of addon.
82/// }
83/// \table_row3{ <b>`extension`</b>,
84/// @anchor cpp_kodi_addon_imagedecoder_defaultPort
85/// string,
86/// The from addon operated and supported image file endings.\n
87/// Use a <b>`|`</b> to separate between different ones.
88/// }
89/// \table_row3{ <b>`defaultPort`</b>,
90/// @anchor cpp_kodi_addon_imagedecoder_defaultPort
91/// string,
92/// The from addon operated image [mimetypes](https://en.wikipedia.org/wiki/Media_type).\n
93/// Use a <b>`|`</b> to separate between different ones.
94/// }
95/// \table_row3{ <b>`library_@PLATFORM@`</b>,
96/// @anchor cpp_kodi_addon_imagedecoder_library
97/// string,
98/// The runtime library used for the addon. This is usually declared by `cmake` and correctly displayed in the translated <b>`addon.xml`</b>.
99/// }
100/// \table_end
101///
102/// @remark For more detailed description of the <b>`addon.xml`</b>, see also https://kodi.wiki/view/Addon.xml.
103///
104///
105/// --------------------------------------------------------------------------
106///
107///
108/// **Example:**
109///
110/// ~~~~~~~~~~~~~{.cpp}
111/// #include <kodi/addon-instance/ImageDecoder.h>
112///
113/// class ATTRIBUTE_HIDDEN CMyImageDecoder : public kodi::addon::CInstanceImageDecoder
114/// {
115/// public:
116/// CMyImageDecoder(KODI_HANDLE instance, const std::string& kodiVersion);
117///
118/// bool LoadImageFromMemory(unsigned char* buffer,
119/// unsigned int bufSize,
120/// unsigned int& width,
121/// unsigned int& height) override;
122///
123/// bool Decode(unsigned char* pixels,
124/// unsigned int width,
125/// unsigned int height,
126/// unsigned int pitch,
127/// ImageFormat format) override;
128///
129/// ...
130/// };
131///
132/// CMyImageDecoder::CMyImageDecoder(KODI_HANDLE instance, const std::string& kodiVersion)
133/// : CInstanceImageDecoder(instance, kodiVersion)
134/// {
135/// ...
136/// }
137///
138/// bool CMyImageDecoder::LoadImageFromMemory(unsigned char* buffer,
139/// unsigned int bufSize,
140/// unsigned int& width,
141/// unsigned int& height)
142/// {
143/// ...
144/// return true;
145/// }
146///
147/// bool CMyImageDecoder::Decode(unsigned char* pixels,
148/// unsigned int width,
149/// unsigned int height,
150/// unsigned int pitch,
151/// ImageFormat format) override;
152/// {
153/// ...
154/// return true;
155/// }
156///
157/// //----------------------------------------------------------------------
158///
159/// class ATTRIBUTE_HIDDEN CMyAddon : public kodi::addon::CAddonBase
160/// {
161/// public:
162/// CMyAddon() = default;
163/// ADDON_STATUS CreateInstance(int instanceType,
164/// const std::string& instanceID,
165/// KODI_HANDLE instance,
166/// const std::string& version,
167/// KODI_HANDLE& addonInstance) override;
168/// };
169///
170/// // If you use only one instance in your add-on, can be instanceType and
171/// // instanceID ignored
172/// ADDON_STATUS CMyAddon::CreateInstance(int instanceType,
173/// const std::string& instanceID,
174/// KODI_HANDLE instance,
175/// const std::string& version,
176/// KODI_HANDLE& addonInstance)
177/// {
178/// if (instanceType == ADDON_INSTANCE_IMAGEDECODER)
179/// {
180/// kodi::Log(ADDON_LOG_INFO, "Creating my image decoder instance");
181/// addonInstance = new CMyImageDecoder(instance, version);
182/// return ADDON_STATUS_OK;
183/// }
184/// else if (...)
185/// {
186/// ...
187/// }
188/// return ADDON_STATUS_UNKNOWN;
189/// }
190///
191/// ADDONCREATOR(CMyAddon)
192/// ~~~~~~~~~~~~~
193///
194/// The destruction of the example class `CMyImageDecoder` is called from
195/// Kodi's header. Manually deleting the add-on instance is not required.
196///
197//------------------------------------------------------------------------------
198class ATTRIBUTE_HIDDEN CInstanceImageDecoder : public IAddonInstance
199{
200public:
201 //============================================================================
202 /// @ingroup cpp_kodi_addon_imagedecoder
203 /// @brief Class constructor.
204 ///
205 /// @param[in] instance The from Kodi given instance given be add-on
206 /// CreateInstance call with instance id
207 /// @ref ADDON_INSTANCE_IMAGEDECODER.
208 /// @param[in] kodiVersion [opt] Version used in Kodi for this instance, to
209 /// allow compatibility to older Kodi versions.
210 ///
211 /// @note Recommended to set <b>`kodiVersion`</b>.
212 ///
213 explicit CInstanceImageDecoder(KODI_HANDLE instance, const std::string& kodiVersion = "")
214 : IAddonInstance(ADDON_INSTANCE_IMAGEDECODER,
215 !kodiVersion.empty() ? kodiVersion
216 : GetKodiTypeVersion(ADDON_INSTANCE_IMAGEDECODER))
217 {
218 if (CAddonBase::m_interface->globalSingleInstance != nullptr)
219 throw std::logic_error("kodi::addon::CInstanceImageDecoder: Creation of multiple together "
220 "with single instance way is not allowed!");
221
222 SetAddonStruct(instance);
223 }
224 //----------------------------------------------------------------------------
225
226 ~CInstanceImageDecoder() override = default;
227
228 //============================================================================
229 /// @ingroup cpp_kodi_addon_imagedecoder
230 /// @brief Initialize an encoder.
231 ///
232 /// @param[in] buffer The data to read from memory
233 /// @param[in] bufSize The buffer size
234 /// @param[in,out] width The optimal width of image on entry, obtained width
235 /// on return
236 /// @param[in,out] height The optimal height of image, actual obtained height
237 /// on return
238 /// @return true if successful done, false on error
239 ///
240 virtual bool LoadImageFromMemory(unsigned char* buffer,
241 unsigned int bufSize,
242 unsigned int& width,
243 unsigned int& height) = 0;
244 //----------------------------------------------------------------------------
245
246 //============================================================================
247 /// @ingroup cpp_kodi_addon_imagedecoder
248 /// @brief Decode previously loaded image.
249 ///
250 /// @param[in] pixels Output buffer
251 /// @param[in] width Width of output image
252 /// @param[in] height Height of output image
253 /// @param[in] pitch Pitch of output image
254 /// @param[in] format Format of output image
255 /// @return true if successful done, false on error
256 ///
257 virtual bool Decode(unsigned char* pixels,
258 unsigned int width,
259 unsigned int height,
260 unsigned int pitch,
261 ImageFormat format) = 0;
262 //----------------------------------------------------------------------------
263
264 //============================================================================
265 /// @ingroup cpp_kodi_addon_imagedecoder
266 /// @brief **Callback to Kodi Function**\n
267 /// Get the wanted mime type from Kodi.
268 ///
269 /// @return the mimetype wanted from Kodi
270 ///
271 /// @remarks Only called from addon itself.
272 ///
273 inline std::string MimeType() { return m_instanceData->props->mimetype; }
274 //----------------------------------------------------------------------------
275
276private:
277 void SetAddonStruct(KODI_HANDLE instance)
278 {
279 if (instance == nullptr)
280 throw std::logic_error("kodi::addon::CInstanceImageDecoder: Creation with empty addon "
281 "structure not allowed, table must be given from Kodi!");
282
283 m_instanceData = static_cast<AddonInstance_ImageDecoder*>(instance);
284 m_instanceData->toAddon->addonInstance = this;
285 m_instanceData->toAddon->load_image_from_memory = ADDON_LoadImageFromMemory;
286 m_instanceData->toAddon->decode = ADDON_Decode;
287 }
288
289 inline static bool ADDON_LoadImageFromMemory(const AddonInstance_ImageDecoder* instance,
290 unsigned char* buffer,
291 unsigned int bufSize,
292 unsigned int* width,
293 unsigned int* height)
294 {
295 return static_cast<CInstanceImageDecoder*>(instance->toAddon->addonInstance)
296 ->LoadImageFromMemory(buffer, bufSize, *width, *height);
297 }
298
299 inline static bool ADDON_Decode(const AddonInstance_ImageDecoder* instance,
300 unsigned char* pixels,
301 unsigned int width,
302 unsigned int height,
303 unsigned int pitch,
304 enum ImageFormat format)
305 {
306 return static_cast<CInstanceImageDecoder*>(instance->toAddon->addonInstance)
307 ->Decode(pixels, width, height, pitch, format);
308 }
309
310 AddonInstance_ImageDecoder* m_instanceData;
311};
312
313} /* namespace addon */
314} /* namespace kodi */
315#endif /* __cplusplus */
diff --git a/xbmc/addons/kodi-dev-kit/include/kodi/addon-instance/Inputstream.h b/xbmc/addons/kodi-dev-kit/include/kodi/addon-instance/Inputstream.h
new file mode 100644
index 0000000..396b92e
--- /dev/null
+++ b/xbmc/addons/kodi-dev-kit/include/kodi/addon-instance/Inputstream.h
@@ -0,0 +1,934 @@
1/*
2 * Copyright (C) 2005-2018 Team Kodi
3 * This file is part of Kodi - https://kodi.tv
4 *
5 * SPDX-License-Identifier: GPL-2.0-or-later
6 * See LICENSES/README.md for more information.
7 */
8
9#pragma once
10
11/*
12 * Parts with a comment named "internal" are only used inside header and not
13 * used or accessed direct during add-on development!
14 */
15
16#include "../AddonBase.h"
17#include "../StreamCodec.h"
18#include "../StreamCrypto.h"
19
20#ifdef BUILD_KODI_ADDON
21#include "../DemuxPacket.h"
22#include "../InputStreamConstants.h"
23#else
24#include "cores/VideoPlayer/Interface/Addon/DemuxPacket.h"
25#include "cores/VideoPlayer/Interface/Addon/InputStreamConstants.h"
26#endif
27
28//Increment this level always if you add features which can lead to compile failures in the addon
29#define INPUTSTREAM_VERSION_LEVEL 2
30
31#define INPUTSTREAM_MAX_STREAM_COUNT 256
32#define INPUTSTREAM_MAX_STRING_NAME_SIZE 256
33#define INPUTSTREAM_MAX_STRING_CODEC_SIZE 32
34#define INPUTSTREAM_MAX_STRING_LANGUAGE_SIZE 64
35
36#ifdef __cplusplus
37extern "C"
38{
39#endif /* __cplusplus */
40
41 /*!
42 * @brief InputStream add-on capabilities. All capabilities are set to "false" as default.
43 */
44 struct INPUTSTREAM_CAPABILITIES
45 {
46 enum MASKTYPE : uint32_t
47 {
48 /// supports interface IDemux
49 SUPPORTS_IDEMUX = (1 << 0),
50
51 /// supports interface IPosTime
52 SUPPORTS_IPOSTIME = (1 << 1),
53
54 /// supports interface IDisplayTime
55 SUPPORTS_IDISPLAYTIME = (1 << 2),
56
57 /// supports seek
58 SUPPORTS_SEEK = (1 << 3),
59
60 /// supports pause
61 SUPPORTS_PAUSE = (1 << 4),
62
63 /// supports interface ITime
64 SUPPORTS_ITIME = (1 << 5),
65
66 /// supports interface IChapter
67 SUPPORTS_ICHAPTER = (1 << 6),
68 };
69
70 /// set of supported capabilities
71 uint32_t m_mask;
72 };
73
74 /*!
75 * @brief structure of key/value pairs passed to addon on Open()
76 */
77 struct INPUTSTREAM
78 {
79 const char* m_strURL;
80 const char* m_mimeType;
81
82 unsigned int m_nCountInfoValues;
83 struct LISTITEMPROPERTY
84 {
85 const char* m_strKey;
86 const char* m_strValue;
87 } m_ListItemProperties[STREAM_MAX_PROPERTY_COUNT];
88
89 const char* m_libFolder;
90 const char* m_profileFolder;
91 };
92
93 /*!
94 * @brief Array of stream IDs
95 */
96 struct INPUTSTREAM_IDS
97 {
98 unsigned int m_streamCount;
99 unsigned int m_streamIds[INPUTSTREAM_MAX_STREAM_COUNT];
100 };
101
102 /*!
103 * @brief MASTERING Metadata
104 */
105 struct INPUTSTREAM_MASTERING_METADATA
106 {
107 double primary_r_chromaticity_x;
108 double primary_r_chromaticity_y;
109 double primary_g_chromaticity_x;
110 double primary_g_chromaticity_y;
111 double primary_b_chromaticity_x;
112 double primary_b_chromaticity_y;
113 double white_point_chromaticity_x;
114 double white_point_chromaticity_y;
115 double luminance_max;
116 double luminance_min;
117 };
118
119 /*!
120 * @brief CONTENTLIGHT Metadata
121 */
122 struct INPUTSTREAM_CONTENTLIGHT_METADATA
123 {
124 uint64_t max_cll;
125 uint64_t max_fall;
126 };
127
128 /*!
129 * @brief stream properties
130 */
131 struct INPUTSTREAM_INFO
132 {
133 enum STREAM_TYPE
134 {
135 TYPE_NONE = 0,
136 TYPE_VIDEO,
137 TYPE_AUDIO,
138 TYPE_SUBTITLE,
139 TYPE_TELETEXT,
140 TYPE_RDS,
141 } m_streamType;
142
143 enum Codec_FEATURES : uint32_t
144 {
145 FEATURE_DECODE = 1
146 };
147 uint32_t m_features;
148
149 enum STREAM_FLAGS : uint32_t
150 {
151 FLAG_NONE = 0x0000,
152 FLAG_DEFAULT = 0x0001,
153 FLAG_DUB = 0x0002,
154 FLAG_ORIGINAL = 0x0004,
155 FLAG_COMMENT = 0x0008,
156 FLAG_LYRICS = 0x0010,
157 FLAG_KARAOKE = 0x0020,
158 FLAG_FORCED = 0x0040,
159 FLAG_HEARING_IMPAIRED = 0x0080,
160 FLAG_VISUAL_IMPAIRED = 0x0100,
161 };
162
163 // Keep in sync with AVColorSpace
164 enum COLORSPACE
165 {
166 COLORSPACE_RGB = 0,
167 COLORSPACE_BT709 = 1,
168 COLORSPACE_UNSPECIFIED = 2,
169 COLORSPACE_UNKNOWN = COLORSPACE_UNSPECIFIED, // compatibility
170 COLORSPACE_RESERVED = 3,
171 COLORSPACE_FCC = 4,
172 COLORSPACE_BT470BG = 5,
173 COLORSPACE_SMPTE170M = 6,
174 COLORSPACE_SMPTE240M = 7,
175 COLORSPACE_YCGCO = 8,
176 COLORSPACE_YCOCG = COLORSPACE_YCGCO,
177 COLORSPACE_BT2020_NCL = 9,
178 COLORSPACE_BT2020_CL = 10,
179 COLORSPACE_SMPTE2085 = 11,
180 COLORSPACE_CHROMA_DERIVED_NCL = 12,
181 COLORSPACE_CHROMA_DERIVED_CL = 13,
182 COLORSPACE_ICTCP = 14,
183 COLORSPACE_MAX
184 };
185
186 // Keep in sync with AVColorPrimaries
187 enum COLORPRIMARIES : int32_t
188 {
189 COLORPRIMARY_RESERVED0 = 0,
190 COLORPRIMARY_BT709 = 1,
191 COLORPRIMARY_UNSPECIFIED = 2,
192 COLORPRIMARY_RESERVED = 3,
193 COLORPRIMARY_BT470M = 4,
194 COLORPRIMARY_BT470BG = 5,
195 COLORPRIMARY_SMPTE170M = 6,
196 COLORPRIMARY_SMPTE240M = 7,
197 COLORPRIMARY_FILM = 8,
198 COLORPRIMARY_BT2020 = 9,
199 COLORPRIMARY_SMPTE428 = 10,
200 COLORPRIMARY_SMPTEST428_1 = COLORPRIMARY_SMPTE428,
201 COLORPRIMARY_SMPTE431 = 11,
202 COLORPRIMARY_SMPTE432 = 12,
203 COLORPRIMARY_JEDEC_P22 = 22,
204 COLORPRIMARY_MAX
205 };
206
207 // Keep in sync with AVColorRange
208 enum COLORRANGE
209 {
210 COLORRANGE_UNKNOWN = 0,
211 COLORRANGE_LIMITED,
212 COLORRANGE_FULLRANGE,
213 COLORRANGE_MAX
214 };
215
216 // keep in sync with AVColorTransferCharacteristic
217 enum COLORTRC : int32_t
218 {
219 COLORTRC_RESERVED0 = 0,
220 COLORTRC_BT709 = 1,
221 COLORTRC_UNSPECIFIED = 2,
222 COLORTRC_RESERVED = 3,
223 COLORTRC_GAMMA22 = 4,
224 COLORTRC_GAMMA28 = 5,
225 COLORTRC_SMPTE170M = 6,
226 COLORTRC_SMPTE240M = 7,
227 COLORTRC_LINEAR = 8,
228 COLORTRC_LOG = 9,
229 COLORTRC_LOG_SQRT = 10,
230 COLORTRC_IEC61966_2_4 = 11,
231 COLORTRC_BT1361_ECG = 12,
232 COLORTRC_IEC61966_2_1 = 13,
233 COLORTRC_BT2020_10 = 14,
234 COLORTRC_BT2020_12 = 15,
235 COLORTRC_SMPTE2084 = 16,
236 COLORTRC_SMPTEST2084 = COLORTRC_SMPTE2084,
237 COLORTRC_SMPTE428 = 17,
238 COLORTRC_SMPTEST428_1 = COLORTRC_SMPTE428,
239 COLORTRC_ARIB_STD_B67 = 18,
240 COLORTRC_MAX
241 };
242
243 uint32_t m_flags;
244
245 //! @brief (optional) name of the stream, \0 for default handling
246 char m_name[INPUTSTREAM_MAX_STRING_NAME_SIZE];
247
248 //! @brief (required) name of codec according to ffmpeg
249 char m_codecName[INPUTSTREAM_MAX_STRING_CODEC_SIZE];
250
251 //! @brief (optional) internal name of codec (selectionstream info)
252 char m_codecInternalName[INPUTSTREAM_MAX_STRING_CODEC_SIZE];
253
254 //! @brief (optional) the profile of the codec
255 STREAMCODEC_PROFILE m_codecProfile;
256
257 //! @brief (required) physical index
258 unsigned int m_pID;
259
260 const uint8_t* m_ExtraData;
261 unsigned int m_ExtraSize;
262
263 //! @brief RFC 5646 language code (empty string if undefined)
264 char m_language[INPUTSTREAM_MAX_STRING_LANGUAGE_SIZE];
265
266 //! Video stream related data
267 //@{
268
269 //! @brief Scale of 1000 and a rate of 29970 will result in 29.97 fps
270 unsigned int m_FpsScale;
271
272 unsigned int m_FpsRate;
273
274 //! @brief height of the stream reported by the demuxer
275 unsigned int m_Height;
276
277 //! @brief width of the stream reported by the demuxer
278 unsigned int m_Width;
279
280 //! @brief display aspect of stream
281 float m_Aspect;
282
283 //@}
284
285 //! Audio stream related data
286 //@{
287
288 //! @brief (required) amount of channels
289 unsigned int m_Channels;
290
291 //! @brief (required) sample rate
292 unsigned int m_SampleRate;
293
294 //! @brief (required) bit rate
295 unsigned int m_BitRate;
296
297 //! @brief (required) bits per sample
298 unsigned int m_BitsPerSample;
299
300 unsigned int m_BlockAlign;
301
302 //@}
303
304 CRYPTO_INFO m_cryptoInfo;
305
306 // new in API version 2.0.8
307 //@{
308 //! @brief Codec If available, the fourcc code codec
309 unsigned int m_codecFourCC;
310
311 //! @brief definition of colorspace
312 COLORSPACE m_colorSpace;
313
314 //! @brief color range if available
315 COLORRANGE m_colorRange;
316 //@}
317
318 //new in API 2.0.9 / INPUTSTREAM_VERSION_LEVEL 1
319 //@{
320 COLORPRIMARIES m_colorPrimaries;
321 COLORTRC m_colorTransferCharacteristic;
322 //@}
323
324 //! @brief mastering static Metadata
325 INPUTSTREAM_MASTERING_METADATA* m_masteringMetadata;
326
327 //! @brief content light static Metadata
328 INPUTSTREAM_CONTENTLIGHT_METADATA* m_contentLightMetadata;
329 };
330
331 struct INPUTSTREAM_TIMES
332 {
333 time_t startTime;
334 double ptsStart;
335 double ptsBegin;
336 double ptsEnd;
337 };
338
339 /*!
340 * @brief "C" ABI Structures to transfer the methods from this to Kodi
341 */
342
343 // this are properties given to the addon on create
344 // at this time we have no parameters for the addon
345 typedef struct AddonProps_InputStream /* internal */
346 {
347 int dummy;
348 } AddonProps_InputStream;
349
350 typedef struct AddonToKodiFuncTable_InputStream /* internal */
351 {
352 KODI_HANDLE kodiInstance;
353 DemuxPacket* (*allocate_demux_packet)(void* kodiInstance, int data_size);
354 DemuxPacket* (*allocate_encrypted_demux_packet)(void* kodiInstance,
355 unsigned int data_size,
356 unsigned int encrypted_subsample_count);
357 void (*free_demux_packet)(void* kodiInstance, DemuxPacket* packet);
358 } AddonToKodiFuncTable_InputStream;
359
360 struct AddonInstance_InputStream;
361 typedef struct KodiToAddonFuncTable_InputStream /* internal */
362 {
363 KODI_HANDLE addonInstance;
364
365 bool(__cdecl* open)(const AddonInstance_InputStream* instance, INPUTSTREAM* props);
366 void(__cdecl* close)(const AddonInstance_InputStream* instance);
367 const char*(__cdecl* get_path_list)(const AddonInstance_InputStream* instance);
368 void(__cdecl* get_capabilities)(const AddonInstance_InputStream* instance,
369 INPUTSTREAM_CAPABILITIES* capabilities);
370
371 // IDemux
372 struct INPUTSTREAM_IDS(__cdecl* get_stream_ids)(const AddonInstance_InputStream* instance);
373 struct INPUTSTREAM_INFO(__cdecl* get_stream)(const AddonInstance_InputStream* instance,
374 int streamid);
375 void(__cdecl* enable_stream)(const AddonInstance_InputStream* instance,
376 int streamid,
377 bool enable);
378 bool(__cdecl* open_stream)(const AddonInstance_InputStream* instance, int streamid);
379 void(__cdecl* demux_reset)(const AddonInstance_InputStream* instance);
380 void(__cdecl* demux_abort)(const AddonInstance_InputStream* instance);
381 void(__cdecl* demux_flush)(const AddonInstance_InputStream* instance);
382 DemuxPacket*(__cdecl* demux_read)(const AddonInstance_InputStream* instance);
383 bool(__cdecl* demux_seek_time)(const AddonInstance_InputStream* instance,
384 double time,
385 bool backwards,
386 double* startpts);
387 void(__cdecl* demux_set_speed)(const AddonInstance_InputStream* instance, int speed);
388 void(__cdecl* set_video_resolution)(const AddonInstance_InputStream* instance,
389 int width,
390 int height);
391
392 // IDisplayTime
393 int(__cdecl* get_total_time)(const AddonInstance_InputStream* instance);
394 int(__cdecl* get_time)(const AddonInstance_InputStream* instance);
395
396 // ITime
397 bool(__cdecl* get_times)(const AddonInstance_InputStream* instance, INPUTSTREAM_TIMES* times);
398
399 // IPosTime
400 bool(__cdecl* pos_time)(const AddonInstance_InputStream* instance, int ms);
401
402 int(__cdecl* read_stream)(const AddonInstance_InputStream* instance,
403 uint8_t* buffer,
404 unsigned int bufferSize);
405 int64_t(__cdecl* seek_stream)(const AddonInstance_InputStream* instance,
406 int64_t position,
407 int whence);
408 int64_t(__cdecl* position_stream)(const AddonInstance_InputStream* instance);
409 int64_t(__cdecl* length_stream)(const AddonInstance_InputStream* instance);
410 bool(__cdecl* is_real_time_stream)(const AddonInstance_InputStream* instance);
411
412 // IChapter
413 int(__cdecl* get_chapter)(const AddonInstance_InputStream* instance);
414 int(__cdecl* get_chapter_count)(const AddonInstance_InputStream* instance);
415 const char*(__cdecl* get_chapter_name)(const AddonInstance_InputStream* instance, int ch);
416 int64_t(__cdecl* get_chapter_pos)(const AddonInstance_InputStream* instance, int ch);
417 bool(__cdecl* seek_chapter)(const AddonInstance_InputStream* instance, int ch);
418
419 int(__cdecl* block_size_stream)(const AddonInstance_InputStream* instance);
420 } KodiToAddonFuncTable_InputStream;
421
422 typedef struct AddonInstance_InputStream /* internal */
423 {
424 AddonProps_InputStream* props;
425 AddonToKodiFuncTable_InputStream* toKodi;
426 KodiToAddonFuncTable_InputStream* toAddon;
427 } AddonInstance_InputStream;
428
429#ifdef __cplusplus
430} /* extern "C" */
431
432namespace kodi
433{
434namespace addon
435{
436
437class ATTRIBUTE_HIDDEN CInstanceInputStream : public IAddonInstance
438{
439public:
440 explicit CInstanceInputStream(KODI_HANDLE instance, const std::string& kodiVersion = "")
441 : IAddonInstance(ADDON_INSTANCE_INPUTSTREAM,
442 !kodiVersion.empty() ? kodiVersion
443 : GetKodiTypeVersion(ADDON_INSTANCE_INPUTSTREAM))
444 {
445 if (CAddonBase::m_interface->globalSingleInstance != nullptr)
446 throw std::logic_error("kodi::addon::CInstanceInputStream: Creation of multiple together "
447 "with single instance way is not allowed!");
448
449 SetAddonStruct(instance, m_kodiVersion);
450 }
451
452 ~CInstanceInputStream() override = default;
453
454 /*!
455 * Open a stream.
456 * @param props
457 * @return True if the stream has been opened successfully, false otherwise.
458 * @remarks
459 */
460 virtual bool Open(INPUTSTREAM& props) = 0;
461
462 /*!
463 * Close an open stream.
464 * @remarks
465 */
466 virtual void Close() = 0;
467
468 /*!
469 * Get Capabilities of this addon.
470 * @param capabilities The add-on's capabilities.
471 * @remarks
472 */
473 virtual void GetCapabilities(INPUTSTREAM_CAPABILITIES& capabilities) = 0;
474
475 /*!
476 * Get IDs of available streams
477 * @remarks
478 */
479 virtual INPUTSTREAM_IDS GetStreamIds() = 0;
480
481 /*!
482 * Get stream properties of a stream.
483 * @param streamid unique id of stream
484 * @return struc of stream properties
485 * @remarks
486 */
487 virtual INPUTSTREAM_INFO GetStream(int streamid) = 0;
488
489 /*!
490 * Enable or disable a stream.
491 * A disabled stream does not send demux packets
492 * @param streamid unique id of stream
493 * @param enable true for enable, false for disable
494 * @remarks
495 */
496 virtual void EnableStream(int streamid, bool enable) = 0;
497
498 /*!
499 * Opens a stream for playback.
500 * @param streamid unique id of stream
501 * @remarks
502 */
503 virtual bool OpenStream(int streamid) = 0;
504
505 /*!
506 * Reset the demultiplexer in the add-on.
507 * @remarks Required if bHandlesDemuxing is set to true.
508 */
509 virtual void DemuxReset() {}
510
511 /*!
512 * Abort the demultiplexer thread in the add-on.
513 * @remarks Required if bHandlesDemuxing is set to true.
514 */
515 virtual void DemuxAbort() {}
516
517 /*!
518 * Flush all data that's currently in the demultiplexer buffer in the add-on.
519 * @remarks Required if bHandlesDemuxing is set to true.
520 */
521 virtual void DemuxFlush() {}
522
523 /*!
524 * Read the next packet from the demultiplexer, if there is one.
525 * @return The next packet.
526 * If there is no next packet, then the add-on should return the
527 * packet created by calling AllocateDemuxPacket(0) on the callback.
528 * If the stream changed and Kodi's player needs to be reinitialised,
529 * then, the add-on should call AllocateDemuxPacket(0) on the
530 * callback, and set the streamid to DMX_SPECIALID_STREAMCHANGE and
531 * return the value.
532 * The add-on should return NULL if an error occurred.
533 * @remarks Return NULL if this add-on won't provide this function.
534 */
535 virtual DemuxPacket* DemuxRead() { return nullptr; }
536
537 /*!
538 * Notify the InputStream addon/demuxer that Kodi wishes to seek the stream by time
539 * Demuxer is required to set stream to an IDR frame
540 * @param time The absolute time since stream start
541 * @param backwards True to seek to keyframe BEFORE time, else AFTER
542 * @param startpts can be updated to point to where display should start
543 * @return True if the seek operation was possible
544 * @remarks Optional, and only used if addon has its own demuxer.
545 */
546 virtual bool DemuxSeekTime(double time, bool backwards, double& startpts) { return false; }
547
548 /*!
549 * Notify the InputStream addon/demuxer that Kodi wishes to change playback speed
550 * @param speed The requested playback speed
551 * @remarks Optional, and only used if addon has its own demuxer.
552 */
553 virtual void DemuxSetSpeed(int speed) {}
554
555 /*!
556 * Sets desired width / height
557 * @param width / hight
558 */
559 virtual void SetVideoResolution(int width, int height) {}
560
561 /*!
562 * Totel time in ms
563 * @remarks
564 */
565 virtual int GetTotalTime() { return -1; }
566
567 /*!
568 * Playing time in ms
569 * @remarks
570 */
571 virtual int GetTime() { return -1; }
572
573 /*!
574 * Get current timing values in PTS scale
575 * @remarks
576 */
577 virtual bool GetTimes(INPUTSTREAM_TIMES& times) { return false; }
578
579 /*!
580 * Positions inputstream to playing time given in ms
581 * @remarks
582 */
583 virtual bool PosTime(int ms) { return false; }
584
585 /*!
586 * Return currently selected chapter
587 * @remarks
588 */
589 virtual int GetChapter() { return -1; };
590
591 /*!
592 * Return number of available chapters
593 * @remarks
594 */
595 virtual int GetChapterCount() { return 0; };
596
597 /*!
598 * Return name of chapter # ch
599 * @remarks
600 */
601 virtual const char* GetChapterName(int ch) { return nullptr; };
602
603 /*!
604 * Return position if chapter # ch in milliseconds
605 * @remarks
606 */
607 virtual int64_t GetChapterPos(int ch) { return 0; };
608
609 /*!
610 * Seek to the beginning of chapter # ch
611 * @remarks
612 */
613 virtual bool SeekChapter(int ch) { return false; };
614
615 /*!
616 * Read from an open stream.
617 * @param buffer The buffer to store the data in.
618 * @param bufferSize The amount of bytes to read.
619 * @return The amount of bytes that were actually read from the stream.
620 * @remarks Return -1 if this add-on won't provide this function.
621 */
622 virtual int ReadStream(uint8_t* buffer, unsigned int bufferSize) { return -1; }
623
624 /*!
625 * Seek in a stream.
626 * @param position The position to seek to.
627 * @param whence ?
628 * @return The new position.
629 * @remarks Return -1 if this add-on won't provide this function.
630 */
631 virtual int64_t SeekStream(int64_t position, int whence = SEEK_SET) { return -1; }
632
633 /*!
634 * @return The position in the stream that's currently being read.
635 * @remarks Return -1 if this add-on won't provide this function.
636 */
637 virtual int64_t PositionStream() { return -1; }
638
639 /*!
640 * @return The total length of the stream that's currently being read.
641 * @remarks Return -1 if this add-on won't provide this function.
642 */
643 virtual int64_t LengthStream() { return -1; }
644
645 /*!
646 * @return Obtain the chunk size to use when reading streams.
647 * @remarks Return 0 if this add-on won't provide this function.
648 */
649 virtual int GetBlockSize() { return 0; }
650
651 /*!
652 * Check for real-time streaming
653 * @return true if current stream is real-time
654 */
655 virtual bool IsRealTimeStream() { return true; }
656
657 /*!
658 * @brief Allocate a demux packet. Free with FreeDemuxPacket
659 * @param dataSize The size of the data that will go into the packet
660 * @return The allocated packet
661 */
662 DemuxPacket* AllocateDemuxPacket(int dataSize)
663 {
664 return m_instanceData->toKodi->allocate_demux_packet(m_instanceData->toKodi->kodiInstance,
665 dataSize);
666 }
667
668 /*!
669 * @brief Allocate a demux packet. Free with FreeDemuxPacket
670 * @param dataSize The size of the data that will go into the packet
671 * @return The allocated packet
672 */
673 DemuxPacket* AllocateEncryptedDemuxPacket(int dataSize, unsigned int encryptedSubsampleCount)
674 {
675 return m_instanceData->toKodi->allocate_encrypted_demux_packet(
676 m_instanceData->toKodi->kodiInstance, dataSize, encryptedSubsampleCount);
677 }
678
679 /*!
680 * @brief Free a packet that was allocated with AllocateDemuxPacket
681 * @param packet The packet to free
682 */
683 void FreeDemuxPacket(DemuxPacket* packet)
684 {
685 return m_instanceData->toKodi->free_demux_packet(m_instanceData->toKodi->kodiInstance, packet);
686 }
687
688private:
689 static int compareVersion(const int v1[3], const int v2[3])
690 {
691 for (unsigned i(0); i < 3; ++i)
692 if (v1[i] != v2[i])
693 return v1[i] - v2[i];
694 return 0;
695 }
696
697 void SetAddonStruct(KODI_HANDLE instance, const std::string& kodiVersion)
698 {
699 if (instance == nullptr)
700 throw std::logic_error("kodi::addon::CInstanceInputStream: Creation with empty addon "
701 "structure not allowed, table must be given from Kodi!");
702 int api[3] = { 0, 0, 0 };
703 sscanf(kodiVersion.c_str(), "%d.%d.%d", &api[0], &api[1], &api[2]);
704
705 m_instanceData = static_cast<AddonInstance_InputStream*>(instance);
706 m_instanceData->toAddon->addonInstance = this;
707 m_instanceData->toAddon->open = ADDON_Open;
708 m_instanceData->toAddon->close = ADDON_Close;
709 m_instanceData->toAddon->get_capabilities = ADDON_GetCapabilities;
710
711 m_instanceData->toAddon->get_stream_ids = ADDON_GetStreamIds;
712 m_instanceData->toAddon->get_stream = ADDON_GetStream;
713 m_instanceData->toAddon->enable_stream = ADDON_EnableStream;
714 m_instanceData->toAddon->open_stream = ADDON_OpenStream;
715 m_instanceData->toAddon->demux_reset = ADDON_DemuxReset;
716 m_instanceData->toAddon->demux_abort = ADDON_DemuxAbort;
717 m_instanceData->toAddon->demux_flush = ADDON_DemuxFlush;
718 m_instanceData->toAddon->demux_read = ADDON_DemuxRead;
719 m_instanceData->toAddon->demux_seek_time = ADDON_DemuxSeekTime;
720 m_instanceData->toAddon->demux_set_speed = ADDON_DemuxSetSpeed;
721 m_instanceData->toAddon->set_video_resolution = ADDON_SetVideoResolution;
722
723 m_instanceData->toAddon->get_total_time = ADDON_GetTotalTime;
724 m_instanceData->toAddon->get_time = ADDON_GetTime;
725
726 m_instanceData->toAddon->get_times = ADDON_GetTimes;
727 m_instanceData->toAddon->pos_time = ADDON_PosTime;
728
729 m_instanceData->toAddon->read_stream = ADDON_ReadStream;
730 m_instanceData->toAddon->seek_stream = ADDON_SeekStream;
731 m_instanceData->toAddon->position_stream = ADDON_PositionStream;
732 m_instanceData->toAddon->length_stream = ADDON_LengthStream;
733 m_instanceData->toAddon->is_real_time_stream = ADDON_IsRealTimeStream;
734
735 // Added on 2.0.10
736 m_instanceData->toAddon->get_chapter = ADDON_GetChapter;
737 m_instanceData->toAddon->get_chapter_count = ADDON_GetChapterCount;
738 m_instanceData->toAddon->get_chapter_name = ADDON_GetChapterName;
739 m_instanceData->toAddon->get_chapter_pos = ADDON_GetChapterPos;
740 m_instanceData->toAddon->seek_chapter = ADDON_SeekChapter;
741
742 // Added on 2.0.12
743 m_instanceData->toAddon->block_size_stream = ADDON_GetBlockSize;
744
745 /*
746 // Way to include part on new API version
747 int minPartVersion[3] = { 3, 0, 0 };
748 if (compareVersion(api, minPartVersion) >= 0)
749 {
750
751 }
752 */
753 }
754
755 inline static bool ADDON_Open(const AddonInstance_InputStream* instance, INPUTSTREAM* props)
756 {
757 return static_cast<CInstanceInputStream*>(instance->toAddon->addonInstance)->Open(*props);
758 }
759
760 inline static void ADDON_Close(const AddonInstance_InputStream* instance)
761 {
762 static_cast<CInstanceInputStream*>(instance->toAddon->addonInstance)->Close();
763 }
764
765 inline static void ADDON_GetCapabilities(const AddonInstance_InputStream* instance,
766 INPUTSTREAM_CAPABILITIES* capabilities)
767 {
768 static_cast<CInstanceInputStream*>(instance->toAddon->addonInstance)
769 ->GetCapabilities(*capabilities);
770 }
771
772
773 // IDemux
774 inline static struct INPUTSTREAM_IDS ADDON_GetStreamIds(const AddonInstance_InputStream* instance)
775 {
776 return static_cast<CInstanceInputStream*>(instance->toAddon->addonInstance)->GetStreamIds();
777 }
778
779 inline static struct INPUTSTREAM_INFO ADDON_GetStream(const AddonInstance_InputStream* instance,
780 int streamid)
781 {
782 return static_cast<CInstanceInputStream*>(instance->toAddon->addonInstance)
783 ->GetStream(streamid);
784 }
785
786 inline static void ADDON_EnableStream(const AddonInstance_InputStream* instance,
787 int streamid,
788 bool enable)
789 {
790 static_cast<CInstanceInputStream*>(instance->toAddon->addonInstance)
791 ->EnableStream(streamid, enable);
792 }
793
794 inline static bool ADDON_OpenStream(const AddonInstance_InputStream* instance, int streamid)
795 {
796 return static_cast<CInstanceInputStream*>(instance->toAddon->addonInstance)
797 ->OpenStream(streamid);
798 }
799
800 inline static void ADDON_DemuxReset(const AddonInstance_InputStream* instance)
801 {
802 static_cast<CInstanceInputStream*>(instance->toAddon->addonInstance)->DemuxReset();
803 }
804
805 inline static void ADDON_DemuxAbort(const AddonInstance_InputStream* instance)
806 {
807 static_cast<CInstanceInputStream*>(instance->toAddon->addonInstance)->DemuxAbort();
808 }
809
810 inline static void ADDON_DemuxFlush(const AddonInstance_InputStream* instance)
811 {
812 static_cast<CInstanceInputStream*>(instance->toAddon->addonInstance)->DemuxFlush();
813 }
814
815 inline static DemuxPacket* ADDON_DemuxRead(const AddonInstance_InputStream* instance)
816 {
817 return static_cast<CInstanceInputStream*>(instance->toAddon->addonInstance)->DemuxRead();
818 }
819
820 inline static bool ADDON_DemuxSeekTime(const AddonInstance_InputStream* instance,
821 double time,
822 bool backwards,
823 double* startpts)
824 {
825 return static_cast<CInstanceInputStream*>(instance->toAddon->addonInstance)
826 ->DemuxSeekTime(time, backwards, *startpts);
827 }
828
829 inline static void ADDON_DemuxSetSpeed(const AddonInstance_InputStream* instance, int speed)
830 {
831 static_cast<CInstanceInputStream*>(instance->toAddon->addonInstance)->DemuxSetSpeed(speed);
832 }
833
834 inline static void ADDON_SetVideoResolution(const AddonInstance_InputStream* instance,
835 int width,
836 int height)
837 {
838 static_cast<CInstanceInputStream*>(instance->toAddon->addonInstance)
839 ->SetVideoResolution(width, height);
840 }
841
842
843 // IDisplayTime
844 inline static int ADDON_GetTotalTime(const AddonInstance_InputStream* instance)
845 {
846 return static_cast<CInstanceInputStream*>(instance->toAddon->addonInstance)->GetTotalTime();
847 }
848
849 inline static int ADDON_GetTime(const AddonInstance_InputStream* instance)
850 {
851 return static_cast<CInstanceInputStream*>(instance->toAddon->addonInstance)->GetTime();
852 }
853
854 // ITime
855 inline static bool ADDON_GetTimes(const AddonInstance_InputStream* instance,
856 INPUTSTREAM_TIMES* times)
857 {
858 return static_cast<CInstanceInputStream*>(instance->toAddon->addonInstance)->GetTimes(*times);
859 }
860
861 // IPosTime
862 inline static bool ADDON_PosTime(const AddonInstance_InputStream* instance, int ms)
863 {
864 return static_cast<CInstanceInputStream*>(instance->toAddon->addonInstance)->PosTime(ms);
865 }
866
867 inline static int ADDON_GetChapter(const AddonInstance_InputStream* instance)
868 {
869 return static_cast<CInstanceInputStream*>(instance->toAddon->addonInstance)->GetChapter();
870 }
871
872 inline static int ADDON_GetChapterCount(const AddonInstance_InputStream* instance)
873 {
874 return static_cast<CInstanceInputStream*>(instance->toAddon->addonInstance)->GetChapterCount();
875 }
876
877 inline static const char* ADDON_GetChapterName(const AddonInstance_InputStream* instance, int ch)
878 {
879 return static_cast<CInstanceInputStream*>(instance->toAddon->addonInstance)->GetChapterName(ch);
880 }
881
882 inline static int64_t ADDON_GetChapterPos(const AddonInstance_InputStream* instance, int ch)
883 {
884 return static_cast<CInstanceInputStream*>(instance->toAddon->addonInstance)->GetChapterPos(ch);
885 }
886
887 inline static bool ADDON_SeekChapter(const AddonInstance_InputStream* instance, int ch)
888 {
889 return static_cast<CInstanceInputStream*>(instance->toAddon->addonInstance)->SeekChapter(ch);
890 }
891
892 inline static int ADDON_ReadStream(const AddonInstance_InputStream* instance,
893 uint8_t* buffer,
894 unsigned int bufferSize)
895 {
896 return static_cast<CInstanceInputStream*>(instance->toAddon->addonInstance)
897 ->ReadStream(buffer, bufferSize);
898 }
899
900 inline static int64_t ADDON_SeekStream(const AddonInstance_InputStream* instance,
901 int64_t position,
902 int whence)
903 {
904 return static_cast<CInstanceInputStream*>(instance->toAddon->addonInstance)
905 ->SeekStream(position, whence);
906 }
907
908 inline static int64_t ADDON_PositionStream(const AddonInstance_InputStream* instance)
909 {
910 return static_cast<CInstanceInputStream*>(instance->toAddon->addonInstance)->PositionStream();
911 }
912
913 inline static int64_t ADDON_LengthStream(const AddonInstance_InputStream* instance)
914 {
915 return static_cast<CInstanceInputStream*>(instance->toAddon->addonInstance)->LengthStream();
916 }
917
918 inline static int ADDON_GetBlockSize(const AddonInstance_InputStream* instance)
919 {
920 return static_cast<CInstanceInputStream*>(instance->toAddon->addonInstance)->GetBlockSize();
921 }
922
923 inline static bool ADDON_IsRealTimeStream(const AddonInstance_InputStream* instance)
924 {
925 return static_cast<CInstanceInputStream*>(instance->toAddon->addonInstance)->IsRealTimeStream();
926 }
927
928 AddonInstance_InputStream* m_instanceData;
929};
930
931} /* namespace addon */
932} /* namespace kodi */
933
934#endif /* __cplusplus */
diff --git a/xbmc/addons/kodi-dev-kit/include/kodi/addon-instance/PVR.h b/xbmc/addons/kodi-dev-kit/include/kodi/addon-instance/PVR.h
new file mode 100644
index 0000000..d5977a7
--- /dev/null
+++ b/xbmc/addons/kodi-dev-kit/include/kodi/addon-instance/PVR.h
@@ -0,0 +1,3423 @@
1/*
2 * Copyright (C) 2005-2018 Team Kodi
3 * This file is part of Kodi - https://kodi.tv
4 *
5 * SPDX-License-Identifier: GPL-2.0-or-later
6 * See LICENSES/README.md for more information.
7 */
8
9#pragma once
10
11#include "../c-api/addon-instance/pvr.h"
12#include "pvr/ChannelGroups.h"
13#include "pvr/Channels.h"
14#include "pvr/EDL.h"
15#include "pvr/EPG.h"
16#include "pvr/General.h"
17#include "pvr/MenuHook.h"
18#include "pvr/Recordings.h"
19#include "pvr/Stream.h"
20#include "pvr/Timers.h"
21
22#ifdef __cplusplus
23
24/*!
25 * @internal
26 * @brief PVR "C++" API interface
27 *
28 * In this field are the pure addon-side C++ data.
29 *
30 * @note Changes can be made without problems and have no influence on other
31 * PVR addons that have already been created.\n
32 * \n
33 * Therefore, @ref ADDON_INSTANCE_VERSION_PVR_MIN can be ignored for these
34 * fields and only the @ref ADDON_INSTANCE_VERSION_PVR needs to be increased.\n
35 * \n
36 * Only must be min version increased if a new compile of addon breaks after
37 * changes here.
38 *
39 * Have by add of new parts a look about **Doxygen** `\\ingroup`, so that
40 * added parts included in documentation.
41 *
42 * If you add addon side related documentation, where his dev need know, use `///`.
43 * For parts only for Kodi make it like here.
44 *
45 * @endinternal
46 */
47
48namespace kodi
49{
50namespace addon
51{
52
53//¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯
54// "C++" Doxygen group set for the definitions
55//{{{
56
57//==============================================================================
58/// @defgroup cpp_kodi_addon_pvr_Defs Definitions, structures and enumerators
59/// @ingroup cpp_kodi_addon_pvr
60/// @brief **PVR client add-on instance definition values**\n
61/// All PVR functions associated data structures.
62///
63/// Used to exchange the available options between Kodi and addon.\n
64/// The groups described here correspond to the groups of functions on PVR
65/// instance class.
66///
67
68//##############################################################################
69/// @defgroup cpp_kodi_addon_pvr_Defs_General 1. General
70/// @ingroup cpp_kodi_addon_pvr_Defs
71/// @brief **PVR add-on general variables**\n
72/// Used to exchange the available options between Kodi and addon.
73///
74/// This group also includes @ref cpp_kodi_addon_pvr_Defs_PVRCapabilities with
75/// which Kodi an @ref kodi::addon::CInstancePVRClient::GetCapabilities()
76/// queries the supported **modules** of the addon.
77///
78/// The standard values are also below, once for error messages and once to
79/// @ref kodi::addon::CInstancePVRClient::ConnectionStateChange() to give Kodi
80/// any information.
81///
82///@{
83//##############################################################################
84/// @defgroup cpp_kodi_addon_pvr_Defs_General_Inputstream class PVRStreamProperty & definition PVR_STREAM_PROPERTY
85/// @ingroup cpp_kodi_addon_pvr_Defs_General
86/// @brief **Inputstream variables**\n
87/// This includes values related to the outside of PVR available inputstream
88/// system.
89///
90/// This can be by separate instance on same addon, by handling in Kodi itself
91/// or to reference of another addon where support needed inputstream.
92///
93/// @note This is complete independent from own system included here
94/// @ref cpp_kodi_addon_pvr_Streams "inputstream".
95///
96//------------------------------------------------------------------------------
97///@}
98
99//##############################################################################
100/// @defgroup cpp_kodi_addon_pvr_Defs_Channel 2. Channel
101/// @ingroup cpp_kodi_addon_pvr_Defs
102/// @brief **PVR add-on channel**\n
103/// Used to exchange the available channel options between Kodi and addon.
104///
105/// Modules here are mainly intended for @ref cpp_kodi_addon_pvr_Channels "channels",
106/// but are also used on other modules to identify the respective TV/radio
107/// channel.
108///
109/// Because of @ref cpp_kodi_addon_pvr_Defs_Channel_PVRSignalStatus and
110/// @ref cpp_kodi_addon_pvr_Defs_Channel_PVRDescrambleInfo is a special case at
111/// this point. This is currently only used on running streams, but it may be
112/// possible that this must always be usable in connection with PiP in the
113/// future.
114///
115//------------------------------------------------------------------------------
116
117//##############################################################################
118/// @defgroup cpp_kodi_addon_pvr_Defs_ChannelGroup 3. Channel Group
119/// @ingroup cpp_kodi_addon_pvr_Defs
120/// @brief **PVR add-on channel group**\n
121/// This group contains data classes and values which are used in PVR on
122/// @ref cpp_kodi_addon_pvr_supportsChannelGroups "channel groups".
123///
124//------------------------------------------------------------------------------
125
126//##############################################################################
127/// @defgroup cpp_kodi_addon_pvr_Defs_epg 4. EPG Tag
128/// @ingroup cpp_kodi_addon_pvr_Defs
129/// @brief **PVR add-on EPG data**\n
130/// Used on @ref cpp_kodi_addon_pvr_EPGTag "EPG methods in PVR instance class".
131///
132/// See related modules about, also below in this view are few macros where
133/// default values of associated places.
134///
135//------------------------------------------------------------------------------
136
137//##############################################################################
138/// @defgroup cpp_kodi_addon_pvr_Defs_Recording 5. Recording
139/// @ingroup cpp_kodi_addon_pvr_Defs
140/// @brief **Representation of a recording**\n
141/// Used to exchange the available recording data between Kodi and addon on
142/// @ref cpp_kodi_addon_pvr_Recordings "Recordings methods in PVR instance class".
143///
144//------------------------------------------------------------------------------
145
146//##############################################################################
147/// @defgroup cpp_kodi_addon_pvr_Defs_Timer 6. Timer
148/// @ingroup cpp_kodi_addon_pvr_Defs
149/// @brief **PVR add-on timer data**\n
150/// Used to exchange the available timer data between Kodi and addon on
151/// @ref cpp_kodi_addon_pvr_Timers "Timers methods in PVR instance class".
152///
153//------------------------------------------------------------------------------
154
155//##############################################################################
156/// @defgroup cpp_kodi_addon_pvr_Defs_Menuhook 7. Menuhook
157/// @ingroup cpp_kodi_addon_pvr_Defs
158/// @brief **PVR Context menu data**\n
159/// Define data for the context menus available to the user
160///
161//------------------------------------------------------------------------------
162
163//##############################################################################
164/// @defgroup cpp_kodi_addon_pvr_Defs_EDLEntry 8. Edit decision list (EDL)
165/// @ingroup cpp_kodi_addon_pvr_Defs
166/// @brief **An edit decision list or EDL is used in the post-production process
167/// of film editing and video editing**\n
168/// Used on @ref kodi::addon::CInstancePVRClient::GetEPGTagEdl and
169/// @ref kodi::addon::CInstancePVRClient::GetRecordingEdl
170///
171//------------------------------------------------------------------------------
172
173//##############################################################################
174/// @defgroup cpp_kodi_addon_pvr_Defs_Stream 9. Inputstream
175/// @ingroup cpp_kodi_addon_pvr_Defs
176/// @brief **Inputstream**\n
177/// This includes classes and values that are used in the PVR inputstream.
178///
179/// Used on @ref cpp_kodi_addon_pvr_Streams "Inputstream methods in PVR instance class".
180///
181/// @note The parts here will be removed in the future and replaced by the
182/// separate @ref cpp_kodi_addon_inputstream "inputstream addon instance".
183/// If there is already a possibility, new addons should do it via the
184/// inputstream instance.
185///
186//------------------------------------------------------------------------------
187
188//}}}
189//______________________________________________________________________________
190
191//¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯
192// "C++" PVR addon instance class
193//{{{
194
195//==============================================================================
196/// @addtogroup cpp_kodi_addon_pvr
197/// @brief \cpp_class{ kodi::addon::CInstancePVRClient }
198/// **PVR client add-on instance**
199///
200/// Kodi features powerful [Live TV](https://kodi.wiki/view/Live_TV) and
201/// [video recording (DVR/PVR)](http://en.wikipedia.org/wiki/Digital_video_recorder)
202/// abilities using a very flexible distributed application structure. That is, by
203/// leveraging other existing third-party
204/// [PVR backend applications](https://kodi.wiki/view/PVR_backend) or
205/// [DVR devices](https://kodi.wiki/view/PVR_backend)
206/// that specialize in receiving television signals and also support the same type
207/// of [client–server model](http://en.wikipedia.org/wiki/client%E2%80%93server_model)
208/// which Kodi uses, (following a [frontend-backend](http://en.wikipedia.org/wiki/Front_and_back_ends)
209/// design principle for [separation of concerns](http://en.wikipedia.org/wiki/Separation_of_concerns)),
210/// these PVR features in Kodi allow you to watch Live TV, listen to radio, view an EPG TV-Guide
211/// and schedule recordings, and also enables many other TV related features, all using
212/// Kodi as your primary interface once the initial pairing connection and
213/// configuration have been done.
214///
215/// @note It is very important to understand that with "Live TV" in the reference
216/// to PVR in Kodi, we do not mean [streaming video](http://en.wikipedia.org/wiki/Streaming_media)
217/// from the internet via websites providing [free content](https://kodi.wiki/view/Free_content)
218/// or online services such as Netflix, Hulu, Vudu and similar, no matter if that
219/// content is actually streamed live or not. If that is what you are looking for
220/// then you might want to look into [Video Addons](https://kodi.wiki/view/Add-ons)
221/// for Kodi instead, (which again is not the same as the "PVR" or "Live TV" we
222/// discuss in this article), but remember that [Kodi does not provide any video
223/// content or video streaming services](https://kodi.wiki/view/Free_content).
224///
225/// The use of the PVR is based on the @ref CInstancePVRClient.
226///
227/// Include the header @ref PVR.h "#include <kodi/addon-instance/PVR.h>"
228/// to use this class.
229///
230///
231/// ----------------------------------------------------------------------------
232///
233/// Here is an example of what the <b>`addon.xml.in`</b> would look like for an PVR addon:
234///
235/// ~~~~~~~~~~~~~{.xml}
236/// <?xml version="1.0" encoding="UTF-8"?>
237/// <addon
238/// id="pvr.myspecialnamefor"
239/// version="1.0.0"
240/// name="My special PVR addon"
241/// provider-name="Your Name">
242/// <requires>@ADDON_DEPENDS@</requires>
243/// <extension
244/// point="kodi.pvrclient"
245/// library_@PLATFORM@="@LIBRARY_FILENAME@"/>
246/// <extension point="xbmc.addon.metadata">
247/// <summary lang="en_GB">My PVR addon addon</summary>
248/// <description lang="en_GB">My PVR addon description</description>
249/// <platform>@PLATFORM@</platform>
250/// </extension>
251/// </addon>
252/// ~~~~~~~~~~~~~
253///
254///
255/// At <b>`<extension point="kodi.pvrclient" ...>`</b> the basic instance definition is declared, this is intended to identify the addon as an PVR and to see its supported types:
256/// | Name | Description
257/// |------|----------------------
258/// | <b>`point`</b> | The identification of the addon instance to inputstream is mandatory <b>`kodi.pvrclient`</b>. In addition, the instance declared in the first <b>`<extension ... />`</b> is also the main type of addon.
259/// | <b>`library_@PLATFORM@`</b> | The runtime library used for the addon. This is usually declared by cmake and correctly displayed in the translated `addon.xml`.
260///
261///
262/// @remark For more detailed description of the <b>`addon.xml`</b>, see also https://kodi.wiki/view/Addon.xml.
263///
264///
265/// --------------------------------------------------------------------------
266///
267/// **Example:**
268///
269/// ~~~~~~~~~~~~~{.cpp}
270/// #include <kodi/addon-instance/PVR.h>
271///
272/// class CMyPVRClient : public ::kodi::addon::CInstancePVRClient
273/// {
274/// public:
275/// CMyPVRClient(KODI_HANDLE instance, const std::string& kodiVersion);
276///
277/// PVR_ERROR GetCapabilities(kodi::addon::PVRCapabilities& capabilities) override;
278/// PVR_ERROR GetBackendName(std::string& name) override;
279/// PVR_ERROR GetBackendVersion(std::string& version) override;
280///
281/// PVR_ERROR GetChannelsAmount(int& amount) override;
282/// PVR_ERROR GetChannels(bool radio, std::vector<kodi::addon::PVRChannel>& channels) override;
283/// PVR_ERROR GetChannelStreamProperties(const kodi::addon::PVRChannel& channel,
284/// std::vector<kodi::addon::PVRStreamProperty>& properties) override;
285///
286/// private:
287/// std::vector<kodi::addon::PVRChannel> m_myChannels;
288/// };
289///
290/// CMyPVRClient::CMyPVRClient(KODI_HANDLE instance, const std::string& kodiVersion)
291/// : CInstancePVRClient(instance, kodiVersion)
292/// {
293/// kodi::addon::PVRChannel channel;
294/// channel.SetUniqueId(123);
295/// channel.SetChannelNumber(1);
296/// channel.SetChannelName("My test channel");
297/// m_myChannels.push_back(channel);
298/// }
299///
300/// PVR_ERROR CMyPVRClient::GetCapabilities(kodi::addon::PVRCapabilities& capabilities)
301/// {
302/// capabilities.SetSupportsTV(true);
303/// return PVR_ERROR_NO_ERROR;
304/// }
305///
306/// PVR_ERROR CMyPVRClient::GetBackendName(std::string& name)
307/// {
308/// name = "My special PVR client";
309/// return PVR_ERROR_NO_ERROR;
310/// }
311///
312/// PVR_ERROR CMyPVRClient::GetBackendVersion(std::string& version)
313/// {
314/// version = "1.0.0";
315/// return PVR_ERROR_NO_ERROR;
316/// }
317///
318/// PVR_ERROR CMyInstance::GetChannelsAmount(int& amount)
319/// {
320/// amount = m_myChannels.size();
321/// return PVR_ERROR_NO_ERROR;
322/// }
323///
324/// PVR_ERROR CMyPVRClient::GetChannels(bool radio, std::vector<kodi::addon::PVRChannel>& channels)
325/// {
326/// channels = m_myChannels;
327/// return PVR_ERROR_NO_ERROR;
328/// }
329///
330/// PVR_ERROR CMyPVRClient::GetChannelStreamProperties(const kodi::addon::PVRChannel& channel,
331/// std::vector<kodi::addon::PVRStreamProperty>& properties)
332/// {
333/// if (channel.GetUniqueId() == 123)
334/// {
335/// properties.push_back(PVR_STREAM_PROPERTY_STREAMURL, "http://distribution.bbb3d.renderfarming.net/video/mp4/bbb_sunflower_1080p_30fps_normal.mp4");
336/// properties.push_back(PVR_STREAM_PROPERTY_ISREALTIMESTREAM, "true");
337/// return PVR_ERROR_NO_ERROR;
338/// }
339/// return PVR_ERROR_UNKNOWN;
340/// }
341///
342/// ...
343///
344/// //----------------------------------------------------------------------
345///
346/// class CMyAddon : public ::kodi::addon::CAddonBase
347/// {
348/// public:
349/// CMyAddon() = default;
350/// ADDON_STATUS CreateInstance(int instanceType,
351/// const std::string& instanceID,
352/// KODI_HANDLE instance,
353/// const std::string& version,
354/// KODI_HANDLE& addonInstance) override;
355/// };
356///
357/// // If you use only one instance in your add-on, can be instanceType and
358/// // instanceID ignored
359/// ADDON_STATUS CMyAddon::CreateInstance(int instanceType,
360/// const std::string& instanceID,
361/// KODI_HANDLE instance,
362/// const std::string& version,
363/// KODI_HANDLE& addonInstance)
364/// {
365/// if (instanceType == ADDON_INSTANCE_PVR)
366/// {
367/// kodi::Log(ADDON_LOG_INFO, "Creating my PVR client instance");
368/// addonInstance = new CMyPVRClient(instance, version);
369/// return ADDON_STATUS_OK;
370/// }
371/// else if (...)
372/// {
373/// ...
374/// }
375/// return ADDON_STATUS_UNKNOWN;
376/// }
377///
378/// ADDONCREATOR(CMyAddon)
379/// ~~~~~~~~~~~~~
380///
381/// The destruction of the example class `CMyPVRClient` is called from
382/// Kodi's header. Manually deleting the add-on instance is not required.
383///
384class ATTRIBUTE_HIDDEN CInstancePVRClient : public IAddonInstance
385{
386public:
387 //============================================================================
388 /// @defgroup cpp_kodi_addon_pvr_Base 1. Basic functions
389 /// @ingroup cpp_kodi_addon_pvr
390 /// @brief **Functions to manage the addon and get basic information about it**\n
391 /// These are e.g. @ref GetCapabilities to know supported groups at
392 /// this addon or the others to get information about the source of the PVR
393 /// stream.
394 ///
395 /// The with "Valid implementation required." declared functions are mandatory,
396 /// all others are an option.
397 ///
398 ///
399 ///---------------------------------------------------------------------------
400 ///
401 /// **Basic parts in interface:**\n
402 /// Copy this to your project and extend with your parts or leave functions
403 /// complete away where not used or supported.
404 ///
405 /// @copydetails cpp_kodi_addon_pvr_Base_header_addon_auto_check
406 /// @copydetails cpp_kodi_addon_pvr_Base_source_addon_auto_check
407 ///
408 ///@{
409
410 //============================================================================
411 /// @brief PVR client class constructor.
412 ///
413 /// Used by an add-on that only supports only PVR and only in one instance.
414 ///
415 ///
416 /// --------------------------------------------------------------------------
417 ///
418 /// **Here's example about the use of this:**
419 /// ~~~~~~~~~~~~~{.cpp}
420 /// #include <kodi/addon-instance/PVR.h>
421 /// ...
422 ///
423 /// class ATTRIBUTE_HIDDEN CPVRExample
424 /// : public kodi::addon::CAddonBase,
425 /// public kodi::addon::CInstancePVRClient
426 /// {
427 /// public:
428 /// CPVRExample()
429 /// {
430 /// }
431 ///
432 /// ~CPVRExample() override;
433 /// {
434 /// }
435 ///
436 /// ...
437 /// };
438 ///
439 /// ADDONCREATOR(CPVRExample)
440 /// ~~~~~~~~~~~~~
441 ///
442 CInstancePVRClient() : IAddonInstance(ADDON_INSTANCE_PVR, GetKodiTypeVersion(ADDON_INSTANCE_PVR))
443 {
444 if (CAddonBase::m_interface->globalSingleInstance != nullptr)
445 throw std::logic_error("kodi::addon::CInstancePVRClient: Creation of more as one in single "
446 "instance way is not allowed!");
447
448 SetAddonStruct(CAddonBase::m_interface->firstKodiInstance, m_kodiVersion);
449 CAddonBase::m_interface->globalSingleInstance = this;
450 }
451 //----------------------------------------------------------------------------
452
453 //============================================================================
454 /// @brief PVR client class constructor used to support multiple instance
455 /// types.
456 ///
457 /// @param[in] instance The instance value given to
458 /// <b>`kodi::addon::CAddonBase::CreateInstance(...)`</b>.
459 /// @param[in] kodiVersion [opt] Version used in Kodi for this instance, to
460 /// allow compatibility to older Kodi versions.
461 ///
462 /// @note Recommended to set <b>`kodiVersion`</b>.
463 ///
464 ///
465 /// --------------------------------------------------------------------------
466 ///
467 /// **Here's example about the use of this:**
468 /// ~~~~~~~~~~~~~{.cpp}
469 /// class CMyPVRClient : public ::kodi::addon::CInstancePVRClient
470 /// {
471 /// public:
472 /// CMyPVRClient(KODI_HANDLE instance, const std::string& kodiVersion)
473 /// : CInstancePVRClient(instance, kodiVersion)
474 /// {
475 /// ...
476 /// }
477 ///
478 /// ...
479 /// };
480 ///
481 /// ADDON_STATUS CMyAddon::CreateInstance(int instanceType,
482 /// const std::string& instanceID,
483 /// KODI_HANDLE instance,
484 /// const std::string& version,
485 /// KODI_HANDLE& addonInstance)
486 /// {
487 /// kodi::Log(ADDON_LOG_INFO, "Creating my PVR client instance");
488 /// addonInstance = new CMyPVRClient(instance, version);
489 /// return ADDON_STATUS_OK;
490 /// }
491 /// ~~~~~~~~~~~~~
492 ///
493 explicit CInstancePVRClient(KODI_HANDLE instance, const std::string& kodiVersion = "")
494 : IAddonInstance(ADDON_INSTANCE_PVR,
495 !kodiVersion.empty() ? kodiVersion : GetKodiTypeVersion(ADDON_INSTANCE_PVR))
496 {
497 if (CAddonBase::m_interface->globalSingleInstance != nullptr)
498 throw std::logic_error("kodi::addon::CInstancePVRClient: Creation of multiple together with "
499 "single instance way is not allowed!");
500
501 SetAddonStruct(instance, m_kodiVersion);
502 }
503 //----------------------------------------------------------------------------
504
505 //============================================================================
506 /// @brief Destructor
507 ///
508 ~CInstancePVRClient() override = default;
509 //----------------------------------------------------------------------------
510
511 //--==----==----==----==----==----==----==----==----==----==----==----==----==
512
513 //============================================================================
514 /// @brief Get the list of features that this add-on provides.
515 ///
516 /// Called by Kodi to query the add-on's capabilities.
517 /// Used to check which options should be presented in the UI, which methods to call, etc.
518 /// All capabilities that the add-on supports should be set to true.
519 ///
520 /// @param capabilities The with @ref cpp_kodi_addon_pvr_Defs_PVRCapabilities defined add-on's capabilities.
521 /// @return @ref PVR_ERROR_NO_ERROR if the properties were fetched successfully.
522 ///
523 /// --------------------------------------------------------------------------
524 ///
525 /// @copydetails cpp_kodi_addon_pvr_Defs_PVRCapabilities_Help
526 ///
527 ///
528 /// --------------------------------------------------------------------------
529 ///
530 /// **Example:**
531 /// ~~~~~~~~~~~~~{.cpp}
532 /// PVR_ERROR CMyPVRClient::GetCapabilities(kodi::addon::PVRCapabilities& capabilities)
533 /// {
534 /// capabilities.SetSupportsTV(true);
535 /// capabilities.SetSupportsEPG(true);
536 /// return PVR_ERROR_NO_ERROR;
537 /// }
538 /// ~~~~~~~~~~~~~
539 ///
540 /// --------------------------------------------------------------------------
541 ///
542 /// @note Valid implementation required.
543 ///
544 virtual PVR_ERROR GetCapabilities(kodi::addon::PVRCapabilities& capabilities) = 0;
545 //----------------------------------------------------------------------------
546
547 //============================================================================
548 /// @brief Get the name reported by the backend that will be displayed in the UI.
549 ///
550 /// @param[out] name The name reported by the backend that will be displayed in the UI.
551 /// @return @ref PVR_ERROR_NO_ERROR if successfully done
552 ///
553 ///
554 /// --------------------------------------------------------------------------
555 ///
556 /// **Example:**
557 /// ~~~~~~~~~~~~~{.cpp}
558 /// PVR_ERROR CMyPVRClient::GetBackendName(std::string& name)
559 /// {
560 /// name = "My special PVR client";
561 /// return PVR_ERROR_NO_ERROR;
562 /// }
563 /// ~~~~~~~~~~~~~
564 ///
565 /// --------------------------------------------------------------------------
566 ///
567 /// @note Valid implementation required.
568 ///
569 virtual PVR_ERROR GetBackendName(std::string& name) = 0;
570 //----------------------------------------------------------------------------
571
572 //============================================================================
573 /// @brief Get the version string reported by the backend that will be
574 /// displayed in the UI.
575 ///
576 /// @param[out] version The version string reported by the backend that will be
577 /// displayed in the UI.
578 /// @return @ref PVR_ERROR_NO_ERROR if successfully done
579 ///
580 ///
581 /// --------------------------------------------------------------------------
582 ///
583 /// **Example:**
584 /// ~~~~~~~~~~~~~{.cpp}
585 /// PVR_ERROR CMyPVRClient::GetBackendVersion(std::string& version)
586 /// {
587 /// version = "1.0.0";
588 /// return PVR_ERROR_NO_ERROR;
589 /// }
590 /// ~~~~~~~~~~~~~
591 ///
592 /// --------------------------------------------------------------------------
593 ///
594 /// @note Valid implementation required.
595 ///
596 virtual PVR_ERROR GetBackendVersion(std::string& version) = 0;
597 //----------------------------------------------------------------------------
598
599 //============================================================================
600 /// @brief Get the hostname of the pvr backend server
601 ///
602 /// @param[out] hostname Hostname as ip address or alias. If backend does not
603 /// utilize a server, return empty string.
604 /// @return @ref PVR_ERROR_NO_ERROR if successfully done
605 ///
606 virtual PVR_ERROR GetBackendHostname(std::string& hostname) { return PVR_ERROR_NOT_IMPLEMENTED; }
607 //----------------------------------------------------------------------------
608
609 //============================================================================
610 /// @brief To get the connection string reported by the backend that will be
611 /// displayed in the UI.
612 ///
613 /// @param[out] connection The connection string reported by the backend that
614 /// will be displayed in the UI.
615 /// @return @ref PVR_ERROR_NO_ERROR if successfully done
616 ///
617 virtual PVR_ERROR GetConnectionString(std::string& connection)
618 {
619 return PVR_ERROR_NOT_IMPLEMENTED;
620 }
621 //----------------------------------------------------------------------------
622
623 //============================================================================
624 /// @brief Get the disk space reported by the backend (if supported).
625 ///
626 /// @param[in] total The total disk space in KiB.
627 /// @param[in] used The used disk space in KiB.
628 /// @return @ref PVR_ERROR_NO_ERROR if the drive space has been fetched
629 /// successfully.
630 ///
631 ///
632 /// --------------------------------------------------------------------------
633 ///
634 /// **Example:**
635 /// ~~~~~~~~~~~~~{.cpp}
636 /// PVR_ERROR CMyPVRClient::GetDriveSpace(uint64_t& total, uint64_t& used)
637 /// {
638 /// total = 100 * 1024 * 1024; // To set complete size of drive in KiB (100GB)
639 /// used = 12232424; // To set the used amount
640 /// return PVR_ERROR_NO_ERROR;
641 /// }
642 /// ~~~~~~~~~~~~~
643 ///
644 virtual PVR_ERROR GetDriveSpace(uint64_t& total, uint64_t& used)
645 {
646 return PVR_ERROR_NOT_IMPLEMENTED;
647 }
648 //----------------------------------------------------------------------------
649
650 //============================================================================
651 /// @brief Call one of the settings related menu hooks (if supported).
652 ///
653 /// Supported @ref cpp_kodi_addon_pvr_Defs_Menuhook_PVRMenuhook "menu hook "
654 /// instances have to be added in `constructor()`, by calling @ref AddMenuHook()
655 /// on the callback.
656 ///
657 /// @param[in] menuhook The hook to call.
658 /// @return @ref PVR_ERROR_NO_ERROR if the hook was called successfully.
659 ///
660 /// --------------------------------------------------------------------------
661 ///
662 /// @copydetails cpp_kodi_addon_pvr_Defs_Menuhook_PVRMenuhook_Help
663 ///
664 ///
665 /// --------------------------------------------------------------------------
666 ///
667 /// **Example:**
668 /// ~~~~~~~~~~~~~{.cpp}
669 /// PVR_ERROR CMyPVRClient::CallSettingsMenuHook(const kodi::addon::PVRMenuhook& menuhook)
670 /// {
671 /// if (menuhook.GetHookId() == 2)
672 /// kodi::QueueNotification(QUEUE_INFO, "", kodi::GetLocalizedString(menuhook.GetLocalizedStringId()));
673 /// return PVR_ERROR_NO_ERROR;
674 /// }
675 /// ~~~~~~~~~~~~~
676 ///
677 virtual PVR_ERROR CallSettingsMenuHook(const kodi::addon::PVRMenuhook& menuhook)
678 {
679 return PVR_ERROR_NOT_IMPLEMENTED;
680 }
681 //----------------------------------------------------------------------------
682
683 //==========================================================================
684 /// @brief **Callback to Kodi Function**\nAdd or replace a menu hook for the context menu for this add-on
685 ///
686 /// This is a callback function, called from addon to give Kodi his context menu's.
687 ///
688 /// @param[in] menuhook The with @ref cpp_kodi_addon_pvr_Defs_Menuhook_PVRMenuhook defined hook to add
689 ///
690 /// @remarks Only called from addon itself
691 ///
692 /// --------------------------------------------------------------------------
693 ///
694 /// @copydetails cpp_kodi_addon_pvr_Defs_Menuhook_PVRMenuhook_Help
695 ///
696 ///
697 /// --------------------------------------------------------------------------
698 ///
699 /// **Here's an example of the use of it:**
700 /// ~~~~~~~~~~~~~{.cpp}
701 /// #include <kodi/addon-instance/PVR.h>
702 /// ...
703 ///
704 /// {
705 /// kodi::addon::PVRMenuhook hook;
706 /// hook.SetHookId(1);
707 /// hook.SetCategory(PVR_MENUHOOK_CHANNEL);
708 /// hook.SetLocalizedStringId(30000);
709 /// AddMenuHook(hook);
710 /// }
711 ///
712 /// {
713 /// kodi::addon::PVRMenuhook hook;
714 /// hook.SetHookId(2);
715 /// hook.SetCategory(PVR_MENUHOOK_SETTING);
716 /// hook.SetLocalizedStringId(30001);
717 /// AddMenuHook(hook);
718 /// }
719 /// ...
720 /// ~~~~~~~~~~~~~
721 ///
722 /// **Here another way:**
723 /// ~~~~~~~~~~~~~{.cpp}
724 /// #include <kodi/addon-instance/PVR.h>
725 /// ...
726 ///
727 /// AddMenuHook(kodi::addon::PVRMenuhook(1, 30000, PVR_MENUHOOK_CHANNEL));
728 /// AddMenuHook(kodi::addon::PVRMenuhook(2, 30001, PVR_MENUHOOK_SETTING));
729 /// ...
730 /// ~~~~~~~~~~~~~
731 ///
732 inline void AddMenuHook(const kodi::addon::PVRMenuhook& hook)
733 {
734 m_instanceData->toKodi->AddMenuHook(m_instanceData->toKodi->kodiInstance, hook);
735 }
736 //----------------------------------------------------------------------------
737
738 //==========================================================================
739 /// @brief **Callback to Kodi Function**\n
740 /// Notify a state change for a PVR backend connection.
741 ///
742 /// @param[in] connectionString The connection string reported by the backend
743 /// that can be displayed in the UI.
744 /// @param[in] newState The by @ref PVR_CONNECTION_STATE defined new state.
745 /// @param[in] message A localized addon-defined string representing the new
746 /// state, that can be displayed in the UI or **empty** if
747 /// the Kodi-defined default string for the new state
748 /// shall be displayed.
749 ///
750 /// @remarks Only called from addon itself
751 ///
752 ///
753 /// --------------------------------------------------------------------------
754 ///
755 ///
756 /// **Here's an example of the use of it:**
757 /// ~~~~~~~~~~~~~{.cpp}
758 /// #include <kodi/addon-instance/PVR.h>
759 /// #include <kodi/General.h> /* for kodi::GetLocalizedString(...) */
760 /// ...
761 ///
762 /// ConnectionStateChange("PVR demo connection lost", PVR_CONNECTION_STATE_DISCONNECTED, kodi::GetLocalizedString(30005, "Lost connection to Server"););
763 /// ...
764 /// ~~~~~~~~~~~~~
765 ///
766 inline void ConnectionStateChange(const std::string& connectionString,
767 PVR_CONNECTION_STATE newState,
768 const std::string& message)
769 {
770 m_instanceData->toKodi->ConnectionStateChange(
771 m_instanceData->toKodi->kodiInstance, connectionString.c_str(), newState, message.c_str());
772 }
773 //----------------------------------------------------------------------------
774
775 //==========================================================================
776 /// @brief **Callback to Kodi Function**\n
777 /// Get user data path of the PVR addon.
778 ///
779 /// @return Path of current Kodi user
780 ///
781 /// @remarks Only called from addon itself
782 ///
783 /// @note Alternatively, @ref kodi::GetAddonPath() can be used for this.
784 ///
785 inline std::string UserPath() const { return m_instanceData->props->strUserPath; }
786 //----------------------------------------------------------------------------
787
788 //==========================================================================
789 /// @brief **Callback to Kodi Function**\n
790 /// Get main client path of the PVR addon.
791 ///
792 /// @return Path of addon client
793 ///
794 /// @remarks Only called from addon itself.
795 ///
796 /// @note Alternatively, @ref kodi::GetBaseUserPath() can be used for this.
797 ///
798 inline std::string ClientPath() const { return m_instanceData->props->strClientPath; }
799 //----------------------------------------------------------------------------
800
801 ///@}
802 //--==----==----==----==----==----==----==----==----==----==----==----==----==
803
804 //============================================================================
805 /// @defgroup cpp_kodi_addon_pvr_Channels 2. Channels (required)
806 /// @ingroup cpp_kodi_addon_pvr
807 /// @brief **Functions to get available TV or Radio channels**\n
808 /// These are mandatory functions for using this addon to get the available
809 /// channels.
810 ///
811 /// @remarks Either @ref PVRCapabilities::SetSupportsTV "SetSupportsTV()" or
812 /// @ref PVRCapabilities::SetSupportsRadio "SetSupportsRadio()" is required to
813 /// be set to <b>`true`</b>.\n
814 /// If a channel changes after the initial import, or if a new one was added,
815 /// then the add-on should call @ref TriggerChannelUpdate().
816 ///
817 ///
818 ///---------------------------------------------------------------------------
819 ///
820 /// **Channel parts in interface:**\n
821 /// Copy this to your project and extend with your parts or leave functions
822 /// complete away where not used or supported.
823 ///
824 /// @copydetails cpp_kodi_addon_pvr_Channels_header_addon_auto_check
825 /// @copydetails cpp_kodi_addon_pvr_Channels_source_addon_auto_check
826 ///
827 ///@{
828
829 //============================================================================
830 /// @brief The total amount of channels on the backend
831 ///
832 /// @param[out] amount The total amount of channels on the backend
833 /// @return @ref PVR_ERROR_NO_ERROR if the amount has been fetched successfully.
834 ///
835 /// @remarks Valid implementation required.
836 ///
837 virtual PVR_ERROR GetChannelsAmount(int& amount) { return PVR_ERROR_NOT_IMPLEMENTED; }
838 //----------------------------------------------------------------------------
839
840 //============================================================================
841 /// @brief Request the list of all channels from the backend.
842 ///
843 /// @param[in] radio True to get the radio channels, false to get the TV channels.
844 /// @param[out] results The channels defined with @ref cpp_kodi_addon_pvr_Defs_Channel_PVRChannel
845 /// and available at the addon, them transferred with
846 /// @ref cpp_kodi_addon_pvr_Defs_Channel_PVRChannelsResultSet.
847 /// @return @ref PVR_ERROR_NO_ERROR if the list has been fetched successfully.
848 ///
849 /// --------------------------------------------------------------------------
850 ///
851 /// @copydetails cpp_kodi_addon_pvr_Defs_Channel_PVRChannel_Help
852 ///
853 ///
854 /// --------------------------------------------------------------------------
855 ///
856 /// @remarks
857 /// If @ref PVRCapabilities::SetSupportsTV() is set to
858 /// <b>`true`</b>, a valid result set needs to be provided for <b>`radio = false`</b>.\n
859 /// If @ref PVRCapabilities::SetSupportsRadio() is set to
860 /// <b>`true`</b>, a valid result set needs to be provided for <b>`radio = true`</b>.
861 /// At least one of these two must provide a valid result set.
862 ///
863 ///
864 ///---------------------------------------------------------------------------
865 ///
866 /// **Example:**
867 /// ~~~~~~~~~~~~~{.cpp}
868 /// ...
869 /// PVR_ERROR CMyPVRInstance::GetChannels(bool radio, kodi::addon::PVRChannelsResultSet& results)
870 /// {
871 /// // Minimal demo example, in reality bigger and loop to transfer all
872 /// kodi::addon::PVRChannel channel;
873 /// channel.SetUniqueId(123);
874 /// channel.SetIsRadio(false);
875 /// channel.SetChannelNumber(1);
876 /// channel.SetChannelName("My channel name");
877 /// ...
878 ///
879 /// // Give it now to Kodi
880 /// results.Add(channel);
881 /// return PVR_ERROR_NO_ERROR;
882 /// }
883 /// ...
884 /// ~~~~~~~~~~~~~
885 ///
886 virtual PVR_ERROR GetChannels(bool radio, kodi::addon::PVRChannelsResultSet& results)
887 {
888 return PVR_ERROR_NOT_IMPLEMENTED;
889 }
890 //----------------------------------------------------------------------------
891
892 //============================================================================
893 /// @brief Get the stream properties for a channel from the backend.
894 ///
895 /// @param[in] channel The channel to get the stream properties for.
896 /// @param[out] properties the properties required to play the stream.
897 /// @return @ref PVR_ERROR_NO_ERROR if the stream is available.
898 ///
899 /// @remarks If @ref PVRCapabilities::SetSupportsTV "SetSupportsTV" or
900 /// @ref PVRCapabilities::SetSupportsRadio "SetSupportsRadio" are set to true
901 /// and @ref PVRCapabilities::SetHandlesInputStream "SetHandlesInputStream" is
902 /// set to false.\n\n
903 /// In this case the implementation must fill the property @ref PVR_STREAM_PROPERTY_STREAMURL
904 /// with the URL Kodi should resolve to playback the channel.
905 ///
906 /// @note The value directly related to inputstream must always begin with the
907 /// name of the associated add-on, e.g. <b>`"inputstream.adaptive.manifest_update_parameter"`</b>.
908 ///
909 ///
910 ///---------------------------------------------------------------------------
911 ///
912 /// **Example:**
913 /// ~~~~~~~~~~~~~{.cpp}
914 /// ...
915 /// PVR_ERROR CMyPVRInstance::GetChannelStreamProperties(const kodi::addon::PVRChannel& channel,
916 /// std::vector<kodi::addon::PVRStreamProperty>& properties)
917 /// {
918 /// ...
919 /// properties.emplace_back(PVR_STREAM_PROPERTY_INPUTSTREAM, "inputstream.adaptive");
920 /// properties.emplace_back("inputstream.adaptive.manifest_type", "mpd");
921 /// properties.emplace_back("inputstream.adaptive.manifest_update_parameter", "full");
922 /// properties.emplace_back(PVR_STREAM_PROPERTY_MIMETYPE, "application/xml+dash");
923 /// return PVR_ERROR_NO_ERROR;
924 /// }
925 /// ...
926 /// ~~~~~~~~~~~~~
927 ///
928 virtual PVR_ERROR GetChannelStreamProperties(
929 const kodi::addon::PVRChannel& channel,
930 std::vector<kodi::addon::PVRStreamProperty>& properties)
931 {
932 return PVR_ERROR_NOT_IMPLEMENTED;
933 }
934 //----------------------------------------------------------------------------
935
936 //============================================================================
937 /// @brief Get the signal status of the stream that's currently open.
938 ///
939 /// @param[out] signalStatus The signal status.
940 /// @return @ref PVR_ERROR_NO_ERROR if the signal status has been read successfully, false otherwise.
941 ///
942 /// @remarks Optional, and only used if @ref PVRCapabilities::SetHandlesInputStream "SetHandlesInputStream"
943 /// is set to true.
944 ///
945 /// --------------------------------------------------------------------------
946 ///
947 /// @copydetails cpp_kodi_addon_pvr_Defs_Channel_PVRSignalStatus_Help
948 ///
949 ///
950 /// --------------------------------------------------------------------------
951 ///
952 ///
953 /// **Here's example about the use of this:**
954 /// ~~~~~~~~~~~~~{.cpp}
955 /// #include <kodi/addon-instance/PVR.h>
956 /// ...
957 ///
958 /// class ATTRIBUTE_HIDDEN CPVRExample
959 /// : public kodi::addon::CAddonBase,
960 /// public kodi::addon::CInstancePVRClient
961 /// {
962 /// public:
963 /// ...
964 /// PVR_ERROR SignalStatus(PVRSignalStatus &signalStatus) override
965 /// {
966 /// signalStatus.SetAapterName("Example adapter 1");
967 /// signalStatus.SetAdapterStatus("OK");
968 /// signalStatus.SetSignal(0xFFFF); // 100%
969 ///
970 /// return PVR_ERROR_NO_ERROR;
971 /// }
972 /// };
973 ///
974 /// ADDONCREATOR(CPVRExample)
975 /// ~~~~~~~~~~~~~
976 ///
977 virtual PVR_ERROR GetSignalStatus(int channelUid, kodi::addon::PVRSignalStatus& signalStatus)
978 {
979 return PVR_ERROR_NOT_IMPLEMENTED;
980 }
981 //----------------------------------------------------------------------------
982
983 //============================================================================
984 /// @brief Get the descramble information of the stream that's currently open.
985 ///
986 /// @param[out] descrambleInfo The descramble information.
987 /// @return @ref PVR_ERROR_NO_ERROR if the descramble information has been
988 /// read successfully, false otherwise.
989 ///
990 /// @remarks Optional, and only used if @ref PVRCapabilities::SetSupportsDescrambleInfo "supportsDescrambleInfo"
991 /// is set to true.
992 ///
993 /// --------------------------------------------------------------------------
994 ///
995 /// @copydetails cpp_kodi_addon_pvr_Defs_Channel_PVRDescrambleInfo_Help
996 ///
997 virtual PVR_ERROR GetDescrambleInfo(int channelUid,
998 kodi::addon::PVRDescrambleInfo& descrambleInfo)
999 {
1000 return PVR_ERROR_NOT_IMPLEMENTED;
1001 }
1002 //----------------------------------------------------------------------------
1003
1004 //============================================================================
1005 /// @brief **Callback to Kodi Function**\n
1006 /// Request Kodi to update it's list of channels.
1007 ///
1008 /// @remarks Only called from addon itself.
1009 ///
1010 inline void TriggerChannelUpdate()
1011 {
1012 m_instanceData->toKodi->TriggerChannelUpdate(m_instanceData->toKodi->kodiInstance);
1013 }
1014 //----------------------------------------------------------------------------
1015
1016 ///@}
1017 //--==----==----==----==----==----==----==----==----==----==----==----==----==
1018
1019 //============================================================================
1020 /// @defgroup cpp_kodi_addon_pvr_supportsChannelGroups 3. Channel Groups (optional)
1021 /// @ingroup cpp_kodi_addon_pvr
1022 /// @brief <b>Bring in this functions if you have set @ref PVRCapabilities::SetSupportsChannelGroups "supportsChannelGroups"
1023 /// to true</b>\n
1024 /// This is used to divide available addon channels into groups, which can
1025 /// then be selected by the user.
1026 ///
1027 ///
1028 ///---------------------------------------------------------------------------
1029 ///
1030 /// **Channel group parts in interface:**\n
1031 /// Copy this to your project and extend with your parts or leave functions
1032 /// complete away where not used or supported.
1033 ///
1034 /// @copydetails cpp_kodi_addon_pvr_supportsChannelGroups_header_addon_auto_check
1035 /// @copydetails cpp_kodi_addon_pvr_supportsChannelGroups_source_addon_auto_check
1036 ///
1037 ///@{
1038
1039 //============================================================================
1040 /// @brief Get the total amount of channel groups on the backend if it supports channel groups.
1041 ///
1042 /// @param[out] amount The total amount of channel groups on the backend
1043 /// @return @ref PVR_ERROR_NO_ERROR if the amount has been fetched successfully.
1044 ///
1045 /// @remarks Required if @ref PVRCapabilities::SetSupportsChannelGroups "supportsChannelGroups" is set to true.
1046 ///
1047 virtual PVR_ERROR GetChannelGroupsAmount(int& amount) { return PVR_ERROR_NOT_IMPLEMENTED; }
1048 //----------------------------------------------------------------------------
1049
1050 //============================================================================
1051 /// @brief Get a list of available channel groups on addon
1052 ///
1053 /// Request the list of all channel groups from the backend if it supports
1054 /// channel groups.
1055 ///
1056 /// @param[in] radio True to get the radio channel groups, false to get the
1057 /// TV channel groups.
1058 /// @param[out] results List of available groups on addon defined with
1059 /// @ref cpp_kodi_addon_pvr_Defs_ChannelGroup_PVRChannelGroup,
1060 /// them transferred with
1061 /// @ref cpp_kodi_addon_pvr_Defs_ChannelGroup_PVRChannelGroupsResultSet.
1062 /// @return @ref PVR_ERROR_NO_ERROR if the list has been fetched successfully.
1063 ///
1064 /// --------------------------------------------------------------------------
1065 ///
1066 /// @copydetails cpp_kodi_addon_pvr_Defs_ChannelGroup_PVRChannelGroup_Help
1067 ///
1068 ///
1069 /// --------------------------------------------------------------------------
1070 ///
1071 /// @remarks Required if @ref PVRCapabilities::SetSupportsChannelGroups "supportsChannelGroups"
1072 /// is set to true.
1073 ///
1074 ///
1075 ///---------------------------------------------------------------------------
1076 ///
1077 /// **Example:**
1078 /// ~~~~~~~~~~~~~{.cpp}
1079 /// ...
1080 /// PVR_ERROR CMyPVRInstance::GetChannelGroups(bool radio, kodi::addon::PVRChannelGroupsResultSet& groups)
1081 /// {
1082 /// kodi::addon::PVRChannelGroup group;
1083 /// group.SetIsRadio(false);
1084 /// group.SetGroupName("My group name");
1085 /// group.SetPosition(1);
1086 /// ...
1087 ///
1088 /// // Give it now to Kodi
1089 /// results.Add(group);
1090 /// return PVR_ERROR_NO_ERROR;
1091 /// }
1092 /// ...
1093 /// ~~~~~~~~~~~~~
1094 ///
1095 virtual PVR_ERROR GetChannelGroups(bool radio, kodi::addon::PVRChannelGroupsResultSet& results)
1096 {
1097 return PVR_ERROR_NOT_IMPLEMENTED;
1098 }
1099 //----------------------------------------------------------------------------
1100
1101 //============================================================================
1102 /// @brief Get a list of members on a group
1103 ///
1104 /// Request the list of all group members of a group from the backend if it
1105 /// supports channel groups.
1106 ///
1107 /// @param[in] group The group to get the members for.
1108 /// @param[out] results List of available group member channels defined with
1109 /// @ref cpp_kodi_addon_pvr_Defs_ChannelGroup_PVRChannelGroupMember,
1110 /// them transferred with
1111 /// @ref PVRChannelGroupMembersResultSet.
1112 /// @return @ref PVR_ERROR_NO_ERROR if the list has been fetched successfully.
1113 ///
1114 /// --------------------------------------------------------------------------
1115 ///
1116 /// @copydetails cpp_kodi_addon_pvr_Defs_ChannelGroup_PVRChannelGroupMember_Help
1117 ///
1118 /// --------------------------------------------------------------------------
1119 ///
1120 /// @remarks Required if @ref PVRCapabilities::SetSupportsChannelGroups "supportsChannelGroups"
1121 /// is set to true.
1122 ///
1123 ///
1124 ///---------------------------------------------------------------------------
1125 ///
1126 /// **Example:**
1127 /// ~~~~~~~~~~~~~{.cpp}
1128 /// ...
1129 /// PVR_ERROR CMyPVRInstance::GetChannelGroupMembers(const kodi::addon::PVRChannelGroup& group,
1130 /// kodi::addon::PVRChannelGroupMembersResultSet& results)
1131 /// {
1132 /// for (const auto& myGroup : m_myGroups)
1133 /// {
1134 /// if (myGroup.strGroupName == group.GetGroupName())
1135 /// {
1136 /// for (unsigned int iChannelPtr = 0; iChannelPtr < myGroup.members.size(); iChannelPtr++)
1137 /// {
1138 /// int iId = myGroup.members.at(iChannelPtr) - 1;
1139 /// if (iId < 0 || iId > (int)m_channels.size() - 1)
1140 /// continue;
1141 ///
1142 /// PVRDemoChannel &channel = m_channels.at(iId);
1143 /// kodi::addon::PVRChannelGroupMember kodiGroupMember;
1144 /// kodiGroupMember.SetGroupName(group.GetGroupName());
1145 /// kodiGroupMember.SetChannelUniqueId(channel.iUniqueId);
1146 /// kodiGroupMember.SetChannelNumber(channel.iChannelNumber);
1147 /// kodiGroupMember.SetSubChannelNumber(channel.iSubChannelNumber);
1148 ///
1149 /// results.Add(kodiGroupMember);
1150 /// }
1151 /// }
1152 /// }
1153 /// return PVR_ERROR_NO_ERROR;
1154 /// }
1155 /// ...
1156 /// ~~~~~~~~~~~~~
1157 ///
1158 virtual PVR_ERROR GetChannelGroupMembers(const kodi::addon::PVRChannelGroup& group,
1159 kodi::addon::PVRChannelGroupMembersResultSet& results)
1160 {
1161 return PVR_ERROR_NOT_IMPLEMENTED;
1162 }
1163 //----------------------------------------------------------------------------
1164
1165 //============================================================================
1166 /// @brief **Callback to Kodi Function**\n
1167 /// Request Kodi to update it's list of channel groups.
1168 ///
1169 /// @remarks Only called from addon itself
1170 ///
1171 inline void TriggerChannelGroupsUpdate()
1172 {
1173 m_instanceData->toKodi->TriggerChannelGroupsUpdate(m_instanceData->toKodi->kodiInstance);
1174 }
1175 //----------------------------------------------------------------------------
1176
1177 ///@}
1178 //--==----==----==----==----==----==----==----==----==----==----==----==----==
1179
1180 //============================================================================
1181 /// @defgroup cpp_kodi_addon_pvr_supportsChannelEdit 4. Channel edit (optional)
1182 /// @ingroup cpp_kodi_addon_pvr
1183 /// @brief <b>Bring in this functions if you have set @ref PVRCapabilities::SetSupportsChannelSettings "supportsChannelSettings"
1184 /// to true or for @ref OpenDialogChannelScan() set @ref PVRCapabilities::SetSupportsChannelScan "supportsChannelScan"
1185 /// to true</b>\n
1186 /// The support of this is a pure option and not mandatory.
1187 ///
1188 ///
1189 ///---------------------------------------------------------------------------
1190 ///
1191 /// **Channel edit parts in interface:**\n
1192 /// Copy this to your project and extend with your parts or leave functions
1193 /// complete away where not used or supported.
1194 ///
1195 /// @copydetails cpp_kodi_addon_pvr_supportsChannelEdit_header_addon_auto_check
1196 /// @copydetails cpp_kodi_addon_pvr_supportsChannelEdit_source_addon_auto_check
1197 ///
1198 ///@{
1199
1200 //============================================================================
1201 /// @brief Delete a channel from the backend.
1202 ///
1203 /// @param[in] channel The channel to delete.
1204 /// @return @ref PVR_ERROR_NO_ERROR if the channel has been deleted successfully.
1205 /// @remarks Required if @ref PVRCapabilities::SetSupportsChannelSettings "supportsChannelSettings"
1206 /// is set to true.
1207 ///
1208 virtual PVR_ERROR DeleteChannel(const kodi::addon::PVRChannel& channel)
1209 {
1210 return PVR_ERROR_NOT_IMPLEMENTED;
1211 }
1212 //----------------------------------------------------------------------------
1213
1214 //==========================================================================
1215 /// @brief Rename a channel on the backend.
1216 ///
1217 /// @param[in] channel The channel to rename, containing the new channel name.
1218 /// @return @ref PVR_ERROR_NO_ERROR if the channel has been renamed successfully.
1219 ///
1220 /// --------------------------------------------------------------------------
1221 ///
1222 /// @copydetails cpp_kodi_addon_pvr_Defs_Channel_PVRChannel_Help
1223 ///
1224 ///
1225 /// --------------------------------------------------------------------------
1226 ///
1227 /// @remarks Optional, and only used if @ref PVRCapabilities::SetSupportsChannelSettings "supportsChannelSettings"
1228 /// is set to true.
1229 ///
1230 virtual PVR_ERROR RenameChannel(const kodi::addon::PVRChannel& channel)
1231 {
1232 return PVR_ERROR_NOT_IMPLEMENTED;
1233 }
1234 //----------------------------------------------------------------------------
1235
1236 //==========================================================================
1237 /// @brief Show the channel settings dialog, if supported by the backend.
1238 ///
1239 /// @param[in] channel The channel to show the dialog for.
1240 /// @return @ref PVR_ERROR_NO_ERROR if the dialog has been displayed successfully.
1241 ///
1242 /// @remarks Required if @ref PVRCapabilities::SetSupportsChannelSettings "supportsChannelSettings" is set to true.
1243 /// @note Use @ref cpp_kodi_gui_CWindow "kodi::gui::CWindow" to create dialog for them.
1244 ///
1245 virtual PVR_ERROR OpenDialogChannelSettings(const kodi::addon::PVRChannel& channel)
1246 {
1247 return PVR_ERROR_NOT_IMPLEMENTED;
1248 }
1249 //----------------------------------------------------------------------------
1250
1251 //==========================================================================
1252 /// @brief Show the dialog to add a channel on the backend, if supported by the backend.
1253 ///
1254 /// @param[in] channel The channel to add.
1255 /// @return @ref PVR_ERROR_NO_ERROR if the channel has been added successfully.
1256 ///
1257 /// @remarks Required if @ref PVRCapabilities::SetSupportsChannelSettings "supportsChannelSettings" is set to true.
1258 /// @note Use @ref cpp_kodi_gui_CWindow "kodi::gui::CWindow" to create dialog for them.
1259 ///
1260 virtual PVR_ERROR OpenDialogChannelAdd(const kodi::addon::PVRChannel& channel)
1261 {
1262 return PVR_ERROR_NOT_IMPLEMENTED;
1263 }
1264 //----------------------------------------------------------------------------
1265
1266 //==========================================================================
1267 /// @brief Show the channel scan dialog if this backend supports it.
1268 ///
1269 /// @return @ref PVR_ERROR_NO_ERROR if the dialog was displayed successfully.
1270 ///
1271 /// @remarks Required if @ref PVRCapabilities::SetSupportsChannelScan "supportsChannelScan" is set to true.
1272 /// @note Use @ref cpp_kodi_gui_CWindow "kodi::gui::CWindow" to create dialog for them.
1273 ///
1274 virtual PVR_ERROR OpenDialogChannelScan() { return PVR_ERROR_NOT_IMPLEMENTED; }
1275 //----------------------------------------------------------------------------
1276
1277 //==========================================================================
1278 /// @brief Call one of the channel related menu hooks (if supported).
1279 ///
1280 /// Supported @ref cpp_kodi_addon_pvr_Defs_Menuhook_PVRMenuhook instances have to be added in
1281 /// `constructor()`, by calling @ref AddMenuHook() on the callback.
1282 ///
1283 /// @param[in] menuhook The hook to call.
1284 /// @param[in] item The selected channel item for which the hook was called.
1285 /// @return @ref PVR_ERROR_NO_ERROR if the hook was called successfully.
1286 ///
1287 /// --------------------------------------------------------------------------
1288 ///
1289 /// @copydetails cpp_kodi_addon_pvr_Defs_Menuhook_PVRMenuhook_Help
1290 ///
1291 virtual PVR_ERROR CallChannelMenuHook(const kodi::addon::PVRMenuhook& menuhook,
1292 const kodi::addon::PVRChannel& item)
1293 {
1294 return PVR_ERROR_NOT_IMPLEMENTED;
1295 }
1296 //----------------------------------------------------------------------------
1297
1298 ///@}
1299 //--==----==----==----==----==----==----==----==----==----==----==----==----==
1300
1301 //============================================================================
1302 /// @defgroup cpp_kodi_addon_pvr_EPGTag 4. EPG methods (optional)
1303 /// @ingroup cpp_kodi_addon_pvr
1304 /// @brief **PVR EPG methods**\n
1305 /// These C ++ class functions of are intended for processing EPG information
1306 /// and for giving it to Kodi.
1307 ///
1308 /// The necessary data is transferred with @ref cpp_kodi_addon_pvr_Defs_epg_PVREPGTag.
1309 ///
1310 /// @remarks Only used by Kodi if @ref PVRCapabilities::SetSupportsEPG "supportsEPG"
1311 /// is set to true.\n\n
1312 ///
1313 ///
1314 ///---------------------------------------------------------------------------
1315 ///
1316 /// **EPG parts in interface:**\n
1317 /// Copy this to your project and extend with your parts or leave functions
1318 /// complete away where not used or supported.
1319 ///
1320 /// @copydetails cpp_kodi_addon_pvr_EPGTag_header_addon_auto_check
1321 /// @copydetails cpp_kodi_addon_pvr_EPGTag_source_addon_auto_check
1322 ///
1323 ///@{
1324
1325 //============================================================================
1326 /// @brief Request the EPG for a channel from the backend.
1327 ///
1328 /// @param[in] channelUid The UID of the channel to get the EPG table for.
1329 /// @param[in] start Get events after this time (UTC).
1330 /// @param[in] end Get events before this time (UTC).
1331 /// @param[out] results List where available EPG information becomes
1332 /// transferred with @ref cpp_kodi_addon_pvr_Defs_epg_PVREPGTag
1333 /// and given to Kodi
1334 /// @return @ref PVR_ERROR_NO_ERROR if the table has been fetched successfully.
1335 ///
1336 /// --------------------------------------------------------------------------
1337 ///
1338 /// @copydetails cpp_kodi_addon_pvr_Defs_epg_PVREPGTag_Help
1339 ///
1340 ///
1341 /// --------------------------------------------------------------------------
1342 ///
1343 /// @remarks Required if @ref PVRCapabilities::SetSupportsEPG "supportsEPG" is set to true.
1344 ///
1345 ///
1346 ///---------------------------------------------------------------------------
1347 ///
1348 /// **Example:**
1349 /// ~~~~~~~~~~~~~{.cpp}
1350 /// ...
1351 /// PVR_ERROR CMyPVRInstance::GetEPGForChannel(int channelUid,
1352 /// time_t start,
1353 /// time_t end,
1354 /// kodi::addon::PVREPGTagsResultSet& results)
1355 /// {
1356 /// // Minimal demo example, in reality bigger, loop to transfer all and to
1357 /// // match wanted times.
1358 /// kodi::addon::PVREPGTag tag;
1359 /// tag.SetUniqueBroadcastId(123);
1360 /// tag.SetUniqueChannelId(123);
1361 /// tag.SetTitle("My epg entry name");
1362 /// tag.SetGenreType(EPG_EVENT_CONTENTMASK_MOVIEDRAMA);
1363 /// tag.SetStartTime(1589148283); // Seconds elapsed since 00:00 hours, Jan 1, 1970 UTC
1364 /// tag.SetEndTime(1589151913);
1365 /// ...
1366 ///
1367 /// // Give it now to Kodi
1368 /// results.Add(tag);
1369 /// return PVR_ERROR_NO_ERROR;
1370 /// }
1371 /// ...
1372 /// ~~~~~~~~~~~~~
1373 ///
1374 virtual PVR_ERROR GetEPGForChannel(int channelUid,
1375 time_t start,
1376 time_t end,
1377 kodi::addon::PVREPGTagsResultSet& results)
1378 {
1379 return PVR_ERROR_NOT_IMPLEMENTED;
1380 }
1381 //----------------------------------------------------------------------------
1382
1383 //============================================================================
1384 /// @brief Check if the given EPG tag can be recorded.
1385 ///
1386 /// @param[in] tag the @ref cpp_kodi_addon_pvr_Defs_epg_PVREPGTag "epg tag" to check.
1387 /// @param[out] isRecordable Set to true if the tag can be recorded.
1388 /// @return @ref PVR_ERROR_NO_ERROR if bIsRecordable has been set successfully.
1389 ///
1390 /// @remarks Optional, it return @ref PVR_ERROR_NOT_IMPLEMENTED by parent to let Kodi decide.
1391 ///
1392 virtual PVR_ERROR IsEPGTagRecordable(const kodi::addon::PVREPGTag& tag, bool& isRecordable)
1393 {
1394 return PVR_ERROR_NOT_IMPLEMENTED;
1395 }
1396 //----------------------------------------------------------------------------
1397
1398 //============================================================================
1399 /// @brief Check if the given EPG tag can be played.
1400 ///
1401 /// @param[in] tag the @ref cpp_kodi_addon_pvr_Defs_epg_PVREPGTag "epg tag" to check.
1402 /// @param[out] isPlayable Set to true if the tag can be played.
1403 /// @return @ref PVR_ERROR_NO_ERROR if bIsPlayable has been set successfully.
1404 ///
1405 /// @remarks Required if add-on supports playing epg tags.
1406 ///
1407 virtual PVR_ERROR IsEPGTagPlayable(const kodi::addon::PVREPGTag& tag, bool& isPlayable)
1408 {
1409 return PVR_ERROR_NOT_IMPLEMENTED;
1410 }
1411 //----------------------------------------------------------------------------
1412
1413 //============================================================================
1414 /// @brief Retrieve the edit decision list (EDL) of an EPG tag on the backend.
1415 ///
1416 /// @param[in] tag The @ref cpp_kodi_addon_pvr_Defs_epg_PVREPGTag "epg tag".
1417 /// @param[out] edl The function has to write the EDL into this array.
1418 /// @return @ref PVR_ERROR_NO_ERROR if the EDL was successfully read or no EDL exists.
1419 ///
1420 /// @remarks Required if @ref PVRCapabilities::SetSupportsEPGEdl "supportsEPGEdl" is set to true.
1421 ///
1422 /// --------------------------------------------------------------------------
1423 ///
1424 /// @copydetails cpp_kodi_addon_pvr_Defs_EDLEntry_PVREDLEntry_Help
1425 ///
1426 ///
1427 /// --------------------------------------------------------------------------
1428 ///
1429 /// @remarks Required if @ref PVRCapabilities::SetSupportsEPGEdl "supportsEPGEdl" is set to true.
1430 ///
1431 virtual PVR_ERROR GetEPGTagEdl(const kodi::addon::PVREPGTag& tag,
1432 std::vector<kodi::addon::PVREDLEntry>& edl)
1433 {
1434 return PVR_ERROR_NOT_IMPLEMENTED;
1435 }
1436 //----------------------------------------------------------------------------
1437
1438 //============================================================================
1439 /// @brief Get the stream properties for an epg tag from the backend.
1440 ///
1441 /// @param[in] tag The @ref cpp_kodi_addon_pvr_Defs_epg_PVREPGTag "epg tag" to get the stream properties for.
1442 /// @param[out] properties the properties required to play the stream.
1443 /// @return @ref PVR_ERROR_NO_ERROR if the stream is available.
1444 ///
1445 /// @remarks Required if add-on supports playing epg tags.
1446 /// In this case your implementation must fill the property @ref PVR_STREAM_PROPERTY_STREAMURL
1447 /// with the URL Kodi should resolve to playback the epg tag.
1448 /// It return @ref PVR_ERROR_NOT_IMPLEMENTED from parent if this add-on won't provide this function.
1449 ///
1450 /// @note The value directly related to inputstream must always begin with the
1451 /// name of the associated add-on, e.g. <b>`"inputstream.adaptive.manifest_update_parameter"`</b>.
1452 ///
1453 ///
1454 ///---------------------------------------------------------------------------
1455 ///
1456 /// **Example:**
1457 /// ~~~~~~~~~~~~~{.cpp}
1458 /// ...
1459 /// PVR_ERROR CMyPVRInstance::GetEPGTagStreamProperties(const kodi::addon::PVREPGTag& tag,
1460 /// std::vector<kodi::addon::PVRStreamProperty>& properties)
1461 /// {
1462 /// ...
1463 /// properties.emplace_back(PVR_STREAM_PROPERTY_INPUTSTREAM, "inputstream.adaptive");
1464 /// properties.emplace_back("inputstream.adaptive.manifest_type", "mpd");
1465 /// properties.emplace_back("inputstream.adaptive.manifest_update_parameter", "full");
1466 /// properties.emplace_back(PVR_STREAM_PROPERTY_MIMETYPE, "application/xml+dash");
1467 /// return PVR_ERROR_NO_ERROR;
1468 /// }
1469 /// ...
1470 /// ~~~~~~~~~~~~~
1471 ///
1472 virtual PVR_ERROR GetEPGTagStreamProperties(
1473 const kodi::addon::PVREPGTag& tag, std::vector<kodi::addon::PVRStreamProperty>& properties)
1474 {
1475 return PVR_ERROR_NOT_IMPLEMENTED;
1476 }
1477 //----------------------------------------------------------------------------
1478
1479 //============================================================================
1480 /// @brief Tell the client the time frame to use when notifying epg events back to Kodi
1481 ///
1482 /// The client might push epg events asynchronously to Kodi using the callback function
1483 /// @ref EpgEventStateChange. To be able to only push events that are actually of
1484 /// interest for Kodi, client needs to know about the epg time frame Kodi uses. Kodi
1485 /// supplies the current epg time frame value in @ref EpgMaxDays() when creating the
1486 /// addon and calls @ref SetEPGTimeFrame later whenever Kodi's epg time frame value
1487 /// changes.
1488 ///
1489 /// @param[in] days number of days from "now". @ref EPG_TIMEFRAME_UNLIMITED means that Kodi
1490 /// is interested in all epg events, regardless of event times.
1491 /// @return @ref PVR_ERROR_NO_ERROR if new value was successfully set.
1492 ///
1493 /// @remarks Required if @ref PVRCapabilities::SetSupportsEPG "supportsEPG" is set to true.
1494 ///
1495 virtual PVR_ERROR SetEPGTimeFrame(int days) { return PVR_ERROR_NOT_IMPLEMENTED; }
1496 //----------------------------------------------------------------------------
1497
1498 //==========================================================================
1499 /// @brief Call one of the EPG related menu hooks (if supported).
1500 ///
1501 /// Supported @ref cpp_kodi_addon_pvr_Defs_Menuhook_PVRMenuhook instances have to be added in
1502 /// `constructor()`, by calling @ref AddMenuHook() on the callback.
1503 ///
1504 /// @param[in] menuhook The hook to call.
1505 /// @param[in] tag The selected EPG item for which the hook was called.
1506 /// @return @ref PVR_ERROR_NO_ERROR if the hook was called successfully.
1507 ///
1508 /// --------------------------------------------------------------------------
1509 ///
1510 /// @copydetails cpp_kodi_addon_pvr_Defs_Menuhook_PVRMenuhook_Help
1511 ///
1512 virtual PVR_ERROR CallEPGMenuHook(const kodi::addon::PVRMenuhook& menuhook,
1513 const kodi::addon::PVREPGTag& tag)
1514 {
1515 return PVR_ERROR_NOT_IMPLEMENTED;
1516 }
1517 //----------------------------------------------------------------------------
1518
1519 //==========================================================================
1520 /// @brief **Callback to Kodi Function**\n
1521 /// Get the Max days handled by Kodi.
1522 ///
1523 /// If > @ref EPG_TIMEFRAME_UNLIMITED, in async epg mode, deliver only events
1524 /// in the range from 'end time > now' to 'start time < now + EpgMaxDays().
1525 /// @ref EPG_TIMEFRAME_UNLIMITED, notify all events.
1526 ///
1527 /// @return The Max days handled by Kodi
1528 ///
1529 inline int EpgMaxDays() const { return m_instanceData->props->iEpgMaxDays; }
1530 //----------------------------------------------------------------------------
1531
1532 //==========================================================================
1533 /// @brief **Callback to Kodi Function**\n
1534 /// Schedule an EPG update for the given channel channel.
1535 ///
1536 /// @param[in] channelUid The unique id of the channel for this add-on
1537 ///
1538 /// @remarks Only called from addon itself
1539 ///
1540 inline void TriggerEpgUpdate(unsigned int channelUid)
1541 {
1542 m_instanceData->toKodi->TriggerEpgUpdate(m_instanceData->toKodi->kodiInstance, channelUid);
1543 }
1544 //----------------------------------------------------------------------------
1545
1546 //==========================================================================
1547 /// @brief **Callback to Kodi Function**\n
1548 /// Notify a state change for an EPG event.
1549 ///
1550 /// @param[in] tag The @ref cpp_kodi_addon_pvr_Defs_epg_PVREPGTag "EPG tag" where have event.
1551 /// @param[in] newState The new state.
1552 /// - For @ref EPG_EVENT_CREATED and @ref EPG_EVENT_UPDATED, tag must be filled with all available event data, not just a delta.
1553 /// - For @ref EPG_EVENT_DELETED, it is sufficient to fill @ref kodi::addon::PVREPGTag::SetUniqueBroadcastId
1554 ///
1555 /// @remarks Only called from addon itself,
1556 ///
1557 ///
1558 ///---------------------------------------------------------------------------
1559 ///
1560 /// **Example:**
1561 /// ~~~~~~~~~~~~~{.cpp}
1562 /// ...
1563 ///
1564 /// void CMyPVRInstance::MyProcessFunction()
1565 /// {
1566 /// ...
1567 /// kodi::addon::PVREPGTag tag; // Here as mini add, in real it should be a complete tag
1568 /// tag.SetUniqueId(123);
1569 ///
1570 /// // added namespace here not needed to have, only to have more clear for where is
1571 /// kodi::addon::CInstancePVRClient::EpgEventStateChange(tag, EPG_EVENT_UPDATED);
1572 /// ...
1573 /// }
1574 ///
1575 /// ...
1576 /// ~~~~~~~~~~~~~
1577 ///
1578 inline void EpgEventStateChange(kodi::addon::PVREPGTag& tag, EPG_EVENT_STATE newState)
1579 {
1580 m_instanceData->toKodi->EpgEventStateChange(m_instanceData->toKodi->kodiInstance, tag.GetTag(),
1581 newState);
1582 }
1583 //----------------------------------------------------------------------------
1584
1585 ///@}
1586 //--==----==----==----==----==----==----==----==----==----==----==----==----==
1587
1588 //============================================================================
1589 /// @defgroup cpp_kodi_addon_pvr_Recordings 5. Recordings (optional)
1590 /// @ingroup cpp_kodi_addon_pvr
1591 /// @brief **PVR recording methods**\n
1592 /// To transfer available recordings of the PVR backend and to allow possible
1593 /// playback.
1594 ///
1595 /// @remarks Only used by Kodi if @ref PVRCapabilities::SetSupportsRecordings "supportsRecordings"
1596 /// is set to true.\n\n
1597 /// If a recordings changes after the initial import, or if a new one was added,
1598 /// then the add-on should call @ref TriggerRecordingUpdate().
1599 ///
1600 ///
1601 ///---------------------------------------------------------------------------
1602 ///
1603 /// **Recordings parts in interface:**\n
1604 /// Copy this to your project and extend with your parts or leave functions
1605 /// complete away where not used or supported.
1606 ///
1607 /// @copydetails cpp_kodi_addon_pvr_Recordings_header_addon_auto_check
1608 /// @copydetails cpp_kodi_addon_pvr_Recordings_source_addon_auto_check
1609 ///
1610 ///@{
1611
1612 //============================================================================
1613 /// @brief To get amount of recording present on backend
1614 ///
1615 /// @param[in] deleted if set return deleted recording (called if
1616 /// @ref PVRCapabilities::SetSupportsRecordingsUndelete "supportsRecordingsUndelete"
1617 /// set to true)
1618 /// @param[out] amount The total amount of recordings on the backend
1619 /// @return @ref PVR_ERROR_NO_ERROR if the amount has been fetched successfully.
1620 ///
1621 /// @remarks Optional, and only used if @ref PVRCapabilities::SetSupportsRecordings "supportsRecordings" is set to true.
1622 ///
1623 virtual PVR_ERROR GetRecordingsAmount(bool deleted, int& amount)
1624 {
1625 return PVR_ERROR_NOT_IMPLEMENTED;
1626 }
1627 //----------------------------------------------------------------------------
1628
1629 //============================================================================
1630 /// @brief Request the list of all recordings from the backend, if supported.
1631 ///
1632 /// Recording entries are added to Kodi by calling TransferRecordingEntry() on the callback.
1633 ///
1634 /// @param[in] deleted if set return deleted recording (called if
1635 /// @ref PVRCapabilities::SetSupportsRecordingsUndelete "supportsRecordingsUndelete"
1636 /// set to true)
1637 /// @param[out] results List of available recordings with @ref cpp_kodi_addon_pvr_Defs_Recording_PVRRecording
1638 /// becomes transferred with @ref cpp_kodi_addon_pvr_Defs_Recording_PVRRecordingsResultSet
1639 /// and given to Kodi
1640 /// @return @ref PVR_ERROR_NO_ERROR if the recordings have been fetched successfully.
1641 ///
1642 /// @remarks Optional, and only used if @ref PVRCapabilities::SetSupportsRecordings "supportsRecordings"
1643 /// is set to true.
1644 ///
1645 /// --------------------------------------------------------------------------
1646 ///
1647 /// @copydetails cpp_kodi_addon_pvr_Defs_Recording_PVRRecording_Help
1648 ///
1649 ///
1650 ///---------------------------------------------------------------------------
1651 ///
1652 /// **Example:**
1653 /// ~~~~~~~~~~~~~{.cpp}
1654 /// ...
1655 /// PVR_ERROR CMyPVRInstance::GetRecordings(bool deleted, kodi::addon::PVRRecordingsResultSet& results)
1656 /// {
1657 /// // Minimal demo example, in reality bigger and loop to transfer all
1658 /// kodi::addon::PVRRecording recording;
1659 /// recording.SetRecordingId(123);
1660 /// recording.SetTitle("My recording name");
1661 /// ...
1662 ///
1663 /// // Give it now to Kodi
1664 /// results.Add(recording);
1665 /// return PVR_ERROR_NO_ERROR;
1666 /// }
1667 /// ...
1668 /// ~~~~~~~~~~~~~
1669 ///
1670 virtual PVR_ERROR GetRecordings(bool deleted, kodi::addon::PVRRecordingsResultSet& results)
1671 {
1672 return PVR_ERROR_NOT_IMPLEMENTED;
1673 }
1674 //----------------------------------------------------------------------------
1675
1676 //============================================================================
1677 /// @brief Delete a recording on the backend.
1678 ///
1679 /// @param[in] recording The @ref cpp_kodi_addon_pvr_Defs_Recording_PVRRecording to delete.
1680 /// @return @ref PVR_ERROR_NO_ERROR if the recording has been deleted successfully.
1681 ///
1682 /// @remarks Optional, and only used if @ref PVRCapabilities::SetSupportsRecordings "supportsRecordings"
1683 /// is set to true.
1684 ///
1685 virtual PVR_ERROR DeleteRecording(const kodi::addon::PVRRecording& recording)
1686 {
1687 return PVR_ERROR_NOT_IMPLEMENTED;
1688 }
1689 //----------------------------------------------------------------------------
1690
1691 //============================================================================
1692 /// @brief Undelete a recording on the backend.
1693 ///
1694 /// @param[in] recording The @ref cpp_kodi_addon_pvr_Defs_Recording_PVRRecording to undelete.
1695 /// @return @ref PVR_ERROR_NO_ERROR if the recording has been undeleted successfully.
1696 ///
1697 /// @remarks Optional, and only used if @ref PVRCapabilities::SetSupportsRecordingsUndelete "supportsRecordingsUndelete"
1698 /// is set to true.
1699 ///
1700 virtual PVR_ERROR UndeleteRecording(const kodi::addon::PVRRecording& recording)
1701 {
1702 return PVR_ERROR_NOT_IMPLEMENTED;
1703 }
1704 //----------------------------------------------------------------------------
1705
1706 //============================================================================
1707 /// @brief Delete all recordings permanent which in the deleted folder on the backend.
1708 ///
1709 /// @return @ref PVR_ERROR_NO_ERROR if the recordings has been deleted successfully.
1710 ///
1711 virtual PVR_ERROR DeleteAllRecordingsFromTrash() { return PVR_ERROR_NOT_IMPLEMENTED; }
1712 //----------------------------------------------------------------------------
1713
1714 //============================================================================
1715 /// @brief Rename a recording on the backend.
1716 ///
1717 /// @param[in] recording The @ref cpp_kodi_addon_pvr_Defs_Recording_PVRRecording
1718 /// to rename, containing the new name.
1719 /// @return @ref PVR_ERROR_NO_ERROR if the recording has been renamed successfully.
1720 ///
1721 /// @remarks Optional, and only used if @ref PVRCapabilities::SetSupportsRecordings "supportsRecordings"
1722 /// is set to true.
1723 ///
1724 virtual PVR_ERROR RenameRecording(const kodi::addon::PVRRecording& recording)
1725 {
1726 return PVR_ERROR_NOT_IMPLEMENTED;
1727 }
1728 //----------------------------------------------------------------------------
1729
1730 //============================================================================
1731 /// @brief Set the lifetime of a recording on the backend.
1732 ///
1733 /// @param[in] recording The @ref cpp_kodi_addon_pvr_Defs_Recording_PVRRecording
1734 /// to change the lifetime for. recording.iLifetime
1735 /// contains the new lieftime value.
1736 /// @return @ref PVR_ERROR_NO_ERROR if the recording's lifetime has been set
1737 /// successfully.
1738 ///
1739 /// @remarks Required if @ref PVRCapabilities::SetSupportsRecordingsLifetimeChange "supportsRecordingsLifetimeChange"
1740 /// is set to true.
1741 ///
1742 virtual PVR_ERROR SetRecordingLifetime(const kodi::addon::PVRRecording& recording)
1743 {
1744 return PVR_ERROR_NOT_IMPLEMENTED;
1745 }
1746 //----------------------------------------------------------------------------
1747
1748 //============================================================================
1749 /// @brief Set the play count of a recording on the backend.
1750 ///
1751 /// @param[in] recording The @ref cpp_kodi_addon_pvr_Defs_Recording_PVRRecording
1752 /// to change the play count.
1753 /// @param[in] count Play count.
1754 /// @return @ref PVR_ERROR_NO_ERROR if the recording's play count has been set
1755 /// successfully.
1756 ///
1757 /// @remarks Required if @ref PVRCapabilities::SetSupportsRecordingPlayCount "supportsRecordingPlayCount"
1758 /// is set to true.
1759 ///
1760 virtual PVR_ERROR SetRecordingPlayCount(const kodi::addon::PVRRecording& recording, int count)
1761 {
1762 return PVR_ERROR_NOT_IMPLEMENTED;
1763 }
1764 //----------------------------------------------------------------------------
1765
1766 //============================================================================
1767 /// @brief Set the last watched position of a recording on the backend.
1768 ///
1769 /// @param[in] recording The @ref cpp_kodi_addon_pvr_Defs_Recording_PVRRecording.
1770 /// @param[in] lastplayedposition The last watched position in seconds
1771 /// @return @ref PVR_ERROR_NO_ERROR if the position has been stored successfully.
1772 ///
1773 /// @remarks Required if @ref PVRCapabilities::SetSupportsLastPlayedPosition "supportsLastPlayedPosition"
1774 /// is set to true.
1775 ///
1776 virtual PVR_ERROR SetRecordingLastPlayedPosition(const kodi::addon::PVRRecording& recording,
1777 int lastplayedposition)
1778 {
1779 return PVR_ERROR_NOT_IMPLEMENTED;
1780 }
1781 //----------------------------------------------------------------------------
1782
1783 //============================================================================
1784 /// @brief Retrieve the last watched position of a recording on the backend.
1785 ///
1786 /// @param[in] recording The @ref cpp_kodi_addon_pvr_Defs_Recording_PVRRecording.
1787 /// @param[out] position The last watched position in seconds
1788 /// @return @ref PVR_ERROR_NO_ERROR if the amount has been fetched successfully.
1789 ///
1790 /// @remarks Required if @ref PVRCapabilities::SetSupportsRecordingPlayCount "supportsRecordingPlayCount"
1791 /// is set to true.
1792 ///
1793 virtual PVR_ERROR GetRecordingLastPlayedPosition(const kodi::addon::PVRRecording& recording,
1794 int& position)
1795 {
1796 return PVR_ERROR_NOT_IMPLEMENTED;
1797 }
1798 //----------------------------------------------------------------------------
1799
1800 //============================================================================
1801 /// @brief Retrieve the edit decision list (EDL) of a recording on the backend.
1802 ///
1803 /// @param[in] recording The @ref cpp_kodi_addon_pvr_Defs_Recording_PVRRecording.
1804 /// @param[out] edl The function has to write the EDL into this array.
1805 /// @return @ref PVR_ERROR_NO_ERROR if the EDL was successfully read or no EDL exists.
1806 ///
1807 /// @remarks Required if @ref PVRCapabilities::SetSupportsRecordingEdl "supportsRecordingEdl"
1808 /// is set to true.
1809 ///
1810 /// --------------------------------------------------------------------------
1811 ///
1812 /// @copydetails cpp_kodi_addon_pvr_Defs_EDLEntry_PVREDLEntry_Help
1813 ///
1814 virtual PVR_ERROR GetRecordingEdl(const kodi::addon::PVRRecording& recording,
1815 std::vector<kodi::addon::PVREDLEntry>& edl)
1816 {
1817 return PVR_ERROR_NOT_IMPLEMENTED;
1818 }
1819 //----------------------------------------------------------------------------
1820
1821 //============================================================================
1822 /// @brief Retrieve the size of a recording on the backend.
1823 ///
1824 /// @param[in] recording The recording to get the size in bytes for.
1825 /// @param[out] size The size in bytes of the recording
1826 /// @return @ref PVR_ERROR_NO_ERROR if the recording's size has been set successfully.
1827 ///
1828 /// @remarks Required if @ref PVRCapabilities::SetSupportsRecordingSize "supportsRecordingSize"
1829 /// is set to true.
1830 ///
1831 virtual PVR_ERROR GetRecordingSize(const kodi::addon::PVRRecording& recording, int64_t& size)
1832 {
1833 return PVR_ERROR_NOT_IMPLEMENTED;
1834 }
1835 //----------------------------------------------------------------------------
1836
1837 //============================================================================
1838 /// @brief Get the stream properties for a recording from the backend.
1839 ///
1840 /// @param[in] recording The @ref cpp_kodi_addon_pvr_Defs_Recording_PVRRecording
1841 /// to get the stream properties for.
1842 /// @param[out] properties The properties required to play the stream.
1843 /// @return @ref PVR_ERROR_NO_ERROR if the stream is available.
1844 ///
1845 /// @remarks Required if @ref PVRCapabilities::SetSupportsRecordings "supportsRecordings"
1846 /// is set to true and the add-on does not implement recording stream functions
1847 /// (@ref OpenRecordedStream, ...).\n
1848 /// In this case your implementation must fill the property @ref PVR_STREAM_PROPERTY_STREAMURL
1849 /// with the URL Kodi should resolve to playback the recording.
1850 ///
1851 /// @note The value directly related to inputstream must always begin with the
1852 /// name of the associated add-on, e.g. <b>`"inputstream.adaptive.manifest_update_parameter"`</b>.
1853 ///
1854 ///
1855 ///---------------------------------------------------------------------------
1856 ///
1857 /// **Example:**
1858 /// ~~~~~~~~~~~~~{.cpp}
1859 /// ...
1860 /// PVR_ERROR CMyPVRInstance::GetRecordingStreamProperties(const kodi::addon::PVRRecording& recording,
1861 /// std::vector<kodi::addon::PVRStreamProperty>& properties)
1862 /// {
1863 /// ...
1864 /// properties.emplace_back(PVR_STREAM_PROPERTY_INPUTSTREAM, "inputstream.adaptive");
1865 /// properties.emplace_back("inputstream.adaptive.manifest_type", "mpd");
1866 /// properties.emplace_back("inputstream.adaptive.manifest_update_parameter", "full");
1867 /// properties.emplace_back(PVR_STREAM_PROPERTY_MIMETYPE, "application/xml+dash");
1868 /// return PVR_ERROR_NO_ERROR;
1869 /// }
1870 /// ...
1871 /// ~~~~~~~~~~~~~
1872 ///
1873 virtual PVR_ERROR GetRecordingStreamProperties(
1874 const kodi::addon::PVRRecording& recording,
1875 std::vector<kodi::addon::PVRStreamProperty>& properties)
1876 {
1877 return PVR_ERROR_NOT_IMPLEMENTED;
1878 }
1879 //----------------------------------------------------------------------------
1880
1881 //==========================================================================
1882 /// @brief Call one of the recording related menu hooks (if supported).
1883 ///
1884 /// Supported @ref cpp_kodi_addon_pvr_Defs_Menuhook_PVRMenuhook instances have to be added in
1885 /// `constructor()`, by calling @ref AddMenuHook() on the callback.
1886 ///
1887 /// @param[in] menuhook The hook to call.
1888 /// @param[in] item The selected recording item for which the hook was called.
1889 /// @return @ref PVR_ERROR_NO_ERROR if the hook was called successfully.
1890 ///
1891 /// --------------------------------------------------------------------------
1892 ///
1893 /// @copydetails cpp_kodi_addon_pvr_Defs_Menuhook_PVRMenuhook_Help
1894 ///
1895 virtual PVR_ERROR CallRecordingMenuHook(const kodi::addon::PVRMenuhook& menuhook,
1896 const kodi::addon::PVRRecording& item)
1897 {
1898 return PVR_ERROR_NOT_IMPLEMENTED;
1899 }
1900 //----------------------------------------------------------------------------
1901
1902 //============================================================================
1903 /// @brief **Callback to Kodi Function**\n
1904 /// Display a notification in Kodi that a recording started or stopped on the
1905 /// server.
1906 ///
1907 /// @param[in] recordingName The name of the recording to display
1908 /// @param[in] fileName The filename of the recording
1909 /// @param[in] on True when recording started, false when it stopped
1910 ///
1911 /// @remarks Only called from addon itself
1912 ///
1913 inline void RecordingNotification(const std::string& recordingName,
1914 const std::string& fileName,
1915 bool on)
1916 {
1917 m_instanceData->toKodi->RecordingNotification(m_instanceData->toKodi->kodiInstance,
1918 recordingName.c_str(), fileName.c_str(), on);
1919 }
1920 //----------------------------------------------------------------------------
1921
1922 //============================================================================
1923 /// @brief **Callback to Kodi Function**\n
1924 /// Request Kodi to update it's list of recordings.
1925 ///
1926 /// @remarks Only called from addon itself
1927 ///
1928 inline void TriggerRecordingUpdate()
1929 {
1930 m_instanceData->toKodi->TriggerRecordingUpdate(m_instanceData->toKodi->kodiInstance);
1931 }
1932 //----------------------------------------------------------------------------
1933
1934 ///@}
1935 //--==----==----==----==----==----==----==----==----==----==----==----==----==
1936
1937 //============================================================================
1938 /// @defgroup cpp_kodi_addon_pvr_Timers 6. Timers (optional)
1939 /// @ingroup cpp_kodi_addon_pvr
1940 /// @brief **PVR timer methods**\n
1941 /// For editing and displaying timed work, such as video recording.
1942 ///
1943 /// @remarks Only used by Kodi if @ref PVRCapabilities::SetSupportsTimers "supportsTimers"
1944 /// is set to true.\n\n
1945 /// If a timer changes after the initial import, or if a new one was added,
1946 /// then the add-on should call @ref TriggerTimerUpdate().
1947 ///
1948 ///
1949 ///---------------------------------------------------------------------------
1950 ///
1951 /// **Timer parts in interface:**\n
1952 /// Copy this to your project and extend with your parts or leave functions
1953 /// complete away where not used or supported.
1954 ///
1955 /// @copydetails cpp_kodi_addon_pvr_Timers_header_addon_auto_check
1956 /// @copydetails cpp_kodi_addon_pvr_Timers_source_addon_auto_check
1957 ///
1958 ///@{
1959
1960 //============================================================================
1961 /// @brief Retrieve the timer types supported by the backend.
1962 ///
1963 /// @param[out] types The function has to write the definition of the
1964 /// @ref cpp_kodi_addon_pvr_Defs_Timer_PVRTimerType types
1965 /// into this array.
1966 /// @return @ref PVR_ERROR_NO_ERROR if the types were successfully written to
1967 /// the array.
1968 ///
1969 /// @note Maximal 32 entries are allowed inside.
1970 ///
1971 /// --------------------------------------------------------------------------
1972 ///
1973 /// @copydetails cpp_kodi_addon_pvr_Defs_Timer_PVRTimerType_Help
1974 ///
1975 virtual PVR_ERROR GetTimerTypes(std::vector<kodi::addon::PVRTimerType>& types)
1976 {
1977 return PVR_ERROR_NOT_IMPLEMENTED;
1978 }
1979 //----------------------------------------------------------------------------
1980
1981 //============================================================================
1982 /// @brief To get total amount of timers on the backend or -1 on error.
1983 ///
1984 /// @param[out] amount The total amount of timers on the backend
1985 /// @return @ref PVR_ERROR_NO_ERROR if the amount has been fetched successfully.
1986 ///
1987 /// @note Required to use if @ref PVRCapabilities::SetSupportsTimers "supportsTimers"
1988 /// is set to true.
1989 ///
1990 virtual PVR_ERROR GetTimersAmount(int& amount) { return PVR_ERROR_NOT_IMPLEMENTED; }
1991 //----------------------------------------------------------------------------
1992
1993 //============================================================================
1994 /// @brief Request the list of all timers from the backend if supported.
1995 ///
1996 /// @param[out] results List of available timers with @ref cpp_kodi_addon_pvr_Defs_Timer_PVRTimer
1997 /// becomes transferred with @ref cpp_kodi_addon_pvr_Defs_Timer_PVRTimersResultSet
1998 /// and given to Kodi
1999 /// @return @ref PVR_ERROR_NO_ERROR if the list has been fetched successfully.
2000 ///
2001 /// @note Required to use if @ref PVRCapabilities::SetSupportsTimers "supportsTimers"
2002 /// is set to true.
2003 ///
2004 /// --------------------------------------------------------------------------
2005 ///
2006 /// @copydetails cpp_kodi_addon_pvr_Defs_Timer_PVRTimer_Help
2007 ///
2008 ///
2009 ///---------------------------------------------------------------------------
2010 ///
2011 /// **Example:**
2012 /// ~~~~~~~~~~~~~{.cpp}
2013 /// ...
2014 /// PVR_ERROR CMyPVRInstance::GetTimers(kodi::addon::PVRTimersResultSet& results)
2015 /// {
2016 /// // Minimal demo example, in reality bigger and loop to transfer all
2017 /// kodi::addon::PVRTimer timer;
2018 /// timer.SetClientIndex(123);
2019 /// timer.SetState(PVR_TIMER_STATE_SCHEDULED);
2020 /// timer.SetTitle("My timer name");
2021 /// ...
2022 ///
2023 /// // Give it now to Kodi
2024 /// results.Add(timer);
2025 /// return PVR_ERROR_NO_ERROR;
2026 /// }
2027 /// ...
2028 /// ~~~~~~~~~~~~~
2029 ///
2030 virtual PVR_ERROR GetTimers(kodi::addon::PVRTimersResultSet& results)
2031 {
2032 return PVR_ERROR_NOT_IMPLEMENTED;
2033 }
2034 //----------------------------------------------------------------------------
2035
2036 //============================================================================
2037 /// @brief Add a timer on the backend.
2038 ///
2039 /// @param[in] timer The timer to add.
2040 /// @return @ref PVR_ERROR_NO_ERROR if the timer has been added successfully.
2041 ///
2042 /// @note Required to use if @ref PVRCapabilities::SetSupportsTimers "supportsTimers"
2043 /// is set to true.
2044 ///
2045 virtual PVR_ERROR AddTimer(const kodi::addon::PVRTimer& timer)
2046 {
2047 return PVR_ERROR_NOT_IMPLEMENTED;
2048 }
2049 //----------------------------------------------------------------------------
2050
2051 //============================================================================
2052 /// @brief Delete a timer on the backend.
2053 ///
2054 /// @param[in] timer The timer to delete.
2055 /// @param[in] forceDelete Set to true to delete a timer that is currently
2056 /// recording a program.
2057 /// @return @ref PVR_ERROR_NO_ERROR if the timer has been deleted successfully.
2058 ///
2059 /// @note Required to use if @ref PVRCapabilities::SetSupportsTimers "supportsTimers"
2060 /// is set to true.
2061 ///
2062 virtual PVR_ERROR DeleteTimer(const kodi::addon::PVRTimer& timer, bool forceDelete)
2063 {
2064 return PVR_ERROR_NOT_IMPLEMENTED;
2065 }
2066 //----------------------------------------------------------------------------
2067
2068 //============================================================================
2069 /// @brief Update the timer information on the backend.
2070 ///
2071 /// @param[in] timer The timer to update.
2072 /// @return @ref PVR_ERROR_NO_ERROR if the timer has been updated successfully.
2073 ///
2074 /// @note Required to use if @ref PVRCapabilities::SetSupportsTimers "supportsTimers"
2075 /// is set to true.
2076 ///
2077 virtual PVR_ERROR UpdateTimer(const kodi::addon::PVRTimer& timer)
2078 {
2079 return PVR_ERROR_NOT_IMPLEMENTED;
2080 }
2081 //----------------------------------------------------------------------------
2082
2083 //============================================================================
2084 /// @brief Call one of the timer related menu hooks (if supported).
2085 ///
2086 /// Supported @ref cpp_kodi_addon_pvr_Defs_Menuhook_PVRMenuhook instances have
2087 /// to be added in `constructor()`, by calling @ref AddMenuHook() on the
2088 /// callback.
2089 ///
2090 /// @param[in] menuhook The hook to call.
2091 /// @param[in] item The selected timer item for which the hook was called.
2092 /// @return @ref PVR_ERROR_NO_ERROR if the hook was called successfully.
2093 ///
2094 /// --------------------------------------------------------------------------
2095 ///
2096 /// @copydetails cpp_kodi_addon_pvr_Defs_Menuhook_PVRMenuhook_Help
2097 ///
2098 virtual PVR_ERROR CallTimerMenuHook(const kodi::addon::PVRMenuhook& menuhook,
2099 const kodi::addon::PVRTimer& item)
2100 {
2101 return PVR_ERROR_NOT_IMPLEMENTED;
2102 }
2103 //----------------------------------------------------------------------------
2104
2105 //============================================================================
2106 /// @brief **Callback to Kodi Function**\n
2107 /// Request Kodi to update it's list of timers.
2108 ///
2109 /// @remarks Only called from addon itself
2110 ///
2111 inline void TriggerTimerUpdate()
2112 {
2113 m_instanceData->toKodi->TriggerTimerUpdate(m_instanceData->toKodi->kodiInstance);
2114 }
2115 //----------------------------------------------------------------------------
2116
2117 ///@}
2118 //--==----==----==----==----==----==----==----==----==----==----==----==----==
2119
2120 //============================================================================
2121 /// @defgroup cpp_kodi_addon_pvr_PowerManagement 7. Power management events (optional)
2122 /// @ingroup cpp_kodi_addon_pvr
2123 /// @brief **Used to notify the pvr addon for power management events**\n
2124 /// Used to allow any energy savings.
2125 ///
2126 ///
2127 ///---------------------------------------------------------------------------
2128 ///
2129 /// **Power management events in interface:**\n
2130 /// Copy this to your project and extend with your parts or leave functions
2131 /// complete away where not used or supported.
2132 ///
2133 /// @copydetails cpp_kodi_addon_pvr_PowerManagement_header_addon_auto_check
2134 /// @copydetails cpp_kodi_addon_pvr_PowerManagement_source_addon_auto_check
2135 ///
2136 ///@{
2137
2138 //============================================================================
2139 /// @brief To notify addon about system sleep
2140 ///
2141 /// @return @ref PVR_ERROR_NO_ERROR If successfully done.
2142 ///
2143 virtual PVR_ERROR OnSystemSleep() { return PVR_ERROR_NOT_IMPLEMENTED; }
2144 //----------------------------------------------------------------------------
2145
2146 //============================================================================
2147 /// @brief To notify addon about system wake up
2148 ///
2149 /// @return @ref PVR_ERROR_NO_ERROR If successfully done.
2150 ///
2151 virtual PVR_ERROR OnSystemWake() { return PVR_ERROR_NOT_IMPLEMENTED; }
2152 //----------------------------------------------------------------------------
2153
2154 //============================================================================
2155 /// @brief To notify addon power saving on system is activated
2156 ///
2157 /// @return @ref PVR_ERROR_NO_ERROR If successfully done.
2158 ///
2159 virtual PVR_ERROR OnPowerSavingActivated() { return PVR_ERROR_NOT_IMPLEMENTED; }
2160 //----------------------------------------------------------------------------
2161
2162 //============================================================================
2163 /// @brief To notify addon power saving on system is deactivated
2164 ///
2165 /// @return @ref PVR_ERROR_NO_ERROR If successfully done.
2166 ///
2167 virtual PVR_ERROR OnPowerSavingDeactivated() { return PVR_ERROR_NOT_IMPLEMENTED; }
2168 //----------------------------------------------------------------------------
2169
2170 ///@}
2171 //--==----==----==----==----==----==----==----==----==----==----==----==----==
2172
2173 //============================================================================
2174 /// @defgroup cpp_kodi_addon_pvr_Streams 8. Inputstream
2175 /// @ingroup cpp_kodi_addon_pvr
2176 /// @brief **PVR Inputstream**\n
2177 /// This includes functions that are used in the PVR inputstream.
2178 ///
2179 /// @warning The parts here will be removed in the future and replaced by the
2180 /// separate @ref cpp_kodi_addon_inputstream "inputstream addon instance".
2181 /// If there is already a possibility, new addons should do it via the
2182 /// inputstream instance.
2183 ///
2184 ///@{
2185
2186 //============================================================================
2187 /// @defgroup cpp_kodi_addon_pvr_Streams_TV 8.1. TV stream
2188 /// @ingroup cpp_kodi_addon_pvr_Streams
2189 /// @brief **PVR TV stream**\n
2190 /// Stream processing regarding live TV.
2191 ///
2192 ///
2193 ///---------------------------------------------------------------------------
2194 ///
2195 /// **TV stream parts in interface:**\n
2196 /// Copy this to your project and extend with your parts or leave functions
2197 /// complete away where not used or supported.
2198 ///
2199 /// @copydetails cpp_kodi_addon_pvr_Streams_TV_header_addon_auto_check
2200 /// @copydetails cpp_kodi_addon_pvr_Streams_TV_source_addon_auto_check
2201 ///
2202 ///@{
2203
2204 //============================================================================
2205 /// @brief Open a live stream on the backend.
2206 ///
2207 /// @param[in] channel The channel to stream.
2208 /// @return True if the stream has been opened successfully, false otherwise.
2209 ///
2210 /// --------------------------------------------------------------------------
2211 ///
2212 /// @copydetails cpp_kodi_addon_pvr_Defs_Channel_PVRChannel_Help
2213 ///
2214 ///
2215 /// --------------------------------------------------------------------------
2216 ///
2217 /// @remarks Required if @ref PVRCapabilities::SetHandlesInputStream() or
2218 /// @ref PVRCapabilities::SetHandlesDemuxing() is set to true.
2219 /// @ref CloseLiveStream() will always be called by Kodi prior to calling this
2220 /// function.
2221 ///
2222 virtual bool OpenLiveStream(const kodi::addon::PVRChannel& channel) { return false; }
2223 //----------------------------------------------------------------------------
2224
2225 //============================================================================
2226 /// @brief Close an open live stream.
2227 ///
2228 /// @remarks Required if @ref PVRCapabilities::SetHandlesInputStream() or
2229 /// @ref PVRCapabilities::SetHandlesDemuxing() is set to true.
2230 ///
2231 virtual void CloseLiveStream() {}
2232 //----------------------------------------------------------------------------
2233
2234 //============================================================================
2235 /// @brief Read from an open live stream.
2236 ///
2237 /// @param[in] pBuffer The buffer to store the data in.
2238 /// @param[in] iBufferSize The amount of bytes to read.
2239 /// @return The amount of bytes that were actually read from the stream.
2240 ///
2241 /// @remarks Required if @ref PVRCapabilities::SetHandlesInputStream() is set
2242 /// to true.
2243 ///
2244 virtual int ReadLiveStream(unsigned char* buffer, unsigned int size) { return 0; }
2245 //----------------------------------------------------------------------------
2246
2247 //============================================================================
2248 /// @brief Seek in a live stream on a backend that supports timeshifting.
2249 ///
2250 /// @param[in] position The position to seek to.
2251 /// @param[in] whence [optional] offset relative to
2252 /// You can set the value of whence to one of three things:
2253 /// | Value | int | Description |
2254 /// |:--------:|:---:|:----------------------------------------------------|
2255 /// | SEEK_SET | 0 | position is relative to the beginning of the file. This is probably what you had in mind anyway, and is the most commonly used value for whence.
2256 /// | SEEK_CUR | 1 | position is relative to the current file pointer position. So, in effect, you can say, "Move to my current position plus 30 bytes," or, "move to my current position minus 20 bytes."
2257 /// | SEEK_END | 2 | position is relative to the end of the file. Just like SEEK_SET except from the other end of the file. Be sure to use negative values for offset if you want to back up from the end of the file, instead of going past the end into oblivion.
2258 ///
2259 /// @return The new position.
2260 ///
2261 /// @remarks Optional, and only used if @ref PVRCapabilities::SetHandlesInputStream()
2262 /// is set to true.
2263 ///
2264 virtual int64_t SeekLiveStream(int64_t position, int whence) { return 0; }
2265 //----------------------------------------------------------------------------
2266
2267 //============================================================================
2268 /// @brief Obtain the length of a live stream.
2269 ///
2270 /// @return The total length of the stream that's currently being read.
2271 ///
2272 /// @remarks Optional, and only used if @ref PVRCapabilities::SetHandlesInputStream()
2273 /// is set to true.
2274 ///
2275 virtual int64_t LengthLiveStream() { return 0; }
2276 //----------------------------------------------------------------------------
2277
2278 //============================================================================
2279 /// @defgroup cpp_kodi_addon_pvr_Streams_TV_Demux 8.1.1. Stream demuxing
2280 /// @ingroup cpp_kodi_addon_pvr_Streams_TV
2281 /// @brief **PVR stream demuxing**\n
2282 /// Read TV streams with own demux within addon.
2283 ///
2284 /// This is only on Live TV streams and only if @ref PVRCapabilities::SetHandlesDemuxing()
2285 /// has been set to "true".
2286 ///
2287 ///
2288 ///---------------------------------------------------------------------------
2289 ///
2290 /// **Stream demuxing parts in interface:**\n
2291 /// Copy this to your project and extend with your parts or leave functions
2292 /// complete away where not used or supported.
2293 ///
2294 /// @copydetails cpp_kodi_addon_pvr_Streams_TV_Demux_header_addon_auto_check
2295 /// @copydetails cpp_kodi_addon_pvr_Streams_TV_Demux_source_addon_auto_check
2296 ///
2297 ///@{
2298
2299 //============================================================================
2300 /// @brief Get the stream properties of the stream that's currently being read.
2301 ///
2302 /// @param[in] properties The properties of the currently playing stream.
2303 /// @return @ref PVR_ERROR_NO_ERROR if the properties have been fetched successfully.
2304 ///
2305 /// @remarks Required, and only used if addon has its own demuxer.
2306 ///
2307 virtual PVR_ERROR GetStreamProperties(std::vector<kodi::addon::PVRStreamProperties>& properties)
2308 {
2309 return PVR_ERROR_NOT_IMPLEMENTED;
2310 }
2311 //----------------------------------------------------------------------------
2312
2313 //============================================================================
2314 /// @brief Read the next packet from the demultiplexer, if there is one.
2315 ///
2316 /// @return The next packet.
2317 /// If there is no next packet, then the add-on should return the packet
2318 /// created by calling @ref AllocateDemuxPacket(0) on the callback.
2319 /// If the stream changed and Kodi's player needs to be reinitialised, then,
2320 /// the add-on should call @ref AllocateDemuxPacket(0) on the callback, and set
2321 /// the streamid to @ref DMX_SPECIALID_STREAMCHANGE and return the value.
2322 /// The add-on should return `nullptr` if an error occurred.
2323 ///
2324 /// @remarks Required, and only used if addon has its own demuxer.
2325 /// Return `nullptr` if this add-on won't provide this function.
2326 ///
2327 virtual DemuxPacket* DemuxRead() { return nullptr; }
2328 //----------------------------------------------------------------------------
2329
2330 //============================================================================
2331 /// @brief Reset the demultiplexer in the add-on.
2332 ///
2333 /// @remarks Required, and only used if addon has its own demuxer.
2334 ///
2335 virtual void DemuxReset() {}
2336 //----------------------------------------------------------------------------
2337
2338 //============================================================================
2339 /// @brief Abort the demultiplexer thread in the add-on.
2340 ///
2341 /// @remarks Required, and only used if addon has its own demuxer.
2342 ///
2343 virtual void DemuxAbort() {}
2344 //----------------------------------------------------------------------------
2345
2346 //============================================================================
2347 /// @brief Flush all data that's currently in the demultiplexer buffer in the
2348 /// add-on.
2349 ///
2350 /// @remarks Required, and only used if addon has its own demuxer.
2351 ///
2352 virtual void DemuxFlush() {}
2353 //----------------------------------------------------------------------------
2354
2355 //============================================================================
2356 /// @brief Notify the pvr addon/demuxer that Kodi wishes to change playback
2357 /// speed.
2358 ///
2359 /// @param[in] speed The requested playback speed
2360 ///
2361 /// @remarks Optional, and only used if addon has its own demuxer.
2362 ///
2363 virtual void SetSpeed(int speed) {}
2364 //----------------------------------------------------------------------------
2365
2366 //============================================================================
2367 /// @brief Notify the pvr addon/demuxer that Kodi wishes to fill demux queue.
2368 ///
2369 /// @param[in] mode The requested filling mode
2370 ///
2371 /// @remarks Optional, and only used if addon has its own demuxer.
2372 ///
2373 virtual void FillBuffer(bool mode) {}
2374 //----------------------------------------------------------------------------
2375
2376 //============================================================================
2377 /// @brief Notify the pvr addon/demuxer that Kodi wishes to seek the stream by
2378 /// time.
2379 ///
2380 /// @param[in] time The absolute time since stream start
2381 /// @param[in] backwards True to seek to keyframe BEFORE time, else AFTER
2382 /// @param[in] startpts can be updated to point to where display should start
2383 /// @return True if the seek operation was possible
2384 ///
2385 /// @remarks Optional, and only used if addon has its own demuxer.
2386 /// Return False if this add-on won't provide this function.
2387 ///
2388 virtual bool SeekTime(double time, bool backwards, double& startpts) { return false; }
2389 //----------------------------------------------------------------------------
2390
2391 //============================================================================
2392 /// @brief **Callback to Kodi Function**\n
2393 /// Get the codec id used by Kodi.
2394 ///
2395 /// @param[in] codecName The name of the codec
2396 /// @return The codec_id, or a codec_id with 0 values when not supported
2397 ///
2398 /// @remarks Only called from addon itself
2399 ///
2400 inline PVRCodec GetCodecByName(const std::string& codecName) const
2401 {
2402 return PVRCodec(m_instanceData->toKodi->GetCodecByName(m_instanceData->toKodi->kodiInstance,
2403 codecName.c_str()));
2404 }
2405 //----------------------------------------------------------------------------
2406
2407 //============================================================================
2408 /// @brief **Callback to Kodi Function**\n
2409 /// Allocate a demux packet. Free with @ref FreeDemuxPacket().
2410 ///
2411 /// @param[in] iDataSize The size of the data that will go into the packet
2412 /// @return The allocated packet
2413 ///
2414 /// @remarks Only called from addon itself
2415 ///
2416 inline DemuxPacket* AllocateDemuxPacket(int iDataSize)
2417 {
2418 return m_instanceData->toKodi->AllocateDemuxPacket(m_instanceData->toKodi->kodiInstance,
2419 iDataSize);
2420 }
2421 //----------------------------------------------------------------------------
2422
2423 //============================================================================
2424 /// @brief **Callback to Kodi Function**\n
2425 /// Free a packet that was allocated with @ref AllocateDemuxPacket().
2426 ///
2427 /// @param[in] pPacket The packet to free
2428 ///
2429 /// @remarks Only called from addon itself.
2430 ///
2431 inline void FreeDemuxPacket(DemuxPacket* pPacket)
2432 {
2433 m_instanceData->toKodi->FreeDemuxPacket(m_instanceData->toKodi->kodiInstance, pPacket);
2434 }
2435 //----------------------------------------------------------------------------
2436 ///@}
2437
2438 ///@}
2439 //--==----==----==----==----==----==----==----==----==----==----==----==----==
2440
2441 //============================================================================
2442 /// @defgroup cpp_kodi_addon_pvr_Streams_Recording 8.2. Recording stream
2443 /// @ingroup cpp_kodi_addon_pvr_Streams
2444 /// @brief **PVR Recording stream**\n
2445 /// Stream processing regarding recordings.
2446 ///
2447 /// @note Demuxing is not possible with the recordings.
2448 ///
2449 ///
2450 ///---------------------------------------------------------------------------
2451 ///
2452 /// **Recording stream parts in interface:**\n
2453 /// Copy this to your project and extend with your parts or leave functions
2454 /// complete away where not used or supported.
2455 ///
2456 /// @copydetails cpp_kodi_addon_pvr_Streams_Recording_header_addon_auto_check
2457 /// @copydetails cpp_kodi_addon_pvr_Streams_Recording_source_addon_auto_check
2458 ///
2459 ///@{
2460
2461 //============================================================================
2462 /// @brief Open a stream to a recording on the backend.
2463 ///
2464 /// @param[in] recording The recording to open.
2465 /// @return True if the stream has been opened successfully, false otherwise.
2466 ///
2467 /// @remarks Optional, and only used if @ref PVRCapabilities::SetSupportsRecordings()
2468 /// is set to true. @ref CloseRecordedStream() will always be called by Kodi
2469 /// prior to calling this function.
2470 ///
2471 virtual bool OpenRecordedStream(const kodi::addon::PVRRecording& recording) { return false; }
2472 //----------------------------------------------------------------------------
2473
2474 //============================================================================
2475 /// @brief Close an open stream from a recording.
2476 ///
2477 /// @remarks Optional, and only used if @ref PVRCapabilities::SetSupportsRecordings()
2478 /// is set to true.
2479 ///
2480 virtual void CloseRecordedStream() {}
2481 //----------------------------------------------------------------------------
2482
2483 //============================================================================
2484 /// @brief Read from a recording.
2485 ///
2486 /// @param[in] buffer The buffer to store the data in.
2487 /// @param[in] size The amount of bytes to read.
2488 /// @return The amount of bytes that were actually read from the stream.
2489 ///
2490 /// @remarks Optional, and only used if @ref PVRCapabilities::SetSupportsRecordings()
2491 /// is set to true.
2492 ///
2493 virtual int ReadRecordedStream(unsigned char* buffer, unsigned int size) { return 0; }
2494 //----------------------------------------------------------------------------
2495
2496 //============================================================================
2497 /// @brief Seek in a recorded stream.
2498 ///
2499 /// @param[in] position The position to seek to.
2500 /// @param[in] whence [optional] offset relative to
2501 /// You can set the value of whence to one of three things:
2502 /// | Value | int | Description |
2503 /// |:--------:|:---:|:----------------------------------------------------|
2504 /// | SEEK_SET | 0 | position is relative to the beginning of the file. This is probably what you had in mind anyway, and is the most commonly used value for whence.
2505 /// | SEEK_CUR | 1 | position is relative to the current file pointer position. So, in effect, you can say, "Move to my current position plus 30 bytes," or, "move to my current position minus 20 bytes."
2506 /// | SEEK_END | 2 | position is relative to the end of the file. Just like SEEK_SET except from the other end of the file. Be sure to use negative values for offset if you want to back up from the end of the file, instead of going past the end into oblivion.
2507 ///
2508 /// @return The new position.
2509 ///
2510 /// @remarks Optional, and only used if @ref PVRCapabilities::SetSupportsRecordings()
2511 /// is set to true.
2512 ///
2513 virtual int64_t SeekRecordedStream(int64_t position, int whence) { return 0; }
2514 //----------------------------------------------------------------------------
2515
2516 //============================================================================
2517 /// @brief Obtain the length of a recorded stream.
2518 ///
2519 /// @return The total length of the stream that's currently being read.
2520 ///
2521 /// @remarks Optional, and only used if @ref PVRCapabilities::SetSupportsRecordings()
2522 /// is true (=> @ref ReadRecordedStream).
2523 ///
2524 virtual int64_t LengthRecordedStream() { return 0; }
2525 //----------------------------------------------------------------------------
2526
2527 ///@}
2528 //--==----==----==----==----==----==----==----==----==----==----==----==----==
2529
2530 //============================================================================
2531 /// @defgroup cpp_kodi_addon_pvr_Streams_Various 8.3. Various functions
2532 /// @ingroup cpp_kodi_addon_pvr_Streams
2533 /// @brief **Various other PVR stream related functions**\n
2534 /// These apply to all other groups in inputstream and are therefore declared
2535 /// as several.
2536 ///
2537 ///
2538 ///---------------------------------------------------------------------------
2539 ///
2540 /// **Various stream parts in interface:**\n
2541 /// Copy this to your project and extend with your parts or leave functions
2542 /// complete away where not used or supported.
2543 ///
2544 /// @copydetails cpp_kodi_addon_pvr_Streams_Various_header_addon_auto_check
2545 /// @copydetails cpp_kodi_addon_pvr_Streams_Various_source_addon_auto_check
2546 ///
2547 ///@{
2548
2549 //============================================================================
2550 ///
2551 /// @brief Check if the backend support pausing the currently playing stream.
2552 ///
2553 /// This will enable/disable the pause button in Kodi based on the return
2554 /// value.
2555 ///
2556 /// @return false if the PVR addon/backend does not support pausing, true if
2557 /// possible
2558 ///
2559 virtual bool CanPauseStream() { return false; }
2560 //----------------------------------------------------------------------------
2561
2562 //============================================================================
2563 ///
2564 /// @brief Check if the backend supports seeking for the currently playing
2565 /// stream.
2566 ///
2567 /// This will enable/disable the rewind/forward buttons in Kodi based on the
2568 /// return value.
2569 ///
2570 /// @return false if the PVR addon/backend does not support seeking, true if
2571 /// possible
2572 ///
2573 virtual bool CanSeekStream() { return false; }
2574 //----------------------------------------------------------------------------
2575
2576 //============================================================================
2577 ///
2578 /// @brief Notify the pvr addon that Kodi (un)paused the currently playing
2579 /// stream.
2580 ///
2581 /// @param[in] paused To inform by `true` is paused and with `false` playing
2582 ///
2583 virtual void PauseStream(bool paused) {}
2584 //----------------------------------------------------------------------------
2585
2586 //============================================================================
2587 ///
2588 /// @brief Check for real-time streaming.
2589 ///
2590 /// @return true if current stream is real-time
2591 ///
2592 virtual bool IsRealTimeStream() { return false; }
2593 //----------------------------------------------------------------------------
2594
2595 //============================================================================
2596 ///
2597 /// @brief Get stream times.
2598 ///
2599 /// @param[out] times A pointer to the data to be filled by the implementation.
2600 /// @return @ref PVR_ERROR_NO_ERROR on success.
2601 ///
2602 virtual PVR_ERROR GetStreamTimes(kodi::addon::PVRStreamTimes& times)
2603 {
2604 return PVR_ERROR_NOT_IMPLEMENTED;
2605 }
2606 //----------------------------------------------------------------------------
2607
2608 //============================================================================
2609 ///
2610 /// @brief Obtain the chunk size to use when reading streams.
2611 ///
2612 /// @param[out] chunksize must be filled with the chunk size in bytes.
2613 /// @return @ref PVR_ERROR_NO_ERROR if the chunk size has been fetched successfully.
2614 ///
2615 /// @remarks Optional, and only used if not reading from demuxer (=> @ref DemuxRead) and
2616 /// @ref PVRCapabilities::SetSupportsRecordings() is true (=> @ref ReadRecordedStream) or
2617 /// @ref PVRCapabilities::SetHandlesInputStream() is true (=> @ref ReadLiveStream).
2618 ///
2619 virtual PVR_ERROR GetStreamReadChunkSize(int& chunksize) { return PVR_ERROR_NOT_IMPLEMENTED; }
2620 //----------------------------------------------------------------------------
2621
2622 ///@}
2623 //--==----==----==----==----==----==----==----==----==----==----==----==----==
2624
2625private:
2626 void SetAddonStruct(KODI_HANDLE instance, const std::string& kodiVersion)
2627 {
2628 if (instance == nullptr)
2629 throw std::logic_error("kodi::addon::CInstancePVRClient: Creation with empty addon "
2630 "structure not allowed, table must be given from Kodi!");
2631
2632 m_instanceData = static_cast<AddonInstance_PVR*>(instance);
2633 m_instanceData->toAddon->addonInstance = this;
2634 //--==----==----==----==----==----==----==----==----==----==----==----==----==
2635 m_instanceData->toAddon->GetCapabilities = ADDON_GetCapabilities;
2636 m_instanceData->toAddon->GetConnectionString = ADDON_GetConnectionString;
2637 m_instanceData->toAddon->GetBackendName = ADDON_GetBackendName;
2638 m_instanceData->toAddon->GetBackendVersion = ADDON_GetBackendVersion;
2639 m_instanceData->toAddon->GetBackendHostname = ADDON_GetBackendHostname;
2640 m_instanceData->toAddon->GetDriveSpace = ADDON_GetDriveSpace;
2641 m_instanceData->toAddon->CallSettingsMenuHook = ADDON_CallSettingsMenuHook;
2642 //--==----==----==----==----==----==----==----==----==----==----==----==----==
2643 m_instanceData->toAddon->GetChannelsAmount = ADDON_GetChannelsAmount;
2644 m_instanceData->toAddon->GetChannels = ADDON_GetChannels;
2645 m_instanceData->toAddon->GetChannelStreamProperties = ADDON_GetChannelStreamProperties;
2646 m_instanceData->toAddon->GetSignalStatus = ADDON_GetSignalStatus;
2647 m_instanceData->toAddon->GetDescrambleInfo = ADDON_GetDescrambleInfo;
2648 //--==----==----==----==----==----==----==----==----==----==----==----==----==
2649 m_instanceData->toAddon->GetChannelGroupsAmount = ADDON_GetChannelGroupsAmount;
2650 m_instanceData->toAddon->GetChannelGroups = ADDON_GetChannelGroups;
2651 m_instanceData->toAddon->GetChannelGroupMembers = ADDON_GetChannelGroupMembers;
2652 //--==----==----==----==----==----==----==----==----==----==----==----==----==
2653 m_instanceData->toAddon->DeleteChannel = ADDON_DeleteChannel;
2654 m_instanceData->toAddon->RenameChannel = ADDON_RenameChannel;
2655 m_instanceData->toAddon->OpenDialogChannelSettings = ADDON_OpenDialogChannelSettings;
2656 m_instanceData->toAddon->OpenDialogChannelAdd = ADDON_OpenDialogChannelAdd;
2657 m_instanceData->toAddon->OpenDialogChannelScan = ADDON_OpenDialogChannelScan;
2658 m_instanceData->toAddon->CallChannelMenuHook = ADDON_CallChannelMenuHook;
2659 //--==----==----==----==----==----==----==----==----==----==----==----==----==
2660 m_instanceData->toAddon->GetEPGForChannel = ADDON_GetEPGForChannel;
2661 m_instanceData->toAddon->IsEPGTagRecordable = ADDON_IsEPGTagRecordable;
2662 m_instanceData->toAddon->IsEPGTagPlayable = ADDON_IsEPGTagPlayable;
2663 m_instanceData->toAddon->GetEPGTagEdl = ADDON_GetEPGTagEdl;
2664 m_instanceData->toAddon->GetEPGTagStreamProperties = ADDON_GetEPGTagStreamProperties;
2665 m_instanceData->toAddon->SetEPGTimeFrame = ADDON_SetEPGTimeFrame;
2666 m_instanceData->toAddon->CallEPGMenuHook = ADDON_CallEPGMenuHook;
2667 //--==----==----==----==----==----==----==----==----==----==----==----==----==
2668 m_instanceData->toAddon->GetRecordingsAmount = ADDON_GetRecordingsAmount;
2669 m_instanceData->toAddon->GetRecordings = ADDON_GetRecordings;
2670 m_instanceData->toAddon->DeleteRecording = ADDON_DeleteRecording;
2671 m_instanceData->toAddon->UndeleteRecording = ADDON_UndeleteRecording;
2672 m_instanceData->toAddon->DeleteAllRecordingsFromTrash = ADDON_DeleteAllRecordingsFromTrash;
2673 m_instanceData->toAddon->RenameRecording = ADDON_RenameRecording;
2674 m_instanceData->toAddon->SetRecordingLifetime = ADDON_SetRecordingLifetime;
2675 m_instanceData->toAddon->SetRecordingPlayCount = ADDON_SetRecordingPlayCount;
2676 m_instanceData->toAddon->SetRecordingLastPlayedPosition = ADDON_SetRecordingLastPlayedPosition;
2677 m_instanceData->toAddon->GetRecordingLastPlayedPosition = ADDON_GetRecordingLastPlayedPosition;
2678 m_instanceData->toAddon->GetRecordingEdl = ADDON_GetRecordingEdl;
2679 m_instanceData->toAddon->GetRecordingSize = ADDON_GetRecordingSize;
2680 m_instanceData->toAddon->GetRecordingStreamProperties = ADDON_GetRecordingStreamProperties;
2681 m_instanceData->toAddon->CallRecordingMenuHook = ADDON_CallRecordingMenuHook;
2682 //--==----==----==----==----==----==----==----==----==----==----==----==----==
2683 m_instanceData->toAddon->GetTimerTypes = ADDON_GetTimerTypes;
2684 m_instanceData->toAddon->GetTimersAmount = ADDON_GetTimersAmount;
2685 m_instanceData->toAddon->GetTimers = ADDON_GetTimers;
2686 m_instanceData->toAddon->AddTimer = ADDON_AddTimer;
2687 m_instanceData->toAddon->DeleteTimer = ADDON_DeleteTimer;
2688 m_instanceData->toAddon->UpdateTimer = ADDON_UpdateTimer;
2689 m_instanceData->toAddon->CallTimerMenuHook = ADDON_CallTimerMenuHook;
2690 //--==----==----==----==----==----==----==----==----==----==----==----==----==
2691 m_instanceData->toAddon->OnSystemSleep = ADDON_OnSystemSleep;
2692 m_instanceData->toAddon->OnSystemWake = ADDON_OnSystemWake;
2693 m_instanceData->toAddon->OnPowerSavingActivated = ADDON_OnPowerSavingActivated;
2694 m_instanceData->toAddon->OnPowerSavingDeactivated = ADDON_OnPowerSavingDeactivated;
2695 //--==----==----==----==----==----==----==----==----==----==----==----==----==
2696 m_instanceData->toAddon->OpenLiveStream = ADDON_OpenLiveStream;
2697 m_instanceData->toAddon->CloseLiveStream = ADDON_CloseLiveStream;
2698 m_instanceData->toAddon->ReadLiveStream = ADDON_ReadLiveStream;
2699 m_instanceData->toAddon->SeekLiveStream = ADDON_SeekLiveStream;
2700 m_instanceData->toAddon->LengthLiveStream = ADDON_LengthLiveStream;
2701 m_instanceData->toAddon->GetStreamProperties = ADDON_GetStreamProperties;
2702 m_instanceData->toAddon->GetStreamReadChunkSize = ADDON_GetStreamReadChunkSize;
2703 m_instanceData->toAddon->IsRealTimeStream = ADDON_IsRealTimeStream;
2704 //--==----==----==----==----==----==----==----==----==----==----==----==----==
2705 m_instanceData->toAddon->OpenRecordedStream = ADDON_OpenRecordedStream;
2706 m_instanceData->toAddon->CloseRecordedStream = ADDON_CloseRecordedStream;
2707 m_instanceData->toAddon->ReadRecordedStream = ADDON_ReadRecordedStream;
2708 m_instanceData->toAddon->SeekRecordedStream = ADDON_SeekRecordedStream;
2709 m_instanceData->toAddon->LengthRecordedStream = ADDON_LengthRecordedStream;
2710 //--==----==----==----==----==----==----==----==----==----==----==----==----==
2711 m_instanceData->toAddon->DemuxReset = ADDON_DemuxReset;
2712 m_instanceData->toAddon->DemuxAbort = ADDON_DemuxAbort;
2713 m_instanceData->toAddon->DemuxFlush = ADDON_DemuxFlush;
2714 m_instanceData->toAddon->DemuxRead = ADDON_DemuxRead;
2715 //--==----==----==----==----==----==----==----==----==----==----==----==----==
2716 m_instanceData->toAddon->CanPauseStream = ADDON_CanPauseStream;
2717 m_instanceData->toAddon->PauseStream = ADDON_PauseStream;
2718 m_instanceData->toAddon->CanSeekStream = ADDON_CanSeekStream;
2719 m_instanceData->toAddon->SeekTime = ADDON_SeekTime;
2720 m_instanceData->toAddon->SetSpeed = ADDON_SetSpeed;
2721 m_instanceData->toAddon->FillBuffer = ADDON_FillBuffer;
2722 m_instanceData->toAddon->GetStreamTimes = ADDON_GetStreamTimes;
2723 }
2724
2725 inline static PVR_ERROR ADDON_GetCapabilities(const AddonInstance_PVR* instance,
2726 PVR_ADDON_CAPABILITIES* capabilities)
2727 {
2728 PVRCapabilities cppCapabilities(capabilities);
2729 return static_cast<CInstancePVRClient*>(instance->toAddon->addonInstance)
2730 ->GetCapabilities(cppCapabilities);
2731 }
2732
2733 inline static PVR_ERROR ADDON_GetBackendName(const AddonInstance_PVR* instance,
2734 char* str,
2735 int memSize)
2736 {
2737 std::string backendName;
2738 PVR_ERROR err = static_cast<CInstancePVRClient*>(instance->toAddon->addonInstance)
2739 ->GetBackendName(backendName);
2740 if (err == PVR_ERROR_NO_ERROR)
2741 strncpy(str, backendName.c_str(), memSize);
2742 return err;
2743 }
2744
2745 inline static PVR_ERROR ADDON_GetBackendVersion(const AddonInstance_PVR* instance,
2746 char* str,
2747 int memSize)
2748 {
2749 std::string backendVersion;
2750 PVR_ERROR err = static_cast<CInstancePVRClient*>(instance->toAddon->addonInstance)
2751 ->GetBackendVersion(backendVersion);
2752 if (err == PVR_ERROR_NO_ERROR)
2753 strncpy(str, backendVersion.c_str(), memSize);
2754 return err;
2755 }
2756
2757 inline static PVR_ERROR ADDON_GetBackendHostname(const AddonInstance_PVR* instance,
2758 char* str,
2759 int memSize)
2760 {
2761 std::string backendHostname;
2762 PVR_ERROR err = static_cast<CInstancePVRClient*>(instance->toAddon->addonInstance)
2763 ->GetBackendHostname(backendHostname);
2764 if (err == PVR_ERROR_NO_ERROR)
2765 strncpy(str, backendHostname.c_str(), memSize);
2766 return err;
2767 }
2768
2769 inline static PVR_ERROR ADDON_GetConnectionString(const AddonInstance_PVR* instance,
2770 char* str,
2771 int memSize)
2772 {
2773 std::string connectionString;
2774 PVR_ERROR err = static_cast<CInstancePVRClient*>(instance->toAddon->addonInstance)
2775 ->GetConnectionString(connectionString);
2776 if (err == PVR_ERROR_NO_ERROR)
2777 strncpy(str, connectionString.c_str(), memSize);
2778 return err;
2779 }
2780
2781 inline static PVR_ERROR ADDON_GetDriveSpace(const AddonInstance_PVR* instance,
2782 uint64_t* total,
2783 uint64_t* used)
2784 {
2785 return static_cast<CInstancePVRClient*>(instance->toAddon->addonInstance)
2786 ->GetDriveSpace(*total, *used);
2787 }
2788
2789 inline static PVR_ERROR ADDON_CallSettingsMenuHook(const AddonInstance_PVR* instance,
2790 const PVR_MENUHOOK* menuhook)
2791 {
2792 return static_cast<CInstancePVRClient*>(instance->toAddon->addonInstance)
2793 ->CallSettingsMenuHook(menuhook);
2794 }
2795
2796 //--==----==----==----==----==----==----==----==----==----==----==----==----==
2797
2798 inline static PVR_ERROR ADDON_GetChannelsAmount(const AddonInstance_PVR* instance, int* amount)
2799 {
2800 return static_cast<CInstancePVRClient*>(instance->toAddon->addonInstance)
2801 ->GetChannelsAmount(*amount);
2802 }
2803
2804 inline static PVR_ERROR ADDON_GetChannels(const AddonInstance_PVR* instance,
2805 ADDON_HANDLE handle,
2806 bool radio)
2807 {
2808 PVRChannelsResultSet result(instance, handle);
2809 return static_cast<CInstancePVRClient*>(instance->toAddon->addonInstance)
2810 ->GetChannels(radio, result);
2811 }
2812
2813 inline static PVR_ERROR ADDON_GetChannelStreamProperties(const AddonInstance_PVR* instance,
2814 const PVR_CHANNEL* channel,
2815 PVR_NAMED_VALUE* properties,
2816 unsigned int* propertiesCount)
2817 {
2818 *propertiesCount = 0;
2819 std::vector<PVRStreamProperty> propertiesList;
2820 PVR_ERROR error = static_cast<CInstancePVRClient*>(instance->toAddon->addonInstance)
2821 ->GetChannelStreamProperties(channel, propertiesList);
2822 if (error == PVR_ERROR_NO_ERROR)
2823 {
2824 for (const auto& property : propertiesList)
2825 {
2826 strncpy(properties[*propertiesCount].strName, property.GetCStructure()->strName,
2827 sizeof(properties[*propertiesCount].strName) - 1);
2828 strncpy(properties[*propertiesCount].strValue, property.GetCStructure()->strValue,
2829 sizeof(properties[*propertiesCount].strValue) - 1);
2830 ++*propertiesCount;
2831 if (*propertiesCount > STREAM_MAX_PROPERTY_COUNT)
2832 break;
2833 }
2834 }
2835 return error;
2836 }
2837
2838 inline static PVR_ERROR ADDON_GetSignalStatus(const AddonInstance_PVR* instance,
2839 int channelUid,
2840 PVR_SIGNAL_STATUS* signalStatus)
2841 {
2842 PVRSignalStatus cppSignalStatus(signalStatus);
2843 return static_cast<CInstancePVRClient*>(instance->toAddon->addonInstance)
2844 ->GetSignalStatus(channelUid, cppSignalStatus);
2845 }
2846
2847 inline static PVR_ERROR ADDON_GetDescrambleInfo(const AddonInstance_PVR* instance,
2848 int channelUid,
2849 PVR_DESCRAMBLE_INFO* descrambleInfo)
2850 {
2851 PVRDescrambleInfo cppDescrambleInfo(descrambleInfo);
2852 return static_cast<CInstancePVRClient*>(instance->toAddon->addonInstance)
2853 ->GetDescrambleInfo(channelUid, cppDescrambleInfo);
2854 }
2855
2856 //--==----==----==----==----==----==----==----==----==----==----==----==----==
2857
2858 inline static PVR_ERROR ADDON_GetChannelGroupsAmount(const AddonInstance_PVR* instance,
2859 int* amount)
2860 {
2861 return static_cast<CInstancePVRClient*>(instance->toAddon->addonInstance)
2862 ->GetChannelGroupsAmount(*amount);
2863 }
2864
2865 inline static PVR_ERROR ADDON_GetChannelGroups(const AddonInstance_PVR* instance,
2866 ADDON_HANDLE handle,
2867 bool radio)
2868 {
2869 PVRChannelGroupsResultSet result(instance, handle);
2870 return static_cast<CInstancePVRClient*>(instance->toAddon->addonInstance)
2871 ->GetChannelGroups(radio, result);
2872 }
2873
2874 inline static PVR_ERROR ADDON_GetChannelGroupMembers(const AddonInstance_PVR* instance,
2875 ADDON_HANDLE handle,
2876 const PVR_CHANNEL_GROUP* group)
2877 {
2878 PVRChannelGroupMembersResultSet result(instance, handle);
2879 return static_cast<CInstancePVRClient*>(instance->toAddon->addonInstance)
2880 ->GetChannelGroupMembers(group, result);
2881 }
2882
2883 //--==----==----==----==----==----==----==----==----==----==----==----==----==
2884
2885 inline static PVR_ERROR ADDON_DeleteChannel(const AddonInstance_PVR* instance,
2886 const PVR_CHANNEL* channel)
2887 {
2888 return static_cast<CInstancePVRClient*>(instance->toAddon->addonInstance)
2889 ->DeleteChannel(channel);
2890 }
2891
2892 inline static PVR_ERROR ADDON_RenameChannel(const AddonInstance_PVR* instance,
2893 const PVR_CHANNEL* channel)
2894 {
2895 return static_cast<CInstancePVRClient*>(instance->toAddon->addonInstance)
2896 ->RenameChannel(channel);
2897 }
2898
2899 inline static PVR_ERROR ADDON_OpenDialogChannelSettings(const AddonInstance_PVR* instance,
2900 const PVR_CHANNEL* channel)
2901 {
2902 return static_cast<CInstancePVRClient*>(instance->toAddon->addonInstance)
2903 ->OpenDialogChannelSettings(channel);
2904 }
2905
2906 inline static PVR_ERROR ADDON_OpenDialogChannelAdd(const AddonInstance_PVR* instance,
2907 const PVR_CHANNEL* channel)
2908 {
2909 return static_cast<CInstancePVRClient*>(instance->toAddon->addonInstance)
2910 ->OpenDialogChannelAdd(channel);
2911 }
2912
2913 inline static PVR_ERROR ADDON_OpenDialogChannelScan(const AddonInstance_PVR* instance)
2914 {
2915 return static_cast<CInstancePVRClient*>(instance->toAddon->addonInstance)
2916 ->OpenDialogChannelScan();
2917 }
2918
2919 inline static PVR_ERROR ADDON_CallChannelMenuHook(const AddonInstance_PVR* instance,
2920 const PVR_MENUHOOK* menuhook,
2921 const PVR_CHANNEL* channel)
2922 {
2923 return static_cast<CInstancePVRClient*>(instance->toAddon->addonInstance)
2924 ->CallChannelMenuHook(menuhook, channel);
2925 }
2926
2927 //--==----==----==----==----==----==----==----==----==----==----==----==----==
2928
2929 inline static PVR_ERROR ADDON_GetEPGForChannel(const AddonInstance_PVR* instance,
2930 ADDON_HANDLE handle,
2931 int channelUid,
2932 time_t start,
2933 time_t end)
2934 {
2935 PVREPGTagsResultSet result(instance, handle);
2936 return static_cast<CInstancePVRClient*>(instance->toAddon->addonInstance)
2937 ->GetEPGForChannel(channelUid, start, end, result);
2938 }
2939
2940 inline static PVR_ERROR ADDON_IsEPGTagRecordable(const AddonInstance_PVR* instance,
2941 const EPG_TAG* tag,
2942 bool* isRecordable)
2943 {
2944 return static_cast<CInstancePVRClient*>(instance->toAddon->addonInstance)
2945 ->IsEPGTagRecordable(tag, *isRecordable);
2946 }
2947
2948 inline static PVR_ERROR ADDON_IsEPGTagPlayable(const AddonInstance_PVR* instance,
2949 const EPG_TAG* tag,
2950 bool* isPlayable)
2951 {
2952 return static_cast<CInstancePVRClient*>(instance->toAddon->addonInstance)
2953 ->IsEPGTagPlayable(tag, *isPlayable);
2954 }
2955
2956 inline static PVR_ERROR ADDON_GetEPGTagEdl(const AddonInstance_PVR* instance,
2957 const EPG_TAG* tag,
2958 PVR_EDL_ENTRY* edl,
2959 int* size)
2960 {
2961 *size = 0;
2962 std::vector<PVREDLEntry> edlList;
2963 PVR_ERROR error = static_cast<CInstancePVRClient*>(instance->toAddon->addonInstance)
2964 ->GetEPGTagEdl(tag, edlList);
2965 if (error == PVR_ERROR_NO_ERROR)
2966 {
2967 for (const auto& edlEntry : edlList)
2968 {
2969 edl[*size] = *edlEntry;
2970 ++*size;
2971 }
2972 }
2973 return error;
2974 }
2975
2976 inline static PVR_ERROR ADDON_GetEPGTagStreamProperties(const AddonInstance_PVR* instance,
2977 const EPG_TAG* tag,
2978 PVR_NAMED_VALUE* properties,
2979 unsigned int* propertiesCount)
2980 {
2981 *propertiesCount = 0;
2982 std::vector<PVRStreamProperty> propertiesList;
2983 PVR_ERROR error = static_cast<CInstancePVRClient*>(instance->toAddon->addonInstance)
2984 ->GetEPGTagStreamProperties(tag, propertiesList);
2985 if (error == PVR_ERROR_NO_ERROR)
2986 {
2987 for (const auto& property : propertiesList)
2988 {
2989 strncpy(properties[*propertiesCount].strName, property.GetCStructure()->strName,
2990 sizeof(properties[*propertiesCount].strName) - 1);
2991 strncpy(properties[*propertiesCount].strValue, property.GetCStructure()->strValue,
2992 sizeof(properties[*propertiesCount].strValue) - 1);
2993 ++*propertiesCount;
2994 if (*propertiesCount > STREAM_MAX_PROPERTY_COUNT)
2995 break;
2996 }
2997 }
2998 return error;
2999 }
3000
3001 inline static PVR_ERROR ADDON_SetEPGTimeFrame(const AddonInstance_PVR* instance, int days)
3002 {
3003 return static_cast<CInstancePVRClient*>(instance->toAddon->addonInstance)
3004 ->SetEPGTimeFrame(days);
3005 }
3006
3007 inline static PVR_ERROR ADDON_CallEPGMenuHook(const AddonInstance_PVR* instance,
3008 const PVR_MENUHOOK* menuhook,
3009 const EPG_TAG* tag)
3010 {
3011 return static_cast<CInstancePVRClient*>(instance->toAddon->addonInstance)
3012 ->CallEPGMenuHook(menuhook, tag);
3013 }
3014
3015 //--==----==----==----==----==----==----==----==----==----==----==----==----==
3016
3017 inline static PVR_ERROR ADDON_GetRecordingsAmount(const AddonInstance_PVR* instance,
3018 bool deleted,
3019 int* amount)
3020 {
3021 return static_cast<CInstancePVRClient*>(instance->toAddon->addonInstance)
3022 ->GetRecordingsAmount(deleted, *amount);
3023 }
3024
3025 inline static PVR_ERROR ADDON_GetRecordings(const AddonInstance_PVR* instance,
3026 ADDON_HANDLE handle,
3027 bool deleted)
3028 {
3029 PVRRecordingsResultSet result(instance, handle);
3030 return static_cast<CInstancePVRClient*>(instance->toAddon->addonInstance)
3031 ->GetRecordings(deleted, result);
3032 }
3033
3034 inline static PVR_ERROR ADDON_DeleteRecording(const AddonInstance_PVR* instance,
3035 const PVR_RECORDING* recording)
3036 {
3037 return static_cast<CInstancePVRClient*>(instance->toAddon->addonInstance)
3038 ->DeleteRecording(recording);
3039 }
3040
3041 inline static PVR_ERROR ADDON_UndeleteRecording(const AddonInstance_PVR* instance,
3042 const PVR_RECORDING* recording)
3043 {
3044 return static_cast<CInstancePVRClient*>(instance->toAddon->addonInstance)
3045 ->UndeleteRecording(recording);
3046 }
3047
3048 inline static PVR_ERROR ADDON_DeleteAllRecordingsFromTrash(const AddonInstance_PVR* instance)
3049 {
3050 return static_cast<CInstancePVRClient*>(instance->toAddon->addonInstance)
3051 ->DeleteAllRecordingsFromTrash();
3052 }
3053
3054 inline static PVR_ERROR ADDON_RenameRecording(const AddonInstance_PVR* instance,
3055 const PVR_RECORDING* recording)
3056 {
3057 return static_cast<CInstancePVRClient*>(instance->toAddon->addonInstance)
3058 ->RenameRecording(recording);
3059 }
3060
3061 inline static PVR_ERROR ADDON_SetRecordingLifetime(const AddonInstance_PVR* instance,
3062 const PVR_RECORDING* recording)
3063 {
3064 return static_cast<CInstancePVRClient*>(instance->toAddon->addonInstance)
3065 ->SetRecordingLifetime(recording);
3066 }
3067
3068 inline static PVR_ERROR ADDON_SetRecordingPlayCount(const AddonInstance_PVR* instance,
3069 const PVR_RECORDING* recording,
3070 int count)
3071 {
3072 return static_cast<CInstancePVRClient*>(instance->toAddon->addonInstance)
3073 ->SetRecordingPlayCount(recording, count);
3074 }
3075
3076 inline static PVR_ERROR ADDON_SetRecordingLastPlayedPosition(const AddonInstance_PVR* instance,
3077 const PVR_RECORDING* recording,
3078 int lastplayedposition)
3079 {
3080 return static_cast<CInstancePVRClient*>(instance->toAddon->addonInstance)
3081 ->SetRecordingLastPlayedPosition(recording, lastplayedposition);
3082 }
3083
3084 inline static PVR_ERROR ADDON_GetRecordingLastPlayedPosition(const AddonInstance_PVR* instance,
3085 const PVR_RECORDING* recording,
3086 int* position)
3087 {
3088 return static_cast<CInstancePVRClient*>(instance->toAddon->addonInstance)
3089 ->GetRecordingLastPlayedPosition(recording, *position);
3090 }
3091
3092 inline static PVR_ERROR ADDON_GetRecordingEdl(const AddonInstance_PVR* instance,
3093 const PVR_RECORDING* recording,
3094 PVR_EDL_ENTRY* edl,
3095 int* size)
3096 {
3097 *size = 0;
3098 std::vector<PVREDLEntry> edlList;
3099 PVR_ERROR error = static_cast<CInstancePVRClient*>(instance->toAddon->addonInstance)
3100 ->GetRecordingEdl(recording, edlList);
3101 if (error == PVR_ERROR_NO_ERROR)
3102 {
3103 for (const auto& edlEntry : edlList)
3104 {
3105 edl[*size] = *edlEntry;
3106 ++*size;
3107 }
3108 }
3109 return error;
3110 }
3111
3112 inline static PVR_ERROR ADDON_GetRecordingSize(const AddonInstance_PVR* instance,
3113 const PVR_RECORDING* recording,
3114 int64_t* size)
3115 {
3116 return static_cast<CInstancePVRClient*>(instance->toAddon->addonInstance)
3117 ->GetRecordingSize(recording, *size);
3118 }
3119
3120 inline static PVR_ERROR ADDON_GetRecordingStreamProperties(const AddonInstance_PVR* instance,
3121 const PVR_RECORDING* recording,
3122 PVR_NAMED_VALUE* properties,
3123 unsigned int* propertiesCount)
3124 {
3125 *propertiesCount = 0;
3126 std::vector<PVRStreamProperty> propertiesList;
3127 PVR_ERROR error = static_cast<CInstancePVRClient*>(instance->toAddon->addonInstance)
3128 ->GetRecordingStreamProperties(recording, propertiesList);
3129 if (error == PVR_ERROR_NO_ERROR)
3130 {
3131 for (const auto& property : propertiesList)
3132 {
3133 strncpy(properties[*propertiesCount].strName, property.GetCStructure()->strName,
3134 sizeof(properties[*propertiesCount].strName) - 1);
3135 strncpy(properties[*propertiesCount].strValue, property.GetCStructure()->strValue,
3136 sizeof(properties[*propertiesCount].strValue) - 1);
3137 ++*propertiesCount;
3138 if (*propertiesCount > STREAM_MAX_PROPERTY_COUNT)
3139 break;
3140 }
3141 }
3142 return error;
3143 }
3144
3145 inline static PVR_ERROR ADDON_CallRecordingMenuHook(const AddonInstance_PVR* instance,
3146 const PVR_MENUHOOK* menuhook,
3147 const PVR_RECORDING* recording)
3148 {
3149 return static_cast<CInstancePVRClient*>(instance->toAddon->addonInstance)
3150 ->CallRecordingMenuHook(menuhook, recording);
3151 }
3152
3153 //--==----==----==----==----==----==----==----==----==----==----==----==----==
3154
3155
3156 inline static PVR_ERROR ADDON_GetTimerTypes(const AddonInstance_PVR* instance,
3157 PVR_TIMER_TYPE* types,
3158 int* typesCount)
3159 {
3160 *typesCount = 0;
3161 std::vector<PVRTimerType> timerTypes;
3162 PVR_ERROR error = static_cast<CInstancePVRClient*>(instance->toAddon->addonInstance)
3163 ->GetTimerTypes(timerTypes);
3164 if (error == PVR_ERROR_NO_ERROR)
3165 {
3166 for (const auto& timerType : timerTypes)
3167 {
3168 types[*typesCount] = *timerType;
3169 ++*typesCount;
3170 if (*typesCount >= PVR_ADDON_TIMERTYPE_ARRAY_SIZE)
3171 break;
3172 }
3173 }
3174 return error;
3175 }
3176
3177 inline static PVR_ERROR ADDON_GetTimersAmount(const AddonInstance_PVR* instance, int* amount)
3178 {
3179 return static_cast<CInstancePVRClient*>(instance->toAddon->addonInstance)
3180 ->GetTimersAmount(*amount);
3181 }
3182
3183 inline static PVR_ERROR ADDON_GetTimers(const AddonInstance_PVR* instance, ADDON_HANDLE handle)
3184 {
3185 PVRTimersResultSet result(instance, handle);
3186 return static_cast<CInstancePVRClient*>(instance->toAddon->addonInstance)->GetTimers(result);
3187 }
3188
3189 inline static PVR_ERROR ADDON_AddTimer(const AddonInstance_PVR* instance, const PVR_TIMER* timer)
3190 {
3191 return static_cast<CInstancePVRClient*>(instance->toAddon->addonInstance)->AddTimer(timer);
3192 }
3193
3194 inline static PVR_ERROR ADDON_DeleteTimer(const AddonInstance_PVR* instance,
3195 const PVR_TIMER* timer,
3196 bool forceDelete)
3197 {
3198 return static_cast<CInstancePVRClient*>(instance->toAddon->addonInstance)
3199 ->DeleteTimer(timer, forceDelete);
3200 }
3201
3202 inline static PVR_ERROR ADDON_UpdateTimer(const AddonInstance_PVR* instance,
3203 const PVR_TIMER* timer)
3204 {
3205 return static_cast<CInstancePVRClient*>(instance->toAddon->addonInstance)->UpdateTimer(timer);
3206 }
3207
3208 inline static PVR_ERROR ADDON_CallTimerMenuHook(const AddonInstance_PVR* instance,
3209 const PVR_MENUHOOK* menuhook,
3210 const PVR_TIMER* timer)
3211 {
3212 return static_cast<CInstancePVRClient*>(instance->toAddon->addonInstance)
3213 ->CallTimerMenuHook(menuhook, timer);
3214 }
3215
3216 //--==----==----==----==----==----==----==----==----==----==----==----==----==
3217
3218 inline static PVR_ERROR ADDON_OnSystemSleep(const AddonInstance_PVR* instance)
3219 {
3220 return static_cast<CInstancePVRClient*>(instance->toAddon->addonInstance)->OnSystemSleep();
3221 }
3222
3223 inline static PVR_ERROR ADDON_OnSystemWake(const AddonInstance_PVR* instance)
3224 {
3225 return static_cast<CInstancePVRClient*>(instance->toAddon->addonInstance)->OnSystemWake();
3226 }
3227
3228 inline static PVR_ERROR ADDON_OnPowerSavingActivated(const AddonInstance_PVR* instance)
3229 {
3230 return static_cast<CInstancePVRClient*>(instance->toAddon->addonInstance)
3231 ->OnPowerSavingActivated();
3232 }
3233
3234 inline static PVR_ERROR ADDON_OnPowerSavingDeactivated(const AddonInstance_PVR* instance)
3235 {
3236 return static_cast<CInstancePVRClient*>(instance->toAddon->addonInstance)
3237 ->OnPowerSavingDeactivated();
3238 }
3239
3240 // obsolete parts below
3241 ///@{
3242
3243 inline static bool ADDON_OpenLiveStream(const AddonInstance_PVR* instance,
3244 const PVR_CHANNEL* channel)
3245 {
3246 return static_cast<CInstancePVRClient*>(instance->toAddon->addonInstance)
3247 ->OpenLiveStream(channel);
3248 }
3249
3250 inline static void ADDON_CloseLiveStream(const AddonInstance_PVR* instance)
3251 {
3252 static_cast<CInstancePVRClient*>(instance->toAddon->addonInstance)->CloseLiveStream();
3253 }
3254
3255 inline static int ADDON_ReadLiveStream(const AddonInstance_PVR* instance,
3256 unsigned char* buffer,
3257 unsigned int size)
3258 {
3259 return static_cast<CInstancePVRClient*>(instance->toAddon->addonInstance)
3260 ->ReadLiveStream(buffer, size);
3261 }
3262
3263 inline static int64_t ADDON_SeekLiveStream(const AddonInstance_PVR* instance,
3264 int64_t position,
3265 int whence)
3266 {
3267 return static_cast<CInstancePVRClient*>(instance->toAddon->addonInstance)
3268 ->SeekLiveStream(position, whence);
3269 }
3270
3271 inline static int64_t ADDON_LengthLiveStream(const AddonInstance_PVR* instance)
3272 {
3273 return static_cast<CInstancePVRClient*>(instance->toAddon->addonInstance)->LengthLiveStream();
3274 }
3275
3276 inline static PVR_ERROR ADDON_GetStreamProperties(const AddonInstance_PVR* instance,
3277 PVR_STREAM_PROPERTIES* properties)
3278 {
3279 properties->iStreamCount = 0;
3280 std::vector<PVRStreamProperties> cppProperties;
3281 PVR_ERROR err = static_cast<CInstancePVRClient*>(instance->toAddon->addonInstance)
3282 ->GetStreamProperties(cppProperties);
3283 if (err == PVR_ERROR_NO_ERROR)
3284 {
3285 for (unsigned int i = 0; i < cppProperties.size(); ++i)
3286 {
3287 memcpy(&properties->stream[i],
3288 static_cast<PVR_STREAM_PROPERTIES::PVR_STREAM*>(cppProperties[i]),
3289 sizeof(PVR_STREAM_PROPERTIES::PVR_STREAM));
3290 ++properties->iStreamCount;
3291
3292 if (properties->iStreamCount >= PVR_STREAM_MAX_STREAMS)
3293 {
3294 kodi::Log(
3295 ADDON_LOG_ERROR,
3296 "CInstancePVRClient::%s: Addon given with '%li' more allowed streams where '%i'",
3297 __func__, cppProperties.size(), PVR_STREAM_MAX_STREAMS);
3298 break;
3299 }
3300 }
3301 }
3302
3303 return err;
3304 }
3305
3306 inline static PVR_ERROR ADDON_GetStreamReadChunkSize(const AddonInstance_PVR* instance,
3307 int* chunksize)
3308 {
3309 return static_cast<CInstancePVRClient*>(instance->toAddon->addonInstance)
3310 ->GetStreamReadChunkSize(*chunksize);
3311 }
3312
3313 inline static bool ADDON_IsRealTimeStream(const AddonInstance_PVR* instance)
3314 {
3315 return static_cast<CInstancePVRClient*>(instance->toAddon->addonInstance)->IsRealTimeStream();
3316 }
3317
3318 inline static bool ADDON_OpenRecordedStream(const AddonInstance_PVR* instance,
3319 const PVR_RECORDING* recording)
3320 {
3321 return static_cast<CInstancePVRClient*>(instance->toAddon->addonInstance)
3322 ->OpenRecordedStream(recording);
3323 }
3324
3325 inline static void ADDON_CloseRecordedStream(const AddonInstance_PVR* instance)
3326 {
3327 static_cast<CInstancePVRClient*>(instance->toAddon->addonInstance)->CloseRecordedStream();
3328 }
3329
3330 inline static int ADDON_ReadRecordedStream(const AddonInstance_PVR* instance,
3331 unsigned char* buffer,
3332 unsigned int size)
3333 {
3334 return static_cast<CInstancePVRClient*>(instance->toAddon->addonInstance)
3335 ->ReadRecordedStream(buffer, size);
3336 }
3337
3338 inline static int64_t ADDON_SeekRecordedStream(const AddonInstance_PVR* instance,
3339 int64_t position,
3340 int whence)
3341 {
3342 return static_cast<CInstancePVRClient*>(instance->toAddon->addonInstance)
3343 ->SeekRecordedStream(position, whence);
3344 }
3345
3346 inline static int64_t ADDON_LengthRecordedStream(const AddonInstance_PVR* instance)
3347 {
3348 return static_cast<CInstancePVRClient*>(instance->toAddon->addonInstance)
3349 ->LengthRecordedStream();
3350 }
3351
3352 inline static void ADDON_DemuxReset(const AddonInstance_PVR* instance)
3353 {
3354 static_cast<CInstancePVRClient*>(instance->toAddon->addonInstance)->DemuxReset();
3355 }
3356
3357 inline static void ADDON_DemuxAbort(const AddonInstance_PVR* instance)
3358 {
3359 static_cast<CInstancePVRClient*>(instance->toAddon->addonInstance)->DemuxAbort();
3360 }
3361
3362 inline static void ADDON_DemuxFlush(const AddonInstance_PVR* instance)
3363 {
3364 static_cast<CInstancePVRClient*>(instance->toAddon->addonInstance)->DemuxFlush();
3365 }
3366
3367 inline static DemuxPacket* ADDON_DemuxRead(const AddonInstance_PVR* instance)
3368 {
3369 return static_cast<CInstancePVRClient*>(instance->toAddon->addonInstance)->DemuxRead();
3370 }
3371
3372 inline static bool ADDON_CanPauseStream(const AddonInstance_PVR* instance)
3373 {
3374 return static_cast<CInstancePVRClient*>(instance->toAddon->addonInstance)->CanPauseStream();
3375 }
3376
3377 inline static bool ADDON_CanSeekStream(const AddonInstance_PVR* instance)
3378 {
3379 return static_cast<CInstancePVRClient*>(instance->toAddon->addonInstance)->CanSeekStream();
3380 }
3381
3382 inline static void ADDON_PauseStream(const AddonInstance_PVR* instance, bool bPaused)
3383 {
3384 static_cast<CInstancePVRClient*>(instance->toAddon->addonInstance)->PauseStream(bPaused);
3385 }
3386
3387 inline static bool ADDON_SeekTime(const AddonInstance_PVR* instance,
3388 double time,
3389 bool backwards,
3390 double* startpts)
3391 {
3392 return static_cast<CInstancePVRClient*>(instance->toAddon->addonInstance)
3393 ->SeekTime(time, backwards, *startpts);
3394 }
3395
3396 inline static void ADDON_SetSpeed(const AddonInstance_PVR* instance, int speed)
3397 {
3398 static_cast<CInstancePVRClient*>(instance->toAddon->addonInstance)->SetSpeed(speed);
3399 }
3400
3401 inline static void ADDON_FillBuffer(const AddonInstance_PVR* instance, bool mode)
3402 {
3403 static_cast<CInstancePVRClient*>(instance->toAddon->addonInstance)->FillBuffer(mode);
3404 }
3405
3406 inline static PVR_ERROR ADDON_GetStreamTimes(const AddonInstance_PVR* instance,
3407 PVR_STREAM_TIMES* times)
3408 {
3409 PVRStreamTimes cppTimes(times);
3410 return static_cast<CInstancePVRClient*>(instance->toAddon->addonInstance)
3411 ->GetStreamTimes(cppTimes);
3412 }
3413 ///@}
3414
3415 AddonInstance_PVR* m_instanceData = nullptr;
3416};
3417//}}}
3418//______________________________________________________________________________
3419
3420} /* namespace addon */
3421} /* namespace kodi */
3422
3423#endif /* __cplusplus */
diff --git a/xbmc/addons/kodi-dev-kit/include/kodi/addon-instance/Peripheral.h b/xbmc/addons/kodi-dev-kit/include/kodi/addon-instance/Peripheral.h
new file mode 100644
index 0000000..46060a8
--- /dev/null
+++ b/xbmc/addons/kodi-dev-kit/include/kodi/addon-instance/Peripheral.h
@@ -0,0 +1,907 @@
1/*
2 * Copyright (C) 2014-2018 Team Kodi
3 * This file is part of Kodi - https://kodi.tv
4 *
5 * SPDX-License-Identifier: GPL-2.0-or-later
6 * See LICENSES/README.md for more information.
7 */
8
9#pragma once
10
11#include "../AddonBase.h"
12#include "peripheral/PeripheralUtils.h"
13
14#ifdef __cplusplus
15namespace kodi
16{
17namespace addon
18{
19
20//##############################################################################
21/// @defgroup cpp_kodi_addon_peripheral_Defs Definitions, structures and enumerators
22/// @ingroup cpp_kodi_addon_peripheral
23/// @brief %Peripheral add-on general variables
24///
25/// Used to exchange the available options between Kodi and addon.
26///
27///
28
29//##############################################################################
30/// @defgroup cpp_kodi_addon_peripheral_Defs_General 1. General
31/// @ingroup cpp_kodi_addon_peripheral_Defs
32/// @brief **%Peripheral add-on general variables**\n
33/// Used to exchange the available options between Kodi and addon.
34///
35/// This group also includes @ref cpp_kodi_addon_peripheral_Defs_PeripheralCapabilities
36/// with which Kodi an @ref kodi::addon::CInstancePeripheral::GetCapabilities()
37/// queries the supported **modules** of the addon.
38///
39
40//##############################################################################
41/// @defgroup cpp_kodi_addon_peripheral_Defs_Peripheral 2. Peripheral
42/// @ingroup cpp_kodi_addon_peripheral_Defs
43/// @brief **%Peripheral add-on operation variables**\n
44/// Used to exchange the available options between Kodi and addon.
45///
46
47//##############################################################################
48/// @defgroup cpp_kodi_addon_peripheral_Defs_Event 3. Event
49/// @ingroup cpp_kodi_addon_peripheral_Defs
50/// @brief **%Event add-on operation variables**\n
51/// Used to exchange the available options between Kodi and addon.
52///
53
54//##############################################################################
55/// @defgroup cpp_kodi_addon_peripheral_Defs_Joystick 4. Joystick
56/// @ingroup cpp_kodi_addon_peripheral_Defs
57/// @brief **%Joystick add-on operation variables**\n
58/// Used to exchange the available options between Kodi and addon.
59///
60
61//==============================================================================
62/// @addtogroup cpp_kodi_addon_peripheral
63/// @brief \cpp_class{ kodi::addon::CInstancePeripheral }
64/// **%Peripheral add-on instance**
65///
66/// The peripheral add-ons provides access to many joystick and gamepad
67/// interfaces across various platforms. An input addon is used to map the
68/// buttons/axis on your physical input device, to the buttons/axis of your
69/// virtual system. This is necessary because different retro systems usually
70/// have different button layouts. A controller configuration utility is also
71/// in the works.
72///
73/// ----------------------------------------------------------------------------
74///
75/// Here is an example of what the <b>`addon.xml.in`</b> would look like for an
76/// peripheral addon:
77///
78/// ~~~~~~~~~~~~~{.xml}
79/// <?xml version="1.0" encoding="UTF-8"?>
80/// <addon
81/// id="peripheral.myspecialnamefor"
82/// version="1.0.0"
83/// name="My special peripheral addon"
84/// provider-name="Your Name">
85/// <requires>@ADDON_DEPENDS@</requires>
86/// <extension
87/// point="kodi.peripheral"
88/// provides_joysticks="true"
89/// provides_buttonmaps="true"
90/// library_@PLATFORM@="@LIBRARY_FILENAME@"/>
91/// <extension point="xbmc.addon.metadata">
92/// <summary lang="en_GB">My peripheral addon</summary>
93/// <description lang="en_GB">My peripheral addon description</description>
94/// <platform>@PLATFORM@</platform>
95/// </extension>
96/// </addon>
97/// ~~~~~~~~~~~~~
98///
99/// Description to peripheral related addon.xml values:
100/// | Name | Description
101/// |:------------------------------|----------------------------------------
102/// | <b>`provides_joysticks`</b> | Set to "true" if addon provides joystick support.
103/// | <b>`provides_buttonmaps`</b> | Set to "true" if button map is used and supported by addon.
104/// | <b>`point`</b> | Addon type specification<br>At all addon types and for this kind always <b>"kodi.peripheral"</b>.
105/// | <b>`library_@PLATFORM@`</b> | Sets the used library name, which is automatically set by cmake at addon build.
106///
107/// @remark For more detailed description of the <b>`addon.xml`</b>, see also https://kodi.wiki/view/Addon.xml.
108///
109///
110/// --------------------------------------------------------------------------
111///
112/// **Here is an example of how addon can be used as a single:**
113/// ~~~~~~~~~~~~~{.cpp}
114/// #include <kodi/addon-instance/Peripheral.h>
115///
116/// class CMyPeripheralAddon : public kodi::addon::CAddonBase,
117/// public kodi::addon::CInstancePeripheral
118/// {
119/// public:
120/// CMyPeripheralAddon();
121///
122/// void GetCapabilities(kodi::addon::PeripheralCapabilities& capabilities) override;
123/// ...
124/// };
125///
126/// CMyPeripheralAddon::CMyPeripheralAddon()
127/// {
128/// ...
129/// }
130///
131/// void CMyPeripheralAddon::GetCapabilities(kodi::addon::PeripheralCapabilities& capabilities)
132/// {
133/// capabilities.SetProvidesJoysticks(true);
134/// capabilities.SetProvidesButtonmaps(true);
135/// ...
136/// }
137///
138/// ADDONCREATOR(CMyPeripheralAddon)
139/// ~~~~~~~~~~~~~
140///
141/// @note It is imperative to use the necessary functions of this class in the
142/// addon.
143///
144/// --------------------------------------------------------------------------
145///
146///
147/// **Here is another example where the peripheral is used together with
148/// other instance types:**
149///
150/// ~~~~~~~~~~~~~{.cpp}
151/// #include <kodi/addon-instance/Peripheral.h>
152///
153/// class CMyPeripheralAddon : public kodi::addon::CInstancePeripheral
154/// {
155/// public:
156/// CMyPeripheralAddon(KODI_HANDLE instance, const std::string& version);
157///
158/// void GetCapabilities(kodi::addon::PeripheralCapabilities& capabilities) override;
159/// ...
160/// };
161///
162/// CMyPeripheralAddon::CMyPeripheralAddon(KODI_HANDLE instance, const std::string& version)
163/// : CInstancePeripheral(instance, version)
164/// {
165/// ...
166/// }
167///
168/// void CMyPeripheralAddon::GetCapabilities(kodi::addon::PeripheralCapabilities& capabilities)
169/// {
170/// capabilities.SetProvidesJoysticks(true);
171/// capabilities.SetProvidesButtonmaps(true);
172/// ...
173/// }
174///
175/// //----------------------------------------------------------------------
176///
177/// class CMyAddon : public kodi::addon::CAddonBase
178/// {
179/// public:
180/// CMyAddon() = default;
181/// ADDON_STATUS CreateInstance(int instanceType,
182/// const std::string& instanceID,
183/// KODI_HANDLE instance,
184/// const std::string& version,
185/// KODI_HANDLE& addonInstance) override;
186/// };
187///
188/// // If you use only one instance in your add-on, can be instanceType and
189/// // instanceID ignored
190/// ADDON_STATUS CMyAddon::CreateInstance(int instanceType,
191/// const std::string& instanceID,
192/// KODI_HANDLE instance,
193/// const std::string& version,
194/// KODI_HANDLE& addonInstance)
195/// {
196/// if (instanceType == ADDON_INSTANCE_PERIPHERAL)
197/// {
198/// kodi::Log(ADDON_LOG_INFO, "Creating my peripheral addon");
199/// addonInstance = new CMyPeripheralAddon(instance, version);
200/// return ADDON_STATUS_OK;
201/// }
202/// else if (...)
203/// {
204/// ...
205/// }
206/// return ADDON_STATUS_UNKNOWN;
207/// }
208///
209/// ADDONCREATOR(CMyAddon)
210/// ~~~~~~~~~~~~~
211///
212/// The destruction of the example class `CMyPeripheralAddon` is called from
213/// Kodi's header. Manually deleting the add-on instance is not required.
214///
215class ATTRIBUTE_HIDDEN CInstancePeripheral : public IAddonInstance
216{
217public:
218 //============================================================================
219 /// @ingroup cpp_kodi_addon_peripheral
220 /// @brief %Peripheral class constructor.
221 ///
222 /// Used by an add-on that only supports peripheral.
223 ///
224 CInstancePeripheral()
225 : IAddonInstance(ADDON_INSTANCE_PERIPHERAL, GetKodiTypeVersion(ADDON_INSTANCE_PERIPHERAL))
226 {
227 if (CAddonBase::m_interface->globalSingleInstance != nullptr)
228 throw std::logic_error("kodi::addon::CInstancePeripheral: Creation of more as one in single "
229 "instance way is not allowed!");
230
231 SetAddonStruct(CAddonBase::m_interface->firstKodiInstance);
232 CAddonBase::m_interface->globalSingleInstance = this;
233 }
234 //----------------------------------------------------------------------------
235
236 //============================================================================
237 /// @ingroup cpp_kodi_addon_peripheral
238 /// @brief %Peripheral addon class constructor used to support multiple
239 /// instance types.
240 ///
241 /// @param[in] instance The instance value given to
242 /// <b>`kodi::addon::CAddonBase::CreateInstance(...)`</b>.
243 /// @param[in] kodiVersion [opt] Version used in Kodi for this instance, to
244 /// allow compatibility to older Kodi versions.
245 ///
246 /// @note Recommended to set <b>`kodiVersion`</b>.
247 ///
248 ///
249 /// --------------------------------------------------------------------------
250 ///
251 //////*Here's example about the use of this:**
252 /// ~~~~~~~~~~~~~{.cpp}
253 /// class CMyPeripheralAddon : public kodi::addon::CInstancePeripheral
254 /// {
255 /// public:
256 /// CMyPeripheralAddon(KODI_HANDLE instance, const std::string& kodiVersion)
257 /// : kodi::addon::CInstancePeripheral(instance, kodiVersion)
258 /// {
259 /// ...
260 /// }
261 ///
262 /// ...
263 /// };
264 ///
265 /// ADDON_STATUS CMyAddon::CreateInstance(int instanceType,
266 /// const std::string& instanceID,
267 /// KODI_HANDLE instance,
268 /// const std::string& version,
269 /// KODI_HANDLE& addonInstance)
270 /// {
271 /// kodi::Log(ADDON_LOG_INFO, "Creating my peripheral");
272 /// addonInstance = new CMyPeripheralAddon(instance, version);
273 /// return ADDON_STATUS_OK;
274 /// }
275 /// ~~~~~~~~~~~~~
276 ///
277 explicit CInstancePeripheral(KODI_HANDLE instance, const std::string& kodiVersion = "")
278 : IAddonInstance(ADDON_INSTANCE_PERIPHERAL,
279 !kodiVersion.empty() ? kodiVersion
280 : GetKodiTypeVersion(ADDON_INSTANCE_PERIPHERAL))
281 {
282 if (CAddonBase::m_interface->globalSingleInstance != nullptr)
283 throw std::logic_error("kodi::addon::CInstancePeripheral: Creation of multiple together with "
284 "single instance way is not allowed!");
285
286 SetAddonStruct(instance);
287 }
288 //----------------------------------------------------------------------------
289
290 //============================================================================
291 /// @ingroup cpp_kodi_addon_peripheral
292 /// @brief Destructor.
293 ///
294 ~CInstancePeripheral() override = default;
295 //----------------------------------------------------------------------------
296
297 //============================================================================
298 /// @defgroup cpp_kodi_addon_peripheral_peripheralOp 1. Peripheral operations
299 /// @ingroup cpp_kodi_addon_peripheral
300 /// @brief %Peripheral operations to handle control about.
301 ///
302 ///---------------------------------------------------------------------------
303 ///
304 /// **%Peripheral parts in interface:**\n
305 /// Copy this to your project and extend with your parts or leave functions
306 /// complete away where not used or supported.
307 ///
308 /// @copydetails cpp_kodi_addon_peripheral_peripheralOp_header_addon_auto_check
309 /// @copydetails cpp_kodi_addon_peripheral_peripheralOp_source_addon_auto_check
310 ///
311 ///@{
312
313 //============================================================================
314 /// @brief Get the list of features that this add-on provides.
315 ///
316 /// Called by the frontend to query the add-on's capabilities and supported
317 /// peripherals. All capabilities that the add-on supports should be set to true.
318 ///
319 /// @param[out] capabilities The add-on's capabilities
320 ///
321 /// @remarks Valid implementation required.
322 ///
323 ///
324 /// ----------------------------------------------------------------------------
325 ///
326 /// @copydetails cpp_kodi_addon_peripheral_Defs_PeripheralCapabilities_Help
327 ///
328 /// --------------------------------------------------------------------------
329 ///
330 /// **Example:**
331 /// ~~~~~~~~~~~~~{.cpp}
332 /// void CMyPeripheralAddon::GetCapabilities(kodi::addon::PeripheralCapabilities& capabilities)
333 /// {
334 /// capabilities.SetProvidesJoysticks(true);
335 /// capabilities.SetProvidesButtonmaps(true);
336 /// }
337 /// ~~~~~~~~~~~~~
338 ///
339 virtual void GetCapabilities(kodi::addon::PeripheralCapabilities& capabilities) {}
340 //----------------------------------------------------------------------------
341
342 //============================================================================
343 /// @brief Perform a scan for joysticks
344 ///
345 /// The frontend calls this when a hardware change is detected. If an add-on
346 /// detects a hardware change, it can trigger this function using the
347 /// @ref TriggerScan() callback.
348 ///
349 /// @param[in] scan_results Assigned to allocated memory
350 /// @return @ref PERIPHERAL_NO_ERROR if successful
351 ///
352 ///
353 /// --------------------------------------------------------------------------
354 ///
355 /// @copydetails cpp_kodi_addon_peripheral_Defs_Peripheral_Peripheral_Help
356 ///
357 virtual PERIPHERAL_ERROR PerformDeviceScan(
358 std::vector<std::shared_ptr<kodi::addon::Peripheral>>& scan_results)
359 {
360 return PERIPHERAL_ERROR_NOT_IMPLEMENTED;
361 }
362 //----------------------------------------------------------------------------
363
364 //============================================================================
365 /// @brief Get all events that have occurred since the last call to
366 /// @ref GetEvents().
367 ///
368 /// @param[out] events List of available events within addon
369 /// @return @ref PERIPHERAL_NO_ERROR if successful
370 ///
371 /// ----------------------------------------------------------------------------
372 ///
373 /// @copydetails cpp_kodi_addon_peripheral_Defs_Peripheral_PeripheralEvent_Help
374 ///
375 virtual PERIPHERAL_ERROR GetEvents(std::vector<kodi::addon::PeripheralEvent>& events)
376 {
377 return PERIPHERAL_ERROR_NOT_IMPLEMENTED;
378 }
379 //----------------------------------------------------------------------------
380
381 //============================================================================
382 /// @brief Send an input event to the peripheral.
383 ///
384 /// @param[in] event The input event
385 /// @return true if the event was handled, false otherwise
386 ///
387 virtual bool SendEvent(const kodi::addon::PeripheralEvent& event) { return false; }
388 //----------------------------------------------------------------------------
389
390 ///@}
391
392 //============================================================================
393 /// @defgroup cpp_kodi_addon_peripheral_joystickOp 2. Joystick operations
394 /// @ingroup cpp_kodi_addon_peripheral
395 /// @brief %Joystick operations to handle control about.
396 ///
397 ///
398 ///---------------------------------------------------------------------------
399 ///
400 /// **%Joystick parts in interface:**\n
401 /// Copy this to your project and extend with your parts or leave functions
402 /// complete away where not used or supported.
403 ///
404 /// @copydetails cpp_kodi_addon_peripheral_joystickOp_header_addon_auto_check
405 /// @copydetails cpp_kodi_addon_peripheral_joystickOp_source_addon_auto_check
406 ///
407 ///@{
408
409 //============================================================================
410 /// @brief Get extended info about an attached joystick.
411 ///
412 /// @param[in] index The joystick's driver index
413 /// @param[out] info The container for the allocated joystick info
414 /// @return @ref PERIPHERAL_NO_ERROR if successful
415 ///
416 ///
417 /// ----------------------------------------------------------------------------
418 ///
419 /// @copydetails cpp_kodi_addon_peripheral_Defs_Joystick_Joystick_Help
420 ///
421 virtual PERIPHERAL_ERROR GetJoystickInfo(unsigned int index, kodi::addon::Joystick& info)
422 {
423 return PERIPHERAL_ERROR_NOT_IMPLEMENTED;
424 }
425 //----------------------------------------------------------------------------
426
427 //============================================================================
428 /// @brief Get the features that allow translating the joystick into the
429 /// controller profile.
430 ///
431 /// @param[in] joystick The device's joystick properties; unknown values may
432 /// be left at their default
433 /// @param[in] controller_id The controller profile being requested, e.g.
434 /// `game.controller.default`
435 /// @param[out] features The array of allocated features
436 /// @return @ref PERIPHERAL_NO_ERROR if successful
437 ///
438 virtual PERIPHERAL_ERROR GetFeatures(const kodi::addon::Joystick& joystick,
439 const std::string& controller_id,
440 std::vector<kodi::addon::JoystickFeature>& features)
441 {
442 return PERIPHERAL_ERROR_NOT_IMPLEMENTED;
443 }
444 //----------------------------------------------------------------------------
445
446 //============================================================================
447 /// @brief Add or update joystick features.
448 ///
449 /// @param[in] joystick The device's joystick properties; unknown values may be
450 /// left at their default
451 /// @param[in] controller_id The game controller profile being updated
452 /// @param[in] features The array of features
453 /// @return @ref PERIPHERAL_NO_ERROR if successful
454 ///
455 virtual PERIPHERAL_ERROR MapFeatures(const kodi::addon::Joystick& joystick,
456 const std::string& controller_id,
457 const std::vector<kodi::addon::JoystickFeature>& features)
458 {
459 return PERIPHERAL_ERROR_NOT_IMPLEMENTED;
460 }
461 //----------------------------------------------------------------------------
462
463 //============================================================================
464 /// @brief Get the driver primitives that should be ignored while mapping the
465 /// device.
466 ///
467 /// @param[in] joystick The device's joystick properties; unknown values may
468 /// be left at their default
469 /// @param[out] primitives The array of allocated driver primitives to be
470 /// ignored
471 /// @return @ref PERIPHERAL_NO_ERROR if successful
472 ///
473 virtual PERIPHERAL_ERROR GetIgnoredPrimitives(
474 const kodi::addon::Joystick& joystick, std::vector<kodi::addon::DriverPrimitive>& primitives)
475 {
476 return PERIPHERAL_ERROR_NOT_IMPLEMENTED;
477 }
478 //----------------------------------------------------------------------------
479
480 //============================================================================
481 /// @brief Set the list of driver primitives that are ignored for the device.
482 ///
483 /// @param[in] joystick The device's joystick properties; unknown values may be left at their default
484 /// @param[in] primitives The array of driver primitives to ignore
485 /// @return @ref PERIPHERAL_NO_ERROR if successful
486 ///
487 virtual PERIPHERAL_ERROR SetIgnoredPrimitives(
488 const kodi::addon::Joystick& joystick,
489 const std::vector<kodi::addon::DriverPrimitive>& primitives)
490 {
491 return PERIPHERAL_ERROR_NOT_IMPLEMENTED;
492 }
493 //----------------------------------------------------------------------------
494
495 //============================================================================
496 /// @brief Save the button map for the given joystick.
497 ///
498 /// @param[in] joystick The device's joystick properties
499 ///
500 virtual void SaveButtonMap(const kodi::addon::Joystick& joystick) {}
501 //----------------------------------------------------------------------------
502
503 //============================================================================
504 /// @brief Revert the button map to the last time it was loaded or committed to disk
505 /// @param[in] joystick The device's joystick properties
506 ///
507 virtual void RevertButtonMap(const kodi::addon::Joystick& joystick) {}
508 //----------------------------------------------------------------------------
509
510 //============================================================================
511 /// @brief Reset the button map for the given joystick and controller profile ID
512 /// @param[in] joystick The device's joystick properties
513 /// @param[in] controller_id The game controller profile being reset
514 ///
515 virtual void ResetButtonMap(const kodi::addon::Joystick& joystick,
516 const std::string& controller_id)
517 {
518 }
519 //----------------------------------------------------------------------------
520
521 //============================================================================
522 /// @brief Powers off the given joystick if supported
523 /// @param[in] index The joystick's driver index
524 ///
525 virtual void PowerOffJoystick(unsigned int index) {}
526 //----------------------------------------------------------------------------
527
528 ///@}
529
530 //============================================================================
531 /// @defgroup cpp_kodi_addon_peripheral_callbacks 3. Callback functions
532 /// @ingroup cpp_kodi_addon_peripheral
533 /// @brief Callback to Kodi functions.
534 ///
535 ///@{
536
537 //============================================================================
538 /// @brief Used to get the full path where the add-on is installed.
539 ///
540 /// @return The add-on installation path
541 ///
542 const std::string AddonPath() const { return m_instanceData->props->addon_path; }
543 //----------------------------------------------------------------------------
544
545 //============================================================================
546 /// @brief Used to get the full path to the add-on's user profile.
547 ///
548 /// @note The trailing folder (consisting of the add-on's ID) is not created
549 /// by default. If it is needed, you must call kodi::vfs::CreateDirectory()
550 /// to create the folder.
551 ///
552 /// @return Path to the user profile
553 ///
554 const std::string UserPath() const { return m_instanceData->props->user_path; }
555 //----------------------------------------------------------------------------
556
557 //============================================================================
558 /// @brief Trigger a scan for peripherals
559 ///
560 /// The add-on calls this if a change in hardware is detected.
561 ///
562 void TriggerScan(void)
563 {
564 return m_instanceData->toKodi->trigger_scan(m_instanceData->toKodi->kodiInstance);
565 }
566 //----------------------------------------------------------------------------
567
568 //============================================================================
569 /// @brief Notify the frontend that button maps have changed.
570 ///
571 /// @param[in] deviceName [optional] The name of the device to refresh, or
572 /// empty/null for all devices
573 /// @param[in] controllerId [optional] The controller ID to refresh, or
574 /// empty/null for all controllers
575 ///
576 void RefreshButtonMaps(const std::string& deviceName = "", const std::string& controllerId = "")
577 {
578 return m_instanceData->toKodi->refresh_button_maps(m_instanceData->toKodi->kodiInstance,
579 deviceName.c_str(), controllerId.c_str());
580 }
581 //----------------------------------------------------------------------------
582
583 //============================================================================
584 /// @brief Return the number of features belonging to the specified
585 /// controller.
586 ///
587 /// @param[in] controllerId The controller ID to enumerate
588 /// @param[in] type [optional] Type to filter by, or @ref JOYSTICK_FEATURE_TYPE_UNKNOWN
589 /// for all features
590 /// @return The number of features matching the request parameters
591 ///
592 unsigned int FeatureCount(const std::string& controllerId,
593 JOYSTICK_FEATURE_TYPE type = JOYSTICK_FEATURE_TYPE_UNKNOWN)
594 {
595 return m_instanceData->toKodi->feature_count(m_instanceData->toKodi->kodiInstance,
596 controllerId.c_str(), type);
597 }
598 //----------------------------------------------------------------------------
599
600 //============================================================================
601 /// @brief Return the type of the feature.
602 ///
603 /// @param[in] controllerId The controller ID to check
604 /// @param[in] featureName The feature to check
605 /// @return The type of the specified feature, or @ref JOYSTICK_FEATURE_TYPE_UNKNOWN
606 /// if unknown
607 ///
608 JOYSTICK_FEATURE_TYPE FeatureType(const std::string& controllerId, const std::string& featureName)
609 {
610 return m_instanceData->toKodi->feature_type(m_instanceData->toKodi->kodiInstance,
611 controllerId.c_str(), featureName.c_str());
612 }
613 //----------------------------------------------------------------------------
614
615 ///@}
616
617private:
618 void SetAddonStruct(KODI_HANDLE instance)
619 {
620 if (instance == nullptr)
621 throw std::logic_error("kodi::addon::CInstancePeripheral: Creation with empty addon "
622 "structure not allowed, table must be given from Kodi!");
623
624 m_instanceData = static_cast<AddonInstance_Peripheral*>(instance);
625 m_instanceData->toAddon->addonInstance = this;
626
627 m_instanceData->toAddon->get_capabilities = ADDON_GetCapabilities;
628 m_instanceData->toAddon->perform_device_scan = ADDON_PerformDeviceScan;
629 m_instanceData->toAddon->free_scan_results = ADDON_FreeScanResults;
630 m_instanceData->toAddon->get_events = ADDON_GetEvents;
631 m_instanceData->toAddon->free_events = ADDON_FreeEvents;
632 m_instanceData->toAddon->send_event = ADDON_SendEvent;
633
634 m_instanceData->toAddon->get_joystick_info = ADDON_GetJoystickInfo;
635 m_instanceData->toAddon->free_joystick_info = ADDON_FreeJoystickInfo;
636 m_instanceData->toAddon->get_features = ADDON_GetFeatures;
637 m_instanceData->toAddon->free_features = ADDON_FreeFeatures;
638 m_instanceData->toAddon->map_features = ADDON_MapFeatures;
639 m_instanceData->toAddon->get_ignored_primitives = ADDON_GetIgnoredPrimitives;
640 m_instanceData->toAddon->free_primitives = ADDON_FreePrimitives;
641 m_instanceData->toAddon->set_ignored_primitives = ADDON_SetIgnoredPrimitives;
642 m_instanceData->toAddon->save_button_map = ADDON_SaveButtonMap;
643 m_instanceData->toAddon->revert_button_map = ADDON_RevertButtonMap;
644 m_instanceData->toAddon->reset_button_map = ADDON_ResetButtonMap;
645 m_instanceData->toAddon->power_off_joystick = ADDON_PowerOffJoystick;
646 }
647
648 inline static void ADDON_GetCapabilities(const AddonInstance_Peripheral* addonInstance,
649 PERIPHERAL_CAPABILITIES* capabilities)
650 {
651 if (!addonInstance || !capabilities)
652 return;
653
654 kodi::addon::PeripheralCapabilities peripheralCapabilities(capabilities);
655 static_cast<CInstancePeripheral*>(addonInstance->toAddon->addonInstance)
656 ->GetCapabilities(peripheralCapabilities);
657 }
658
659 inline static PERIPHERAL_ERROR ADDON_PerformDeviceScan(
660 const AddonInstance_Peripheral* addonInstance,
661 unsigned int* peripheral_count,
662 PERIPHERAL_INFO** scan_results)
663 {
664 if (!addonInstance || !peripheral_count || !scan_results)
665 return PERIPHERAL_ERROR_INVALID_PARAMETERS;
666
667 std::vector<std::shared_ptr<kodi::addon::Peripheral>> peripherals;
668 PERIPHERAL_ERROR err = static_cast<CInstancePeripheral*>(addonInstance->toAddon->addonInstance)
669 ->PerformDeviceScan(peripherals);
670 if (err == PERIPHERAL_NO_ERROR)
671 {
672 *peripheral_count = static_cast<unsigned int>(peripherals.size());
673 kodi::addon::Peripherals::ToStructs(peripherals, scan_results);
674 }
675
676 return err;
677 }
678
679 inline static void ADDON_FreeScanResults(const AddonInstance_Peripheral* addonInstance,
680 unsigned int peripheral_count,
681 PERIPHERAL_INFO* scan_results)
682 {
683 if (!addonInstance)
684 return;
685
686 kodi::addon::Peripherals::FreeStructs(peripheral_count, scan_results);
687 }
688
689 inline static PERIPHERAL_ERROR ADDON_GetEvents(const AddonInstance_Peripheral* addonInstance,
690 unsigned int* event_count,
691 PERIPHERAL_EVENT** events)
692 {
693 if (!addonInstance || !event_count || !events)
694 return PERIPHERAL_ERROR_INVALID_PARAMETERS;
695
696 std::vector<kodi::addon::PeripheralEvent> peripheralEvents;
697 PERIPHERAL_ERROR err = static_cast<CInstancePeripheral*>(addonInstance->toAddon->addonInstance)
698 ->GetEvents(peripheralEvents);
699 if (err == PERIPHERAL_NO_ERROR)
700 {
701 *event_count = static_cast<unsigned int>(peripheralEvents.size());
702 kodi::addon::PeripheralEvents::ToStructs(peripheralEvents, events);
703 }
704
705 return err;
706 }
707
708 inline static void ADDON_FreeEvents(const AddonInstance_Peripheral* addonInstance,
709 unsigned int event_count,
710 PERIPHERAL_EVENT* events)
711 {
712 if (!addonInstance)
713 return;
714
715 kodi::addon::PeripheralEvents::FreeStructs(event_count, events);
716 }
717
718 inline static bool ADDON_SendEvent(const AddonInstance_Peripheral* addonInstance,
719 const PERIPHERAL_EVENT* event)
720 {
721 if (!addonInstance || !event)
722 return false;
723 return static_cast<CInstancePeripheral*>(addonInstance->toAddon->addonInstance)
724 ->SendEvent(kodi::addon::PeripheralEvent(*event));
725 }
726
727
728 inline static PERIPHERAL_ERROR ADDON_GetJoystickInfo(
729 const AddonInstance_Peripheral* addonInstance, unsigned int index, JOYSTICK_INFO* info)
730 {
731 if (!addonInstance || !info)
732 return PERIPHERAL_ERROR_INVALID_PARAMETERS;
733
734 kodi::addon::Joystick addonInfo;
735 PERIPHERAL_ERROR err = static_cast<CInstancePeripheral*>(addonInstance->toAddon->addonInstance)
736 ->GetJoystickInfo(index, addonInfo);
737 if (err == PERIPHERAL_NO_ERROR)
738 {
739 addonInfo.ToStruct(*info);
740 }
741
742 return err;
743 }
744
745 inline static void ADDON_FreeJoystickInfo(const AddonInstance_Peripheral* addonInstance,
746 JOYSTICK_INFO* info)
747 {
748 if (!addonInstance)
749 return;
750
751 kodi::addon::Joystick::FreeStruct(*info);
752 }
753
754 inline static PERIPHERAL_ERROR ADDON_GetFeatures(const AddonInstance_Peripheral* addonInstance,
755 const JOYSTICK_INFO* joystick,
756 const char* controller_id,
757 unsigned int* feature_count,
758 JOYSTICK_FEATURE** features)
759 {
760 if (!addonInstance || !joystick || !controller_id || !feature_count || !features)
761 return PERIPHERAL_ERROR_INVALID_PARAMETERS;
762
763 kodi::addon::Joystick addonJoystick(*joystick);
764 std::vector<kodi::addon::JoystickFeature> featuresVector;
765
766 PERIPHERAL_ERROR err = static_cast<CInstancePeripheral*>(addonInstance->toAddon->addonInstance)
767 ->GetFeatures(addonJoystick, controller_id, featuresVector);
768 if (err == PERIPHERAL_NO_ERROR)
769 {
770 *feature_count = static_cast<unsigned int>(featuresVector.size());
771 kodi::addon::JoystickFeatures::ToStructs(featuresVector, features);
772 }
773
774 return err;
775 }
776
777 inline static void ADDON_FreeFeatures(const AddonInstance_Peripheral* addonInstance,
778 unsigned int feature_count,
779 JOYSTICK_FEATURE* features)
780 {
781 if (!addonInstance)
782 return;
783
784 kodi::addon::JoystickFeatures::FreeStructs(feature_count, features);
785 }
786
787 inline static PERIPHERAL_ERROR ADDON_MapFeatures(const AddonInstance_Peripheral* addonInstance,
788 const JOYSTICK_INFO* joystick,
789 const char* controller_id,
790 unsigned int feature_count,
791 const JOYSTICK_FEATURE* features)
792 {
793 if (!addonInstance || !joystick || !controller_id || (feature_count > 0 && !features))
794 return PERIPHERAL_ERROR_INVALID_PARAMETERS;
795
796 kodi::addon::Joystick addonJoystick(*joystick);
797 std::vector<kodi::addon::JoystickFeature> primitiveVector;
798
799 for (unsigned int i = 0; i < feature_count; i++)
800 primitiveVector.emplace_back(*(features + i));
801
802 return static_cast<CInstancePeripheral*>(addonInstance->toAddon->addonInstance)
803 ->MapFeatures(addonJoystick, controller_id, primitiveVector);
804 }
805
806 inline static PERIPHERAL_ERROR ADDON_GetIgnoredPrimitives(
807 const AddonInstance_Peripheral* addonInstance,
808 const JOYSTICK_INFO* joystick,
809 unsigned int* primitive_count,
810 JOYSTICK_DRIVER_PRIMITIVE** primitives)
811 {
812 if (!addonInstance || !joystick || !primitive_count || !primitives)
813 return PERIPHERAL_ERROR_INVALID_PARAMETERS;
814
815 kodi::addon::Joystick addonJoystick(*joystick);
816 std::vector<kodi::addon::DriverPrimitive> primitiveVector;
817
818 PERIPHERAL_ERROR err = static_cast<CInstancePeripheral*>(addonInstance->toAddon->addonInstance)
819 ->GetIgnoredPrimitives(addonJoystick, primitiveVector);
820 if (err == PERIPHERAL_NO_ERROR)
821 {
822 *primitive_count = static_cast<unsigned int>(primitiveVector.size());
823 kodi::addon::DriverPrimitives::ToStructs(primitiveVector, primitives);
824 }
825
826 return err;
827 }
828
829 inline static void ADDON_FreePrimitives(const AddonInstance_Peripheral* addonInstance,
830 unsigned int primitive_count,
831 JOYSTICK_DRIVER_PRIMITIVE* primitives)
832 {
833 if (!addonInstance)
834 return;
835
836 kodi::addon::DriverPrimitives::FreeStructs(primitive_count, primitives);
837 }
838
839 inline static PERIPHERAL_ERROR ADDON_SetIgnoredPrimitives(
840 const AddonInstance_Peripheral* addonInstance,
841 const JOYSTICK_INFO* joystick,
842 unsigned int primitive_count,
843 const JOYSTICK_DRIVER_PRIMITIVE* primitives)
844 {
845 if (!addonInstance || !joystick || (primitive_count > 0 && !primitives))
846 return PERIPHERAL_ERROR_INVALID_PARAMETERS;
847
848 kodi::addon::Joystick addonJoystick(*joystick);
849 std::vector<kodi::addon::DriverPrimitive> primitiveVector;
850
851 for (unsigned int i = 0; i < primitive_count; i++)
852 primitiveVector.emplace_back(*(primitives + i));
853
854 return static_cast<CInstancePeripheral*>(addonInstance->toAddon->addonInstance)
855 ->SetIgnoredPrimitives(addonJoystick, primitiveVector);
856 }
857
858 inline static void ADDON_SaveButtonMap(const AddonInstance_Peripheral* addonInstance,
859 const JOYSTICK_INFO* joystick)
860 {
861 if (!addonInstance || !joystick)
862 return;
863
864 kodi::addon::Joystick addonJoystick(*joystick);
865 static_cast<CInstancePeripheral*>(addonInstance->toAddon->addonInstance)
866 ->SaveButtonMap(addonJoystick);
867 }
868
869 inline static void ADDON_RevertButtonMap(const AddonInstance_Peripheral* addonInstance,
870 const JOYSTICK_INFO* joystick)
871 {
872 if (!addonInstance || !joystick)
873 return;
874
875 kodi::addon::Joystick addonJoystick(*joystick);
876 static_cast<CInstancePeripheral*>(addonInstance->toAddon->addonInstance)
877 ->RevertButtonMap(addonJoystick);
878 }
879
880 inline static void ADDON_ResetButtonMap(const AddonInstance_Peripheral* addonInstance,
881 const JOYSTICK_INFO* joystick,
882 const char* controller_id)
883 {
884 if (!addonInstance || !joystick || !controller_id)
885 return;
886
887 kodi::addon::Joystick addonJoystick(*joystick);
888 static_cast<CInstancePeripheral*>(addonInstance->toAddon->addonInstance)
889 ->ResetButtonMap(addonJoystick, controller_id);
890 }
891
892 inline static void ADDON_PowerOffJoystick(const AddonInstance_Peripheral* addonInstance,
893 unsigned int index)
894 {
895 if (!addonInstance)
896 return;
897
898 static_cast<CInstancePeripheral*>(addonInstance->toAddon->addonInstance)
899 ->PowerOffJoystick(index);
900 }
901
902 AddonInstance_Peripheral* m_instanceData;
903};
904
905} /* namespace addon */
906} /* namespace kodi */
907#endif /* __cplusplus */
diff --git a/xbmc/addons/kodi-dev-kit/include/kodi/addon-instance/Screensaver.h b/xbmc/addons/kodi-dev-kit/include/kodi/addon-instance/Screensaver.h
new file mode 100644
index 0000000..4902fcb
--- /dev/null
+++ b/xbmc/addons/kodi-dev-kit/include/kodi/addon-instance/Screensaver.h
@@ -0,0 +1,470 @@
1/*
2 * Copyright (C) 2005-2018 Team Kodi
3 * This file is part of Kodi - https://kodi.tv
4 *
5 * SPDX-License-Identifier: GPL-2.0-or-later
6 * See LICENSES/README.md for more information.
7 */
8
9#pragma once
10
11#include "../AddonBase.h"
12#include "../c-api/addon-instance/screensaver.h"
13#include "../gui/renderHelper.h"
14
15#ifdef __cplusplus
16namespace kodi
17{
18namespace addon
19{
20
21//==============================================================================
22/// @addtogroup cpp_kodi_addon_screensaver
23/// @brief \cpp_class{ kodi::addon::CInstanceScreensaver }
24/// **Screensaver add-on instance**
25///
26/// A screensaver is a Kodi addon that fills the screen with moving images or
27/// patterns when the computer is not in use. Initially designed to prevent
28/// phosphor burn-in on CRT and plasma computer monitors (hence the name),
29/// screensavers are now used primarily for entertainment, security or to
30/// display system status information.
31///
32/// Include the header @ref Screensaver.h "#include <kodi/addon-instance/ScreenSaver.h>"
33/// to use this class.
34///
35/// This interface allows the creating of screensavers for Kodi, based upon
36/// **DirectX** or/and **OpenGL** rendering with `C++` code.
37///
38/// The interface is small and easy usable. It has three functions:
39///
40/// * <b><c>Start()</c></b> - Called on creation
41/// * <b><c>Render()</c></b> - Called at render time
42/// * <b><c>Stop()</c></b> - Called when the screensaver has no work
43///
44/// Additionally, there are several \ref cpp_kodi_addon_screensaver_CB "other functions"
45/// available in which the child class can ask about the current hardware,
46/// including the device, display and several other parts.
47///
48/// ----------------------------------------------------------------------------
49///
50/// Here is an example of what the <b>`addon.xml.in`</b> would look like for an
51/// screensaver addon:
52///
53/// ~~~~~~~~~~~~~{.xml}
54/// <?xml version="1.0" encoding="UTF-8"?>
55/// <addon
56/// id="screensaver.myspecialnamefor"
57/// version="1.0.0"
58/// name="My special screensaver addon"
59/// provider-name="Your Name">
60/// <requires>@ADDON_DEPENDS@</requires>
61/// <extension
62/// point="xbmc.ui.screensaver"
63/// library_@PLATFORM@="@LIBRARY_FILENAME@"/>
64/// <extension point="xbmc.addon.metadata">
65/// <summary lang="en_GB">My screensaver addon</summary>
66/// <description lang="en_GB">My screensaver addon description</description>
67/// <platform>@PLATFORM@</platform>
68/// </extension>
69/// </addon>
70/// ~~~~~~~~~~~~~
71///
72/// Description to screensaver related addon.xml values:
73/// | Name | Description
74/// |:------------------------------|----------------------------------------
75/// | <b>`point`</b> | Addon type specification<br>At all addon types and for this kind always <b>"xbmc.ui.screensaver"</b>.
76/// | <b>`library_@PLATFORM@`</b> | Sets the used library name, which is automatically set by cmake at addon build.
77///
78/// @remark For more detailed description of the <b>`addon.xml`</b>, see also https://kodi.wiki/view/Addon.xml.
79///
80///
81/// --------------------------------------------------------------------------
82///
83/// **Here is an example of the minimum required code to start a screensaver:**
84/// ~~~~~~~~~~~~~{.cpp}
85/// #include <kodi/addon-instance/Screensaver.h>
86///
87/// class CMyScreenSaver : public kodi::addon::CAddonBase,
88/// public kodi::addon::CInstanceScreensaver
89/// {
90/// public:
91/// CMyScreenSaver();
92///
93/// bool Start() override;
94/// void Render() override;
95/// };
96///
97/// CMyScreenSaver::CMyScreenSaver()
98/// {
99/// ...
100/// }
101///
102/// bool CMyScreenSaver::Start()
103/// {
104/// ...
105/// return true;
106/// }
107///
108/// void CMyScreenSaver::Render()
109/// {
110/// ...
111/// }
112///
113/// ADDONCREATOR(CMyScreenSaver)
114/// ~~~~~~~~~~~~~
115///
116///
117/// --------------------------------------------------------------------------
118///
119///
120/// **Here is another example where the screensaver is used together with
121/// other instance types:**
122///
123/// ~~~~~~~~~~~~~{.cpp}
124/// #include <kodi/addon-instance/Screensaver.h>
125///
126/// class CMyScreenSaver : public kodi::addon::CInstanceScreensaver
127/// {
128/// public:
129/// CMyScreenSaver(KODI_HANDLE instance, const std::string& version);
130///
131/// bool Start() override;
132/// void Render() override;
133/// };
134///
135/// CMyScreenSaver::CMyScreenSaver(KODI_HANDLE instance, const std::string& version)
136/// : CInstanceScreensaver(instance, version)
137/// {
138/// ...
139/// }
140///
141/// bool CMyScreenSaver::Start()
142/// {
143/// ...
144/// return true;
145/// }
146///
147/// void CMyScreenSaver::Render()
148/// {
149/// ...
150/// }
151///
152///
153/// //----------------------------------------------------------------------
154///
155/// class CMyAddon : public kodi::addon::CAddonBase
156/// {
157/// public:
158/// CMyAddon() = default;
159/// ADDON_STATUS CreateInstance(int instanceType,
160/// const std::string& instanceID,
161/// KODI_HANDLE instance,
162/// const std::string& version,
163/// KODI_HANDLE& addonInstance) override;
164/// };
165///
166/// // If you use only one instance in your add-on, can be instanceType and
167/// // instanceID ignored
168/// ADDON_STATUS CMyAddon::CreateInstance(int instanceType,
169/// const std::string& instanceID,
170/// KODI_HANDLE instance,
171/// const std::string& version,
172/// KODI_HANDLE& addonInstance)
173/// {
174/// if (instanceType == ADDON_INSTANCE_SCREENSAVER)
175/// {
176/// kodi::Log(ADDON_LOG_INFO, "Creating my Screensaver");
177/// addonInstance = new CMyScreenSaver(instance, version);
178/// return ADDON_STATUS_OK;
179/// }
180/// else if (...)
181/// {
182/// ...
183/// }
184/// return ADDON_STATUS_UNKNOWN;
185/// }
186///
187/// ADDONCREATOR(CMyAddon)
188/// ~~~~~~~~~~~~~
189///
190/// The destruction of the example class `CMyScreenSaver` is called from
191/// Kodi's header. Manually deleting the add-on instance is not required.
192///
193class ATTRIBUTE_HIDDEN CInstanceScreensaver : public IAddonInstance
194{
195public:
196 //============================================================================
197 /// @ingroup cpp_kodi_addon_screensaver
198 /// @brief Screensaver class constructor.
199 ///
200 /// Used by an add-on that only supports screensavers.
201 ///
202 CInstanceScreensaver()
203 : IAddonInstance(ADDON_INSTANCE_SCREENSAVER, GetKodiTypeVersion(ADDON_INSTANCE_SCREENSAVER))
204 {
205 if (CAddonBase::m_interface->globalSingleInstance != nullptr)
206 throw std::logic_error("kodi::addon::CInstanceScreensaver: Creation of more as one in single "
207 "instance way is not allowed!");
208
209 SetAddonStruct(CAddonBase::m_interface->firstKodiInstance);
210 CAddonBase::m_interface->globalSingleInstance = this;
211 }
212 //----------------------------------------------------------------------------
213
214 //============================================================================
215 /// @ingroup cpp_kodi_addon_screensaver
216 /// @brief Screensaver class constructor used to support multiple instance
217 /// types.
218 ///
219 /// @param[in] instance The instance value given to
220 /// <b>`kodi::addon::CAddonBase::CreateInstance(...)`</b>.
221 /// @param[in] kodiVersion [opt] Version used in Kodi for this instance, to
222 /// allow compatibility to older Kodi versions.
223 ///
224 /// @note Recommended to set <b>`kodiVersion`</b>.
225 ///
226 ///
227 /// --------------------------------------------------------------------------
228 ///
229 /// **Here's example about the use of this:**
230 /// ~~~~~~~~~~~~~{.cpp}
231 /// class CMyScreenSaver : public kodi::addon::CInstanceScreensaver
232 /// {
233 /// public:
234 /// CMyScreenSaver(KODI_HANDLE instance, const std::string& kodiVersion)
235 /// : kodi::addon::CInstanceScreensaver(instance, kodiVersion)
236 /// {
237 /// ...
238 /// }
239 ///
240 /// ...
241 /// };
242 ///
243 /// ADDON_STATUS CMyAddon::CreateInstance(int instanceType,
244 /// const std::string& instanceID,
245 /// KODI_HANDLE instance,
246 /// const std::string& version,
247 /// KODI_HANDLE& addonInstance)
248 /// {
249 /// kodi::Log(ADDON_LOG_INFO, "Creating my screensaver");
250 /// addonInstance = new CMyScreenSaver(instance, version);
251 /// return ADDON_STATUS_OK;
252 /// }
253 /// ~~~~~~~~~~~~~
254 ///
255 explicit CInstanceScreensaver(KODI_HANDLE instance, const std::string& kodiVersion = "")
256 : IAddonInstance(ADDON_INSTANCE_SCREENSAVER,
257 !kodiVersion.empty() ? kodiVersion
258 : GetKodiTypeVersion(ADDON_INSTANCE_SCREENSAVER))
259 {
260 if (CAddonBase::m_interface->globalSingleInstance != nullptr)
261 throw std::logic_error("kodi::addon::CInstanceScreensaver: Creation of multiple together "
262 "with single instance way is not allowed!");
263
264 SetAddonStruct(instance);
265 }
266 //----------------------------------------------------------------------------
267
268 //============================================================================
269 /// @ingroup cpp_kodi_addon_screensaver
270 /// @brief Destructor.
271 ///
272 ~CInstanceScreensaver() override = default;
273 //----------------------------------------------------------------------------
274
275 //============================================================================
276 /// @ingroup cpp_kodi_addon_screensaver
277 /// @brief Used to notify the screensaver that it has been started.
278 ///
279 /// @return true if the screensaver was started successfully, false otherwise
280 ///
281 virtual bool Start() { return true; }
282 //----------------------------------------------------------------------------
283
284 //============================================================================
285 /// @ingroup cpp_kodi_addon_screensaver
286 /// @brief Used to inform the screensaver that the rendering control was
287 /// stopped.
288 ///
289 virtual void Stop() {}
290 //----------------------------------------------------------------------------
291
292 //============================================================================
293 /// @ingroup cpp_kodi_addon_screensaver
294 /// @brief Used to indicate when the add-on should render
295 ///
296 virtual void Render() {}
297 //----------------------------------------------------------------------------
298
299 //============================================================================
300 /// @defgroup cpp_kodi_addon_screensaver_CB Information functions
301 /// @ingroup cpp_kodi_addon_screensaver
302 /// @brief **To get info about the device, display and several other parts**
303 ///
304 ///@{
305
306 //============================================================================
307 /// @ingroup cpp_kodi_addon_screensaver_CB
308 /// @brief Device that represents the display adapter.
309 ///
310 /// @return A pointer to the device
311 ///
312 /// @note This is only available on **DirectX**, It us unused (`nullptr`) on
313 /// **OpenGL**
314 ///
315 /// This value can also be becomed by @ref kodi::gui::GetHWContext() and is
316 /// recommended to use.
317 ///
318 ///-------------------------------------------------------------------------
319 ///
320 /// **Example:**
321 /// ~~~~~~~~~~~~~{.cpp}
322 /// #include <d3d11_1.h>
323 /// ..
324 /// // Note: Device() there is used inside addon child class about
325 /// // kodi::addon::CInstanceVisualization
326 /// ID3D11DeviceContext1* context = static_cast<ID3D11DeviceContext1*>(kodi::addon::CInstanceVisualization::Device());
327 /// ..
328 /// ~~~~~~~~~~~~~
329 ///
330 inline kodi::HardwareContext Device() { return m_instanceData->props->device; }
331 //----------------------------------------------------------------------------
332
333 //============================================================================
334 /// @ingroup cpp_kodi_addon_screensaver_CB
335 /// @brief Returns the X position of the rendering window.
336 ///
337 /// @return The X position, in pixels
338 ///
339 inline int X() { return m_instanceData->props->x; }
340 //----------------------------------------------------------------------------
341
342 //============================================================================
343 /// @ingroup cpp_kodi_addon_screensaver_CB
344 /// @brief Returns the Y position of the rendering window.
345 ///
346 /// @return The Y position, in pixels
347 ///
348 inline int Y() { return m_instanceData->props->y; }
349 //----------------------------------------------------------------------------
350
351 //============================================================================
352 /// @ingroup cpp_kodi_addon_screensaver_CB
353 /// @brief Returns the width of the rendering window.
354 ///
355 /// @return The width, in pixels
356 ///
357 inline int Width() { return m_instanceData->props->width; }
358 //----------------------------------------------------------------------------
359
360 //============================================================================
361 /// @ingroup cpp_kodi_addon_screensaver_CB
362 /// @brief Returns the height of the rendering window.
363 ///
364 /// @return The height, in pixels
365 ///
366 inline int Height() { return m_instanceData->props->height; }
367 //----------------------------------------------------------------------------
368
369 //============================================================================
370 /// @ingroup cpp_kodi_addon_screensaver_CB
371 /// @brief Pixel aspect ratio (often abbreviated PAR) is a ratio that
372 /// describes how the width of a pixel compares to the height of that pixel.
373 ///
374 /// @return The pixel aspect ratio used by the display
375 ///
376 inline float PixelRatio() { return m_instanceData->props->pixelRatio; }
377 //----------------------------------------------------------------------------
378
379 //============================================================================
380 /// @ingroup cpp_kodi_addon_screensaver_CB
381 /// @brief Used to get the name of the add-on defined in `addon.xml`.
382 ///
383 /// @return The add-on name
384 ///
385 inline std::string Name() { return m_instanceData->props->name; }
386 //----------------------------------------------------------------------------
387
388 //============================================================================
389 ///
390 /// @ingroup cpp_kodi_addon_screensaver_CB
391 /// @brief Used to get the full path where the add-on is installed.
392 ///
393 /// @return The add-on installation path
394 ///
395 inline std::string Presets() { return m_instanceData->props->presets; }
396 //----------------------------------------------------------------------------
397
398 //============================================================================
399 /// @ingroup cpp_kodi_addon_screensaver_CB
400 /// @brief Used to get the full path to the add-on's user profile.
401 ///
402 /// @note The trailing folder (consisting of the add-on's ID) is not created
403 /// by default. If it is needed, you must call kodi::vfs::CreateDirectory()
404 /// to create the folder.
405 ///
406 /// @return Path to the user profile
407 ///
408 inline std::string Profile() { return m_instanceData->props->profile; }
409 //----------------------------------------------------------------------------
410
411 ///@}
412
413private:
414 void SetAddonStruct(KODI_HANDLE instance)
415 {
416 if (instance == nullptr)
417 throw std::logic_error("kodi::addon::CInstanceScreensaver: Creation with empty addon "
418 "structure not allowed, table must be given from Kodi!");
419
420 m_instanceData = static_cast<AddonInstance_Screensaver*>(instance);
421 m_instanceData->toAddon->addonInstance = this;
422 m_instanceData->toAddon->Start = ADDON_Start;
423 m_instanceData->toAddon->Stop = ADDON_Stop;
424 m_instanceData->toAddon->Render = ADDON_Render;
425 }
426
427 inline static bool ADDON_Start(AddonInstance_Screensaver* instance)
428 {
429 CInstanceScreensaver* thisClass =
430 static_cast<CInstanceScreensaver*>(instance->toAddon->addonInstance);
431 thisClass->m_renderHelper = kodi::gui::GetRenderHelper();
432 return thisClass->Start();
433 }
434
435 inline static void ADDON_Stop(AddonInstance_Screensaver* instance)
436 {
437 CInstanceScreensaver* thisClass =
438 static_cast<CInstanceScreensaver*>(instance->toAddon->addonInstance);
439 thisClass->Stop();
440 thisClass->m_renderHelper = nullptr;
441 }
442
443 inline static void ADDON_Render(AddonInstance_Screensaver* instance)
444 {
445 CInstanceScreensaver* thisClass =
446 static_cast<CInstanceScreensaver*>(instance->toAddon->addonInstance);
447
448 if (!thisClass->m_renderHelper)
449 return;
450 thisClass->m_renderHelper->Begin();
451 thisClass->Render();
452 thisClass->m_renderHelper->End();
453 }
454
455 /*
456 * Background render helper holds here and in addon base.
457 * In addon base also to have for the others, and stored here for the worst
458 * case where this class is independent from base and base becomes closed
459 * before.
460 *
461 * This is on Kodi with GL unused and the calls to there are empty (no work)
462 * On Kodi with Direct X where angle is present becomes this used.
463 */
464 std::shared_ptr<kodi::gui::IRenderHelper> m_renderHelper;
465 AddonInstance_Screensaver* m_instanceData;
466};
467
468} /* namespace addon */
469} /* namespace kodi */
470#endif /* __cplusplus */
diff --git a/xbmc/addons/kodi-dev-kit/include/kodi/addon-instance/VFS.h b/xbmc/addons/kodi-dev-kit/include/kodi/addon-instance/VFS.h
new file mode 100644
index 0000000..177bf72
--- /dev/null
+++ b/xbmc/addons/kodi-dev-kit/include/kodi/addon-instance/VFS.h
@@ -0,0 +1,1226 @@
1/*
2 * Copyright (C) 2015-2018 Team Kodi
3 *
4 * SPDX-License-Identifier: GPL-2.0-or-later
5 * See LICENSES/README.md for more information.
6 */
7
8#pragma once
9
10#include "../AddonBase.h"
11#include "../Filesystem.h"
12#include "../c-api/addon-instance/vfs.h"
13
14#ifdef __cplusplus
15
16namespace kodi
17{
18namespace addon
19{
20
21class CInstanceVFS;
22
23//==============================================================================
24/// @ingroup cpp_kodi_addon_vfs_Defs
25/// @brief **VFS add-on file handle**\n
26/// This used to handle opened files of addon with related memory pointer about
27/// class or structure and to have on further file control functions available.
28///
29/// See @ref cpp_kodi_addon_vfs_filecontrol "file editing functions" for used
30/// places.
31///
32///@{
33using VFSFileHandle = VFS_FILE_HANDLE;
34///@}
35//------------------------------------------------------------------------------
36
37//==============================================================================
38/// @defgroup cpp_kodi_addon_vfs_Defs_VFSUrl class VFSUrl
39/// @ingroup cpp_kodi_addon_vfs_Defs
40/// @brief **VFS add-on URL data**\n
41/// This class is used to inform the addon of the desired wanted connection.
42///
43/// Used on mostly all addon functions to identify related target.
44///
45/// ----------------------------------------------------------------------------
46///
47/// @copydetails cpp_kodi_addon_vfs_Defs_VFSUrl_Help
48///
49///@{
50class ATTRIBUTE_HIDDEN VFSUrl : public CStructHdl<VFSUrl, VFSURL>
51{
52 /*! \cond PRIVATE */
53 friend class CInstanceVFS;
54 /*! \endcond */
55
56public:
57 /// @defgroup cpp_kodi_addon_vfs_Defs_VFSUrl_Help Value Help
58 /// @ingroup cpp_kodi_addon_vfs_Defs_VFSUrl
59 ///
60 /// <b>The following table contains values that can be set with @ref cpp_kodi_addon_vfs_Defs_VFSUrl :</b>
61 /// | Name | Type | Get call
62 /// |------|------|----------
63 /// | **URL** | `std::string` | @ref VFSUrl::GetURL "GetURL"
64 /// | **Domain name** | `std::string` | @ref VFSUrl::GetDomain "GetDomain"
65 /// | **Hostname** | `std::string` | @ref VFSUrl::GetHostname "GetHostname"
66 /// | **Filename** | `std::string` | @ref VFSUrl::GetFilename "GetFilename"
67 /// | **Network port** | `unsigned int` | @ref VFSUrl::GetPort "GetPort"
68 /// | **Special options** | `std::string` | @ref VFSUrl::GetOptions "GetOptions"
69 /// | **Username** | `std::string` | @ref VFSUrl::GetUsername "GetUsername"
70 /// | **Password** | `std::string` | @ref VFSUrl::GetPassword "GetPassword"
71 /// | **Get URL with user and password hidden** | `std::string` | @ref VFSUrl::GetRedacted "GetRedacted"
72 /// | **Sharename** | `std::string` | @ref VFSUrl::GetSharename "GetSharename"
73 /// | **Network protocol** | `std::string` | @ref VFSUrl::GetProtocol "GetProtocol"
74 ///
75
76 /// @addtogroup cpp_kodi_addon_vfs_Defs_VFSUrl
77 ///@{
78
79 /// @brief Desired URL of the file system to be edited
80 ///
81 /// This includes all available parts of the access and is structured as
82 /// follows:
83 /// -
84 /// <b>`<PROTOCOL>`://`<USERNAME>`:`<PASSWORD>``@``<HOSTNAME>`:`<PORT>`/`<FILENAME>`?`<OPTIONS>`</b>
85 std::string GetURL() const { return m_cStructure->url; }
86
87 /// @brief The associated domain name, which is optional and not available
88 /// in all cases.
89 std::string GetDomain() const { return m_cStructure->domain; }
90
91 /// @brief This includes the network address (e.g. `192.168.0.123`) or if
92 /// the addon refers to file packages the path to it
93 /// (e.g. `/home/by_me/MyPacket.rar`).
94 std::string GetHostname() const { return m_cStructure->hostname; }
95
96 /// @brief With this variable the desired path to a folder or file within
97 /// the hostname is given (e.g. `storage/videos/00001.ts`).
98 std::string GetFilename() const { return m_cStructure->filename; }
99
100 /// @brief [Networking port](https://en.wikipedia.org/wiki/Port_(computer_networking))
101 /// to use for protocol.
102 unsigned int GetPort() const { return m_cStructure->port; }
103
104 /// @brief Special options on opened URL, this can e.g. on RAR packages
105 /// <b>`?flags=8&nextvalue=123`</b> to inform about to not cache a read.
106 ///
107 /// Available options from Kodi:
108 /// | Value: | Description:
109 /// |-----------|-------------------
110 /// | flags=8 | Used on RAR packages so that no data is cached from the requested source.
111 /// | cache=no | Used on ZIP packages so that no data from the requested source is stored in the cache. However, this is currently not available from addons!
112 ///
113 /// In addition, other addons can use the URLs given by them to give options
114 /// that fit the respective VFS addon and allow special operations.
115 ///
116 /// @note This procedure is not yet standardized and is currently not
117 /// exactly available which are handed over.
118 std::string GetOptions() const { return m_cStructure->options; }
119
120 /// @brief Desired username.
121 std::string GetUsername() const { return m_cStructure->username; }
122
123 /// @brief Desired password.
124 std::string GetPassword() const { return m_cStructure->password; }
125
126 /// @brief The complete URL is passed on here, but the user name and
127 /// password are not shown and only appear to there as `USERNAME:PASSWORD`.
128 ///
129 /// As example <b>`sftp://USERNAME:PASSWORD@192.168.178.123/storage/videos/00001.ts`</b>.
130 std::string GetRedacted() const { return m_cStructure->redacted; }
131
132 /// @brief The name which is taken as the basis by source and would be first
133 /// in folder view.
134 ///
135 /// As example on <b>`sftp://dudu:isprivate@192.168.178.123/storage/videos/00001.ts`</b>
136 /// becomes then <b>`storage`</b> used here.
137 std::string GetSharename() const { return m_cStructure->sharename; }
138
139 /// @brief Protocol name used on this stream, e.g. <b>`sftp`</b>.
140 std::string GetProtocol() const { return m_cStructure->protocol; }
141
142 ///@}
143
144private:
145 VFSUrl() = delete;
146 VFSUrl(const VFSUrl& channel) = delete;
147 VFSUrl(const VFSURL* channel) : CStructHdl(channel) {}
148 VFSUrl(VFSURL* channel) : CStructHdl(channel) {}
149};
150///@}
151//------------------------------------------------------------------------------
152
153//##############################################################################
154/// @defgroup cpp_kodi_addon_vfs_Defs Definitions, structures and enumerators
155/// \ingroup cpp_kodi_addon_vfs
156/// @brief **VFS add-on general variables**
157///
158/// Used to exchange the available options between Kodi and addon.
159///
160///
161
162//==============================================================================
163///
164/// \addtogroup cpp_kodi_addon_vfs
165/// @brief \cpp_class{ kodi::addon::CInstanceVFS }
166/// **Virtual Filesystem (VFS) add-on instance**
167///
168/// This instance type is used to allow Kodi various additional file system
169/// types. Be it a special file system, a compressed package or a system
170/// available over the network, everything is possible with it.
171///
172/// This usage can be requested under various conditions, for example explicitly
173/// by another addon, by a Mimetype protocol defined in <b>`addon.xml`</b> or supported
174/// file extensions.
175///
176/// Include the header @ref VFS.h "#include <kodi/addon-instance/VFS.h>"
177/// to use this class.
178///
179/// ----------------------------------------------------------------------------
180///
181/// Here is an example of what the <b>`addon.xml.in`</b> would look like for an VFS addon:
182///
183/// ~~~~~~~~~~~~~{.xml}
184/// <?xml version="1.0" encoding="UTF-8"?>
185/// <addon
186/// id="vfs.myspecialnamefor"
187/// version="1.0.0"
188/// name="My VFS addon"
189/// provider-name="Your Name">
190/// <requires>@ADDON_DEPENDS@</requires>
191/// <extension
192/// point="kodi.vfs"
193/// protocols="myprot"
194/// extensions=".abc|.def"
195/// files="true"
196/// filedirectories="true"
197/// directories="true"
198/// encodedhostname="true"
199/// supportDialog="true"
200/// supportPath="true"
201/// supportUsername="true"
202/// supportPassword="true"
203/// supportPort="true"
204/// supportBrowsing="true"
205/// supportWrite="true"
206/// defaultPort="1234"
207/// label="30000"
208/// zeroconf="your_special_zeroconf_allowed_identifier"
209/// library_@PLATFORM@="@LIBRARY_FILENAME@"/>
210/// <extension point="xbmc.addon.metadata">
211/// <summary lang="en_GB">My VFS addon summary</summary>
212/// <description lang="en_GB">My VFS description</description>
213/// <platform>@PLATFORM@</platform>
214/// </extension>
215/// </addon>
216/// ~~~~~~~~~~~~~
217///
218/// @note Regarding boolean values with "false", these can also be omitted,
219/// since this would be the default.
220///
221///
222/// ### Standard values that can be declared for processing in `addon.xml`.
223///
224/// These values are used by Kodi to identify associated streams and file
225/// extensions and then to select the associated addon.
226///
227/// \table_start
228/// \table_h3{ Labels, Type, Description }
229/// \table_row3{ <b>`point`</b>,
230/// \anchor cpp_kodi_addon_vfs_point
231/// string,
232/// The identification of the addon instance to VFS is mandatory <b>`kodi.vfs`</b>.
233/// In addition\, the instance declared in the first <b>`<extension ... />`</b> is also the main type of addon.
234/// }
235/// \table_row3{ <b>`defaultPort`</b>,
236/// \anchor cpp_kodi_addon_vfs_defaultPort
237/// integer,
238/// Default [networking port](https://en.wikipedia.org/wiki/Port_(computer_networking))
239/// to use for protocol.
240/// }
241/// \table_row3{ <b>`directories`</b>,
242/// \anchor cpp_kodi_addon_vfs_directories
243/// boolean,
244/// VFS entry can list directories.
245/// }
246/// \table_row3{ <b>`extensions`</b>,
247/// \anchor cpp_kodi_addon_vfs_extensions
248/// string,
249/// Extensions for VFS entry.\n
250/// It is possible to declare several using <b>`|`</b>\, e.g. <b>`.abc|.def|.ghi`</b>.
251/// }
252/// \table_row3{ <b>`encodedhostname`</b>,
253/// \anchor cpp_kodi_addon_vfs_encodedhostname
254/// boolean,
255/// URL protocol from add-ons use encoded hostnames.
256/// }
257/// \table_row3{ <b>`filedirectories`</b>,
258/// \anchor cpp_kodi_addon_vfs_filedirectories
259/// boolean,
260/// VFS entry contains file directories.
261/// }
262/// \table_row3{ <b>`files`</b>,
263/// \anchor cpp_kodi_addon_vfs_directories
264/// boolean,
265/// Set to declare that VFS provides files.
266/// }
267/// \table_row3{ <b>`protocols`</b>,
268/// \anchor cpp_kodi_addon_vfs_protocols
269/// boolean,
270/// Protocols for VFS entry.\n
271/// It is possible to declare several using <b>`|`</b>\, e.g. <b>`myprot1|myprot2`</b>.\n
272/// @note This field also used to show on GUI\, see <b>`supportBrowsing`</b> below about <b>*2:</b>.
273/// When used there\, however\, only a **single** protocol is possible!
274/// }
275/// \table_row3{ <b>`supportWrite`</b>,
276/// \anchor cpp_kodi_addon_vfs_supportWrite
277/// boolean,
278/// Protocol supports write operations.
279/// }
280/// \table_row3{ <b>`zeroconf`</b>,
281/// \anchor cpp_kodi_addon_vfs_zeroconf
282/// string,
283/// [Zero conf](https://en.wikipedia.org/wiki/Zero-configuration_networking) announce string for VFS protocol.
284/// }
285/// \table_row3{ <b>`library_@PLATFORM@`</b>,
286/// \anchor cpp_kodi_addon_vfs_library
287/// string,
288/// The runtime library used for the addon. This is usually declared by `cmake` and correctly displayed in the translated <b>`addon.xml`</b>.
289/// }
290/// \table_end
291///
292///
293/// ### User selectable parts of the addon.
294///
295/// The following table describes the values that can be defined by <b>`addon.xml`</b>
296/// and which part they relate to for user input.
297///
298/// \table_start
299/// \table_h3{ Labels, Type, Description }
300/// \table_row3{ <b>`supportBrowsing`</b>,
301/// \anchor cpp_kodi_addon_vfs_protocol_supportBrowsing
302/// boolean,
303/// Protocol supports server browsing. Used to open related sources by users in the window.\n\n
304/// | Associated places in Kodi: |
305/// | :---- |
306/// | \image html cpp_kodi_addon_vfs_protocol_1.png |
307/// <br>
308/// <b>*1:</b> The entry in the menu represented by this option corresponds to the text given with <b>`label`</b>.
309/// When the button is pressed\, @ref CInstanceVFS::GetDirectory is called on the add-on to get its content.\n
310/// <b>*2:</b> Protocol name of the stream defined with <b>`protocols`</b> in xml.\n
311/// @remark See also <b>`supportDialog`</b> about <b>*3:</b>.
312/// }
313/// \table_row3{ <b>`supportDialog`</b>,
314/// \anchor cpp_kodi_addon_vfs_protocol_supportDialog
315/// boolean,
316/// To point out that Kodi assigns a dialog to this VFS in order to compare it with other values e.g. query supportPassword in it.\n
317/// This will be available when adding sources in Kodi under <b>"Add network location..."</b>.\n\n
318/// | Associated places in Kodi: |
319/// | :---- |
320/// | \image html cpp_kodi_addon_vfs_protocol_2.png |
321/// <br>
322/// <b>*1:</b> Field for selecting the VFS handler\, the addon will be available if <b>`supportDialog`</b> is set to <b>`true`</b>.\n
323/// <b>*2:</b> To set the associated server address. **Note:** *This field is always activated and cannot be changed by the addon.*\n
324/// <b>*3:</b> If <b>`supportBrowsing`</b> is set to <b>`true`</b>\, the button for opening a file selection dialog is given here too\, as in the file window.\n
325/// <b>*4:</b> This field is available if <b>`supportPath`</b> is set to <b>`true`</b>.\n
326/// <b>*5:</b> To edit the connection port. This field is available if <b>`supportPort`</b> is set to <b>`true`</b>.\n
327/// <b>*6:</b> This sets the required username and is available when <b>`supportUsername`</b> is set to <b>`true`</b>.\n
328/// <b>*7:</b> This sets the required password and is available when <b>`supportPassword`</b> is set to <b>`true`</b>.
329/// }
330/// \table_row3{ <b>`supportPath`</b>,
331/// \anchor cpp_kodi_addon_vfs_protocol_supportPath
332/// boolean,
333/// Protocol has path in addition to server name (see <b>`supportDialog`</b> about <b>*4:</b>).
334/// }
335/// \table_row3{ <b>`supportPort`</b>,
336/// \anchor cpp_kodi_addon_vfs_protocol_supportPort
337/// boolean,
338/// Protocol supports port customization (see <b>`supportDialog`</b> about <b>*5:</b>).
339/// }
340/// \table_row3{ <b>`supportUsername`</b>,
341/// \anchor cpp_kodi_addon_vfs_protocol_supportUsername
342/// boolean,
343/// Protocol uses logins (see <b>`supportDialog`</b> about <b>*6:</b>).
344/// }
345/// \table_row3{ <b>`supportPassword`</b>,
346/// \anchor cpp_kodi_addon_vfs_protocol_supportPassword
347/// boolean,
348/// Protocol supports passwords (see <b>`supportDialog`</b> about <b>*7:</b>).
349/// }
350/// \table_row3{ <b>`protocols`</b>,
351/// \anchor cpp_kodi_addon_vfs_protocol_protocols
352/// string,
353/// Protocols for VFS entry.
354/// @note This field is not editable and only used on GUI to show his name\, see <b>`supportBrowsing`</b> about <b>*2:</b>
355/// }
356/// \table_row3{ <b>`label`</b>,
357/// \anchor cpp_kodi_addon_vfs_protocol_label
358/// integer,
359/// The text identification number used in Kodi for display in the menu at <b>`supportDialog`</b>
360/// as a selection option and at <b>`supportBrowsing`</b> (see his image reference <b>*1</b>) as a menu entry.\n
361/// This can be a text identifier in Kodi or from addon.\n
362/// @remark For addon within <b>30000</b>-<b>30999</b> or <b>32000</b>-<b>32999</b>.
363/// }
364/// \table_end
365///
366/// @remark For more detailed description of the <b>`addon.xml`</b>, see also https://kodi.wiki/view/Addon.xml.
367///
368///
369/// --------------------------------------------------------------------------
370///
371///
372/// **Example:**
373///
374/// ~~~~~~~~~~~~~{.cpp}
375/// #include <kodi/addon-instance/VFS.h>
376///
377/// class CMyVFS : public kodi::addon::CInstanceVFS
378/// {
379/// public:
380/// CMyVFS(KODI_HANDLE instance, const std::string& kodiVersion);
381///
382/// // Add all your required functions, the most CInstanceVFS functions of
383/// // must be included to have addon working correctly.
384/// ...
385/// };
386///
387/// CMyVFS::CMyVFS(KODI_HANDLE instance, const std::string& kodiVersion)
388/// : kodi::addon::CInstanceVFS(instance, kodiVersion)
389/// {
390/// ...
391/// }
392///
393/// ...
394///
395/// //----------------------------------------------------------------------
396///
397/// class CMyAddon : public kodi::addon::CAddonBase
398/// {
399/// public:
400/// CMyAddon() { }
401/// ADDON_STATUS CreateInstance(int instanceType,
402/// const std::string& instanceID,
403/// KODI_HANDLE instance,
404/// const std::string& version,
405/// KODI_HANDLE& addonInstance) override;
406/// };
407///
408/// // If you use only one instance in your add-on, can be instanceType and
409/// // instanceID ignored
410/// ADDON_STATUS CMyAddon::CreateInstance(int instanceType,
411/// const std::string& instanceID,
412/// KODI_HANDLE instance,
413/// const std::string& version,
414/// KODI_HANDLE& addonInstance)
415/// {
416/// if (instanceType == ADDON_INSTANCE_VFS)
417/// {
418/// kodi::Log(ADDON_LOG_INFO, "Creating my VFS instance");
419/// addonInstance = new CMyVFS(instance, version);
420/// return ADDON_STATUS_OK;
421/// }
422/// else if (...)
423/// {
424/// ...
425/// }
426/// return ADDON_STATUS_UNKNOWN;
427/// }
428///
429/// ADDONCREATOR(CMyAddon)
430/// ~~~~~~~~~~~~~
431///
432/// The destruction of the example class `CMyVFS` is called from
433/// Kodi's header. Manually deleting the add-on instance is not required.
434///
435//------------------------------------------------------------------------------
436class ATTRIBUTE_HIDDEN CInstanceVFS : public IAddonInstance
437{
438public:
439 //============================================================================
440 /// @ingroup cpp_kodi_addon_vfs
441 /// @brief VFS class constructor used to support multiple instance
442 /// types
443 ///
444 /// @param[in] instance The instance value given to
445 /// <b>`kodi::addon::CAddonBase::CreateInstance(...)`</b>.
446 /// @param[in] kodiVersion [opt] given from Kodi by @ref CAddonBase::CreateInstance
447 /// to identify his instance API version
448 ///
449 /// @note Instance path as a single is not supported by this type. It must
450 /// ensure that it can be called up several times.
451 ///
452 /// @warning Only use `instance` from the @ref CAddonBase::CreateInstance or
453 /// @ref CAddonBase::CreateInstance call.
454 ///
455 explicit CInstanceVFS(KODI_HANDLE instance, const std::string& kodiVersion = "")
456 : IAddonInstance(ADDON_INSTANCE_VFS,
457 !kodiVersion.empty() ? kodiVersion : GetKodiTypeVersion(ADDON_INSTANCE_VFS))
458 {
459 if (CAddonBase::m_interface->globalSingleInstance != nullptr)
460 throw std::logic_error("kodi::addon::CInstanceVFS: Creation of multiple together with single "
461 "instance way is not allowed!");
462
463 SetAddonStruct(instance);
464 }
465 //----------------------------------------------------------------------------
466
467 //============================================================================
468 /// @ingroup cpp_kodi_addon_vfs
469 /// @brief Destructor
470 ///
471 ~CInstanceVFS() override = default;
472 //----------------------------------------------------------------------------
473
474 //============================================================================
475 /// @defgroup cpp_kodi_addon_vfs_general 1. General access functions
476 /// @ingroup cpp_kodi_addon_vfs
477 /// @brief **General access functions**
478 ///
479 /// This functions which are intended for getting folders, editing storage
480 /// locations and file system queries.
481 ///
482
483 //============================================================================
484 /// @defgroup cpp_kodi_addon_vfs_filecontrol 2. File editing functions
485 /// @ingroup cpp_kodi_addon_vfs
486 /// @brief **File editing functions.**
487 ///
488 /// This value represents the addon-side handlers and to be able to identify
489 /// his own parts in the event of further access.
490 ///
491
492 //@{
493 //============================================================================
494 /// @ingroup cpp_kodi_addon_vfs_filecontrol
495 /// @brief Open a file for input
496 ///
497 /// @param[in] url The URL of the file
498 /// @return Context for the opened file
499 ///
500 ///
501 /// ----------------------------------------------------------------------------
502 ///
503 /// @copydetails cpp_kodi_addon_vfs_Defs_VFSUrl_Help
504 ///
505 virtual kodi::addon::VFSFileHandle Open(const kodi::addon::VFSUrl& url) { return nullptr; }
506 //----------------------------------------------------------------------------
507
508 //============================================================================
509 /// @ingroup cpp_kodi_addon_vfs_filecontrol
510 /// @brief Open a file for output
511 ///
512 /// @param[in] url The URL of the file
513 /// @param[in] overWrite Whether or not to overwrite an existing file
514 /// @return Context for the opened file
515 ///
516 virtual kodi::addon::VFSFileHandle OpenForWrite(const kodi::addon::VFSUrl& url, bool overWrite)
517 {
518 return nullptr;
519 }
520 //----------------------------------------------------------------------------
521
522 //============================================================================
523 /// @ingroup cpp_kodi_addon_vfs_filecontrol
524 /// @brief Close a file
525 ///
526 /// @param[in] context The context of the file
527 /// @return True on success, false on failure
528 ///
529 virtual bool Close(kodi::addon::VFSFileHandle context) { return false; }
530 //----------------------------------------------------------------------------
531
532 //============================================================================
533 /// @ingroup cpp_kodi_addon_vfs_filecontrol
534 /// @brief Read from a file
535 ///
536 /// @param[in] context The context of the file
537 /// @param[out] buffer The buffer to read data into
538 /// @param[in] uiBufSize Number of bytes to read
539 /// @return Number of bytes read
540 ///
541 virtual ssize_t Read(kodi::addon::VFSFileHandle context, uint8_t* buffer, size_t uiBufSize)
542 {
543 return -1;
544 }
545 //----------------------------------------------------------------------------
546
547 //============================================================================
548 /// @ingroup cpp_kodi_addon_vfs_filecontrol
549 /// @brief Write to a file
550 ///
551 /// @param[in] context The context of the file
552 /// @param[in] buffer The buffer to read data from
553 /// @param[in] uiBufSize Number of bytes to write
554 /// @return Number of bytes written
555 ///
556 virtual ssize_t Write(kodi::addon::VFSFileHandle context, const uint8_t* buffer, size_t uiBufSize)
557 {
558 return -1;
559 }
560 //----------------------------------------------------------------------------
561
562 //============================================================================
563 /// @ingroup cpp_kodi_addon_vfs_filecontrol
564 /// @brief Seek in a file
565 ///
566 /// @param[in] context The context of the file
567 /// @param[in] position The position to seek to
568 /// @param[in] whence Position in file 'position' is relative to (SEEK_CUR, SEEK_SET, SEEK_END):
569 /// | Value | int | Description |
570 /// |:--------:|:---:|:----------------------------------------------------|
571 /// | SEEK_SET | 0 | position is relative to the beginning of the file. This is probably what you had in mind anyway, and is the most commonly used value for whence.
572 /// | SEEK_CUR | 1 | position is relative to the current file pointer position. So, in effect, you can say, "Move to my current position plus 30 bytes," or, "move to my current position minus 20 bytes."
573 /// | SEEK_END | 2 | position is relative to the end of the file. Just like SEEK_SET except from the other end of the file. Be sure to use negative values for offset if you want to back up from the end of the file, instead of going past the end into oblivion.
574 /// @return Offset in file after seek
575 ///
576 virtual int64_t Seek(kodi::addon::VFSFileHandle context, int64_t position, int whence)
577 {
578 return -1;
579 }
580 //----------------------------------------------------------------------------
581
582 //============================================================================
583 /// @ingroup cpp_kodi_addon_vfs_filecontrol
584 /// @brief Truncate a file
585 ///
586 /// @param[in] context The context of the file
587 /// @param[in] size The size to truncate the file to
588 /// @return 0 on success, -1 on error
589 ///
590 virtual int Truncate(kodi::addon::VFSFileHandle context, int64_t size) { return -1; }
591 //----------------------------------------------------------------------------
592
593 //============================================================================
594 /// @ingroup cpp_kodi_addon_vfs_filecontrol
595 /// @brief Get total size of a file
596 ///
597 /// @param[in] context The context of the file
598 /// @return Total file size
599 ///
600 virtual int64_t GetLength(kodi::addon::VFSFileHandle context) { return 0; }
601 //----------------------------------------------------------------------------
602
603 //============================================================================
604 /// @ingroup cpp_kodi_addon_vfs_filecontrol
605 /// @brief Get current position in a file
606 ///
607 /// @param[in] context The context of the file
608 /// @return Current position
609 ///
610 virtual int64_t GetPosition(kodi::addon::VFSFileHandle context) { return 0; }
611 //----------------------------------------------------------------------------
612
613 //============================================================================
614 /// @ingroup cpp_kodi_addon_vfs_filecontrol
615 /// @brief Get chunk size of a file
616 ///
617 /// @param[in] context The context of the file
618 /// @return Chunk size
619 ///
620 virtual int GetChunkSize(kodi::addon::VFSFileHandle context) { return 1; }
621 //----------------------------------------------------------------------------
622
623 //============================================================================
624 /// @ingroup cpp_kodi_addon_vfs_filecontrol
625 /// @brief To check seek possible on current stream by file.
626 ///
627 /// @return true if seek possible, false if not
628 ///
629 virtual bool IoControlGetSeekPossible(kodi::addon::VFSFileHandle context) { return false; }
630 //----------------------------------------------------------------------------
631
632 //============================================================================
633 /// @ingroup cpp_kodi_addon_vfs_filecontrol
634 /// @brief To check a running stream on file for state of his cache.
635 ///
636 /// @param[in] status Information about current cache status
637 /// @return true if successfull done, false otherwise
638 ///
639 ///
640 /// @copydetails cpp_kodi_vfs_Defs_CacheStatus_Help
641 ///
642 virtual bool IoControlGetCacheStatus(kodi::addon::VFSFileHandle context,
643 kodi::vfs::CacheStatus& status)
644 {
645 return false;
646 }
647 //----------------------------------------------------------------------------
648
649 //============================================================================
650 /// @ingroup cpp_kodi_addon_vfs_filecontrol
651 /// @brief Unsigned int with speed limit for caching in bytes per second.
652 ///
653 /// @param[in] rate Cache rate size to use
654 /// @return true if successfull done, false otherwise
655 ///
656 virtual bool IoControlSetCacheRate(kodi::addon::VFSFileHandle context, unsigned int rate)
657 {
658 return false;
659 }
660 //----------------------------------------------------------------------------
661
662 //============================================================================
663 /// @ingroup cpp_kodi_addon_vfs_filecontrol
664 /// @brief Enable/disable retry within the protocol handler (if supported).
665 ///
666 /// @param[in] retry To set the retry, true for use, false for not
667 /// @return true if successfull done, false otherwise
668 ///
669 virtual bool IoControlSetRetry(kodi::addon::VFSFileHandle context, bool retry) { return false; }
670 //----------------------------------------------------------------------------
671 //@}
672
673 //@{
674 //============================================================================
675 /// @ingroup cpp_kodi_addon_vfs_general
676 /// @brief Stat a file
677 ///
678 /// @param[in] url The URL of the file
679 /// @param[in] buffer The buffer to store results in
680 /// @return -1 on error, 0 otherwise
681 ///
682 ///
683 /// ----------------------------------------------------------------------------
684 ///
685 /// @copydetails cpp_kodi_addon_vfs_Defs_VFSUrl_Help
686 ///
687 virtual int Stat(const kodi::addon::VFSUrl& url, kodi::vfs::FileStatus& buffer) { return 0; }
688 //----------------------------------------------------------------------------
689
690 //============================================================================
691 /// @ingroup cpp_kodi_addon_vfs_general
692 /// @brief Check for file existence
693 ///
694 /// @param[in] url The URL of the file
695 /// @return True if file exists, false otherwise
696 ///
697 virtual bool Exists(const kodi::addon::VFSUrl& url) { return false; }
698 //----------------------------------------------------------------------------
699
700 //============================================================================
701 /// @ingroup cpp_kodi_addon_vfs_general
702 /// @brief Clear out any idle connections
703 ///
704 virtual void ClearOutIdle() {}
705 //----------------------------------------------------------------------------
706
707 //============================================================================
708 /// @ingroup cpp_kodi_addon_vfs_general
709 /// @brief Disconnect all connections
710 ///
711 virtual void DisconnectAll() {}
712 //----------------------------------------------------------------------------
713
714 //============================================================================
715 /// @ingroup cpp_kodi_addon_vfs_general
716 /// @brief Delete a file
717 ///
718 /// @param[in] url The URL of the file
719 /// @return True if deletion was successful, false otherwise
720 ///
721 virtual bool Delete(const kodi::addon::VFSUrl& url) { return false; }
722 //----------------------------------------------------------------------------
723
724 //============================================================================
725 /// @ingroup cpp_kodi_addon_vfs_general
726 /// @brief Rename a file
727 ///
728 /// @param[in] url The URL of the source file
729 /// @param[in] url2 The URL of the destination file
730 /// @return True if deletion was successful, false otherwise
731 ///
732 virtual bool Rename(const kodi::addon::VFSUrl& url, const kodi::addon::VFSUrl& url2)
733 {
734 return false;
735 }
736 //----------------------------------------------------------------------------
737
738 //============================================================================
739 /// @ingroup cpp_kodi_addon_vfs_general
740 /// @brief Check for directory existence
741 ///
742 /// @param[in] url The URL of the file
743 /// @return True if directory exists, false otherwise
744 ///
745 virtual bool DirectoryExists(const kodi::addon::VFSUrl& url) { return false; }
746 //----------------------------------------------------------------------------
747
748 //============================================================================
749 /// @ingroup cpp_kodi_addon_vfs_general
750 /// @brief Remove a directory
751 ///
752 /// @param[in] url The URL of the directory
753 /// @return True if removal was successful, false otherwise
754 ///
755 virtual bool RemoveDirectory(const kodi::addon::VFSUrl& url) { return false; }
756 //----------------------------------------------------------------------------
757
758 //============================================================================
759 /// @ingroup cpp_kodi_addon_vfs_general
760 /// @brief Create a directory
761 ///
762 /// @param[in] url The URL of the file
763 /// @return True if creation was successful, false otherwise
764 ///
765 virtual bool CreateDirectory(const kodi::addon::VFSUrl& url) { return false; }
766 //----------------------------------------------------------------------------
767
768 //============================================================================
769 /// @defgroup cpp_kodi_addon_vfs_general_cb_GetDirectory Callbacks GetDirectory()
770 /// @ingroup cpp_kodi_addon_vfs_general
771 /// @brief Callback functions on GetDirectory()
772 ///
773 /// This functions becomes available during call of GetDirectory() from
774 /// Kodi.
775 ///
776 /// If GetDirectory() returns false becomes the parts from here used on
777 /// next call of the function.
778 ///
779 /// **Example:**
780 /// ~~~~~~~~~~~~~{.cpp}
781 ///
782 /// #include <kodi/addon-instance/VFS.h>
783 ///
784 /// ...
785 ///
786 /// bool CMyVFS::GetDirectory(const kodi::addon::VFSUrl& url,
787 /// std::vector<kodi::vfs::CDirEntry>& items,
788 /// CVFSCallbacks callbacks)
789 /// {
790 /// std::string neededString;
791 /// callbacks.GetKeyboardInput("Test", neededString, true);
792 /// if (neededString.empty())
793 /// return false;
794 ///
795 /// // Do the work
796 /// ...
797 /// return true;
798 /// }
799 /// ~~~~~~~~~~~~~
800 ///
801 class CVFSCallbacks
802 {
803 public:
804 /// @ingroup cpp_kodi_addon_vfs_general_cb_GetDirectory
805 /// @brief Require keyboard input
806 ///
807 /// Becomes called if GetDirectory() returns false and GetDirectory()
808 /// becomes after entry called again.
809 ///
810 /// @param[in] heading The heading of the keyboard dialog
811 /// @param[out] input The resulting string. Returns string after
812 /// second call!
813 /// @param[in] hiddenInput To show input only as "*" on dialog
814 /// @return True if input was received, false otherwise
815 ///
816 bool GetKeyboardInput(const std::string& heading, std::string& input, bool hiddenInput = false)
817 {
818 char* cInput = nullptr;
819 bool ret = m_cb->get_keyboard_input(m_cb->ctx, heading.c_str(), &cInput, hiddenInput);
820 if (cInput)
821 {
822 input = cInput;
823 ::kodi::addon::CAddonBase::m_interface->toKodi->free_string(
824 ::kodi::addon::CAddonBase::m_interface->toKodi->kodiBase, cInput);
825 }
826 return ret;
827 }
828
829 /// @ingroup cpp_kodi_addon_vfs_general_cb_GetDirectory
830 /// @brief Display an error dialog
831 ///
832 /// @param[in] heading The heading of the error dialog
833 /// @param[in] line1 The first line of the error dialog
834 /// @param[in] line2 [opt] The second line of the error dialog
835 /// @param[in] line3 [opt] The third line of the error dialog
836 ///
837 void SetErrorDialog(const std::string& heading,
838 const std::string& line1,
839 const std::string& line2 = "",
840 const std::string& line3 = "")
841 {
842 m_cb->set_error_dialog(m_cb->ctx, heading.c_str(), line1.c_str(), line2.c_str(),
843 line3.c_str());
844 }
845
846 /// @ingroup cpp_kodi_addon_vfs_general_cb_GetDirectory
847 /// @brief Prompt the user for authentication of a URL
848 ///
849 /// @param[in] url The URL
850 void RequireAuthentication(const std::string& url)
851 {
852 m_cb->require_authentication(m_cb->ctx, url.c_str());
853 }
854
855 explicit CVFSCallbacks(const VFSGetDirectoryCallbacks* cb) : m_cb(cb) {}
856
857 private:
858 const VFSGetDirectoryCallbacks* m_cb;
859 };
860 //----------------------------------------------------------------------------
861
862 //============================================================================
863 /// @ingroup cpp_kodi_addon_vfs_general
864 /// @brief List a directory
865 ///
866 /// @param[in] url The URL of the directory
867 /// @param[out] entries The entries in the directory, see
868 /// @ref cpp_kodi_vfs_CDirEntry "kodi::vfs::CDirEntry"
869 /// about his content
870 /// @param[in] callbacks A callback structure
871 /// @return Context for the directory listing
872 ///
873 ///
874 /// --------------------------------------------------------------------------
875 ///
876 /// ### Callbacks:
877 /// @copydetails cpp_kodi_addon_vfs_general_cb_GetDirectory
878 ///
879 /// **Available callback functions**
880 /// | Function: | Description
881 /// |--|--
882 /// | CVFSCallbacks::GetKeyboardInput | @copybrief CVFSCallbacks::GetKeyboardInput @copydetails CVFSCallbacks::GetKeyboardInput
883 /// | CVFSCallbacks::SetErrorDialog | @copybrief CVFSCallbacks::SetErrorDialog @copydetails CVFSCallbacks::SetErrorDialog
884 /// | CVFSCallbacks::RequireAuthentication | @copybrief CVFSCallbacks::RequireAuthentication @copydetails CVFSCallbacks::RequireAuthentication
885 ///
886 virtual bool GetDirectory(const kodi::addon::VFSUrl& url,
887 std::vector<kodi::vfs::CDirEntry>& entries,
888 CVFSCallbacks callbacks)
889 {
890 return false;
891 }
892 //----------------------------------------------------------------------------
893
894 //============================================================================
895 /// @ingroup cpp_kodi_addon_vfs_general
896 /// @brief Check if file should be presented as a directory (multiple streams)
897 ///
898 /// @param[in] url The URL of the file
899 /// @param[out] entries The entries in the directory, see
900 /// @ref cpp_kodi_vfs_CDirEntry "kodi::vfs::CDirEntry"
901 /// about his content
902 /// @param[out] rootPath Path to root directory if multiple entries
903 /// @return Context for the directory listing
904 ///
905 virtual bool ContainsFiles(const kodi::addon::VFSUrl& url,
906 std::vector<kodi::vfs::CDirEntry>& entries,
907 std::string& rootPath)
908 {
909 return false;
910 }
911 //----------------------------------------------------------------------------
912 //@}
913
914private:
915 void SetAddonStruct(KODI_HANDLE instance)
916 {
917 if (instance == nullptr)
918 throw std::logic_error("kodi::addon::CInstanceVFS: Creation with empty addon structure not "
919 "allowed, table must be given from Kodi!");
920
921 m_instanceData = static_cast<AddonInstance_VFSEntry*>(instance);
922 m_instanceData->toAddon->addonInstance = this;
923 m_instanceData->toAddon->open = ADDON_Open;
924 m_instanceData->toAddon->open_for_write = ADDON_OpenForWrite;
925 m_instanceData->toAddon->read = ADDON_Read;
926 m_instanceData->toAddon->write = ADDON_Write;
927 m_instanceData->toAddon->seek = ADDON_Seek;
928 m_instanceData->toAddon->truncate = ADDON_Truncate;
929 m_instanceData->toAddon->get_length = ADDON_GetLength;
930 m_instanceData->toAddon->get_position = ADDON_GetPosition;
931 m_instanceData->toAddon->get_chunk_size = ADDON_GetChunkSize;
932 m_instanceData->toAddon->io_control_get_seek_possible = ADDON_IoControlGetSeekPossible;
933 m_instanceData->toAddon->io_control_get_cache_status = ADDON_IoControlGetCacheStatus;
934 m_instanceData->toAddon->io_control_set_cache_rate = ADDON_IoControlSetCacheRate;
935 m_instanceData->toAddon->io_control_set_retry = ADDON_IoControlSetRetry;
936 m_instanceData->toAddon->stat = ADDON_Stat;
937 m_instanceData->toAddon->close = ADDON_Close;
938 m_instanceData->toAddon->exists = ADDON_Exists;
939 m_instanceData->toAddon->clear_out_idle = ADDON_ClearOutIdle;
940 m_instanceData->toAddon->disconnect_all = ADDON_DisconnectAll;
941 m_instanceData->toAddon->delete_it = ADDON_Delete;
942 m_instanceData->toAddon->rename = ADDON_Rename;
943 m_instanceData->toAddon->directory_exists = ADDON_DirectoryExists;
944 m_instanceData->toAddon->remove_directory = ADDON_RemoveDirectory;
945 m_instanceData->toAddon->create_directory = ADDON_CreateDirectory;
946 m_instanceData->toAddon->get_directory = ADDON_GetDirectory;
947 m_instanceData->toAddon->free_directory = ADDON_FreeDirectory;
948 m_instanceData->toAddon->contains_files = ADDON_ContainsFiles;
949 }
950
951 inline static VFS_FILE_HANDLE ADDON_Open(const AddonInstance_VFSEntry* instance,
952 const VFSURL* url)
953 {
954 return static_cast<CInstanceVFS*>(instance->toAddon->addonInstance)->Open(url);
955 }
956
957 inline static VFS_FILE_HANDLE ADDON_OpenForWrite(const AddonInstance_VFSEntry* instance,
958 const VFSURL* url,
959 bool overWrite)
960 {
961 return static_cast<CInstanceVFS*>(instance->toAddon->addonInstance)
962 ->OpenForWrite(url, overWrite);
963 }
964
965 inline static ssize_t ADDON_Read(const AddonInstance_VFSEntry* instance,
966 VFS_FILE_HANDLE context,
967 uint8_t* buffer,
968 size_t uiBufSize)
969 {
970 return static_cast<CInstanceVFS*>(instance->toAddon->addonInstance)
971 ->Read(context, buffer, uiBufSize);
972 }
973
974 inline static ssize_t ADDON_Write(const AddonInstance_VFSEntry* instance,
975 VFS_FILE_HANDLE context,
976 const uint8_t* buffer,
977 size_t uiBufSize)
978 {
979 return static_cast<CInstanceVFS*>(instance->toAddon->addonInstance)
980 ->Write(context, buffer, uiBufSize);
981 }
982
983 inline static int64_t ADDON_Seek(const AddonInstance_VFSEntry* instance,
984 VFS_FILE_HANDLE context,
985 int64_t position,
986 int whence)
987 {
988 return static_cast<CInstanceVFS*>(instance->toAddon->addonInstance)
989 ->Seek(context, position, whence);
990 }
991
992 inline static int ADDON_Truncate(const AddonInstance_VFSEntry* instance,
993 VFS_FILE_HANDLE context,
994 int64_t size)
995 {
996 return static_cast<CInstanceVFS*>(instance->toAddon->addonInstance)->Truncate(context, size);
997 }
998
999 inline static int64_t ADDON_GetLength(const AddonInstance_VFSEntry* instance,
1000 VFS_FILE_HANDLE context)
1001 {
1002 return static_cast<CInstanceVFS*>(instance->toAddon->addonInstance)->GetLength(context);
1003 }
1004
1005 inline static int64_t ADDON_GetPosition(const AddonInstance_VFSEntry* instance,
1006 VFS_FILE_HANDLE context)
1007 {
1008 return static_cast<CInstanceVFS*>(instance->toAddon->addonInstance)->GetPosition(context);
1009 }
1010
1011 inline static int ADDON_GetChunkSize(const AddonInstance_VFSEntry* instance,
1012 VFS_FILE_HANDLE context)
1013 {
1014 return static_cast<CInstanceVFS*>(instance->toAddon->addonInstance)->GetChunkSize(context);
1015 }
1016
1017 inline static bool ADDON_IoControlGetSeekPossible(const AddonInstance_VFSEntry* instance,
1018 VFS_FILE_HANDLE context)
1019 {
1020 return static_cast<CInstanceVFS*>(instance->toAddon->addonInstance)
1021 ->IoControlGetSeekPossible(context);
1022 }
1023
1024 inline static bool ADDON_IoControlGetCacheStatus(const struct AddonInstance_VFSEntry* instance,
1025 VFS_FILE_HANDLE context,
1026 VFS_CACHE_STATUS_DATA* status)
1027 {
1028 kodi::vfs::CacheStatus cppStatus(status);
1029 return static_cast<CInstanceVFS*>(instance->toAddon->addonInstance)
1030 ->IoControlGetCacheStatus(context, cppStatus);
1031 }
1032
1033 inline static bool ADDON_IoControlSetCacheRate(const struct AddonInstance_VFSEntry* instance,
1034 VFS_FILE_HANDLE context,
1035 unsigned int rate)
1036 {
1037 return static_cast<CInstanceVFS*>(instance->toAddon->addonInstance)
1038 ->IoControlSetCacheRate(context, rate);
1039 }
1040
1041 inline static bool ADDON_IoControlSetRetry(const struct AddonInstance_VFSEntry* instance,
1042 VFS_FILE_HANDLE context,
1043 bool retry)
1044 {
1045 return static_cast<CInstanceVFS*>(instance->toAddon->addonInstance)
1046 ->IoControlSetRetry(context, retry);
1047 }
1048
1049 inline static int ADDON_Stat(const AddonInstance_VFSEntry* instance,
1050 const VFSURL* url,
1051 struct STAT_STRUCTURE* buffer)
1052 {
1053 kodi::vfs::FileStatus cppBuffer(buffer);
1054 return static_cast<CInstanceVFS*>(instance->toAddon->addonInstance)->Stat(url, cppBuffer);
1055 }
1056
1057 inline static bool ADDON_Close(const AddonInstance_VFSEntry* instance, VFS_FILE_HANDLE context)
1058 {
1059 return static_cast<CInstanceVFS*>(instance->toAddon->addonInstance)->Close(context);
1060 }
1061
1062 inline static bool ADDON_Exists(const AddonInstance_VFSEntry* instance, const VFSURL* url)
1063 {
1064 return static_cast<CInstanceVFS*>(instance->toAddon->addonInstance)->Exists(url);
1065 }
1066
1067 inline static void ADDON_ClearOutIdle(const AddonInstance_VFSEntry* instance)
1068 {
1069 return static_cast<CInstanceVFS*>(instance->toAddon->addonInstance)->ClearOutIdle();
1070 }
1071
1072 inline static void ADDON_DisconnectAll(const AddonInstance_VFSEntry* instance)
1073 {
1074 return static_cast<CInstanceVFS*>(instance->toAddon->addonInstance)->DisconnectAll();
1075 }
1076
1077 inline static bool ADDON_Delete(const AddonInstance_VFSEntry* instance, const VFSURL* url)
1078 {
1079 return static_cast<CInstanceVFS*>(instance->toAddon->addonInstance)->Delete(url);
1080 }
1081
1082 inline static bool ADDON_Rename(const AddonInstance_VFSEntry* instance,
1083 const VFSURL* url,
1084 const VFSURL* url2)
1085 {
1086 return static_cast<CInstanceVFS*>(instance->toAddon->addonInstance)->Rename(url, url2);
1087 }
1088
1089 inline static bool ADDON_DirectoryExists(const AddonInstance_VFSEntry* instance,
1090 const VFSURL* url)
1091 {
1092 return static_cast<CInstanceVFS*>(instance->toAddon->addonInstance)->DirectoryExists(url);
1093 }
1094
1095 inline static bool ADDON_RemoveDirectory(const AddonInstance_VFSEntry* instance,
1096 const VFSURL* url)
1097 {
1098 return static_cast<CInstanceVFS*>(instance->toAddon->addonInstance)->RemoveDirectory(url);
1099 }
1100
1101 inline static bool ADDON_CreateDirectory(const AddonInstance_VFSEntry* instance,
1102 const VFSURL* url)
1103 {
1104 return static_cast<CInstanceVFS*>(instance->toAddon->addonInstance)->CreateDirectory(url);
1105 }
1106
1107 inline static bool ADDON_GetDirectory(const AddonInstance_VFSEntry* instance,
1108 const VFSURL* url,
1109 VFSDirEntry** retEntries,
1110 int* num_entries,
1111 VFSGetDirectoryCallbacks* callbacks)
1112 {
1113 std::vector<kodi::vfs::CDirEntry> addonEntries;
1114 bool ret = static_cast<CInstanceVFS*>(instance->toAddon->addonInstance)
1115 ->GetDirectory(url, addonEntries, CVFSCallbacks(callbacks));
1116 if (ret)
1117 {
1118 VFSDirEntry* entries =
1119 static_cast<VFSDirEntry*>(malloc(sizeof(VFSDirEntry) * addonEntries.size()));
1120 for (unsigned int i = 0; i < addonEntries.size(); ++i)
1121 {
1122 entries[i].label = strdup(addonEntries[i].Label().c_str());
1123 entries[i].title = strdup(addonEntries[i].Title().c_str());
1124 entries[i].path = strdup(addonEntries[i].Path().c_str());
1125 entries[i].folder = addonEntries[i].IsFolder();
1126 entries[i].size = addonEntries[i].Size();
1127 entries[i].date_time = addonEntries[i].DateTime();
1128
1129 entries[i].num_props = 0;
1130 const std::map<std::string, std::string>& props = addonEntries[i].GetProperties();
1131 if (!props.empty())
1132 {
1133 entries[i].properties =
1134 static_cast<VFSProperty*>(malloc(sizeof(VFSProperty) * props.size()));
1135 for (const auto& prop : props)
1136 {
1137 entries[i].properties[entries[i].num_props].name = strdup(prop.first.c_str());
1138 entries[i].properties[entries[i].num_props].val = strdup(prop.second.c_str());
1139 ++entries[i].num_props;
1140 }
1141 }
1142 else
1143 entries[i].properties = nullptr;
1144 }
1145 *retEntries = entries;
1146 *num_entries = static_cast<int>(addonEntries.size());
1147 }
1148 return ret;
1149 }
1150
1151 inline static void ADDON_FreeDirectory(const AddonInstance_VFSEntry* instance,
1152 VFSDirEntry* entries,
1153 int num_entries)
1154 {
1155 for (int i = 0; i < num_entries; ++i)
1156 {
1157 if (entries[i].properties)
1158 {
1159 for (unsigned int j = 0; j < entries[i].num_props; ++j)
1160 {
1161 free(entries[i].properties[j].name);
1162 free(entries[i].properties[j].val);
1163 }
1164 free(entries[i].properties);
1165 }
1166 free(entries[i].label);
1167 free(entries[i].title);
1168 free(entries[i].path);
1169 }
1170 free(entries);
1171 }
1172
1173 inline static bool ADDON_ContainsFiles(const AddonInstance_VFSEntry* instance,
1174 const VFSURL* url,
1175 VFSDirEntry** retEntries,
1176 int* num_entries,
1177 char* rootpath)
1178 {
1179 std::string cppRootPath;
1180 std::vector<kodi::vfs::CDirEntry> addonEntries;
1181 bool ret = static_cast<CInstanceVFS*>(instance->toAddon->addonInstance)
1182 ->ContainsFiles(url, addonEntries, cppRootPath);
1183 if (ret)
1184 {
1185 strncpy(rootpath, cppRootPath.c_str(), ADDON_STANDARD_STRING_LENGTH);
1186
1187 VFSDirEntry* entries =
1188 static_cast<VFSDirEntry*>(malloc(sizeof(VFSDirEntry) * addonEntries.size()));
1189 for (size_t i = 0; i < addonEntries.size(); ++i)
1190 {
1191 entries[i].label = strdup(addonEntries[i].Label().c_str());
1192 entries[i].title = strdup(addonEntries[i].Title().c_str());
1193 entries[i].path = strdup(addonEntries[i].Path().c_str());
1194 entries[i].folder = addonEntries[i].IsFolder();
1195 entries[i].size = addonEntries[i].Size();
1196 entries[i].date_time = addonEntries[i].DateTime();
1197
1198 entries[i].num_props = 0;
1199 const std::map<std::string, std::string>& props = addonEntries[i].GetProperties();
1200 if (!props.empty())
1201 {
1202 entries[i].properties =
1203 static_cast<VFSProperty*>(malloc(sizeof(VFSProperty) * props.size()));
1204 for (const auto& prop : props)
1205 {
1206 entries[i].properties[entries[i].num_props].name = strdup(prop.first.c_str());
1207 entries[i].properties[entries[i].num_props].val = strdup(prop.second.c_str());
1208 ++entries[i].num_props;
1209 }
1210 }
1211 else
1212 entries[i].properties = nullptr;
1213 }
1214 *retEntries = entries;
1215 *num_entries = static_cast<int>(addonEntries.size());
1216 }
1217 return ret;
1218 }
1219
1220 AddonInstance_VFSEntry* m_instanceData;
1221};
1222
1223} /* namespace addon */
1224} /* namespace kodi */
1225
1226#endif /* __cplusplus */
diff --git a/xbmc/addons/kodi-dev-kit/include/kodi/addon-instance/VideoCodec.h b/xbmc/addons/kodi-dev-kit/include/kodi/addon-instance/VideoCodec.h
new file mode 100644
index 0000000..12893db
--- /dev/null
+++ b/xbmc/addons/kodi-dev-kit/include/kodi/addon-instance/VideoCodec.h
@@ -0,0 +1,249 @@
1/*
2 * Copyright (C) 2017-2018 Team Kodi
3 * This file is part of Kodi - https://kodi.tv
4 *
5 * SPDX-License-Identifier: GPL-2.0-or-later
6 * See LICENSES/README.md for more information.
7 */
8
9#pragma once
10
11#include "../AddonBase.h"
12#include "../StreamCrypto.h"
13#include "../StreamCodec.h"
14
15#ifdef BUILD_KODI_ADDON
16#include "../DemuxPacket.h"
17#else
18#include "cores/VideoPlayer/Interface/Addon/DemuxPacket.h"
19#endif
20
21extern "C"
22{
23 enum VIDEOCODEC_FORMAT
24 {
25 UnknownVideoFormat = 0,
26 VideoFormatYV12,
27 VideoFormatI420,
28 MaxVideoFormats
29 };
30
31
32 struct VIDEOCODEC_INITDATA
33 {
34 enum Codec {
35 CodecUnknown = 0,
36 CodecVp8,
37 CodecH264,
38 CodecVp9
39 } codec;
40
41 STREAMCODEC_PROFILE codecProfile;
42
43 //UnknownVideoFormat is terminator
44 VIDEOCODEC_FORMAT *videoFormats;
45
46 uint32_t width, height;
47
48 const uint8_t *extraData;
49 unsigned int extraDataSize;
50
51 CRYPTO_INFO cryptoInfo;
52 };
53
54 struct VIDEOCODEC_PICTURE
55 {
56 enum VideoPlane {
57 YPlane = 0,
58 UPlane,
59 VPlane,
60 MaxPlanes = 3,
61 };
62
63 enum Flags : uint32_t {
64 FLAG_DROP,
65 FLAG_DRAIN
66 };
67
68 VIDEOCODEC_FORMAT videoFormat;
69 uint32_t flags;
70
71 uint32_t width, height;
72
73 uint8_t *decodedData;
74 size_t decodedDataSize;
75
76 uint32_t planeOffsets[VideoPlane::MaxPlanes];
77 uint32_t stride[VideoPlane::MaxPlanes];
78
79 int64_t pts;
80
81 KODI_HANDLE videoBufferHandle; //< will be passed in release_frame_buffer
82 };
83
84 enum VIDEOCODEC_RETVAL
85 {
86 VC_NONE = 0, //< noop
87 VC_ERROR, //< an error occurred, no other messages will be returned
88 VC_BUFFER, //< the decoder needs more data
89 VC_PICTURE, //< the decoder got a picture
90 VC_EOF, //< the decoder signals EOF
91 };
92
93 // this are properties given to the addon on create
94 // at this time we have no parameters for the addon
95 typedef struct AddonProps_VideoCodec
96 {
97 int dummy;
98 } AddonProps_VideoCodec;
99
100 struct AddonInstance_VideoCodec;
101 typedef struct KodiToAddonFuncTable_VideoCodec
102 {
103 KODI_HANDLE addonInstance;
104
105 //! \brief Opens a codec
106 bool (__cdecl* open) (const AddonInstance_VideoCodec* instance, VIDEOCODEC_INITDATA *initData);
107
108 //! \brief Reconfigures a codec
109 bool (__cdecl* reconfigure) (const AddonInstance_VideoCodec* instance, VIDEOCODEC_INITDATA *initData);
110
111 //! \brief Feed codec if requested from GetPicture() (return VC_BUFFER)
112 bool (__cdecl* add_data) (const AddonInstance_VideoCodec* instance, const DemuxPacket *packet);
113
114 //! \brief Get a decoded picture / request new data
115 VIDEOCODEC_RETVAL (__cdecl* get_picture) (const AddonInstance_VideoCodec* instance, VIDEOCODEC_PICTURE *picture);
116
117 //! \brief Get the name of this video decoder
118 const char *(__cdecl* get_name) (const AddonInstance_VideoCodec* instance);
119
120 //! \brief Reset the codec
121 void (__cdecl* reset)(const AddonInstance_VideoCodec* instance);
122 } KodiToAddonFuncTable_VideoCodec;
123
124 typedef struct AddonToKodiFuncTable_VideoCodec
125 {
126 KODI_HANDLE kodiInstance;
127 bool(*get_frame_buffer)(void* kodiInstance, VIDEOCODEC_PICTURE *picture);
128 void(*release_frame_buffer)(void* kodiInstance, void *buffer);
129 } AddonToKodiFuncTable_VideoCodec;
130
131 typedef struct AddonInstance_VideoCodec
132 {
133 AddonProps_VideoCodec* props;
134 AddonToKodiFuncTable_VideoCodec* toKodi;
135 KodiToAddonFuncTable_VideoCodec* toAddon;
136 } AddonInstance_VideoCodec;
137}
138
139namespace kodi
140{
141 namespace addon
142 {
143
144 class ATTRIBUTE_HIDDEN CInstanceVideoCodec : public IAddonInstance
145 {
146 public:
147 explicit CInstanceVideoCodec(KODI_HANDLE instance, const std::string& kodiVersion = "")
148 : IAddonInstance(ADDON_INSTANCE_VIDEOCODEC,
149 !kodiVersion.empty() ? kodiVersion
150 : GetKodiTypeVersion(ADDON_INSTANCE_VIDEOCODEC))
151 {
152 if (CAddonBase::m_interface->globalSingleInstance != nullptr)
153 throw std::logic_error("kodi::addon::CInstanceVideoCodec: Creation of multiple together with single instance way is not allowed!");
154
155 SetAddonStruct(instance);
156 }
157
158 ~CInstanceVideoCodec() override = default;
159
160 //! \copydoc CInstanceVideoCodec::Open
161 virtual bool Open(VIDEOCODEC_INITDATA &initData) { return false; };
162
163 //! \copydoc CInstanceVideoCodec::Reconfigure
164 virtual bool Reconfigure(VIDEOCODEC_INITDATA &initData) { return false; };
165
166 //! \copydoc CInstanceVideoCodec::AddData
167 virtual bool AddData(const DemuxPacket &packet) { return false; };
168
169 //! \copydoc CInstanceVideoCodec::GetPicture
170 virtual VIDEOCODEC_RETVAL GetPicture(VIDEOCODEC_PICTURE &picture) { return VC_ERROR; };
171
172 //! \copydoc CInstanceVideoCodec::GetName
173 virtual const char *GetName() { return nullptr; };
174
175 //! \copydoc CInstanceVideoCodec::Reset
176 virtual void Reset() {};
177
178 /*!
179 * @brief AddonToKodi interface
180 */
181
182 //! \copydoc CInstanceVideoCodec::GetFrameBuffer
183 bool GetFrameBuffer(VIDEOCODEC_PICTURE &picture)
184 {
185 return m_instanceData->toKodi->get_frame_buffer(m_instanceData->toKodi->kodiInstance,
186 &picture);
187 }
188
189 //! \copydoc CInstanceVideoCodec::ReleaseFrameBuffer
190 void ReleaseFrameBuffer(void *buffer)
191 {
192 return m_instanceData->toKodi->release_frame_buffer(m_instanceData->toKodi->kodiInstance,
193 buffer);
194 }
195
196 private:
197 void SetAddonStruct(KODI_HANDLE instance)
198 {
199 if (instance == nullptr)
200 throw std::logic_error("kodi::addon::CInstanceVideoCodec: Creation with empty addon structure not allowed, table must be given from Kodi!");
201
202 m_instanceData = static_cast<AddonInstance_VideoCodec*>(instance);
203
204 m_instanceData->toAddon->addonInstance = this;
205 m_instanceData->toAddon->open = ADDON_Open;
206 m_instanceData->toAddon->reconfigure = ADDON_Reconfigure;
207 m_instanceData->toAddon->add_data = ADDON_AddData;
208 m_instanceData->toAddon->get_picture = ADDON_GetPicture;
209 m_instanceData->toAddon->get_name = ADDON_GetName;
210 m_instanceData->toAddon->reset = ADDON_Reset;
211 }
212
213 inline static bool ADDON_Open(const AddonInstance_VideoCodec* instance, VIDEOCODEC_INITDATA *initData)
214 {
215 return static_cast<CInstanceVideoCodec*>(instance->toAddon->addonInstance)->Open(*initData);
216 }
217
218 inline static bool ADDON_Reconfigure(const AddonInstance_VideoCodec* instance, VIDEOCODEC_INITDATA *initData)
219 {
220 return static_cast<CInstanceVideoCodec*>(instance->toAddon->addonInstance)
221 ->Reconfigure(*initData);
222 }
223
224 inline static bool ADDON_AddData(const AddonInstance_VideoCodec* instance, const DemuxPacket *packet)
225 {
226 return static_cast<CInstanceVideoCodec*>(instance->toAddon->addonInstance)
227 ->AddData(*packet);
228 }
229
230 inline static VIDEOCODEC_RETVAL ADDON_GetPicture(const AddonInstance_VideoCodec* instance, VIDEOCODEC_PICTURE *picture)
231 {
232 return static_cast<CInstanceVideoCodec*>(instance->toAddon->addonInstance)
233 ->GetPicture(*picture);
234 }
235
236 inline static const char *ADDON_GetName(const AddonInstance_VideoCodec* instance)
237 {
238 return static_cast<CInstanceVideoCodec*>(instance->toAddon->addonInstance)->GetName();
239 }
240
241 inline static void ADDON_Reset(const AddonInstance_VideoCodec* instance)
242 {
243 return static_cast<CInstanceVideoCodec*>(instance->toAddon->addonInstance)->Reset();
244 }
245
246 AddonInstance_VideoCodec* m_instanceData;
247 };
248 } // namespace addon
249} // namespace kodi
diff --git a/xbmc/addons/kodi-dev-kit/include/kodi/addon-instance/Visualization.h b/xbmc/addons/kodi-dev-kit/include/kodi/addon-instance/Visualization.h
new file mode 100644
index 0000000..7b1db65
--- /dev/null
+++ b/xbmc/addons/kodi-dev-kit/include/kodi/addon-instance/Visualization.h
@@ -0,0 +1,992 @@
1/*
2 * Copyright (C) 2005-2018 Team Kodi
3 * This file is part of Kodi - https://kodi.tv
4 *
5 * SPDX-License-Identifier: GPL-2.0-or-later
6 * See LICENSES/README.md for more information.
7 */
8
9#pragma once
10
11#include "../AddonBase.h"
12#include "../c-api/addon-instance/visualization.h"
13#include "../gui/renderHelper.h"
14
15#ifdef __cplusplus
16namespace kodi
17{
18namespace addon
19{
20
21
22//==============================================================================
23/// @defgroup cpp_kodi_addon_visualization_Defs_VisualizationTrack class VisualizationTrack
24/// @ingroup cpp_kodi_addon_visualization_Defs
25/// @brief **Info tag data structure**\n
26/// Representation of available information of processed audio file.
27///
28/// This is used to store all the necessary data of audio stream and to have on
29/// e.g. GUI for information.
30///
31/// Called from @ref kodi::addon::CInstanceVisualization::UpdateTrack() with the
32/// information of the currently-playing song.
33///
34/// ----------------------------------------------------------------------------
35///
36/// @copydetails cpp_kodi_addon_visualization_Defs_VisualizationTrack_Help
37///
38///@{
39class VisualizationTrack
40{
41 /*! \cond PRIVATE */
42 friend class CInstanceVisualization;
43 /*! \endcond */
44
45public:
46 /*! \cond PRIVATE */
47 VisualizationTrack() = default;
48 VisualizationTrack(const VisualizationTrack& tag)
49 {
50 *this = tag;
51 }
52
53 VisualizationTrack& operator=(const VisualizationTrack& right)
54 {
55 if (&right == this)
56 return *this;
57
58 m_title = right.m_title;
59 m_artist = right.m_artist;
60 m_album = right.m_album;
61 m_albumArtist = right.m_albumArtist;
62 m_genre = right.m_genre;
63 m_comment = right.m_comment;
64 m_lyrics = right.m_lyrics;
65
66 m_trackNumber = right.m_trackNumber;
67 m_discNumber = right.m_discNumber;
68 m_duration = right.m_duration;
69 m_year = right.m_year;
70 m_rating = right.m_rating;
71 return *this;
72 }
73 /*! \endcond */
74
75 /// @defgroup cpp_kodi_addon_visualization_Defs_VisualizationTrack_Help Value Help
76 /// @ingroup cpp_kodi_addon_visualization_Defs_VisualizationTrack
77 ///
78 /// <b>The following table contains values that can be set with @ref cpp_kodi_addon_visualization_Defs_VisualizationTrack :</b>
79 /// | Name | Type | Set call | Get call
80 /// |------|------|----------|----------
81 /// | **Title of the current song.** | `std::string` | @ref VisualizationTrack::SetTitle "SetTitle" | @ref VisualizationTrack::GetTitle "GetTitle"
82 /// | **Artist names, as a single string** | `std::string` | @ref VisualizationTrack::SetArtist "SetArtist" | @ref VisualizationTrack::GetArtist "GetArtist"
83 /// | **Album that the current song is from.** | `std::string` | @ref VisualizationTrack::SetAlbum "SetAlbum" | @ref VisualizationTrack::GetAlbum "GetAlbum"
84 /// | **Album artist names, as a single string** | `std::string` | @ref VisualizationTrack::SetAlbumArtist "SetAlbumArtist" | @ref VisualizationTrack::GetAlbumArtist "GetAlbumArtist"
85 /// | **The genre name from the music tag, if present** | `std::string` | @ref VisualizationTrack::SetGenre "SetGenre" | @ref VisualizationTrack::GetGenre "GetGenre"
86 /// | **Duration of the current song, in seconds** | `int` | @ref VisualizationTrack::SetDuration "SetDuration" | @ref VisualizationTrack::GetDuration "GetDuration"
87 /// | **Track number of the current song** | `int` | @ref VisualizationTrack::SetTrack "SetTrack" | @ref VisualizationTrack::GetTrack "GetTrack"
88 /// | **Disc number of the current song stored in the ID tag info** | `int` | @ref VisualizationTrack::SetDisc "SetDisc" | @ref VisualizationTrack::GetDisc "GetDisc"
89 /// | **Year that the current song was released** | `int` | @ref VisualizationTrack::SetYear "SetYear" | @ref VisualizationTrack::GetYear "GetYear"
90 /// | **Lyrics of the current song, if available** | `std::string` | @ref VisualizationTrack::SetLyrics "SetLyrics" | @ref VisualizationTrack::GetLyrics "GetLyrics"
91 /// | **The user-defined rating of the current song** | `int` | @ref VisualizationTrack::SetRating "SetRating" | @ref VisualizationTrack::GetRating "GetRating"
92 /// | **Comment of the current song stored in the ID tag info** | `std::string` | @ref VisualizationTrack::SetComment "SetComment" | @ref VisualizationTrack::GetComment "GetComment"
93 ///
94
95 /// @addtogroup cpp_kodi_addon_visualization_Defs_VisualizationTrack
96 ///@{
97
98 /// @brief Set title of the current song.
99 void SetTitle(const std::string& title) { m_title = title; }
100
101 /// @brief Get title of the current song.
102 const std::string& GetTitle() const { return m_title; }
103
104 /// @brief Set artist names, as a single string-
105 void SetArtist(const std::string& artist) { m_artist = artist; }
106
107 /// @brief Get artist names, as a single string-
108 const std::string& GetArtist() const { return m_artist; }
109
110 /// @brief Set Album that the current song is from.
111 void SetAlbum(const std::string& album) { m_album = album; }
112
113 /// @brief Get Album that the current song is from.
114 const std::string& GetAlbum() const { return m_album; }
115
116 /// @brief Set album artist names, as a single stringalbum artist name
117 void SetAlbumArtist(const std::string& albumArtist) { m_albumArtist = albumArtist; }
118
119 /// @brief Get album artist names, as a single string-
120 const std::string& GetAlbumArtist() const { return m_albumArtist; }
121
122 /// @brief Set genre name from music as string if present.
123 void SetGenre(const std::string& genre) { m_genre = genre; }
124
125 /// @brief Get genre name from music as string if present.
126 const std::string& GetGenre() const { return m_genre; }
127
128 /// @brief Set the duration of music as integer from info.
129 void SetDuration(int duration) { m_duration = duration; }
130
131 /// @brief Get the duration of music as integer from info.
132 int GetDuration() const { return m_duration; }
133
134 /// @brief Set track number (if present) from music info as integer.
135 void SetTrack(int trackNumber) { m_trackNumber = trackNumber; }
136
137 /// @brief Get track number (if present).
138 int GetTrack() const { return m_trackNumber; }
139
140 /// @brief Set disk number (if present) from music info as integer.
141 void SetDisc(int discNumber) { m_discNumber = discNumber; }
142
143 /// @brief Get disk number (if present)
144 int GetDisc() const { return m_discNumber; }
145
146 /// @brief Set year that the current song was released.
147 void SetYear(int year) { m_year = year; }
148
149 /// @brief Get year that the current song was released.
150 int GetYear() const { return m_year; }
151
152 /// @brief Set string from lyrics.
153 void SetLyrics(const std::string& lyrics) { m_lyrics = lyrics; }
154
155 /// @brief Get string from lyrics.
156 const std::string& GetLyrics() const { return m_lyrics; }
157
158 /// @brief Set the user-defined rating of the current song.
159 void SetRating(int rating) { m_rating = rating; }
160
161 /// @brief Get the user-defined rating of the current song.
162 int GetRating() const { return m_rating; }
163
164 /// @brief Set additional information comment (if present).
165 void SetComment(const std::string& comment) { m_comment = comment; }
166
167 /// @brief Get additional information comment (if present).
168 const std::string& GetComment() const { return m_comment; }
169
170 ///@}
171
172private:
173 VisualizationTrack(const VIS_TRACK* tag)
174 {
175 if (!tag)
176 return;
177
178 m_title = tag->title ? tag->title : "";
179 m_artist = tag->artist ? tag->artist : "";
180 m_album = tag->album ? tag->album : "";
181 m_albumArtist = tag->albumArtist ? tag->albumArtist : "";
182 m_genre = tag->genre ? tag->genre : "";
183 m_comment = tag->comment ? tag->comment : "";
184 m_lyrics = tag->lyrics ? tag->lyrics : "";
185
186 m_trackNumber = tag->trackNumber;
187 m_discNumber = tag->discNumber;
188 m_duration = tag->duration;
189 m_year = tag->year;
190 m_rating = tag->rating;
191 }
192
193 std::string m_title;
194 std::string m_artist;
195 std::string m_album;
196 std::string m_albumArtist;
197 std::string m_genre;
198 std::string m_comment;
199 std::string m_lyrics;
200
201 int m_trackNumber = 0;
202 int m_discNumber = 0;
203 int m_duration = 0;
204 int m_year = 0;
205 int m_rating = 0;
206};
207///@}
208//------------------------------------------------------------------------------
209
210//==============================================================================
211/// @defgroup cpp_kodi_addon_visualization_Defs Definitions, structures and enumerators
212/// @ingroup cpp_kodi_addon_visualization
213/// @brief **Visualization add-on instance definition values**\n
214/// All visualization functions associated data structures.
215///
216/// Used to exchange the available options between Kodi and addon.
217///
218
219//==============================================================================
220/// @addtogroup cpp_kodi_addon_visualization
221/// @brief \cpp_class{ kodi::addon::CInstanceVisualization }
222/// **Visualization add-on instance**\n
223/// [Music visualization](https://en.wikipedia.org/wiki/Music_visualization),
224/// or music visualisation, is a feature in Kodi that generates animated
225/// imagery based on a piece of music. The imagery is usually generated and
226/// rendered in real time synchronized to the music.
227///
228/// Visualization techniques range from simple ones (e.g., a simulation of an
229/// oscilloscope display) to elaborate ones, which often include a plurality
230/// of composited effects. The changes in the music's loudness and frequency
231/// spectrum are among the properties used as input to the visualization.
232///
233/// Include the header @ref Visualization.h "#include <kodi/addon-instance/Visualization.h>"
234/// to use this class.
235///
236/// This interface allows the creation of visualizations for Kodi, based upon
237/// **DirectX** or/and **OpenGL** rendering with `C++` code.
238///
239/// Additionally, there are several @ref cpp_kodi_addon_visualization_CB "other functions"
240/// available in which the child class can ask about the current hardware,
241/// including the device, display and several other parts.
242///
243/// ----------------------------------------------------------------------------
244///
245/// **Here's an example on addon.xml:**
246/// ~~~~~~~~~~~~~{.xml}
247/// <?xml version="1.0" encoding="UTF-8"?>
248/// <addon
249/// id="visualization.myspecialnamefor"
250/// version="1.0.0"
251/// name="My special visualization addon"
252/// provider-name="Your Name">
253/// <requires>@ADDON_DEPENDS@</requires>
254/// <extension
255/// point="xbmc.player.musicviz"
256/// library_@PLATFORM@="@LIBRARY_FILENAME@"/>
257/// <extension point="xbmc.addon.metadata">
258/// <summary lang="en_GB">My visualization addon addon</summary>
259/// <description lang="en_GB">My visualization addon description</description>
260/// <platform>@PLATFORM@</platform>
261/// </extension>
262/// </addon>
263/// ~~~~~~~~~~~~~
264///
265/// Description to visualization related addon.xml values:
266/// | Name | Description
267/// |:------------------------------|----------------------------------------
268/// | <b>`point`</b> | Addon type specification<br>At all addon types and for this kind always <b>"xbmc.player.musicviz"</b>.
269/// | <b>`library_@PLATFORM@`</b> | Sets the used library name, which is automatically set by cmake at addon build.
270///
271/// --------------------------------------------------------------------------
272///
273/// **Here is an example of the minimum required code to start a visualization:**
274/// ~~~~~~~~~~~~~{.cpp}
275/// #include <kodi/addon-instance/Visualization.h>
276///
277/// class CMyVisualization : public kodi::addon::CAddonBase,
278/// public kodi::addon::CInstanceVisualization
279/// {
280/// public:
281/// CMyVisualization();
282///
283/// bool Start(int channels, int samplesPerSec, int bitsPerSample, std::string songName) override;
284/// void AudioData(const float* audioData, int audioDataLength, float* freqData, int freqDataLength) override;
285/// void Render() override;
286/// };
287///
288/// CMyVisualization::CMyVisualization()
289/// {
290/// ...
291/// }
292///
293/// bool CMyVisualization::Start(int channels, int samplesPerSec, int bitsPerSample, std::string songName)
294/// {
295/// ...
296/// return true;
297/// }
298///
299/// void CMyVisualization::AudioData(const float* audioData, int audioDataLength, float* freqData, int freqDataLength)
300/// {
301/// ...
302/// }
303///
304/// void CMyVisualization::Render()
305/// {
306/// ...
307/// }
308///
309/// ADDONCREATOR(CMyVisualization)
310/// ~~~~~~~~~~~~~
311///
312///
313/// --------------------------------------------------------------------------
314///
315///
316/// **Here is another example where the visualization is used together with
317/// other instance types:**
318///
319/// ~~~~~~~~~~~~~{.cpp}
320/// #include <kodi/addon-instance/Visualization.h>
321///
322/// class CMyVisualization : public kodi::addon::CInstanceVisualization
323/// {
324/// public:
325/// CMyVisualization(KODI_HANDLE instance, const std::string& version);
326///
327/// bool Start(int channels, int samplesPerSec, int bitsPerSample, std::string songName) override;
328/// void AudioData(const float* audioData, int audioDataLength, float* freqData, int freqDataLength) override;
329/// void Render() override;
330/// };
331///
332/// CMyVisualization::CMyVisualization(KODI_HANDLE instance, const std::string& version)
333/// : kodi::addon::CInstanceAudioDecoder(instance, version)
334/// {
335/// ...
336/// }
337///
338/// bool CMyVisualization::Start(int channels, int samplesPerSec, int bitsPerSample, std::string songName)
339/// {
340/// ...
341/// return true;
342/// }
343///
344/// void CMyVisualization::AudioData(const float* audioData, int audioDataLength, float* freqData, int freqDataLength)
345/// {
346/// ...
347/// }
348///
349/// void CMyVisualization::Render()
350/// {
351/// ...
352/// }
353///
354///
355/// //----------------------------------------------------------------------
356///
357/// class CMyAddon : public kodi::addon::CAddonBase
358/// {
359/// public:
360/// CMyAddon() { }
361/// ADDON_STATUS CreateInstance(int instanceType,
362/// const std::string& instanceID,
363/// KODI_HANDLE instance,
364/// const std::string& version,
365/// KODI_HANDLE& addonInstance) override;
366/// };
367///
368/// // If you use only one instance in your add-on, can be instanceType and
369/// // instanceID ignored
370/// ADDON_STATUS CMyAddon::CreateInstance(int instanceType,
371/// const std::string& instanceID,
372/// KODI_HANDLE instance,
373/// const std::string& version,
374/// KODI_HANDLE& addonInstance)
375/// {
376/// if (instanceType == ADDON_INSTANCE_VISUALIZATION)
377/// {
378/// kodi::Log(ADDON_LOG_INFO, "Creating my visualization");
379/// addonInstance = new CMyVisualization(instance, version);
380/// return ADDON_STATUS_OK;
381/// }
382/// else if (...)
383/// {
384/// ...
385/// }
386/// return ADDON_STATUS_UNKNOWN;
387/// }
388///
389/// ADDONCREATOR(CMyAddon)
390/// ~~~~~~~~~~~~~
391///
392/// The destruction of the example class `CMyVisualization` is called from
393/// Kodi's header. Manually deleting the add-on instance is not required.
394///
395class ATTRIBUTE_HIDDEN CInstanceVisualization : public IAddonInstance
396{
397public:
398 //============================================================================
399 ///
400 /// @ingroup cpp_kodi_addon_visualization
401 /// @brief Visualization class constructor
402 ///
403 /// Used by an add-on that only supports visualizations.
404 ///
405 CInstanceVisualization()
406 : IAddonInstance(ADDON_INSTANCE_VISUALIZATION, GetKodiTypeVersion(ADDON_INSTANCE_VISUALIZATION))
407 {
408 if (CAddonBase::m_interface->globalSingleInstance != nullptr)
409 throw std::logic_error(
410 "kodi::addon::CInstanceVisualization: Cannot create multiple instances of add-on.");
411
412 SetAddonStruct(CAddonBase::m_interface->firstKodiInstance);
413 CAddonBase::m_interface->globalSingleInstance = this;
414 }
415 //----------------------------------------------------------------------------
416
417 //==========================================================================
418 /// @ingroup cpp_kodi_addon_visualization
419 /// @brief Visualization class constructor used to support multiple instance
420 /// types.
421 ///
422 /// @param[in] instance The instance value given to
423 /// <b>`kodi::addon::CAddonBase::CreateInstance(...)`</b>.
424 /// @param[in] kodiVersion [opt] Version used in Kodi for this instance, to
425 /// allow compatibility to older Kodi versions.
426 ///
427 /// @note Recommended to set <b>`kodiVersion`</b>.
428 ///
429 ///
430 /// --------------------------------------------------------------------------
431 ///
432 /// **Here's example about the use of this:**
433 /// ~~~~~~~~~~~~~{.cpp}
434 /// class CMyVisualization : public kodi::addon::CInstanceAudioDecoder
435 /// {
436 /// public:
437 /// CMyVisualization(KODI_HANDLE instance, const std::string& kodiVersion)
438 /// : kodi::addon::CInstanceAudioDecoder(instance, kodiVersion)
439 /// {
440 /// ...
441 /// }
442 ///
443 /// ...
444 /// };
445 ///
446 /// ADDON_STATUS CMyAddon::CreateInstance(int instanceType,
447 /// const std::string& instanceID,
448 /// KODI_HANDLE instance,
449 /// const std::string& version,
450 /// KODI_HANDLE& addonInstance)
451 /// {
452 /// kodi::Log(ADDON_LOG_INFO, "Creating my visualization");
453 /// addonInstance = new CMyVisualization(instance, version);
454 /// return ADDON_STATUS_OK;
455 /// }
456 /// ~~~~~~~~~~~~~
457 ///
458 explicit CInstanceVisualization(KODI_HANDLE instance, const std::string& kodiVersion = "")
459 : IAddonInstance(ADDON_INSTANCE_VISUALIZATION,
460 !kodiVersion.empty() ? kodiVersion
461 : GetKodiTypeVersion(ADDON_INSTANCE_VISUALIZATION))
462 {
463 if (CAddonBase::m_interface->globalSingleInstance != nullptr)
464 throw std::logic_error("kodi::addon::CInstanceVisualization: Creation of multiple together "
465 "with single instance way is not allowed!");
466
467 SetAddonStruct(instance);
468 }
469 //----------------------------------------------------------------------------
470
471 //============================================================================
472 /// @ingroup cpp_kodi_addon_visualization
473 /// @brief Destructor.
474 ///
475 ~CInstanceVisualization() override = default;
476 //----------------------------------------------------------------------------
477
478 //============================================================================
479 /// @ingroup cpp_kodi_addon_visualization
480 /// @brief Used to notify the visualization that a new song has been started.
481 ///
482 /// @param[in] channels Number of channels in the stream
483 /// @param[in] samplesPerSec Samples per second of stream
484 /// @param[in] bitsPerSample Number of bits in one sample
485 /// @param[in] songName The name of the currently-playing song
486 /// @return true if start successful done
487 ///
488 virtual bool Start(int channels, int samplesPerSec, int bitsPerSample, std::string songName)
489 {
490 return true;
491 }
492 //----------------------------------------------------------------------------
493
494 //============================================================================
495 /// @ingroup cpp_kodi_addon_visualization
496 /// @brief Used to inform the visualization that the rendering control was
497 /// stopped.
498 ///
499 virtual void Stop() {}
500 //----------------------------------------------------------------------------
501
502 //============================================================================
503 /// @ingroup cpp_kodi_addon_visualization
504 /// @brief Pass audio data to the visualization.
505 ///
506 /// @param[in] audioData The raw audio data
507 /// @param[in] audioDataLength Length of the audioData array
508 /// @param[in] freqData The [FFT](https://en.wikipedia.org/wiki/Fast_Fourier_transform)
509 /// of the audio data
510 /// @param[in] freqDataLength Length of frequency data array
511 ///
512 /// Values **freqData** and **freqDataLength** are used if GetInfo() returns
513 /// true for the `wantsFreq` parameter. Otherwise, **freqData** is set to
514 /// `nullptr` and **freqDataLength** is `0`.
515 ///
516 virtual void AudioData(const float* audioData,
517 int audioDataLength,
518 float* freqData,
519 int freqDataLength)
520 {
521 }
522 //----------------------------------------------------------------------------
523
524 //============================================================================
525 /// @ingroup cpp_kodi_addon_visualization
526 /// @brief Used to inform Kodi that the rendered region is dirty and need an
527 /// update.
528 ///
529 /// @return True if dirty
530 ///
531 virtual bool IsDirty() { return true; }
532 //----------------------------------------------------------------------------
533
534 //============================================================================
535 /// @ingroup cpp_kodi_addon_visualization
536 /// @brief Used to indicate when the add-on should render.
537 ///
538 virtual void Render() {}
539 //----------------------------------------------------------------------------
540
541 //============================================================================
542 /// @ingroup cpp_kodi_addon_visualization
543 /// @brief Used to get the number of buffers from the current visualization.
544 ///
545 /// @param[out] wantsFreq Indicates whether the add-on wants FFT data. If set
546 /// to true, the **freqData** and **freqDataLength**
547 /// parameters of @ref AudioData() are used
548 /// @param[out] syncDelay The number of buffers to delay before calling
549 /// @ref AudioData()
550 ///
551 /// @note If this function is not implemented, it will default to
552 /// `wantsFreq` = false and `syncDelay` = 0.
553 ///
554 virtual void GetInfo(bool& wantsFreq, int& syncDelay)
555 {
556 wantsFreq = false;
557 syncDelay = 0;
558 }
559 //----------------------------------------------------------------------------
560
561 //============================================================================
562 /// @ingroup cpp_kodi_addon_visualization
563 /// @brief Used to get a list of visualization presets the user can select.
564 /// from
565 ///
566 /// @param[out] presets The vector list containing the names of presets that
567 /// the user can select
568 /// @return Return true if successful, or false if there are no presets to
569 /// choose from
570 ///
571 virtual bool GetPresets(std::vector<std::string>& presets) { return false; }
572 //----------------------------------------------------------------------------
573
574 //============================================================================
575 /// @ingroup cpp_kodi_addon_visualization
576 /// @brief Get the index of the current preset.
577 ///
578 /// @return Index number of the current preset
579 ///
580 virtual int GetActivePreset() { return -1; }
581 //----------------------------------------------------------------------------
582
583 //============================================================================
584 /// @ingroup cpp_kodi_addon_visualization
585 /// @brief Check if the add-on is locked to the current preset.
586 ///
587 /// @return True if locked to the current preset
588 ///
589 virtual bool IsLocked() { return false; }
590 //----------------------------------------------------------------------------
591
592 //============================================================================
593 /// @ingroup cpp_kodi_addon_visualization
594 /// @brief Load the previous visualization preset.
595 ///
596 /// @return Return true if the previous preset was loaded
597 ///
598 virtual bool PrevPreset() { return false; }
599 //----------------------------------------------------------------------------
600
601 //============================================================================
602 /// @ingroup cpp_kodi_addon_visualization
603 /// @brief Load the next visualization preset.
604 ///
605 /// @return Return true if the next preset was loaded
606 ///
607 virtual bool NextPreset() { return false; }
608 //----------------------------------------------------------------------------
609
610 //============================================================================
611 /// @ingroup cpp_kodi_addon_visualization
612 /// @brief Load a visualization preset.
613 ///
614 /// This function is called after a new preset is selected.
615 ///
616 /// @param[in] select Preset index to use
617 /// @return Return true if the preset is loaded
618 ///
619 virtual bool LoadPreset(int select) { return false; }
620 //----------------------------------------------------------------------------
621
622 //============================================================================
623 /// @ingroup cpp_kodi_addon_visualization
624 /// @brief Switch to a new random preset.
625 ///
626 /// @return Return true if a random preset was loaded
627 ///
628 virtual bool RandomPreset() { return false; }
629 //----------------------------------------------------------------------------
630
631 //============================================================================
632 /// @ingroup cpp_kodi_addon_visualization
633 /// @brief Lock the current visualization preset, preventing it from changing.
634 ///
635 /// @param[in] lockUnlock If set to true, the preset should be locked
636 /// @return Return true if the current preset is locked
637 ///
638 virtual bool LockPreset(bool lockUnlock) { return false; }
639 //----------------------------------------------------------------------------
640
641 //============================================================================
642 /// @ingroup cpp_kodi_addon_visualization
643 /// @brief Used to increase/decrease the visualization preset rating.
644 ///
645 /// @param[in] plusMinus If set to true the rating is increased, otherwise
646 /// decreased
647 /// @return Return true if the rating is modified
648 ///
649 virtual bool RatePreset(bool plusMinus) { return false; }
650 //----------------------------------------------------------------------------
651
652 //============================================================================
653 /// @ingroup cpp_kodi_addon_visualization
654 /// @brief Inform the visualization of the current album art image.
655 ///
656 /// @param[in] albumart Path to the current album art image
657 /// @return Return true if the image is used
658 ///
659 virtual bool UpdateAlbumart(std::string albumart) { return false; }
660 //----------------------------------------------------------------------------
661
662 //============================================================================
663 /// @ingroup cpp_kodi_addon_visualization
664 /// @brief Inform the visualization of the current track's tag information.
665 ///
666 /// @param[in] track Visualization track information structure
667 /// @return Return true if the track information is used
668 ///
669 /// --------------------------------------------------------------------------
670 ///
671 /// @copydetails cpp_kodi_addon_visualization_Defs_VisualizationTrack_Help
672 ///
673 ///-------------------------------------------------------------------------
674 ///
675 /// **Example:**
676 /// ~~~~~~~~~~~~~{.cpp}
677 ///
678 /// #include <kodi/addon-instance/Visualization.h>
679 ///
680 /// class CMyVisualization : public kodi::addon::CInstanceVisualization
681 /// {
682 /// public:
683 /// CMyVisualization(KODI_HANDLE instance, const std::string& version);
684 ///
685 /// ...
686 ///
687 /// private:
688 /// kodi::addon::VisualizationTrack m_runningTrack;
689 /// };
690 ///
691 /// bool CMyVisualization::UpdateTrack(const kodi::addon::VisualizationTrack& track)
692 /// {
693 /// m_runningTrack = track;
694 /// return true;
695 /// }
696 ///
697 /// ~~~~~~~~~~~~~
698 ///
699 virtual bool UpdateTrack(const kodi::addon::VisualizationTrack& track) { return false; }
700 //----------------------------------------------------------------------------
701
702 //============================================================================
703 /// @defgroup cpp_kodi_addon_visualization_CB Information functions
704 /// @ingroup cpp_kodi_addon_visualization
705 /// @brief **To get info about the device, display and several other parts**\n
706 /// These are functions to query any values or to transfer them to Kodi.
707 ///
708 ///@{
709
710 //============================================================================
711 /// @ingroup cpp_kodi_addon_visualization_CB
712 /// @brief To transfer available presets on addon.
713 ///
714 /// Used if @ref GetPresets not possible to use, e.g. where available presets
715 /// are only known during @ref Start call.
716 ///
717 /// @param[in] presets List to store available presets.
718 ///
719 /// @note The function should only be called once, if possible
720 ///
721 inline void TransferPresets(const std::vector<std::string>& presets)
722 {
723 m_instanceData->toKodi->clear_presets(m_instanceData->toKodi->kodiInstance);
724 for (auto it : presets)
725 m_instanceData->toKodi->transfer_preset(m_instanceData->toKodi->kodiInstance, it.c_str());
726 }
727 //----------------------------------------------------------------------------
728
729 //============================================================================
730 /// @ingroup cpp_kodi_addon_visualization_CB
731 /// @brief Device that represents the display adapter.
732 ///
733 /// @return A pointer to the used device with @ref cpp_kodi_Defs_HardwareContext "HardwareContext"
734 ///
735 /// @note This is only available on **DirectX**, It us unused (`nullptr`) on
736 /// **OpenGL**
737 ///
738 ///-------------------------------------------------------------------------
739 ///
740 /// **Example:**
741 /// ~~~~~~~~~~~~~{.cpp}
742 /// #include <d3d11_1.h>
743 /// ..
744 /// // Note: Device() there is used inside addon child class about
745 /// // kodi::addon::CInstanceVisualization
746 /// ID3D11DeviceContext1* context = static_cast<ID3D11DeviceContext1*>(kodi::addon::CInstanceVisualization::Device());
747 /// ..
748 /// ~~~~~~~~~~~~~
749 ///
750 inline kodi::HardwareContext Device() { return m_instanceData->props->device; }
751 //----------------------------------------------------------------------------
752
753 //============================================================================
754 /// @ingroup cpp_kodi_addon_visualization_CB
755 /// @brief Returns the X position of the rendering window.
756 ///
757 /// @return The X position, in pixels
758 ///
759 inline int X() { return m_instanceData->props->x; }
760 //----------------------------------------------------------------------------
761
762 //============================================================================
763 /// @ingroup cpp_kodi_addon_visualization_CB
764 /// @brief Returns the Y position of the rendering window.
765 ///
766 /// @return The Y position, in pixels
767 ///
768 inline int Y() { return m_instanceData->props->y; }
769 //----------------------------------------------------------------------------
770
771 //============================================================================
772 /// @ingroup cpp_kodi_addon_visualization_CB
773 /// @brief Returns the width of the rendering window.
774 ///
775 /// @return The width, in pixels
776 ///
777 inline int Width() { return m_instanceData->props->width; }
778 //----------------------------------------------------------------------------
779
780 //============================================================================
781 /// @ingroup cpp_kodi_addon_visualization_CB
782 /// @brief Returns the height of the rendering window.
783 ///
784 /// @return The height, in pixels
785 ///
786 inline int Height() { return m_instanceData->props->height; }
787 //----------------------------------------------------------------------------
788
789 //============================================================================
790 /// @ingroup cpp_kodi_addon_visualization_CB
791 /// @brief Pixel aspect ratio (often abbreviated PAR) is a ratio that
792 /// describes how the width of a pixel compares to the height of that pixel.
793 ///
794 /// @return The pixel aspect ratio used by the display
795 ///
796 inline float PixelRatio() { return m_instanceData->props->pixelRatio; }
797 //----------------------------------------------------------------------------
798
799 //============================================================================
800 /// @ingroup cpp_kodi_addon_visualization_CB
801 /// @brief Used to get the name of the add-on defined in `addon.xml`.
802 ///
803 /// @return The add-on name
804 ///
805 inline std::string Name() { return m_instanceData->props->name; }
806 //----------------------------------------------------------------------------
807
808 //============================================================================
809 /// @ingroup cpp_kodi_addon_visualization_CB
810 /// @brief Used to get the full path where the add-on is installed.
811 ///
812 /// @return The add-on installation path
813 ///
814 inline std::string Presets() { return m_instanceData->props->presets; }
815 //----------------------------------------------------------------------------
816
817 //============================================================================
818 /// @ingroup cpp_kodi_addon_visualization_CB
819 /// @brief Used to get the full path to the add-on's user profile.
820 ///
821 /// @note The trailing folder (consisting of the add-on's ID) is not created
822 /// by default. If it is needed, you must call kodi::vfs::CreateDirectory()
823 /// to create the folder.
824 ///
825 /// @return Path to the user profile
826 ///
827 inline std::string Profile() { return m_instanceData->props->profile; }
828 //----------------------------------------------------------------------------
829
830 ///@}
831
832private:
833 void SetAddonStruct(KODI_HANDLE instance)
834 {
835 if (instance == nullptr)
836 throw std::logic_error("kodi::addon::CInstanceVisualization: Null pointer instance passed.");
837
838 m_instanceData = static_cast<AddonInstance_Visualization*>(instance);
839 m_instanceData->toAddon->addonInstance = this;
840 m_instanceData->toAddon->start = ADDON_Start;
841 m_instanceData->toAddon->stop = ADDON_Stop;
842 m_instanceData->toAddon->audio_data = ADDON_AudioData;
843 m_instanceData->toAddon->is_dirty = ADDON_IsDirty;
844 m_instanceData->toAddon->render = ADDON_Render;
845 m_instanceData->toAddon->get_info = ADDON_GetInfo;
846 m_instanceData->toAddon->prev_preset = ADDON_PrevPreset;
847 m_instanceData->toAddon->next_preset = ADDON_NextPreset;
848 m_instanceData->toAddon->load_preset = ADDON_LoadPreset;
849 m_instanceData->toAddon->random_preset = ADDON_RandomPreset;
850 m_instanceData->toAddon->lock_preset = ADDON_LockPreset;
851 m_instanceData->toAddon->rate_preset = ADDON_RatePreset;
852 m_instanceData->toAddon->update_albumart = ADDON_UpdateAlbumart;
853 m_instanceData->toAddon->update_track = ADDON_UpdateTrack;
854 m_instanceData->toAddon->get_presets = ADDON_GetPresets;
855 m_instanceData->toAddon->get_active_preset = ADDON_GetActivePreset;
856 m_instanceData->toAddon->is_locked = ADDON_IsLocked;
857 }
858
859 inline static bool ADDON_Start(const AddonInstance_Visualization* addon,
860 int channels,
861 int samplesPerSec,
862 int bitsPerSample,
863 const char* songName)
864 {
865 CInstanceVisualization* thisClass =
866 static_cast<CInstanceVisualization*>(addon->toAddon->addonInstance);
867 thisClass->m_renderHelper = kodi::gui::GetRenderHelper();
868 return thisClass->Start(channels, samplesPerSec, bitsPerSample, songName);
869 }
870
871 inline static void ADDON_Stop(const AddonInstance_Visualization* addon)
872 {
873 CInstanceVisualization* thisClass =
874 static_cast<CInstanceVisualization*>(addon->toAddon->addonInstance);
875 thisClass->Stop();
876 thisClass->m_renderHelper = nullptr;
877 }
878
879 inline static void ADDON_AudioData(const AddonInstance_Visualization* addon,
880 const float* audioData,
881 int audioDataLength,
882 float* freqData,
883 int freqDataLength)
884 {
885 static_cast<CInstanceVisualization*>(addon->toAddon->addonInstance)
886 ->AudioData(audioData, audioDataLength, freqData, freqDataLength);
887 }
888
889 inline static bool ADDON_IsDirty(const AddonInstance_Visualization* addon)
890 {
891 return static_cast<CInstanceVisualization*>(addon->toAddon->addonInstance)->IsDirty();
892 }
893
894 inline static void ADDON_Render(const AddonInstance_Visualization* addon)
895 {
896 CInstanceVisualization* thisClass =
897 static_cast<CInstanceVisualization*>(addon->toAddon->addonInstance);
898 if (!thisClass->m_renderHelper)
899 return;
900 thisClass->m_renderHelper->Begin();
901 thisClass->Render();
902 thisClass->m_renderHelper->End();
903 }
904
905 inline static void ADDON_GetInfo(const AddonInstance_Visualization* addon, VIS_INFO* info)
906 {
907 static_cast<CInstanceVisualization*>(addon->toAddon->addonInstance)
908 ->GetInfo(info->bWantsFreq, info->iSyncDelay);
909 }
910
911 inline static unsigned int ADDON_GetPresets(const AddonInstance_Visualization* addon)
912 {
913 CInstanceVisualization* thisClass =
914 static_cast<CInstanceVisualization*>(addon->toAddon->addonInstance);
915 std::vector<std::string> presets;
916 if (thisClass->GetPresets(presets))
917 {
918 for (auto it : presets)
919 thisClass->m_instanceData->toKodi->transfer_preset(addon->toKodi->kodiInstance, it.c_str());
920 }
921
922 return static_cast<unsigned int>(presets.size());
923 }
924
925 inline static int ADDON_GetActivePreset(const AddonInstance_Visualization* addon)
926 {
927 return static_cast<CInstanceVisualization*>(addon->toAddon->addonInstance)->GetActivePreset();
928 }
929
930 inline static bool ADDON_PrevPreset(const AddonInstance_Visualization* addon)
931 {
932 return static_cast<CInstanceVisualization*>(addon->toAddon->addonInstance)->PrevPreset();
933 }
934
935 inline static bool ADDON_NextPreset(const AddonInstance_Visualization* addon)
936 {
937 return static_cast<CInstanceVisualization*>(addon->toAddon->addonInstance)->NextPreset();
938 }
939
940 inline static bool ADDON_LoadPreset(const AddonInstance_Visualization* addon, int select)
941
942 {
943 return static_cast<CInstanceVisualization*>(addon->toAddon->addonInstance)->LoadPreset(select);
944 }
945
946 inline static bool ADDON_RandomPreset(const AddonInstance_Visualization* addon)
947 {
948 return static_cast<CInstanceVisualization*>(addon->toAddon->addonInstance)->RandomPreset();
949 }
950
951 inline static bool ADDON_LockPreset(const AddonInstance_Visualization* addon)
952 {
953 CInstanceVisualization* thisClass =
954 static_cast<CInstanceVisualization*>(addon->toAddon->addonInstance);
955 thisClass->m_presetLockedByUser = !thisClass->m_presetLockedByUser;
956 return thisClass->LockPreset(thisClass->m_presetLockedByUser);
957 }
958
959 inline static bool ADDON_RatePreset(const AddonInstance_Visualization* addon, bool plus_minus)
960 {
961 return static_cast<CInstanceVisualization*>(addon->toAddon->addonInstance)
962 ->RatePreset(plus_minus);
963 }
964
965 inline static bool ADDON_IsLocked(const AddonInstance_Visualization* addon)
966 {
967 return static_cast<CInstanceVisualization*>(addon->toAddon->addonInstance)->IsLocked();
968 }
969
970 inline static bool ADDON_UpdateAlbumart(const AddonInstance_Visualization* addon,
971 const char* albumart)
972 {
973 return static_cast<CInstanceVisualization*>(addon->toAddon->addonInstance)
974 ->UpdateAlbumart(albumart);
975 }
976
977 inline static bool ADDON_UpdateTrack(const AddonInstance_Visualization* addon,
978 const VIS_TRACK* track)
979 {
980 VisualizationTrack cppTrack(track);
981 return static_cast<CInstanceVisualization*>(addon->toAddon->addonInstance)
982 ->UpdateTrack(cppTrack);
983 }
984
985 std::shared_ptr<kodi::gui::IRenderHelper> m_renderHelper;
986 bool m_presetLockedByUser = false;
987 AddonInstance_Visualization* m_instanceData;
988};
989
990} /* namespace addon */
991} /* namespace kodi */
992#endif /* __cplusplus */
diff --git a/xbmc/addons/kodi-dev-kit/include/kodi/addon-instance/peripheral/CMakeLists.txt b/xbmc/addons/kodi-dev-kit/include/kodi/addon-instance/peripheral/CMakeLists.txt
new file mode 100644
index 0000000..d6fba69
--- /dev/null
+++ b/xbmc/addons/kodi-dev-kit/include/kodi/addon-instance/peripheral/CMakeLists.txt
@@ -0,0 +1,5 @@
1set(HEADERS PeripheralUtils.h)
2
3if(NOT ENABLE_STATIC_LIBS)
4 core_add_library(addons_kodi-dev-kit_include_kodi_addon-instance_peripheral)
5endif()
diff --git a/xbmc/addons/kodi-dev-kit/include/kodi/addon-instance/peripheral/PeripheralUtils.h b/xbmc/addons/kodi-dev-kit/include/kodi/addon-instance/peripheral/PeripheralUtils.h
new file mode 100644
index 0000000..febaeb9
--- /dev/null
+++ b/xbmc/addons/kodi-dev-kit/include/kodi/addon-instance/peripheral/PeripheralUtils.h
@@ -0,0 +1,1277 @@
1/*
2 * Copyright (C) 2014-2018 Team Kodi
3 * This file is part of Kodi - https://kodi.tv
4 *
5 * SPDX-License-Identifier: GPL-2.0-or-later
6 * See LICENSES/README.md for more information.
7 */
8
9#pragma once
10
11#include "../../AddonBase.h"
12#include "../../c-api/addon-instance/peripheral.h"
13
14#ifdef __cplusplus
15
16#include <array> // Requires c++11
17#include <cstring>
18#include <memory>
19#include <string>
20#include <utility>
21#include <vector>
22
23#define PERIPHERAL_SAFE_DELETE(x) \
24 do \
25 { \
26 delete (x); \
27 (x) = NULL; \
28 } while (0)
29#define PERIPHERAL_SAFE_DELETE_ARRAY(x) \
30 do \
31 { \
32 delete[](x); \
33 (x) = NULL; \
34 } while (0)
35
36namespace kodi
37{
38namespace addon
39{
40
41class CInstancePeripheral;
42
43/*!
44 * Utility class to manipulate arrays of peripheral types.
45 */
46template<class THE_CLASS, typename THE_STRUCT>
47class PeripheralVector
48{
49public:
50 static void ToStructs(const std::vector<THE_CLASS>& vecObjects, THE_STRUCT** pStructs)
51 {
52 if (!pStructs)
53 return;
54
55 if (vecObjects.empty())
56 {
57 *pStructs = NULL;
58 }
59 else
60 {
61 (*pStructs) = new THE_STRUCT[vecObjects.size()];
62 for (unsigned int i = 0; i < vecObjects.size(); i++)
63 vecObjects.at(i).ToStruct((*pStructs)[i]);
64 }
65 }
66
67 static void ToStructs(const std::vector<THE_CLASS*>& vecObjects, THE_STRUCT** pStructs)
68 {
69 if (!pStructs)
70 return;
71
72 if (vecObjects.empty())
73 {
74 *pStructs = NULL;
75 }
76 else
77 {
78 *pStructs = new THE_STRUCT[vecObjects.size()];
79 for (unsigned int i = 0; i < vecObjects.size(); i++)
80 vecObjects.at(i)->ToStruct((*pStructs)[i]);
81 }
82 }
83
84 static void ToStructs(const std::vector<std::shared_ptr<THE_CLASS>>& vecObjects,
85 THE_STRUCT** pStructs)
86 {
87 if (!pStructs)
88 return;
89
90 if (vecObjects.empty())
91 {
92 *pStructs = NULL;
93 }
94 else
95 {
96 *pStructs = new THE_STRUCT[vecObjects.size()];
97 for (unsigned int i = 0; i < vecObjects.size(); i++)
98 vecObjects.at(i)->ToStruct((*pStructs)[i]);
99 }
100 }
101
102 static void FreeStructs(unsigned int structCount, THE_STRUCT* structs)
103 {
104 if (structs)
105 {
106 for (unsigned int i = 0; i < structCount; i++)
107 THE_CLASS::FreeStruct(structs[i]);
108 }
109 PERIPHERAL_SAFE_DELETE_ARRAY(structs);
110 }
111};
112
113//==============================================================================
114/// @defgroup cpp_kodi_addon_peripheral_Defs_PeripheralCapabilities class PeripheralCapabilities
115/// @ingroup cpp_kodi_addon_peripheral_Defs_General
116/// @brief **%Peripheral add-on capabilities**\n
117/// This class is needed to tell Kodi which options are supported on the addon.
118///
119/// If a capability is set to **true**, then the corresponding methods from
120/// @ref cpp_kodi_addon_peripheral "kodi::addon::CInstancePeripheral" need to be
121/// implemented.
122///
123/// As default them all set to **false**.
124///
125/// Used on @ref kodi::addon::CInstancePeripheral::GetCapabilities().
126///
127/// ----------------------------------------------------------------------------
128///
129/// @copydetails cpp_kodi_addon_peripheral_Defs_PeripheralCapabilities_Help
130///
131///@{
132class PeripheralCapabilities : public CStructHdl<PeripheralCapabilities, PERIPHERAL_CAPABILITIES>
133{
134 /*! \cond PRIVATE */
135 friend class CInstancePeripheral;
136 /*! \endcond */
137
138public:
139 /*! \cond PRIVATE */
140 PeripheralCapabilities()
141 {
142 m_cStructure->provides_joysticks = false;
143 m_cStructure->provides_joystick_rumble = false;
144 m_cStructure->provides_joystick_power_off = false;
145 m_cStructure->provides_buttonmaps = false;
146 }
147
148 PeripheralCapabilities(const PeripheralCapabilities& data) : CStructHdl(data) {}
149 /*! \endcond */
150
151 /// @defgroup cpp_kodi_addon_peripheral_Defs_PeripheralCapabilities_Help Value Help
152 /// @ingroup cpp_kodi_addon_peripheral_Defs_PeripheralCapabilities
153 /// ----------------------------------------------------------------------------
154 ///
155 /// <b>The following table contains values that can be set with @ref cpp_kodi_addon_peripheral_Defs_PeripheralCapabilities :</b>
156 /// | Name | Type | Set call | Get call
157 /// |------|------|----------|----------
158 /// | **Provides joysticks** | `boolean` | @ref PeripheralCapabilities::SetProvidesJoysticks "SetProvidesJoysticks" | @ref PeripheralCapabilities::GetProvidesJoysticks "GetProvidesJoysticks"
159 /// | **Provides joystick rumble** | `boolean` | @ref PeripheralCapabilities::SetProvidesJoystickRumble "SetProvidesJoystickRumble" | @ref PeripheralCapabilities::GetProvidesJoystickRumble "GetProvidesJoystickRumble"
160 /// | **Provides joystick power off** | `boolean` | @ref PeripheralCapabilities::SetProvidesJoystickPowerOff "SetProvidesJoystickPowerOff" | @ref PeripheralCapabilities::GetProvidesJoystickPowerOff "GetProvidesJoystickPowerOff"
161 /// | **Provides button maps** | `boolean` | @ref PeripheralCapabilities::SetProvidesButtonmaps "SetProvidesButtonmaps" | @ref PeripheralCapabilities::GetProvidesButtonmaps "GetProvidesButtonmaps"
162
163 /// @addtogroup cpp_kodi_addon_peripheral_Defs_PeripheralCapabilities
164 ///@{
165
166 /// @brief Set true if the add-on provides joysticks.
167 void SetProvidesJoysticks(bool providesJoysticks)
168 {
169 m_cStructure->provides_joysticks = providesJoysticks;
170 }
171
172 /// @brief To get with @ref SetProvidesJoysticks changed values.
173 bool GetProvidesJoysticks() const { return m_cStructure->provides_joysticks; }
174
175 /// @brief Set true if the add-on provides joystick rumble.
176 void SetProvidesJoystickRumble(bool providesJoystickRumble)
177 {
178 m_cStructure->provides_joystick_rumble = providesJoystickRumble;
179 }
180
181 /// @brief To get with @ref SetProvidesJoystickRumble changed values.
182 bool GetProvidesJoystickRumble() const { return m_cStructure->provides_joystick_rumble; }
183
184 /// @brief Set true if the add-on provides power off about joystick.
185 void SetProvidesJoystickPowerOff(bool providesJoystickPowerOff)
186 {
187 m_cStructure->provides_joystick_power_off = providesJoystickPowerOff;
188 }
189
190 /// @brief To get with @ref SetProvidesJoystickPowerOff changed values.
191 bool GetProvidesJoystickPowerOff() const { return m_cStructure->provides_joystick_power_off; }
192
193 /// @brief Set true if the add-on provides button maps.
194 void SetProvidesButtonmaps(bool providesButtonmaps)
195 {
196 m_cStructure->provides_buttonmaps = providesButtonmaps;
197 }
198
199 /// @brief To get with @ref SetProvidesButtonmaps changed values.
200 bool GetProvidesButtonmaps() const { return m_cStructure->provides_buttonmaps; }
201
202 ///@}
203
204private:
205 PeripheralCapabilities(const PERIPHERAL_CAPABILITIES* data) : CStructHdl(data) {}
206 PeripheralCapabilities(PERIPHERAL_CAPABILITIES* data) : CStructHdl(data) {}
207};
208///@}
209//------------------------------------------------------------------------------
210
211//==============================================================================
212/// @defgroup cpp_kodi_addon_peripheral_Defs_Peripheral_Peripheral class Peripheral
213/// @ingroup cpp_kodi_addon_peripheral_Defs_Peripheral
214/// @brief **Wrapper class providing peripheral information**\n
215/// Classes can extend %Peripheral to inherit peripheral properties.
216///
217/// Used on @ref kodi::addon::CInstancePeripheral::PerformDeviceScan().
218///
219/// ----------------------------------------------------------------------------
220///
221/// @copydetails cpp_kodi_addon_peripheral_Defs_Peripheral_Peripheral_Help
222///
223///@{
224class Peripheral
225{
226public:
227 /// @defgroup cpp_kodi_addon_peripheral_Defs_Peripheral_Peripheral_Help Value Help
228 /// @ingroup cpp_kodi_addon_peripheral_Defs_Peripheral_Peripheral
229 /// ----------------------------------------------------------------------------
230 ///
231 /// <b>The following table contains values that can be set with @ref cpp_kodi_addon_peripheral_Defs_Peripheral_Peripheral :</b>
232 /// | Name | Type | Set call | Get call
233 /// |------|------|----------|----------
234 /// | **%Peripheral type** | @ref PERIPHERAL_TYPE | @ref Peripheral::SetType "SetType" | @ref Peripheral::Type "Type"
235 /// | **%Peripheral name** | `const std::string&` | @ref Peripheral::SetName "SetName" | @ref Peripheral::Name "Name"
236 /// | **%Peripheral vendor id** | `uint16_t` | @ref Peripheral::SetVendorID "SetVendorID" | @ref Peripheral::VendorID "VendorID"
237 /// | **%Peripheral product id** | `uint16_t` | @ref Peripheral::SetProductID "SetProductID" | @ref Peripheral::ProductID "ProductID"
238 /// | **%Peripheral index** | `unsigned int` | @ref Peripheral::SetIndex "SetIndex" | @ref Peripheral::Index "Index"
239 ///
240 /// Further are following included:
241 /// - @ref Peripheral::Peripheral "Peripheral(PERIPHERAL_TYPE type = PERIPHERAL_TYPE_UNKNOWN, const std::string& strName = \"\")": Class constructor.
242 /// - @ref Peripheral::IsVidPidKnown "IsVidPidKnown()": To check VID and PID are known.
243 ///
244
245 /// @addtogroup cpp_kodi_addon_peripheral_Defs_Peripheral_Peripheral
246 ///@{
247
248 /// @brief Constructor.
249 ///
250 /// @param[in] type [optional] Peripheral type, or @ref PERIPHERAL_TYPE_UNKNOWN
251 /// as default
252 /// @param[in] strName [optional] Name of related peripheral
253 Peripheral(PERIPHERAL_TYPE type = PERIPHERAL_TYPE_UNKNOWN, const std::string& strName = "")
254 : m_type(type), m_strName(strName)
255 {
256 }
257
258 /// @brief Destructor.
259 virtual ~Peripheral(void) = default;
260
261 /// @brief Get peripheral type.
262 ///
263 /// @return Type defined with @ref PERIPHERAL_TYPE
264 PERIPHERAL_TYPE Type(void) const { return m_type; }
265
266 /// @brief Get peripheral name.
267 ///
268 /// @return Name string of peripheral
269 const std::string& Name(void) const { return m_strName; }
270
271 /// @brief Get peripheral vendor id.
272 ///
273 /// @return Vendor id
274 uint16_t VendorID(void) const { return m_vendorId; }
275
276 /// @brief Get peripheral product id.
277 ///
278 /// @return Product id
279 uint16_t ProductID(void) const { return m_productId; }
280
281 /// @brief Get peripheral index identifier.
282 ///
283 /// @return Index number
284 unsigned int Index(void) const { return m_index; }
285
286 /// @brief Check VID and PID are known.
287 ///
288 /// @return true if VID and PID are not 0
289 ///
290 /// @note Derived property: VID and PID are `0x0000` if unknown
291 bool IsVidPidKnown(void) const { return m_vendorId != 0 || m_productId != 0; }
292
293 /// @brief Set peripheral type.
294 ///
295 /// @param[in] type Type to set
296 void SetType(PERIPHERAL_TYPE type) { m_type = type; }
297
298 /// @brief Set peripheral name.
299 ///
300 /// @param[in] strName Name to set
301 void SetName(const std::string& strName) { m_strName = strName; }
302
303 /// @brief Set peripheral vendor id.
304 ///
305 /// @param[in] vendorId Type to set
306 void SetVendorID(uint16_t vendorId) { m_vendorId = vendorId; }
307
308 /// @brief Set peripheral product identifier.
309 ///
310 /// @param[in] productId Type to set
311 void SetProductID(uint16_t productId) { m_productId = productId; }
312
313 /// @brief Set peripheral index.
314 ///
315 /// @param[in] index Type to set
316 void SetIndex(unsigned int index) { m_index = index; }
317
318 ///@}
319
320 explicit Peripheral(const PERIPHERAL_INFO& info)
321 : m_type(info.type),
322 m_strName(info.name ? info.name : ""),
323 m_vendorId(info.vendor_id),
324 m_productId(info.product_id),
325 m_index(info.index)
326 {
327 }
328
329 void ToStruct(PERIPHERAL_INFO& info) const
330 {
331 info.type = m_type;
332 info.name = new char[m_strName.size() + 1];
333 info.vendor_id = m_vendorId;
334 info.product_id = m_productId;
335 info.index = m_index;
336
337 std::strcpy(info.name, m_strName.c_str());
338 }
339
340 static void FreeStruct(PERIPHERAL_INFO& info) { PERIPHERAL_SAFE_DELETE_ARRAY(info.name); }
341
342private:
343 PERIPHERAL_TYPE m_type;
344 std::string m_strName;
345 uint16_t m_vendorId = 0;
346 uint16_t m_productId = 0;
347 unsigned int m_index = 0;
348};
349///@}
350//------------------------------------------------------------------------------
351
352typedef PeripheralVector<Peripheral, PERIPHERAL_INFO> Peripherals;
353
354//==============================================================================
355/// @defgroup cpp_kodi_addon_peripheral_Defs_Peripheral_PeripheralEvent class PeripheralEvent
356/// @ingroup cpp_kodi_addon_peripheral_Defs_Peripheral
357/// @brief **Wrapper class for %peripheral events**\n
358/// To handle data of change events between add-on and Kodi.
359///
360/// Used on @ref kodi::addon::CInstancePeripheral::GetEvents() and
361/// @ref kodi::addon::CInstancePeripheral::SendEvent().
362///
363/// ----------------------------------------------------------------------------
364///
365/// @copydetails cpp_kodi_addon_peripheral_Defs_Peripheral_PeripheralEvent_Help
366///
367///@{
368class PeripheralEvent
369{
370public:
371 /// @defgroup cpp_kodi_addon_peripheral_Defs_Peripheral_PeripheralEvent_Help Value Help
372 /// @ingroup cpp_kodi_addon_peripheral_Defs_Peripheral_PeripheralEvent
373 /// ----------------------------------------------------------------------------
374 ///
375 /// <b>The following table contains values that can be set with @ref cpp_kodi_addon_peripheral_Defs_Peripheral_PeripheralEvent :</b>
376 /// | Name | Type | Set call | Get call
377 /// |------|------|----------|----------
378 /// | **%Peripheral event type** | @ref PERIPHERAL_EVENT_TYPE | @ref PeripheralEvent::SetType "SetType" | @ref PeripheralEvent::Type "Type"
379 /// | **%Peripheral index** | `unsigned int` | @ref PeripheralEvent::SetPeripheralIndex "SetPeripheralIndex" | @ref PeripheralEvent::PeripheralIndex "PeripheralIndex"
380 /// | **%Peripheral event driver index** | `unsigned int` | @ref PeripheralEvent::SetDriverIndex "SetDriverIndex" | @ref PeripheralEvent::DriverIndex "DriverIndex"
381 /// | **%Peripheral event button state** | @ref JOYSTICK_STATE_BUTTON | @ref PeripheralEvent::SetButtonState "SetButtonState" | @ref PeripheralEvent::ButtonState "ButtonState"
382 /// | **%Peripheral event hat state** | @ref JOYSTICK_STATE_HAT | @ref PeripheralEvent::SetHatState "SetHatState" | @ref PeripheralEvent::HatState "HatState"
383 /// | **%Peripheral event axis state** | @ref JOYSTICK_STATE_AXIS (`float`) | @ref PeripheralEvent::SetAxisState "SetAxisState" | @ref PeripheralEvent::AxisState "AxisState"
384 /// | **%Peripheral event motor state** | @ref JOYSTICK_STATE_MOTOR (`float`) | @ref PeripheralEvent::SetMotorState "SetMotorState" | @ref PeripheralEvent::MotorState "MotorState"
385 ///
386 /// Further are several class constructors with values included.
387
388 /// @addtogroup cpp_kodi_addon_peripheral_Defs_Peripheral_PeripheralEvent
389 ///@{
390
391 /// @brief Constructor.
392 PeripheralEvent() = default;
393
394 /// @brief Constructor.
395 ///
396 /// @param[in] peripheralIndex %Peripheral index
397 /// @param[in] buttonIndex Button index
398 /// @param[in] state Joystick state button
399 PeripheralEvent(unsigned int peripheralIndex,
400 unsigned int buttonIndex,
401 JOYSTICK_STATE_BUTTON state)
402 : m_type(PERIPHERAL_EVENT_TYPE_DRIVER_BUTTON),
403 m_peripheralIndex(peripheralIndex),
404 m_driverIndex(buttonIndex),
405 m_buttonState(state)
406 {
407 }
408
409 /// @brief Constructor.
410 ///
411 /// @param[in] peripheralIndex %Peripheral index
412 /// @param[in] hatIndex Hat index
413 /// @param[in] state Joystick state hat
414 PeripheralEvent(unsigned int peripheralIndex, unsigned int hatIndex, JOYSTICK_STATE_HAT state)
415 : m_type(PERIPHERAL_EVENT_TYPE_DRIVER_HAT),
416 m_peripheralIndex(peripheralIndex),
417 m_driverIndex(hatIndex),
418 m_hatState(state)
419 {
420 }
421
422 /// @brief Constructor.
423 ///
424 /// @param[in] peripheralIndex %Peripheral index
425 /// @param[in] axisIndex Axis index
426 /// @param[in] state Joystick state axis
427 PeripheralEvent(unsigned int peripheralIndex, unsigned int axisIndex, JOYSTICK_STATE_AXIS state)
428 : m_type(PERIPHERAL_EVENT_TYPE_DRIVER_AXIS),
429 m_peripheralIndex(peripheralIndex),
430 m_driverIndex(axisIndex),
431 m_axisState(state)
432 {
433 }
434
435 /// @brief Get type of event.
436 ///
437 /// @return Type defined with @ref PERIPHERAL_EVENT_TYPE
438 PERIPHERAL_EVENT_TYPE Type(void) const { return m_type; }
439
440 /// @brief Get peripheral index.
441 ///
442 /// @return %Peripheral index number
443 unsigned int PeripheralIndex(void) const { return m_peripheralIndex; }
444
445 /// @brief Get driver index.
446 ///
447 /// @return Driver index number
448 unsigned int DriverIndex(void) const { return m_driverIndex; }
449
450 /// @brief Get button state.
451 ///
452 /// @return Button state as @ref JOYSTICK_STATE_BUTTON
453 JOYSTICK_STATE_BUTTON ButtonState(void) const { return m_buttonState; }
454
455 /// @brief Get hat state.
456 ///
457 /// @return Hat state
458 JOYSTICK_STATE_HAT HatState(void) const { return m_hatState; }
459
460 /// @brief Get axis state.
461 ///
462 /// @return Axis state
463 JOYSTICK_STATE_AXIS AxisState(void) const { return m_axisState; }
464
465 /// @brief Get motor state.
466 ///
467 /// @return Motor state
468 JOYSTICK_STATE_MOTOR MotorState(void) const { return m_motorState; }
469
470 /// @brief Set type of event.
471 ///
472 /// @param[in] type Type defined with @ref PERIPHERAL_EVENT_TYPE
473 void SetType(PERIPHERAL_EVENT_TYPE type) { m_type = type; }
474
475 /// @brief Set peripheral index.
476 ///
477 /// @param[in] index %Peripheral index number
478 void SetPeripheralIndex(unsigned int index) { m_peripheralIndex = index; }
479
480 /// @brief Set driver index.
481 ///
482 /// @param[in] index Driver index number
483 void SetDriverIndex(unsigned int index) { m_driverIndex = index; }
484
485 /// @brief Set button state.
486 ///
487 /// @param[in] state Button state as @ref JOYSTICK_STATE_BUTTON
488 void SetButtonState(JOYSTICK_STATE_BUTTON state) { m_buttonState = state; }
489
490 /// @brief Set hat state.
491 ///
492 /// @param[in] state Hat state as @ref JOYSTICK_STATE_HAT (float)
493 void SetHatState(JOYSTICK_STATE_HAT state) { m_hatState = state; }
494
495 /// @brief Set axis state.
496 ///
497 /// @param[in] state Axis state as @ref JOYSTICK_STATE_AXIS (float)
498 void SetAxisState(JOYSTICK_STATE_AXIS state) { m_axisState = state; }
499
500 /// @brief Set motor state.
501 ///
502 /// @param[in] state Motor state as @ref JOYSTICK_STATE_MOTOR (float)
503 void SetMotorState(JOYSTICK_STATE_MOTOR state) { m_motorState = state; }
504
505 ///@}
506
507 explicit PeripheralEvent(const PERIPHERAL_EVENT& event)
508 : m_type(event.type),
509 m_peripheralIndex(event.peripheral_index),
510 m_driverIndex(event.driver_index),
511 m_buttonState(event.driver_button_state),
512 m_hatState(event.driver_hat_state),
513 m_axisState(event.driver_axis_state),
514 m_motorState(event.motor_state)
515 {
516 }
517
518 void ToStruct(PERIPHERAL_EVENT& event) const
519 {
520 event.type = m_type;
521 event.peripheral_index = m_peripheralIndex;
522 event.driver_index = m_driverIndex;
523 event.driver_button_state = m_buttonState;
524 event.driver_hat_state = m_hatState;
525 event.driver_axis_state = m_axisState;
526 event.motor_state = m_motorState;
527 }
528
529 static void FreeStruct(PERIPHERAL_EVENT& event) { (void)event; }
530
531private:
532 PERIPHERAL_EVENT_TYPE m_type = PERIPHERAL_EVENT_TYPE_NONE;
533 unsigned int m_peripheralIndex = 0;
534 unsigned int m_driverIndex = 0;
535 JOYSTICK_STATE_BUTTON m_buttonState = JOYSTICK_STATE_BUTTON_UNPRESSED;
536 JOYSTICK_STATE_HAT m_hatState = JOYSTICK_STATE_HAT_UNPRESSED;
537 JOYSTICK_STATE_AXIS m_axisState = 0.0f;
538 JOYSTICK_STATE_MOTOR m_motorState = 0.0f;
539};
540///@}
541//------------------------------------------------------------------------------
542
543typedef PeripheralVector<PeripheralEvent, PERIPHERAL_EVENT> PeripheralEvents;
544
545//==============================================================================
546/// @defgroup cpp_kodi_addon_peripheral_Defs_Joystick_Joystick class Joystick
547/// @ingroup cpp_kodi_addon_peripheral_Defs_Joystick
548/// @brief **Wrapper class providing additional joystick information**\n
549/// This is a child class to expand another class with necessary joystick data.
550///
551/// For data not provided by @ref cpp_kodi_addon_peripheral_Defs_Peripheral_Peripheral.
552///
553/// Used on:
554/// - @ref kodi::addon::CInstancePeripheral::GetJoystickInfo()
555/// - @ref kodi::addon::CInstancePeripheral::GetFeatures().
556/// - @ref kodi::addon::CInstancePeripheral::MapFeatures().
557/// - @ref kodi::addon::CInstancePeripheral::GetIgnoredPrimitives().
558/// - @ref kodi::addon::CInstancePeripheral::SetIgnoredPrimitives().
559/// - @ref kodi::addon::CInstancePeripheral::SaveButtonMap().
560/// - @ref kodi::addon::CInstancePeripheral::RevertButtonMap().
561/// - @ref kodi::addon::CInstancePeripheral::ResetButtonMap().
562///
563/// ----------------------------------------------------------------------------
564///
565/// @copydetails cpp_kodi_addon_peripheral_Defs_Joystick_Joystick_Help
566///
567///@{
568class Joystick : public Peripheral
569{
570public:
571 /// @defgroup cpp_kodi_addon_peripheral_Defs_Joystick_Joystick_Help Value Help
572 /// @ingroup cpp_kodi_addon_peripheral_Defs_Joystick_Joystick
573 /// ----------------------------------------------------------------------------
574 ///
575 /// <b>The following table contains values that can be set with @ref cpp_kodi_addon_peripheral_Defs_Joystick_Joystick :</b>
576 /// | Name | Type | Class | Set call | Get call
577 /// |------|------|-------|----------|----------
578 /// | **%Joystick provider** | `const std::string&` | @ref Joystick | @ref Joystick::SetProvider "SetProvider" | @ref Joystick::Provider "Provider"
579 /// | **%Joystick requested port** | `int` | @ref Joystick | @ref Joystick::SetRequestedPort "SetRequestedPort" | @ref Joystick::RequestedPort "RequestedPort"
580 /// | **%Joystick button count** | `unsigned int` | @ref Joystick | @ref Joystick::SetButtonCount "SetButtonCount" | @ref Joystick::ButtonCount "ButtonCount"
581 /// | **%Joystick hat count** | `unsigned int` | @ref Joystick | @ref Joystick::SetHatCount "SetHatCount" | @ref Joystick::HatCount "HatCount"
582 /// | **%Joystick axis count** | `unsigned int` | @ref Joystick | @ref Joystick::SetAxisCount "SetAxisCount" | @ref Joystick::AxisCount "AxisCount"
583 /// | **%Joystick motor count** | `unsigned int` | @ref Joystick | @ref Joystick::SetMotorCount "SetMotorCount" | @ref Joystick::MotorCount "MotorCount"
584 /// | **%Joystick support power off** | `bool` | @ref Joystick | @ref Joystick::SetSupportsPowerOff "SetSupportsPowerOff" | @ref Joystick::SupportsPowerOff "SupportsPowerOff"
585 /// | **%Peripheral type** | @ref PERIPHERAL_TYPE | @ref Peripheral | @ref Peripheral::SetType "SetType" | @ref Peripheral::Type "Type"
586 /// | **%Peripheral name** | `const std::string&` | @ref Peripheral | @ref Peripheral::SetName "SetName" | @ref Peripheral::Name "Name"
587 /// | **%Peripheral vendor id** | `uint16_t` | @ref Peripheral | @ref Peripheral::SetVendorID "SetVendorID" | @ref Peripheral::VendorID "VendorID"
588 /// | **%Peripheral product id** | `uint16_t` | @ref Peripheral | @ref Peripheral::SetProductID "SetProductID" | @ref Peripheral::ProductID "ProductID"
589 /// | **%Peripheral index** | `unsigned int` | @ref Peripheral | @ref Peripheral::SetIndex "SetIndex" | @ref Peripheral::Index "Index"
590 ///
591 /// Further are following included:
592 /// - @ref Joystick::Joystick "Joystick(const std::string& provider = \"\", const std::string& strName = \"\")"
593 /// - @ref Joystick::operator= "Joystick& operator=(const Joystick& rhs)"
594 /// - @ref Peripheral::IsVidPidKnown "IsVidPidKnown()": To check VID and PID are known.
595 ///
596
597 /// @addtogroup cpp_kodi_addon_peripheral_Defs_Joystick_Joystick
598 ///@{
599
600 /// @brief Constructor.
601 ///
602 /// @param[in] provider [optional] Provide name
603 /// @param[in] strName [optional] Name of related joystick
604 Joystick(const std::string& provider = "", const std::string& strName = "")
605 : Peripheral(PERIPHERAL_TYPE_JOYSTICK, strName),
606 m_provider(provider),
607 m_requestedPort(NO_PORT_REQUESTED)
608 {
609 }
610
611 /// @brief Class copy constructor.
612 ///
613 /// @param[in] other Other class to copy on construct here
614 Joystick(const Joystick& other) { *this = other; }
615
616 /// @brief Destructor.
617 ///
618 ~Joystick(void) override = default;
619
620 /// @brief Copy data from another @ref Joystick class to here.
621 ///
622 /// @param[in] other Other class to copy here
623 Joystick& operator=(const Joystick& rhs)
624 {
625 if (this != &rhs)
626 {
627 Peripheral::operator=(rhs);
628
629 m_provider = rhs.m_provider;
630 m_requestedPort = rhs.m_requestedPort;
631 m_buttonCount = rhs.m_buttonCount;
632 m_hatCount = rhs.m_hatCount;
633 m_axisCount = rhs.m_axisCount;
634 m_motorCount = rhs.m_motorCount;
635 m_supportsPowerOff = rhs.m_supportsPowerOff;
636 }
637 return *this;
638 }
639
640 /// @brief Get provider name.
641 ///
642 /// @return Name of provider
643 const std::string& Provider(void) const { return m_provider; }
644
645 /// @brief Get requested port number.
646 ///
647 /// @return Port
648 int RequestedPort(void) const { return m_requestedPort; }
649
650 /// @brief Get button count.
651 ///
652 /// @return Button count
653 unsigned int ButtonCount(void) const { return m_buttonCount; }
654
655 /// @brief Get hat count.
656 ///
657 /// @return Hat count
658 unsigned int HatCount(void) const { return m_hatCount; }
659
660 /// @brief Get axis count.
661 ///
662 /// @return Axis count
663 unsigned int AxisCount(void) const { return m_axisCount; }
664
665 /// @brief Get motor count.
666 ///
667 /// @return Motor count
668 unsigned int MotorCount(void) const { return m_motorCount; }
669
670 /// @brief Get supports power off.
671 ///
672 /// @return True if power off is supported, false otherwise
673 bool SupportsPowerOff(void) const { return m_supportsPowerOff; }
674
675 /// @brief Set provider name.
676 ///
677 /// @param[in] provider Name of provider
678 void SetProvider(const std::string& provider) { m_provider = provider; }
679
680 /// @brief Get requested port number.
681 ///
682 /// @param[in] requestedPort Port
683 void SetRequestedPort(int requestedPort) { m_requestedPort = requestedPort; }
684
685 /// @brief Get button count.
686 ///
687 /// @param[in] buttonCount Button count
688 void SetButtonCount(unsigned int buttonCount) { m_buttonCount = buttonCount; }
689
690 /// @brief Get hat count.
691 ///
692 /// @param[in] hatCount Hat count
693 void SetHatCount(unsigned int hatCount) { m_hatCount = hatCount; }
694
695 /// @brief Get axis count.
696 ///
697 /// @param[in] axisCount Axis count
698 void SetAxisCount(unsigned int axisCount) { m_axisCount = axisCount; }
699
700 /// @brief Get motor count.
701 ///
702 /// @param[in] motorCount Motor count
703 void SetMotorCount(unsigned int motorCount) { m_motorCount = motorCount; }
704
705 /// @brief Get supports power off.
706 ///
707 /// @param[in] supportsPowerOff True if power off is supported, false otherwise
708 void SetSupportsPowerOff(bool supportsPowerOff) { m_supportsPowerOff = supportsPowerOff; }
709
710 ///@}
711
712 explicit Joystick(const JOYSTICK_INFO& info)
713 : Peripheral(info.peripheral),
714 m_provider(info.provider ? info.provider : ""),
715 m_requestedPort(info.requested_port),
716 m_buttonCount(info.button_count),
717 m_hatCount(info.hat_count),
718 m_axisCount(info.axis_count),
719 m_motorCount(info.motor_count),
720 m_supportsPowerOff(info.supports_poweroff)
721 {
722 }
723
724 void ToStruct(JOYSTICK_INFO& info) const
725 {
726 Peripheral::ToStruct(info.peripheral);
727
728 info.provider = new char[m_provider.size() + 1];
729 info.requested_port = m_requestedPort;
730 info.button_count = m_buttonCount;
731 info.hat_count = m_hatCount;
732 info.axis_count = m_axisCount;
733 info.motor_count = m_motorCount;
734 info.supports_poweroff = m_supportsPowerOff;
735
736 std::strcpy(info.provider, m_provider.c_str());
737 }
738
739 static void FreeStruct(JOYSTICK_INFO& info)
740 {
741 Peripheral::FreeStruct(info.peripheral);
742
743 PERIPHERAL_SAFE_DELETE_ARRAY(info.provider);
744 }
745
746private:
747 std::string m_provider;
748 int m_requestedPort;
749 unsigned int m_buttonCount = 0;
750 unsigned int m_hatCount = 0;
751 unsigned int m_axisCount = 0;
752 unsigned int m_motorCount = 0;
753 bool m_supportsPowerOff = false;
754};
755///@}
756//------------------------------------------------------------------------------
757
758typedef PeripheralVector<Joystick, JOYSTICK_INFO> Joysticks;
759
760class JoystickFeature;
761
762//==============================================================================
763/// @defgroup cpp_kodi_addon_peripheral_Defs_Joystick_DriverPrimitive class DriverPrimitive
764/// @ingroup cpp_kodi_addon_peripheral_Defs_Joystick
765/// @brief **Base class for joystick driver primitives**
766///
767/// A driver primitive can be:
768///
769/// 1. a button
770/// 2. a hat direction
771/// 3. a semiaxis (either the positive or negative half of an axis)
772/// 4. a motor
773/// 5. a keyboard key
774/// 6. a mouse button
775/// 7. a relative pointer direction
776///
777/// The type determines the fields in use:
778///
779/// Button:
780/// - driver index
781///
782/// Hat direction:
783/// - driver index
784/// - hat direction
785///
786/// Semiaxis:
787/// - driver index
788/// - center
789/// - semiaxis direction
790/// - range
791///
792/// Motor:
793/// - driver index
794///
795/// Key:
796/// - key code
797///
798/// Mouse button:
799/// - driver index
800///
801/// Relative pointer direction:
802/// - relative pointer direction
803///
804///@{
805struct DriverPrimitive
806{
807protected:
808 /*!
809 * \brief Construct a driver primitive of the specified type
810 */
811 DriverPrimitive(JOYSTICK_DRIVER_PRIMITIVE_TYPE type, unsigned int driverIndex)
812 : m_type(type), m_driverIndex(driverIndex)
813 {
814 }
815
816public:
817 /// @addtogroup cpp_kodi_addon_peripheral_Defs_Joystick_DriverPrimitive
818 ///@{
819
820 /// @brief Construct an invalid driver primitive.
821 DriverPrimitive(void) = default;
822
823 /// @brief Construct a driver primitive representing a joystick button.
824 ///
825 /// @param[in] buttonIndex Index
826 /// @return Created class
827 static DriverPrimitive CreateButton(unsigned int buttonIndex)
828 {
829 return DriverPrimitive(JOYSTICK_DRIVER_PRIMITIVE_TYPE_BUTTON, buttonIndex);
830 }
831
832 /// @brief Construct a driver primitive representing one of the four direction
833 /// arrows on a dpad.
834 ///
835 /// @param[in] hatIndex Hat index
836 /// @param[in] direction With @ref JOYSTICK_DRIVER_HAT_DIRECTION defined direction
837 DriverPrimitive(unsigned int hatIndex, JOYSTICK_DRIVER_HAT_DIRECTION direction)
838 : m_type(JOYSTICK_DRIVER_PRIMITIVE_TYPE_HAT_DIRECTION),
839 m_driverIndex(hatIndex),
840 m_hatDirection(direction)
841 {
842 }
843
844 /// @brief Construct a driver primitive representing the positive or negative
845 /// half of an axis.
846 ///
847 /// @param[in] axisIndex Axis index
848 /// @param[in] center Center
849 /// @param[in] direction With @ref JOYSTICK_DRIVER_HAT_DIRECTION defined direction
850 /// @param[in] range Range
851 DriverPrimitive(unsigned int axisIndex,
852 int center,
853 JOYSTICK_DRIVER_SEMIAXIS_DIRECTION direction,
854 unsigned int range)
855 : m_type(JOYSTICK_DRIVER_PRIMITIVE_TYPE_SEMIAXIS),
856 m_driverIndex(axisIndex),
857 m_center(center),
858 m_semiAxisDirection(direction),
859 m_range(range)
860 {
861 }
862
863 /// @brief Construct a driver primitive representing a motor.
864 ///
865 /// @param[in] motorIndex Motor index number
866 /// @return Constructed driver primitive representing a motor
867 static DriverPrimitive CreateMotor(unsigned int motorIndex)
868 {
869 return DriverPrimitive(JOYSTICK_DRIVER_PRIMITIVE_TYPE_MOTOR, motorIndex);
870 }
871
872 /// @brief Construct a driver primitive representing a key on a keyboard.
873 ///
874 /// @param[in] keycode Keycode to use
875 DriverPrimitive(std::string keycode)
876 : m_type(JOYSTICK_DRIVER_PRIMITIVE_TYPE_KEY), m_keycode(std::move(keycode))
877 {
878 }
879
880 /// @brief Construct a driver primitive representing a mouse button.
881 ///
882 /// @param[in] buttonIndex Index
883 /// @return Constructed driver primitive representing a mouse button
884 static DriverPrimitive CreateMouseButton(JOYSTICK_DRIVER_MOUSE_INDEX buttonIndex)
885 {
886 return DriverPrimitive(JOYSTICK_DRIVER_PRIMITIVE_TYPE_MOUSE_BUTTON,
887 static_cast<unsigned int>(buttonIndex));
888 }
889
890 /// @brief Construct a driver primitive representing one of the four
891 /// direction in which a relative pointer can move
892 ///
893 /// @param[in] direction With @ref JOYSTICK_DRIVER_RELPOINTER_DIRECTION defined direction
894 DriverPrimitive(JOYSTICK_DRIVER_RELPOINTER_DIRECTION direction)
895 : m_type(JOYSTICK_DRIVER_PRIMITIVE_TYPE_RELPOINTER_DIRECTION), m_relPointerDirection(direction)
896 {
897 }
898
899 /// @brief Get type of primitive.
900 ///
901 /// @return The with @ref JOYSTICK_DRIVER_PRIMITIVE_TYPE defined type
902 JOYSTICK_DRIVER_PRIMITIVE_TYPE Type(void) const { return m_type; }
903
904 /// @brief Get driver index.
905 ///
906 /// @return Index number
907 unsigned int DriverIndex(void) const { return m_driverIndex; }
908
909 /// @brief Get hat direction
910 ///
911 /// @return The with @ref JOYSTICK_DRIVER_HAT_DIRECTION defined direction
912 JOYSTICK_DRIVER_HAT_DIRECTION HatDirection(void) const { return m_hatDirection; }
913
914 /// @brief Get center
915 ///
916 /// @return Center
917 int Center(void) const { return m_center; }
918
919 /// @brief Get semi axis direction
920 ///
921 /// @return With @ref JOYSTICK_DRIVER_SEMIAXIS_DIRECTION defined direction
922 JOYSTICK_DRIVER_SEMIAXIS_DIRECTION SemiAxisDirection(void) const { return m_semiAxisDirection; }
923
924 /// @brief Get range.
925 ///
926 /// @return Range
927 unsigned int Range(void) const { return m_range; }
928
929 /// @brief Get key code as string.
930 ///
931 /// @return Key code
932 const std::string& Keycode(void) const { return m_keycode; }
933
934 /// @brief Get mouse index
935 ///
936 /// @return With @ref JOYSTICK_DRIVER_MOUSE_INDEX defined mouse index
937 JOYSTICK_DRIVER_MOUSE_INDEX MouseIndex(void) const
938 {
939 return static_cast<JOYSTICK_DRIVER_MOUSE_INDEX>(m_driverIndex);
940 }
941
942 /// @brief Get relative pointer direction.
943 ///
944 /// @return With @ref JOYSTICK_DRIVER_RELPOINTER_DIRECTION defined direction
945 JOYSTICK_DRIVER_RELPOINTER_DIRECTION RelPointerDirection(void) const
946 {
947 return m_relPointerDirection;
948 }
949
950 /// @brief Compare this with another class of this type.
951 ///
952 /// @param[in] other Other class to compare
953 /// @return True if they are equal, false otherwise
954 bool operator==(const DriverPrimitive& other) const
955 {
956 if (m_type == other.m_type)
957 {
958 switch (m_type)
959 {
960 case JOYSTICK_DRIVER_PRIMITIVE_TYPE_BUTTON:
961 {
962 return m_driverIndex == other.m_driverIndex;
963 }
964 case JOYSTICK_DRIVER_PRIMITIVE_TYPE_HAT_DIRECTION:
965 {
966 return m_driverIndex == other.m_driverIndex && m_hatDirection == other.m_hatDirection;
967 }
968 case JOYSTICK_DRIVER_PRIMITIVE_TYPE_SEMIAXIS:
969 {
970 return m_driverIndex == other.m_driverIndex && m_center == other.m_center &&
971 m_semiAxisDirection == other.m_semiAxisDirection && m_range == other.m_range;
972 }
973 case JOYSTICK_DRIVER_PRIMITIVE_TYPE_KEY:
974 {
975 return m_keycode == other.m_keycode;
976 }
977 case JOYSTICK_DRIVER_PRIMITIVE_TYPE_MOTOR:
978 {
979 return m_driverIndex == other.m_driverIndex;
980 }
981 case JOYSTICK_DRIVER_PRIMITIVE_TYPE_MOUSE_BUTTON:
982 {
983 return m_driverIndex == other.m_driverIndex;
984 }
985 case JOYSTICK_DRIVER_PRIMITIVE_TYPE_RELPOINTER_DIRECTION:
986 {
987 return m_relPointerDirection == other.m_relPointerDirection;
988 }
989 default:
990 break;
991 }
992 }
993 return false;
994 }
995
996 ///@}
997
998 explicit DriverPrimitive(const JOYSTICK_DRIVER_PRIMITIVE& primitive) : m_type(primitive.type)
999 {
1000 switch (m_type)
1001 {
1002 case JOYSTICK_DRIVER_PRIMITIVE_TYPE_BUTTON:
1003 {
1004 m_driverIndex = primitive.button.index;
1005 break;
1006 }
1007 case JOYSTICK_DRIVER_PRIMITIVE_TYPE_HAT_DIRECTION:
1008 {
1009 m_driverIndex = primitive.hat.index;
1010 m_hatDirection = primitive.hat.direction;
1011 break;
1012 }
1013 case JOYSTICK_DRIVER_PRIMITIVE_TYPE_SEMIAXIS:
1014 {
1015 m_driverIndex = primitive.semiaxis.index;
1016 m_center = primitive.semiaxis.center;
1017 m_semiAxisDirection = primitive.semiaxis.direction;
1018 m_range = primitive.semiaxis.range;
1019 break;
1020 }
1021 case JOYSTICK_DRIVER_PRIMITIVE_TYPE_MOTOR:
1022 {
1023 m_driverIndex = primitive.motor.index;
1024 break;
1025 }
1026 case JOYSTICK_DRIVER_PRIMITIVE_TYPE_KEY:
1027 {
1028 m_keycode = primitive.key.keycode;
1029 break;
1030 }
1031 case JOYSTICK_DRIVER_PRIMITIVE_TYPE_MOUSE_BUTTON:
1032 {
1033 m_driverIndex = primitive.mouse.button;
1034 break;
1035 }
1036 case JOYSTICK_DRIVER_PRIMITIVE_TYPE_RELPOINTER_DIRECTION:
1037 {
1038 m_relPointerDirection = primitive.relpointer.direction;
1039 break;
1040 }
1041 default:
1042 break;
1043 }
1044 }
1045
1046 void ToStruct(JOYSTICK_DRIVER_PRIMITIVE& driver_primitive) const
1047 {
1048 driver_primitive.type = m_type;
1049 switch (m_type)
1050 {
1051 case JOYSTICK_DRIVER_PRIMITIVE_TYPE_BUTTON:
1052 {
1053 driver_primitive.button.index = m_driverIndex;
1054 break;
1055 }
1056 case JOYSTICK_DRIVER_PRIMITIVE_TYPE_HAT_DIRECTION:
1057 {
1058 driver_primitive.hat.index = m_driverIndex;
1059 driver_primitive.hat.direction = m_hatDirection;
1060 break;
1061 }
1062 case JOYSTICK_DRIVER_PRIMITIVE_TYPE_SEMIAXIS:
1063 {
1064 driver_primitive.semiaxis.index = m_driverIndex;
1065 driver_primitive.semiaxis.center = m_center;
1066 driver_primitive.semiaxis.direction = m_semiAxisDirection;
1067 driver_primitive.semiaxis.range = m_range;
1068 break;
1069 }
1070 case JOYSTICK_DRIVER_PRIMITIVE_TYPE_MOTOR:
1071 {
1072 driver_primitive.motor.index = m_driverIndex;
1073 break;
1074 }
1075 case JOYSTICK_DRIVER_PRIMITIVE_TYPE_KEY:
1076 {
1077 const size_t size = sizeof(driver_primitive.key.keycode);
1078 std::strncpy(driver_primitive.key.keycode, m_keycode.c_str(), size - 1);
1079 driver_primitive.key.keycode[size - 1] = '\0';
1080 break;
1081 }
1082 case JOYSTICK_DRIVER_PRIMITIVE_TYPE_MOUSE_BUTTON:
1083 {
1084 driver_primitive.mouse.button = static_cast<JOYSTICK_DRIVER_MOUSE_INDEX>(m_driverIndex);
1085 break;
1086 }
1087 case JOYSTICK_DRIVER_PRIMITIVE_TYPE_RELPOINTER_DIRECTION:
1088 {
1089 driver_primitive.relpointer.direction = m_relPointerDirection;
1090 break;
1091 }
1092 default:
1093 break;
1094 }
1095 }
1096
1097 static void FreeStruct(JOYSTICK_DRIVER_PRIMITIVE& primitive) { (void)primitive; }
1098
1099private:
1100 JOYSTICK_DRIVER_PRIMITIVE_TYPE m_type = JOYSTICK_DRIVER_PRIMITIVE_TYPE_UNKNOWN;
1101 unsigned int m_driverIndex = 0;
1102 JOYSTICK_DRIVER_HAT_DIRECTION m_hatDirection = JOYSTICK_DRIVER_HAT_UNKNOWN;
1103 int m_center = 0;
1104 JOYSTICK_DRIVER_SEMIAXIS_DIRECTION m_semiAxisDirection = JOYSTICK_DRIVER_SEMIAXIS_UNKNOWN;
1105 unsigned int m_range = 1;
1106 std::string m_keycode;
1107 JOYSTICK_DRIVER_RELPOINTER_DIRECTION m_relPointerDirection = JOYSTICK_DRIVER_RELPOINTER_UNKNOWN;
1108};
1109///@}
1110//------------------------------------------------------------------------------
1111
1112typedef PeripheralVector<DriverPrimitive, JOYSTICK_DRIVER_PRIMITIVE> DriverPrimitives;
1113
1114//==============================================================================
1115/// @defgroup cpp_kodi_addon_peripheral_Defs_Joystick_JoystickFeature class JoystickFeature
1116/// @ingroup cpp_kodi_addon_peripheral_Defs_Joystick
1117/// @brief **Base class for joystick feature primitives**
1118///
1119/// Class for joystick features. A feature can be:
1120///
1121/// 1. scalar *[1]*
1122/// 2. analog stick
1123/// 3. accelerometer
1124/// 4. motor
1125/// 5. relative pointer *[2]*
1126/// 6. absolute pointer
1127/// 7. wheel
1128/// 8. throttle
1129/// 9. keyboard key
1130///
1131/// *[1]* All three driver primitives (buttons, hats and axes) have a state that
1132/// can be represented using a single scalar value. For this reason,
1133/// features that map to a single primitive are called "scalar features".
1134///
1135/// *[2]* Relative pointers are similar to analog sticks, but they use
1136/// relative distances instead of positions.
1137///
1138///@{
1139class JoystickFeature
1140{
1141public:
1142 /// @addtogroup cpp_kodi_addon_peripheral_Defs_Joystick_JoystickFeature
1143 ///@{
1144
1145 /// @brief Class constructor.
1146 ///
1147 /// @param[in] name [optional] Name of the feature
1148 /// @param[in] type [optional] Type of the feature, @ref JOYSTICK_FEATURE_TYPE_UNKNOWN
1149 /// as default
1150 JoystickFeature(const std::string& name = "",
1151 JOYSTICK_FEATURE_TYPE type = JOYSTICK_FEATURE_TYPE_UNKNOWN)
1152 : m_name(name), m_type(type), m_primitives{}
1153 {
1154 }
1155
1156 /// @brief Class copy constructor.
1157 ///
1158 /// @param[in] other Other class to copy on construct here
1159 JoystickFeature(const JoystickFeature& other) { *this = other; }
1160
1161 /// @brief Copy data from another @ref JoystickFeature class to here.
1162 ///
1163 /// @param[in] other Other class to copy here
1164 JoystickFeature& operator=(const JoystickFeature& rhs)
1165 {
1166 if (this != &rhs)
1167 {
1168 m_name = rhs.m_name;
1169 m_type = rhs.m_type;
1170 m_primitives = rhs.m_primitives;
1171 }
1172 return *this;
1173 }
1174
1175 /// @brief Compare this with another class of this type.
1176 ///
1177 /// @param[in] other Other class to compare
1178 /// @return True if they are equal, false otherwise
1179 bool operator==(const JoystickFeature& other) const
1180 {
1181 return m_name == other.m_name && m_type == other.m_type && m_primitives == other.m_primitives;
1182 }
1183
1184 /// @brief Get name of feature.
1185 ///
1186 /// @return Name of feature
1187 const std::string& Name(void) const { return m_name; }
1188
1189 /// @brief Get name of feature.
1190 ///
1191 /// @return Type of feature defined with @ref JOYSTICK_FEATURE_TYPE
1192 JOYSTICK_FEATURE_TYPE Type(void) const { return m_type; }
1193
1194 /// @brief Check this feature is valid.
1195 ///
1196 /// @return True if valid (type != JOYSTICK_FEATURE_TYPE_UNKNOWN), false otherwise
1197 bool IsValid() const { return m_type != JOYSTICK_FEATURE_TYPE_UNKNOWN; }
1198
1199 /// @brief Set name of feature.
1200 ///
1201 /// @param[in] name Name of feature
1202 void SetName(const std::string& name) { m_name = name; }
1203
1204 /// @brief Set type of feature.
1205 ///
1206 /// @param[in] type Type of feature
1207 void SetType(JOYSTICK_FEATURE_TYPE type) { m_type = type; }
1208
1209 /// @brief Set type as invalid.
1210 void SetInvalid(void) { m_type = JOYSTICK_FEATURE_TYPE_UNKNOWN; }
1211
1212 /// @brief Get primitive of feature by wanted type.
1213 ///
1214 /// @param[in] which Type of feature, defined with @ref JOYSTICK_FEATURE_PRIMITIVE
1215 /// @return Primitive of asked type
1216 const DriverPrimitive& Primitive(JOYSTICK_FEATURE_PRIMITIVE which) const
1217 {
1218 return m_primitives[which];
1219 }
1220
1221 /// @brief Set primitive for feature by wanted type.
1222 ///
1223 /// @param[in] which Type of feature, defined with @ref JOYSTICK_FEATURE_PRIMITIVE
1224 /// @param[in] primitive The with @ref DriverPrimitive defined primitive to set
1225 void SetPrimitive(JOYSTICK_FEATURE_PRIMITIVE which, const DriverPrimitive& primitive)
1226 {
1227 m_primitives[which] = primitive;
1228 }
1229
1230 /// @brief Get all primitives on this class.
1231 ///
1232 /// @return Array list of primitives
1233 std::array<DriverPrimitive, JOYSTICK_PRIMITIVE_MAX>& Primitives() { return m_primitives; }
1234
1235 /// @brief Get all primitives on this class (as constant).
1236 ///
1237 /// @return Constant a´rray list of primitives
1238 const std::array<DriverPrimitive, JOYSTICK_PRIMITIVE_MAX>& Primitives() const
1239 {
1240 return m_primitives;
1241 }
1242
1243 ///@}
1244
1245 explicit JoystickFeature(const JOYSTICK_FEATURE& feature)
1246 : m_name(feature.name ? feature.name : ""), m_type(feature.type)
1247 {
1248 for (unsigned int i = 0; i < JOYSTICK_PRIMITIVE_MAX; i++)
1249 m_primitives[i] = DriverPrimitive(feature.primitives[i]);
1250 }
1251
1252 void ToStruct(JOYSTICK_FEATURE& feature) const
1253 {
1254 feature.name = new char[m_name.length() + 1];
1255 feature.type = m_type;
1256 for (unsigned int i = 0; i < JOYSTICK_PRIMITIVE_MAX; i++)
1257 m_primitives[i].ToStruct(feature.primitives[i]);
1258
1259 std::strcpy(feature.name, m_name.c_str());
1260 }
1261
1262 static void FreeStruct(JOYSTICK_FEATURE& feature) { PERIPHERAL_SAFE_DELETE_ARRAY(feature.name); }
1263
1264private:
1265 std::string m_name;
1266 JOYSTICK_FEATURE_TYPE m_type;
1267 std::array<DriverPrimitive, JOYSTICK_PRIMITIVE_MAX> m_primitives;
1268};
1269///@}
1270//------------------------------------------------------------------------------
1271
1272typedef PeripheralVector<JoystickFeature, JOYSTICK_FEATURE> JoystickFeatures;
1273
1274} /* namespace addon */
1275} /* namespace kodi */
1276
1277#endif /* __cplusplus */
diff --git a/xbmc/addons/kodi-dev-kit/include/kodi/addon-instance/pvr/CMakeLists.txt b/xbmc/addons/kodi-dev-kit/include/kodi/addon-instance/pvr/CMakeLists.txt
new file mode 100644
index 0000000..3443b1e
--- /dev/null
+++ b/xbmc/addons/kodi-dev-kit/include/kodi/addon-instance/pvr/CMakeLists.txt
@@ -0,0 +1,13 @@
1set(HEADERS ChannelGroups.h
2 Channels.h
3 EDL.h
4 EPG.h
5 General.h
6 MenuHook.h
7 Recordings.h
8 Stream.h
9 Timers.h)
10
11if(NOT ENABLE_STATIC_LIBS)
12 core_add_library(addons_kodi-dev-kit_include_kodi_addon-instance_pvr)
13endif()
diff --git a/xbmc/addons/kodi-dev-kit/include/kodi/addon-instance/pvr/ChannelGroups.h b/xbmc/addons/kodi-dev-kit/include/kodi/addon-instance/pvr/ChannelGroups.h
new file mode 100644
index 0000000..17995bb
--- /dev/null
+++ b/xbmc/addons/kodi-dev-kit/include/kodi/addon-instance/pvr/ChannelGroups.h
@@ -0,0 +1,271 @@
1/*
2 * Copyright (C) 2005-2018 Team Kodi
3 * This file is part of Kodi - https://kodi.tv
4 *
5 * SPDX-License-Identifier: GPL-2.0-or-later
6 * See LICENSES/README.md for more information.
7 */
8
9#pragma once
10
11#include "../../AddonBase.h"
12#include "../../c-api/addon-instance/pvr.h"
13
14//¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯
15// "C++" Definitions group 3 - PVR channel group
16#ifdef __cplusplus
17
18namespace kodi
19{
20namespace addon
21{
22
23//==============================================================================
24/// @defgroup cpp_kodi_addon_pvr_Defs_ChannelGroup_PVRChannelGroup class PVRChannelGroup
25/// @ingroup cpp_kodi_addon_pvr_Defs_ChannelGroup
26/// @brief **PVR add-on channel group**\n
27/// To define a group for channels, this becomes be asked from
28/// @ref kodi::addon::CInstancePVRClient::GetChannelGroups() and used on
29/// @ref kodi::addon::CInstancePVRClient::GetChannelGroupMembers() to get his
30/// content with @ref cpp_kodi_addon_pvr_Defs_ChannelGroup_PVRChannelGroupMember "PVRChannelGroupMember".
31///
32/// ----------------------------------------------------------------------------
33///
34/// @copydetails cpp_kodi_addon_pvr_Defs_ChannelGroup_PVRChannelGroup_Help
35///
36///@{
37class PVRChannelGroup : public CStructHdl<PVRChannelGroup, PVR_CHANNEL_GROUP>
38{
39 friend class CInstancePVRClient;
40
41public:
42 /*! \cond PRIVATE */
43 PVRChannelGroup() { memset(m_cStructure, 0, sizeof(PVR_CHANNEL_GROUP)); }
44 PVRChannelGroup(const PVRChannelGroup& channel) : CStructHdl(channel) {}
45 /*! \endcond */
46
47 /// @defgroup cpp_kodi_addon_pvr_Defs_ChannelGroup_PVRChannelGroup_Help Value Help
48 /// @ingroup cpp_kodi_addon_pvr_Defs_ChannelGroup_PVRChannelGroup
49 ///
50 /// <b>The following table contains values that can be set with @ref cpp_kodi_addon_pvr_Defs_ChannelGroup_PVRChannelGroup :</b>
51 /// | Name | Type | Set call | Get call | Usage
52 /// |------|------|----------|----------|-----------
53 /// | **Group name** | `std::string` | @ref PVRChannelGroup::SetGroupName "SetGroupName" | @ref PVRChannelGroup::GetGroupName "GetGroupName" | *required to set*
54 /// | **Is radio** | `bool` | @ref PVRChannelGroup::SetIsRadio "SetIsRadio" | @ref PVRChannelGroup::GetIsRadio "GetIsRadio" | *required to set*
55 /// | **Position** | `unsigned int` | @ref PVRChannelGroup::SetPosition "SetPosition" | @ref PVRChannelGroup::GetPosition "GetPosition" | *optional*
56 ///
57
58 /// @ingroup cpp_kodi_addon_pvr_Defs_ChannelGroup_PVRChannelGroup
59 ///@{
60
61 /// @brief **required**\n
62 /// Name of this channel group.
63 void SetGroupName(const std::string& groupName)
64 {
65 strncpy(m_cStructure->strGroupName, groupName.c_str(), sizeof(m_cStructure->strGroupName) - 1);
66 }
67
68 /// @brief To get with @ref SetGroupName changed values.
69 std::string GetGroupName() const { return m_cStructure->strGroupName; }
70
71 /// @brief **required**\n
72 /// **true** If this is a radio channel group, **false** otherwise.
73 void SetIsRadio(bool isRadio) { m_cStructure->bIsRadio = isRadio; }
74
75 /// @brief To get with @ref SetIsRadio changed values.
76 bool GetIsRadio() const { return m_cStructure->bIsRadio; }
77
78 /// @brief **optional**\n
79 /// Sort position of the group (<b>`0`</b> indicates that the backend doesn't
80 /// support sorting of groups).
81 void SetPosition(unsigned int position) { m_cStructure->iPosition = position; }
82
83 /// @brief To get with @ref SetPosition changed values.
84 unsigned int GetPosition() const { return m_cStructure->iPosition; }
85
86 ///@}
87
88private:
89 PVRChannelGroup(const PVR_CHANNEL_GROUP* channel) : CStructHdl(channel) {}
90 PVRChannelGroup(PVR_CHANNEL_GROUP* channel) : CStructHdl(channel) {}
91};
92///@}
93//------------------------------------------------------------------------------
94
95//==============================================================================
96/// @defgroup cpp_kodi_addon_pvr_Defs_ChannelGroup_PVRChannelGroupsResultSet class PVRChannelGroupsResultSet
97/// @ingroup cpp_kodi_addon_pvr_Defs_ChannelGroup_PVRChannelGroup
98/// @brief **PVR add-on channel group member transfer class**\n
99/// To transfer the content of @ref kodi::addon::CInstancePVRClient::GetChannelGroups().
100///
101///@{
102class PVRChannelGroupsResultSet
103{
104public:
105 /*! \cond PRIVATE */
106 PVRChannelGroupsResultSet() = delete;
107 PVRChannelGroupsResultSet(const AddonInstance_PVR* instance, ADDON_HANDLE handle)
108 : m_instance(instance), m_handle(handle)
109 {
110 }
111 /*! \endcond */
112
113
114 /// @addtogroup cpp_kodi_addon_pvr_Defs_ChannelGroup_PVRChannelGroupsResultSet
115 ///@{
116
117 /// @brief To add and give content from addon to Kodi on related call.
118 ///
119 /// @param[in] tag The to transferred data.
120 void Add(const kodi::addon::PVRChannelGroup& tag)
121 {
122 m_instance->toKodi->TransferChannelGroup(m_instance->toKodi->kodiInstance, m_handle, tag);
123 }
124
125 ///@}
126
127private:
128 const AddonInstance_PVR* m_instance = nullptr;
129 const ADDON_HANDLE m_handle;
130};
131///@}
132//------------------------------------------------------------------------------
133
134//==============================================================================
135/// @defgroup cpp_kodi_addon_pvr_Defs_ChannelGroup_PVRChannelGroupMember class PVRChannelGroupMember
136/// @ingroup cpp_kodi_addon_pvr_Defs_ChannelGroup
137/// @brief **PVR add-on channel group member**\n
138/// To define the content of @ref kodi::addon::CInstancePVRClient::GetChannelGroups()
139/// given groups.
140///
141/// This content becomes then requested with @ref kodi::addon::CInstancePVRClient::GetChannelGroupMembers().
142///
143/// ----------------------------------------------------------------------------
144///
145/// @copydetails cpp_kodi_addon_pvr_Defs_ChannelGroup_PVRChannelGroupMember_Help
146///
147///@{
148class PVRChannelGroupMember : public CStructHdl<PVRChannelGroupMember, PVR_CHANNEL_GROUP_MEMBER>
149{
150 friend class CInstancePVRClient;
151
152public:
153 /*! \cond PRIVATE */
154 PVRChannelGroupMember() { memset(m_cStructure, 0, sizeof(PVR_CHANNEL_GROUP_MEMBER)); }
155 PVRChannelGroupMember(const PVRChannelGroupMember& channel) : CStructHdl(channel) {}
156 /*! \endcond */
157
158 /// @defgroup cpp_kodi_addon_pvr_Defs_ChannelGroup_PVRChannelGroupMember_Help Value Help
159 /// @ingroup cpp_kodi_addon_pvr_Defs_ChannelGroup_PVRChannelGroupMember
160 ///
161 /// <b>The following table contains values that can be set with @ref cpp_kodi_addon_pvr_Defs_ChannelGroup_PVRChannelGroupMember :</b>
162 /// | Name | Type | Set call | Get call | Usage
163 /// |-------|-------|-----------|----------|-----------
164 /// | **Group name** | `std::string` | @ref PVRChannelGroupMember::SetGroupName "SetGroupName" | @ref PVRChannelGroupMember::GetGroupName "GetGroupName" | *required to set*
165 /// | **Channel unique id** | `unsigned int` | @ref PVRChannelGroupMember::SetChannelUniqueId "SetChannelUniqueId" | @ref PVRChannelGroupMember::GetChannelUniqueId "GetChannelUniqueId" | *required to set*
166 /// | **Channel Number** | `unsigned int` | @ref PVRChannelGroupMember::SetChannelNumber "SetChannelNumber" | @ref PVRChannelGroupMember::GetChannelNumber "GetChannelNumber" | *optional*
167 /// | **Sub channel number** | `unsigned int` | @ref PVRChannelGroupMember::SetSubChannelNumber "SetSubChannelNumber"| @ref PVRChannelGroupMember::GetSubChannelNumber "GetSubChannelNumber" | *optional*
168 /// | **Order** | `int` | @ref PVRChannel::SetOrder "SetOrder" | @ref PVRChannel::GetOrder "GetOrder" | *optional*
169 ///
170
171 /// @addtogroup cpp_kodi_addon_pvr_Defs_ChannelGroup_PVRChannelGroupMember
172 ///@{
173
174 /// @brief **required**\n
175 /// Name of the channel group to add the channel to.
176 void SetGroupName(const std::string& groupName)
177 {
178 strncpy(m_cStructure->strGroupName, groupName.c_str(), sizeof(m_cStructure->strGroupName) - 1);
179 }
180
181 /// @brief To get with @ref SetGroupName changed values.
182 std::string GetGroupName() const { return m_cStructure->strGroupName; }
183
184 /// @brief **required**\n
185 /// Unique id of the member.
186 void SetChannelUniqueId(unsigned int channelUniqueId)
187 {
188 m_cStructure->iChannelUniqueId = channelUniqueId;
189 }
190
191 /// @brief To get with @ref SetChannelUniqueId changed values.
192 unsigned int GetChannelUniqueId() const { return m_cStructure->iChannelUniqueId; }
193
194 /// @brief **optional**\n
195 /// Channel number within the group.
196 void SetChannelNumber(unsigned int channelNumber)
197 {
198 m_cStructure->iChannelNumber = channelNumber;
199 }
200
201 /// @brief To get with @ref SetChannelNumber changed values.
202 unsigned int GetChannelNumber() const { return m_cStructure->iChannelNumber; }
203
204 /// @brief **optional**\n
205 /// Sub channel number within the group (ATSC).
206 void SetSubChannelNumber(unsigned int subChannelNumber)
207 {
208 m_cStructure->iSubChannelNumber = subChannelNumber;
209 }
210
211 /// @brief To get with @ref SetSubChannelNumber changed values.
212 unsigned int GetSubChannelNumber() const { return m_cStructure->iSubChannelNumber; }
213
214 /// @brief **optional**\n
215 /// The value denoting the order of this channel in the <b>'All channels'</b> group.
216 void SetOrder(bool order) { m_cStructure->iOrder = order; }
217
218 /// @brief To get with @ref SetOrder changed values.
219 bool GetOrder() const { return m_cStructure->iOrder; }
220
221 ///@}
222
223private:
224 PVRChannelGroupMember(const PVR_CHANNEL_GROUP_MEMBER* channel) : CStructHdl(channel) {}
225 PVRChannelGroupMember(PVR_CHANNEL_GROUP_MEMBER* channel) : CStructHdl(channel) {}
226};
227///@}
228//------------------------------------------------------------------------------
229
230//==============================================================================
231/// @defgroup cpp_kodi_addon_pvr_Defs_ChannelGroup_PVRChannelGroupMembersResultSet class PVRChannelGroupMembersResultSet
232/// @ingroup cpp_kodi_addon_pvr_Defs_ChannelGroup_PVRChannelGroupMember
233/// @brief **PVR add-on channel group member transfer class**\n
234/// To transfer the content of @ref kodi::addon::CInstancePVRClient::GetChannelGroupMembers().
235///
236///@{
237class PVRChannelGroupMembersResultSet
238{
239public:
240 /*! \cond PRIVATE */
241 PVRChannelGroupMembersResultSet() = delete;
242 PVRChannelGroupMembersResultSet(const AddonInstance_PVR* instance, ADDON_HANDLE handle)
243 : m_instance(instance), m_handle(handle)
244 {
245 }
246 /*! \endcond */
247
248 /// @addtogroup cpp_kodi_addon_pvr_Defs_ChannelGroup_PVRChannelGroupMembersResultSet
249 ///@{
250
251 /// @brief To add and give content from addon to Kodi on related call.
252 ///
253 /// @param[in] tag The to transferred data.
254 void Add(const kodi::addon::PVRChannelGroupMember& tag)
255 {
256 m_instance->toKodi->TransferChannelGroupMember(m_instance->toKodi->kodiInstance, m_handle, tag);
257 }
258
259 ///@}
260
261private:
262 const AddonInstance_PVR* m_instance = nullptr;
263 const ADDON_HANDLE m_handle;
264};
265///@}
266//------------------------------------------------------------------------------
267
268} /* namespace addon */
269} /* namespace kodi */
270
271#endif /* __cplusplus */
diff --git a/xbmc/addons/kodi-dev-kit/include/kodi/addon-instance/pvr/Channels.h b/xbmc/addons/kodi-dev-kit/include/kodi/addon-instance/pvr/Channels.h
new file mode 100644
index 0000000..9c2f5d2
--- /dev/null
+++ b/xbmc/addons/kodi-dev-kit/include/kodi/addon-instance/pvr/Channels.h
@@ -0,0 +1,518 @@
1/*
2 * Copyright (C) 2005-2018 Team Kodi
3 * This file is part of Kodi - https://kodi.tv
4 *
5 * SPDX-License-Identifier: GPL-2.0-or-later
6 * See LICENSES/README.md for more information.
7 */
8
9#pragma once
10
11#include "../../AddonBase.h"
12#include "../../c-api/addon-instance/pvr.h"
13
14//¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯
15// "C++" Definitions group 2 - PVR channel
16#ifdef __cplusplus
17
18namespace kodi
19{
20namespace addon
21{
22
23//==============================================================================
24/// @defgroup cpp_kodi_addon_pvr_Defs_Channel_PVRChannel class PVRChannel
25/// @ingroup cpp_kodi_addon_pvr_Defs_Channel
26/// @brief **Channel data structure**\n
27/// Representation of a TV or radio channel.
28///
29/// This is used to store all the necessary TV or radio channel data and can
30/// either provide the necessary data from / to Kodi for the associated
31/// functions or can also be used in the addon to store its data.
32///
33/// ----------------------------------------------------------------------------
34///
35/// @copydetails cpp_kodi_addon_pvr_Defs_Channel_PVRChannel_Help
36///
37///@{
38class PVRChannel : public CStructHdl<PVRChannel, PVR_CHANNEL>
39{
40 friend class CInstancePVRClient;
41
42public:
43 /*! \cond PRIVATE */
44 PVRChannel() { memset(m_cStructure, 0, sizeof(PVR_CHANNEL)); }
45 PVRChannel(const PVRChannel& channel) : CStructHdl(channel) {}
46 /*! \endcond */
47
48 /// @defgroup cpp_kodi_addon_pvr_Defs_Channel_PVRChannel_Help Value Help
49 /// @ingroup cpp_kodi_addon_pvr_Defs_Channel_PVRChannel
50 ///
51 /// <b>The following table contains values that can be set with @ref cpp_kodi_addon_pvr_Defs_Channel_PVRChannel :</b>
52 /// | Name | Type | Set call | Get call | Usage
53 /// |------|------|----------|----------|-----------
54 /// | **Unique id** | `unsigned int` | @ref PVRChannel::SetUniqueId "SetUniqueId" | @ref PVRChannel::GetUniqueId "GetUniqueId" | *required to set*
55 /// | **Is radio** | `bool` | @ref PVRChannel::SetIsRadio "SetIsRadio" | @ref PVRChannel::GetIsRadio "GetIsRadio" | *required to set*
56 /// | **Channel number** | `unsigned int` | @ref PVRChannel::SetChannelNumber "SetChannelNumber" | @ref PVRChannel::GetChannelNumber "GetChannelNumber" | *optional*
57 /// | **Sub channel number** | `unsigned int` | @ref PVRChannel::SetSubChannelNumber "SetSubChannelNumber" | @ref PVRChannel::GetSubChannelNumber "GetSubChannelNumber" | *optional*
58 /// | **Channel name** | `std::string` | @ref PVRChannel::SetChannelName "SetChannelName" | @ref PVRChannel::GetChannelName "GetChannelName" | *optional*
59 /// | **Mime type** | `std::string` | @ref PVRChannel::SetMimeType "SetMimeType" | @ref PVRChannel::GetMimeType "GetMimeType" | *optional*
60 /// | **Encryption system** | `unsigned int` | @ref PVRChannel::SetEncryptionSystem "SetEncryptionSystem" | @ref PVRChannel::GetEncryptionSystem "GetEncryptionSystem" | *optional*
61 /// | **Icon path** | `std::string` | @ref PVRChannel::SetIconPath "SetIconPath" | @ref PVRChannel::GetIconPath "GetIconPath" | *optional*
62 /// | **Is hidden** | `bool` | @ref PVRChannel::SetIsHidden "SetIsHidden" | @ref PVRChannel::GetIsHidden "GetIsHidden" | *optional*
63 /// | **Has archive** | `bool` | @ref PVRChannel::SetHasArchive "SetHasArchive" | @ref PVRChannel::GetHasArchive "GetHasArchive" | *optional*
64 /// | **Order** | `int` | @ref PVRChannel::SetOrder "SetOrder" | @ref PVRChannel::GetOrder "GetOrder" | *optional*
65 ///
66
67 /// @addtogroup cpp_kodi_addon_pvr_Defs_Channel_PVRChannel
68 ///@{
69
70 /// @brief **required**\n
71 /// Unique identifier for this channel.
72 void SetUniqueId(unsigned int uniqueId) { m_cStructure->iUniqueId = uniqueId; }
73
74 /// @brief To get with @ref SetUniqueId changed values.
75 unsigned int GetUniqueId() const { return m_cStructure->iUniqueId; }
76
77 /// @brief **required**\n
78 /// **true** if this is a radio channel, **false** if it's a TV channel.
79 void SetIsRadio(bool isRadio) { m_cStructure->bIsRadio = isRadio; }
80
81 /// @brief To get with @ref SetIsRadio changed values.
82 bool GetIsRadio() const { return m_cStructure->bIsRadio; }
83
84 /// @brief **optional**\n
85 /// Channel number of this channel on the backend.
86 void SetChannelNumber(unsigned int channelNumber)
87 {
88 m_cStructure->iChannelNumber = channelNumber;
89 }
90
91 /// @brief To get with @ref SetChannelNumber changed values.
92 unsigned int GetChannelNumber() const { return m_cStructure->iChannelNumber; }
93
94 /// @brief **optional**\n
95 /// Sub channel number of this channel on the backend (ATSC).
96 void SetSubChannelNumber(unsigned int subChannelNumber)
97 {
98 m_cStructure->iSubChannelNumber = subChannelNumber;
99 }
100
101 /// @brief To get with @ref SetSubChannelNumber changed values.
102 unsigned int GetSubChannelNumber() const { return m_cStructure->iSubChannelNumber; }
103
104 /// @brief **optional**\n
105 /// Channel name given to this channel.
106 void SetChannelName(const std::string& channelName)
107 {
108 strncpy(m_cStructure->strChannelName, channelName.c_str(),
109 sizeof(m_cStructure->strChannelName) - 1);
110 }
111
112 /// @brief To get with @ref SetChannelName changed values.
113 std::string GetChannelName() const { return m_cStructure->strChannelName; }
114
115 /// @brief **optional**\n
116 /// Input format mime type.
117 ///
118 /// Available types can be found in https://www.iana.org/assignments/media-types/media-types.xhtml
119 /// on "application" and "video" or leave empty if unknown.
120 ///
121 void SetMimeType(const std::string& inputFormat)
122 {
123 strncpy(m_cStructure->strMimeType, inputFormat.c_str(), sizeof(m_cStructure->strMimeType) - 1);
124 }
125
126 /// @brief To get with @ref SetMimeType changed values.
127 std::string GetMimeType() const { return m_cStructure->strMimeType; }
128
129 /// @brief **optional**\n
130 /// The encryption ID or CaID of this channel (Conditional access systems).
131 ///
132 /// Lists about available ID's:
133 /// - http://www.dvb.org/index.php?id=174
134 /// - http://en.wikipedia.org/wiki/Conditional_access_system
135 ///
136 void SetEncryptionSystem(unsigned int encryptionSystem)
137 {
138 m_cStructure->iEncryptionSystem = encryptionSystem;
139 }
140
141 /// @brief To get with @ref SetEncryptionSystem changed values.
142 unsigned int GetEncryptionSystem() const { return m_cStructure->iEncryptionSystem; }
143
144 /// @brief **optional**\n
145 /// Path to the channel icon (if present).
146 void SetIconPath(const std::string& iconPath)
147 {
148 strncpy(m_cStructure->strIconPath, iconPath.c_str(), sizeof(m_cStructure->strIconPath) - 1);
149 }
150
151 /// @brief To get with @ref SetIconPath changed values.
152 std::string GetIconPath() const { return m_cStructure->strIconPath; }
153
154 /// @brief **optional**\n
155 /// **true** if this channel is marked as hidden.
156 void SetIsHidden(bool isHidden) { m_cStructure->bIsHidden = isHidden; }
157
158 /// @brief To get with @ref GetIsRadio changed values.
159 bool GetIsHidden() const { return m_cStructure->bIsHidden; }
160
161 /// @brief **optional**\n
162 /// **true** if this channel has a server-side back buffer.
163 void SetHasArchive(bool hasArchive) { m_cStructure->bHasArchive = hasArchive; }
164
165 /// @brief To get with @ref GetIsRadio changed values.
166 bool GetHasArchive() const { return m_cStructure->bHasArchive; }
167
168 /// @brief **optional**\n
169 /// The value denoting the order of this channel in the 'All channels' group.
170 void SetOrder(bool order) { m_cStructure->iOrder = order; }
171
172 /// @brief To get with @ref SetOrder changed values.
173 bool GetOrder() const { return m_cStructure->iOrder; }
174 ///@}
175
176private:
177 PVRChannel(const PVR_CHANNEL* channel) : CStructHdl(channel) {}
178 PVRChannel(PVR_CHANNEL* channel) : CStructHdl(channel) {}
179};
180///@}
181//------------------------------------------------------------------------------
182
183//==============================================================================
184/// @defgroup cpp_kodi_addon_pvr_Defs_Channel_PVRChannelsResultSet class PVRChannelsResultSet
185/// @ingroup cpp_kodi_addon_pvr_Defs_Channel_PVRChannel
186/// @brief **PVR add-on channel transfer class**\n
187/// To transfer the content of @ref kodi::addon::CInstancePVRClient::GetChannels().
188///
189///@{
190class PVRChannelsResultSet
191{
192public:
193 /*! \cond PRIVATE */
194 PVRChannelsResultSet() = delete;
195 PVRChannelsResultSet(const AddonInstance_PVR* instance, ADDON_HANDLE handle)
196 : m_instance(instance), m_handle(handle)
197 {
198 }
199 /*! \endcond */
200
201 /// @addtogroup cpp_kodi_addon_pvr_Defs_Channel_PVRChannelsResultSet
202 ///@{
203
204 /// @brief To add and give content from addon to Kodi on related call.
205 ///
206 /// @param[in] tag The to transferred data.
207 void Add(const kodi::addon::PVRChannel& tag)
208 {
209 m_instance->toKodi->TransferChannelEntry(m_instance->toKodi->kodiInstance, m_handle, tag);
210 }
211
212 ///@}
213
214private:
215 const AddonInstance_PVR* m_instance = nullptr;
216 const ADDON_HANDLE m_handle;
217};
218///@}
219//------------------------------------------------------------------------------
220
221//==============================================================================
222/// @defgroup cpp_kodi_addon_pvr_Defs_Channel_PVRSignalStatus class PVRSignalStatus
223/// @ingroup cpp_kodi_addon_pvr_Defs_Channel
224/// @brief **PVR Signal status information**\n
225/// This class gives current status information from stream to Kodi.
226///
227/// Used to get information for user by call of @ref kodi::addon::CInstancePVRClient::GetSignalStatus()
228/// to see current quality and source.
229///
230/// ----------------------------------------------------------------------------
231///
232/// @copydetails cpp_kodi_addon_pvr_Defs_Channel_PVRSignalStatus_Help
233///
234///@{
235class PVRSignalStatus : public CStructHdl<PVRSignalStatus, PVR_SIGNAL_STATUS>
236{
237 friend class CInstancePVRClient;
238
239public:
240 /*! \cond PRIVATE */
241 PVRSignalStatus() = default;
242 PVRSignalStatus(const PVRSignalStatus& type) : CStructHdl(type) {}
243 /*! \endcond */
244
245
246 /// @defgroup cpp_kodi_addon_pvr_Defs_Channel_PVRSignalStatus_Help Value Help
247 /// @ingroup cpp_kodi_addon_pvr_Defs_Channel_PVRSignalStatus
248 ///
249 /// <b>The following table contains values that can be set with @ref cpp_kodi_addon_pvr_Defs_Channel_PVRSignalStatus :</b>
250 /// | Name | Type | Set call | Get call | Usage
251 /// |------|------|----------|----------|-----------
252 /// | **Adapter name** | `std::string` | @ref PVRSignalStatus::SetAdapterName "SetAdapterName" | @ref PVRSignalStatus::GetAdapterName "GetAdapterName" | *optional*
253 /// | **Adapter status** | `std::string` | @ref PVRSignalStatus::SetAdapterStatus "SetAdapterStatus" | @ref PVRSignalStatus::GetAdapterStatus "GetAdapterStatus" | *optional*
254 /// | **Service name** | `std::string` | @ref PVRSignalStatus::SetServiceName "SetServiceName" | @ref PVRSignalStatus::GetServiceName "GetServiceName" | *optional*
255 /// | **Provider name** | `std::string` | @ref PVRSignalStatus::SetProviderName "SetProviderName" | @ref PVRSignalStatus::GetProviderName "GetProviderName" | *optional*
256 /// | **Mux name** | `std::string` | @ref PVRSignalStatus::SetMuxName "SetMuxName" | @ref PVRSignalStatus::GetMuxName "GetMuxName" | *optional*
257 /// | **Signal/noise ratio** | `int` | @ref PVRSignalStatus::SetSNR "SetSNR" | @ref PVRSignalStatus::GetSNR "GetSNR" | *optional*
258 /// | **Signal strength** | `int` | @ref PVRSignalStatus::SetSignal "SetSignal" | @ref PVRSignalStatus::GetSignal "GetSignal" | *optional*
259 /// | **Bit error rate** | `long` | @ref PVRSignalStatus::SetBER "SetBER" | @ref PVRSignalStatus::GetBER "GetBER" | *optional*
260 /// | **Uncorrected blocks** | `long` | @ref PVRSignalStatus::SetUNC "SetUNC" | @ref PVRSignalStatus::GetUNC "GetUNC" | *optional*
261 ///
262
263 /// @addtogroup cpp_kodi_addon_pvr_Defs_Channel_PVRSignalStatus
264 ///@{
265
266 /// @brief **optional**\n
267 /// Name of the adapter that's being used.
268 void SetAdapterName(const std::string& adapterName)
269 {
270 strncpy(m_cStructure->strAdapterName, adapterName.c_str(),
271 sizeof(m_cStructure->strAdapterName) - 1);
272 }
273
274 /// @brief To get with @ref SetAdapterName changed values.
275 std::string GetAdapterName() const { return m_cStructure->strAdapterName; }
276
277 /// @brief **optional**\n
278 /// Status of the adapter that's being used.
279 void SetAdapterStatus(const std::string& adapterStatus)
280 {
281 strncpy(m_cStructure->strAdapterStatus, adapterStatus.c_str(),
282 sizeof(m_cStructure->strAdapterStatus) - 1);
283 }
284
285 /// @brief To get with @ref SetAdapterStatus changed values.
286 std::string GetAdapterStatus() const { return m_cStructure->strAdapterStatus; }
287
288 /// @brief **optional**\n
289 /// Name of the current service.
290 void SetServiceName(const std::string& serviceName)
291 {
292 strncpy(m_cStructure->strServiceName, serviceName.c_str(),
293 sizeof(m_cStructure->strServiceName) - 1);
294 }
295
296 /// @brief To get with @ref SetServiceName changed values.
297 std::string GetServiceName() const { return m_cStructure->strServiceName; }
298
299 /// @brief **optional**\n
300 /// Name of the current service's provider.
301 void SetProviderName(const std::string& providerName)
302 {
303 strncpy(m_cStructure->strProviderName, providerName.c_str(),
304 sizeof(m_cStructure->strProviderName) - 1);
305 }
306
307 /// @brief To get with @ref SetProviderName changed values.
308 std::string GetProviderName() const { return m_cStructure->strProviderName; }
309
310 /// @brief **optional**\n
311 /// Name of the current mux.
312 void SetMuxName(const std::string& muxName)
313 {
314 strncpy(m_cStructure->strMuxName, muxName.c_str(), sizeof(m_cStructure->strMuxName) - 1);
315 }
316
317 /// @brief To get with @ref SetMuxName changed values.
318 std::string GetMuxName() const { return m_cStructure->strMuxName; }
319
320 /// @brief **optional**\n
321 /// Signal/noise ratio.
322 ///
323 /// @note 100% is 0xFFFF 65535
324 void SetSNR(int snr) { m_cStructure->iSNR = snr; }
325
326 /// @brief To get with @ref SetSNR changed values.
327 int GetSNR() const { return m_cStructure->iSNR; }
328
329 /// @brief **optional**\n
330 /// Signal strength.
331 ///
332 /// @note 100% is 0xFFFF 65535
333 void SetSignal(int signal) { m_cStructure->iSignal = signal; }
334
335 /// @brief To get with @ref SetSignal changed values.
336 int GetSignal() const { return m_cStructure->iSignal; }
337
338 /// @brief **optional**\n
339 /// Bit error rate.
340 void SetBER(long ber) { m_cStructure->iBER = ber; }
341
342 /// @brief To get with @ref SetBER changed values.
343 long GetBER() const { return m_cStructure->iBER; }
344
345 /// @brief **optional**\n
346 /// Uncorrected blocks:
347 void SetUNC(long unc) { m_cStructure->iUNC = unc; }
348
349 /// @brief To get with @ref SetBER changed values.
350 long GetUNC() const { return m_cStructure->iUNC; }
351 ///@}
352
353private:
354 PVRSignalStatus(const PVR_SIGNAL_STATUS* type) : CStructHdl(type) {}
355 PVRSignalStatus(PVR_SIGNAL_STATUS* type) : CStructHdl(type) {}
356};
357///@}
358//------------------------------------------------------------------------------
359
360//==============================================================================
361/// @defgroup cpp_kodi_addon_pvr_Defs_Channel_PVRDescrambleInfo class PVRDescrambleInfo
362/// @ingroup cpp_kodi_addon_pvr_Defs_Channel
363/// @brief **Data structure for descrample info**\n
364/// Information data to give via this to Kodi.
365///
366/// As description see also here https://en.wikipedia.org/wiki/Conditional_access.
367///
368/// Used on @ref kodi::addon::CInstancePVRClient::GetDescrambleInfo().
369///
370/// ----------------------------------------------------------------------------
371///
372/// @copydetails cpp_kodi_addon_pvr_Defs_Channel_PVRDescrambleInfo_Help
373///
374///@{
375class PVRDescrambleInfo : public CStructHdl<PVRDescrambleInfo, PVR_DESCRAMBLE_INFO>
376{
377 friend class CInstancePVRClient;
378
379public:
380 /*! \cond PRIVATE */
381 PVRDescrambleInfo()
382 {
383 m_cStructure->iPid = PVR_DESCRAMBLE_INFO_NOT_AVAILABLE;
384 m_cStructure->iCaid = PVR_DESCRAMBLE_INFO_NOT_AVAILABLE;
385 m_cStructure->iProvid = PVR_DESCRAMBLE_INFO_NOT_AVAILABLE;
386 m_cStructure->iEcmTime = PVR_DESCRAMBLE_INFO_NOT_AVAILABLE;
387 m_cStructure->iHops = PVR_DESCRAMBLE_INFO_NOT_AVAILABLE;
388 }
389 PVRDescrambleInfo(const PVRDescrambleInfo& type) : CStructHdl(type) {}
390 /*! \endcond */
391
392 /// @defgroup cpp_kodi_addon_pvr_Defs_Channel_PVRDescrambleInfo_Help Value Help
393 /// @ingroup cpp_kodi_addon_pvr_Defs_Channel_PVRDescrambleInfo
394 ///
395 /// <b>The following table contains values that can be set with @ref cpp_kodi_addon_pvr_Defs_Channel_PVRDescrambleInfo :</b>
396 /// | Name | Type | Set call | Get call | Usage
397 /// |------|------|----------|----------|-----------
398 /// | **Packet identifier** | `int` | @ref PVRDescrambleInfo::SetPID "SetPID" | @ref PVRDescrambleInfo::GetPID "GetPID" | *optional*
399 /// | **Conditional access identifier** | `int` | @ref PVRDescrambleInfo::SetCAID "SetCAID" | @ref PVRDescrambleInfo::GetCAID "GetCAID" | *optional*
400 /// | **Provider-ID** | `int` | @ref PVRDescrambleInfo::SetProviderID "SetProviderID" | @ref PVRDescrambleInfo::GetProviderID "GetProviderID" | *optional*
401 /// | **ECM time** | `int` | @ref PVRDescrambleInfo::SetECMTime "SetECMTime" | @ref PVRDescrambleInfo::GetECMTime "GetECMTime" | *optional*
402 /// | **Hops** | `int` | @ref PVRDescrambleInfo::SetHops "SetHops" | @ref PVRDescrambleInfo::GetHops "GetHops" | *optional*
403 /// | **Descramble card system** | `std::string` | @ref PVRDescrambleInfo::SetHops "SetHops" | @ref PVRDescrambleInfo::GetHops "GetHops" | *optional*
404 /// | **Reader** | `std::string` | @ref PVRDescrambleInfo::SetReader "SetReader" | @ref PVRDescrambleInfo::GetReader "GetReader" | *optional*
405 /// | **From** | `std::string` | @ref PVRDescrambleInfo::SetFrom "SetFrom" | @ref PVRDescrambleInfo::GetFrom "GetFrom" | *optional*
406 /// | **Protocol** | `std::string` | @ref PVRDescrambleInfo::SetProtocol "SetProtocol" | @ref PVRDescrambleInfo::GetProtocol "GetProtocol" | *optional*
407 ///
408
409 /// @addtogroup cpp_kodi_addon_pvr_Defs_Channel_PVRDescrambleInfo
410 ///@{
411
412 /// @brief **optional**\n
413 /// Packet identifier.
414 ///
415 /// Each table or elementary stream in a transport stream is identified by
416 /// a 13-bit packet identifier (PID).
417 ///
418 /// Is @ref PVR_DESCRAMBLE_INFO_NOT_AVAILABLE as default, if not available
419 void SetPID(int pid) { m_cStructure->iPid = pid; }
420
421 /// @brief To get with @ref SetPID changed values
422 int GetPID() const { return m_cStructure->iPid; }
423
424 /// @brief **optional**\n
425 /// Conditional access identifier.
426 ///
427 /// Conditional access (abbreviated CA) or conditional access system (abbreviated CAS)
428 /// is the protection of content by requiring certain criteria to be met before granting
429 /// access to the content.
430 ///
431 /// Available CA system ID's listed here https://www.dvbservices.com/identifiers/ca_system_id.
432 ///
433 /// @ref PVR_DESCRAMBLE_INFO_NOT_AVAILABLE if not available.
434 void SetCAID(int iCaid) { m_cStructure->iCaid = iCaid; }
435
436 /// @brief To get with @ref SetCAID changed values.
437 int GetCAID() const { return m_cStructure->iCaid; }
438
439 /// @brief **optional**\n
440 /// Provider-ID.
441 ///
442 /// Is @ref PVR_DESCRAMBLE_INFO_NOT_AVAILABLE as default, if not available.
443 void SetProviderID(int provid) { m_cStructure->iProvid = provid; }
444
445 /// @brief To get with @ref SetProviderID changed values
446 int GetProviderID() const { return m_cStructure->iProvid; }
447
448 /// @brief **optional**\n
449 /// ECM time.
450 ///
451 /// Is @ref PVR_DESCRAMBLE_INFO_NOT_AVAILABLE as default, if not available.
452 void SetECMTime(int ecmTime) { m_cStructure->iEcmTime = ecmTime; }
453
454 /// @brief To get with @ref SetECMTime changed values.
455 int GetECMTime() const { return m_cStructure->iEcmTime; }
456
457 /// @brief **optional**\n
458 /// Hops.
459 ///
460 /// Is @ref PVR_DESCRAMBLE_INFO_NOT_AVAILABLE as default, if not available.
461 void SetHops(int hops) { m_cStructure->iHops = hops; }
462
463 /// @brief To get with @ref SetHops changed values.
464 int GetHops() const { return m_cStructure->iHops; }
465
466 /// @brief **optional**\n
467 /// Empty string if not available.
468 void SetCardSystem(const std::string& cardSystem)
469 {
470 strncpy(m_cStructure->strCardSystem, cardSystem.c_str(),
471 sizeof(m_cStructure->strCardSystem) - 1);
472 }
473
474 /// @brief To get with @ref SetCardSystem changed values.
475 std::string GetCardSystem() const { return m_cStructure->strCardSystem; }
476
477 /// @brief **optional**\n
478 /// Empty string if not available.
479 void SetReader(const std::string& reader)
480 {
481 strncpy(m_cStructure->strReader, reader.c_str(), sizeof(m_cStructure->strReader) - 1);
482 }
483
484 /// @brief To get with @ref SetReader changed values.
485 std::string GetReader() const { return m_cStructure->strReader; }
486
487 /// @brief **optional**\n
488 /// Empty string if not available.
489 void SetFrom(const std::string& from)
490 {
491 strncpy(m_cStructure->strFrom, from.c_str(), sizeof(m_cStructure->strFrom) - 1);
492 }
493
494 /// @brief To get with @ref SetFrom changed values.
495 std::string GetFrom() const { return m_cStructure->strFrom; }
496
497 /// @brief **optional**\n
498 /// Empty string if not available.
499 void SetProtocol(const std::string& protocol)
500 {
501 strncpy(m_cStructure->strProtocol, protocol.c_str(), sizeof(m_cStructure->strProtocol) - 1);
502 }
503
504 /// @brief To get with @ref SetProtocol changed values.
505 std::string GetProtocol() const { return m_cStructure->strProtocol; }
506 ///@}
507
508private:
509 PVRDescrambleInfo(const PVR_DESCRAMBLE_INFO* type) : CStructHdl(type) {}
510 PVRDescrambleInfo(PVR_DESCRAMBLE_INFO* type) : CStructHdl(type) {}
511};
512///@}
513//------------------------------------------------------------------------------
514
515} /* namespace addon */
516} /* namespace kodi */
517
518#endif /* __cplusplus */
diff --git a/xbmc/addons/kodi-dev-kit/include/kodi/addon-instance/pvr/EDL.h b/xbmc/addons/kodi-dev-kit/include/kodi/addon-instance/pvr/EDL.h
new file mode 100644
index 0000000..34c7c41
--- /dev/null
+++ b/xbmc/addons/kodi-dev-kit/include/kodi/addon-instance/pvr/EDL.h
@@ -0,0 +1,90 @@
1/*
2 * Copyright (C) 2005-2018 Team Kodi
3 * This file is part of Kodi - https://kodi.tv
4 *
5 * SPDX-License-Identifier: GPL-2.0-or-later
6 * See LICENSES/README.md for more information.
7 */
8
9#pragma once
10
11#include "../../AddonBase.h"
12#include "../../c-api/addon-instance/pvr/pvr_edl.h"
13
14//¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯
15// "C++" Definitions group 8 - PVR Edit definition list (EDL)
16#ifdef __cplusplus
17
18namespace kodi
19{
20namespace addon
21{
22
23//==============================================================================
24/// @defgroup cpp_kodi_addon_pvr_Defs_EDLEntry_PVREDLEntry class PVREDLEntry
25/// @ingroup cpp_kodi_addon_pvr_Defs_EDLEntry
26/// @brief **Edit definition list (EDL) entry**\n
27/// Time places and type of related fields.
28///
29/// This used within @ref cpp_kodi_addon_pvr_EPGTag "EPG" and
30/// @ref cpp_kodi_addon_pvr_Recordings "recordings".
31///
32/// ----------------------------------------------------------------------------
33///
34/// @copydetails cpp_kodi_addon_pvr_Defs_EDLEntry_PVREDLEntry_Help
35///
36///@{
37class PVREDLEntry : public CStructHdl<PVREDLEntry, PVR_EDL_ENTRY>
38{
39 friend class CInstancePVRClient;
40
41public:
42 /*! \cond PRIVATE */
43 PVREDLEntry() { memset(m_cStructure, 0, sizeof(PVR_EDL_ENTRY)); }
44 PVREDLEntry(const PVREDLEntry& type) : CStructHdl(type) {}
45 /*! \endcond */
46
47 /// @defgroup cpp_kodi_addon_pvr_Defs_EDLEntry_PVREDLEntry_Help Value Help
48 /// @ingroup cpp_kodi_addon_pvr_Defs_EDLEntry_PVREDLEntry
49 ///
50 /// <b>The following table contains values that can be set with @ref cpp_kodi_addon_pvr_Defs_EDLEntry_PVREDLEntry :</b>
51 /// | Name | Type | Set call | Get call | Usage
52 /// |------|------|----------|----------|-----------
53 /// | **Start time** | `int64_t` | @ref PVREDLEntry::SetStart "SetStart" | @ref PVREDLEntry::GetStart "GetStart" | *required to set*
54 /// | **End time** | `int64_t` | @ref PVREDLEntry::SetEnd "SetEnd" | @ref PVREDLEntry::GetEnd "GetEnd" | *required to set*
55 /// | **Type** | @ref PVR_EDL_TYPE | @ref PVREDLEntry::SetType "SetType" | @ref PVREDLEntry::GetType "GetType" | *required to set*
56 ///
57
58 /// @addtogroup cpp_kodi_addon_pvr_Defs_EDLEntry_PVREDLEntry
59 ///@{
60
61 /// @brief Start time in milliseconds.
62 void SetStart(int64_t start) { m_cStructure->start = start; }
63
64 /// @brief To get with @ref SetStart() changed values.
65 int64_t GetStart() const { return m_cStructure->start; }
66
67 /// @brief End time in milliseconds.
68 void SetEnd(int64_t end) { m_cStructure->end = end; }
69
70 /// @brief To get with @ref SetEnd() changed values.
71 int64_t GetEnd() const { return m_cStructure->end; }
72
73 /// @brief The with @ref PVR_EDL_TYPE used definition list type.
74 void SetType(PVR_EDL_TYPE type) { m_cStructure->type = type; }
75
76 /// @brief To get with @ref SetType() changed values.
77 PVR_EDL_TYPE GetType() const { return m_cStructure->type; }
78 ///@}
79
80private:
81 PVREDLEntry(const PVR_EDL_ENTRY* type) : CStructHdl(type) {}
82 PVREDLEntry(PVR_EDL_ENTRY* type) : CStructHdl(type) {}
83};
84///@}
85//------------------------------------------------------------------------------
86
87} /* namespace addon */
88} /* namespace kodi */
89
90#endif /* __cplusplus */
diff --git a/xbmc/addons/kodi-dev-kit/include/kodi/addon-instance/pvr/EPG.h b/xbmc/addons/kodi-dev-kit/include/kodi/addon-instance/pvr/EPG.h
new file mode 100644
index 0000000..e1fc04f
--- /dev/null
+++ b/xbmc/addons/kodi-dev-kit/include/kodi/addon-instance/pvr/EPG.h
@@ -0,0 +1,500 @@
1/*
2 * Copyright (C) 2005-2018 Team Kodi
3 * This file is part of Kodi - https://kodi.tv
4 *
5 * SPDX-License-Identifier: GPL-2.0-or-later
6 * See LICENSES/README.md for more information.
7 */
8
9#pragma once
10
11#include "../../AddonBase.h"
12#include "../../c-api/addon-instance/pvr.h"
13
14//¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯
15// "C++" Definitions group 4 - PVR EPG
16#ifdef __cplusplus
17
18namespace kodi
19{
20namespace addon
21{
22
23//==============================================================================
24/// @defgroup cpp_kodi_addon_pvr_Defs_epg_PVREPGTag class PVREPGTag
25/// @ingroup cpp_kodi_addon_pvr_Defs_epg
26/// @brief **PVR add-on EPG data tag**\n
27/// Representation of an EPG event.
28///
29/// Herewith all EPG related data are saved in one class whereby the data can
30/// be exchanged with Kodi, or can also be used on the addon to save there.
31///
32/// See @ref cpp_kodi_addon_pvr_EPGTag "EPG methods" about usage.
33///
34/// ----------------------------------------------------------------------------
35///
36/// @copydetails cpp_kodi_addon_pvr_Defs_epg_PVREPGTag_Help
37///
38///@{
39class PVREPGTag : public CStructHdl<PVREPGTag, EPG_TAG>
40{
41 friend class CInstancePVRClient;
42
43public:
44 /*! \cond PRIVATE */
45 PVREPGTag()
46 {
47 memset(m_cStructure, 0, sizeof(EPG_TAG));
48 m_cStructure->iSeriesNumber = EPG_TAG_INVALID_SERIES_EPISODE;
49 m_cStructure->iEpisodeNumber = EPG_TAG_INVALID_SERIES_EPISODE;
50 m_cStructure->iEpisodePartNumber = EPG_TAG_INVALID_SERIES_EPISODE;
51 }
52 PVREPGTag(const PVREPGTag& epg) : CStructHdl(epg)
53 {
54 m_title = epg.m_title;
55 m_plotOutline = epg.m_plotOutline;
56 m_plot = epg.m_plot;
57 m_originalTitle = epg.m_originalTitle;
58 m_cast = epg.m_cast;
59 m_director = epg.m_director;
60 m_writer = epg.m_writer;
61 m_IMDBNumber = epg.m_IMDBNumber;
62 m_iconPath = epg.m_iconPath;
63 m_genreDescription = epg.m_genreDescription;
64 m_episodeName = epg.m_episodeName;
65 m_seriesLink = epg.m_seriesLink;
66 m_firstAired = epg.m_firstAired;
67 }
68 /*! \endcond */
69
70
71 /// @defgroup cpp_kodi_addon_pvr_Defs_epg_PVREPGTag_Help Value Help
72 /// @ingroup cpp_kodi_addon_pvr_Defs_epg_PVREPGTag
73 ///
74 /// <b>The following table contains values that can be set with @ref cpp_kodi_addon_pvr_Defs_epg_PVREPGTag :</b>
75 /// | Name | Type | Set call | Get call | Usage
76 /// |------|------|----------|----------|---------
77 /// | **Unique broadcast id** | `unsigned int` | @ref PVREPGTag::SetUniqueBroadcastId "SetUniqueBroadcastId" | @ref PVREPGTag::GetUniqueBroadcastId "GetUniqueBroadcastId" | *required to set*
78 /// | **Unique channel id** | `unsigned int` | @ref PVREPGTag::SetUniqueChannelId "SetUniqueChannelId" | @ref PVREPGTag::GetUniqueChannelId "GetUniqueChannelId" | *required to set*
79 /// | **Title** | `std::string` | @ref PVREPGTag::SetTitle "SetTitle" | @ref PVREPGTag::GetTitle "GetTitle" | *required to set*
80 /// | **Start time** | `time_t` | @ref PVREPGTag::SetStartTime "SetStartTime" | @ref PVREPGTag::GetStartTime "GetStartTime" | *required to set*
81 /// | **End time** | `time_t` | @ref PVREPGTag::SetEndTime "SetEndTime" | @ref PVREPGTag::GetEndTime "GetEndTime" | *required to set*
82 /// | **Plot outline** | `std::string` | @ref PVREPGTag::SetPlotOutline "SetPlotOutline" | @ref PVREPGTag::GetPlotOutline "GetPlotOutline" | *optional*
83 /// | **Plot** | `std::string` | @ref PVREPGTag::SetPlot "SetPlot" | @ref PVREPGTag::GetPlot "GetPlot" | *optional*
84 /// | **Original title** | `std::string` | @ref PVREPGTag::SetOriginalTitle "SetOriginalTitle" | @ref PVREPGTag::GetOriginalTitle "GetOriginalTitle" | *optional*
85 /// | **Cast** | `std::string` | @ref PVREPGTag::SetCast "SetCast" | @ref PVREPGTag::GetCast "GetCast" | *optional*
86 /// | **Director** | `std::string` | @ref PVREPGTag::SetDirector "SetDirector" | @ref PVREPGTag::GetDirector "GetDirector" | *optional*
87 /// | **Writer** | `std::string` | @ref PVREPGTag::SetWriter "SetWriter" | @ref PVREPGTag::GetWriter "GetWriter" | *optional*
88 /// | **Year** | `int` | @ref PVREPGTag::SetYear "SetYear" | @ref PVREPGTag::GetYear "GetYear" | *optional*
89 /// | **IMDB number** | `std::string` | @ref PVREPGTag::SetIMDBNumber "SetIMDBNumber" | @ref PVREPGTag::GetIMDBNumber "GetIMDBNumber" | *optional*
90 /// | **Icon path** | `std::string` | @ref PVREPGTag::SetIconPath "SetIconPath" | @ref PVREPGTag::GetIconPath "GetIconPath" | *optional*
91 /// | **Genre type** | `int` | @ref PVREPGTag::SetGenreType "SetGenreType" | @ref PVREPGTag::GetGenreType "GetGenreType" | *optional*
92 /// | **Genre sub type** | `int` | @ref PVREPGTag::SetGenreSubType "SetGenreSubType" | @ref PVREPGTag::GetGenreSubType "GetGenreSubType" | *optional*
93 /// | **Genre description** | `std::string` | @ref PVREPGTag::SetGenreDescription "SetGenreDescription" | @ref PVREPGTag::GetGenreDescription "GetGenreDescription" | *optional*
94 /// | **First aired** | `time_t` | @ref PVREPGTag::SetFirstAired "SetFirstAired" | @ref PVREPGTag::GetFirstAired "GetFirstAired" | *optional*
95 /// | **Parental rating** | `int` | @ref PVREPGTag::SetParentalRating "SetParentalRating" | @ref PVREPGTag::GetParentalRating "GetParentalRating" | *optional*
96 /// | **Star rating** | `int` | @ref PVREPGTag::SetStarRating "SetStarRating" | @ref PVREPGTag::GetStarRating "GetStarRating" | *optional*
97 /// | **Series number** | `int` | @ref PVREPGTag::SetSeriesNumber "SetSeriesNumber" | @ref PVREPGTag::GetSeriesNumber "GetSeriesNumber" | *optional*
98 /// | **Episode number** | `int` | @ref PVREPGTag::SetEpisodeNumber "SetEpisodeNumber" | @ref PVREPGTag::GetEpisodeNumber "GetEpisodeNumber" | *optional*
99 /// | **Episode part number** | `int` | @ref PVREPGTag::SetEpisodePartNumber "SetEpisodePartNumber" | @ref PVREPGTag::GetEpisodePartNumber "GetEpisodePartNumber" | *optional*
100 /// | **Episode name** | `std::string` | @ref PVREPGTag::SetEpisodeName "SetEpisodeName" | @ref PVREPGTag::GetEpisodeName "GetEpisodeName" | *optional*
101 /// | **Flags** | `unsigned int` | @ref PVREPGTag::SetFlags "SetFlags" | @ref PVREPGTag::GetFlags "GetFlags" | *optional*
102 /// | **Series link** | `std::string` | @ref PVREPGTag::SetSeriesLink "SetSeriesLink" | @ref PVREPGTag::GetSeriesLink "GetSeriesLink" | *optional*
103 ///
104
105 /// @addtogroup cpp_kodi_addon_pvr_Defs_epg_PVREPGTag
106 ///@{
107
108 /// @brief **required**\n
109 /// Identifier for this event. Event uids must be unique for a channel. Valid uids must be greater than @ref EPG_TAG_INVALID_UID.
110 void SetUniqueBroadcastId(unsigned int uniqueBroadcastId)
111 {
112 m_cStructure->iUniqueBroadcastId = uniqueBroadcastId;
113 }
114
115 /// @brief To get with @ref SetUniqueBroadcastId changed values.
116 unsigned int GetUniqueBroadcastId() const { return m_cStructure->iUniqueBroadcastId; }
117
118 /// @brief **required**\n
119 /// Unique identifier of the channel this event belongs to.
120 void SetUniqueChannelId(unsigned int uniqueChannelId)
121 {
122 m_cStructure->iUniqueChannelId = uniqueChannelId;
123 }
124
125 /// @brief To get with @ref SetUniqueChannelId changed values
126 unsigned int GetUniqueChannelId() const { return m_cStructure->iUniqueChannelId; }
127
128 /// @brief **required**\n
129 /// This event's title.
130 void SetTitle(const std::string& title) { m_title = title; }
131
132 /// @brief To get with @ref SetTitle changed values.
133 std::string GetTitle() const { return m_title; }
134
135 /// @brief **required**\n
136 /// Start time in UTC.
137 ///
138 /// Seconds elapsed since 00:00 hours, Jan 1, 1970 UTC.
139 void SetStartTime(time_t startTime) { m_cStructure->startTime = startTime; }
140
141 /// @brief To get with @ref SetStartTime changed values.
142 time_t GetStartTime() const { return m_cStructure->startTime; }
143
144 /// @brief **required**\n
145 /// End time in UTC.
146 ///
147 /// Seconds elapsed since 00:00 hours, Jan 1, 1970 UTC.
148 void SetEndTime(time_t endTime) { m_cStructure->endTime = endTime; }
149
150 /// @brief To get with @ref SetEndTime changed values.
151 time_t GetEndTime() const { return m_cStructure->endTime; }
152
153 /// @brief **optional**\n
154 /// Plot outline name.
155 void SetPlotOutline(const std::string& plotOutline) { m_plotOutline = plotOutline; }
156
157 /// @brief To get with @ref SetPlotOutline changed values.
158 std::string GetPlotOutline() const { return m_plotOutline; }
159
160 /// @brief **optional**\n
161 /// Plot name.
162 void SetPlot(const std::string& plot) { m_plot = plot; }
163
164 /// @brief To get with @ref GetPlot changed values.
165 std::string GetPlot() const { return m_plot; }
166
167 /// @brief **optional**\n
168 /// Original title.
169 void SetOriginalTitle(const std::string& originalTitle) { m_originalTitle = originalTitle; }
170
171 /// @brief To get with @ref SetOriginalTitle changed values
172 std::string GetOriginalTitle() const { return m_originalTitle; }
173
174 /// @brief **optional**\n
175 /// Cast name(s).
176 ///
177 /// @note Use @ref EPG_STRING_TOKEN_SEPARATOR to separate different persons.
178 void SetCast(const std::string& cast) { m_cast = cast; }
179
180 /// @brief To get with @ref SetCast changed values
181 std::string GetCast() const { return m_cast; }
182
183 /// @brief **optional**\n
184 /// Director name(s).
185 ///
186 /// @note Use @ref EPG_STRING_TOKEN_SEPARATOR to separate different persons.
187 void SetDirector(const std::string& director) { m_director = director; }
188
189 /// @brief To get with @ref SetDirector changed values.
190 std::string GetDirector() const { return m_director; }
191
192 /// @brief **optional**\n
193 /// Writer name(s).
194 ///
195 /// @note Use @ref EPG_STRING_TOKEN_SEPARATOR to separate different persons.
196 void SetWriter(const std::string& writer) { m_writer = writer; }
197
198 /// @brief To get with @ref SetDirector changed values
199 std::string GetWriter() const { return m_writer; }
200
201 /// @brief **optional**\n
202 /// Year.
203 void SetYear(int year) { m_cStructure->iYear = year; }
204
205 /// @brief To get with @ref SetYear changed values.
206 int GetYear() const { return m_cStructure->iYear; }
207
208 /// @brief **optional**\n
209 /// [IMDB](https://en.wikipedia.org/wiki/IMDb) identification number.
210 void SetIMDBNumber(const std::string& IMDBNumber) { m_IMDBNumber = IMDBNumber; }
211
212 /// @brief To get with @ref SetIMDBNumber changed values.
213 std::string GetIMDBNumber() const { return m_IMDBNumber; }
214
215 /// @brief **optional**\n
216 /// Icon path.
217 void SetIconPath(const std::string& iconPath) { m_iconPath = iconPath; }
218
219 /// @brief To get with @ref SetIconPath changed values.
220 std::string GetIconPath() const { return m_iconPath; }
221
222 /// @brief **optional**\n
223 /// Genre type.
224 ///
225 /// --------------------------------------------------------------------------
226 ///
227 /// @copydetails EPG_EVENT_CONTENTMASK
228 ///
229 /// Use @ref EPG_GENRE_USE_STRING if type becomes given by @ref SetGenreDescription.
230 ///
231 /// @note If confirmed that backend brings the types in [ETSI EN 300 468](https://www.etsi.org/deliver/etsi_en/300400_300499/300468/01.14.01_60/en_300468v011401p.pdf)
232 /// conform values, can be @ref EPG_EVENT_CONTENTMASK ignored and to set here
233 /// with backend value.
234 ///
235 ///
236 /// --------------------------------------------------------------------------
237 ///
238 /// **Example 1:**
239 /// ~~~~~~~~~~~~~{.cpp}
240 /// kodi::addon::PVREPGTag tag;
241 /// tag.SetGenreType(EPG_EVENT_CONTENTMASK_MOVIEDRAMA);
242 /// ~~~~~~~~~~~~~
243 ///
244 /// --------------------------------------------------------------------------
245 ///
246 /// **Example 2** (in case of other, not ETSI EN 300 468 conform genre types):
247 /// ~~~~~~~~~~~~~{.cpp}
248 /// kodi::addon::PVREPGTag tag;
249 /// tag.SetGenreType(EPG_GENRE_USE_STRING);
250 /// tag.SetGenreDescription("My special genre name"); // Should use (if possible) kodi::GetLocalizedString(...) to have match user language.
251 /// ~~~~~~~~~~~~~
252 ///
253 void SetGenreType(int genreType) { m_cStructure->iGenreType = genreType; }
254
255 /// @brief To get with @ref SetGenreType changed values
256 int GetGenreType() const { return m_cStructure->iGenreType; }
257
258 /// @brief **optional**\n
259 /// Genre sub type.
260 ///
261 /// @copydetails EPG_EVENT_CONTENTMASK
262 ///
263 /// Subtypes groups related to set by @ref SetGenreType:
264 /// | Main genre type | List with available sub genre types
265 /// |-----------------|-----------------------------------------
266 /// | @ref EPG_EVENT_CONTENTMASK_UNDEFINED | Nothing, should be 0
267 /// | @ref EPG_EVENT_CONTENTMASK_MOVIEDRAMA | @ref EPG_EVENT_CONTENTSUBMASK_MOVIEDRAMA
268 /// | @ref EPG_EVENT_CONTENTMASK_NEWSCURRENTAFFAIRS | @ref EPG_EVENT_CONTENTSUBMASK_NEWSCURRENTAFFAIRS
269 /// | @ref EPG_EVENT_CONTENTMASK_SHOW | @ref EPG_EVENT_CONTENTSUBMASK_SHOW
270 /// | @ref EPG_EVENT_CONTENTMASK_SPORTS | @ref EPG_EVENT_CONTENTSUBMASK_SPORTS
271 /// | @ref EPG_EVENT_CONTENTMASK_CHILDRENYOUTH | @ref EPG_EVENT_CONTENTSUBMASK_CHILDRENYOUTH
272 /// | @ref EPG_EVENT_CONTENTMASK_MUSICBALLETDANCE | @ref EPG_EVENT_CONTENTSUBMASK_MUSICBALLETDANCE
273 /// | @ref EPG_EVENT_CONTENTMASK_ARTSCULTURE | @ref EPG_EVENT_CONTENTSUBMASK_ARTSCULTURE
274 /// | @ref EPG_EVENT_CONTENTMASK_SOCIALPOLITICALECONOMICS | @ref EPG_EVENT_CONTENTSUBMASK_SOCIALPOLITICALECONOMICS
275 /// | @ref EPG_EVENT_CONTENTMASK_EDUCATIONALSCIENCE | @ref EPG_EVENT_CONTENTSUBMASK_EDUCATIONALSCIENCE
276 /// | @ref EPG_EVENT_CONTENTMASK_LEISUREHOBBIES | @ref EPG_EVENT_CONTENTSUBMASK_LEISUREHOBBIES
277 /// | @ref EPG_EVENT_CONTENTMASK_SPECIAL | @ref EPG_EVENT_CONTENTSUBMASK_SPECIAL
278 /// | @ref EPG_EVENT_CONTENTMASK_USERDEFINED | Can be defined by you
279 /// | @ref EPG_GENRE_USE_STRING | **Kodi's own value**, which declares that the type with @ref SetGenreDescription is given.
280 ///
281 /// --------------------------------------------------------------------------
282 ///
283 /// **Example:**
284 /// ~~~~~~~~~~~~~{.cpp}
285 /// kodi::addon::PVREPGTag tag;
286 /// tag.SetGenreType(EPG_EVENT_CONTENTMASK_MUSICBALLETDANCE);
287 /// tag.SetGenreSubType(EPG_EVENT_CONTENTSUBMASK_MUSICBALLETDANCE_JAZZ);
288 /// ~~~~~~~~~~~~~
289 ///
290 void SetGenreSubType(int genreSubType) { m_cStructure->iGenreSubType = genreSubType; }
291
292 /// @brief To get with @ref SetGenreSubType changed values.
293 int GetGenreSubType() const { return m_cStructure->iGenreSubType; }
294
295 /// @brief **optional**\n genre. Will be used only when genreType == @ref EPG_GENRE_USE_STRING
296 /// or genreSubType == @ref EPG_GENRE_USE_STRING.
297 ///
298 /// Use @ref EPG_STRING_TOKEN_SEPARATOR to separate different genres.
299 ///
300 /// In case of other, not [ETSI EN 300 468](https://www.etsi.org/deliver/etsi_en/300400_300499/300468/01.14.01_60/en_300468v011401p.pdf)
301 /// conform genre types or something special.
302 ///
303 /// --------------------------------------------------------------------------
304 ///
305 /// **Example:**
306 /// ~~~~~~~~~~~~~{.cpp}
307 /// kodi::addon::PVREPGTag tag;
308 /// tag.SetGenreType(EPG_GENRE_USE_STRING);
309 /// tag.SetGenreDescription("Action" + EPG_STRING_TOKEN_SEPARATOR + "Thriller");
310 /// ~~~~~~~~~~~~~
311 ///
312 void SetGenreDescription(const std::string& genreDescription)
313 {
314 m_genreDescription = genreDescription;
315 }
316
317 /// @brief To get with @ref SetGenreDescription changed values.
318 std::string GetGenreDescription() const { return m_genreDescription; }
319
320 /// @brief **optional**\n
321 /// First aired in UTC.
322 void SetFirstAired(const std::string& firstAired) { m_firstAired = firstAired; }
323
324 /// @brief To get with @ref SetFirstAired changed values.
325 std::string GetFirstAired() const { return m_firstAired; }
326
327 /// @brief **optional**\n
328 /// Parental rating.
329 void SetParentalRating(int parentalRating) { m_cStructure->iParentalRating = parentalRating; }
330
331 /// @brief To get with @ref SetParentalRatinge changed values.
332 int GetParentalRating() const { return m_cStructure->iParentalRating; }
333
334 /// @brief **optional**\n
335 /// Star rating.
336 void SetStarRating(int starRating) { m_cStructure->iStarRating = starRating; }
337
338 /// @brief To get with @ref SetStarRating changed values.
339 int GetStarRating() const { return m_cStructure->iStarRating; }
340
341 /// @brief **optional**\n
342 /// Series number.
343 void SetSeriesNumber(int seriesNumber) { m_cStructure->iSeriesNumber = seriesNumber; }
344
345 /// @brief To get with @ref SetSeriesNumber changed values.
346 int GetSeriesNumber() const { return m_cStructure->iSeriesNumber; }
347
348 /// @brief **optional**\n
349 /// Episode number.
350 void SetEpisodeNumber(int episodeNumber) { m_cStructure->iEpisodeNumber = episodeNumber; }
351
352 /// @brief To get with @ref SetEpisodeNumber changed values.
353 int GetEpisodeNumber() const { return m_cStructure->iEpisodeNumber; }
354
355 /// @brief **optional**\n
356 /// Episode part number.
357 void SetEpisodePartNumber(int episodePartNumber)
358 {
359 m_cStructure->iEpisodePartNumber = episodePartNumber;
360 }
361
362 /// @brief To get with @ref SetEpisodePartNumber changed values.
363 int GetEpisodePartNumber() const { return m_cStructure->iEpisodePartNumber; }
364
365 /// @brief **optional**\n
366 /// Episode name.
367 void SetEpisodeName(const std::string& episodeName) { m_episodeName = episodeName; }
368
369 /// @brief To get with @ref SetEpisodeName changed values.
370 std::string GetEpisodeName() const { return m_episodeName; }
371
372 /// @brief **optional**\n
373 /// Bit field of independent flags associated with the EPG entry.
374 ///
375 /// See @ref cpp_kodi_addon_pvr_Defs_epg_EPG_TAG_FLAG for available bit flags.
376 ///
377 /// --------------------------------------------------------------------------
378 ///
379 /// @copydetails cpp_kodi_addon_pvr_Defs_epg_EPG_TAG_FLAG
380 ///
381 void SetFlags(unsigned int flags) { m_cStructure->iFlags = flags; }
382
383 /// @brief To get with @ref SetFlags changed values.
384 unsigned int GetFlags() const { return m_cStructure->iFlags; }
385
386 /// @brief **optional**\n
387 /// Series link for this event.
388 void SetSeriesLink(const std::string& seriesLink) { m_seriesLink = seriesLink; }
389
390 /// @brief To get with @ref SetSeriesLink changed values.
391 std::string GetSeriesLink() const { return m_seriesLink; }
392
393 ///@}
394
395 // Internal used, as this have own memory for strings and to translate them to "C"
396 EPG_TAG* GetTag() const
397 {
398 m_cStructure->strTitle = m_title.c_str();
399 m_cStructure->strPlotOutline = m_plotOutline.c_str();
400 m_cStructure->strPlot = m_plot.c_str();
401 m_cStructure->strOriginalTitle = m_originalTitle.c_str();
402 m_cStructure->strCast = m_cast.c_str();
403 m_cStructure->strDirector = m_director.c_str();
404 m_cStructure->strWriter = m_writer.c_str();
405 m_cStructure->strIMDBNumber = m_IMDBNumber.c_str();
406 m_cStructure->strIconPath = m_iconPath.c_str();
407 m_cStructure->strGenreDescription = m_genreDescription.c_str();
408 m_cStructure->strEpisodeName = m_episodeName.c_str();
409 m_cStructure->strSeriesLink = m_seriesLink.c_str();
410 m_cStructure->strFirstAired = m_firstAired.c_str();
411
412 return m_cStructure;
413 }
414
415private:
416 PVREPGTag(const EPG_TAG* epg) : CStructHdl(epg) { SetData(epg); }
417 PVREPGTag(EPG_TAG* epg) : CStructHdl(epg) { SetData(epg); }
418
419 const PVREPGTag& operator=(const PVREPGTag& right);
420 const PVREPGTag& operator=(const EPG_TAG& right);
421 operator EPG_TAG*();
422
423 std::string m_title;
424 std::string m_plotOutline;
425 std::string m_plot;
426 std::string m_originalTitle;
427 std::string m_cast;
428 std::string m_director;
429 std::string m_writer;
430 std::string m_IMDBNumber;
431 std::string m_episodeName;
432 std::string m_iconPath;
433 std::string m_seriesLink;
434 std::string m_genreDescription;
435 std::string m_firstAired;
436
437 void SetData(const EPG_TAG* tag)
438 {
439 m_title = tag->strTitle == nullptr ? "" : tag->strTitle;
440 m_plotOutline = tag->strPlotOutline == nullptr ? "" : tag->strPlotOutline;
441 m_plot = tag->strPlot == nullptr ? "" : tag->strPlot;
442 m_originalTitle = tag->strOriginalTitle == nullptr ? "" : tag->strOriginalTitle;
443 m_cast = tag->strCast == nullptr ? "" : tag->strCast;
444 m_director = tag->strDirector == nullptr ? "" : tag->strDirector;
445 m_writer = tag->strWriter == nullptr ? "" : tag->strWriter;
446 m_IMDBNumber = tag->strIMDBNumber == nullptr ? "" : tag->strIMDBNumber;
447 m_iconPath = tag->strIconPath == nullptr ? "" : tag->strIconPath;
448 m_genreDescription = tag->strGenreDescription == nullptr ? "" : tag->strGenreDescription;
449 m_episodeName = tag->strEpisodeName == nullptr ? "" : tag->strEpisodeName;
450 m_seriesLink = tag->strSeriesLink == nullptr ? "" : tag->strSeriesLink;
451 m_firstAired = tag->strFirstAired == nullptr ? "" : tag->strFirstAired;
452 }
453};
454///@}
455//------------------------------------------------------------------------------
456
457//==============================================================================
458/// @defgroup cpp_kodi_addon_pvr_Defs_epg_PVREPGTagsResultSet class PVREPGTagsResultSet
459/// @ingroup cpp_kodi_addon_pvr_Defs_epg_PVREPGTag
460/// @brief **PVR add-on EPG entry transfer class**\n
461/// To transfer the content of @ref kodi::addon::CInstancePVRClient::GetEPGForChannel().
462///
463/// @note This becomes only be used on addon call above, not usable outside on
464/// addon itself.
465///@{
466class PVREPGTagsResultSet
467{
468public:
469 /*! \cond PRIVATE */
470 PVREPGTagsResultSet() = delete;
471 PVREPGTagsResultSet(const AddonInstance_PVR* instance, ADDON_HANDLE handle)
472 : m_instance(instance), m_handle(handle)
473 {
474 }
475 /*! \endcond */
476
477 /// @addtogroup cpp_kodi_addon_pvr_Defs_epg_PVREPGTagsResultSet
478 ///@{
479
480 /// @brief To add and give content from addon to Kodi on related call.
481 ///
482 /// @param[in] tag The to transferred data.
483 void Add(const kodi::addon::PVREPGTag& tag)
484 {
485 m_instance->toKodi->TransferEpgEntry(m_instance->toKodi->kodiInstance, m_handle, tag.GetTag());
486 }
487
488 ///@}
489
490private:
491 const AddonInstance_PVR* m_instance = nullptr;
492 const ADDON_HANDLE m_handle;
493};
494///@}
495//------------------------------------------------------------------------------
496
497} /* namespace addon */
498} /* namespace kodi */
499
500#endif /* __cplusplus */
diff --git a/xbmc/addons/kodi-dev-kit/include/kodi/addon-instance/pvr/General.h b/xbmc/addons/kodi-dev-kit/include/kodi/addon-instance/pvr/General.h
new file mode 100644
index 0000000..c7977c2
--- /dev/null
+++ b/xbmc/addons/kodi-dev-kit/include/kodi/addon-instance/pvr/General.h
@@ -0,0 +1,511 @@
1/*
2 * Copyright (C) 2005-2018 Team Kodi
3 * This file is part of Kodi - https://kodi.tv
4 *
5 * SPDX-License-Identifier: GPL-2.0-or-later
6 * See LICENSES/README.md for more information.
7 */
8
9#pragma once
10
11#include "../../AddonBase.h"
12#include "../../c-api/addon-instance/pvr/pvr_general.h"
13
14//¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯
15// "C++" Definitions group 1 - General PVR
16#ifdef __cplusplus
17
18namespace kodi
19{
20namespace addon
21{
22
23//==============================================================================
24/// @defgroup cpp_kodi_addon_pvr_Defs_PVRTypeIntValue class PVRTypeIntValue
25/// @ingroup cpp_kodi_addon_pvr_Defs_General
26/// @brief **PVR add-on type value**\n
27/// Representation of a <b>`<int, std::string>`</b> event related value.
28///
29/// ----------------------------------------------------------------------------
30///
31/// @copydetails cpp_kodi_addon_pvr_Defs_PVRTypeIntValue_Help
32///
33///@{
34class PVRTypeIntValue : public CStructHdl<PVRTypeIntValue, PVR_ATTRIBUTE_INT_VALUE>
35{
36 friend class CInstancePVRClient;
37
38public:
39 /*! \cond PRIVATE */
40 PVRTypeIntValue(const PVRTypeIntValue& data) : CStructHdl(data) {}
41 /*! \endcond */
42
43 /// @defgroup cpp_kodi_addon_pvr_Defs_PVRTypeIntValue_Help Value Help
44 /// @ingroup cpp_kodi_addon_pvr_Defs_PVRTypeIntValue
45 ///
46 /// <b>The following table contains values that can be set with @ref cpp_kodi_addon_pvr_Defs_PVRTypeIntValue :</b>
47 /// | Name | Type | Set call | Get call
48 /// |------|------|----------|----------
49 /// | **Value** | `int` | @ref PVRTypeIntValue::SetValue "SetValue" | @ref PVRTypeIntValue::GetValue "GetValue"
50 /// | **Description** | `std::string` | @ref PVRTypeIntValue::SetDescription "SetDescription" | @ref PVRTypeIntValue::GetDescription "GetDescription"
51 ///
52 /// @remark Further can there be used his class constructor to set values.
53
54 /// @addtogroup cpp_kodi_addon_pvr_Defs_PVRTypeIntValue
55 ///@{
56
57 /// @brief Default class constructor.
58 ///
59 /// @note Values must be set afterwards.
60 PVRTypeIntValue() = default;
61
62 /// @brief Class constructor with integrated value set.
63 ///
64 /// @param[in] value Type identification value
65 /// @param[in] description Type description text
66 PVRTypeIntValue(int value, const std::string& description)
67 {
68 SetValue(value);
69 SetDescription(description);
70 }
71
72 /// @brief To set with the identification value.
73 void SetValue(int value) { m_cStructure->iValue = value; }
74
75 /// @brief To get with the identification value.
76 int GetValue() const { return m_cStructure->iValue; }
77
78 /// @brief To set with the description text of the value.
79 void SetDescription(const std::string& description)
80 {
81 strncpy(m_cStructure->strDescription, description.c_str(),
82 sizeof(m_cStructure->strDescription) - 1);
83 }
84
85 /// @brief To get with the description text of the value.
86 std::string GetDescription() const { return m_cStructure->strDescription; }
87 ///@}
88
89private:
90 PVRTypeIntValue(const PVR_ATTRIBUTE_INT_VALUE* data) : CStructHdl(data) {}
91 PVRTypeIntValue(PVR_ATTRIBUTE_INT_VALUE* data) : CStructHdl(data) {}
92};
93///@}
94//------------------------------------------------------------------------------
95
96//==============================================================================
97/// @defgroup cpp_kodi_addon_pvr_Defs_PVRCapabilities class PVRCapabilities
98/// @ingroup cpp_kodi_addon_pvr_Defs_General
99/// @brief **PVR add-on capabilities**\n
100/// This class is needed to tell Kodi which options are supported on the addon.
101///
102/// If a capability is set to **true**, then the corresponding methods from
103/// @ref cpp_kodi_addon_pvr "kodi::addon::CInstancePVRClient" need to be
104/// implemented.
105///
106/// As default them all set to **false**.
107///
108/// Used on @ref kodi::addon::CInstancePVRClient::GetCapabilities().
109///
110/// ----------------------------------------------------------------------------
111///
112/// @copydetails cpp_kodi_addon_pvr_Defs_PVRCapabilities_Help
113///
114///@{
115class PVRCapabilities
116{
117 friend class CInstancePVRClient;
118
119public:
120 /*! \cond PRIVATE */
121 explicit PVRCapabilities() = delete;
122 /*! \endcond */
123
124 /// @defgroup cpp_kodi_addon_pvr_Defs_PVRCapabilities_Help Value Help
125 /// @ingroup cpp_kodi_addon_pvr_Defs_PVRCapabilities
126 /// ----------------------------------------------------------------------------
127 ///
128 /// <b>The following table contains values that can be set with @ref cpp_kodi_addon_pvr_Defs_PVRCapabilities :</b>
129 /// | Name | Type | Set call | Get call
130 /// |------|------|----------|----------
131 /// | **Supports EPG** | `boolean` | @ref PVRCapabilities::SetSupportsEPG "SetSupportsEPG" | @ref PVRCapabilities::GetSupportsEPG "GetSupportsEPG"
132 /// | **Supports EPG EDL** | `boolean` | @ref PVRCapabilities::SetSupportsEPGEdl "SetSupportsEPGEdl" | @ref PVRCapabilities::GetSupportsEPGEdl "GetSupportsEPGEdl"
133 /// | **Supports TV** | `boolean` | @ref PVRCapabilities::SetSupportsTV "SetSupportsTV" | @ref PVRCapabilities::GetSupportsTV "GetSupportsTV"
134 /// | **Supports radio** | `boolean` | @ref PVRCapabilities::SetSupportsRadio "SetSupportsRadio" | @ref PVRCapabilities::GetSupportsRadio "GetSupportsRadio"
135 /// | **Supports recordings** | `boolean` | @ref PVRCapabilities::SetSupportsRecordings "SetSupportsRecordings" | @ref PVRCapabilities::GetSupportsRecordings "GetSupportsRecordings"
136 /// | **Supports recordings undelete** | `boolean` | @ref PVRCapabilities::SetSupportsRecordingsUndelete "SetSupportsRecordingsUndelete" | @ref PVRCapabilities::GetSupportsRecordingsUndelete "SetSupportsRecordingsUndelete"
137 /// | **Supports timers** | `boolean` | @ref PVRCapabilities::SetSupportsTimers "SetSupportsTimers" | @ref PVRCapabilities::GetSupportsTimers "GetSupportsTimers"
138 /// | **Supports channel groups** | `boolean` | @ref PVRCapabilities::SetSupportsChannelGroups "SetSupportsChannelGroups" | @ref PVRCapabilities::GetSupportsChannelGroups "GetSupportsChannelGroups"
139 /// | **Supports channel scan** | `boolean` | @ref PVRCapabilities::SetSupportsChannelScan "SetSupportsChannelScan" | @ref PVRCapabilities::GetSupportsChannelScan "GetSupportsChannelScan"
140 /// | **Supports channel settings** | `boolean` | @ref PVRCapabilities::SetSupportsChannelSettings "SetSupportsChannelSettings" | @ref PVRCapabilities::GetSupportsChannelSettings "GetSupportsChannelSettings"
141 /// | **Handles input stream** | `boolean` | @ref PVRCapabilities::SetHandlesInputStream "SetHandlesInputStream" | @ref PVRCapabilities::GetHandlesInputStream "GetHandlesInputStream"
142 /// | **Handles demuxing** | `boolean` | @ref PVRCapabilities::SetHandlesDemuxing "SetHandlesDemuxing" | @ref PVRCapabilities::GetHandlesDemuxing "GetHandlesDemuxing"
143 /// | **Supports recording play count** | `boolean` | @ref PVRCapabilities::SetSupportsRecordingPlayCount "SetSupportsRecordingPlayCount" | @ref PVRCapabilities::GetSupportsRecordingPlayCount "GetSupportsRecordingPlayCount"
144 /// | **Supports last played position** | `boolean` | @ref PVRCapabilities::SetSupportsLastPlayedPosition "SetSupportsLastPlayedPosition" | @ref PVRCapabilities::GetSupportsLastPlayedPosition "GetSupportsLastPlayedPosition"
145 /// | **Supports recording EDL** | `boolean` | @ref PVRCapabilities::SetSupportsRecordingEdl "SetSupportsRecordingEdl" | @ref PVRCapabilities::GetSupportsRecordingEdl "GetSupportsRecordingEdl"
146 /// | **Supports recordings rename** | `boolean` | @ref PVRCapabilities::SetSupportsRecordingsRename "SetSupportsRecordingsRename" | @ref PVRCapabilities::GetSupportsRecordingsRename "GetSupportsRecordingsRename"
147 /// | **Supports recordings lifetime change** | `boolean` | @ref PVRCapabilities::SetSupportsRecordingsLifetimeChange "SetSupportsRecordingsLifetimeChange" | @ref PVRCapabilities::GetSupportsRecordingsLifetimeChange "GetSupportsRecordingsLifetimeChange"
148 /// | **Supports descramble info** | `boolean` | @ref PVRCapabilities::SetSupportsDescrambleInfo "SetSupportsDescrambleInfo" | @ref PVRCapabilities::GetSupportsDescrambleInfo "GetSupportsDescrambleInfo"
149 /// | **Supports async EPG transfer** | `boolean` | @ref PVRCapabilities::SetSupportsAsyncEPGTransfer "SetSupportsAsyncEPGTransfer" | @ref PVRCapabilities::GetSupportsAsyncEPGTransfer "GetSupportsAsyncEPGTransfer"
150 /// | **Supports recording size** | `boolean` | @ref PVRCapabilities::SetSupportsRecordingSize "SetSupportsRecordingSize" | @ref PVRCapabilities::GetSupportsRecordingSize "GetSupportsRecordingSize"
151 /// | **Recordings lifetime values** | @ref cpp_kodi_addon_pvr_Defs_PVRTypeIntValue "PVRTypeIntValue" | @ref PVRCapabilities::SetRecordingsLifetimeValues "SetRecordingsLifetimeValues" | @ref PVRCapabilities::GetRecordingsLifetimeValues "GetRecordingsLifetimeValues"
152 ///
153 /// @warning This class can not be used outside of @ref kodi::addon::CInstancePVRClient::GetCapabilities()
154 ///
155
156 /// @addtogroup cpp_kodi_addon_pvr_Defs_PVRCapabilities
157 ///@{
158
159 /// @brief Set **true** if the add-on provides EPG information.
160 void SetSupportsEPG(bool supportsEPG) { m_capabilities->bSupportsEPG = supportsEPG; }
161
162 /// @brief To get with @ref SetSupportsEPG changed values.
163 bool GetSupportsEPG() const { return m_capabilities->bSupportsEPG; }
164
165 /// @brief Set **true** if the backend supports retrieving an edit decision
166 /// list for an EPG tag.
167 void SetSupportsEPGEdl(bool supportsEPGEdl) { m_capabilities->bSupportsEPGEdl = supportsEPGEdl; }
168
169 /// @brief To get with @ref SetSupportsEPGEdl changed values.
170 bool GetSupportsEPGEdl() const { return m_capabilities->bSupportsEPGEdl; }
171
172 /// @brief Set **true** if this add-on provides TV channels.
173 void SetSupportsTV(bool supportsTV) { m_capabilities->bSupportsTV = supportsTV; }
174
175 /// @brief To get with @ref SetSupportsTV changed values.
176 bool GetSupportsTV() const { return m_capabilities->bSupportsTV; }
177
178 /// @brief Set **true** if this add-on provides TV channels.
179 void SetSupportsRadio(bool supportsRadio) { m_capabilities->bSupportsRadio = supportsRadio; }
180
181 /// @brief To get with @ref SetSupportsRadio changed values.
182 bool GetSupportsRadio() const { return m_capabilities->bSupportsRadio; }
183
184 /// @brief **true** if this add-on supports playback of recordings stored on
185 /// the backend.
186 void SetSupportsRecordings(bool supportsRecordings)
187 {
188 m_capabilities->bSupportsRecordings = supportsRecordings;
189 }
190
191 /// @brief To get with @ref SetSupportsRecordings changed values.
192 bool GetSupportsRecordings() const { return m_capabilities->bSupportsRecordings; }
193
194 /// @brief Set **true** if this add-on supports undelete of recordings stored
195 /// on the backend.
196 void SetSupportsRecordingsUndelete(bool supportsRecordingsUndelete)
197 {
198 m_capabilities->bSupportsRecordingsUndelete = supportsRecordingsUndelete;
199 }
200
201 /// @brief To get with @ref SetSupportsRecordings changed values.
202 bool GetSupportsRecordingsUndelete() const { return m_capabilities->bSupportsRecordingsUndelete; }
203
204 /// @brief Set **true** if this add-on supports the creation and editing of
205 /// timers.
206 void SetSupportsTimers(bool supportsTimers) { m_capabilities->bSupportsTimers = supportsTimers; }
207
208 /// @brief To get with @ref SetSupportsTimers changed values.
209 bool GetSupportsTimers() const { return m_capabilities->bSupportsTimers; }
210
211 /// @brief Set **true** if this add-on supports channel groups.
212 ///
213 /// It use the following functions:
214 /// - @ref kodi::addon::CInstancePVRClient::GetChannelGroupsAmount()
215 /// - @ref kodi::addon::CInstancePVRClient::GetChannelGroups()
216 /// - @ref kodi::addon::CInstancePVRClient::GetChannelGroupMembers()
217 void SetSupportsChannelGroups(bool supportsChannelGroups)
218 {
219 m_capabilities->bSupportsChannelGroups = supportsChannelGroups;
220 }
221
222 /// @brief To get with @ref SetSupportsChannelGroups changed values.
223 bool GetSupportsChannelGroups() const { return m_capabilities->bSupportsChannelGroups; }
224
225 /// @brief Set **true** if this add-on support scanning for new channels on
226 /// the backend.
227 ///
228 /// It use the following function:
229 /// - @ref kodi::addon::CInstancePVRClient::OpenDialogChannelScan()
230 void SetSupportsChannelScan(bool supportsChannelScan)
231 {
232 m_capabilities->bSupportsChannelScan = supportsChannelScan;
233 }
234
235 /// @brief To get with @ref SetSupportsChannelScan changed values.
236 bool GetSupportsChannelScan() const { return m_capabilities->bSupportsChannelScan; }
237
238 /// @brief Set **true** if this add-on supports channel edit.
239 ///
240 /// It use the following functions:
241 /// - @ref kodi::addon::CInstancePVRClient::DeleteChannel()
242 /// - @ref kodi::addon::CInstancePVRClient::RenameChannel()
243 /// - @ref kodi::addon::CInstancePVRClient::OpenDialogChannelSettings()
244 /// - @ref kodi::addon::CInstancePVRClient::OpenDialogChannelAdd()
245 void SetSupportsChannelSettings(bool supportsChannelSettings)
246 {
247 m_capabilities->bSupportsChannelSettings = supportsChannelSettings;
248 }
249
250 /// @brief To get with @ref SetSupportsChannelSettings changed values.
251 bool GetSupportsChannelSettings() const { return m_capabilities->bSupportsChannelSettings; }
252
253 /// @brief Set **true** if this add-on provides an input stream. false if Kodi
254 /// handles the stream.
255 void SetHandlesInputStream(bool handlesInputStream)
256 {
257 m_capabilities->bHandlesInputStream = handlesInputStream;
258 }
259
260 /// @brief To get with @ref SetHandlesInputStream changed values.
261 bool GetHandlesInputStream() const { return m_capabilities->bHandlesInputStream; }
262
263 /// @brief Set **true** if this add-on demultiplexes packets.
264 void SetHandlesDemuxing(bool handlesDemuxing)
265 {
266 m_capabilities->bHandlesDemuxing = handlesDemuxing;
267 }
268
269 /// @brief To get with @ref SetHandlesDemuxing changed values.
270 bool GetHandlesDemuxing() const { return m_capabilities->bHandlesDemuxing; }
271
272 /// @brief Set **true** if the backend supports play count for recordings.
273 void SetSupportsRecordingPlayCount(bool supportsRecordingPlayCount)
274 {
275 m_capabilities->bSupportsRecordingPlayCount = supportsRecordingPlayCount;
276 }
277
278 /// @brief To get with @ref SetSupportsRecordingPlayCount changed values.
279 bool GetSupportsRecordingPlayCount() const { return m_capabilities->bSupportsRecordingPlayCount; }
280
281 /// @brief Set **true** if the backend supports store/retrieve of last played
282 /// position for recordings.
283 void SetSupportsLastPlayedPosition(bool supportsLastPlayedPosition)
284 {
285 m_capabilities->bSupportsLastPlayedPosition = supportsLastPlayedPosition;
286 }
287
288 /// @brief To get with @ref SetSupportsLastPlayedPosition changed values.
289 bool GetSupportsLastPlayedPosition() const { return m_capabilities->bSupportsLastPlayedPosition; }
290
291 /// @brief Set **true** if the backend supports retrieving an edit decision
292 /// list for recordings.
293 void SetSupportsRecordingEdl(bool supportsRecordingEdl)
294 {
295 m_capabilities->bSupportsRecordingEdl = supportsRecordingEdl;
296 }
297
298 /// @brief To get with @ref SetSupportsRecordingEdl changed values.
299 bool GetSupportsRecordingEdl() const { return m_capabilities->bSupportsRecordingEdl; }
300
301 /// @brief Set **true** if the backend supports renaming recordings.
302 void SetSupportsRecordingsRename(bool supportsRecordingsRename)
303 {
304 m_capabilities->bSupportsRecordingsRename = supportsRecordingsRename;
305 }
306
307 /// @brief To get with @ref SetSupportsRecordingsRename changed values.
308 bool GetSupportsRecordingsRename() const { return m_capabilities->bSupportsRecordingsRename; }
309
310 /// @brief Set **true** if the backend supports changing lifetime for
311 /// recordings.
312 void SetSupportsRecordingsLifetimeChange(bool supportsRecordingsLifetimeChange)
313 {
314 m_capabilities->bSupportsRecordingsLifetimeChange = supportsRecordingsLifetimeChange;
315 }
316
317 /// @brief To get with @ref SetSupportsRecordingsLifetimeChange changed
318 /// values.
319 bool GetSupportsRecordingsLifetimeChange() const
320 {
321 return m_capabilities->bSupportsRecordingsLifetimeChange;
322 }
323
324 /// @brief Set **true** if the backend supports descramble information for
325 /// playing channels.
326 void SetSupportsDescrambleInfo(bool supportsDescrambleInfo)
327 {
328 m_capabilities->bSupportsDescrambleInfo = supportsDescrambleInfo;
329 }
330
331 /// @brief To get with @ref SetSupportsDescrambleInfo changed values.
332 bool GetSupportsDescrambleInfo() const { return m_capabilities->bSupportsDescrambleInfo; }
333
334 /// @brief Set **true** if this addon-on supports asynchronous transfer of epg
335 /// events to Kodi using the callback function
336 /// @ref kodi::addon::CInstancePVRClient::EpgEventStateChange().
337 void SetSupportsAsyncEPGTransfer(bool supportsAsyncEPGTransfer)
338 {
339 m_capabilities->bSupportsAsyncEPGTransfer = supportsAsyncEPGTransfer;
340 }
341
342 /// @brief To get with @ref SetSupportsAsyncEPGTransfer changed values.
343 bool GetSupportsAsyncEPGTransfer() const { return m_capabilities->bSupportsAsyncEPGTransfer; }
344
345 /// @brief Set **true** if this addon-on supports retrieving size of recordings.
346 void SetSupportsRecordingSize(bool supportsRecordingSize)
347 {
348 m_capabilities->bSupportsRecordingSize = supportsRecordingSize;
349 }
350
351 /// @brief To get with @ref SetSupportsRecordingSize changed values.
352 bool GetSupportsRecordingSize() const { return m_capabilities->bSupportsRecordingSize; }
353
354 /// @brief **optional**\n
355 /// Set array containing the possible values for @ref PVRRecording::SetLifetime().
356 ///
357 /// --------------------------------------------------------------------------
358 ///
359 /// @copydetails cpp_kodi_addon_pvr_Defs_PVRTypeIntValue_Help
360 void SetRecordingsLifetimeValues(
361 const std::vector<PVRTypeIntValue>& recordingsLifetimeValues)
362 {
363 m_capabilities->iRecordingsLifetimesSize = 0;
364 for (unsigned int i = 0; i < recordingsLifetimeValues.size() &&
365 i < sizeof(m_capabilities->recordingsLifetimeValues);
366 ++i)
367 {
368 m_capabilities->recordingsLifetimeValues[i].iValue =
369 recordingsLifetimeValues[i].GetCStructure()->iValue;
370 strncpy(m_capabilities->recordingsLifetimeValues[i].strDescription,
371 recordingsLifetimeValues[i].GetCStructure()->strDescription,
372 sizeof(m_capabilities->recordingsLifetimeValues[i].strDescription) - 1);
373 ++m_capabilities->iRecordingsLifetimesSize;
374 }
375 }
376
377 /// @brief To get with @ref SetRecordingsLifetimeValues changed values.
378 std::vector<PVRTypeIntValue> GetRecordingsLifetimeValues() const
379 {
380 std::vector<PVRTypeIntValue> recordingsLifetimeValues;
381 for (unsigned int i = 0; i < m_capabilities->iRecordingsLifetimesSize; ++i)
382 recordingsLifetimeValues.emplace_back(
383 m_capabilities->recordingsLifetimeValues[i].iValue,
384 m_capabilities->recordingsLifetimeValues[i].strDescription);
385 return recordingsLifetimeValues;
386 }
387 ///@}
388
389private:
390 PVRCapabilities(PVR_ADDON_CAPABILITIES* capabilities) : m_capabilities(capabilities) {}
391
392 PVR_ADDON_CAPABILITIES* m_capabilities;
393};
394///@}
395//------------------------------------------------------------------------------
396
397//==============================================================================
398/// @defgroup cpp_kodi_addon_pvr_Defs_General_Inputstream_PVRStreamProperty class PVRStreamProperty
399/// @ingroup cpp_kodi_addon_pvr_Defs_General_Inputstream
400/// @brief **PVR stream property value handler**\n
401/// To set for Kodi wanted stream properties.
402///
403/// ----------------------------------------------------------------------------
404///
405/// @copydetails cpp_kodi_addon_pvr_Defs_General_Inputstream_PVRStreamProperty_Help
406///
407///---------------------------------------------------------------------------
408///
409/// **Example:**
410/// ~~~~~~~~~~~~~{.cpp}
411/// ...
412///
413/// PVR_ERROR CMyPVRInstance::GetChannelStreamProperties(const kodi::addon::PVRChannel& channel,
414/// std::vector<kodi::addon::PVRStreamProperty>& properties)
415/// {
416/// ...
417/// properties.emplace_back(PVR_STREAM_PROPERTY_INPUTSTREAM, "inputstream.adaptive");
418/// return PVR_ERROR_NO_ERROR;
419/// }
420///
421/// ...
422/// ~~~~~~~~~~~~~
423///
424///
425/// **Example 2:**
426/// ~~~~~~~~~~~~~{.cpp}
427/// ...
428///
429/// PVR_ERROR CMyPVRInstance::GetChannelStreamProperties(const kodi::addon::PVRChannel& channel,
430/// std::vector<kodi::addon::PVRStreamProperty>& properties)
431/// {
432/// ...
433/// kodi::addon::PVRStreamProperty property;
434/// property.SetName(PVR_STREAM_PROPERTY_INPUTSTREAM);
435/// property.SetValue("inputstream.adaptive");
436/// properties.emplace_back(property);
437/// return PVR_ERROR_NO_ERROR;
438/// }
439///
440/// ...
441/// ~~~~~~~~~~~~~
442///
443///@{
444class PVRStreamProperty : public CStructHdl<PVRStreamProperty, PVR_NAMED_VALUE>
445{
446 friend class CInstancePVRClient;
447
448public:
449 /*! \cond PRIVATE */
450 PVRStreamProperty(const PVRStreamProperty& data) : CStructHdl(data) {}
451 /*! \endcond */
452
453 /// @defgroup cpp_kodi_addon_pvr_Defs_General_Inputstream_PVRStreamProperty_Help Value Help
454 /// @ingroup cpp_kodi_addon_pvr_Defs_General_Inputstream_PVRStreamProperty
455 ///
456 /// <b>The following table contains values that can be set with @ref cpp_kodi_addon_pvr_Defs_General_Inputstream_PVRStreamProperty :</b>
457 /// | Name | Type | Set call | Get call
458 /// |------|------|----------|----------
459 /// | **Name** | `int` | @ref PVRStreamProperty::SetValue "SetName" | @ref PVRStreamProperty::GetName "GetName"
460 /// | **Value** | `std::string` | @ref PVRStreamProperty::SetValue "SetValue" | @ref PVRStreamProperty::GetValue "GetValue"
461 ///
462 /// @remark Further can there be used his class constructor to set values.
463
464 /// @addtogroup cpp_kodi_addon_pvr_Defs_General_Inputstream_PVRStreamProperty
465 ///@{
466
467 /// @brief Default class constructor.
468 ///
469 /// @note Values must be set afterwards.
470 PVRStreamProperty() = default;
471
472 /// @brief Class constructor with integrated value set.
473 ///
474 /// @param[in] name Type identification
475 /// @param[in] value Type used property value
476 PVRStreamProperty(const std::string& name, const std::string& value)
477 {
478 SetName(name);
479 SetValue(value);
480 }
481
482 /// @brief To set with the identification name.
483 void SetName(const std::string& name)
484 {
485 strncpy(m_cStructure->strName, name.c_str(), sizeof(m_cStructure->strName) - 1);
486 }
487
488 /// @brief To get with the identification name.
489 std::string GetName() const { return m_cStructure->strName; }
490
491 /// @brief To set with the used property value.
492 void SetValue(const std::string& value)
493 {
494 strncpy(m_cStructure->strValue, value.c_str(), sizeof(m_cStructure->strValue) - 1);
495 }
496
497 /// @brief To get with the used property value.
498 std::string GetValue() const { return m_cStructure->strValue; }
499 ///@}
500
501private:
502 PVRStreamProperty(const PVR_NAMED_VALUE* data) : CStructHdl(data) {}
503 PVRStreamProperty(PVR_NAMED_VALUE* data) : CStructHdl(data) {}
504};
505///@}
506//------------------------------------------------------------------------------
507
508} /* namespace addon */
509} /* namespace kodi */
510
511#endif /* __cplusplus */
diff --git a/xbmc/addons/kodi-dev-kit/include/kodi/addon-instance/pvr/MenuHook.h b/xbmc/addons/kodi-dev-kit/include/kodi/addon-instance/pvr/MenuHook.h
new file mode 100644
index 0000000..053a4d5
--- /dev/null
+++ b/xbmc/addons/kodi-dev-kit/include/kodi/addon-instance/pvr/MenuHook.h
@@ -0,0 +1,130 @@
1/*
2 * Copyright (C) 2005-2018 Team Kodi
3 * This file is part of Kodi - https://kodi.tv
4 *
5 * SPDX-License-Identifier: GPL-2.0-or-later
6 * See LICENSES/README.md for more information.
7 */
8
9#pragma once
10
11#include "../../AddonBase.h"
12#include "../../c-api/addon-instance/pvr/pvr_menu_hook.h"
13
14//¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯
15// "C++" Definitions group 7 - Menu hook
16#ifdef __cplusplus
17
18namespace kodi
19{
20namespace addon
21{
22
23//==============================================================================
24/// @defgroup cpp_kodi_addon_pvr_Defs_Menuhook_PVRMenuhook class PVRMenuhook
25/// @ingroup cpp_kodi_addon_pvr_Defs_Menuhook
26/// @brief **Context menu hook**\n
27/// Menu hooks that are available in the context menus while playing a stream via this add-on.
28/// And in the Live TV settings dialog.
29///
30/// Possible menu's given to Kodi.
31///
32/// This can be becomes used on this, if @ref kodi::addon::CInstancePVRClient::AddMenuHook()
33/// was set to related type:
34/// - @ref kodi::addon::CInstancePVRClient::CallSettingsMenuHook()
35/// - @ref kodi::addon::CInstancePVRClient::CallChannelMenuHook()
36/// - @ref kodi::addon::CInstancePVRClient::CallEPGMenuHook()
37/// - @ref kodi::addon::CInstancePVRClient::CallRecordingMenuHook()
38/// - @ref kodi::addon::CInstancePVRClient::CallTimerMenuHook()
39///
40/// ----------------------------------------------------------------------------
41///
42/// @copydetails cpp_kodi_addon_pvr_Defs_Menuhook_PVRMenuhook_Help
43///
44///@{
45class PVRMenuhook : public CStructHdl<PVRMenuhook, PVR_MENUHOOK>
46{
47 friend class CInstancePVRClient;
48
49public:
50 /// @addtogroup cpp_kodi_addon_pvr_Defs_Menuhook_PVRMenuhook
51 /// @brief Optional class constructor with value set.
52 ///
53 /// @param[in] hookId This hook's identifier
54 /// @param[in] localizedStringId Localized string identifier
55 /// @param[in] category Category of menu hook, defined with @ref PVR_MENUHOOK_CAT
56 ///
57 ///
58 /// --------------------------------------------------------------------------
59 ///
60 /// Example:
61 /// ~~~~~~~~~~~~~{.cpp}
62 /// AddMenuHook(kodi::addon::PVRMenuhook(1, 30001, PVR_MENUHOOK_CHANNEL));
63 /// ~~~~~~~~~~~~~
64 ///
65 PVRMenuhook(unsigned int hookId, unsigned int localizedStringId, PVR_MENUHOOK_CAT category)
66 {
67 m_cStructure->iHookId = hookId;
68 m_cStructure->iLocalizedStringId = localizedStringId;
69 m_cStructure->category = category;
70 }
71
72 /*! \cond PRIVATE */
73 PVRMenuhook()
74 {
75 m_cStructure->iHookId = 0;
76 m_cStructure->iLocalizedStringId = 0;
77 m_cStructure->category = PVR_MENUHOOK_UNKNOWN;
78 }
79 PVRMenuhook(const PVRMenuhook& data) : CStructHdl(data) {}
80 /*! \endcond */
81
82 /// @defgroup cpp_kodi_addon_pvr_Defs_Menuhook_PVRMenuhook_Help Value Help
83 /// @ingroup cpp_kodi_addon_pvr_Defs_Menuhook_PVRMenuhook
84 ///
85 /// <b>The following table contains values that can be set with @ref cpp_kodi_addon_pvr_Defs_Menuhook_PVRMenuhook :</b>
86 /// | Name | Type | Set call | Get call | Usage
87 /// |------|------|----------|----------|-----------
88 /// | **This hook's identifier** | `unsigned int` | @ref PVRMenuhook::SetHookId "SetHookId" | @ref PVRMenuhook::GetHookId "GetHookId" | *required to set*
89 /// | **Localized string Identifier** | `unsigned int` | @ref PVRMenuhook::SetLocalizedStringId "SetLocalizedStringId" | @ref PVRMenuhook::GetLocalizedStringId "GetLocalizedStringId" | *required to set*
90 /// | **Category of menu hook** | @ref PVR_MENUHOOK_CAT | @ref PVRMenuhook::SetCategory "SetCategory" | @ref PVRMenuhook::GetCategory "GetCategory" | *required to set*
91
92 /// @addtogroup cpp_kodi_addon_pvr_Defs_Menuhook_PVRMenuhook
93 ///@{
94
95 /// @brief **required**\n
96 /// This hook's identifier.
97 void SetHookId(unsigned int hookId) { m_cStructure->iHookId = hookId; }
98
99 /// @brief To get with @ref SetHookId() changed values.
100 unsigned int GetHookId() const { return m_cStructure->iHookId; }
101
102 /// @brief **required**\n
103 /// The id of the label for this hook in @ref kodi::GetLocalizedString().
104 void SetLocalizedStringId(unsigned int localizedStringId)
105 {
106 m_cStructure->iLocalizedStringId = localizedStringId;
107 }
108
109 /// @brief To get with @ref SetLocalizedStringId() changed values.
110 unsigned int GetLocalizedStringId() const { return m_cStructure->iLocalizedStringId; }
111
112 /// @brief **required**\n
113 /// Category of menu hook.
114 void SetCategory(PVR_MENUHOOK_CAT category) { m_cStructure->category = category; }
115
116 /// @brief To get with @ref SetCategory() changed values.
117 PVR_MENUHOOK_CAT GetCategory() const { return m_cStructure->category; }
118 ///@}
119
120private:
121 PVRMenuhook(const PVR_MENUHOOK* data) : CStructHdl(data) {}
122 PVRMenuhook(PVR_MENUHOOK* data) : CStructHdl(data) {}
123};
124///@}
125//------------------------------------------------------------------------------
126
127} /* namespace addon */
128} /* namespace kodi */
129
130#endif /* __cplusplus */
diff --git a/xbmc/addons/kodi-dev-kit/include/kodi/addon-instance/pvr/Recordings.h b/xbmc/addons/kodi-dev-kit/include/kodi/addon-instance/pvr/Recordings.h
new file mode 100644
index 0000000..24ecf11
--- /dev/null
+++ b/xbmc/addons/kodi-dev-kit/include/kodi/addon-instance/pvr/Recordings.h
@@ -0,0 +1,520 @@
1/*
2 * Copyright (C) 2005-2018 Team Kodi
3 * This file is part of Kodi - https://kodi.tv
4 *
5 * SPDX-License-Identifier: GPL-2.0-or-later
6 * See LICENSES/README.md for more information.
7 */
8
9#pragma once
10
11#include "../../AddonBase.h"
12#include "../../c-api/addon-instance/pvr.h"
13
14//¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯
15// "C++" Definitions group 5 - PVR recordings
16#ifdef __cplusplus
17
18namespace kodi
19{
20namespace addon
21{
22
23//==============================================================================
24/// @defgroup cpp_kodi_addon_pvr_Defs_Recording_PVRRecording class PVRRecording
25/// @ingroup cpp_kodi_addon_pvr_Defs_Recording
26/// @brief **Data structure with available recordings data**\n
27/// With this, recordings related data are transferred between addon and Kodi
28/// and can also be used by the addon itself.
29///
30/// The related values here are automatically initiated to defaults and need
31/// only be set if supported and used.
32///
33/// ----------------------------------------------------------------------------
34///
35/// @copydetails cpp_kodi_addon_pvr_Defs_Recording_PVRRecording_Help
36///
37///@{
38class PVRRecording : public CStructHdl<PVRRecording, PVR_RECORDING>
39{
40 friend class CInstancePVRClient;
41
42public:
43 /*! \cond PRIVATE */
44 PVRRecording()
45 {
46 m_cStructure->iSeriesNumber = PVR_RECORDING_INVALID_SERIES_EPISODE;
47 m_cStructure->iEpisodeNumber = PVR_RECORDING_INVALID_SERIES_EPISODE;
48 m_cStructure->recordingTime = 0;
49 m_cStructure->iDuration = PVR_RECORDING_VALUE_NOT_AVAILABLE;
50 m_cStructure->iPriority = PVR_RECORDING_VALUE_NOT_AVAILABLE;
51 m_cStructure->iLifetime = PVR_RECORDING_VALUE_NOT_AVAILABLE;
52 m_cStructure->iGenreType = PVR_RECORDING_VALUE_NOT_AVAILABLE;
53 m_cStructure->iGenreSubType = PVR_RECORDING_VALUE_NOT_AVAILABLE;
54 m_cStructure->iPlayCount = PVR_RECORDING_VALUE_NOT_AVAILABLE;
55 m_cStructure->iLastPlayedPosition = PVR_RECORDING_VALUE_NOT_AVAILABLE;
56 m_cStructure->bIsDeleted = false;
57 m_cStructure->iEpgEventId = 0;
58 m_cStructure->iChannelUid = PVR_RECORDING_VALUE_NOT_AVAILABLE;
59 m_cStructure->channelType = PVR_RECORDING_CHANNEL_TYPE_UNKNOWN;
60 m_cStructure->iFlags = 0;
61 m_cStructure->sizeInBytes = PVR_RECORDING_VALUE_NOT_AVAILABLE;
62 }
63 PVRRecording(const PVRRecording& recording) : CStructHdl(recording) {}
64 /*! \endcond */
65
66 /// @defgroup cpp_kodi_addon_pvr_Defs_Recording_PVRRecording_Help Value Help
67 /// @ingroup cpp_kodi_addon_pvr_Defs_Recording_PVRRecording
68 ///
69 /// <b>The following table contains values that can be set with @ref cpp_kodi_addon_pvr_Defs_Recording_PVRRecording :</b>
70 /// | Name | Type | Set call | Get call | Usage
71 /// |------|------|----------|----------|-----------
72 /// | **Recording id** | `std::string` | @ref PVRRecording::SetRecordingId "SetRecordingId" | @ref PVRRecording::GetRecordingId "GetRecordingId" | *required to set*
73 /// | **Title** | `std::string` | @ref PVRRecording::SetTitle "SetTitle" | @ref PVRRecording::GetTitle "GetTitle" | *required to set*
74 /// | **Episode name** | `std::string` | @ref PVRRecording::SetEpisodeName "SetEpisodeName" | @ref PVRRecording::GetEpisodeName "GetEpisodeName" | *optional*
75 /// | **Series number** | `int` | @ref PVRRecording::SetSeriesNumber "SetSeriesNumber" | @ref PVRRecording::GetSeriesNumber "GetSeriesNumber" | *optional*
76 /// | **Episode number** | `int` | @ref PVRRecording::SetEpisodeNumber "SetEpisodeNumber" | @ref PVRRecording::GetEpisodeNumber "GetEpisodeNumber" | *optional*
77 /// | **Year** | `int` | @ref PVRRecording::SetYear "SetYear" | @ref PVRRecording::GetYear "GetYear" | *optional*
78 /// | **Directory** | `std::string` | @ref PVRRecording::SetDirectory "SetDirectory" | @ref PVRRecording::GetDirectory "GetDirectory" | *optional*
79 /// | **Plot outline** | `std::string` | @ref PVRRecording::SetPlotOutline "SetPlotOutline" | @ref PVRRecording::GetPlotOutline "GetPlotOutline" | *optional*
80 /// | **Plot** | `std::string` | @ref PVRRecording::SetPlot "SetPlot" | @ref PVRRecording::GetPlot "GetPlot" | *optional*
81 /// | **Genre description** | `std::string` | @ref PVRRecording::SetGenreDescription "SetGenreDescription" | @ref PVRRecording::GetGenreDescription "GetGenreDescription" | *optional*
82 /// | **Channel name** | `std::string` | @ref PVRRecording::SetChannelName "SetChannelName" | @ref PVRRecording::GetChannelName "GetChannelName" | *optional*
83 /// | **Icon path** | `std::string` | @ref PVRRecording::SetIconPath "SetIconPath" | @ref PVRRecording::GetIconPath "GetIconPath" | *optional*
84 /// | **Thumbnail path** | `std::string` | @ref PVRRecording::SetThumbnailPath "SetThumbnailPath" | @ref PVRRecording::GetThumbnailPath "GetThumbnailPath" | *optional*
85 /// | **Fanart path** | `std::string` | @ref PVRRecording::SetFanartPath "SetFanartPath" | @ref PVRRecording::GetFanartPath "GetFanartPath" | *optional*
86 /// | **Recording time** | `time_t` | @ref PVRRecording::SetRecordingTime "SetRecordingTime" | @ref PVRRecording::GetRecordingTime "GetRecordingTime" | *optional*
87 /// | **Duration** | `int` | @ref PVRRecording::SetDuration "SetDuration" | @ref PVRRecording::GetDuration "GetDuration" | *optional*
88 /// | **Priority** | `int` | @ref PVRRecording::SetPriority "SetPriority" | @ref PVRRecording::GetPriority "GetPriority" | *optional*
89 /// | **Lifetime** | `int` | @ref PVRRecording::SetLifetime "SetLifetime" | @ref PVRRecording::GetLifetime "GetLifetime" | *optional*
90 /// | **Genre type** | `int` | @ref PVRRecording::SetGenreType "SetGenreType" | @ref PVRRecording::GetGenreType "GetGenreType" | *optional*
91 /// | **Genre sub type** | `int` | @ref PVRRecording::SetGenreSubType "SetGenreSubType" | @ref PVRRecording::GetGenreSubType "GetGenreSubType" | *optional*
92 /// | **Play count** | `int` | @ref PVRRecording::SetPlayCount "SetPlayCount" | @ref PVRRecording::GetPlayCount "GetPlayCount" | *optional*
93 /// | **Last played position** | `int` | @ref PVRRecording::SetLastPlayedPosition "SetLastPlayedPosition" | @ref PVRRecording::GetLastPlayedPosition "GetLastPlayedPosition" | *optional*
94 /// | **Is deleted** | `bool` | @ref PVRRecording::SetIsDeleted "SetIsDeleted" | @ref PVRRecording::GetIsDeleted "GetIsDeleted" | *optional*
95 /// | **EPG event id** | `unsigned int` | @ref PVRRecording::SetEPGEventId "SetEPGEventId" | @ref PVRRecording::GetEPGEventId "GetEPGEventId" | *optional*
96 /// | **Channel unique id** | `int` | @ref PVRRecording::SetChannelUid "SetChannelUid" | @ref PVRRecording::GetChannelUid "GetChannelUid" | *optional*
97 /// | **Channel type** | @ref PVR_RECORDING_CHANNEL_TYPE | @ref PVRRecording::SetChannelType "SetChannelType" | @ref PVRRecording::GetChannelType "GetChannelType" | *optional*
98 /// | **First aired** | `std::string` | @ref PVRRecording::SetFirstAired "SetFirstAired" | @ref PVRRecording::GetFirstAired "GetFirstAired" | *optional*
99 /// | **Flags** | `std::string` | @ref PVRRecording::SetFlags "SetFlags" | @ref PVRRecording::GetFlags "GetFlags" | *optional*
100 /// | **Size in bytes** | `std::string` | @ref PVRRecording::SetSizeInBytes "SetSizeInBytes" | @ref PVRRecording::GetSizeInBytes "GetSizeInBytes" | *optional*
101
102 /// @addtogroup cpp_kodi_addon_pvr_Defs_Recording_PVRRecording
103 ///@{
104
105 /// @brief **required**\n
106 /// Unique identifier of the recording on the client.
107 void SetRecordingId(const std::string& recordingId)
108 {
109 strncpy(m_cStructure->strRecordingId, recordingId.c_str(),
110 sizeof(m_cStructure->strRecordingId) - 1);
111 }
112
113 /// @brief To get with @ref SetRecordingId changed values.
114 std::string GetRecordingId() const { return m_cStructure->strRecordingId; }
115
116 /// @brief **required**\n
117 /// The title of this recording.
118 void SetTitle(const std::string& title)
119 {
120 strncpy(m_cStructure->strTitle, title.c_str(), sizeof(m_cStructure->strTitle) - 1);
121 }
122
123 /// @brief To get with @ref SetTitle changed values.
124 std::string GetTitle() const { return m_cStructure->strTitle; }
125
126 /// @brief **optional**\n
127 /// Episode name (also known as subtitle).
128 void SetEpisodeName(const std::string& episodeName)
129 {
130 strncpy(m_cStructure->strEpisodeName, episodeName.c_str(),
131 sizeof(m_cStructure->strEpisodeName) - 1);
132 }
133
134 /// @brief To get with @ref SetEpisodeName changed values.
135 std::string GetEpisodeName() const { return m_cStructure->strEpisodeName; }
136
137 /// @brief **optional**\n
138 /// Series number (usually called season).
139 ///
140 /// Set to "0" for specials/pilot. For 'invalid' see @ref SetEpisodeNumber or set to -1.
141 void SetSeriesNumber(int seriesNumber) { m_cStructure->iSeriesNumber = seriesNumber; }
142
143 /// @brief To get with @ref SetSeriesNumber changed values.
144 int GetSeriesNumber() const { return m_cStructure->iSeriesNumber; }
145
146 /// @brief **optional**\n
147 /// Eepisode number within the "iSeriesNumber" season.
148 ///
149 /// For 'invalid' set to -1 or seriesNumber=episodeNumber=0 to show both are invalid.
150 void SetEpisodeNumber(int episodeNumber) { m_cStructure->iEpisodeNumber = episodeNumber; }
151
152 /// @brief To get with @ref SetEpisodeNumber changed values.
153 int GetEpisodeNumber() const { return m_cStructure->iEpisodeNumber; }
154
155 /// @brief **optional**\n
156 /// Year of first release (use to identify a specific movie re-make) / first
157 /// airing for TV shows.
158 ///
159 /// Set to '0' for invalid.
160 void SetYear(int year) { m_cStructure->iYear = year; }
161
162 /// @brief To get with @ref SetYear changed values.
163 int GetYear() const { return m_cStructure->iYear; }
164
165 /// @brief **optional**\n
166 ///
167 /// Directory of this recording on the client.
168 void SetDirectory(const std::string& directory)
169 {
170 strncpy(m_cStructure->strDirectory, directory.c_str(), sizeof(m_cStructure->strDirectory) - 1);
171 }
172
173 /// @brief To get with @ref SetDirectory changed values.
174 std::string GetDirectory() const { return m_cStructure->strDirectory; }
175
176 /// @brief **optional**\n
177 /// Plot outline name.
178 void SetPlotOutline(const std::string& plotOutline)
179 {
180 strncpy(m_cStructure->strPlotOutline, plotOutline.c_str(),
181 sizeof(m_cStructure->strPlotOutline) - 1);
182 }
183
184 /// @brief To get with @ref SetPlotOutline changed values.
185 std::string GetPlotOutline() const { return m_cStructure->strPlotOutline; }
186
187 /// @brief **optional**\n
188 /// Plot name.
189 void SetPlot(const std::string& plot)
190 {
191 strncpy(m_cStructure->strPlot, plot.c_str(), sizeof(m_cStructure->strPlot) - 1);
192 }
193
194 /// @brief To get with @ref SetPlot changed values.
195 std::string GetPlot() const { return m_cStructure->strPlot; }
196
197 /// @brief **optional**\n
198 /// Channel name.
199 void SetChannelName(const std::string& channelName)
200 {
201 strncpy(m_cStructure->strChannelName, channelName.c_str(),
202 sizeof(m_cStructure->strChannelName) - 1);
203 }
204
205 /// @brief To get with @ref SetChannelName changed values.
206 std::string GetChannelName() const { return m_cStructure->strChannelName; }
207
208 /// @brief **optional**\n
209 /// Channel logo (icon) path.
210 void SetIconPath(const std::string& iconPath)
211 {
212 strncpy(m_cStructure->strIconPath, iconPath.c_str(), sizeof(m_cStructure->strIconPath) - 1);
213 }
214
215 /// @brief To get with @ref SetIconPath changed values.
216 std::string GetIconPath() const { return m_cStructure->strIconPath; }
217
218 /// @brief **optional**\n
219 /// Thumbnail path.
220 void SetThumbnailPath(const std::string& thumbnailPath)
221 {
222 strncpy(m_cStructure->strThumbnailPath, thumbnailPath.c_str(),
223 sizeof(m_cStructure->strThumbnailPath) - 1);
224 }
225
226 /// @brief To get with @ref SetThumbnailPath changed values.
227 std::string GetThumbnailPath() const { return m_cStructure->strThumbnailPath; }
228
229 /// @brief **optional**\n
230 /// Fanart path.
231 void SetFanartPath(const std::string& fanartPath)
232 {
233 strncpy(m_cStructure->strFanartPath, fanartPath.c_str(),
234 sizeof(m_cStructure->strFanartPath) - 1);
235 }
236
237 /// @brief To get with @ref SetFanartPath changed values.
238 std::string GetFanartPath() const { return m_cStructure->strFanartPath; }
239
240 /// @brief **optional**\n
241 /// Start time of the recording.
242 void SetRecordingTime(time_t recordingTime) { m_cStructure->recordingTime = recordingTime; }
243
244 /// @brief To get with @ref SetRecordingTime changed values.
245 time_t GetRecordingTime() const { return m_cStructure->recordingTime; }
246
247 /// @brief **optional**\n
248 /// Duration of the recording in seconds.
249 void SetDuration(int duration) { m_cStructure->iDuration = duration; }
250
251 /// @brief To get with @ref SetDuration changed values.
252 int GetDuration() const { return m_cStructure->iDuration; }
253
254 /// @brief **optional**\n
255 /// Priority of this recording (from 0 - 100).
256 void SetPriority(int priority) { m_cStructure->iPriority = priority; }
257
258 /// @brief To get with @ref SetPriority changed values.
259 int GetPriority() const { return m_cStructure->iPriority; }
260
261 /// @brief **optional**\n
262 /// Life time in days of this recording.
263 void SetLifetime(int lifetime) { m_cStructure->iLifetime = lifetime; }
264
265 /// @brief To get with @ref SetLifetime changed values.
266 int GetLifetime() const { return m_cStructure->iLifetime; }
267
268 /// @brief **optional**\n
269 /// Genre type.
270 ///
271 /// Use @ref EPG_GENRE_USE_STRING if type becomes given by @ref SetGenreDescription.
272 ///
273 /// @note If confirmed that backend brings the types in [ETSI EN 300 468](https://www.etsi.org/deliver/etsi_en/300400_300499/300468/01.14.01_60/en_300468v011401p.pdf)
274 /// conform values, can be @ref EPG_EVENT_CONTENTMASK ignored and to set here
275 /// with backend value.
276 ///
277 ///
278 /// --------------------------------------------------------------------------
279 ///
280 /// **Example 1:**
281 /// ~~~~~~~~~~~~~{.cpp}
282 /// kodi::addon::PVRRecording tag;
283 /// tag.SetGenreType(EPG_EVENT_CONTENTMASK_MOVIEDRAMA);
284 /// ~~~~~~~~~~~~~
285 ///
286 /// --------------------------------------------------------------------------
287 ///
288 /// **Example 2** (in case of other, not ETSI EN 300 468 conform genre types):
289 /// ~~~~~~~~~~~~~{.cpp}
290 /// kodi::addon::PVRRecording tag;
291 /// tag.SetGenreType(EPG_GENRE_USE_STRING);
292 /// tag.SetGenreDescription("My special genre name"); // Should use (if possible) kodi::GetLocalizedString(...) to have match user language.
293 /// ~~~~~~~~~~~~~
294 ///
295 void SetGenreType(int genreType) { m_cStructure->iGenreType = genreType; }
296
297 /// @brief To get with @ref SetGenreType changed values.
298 int GetGenreType() const { return m_cStructure->iGenreType; }
299
300 /// @brief **optional**\n
301 /// Genre sub type.
302 ///
303 /// Subtypes groups related to set by @ref SetGenreType:
304 /// | Main genre type | List with available sub genre types
305 /// |-----------------|-----------------------------------------
306 /// | @ref EPG_EVENT_CONTENTMASK_UNDEFINED | Nothing, should be 0
307 /// | @ref EPG_EVENT_CONTENTMASK_MOVIEDRAMA | @ref EPG_EVENT_CONTENTSUBMASK_MOVIEDRAMA
308 /// | @ref EPG_EVENT_CONTENTMASK_NEWSCURRENTAFFAIRS | @ref EPG_EVENT_CONTENTSUBMASK_NEWSCURRENTAFFAIRS
309 /// | @ref EPG_EVENT_CONTENTMASK_SHOW | @ref EPG_EVENT_CONTENTSUBMASK_SHOW
310 /// | @ref EPG_EVENT_CONTENTMASK_SPORTS | @ref EPG_EVENT_CONTENTSUBMASK_SPORTS
311 /// | @ref EPG_EVENT_CONTENTMASK_CHILDRENYOUTH | @ref EPG_EVENT_CONTENTSUBMASK_CHILDRENYOUTH
312 /// | @ref EPG_EVENT_CONTENTMASK_MUSICBALLETDANCE | @ref EPG_EVENT_CONTENTSUBMASK_MUSICBALLETDANCE
313 /// | @ref EPG_EVENT_CONTENTMASK_ARTSCULTURE | @ref EPG_EVENT_CONTENTSUBMASK_ARTSCULTURE
314 /// | @ref EPG_EVENT_CONTENTMASK_SOCIALPOLITICALECONOMICS | @ref EPG_EVENT_CONTENTSUBMASK_SOCIALPOLITICALECONOMICS
315 /// | @ref EPG_EVENT_CONTENTMASK_EDUCATIONALSCIENCE | @ref EPG_EVENT_CONTENTSUBMASK_EDUCATIONALSCIENCE
316 /// | @ref EPG_EVENT_CONTENTMASK_LEISUREHOBBIES | @ref EPG_EVENT_CONTENTSUBMASK_LEISUREHOBBIES
317 /// | @ref EPG_EVENT_CONTENTMASK_SPECIAL | @ref EPG_EVENT_CONTENTSUBMASK_SPECIAL
318 /// | @ref EPG_EVENT_CONTENTMASK_USERDEFINED | Can be defined by you
319 /// | @ref EPG_GENRE_USE_STRING | **Kodi's own value**, which declares that the type with @ref SetGenreDescription is given.
320 ///
321 /// --------------------------------------------------------------------------
322 ///
323 /// **Example:**
324 /// ~~~~~~~~~~~~~{.cpp}
325 /// kodi::addon::PVRRecording tag;
326 /// tag.SetGenreType(EPG_EVENT_CONTENTMASK_MUSICBALLETDANCE);
327 /// tag.SetGenreSubType(EPG_EVENT_CONTENTSUBMASK_MUSICBALLETDANCE_JAZZ);
328 /// ~~~~~~~~~~~~~
329 ///
330 void SetGenreSubType(int genreSubType) { m_cStructure->iGenreSubType = genreSubType; }
331
332 /// @brief To get with @ref SetGenreSubType changed values.
333 int GetGenreSubType() const { return m_cStructure->iGenreSubType; }
334
335 /// @brief **optional**\n
336 /// To set own genre description name.
337 ///
338 /// Will be used only when genreType == @ref EPG_GENRE_USE_STRING or
339 /// genreSubType == @ref EPG_GENRE_USE_STRING.
340 ///
341 /// Use @ref EPG_STRING_TOKEN_SEPARATOR to separate different genres.
342 ///
343 /// In case of other, not [ETSI EN 300 468](https://www.etsi.org/deliver/etsi_en/300400_300499/300468/01.14.01_60/en_300468v011401p.pdf)
344 /// conform genre types or something special.
345 ///
346 /// --------------------------------------------------------------------------
347 ///
348 /// **Example:**
349 /// ~~~~~~~~~~~~~{.cpp}
350 /// kodi::addon::PVRRecording tag;
351 /// tag.SetGenreType(EPG_GENRE_USE_STRING);
352 /// tag.SetGenreDescription("Action" + EPG_STRING_TOKEN_SEPARATOR + "Thriller");
353 /// ~~~~~~~~~~~~~
354 ///
355 void SetGenreDescription(const std::string& genreDescription)
356 {
357 strncpy(m_cStructure->strGenreDescription, genreDescription.c_str(),
358 sizeof(m_cStructure->strGenreDescription) - 1);
359 }
360
361 /// @brief To get with @ref SetGenreDescription changed values.
362 std::string GetGenreDescription() const { return m_cStructure->strGenreDescription; }
363
364 /// @brief **optional**\n
365 /// Play count of this recording on the client.
366 void SetPlayCount(int playCount) { m_cStructure->iPlayCount = playCount; }
367
368 /// @brief To get with @ref SetPlayCount changed values.
369 int GetPlayCount() const { return m_cStructure->iPlayCount; }
370
371 /// @brief **optional**\n
372 /// Last played position of this recording on the client.
373 void SetLastPlayedPosition(int lastPlayedPosition)
374 {
375 m_cStructure->iLastPlayedPosition = lastPlayedPosition;
376 }
377
378 /// @brief To get with @ref SetLastPlayedPosition changed values.
379 int GetLastPlayedPosition() const { return m_cStructure->iLastPlayedPosition; }
380
381 /// @brief **optional**\n
382 /// Shows this recording is deleted and can be undelete.
383 void SetIsDeleted(int isDeleted) { m_cStructure->bIsDeleted = isDeleted; }
384
385 /// @brief To get with @ref SetIsDeleted changed values.
386 int GetIsDeleted() const { return m_cStructure->bIsDeleted; }
387
388 /// @brief **optional**\n
389 /// EPG event id associated with this recording. Valid ids must be greater than @ref EPG_TAG_INVALID_UID.
390 void SetEPGEventId(unsigned int epgEventId) { m_cStructure->iEpgEventId = epgEventId; }
391
392 /// @brief To get with @ref SetEPGEventId changed values.
393 unsigned int GetEPGEventId() const { return m_cStructure->iEpgEventId; }
394
395 /// @brief **optional**\n
396 /// Unique identifier of the channel for this recording. @ref PVR_CHANNEL_INVALID_UID
397 /// denotes that channel uid is not available.
398 void SetChannelUid(int channelUid) { m_cStructure->iChannelUid = channelUid; }
399
400 /// @brief To get with @ref SetChannelUid changed values
401 int GetChannelUid() const { return m_cStructure->iChannelUid; }
402
403 /// @brief **optional**\n
404 /// Channel type.
405 ///
406 /// Set to @ref PVR_RECORDING_CHANNEL_TYPE_UNKNOWN if the type cannot be
407 /// determined.
408 ///
409 /// --------------------------------------------------------------------------
410 ///
411 /// Example:
412 /// ~~~~~~~~~~~~~{.cpp}
413 /// kodi::addon::PVRRecording tag;
414 /// tag.SetChannelType(PVR_RECORDING_CHANNEL_TYPE_TV);
415 /// ~~~~~~~~~~~~~
416 ///
417 void SetChannelType(PVR_RECORDING_CHANNEL_TYPE channelType)
418 {
419 m_cStructure->channelType = channelType;
420 }
421
422 /// @brief To get with @ref SetChannelType changed values
423 PVR_RECORDING_CHANNEL_TYPE GetChannelType() const { return m_cStructure->channelType; }
424
425 /// @brief **optional**\n
426 /// First aired date of this recording.
427 ///
428 /// Used only for display purposes. Specify in W3C date format "YYYY-MM-DD".
429 ///
430 /// --------------------------------------------------------------------------
431 ///
432 /// Example:
433 /// ~~~~~~~~~~~~~{.cpp}
434 /// kodi::addon::PVRRecording tag;
435 /// tag.SetFirstAired(1982-10-22);
436 /// ~~~~~~~~~~~~~
437 ///
438 void SetFirstAired(const std::string& firstAired)
439 {
440 strncpy(m_cStructure->strFirstAired, firstAired.c_str(),
441 sizeof(m_cStructure->strFirstAired) - 1);
442 }
443
444 /// @brief To get with @ref SetFirstAired changed values
445 std::string GetFirstAired() const { return m_cStructure->strFirstAired; }
446
447 /// @brief **optional**\n
448 /// Bit field of independent flags associated with the recording.
449 ///
450 /// See @ref cpp_kodi_addon_pvr_Defs_Recording_PVR_RECORDING_FLAG for
451 /// available bit flags.
452 ///
453 /// --------------------------------------------------------------------------
454 ///
455 /// @copydetails cpp_kodi_addon_pvr_Defs_Recording_PVR_RECORDING_FLAG
456 ///
457 void SetFlags(unsigned int flags) { m_cStructure->iFlags = flags; }
458
459 /// @brief To get with @ref SetFlags changed values.
460 unsigned int GetFlags() const { return m_cStructure->iFlags; }
461
462 /// @brief **optional**\n
463 /// Size of the recording in bytes.
464 void SetSizeInBytes(int64_t sizeInBytes) { m_cStructure->sizeInBytes = sizeInBytes; }
465
466 /// @brief To get with @ref SetSizeInBytes changed values.
467 int64_t GetSizeInBytes() const { return m_cStructure->sizeInBytes; }
468 ///@}
469
470private:
471 PVRRecording(const PVR_RECORDING* recording) : CStructHdl(recording) {}
472 PVRRecording(PVR_RECORDING* recording) : CStructHdl(recording) {}
473};
474///@}
475//------------------------------------------------------------------------------
476
477//==============================================================================
478/// @defgroup cpp_kodi_addon_pvr_Defs_Recording_PVRRecordingsResultSet class PVRRecordingsResultSet
479/// @ingroup cpp_kodi_addon_pvr_Defs_Recording_PVRRecording
480/// @brief **PVR add-on recording transfer class**\n
481/// To transfer the content of @ref kodi::addon::CInstancePVRClient::GetRecordings().
482///
483/// @note This becomes only be used on addon call above, not usable outside on
484/// addon itself.
485///@{
486class PVRRecordingsResultSet
487{
488public:
489 /*! \cond PRIVATE */
490 PVRRecordingsResultSet() = delete;
491 PVRRecordingsResultSet(const AddonInstance_PVR* instance, ADDON_HANDLE handle)
492 : m_instance(instance), m_handle(handle)
493 {
494 }
495 /*! \endcond */
496
497 /// @addtogroup cpp_kodi_addon_pvr_Defs_Recording_PVRRecordingsResultSet
498 ///@{
499
500 /// @brief To add and give content from addon to Kodi on related call.
501 ///
502 /// @param[in] tag The to transferred data.
503 void Add(const kodi::addon::PVRRecording& tag)
504 {
505 m_instance->toKodi->TransferRecordingEntry(m_instance->toKodi->kodiInstance, m_handle, tag);
506 }
507
508 ///@}
509
510private:
511 const AddonInstance_PVR* m_instance = nullptr;
512 const ADDON_HANDLE m_handle;
513};
514///@}
515//------------------------------------------------------------------------------
516
517} /* namespace addon */
518} /* namespace kodi */
519
520#endif /* __cplusplus */
diff --git a/xbmc/addons/kodi-dev-kit/include/kodi/addon-instance/pvr/Stream.h b/xbmc/addons/kodi-dev-kit/include/kodi/addon-instance/pvr/Stream.h
new file mode 100644
index 0000000..5613947
--- /dev/null
+++ b/xbmc/addons/kodi-dev-kit/include/kodi/addon-instance/pvr/Stream.h
@@ -0,0 +1,330 @@
1/*
2 * Copyright (C) 2005-2018 Team Kodi
3 * This file is part of Kodi - https://kodi.tv
4 *
5 * SPDX-License-Identifier: GPL-2.0-or-later
6 * See LICENSES/README.md for more information.
7 */
8
9#pragma once
10
11#include "../../AddonBase.h"
12#include "../../c-api/addon-instance/pvr/pvr_stream.h"
13
14//¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯
15// "C++" Definitions group 9 - PVR stream definitions (NOTE: Becomes replaced
16// in future by inputstream addon instance way)
17
18#ifdef __cplusplus
19
20namespace kodi
21{
22namespace addon
23{
24
25//==============================================================================
26/// @defgroup cpp_kodi_addon_pvr_Defs_Stream_PVRCodec class PVRCodec
27/// @ingroup cpp_kodi_addon_pvr_Defs_Stream
28/// @brief **PVR codec identifier**\n
29/// Used to exchange the desired codec type between Kodi and addon.
30///
31/// @ref kodi::addon::CInstancePVRClient::GetCodecByName is used to get this data.
32///
33/// ----------------------------------------------------------------------------
34///
35/// @copydetails cpp_kodi_addon_pvr_Defs_Stream_PVRCodec_Help
36///
37///@{
38class PVRCodec : public CStructHdl<PVRCodec, PVR_CODEC>
39{
40 friend class CInstancePVRClient;
41
42public:
43 /*! \cond PRIVATE */
44 PVRCodec()
45 {
46 m_cStructure->codec_type = PVR_CODEC_TYPE_UNKNOWN;
47 m_cStructure->codec_id = PVR_INVALID_CODEC_ID;
48 }
49 PVRCodec(const PVRCodec& type) : CStructHdl(type) {}
50 /*! \endcond */
51
52 /// @defgroup cpp_kodi_addon_pvr_Defs_Stream_PVRCodec_Help Value Help
53 /// @ingroup cpp_kodi_addon_pvr_Defs_Stream_PVRCodec
54 ///
55 /// <b>The following table contains values that can be set with @ref cpp_kodi_addon_pvr_Defs_Stream_PVRCodec :</b>
56 /// | Name | Type | Set call | Get call
57 /// |------|------|----------|----------
58 /// | **Codec type** | @ref PVR_CODEC_TYPE | @ref PVRCodec::SetCodecType "SetCodecType" | @ref PVRCodec::GetCodecType "GetCodecType"
59 /// | **Codec identifier** | `unsigned int` | @ref PVRCodec::SetCodecId "SetCodecId" | @ref PVRCodec::GetCodecId "GetCodecId"
60 ///
61
62 /// @addtogroup cpp_kodi_addon_pvr_Defs_Stream_PVRCodec
63 ///@{
64
65 /// @brief Codec type.
66 void SetCodecType(PVR_CODEC_TYPE codecType) { m_cStructure->codec_type = codecType; }
67
68 /// @brief To get with @ref SetCodecType() changed values.
69 PVR_CODEC_TYPE GetCodecType() const { return m_cStructure->codec_type; }
70
71 /// @brief Codec id.
72 ///
73 /// Related codec identifier, normally match the ffmpeg id's.
74 void SetCodecId(unsigned int codecId) { m_cStructure->codec_id = codecId; }
75
76 /// @brief To get with @ref SetCodecId() changed values.
77 unsigned int GetCodecId() const { return m_cStructure->codec_id; }
78 ///@}
79
80private:
81 PVRCodec(const PVR_CODEC& type) : CStructHdl(&type) {}
82 PVRCodec(const PVR_CODEC* type) : CStructHdl(type) {}
83 PVRCodec(PVR_CODEC* type) : CStructHdl(type) {}
84};
85///@}
86//------------------------------------------------------------------------------
87
88//==============================================================================
89/// @defgroup cpp_kodi_addon_pvr_Defs_Stream_PVRStreamProperties class PVRStreamProperties
90/// @ingroup cpp_kodi_addon_pvr_Defs_Stream
91/// @brief **PVR stream properties**\n
92/// All information about a respective stream is stored in this, so that Kodi
93/// can process the data given by the addon after demux.
94///
95/// ----------------------------------------------------------------------------
96///
97/// @copydetails cpp_kodi_addon_pvr_Defs_Stream_PVRStreamProperties_Help
98///
99///@{
100class PVRStreamProperties
101 : public CStructHdl<PVRStreamProperties, PVR_STREAM_PROPERTIES::PVR_STREAM>
102{
103 friend class CInstancePVRClient;
104
105public:
106 /*! \cond PRIVATE */
107 PVRStreamProperties() { memset(m_cStructure, 0, sizeof(PVR_STREAM_PROPERTIES::PVR_STREAM)); }
108 PVRStreamProperties(const PVRStreamProperties& type) : CStructHdl(type) {}
109 /*! \endcond */
110
111 /// @defgroup cpp_kodi_addon_pvr_Defs_Stream_PVRStreamProperties_Help Value Help
112 /// @ingroup cpp_kodi_addon_pvr_Defs_Stream_PVRStreamProperties
113 /// ----------------------------------------------------------------------------
114 ///
115 /// <b>The following table contains values that can be set with @ref cpp_kodi_addon_pvr_Defs_Stream_PVRStreamProperties :</b>
116 /// | Name | Type | Set call | Get call
117 /// |------|------|----------|----------
118 /// | **PID** | `unsigned int` | @ref PVRStreamProperties::SetPID "SetPID" | @ref PVRStreamProperties::GetPID "GetPID"
119 /// | **Codec type** | @ref PVR_CODEC_TYPE | @ref PVRStreamProperties::SetCodecType "SetCodecType" | @ref PVRStreamProperties::GetCodecType "GetCodecType"
120 /// | **Codec identifier** | `unsigned int` | @ref PVRStreamProperties::SetCodecId "SetCodecId" | @ref PVRStreamProperties::GetCodecId "GetCodecId"
121 /// | **Language** | `std::string` | @ref PVRStreamProperties::SetLanguage "SetLanguage" | @ref PVRStreamProperties::GetLanguage "GetLanguage"
122 /// | **Subtitle info** | `int` | @ref PVRStreamProperties::SetSubtitleInfo "SetSubtitleInfo" | @ref PVRStreamProperties::GetSubtitleInfo "GetSubtitleInfo"
123 /// | **FPS scale** | `int` | @ref PVRStreamProperties::SetFPSScale "SetFPSScale" | @ref PVRStreamProperties::GetFPSScale "GetFPSScale"
124 /// | **FPS rate** | `int` | @ref PVRStreamProperties::SetFPSRate "SetFPSRate" | @ref PVRStreamProperties::GetFPSRate "GetFPSRate"
125 /// | **Height** | `int` | @ref PVRStreamProperties::SetHeight "SetHeight" | @ref PVRStreamProperties::GetHeight "GetHeight"
126 /// | **Width** | `int` | @ref PVRStreamProperties::SetWidth "SetWidth" | @ref PVRStreamProperties::GetWidth "GetWidth"
127 /// | **Aspect ratio** | `float` | @ref PVRStreamProperties::SetAspect "SetAspect" | @ref PVRStreamProperties::GetAspect "GetAspect"
128 /// | **Channels** | `int` | @ref PVRStreamProperties::SetChannels "SetChannels" | @ref PVRStreamProperties::GetChannels "GetChannels"
129 /// | **Samplerate** | `int` | @ref PVRStreamProperties::SetSampleRate "SetSampleRate" | @ref PVRStreamProperties::GetSampleRate "GetSampleRate"
130 /// | **Block align** | `int` | @ref PVRStreamProperties::SetBlockAlign "SetBlockAlign" | @ref PVRStreamProperties::GetBlockAlign "GetBlockAlign"
131 /// | **Bit rate** | `int` | @ref PVRStreamProperties::SetBitRate "SetBitRate" | @ref PVRStreamProperties::GetBitRate "GetBitRate"
132 /// | **Bits per sample** | `int` | @ref PVRStreamProperties::SetBitsPerSample "SetBitsPerSample" | @ref PVRStreamProperties::GetBitsPerSample "GetBitsPerSample"
133 ///
134
135 /// @addtogroup cpp_kodi_addon_pvr_Defs_Stream_PVRStreamProperties
136 ///@{
137
138 /// @brief PID.
139 void SetPID(unsigned int pid) { m_cStructure->iPID = pid; }
140
141 /// @brief To get with @ref SetPID() changed values.
142 unsigned int GetPID() const { return m_cStructure->iPID; }
143
144 /// @brief Codec type this stream.
145 void SetCodecType(PVR_CODEC_TYPE codecType) { m_cStructure->iCodecType = codecType; }
146
147 /// @brief To get with @ref SetCodecType() changed values.
148 PVR_CODEC_TYPE GetCodecType() const { return m_cStructure->iCodecType; }
149
150 /// @brief Codec id of this stream.
151 void SetCodecId(unsigned int codecId) { m_cStructure->iCodecId = codecId; }
152
153 /// @brief To get with @ref SetCodecId() changed values.
154 unsigned int GetCodecId() const { return m_cStructure->iCodecId; }
155
156 /// @brief 3 letter language id.
157 void SetLanguage(const std::string& language)
158 {
159 if (language.size() > 3)
160 {
161 kodi::Log(ADDON_LOG_ERROR,
162 "PVRStreamProperties::%s: Language string size '%li' higher as needed 3", __func__,
163 language.size());
164 return;
165 }
166 m_cStructure->strLanguage[0] = language[0];
167 m_cStructure->strLanguage[1] = language[1];
168 m_cStructure->strLanguage[2] = language[2];
169 m_cStructure->strLanguage[2] = 0;
170 }
171
172 /// @brief To get with @ref SetLanguage() changed values.
173 std::string GetLanguage() const { return m_cStructure->strLanguage; }
174
175 /// @brief Subtitle Info
176 void SetSubtitleInfo(int subtitleInfo) { m_cStructure->iSubtitleInfo = subtitleInfo; }
177
178 /// @brief To get with @ref SetSubtitleInfo() changed values.
179 int GetSubtitleInfo() const { return m_cStructure->iSubtitleInfo; }
180
181 /// @brief To set scale of 1000 and a rate of 29970 will result in 29.97 fps.
182 void SetFPSScale(int fpsScale) { m_cStructure->iFPSScale = fpsScale; }
183
184 /// @brief To get with @ref SetFPSScale() changed values.
185 int GetFPSScale() const { return m_cStructure->iFPSScale; }
186
187 /// @brief FPS rate
188 void SetFPSRate(int fpsRate) { m_cStructure->iFPSRate = fpsRate; }
189
190 /// @brief To get with @ref SetFPSRate() changed values.
191 int GetFPSRate() const { return m_cStructure->iFPSRate; }
192
193 /// @brief Height of the stream reported by the demuxer
194 void SetHeight(int height) { m_cStructure->iHeight = height; }
195
196 /// @brief To get with @ref SetHeight() changed values.
197 int GetHeight() const { return m_cStructure->iHeight; }
198
199 /// @brief Width of the stream reported by the demuxer.
200 void SetWidth(int width) { m_cStructure->iWidth = width; }
201
202 /// @brief To get with @ref SetWidth() changed values.
203 int GetWidth() const { return m_cStructure->iWidth; }
204
205 /// @brief Display aspect ratio of the stream.
206 void SetAspect(float aspect) { m_cStructure->fAspect = aspect; }
207
208 /// @brief To get with @ref SetAspect() changed values.
209 float GetAspect() const { return m_cStructure->fAspect; }
210
211 /// @brief Amount of channels.
212 void SetChannels(int channels) { m_cStructure->iChannels = channels; }
213
214 /// @brief To get with @ref SetChannels() changed values.
215 int GetChannels() const { return m_cStructure->iChannels; }
216
217 /// @brief Sample rate.
218 void SetSampleRate(int sampleRate) { m_cStructure->iSampleRate = sampleRate; }
219
220 /// @brief To get with @ref SetSampleRate() changed values.
221 int GetSampleRate() const { return m_cStructure->iSampleRate; }
222
223 /// @brief Block alignment
224 void SetBlockAlign(int blockAlign) { m_cStructure->iBlockAlign = blockAlign; }
225
226 /// @brief To get with @ref SetBlockAlign() changed values.
227 int GetBlockAlign() const { return m_cStructure->iBlockAlign; }
228
229 /// @brief Bit rate.
230 void SetBitRate(int bitRate) { m_cStructure->iBitRate = bitRate; }
231
232 /// @brief To get with @ref SetBitRate() changed values.
233 int GetBitRate() const { return m_cStructure->iBitRate; }
234
235 /// @brief Bits per sample.
236 void SetBitsPerSample(int bitsPerSample) { m_cStructure->iBitsPerSample = bitsPerSample; }
237
238 /// @brief To get with @ref SetBitsPerSample() changed values.
239 int GetBitsPerSample() const { return m_cStructure->iBitsPerSample; }
240 ///@}
241
242private:
243 PVRStreamProperties(const PVR_STREAM_PROPERTIES::PVR_STREAM* type) : CStructHdl(type) {}
244 PVRStreamProperties(PVR_STREAM_PROPERTIES::PVR_STREAM* type) : CStructHdl(type) {}
245};
246///@}
247//------------------------------------------------------------------------------
248
249//==============================================================================
250/// @defgroup cpp_kodi_addon_pvr_Defs_Stream_PVRStreamTimes class PVRStreamTimes
251/// @ingroup cpp_kodi_addon_pvr_Defs_Stream
252/// @brief **Times of playing stream (Live TV and recordings)**\n
253/// This class is used to transfer the necessary data when
254/// @ref kodi::addon::PVRStreamProperties::GetStreamTimes is called.
255///
256/// ----------------------------------------------------------------------------
257///
258/// @copydetails cpp_kodi_addon_pvr_Defs_Stream_PVRStreamTimes_Help
259///
260///@{
261class PVRStreamTimes : public CStructHdl<PVRStreamTimes, PVR_STREAM_TIMES>
262{
263 friend class CInstancePVRClient;
264
265public:
266 /*! \cond PRIVATE */
267 PVRStreamTimes() { memset(m_cStructure, 0, sizeof(PVR_STREAM_TIMES)); }
268 PVRStreamTimes(const PVRStreamTimes& type) : CStructHdl(type) {}
269 /*! \endcond */
270
271 /// @defgroup cpp_kodi_addon_pvr_Defs_Stream_PVRStreamTimes_Help Value Help
272 /// @ingroup cpp_kodi_addon_pvr_Defs_Stream_PVRStreamTimes
273 /// ----------------------------------------------------------------------------
274 ///
275 /// <b>The following table contains values that can be set with @ref cpp_kodi_addon_pvr_Defs_Stream_PVRStreamTimes :</b>
276 /// | Name | Type | Set call | Get call
277 /// |------|------|----------|----------
278 /// | **Start time** | `time_t` | @ref PVRStreamTimes::SetStartTime "SetStartTime" | @ref PVRStreamTimes::GetStartTime "GetStartTime"
279 /// | **PTS start** | `int64_t` | @ref PVRStreamTimes::SetPTSStart "SetPTSStart" | @ref PVRStreamTimes::GetPTSStart "GetPTSStart"
280 /// | **PTS begin** | `int64_t` | @ref PVRStreamTimes::SetPTSBegin "SetPTSBegin" | @ref PVRStreamTimes::GetPTSBegin "GetPTSBegin"
281 /// | **PTS end** | `int64_t` | @ref PVRStreamTimes::SetPTSEnd "SetPTSEnd" | @ref PVRStreamTimes::GetPTSEnd "GetPTSEnd"
282 ///
283
284 /// @addtogroup cpp_kodi_addon_pvr_Defs_Stream_PVRStreamTimes
285 ///@{
286
287 /// @brief For recordings, this must be zero. For Live TV, this is a reference
288 /// time in units of time_t (UTC) from which time elapsed starts. Ideally start
289 /// of tv show, but can be any other value.
290 void SetStartTime(time_t startTime) { m_cStructure->startTime = startTime; }
291
292 /// @brief To get with @ref SetStartTime() changed values.
293 time_t GetStartTime() const { return m_cStructure->startTime; }
294
295 /// @brief The pts of startTime.
296 void SetPTSStart(int64_t ptsStart) { m_cStructure->ptsStart = ptsStart; }
297
298 /// @brief To get with @ref SetPTSStart() changed values.
299 int64_t GetPTSStart() const { return m_cStructure->ptsStart; }
300
301 /// @brief Earliest pts player can seek back. Value is in micro seconds,
302 /// relative to PTS start. For recordings, this must be zero. For Live TV, this
303 /// must be zero if not timeshifting and must point to begin of the timeshift
304 /// buffer, otherwise.
305 void SetPTSBegin(int64_t ptsBegin) { m_cStructure->ptsBegin = ptsBegin; }
306
307 /// @brief To get with @ref SetPTSBegin() changed values.
308 int64_t GetPTSBegin() const { return m_cStructure->ptsBegin; }
309
310 /// @brief Latest pts player can seek forward. Value is in micro seconds,
311 /// relative to PTS start. For recordings, this must be the total length. For
312 /// Live TV, this must be zero if not timeshifting and must point to end of
313 /// the timeshift buffer, otherwise.
314 void SetPTSEnd(int64_t ptsEnd) { m_cStructure->ptsEnd = ptsEnd; }
315
316 /// @brief To get with @ref SetPTSEnd() changed values.
317 int64_t GetPTSEnd() const { return m_cStructure->ptsEnd; }
318 ///@}
319
320private:
321 PVRStreamTimes(const PVR_STREAM_TIMES* type) : CStructHdl(type) {}
322 PVRStreamTimes(PVR_STREAM_TIMES* type) : CStructHdl(type) {}
323};
324///@}
325//------------------------------------------------------------------------------
326
327} /* namespace addon */
328} /* namespace kodi */
329
330#endif /* __cplusplus */
diff --git a/xbmc/addons/kodi-dev-kit/include/kodi/addon-instance/pvr/Timers.h b/xbmc/addons/kodi-dev-kit/include/kodi/addon-instance/pvr/Timers.h
new file mode 100644
index 0000000..6e05e55
--- /dev/null
+++ b/xbmc/addons/kodi-dev-kit/include/kodi/addon-instance/pvr/Timers.h
@@ -0,0 +1,896 @@
1/*
2 * Copyright (C) 2005-2018 Team Kodi
3 * This file is part of Kodi - https://kodi.tv
4 *
5 * SPDX-License-Identifier: GPL-2.0-or-later
6 * See LICENSES/README.md for more information.
7 */
8
9#pragma once
10
11#include "General.h"
12#include "../../AddonBase.h"
13#include "../../c-api/addon-instance/pvr.h"
14
15//¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯
16// "C++" Definitions group 6 - PVR timers
17#ifdef __cplusplus
18
19namespace kodi
20{
21namespace addon
22{
23
24//==============================================================================
25/// @defgroup cpp_kodi_addon_pvr_Defs_Timer_PVRTimer class PVRTimer
26/// @ingroup cpp_kodi_addon_pvr_Defs_Timer
27/// @brief **PVR add-on timer type**\n
28/// Representation of a timer event.
29///
30/// The related values here are automatically initiated to defaults and need
31/// only be set if supported and used.
32///
33/// ----------------------------------------------------------------------------
34///
35/// @copydetails cpp_kodi_addon_pvr_Defs_Timer_PVRTimer_Help
36///
37///@{
38class PVRTimer : public CStructHdl<PVRTimer, PVR_TIMER>
39{
40 friend class CInstancePVRClient;
41
42public:
43 /*! \cond PRIVATE */
44 PVRTimer()
45 {
46 m_cStructure->iClientIndex = 0;
47 m_cStructure->state = PVR_TIMER_STATE_NEW;
48 m_cStructure->iTimerType = PVR_TIMER_TYPE_NONE;
49 m_cStructure->iParentClientIndex = 0;
50 m_cStructure->iClientChannelUid = PVR_TIMER_VALUE_NOT_AVAILABLE;
51 m_cStructure->startTime = 0;
52 m_cStructure->endTime = 0;
53 m_cStructure->bStartAnyTime = false;
54 m_cStructure->bEndAnyTime = false;
55 m_cStructure->bFullTextEpgSearch = false;
56 m_cStructure->iPriority = PVR_TIMER_VALUE_NOT_AVAILABLE;
57 m_cStructure->iLifetime = PVR_TIMER_VALUE_NOT_AVAILABLE;
58 m_cStructure->iMaxRecordings = PVR_TIMER_VALUE_NOT_AVAILABLE;
59 m_cStructure->iRecordingGroup = 0;
60 m_cStructure->firstDay = 0;
61 m_cStructure->iWeekdays = PVR_WEEKDAY_NONE;
62 m_cStructure->iPreventDuplicateEpisodes = 0;
63 m_cStructure->iEpgUid = 0;
64 m_cStructure->iMarginStart = 0;
65 m_cStructure->iMarginEnd = 0;
66 m_cStructure->iGenreType = PVR_TIMER_VALUE_NOT_AVAILABLE;
67 m_cStructure->iGenreSubType = PVR_TIMER_VALUE_NOT_AVAILABLE;
68 }
69 PVRTimer(const PVRTimer& data) : CStructHdl(data) {}
70 /*! \endcond */
71
72 /// @defgroup cpp_kodi_addon_pvr_Defs_Timer_PVRTimer_Help Value Help
73 /// @ingroup cpp_kodi_addon_pvr_Defs_Timer_PVRTimer
74 ///
75 /// <b>The following table contains values that can be set with @ref cpp_kodi_addon_pvr_Defs_Timer_PVRTimer :</b>
76 /// | Name | Type | Set call | Get call | Usage
77 /// |------|------|----------|----------|-----------
78 /// | **Client index** | `unsigned int` | @ref PVRTimer::SetClientIndex "SetClientIndex" | @ref PVRTimer::GetClientIndex "GetClientIndex" | *required to set*
79 /// | **State** | @ref PVR_TIMER_STATE | @ref PVRTimer::SetState "SetState" | @ref PVRTimer::GetState "GetState" | *required to set*
80 /// | **Type** | `unsigned int` | @ref PVRTimer::SetTimerType "SetTimerType" | @ref PVRTimer::GetTimerType "GetTimerType" | *required to set*
81 /// | **Title** | `std::string` | @ref PVRTimer::SetTitle "SetTitle" | @ref PVRTimer::GetTitle "GetTitle" | *required to set*
82 /// | **Parent client index** | `unsigned int` | @ref PVRTimer::SetParentClientIndex "SetParentClientIndex" | @ref PVRTimer::GetParentClientIndex "GetParentClientIndex" | *optional*
83 /// | **Client channel unique identifier** | `int` | @ref PVRTimer::SetClientChannelUid "SetClientChannelUid" | @ref PVRTimer::GetClientChannelUid "GetClientChannelUid" | *optional*
84 /// | **Start time** | `time_t` | @ref PVRTimer::SetStartTime "SetStartTime" | @ref PVRTimer::GetStartTime "GetStartTime" | *optional*
85 /// | **End time** | `time_t` | @ref PVRTimer::SetEndTime "SetEndTime" | @ref PVRTimer::GetEndTime "GetEndTime" | *optional*
86 /// | **Start any time** | `bool` | @ref PVRTimer::SetStartAnyTime "SetStartAnyTime" | @ref PVRTimer::GetStartAnyTime "GetStartAnyTime" | *optional*
87 /// | **End any time** | `bool` | @ref PVRTimer::SetEndAnyTime "SetEndAnyTime" | @ref PVRTimer::GetEndAnyTime "GetEndAnyTime" | *optional*
88 /// | **EPG search string** | `std::string` | @ref PVRTimer::SetEPGSearchString "SetEPGSearchString" | @ref PVRTimer::GetEPGSearchString "GetEPGSearchString" | *optional*
89 /// | **Full text EPG search** | `bool` | @ref PVRTimer::SetFullTextEpgSearch "SetFullTextEpgSearch" | @ref PVRTimer::GetFullTextEpgSearch "GetFullTextEpgSearch" | *optional*
90 /// | **Recording store directory** | `std::string` | @ref PVRTimer::SetDirectory "SetDirectory" | @ref PVRTimer::GetDirectory "GetDirectory" | *optional*
91 /// | **Timer priority** | `int` | @ref PVRTimer::SetPriority "SetPriority" | @ref PVRTimer::GetPriority "GetPriority" | *optional*
92 /// | **Timer lifetime** | `int` | @ref PVRTimer::SetLifetime "SetLifetime" | @ref PVRTimer::GetLifetime "GetLifetime" | *optional*
93 /// | **Max recordings** | `int` | @ref PVRTimer::SetMaxRecordings "SetMaxRecordings" | @ref PVRTimer::GetMaxRecordings "GetMaxRecordings" | *optional*
94 /// | **Recording group** | `unsigned int` | @ref PVRTimer::SetRecordingGroup "SetRecordingGroup" | @ref PVRTimer::GetRecordingGroup "GetRecordingGroup" | *optional*
95 /// | **First start day** | `time_t` | @ref PVRTimer::SetFirstDay "SetFirstDay" | @ref PVRTimer::GetFirstDay "GetFirstDay" | *optional*
96 /// | **Used timer weekdays** | `unsigned int` | @ref PVRTimer::SetWeekdays "SetWeekdays" | @ref PVRTimer::GetWeekdays "GetWeekdays" | *optional*
97 /// | **Prevent duplicate episodes** | `unsigned int` | @ref PVRTimer::SetPreventDuplicateEpisodes "SetPreventDuplicateEpisodes" | @ref PVRTimer::GetPreventDuplicateEpisodes "GetPreventDuplicateEpisodes" | *optional*
98 /// | **EPG unique identifier** | `unsigned int` | @ref PVRTimer::SetEPGUid "SetEPGUid" | @ref PVRTimer::GetEPGUid "GetEPGUid" | *optional*
99 /// | **Margin start** | `unsigned int` | @ref PVRTimer::SetMarginStart "SetMarginStart" | @ref PVRTimer::GetMarginStart "GetMarginStart" | *optional*
100 /// | **Margin end** | `unsigned int` | @ref PVRTimer::SetMarginEnd "SetMarginEnd" | @ref PVRTimer::GetMarginEnd "GetMarginEnd" | *optional*
101 /// | **Genre type** | `int` | @ref PVRTimer::SetGenreType "SetGenreType" | @ref PVRTimer::GetGenreType "GetGenreType" | *optional*
102 /// | **Genre sub type** | `int` | @ref PVRTimer::SetGenreSubType "SetGenreSubType" | @ref PVRTimer::GetGenreSubType "GetGenreSubType" | *optional*
103 /// | **Series link** | `std::string` | @ref PVRTimer::SetSeriesLink "SetSeriesLink" | @ref PVRTimer::GetSeriesLink "GetSeriesLink" | *optional*
104
105 /// @addtogroup cpp_kodi_addon_pvr_Defs_Timer_PVRTimer
106 ///@{
107
108 /// @brief **required**\n
109 /// The index of this timer given by the client.
110 ///
111 /// @ref PVR_TIMER_NO_CLIENT_INDEX indicates that the index was not yet set
112 /// by the client, for example for new timers created by Kodi and passed the
113 /// first time to the client. A valid index must be greater than
114 /// @ref PVR_TIMER_NO_CLIENT_INDEX.
115 ///
116 void SetClientIndex(unsigned int clientIndex) { m_cStructure->iClientIndex = clientIndex; }
117
118 /// @brief To get with @ref SetClientIndex changed values.
119 unsigned int GetClientIndex() const { return m_cStructure->iClientIndex; }
120
121 /// @brief **required**\n
122 /// The state of this timer.
123 ///
124 /// @note @ref PVR_TIMER_STATE_NEW is default.
125 ///
126 ///
127 /// --------------------------------------------------------------------------
128 ///
129 /// **Example:**
130 /// ~~~~~~~~~~~~~{.cpp}
131 /// kodi::addon::PVRTimer tag;
132 /// tag.SetState(PVR_TIMER_STATE_RECORDING);
133 /// ~~~~~~~~~~~~~
134 ///
135 void SetState(PVR_TIMER_STATE state) { m_cStructure->state = state; }
136
137 /// @brief To get with @ref SetState changed values.
138 PVR_TIMER_STATE GetState() const { return m_cStructure->state; }
139
140 /// @brief **required**\n
141 /// The type of this timer.
142 ///
143 /// It is private to the addon and can be freely defined by the addon.
144 /// The value must be greater than @ref PVR_TIMER_TYPE_NONE.
145 ///
146 /// Kodi does not interpret this value (except for checking for @ref PVR_TIMER_TYPE_NONE),
147 /// but will pass the right id to the addon with every @ref PVRTimer instance,
148 /// thus the addon easily can determine the timer type.
149 ///
150 /// @note @ref PVR_TIMER_TYPE_NONE is default.
151 ///
152 ///
153 /// --------------------------------------------------------------------------
154 ///
155 /// **Example:**
156 /// ~~~~~~~~~~~~~{.cpp}
157 /// kodi::addon::PVRTimer tag;
158 /// tag.SetTimerType(123);
159 /// ~~~~~~~~~~~~~
160 ///
161 void SetTimerType(unsigned int timerType) { m_cStructure->iTimerType = timerType; }
162
163 /// @brief To get with @ref SetTimerType changed values.
164 unsigned int GetTimerType() const { return m_cStructure->iTimerType; }
165
166 /// @brief **required**\n
167 /// A title for this timer.
168 void SetTitle(const std::string& title)
169 {
170 strncpy(m_cStructure->strTitle, title.c_str(), sizeof(m_cStructure->strTitle) - 1);
171 }
172
173 /// @brief To get with @ref SetTitle changed values.
174 std::string GetTitle() const { return m_cStructure->strTitle; }
175
176 /// @brief **optional**\n
177 /// For timers scheduled by a repeating timer.
178 ///
179 /// The index of the repeating timer that scheduled this timer (it's
180 /// @ref clientIndex value). Use @ref PVR_TIMER_NO_PARENT to indicate that
181 /// this timer was no scheduled by a repeating timer.
182 void SetParentClientIndex(unsigned int parentClientIndex)
183 {
184 m_cStructure->iParentClientIndex = parentClientIndex;
185 }
186
187 /// @brief To get with @ref SetParentClientIndex changed values.
188 unsigned int GetParentClientIndex() const { return m_cStructure->iParentClientIndex; }
189
190 /// @brief **optional**\n
191 /// Unique identifier of the channel to record on.
192 ///
193 /// @ref PVR_TIMER_ANY_CHANNEL will denote "any channel", not a specific one.
194 /// @ref PVR_CHANNEL_INVALID_UID denotes that channel uid is not available.
195 void SetClientChannelUid(int clientChannelUid)
196 {
197 m_cStructure->iClientChannelUid = clientChannelUid;
198 }
199
200 /// @brief To get with @ref SetClientChannelUid changed values
201 int GetClientChannelUid() const { return m_cStructure->iClientChannelUid; }
202
203 /// @brief **optional**\n
204 /// Start time of the recording in UTC.
205 ///
206 /// Instant timers that are sent to the add-on by Kodi will have this value
207 /// set to 0.
208 void SetStartTime(time_t startTime) { m_cStructure->startTime = startTime; }
209
210 /// @brief To get with @ref SetStartTime changed values.
211 time_t GetStartTime() const { return m_cStructure->startTime; }
212
213 /// @brief **optional**\n
214 /// End time of the recording in UTC.
215 void SetEndTime(time_t endTime) { m_cStructure->endTime = endTime; }
216
217 /// @brief To get with @ref SetEndTime changed values.
218 time_t GetEndTime() const { return m_cStructure->endTime; }
219
220 /// @brief **optional**\n
221 /// For EPG based (not Manual) timers indicates startTime does not apply.
222 ///
223 /// Default = false.
224 void SetStartAnyTime(bool startAnyTime) { m_cStructure->bStartAnyTime = startAnyTime; }
225
226 /// @brief To get with @ref SetStartAnyTime changed values.
227 bool GetStartAnyTime() const { return m_cStructure->bStartAnyTime; }
228
229 /// @brief **optional**\n
230 /// For EPG based (not Manual) timers indicates endTime does not apply.
231 ///
232 /// Default = false
233 void SetEndAnyTime(bool endAnyTime) { m_cStructure->bEndAnyTime = endAnyTime; }
234
235 /// @brief To get with @ref SetEndAnyTime changed values.
236 bool GetEndAnyTime() const { return m_cStructure->bEndAnyTime; }
237
238 /// @brief **optional**\n
239 /// A string used to search epg data for repeating epg-based timers.
240 ///
241 /// Format is backend-dependent, for example regexp.
242 void SetEPGSearchString(const std::string& epgSearchString)
243 {
244 strncpy(m_cStructure->strEpgSearchString, epgSearchString.c_str(),
245 sizeof(m_cStructure->strEpgSearchString) - 1);
246 }
247
248 /// @brief To get with @ref SetEPGSearchString changed values
249 std::string GetEPGSearchString() const { return m_cStructure->strEpgSearchString; }
250
251 /// @brief **optional**\n
252 /// Indicates, whether @ref SetEPGSearchString() is to match against the epg
253 /// episode title only or also against "other" epg data (backend-dependent).
254 void SetFullTextEpgSearch(bool fullTextEpgSearch)
255 {
256 m_cStructure->bFullTextEpgSearch = fullTextEpgSearch;
257 }
258
259 /// @brief To get with @ref SetFullTextEpgSearch changed values.
260 bool GetFullTextEpgSearch() const { return m_cStructure->bFullTextEpgSearch; }
261
262 /// @brief **optional**\n
263 /// The (relative) directory where the recording will be stored in.
264 void SetDirectory(const std::string& directory)
265 {
266 strncpy(m_cStructure->strDirectory, directory.c_str(), sizeof(m_cStructure->strDirectory) - 1);
267 }
268
269 /// @brief To get with @ref SetDirectory changed values.
270 std::string GetDirectory() const { return m_cStructure->strDirectory; }
271
272 /// @brief **optional**\n
273 /// The summary for this timer.
274 void SetSummary(const std::string& summary)
275 {
276 strncpy(m_cStructure->strSummary, summary.c_str(), sizeof(m_cStructure->strSummary) - 1);
277 }
278
279 /// @brief To get with @ref SetDirectory changed values.
280 std::string GetSummary() const { return m_cStructure->strSummary; }
281
282 /// @brief **optional**\n
283 /// The priority of this timer.
284 void SetPriority(int priority) { m_cStructure->iPriority = priority; }
285
286 /// @brief To get with @ref SetPriority changed values.
287 int GetPriority() const { return m_cStructure->iPriority; }
288
289 /// @brief **optional**\n
290 /// Lifetime of recordings created by this timer.
291 ///
292 /// Value > 0 days after which recordings will be deleted by the backend, < 0
293 /// addon defined integer list reference, == 0 disabled.
294 void SetLifetime(int priority) { m_cStructure->iLifetime = priority; }
295
296 /// @brief To get with @ref SetLifetime changed values.
297 int GetLifetime() const { return m_cStructure->iLifetime; }
298
299 /// @brief **optional**\n
300 /// Maximum number of recordings this timer shall create.
301 ///
302 /// Value > 0 number of recordings, < 0 addon defined integer list reference, == 0 disabled.
303 void SetMaxRecordings(int maxRecordings) { m_cStructure->iMaxRecordings = maxRecordings; }
304
305 /// @brief To get with @ref SetMaxRecordings changed values.
306 int GetMaxRecordings() const { return m_cStructure->iMaxRecordings; }
307
308 /// @brief **optional**\n
309 /// Integer ref to addon/backend defined list of recording groups.
310 void SetRecordingGroup(unsigned int recordingGroup)
311 {
312 m_cStructure->iRecordingGroup = recordingGroup;
313 }
314
315 /// @brief To get with @ref SetRecordingGroup changed values.
316 unsigned int GetRecordingGroup() const { return m_cStructure->iRecordingGroup; }
317
318 /// @brief **optional**\n
319 /// The first day this timer is active, for repeating timers.
320 void SetFirstDay(time_t firstDay) { m_cStructure->firstDay = firstDay; }
321
322 /// @brief To get with @ref SetFirstDay changed values.
323 time_t GetFirstDay() const { return m_cStructure->firstDay; }
324
325 /// @brief **optional**\n
326 /// Week days, for repeating timers (see
327 /// @ref cpp_kodi_addon_pvr_Defs_Timer_PVR_WEEKDAY "PVR_WEEKDAY_*" constant values)
328 ///
329 /// @note @ref PVR_WEEKDAY_NONE is default.
330 ///
331 ///
332 /// --------------------------------------------------------------------------
333 ///
334 /// **Example:**
335 /// ~~~~~~~~~~~~~{.cpp}
336 /// ...
337 /// kodi::addon::PVRTimer tag;
338 /// tag.SetWeekdays(PVR_WEEKDAY_MONDAY | PVR_WEEKDAY_SATURDAY);
339 /// ...
340 /// ~~~~~~~~~~~~~
341 void SetWeekdays(unsigned int weekdays) { m_cStructure->iWeekdays = weekdays; }
342
343 /// @brief To get with @ref SetFirstDay changed values.
344 unsigned int GetWeekdays() const { return m_cStructure->iWeekdays; }
345
346 /// @brief **optional**\n
347 /// Prevent duplicate episodes.
348 ///
349 /// Should 1 if backend should only record new episodes in case of a repeating
350 /// epg-based timer, 0 if all episodes shall be recorded (no duplicate detection).
351 ///
352 /// Actual algorithm for duplicate detection is defined by the backend.
353 /// Addons may define own values for different duplicate detection
354 /// algorithms, thus this is not just a bool.
355 void SetPreventDuplicateEpisodes(unsigned int preventDuplicateEpisodes)
356 {
357 m_cStructure->iPreventDuplicateEpisodes = preventDuplicateEpisodes;
358 }
359
360 /// @brief To get with @ref SetPreventDuplicateEpisodes changed values.
361 unsigned int GetPreventDuplicateEpisodes() const
362 {
363 return m_cStructure->iPreventDuplicateEpisodes;
364 }
365
366 /// @brief **optional**\n
367 /// EPG event id associated with this timer. Event ids must be unique for a
368 /// channel.
369 ///
370 /// Valid ids must be greater than @ref EPG_TAG_INVALID_UID.
371 void SetEPGUid(unsigned int epgUid) { m_cStructure->iEpgUid = epgUid; }
372
373 /// @brief To get with @ref SetEPGUid changed values.
374 unsigned int GetEPGUid() const { return m_cStructure->iEpgUid; }
375
376 /// @brief **optional**\n
377 /// If set, the backend starts the recording selected minutes before
378 /// @ref SetStartTime.
379 void SetMarginStart(unsigned int marginStart) { m_cStructure->iMarginStart = marginStart; }
380
381 /// @brief To get with @ref SetMarginStart changed values.
382 unsigned int GetMarginStart() const { return m_cStructure->iMarginStart; }
383
384 /// @brief **optional**\n
385 /// If set, the backend ends the recording selected minutes after
386 /// @ref SetEndTime.
387 void SetMarginEnd(unsigned int marginEnd) { m_cStructure->iMarginEnd = marginEnd; }
388
389 /// @brief To get with @ref SetMarginEnd changed values.
390 unsigned int GetMarginEnd() const { return m_cStructure->iMarginEnd; }
391
392 /// @brief **optional**\n
393 /// Genre type.
394 ///
395 /// @copydetails EPG_EVENT_CONTENTMASK
396 ///
397 /// --------------------------------------------------------------------------
398 ///
399 /// **Example:**
400 /// ~~~~~~~~~~~~~{.cpp}
401 /// ...
402 /// kodi::addon::PVRTimer tag;
403 /// tag.SetGenreType(EPG_EVENT_CONTENTMASK_MOVIEDRAMA);
404 /// ...
405 /// ~~~~~~~~~~~~~
406 ///
407 /// @note If confirmed that backend brings the types in [ETSI EN 300 468](https://www.etsi.org/deliver/etsi_en/300400_300499/300468/01.14.01_60/en_300468v011401p.pdf)
408 /// conform values, can be @ref EPG_EVENT_CONTENTMASK ignored and to set here
409 /// with backend value.
410 ///
411 void SetGenreType(int genreType) { m_cStructure->iGenreType = genreType; }
412
413 /// @brief To get with @ref SetGenreType changed values.
414 int GetGenreType() const { return m_cStructure->iGenreType; }
415
416 /// @brief **optional**\n
417 /// Genre sub type.
418 ///
419 /// @copydetails EPG_EVENT_CONTENTMASK
420 ///
421 /// Subtypes groups related to set by @ref SetGenreType:
422 /// | Main genre type | List with available sub genre types
423 /// |-----------------|-----------------------------------------
424 /// | @ref EPG_EVENT_CONTENTMASK_UNDEFINED | Nothing, should be 0
425 /// | @ref EPG_EVENT_CONTENTMASK_MOVIEDRAMA | @ref EPG_EVENT_CONTENTSUBMASK_MOVIEDRAMA
426 /// | @ref EPG_EVENT_CONTENTMASK_NEWSCURRENTAFFAIRS | @ref EPG_EVENT_CONTENTSUBMASK_NEWSCURRENTAFFAIRS
427 /// | @ref EPG_EVENT_CONTENTMASK_SHOW | @ref EPG_EVENT_CONTENTSUBMASK_SHOW
428 /// | @ref EPG_EVENT_CONTENTMASK_SPORTS | @ref EPG_EVENT_CONTENTSUBMASK_SPORTS
429 /// | @ref EPG_EVENT_CONTENTMASK_CHILDRENYOUTH | @ref EPG_EVENT_CONTENTSUBMASK_CHILDRENYOUTH
430 /// | @ref EPG_EVENT_CONTENTMASK_MUSICBALLETDANCE | @ref EPG_EVENT_CONTENTSUBMASK_MUSICBALLETDANCE
431 /// | @ref EPG_EVENT_CONTENTMASK_ARTSCULTURE | @ref EPG_EVENT_CONTENTSUBMASK_ARTSCULTURE
432 /// | @ref EPG_EVENT_CONTENTMASK_SOCIALPOLITICALECONOMICS | @ref EPG_EVENT_CONTENTSUBMASK_SOCIALPOLITICALECONOMICS
433 /// | @ref EPG_EVENT_CONTENTMASK_EDUCATIONALSCIENCE | @ref EPG_EVENT_CONTENTSUBMASK_EDUCATIONALSCIENCE
434 /// | @ref EPG_EVENT_CONTENTMASK_LEISUREHOBBIES | @ref EPG_EVENT_CONTENTSUBMASK_LEISUREHOBBIES
435 /// | @ref EPG_EVENT_CONTENTMASK_SPECIAL | @ref EPG_EVENT_CONTENTSUBMASK_SPECIAL
436 /// | @ref EPG_EVENT_CONTENTMASK_USERDEFINED | Can be defined by you
437 ///
438 /// --------------------------------------------------------------------------
439 ///
440 /// **Example:**
441 /// ~~~~~~~~~~~~~{.cpp}
442 /// ...
443 /// kodi::addon::PVRTimer tag;
444 /// tag.SetGenreType(EPG_EVENT_CONTENTMASK_MUSICBALLETDANCE);
445 /// tag.SetGenreSubType(EPG_EVENT_CONTENTSUBMASK_MUSICBALLETDANCE_JAZZ);
446 /// ...
447 /// ~~~~~~~~~~~~~
448 ///
449 void SetGenreSubType(int genreSubType) { m_cStructure->iGenreSubType = genreSubType; }
450
451 /// @brief To get with @ref SetGenreType changed values.
452 int GetGenreSubType() const { return m_cStructure->iGenreSubType; }
453
454 /// @brief **optional**\n
455 /// Series link for this timer.
456 ///
457 /// If set for an epg-based timer rule, matching events will be found by
458 /// checking with here, instead of @ref SetTitle() (and @ref SetFullTextEpgSearch()).
459 void SetSeriesLink(const std::string& seriesLink)
460 {
461 strncpy(m_cStructure->strSeriesLink, seriesLink.c_str(),
462 sizeof(m_cStructure->strSeriesLink) - 1);
463 }
464
465 /// @brief To get with @ref SetSeriesLink changed values.
466 std::string GetSeriesLink() const { return m_cStructure->strSeriesLink; }
467 ///@}
468
469private:
470 PVRTimer(const PVR_TIMER* data) : CStructHdl(data) {}
471 PVRTimer(PVR_TIMER* data) : CStructHdl(data) {}
472};
473
474///@}
475//------------------------------------------------------------------------------
476
477//==============================================================================
478/// @defgroup cpp_kodi_addon_pvr_Defs_Timer_PVRTimersResultSet class PVRTimersResultSet
479/// @ingroup cpp_kodi_addon_pvr_Defs_Timer_PVRTimer
480/// @brief **PVR add-on timer transfer class**\n
481/// To transfer the content of @ref kodi::addon::CInstancePVRClient::GetTimers().
482///
483/// @note This becomes only be used on addon call above, not usable outside on
484/// addon itself.
485///@{
486class PVRTimersResultSet
487{
488public:
489 /*! \cond PRIVATE */
490 PVRTimersResultSet() = delete;
491 PVRTimersResultSet(const AddonInstance_PVR* instance, ADDON_HANDLE handle)
492 : m_instance(instance), m_handle(handle)
493 {
494 }
495 /*! \endcond */
496
497 /// @addtogroup cpp_kodi_addon_pvr_Defs_Timer_PVRTimersResultSet
498 ///@{
499
500 /// @brief To add and give content from addon to Kodi on related call.
501 ///
502 /// @param[in] tag The to transferred data.
503 void Add(const kodi::addon::PVRTimer& tag)
504 {
505 m_instance->toKodi->TransferTimerEntry(m_instance->toKodi->kodiInstance, m_handle, tag);
506 }
507
508 ///@}
509
510private:
511 const AddonInstance_PVR* m_instance = nullptr;
512 const ADDON_HANDLE m_handle;
513};
514///@}
515//------------------------------------------------------------------------------
516
517//==============================================================================
518/// @defgroup cpp_kodi_addon_pvr_Defs_Timer_PVRTimerType class PVRTimerType
519/// @ingroup cpp_kodi_addon_pvr_Defs_Timer
520/// @brief **PVR add-on timer type**\n
521/// To define the content of @ref kodi::addon::CInstancePVRClient::GetTimerTypes()
522/// given groups.
523///
524/// ----------------------------------------------------------------------------
525///
526/// @copydetails cpp_kodi_addon_pvr_Defs_Timer_PVRTimerType_Help
527///
528///@{
529class PVRTimerType : public CStructHdl<PVRTimerType, PVR_TIMER_TYPE>
530{
531 friend class CInstancePVRClient;
532
533public:
534 /*! \cond PRIVATE */
535 PVRTimerType()
536 {
537 memset(m_cStructure, 0, sizeof(PVR_TIMER_TYPE));
538 m_cStructure->iPrioritiesDefault = -1;
539 m_cStructure->iLifetimesDefault = -1;
540 m_cStructure->iPreventDuplicateEpisodesDefault = -1;
541 m_cStructure->iRecordingGroupDefault = -1;
542 m_cStructure->iMaxRecordingsDefault = -1;
543 }
544 PVRTimerType(const PVRTimerType& type) : CStructHdl(type) {}
545 /*! \endcond */
546
547 /// @defgroup cpp_kodi_addon_pvr_Defs_Timer_PVRTimerType_Help Value Help
548 /// @ingroup cpp_kodi_addon_pvr_Defs_Timer_PVRTimerType
549 /// ----------------------------------------------------------------------------
550 ///
551 /// <b>The following table contains values that can be set with @ref cpp_kodi_addon_pvr_Defs_Timer_PVRTimerType :</b>
552 /// | Name | Type | Set call | Get call | Usage
553 /// |------|------|----------|----------|-----------
554 /// | **Identifier** | `unsigned int` | @ref PVRTimerType::SetId "SetId" | @ref PVRTimerType::GetId "GetId" | *required to set*
555 /// | **Attributes** | `unsigned int` | @ref PVRTimerType::SetAttributes "SetAttributes" | @ref PVRTimerType::GetAttributes "GetAttributes" | *required to set*
556 /// | **Description** | `std::string` | @ref PVRTimerType::SetDescription "SetDescription" | @ref PVRTimerType::GetDescription "GetDescription" | *optional*
557 /// | | | | | |
558 /// | **Priority selection** | @ref cpp_kodi_addon_pvr_Defs_PVRTypeIntValue "PVRTypeIntValue" | @ref PVRTimerType::SetPriorities "SetPriorities" | @ref PVRTimerType::GetPriorities "GetPriorities" | *optional*
559 /// | **Priority default selection** | `int`| @ref PVRTimerType::SetPrioritiesDefault "SetPrioritiesDefault" | @ref PVRTimerType::GetPrioritiesDefault "GetPrioritiesDefault" | *optional*
560 /// | | | | | |
561 /// | **Lifetime selection** | @ref cpp_kodi_addon_pvr_Defs_PVRTypeIntValue "PVRTypeIntValue" | @ref PVRTimerType::SetLifetimes "SetLifetimes" | @ref PVRTimerType::GetLifetimes "GetLifetimes" | *optional*
562 /// | **Lifetime default selection** | `int`| @ref PVRTimerType::SetLifetimesDefault "SetLifetimesDefault" | @ref PVRTimerType::GetLifetimesDefault "GetLifetimesDefault" | *optional*
563 /// | | | | | |
564 /// | **Prevent duplicate episodes selection** | @ref cpp_kodi_addon_pvr_Defs_PVRTypeIntValue "PVRTypeIntValue" | @ref PVRTimerType::SetPreventDuplicateEpisodes "SetPreventDuplicateEpisodes" | @ref PVRTimerType::GetPreventDuplicateEpisodes "GetPreventDuplicateEpisodes" | *optional*
565 /// | **Prevent duplicate episodes default** | `int`| @ref PVRTimerType::SetPreventDuplicateEpisodesDefault "SetPreventDuplicateEpisodesDefault" | @ref PVRTimerType::GetPreventDuplicateEpisodesDefault "GetPreventDuplicateEpisodesDefault" | *optional*
566 /// | | | | | |
567 /// | **Recording group selection**| @ref cpp_kodi_addon_pvr_Defs_PVRTypeIntValue "PVRTypeIntValue" | @ref PVRTimerType::SetRecordingGroups "SetRecordingGroups" | @ref PVRTimerType::GetRecordingGroups "GetRecordingGroups" | *optional*
568 /// | **Recording group default** | `int`| @ref PVRTimerType::SetRecordingGroupDefault "SetRecordingGroupDefault" | @ref PVRTimerType::GetRecordingGroupDefault "GetRecordingGroupDefault" | *optional*
569 /// | | | | | |
570 /// | **Max recordings selection** | @ref cpp_kodi_addon_pvr_Defs_PVRTypeIntValue "PVRTypeIntValue" | @ref PVRTimerType::SetMaxRecordings "SetMaxRecordings" | @ref PVRTimerType::GetMaxRecordings "GetMaxRecordings" | *optional*
571 /// | **Max recordings default** | `int`| @ref PVRTimerType::SetMaxRecordingsDefault "SetMaxRecordingsDefault" | @ref PVRTimerType::GetMaxRecordingsDefault "GetMaxRecordingsDefault" | *optional*
572 ///
573
574 /// @addtogroup cpp_kodi_addon_pvr_Defs_Timer_PVRTimerType
575 ///@{
576
577 /// @brief **required**\n
578 /// This type's identifier. Ids must be > @ref PVR_TIMER_TYPE_NONE.
579 void SetId(unsigned int id) { m_cStructure->iId = id; }
580
581 /// @brief To get with @ref SetAttributes changed values.
582 unsigned int GetId() const { return m_cStructure->iId; }
583
584 /// @brief **required**\n
585 /// Defines the attributes for this type (@ref cpp_kodi_addon_pvr_Defs_Timer_PVR_TIMER_TYPE "PVR_TIMER_TYPE_*" constants).
586 ///
587 /// To defines the attributes for a type. These values are bit fields that can be
588 /// used together.
589 ///
590 ///--------------------------------------------------------------------------
591 ///
592 /// **Example:**
593 /// ~~~~~~~~~~~~~{.cpp}
594 /// kodi::addon::PVRTimerType tag;
595 /// tag.SetAttributes(PVR_TIMER_TYPE_IS_MANUAL | PVR_TIMER_TYPE_IS_REPEATING);
596 /// ~~~~~~~~~~~~~
597 ///
598 void SetAttributes(uint64_t attributes) { m_cStructure->iAttributes = attributes; }
599
600 /// @brief To get with @ref SetAttributes changed values.
601 uint64_t GetAttributes() const { return m_cStructure->iAttributes; }
602
603 /// @brief **optional**\n
604 /// A short localized string describing the purpose of the type. (e.g.
605 /// "Any time at this channel if title matches").
606 ///
607 /// If left blank, Kodi will generate a description based on the attributes
608 /// REPEATING and MANUAL. (e.g. "Repeating EPG-based.")
609 void SetDescription(const std::string& description)
610 {
611 strncpy(m_cStructure->strDescription, description.c_str(),
612 sizeof(m_cStructure->strDescription) - 1);
613 }
614
615 /// @brief To get with @ref SetDescription changed values.
616 std::string GetDescription() const { return m_cStructure->strDescription; }
617
618 //----------------------------------------------------------------------------
619
620 /// @brief **optional**\n
621 /// Priority value definitions.
622 ///
623 /// Array containing the possible values for @ref PVRTimer::SetPriority().
624 ///
625 /// @param[in] priorities List of priority values
626 /// @param[in] prioritiesDefault [opt] The default value in list, can also be
627 /// set by @ref SetPrioritiesDefault()
628 ///
629 /// --------------------------------------------------------------------------
630 ///
631 /// @copydetails cpp_kodi_addon_pvr_Defs_PVRTypeIntValue_Help
632 void SetPriorities(const std::vector<PVRTypeIntValue>& priorities, int prioritiesDefault = -1)
633 {
634 m_cStructure->iPrioritiesSize = static_cast<unsigned int>(priorities.size());
635 for (unsigned int i = 0;
636 i < m_cStructure->iPrioritiesSize && i < sizeof(m_cStructure->priorities); ++i)
637 {
638 m_cStructure->priorities[i].iValue = priorities[i].GetCStructure()->iValue;
639 strncpy(m_cStructure->priorities[i].strDescription,
640 priorities[i].GetCStructure()->strDescription,
641 sizeof(m_cStructure->priorities[i].strDescription) - 1);
642 }
643 if (prioritiesDefault != -1)
644 m_cStructure->iPrioritiesDefault = prioritiesDefault;
645 }
646
647 /// @brief To get with @ref SetPriorities changed values.
648 std::vector<PVRTypeIntValue> GetPriorities() const
649 {
650 std::vector<PVRTypeIntValue> ret;
651 for (unsigned int i = 0; i < m_cStructure->iPrioritiesSize; ++i)
652 ret.emplace_back(m_cStructure->priorities[i].iValue,
653 m_cStructure->priorities[i].strDescription);
654 return ret;
655 }
656
657 /// @brief **optional**\n
658 /// The default value for @ref PVRTimer::SetPriority().
659 ///
660 /// @note Must be filled if @ref SetPriorities contain values and not
661 /// defined there on second function value.
662 void SetPrioritiesDefault(int prioritiesDefault)
663 {
664 m_cStructure->iPrioritiesDefault = prioritiesDefault;
665 }
666
667 /// @brief To get with @ref SetPrioritiesDefault changed values.
668 int GetPrioritiesDefault() const { return m_cStructure->iPrioritiesDefault; }
669
670 //----------------------------------------------------------------------------
671
672 /// @brief **optional**\n
673 /// Lifetime value definitions.
674 ///
675 /// Array containing the possible values for @ref PVRTimer::SetLifetime().
676 ///
677 /// @param[in] lifetimes List of lifetimes values
678 /// @param[in] lifetimesDefault [opt] The default value in list, can also be
679 /// set by @ref SetLifetimesDefault()
680 ///
681 /// --------------------------------------------------------------------------
682 ///
683 /// @copydetails cpp_kodi_addon_pvr_Defs_PVRTypeIntValue_Help
684 void SetLifetimes(const std::vector<PVRTypeIntValue>& lifetimes, int lifetimesDefault = -1)
685 {
686 m_cStructure->iLifetimesSize = static_cast<unsigned int>(lifetimes.size());
687 for (unsigned int i = 0;
688 i < m_cStructure->iLifetimesSize && i < sizeof(m_cStructure->lifetimes); ++i)
689 {
690 m_cStructure->lifetimes[i].iValue = lifetimes[i].GetCStructure()->iValue;
691 strncpy(m_cStructure->lifetimes[i].strDescription,
692 lifetimes[i].GetCStructure()->strDescription,
693 sizeof(m_cStructure->lifetimes[i].strDescription) - 1);
694 }
695 if (lifetimesDefault != -1)
696 m_cStructure->iLifetimesDefault = lifetimesDefault;
697 }
698
699 /// @brief To get with @ref SetLifetimes changed values.
700 std::vector<PVRTypeIntValue> GetLifetimes() const
701 {
702 std::vector<PVRTypeIntValue> ret;
703 for (unsigned int i = 0; i < m_cStructure->iLifetimesSize; ++i)
704 ret.emplace_back(m_cStructure->lifetimes[i].iValue,
705 m_cStructure->lifetimes[i].strDescription);
706 return ret;
707 }
708
709 /// @brief **optional**\n
710 /// The default value for @ref SetLifetimes().
711 ///
712 /// @note Must be filled if @ref SetLifetimes contain values and not
713 /// defined there on second function value.
714 void SetLifetimesDefault(int lifetimesDefault)
715 {
716 m_cStructure->iLifetimesDefault = lifetimesDefault;
717 }
718
719 /// @brief To get with @ref SetLifetimesDefault changed values.
720 int GetLifetimesDefault() const { return m_cStructure->iLifetimesDefault; }
721
722 //----------------------------------------------------------------------------
723
724 /// @brief **optional**\n
725 /// Prevent duplicate episodes value definitions.
726 ///
727 /// Array containing the possible values for @ref PVRTimer::SetPreventDuplicateEpisodes().
728 ///
729 /// @note Must be filled if @ref PVRTimer::SetPreventDuplicateEpisodes() is not empty.
730 ///
731 /// @param[in] preventDuplicateEpisodes List of duplicate episodes values
732 /// @param[in] preventDuplicateEpisodesDefault [opt] The default value in list, can also be
733 /// set by @ref SetPreventDuplicateEpisodesDefault()
734 ///
735 /// --------------------------------------------------------------------------
736 ///
737 /// @copydetails cpp_kodi_addon_pvr_Defs_PVRTypeIntValue_Help
738 void SetPreventDuplicateEpisodes(
739 const std::vector<PVRTypeIntValue>& preventDuplicateEpisodes,
740 int preventDuplicateEpisodesDefault = -1)
741 {
742 m_cStructure->iPreventDuplicateEpisodesSize =
743 static_cast<unsigned int>(preventDuplicateEpisodes.size());
744 for (unsigned int i = 0; i < m_cStructure->iPreventDuplicateEpisodesSize &&
745 i < sizeof(m_cStructure->preventDuplicateEpisodes);
746 ++i)
747 {
748 m_cStructure->preventDuplicateEpisodes[i].iValue =
749 preventDuplicateEpisodes[i].GetCStructure()->iValue;
750 strncpy(m_cStructure->preventDuplicateEpisodes[i].strDescription,
751 preventDuplicateEpisodes[i].GetCStructure()->strDescription,
752 sizeof(m_cStructure->preventDuplicateEpisodes[i].strDescription) - 1);
753 }
754 if (preventDuplicateEpisodesDefault != -1)
755 m_cStructure->iPreventDuplicateEpisodesDefault = preventDuplicateEpisodesDefault;
756 }
757
758 /// @brief To get with @ref SetPreventDuplicateEpisodes changed values.
759 std::vector<PVRTypeIntValue> GetPreventDuplicateEpisodes() const
760 {
761 std::vector<PVRTypeIntValue> ret;
762 for (unsigned int i = 0; i < m_cStructure->iPreventDuplicateEpisodesSize; ++i)
763 ret.emplace_back(m_cStructure->preventDuplicateEpisodes[i].iValue,
764 m_cStructure->preventDuplicateEpisodes[i].strDescription);
765 return ret;
766 }
767
768 /// @brief **optional**\n
769 /// The default value for @ref PVRTimer::SetPreventDuplicateEpisodes().
770 ///
771 /// @note Must be filled if @ref SetPreventDuplicateEpisodes contain values and not
772 /// defined there on second function value.
773 void SetPreventDuplicateEpisodesDefault(int preventDuplicateEpisodesDefault)
774 {
775 m_cStructure->iPreventDuplicateEpisodesDefault = preventDuplicateEpisodesDefault;
776 }
777
778 /// @brief To get with @ref SetPreventDuplicateEpisodesDefault changed values.
779 int GetPreventDuplicateEpisodesDefault() const
780 {
781 return m_cStructure->iPreventDuplicateEpisodesDefault;
782 }
783
784 //----------------------------------------------------------------------------
785
786 /// @brief **optional**\n
787 /// Array containing the possible values of @ref PVRTimer::SetRecordingGroup()
788 ///
789 /// @param[in] recordingGroup List of recording group values
790 /// @param[in] recordingGroupDefault [opt] The default value in list, can also be
791 /// set by @ref SetRecordingGroupDefault()
792 ///
793 /// --------------------------------------------------------------------------
794 ///
795 /// @copydetails cpp_kodi_addon_pvr_Defs_PVRTypeIntValue_Help
796 void SetRecordingGroups(const std::vector<PVRTypeIntValue>& recordingGroup,
797 int recordingGroupDefault = -1)
798 {
799 m_cStructure->iRecordingGroupSize = static_cast<unsigned int>(recordingGroup.size());
800 for (unsigned int i = 0;
801 i < m_cStructure->iRecordingGroupSize && i < sizeof(m_cStructure->recordingGroup); ++i)
802 {
803 m_cStructure->recordingGroup[i].iValue = recordingGroup[i].GetCStructure()->iValue;
804 strncpy(m_cStructure->recordingGroup[i].strDescription,
805 recordingGroup[i].GetCStructure()->strDescription,
806 sizeof(m_cStructure->recordingGroup[i].strDescription) - 1);
807 }
808 if (recordingGroupDefault != -1)
809 m_cStructure->iRecordingGroupDefault = recordingGroupDefault;
810 }
811
812 /// @brief To get with @ref SetRecordingGroups changed values
813 std::vector<PVRTypeIntValue> GetRecordingGroups() const
814 {
815 std::vector<PVRTypeIntValue> ret;
816 for (unsigned int i = 0; i < m_cStructure->iRecordingGroupSize; ++i)
817 ret.emplace_back(m_cStructure->recordingGroup[i].iValue,
818 m_cStructure->recordingGroup[i].strDescription);
819 return ret;
820 }
821
822 /// @brief **optional**\n
823 /// The default value for @ref PVRTimer::SetRecordingGroup().
824 ///
825 /// @note Must be filled if @ref SetRecordingGroups contain values and not
826 /// defined there on second function value.
827 void SetRecordingGroupDefault(int recordingGroupDefault)
828 {
829 m_cStructure->iRecordingGroupDefault = recordingGroupDefault;
830 }
831
832 /// @brief To get with @ref SetRecordingGroupDefault changed values
833 int GetRecordingGroupDefault() const { return m_cStructure->iRecordingGroupDefault; }
834
835 //----------------------------------------------------------------------------
836
837 /// @brief **optional**\n
838 /// Array containing the possible values of @ref PVRTimer::SetMaxRecordings().
839 ///
840 /// @param[in] maxRecordings List of lifetimes values
841 /// @param[in] maxRecordingsDefault [opt] The default value in list, can also be
842 /// set by @ref SetMaxRecordingsDefault()
843 ///
844 /// --------------------------------------------------------------------------
845 ///
846 /// @copydetails cpp_kodi_addon_pvr_Defs_PVRTypeIntValue_Help
847 void SetMaxRecordings(const std::vector<PVRTypeIntValue>& maxRecordings,
848 int maxRecordingsDefault = -1)
849 {
850 m_cStructure->iMaxRecordingsSize = static_cast<unsigned int>(maxRecordings.size());
851 for (unsigned int i = 0;
852 i < m_cStructure->iMaxRecordingsSize && i < sizeof(m_cStructure->maxRecordings); ++i)
853 {
854 m_cStructure->maxRecordings[i].iValue = maxRecordings[i].GetCStructure()->iValue;
855 strncpy(m_cStructure->maxRecordings[i].strDescription,
856 maxRecordings[i].GetCStructure()->strDescription,
857 sizeof(m_cStructure->maxRecordings[i].strDescription) - 1);
858 }
859 if (maxRecordingsDefault != -1)
860 m_cStructure->iMaxRecordingsDefault = maxRecordingsDefault;
861 }
862
863 /// @brief To get with @ref SetMaxRecordings changed values
864 std::vector<PVRTypeIntValue> GetMaxRecordings() const
865 {
866 std::vector<PVRTypeIntValue> ret;
867 for (unsigned int i = 0; i < m_cStructure->iMaxRecordingsSize; ++i)
868 ret.emplace_back(m_cStructure->maxRecordings[i].iValue,
869 m_cStructure->maxRecordings[i].strDescription);
870 return ret;
871 }
872
873 /// @brief **optional**\n
874 /// The default value for @ref SetMaxRecordings().
875 ///
876 /// Can be set with here if on @ref SetMaxRecordings not given as second value.
877 void SetMaxRecordingsDefault(int maxRecordingsDefault)
878 {
879 m_cStructure->iMaxRecordingsDefault = maxRecordingsDefault;
880 }
881
882 /// @brief To get with @ref SetMaxRecordingsDefault changed values
883 int GetMaxRecordingsDefault() const { return m_cStructure->iMaxRecordingsDefault; }
884 ///@}
885
886private:
887 PVRTimerType(const PVR_TIMER_TYPE* type) : CStructHdl(type) {}
888 PVRTimerType(PVR_TIMER_TYPE* type) : CStructHdl(type) {}
889};
890///@}
891//------------------------------------------------------------------------------
892
893} /* namespace addon */
894} /* namespace kodi */
895
896#endif /* __cplusplus */
diff --git a/xbmc/addons/kodi-dev-kit/include/kodi/c-api/CMakeLists.txt b/xbmc/addons/kodi-dev-kit/include/kodi/c-api/CMakeLists.txt
new file mode 100644
index 0000000..091e0fe
--- /dev/null
+++ b/xbmc/addons/kodi-dev-kit/include/kodi/c-api/CMakeLists.txt
@@ -0,0 +1,13 @@
1set(HEADERS addon_base.h
2 audio_engine.h
3 filesystem.h
4 general.h
5 network.h)
6
7if(CORE_SYSTEM_NAME STREQUAL android)
8 list(APPEND SOURCES platform/android/system.h)
9endif()
10
11if(NOT ENABLE_STATIC_LIBS)
12 core_add_library(addons_kodi-dev-kit_include_kodi_c-api)
13endif()
diff --git a/xbmc/addons/kodi-dev-kit/include/kodi/c-api/addon-instance/CMakeLists.txt b/xbmc/addons/kodi-dev-kit/include/kodi/c-api/addon-instance/CMakeLists.txt
new file mode 100644
index 0000000..4edd034
--- /dev/null
+++ b/xbmc/addons/kodi-dev-kit/include/kodi/c-api/addon-instance/CMakeLists.txt
@@ -0,0 +1,13 @@
1set(HEADERS audio_decoder.h
2 audio_encoder.h
3 game.h
4 image_decoder.h
5 peripheral.h
6 pvr.h
7 screensaver.h
8 vfs.h
9 visualization.h)
10
11if(NOT ENABLE_STATIC_LIBS)
12 core_add_library(addons_kodi-dev-kit_include_kodi_c-api_addon-instance)
13endif()
diff --git a/xbmc/addons/kodi-dev-kit/include/kodi/c-api/addon-instance/audio_decoder.h b/xbmc/addons/kodi-dev-kit/include/kodi/c-api/addon-instance/audio_decoder.h
new file mode 100644
index 0000000..8b75ddb
--- /dev/null
+++ b/xbmc/addons/kodi-dev-kit/include/kodi/c-api/addon-instance/audio_decoder.h
@@ -0,0 +1,92 @@
1/*
2 * Copyright (C) 2005-2020 Team Kodi
3 * This file is part of Kodi - https://kodi.tv
4 *
5 * SPDX-License-Identifier: GPL-2.0-or-later
6 * See LICENSES/README.md for more information.
7 */
8
9#pragma once
10
11#ifndef C_API_ADDONINSTANCE_AUDIO_DECODER_H
12#define C_API_ADDONINSTANCE_AUDIO_DECODER_H
13
14#include "../addon_base.h"
15#include "../audio_engine.h"
16
17#define AUDIO_DECODER_LYRICS_SIZE 65535
18
19#ifdef __cplusplus
20extern "C"
21{
22#endif /* __cplusplus */
23
24 // WARNING About size use malloc/new!
25 struct AUDIO_DECODER_INFO_TAG
26 {
27 char title[ADDON_STANDARD_STRING_LENGTH_SMALL];
28 char artist[ADDON_STANDARD_STRING_LENGTH_SMALL];
29 char album[ADDON_STANDARD_STRING_LENGTH_SMALL];
30 char album_artist[ADDON_STANDARD_STRING_LENGTH_SMALL];
31 char media_type[ADDON_STANDARD_STRING_LENGTH_SMALL];
32 char genre[ADDON_STANDARD_STRING_LENGTH_SMALL];
33 int duration;
34 int track;
35 int disc;
36 char disc_subtitle[ADDON_STANDARD_STRING_LENGTH_SMALL];
37 int disc_total;
38 char release_date[ADDON_STANDARD_STRING_LENGTH_SMALL];
39 char lyrics[AUDIO_DECODER_LYRICS_SIZE];
40 int samplerate;
41 int channels;
42 int bitrate;
43 char comment[ADDON_STANDARD_STRING_LENGTH];
44 };
45
46 typedef struct AddonProps_AudioDecoder
47 {
48 int dummy;
49 } AddonProps_AudioDecoder;
50
51 typedef struct AddonToKodiFuncTable_AudioDecoder
52 {
53 KODI_HANDLE kodiInstance;
54 } AddonToKodiFuncTable_AudioDecoder;
55
56 struct AddonInstance_AudioDecoder;
57 typedef struct KodiToAddonFuncTable_AudioDecoder
58 {
59 KODI_HANDLE addonInstance;
60 bool(__cdecl* init)(const struct AddonInstance_AudioDecoder* instance,
61 const char* file,
62 unsigned int filecache,
63 int* channels,
64 int* samplerate,
65 int* bitspersample,
66 int64_t* totaltime,
67 int* bitrate,
68 enum AudioEngineDataFormat* format,
69 const enum AudioEngineChannel** info);
70 int(__cdecl* read_pcm)(const struct AddonInstance_AudioDecoder* instance,
71 uint8_t* buffer,
72 int size,
73 int* actualsize);
74 int64_t(__cdecl* seek)(const struct AddonInstance_AudioDecoder* instance, int64_t time);
75 bool(__cdecl* read_tag)(const struct AddonInstance_AudioDecoder* instance,
76 const char* file,
77 struct AUDIO_DECODER_INFO_TAG* tag);
78 int(__cdecl* track_count)(const struct AddonInstance_AudioDecoder* instance, const char* file);
79 } KodiToAddonFuncTable_AudioDecoder;
80
81 typedef struct AddonInstance_AudioDecoder
82 {
83 struct AddonProps_AudioDecoder* props;
84 struct AddonToKodiFuncTable_AudioDecoder* toKodi;
85 struct KodiToAddonFuncTable_AudioDecoder* toAddon;
86 } AddonInstance_AudioDecoder;
87
88#ifdef __cplusplus
89} /* extern "C" */
90#endif /* __cplusplus */
91
92#endif /* !C_API_ADDONINSTANCE_AUDIO_DECODER_H */
diff --git a/xbmc/addons/kodi-dev-kit/include/kodi/c-api/addon-instance/audio_encoder.h b/xbmc/addons/kodi-dev-kit/include/kodi/c-api/addon-instance/audio_encoder.h
new file mode 100644
index 0000000..6f24d1c
--- /dev/null
+++ b/xbmc/addons/kodi-dev-kit/include/kodi/c-api/addon-instance/audio_encoder.h
@@ -0,0 +1,67 @@
1/*
2 * Copyright (C) 2005-2018 Team Kodi
3 * This file is part of Kodi - https://kodi.tv
4 *
5 * SPDX-License-Identifier: GPL-2.0-or-later
6 * See LICENSES/README.md for more information.
7 */
8
9#pragma once
10
11#ifndef C_API_ADDONINSTANCE_AUDIO_ENCODER_H
12#define C_API_ADDONINSTANCE_AUDIO_ENCODER_H
13
14#include "../addon_base.h"
15
16#ifdef __cplusplus
17extern "C"
18{
19#endif /* __cplusplus */
20
21 typedef struct AddonProps_AudioEncoder
22 {
23 int dummy;
24 } AddonProps_AudioEncoder;
25
26 typedef struct AddonToKodiFuncTable_AudioEncoder
27 {
28 KODI_HANDLE kodiInstance;
29 int (*write)(KODI_HANDLE kodiInstance, const uint8_t* data, int len);
30 int64_t (*seek)(KODI_HANDLE kodiInstance, int64_t pos, int whence);
31 } AddonToKodiFuncTable_AudioEncoder;
32
33 struct AddonInstance_AudioEncoder;
34 typedef struct KodiToAddonFuncTable_AudioEncoder
35 {
36 KODI_HANDLE addonInstance;
37 bool(__cdecl* start)(const struct AddonInstance_AudioEncoder* instance,
38 int in_channels,
39 int in_rate,
40 int in_bits,
41 const char* title,
42 const char* artist,
43 const char* albumartist,
44 const char* album,
45 const char* year,
46 const char* track,
47 const char* genre,
48 const char* comment,
49 int track_length);
50 int(__cdecl* encode)(const struct AddonInstance_AudioEncoder* instance,
51 int num_bytes_read,
52 const uint8_t* pbt_stream);
53 bool(__cdecl* finish)(const struct AddonInstance_AudioEncoder* instance);
54 } KodiToAddonFuncTable_AudioEncoder;
55
56 typedef struct AddonInstance_AudioEncoder
57 {
58 struct AddonProps_AudioEncoder* props;
59 struct AddonToKodiFuncTable_AudioEncoder* toKodi;
60 struct KodiToAddonFuncTable_AudioEncoder* toAddon;
61 } AddonInstance_AudioEncoder;
62
63#ifdef __cplusplus
64} /* extern "C" */
65#endif /* __cplusplus */
66
67#endif /* !C_API_ADDONINSTANCE_AUDIO_ENCODER_H */
diff --git a/xbmc/addons/kodi-dev-kit/include/kodi/c-api/addon-instance/game.h b/xbmc/addons/kodi-dev-kit/include/kodi/c-api/addon-instance/game.h
new file mode 100644
index 0000000..c97fa5d
--- /dev/null
+++ b/xbmc/addons/kodi-dev-kit/include/kodi/c-api/addon-instance/game.h
@@ -0,0 +1,1212 @@
1/*
2 * Copyright (C) 2014-2020 Team Kodi
3 * This file is part of Kodi - https://kodi.tv
4 *
5 * SPDX-License-Identifier: GPL-2.0-or-later
6 * See LICENSES/README.md for more information.
7 */
8
9#pragma once
10
11#ifndef C_API_ADDONINSTANCE_GAME_H
12#define C_API_ADDONINSTANCE_GAME_H
13
14#include "../addon_base.h"
15
16#include <stddef.h> /* size_t */
17
18//==============================================================================
19/// @ingroup cpp_kodi_addon_game_Defs
20/// @brief **Port ID used when topology is unknown**
21#define DEFAULT_PORT_ID "1"
22//------------------------------------------------------------------------------
23
24#ifdef __cplusplus
25extern "C"
26{
27#endif /* __cplusplus */
28
29 //============================================================================
30 /// @ingroup cpp_kodi_addon_game_Defs
31 /// @brief **Game add-on error codes**
32 ///
33 /// Used as return values on most Game related functions.
34 ///
35 typedef enum GAME_ERROR
36 {
37 /// @brief no error occurred
38 GAME_ERROR_NO_ERROR,
39
40 /// @brief an unknown error occurred
41 GAME_ERROR_UNKNOWN,
42
43 /// @brief the method that the frontend called is not implemented
44 GAME_ERROR_NOT_IMPLEMENTED,
45
46 /// @brief the command was rejected by the game client
47 GAME_ERROR_REJECTED,
48
49 /// @brief the parameters of the method that was called are invalid for this operation
50 GAME_ERROR_INVALID_PARAMETERS,
51
52 /// @brief the command failed
53 GAME_ERROR_FAILED,
54
55 /// @brief no game is loaded
56 GAME_ERROR_NOT_LOADED,
57
58 /// @brief game requires restricted resources
59 GAME_ERROR_RESTRICTED,
60 } GAME_ERROR;
61 //----------------------------------------------------------------------------
62
63 //--==----==----==----==----==----==----==----==----==----==----==----==----==--
64 /// @defgroup cpp_kodi_addon_game_Defs_AudioStream 1. Audio stream
65 /// @ingroup cpp_kodi_addon_game_Defs
66 /// @brief **The for Audio stream used data system**
67 ///
68 /// Used to give Addon currently used audio stream configuration on Kodi and
69 /// arrays to give related data to Kodi on callbacks.
70 ///
71 ///@{
72
73 //============================================================================
74 /// @brief **Stream Format**
75 ///
76 /// From Kodi requested specified audio sample format.
77 ///
78 typedef enum GAME_PCM_FORMAT
79 {
80 GAME_PCM_FORMAT_UNKNOWN,
81
82 /// @brief S16NE sample format
83 GAME_PCM_FORMAT_S16NE,
84 } GAME_PCM_FORMAT;
85 //----------------------------------------------------------------------------
86
87 //============================================================================
88 /// @brief **Audio channel**
89 ///
90 /// Channel identification flags.
91 ///
92 typedef enum GAME_AUDIO_CHANNEL
93 {
94 /// @brief Channel list terminator
95 GAME_CH_NULL,
96
97 /// @brief Channel front left
98 GAME_CH_FL,
99
100 /// @brief Channel front right
101 GAME_CH_FR,
102
103 /// @brief Channel front center
104 GAME_CH_FC,
105
106 /// @brief Channel Low Frequency Effects / Subwoofer
107 GAME_CH_LFE,
108
109 /// @brief Channel back left
110 GAME_CH_BL,
111
112 /// @brief Channel back right
113 GAME_CH_BR,
114
115 /// @brief Channel front left over center
116 GAME_CH_FLOC,
117
118 /// @brief Channel front right over center
119 GAME_CH_FROC,
120
121 /// @brief Channel back center
122 GAME_CH_BC,
123
124 /// @brief Channel surround/side left
125 GAME_CH_SL,
126
127 /// @brief Channel surround/side right
128 GAME_CH_SR,
129
130 /// @brief Channel top front left
131 GAME_CH_TFL,
132
133 /// @brief Channel top front right
134 GAME_CH_TFR,
135
136 /// @brief Channel top front center
137 GAME_CH_TFC,
138
139 /// @brief Channel top center
140 GAME_CH_TC,
141
142 /// @brief Channel top back left
143 GAME_CH_TBL,
144
145 /// @brief Channel top back right
146 GAME_CH_TBR,
147
148 /// @brief Channel top back center
149 GAME_CH_TBC,
150
151 /// @brief Channel bacl left over center
152 GAME_CH_BLOC,
153
154 /// @brief Channel back right over center
155 GAME_CH_BROC,
156 } GAME_AUDIO_CHANNEL;
157 //----------------------------------------------------------------------------
158
159 //============================================================================
160 /// @brief **Game audio stream properties**
161 ///
162 /// Used by Kodi to pass the currently required audio stream settings to the addon
163 ///
164 typedef struct game_stream_audio_properties
165 {
166 GAME_PCM_FORMAT format;
167 const GAME_AUDIO_CHANNEL* channel_map;
168 } ATTRIBUTE_PACKED game_stream_audio_properties;
169 //----------------------------------------------------------------------------
170
171 //============================================================================
172 /// @brief **Audio stream packet**
173 ///
174 /// This packet contains audio stream data passed to Kodi.
175 ///
176 typedef struct game_stream_audio_packet
177 {
178 /// @brief Pointer for audio stream data given to Kodi
179 const uint8_t* data;
180
181 /// @brief Size of data array
182 size_t size;
183 } ATTRIBUTE_PACKED game_stream_audio_packet;
184 //----------------------------------------------------------------------------
185
186 ///@}
187
188 //--==----==----==----==----==----==----==----==----==----==----==----==----==--
189 /// @defgroup cpp_kodi_addon_game_Defs_VideoStream 2. Video stream
190 /// @ingroup cpp_kodi_addon_game_Defs
191 /// @brief **The for Video stream used data system**
192 ///
193 /// Used to give Addon currently used video stream configuration on Kodi and
194 /// arrays to give related data to Kodi on callbacks.
195 ///
196 ///@{
197
198 //============================================================================
199 /// @brief **Pixel format**
200 ///
201 /// From Kodi requested specified video RGB color model format.
202 ///
203 typedef enum GAME_PIXEL_FORMAT
204 {
205 GAME_PIXEL_FORMAT_UNKNOWN,
206
207 /// @brief 0RGB8888 Format
208 GAME_PIXEL_FORMAT_0RGB8888,
209
210 /// @brief RGB565 Format
211 GAME_PIXEL_FORMAT_RGB565,
212
213 /// @brief 0RGB1555 Format
214 GAME_PIXEL_FORMAT_0RGB1555,
215 } GAME_PIXEL_FORMAT;
216 //----------------------------------------------------------------------------
217
218 //============================================================================
219 /// @brief **Video rotation position**
220 ///
221 /// To define position how video becomes shown.
222 ///
223 typedef enum GAME_VIDEO_ROTATION
224 {
225 /// @brief 0° and Without rotation
226 GAME_VIDEO_ROTATION_0,
227
228 /// @brief rotate 90° counterclockwise
229 GAME_VIDEO_ROTATION_90_CCW,
230
231 /// @brief rotate 180° counterclockwise
232 GAME_VIDEO_ROTATION_180_CCW,
233
234 /// @brief rotate 270° counterclockwise
235 GAME_VIDEO_ROTATION_270_CCW,
236 } GAME_VIDEO_ROTATION;
237 //----------------------------------------------------------------------------
238
239 //============================================================================
240 /// @brief **Game video stream properties**
241 ///
242 /// Used by Kodi to pass the currently required video stream settings to the addon
243 ///
244 typedef struct game_stream_video_properties
245 {
246 /// @brief The to used pixel format
247 GAME_PIXEL_FORMAT format;
248
249 /// @brief The nominal used width
250 unsigned int nominal_width;
251
252 /// @brief The nominal used height
253 unsigned int nominal_height;
254
255 /// @brief The maximal used width
256 unsigned int max_width;
257
258 /// @brief The maximal used height
259 unsigned int max_height;
260
261 /// @brief On video stream used aspect ration
262 ///
263 /// @note If aspect_ratio is <= 0.0, an aspect ratio of nominal_width / nominal_height is assumed
264 float aspect_ratio;
265 } ATTRIBUTE_PACKED game_stream_video_properties;
266 //----------------------------------------------------------------------------
267
268 //============================================================================
269 /// @brief **Video stream packet**
270 ///
271 /// This packet contains video stream data passed to Kodi.
272 ///
273 typedef struct game_stream_video_packet
274 {
275 /// @brief Video height
276 unsigned int width;
277
278 /// @brief Video width
279 unsigned int height;
280
281 /// @brief Width @ref GAME_VIDEO_ROTATION defined rotation angle.
282 GAME_VIDEO_ROTATION rotation;
283
284 /// @brief Pointer for video stream data given to Kodi
285 const uint8_t* data;
286
287 /// @brief Size of data array
288 size_t size;
289 } ATTRIBUTE_PACKED game_stream_video_packet;
290 //----------------------------------------------------------------------------
291
292 ///@}
293
294 //--==----==----==----==----==----==----==----==----==----==----==----==----==--
295 /// @defgroup cpp_kodi_addon_game_Defs_HardwareFramebuffer 3. Hardware framebuffer stream
296 /// @ingroup cpp_kodi_addon_game_Defs
297 /// @brief **Hardware framebuffer stream data**
298 ///
299 ///@{
300
301 //============================================================================
302 /// @brief **Hardware framebuffer type**
303 ///
304 typedef enum GAME_HW_CONTEXT_TYPE
305 {
306 /// @brief None context
307 GAME_HW_CONTEXT_NONE,
308
309 /// @brief OpenGL 2.x. Driver can choose to use latest compatibility context
310 GAME_HW_CONTEXT_OPENGL,
311
312 /// @brief OpenGL ES 2.0
313 GAME_HW_CONTEXT_OPENGLES2,
314
315 /// @brief Modern desktop core GL context. Use major/minor fields to set GL version
316 GAME_HW_CONTEXT_OPENGL_CORE,
317
318 /// @brief OpenGL ES 3.0
319 GAME_HW_CONTEXT_OPENGLES3,
320
321 /// @brief OpenGL ES 3.1+. Set major/minor fields.
322 GAME_HW_CONTEXT_OPENGLES_VERSION,
323
324 /// @brief Vulkan
325 GAME_HW_CONTEXT_VULKAN
326 } GAME_HW_CONTEXT_TYPE;
327 //----------------------------------------------------------------------------
328
329 //============================================================================
330 /// @brief **Hardware framebuffer properties**
331 ///
332 typedef struct game_stream_hw_framebuffer_properties
333 {
334 /// @brief The API to use.
335 ///
336 GAME_HW_CONTEXT_TYPE context_type;
337
338 /// @brief Set if render buffers should have depth component attached.
339 ///
340 /// @todo: Obsolete
341 ///
342 bool depth;
343
344 /// @brief Set if stencil buffers should be attached.
345 ///
346 /// If depth and stencil are true, a packed 24/8 buffer will be added.
347 /// Only attaching stencil is invalid and will be ignored.
348 ///
349 /// @todo: Obsolete.
350 ///
351 bool stencil;
352
353 /// @brief Use conventional bottom-left origin convention.
354 ///
355 /// If false, standard top-left origin semantics are used.
356 ///
357 /// @todo: Move to GL specific interface
358 ///
359 bool bottom_left_origin;
360
361 /// @brief Major version number for core GL context or GLES 3.1+.
362 unsigned int version_major;
363
364 /// @brief Minor version number for core GL context or GLES 3.1+.
365 unsigned int version_minor;
366
367 /// @brief If this is true, the frontend will go very far to avoid resetting context
368 /// in scenarios like toggling fullscreen, etc.
369 ///
370 /// @todo: Obsolete? Maybe frontend should just always assume this...
371 ///
372 /// The reset callback might still be called in extreme situations such as if
373 /// the context is lost beyond recovery.
374 ///
375 /// For optimal stability, set this to false, and allow context to be reset at
376 /// any time.
377 ///
378 bool cache_context;
379
380 /// @brief Creates a debug context.
381 bool debug_context;
382 } ATTRIBUTE_PACKED game_stream_hw_framebuffer_properties;
383 //----------------------------------------------------------------------------
384
385 //============================================================================
386 /// @brief **Hardware framebuffer buffer**
387 ///
388 typedef struct game_stream_hw_framebuffer_buffer
389 {
390 /// @brief
391 uintptr_t framebuffer;
392 } ATTRIBUTE_PACKED game_stream_hw_framebuffer_buffer;
393 //----------------------------------------------------------------------------
394
395 //============================================================================
396 /// @brief **Hardware framebuffer packet**
397 ///
398 typedef struct game_stream_hw_framebuffer_packet
399 {
400 /// @brief
401 uintptr_t framebuffer;
402 } ATTRIBUTE_PACKED game_stream_hw_framebuffer_packet;
403 //----------------------------------------------------------------------------
404
405 //============================================================================
406 /// @brief **Hardware framebuffer process function address**
407 ///
408 typedef void (*game_proc_address_t)(void);
409 //----------------------------------------------------------------------------
410
411 ///@}
412
413 //--==----==----==----==----==----==----==----==----==----==----==----==----==--
414 /// @defgroup cpp_kodi_addon_game_Defs_SoftwareFramebuffer 4. Software framebuffer stream
415 /// @ingroup cpp_kodi_addon_game_Defs
416 /// @brief **Software framebuffer stream data**
417 ///
418 ///@{
419
420 //============================================================================
421 /// @brief **Game video stream properties**
422 ///
423 /// Used by Kodi to pass the currently required video stream settings to the addon
424 ///
425 typedef game_stream_video_properties game_stream_sw_framebuffer_properties;
426 //----------------------------------------------------------------------------
427
428 //============================================================================
429 /// @brief **Hardware framebuffer type**
430 ///
431 typedef struct game_stream_sw_framebuffer_buffer
432 {
433 GAME_PIXEL_FORMAT format;
434 uint8_t* data;
435 size_t size;
436 } ATTRIBUTE_PACKED game_stream_sw_framebuffer_buffer;
437 //----------------------------------------------------------------------------
438
439 //============================================================================
440 /// @brief **Video stream packet**
441 ///
442 /// This packet contains video stream data passed to Kodi.
443 ///
444 typedef game_stream_video_packet game_stream_sw_framebuffer_packet;
445 //----------------------------------------------------------------------------
446
447 ///@}
448
449 //--==----==----==----==----==----==----==----==----==----==----==----==----==--
450 /// @defgroup cpp_kodi_addon_game_Defs_StreamTypes 5. Stream types
451 /// @ingroup cpp_kodi_addon_game_Defs
452 /// @brief **Stream types data**
453 ///
454 ///@{
455
456 //============================================================================
457 /// @brief **Game stream types**
458 ///
459 typedef enum GAME_STREAM_TYPE
460 {
461 /// @brief Unknown
462 GAME_STREAM_UNKNOWN,
463
464 /// @brief Audio stream
465 GAME_STREAM_AUDIO,
466
467 /// @brief Video stream
468 GAME_STREAM_VIDEO,
469
470 /// @brief Hardware framebuffer
471 GAME_STREAM_HW_FRAMEBUFFER,
472
473 /// @brief Software framebuffer
474 GAME_STREAM_SW_FRAMEBUFFER,
475 } GAME_STREAM_TYPE;
476 //----------------------------------------------------------------------------
477
478 //============================================================================
479 /// @brief **Immutable stream metadata**
480 ///
481 /// This metadata is provided when the stream is opened. If any stream
482 /// properties change, a new stream must be opened.
483 ///
484 typedef struct game_stream_properties
485 {
486 /// @brief
487 GAME_STREAM_TYPE type;
488 union
489 {
490 /// @brief
491 game_stream_audio_properties audio;
492
493 /// @brief
494 game_stream_video_properties video;
495
496 /// @brief
497 game_stream_hw_framebuffer_properties hw_framebuffer;
498
499 /// @brief
500 game_stream_sw_framebuffer_properties sw_framebuffer;
501 };
502 } ATTRIBUTE_PACKED game_stream_properties;
503 //----------------------------------------------------------------------------
504
505 //============================================================================
506 /// @brief **Stream buffers for hardware rendering and zero-copy support**
507 ///
508 typedef struct game_stream_buffer
509 {
510 /// @brief
511 GAME_STREAM_TYPE type;
512 union
513 {
514 /// @brief
515 game_stream_hw_framebuffer_buffer hw_framebuffer;
516
517 /// @brief
518 game_stream_sw_framebuffer_buffer sw_framebuffer;
519 };
520 } ATTRIBUTE_PACKED game_stream_buffer;
521 //----------------------------------------------------------------------------
522
523 //============================================================================
524 /// @brief **Stream packet and ephemeral metadata**
525 ///
526 /// This packet contains stream data and accompanying metadata. The metadata
527 /// is ephemeral, meaning it only applies to the current packet and can change
528 /// from packet to packet in the same stream.
529 ///
530 typedef struct game_stream_packet
531 {
532 /// @brief
533 GAME_STREAM_TYPE type;
534 union
535 {
536 /// @brief
537 game_stream_audio_packet audio;
538
539 /// @brief
540 game_stream_video_packet video;
541
542 /// @brief
543 game_stream_hw_framebuffer_packet hw_framebuffer;
544
545 /// @brief
546 game_stream_sw_framebuffer_packet sw_framebuffer;
547 };
548 } ATTRIBUTE_PACKED game_stream_packet;
549 //----------------------------------------------------------------------------
550
551 ///@}
552
553 //--==----==----==----==----==----==----==----==----==----==----==----==----==--
554 /// @defgroup cpp_kodi_addon_game_Defs_GameTypes 6. Game types
555 /// @ingroup cpp_kodi_addon_game_Defs
556 /// @brief **Game types data**
557 ///
558 ///@{
559
560 //============================================================================
561 /// @brief **Game reguin definition**
562 ///
563 /// Returned from game_get_region()
564 typedef enum GAME_REGION
565 {
566 /// @brief Game region unknown
567 GAME_REGION_UNKNOWN,
568
569 /// @brief Game region NTSC
570 GAME_REGION_NTSC,
571
572 /// @brief Game region PAL
573 GAME_REGION_PAL,
574 } GAME_REGION;
575 //----------------------------------------------------------------------------
576
577 //============================================================================
578 /// @brief **Special game types passed into game_load_game_special().**
579 ///
580 /// @remark Only used when multiple ROMs are required.
581 ///
582 typedef enum SPECIAL_GAME_TYPE
583 {
584 /// @brief Game Type BSX
585 SPECIAL_GAME_TYPE_BSX,
586
587 /// @brief Game Type BSX slotted
588 SPECIAL_GAME_TYPE_BSX_SLOTTED,
589
590 /// @brief Game Type sufami turbo
591 SPECIAL_GAME_TYPE_SUFAMI_TURBO,
592
593 /// @brief Game Type super game boy
594 SPECIAL_GAME_TYPE_SUPER_GAME_BOY,
595 } SPECIAL_GAME_TYPE;
596 //----------------------------------------------------------------------------
597
598 //============================================================================
599 /// @brief **Game Memory**
600 ///
601 typedef enum GAME_MEMORY
602 {
603 /// @brief Passed to game_get_memory_data/size(). If the memory type doesn't apply
604 /// to the implementation NULL/0 can be returned.
605 GAME_MEMORY_MASK = 0xff,
606
607 /// @brief Regular save ram.
608 ///
609 /// This ram is usually found on a game cartridge, backed
610 /// up by a battery. If save game data is too complex for a single memory
611 /// buffer, the SYSTEM_DIRECTORY environment callback can be used.
612 GAME_MEMORY_SAVE_RAM = 0,
613
614 /// @brief Some games have a built-in clock to keep track of time.
615 ///
616 /// This memory is usually just a couple of bytes to keep track of time.
617 GAME_MEMORY_RTC = 1,
618
619 /// @brief System ram lets a frontend peek into a game systems main RAM
620 GAME_MEMORY_SYSTEM_RAM = 2,
621
622 /// @brief Video ram lets a frontend peek into a game systems video RAM (VRAM)
623 GAME_MEMORY_VIDEO_RAM = 3,
624
625 /// @brief Special memory type
626 GAME_MEMORY_SNES_BSX_RAM = ((1 << 8) | GAME_MEMORY_SAVE_RAM),
627
628 /// @brief Special memory type
629 GAME_MEMORY_SNES_BSX_PRAM = ((2 << 8) | GAME_MEMORY_SAVE_RAM),
630
631 /// @brief Special memory type
632 GAME_MEMORY_SNES_SUFAMI_TURBO_A_RAM = ((3 << 8) | GAME_MEMORY_SAVE_RAM),
633
634 /// @brief Special memory type
635 GAME_MEMORY_SNES_SUFAMI_TURBO_B_RAM = ((4 << 8) | GAME_MEMORY_SAVE_RAM),
636
637 /// @brief Special memory type
638 GAME_MEMORY_SNES_GAME_BOY_RAM = ((5 << 8) | GAME_MEMORY_SAVE_RAM),
639
640 /// @brief Special memory type
641 GAME_MEMORY_SNES_GAME_BOY_RTC = ((6 << 8) | GAME_MEMORY_RTC),
642 } GAME_MEMORY;
643 //----------------------------------------------------------------------------
644
645 //============================================================================
646 /// @brief **ID values for SIMD CPU features**
647 typedef enum GAME_SIMD
648 {
649 /// @brief SIMD CPU SSE
650 GAME_SIMD_SSE = (1 << 0),
651
652 /// @brief SIMD CPU SSE2
653 GAME_SIMD_SSE2 = (1 << 1),
654
655 /// @brief SIMD CPU VMX
656 GAME_SIMD_VMX = (1 << 2),
657
658 /// @brief SIMD CPU VMX128
659 GAME_SIMD_VMX128 = (1 << 3),
660
661 /// @brief SIMD CPU AVX
662 GAME_SIMD_AVX = (1 << 4),
663
664 /// @brief SIMD CPU NEON
665 GAME_SIMD_NEON = (1 << 5),
666
667 /// @brief SIMD CPU SSE3
668 GAME_SIMD_SSE3 = (1 << 6),
669
670 /// @brief SIMD CPU SSSE3
671 GAME_SIMD_SSSE3 = (1 << 7),
672
673 /// @brief SIMD CPU MMX
674 GAME_SIMD_MMX = (1 << 8),
675
676 /// @brief SIMD CPU MMXEXT
677 GAME_SIMD_MMXEXT = (1 << 9),
678
679 /// @brief SIMD CPU SSE4
680 GAME_SIMD_SSE4 = (1 << 10),
681
682 /// @brief SIMD CPU SSE42
683 GAME_SIMD_SSE42 = (1 << 11),
684
685 /// @brief SIMD CPU AVX2
686 GAME_SIMD_AVX2 = (1 << 12),
687
688 /// @brief SIMD CPU VFPU
689 GAME_SIMD_VFPU = (1 << 13),
690 } GAME_SIMD;
691 //----------------------------------------------------------------------------
692
693 ///@}
694
695 //--==----==----==----==----==----==----==----==----==----==----==----==----==--
696 /// @defgroup cpp_kodi_addon_game_Defs_InputTypes 7. Input types
697 /// @ingroup cpp_kodi_addon_game_Defs
698 /// @brief **Input types**
699 ///
700 ///@{
701
702 //============================================================================
703 /// @brief
704 typedef enum GAME_INPUT_EVENT_SOURCE
705 {
706 /// @brief
707 GAME_INPUT_EVENT_DIGITAL_BUTTON,
708
709 /// @brief
710 GAME_INPUT_EVENT_ANALOG_BUTTON,
711
712 /// @brief
713 GAME_INPUT_EVENT_AXIS,
714
715 /// @brief
716 GAME_INPUT_EVENT_ANALOG_STICK,
717
718 /// @brief
719 GAME_INPUT_EVENT_ACCELEROMETER,
720
721 /// @brief
722 GAME_INPUT_EVENT_KEY,
723
724 /// @brief
725 GAME_INPUT_EVENT_RELATIVE_POINTER,
726
727 /// @brief
728 GAME_INPUT_EVENT_ABSOLUTE_POINTER,
729
730 /// @brief
731 GAME_INPUT_EVENT_MOTOR,
732 } GAME_INPUT_EVENT_SOURCE;
733 //----------------------------------------------------------------------------
734
735 //============================================================================
736 /// @brief
737 typedef enum GAME_KEY_MOD
738 {
739 /// @brief
740 GAME_KEY_MOD_NONE = 0x0000,
741
742 /// @brief
743 GAME_KEY_MOD_SHIFT = 0x0001,
744
745 /// @brief
746 GAME_KEY_MOD_CTRL = 0x0002,
747
748 /// @brief
749 GAME_KEY_MOD_ALT = 0x0004,
750
751 /// @brief
752 GAME_KEY_MOD_META = 0x0008,
753
754 /// @brief
755 GAME_KEY_MOD_SUPER = 0x0010,
756
757 /// @brief
758 GAME_KEY_MOD_NUMLOCK = 0x0100,
759
760 /// @brief
761 GAME_KEY_MOD_CAPSLOCK = 0x0200,
762
763 /// @brief
764 GAME_KEY_MOD_SCROLLOCK = 0x0400,
765 } GAME_KEY_MOD;
766 //----------------------------------------------------------------------------
767
768 //============================================================================
769 /// @brief Type of port on the virtual game console
770 typedef enum GAME_PORT_TYPE
771 {
772 /// @brief Game port unknown
773 GAME_PORT_UNKNOWN,
774
775 /// @brief Game port Keyboard
776 GAME_PORT_KEYBOARD,
777
778 /// @brief Game port mouse
779 GAME_PORT_MOUSE,
780
781 /// @brief Game port controller
782 GAME_PORT_CONTROLLER,
783 } GAME_PORT_TYPE;
784 //----------------------------------------------------------------------------
785
786 /*! @cond PRIVATE */
787 /*!
788 * @brief "C" Game add-on controller layout.
789 *
790 * Structure used to interface in "C" between Kodi and Addon.
791 *
792 * See @ref AddonGameControllerLayout for description of values.
793 */
794 typedef struct game_controller_layout
795 {
796 char* controller_id;
797 bool provides_input; // False for multitaps
798 char** digital_buttons;
799 unsigned int digital_button_count;
800 char** analog_buttons;
801 unsigned int analog_button_count;
802 char** analog_sticks;
803 unsigned int analog_stick_count;
804 char** accelerometers;
805 unsigned int accelerometer_count;
806 char** keys;
807 unsigned int key_count;
808 char** rel_pointers;
809 unsigned int rel_pointer_count;
810 char** abs_pointers;
811 unsigned int abs_pointer_count;
812 char** motors;
813 unsigned int motor_count;
814 } ATTRIBUTE_PACKED game_controller_layout;
815 /*! @endcond */
816
817 struct game_input_port;
818
819 //============================================================================
820 /// @brief Device that can provide input
821 typedef struct game_input_device
822 {
823 /// @brief ID used in the Kodi controller API
824 const char* controller_id;
825
826 /// @brief
827 const char* port_address;
828
829 /// @brief
830 struct game_input_port* available_ports;
831
832 /// @brief
833 unsigned int port_count;
834 } ATTRIBUTE_PACKED game_input_device;
835 //----------------------------------------------------------------------------
836
837 //============================================================================
838 /// @brief Port that can provide input
839 ///
840 /// Ports can accept multiple devices and devices can have multiple ports, so
841 /// the topology of possible configurations is a tree structure of alternating
842 /// port and device nodes.
843 ///
844 typedef struct game_input_port
845 {
846 /// @brief
847 GAME_PORT_TYPE type;
848
849 /// @brief Required for GAME_PORT_CONTROLLER type
850 const char* port_id;
851
852 /// @brief
853 game_input_device* accepted_devices;
854
855 /// @brief
856 unsigned int device_count;
857 } ATTRIBUTE_PACKED game_input_port;
858 //----------------------------------------------------------------------------
859
860 //============================================================================
861 /// @brief The input topology is the possible ways to connect input devices
862 ///
863 /// This represents the logical topology, which is the possible connections that
864 /// the game client's logic can handle. It is strictly a subset of the physical
865 /// topology. Loops are not allowed.
866 ///
867 typedef struct game_input_topology
868 {
869 /// @brief The list of ports on the virtual game console
870 game_input_port* ports;
871
872 /// @brief The number of ports
873 unsigned int port_count;
874
875 /// @brief A limit on the number of input-providing devices, or -1 for no limit
876 int player_limit;
877 } ATTRIBUTE_PACKED game_input_topology;
878 //----------------------------------------------------------------------------
879
880 //============================================================================
881 /// @brief
882 typedef struct game_digital_button_event
883 {
884 /// @brief
885 bool pressed;
886 } ATTRIBUTE_PACKED game_digital_button_event;
887 //----------------------------------------------------------------------------
888
889 //============================================================================
890 /// @brief
891 typedef struct game_analog_button_event
892 {
893 /// @brief
894 float magnitude;
895 } ATTRIBUTE_PACKED game_analog_button_event;
896 //----------------------------------------------------------------------------
897
898 //============================================================================
899 /// @brief
900 typedef struct game_axis_event
901 {
902 /// @brief
903 float position;
904 } ATTRIBUTE_PACKED game_axis_event;
905 //----------------------------------------------------------------------------
906
907 //============================================================================
908 /// @brief
909 typedef struct game_analog_stick_event
910 {
911 /// @brief
912 float x;
913
914 /// @brief
915 float y;
916 } ATTRIBUTE_PACKED game_analog_stick_event;
917 //----------------------------------------------------------------------------
918
919 //============================================================================
920 /// @brief
921 typedef struct game_accelerometer_event
922 {
923 /// @brief
924 float x;
925
926 /// @brief
927 float y;
928
929 /// @brief
930 float z;
931 } ATTRIBUTE_PACKED game_accelerometer_event;
932 //----------------------------------------------------------------------------
933
934 //============================================================================
935 /// @brief
936 typedef struct game_key_event
937 {
938 /// @brief
939 bool pressed;
940
941 /// @brief If the keypress generates a printing character
942 ///
943 /// The unicode value contains the character generated. If the key is a
944 /// non-printing character, e.g. a function or arrow key, the unicode value
945 /// is zero.
946 uint32_t unicode;
947
948 /// @brief
949 GAME_KEY_MOD modifiers;
950 } ATTRIBUTE_PACKED game_key_event;
951 //----------------------------------------------------------------------------
952
953 //============================================================================
954 /// @brief
955 typedef struct game_rel_pointer_event
956 {
957 /// @brief
958 int x;
959
960 /// @brief
961 int y;
962 } ATTRIBUTE_PACKED game_rel_pointer_event;
963 //----------------------------------------------------------------------------
964
965 //============================================================================
966 /// @brief
967 typedef struct game_abs_pointer_event
968 {
969 /// @brief
970 bool pressed;
971
972 /// @brief
973 float x;
974
975 /// @brief
976 float y;
977 } ATTRIBUTE_PACKED game_abs_pointer_event;
978 //----------------------------------------------------------------------------
979
980 //============================================================================
981 /// @brief
982 typedef struct game_motor_event
983 {
984 /// @brief
985 float magnitude;
986 } ATTRIBUTE_PACKED game_motor_event;
987 //----------------------------------------------------------------------------
988
989 //============================================================================
990 /// @brief
991 typedef struct game_input_event
992 {
993 /// @brief
994 GAME_INPUT_EVENT_SOURCE type;
995
996 /// @brief
997 const char* controller_id;
998
999 /// @brief
1000 GAME_PORT_TYPE port_type;
1001
1002 /// @brief
1003 const char* port_address;
1004
1005 /// @brief
1006 const char* feature_name;
1007 union
1008 {
1009 /// @brief
1010 struct game_digital_button_event digital_button;
1011
1012 /// @brief
1013 struct game_analog_button_event analog_button;
1014
1015 /// @brief
1016 struct game_axis_event axis;
1017
1018 /// @brief
1019 struct game_analog_stick_event analog_stick;
1020
1021 /// @brief
1022 struct game_accelerometer_event accelerometer;
1023
1024 /// @brief
1025 struct game_key_event key;
1026
1027 /// @brief
1028 struct game_rel_pointer_event rel_pointer;
1029
1030 /// @brief
1031 struct game_abs_pointer_event abs_pointer;
1032
1033 /// @brief
1034 struct game_motor_event motor;
1035 };
1036 } ATTRIBUTE_PACKED game_input_event;
1037 //----------------------------------------------------------------------------
1038
1039 ///@}
1040
1041 //--==----==----==----==----==----==----==----==----==----==----==----==----==--
1042 /// @defgroup cpp_kodi_addon_game_Defs_EnvironmentTypes 8. Environment types
1043 /// @ingroup cpp_kodi_addon_game_Defs
1044 /// @brief **Environment types**
1045 ///
1046 ///@{
1047
1048 //============================================================================
1049 /// @brief Game system timing
1050 ///
1051 struct game_system_timing
1052 {
1053 /// @brief FPS of video content.
1054 double fps;
1055
1056 /// @brief Sampling rate of audio.
1057 double sample_rate;
1058 };
1059 //----------------------------------------------------------------------------
1060
1061 ///@}
1062
1063
1064 //--==----==----==----==----==----==----==----==----==----==----==----==----==--
1065
1066 /*!
1067 * @brief Game properties
1068 *
1069 * Not to be used outside this header.
1070 */
1071 typedef struct AddonProps_Game
1072 {
1073 /*!
1074 * The path of the game client being loaded.
1075 */
1076 const char* game_client_dll_path;
1077
1078 /*!
1079 * Paths to proxy DLLs used to load the game client.
1080 */
1081 const char** proxy_dll_paths;
1082
1083 /*!
1084 * Number of proxy DLL paths provided.
1085 */
1086 unsigned int proxy_dll_count;
1087
1088 /*!
1089 * The "system" directories of the frontend. These directories can be used to
1090 * store system-specific ROMs such as BIOSes, configuration data, etc.
1091 */
1092 const char** resource_directories;
1093
1094 /*!
1095 * Number of resource directories provided
1096 */
1097 unsigned int resource_directory_count;
1098
1099 /*!
1100 * The writable directory of the frontend. This directory can be used to store
1101 * SRAM, memory cards, high scores, etc, if the game client cannot use the
1102 * regular memory interface, GetMemoryData().
1103 */
1104 const char* profile_directory;
1105
1106 /*!
1107 * The value of the <supports_vfs> property from addon.xml
1108 */
1109 bool supports_vfs;
1110
1111 /*!
1112 * The extensions in the <extensions> property from addon.xml
1113 */
1114 const char** extensions;
1115
1116 /*!
1117 * Number of extensions provided
1118 */
1119 unsigned int extension_count;
1120 } AddonProps_Game;
1121
1122 typedef void* KODI_GAME_STREAM_HANDLE;
1123
1124 /*! Structure to transfer the methods from kodi_game_dll.h to Kodi */
1125
1126 struct AddonInstance_Game;
1127
1128 /*!
1129 * @brief Game callbacks
1130 *
1131 * Not to be used outside this header.
1132 */
1133 typedef struct AddonToKodiFuncTable_Game
1134 {
1135 KODI_HANDLE kodiInstance;
1136
1137 void (*CloseGame)(KODI_HANDLE kodiInstance);
1138 KODI_GAME_STREAM_HANDLE (*OpenStream)(KODI_HANDLE, const struct game_stream_properties*);
1139 bool (*GetStreamBuffer)(KODI_HANDLE,
1140 KODI_GAME_STREAM_HANDLE,
1141 unsigned int,
1142 unsigned int,
1143 struct game_stream_buffer*);
1144 void (*AddStreamData)(KODI_HANDLE, KODI_GAME_STREAM_HANDLE, const struct game_stream_packet*);
1145 void (*ReleaseStreamBuffer)(KODI_HANDLE, KODI_GAME_STREAM_HANDLE, struct game_stream_buffer*);
1146 void (*CloseStream)(KODI_HANDLE, KODI_GAME_STREAM_HANDLE);
1147 game_proc_address_t (*HwGetProcAddress)(KODI_HANDLE kodiInstance, const char* symbol);
1148 bool (*InputEvent)(KODI_HANDLE kodiInstance, const struct game_input_event* event);
1149 } AddonToKodiFuncTable_Game;
1150
1151 /*!
1152 * @brief Game function hooks
1153 *
1154 * Not to be used outside this header.
1155 */
1156 typedef struct KodiToAddonFuncTable_Game
1157 {
1158 KODI_HANDLE addonInstance;
1159
1160 GAME_ERROR(__cdecl* LoadGame)(const struct AddonInstance_Game*, const char*);
1161 GAME_ERROR(__cdecl* LoadGameSpecial)
1162 (const struct AddonInstance_Game*, enum SPECIAL_GAME_TYPE, const char**, size_t);
1163 GAME_ERROR(__cdecl* LoadStandalone)(const struct AddonInstance_Game*);
1164 GAME_ERROR(__cdecl* UnloadGame)(const struct AddonInstance_Game*);
1165 GAME_ERROR(__cdecl* GetGameTiming)
1166 (const struct AddonInstance_Game*, struct game_system_timing*);
1167 GAME_REGION(__cdecl* GetRegion)(const struct AddonInstance_Game*);
1168 bool(__cdecl* RequiresGameLoop)(const struct AddonInstance_Game*);
1169 GAME_ERROR(__cdecl* RunFrame)(const struct AddonInstance_Game*);
1170 GAME_ERROR(__cdecl* Reset)(const struct AddonInstance_Game*);
1171 GAME_ERROR(__cdecl* HwContextReset)(const struct AddonInstance_Game*);
1172 GAME_ERROR(__cdecl* HwContextDestroy)(const struct AddonInstance_Game*);
1173 bool(__cdecl* HasFeature)(const struct AddonInstance_Game*, const char*, const char*);
1174 game_input_topology*(__cdecl* GetTopology)(const struct AddonInstance_Game*);
1175 void(__cdecl* FreeTopology)(const struct AddonInstance_Game*, struct game_input_topology*);
1176 void(__cdecl* SetControllerLayouts)(const struct AddonInstance_Game*,
1177 const struct game_controller_layout*,
1178 unsigned int);
1179 bool(__cdecl* EnableKeyboard)(const struct AddonInstance_Game*, bool, const char*);
1180 bool(__cdecl* EnableMouse)(const struct AddonInstance_Game*, bool, const char*);
1181 bool(__cdecl* ConnectController)(const struct AddonInstance_Game*,
1182 bool,
1183 const char*,
1184 const char*);
1185 bool(__cdecl* InputEvent)(const struct AddonInstance_Game*, const struct game_input_event*);
1186 size_t(__cdecl* SerializeSize)(const struct AddonInstance_Game*);
1187 GAME_ERROR(__cdecl* Serialize)(const struct AddonInstance_Game*, uint8_t*, size_t);
1188 GAME_ERROR(__cdecl* Deserialize)(const struct AddonInstance_Game*, const uint8_t*, size_t);
1189 GAME_ERROR(__cdecl* CheatReset)(const struct AddonInstance_Game*);
1190 GAME_ERROR(__cdecl* GetMemory)
1191 (const struct AddonInstance_Game*, enum GAME_MEMORY, uint8_t**, size_t*);
1192 GAME_ERROR(__cdecl* SetCheat)
1193 (const struct AddonInstance_Game*, unsigned int, bool, const char*);
1194 } KodiToAddonFuncTable_Game;
1195
1196 /*!
1197 * @brief Game instance
1198 *
1199 * Not to be used outside this header.
1200 */
1201 typedef struct AddonInstance_Game
1202 {
1203 struct AddonProps_Game* props;
1204 struct AddonToKodiFuncTable_Game* toKodi;
1205 struct KodiToAddonFuncTable_Game* toAddon;
1206 } AddonInstance_Game;
1207
1208#ifdef __cplusplus
1209}
1210#endif /* __cplusplus */
1211
1212#endif /* !C_API_ADDONINSTANCE_GAME_H */
diff --git a/xbmc/addons/kodi-dev-kit/include/kodi/c-api/addon-instance/image_decoder.h b/xbmc/addons/kodi-dev-kit/include/kodi/c-api/addon-instance/image_decoder.h
new file mode 100644
index 0000000..6455b38
--- /dev/null
+++ b/xbmc/addons/kodi-dev-kit/include/kodi/c-api/addon-instance/image_decoder.h
@@ -0,0 +1,83 @@
1/*
2 * Copyright (C) 2005-2018 Team Kodi
3 * This file is part of Kodi - https://kodi.tv
4 *
5 * SPDX-License-Identifier: GPL-2.0-or-later
6 * See LICENSES/README.md for more information.
7 */
8
9#pragma once
10
11#ifndef C_API_ADDONINSTANCE_IMAGE_DECODER_H
12#define C_API_ADDONINSTANCE_IMAGE_DECODER_H
13
14#include "../addon_base.h"
15
16#ifdef __cplusplus
17extern "C"
18{
19#endif /* __cplusplus */
20
21 //============================================================================
22 /// @ingroup cpp_kodi_addon_imagedecoder_Defs
23 /// @brief **Image format types**\n
24 /// Used to define wanted target format where image decoder should give to
25 /// Kodi.
26 ///
27 typedef enum ImageFormat
28 {
29 /// @brief A 32-bit ARGB pixel format, with alpha, that uses 8 bits per
30 /// channel, ARGBARGB...
31 ADDON_IMG_FMT_A8R8G8B8 = 1,
32
33 /// @brief A 8, alpha only, 8bpp, AAA...
34 ADDON_IMG_FMT_A8 = 2,
35
36 /// @brief RGBA 8:8:8:8, with alpha, 32bpp, RGBARGBA...
37 ADDON_IMG_FMT_RGBA8 = 3,
38
39 /// @brief RGB 8:8:8, with alpha, 24bpp, RGBRGB...
40 ADDON_IMG_FMT_RGB8 = 4
41 } ImageFormat;
42 //----------------------------------------------------------------------------
43
44 typedef struct AddonProps_ImageDecoder
45 {
46 const char* mimetype;
47 } AddonProps_ImageDecoder;
48
49 typedef struct AddonToKodiFuncTable_ImageDecoder
50 {
51 KODI_HANDLE kodi_instance;
52 } AddonToKodiFuncTable_ImageDecoder;
53
54 struct AddonInstance_ImageDecoder;
55 typedef struct KodiToAddonFuncTable_ImageDecoder
56 {
57 KODI_HANDLE addonInstance;
58 bool(__cdecl* load_image_from_memory)(const struct AddonInstance_ImageDecoder* instance,
59 unsigned char* buffer,
60 unsigned int buf_size,
61 unsigned int* width,
62 unsigned int* height);
63
64 bool(__cdecl* decode)(const struct AddonInstance_ImageDecoder* instance,
65 unsigned char* pixels,
66 unsigned int width,
67 unsigned int height,
68 unsigned int pitch,
69 enum ImageFormat format);
70 } KodiToAddonFuncTable_ImageDecoder;
71
72 typedef struct AddonInstance_ImageDecoder
73 {
74 struct AddonProps_ImageDecoder* props;
75 struct AddonToKodiFuncTable_ImageDecoder* toKodi;
76 struct KodiToAddonFuncTable_ImageDecoder* toAddon;
77 } AddonInstance_ImageDecoder;
78
79#ifdef __cplusplus
80} /* extern "C" */
81#endif /* __cplusplus */
82
83#endif /* !C_API_ADDONINSTANCE_IMAGE_DECODER_H */
diff --git a/xbmc/addons/kodi-dev-kit/include/kodi/c-api/addon-instance/peripheral.h b/xbmc/addons/kodi-dev-kit/include/kodi/c-api/addon-instance/peripheral.h
new file mode 100644
index 0000000..393f34a
--- /dev/null
+++ b/xbmc/addons/kodi-dev-kit/include/kodi/c-api/addon-instance/peripheral.h
@@ -0,0 +1,709 @@
1/*
2 * Copyright (C) 2014-2018 Team Kodi
3 * This file is part of Kodi - https://kodi.tv
4 *
5 * SPDX-License-Identifier: GPL-2.0-or-later
6 * See LICENSES/README.md for more information.
7 */
8
9#pragma once
10
11#ifndef C_API_ADDONINSTANCE_PERIPHERAL_H
12#define C_API_ADDONINSTANCE_PERIPHERAL_H
13
14#include "../addon_base.h"
15
16/* indicates a joystick has no preference for port number */
17#define NO_PORT_REQUESTED (-1)
18
19/* joystick's driver button/hat/axis index is unknown */
20#define DRIVER_INDEX_UNKNOWN (-1)
21
22#ifdef __cplusplus
23extern "C"
24{
25#endif /* __cplusplus */
26
27 //============================================================================
28 /// @defgroup cpp_kodi_addon_peripheral_Defs_General_PERIPHERAL_ERROR enum PERIPHERAL_ERROR
29 /// @ingroup cpp_kodi_addon_peripheral_Defs_General
30 /// @brief **Peripheral add-on error codes**\n
31 /// Used as return values on most peripheral related functions.
32 ///
33 /// In this way, a peripheral instance signals errors in its processing and,
34 /// under certain conditions, allows Kodi to make corrections.
35 ///
36 ///@{
37 typedef enum PERIPHERAL_ERROR
38 {
39 /// @brief __0__ : No error occurred
40 PERIPHERAL_NO_ERROR = 0,
41
42 /// @brief __-1__ : An unknown error occurred
43 PERIPHERAL_ERROR_UNKNOWN = -1,
44
45 /// @brief __-2__ : The command failed
46 PERIPHERAL_ERROR_FAILED = -2,
47
48 /// @brief __-3__ : The parameters of the method are invalid for this operation
49 PERIPHERAL_ERROR_INVALID_PARAMETERS = -3,
50
51 /// @brief __-4__ : The method that the frontend called is not implemented
52 PERIPHERAL_ERROR_NOT_IMPLEMENTED = -4,
53
54 /// @brief __-5__ : No peripherals are connected
55 PERIPHERAL_ERROR_NOT_CONNECTED = -5,
56
57 /// @brief __-6__ : Peripherals are connected, but command was interrupted
58 PERIPHERAL_ERROR_CONNECTION_FAILED = -6,
59 } PERIPHERAL_ERROR;
60 ///@}
61 //----------------------------------------------------------------------------
62
63 // @name Peripheral types
64 //{
65
66 //============================================================================
67 /// @defgroup cpp_kodi_addon_peripheral_Defs_Peripheral_PERIPHERAL_TYPE enum PERIPHERAL_TYPE
68 /// @ingroup cpp_kodi_addon_peripheral_Defs_Peripheral
69 /// @brief **Peripheral types**\n
70 /// Types used to identify wanted peripheral.
71 ///@{
72 typedef enum PERIPHERAL_TYPE
73 {
74 /// @brief Type declared as unknown.
75 PERIPHERAL_TYPE_UNKNOWN,
76
77 /// @brief Type declared as joystick.
78 PERIPHERAL_TYPE_JOYSTICK,
79
80 /// @brief Type declared as keyboard.
81 PERIPHERAL_TYPE_KEYBOARD,
82 } PERIPHERAL_TYPE;
83 ///@}
84 //----------------------------------------------------------------------------
85
86 /*!
87 * @brief Information shared between peripherals
88 */
89 typedef struct PERIPHERAL_INFO
90 {
91 PERIPHERAL_TYPE type; /*!< type of peripheral */
92 char* name; /*!< name of peripheral */
93 uint16_t vendor_id; /*!< vendor ID of peripheral, 0x0000 if unknown */
94 uint16_t product_id; /*!< product ID of peripheral, 0x0000 if unknown */
95 unsigned int index; /*!< the order in which the add-on identified this peripheral */
96 } ATTRIBUTE_PACKED PERIPHERAL_INFO;
97
98 /*!
99 * @brief Peripheral add-on capabilities.
100 */
101 typedef struct PERIPHERAL_CAPABILITIES
102 {
103 bool provides_joysticks; /*!< true if the add-on provides joysticks */
104 bool provides_joystick_rumble;
105 bool provides_joystick_power_off;
106 bool provides_buttonmaps; /*!< true if the add-on provides button maps */
107 } ATTRIBUTE_PACKED PERIPHERAL_CAPABILITIES;
108
109 //}
110
111 // @name Event types
112 //{
113
114 //============================================================================
115 /// @defgroup cpp_kodi_addon_peripheral_Defs_Event_PERIPHERAL_EVENT_TYPE enum PERIPHERAL_EVENT_TYPE
116 /// @ingroup cpp_kodi_addon_peripheral_Defs_Event
117 /// @brief **Event types**\n
118 /// Types of events that can be sent and received.
119 ///@{
120 typedef enum PERIPHERAL_EVENT_TYPE
121 {
122 /// @brief unknown event
123 PERIPHERAL_EVENT_TYPE_NONE,
124
125 /// @brief state changed for joystick driver button
126 PERIPHERAL_EVENT_TYPE_DRIVER_BUTTON,
127
128 /// @brief state changed for joystick driver hat
129 PERIPHERAL_EVENT_TYPE_DRIVER_HAT,
130
131 /// @brief state changed for joystick driver axis
132 PERIPHERAL_EVENT_TYPE_DRIVER_AXIS,
133
134 /// @brief set the state for joystick rumble motor
135 PERIPHERAL_EVENT_TYPE_SET_MOTOR,
136 } PERIPHERAL_EVENT_TYPE;
137 ///@}
138 //----------------------------------------------------------------------------
139
140 //============================================================================
141 /// @defgroup cpp_kodi_addon_peripheral_Defs_Event_JOYSTICK_STATE_BUTTON enum JOYSTICK_STATE_BUTTON
142 /// @ingroup cpp_kodi_addon_peripheral_Defs_Event
143 /// @brief **State button**\n
144 /// States a button can have
145 ///@{
146 typedef enum JOYSTICK_STATE_BUTTON
147 {
148 /// @brief button is released
149 JOYSTICK_STATE_BUTTON_UNPRESSED = 0x0,
150
151 /// @brief button is pressed
152 JOYSTICK_STATE_BUTTON_PRESSED = 0x1,
153 } JOYSTICK_STATE_BUTTON;
154 ///@}
155 //----------------------------------------------------------------------------
156
157 //============================================================================
158 /// @defgroup cpp_kodi_addon_peripheral_Defs_Event_JOYSTICK_STATE_HAT enum JOYSTICK_STATE_HAT
159 /// @ingroup cpp_kodi_addon_peripheral_Defs_Event
160 /// @brief **State hat**\n
161 /// States a D-pad (also called a hat) can have
162 ///@{
163 typedef enum JOYSTICK_STATE_HAT
164 {
165 /// @brief no directions are pressed
166 JOYSTICK_STATE_HAT_UNPRESSED = 0x0,
167
168 /// @brief only left is pressed
169 JOYSTICK_STATE_HAT_LEFT = 0x1,
170
171 /// @brief only right is pressed
172 JOYSTICK_STATE_HAT_RIGHT = 0x2,
173
174 /// @brief only up is pressed
175 JOYSTICK_STATE_HAT_UP = 0x4,
176
177 /// @brief only down is pressed
178 JOYSTICK_STATE_HAT_DOWN = 0x8,
179
180 /// @brief left and up is pressed
181 JOYSTICK_STATE_HAT_LEFT_UP = JOYSTICK_STATE_HAT_LEFT | JOYSTICK_STATE_HAT_UP,
182
183 /// @brief left and down is pressed
184 JOYSTICK_STATE_HAT_LEFT_DOWN = JOYSTICK_STATE_HAT_LEFT | JOYSTICK_STATE_HAT_DOWN,
185
186 /// @brief right and up is pressed
187 JOYSTICK_STATE_HAT_RIGHT_UP = JOYSTICK_STATE_HAT_RIGHT | JOYSTICK_STATE_HAT_UP,
188
189 /// @brief right and down is pressed
190 JOYSTICK_STATE_HAT_RIGHT_DOWN = JOYSTICK_STATE_HAT_RIGHT | JOYSTICK_STATE_HAT_DOWN,
191 } JOYSTICK_STATE_HAT;
192 ///@}
193 //----------------------------------------------------------------------------
194
195 //============================================================================
196 /// @ingroup cpp_kodi_addon_peripheral_Defs_Event
197 /// @brief Axis value in the closed interval [-1.0, 1.0]
198 ///
199 /// The axis state uses the XInput coordinate system:
200 /// - Negative values signify down or to the left
201 /// - Positive values signify up or to the right
202 ///
203 typedef float JOYSTICK_STATE_AXIS;
204 //----------------------------------------------------------------------------
205
206 //============================================================================
207 /// @ingroup cpp_kodi_addon_peripheral_Defs_Event
208 /// @brief Motor value in the closed interval [0.0, 1.0]
209 typedef float JOYSTICK_STATE_MOTOR;
210 //----------------------------------------------------------------------------
211
212 /*!
213 * @brief Event information
214 */
215 typedef struct PERIPHERAL_EVENT
216 {
217 /*! @brief Index of the peripheral handling/receiving the event */
218 unsigned int peripheral_index;
219
220 /*! @brief Type of the event used to determine which enum field to access below */
221 PERIPHERAL_EVENT_TYPE type;
222
223 /*! @brief The index of the event source */
224 unsigned int driver_index;
225
226 JOYSTICK_STATE_BUTTON driver_button_state;
227 JOYSTICK_STATE_HAT driver_hat_state;
228 JOYSTICK_STATE_AXIS driver_axis_state;
229 JOYSTICK_STATE_MOTOR motor_state;
230 } ATTRIBUTE_PACKED PERIPHERAL_EVENT;
231
232 //}
233
234 // @name Joystick types
235 //{
236
237 /*!
238 * @brief Info specific to joystick peripherals
239 */
240 typedef struct JOYSTICK_INFO
241 {
242 PERIPHERAL_INFO peripheral; /*!< @brief peripheral info for this joystick */
243 char* provider; /*!< @brief name of the driver or interface providing the joystick */
244 int requested_port; /*!< @brief requested port number (such as for 360 controllers), or NO_PORT_REQUESTED */
245 unsigned int button_count; /*!< @brief number of buttons reported by the driver */
246 unsigned int hat_count; /*!< @brief number of hats reported by the driver */
247 unsigned int axis_count; /*!< @brief number of axes reported by the driver */
248 unsigned int motor_count; /*!< @brief number of motors reported by the driver */
249 bool supports_poweroff; /*!< @brief whether the joystick supports being powered off */
250 } ATTRIBUTE_PACKED JOYSTICK_INFO;
251
252 //============================================================================
253 /// @defgroup cpp_kodi_addon_peripheral_Defs_Joystick_JOYSTICK_DRIVER_PRIMITIVE_TYPE enum JOYSTICK_DRIVER_PRIMITIVE_TYPE
254 /// @ingroup cpp_kodi_addon_peripheral_Defs_Joystick
255 /// @brief **Driver primitive type**\n
256 /// Driver input primitives
257 ///
258 /// Mapping lower-level driver values to higher-level controller features is
259 /// non-injective; two triggers can share a single axis.
260 ///
261 /// To handle this, driver values are subdivided into "primitives" that map
262 /// injectively to higher-level features.
263 ///
264 ///@{
265 typedef enum JOYSTICK_DRIVER_PRIMITIVE_TYPE
266 {
267 /// @brief Driver input primitive type unknown
268 JOYSTICK_DRIVER_PRIMITIVE_TYPE_UNKNOWN,
269
270 /// @brief Driver input primitive type button
271 JOYSTICK_DRIVER_PRIMITIVE_TYPE_BUTTON,
272
273 /// @brief Driver input primitive type hat direction
274 JOYSTICK_DRIVER_PRIMITIVE_TYPE_HAT_DIRECTION,
275
276 /// @brief Driver input primitive type semiaxis
277 JOYSTICK_DRIVER_PRIMITIVE_TYPE_SEMIAXIS,
278
279 /// @brief Driver input primitive type motor
280 JOYSTICK_DRIVER_PRIMITIVE_TYPE_MOTOR,
281
282 /// @brief Driver input primitive type key
283 JOYSTICK_DRIVER_PRIMITIVE_TYPE_KEY,
284
285 /// @brief Driver input primitive type mouse button
286 JOYSTICK_DRIVER_PRIMITIVE_TYPE_MOUSE_BUTTON,
287
288 /// @brief Driver input primitive type relative pointer direction
289 JOYSTICK_DRIVER_PRIMITIVE_TYPE_RELPOINTER_DIRECTION,
290 } JOYSTICK_DRIVER_PRIMITIVE_TYPE;
291 ///@}
292 //----------------------------------------------------------------------------
293
294 /*!
295 * @brief Button primitive
296 */
297 typedef struct JOYSTICK_DRIVER_BUTTON
298 {
299 int index;
300 } ATTRIBUTE_PACKED JOYSTICK_DRIVER_BUTTON;
301
302 //============================================================================
303 /// @defgroup cpp_kodi_addon_peripheral_Defs_Joystick_JOYSTICK_DRIVER_HAT_DIRECTION enum JOYSTICK_DRIVER_HAT_DIRECTION
304 /// @ingroup cpp_kodi_addon_peripheral_Defs_Joystick
305 /// @brief **Driver direction**\n
306 /// Hat direction.
307 ///@{
308 typedef enum JOYSTICK_DRIVER_HAT_DIRECTION
309 {
310 /// @brief Driver hat unknown
311 JOYSTICK_DRIVER_HAT_UNKNOWN,
312
313 /// @brief Driver hat left
314 JOYSTICK_DRIVER_HAT_LEFT,
315
316 /// @brief Driver hat right
317 JOYSTICK_DRIVER_HAT_RIGHT,
318
319 /// @brief Driver hat up
320 JOYSTICK_DRIVER_HAT_UP,
321
322 /// @brief Driver hat down
323 JOYSTICK_DRIVER_HAT_DOWN,
324 } JOYSTICK_DRIVER_HAT_DIRECTION;
325 ///@}
326 //----------------------------------------------------------------------------
327
328 /*!
329 * @brief Hat direction primitive
330 */
331 typedef struct JOYSTICK_DRIVER_HAT
332 {
333 int index;
334 JOYSTICK_DRIVER_HAT_DIRECTION direction;
335 } ATTRIBUTE_PACKED JOYSTICK_DRIVER_HAT;
336
337 //============================================================================
338 /// @defgroup cpp_kodi_addon_peripheral_Defs_Joystick_JOYSTICK_DRIVER_SEMIAXIS_DIRECTION enum JOYSTICK_DRIVER_SEMIAXIS_DIRECTION
339 /// @ingroup cpp_kodi_addon_peripheral_Defs_Joystick
340 /// @brief **Driver direction**\n
341 /// Semiaxis direction.
342 ///@{
343 typedef enum JOYSTICK_DRIVER_SEMIAXIS_DIRECTION
344 {
345 /// @brief negative half of the axis
346 JOYSTICK_DRIVER_SEMIAXIS_NEGATIVE = -1,
347
348 /// @brief unknown direction
349 JOYSTICK_DRIVER_SEMIAXIS_UNKNOWN = 0,
350
351 /// @brief positive half of the axis
352 JOYSTICK_DRIVER_SEMIAXIS_POSITIVE = 1,
353 } JOYSTICK_DRIVER_SEMIAXIS_DIRECTION;
354 ///@}
355 //----------------------------------------------------------------------------
356
357 /*!
358 * @brief Semiaxis primitive
359 */
360 typedef struct JOYSTICK_DRIVER_SEMIAXIS
361 {
362 int index;
363 int center;
364 JOYSTICK_DRIVER_SEMIAXIS_DIRECTION direction;
365 unsigned int range;
366 } ATTRIBUTE_PACKED JOYSTICK_DRIVER_SEMIAXIS;
367
368 /*!
369 * @brief Motor primitive
370 */
371 typedef struct JOYSTICK_DRIVER_MOTOR
372 {
373 int index;
374 } ATTRIBUTE_PACKED JOYSTICK_DRIVER_MOTOR;
375
376 /*!
377 * @brief Keyboard key primitive
378 */
379 typedef struct JOYSTICK_DRIVER_KEY
380 {
381 char keycode[16];
382 } ATTRIBUTE_PACKED JOYSTICK_DRIVER_KEY;
383
384 //============================================================================
385 /// @defgroup cpp_kodi_addon_peripheral_Defs_Joystick_JOYSTICK_DRIVER_MOUSE_INDEX enum JOYSTICK_DRIVER_MOUSE_INDEX
386 /// @ingroup cpp_kodi_addon_peripheral_Defs_Joystick
387 /// @brief **Buttons**\n
388 /// Mouse buttons.
389 ///@{
390 typedef enum JOYSTICK_DRIVER_MOUSE_INDEX
391 {
392 /// @brief Mouse index unknown
393 JOYSTICK_DRIVER_MOUSE_INDEX_UNKNOWN,
394
395 /// @brief Mouse index left
396 JOYSTICK_DRIVER_MOUSE_INDEX_LEFT,
397
398 /// @brief Mouse index right
399 JOYSTICK_DRIVER_MOUSE_INDEX_RIGHT,
400
401 /// @brief Mouse index middle
402 JOYSTICK_DRIVER_MOUSE_INDEX_MIDDLE,
403
404 /// @brief Mouse index button 4
405 JOYSTICK_DRIVER_MOUSE_INDEX_BUTTON4,
406
407 /// @brief Mouse index button 5
408 JOYSTICK_DRIVER_MOUSE_INDEX_BUTTON5,
409
410 /// @brief Mouse index wheel up
411 JOYSTICK_DRIVER_MOUSE_INDEX_WHEEL_UP,
412
413 /// @brief Mouse index wheel down
414 JOYSTICK_DRIVER_MOUSE_INDEX_WHEEL_DOWN,
415
416 /// @brief Mouse index horizontal wheel left
417 JOYSTICK_DRIVER_MOUSE_INDEX_HORIZ_WHEEL_LEFT,
418
419 /// @brief Mouse index horizontal wheel right
420 JOYSTICK_DRIVER_MOUSE_INDEX_HORIZ_WHEEL_RIGHT,
421 } JOYSTICK_DRIVER_MOUSE_INDEX;
422 ///@}
423 //----------------------------------------------------------------------------
424
425 /*!
426 * @brief Mouse button primitive
427 */
428 typedef struct JOYSTICK_DRIVER_MOUSE_BUTTON
429 {
430 JOYSTICK_DRIVER_MOUSE_INDEX button;
431 } ATTRIBUTE_PACKED JOYSTICK_DRIVER_MOUSE_BUTTON;
432
433 //============================================================================
434 /// @defgroup cpp_kodi_addon_peripheral_Defs_Joystick_JOYSTICK_DRIVER_RELPOINTER_DIRECTION enum JOYSTICK_DRIVER_RELPOINTER_DIRECTION
435 /// @ingroup cpp_kodi_addon_peripheral_Defs_Joystick
436 /// @brief **Pointer direction**\n
437 /// Relative pointer direction
438 ///@{
439 typedef enum JOYSTICK_DRIVER_RELPOINTER_DIRECTION
440 {
441 /// @brief Relative pointer direction unknown
442 JOYSTICK_DRIVER_RELPOINTER_UNKNOWN,
443
444 /// @brief Relative pointer direction left
445 JOYSTICK_DRIVER_RELPOINTER_LEFT,
446
447 /// @brief Relative pointer direction right
448 JOYSTICK_DRIVER_RELPOINTER_RIGHT,
449
450 /// @brief Relative pointer direction up
451 JOYSTICK_DRIVER_RELPOINTER_UP,
452
453 /// @brief Relative pointer direction down
454 JOYSTICK_DRIVER_RELPOINTER_DOWN,
455 } JOYSTICK_DRIVER_RELPOINTER_DIRECTION;
456 ///@}
457 //----------------------------------------------------------------------------
458
459 /*!
460 * @brief Relative pointer direction primitive
461 */
462 typedef struct JOYSTICK_DRIVER_RELPOINTER
463 {
464 JOYSTICK_DRIVER_RELPOINTER_DIRECTION direction;
465 } ATTRIBUTE_PACKED JOYSTICK_DRIVER_RELPOINTER;
466
467 /*!
468 * @brief Driver primitive struct
469 */
470 typedef struct JOYSTICK_DRIVER_PRIMITIVE
471 {
472 JOYSTICK_DRIVER_PRIMITIVE_TYPE type;
473 union
474 {
475 struct JOYSTICK_DRIVER_BUTTON button;
476 struct JOYSTICK_DRIVER_HAT hat;
477 struct JOYSTICK_DRIVER_SEMIAXIS semiaxis;
478 struct JOYSTICK_DRIVER_MOTOR motor;
479 struct JOYSTICK_DRIVER_KEY key;
480 struct JOYSTICK_DRIVER_MOUSE_BUTTON mouse;
481 struct JOYSTICK_DRIVER_RELPOINTER relpointer;
482 };
483 } ATTRIBUTE_PACKED JOYSTICK_DRIVER_PRIMITIVE;
484
485 //============================================================================
486 /// @defgroup cpp_kodi_addon_peripheral_Defs_Joystick_JOYSTICK_FEATURE_TYPE enum JOYSTICK_FEATURE_TYPE
487 /// @ingroup cpp_kodi_addon_peripheral_Defs_Joystick
488 /// @brief **Feature type**\n
489 /// Controller feature.
490 ///
491 /// Controller features are an abstraction over driver values. Each feature
492 /// maps to one or more driver primitives.
493 ///
494 ///@{
495 typedef enum JOYSTICK_FEATURE_TYPE
496 {
497 /// @brief Unknown type
498 JOYSTICK_FEATURE_TYPE_UNKNOWN,
499
500 /// @brief Type scalar
501 JOYSTICK_FEATURE_TYPE_SCALAR,
502
503 /// @brief Type analog stick
504 JOYSTICK_FEATURE_TYPE_ANALOG_STICK,
505
506 /// @brief Type accelerometer
507 JOYSTICK_FEATURE_TYPE_ACCELEROMETER,
508
509 /// @brief Type motor
510 JOYSTICK_FEATURE_TYPE_MOTOR,
511
512 /// @brief Type relative pointer
513 JOYSTICK_FEATURE_TYPE_RELPOINTER,
514
515 /// @brief Type absolut pointer
516 JOYSTICK_FEATURE_TYPE_ABSPOINTER,
517
518 /// @brief Type wheel
519 JOYSTICK_FEATURE_TYPE_WHEEL,
520
521 /// @brief Type throttle
522 JOYSTICK_FEATURE_TYPE_THROTTLE,
523
524 /// @brief Type key
525 JOYSTICK_FEATURE_TYPE_KEY,
526 } JOYSTICK_FEATURE_TYPE;
527 ///@}
528 //----------------------------------------------------------------------------
529
530 //============================================================================
531 /// @defgroup cpp_kodi_addon_peripheral_Defs_Joystick_JOYSTICK_FEATURE_PRIMITIVE enum JOYSTICK_FEATURE_PRIMITIVE
532 /// @ingroup cpp_kodi_addon_peripheral_Defs_Joystick
533 /// @brief **Feature primitives**\n
534 /// Indices used to access a feature's driver primitives.
535 ///
536 ///@{
537 typedef enum JOYSTICK_FEATURE_PRIMITIVE
538 {
539 /// @brief Scalar feature (a button, hat direction or semiaxis)
540 JOYSTICK_SCALAR_PRIMITIVE = 0,
541
542 /// @brief Analog stick up
543 JOYSTICK_ANALOG_STICK_UP = 0,
544 /// @brief Analog stick down
545 JOYSTICK_ANALOG_STICK_DOWN = 1,
546 /// @brief Analog stick right
547 JOYSTICK_ANALOG_STICK_RIGHT = 2,
548 /// @brief Analog stick left
549 JOYSTICK_ANALOG_STICK_LEFT = 3,
550
551 /// @brief Accelerometer X
552 JOYSTICK_ACCELEROMETER_POSITIVE_X = 0,
553 /// @brief Accelerometer Y
554 JOYSTICK_ACCELEROMETER_POSITIVE_Y = 1,
555 /// @brief Accelerometer Z
556 JOYSTICK_ACCELEROMETER_POSITIVE_Z = 2,
557
558 /// @brief Motor
559 JOYSTICK_MOTOR_PRIMITIVE = 0,
560
561 /// @brief Wheel left
562 JOYSTICK_WHEEL_LEFT = 0,
563 /// @brief Wheel right
564 JOYSTICK_WHEEL_RIGHT = 1,
565
566 /// @brief Throttle up
567 JOYSTICK_THROTTLE_UP = 0,
568 /// @brief Throttle down
569 JOYSTICK_THROTTLE_DOWN = 1,
570
571 /// @brief Key
572 JOYSTICK_KEY_PRIMITIVE = 0,
573
574 /// @brief Mouse button
575 JOYSTICK_MOUSE_BUTTON = 0,
576
577 /// @brief Relative pointer direction up
578 JOYSTICK_RELPOINTER_UP = 0,
579 /// @brief Relative pointer direction down
580 JOYSTICK_RELPOINTER_DOWN = 1,
581 /// @brief Relative pointer direction right
582 JOYSTICK_RELPOINTER_RIGHT = 2,
583 /// @brief Relative pointer direction left
584 JOYSTICK_RELPOINTER_LEFT = 3,
585
586 /// @brief Maximum number of primitives
587 JOYSTICK_PRIMITIVE_MAX = 4,
588 } JOYSTICK_FEATURE_PRIMITIVE;
589 ///@}
590 //----------------------------------------------------------------------------
591
592 /*!
593 * @brief Mapping between higher-level controller feature and its driver primitives
594 */
595 typedef struct JOYSTICK_FEATURE
596 {
597 char* name;
598 JOYSTICK_FEATURE_TYPE type;
599 struct JOYSTICK_DRIVER_PRIMITIVE primitives[JOYSTICK_PRIMITIVE_MAX];
600 } ATTRIBUTE_PACKED JOYSTICK_FEATURE;
601 //}
602
603 typedef struct AddonProps_Peripheral
604 {
605 const char* user_path; /*!< @brief path to the user profile */
606 const char* addon_path; /*!< @brief path to this add-on */
607 } ATTRIBUTE_PACKED AddonProps_Peripheral;
608
609 struct AddonInstance_Peripheral;
610
611 typedef struct AddonToKodiFuncTable_Peripheral
612 {
613 KODI_HANDLE kodiInstance;
614 void (*trigger_scan)(void* kodiInstance);
615 void (*refresh_button_maps)(void* kodiInstance,
616 const char* device_name,
617 const char* controller_id);
618 unsigned int (*feature_count)(void* kodiInstance,
619 const char* controller_id,
620 JOYSTICK_FEATURE_TYPE type);
621 JOYSTICK_FEATURE_TYPE(*feature_type)
622 (void* kodiInstance, const char* controller_id, const char* feature_name);
623 } AddonToKodiFuncTable_Peripheral;
624
625 //! @todo Mouse, light gun, multitouch
626
627 typedef struct KodiToAddonFuncTable_Peripheral
628 {
629 KODI_HANDLE addonInstance;
630
631 void(__cdecl* get_capabilities)(const struct AddonInstance_Peripheral* addonInstance,
632 struct PERIPHERAL_CAPABILITIES* capabilities);
633 PERIPHERAL_ERROR(__cdecl* perform_device_scan)
634 (const struct AddonInstance_Peripheral* addonInstance,
635 unsigned int* peripheral_count,
636 struct PERIPHERAL_INFO** scan_results);
637 void(__cdecl* free_scan_results)(const struct AddonInstance_Peripheral* addonInstance,
638 unsigned int peripheral_count,
639 struct PERIPHERAL_INFO* scan_results);
640 PERIPHERAL_ERROR(__cdecl* get_events)
641 (const struct AddonInstance_Peripheral* addonInstance,
642 unsigned int* event_count,
643 struct PERIPHERAL_EVENT** events);
644 void(__cdecl* free_events)(const struct AddonInstance_Peripheral* addonInstance,
645 unsigned int event_count,
646 struct PERIPHERAL_EVENT* events);
647 bool(__cdecl* send_event)(const struct AddonInstance_Peripheral* addonInstance,
648 const struct PERIPHERAL_EVENT* event);
649
650 /// @name Joystick operations
651 ///{
652 PERIPHERAL_ERROR(__cdecl* get_joystick_info)
653 (const struct AddonInstance_Peripheral* addonInstance,
654 unsigned int index,
655 struct JOYSTICK_INFO* info);
656 void(__cdecl* free_joystick_info)(const struct AddonInstance_Peripheral* addonInstance,
657 struct JOYSTICK_INFO* info);
658 PERIPHERAL_ERROR(__cdecl* get_features)
659 (const struct AddonInstance_Peripheral* addonInstance,
660 const struct JOYSTICK_INFO* joystick,
661 const char* controller_id,
662 unsigned int* feature_count,
663 struct JOYSTICK_FEATURE** features);
664 void(__cdecl* free_features)(const struct AddonInstance_Peripheral* addonInstance,
665 unsigned int feature_count,
666 struct JOYSTICK_FEATURE* features);
667 PERIPHERAL_ERROR(__cdecl* map_features)
668 (const struct AddonInstance_Peripheral* addonInstance,
669 const struct JOYSTICK_INFO* joystick,
670 const char* controller_id,
671 unsigned int feature_count,
672 const struct JOYSTICK_FEATURE* features);
673 PERIPHERAL_ERROR(__cdecl* get_ignored_primitives)
674 (const struct AddonInstance_Peripheral* addonInstance,
675 const struct JOYSTICK_INFO* joystick,
676 unsigned int* feature_count,
677 struct JOYSTICK_DRIVER_PRIMITIVE** primitives);
678 void(__cdecl* free_primitives)(const struct AddonInstance_Peripheral* addonInstance,
679 unsigned int,
680 struct JOYSTICK_DRIVER_PRIMITIVE* primitives);
681 PERIPHERAL_ERROR(__cdecl* set_ignored_primitives)
682 (const struct AddonInstance_Peripheral* addonInstance,
683 const struct JOYSTICK_INFO* joystick,
684 unsigned int primitive_count,
685 const struct JOYSTICK_DRIVER_PRIMITIVE* primitives);
686 void(__cdecl* save_button_map)(const struct AddonInstance_Peripheral* addonInstance,
687 const struct JOYSTICK_INFO* joystick);
688 void(__cdecl* revert_button_map)(const struct AddonInstance_Peripheral* addonInstance,
689 const struct JOYSTICK_INFO* joystick);
690 void(__cdecl* reset_button_map)(const struct AddonInstance_Peripheral* addonInstance,
691 const struct JOYSTICK_INFO* joystick,
692 const char* controller_id);
693 void(__cdecl* power_off_joystick)(const struct AddonInstance_Peripheral* addonInstance,
694 unsigned int index);
695 ///}
696 } KodiToAddonFuncTable_Peripheral;
697
698 typedef struct AddonInstance_Peripheral
699 {
700 struct AddonProps_Peripheral* props;
701 struct AddonToKodiFuncTable_Peripheral* toKodi;
702 struct KodiToAddonFuncTable_Peripheral* toAddon;
703 } AddonInstance_Peripheral;
704
705#ifdef __cplusplus
706} /* extern "C" */
707#endif /* __cplusplus */
708
709#endif /* !C_API_ADDONINSTANCE_PERIPHERAL_H */
diff --git a/xbmc/addons/kodi-dev-kit/include/kodi/c-api/addon-instance/pvr.h b/xbmc/addons/kodi-dev-kit/include/kodi/c-api/addon-instance/pvr.h
new file mode 100644
index 0000000..a50ea2b
--- /dev/null
+++ b/xbmc/addons/kodi-dev-kit/include/kodi/c-api/addon-instance/pvr.h
@@ -0,0 +1,332 @@
1/*
2 * Copyright (C) 2005-2018 Team Kodi
3 * This file is part of Kodi - https://kodi.tv
4 *
5 * SPDX-License-Identifier: GPL-2.0-or-later
6 * See LICENSES/README.md for more information.
7 */
8
9#pragma once
10
11#ifndef C_API_ADDONINSTANCE_PVR_H
12#define C_API_ADDONINSTANCE_PVR_H
13
14#include "../../AddonBase.h"
15#include "pvr/pvr_channel_groups.h"
16#include "pvr/pvr_channels.h"
17#include "pvr/pvr_defines.h"
18#include "pvr/pvr_edl.h"
19#include "pvr/pvr_epg.h"
20#include "pvr/pvr_general.h"
21#include "pvr/pvr_menu_hook.h"
22#include "pvr/pvr_recordings.h"
23#include "pvr/pvr_stream.h"
24#include "pvr/pvr_timers.h"
25
26//¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯
27// "C" main interface function tables between Kodi and addon
28//
29// Values related to all parts and not used direct on addon, are to define here.
30//
31#ifdef __cplusplus
32extern "C"
33{
34#endif /* __cplusplus */
35
36 /*!
37 * @internal
38 * @brief PVR "C" basis API interface
39 *
40 * This field contains things that are exchanged between Kodi and Addon
41 * and is the basis of the PVR-side "C" API.
42 *
43 * @warning Care should be taken when making changes in this fields!\n
44 * Changes can destroy API in addons that have already been created. If a
45 * necessary change or new feature is added, the version of the PVR
46 * at @ref ADDON_INSTANCE_VERSION_PVR_MIN must be increased too.\n
47 * \n
48 * Conditional changes can be made in some places, without min PVR version
49 * increase. The add-on should then use CreateInstanceEx and add partial tests
50 * for this in the C++ header.
51 *
52 * Have by add of new parts a look about **Doxygen** `\\ingroup`, so that
53 * added parts included in documentation.
54 *
55 * If you add addon side related documentation, where his dev need know,
56 * use `///`. For parts only for Kodi make it like here.
57 *
58 * @endinternal
59 */
60
61 struct AddonInstance_PVR;
62
63 /*!
64 * @brief Structure to define typical standard values
65 */
66 typedef struct AddonProperties_PVR
67 {
68 const char* strUserPath;
69 const char* strClientPath;
70 int iEpgMaxDays;
71 } AddonProperties_PVR;
72
73 /*!
74 * @brief Structure to transfer the methods from Kodi to addon
75 */
76 typedef struct AddonToKodiFuncTable_PVR
77 {
78 // Pointer inside Kodi where used from him to find his class
79 KODI_HANDLE kodiInstance;
80
81 //--==----==----==----==----==----==----==----==----==----==----==----==----==
82 // General callback functions
83 void (*AddMenuHook)(void* kodiInstance, const struct PVR_MENUHOOK* hook);
84 void (*RecordingNotification)(void* kodiInstance,
85 const char* name,
86 const char* fileName,
87 bool on);
88 void (*ConnectionStateChange)(void* kodiInstance,
89 const char* strConnectionString,
90 enum PVR_CONNECTION_STATE newState,
91 const char* strMessage);
92 void (*EpgEventStateChange)(void* kodiInstance,
93 struct EPG_TAG* tag,
94 enum EPG_EVENT_STATE newState);
95
96 //--==----==----==----==----==----==----==----==----==----==----==----==----==
97 // Transfer functions where give data back to Kodi, e.g. GetChannels calls TransferChannelEntry
98 void (*TransferChannelEntry)(void* kodiInstance,
99 const ADDON_HANDLE handle,
100 const struct PVR_CHANNEL* chan);
101 void (*TransferChannelGroup)(void* kodiInstance,
102 const ADDON_HANDLE handle,
103 const struct PVR_CHANNEL_GROUP* group);
104 void (*TransferChannelGroupMember)(void* kodiInstance,
105 const ADDON_HANDLE handle,
106 const struct PVR_CHANNEL_GROUP_MEMBER* member);
107 void (*TransferEpgEntry)(void* kodiInstance,
108 const ADDON_HANDLE handle,
109 const struct EPG_TAG* epgentry);
110 void (*TransferRecordingEntry)(void* kodiInstance,
111 const ADDON_HANDLE handle,
112 const struct PVR_RECORDING* recording);
113 void (*TransferTimerEntry)(void* kodiInstance,
114 const ADDON_HANDLE handle,
115 const struct PVR_TIMER* timer);
116
117 //--==----==----==----==----==----==----==----==----==----==----==----==----==
118 // Kodi inform interface functions
119 void (*TriggerChannelUpdate)(void* kodiInstance);
120 void (*TriggerChannelGroupsUpdate)(void* kodiInstance);
121 void (*TriggerEpgUpdate)(void* kodiInstance, unsigned int iChannelUid);
122 void (*TriggerRecordingUpdate)(void* kodiInstance);
123 void (*TriggerTimerUpdate)(void* kodiInstance);
124
125 //--==----==----==----==----==----==----==----==----==----==----==----==----==
126 // Stream demux interface functions
127 void (*FreeDemuxPacket)(void* kodiInstance, struct DemuxPacket* pPacket);
128 struct DemuxPacket* (*AllocateDemuxPacket)(void* kodiInstance, int iDataSize);
129 struct PVR_CODEC (*GetCodecByName)(const void* kodiInstance, const char* strCodecName);
130
131 //--==----==----==----==----==----==----==----==----==----==----==----==----==
132 // New functions becomes added below and can be on another API change (where
133 // breaks min API version) moved up.
134 } AddonToKodiFuncTable_PVR;
135
136 /*!
137 * @brief Structure to transfer the methods from addon to Kodi
138 */
139 typedef struct KodiToAddonFuncTable_PVR
140 {
141 // Pointer inside addon where used on them to find his instance class (currently unused!)
142 KODI_HANDLE addonInstance;
143
144 //--==----==----==----==----==----==----==----==----==----==----==----==----==
145 // General interface functions
146 enum PVR_ERROR(__cdecl* GetCapabilities)(const struct AddonInstance_PVR*,
147 struct PVR_ADDON_CAPABILITIES*);
148 enum PVR_ERROR(__cdecl* GetBackendName)(const struct AddonInstance_PVR*, char*, int);
149 enum PVR_ERROR(__cdecl* GetBackendVersion)(const struct AddonInstance_PVR*, char*, int);
150 enum PVR_ERROR(__cdecl* GetBackendHostname)(const struct AddonInstance_PVR*, char*, int);
151 enum PVR_ERROR(__cdecl* GetConnectionString)(const struct AddonInstance_PVR*, char*, int);
152 enum PVR_ERROR(__cdecl* GetDriveSpace)(const struct AddonInstance_PVR*, uint64_t*, uint64_t*);
153 enum PVR_ERROR(__cdecl* CallSettingsMenuHook)(const struct AddonInstance_PVR*,
154 const struct PVR_MENUHOOK*);
155
156 //--==----==----==----==----==----==----==----==----==----==----==----==----==
157 // Channel interface functions
158
159 enum PVR_ERROR(__cdecl* GetChannelsAmount)(const struct AddonInstance_PVR*, int*);
160 enum PVR_ERROR(__cdecl* GetChannels)(const struct AddonInstance_PVR*, ADDON_HANDLE, bool);
161 enum PVR_ERROR(__cdecl* GetChannelStreamProperties)(const struct AddonInstance_PVR*,
162 const struct PVR_CHANNEL*,
163 struct PVR_NAMED_VALUE*,
164 unsigned int*);
165 enum PVR_ERROR(__cdecl* GetSignalStatus)(const struct AddonInstance_PVR*,
166 int,
167 struct PVR_SIGNAL_STATUS*);
168 enum PVR_ERROR(__cdecl* GetDescrambleInfo)(const struct AddonInstance_PVR*,
169 int,
170 struct PVR_DESCRAMBLE_INFO*);
171
172 //--==----==----==----==----==----==----==----==----==----==----==----==----==
173 // Channel group interface functions
174 enum PVR_ERROR(__cdecl* GetChannelGroupsAmount)(const struct AddonInstance_PVR*, int*);
175 enum PVR_ERROR(__cdecl* GetChannelGroups)(const struct AddonInstance_PVR*, ADDON_HANDLE, bool);
176 enum PVR_ERROR(__cdecl* GetChannelGroupMembers)(const struct AddonInstance_PVR*,
177 ADDON_HANDLE,
178 const struct PVR_CHANNEL_GROUP*);
179
180 //--==----==----==----==----==----==----==----==----==----==----==----==----==
181 // Channel edit interface functions
182 enum PVR_ERROR(__cdecl* DeleteChannel)(const struct AddonInstance_PVR*,
183 const struct PVR_CHANNEL*);
184 enum PVR_ERROR(__cdecl* RenameChannel)(const struct AddonInstance_PVR*,
185 const struct PVR_CHANNEL*);
186 enum PVR_ERROR(__cdecl* OpenDialogChannelSettings)(const struct AddonInstance_PVR*,
187 const struct PVR_CHANNEL*);
188 enum PVR_ERROR(__cdecl* OpenDialogChannelAdd)(const struct AddonInstance_PVR*,
189 const struct PVR_CHANNEL*);
190 enum PVR_ERROR(__cdecl* OpenDialogChannelScan)(const struct AddonInstance_PVR*);
191 enum PVR_ERROR(__cdecl* CallChannelMenuHook)(const struct AddonInstance_PVR*,
192 const PVR_MENUHOOK*,
193 const PVR_CHANNEL*);
194
195 //--==----==----==----==----==----==----==----==----==----==----==----==----==
196 // EPG interface functions
197 enum PVR_ERROR(__cdecl* GetEPGForChannel)(
198 const struct AddonInstance_PVR*, ADDON_HANDLE, int, time_t, time_t);
199 enum PVR_ERROR(__cdecl* IsEPGTagRecordable)(const struct AddonInstance_PVR*,
200 const struct EPG_TAG*,
201 bool*);
202 enum PVR_ERROR(__cdecl* IsEPGTagPlayable)(const struct AddonInstance_PVR*,
203 const struct EPG_TAG*,
204 bool*);
205 enum PVR_ERROR(__cdecl* GetEPGTagEdl)(const struct AddonInstance_PVR*,
206 const struct EPG_TAG*,
207 struct PVR_EDL_ENTRY[],
208 int*);
209 enum PVR_ERROR(__cdecl* GetEPGTagStreamProperties)(const struct AddonInstance_PVR*,
210 const struct EPG_TAG*,
211 struct PVR_NAMED_VALUE*,
212 unsigned int*);
213 enum PVR_ERROR(__cdecl* SetEPGTimeFrame)(const struct AddonInstance_PVR*, int);
214 enum PVR_ERROR(__cdecl* CallEPGMenuHook)(const struct AddonInstance_PVR*,
215 const struct PVR_MENUHOOK*,
216 const struct EPG_TAG*);
217
218 //--==----==----==----==----==----==----==----==----==----==----==----==----==
219 // Recording interface functions
220 enum PVR_ERROR(__cdecl* GetRecordingsAmount)(const struct AddonInstance_PVR*, bool, int*);
221 enum PVR_ERROR(__cdecl* GetRecordings)(const struct AddonInstance_PVR*, ADDON_HANDLE, bool);
222 enum PVR_ERROR(__cdecl* DeleteRecording)(const struct AddonInstance_PVR*,
223 const struct PVR_RECORDING*);
224 enum PVR_ERROR(__cdecl* UndeleteRecording)(const struct AddonInstance_PVR*,
225 const struct PVR_RECORDING*);
226 enum PVR_ERROR(__cdecl* DeleteAllRecordingsFromTrash)(const struct AddonInstance_PVR*);
227 enum PVR_ERROR(__cdecl* RenameRecording)(const struct AddonInstance_PVR*,
228 const struct PVR_RECORDING*);
229 enum PVR_ERROR(__cdecl* SetRecordingLifetime)(const struct AddonInstance_PVR*,
230 const struct PVR_RECORDING*);
231 enum PVR_ERROR(__cdecl* SetRecordingPlayCount)(const struct AddonInstance_PVR*,
232 const struct PVR_RECORDING*,
233 int);
234 enum PVR_ERROR(__cdecl* SetRecordingLastPlayedPosition)(const struct AddonInstance_PVR*,
235 const struct PVR_RECORDING*,
236 int);
237 enum PVR_ERROR(__cdecl* GetRecordingLastPlayedPosition)(const struct AddonInstance_PVR*,
238 const struct PVR_RECORDING*,
239 int*);
240 enum PVR_ERROR(__cdecl* GetRecordingEdl)(const struct AddonInstance_PVR*,
241 const struct PVR_RECORDING*,
242 struct PVR_EDL_ENTRY[],
243 int*);
244 enum PVR_ERROR(__cdecl* GetRecordingSize)(const struct AddonInstance_PVR*,
245 const PVR_RECORDING*,
246 int64_t*);
247 enum PVR_ERROR(__cdecl* GetRecordingStreamProperties)(const struct AddonInstance_PVR*,
248 const struct PVR_RECORDING*,
249 struct PVR_NAMED_VALUE*,
250 unsigned int*);
251 enum PVR_ERROR(__cdecl* CallRecordingMenuHook)(const struct AddonInstance_PVR*,
252 const struct PVR_MENUHOOK*,
253 const struct PVR_RECORDING*);
254
255 //--==----==----==----==----==----==----==----==----==----==----==----==----==
256 // Timer interface functions
257 enum PVR_ERROR(__cdecl* GetTimerTypes)(const struct AddonInstance_PVR*,
258 struct PVR_TIMER_TYPE[],
259 int*);
260 enum PVR_ERROR(__cdecl* GetTimersAmount)(const struct AddonInstance_PVR*, int*);
261 enum PVR_ERROR(__cdecl* GetTimers)(const struct AddonInstance_PVR*, ADDON_HANDLE);
262 enum PVR_ERROR(__cdecl* AddTimer)(const struct AddonInstance_PVR*, const struct PVR_TIMER*);
263 enum PVR_ERROR(__cdecl* DeleteTimer)(const struct AddonInstance_PVR*,
264 const struct PVR_TIMER*,
265 bool);
266 enum PVR_ERROR(__cdecl* UpdateTimer)(const struct AddonInstance_PVR*, const struct PVR_TIMER*);
267 enum PVR_ERROR(__cdecl* CallTimerMenuHook)(const struct AddonInstance_PVR*,
268 const struct PVR_MENUHOOK*,
269 const struct PVR_TIMER*);
270
271 //--==----==----==----==----==----==----==----==----==----==----==----==----==
272 // Powersaving interface functions
273 enum PVR_ERROR(__cdecl* OnSystemSleep)(const struct AddonInstance_PVR*);
274 enum PVR_ERROR(__cdecl* OnSystemWake)(const struct AddonInstance_PVR*);
275 enum PVR_ERROR(__cdecl* OnPowerSavingActivated)(const struct AddonInstance_PVR*);
276 enum PVR_ERROR(__cdecl* OnPowerSavingDeactivated)(const struct AddonInstance_PVR*);
277
278 //--==----==----==----==----==----==----==----==----==----==----==----==----==
279 // Live stream read interface functions
280 bool(__cdecl* OpenLiveStream)(const struct AddonInstance_PVR*, const struct PVR_CHANNEL*);
281 void(__cdecl* CloseLiveStream)(const struct AddonInstance_PVR*);
282 int(__cdecl* ReadLiveStream)(const struct AddonInstance_PVR*, unsigned char*, unsigned int);
283 int64_t(__cdecl* SeekLiveStream)(const struct AddonInstance_PVR*, int64_t, int);
284 int64_t(__cdecl* LengthLiveStream)(const struct AddonInstance_PVR*);
285
286 //--==----==----==----==----==----==----==----==----==----==----==----==----==
287 // Recording stream read interface functions
288 bool(__cdecl* OpenRecordedStream)(const struct AddonInstance_PVR*, const struct PVR_RECORDING*);
289 void(__cdecl* CloseRecordedStream)(const struct AddonInstance_PVR*);
290 int(__cdecl* ReadRecordedStream)(const struct AddonInstance_PVR*, unsigned char*, unsigned int);
291 int64_t(__cdecl* SeekRecordedStream)(const struct AddonInstance_PVR*, int64_t, int);
292 int64_t(__cdecl* LengthRecordedStream)(const struct AddonInstance_PVR*);
293
294 //--==----==----==----==----==----==----==----==----==----==----==----==----==
295 // Stream demux interface functions
296 enum PVR_ERROR(__cdecl* GetStreamProperties)(const struct AddonInstance_PVR*,
297 struct PVR_STREAM_PROPERTIES*);
298 struct DemuxPacket*(__cdecl* DemuxRead)(const struct AddonInstance_PVR*);
299 void(__cdecl* DemuxReset)(const struct AddonInstance_PVR*);
300 void(__cdecl* DemuxAbort)(const struct AddonInstance_PVR*);
301 void(__cdecl* DemuxFlush)(const struct AddonInstance_PVR*);
302 void(__cdecl* SetSpeed)(const struct AddonInstance_PVR*, int);
303 void(__cdecl* FillBuffer)(const struct AddonInstance_PVR*, bool);
304 bool(__cdecl* SeekTime)(const struct AddonInstance_PVR*, double, bool, double*);
305
306 //--==----==----==----==----==----==----==----==----==----==----==----==----==
307 // General stream interface functions
308 bool(__cdecl* CanPauseStream)(const struct AddonInstance_PVR*);
309 void(__cdecl* PauseStream)(const struct AddonInstance_PVR*, bool);
310 bool(__cdecl* CanSeekStream)(const struct AddonInstance_PVR*);
311 bool(__cdecl* IsRealTimeStream)(const struct AddonInstance_PVR*);
312 enum PVR_ERROR(__cdecl* GetStreamTimes)(const struct AddonInstance_PVR*,
313 struct PVR_STREAM_TIMES*);
314 enum PVR_ERROR(__cdecl* GetStreamReadChunkSize)(const struct AddonInstance_PVR*, int*);
315
316 //--==----==----==----==----==----==----==----==----==----==----==----==----==
317 // New functions becomes added below and can be on another API change (where
318 // breaks min API version) moved up.
319 } KodiToAddonFuncTable_PVR;
320
321 typedef struct AddonInstance_PVR
322 {
323 struct AddonProperties_PVR* props;
324 struct AddonToKodiFuncTable_PVR* toKodi;
325 struct KodiToAddonFuncTable_PVR* toAddon;
326 } AddonInstance_PVR;
327
328#ifdef __cplusplus
329}
330#endif /* __cplusplus */
331
332#endif /* !C_API_ADDONINSTANCE_PVR_H */
diff --git a/xbmc/addons/kodi-dev-kit/include/kodi/c-api/addon-instance/pvr/CMakeLists.txt b/xbmc/addons/kodi-dev-kit/include/kodi/c-api/addon-instance/pvr/CMakeLists.txt
new file mode 100644
index 0000000..0e37ea4
--- /dev/null
+++ b/xbmc/addons/kodi-dev-kit/include/kodi/c-api/addon-instance/pvr/CMakeLists.txt
@@ -0,0 +1,14 @@
1set(HEADERS pvr_channel_groups.h
2 pvr_channels.h
3 pvr_defines.h
4 pvr_edl.h
5 pvr_epg.h
6 pvr_general.h
7 pvr_menu_hook.h
8 pvr_recordings.h
9 pvr_stream.h
10 pvr_timers.h)
11
12if(NOT ENABLE_STATIC_LIBS)
13 core_add_library(addons_kodi-dev-kit_include_kodi_c-api_addon-instance_pvr)
14endif()
diff --git a/xbmc/addons/kodi-dev-kit/include/kodi/c-api/addon-instance/pvr/pvr_channel_groups.h b/xbmc/addons/kodi-dev-kit/include/kodi/c-api/addon-instance/pvr/pvr_channel_groups.h
new file mode 100644
index 0000000..a24d27f
--- /dev/null
+++ b/xbmc/addons/kodi-dev-kit/include/kodi/c-api/addon-instance/pvr/pvr_channel_groups.h
@@ -0,0 +1,59 @@
1/*
2 * Copyright (C) 2005-2018 Team Kodi
3 * This file is part of Kodi - https://kodi.tv
4 *
5 * SPDX-License-Identifier: GPL-2.0-or-later
6 * See LICENSES/README.md for more information.
7 */
8
9#pragma once
10
11#ifndef C_API_ADDONINSTANCE_PVR_CHANNEL_GROUPS_H
12#define C_API_ADDONINSTANCE_PVR_CHANNEL_GROUPS_H
13
14#include "pvr_defines.h"
15
16#include <stdbool.h>
17
18//¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯
19// "C" Definitions group 3 - PVR channel group
20#ifdef __cplusplus
21extern "C"
22{
23#endif /* __cplusplus */
24
25 /*!
26 * @brief "C" PVR add-on channel group.
27 *
28 * Structure used to interface in "C" between Kodi and Addon.
29 *
30 * See @ref kodi::addon::PVRChannelGroup for description of values.
31 */
32 typedef struct PVR_CHANNEL_GROUP
33 {
34 char strGroupName[PVR_ADDON_NAME_STRING_LENGTH];
35 bool bIsRadio;
36 unsigned int iPosition;
37 } PVR_CHANNEL_GROUP;
38
39 /*!
40 * @brief "C" PVR add-on channel group member.
41 *
42 * Structure used to interface in "C" between Kodi and Addon.
43 *
44 * See @ref kodi::addon::PVRChannelGroupMember for description of values.
45 */
46 typedef struct PVR_CHANNEL_GROUP_MEMBER
47 {
48 char strGroupName[PVR_ADDON_NAME_STRING_LENGTH];
49 unsigned int iChannelUniqueId;
50 unsigned int iChannelNumber;
51 unsigned int iSubChannelNumber;
52 int iOrder;
53 } PVR_CHANNEL_GROUP_MEMBER;
54
55#ifdef __cplusplus
56}
57#endif /* __cplusplus */
58
59#endif /* !C_API_ADDONINSTANCE_PVR_CHANNEL_GROUPS_H */
diff --git a/xbmc/addons/kodi-dev-kit/include/kodi/c-api/addon-instance/pvr/pvr_channels.h b/xbmc/addons/kodi-dev-kit/include/kodi/c-api/addon-instance/pvr/pvr_channels.h
new file mode 100644
index 0000000..00daffa
--- /dev/null
+++ b/xbmc/addons/kodi-dev-kit/include/kodi/c-api/addon-instance/pvr/pvr_channels.h
@@ -0,0 +1,109 @@
1/*
2 * Copyright (C) 2005-2018 Team Kodi
3 * This file is part of Kodi - https://kodi.tv
4 *
5 * SPDX-License-Identifier: GPL-2.0-or-later
6 * See LICENSES/README.md for more information.
7 */
8
9#pragma once
10
11#ifndef C_API_ADDONINSTANCE_PVR_CHANNELS_H
12#define C_API_ADDONINSTANCE_PVR_CHANNELS_H
13
14#include "pvr_defines.h"
15
16#include <stdbool.h>
17
18//¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯
19// "C" Definitions group 2 - PVR channel
20#ifdef __cplusplus
21extern "C"
22{
23#endif /* __cplusplus */
24
25 //============================================================================
26 /// @ingroup cpp_kodi_addon_pvr_Defs_Channel
27 /// @brief Denotes that no channel uid is available.
28 ///
29 /// Special @ref kodi::addon::PVRTimer::SetClientChannelUid() and
30 /// @ref kodi::addon::PVRRecording::SetChannelUid() value to indicate that no
31 /// channel uid is available.
32 #define PVR_CHANNEL_INVALID_UID -1
33 //----------------------------------------------------------------------------
34
35 /*!
36 * @brief "C" PVR add-on channel.
37 *
38 * Structure used to interface in "C" between Kodi and Addon.
39 *
40 * See @ref kodi::addon::PVRChannel for description of values.
41 */
42 typedef struct PVR_CHANNEL
43 {
44 unsigned int iUniqueId;
45 bool bIsRadio;
46 unsigned int iChannelNumber;
47 unsigned int iSubChannelNumber;
48 char strChannelName[PVR_ADDON_NAME_STRING_LENGTH];
49 char strMimeType[PVR_ADDON_INPUT_FORMAT_STRING_LENGTH];
50 unsigned int iEncryptionSystem;
51 char strIconPath[PVR_ADDON_URL_STRING_LENGTH];
52 bool bIsHidden;
53 bool bHasArchive;
54 int iOrder;
55 } PVR_CHANNEL;
56
57 /*!
58 * @brief "C" PVR add-on signal status information.
59 *
60 * Structure used to interface in "C" between Kodi and Addon.
61 *
62 * See @ref kodi::addon::PVRSignalStatus for description of values.
63 */
64 typedef struct PVR_SIGNAL_STATUS
65 {
66 char strAdapterName[PVR_ADDON_NAME_STRING_LENGTH];
67 char strAdapterStatus[PVR_ADDON_NAME_STRING_LENGTH];
68 char strServiceName[PVR_ADDON_NAME_STRING_LENGTH];
69 char strProviderName[PVR_ADDON_NAME_STRING_LENGTH];
70 char strMuxName[PVR_ADDON_NAME_STRING_LENGTH];
71 int iSNR;
72 int iSignal;
73 long iBER;
74 long iUNC;
75 } PVR_SIGNAL_STATUS;
76
77 //============================================================================
78 /// @ingroup cpp_kodi_addon_pvr_Defs_Channel_PVRDescrambleInfo
79 /// @brief Special @ref cpp_kodi_addon_pvr_Defs_Channel_PVRDescrambleInfo
80 /// value to indicate that a struct member's value is not available
81 ///
82 #define PVR_DESCRAMBLE_INFO_NOT_AVAILABLE -1
83 //----------------------------------------------------------------------------
84
85 /*!
86 * @brief "C" PVR add-on descramble information.
87 *
88 * Structure used to interface in "C" between Kodi and Addon.
89 *
90 * See @ref kodi::addon::PVRDescrambleInfo for description of values.
91 */
92 typedef struct PVR_DESCRAMBLE_INFO
93 {
94 int iPid;
95 int iCaid;
96 int iProvid;
97 int iEcmTime;
98 int iHops;
99 char strCardSystem[PVR_ADDON_DESCRAMBLE_INFO_STRING_LENGTH];
100 char strReader[PVR_ADDON_DESCRAMBLE_INFO_STRING_LENGTH];
101 char strFrom[PVR_ADDON_DESCRAMBLE_INFO_STRING_LENGTH];
102 char strProtocol[PVR_ADDON_DESCRAMBLE_INFO_STRING_LENGTH];
103 } PVR_DESCRAMBLE_INFO;
104
105#ifdef __cplusplus
106}
107#endif /* __cplusplus */
108
109#endif /* !C_API_ADDONINSTANCE_PVR_CHANNELS_H */
diff --git a/xbmc/addons/kodi-dev-kit/include/kodi/c-api/addon-instance/pvr/pvr_defines.h b/xbmc/addons/kodi-dev-kit/include/kodi/c-api/addon-instance/pvr/pvr_defines.h
new file mode 100644
index 0000000..449000f
--- /dev/null
+++ b/xbmc/addons/kodi-dev-kit/include/kodi/c-api/addon-instance/pvr/pvr_defines.h
@@ -0,0 +1,66 @@
1/*
2 * Copyright (C) 2005-2018 Team Kodi
3 * This file is part of Kodi - https://kodi.tv
4 *
5 * SPDX-License-Identifier: GPL-2.0-or-later
6 * See LICENSES/README.md for more information.
7 */
8
9#pragma once
10
11#ifndef C_API_ADDONINSTANCE_PVR_DEFINES_H
12#define C_API_ADDONINSTANCE_PVR_DEFINES_H
13
14//¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯
15// "C" Standard PVR definitions
16//
17// Values related to all parts and not used direct on addon, are to define here.
18//
19#ifdef __cplusplus
20extern "C"
21{
22#endif /* __cplusplus */
23
24 /*!
25 * @brief API array sizes which are used for data exchange between
26 * Kodi and addon.
27 */
28 ///@{
29 #define PVR_ADDON_NAME_STRING_LENGTH 1024
30 #define PVR_ADDON_URL_STRING_LENGTH 1024
31 #define PVR_ADDON_DESC_STRING_LENGTH 1024
32 #define PVR_ADDON_INPUT_FORMAT_STRING_LENGTH 32
33 #define PVR_ADDON_EDL_LENGTH 32
34 #define PVR_ADDON_TIMERTYPE_ARRAY_SIZE 32
35 #define PVR_ADDON_TIMERTYPE_VALUES_ARRAY_SIZE 512
36 #define PVR_ADDON_TIMERTYPE_VALUES_ARRAY_SIZE_SMALL 128
37 #define PVR_ADDON_TIMERTYPE_STRING_LENGTH 128
38 #define PVR_ADDON_ATTRIBUTE_DESC_LENGTH 128
39 #define PVR_ADDON_ATTRIBUTE_VALUES_ARRAY_SIZE 512
40 #define PVR_ADDON_DESCRAMBLE_INFO_STRING_LENGTH 64
41 #define PVR_ADDON_DATE_STRING_LENGTH 32
42 ///@}
43
44 /*!
45 * @brief "C" Representation of a general attribute integer value.
46 */
47 typedef struct PVR_ATTRIBUTE_INT_VALUE
48 {
49 int iValue;
50 char strDescription[PVR_ADDON_ATTRIBUTE_DESC_LENGTH];
51 } PVR_ATTRIBUTE_INT_VALUE;
52
53 /*!
54 * @brief "C" Representation of a named value.
55 */
56 typedef struct PVR_NAMED_VALUE
57 {
58 char strName[PVR_ADDON_NAME_STRING_LENGTH];
59 char strValue[PVR_ADDON_NAME_STRING_LENGTH];
60 } PVR_NAMED_VALUE;
61
62#ifdef __cplusplus
63}
64#endif /* __cplusplus */
65
66#endif /* !C_API_ADDONINSTANCE_PVR_DEFINES_H */
diff --git a/xbmc/addons/kodi-dev-kit/include/kodi/c-api/addon-instance/pvr/pvr_edl.h b/xbmc/addons/kodi-dev-kit/include/kodi/c-api/addon-instance/pvr/pvr_edl.h
new file mode 100644
index 0000000..e7cdf06
--- /dev/null
+++ b/xbmc/addons/kodi-dev-kit/include/kodi/c-api/addon-instance/pvr/pvr_edl.h
@@ -0,0 +1,67 @@
1/*
2 * Copyright (C) 2005-2018 Team Kodi
3 * This file is part of Kodi - https://kodi.tv
4 *
5 * SPDX-License-Identifier: GPL-2.0-or-later
6 * See LICENSES/README.md for more information.
7 */
8
9#pragma once
10
11#ifndef C_API_ADDONINSTANCE_PVR_EDL_H
12#define C_API_ADDONINSTANCE_PVR_EDL_H
13
14#include "pvr_defines.h"
15
16#include <stdint.h>
17
18//¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯
19// "C" Definitions group 8 - PVR Edit definition list (EDL)
20#ifdef __cplusplus
21extern "C"
22{
23#endif /* __cplusplus */
24
25 //============================================================================
26 /// @defgroup cpp_kodi_addon_pvr_Defs_EDLEntry_PVR_EDL_TYPE enum PVR_EDL_TYPE
27 /// @ingroup cpp_kodi_addon_pvr_Defs_EDLEntry
28 /// @brief **Edit definition list types**\n
29 /// Possible type values for @ref cpp_kodi_addon_pvr_Defs_EDLEntry_PVREDLEntry.
30 ///
31 ///@{
32 typedef enum PVR_EDL_TYPE
33 {
34 /// @brief __0__ : cut (completely remove content)
35 PVR_EDL_TYPE_CUT = 0,
36
37 /// @brief __1__ : mute audio
38 PVR_EDL_TYPE_MUTE = 1,
39
40 /// @brief __2__ : scene markers (chapter seeking)
41 PVR_EDL_TYPE_SCENE = 2,
42
43 /// @brief __3__ : commercial breaks
44 PVR_EDL_TYPE_COMBREAK = 3
45 } PVR_EDL_TYPE;
46 ///@}
47 //----------------------------------------------------------------------------
48
49 /*!
50 * @brief "C" Edit definition list entry.
51 *
52 * Structure used to interface in "C" between Kodi and Addon.
53 *
54 * See @ref kodi::addon::PVREDLEntry for description of values.
55 */
56 typedef struct PVR_EDL_ENTRY
57 {
58 int64_t start;
59 int64_t end;
60 enum PVR_EDL_TYPE type;
61 } PVR_EDL_ENTRY;
62
63#ifdef __cplusplus
64}
65#endif /* __cplusplus */
66
67#endif /* !C_API_ADDONINSTANCE_PVR_EDL_H */
diff --git a/xbmc/addons/kodi-dev-kit/include/kodi/c-api/addon-instance/pvr/pvr_epg.h b/xbmc/addons/kodi-dev-kit/include/kodi/c-api/addon-instance/pvr/pvr_epg.h
new file mode 100644
index 0000000..d7512dc
--- /dev/null
+++ b/xbmc/addons/kodi-dev-kit/include/kodi/c-api/addon-instance/pvr/pvr_epg.h
@@ -0,0 +1,658 @@
1/*
2 * Copyright (C) 2005-2018 Team Kodi
3 * This file is part of Kodi - https://kodi.tv
4 *
5 * SPDX-License-Identifier: GPL-2.0-or-later
6 * See LICENSES/README.md for more information.
7 */
8
9#pragma once
10
11#ifndef C_API_ADDONINSTANCE_PVR_EPG_H
12#define C_API_ADDONINSTANCE_PVR_EPG_H
13
14#include "pvr_defines.h"
15
16#include <time.h>
17
18//¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯
19// "C" Definitions group 4 - PVR EPG
20#ifdef __cplusplus
21extern "C"
22{
23#endif /* __cplusplus */
24
25 //============================================================================
26 /// @defgroup cpp_kodi_addon_pvr_Defs_epg_EPG_EVENT enum EPG_EVENT_CONTENTMASK (and sub types)
27 /// @ingroup cpp_kodi_addon_pvr_Defs_epg
28 /// @brief **EPG entry content event types.**\n
29 /// These ID's come from the DVB-SI EIT table "content descriptor"
30 /// Also known under the name "E-book genre assignments".
31 ///
32 /// See [ETSI EN 300 468 V1.14.1 (2014-05)](https://www.etsi.org/deliver/etsi_en/300400_300499/300468/01.14.01_60/en_300468v011401p.pdf)
33 /// about.
34 ///
35 /// Values used by this functions:
36 /// - @ref kodi::addon::PVREPGTag::SetGenreType()
37 /// - @ref kodi::addon::PVREPGTag::SetGenreSubType()
38 /// - @ref kodi::addon::PVRRecording::SetGenreType()
39 /// - @ref kodi::addon::PVRRecording::SetGenreSubType()
40 ///
41 /// Following types are listed here:
42 /// | emum Type | Description
43 /// |-----------|--------------------
44 /// | @ref EPG_EVENT_CONTENTMASK | EPG entry main content to use.
45 /// | @ref EPG_EVENT_CONTENTSUBMASK_MOVIEDRAMA | EPG entry sub content to @ref EPG_EVENT_CONTENTMASK_MOVIEDRAMA event types for sub type of <b>"Movie/Drama"</b>.
46 /// | @ref EPG_EVENT_CONTENTSUBMASK_NEWSCURRENTAFFAIRS | EPG entry sub content to @ref EPG_EVENT_CONTENTMASK_NEWSCURRENTAFFAIRS event types for sub type of <b>"News/Current affairs"</b>.
47 /// | @ref EPG_EVENT_CONTENTSUBMASK_SHOW | EPG entry sub content to @ref EPG_EVENT_CONTENTMASK_SHOW event types for sub type of <b>"Show/Game show"</b>.
48 /// | @ref EPG_EVENT_CONTENTSUBMASK_SPORTS | @brief EPG entry sub content to @ref EPG_EVENT_CONTENTMASK_SPORTS event types for sub type of <b>"Sports"</b>.
49 /// | @ref EPG_EVENT_CONTENTSUBMASK_CHILDRENYOUTH | EPG entry sub content to @ref EPG_EVENT_CONTENTMASK_CHILDRENYOUTH event types for sub type of <b>"Children's/Youth programmes"</b>.
50 /// | @ref EPG_EVENT_CONTENTSUBMASK_MUSICBALLETDANCE | EPG entry sub content to @ref EPG_EVENT_CONTENTMASK_MUSICBALLETDANCE event types for sub type of <b>"Music/Ballet/Dance"</b>.
51 /// | @ref EPG_EVENT_CONTENTSUBMASK_ARTSCULTURE | EPG entry sub content to @ref EPG_EVENT_CONTENTMASK_ARTSCULTURE event types for sub type of <b>"Arts/Culture (without music)"</b>.
52 /// | @ref EPG_EVENT_CONTENTSUBMASK_SOCIALPOLITICALECONOMICS | EPG entry sub content to @ref EPG_EVENT_CONTENTMASK_SOCIALPOLITICALECONOMICS event types for sub type of <b>"Social/Political issues/Economics"</b>.
53 /// | @ref EPG_EVENT_CONTENTSUBMASK_EDUCATIONALSCIENCE | EPG entry sub content to @ref EPG_EVENT_CONTENTMASK_EDUCATIONALSCIENCE event types for sub type of <b>"Education/Science/Factual topics"</b>.
54 /// | @ref EPG_EVENT_CONTENTSUBMASK_LEISUREHOBBIES | EPG entry sub content to @ref EPG_EVENT_CONTENTMASK_LEISUREHOBBIES event types for sub type of <b>"Leisure hobbies"</b>.
55 /// | @ref EPG_EVENT_CONTENTSUBMASK_SPECIAL | EPG entry sub content to @ref EPG_EVENT_CONTENTMASK_SPECIAL event types for sub type of <b>"Special characteristics"</b>.
56 ///@{
57
58 //============================================================================
59 /// @ingroup cpp_kodi_addon_pvr_Defs_epg_EPG_EVENT
60 /// @brief EPG entry main content to use.
61 ///
62 ///@{
63 typedef enum EPG_EVENT_CONTENTMASK
64 {
65 /// @brief __0x00__ : Undefined content mask entry.
66 EPG_EVENT_CONTENTMASK_UNDEFINED = 0x00,
67
68 /// @brief __0x10__ : Movie/Drama.\n
69 /// \n
70 /// See @ref EPG_EVENT_CONTENTSUBMASK_MOVIEDRAMA about related sub types.
71 EPG_EVENT_CONTENTMASK_MOVIEDRAMA = 0x10,
72
73 /// @brief __0x20__ : News/Current affairs.\n
74 /// \n
75 /// See @ref EPG_EVENT_CONTENTSUBMASK_NEWSCURRENTAFFAIRS about related sub types.
76 EPG_EVENT_CONTENTMASK_NEWSCURRENTAFFAIRS = 0x20,
77
78 /// @brief __0x30__ : Show/Game show.\n
79 /// \n
80 /// See @ref EPG_EVENT_CONTENTSUBMASK_SHOW about related sub types.
81 EPG_EVENT_CONTENTMASK_SHOW = 0x30,
82
83 /// @brief __0x40__ : Sports.\n
84 /// \n
85 /// See @ref EPG_EVENT_CONTENTSUBMASK_SPORTS about related sub types.
86 EPG_EVENT_CONTENTMASK_SPORTS = 0x40,
87
88 /// @brief __0x50__ : Children's/Youth programmes.\n
89 /// \n
90 /// See @ref EPG_EVENT_CONTENTSUBMASK_CHILDRENYOUTH about related sub types.
91 EPG_EVENT_CONTENTMASK_CHILDRENYOUTH = 0x50,
92
93 /// @brief __0x60__ : Music/Ballet/Dance.\n
94 /// \n
95 /// See @ref EPG_EVENT_CONTENTSUBMASK_MUSICBALLETDANCE about related sub types.
96 EPG_EVENT_CONTENTMASK_MUSICBALLETDANCE = 0x60,
97
98 /// @brief __0x70__ : Arts/Culture (without music).\n
99 /// \n
100 /// See @ref EPG_EVENT_CONTENTSUBMASK_ARTSCULTURE about related sub types.
101 EPG_EVENT_CONTENTMASK_ARTSCULTURE = 0x70,
102
103 /// @brief __0x80__ : Social/Political issues/Economics.\n
104 /// \n
105 /// See @ref EPG_EVENT_CONTENTSUBMASK_SOCIALPOLITICALECONOMICS about related sub types.
106 EPG_EVENT_CONTENTMASK_SOCIALPOLITICALECONOMICS = 0x80,
107
108 /// @brief __0x90__ : Education/Science/Factual topics.\n
109 /// \n
110 /// See @ref EPG_EVENT_CONTENTSUBMASK_EDUCATIONALSCIENCE about related sub types.
111 EPG_EVENT_CONTENTMASK_EDUCATIONALSCIENCE = 0x90,
112
113 /// @brief __0xA0__ : Leisure hobbies.\n
114 /// \n
115 /// See @ref EPG_EVENT_CONTENTSUBMASK_LEISUREHOBBIES about related sub types.
116 EPG_EVENT_CONTENTMASK_LEISUREHOBBIES = 0xA0,
117
118 /// @brief __0xB0__ : Special characteristics.\n
119 /// \n
120 /// See @ref EPG_EVENT_CONTENTSUBMASK_SPECIAL about related sub types.
121 EPG_EVENT_CONTENTMASK_SPECIAL = 0xB0,
122
123 /// @brief __0xF0__ User defined.
124 EPG_EVENT_CONTENTMASK_USERDEFINED = 0xF0,
125
126 /// @brief Used to override standard genre types with a own name about.\n
127 /// \n
128 /// Set to this value @ref EPG_GENRE_USE_STRING on following places:
129 /// - @ref kodi::addon::PVREPGTag::SetGenreType()
130 /// - @ref kodi::addon::PVREPGTag::SetGenreSubType()
131 /// - @ref kodi::addon::PVRRecording::SetGenreType()
132 /// - @ref kodi::addon::PVRRecording::SetGenreSubType()
133 ///
134 /// @warning Value here is not a [ETSI EN 300 468 V1.14.1 (2014-05)](https://www.etsi.org/deliver/etsi_en/300400_300499/300468/01.14.01_60/en_300468v011401p.pdf)
135 /// conform.
136 ///
137 /// @note This is a own Kodi definition to set that genre is given by own
138 /// string. Used on @ref kodi::addon::PVREPGTag::SetGenreDescription() and
139 /// @ref kodi::addon::PVRRecording::SetGenreDescription()
140 EPG_GENRE_USE_STRING = 0x100
141 } EPG_EVENT_CONTENTMASK;
142 ///@}
143 //----------------------------------------------------------------------------
144
145 //============================================================================
146 /// @ingroup cpp_kodi_addon_pvr_Defs_epg_EPG_EVENT
147 /// @brief EPG entry sub content to @ref EPG_EVENT_CONTENTMASK_MOVIEDRAMA event
148 /// types for sub type of <b>"Movie/Drama"</b>.
149 ///
150 ///@{
151 typedef enum EPG_EVENT_CONTENTSUBMASK_MOVIEDRAMA
152 {
153 /// @brief __0x0__ : Movie/drama (general).
154 EPG_EVENT_CONTENTSUBMASK_MOVIEDRAMA_GENERAL = 0x0,
155
156 /// @brief __0x1__ : Detective/thriller.
157 EPG_EVENT_CONTENTSUBMASK_MOVIEDRAMA_DETECTIVE_THRILLER = 0x1,
158
159 /// @brief __0x2__ : Adventure/western/war.
160 EPG_EVENT_CONTENTSUBMASK_MOVIEDRAMA_ADVENTURE_WESTERN_WAR = 0x2,
161
162 /// @brief __0x3__ : Science fiction/fantasy/horror.
163 EPG_EVENT_CONTENTSUBMASK_MOVIEDRAMA_SCIENCEFICTION_FANTASY_HORROR = 0x3,
164
165 /// @brief __0x4__ : Comedy.
166 EPG_EVENT_CONTENTSUBMASK_MOVIEDRAMA_COMEDY = 0x4,
167
168 /// @brief __0x5__ : Soap/melodrama/folkloric.
169 EPG_EVENT_CONTENTSUBMASK_MOVIEDRAMA_SOAP_MELODRAMA_FOLKLORIC = 0x5,
170
171 /// @brief __0x6__ : Romance.
172 EPG_EVENT_CONTENTSUBMASK_MOVIEDRAMA_ROMANCE = 0x6,
173
174 /// @brief __0x7__ : Serious/classical/religious/historical movie/drama.
175 EPG_EVENT_CONTENTSUBMASK_MOVIEDRAMA_SERIOUS_CLASSICAL_RELIGIOUS_HISTORICAL = 0x7,
176
177 /// @brief __0x8__ : Adult movie/drama.
178 EPG_EVENT_CONTENTSUBMASK_MOVIEDRAMA_ADULT = 0x8,
179
180 /// @brief __0xF__ : User defined.
181 EPG_EVENT_CONTENTSUBMASK_MOVIEDRAMA_USERDEFINED = 0xF
182 } EPG_EVENT_CONTENTSUBMASK_MOVIEDRAMA;
183 ///@}
184 //----------------------------------------------------------------------------
185
186 //============================================================================
187 /// @ingroup cpp_kodi_addon_pvr_Defs_epg_EPG_EVENT
188 /// @brief EPG entry sub content to @ref EPG_EVENT_CONTENTMASK_NEWSCURRENTAFFAIRS event
189 /// types for sub type of <b>"News/Current affairs"</b>.
190 ///
191 typedef enum EPG_EVENT_CONTENTSUBMASK_NEWSCURRENTAFFAIRS
192 {
193 /// @brief __0x0__ : News/current affairs (general).
194 EPG_EVENT_CONTENTSUBMASK_NEWSCURRENTAFFAIRS_GENERAL = 0x0,
195
196 /// @brief __0x1__ : News/weather report.
197 EPG_EVENT_CONTENTSUBMASK_NEWSCURRENTAFFAIRS_WEATHER = 0x1,
198
199 /// @brief __0x2__ : News magazine.
200 EPG_EVENT_CONTENTSUBMASK_NEWSCURRENTAFFAIRS_MAGAZINE = 0x2,
201
202 /// @brief __0x3__ : Documentary.
203 EPG_EVENT_CONTENTSUBMASK_NEWSCURRENTAFFAIRS_DOCUMENTARY = 0x3,
204
205 /// @brief __0x4__ : Discussion/interview/debate
206 EPG_EVENT_CONTENTSUBMASK_NEWSCURRENTAFFAIRS_DISCUSSION_INTERVIEW_DEBATE = 0x4,
207
208 /// @brief __0xF__ : User defined.
209 EPG_EVENT_CONTENTSUBMASK_NEWSCURRENTAFFAIRS_USERDEFINED = 0xF
210 } EPG_EVENT_CONTENTSUBMASK_NEWSCURRENTAFFAIRS;
211 //----------------------------------------------------------------------------
212
213 //============================================================================
214 /// @ingroup cpp_kodi_addon_pvr_Defs_epg_EPG_EVENT
215 /// @brief EPG entry sub content to @ref EPG_EVENT_CONTENTMASK_SHOW event
216 /// types for sub type of <b>"Show/Game show"</b>.
217 ///
218 typedef enum EPG_EVENT_CONTENTSUBMASK_SHOW
219 {
220 /// @brief __0x0__ : Show/game show (general).
221 EPG_EVENT_CONTENTSUBMASK_SHOW_GENERAL = 0x0,
222
223 /// @brief __0x1__ : Game show/quiz/contest.
224 EPG_EVENT_CONTENTSUBMASK_SHOW_GAMESHOW_QUIZ_CONTEST = 0x1,
225
226 /// @brief __0x2__ : Variety show.
227 EPG_EVENT_CONTENTSUBMASK_SHOW_VARIETY_SHOW = 0x2,
228
229 /// @brief __0x3__ : Talk show.
230 EPG_EVENT_CONTENTSUBMASK_SHOW_TALK_SHOW = 0x3,
231
232 /// @brief __0xF__ : User defined.
233 EPG_EVENT_CONTENTSUBMASK_SHOW_USERDEFINED = 0xF
234 } EPG_EVENT_CONTENTSUBMASK_SHOW;
235 //----------------------------------------------------------------------------
236
237 //============================================================================
238 /// @ingroup cpp_kodi_addon_pvr_Defs_epg_EPG_EVENT
239 /// @brief EPG entry sub content to @ref EPG_EVENT_CONTENTMASK_SPORTS event
240 /// types for sub type of <b>"Sports"</b>.
241 ///
242 typedef enum EPG_EVENT_CONTENTSUBMASK_SPORTS
243 {
244 /// @brief __0x0__ : Sports (general).
245 EPG_EVENT_CONTENTSUBMASK_SPORTS_GENERAL = 0x0,
246
247 /// @brief __0x1__ : Special events (Olympic Games, World Cup, etc.).
248 EPG_EVENT_CONTENTSUBMASK_SPORTS_OLYMPICGAMES_WORLDCUP = 0x1,
249
250 /// @brief __0x2__ : Sports magazines.
251 EPG_EVENT_CONTENTSUBMASK_SPORTS_SPORTS_MAGAZINES = 0x2,
252
253 /// @brief __0x3__ : Football/soccer.
254 EPG_EVENT_CONTENTSUBMASK_SPORTS_FOOTBALL_SOCCER = 0x3,
255
256 /// @brief __0x4__ : Tennis/squash.
257 EPG_EVENT_CONTENTSUBMASK_SPORTS_TENNIS_SQUASH = 0x4,
258
259 /// @brief __0x5__ : Team sports (excluding football).
260 EPG_EVENT_CONTENTSUBMASK_SPORTS_TEAMSPORTS = 0x5,
261
262 /// @brief __0x6__ : Athletics.
263 EPG_EVENT_CONTENTSUBMASK_SPORTS_ATHLETICS = 0x6,
264
265 /// @brief __0x7__ : Motor sport.
266 EPG_EVENT_CONTENTSUBMASK_SPORTS_MOTORSPORT = 0x7,
267
268 /// @brief __0x8__ : Water sport.
269 EPG_EVENT_CONTENTSUBMASK_SPORTS_WATERSPORT = 0x8,
270
271 /// @brief __0x9__ : Winter sports.
272 EPG_EVENT_CONTENTSUBMASK_SPORTS_WINTERSPORTS = 0x9,
273
274 /// @brief __0xA__ : Equestrian.
275 EPG_EVENT_CONTENTSUBMASK_SPORTS_EQUESTRIAN = 0xA,
276
277 /// @brief __0xB__ : Martial sports.
278 EPG_EVENT_CONTENTSUBMASK_SPORTS_MARTIALSPORTS = 0xB,
279
280 /// @brief __0xF__ : User defined.
281 EPG_EVENT_CONTENTSUBMASK_SPORTS_USERDEFINED = 0xF
282 } EPG_EVENT_CONTENTSUBMASK_SPORTS;
283 //----------------------------------------------------------------------------
284
285 //============================================================================
286 /// @ingroup cpp_kodi_addon_pvr_Defs_epg_EPG_EVENT
287 /// @brief EPG entry sub content to @ref EPG_EVENT_CONTENTMASK_CHILDRENYOUTH event
288 /// types for sub type of <b>"Children's/Youth programmes"</b>.
289 ///
290 typedef enum EPG_EVENT_CONTENTSUBMASK_CHILDRENYOUTH
291 {
292 /// @brief __0x0__ : Children's/youth programmes (general).
293 EPG_EVENT_CONTENTSUBMASK_CHILDRENYOUTH_GENERAL = 0x0,
294
295 /// @brief __0x1__ : Pre-school children's programmes.
296 EPG_EVENT_CONTENTSUBMASK_CHILDRENYOUTH_PRESCHOOL_CHILDREN = 0x1,
297
298 /// @brief __0x2__ : Entertainment programmes for 6 to 14.
299 EPG_EVENT_CONTENTSUBMASK_CHILDRENYOUTH_ENTERTAIN_6TO14 = 0x2,
300
301 /// @brief __0x3__ : Entertainment programmes for 10 to 16.
302 EPG_EVENT_CONTENTSUBMASK_CHILDRENYOUTH_ENTERTAIN_10TO16 = 0x3,
303
304 /// @brief __0x4__ : Informational/educational/school programmes.
305 EPG_EVENT_CONTENTSUBMASK_CHILDRENYOUTH_INFORMATIONAL_EDUCATIONAL_SCHOOL = 0x4,
306
307 /// @brief __0x5__ : Cartoons/puppets.
308 EPG_EVENT_CONTENTSUBMASK_CHILDRENYOUTH_CARTOONS_PUPPETS = 0x5,
309
310 /// @brief __0xF__ : User defined.
311 EPG_EVENT_CONTENTSUBMASK_CHILDRENYOUTH_USERDEFINED = 0xF
312 } EPG_EVENT_CONTENTSUBMASK_CHILDRENYOUTH;
313 //----------------------------------------------------------------------------
314
315 //============================================================================
316 /// @ingroup cpp_kodi_addon_pvr_Defs_epg_EPG_EVENT
317 /// @brief EPG entry sub content to @ref EPG_EVENT_CONTENTMASK_MUSICBALLETDANCE event
318 /// types for sub type of <b>"Music/Ballet/Dance"</b>.
319 ///
320 typedef enum EPG_EVENT_CONTENTSUBMASK_MUSICBALLETDANCE
321 {
322 /// @brief __0x0__ : Music/ballet/dance (general).
323 EPG_EVENT_CONTENTSUBMASK_MUSICBALLETDANCE_GENERAL = 0x0,
324
325 /// @brief __0x1__ : Rock/pop.
326 EPG_EVENT_CONTENTSUBMASK_MUSICBALLETDANCE_ROCKPOP = 0x1,
327
328 /// @brief __0x2__ : Serious music/classical music.
329 EPG_EVENT_CONTENTSUBMASK_MUSICBALLETDANCE_SERIOUSMUSIC_CLASSICALMUSIC = 0x2,
330
331 /// @brief __0x3__ : Folk/traditional music.
332 EPG_EVENT_CONTENTSUBMASK_MUSICBALLETDANCE_FOLK_TRADITIONAL_MUSIC = 0x3,
333
334 /// @brief __0x4__ : Jazz.
335 EPG_EVENT_CONTENTSUBMASK_MUSICBALLETDANCE_JAZZ = 0x4,
336
337 /// @brief __0x5__ : Musical/opera.
338 EPG_EVENT_CONTENTSUBMASK_MUSICBALLETDANCE_MUSICAL_OPERA = 0x5,
339
340 /// @brief __0x6__ : Ballet.
341 EPG_EVENT_CONTENTSUBMASK_MUSICBALLETDANCE_BALLET = 0x6,
342
343 /// @brief __0xF__ : User defined.
344 EPG_EVENT_CONTENTSUBMASK_MUSICBALLETDANCE_USERDEFINED = 0xF
345 } EPG_EVENT_CONTENTSUBMASK_MUSICBALLETDANCE;
346 //----------------------------------------------------------------------------
347
348 //============================================================================
349 /// @ingroup cpp_kodi_addon_pvr_Defs_epg_EPG_EVENT
350 /// @brief EPG entry sub content to @ref EPG_EVENT_CONTENTMASK_ARTSCULTURE event
351 /// types for sub type of <b>"Arts/Culture (without music)"</b>.
352 ///
353 typedef enum EPG_EVENT_CONTENTSUBMASK_ARTSCULTURE
354 {
355 /// @brief __0x0__ : Arts/culture (without music, general).
356 EPG_EVENT_CONTENTSUBMASK_ARTSCULTURE_GENERAL = 0x0,
357
358 /// @brief __0x1__ : Performing arts.
359 EPG_EVENT_CONTENTSUBMASK_ARTSCULTURE_PERFORMINGARTS = 0x1,
360
361 /// @brief __0x2__ : Fine arts.
362 EPG_EVENT_CONTENTSUBMASK_ARTSCULTURE_FINEARTS = 0x2,
363
364 /// @brief __0x3__ : Religion.
365 EPG_EVENT_CONTENTSUBMASK_ARTSCULTURE_RELIGION = 0x3,
366
367 /// @brief __0x4__ : Popular culture/traditional arts.
368 EPG_EVENT_CONTENTSUBMASK_ARTSCULTURE_POPULARCULTURE_TRADITIONALARTS = 0x4,
369
370 /// @brief __0x5__ : Literature.
371 EPG_EVENT_CONTENTSUBMASK_ARTSCULTURE_LITERATURE = 0x5,
372
373 /// @brief __0x6__ : Film/cinema.
374 EPG_EVENT_CONTENTSUBMASK_ARTSCULTURE_FILM_CINEMA = 0x6,
375
376 /// @brief __0x7__ : Experimental film/video.
377 EPG_EVENT_CONTENTSUBMASK_ARTSCULTURE_EXPERIMENTALFILM_VIDEO = 0x7,
378
379 /// @brief __0x8__ : Broadcasting/press.
380 EPG_EVENT_CONTENTSUBMASK_ARTSCULTURE_BROADCASTING_PRESS = 0x8,
381
382 /// @brief __0x9__ : New media.
383 EPG_EVENT_CONTENTSUBMASK_ARTSCULTURE_NEWMEDIA = 0x9,
384
385 /// @brief __0xA__ : Arts/culture magazines.
386 EPG_EVENT_CONTENTSUBMASK_ARTSCULTURE_ARTS_CULTUREMAGAZINES = 0xA,
387
388 /// @brief __0xB__ : Fashion.
389 EPG_EVENT_CONTENTSUBMASK_ARTSCULTURE_FASHION = 0xB,
390
391 /// @brief __0xF__ : User defined.
392 EPG_EVENT_CONTENTSUBMASK_ARTSCULTURE_USERDEFINED = 0xF
393 } EPG_EVENT_CONTENTSUBMASK_ARTSCULTURE;
394 //----------------------------------------------------------------------------
395
396 //============================================================================
397 /// @ingroup cpp_kodi_addon_pvr_Defs_epg_EPG_EVENT
398 /// @brief EPG entry sub content to @ref EPG_EVENT_CONTENTMASK_SOCIALPOLITICALECONOMICS event
399 /// types for sub type of <b>"Social/Political issues/Economics"</b>.
400 ///
401 typedef enum EPG_EVENT_CONTENTSUBMASK_SOCIALPOLITICALECONOMICS
402 {
403 /// @brief __0x0__ : Social/political issues/economics (general).
404 EPG_EVENT_CONTENTSUBMASK_SOCIALPOLITICALECONOMICS_GENERAL = 0x0,
405
406 /// @brief __0x1__ : Magazines/reports/documentary.
407 EPG_EVENT_CONTENTSUBMASK_SOCIALPOLITICALECONOMICS_MAGAZINES_REPORTS_DOCUMENTARY = 0x1,
408
409 /// @brief __0x2__ : Economics/social advisory.
410 EPG_EVENT_CONTENTSUBMASK_SOCIALPOLITICALECONOMICS_ECONOMICS_SOCIALADVISORY = 0x2,
411
412 /// @brief __0x3__ : Remarkable people.
413 EPG_EVENT_CONTENTSUBMASK_SOCIALPOLITICALECONOMICS_REMARKABLEPEOPLE = 0x3,
414
415 /// @brief __0xF__ : User defined.
416 EPG_EVENT_CONTENTSUBMASK_SOCIALPOLITICALECONOMICS_USERDEFINED = 0xF
417 } EPG_EVENT_CONTENTSUBMASK_SOCIALPOLITICALECONOMICS;
418 //----------------------------------------------------------------------------
419
420 //============================================================================
421 /// @ingroup cpp_kodi_addon_pvr_Defs_epg_EPG_EVENT
422 /// @brief EPG entry sub content to @ref EPG_EVENT_CONTENTMASK_EDUCATIONALSCIENCE event
423 /// types for sub type of <b>"Education/Science/Factual topics"</b>.
424 ///
425 typedef enum EPG_EVENT_CONTENTSUBMASK_EDUCATIONALSCIENCE
426 {
427 /// @brief __0x0__ : Education/science/factual topics (general).
428 EPG_EVENT_CONTENTSUBMASK_EDUCATIONALSCIENCE_GENERAL = 0x0,
429
430 /// @brief __0x1__ : Nature/animals/environment.
431 EPG_EVENT_CONTENTSUBMASK_EDUCATIONALSCIENCE_NATURE_ANIMALS_ENVIRONMENT = 0x1,
432
433 /// @brief __0x2__ : Technology/natural sciences.
434 EPG_EVENT_CONTENTSUBMASK_EDUCATIONALSCIENCE_TECHNOLOGY_NATURALSCIENCES = 0x2,
435
436 /// @brief __0x3__ : Medicine/physiology/psychology.
437 EPG_EVENT_CONTENTSUBMASK_EDUCATIONALSCIENCE_MEDICINE_PHYSIOLOGY_PSYCHOLOGY = 0x3,
438
439 /// @brief __0x4__ : Foreign countries/expeditions.
440 EPG_EVENT_CONTENTSUBMASK_EDUCATIONALSCIENCE_FOREIGNCOUNTRIES_EXPEDITIONS = 0x4,
441
442 /// @brief __0x5__ : Social/spiritual sciences.
443 EPG_EVENT_CONTENTSUBMASK_EDUCATIONALSCIENCE_SOCIAL_SPIRITUALSCIENCES = 0x5,
444
445 /// @brief __0x6__ : Further education.
446 EPG_EVENT_CONTENTSUBMASK_EDUCATIONALSCIENCE_FURTHEREDUCATION = 0x6,
447
448 /// @brief __0x7__ : Languages.
449 EPG_EVENT_CONTENTSUBMASK_EDUCATIONALSCIENCE_LANGUAGES = 0x7,
450
451 /// @brief __0xF__ : User defined.
452 EPG_EVENT_CONTENTSUBMASK_EDUCATIONALSCIENCE_USERDEFINED = 0xF
453 } EPG_EVENT_CONTENTSUBMASK_EDUCATIONALSCIENCE;
454 //----------------------------------------------------------------------------
455
456 //============================================================================
457 /// @ingroup cpp_kodi_addon_pvr_Defs_epg_EPG_EVENT
458 /// @brief EPG entry sub content to @ref EPG_EVENT_CONTENTMASK_LEISUREHOBBIES event
459 /// types for sub type of <b>"Leisure hobbies"</b>.
460 ///
461 typedef enum EPG_EVENT_CONTENTSUBMASK_LEISUREHOBBIES
462 {
463 /// @brief __0x0__ : Leisure hobbies (general) .
464 EPG_EVENT_CONTENTSUBMASK_LEISUREHOBBIES_GENERAL = 0x0,
465
466 /// @brief __0x1__ : Tourism/travel.
467 EPG_EVENT_CONTENTSUBMASK_LEISUREHOBBIES_TOURISM_TRAVEL = 0x1,
468
469 /// @brief __0x2__ : Handicraft.
470 EPG_EVENT_CONTENTSUBMASK_LEISUREHOBBIES_HANDICRAFT = 0x2,
471
472 /// @brief __0x3__ : Motoring.
473 EPG_EVENT_CONTENTSUBMASK_LEISUREHOBBIES_MOTORING = 0x3,
474
475 /// @brief __0x4__ : Fitness and health.
476 EPG_EVENT_CONTENTSUBMASK_LEISUREHOBBIES_FITNESSANDHEALTH = 0x4,
477
478 /// @brief __0x5__ : Cooking.
479 EPG_EVENT_CONTENTSUBMASK_LEISUREHOBBIES_COOKING = 0x5,
480
481 /// @brief __0x6__ : Advertisement/shopping.
482 EPG_EVENT_CONTENTSUBMASK_LEISUREHOBBIES_ADVERTISEMENT_SHOPPING = 0x6,
483
484 /// @brief __0x7__ : Gardening.
485 EPG_EVENT_CONTENTSUBMASK_LEISUREHOBBIES_GARDENING = 0x7,
486
487 /// @brief __0xF__ : User defined.
488 EPG_EVENT_CONTENTSUBMASK_LEISUREHOBBIES_USERDEFINED = 0xF
489 } EPG_EVENT_CONTENTSUBMASK_LEISUREHOBBIES;
490 //----------------------------------------------------------------------------
491
492 //============================================================================
493 /// @ingroup cpp_kodi_addon_pvr_Defs_epg_EPG_EVENT
494 /// @brief EPG entry sub content to @ref EPG_EVENT_CONTENTMASK_SPECIAL event
495 /// types for sub type of <b>"Special characteristics"</b>.
496 ///
497 typedef enum EPG_EVENT_CONTENTSUBMASK_SPECIAL
498 {
499 /// @brief __0x0__ : Special characteristics / Original language (general).
500 EPG_EVENT_CONTENTSUBMASK_SPECIAL_GENERAL = 0x0,
501
502 /// @brief __0x1__ : Black and white.
503 EPG_EVENT_CONTENTSUBMASK_SPECIAL_BLACKANDWHITE = 0x1,
504
505 /// @brief __0x2__ : Unpublished.
506 EPG_EVENT_CONTENTSUBMASK_SPECIAL_UNPUBLISHED = 0x2,
507
508 /// @brief __0x3__ : Live broadcast.
509 EPG_EVENT_CONTENTSUBMASK_SPECIAL_LIVEBROADCAST = 0x3,
510
511 /// @brief __0x4__ : Plano-stereoscopic.
512 EPG_EVENT_CONTENTSUBMASK_SPECIAL_PLANOSTEREOSCOPIC = 0x4,
513
514 /// @brief __0x5__ : Local or regional.
515 EPG_EVENT_CONTENTSUBMASK_SPECIAL_LOCALORREGIONAL = 0x5,
516
517 /// @brief __0xF__ : User defined.
518 EPG_EVENT_CONTENTSUBMASK_SPECIAL_USERDEFINED = 0xF
519 } EPG_EVENT_CONTENTSUBMASK_SPECIAL;
520 //----------------------------------------------------------------------------
521
522 ///@}
523
524 //============================================================================
525 /// @ingroup cpp_kodi_addon_pvr_Defs_epg
526 /// @brief Separator to use in strings containing different tokens, for example
527 /// writers, directors, actors of an event.
528 ///
529 #define EPG_STRING_TOKEN_SEPARATOR ","
530 //----------------------------------------------------------------------------
531
532 //============================================================================
533 /// @defgroup cpp_kodi_addon_pvr_Defs_epg_EPG_TAG_FLAG enum EPG_TAG_FLAG
534 /// @ingroup cpp_kodi_addon_pvr_Defs_epg
535 /// @brief <b>Bit field of independent flags associated with the EPG entry.</b>\n
536 /// Values used by @ref kodi::addon::PVREPGTag::SetFlags().
537 ///
538 /// Here's example about the use of this:
539 /// ~~~~~~~~~~~~~{.cpp}
540 /// kodi::addon::PVREPGTag tag;
541 /// tag.SetFlags(EPG_TAG_FLAG_IS_SERIES | EPG_TAG_FLAG_IS_NEW);
542 /// ~~~~~~~~~~~~~
543 ///
544 ///@{
545 typedef enum EPG_TAG_FLAG
546 {
547 /// @brief __0000 0000__ : Nothing special to say about this entry.
548 EPG_TAG_FLAG_UNDEFINED = 0,
549
550 /// @brief __0000 0001__ : This EPG entry is part of a series.
551 EPG_TAG_FLAG_IS_SERIES = (1 << 0),
552
553 /// @brief __0000 0010__ : This EPG entry will be flagged as new.
554 EPG_TAG_FLAG_IS_NEW = (1 << 1),
555
556 /// @brief __0000 0100__ : This EPG entry will be flagged as a premiere.
557 EPG_TAG_FLAG_IS_PREMIERE = (1 << 2),
558
559 /// @brief __0000 1000__ : This EPG entry will be flagged as a finale.
560 EPG_TAG_FLAG_IS_FINALE = (1 << 3),
561
562 /// @brief __0001 0000__ : This EPG entry will be flagged as live.
563 EPG_TAG_FLAG_IS_LIVE = (1 << 4),
564 } EPG_TAG_FLAG;
565 ///@}
566 //----------------------------------------------------------------------------
567
568 //============================================================================
569 /// @ingroup cpp_kodi_addon_pvr_Defs_epg
570 /// @brief Special PVREPGTag::SetUniqueBroadcastId value
571 ///
572 /// Special @ref kodi::addon::PVREPGTag::SetUniqueBroadcastId() value to
573 /// indicate that a tag has not a valid EPG event uid.
574 ///
575 #define EPG_TAG_INVALID_UID 0
576 //----------------------------------------------------------------------------
577
578 //============================================================================
579 /// @ingroup cpp_kodi_addon_pvr_Defs_epg
580 /// @brief Special @ref kodi::addon::PVREPGTag::SetSeriesNumber(), @ref kodi::addon::PVREPGTag::SetEpisodeNumber()
581 /// and @ref kodi::addon::PVREPGTag::SetEpisodePartNumber() value to indicate
582 /// it is not to be used.
583 ///
584 #define EPG_TAG_INVALID_SERIES_EPISODE -1
585 //----------------------------------------------------------------------------
586
587 //============================================================================
588 /// @ingroup cpp_kodi_addon_pvr_Defs_epg
589 /// @brief Timeframe value for use with @ref kodi::addon::CInstancePVRClient::SetEPGTimeFrame()
590 /// function to indicate "no timeframe".
591 ///
592 #define EPG_TIMEFRAME_UNLIMITED -1
593 //----------------------------------------------------------------------------
594
595 //============================================================================
596 /// @defgroup cpp_kodi_addon_pvr_Defs_epg_EPG_EVENT_STATE enum EPG_EVENT_STATE
597 /// @ingroup cpp_kodi_addon_pvr_Defs_epg
598 /// @brief **EPG event states.**\n
599 /// Used with @ref kodi::addon::CInstancePVRClient::EpgEventStateChange()
600 /// callback.
601 ///
602 ///@{
603 typedef enum EPG_EVENT_STATE
604 {
605 /// @brief __0__ : Event created.
606 EPG_EVENT_CREATED = 0,
607
608 /// @brief __1__ : Event updated.
609 EPG_EVENT_UPDATED = 1,
610
611 /// @brief __2__ : Event deleted.
612 EPG_EVENT_DELETED = 2,
613 } EPG_EVENT_STATE;
614 ///@}
615 //----------------------------------------------------------------------------
616
617 /*!
618 * @brief "C" PVR add-on channel group member.
619 *
620 * Structure used to interface in "C" between Kodi and Addon.
621 *
622 * See @ref kodi::addon::PVREPGTag for description of values.
623 */
624 typedef struct EPG_TAG
625 {
626 unsigned int iUniqueBroadcastId;
627 unsigned int iUniqueChannelId;
628 const char* strTitle;
629 time_t startTime;
630 time_t endTime;
631 const char* strPlotOutline;
632 const char* strPlot;
633 const char* strOriginalTitle;
634 const char* strCast;
635 const char* strDirector;
636 const char* strWriter;
637 int iYear;
638 const char* strIMDBNumber;
639 const char* strIconPath;
640 int iGenreType;
641 int iGenreSubType;
642 const char* strGenreDescription;
643 const char* strFirstAired;
644 int iParentalRating;
645 int iStarRating;
646 int iSeriesNumber;
647 int iEpisodeNumber;
648 int iEpisodePartNumber;
649 const char* strEpisodeName;
650 unsigned int iFlags;
651 const char* strSeriesLink;
652 } EPG_TAG;
653
654#ifdef __cplusplus
655}
656#endif /* __cplusplus */
657
658#endif /* !C_API_ADDONINSTANCE_PVR_EPG_H */
diff --git a/xbmc/addons/kodi-dev-kit/include/kodi/c-api/addon-instance/pvr/pvr_general.h b/xbmc/addons/kodi-dev-kit/include/kodi/c-api/addon-instance/pvr/pvr_general.h
new file mode 100644
index 0000000..e2136f6
--- /dev/null
+++ b/xbmc/addons/kodi-dev-kit/include/kodi/c-api/addon-instance/pvr/pvr_general.h
@@ -0,0 +1,295 @@
1/*
2 * Copyright (C) 2005-2018 Team Kodi
3 * This file is part of Kodi - https://kodi.tv
4 *
5 * SPDX-License-Identifier: GPL-2.0-or-later
6 * See LICENSES/README.md for more information.
7 */
8
9#pragma once
10
11#ifndef C_API_ADDONINSTANCE_PVR_GENERAL_H
12#define C_API_ADDONINSTANCE_PVR_GENERAL_H
13
14#include "pvr_defines.h"
15
16#ifdef BUILD_KODI_ADDON
17#include "../../../InputStreamConstants.h"
18#else
19#include "cores/VideoPlayer/Interface/Addon/InputStreamConstants.h"
20#endif
21
22#include <stdbool.h>
23
24//¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯
25// "C" Definitions group 1 - General PVR
26#ifdef __cplusplus
27extern "C"
28{
29#endif /* __cplusplus */
30
31 //============================================================================
32 /// @defgroup cpp_kodi_addon_pvr_Defs_General_PVR_ERROR enum PVR_ERROR
33 /// @ingroup cpp_kodi_addon_pvr_Defs_General
34 /// @brief **PVR add-on error codes**\n
35 /// Used as return values on most PVR related functions.
36 ///
37 /// In this way, a PVR instance signals errors in its processing and, under
38 /// certain conditions, allows Kodi to make corrections.
39 ///
40 ///@{
41 typedef enum PVR_ERROR
42 {
43 /// @brief __0__ : No error occurred.
44 PVR_ERROR_NO_ERROR = 0,
45
46 /// @brief __-1__ : An unknown error occurred.
47 PVR_ERROR_UNKNOWN = -1,
48
49 /// @brief __-2__ : The method that Kodi called is not implemented by the add-on.
50 PVR_ERROR_NOT_IMPLEMENTED = -2,
51
52 /// @brief __-3__ : The backend reported an error, or the add-on isn't connected.
53 PVR_ERROR_SERVER_ERROR = -3,
54
55 /// @brief __-4__ : The command was sent to the backend, but the response timed out.
56 PVR_ERROR_SERVER_TIMEOUT = -4,
57
58 /// @brief __-5__ : The command was rejected by the backend.
59 PVR_ERROR_REJECTED = -5,
60
61 /// @brief __-6__ : The requested item can not be added, because it's already present.
62 PVR_ERROR_ALREADY_PRESENT = -6,
63
64 /// @brief __-7__ : The parameters of the method that was called are invalid for this
65 /// operation.
66 PVR_ERROR_INVALID_PARAMETERS = -7,
67
68 /// @brief __-8__ : A recording is running, so the timer can't be deleted without
69 /// doing a forced delete.
70 PVR_ERROR_RECORDING_RUNNING = -8,
71
72 /// @brief __-9__ : The command failed.
73 PVR_ERROR_FAILED = -9,
74 } PVR_ERROR;
75 ///@}
76 //----------------------------------------------------------------------------
77
78 //============================================================================
79 /// @defgroup cpp_kodi_addon_pvr_Defs_General_PVR_CONNECTION_STATE enum PVR_CONNECTION_STATE
80 /// @ingroup cpp_kodi_addon_pvr_Defs_General
81 /// @brief **PVR backend connection states**\n
82 /// Used with @ref kodi::addon::CInstancePVRClient::ConnectionStateChange() callback.
83 ///
84 /// With this, a PVR instance signals that Kodi should perform special
85 /// operations.
86 ///
87 ///@{
88 typedef enum PVR_CONNECTION_STATE
89 {
90 /// @brief __0__ : Unknown state (e.g. not yet tried to connect).
91 PVR_CONNECTION_STATE_UNKNOWN = 0,
92
93 /// @brief __1__ : Backend server is not reachable (e.g. server not existing or
94 /// network down).
95 PVR_CONNECTION_STATE_SERVER_UNREACHABLE = 1,
96
97 /// @brief __2__ : Backend server is reachable, but there is not the expected type of
98 /// server running (e.g. HTSP required, but FTP running at given server:port).
99 PVR_CONNECTION_STATE_SERVER_MISMATCH = 2,
100
101 /// @brief __3__ : Backend server is reachable, but server version does not match
102 /// client requirements.
103 PVR_CONNECTION_STATE_VERSION_MISMATCH = 3,
104
105 /// @brief __4__ : Backend server is reachable, but denies client access (e.g. due
106 /// to wrong credentials).
107 PVR_CONNECTION_STATE_ACCESS_DENIED = 4,
108
109 /// @brief __5__ : Connection to backend server is established.
110 PVR_CONNECTION_STATE_CONNECTED = 5,
111
112 /// @brief __6__ : No connection to backend server (e.g. due to network errors or
113 /// client initiated disconnect).
114 PVR_CONNECTION_STATE_DISCONNECTED = 6,
115
116 /// @brief __7__ : Connecting to backend.
117 PVR_CONNECTION_STATE_CONNECTING = 7,
118 } PVR_CONNECTION_STATE;
119 ///@}
120 //----------------------------------------------------------------------------
121
122 //============================================================================
123 /// @defgroup cpp_kodi_addon_pvr_Defs_General_PVR_STREAM_PROPERTY definition PVR_STREAM_PROPERTY
124 /// @ingroup cpp_kodi_addon_pvr_Defs_General_Inputstream
125 /// @brief **PVR related stream property values**\n
126 /// This is used to pass additional data to Kodi on a given PVR stream.
127 ///
128 /// Then transferred to livestream, recordings or EPG Tag stream using the
129 /// properties.
130 ///
131 /// This defines are used by:
132 /// - @ref kodi::addon::CInstancePVRClient::GetChannelStreamProperties()
133 /// - @ref kodi::addon::CInstancePVRClient::GetEPGTagStreamProperties()
134 /// - @ref kodi::addon::CInstancePVRClient::GetRecordingStreamProperties()
135 ///
136 ///
137 ///---------------------------------------------------------------------------
138 ///
139 /// **Example:**
140 /// ~~~~~~~~~~~~~{.cpp}
141 /// ...
142 ///
143 /// PVR_ERROR CMyPVRInstance::GetChannelStreamProperties(const kodi::addon::PVRChannel& channel,
144 /// std::vector<PVRStreamProperty>& properties)
145 /// {
146 /// ...
147 /// properties.emplace_back(PVR_STREAM_PROPERTY_INPUTSTREAM, "inputstream.adaptive");
148 /// properties.emplace_back("inputstream.adaptive.manifest_type", "mpd");
149 /// properties.emplace_back("inputstream.adaptive.manifest_update_parameter", "full");
150 /// properties.emplace_back(PVR_STREAM_PROPERTY_MIMETYPE, "application/xml+dash");
151 /// return PVR_ERROR_NO_ERROR;
152 /// }
153 ///
154 /// ...
155 /// ~~~~~~~~~~~~~
156 ///
157 ///@{
158
159 /// @brief the URL of the stream that should be played.
160 ///
161 #define PVR_STREAM_PROPERTY_STREAMURL "streamurl"
162
163 /// @brief To define in stream properties the name of the inputstream add-on
164 /// that should be used.
165 ///
166 /// Leave blank to use Kodi's built-in playing capabilities or to allow ffmpeg
167 /// to handle directly set to @ref PVR_STREAM_PROPERTY_VALUE_INPUTSTREAMFFMPEG.
168 ///
169 #define PVR_STREAM_PROPERTY_INPUTSTREAM STREAM_PROPERTY_INPUTSTREAM
170
171 /// @brief Identification string for an input stream.
172 ///
173 /// This value can be used in addition to @ref PVR_STREAM_PROPERTY_INPUTSTREAM.
174 /// It is used to provide the respective inpustream addon with additional
175 /// identification.
176 ///
177 /// The difference between this and other stream properties is that it is also
178 /// passed in the associated @ref kodi::addon::CAddonBase::CreateInstance()
179 /// call.
180 ///
181 /// This makes it possible to select different processing classes within the
182 /// associated add-on.
183 ///
184 ///
185 ///---------------------------------------------------------------------------
186 ///
187 /// **Example:**
188 /// ~~~~~~~~~~~~~{.cpp}
189 /// ...
190 ///
191 /// // On PVR instance of addon
192 /// PVR_ERROR CMyPVRInstance::GetChannelStreamProperties(const kodi::addon::PVRChannel& channel,
193 /// std::vector<PVRStreamProperty>& properties)
194 /// {
195 /// ...
196 /// // For here on example the inpustream is also inside the PVR addon
197 /// properties.emplace_back(PVR_STREAM_PROPERTY_INPUTSTREAM, "pvr.my_one");
198 /// properties.emplace_back(PVR_STREAM_PROPERTY_INPUTSTREAM_INSTANCE_ID, "my_special_id_1");
199 /// return PVR_ERROR_NO_ERROR;
200 /// }
201 ///
202 /// ...
203 ///
204 /// // On CAddonBase part of addon
205 /// ADDON_STATUS CMyAddon::CreateInstanceEx(int instanceType,
206 /// std::string instanceID,
207 /// KODI_HANDLE instance,
208 /// KODI_HANDLE& addonInstance
209 /// const std::string& version)
210 /// {
211 /// if (instanceType == ADDON_INSTANCE_INPUTSTREAM)
212 /// {
213 /// kodi::Log(ADDON_LOG_INFO, "Creating my special inputstream");
214 /// if (instanceID == "my_special_id_1")
215 /// addonInstance = new CMyPVRClientInstance_Type1(instance, version);
216 /// else if (instanceID == "my_special_id_2")
217 /// addonInstance = new CMyPVRClientInstance_Type2(instance, version);
218 /// return ADDON_STATUS_OK;
219 /// }
220 /// else if (...)
221 /// {
222 /// ...
223 /// }
224 /// return ADDON_STATUS_UNKNOWN;
225 /// }
226 ///
227 /// ...
228 /// ~~~~~~~~~~~~~
229 ///
230 #define PVR_STREAM_PROPERTY_INPUTSTREAM_INSTANCE_ID STREAM_PROPERTY_INPUTSTREAM_INSTANCE_ID
231
232 /// @brief the MIME type of the stream that should be played.
233 ///
234 #define PVR_STREAM_PROPERTY_MIMETYPE "mimetype"
235
236 /// @brief <b>"true"</b> to denote that the stream that should be played is a
237 /// realtime stream.
238 ///
239 /// Any other value indicates that this is no realtime stream.
240 ///
241 #define PVR_STREAM_PROPERTY_ISREALTIMESTREAM STREAM_PROPERTY_ISREALTIMESTREAM
242
243 /// @brief <b>"true"</b> to denote that if the stream is from an EPG tag.
244 ///
245 /// It should be played is a live stream. Otherwise if it's a EPG tag it will
246 /// play as normal video.
247 ///
248 #define PVR_STREAM_PROPERTY_EPGPLAYBACKASLIVE "epgplaybackaslive"
249
250 /// @brief Special value for @ref PVR_STREAM_PROPERTY_INPUTSTREAM to use
251 /// ffmpeg to directly play a stream URL.
252 #define PVR_STREAM_PROPERTY_VALUE_INPUTSTREAMFFMPEG STREAM_PROPERTY_VALUE_INPUTSTREAMFFMPEG
253
254 ///@}
255 //-----------------------------------------------------------------------------
256
257 /*!
258 * @brief "C" PVR add-on capabilities.
259 *
260 * Structure used to interface in "C" between Kodi and Addon.
261 *
262 * See @ref kodi::addon::PVRCapabilities for description of values.
263 */
264 typedef struct PVR_ADDON_CAPABILITIES
265 {
266 bool bSupportsEPG;
267 bool bSupportsEPGEdl;
268 bool bSupportsTV;
269 bool bSupportsRadio;
270 bool bSupportsRecordings;
271 bool bSupportsRecordingsUndelete;
272 bool bSupportsTimers;
273 bool bSupportsChannelGroups;
274 bool bSupportsChannelScan;
275 bool bSupportsChannelSettings;
276 bool bHandlesInputStream;
277 bool bHandlesDemuxing;
278 bool bSupportsRecordingPlayCount;
279 bool bSupportsLastPlayedPosition;
280 bool bSupportsRecordingEdl;
281 bool bSupportsRecordingsRename;
282 bool bSupportsRecordingsLifetimeChange;
283 bool bSupportsDescrambleInfo;
284 bool bSupportsAsyncEPGTransfer;
285 bool bSupportsRecordingSize;
286
287 unsigned int iRecordingsLifetimesSize;
288 struct PVR_ATTRIBUTE_INT_VALUE recordingsLifetimeValues[PVR_ADDON_ATTRIBUTE_VALUES_ARRAY_SIZE];
289 } PVR_ADDON_CAPABILITIES;
290
291#ifdef __cplusplus
292}
293#endif /* __cplusplus */
294
295#endif /* !C_API_ADDONINSTANCE_PVR_GENERAL_H */
diff --git a/xbmc/addons/kodi-dev-kit/include/kodi/c-api/addon-instance/pvr/pvr_menu_hook.h b/xbmc/addons/kodi-dev-kit/include/kodi/c-api/addon-instance/pvr/pvr_menu_hook.h
new file mode 100644
index 0000000..2ead263
--- /dev/null
+++ b/xbmc/addons/kodi-dev-kit/include/kodi/c-api/addon-instance/pvr/pvr_menu_hook.h
@@ -0,0 +1,77 @@
1/*
2 * Copyright (C) 2005-2018 Team Kodi
3 * This file is part of Kodi - https://kodi.tv
4 *
5 * SPDX-License-Identifier: GPL-2.0-or-later
6 * See LICENSES/README.md for more information.
7 */
8
9#pragma once
10
11#ifndef C_API_ADDONINSTANCE_PVR_MENUHOOK_H
12#define C_API_ADDONINSTANCE_PVR_MENUHOOK_H
13
14#include "pvr_defines.h"
15
16//¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯
17// "C" Definitions group 7 - Menu hook
18#ifdef __cplusplus
19extern "C"
20{
21#endif /* __cplusplus */
22
23 //============================================================================
24 /// @defgroup cpp_kodi_addon_pvr_Defs_Menuhook_PVR_MENUHOOK_CAT enum PVR_MENUHOOK_CAT
25 /// @ingroup cpp_kodi_addon_pvr_Defs_Menuhook
26 /// @brief **PVR context menu hook categories**\n
27 /// Possible menu types given to Kodi with @ref kodi::addon::CInstancePVRClient::AddMenuHook().
28 ///
29 ///@{
30 typedef enum PVR_MENUHOOK_CAT
31 {
32 /// @brief __-1__ : Unknown menu hook.
33 PVR_MENUHOOK_UNKNOWN = -1,
34
35 /// @brief __0__ : All categories.
36 PVR_MENUHOOK_ALL = 0,
37
38 /// @brief __1__ : For channels.
39 PVR_MENUHOOK_CHANNEL = 1,
40
41 /// @brief __2__ : For timers.
42 PVR_MENUHOOK_TIMER = 2,
43
44 /// @brief __3__ : For EPG.
45 PVR_MENUHOOK_EPG = 3,
46
47 /// @brief __4__ : For recordings.
48 PVR_MENUHOOK_RECORDING = 4,
49
50 /// @brief __5__ : For deleted recordings.
51 PVR_MENUHOOK_DELETED_RECORDING = 5,
52
53 /// @brief __6__ : For settings.
54 PVR_MENUHOOK_SETTING = 6,
55 } PVR_MENUHOOK_CAT;
56 ///@}
57 //----------------------------------------------------------------------------
58
59 /*!
60 * @brief "C" PVR add-on menu hook.
61 *
62 * Structure used to interface in "C" between Kodi and Addon.
63 *
64 * See @ref kodi::addon::PVRMenuhook for description of values.
65 */
66 typedef struct PVR_MENUHOOK
67 {
68 unsigned int iHookId;
69 unsigned int iLocalizedStringId;
70 enum PVR_MENUHOOK_CAT category;
71 } PVR_MENUHOOK;
72
73#ifdef __cplusplus
74}
75#endif /* __cplusplus */
76
77#endif /* !C_API_ADDONINSTANCE_PVR_MENUHOOK_H */
diff --git a/xbmc/addons/kodi-dev-kit/include/kodi/c-api/addon-instance/pvr/pvr_recordings.h b/xbmc/addons/kodi-dev-kit/include/kodi/c-api/addon-instance/pvr/pvr_recordings.h
new file mode 100644
index 0000000..2e2c081
--- /dev/null
+++ b/xbmc/addons/kodi-dev-kit/include/kodi/c-api/addon-instance/pvr/pvr_recordings.h
@@ -0,0 +1,148 @@
1/*
2 * Copyright (C) 2005-2018 Team Kodi
3 * This file is part of Kodi - https://kodi.tv
4 *
5 * SPDX-License-Identifier: GPL-2.0-or-later
6 * See LICENSES/README.md for more information.
7 */
8
9#pragma once
10
11#ifndef C_API_ADDONINSTANCE_PVR_RECORDINGS_H
12#define C_API_ADDONINSTANCE_PVR_RECORDINGS_H
13
14#include "pvr_defines.h"
15
16#include <stdbool.h>
17#include <stdint.h>
18#include <time.h>
19
20//¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯
21// "C" Definitions group 5 - PVR recordings
22#ifdef __cplusplus
23extern "C"
24{
25#endif /* __cplusplus */
26
27 //============================================================================
28 /// @defgroup cpp_kodi_addon_pvr_Defs_Recording_PVR_RECORDING_FLAG enum PVR_RECORDING_FLAG
29 /// @ingroup cpp_kodi_addon_pvr_Defs_Recording
30 /// @brief **Bit field of independent flags associated with the EPG entry.**\n
31 /// Values used by @ref kodi::addon::PVRRecording::SetFlags().
32 ///
33 /// Here's example about the use of this:
34 /// ~~~~~~~~~~~~~{.cpp}
35 /// kodi::addon::PVRRecording tag;
36 /// tag.SetFlags(PVR_RECORDING_FLAG_IS_SERIES | PVR_RECORDING_FLAG_IS_PREMIERE);
37 /// ~~~~~~~~~~~~~
38 ///
39 ///@{
40 typedef enum PVR_RECORDING_FLAG
41 {
42 /// @brief __0000 0000__ : Nothing special to say about this recording.
43 PVR_RECORDING_FLAG_UNDEFINED = 0,
44
45 /// @brief __0000 0001__ : This recording is part of a series.
46 PVR_RECORDING_FLAG_IS_SERIES = (1 << 0),
47
48 /// @brief __0000 0010__ : This recording will be flagged as new.
49 PVR_RECORDING_FLAG_IS_NEW = (1 << 1),
50
51 /// @brief __0000 0100__ : This recording will be flagged as a premiere.
52 PVR_RECORDING_FLAG_IS_PREMIERE = (1 << 2),
53
54 /// @brief __0000 1000__ : This recording will be flagged as a finale.
55 PVR_RECORDING_FLAG_IS_FINALE = (1 << 3),
56
57 /// @brief __0001 0000__ : This recording will be flagged as live.
58 PVR_RECORDING_FLAG_IS_LIVE = (1 << 4),
59 } PVR_RECORDING_FLAG;
60 ///@}
61 //----------------------------------------------------------------------------
62
63 //============================================================================
64 /// @ingroup cpp_kodi_addon_pvr_Defs_Recording_PVRRecording
65 /// @brief Special @ref kodi::addon::PVRRecording::SetSeriesNumber() and
66 /// @ref kodi::addon::PVRRecording::SetEpisodeNumber() value to indicate it is
67 /// not to be used.
68 ///
69 /// Used if recording has no valid season and/or episode info.
70 ///
71 #define PVR_RECORDING_INVALID_SERIES_EPISODE EPG_TAG_INVALID_SERIES_EPISODE
72 //----------------------------------------------------------------------------
73
74 //============================================================================
75 /// @ingroup cpp_kodi_addon_pvr_Defs_Recording_PVRRecording
76 /// @brief Value where set in background to inform that related part not used.
77 ///
78 /// Normally this related parts need not to set by this as it is default.
79 #define PVR_RECORDING_VALUE_NOT_AVAILABLE -1
80 //----------------------------------------------------------------------------
81
82 //============================================================================
83 /// @defgroup cpp_kodi_addon_pvr_Defs_Recording_PVR_RECORDING_CHANNEL_TYPE enum PVR_RECORDING_CHANNEL_TYPE
84 /// @ingroup cpp_kodi_addon_pvr_Defs_Recording
85 /// @brief **PVR recording channel types**\n
86 /// Used on @ref kodi::addon::PVRRecording::SetChannelType() value to set related
87 /// type.
88 ///
89 ///@{
90 typedef enum PVR_RECORDING_CHANNEL_TYPE
91 {
92 /// @brief __0__ : Unknown type.
93 PVR_RECORDING_CHANNEL_TYPE_UNKNOWN = 0,
94
95 /// @brief __1__ : TV channel.
96 PVR_RECORDING_CHANNEL_TYPE_TV = 1,
97
98 /// @brief __2__ : Radio channel.
99 PVR_RECORDING_CHANNEL_TYPE_RADIO = 2,
100 } PVR_RECORDING_CHANNEL_TYPE;
101 ///@}
102 //----------------------------------------------------------------------------
103
104 /*!
105 * @brief "C" PVR add-on recording.
106 *
107 * Structure used to interface in "C" between Kodi and Addon.
108 *
109 * See @ref kodi::addon::PVRRecording for description of values.
110 */
111 typedef struct PVR_RECORDING
112 {
113 char strRecordingId[PVR_ADDON_NAME_STRING_LENGTH];
114 char strTitle[PVR_ADDON_NAME_STRING_LENGTH];
115 char strEpisodeName[PVR_ADDON_NAME_STRING_LENGTH];
116 int iSeriesNumber;
117 int iEpisodeNumber;
118 int iYear;
119 char strDirectory[PVR_ADDON_URL_STRING_LENGTH];
120 char strPlotOutline[PVR_ADDON_DESC_STRING_LENGTH];
121 char strPlot[PVR_ADDON_DESC_STRING_LENGTH];
122 char strGenreDescription[PVR_ADDON_DESC_STRING_LENGTH];
123 char strChannelName[PVR_ADDON_NAME_STRING_LENGTH];
124 char strIconPath[PVR_ADDON_URL_STRING_LENGTH];
125 char strThumbnailPath[PVR_ADDON_URL_STRING_LENGTH];
126 char strFanartPath[PVR_ADDON_URL_STRING_LENGTH];
127 time_t recordingTime;
128 int iDuration;
129 int iPriority;
130 int iLifetime;
131 int iGenreType;
132 int iGenreSubType;
133 int iPlayCount;
134 int iLastPlayedPosition;
135 bool bIsDeleted;
136 unsigned int iEpgEventId;
137 int iChannelUid;
138 enum PVR_RECORDING_CHANNEL_TYPE channelType;
139 char strFirstAired[PVR_ADDON_DATE_STRING_LENGTH];
140 unsigned int iFlags;
141 int64_t sizeInBytes;
142 } PVR_RECORDING;
143
144#ifdef __cplusplus
145}
146#endif /* __cplusplus */
147
148#endif /* !C_API_ADDONINSTANCE_PVR_RECORDINGS_H */
diff --git a/xbmc/addons/kodi-dev-kit/include/kodi/c-api/addon-instance/pvr/pvr_stream.h b/xbmc/addons/kodi-dev-kit/include/kodi/c-api/addon-instance/pvr/pvr_stream.h
new file mode 100644
index 0000000..1206c67
--- /dev/null
+++ b/xbmc/addons/kodi-dev-kit/include/kodi/c-api/addon-instance/pvr/pvr_stream.h
@@ -0,0 +1,160 @@
1/*
2 * Copyright (C) 2005-2018 Team Kodi
3 * This file is part of Kodi - https://kodi.tv
4 *
5 * SPDX-License-Identifier: GPL-2.0-or-later
6 * See LICENSES/README.md for more information.
7 */
8
9#pragma once
10
11#ifndef C_API_ADDONINSTANCE_PVR_STREAM_H
12#define C_API_ADDONINSTANCE_PVR_STREAM_H
13
14#include "pvr_defines.h"
15
16#ifdef BUILD_KODI_ADDON
17#include "../../../DemuxPacket.h"
18#else
19#include "cores/VideoPlayer/Interface/Addon/DemuxPacket.h"
20#endif
21
22#include <stdint.h>
23#include <time.h>
24
25//¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯
26// "C" Definitions group 9 - PVR stream definitions (NOTE: Becomes replaced
27// in future by inputstream addon instance way)
28#ifdef __cplusplus
29extern "C"
30{
31#endif /* __cplusplus */
32
33 //============================================================================
34 /// @ingroup cpp_kodi_addon_pvr_Defs_Stream
35 /// @brief Maximum of allowed streams
36 ///
37 #define PVR_STREAM_MAX_STREAMS 20
38 //----------------------------------------------------------------------------
39
40 //============================================================================
41 /// @ingroup cpp_kodi_addon_pvr_Defs_Stream
42 /// @brief Invalid codec identifier
43 ///
44 #define PVR_INVALID_CODEC_ID 0
45 //----------------------------------------------------------------------------
46
47 //============================================================================
48 /// @ingroup cpp_kodi_addon_pvr_Defs_Stream
49 /// @brief Invalid codec
50 ///
51 #define PVR_INVALID_CODEC \
52 { \
53 PVR_CODEC_TYPE_UNKNOWN, PVR_INVALID_CODEC_ID \
54 }
55 //----------------------------------------------------------------------------
56
57 //============================================================================
58 /// @defgroup cpp_kodi_addon_pvr_Defs_Stream_PVR_CODEC_TYPE enum PVR_CODEC_TYPE
59 /// @ingroup cpp_kodi_addon_pvr_Defs_Stream
60 /// @brief **Inputstream types**\n
61 /// To identify type on stream.
62 ///
63 /// Used on @ref kodi::addon::PVRStreamProperties::SetCodecType and @ref kodi::addon::PVRStreamProperties::SetCodecType.
64 ///
65 ///@{
66 typedef enum PVR_CODEC_TYPE
67 {
68 /// @brief To set nothing defined.
69 PVR_CODEC_TYPE_UNKNOWN = -1,
70
71 /// @brief To identify @ref cpp_kodi_addon_pvr_Defs_Stream_PVRStreamProperties as Video.
72 PVR_CODEC_TYPE_VIDEO,
73
74 /// @brief To identify @ref cpp_kodi_addon_pvr_Defs_Stream_PVRStreamProperties as Audio.
75 PVR_CODEC_TYPE_AUDIO,
76
77 /// @brief To identify @ref cpp_kodi_addon_pvr_Defs_Stream_PVRStreamProperties as Data.
78 ///
79 /// With codec id related source identified.
80 PVR_CODEC_TYPE_DATA,
81
82 /// @brief To identify @ref cpp_kodi_addon_pvr_Defs_Stream_PVRStreamProperties as Subtitle.
83 PVR_CODEC_TYPE_SUBTITLE,
84
85 /// @brief To identify @ref cpp_kodi_addon_pvr_Defs_Stream_PVRStreamProperties as Radio RDS.
86 PVR_CODEC_TYPE_RDS,
87
88 PVR_CODEC_TYPE_NB
89 } PVR_CODEC_TYPE;
90 ///@}
91 //----------------------------------------------------------------------------
92
93 //============================================================================
94 /// @defgroup cpp_kodi_addon_pvr_Defs_Stream_PVR_CODEC struct PVR_CODEC
95 /// @ingroup cpp_kodi_addon_pvr_Defs_Stream
96 /// @brief **Codec identification structure**\n
97 /// Identifier about stream between Kodi and addon.
98 ///
99 ///@{
100 typedef struct PVR_CODEC
101 {
102 /// @brief Used codec type for stream.
103 enum PVR_CODEC_TYPE codec_type;
104
105 /// @brief Related codec identifier, normally match the ffmpeg id's.
106 unsigned int codec_id;
107 } PVR_CODEC;
108 ///@}
109 //----------------------------------------------------------------------------
110
111 /*!
112 * @brief "C" Stream properties
113 *
114 * Structure used to interface in "C" between Kodi and Addon.
115 *
116 * See @ref cpp_kodi_addon_pvr_Defs_Stream_PVRStreamProperties for description of values.
117 */
118 typedef struct PVR_STREAM_PROPERTIES
119 {
120 unsigned int iStreamCount;
121 struct PVR_STREAM
122 {
123 unsigned int iPID;
124 enum PVR_CODEC_TYPE iCodecType;
125 unsigned int iCodecId;
126 char strLanguage[4];
127 int iSubtitleInfo;
128 int iFPSScale;
129 int iFPSRate;
130 int iHeight;
131 int iWidth;
132 float fAspect;
133 int iChannels;
134 int iSampleRate;
135 int iBlockAlign;
136 int iBitRate;
137 int iBitsPerSample;
138 } stream[PVR_STREAM_MAX_STREAMS];
139 } PVR_STREAM_PROPERTIES;
140
141 /*!
142 * @brief "C" Times of playing stream (Live TV and recordings)
143 *
144 * Structure used to interface in "C" between Kodi and Addon.
145 *
146 * See @ref cpp_kodi_addon_pvr_Defs_Stream_PVRStreamTimes for description of values.
147 */
148 typedef struct PVR_STREAM_TIMES
149 {
150 time_t startTime;
151 int64_t ptsStart;
152 int64_t ptsBegin;
153 int64_t ptsEnd;
154 } PVR_STREAM_TIMES;
155
156#ifdef __cplusplus
157}
158#endif /* __cplusplus */
159
160#endif /* !C_API_ADDONINSTANCE_PVR_STREAM_H */
diff --git a/xbmc/addons/kodi-dev-kit/include/kodi/c-api/addon-instance/pvr/pvr_timers.h b/xbmc/addons/kodi-dev-kit/include/kodi/c-api/addon-instance/pvr/pvr_timers.h
new file mode 100644
index 0000000..209726d
--- /dev/null
+++ b/xbmc/addons/kodi-dev-kit/include/kodi/c-api/addon-instance/pvr/pvr_timers.h
@@ -0,0 +1,412 @@
1/*
2 * Copyright (C) 2005-2018 Team Kodi
3 * This file is part of Kodi - https://kodi.tv
4 *
5 * SPDX-License-Identifier: GPL-2.0-or-later
6 * See LICENSES/README.md for more information.
7 */
8
9#pragma once
10
11#ifndef C_API_ADDONINSTANCE_PVR_TIMERS_H
12#define C_API_ADDONINSTANCE_PVR_TIMERS_H
13
14#include "pvr_defines.h"
15
16#include <stdbool.h>
17#include <stdint.h>
18#include <time.h>
19
20//¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯
21// "C" Definitions group 6 - PVR timers
22#ifdef __cplusplus
23extern "C"
24{
25#endif /* __cplusplus */
26
27 //============================================================================
28 /// @defgroup cpp_kodi_addon_pvr_Defs_Timer_PVR_TIMER_ definition PVR_TIMER (various)
29 /// @ingroup cpp_kodi_addon_pvr_Defs_Timer
30 /// @brief **PVR timer various different definitions**\n
31 /// This mostly used on @ref cpp_kodi_addon_pvr_Defs_Timer_PVRTimer "kodi::addon::PVRTimer"
32 /// to define default or not available.
33 ///
34 ///@{
35
36 //============================================================================
37 /// @brief Numeric PVR timer type definitions (@ref kodi::addon::PVRTimer::SetTimerType()
38 /// values).
39 ///
40 /// "Null" value for a numeric timer type.
41 #define PVR_TIMER_TYPE_NONE 0
42 //----------------------------------------------------------------------------
43
44 //============================================================================
45 /// @brief Special @ref kodi::addon::PVRTimer::SetClientIndex() value to indicate
46 /// that a timer has not (yet) a valid client index.
47 ///
48 /// Timer has not (yet) a valid client index.
49 #define PVR_TIMER_NO_CLIENT_INDEX 0
50 //----------------------------------------------------------------------------
51
52 //============================================================================
53 /// @brief Special @ref kodi::addon::PVRTimer::SetParentClientIndex() value to
54 /// indicate that a timer has no parent.
55 ///
56 /// Timer has no parent; it was not scheduled by a repeating timer.
57 #define PVR_TIMER_NO_PARENT PVR_TIMER_NO_CLIENT_INDEX
58 //----------------------------------------------------------------------------
59
60 //============================================================================
61 /// @brief Special @ref kodi::addon::PVRTimer::SetEPGUid() value to indicate
62 /// that a timer has no EPG event uid.
63 ///
64 /// Timer has no EPG event unique identifier.
65 #define PVR_TIMER_NO_EPG_UID EPG_TAG_INVALID_UID
66 //----------------------------------------------------------------------------
67
68 //============================================================================
69 /// @brief Special @ref kodi::addon::PVRTimer::SetClientChannelUid() value to
70 /// indicate "any channel". Useful for some repeating timer types.
71 ///
72 /// denotes "any channel", not a specific one.
73 ///
74 #define PVR_TIMER_ANY_CHANNEL -1
75 //----------------------------------------------------------------------------
76
77 //============================================================================
78 /// @brief Value where set in background to inform that related part not used.
79 ///
80 /// Normally this related parts need not to set by this as it is default.
81 #define PVR_TIMER_VALUE_NOT_AVAILABLE -1
82 //----------------------------------------------------------------------------
83
84 ///@}
85 //----------------------------------------------------------------------------
86
87
88 //============================================================================
89 /// @defgroup cpp_kodi_addon_pvr_Defs_Timer_PVR_TIMER_TYPES enum PVR_TIMER_TYPES
90 /// @ingroup cpp_kodi_addon_pvr_Defs_Timer
91 /// @brief **PVR timer type attributes (@ref kodi::addon::PVRTimerType::SetAttributes() values).**\n
92 /// To defines the attributes for a type. These values are bit fields that can be
93 /// used together.
94 ///
95 ///--------------------------------------------------------------------------
96 ///
97 /// **Example:**
98 /// ~~~~~~~~~~~~~{.cpp}
99 /// kodi::addon::PVRTimerType tag;
100 /// tag.SetAttributes(PVR_TIMER_TYPE_IS_MANUAL | PVR_TIMER_TYPE_IS_REPEATING);
101 /// ~~~~~~~~~~~~~
102 ///
103 ///@{
104 typedef enum PVR_TIMER_TYPES
105 {
106 /// @brief __0000 0000 0000 0000 0000 0000 0000 0000__ :\n Empty attribute value.
107 PVR_TIMER_TYPE_ATTRIBUTE_NONE = 0,
108
109 /// @brief __0000 0000 0000 0000 0000 0000 0000 0001__ :\n Defines whether this is a type for
110 /// manual (time-based) or epg-based timers.
111 PVR_TIMER_TYPE_IS_MANUAL = (1 << 0),
112
113 /// @brief __0000 0000 0000 0000 0000 0000 0000 0010__ :\n Defines whether this is a type for
114 /// repeating or one-shot timers.
115 PVR_TIMER_TYPE_IS_REPEATING = (1 << 1),
116
117 /// @brief __0000 0000 0000 0000 0000 0000 0000 0100__ :\n Timers of this type must not be edited
118 /// by Kodi.
119 PVR_TIMER_TYPE_IS_READONLY = (1 << 2),
120
121 /// @brief __0000 0000 0000 0000 0000 0000 0000 1000__ :\n Timers of this type must not be created
122 /// by Kodi. All other operations are allowed, though.
123 PVR_TIMER_TYPE_FORBIDS_NEW_INSTANCES = (1 << 3),
124
125 /// @brief __0000 0000 0000 0000 0000 0000 0001 0000__ :\n This type supports enabling/disabling
126 /// of the timer (@ref kodi::addon::PVRTimer::SetState() with
127 /// @ref PVR_TIMER_STATE_SCHEDULED | @ref PVR_TIMER_STATE_DISABLED).
128 PVR_TIMER_TYPE_SUPPORTS_ENABLE_DISABLE = (1 << 4),
129
130 /// @brief __0000 0000 0000 0000 0000 0000 0010 0000__ :\n This type supports channels
131 /// (@ref kodi::addon::PVRTimer::SetClientChannelUid()).
132 PVR_TIMER_TYPE_SUPPORTS_CHANNELS = (1 << 5),
133
134 /// @brief __0000 0000 0000 0000 0000 0000 0100 0000__ :\n This type supports a recording start
135 /// time (@ref kodi::addon::PVRTimer::SetStartTime()).
136 PVR_TIMER_TYPE_SUPPORTS_START_TIME = (1 << 6),
137
138 /// @brief __0000 0000 0000 0000 0000 0000 1000 0000__ :\n This type supports matching epg episode
139 /// title using@ref kodi::addon::PVRTimer::SetEPGSearchString().
140 PVR_TIMER_TYPE_SUPPORTS_TITLE_EPG_MATCH = (1 << 7),
141
142 /// @brief __0000 0000 0000 0000 0000 0001 0000 0000__ :\n This type supports matching "more" epg
143 /// data (not just episode title) using @ref kodi::addon::PVRTimer::SetEPGSearchString().
144 /// Setting @ref PVR_TIMER_TYPE_SUPPORTS_FULLTEXT_EPG_MATCH implies
145 /// @ref PVR_TIMER_TYPE_SUPPORTS_TITLE_EPG_MATCH.
146 PVR_TIMER_TYPE_SUPPORTS_FULLTEXT_EPG_MATCH = (1 << 8),
147
148 /// @brief __0000 0000 0000 0000 0000 0010 0000 0000__ :\n This type supports a first day the
149 /// timer gets active (@ref kodi::addon::PVRTimer::SetFirstDay()).
150 PVR_TIMER_TYPE_SUPPORTS_FIRST_DAY = (1 << 9),
151
152 /// @brief __0000 0000 0000 0000 0000 0100 0000 0000__ :\n This type supports weekdays for
153 /// defining the recording schedule (@ref kodi::addon::PVRTimer::SetWeekdays()).
154 PVR_TIMER_TYPE_SUPPORTS_WEEKDAYS = (1 << 10),
155
156 /// @brief __0000 0000 0000 0000 0000 1000 0000 0000__ :\n This type supports the <b>"record only new episodes"</b> feature
157 /// (@ref kodi::addon::PVRTimer::SetPreventDuplicateEpisodes()).
158 PVR_TIMER_TYPE_SUPPORTS_RECORD_ONLY_NEW_EPISODES = (1 << 11),
159
160 /// @brief __0000 0000 0000 0000 0001 0000 0000 0000__ :\n This type supports pre and post record time (@ref kodi::addon::PVRTimer::SetMarginStart(),
161 /// @ref kodi::addon::PVRTimer::SetMarginEnd()).
162 PVR_TIMER_TYPE_SUPPORTS_START_END_MARGIN = (1 << 12),
163
164 /// @brief __0000 0000 0000 0000 0010 0000 0000 0000__ :\n This type supports recording priority (@ref kodi::addon::PVRTimer::SetPriority()).
165 PVR_TIMER_TYPE_SUPPORTS_PRIORITY = (1 << 13),
166
167 /// @brief __0000 0000 0000 0000 0100 0000 0000 0000__ :\n This type supports recording lifetime (@ref kodi::addon::PVRTimer::SetLifetime()).
168 PVR_TIMER_TYPE_SUPPORTS_LIFETIME = (1 << 14),
169
170 /// @brief __0000 0000 0000 0000 1000 0000 0000 0000__ :\n This type supports placing recordings in user defined folders
171 /// (@ref kodi::addon::PVRTimer::SetDirectory()).
172 PVR_TIMER_TYPE_SUPPORTS_RECORDING_FOLDERS = (1 << 15),
173
174 /// @brief __0000 0000 0000 0001 0000 0000 0000 0000__ :\n This type supports a list of recording groups
175 /// (@ref kodi::addon::PVRTimer::SetRecordingGroup()).
176 PVR_TIMER_TYPE_SUPPORTS_RECORDING_GROUP = (1 << 16),
177
178 /// @brief __0000 0000 0000 0010 0000 0000 0000 0000__ :\n This type supports a recording end time (@ref kodi::addon::PVRTimer::SetEndTime()).
179 PVR_TIMER_TYPE_SUPPORTS_END_TIME = (1 << 17),
180
181 /// @brief __0000 0000 0000 0100 0000 0000 0000 0000__ :\n Enables an 'Any Time' over-ride option for start time
182 /// (using @ref kodi::addon::PVRTimer::SetStartAnyTime()).
183 PVR_TIMER_TYPE_SUPPORTS_START_ANYTIME = (1 << 18),
184
185 /// @brief __0000 0000 0000 1000 0000 0000 0000 0000__ :\n Enables a separate <b>'Any Time'</b> over-ride for end time
186 /// (using @ref kodi::addon::PVRTimer::SetEndAnyTime()).
187 PVR_TIMER_TYPE_SUPPORTS_END_ANYTIME = (1 << 19),
188
189 /// @brief __0000 0000 0001 0000 0000 0000 0000 0000__ :\n This type supports specifying a maximum recordings setting'
190 /// (@ref kodi::addon::PVRTimer::SetMaxRecordings()).
191 PVR_TIMER_TYPE_SUPPORTS_MAX_RECORDINGS = (1 << 20),
192
193 /// @brief __0000 0000 0010 0000 0000 0000 0000 0000__ :\n This type should not appear on any create menus which don't
194 /// provide an associated @ref cpp_kodi_addon_pvr_Defs_epg_PVREPGTag "EPG tag".
195 PVR_TIMER_TYPE_REQUIRES_EPG_TAG_ON_CREATE = (1 << 21),
196
197 /// @brief __0000 0000 0100 0000 0000 0000 0000 0000__ :\n This type should not appear on any create menus which provide an
198 /// associated @ref cpp_kodi_addon_pvr_Defs_epg_PVREPGTag "EPG tag".
199 PVR_TIMER_TYPE_FORBIDS_EPG_TAG_ON_CREATE = (1 << 22),
200
201 /// @brief __0000 0000 1000 0000 0000 0000 0000 0000__ :\n This type should not appear on any create menus unless associated
202 /// with an @ref cpp_kodi_addon_pvr_Defs_epg_PVREPGTag "EPG tag" with
203 /// 'series' attributes.
204 ///
205 /// Following conditions allow this:
206 /// - @ref kodi::addon::PVREPGTag::SetFlags() have flag @ref EPG_TAG_FLAG_IS_SERIES
207 /// - @ref kodi::addon::PVREPGTag::SetSeriesNumber() > 0
208 /// - @ref kodi::addon::PVREPGTag::SetEpisodeNumber() > 0
209 /// - @ref kodi::addon::PVREPGTag::SetEpisodePartNumber() > 0
210 ///
211 /// Implies @ref PVR_TIMER_TYPE_REQUIRES_EPG_TAG_ON_CREATE.
212 PVR_TIMER_TYPE_REQUIRES_EPG_SERIES_ON_CREATE = (1 << 23),
213
214 /// @brief __0000 0001 0000 0000 0000 0000 0000 0000__ :\n This type supports 'any channel', for example when defining a timer
215 /// rule that should match any channel instaed of a particular channel.
216 PVR_TIMER_TYPE_SUPPORTS_ANY_CHANNEL = (1 << 24),
217
218 /// @brief __0000 0010 0000 0000 0000 0000 0000 0000__ :\n This type should not appear on any create menus which don't provide
219 /// an associated @ref cpp_kodi_addon_pvr_Defs_epg_PVREPGTag "EPG tag" with
220 /// a series link.
221 PVR_TIMER_TYPE_REQUIRES_EPG_SERIESLINK_ON_CREATE = (1 << 25),
222
223 /// @brief __0000 0100 0000 0000 0000 0000 0000 0000__ :\n This type allows deletion of an otherwise read-only timer.
224 PVR_TIMER_TYPE_SUPPORTS_READONLY_DELETE = (1 << 26),
225
226 /// @brief __0000 1000 0000 0000 0000 0000 0000 0000__ :\n Timers of this type do trigger a reminder if time is up.
227 PVR_TIMER_TYPE_IS_REMINDER = (1 << 27),
228
229 /// @brief __0001 0000 0000 0000 0000 0000 0000 0000__ :\n This type supports pre record time (@ref kodi::addon::PVRTimer::SetMarginStart()).
230 PVR_TIMER_TYPE_SUPPORTS_START_MARGIN = (1 << 28),
231
232 /// @brief __0010 0000 0000 0000 0000 0000 0000 0000__ :\n This type supports post record time (@ref kodi::addon::PVRTimer::SetMarginEnd()).
233 PVR_TIMER_TYPE_SUPPORTS_END_MARGIN = (1 << 29),
234 } PVR_TIMER_TYPES;
235 ///@}
236 //----------------------------------------------------------------------------
237
238 //============================================================================
239 /// @defgroup cpp_kodi_addon_pvr_Defs_Timer_PVR_WEEKDAY enum PVR_WEEKDAY
240 /// @ingroup cpp_kodi_addon_pvr_Defs_Timer
241 /// @brief **PVR timer weekdays** (@ref kodi::addon::PVRTimer::SetWeekdays() **values**)\n
242 /// Used to select the days of a week you want.
243 ///
244 /// It can be also used to select several days e.g.:
245 /// ~~~~~~~~~~~~~{.cpp}
246 /// ...
247 /// unsigned int day = PVR_WEEKDAY_MONDAY | PVR_WEEKDAY_SATURDAY;
248 /// ...
249 /// ~~~~~~~~~~~~~
250 ///
251 ///@{
252 typedef enum PVR_WEEKDAYS
253 {
254 /// @brief __0000 0000__ : Nothing selected.
255 PVR_WEEKDAY_NONE = 0,
256
257 /// @brief __0000 0001__ : To select Monday.
258 PVR_WEEKDAY_MONDAY = (1 << 0),
259
260 /// @brief __0000 0010__ : To select Tuesday.
261 PVR_WEEKDAY_TUESDAY = (1 << 1),
262
263 /// @brief __0000 0100__ : To select Wednesday.
264 PVR_WEEKDAY_WEDNESDAY = (1 << 2),
265
266 /// @brief __0000 1000__ : To select Thursday.
267 PVR_WEEKDAY_THURSDAY = (1 << 3),
268
269 /// @brief __0001 0000__ : To select Friday.
270 PVR_WEEKDAY_FRIDAY = (1 << 4),
271
272 /// @brief __0010 0000__ : To select Saturday.
273 PVR_WEEKDAY_SATURDAY = (1 << 5),
274
275 /// @brief __0100 0000__ : To select Sunday.
276 PVR_WEEKDAY_SUNDAY = (1 << 6),
277
278 /// @brief __0111 1111__ : To select all days of week.
279 PVR_WEEKDAY_ALLDAYS = PVR_WEEKDAY_MONDAY | PVR_WEEKDAY_TUESDAY | PVR_WEEKDAY_WEDNESDAY |
280 PVR_WEEKDAY_THURSDAY | PVR_WEEKDAY_FRIDAY | PVR_WEEKDAY_SATURDAY |
281 PVR_WEEKDAY_SUNDAY
282 } PVR_WEEKDAY;
283 ///@}
284 //----------------------------------------------------------------------------
285
286 //============================================================================
287 /// @defgroup cpp_kodi_addon_pvr_Defs_Timer_PVR_TIMER_STATE enum PVR_TIMER_STATE
288 /// @ingroup cpp_kodi_addon_pvr_Defs_Timer
289 /// @brief **PVR timer states**\n
290 /// To set within @ref cpp_kodi_addon_pvr_Defs_Timer_PVRTimer "kodi::addon::PVRTimer"
291 /// the needed state about.
292 ///
293 ///@{
294 typedef enum PVR_TIMER_STATE
295 {
296 /// @brief __0__ : The timer was just created on the backend and is not yet active.
297 ///
298 /// This state must not be used for timers just created on the client side.
299 PVR_TIMER_STATE_NEW = 0,
300
301 /// @brief __1__ : The timer is scheduled for recording.
302 PVR_TIMER_STATE_SCHEDULED = 1,
303
304 /// @brief __2__ : The timer is currently recordings.
305 PVR_TIMER_STATE_RECORDING = 2,
306
307 /// @brief __3__ : The recording completed successfully.
308 PVR_TIMER_STATE_COMPLETED = 3,
309
310 /// @brief __4__ : Recording started, but was aborted.
311 PVR_TIMER_STATE_ABORTED = 4,
312
313 /// @brief __5__ : The timer was scheduled, but was canceled.
314 PVR_TIMER_STATE_CANCELLED = 5,
315
316 /// @brief __6__ : The scheduled timer conflicts with another one, but will be
317 /// recorded.
318 PVR_TIMER_STATE_CONFLICT_OK = 6,
319
320 /// @brief __7__ : The scheduled timer conflicts with another one and won't be
321 /// recorded.
322 PVR_TIMER_STATE_CONFLICT_NOK = 7,
323
324 /// @brief __8__ : The timer is scheduled, but can't be recorded for some reason.
325 PVR_TIMER_STATE_ERROR = 8,
326
327 /// @brief __9__ : The timer was disabled by the user, can be enabled via setting
328 /// the state to @ref PVR_TIMER_STATE_SCHEDULED.
329 PVR_TIMER_STATE_DISABLED = 9,
330 } PVR_TIMER_STATE;
331 ///@}
332 //----------------------------------------------------------------------------
333
334 /*!
335 * @brief "C" PVR add-on timer event.
336 *
337 * Structure used to interface in "C" between Kodi and Addon.
338 *
339 * See @ref cpp_kodi_addon_pvr_Defs_Timer_PVRTimer "kodi::addon::PVRTimer" for
340 * description of values.
341 */
342 typedef struct PVR_TIMER
343 {
344 unsigned int iClientIndex;
345 unsigned int iParentClientIndex;
346 int iClientChannelUid;
347 time_t startTime;
348 time_t endTime;
349 bool bStartAnyTime;
350 bool bEndAnyTime;
351 enum PVR_TIMER_STATE state;
352 unsigned int iTimerType;
353 char strTitle[PVR_ADDON_NAME_STRING_LENGTH];
354 char strEpgSearchString[PVR_ADDON_NAME_STRING_LENGTH];
355 bool bFullTextEpgSearch;
356 char strDirectory[PVR_ADDON_URL_STRING_LENGTH];
357 char strSummary[PVR_ADDON_DESC_STRING_LENGTH];
358 int iPriority;
359 int iLifetime;
360 int iMaxRecordings;
361 unsigned int iRecordingGroup;
362 time_t firstDay;
363 unsigned int iWeekdays;
364 unsigned int iPreventDuplicateEpisodes;
365 unsigned int iEpgUid;
366 unsigned int iMarginStart;
367 unsigned int iMarginEnd;
368 int iGenreType;
369 int iGenreSubType;
370 char strSeriesLink[PVR_ADDON_URL_STRING_LENGTH];
371 } PVR_TIMER;
372
373 /*!
374 * @brief "C" PVR add-on timer event type.
375 *
376 * Structure used to interface in "C" between Kodi and Addon.
377 *
378 * See @ref cpp_kodi_addon_pvr_Defs_Timer_PVRTimerType "kodi::addon::PVRTimerType" for
379 * description of values.
380 */
381 typedef struct PVR_TIMER_TYPE
382 {
383 unsigned int iId;
384 uint64_t iAttributes;
385 char strDescription[PVR_ADDON_TIMERTYPE_STRING_LENGTH];
386
387 unsigned int iPrioritiesSize;
388 struct PVR_ATTRIBUTE_INT_VALUE priorities[PVR_ADDON_TIMERTYPE_VALUES_ARRAY_SIZE];
389 int iPrioritiesDefault;
390
391 unsigned int iLifetimesSize;
392 struct PVR_ATTRIBUTE_INT_VALUE lifetimes[PVR_ADDON_TIMERTYPE_VALUES_ARRAY_SIZE];
393 int iLifetimesDefault;
394
395 unsigned int iPreventDuplicateEpisodesSize;
396 struct PVR_ATTRIBUTE_INT_VALUE preventDuplicateEpisodes[PVR_ADDON_TIMERTYPE_VALUES_ARRAY_SIZE];
397 unsigned int iPreventDuplicateEpisodesDefault;
398
399 unsigned int iRecordingGroupSize;
400 struct PVR_ATTRIBUTE_INT_VALUE recordingGroup[PVR_ADDON_TIMERTYPE_VALUES_ARRAY_SIZE];
401 unsigned int iRecordingGroupDefault;
402
403 unsigned int iMaxRecordingsSize;
404 struct PVR_ATTRIBUTE_INT_VALUE maxRecordings[PVR_ADDON_TIMERTYPE_VALUES_ARRAY_SIZE_SMALL];
405 int iMaxRecordingsDefault;
406 } PVR_TIMER_TYPE;
407
408#ifdef __cplusplus
409}
410#endif /* __cplusplus */
411
412#endif /* !C_API_ADDONINSTANCE_PVR_TIMERS_H */
diff --git a/xbmc/addons/kodi-dev-kit/include/kodi/c-api/addon-instance/screensaver.h b/xbmc/addons/kodi-dev-kit/include/kodi/c-api/addon-instance/screensaver.h
new file mode 100644
index 0000000..32cf6e1
--- /dev/null
+++ b/xbmc/addons/kodi-dev-kit/include/kodi/c-api/addon-instance/screensaver.h
@@ -0,0 +1,75 @@
1/*
2 * Copyright (C) 2005-2020 Team Kodi
3 * This file is part of Kodi - https://kodi.tv
4 *
5 * SPDX-License-Identifier: GPL-2.0-or-later
6 * See LICENSES/README.md for more information.
7 */
8
9#pragma once
10
11#include "../addon_base.h"
12
13#ifdef __cplusplus
14extern "C"
15{
16#endif /* __cplusplus */
17
18 struct AddonInstance_Screensaver;
19
20 /*!
21 * @brief Screensaver properties
22 *
23 * Not to be used outside this header.
24 */
25 typedef struct AddonProps_Screensaver
26 {
27 ADDON_HARDWARE_CONTEXT device;
28 int x;
29 int y;
30 int width;
31 int height;
32 float pixelRatio;
33 const char* name;
34 const char* presets;
35 const char* profile;
36 } AddonProps_Screensaver;
37
38 /*!
39 * @brief Screensaver callbacks
40 *
41 * Not to be used outside this header.
42 */
43 typedef struct AddonToKodiFuncTable_Screensaver
44 {
45 KODI_HANDLE kodiInstance;
46 } AddonToKodiFuncTable_Screensaver;
47
48 /*!
49 * @brief Screensaver function hooks
50 *
51 * Not to be used outside this header.
52 */
53 typedef struct KodiToAddonFuncTable_Screensaver
54 {
55 KODI_HANDLE addonInstance;
56 bool(__cdecl* Start)(struct AddonInstance_Screensaver* instance);
57 void(__cdecl* Stop)(struct AddonInstance_Screensaver* instance);
58 void(__cdecl* Render)(struct AddonInstance_Screensaver* instance);
59 } KodiToAddonFuncTable_Screensaver;
60
61 /*!
62 * @brief Screensaver instance
63 *
64 * Not to be used outside this header.
65 */
66 typedef struct AddonInstance_Screensaver
67 {
68 struct AddonProps_Screensaver* props;
69 struct AddonToKodiFuncTable_Screensaver* toKodi;
70 struct KodiToAddonFuncTable_Screensaver* toAddon;
71 } AddonInstance_Screensaver;
72
73#ifdef __cplusplus
74} /* extern "C" */
75#endif /* __cplusplus */
diff --git a/xbmc/addons/kodi-dev-kit/include/kodi/c-api/addon-instance/vfs.h b/xbmc/addons/kodi-dev-kit/include/kodi/c-api/addon-instance/vfs.h
new file mode 100644
index 0000000..a6c3f44
--- /dev/null
+++ b/xbmc/addons/kodi-dev-kit/include/kodi/c-api/addon-instance/vfs.h
@@ -0,0 +1,149 @@
1/*
2 * Copyright (C) 2005-2020 Team Kodi
3 *
4 * SPDX-License-Identifier: GPL-2.0-or-later
5 * See LICENSES/README.md for more information.
6 */
7
8#pragma once
9
10#ifndef C_API_ADDONINSTANCE_VFS_H
11#define C_API_ADDONINSTANCE_VFS_H
12
13#include "../addon_base.h"
14#include "../filesystem.h"
15
16#define VFS_FILE_HANDLE void*
17
18#ifdef __cplusplus
19extern "C"
20{
21#endif /* __cplusplus */
22
23 struct VFSURL
24 {
25 const char* url;
26 const char* domain;
27 const char* hostname;
28 const char* filename;
29 unsigned int port;
30 const char* options;
31 const char* username;
32 const char* password;
33 const char* redacted;
34 const char* sharename;
35 const char* protocol;
36 };
37
38 typedef struct VFSGetDirectoryCallbacks /* internal */
39 {
40 bool(__cdecl* get_keyboard_input)(KODI_HANDLE ctx,
41 const char* heading,
42 char** input,
43 bool hidden_input);
44 void(__cdecl* set_error_dialog)(KODI_HANDLE ctx,
45 const char* heading,
46 const char* line1,
47 const char* line2,
48 const char* line3);
49 void(__cdecl* require_authentication)(KODI_HANDLE ctx, const char* url);
50 KODI_HANDLE ctx;
51 } VFSGetDirectoryCallbacks;
52
53 typedef struct AddonProps_VFSEntry /* internal */
54 {
55 int dummy;
56 } AddonProps_VFSEntry;
57
58 typedef struct AddonToKodiFuncTable_VFSEntry /* internal */
59 {
60 KODI_HANDLE kodiInstance;
61 } AddonToKodiFuncTable_VFSEntry;
62
63 struct AddonInstance_VFSEntry;
64 typedef struct KodiToAddonFuncTable_VFSEntry /* internal */
65 {
66 KODI_HANDLE addonInstance;
67
68 VFS_FILE_HANDLE(__cdecl* open)
69 (const struct AddonInstance_VFSEntry* instance, const struct VFSURL* url);
70 VFS_FILE_HANDLE(__cdecl* open_for_write)
71 (const struct AddonInstance_VFSEntry* instance, const struct VFSURL* url, bool overwrite);
72 ssize_t(__cdecl* read)(const struct AddonInstance_VFSEntry* instance,
73 VFS_FILE_HANDLE context,
74 uint8_t* buffer,
75 size_t buf_size);
76 ssize_t(__cdecl* write)(const struct AddonInstance_VFSEntry* instance,
77 VFS_FILE_HANDLE context,
78 const uint8_t* buffer,
79 size_t buf_size);
80 int64_t(__cdecl* seek)(const struct AddonInstance_VFSEntry* instance,
81 VFS_FILE_HANDLE context,
82 int64_t position,
83 int whence);
84 int(__cdecl* truncate)(const struct AddonInstance_VFSEntry* instance,
85 VFS_FILE_HANDLE context,
86 int64_t size);
87 int64_t(__cdecl* get_length)(const struct AddonInstance_VFSEntry* instance,
88 VFS_FILE_HANDLE context);
89 int64_t(__cdecl* get_position)(const struct AddonInstance_VFSEntry* instance,
90 VFS_FILE_HANDLE context);
91 int(__cdecl* get_chunk_size)(const struct AddonInstance_VFSEntry* instance,
92 VFS_FILE_HANDLE context);
93 bool(__cdecl* io_control_get_seek_possible)(const struct AddonInstance_VFSEntry* instance,
94 VFS_FILE_HANDLE context);
95 bool(__cdecl* io_control_get_cache_status)(const struct AddonInstance_VFSEntry* instance,
96 VFS_FILE_HANDLE context,
97 VFS_CACHE_STATUS_DATA* status);
98 bool(__cdecl* io_control_set_cache_rate)(const struct AddonInstance_VFSEntry* instance,
99 VFS_FILE_HANDLE context,
100 unsigned int rate);
101 bool(__cdecl* io_control_set_retry)(const struct AddonInstance_VFSEntry* instance,
102 VFS_FILE_HANDLE context,
103 bool retry);
104 int(__cdecl* stat)(const struct AddonInstance_VFSEntry* instance,
105 const struct VFSURL* url,
106 struct STAT_STRUCTURE* buffer);
107 bool(__cdecl* close)(const struct AddonInstance_VFSEntry* instance, VFS_FILE_HANDLE context);
108
109 bool(__cdecl* exists)(const struct AddonInstance_VFSEntry* instance, const struct VFSURL* url);
110 void(__cdecl* clear_out_idle)(const struct AddonInstance_VFSEntry* instance);
111 void(__cdecl* disconnect_all)(const struct AddonInstance_VFSEntry* instance);
112 bool(__cdecl* delete_it)(const struct AddonInstance_VFSEntry* instance,
113 const struct VFSURL* url);
114 bool(__cdecl* rename)(const struct AddonInstance_VFSEntry* instance,
115 const struct VFSURL* url,
116 const struct VFSURL* url2);
117 bool(__cdecl* directory_exists)(const struct AddonInstance_VFSEntry* instance,
118 const struct VFSURL* url);
119 bool(__cdecl* remove_directory)(const struct AddonInstance_VFSEntry* instance,
120 const struct VFSURL* url);
121 bool(__cdecl* create_directory)(const struct AddonInstance_VFSEntry* instance,
122 const struct VFSURL* url);
123 bool(__cdecl* get_directory)(const struct AddonInstance_VFSEntry* instance,
124 const struct VFSURL* url,
125 struct VFSDirEntry** entries,
126 int* num_entries,
127 struct VFSGetDirectoryCallbacks* callbacks);
128 bool(__cdecl* contains_files)(const struct AddonInstance_VFSEntry* instance,
129 const struct VFSURL* url,
130 struct VFSDirEntry** entries,
131 int* num_entries,
132 char* rootpath);
133 void(__cdecl* free_directory)(const struct AddonInstance_VFSEntry* instance,
134 struct VFSDirEntry* entries,
135 int num_entries);
136 } KodiToAddonFuncTable_VFSEntry;
137
138 typedef struct AddonInstance_VFSEntry /* internal */
139 {
140 struct AddonProps_VFSEntry* props;
141 struct AddonToKodiFuncTable_VFSEntry* toKodi;
142 struct KodiToAddonFuncTable_VFSEntry* toAddon;
143 } AddonInstance_VFSEntry;
144
145#ifdef __cplusplus
146} /* extern "C" */
147#endif /* __cplusplus */
148
149#endif /* !C_API_ADDONINSTANCE_VFS_H */
diff --git a/xbmc/addons/kodi-dev-kit/include/kodi/c-api/addon-instance/visualization.h b/xbmc/addons/kodi-dev-kit/include/kodi/c-api/addon-instance/visualization.h
new file mode 100644
index 0000000..913aad8
--- /dev/null
+++ b/xbmc/addons/kodi-dev-kit/include/kodi/c-api/addon-instance/visualization.h
@@ -0,0 +1,117 @@
1/*
2 * Copyright (C) 2005-2020 Team Kodi
3 * This file is part of Kodi - https://kodi.tv
4 *
5 * SPDX-License-Identifier: GPL-2.0-or-later
6 * See LICENSES/README.md for more information.
7 */
8
9#pragma once
10
11#include "../addon_base.h"
12
13#define VIZ_LYRICS_SIZE 32768
14
15#ifdef __cplusplus
16extern "C"
17{
18#endif /* __cplusplus */
19
20 struct VIS_INFO
21 {
22 bool bWantsFreq;
23 int iSyncDelay;
24 };
25
26 struct VIS_TRACK
27 {
28 const char *title;
29 const char *artist;
30 const char *album;
31 const char *albumArtist;
32 const char *genre;
33 const char *comment;
34 const char *lyrics;
35
36 const char *reserved1;
37 const char *reserved2;
38
39 int trackNumber;
40 int discNumber;
41 int duration;
42 int year;
43 int rating;
44
45 int reserved3;
46 int reserved4;
47 };
48
49 typedef struct AddonProps_Visualization
50 {
51 ADDON_HARDWARE_CONTEXT device;
52 int x;
53 int y;
54 int width;
55 int height;
56 float pixelRatio;
57 const char* name;
58 const char* presets;
59 const char* profile;
60 } AddonProps_Visualization;
61
62 typedef struct AddonToKodiFuncTable_Visualization
63 {
64 KODI_HANDLE kodiInstance;
65 void(__cdecl* transfer_preset)(KODI_HANDLE kodiInstance, const char* preset);
66 void(__cdecl* clear_presets)(KODI_HANDLE kodiInstance);
67 } AddonToKodiFuncTable_Visualization;
68
69 struct AddonInstance_Visualization;
70
71 typedef struct KodiToAddonFuncTable_Visualization
72 {
73 KODI_HANDLE addonInstance;
74 bool(__cdecl* start)(const struct AddonInstance_Visualization* instance,
75 int channels,
76 int samples_per_sec,
77 int bits_per_sample,
78 const char* song_name);
79 void(__cdecl* stop)(const struct AddonInstance_Visualization* instance);
80
81 void(__cdecl* get_info)(const struct AddonInstance_Visualization* instance,
82 struct VIS_INFO* info);
83
84 void(__cdecl* audio_data)(const struct AddonInstance_Visualization* instance,
85 const float* audio_data,
86 int audio_data_length,
87 float* freq_data,
88 int freq_data_length);
89 bool(__cdecl* is_dirty)(const struct AddonInstance_Visualization* instance);
90 void(__cdecl* render)(const struct AddonInstance_Visualization* instance);
91
92 unsigned int(__cdecl* get_presets)(const struct AddonInstance_Visualization* instance);
93 int(__cdecl* get_active_preset)(const struct AddonInstance_Visualization* instance);
94 bool(__cdecl* prev_preset)(const struct AddonInstance_Visualization* instance);
95 bool(__cdecl* next_preset)(const struct AddonInstance_Visualization* instance);
96 bool(__cdecl* load_preset)(const struct AddonInstance_Visualization* instance, int select);
97 bool(__cdecl* random_preset)(const struct AddonInstance_Visualization* instance);
98 bool(__cdecl* lock_preset)(const struct AddonInstance_Visualization* instance);
99 bool(__cdecl* rate_preset)(const struct AddonInstance_Visualization* instance, bool plus_minus);
100 bool(__cdecl* is_locked)(const struct AddonInstance_Visualization* instance);
101
102 bool(__cdecl* update_albumart)(const struct AddonInstance_Visualization* instance,
103 const char* albumart);
104 bool(__cdecl* update_track)(const struct AddonInstance_Visualization* instance,
105 const struct VIS_TRACK* track);
106 } KodiToAddonFuncTable_Visualization;
107
108 typedef struct AddonInstance_Visualization
109 {
110 struct AddonProps_Visualization* props;
111 struct AddonToKodiFuncTable_Visualization* toKodi;
112 struct KodiToAddonFuncTable_Visualization* toAddon;
113 } AddonInstance_Visualization;
114
115#ifdef __cplusplus
116} /* extern "C" */
117#endif /* __cplusplus */
diff --git a/xbmc/addons/kodi-dev-kit/include/kodi/c-api/addon_base.h b/xbmc/addons/kodi-dev-kit/include/kodi/c-api/addon_base.h
new file mode 100644
index 0000000..faa99fa
--- /dev/null
+++ b/xbmc/addons/kodi-dev-kit/include/kodi/c-api/addon_base.h
@@ -0,0 +1,264 @@
1/*
2 * Copyright (C) 2005-2019 Team Kodi
3 * This file is part of Kodi - https://kodi.tv
4 *
5 * SPDX-License-Identifier: GPL-2.0-or-later
6 * See LICENSES/README.md for more information.
7 */
8
9#pragma once
10
11#ifndef C_API_ADDON_BASE_H
12#define C_API_ADDON_BASE_H
13
14#if !defined(NOMINMAX)
15#define NOMINMAX
16#endif
17
18#include "stdbool.h"
19#include "stdint.h"
20
21#ifndef TARGET_WINDOWS
22#ifndef __cdecl
23#define __cdecl
24#endif
25#ifndef __declspec
26#define __declspec(X)
27#endif
28#endif
29
30#undef ATTRIBUTE_PACKED
31#undef PRAGMA_PACK_BEGIN
32#undef PRAGMA_PACK_END
33
34#if defined(__GNUC__)
35#define ATTRIBUTE_PACKED __attribute__((packed))
36#define PRAGMA_PACK 0
37#define ATTRIBUTE_HIDDEN __attribute__((visibility("hidden")))
38#endif
39
40#if !defined(ATTRIBUTE_PACKED)
41#define ATTRIBUTE_PACKED
42#define PRAGMA_PACK 1
43#endif
44
45#if !defined(ATTRIBUTE_HIDDEN)
46#define ATTRIBUTE_HIDDEN
47#endif
48
49#ifdef _MSC_VER
50#define ATTRIBUTE_FORCEINLINE __forceinline
51#elif defined(__GNUC__)
52#define ATTRIBUTE_FORCEINLINE inline __attribute__((__always_inline__))
53#elif defined(__CLANG__)
54#if __has_attribute(__always_inline__)
55#define ATTRIBUTE_FORCEINLINE inline __attribute__((__always_inline__))
56#else
57#define ATTRIBUTE_FORCEINLINE inline
58#endif
59#else
60#define ATTRIBUTE_FORCEINLINE inline
61#endif
62
63// Hardware specific device context interface
64#define ADDON_HARDWARE_CONTEXT void*
65
66/*
67 * To have a on add-on and kodi itself handled string always on known size!
68 */
69#define ADDON_STANDARD_STRING_LENGTH 1024
70#define ADDON_STANDARD_STRING_LENGTH_SMALL 256
71
72#ifdef __cplusplus
73extern "C"
74{
75#endif /* __cplusplus */
76
77 //============================================================================
78 /// @ingroup cpp_kodi_addon_addonbase
79 /// @brief Return value of functions in @ref cpp_kodi_addon_addonbase "kodi::addon::CAddonBase"
80 /// and associated classes.
81 ///
82 ///@{
83 typedef enum ADDON_STATUS
84 {
85 /// @brief For everything OK and no error
86 ADDON_STATUS_OK,
87
88 /// @brief A needed connection was lost
89 ADDON_STATUS_LOST_CONNECTION,
90
91 /// @brief Addon needs a restart inside Kodi
92 ADDON_STATUS_NEED_RESTART,
93
94 /// @brief Necessary settings are not yet set
95 ADDON_STATUS_NEED_SETTINGS,
96
97 /// @brief Unknown and incomprehensible error
98 ADDON_STATUS_UNKNOWN,
99
100 /// @brief Permanent failure, like failing to resolve methods
101 ADDON_STATUS_PERMANENT_FAILURE,
102
103 /* internal used return error if function becomes not used from child on
104 * addon */
105 ADDON_STATUS_NOT_IMPLEMENTED
106 } ADDON_STATUS;
107 ///@}
108 //----------------------------------------------------------------------------
109
110 //============================================================================
111 /// @defgroup cpp_kodi_Defs_AddonLog enum AddonLog
112 /// @ingroup cpp_kodi_Defs
113 /// @brief **Log file type definitions**\n
114 /// These define the types of log entries given with @ref kodi::Log() to Kodi.
115 ///
116 /// -------------------------------------------------------------------------
117 ///
118 /// **Example:**
119 /// ~~~~~~~~~~~~~{.cpp}
120 /// #include <kodi/General.h>
121 ///
122 /// kodi::Log(ADDON_LOG_ERROR, "%s: There is an error occurred!", __func__);
123 ///
124 /// ~~~~~~~~~~~~~
125 ///
126 ///@{
127 typedef enum AddonLog
128 {
129 /// @brief **0** : To include debug information in the log file.
130 ADDON_LOG_DEBUG = 0,
131
132 /// @brief **1** : To include information messages in the log file.
133 ADDON_LOG_INFO = 1,
134
135 /// @brief **2** : To write warnings in the log file.
136 ADDON_LOG_WARNING = 2,
137
138 /// @brief **3** : To report error messages in the log file.
139 ADDON_LOG_ERROR = 3,
140
141 /// @brief **4** : To notify fatal unrecoverable errors, which can may also indicate
142 /// upcoming crashes.
143 ADDON_LOG_FATAL = 4
144 } AddonLog;
145 ///@}
146 //----------------------------------------------------------------------------
147
148 /*! @brief Standard undefined pointer handle */
149 typedef void* KODI_HANDLE;
150
151 /*!
152 * @brief Handle used to return data from the PVR add-on to CPVRClient
153 */
154 struct ADDON_HANDLE_STRUCT
155 {
156 void* callerAddress; /*!< address of the caller */
157 void* dataAddress; /*!< address to store data in */
158 int dataIdentifier; /*!< parameter to pass back when calling the callback */
159 };
160 typedef struct ADDON_HANDLE_STRUCT* ADDON_HANDLE;
161
162 /*!
163 * @brief Callback function tables from addon to Kodi
164 * Set complete from Kodi!
165 */
166 struct AddonToKodiFuncTable_kodi;
167 struct AddonToKodiFuncTable_kodi_audioengine;
168 struct AddonToKodiFuncTable_kodi_filesystem;
169 struct AddonToKodiFuncTable_kodi_network;
170 struct AddonToKodiFuncTable_kodi_gui;
171 typedef struct AddonToKodiFuncTable_Addon
172 {
173 // Pointer inside Kodi, used on callback functions to give related handle
174 // class, for this ADDON::CAddonDll inside Kodi.
175 KODI_HANDLE kodiBase;
176
177 // Function addresses used for callbacks from addon to Kodi
178 char* (*get_type_version)(void* kodiBase, int type);
179
180 void (*free_string)(void* kodiBase, char* str);
181 void (*free_string_array)(void* kodiBase, char** arr, int numElements);
182 char* (*get_addon_path)(void* kodiBase);
183 char* (*get_base_user_path)(void* kodiBase);
184 void (*addon_log_msg)(void* kodiBase, const int loglevel, const char* msg);
185
186 bool (*get_setting_bool)(void* kodiBase, const char* id, bool* value);
187 bool (*get_setting_int)(void* kodiBase, const char* id, int* value);
188 bool (*get_setting_float)(void* kodiBase, const char* id, float* value);
189 bool (*get_setting_string)(void* kodiBase, const char* id, char** value);
190
191 bool (*set_setting_bool)(void* kodiBase, const char* id, bool value);
192 bool (*set_setting_int)(void* kodiBase, const char* id, int value);
193 bool (*set_setting_float)(void* kodiBase, const char* id, float value);
194 bool (*set_setting_string)(void* kodiBase, const char* id, const char* value);
195
196 void* (*get_interface)(void* kodiBase, const char* name, const char* version);
197
198 struct AddonToKodiFuncTable_kodi* kodi;
199 struct AddonToKodiFuncTable_kodi_audioengine* kodi_audioengine;
200 struct AddonToKodiFuncTable_kodi_filesystem* kodi_filesystem;
201 struct AddonToKodiFuncTable_kodi_gui* kodi_gui;
202 struct AddonToKodiFuncTable_kodi_network* kodi_network;
203
204 // Move up by min version change about
205 bool (*is_setting_using_default)(void* kodiBase, const char* id);
206 } AddonToKodiFuncTable_Addon;
207
208 /*!
209 * @brief Function tables from Kodi to addon
210 */
211 typedef struct KodiToAddonFuncTable_Addon
212 {
213 void (*destroy)();
214 ADDON_STATUS (*get_status)();
215 ADDON_STATUS(*create_instance)
216 (int instanceType,
217 const char* instanceID,
218 KODI_HANDLE instance,
219 const char* version,
220 KODI_HANDLE* addonInstance,
221 KODI_HANDLE parent);
222 void (*destroy_instance)(int instanceType, KODI_HANDLE instance);
223 ADDON_STATUS (*set_setting)(const char* settingName, const void* settingValue);
224 } KodiToAddonFuncTable_Addon;
225
226 /*!
227 * @brief Main structure passed from kodi to addon with basic information needed to
228 * create add-on.
229 */
230 typedef struct AddonGlobalInterface
231 {
232 // String with full path where add-on is installed (without his name on end)
233 // Set from Kodi!
234 const char* libBasePath;
235
236 // Master API version of Kodi itself (ADDON_GLOBAL_VERSION_MAIN)
237 const char* kodi_base_api_version;
238
239 // Pointer of first created instance, used in case this add-on goes with single way
240 // Set from Kodi!
241 KODI_HANDLE firstKodiInstance;
242
243 // Pointer to master base class inside add-on
244 // Set from addon header (kodi::addon::CAddonBase)!
245 KODI_HANDLE addonBase;
246
247 // Pointer to a instance used on single way (together with this class)
248 // Set from addon header (kodi::addon::IAddonInstance)!
249 KODI_HANDLE globalSingleInstance;
250
251 // Callback function tables from addon to Kodi
252 // Set from Kodi!
253 AddonToKodiFuncTable_Addon* toKodi;
254
255 // Function tables from Kodi to addon
256 // Set from addon header!
257 KodiToAddonFuncTable_Addon* toAddon;
258 } AddonGlobalInterface;
259
260#ifdef __cplusplus
261}
262#endif /* __cplusplus */
263
264#endif /* !C_API_ADDON_BASE_H */
diff --git a/xbmc/addons/kodi-dev-kit/include/kodi/c-api/audio_engine.h b/xbmc/addons/kodi-dev-kit/include/kodi/c-api/audio_engine.h
new file mode 100644
index 0000000..97510f7
--- /dev/null
+++ b/xbmc/addons/kodi-dev-kit/include/kodi/c-api/audio_engine.h
@@ -0,0 +1,314 @@
1/*
2 * Copyright (C) 2005-2019 Team Kodi
3 * This file is part of Kodi - https://kodi.tv
4 *
5 * SPDX-License-Identifier: GPL-2.0-or-later
6 * See LICENSES/README.md for more information.
7 */
8
9#pragma once
10
11#ifndef C_API_AUDIO_ENGINE_H
12#define C_API_AUDIO_ENGINE_H
13
14#include <stdbool.h>
15#include <stdint.h>
16
17#ifdef __cplusplus
18extern "C"
19{
20#endif /* __cplusplus */
21
22 //¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯
23 // "C" Definitions, structures and enumerators of audio engine
24 //{{{
25
26 //============================================================================
27 /// @defgroup cpp_kodi_audioengine_Defs_AudioEngineStreamOptions enum AudioEngineStreamOptions
28 /// @ingroup cpp_kodi_audioengine_Defs
29 /// @brief **Bit options to pass to CAEStream**\n
30 /// A bit field of stream options.
31 ///
32 ///
33 /// ------------------------------------------------------------------------
34 ///
35 /// **Usage example:**
36 /// ~~~~~~~~~~~~~{.cpp}
37 /// // Here only as minimal, "format" must be set to wanted types
38 /// kodi::audioengine::AudioEngineFormat format;
39 /// m_audioengine = new kodi::audioengine::CAEStream(format, AUDIO_STREAM_FORCE_RESAMPLE | AUDIO_STREAM_AUTOSTART);
40 /// ~~~~~~~~~~~~~
41 ///
42 ///@{
43 typedef enum AudioEngineStreamOptions
44 {
45 /// force resample even if rates match
46 AUDIO_STREAM_FORCE_RESAMPLE = 1 << 0,
47 /// create the stream paused
48 AUDIO_STREAM_PAUSED = 1 << 1,
49 /// autostart the stream when enough data is buffered
50 AUDIO_STREAM_AUTOSTART = 1 << 2,
51 } AudioEngineStreamOptions;
52 ///@}
53 //----------------------------------------------------------------------------
54
55 //============================================================================
56 /// @defgroup cpp_kodi_audioengine_Defs_AudioEngineChannel enum AudioEngineChannel
57 /// @ingroup cpp_kodi_audioengine_Defs
58 /// @brief **The possible channels**\n
59 /// Used to set available or used channels on stream.
60 ///
61 ///
62 /// ------------------------------------------------------------------------
63 ///
64 /// **Usage example:**
65 /// ~~~~~~~~~~~~~{.cpp}
66 /// kodi::audioengine::AudioEngineFormat format;
67 /// format.SetChannelLayout(std::vector<AudioEngineChannel>(AUDIOENGINE_CH_FL, AUDIOENGINE_CH_FR));
68 /// ~~~~~~~~~~~~~
69 ///
70 ///@{
71 enum AudioEngineChannel
72 {
73 /// Used inside to indicate the end of a list and not for addon use directly.
74 AUDIOENGINE_CH_NULL = -1,
75 /// RAW Audio format
76 AUDIOENGINE_CH_RAW,
77 /// Front left
78 AUDIOENGINE_CH_FL,
79 /// Front right
80 AUDIOENGINE_CH_FR,
81 /// Front center
82 AUDIOENGINE_CH_FC,
83 /// LFE / Subwoofer
84 AUDIOENGINE_CH_LFE,
85 /// Back left
86 AUDIOENGINE_CH_BL,
87 /// Back right
88 AUDIOENGINE_CH_BR,
89 /// Front left over center
90 AUDIOENGINE_CH_FLOC,
91 /// Front right over center
92 AUDIOENGINE_CH_FROC,
93 /// Back center
94 AUDIOENGINE_CH_BC,
95 /// Side left
96 AUDIOENGINE_CH_SL,
97 /// Side right
98 AUDIOENGINE_CH_SR,
99 /// Top front left
100 AUDIOENGINE_CH_TFL,
101 /// Top front right
102 AUDIOENGINE_CH_TFR,
103 /// Top front center
104 AUDIOENGINE_CH_TFC,
105 /// Top center
106 AUDIOENGINE_CH_TC,
107 /// Top back left
108 AUDIOENGINE_CH_TBL,
109 /// Top back right
110 AUDIOENGINE_CH_TBR,
111 /// Top back center
112 AUDIOENGINE_CH_TBC,
113 /// Back left over center
114 AUDIOENGINE_CH_BLOC,
115 /// Back right over center
116 AUDIOENGINE_CH_BROC,
117 /// Maximum possible value, to use e.g. as size inside list
118 AUDIOENGINE_CH_MAX
119 };
120 ///@}
121 //----------------------------------------------------------------------------
122
123 //============================================================================
124 /// @defgroup cpp_kodi_audioengine_Defs_AudioEngineDataFormat enum AudioEngineDataFormat
125 /// @ingroup cpp_kodi_audioengine_Defs
126 /// @brief **Audio sample formats**\n
127 /// The bit layout of the audio data.
128 ///
129 /// LE = Little Endian, BE = Big Endian, NE = Native Endian
130 ///
131 /// For planar sample formats, each audio channel is in a separate data plane,
132 /// and linesize is the buffer size, in bytes, for a single plane. All data
133 /// planes must be the same size. For packed sample formats, only the first
134 /// data plane is used, and samples for each channel are interleaved. In this
135 /// case, linesize is the buffer size, in bytes, for the 1 plane.
136 ///
137 /// @note This is ordered from the worst to best preferred formats
138 ///
139 ///
140 /// ------------------------------------------------------------------------
141 ///
142 /// **Usage example:**
143 /// ~~~~~~~~~~~~~{.cpp}
144 /// kodi::audioengine::AudioEngineFormat format;
145 /// format.SetDataFormat(AUDIOENGINE_FMT_FLOATP);
146 /// ~~~~~~~~~~~~~
147 ///
148 ///@{
149 enum AudioEngineDataFormat
150 {
151 /// To define format as invalid
152 AUDIOENGINE_FMT_INVALID = -1,
153
154 /// Unsigned integer 8 bit
155 AUDIOENGINE_FMT_U8,
156
157 /// Big Endian signed integer 16 bit
158 AUDIOENGINE_FMT_S16BE,
159 /// Little Endian signed integer 16 bit
160 AUDIOENGINE_FMT_S16LE,
161 /// Native Endian signed integer 16 bit
162 AUDIOENGINE_FMT_S16NE,
163
164 /// Big Endian signed integer 32 bit
165 AUDIOENGINE_FMT_S32BE,
166 /// Little Endian signed integer 32 bit
167 AUDIOENGINE_FMT_S32LE,
168 /// Native Endian signed integer 32 bit
169 AUDIOENGINE_FMT_S32NE,
170
171 /// Big Endian signed integer 24 bit (in 4 bytes)
172 AUDIOENGINE_FMT_S24BE4,
173 /// Little Endian signed integer 24 bit (in 4 bytes)
174 AUDIOENGINE_FMT_S24LE4,
175 /// Native Endian signed integer 24 bit (in 4 bytes)
176 AUDIOENGINE_FMT_S24NE4,
177 /// S32 with bits_per_sample < 32
178 AUDIOENGINE_FMT_S24NE4MSB,
179
180 /// Big Endian signed integer 24 bit (3 bytes)
181 AUDIOENGINE_FMT_S24BE3,
182 /// Little Endian signed integer 24 bit (3 bytes)
183 AUDIOENGINE_FMT_S24LE3,
184 /// Native Endian signed integer 24 bit (3 bytes)
185 AUDIOENGINE_FMT_S24NE3,
186
187 /// Double floating point
188 AUDIOENGINE_FMT_DOUBLE,
189 /// Floating point
190 AUDIOENGINE_FMT_FLOAT,
191
192 /// **Bitstream**\n
193 /// RAW Audio format
194 AUDIOENGINE_FMT_RAW,
195
196 /// **Planar format**\n
197 /// Unsigned byte
198 AUDIOENGINE_FMT_U8P,
199 /// **Planar format**\n
200 /// Native Endian signed 16 bit
201 AUDIOENGINE_FMT_S16NEP,
202 /// **Planar format**\n
203 /// Native Endian signed 32 bit
204 AUDIOENGINE_FMT_S32NEP,
205 /// **Planar format**\n
206 /// Native Endian signed integer 24 bit (in 4 bytes)
207 AUDIOENGINE_FMT_S24NE4P,
208 /// **Planar format**\n
209 /// S32 with bits_per_sample < 32
210 AUDIOENGINE_FMT_S24NE4MSBP,
211 /// **Planar format**\n
212 /// Native Endian signed integer 24 bit (in 3 bytes)
213 AUDIOENGINE_FMT_S24NE3P,
214 /// **Planar format**\n
215 /// Double floating point
216 AUDIOENGINE_FMT_DOUBLEP,
217 /// **Planar format**\n
218 /// Floating point
219 AUDIOENGINE_FMT_FLOATP,
220
221 /// Amount of sample formats.
222 AUDIOENGINE_FMT_MAX
223 };
224 ///@}
225 //----------------------------------------------------------------------------
226
227 /*!
228 * @brief Internal API structure which are used for data exchange between
229 * Kodi and addon.
230 */
231 struct AUDIO_ENGINE_FORMAT
232 {
233 /*! The stream's data format (eg, AUDIOENGINE_FMT_S16LE) */
234 enum AudioEngineDataFormat m_dataFormat;
235
236 /*! The stream's sample rate (eg, 48000) */
237 unsigned int m_sampleRate;
238
239 /*! The encoded streams sample rate if a bitstream, otherwise undefined */
240 unsigned int m_encodedRate;
241
242 /*! The amount of used speaker channels */
243 unsigned int m_channelCount;
244
245 /*! The stream's channel layout */
246 enum AudioEngineChannel m_channels[AUDIOENGINE_CH_MAX];
247
248 /*! The number of frames per period */
249 unsigned int m_frames;
250
251 /*! The size of one frame in bytes */
252 unsigned int m_frameSize;
253 };
254
255 /* A stream handle pointer, which is only used internally by the addon stream handle */
256 typedef void AEStreamHandle;
257
258 //}}}
259
260 //¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯
261 // "C" Internal interface tables for intercommunications between addon and kodi
262 //{{{
263
264 /*
265 * Function address structure, not need to visible on dev kit doxygen
266 * documentation
267 */
268 typedef struct AddonToKodiFuncTable_kodi_audioengine
269 {
270 AEStreamHandle* (*make_stream)(void* kodiBase,
271 struct AUDIO_ENGINE_FORMAT* format,
272 unsigned int options);
273 void (*free_stream)(void* kodiBase, AEStreamHandle* stream);
274 bool (*get_current_sink_format)(void* kodiBase, struct AUDIO_ENGINE_FORMAT* sink_format);
275
276 // Audio Engine Stream definitions
277 unsigned int (*aestream_get_space)(void* kodiBase, AEStreamHandle* handle);
278 unsigned int (*aestream_add_data)(void* kodiBase,
279 AEStreamHandle* handle,
280 uint8_t* const* data,
281 unsigned int offset,
282 unsigned int frames,
283 double pts,
284 bool hasDownmix,
285 double centerMixLevel);
286 double (*aestream_get_delay)(void* kodiBase, AEStreamHandle* handle);
287 bool (*aestream_is_buffering)(void* kodiBase, AEStreamHandle* handle);
288 double (*aestream_get_cache_time)(void* kodiBase, AEStreamHandle* handle);
289 double (*aestream_get_cache_total)(void* kodiBase, AEStreamHandle* handle);
290 void (*aestream_pause)(void* kodiBase, AEStreamHandle* handle);
291 void (*aestream_resume)(void* kodiBase, AEStreamHandle* handle);
292 void (*aestream_drain)(void* kodiBase, AEStreamHandle* handle, bool wait);
293 bool (*aestream_is_draining)(void* kodiBase, AEStreamHandle* handle);
294 bool (*aestream_is_drained)(void* kodiBase, AEStreamHandle* handle);
295 void (*aestream_flush)(void* kodiBase, AEStreamHandle* handle);
296 float (*aestream_get_volume)(void* kodiBase, AEStreamHandle* handle);
297 void (*aestream_set_volume)(void* kodiBase, AEStreamHandle* handle, float volume);
298 float (*aestream_get_amplification)(void* kodiBase, AEStreamHandle* handle);
299 void (*aestream_set_amplification)(void* kodiBase, AEStreamHandle* handle, float amplify);
300 unsigned int (*aestream_get_frame_size)(void* kodiBase, AEStreamHandle* handle);
301 unsigned int (*aestream_get_channel_count)(void* kodiBase, AEStreamHandle* handle);
302 unsigned int (*aestream_get_sample_rate)(void* kodiBase, AEStreamHandle* handle);
303 enum AudioEngineDataFormat (*aestream_get_data_format)(void* kodiBase, AEStreamHandle* handle);
304 double (*aestream_get_resample_ratio)(void* kodiBase, AEStreamHandle* handle);
305 void (*aestream_set_resample_ratio)(void* kodiBase, AEStreamHandle* handle, double ratio);
306 } AddonToKodiFuncTable_kodi_audioengine;
307
308 //}}}
309
310#ifdef __cplusplus
311}
312#endif /* __cplusplus */
313
314#endif /* !C_API_AUDIO_ENGINE_H */
diff --git a/xbmc/addons/kodi-dev-kit/include/kodi/c-api/filesystem.h b/xbmc/addons/kodi-dev-kit/include/kodi/c-api/filesystem.h
new file mode 100644
index 0000000..70f9400
--- /dev/null
+++ b/xbmc/addons/kodi-dev-kit/include/kodi/c-api/filesystem.h
@@ -0,0 +1,325 @@
1/*
2 * Copyright (C) 2005-2018 Team Kodi
3 * This file is part of Kodi - https://kodi.tv
4 *
5 * SPDX-License-Identifier: GPL-2.0-or-later
6 * See LICENSES/README.md for more information.
7 */
8
9#pragma once
10
11#ifndef C_API_FILESYSTEM_H
12#define C_API_FILESYSTEM_H
13
14#include <stdbool.h>
15#include <stdint.h>
16#include <time.h>
17
18#ifdef _WIN32 // windows
19#ifndef _SSIZE_T_DEFINED
20typedef intptr_t ssize_t;
21#define _SSIZE_T_DEFINED
22#endif // !_SSIZE_T_DEFINED
23
24// Prevent conflicts with Windows macros where have this names.
25#ifdef CreateDirectory
26#undef CreateDirectory
27#endif // CreateDirectory
28#ifdef DeleteFile
29#undef DeleteFile
30#endif // DeleteFile
31#ifdef RemoveDirectory
32#undef RemoveDirectory
33#endif // RemoveDirectory
34#endif // _WIN32
35
36#ifdef TARGET_POSIX // Linux, Mac, FreeBSD
37#include <sys/types.h>
38#endif // TARGET_POSIX
39
40#ifdef __cplusplus
41extern "C"
42{
43#endif /* __cplusplus */
44
45 //¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯
46 // "C" Definitions, structures and enumerators of filesystem
47 //{{{
48
49 //============================================================================
50 /// @defgroup cpp_kodi_vfs_Defs_OpenFileFlags enum OpenFileFlags
51 /// @ingroup cpp_kodi_vfs_Defs
52 /// @brief **Flags to define way how file becomes opened**\n
53 /// The values can be used together, e.g. <b>`file.Open("myfile", ADDON_READ_TRUNCATED | ADDON_READ_CHUNKED);`</b>
54 ///
55 /// Used on @ref kodi::vfs::CFile::OpenFile().
56 ///
57 ///@{
58 typedef enum OpenFileFlags
59 {
60 /// @brief **0000 0000 0001** :\n
61 /// Indicate that caller can handle truncated reads, where function
62 /// returns before entire buffer has been filled.
63 ADDON_READ_TRUNCATED = 0x01,
64
65 /// @brief **0000 0000 0010** :\n
66 /// Indicate that that caller support read in the minimum defined
67 /// chunk size, this disables internal cache then.
68 ADDON_READ_CHUNKED = 0x02,
69
70 /// @brief **0000 0000 0100** :\n
71 /// Use cache to access this file.
72 ADDON_READ_CACHED = 0x04,
73
74 /// @brief **0000 0000 1000** :\n
75 /// Open without caching. regardless to file type.
76 ADDON_READ_NO_CACHE = 0x08,
77
78 /// @brief **0000 0001 0000** :\n
79 /// Calcuate bitrate for file while reading.
80 ADDON_READ_BITRATE = 0x10,
81
82 /// @brief **0000 0010 0000** :\n
83 /// Indicate to the caller we will seek between multiple streams in
84 /// the file frequently.
85 ADDON_READ_MULTI_STREAM = 0x20,
86
87 /// @brief **0000 0100 0000** :\n
88 /// indicate to the caller file is audio and/or video (and e.g. may
89 /// grow).
90 ADDON_READ_AUDIO_VIDEO = 0x40,
91
92 /// @brief **0000 1000 0000** :\n
93 /// Indicate that caller will do write operations before reading.
94 ADDON_READ_AFTER_WRITE = 0x80,
95
96 /// @brief **0001 0000 0000** :\n
97 /// Indicate that caller want to reopen a file if its already open.
98 ADDON_READ_REOPEN = 0x100
99 } OpenFileFlags;
100 ///@}
101 //----------------------------------------------------------------------------
102
103 //============================================================================
104 /// @defgroup cpp_kodi_vfs_Defs_CURLOptiontype enum CURLOptiontype
105 /// @ingroup cpp_kodi_vfs_Defs
106 /// @brief **CURL message types**\n
107 /// Used on kodi::vfs::CFile::CURLAddOption().
108 ///
109 //@{
110 typedef enum CURLOptiontype
111 {
112 /// @brief Set a general option.
113 ADDON_CURL_OPTION_OPTION,
114
115 /// @brief Set a protocol option.
116 ///
117 /// The following names for *ADDON_CURL_OPTION_PROTOCOL* are possible:
118 ///
119 /// | Option name | Description
120 /// |------------------------------------:|:--------------------------------
121 /// | <b>`accept-charset`</b> | Set the "accept-charset" header
122 /// | <b>`acceptencoding or encoding`</b> | Set the "accept-encoding" header
123 /// | <b>`active-remote`</b> | Set the "active-remote" header
124 /// | <b>`auth`</b> | Set the authentication method. Possible values: any, anysafe, digest, ntlm
125 /// | <b>`connection-timeout`</b> | Set the connection timeout in seconds
126 /// | <b>`cookie`</b> | Set the "cookie" header
127 /// | <b>`customrequest`</b> | Set a custom HTTP request like DELETE
128 /// | <b>`noshout`</b> | Set to true if kodi detects a stream as shoutcast by mistake.
129 /// | <b>`postdata`</b> | Set the post body (value needs to be base64 encoded). (Implicitly sets the request to POST)
130 /// | <b>`referer`</b> | Set the "referer" header
131 /// | <b>`user-agent`</b> | Set the "user-agent" header
132 /// | <b>`seekable`</b> | Set the stream seekable. 1: enable, 0: disable
133 /// | <b>`sslcipherlist`</b> | Set list of accepted SSL ciphers.
134 ///
135 ADDON_CURL_OPTION_PROTOCOL,
136
137 /// @brief Set User and password
138 ADDON_CURL_OPTION_CREDENTIALS,
139
140 /// @brief Add a Header
141 ADDON_CURL_OPTION_HEADER
142 } CURLOptiontype;
143 //@}
144 //----------------------------------------------------------------------------
145
146 //============================================================================
147 /// @defgroup cpp_kodi_vfs_Defs_FilePropertyTypes enum FilePropertyTypes
148 /// @ingroup cpp_kodi_vfs_Defs
149 /// @brief **File property types**\n
150 /// Mostly to read internet sources.
151 ///
152 /// Used on kodi::vfs::CFile::GetPropertyValue() and kodi::vfs::CFile::GetPropertyValues().
153 ///
154 //@{
155 typedef enum FilePropertyTypes
156 {
157 /// @brief Get protocol response line.
158 ADDON_FILE_PROPERTY_RESPONSE_PROTOCOL,
159 /// @brief Get a response header.
160 ADDON_FILE_PROPERTY_RESPONSE_HEADER,
161 /// @brief Get file content type.
162 ADDON_FILE_PROPERTY_CONTENT_TYPE,
163 /// @brief Get file content charset.
164 ADDON_FILE_PROPERTY_CONTENT_CHARSET,
165 /// @brief Get file mime type.
166 ADDON_FILE_PROPERTY_MIME_TYPE,
167 /// @brief Get file effective URL (last one if redirected).
168 ADDON_FILE_PROPERTY_EFFECTIVE_URL
169 } FilePropertyTypes;
170 //@}
171 //----------------------------------------------------------------------------
172
173 //}}}
174
175 //¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯
176 // "C" Internal interface tables for intercommunications between addon and kodi
177 //{{{
178
179 struct KODI_HTTP_HEADER
180 {
181 void* handle;
182
183 char* (*get_value)(void* kodiBase, void* handle, const char* param);
184 char** (*get_values)(void* kodiBase, void* handle, const char* param, int* length);
185 char* (*get_header)(void* kodiBase, void* handle);
186 char* (*get_mime_type)(void* kodiBase, void* handle);
187 char* (*get_charset)(void* kodiBase, void* handle);
188 char* (*get_proto_line)(void* kodiBase, void* handle);
189 };
190
191 struct STAT_STRUCTURE
192 {
193 /// ID of device containing file
194 uint32_t deviceId;
195 /// Total size, in bytes
196 uint64_t size;
197 /// Time of last access
198 time_t accessTime;
199 /// Time of last modification
200 time_t modificationTime;
201 /// Time of last status change
202 time_t statusTime;
203 /// The stat url is a directory
204 bool isDirectory;
205 /// The stat url is a symbolic link
206 bool isSymLink;
207 /// The stat url is block special
208 bool isBlock;
209 /// The stat url is character special
210 bool isCharacter;
211 /// The stat url is FIFO special
212 bool isFifo;
213 /// The stat url is regular
214 bool isRegular;
215 /// The stat url is socket
216 bool isSocket;
217 /// The file serial number, which distinguishes this file from all other files on the same
218 /// device.
219 uint64_t fileSerialNumber;
220 };
221
222 struct VFS_CACHE_STATUS_DATA
223 {
224 uint64_t forward;
225 unsigned int maxrate;
226 unsigned int currate;
227 bool lowspeed;
228 };
229
230 struct VFSProperty
231 {
232 char* name;
233 char* val;
234 };
235
236 struct VFSDirEntry
237 {
238 char* label; //!< item label
239 char* title; //!< item title
240 char* path; //!< item path
241 unsigned int num_props; //!< Number of properties attached to item
242 struct VFSProperty* properties; //!< Properties
243 time_t date_time; //!< file creation date & time
244 bool folder; //!< Item is a folder
245 uint64_t size; //!< Size of file represented by item
246 };
247
248 typedef struct AddonToKodiFuncTable_kodi_filesystem
249 {
250 bool (*can_open_directory)(void* kodiBase, const char* url);
251 bool (*create_directory)(void* kodiBase, const char* path);
252 bool (*remove_directory)(void* kodiBase, const char* path);
253 bool (*directory_exists)(void* kodiBase, const char* path);
254 bool (*get_directory)(void* kodiBase,
255 const char* path,
256 const char* mask,
257 struct VFSDirEntry** items,
258 unsigned int* num_items);
259 void (*free_directory)(void* kodiBase, struct VFSDirEntry* items, unsigned int num_items);
260
261 bool (*file_exists)(void* kodiBase, const char* filename, bool useCache);
262 bool (*stat_file)(void* kodiBase, const char* filename, struct STAT_STRUCTURE* buffer);
263 bool (*delete_file)(void* kodiBase, const char* filename);
264 bool (*rename_file)(void* kodiBase, const char* filename, const char* newFileName);
265 bool (*copy_file)(void* kodiBase, const char* filename, const char* dest);
266
267 char* (*get_file_md5)(void* kodiBase, const char* filename);
268 char* (*get_cache_thumb_name)(void* kodiBase, const char* filename);
269 char* (*make_legal_filename)(void* kodiBase, const char* filename);
270 char* (*make_legal_path)(void* kodiBase, const char* path);
271 char* (*translate_special_protocol)(void* kodiBase, const char* strSource);
272 bool (*is_internet_stream)(void* kodiBase, const char* path, bool strictCheck);
273 bool (*is_on_lan)(void* kodiBase, const char* path);
274 bool (*is_remote)(void* kodiBase, const char* path);
275 bool (*is_local)(void* kodiBase, const char* path);
276 bool (*is_url)(void* kodiBase, const char* path);
277 bool (*get_http_header)(void* kodiBase, const char* url, struct KODI_HTTP_HEADER* headers);
278 bool (*get_mime_type)(void* kodiBase, const char* url, char** content, const char* useragent);
279 bool (*get_content_type)(void* kodiBase,
280 const char* url,
281 char** content,
282 const char* useragent);
283 bool (*get_cookies)(void* kodiBase, const char* url, char** cookies);
284 bool (*http_header_create)(void* kodiBase, struct KODI_HTTP_HEADER* headers);
285 void (*http_header_free)(void* kodiBase, struct KODI_HTTP_HEADER* headers);
286
287 void* (*open_file)(void* kodiBase, const char* filename, unsigned int flags);
288 void* (*open_file_for_write)(void* kodiBase, const char* filename, bool overwrite);
289 ssize_t (*read_file)(void* kodiBase, void* file, void* ptr, size_t size);
290 bool (*read_file_string)(void* kodiBase, void* file, char* szLine, int iLineLength);
291 ssize_t (*write_file)(void* kodiBase, void* file, const void* ptr, size_t size);
292 void (*flush_file)(void* kodiBase, void* file);
293 int64_t (*seek_file)(void* kodiBase, void* file, int64_t position, int whence);
294 int (*truncate_file)(void* kodiBase, void* file, int64_t size);
295 int64_t (*get_file_position)(void* kodiBase, void* file);
296 int64_t (*get_file_length)(void* kodiBase, void* file);
297 double (*get_file_download_speed)(void* kodiBase, void* file);
298 void (*close_file)(void* kodiBase, void* file);
299 int (*get_file_chunk_size)(void* kodiBase, void* file);
300 bool (*io_control_get_seek_possible)(void* kodiBase, void* file);
301 bool (*io_control_get_cache_status)(void* kodiBase,
302 void* file,
303 struct VFS_CACHE_STATUS_DATA* status);
304 bool (*io_control_set_cache_rate)(void* kodiBase, void* file, unsigned int rate);
305 bool (*io_control_set_retry)(void* kodiBase, void* file, bool retry);
306 char** (*get_property_values)(
307 void* kodiBase, void* file, int type, const char* name, int* numValues);
308
309 void* (*curl_create)(void* kodiBase, const char* url);
310 bool (*curl_add_option)(
311 void* kodiBase, void* file, int type, const char* name, const char* value);
312 bool (*curl_open)(void* kodiBase, void* file, unsigned int flags);
313
314 bool (*get_disk_space)(
315 void* kodiBase, const char* path, uint64_t* capacity, uint64_t* free, uint64_t* available);
316 bool (*remove_directory_recursive)(void* kodiBase, const char* path);
317 } AddonToKodiFuncTable_kodi_filesystem;
318
319 //}}}
320
321#ifdef __cplusplus
322} /* extern "C" */
323#endif /* __cplusplus */
324
325#endif /* !C_API_FILESYSTEM_H */
diff --git a/xbmc/addons/kodi-dev-kit/include/kodi/c-api/general.h b/xbmc/addons/kodi-dev-kit/include/kodi/c-api/general.h
new file mode 100644
index 0000000..12afd02
--- /dev/null
+++ b/xbmc/addons/kodi-dev-kit/include/kodi/c-api/general.h
@@ -0,0 +1,130 @@
1/*
2 * Copyright (C) 2005-2018 Team Kodi
3 * This file is part of Kodi - https://kodi.tv
4 *
5 * SPDX-License-Identifier: GPL-2.0-or-later
6 * See LICENSES/README.md for more information.
7 */
8
9#pragma once
10
11#ifndef C_API_GENERAL_H
12#define C_API_GENERAL_H
13
14#include <stdbool.h>
15
16#ifdef __cplusplus
17extern "C"
18{
19#endif /* __cplusplus */
20
21 //============================================================================
22 /// \ingroup cpp_kodi_Defs
23 /// @brief For kodi::CurrentKeyboardLayout used defines
24 ///
25 typedef enum StdKbButtons
26 {
27 /// The quantity of buttons per row on Kodi's standard keyboard
28 STD_KB_BUTTONS_PER_ROW = 20,
29 /// The quantity of rows on Kodi's standard keyboard
30 STD_KB_BUTTONS_MAX_ROWS = 4,
31 /// Keyboard layout type, this for initial standard
32 STD_KB_MODIFIER_KEY_NONE = 0x00,
33 /// Keyboard layout type, this for shift controled layout (uppercase)
34 STD_KB_MODIFIER_KEY_SHIFT = 0x01,
35 /// Keyboard layout type, this to show symbols
36 STD_KB_MODIFIER_KEY_SYMBOL = 0x02
37 } StdKbButtons;
38 //----------------------------------------------------------------------------
39
40 //============================================================================
41 /// \ingroup cpp_kodi_Defs
42 /// @brief For kodi::QueueNotification() used message types
43 ///
44 typedef enum QueueMsg
45 {
46 /// Show info notification message
47 QUEUE_INFO,
48 /// Show warning notification message
49 QUEUE_WARNING,
50 /// Show error notification message
51 QUEUE_ERROR,
52 /// Show with own given image and parts if set on values
53 QUEUE_OWN_STYLE
54 } QueueMsg;
55 //----------------------------------------------------------------------------
56
57 //============================================================================
58 /// \ingroup cpp_kodi_Defs
59 /// @brief Format codes to get string from them.
60 ///
61 /// Used on kodi::GetLanguage().
62 ///
63 typedef enum LangFormats
64 {
65 /// two letter code as defined in ISO 639-1
66 LANG_FMT_ISO_639_1,
67 /// three letter code as defined in ISO 639-2/T or ISO 639-2/B
68 LANG_FMT_ISO_639_2,
69 /// full language name in English
70 LANG_FMT_ENGLISH_NAME
71 } LangFormats;
72 //----------------------------------------------------------------------------
73
74 /*
75 * For interface between add-on and kodi.
76 *
77 * This structure defines the addresses of functions stored inside Kodi which
78 * are then available for the add-on to call
79 *
80 * All function pointers there are used by the C++ interface functions below.
81 * You find the set of them on xbmc/addons/interfaces/General.cpp
82 *
83 * Note: For add-on development itself this is not needed
84 */
85 typedef struct AddonKeyboardKeyTable
86 {
87 char* keys[STD_KB_BUTTONS_MAX_ROWS][STD_KB_BUTTONS_PER_ROW];
88 } AddonKeyboardKeyTable;
89 typedef struct AddonToKodiFuncTable_kodi
90 {
91 char* (*get_addon_info)(void* kodiBase, const char* id);
92 bool (*open_settings_dialog)(void* kodiBase);
93 char* (*unknown_to_utf8)(void* kodiBase, const char* source, bool* ret, bool failOnBadChar);
94 char* (*get_localized_string)(void* kodiBase, long label_id);
95 char* (*get_language)(void* kodiBase, int format, bool region);
96 bool (*queue_notification)(void* kodiBase,
97 int type,
98 const char* header,
99 const char* message,
100 const char* imageFile,
101 unsigned int displayTime,
102 bool withSound,
103 unsigned int messageTime);
104 void (*get_md5)(void* kodiBase, const char* text, char* md5);
105 char* (*get_temp_path)(void* kodiBase);
106 char* (*get_region)(void* kodiBase, const char* id);
107 void (*get_free_mem)(void* kodiBase, long* free, long* total, bool as_bytes);
108 int (*get_global_idle_time)(void* kodiBase);
109 bool (*is_addon_avilable)(void* kodiBase, const char* id, char** version, bool* enabled);
110 void (*kodi_version)(void* kodiBase,
111 char** compile_name,
112 int* major,
113 int* minor,
114 char** revision,
115 char** tag,
116 char** tagversion);
117 char* (*get_current_skin_id)(void* kodiBase);
118 bool (*get_keyboard_layout)(void* kodiBase,
119 char** layout_name,
120 int modifier_key,
121 struct AddonKeyboardKeyTable* layout);
122 bool (*change_keyboard_layout)(void* kodiBase, char** layout_name);
123 } AddonToKodiFuncTable_kodi;
124
125
126#ifdef __cplusplus
127} /* extern "C" */
128#endif /* __cplusplus */
129
130#endif /* !C_API_GENERAL_H */
diff --git a/xbmc/addons/kodi-dev-kit/include/kodi/c-api/gui/CMakeLists.txt b/xbmc/addons/kodi-dev-kit/include/kodi/c-api/gui/CMakeLists.txt
new file mode 100644
index 0000000..53c4e60
--- /dev/null
+++ b/xbmc/addons/kodi-dev-kit/include/kodi/c-api/gui/CMakeLists.txt
@@ -0,0 +1,8 @@
1set(HEADERS definitions.h
2 general.h
3 list_item.h
4 window.h)
5
6if(NOT ENABLE_STATIC_LIBS)
7 core_add_library(addons_kodi-dev-kit_include_kodi_c-api_gui)
8endif()
diff --git a/xbmc/addons/kodi-dev-kit/include/kodi/c-api/gui/controls/CMakeLists.txt b/xbmc/addons/kodi-dev-kit/include/kodi/c-api/gui/controls/CMakeLists.txt
new file mode 100644
index 0000000..2e6cd53
--- /dev/null
+++ b/xbmc/addons/kodi-dev-kit/include/kodi/c-api/gui/controls/CMakeLists.txt
@@ -0,0 +1,16 @@
1set(HEADERS button.h
2 edit.h
3 fade_label.h
4 image.h
5 label.h
6 progress.h
7 radio_button.h
8 rendering.h
9 settings_slider.h
10 slider.h
11 spin.h
12 text_box.h)
13
14if(NOT ENABLE_STATIC_LIBS)
15 core_add_library(addons_kodi-dev-kit_include_kodi_c-api_gui_controls)
16endif()
diff --git a/xbmc/addons/kodi-dev-kit/include/kodi/c-api/gui/controls/button.h b/xbmc/addons/kodi-dev-kit/include/kodi/c-api/gui/controls/button.h
new file mode 100644
index 0000000..84fd822
--- /dev/null
+++ b/xbmc/addons/kodi-dev-kit/include/kodi/c-api/gui/controls/button.h
@@ -0,0 +1,35 @@
1/*
2 * Copyright (C) 2005-2020 Team Kodi
3 * This file is part of Kodi - https://kodi.tv
4 *
5 * SPDX-License-Identifier: GPL-2.0-or-later
6 * See LICENSES/README.md for more information.
7 */
8
9#pragma once
10
11#ifndef C_API_GUI_CONTROLS_BUTTON_H
12#define C_API_GUI_CONTROLS_BUTTON_H
13
14#include "../definitions.h"
15
16#ifdef __cplusplus
17extern "C"
18{
19#endif /* __cplusplus */
20
21 typedef struct AddonToKodiFuncTable_kodi_gui_control_button
22 {
23 void (*set_visible)(KODI_HANDLE kodiBase, KODI_GUI_CONTROL_HANDLE handle, bool visible);
24 void (*set_enabled)(KODI_HANDLE kodiBase, KODI_GUI_CONTROL_HANDLE handle, bool enabled);
25 void (*set_label)(KODI_HANDLE kodiBase, KODI_GUI_CONTROL_HANDLE handle, const char* label);
26 char* (*get_label)(KODI_HANDLE kodiBase, KODI_GUI_CONTROL_HANDLE handle);
27 void (*set_label2)(KODI_HANDLE kodiBase, KODI_GUI_CONTROL_HANDLE handle, const char* label);
28 char* (*get_label2)(KODI_HANDLE kodiBase, KODI_GUI_CONTROL_HANDLE handle);
29 } AddonToKodiFuncTable_kodi_gui_control_button;
30
31#ifdef __cplusplus
32} /* extern "C" */
33#endif /* __cplusplus */
34
35#endif /* !C_API_GUI_CONTROLS_BUTTON_H */
diff --git a/xbmc/addons/kodi-dev-kit/include/kodi/c-api/gui/controls/edit.h b/xbmc/addons/kodi-dev-kit/include/kodi/c-api/gui/controls/edit.h
new file mode 100644
index 0000000..ca38b27
--- /dev/null
+++ b/xbmc/addons/kodi-dev-kit/include/kodi/c-api/gui/controls/edit.h
@@ -0,0 +1,79 @@
1/*
2 * Copyright (C) 2005-2020 Team Kodi
3 * This file is part of Kodi - https://kodi.tv
4 *
5 * SPDX-License-Identifier: GPL-2.0-or-later
6 * See LICENSES/README.md for more information.
7 */
8
9#pragma once
10
11#ifndef C_API_GUI_CONTROLS_EDIT_H
12#define C_API_GUI_CONTROLS_EDIT_H
13
14#include "../definitions.h"
15
16#ifdef __cplusplus
17extern "C"
18{
19#endif /* __cplusplus */
20
21 //============================================================================
22 /// @ingroup cpp_kodi_gui_windows_controls_CEdit_Defs
23 /// @{
24 /// @anchor AddonGUIInputType
25 /// @brief Text input types used on kodi::gui::controls::CEdit
26 enum AddonGUIInputType
27 {
28 /// Text inside edit control only readable
29 ADDON_INPUT_TYPE_READONLY = -1,
30 /// Normal text entries
31 ADDON_INPUT_TYPE_TEXT = 0,
32 /// To use on edit control only numeric numbers
33 ADDON_INPUT_TYPE_NUMBER,
34 /// To insert seconds
35 ADDON_INPUT_TYPE_SECONDS,
36 /// To insert time
37 ADDON_INPUT_TYPE_TIME,
38 /// To insert a date
39 ADDON_INPUT_TYPE_DATE,
40 /// Used for write in IP addresses
41 ADDON_INPUT_TYPE_IPADDRESS,
42 /// Text field used as password entry field with not visible text
43 ADDON_INPUT_TYPE_PASSWORD,
44 /// Text field used as password entry field with not visible text but
45 /// returned as MD5 value
46 ADDON_INPUT_TYPE_PASSWORD_MD5,
47 /// Use text field for search purpose
48 ADDON_INPUT_TYPE_SEARCH,
49 /// Text field as filter
50 ADDON_INPUT_TYPE_FILTER,
51 ///
52 ADDON_INPUT_TYPE_PASSWORD_NUMBER_VERIFY_NEW
53 };
54 /// @}
55 //----------------------------------------------------------------------------
56
57 typedef struct AddonToKodiFuncTable_kodi_gui_control_edit
58 {
59 void (*set_visible)(KODI_HANDLE kodiBase, KODI_GUI_CONTROL_HANDLE handle, bool visible);
60 void (*set_enabled)(KODI_HANDLE kodiBase, KODI_GUI_CONTROL_HANDLE handle, bool enabled);
61 void (*set_label)(KODI_HANDLE kodiBase, KODI_GUI_CONTROL_HANDLE handle, const char* label);
62 char* (*get_label)(KODI_HANDLE kodiBase, KODI_GUI_CONTROL_HANDLE handle);
63 void (*set_text)(KODI_HANDLE kodiBase, KODI_GUI_CONTROL_HANDLE handle, const char* text);
64 char* (*get_text)(KODI_HANDLE kodiBase, KODI_GUI_CONTROL_HANDLE handle);
65 void (*set_cursor_position)(KODI_HANDLE kodiBase,
66 KODI_GUI_CONTROL_HANDLE handle,
67 unsigned int position);
68 unsigned int (*get_cursor_position)(KODI_HANDLE kodiBase, KODI_GUI_CONTROL_HANDLE handle);
69 void (*set_input_type)(KODI_HANDLE kodiBase,
70 KODI_GUI_CONTROL_HANDLE handle,
71 int type,
72 const char* heading);
73 } AddonToKodiFuncTable_kodi_gui_control_edit;
74
75#ifdef __cplusplus
76} /* extern "C" */
77#endif /* __cplusplus */
78
79#endif /* !C_API_GUI_CONTROLS_EDIT_H */
diff --git a/xbmc/addons/kodi-dev-kit/include/kodi/c-api/gui/controls/fade_label.h b/xbmc/addons/kodi-dev-kit/include/kodi/c-api/gui/controls/fade_label.h
new file mode 100644
index 0000000..fea014b
--- /dev/null
+++ b/xbmc/addons/kodi-dev-kit/include/kodi/c-api/gui/controls/fade_label.h
@@ -0,0 +1,34 @@
1/*
2 * Copyright (C) 2005-2020 Team Kodi
3 * This file is part of Kodi - https://kodi.tv
4 *
5 * SPDX-License-Identifier: GPL-2.0-or-later
6 * See LICENSES/README.md for more information.
7 */
8
9#pragma once
10
11#ifndef C_API_GUI_CONTROLS_FADE_LABEL_H
12#define C_API_GUI_CONTROLS_FADE_LABEL_H
13
14#include "../definitions.h"
15
16#ifdef __cplusplus
17extern "C"
18{
19#endif /* __cplusplus */
20
21 typedef struct AddonToKodiFuncTable_kodi_gui_control_fade_label
22 {
23 void (*set_visible)(KODI_HANDLE kodiBase, KODI_GUI_CONTROL_HANDLE handle, bool visible);
24 void (*add_label)(KODI_HANDLE kodiBase, KODI_GUI_CONTROL_HANDLE handle, const char* text);
25 char* (*get_label)(KODI_HANDLE kodiBase, KODI_GUI_CONTROL_HANDLE handle);
26 void (*set_scrolling)(KODI_HANDLE kodiBase, KODI_GUI_CONTROL_HANDLE handle, bool scroll);
27 void (*reset)(KODI_HANDLE kodiBase, KODI_GUI_CONTROL_HANDLE handle);
28 } AddonToKodiFuncTable_kodi_gui_control_fade_label;
29
30#ifdef __cplusplus
31} /* extern "C" */
32#endif /* __cplusplus */
33
34#endif /* !C_API_GUI_CONTROLS_FADE_LABEL_H */
diff --git a/xbmc/addons/kodi-dev-kit/include/kodi/c-api/gui/controls/image.h b/xbmc/addons/kodi-dev-kit/include/kodi/c-api/gui/controls/image.h
new file mode 100644
index 0000000..4a46e6d
--- /dev/null
+++ b/xbmc/addons/kodi-dev-kit/include/kodi/c-api/gui/controls/image.h
@@ -0,0 +1,37 @@
1/*
2 * Copyright (C) 2005-2020 Team Kodi
3 * This file is part of Kodi - https://kodi.tv
4 *
5 * SPDX-License-Identifier: GPL-2.0-or-later
6 * See LICENSES/README.md for more information.
7 */
8
9#pragma once
10
11#ifndef C_API_GUI_CONTROLS_IMAGE_H
12#define C_API_GUI_CONTROLS_IMAGE_H
13
14#include "../definitions.h"
15
16#ifdef __cplusplus
17extern "C"
18{
19#endif /* __cplusplus */
20
21 typedef struct AddonToKodiFuncTable_kodi_gui_control_image
22 {
23 void (*set_visible)(KODI_HANDLE kodiBase, KODI_GUI_CONTROL_HANDLE handle, bool visible);
24 void (*set_filename)(KODI_HANDLE kodiBase,
25 KODI_GUI_CONTROL_HANDLE handle,
26 const char* filename,
27 bool use_cache);
28 void (*set_color_diffuse)(KODI_HANDLE kodiBase,
29 KODI_GUI_CONTROL_HANDLE handle,
30 uint32_t color_diffuse);
31 } AddonToKodiFuncTable_kodi_gui_control_image;
32
33#ifdef __cplusplus
34} /* extern "C" */
35#endif /* __cplusplus */
36
37#endif /* !C_API_GUI_CONTROLS_IMAGE_H */
diff --git a/xbmc/addons/kodi-dev-kit/include/kodi/c-api/gui/controls/label.h b/xbmc/addons/kodi-dev-kit/include/kodi/c-api/gui/controls/label.h
new file mode 100644
index 0000000..d8a9fe4
--- /dev/null
+++ b/xbmc/addons/kodi-dev-kit/include/kodi/c-api/gui/controls/label.h
@@ -0,0 +1,32 @@
1/*
2 * Copyright (C) 2005-2020 Team Kodi
3 * This file is part of Kodi - https://kodi.tv
4 *
5 * SPDX-License-Identifier: GPL-2.0-or-later
6 * See LICENSES/README.md for more information.
7 */
8
9#pragma once
10
11#ifndef C_API_GUI_CONTROLS_LABEL_H
12#define C_API_GUI_CONTROLS_LABEL_H
13
14#include "../definitions.h"
15
16#ifdef __cplusplus
17extern "C"
18{
19#endif /* __cplusplus */
20
21 typedef struct AddonToKodiFuncTable_kodi_gui_control_label
22 {
23 void (*set_visible)(KODI_HANDLE kodiBase, KODI_GUI_CONTROL_HANDLE handle, bool visible);
24 void (*set_label)(KODI_HANDLE kodiBase, KODI_GUI_CONTROL_HANDLE handle, const char* text);
25 char* (*get_label)(KODI_HANDLE kodiBase, KODI_GUI_CONTROL_HANDLE handle);
26 } AddonToKodiFuncTable_kodi_gui_control_label;
27
28#ifdef __cplusplus
29} /* extern "C" */
30#endif /* __cplusplus */
31
32#endif /* !C_API_GUI_CONTROLS_LABEL_H */
diff --git a/xbmc/addons/kodi-dev-kit/include/kodi/c-api/gui/controls/progress.h b/xbmc/addons/kodi-dev-kit/include/kodi/c-api/gui/controls/progress.h
new file mode 100644
index 0000000..88638e0
--- /dev/null
+++ b/xbmc/addons/kodi-dev-kit/include/kodi/c-api/gui/controls/progress.h
@@ -0,0 +1,32 @@
1/*
2 * Copyright (C) 2005-2020 Team Kodi
3 * This file is part of Kodi - https://kodi.tv
4 *
5 * SPDX-License-Identifier: GPL-2.0-or-later
6 * See LICENSES/README.md for more information.
7 */
8
9#pragma once
10
11#ifndef C_API_GUI_CONTROLS_PROGRESS_H
12#define C_API_GUI_CONTROLS_PROGRESS_H
13
14#include "../definitions.h"
15
16#ifdef __cplusplus
17extern "C"
18{
19#endif /* __cplusplus */
20
21 typedef struct AddonToKodiFuncTable_kodi_gui_control_progress
22 {
23 void (*set_visible)(KODI_HANDLE kodiBase, KODI_GUI_CONTROL_HANDLE handle, bool visible);
24 void (*set_percentage)(KODI_HANDLE kodiBase, KODI_GUI_CONTROL_HANDLE handle, float percent);
25 float (*get_percentage)(KODI_HANDLE kodiBase, KODI_GUI_CONTROL_HANDLE handle);
26 } AddonToKodiFuncTable_kodi_gui_control_progress;
27
28#ifdef __cplusplus
29} /* extern "C" */
30#endif /* __cplusplus */
31
32#endif /* !C_API_GUI_CONTROLS_PROGRESS_H */
diff --git a/xbmc/addons/kodi-dev-kit/include/kodi/c-api/gui/controls/radio_button.h b/xbmc/addons/kodi-dev-kit/include/kodi/c-api/gui/controls/radio_button.h
new file mode 100644
index 0000000..a672d95
--- /dev/null
+++ b/xbmc/addons/kodi-dev-kit/include/kodi/c-api/gui/controls/radio_button.h
@@ -0,0 +1,35 @@
1/*
2 * Copyright (C) 2005-2020 Team Kodi
3 * This file is part of Kodi - https://kodi.tv
4 *
5 * SPDX-License-Identifier: GPL-2.0-or-later
6 * See LICENSES/README.md for more information.
7 */
8
9#pragma once
10
11#ifndef C_API_GUI_CONTROLS_RADIO_BUTTON_H
12#define C_API_GUI_CONTROLS_RADIO_BUTTON_H
13
14#include "../definitions.h"
15
16#ifdef __cplusplus
17extern "C"
18{
19#endif /* __cplusplus */
20
21 typedef struct AddonToKodiFuncTable_kodi_gui_control_radio_button
22 {
23 void (*set_visible)(KODI_HANDLE kodiBase, KODI_GUI_CONTROL_HANDLE handle, bool visible);
24 void (*set_enabled)(KODI_HANDLE kodiBase, KODI_GUI_CONTROL_HANDLE handle, bool enabled);
25 void (*set_label)(KODI_HANDLE kodiBase, KODI_GUI_CONTROL_HANDLE handle, const char* text);
26 char* (*get_label)(KODI_HANDLE kodiBase, KODI_GUI_CONTROL_HANDLE handle);
27 void (*set_selected)(KODI_HANDLE kodiBase, KODI_GUI_CONTROL_HANDLE handle, bool selected);
28 bool (*is_selected)(KODI_HANDLE kodiBase, KODI_GUI_CONTROL_HANDLE handle);
29 } AddonToKodiFuncTable_kodi_gui_control_radio_button;
30
31#ifdef __cplusplus
32} /* extern "C" */
33#endif /* __cplusplus */
34
35#endif /* !C_API_GUI_CONTROLS_RADIO_BUTTON_H */
diff --git a/xbmc/addons/kodi-dev-kit/include/kodi/c-api/gui/controls/rendering.h b/xbmc/addons/kodi-dev-kit/include/kodi/c-api/gui/controls/rendering.h
new file mode 100644
index 0000000..d4053a6
--- /dev/null
+++ b/xbmc/addons/kodi-dev-kit/include/kodi/c-api/gui/controls/rendering.h
@@ -0,0 +1,38 @@
1/*
2 * Copyright (C) 2005-2020 Team Kodi
3 * This file is part of Kodi - https://kodi.tv
4 *
5 * SPDX-License-Identifier: GPL-2.0-or-later
6 * See LICENSES/README.md for more information.
7 */
8
9#pragma once
10
11#ifndef C_API_GUI_CONTROLS_RENDERING_H
12#define C_API_GUI_CONTROLS_RENDERING_H
13
14#include "../definitions.h"
15
16#ifdef __cplusplus
17extern "C"
18{
19#endif /* __cplusplus */
20
21 typedef struct AddonToKodiFuncTable_kodi_gui_control_rendering
22 {
23 void (*set_callbacks)(
24 KODI_HANDLE kodiBase,
25 KODI_GUI_CONTROL_HANDLE handle,
26 KODI_GUI_CLIENT_HANDLE clienthandle,
27 bool (*createCB)(KODI_GUI_CLIENT_HANDLE, int, int, int, int, ADDON_HARDWARE_CONTEXT),
28 void (*renderCB)(KODI_GUI_CLIENT_HANDLE),
29 void (*stopCB)(KODI_GUI_CLIENT_HANDLE),
30 bool (*dirtyCB)(KODI_GUI_CLIENT_HANDLE));
31 void (*destroy)(void* kodiBase, KODI_GUI_CONTROL_HANDLE handle);
32 } AddonToKodiFuncTable_kodi_gui_control_rendering;
33
34#ifdef __cplusplus
35} /* extern "C" */
36#endif /* __cplusplus */
37
38#endif /* !C_API_GUI_CONTROLS_RENDERING_H */
diff --git a/xbmc/addons/kodi-dev-kit/include/kodi/c-api/gui/controls/settings_slider.h b/xbmc/addons/kodi-dev-kit/include/kodi/c-api/gui/controls/settings_slider.h
new file mode 100644
index 0000000..2cbc972
--- /dev/null
+++ b/xbmc/addons/kodi-dev-kit/include/kodi/c-api/gui/controls/settings_slider.h
@@ -0,0 +1,48 @@
1/*
2 * Copyright (C) 2005-2020 Team Kodi
3 * This file is part of Kodi - https://kodi.tv
4 *
5 * SPDX-License-Identifier: GPL-2.0-or-later
6 * See LICENSES/README.md for more information.
7 */
8
9#pragma once
10
11#ifndef C_API_GUI_CONTROLS_SETTINGS_SLIDER_H
12#define C_API_GUI_CONTROLS_SETTINGS_SLIDER_H
13
14#include "../definitions.h"
15
16#ifdef __cplusplus
17extern "C"
18{
19#endif /* __cplusplus */
20
21 typedef struct AddonToKodiFuncTable_kodi_gui_control_settings_slider
22 {
23 void (*set_visible)(KODI_HANDLE kodiBase, KODI_GUI_CONTROL_HANDLE handle, bool visible);
24 void (*set_enabled)(KODI_HANDLE kodiBase, KODI_GUI_CONTROL_HANDLE handle, bool enabled);
25 void (*set_text)(KODI_HANDLE kodiBase, KODI_GUI_CONTROL_HANDLE handle, const char* label);
26 void (*reset)(KODI_HANDLE kodiBase, KODI_GUI_CONTROL_HANDLE handle);
27 void (*set_int_range)(KODI_HANDLE kodiBase, KODI_GUI_CONTROL_HANDLE handle, int start, int end);
28 void (*set_int_value)(KODI_HANDLE kodiBase, KODI_GUI_CONTROL_HANDLE handle, int value);
29 int (*get_int_value)(KODI_HANDLE kodiBase, KODI_GUI_CONTROL_HANDLE handle);
30 void (*set_int_interval)(KODI_HANDLE kodiBase, KODI_GUI_CONTROL_HANDLE handle, int interval);
31 void (*set_percentage)(KODI_HANDLE kodiBase, KODI_GUI_CONTROL_HANDLE handle, float percent);
32 float (*get_percentage)(KODI_HANDLE kodiBase, KODI_GUI_CONTROL_HANDLE handle);
33 void (*set_float_range)(KODI_HANDLE kodiBase,
34 KODI_GUI_CONTROL_HANDLE handle,
35 float start,
36 float end);
37 void (*set_float_value)(KODI_HANDLE kodiBase, KODI_GUI_CONTROL_HANDLE handle, float value);
38 float (*get_float_value)(KODI_HANDLE kodiBase, KODI_GUI_CONTROL_HANDLE handle);
39 void (*set_float_interval)(KODI_HANDLE kodiBase,
40 KODI_GUI_CONTROL_HANDLE handle,
41 float interval);
42 } AddonToKodiFuncTable_kodi_gui_control_settings_slider;
43
44#ifdef __cplusplus
45} /* extern "C" */
46#endif /* __cplusplus */
47
48#endif /* !C_API_GUI_CONTROLS_SETTINGS_SLIDER_H */
diff --git a/xbmc/addons/kodi-dev-kit/include/kodi/c-api/gui/controls/slider.h b/xbmc/addons/kodi-dev-kit/include/kodi/c-api/gui/controls/slider.h
new file mode 100644
index 0000000..0a67208
--- /dev/null
+++ b/xbmc/addons/kodi-dev-kit/include/kodi/c-api/gui/controls/slider.h
@@ -0,0 +1,48 @@
1/*
2 * Copyright (C) 2005-2020 Team Kodi
3 * This file is part of Kodi - https://kodi.tv
4 *
5 * SPDX-License-Identifier: GPL-2.0-or-later
6 * See LICENSES/README.md for more information.
7 */
8
9#pragma once
10
11#ifndef C_API_GUI_CONTROLS_SLIDER_H
12#define C_API_GUI_CONTROLS_SLIDER_H
13
14#include "../definitions.h"
15
16#ifdef __cplusplus
17extern "C"
18{
19#endif /* __cplusplus */
20
21 typedef struct AddonToKodiFuncTable_kodi_gui_control_slider
22 {
23 void (*set_visible)(KODI_HANDLE kodiBase, KODI_GUI_CONTROL_HANDLE handle, bool visible);
24 void (*set_enabled)(KODI_HANDLE kodiBase, KODI_GUI_CONTROL_HANDLE handle, bool enabled);
25 void (*reset)(KODI_HANDLE kodiBase, KODI_GUI_CONTROL_HANDLE handle);
26 char* (*get_description)(KODI_HANDLE kodiBase, KODI_GUI_CONTROL_HANDLE handle);
27 void (*set_int_range)(KODI_HANDLE kodiBase, KODI_GUI_CONTROL_HANDLE handle, int start, int end);
28 void (*set_int_value)(KODI_HANDLE kodiBase, KODI_GUI_CONTROL_HANDLE handle, int value);
29 int (*get_int_value)(KODI_HANDLE kodiBase, KODI_GUI_CONTROL_HANDLE handle);
30 void (*set_int_interval)(KODI_HANDLE kodiBase, KODI_GUI_CONTROL_HANDLE handle, int interval);
31 void (*set_percentage)(KODI_HANDLE kodiBase, KODI_GUI_CONTROL_HANDLE handle, float percent);
32 float (*get_percentage)(KODI_HANDLE kodiBase, KODI_GUI_CONTROL_HANDLE handle);
33 void (*set_float_range)(KODI_HANDLE kodiBase,
34 KODI_GUI_CONTROL_HANDLE handle,
35 float start,
36 float end);
37 void (*set_float_value)(KODI_HANDLE kodiBase, KODI_GUI_CONTROL_HANDLE handle, float value);
38 float (*get_float_value)(KODI_HANDLE kodiBase, KODI_GUI_CONTROL_HANDLE handle);
39 void (*set_float_interval)(KODI_HANDLE kodiBase,
40 KODI_GUI_CONTROL_HANDLE handle,
41 float interval);
42 } AddonToKodiFuncTable_kodi_gui_control_slider;
43
44#ifdef __cplusplus
45} /* extern "C" */
46#endif /* __cplusplus */
47
48#endif /* !C_API_GUI_CONTROLS_SLIDER_H */
diff --git a/xbmc/addons/kodi-dev-kit/include/kodi/c-api/gui/controls/spin.h b/xbmc/addons/kodi-dev-kit/include/kodi/c-api/gui/controls/spin.h
new file mode 100644
index 0000000..d5e5c86
--- /dev/null
+++ b/xbmc/addons/kodi-dev-kit/include/kodi/c-api/gui/controls/spin.h
@@ -0,0 +1,58 @@
1/*
2 * Copyright (C) 2005-2020 Team Kodi
3 * This file is part of Kodi - https://kodi.tv
4 *
5 * SPDX-License-Identifier: GPL-2.0-or-later
6 * See LICENSES/README.md for more information.
7 */
8
9#pragma once
10
11#ifndef C_API_GUI_CONTROLS_SPIN_H
12#define C_API_GUI_CONTROLS_SPIN_H
13
14#include "../definitions.h"
15
16#ifdef __cplusplus
17extern "C"
18{
19#endif /* __cplusplus */
20
21 typedef struct AddonToKodiFuncTable_kodi_gui_control_spin
22 {
23 void (*set_visible)(KODI_HANDLE kodiBase, KODI_GUI_CONTROL_HANDLE handle, bool visible);
24 void (*set_enabled)(KODI_HANDLE kodiBase, KODI_GUI_CONTROL_HANDLE handle, bool enabled);
25 void (*set_text)(KODI_HANDLE kodiBase, KODI_GUI_CONTROL_HANDLE handle, const char* text);
26 void (*reset)(KODI_HANDLE kodiBase, KODI_GUI_CONTROL_HANDLE handle);
27 void (*set_type)(KODI_HANDLE kodiBase, KODI_GUI_CONTROL_HANDLE handle, int type);
28 void (*add_string_label)(KODI_HANDLE kodiBase,
29 KODI_GUI_CONTROL_HANDLE handle,
30 const char* label,
31 const char* value);
32 void (*set_string_value)(KODI_HANDLE kodiBase,
33 KODI_GUI_CONTROL_HANDLE handle,
34 const char* value);
35 char* (*get_string_value)(KODI_HANDLE kodiBase, KODI_GUI_CONTROL_HANDLE handle);
36 void (*add_int_label)(KODI_HANDLE kodiBase,
37 KODI_GUI_CONTROL_HANDLE handle,
38 const char* label,
39 int value);
40 void (*set_int_range)(KODI_HANDLE kodiBase, KODI_GUI_CONTROL_HANDLE handle, int start, int end);
41 void (*set_int_value)(KODI_HANDLE kodiBase, KODI_GUI_CONTROL_HANDLE handle, int value);
42 int (*get_int_value)(KODI_HANDLE kodiBase, KODI_GUI_CONTROL_HANDLE handle);
43 void (*set_float_range)(KODI_HANDLE kodiBase,
44 KODI_GUI_CONTROL_HANDLE handle,
45 float start,
46 float end);
47 void (*set_float_value)(KODI_HANDLE kodiBase, KODI_GUI_CONTROL_HANDLE handle, float value);
48 float (*get_float_value)(KODI_HANDLE kodiBase, KODI_GUI_CONTROL_HANDLE handle);
49 void (*set_float_interval)(KODI_HANDLE kodiBase,
50 KODI_GUI_CONTROL_HANDLE handle,
51 float interval);
52 } AddonToKodiFuncTable_kodi_gui_control_spin;
53
54#ifdef __cplusplus
55} /* extern "C" */
56#endif /* __cplusplus */
57
58#endif /* !C_API_GUI_CONTROLS_SPIN_H */
diff --git a/xbmc/addons/kodi-dev-kit/include/kodi/c-api/gui/controls/text_box.h b/xbmc/addons/kodi-dev-kit/include/kodi/c-api/gui/controls/text_box.h
new file mode 100644
index 0000000..276d04c
--- /dev/null
+++ b/xbmc/addons/kodi-dev-kit/include/kodi/c-api/gui/controls/text_box.h
@@ -0,0 +1,36 @@
1/*
2 * Copyright (C) 2005-2020 Team Kodi
3 * This file is part of Kodi - https://kodi.tv
4 *
5 * SPDX-License-Identifier: GPL-2.0-or-later
6 * See LICENSES/README.md for more information.
7 */
8
9#pragma once
10
11#ifndef C_API_GUI_CONTROLS_TEXT_BOX_H
12#define C_API_GUI_CONTROLS_TEXT_BOX_H
13
14#include "../definitions.h"
15
16#ifdef __cplusplus
17extern "C"
18{
19#endif /* __cplusplus */
20
21 typedef struct AddonToKodiFuncTable_kodi_gui_control_text_box
22 {
23 void (*set_visible)(KODI_HANDLE kodiBase, KODI_GUI_CONTROL_HANDLE handle, bool visible);
24 void (*reset)(KODI_HANDLE kodiBase, KODI_GUI_CONTROL_HANDLE handle);
25 void (*set_text)(KODI_HANDLE kodiBase, KODI_GUI_CONTROL_HANDLE handle, const char* text);
26 char* (*get_text)(KODI_HANDLE kodiBase, KODI_GUI_CONTROL_HANDLE handle);
27 void (*scroll)(KODI_HANDLE kodiBase, KODI_GUI_CONTROL_HANDLE handle, unsigned int scroll);
28 void (*set_auto_scrolling)(
29 KODI_HANDLE kodiBase, KODI_GUI_CONTROL_HANDLE handle, int delay, int time, int repeat);
30 } AddonToKodiFuncTable_kodi_gui_control_text_box;
31
32#ifdef __cplusplus
33} /* extern "C" */
34#endif /* __cplusplus */
35
36#endif /* !C_API_GUI_CONTROLS_TEXT_BOX_H */
diff --git a/xbmc/addons/kodi-dev-kit/include/kodi/c-api/gui/definitions.h b/xbmc/addons/kodi-dev-kit/include/kodi/c-api/gui/definitions.h
new file mode 100644
index 0000000..ec60bc2
--- /dev/null
+++ b/xbmc/addons/kodi-dev-kit/include/kodi/c-api/gui/definitions.h
@@ -0,0 +1,106 @@
1/*
2 * Copyright (C) 2005-2018 Team Kodi
3 * This file is part of Kodi - https://kodi.tv
4 *
5 * SPDX-License-Identifier: GPL-2.0-or-later
6 * See LICENSES/README.md for more information.
7 */
8
9#pragma once
10
11#ifndef C_API_GUI_DEFINITIONS_H
12#define C_API_GUI_DEFINITIONS_H
13
14#include "../addon_base.h"
15
16#ifdef __cplusplus
17extern "C"
18{
19#endif /* __cplusplus */
20
21 typedef void* KODI_GUI_HANDLE;
22 typedef void* KODI_GUI_CLIENT_HANDLE;
23 typedef void* KODI_GUI_CONTROL_HANDLE;
24 typedef void* KODI_GUI_LISTITEM_HANDLE;
25 typedef void* KODI_GUI_WINDOW_HANDLE;
26
27 struct AddonToKodiFuncTable_kodi_gui_general;
28 struct AddonToKodiFuncTable_kodi_gui_control_button;
29 struct AddonToKodiFuncTable_kodi_gui_control_edit;
30 struct AddonToKodiFuncTable_kodi_gui_control_fade_label;
31 struct AddonToKodiFuncTable_kodi_gui_control_label;
32 struct AddonToKodiFuncTable_kodi_gui_control_image;
33 struct AddonToKodiFuncTable_kodi_gui_control_progress;
34 struct AddonToKodiFuncTable_kodi_gui_control_radio_button;
35 struct AddonToKodiFuncTable_kodi_gui_control_rendering;
36 struct AddonToKodiFuncTable_kodi_gui_control_settings_slider;
37 struct AddonToKodiFuncTable_kodi_gui_control_slider;
38 struct AddonToKodiFuncTable_kodi_gui_control_spin;
39 struct AddonToKodiFuncTable_kodi_gui_control_text_box;
40 struct AddonToKodiFuncTable_kodi_gui_dialogContextMenu;
41 struct AddonToKodiFuncTable_kodi_gui_dialogExtendedProgress;
42 struct AddonToKodiFuncTable_kodi_gui_dialogFileBrowser;
43 struct AddonToKodiFuncTable_kodi_gui_dialogKeyboard;
44 struct AddonToKodiFuncTable_kodi_gui_dialogNumeric;
45 struct AddonToKodiFuncTable_kodi_gui_dialogOK;
46 struct AddonToKodiFuncTable_kodi_gui_dialogProgress;
47 struct AddonToKodiFuncTable_kodi_gui_dialogSelect;
48 struct AddonToKodiFuncTable_kodi_gui_dialogTextViewer;
49 struct AddonToKodiFuncTable_kodi_gui_dialogYesNo;
50 struct AddonToKodiFuncTable_kodi_gui_listItem;
51 struct AddonToKodiFuncTable_kodi_gui_window;
52
53 typedef struct AddonToKodiFuncTable_kodi_gui
54 {
55 struct AddonToKodiFuncTable_kodi_gui_general* general;
56 struct AddonToKodiFuncTable_kodi_gui_control_button* control_button;
57 struct AddonToKodiFuncTable_kodi_gui_control_edit* control_edit;
58 struct AddonToKodiFuncTable_kodi_gui_control_fade_label* control_fade_label;
59 struct AddonToKodiFuncTable_kodi_gui_control_label* control_label;
60 struct AddonToKodiFuncTable_kodi_gui_control_image* control_image;
61 struct AddonToKodiFuncTable_kodi_gui_control_progress* control_progress;
62 struct AddonToKodiFuncTable_kodi_gui_control_radio_button* control_radio_button;
63 struct AddonToKodiFuncTable_kodi_gui_control_rendering* control_rendering;
64 struct AddonToKodiFuncTable_kodi_gui_control_settings_slider* control_settings_slider;
65 struct AddonToKodiFuncTable_kodi_gui_control_slider* control_slider;
66 struct AddonToKodiFuncTable_kodi_gui_control_spin* control_spin;
67 struct AddonToKodiFuncTable_kodi_gui_control_text_box* control_text_box;
68 KODI_HANDLE control_dummy1;
69 KODI_HANDLE control_dummy2;
70 KODI_HANDLE control_dummy3;
71 KODI_HANDLE control_dummy4;
72 KODI_HANDLE control_dummy5;
73 KODI_HANDLE control_dummy6;
74 KODI_HANDLE control_dummy7;
75 KODI_HANDLE control_dummy8;
76 KODI_HANDLE control_dummy9;
77 KODI_HANDLE control_dummy10; /* This and above used to add new controls */
78 struct AddonToKodiFuncTable_kodi_gui_dialogContextMenu* dialogContextMenu;
79 struct AddonToKodiFuncTable_kodi_gui_dialogExtendedProgress* dialogExtendedProgress;
80 struct AddonToKodiFuncTable_kodi_gui_dialogFileBrowser* dialogFileBrowser;
81 struct AddonToKodiFuncTable_kodi_gui_dialogKeyboard* dialogKeyboard;
82 struct AddonToKodiFuncTable_kodi_gui_dialogNumeric* dialogNumeric;
83 struct AddonToKodiFuncTable_kodi_gui_dialogOK* dialogOK;
84 struct AddonToKodiFuncTable_kodi_gui_dialogProgress* dialogProgress;
85 struct AddonToKodiFuncTable_kodi_gui_dialogSelect* dialogSelect;
86 struct AddonToKodiFuncTable_kodi_gui_dialogTextViewer* dialogTextViewer;
87 struct AddonToKodiFuncTable_kodi_gui_dialogYesNo* dialogYesNo;
88 KODI_HANDLE dialog_dummy1;
89 KODI_HANDLE dialog_dummy2;
90 KODI_HANDLE dialog_dummy3;
91 KODI_HANDLE dialog_dummy4;
92 KODI_HANDLE dialog_dummy5;
93 KODI_HANDLE dialog_dummy6;
94 KODI_HANDLE dialog_dummy7;
95 KODI_HANDLE dialog_dummy8;
96 KODI_HANDLE dialog_dummy9;
97 KODI_HANDLE dialog_dummy10; /* This and above used to add new dialogs */
98 struct AddonToKodiFuncTable_kodi_gui_listItem* listItem;
99 struct AddonToKodiFuncTable_kodi_gui_window* window;
100 } AddonToKodiFuncTable_kodi_gui;
101
102#ifdef __cplusplus
103} /* extern "C" */
104#endif /* __cplusplus */
105
106#endif /* !C_API_GUI_DEFINITIONS_H */
diff --git a/xbmc/addons/kodi-dev-kit/include/kodi/c-api/gui/dialogs/CMakeLists.txt b/xbmc/addons/kodi-dev-kit/include/kodi/c-api/gui/dialogs/CMakeLists.txt
new file mode 100644
index 0000000..bc35e91
--- /dev/null
+++ b/xbmc/addons/kodi-dev-kit/include/kodi/c-api/gui/dialogs/CMakeLists.txt
@@ -0,0 +1,14 @@
1set(HEADERS context_menu.h
2 extended_progress.h
3 filebrowser.h
4 keyboard.h
5 numeric.h
6 ok.h
7 progress.h
8 select.h
9 text_viewer.h
10 yes_no.h)
11
12if(NOT ENABLE_STATIC_LIBS)
13 core_add_library(addons_kodi-dev-kit_include_kodi_c-api_gui_dialogs)
14endif()
diff --git a/xbmc/addons/kodi-dev-kit/include/kodi/c-api/gui/dialogs/context_menu.h b/xbmc/addons/kodi-dev-kit/include/kodi/c-api/gui/dialogs/context_menu.h
new file mode 100644
index 0000000..8bb5370
--- /dev/null
+++ b/xbmc/addons/kodi-dev-kit/include/kodi/c-api/gui/dialogs/context_menu.h
@@ -0,0 +1,33 @@
1/*
2 * Copyright (C) 2005-2020 Team Kodi
3 * This file is part of Kodi - https://kodi.tv
4 *
5 * SPDX-License-Identifier: GPL-2.0-or-later
6 * See LICENSES/README.md for more information.
7 */
8
9#pragma once
10
11#ifndef C_API_GUI_DIALOGS_CONTEXT_MENU_H
12#define C_API_GUI_DIALOGS_CONTEXT_MENU_H
13
14#include "../definitions.h"
15
16#ifdef __cplusplus
17extern "C"
18{
19#endif /* __cplusplus */
20
21 typedef struct AddonToKodiFuncTable_kodi_gui_dialogContextMenu
22 {
23 int (*open)(KODI_HANDLE kodiBase,
24 const char* heading,
25 const char* entries[],
26 unsigned int size);
27 } AddonToKodiFuncTable_kodi_gui_dialogContextMenu;
28
29#ifdef __cplusplus
30} /* extern "C" */
31#endif /* __cplusplus */
32
33#endif /* !C_API_GUI_DIALOGS_CONTEXT_MENU_H */
diff --git a/xbmc/addons/kodi-dev-kit/include/kodi/c-api/gui/dialogs/extended_progress.h b/xbmc/addons/kodi-dev-kit/include/kodi/c-api/gui/dialogs/extended_progress.h
new file mode 100644
index 0000000..e53588f
--- /dev/null
+++ b/xbmc/addons/kodi-dev-kit/include/kodi/c-api/gui/dialogs/extended_progress.h
@@ -0,0 +1,43 @@
1/*
2 * Copyright (C) 2005-2020 Team Kodi
3 * This file is part of Kodi - https://kodi.tv
4 *
5 * SPDX-License-Identifier: GPL-2.0-or-later
6 * See LICENSES/README.md for more information.
7 */
8
9#pragma once
10
11#ifndef C_API_GUI_DIALOGS_EXTENDED_PROGRESS_H
12#define C_API_GUI_DIALOGS_EXTENDED_PROGRESS_H
13
14#include "../definitions.h"
15
16#ifdef __cplusplus
17extern "C"
18{
19#endif /* __cplusplus */
20
21 typedef struct AddonToKodiFuncTable_kodi_gui_dialogExtendedProgress
22 {
23 KODI_GUI_HANDLE (*new_dialog)(KODI_HANDLE kodiBase, const char* title);
24 void (*delete_dialog)(KODI_HANDLE kodiBase, KODI_GUI_HANDLE handle);
25 char* (*get_title)(KODI_HANDLE kodiBase, KODI_GUI_HANDLE handle);
26 void (*set_title)(KODI_HANDLE kodiBase, KODI_GUI_HANDLE handle, const char* title);
27 char* (*get_text)(KODI_HANDLE kodiBase, KODI_GUI_HANDLE handle);
28 void (*set_text)(KODI_HANDLE kodiBase, KODI_GUI_HANDLE handle, const char* text);
29 bool (*is_finished)(KODI_HANDLE kodiBase, KODI_GUI_HANDLE handle);
30 void (*mark_finished)(KODI_HANDLE kodiBase, KODI_GUI_HANDLE handle);
31 float (*get_percentage)(KODI_HANDLE kodiBase, KODI_GUI_HANDLE handle);
32 void (*set_percentage)(KODI_HANDLE kodiBase, KODI_GUI_HANDLE handle, float percentage);
33 void (*set_progress)(KODI_HANDLE kodiBase,
34 KODI_GUI_HANDLE handle,
35 int currentItem,
36 int itemCount);
37 } AddonToKodiFuncTable_kodi_gui_dialogExtendedProgress;
38
39#ifdef __cplusplus
40} /* extern "C" */
41#endif /* __cplusplus */
42
43#endif /* !C_API_GUI_DIALOGS_EXTENDED_PROGRESS_H */
diff --git a/xbmc/addons/kodi-dev-kit/include/kodi/c-api/gui/dialogs/filebrowser.h b/xbmc/addons/kodi-dev-kit/include/kodi/c-api/gui/dialogs/filebrowser.h
new file mode 100644
index 0000000..7ae4fac
--- /dev/null
+++ b/xbmc/addons/kodi-dev-kit/include/kodi/c-api/gui/dialogs/filebrowser.h
@@ -0,0 +1,77 @@
1/*
2 * Copyright (C) 2005-2020 Team Kodi
3 * This file is part of Kodi - https://kodi.tv
4 *
5 * SPDX-License-Identifier: GPL-2.0-or-later
6 * See LICENSES/README.md for more information.
7 */
8
9#pragma once
10
11#ifndef C_API_GUI_DIALOGS_FILEBROWSER_H
12#define C_API_GUI_DIALOGS_FILEBROWSER_H
13
14#include "../definitions.h"
15
16#ifdef __cplusplus
17extern "C"
18{
19#endif /* __cplusplus */
20
21 typedef struct AddonToKodiFuncTable_kodi_gui_dialogFileBrowser
22 {
23 bool (*show_and_get_directory)(KODI_HANDLE kodiBase,
24 const char* shares,
25 const char* heading,
26 const char* path_in,
27 char** path_out,
28 bool writeOnly);
29 bool (*show_and_get_file)(KODI_HANDLE kodiBase,
30 const char* shares,
31 const char* mask,
32 const char* heading,
33 const char* path_in,
34 char** path_out,
35 bool use_thumbs,
36 bool use_file_directories);
37 bool (*show_and_get_file_from_dir)(KODI_HANDLE kodiBase,
38 const char* directory,
39 const char* mask,
40 const char* heading,
41 const char* path_in,
42 char** path_out,
43 bool use_thumbs,
44 bool use_file_directories,
45 bool singleList);
46 bool (*show_and_get_file_list)(KODI_HANDLE kodiBase,
47 const char* shares,
48 const char* mask,
49 const char* heading,
50 char*** file_list,
51 unsigned int* entries,
52 bool use_thumbs,
53 bool use_file_directories);
54 bool (*show_and_get_source)(KODI_HANDLE kodiBase,
55 const char* path_in,
56 char** path_out,
57 bool allow_network_shares,
58 const char* additional_share,
59 const char* type);
60 bool (*show_and_get_image)(KODI_HANDLE kodiBase,
61 const char* shares,
62 const char* heading,
63 const char* path_in,
64 char** path_out);
65 bool (*show_and_get_image_list)(KODI_HANDLE kodiBase,
66 const char* shares,
67 const char* heading,
68 char*** file_list,
69 unsigned int* entries);
70 void (*clear_file_list)(KODI_HANDLE kodiBase, char*** file_list, unsigned int entries);
71 } AddonToKodiFuncTable_kodi_gui_dialogFileBrowser;
72
73#ifdef __cplusplus
74} /* extern "C" */
75#endif /* __cplusplus */
76
77#endif /* !C_API_GUI_DIALOGS_FILEBROWSER_H */
diff --git a/xbmc/addons/kodi-dev-kit/include/kodi/c-api/gui/dialogs/keyboard.h b/xbmc/addons/kodi-dev-kit/include/kodi/c-api/gui/dialogs/keyboard.h
new file mode 100644
index 0000000..fc3c34c
--- /dev/null
+++ b/xbmc/addons/kodi-dev-kit/include/kodi/c-api/gui/dialogs/keyboard.h
@@ -0,0 +1,74 @@
1/*
2 * Copyright (C) 2005-2020 Team Kodi
3 * This file is part of Kodi - https://kodi.tv
4 *
5 * SPDX-License-Identifier: GPL-2.0-or-later
6 * See LICENSES/README.md for more information.
7 */
8
9#pragma once
10
11#ifndef C_API_GUI_DIALOGS_KEYBOARD_H
12#define C_API_GUI_DIALOGS_KEYBOARD_H
13
14#include "../definitions.h"
15
16#ifdef __cplusplus
17extern "C"
18{
19#endif /* __cplusplus */
20
21 typedef struct AddonToKodiFuncTable_kodi_gui_dialogKeyboard
22 {
23 bool (*show_and_get_input_with_head)(KODI_HANDLE kodiBase,
24 const char* text_in,
25 char** text_out,
26 const char* heading,
27 bool allow_empty_result,
28 bool hiddenInput,
29 unsigned int auto_close_ms);
30 bool (*show_and_get_input)(KODI_HANDLE kodiBase,
31 const char* text_in,
32 char** text_out,
33 bool allow_empty_result,
34 unsigned int auto_close_ms);
35 bool (*show_and_get_new_password_with_head)(KODI_HANDLE kodiBase,
36 const char* password_in,
37 char** password_out,
38 const char* heading,
39 bool allow_empty_result,
40 unsigned int auto_close_ms);
41 bool (*show_and_get_new_password)(KODI_HANDLE kodiBase,
42 const char* password_in,
43 char** password_out,
44 unsigned int auto_close_ms);
45 bool (*show_and_verify_new_password_with_head)(KODI_HANDLE kodiBase,
46 char** password_out,
47 const char* heading,
48 bool allow_empty_result,
49 unsigned int auto_close_ms);
50 bool (*show_and_verify_new_password)(KODI_HANDLE kodiBase,
51 char** password_out,
52 unsigned int auto_close_ms);
53 int (*show_and_verify_password)(KODI_HANDLE kodiBase,
54 const char* password_in,
55 char** password_out,
56 const char* heading,
57 int retries,
58 unsigned int auto_close_ms);
59 bool (*show_and_get_filter)(KODI_HANDLE kodiBase,
60 const char* text_in,
61 char** text_out,
62 bool searching,
63 unsigned int auto_close_ms);
64 bool (*send_text_to_active_keyboard)(KODI_HANDLE kodiBase,
65 const char* text,
66 bool close_keyboard);
67 bool (*is_keyboard_activated)(KODI_HANDLE kodiBase);
68 } AddonToKodiFuncTable_kodi_gui_dialogKeyboard;
69
70#ifdef __cplusplus
71} /* extern "C" */
72#endif /* __cplusplus */
73
74#endif /* !C_API_GUI_DIALOGS_KEYBOARD_H */
diff --git a/xbmc/addons/kodi-dev-kit/include/kodi/c-api/gui/dialogs/numeric.h b/xbmc/addons/kodi-dev-kit/include/kodi/c-api/gui/dialogs/numeric.h
new file mode 100644
index 0000000..df23cd7
--- /dev/null
+++ b/xbmc/addons/kodi-dev-kit/include/kodi/c-api/gui/dialogs/numeric.h
@@ -0,0 +1,54 @@
1/*
2 * Copyright (C) 2005-2020 Team Kodi
3 * This file is part of Kodi - https://kodi.tv
4 *
5 * SPDX-License-Identifier: GPL-2.0-or-later
6 * See LICENSES/README.md for more information.
7 */
8
9#pragma once
10
11#ifndef C_API_GUI_DIALOGS_NUMERIC_H
12#define C_API_GUI_DIALOGS_NUMERIC_H
13
14#include "../definitions.h"
15
16#ifdef __cplusplus
17extern "C"
18{
19#endif /* __cplusplus */
20
21 typedef struct AddonToKodiFuncTable_kodi_gui_dialogNumeric
22 {
23 bool (*show_and_verify_new_password)(KODI_HANDLE kodiBase, char** password);
24 int (*show_and_verify_password)(KODI_HANDLE kodiBase,
25 const char* password,
26 const char* heading,
27 int retries);
28 bool (*show_and_verify_input)(KODI_HANDLE kodiBase,
29 const char* verify_in,
30 char** verify_out,
31 const char* heading,
32 bool verify_input);
33 bool (*show_and_get_time)(KODI_HANDLE kodiBase, struct tm* time, const char* heading);
34 bool (*show_and_get_date)(KODI_HANDLE kodiBase, struct tm* date, const char* heading);
35 bool (*show_and_get_ip_address)(KODI_HANDLE kodiBase,
36 const char* ip_address_in,
37 char** ip_address_out,
38 const char* heading);
39 bool (*show_and_get_number)(KODI_HANDLE kodiBase,
40 const char* input_in,
41 char** input_out,
42 const char* heading,
43 unsigned int auto_close_ms);
44 bool (*show_and_get_seconds)(KODI_HANDLE kodiBase,
45 const char* time_in,
46 char** time_out,
47 const char* heading);
48 } AddonToKodiFuncTable_kodi_gui_dialogNumeric;
49
50#ifdef __cplusplus
51} /* extern "C" */
52#endif /* __cplusplus */
53
54#endif /* !C_API_GUI_DIALOGS_NUMERIC_H */
diff --git a/xbmc/addons/kodi-dev-kit/include/kodi/c-api/gui/dialogs/ok.h b/xbmc/addons/kodi-dev-kit/include/kodi/c-api/gui/dialogs/ok.h
new file mode 100644
index 0000000..9f37051
--- /dev/null
+++ b/xbmc/addons/kodi-dev-kit/include/kodi/c-api/gui/dialogs/ok.h
@@ -0,0 +1,37 @@
1/*
2 * Copyright (C) 2005-2020 Team Kodi
3 * This file is part of Kodi - https://kodi.tv
4 *
5 * SPDX-License-Identifier: GPL-2.0-or-later
6 * See LICENSES/README.md for more information.
7 */
8
9#pragma once
10
11#ifndef C_API_GUI_DIALOGS_OK_H
12#define C_API_GUI_DIALOGS_OK_H
13
14#include "../definitions.h"
15
16#ifdef __cplusplus
17extern "C"
18{
19#endif /* __cplusplus */
20
21 typedef struct AddonToKodiFuncTable_kodi_gui_dialogOK
22 {
23 void (*show_and_get_input_single_text)(KODI_HANDLE kodiBase,
24 const char* heading,
25 const char* text);
26 void (*show_and_get_input_line_text)(KODI_HANDLE kodiBase,
27 const char* heading,
28 const char* line0,
29 const char* line1,
30 const char* line2);
31 } AddonToKodiFuncTable_kodi_gui_dialogOK;
32
33#ifdef __cplusplus
34} /* extern "C" */
35#endif /* __cplusplus */
36
37#endif /* !C_API_GUI_DIALOGS_OK_H */
diff --git a/xbmc/addons/kodi-dev-kit/include/kodi/c-api/gui/dialogs/progress.h b/xbmc/addons/kodi-dev-kit/include/kodi/c-api/gui/dialogs/progress.h
new file mode 100644
index 0000000..f1c8972
--- /dev/null
+++ b/xbmc/addons/kodi-dev-kit/include/kodi/c-api/gui/dialogs/progress.h
@@ -0,0 +1,45 @@
1/*
2 * Copyright (C) 2005-2020 Team Kodi
3 * This file is part of Kodi - https://kodi.tv
4 *
5 * SPDX-License-Identifier: GPL-2.0-or-later
6 * See LICENSES/README.md for more information.
7 */
8
9#pragma once
10
11#ifndef C_API_GUI_DIALOGS_PROGRESS_H
12#define C_API_GUI_DIALOGS_PROGRESS_H
13
14#include "../definitions.h"
15
16#ifdef __cplusplus
17extern "C"
18{
19#endif /* __cplusplus */
20
21 typedef struct AddonToKodiFuncTable_kodi_gui_dialogProgress
22 {
23 KODI_GUI_HANDLE (*new_dialog)(KODI_HANDLE kodiBase);
24 void (*delete_dialog)(KODI_HANDLE kodiBase, KODI_GUI_HANDLE handle);
25 void (*open)(KODI_HANDLE kodiBase, KODI_GUI_HANDLE handle);
26 void (*set_heading)(KODI_HANDLE kodiBase, KODI_GUI_HANDLE handle, const char* heading);
27 void (*set_line)(KODI_HANDLE kodiBase,
28 KODI_GUI_HANDLE handle,
29 unsigned int lineNo,
30 const char* line);
31 void (*set_can_cancel)(KODI_HANDLE kodiBase, KODI_GUI_HANDLE handle, bool canCancel);
32 bool (*is_canceled)(KODI_HANDLE kodiBase, KODI_GUI_HANDLE handle);
33 void (*set_percentage)(KODI_HANDLE kodiBase, KODI_GUI_HANDLE handle, int percentage);
34 int (*get_percentage)(KODI_HANDLE kodiBase, KODI_GUI_HANDLE handle);
35 void (*show_progress_bar)(KODI_HANDLE kodiBase, KODI_GUI_HANDLE handle, bool pnOff);
36 void (*set_progress_max)(KODI_HANDLE kodiBase, KODI_GUI_HANDLE handle, int max);
37 void (*set_progress_advance)(KODI_HANDLE kodiBase, KODI_GUI_HANDLE handle, int nSteps);
38 bool (*abort)(KODI_HANDLE kodiBase, KODI_GUI_HANDLE handle);
39 } AddonToKodiFuncTable_kodi_gui_dialogProgress;
40
41#ifdef __cplusplus
42} /* extern "C" */
43#endif /* __cplusplus */
44
45#endif /* !C_API_GUI_DIALOGS_PROGRESS_H */
diff --git a/xbmc/addons/kodi-dev-kit/include/kodi/c-api/gui/dialogs/select.h b/xbmc/addons/kodi-dev-kit/include/kodi/c-api/gui/dialogs/select.h
new file mode 100644
index 0000000..41ab82f
--- /dev/null
+++ b/xbmc/addons/kodi-dev-kit/include/kodi/c-api/gui/dialogs/select.h
@@ -0,0 +1,42 @@
1/*
2 * Copyright (C) 2005-2020 Team Kodi
3 * This file is part of Kodi - https://kodi.tv
4 *
5 * SPDX-License-Identifier: GPL-2.0-or-later
6 * See LICENSES/README.md for more information.
7 */
8
9#pragma once
10
11#ifndef C_API_GUI_DIALOGS_SELECT_H
12#define C_API_GUI_DIALOGS_SELECT_H
13
14#include "../definitions.h"
15
16#ifdef __cplusplus
17extern "C"
18{
19#endif /* __cplusplus */
20
21 typedef struct AddonToKodiFuncTable_kodi_gui_dialogSelect
22 {
23 int (*open)(KODI_HANDLE kodiBase,
24 const char* heading,
25 const char* entries[],
26 unsigned int size,
27 int selected,
28 unsigned int autoclose);
29 bool (*open_multi_select)(KODI_HANDLE kodiBase,
30 const char* heading,
31 const char* entryIDs[],
32 const char* entryNames[],
33 bool entriesSelected[],
34 unsigned int size,
35 unsigned int autoclose);
36 } AddonToKodiFuncTable_kodi_gui_dialogSelect;
37
38#ifdef __cplusplus
39} /* extern "C" */
40#endif /* __cplusplus */
41
42#endif /* !C_API_GUI_DIALOGS_SELECT_H */
diff --git a/xbmc/addons/kodi-dev-kit/include/kodi/c-api/gui/dialogs/text_viewer.h b/xbmc/addons/kodi-dev-kit/include/kodi/c-api/gui/dialogs/text_viewer.h
new file mode 100644
index 0000000..eb38b0b
--- /dev/null
+++ b/xbmc/addons/kodi-dev-kit/include/kodi/c-api/gui/dialogs/text_viewer.h
@@ -0,0 +1,30 @@
1/*
2 * Copyright (C) 2005-2020 Team Kodi
3 * This file is part of Kodi - https://kodi.tv
4 *
5 * SPDX-License-Identifier: GPL-2.0-or-later
6 * See LICENSES/README.md for more information.
7 */
8
9#pragma once
10
11#ifndef C_API_GUI_DIALOGS_TEXT_VIEWER_H
12#define C_API_GUI_DIALOGS_TEXT_VIEWER_H
13
14#include "../definitions.h"
15
16#ifdef __cplusplus
17extern "C"
18{
19#endif /* __cplusplus */
20
21 typedef struct AddonToKodiFuncTable_kodi_gui_dialogTextViewer
22 {
23 void (*open)(KODI_HANDLE kodiBase, const char* heading, const char* text);
24 } AddonToKodiFuncTable_kodi_gui_dialogTextViewer;
25
26#ifdef __cplusplus
27} /* extern "C" */
28#endif /* __cplusplus */
29
30#endif /* !C_API_GUI_DIALOGS_TEXT_VIEWER_H */
diff --git a/xbmc/addons/kodi-dev-kit/include/kodi/c-api/gui/dialogs/yes_no.h b/xbmc/addons/kodi-dev-kit/include/kodi/c-api/gui/dialogs/yes_no.h
new file mode 100644
index 0000000..01ed806
--- /dev/null
+++ b/xbmc/addons/kodi-dev-kit/include/kodi/c-api/gui/dialogs/yes_no.h
@@ -0,0 +1,50 @@
1/*
2 * Copyright (C) 2005-2020 Team Kodi
3 * This file is part of Kodi - https://kodi.tv
4 *
5 * SPDX-License-Identifier: GPL-2.0-or-later
6 * See LICENSES/README.md for more information.
7 */
8
9#pragma once
10
11#ifndef C_API_GUI_DIALOGS_YES_NO_H
12#define C_API_GUI_DIALOGS_YES_NO_H
13
14#include "../definitions.h"
15
16#ifdef __cplusplus
17extern "C"
18{
19#endif /* __cplusplus */
20
21 typedef struct AddonToKodiFuncTable_kodi_gui_dialogYesNo
22 {
23 bool (*show_and_get_input_single_text)(KODI_HANDLE kodiBase,
24 const char* heading,
25 const char* text,
26 bool* canceled,
27 const char* noLabel,
28 const char* yesLabel);
29 bool (*show_and_get_input_line_text)(KODI_HANDLE kodiBase,
30 const char* heading,
31 const char* line0,
32 const char* line1,
33 const char* line2,
34 const char* noLabel,
35 const char* yesLabel);
36 bool (*show_and_get_input_line_button_text)(KODI_HANDLE kodiBase,
37 const char* heading,
38 const char* line0,
39 const char* line1,
40 const char* line2,
41 bool* canceled,
42 const char* noLabel,
43 const char* yesLabel);
44 } AddonToKodiFuncTable_kodi_gui_dialogYesNo;
45
46#ifdef __cplusplus
47} /* extern "C" */
48#endif /* __cplusplus */
49
50#endif /* !C_API_GUI_DIALOGS_YES_NO_H */
diff --git a/xbmc/addons/kodi-dev-kit/include/kodi/c-api/gui/general.h b/xbmc/addons/kodi-dev-kit/include/kodi/c-api/gui/general.h
new file mode 100644
index 0000000..d0d256c
--- /dev/null
+++ b/xbmc/addons/kodi-dev-kit/include/kodi/c-api/gui/general.h
@@ -0,0 +1,37 @@
1/*
2 * Copyright (C) 2005-2020 Team Kodi
3 * This file is part of Kodi - https://kodi.tv
4 *
5 * SPDX-License-Identifier: GPL-2.0-or-later
6 * See LICENSES/README.md for more information.
7 */
8
9#pragma once
10
11#ifndef C_API_GUI_GENERAL_H
12#define C_API_GUI_GENERAL_H
13
14#include "definitions.h"
15
16#ifdef __cplusplus
17extern "C"
18{
19#endif /* __cplusplus */
20
21 typedef struct AddonToKodiFuncTable_kodi_gui_general
22 {
23 void (*lock)();
24 void (*unlock)();
25 int (*get_screen_height)(KODI_HANDLE kodiBase);
26 int (*get_screen_width)(KODI_HANDLE kodiBase);
27 int (*get_video_resolution)(KODI_HANDLE kodiBase);
28 int (*get_current_window_dialog_id)(KODI_HANDLE kodiBase);
29 int (*get_current_window_id)(KODI_HANDLE kodiBase);
30 ADDON_HARDWARE_CONTEXT (*get_hw_context)(KODI_HANDLE kodiBase);
31 } AddonToKodiFuncTable_kodi_gui_general;
32
33#ifdef __cplusplus
34} /* extern "C" */
35#endif /* __cplusplus */
36
37#endif /* !C_API_GUI_GENERAL_H */
diff --git a/xbmc/addons/kodi-dev-kit/include/kodi/c-api/gui/input/CMakeLists.txt b/xbmc/addons/kodi-dev-kit/include/kodi/c-api/gui/input/CMakeLists.txt
new file mode 100644
index 0000000..c0bbd11
--- /dev/null
+++ b/xbmc/addons/kodi-dev-kit/include/kodi/c-api/gui/input/CMakeLists.txt
@@ -0,0 +1,5 @@
1set(HEADERS action_ids.h)
2
3if(NOT ENABLE_STATIC_LIBS)
4 core_add_library(addons_kodi-dev-kit_include_kodi_c-api_gui_input)
5endif()
diff --git a/xbmc/addons/kodi-dev-kit/include/kodi/c-api/gui/input/action_ids.h b/xbmc/addons/kodi-dev-kit/include/kodi/c-api/gui/input/action_ids.h
new file mode 100644
index 0000000..274f3d9
--- /dev/null
+++ b/xbmc/addons/kodi-dev-kit/include/kodi/c-api/gui/input/action_ids.h
@@ -0,0 +1,763 @@
1/*
2 * Copyright (C) 2005-2020 Team Kodi
3 * This file is part of Kodi - https://kodi.tv
4 *
5 * SPDX-License-Identifier: GPL-2.0-or-later
6 * See LICENSES/README.md for more information.
7 */
8
9#pragma once
10
11#ifndef C_API_GUI_ACTION_IDS_H
12#define C_API_GUI_ACTION_IDS_H
13
14/// @defgroup cpp_kodi_gui_Defs_action_ids enum ADDON_ACTION
15/// @ingroup cpp_kodi_gui_Defs
16/// @brief **Action Id's**\n
17/// Actions that we have defined.
18///
19///@{
20enum ADDON_ACTION
21{
22 /// @ingroup cpp_kodi_gui_key_action_ids
23 ///@{
24
25 /// @brief <b>`0 `</b>: None.
26 ADDON_ACTION_NONE = 0,
27
28 /// @brief <b>`1 `</b>: Move left.
29 ADDON_ACTION_MOVE_LEFT = 1,
30
31 /// @brief <b>`2 `</b>: Move right.
32 ADDON_ACTION_MOVE_RIGHT = 2,
33
34 /// @brief <b>`3 `</b>: Move up.
35 ADDON_ACTION_MOVE_UP = 3,
36
37 /// @brief <b>`4 `</b>: Move down.
38 ADDON_ACTION_MOVE_DOWN = 4,
39
40 /// @brief <b>`5 `</b>: Page up.
41 ADDON_ACTION_PAGE_UP = 5,
42
43 /// @brief <b>`6 `</b>: Page down.
44 ADDON_ACTION_PAGE_DOWN = 6,
45
46 /// @brief <b>`7 `</b>: Select item.
47 ADDON_ACTION_SELECT_ITEM = 7,
48
49 /// @brief <b>`8 `</b>: Highlight item.
50 ADDON_ACTION_HIGHLIGHT_ITEM = 8,
51
52 /// @brief <b>`9 `</b>: Parent directory.
53 ADDON_ACTION_PARENT_DIR = 9,
54
55 /// @brief <b>`10 `</b>: Previous menu.
56 ADDON_ACTION_PREVIOUS_MENU = 10,
57
58 /// @brief <b>`11 `</b>: Show info.
59 ADDON_ACTION_SHOW_INFO = 11,
60
61 /// @brief <b>`12 `</b>: Pause.
62 ADDON_ACTION_PAUSE = 12,
63
64 /// @brief <b>`13 `</b>: Stop.
65 ADDON_ACTION_STOP = 13,
66
67 /// @brief <b>`14 `</b>: Next item.
68 ADDON_ACTION_NEXT_ITEM = 14,
69
70 /// @brief <b>`15 `</b>: Previous item.
71 ADDON_ACTION_PREV_ITEM = 15,
72
73 /// @brief <b>`16 `</b>: Can be used to specify specific action in a window, Playback control is handled in ADDON_ACTION_PLAYER_*
74 ADDON_ACTION_FORWARD = 16,
75
76 /// @brief <b>`17 `</b>: Can be used to specify specific action in a window, Playback control is handled in ADDON_ACTION_PLAYER_*
77 ADDON_ACTION_REWIND = 17,
78
79 /// @brief <b>`18 `</b>: Toggle between GUI and movie or GUI and visualisation.
80 ADDON_ACTION_SHOW_GUI = 18,
81
82 /// @brief <b>`19 `</b>: Toggle quick-access zoom modes. Can b used in videoFullScreen.zml window id=2005
83 ADDON_ACTION_ASPECT_RATIO = 19,
84
85 /// @brief <b>`20 `</b>: Seek +1% in the movie. Can b used in videoFullScreen.xml window id=2005
86 ADDON_ACTION_STEP_FORWARD = 20,
87
88 /// @brief <b>`21 `</b>: Seek -1% in the movie. Can b used in videoFullScreen.xml window id=2005
89 ADDON_ACTION_STEP_BACK = 21,
90
91 /// @brief <b>`22 `</b>: Seek +10% in the movie. Can b used in videoFullScreen.xml window id=2005
92 ADDON_ACTION_BIG_STEP_FORWARD = 22,
93
94 /// @brief <b>`23 `</b>: Seek -10% in the movie. Can b used in videoFullScreen.xml window id=2005
95 ADDON_ACTION_BIG_STEP_BACK = 23,
96
97 /// @brief <b>`24 `</b>: Show/hide OSD. Can b used in videoFullScreen.xml window id=2005
98 ADDON_ACTION_SHOW_OSD = 24,
99
100 /// @brief <b>`25 `</b>: Turn subtitles on/off. Can b used in videoFullScreen.xml window id=2005
101 ADDON_ACTION_SHOW_SUBTITLES = 25,
102
103 /// @brief <b>`26 `</b>: Switch to next subtitle of movie. Can b used in videoFullScreen.xml window id=2005
104 ADDON_ACTION_NEXT_SUBTITLE = 26,
105
106 /// @brief <b>`27 `</b>: Show debug info for VideoPlayer
107 ADDON_ACTION_PLAYER_DEBUG = 27,
108
109 /// @brief <b>`28 `</b>: Show next picture of slideshow. Can b used in slideshow.xml window id=2007
110 ADDON_ACTION_NEXT_PICTURE = 28,
111
112 /// @brief <b>`29 `</b>: Show previous picture of slideshow. Can b used in slideshow.xml window id=2007
113 ADDON_ACTION_PREV_PICTURE = 29,
114
115 /// @brief <b>`30 `</b>: Zoom in picture during slideshow. Can b used in slideshow.xml window id=2007
116 ADDON_ACTION_ZOOM_OUT = 30,
117
118 /// @brief <b>`31 `</b>: Zoom out picture during slideshow. Can b used in slideshow.xml window id=2007
119 ADDON_ACTION_ZOOM_IN = 31,
120
121 /// @brief <b>`32 `</b>: Used to toggle between source view and destination view. Can be used in myfiles.xml window id=3
122 ADDON_ACTION_TOGGLE_SOURCE_DEST = 32,
123
124 /// @brief <b>`33 `</b>: Used to toggle between current view and playlist view. Can b used in all mymusic xml files
125 ADDON_ACTION_SHOW_PLAYLIST = 33,
126
127 /// @brief <b>`34 `</b>: Used to queue a item to the playlist. Can b used in all mymusic xml files
128 ADDON_ACTION_QUEUE_ITEM = 34,
129
130 /// @brief <b>`35 `</b>: Not used anymore
131 ADDON_ACTION_REMOVE_ITEM = 35,
132
133 /// @brief <b>`36 `</b>: Not used anymore
134 ADDON_ACTION_SHOW_FULLSCREEN = 36,
135
136 /// @brief <b>`37 `</b>: Zoom 1x picture during slideshow. Can b used in slideshow.xml window id=2007
137 ADDON_ACTION_ZOOM_LEVEL_NORMAL = 37,
138
139 /// @brief <b>`38 `</b>: Zoom 2x picture during slideshow. Can b used in slideshow.xml window id=2007
140 ADDON_ACTION_ZOOM_LEVEL_1 = 38,
141
142 /// @brief <b>`39 `</b>: Zoom 3x picture during slideshow. Can b used in slideshow.xml window id=2007
143 ADDON_ACTION_ZOOM_LEVEL_2 = 39,
144
145 /// @brief <b>`40 `</b>: Zoom 4x picture during slideshow. Can b used in slideshow.xml window id=2007
146 ADDON_ACTION_ZOOM_LEVEL_3 = 40,
147
148 /// @brief <b>`41 `</b>: Zoom 5x picture during slideshow. Can b used in slideshow.xml window id=2007
149 ADDON_ACTION_ZOOM_LEVEL_4 = 41,
150
151 /// @brief <b>`42 `</b>: Zoom 6x picture during slideshow. Can b used in slideshow.xml window id=2007
152 ADDON_ACTION_ZOOM_LEVEL_5 = 42,
153
154 /// @brief <b>`43 `</b>: Zoom 7x picture during slideshow. Can b used in slideshow.xml window id=2007
155 ADDON_ACTION_ZOOM_LEVEL_6 = 43,
156
157 /// @brief <b>`44 `</b>: Zoom 8x picture during slideshow. Can b used in slideshow.xml window id=2007
158 ADDON_ACTION_ZOOM_LEVEL_7 = 44,
159
160 /// @brief <b>`45 `</b>: Zoom 9x picture during slideshow. Can b used in slideshow.xml window id=2007
161 ADDON_ACTION_ZOOM_LEVEL_8 = 45,
162
163 /// @brief <b>`46 `</b>: Zoom 10x picture during slideshow. Can b used in slideshow.xml window id=2007
164 ADDON_ACTION_ZOOM_LEVEL_9 = 46,
165
166 /// @brief <b>`47 `</b>: Select next arrow. Can b used in: settingsScreenCalibration.xml windowid=11
167 ADDON_ACTION_CALIBRATE_SWAP_ARROWS = 47,
168
169 /// @brief <b>`48 `</b>: Reset calibration to defaults. Can b used in: `settingsScreenCalibration.xml` windowid=11/settingsUICalibration.xml windowid=10
170 ADDON_ACTION_CALIBRATE_RESET = 48,
171
172 /// @brief <b>`49 `</b>: Analog thumbstick move. Can b used in: `slideshow.xml`
173 /// windowid=2007/settingsScreenCalibration.xml windowid=11/settingsUICalibration.xml
174 /// windowid=10
175 /// @note see also ADDON_ACTION_ANALOG_MOVE_X_LEFT, ADDON_ACTION_ANALOG_MOVE_X_RIGHT,
176 /// ADDON_ACTION_ANALOG_MOVE_Y_UP, ADDON_ACTION_ANALOG_MOVE_Y_DOWN
177 ADDON_ACTION_ANALOG_MOVE = 49,
178
179 /// @brief <b>`50 `</b>: Rotate current picture clockwise during slideshow. Can be used in slideshow.xml window id=2007
180 ADDON_ACTION_ROTATE_PICTURE_CW = 50,
181
182 /// @brief <b>`51 `</b>: Rotate current picture counterclockwise during slideshow. Can be used in slideshow.xml window id=2007
183 ADDON_ACTION_ROTATE_PICTURE_CCW = 51,
184
185 /// @brief <b>`52 `</b>: Decrease subtitle/movie Delay. Can b used in videoFullScreen.xml window id=2005
186 ADDON_ACTION_SUBTITLE_DELAY_MIN = 52,
187
188 /// @brief <b>`53 `</b>: Increase subtitle/movie Delay. Can b used in videoFullScreen.xml window id=2005
189 ADDON_ACTION_SUBTITLE_DELAY_PLUS = 53,
190
191 /// @brief <b>`54 `</b>: Increase avsync delay. Can b used in videoFullScreen.xml window id=2005
192 ADDON_ACTION_AUDIO_DELAY_MIN = 54,
193
194 /// @brief <b>`55 `</b>: Decrease avsync delay. Can b used in videoFullScreen.xml window id=2005
195 ADDON_ACTION_AUDIO_DELAY_PLUS = 55,
196
197 /// @brief <b>`56 `</b>: Select next language in movie. Can b used in videoFullScreen.xml window id=2005
198 ADDON_ACTION_AUDIO_NEXT_LANGUAGE = 56,
199
200 /// @brief <b>`57 `</b>: Switch 2 next resolution. Can b used during screen calibration settingsScreenCalibration.xml windowid=11
201 ADDON_ACTION_CHANGE_RESOLUTION = 57,
202
203 /// @brief <b>`58 `</b>: remote keys 0-9. are used by multiple windows
204 /// for example in videoFullScreen.xml window id=2005 you can
205 /// enter time (mmss) to jump to particular point in the movie
206 /// with spincontrols you can enter 3digit number to quickly set
207 /// spincontrol to desired value
208 ///
209 /// Remote key 0
210 ADDON_ACTION_REMOTE_0 = 58,
211
212 /// @brief <b>`59 `</b>: Remote key 1
213 ADDON_ACTION_REMOTE_1 = 59,
214
215 /// @brief <b>`60 `</b>: Remote key 2
216 ADDON_ACTION_REMOTE_2 = 60,
217
218 /// @brief <b>`61 `</b>: Remote key 3
219 ADDON_ACTION_REMOTE_3 = 61,
220
221 /// @brief <b>`62 `</b>: Remote key 4
222 ADDON_ACTION_REMOTE_4 = 62,
223
224 /// @brief <b>`63 `</b>: Remote key 5
225 ADDON_ACTION_REMOTE_5 = 63,
226
227 /// @brief <b>`64 `</b>: Remote key 6
228 ADDON_ACTION_REMOTE_6 = 64,
229
230 /// @brief <b>`65 `</b>: Remote key 7
231 ADDON_ACTION_REMOTE_7 = 65,
232
233 /// @brief <b>`66 `</b>: Remote key 8
234 ADDON_ACTION_REMOTE_8 = 66,
235
236 /// @brief <b>`67 `</b>: Remote key 9
237 ADDON_ACTION_REMOTE_9 = 67,
238
239 /// @brief <b>`69 `</b>: Show player process info (video decoder, pixel format, pvr signal strength and the like
240 ADDON_ACTION_PLAYER_PROCESS_INFO = 69,
241
242 /// @brief <b>`70 `</b>: Program select.
243 ADDON_ACTION_PLAYER_PROGRAM_SELECT = 70,
244
245 /// @brief <b>`71 `</b>: Resolution select.
246 ADDON_ACTION_PLAYER_RESOLUTION_SELECT = 71,
247
248 /// @brief <b>`76 `</b>: Jumps a few seconds back during playback of movie. Can b used in videoFullScreen.xml window id=2005
249 ADDON_ACTION_SMALL_STEP_BACK = 76,
250
251 /// @brief <b>`77 `</b>: FF in current file played. global action, can be used anywhere
252 ADDON_ACTION_PLAYER_FORWARD = 77,
253
254 /// @brief <b>`78 `</b>: RW in current file played. global action, can be used anywhere
255 ADDON_ACTION_PLAYER_REWIND = 78,
256
257 /// @brief <b>`79 `</b>: Play current song. Unpauses song and sets playspeed to 1x. global action, can be used anywhere
258 ADDON_ACTION_PLAYER_PLAY = 79,
259
260 /// @brief <b>`80 `</b>: Delete current selected item. Can be used in myfiles.xml window id=3 and in myvideoTitle.xml window id=25
261 ADDON_ACTION_DELETE_ITEM = 80,
262
263 /// @brief <b>`81 `</b>: Copy current selected item. Can be used in myfiles.xml window id=3
264 ADDON_ACTION_COPY_ITEM = 81,
265
266 /// @brief <b>`82 `</b>: move current selected item. Can be used in myfiles.xml window id=3
267 ADDON_ACTION_MOVE_ITEM = 82,
268
269 /// @brief <b>`85 `</b>: Take a screenshot.
270 ADDON_ACTION_TAKE_SCREENSHOT = 85,
271
272 /// @brief <b>`87 `</b>: Rename item.
273 ADDON_ACTION_RENAME_ITEM = 87,
274
275 /// @brief <b>`87 `</b>: Volume up.
276 ADDON_ACTION_VOLUME_UP = 88,
277
278 /// @brief <b>`87 `</b>: Volume down.
279 ADDON_ACTION_VOLUME_DOWN = 89,
280
281 /// @brief <b>`90 `</b>: Volume amplication.
282 ADDON_ACTION_VOLAMP = 90,
283
284 /// @brief <b>`90 `</b>: Mute.
285 ADDON_ACTION_MUTE = 91,
286
287 /// @brief <b>`90 `</b>: Nav back.
288 ADDON_ACTION_NAV_BACK = 92,
289
290 /// @brief <b>`90 `</b>: Volume amp up,
291 ADDON_ACTION_VOLAMP_UP = 93,
292
293 /// @brief <b>`94 `</b>: Volume amp down.
294 ADDON_ACTION_VOLAMP_DOWN = 94,
295
296 /// @brief <b>`95 `</b>: Creates an episode bookmark on the currently playing video file containing more than one
297 /// episode
298 ADDON_ACTION_CREATE_EPISODE_BOOKMARK = 95,
299
300 /// @brief <b>`96 `</b>: Creates a bookmark of the currently playing video file
301 ADDON_ACTION_CREATE_BOOKMARK = 96,
302
303 /// @brief <b>`97 `</b>: Goto the next chapter, if not available perform a big step forward
304 ADDON_ACTION_CHAPTER_OR_BIG_STEP_FORWARD = 97,
305
306 /// @brief <b>`98 `</b>: Goto the previous chapter, if not available perform a big step back
307 ADDON_ACTION_CHAPTER_OR_BIG_STEP_BACK = 98,
308
309 /// @brief <b>`99 `</b>: Switch to next subtitle of movie, but will not enable/disable the subtitles. Can be used
310 /// in videoFullScreen.xml window id=2005
311 ADDON_ACTION_CYCLE_SUBTITLE = 99,
312
313 /// @brief <b>`100`</b>: Mouse action values start.
314 ///
315 /// Ends with @ref ADDON_ACTION_MOUSE_END.
316 ADDON_ACTION_MOUSE_START = 100,
317
318 /// @brief <b>`100`</b>: Mouse left click.
319 ADDON_ACTION_MOUSE_LEFT_CLICK = 100,
320
321 /// @brief <b>`101`</b>: Mouse right click.
322 ADDON_ACTION_MOUSE_RIGHT_CLICK = 101,
323
324 /// @brief <b>`102`</b>: Mouse middle click.
325 ADDON_ACTION_MOUSE_MIDDLE_CLICK = 102,
326
327 /// @brief <b>`103`</b>: Mouse double click.
328 ADDON_ACTION_MOUSE_DOUBLE_CLICK = 103,
329
330 /// @brief <b>`104`</b>: Mouse wheel up.
331 ADDON_ACTION_MOUSE_WHEEL_UP = 104,
332
333 /// @brief <b>`105`</b>: Mouse wheel down.
334 ADDON_ACTION_MOUSE_WHEEL_DOWN = 105,
335
336 /// @brief <b>`106`</b>: Mouse drag.
337 ADDON_ACTION_MOUSE_DRAG = 106,
338
339 /// @brief <b>`107`</b>: Mouse move.
340 ADDON_ACTION_MOUSE_MOVE = 107,
341
342 /// @brief <b>`108`</b>: Mouse long click.
343 ADDON_ACTION_MOUSE_LONG_CLICK = 108,
344
345 /// @brief <b>`109`</b>: Mouse drag end.
346 ADDON_ACTION_MOUSE_DRAG_END = 109,
347
348 /// @brief <b>`109`</b>: Mouse action values end.
349 ///
350 /// Starts with @ref ADDON_ACTION_MOUSE_START.
351 ADDON_ACTION_MOUSE_END = 109,
352
353 /// @brief <b>`110`</b>: Backspace.
354 ADDON_ACTION_BACKSPACE = 110,
355
356 /// @brief <b>`111`</b>: Scroll up.
357 ADDON_ACTION_SCROLL_UP = 111,
358
359 /// @brief <b>`112`</b>: Scroll down.
360 ADDON_ACTION_SCROLL_DOWN = 112,
361
362 /// @brief <b>`113`</b>: Analog forward.
363 ADDON_ACTION_ANALOG_FORWARD = 113,
364
365 /// @brief <b>`114`</b>: Analog rewind.
366 ADDON_ACTION_ANALOG_REWIND = 114,
367
368 /// @brief <b>`115`</b>: move item up in playlist
369 ADDON_ACTION_MOVE_ITEM_UP = 115,
370
371 /// @brief <b>`116`</b>: move item down in playlist
372 ADDON_ACTION_MOVE_ITEM_DOWN = 116,
373
374 /// @brief <b>`117`</b>: pops up the context menu
375 ADDON_ACTION_CONTEXT_MENU = 117,
376
377 /// @brief <b>`118`</b>: stuff for virtual keyboard shortcuts
378 ADDON_ACTION_SHIFT = 118,
379
380 /// @brief <b>`119`</b>: stuff for virtual keyboard shortcuts
381 ADDON_ACTION_SYMBOLS = 119,
382
383 /// @brief <b>`120`</b>: stuff for virtual keyboard shortcuts
384 ADDON_ACTION_CURSOR_LEFT = 120,
385
386 /// @brief <b>`121`</b>: stuff for virtual keyboard shortcuts
387 ADDON_ACTION_CURSOR_RIGHT = 121,
388
389 /// @brief <b>`122`</b>: Build in function
390 ADDON_ACTION_BUILT_IN_FUNCTION = 122,
391
392 /// @brief <b>`114`</b>: Displays current time, can be used in videoFullScreen.xml window id=2005
393 ADDON_ACTION_SHOW_OSD_TIME = 123,
394
395 /// @brief <b>`124`</b>: Seeks forward, and displays the seek bar.
396 ADDON_ACTION_ANALOG_SEEK_FORWARD = 124,
397
398 /// @brief <b>`125`</b>: Seeks backward, and displays the seek bar.
399 ADDON_ACTION_ANALOG_SEEK_BACK = 125,
400
401 /// @brief <b>`126`</b>: Visualization preset show.
402 ADDON_ACTION_VIS_PRESET_SHOW = 126,
403
404 /// @brief <b>`128`</b>: Visualization preset next.
405 ADDON_ACTION_VIS_PRESET_NEXT = 128,
406
407 /// @brief <b>`129`</b>: Visualization preset previous.
408 ADDON_ACTION_VIS_PRESET_PREV = 129,
409
410 /// @brief <b>`130`</b>: Visualization preset lock.
411 ADDON_ACTION_VIS_PRESET_LOCK = 130,
412
413 /// @brief <b>`131`</b>: Visualization preset random.
414 ADDON_ACTION_VIS_PRESET_RANDOM = 131,
415
416 /// @brief <b>`132`</b>: Visualization preset plus.
417 ADDON_ACTION_VIS_RATE_PRESET_PLUS = 132,
418
419 /// @brief <b>`133`</b>: Visualization preset minus.
420 ADDON_ACTION_VIS_RATE_PRESET_MINUS = 133,
421
422 /// @brief <b>`134`</b>: Show Videomenu
423 ADDON_ACTION_SHOW_VIDEOMENU = 134,
424
425 /// @brief <b>`135`</b>: Enter.
426 ADDON_ACTION_ENTER = 135,
427
428 /// @brief <b>`136`</b>: Increase rating.
429 ADDON_ACTION_INCREASE_RATING = 136,
430
431 /// @brief <b>`137`</b>: Decrease rating.
432 ADDON_ACTION_DECREASE_RATING = 137,
433
434 /// @brief <b>`138`</b>: Switch to next scene/cutpoint in movie.
435 ADDON_ACTION_NEXT_SCENE = 138,
436
437 /// @brief <b>`139`</b>: Switch to previous scene/cutpoint in movie.
438 ADDON_ACTION_PREV_SCENE = 139,
439
440 /// @brief <b>`140`</b>: Jump through a list or container to next letter.
441 ADDON_ACTION_NEXT_LETTER = 140,
442
443 /// @brief <b>`141`</b>: Jump through a list or container to previous letter.
444 ADDON_ACTION_PREV_LETTER = 141,
445
446 /// @brief <b>`142`</b>: Jump direct to a particular letter using SMS-style input
447 ///
448 /// Jump to SMS2.
449 ADDON_ACTION_JUMP_SMS2 = 142,
450
451 /// @brief <b>`143`</b>: Jump to SMS3.
452 ADDON_ACTION_JUMP_SMS3 = 143,
453
454 /// @brief <b>`144`</b>: Jump to SMS4.
455 ADDON_ACTION_JUMP_SMS4 = 144,
456
457 /// @brief <b>`145`</b>: Jump to SMS5.
458 ADDON_ACTION_JUMP_SMS5 = 145,
459
460 /// @brief <b>`146`</b>: Jump to SMS6.
461 ADDON_ACTION_JUMP_SMS6 = 146,
462
463 /// @brief <b>`147`</b>: Jump to SMS7.
464 ADDON_ACTION_JUMP_SMS7 = 147,
465
466 /// @brief <b>`148`</b>: Jump to SMS8.
467 ADDON_ACTION_JUMP_SMS8 = 148,
468
469 /// @brief <b>`149`</b>: Jump to SMS9.
470 ADDON_ACTION_JUMP_SMS9 = 149,
471
472 /// @brief <b>`150`</b>: Filter clear.
473 ADDON_ACTION_FILTER_CLEAR = 150,
474
475 /// @brief <b>`151`</b>: Filter SMS2.
476 ADDON_ACTION_FILTER_SMS2 = 151,
477
478 /// @brief <b>`152`</b>: Filter SMS3.
479 ADDON_ACTION_FILTER_SMS3 = 152,
480
481 /// @brief <b>`153`</b>: Filter SMS4.
482 ADDON_ACTION_FILTER_SMS4 = 153,
483
484 /// @brief <b>`154`</b>: Filter SMS5.
485 ADDON_ACTION_FILTER_SMS5 = 154,
486
487 /// @brief <b>`155`</b>: Filter SMS6.
488 ADDON_ACTION_FILTER_SMS6 = 155,
489
490 /// @brief <b>`156`</b>: Filter SMS7.
491 ADDON_ACTION_FILTER_SMS7 = 156,
492
493 /// @brief <b>`157`</b>: Filter SMS8.
494 ADDON_ACTION_FILTER_SMS8 = 157,
495
496 /// @brief <b>`158`</b>: Filter SMS9.
497 ADDON_ACTION_FILTER_SMS9 = 158,
498
499 /// @brief <b>`159`</b>: First page.
500 ADDON_ACTION_FIRST_PAGE = 159,
501
502 /// @brief <b>`160`</b>: Last page.
503 ADDON_ACTION_LAST_PAGE = 160,
504
505 /// @brief <b>`161`</b>: Audio delay.
506 ADDON_ACTION_AUDIO_DELAY = 161,
507
508 /// @brief <b>`162`</b>: Subtitle delay.
509 ADDON_ACTION_SUBTITLE_DELAY = 162,
510
511 /// @brief <b>`163`</b>: Menu.
512 ADDON_ACTION_MENU = 163,
513
514 /// @brief <b>`164`</b>: Set rating.
515 ADDON_ACTION_SET_RATING = 164,
516
517 /// @brief <b>`170`</b>: Record.
518 ADDON_ACTION_RECORD = 170,
519
520 /// @brief <b>`180`</b>: Paste.
521 ADDON_ACTION_PASTE = 180,
522
523 /// @brief <b>`181`</b>: Next control.
524 ADDON_ACTION_NEXT_CONTROL = 181,
525
526 /// @brief <b>`182`</b>: Previous control.
527 ADDON_ACTION_PREV_CONTROL = 182,
528
529 /// @brief <b>`183`</b>: Channel switch.
530 ADDON_ACTION_CHANNEL_SWITCH = 183,
531
532 /// @brief <b>`184`</b>: Channel up.
533 ADDON_ACTION_CHANNEL_UP = 184,
534
535 /// @brief <b>`185`</b>: Channel down.
536 ADDON_ACTION_CHANNEL_DOWN = 185,
537
538 /// @brief <b>`186`</b>: Next channel group.
539 ADDON_ACTION_NEXT_CHANNELGROUP = 186,
540
541 /// @brief <b>`187`</b>: Previous channel group.
542 ADDON_ACTION_PREVIOUS_CHANNELGROUP = 187,
543
544 /// @brief <b>`188`</b>: PVR play.
545 ADDON_ACTION_PVR_PLAY = 188,
546
547 /// @brief <b>`189`</b>: PVR play TV.
548 ADDON_ACTION_PVR_PLAY_TV = 189,
549
550 /// @brief <b>`190`</b>: PVR play radio.
551 ADDON_ACTION_PVR_PLAY_RADIO = 190,
552
553 /// @brief <b>`191`</b>: PVR show timer rule.
554 ADDON_ACTION_PVR_SHOW_TIMER_RULE = 191,
555
556 /// @brief <b>`192`</b>: Channel number sep
557 ADDON_ACTION_CHANNEL_NUMBER_SEP = 192,
558
559 /// @brief <b>`193`</b>: PVR announce reminders
560 ADDON_ACTION_PVR_ANNOUNCE_REMINDERS = 193,
561
562 /// @brief <b>`199`</b>: Switch 2 desktop resolution
563 ADDON_ACTION_TOGGLE_FULLSCREEN = 199,
564
565 /// @brief <b>`200`</b>: Toggle watched status (videos)
566 ADDON_ACTION_TOGGLE_WATCHED = 200,
567
568 /// @brief <b>`201`</b>: Scan item
569 ADDON_ACTION_SCAN_ITEM = 201,
570
571 /// @brief <b>`202`</b>: Switch digital <-> analog
572 ADDON_ACTION_TOGGLE_DIGITAL_ANALOG = 202,
573
574 /// @brief <b>`203`</b>: Reloads CButtonTranslator's keymaps
575 ADDON_ACTION_RELOAD_KEYMAPS = 203,
576
577 /// @brief <b>`204`</b>: Start the GUIControlProfiler running
578 ADDON_ACTION_GUIPROFILE_BEGIN = 204,
579
580 /// @brief <b>`215`</b>: Teletext Color button <b>Red</b> to control TopText
581 ADDON_ACTION_TELETEXT_RED = 215,
582
583 /// @brief <b>`216`</b>: Teletext Color button <b>Green</b> to control TopText
584 ADDON_ACTION_TELETEXT_GREEN = 216,
585
586 /// @brief <b>`217`</b>: Teletext Color button <b>Yellow</b> to control TopText
587 ADDON_ACTION_TELETEXT_YELLOW = 217,
588
589 /// @brief <b>`218`</b>: Teletext Color button <b>Blue</b> to control TopText
590 ADDON_ACTION_TELETEXT_BLUE = 218,
591
592 /// @brief <b>`219`</b>: Increase par.
593 ADDON_ACTION_INCREASE_PAR = 219,
594
595 /// @brief <b>`220`</b>: Decrease par.
596 ADDON_ACTION_DECREASE_PAR = 220,
597
598 /// @brief <b>`227`</b>: Shift up video image in VideoPlayer
599 ADDON_ACTION_VSHIFT_UP = 227,
600
601 /// @brief <b>`228`</b>: Shift down video image in VideoPlayer
602 ADDON_ACTION_VSHIFT_DOWN = 228,
603
604 /// @brief <b>`229`</b>: Play/pause. If playing it pauses, if paused it plays.
605 ADDON_ACTION_PLAYER_PLAYPAUSE = 229,
606
607 /// @brief <b>`230`</b>: Shift up subtitles in VideoPlayer
608 ADDON_ACTION_SUBTITLE_VSHIFT_UP = 230,
609
610 /// @brief <b>`231`</b>: Shift down subtitles in VideoPlayer
611 ADDON_ACTION_SUBTITLE_VSHIFT_DOWN = 231,
612
613 /// @brief <b>`232`</b>: Toggle vertical alignment of subtitles
614 ADDON_ACTION_SUBTITLE_ALIGN = 232,
615
616 /// @brief <b>`233`</b>: Filter.
617 ADDON_ACTION_FILTER = 233,
618
619 /// @brief <b>`234`</b>: Switch player.
620 ADDON_ACTION_SWITCH_PLAYER = 234,
621
622 /// @brief <b>`235`</b>: Stereo mode next.
623 ADDON_ACTION_STEREOMODE_NEXT = 235,
624
625 /// @brief <b>`236`</b>: Stereo mode previous.
626 ADDON_ACTION_STEREOMODE_PREVIOUS = 236,
627
628 /// @brief <b>`237`</b>: Turns 3d mode on/off.
629 ADDON_ACTION_STEREOMODE_TOGGLE = 237,
630
631 /// @brief <b>`238`</b>: Stereo mode select.
632 ADDON_ACTION_STEREOMODE_SELECT = 238,
633
634 /// @brief <b>`239`</b>: Stereo mode to mono.
635 ADDON_ACTION_STEREOMODE_TOMONO = 239,
636
637 /// @brief <b>`240`</b>: Stereo mode set.
638 ADDON_ACTION_STEREOMODE_SET = 240,
639
640 /// @brief <b>`241`</b>: Settings reset.
641 ADDON_ACTION_SETTINGS_RESET = 241,
642
643 /// @brief <b>`242`</b>: Settings level change.
644 ADDON_ACTION_SETTINGS_LEVEL_CHANGE = 242,
645
646 /// @brief <b>`243`</b>: Show autoclosing OSD. Can b used in videoFullScreen.xml window id=2005
647 ADDON_ACTION_TRIGGER_OSD = 243,
648
649 /// @brief <b>`244`</b>: Input text.
650 ADDON_ACTION_INPUT_TEXT = 244,
651
652 /// @brief <b>`245`</b>: Volume set.
653 ADDON_ACTION_VOLUME_SET = 245,
654
655 /// @brief <b>`246`</b>: Toggle commercial skip.
656 ADDON_ACTION_TOGGLE_COMMSKIP = 246,
657
658 /// @brief <b>`247`</b>: Browse for subtitle. Can be used in videofullscreen
659 ADDON_ACTION_BROWSE_SUBTITLE = 247,
660
661 /// @brief <b>`248`</b>: Send a reset command to the active game
662 ADDON_ACTION_PLAYER_RESET = 248,
663
664 /// @brief <b>`249`</b>: Toggle font. Used in TextViewer dialog
665 ADDON_ACTION_TOGGLE_FONT = 249,
666
667 /// @brief <b>`250`</b>: Cycle video streams. Used in videofullscreen.
668 ADDON_ACTION_VIDEO_NEXT_STREAM = 250,
669
670 /// @brief <b>`251`</b>: Used to queue an item to the next position in the playlist
671 ADDON_ACTION_QUEUE_ITEM_NEXT = 251,
672
673 /// @brief <b>`247`</b>: Toggle display HDR on/off
674 ADDON_ACTION_HDR_TOGGLE = 260,
675
676 /// @brief <b>`300`</b>: Voice actions
677 ADDON_ACTION_VOICE_RECOGNIZE = 300,
678
679 // Number 347 used om front by ADDON_ACTION_BROWSE_SUBTITLE
680
681 /// @brief <b>`401`</b>: Touch actions
682 ADDON_ACTION_TOUCH_TAP = 401,
683
684 /// @brief <b>`410`</b>: Touch actions
685 ADDON_ACTION_TOUCH_TAP_TEN = 410,
686
687 /// @brief <b>`411`</b>: Touch actions
688 ADDON_ACTION_TOUCH_LONGPRESS = 411,
689
690 /// @brief <b>`412`</b>: Touch actions
691 ADDON_ACTION_TOUCH_LONGPRESS_TEN = 420,
692
693 /// @brief <b>`500`</b>: Gesture notify.
694 ADDON_ACTION_GESTURE_NOTIFY = 500,
695
696 /// @brief <b>`501`</b>: Gesture begin.
697 ADDON_ACTION_GESTURE_BEGIN = 501,
698
699 /// @brief <b>`502`</b>: Send action with point and currentPinchScale (fingers together < 1.0 -> fingers apart > 1.0)
700 ADDON_ACTION_GESTURE_ZOOM = 502,
701
702 /// @brief <b>`503`</b>: Gesture rotate.
703 ADDON_ACTION_GESTURE_ROTATE = 503,
704
705 /// @brief <b>`504`</b>: Gesture pan.
706 ADDON_ACTION_GESTURE_PAN = 504,
707
708 /// @brief <b>`505`</b>: Gesture was interrupted in unspecified state
709 ADDON_ACTION_GESTURE_ABORT = 505,
710
711 /// @brief <b>`511`</b>: Gesture swipe left.
712 ADDON_ACTION_GESTURE_SWIPE_LEFT = 511,
713
714 /// @brief <b>`520`</b>: Gesture swipe left ten
715 ADDON_ACTION_GESTURE_SWIPE_LEFT_TEN = 520,
716
717 /// @brief <b>`521`</b>: Gesture swipe right
718 ADDON_ACTION_GESTURE_SWIPE_RIGHT = 521,
719
720 /// @brief <b>`530`</b>: Gesture swipe right ten
721 ADDON_ACTION_GESTURE_SWIPE_RIGHT_TEN = 530,
722
723 /// @brief <b>`531`</b>: Gesture swipe up
724 ADDON_ACTION_GESTURE_SWIPE_UP = 531,
725
726 /// @brief <b>`540`</b>: Gesture swipe up ten
727 ADDON_ACTION_GESTURE_SWIPE_UP_TEN = 540,
728
729 /// @brief <b>`541`</b>: Gesture swipe down.
730 ADDON_ACTION_GESTURE_SWIPE_DOWN = 541,
731
732 /// @brief <b>`550`</b>: Gesture swipe down ten.
733 ADDON_ACTION_GESTURE_SWIPE_DOWN_TEN = 550,
734
735 /// @brief <b>`599`</b>: 5xx is reserved for additional gesture actions
736 ADDON_ACTION_GESTURE_END = 599,
737
738 // other, non-gesture actions
739
740 /// @brief <b>`601`</b>: Analog thumbstick move, horizontal axis, left; see ADDON_ACTION_ANALOG_MOVE
741 ADDON_ACTION_ANALOG_MOVE_X_LEFT = 601,
742
743 /// @brief <b>`602`</b>: Analog thumbstick move, horizontal axis, right; see ADDON_ACTION_ANALOG_MOVE
744 ADDON_ACTION_ANALOG_MOVE_X_RIGHT = 602,
745
746 /// @brief <b>`603`</b>: Analog thumbstick move, vertical axis, up; see ADDON_ACTION_ANALOG_MOVE
747 ADDON_ACTION_ANALOG_MOVE_Y_UP = 603,
748
749 /// @brief <b>`604`</b>: Analog thumbstick move, vertical axis, down; see ADDON_ACTION_ANALOG_MOVE
750 ADDON_ACTION_ANALOG_MOVE_Y_DOWN = 604,
751
752 /// @brief <b>`998`</b>: ERROR action is used to play an error sound.
753 ADDON_ACTION_ERROR = 998,
754
755 /// @brief <b>`999`</b>: The NOOP action can be specified to disable an input event. This is
756 /// useful in user keyboard.xml etc to disable actions specified in the
757 /// system mappings.
758 ADDON_ACTION_NOOP = 999
759 ///@}
760};
761///@}
762
763#endif /* !C_API_GUI_ACTION_IDS_H */
diff --git a/xbmc/addons/kodi-dev-kit/include/kodi/c-api/gui/list_item.h b/xbmc/addons/kodi-dev-kit/include/kodi/c-api/gui/list_item.h
new file mode 100644
index 0000000..f0c4dc7
--- /dev/null
+++ b/xbmc/addons/kodi-dev-kit/include/kodi/c-api/gui/list_item.h
@@ -0,0 +1,54 @@
1/*
2 * Copyright (C) 2005-2020 Team Kodi
3 * This file is part of Kodi - https://kodi.tv
4 *
5 * SPDX-License-Identifier: GPL-2.0-or-later
6 * See LICENSES/README.md for more information.
7 */
8
9#pragma once
10
11#ifndef C_API_GUI_LIST_ITEM_H
12#define C_API_GUI_LIST_ITEM_H
13
14#include "definitions.h"
15
16#ifdef __cplusplus
17extern "C"
18{
19#endif /* __cplusplus */
20
21 typedef struct AddonToKodiFuncTable_kodi_gui_listItem
22 {
23 KODI_GUI_LISTITEM_HANDLE(*create)
24 (KODI_HANDLE kodiBase,
25 const char* label,
26 const char* label2,
27 const char* path);
28 void (*destroy)(KODI_HANDLE kodiBase, KODI_GUI_LISTITEM_HANDLE handle);
29
30 char* (*get_label)(KODI_HANDLE kodiBase, KODI_GUI_LISTITEM_HANDLE handle);
31 void (*set_label)(KODI_HANDLE kodiBase, KODI_GUI_LISTITEM_HANDLE handle, const char* label);
32 char* (*get_label2)(KODI_HANDLE kodiBase, KODI_GUI_LISTITEM_HANDLE handle);
33 void (*set_label2)(KODI_HANDLE kodiBase, KODI_GUI_LISTITEM_HANDLE handle, const char* label);
34 char* (*get_art)(KODI_HANDLE kodiBase, KODI_GUI_LISTITEM_HANDLE handle, const char* type);
35 void (*set_art)(KODI_HANDLE kodiBase,
36 KODI_GUI_LISTITEM_HANDLE handle,
37 const char* type,
38 const char* image);
39 char* (*get_path)(KODI_HANDLE kodiBase, KODI_GUI_LISTITEM_HANDLE handle);
40 void (*set_path)(KODI_HANDLE kodiBase, KODI_GUI_LISTITEM_HANDLE handle, const char* path);
41 char* (*get_property)(KODI_HANDLE kodiBase, KODI_GUI_LISTITEM_HANDLE handle, const char* key);
42 void (*set_property)(KODI_HANDLE kodiBase,
43 KODI_GUI_LISTITEM_HANDLE handle,
44 const char* key,
45 const char* value);
46 void (*select)(KODI_HANDLE kodiBase, KODI_GUI_LISTITEM_HANDLE handle, bool select);
47 bool (*is_selected)(KODI_HANDLE kodiBase, KODI_GUI_LISTITEM_HANDLE handle);
48 } AddonToKodiFuncTable_kodi_gui_listItem;
49
50#ifdef __cplusplus
51} /* extern "C" */
52#endif /* __cplusplus */
53
54#endif /* !C_API_GUI_LIST_ITEM_H */
diff --git a/xbmc/addons/kodi-dev-kit/include/kodi/c-api/gui/window.h b/xbmc/addons/kodi-dev-kit/include/kodi/c-api/gui/window.h
new file mode 100644
index 0000000..0f844f5
--- /dev/null
+++ b/xbmc/addons/kodi-dev-kit/include/kodi/c-api/gui/window.h
@@ -0,0 +1,183 @@
1/*
2 * Copyright (C) 2005-2020 Team Kodi
3 * This file is part of Kodi - https://kodi.tv
4 *
5 * SPDX-License-Identifier: GPL-2.0-or-later
6 * See LICENSES/README.md for more information.
7 */
8
9#pragma once
10
11#ifndef C_API_GUI_WINDOW_H
12#define C_API_GUI_WINDOW_H
13
14#include "definitions.h"
15#include "input/action_ids.h"
16
17#include <stddef.h>
18
19#define ADDON_MAX_CONTEXT_ENTRIES 20
20#define ADDON_MAX_CONTEXT_ENTRY_NAME_LENGTH 80
21
22#ifdef __cplusplus
23extern "C"
24{
25#endif /* __cplusplus */
26
27 typedef struct gui_context_menu_pair
28 {
29 unsigned int id;
30 char name[ADDON_MAX_CONTEXT_ENTRY_NAME_LENGTH];
31 } gui_context_menu_pair;
32
33 typedef struct AddonToKodiFuncTable_kodi_gui_window
34 {
35 /* Window creation functions */
36 KODI_GUI_WINDOW_HANDLE(*create)
37 (KODI_HANDLE kodiBase,
38 const char* xml_filename,
39 const char* default_skin,
40 bool as_dialog,
41 bool is_media);
42 void (*destroy)(KODI_HANDLE kodiBase, KODI_GUI_WINDOW_HANDLE handle);
43
44 void (*set_callbacks)(KODI_HANDLE kodiBase,
45 KODI_GUI_WINDOW_HANDLE handle,
46 KODI_GUI_CLIENT_HANDLE clienthandle,
47 bool (*CBInit)(KODI_GUI_CLIENT_HANDLE),
48 bool (*CBFocus)(KODI_GUI_CLIENT_HANDLE, int),
49 bool (*CBClick)(KODI_GUI_CLIENT_HANDLE, int),
50 bool (*CBOnAction)(KODI_GUI_CLIENT_HANDLE, enum ADDON_ACTION),
51 void (*CBGetContextButtons)(
52 KODI_GUI_CLIENT_HANDLE, int, gui_context_menu_pair*, unsigned int*),
53 bool (*CBOnContextButton)(KODI_GUI_CLIENT_HANDLE, int, unsigned int));
54 bool (*show)(KODI_HANDLE kodiBase, KODI_GUI_WINDOW_HANDLE handle);
55 bool (*close)(KODI_HANDLE kodiBase, KODI_GUI_WINDOW_HANDLE handle);
56 bool (*do_modal)(KODI_HANDLE kodiBase, KODI_GUI_WINDOW_HANDLE handle);
57
58 /* Window control functions */
59 bool (*set_focus_id)(KODI_HANDLE kodiBase, KODI_GUI_WINDOW_HANDLE handle, int control_id);
60 int (*get_focus_id)(KODI_HANDLE kodiBase, KODI_GUI_WINDOW_HANDLE handle);
61 void (*set_control_label)(KODI_HANDLE kodiBase,
62 KODI_GUI_WINDOW_HANDLE handle,
63 int control_id,
64 const char* label);
65 void (*set_control_visible)(KODI_HANDLE kodiBase,
66 KODI_GUI_WINDOW_HANDLE handle,
67 int control_id,
68 bool visible);
69 void (*set_control_selected)(KODI_HANDLE kodiBase,
70 KODI_GUI_WINDOW_HANDLE handle,
71 int control_id,
72 bool selected);
73
74 /* Window property functions */
75 void (*set_property)(KODI_HANDLE kodiBase,
76 KODI_GUI_WINDOW_HANDLE handle,
77 const char* key,
78 const char* value);
79 void (*set_property_int)(KODI_HANDLE kodiBase,
80 KODI_GUI_WINDOW_HANDLE handle,
81 const char* key,
82 int value);
83 void (*set_property_bool)(KODI_HANDLE kodiBase,
84 KODI_GUI_WINDOW_HANDLE handle,
85 const char* key,
86 bool value);
87 void (*set_property_double)(KODI_HANDLE kodiBase,
88 KODI_GUI_WINDOW_HANDLE handle,
89 const char* key,
90 double value);
91 char* (*get_property)(KODI_HANDLE kodiBase, KODI_GUI_WINDOW_HANDLE handle, const char* key);
92 int (*get_property_int)(KODI_HANDLE kodiBase, KODI_GUI_WINDOW_HANDLE handle, const char* key);
93 bool (*get_property_bool)(KODI_HANDLE kodiBase, KODI_GUI_WINDOW_HANDLE handle, const char* key);
94 double (*get_property_double)(KODI_HANDLE kodiBase,
95 KODI_GUI_WINDOW_HANDLE handle,
96 const char* key);
97 void (*clear_properties)(KODI_HANDLE kodiBase, KODI_GUI_WINDOW_HANDLE handle);
98 void (*clear_property)(KODI_HANDLE kodiBase, KODI_GUI_WINDOW_HANDLE handle, const char* key);
99
100 /* List item functions */
101 void (*clear_item_list)(KODI_HANDLE kodiBase, KODI_GUI_WINDOW_HANDLE handle);
102 void (*add_list_item)(KODI_HANDLE kodiBase,
103 KODI_GUI_WINDOW_HANDLE handle,
104 KODI_GUI_LISTITEM_HANDLE item,
105 int list_position);
106 void (*remove_list_item_from_position)(KODI_HANDLE kodiBase,
107 KODI_GUI_WINDOW_HANDLE handle,
108 int list_position);
109 void (*remove_list_item)(KODI_HANDLE kodiBase,
110 KODI_GUI_WINDOW_HANDLE handle,
111 KODI_GUI_LISTITEM_HANDLE item);
112 KODI_GUI_LISTITEM_HANDLE(*get_list_item)
113 (KODI_HANDLE kodiBase, KODI_GUI_WINDOW_HANDLE handle, int list_position);
114 void (*set_current_list_position)(KODI_HANDLE kodiBase,
115 KODI_GUI_WINDOW_HANDLE handle,
116 int list_position);
117 int (*get_current_list_position)(KODI_HANDLE kodiBase, KODI_GUI_WINDOW_HANDLE handle);
118 int (*get_list_size)(KODI_HANDLE kodiBase, KODI_GUI_WINDOW_HANDLE handle);
119 void (*set_container_property)(KODI_HANDLE kodiBase,
120 KODI_GUI_WINDOW_HANDLE handle,
121 const char* key,
122 const char* value);
123 void (*set_container_content)(KODI_HANDLE kodiBase,
124 KODI_GUI_WINDOW_HANDLE handle,
125 const char* value);
126 int (*get_current_container_id)(KODI_HANDLE kodiBase, KODI_GUI_WINDOW_HANDLE handle);
127
128 /* Various functions */
129 void (*mark_dirty_region)(KODI_HANDLE kodiBase, KODI_GUI_WINDOW_HANDLE handle);
130
131 /* GUI control access functions */
132 KODI_GUI_CONTROL_HANDLE(*get_control_button)
133 (KODI_HANDLE kodiBase, KODI_GUI_WINDOW_HANDLE handle, int control_id);
134 KODI_GUI_CONTROL_HANDLE(*get_control_edit)
135 (KODI_HANDLE kodiBase, KODI_GUI_WINDOW_HANDLE handle, int control_id);
136 KODI_GUI_CONTROL_HANDLE(*get_control_fade_label)
137 (KODI_HANDLE kodiBase, KODI_GUI_WINDOW_HANDLE handle, int control_id);
138 KODI_GUI_CONTROL_HANDLE(*get_control_image)
139 (KODI_HANDLE kodiBase, KODI_GUI_WINDOW_HANDLE handle, int control_id);
140 KODI_GUI_CONTROL_HANDLE(*get_control_label)
141 (KODI_HANDLE kodiBase, KODI_GUI_WINDOW_HANDLE handle, int control_id);
142 KODI_GUI_CONTROL_HANDLE(*get_control_progress)
143 (KODI_HANDLE kodiBase, KODI_GUI_WINDOW_HANDLE handle, int control_id);
144 KODI_GUI_CONTROL_HANDLE(*get_control_radio_button)
145 (KODI_HANDLE kodiBase, KODI_GUI_WINDOW_HANDLE handle, int control_id);
146 KODI_GUI_CONTROL_HANDLE(*get_control_render_addon)
147 (KODI_HANDLE kodiBase, KODI_GUI_WINDOW_HANDLE handle, int control_id);
148 KODI_GUI_CONTROL_HANDLE(*get_control_settings_slider)
149 (KODI_HANDLE kodiBase, KODI_GUI_WINDOW_HANDLE handle, int control_id);
150 KODI_GUI_CONTROL_HANDLE(*get_control_slider)
151 (KODI_HANDLE kodiBase, KODI_GUI_WINDOW_HANDLE handle, int control_id);
152 KODI_GUI_CONTROL_HANDLE(*get_control_spin)
153 (KODI_HANDLE kodiBase, KODI_GUI_WINDOW_HANDLE handle, int control_id);
154 KODI_GUI_CONTROL_HANDLE(*get_control_text_box)
155 (KODI_HANDLE kodiBase, KODI_GUI_WINDOW_HANDLE handle, int control_id);
156 KODI_GUI_CONTROL_HANDLE(*get_control_dummy1)
157 (KODI_HANDLE kodiBase, KODI_GUI_WINDOW_HANDLE handle, int control_id);
158 KODI_GUI_CONTROL_HANDLE(*get_control_dummy2)
159 (KODI_HANDLE kodiBase, KODI_GUI_WINDOW_HANDLE handle, int control_id);
160 KODI_GUI_CONTROL_HANDLE(*get_control_dummy3)
161 (KODI_HANDLE kodiBase, KODI_GUI_WINDOW_HANDLE handle, int control_id);
162 KODI_GUI_CONTROL_HANDLE(*get_control_dummy4)
163 (KODI_HANDLE kodiBase, KODI_GUI_WINDOW_HANDLE handle, int control_id);
164 KODI_GUI_CONTROL_HANDLE(*get_control_dummy5)
165 (KODI_HANDLE kodiBase, KODI_GUI_WINDOW_HANDLE handle, int control_id);
166 KODI_GUI_CONTROL_HANDLE(*get_control_dummy6)
167 (KODI_HANDLE kodiBase, KODI_GUI_WINDOW_HANDLE handle, int control_id);
168 KODI_GUI_CONTROL_HANDLE(*get_control_dummy7)
169 (KODI_HANDLE kodiBase, KODI_GUI_WINDOW_HANDLE handle, int control_id);
170 KODI_GUI_CONTROL_HANDLE(*get_control_dummy8)
171 (KODI_HANDLE kodiBase, KODI_GUI_WINDOW_HANDLE handle, int control_id);
172 KODI_GUI_CONTROL_HANDLE(*get_control_dummy9)
173 (KODI_HANDLE kodiBase, KODI_GUI_WINDOW_HANDLE handle, int control_id);
174 KODI_GUI_CONTROL_HANDLE(*get_control_dummy10)
175 (KODI_HANDLE kodiBase, KODI_GUI_WINDOW_HANDLE handle, int control_id);
176 /* This above used to add new get_control_* functions */
177 } AddonToKodiFuncTable_kodi_gui_window;
178
179#ifdef __cplusplus
180} /* extern "C" */
181#endif /* __cplusplus */
182
183#endif /* !C_API_GUI_WINDOW_H */
diff --git a/xbmc/addons/kodi-dev-kit/include/kodi/c-api/network.h b/xbmc/addons/kodi-dev-kit/include/kodi/c-api/network.h
new file mode 100644
index 0000000..88d5231
--- /dev/null
+++ b/xbmc/addons/kodi-dev-kit/include/kodi/c-api/network.h
@@ -0,0 +1,48 @@
1/*
2 * Copyright (C) 2005-2018 Team Kodi
3 * This file is part of Kodi - https://kodi.tv
4 *
5 * SPDX-License-Identifier: GPL-2.0-or-later
6 * See LICENSES/README.md for more information.
7 */
8
9#pragma once
10
11#ifndef C_API_NETWORK_H
12#define C_API_NETWORK_H
13
14#include <stdbool.h>
15
16#ifdef __cplusplus
17extern "C"
18{
19#endif /* __cplusplus */
20
21 /*
22 * For interface between add-on and kodi.
23 *
24 * This structure defines the addresses of functions stored inside Kodi which
25 * are then available for the add-on to call
26 *
27 * All function pointers there are used by the C++ interface functions below.
28 * You find the set of them on xbmc/addons/interfaces/General.cpp
29 *
30 * Note: For add-on development itself this is not needed
31 */
32 typedef struct AddonToKodiFuncTable_kodi_network
33 {
34 bool (*wake_on_lan)(void* kodiBase, const char* mac);
35 char* (*get_ip_address)(void* kodiBase);
36 char* (*dns_lookup)(void* kodiBase, const char* url, bool* ret);
37 char* (*url_encode)(void* kodiBase, const char* url);
38 char* (*get_hostname)(void* kodiBase);
39 bool (*is_local_host)(void* kodiBase, const char* hostname);
40 bool (*is_host_on_lan)(void* kodiBase, const char* hostname, bool offLineCheck);
41 char* (*get_user_agent)(void* kodiBase);
42 } AddonToKodiFuncTable_kodi_network;
43
44#ifdef __cplusplus
45} /* extern "C" */
46#endif /* __cplusplus */
47
48#endif /* C_API_NETWORK_H */
diff --git a/xbmc/addons/kodi-dev-kit/include/kodi/c-api/platform/android/system.h b/xbmc/addons/kodi-dev-kit/include/kodi/c-api/platform/android/system.h
new file mode 100644
index 0000000..568a2fd
--- /dev/null
+++ b/xbmc/addons/kodi-dev-kit/include/kodi/c-api/platform/android/system.h
@@ -0,0 +1,34 @@
1/*
2 * Copyright (C) 2005-2020 Team Kodi
3 * This file is part of Kodi - https://kodi.tv
4 *
5 * SPDX-License-Identifier: GPL-2.0-or-later
6 * See LICENSES/README.md for more information.
7 */
8
9#pragma once
10
11#ifndef C_API_PLATFORM_ANDROID_H
12#define C_API_PLATFORM_ANDROID_H
13
14#define INTERFACE_ANDROID_SYSTEM_NAME "ANDROID_SYSTEM"
15#define INTERFACE_ANDROID_SYSTEM_VERSION "1.0.2"
16#define INTERFACE_ANDROID_SYSTEM_VERSION_MIN "1.0.1"
17
18#ifdef __cplusplus
19extern "C"
20{
21#endif /* __cplusplus */
22
23 struct AddonToKodiFuncTable_android_system
24 {
25 void* (*get_jni_env)();
26 int (*get_sdk_version)();
27 const char *(*get_class_name)();
28 };
29
30#ifdef __cplusplus
31}
32#endif /* __cplusplus */
33
34#endif /* !C_API_PLATFORM_ANDROID_H */
diff --git a/xbmc/addons/kodi-dev-kit/include/kodi/gui/CMakeLists.txt b/xbmc/addons/kodi-dev-kit/include/kodi/gui/CMakeLists.txt
new file mode 100644
index 0000000..8f12955
--- /dev/null
+++ b/xbmc/addons/kodi-dev-kit/include/kodi/gui/CMakeLists.txt
@@ -0,0 +1,8 @@
1set(HEADERS General.h
2 ListItem.h
3 Window.h
4 renderHelper.h)
5
6if(NOT ENABLE_STATIC_LIBS)
7 core_add_library(addons_kodi-dev-kit_include_kodi_gui)
8endif()
diff --git a/xbmc/addons/kodi-dev-kit/include/kodi/gui/General.h b/xbmc/addons/kodi-dev-kit/include/kodi/gui/General.h
new file mode 100644
index 0000000..85ba3f2
--- /dev/null
+++ b/xbmc/addons/kodi-dev-kit/include/kodi/gui/General.h
@@ -0,0 +1,176 @@
1/*
2 * Copyright (C) 2005-2018 Team Kodi
3 * This file is part of Kodi - https://kodi.tv
4 *
5 * SPDX-License-Identifier: GPL-2.0-or-later
6 * See LICENSES/README.md for more information.
7 */
8
9#pragma once
10
11#include "../AddonBase.h"
12#include "../c-api/gui/general.h"
13
14#ifdef __cplusplus
15
16namespace kodi
17{
18namespace gui
19{
20
21//==============================================================================
22/// @addtogroup cpp_kodi_gui_general
23/// Permits the use of the required functions of the add-on to Kodi.
24///
25/// These are pure functions them no other initialization need.
26///
27/// It has the header @ref kodi/gui/General.h "#include <kodi/gui/General.h>" be included
28/// to enjoy it.
29///
30
31//==============================================================================
32/// @ingroup cpp_kodi_gui_general
33/// @brief Performs a graphical lock of rendering engine.
34///
35inline void ATTRIBUTE_HIDDEN Lock()
36{
37 using namespace ::kodi::addon;
38 CAddonBase::m_interface->toKodi->kodi_gui->general->lock();
39}
40//------------------------------------------------------------------------------
41
42//==============================================================================
43/// @ingroup cpp_kodi_gui_general
44/// @brief Performs a graphical unlock of previous locked rendering engine.
45///
46inline void ATTRIBUTE_HIDDEN Unlock()
47{
48 using namespace ::kodi::addon;
49 CAddonBase::m_interface->toKodi->kodi_gui->general->unlock();
50}
51//------------------------------------------------------------------------------
52
53//==============================================================================
54/// @ingroup cpp_kodi_gui_general
55/// @brief Return the the current screen height with pixel.
56///
57/// @return Screen height with pixel
58///
59inline int ATTRIBUTE_HIDDEN GetScreenHeight()
60{
61 using namespace ::kodi::addon;
62 return CAddonBase::m_interface->toKodi->kodi_gui->general->get_screen_height(
63 CAddonBase::m_interface->toKodi->kodiBase);
64}
65//------------------------------------------------------------------------------
66
67//==============================================================================
68/// @ingroup cpp_kodi_gui_general
69/// @brief Return the the current screen width with pixel.
70///
71/// @return Screen width with pixel
72///
73inline int ATTRIBUTE_HIDDEN GetScreenWidth()
74{
75 using namespace ::kodi::addon;
76 return CAddonBase::m_interface->toKodi->kodi_gui->general->get_screen_width(
77 CAddonBase::m_interface->toKodi->kodiBase);
78}
79//------------------------------------------------------------------------------
80
81//==============================================================================
82/// @ingroup cpp_kodi_gui_general
83/// @brief Return the the current screen rendering resolution.
84///
85/// @return Current screen rendering resolution
86///
87inline int ATTRIBUTE_HIDDEN GetVideoResolution()
88{
89 using namespace ::kodi::addon;
90 return CAddonBase::m_interface->toKodi->kodi_gui->general->get_video_resolution(
91 CAddonBase::m_interface->toKodi->kodiBase);
92}
93//------------------------------------------------------------------------------
94
95//==============================================================================
96/// @ingroup cpp_kodi_gui_general
97/// @brief Returns the id for the current 'active' dialog as an integer.
98///
99/// @return The currently active dialog Id
100///
101///
102///-------------------------------------------------------------------------
103///
104/// **Example:**
105/// ~~~~~~~~~~~~~{.cpp}
106/// ..
107/// int wid = kodi::gui::GetCurrentWindowDialogId();
108/// ..
109/// ~~~~~~~~~~~~~
110///
111inline int ATTRIBUTE_HIDDEN GetCurrentWindowDialogId()
112{
113 using namespace ::kodi::addon;
114 return CAddonBase::m_interface->toKodi->kodi_gui->general->get_current_window_dialog_id(
115 CAddonBase::m_interface->toKodi->kodiBase);
116}
117//------------------------------------------------------------------------------
118
119//==============================================================================
120/// @ingroup cpp_kodi_gui_general
121/// @brief Returns the id for the current 'active' window as an integer.
122///
123/// @return The currently active window Id
124///
125///
126///-------------------------------------------------------------------------
127///
128/// **Example:**
129/// ~~~~~~~~~~~~~{.cpp}
130/// ..
131/// int wid = kodi::gui::GetCurrentWindowId();
132/// ..
133/// ~~~~~~~~~~~~~
134///
135inline int ATTRIBUTE_HIDDEN GetCurrentWindowId()
136{
137 using namespace ::kodi::addon;
138 return CAddonBase::m_interface->toKodi->kodi_gui->general->get_current_window_id(
139 CAddonBase::m_interface->toKodi->kodiBase);
140}
141//------------------------------------------------------------------------------
142
143//==============================================================================
144/// @ingroup cpp_kodi_gui_general
145/// @brief To get hardware specific device context interface.
146///
147/// @return A pointer to the used device with @ref cpp_kodi_Defs_HardwareContext "kodi::HardwareContext"
148///
149/// @warning This function is only be supported under Windows, on all other
150/// OS it return `nullptr`!
151///
152/// @note Returned Windows class pointer is `ID3D11DeviceContext1`.
153///
154///
155///-------------------------------------------------------------------------
156///
157/// **Example:**
158/// ~~~~~~~~~~~~~{.cpp}
159/// #include <d3d11_1.h>
160/// ..
161/// ID3D11DeviceContext1* context = static_cast<ID3D11DeviceContext1*>(kodi::gui::GetHWContext());
162/// ..
163/// ~~~~~~~~~~~~~
164///
165inline kodi::HardwareContext GetHWContext()
166{
167 using namespace ::kodi::addon;
168 return CAddonBase::m_interface->toKodi->kodi_gui->general->get_hw_context(
169 CAddonBase::m_interface->toKodi->kodiBase);
170}
171//------------------------------------------------------------------------------
172
173} /* namespace gui */
174} /* namespace kodi */
175
176#endif /* __cplusplus */
diff --git a/xbmc/addons/kodi-dev-kit/include/kodi/gui/ListItem.h b/xbmc/addons/kodi-dev-kit/include/kodi/gui/ListItem.h
new file mode 100644
index 0000000..3a4d50b
--- /dev/null
+++ b/xbmc/addons/kodi-dev-kit/include/kodi/gui/ListItem.h
@@ -0,0 +1,345 @@
1/*
2 * Copyright (C) 2005-2018 Team Kodi
3 * This file is part of Kodi - https://kodi.tv
4 *
5 * SPDX-License-Identifier: GPL-2.0-or-later
6 * See LICENSES/README.md for more information.
7 */
8
9#pragma once
10
11#include "../AddonBase.h"
12#include "../c-api/gui/list_item.h"
13
14#ifdef __cplusplus
15
16#include <memory>
17
18namespace kodi
19{
20namespace gui
21{
22
23class CWindow;
24
25class ATTRIBUTE_HIDDEN CAddonGUIControlBase
26{
27public:
28 KODI_GUI_LISTITEM_HANDLE GetControlHandle() const { return m_controlHandle; }
29
30protected:
31 explicit CAddonGUIControlBase(CAddonGUIControlBase* window)
32 : m_controlHandle(nullptr),
33 m_interface(::kodi::addon::CAddonBase::m_interface->toKodi),
34 m_Window(window)
35 {
36 }
37
38 virtual ~CAddonGUIControlBase() = default;
39
40 friend class CWindow;
41
42 KODI_GUI_LISTITEM_HANDLE m_controlHandle;
43 AddonToKodiFuncTable_Addon* m_interface;
44 CAddonGUIControlBase* m_Window;
45
46private:
47 CAddonGUIControlBase() = delete;
48 CAddonGUIControlBase(const CAddonGUIControlBase&) = delete;
49 CAddonGUIControlBase& operator=(const CAddonGUIControlBase&) = delete;
50};
51
52class CListItem;
53
54//==============================================================================
55/// @addtogroup cpp_kodi_gui_windows_listitem
56/// @brief @cpp_class{ kodi::gui::CListItem }
57/// **Selectable window list item**\n
58/// The list item control is used for creating item lists in Kodi.
59///
60/// The with @ref ListItem.h "#include <kodi/gui/ListItem.h>" given
61/// class is used to create a item entry for a list on window and to support it's
62/// control.
63///
64class ATTRIBUTE_HIDDEN CListItem : public CAddonGUIControlBase
65{
66public:
67 //============================================================================
68 /// @ingroup cpp_kodi_gui_windows_listitem
69 /// @brief Class constructor with parameters.
70 ///
71 /// @param[in] label [opt] Item label
72 /// @param[in] label2 [opt] Second Item label (if needed)
73 /// @param[in] path [opt] Path to where item is defined
74 ///
75 CListItem(const std::string& label = "",
76 const std::string& label2 = "",
77 const std::string& path = "")
78 : CAddonGUIControlBase(nullptr)
79 {
80 m_controlHandle = m_interface->kodi_gui->listItem->create(m_interface->kodiBase, label.c_str(),
81 label2.c_str(), path.c_str());
82 }
83
84 /*
85 * Constructor used for parts given by list items from addon window
86 *
87 * Related to call of "std::shared_ptr<CListItem> kodi::gui::CWindow::GetListItem(int listPos)"
88 * Not needed for addon development itself
89 */
90 explicit CListItem(KODI_GUI_LISTITEM_HANDLE listItemHandle) : CAddonGUIControlBase(nullptr)
91 {
92 m_controlHandle = listItemHandle;
93 }
94
95 //============================================================================
96 /// @ingroup cpp_kodi_gui_windows_listitem
97 /// @brief Class destructor
98 ///
99 ~CListItem() override
100 {
101 m_interface->kodi_gui->listItem->destroy(m_interface->kodiBase, m_controlHandle);
102 }
103 //----------------------------------------------------------------------------
104
105 //============================================================================
106 /// @ingroup cpp_kodi_gui_windows_listitem
107 /// @brief Returns the listitem label.
108 ///
109 /// @return Label of item
110 ///
111 std::string GetLabel()
112 {
113 std::string label;
114 char* ret = m_interface->kodi_gui->listItem->get_label(m_interface->kodiBase, m_controlHandle);
115 if (ret != nullptr)
116 {
117 if (std::strlen(ret))
118 label = ret;
119 m_interface->free_string(m_interface->kodiBase, ret);
120 }
121 return label;
122 }
123 //----------------------------------------------------------------------------
124
125 //============================================================================
126 /// @ingroup cpp_kodi_gui_windows_listitem
127 /// @brief Sets the listitem label.
128 ///
129 /// @param[in] label string or unicode - text string.
130 ///
131 void SetLabel(const std::string& label)
132 {
133 m_interface->kodi_gui->listItem->set_label(m_interface->kodiBase, m_controlHandle,
134 label.c_str());
135 }
136 //----------------------------------------------------------------------------
137
138 //============================================================================
139 /// @ingroup cpp_kodi_gui_windows_listitem
140 /// @brief Returns the second listitem label.
141 ///
142 /// @return Second label of item
143 ///
144 std::string GetLabel2()
145 {
146 std::string label;
147 char* ret = m_interface->kodi_gui->listItem->get_label2(m_interface->kodiBase, m_controlHandle);
148 if (ret != nullptr)
149 {
150 if (std::strlen(ret))
151 label = ret;
152 m_interface->free_string(m_interface->kodiBase, ret);
153 }
154 return label;
155 }
156 //----------------------------------------------------------------------------
157
158 //============================================================================
159 /// @ingroup cpp_kodi_gui_windows_listitem
160 /// @brief Sets the listitem's label2.
161 ///
162 /// @param[in] label string or unicode - text string.
163 ///
164 void SetLabel2(const std::string& label)
165 {
166 m_interface->kodi_gui->listItem->set_label2(m_interface->kodiBase, m_controlHandle,
167 label.c_str());
168 }
169 //----------------------------------------------------------------------------
170
171 //============================================================================
172 /// @ingroup cpp_kodi_gui_windows_listitem
173 /// @brief Sets the listitem's art
174 ///
175 /// @param[in] type Type of Art to set
176 /// - Some default art values (any string possible):
177 /// | value (type) | Type |
178 /// |:-------------:|:--------------------------------------------------|
179 /// | thumb | string - image filename
180 /// | poster | string - image filename
181 /// | banner | string - image filename
182 /// | fanart | string - image filename
183 /// | clearart | string - image filename
184 /// | clearlogo | string - image filename
185 /// | landscape | string - image filename
186 /// | icon | string - image filename
187 /// @return The url to use for Art
188 ///
189 std::string GetArt(const std::string& type)
190 {
191 std::string strReturn;
192 char* ret = m_interface->kodi_gui->listItem->get_art(m_interface->kodiBase, m_controlHandle,
193 type.c_str());
194 if (ret != nullptr)
195 {
196 if (std::strlen(ret))
197 strReturn = ret;
198 m_interface->free_string(m_interface->kodiBase, ret);
199 }
200 return strReturn;
201 }
202 //----------------------------------------------------------------------------
203
204 //============================================================================
205 /// @ingroup cpp_kodi_gui_windows_listitem
206 /// @brief Sets the listitem's art
207 ///
208 /// @param[in] type Type of Art to set
209 /// @param[in] url The url to use for Art
210 /// - Some default art values (any string possible):
211 /// | value (type) | Type |
212 /// |:-------------:|:--------------------------------------------------|
213 /// | thumb | string - image filename
214 /// | poster | string - image filename
215 /// | banner | string - image filename
216 /// | fanart | string - image filename
217 /// | clearart | string - image filename
218 /// | clearlogo | string - image filename
219 /// | landscape | string - image filename
220 /// | icon | string - image filename
221 ///
222 void SetArt(const std::string& type, const std::string& url)
223 {
224 m_interface->kodi_gui->listItem->set_art(m_interface->kodiBase, m_controlHandle, type.c_str(),
225 url.c_str());
226 }
227 //----------------------------------------------------------------------------
228
229 //============================================================================
230 /// @ingroup cpp_kodi_gui_windows_listitem
231 /// @brief Returns the path / filename of this listitem.
232 ///
233 /// @return Path string
234 ///
235 std::string GetPath()
236 {
237 std::string strReturn;
238 char* ret = m_interface->kodi_gui->listItem->get_path(m_interface->kodiBase, m_controlHandle);
239 if (ret != nullptr)
240 {
241 if (std::strlen(ret))
242 strReturn = ret;
243 m_interface->free_string(m_interface->kodiBase, ret);
244 }
245 return strReturn;
246 }
247 //----------------------------------------------------------------------------
248
249 //============================================================================
250 /// @ingroup cpp_kodi_gui_windows_listitem
251 /// @brief Sets the listitem's path.
252 ///
253 /// @param[in] path string or unicode - path, activated when item is clicked.
254 ///
255 /// @note You can use the above as keywords for arguments.
256 ///
257 void SetPath(const std::string& path)
258 {
259 m_interface->kodi_gui->listItem->set_path(m_interface->kodiBase, m_controlHandle, path.c_str());
260 }
261 //----------------------------------------------------------------------------
262
263 //============================================================================
264 /// @ingroup cpp_kodi_gui_windows_listitem
265 /// @brief Sets a listitem property, similar to an infolabel.
266 ///
267 /// @param[in] key string - property name.
268 /// @param[in] value string or unicode - value of property.
269 ///
270 /// @note Key is NOT case sensitive.
271 /// You can use the above as keywords for arguments and skip certain@n
272 /// optional arguments.\n
273 /// Once you use a keyword, all following arguments require the
274 /// keyword.
275 ///
276 /// Some of these are treated internally by Kodi, such as the
277 /// <b>'StartOffset'</b> property, which is the offset in seconds at which to
278 /// start playback of an item. Others may be used in the skin to add
279 /// extra information, such as <b>'WatchedCount'</b> for tvshow items
280 ///
281 void SetProperty(const std::string& key, const std::string& value)
282 {
283 m_interface->kodi_gui->listItem->set_property(m_interface->kodiBase, m_controlHandle,
284 key.c_str(), value.c_str());
285 }
286 //----------------------------------------------------------------------------
287
288 //============================================================================
289 /// @ingroup cpp_kodi_gui_windows_listitem
290 /// @brief Returns a listitem property as a string, similar to an infolabel.
291 ///
292 /// @param[in] key string - property name.
293 /// @return string - List item property
294 ///
295 /// @note Key is NOT case sensitive.\n
296 /// You can use the above as keywords for arguments and skip certain
297 /// optional arguments.\n
298 /// Once you use a keyword, all following arguments require the
299 /// keyword.
300 ///
301 std::string GetProperty(const std::string& key)
302 {
303 std::string label;
304 char* ret = m_interface->kodi_gui->listItem->get_property(m_interface->kodiBase,
305 m_controlHandle, key.c_str());
306 if (ret != nullptr)
307 {
308 if (std::strlen(ret))
309 label = ret;
310 m_interface->free_string(m_interface->kodiBase, ret);
311 }
312 return label;
313 }
314 //----------------------------------------------------------------------------
315
316 //============================================================================
317 /// @ingroup cpp_kodi_gui_windows_listitem
318 /// @brief To control selection of item in list (also multiple selection,
319 /// in list on serveral items possible).
320 ///
321 /// @param[in] selected if true becomes set as selected
322 ///
323 void Select(bool selected)
324 {
325 m_interface->kodi_gui->listItem->select(m_interface->kodiBase, m_controlHandle, selected);
326 }
327 //----------------------------------------------------------------------------
328
329 //============================================================================
330 /// @ingroup cpp_kodi_gui_windows_listitem
331 /// @brief Returns the listitem's selected status.
332 ///
333 /// @return true if selected, otherwise false
334 ///
335 bool IsSelected()
336 {
337 return m_interface->kodi_gui->listItem->is_selected(m_interface->kodiBase, m_controlHandle);
338 }
339 //----------------------------------------------------------------------------
340};
341
342} /* namespace gui */
343} /* namespace kodi */
344
345#endif /* __cplusplus */
diff --git a/xbmc/addons/kodi-dev-kit/include/kodi/gui/Window.h b/xbmc/addons/kodi-dev-kit/include/kodi/gui/Window.h
new file mode 100644
index 0000000..3066b3c
--- /dev/null
+++ b/xbmc/addons/kodi-dev-kit/include/kodi/gui/Window.h
@@ -0,0 +1,915 @@
1/*
2 * Copyright (C) 2005-2018 Team Kodi
3 * This file is part of Kodi - https://kodi.tv
4 *
5 * SPDX-License-Identifier: GPL-2.0-or-later
6 * See LICENSES/README.md for more information.
7 */
8
9#pragma once
10
11#include "../AddonBase.h"
12#include "../c-api/gui/window.h"
13#include "ListItem.h"
14#include "input/ActionIDs.h"
15
16#ifdef __cplusplus
17
18namespace kodi
19{
20namespace gui
21{
22
23//==============================================================================
24/// @defgroup cpp_kodi_gui_windows_window_Defs Definitions, structures and enumerators
25/// @ingroup cpp_kodi_gui_windows_window
26/// @brief **Library definition values**\n
27/// Additional values, structures and things that are used in the Window class.
28///
29/// ------------------------------------------------------------------------
30///
31/// @link cpp_kodi_gui_windows_window Go back to normal functions from CWindow@endlink
32///
33
34//==============================================================================
35/// @ingroup cpp_kodi_gui_windows_window_Defs
36/// @brief **Handler for addon-sided processing class**\n
37/// If the callback functions used by the window are not used directly in the
38/// @ref cpp_kodi_gui_windows_window "CWindow" class and are outside of it.
39///
40/// This value here corresponds to a <b>`void*`</b> and returns the address
41/// requested by the add-on for callbacks.
42///
43using ClientHandle = KODI_GUI_CLIENT_HANDLE;
44//------------------------------------------------------------------------------
45
46class CListItem;
47
48//==============================================================================
49/// @addtogroup cpp_kodi_gui_windows_window
50/// @brief @cpp_class{ kodi::gui::CWindow }
51/// **Main window control class**\n
52/// The addon uses its own skin xml file and displays it in Kodi using this class.
53///
54/// The with @ref Window.h "#include <kodi/gui/Window.h>"
55/// included file brings support to create a window or dialog on Kodi.
56///
57/// The add-on has to integrate its own @ref cpp_kodi_gui_windows_window_callbacks "callback functions"
58/// in order to process the necessary user access to its window.
59///
60///
61/// --------------------------------------------------------------------------
62///
63/// **Window header example:**
64/// ~~~~~~~~~~~~~{.xml}
65/// <?xml version="1.0" encoding="UTF-8"?>
66/// <window>
67/// <onload>RunScript(script.foobar)</onload>
68/// <onunload>SetProperty(foo,bar)</onunload>
69/// <defaultcontrol always="false">2</defaultcontrol>
70/// <menucontrol>9000</menucontrol>
71/// <backgroundcolor>0xff00ff00</backgroundcolor>
72/// <views>50,51,509,510</views>
73/// <visible>Window.IsActive(Home)</visible>
74/// <animation effect="fade" time="100">WindowOpen</animation>
75/// <animation effect="slide" end="0,576" time="100">WindowClose</animation>
76/// <zorder>1</zorder>
77/// <coordinates>
78/// <left>40</left>
79/// <top>50</top>
80/// <origin x="100" y="50">Window.IsActive(Home)</origin>
81/// </coordinates>
82/// <previouswindow>MyVideos</previouswindow>
83/// <controls>
84/// <control>
85/// </control>
86/// ....
87/// </controls>
88/// </window>
89/// ~~~~~~~~~~~~~
90///
91/// --------------------------------------------------------------------------
92///
93/// On functions defined input variable <b><tt>controlId</tt> (GUI control identifier)</b>
94/// is the on window.xml defined value behind type added with <tt><b>id="..."</b></tt> and
95/// used to identify for changes there and on callbacks.
96///
97/// ~~~~~~~~~~~~~{.xml}
98/// <control type="label" id="31">
99/// <description>Title Label</description>
100/// ...
101/// </control>
102/// <control type="progress" id="32">
103/// <description>progress control</description>
104/// ...
105/// </control>
106/// ~~~~~~~~~~~~~
107///
108///
109class ATTRIBUTE_HIDDEN CWindow : public CAddonGUIControlBase
110{
111public:
112 //============================================================================
113 /// @ingroup cpp_kodi_gui_windows_window
114 /// @brief Class constructor with needed values for window / dialog.
115 ///
116 /// Creates a new Window class.
117 ///
118 /// @param[in] xmlFilename XML file for the skin
119 /// @param[in] defaultSkin Default skin to use if needed not available
120 /// @param[in] asDialog Use window as dialog if set
121 /// @param[in] isMedia [opt] bool - if False, create a regular window.
122 /// if True, create a mediawindow. (default=false)
123 ///
124 /// @note <b>`isMedia`</b> value as true only usable for windows not for dialogs.
125 ///
126 CWindow(const std::string& xmlFilename,
127 const std::string& defaultSkin,
128 bool asDialog,
129 bool isMedia = false)
130 : CAddonGUIControlBase(nullptr)
131 {
132 m_controlHandle = m_interface->kodi_gui->window->create(
133 m_interface->kodiBase, xmlFilename.c_str(), defaultSkin.c_str(), asDialog, isMedia);
134 if (!m_controlHandle)
135 kodi::Log(ADDON_LOG_FATAL, "kodi::gui::CWindow can't create window class from Kodi !!!");
136 m_interface->kodi_gui->window->set_callbacks(m_interface->kodiBase, m_controlHandle, this,
137 CBOnInit, CBOnFocus, CBOnClick, CBOnAction,
138 CBGetContextButtons, CBOnContextButton);
139 }
140 //----------------------------------------------------------------------------
141
142 //============================================================================
143 /// @ingroup CWindow
144 /// @brief Class destructor.
145 ///
146 ~CWindow() override
147 {
148 if (m_controlHandle)
149 m_interface->kodi_gui->window->destroy(m_interface->kodiBase, m_controlHandle);
150 }
151 //----------------------------------------------------------------------------
152
153 //============================================================================
154 /// @ingroup cpp_kodi_gui_windows_window
155 /// @brief Show this window.
156 ///
157 /// Shows this window by activating it, calling close() after it wil activate
158 /// the current window again.
159 ///
160 /// @note If your Add-On ends this window will be closed to. To show it forever,
161 /// make a loop at the end of your Add-On or use @ref DoModal() instead.
162 ///
163 /// @warning If used must be the class be global present until Kodi becomes
164 /// closed. The creation can be done before "Show" becomes called, but
165 /// not delete class after them.
166 ///
167 /// @return Return true if call and show is successed, if false was something
168 /// failed to get needed skin parts.
169 ///
170 bool Show()
171 {
172 return m_interface->kodi_gui->window->show(m_interface->kodiBase, m_controlHandle);
173 }
174 //----------------------------------------------------------------------------
175
176 //============================================================================
177 /// @ingroup cpp_kodi_gui_windows_window
178 /// @brief Closes this window.
179 ///
180 /// Closes this window by activating the old window.
181 /// @note The window is not deleted with this method.
182 ///
183 void Close() { m_interface->kodi_gui->window->close(m_interface->kodiBase, m_controlHandle); }
184 //----------------------------------------------------------------------------
185
186 //============================================================================
187 /// @ingroup cpp_kodi_gui_windows_window
188 /// @brief Display this window until close() is called.
189 ///
190 void DoModal()
191 {
192 m_interface->kodi_gui->window->do_modal(m_interface->kodiBase, m_controlHandle);
193 }
194 //----------------------------------------------------------------------------
195
196 //============================================================================
197 /// @ingroup cpp_kodi_gui_windows_window
198 /// @brief Gives the control with the supplied focus.
199 ///
200 /// @param[in] controlId On skin defined id of control
201 /// @return Return true if call and focus is successed, if false was something
202 /// failed to get needed skin parts
203 ///
204 bool SetFocusId(int controlId)
205 {
206 return m_interface->kodi_gui->window->set_focus_id(m_interface->kodiBase, m_controlHandle,
207 controlId);
208 }
209 //----------------------------------------------------------------------------
210
211 //============================================================================
212 /// @ingroup cpp_kodi_gui_windows_window
213 /// @brief Returns the id of the control which is focused.
214 ///
215 /// @return Focused control id
216 ///
217 int GetFocusId()
218 {
219 return m_interface->kodi_gui->window->get_focus_id(m_interface->kodiBase, m_controlHandle);
220 }
221 //----------------------------------------------------------------------------
222
223 //============================================================================
224 /// @ingroup cpp_kodi_gui_windows_window
225 /// @brief To set the used label on given control id.
226 ///
227 /// @param[in] controlId Control id where label need to set
228 /// @param[in] label Label to use
229 ///
230 void SetControlLabel(int controlId, const std::string& label)
231 {
232 m_interface->kodi_gui->window->set_control_label(m_interface->kodiBase, m_controlHandle,
233 controlId, label.c_str());
234 }
235 //----------------------------------------------------------------------------
236
237 //============================================================================
238 /// @ingroup cpp_kodi_gui_windows_window
239 /// @brief To set the visibility on given control id.
240 ///
241 /// @param[in] controlId Control id where visibility is changed
242 /// @param[in] visible Boolean value with `true` for visible, `false` for hidden
243 ///
244 void SetControlVisible(int controlId, bool visible)
245 {
246 m_interface->kodi_gui->window->set_control_visible(m_interface->kodiBase, m_controlHandle,
247 controlId, visible);
248 }
249 //----------------------------------------------------------------------------
250
251 //============================================================================
252 /// @ingroup cpp_kodi_gui_windows_window
253 /// @brief To set the selection on given control id.
254 ///
255 /// @param[in] controlId Control id where selection is changed
256 /// @param[in] selected Boolean value with `true` for selected, `false` for not
257 ///
258 void SetControlSelected(int controlId, bool selected)
259 {
260 m_interface->kodi_gui->window->set_control_selected(m_interface->kodiBase, m_controlHandle,
261 controlId, selected);
262 }
263 //----------------------------------------------------------------------------
264
265 //============================================================================
266 /// @ingroup cpp_kodi_gui_windows_window
267 /// @brief Sets a window property, similar to an infolabel.
268 ///
269 /// @param[in] key string - property name.
270 /// @param[in] value string or unicode - value of property.
271 ///
272 /// @note Key is NOT case sensitive. Setting value to an empty string is
273 /// equivalent to clearProperty(key).\n
274 /// You can use the above as keywords for arguments and skip certain
275 /// optional arguments.\n
276 /// Once you use a keyword, all following arguments require the keyword.
277 ///
278 void SetProperty(const std::string& key, const std::string& value)
279 {
280 m_interface->kodi_gui->window->set_property(m_interface->kodiBase, m_controlHandle, key.c_str(),
281 value.c_str());
282 }
283 //----------------------------------------------------------------------------
284
285 //============================================================================
286 /// @ingroup cpp_kodi_gui_windows_window
287 /// @brief Returns a window property as a string, similar to an infolabel.
288 ///
289 /// @param[in] key string - property name.
290 /// @return The property as string (if present)
291 ///
292 /// @note Key is NOT case sensitive. Setting value to an empty string is
293 /// equivalent to clearProperty(key).\n
294 /// You can use the above as keywords for arguments and skip certain
295 /// optional arguments.\n
296 /// Once you use a keyword, all following arguments require the keyword.
297 ///
298 std::string GetProperty(const std::string& key) const
299 {
300 std::string label;
301 char* ret = m_interface->kodi_gui->window->get_property(m_interface->kodiBase, m_controlHandle,
302 key.c_str());
303 if (ret != nullptr)
304 {
305 if (std::strlen(ret))
306 label = ret;
307 m_interface->free_string(m_interface->kodiBase, ret);
308 }
309 return label;
310 }
311 //----------------------------------------------------------------------------
312
313 //============================================================================
314 /// @ingroup cpp_kodi_gui_windows_window
315 /// @brief Sets a window property with integer value
316 ///
317 /// @param[in] key string - property name.
318 /// @param[in] value integer value to set
319 ///
320 void SetPropertyInt(const std::string& key, int value)
321 {
322 m_interface->kodi_gui->window->set_property_int(m_interface->kodiBase, m_controlHandle,
323 key.c_str(), value);
324 }
325 //----------------------------------------------------------------------------
326
327 //============================================================================
328 /// @ingroup cpp_kodi_gui_windows_window
329 /// @brief Returns a window property with integer value
330 ///
331 /// @param[in] key string - property name.
332 /// @return integer value of property
333 ///
334 int GetPropertyInt(const std::string& key) const
335 {
336 return m_interface->kodi_gui->window->get_property_int(m_interface->kodiBase, m_controlHandle,
337 key.c_str());
338 }
339 //----------------------------------------------------------------------------
340
341 //============================================================================
342 /// @ingroup cpp_kodi_gui_windows_window
343 /// @brief Sets a window property with boolean value
344 ///
345 /// @param[in] key string - property name.
346 /// @param[in] value boolean value to set
347 ///
348 void SetPropertyBool(const std::string& key, bool value)
349 {
350 m_interface->kodi_gui->window->set_property_bool(m_interface->kodiBase, m_controlHandle,
351 key.c_str(), value);
352 }
353 //----------------------------------------------------------------------------
354
355 //============================================================================
356 /// @ingroup cpp_kodi_gui_windows_window
357 /// @brief Returns a window property with boolean value
358 ///
359 /// @param[in] key string - property name.
360 /// @return boolean value of property
361 ///
362 bool GetPropertyBool(const std::string& key) const
363 {
364 return m_interface->kodi_gui->window->get_property_bool(m_interface->kodiBase, m_controlHandle,
365 key.c_str());
366 }
367 //----------------------------------------------------------------------------
368
369 //============================================================================
370 /// @ingroup cpp_kodi_gui_windows_window
371 /// @brief Sets a window property with double value
372 ///
373 /// @param[in] key string - property name.
374 /// @param[in] value double value to set
375 ///
376 void SetPropertyDouble(const std::string& key, double value)
377 {
378 m_interface->kodi_gui->window->set_property_double(m_interface->kodiBase, m_controlHandle,
379 key.c_str(), value);
380 }
381 //----------------------------------------------------------------------------
382
383 //============================================================================
384 /// @ingroup cpp_kodi_gui_windows_window
385 /// @brief Returns a window property with double value
386 ///
387 /// @param[in] key string - property name.
388 /// @return double value of property
389 ///
390 double GetPropertyDouble(const std::string& key) const
391 {
392 return m_interface->kodi_gui->window->get_property_double(m_interface->kodiBase,
393 m_controlHandle, key.c_str());
394 }
395 //----------------------------------------------------------------------------
396
397 //============================================================================
398 /// @ingroup cpp_kodi_gui_windows_window
399 /// @brief Remove all present properties from window
400 ///
401 void ClearProperties()
402 {
403 m_interface->kodi_gui->window->clear_properties(m_interface->kodiBase, m_controlHandle);
404 }
405 //----------------------------------------------------------------------------
406
407 //============================================================================
408 /// @ingroup cpp_kodi_gui_windows_window
409 /// @brief Clears the specific window property.
410 ///
411 /// @param[in] key string - property name.
412 ///
413 /// @note Key is NOT case sensitive. Equivalent to SetProperty(key, "")
414 /// You can use the above as keywords for arguments and skip certain
415 /// optional arguments.
416 /// Once you use a keyword, all following arguments require the
417 /// keyword.
418 ///
419 ///
420 ///-----------------------------------------------------------------------
421 ///
422 /// **Example:**
423 /// ~~~~~~~~~~~~~{.cpp}
424 /// ..
425 /// ClearProperty('Category')
426 /// ..
427 /// ~~~~~~~~~~~~~
428 ///
429 void ClearProperty(const std::string& key)
430 {
431 m_interface->kodi_gui->window->clear_property(m_interface->kodiBase, m_controlHandle,
432 key.c_str());
433 }
434 //----------------------------------------------------------------------------
435
436 /// @{
437 //============================================================================
438 /// @ingroup cpp_kodi_gui_windows_window
439 /// @brief Function delete all entries in integrated list.
440 ///
441 void ClearList()
442 {
443 m_interface->kodi_gui->window->clear_item_list(m_interface->kodiBase, m_controlHandle);
444 }
445 //----------------------------------------------------------------------------
446
447 //============================================================================
448 /// @ingroup cpp_kodi_gui_windows_window
449 /// @brief To add a list item in the on window integrated list.
450 ///
451 /// @param[in] item List item to add
452 /// @param[in] itemPosition [opt] The position for item, default is on end
453 ///
454 void AddListItem(std::shared_ptr<CListItem> item, int itemPosition = -1)
455 {
456 m_interface->kodi_gui->window->add_list_item(m_interface->kodiBase, m_controlHandle,
457 item->m_controlHandle, itemPosition);
458 }
459 //----------------------------------------------------------------------------
460
461 //============================================================================
462 /// @ingroup cpp_kodi_gui_windows_window
463 /// @brief To add a list item based upon string in the on window integrated list.
464 ///
465 /// @param[in] item List item to add
466 /// @param[in] itemPosition [opt] The position for item, default is on end
467 ///
468 void AddListItem(const std::string item, int itemPosition = -1)
469 {
470 m_interface->kodi_gui->window->add_list_item(
471 m_interface->kodiBase, m_controlHandle,
472 std::make_shared<kodi::gui::CListItem>(item)->m_controlHandle, itemPosition);
473 }
474 //----------------------------------------------------------------------------
475
476 //============================================================================
477 /// @ingroup cpp_kodi_gui_windows_window
478 /// @brief Remove list item on position.
479 ///
480 /// @param[in] itemPosition List position to remove
481 ///
482 void RemoveListItem(int itemPosition)
483 {
484 m_interface->kodi_gui->window->remove_list_item_from_position(m_interface->kodiBase,
485 m_controlHandle, itemPosition);
486 }
487 //----------------------------------------------------------------------------
488
489 //============================================================================
490 /// @ingroup cpp_kodi_gui_windows_window
491 /// @brief Remove item with given control class from list.
492 ///
493 /// @param[in] item List item control class to remove
494 ///
495 void RemoveListItem(std::shared_ptr<CListItem> item)
496 {
497 m_interface->kodi_gui->window->remove_list_item(m_interface->kodiBase, m_controlHandle,
498 item->m_controlHandle);
499 }
500 //----------------------------------------------------------------------------
501
502 //============================================================================
503 /// @ingroup cpp_kodi_gui_windows_window
504 /// @brief To get list item control class on wanted position.
505 ///
506 /// @param[in] listPos Position from where control is needed
507 /// @return The list item control class or null if not found
508 ///
509 /// @warning Function returns a new generated **CListItem** class!
510 ///
511 std::shared_ptr<CListItem> GetListItem(int listPos)
512 {
513 KODI_GUI_LISTITEM_HANDLE handle = m_interface->kodi_gui->window->get_list_item(
514 m_interface->kodiBase, m_controlHandle, listPos);
515 if (!handle)
516 return std::shared_ptr<CListItem>();
517
518 return std::make_shared<kodi::gui::CListItem>(handle);
519 }
520 //----------------------------------------------------------------------------
521
522 //============================================================================
523 /// @ingroup cpp_kodi_gui_windows_window
524 /// @brief To set position of selected part in list.
525 ///
526 /// @param[in] listPos Position to use
527 ///
528 void SetCurrentListPosition(int listPos)
529 {
530 m_interface->kodi_gui->window->set_current_list_position(m_interface->kodiBase, m_controlHandle,
531 listPos);
532 }
533 //----------------------------------------------------------------------------
534
535 //============================================================================
536 /// @ingroup cpp_kodi_gui_windows_window
537 /// @brief To get current selected position in list
538 ///
539 /// @return Current list position
540 ///
541 int GetCurrentListPosition()
542 {
543 return m_interface->kodi_gui->window->get_current_list_position(m_interface->kodiBase,
544 m_controlHandle);
545 }
546 //----------------------------------------------------------------------------
547
548 //============================================================================
549 /// @ingroup cpp_kodi_gui_windows_window
550 /// @brief To get the amount of entries in the list.
551 ///
552 /// @return Size of in window integrated control class
553 ///
554 int GetListSize()
555 {
556 return m_interface->kodi_gui->window->get_list_size(m_interface->kodiBase, m_controlHandle);
557 }
558 //----------------------------------------------------------------------------
559
560 //============================================================================
561 /// @ingroup cpp_kodi_gui_windows_window
562 /// @brief Sets a container property, similar to an infolabel.
563 ///
564 /// @param[in] key string - property name.
565 /// @param[in] value string or unicode - value of property.
566 ///
567 /// @note Key is NOT case sensitive.\n
568 /// You can use the above as keywords for arguments and skip certain
569 /// optional arguments.\n
570 /// Once you use a keyword, all following arguments require the keyword.
571 ///
572 void SetContainerProperty(const std::string& key, const std::string& value)
573 {
574 m_interface->kodi_gui->window->set_container_property(m_interface->kodiBase, m_controlHandle,
575 key.c_str(), value.c_str());
576 }
577 //----------------------------------------------------------------------------
578
579 //============================================================================
580 /// @ingroup cpp_kodi_gui_windows_window
581 /// @brief Sets the content type of the container.
582 ///
583 /// @param[in] value string or unicode - content value.
584 ///
585 /// __Available content types__
586 /// | Name | Media |
587 /// |:-----------:|:-----------------------------------------|
588 /// | actors | Videos
589 /// | addons | Addons, Music, Pictures, Programs, Videos
590 /// | albums | Music, Videos
591 /// | artists | Music, Videos
592 /// | countries | Music, Videos
593 /// | directors | Videos
594 /// | files | Music, Videos
595 /// | games | Games
596 /// | genres | Music, Videos
597 /// | images | Pictures
598 /// | mixed | Music, Videos
599 /// | movies | Videos
600 /// | Musicvideos | Music, Videos
601 /// | playlists | Music, Videos
602 /// | seasons | Videos
603 /// | sets | Videos
604 /// | songs | Music
605 /// | studios | Music, Videos
606 /// | tags | Music, Videos
607 /// | tvshows | Videos
608 /// | videos | Videos
609 /// | years | Music, Videos
610 ///
611 void SetContainerContent(const std::string& value)
612 {
613 m_interface->kodi_gui->window->set_container_content(m_interface->kodiBase, m_controlHandle,
614 value.c_str());
615 }
616 //----------------------------------------------------------------------------
617
618 //============================================================================
619 /// @ingroup cpp_kodi_gui_windows_window
620 /// @brief Get the id of the currently visible container.
621 ///
622 /// @return currently visible container id
623 ///
624 int GetCurrentContainerId()
625 {
626 return m_interface->kodi_gui->window->get_current_container_id(m_interface->kodiBase,
627 m_controlHandle);
628 }
629 //----------------------------------------------------------------------------
630 /// @}
631
632 //============================================================================
633 /// @ingroup cpp_kodi_gui_windows_window
634 /// @brief To inform Kodi that it need to render region new.
635 ///
636 void MarkDirtyRegion()
637 {
638 return m_interface->kodi_gui->window->mark_dirty_region(m_interface->kodiBase, m_controlHandle);
639 }
640 //----------------------------------------------------------------------------
641
642 //============================================================================
643 /// @defgroup cpp_kodi_gui_windows_window_callbacks Callback functions from Kodi to add-on
644 /// @ingroup cpp_kodi_gui_windows_window
645 /// @{
646 /// @brief <b>GUI window callback functions.</b>\n
647 /// Functions to handle control callbacks from Kodi
648 ///
649 /// ------------------------------------------------------------------------
650 ///
651 /// @link cpp_kodi_gui_windows_window Go back to normal functions from CWindow@endlink
652 //
653
654 //============================================================================
655 /// @ingroup cpp_kodi_gui_windows_window_callbacks
656 /// @brief OnInit method.
657 ///
658 /// @return Return true if initialize was done successful
659 ///
660 ///
661 virtual bool OnInit() { return false; }
662 //----------------------------------------------------------------------------
663
664 //============================================================================
665 /// @ingroup cpp_kodi_gui_windows_window_callbacks
666 /// @brief OnFocus method.
667 ///
668 /// @param[in] controlId GUI control identifier
669 /// @return Return true if focus condition was handled there or false to handle
670 /// them by Kodi itself
671 ///
672 ///
673 virtual bool OnFocus(int controlId) { return false; }
674 //----------------------------------------------------------------------------
675
676 //============================================================================
677 /// @ingroup cpp_kodi_gui_windows_window_callbacks
678 /// @brief OnClick method.
679 ///
680 /// @param[in] controlId GUI control identifier
681 /// @return Return true if click was handled there or false to handle them by
682 /// Kodi itself
683 ///
684 ///
685 virtual bool OnClick(int controlId) { return false; }
686 //----------------------------------------------------------------------------
687
688 //============================================================================
689 /// @ingroup cpp_kodi_gui_windows_window_callbacks
690 /// @brief OnAction method.
691 ///
692 /// @param[in] actionId The action id to perform, see
693 /// @ref kodi_key_action_ids to get list of
694 /// them
695 /// @return Return true if action was handled there
696 /// or false to handle them by Kodi itself
697 ///
698 ///
699 /// This method will receive all actions that the main program will send
700 /// to this window.
701 ///
702 /// @note
703 /// - By default, only the @c ADDON_ACTION_PREVIOUS_MENU and @c ADDON_ACTION_NAV_BACK actions are handled.
704 /// - Overwrite this method to let your code handle all actions.
705 /// - Don't forget to capture @ref ADDON_ACTION_PREVIOUS_MENU or @ref ADDON_ACTION_NAV_BACK, else the user can't close this window.
706 ///
707 ///
708 ///----------------------------------------------------------------------------
709 ///
710 /// **Example:**
711 /// ~~~~~~~~~~~~~{.cpp}
712 /// ..
713 /// // Window used with parent / child way
714 /// bool cYOUR_CLASS::OnAction(ADDON_ACTION actionId)
715 /// {
716 /// switch (action)
717 /// {
718 /// case ADDON_ACTION_PREVIOUS_MENU:
719 /// case ADDON_ACTION_NAV_BACK:
720 /// printf("action recieved: previous");
721 /// Close();
722 /// return true;
723 /// case ADDON_ACTION_SHOW_INFO:
724 /// printf("action recieved: show info");
725 /// break;
726 /// case ADDON_ACTION_STOP:
727 /// printf("action recieved: stop");
728 /// break;
729 /// case ADDON_ACTION_PAUSE:
730 /// printf("action recieved: pause");
731 /// break;
732 /// default:
733 /// break;
734 /// }
735 /// return false;
736 /// }
737 /// ..
738 /// ~~~~~~~~~~~~~
739 ///
740 virtual bool OnAction(ADDON_ACTION actionId)
741 {
742 switch (actionId)
743 {
744 case ADDON_ACTION_PREVIOUS_MENU:
745 case ADDON_ACTION_NAV_BACK:
746 Close();
747 return true;
748 default:
749 break;
750 }
751 return false;
752 }
753 //----------------------------------------------------------------------------
754
755 //============================================================================
756 /// @ingroup cpp_kodi_gui_windows_window_callbacks
757 /// @brief Get context menu buttons for list entry.
758 ///
759 /// @param[in] itemNumber Selected list item entry
760 /// @param[in] buttons List where context menus becomes added with his
761 /// identifier and name
762 ///
763 virtual void GetContextButtons(int itemNumber,
764 std::vector<std::pair<unsigned int, std::string>>& buttons)
765 {
766 }
767 //----------------------------------------------------------------------------
768
769 //============================================================================
770 /// @ingroup cpp_kodi_gui_windows_window_callbacks
771 /// @brief Called after selection in context menu.
772 ///
773 /// @param[in] itemNumber Selected list item entry
774 /// @param[in] button The pressed button id
775 /// @return true if handled, otherwise false
776 ///
777 virtual bool OnContextButton(int itemNumber, unsigned int button) { return false; }
778 //----------------------------------------------------------------------------
779
780 //============================================================================
781 /// @ingroup cpp_kodi_gui_windows_window_callbacks
782 /// @brief **Set independent callbacks**
783 ///
784 /// If the class is used independent (with "new CWindow") and
785 /// not as parent (with \"cCLASS_own : public @ref cpp_kodi_gui_windows_window "kodi::gui::CWindow"\") from own must be the
786 /// callback from Kodi to add-on overdriven with own functions!
787 ///
788 /// @param[in] cbhdl The pointer to own handle data structure / class
789 /// @param[in] CBOnInit Own defined window init function
790 /// @param[in] CBOnFocus Own defined focus function
791 /// @param[in] CBOnClick Own defined click function
792 /// @param[in] CBOnAction Own defined action function
793 /// @param[in] CBGetContextButtons [opt] To get context menu entries for
794 /// lists function
795 /// @param[in] CBOnContextButton [opt] Used context menu entry function
796 ///
797 ///
798 ///----------------------------------------------------------------------------
799 ///
800 /// **Example:**
801 /// ~~~~~~~~~~~~~{.cpp}
802 /// ...
803 ///
804 /// bool OnInit(kodi::gui::ClientHandle cbhdl)
805 /// {
806 /// ...
807 /// return true;
808 /// }
809 ///
810 /// bool OnFocus(kodi::gui::ClientHandle cbhdl, int controlId)
811 /// {
812 /// ...
813 /// return true;
814 /// }
815 ///
816 /// bool OnClick(kodi::gui::ClientHandle cbhdl, int controlId)
817 /// {
818 /// ...
819 /// return true;
820 /// }
821 ///
822 /// bool OnAction(kodi::gui::ClientHandle cbhdl, ADDON_ACTION actionId)
823 /// {
824 /// ...
825 /// return true;
826 /// }
827 ///
828 /// ...
829 /// // Somewhere where you create the window
830 /// CWindow myWindow = new CWindow;
831 /// myWindow->SetIndependentCallbacks(myWindow, OnInit, OnFocus, OnClick, OnAction);
832 /// ...
833 /// ~~~~~~~~~~~~~
834 ///
835 void SetIndependentCallbacks(kodi::gui::ClientHandle cbhdl,
836 bool (*CBOnInit)(kodi::gui::ClientHandle cbhdl),
837 bool (*CBOnFocus)(kodi::gui::ClientHandle cbhdl, int controlId),
838 bool (*CBOnClick)(kodi::gui::ClientHandle cbhdl, int controlId),
839 bool (*CBOnAction)(kodi::gui::ClientHandle cbhdl,
840 ADDON_ACTION actionId),
841 void (*CBGetContextButtons)(kodi::gui::ClientHandle cbhdl,
842 int itemNumber,
843 gui_context_menu_pair* buttons,
844 unsigned int* size) = nullptr,
845 bool (*CBOnContextButton)(kodi::gui::ClientHandle cbhdl,
846 int itemNumber,
847 unsigned int button) = nullptr)
848 {
849 if (!cbhdl || !CBOnInit || !CBOnFocus || !CBOnClick || !CBOnAction)
850 {
851 kodi::Log(ADDON_LOG_FATAL, "kodi::gui::CWindow::%s called with nullptr !!!", __FUNCTION__);
852 return;
853 }
854
855 m_interface->kodi_gui->window->set_callbacks(m_interface->kodiBase, m_controlHandle, cbhdl,
856 CBOnInit, CBOnFocus, CBOnClick, CBOnAction,
857 CBGetContextButtons, CBOnContextButton);
858 }
859 //----------------------------------------------------------------------------
860 /// @}
861
862private:
863 static bool CBOnInit(KODI_GUI_CLIENT_HANDLE cbhdl)
864 {
865 return static_cast<CWindow*>(cbhdl)->OnInit();
866 }
867
868 static bool CBOnFocus(KODI_GUI_CLIENT_HANDLE cbhdl, int controlId)
869 {
870 return static_cast<CWindow*>(cbhdl)->OnFocus(controlId);
871 }
872
873 static bool CBOnClick(KODI_GUI_CLIENT_HANDLE cbhdl, int controlId)
874 {
875 return static_cast<CWindow*>(cbhdl)->OnClick(controlId);
876 }
877
878 static bool CBOnAction(KODI_GUI_CLIENT_HANDLE cbhdl, ADDON_ACTION actionId)
879 {
880 return static_cast<CWindow*>(cbhdl)->OnAction(actionId);
881 }
882
883 static void CBGetContextButtons(KODI_GUI_CLIENT_HANDLE cbhdl,
884 int itemNumber,
885 gui_context_menu_pair* buttons,
886 unsigned int* size)
887 {
888 std::vector<std::pair<unsigned int, std::string>> buttonList;
889 static_cast<CWindow*>(cbhdl)->GetContextButtons(itemNumber, buttonList);
890 if (!buttonList.empty())
891 {
892 unsigned int presentSize = static_cast<unsigned int>(buttonList.size());
893 if (presentSize > *size)
894 kodi::Log(ADDON_LOG_WARNING, "GetContextButtons: More as allowed '%i' entries present!",
895 *size);
896 else
897 *size = presentSize;
898 for (unsigned int i = 0; i < *size; ++i)
899 {
900 buttons[i].id = buttonList[i].first;
901 strncpy(buttons[i].name, buttonList[i].second.c_str(), ADDON_MAX_CONTEXT_ENTRY_NAME_LENGTH);
902 }
903 }
904 }
905
906 static bool CBOnContextButton(KODI_GUI_CLIENT_HANDLE cbhdl, int itemNumber, unsigned int button)
907 {
908 return static_cast<CWindow*>(cbhdl)->OnContextButton(itemNumber, button);
909 }
910};
911
912} /* namespace gui */
913} /* namespace kodi */
914
915#endif /* __cplusplus */
diff --git a/xbmc/addons/kodi-dev-kit/include/kodi/gui/controls/Button.h b/xbmc/addons/kodi-dev-kit/include/kodi/gui/controls/Button.h
new file mode 100644
index 0000000..873a549
--- /dev/null
+++ b/xbmc/addons/kodi-dev-kit/include/kodi/gui/controls/Button.h
@@ -0,0 +1,166 @@
1/*
2 * Copyright (C) 2005-2018 Team Kodi
3 * This file is part of Kodi - https://kodi.tv
4 *
5 * SPDX-License-Identifier: GPL-2.0-or-later
6 * See LICENSES/README.md for more information.
7 */
8
9#pragma once
10
11#include "../../c-api/gui/controls/button.h"
12#include "../Window.h"
13
14#ifdef __cplusplus
15
16namespace kodi
17{
18namespace gui
19{
20namespace controls
21{
22
23//==============================================================================
24/// @defgroup cpp_kodi_gui_windows_controls_CButton Control Button
25/// @ingroup cpp_kodi_gui_windows_controls
26/// @brief @cpp_class{ kodi::gui::controls::CButton }
27/// **Standard push button control for window**\n
28/// The button control is used for creating push buttons in Kodi.
29///
30/// You can choose the position, size, and look of the button, as well as
31/// choosing what action(s) should be performed when pushed.
32///
33/// It has the header @ref Button.h "#include <kodi/gui/controls/Button.h>"
34/// be included to enjoy it.
35///
36/// Here you find the needed skin part for a @ref skin_Button_control "button control"
37///
38/// @note The call of the control is only possible from the corresponding
39/// window as its class and identification number is required.
40///
41class ATTRIBUTE_HIDDEN CButton : public CAddonGUIControlBase
42{
43public:
44 //============================================================================
45 /// @ingroup cpp_kodi_gui_windows_controls_CButton
46 /// @brief Construct a new control.
47 ///
48 /// @param[in] window Related window control class
49 /// @param[in] controlId Used skin xml control id
50 ///
51 CButton(CWindow* window, int controlId) : CAddonGUIControlBase(window)
52 {
53 m_controlHandle = m_interface->kodi_gui->window->get_control_button(
54 m_interface->kodiBase, m_Window->GetControlHandle(), controlId);
55 if (!m_controlHandle)
56 kodi::Log(ADDON_LOG_FATAL, "kodi::gui::CButton can't create control class from Kodi !!!");
57 }
58 //----------------------------------------------------------------------------
59
60 //============================================================================
61 /// @ingroup cpp_kodi_gui_windows_controls_CButton
62 /// @brief Destructor.
63 ///
64 ~CButton() override = default;
65 //----------------------------------------------------------------------------
66
67 //============================================================================
68 /// @ingroup cpp_kodi_gui_windows_controls_CButton
69 /// @brief Set the control on window to visible.
70 ///
71 /// @param[in] visible If true visible, otherwise hidden
72 ///
73 void SetVisible(bool visible)
74 {
75 m_interface->kodi_gui->control_button->set_visible(m_interface->kodiBase, m_controlHandle,
76 visible);
77 }
78 //----------------------------------------------------------------------------
79
80 //============================================================================
81 /// @ingroup cpp_kodi_gui_windows_controls_CButton
82 /// @brief Set's the control's enabled/disabled state.
83 ///
84 /// @param[in] enabled If true enabled, otherwise disabled
85 ///
86 void SetEnabled(bool enabled)
87 {
88 m_interface->kodi_gui->control_button->set_enabled(m_interface->kodiBase, m_controlHandle,
89 enabled);
90 }
91 //----------------------------------------------------------------------------
92
93 //============================================================================
94 /// @ingroup cpp_kodi_gui_windows_controls_CButton
95 /// @brief To set the text string on button.
96 ///
97 /// @param[in] label Text to show
98 ///
99 void SetLabel(const std::string& label)
100 {
101 m_interface->kodi_gui->control_button->set_label(m_interface->kodiBase, m_controlHandle,
102 label.c_str());
103 }
104 //----------------------------------------------------------------------------
105
106 //============================================================================
107 /// @ingroup cpp_kodi_gui_windows_controls_CButton
108 /// @brief Get the used text from button.
109 ///
110 /// @return Text shown
111 ///
112 std::string GetLabel() const
113 {
114 std::string label;
115 char* ret =
116 m_interface->kodi_gui->control_button->get_label(m_interface->kodiBase, m_controlHandle);
117 if (ret != nullptr)
118 {
119 if (std::strlen(ret))
120 label = ret;
121 m_interface->free_string(m_interface->kodiBase, ret);
122 }
123 return label;
124 }
125 //----------------------------------------------------------------------------
126
127 //============================================================================
128 /// @ingroup cpp_kodi_gui_windows_controls_CButton
129 /// @brief If two labels are used for button becomes it set with them.
130 ///
131 /// @param[in] label Text for second label
132 ///
133 void SetLabel2(const std::string& label)
134 {
135 m_interface->kodi_gui->control_button->set_label2(m_interface->kodiBase, m_controlHandle,
136 label.c_str());
137 }
138 //----------------------------------------------------------------------------
139
140 //============================================================================
141 /// @ingroup cpp_kodi_gui_windows_controls_CButton
142 /// @brief Get the second label if present.
143 ///
144 /// @return Second label
145 ///
146 std::string GetLabel2() const
147 {
148 std::string label;
149 char* ret =
150 m_interface->kodi_gui->control_button->get_label2(m_interface->kodiBase, m_controlHandle);
151 if (ret != nullptr)
152 {
153 if (std::strlen(ret))
154 label = ret;
155 m_interface->free_string(m_interface->kodiBase, ret);
156 }
157 return label;
158 }
159 //----------------------------------------------------------------------------
160};
161
162} /* namespace controls */
163} /* namespace gui */
164} /* namespace kodi */
165
166#endif /* __cplusplus */
diff --git a/xbmc/addons/kodi-dev-kit/include/kodi/gui/controls/CMakeLists.txt b/xbmc/addons/kodi-dev-kit/include/kodi/gui/controls/CMakeLists.txt
new file mode 100644
index 0000000..3fdab01
--- /dev/null
+++ b/xbmc/addons/kodi-dev-kit/include/kodi/gui/controls/CMakeLists.txt
@@ -0,0 +1,16 @@
1set(HEADERS Button.h
2 Edit.h
3 FadeLabel.h
4 Image.h
5 Label.h
6 Progress.h
7 RadioButton.h
8 Rendering.h
9 SettingsSlider.h
10 Slider.h
11 Spin.h
12 TextBox.h)
13
14if(NOT ENABLE_STATIC_LIBS)
15 core_add_library(addons_kodi-dev-kit_include_kodi_gui_controls)
16endif()
diff --git a/xbmc/addons/kodi-dev-kit/include/kodi/gui/controls/Edit.h b/xbmc/addons/kodi-dev-kit/include/kodi/gui/controls/Edit.h
new file mode 100644
index 0000000..00c6231
--- /dev/null
+++ b/xbmc/addons/kodi-dev-kit/include/kodi/gui/controls/Edit.h
@@ -0,0 +1,217 @@
1/*
2 * Copyright (C) 2005-2018 Team Kodi
3 * This file is part of Kodi - https://kodi.tv
4 *
5 * SPDX-License-Identifier: GPL-2.0-or-later
6 * See LICENSES/README.md for more information.
7 */
8
9#pragma once
10
11#include "../../c-api/gui/controls/edit.h"
12#include "../Window.h"
13
14#ifdef __cplusplus
15
16namespace kodi
17{
18namespace gui
19{
20namespace controls
21{
22
23//==============================================================================
24/// @defgroup cpp_kodi_gui_windows_controls_CEdit Control Edit
25/// @ingroup cpp_kodi_gui_windows_controls
26/// @brief @cpp_class{ kodi::gui::controls::CEdit }
27/// **Editable window text control used as an input control for the osd keyboard
28/// and other input fields**\n
29/// The edit control allows a user to input text in Kodi.
30///
31/// You can choose the font, size, colour, location and header of the text to be
32/// displayed.
33///
34/// It has the header @ref Edit.h "#include <kodi/gui/controls/Edit.h>"
35/// be included to enjoy it.
36///
37/// Here you find the needed skin partfor a @ref skin_Edit_control "edit control".
38///
39/// @note The call of the control is only possible from the corresponding
40/// window as its class and identification number is required.
41///
42
43//==============================================================================
44// see gui/definition.h for use of group "cpp_kodi_gui_windows_controls_CEdit_Defs"
45///
46/// @defgroup cpp_kodi_gui_windows_controls_CEdit_Defs Definitions, structures and enumerators
47/// @ingroup cpp_kodi_gui_windows_controls_CEdit
48/// @brief **Library definition values**
49///
50
51class ATTRIBUTE_HIDDEN CEdit : public CAddonGUIControlBase
52{
53public:
54 //============================================================================
55 /// @ingroup cpp_kodi_gui_windows_controls_CEdit
56 /// @brief Construct a new control.
57 ///
58 /// @param[in] window Related window control class
59 /// @param[in] controlId Used skin xml control id
60 ///
61 CEdit(CWindow* window, int controlId) : CAddonGUIControlBase(window)
62 {
63 m_controlHandle = m_interface->kodi_gui->window->get_control_edit(
64 m_interface->kodiBase, m_Window->GetControlHandle(), controlId);
65 if (!m_controlHandle)
66 kodi::Log(ADDON_LOG_FATAL,
67 "kodi::gui::control::CEdit can't create control class from Kodi !!!");
68 }
69 //----------------------------------------------------------------------------
70
71 //============================================================================
72 /// @ingroup cpp_kodi_gui_windows_controls_CEdit
73 /// @brief Destructor.
74 ///
75 ~CEdit() override = default;
76 //----------------------------------------------------------------------------
77
78 //============================================================================
79 /// @ingroup cpp_kodi_gui_windows_controls_CEdit
80 /// @brief Set the control on window to visible.
81 ///
82 /// @param[in] visible If true visible, otherwise hidden
83 ///
84 void SetVisible(bool visible)
85 {
86 m_interface->kodi_gui->control_edit->set_visible(m_interface->kodiBase, m_controlHandle,
87 visible);
88 }
89 //----------------------------------------------------------------------------
90
91 //============================================================================
92 /// @ingroup cpp_kodi_gui_windows_controls_CEdit
93 /// @brief Set's the control's enabled/disabled state.
94 ///
95 /// @param[in] enabled If true enabled, otherwise disabled
96 ///
97 void SetEnabled(bool enabled)
98 {
99 m_interface->kodi_gui->control_edit->set_enabled(m_interface->kodiBase, m_controlHandle,
100 enabled);
101 }
102 //----------------------------------------------------------------------------
103
104 //============================================================================
105 /// @ingroup cpp_kodi_gui_windows_controls_CEdit
106 /// @brief To set the text string on edit control.
107 ///
108 /// @param[in] label Text to show
109 ///
110 void SetLabel(const std::string& label)
111 {
112 m_interface->kodi_gui->control_edit->set_label(m_interface->kodiBase, m_controlHandle,
113 label.c_str());
114 }
115 //----------------------------------------------------------------------------
116
117 //============================================================================
118 /// @ingroup cpp_kodi_gui_windows_controls_CEdit
119 /// @brief Returns the text heading for this edit control.
120 ///
121 /// @return Heading text
122 ///
123 std::string GetLabel() const
124 {
125 std::string label;
126 char* ret =
127 m_interface->kodi_gui->control_edit->get_label(m_interface->kodiBase, m_controlHandle);
128 if (ret != nullptr)
129 {
130 if (std::strlen(ret))
131 label = ret;
132 m_interface->free_string(m_interface->kodiBase, ret);
133 }
134 return label;
135 }
136 //----------------------------------------------------------------------------
137
138 //============================================================================
139 /// @ingroup cpp_kodi_gui_windows_controls_CEdit
140 /// @brief Set's text heading for this edit control.
141 ///
142 /// @param[in] text string or unicode - text string.
143 ///
144 void SetText(const std::string& text)
145 {
146 m_interface->kodi_gui->control_edit->set_text(m_interface->kodiBase, m_controlHandle,
147 text.c_str());
148 }
149 //----------------------------------------------------------------------------
150
151 //============================================================================
152 /// @ingroup cpp_kodi_gui_windows_controls_CEdit
153 /// @brief Returns the text value for this edit control.
154 ///
155 /// @return Text value of control
156 ///
157 std::string GetText() const
158 {
159 std::string text;
160 char* ret =
161 m_interface->kodi_gui->control_edit->get_text(m_interface->kodiBase, m_controlHandle);
162 if (ret != nullptr)
163 {
164 if (std::strlen(ret))
165 text = ret;
166 m_interface->free_string(m_interface->kodiBase, ret);
167 }
168 return text;
169 }
170 //----------------------------------------------------------------------------
171
172 //============================================================================
173 /// @ingroup cpp_kodi_gui_windows_controls_CEdit
174 /// @brief Set the cursor position on text.
175 ///
176 /// @param[in] position The position to set
177 ///
178 void SetCursorPosition(unsigned int position)
179 {
180 m_interface->kodi_gui->control_edit->set_cursor_position(m_interface->kodiBase, m_controlHandle,
181 position);
182 }
183 //----------------------------------------------------------------------------
184
185 //============================================================================
186 /// @ingroup cpp_kodi_gui_windows_controls_CEdit
187 /// @brief To get current cursor position on text field.
188 ///
189 /// @return The current cursor position
190 ///
191 unsigned int GetCursorPosition()
192 {
193 return m_interface->kodi_gui->control_edit->get_cursor_position(m_interface->kodiBase,
194 m_controlHandle);
195 }
196 //----------------------------------------------------------------------------
197
198 //============================================================================
199 /// @ingroup cpp_kodi_gui_windows_controls_CEdit
200 /// @brief To set field input type which are defined on @ref AddonGUIInputType.
201 ///
202 /// @param[in] type The @ref AddonGUIInputType "Add-on input type" to use
203 /// @param[in] heading The heading text for related keyboard dialog
204 ///
205 void SetInputType(AddonGUIInputType type, const std::string& heading)
206 {
207 m_interface->kodi_gui->control_edit->set_input_type(m_interface->kodiBase, m_controlHandle,
208 static_cast<int>(type), heading.c_str());
209 }
210 //----------------------------------------------------------------------------
211};
212
213} /* namespace controls */
214} /* namespace gui */
215} /* namespace kodi */
216
217#endif /* __cplusplus */
diff --git a/xbmc/addons/kodi-dev-kit/include/kodi/gui/controls/FadeLabel.h b/xbmc/addons/kodi-dev-kit/include/kodi/gui/controls/FadeLabel.h
new file mode 100644
index 0000000..01847fb
--- /dev/null
+++ b/xbmc/addons/kodi-dev-kit/include/kodi/gui/controls/FadeLabel.h
@@ -0,0 +1,148 @@
1/*
2 * Copyright (C) 2005-2018 Team Kodi
3 * This file is part of Kodi - https://kodi.tv
4 *
5 * SPDX-License-Identifier: GPL-2.0-or-later
6 * See LICENSES/README.md for more information.
7 */
8
9#pragma once
10
11#include "../../c-api/gui/controls/fade_label.h"
12#include "../Window.h"
13
14#ifdef __cplusplus
15
16namespace kodi
17{
18namespace gui
19{
20namespace controls
21{
22
23//==============================================================================
24/// @defgroup cpp_kodi_gui_windows_controls_CFadeLabel Control Fade Label
25/// @ingroup cpp_kodi_gui_windows_controls
26/// @brief @cpp_class{ kodi::gui::controls::CFadeLabel }
27/// **Window control used to show multiple pieces of text in the same position,
28/// by fading from one to the other**\n
29/// The fade label control is used for displaying multiple pieces of text in
30/// the same space in Kodi.
31///
32/// You can choose the font, size, colour, location and contents of the text to
33/// be displayed. The first piece of information to display fades in over 50
34/// frames, then scrolls off to the left. Once it is finished scrolling off
35/// screen, the second piece of information fades in and the process repeats.
36/// A fade label control is not supported in a list container.
37///
38/// It has the header @ref FadeLabel.h "#include <kodi/gui/controls/FadeLabel.h>"
39/// be included to enjoy it.
40///
41/// Here you find the needed skin part for a @ref Fade_Label_Control "fade label control".
42///
43/// @note The call of the control is only possible from the corresponding
44/// window as its class and identification number is required.
45///
46class ATTRIBUTE_HIDDEN CFadeLabel : public CAddonGUIControlBase
47{
48public:
49 //============================================================================
50 /// @ingroup cpp_kodi_gui_windows_controls_CFadeLabel
51 /// @brief Construct a new control.
52 ///
53 /// @param[in] window Related window control class
54 /// @param[in] controlId Used skin xml control id
55 ///
56 CFadeLabel(CWindow* window, int controlId) : CAddonGUIControlBase(window)
57 {
58 m_controlHandle = m_interface->kodi_gui->window->get_control_fade_label(
59 m_interface->kodiBase, m_Window->GetControlHandle(), controlId);
60 if (!m_controlHandle)
61 kodi::Log(ADDON_LOG_FATAL,
62 "kodi::gui::controls::CFadeLabel can't create control class from Kodi !!!");
63 }
64 //----------------------------------------------------------------------------
65
66 //============================================================================
67 /// @ingroup cpp_kodi_gui_windows_controls_CFadeLabel
68 /// @brief Destructor.
69 ///
70 ~CFadeLabel() override = default;
71 //----------------------------------------------------------------------------
72
73 //============================================================================
74 /// @ingroup cpp_kodi_gui_windows_controls_CFadeLabel
75 /// @brief Set the control on window to visible.
76 ///
77 /// @param[in] visible If true visible, otherwise hidden
78 ///
79 void SetVisible(bool visible)
80 {
81 m_interface->kodi_gui->control_fade_label->set_visible(m_interface->kodiBase, m_controlHandle,
82 visible);
83 }
84 //----------------------------------------------------------------------------
85
86 //============================================================================
87 /// @ingroup cpp_kodi_gui_windows_controls_CFadeLabel
88 /// @brief To add additional text string on fade label.
89 ///
90 /// @param[in] label Text to show
91 ///
92 void AddLabel(const std::string& label)
93 {
94 m_interface->kodi_gui->control_fade_label->add_label(m_interface->kodiBase, m_controlHandle,
95 label.c_str());
96 }
97 //----------------------------------------------------------------------------
98
99 //============================================================================
100 /// @ingroup cpp_kodi_gui_windows_controls_CFadeLabel
101 /// @brief Get the used text from button.
102 ///
103 /// @return Text shown
104 ///
105 std::string GetLabel() const
106 {
107 std::string label;
108 char* ret = m_interface->kodi_gui->control_fade_label->get_label(m_interface->kodiBase,
109 m_controlHandle);
110 if (ret != nullptr)
111 {
112 if (std::strlen(ret))
113 label = ret;
114 m_interface->free_string(m_interface->kodiBase, ret);
115 }
116 return label;
117 }
118 //----------------------------------------------------------------------------
119
120 //============================================================================
121 /// @ingroup cpp_kodi_gui_windows_controls_CFadeLabel
122 /// @brief To enable or disable scrolling on fade label.
123 ///
124 /// @param[in] scroll To enable scrolling set to true, otherwise is disabled
125 ///
126 void SetScrolling(bool scroll)
127 {
128 m_interface->kodi_gui->control_fade_label->set_scrolling(m_interface->kodiBase, m_controlHandle,
129 scroll);
130 }
131 //----------------------------------------------------------------------------
132
133 //============================================================================
134 /// @ingroup cpp_kodi_gui_windows_controls_CFadeLabel
135 /// @brief To reset al inserted labels.
136 ///
137 void Reset()
138 {
139 m_interface->kodi_gui->control_fade_label->reset(m_interface->kodiBase, m_controlHandle);
140 }
141 //----------------------------------------------------------------------------
142};
143
144} /* namespace controls */
145} /* namespace gui */
146} /* namespace kodi */
147
148#endif /* __cplusplus */
diff --git a/xbmc/addons/kodi-dev-kit/include/kodi/gui/controls/Image.h b/xbmc/addons/kodi-dev-kit/include/kodi/gui/controls/Image.h
new file mode 100644
index 0000000..9dc493e
--- /dev/null
+++ b/xbmc/addons/kodi-dev-kit/include/kodi/gui/controls/Image.h
@@ -0,0 +1,112 @@
1/*
2 * Copyright (C) 2005-2018 Team Kodi
3 * This file is part of Kodi - https://kodi.tv
4 *
5 * SPDX-License-Identifier: GPL-2.0-or-later
6 * See LICENSES/README.md for more information.
7 */
8
9#pragma once
10
11#include "../../c-api/gui/controls/image.h"
12#include "../Window.h"
13
14#ifdef __cplusplus
15
16namespace kodi
17{
18namespace gui
19{
20namespace controls
21{
22
23//============================================================================
24/// @defgroup cpp_kodi_gui_windows_controls_CImage Control Image
25/// @ingroup cpp_kodi_gui_windows_controls
26/// @brief @cpp_class{ kodi::gui::controls::CImage }
27/// **Window control used to show an image.**\n
28/// The image control is used for displaying images in Kodi. You can choose
29/// the position, size, transparency and contents of the image to be displayed.
30///
31/// It has the header @ref Image.h "#include <kodi/gui/controls/Image.h>"
32/// be included to enjoy it.
33///
34/// Here you find the needed skin part for a @ref Image_Control "image control".
35///
36/// @note The call of the control is only possible from the corresponding
37/// window as its class and identification number is required.
38///
39class ATTRIBUTE_HIDDEN CImage : public CAddonGUIControlBase
40{
41public:
42 //==========================================================================
43 /// @ingroup cpp_kodi_gui_windows_controls_CImage
44 /// @brief Construct a new control.
45 ///
46 /// @param[in] window Related window control class
47 /// @param[in] controlId Used skin xml control id
48 ///
49 CImage(CWindow* window, int controlId) : CAddonGUIControlBase(window)
50 {
51 m_controlHandle = m_interface->kodi_gui->window->get_control_image(
52 m_interface->kodiBase, m_Window->GetControlHandle(), controlId);
53 if (!m_controlHandle)
54 kodi::Log(ADDON_LOG_FATAL,
55 "kodi::gui::controls::CImage can't create control class from Kodi !!!");
56 }
57 //--------------------------------------------------------------------------
58
59 //==========================================================================
60 /// @ingroup cpp_kodi_gui_windows_controls_CImage
61 /// @brief Destructor.
62 ///
63 ~CImage() override = default;
64 //--------------------------------------------------------------------------
65
66 //==========================================================================
67 /// @ingroup cpp_kodi_gui_windows_controls_CImage
68 /// @brief Set the control on window to visible.
69 ///
70 /// @param[in] visible If true visible, otherwise hidden
71 ///
72 void SetVisible(bool visible)
73 {
74 m_interface->kodi_gui->control_image->set_visible(m_interface->kodiBase, m_controlHandle,
75 visible);
76 }
77 //--------------------------------------------------------------------------
78
79 //==========================================================================
80 /// @ingroup cpp_kodi_gui_windows_controls_CImage
81 /// @brief To set the filename used on image control.
82 ///
83 /// @param[in] filename Image file to use
84 /// @param[in] useCache To define storage of image, default is in cache, if
85 /// false becomes it loaded always on changes again
86 ///
87 void SetFileName(const std::string& filename, bool useCache = true)
88 {
89 m_interface->kodi_gui->control_image->set_filename(m_interface->kodiBase, m_controlHandle,
90 filename.c_str(), useCache);
91 }
92 //--------------------------------------------------------------------------
93
94 //==========================================================================
95 /// @ingroup cpp_kodi_gui_windows_controls_CImage
96 /// @brief To set set the diffuse color on image.
97 ///
98 /// @param[in] colorDiffuse Color to use for diffuse
99 ///
100 void SetColorDiffuse(uint32_t colorDiffuse)
101 {
102 m_interface->kodi_gui->control_image->set_color_diffuse(m_interface->kodiBase, m_controlHandle,
103 colorDiffuse);
104 }
105 //--------------------------------------------------------------------------
106};
107
108} /* namespace controls */
109} /* namespace gui */
110} /* namespace kodi */
111
112#endif /* __cplusplus */
diff --git a/xbmc/addons/kodi-dev-kit/include/kodi/gui/controls/Label.h b/xbmc/addons/kodi-dev-kit/include/kodi/gui/controls/Label.h
new file mode 100644
index 0000000..d10b85f
--- /dev/null
+++ b/xbmc/addons/kodi-dev-kit/include/kodi/gui/controls/Label.h
@@ -0,0 +1,118 @@
1/*
2 * Copyright (C) 2005-2018 Team Kodi
3 * This file is part of Kodi - https://kodi.tv
4 *
5 * SPDX-License-Identifier: GPL-2.0-or-later
6 * See LICENSES/README.md for more information.
7 */
8
9#pragma once
10
11#include "../../c-api/gui/controls/label.h"
12#include "../Window.h"
13
14#ifdef __cplusplus
15
16namespace kodi
17{
18namespace gui
19{
20namespace controls
21{
22
23//==============================================================================
24/// @defgroup cpp_kodi_gui_windows_controls_CLabel Control Label
25/// @ingroup cpp_kodi_gui_windows_controls
26/// @brief @cpp_class{ kodi::gui::controls::CLabel }
27/// **Window control used to show some lines of text**\n
28/// The label control is used for displaying text in Kodi. You can choose
29/// the font, size, colour, location and contents of the text to be displayed.
30///
31/// It has the header @ref Label.h "#include <kodi/gui/controls/Label.h>"
32/// be included to enjoy it.
33///
34/// Here you find the needed skin part for a @ref Label_Control "label control".
35///
36/// @note The call of the control is only possible from the corresponding
37/// window as its class and identification number is required.
38///
39class ATTRIBUTE_HIDDEN CLabel : public CAddonGUIControlBase
40{
41public:
42 //============================================================================
43 /// @ingroup cpp_kodi_gui_windows_controls_CLabel
44 /// @brief Construct a new control.
45 ///
46 /// @param[in] window Related window control class
47 /// @param[in] controlId Used skin xml control id
48 ///
49 CLabel(CWindow* window, int controlId) : CAddonGUIControlBase(window)
50 {
51 m_controlHandle = m_interface->kodi_gui->window->get_control_label(
52 m_interface->kodiBase, m_Window->GetControlHandle(), controlId);
53 if (!m_controlHandle)
54 kodi::Log(ADDON_LOG_FATAL,
55 "kodi::gui::controls::CLabel can't create control class from Kodi !!!");
56 }
57 //----------------------------------------------------------------------------
58
59 //============================================================================
60 /// @ingroup cpp_kodi_gui_windows_controls_CLabel
61 /// @brief Destructor.
62 ///
63 ~CLabel() override = default;
64 //----------------------------------------------------------------------------
65
66 //============================================================================
67 /// @ingroup cpp_kodi_gui_windows_controls_CLabel
68 /// @brief Set the control on window to visible.
69 ///
70 /// @param[in] visible If true visible, otherwise hidden
71 ///
72 void SetVisible(bool visible)
73 {
74 m_interface->kodi_gui->control_label->set_visible(m_interface->kodiBase, m_controlHandle,
75 visible);
76 }
77 //----------------------------------------------------------------------------
78
79 //============================================================================
80 /// @ingroup cpp_kodi_gui_windows_controls_CLabel
81 /// @brief To set the text string on label.
82 ///
83 /// @param[in] text Text to show
84 ///
85 void SetLabel(const std::string& text)
86 {
87 m_interface->kodi_gui->control_label->set_label(m_interface->kodiBase, m_controlHandle,
88 text.c_str());
89 }
90 //----------------------------------------------------------------------------
91
92 //============================================================================
93 /// @ingroup cpp_kodi_gui_windows_controls_CLabel
94 /// @brief Get the used text from control.
95 ///
96 /// @return Used text on label control
97 ///
98 std::string GetLabel() const
99 {
100 std::string label;
101 char* ret =
102 m_interface->kodi_gui->control_label->get_label(m_interface->kodiBase, m_controlHandle);
103 if (ret != nullptr)
104 {
105 if (std::strlen(ret))
106 label = ret;
107 m_interface->free_string(m_interface->kodiBase, ret);
108 }
109 return label;
110 }
111 //----------------------------------------------------------------------------
112};
113
114} /* namespace controls */
115} /* namespace gui */
116} /* namespace kodi */
117
118#endif /* __cplusplus */
diff --git a/xbmc/addons/kodi-dev-kit/include/kodi/gui/controls/Progress.h b/xbmc/addons/kodi-dev-kit/include/kodi/gui/controls/Progress.h
new file mode 100644
index 0000000..83b16aa
--- /dev/null
+++ b/xbmc/addons/kodi-dev-kit/include/kodi/gui/controls/Progress.h
@@ -0,0 +1,112 @@
1/*
2 * Copyright (C) 2005-2018 Team Kodi
3 * This file is part of Kodi - https://kodi.tv
4 *
5 * SPDX-License-Identifier: GPL-2.0-or-later
6 * See LICENSES/README.md for more information.
7 */
8
9#pragma once
10
11#include "../../c-api/gui/controls/progress.h"
12#include "../Window.h"
13
14#ifdef __cplusplus
15
16namespace kodi
17{
18namespace gui
19{
20namespace controls
21{
22
23//==============================================================================
24/// @defgroup cpp_kodi_gui_windows_controls_CProgress Control Progress
25/// @ingroup cpp_kodi_gui_windows_controls
26/// @brief @cpp_class{ kodi::gui::controls::CProgress }
27/// **Window control to show the progress of a particular operation**\n
28/// The progress control is used to show the progress of an item that may take
29/// a long time, or to show how far through a movie you are.
30///
31/// You can choose the position, size, and look of the progress control.
32///
33/// It has the header @ref Progress.h "#include <kodi/gui/controls/Progress.h>"
34/// be included to enjoy it.
35///
36/// Here you find the needed skin part for a @ref Progress_Control "progress control".
37///
38/// @note The call of the control is only possible from the corresponding
39/// window as its class and identification number is required.
40///
41class ATTRIBUTE_HIDDEN CProgress : public CAddonGUIControlBase
42{
43public:
44 //============================================================================
45 /// @ingroup cpp_kodi_gui_windows_controls_CProgress
46 /// @brief Construct a new control.
47 ///
48 /// @param[in] window Related window control class
49 /// @param[in] controlId Used skin xml control id
50 ///
51 CProgress(CWindow* window, int controlId) : CAddonGUIControlBase(window)
52 {
53 m_controlHandle = m_interface->kodi_gui->window->get_control_progress(
54 m_interface->kodiBase, m_Window->GetControlHandle(), controlId);
55 if (!m_controlHandle)
56 kodi::Log(ADDON_LOG_FATAL,
57 "kodi::gui::controls::CProgress can't create control class from Kodi !!!");
58 }
59 //----------------------------------------------------------------------------
60
61 //============================================================================
62 /// @ingroup cpp_kodi_gui_windows_controls_CProgress
63 /// @brief Destructor.
64 ///
65 ~CProgress() override = default;
66 //----------------------------------------------------------------------------
67
68 //============================================================================
69 /// @ingroup cpp_kodi_gui_windows_controls_CProgress
70 /// @brief Set the control on window to visible.
71 ///
72 /// @param[in] visible If true visible, otherwise hidden
73 ///
74 void SetVisible(bool visible)
75 {
76 m_interface->kodi_gui->control_progress->set_visible(m_interface->kodiBase, m_controlHandle,
77 visible);
78 }
79 //----------------------------------------------------------------------------
80
81 //============================================================================
82 /// @ingroup cpp_kodi_gui_windows_controls_CProgress
83 /// @brief To set Percent position of control.
84 ///
85 /// @param[in] percent The percent position to use
86 ///
87 void SetPercentage(float percent)
88 {
89 m_interface->kodi_gui->control_progress->set_percentage(m_interface->kodiBase, m_controlHandle,
90 percent);
91 }
92 //----------------------------------------------------------------------------
93
94 //============================================================================
95 /// @ingroup cpp_kodi_gui_windows_controls_CProgress
96 /// @brief Get the active percent position of progress bar.
97 ///
98 /// @return Progress position as percent
99 ///
100 float GetPercentage() const
101 {
102 return m_interface->kodi_gui->control_progress->get_percentage(m_interface->kodiBase,
103 m_controlHandle);
104 }
105 //----------------------------------------------------------------------------
106};
107
108} /* namespace controls */
109} /* namespace gui */
110} /* namespace kodi */
111
112#endif /* __cplusplus */
diff --git a/xbmc/addons/kodi-dev-kit/include/kodi/gui/controls/RadioButton.h b/xbmc/addons/kodi-dev-kit/include/kodi/gui/controls/RadioButton.h
new file mode 100644
index 0000000..3b6a23c
--- /dev/null
+++ b/xbmc/addons/kodi-dev-kit/include/kodi/gui/controls/RadioButton.h
@@ -0,0 +1,214 @@
1/*
2 * Copyright (C) 2005-2018 Team Kodi
3 * This file is part of Kodi - https://kodi.tv
4 *
5 * SPDX-License-Identifier: GPL-2.0-or-later
6 * See LICENSES/README.md for more information.
7 */
8
9#pragma once
10
11#include "../../c-api/gui/controls/radio_button.h"
12#include "../Window.h"
13
14#ifdef __cplusplus
15
16namespace kodi
17{
18namespace gui
19{
20namespace controls
21{
22
23//==============================================================================
24/// @defgroup cpp_kodi_gui_windows_controls_CRadioButton Control Radio Button
25/// @ingroup cpp_kodi_gui_windows_controls
26/// @brief @cpp_class{ kodi::gui::controls::CRadioButton }
27/// **Window control for a radio button (as used for on/off settings)**\n
28/// The radio button control is used for creating push button on/off settings
29/// in Kodi.
30///
31/// You can choose the position, size, and look of the button. When the user
32/// clicks on the radio button, the state will change, toggling the extra
33/// textures (textureradioon and textureradiooff). Used for settings
34/// controls.
35///
36/// It has the header @ref RadioButton.h "#include <kodi/gui/controls/RadioButton.h>"
37/// be included to enjoy it.
38///
39/// Here you find the needed skin part for a @ref Radio_button_control "radio button control".
40///
41/// @note The call of the control is only possible from the corresponding
42/// window as its class and identification number is required.
43///
44///
45/// --------------------------------------------------------------------------
46/// **Example:**
47/// ~~~~~~~~~~~~cpp
48/// #include <kodi/gui/Window.h>
49///
50/// #define MY_RADIO_BUTTON_CONTROL 1
51///
52/// class CMyWindow : public kodi::gui::CWindow
53/// {
54/// public:
55/// CMyWindow()
56///
57/// void ShowWindow();
58///
59/// bool OnInit() override;
60/// bool OnClick(int controlId) override;
61///
62/// private:
63/// kodi::gui::controls::CSpin m_myRadioButtonControl;
64/// };
65///
66/// CMyWindow::CMyWindow()
67/// : kodi::gui::CWindow("my_skin.xml", "skin.estuary", true, false),
68/// m_myRadioButtonControl(this, MY_RADIO_BUTTON_CONTROL)
69/// {
70/// }
71///
72/// void CMyWindow::ShowWindow()
73/// {
74/// kodi::gui::CWindow::DoModal();
75/// }
76///
77/// bool CMyWindow::OnInit()
78/// {
79/// m_myRadioButtonControl.SetSelected(false); // can also on skin set to default
80/// return true;
81/// }
82///
83/// bool CMyWindow::OnClick(int controlId)
84/// {
85/// if (controlId == MY_RADIO_BUTTON_CONTROL)
86/// {
87/// bool selected = m_myRadioButtonControl.IsSelected();
88/// ...
89/// }
90/// return true;
91/// }
92/// return false;
93/// }
94/// ~~~~~~~~~~~~
95///
96class ATTRIBUTE_HIDDEN CRadioButton : public CAddonGUIControlBase
97{
98public:
99 //============================================================================
100 /// @ingroup cpp_kodi_gui_windows_controls_CRadioButton
101 /// @brief Construct a new control.
102 ///
103 /// @param[in] window Related window control class
104 /// @param[in] controlId Used skin xml control id
105 ///
106 CRadioButton(CWindow* window, int controlId) : CAddonGUIControlBase(window)
107 {
108 m_controlHandle = m_interface->kodi_gui->window->get_control_radio_button(
109 m_interface->kodiBase, m_Window->GetControlHandle(), controlId);
110 if (!m_controlHandle)
111 kodi::Log(ADDON_LOG_FATAL,
112 "kodi::gui::controls::CRadioButton can't create control class from Kodi !!!");
113 }
114 //----------------------------------------------------------------------------
115
116 //============================================================================
117 /// @ingroup cpp_kodi_gui_windows_controls_CRadioButton
118 /// @brief Destructor.
119 ///
120 ~CRadioButton() override = default;
121 //----------------------------------------------------------------------------
122
123 //============================================================================
124 /// @ingroup cpp_kodi_gui_windows_controls_CRadioButton.
125 /// @brief Set the control on window to visible.
126 ///
127 /// @param[in] visible If true visible, otherwise hidden
128 ///
129 void SetVisible(bool visible)
130 {
131 m_interface->kodi_gui->control_radio_button->set_visible(m_interface->kodiBase, m_controlHandle,
132 visible);
133 }
134 //----------------------------------------------------------------------------
135
136 //============================================================================
137 /// @ingroup cpp_kodi_gui_windows_controls_CRadioButton
138 /// @brief Set's the control's enabled/disabled state.
139 ///
140 /// @param[in] enabled If true enabled, otherwise disabled
141 ///
142 void SetEnabled(bool enabled)
143 {
144 m_interface->kodi_gui->control_radio_button->set_enabled(m_interface->kodiBase, m_controlHandle,
145 enabled);
146 }
147 //----------------------------------------------------------------------------
148
149 //============================================================================
150 /// @ingroup cpp_kodi_gui_windows_controls_CRadioButton
151 /// @brief To set the text string on radio button.
152 ///
153 /// @param[in] label Text to show
154 ///
155 void SetLabel(const std::string& label)
156 {
157 m_interface->kodi_gui->control_radio_button->set_label(m_interface->kodiBase, m_controlHandle,
158 label.c_str());
159 }
160 //----------------------------------------------------------------------------
161
162 //============================================================================
163 /// @ingroup cpp_kodi_gui_windows_controls_CRadioButton
164 /// @brief Get the used text from control.
165 ///
166 /// @return Text shown
167 ///
168 std::string GetLabel() const
169 {
170 std::string label;
171 char* ret = m_interface->kodi_gui->control_radio_button->get_label(m_interface->kodiBase,
172 m_controlHandle);
173 if (ret != nullptr)
174 {
175 if (std::strlen(ret))
176 label = ret;
177 m_interface->free_string(m_interface->kodiBase, ret);
178 }
179 return label;
180 }
181 //----------------------------------------------------------------------------
182
183 //============================================================================
184 /// @ingroup cpp_kodi_gui_windows_controls_CRadioButton
185 /// @brief To set radio button condition to on or off.
186 ///
187 /// @param[in] selected true set radio button to selection on, otherwise off
188 ///
189 void SetSelected(bool selected)
190 {
191 m_interface->kodi_gui->control_radio_button->set_selected(m_interface->kodiBase,
192 m_controlHandle, selected);
193 }
194 //----------------------------------------------------------------------------
195
196 //============================================================================
197 /// @ingroup cpp_kodi_gui_windows_controls_CRadioButton
198 /// @brief Get the current selected condition of radio button.
199 ///
200 /// @return Selected condition
201 ///
202 bool IsSelected() const
203 {
204 return m_interface->kodi_gui->control_radio_button->is_selected(m_interface->kodiBase,
205 m_controlHandle);
206 }
207 //----------------------------------------------------------------------------
208};
209
210} /* namespace controls */
211} /* namespace gui */
212} /* namespace kodi */
213
214#endif /* __cplusplus */
diff --git a/xbmc/addons/kodi-dev-kit/include/kodi/gui/controls/Rendering.h b/xbmc/addons/kodi-dev-kit/include/kodi/gui/controls/Rendering.h
new file mode 100644
index 0000000..7f5feef
--- /dev/null
+++ b/xbmc/addons/kodi-dev-kit/include/kodi/gui/controls/Rendering.h
@@ -0,0 +1,217 @@
1/*
2 * Copyright (C) 2005-2018 Team Kodi
3 * This file is part of Kodi - https://kodi.tv
4 *
5 * SPDX-License-Identifier: GPL-2.0-or-later
6 * See LICENSES/README.md for more information.
7 */
8
9#pragma once
10
11#include "../../c-api/gui/controls/rendering.h"
12#include "../Window.h"
13#include "../renderHelper.h"
14
15#ifdef __cplusplus
16
17namespace kodi
18{
19namespace gui
20{
21namespace controls
22{
23
24//============================================================================
25/// @defgroup cpp_kodi_gui_windows_controls_CRendering Control Rendering
26/// @ingroup cpp_kodi_gui_windows_controls
27/// @brief @cpp_class{ kodi::gui::controls::CRendering }
28/// **Window control for rendering own parts**\n
29/// This rendering control is used when own parts are needed.
30///
31/// You have the control over them to render direct OpenGL or DirectX content
32/// to the screen set by the size of them.
33///
34/// Alternative can be the virtual functions from t his been ignored if the
35/// callbacks are defined by the @ref CRendering_SetIndependentCallbacks
36/// function and class is used as single and not as a parent class.
37///
38/// It has the header @ref Rendering.h "#include <kodi/gui/controls/Rendering.h>"
39/// be included to enjoy it.
40///
41/// Here you find the needed skin part for a @ref Addon_Rendering_control "rendering control".
42///
43/// @note The call of the control is only possible from the corresponding
44/// window as its class and identification number is required.
45///
46class ATTRIBUTE_HIDDEN CRendering : public CAddonGUIControlBase
47{
48public:
49 //==========================================================================
50 /// @ingroup cpp_kodi_gui_windows_controls_CRendering
51 /// @brief Construct a new control.
52 ///
53 /// @param[in] window Related window control class
54 /// @param[in] controlId Used skin xml control id
55 ///
56 CRendering(CWindow* window, int controlId) : CAddonGUIControlBase(window)
57 {
58 m_controlHandle = m_interface->kodi_gui->window->get_control_render_addon(
59 m_interface->kodiBase, m_Window->GetControlHandle(), controlId);
60 if (m_controlHandle)
61 m_interface->kodi_gui->control_rendering->set_callbacks(m_interface->kodiBase,
62 m_controlHandle, this, OnCreateCB,
63 OnRenderCB, OnStopCB, OnDirtyCB);
64 else
65 kodi::Log(ADDON_LOG_FATAL, "kodi::gui::controls::%s can't create control class from Kodi !!!",
66 __FUNCTION__);
67 }
68 //--------------------------------------------------------------------------
69
70 //==========================================================================
71 /// @ingroup cpp_kodi_gui_windows_controls_CRendering
72 /// @brief Destructor.
73 ///
74 ~CRendering() override
75 {
76 m_interface->kodi_gui->control_rendering->destroy(m_interface->kodiBase, m_controlHandle);
77 }
78 //--------------------------------------------------------------------------
79
80 //==========================================================================
81 /// @ingroup cpp_kodi_gui_windows_controls_CRendering
82 /// @brief To create rendering control on Add-on.
83 ///
84 /// Function creates the needed rendering control for Kodi which becomes
85 /// handled and processed from Add-on
86 ///
87 /// @note This is callback function from Kodi to Add-on and not to use
88 /// for calls from add-on to this function.
89 ///
90 /// @param[in] x Horizontal position
91 /// @param[in] y Vertical position
92 /// @param[in] w Width of control
93 /// @param[in] h Height of control
94 /// @param[in] device The device to use. For OpenGL is empty on Direct X is
95 /// the needed device send.
96 /// @return Add-on needs to return true if successed, otherwise false.
97 ///
98 /// @note The @ref kodi::HardwareContext is basically a simple pointer which
99 /// has to be changed to the desired format at the corresponding places using
100 /// <b>`static_cast<...>(...)`</b>.
101 ///
102 virtual bool Create(int x, int y, int w, int h, kodi::HardwareContext device) { return false; }
103 //--------------------------------------------------------------------------
104
105 //==========================================================================
106 /// @ingroup cpp_kodi_gui_windows_controls_CRendering
107 /// @brief Render process call from Kodi.
108 ///
109 /// @note This is callback function from Kodi to Add-on and not to use for
110 /// calls from add-on to this function.
111 ///
112 virtual void Render() {}
113 //--------------------------------------------------------------------------
114
115 //==========================================================================
116 /// @ingroup cpp_kodi_gui_windows_controls_CRendering
117 /// @brief Call from Kodi to stop rendering process.
118 ///
119 /// @note This is callback function from Kodi to Add-on and not to use
120 /// for calls from add-on to this function.
121 ///
122 virtual void Stop() {}
123 //--------------------------------------------------------------------------
124
125 //==========================================================================
126 /// @ingroup cpp_kodi_gui_windows_controls_CRendering
127 /// @brief Call from Kodi where add-on becomes asked about dirty rendering
128 /// region.
129 ///
130 /// @note This is callback function from Kodi to Add-on and not to use
131 /// for calls from add-on to this function.
132 ///
133 /// @return True if a render region is dirty and need rendering.
134 ///
135 virtual bool Dirty() { return false; }
136 //--------------------------------------------------------------------------
137
138 //==========================================================================
139 /// @ingroup cpp_kodi_gui_windows_controls_CRendering
140 /// @anchor CRendering_SetIndependentCallbacks
141 /// @brief If the class is used independent (with "new CRendering")
142 /// and not as parent (with "cCLASS_own : CRendering") from own must
143 /// be the callback from Kodi to add-on overdriven with own functions!
144 ///
145 /// @param[in] cbhdl Addon related class point where becomes given as value on
146 /// related functions.
147 /// @param[in] CBCreate External creation function pointer, see also @ref Create
148 /// about related values
149 /// @param[in] CBRender External render function pointer, see also @ref Render
150 /// about related values
151 /// @param[in] CBStop External stop function pointer, see also @ref Stop
152 /// about related values
153 /// @param[in] CBDirty External dirty function pointer, see also @ref Dirty
154 /// about related values
155 ///
156 void SetIndependentCallbacks(kodi::gui::ClientHandle cbhdl,
157 bool (*CBCreate)(kodi::gui::ClientHandle cbhdl,
158 int x,
159 int y,
160 int w,
161 int h,
162 kodi::HardwareContext device),
163 void (*CBRender)(kodi::gui::ClientHandle cbhdl),
164 void (*CBStop)(kodi::gui::ClientHandle cbhdl),
165 bool (*CBDirty)(kodi::gui::ClientHandle cbhdl))
166 {
167 if (!cbhdl || !CBCreate || !CBRender || !CBStop || !CBDirty)
168 {
169 kodi::Log(ADDON_LOG_ERROR, "kodi::gui::controls::%s called with nullptr !!!", __FUNCTION__);
170 return;
171 }
172
173 m_interface->kodi_gui->control_rendering->set_callbacks(
174 m_interface->kodiBase, m_controlHandle, cbhdl, CBCreate, CBRender, CBStop, CBDirty);
175 }
176 //--------------------------------------------------------------------------
177
178private:
179 /*
180 * Defined callback functions from Kodi to add-on, for use in parent / child system
181 * (is private)!
182 */
183 static bool OnCreateCB(
184 KODI_GUI_CLIENT_HANDLE cbhdl, int x, int y, int w, int h, ADDON_HARDWARE_CONTEXT device)
185 {
186 static_cast<CRendering*>(cbhdl)->m_renderHelper = kodi::gui::GetRenderHelper();
187 return static_cast<CRendering*>(cbhdl)->Create(x, y, w, h, device);
188 }
189
190 static void OnRenderCB(KODI_GUI_CLIENT_HANDLE cbhdl)
191 {
192 if (!static_cast<CRendering*>(cbhdl)->m_renderHelper)
193 return;
194 static_cast<CRendering*>(cbhdl)->m_renderHelper->Begin();
195 static_cast<CRendering*>(cbhdl)->Render();
196 static_cast<CRendering*>(cbhdl)->m_renderHelper->End();
197 }
198
199 static void OnStopCB(KODI_GUI_CLIENT_HANDLE cbhdl)
200 {
201 static_cast<CRendering*>(cbhdl)->Stop();
202 static_cast<CRendering*>(cbhdl)->m_renderHelper = nullptr;
203 }
204
205 static bool OnDirtyCB(KODI_GUI_CLIENT_HANDLE cbhdl)
206 {
207 return static_cast<CRendering*>(cbhdl)->Dirty();
208 }
209
210 std::shared_ptr<kodi::gui::IRenderHelper> m_renderHelper;
211};
212
213} /* namespace controls */
214} /* namespace gui */
215} /* namespace kodi */
216
217#endif /* __cplusplus */
diff --git a/xbmc/addons/kodi-dev-kit/include/kodi/gui/controls/SettingsSlider.h b/xbmc/addons/kodi-dev-kit/include/kodi/gui/controls/SettingsSlider.h
new file mode 100644
index 0000000..5557fc4
--- /dev/null
+++ b/xbmc/addons/kodi-dev-kit/include/kodi/gui/controls/SettingsSlider.h
@@ -0,0 +1,314 @@
1/*
2 * Copyright (C) 2005-2018 Team Kodi
3 * This file is part of Kodi - https://kodi.tv
4 *
5 * SPDX-License-Identifier: GPL-2.0-or-later
6 * See LICENSES/README.md for more information.
7 */
8
9#pragma once
10
11#include "../../c-api/gui/controls/settings_slider.h"
12#include "../Window.h"
13
14#ifdef __cplusplus
15
16namespace kodi
17{
18namespace gui
19{
20namespace controls
21{
22
23//==============================================================================
24/// @defgroup cpp_kodi_gui_windows_controls_CSettingsSlider Control Settings Slider
25/// @ingroup cpp_kodi_gui_windows_controls
26/// @brief @cpp_class{ kodi::gui::controls::CSettingsSlider }
27/// **Window control for moveable slider with text name**\n
28/// The settings slider control is used in the settings screens for when an
29/// option is best specified on a sliding scale.
30///
31/// You can choose the position, size, and look of the slider control. It is
32/// basically a cross between the button control and a slider control. It has a
33/// label and focus and non focus textures, as well as a slider control on the
34/// right.
35///
36/// It has the header @ref SettingsSlider.h "#include <kodi/gui/controls/SettingsSlider.h>"
37/// be included to enjoy it.
38///
39/// Here you find the needed skin part for a @ref Settings_Slider_Control "settings slider control".
40///
41/// @note The call of the control is only possible from the corresponding
42/// window as its class and identification number is required.
43///
44class ATTRIBUTE_HIDDEN CSettingsSlider : public CAddonGUIControlBase
45{
46public:
47 //============================================================================
48 /// @ingroup cpp_kodi_gui_windows_controls_CSettingsSlider
49 /// @brief Construct a new control.
50 ///
51 /// @param[in] window Related window control class
52 /// @param[in] controlId Used skin xml control id
53 ///
54 CSettingsSlider(CWindow* window, int controlId) : CAddonGUIControlBase(window)
55 {
56 m_controlHandle = m_interface->kodi_gui->window->get_control_settings_slider(
57 m_interface->kodiBase, m_Window->GetControlHandle(), controlId);
58 if (!m_controlHandle)
59 kodi::Log(ADDON_LOG_FATAL,
60 "kodi::gui::controls::CSettingsSlider can't create control class from Kodi !!!");
61 }
62 //----------------------------------------------------------------------------
63
64 //============================================================================
65 /// @ingroup cpp_kodi_gui_windows_controls_CSettingsSlider
66 /// @brief Destructor.
67 ///
68 ~CSettingsSlider() override = default;
69 //----------------------------------------------------------------------------
70
71 //============================================================================
72 /// @ingroup cpp_kodi_gui_windows_controls_CSettingsSlider
73 /// @brief Set the control on window to visible.
74 ///
75 /// @param[in] visible If true visible, otherwise hidden
76 ///
77 void SetVisible(bool visible)
78 {
79 m_interface->kodi_gui->control_settings_slider->set_visible(m_interface->kodiBase,
80 m_controlHandle, visible);
81 }
82 //----------------------------------------------------------------------------
83
84 //============================================================================
85 /// @ingroup cpp_kodi_gui_windows_controls_CSettingsSlider
86 /// @brief Set's the control's enabled/disabled state.
87 ///
88 /// @param[in] enabled If true enabled, otherwise disabled
89 ///
90 void SetEnabled(bool enabled)
91 {
92 m_interface->kodi_gui->control_settings_slider->set_enabled(m_interface->kodiBase,
93 m_controlHandle, enabled);
94 }
95 //----------------------------------------------------------------------------
96
97 //============================================================================
98 /// @ingroup cpp_kodi_gui_windows_controls_CSettingsSlider
99 /// @brief To set the text string on settings slider.
100 ///
101 /// @param[in] text Text to show
102 ///
103 void SetText(const std::string& text)
104 {
105 m_interface->kodi_gui->control_settings_slider->set_text(m_interface->kodiBase, m_controlHandle,
106 text.c_str());
107 }
108 //----------------------------------------------------------------------------
109
110 //============================================================================
111 /// @ingroup cpp_kodi_gui_windows_controls_CSettingsSlider
112 /// @brief To reset slider on defaults.
113 ///
114 void Reset()
115 {
116 m_interface->kodi_gui->control_settings_slider->reset(m_interface->kodiBase, m_controlHandle);
117 }
118 //----------------------------------------------------------------------------
119
120 //============================================================================
121 /// @ingroup cpp_kodi_gui_windows_controls_CSettingsSlider
122 /// @brief To set the the range as integer of slider, e.g. -10 is the slider
123 /// start and e.g. +10 is the from here defined position where it reach the
124 /// end.
125 ///
126 /// Ad default is the range from 0 to 100.
127 ///
128 /// The integer interval is as default 1 and can be changed with
129 /// @ref SetIntInterval.
130 ///
131 /// @param[in] start Integer start value
132 /// @param[in] end Integer end value
133 ///
134 /// @note Percent, floating point or integer are alone possible. Combining
135 /// these different values can be not together and can, therefore, only
136 /// one each can be used.
137 ///
138 void SetIntRange(int start, int end)
139 {
140 m_interface->kodi_gui->control_settings_slider->set_int_range(m_interface->kodiBase,
141 m_controlHandle, start, end);
142 }
143 //----------------------------------------------------------------------------
144
145 //============================================================================
146 /// @ingroup cpp_kodi_gui_windows_controls_CSettingsSlider
147 /// @brief Set the slider position with the given integer value. The Range
148 /// must be defined with a call from @ref SetIntRange before.
149 ///
150 /// @param[in] value Position in range to set with integer
151 ///
152 /// @note Percent, floating point or integer are alone possible. Combining
153 /// these different values can be not together and can, therefore, only
154 /// one each can be used.
155 ///
156 void SetIntValue(int value)
157 {
158 m_interface->kodi_gui->control_settings_slider->set_int_value(m_interface->kodiBase,
159 m_controlHandle, value);
160 }
161 //----------------------------------------------------------------------------
162
163 //============================================================================
164 /// @ingroup cpp_kodi_gui_windows_controls_CSettingsSlider
165 /// @brief To get the current position as integer value.
166 ///
167 /// @return The position as integer
168 ///
169 /// @note Percent, floating point or integer are alone possible. Combining
170 /// these different values can be not together and can, therefore, only
171 /// one each can be used.
172 ///
173 int GetIntValue() const
174 {
175 return m_interface->kodi_gui->control_settings_slider->get_int_value(m_interface->kodiBase,
176 m_controlHandle);
177 }
178 //----------------------------------------------------------------------------
179
180 //============================================================================
181 /// @ingroup cpp_kodi_gui_windows_controls_CSettingsSlider
182 /// @brief To set the interval steps of slider, as default is it 1. If it
183 /// becomes changed with this function will a step of the user with the
184 /// value fixed here be executed.
185 ///
186 /// @param[in] interval Intervall step to set.
187 ///
188 /// @note Percent, floating point or integer are alone possible. Combining
189 /// these different values can be not together and can, therefore, only
190 /// one each can be used.
191 ///
192 void SetIntInterval(int interval)
193 {
194 m_interface->kodi_gui->control_settings_slider->set_int_interval(m_interface->kodiBase,
195 m_controlHandle, interval);
196 }
197 //----------------------------------------------------------------------------
198
199 //============================================================================
200 /// @ingroup cpp_kodi_gui_windows_controls_CSettingsSlider
201 /// @brief Sets the percent of the slider.
202 ///
203 /// @param[in] percent float - Percent value of slide
204 ///
205 /// @note Percent, floating point or integer are alone possible. Combining
206 /// these different values can be not together and can, therefore, only
207 /// one each can be used.
208 ///
209 void SetPercentage(float percent)
210 {
211 m_interface->kodi_gui->control_settings_slider->set_percentage(m_interface->kodiBase,
212 m_controlHandle, percent);
213 }
214 //----------------------------------------------------------------------------
215
216 //============================================================================
217 /// @ingroup cpp_kodi_gui_windows_controls_CSettingsSlider
218 /// @brief Returns a float of the percent of the slider.
219 ///
220 /// @return float - Percent of slider
221 ///
222 /// @note Percent, floating point or integer are alone possible. Combining
223 /// these different values can be not together and can, therefore, only
224 /// one each can be used.
225 ///
226 float GetPercentage() const
227 {
228 return m_interface->kodi_gui->control_settings_slider->get_percentage(m_interface->kodiBase,
229 m_controlHandle);
230 }
231 //----------------------------------------------------------------------------
232
233 //============================================================================
234 /// @ingroup cpp_kodi_gui_windows_controls_CSettingsSlider
235 /// @brief To set the the range as float of slider, e.g. -25.0 is the slider
236 /// start and e.g. +25.0 is the from here defined position where it reach
237 /// the end.
238 ///
239 /// As default is the range 0.0 to 1.0.
240 ///
241 /// The float interval is as default 0.1 and can be changed with
242 /// @ref SetFloatInterval.
243 ///
244 /// @param[in] start Integer start value
245 /// @param[in] end Integer end value
246 ///
247 /// @note Percent, floating point or integer are alone possible. Combining
248 /// these different values can be not together and can, therefore, only
249 /// one each can be used.
250 ///
251 void SetFloatRange(float start, float end)
252 {
253 m_interface->kodi_gui->control_settings_slider->set_float_range(m_interface->kodiBase,
254 m_controlHandle, start, end);
255 }
256 //----------------------------------------------------------------------------
257
258 //============================================================================
259 /// @ingroup cpp_kodi_gui_windows_controls_CSettingsSlider
260 /// @brief Set the slider position with the given float value. The Range can
261 /// be defined with a call from @ref SetIntRange before, as default it
262 /// is 0.0 to 1.0.
263 ///
264 /// @param[in] value Position in range to set with float
265 ///
266 /// @note Percent, floating point or integer are alone possible. Combining
267 /// these different values can be not together and can, therefore, only
268 /// one each can be used.
269 ///
270 void SetFloatValue(float value)
271 {
272 m_interface->kodi_gui->control_settings_slider->set_float_value(m_interface->kodiBase,
273 m_controlHandle, value);
274 }
275 //----------------------------------------------------------------------------
276
277 //============================================================================
278 /// @ingroup cpp_kodi_gui_windows_controls_CSettingsSlider
279 /// @brief To get the current position as float value.
280 ///
281 /// @return The position as float
282 ///
283 float GetFloatValue() const
284 {
285 return m_interface->kodi_gui->control_settings_slider->get_float_value(m_interface->kodiBase,
286 m_controlHandle);
287 }
288 //----------------------------------------------------------------------------
289
290 //============================================================================
291 /// @ingroup cpp_kodi_gui_windows_controls_CSettingsSlider
292 /// @brief To set the interval steps of slider, as default is it 0.1 If it
293 /// becomes changed with this function will a step of the user with the
294 /// value fixed here be executed.
295 ///
296 /// @param[in] interval Intervall step to set.
297 ///
298 /// @note Percent, floating point or integer are alone possible. Combining
299 /// these different values can be not together and can, therefore, only
300 /// one each can be used.
301 ///
302 void SetFloatInterval(float interval)
303 {
304 m_interface->kodi_gui->control_settings_slider->set_float_interval(m_interface->kodiBase,
305 m_controlHandle, interval);
306 }
307 //----------------------------------------------------------------------------
308};
309
310} /* namespace controls */
311} /* namespace gui */
312} /* namespace kodi */
313
314#endif /* __cplusplus */
diff --git a/xbmc/addons/kodi-dev-kit/include/kodi/gui/controls/Slider.h b/xbmc/addons/kodi-dev-kit/include/kodi/gui/controls/Slider.h
new file mode 100644
index 0000000..077def8
--- /dev/null
+++ b/xbmc/addons/kodi-dev-kit/include/kodi/gui/controls/Slider.h
@@ -0,0 +1,326 @@
1/*
2 * Copyright (C) 2005-2018 Team Kodi
3 * This file is part of Kodi - https://kodi.tv
4 *
5 * SPDX-License-Identifier: GPL-2.0-or-later
6 * See LICENSES/README.md for more information.
7 */
8
9#pragma once
10
11#include "../../c-api/gui/controls/slider.h"
12#include "../Window.h"
13
14#ifdef __cplusplus
15
16namespace kodi
17{
18namespace gui
19{
20namespace controls
21{
22
23//==============================================================================
24/// @defgroup cpp_kodi_gui_windows_controls_CSlider Control Slider
25/// @ingroup cpp_kodi_gui_windows_controls
26/// @brief @cpp_class{ kodi::gui::controls::CSlider }
27/// **Window control for moveable slider**\n
28/// The slider control is used for things where a sliding bar best represents
29/// the operation at hand (such as a volume control or seek control).
30///
31/// You can choose the position, size, and look of the slider control.
32///
33/// It has the header @ref Slider.h "#include <kodi/gui/controls/Slider.h>"
34/// be included to enjoy it.
35///
36/// Here you find the needed skin part for a @ref Slider_Control "slider control".
37///
38/// @note The call of the control is only possible from the corresponding
39/// window as its class and identification number is required.
40///
41class ATTRIBUTE_HIDDEN CSlider : public CAddonGUIControlBase
42{
43public:
44 //============================================================================
45 /// @ingroup cpp_kodi_gui_windows_controls_CSlider
46 /// @brief Construct a new control.
47 ///
48 /// @param[in] window Related window control class
49 /// @param[in] controlId Used skin xml control id
50 ///
51 CSlider(CWindow* window, int controlId) : CAddonGUIControlBase(window)
52 {
53 m_controlHandle = m_interface->kodi_gui->window->get_control_slider(
54 m_interface->kodiBase, m_Window->GetControlHandle(), controlId);
55 if (!m_controlHandle)
56 kodi::Log(ADDON_LOG_FATAL,
57 "kodi::gui::controls::CSlider can't create control class from Kodi !!!");
58 }
59 //----------------------------------------------------------------------------
60
61 //============================================================================
62 /// @ingroup cpp_kodi_gui_windows_controls_CSlider
63 /// @brief Destructor.
64 ///
65 ~CSlider() override = default;
66 //----------------------------------------------------------------------------
67
68 //============================================================================
69 /// @ingroup cpp_kodi_gui_windows_controls_CSlider
70 /// @brief Set the control on window to visible.
71 ///
72 /// @param[in] visible If true visible, otherwise hidden
73 ///
74 void SetVisible(bool visible)
75 {
76 m_interface->kodi_gui->control_slider->set_visible(m_interface->kodiBase, m_controlHandle,
77 visible);
78 }
79 //----------------------------------------------------------------------------
80
81 //============================================================================
82 /// @ingroup cpp_kodi_gui_windows_controls_CSlider
83 /// @brief Set's the control's enabled/disabled state.
84 ///
85 /// @param[in] enabled If true enabled, otherwise disabled
86 ///
87 void SetEnabled(bool enabled)
88 {
89 m_interface->kodi_gui->control_slider->set_enabled(m_interface->kodiBase, m_controlHandle,
90 enabled);
91 }
92 //----------------------------------------------------------------------------
93
94 //============================================================================
95 /// @ingroup cpp_kodi_gui_windows_controls_CSlider
96 /// @brief To reset slider on defaults.
97 ///
98 void Reset()
99 {
100 m_interface->kodi_gui->control_slider->reset(m_interface->kodiBase, m_controlHandle);
101 }
102 //----------------------------------------------------------------------------
103
104 //============================================================================
105 /// @ingroup cpp_kodi_gui_windows_controls_CSlider
106 /// @brief With GetDescription becomes a string value of position returned.
107 ///
108 /// @return Text string about current slider position
109 ///
110 /// The following are the text definition returned from this:
111 /// | Value | Without range selection | With range selection |
112 /// |:---------:|:------------------------|:-------------------------------|
113 /// | float | <c>%2.2f</c> | <c>[%2.2f, %2.2f]</c> |
114 /// | integer | <c>%i</c> | <c>[%i, %i]</c> |
115 /// | percent | <c>%i%%</c> | <c>[%i%%, %i%%]</c> |
116 ///
117 std::string GetDescription() const
118 {
119 std::string text;
120 char* ret = m_interface->kodi_gui->control_slider->get_description(m_interface->kodiBase,
121 m_controlHandle);
122 if (ret != nullptr)
123 {
124 if (std::strlen(ret))
125 text = ret;
126 m_interface->free_string(m_interface->kodiBase, ret);
127 }
128 return text;
129 }
130 //----------------------------------------------------------------------------
131
132 //============================================================================
133 /// @ingroup cpp_kodi_gui_windows_controls_CSlider
134 /// @brief To set the the range as integer of slider, e.g. -10 is the slider
135 /// start and e.g. +10 is the from here defined position where it reach the
136 /// end.
137 ///
138 /// Ad default is the range from 0 to 100.
139 ///
140 /// The integer interval is as default 1 and can be changed with
141 /// @ref SetIntInterval.
142 ///
143 /// @param[in] start Integer start value
144 /// @param[in] end Integer end value
145 ///
146 /// @note Percent, floating point or integer are alone possible. Combining
147 /// these different values can be not together and can, therefore, only one
148 /// each can be used.
149 ///
150 void SetIntRange(int start, int end)
151 {
152 m_interface->kodi_gui->control_slider->set_int_range(m_interface->kodiBase, m_controlHandle,
153 start, end);
154 }
155 //----------------------------------------------------------------------------
156
157 //============================================================================
158 /// @ingroup cpp_kodi_gui_windows_controls_CSlider
159 /// @brief Set the slider position with the given integer value. The Range
160 /// must be defined with a call from @ref SetIntRange before.
161 ///
162 /// @param[in] value Position in range to set with integer
163 ///
164 /// @note Percent, floating point or integer are alone possible. Combining
165 /// these different values can be not together and can, therefore, only one
166 /// each can be used.
167 ///
168 void SetIntValue(int value)
169 {
170 m_interface->kodi_gui->control_slider->set_int_value(m_interface->kodiBase, m_controlHandle,
171 value);
172 }
173 //----------------------------------------------------------------------------
174
175 //============================================================================
176 /// @ingroup cpp_kodi_gui_windows_controls_CSlider
177 /// @brief To get the current position as integer value.
178 ///
179 /// @return The position as integer
180 ///
181 /// @note Percent, floating point or integer are alone possible. Combining
182 /// these different values can be not together and can, therefore, only
183 /// one each can be used.
184 ///
185 int GetIntValue() const
186 {
187 return m_interface->kodi_gui->control_slider->get_int_value(m_interface->kodiBase,
188 m_controlHandle);
189 }
190 //----------------------------------------------------------------------------
191
192 //============================================================================
193 /// @ingroup cpp_kodi_gui_windows_controls_CSlider
194 /// @brief To set the interval steps of slider, as default is it 1. If it
195 /// becomes changed with this function will a step of the user with the
196 /// value fixed here be executed.
197 ///
198 /// @param[in] interval Intervall step to set.
199 ///
200 /// @note Percent, floating point or integer are alone possible. Combining
201 /// these different values can be not together and can, therefore, only one
202 /// each can be used.
203 ///
204 void SetIntInterval(int interval)
205 {
206 m_interface->kodi_gui->control_slider->set_int_interval(m_interface->kodiBase, m_controlHandle,
207 interval);
208 }
209 //----------------------------------------------------------------------------
210
211 //============================================================================
212 /// @ingroup cpp_kodi_gui_windows_controls_CSlider
213 /// @brief Sets the percent of the slider.
214 ///
215 /// @param[in] percent float - Percent value of slide
216 ///
217 /// @note Percent, floating point or integer are alone possible. Combining
218 /// these different values can be not together and can, therefore, only one
219 /// each can be used.
220 ///
221 void SetPercentage(float percent)
222 {
223 m_interface->kodi_gui->control_slider->set_percentage(m_interface->kodiBase, m_controlHandle,
224 percent);
225 }
226 //----------------------------------------------------------------------------
227
228 //============================================================================
229 /// @ingroup cpp_kodi_gui_windows_controls_CSlider
230 /// @brief Returns a float of the percent of the slider.
231 ///
232 /// @return float - Percent of slider
233 ///
234 /// @note Percent, floating point or integer are alone possible. Combining
235 /// these different values can be not together and can, therefore, only one
236 /// each can be used.
237 ///
238 float GetPercentage() const
239 {
240 return m_interface->kodi_gui->control_slider->get_percentage(m_interface->kodiBase,
241 m_controlHandle);
242 }
243 //----------------------------------------------------------------------------
244
245 //============================================================================
246 /// @ingroup cpp_kodi_gui_windows_controls_CSlider
247 /// @brief To set the the range as float of slider, e.g. -25.0 is the slider
248 /// start and e.g. +25.0 is the from here defined position where it reach
249 /// the end.
250 ///
251 /// As default is the range 0.0 to 1.0.
252 ///
253 /// The float interval is as default 0.1 and can be changed with
254 /// @ref SetFloatInterval.
255 ///
256 /// @param[in] start Integer start value
257 /// @param[in] end Integer end value
258 ///
259 /// @note Percent, floating point or integer are alone possible. Combining
260 /// these different values can be not together and can, therefore, only
261 /// one each can be used.
262 ///
263 void SetFloatRange(float start, float end)
264 {
265 m_interface->kodi_gui->control_slider->set_float_range(m_interface->kodiBase, m_controlHandle,
266 start, end);
267 }
268 //----------------------------------------------------------------------------
269
270 //============================================================================
271 /// @ingroup cpp_kodi_gui_windows_controls_CSlider
272 /// @brief Set the slider position with the given float value. The Range
273 /// can be defined with a call from @ref SetIntRange before, as default it
274 /// is 0.0 to 1.0.
275 ///
276 /// @param[in] value Position in range to set with float
277 ///
278 /// @note Percent, floating point or integer are alone possible. Combining
279 /// these different values can be not together and can, therefore, only one
280 /// each can be used.
281 ///
282 void SetFloatValue(float value)
283 {
284 m_interface->kodi_gui->control_slider->set_float_value(m_interface->kodiBase, m_controlHandle,
285 value);
286 }
287 //----------------------------------------------------------------------------
288
289 //============================================================================
290 /// @ingroup cpp_kodi_gui_windows_controls_CSlider
291 /// @brief To get the current position as float value.
292 ///
293 /// @return The position as float
294 ///
295 float GetFloatValue() const
296 {
297 return m_interface->kodi_gui->control_slider->get_float_value(m_interface->kodiBase,
298 m_controlHandle);
299 }
300 //----------------------------------------------------------------------------
301
302 //============================================================================
303 /// @ingroup cpp_kodi_gui_windows_controls_CSlider
304 /// @brief To set the interval steps of slider, as default is it 0.1 If it
305 /// becomes changed with this function will a step of the user with the
306 /// value fixed here be executed.
307 ///
308 /// @param[in] interval Intervall step to set.
309 ///
310 /// @note Percent, floating point or integer are alone possible. Combining
311 /// these different values can be not together and can, therefore, only
312 /// one each can be used.
313 ///
314 void SetFloatInterval(float interval)
315 {
316 m_interface->kodi_gui->control_slider->set_float_interval(m_interface->kodiBase,
317 m_controlHandle, interval);
318 }
319 //----------------------------------------------------------------------------
320};
321
322} /* namespace controls */
323} /* namespace gui */
324} /* namespace kodi */
325
326#endif /* __cplusplus */
diff --git a/xbmc/addons/kodi-dev-kit/include/kodi/gui/controls/Spin.h b/xbmc/addons/kodi-dev-kit/include/kodi/gui/controls/Spin.h
new file mode 100644
index 0000000..6c55243
--- /dev/null
+++ b/xbmc/addons/kodi-dev-kit/include/kodi/gui/controls/Spin.h
@@ -0,0 +1,416 @@
1/*
2 * Copyright (C) 2005-2018 Team Kodi
3 * This file is part of Kodi - https://kodi.tv
4 *
5 * SPDX-License-Identifier: GPL-2.0-or-later
6 * See LICENSES/README.md for more information.
7 */
8
9#pragma once
10
11#include "../../c-api/gui/controls/spin.h"
12#include "../Window.h"
13
14#ifdef __cplusplus
15
16namespace kodi
17{
18namespace gui
19{
20namespace controls
21{
22
23//==============================================================================
24/// @defgroup cpp_kodi_gui_windows_controls_CSpin Control Spin
25/// @ingroup cpp_kodi_gui_windows_controls
26/// @brief @cpp_class{ kodi::gui::controls::CSpin }
27/// **Window control used for cycling up/down controls**\n
28/// The settings spin control is used in the settings screens for when a list
29/// of options can be chosen from using up/down arrows.
30///
31/// You can choose the position, size, and look of the spin control. It is
32/// basically a cross between the button control and a spin control. It has a
33/// label and focus and non focus textures, as well as a spin control on the
34/// right.
35///
36/// It has the header @ref Spin.h "#include <kodi/gui/controls/Spin.h>"
37/// be included to enjoy it.
38///
39/// Here you find the needed skin part for a @ref Spin_Control "spin control".
40///
41/// @note The call of the control is only possible from the corresponding
42/// window as its class and identification number is required.
43///
44/// --------------------------------------------------------------------------
45/// **Example:**
46/// ~~~~~~~~~~~~cpp
47/// #include <kodi/gui/Window.h>
48///
49/// #define MY_SPIN_CONTROL 1
50///
51/// class CMyWindow : public kodi::gui::CWindow
52/// {
53/// public:
54/// CMyWindow()
55///
56/// void ShowWindow();
57///
58/// bool OnInit() override;
59/// bool OnClick(int controlId) override;
60///
61/// private:
62/// kodi::gui::controls::CSpin m_mySpinControl;
63/// };
64///
65/// CMyWindow::CMyWindow()
66/// : kodi::gui::CWindow("my_skin.xml", "skin.estuary", true, false),
67/// m_mySpinControl(this, MY_SPIN_CONTROL)
68/// {
69/// }
70///
71/// void CMyWindow::ShowWindow()
72/// {
73/// kodi::gui::CWindow::DoModal();
74/// }
75///
76/// bool CMyWindow::OnInit()
77/// {
78/// m_mySpinControl.SetType(kodi::gui::controls::ADDON_SPIN_CONTROL_TYPE_INT);
79/// m_mySpinControl.SetIntRange(1, 80);
80/// return true;
81/// }
82///
83/// bool CMyWindow::OnClick(int controlId)
84/// {
85/// if (controlId == MY_SPIN_CONTROL)
86/// {
87/// int value = m_mySpinControl.GetIntValue();
88/// ...
89/// }
90/// return true;
91/// }
92/// return false;
93/// }
94/// ~~~~~~~~~~~~
95///
96
97
98//==============================================================================
99/// @ingroup cpp_kodi_gui_windows_controls_CSpin
100/// @anchor AddonGUISpinControlType
101/// @brief The values here defines the used value format for steps on
102/// spin control.
103///
104typedef enum AddonGUISpinControlType
105{
106 /// One spin step interpreted as integer
107 ADDON_SPIN_CONTROL_TYPE_INT = 1,
108 /// One spin step interpreted as floating point value
109 ADDON_SPIN_CONTROL_TYPE_FLOAT = 2,
110 /// One spin step interpreted as text string
111 ADDON_SPIN_CONTROL_TYPE_TEXT = 3,
112 /// One spin step interpreted as a page change value
113 ADDON_SPIN_CONTROL_TYPE_PAGE = 4
114} AddonGUISpinControlType;
115//------------------------------------------------------------------------------
116
117class ATTRIBUTE_HIDDEN CSpin : public CAddonGUIControlBase
118{
119public:
120 //============================================================================
121 /// @ingroup cpp_kodi_gui_windows_controls_CSpin
122 /// @brief Construct a new control.
123 ///
124 /// @param[in] window Related window control class
125 /// @param[in] controlId Used skin xml control id
126 ///
127 CSpin(CWindow* window, int controlId) : CAddonGUIControlBase(window)
128 {
129 m_controlHandle = m_interface->kodi_gui->window->get_control_spin(
130 m_interface->kodiBase, m_Window->GetControlHandle(), controlId);
131 if (!m_controlHandle)
132 kodi::Log(ADDON_LOG_FATAL,
133 "kodi::gui::controls::CSpin can't create control class from Kodi !!!");
134 }
135 //----------------------------------------------------------------------------
136
137 //============================================================================
138 /// @ingroup cpp_kodi_gui_windows_controls_CSpin
139 /// @brief Destructor.
140 ///
141 ~CSpin() override = default;
142 //----------------------------------------------------------------------------
143
144 //============================================================================
145 /// @ingroup cpp_kodi_gui_windows_controls_CSpin
146 /// @brief Set the control on window to visible.
147 ///
148 /// @param[in] visible If true visible, otherwise hidden
149 ///
150 void SetVisible(bool visible)
151 {
152 m_interface->kodi_gui->control_spin->set_visible(m_interface->kodiBase, m_controlHandle,
153 visible);
154 }
155 //----------------------------------------------------------------------------
156
157 //============================================================================
158 /// @ingroup cpp_kodi_gui_windows_controls_CSpin
159 /// @brief Set's the control's enabled/disabled state.
160 ///
161 /// @param[in] enabled If true enabled, otherwise disabled
162 ///
163 void SetEnabled(bool enabled)
164 {
165 m_interface->kodi_gui->control_spin->set_enabled(m_interface->kodiBase, m_controlHandle,
166 enabled);
167 }
168 //----------------------------------------------------------------------------
169
170 //============================================================================
171 /// @ingroup cpp_kodi_gui_windows_controls_CSpin
172 /// @brief To set the text string on spin control.
173 ///
174 /// @param[in] text Text to show as name for spin
175 ///
176 void SetText(const std::string& text)
177 {
178 m_interface->kodi_gui->control_spin->set_text(m_interface->kodiBase, m_controlHandle,
179 text.c_str());
180 }
181 //----------------------------------------------------------------------------
182
183 //============================================================================
184 /// @ingroup cpp_kodi_gui_windows_controls_CSpin
185 /// @brief To reset spin control to defaults.
186 ///
187 void Reset()
188 {
189 m_interface->kodi_gui->control_spin->reset(m_interface->kodiBase, m_controlHandle);
190 }
191 //----------------------------------------------------------------------------
192
193 //============================================================================
194 /// @ingroup cpp_kodi_gui_windows_controls_CSpin
195 /// @brief To set the with SpinControlType defined types of spin.
196 ///
197 /// @param[in] type The type to use
198 ///
199 /// @note See description of @ref AddonGUISpinControlType for available types.
200 ///
201 void SetType(AddonGUISpinControlType type)
202 {
203 m_interface->kodi_gui->control_spin->set_type(m_interface->kodiBase, m_controlHandle,
204 (int)type);
205 }
206 //----------------------------------------------------------------------------
207
208 //============================================================================
209 /// @ingroup cpp_kodi_gui_windows_controls_CSpin
210 /// @brief To add a label entry in spin defined with a value as string.
211 ///
212 /// Format must be set to @ref ADDON_SPIN_CONTROL_TYPE_TEXT to use this function.
213 ///
214 /// @param[in] label Label string to view on skin
215 /// @param[in] value String value to use for selection of them
216 ///
217 void AddLabel(const std::string& label, const std::string& value)
218 {
219 m_interface->kodi_gui->control_spin->add_string_label(m_interface->kodiBase, m_controlHandle,
220 label.c_str(), value.c_str());
221 }
222 //----------------------------------------------------------------------------
223
224 //============================================================================
225 /// @ingroup cpp_kodi_gui_windows_controls_CSpin
226 /// @brief To add a label entry in spin defined with a value as integer.
227 ///
228 /// Format must be set to @ref ADDON_SPIN_CONTROL_TYPE_INT to use this function.
229 ///
230 /// @param[in] label Label string to view on skin
231 /// @param[in] value Integer value to use for selection of them.
232 ///
233 void AddLabel(const std::string& label, int value)
234 {
235 m_interface->kodi_gui->control_spin->add_int_label(m_interface->kodiBase, m_controlHandle,
236 label.c_str(), value);
237 }
238 //----------------------------------------------------------------------------
239
240 //============================================================================
241 /// @ingroup cpp_kodi_gui_windows_controls_CSpin
242 /// @brief To change the spin to position with them string as value.
243 ///
244 /// Format must be set to @ref ADDON_SPIN_CONTROL_TYPE_TEXT to use this function.
245 ///
246 /// @param[in] value String value to change to
247 ///
248 void SetStringValue(const std::string& value)
249 {
250 m_interface->kodi_gui->control_spin->set_string_value(m_interface->kodiBase, m_controlHandle,
251 value.c_str());
252 }
253 //----------------------------------------------------------------------------
254
255 //============================================================================
256 /// @ingroup cpp_kodi_gui_windows_controls_CSpin
257 /// @brief To get the current spin control position with text string value.
258 ///
259 /// Format must be set to @ref ADDON_SPIN_CONTROL_TYPE_TEXT to use this function.
260 ///
261 /// @return Currently selected string value
262 ///
263 std::string GetStringValue() const
264 {
265 std::string value;
266 char* ret = m_interface->kodi_gui->control_spin->get_string_value(m_interface->kodiBase,
267 m_controlHandle);
268 if (ret != nullptr)
269 {
270 if (std::strlen(ret))
271 value = ret;
272 m_interface->free_string(m_interface->kodiBase, ret);
273 }
274 return value;
275 }
276 //----------------------------------------------------------------------------
277
278 //============================================================================
279 /// @ingroup cpp_kodi_gui_windows_controls_CSpin
280 /// @brief To set the the range as integer of slider, e.g. -10 is the slider
281 /// start and e.g. +10 is the from here defined position where it reach the
282 /// end.
283 ///
284 /// Ad default is the range from 0 to 100.
285 ///
286 /// @param[in] start Integer start value
287 /// @param[in] end Integer end value
288 ///
289 /// @note Percent, floating point or integer are alone possible. Combining
290 /// these different values can be not together and can, therefore, only
291 /// one each can be used and must be defined with @ref SetType before.
292 ///
293 void SetIntRange(int start, int end)
294 {
295 m_interface->kodi_gui->control_spin->set_int_range(m_interface->kodiBase, m_controlHandle,
296 start, end);
297 }
298 //----------------------------------------------------------------------------
299
300 //============================================================================
301 /// @ingroup cpp_kodi_gui_windows_controls_CSpin
302 /// @brief Set the slider position with the given integer value. The Range
303 /// must be defined with a call from @ref SetIntRange before.
304 ///
305 /// @param[in] value Position in range to set with integer
306 ///
307 /// @note Percent, floating point or integer are alone possible. Combining
308 /// these different values can be not together and can, therefore, only
309 /// one each can be used and must be defined with @ref SetType before.
310 ///
311 void SetIntValue(int value)
312 {
313 m_interface->kodi_gui->control_spin->set_int_value(m_interface->kodiBase, m_controlHandle,
314 value);
315 }
316 //----------------------------------------------------------------------------
317
318 //============================================================================
319 /// @ingroup cpp_kodi_gui_windows_controls_CSpin
320 /// @brief To get the current position as integer value.
321 ///
322 /// @return The position as integer
323 ///
324 /// @note Percent, floating point or integer are alone possible. Combining
325 /// these different values can be not together and can, therefore, only
326 /// one each can be used and must be defined with @ref SetType before.
327 ///
328 int GetIntValue() const
329 {
330 return m_interface->kodi_gui->control_spin->get_int_value(m_interface->kodiBase,
331 m_controlHandle);
332 }
333 //----------------------------------------------------------------------------
334
335 //============================================================================
336 /// @ingroup cpp_kodi_gui_windows_controls_CSpin
337 /// @brief To set the the range as float of spin, e.g. -25.0 is the spin
338 /// start and e.g. +25.0 is the from here defined position where it reach
339 /// the end.
340 ///
341 /// As default is the range 0.0 to 1.0.
342 ///
343 /// The float interval is as default 0.1 and can be changed with
344 /// @ref SetFloatInterval.
345 ///
346 /// @param[in] start Integer start value
347 /// @param[in] end Integer end value
348 ///
349 /// @note Percent, floating point or integer are alone possible. Combining
350 /// these different values can be not together and can, therefore, only
351 /// one each can be used and must be defined with @ref SetType before.
352 ///
353 void SetFloatRange(float start, float end)
354 {
355 m_interface->kodi_gui->control_spin->set_float_range(m_interface->kodiBase, m_controlHandle,
356 start, end);
357 }
358 //----------------------------------------------------------------------------
359
360 //============================================================================
361 /// @ingroup cpp_kodi_gui_windows_controls_CSpin
362 /// @brief Set the spin position with the given float value. The Range
363 /// can be defined with a call from @ref SetIntRange before, as default it
364 /// is 0.0 to 1.0.
365 ///
366 /// @param[in] value Position in range to set with float
367 ///
368 /// @note Percent, floating point or integer are alone possible. Combining
369 /// these different values can be not together and can, therefore, only
370 /// one each can be used and must be defined with @ref SetType before.
371 ///
372 void SetFloatValue(float value)
373 {
374 m_interface->kodi_gui->control_spin->set_float_value(m_interface->kodiBase, m_controlHandle,
375 value);
376 }
377 //----------------------------------------------------------------------------
378
379 //============================================================================
380 /// @ingroup cpp_kodi_gui_windows_controls_CSpin
381 /// @brief To get the current position as float value.
382 ///
383 /// @return The position as float
384 ///
385 float GetFloatValue() const
386 {
387 return m_interface->kodi_gui->control_spin->get_float_value(m_interface->kodiBase,
388 m_controlHandle);
389 }
390 //----------------------------------------------------------------------------
391
392 //============================================================================
393 /// @ingroup cpp_kodi_gui_windows_controls_CSpin
394 /// @brief To set the interval steps of spin, as default is it 0.1 If it
395 /// becomes changed with this function will a step of the user with the
396 /// value fixed here be executed.
397 ///
398 /// @param[in] interval Intervall step to set.
399 ///
400 /// @note Percent, floating point or integer are alone possible. Combining
401 /// these different values can be not together and can, therefore, only
402 /// one each can be used and must be defined with @ref SetType before.
403 ///
404 void SetFloatInterval(float interval)
405 {
406 m_interface->kodi_gui->control_spin->set_float_interval(m_interface->kodiBase, m_controlHandle,
407 interval);
408 }
409 //----------------------------------------------------------------------------
410};
411
412} /* namespace controls */
413} /* namespace gui */
414} /* namespace kodi */
415
416#endif /* __cplusplus */
diff --git a/xbmc/addons/kodi-dev-kit/include/kodi/gui/controls/TextBox.h b/xbmc/addons/kodi-dev-kit/include/kodi/gui/controls/TextBox.h
new file mode 100644
index 0000000..2634568
--- /dev/null
+++ b/xbmc/addons/kodi-dev-kit/include/kodi/gui/controls/TextBox.h
@@ -0,0 +1,164 @@
1/*
2 * Copyright (C) 2005-2018 Team Kodi
3 * This file is part of Kodi - https://kodi.tv
4 *
5 * SPDX-License-Identifier: GPL-2.0-or-later
6 * See LICENSES/README.md for more information.
7 */
8
9#pragma once
10
11#include "../../c-api/gui/controls/text_box.h"
12#include "../Window.h"
13
14#ifdef __cplusplus
15
16namespace kodi
17{
18namespace gui
19{
20namespace controls
21{
22
23//============================================================================
24/// @defgroup cpp_kodi_gui_windows_controls_CTextBox Control Text Box
25/// @ingroup cpp_kodi_gui_windows_controls
26/// @brief @cpp_class{ kodi::gui::controls::CTextBox }
27/// **Used to show a multi-page piece of text**\n
28/// The text box control can be used to display descriptions, help texts or
29/// other larger texts.
30///
31/// It corresponds to the representation which is also to be seen on the
32/// @ref CDialogTextViewer.
33///
34/// It has the header @ref TextBox.h "#include <kodi/gui/controls/TextBox.h>"
35/// be included to enjoy it.
36///
37/// Here you find the needed skin part for a @ref Text_Box "textbox control".
38///
39/// @note The call of the control is only possible from the corresponding
40/// window as its class and identification number is required.
41///
42class ATTRIBUTE_HIDDEN CTextBox : public CAddonGUIControlBase
43{
44public:
45 //==========================================================================
46 /// @ingroup cpp_kodi_gui_windows_controls_CTextBox
47 /// @brief Construct a new control.
48 ///
49 /// @param[in] window related window control class
50 /// @param[in] controlId Used skin xml control id
51 ///
52 CTextBox(CWindow* window, int controlId) : CAddonGUIControlBase(window)
53 {
54 m_controlHandle = m_interface->kodi_gui->window->get_control_text_box(
55 m_interface->kodiBase, m_Window->GetControlHandle(), controlId);
56 if (!m_controlHandle)
57 kodi::Log(ADDON_LOG_FATAL,
58 "kodi::gui::controls::CTextBox can't create control class from Kodi !!!");
59 }
60 //--------------------------------------------------------------------------
61
62 //==========================================================================
63 /// @ingroup cpp_kodi_gui_windows_controls_CTextBox
64 /// @brief Destructor.
65 ///
66 ~CTextBox() override = default;
67 //--------------------------------------------------------------------------
68
69 //==========================================================================
70 /// @ingroup cpp_kodi_gui_windows_controls_CTextBox
71 /// @brief Set the control on window to visible.
72 ///
73 /// @param[in] visible If true visible, otherwise hidden
74 ///
75 void SetVisible(bool visible)
76 {
77 m_interface->kodi_gui->control_text_box->set_visible(m_interface->kodiBase, m_controlHandle,
78 visible);
79 }
80 //--------------------------------------------------------------------------
81
82 //==========================================================================
83 /// @ingroup cpp_kodi_gui_windows_controls_CTextBox
84 /// @brief To reset box an remove all the text.
85 ///
86 void Reset() { m_interface->kodi_gui->control_text_box->reset(m_controlHandle, m_controlHandle); }
87 //--------------------------------------------------------------------------
88
89 //==========================================================================
90 /// @ingroup cpp_kodi_gui_windows_controls_CTextBox
91 /// @brief To set the text on box.
92 ///
93 /// @param[in] text Text to show
94 ///
95 void SetText(const std::string& text)
96 {
97 m_interface->kodi_gui->control_text_box->set_text(m_interface->kodiBase, m_controlHandle,
98 text.c_str());
99 }
100 //--------------------------------------------------------------------------
101
102 //==========================================================================
103 /// @ingroup cpp_kodi_gui_windows_controls_CTextBox
104 /// @brief Get the used text from control.
105 ///
106 /// @return Text shown
107 ///
108 std::string GetText() const
109 {
110 std::string text;
111 char* ret =
112 m_interface->kodi_gui->control_text_box->get_text(m_interface->kodiBase, m_controlHandle);
113 if (ret != nullptr)
114 {
115 if (std::strlen(ret))
116 text = ret;
117 m_interface->free_string(m_interface->kodiBase, ret);
118 }
119 return text;
120 }
121 //--------------------------------------------------------------------------
122
123 //==========================================================================
124 /// @ingroup cpp_kodi_gui_windows_controls_CTextBox
125 /// @brief To scroll text on other position.
126 ///
127 /// @param[in] position The line position to scroll to
128 ///
129 void Scroll(unsigned int position)
130 {
131 m_interface->kodi_gui->control_text_box->scroll(m_interface->kodiBase, m_controlHandle,
132 position);
133 }
134 //--------------------------------------------------------------------------
135
136 //==========================================================================
137 /// @ingroup cpp_kodi_gui_windows_controls_CTextBox
138 /// @brief To set automatic scrolling of textbox
139 ///
140 /// Specifies the timing and conditions of any autoscrolling this textbox
141 /// should have. Times are in milliseconds. The content is delayed for the
142 /// given delay, then scrolls at a rate of one line per time interval until
143 /// the end. If the repeat tag is present, it then delays for the repeat
144 /// time, fades out over 1 second, and repeats. It does not wrap or reset
145 /// to the top at the end of the scroll.
146 ///
147 /// @param[in] delay Content delay
148 /// @param[in] time One line per time interval
149 /// @param[in] repeat Delays with given time, fades out over 1 second, and
150 /// repeats
151 ///
152 void SetAutoScrolling(int delay, int time, int repeat)
153 {
154 m_interface->kodi_gui->control_text_box->set_auto_scrolling(
155 m_interface->kodiBase, m_controlHandle, delay, time, repeat);
156 }
157 //--------------------------------------------------------------------------
158};
159
160} /* namespace controls */
161} /* namespace gui */
162} /* namespace kodi */
163
164#endif /* __cplusplus */
diff --git a/xbmc/addons/kodi-dev-kit/include/kodi/gui/dialogs/CMakeLists.txt b/xbmc/addons/kodi-dev-kit/include/kodi/gui/dialogs/CMakeLists.txt
new file mode 100644
index 0000000..9aaee4f
--- /dev/null
+++ b/xbmc/addons/kodi-dev-kit/include/kodi/gui/dialogs/CMakeLists.txt
@@ -0,0 +1,14 @@
1set(HEADERS ContextMenu.h
2 ExtendedProgress.h
3 FileBrowser.h
4 Keyboard.h
5 Numeric.h
6 OK.h
7 Progress.h
8 Select.h
9 TextViewer.h
10 YesNo.h)
11
12if(NOT ENABLE_STATIC_LIBS)
13 core_add_library(addons_kodi-dev-kit_include_kodi_gui_dialogs)
14endif()
diff --git a/xbmc/addons/kodi-dev-kit/include/kodi/gui/dialogs/ContextMenu.h b/xbmc/addons/kodi-dev-kit/include/kodi/gui/dialogs/ContextMenu.h
new file mode 100644
index 0000000..b576b9a
--- /dev/null
+++ b/xbmc/addons/kodi-dev-kit/include/kodi/gui/dialogs/ContextMenu.h
@@ -0,0 +1,186 @@
1/*
2 * Copyright (C) 2005-2018 Team Kodi
3 * This file is part of Kodi - https://kodi.tv
4 *
5 * SPDX-License-Identifier: GPL-2.0-or-later
6 * See LICENSES/README.md for more information.
7 */
8
9#pragma once
10
11#include "../../AddonBase.h"
12#include "../../c-api/gui/dialogs/context_menu.h"
13
14#ifdef __cplusplus
15
16namespace kodi
17{
18namespace gui
19{
20namespace dialogs
21{
22
23//==============================================================================
24/// @defgroup cpp_kodi_gui_dialogs_ContextMenu Dialog Context Menu
25/// @ingroup cpp_kodi_gui_dialogs
26/// @brief @cpp_namespace{ kodi::gui::dialogs::ContextMenu }
27/// **Context menu dialog**@n
28/// The function listed below permits the call of a dialogue as context menu to
29/// select of an entry as a key
30///
31/// It has the header @ref ContextMenu.h "#include <kodi/gui/dialogs/ContextMenu.h>"
32/// be included to enjoy it.
33///
34///
35namespace ContextMenu
36{
37//==============================================================================
38/// @ingroup cpp_kodi_gui_dialogs_ContextMenu
39/// @brief Show a context menu dialog about given parts.
40///
41/// @param[in] heading Dialog heading name
42/// @param[in] entries String list about entries
43/// @return The selected entry, if return <tt>-1</tt> was nothing selected or canceled
44///
45///
46///-------------------------------------------------------------------------
47///
48/// **Example:**
49/// ~~~~~~~~~~~~~{.cpp}
50/// #include <kodi/gui/dialogs/ContextMenu.h>
51///
52/// const std::vector<std::string> entries
53/// {
54/// "Test 1",
55/// "Test 2",
56/// "Test 3",
57/// "Test 4",
58/// "Test 5"
59/// };
60///
61/// int selected = kodi::gui::dialogs::ContextMenu::Show("Test selection", entries);
62/// if (selected < 0)
63/// fprintf(stderr, "Item selection canceled\n");
64/// else
65/// fprintf(stderr, "Selected item is: %i\n", selected);
66/// ~~~~~~~~~~~~~
67///
68inline int ATTRIBUTE_HIDDEN Show(const std::string& heading,
69 const std::vector<std::string>& entries)
70{
71 using namespace ::kodi::addon;
72 unsigned int size = static_cast<unsigned int>(entries.size());
73 const char** cEntries = static_cast<const char**>(malloc(size * sizeof(const char**)));
74 for (unsigned int i = 0; i < size; ++i)
75 {
76 cEntries[i] = entries[i].c_str();
77 }
78 int ret = CAddonBase::m_interface->toKodi->kodi_gui->dialogContextMenu->open(
79 CAddonBase::m_interface->toKodi->kodiBase, heading.c_str(), cEntries, size);
80 free(cEntries);
81 return ret;
82}
83//------------------------------------------------------------------------------
84
85//==============================================================================
86/// @ingroup cpp_kodi_gui_dialogs_ContextMenu
87/// @brief Show a context menu dialog about given parts.
88///
89/// @param[in] heading Dialog heading name
90/// @param[in] entries String list about entries
91/// @return The selected entry, if return <tt>-1</tt> was nothing selected or canceled
92///
93///
94///-------------------------------------------------------------------------
95///
96/// **Example:**
97/// ~~~~~~~~~~~~~{.cpp}
98/// #include <kodi/gui/dialogs/ContextMenu.h>
99///
100/// const std::vector<std::pair<std::string, std::string>> entries
101/// {
102/// { "ID 1", "Test 1" },
103/// { "ID 2", "Test 2" },
104/// { "ID 3", "Test 3" },
105/// { "ID 4", "Test 4" },
106/// { "ID 5", "Test 5" }
107/// };
108///
109/// int selected = kodi::gui::dialogs::ContextMenu::Show("Test selection", entries);
110/// if (selected < 0)
111/// fprintf(stderr, "Item selection canceled\n");
112/// else
113/// fprintf(stderr, "Selected item is: %i\n", selected);
114/// ~~~~~~~~~~~~~
115///
116inline int ATTRIBUTE_HIDDEN Show(const std::string& heading,
117 const std::vector<std::pair<std::string, std::string>>& entries)
118{
119 using namespace ::kodi::addon;
120 unsigned int size = static_cast<unsigned int>(entries.size());
121 const char** cEntries = static_cast<const char**>(malloc(size * sizeof(const char**)));
122 for (unsigned int i = 0; i < size; ++i)
123 {
124 cEntries[i] = entries[i].second.c_str();
125 }
126 int ret = CAddonBase::m_interface->toKodi->kodi_gui->dialogContextMenu->open(
127 CAddonBase::m_interface->toKodi->kodiBase, heading.c_str(), cEntries, size);
128 free(cEntries);
129 return ret;
130}
131//------------------------------------------------------------------------------
132
133//==============================================================================
134/// @ingroup cpp_kodi_gui_dialogs_ContextMenu
135/// @brief Show a context menu dialog about given parts.
136///
137/// @param[in] heading Dialog heading name
138/// @param[in] entries String list about entries
139/// @return The selected entry, if return <tt>-1</tt> was nothing selected or canceled
140///
141///
142///-------------------------------------------------------------------------
143///
144/// **Example:**
145/// ~~~~~~~~~~~~~{.cpp}
146/// #include <kodi/gui/dialogs/ContextMenu.h>
147///
148/// const std::vector<std::pair<int, std::string>> entries
149/// {
150/// { 1, "Test 1" },
151/// { 2, "Test 2" },
152/// { 3, "Test 3" },
153/// { 4, "Test 4" },
154/// { 5, "Test 5" }
155/// };
156///
157/// int selected = kodi::gui::dialogs::ContextMenu::Show("Test selection", entries);
158/// if (selected < 0)
159/// fprintf(stderr, "Item selection canceled\n");
160/// else
161/// fprintf(stderr, "Selected item is: %i\n", selected);
162/// ~~~~~~~~~~~~~
163///
164inline int ATTRIBUTE_HIDDEN Show(const std::string& heading,
165 const std::vector<std::pair<int, std::string>>& entries)
166{
167 using namespace ::kodi::addon;
168 unsigned int size = static_cast<unsigned int>(entries.size());
169 const char** cEntries = static_cast<const char**>(malloc(size * sizeof(const char**)));
170 for (unsigned int i = 0; i < size; ++i)
171 {
172 cEntries[i] = entries[i].second.c_str();
173 }
174 int ret = CAddonBase::m_interface->toKodi->kodi_gui->dialogContextMenu->open(
175 CAddonBase::m_interface->toKodi->kodiBase, heading.c_str(), cEntries, size);
176 free(cEntries);
177 return ret;
178}
179//------------------------------------------------------------------------------
180}; // namespace ContextMenu
181
182} /* namespace dialogs */
183} /* namespace gui */
184} /* namespace kodi */
185
186#endif /* __cplusplus */
diff --git a/xbmc/addons/kodi-dev-kit/include/kodi/gui/dialogs/ExtendedProgress.h b/xbmc/addons/kodi-dev-kit/include/kodi/gui/dialogs/ExtendedProgress.h
new file mode 100644
index 0000000..c650483
--- /dev/null
+++ b/xbmc/addons/kodi-dev-kit/include/kodi/gui/dialogs/ExtendedProgress.h
@@ -0,0 +1,242 @@
1/*
2 * Copyright (C) 2005-2018 Team Kodi
3 * This file is part of Kodi - https://kodi.tv
4 *
5 * SPDX-License-Identifier: GPL-2.0-or-later
6 * See LICENSES/README.md for more information.
7 */
8
9#pragma once
10
11#include "../../AddonBase.h"
12#include "../../c-api/gui/dialogs/extended_progress.h"
13
14#ifdef __cplusplus
15
16namespace kodi
17{
18namespace gui
19{
20namespace dialogs
21{
22
23//==============================================================================
24/// @defgroup cpp_kodi_gui_dialogs_CExtendedProgress Dialog Extended Progress
25/// @ingroup cpp_kodi_gui_dialogs
26/// @brief @cpp_class{ kodi::gui::dialogs::ExtendedProgress }
27/// **Progress dialog shown for background work**
28///
29/// The with @ref ExtendedProgress.h "#include <kodi/gui/dialogs/ExtendedProgress.h>"
30/// given class are basically used to create Kodi's extended progress.
31///
32///
33/// --------------------------------------------------------------------------
34///
35/// **Example:**
36/// ~~~~~~~~~~~~~{.cpp}
37/// #include <kodi/gui/dialogs/ExtendedProgress.h>
38///
39/// kodi::gui::dialogs::CExtendedProgress *ext_progress = new kodi::gui::dialogs::CExtendedProgress("Test Extended progress");
40/// ext_progress->SetText("Test progress");
41/// for (unsigned int i = 0; i < 50; i += 10)
42/// {
43/// ext_progress->SetProgress(i, 100);
44/// sleep(1);
45/// }
46///
47/// ext_progress->SetTitle("Test Extended progress - Second round");
48/// ext_progress->SetText("Test progress - Step 2");
49///
50/// for (unsigned int i = 50; i < 100; i += 10)
51/// {
52/// ext_progress->SetProgress(i, 100);
53/// sleep(1);
54/// }
55/// delete ext_progress;
56/// ~~~~~~~~~~~~~
57///
58class ATTRIBUTE_HIDDEN CExtendedProgress
59{
60public:
61 //============================================================================
62 /// @ingroup cpp_kodi_gui_dialogs_CExtendedProgress
63 /// Construct a new dialog.
64 ///
65 /// @param[in] title [opt] Title string
66 ///
67 explicit CExtendedProgress(const std::string& title = "")
68 {
69 using namespace ::kodi::addon;
70 m_DialogHandle = CAddonBase::m_interface->toKodi->kodi_gui->dialogExtendedProgress->new_dialog(
71 CAddonBase::m_interface->toKodi->kodiBase, title.c_str());
72 if (!m_DialogHandle)
73 kodi::Log(ADDON_LOG_FATAL,
74 "kodi::gui::CDialogExtendedProgress can't create window class from Kodi !!!");
75 }
76 //----------------------------------------------------------------------------
77
78 //============================================================================
79 /// @ingroup cpp_kodi_gui_dialogs_CExtendedProgress
80 /// Destructor.
81 ///
82 ~CExtendedProgress()
83 {
84 using namespace ::kodi::addon;
85 if (m_DialogHandle)
86 CAddonBase::m_interface->toKodi->kodi_gui->dialogExtendedProgress->delete_dialog(
87 CAddonBase::m_interface->toKodi->kodiBase, m_DialogHandle);
88 }
89 //----------------------------------------------------------------------------
90
91 //============================================================================
92 /// @ingroup cpp_kodi_gui_dialogs_CExtendedProgress
93 /// @brief Get the used title.
94 ///
95 /// @return Title string
96 ///
97 std::string Title() const
98 {
99 using namespace ::kodi::addon;
100 std::string text;
101 char* strMsg = CAddonBase::m_interface->toKodi->kodi_gui->dialogExtendedProgress->get_title(
102 CAddonBase::m_interface->toKodi->kodiBase, m_DialogHandle);
103 if (strMsg != nullptr)
104 {
105 if (std::strlen(strMsg))
106 text = strMsg;
107 CAddonBase::m_interface->toKodi->free_string(CAddonBase::m_interface->toKodi->kodiBase,
108 strMsg);
109 }
110 return text;
111 }
112 //----------------------------------------------------------------------------
113
114 //============================================================================
115 /// @ingroup cpp_kodi_gui_dialogs_CExtendedProgress
116 /// @brief To set the title of dialog.
117 ///
118 /// @param[in] title Title string
119 ///
120 void SetTitle(const std::string& title)
121 {
122 using namespace ::kodi::addon;
123 CAddonBase::m_interface->toKodi->kodi_gui->dialogExtendedProgress->set_title(
124 CAddonBase::m_interface->toKodi->kodiBase, m_DialogHandle, title.c_str());
125 }
126 //----------------------------------------------------------------------------
127
128 //============================================================================
129 /// @ingroup cpp_kodi_gui_dialogs_CExtendedProgress
130 /// @brief Get the used text information string.
131 ///
132 /// @return Text string
133 ///
134 std::string Text() const
135 {
136 using namespace ::kodi::addon;
137 std::string text;
138 char* strMsg = CAddonBase::m_interface->toKodi->kodi_gui->dialogExtendedProgress->get_text(
139 CAddonBase::m_interface->toKodi->kodiBase, m_DialogHandle);
140 if (strMsg != nullptr)
141 {
142 if (std::strlen(strMsg))
143 text = strMsg;
144 CAddonBase::m_interface->toKodi->free_string(CAddonBase::m_interface->toKodi->kodiBase,
145 strMsg);
146 }
147 return text;
148 }
149 //----------------------------------------------------------------------------
150
151 //============================================================================
152 /// @ingroup cpp_kodi_gui_dialogs_CExtendedProgress
153 /// @brief To set the used text information string.
154 ///
155 /// @param[in] text Information text to set
156 ///
157 void SetText(const std::string& text)
158 {
159 using namespace ::kodi::addon;
160 CAddonBase::m_interface->toKodi->kodi_gui->dialogExtendedProgress->set_text(
161 CAddonBase::m_interface->toKodi->kodiBase, m_DialogHandle, text.c_str());
162 }
163 //----------------------------------------------------------------------------
164
165 //============================================================================
166 /// @ingroup cpp_kodi_gui_dialogs_CExtendedProgress
167 /// @brief To ask dialog is finished.
168 ///
169 /// @return True if on end
170 ///
171 bool IsFinished() const
172 {
173 using namespace ::kodi::addon;
174 return CAddonBase::m_interface->toKodi->kodi_gui->dialogExtendedProgress->is_finished(
175 CAddonBase::m_interface->toKodi->kodiBase, m_DialogHandle);
176 }
177 //----------------------------------------------------------------------------
178
179 //============================================================================
180 /// @ingroup cpp_kodi_gui_dialogs_CExtendedProgress
181 /// @brief Mark progress finished.
182 ///
183 void MarkFinished()
184 {
185 using namespace ::kodi::addon;
186 CAddonBase::m_interface->toKodi->kodi_gui->dialogExtendedProgress->mark_finished(
187 CAddonBase::m_interface->toKodi->kodiBase, m_DialogHandle);
188 }
189 //----------------------------------------------------------------------------
190
191 //============================================================================
192 /// @ingroup cpp_kodi_gui_dialogs_CExtendedProgress
193 /// @brief Get the current progress position as percent.
194 ///
195 /// @return Position
196 ///
197 float Percentage() const
198 {
199 using namespace ::kodi::addon;
200 return CAddonBase::m_interface->toKodi->kodi_gui->dialogExtendedProgress->get_percentage(
201 CAddonBase::m_interface->toKodi->kodiBase, m_DialogHandle);
202 }
203 //----------------------------------------------------------------------------
204
205 //============================================================================
206 /// @ingroup cpp_kodi_gui_dialogs_CExtendedProgress
207 /// @brief To set the current progress position as percent.
208 ///
209 /// @param[in] percentage Position to use from 0.0 to 100.0
210 ///
211 void SetPercentage(float percentage)
212 {
213 using namespace ::kodi::addon;
214 CAddonBase::m_interface->toKodi->kodi_gui->dialogExtendedProgress->set_percentage(
215 CAddonBase::m_interface->toKodi->kodiBase, m_DialogHandle, percentage);
216 }
217 //----------------------------------------------------------------------------
218
219 //============================================================================
220 /// @ingroup cpp_kodi_gui_dialogs_CExtendedProgress
221 /// @brief To set progress position with predefined places.
222 ///
223 /// @param[in] currentItem Place position to use
224 /// @param[in] itemCount Amount of used places
225 ///
226 void SetProgress(int currentItem, int itemCount)
227 {
228 using namespace ::kodi::addon;
229 CAddonBase::m_interface->toKodi->kodi_gui->dialogExtendedProgress->set_progress(
230 CAddonBase::m_interface->toKodi->kodiBase, m_DialogHandle, currentItem, itemCount);
231 }
232 //----------------------------------------------------------------------------
233
234private:
235 KODI_GUI_HANDLE m_DialogHandle;
236};
237
238} /* namespace dialogs */
239} /* namespace gui */
240} /* namespace kodi */
241
242#endif /* __cplusplus */
diff --git a/xbmc/addons/kodi-dev-kit/include/kodi/gui/dialogs/FileBrowser.h b/xbmc/addons/kodi-dev-kit/include/kodi/gui/dialogs/FileBrowser.h
new file mode 100644
index 0000000..244c76c
--- /dev/null
+++ b/xbmc/addons/kodi-dev-kit/include/kodi/gui/dialogs/FileBrowser.h
@@ -0,0 +1,302 @@
1/*
2 * Copyright (C) 2005-2018 Team Kodi
3 * This file is part of Kodi - https://kodi.tv
4 *
5 * SPDX-License-Identifier: GPL-2.0-or-later
6 * See LICENSES/README.md for more information.
7 */
8
9#pragma once
10
11#include "../../AddonBase.h"
12#include "../../c-api/gui/dialogs/filebrowser.h"
13
14#ifdef __cplusplus
15
16namespace kodi
17{
18namespace gui
19{
20namespace dialogs
21{
22
23//==============================================================================
24/// @defgroup cpp_kodi_gui_dialogs_FileBrowser Dialog File Browser
25/// @ingroup cpp_kodi_gui_dialogs
26/// @brief @cpp_namespace{ kodi::gui::dialogs::FileBrowser }
27/// **File browser dialog**\n
28/// The functions listed below of the class "FileBrowser" offer the possibility
29/// to select to a file by the user of the add-on.
30///
31/// It allows all the options that are possible in Kodi itself and offers all
32/// support file types.
33///
34/// It has the header @ref FileBrowser.h "#include <kodi/gui/dialogs/FileBrowser.h>"
35/// be included to enjoy it.
36///
37namespace FileBrowser
38{
39//==============================================================================
40/// @ingroup cpp_kodi_gui_dialogs_FileBrowser
41/// @brief Directory selection dialog.
42///
43/// @param[in] shares With Shares becomes the available start folders be set
44/// @param[in] heading Dialog header name
45/// @param[in,out] path As in the path to start and return value about
46/// selected directory
47/// @param[in] writeOnly [opt] If set only writeable folders are shown
48/// @return False if selection becomes canceled
49///
50/// **Example:**
51/// ~~~~~~~~~~~~~{.cpp}
52/// #include <kodi/gui/dialogs/FileBrowser.h>
53///
54/// // Example show directory selection dialog with on 'share' (first value)
55/// // defined directory types.
56/// //
57/// // If this becomes leaved empty and 'directory' is empty goes it to the
58/// // base path of the hard disk.
59/// //
60/// // Also can be with path written to 'directory' before the dialog forced
61/// // to a start place.
62/// std::string directory;
63/// bool ret = kodi::gui::dialogs::FileBrowser::ShowAndGetDirectory("local|network|removable",
64/// "Test directory selection",
65/// directory,
66/// false);
67/// fprintf(stderr, "Selected directory is : %s and was %s\n", directory.c_str(), ret ? "OK" : "Canceled");
68/// ~~~~~~~~~~~~~
69///
70inline bool ATTRIBUTE_HIDDEN ShowAndGetDirectory(const std::string& shares,
71 const std::string& heading,
72 std::string& path,
73 bool writeOnly = false)
74{
75 using namespace ::kodi::addon;
76 char* retString = nullptr;
77 bool ret = CAddonBase::m_interface->toKodi->kodi_gui->dialogFileBrowser->show_and_get_directory(
78 CAddonBase::m_interface->toKodi->kodiBase, shares.c_str(), heading.c_str(), path.c_str(),
79 &retString, writeOnly);
80 if (retString != nullptr)
81 {
82 if (std::strlen(retString))
83 path = retString;
84 CAddonBase::m_interface->toKodi->free_string(CAddonBase::m_interface->toKodi->kodiBase,
85 retString);
86 }
87 return ret;
88}
89//------------------------------------------------------------------------------
90
91//==============================================================================
92/// @ingroup cpp_kodi_gui_dialogs_FileBrowser
93/// @brief File selection dialog.
94///
95/// @param[in] shares With Shares becomes the available start folders be set.
96/// @param[in] mask The mask to filter visible files, e.g. ".m3u|.pls|.b4s|.wpl"
97/// @param[in] heading Dialog header name
98/// @param[in,out] path As in the path to start and Return value about selected
99/// file
100/// @param[in] useThumbs [opt] If set show thumbs if possible on dialog
101/// @param[in] useFileDirectories [opt] If set also packages (e.g. *.zip) are
102/// handled as directories.
103/// @return False if selection becomes canceled
104///
105inline bool ATTRIBUTE_HIDDEN ShowAndGetFile(const std::string& shares,
106 const std::string& mask,
107 const std::string& heading,
108 std::string& path,
109 bool useThumbs = false,
110 bool useFileDirectories = false)
111{
112 using namespace ::kodi::addon;
113 char* retString = nullptr;
114 bool ret = CAddonBase::m_interface->toKodi->kodi_gui->dialogFileBrowser->show_and_get_file(
115 CAddonBase::m_interface->toKodi->kodiBase, shares.c_str(), mask.c_str(), heading.c_str(),
116 path.c_str(), &retString, useThumbs, useFileDirectories);
117 if (retString != nullptr)
118 {
119 if (std::strlen(retString))
120 path = retString;
121 CAddonBase::m_interface->toKodi->free_string(CAddonBase::m_interface->toKodi->kodiBase,
122 retString);
123 }
124 return ret;
125}
126//------------------------------------------------------------------------------
127
128//==============================================================================
129/// @ingroup cpp_kodi_gui_dialogs_FileBrowser
130/// @brief File selection from a directory.
131///
132/// @param[in] directory The directory name where the dialog start, possible are
133/// normal names and kodi's special names
134/// @param[in] mask The mask to filter visible files, e.g. ".m3u|.pls|.b4s|.wpl"
135/// @param[in] heading Dialog header name
136/// @param[in,out] path As in the path to start and Return value about selected
137/// file
138/// @param[in] useThumbs [opt] If set show thumbs if possible on dialog
139/// @param[in] useFileDirectories [opt] If set also packages (e.g. *.zip) are
140/// handled as directories
141/// @param[in] singleList [opt]
142/// @return False if selection becomes canceled
143///
144inline bool ATTRIBUTE_HIDDEN ShowAndGetFileFromDir(const std::string& directory,
145 const std::string& mask,
146 const std::string& heading,
147 std::string& path,
148 bool useThumbs = false,
149 bool useFileDirectories = false,
150 bool singleList = false)
151{
152 using namespace ::kodi::addon;
153 char* retString = nullptr;
154 bool ret =
155 CAddonBase::m_interface->toKodi->kodi_gui->dialogFileBrowser->show_and_get_file_from_dir(
156 CAddonBase::m_interface->toKodi->kodiBase, directory.c_str(), mask.c_str(),
157 heading.c_str(), path.c_str(), &retString, useThumbs, useFileDirectories, singleList);
158 if (retString != nullptr)
159 {
160 if (std::strlen(retString))
161 path = retString;
162 CAddonBase::m_interface->toKodi->free_string(CAddonBase::m_interface->toKodi->kodiBase,
163 retString);
164 }
165 return ret;
166}
167//------------------------------------------------------------------------------
168
169//==============================================================================
170/// @ingroup cpp_kodi_gui_dialogs_FileBrowser
171/// @brief File selection dialog to get several in to a list.
172///
173/// @param[in] shares With Shares becomes the available start folders be set.
174/// @param[in] mask The mask to filter visible files, e.g. ".m3u|.pls|.b4s|.wpl"
175/// @param[in] heading Dialog header name
176/// @param[out] fileList Return value about selected files
177/// @param[in] useThumbs [opt] If set show thumbs if possible on dialog.
178/// @param[in] useFileDirectories [opt] If set also packages (e.g. *.zip) are
179/// handled as directories.
180/// @return False if selection becomes canceled.
181///
182inline bool ATTRIBUTE_HIDDEN ShowAndGetFileList(const std::string& shares,
183 const std::string& mask,
184 const std::string& heading,
185 std::vector<std::string>& fileList,
186 bool useThumbs = false,
187 bool useFileDirectories = false)
188{
189 using namespace ::kodi::addon;
190 char** list = nullptr;
191 unsigned int listSize = 0;
192 bool ret = CAddonBase::m_interface->toKodi->kodi_gui->dialogFileBrowser->show_and_get_file_list(
193 CAddonBase::m_interface->toKodi->kodiBase, shares.c_str(), mask.c_str(), heading.c_str(),
194 &list, &listSize, useThumbs, useFileDirectories);
195 if (ret)
196 {
197 for (unsigned int i = 0; i < listSize; ++i)
198 fileList.emplace_back(list[i]);
199 CAddonBase::m_interface->toKodi->kodi_gui->dialogFileBrowser->clear_file_list(
200 CAddonBase::m_interface->toKodi->kodiBase, &list, listSize);
201 }
202 return ret;
203}
204//------------------------------------------------------------------------------
205
206//==============================================================================
207/// @ingroup cpp_kodi_gui_dialogs_FileBrowser
208/// @brief Source selection dialog.
209///
210/// @param[in,out] path As in the path to start and Return value about selected
211/// source
212/// @param[in] allowNetworkShares Allow also access to network
213/// @param[in] additionalShare [opt] With additionalShare becomes the available
214/// start folders be set.
215/// @param[in] type [opt]
216/// @return False if selection becomes canceled
217///
218inline bool ATTRIBUTE_HIDDEN ShowAndGetSource(std::string& path,
219 bool allowNetworkShares,
220 const std::string& additionalShare = "",
221 const std::string& type = "")
222{
223 using namespace ::kodi::addon;
224 char* retString = nullptr;
225 bool ret = CAddonBase::m_interface->toKodi->kodi_gui->dialogFileBrowser->show_and_get_source(
226 CAddonBase::m_interface->toKodi->kodiBase, path.c_str(), &retString, allowNetworkShares,
227 additionalShare.c_str(), type.c_str());
228 if (retString != nullptr)
229 {
230 if (std::strlen(retString))
231 path = retString;
232 CAddonBase::m_interface->toKodi->free_string(CAddonBase::m_interface->toKodi->kodiBase,
233 retString);
234 }
235 return ret;
236}
237//------------------------------------------------------------------------------
238
239//==============================================================================
240/// @ingroup cpp_kodi_gui_dialogs_FileBrowser
241/// @brief Image selection dialog.
242///
243/// @param[in] shares With Shares becomes the available start folders be set
244/// @param[in] heading Dialog header name
245/// @param[out] path Return value about selected image
246/// @return False if selection becomes canceled
247///
248inline bool ATTRIBUTE_HIDDEN ShowAndGetImage(const std::string& shares,
249 const std::string& heading,
250 std::string& path)
251{
252 using namespace ::kodi::addon;
253 char* retString = nullptr;
254 bool ret = CAddonBase::m_interface->toKodi->kodi_gui->dialogFileBrowser->show_and_get_image(
255 CAddonBase::m_interface->toKodi->kodiBase, shares.c_str(), heading.c_str(), path.c_str(),
256 &retString);
257 if (retString != nullptr)
258 {
259 if (std::strlen(retString))
260 path = retString;
261 CAddonBase::m_interface->toKodi->free_string(CAddonBase::m_interface->toKodi->kodiBase,
262 retString);
263 }
264 return ret;
265}
266//------------------------------------------------------------------------------
267
268//==============================================================================
269/// @ingroup cpp_kodi_gui_dialogs_FileBrowser
270/// @brief Image selection dialog to get several in to a list.
271///
272/// @param[in] shares With Shares becomes the available start folders be set
273/// @param[in] heading Dialog header name
274/// @param[out] file_list Return value about selected images
275/// @return False if selection becomes canceled
276///
277inline bool ATTRIBUTE_HIDDEN ShowAndGetImageList(const std::string& shares,
278 const std::string& heading,
279 std::vector<std::string>& file_list)
280{
281 using namespace ::kodi::addon;
282 char** list = nullptr;
283 unsigned int listSize = 0;
284 bool ret = CAddonBase::m_interface->toKodi->kodi_gui->dialogFileBrowser->show_and_get_image_list(
285 CAddonBase::m_interface->toKodi->kodiBase, shares.c_str(), heading.c_str(), &list, &listSize);
286 if (ret)
287 {
288 for (unsigned int i = 0; i < listSize; ++i)
289 file_list.emplace_back(list[i]);
290 CAddonBase::m_interface->toKodi->kodi_gui->dialogFileBrowser->clear_file_list(
291 CAddonBase::m_interface->toKodi->kodiBase, &list, listSize);
292 }
293 return ret;
294}
295//------------------------------------------------------------------------------
296}; // namespace FileBrowser
297
298} /* namespace dialogs */
299} /* namespace gui */
300} /* namespace kodi */
301
302#endif /* __cplusplus */
diff --git a/xbmc/addons/kodi-dev-kit/include/kodi/gui/dialogs/Keyboard.h b/xbmc/addons/kodi-dev-kit/include/kodi/gui/dialogs/Keyboard.h
new file mode 100644
index 0000000..710b7dd
--- /dev/null
+++ b/xbmc/addons/kodi-dev-kit/include/kodi/gui/dialogs/Keyboard.h
@@ -0,0 +1,404 @@
1/*
2 * Copyright (C) 2005-2018 Team Kodi
3 * This file is part of Kodi - https://kodi.tv
4 *
5 * SPDX-License-Identifier: GPL-2.0-or-later
6 * See LICENSES/README.md for more information.
7 */
8
9#pragma once
10
11#include "../../AddonBase.h"
12#include "../../c-api/gui/dialogs/keyboard.h"
13
14#ifdef __cplusplus
15
16namespace kodi
17{
18namespace gui
19{
20namespace dialogs
21{
22
23//================================================================================
24/// @defgroup cpp_kodi_gui_dialogs_Keyboard Dialog Keyboard
25/// @ingroup cpp_kodi_gui_dialogs
26/// @brief @cpp_namespace{ kodi::gui::dialogs::Keyboard }
27/// **Keyboard dialogs**\n
28/// The functions listed below have to be permitted by the user for the
29/// representation of a keyboard around an input.
30///
31/// The class supports several kinds, from an easy text choice up to the
32/// passport Word production and their confirmation for add-on.
33///
34/// It has the header @ref Keyboard.h "#include <kodi/gui/dialogs/Keyboard.h>"
35/// be included to enjoy it.
36///
37namespace Keyboard
38{
39//==============================================================================
40/// @ingroup cpp_kodi_gui_dialogs_Keyboard
41/// @brief Show keyboard with initial value `text` and replace with result
42/// string.
43///
44/// @param[in,out] text Overwritten with user input if return=true.
45/// @param[in] heading String shown on dialog title.
46/// @param[in] allowEmptyResult Whether a blank password is valid or not.
47/// @param[in] hiddenInput [opt] The inserted input is not shown as text.
48/// @param[in] autoCloseMs [opt] To close the dialog after a specified time, in
49/// milliseconds, default is 0 which keeps the dialog
50/// open indefinitely.
51/// @return true if successful display and user input. false if unsuccessful
52/// display, no user input, or canceled editing.
53///
54///
55///-------------------------------------------------------------------------
56///
57/// **Example:**
58/// ~~~~~~~~~~~~~{.cpp}
59/// #include <kodi/gui/dialogs/Keyboard.h>
60///
61/// // The example shows the display of keyboard call dialog at Kodi from the add-on.
62/// // Below all values are set, however, can last two (hidden input = false and autoCloseMs = 0)
63/// // to be released if not needed.
64/// std::string text = "Please change me to them want you want"; // It can be leaved empty or a entry text added
65/// bool bRet = ::kodi::gui::dialogs::Keyboard::ShowAndGetInput(text,
66/// "Demonstration text entry",
67/// true,
68/// false,
69/// 0);
70/// fprintf(stderr, "Written keyboard input is : '%s' and was %s\n",
71/// text.c_str(), bRet ? "OK" : "Canceled");
72/// ~~~~~~~~~~~~~
73///
74inline bool ATTRIBUTE_HIDDEN ShowAndGetInput(std::string& text,
75 const std::string& heading,
76 bool allowEmptyResult,
77 bool hiddenInput = false,
78 unsigned int autoCloseMs = 0)
79{
80 using namespace ::kodi::addon;
81 char* retString = nullptr;
82 bool ret =
83 CAddonBase::m_interface->toKodi->kodi_gui->dialogKeyboard->show_and_get_input_with_head(
84 CAddonBase::m_interface->toKodi->kodiBase, text.c_str(), &retString, heading.c_str(),
85 allowEmptyResult, hiddenInput, autoCloseMs);
86 if (retString != nullptr)
87 {
88 text = retString;
89 CAddonBase::m_interface->toKodi->free_string(CAddonBase::m_interface->toKodi->kodiBase,
90 retString);
91 }
92 return ret;
93}
94//------------------------------------------------------------------------------
95
96//==============================================================================
97/// @ingroup cpp_kodi_gui_dialogs_Keyboard
98/// @brief The example shows the display of keyboard call dialog at Kodi
99/// from the add-on.
100///
101/// @param[out] text Overwritten with user input if return=true.
102/// @param[in] allowEmptyResult If set to true keyboard can also exited without
103/// entered text.
104/// @param[in] autoCloseMs [opt] To close the dialog after a specified time, in
105/// milliseconds, default is 0 which keeps the dialog
106/// open indefinitely.
107/// @return true if successful display and user input. false if unsuccessful
108/// display, no user input, or canceled editing.
109///
110inline bool ATTRIBUTE_HIDDEN ShowAndGetInput(std::string& text,
111 bool allowEmptyResult,
112 unsigned int autoCloseMs = 0)
113{
114 using namespace ::kodi::addon;
115 char* retString = nullptr;
116 bool ret = CAddonBase::m_interface->toKodi->kodi_gui->dialogKeyboard->show_and_get_input(
117 CAddonBase::m_interface->toKodi->kodiBase, text.c_str(), &retString, allowEmptyResult,
118 autoCloseMs);
119 if (retString != nullptr)
120 {
121 text = retString;
122 CAddonBase::m_interface->toKodi->free_string(CAddonBase::m_interface->toKodi->kodiBase,
123 retString);
124 }
125 return ret;
126}
127//------------------------------------------------------------------------------
128
129//==============================================================================
130/// @ingroup cpp_kodi_gui_dialogs_Keyboard
131/// @brief Shows keyboard and prompts for a password. Differs from
132/// `ShowAndVerifyNewPassword()` in that no second verification.
133///
134/// @param[in,out] newPassword Overwritten with user input if return=true.
135/// @param[in] heading String shown on dialog title.
136/// @param[in] allowEmptyResult Whether a blank password is valid or not.
137/// @param[in] autoCloseMs [opt] To close the dialog after a specified time, in
138/// milliseconds, default is 0 which keeps the dialog
139/// open indefinitely.
140/// @return true if successful display and user input. false if unsuccessful
141/// display, no user input, or canceled editing.
142///
143inline bool ATTRIBUTE_HIDDEN ShowAndGetNewPassword(std::string& newPassword,
144 const std::string& heading,
145 bool allowEmptyResult,
146 unsigned int autoCloseMs = 0)
147{
148 using namespace ::kodi::addon;
149 char* retString = nullptr;
150 bool ret = CAddonBase::m_interface->toKodi->kodi_gui->dialogKeyboard
151 ->show_and_get_new_password_with_head(
152 CAddonBase::m_interface->toKodi->kodiBase, newPassword.c_str(), &retString,
153 heading.c_str(), allowEmptyResult, autoCloseMs);
154 if (retString != nullptr)
155 {
156 newPassword = retString;
157 CAddonBase::m_interface->toKodi->free_string(CAddonBase::m_interface->toKodi->kodiBase,
158 retString);
159 }
160 return ret;
161}
162//------------------------------------------------------------------------------
163
164//==============================================================================
165/// @ingroup cpp_kodi_gui_dialogs_Keyboard
166/// @brief Shows keyboard and prompts for a password. Differs from
167/// `ShowAndVerifyNewPassword()` in that no second verification.
168///
169/// @param[in,out] newPassword Overwritten with user input if return=true.
170/// @param[in] autoCloseMs [opt] To close the dialog after a specified time, in
171/// milliseconds, default is 0 which keeps the dialog
172/// open indefinitely.
173/// @return true if successful display and user input. false if unsuccessful
174/// display, no user input, or canceled editing.
175///
176inline bool ATTRIBUTE_HIDDEN ShowAndGetNewPassword(std::string& newPassword,
177 unsigned int autoCloseMs = 0)
178{
179 using namespace ::kodi::addon;
180 char* retString = nullptr;
181 bool ret = CAddonBase::m_interface->toKodi->kodi_gui->dialogKeyboard->show_and_get_new_password(
182 CAddonBase::m_interface->toKodi->kodiBase, newPassword.c_str(), &retString, autoCloseMs);
183 if (retString != nullptr)
184 {
185 newPassword = retString;
186 CAddonBase::m_interface->toKodi->free_string(CAddonBase::m_interface->toKodi->kodiBase,
187 retString);
188 }
189 return ret;
190}
191//------------------------------------------------------------------------------
192
193//==============================================================================
194/// @ingroup cpp_kodi_gui_dialogs_Keyboard
195/// @brief Show keyboard twice to get and confirm a user-entered password
196/// string.
197///
198/// @param[out] newPassword Overwritten with user input if return=true.
199/// @param[in] heading String shown on dialog title.
200/// @param[in] allowEmptyResult
201/// @param[in] autoCloseMs [opt] To close the dialog after a specified time, in
202/// milliseconds, default is 0 which keeps the dialog
203/// open indefinitely.
204/// @return true if successful display and user input. false if unsuccessful
205/// display, no user input, or canceled editing.
206///
207///
208///-------------------------------------------------------------------------
209///
210/// **Example:**
211/// ~~~~~~~~~~~~~{.cpp}
212/// #include <kodi/General.h>
213/// #include <kodi/gui/dialogs/Keyboard.h>
214///
215/// // The example below shows the complete use of keyboard dialog for password
216/// // check. If only one check from add-on needed can be function with retries
217/// // set to '0' called alone.
218/// //
219/// // The use of MD5 translated password is always required for the check on Kodi!
220///
221/// int maxretries = 3;
222/// // Password names need to be send as md5 sum to kodi.
223/// std::string password;
224/// kodi::GetMD5("kodi", password);
225///
226/// // To the loop about password checks.
227/// int ret;
228/// for (unsigned int i = 0; i < maxretries; i++)
229/// {
230/// // Ask the user about the password.
231/// ret = ::kodi::gui::dialogs::Keyboard::ShowAndVerifyPassword(password, "Demo password call for PW 'kodi'", i, 0);
232/// if (ret == 0)
233/// {
234/// fprintf(stderr, "Password successfull confirmed after '%i' tries\n", i+1);
235/// break;
236/// }
237/// else if (ret < 0)
238/// {
239/// fprintf(stderr, "Canceled editing on try '%i'\n", i+1);
240/// break;
241/// }
242/// else // if (ret > 0)
243/// {
244/// fprintf(stderr, "Wrong password entered on try '%i'\n", i+1);
245/// }
246/// }
247/// ~~~~~~~~~~~~~
248///
249inline bool ATTRIBUTE_HIDDEN ShowAndVerifyNewPassword(std::string& newPassword,
250 const std::string& heading,
251 bool allowEmptyResult,
252 unsigned int autoCloseMs = 0)
253{
254 using namespace ::kodi::addon;
255 char* retString = nullptr;
256 bool ret = CAddonBase::m_interface->toKodi->kodi_gui->dialogKeyboard
257 ->show_and_verify_new_password_with_head(CAddonBase::m_interface->toKodi->kodiBase,
258 &retString, heading.c_str(),
259 allowEmptyResult, autoCloseMs);
260 if (retString != nullptr)
261 {
262 newPassword = retString;
263 CAddonBase::m_interface->toKodi->free_string(CAddonBase::m_interface->toKodi->kodiBase,
264 retString);
265 }
266 return ret;
267}
268//------------------------------------------------------------------------------
269
270//==============================================================================
271/// @ingroup cpp_kodi_gui_dialogs_Keyboard
272/// @brief Show keyboard twice to get and confirm a user-entered password
273/// string.
274///
275/// @param[out] newPassword Overwritten with user input if return=true.
276/// @param[in] autoCloseMs [opt] To close the dialog after a specified time, in
277/// milliseconds, default is 0 which keeps the dialog
278/// open indefinitely.
279/// @return true if successful display and user input. false if unsuccessful
280/// display, no user input, or canceled editing.
281///
282inline bool ATTRIBUTE_HIDDEN ShowAndVerifyNewPassword(std::string& newPassword,
283 unsigned int autoCloseMs = 0)
284{
285 using namespace ::kodi::addon;
286 char* retString = nullptr;
287 bool ret =
288 CAddonBase::m_interface->toKodi->kodi_gui->dialogKeyboard->show_and_verify_new_password(
289 CAddonBase::m_interface->toKodi->kodiBase, &retString, autoCloseMs);
290 if (retString != nullptr)
291 {
292 newPassword = retString;
293 CAddonBase::m_interface->toKodi->free_string(CAddonBase::m_interface->toKodi->kodiBase,
294 retString);
295 }
296 return ret;
297}
298//------------------------------------------------------------------------------
299
300//==============================================================================
301/// @ingroup cpp_kodi_gui_dialogs_Keyboard
302/// @brief Show keyboard and verify user input against `password`.
303///
304/// @param[in,out] password Value to compare against user input.
305/// @param[in] heading String shown on dialog title.
306/// @param[in] retries If greater than 0, shows "Incorrect password, %d retries
307/// left" on dialog line 2, else line 2 is blank.
308/// @param[in] autoCloseMs [opt] To close the dialog after a specified time, in
309/// milliseconds, default is 0 which keeps the dialog
310/// open indefinitely.
311/// @return 0 if successful display and user input. 1 if unsuccessful input.
312/// -1 if no user input or canceled editing.
313///
314inline int ATTRIBUTE_HIDDEN ShowAndVerifyPassword(std::string& password,
315 const std::string& heading,
316 int retries,
317 unsigned int autoCloseMs = 0)
318{
319 using namespace ::kodi::addon;
320 char* retString = nullptr;
321 int ret = CAddonBase::m_interface->toKodi->kodi_gui->dialogKeyboard->show_and_verify_password(
322 CAddonBase::m_interface->toKodi->kodiBase, password.c_str(), &retString, heading.c_str(),
323 retries, autoCloseMs);
324 if (retString != nullptr)
325 {
326 password = retString;
327 CAddonBase::m_interface->toKodi->free_string(CAddonBase::m_interface->toKodi->kodiBase,
328 retString);
329 }
330 return ret;
331}
332//------------------------------------------------------------------------------
333
334//==============================================================================
335/// @ingroup cpp_kodi_gui_dialogs_Keyboard
336/// @brief Shows a filter related keyboard.
337///
338/// @param[in,out] text Overwritten with user input if return=true.
339/// @param[in] searching Use dialog for search and send our search message in
340/// safe way (only the active window needs it)
341/// - header name if true is "Enter search string"
342/// - header name if false is "Enter value"
343/// @param autoCloseMs [opt] To close the dialog after a specified time, in
344/// milliseconds, default is 0 which keeps the dialog open
345/// indefinitely.
346/// @return true if successful display and user input. false if unsuccessful
347/// display, no user input, or canceled editing.
348///
349inline bool ATTRIBUTE_HIDDEN ShowAndGetFilter(std::string& text,
350 bool searching,
351 unsigned int autoCloseMs = 0)
352{
353 using namespace ::kodi::addon;
354 char* retString = nullptr;
355 bool ret = CAddonBase::m_interface->toKodi->kodi_gui->dialogKeyboard->show_and_get_filter(
356 CAddonBase::m_interface->toKodi->kodiBase, text.c_str(), &retString, searching, autoCloseMs);
357 if (retString != nullptr)
358 {
359 text = retString;
360 CAddonBase::m_interface->toKodi->free_string(CAddonBase::m_interface->toKodi->kodiBase,
361 retString);
362 }
363 return ret;
364}
365//------------------------------------------------------------------------------
366
367//==============================================================================
368/// @ingroup cpp_kodi_gui_dialogs_Keyboard
369/// @brief Send a text to a visible keyboard.
370///
371/// @param[in] text Overwritten with user input if return=true.
372/// @param[in] closeKeyboard [opt] The open dialog is if also closed on 'true'.
373/// @return true if successful done, false if unsuccessful or keyboard not
374/// present.
375///
376inline bool ATTRIBUTE_HIDDEN SendTextToActiveKeyboard(const std::string& text,
377 bool closeKeyboard = false)
378{
379 using namespace ::kodi::addon;
380 return CAddonBase::m_interface->toKodi->kodi_gui->dialogKeyboard->send_text_to_active_keyboard(
381 CAddonBase::m_interface->toKodi->kodiBase, text.c_str(), closeKeyboard);
382}
383//------------------------------------------------------------------------------
384
385//==============================================================================
386/// @ingroup cpp_kodi_gui_dialogs_Keyboard
387/// @brief Check for visible keyboard on GUI.
388///
389/// @return true if keyboard present, false if not present
390///
391inline bool ATTRIBUTE_HIDDEN IsKeyboardActivated()
392{
393 using namespace ::kodi::addon;
394 return CAddonBase::m_interface->toKodi->kodi_gui->dialogKeyboard->is_keyboard_activated(
395 CAddonBase::m_interface->toKodi->kodiBase);
396}
397//------------------------------------------------------------------------------
398}; // namespace Keyboard
399
400} /* namespace dialogs */
401} /* namespace gui */
402} /* namespace kodi */
403
404#endif /* __cplusplus */
diff --git a/xbmc/addons/kodi-dev-kit/include/kodi/gui/dialogs/Numeric.h b/xbmc/addons/kodi-dev-kit/include/kodi/gui/dialogs/Numeric.h
new file mode 100644
index 0000000..835a8d4
--- /dev/null
+++ b/xbmc/addons/kodi-dev-kit/include/kodi/gui/dialogs/Numeric.h
@@ -0,0 +1,346 @@
1/*
2 * Copyright (C) 2005-2018 Team Kodi
3 * This file is part of Kodi - https://kodi.tv
4 *
5 * SPDX-License-Identifier: GPL-2.0-or-later
6 * See LICENSES/README.md for more information.
7 */
8
9#pragma once
10
11#include "../../AddonBase.h"
12#include "../../c-api/gui/dialogs/numeric.h"
13
14#ifdef __cplusplus
15
16namespace kodi
17{
18namespace gui
19{
20namespace dialogs
21{
22
23//==============================================================================
24/// @defgroup cpp_kodi_gui_dialogs_Numeric Dialog Numeric
25/// @ingroup cpp_kodi_gui_dialogs
26/// @{
27/// @brief @cpp_namespace{ kodi::gui::dialogs::Numeric }
28/// **Numeric dialogs**\n
29/// The functions listed below have to be permitted by the user for the
30/// representation of a numeric keyboard around an input.
31///
32/// The class supports several kinds, from an easy number choice up to the
33/// passport Word production and their confirmation for add-on.
34///
35/// It has the header @ref Numeric.h "#include <kodi/gui/dialogs/Numeric.h>"
36/// be included to enjoy it.
37///
38namespace Numeric
39{
40//==============================================================================
41/// @ingroup cpp_kodi_gui_dialogs_Numeric
42/// @brief Use dialog to get numeric new password
43///
44/// @param[out] newPassword String to preload into the keyboard accumulator.
45/// Overwritten with user input if return=true.
46/// Returned in MD5 format.
47/// @return true if successful display and user input entry/re-entry. false if
48/// unsuccessful display, no user input, or canceled editing.
49///
50inline bool ATTRIBUTE_HIDDEN ShowAndVerifyNewPassword(std::string& newPassword)
51{
52 using namespace ::kodi::addon;
53 char* pw = nullptr;
54 bool ret = CAddonBase::m_interface->toKodi->kodi_gui->dialogNumeric->show_and_verify_new_password(
55 CAddonBase::m_interface->toKodi->kodiBase, &pw);
56 if (pw != nullptr)
57 {
58 newPassword = pw;
59 CAddonBase::m_interface->toKodi->free_string(CAddonBase::m_interface->toKodi->kodiBase, pw);
60 }
61 return ret;
62}
63//------------------------------------------------------------------------------
64
65//==============================================================================
66///
67/// @ingroup cpp_kodi_gui_dialogs_Numeric
68/// @brief Use dialog to verify numeric password.
69///
70/// @param[in] password Password to compare with user input, need
71/// in MD5 format.
72/// @param[in] heading Heading to display
73/// @param[in] retries If greater than 0, shows "Incorrect
74/// password, %d retries left" on dialog
75/// line 2, else line 2 is blank.
76/// @return Possible values:
77/// - 0 if successful display and user input.
78/// - 1 if unsuccessful input.
79/// - -1 if no user input or canceled editing.
80///
81///
82///-------------------------------------------------------------------------
83///
84/// **Example:**
85/// ~~~~~~~~~~~~~{.cpp}
86/// #include <stdio.h> // fprintf
87/// #include <kodi/General.h>
88/// #include <kodi/gui/dialogs/Numeric.h>
89///
90/// // The example below shows the complete use of keyboard dialog for password
91/// // check. If only one check from add-on needed can be function with retries
92/// // set to '0' called alone.
93/// //
94/// // The use of MD5 translated password is always required for the check on Kodi!
95///
96/// int maxretries = 3;
97///
98/// // Password names need to be send as md5 sum to kodi.
99/// std::string password = kodi::GetMD5("1234");
100///
101/// // To the loop about password checks.
102/// int ret;
103/// for (unsigned int i = 0; i < maxretries; i++)
104/// {
105/// // Ask the user about the password.
106/// ret = kodi::gui::dialogs::Numeric::ShowAndVerifyPassword(password, "Demo numeric password call for PW '1234'", i);
107/// if (ret == 0)
108/// {
109/// fprintf(stderr, "Numeric password successfull confirmed after '%i' tries\n", i+1);
110/// break;
111/// }
112/// else if (ret < 0)
113/// {
114/// fprintf(stderr, "Canceled editing on try '%i'\n", i+1);
115/// break;
116/// }
117/// else // if (ret > 0)
118/// {
119/// fprintf(stderr, "Wrong numeric password entered on try '%i'\n", i+1);
120/// }
121/// }
122/// ~~~~~~~~~~~~~
123///
124inline int ATTRIBUTE_HIDDEN ShowAndVerifyPassword(const std::string& password,
125 const std::string& heading,
126 int retries)
127{
128 using namespace ::kodi::addon;
129 return CAddonBase::m_interface->toKodi->kodi_gui->dialogNumeric->show_and_verify_password(
130 CAddonBase::m_interface->toKodi->kodiBase, password.c_str(), heading.c_str(), retries);
131}
132//------------------------------------------------------------------------------
133
134//==============================================================================
135/// @ingroup cpp_kodi_gui_dialogs_Numeric
136/// @brief Use dialog to verify numeric password
137///
138/// @param[in,out] toVerify Value to compare against user input.
139/// @param[in] heading Heading to display
140/// @param[in] verifyInput If set as true we verify the users input versus
141/// toVerify.
142/// @return true if successful display and user input. false if unsuccessful
143/// display, no user input, or canceled editing.
144///
145inline bool ATTRIBUTE_HIDDEN ShowAndVerifyInput(std::string& toVerify,
146 const std::string& heading,
147 bool verifyInput)
148{
149 using namespace ::kodi::addon;
150 char* retString = nullptr;
151 bool ret = CAddonBase::m_interface->toKodi->kodi_gui->dialogNumeric->show_and_verify_input(
152 CAddonBase::m_interface->toKodi->kodiBase, toVerify.c_str(), &retString, heading.c_str(),
153 verifyInput);
154 if (retString != nullptr)
155 {
156 toVerify = retString;
157 CAddonBase::m_interface->toKodi->free_string(CAddonBase::m_interface->toKodi->kodiBase,
158 retString);
159 }
160 return ret;
161}
162//------------------------------------------------------------------------------
163
164//==============================================================================
165/// @ingroup cpp_kodi_gui_dialogs_Numeric
166/// @brief Use dialog to get time value.
167///
168/// @param[out] time Overwritten with user input if return=true and time
169/// inserted.
170/// @param[in] heading Heading to display.
171/// @return true if successful display and user input. false if unsuccessful
172/// display, no user input, or canceled editing.
173///
174///
175///-------------------------------------------------------------------------
176///
177/// **Example:**
178/// ~~~~~~~~~~~~~{.cpp}
179/// #include <stdio.h> // printf
180/// #include <time.h> // time_t, struct tm, time, localtime, strftime
181/// #include <kodi/gui/dialogs/Numeric.h>
182///
183/// time_t rawtime;
184/// struct tm * timeinfo;
185/// char buffer [10];
186///
187/// time (&rawtime);
188/// timeinfo = localtime(&rawtime);
189/// bool bRet = kodi::gui::dialogs::Numeric::ShowAndGetTime(*timeinfo, "Selected time test call");
190/// strftime(buffer, sizeof(buffer), "%H:%M.", timeinfo);
191/// printf("Selected time it's %s and was on Dialog %s\n", buffer, bRet ? "OK" : "Canceled");
192/// ~~~~~~~~~~~~~
193///
194inline bool ATTRIBUTE_HIDDEN ShowAndGetTime(tm& time, const std::string& heading)
195{
196 using namespace ::kodi::addon;
197 return CAddonBase::m_interface->toKodi->kodi_gui->dialogNumeric->show_and_get_time(
198 CAddonBase::m_interface->toKodi->kodiBase, &time, heading.c_str());
199}
200//------------------------------------------------------------------------------
201
202//==============================================================================
203/// @ingroup cpp_kodi_gui_dialogs_Numeric
204/// @brief Use dialog to get date value.
205///
206/// @param[in,out] date Overwritten with user input if return=true and date
207/// inserted.
208/// @param[in] heading Heading to display
209/// @return true if successful display and user input. false if unsuccessful
210/// display, no user input, or canceled editing.
211///
212///
213///-------------------------------------------------------------------------
214///
215/// **Example:**
216/// ~~~~~~~~~~~~~{.cpp}
217/// #include <stdio.h> // printf
218/// #include <time.h> // time_t, struct tm, time, localtime, strftime
219/// #include <kodi/gui/dialogs/Numeric.h>
220///
221/// time_t rawtime;
222/// struct tm * timeinfo;
223/// char buffer [20];
224///
225/// time (&rawtime);
226/// timeinfo = localtime(&rawtime);
227/// bool bRet = kodi::gui::dialogs::Numeric::ShowAndGetDate(*timeinfo, "Selected date test call");
228/// strftime(buffer, sizeof(buffer), "%Y-%m-%d", timeinfo);
229/// printf("Selected date it's %s and was on Dialog %s\n", buffer, bRet ? "OK" : "Canceled");
230/// ~~~~~~~~~~~~~
231///
232inline bool ATTRIBUTE_HIDDEN ShowAndGetDate(tm& date, const std::string& heading)
233{
234 using namespace ::kodi::addon;
235 return CAddonBase::m_interface->toKodi->kodi_gui->dialogNumeric->show_and_get_date(
236 CAddonBase::m_interface->toKodi->kodiBase, &date, heading.c_str());
237}
238//------------------------------------------------------------------------------
239
240//==============================================================================
241/// @ingroup cpp_kodi_gui_dialogs_Numeric
242/// @brief Use dialog to get a IP
243///
244/// @param[in,out] ipAddress Overwritten with user input if return=true and
245/// IP address inserted.
246/// @param[in] heading Heading to display.
247/// @return true if successful display and user input. false if unsuccessful
248/// display, no user input, or canceled editing.
249///
250inline bool ATTRIBUTE_HIDDEN ShowAndGetIPAddress(std::string& ipAddress, const std::string& heading)
251{
252 using namespace ::kodi::addon;
253 char* retString = nullptr;
254 bool ret = CAddonBase::m_interface->toKodi->kodi_gui->dialogNumeric->show_and_get_ip_address(
255 CAddonBase::m_interface->toKodi->kodiBase, ipAddress.c_str(), &retString, heading.c_str());
256 if (retString != nullptr)
257 {
258 ipAddress = retString;
259 CAddonBase::m_interface->toKodi->free_string(CAddonBase::m_interface->toKodi->kodiBase,
260 retString);
261 }
262 return ret;
263}
264//------------------------------------------------------------------------------
265
266//==============================================================================
267/// @ingroup cpp_kodi_gui_dialogs_Numeric
268/// @brief Use dialog to get normal number.
269///
270/// @param[in,out] input Overwritten with user input if return=true and time
271/// in seconds inserted
272/// @param[in] heading Heading to display
273/// @param[in] autoCloseTimeoutMs [opt] To close the dialog after a specified
274/// time, in milliseconds, default is 0
275/// which keeps the dialog open
276/// indefinitely.
277/// @return true if successful display and user input. false if unsuccessful
278/// display, no user input, or canceled editing.
279///
280///
281///-------------------------------------------------------------------------
282///
283/// **Example:**
284/// ~~~~~~~~~~~~~{.cpp}
285/// #include <stdio.h> // printf
286/// #include <stdlib.h> // strtoull (C++11)
287/// #include <kodi/gui/dialogs/Numeric.h>
288///
289/// std::string number;
290/// bool bRet = kodi::gui::dialogs::Numeric::ShowAndGetNumber(number, "Number test call");
291/// printf("Written number input is : %llu and was %s\n",
292/// strtoull(number.c_str(), nullptr, 0), bRet ? "OK" : "Canceled");
293/// ~~~~~~~~~~~~~
294///
295inline bool ATTRIBUTE_HIDDEN ShowAndGetNumber(std::string& input,
296 const std::string& heading,
297 unsigned int autoCloseTimeoutMs = 0)
298{
299 using namespace ::kodi::addon;
300 char* retString = nullptr;
301 bool ret = CAddonBase::m_interface->toKodi->kodi_gui->dialogNumeric->show_and_get_number(
302 CAddonBase::m_interface->toKodi->kodiBase, input.c_str(), &retString, heading.c_str(),
303 autoCloseTimeoutMs);
304 if (retString != nullptr)
305 {
306 input = retString;
307 CAddonBase::m_interface->toKodi->free_string(CAddonBase::m_interface->toKodi->kodiBase,
308 retString);
309 }
310 return ret;
311}
312//------------------------------------------------------------------------------
313
314//==============================================================================
315/// @ingroup cpp_kodi_gui_dialogs_Numeric
316/// @brief Show numeric keypad to get seconds.
317///
318/// @param[in,out] time Overwritten with user input if return=true and time
319/// in seconds inserted.
320/// @param[in] heading Heading to display
321/// @return true if successful display and user input. false if unsuccessful
322/// display, no user input, or canceled editing.
323///
324inline bool ATTRIBUTE_HIDDEN ShowAndGetSeconds(std::string& time, const std::string& heading)
325{
326 using namespace ::kodi::addon;
327 char* retString = nullptr;
328 bool ret = CAddonBase::m_interface->toKodi->kodi_gui->dialogNumeric->show_and_get_seconds(
329 CAddonBase::m_interface->toKodi->kodiBase, time.c_str(), &retString, heading.c_str());
330 if (retString != nullptr)
331 {
332 time = retString;
333 CAddonBase::m_interface->toKodi->free_string(CAddonBase::m_interface->toKodi->kodiBase,
334 retString);
335 }
336 return ret;
337}
338//------------------------------------------------------------------------------
339}; // namespace Numeric
340/// @}
341
342} /* namespace dialogs */
343} /* namespace gui */
344} /* namespace kodi */
345
346#endif /* __cplusplus */
diff --git a/xbmc/addons/kodi-dev-kit/include/kodi/gui/dialogs/OK.h b/xbmc/addons/kodi-dev-kit/include/kodi/gui/dialogs/OK.h
new file mode 100644
index 0000000..747ab9d
--- /dev/null
+++ b/xbmc/addons/kodi-dev-kit/include/kodi/gui/dialogs/OK.h
@@ -0,0 +1,101 @@
1/*
2 * Copyright (C) 2005-2018 Team Kodi
3 * This file is part of Kodi - https://kodi.tv
4 *
5 * SPDX-License-Identifier: GPL-2.0-or-later
6 * See LICENSES/README.md for more information.
7 */
8
9#pragma once
10
11#include "../../AddonBase.h"
12#include "../../c-api/gui/dialogs/ok.h"
13
14#ifdef __cplusplus
15
16namespace kodi
17{
18namespace gui
19{
20namespace dialogs
21{
22
23//==============================================================================
24/// @defgroup cpp_kodi_gui_dialogs_OK Dialog OK
25/// @ingroup cpp_kodi_gui_dialogs
26/// @{
27/// @brief @cpp_namespace{ kodi::gui::dialogs::OK }
28/// **OK dialog**\n
29/// The functions listed below permit the call of a dialogue of information, a
30/// confirmation of the user by press from OK required.
31///
32/// It has the header @ref OK.h "#include <kodi/gui/dialogs/OK.h>"
33/// be included to enjoy it.
34///
35namespace OK
36{
37//==============================================================================
38/// @ingroup cpp_kodi_gui_dialogs_OK
39/// @brief Use dialog to inform user with text and confirmation with OK with
40/// continued string.
41///
42/// @param[in] heading Dialog heading.
43/// @param[in] text Multi-line text.
44///
45///
46///-------------------------------------------------------------------------
47///
48/// **Example:**
49/// ~~~~~~~~~~~~~{.cpp}
50/// #include <kodi/gui/dialogs/OK.h>
51/// ...
52/// kodi::gui::dialogs::OK::ShowAndGetInput("Test dialog", "Hello World!\nI'm a call from add-on\n :) :D");
53/// ~~~~~~~~~~~~~
54///
55inline void ATTRIBUTE_HIDDEN ShowAndGetInput(const std::string& heading, const std::string& text)
56{
57 using namespace ::kodi::addon;
58 CAddonBase::m_interface->toKodi->kodi_gui->dialogOK->show_and_get_input_single_text(
59 CAddonBase::m_interface->toKodi->kodiBase, heading.c_str(), text.c_str());
60}
61//------------------------------------------------------------------------------
62
63//==============================================================================
64/// @ingroup cpp_kodi_gui_dialogs_OK
65/// @brief Use dialog to inform user with text and confirmation with OK with
66/// strings separated to the lines.
67///
68/// @param[in] heading Dialog heading.
69/// @param[in] line0 Line #1 text.
70/// @param[in] line1 Line #2 text.
71/// @param[in] line2 Line #3 text.
72///
73///
74///-------------------------------------------------------------------------
75///
76/// **Example:**
77/// ~~~~~~~~~~~~~{.cpp}
78/// #include <kodi/gui/dialogs/OK.h>
79/// ...
80/// kodi::gui::dialogs::OK::ShowAndGetInput("Test dialog", "Hello World!", "I'm a call from add-on", " :) :D");
81/// ~~~~~~~~~~~~~
82///
83inline void ATTRIBUTE_HIDDEN ShowAndGetInput(const std::string& heading,
84 const std::string& line0,
85 const std::string& line1,
86 const std::string& line2)
87{
88 using namespace ::kodi::addon;
89 CAddonBase::m_interface->toKodi->kodi_gui->dialogOK->show_and_get_input_line_text(
90 CAddonBase::m_interface->toKodi->kodiBase, heading.c_str(), line0.c_str(), line1.c_str(),
91 line2.c_str());
92}
93//------------------------------------------------------------------------------
94} // namespace OK
95/// @}
96
97} /* namespace dialogs */
98} /* namespace gui */
99} /* namespace kodi */
100
101#endif /* __cplusplus */
diff --git a/xbmc/addons/kodi-dev-kit/include/kodi/gui/dialogs/Progress.h b/xbmc/addons/kodi-dev-kit/include/kodi/gui/dialogs/Progress.h
new file mode 100644
index 0000000..d242a56
--- /dev/null
+++ b/xbmc/addons/kodi-dev-kit/include/kodi/gui/dialogs/Progress.h
@@ -0,0 +1,244 @@
1/*
2 * Copyright (C) 2005-2018 Team Kodi
3 * This file is part of Kodi - https://kodi.tv
4 *
5 * SPDX-License-Identifier: GPL-2.0-or-later
6 * See LICENSES/README.md for more information.
7 */
8
9#pragma once
10
11#include "../../AddonBase.h"
12#include "../../c-api/gui/dialogs/progress.h"
13
14#ifdef __cplusplus
15
16namespace kodi
17{
18namespace gui
19{
20namespace dialogs
21{
22
23//==============================================================================
24/// @defgroup cpp_kodi_gui_dialogs_CProgress Dialog Progress
25/// @ingroup cpp_kodi_gui_dialogs
26/// @brief @cpp_class{ kodi::gui::dialogs::CProgress }
27/// **Progress dialog shown in center**\n
28/// The with @ref Progress.h "#include <kodi/gui/dialogs/Progress.h>"
29/// given class are basically used to create Kodi's progress dialog with named
30/// text fields.
31///
32/// **Example:**
33/// ~~~~~~~~~~~~~{.cpp}
34/// #include <kodi/gui/dialogs/Progress.h>
35///
36/// kodi::gui::dialogs::CProgress *progress = new kodi::gui::dialogs::CProgress;
37/// progress->SetHeading("Test progress");
38/// progress->SetLine(1, "line 1");
39/// progress->SetLine(2, "line 2");
40/// progress->SetLine(3, "line 3");
41/// progress->SetCanCancel(true);
42/// progress->ShowProgressBar(true);
43/// progress->Open();
44/// for (unsigned int i = 0; i < 100; i += 10)
45/// {
46/// progress->SetPercentage(i);
47/// sleep(1);
48/// }
49/// delete progress;
50/// ~~~~~~~~~~~~~
51///
52class ATTRIBUTE_HIDDEN CProgress
53{
54public:
55 //============================================================================
56 /// @ingroup cpp_kodi_gui_dialogs_CProgress
57 /// @brief Construct a new dialog
58 ///
59 CProgress()
60 {
61 using namespace ::kodi::addon;
62 m_DialogHandle = CAddonBase::m_interface->toKodi->kodi_gui->dialogProgress->new_dialog(
63 CAddonBase::m_interface->toKodi->kodiBase);
64 if (!m_DialogHandle)
65 kodi::Log(ADDON_LOG_FATAL,
66 "kodi::gui::dialogs::CProgress can't create window class from Kodi !!!");
67 }
68 //----------------------------------------------------------------------------
69
70 //============================================================================
71 /// @ingroup cpp_kodi_gui_dialogs_CProgress
72 /// @brief Destructor
73 ///
74 ~CProgress()
75 {
76 using namespace ::kodi::addon;
77 if (m_DialogHandle)
78 CAddonBase::m_interface->toKodi->kodi_gui->dialogProgress->delete_dialog(
79 CAddonBase::m_interface->toKodi->kodiBase, m_DialogHandle);
80 }
81 //----------------------------------------------------------------------------
82
83 //============================================================================
84 /// @ingroup cpp_kodi_gui_dialogs_CProgress
85 /// @brief To open the dialog
86 ///
87 void Open()
88 {
89 using namespace ::kodi::addon;
90 CAddonBase::m_interface->toKodi->kodi_gui->dialogProgress->open(
91 CAddonBase::m_interface->toKodi->kodiBase, m_DialogHandle);
92 }
93 //----------------------------------------------------------------------------
94
95 //============================================================================
96 /// @ingroup cpp_kodi_gui_dialogs_CProgress
97 /// @brief Set the heading title of dialog
98 ///
99 /// @param[in] heading Title string to use
100 ///
101 void SetHeading(const std::string& heading)
102 {
103 using namespace ::kodi::addon;
104 CAddonBase::m_interface->toKodi->kodi_gui->dialogProgress->set_heading(
105 CAddonBase::m_interface->toKodi->kodiBase, m_DialogHandle, heading.c_str());
106 }
107 //----------------------------------------------------------------------------
108
109 //============================================================================
110 /// @ingroup cpp_kodi_gui_dialogs_CProgress
111 /// @brief To set the line text field on dialog from 0 - 2
112 ///
113 /// @param[in] iLine Line number
114 /// @param[in] line Text string
115 ///
116 void SetLine(unsigned int iLine, const std::string& line)
117 {
118 using namespace ::kodi::addon;
119 CAddonBase::m_interface->toKodi->kodi_gui->dialogProgress->set_line(
120 CAddonBase::m_interface->toKodi->kodiBase, m_DialogHandle, iLine, line.c_str());
121 }
122 //----------------------------------------------------------------------------
123
124 //============================================================================
125 /// @ingroup cpp_kodi_gui_dialogs_CProgress
126 /// @brief To enable and show cancel button on dialog
127 ///
128 /// @param[in] canCancel if true becomes it shown
129 ///
130 void SetCanCancel(bool canCancel)
131 {
132 using namespace ::kodi::addon;
133 CAddonBase::m_interface->toKodi->kodi_gui->dialogProgress->set_can_cancel(
134 CAddonBase::m_interface->toKodi->kodiBase, m_DialogHandle, canCancel);
135 }
136 //----------------------------------------------------------------------------
137
138 //============================================================================
139 /// @ingroup cpp_kodi_gui_dialogs_CProgress
140 /// @brief To check dialog for clicked cancel button
141 ///
142 /// @return True if canceled
143 ///
144 bool IsCanceled() const
145 {
146 using namespace ::kodi::addon;
147 return CAddonBase::m_interface->toKodi->kodi_gui->dialogProgress->is_canceled(
148 CAddonBase::m_interface->toKodi->kodiBase, m_DialogHandle);
149 }
150 //----------------------------------------------------------------------------
151
152 //============================================================================
153 /// @ingroup cpp_kodi_gui_dialogs_CProgress
154 /// @brief Get the current progress position as percent
155 ///
156 /// @param[in] percentage Position to use from 0 to 100
157 ///
158 void SetPercentage(int percentage)
159 {
160 using namespace ::kodi::addon;
161 CAddonBase::m_interface->toKodi->kodi_gui->dialogProgress->set_percentage(
162 CAddonBase::m_interface->toKodi->kodiBase, m_DialogHandle, percentage);
163 }
164 //----------------------------------------------------------------------------
165
166 //============================================================================
167 /// @ingroup cpp_kodi_gui_dialogs_CProgress
168 /// @brief To set the current progress position as percent
169 ///
170 /// @return Current Position used from 0 to 100
171 ///
172 int GetPercentage() const
173 {
174 using namespace ::kodi::addon;
175 return CAddonBase::m_interface->toKodi->kodi_gui->dialogProgress->get_percentage(
176 CAddonBase::m_interface->toKodi->kodiBase, m_DialogHandle);
177 }
178 //----------------------------------------------------------------------------
179
180 //============================================================================
181 /// @ingroup cpp_kodi_gui_dialogs_CProgress
182 /// @brief To show or hide progress bar dialog
183 ///
184 /// @param[in] onOff If true becomes it shown
185 ///
186 void ShowProgressBar(bool onOff)
187 {
188 using namespace ::kodi::addon;
189 CAddonBase::m_interface->toKodi->kodi_gui->dialogProgress->show_progress_bar(
190 CAddonBase::m_interface->toKodi->kodiBase, m_DialogHandle, onOff);
191 }
192 //----------------------------------------------------------------------------
193
194 //============================================================================
195 /// @ingroup cpp_kodi_gui_dialogs_CProgress
196 /// @brief Set the maximum position of progress, needed if `SetProgressAdvance(...)` is used
197 ///
198 /// @param[in] max Biggest usable position to use
199 ///
200 void SetProgressMax(int max)
201 {
202 using namespace ::kodi::addon;
203 CAddonBase::m_interface->toKodi->kodi_gui->dialogProgress->set_progress_max(
204 CAddonBase::m_interface->toKodi->kodiBase, m_DialogHandle, max);
205 }
206 //----------------------------------------------------------------------------
207
208 //============================================================================
209 /// @ingroup cpp_kodi_gui_dialogs_CProgress
210 /// @brief To increase progress bar by defined step size until reach of maximum position
211 ///
212 /// @param[in] steps Step size to increase, default is 1
213 ///
214 void SetProgressAdvance(int steps = 1)
215 {
216 using namespace ::kodi::addon;
217 CAddonBase::m_interface->toKodi->kodi_gui->dialogProgress->set_progress_advance(
218 CAddonBase::m_interface->toKodi->kodiBase, m_DialogHandle, steps);
219 }
220 //----------------------------------------------------------------------------
221
222 //============================================================================
223 /// @ingroup cpp_kodi_gui_dialogs_CProgress
224 /// @brief To check progress was canceled on work
225 ///
226 /// @return True if aborted
227 ///
228 bool Abort()
229 {
230 using namespace ::kodi::addon;
231 return CAddonBase::m_interface->toKodi->kodi_gui->dialogProgress->abort(
232 CAddonBase::m_interface->toKodi->kodiBase, m_DialogHandle);
233 }
234 //----------------------------------------------------------------------------
235
236private:
237 KODI_GUI_HANDLE m_DialogHandle;
238};
239
240} /* namespace dialogs */
241} /* namespace gui */
242} /* namespace kodi */
243
244#endif /* __cplusplus */
diff --git a/xbmc/addons/kodi-dev-kit/include/kodi/gui/dialogs/Select.h b/xbmc/addons/kodi-dev-kit/include/kodi/gui/dialogs/Select.h
new file mode 100644
index 0000000..9b1923e
--- /dev/null
+++ b/xbmc/addons/kodi-dev-kit/include/kodi/gui/dialogs/Select.h
@@ -0,0 +1,269 @@
1/*
2 * Copyright (C) 2005-2018 Team Kodi
3 * This file is part of Kodi - https://kodi.tv
4 *
5 * SPDX-License-Identifier: GPL-2.0-or-later
6 * See LICENSES/README.md for more information.
7 */
8
9#pragma once
10
11#include "../../AddonBase.h"
12#include "../../c-api/gui/dialogs/select.h"
13
14#ifdef __cplusplus
15
16namespace kodi
17{
18namespace gui
19{
20namespace dialogs
21{
22
23//==============================================================================
24/// @defgroup cpp_kodi_gui_dialogs_Select_Defs Definitions, structures and enumerators
25/// @ingroup cpp_kodi_gui_dialogs_Select
26/// @brief **Dialog Select definition values**\n
27/// Data structures associated with this dialog.
28///
29//------------------------------------------------------------------------------
30
31//==============================================================================
32/// @ingroup cpp_kodi_gui_dialogs_Select_Defs
33/// @brief **Selection entry structure**\n
34/// Used to provide the necessary data for the selection dialog and to declare
35/// the selected position in it.
36///
37typedef struct SSelectionEntry
38{
39 /*! \cond PRIVATE */
40 SSelectionEntry() = default;
41 /*! \endcond */
42
43 /// Entry identfication string
44 std::string id;
45
46 /// Entry name to show on GUI dialog
47 std::string name;
48
49 /// Place where entry can be preselected and after return the from user
50 /// selected is set.
51 bool selected = false;
52} SSelectionEntry;
53//------------------------------------------------------------------------------
54
55//==============================================================================
56/// @defgroup cpp_kodi_gui_dialogs_Select Dialog Select
57/// @ingroup cpp_kodi_gui_dialogs
58/// @{
59/// @brief @cpp_namespace{ kodi::gui::dialogs::Select }
60/// **Selection dialog**\n
61/// The function listed below permits the call of a dialogue to select of an
62/// entry as a key
63///
64/// It has the header @ref Select.h "#include <kodi/gui/dialogs/Select.h>"
65/// be included to enjoy it.
66///
67///
68namespace Select
69{
70//==============================================================================
71/// @ingroup cpp_kodi_gui_dialogs_Select
72/// @brief Show a selection dialog about given parts.
73///
74/// @param[in] heading Dialog heading name
75/// @param[in] entries String list about entries
76/// @param[in] selected [opt] Predefined selection (default is <tt>-1</tt> for
77/// the first)
78/// @param[in] autoclose [opt] To close dialog automatic after the given time
79/// in ms. As '0' it stays open.
80/// @return The selected entry, if return <tt>-1</tt> was nothing selected or
81/// canceled
82///
83///
84///-------------------------------------------------------------------------
85///
86/// **Example:**
87/// ~~~~~~~~~~~~~{.cpp}
88/// #include <kodi/gui/dialogs/Select.h>
89///
90/// const std::vector<std::string> entries
91/// {
92/// "Test 1",
93/// "Test 2",
94/// "Test 3",
95/// "Test 4",
96/// "Test 5"
97/// };
98///
99/// int selected = kodi::gui::dialogs::Select::Show("Test selection", entries, -1);
100/// if (selected < 0)
101/// fprintf(stderr, "Item selection canceled\n");
102/// else
103/// fprintf(stderr, "Selected item is: %i\n", selected);
104/// ~~~~~~~~~~~~~
105///
106inline int ATTRIBUTE_HIDDEN Show(const std::string& heading,
107 const std::vector<std::string>& entries,
108 int selected = -1,
109 unsigned int autoclose = 0)
110{
111 using namespace ::kodi::addon;
112 unsigned int size = static_cast<unsigned int>(entries.size());
113 const char** cEntries = (const char**)malloc(size * sizeof(const char**));
114 for (unsigned int i = 0; i < size; ++i)
115 {
116 cEntries[i] = entries[i].c_str();
117 }
118 int ret = CAddonBase::m_interface->toKodi->kodi_gui->dialogSelect->open(
119 CAddonBase::m_interface->toKodi->kodiBase, heading.c_str(), cEntries, size, selected,
120 autoclose);
121 free(cEntries);
122 return ret;
123}
124//------------------------------------------------------------------------------
125
126//==============================================================================
127/// @ingroup cpp_kodi_gui_dialogs_Select
128/// @brief Show a selection dialog about given parts.
129///
130/// This function is mostly equal to the other, only becomes the string list
131/// here done by a @ref SSelectionEntry, where a ID string can be defined.
132///
133/// @param[in] heading Dialog heading name
134/// @param[in] entries @ref SSelectionEntry list about entries
135/// @param[in] selected [opt] Predefined selection (default is <tt>-1</tt> for
136/// the first)
137/// @param[in] autoclose [opt] To close dialog automatic after the given time
138/// in ms. As '0' it stays open.
139/// @return The selected entry, if return <tt>-1</tt> was nothing selected
140/// or canceled
141///
142///
143///-------------------------------------------------------------------------
144///
145/// **Example:**
146/// ~~~~~~~~~~~~~{.cpp}
147/// #include <kodi/gui/dialogs/Select.h>
148///
149/// std::vector<kodi::gui::dialogs::SSelectionEntry> entries
150/// {
151/// { "ID 1", "Test 1", false },
152/// { "ID 2", "Test 2", false },
153/// { "ID 3", "Test 3", false },
154/// { "ID 4", "Test 4", false },
155/// { "ID 5", "Test 5", false }
156/// };
157///
158/// int selected = kodi::gui::dialogs::Select::Show("Test selection", entries, -1);
159/// if (selected < 0)
160/// fprintf(stderr, "Item selection canceled\n");
161/// else
162/// fprintf(stderr, "Selected item is: %i\n", selected);
163/// ~~~~~~~~~~~~~
164///
165inline int ATTRIBUTE_HIDDEN Show(const std::string& heading,
166 std::vector<kodi::gui::dialogs::SSelectionEntry>& entries,
167 int selected = -1,
168 unsigned int autoclose = 0)
169{
170 using namespace ::kodi::addon;
171 unsigned int size = static_cast<unsigned int>(entries.size());
172 const char** cEntries = static_cast<const char**>(malloc(size * sizeof(const char*)));
173 for (unsigned int i = 0; i < size; ++i)
174 {
175 cEntries[i] = entries[i].name.c_str();
176 if (selected == -1 && entries[i].selected)
177 selected = i;
178 }
179 int ret = CAddonBase::m_interface->toKodi->kodi_gui->dialogSelect->open(
180 CAddonBase::m_interface->toKodi->kodiBase, heading.c_str(), cEntries, size, selected,
181 autoclose);
182 if (ret >= 0)
183 {
184 entries[ret].selected = true;
185 }
186 free(cEntries);
187 return ret;
188}
189//------------------------------------------------------------------------------
190
191//==============================================================================
192/// @ingroup cpp_kodi_gui_dialogs_Select
193/// @brief Show a multiple selection dialog about given parts.
194///
195/// @param[in] heading Dialog heading name
196/// @param[in] entries @ref SSelectionEntry list about entries
197/// @param[in] autoclose [opt] To close dialog automatic after the given time in
198/// ms. As '0' it stays open.
199/// @return The selected entries, if return <tt>empty</tt> was nothing selected
200/// or canceled
201///
202/// With selected on @ref SSelectionEntry can be a pre selection defined.
203///
204///-------------------------------------------------------------------------
205///
206/// **Example:**
207/// ~~~~~~~~~~~~~{.cpp}
208/// #include <kodi/gui/dialogs/Select.h>
209///
210/// std::vector<kodi::gui::dialogs::SSelectionEntry> entries
211/// {
212/// { "ID 1", "Test 1", false },
213/// { "ID 2", "Test 2", false },
214/// { "ID 3", "Test 3", false },
215/// { "ID 4", "Test 4", false },
216/// { "ID 5", "Test 5", false }
217/// };
218///
219/// bool ret = kodi::gui::dialogs::Select::ShowMultiSelect("Test selection", entries);
220/// if (!ret)
221/// fprintf(stderr, "Selection canceled\n");
222/// else
223/// {
224/// fprintf(stderr, "Selected items:\n");
225/// for (const auto& entry : entries)
226/// {
227/// if (entry.selected)
228/// fprintf(stderr, " - %s\n", entry.selected.id.c_str());
229/// }
230/// }
231/// ~~~~~~~~~~~~~
232///
233inline bool ATTRIBUTE_HIDDEN ShowMultiSelect(const std::string& heading,
234 std::vector<kodi::gui::dialogs::SSelectionEntry>& entries,
235 int autoclose = 0)
236{
237 using namespace ::kodi::addon;
238 unsigned int size = static_cast<unsigned int>(entries.size());
239 const char** cEntryIDs = static_cast<const char**>(malloc(size * sizeof(const char*)));
240 const char** cEntryNames = static_cast<const char**>(malloc(size * sizeof(const char*)));
241 bool* cEntriesSelected = static_cast<bool*>(malloc(size * sizeof(bool)));
242 for (unsigned int i = 0; i < size; ++i)
243 {
244 cEntryIDs[i] = entries[i].id.c_str();
245 cEntryNames[i] = entries[i].name.c_str();
246 cEntriesSelected[i] = entries[i].selected;
247 }
248 bool ret = CAddonBase::m_interface->toKodi->kodi_gui->dialogSelect->open_multi_select(
249 CAddonBase::m_interface->toKodi->kodiBase, heading.c_str(), cEntryIDs, cEntryNames,
250 cEntriesSelected, size, autoclose);
251 if (ret)
252 {
253 for (unsigned int i = 0; i < size; ++i)
254 entries[i].selected = cEntriesSelected[i];
255 }
256 free(cEntryNames);
257 free(cEntryIDs);
258 free(cEntriesSelected);
259 return ret;
260}
261//------------------------------------------------------------------------------
262}; // namespace Select
263/// @}
264
265} /* namespace dialogs */
266} /* namespace gui */
267} /* namespace kodi */
268
269#endif /* __cplusplus */
diff --git a/xbmc/addons/kodi-dev-kit/include/kodi/gui/dialogs/TextViewer.h b/xbmc/addons/kodi-dev-kit/include/kodi/gui/dialogs/TextViewer.h
new file mode 100644
index 0000000..42a86f3
--- /dev/null
+++ b/xbmc/addons/kodi-dev-kit/include/kodi/gui/dialogs/TextViewer.h
@@ -0,0 +1,109 @@
1/*
2 * Copyright (C) 2015-2018 Team Kodi
3 * This file is part of Kodi - https://kodi.tv
4 *
5 * SPDX-License-Identifier: GPL-2.0-or-later
6 * See LICENSES/README.md for more information.
7 */
8
9#pragma once
10
11#include "../../AddonBase.h"
12#include "../../c-api/gui/dialogs/text_viewer.h"
13
14#ifdef __cplusplus
15
16namespace kodi
17{
18namespace gui
19{
20namespace dialogs
21{
22
23//==============================================================================
24/// @defgroup cpp_kodi_gui_dialogs_TextViewer Dialog Text Viewer
25/// @ingroup cpp_kodi_gui_dialogs
26/// @{
27/// @brief @cpp_namespace{ kodi::gui::dialogs::TextViewer }
28/// **Text viewer dialog**\n
29/// The text viewer dialog can be used to display descriptions, help texts or
30/// other larger texts.
31///
32/// In order to achieve a line break is a <b>\\n</b> directly in the text or
33/// in the <em>"./resources/language/resource.language.??_??/strings.po"</em>
34/// to call with <b>std::string kodi::general::GetLocalizedString(...);</b>.
35///
36/// It has the header \ref TextViewer.h "#include <kodi/gui/dialogs/TextViewer.h>"
37/// be included to enjoy it.
38///
39namespace TextViewer
40{
41//==============================================================================
42/// @ingroup cpp_kodi_gui_dialogs_TextViewer
43/// @brief Show info text dialog
44///
45/// @param[in] heading mall heading text
46/// @param[in] text Showed text on dialog
47///
48///
49///-------------------------------------------------------------------------
50///
51/// **Example:**
52/// ~~~~~~~~~~~~~{.cpp}
53/// #include <kodi/gui/dialogs/TextViewer.h>
54///
55/// kodi::gui::dialogs::TextViewer::Show("The Wizard of Oz (1939 film)",
56/// "The Wizard of Oz is a 1939 American musical comedy-drama fantasy film "
57/// "produced by Metro-Goldwyn-Mayer, and the most well-known and commercially "
58/// "successful adaptation based on the 1900 novel The Wonderful Wizard of Oz "
59/// "by L. Frank Baum. The film stars Judy Garland as Dorothy Gale. The film"
60/// "co-stars Terry the dog, billed as Toto; Ray Bolger, Jack Haley, Bert Lahr, "
61/// "Frank Morgan, Billie Burke, Margaret Hamilton, with Charley Grapewin and "
62/// "Clara Blandick, and the Singer Midgets as the Munchkins.\n"
63/// "\n"
64/// "Notable for its use of Technicolor, fantasy storytelling, musical score and "
65/// "unusual characters, over the years it has become an icon of American popular "
66/// "culture. It was nominated for six Academy Awards, including Best Picture but "
67/// "lost to Gone with the Wind. It did win in two other categories including Best "
68/// "Original Song for \"Over the Rainbow\". However, the film was a box office "
69/// "disappointment on its initial release, earning only $3,017,000 on a $2,777,000 "
70/// "budget, despite receiving largely positive reviews. It was MGM's most "
71/// "expensive production at that time, and did not completely recoup the studio's "
72/// "investment and turn a profit until theatrical re-releases starting in 1949.\n"
73/// "\n"
74/// "The 1956 broadcast television premiere of the film on CBS re-introduced the "
75/// "film to the wider public and eventually made the presentation an annual "
76/// "tradition, making it one of the most known films in cinema history. The "
77/// "film was named the most-viewed motion picture on television syndication by "
78/// "the Library of Congress who also included the film in its National Film "
79/// "Registry in its inaugural year in 1989. Designation on the registry calls "
80/// "for efforts to preserve it for being \"culturally, historically, and "
81/// "aesthetically significant\". It is also one of the few films on UNESCO's "
82/// "Memory of the World Register.\n"
83/// "\n"
84/// "The Wizard of Oz is often ranked on best-movie lists in critics' and public "
85/// "polls. It is the source of many quotes referenced in modern popular culture. "
86/// "It was directed primarily by Victor Fleming (who left production to take "
87/// "over direction on the troubled Gone with the Wind production). Noel Langley, "
88/// "Florence Ryerson and Edgar Allan Woolf received credit for the screenplay, "
89/// "but there were uncredited contributions by others. The songs were written "
90/// "by Edgar \"Yip\" Harburg (lyrics) and Harold Arlen (music). The incidental "
91/// "music, based largely on the songs, was composed by Herbert Stothart, with "
92/// "interspersed renderings from classical composers.\n");
93/// ~~~~~~~~~~~~~
94///
95inline void ATTRIBUTE_HIDDEN Show(const std::string& heading, const std::string& text)
96{
97 using namespace ::kodi::addon;
98 CAddonBase::m_interface->toKodi->kodi_gui->dialogTextViewer->open(
99 CAddonBase::m_interface->toKodi->kodiBase, heading.c_str(), text.c_str());
100}
101//------------------------------------------------------------------------------
102}; // namespace TextViewer
103/// @}
104
105} /* namespace dialogs */
106} /* namespace gui */
107} /* namespace kodi */
108
109#endif /* __cplusplus */
diff --git a/xbmc/addons/kodi-dev-kit/include/kodi/gui/dialogs/YesNo.h b/xbmc/addons/kodi-dev-kit/include/kodi/gui/dialogs/YesNo.h
new file mode 100644
index 0000000..6e6e069
--- /dev/null
+++ b/xbmc/addons/kodi-dev-kit/include/kodi/gui/dialogs/YesNo.h
@@ -0,0 +1,188 @@
1/*
2 * Copyright (C) 2005-2018 Team Kodi
3 * This file is part of Kodi - https://kodi.tv
4 *
5 * SPDX-License-Identifier: GPL-2.0-or-later
6 * See LICENSES/README.md for more information.
7 */
8
9#pragma once
10
11#include "../../AddonBase.h"
12#include "../../c-api/gui/dialogs/yes_no.h"
13
14#ifdef __cplusplus
15
16namespace kodi
17{
18namespace gui
19{
20namespace dialogs
21{
22
23//==============================================================================
24/// @defgroup cpp_kodi_gui_dialogs_YesNo Dialog Yes/No
25/// @ingroup cpp_kodi_gui_dialogs
26/// @{
27/// @brief @cpp_namespace{ kodi::gui::dialogs::YesNo }
28/// **Yes / No dialog**\n
29/// The Yes / No dialog can be used to inform the user about questions and get
30/// the answer.
31///
32/// In order to achieve a line break is a <b>\\n</b> directly in the text or
33/// in the <em>"./resources/language/resource.language.??_??/strings.po"</em>
34/// to call with <b>std::string kodi::general::GetLocalizedString(...);</b>.
35///
36/// It has the header @ref YesNo.h "#include <kodi/gui/dialogs/YesNo.h>"
37/// be included to enjoy it.
38///
39namespace YesNo
40{
41//==============================================================================
42/// @ingroup cpp_kodi_gui_dialogs_YesNo
43/// @brief Use dialog to get numeric new password with one text string shown
44/// everywhere and cancel return field.
45///
46/// @param[in] heading Dialog heading
47/// @param[in] text Multi-line text
48/// @param[out] canceled Return value about cancel button
49/// @param[in] noLabel [opt] label to put on the no button
50/// @param[in] yesLabel [opt] label to put on the yes button
51/// @return Returns True if 'Yes' was pressed, else False
52///
53/// @note It is preferred to only use this as it is actually a multi-line text.
54///
55///
56///-------------------------------------------------------------------------
57///
58/// **Example:**
59/// ~~~~~~~~~~~~~{.cpp}
60/// #include <kodi/gui/dialogs/YesNo.h>
61///
62/// bool canceled = false;
63/// bool ret = kodi::gui::dialogs::YesNo::ShowAndGetInput(
64/// "Yes / No test call", // The Header
65/// "You has opened Yes / No dialog for test\n\nIs this OK for you?",
66/// canceled, // return value about cancel button
67/// "Not really", // No label, is optional and if empty "No"
68/// "Ohhh yes"); // Yes label, also optional and if empty "Yes"
69/// fprintf(stderr, "You has called Yes/No, returned '%s' and was %s\n",
70/// ret ? "yes" : "no",
71/// canceled ? "canceled" : "not canceled");
72/// ~~~~~~~~~~~~~
73///
74inline bool ATTRIBUTE_HIDDEN ShowAndGetInput(const std::string& heading,
75 const std::string& text,
76 bool& canceled,
77 const std::string& noLabel = "",
78 const std::string& yesLabel = "")
79{
80 using namespace ::kodi::addon;
81 return CAddonBase::m_interface->toKodi->kodi_gui->dialogYesNo->show_and_get_input_single_text(
82 CAddonBase::m_interface->toKodi->kodiBase, heading.c_str(), text.c_str(), &canceled,
83 noLabel.c_str(), yesLabel.c_str());
84}
85//------------------------------------------------------------------------------
86
87//==============================================================================
88/// @ingroup cpp_kodi_gui_dialogs_YesNo
89/// @brief Use dialog to get numeric new password with separated line strings.
90///
91/// @param[in] heading Dialog heading
92/// @param[in] line0 Line #0 text
93/// @param[in] line1 Line #1 text
94/// @param[in] line2 Line #2 text
95/// @param[in] noLabel [opt] label to put on the no button
96/// @param[in] yesLabel [opt] label to put on the yes button
97/// @return Returns True if 'Yes' was pressed, else False
98///
99///
100///-------------------------------------------------------------------------
101///
102/// **Example:**
103/// ~~~~~~~~~~~~~{.cpp}
104/// #include <kodi/gui/dialogs/YesNo.h>
105///
106/// bool ret = kodi::gui::dialogs::YesNo::ShowAndGetInput(
107/// "Yes / No test call", // The Header
108/// "You has opened Yes / No dialog for test",
109/// "",
110/// "Is this OK for you?",
111/// "Not really", // No label, is optional and if empty "No"
112/// "Ohhh yes"); // Yes label, also optional and if empty "Yes"
113/// fprintf(stderr, "You has called Yes/No, returned '%s'\n",
114/// ret ? "yes" : "no");
115/// ~~~~~~~~~~~~~
116///
117inline bool ATTRIBUTE_HIDDEN ShowAndGetInput(const std::string& heading,
118 const std::string& line0,
119 const std::string& line1,
120 const std::string& line2,
121 const std::string& noLabel = "",
122 const std::string& yesLabel = "")
123{
124 using namespace ::kodi::addon;
125 return CAddonBase::m_interface->toKodi->kodi_gui->dialogYesNo->show_and_get_input_line_text(
126 CAddonBase::m_interface->toKodi->kodiBase, heading.c_str(), line0.c_str(), line1.c_str(),
127 line2.c_str(), noLabel.c_str(), yesLabel.c_str());
128}
129//------------------------------------------------------------------------------
130
131//==============================================================================
132/// @ingroup cpp_kodi_gui_dialogs_YesNo
133/// @brief Use dialog to get numeric new password with separated line strings
134/// and cancel return field.
135///
136/// @param[in] heading Dialog heading
137/// @param[in] line0 Line #0 text
138/// @param[in] line1 Line #1 text
139/// @param[in] line2 Line #2 text
140/// @param[out] canceled Return value about cancel button
141/// @param[in] noLabel [opt] label to put on the no button
142/// @param[in] yesLabel [opt] label to put on the yes button
143/// @return Returns True if 'Yes' was pressed, else False
144///
145///
146///-------------------------------------------------------------------------
147///
148/// **Example:**
149/// ~~~~~~~~~~~~~{.cpp}
150/// #include <kodi/gui/dialogs/YesNo.h>
151///
152/// bool canceled = false;
153/// bool ret = kodi::gui::dialogs::YesNo::ShowAndGetInput(
154/// "Yes / No test call", // The Header
155/// "You has opened Yes / No dialog for test",
156/// "",
157/// "Is this OK for you?",
158/// canceled, // return value about cancel button
159/// "Not really", // No label, is optional and if empty "No"
160/// "Ohhh yes"); // Yes label, also optional and if empty "Yes"
161/// fprintf(stderr, "You has called Yes/No, returned '%s' and was %s\n",
162/// ret ? "yes" : "no",
163/// canceled ? "canceled" : "not canceled");
164/// ~~~~~~~~~~~~~
165///
166inline bool ATTRIBUTE_HIDDEN ShowAndGetInput(const std::string& heading,
167 const std::string& line0,
168 const std::string& line1,
169 const std::string& line2,
170 bool& canceled,
171 const std::string& noLabel = "",
172 const std::string& yesLabel = "")
173{
174 using namespace ::kodi::addon;
175 return CAddonBase::m_interface->toKodi->kodi_gui->dialogYesNo
176 ->show_and_get_input_line_button_text(
177 CAddonBase::m_interface->toKodi->kodiBase, heading.c_str(), line0.c_str(), line1.c_str(),
178 line2.c_str(), &canceled, noLabel.c_str(), yesLabel.c_str());
179}
180//------------------------------------------------------------------------------
181}; // namespace YesNo
182/// @}
183
184} /* namespace dialogs */
185} /* namespace gui */
186} /* namespace kodi */
187
188#endif /* __cplusplus */
diff --git a/xbmc/addons/kodi-dev-kit/include/kodi/gui/gl/CMakeLists.txt b/xbmc/addons/kodi-dev-kit/include/kodi/gui/gl/CMakeLists.txt
new file mode 100644
index 0000000..844902d
--- /dev/null
+++ b/xbmc/addons/kodi-dev-kit/include/kodi/gui/gl/CMakeLists.txt
@@ -0,0 +1,7 @@
1set(HEADERS GL.h
2 GLonDX.h
3 Shader.h)
4
5if(NOT ENABLE_STATIC_LIBS)
6 core_add_library(addons_kodi-dev-kit_include_kodi_gui_gl)
7endif()
diff --git a/xbmc/addons/kodi-dev-kit/include/kodi/gui/gl/GL.h b/xbmc/addons/kodi-dev-kit/include/kodi/gui/gl/GL.h
new file mode 100644
index 0000000..16d43e3
--- /dev/null
+++ b/xbmc/addons/kodi-dev-kit/include/kodi/gui/gl/GL.h
@@ -0,0 +1,112 @@
1/*
2 * Copyright (C) 2005-2019 Team Kodi
3 * This file is part of Kodi - https://kodi.tv
4 *
5 * SPDX-License-Identifier: GPL-2.0-or-later
6 * See LICENSES/README.md for more information.
7 */
8
9#pragma once
10
11#ifdef __cplusplus
12
13//==============================================================================
14/// @defgroup cpp_kodi_gui_helpers_gl OpenGL helpers
15/// @ingroup cpp_kodi_gui_helpers
16/// @brief **Auxiliary functions for Open GL**\n
17/// This group includes help for definitions, functions, and classes for
18/// OpenGL.
19///
20/// To use OpenGL for your system, add the @ref GL.h "#include <kodi/gui/gl/GL.h>".
21///
22/// The @ref HAS_GL is declared if Open GL is required and @ref HAS_GLES if Open GL
23/// Embedded Systems (ES) is required, with ES the version is additionally given
24/// in the definition, this can be "2" or "3".
25///
26///
27///-----------------------------------------------------------------------------
28///
29/// Following @ref GL_TYPE_STRING define can be used, for example, to manage
30/// different folders for GL and GLES and make the selection easier.
31/// This are on OpenGL <b>"GL"</b> and on Open GL|ES <b>"GLES"</b>.
32///
33/// **Example:**
34/// ~~~~~~~~~~~~~~~~~{.cpp}
35/// kodi::GetAddonPath("resources/shaders/" GL_TYPE_STRING "/frag.glsl");
36/// ~~~~~~~~~~~~~~~~~
37///
38///
39///----------------------------------------------------------------------------
40///
41/// In addition, @ref BUFFER_OFFSET is declared in it which can be used to give an
42/// offset on the array to GL.
43///
44/// **Example:**
45/// ~~~~~~~~~~~~~~~~~{.cpp}
46/// const struct PackedVertex {
47/// float position[3]; // Position x, y, z
48/// float color[4]; // Color r, g, b, a
49/// } vertices[3] = {
50/// { { -0.5f, -0.5f, 0.0f }, { 1.0f, 0.0f, 0.0f, 1.0f } },
51/// { { 0.5f, -0.5f, 0.0f }, { 0.0f, 1.0f, 0.0f, 1.0f } },
52/// { { 0.0f, 0.5f, 0.0f }, { 0.0f, 0.0f, 1.0f, 1.0f } }
53/// };
54///
55/// glVertexAttribPointer(m_aPosition, 3, GL_FLOAT, GL_FALSE, sizeof(PackedVertex), BUFFER_OFFSET(offsetof(PackedVertex, position)));
56/// glEnableVertexAttribArray(m_aPosition);
57///
58/// glVertexAttribPointer(m_aColor, 4, GL_FLOAT, GL_FALSE, sizeof(PackedVertex), BUFFER_OFFSET(offsetof(PackedVertex, color)));
59/// glEnableVertexAttribArray(m_aColor);
60/// ~~~~~~~~~~~~~~~~~
61
62#if HAS_GL
63#define GL_TYPE_STRING "GL"
64// always define GL_GLEXT_PROTOTYPES before include gl headers
65#if !defined(GL_GLEXT_PROTOTYPES)
66#define GL_GLEXT_PROTOTYPES
67#endif
68#if defined(TARGET_LINUX)
69#include <GL/gl.h>
70#include <GL/glext.h>
71#elif defined(TARGET_FREEBSD)
72#include <GL/gl.h>
73#elif defined(TARGET_DARWIN)
74#include <OpenGL/gl3.h>
75#include <OpenGL/gl3ext.h>
76#elif defined(WIN32)
77#error Use of GL under Windows is not possible
78#endif
79#elif HAS_GLES >= 2
80#define GL_TYPE_STRING "GLES"
81#if defined(WIN32)
82#if defined(HAS_ANGLE)
83#include <angle_gl.h>
84#else
85#error Use of GLES only be available under Windows by the use of angle
86#endif
87#elif defined(TARGET_DARWIN)
88#if HAS_GLES == 3
89#include <OpenGLES/ES3/gl.h>
90#include <OpenGLES/ES3/glext.h>
91#else
92#include <OpenGLES/ES2/gl.h>
93#include <OpenGLES/ES2/glext.h>
94#endif
95#else
96#if HAS_GLES == 3
97#include <GLES3/gl3.h>
98#include <GLES3/gl3ext.h>
99#else
100#include <GLES2/gl2.h>
101#include <GLES2/gl2ext.h>
102#endif
103#endif
104#endif
105
106#ifndef BUFFER_OFFSET
107/// @ingroup cpp_kodi_gui_helpers_gl
108/// @brief To give a offset number as pointer value.
109#define BUFFER_OFFSET(i) ((char*)nullptr + (i))
110#endif
111
112#endif /* __cplusplus */
diff --git a/xbmc/addons/kodi-dev-kit/include/kodi/gui/gl/GLonDX.h b/xbmc/addons/kodi-dev-kit/include/kodi/gui/gl/GLonDX.h
new file mode 100644
index 0000000..4dd97af
--- /dev/null
+++ b/xbmc/addons/kodi-dev-kit/include/kodi/gui/gl/GLonDX.h
@@ -0,0 +1,389 @@
1/*
2 * Copyright (C) 2005-2019 Team Kodi
3 * This file is part of Kodi - https://kodi.tv
4 *
5 * SPDX-License-Identifier: GPL-2.0-or-later
6 * See LICENSES/README.md for more information.
7 */
8
9#pragma once
10
11#ifdef __cplusplus
12
13#include <EGL/egl.h>
14#include <EGL/eglext.h>
15#include <angle_gl.h>
16#include <d3d11.h>
17#include <d3dcompiler.h>
18#include <kodi/AddonBase.h>
19#include <kodi/gui/General.h>
20#include <wrl/client.h>
21
22#pragma comment(lib, "d3dcompiler.lib")
23#ifndef GL_CLIENT_VERSION
24#define GL_CLIENT_VERSION 3
25#endif
26
27namespace kodi
28{
29namespace gui
30{
31namespace gl
32{
33
34class ATTRIBUTE_HIDDEN CGLonDX : public kodi::gui::IRenderHelper
35{
36public:
37 explicit CGLonDX() : m_pContext(reinterpret_cast<ID3D11DeviceContext*>(kodi::gui::GetHWContext()))
38 {
39 }
40 ~CGLonDX() override { destruct(); }
41
42 bool Init() override
43 {
44 EGLint egl_display_attrs[] = {EGL_PLATFORM_ANGLE_TYPE_ANGLE,
45 EGL_PLATFORM_ANGLE_TYPE_D3D11_ANGLE,
46 EGL_PLATFORM_ANGLE_MAX_VERSION_MAJOR_ANGLE,
47 EGL_DONT_CARE,
48 EGL_PLATFORM_ANGLE_MAX_VERSION_MAJOR_ANGLE,
49 EGL_DONT_CARE,
50 EGL_EXPERIMENTAL_PRESENT_PATH_ANGLE,
51 EGL_EXPERIMENTAL_PRESENT_PATH_FAST_ANGLE,
52 EGL_NONE};
53 EGLint egl_config_attrs[] = {EGL_RED_SIZE,
54 8,
55 EGL_GREEN_SIZE,
56 8,
57 EGL_BLUE_SIZE,
58 8,
59 EGL_ALPHA_SIZE,
60 8,
61 EGL_BIND_TO_TEXTURE_RGBA,
62 EGL_TRUE,
63 EGL_RENDERABLE_TYPE,
64 GL_CLIENT_VERSION == 3 ? EGL_OPENGL_ES3_BIT : EGL_OPENGL_ES2_BIT,
65 EGL_SURFACE_TYPE,
66 EGL_PBUFFER_BIT,
67 EGL_NONE};
68 EGLint egl_context_attrs[] = {EGL_CONTEXT_CLIENT_VERSION, GL_CLIENT_VERSION, EGL_NONE};
69
70 m_eglDisplay =
71 eglGetPlatformDisplayEXT(EGL_PLATFORM_ANGLE_ANGLE, EGL_DEFAULT_DISPLAY, egl_display_attrs);
72 if (m_eglDisplay == EGL_NO_DISPLAY)
73 {
74 Log(ADDON_LOG_ERROR, "GLonDX: unable to get EGL display (%s)", eglGetErrorString());
75 return false;
76 }
77
78 if (eglInitialize(m_eglDisplay, nullptr, nullptr) != EGL_TRUE)
79 {
80 Log(ADDON_LOG_ERROR, "GLonDX: unable to init EGL display (%s)", eglGetErrorString());
81 return false;
82 }
83
84 EGLint numConfigs = 0;
85 if (eglChooseConfig(m_eglDisplay, egl_config_attrs, &m_eglConfig, 1, &numConfigs) != EGL_TRUE ||
86 numConfigs == 0)
87 {
88 Log(ADDON_LOG_ERROR, "GLonDX: unable to get EGL config (%s)", eglGetErrorString());
89 return false;
90 }
91
92 m_eglContext = eglCreateContext(m_eglDisplay, m_eglConfig, nullptr, egl_context_attrs);
93 if (m_eglContext == EGL_NO_CONTEXT)
94 {
95 Log(ADDON_LOG_ERROR, "GLonDX: unable to create EGL context (%s)", eglGetErrorString());
96 return false;
97 }
98
99 if (!createD3DResources())
100 return false;
101
102 if (eglMakeCurrent(m_eglDisplay, m_eglBuffer, m_eglBuffer, m_eglContext) != EGL_TRUE)
103 {
104 Log(ADDON_LOG_ERROR, "GLonDX: unable to make current EGL (%s)", eglGetErrorString());
105 return false;
106 }
107 return true;
108 }
109
110 void CheckGL(ID3D11DeviceContext* device)
111 {
112 if (m_pContext != device)
113 {
114 m_pSRView = nullptr;
115 m_pVShader = nullptr;
116 m_pPShader = nullptr;
117 m_pContext = device;
118
119 if (m_eglBuffer != EGL_NO_SURFACE)
120 {
121 eglMakeCurrent(m_eglDisplay, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT);
122 eglDestroySurface(m_eglDisplay, m_eglBuffer);
123 m_eglBuffer = EGL_NO_SURFACE;
124 }
125
126 // create new resources
127 if (!createD3DResources())
128 return;
129
130 eglMakeCurrent(m_eglDisplay, m_eglBuffer, m_eglBuffer, m_eglContext);
131 }
132 }
133
134 void Begin() override
135 {
136 // confirm on begin D3D context is correct
137 CheckGL(reinterpret_cast<ID3D11DeviceContext*>(kodi::gui::GetHWContext()));
138
139 glClearColor(0.0f, 0.0f, 0.0f, 1.0f);
140 glClear(GL_COLOR_BUFFER_BIT);
141 }
142
143 void End() override
144 {
145 glFlush();
146
147 // set our primitive shaders
148 m_pContext->VSSetShader(m_pVShader.Get(), nullptr, 0);
149 m_pContext->PSSetShader(m_pPShader.Get(), nullptr, 0);
150 m_pContext->PSSetShaderResources(0, 1, m_pSRView.GetAddressOf());
151 // draw texture
152 m_pContext->IASetPrimitiveTopology(D3D11_PRIMITIVE_TOPOLOGY_TRIANGLESTRIP);
153 m_pContext->IASetVertexBuffers(0, 0, nullptr, nullptr, nullptr);
154 m_pContext->IASetInputLayout(nullptr);
155 m_pContext->Draw(4, 0);
156 // unset shaders
157 m_pContext->PSSetShader(nullptr, nullptr, 0);
158 m_pContext->VSSetShader(nullptr, nullptr, 0);
159 // unbind our view
160 ID3D11ShaderResourceView* views[1] = {};
161 m_pContext->PSSetShaderResources(0, 1, views);
162 }
163
164private:
165 enum ShaderType
166 {
167 VERTEX_SHADER,
168 PIXEL_SHADER
169 };
170
171 bool createD3DResources()
172 {
173 HANDLE sharedHandle;
174 Microsoft::WRL::ComPtr<ID3D11Device> pDevice;
175 Microsoft::WRL::ComPtr<ID3D11RenderTargetView> pRTView;
176 Microsoft::WRL::ComPtr<ID3D11Resource> pRTResource;
177 Microsoft::WRL::ComPtr<ID3D11Texture2D> pRTTexture;
178 Microsoft::WRL::ComPtr<ID3D11Texture2D> pOffScreenTexture;
179 Microsoft::WRL::ComPtr<IDXGIResource> dxgiResource;
180
181 m_pContext->GetDevice(&pDevice);
182 m_pContext->OMGetRenderTargets(1, &pRTView, nullptr);
183 if (!pRTView)
184 return false;
185
186 pRTView->GetResource(&pRTResource);
187 if (FAILED(pRTResource.As(&pRTTexture)))
188 return false;
189
190 D3D11_TEXTURE2D_DESC texDesc;
191 pRTTexture->GetDesc(&texDesc);
192 texDesc.Format = DXGI_FORMAT_B8G8R8A8_UNORM;
193 texDesc.BindFlags = D3D11_BIND_SHADER_RESOURCE | D3D11_BIND_RENDER_TARGET;
194 texDesc.MiscFlags = D3D11_RESOURCE_MISC_SHARED;
195 if (FAILED(pDevice->CreateTexture2D(&texDesc, nullptr, &pOffScreenTexture)))
196 {
197 Log(ADDON_LOG_ERROR, "GLonDX: unable to create intermediate texture");
198 return false;
199 }
200
201 CD3D11_SHADER_RESOURCE_VIEW_DESC srvDesc(pOffScreenTexture.Get(),
202 D3D11_SRV_DIMENSION_TEXTURE2D);
203 if (FAILED(pDevice->CreateShaderResourceView(pOffScreenTexture.Get(), &srvDesc, &m_pSRView)))
204 {
205 Log(ADDON_LOG_ERROR, "GLonDX: unable to create shader view");
206 return false;
207 }
208
209 if (FAILED(pOffScreenTexture.As(&dxgiResource)) ||
210 FAILED(dxgiResource->GetSharedHandle(&sharedHandle)))
211 {
212 Log(ADDON_LOG_ERROR, "GLonDX: unable get shared handle for texture");
213 return false;
214 }
215
216 // initiate simple shaders
217 if (FAILED(d3dCreateShader(VERTEX_SHADER, vs_out_shader_text, &m_pVShader)))
218 {
219 Log(ADDON_LOG_ERROR, "GLonDX: unable to create vertex shader view");
220 return false;
221 }
222
223 if (FAILED(d3dCreateShader(PIXEL_SHADER, ps_out_shader_text, &m_pPShader)))
224 {
225 Log(ADDON_LOG_ERROR, "GLonDX: unable to create pixel shader view");
226 return false;
227 }
228
229 // create EGL buffer from D3D shared texture
230 EGLint egl_buffer_attrs[] = {EGL_WIDTH,
231 static_cast<EGLint>(texDesc.Width),
232 EGL_HEIGHT,
233 static_cast<EGLint>(texDesc.Height),
234 EGL_TEXTURE_TARGET,
235 EGL_TEXTURE_2D,
236 EGL_TEXTURE_FORMAT,
237 EGL_TEXTURE_RGBA,
238 EGL_NONE};
239
240 m_eglBuffer =
241 eglCreatePbufferFromClientBuffer(m_eglDisplay, EGL_D3D_TEXTURE_2D_SHARE_HANDLE_ANGLE,
242 sharedHandle, m_eglConfig, egl_buffer_attrs);
243
244 if (m_eglBuffer == EGL_NO_SURFACE)
245 {
246 Log(ADDON_LOG_ERROR, "GLonDX: unable to create EGL buffer (%s)", eglGetErrorString());
247 return false;
248 }
249 return true;
250 }
251
252 HRESULT d3dCreateShader(ShaderType shaderType,
253 const std::string& source,
254 IUnknown** ppShader) const
255 {
256 Microsoft::WRL::ComPtr<ID3DBlob> pBlob;
257 Microsoft::WRL::ComPtr<ID3DBlob> pErrors;
258
259 auto hr = D3DCompile(source.c_str(), source.length(), nullptr, nullptr, nullptr, "main",
260 shaderType == PIXEL_SHADER ? "ps_4_0" : "vs_4_0", 0, 0, &pBlob, &pErrors);
261
262 if (SUCCEEDED(hr))
263 {
264 Microsoft::WRL::ComPtr<ID3D11Device> pDevice;
265 m_pContext->GetDevice(&pDevice);
266
267 if (shaderType == PIXEL_SHADER)
268 {
269 hr = pDevice->CreatePixelShader(pBlob->GetBufferPointer(), pBlob->GetBufferSize(), nullptr,
270 reinterpret_cast<ID3D11PixelShader**>(ppShader));
271 }
272 else
273 {
274 hr = pDevice->CreateVertexShader(pBlob->GetBufferPointer(), pBlob->GetBufferSize(), nullptr,
275 reinterpret_cast<ID3D11VertexShader**>(ppShader));
276 }
277
278 if (FAILED(hr))
279 {
280 Log(ADDON_LOG_ERROR, "GLonDX: unable to create %s shader",
281 shaderType == PIXEL_SHADER ? "pixel" : "vertex");
282 }
283 }
284 else
285 {
286 Log(ADDON_LOG_ERROR, "GLonDX: unable to compile shader (%s)", pErrors->GetBufferPointer());
287 }
288 return hr;
289 }
290
291 static const char* eglGetErrorString()
292 {
293#define CASE_STR(value) \
294 case value: \
295 return #value
296 switch (eglGetError())
297 {
298 CASE_STR(EGL_SUCCESS);
299 CASE_STR(EGL_NOT_INITIALIZED);
300 CASE_STR(EGL_BAD_ACCESS);
301 CASE_STR(EGL_BAD_ALLOC);
302 CASE_STR(EGL_BAD_ATTRIBUTE);
303 CASE_STR(EGL_BAD_CONTEXT);
304 CASE_STR(EGL_BAD_CONFIG);
305 CASE_STR(EGL_BAD_CURRENT_SURFACE);
306 CASE_STR(EGL_BAD_DISPLAY);
307 CASE_STR(EGL_BAD_SURFACE);
308 CASE_STR(EGL_BAD_MATCH);
309 CASE_STR(EGL_BAD_PARAMETER);
310 CASE_STR(EGL_BAD_NATIVE_PIXMAP);
311 CASE_STR(EGL_BAD_NATIVE_WINDOW);
312 CASE_STR(EGL_CONTEXT_LOST);
313 default:
314 return "Unknown";
315 }
316#undef CASE_STR
317 }
318
319 void destruct()
320 {
321 if (m_eglDisplay != EGL_NO_DISPLAY)
322 {
323 eglMakeCurrent(m_eglDisplay, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT);
324
325 if (m_eglBuffer != EGL_NO_SURFACE)
326 {
327 eglDestroySurface(m_eglDisplay, m_eglBuffer);
328 m_eglBuffer = EGL_NO_SURFACE;
329 }
330
331 if (m_eglContext != EGL_NO_CONTEXT)
332 {
333 eglDestroyContext(m_eglDisplay, m_eglContext);
334 m_eglContext = EGL_NO_CONTEXT;
335 }
336
337 eglTerminate(m_eglDisplay);
338 m_eglDisplay = EGL_NO_DISPLAY;
339 }
340
341 m_pSRView = nullptr;
342 m_pVShader = nullptr;
343 m_pPShader = nullptr;
344 m_pContext = nullptr;
345 }
346
347 EGLConfig m_eglConfig = EGL_NO_CONFIG_KHR;
348 EGLDisplay m_eglDisplay = EGL_NO_DISPLAY;
349 EGLContext m_eglContext = EGL_NO_CONTEXT;
350 EGLSurface m_eglBuffer = EGL_NO_SURFACE;
351
352 ID3D11DeviceContext* m_pContext = nullptr; // don't hold context
353 Microsoft::WRL::ComPtr<ID3D11ShaderResourceView> m_pSRView = nullptr;
354 Microsoft::WRL::ComPtr<ID3D11VertexShader> m_pVShader = nullptr;
355 Microsoft::WRL::ComPtr<ID3D11PixelShader> m_pPShader = nullptr;
356
357#define TO_STRING(...) #__VA_ARGS__
358 std::string vs_out_shader_text = TO_STRING(void main(uint id
359 : SV_VertexId, out float2 tex
360 : TEXCOORD0, out float4 pos
361 : SV_POSITION) {
362 tex = float2(id % 2, (id % 4) >> 1);
363 pos = float4((tex.x - 0.5f) * 2, -(tex.y - 0.5f) * 2, 0, 1);
364 });
365
366 std::string ps_out_shader_text = TO_STRING(
367 Texture2D texMain : register(t0);
368 SamplerState Sampler
369 {
370 Filter = MIN_MAG_MIP_LINEAR;
371 AddressU = CLAMP;
372 AddressV = CLAMP;
373 Comparison = NEVER;
374 };
375
376 float4 main(in float2 tex : TEXCOORD0) : SV_TARGET
377 {
378 return texMain.Sample(Sampler, tex);
379 });
380#undef TO_STRING
381}; /* class CGLonDX */
382
383} /* namespace gl */
384
385using CRenderHelper = gl::CGLonDX;
386} /* namespace gui */
387} /* namespace kodi */
388
389#endif /* __cplusplus */
diff --git a/xbmc/addons/kodi-dev-kit/include/kodi/gui/gl/Shader.h b/xbmc/addons/kodi-dev-kit/include/kodi/gui/gl/Shader.h
new file mode 100644
index 0000000..bf6d48c
--- /dev/null
+++ b/xbmc/addons/kodi-dev-kit/include/kodi/gui/gl/Shader.h
@@ -0,0 +1,571 @@
1/*
2 * Copyright (C) 2005-2019 Team Kodi
3 * This file is part of Kodi - https://kodi.tv
4 *
5 * SPDX-License-Identifier: GPL-2.0-or-later
6 * See LICENSES/README.md for more information.
7 */
8
9#pragma once
10
11#include "GL.h"
12
13#ifdef __cplusplus
14
15#include <stdio.h>
16#include <string>
17#include <vector>
18
19#include <kodi/AddonBase.h>
20#include <kodi/Filesystem.h>
21
22#define LOG_SIZE 1024
23#define GLchar char
24
25namespace kodi
26{
27namespace gui
28{
29namespace gl
30{
31
32//========================================================================
33/// CShader - base class
34class ATTRIBUTE_HIDDEN CShader
35{
36public:
37 CShader() = default;
38 virtual ~CShader() = default;
39 virtual bool Compile(const std::string& extraBegin = "", const std::string& extraEnd = "") = 0;
40 virtual void Free() = 0;
41 virtual GLuint Handle() = 0;
42
43 bool LoadSource(const std::string& file)
44 {
45 char buffer[16384];
46
47 kodi::vfs::CFile source;
48 if (!source.OpenFile(file))
49 {
50 kodi::Log(ADDON_LOG_ERROR, "CShader::%s: Failed to open file '%s'", __FUNCTION__,
51 file.c_str());
52 return false;
53 }
54 size_t len = source.Read(buffer, sizeof(buffer));
55 m_source.assign(buffer);
56 m_source[len] = 0;
57 source.Close();
58 return true;
59 }
60
61 bool OK() const { return m_compiled; }
62
63protected:
64 std::string m_source;
65 std::string m_lastLog;
66 bool m_compiled = false;
67};
68//------------------------------------------------------------------------
69
70//========================================================================
71/// CVertexShader
72class ATTRIBUTE_HIDDEN CVertexShader : public CShader
73{
74public:
75 CVertexShader() = default;
76 ~CVertexShader() override { Free(); }
77
78 void Free() override
79 {
80 if (m_vertexShader)
81 glDeleteShader(m_vertexShader);
82 m_vertexShader = 0;
83 }
84
85 bool Compile(const std::string& extraBegin = "", const std::string& extraEnd = "") override
86 {
87 GLint params[4];
88
89 Free();
90
91 m_vertexShader = glCreateShader(GL_VERTEX_SHADER);
92
93 GLsizei count = 0;
94 const char* sources[3];
95 if (!extraBegin.empty())
96 sources[count++] = extraBegin.c_str();
97 if (!m_source.empty())
98 sources[count++] = m_source.c_str();
99 if (!extraEnd.empty())
100 sources[count++] = extraEnd.c_str();
101
102 glShaderSource(m_vertexShader, count, sources, nullptr);
103 glCompileShader(m_vertexShader);
104 glGetShaderiv(m_vertexShader, GL_COMPILE_STATUS, params);
105 if (params[0] != GL_TRUE)
106 {
107 GLchar log[LOG_SIZE];
108 glGetShaderInfoLog(m_vertexShader, LOG_SIZE, nullptr, log);
109 kodi::Log(ADDON_LOG_ERROR, "CVertexShader::%s: %s", __FUNCTION__, log);
110 fprintf(stderr, "CVertexShader::%s: %s\n", __FUNCTION__, log);
111 m_lastLog = log;
112 m_compiled = false;
113 }
114 else
115 {
116 GLchar log[LOG_SIZE];
117 glGetShaderInfoLog(m_vertexShader, LOG_SIZE, nullptr, log);
118 m_lastLog = log;
119 m_compiled = true;
120 }
121 return m_compiled;
122 }
123
124 GLuint Handle() override { return m_vertexShader; }
125
126protected:
127 GLuint m_vertexShader = 0;
128};
129//------------------------------------------------------------------------
130
131//========================================================================
132/// CPixelShader
133class ATTRIBUTE_HIDDEN CPixelShader : public CShader
134{
135public:
136 CPixelShader() = default;
137 ~CPixelShader() { Free(); }
138 void Free() override
139 {
140 if (m_pixelShader)
141 glDeleteShader(m_pixelShader);
142 m_pixelShader = 0;
143 }
144
145 bool Compile(const std::string& extraBegin = "", const std::string& extraEnd = "") override
146 {
147 GLint params[4];
148
149 Free();
150
151 m_pixelShader = glCreateShader(GL_FRAGMENT_SHADER);
152
153 GLsizei count = 0;
154 const char* sources[3];
155 if (!extraBegin.empty())
156 sources[count++] = extraBegin.c_str();
157 if (!m_source.empty())
158 sources[count++] = m_source.c_str();
159 if (!extraEnd.empty())
160 sources[count++] = extraEnd.c_str();
161
162 glShaderSource(m_pixelShader, count, sources, 0);
163 glCompileShader(m_pixelShader);
164 glGetShaderiv(m_pixelShader, GL_COMPILE_STATUS, params);
165 if (params[0] != GL_TRUE)
166 {
167 GLchar log[LOG_SIZE];
168 glGetShaderInfoLog(m_pixelShader, LOG_SIZE, nullptr, log);
169 kodi::Log(ADDON_LOG_ERROR, "CPixelShader::%s: %s", __FUNCTION__, log);
170 fprintf(stderr, "CPixelShader::%s: %s\n", __FUNCTION__, log);
171 m_lastLog = log;
172 m_compiled = false;
173 }
174 else
175 {
176 GLchar log[LOG_SIZE];
177 glGetShaderInfoLog(m_pixelShader, LOG_SIZE, nullptr, log);
178 m_lastLog = log;
179 m_compiled = true;
180 }
181 return m_compiled;
182 }
183
184 GLuint Handle() override { return m_pixelShader; }
185
186protected:
187 GLuint m_pixelShader = 0;
188};
189//------------------------------------------------------------------------
190
191//============================================================================
192/// @defgroup cpp_kodi_gui_helpers_gl_CShaderProgram GL Shader Program
193/// @ingroup cpp_kodi_gui_helpers_gl
194/// @brief @cpp_class{ kodi::gui::gl::CShaderProgram }
195/// **Class to manage an OpenGL shader program**\n
196/// With this class the used GL shader code can be defined on the GPU and
197/// its variables can be managed between CPU and GPU.
198///
199/// It has the header @ref Shader.h "#include <kodi/gui/gl/Shader.h>"
200/// be included to enjoy it.
201///
202/// ----------------------------------------------------------------------------
203///
204/// <b>Example:</b>
205///
206/// ~~~~~~~~~~~~~{.cpp}
207///
208/// #include <kodi/gui/gl/Shader.h>
209/// ...
210///
211/// class ATTRIBUTE_HIDDEN CExample
212/// : ...,
213/// public kodi::gui::gl::CShaderProgram
214/// {
215/// public:
216/// CExample() = default;
217///
218/// bool Start();
219/// void Render();
220///
221/// // override functions for kodi::gui::gl::CShaderProgram
222/// void OnCompiledAndLinked() override;
223/// bool OnEnabled() override;
224///
225/// private:
226/// ...
227/// GLint m_aPosition = -1;
228/// GLint m_aColor = -1;
229/// };
230///
231/// bool CExample::Start()
232/// {
233/// // Define shaders and load
234/// std::string fraqShader = kodi::GetAddonPath("resources/shaders/" GL_TYPE_STRING "/glsl.frag");
235/// std::string vertShader = kodi::GetAddonPath("resources/shaders/" GL_TYPE_STRING "/glsl.vert");
236/// if (!LoadShaderFiles(vertShader, fraqShader) || !CompileAndLink())
237/// return false;
238///
239/// ...
240/// return true;
241/// }
242///
243/// ...
244///
245/// void CExample::Render()
246/// {
247/// ...
248///
249/// EnableShader();
250/// ...
251/// DO WORK
252/// ...
253/// DisableShader();
254/// }
255///
256/// void CExample::OnCompiledAndLinked()
257/// {
258/// ...
259/// DO YOUR WORK HERE FOR WHAT IS ONE TIME REQUIRED DURING COMPILE OF SHADER, E.G.:
260///
261/// m_aPosition = glGetAttribLocation(ProgramHandle(), "a_position");
262/// m_aColor = glGetAttribLocation(ProgramHandle(), "a_color");
263/// }
264///
265/// bool OnEnabled() override
266/// {
267/// ...
268/// DO YOUR WORK HERE FOR WHAT REQUIRED DURING ENABLE OF SHADER
269/// ...
270/// return true;
271/// }
272///
273/// ADDONCREATOR(CExample);
274/// ~~~~~~~~~~~~~
275///
276class ATTRIBUTE_HIDDEN CShaderProgram
277{
278public:
279 //==========================================================================
280 /// @ingroup cpp_kodi_gui_helpers_gl_CShaderProgram
281 /// @brief Construct a new shader.
282 ///
283 /// Load must be done later with @ref LoadShaderFiles.
284 ///
285 CShaderProgram() = default;
286 //--------------------------------------------------------------------------
287
288 //==========================================================================
289 /// @ingroup cpp_kodi_gui_helpers_gl_CShaderProgram
290 /// @brief Construct a new shader and load defined shader files.
291 ///
292 /// @param[in] vert Path to used GL vertext shader
293 /// @param[in] frag Path to used GL fragment shader
294 ///
295 CShaderProgram(const std::string& vert, const std::string& frag) { LoadShaderFiles(vert, frag); }
296 //--------------------------------------------------------------------------
297
298 //==========================================================================
299 /// @ingroup cpp_kodi_gui_helpers_gl_CShaderProgram
300 /// @brief Destructor.
301 ///
302 virtual ~CShaderProgram() { ShaderFree(); }
303 //--------------------------------------------------------------------------
304
305 //==========================================================================
306 /// @ingroup cpp_kodi_gui_helpers_gl_CShaderProgram
307 /// @brief To load manually the needed shader files.
308 ///
309 /// @param[in] vert Path to used GL vertext shader
310 /// @param[in] frag Path to used GL fragment shader
311 ///
312 ///
313 /// @note The use of the files is optional, but it must either be passed over
314 /// here or via @ref CompileAndLink, or both of the source code.
315 ///
316 bool LoadShaderFiles(const std::string& vert, const std::string& frag)
317 {
318 if (!kodi::vfs::FileExists(vert) || !m_pVP.LoadSource(vert))
319 {
320 kodi::Log(ADDON_LOG_ERROR, "%s: Failed to load '%s'", __func__, vert.c_str());
321 return false;
322 }
323
324 if (!kodi::vfs::FileExists(frag) || !m_pFP.LoadSource(frag))
325 {
326 kodi::Log(ADDON_LOG_ERROR, "%s: Failed to load '%s'", __func__, frag.c_str());
327 return false;
328 }
329
330 return true;
331 }
332 //--------------------------------------------------------------------------
333
334 //==========================================================================
335 /// @ingroup cpp_kodi_gui_helpers_gl_CShaderProgram
336 /// @brief To compile and link the shader to the GL interface.
337 ///
338 /// Optionally, additional source code can be transferred here, or it can be
339 /// used independently without any files
340 ///
341 /// @param[in] vertexExtraBegin [opt] To additionally add vextex source
342 /// code to the beginning of the loaded file
343 /// source code
344 /// @param[in] vertexExtraEnd [opt] To additionally add vextex source
345 /// code to the end of the loaded file
346 /// source code
347 /// @param[in] fragmentExtraBegin [opt] To additionally add fragment source
348 /// code to the beginning of the loaded file
349 /// source code
350 /// @param[in] fragmentExtraEnd [opt] To additionally add fragment source
351 /// code to the end of the loaded file
352 /// source code
353 /// @return true if compile was successed
354 ///
355 ///
356 /// @note In the case of a compile error, it will be written once into the Kodi
357 /// log and in addition to the console output to quickly detect the errors when
358 /// writing the damage.
359 ///
360 ///
361 bool CompileAndLink(const std::string& vertexExtraBegin = "",
362 const std::string& vertexExtraEnd = "",
363 const std::string& fragmentExtraBegin = "",
364 const std::string& fragmentExtraEnd = "")
365 {
366 GLint params[4];
367
368 // free resources
369 ShaderFree();
370 m_ok = false;
371
372 // compiled vertex shader
373 if (!m_pVP.Compile(vertexExtraBegin, vertexExtraEnd))
374 {
375 kodi::Log(ADDON_LOG_ERROR, "GL: Error compiling vertex shader");
376 return false;
377 }
378
379 // compile pixel shader
380 if (!m_pFP.Compile(fragmentExtraBegin, fragmentExtraEnd))
381 {
382 m_pVP.Free();
383 kodi::Log(ADDON_LOG_ERROR, "GL: Error compiling fragment shader");
384 return false;
385 }
386
387 // create program object
388 m_shaderProgram = glCreateProgram();
389 if (!m_shaderProgram)
390 {
391 kodi::Log(ADDON_LOG_ERROR, "CShaderProgram::%s: Failed to create GL program", __FUNCTION__);
392 ShaderFree();
393 return false;
394 }
395
396 // attach the vertex shader
397 glAttachShader(m_shaderProgram, m_pVP.Handle());
398 glAttachShader(m_shaderProgram, m_pFP.Handle());
399
400 // link the program
401 glLinkProgram(m_shaderProgram);
402 glGetProgramiv(m_shaderProgram, GL_LINK_STATUS, params);
403 if (params[0] != GL_TRUE)
404 {
405 GLchar log[LOG_SIZE];
406 glGetProgramInfoLog(m_shaderProgram, LOG_SIZE, nullptr, log);
407 kodi::Log(ADDON_LOG_ERROR, "CShaderProgram::%s: %s", __FUNCTION__, log);
408 fprintf(stderr, "CShaderProgram::%s: %s@n", __FUNCTION__, log);
409 ShaderFree();
410 return false;
411 }
412
413 m_validated = false;
414 m_ok = true;
415 OnCompiledAndLinked();
416 return true;
417 }
418 //--------------------------------------------------------------------------
419
420 //==========================================================================
421 /// @ingroup cpp_kodi_gui_helpers_gl_CShaderProgram
422 /// @brief To activate the shader and use it on the GPU.
423 ///
424 /// @return true if enable was successfull done
425 ///
426 ///
427 /// @note During this call, the @ref OnEnabled stored in the child is also
428 /// called
429 ///
430 bool EnableShader()
431 {
432 if (ShaderOK())
433 {
434 glUseProgram(m_shaderProgram);
435 if (OnEnabled())
436 {
437 if (!m_validated)
438 {
439 // validate the program
440 GLint params[4];
441 glValidateProgram(m_shaderProgram);
442 glGetProgramiv(m_shaderProgram, GL_VALIDATE_STATUS, params);
443 if (params[0] != GL_TRUE)
444 {
445 GLchar log[LOG_SIZE];
446 glGetProgramInfoLog(m_shaderProgram, LOG_SIZE, nullptr, log);
447 kodi::Log(ADDON_LOG_ERROR, "CShaderProgram::%s: %s", __FUNCTION__, log);
448 fprintf(stderr, "CShaderProgram::%s: %s\n", __FUNCTION__, log);
449 }
450 m_validated = true;
451 }
452 return true;
453 }
454 else
455 {
456 glUseProgram(0);
457 return false;
458 }
459 return true;
460 }
461 return false;
462 }
463 //--------------------------------------------------------------------------
464
465 //==========================================================================
466 /// @ingroup cpp_kodi_gui_helpers_gl_CShaderProgram
467 /// @brief To deactivate the shader use on the GPU.
468 ///
469 void DisableShader()
470 {
471 if (ShaderOK())
472 {
473 glUseProgram(0);
474 OnDisabled();
475 }
476 }
477 //--------------------------------------------------------------------------
478
479 //==========================================================================
480 /// @ingroup cpp_kodi_gui_helpers_gl_CShaderProgram
481 /// @brief Used to check if shader has been loaded before.
482 ///
483 /// @return true if enable was successfull done
484 ///
485 /// @note The CompileAndLink call sets these values
486 ///
487 ATTRIBUTE_FORCEINLINE bool ShaderOK() const { return m_ok; }
488 //--------------------------------------------------------------------------
489
490 //==========================================================================
491 /// @ingroup cpp_kodi_gui_helpers_gl_CShaderProgram
492 /// @brief To get the vertex shader class used by Kodi at the addon.
493 ///
494 /// @return pointer to vertex shader class
495 ///
496 ATTRIBUTE_FORCEINLINE CVertexShader& VertexShader() { return m_pVP; }
497 //--------------------------------------------------------------------------
498
499 //==========================================================================
500 /// @ingroup cpp_kodi_gui_helpers_gl_CShaderProgram
501 /// @brief To get the fragment shader class used by Kodi at the addon.
502 ///
503 /// @return pointer to fragment shader class
504 ///
505 ATTRIBUTE_FORCEINLINE CPixelShader& PixelShader() { return m_pFP; }
506 //--------------------------------------------------------------------------
507
508 //==========================================================================
509 /// @ingroup cpp_kodi_gui_helpers_gl_CShaderProgram
510 /// @brief Used to get the definition created in the OpenGL itself.
511 ///
512 /// @return GLuint of GL shader program handler
513 ///
514 ATTRIBUTE_FORCEINLINE GLuint ProgramHandle() { return m_shaderProgram; }
515 //--------------------------------------------------------------------------
516
517 //==========================================================================
518 /// @defgroup cpp_kodi_gui_helpers_gl_CShaderProgram_child Child Functions
519 /// @ingroup cpp_kodi_gui_helpers_gl_CShaderProgram
520 /// @brief @cpp_class{ kodi::gui::gl::CShaderProgram child functions }
521 ///
522 /// Functions that are added by parent in the child
523 /// @{
524 //==========================================================================
525 ///
526 /// @ingroup cpp_kodi_gui_helpers_gl_CShaderProgram_child
527 /// @brief Mandatory child function to set the necessary CPU to GPU data
528 ///
529 virtual void OnCompiledAndLinked(){};
530 //--------------------------------------------------------------------------
531
532 //==========================================================================
533 /// @ingroup cpp_kodi_gui_helpers_gl_CShaderProgram_child
534 /// @brief Optional function to exchange data between CPU and GPU while
535 /// activating the shader
536 ///
537 /// @return true if enable was successfull done
538 ///
539 virtual bool OnEnabled() { return true; };
540 //--------------------------------------------------------------------------
541
542 //==========================================================================
543 /// @ingroup cpp_kodi_gui_helpers_gl_CShaderProgram_child
544 /// @brief Optional child function that may have to be performed when
545 /// switching off the shader
546 virtual void OnDisabled(){};
547 //--------------------------------------------------------------------------
548 /// @}
549
550private:
551 void ShaderFree()
552 {
553 if (m_shaderProgram)
554 glDeleteProgram(m_shaderProgram);
555 m_shaderProgram = 0;
556 m_ok = false;
557 }
558
559 CVertexShader m_pVP;
560 CPixelShader m_pFP;
561 GLuint m_shaderProgram = 0;
562 bool m_ok = false;
563 bool m_validated = false;
564};
565//------------------------------------------------------------------------
566
567} /* namespace gl */
568} /* namespace gui */
569} /* namespace kodi */
570
571#endif /* __cplusplus */
diff --git a/xbmc/addons/kodi-dev-kit/include/kodi/gui/input/ActionIDs.h b/xbmc/addons/kodi-dev-kit/include/kodi/gui/input/ActionIDs.h
new file mode 100644
index 0000000..4c816a4
--- /dev/null
+++ b/xbmc/addons/kodi-dev-kit/include/kodi/gui/input/ActionIDs.h
@@ -0,0 +1,11 @@
1/*
2 * Copyright (C) 2005-2020 Team Kodi
3 * This file is part of Kodi - https://kodi.tv
4 *
5 * SPDX-License-Identifier: GPL-2.0-or-later
6 * See LICENSES/README.md for more information.
7 */
8
9#pragma once
10
11#include "../../c-api/gui/input/action_ids.h"
diff --git a/xbmc/addons/kodi-dev-kit/include/kodi/gui/input/CMakeLists.txt b/xbmc/addons/kodi-dev-kit/include/kodi/gui/input/CMakeLists.txt
new file mode 100644
index 0000000..d576974
--- /dev/null
+++ b/xbmc/addons/kodi-dev-kit/include/kodi/gui/input/CMakeLists.txt
@@ -0,0 +1,5 @@
1set(HEADERS ActionIDs.h)
2
3if(NOT ENABLE_STATIC_LIBS)
4 core_add_library(addons_kodi-dev-kit_include_kodi_gui_input)
5endif()
diff --git a/xbmc/addons/kodi-dev-kit/include/kodi/gui/renderHelper.h b/xbmc/addons/kodi-dev-kit/include/kodi/gui/renderHelper.h
new file mode 100644
index 0000000..dabe101
--- /dev/null
+++ b/xbmc/addons/kodi-dev-kit/include/kodi/gui/renderHelper.h
@@ -0,0 +1,82 @@
1/*
2 * Copyright (C) 2005-2019 Team Kodi
3 * This file is part of Kodi - https://kodi.tv
4 *
5 * SPDX-License-Identifier: GPL-2.0-or-later
6 * See LICENSES/README.md for more information.
7 */
8
9#pragma once
10
11#include "../AddonBase.h"
12
13#ifdef __cplusplus
14
15namespace kodi
16{
17namespace gui
18{
19struct ATTRIBUTE_HIDDEN IRenderHelper
20{
21 virtual ~IRenderHelper() = default;
22 virtual bool Init() = 0;
23 virtual void Begin() = 0;
24 virtual void End() = 0;
25}; /* class IRenderHelper */
26} /* namespace gui */
27} /* namespace kodi */
28
29#if defined(WIN32) && defined(HAS_ANGLE)
30#include "gl/GLonDX.h"
31#else
32/*
33 * Default background GUI render helper class
34 */
35namespace kodi
36{
37namespace gui
38{
39struct ATTRIBUTE_HIDDEN CRenderHelperStub : public IRenderHelper
40{
41 bool Init() override { return true; }
42 void Begin() override {}
43 void End() override {}
44}; /* class CRenderHelperStub */
45
46using CRenderHelper = CRenderHelperStub;
47} /* namespace gui */
48} /* namespace kodi */
49#endif
50
51namespace kodi
52{
53namespace gui
54{
55
56/*
57 * Create render background handler, e.g. becomes on "Windows" Angle used
58 * to emulate GL.
59 *
60 * This only be used internal and not from addon's direct.
61 *
62 * Function defines here and not in CAddonBase because of a hen and egg problem.
63 */
64inline std::shared_ptr<IRenderHelper> ATTRIBUTE_HIDDEN GetRenderHelper()
65{
66 using namespace ::kodi::addon;
67 if (static_cast<CAddonBase*>(CAddonBase::m_interface->addonBase)->m_renderHelper)
68 return static_cast<CAddonBase*>(CAddonBase::m_interface->addonBase)->m_renderHelper;
69
70 const std::shared_ptr<kodi::gui::IRenderHelper> renderHelper(new CRenderHelper());
71 if (!renderHelper->Init())
72 return nullptr;
73
74 static_cast<CAddonBase*>(CAddonBase::m_interface->addonBase)->m_renderHelper =
75 renderHelper; // Hold on base for other types
76 return renderHelper;
77}
78
79} /* namespace gui */
80} /* namespace kodi */
81
82#endif /* __cplusplus */
diff --git a/xbmc/addons/kodi-dev-kit/include/kodi/platform/android/System.h b/xbmc/addons/kodi-dev-kit/include/kodi/platform/android/System.h
new file mode 100644
index 0000000..245abd6
--- /dev/null
+++ b/xbmc/addons/kodi-dev-kit/include/kodi/platform/android/System.h
@@ -0,0 +1,105 @@
1/*
2 * Copyright (C) 2005-2018 Team Kodi
3 * This file is part of Kodi - https://kodi.tv
4 *
5 * SPDX-License-Identifier: GPL-2.0-or-later
6 * See LICENSES/README.md for more information.
7 */
8
9#pragma once
10
11#include "../../AddonBase.h"
12#include "../../c-api/platform/android/system.h"
13
14#ifdef __cplusplus
15namespace kodi
16{
17namespace platform
18{
19
20//==============================================================================
21/// @defgroup cpp_kodi_platform_CInterfaceAndroidSystem class CInterfaceAndroidSystem
22/// @ingroup cpp_kodi_platform
23/// @brief **Android platform specific functions**\n
24/// C++ class to query Android specific things in Kodi.
25///
26/// It has the header is @ref System.h "#include <kodi/platform/android/System.h>".
27///
28/// ----------------------------------------------------------------------------
29///
30/// **Example:**
31/// ~~~~~~~~~~~~~{.cpp}
32/// #include <kodi/platform/android/System.h>
33///
34/// #if defined(ANDROID)
35/// kodi::platform::CInterfaceAndroidSystem system;
36/// if (system.GetSDKVersion() >= 23)
37/// {
38/// ...
39/// }
40/// #endif
41/// ~~~~~~~~~~~~~
42///
43class ATTRIBUTE_HIDDEN CInterfaceAndroidSystem
44{
45public:
46 CInterfaceAndroidSystem()
47 : m_interface(static_cast<AddonToKodiFuncTable_android_system*>(
48 GetInterface(INTERFACE_ANDROID_SYSTEM_NAME, INTERFACE_ANDROID_SYSTEM_VERSION))){};
49
50 //============================================================================
51 /// @ingroup cpp_kodi_platform_CInterfaceAndroidSystem
52 /// @brief Request an JNI env pointer for the calling thread.
53 ///
54 /// JNI env has to be controlled by kodi because of the underlying
55 /// threading concep.
56 ///
57 /// @return JNI env pointer for the calling thread
58 ///
59 inline void* GetJNIEnv()
60 {
61 if (m_interface)
62 return m_interface->get_jni_env();
63
64 return nullptr;
65 }
66 //----------------------------------------------------------------------------
67
68 //============================================================================
69 /// @ingroup cpp_kodi_platform_CInterfaceAndroidSystem
70 /// @brief Request the android sdk version to e.g. initialize <b>`JNIBase`</b>.
71 ///
72 /// @return Android SDK version
73 ///
74 inline int GetSDKVersion()
75 {
76 if (m_interface)
77 return m_interface->get_sdk_version();
78
79 return 0;
80 }
81 //----------------------------------------------------------------------------
82
83 //============================================================================
84 /// @ingroup cpp_kodi_platform_CInterfaceAndroidSystem
85 /// @brief Request the android main class name e.g. <b>`org.xbmc.kodi`</b>.
86 ///
87 /// @return package class name
88 ///
89 inline std::string GetClassName()
90 {
91 if (m_interface)
92 return m_interface->get_class_name();
93
94 return std::string();
95 }
96 //----------------------------------------------------------------------------
97
98private:
99 AddonToKodiFuncTable_android_system* m_interface;
100};
101//------------------------------------------------------------------------------
102
103} /* namespace platform */
104} /* namespace kodi */
105#endif /* __cplusplus */
diff --git a/xbmc/addons/kodi-dev-kit/include/kodi/tools/CMakeLists.txt b/xbmc/addons/kodi-dev-kit/include/kodi/tools/CMakeLists.txt
new file mode 100644
index 0000000..16b83cb
--- /dev/null
+++ b/xbmc/addons/kodi-dev-kit/include/kodi/tools/CMakeLists.txt
@@ -0,0 +1,9 @@
1set(HEADERS DllHelper.h
2 EndTime.h
3 StringUtils.h
4 Thread.h
5 Timer.h)
6
7if(NOT ENABLE_STATIC_LIBS)
8 core_add_library(addons_kodi-dev-kit_include_kodi_tools)
9endif()
diff --git a/xbmc/addons/kodi-dev-kit/include/kodi/tools/DllHelper.h b/xbmc/addons/kodi-dev-kit/include/kodi/tools/DllHelper.h
new file mode 100644
index 0000000..3cc9eea
--- /dev/null
+++ b/xbmc/addons/kodi-dev-kit/include/kodi/tools/DllHelper.h
@@ -0,0 +1,211 @@
1/*
2 * Copyright (C) 2005-2018 Team Kodi
3 * This file is part of Kodi - https://kodi.tv
4 *
5 * SPDX-License-Identifier: GPL-2.0-or-later
6 * See LICENSES/README.md for more information.
7 */
8
9#pragma once
10
11#ifdef __cplusplus
12
13#include <string>
14
15#include <dlfcn.h>
16#include <kodi/AddonBase.h>
17#include <kodi/Filesystem.h>
18
19//==============================================================================
20/// @ingroup cpp_kodi_tools_CDllHelper
21/// @brief Macro to translate the given pointer value name of functions to
22/// requested function name.
23///
24/// @note This should always be used and does the work of
25/// @ref kodi::tools::CDllHelper::RegisterSymbol().
26///
27#define REGISTER_DLL_SYMBOL(functionPtr) \
28 kodi::tools::CDllHelper::RegisterSymbol(functionPtr, #functionPtr)
29//------------------------------------------------------------------------------
30
31namespace kodi
32{
33namespace tools
34{
35
36//==============================================================================
37/// @defgroup cpp_kodi_tools_CDllHelper class CDllHelper
38/// @ingroup cpp_kodi_tools
39/// @brief **Class to help with load of shared library functions**\n
40/// You can add them as parent to your class and to help with load of shared
41/// library functions.
42///
43/// @note To use on Windows must you also include [dlfcn-win32](https://github.com/dlfcn-win32/dlfcn-win32)
44/// on your addon!\n\n
45/// Furthermore, this allows the use of Android where the required library is
46/// copied to an EXE useable folder.
47///
48///
49/// ----------------------------------------------------------------------------
50///
51/// **Example:**
52/// ~~~~~~~~~~~~~{.cpp}
53///
54/// #include <kodi/tools/DllHelper.h>
55///
56/// ...
57/// class CMyInstance : public kodi::addon::CInstanceAudioDecoder,
58/// private kodi::tools::CDllHelper
59/// {
60/// public:
61/// CMyInstance(KODI_HANDLE instance, const std::string& kodiVersion);
62/// bool Start();
63///
64/// ...
65///
66/// // The pointers for on shared library exported functions
67/// int (*Init)();
68/// void (*Cleanup)();
69/// int (*GetLength)();
70/// };
71///
72/// CMyInstance::CMyInstance(KODI_HANDLE instance, const std::string& kodiVersion)
73/// : CInstanceAudioDecoder(instance, kodiVersion)
74/// {
75/// }
76///
77/// bool CMyInstance::Start()
78/// {
79/// std::string lib = kodi::GetAddonPath("myLib.so");
80/// if (!LoadDll(lib)) return false;
81/// if (!REGISTER_DLL_SYMBOL(Init)) return false;
82/// if (!REGISTER_DLL_SYMBOL(Cleanup)) return false;
83/// if (!REGISTER_DLL_SYMBOL(GetLength)) return false;
84///
85/// Init();
86/// return true;
87/// }
88/// ...
89/// ~~~~~~~~~~~~~
90///
91///@{
92class ATTRIBUTE_HIDDEN CDllHelper
93{
94public:
95 //============================================================================
96 /// @ingroup cpp_kodi_tools_CDllHelper
97 /// @brief Class constructor.
98 ///
99 CDllHelper() = default;
100 //----------------------------------------------------------------------------
101
102 //============================================================================
103 /// @ingroup cpp_kodi_tools_CDllHelper
104 /// @brief Class destructor.
105 ///
106 virtual ~CDllHelper()
107 {
108 if (m_dll)
109 dlclose(m_dll);
110 }
111 //----------------------------------------------------------------------------
112
113 //============================================================================
114 /// @ingroup cpp_kodi_tools_CDllHelper
115 /// @brief Function to load requested library.
116 ///
117 /// @param[in] path The path with filename of shared library to load
118 /// @return true if load was successful done
119 ///
120 bool LoadDll(std::string path)
121 {
122#if defined(TARGET_ANDROID)
123 if (kodi::vfs::FileExists(path))
124 {
125 // Check already defined for "xbmcaltbinaddons", if yes no copy necassary.
126 std::string xbmcaltbinaddons =
127 kodi::vfs::TranslateSpecialProtocol("special://xbmcaltbinaddons/");
128 if (path.compare(0, xbmcaltbinaddons.length(), xbmcaltbinaddons) != 0)
129 {
130 bool doCopy = true;
131 std::string dstfile = xbmcaltbinaddons + kodi::vfs::GetFileName(path);
132
133 kodi::vfs::FileStatus dstFileStat;
134 if (kodi::vfs::StatFile(dstfile, dstFileStat))
135 {
136 kodi::vfs::FileStatus srcFileStat;
137 if (kodi::vfs::StatFile(path, srcFileStat))
138 {
139 if (dstFileStat.GetSize() == srcFileStat.GetSize() &&
140 dstFileStat.GetModificationTime() > srcFileStat.GetModificationTime())
141 doCopy = false;
142 }
143 }
144
145 if (doCopy)
146 {
147 kodi::Log(ADDON_LOG_DEBUG, "Caching '%s' to '%s'", path.c_str(), dstfile.c_str());
148 if (!kodi::vfs::CopyFile(path, dstfile))
149 {
150 kodi::Log(ADDON_LOG_ERROR, "Failed to cache '%s' to '%s'", path.c_str(),
151 dstfile.c_str());
152 return false;
153 }
154 }
155
156 path = dstfile;
157 }
158 }
159 else
160 {
161 return false;
162 }
163#endif
164
165 m_dll = dlopen(path.c_str(), RTLD_LAZY);
166 if (m_dll == nullptr)
167 {
168 kodi::Log(ADDON_LOG_ERROR, "Unable to load %s", dlerror());
169 return false;
170 }
171 return true;
172 }
173 //----------------------------------------------------------------------------
174
175 //============================================================================
176 /// @ingroup cpp_kodi_tools_CDllHelper
177 /// @brief Function to register requested library symbol.
178 ///
179 /// @warning This function should not be used, use instead the macro
180 /// @ref REGISTER_DLL_SYMBOL to register the symbol pointer.
181 ///
182 ///
183 /// Use this always via Macro, e.g.:
184 /// ~~~~~~~~~~~~~{.cpp}
185 /// if (!REGISTER_DLL_SYMBOL(Init))
186 /// return false;
187 /// ~~~~~~~~~~~~~
188 ///
189 template <typename T>
190 bool RegisterSymbol(T& functionPtr, const char* strFunctionPtr)
191 {
192 functionPtr = reinterpret_cast<T>(dlsym(m_dll, strFunctionPtr));
193 if (functionPtr == nullptr)
194 {
195 kodi::Log(ADDON_LOG_ERROR, "Unable to assign function %s", dlerror());
196 return false;
197 }
198 return true;
199 }
200 //----------------------------------------------------------------------------
201
202private:
203 void* m_dll = nullptr;
204};
205///@}
206//------------------------------------------------------------------------------
207
208} /* namespace tools */
209} /* namespace kodi */
210
211#endif /* __cplusplus */
diff --git a/xbmc/addons/kodi-dev-kit/include/kodi/tools/EndTime.h b/xbmc/addons/kodi-dev-kit/include/kodi/tools/EndTime.h
new file mode 100644
index 0000000..14983fa
--- /dev/null
+++ b/xbmc/addons/kodi-dev-kit/include/kodi/tools/EndTime.h
@@ -0,0 +1,215 @@
1/*
2 * Copyright (C) 2005-2020 Team Kodi
3 * https://kodi.tv
4 *
5 * SPDX-License-Identifier: GPL-2.0-or-later
6 * See LICENSE.md for more information.
7 */
8
9#pragma once
10
11#ifdef __cplusplus
12
13#include <chrono>
14
15namespace kodi
16{
17namespace tools
18{
19
20//==============================================================================
21/// @defgroup cpp_kodi_tools_CEndTime class CEndTime
22/// @ingroup cpp_kodi_tools
23/// @brief **Timeout check**\n
24/// Class which makes it easy to check if a specified amount of time has passed.
25///
26/// This code uses the support of platform-independent chrono system introduced
27/// with C++11.
28///
29///
30/// ----------------------------------------------------------------------------
31///
32/// **Example:**
33/// ~~~~~~~~~~~~~{.cpp}
34/// #include <kodi/tools/EndTime.h>
35///
36/// class ATTRIBUTE_HIDDEN CExample
37/// {
38/// public:
39/// CExample()
40/// {
41/// TimerCall();
42/// }
43///
44/// void TimerCall()
45/// {
46/// fprintf(stderr, "Hello World\n");
47/// CEndTime timer(1000);
48///
49/// while (timer.MillisLeft())
50/// {
51/// if (timer.IsTimePast())
52/// {
53/// fprintf(stderr, "We timed out!\n");
54/// }
55/// std::this_thread::sleep_for(std::chrono::milliseconds(10));
56/// }
57/// }
58///
59/// };
60/// ~~~~~~~~~~~~~
61///
62///@{
63class CEndTime
64{
65public:
66 //============================================================================
67 /// @ingroup cpp_kodi_tools_CEndTime
68 /// @brief Class constructor with no time to expiry set
69 ///
70 inline CEndTime() = default;
71 //============================================================================
72 /// @ingroup cpp_kodi_tools_CEndTime
73 /// @brief Class constructor to set future time when timer has expired
74 ///
75 /// @param[in] millisecondsIntoTheFuture the time in the future we cosider this timer as expired
76 ///
77 inline explicit CEndTime(unsigned int millisecondsIntoTheFuture)
78 : m_startTime(std::chrono::system_clock::now().time_since_epoch()),
79 m_totalWaitTime(std::chrono::milliseconds(millisecondsIntoTheFuture))
80 {
81 }
82 //----------------------------------------------------------------------------
83
84 //============================================================================
85 /// @ingroup cpp_kodi_tools_CEndTime
86 /// @brief Set the time in the future we cosider this timer as expired
87 ///
88 /// @param[in] millisecondsIntoTheFuture the time in the future we cosider this timer as expired
89 ///
90 inline void Set(unsigned int millisecondsIntoTheFuture)
91 {
92 using namespace std::chrono;
93
94 m_startTime = system_clock::now().time_since_epoch();
95 m_totalWaitTime = milliseconds(millisecondsIntoTheFuture);
96 }
97 //----------------------------------------------------------------------------
98
99 //============================================================================
100 /// @ingroup cpp_kodi_tools_CEndTime
101 /// @brief Check if the expiry time has been reached
102 ///
103 /// @return True if the expiry amount of time has past, false otherwise
104 ///
105 inline bool IsTimePast() const
106 {
107 using namespace std::chrono;
108
109 // timer is infinite
110 if (m_totalWaitTime.count() == std::numeric_limits<unsigned int>::max())
111 return false;
112
113 if (m_totalWaitTime.count() == 0)
114 return true;
115 else
116 return (system_clock::now().time_since_epoch() - m_startTime) >= m_totalWaitTime;
117 }
118 //----------------------------------------------------------------------------
119
120 //============================================================================
121 /// @ingroup cpp_kodi_tools_CEndTime
122 /// @brief The amount of time left till this timer expires
123 ///
124 /// @return 0 if the expiry amount of time has past, the numbe rof milliseconds remaining otherwise
125 ///
126 inline unsigned int MillisLeft() const
127 {
128 using namespace std::chrono;
129
130 // timer is infinite
131 if (m_totalWaitTime.count() == std::numeric_limits<unsigned int>::max())
132 return std::numeric_limits<unsigned int>::max();
133
134 if (m_totalWaitTime.count() == 0)
135 return 0;
136
137 auto elapsed = system_clock::now().time_since_epoch() - m_startTime;
138
139 auto timeWaitedAlready = duration_cast<milliseconds>(elapsed).count();
140
141 if (timeWaitedAlready >= m_totalWaitTime.count())
142 return 0;
143
144 return static_cast<unsigned int>(m_totalWaitTime.count() - timeWaitedAlready);
145 }
146 //----------------------------------------------------------------------------
147
148 //============================================================================
149 /// @ingroup cpp_kodi_tools_CEndTime
150 /// @brief Consider this timer expired
151 ///
152 inline void SetExpired()
153 {
154 using namespace std::chrono;
155 m_totalWaitTime = milliseconds(0);
156 }
157 //----------------------------------------------------------------------------
158
159 //============================================================================
160 /// @ingroup cpp_kodi_tools_CEndTime
161 /// @brief Set this timer as never expiring
162 ///
163 inline void SetInfinite()
164 {
165 using namespace std::chrono;
166 m_totalWaitTime = milliseconds(std::numeric_limits<unsigned int>::max());
167 }
168 //----------------------------------------------------------------------------
169
170 //============================================================================
171 /// @ingroup cpp_kodi_tools_CEndTime
172 /// @brief Check if the timer has been set to infinite expiry
173 ///
174 /// @return True if the expiry has been set as infinite, false otherwise
175 ///
176 inline bool IsInfinite(void) const
177 {
178 return (m_totalWaitTime.count() == std::numeric_limits<unsigned int>::max());
179 }
180 //----------------------------------------------------------------------------
181
182 //============================================================================
183 /// @ingroup cpp_kodi_tools_CEndTime
184 /// @brief Get the initial timeout value this timer had
185 ///
186 /// @return The initial expiry amount of time this timer had in milliseconds
187 ///
188 inline unsigned int GetInitialTimeoutValue(void) const
189 {
190 auto value = std::chrono::duration_cast<std::chrono::milliseconds>(m_totalWaitTime);
191 return static_cast<unsigned int>(value.count());
192 }
193
194 //============================================================================
195 /// @ingroup cpp_kodi_tools_CEndTime
196 /// @brief Get the time this timer started
197 ///
198 /// @return The time this timer started in milliseconds since epoch
199 ///
200 inline uint64_t GetStartTime(void) const
201 {
202 auto value = std::chrono::duration_cast<std::chrono::milliseconds>(m_startTime);
203 return value.count();
204 }
205 //----------------------------------------------------------------------------
206
207private:
208 std::chrono::system_clock::duration m_startTime;
209 std::chrono::system_clock::duration m_totalWaitTime;
210};
211
212} /* namespace tools */
213} /* namespace kodi */
214
215#endif /* __cplusplus */
diff --git a/xbmc/addons/kodi-dev-kit/include/kodi/tools/StringUtils.h b/xbmc/addons/kodi-dev-kit/include/kodi/tools/StringUtils.h
new file mode 100644
index 0000000..977c0e5
--- /dev/null
+++ b/xbmc/addons/kodi-dev-kit/include/kodi/tools/StringUtils.h
@@ -0,0 +1,3086 @@
1/*
2 * Copyright (C) 2005-2020 Team Kodi
3 * This file is part of Kodi - https://kodi.tv
4 *
5 * SPDX-License-Identifier: GPL-2.0-or-later
6 * See LICENSES/README.md for more information.
7 */
8
9#pragma once
10
11#ifdef __cplusplus
12
13#if !defined(NOMINMAX)
14#define NOMINMAX
15#endif
16
17#include <algorithm>
18#include <array>
19#include <cassert>
20#include <cinttypes>
21#include <cmath>
22#include <cstdarg>
23#include <cstring>
24#include <iomanip>
25#include <regex>
26#include <sstream>
27#include <string>
28#include <vector>
29
30// # of bytes for initial allocation for printf
31#define FORMAT_BLOCK_SIZE 512
32
33// macros for gcc, clang & others
34#ifndef PARAM1_PRINTF_FORMAT
35#ifdef __GNUC__
36// for use in functions that take printf format string as first parameter and additional printf parameters as second parameter
37// for example: int myprintf(const char* format, ...) PARAM1_PRINTF_FORMAT;
38#define PARAM1_PRINTF_FORMAT __attribute__((format(printf, 1, 2)))
39
40// for use in functions that take printf format string as second parameter and additional printf parameters as third parameter
41// for example: bool log_string(int logLevel, const char* format, ...) PARAM2_PRINTF_FORMAT;
42// note: all non-static class member functions take pointer to class object as hidden first parameter
43#define PARAM2_PRINTF_FORMAT __attribute__((format(printf, 2, 3)))
44
45// for use in functions that take printf format string as third parameter and additional printf parameters as fourth parameter
46// note: all non-static class member functions take pointer to class object as hidden first parameter
47// for example: class A { bool log_string(int logLevel, const char* functionName, const char* format, ...) PARAM3_PRINTF_FORMAT; };
48#define PARAM3_PRINTF_FORMAT __attribute__((format(printf, 3, 4)))
49
50// for use in functions that take printf format string as fourth parameter and additional printf parameters as fith parameter
51// note: all non-static class member functions take pointer to class object as hidden first parameter
52// for example: class A { bool log_string(int logLevel, const char* functionName, int component, const char* format, ...) PARAM4_PRINTF_FORMAT; };
53#define PARAM4_PRINTF_FORMAT __attribute__((format(printf, 4, 5)))
54#else // ! __GNUC__
55#define PARAM1_PRINTF_FORMAT
56#define PARAM2_PRINTF_FORMAT
57#define PARAM3_PRINTF_FORMAT
58#define PARAM4_PRINTF_FORMAT
59#endif // ! __GNUC__
60#endif // PARAM1_PRINTF_FORMAT
61
62// macros for VC
63// VC check parameters only when "Code Analysis" is called
64#ifndef PRINTF_FORMAT_STRING
65#ifdef _MSC_VER
66#include <sal.h>
67
68// for use in any function that take printf format string and parameters
69// for example: bool log_string(int logLevel, PRINTF_FORMAT_STRING const char* format, ...);
70#define PRINTF_FORMAT_STRING _In_z_ _Printf_format_string_
71
72// specify that parameter must be zero-terminated string
73// for example: void SetName(IN_STRING const char* newName);
74#define IN_STRING _In_z_
75
76// specify that parameter must be zero-terminated string or NULL
77// for example: bool SetAdditionalName(IN_OPT_STRING const char* addName);
78#define IN_OPT_STRING _In_opt_z_
79#else // ! _MSC_VER
80#define PRINTF_FORMAT_STRING
81#define IN_STRING
82#define IN_OPT_STRING
83#endif // ! _MSC_VER
84#endif // PRINTF_FORMAT_STRING
85
86static constexpr wchar_t unicode_lowers[] = {
87 (wchar_t)0x0061, (wchar_t)0x0062, (wchar_t)0x0063, (wchar_t)0x0064, (wchar_t)0x0065,
88 (wchar_t)0x0066, (wchar_t)0x0067, (wchar_t)0x0068, (wchar_t)0x0069, (wchar_t)0x006A,
89 (wchar_t)0x006B, (wchar_t)0x006C, (wchar_t)0x006D, (wchar_t)0x006E, (wchar_t)0x006F,
90 (wchar_t)0x0070, (wchar_t)0x0071, (wchar_t)0x0072, (wchar_t)0x0073, (wchar_t)0x0074,
91 (wchar_t)0x0075, (wchar_t)0x0076, (wchar_t)0x0077, (wchar_t)0x0078, (wchar_t)0x0079,
92 (wchar_t)0x007A, (wchar_t)0x00E0, (wchar_t)0x00E1, (wchar_t)0x00E2, (wchar_t)0x00E3,
93 (wchar_t)0x00E4, (wchar_t)0x00E5, (wchar_t)0x00E6, (wchar_t)0x00E7, (wchar_t)0x00E8,
94 (wchar_t)0x00E9, (wchar_t)0x00EA, (wchar_t)0x00EB, (wchar_t)0x00EC, (wchar_t)0x00ED,
95 (wchar_t)0x00EE, (wchar_t)0x00EF, (wchar_t)0x00F0, (wchar_t)0x00F1, (wchar_t)0x00F2,
96 (wchar_t)0x00F3, (wchar_t)0x00F4, (wchar_t)0x00F5, (wchar_t)0x00F6, (wchar_t)0x00F8,
97 (wchar_t)0x00F9, (wchar_t)0x00FA, (wchar_t)0x00FB, (wchar_t)0x00FC, (wchar_t)0x00FD,
98 (wchar_t)0x00FE, (wchar_t)0x00FF, (wchar_t)0x0101, (wchar_t)0x0103, (wchar_t)0x0105,
99 (wchar_t)0x0107, (wchar_t)0x0109, (wchar_t)0x010B, (wchar_t)0x010D, (wchar_t)0x010F,
100 (wchar_t)0x0111, (wchar_t)0x0113, (wchar_t)0x0115, (wchar_t)0x0117, (wchar_t)0x0119,
101 (wchar_t)0x011B, (wchar_t)0x011D, (wchar_t)0x011F, (wchar_t)0x0121, (wchar_t)0x0123,
102 (wchar_t)0x0125, (wchar_t)0x0127, (wchar_t)0x0129, (wchar_t)0x012B, (wchar_t)0x012D,
103 (wchar_t)0x012F, (wchar_t)0x0131, (wchar_t)0x0133, (wchar_t)0x0135, (wchar_t)0x0137,
104 (wchar_t)0x013A, (wchar_t)0x013C, (wchar_t)0x013E, (wchar_t)0x0140, (wchar_t)0x0142,
105 (wchar_t)0x0144, (wchar_t)0x0146, (wchar_t)0x0148, (wchar_t)0x014B, (wchar_t)0x014D,
106 (wchar_t)0x014F, (wchar_t)0x0151, (wchar_t)0x0153, (wchar_t)0x0155, (wchar_t)0x0157,
107 (wchar_t)0x0159, (wchar_t)0x015B, (wchar_t)0x015D, (wchar_t)0x015F, (wchar_t)0x0161,
108 (wchar_t)0x0163, (wchar_t)0x0165, (wchar_t)0x0167, (wchar_t)0x0169, (wchar_t)0x016B,
109 (wchar_t)0x016D, (wchar_t)0x016F, (wchar_t)0x0171, (wchar_t)0x0173, (wchar_t)0x0175,
110 (wchar_t)0x0177, (wchar_t)0x017A, (wchar_t)0x017C, (wchar_t)0x017E, (wchar_t)0x0183,
111 (wchar_t)0x0185, (wchar_t)0x0188, (wchar_t)0x018C, (wchar_t)0x0192, (wchar_t)0x0199,
112 (wchar_t)0x01A1, (wchar_t)0x01A3, (wchar_t)0x01A5, (wchar_t)0x01A8, (wchar_t)0x01AD,
113 (wchar_t)0x01B0, (wchar_t)0x01B4, (wchar_t)0x01B6, (wchar_t)0x01B9, (wchar_t)0x01BD,
114 (wchar_t)0x01C6, (wchar_t)0x01C9, (wchar_t)0x01CC, (wchar_t)0x01CE, (wchar_t)0x01D0,
115 (wchar_t)0x01D2, (wchar_t)0x01D4, (wchar_t)0x01D6, (wchar_t)0x01D8, (wchar_t)0x01DA,
116 (wchar_t)0x01DC, (wchar_t)0x01DF, (wchar_t)0x01E1, (wchar_t)0x01E3, (wchar_t)0x01E5,
117 (wchar_t)0x01E7, (wchar_t)0x01E9, (wchar_t)0x01EB, (wchar_t)0x01ED, (wchar_t)0x01EF,
118 (wchar_t)0x01F3, (wchar_t)0x01F5, (wchar_t)0x01FB, (wchar_t)0x01FD, (wchar_t)0x01FF,
119 (wchar_t)0x0201, (wchar_t)0x0203, (wchar_t)0x0205, (wchar_t)0x0207, (wchar_t)0x0209,
120 (wchar_t)0x020B, (wchar_t)0x020D, (wchar_t)0x020F, (wchar_t)0x0211, (wchar_t)0x0213,
121 (wchar_t)0x0215, (wchar_t)0x0217, (wchar_t)0x0253, (wchar_t)0x0254, (wchar_t)0x0257,
122 (wchar_t)0x0258, (wchar_t)0x0259, (wchar_t)0x025B, (wchar_t)0x0260, (wchar_t)0x0263,
123 (wchar_t)0x0268, (wchar_t)0x0269, (wchar_t)0x026F, (wchar_t)0x0272, (wchar_t)0x0275,
124 (wchar_t)0x0283, (wchar_t)0x0288, (wchar_t)0x028A, (wchar_t)0x028B, (wchar_t)0x0292,
125 (wchar_t)0x03AC, (wchar_t)0x03AD, (wchar_t)0x03AE, (wchar_t)0x03AF, (wchar_t)0x03B1,
126 (wchar_t)0x03B2, (wchar_t)0x03B3, (wchar_t)0x03B4, (wchar_t)0x03B5, (wchar_t)0x03B6,
127 (wchar_t)0x03B7, (wchar_t)0x03B8, (wchar_t)0x03B9, (wchar_t)0x03BA, (wchar_t)0x03BB,
128 (wchar_t)0x03BC, (wchar_t)0x03BD, (wchar_t)0x03BE, (wchar_t)0x03BF, (wchar_t)0x03C0,
129 (wchar_t)0x03C1, (wchar_t)0x03C3, (wchar_t)0x03C4, (wchar_t)0x03C5, (wchar_t)0x03C6,
130 (wchar_t)0x03C7, (wchar_t)0x03C8, (wchar_t)0x03C9, (wchar_t)0x03CA, (wchar_t)0x03CB,
131 (wchar_t)0x03CC, (wchar_t)0x03CD, (wchar_t)0x03CE, (wchar_t)0x03E3, (wchar_t)0x03E5,
132 (wchar_t)0x03E7, (wchar_t)0x03E9, (wchar_t)0x03EB, (wchar_t)0x03ED, (wchar_t)0x03EF,
133 (wchar_t)0x0430, (wchar_t)0x0431, (wchar_t)0x0432, (wchar_t)0x0433, (wchar_t)0x0434,
134 (wchar_t)0x0435, (wchar_t)0x0436, (wchar_t)0x0437, (wchar_t)0x0438, (wchar_t)0x0439,
135 (wchar_t)0x043A, (wchar_t)0x043B, (wchar_t)0x043C, (wchar_t)0x043D, (wchar_t)0x043E,
136 (wchar_t)0x043F, (wchar_t)0x0440, (wchar_t)0x0441, (wchar_t)0x0442, (wchar_t)0x0443,
137 (wchar_t)0x0444, (wchar_t)0x0445, (wchar_t)0x0446, (wchar_t)0x0447, (wchar_t)0x0448,
138 (wchar_t)0x0449, (wchar_t)0x044A, (wchar_t)0x044B, (wchar_t)0x044C, (wchar_t)0x044D,
139 (wchar_t)0x044E, (wchar_t)0x044F, (wchar_t)0x0451, (wchar_t)0x0452, (wchar_t)0x0453,
140 (wchar_t)0x0454, (wchar_t)0x0455, (wchar_t)0x0456, (wchar_t)0x0457, (wchar_t)0x0458,
141 (wchar_t)0x0459, (wchar_t)0x045A, (wchar_t)0x045B, (wchar_t)0x045C, (wchar_t)0x045E,
142 (wchar_t)0x045F, (wchar_t)0x0461, (wchar_t)0x0463, (wchar_t)0x0465, (wchar_t)0x0467,
143 (wchar_t)0x0469, (wchar_t)0x046B, (wchar_t)0x046D, (wchar_t)0x046F, (wchar_t)0x0471,
144 (wchar_t)0x0473, (wchar_t)0x0475, (wchar_t)0x0477, (wchar_t)0x0479, (wchar_t)0x047B,
145 (wchar_t)0x047D, (wchar_t)0x047F, (wchar_t)0x0481, (wchar_t)0x0491, (wchar_t)0x0493,
146 (wchar_t)0x0495, (wchar_t)0x0497, (wchar_t)0x0499, (wchar_t)0x049B, (wchar_t)0x049D,
147 (wchar_t)0x049F, (wchar_t)0x04A1, (wchar_t)0x04A3, (wchar_t)0x04A5, (wchar_t)0x04A7,
148 (wchar_t)0x04A9, (wchar_t)0x04AB, (wchar_t)0x04AD, (wchar_t)0x04AF, (wchar_t)0x04B1,
149 (wchar_t)0x04B3, (wchar_t)0x04B5, (wchar_t)0x04B7, (wchar_t)0x04B9, (wchar_t)0x04BB,
150 (wchar_t)0x04BD, (wchar_t)0x04BF, (wchar_t)0x04C2, (wchar_t)0x04C4, (wchar_t)0x04C8,
151 (wchar_t)0x04CC, (wchar_t)0x04D1, (wchar_t)0x04D3, (wchar_t)0x04D5, (wchar_t)0x04D7,
152 (wchar_t)0x04D9, (wchar_t)0x04DB, (wchar_t)0x04DD, (wchar_t)0x04DF, (wchar_t)0x04E1,
153 (wchar_t)0x04E3, (wchar_t)0x04E5, (wchar_t)0x04E7, (wchar_t)0x04E9, (wchar_t)0x04EB,
154 (wchar_t)0x04EF, (wchar_t)0x04F1, (wchar_t)0x04F3, (wchar_t)0x04F5, (wchar_t)0x04F9,
155 (wchar_t)0x0561, (wchar_t)0x0562, (wchar_t)0x0563, (wchar_t)0x0564, (wchar_t)0x0565,
156 (wchar_t)0x0566, (wchar_t)0x0567, (wchar_t)0x0568, (wchar_t)0x0569, (wchar_t)0x056A,
157 (wchar_t)0x056B, (wchar_t)0x056C, (wchar_t)0x056D, (wchar_t)0x056E, (wchar_t)0x056F,
158 (wchar_t)0x0570, (wchar_t)0x0571, (wchar_t)0x0572, (wchar_t)0x0573, (wchar_t)0x0574,
159 (wchar_t)0x0575, (wchar_t)0x0576, (wchar_t)0x0577, (wchar_t)0x0578, (wchar_t)0x0579,
160 (wchar_t)0x057A, (wchar_t)0x057B, (wchar_t)0x057C, (wchar_t)0x057D, (wchar_t)0x057E,
161 (wchar_t)0x057F, (wchar_t)0x0580, (wchar_t)0x0581, (wchar_t)0x0582, (wchar_t)0x0583,
162 (wchar_t)0x0584, (wchar_t)0x0585, (wchar_t)0x0586, (wchar_t)0x10D0, (wchar_t)0x10D1,
163 (wchar_t)0x10D2, (wchar_t)0x10D3, (wchar_t)0x10D4, (wchar_t)0x10D5, (wchar_t)0x10D6,
164 (wchar_t)0x10D7, (wchar_t)0x10D8, (wchar_t)0x10D9, (wchar_t)0x10DA, (wchar_t)0x10DB,
165 (wchar_t)0x10DC, (wchar_t)0x10DD, (wchar_t)0x10DE, (wchar_t)0x10DF, (wchar_t)0x10E0,
166 (wchar_t)0x10E1, (wchar_t)0x10E2, (wchar_t)0x10E3, (wchar_t)0x10E4, (wchar_t)0x10E5,
167 (wchar_t)0x10E6, (wchar_t)0x10E7, (wchar_t)0x10E8, (wchar_t)0x10E9, (wchar_t)0x10EA,
168 (wchar_t)0x10EB, (wchar_t)0x10EC, (wchar_t)0x10ED, (wchar_t)0x10EE, (wchar_t)0x10EF,
169 (wchar_t)0x10F0, (wchar_t)0x10F1, (wchar_t)0x10F2, (wchar_t)0x10F3, (wchar_t)0x10F4,
170 (wchar_t)0x10F5, (wchar_t)0x1E01, (wchar_t)0x1E03, (wchar_t)0x1E05, (wchar_t)0x1E07,
171 (wchar_t)0x1E09, (wchar_t)0x1E0B, (wchar_t)0x1E0D, (wchar_t)0x1E0F, (wchar_t)0x1E11,
172 (wchar_t)0x1E13, (wchar_t)0x1E15, (wchar_t)0x1E17, (wchar_t)0x1E19, (wchar_t)0x1E1B,
173 (wchar_t)0x1E1D, (wchar_t)0x1E1F, (wchar_t)0x1E21, (wchar_t)0x1E23, (wchar_t)0x1E25,
174 (wchar_t)0x1E27, (wchar_t)0x1E29, (wchar_t)0x1E2B, (wchar_t)0x1E2D, (wchar_t)0x1E2F,
175 (wchar_t)0x1E31, (wchar_t)0x1E33, (wchar_t)0x1E35, (wchar_t)0x1E37, (wchar_t)0x1E39,
176 (wchar_t)0x1E3B, (wchar_t)0x1E3D, (wchar_t)0x1E3F, (wchar_t)0x1E41, (wchar_t)0x1E43,
177 (wchar_t)0x1E45, (wchar_t)0x1E47, (wchar_t)0x1E49, (wchar_t)0x1E4B, (wchar_t)0x1E4D,
178 (wchar_t)0x1E4F, (wchar_t)0x1E51, (wchar_t)0x1E53, (wchar_t)0x1E55, (wchar_t)0x1E57,
179 (wchar_t)0x1E59, (wchar_t)0x1E5B, (wchar_t)0x1E5D, (wchar_t)0x1E5F, (wchar_t)0x1E61,
180 (wchar_t)0x1E63, (wchar_t)0x1E65, (wchar_t)0x1E67, (wchar_t)0x1E69, (wchar_t)0x1E6B,
181 (wchar_t)0x1E6D, (wchar_t)0x1E6F, (wchar_t)0x1E71, (wchar_t)0x1E73, (wchar_t)0x1E75,
182 (wchar_t)0x1E77, (wchar_t)0x1E79, (wchar_t)0x1E7B, (wchar_t)0x1E7D, (wchar_t)0x1E7F,
183 (wchar_t)0x1E81, (wchar_t)0x1E83, (wchar_t)0x1E85, (wchar_t)0x1E87, (wchar_t)0x1E89,
184 (wchar_t)0x1E8B, (wchar_t)0x1E8D, (wchar_t)0x1E8F, (wchar_t)0x1E91, (wchar_t)0x1E93,
185 (wchar_t)0x1E95, (wchar_t)0x1EA1, (wchar_t)0x1EA3, (wchar_t)0x1EA5, (wchar_t)0x1EA7,
186 (wchar_t)0x1EA9, (wchar_t)0x1EAB, (wchar_t)0x1EAD, (wchar_t)0x1EAF, (wchar_t)0x1EB1,
187 (wchar_t)0x1EB3, (wchar_t)0x1EB5, (wchar_t)0x1EB7, (wchar_t)0x1EB9, (wchar_t)0x1EBB,
188 (wchar_t)0x1EBD, (wchar_t)0x1EBF, (wchar_t)0x1EC1, (wchar_t)0x1EC3, (wchar_t)0x1EC5,
189 (wchar_t)0x1EC7, (wchar_t)0x1EC9, (wchar_t)0x1ECB, (wchar_t)0x1ECD, (wchar_t)0x1ECF,
190 (wchar_t)0x1ED1, (wchar_t)0x1ED3, (wchar_t)0x1ED5, (wchar_t)0x1ED7, (wchar_t)0x1ED9,
191 (wchar_t)0x1EDB, (wchar_t)0x1EDD, (wchar_t)0x1EDF, (wchar_t)0x1EE1, (wchar_t)0x1EE3,
192 (wchar_t)0x1EE5, (wchar_t)0x1EE7, (wchar_t)0x1EE9, (wchar_t)0x1EEB, (wchar_t)0x1EED,
193 (wchar_t)0x1EEF, (wchar_t)0x1EF1, (wchar_t)0x1EF3, (wchar_t)0x1EF5, (wchar_t)0x1EF7,
194 (wchar_t)0x1EF9, (wchar_t)0x1F00, (wchar_t)0x1F01, (wchar_t)0x1F02, (wchar_t)0x1F03,
195 (wchar_t)0x1F04, (wchar_t)0x1F05, (wchar_t)0x1F06, (wchar_t)0x1F07, (wchar_t)0x1F10,
196 (wchar_t)0x1F11, (wchar_t)0x1F12, (wchar_t)0x1F13, (wchar_t)0x1F14, (wchar_t)0x1F15,
197 (wchar_t)0x1F20, (wchar_t)0x1F21, (wchar_t)0x1F22, (wchar_t)0x1F23, (wchar_t)0x1F24,
198 (wchar_t)0x1F25, (wchar_t)0x1F26, (wchar_t)0x1F27, (wchar_t)0x1F30, (wchar_t)0x1F31,
199 (wchar_t)0x1F32, (wchar_t)0x1F33, (wchar_t)0x1F34, (wchar_t)0x1F35, (wchar_t)0x1F36,
200 (wchar_t)0x1F37, (wchar_t)0x1F40, (wchar_t)0x1F41, (wchar_t)0x1F42, (wchar_t)0x1F43,
201 (wchar_t)0x1F44, (wchar_t)0x1F45, (wchar_t)0x1F51, (wchar_t)0x1F53, (wchar_t)0x1F55,
202 (wchar_t)0x1F57, (wchar_t)0x1F60, (wchar_t)0x1F61, (wchar_t)0x1F62, (wchar_t)0x1F63,
203 (wchar_t)0x1F64, (wchar_t)0x1F65, (wchar_t)0x1F66, (wchar_t)0x1F67, (wchar_t)0x1F80,
204 (wchar_t)0x1F81, (wchar_t)0x1F82, (wchar_t)0x1F83, (wchar_t)0x1F84, (wchar_t)0x1F85,
205 (wchar_t)0x1F86, (wchar_t)0x1F87, (wchar_t)0x1F90, (wchar_t)0x1F91, (wchar_t)0x1F92,
206 (wchar_t)0x1F93, (wchar_t)0x1F94, (wchar_t)0x1F95, (wchar_t)0x1F96, (wchar_t)0x1F97,
207 (wchar_t)0x1FA0, (wchar_t)0x1FA1, (wchar_t)0x1FA2, (wchar_t)0x1FA3, (wchar_t)0x1FA4,
208 (wchar_t)0x1FA5, (wchar_t)0x1FA6, (wchar_t)0x1FA7, (wchar_t)0x1FB0, (wchar_t)0x1FB1,
209 (wchar_t)0x1FD0, (wchar_t)0x1FD1, (wchar_t)0x1FE0, (wchar_t)0x1FE1, (wchar_t)0x24D0,
210 (wchar_t)0x24D1, (wchar_t)0x24D2, (wchar_t)0x24D3, (wchar_t)0x24D4, (wchar_t)0x24D5,
211 (wchar_t)0x24D6, (wchar_t)0x24D7, (wchar_t)0x24D8, (wchar_t)0x24D9, (wchar_t)0x24DA,
212 (wchar_t)0x24DB, (wchar_t)0x24DC, (wchar_t)0x24DD, (wchar_t)0x24DE, (wchar_t)0x24DF,
213 (wchar_t)0x24E0, (wchar_t)0x24E1, (wchar_t)0x24E2, (wchar_t)0x24E3, (wchar_t)0x24E4,
214 (wchar_t)0x24E5, (wchar_t)0x24E6, (wchar_t)0x24E7, (wchar_t)0x24E8, (wchar_t)0x24E9,
215 (wchar_t)0xFF41, (wchar_t)0xFF42, (wchar_t)0xFF43, (wchar_t)0xFF44, (wchar_t)0xFF45,
216 (wchar_t)0xFF46, (wchar_t)0xFF47, (wchar_t)0xFF48, (wchar_t)0xFF49, (wchar_t)0xFF4A,
217 (wchar_t)0xFF4B, (wchar_t)0xFF4C, (wchar_t)0xFF4D, (wchar_t)0xFF4E, (wchar_t)0xFF4F,
218 (wchar_t)0xFF50, (wchar_t)0xFF51, (wchar_t)0xFF52, (wchar_t)0xFF53, (wchar_t)0xFF54,
219 (wchar_t)0xFF55, (wchar_t)0xFF56, (wchar_t)0xFF57, (wchar_t)0xFF58, (wchar_t)0xFF59,
220 (wchar_t)0xFF5A};
221
222static const wchar_t unicode_uppers[] = {
223 (wchar_t)0x0041, (wchar_t)0x0042, (wchar_t)0x0043, (wchar_t)0x0044, (wchar_t)0x0045,
224 (wchar_t)0x0046, (wchar_t)0x0047, (wchar_t)0x0048, (wchar_t)0x0049, (wchar_t)0x004A,
225 (wchar_t)0x004B, (wchar_t)0x004C, (wchar_t)0x004D, (wchar_t)0x004E, (wchar_t)0x004F,
226 (wchar_t)0x0050, (wchar_t)0x0051, (wchar_t)0x0052, (wchar_t)0x0053, (wchar_t)0x0054,
227 (wchar_t)0x0055, (wchar_t)0x0056, (wchar_t)0x0057, (wchar_t)0x0058, (wchar_t)0x0059,
228 (wchar_t)0x005A, (wchar_t)0x00C0, (wchar_t)0x00C1, (wchar_t)0x00C2, (wchar_t)0x00C3,
229 (wchar_t)0x00C4, (wchar_t)0x00C5, (wchar_t)0x00C6, (wchar_t)0x00C7, (wchar_t)0x00C8,
230 (wchar_t)0x00C9, (wchar_t)0x00CA, (wchar_t)0x00CB, (wchar_t)0x00CC, (wchar_t)0x00CD,
231 (wchar_t)0x00CE, (wchar_t)0x00CF, (wchar_t)0x00D0, (wchar_t)0x00D1, (wchar_t)0x00D2,
232 (wchar_t)0x00D3, (wchar_t)0x00D4, (wchar_t)0x00D5, (wchar_t)0x00D6, (wchar_t)0x00D8,
233 (wchar_t)0x00D9, (wchar_t)0x00DA, (wchar_t)0x00DB, (wchar_t)0x00DC, (wchar_t)0x00DD,
234 (wchar_t)0x00DE, (wchar_t)0x0178, (wchar_t)0x0100, (wchar_t)0x0102, (wchar_t)0x0104,
235 (wchar_t)0x0106, (wchar_t)0x0108, (wchar_t)0x010A, (wchar_t)0x010C, (wchar_t)0x010E,
236 (wchar_t)0x0110, (wchar_t)0x0112, (wchar_t)0x0114, (wchar_t)0x0116, (wchar_t)0x0118,
237 (wchar_t)0x011A, (wchar_t)0x011C, (wchar_t)0x011E, (wchar_t)0x0120, (wchar_t)0x0122,
238 (wchar_t)0x0124, (wchar_t)0x0126, (wchar_t)0x0128, (wchar_t)0x012A, (wchar_t)0x012C,
239 (wchar_t)0x012E, (wchar_t)0x0049, (wchar_t)0x0132, (wchar_t)0x0134, (wchar_t)0x0136,
240 (wchar_t)0x0139, (wchar_t)0x013B, (wchar_t)0x013D, (wchar_t)0x013F, (wchar_t)0x0141,
241 (wchar_t)0x0143, (wchar_t)0x0145, (wchar_t)0x0147, (wchar_t)0x014A, (wchar_t)0x014C,
242 (wchar_t)0x014E, (wchar_t)0x0150, (wchar_t)0x0152, (wchar_t)0x0154, (wchar_t)0x0156,
243 (wchar_t)0x0158, (wchar_t)0x015A, (wchar_t)0x015C, (wchar_t)0x015E, (wchar_t)0x0160,
244 (wchar_t)0x0162, (wchar_t)0x0164, (wchar_t)0x0166, (wchar_t)0x0168, (wchar_t)0x016A,
245 (wchar_t)0x016C, (wchar_t)0x016E, (wchar_t)0x0170, (wchar_t)0x0172, (wchar_t)0x0174,
246 (wchar_t)0x0176, (wchar_t)0x0179, (wchar_t)0x017B, (wchar_t)0x017D, (wchar_t)0x0182,
247 (wchar_t)0x0184, (wchar_t)0x0187, (wchar_t)0x018B, (wchar_t)0x0191, (wchar_t)0x0198,
248 (wchar_t)0x01A0, (wchar_t)0x01A2, (wchar_t)0x01A4, (wchar_t)0x01A7, (wchar_t)0x01AC,
249 (wchar_t)0x01AF, (wchar_t)0x01B3, (wchar_t)0x01B5, (wchar_t)0x01B8, (wchar_t)0x01BC,
250 (wchar_t)0x01C4, (wchar_t)0x01C7, (wchar_t)0x01CA, (wchar_t)0x01CD, (wchar_t)0x01CF,
251 (wchar_t)0x01D1, (wchar_t)0x01D3, (wchar_t)0x01D5, (wchar_t)0x01D7, (wchar_t)0x01D9,
252 (wchar_t)0x01DB, (wchar_t)0x01DE, (wchar_t)0x01E0, (wchar_t)0x01E2, (wchar_t)0x01E4,
253 (wchar_t)0x01E6, (wchar_t)0x01E8, (wchar_t)0x01EA, (wchar_t)0x01EC, (wchar_t)0x01EE,
254 (wchar_t)0x01F1, (wchar_t)0x01F4, (wchar_t)0x01FA, (wchar_t)0x01FC, (wchar_t)0x01FE,
255 (wchar_t)0x0200, (wchar_t)0x0202, (wchar_t)0x0204, (wchar_t)0x0206, (wchar_t)0x0208,
256 (wchar_t)0x020A, (wchar_t)0x020C, (wchar_t)0x020E, (wchar_t)0x0210, (wchar_t)0x0212,
257 (wchar_t)0x0214, (wchar_t)0x0216, (wchar_t)0x0181, (wchar_t)0x0186, (wchar_t)0x018A,
258 (wchar_t)0x018E, (wchar_t)0x018F, (wchar_t)0x0190, (wchar_t)0x0193, (wchar_t)0x0194,
259 (wchar_t)0x0197, (wchar_t)0x0196, (wchar_t)0x019C, (wchar_t)0x019D, (wchar_t)0x019F,
260 (wchar_t)0x01A9, (wchar_t)0x01AE, (wchar_t)0x01B1, (wchar_t)0x01B2, (wchar_t)0x01B7,
261 (wchar_t)0x0386, (wchar_t)0x0388, (wchar_t)0x0389, (wchar_t)0x038A, (wchar_t)0x0391,
262 (wchar_t)0x0392, (wchar_t)0x0393, (wchar_t)0x0394, (wchar_t)0x0395, (wchar_t)0x0396,
263 (wchar_t)0x0397, (wchar_t)0x0398, (wchar_t)0x0399, (wchar_t)0x039A, (wchar_t)0x039B,
264 (wchar_t)0x039C, (wchar_t)0x039D, (wchar_t)0x039E, (wchar_t)0x039F, (wchar_t)0x03A0,
265 (wchar_t)0x03A1, (wchar_t)0x03A3, (wchar_t)0x03A4, (wchar_t)0x03A5, (wchar_t)0x03A6,
266 (wchar_t)0x03A7, (wchar_t)0x03A8, (wchar_t)0x03A9, (wchar_t)0x03AA, (wchar_t)0x03AB,
267 (wchar_t)0x038C, (wchar_t)0x038E, (wchar_t)0x038F, (wchar_t)0x03E2, (wchar_t)0x03E4,
268 (wchar_t)0x03E6, (wchar_t)0x03E8, (wchar_t)0x03EA, (wchar_t)0x03EC, (wchar_t)0x03EE,
269 (wchar_t)0x0410, (wchar_t)0x0411, (wchar_t)0x0412, (wchar_t)0x0413, (wchar_t)0x0414,
270 (wchar_t)0x0415, (wchar_t)0x0416, (wchar_t)0x0417, (wchar_t)0x0418, (wchar_t)0x0419,
271 (wchar_t)0x041A, (wchar_t)0x041B, (wchar_t)0x041C, (wchar_t)0x041D, (wchar_t)0x041E,
272 (wchar_t)0x041F, (wchar_t)0x0420, (wchar_t)0x0421, (wchar_t)0x0422, (wchar_t)0x0423,
273 (wchar_t)0x0424, (wchar_t)0x0425, (wchar_t)0x0426, (wchar_t)0x0427, (wchar_t)0x0428,
274 (wchar_t)0x0429, (wchar_t)0x042A, (wchar_t)0x042B, (wchar_t)0x042C, (wchar_t)0x042D,
275 (wchar_t)0x042E, (wchar_t)0x042F, (wchar_t)0x0401, (wchar_t)0x0402, (wchar_t)0x0403,
276 (wchar_t)0x0404, (wchar_t)0x0405, (wchar_t)0x0406, (wchar_t)0x0407, (wchar_t)0x0408,
277 (wchar_t)0x0409, (wchar_t)0x040A, (wchar_t)0x040B, (wchar_t)0x040C, (wchar_t)0x040E,
278 (wchar_t)0x040F, (wchar_t)0x0460, (wchar_t)0x0462, (wchar_t)0x0464, (wchar_t)0x0466,
279 (wchar_t)0x0468, (wchar_t)0x046A, (wchar_t)0x046C, (wchar_t)0x046E, (wchar_t)0x0470,
280 (wchar_t)0x0472, (wchar_t)0x0474, (wchar_t)0x0476, (wchar_t)0x0478, (wchar_t)0x047A,
281 (wchar_t)0x047C, (wchar_t)0x047E, (wchar_t)0x0480, (wchar_t)0x0490, (wchar_t)0x0492,
282 (wchar_t)0x0494, (wchar_t)0x0496, (wchar_t)0x0498, (wchar_t)0x049A, (wchar_t)0x049C,
283 (wchar_t)0x049E, (wchar_t)0x04A0, (wchar_t)0x04A2, (wchar_t)0x04A4, (wchar_t)0x04A6,
284 (wchar_t)0x04A8, (wchar_t)0x04AA, (wchar_t)0x04AC, (wchar_t)0x04AE, (wchar_t)0x04B0,
285 (wchar_t)0x04B2, (wchar_t)0x04B4, (wchar_t)0x04B6, (wchar_t)0x04B8, (wchar_t)0x04BA,
286 (wchar_t)0x04BC, (wchar_t)0x04BE, (wchar_t)0x04C1, (wchar_t)0x04C3, (wchar_t)0x04C7,
287 (wchar_t)0x04CB, (wchar_t)0x04D0, (wchar_t)0x04D2, (wchar_t)0x04D4, (wchar_t)0x04D6,
288 (wchar_t)0x04D8, (wchar_t)0x04DA, (wchar_t)0x04DC, (wchar_t)0x04DE, (wchar_t)0x04E0,
289 (wchar_t)0x04E2, (wchar_t)0x04E4, (wchar_t)0x04E6, (wchar_t)0x04E8, (wchar_t)0x04EA,
290 (wchar_t)0x04EE, (wchar_t)0x04F0, (wchar_t)0x04F2, (wchar_t)0x04F4, (wchar_t)0x04F8,
291 (wchar_t)0x0531, (wchar_t)0x0532, (wchar_t)0x0533, (wchar_t)0x0534, (wchar_t)0x0535,
292 (wchar_t)0x0536, (wchar_t)0x0537, (wchar_t)0x0538, (wchar_t)0x0539, (wchar_t)0x053A,
293 (wchar_t)0x053B, (wchar_t)0x053C, (wchar_t)0x053D, (wchar_t)0x053E, (wchar_t)0x053F,
294 (wchar_t)0x0540, (wchar_t)0x0541, (wchar_t)0x0542, (wchar_t)0x0543, (wchar_t)0x0544,
295 (wchar_t)0x0545, (wchar_t)0x0546, (wchar_t)0x0547, (wchar_t)0x0548, (wchar_t)0x0549,
296 (wchar_t)0x054A, (wchar_t)0x054B, (wchar_t)0x054C, (wchar_t)0x054D, (wchar_t)0x054E,
297 (wchar_t)0x054F, (wchar_t)0x0550, (wchar_t)0x0551, (wchar_t)0x0552, (wchar_t)0x0553,
298 (wchar_t)0x0554, (wchar_t)0x0555, (wchar_t)0x0556, (wchar_t)0x10A0, (wchar_t)0x10A1,
299 (wchar_t)0x10A2, (wchar_t)0x10A3, (wchar_t)0x10A4, (wchar_t)0x10A5, (wchar_t)0x10A6,
300 (wchar_t)0x10A7, (wchar_t)0x10A8, (wchar_t)0x10A9, (wchar_t)0x10AA, (wchar_t)0x10AB,
301 (wchar_t)0x10AC, (wchar_t)0x10AD, (wchar_t)0x10AE, (wchar_t)0x10AF, (wchar_t)0x10B0,
302 (wchar_t)0x10B1, (wchar_t)0x10B2, (wchar_t)0x10B3, (wchar_t)0x10B4, (wchar_t)0x10B5,
303 (wchar_t)0x10B6, (wchar_t)0x10B7, (wchar_t)0x10B8, (wchar_t)0x10B9, (wchar_t)0x10BA,
304 (wchar_t)0x10BB, (wchar_t)0x10BC, (wchar_t)0x10BD, (wchar_t)0x10BE, (wchar_t)0x10BF,
305 (wchar_t)0x10C0, (wchar_t)0x10C1, (wchar_t)0x10C2, (wchar_t)0x10C3, (wchar_t)0x10C4,
306 (wchar_t)0x10C5, (wchar_t)0x1E00, (wchar_t)0x1E02, (wchar_t)0x1E04, (wchar_t)0x1E06,
307 (wchar_t)0x1E08, (wchar_t)0x1E0A, (wchar_t)0x1E0C, (wchar_t)0x1E0E, (wchar_t)0x1E10,
308 (wchar_t)0x1E12, (wchar_t)0x1E14, (wchar_t)0x1E16, (wchar_t)0x1E18, (wchar_t)0x1E1A,
309 (wchar_t)0x1E1C, (wchar_t)0x1E1E, (wchar_t)0x1E20, (wchar_t)0x1E22, (wchar_t)0x1E24,
310 (wchar_t)0x1E26, (wchar_t)0x1E28, (wchar_t)0x1E2A, (wchar_t)0x1E2C, (wchar_t)0x1E2E,
311 (wchar_t)0x1E30, (wchar_t)0x1E32, (wchar_t)0x1E34, (wchar_t)0x1E36, (wchar_t)0x1E38,
312 (wchar_t)0x1E3A, (wchar_t)0x1E3C, (wchar_t)0x1E3E, (wchar_t)0x1E40, (wchar_t)0x1E42,
313 (wchar_t)0x1E44, (wchar_t)0x1E46, (wchar_t)0x1E48, (wchar_t)0x1E4A, (wchar_t)0x1E4C,
314 (wchar_t)0x1E4E, (wchar_t)0x1E50, (wchar_t)0x1E52, (wchar_t)0x1E54, (wchar_t)0x1E56,
315 (wchar_t)0x1E58, (wchar_t)0x1E5A, (wchar_t)0x1E5C, (wchar_t)0x1E5E, (wchar_t)0x1E60,
316 (wchar_t)0x1E62, (wchar_t)0x1E64, (wchar_t)0x1E66, (wchar_t)0x1E68, (wchar_t)0x1E6A,
317 (wchar_t)0x1E6C, (wchar_t)0x1E6E, (wchar_t)0x1E70, (wchar_t)0x1E72, (wchar_t)0x1E74,
318 (wchar_t)0x1E76, (wchar_t)0x1E78, (wchar_t)0x1E7A, (wchar_t)0x1E7C, (wchar_t)0x1E7E,
319 (wchar_t)0x1E80, (wchar_t)0x1E82, (wchar_t)0x1E84, (wchar_t)0x1E86, (wchar_t)0x1E88,
320 (wchar_t)0x1E8A, (wchar_t)0x1E8C, (wchar_t)0x1E8E, (wchar_t)0x1E90, (wchar_t)0x1E92,
321 (wchar_t)0x1E94, (wchar_t)0x1EA0, (wchar_t)0x1EA2, (wchar_t)0x1EA4, (wchar_t)0x1EA6,
322 (wchar_t)0x1EA8, (wchar_t)0x1EAA, (wchar_t)0x1EAC, (wchar_t)0x1EAE, (wchar_t)0x1EB0,
323 (wchar_t)0x1EB2, (wchar_t)0x1EB4, (wchar_t)0x1EB6, (wchar_t)0x1EB8, (wchar_t)0x1EBA,
324 (wchar_t)0x1EBC, (wchar_t)0x1EBE, (wchar_t)0x1EC0, (wchar_t)0x1EC2, (wchar_t)0x1EC4,
325 (wchar_t)0x1EC6, (wchar_t)0x1EC8, (wchar_t)0x1ECA, (wchar_t)0x1ECC, (wchar_t)0x1ECE,
326 (wchar_t)0x1ED0, (wchar_t)0x1ED2, (wchar_t)0x1ED4, (wchar_t)0x1ED6, (wchar_t)0x1ED8,
327 (wchar_t)0x1EDA, (wchar_t)0x1EDC, (wchar_t)0x1EDE, (wchar_t)0x1EE0, (wchar_t)0x1EE2,
328 (wchar_t)0x1EE4, (wchar_t)0x1EE6, (wchar_t)0x1EE8, (wchar_t)0x1EEA, (wchar_t)0x1EEC,
329 (wchar_t)0x1EEE, (wchar_t)0x1EF0, (wchar_t)0x1EF2, (wchar_t)0x1EF4, (wchar_t)0x1EF6,
330 (wchar_t)0x1EF8, (wchar_t)0x1F08, (wchar_t)0x1F09, (wchar_t)0x1F0A, (wchar_t)0x1F0B,
331 (wchar_t)0x1F0C, (wchar_t)0x1F0D, (wchar_t)0x1F0E, (wchar_t)0x1F0F, (wchar_t)0x1F18,
332 (wchar_t)0x1F19, (wchar_t)0x1F1A, (wchar_t)0x1F1B, (wchar_t)0x1F1C, (wchar_t)0x1F1D,
333 (wchar_t)0x1F28, (wchar_t)0x1F29, (wchar_t)0x1F2A, (wchar_t)0x1F2B, (wchar_t)0x1F2C,
334 (wchar_t)0x1F2D, (wchar_t)0x1F2E, (wchar_t)0x1F2F, (wchar_t)0x1F38, (wchar_t)0x1F39,
335 (wchar_t)0x1F3A, (wchar_t)0x1F3B, (wchar_t)0x1F3C, (wchar_t)0x1F3D, (wchar_t)0x1F3E,
336 (wchar_t)0x1F3F, (wchar_t)0x1F48, (wchar_t)0x1F49, (wchar_t)0x1F4A, (wchar_t)0x1F4B,
337 (wchar_t)0x1F4C, (wchar_t)0x1F4D, (wchar_t)0x1F59, (wchar_t)0x1F5B, (wchar_t)0x1F5D,
338 (wchar_t)0x1F5F, (wchar_t)0x1F68, (wchar_t)0x1F69, (wchar_t)0x1F6A, (wchar_t)0x1F6B,
339 (wchar_t)0x1F6C, (wchar_t)0x1F6D, (wchar_t)0x1F6E, (wchar_t)0x1F6F, (wchar_t)0x1F88,
340 (wchar_t)0x1F89, (wchar_t)0x1F8A, (wchar_t)0x1F8B, (wchar_t)0x1F8C, (wchar_t)0x1F8D,
341 (wchar_t)0x1F8E, (wchar_t)0x1F8F, (wchar_t)0x1F98, (wchar_t)0x1F99, (wchar_t)0x1F9A,
342 (wchar_t)0x1F9B, (wchar_t)0x1F9C, (wchar_t)0x1F9D, (wchar_t)0x1F9E, (wchar_t)0x1F9F,
343 (wchar_t)0x1FA8, (wchar_t)0x1FA9, (wchar_t)0x1FAA, (wchar_t)0x1FAB, (wchar_t)0x1FAC,
344 (wchar_t)0x1FAD, (wchar_t)0x1FAE, (wchar_t)0x1FAF, (wchar_t)0x1FB8, (wchar_t)0x1FB9,
345 (wchar_t)0x1FD8, (wchar_t)0x1FD9, (wchar_t)0x1FE8, (wchar_t)0x1FE9, (wchar_t)0x24B6,
346 (wchar_t)0x24B7, (wchar_t)0x24B8, (wchar_t)0x24B9, (wchar_t)0x24BA, (wchar_t)0x24BB,
347 (wchar_t)0x24BC, (wchar_t)0x24BD, (wchar_t)0x24BE, (wchar_t)0x24BF, (wchar_t)0x24C0,
348 (wchar_t)0x24C1, (wchar_t)0x24C2, (wchar_t)0x24C3, (wchar_t)0x24C4, (wchar_t)0x24C5,
349 (wchar_t)0x24C6, (wchar_t)0x24C7, (wchar_t)0x24C8, (wchar_t)0x24C9, (wchar_t)0x24CA,
350 (wchar_t)0x24CB, (wchar_t)0x24CC, (wchar_t)0x24CD, (wchar_t)0x24CE, (wchar_t)0x24CF,
351 (wchar_t)0xFF21, (wchar_t)0xFF22, (wchar_t)0xFF23, (wchar_t)0xFF24, (wchar_t)0xFF25,
352 (wchar_t)0xFF26, (wchar_t)0xFF27, (wchar_t)0xFF28, (wchar_t)0xFF29, (wchar_t)0xFF2A,
353 (wchar_t)0xFF2B, (wchar_t)0xFF2C, (wchar_t)0xFF2D, (wchar_t)0xFF2E, (wchar_t)0xFF2F,
354 (wchar_t)0xFF30, (wchar_t)0xFF31, (wchar_t)0xFF32, (wchar_t)0xFF33, (wchar_t)0xFF34,
355 (wchar_t)0xFF35, (wchar_t)0xFF36, (wchar_t)0xFF37, (wchar_t)0xFF38, (wchar_t)0xFF39,
356 (wchar_t)0xFF3A};
357
358namespace kodi
359{
360namespace tools
361{
362
363template<typename T, std::enable_if_t<!std::is_enum<T>::value, int> = 0>
364constexpr auto&& EnumToInt(T&& arg) noexcept
365{
366 return arg;
367}
368template<typename T, std::enable_if_t<std::is_enum<T>::value, int> = 0>
369constexpr auto EnumToInt(T&& arg) noexcept
370{
371 return static_cast<int>(arg);
372}
373
374//==============================================================================
375/// @defgroup cpp_kodi_tools_StringUtils_Defs Definitions, structures and enumerators
376/// @ingroup cpp_kodi_tools_StringUtils
377/// @brief **Parts used within string util functions**\n
378/// All to string functions associated data structures.
379///
380/// It is divided into individual modules that correspond to the respective
381/// types.
382///
383///
384///
385
386//==============================================================================
387/// @defgroup cpp_kodi_tools_StringUtils_Defs_TIME_FORMAT enum TIME_FORMAT
388/// @ingroup cpp_kodi_tools_StringUtils_Defs
389/// @brief TIME_FORMAT enum/bitmask used for formatting time strings.
390///
391/// Note the use of bitmasking, e.g. TIME_FORMAT_HH_MM_SS = TIME_FORMAT_HH | TIME_FORMAT_MM | TIME_FORMAT_SS
392/// @sa kodi::tools::StringUtils::SecondsToTimeString
393///
394/// @note For InfoLabels use the equivalent value listed (bold) on the
395/// description of each enum value.
396///
397/// <b>Example:</b> 3661 seconds => h=1, hh=01, m=1, mm=01, ss=01, hours=1, mins=61, secs=3661
398///
399///@{
400enum TIME_FORMAT
401{
402 /// Usually used as the fallback value if the format value is empty
403 TIME_FORMAT_GUESS = 0,
404
405 /// <b>ss</b> - seconds only
406 TIME_FORMAT_SS = 1,
407
408 /// <b>mm</b> - minutes only (2-digit)
409 TIME_FORMAT_MM = 2,
410
411 /// <b>mm:ss</b> - minutes and seconds
412 TIME_FORMAT_MM_SS = 3,
413
414 /// <b>hh</b> - hours only (2-digit)
415 TIME_FORMAT_HH = 4,
416
417 /// <b>hh:ss</b> - hours and seconds (this is not particularly useful)
418 TIME_FORMAT_HH_SS = 5,
419
420 /// <b>hh:mm</b> - hours and minutes
421 TIME_FORMAT_HH_MM = 6,
422
423 /// <b>hh:mm:ss</b> - hours, minutes and seconds
424 TIME_FORMAT_HH_MM_SS = 7,
425
426 /// <b>xx</b> - returns AM/PM for a 12-hour clock
427 TIME_FORMAT_XX = 8,
428
429 /// <b>hh:mm xx</b> - returns hours and minutes in a 12-hour clock format (AM/PM)
430 TIME_FORMAT_HH_MM_XX = 14,
431
432 /// <b>hh:mm:ss xx</b> - returns hours (2-digit), minutes and seconds in a 12-hour clock format (AM/PM)
433 TIME_FORMAT_HH_MM_SS_XX = 15,
434
435 /// <b>h</b> - hours only (1-digit)
436 TIME_FORMAT_H = 16,
437
438 /// <b>hh:mm:ss</b> - hours, minutes and seconds
439 TIME_FORMAT_H_MM_SS = 19,
440
441 /// <b>hh:mm:ss xx</b> - returns hours (1-digit), minutes and seconds in a 12-hour clock format (AM/PM)
442 TIME_FORMAT_H_MM_SS_XX = 27,
443
444 /// <b>secs</b> - total time in seconds
445 TIME_FORMAT_SECS = 32,
446
447 /// <b>mins</b> - total time in minutes
448 TIME_FORMAT_MINS = 64,
449
450 /// <b>hours</b> - total time in hours
451 TIME_FORMAT_HOURS = 128,
452
453 /// <b>m</b> - minutes only (1-digit)
454 TIME_FORMAT_M = 256
455};
456///@}
457//------------------------------------------------------------------------------
458
459//==============================================================================
460/// @defgroup cpp_kodi_tools_StringUtils class StringUtils
461/// @ingroup cpp_kodi_tools
462/// @brief **C++ class for processing strings**\n
463/// This class brings many different functions to edit, check or search texts.
464///
465/// Is intended to reduce any code work of C++ on addons and to have them faster
466/// to use.
467///
468/// All functions are static within the <b>`kodi::tools::StringUtils`</b> class.
469///
470///@{
471class StringUtils
472{
473public:
474 //============================================================================
475 /// @ingroup cpp_kodi_tools_StringUtils_Defs
476 /// @brief Defines a static empty <b>`std::string`</b>.
477 ///
478 static const std::string Empty;
479 //----------------------------------------------------------------------------
480
481 //----------------------------------------------------------------------------
482 /// @defgroup cpp_kodi_tools_StringUtils_FormatControl String format
483 /// @ingroup cpp_kodi_tools_StringUtils
484 /// @brief **Formatting functions**\n
485 /// Used to output the given values in newly formatted text using functions.
486 ///
487 /*!@{*/
488
489 //============================================================================
490 /// @brief Returns the C++ string pointed by given format. If format includes
491 /// format specifiers (subsequences beginning with %), the additional arguments
492 /// following format are formatted and inserted in the resulting string replacing
493 /// their respective specifiers.
494 ///
495 /// After the format parameter, the function expects at least as many additional
496 /// arguments as specified by format.
497 ///
498 /// @param[in] fmt The format of the text to process for output.
499 /// C string that contains the text to be written to the stream.
500 /// It can optionally contain embedded format specifiers that are
501 /// replaced by the values specified in subsequent additional
502 /// arguments and formatted as requested.
503 /// | specifier | Output | Example
504 /// |------------|----------------------------------------------------|------------
505 /// | d or i | Signed decimal integer | 392
506 /// | u | Unsigned decimal integer | 7235
507 /// | o | Unsigned octal | 610
508 /// | x | Unsigned hexadecimal integer | 7fa
509 /// | X | Unsigned hexadecimal integer (uppercase) | 7FA
510 /// | f | Decimal floating point, lowercase | 392.65
511 /// | F | Decimal floating point, uppercase | 392.65
512 /// | e | Scientific notation (mantissa/exponent), lowercase | 3.9265e+2
513 /// | E | Scientific notation (mantissa/exponent), uppercase | 3.9265E+2
514 /// | g | Use the shortest representation: %e or %f | 392.65
515 /// | G | Use the shortest representation: %E or %F | 392.65
516 /// | a | Hexadecimal floating point, lowercase | -0xc.90fep-2
517 /// | A | Hexadecimal floating point, uppercase | -0XC.90FEP-2
518 /// | c | Character | a
519 /// | s | String of characters | sample
520 /// | p | Pointer address | b8000000
521 /// | % | A % followed by another % character will write a single % to the stream. | %
522 /// The length sub-specifier modifies the length of the data type. This is a chart
523 /// showing the types used to interpret the corresponding arguments with and without
524 /// length specifier (if a different type is used, the proper type promotion or
525 /// conversion is performed, if allowed):
526 /// | length| d i | u o x X | f F e E g G a A | c | s | p | n |
527 /// |-------|---------------|-----------------------|-----------------|-------|---------|---------|-----------------|
528 /// | (none)| int | unsigned int | double | int | char* | void* | int* |
529 /// | hh | signed char | unsigned char | | | | | signed char* |
530 /// | h | short int | unsigned short int | | | | | short int* |
531 /// | l | long int | unsigned long int | | wint_t| wchar_t*| | long int* |
532 /// | ll | long long int | unsigned long long int| | | | | long long int* |
533 /// | j | intmax_t | uintmax_t | | | | | intmax_t* |
534 /// | z | size_t | size_t | | | | | size_t* |
535 /// | t | ptrdiff_t | ptrdiff_t | | | | | ptrdiff_t* |
536 /// | L | | | long double | | | | |
537 /// <b>Note:</b> that the c specifier takes an int (or wint_t) as argument, but performs the proper conversion to a char value
538 /// (or a wchar_t) before formatting it for output.
539 /// @param[in] ... <i>(additional arguments)</i>\n
540 /// Depending on the format string, the function may expect a
541 /// sequence of additional arguments, each containing a value
542 /// to be used to replace a format specifier in the format
543 /// string (or a pointer to a storage location, for n).\n
544 /// There should be at least as many of these arguments as the
545 /// number of values specified in the format specifiers.
546 /// Additional arguments are ignored by the function.
547 /// @return Formatted string
548 ///
549 ///
550 /// --------------------------------------------------------------------------
551 /// Example:
552 /// ~~~~~~~~~~~~~{.cpp}
553 /// #include <kodi/tools/StringUtils.h>
554 ///
555 /// std::string str = kodi::tools::StringUtils::Format("Hello %s %i", "World", 2020);
556 /// ~~~~~~~~~~~~~
557 ///
558 inline static std::string Format(const char* fmt, ...)
559 {
560 va_list args;
561 va_start(args, fmt);
562 std::string str = FormatV(fmt, args);
563 va_end(args);
564
565 return str;
566 }
567 //----------------------------------------------------------------------------
568
569 //============================================================================
570 /// @brief Returns the C++ wide string pointed by given format.
571 ///
572 /// @param[in] fmt The format of the text to process for output
573 /// (see @ref Format(const char* fmt, ...) for details).
574 /// @param[in] ... <i>(additional arguments)</i>\n
575 /// Depending on the format string, the function may expect a
576 /// sequence of additional arguments, each containing a value
577 /// to be used to replace a format specifier in the format
578 /// string (or a pointer to a storage location, for n).\n
579 /// There should be at least as many of these arguments as the
580 /// number of values specified in the format specifiers.
581 /// Additional arguments are ignored by the function.
582 /// @return Formatted string
583 ///
584 inline static std::wstring Format(const wchar_t* fmt, ...)
585 {
586 va_list args;
587 va_start(args, fmt);
588 std::wstring str = FormatV(fmt, args);
589 va_end(args);
590
591 return str;
592 }
593 //----------------------------------------------------------------------------
594
595 //============================================================================
596 /// @brief Returns the C++ string pointed by given format list.
597 ///
598 /// @param[in] fmt The format of the text to process for output
599 /// (see @ref Format(const char* fmt, ...) for details).
600 /// @param[in] args A value identifying a variable arguments list initialized
601 /// with `va_start`.
602 /// @return Formatted string
603 ///
604 inline static std::string FormatV(PRINTF_FORMAT_STRING const char* fmt, va_list args)
605 {
606 if (!fmt || !fmt[0])
607 return "";
608
609 int size = FORMAT_BLOCK_SIZE;
610 va_list argCopy;
611
612 while (true)
613 {
614 char* cstr = reinterpret_cast<char*>(malloc(sizeof(char) * size));
615 if (!cstr)
616 return "";
617
618 va_copy(argCopy, args);
619 int nActual = vsnprintf(cstr, size, fmt, argCopy);
620 va_end(argCopy);
621
622 if (nActual > -1 && nActual < size) // We got a valid result
623 {
624 std::string str(cstr, nActual);
625 free(cstr);
626 return str;
627 }
628 free(cstr);
629#ifndef TARGET_WINDOWS
630 if (nActual > -1) // Exactly what we will need (glibc 2.1)
631 size = nActual + 1;
632 else // Let's try to double the size (glibc 2.0)
633 size *= 2;
634#else // TARGET_WINDOWS
635 va_copy(argCopy, args);
636 size = _vscprintf(fmt, argCopy);
637 va_end(argCopy);
638 if (size < 0)
639 return "";
640 else
641 size++; // increment for null-termination
642#endif // TARGET_WINDOWS
643 }
644
645 return ""; // unreachable
646 }
647 //----------------------------------------------------------------------------
648
649 //============================================================================
650 /// @brief Returns the C++ wide string pointed by given format list.
651 ///
652 /// @param[in] fmt The format of the text to process for output
653 /// (see @ref Format(const char* fmt, ...) for details).
654 /// @param[in] args A value identifying a variable arguments list initialized
655 /// with `va_start`.
656 /// @return Formatted string
657 ///
658 inline static std::wstring FormatV(PRINTF_FORMAT_STRING const wchar_t* fmt, va_list args)
659 {
660 if (!fmt || !fmt[0])
661 return L"";
662
663 int size = FORMAT_BLOCK_SIZE;
664 va_list argCopy;
665
666 while (true)
667 {
668 wchar_t* cstr = reinterpret_cast<wchar_t*>(malloc(sizeof(wchar_t) * size));
669 if (!cstr)
670 return L"";
671
672 va_copy(argCopy, args);
673 int nActual = vswprintf(cstr, size, fmt, argCopy);
674 va_end(argCopy);
675
676 if (nActual > -1 && nActual < size) // We got a valid result
677 {
678 std::wstring str(cstr, nActual);
679 free(cstr);
680 return str;
681 }
682 free(cstr);
683
684#ifndef TARGET_WINDOWS
685 if (nActual > -1) // Exactly what we will need (glibc 2.1)
686 size = nActual + 1;
687 else // Let's try to double the size (glibc 2.0)
688 size *= 2;
689#else // TARGET_WINDOWS
690 va_copy(argCopy, args);
691 size = _vscwprintf(fmt, argCopy);
692 va_end(argCopy);
693 if (size < 0)
694 return L"";
695 else
696 size++; // increment for null-termination
697#endif // TARGET_WINDOWS
698 }
699
700 return L"";
701 }
702 //----------------------------------------------------------------------------
703
704 //============================================================================
705 /// @brief Returns bytes in a human readable format using the smallest unit
706 /// that will fit `bytes` in at most three digits. The number of decimals are
707 /// adjusted with significance such that 'small' numbers will have more
708 /// decimals than larger ones.
709 ///
710 /// For example: 1024 bytes will be formatted as "1.00kB", 10240 bytes as
711 /// "10.0kB" and 102400 bytes as "100kB". See TestStringUtils for more
712 /// examples.
713 ///
714 /// Supported file sizes:
715 /// | Value | Short | Metric
716 /// |------------|-------|-----------
717 /// | 1 | B | byte
718 /// | 1024¹ | kB | kilobyte
719 /// | 1024² | MB | megabyte
720 /// | 1024³ | GB | gigabyte
721 /// | 1024 exp 4 | TB | terabyte
722 /// | 1024 exp 5 | PB | petabyte
723 /// | 1024 exp 6 | EB | exabyte
724 /// | 1024 exp 7 | ZB | zettabyte
725 /// | 1024 exp 8 | YB | yottabyte
726 ///
727 /// @param[in] bytes Bytes amount to return as human readable string
728 /// @return Size as string
729 ///
730 ///
731 /// --------------------------------------------------------------------------
732 /// Example:
733 /// ~~~~~~~~~~~~~{.cpp}
734 /// #include <kodi/tools/StringUtils.h>
735 ///
736 /// EXPECT_STREQ("0B", kodi::tools::StringUtils::FormatFileSize(0).c_str());
737 ///
738 /// EXPECT_STREQ("999B", kodi::tools::StringUtils::FormatFileSize(999).c_str());
739 /// EXPECT_STREQ("0.98kB", kodi::tools::StringUtils::FormatFileSize(1000).c_str());
740 ///
741 /// EXPECT_STREQ("1.00kB", kodi::tools::StringUtils::FormatFileSize(1024).c_str());
742 /// EXPECT_STREQ("9.99kB", kodi::tools::StringUtils::FormatFileSize(10229).c_str());
743 ///
744 /// EXPECT_STREQ("10.1kB", kodi::tools::StringUtils::FormatFileSize(10387).c_str());
745 /// EXPECT_STREQ("99.9kB", kodi::tools::StringUtils::FormatFileSize(102297).c_str());
746 ///
747 /// EXPECT_STREQ("100kB", kodi::tools::StringUtils::FormatFileSize(102400).c_str());
748 /// EXPECT_STREQ("999kB", kodi::tools::StringUtils::FormatFileSize(1023431).c_str());
749 ///
750 /// EXPECT_STREQ("0.98MB", kodi::tools::StringUtils::FormatFileSize(1023897).c_str());
751 /// EXPECT_STREQ("0.98MB", kodi::tools::StringUtils::FormatFileSize(1024000).c_str());
752 ///
753 /// EXPECT_STREQ("5.30EB", kodi::tools::StringUtils::FormatFileSize(6115888293969133568).c_str());
754 /// ~~~~~~~~~~~~~
755 ///
756 inline static std::string FormatFileSize(uint64_t bytes)
757 {
758 const std::array<std::string, 9> units{{"B", "kB", "MB", "GB", "TB", "PB", "EB", "ZB", "YB"}};
759 if (bytes < 1000)
760 return Format("%" PRIu64 "B", bytes);
761
762 size_t i = 0;
763 double value = static_cast<double>(bytes);
764 while (i + 1 < units.size() && value >= 999.5)
765 {
766 ++i;
767 value /= 1024.0;
768 }
769 unsigned int decimals = value < 9.995 ? 2 : (value < 99.95 ? 1 : 0);
770 auto frmt = "%." + Format("%u", decimals) + "f%s";
771 return Format(frmt.c_str(), value, units[i].c_str());
772 }
773 //----------------------------------------------------------------------------
774
775 //============================================================================
776 /// @brief Convert the string of binary chars to the actual string.
777 ///
778 /// Convert the string representation of binary chars to the actual string.
779 /// For example <b>`\1\2\3`</b> is converted to a string with binary char
780 /// <b>`\1`</b>, <b>`\2`</b> and <b>`\3`</b>
781 ///
782 /// @param[in] in String to convert
783 /// @return Converted string
784 ///
785 inline static std::string BinaryStringToString(const std::string& in)
786 {
787 std::string out;
788 out.reserve(in.size() / 2);
789 for (const char *cur = in.c_str(), *end = cur + in.size(); cur != end; ++cur)
790 {
791 if (*cur == '\\')
792 {
793 ++cur;
794 if (cur == end)
795 {
796 break;
797 }
798 if (isdigit(*cur))
799 {
800 char* end;
801 unsigned long num = strtol(cur, &end, 10);
802 cur = end - 1;
803 out.push_back(static_cast<char>(num));
804 continue;
805 }
806 }
807 out.push_back(*cur);
808 }
809 return out;
810 }
811 //----------------------------------------------------------------------------
812
813 //============================================================================
814 /// @brief Convert each character in the string to its hexadecimal
815 /// representation and return the concatenated result
816 ///
817 /// Example: "abc\n" -> "6162630a"
818 ///
819 /// @param[in] in String to convert
820 /// @return Converted string
821 ///
822 ///
823 /// --------------------------------------------------------------------------
824 /// Example:
825 /// ~~~~~~~~~~~~~{.cpp}
826 /// #include <kodi/tools/StringUtils.h>
827 ///
828 /// EXPECT_STREQ("", kodi::tools::StringUtils::ToHexadecimal("").c_str());
829 /// EXPECT_STREQ("616263", kodi::tools::StringUtils::ToHexadecimal("abc").c_str());
830 /// std::string a{"a\0b\n", 4};
831 /// EXPECT_STREQ("6100620a", kodi::tools::StringUtils::ToHexadecimal(a).c_str());
832 /// std::string nul{"\0", 1};
833 /// EXPECT_STREQ("00", kodi::tools::StringUtils::ToHexadecimal(nul).c_str());
834 /// std::string ff{"\xFF", 1};
835 /// EXPECT_STREQ("ff", kodi::tools::StringUtils::ToHexadecimal(ff).c_str());
836 /// ~~~~~~~~~~~~~
837 ///
838 inline static std::string ToHexadecimal(const std::string& in)
839 {
840 std::ostringstream ss;
841 ss << std::hex;
842 for (unsigned char ch : in)
843 {
844 ss << std::setw(2) << std::setfill('0') << static_cast<unsigned long>(ch);
845 }
846 return ss.str();
847 }
848 //----------------------------------------------------------------------------
849
850 /*!@}*/
851
852 //----------------------------------------------------------------------------
853 /// @defgroup cpp_kodi_tools_StringUtils_EditControl String edit
854 /// @ingroup cpp_kodi_tools_StringUtils
855 /// @brief **Edits given texts**\n
856 /// This is used to revise the respective strings and to get them in the desired format.
857 ///
858 /*!@{*/
859
860 //============================================================================
861 /// @brief Convert a string to uppercase.
862 ///
863 /// @param[in,out] str String to convert
864 ///
865 ///
866 /// --------------------------------------------------------------------------
867 /// Example:
868 /// ~~~~~~~~~~~~~{.cpp}
869 /// #include <kodi/tools/StringUtils.h>
870 ///
871 /// std::string refstr = "TEST";
872 ///
873 /// std::string varstr = "TeSt";
874 /// kodi::tools::StringUtils::ToUpper(varstr);
875 /// EXPECT_STREQ(refstr.c_str(), varstr.c_str());
876 /// ~~~~~~~~~~~~~
877 ///
878 inline static void ToUpper(std::string& str)
879 {
880 std::transform(str.begin(), str.end(), str.begin(), ::toupper);
881 }
882 //----------------------------------------------------------------------------
883
884 //============================================================================
885 /// @brief Convert a 16bit wide string to uppercase.
886 ///
887 /// @param[in,out] str String to convert
888 ///
889 inline static void ToUpper(std::wstring& str)
890 {
891 transform(str.begin(), str.end(), str.begin(), toupperUnicode);
892 }
893 //----------------------------------------------------------------------------
894
895 //============================================================================
896 /// @brief Convert a string to lowercase.
897 ///
898 /// @param[in,out] str String to convert
899 ///
900 ///
901 /// --------------------------------------------------------------------------
902 /// Example:
903 /// ~~~~~~~~~~~~~{.cpp}
904 /// #include <kodi/tools/StringUtils.h>
905 ///
906 /// std::string refstr = "test";
907 ///
908 /// std::string varstr = "TeSt";
909 /// kodi::tools::StringUtils::ToLower(varstr);
910 /// EXPECT_STREQ(refstr.c_str(), varstr.c_str());
911 /// ~~~~~~~~~~~~~
912 ///
913 inline static void ToLower(std::string& str)
914 {
915 transform(str.begin(), str.end(), str.begin(), ::tolower);
916 }
917 //----------------------------------------------------------------------------
918
919 //============================================================================
920 /// @brief Convert a 16bit wide string to lowercase.
921 ///
922 /// @param[in,out] str String to convert
923 ///
924 inline static void ToLower(std::wstring& str)
925 {
926 transform(str.begin(), str.end(), str.begin(), tolowerUnicode);
927 }
928 //----------------------------------------------------------------------------
929
930 //============================================================================
931 /// @brief Combine all numerical digits and give it as integer value.
932 ///
933 /// @param[in,out] str String to check for digits
934 /// @return All numerical digits fit together as integer value
935 ///
936 inline static int ReturnDigits(const std::string& str)
937 {
938 std::stringstream ss;
939 for (const auto& character : str)
940 {
941 if (isdigit(character))
942 ss << character;
943 }
944 return atoi(ss.str().c_str());
945 }
946 //----------------------------------------------------------------------------
947
948 //============================================================================
949 /// @brief Returns a string from start with givent count.
950 ///
951 /// @param[in] str String to use
952 /// @param[in] count Amount of characters to go from left
953 /// @return The left part string in amount of given count or complete if it
954 /// was higher.
955 ///
956 ///
957 /// --------------------------------------------------------------------------
958 /// Example:
959 /// ~~~~~~~~~~~~~{.cpp}
960 /// #include <kodi/tools/StringUtils.h>
961 ///
962 /// std::string refstr, varstr;
963 /// std::string origstr = "test";
964 ///
965 /// refstr = "";
966 /// varstr = kodi::tools::StringUtils::Left(origstr, 0);
967 /// EXPECT_STREQ(refstr.c_str(), varstr.c_str());
968 ///
969 /// refstr = "te";
970 /// varstr = kodi::tools::StringUtils::Left(origstr, 2);
971 /// EXPECT_STREQ(refstr.c_str(), varstr.c_str());
972 ///
973 /// refstr = "test";
974 /// varstr = kodi::tools::StringUtils::Left(origstr, 10);
975 /// EXPECT_STREQ(refstr.c_str(), varstr.c_str());
976 /// ~~~~~~~~~~~~~
977 ///
978 inline static std::string Left(const std::string& str, size_t count)
979 {
980 count = std::max((size_t)0, std::min(count, str.size()));
981 return str.substr(0, count);
982 }
983 //----------------------------------------------------------------------------
984
985 //============================================================================
986 /// @brief Get substring from mid of given string.
987 ///
988 /// @param[in] str String to get substring from
989 /// @param[in] first Position from where to start
990 /// @param[in] count [opt] length of position to get after start, default is
991 /// complete to end
992 /// @return The substring taken from middle of input string
993 ///
994 ///
995 /// --------------------------------------------------------------------------
996 /// Example:
997 /// ~~~~~~~~~~~~~{.cpp}
998 /// #include <kodi/tools/StringUtils.h>
999 ///
1000 /// std::string refstr, varstr;
1001 /// std::string origstr = "test";
1002 ///
1003 /// refstr = "";
1004 /// varstr = kodi::tools::StringUtils::Mid(origstr, 0, 0);
1005 /// EXPECT_STREQ(refstr.c_str(), varstr.c_str());
1006 ///
1007 /// refstr = "te";
1008 /// varstr = kodi::tools::StringUtils::Mid(origstr, 0, 2);
1009 /// EXPECT_STREQ(refstr.c_str(), varstr.c_str());
1010 ///
1011 /// refstr = "test";
1012 /// varstr = kodi::tools::StringUtils::Mid(origstr, 0, 10);
1013 /// EXPECT_STREQ(refstr.c_str(), varstr.c_str());
1014 ///
1015 /// refstr = "st";
1016 /// varstr = kodi::tools::StringUtils::Mid(origstr, 2);
1017 /// EXPECT_STREQ(refstr.c_str(), varstr.c_str());
1018 ///
1019 /// refstr = "st";
1020 /// varstr = kodi::tools::StringUtils::Mid(origstr, 2, 2);
1021 /// EXPECT_STREQ(refstr.c_str(), varstr.c_str());
1022 ///
1023 /// refstr = "es";
1024 /// varstr = kodi::tools::StringUtils::Mid(origstr, 1, 2);
1025 /// EXPECT_STREQ(refstr.c_str(), varstr.c_str());
1026 /// ~~~~~~~~~~~~~
1027 ///
1028 inline static std::string Mid(const std::string& str,
1029 size_t first,
1030 size_t count = std::string::npos)
1031 {
1032 if (first + count > str.size())
1033 count = str.size() - first;
1034
1035 if (first > str.size())
1036 return std::string();
1037
1038 assert(first + count <= str.size());
1039
1040 return str.substr(first, count);
1041 }
1042 //----------------------------------------------------------------------------
1043
1044 //============================================================================
1045 /// @brief Returns a string from end with givent count.
1046 ///
1047 /// @param[in] str String to use
1048 /// @param[in] count Amount of characters to go from right
1049 /// @return The right part string in amount of given count or complete if it
1050 /// was higher.
1051 ///
1052 ///
1053 /// --------------------------------------------------------------------------
1054 /// Example:
1055 /// ~~~~~~~~~~~~~{.cpp}
1056 /// #include <kodi/tools/StringUtils.h>
1057 ///
1058 /// std::string refstr, varstr;
1059 /// std::string origstr = "test";
1060 ///
1061 /// refstr = "";
1062 /// varstr = kodi::tools::StringUtils::Right(origstr, 0);
1063 /// EXPECT_STREQ(refstr.c_str(), varstr.c_str());
1064 ///
1065 /// refstr = "st";
1066 /// varstr = kodi::tools::StringUtils::Right(origstr, 2);
1067 /// EXPECT_STREQ(refstr.c_str(), varstr.c_str());
1068 ///
1069 /// refstr = "test";
1070 /// varstr = kodi::tools::StringUtils::Right(origstr, 10);
1071 /// EXPECT_STREQ(refstr.c_str(), varstr.c_str());
1072 /// ~~~~~~~~~~~~~
1073 ///
1074 inline static std::string Right(const std::string& str, size_t count)
1075 {
1076 count = std::max((size_t)0, std::min(count, str.size()));
1077 return str.substr(str.size() - count);
1078 }
1079 //----------------------------------------------------------------------------
1080
1081 //============================================================================
1082 /// @brief Trim a string with remove of not wanted spaces at begin and end
1083 /// of string.
1084 ///
1085 /// @param[in,out] str String to trim, becomes also changed and given on
1086 /// return
1087 /// @return The changed string
1088 ///
1089 ///
1090 /// --------------------------------------------------------------------------
1091 /// Example:
1092 /// ~~~~~~~~~~~~~{.cpp}
1093 /// #include <kodi/tools/StringUtils.h>
1094 ///
1095 /// std::string refstr = "test test";
1096 ///
1097 /// std::string varstr = " test test ";
1098 /// kodi::tools::StringUtils::Trim(varstr);
1099 /// EXPECT_STREQ(refstr.c_str(), varstr.c_str());
1100 /// ~~~~~~~~~~~~~
1101 ///
1102 inline static std::string& Trim(std::string& str)
1103 {
1104 TrimLeft(str);
1105 return TrimRight(str);
1106 }
1107 //----------------------------------------------------------------------------
1108
1109 //============================================================================
1110 /// @brief Trim a string with remove of not wanted characters at begin and end
1111 /// of string.
1112 ///
1113 /// @param[in,out] str String to trim, becomes also changed and given on
1114 /// return
1115 /// @param[in] chars Characters to use for trim
1116 /// @return The changed string
1117 ///
1118 inline static std::string& Trim(std::string& str, const char* const chars)
1119 {
1120 TrimLeft(str, chars);
1121 return TrimRight(str, chars);
1122 }
1123 //----------------------------------------------------------------------------
1124
1125 //============================================================================
1126 /// @brief Trim a string with remove of not wanted spaces at begin of string.
1127 ///
1128 /// @param[in,out] str String to trim, becomes also changed and given on
1129 /// return
1130 /// @return The changed string
1131 ///
1132 ///
1133 /// --------------------------------------------------------------------------
1134 /// Example:
1135 /// ~~~~~~~~~~~~~{.cpp}
1136 /// #include <kodi/tools/StringUtils.h>
1137 ///
1138 /// std::string refstr = "test test ";
1139 ///
1140 /// std::string varstr = " test test ";
1141 /// kodi::tools::StringUtils::TrimLeft(varstr);
1142 /// EXPECT_STREQ(refstr.c_str(), varstr.c_str());
1143 /// ~~~~~~~~~~~~~
1144 ///
1145 inline static std::string& TrimLeft(std::string& str)
1146 {
1147 str.erase(str.begin(),
1148 std::find_if(str.begin(), str.end(), [](char s) { return IsSpace(s) == 0; }));
1149 return str;
1150 }
1151 //----------------------------------------------------------------------------
1152
1153 //============================================================================
1154 /// @brief Trim a string with remove of not wanted characters at begin of
1155 /// string.
1156 ///
1157 /// @param[in,out] str String to trim, becomes also changed and given on
1158 /// return
1159 /// @param[in] chars Characters to use for trim
1160 /// @return The changed string
1161 ///
1162 inline static std::string& TrimLeft(std::string& str, const char* const chars)
1163 {
1164 size_t nidx = str.find_first_not_of(chars);
1165 str.erase(0, nidx);
1166 return str;
1167 }
1168 //----------------------------------------------------------------------------
1169
1170 //============================================================================
1171 /// @brief Trim a string with remove of not wanted spaces at end of string.
1172 ///
1173 /// @param[in,out] str String to trim, becomes also changed and given on
1174 /// return
1175 /// @return The changed string
1176 ///
1177 ///
1178 /// --------------------------------------------------------------------------
1179 /// Example:
1180 /// ~~~~~~~~~~~~~{.cpp}
1181 /// #include <kodi/tools/StringUtils.h>
1182 ///
1183 /// std::string refstr = " test test";
1184 ///
1185 /// std::string varstr = " test test ";
1186 /// kodi::tools::StringUtils::TrimRight(varstr);
1187 /// EXPECT_STREQ(refstr.c_str(), varstr.c_str());
1188 /// ~~~~~~~~~~~~~
1189 ///
1190 inline static std::string& TrimRight(std::string& str)
1191 {
1192 str.erase(std::find_if(str.rbegin(), str.rend(), [](char s) { return IsSpace(s) == 0; }).base(),
1193 str.end());
1194 return str;
1195 }
1196 //----------------------------------------------------------------------------
1197
1198 //============================================================================
1199 /// @brief Trim a string with remove of not wanted characters at end of
1200 /// string.
1201 ///
1202 /// @param[in,out] str String to trim, becomes also changed and given on
1203 /// return
1204 /// @param[in] chars Characters to use for trim
1205 /// @return The changed string
1206 ///
1207 inline static std::string& TrimRight(std::string& str, const char* const chars)
1208 {
1209 size_t nidx = str.find_last_not_of(chars);
1210 str.erase(str.npos == nidx ? 0 : ++nidx);
1211 return str;
1212 }
1213 //----------------------------------------------------------------------------
1214
1215 //============================================================================
1216 /// @brief Cleanup string by remove of duplicates of spaces and tabs.
1217 ///
1218 /// @param[in,out] str String to remove duplicates, becomes also changed and
1219 /// given further on return
1220 /// @return The changed string
1221 ///
1222 inline static std::string& RemoveDuplicatedSpacesAndTabs(std::string& str)
1223 {
1224 std::string::iterator it = str.begin();
1225 bool onSpace = false;
1226 while (it != str.end())
1227 {
1228 if (*it == '\t')
1229 *it = ' ';
1230
1231 if (*it == ' ')
1232 {
1233 if (onSpace)
1234 {
1235 it = str.erase(it);
1236 continue;
1237 }
1238 else
1239 onSpace = true;
1240 }
1241 else
1242 onSpace = false;
1243
1244 ++it;
1245 }
1246 return str;
1247 }
1248 //----------------------------------------------------------------------------
1249
1250 //============================================================================
1251 /// @brief Replace a character with another inside text string.
1252 ///
1253 /// @param[in] str String to replace within
1254 /// @param[in] oldChar Character to search for replacement
1255 /// @param[in] newChar New character to use for replacement
1256 /// @return Amount of replaced characters
1257 ///
1258 ///
1259 /// --------------------------------------------------------------------------
1260 /// Example:
1261 /// ~~~~~~~~~~~~~{.cpp}
1262 /// #include <kodi/tools/StringUtils.h>
1263 ///
1264 /// std::string refstr = "text text";
1265 ///
1266 /// std::string varstr = "test test";
1267 /// EXPECT_EQ(kodi::tools::StringUtils::Replace(varstr, 's', 'x'), 2);
1268 /// EXPECT_STREQ(refstr.c_str(), varstr.c_str());
1269 ///
1270 /// EXPECT_EQ(kodi::tools::StringUtils::Replace(varstr, 's', 'x'), 0);
1271 /// EXPECT_STREQ(refstr.c_str(), varstr.c_str());
1272 /// ~~~~~~~~~~~~~
1273 ///
1274 inline static int Replace(std::string& str, char oldChar, char newChar)
1275 {
1276 int replacedChars = 0;
1277 for (std::string::iterator it = str.begin(); it != str.end(); ++it)
1278 {
1279 if (*it == oldChar)
1280 {
1281 *it = newChar;
1282 replacedChars++;
1283 }
1284 }
1285
1286 return replacedChars;
1287 }
1288 //----------------------------------------------------------------------------
1289
1290 //============================================================================
1291 /// @brief Replace a complete text with another inside text string.
1292 ///
1293 /// @param[in] str String to replace within
1294 /// @param[in] oldStr String to search for replacement
1295 /// @param[in] newStr New string to use for replacement
1296 /// @return Amount of replaced text fields
1297 ///
1298 ///
1299 /// --------------------------------------------------------------------------
1300 /// Example:
1301 /// ~~~~~~~~~~~~~{.cpp}
1302 /// #include <kodi/tools/StringUtils.h>
1303 ///
1304 /// std::string refstr = "text text";
1305 ///
1306 /// std::string varstr = "test test";
1307 /// EXPECT_EQ(kodi::tools::StringUtils::Replace(varstr, "s", "x"), 2);
1308 /// EXPECT_STREQ(refstr.c_str(), varstr.c_str());
1309 ///
1310 /// EXPECT_EQ(kodi::tools::StringUtils::Replace(varstr, "s", "x"), 0);
1311 /// EXPECT_STREQ(refstr.c_str(), varstr.c_str());
1312 /// ~~~~~~~~~~~~~
1313 ///
1314 inline static int Replace(std::string& str, const std::string& oldStr, const std::string& newStr)
1315 {
1316 if (oldStr.empty())
1317 return 0;
1318
1319 int replacedChars = 0;
1320 size_t index = 0;
1321
1322 while (index < str.size() && (index = str.find(oldStr, index)) != std::string::npos)
1323 {
1324 str.replace(index, oldStr.size(), newStr);
1325 index += newStr.size();
1326 replacedChars++;
1327 }
1328
1329 return replacedChars;
1330 }
1331 //----------------------------------------------------------------------------
1332
1333 //============================================================================
1334 /// @brief Replace a complete text with another inside 16bit wide text string.
1335 ///
1336 /// @param[in] str String to replace within
1337 /// @param[in] oldStr String to search for replacement
1338 /// @param[in] newStr New string to use for replacement
1339 /// @return Amount of replaced text fields
1340 ///
1341 inline static int Replace(std::wstring& str,
1342 const std::wstring& oldStr,
1343 const std::wstring& newStr)
1344 {
1345 if (oldStr.empty())
1346 return 0;
1347
1348 int replacedChars = 0;
1349 size_t index = 0;
1350
1351 while (index < str.size() && (index = str.find(oldStr, index)) != std::string::npos)
1352 {
1353 str.replace(index, oldStr.size(), newStr);
1354 index += newStr.size();
1355 replacedChars++;
1356 }
1357
1358 return replacedChars;
1359 }
1360 //----------------------------------------------------------------------------
1361
1362 //============================================================================
1363 /// @brief Transform characters to create a safe URL.
1364 ///
1365 /// @param[in] str The string to transform
1366 /// @return The transformed string, with unsafe characters replaced by "_"
1367 ///
1368 /// Safe URLs are composed of the unreserved characters defined in
1369 /// RFC 3986 section 2.3:
1370 ///
1371 /// ALPHA / DIGIT / "-" / "." / "_" / "~"
1372 ///
1373 /// Characters outside of this set will be replaced by "_".
1374 ///
1375 inline static std::string MakeSafeUrl(const std::string& str)
1376 {
1377 std::string safeUrl;
1378
1379 safeUrl.reserve(str.size());
1380
1381 std::transform(str.begin(), str.end(), std::back_inserter(safeUrl), [](char c) {
1382 if (('a' <= c && c <= 'z') || ('A' <= c && c <= 'Z') || ('0' <= c && c <= '9') || c == '-' ||
1383 c == '.' || c == '_' || c == '~')
1384 {
1385 return c;
1386 }
1387 return '_';
1388 });
1389
1390 return safeUrl;
1391 }
1392 //----------------------------------------------------------------------------
1393
1394 //============================================================================
1395 /// @brief Transform characters to create a safe, printable string.
1396 ///
1397 /// @param[in] str The string to transform
1398 /// @return The transformed string, with unsafe characters replaced by " "
1399 ///
1400 /// Unsafe characters are defined as the non-printable ASCII characters
1401 /// (character code 0-31).
1402 ///
1403 inline static std::string MakeSafeString(const std::string& str)
1404 {
1405 std::string safeString;
1406
1407 safeString.reserve(str.size());
1408
1409 std::transform(str.begin(), str.end(), std::back_inserter(safeString), [](char c) {
1410 if (c < 0x20)
1411 return ' ';
1412
1413 return c;
1414 });
1415
1416 return safeString;
1417 }
1418 //----------------------------------------------------------------------------
1419
1420 //============================================================================
1421 /// @brief Removes a MAC address from a given string.
1422 ///
1423 /// @param[in] str The string containing a MAC address
1424 /// @return The string without the MAC address (for chaining)
1425 ///
1426 inline static std::string RemoveMACAddress(const std::string& str)
1427 {
1428 std::regex re(R"mac([\(\[]?([0-9A-Fa-f]{2}[:-]){5}([0-9A-Fa-f]{2})[\)\]]?)mac");
1429 return std::regex_replace(str, re, "", std::regex_constants::format_default);
1430 }
1431 //----------------------------------------------------------------------------
1432
1433 //============================================================================
1434 /// @brief Remove carriage return and line feeds on string ends.
1435 ///
1436 /// @param[in,out] str String where CR and LF becomes removed on end
1437 ///
1438 ///
1439 /// --------------------------------------------------------------------------
1440 /// Example:
1441 /// ~~~~~~~~~~~~~{.cpp}
1442 /// #include <kodi/tools/StringUtils.h>
1443 ///
1444 /// std::string refstr, varstr;
1445 ///
1446 /// refstr = "test\r\nstring\nblah blah";
1447 /// varstr = "test\r\nstring\nblah blah\n";
1448 /// kodi::tools::StringUtils::RemoveCRLF(varstr);
1449 /// EXPECT_STREQ(refstr.c_str(), varstr.c_str());
1450 /// ~~~~~~~~~~~~~
1451 ///
1452 inline static void RemoveCRLF(std::string& strLine) { StringUtils::TrimRight(strLine, "\n\r"); }
1453 //----------------------------------------------------------------------------
1454
1455 //============================================================================
1456 /// @brief Convert a word to a digit numerical string
1457 ///
1458 /// @param[in] str String to convert
1459 ///
1460 ///
1461 /// --------------------------------------------------------------------------
1462 /// Example:
1463 /// ~~~~~~~~~~~~~{.cpp}
1464 /// std::string ref, var;
1465 ///
1466 /// ref = "8378 787464";
1467 /// var = "test string";
1468 /// kodi::tools::StringUtils::WordToDigits(var);
1469 /// EXPECT_STREQ(ref.c_str(), var.c_str());
1470 /// ~~~~~~~~~~~~~
1471 ///
1472 inline static void WordToDigits(std::string& word)
1473 {
1474 static const char word_to_letter[] = "22233344455566677778889999";
1475 StringUtils::ToLower(word);
1476 for (unsigned int i = 0; i < word.size(); ++i)
1477 { // NB: This assumes ascii, which probably needs extending at some point.
1478 char letter = word[i];
1479 if ((letter >= 'a' && letter <= 'z')) // assume contiguous letter range
1480 {
1481 word[i] = word_to_letter[letter - 'a'];
1482 }
1483 else if (letter < '0' || letter > '9') // We want to keep 0-9!
1484 {
1485 word[i] = ' '; // replace everything else with a space
1486 }
1487 }
1488 }
1489 //----------------------------------------------------------------------------
1490
1491 //============================================================================
1492 /// @brief Escapes the given string to be able to be used as a parameter.
1493 ///
1494 /// Escapes backslashes and double-quotes with an additional backslash and
1495 /// adds double-quotes around the whole string.
1496 ///
1497 /// @param[in] param String to escape/paramify
1498 /// @return Escaped/Paramified string
1499 ///
1500 ///
1501 /// --------------------------------------------------------------------------
1502 /// Example:
1503 /// ~~~~~~~~~~~~~{.cpp}
1504 /// const char *input = "some, very \\ odd \"string\"";
1505 /// const char *ref = "\"some, very \\\\ odd \\\"string\\\"\"";
1506 ///
1507 /// std::string result = kodi::tools::StringUtils::Paramify(input);
1508 /// EXPECT_STREQ(ref, result.c_str());
1509 /// ~~~~~~~~~~~~~
1510 ///
1511 inline static std::string Paramify(const std::string& param)
1512 {
1513 std::string result = param;
1514 // escape backspaces
1515 StringUtils::Replace(result, "\\", "\\\\");
1516 // escape double quotes
1517 StringUtils::Replace(result, "\"", "\\\"");
1518
1519 // add double quotes around the whole string
1520 return "\"" + result + "\"";
1521 }
1522 //----------------------------------------------------------------------------
1523
1524 /*!@}*/
1525
1526 //----------------------------------------------------------------------------
1527 /// @defgroup cpp_kodi_tools_StringUtils_CompareControl String compare
1528 /// @ingroup cpp_kodi_tools_StringUtils
1529 /// @brief **Check strings for the desired state**\n
1530 /// With this, texts can be checked to see that they correspond to a required
1531 /// format.
1532 ///
1533 /*!@{*/
1534
1535 //============================================================================
1536 /// @brief Compare two strings with ignore of lower-/uppercase.
1537 ///
1538 /// @param[in] str1 C++ string to compare
1539 /// @param[in] str2 C++ string to compare
1540 /// @return True if the strings are equal, false otherwise
1541 ///
1542 ///
1543 /// --------------------------------------------------------------------------
1544 /// Example:
1545 /// ~~~~~~~~~~~~~{.cpp}
1546 /// #include <kodi/tools/StringUtils.h>
1547 ///
1548 /// std::string refstr = "TeSt";
1549 ///
1550 /// EXPECT_TRUE(kodi::tools::StringUtils::EqualsNoCase(refstr, "TeSt"));
1551 /// EXPECT_TRUE(kodi::tools::StringUtils::EqualsNoCase(refstr, "tEsT"));
1552 /// ~~~~~~~~~~~~~
1553 ///
1554 inline static bool EqualsNoCase(const std::string& str1, const std::string& str2)
1555 {
1556 // before we do the char-by-char comparison, first compare sizes of both strings.
1557 // This led to a 33% improvement in benchmarking on average. (size() just returns a member of std::string)
1558 if (str1.size() != str2.size())
1559 return false;
1560 return EqualsNoCase(str1.c_str(), str2.c_str());
1561 }
1562 //----------------------------------------------------------------------------
1563
1564 //============================================================================
1565 /// @brief Compare two strings with ignore of lower-/uppercase.
1566 ///
1567 /// @param[in] str1 C++ string to compare
1568 /// @param[in] s2 C string to compare
1569 /// @return True if the strings are equal, false otherwise
1570 ///
1571 inline static bool EqualsNoCase(const std::string& str1, const char* s2)
1572 {
1573 return EqualsNoCase(str1.c_str(), s2);
1574 }
1575 //----------------------------------------------------------------------------
1576
1577 //============================================================================
1578 /// @brief Compare two strings with ignore of lower-/uppercase.
1579 ///
1580 /// @param[in] s1 C string to compare
1581 /// @param[in] s2 C string to compare
1582 /// @return True if the strings are equal, false otherwise
1583 ///
1584 inline static bool EqualsNoCase(const char* s1, const char* s2)
1585 {
1586 char c2; // we need only one char outside the loop
1587 do
1588 {
1589 const char c1 = *s1++; // const local variable should help compiler to optimize
1590 c2 = *s2++;
1591 // This includes the possibility that one of the characters is the null-terminator,
1592 // which implies a string mismatch.
1593 if (c1 != c2 && ::tolower(c1) != ::tolower(c2))
1594 return false;
1595 } while (c2 != '\0'); // At this point, we know c1 == c2, so there's no need to test them both.
1596 return true;
1597 }
1598 //----------------------------------------------------------------------------
1599
1600 //============================================================================
1601 /// @brief Compare two strings with ignore of lower-/uppercase with given
1602 /// size.
1603 ///
1604 /// Equal to @ref EqualsNoCase only that size can defined and on return the
1605 /// difference between compared character becomes given.
1606 ///
1607 /// @param[in] str1 C++ string to compare
1608 /// @param[in] str2 C++ string to compare
1609 /// @param[in] n [opt] Length to check, 0 as default to make complete
1610 /// @return 0 if equal, otherwise difference of failed character in string to
1611 /// other ("a" - "b" = -1)
1612 ///
1613 inline static int CompareNoCase(const std::string& str1, const std::string& str2, size_t n = 0)
1614 {
1615 return CompareNoCase(str1.c_str(), str2.c_str(), n);
1616 }
1617 //----------------------------------------------------------------------------
1618
1619 //============================================================================
1620 /// @brief Compare two strings with ignore of lower-/uppercase with given
1621 /// size.
1622 ///
1623 /// Equal to @ref EqualsNoCase only that size can defined and on return the
1624 /// difference between compared character becomes given.
1625 ///
1626 /// @param[in] s1 C string to compare
1627 /// @param[in] s2 C string to compare
1628 /// @param[in] n [opt] Length to check, 0 as default to make complete
1629 /// @return 0 if equal, otherwise difference of failed character in string to
1630 /// other ("a" - "b" = -1)
1631 ///
1632 inline static int CompareNoCase(const char* s1, const char* s2, size_t n = 0)
1633 {
1634 char c2; // we need only one char outside the loop
1635 size_t index = 0;
1636 do
1637 {
1638 const char c1 = *s1++; // const local variable should help compiler to optimize
1639 c2 = *s2++;
1640 index++;
1641 // This includes the possibility that one of the characters is the null-terminator,
1642 // which implies a string mismatch.
1643 if (c1 != c2 && ::tolower(c1) != ::tolower(c2))
1644 return ::tolower(c1) - ::tolower(c2);
1645 } while (c2 != '\0' &&
1646 index != n); // At this point, we know c1 == c2, so there's no need to test them both.
1647 return 0;
1648 }
1649 //----------------------------------------------------------------------------
1650
1651 //============================================================================
1652 /// @brief Checks a string for the begin of another string.
1653 ///
1654 /// @param[in] str1 C++ string to be checked
1655 /// @param[in] str2 C++ string with which text defined in str1 is checked at
1656 /// the beginning
1657 /// @return True if string started with asked text, false otherwise
1658 ///
1659 ///
1660 /// --------------------------------------------------------------------------
1661 /// Example:
1662 /// ~~~~~~~~~~~~~{.cpp}
1663 /// #include <kodi/tools/StringUtils.h>
1664 ///
1665 /// bool ret;
1666 /// std::string refstr = "test";
1667 ///
1668 /// ret = kodi::tools::StringUtils::StartsWith(refstr, "te");
1669 /// fprintf(stderr, "Excpect true for here and is '%s'\n", ret ? "true" : "false");
1670 ///
1671 /// ret = kodi::tools::StringUtils::StartsWith(refstr, "abc");
1672 /// fprintf(stderr, "Excpect false for here and is '%s'\n", ret ? "true" : "false");
1673 /// ~~~~~~~~~~~~~
1674 ///
1675 inline static bool StartsWith(const std::string& str1, const std::string& str2)
1676 {
1677 return str1.compare(0, str2.size(), str2) == 0;
1678 }
1679 //----------------------------------------------------------------------------
1680
1681 //============================================================================
1682 /// @brief Checks a string for the begin of another string.
1683 ///
1684 /// @param[in] str1 C++ string to be checked
1685 /// @param[in] s2 C string with which text defined in str1 is checked at
1686 /// the beginning
1687 /// @return True if string started with asked text, false otherwise
1688 ///
1689 inline static bool StartsWith(const std::string& str1, const char* s2)
1690 {
1691 return StartsWith(str1.c_str(), s2);
1692 }
1693 //----------------------------------------------------------------------------
1694
1695 //============================================================================
1696 /// @brief Checks a string for the begin of another string.
1697 ///
1698 /// @param[in] s1 C string to be checked
1699 /// @param[in] s2 C string with which text defined in str1 is checked at
1700 /// the beginning
1701 /// @return True if string started with asked text, false otherwise
1702 ///
1703 inline static bool StartsWith(const char* s1, const char* s2)
1704 {
1705 while (*s2 != '\0')
1706 {
1707 if (*s1 != *s2)
1708 return false;
1709 s1++;
1710 s2++;
1711 }
1712 return true;
1713 }
1714 //----------------------------------------------------------------------------
1715
1716 //============================================================================
1717 /// @brief Checks a string for the begin of another string by ignore of
1718 /// upper-/lowercase.
1719 ///
1720 /// @param[in] str1 C++ string to be checked
1721 /// @param[in] str2 C++ string with which text defined in str1 is checked at
1722 /// the beginning
1723 /// @return True if string started with asked text, false otherwise
1724 ///
1725 ///
1726 /// --------------------------------------------------------------------------
1727 /// Example:
1728 /// ~~~~~~~~~~~~~{.cpp}
1729 /// #include <kodi/tools/StringUtils.h>
1730 ///
1731 /// bool ret;
1732 /// std::string refstr = "test";
1733 ///
1734 /// ret = kodi::tools::StringUtils::StartsWithNoCase(refstr, "te");
1735 /// fprintf(stderr, "Excpect true for here and is '%s'\n", ret ? "true" : "false");
1736 ///
1737 /// ret = kodi::tools::StringUtils::StartsWithNoCase(refstr, "TEs");
1738 /// fprintf(stderr, "Excpect true for here and is '%s'\n", ret ? "true" : "false");
1739 ///
1740 /// ret = kodi::tools::StringUtils::StartsWithNoCase(refstr, "abc");
1741 /// fprintf(stderr, "Excpect false for here and is '%s'\n", ret ? "true" : "false");
1742 /// ~~~~~~~~~~~~~
1743 ///
1744 inline static bool StartsWithNoCase(const std::string& str1, const std::string& str2)
1745 {
1746 return StartsWithNoCase(str1.c_str(), str2.c_str());
1747 }
1748 //----------------------------------------------------------------------------
1749
1750 //============================================================================
1751 /// @brief Checks a string for the begin of another string by ignore of
1752 /// upper-/lowercase.
1753 ///
1754 /// @param[in] str1 C++ string to be checked
1755 /// @param[in] s2 C string with which text defined in str1 is checked at
1756 /// the beginning
1757 /// @return True if string started with asked text, false otherwise
1758 ///
1759 inline static bool StartsWithNoCase(const std::string& str1, const char* s2)
1760 {
1761 return StartsWithNoCase(str1.c_str(), s2);
1762 }
1763 //----------------------------------------------------------------------------
1764
1765 //============================================================================
1766 /// @brief Checks a string for the begin of another string by ignore of
1767 /// upper-/lowercase.
1768 ///
1769 /// @param[in] s1 C string to be checked
1770 /// @param[in] s2 C string with which text defined in str1 is checked at
1771 /// the beginning
1772 /// @return True if string started with asked text, false otherwise
1773 ///
1774 inline static bool StartsWithNoCase(const char* s1, const char* s2)
1775 {
1776 while (*s2 != '\0')
1777 {
1778 if (::tolower(*s1) != ::tolower(*s2))
1779 return false;
1780 s1++;
1781 s2++;
1782 }
1783 return true;
1784 }
1785 //----------------------------------------------------------------------------
1786
1787 //============================================================================
1788 /// @brief Checks a string for the ending of another string.
1789 ///
1790 /// @param[in] str1 C++ string to be checked
1791 /// @param[in] str2 C++ string with which text defined in str1 is checked at
1792 /// the ending
1793 /// @return True if string ended with asked text, false otherwise
1794 ///
1795 ///
1796 /// --------------------------------------------------------------------------
1797 /// Example:
1798 /// ~~~~~~~~~~~~~{.cpp}
1799 /// #include <kodi/tools/StringUtils.h>
1800 ///
1801 /// bool ret;
1802 /// std::string refstr = "test";
1803 ///
1804 /// ret = kodi::tools::StringUtils::EndsWith(refstr, "st");
1805 /// fprintf(stderr, "Excpect true for here and is '%s'\n", ret ? "true" : "false");
1806 ///
1807 /// ret = kodi::tools::StringUtils::EndsWith(refstr, "abc");
1808 /// fprintf(stderr, "Excpect false for here and is '%s'\n", ret ? "true" : "false");
1809 /// ~~~~~~~~~~~~~
1810 ///
1811 inline static bool EndsWith(const std::string& str1, const std::string& str2)
1812 {
1813 if (str1.size() < str2.size())
1814 return false;
1815 return str1.compare(str1.size() - str2.size(), str2.size(), str2) == 0;
1816 }
1817 //----------------------------------------------------------------------------
1818
1819 //============================================================================
1820 /// @brief Checks a string for the ending of another string.
1821 ///
1822 /// @param[in] str1 C++ string to be checked
1823 /// @param[in] s2 C string with which text defined in str1 is checked at
1824 /// the ending
1825 /// @return True if string ended with asked text, false otherwise
1826 ///
1827 inline static bool EndsWith(const std::string& str1, const char* s2)
1828 {
1829 size_t len2 = strlen(s2);
1830 if (str1.size() < len2)
1831 return false;
1832 return str1.compare(str1.size() - len2, len2, s2) == 0;
1833 }
1834 //----------------------------------------------------------------------------
1835
1836 //============================================================================
1837 /// @brief Checks a string for the ending of another string by ignore of
1838 /// upper-/lowercase.
1839 ///
1840 /// @param[in] str1 C++ string to be checked
1841 /// @param[in] str2 C++ string with which text defined in str1 is checked at
1842 /// the ending
1843 /// @return True if string ended with asked text, false otherwise
1844 ///
1845 ///
1846 /// --------------------------------------------------------------------------
1847 /// Example:
1848 /// ~~~~~~~~~~~~~{.cpp}
1849 /// #include <kodi/tools/StringUtils.h>
1850 ///
1851 /// bool ret;
1852 /// std::string refstr = "test";
1853 ///
1854 /// ret = kodi::tools::StringUtils::EndsWithNoCase(refstr, "ST");
1855 /// fprintf(stderr, "Excpect true for here and is '%s'\n", ret ? "true" : "false");
1856 ///
1857 /// ret = kodi::tools::StringUtils::EndsWithNoCase(refstr, "ABC");
1858 /// fprintf(stderr, "Excpect false for here and is '%s'\n", ret ? "true" : "false");
1859 /// ~~~~~~~~~~~~~
1860 ///
1861 inline static bool EndsWithNoCase(const std::string& str1, const std::string& str2)
1862 {
1863 if (str1.size() < str2.size())
1864 return false;
1865 const char* s1 = str1.c_str() + str1.size() - str2.size();
1866 const char* s2 = str2.c_str();
1867 while (*s2 != '\0')
1868 {
1869 if (::tolower(*s1) != ::tolower(*s2))
1870 return false;
1871 s1++;
1872 s2++;
1873 }
1874 return true;
1875 }
1876 //----------------------------------------------------------------------------
1877
1878 //============================================================================
1879 /// @brief Checks a string for the ending of another string by ignore of
1880 /// upper-/lowercase.
1881 ///
1882 /// @param[in] str1 C++ string to be checked
1883 /// @param[in] s2 C string with which text defined in str1 is checked at
1884 /// the ending
1885 /// @return True if string ended with asked text, false otherwise
1886 ///
1887 inline static bool EndsWithNoCase(const std::string& str1, const char* s2)
1888 {
1889 size_t len2 = strlen(s2);
1890 if (str1.size() < len2)
1891 return false;
1892 const char* s1 = str1.c_str() + str1.size() - len2;
1893 while (*s2 != '\0')
1894 {
1895 if (::tolower(*s1) != ::tolower(*s2))
1896 return false;
1897 s1++;
1898 s2++;
1899 }
1900 return true;
1901 }
1902 //----------------------------------------------------------------------------
1903
1904 //============================================================================
1905 /// @brief Compare two strings by his calculated alpha numeric values.
1906 ///
1907 /// @param[in] left Left string to compare with right
1908 /// @param[in] right Right string to compare with left
1909 /// @return Return about compare
1910 /// - 0 if left and right the same
1911 /// - -1 if right is longer
1912 /// - 1 if left is longer
1913 /// - < 0 if less equal
1914 /// - > 0 if more equal
1915 ///
1916 ///
1917 /// --------------------------------------------------------------------------
1918 /// Example:
1919 /// ~~~~~~~~~~~~~{.cpp}
1920 /// #include <kodi/tools/StringUtils.h>
1921 ///
1922 /// int64_t ref, var;
1923 ///
1924 /// ref = 0;
1925 /// var = kodi::tools::StringUtils::AlphaNumericCompare(L"123abc", L"abc123");
1926 /// EXPECT_LT(var, ref);
1927 /// ~~~~~~~~~~~~~
1928 ///
1929 inline static int64_t AlphaNumericCompare(const wchar_t* left, const wchar_t* right)
1930 {
1931 const wchar_t* l = left;
1932 const wchar_t* r = right;
1933 const wchar_t *ld, *rd;
1934 wchar_t lc, rc;
1935 int64_t lnum, rnum;
1936 const std::collate<wchar_t>& coll = std::use_facet<std::collate<wchar_t>>(std::locale());
1937 int cmp_res = 0;
1938 while (*l != 0 && *r != 0)
1939 {
1940 // check if we have a numerical value
1941 if (*l >= L'0' && *l <= L'9' && *r >= L'0' && *r <= L'9')
1942 {
1943 ld = l;
1944 lnum = 0;
1945 while (*ld >= L'0' && *ld <= L'9' && ld < l + 15)
1946 { // compare only up to 15 digits
1947 lnum *= 10;
1948 lnum += *ld++ - '0';
1949 }
1950 rd = r;
1951 rnum = 0;
1952 while (*rd >= L'0' && *rd <= L'9' && rd < r + 15)
1953 { // compare only up to 15 digits
1954 rnum *= 10;
1955 rnum += *rd++ - L'0';
1956 }
1957 // do we have numbers?
1958 if (lnum != rnum)
1959 { // yes - and they're different!
1960 return lnum - rnum;
1961 }
1962 l = ld;
1963 r = rd;
1964 continue;
1965 }
1966 // do case less comparison
1967 lc = *l;
1968 if (lc >= L'A' && lc <= L'Z')
1969 lc += L'a' - L'A';
1970 rc = *r;
1971 if (rc >= L'A' && rc <= L'Z')
1972 rc += L'a' - L'A';
1973
1974 // ok, do a normal comparison, taking current locale into account. Add special case stuff (eg '(' characters)) in here later
1975 if ((cmp_res = coll.compare(&lc, &lc + 1, &rc, &rc + 1)) != 0)
1976 {
1977 return cmp_res;
1978 }
1979 l++;
1980 r++;
1981 }
1982 if (*r)
1983 { // r is longer
1984 return -1;
1985 }
1986 else if (*l)
1987 { // l is longer
1988 return 1;
1989 }
1990 return 0; // files are the same
1991 }
1992 //----------------------------------------------------------------------------
1993
1994 //============================================================================
1995 /// @brief UTF8 version of strlen
1996 ///
1997 /// Skips any non-starting bytes in the count, thus returning the number of
1998 /// utf8 characters.
1999 ///
2000 /// @param[in] s c-string to find the length of.
2001 /// @return The number of utf8 characters in the string.
2002 ///
2003 inline static size_t Utf8StringLength(const char* s)
2004 {
2005 size_t length = 0;
2006 while (*s)
2007 {
2008 if ((*s++ & 0xC0) != 0x80)
2009 length++;
2010 }
2011 return length;
2012 }
2013 //----------------------------------------------------------------------------
2014
2015 //============================================================================
2016 /// @brief Check given character is a space.
2017 ///
2018 /// Hack to check only first byte of UTF-8 character
2019 /// without this hack "TrimX" functions failed on Win32 and OS X with UTF-8 strings
2020 ///
2021 /// @param[in] c Character to check
2022 /// @return true if space, false otherwise
2023 ///
2024 inline static int IsSpace(char c) { return (c & 0x80) == 0 && ::isspace(c); }
2025 //----------------------------------------------------------------------------
2026
2027 //============================================================================
2028 /// @brief Checks given pointer in string is a UTF8 letter.
2029 ///
2030 /// @param[in] str Given character values to check, must be minimum array of 2
2031 /// @return return -1 if not, else return the utf8 char length.
2032 ///
2033 inline static int IsUTF8Letter(const unsigned char* str)
2034 {
2035 // reference:
2036 // unicode -> utf8 table: http://www.utf8-chartable.de/
2037 // latin characters in unicode: http://en.wikipedia.org/wiki/Latin_characters_in_Unicode
2038 unsigned char ch = str[0];
2039 if (!ch)
2040 return -1;
2041 if ((ch >= 'a' && ch <= 'z') || (ch >= 'A' && ch <= 'Z'))
2042 return 1;
2043 if (!(ch & 0x80))
2044 return -1;
2045 unsigned char ch2 = str[1];
2046 if (!ch2)
2047 return -1;
2048 // check latin 1 letter table: http://en.wikipedia.org/wiki/C1_Controls_and_Latin-1_Supplement
2049 if (ch == 0xC3 && ch2 >= 0x80 && ch2 <= 0xBF && ch2 != 0x97 && ch2 != 0xB7)
2050 return 2;
2051 // check latin extended A table: http://en.wikipedia.org/wiki/Latin_Extended-A
2052 if (ch >= 0xC4 && ch <= 0xC7 && ch2 >= 0x80 && ch2 <= 0xBF)
2053 return 2;
2054 // check latin extended B table: http://en.wikipedia.org/wiki/Latin_Extended-B
2055 // and International Phonetic Alphabet: http://en.wikipedia.org/wiki/IPA_Extensions_(Unicode_block)
2056 if (((ch == 0xC8 || ch == 0xC9) && ch2 >= 0x80 && ch2 <= 0xBF) ||
2057 (ch == 0xCA && ch2 >= 0x80 && ch2 <= 0xAF))
2058 return 2;
2059 return -1;
2060 }
2061 //----------------------------------------------------------------------------
2062
2063 //============================================================================
2064 /// @brief Check whether a string is a natural number.
2065 ///
2066 /// Matches `[ \t]*[0-9]+[ \t]*`
2067 ///
2068 /// @param[in] str The string to check
2069 /// @return true if the string is a natural number, false otherwise.
2070 ///
2071 ///
2072 /// --------------------------------------------------------------------------
2073 /// Example:
2074 /// ~~~~~~~~~~~~~{.cpp}
2075 /// #include <kodi/tools/StringUtils.h>
2076 ///
2077 /// EXPECT_TRUE(kodi::tools::StringUtils::IsNaturalNumber("10"));
2078 /// EXPECT_TRUE(kodi::tools::StringUtils::IsNaturalNumber(" 10"));
2079 /// EXPECT_TRUE(kodi::tools::StringUtils::IsNaturalNumber("0"));
2080 /// EXPECT_FALSE(kodi::tools::StringUtils::IsNaturalNumber(" 1 0"));
2081 /// EXPECT_FALSE(kodi::tools::StringUtils::IsNaturalNumber("1.0"));
2082 /// EXPECT_FALSE(kodi::tools::StringUtils::IsNaturalNumber("1.1"));
2083 /// EXPECT_FALSE(kodi::tools::StringUtils::IsNaturalNumber("0x1"));
2084 /// EXPECT_FALSE(kodi::tools::StringUtils::IsNaturalNumber("blah"));
2085 /// EXPECT_FALSE(kodi::tools::StringUtils::IsNaturalNumber("120 h"));
2086 /// EXPECT_FALSE(kodi::tools::StringUtils::IsNaturalNumber(" "));
2087 /// EXPECT_FALSE(kodi::tools::StringUtils::IsNaturalNumber(""));
2088 /// ~~~~~~~~~~~~~
2089 ///
2090 inline static bool IsNaturalNumber(const std::string& str)
2091 {
2092 size_t i = 0, n = 0;
2093 // allow whitespace,digits,whitespace
2094 while (i < str.size() && isspace((unsigned char)str[i]))
2095 i++;
2096 while (i < str.size() && isdigit((unsigned char)str[i]))
2097 {
2098 i++;
2099 n++;
2100 }
2101 while (i < str.size() && isspace((unsigned char)str[i]))
2102 i++;
2103 return i == str.size() && n > 0;
2104 }
2105 //----------------------------------------------------------------------------
2106
2107 //============================================================================
2108 /// @brief Check whether a string is an integer.
2109 ///
2110 /// Matches `[ \t]*[\-]*[0-9]+[ \t]*`
2111 ///
2112 /// @param str The string to check
2113 /// @return true if the string is an integer, false otherwise.
2114 ///
2115 ///
2116 /// --------------------------------------------------------------------------
2117 /// Example:
2118 /// ~~~~~~~~~~~~~{.cpp}
2119 /// #include <kodi/tools/StringUtils.h>
2120 ///
2121 /// EXPECT_TRUE(kodi::tools::StringUtils::IsInteger("10"));
2122 /// EXPECT_TRUE(kodi::tools::StringUtils::IsInteger(" -10"));
2123 /// EXPECT_TRUE(kodi::tools::StringUtils::IsInteger("0"));
2124 /// EXPECT_FALSE(kodi::tools::StringUtils::IsInteger(" 1 0"));
2125 /// EXPECT_FALSE(kodi::tools::StringUtils::IsInteger("1.0"));
2126 /// EXPECT_FALSE(kodi::tools::StringUtils::IsInteger("1.1"));
2127 /// EXPECT_FALSE(kodi::tools::StringUtils::IsInteger("0x1"));
2128 /// EXPECT_FALSE(kodi::tools::StringUtils::IsInteger("blah"));
2129 /// EXPECT_FALSE(kodi::tools::StringUtils::IsInteger("120 h"));
2130 /// EXPECT_FALSE(kodi::tools::StringUtils::IsInteger(" "));
2131 /// EXPECT_FALSE(kodi::tools::StringUtils::IsInteger(""));
2132 /// ~~~~~~~~~~~~~
2133 ///
2134 inline static bool IsInteger(const std::string& str)
2135 {
2136 size_t i = 0, n = 0;
2137 // allow whitespace,-,digits,whitespace
2138 while (i < str.size() && isspace((unsigned char)str[i]))
2139 i++;
2140 if (i < str.size() && str[i] == '-')
2141 i++;
2142 while (i < str.size() && isdigit((unsigned char)str[i]))
2143 {
2144 i++;
2145 n++;
2146 }
2147 while (i < str.size() && isspace((unsigned char)str[i]))
2148 i++;
2149 return i == str.size() && n > 0;
2150 }
2151 //----------------------------------------------------------------------------
2152
2153 //============================================================================
2154 /// @brief Checks a character is ascii number.
2155 ///
2156 /// @param[in] chr Single character to test
2157 /// @return true if yes, false otherwise
2158 ///
2159 inline static bool IsAasciiDigit(char chr) // locale independent
2160 {
2161 return chr >= '0' && chr <= '9';
2162 }
2163 //----------------------------------------------------------------------------
2164
2165 //============================================================================
2166 /// @brief Checks a character is ascii hexadecimal number.
2167 ///
2168 /// @param[in] chr Single character to test
2169 /// @return true if yes, false otherwise
2170 ///
2171 inline static bool IsAsciiXDigit(char chr) // locale independent
2172 {
2173 return (chr >= '0' && chr <= '9') || (chr >= 'a' && chr <= 'f') || (chr >= 'A' && chr <= 'F');
2174 }
2175 //----------------------------------------------------------------------------
2176
2177 //============================================================================
2178 /// @brief Translate a character where defined as a numerical value (0-9)
2179 /// string to right integer.
2180 ///
2181 /// @param[in] chr Single character to translate
2182 /// @return
2183 ///
2184 inline static int AsciiDigitValue(char chr) // locale independent
2185 {
2186 if (!IsAasciiDigit(chr))
2187 return -1;
2188
2189 return chr - '0';
2190 }
2191 //----------------------------------------------------------------------------
2192
2193 //============================================================================
2194 /// @brief Translate a character where defined as a hexadecimal value string
2195 /// to right integer.
2196 ///
2197 /// @param[in] chr Single character to translate
2198 /// @return Corresponding integer value, e.g. character is "A" becomes
2199 /// returned as a integer with 10.
2200 ///
2201 inline static int AsciiXDigitValue(char chr) // locale independent
2202 {
2203 int v = AsciiDigitValue(chr);
2204 if (v >= 0)
2205 return v;
2206 if (chr >= 'a' && chr <= 'f')
2207 return chr - 'a' + 10;
2208 if (chr >= 'A' && chr <= 'F')
2209 return chr - 'A' + 10;
2210
2211 return -1;
2212 }
2213 //----------------------------------------------------------------------------
2214
2215 //============================================================================
2216 /// @brief Checks a character is ascii alphabetic lowercase.
2217 ///
2218 /// @param[in] chr Single character to test
2219 /// @return True if ascii uppercase letter, false otherwise
2220 ///
2221 inline static bool IsAsciiUppercaseLetter(char chr) // locale independent
2222 {
2223 return (chr >= 'A' && chr <= 'Z');
2224 }
2225 //----------------------------------------------------------------------------
2226
2227 //============================================================================
2228 /// @brief Checks a character is ascii alphabetic lowercase.
2229 ///
2230 /// @param[in] chr Single character to test
2231 /// @return True if ascii lowercase letter, false otherwise
2232 ///
2233 inline static bool IsAsciiLowercaseLetter(char chr) // locale independent
2234 {
2235 return (chr >= 'a' && chr <= 'z');
2236 }
2237 //----------------------------------------------------------------------------
2238
2239 //============================================================================
2240 /// @brief Checks a character is within ascii alphabetic and numerical fields.
2241 ///
2242 /// @param[in] chr Single character to test
2243 /// @return true if alphabetic / numerical ascii value
2244 ///
2245 inline static bool IsAsciiAlphaNum(char chr) // locale independent
2246 {
2247 return IsAsciiUppercaseLetter(chr) || IsAsciiLowercaseLetter(chr) || IsAasciiDigit(chr);
2248 }
2249 //----------------------------------------------------------------------------
2250
2251 //============================================================================
2252 /// @brief Check a string for another text.
2253 ///
2254 /// @param[in] str String to seach for keywords
2255 /// @param[in] keywords List of keywords to search in text
2256 /// @return true if string contains word in list
2257 ///
2258 inline static bool ContainsKeyword(const std::string& str,
2259 const std::vector<std::string>& keywords)
2260 {
2261 for (const auto& it : keywords)
2262 {
2263 if (str.find(it) != str.npos)
2264 return true;
2265 }
2266 return false;
2267 }
2268 //----------------------------------------------------------------------------
2269
2270 /*!@}*/
2271
2272 //----------------------------------------------------------------------------
2273 /// @defgroup cpp_kodi_tools_StringUtils_SearchControl String search
2274 /// @ingroup cpp_kodi_tools_StringUtils
2275 /// @brief **To search a string**\n
2276 /// Various functions are defined in here which allow you to search through a
2277 /// text in different ways.
2278 ///
2279 /*!@{*/
2280
2281 //============================================================================
2282 /// @brief Search for a single word within a text.
2283 ///
2284 /// @param[in] str String to search within
2285 /// @param[in] wordLowerCase Word as lowercase to search
2286 /// @return Position in string where word is found, -1 (std::string::npos) if
2287 /// not found
2288 ///
2289 ///
2290 /// --------------------------------------------------------------------------
2291 /// Example:
2292 /// ~~~~~~~~~~~~~{.cpp}
2293 /// #include <kodi/tools/StringUtils.h>
2294 ///
2295 /// size_t ref, var;
2296 ///
2297 /// // The name "string" is alone within text and becomes found on position 5
2298 /// ref = 5;
2299 /// var = kodi::tools::StringUtils::FindWords("test string", "string");
2300 /// EXPECT_EQ(ref, var);
2301 ///
2302 /// // The 12 is included inside another word and then not found as it should alone (-1 return)
2303 /// ref = -1;
2304 /// var = kodi::tools::StringUtils::FindWords("apple2012", "12");
2305 /// EXPECT_EQ(ref, var);
2306 /// ~~~~~~~~~~~~~
2307 ///
2308 inline static size_t FindWords(const char* str, const char* wordLowerCase)
2309 {
2310 // NOTE: This assumes word is lowercase!
2311 const unsigned char* s = (const unsigned char*)str;
2312 do
2313 {
2314 // start with a compare
2315 const unsigned char* c = s;
2316 const unsigned char* w = (const unsigned char*)wordLowerCase;
2317 bool same = true;
2318 while (same && *c && *w)
2319 {
2320 unsigned char lc = *c++;
2321 if (lc >= 'A' && lc <= 'Z')
2322 lc += 'a' - 'A';
2323
2324 if (lc != *w++) // different
2325 same = false;
2326 }
2327 if (same && *w == 0) // only the same if word has been exhausted
2328 return (const char*)s - str;
2329
2330 // otherwise, skip current word (composed by latin letters) or number
2331 int l;
2332 if (*s >= '0' && *s <= '9')
2333 {
2334 ++s;
2335 while (*s >= '0' && *s <= '9')
2336 ++s;
2337 }
2338 else if ((l = IsUTF8Letter(s)) > 0)
2339 {
2340 s += l;
2341 while ((l = IsUTF8Letter(s)) > 0)
2342 s += l;
2343 }
2344 else
2345 ++s;
2346 while (*s && *s == ' ')
2347 s++;
2348
2349 // and repeat until we're done
2350 } while (*s);
2351
2352 return std::string::npos;
2353 }
2354 //----------------------------------------------------------------------------
2355
2356 //============================================================================
2357 /// @brief Search a string for a given bracket and give its end position.
2358 ///
2359 /// @param[in] str String to search within
2360 /// @param[in] opener Begin character to start search
2361 /// @param[in] closer End character to end search
2362 /// @param[in] startPos [opt] Position to start search in string, 0 as default
2363 /// to start from begin
2364 /// @return End position where found, -1 if failed
2365 ///
2366 ///
2367 /// --------------------------------------------------------------------------
2368 /// Example:
2369 /// ~~~~~~~~~~~~~{.cpp}
2370 /// #include <kodi/tools/StringUtils.h>
2371 ///
2372 /// int ref, var;
2373 ///
2374 /// ref = 11;
2375 /// var = kodi::tools::StringUtils::FindEndBracket("atest testbb test", 'a', 'b');
2376 /// EXPECT_EQ(ref, var);
2377 /// ~~~~~~~~~~~~~
2378 ///
2379 inline static size_t FindEndBracket(const std::string& str,
2380 char opener,
2381 char closer,
2382 size_t startPos = 0)
2383 {
2384 size_t blocks = 1;
2385 for (size_t i = startPos; i < str.size(); i++)
2386 {
2387 if (str[i] == opener)
2388 blocks++;
2389 else if (str[i] == closer)
2390 {
2391 blocks--;
2392 if (!blocks)
2393 return i;
2394 }
2395 }
2396
2397 return std::string::npos;
2398 }
2399 //----------------------------------------------------------------------------
2400
2401 //============================================================================
2402 /// @brief Search a text and return the number of parts found as a number.
2403 ///
2404 /// @param[in] strInput Input string to search for
2405 /// @param[in] strFind String to search in input
2406 /// @return Amount how much the string is found
2407 ///
2408 ///
2409 /// --------------------------------------------------------------------------
2410 /// Example:
2411 /// ~~~~~~~~~~~~~{.cpp}
2412 /// #include <kodi/tools/StringUtils.h>
2413 ///
2414 /// EXPECT_EQ(3, kodi::tools::StringUtils::FindNumber("aabcaadeaa", "aa"));
2415 /// EXPECT_EQ(1, kodi::tools::StringUtils::FindNumber("aabcaadeaa", "b"));
2416 /// ~~~~~~~~~~~~~
2417 ///
2418 inline static int FindNumber(const std::string& strInput, const std::string& strFind)
2419 {
2420 size_t pos = strInput.find(strFind, 0);
2421 int numfound = 0;
2422 while (pos != std::string::npos)
2423 {
2424 numfound++;
2425 pos = strInput.find(strFind, pos + 1);
2426 }
2427 return numfound;
2428 }
2429 //----------------------------------------------------------------------------
2430
2431 /*!@}*/
2432
2433 //----------------------------------------------------------------------------
2434 /// @defgroup cpp_kodi_tools_StringUtils_ListControl String list
2435 /// @ingroup cpp_kodi_tools_StringUtils
2436 /// @brief **Creating lists using a string**\n
2437 /// With this, either simple vectors or lists defined by templates can be given
2438 /// for the respective divided text.
2439 ///
2440 /*!@{*/
2441
2442 //============================================================================
2443 /// @brief Concatenates the elements of a specified array or the members of a
2444 /// collection and uses the specified separator between each element or
2445 /// member.
2446 ///
2447 /// @param[in] strings An array of objects whose string representations are
2448 /// concatenated.
2449 /// @param[in] delimiter Delimiter to be used to join the input string
2450 /// @return A string consisting of the elements of values, separated by the
2451 /// separator character.
2452 ///
2453 ///
2454 /// --------------------------------------------------------------------------
2455 /// Example:
2456 /// ~~~~~~~~~~~~~{.cpp}
2457 /// #include <kodi/tools/StringUtils.h>
2458 ///
2459 /// std::string refstr, varstr;
2460 /// std::vector<std::string> strarray;
2461 ///
2462 /// strarray.emplace_back("a");
2463 /// strarray.emplace_back("b");
2464 /// strarray.emplace_back("c");
2465 /// strarray.emplace_back("de");
2466 /// strarray.emplace_back(",");
2467 /// strarray.emplace_back("fg");
2468 /// strarray.emplace_back(",");
2469 /// refstr = "a,b,c,de,,,fg,,";
2470 /// varstr = kodi::tools::StringUtils::Join(strarray, ",");
2471 /// EXPECT_STREQ(refstr.c_str(), varstr.c_str());
2472 /// ~~~~~~~~~~~~~
2473 ///
2474 template<typename CONTAINER>
2475 inline static std::string Join(const CONTAINER& strings, const std::string& delimiter)
2476 {
2477 std::string result;
2478 for (const auto& str : strings)
2479 result += str + delimiter;
2480
2481 if (!result.empty())
2482 result.erase(result.size() - delimiter.size());
2483 return result;
2484 }
2485 //----------------------------------------------------------------------------
2486
2487 //============================================================================
2488 /// @brief Splits the given input string using the given delimiter into
2489 /// separate strings.
2490 ///
2491 /// If the given input string is empty the result will be an empty array (not
2492 /// an array containing an empty string).
2493 ///
2494 /// @param[in] input Input string to be split
2495 /// @param[in] delimiter Delimiter to be used to split the input string
2496 /// @param[in] iMaxStrings [opt] Maximum number of resulting split strings
2497 /// @return List of splitted strings
2498 ///
2499 ///
2500 /// --------------------------------------------------------------------------
2501 /// Example:
2502 /// ~~~~~~~~~~~~~{.cpp}
2503 /// #include <kodi/tools/StringUtils.h>
2504 ///
2505 /// std::vector<std::string> varresults;
2506 ///
2507 /// varresults = kodi::tools::StringUtils::Split("g,h,ij,k,lm,,n", ",");
2508 /// EXPECT_STREQ("g", varresults.at(0).c_str());
2509 /// EXPECT_STREQ("h", varresults.at(1).c_str());
2510 /// EXPECT_STREQ("ij", varresults.at(2).c_str());
2511 /// EXPECT_STREQ("k", varresults.at(3).c_str());
2512 /// EXPECT_STREQ("lm", varresults.at(4).c_str());
2513 /// EXPECT_STREQ("", varresults.at(5).c_str());
2514 /// EXPECT_STREQ("n", varresults.at(6).c_str());
2515 /// ~~~~~~~~~~~~~
2516 ///
2517 inline static std::vector<std::string> Split(const std::string& input,
2518 const std::string& delimiter,
2519 unsigned int iMaxStrings = 0)
2520 {
2521 std::vector<std::string> result;
2522 SplitTo(std::back_inserter(result), input, delimiter, iMaxStrings);
2523 return result;
2524 }
2525 //----------------------------------------------------------------------------
2526
2527 //============================================================================
2528 /// @brief Splits the given input string using the given delimiter into
2529 /// separate strings.
2530 ///
2531 /// If the given input string is empty the result will be an empty array (not
2532 /// an array containing an empty string).
2533 ///
2534 /// @param[in] input Input string to be split
2535 /// @param[in] delimiter Delimiter to be used to split the input string
2536 /// @param[in] iMaxStrings [opt] Maximum number of resulting split strings
2537 /// @return List of splitted strings
2538 ///
2539 inline static std::vector<std::string> Split(const std::string& input,
2540 const char delimiter,
2541 int iMaxStrings = 0)
2542 {
2543 std::vector<std::string> result;
2544 SplitTo(std::back_inserter(result), input, delimiter, iMaxStrings);
2545 return result;
2546 }
2547 //----------------------------------------------------------------------------
2548
2549 //============================================================================
2550 /// @brief Splits the given input string using the given delimiter into
2551 /// separate strings.
2552 ///
2553 /// If the given input string is empty the result will be an empty array (not
2554 /// an array containing an empty string).
2555 ///
2556 /// @param[in] input Input string to be split
2557 /// @param[in] delimiters Delimiter strings to be used to split the input
2558 /// strings
2559 /// @return List of splitted strings
2560 ///
2561 inline static std::vector<std::string> Split(const std::string& input,
2562 const std::vector<std::string>& delimiters)
2563 {
2564 std::vector<std::string> result;
2565 SplitTo(std::back_inserter(result), input, delimiters);
2566 return result;
2567 }
2568 //----------------------------------------------------------------------------
2569
2570 //============================================================================
2571 /// @brief Splits the given input string using the given delimiter into
2572 /// separate strings.
2573 ///
2574 /// If the given input string is empty nothing will be put into the target
2575 /// iterator.
2576 ///
2577 /// @param[in] d_first The beginning of the destination range
2578 /// @param[in] input Input string to be split
2579 /// @param[in] delimiter Delimiter to be used to split the input string
2580 /// @param[in] iMaxStrings [opt] Maximum number of resulting split strings
2581 /// @return Output iterator to the element in the destination range, one past
2582 /// the last element that was put there
2583 ///
2584 template<typename OutputIt>
2585 inline static OutputIt SplitTo(OutputIt d_first,
2586 const std::string& input,
2587 const std::string& delimiter,
2588 unsigned int iMaxStrings = 0)
2589 {
2590 OutputIt dest = d_first;
2591
2592 if (input.empty())
2593 return dest;
2594 if (delimiter.empty())
2595 {
2596 *d_first++ = input;
2597 return dest;
2598 }
2599
2600 const size_t delimLen = delimiter.length();
2601 size_t nextDelim;
2602 size_t textPos = 0;
2603 do
2604 {
2605 if (--iMaxStrings == 0)
2606 {
2607 *dest++ = input.substr(textPos);
2608 break;
2609 }
2610 nextDelim = input.find(delimiter, textPos);
2611 *dest++ = input.substr(textPos, nextDelim - textPos);
2612 textPos = nextDelim + delimLen;
2613 } while (nextDelim != std::string::npos);
2614
2615 return dest;
2616 }
2617 //----------------------------------------------------------------------------
2618
2619 //============================================================================
2620 /// @brief Splits the given input string using the given delimiter into
2621 /// separate strings.
2622 ///
2623 /// If the given input string is empty nothing will be put into the target
2624 /// iterator.
2625 ///
2626 /// @param[in] d_first The beginning of the destination range
2627 /// @param[in] input Input string to be split
2628 /// @param[in] delimiter Delimiter to be used to split the input string
2629 /// @param[in] iMaxStrings [opt] Maximum number of resulting split strings
2630 /// @return Output iterator to the element in the destination range, one past
2631 /// the last element that was put there
2632 ///
2633 template<typename OutputIt>
2634 inline static OutputIt SplitTo(OutputIt d_first,
2635 const std::string& input,
2636 const char delimiter,
2637 int iMaxStrings = 0)
2638 {
2639 return SplitTo(d_first, input, std::string(1, delimiter), iMaxStrings);
2640 }
2641 //----------------------------------------------------------------------------
2642
2643 //============================================================================
2644 /// @brief Splits the given input string using the given delimiter into
2645 /// separate strings.
2646 ///
2647 /// If the given input string is empty nothing will be put into the target
2648 /// iterator.
2649 ///
2650 /// @param[in] d_first The beginning of the destination range
2651 /// @param[in] input Input string to be split
2652 /// @param[in] delimiters Delimiter strings to be used to split the input
2653 /// strings
2654 /// @return Output iterator to the element in the destination range, one past
2655 /// the last element that was put there
2656 ///
2657 template<typename OutputIt>
2658 inline static OutputIt SplitTo(OutputIt d_first,
2659 const std::string& input,
2660 const std::vector<std::string>& delimiters)
2661 {
2662 OutputIt dest = d_first;
2663 if (input.empty())
2664 return dest;
2665
2666 if (delimiters.empty())
2667 {
2668 *dest++ = input;
2669 return dest;
2670 }
2671 std::string str = input;
2672 for (size_t di = 1; di < delimiters.size(); di++)
2673 StringUtils::Replace(str, delimiters[di], delimiters[0]);
2674 return SplitTo(dest, str, delimiters[0]);
2675 }
2676 //----------------------------------------------------------------------------
2677
2678 //============================================================================
2679 /// @brief Splits the given input strings using the given delimiters into
2680 /// further separate strings.
2681 ///
2682 /// If the given input string vector is empty the result will be an empty
2683 /// array (not an array containing an empty string).
2684 ///
2685 /// Delimiter strings are applied in order, so once the (optional) maximum
2686 /// number of items is produced no other delimiters are applied. This produces
2687 /// different results to applying all delimiters at once e.g. "a/b#c/d"
2688 /// becomes "a", "b#c", "d" rather than "a", "b", "c/d"
2689 ///
2690 /// @param[in] input Input vector of strings each to be split
2691 /// @param[in] delimiters Delimiter strings to be used to split the input
2692 /// strings
2693 /// @param[in] iMaxStrings [opt] Maximum number of resulting split strings
2694 /// @return List of splitted strings
2695 ///
2696 inline static std::vector<std::string> SplitMulti(const std::vector<std::string>& input,
2697 const std::vector<std::string>& delimiters,
2698 unsigned int iMaxStrings = 0)
2699 {
2700 if (input.empty())
2701 return std::vector<std::string>();
2702
2703 std::vector<std::string> results(input);
2704
2705 if (delimiters.empty() || (iMaxStrings > 0 && iMaxStrings <= input.size()))
2706 return results;
2707
2708 std::vector<std::string> strings1;
2709 if (iMaxStrings == 0)
2710 {
2711 for (size_t di = 0; di < delimiters.size(); di++)
2712 {
2713 for (size_t i = 0; i < results.size(); i++)
2714 {
2715 std::vector<std::string> substrings = StringUtils::Split(results[i], delimiters[di]);
2716 for (size_t j = 0; j < substrings.size(); j++)
2717 strings1.push_back(substrings[j]);
2718 }
2719 results = strings1;
2720 strings1.clear();
2721 }
2722 return results;
2723 }
2724
2725 // Control the number of strings input is split into, keeping the original strings.
2726 // Note iMaxStrings > input.size()
2727 size_t iNew = iMaxStrings - results.size();
2728 for (size_t di = 0; di < delimiters.size(); di++)
2729 {
2730 for (size_t i = 0; i < results.size(); i++)
2731 {
2732 if (iNew > 0)
2733 {
2734 std::vector<std::string> substrings =
2735 StringUtils::Split(results[i], delimiters[di], static_cast<int>(iNew + 1));
2736 iNew = iNew - substrings.size() + 1;
2737 for (size_t j = 0; j < substrings.size(); j++)
2738 strings1.push_back(substrings[j]);
2739 }
2740 else
2741 strings1.push_back(results[i]);
2742 }
2743 results = strings1;
2744 iNew = iMaxStrings - results.size();
2745 strings1.clear();
2746 if ((iNew <= 0))
2747 break; //Stop trying any more delimiters
2748 }
2749 return results;
2750 }
2751 //----------------------------------------------------------------------------
2752
2753 //============================================================================
2754 /// @brief Split a string by the specified delimiters.
2755 ///
2756 /// Splits a string using one or more delimiting characters, ignoring empty
2757 /// tokens.
2758 ///
2759 /// Differs from Split() in two ways:
2760 /// 1. The delimiters are treated as individual characters, rather than a single delimiting string.
2761 /// 2. Empty tokens are ignored.
2762 ///
2763 ///
2764 /// @param[in] input String to split
2765 /// @param[in] delimiters Delimiters
2766 /// @return A vector of tokens
2767 ///
2768 inline static std::vector<std::string> Tokenize(const std::string& input,
2769 const std::string& delimiters)
2770 {
2771 std::vector<std::string> tokens;
2772 Tokenize(input, tokens, delimiters);
2773 return tokens;
2774 }
2775 //----------------------------------------------------------------------------
2776
2777 //============================================================================
2778 /// @brief Tokenizing a string denotes splitting a string with respect to a
2779 /// delimiter.
2780 ///
2781 /// @param[in] input String to split
2782 /// @param[out] tokens A vector of tokens
2783 /// @param[in] delimiters Delimiters
2784 ///
2785 inline static void Tokenize(const std::string& input,
2786 std::vector<std::string>& tokens,
2787 const std::string& delimiters)
2788 {
2789 tokens.clear();
2790 // Skip delimiters at beginning.
2791 std::string::size_type dataPos = input.find_first_not_of(delimiters);
2792 while (dataPos != std::string::npos)
2793 {
2794 // Find next delimiter
2795 const std::string::size_type nextDelimPos = input.find_first_of(delimiters, dataPos);
2796 // Found a token, add it to the vector.
2797 tokens.push_back(input.substr(dataPos, nextDelimPos - dataPos));
2798 // Skip delimiters. Note the "not_of"
2799 dataPos = input.find_first_not_of(delimiters, nextDelimPos);
2800 }
2801 }
2802 //----------------------------------------------------------------------------
2803
2804 //============================================================================
2805 /// @brief Tokenizing a string denotes splitting a string with respect to a
2806 /// delimiter.
2807 ///
2808 /// @param[in] input String to split
2809 /// @param[in] delimiter Delimiters
2810 /// @return A vector of tokens
2811 ///
2812 inline static std::vector<std::string> Tokenize(const std::string& input, const char delimiter)
2813 {
2814 std::vector<std::string> tokens;
2815 Tokenize(input, tokens, delimiter);
2816 return tokens;
2817 }
2818 //----------------------------------------------------------------------------
2819
2820 //============================================================================
2821 /// @brief Tokenizing a string denotes splitting a string with respect to a
2822 /// delimiter.
2823 ///
2824 /// @param[in] input String to split
2825 /// @param[out] tokens List of
2826 /// @param[in] delimiter Delimiters
2827 ///
2828 inline static void Tokenize(const std::string& input,
2829 std::vector<std::string>& tokens,
2830 const char delimiter)
2831 {
2832 tokens.clear();
2833 // Skip delimiters at beginning.
2834 std::string::size_type dataPos = input.find_first_not_of(delimiter);
2835 while (dataPos != std::string::npos)
2836 {
2837 // Find next delimiter
2838 const std::string::size_type nextDelimPos = input.find(delimiter, dataPos);
2839 // Found a token, add it to the vector.
2840 tokens.push_back(input.substr(dataPos, nextDelimPos - dataPos));
2841 // Skip delimiters. Note the "not_of"
2842 dataPos = input.find_first_not_of(delimiter, nextDelimPos);
2843 }
2844 }
2845 //----------------------------------------------------------------------------
2846
2847 /*!@}*/
2848
2849 //----------------------------------------------------------------------------
2850 /// @defgroup cpp_kodi_tools_StringUtils_TimeControl Time value processing
2851 /// @ingroup cpp_kodi_tools_StringUtils
2852 /// @brief **String time formats**\n
2853 /// This is used to process the respective time formats in text fields.
2854 /*!@{*/
2855
2856 //============================================================================
2857 /// @brief Converts a time string to the respective integer value.
2858 ///
2859 /// @param[in] timeString String with time.\n
2860 /// Following types are possible:
2861 /// - "MM min" (integer number with "min" on end)
2862 /// - "HH:MM:SS"
2863 /// @return Time in seconds
2864 ///
2865 ///
2866 /// --------------------------------------------------------------------------
2867 /// Example:
2868 /// ~~~~~~~~~~~~~{.cpp}
2869 /// #include <kodi/tools/StringUtils.h>
2870 ///
2871 /// EXPECT_EQ(77455, kodi::tools::StringUtils::TimeStringToSeconds("21:30:55"));
2872 /// EXPECT_EQ(7*60, kodi::tools::StringUtils::TimeStringToSeconds("7 min"));
2873 /// EXPECT_EQ(7*60, kodi::tools::StringUtils::TimeStringToSeconds("7 min\t"));
2874 /// EXPECT_EQ(154*60, kodi::tools::StringUtils::TimeStringToSeconds(" 154 min"));
2875 /// EXPECT_EQ(1*60+1, kodi::tools::StringUtils::TimeStringToSeconds("1:01"));
2876 /// EXPECT_EQ(4*60+3, kodi::tools::StringUtils::TimeStringToSeconds("4:03"));
2877 /// EXPECT_EQ(2*3600+4*60+3, kodi::tools::StringUtils::TimeStringToSeconds("2:04:03"));
2878 /// EXPECT_EQ(2*3600+4*60+3, kodi::tools::StringUtils::TimeStringToSeconds(" 2:4:3"));
2879 /// EXPECT_EQ(2*3600+4*60+3, kodi::tools::StringUtils::TimeStringToSeconds(" \t\t 02:04:03 \n "));
2880 /// EXPECT_EQ(1*3600+5*60+2, kodi::tools::StringUtils::TimeStringToSeconds("01:05:02:04:03 \n "));
2881 /// EXPECT_EQ(0, kodi::tools::StringUtils::TimeStringToSeconds("blah"));
2882 /// EXPECT_EQ(0, kodi::tools::StringUtils::TimeStringToSeconds("ля-ля"));
2883 /// ~~~~~~~~~~~~~
2884 ///
2885 inline static long TimeStringToSeconds(const std::string& timeString)
2886 {
2887 std::string strCopy(timeString);
2888 StringUtils::Trim(strCopy);
2889 if (StringUtils::EndsWithNoCase(strCopy, " min"))
2890 {
2891 // this is imdb format of "XXX min"
2892 return 60 * atoi(strCopy.c_str());
2893 }
2894 else
2895 {
2896 std::vector<std::string> secs = StringUtils::Split(strCopy, ':');
2897 int timeInSecs = 0;
2898 for (unsigned int i = 0; i < 3 && i < secs.size(); i++)
2899 {
2900 timeInSecs *= 60;
2901 timeInSecs += atoi(secs[i].c_str());
2902 }
2903 return timeInSecs;
2904 }
2905 }
2906 //----------------------------------------------------------------------------
2907
2908 //============================================================================
2909 /// @brief Convert a time in seconds to a string based on the given time
2910 /// format.
2911 ///
2912 /// @param[in] seconds time in seconds
2913 /// @param[in] format [opt] The format we want the time in
2914 /// @return The formatted time
2915 ///
2916 /// @sa TIME_FORMAT
2917 ///
2918 ///
2919 /// --------------------------------------------------------------------------
2920 /// Example:
2921 /// ~~~~~~~~~~~~~{.cpp}
2922 /// #include <kodi/tools/StringUtils.h>
2923 ///
2924 /// std::string ref, var;
2925 ///
2926 /// ref = "21:30:55";
2927 /// var = kodi::tools::StringUtils::SecondsToTimeString(77455);
2928 /// EXPECT_STREQ(ref.c_str(), var.c_str());
2929 /// ~~~~~~~~~~~~~
2930 ///
2931 inline static std::string SecondsToTimeString(long seconds,
2932 TIME_FORMAT format = TIME_FORMAT_GUESS)
2933 {
2934 bool isNegative = seconds < 0;
2935 seconds = std::abs(seconds);
2936
2937 std::string strHMS;
2938 if (format == TIME_FORMAT_SECS)
2939 strHMS = StringUtils::Format("%i", seconds);
2940 else if (format == TIME_FORMAT_MINS)
2941 strHMS = StringUtils::Format("%i", lrintf(static_cast<float>(seconds) / 60.0f));
2942 else if (format == TIME_FORMAT_HOURS)
2943 strHMS = StringUtils::Format("%i", lrintf(static_cast<float>(seconds) / 3600.0f));
2944 else if (format & TIME_FORMAT_M)
2945 strHMS += StringUtils::Format("%i", seconds % 3600 / 60);
2946 else
2947 {
2948 int hh = seconds / 3600;
2949 seconds = seconds % 3600;
2950 int mm = seconds / 60;
2951 int ss = seconds % 60;
2952
2953 if (format == TIME_FORMAT_GUESS)
2954 format = (hh >= 1) ? TIME_FORMAT_HH_MM_SS : TIME_FORMAT_MM_SS;
2955 if (format & TIME_FORMAT_HH)
2956 strHMS += StringUtils::Format("%2.2i", hh);
2957 else if (format & TIME_FORMAT_H)
2958 strHMS += StringUtils::Format("%i", hh);
2959 if (format & TIME_FORMAT_MM)
2960 strHMS += StringUtils::Format(strHMS.empty() ? "%2.2i" : ":%2.2i", mm);
2961 if (format & TIME_FORMAT_SS)
2962 strHMS += StringUtils::Format(strHMS.empty() ? "%2.2i" : ":%2.2i", ss);
2963 }
2964
2965 if (isNegative)
2966 strHMS = "-" + strHMS;
2967
2968 return strHMS;
2969 }
2970 //----------------------------------------------------------------------------
2971
2972 //============================================================================
2973 /// @brief Converts a string in the format YYYYMMDD to the corresponding
2974 /// integer value.
2975 ///
2976 /// @param[in] dateString The date in the associated format, possible values
2977 /// are:
2978 /// - DD (for days only)
2979 /// - MM-DD (for days with month)
2980 /// - YYYY-MM-DD (for years, then month and last days)
2981 /// @return Corresponding integer, e.g. "2020-12-24" return as integer value
2982 /// 20201224
2983 ///
2984 ///
2985 /// --------------------------------------------------------------------------
2986 /// Example:
2987 /// ~~~~~~~~~~~~~{.cpp}
2988 /// #include <kodi/tools/StringUtils.h>
2989 ///
2990 /// int ref, var;
2991 ///
2992 /// ref = 20120706;
2993 /// var = kodi::tools::StringUtils::DateStringToYYYYMMDD("2012-07-06");
2994 /// EXPECT_EQ(ref, var);
2995 /// ~~~~~~~~~~~~~
2996 ///
2997 inline static int DateStringToYYYYMMDD(const std::string& dateString)
2998 {
2999 std::vector<std::string> days = StringUtils::Split(dateString, '-');
3000 if (days.size() == 1)
3001 return atoi(days[0].c_str());
3002 else if (days.size() == 2)
3003 return atoi(days[0].c_str()) * 100 + atoi(days[1].c_str());
3004 else if (days.size() == 3)
3005 return atoi(days[0].c_str()) * 10000 + atoi(days[1].c_str()) * 100 + atoi(days[2].c_str());
3006 else
3007 return -1;
3008 }
3009 //----------------------------------------------------------------------------
3010
3011 /*!@}*/
3012
3013private:
3014 inline static int compareWchar(const void* a, const void* b)
3015 {
3016 if (*static_cast<const wchar_t*>(a) < *static_cast<const wchar_t*>(b))
3017 return -1;
3018 else if (*static_cast<const wchar_t*>(a) > *static_cast<const wchar_t*>(b))
3019 return 1;
3020 return 0;
3021 }
3022
3023 inline static wchar_t tolowerUnicode(const wchar_t& c)
3024 {
3025 wchar_t* p =
3026 static_cast<wchar_t*>(bsearch(&c, unicode_uppers, sizeof(unicode_uppers) / sizeof(wchar_t),
3027 sizeof(wchar_t), compareWchar));
3028 if (p)
3029 return *(unicode_lowers + (p - unicode_uppers));
3030
3031 return c;
3032 }
3033
3034 inline static wchar_t toupperUnicode(const wchar_t& c)
3035 {
3036 wchar_t* p =
3037 static_cast<wchar_t*>(bsearch(&c, unicode_lowers, sizeof(unicode_lowers) / sizeof(wchar_t),
3038 sizeof(wchar_t), compareWchar));
3039 if (p)
3040 return *(unicode_uppers + (p - unicode_lowers));
3041
3042 return c;
3043 }
3044
3045 static uint32_t UTF8ToUnicode(const unsigned char* z, int nKey, unsigned char& bytes)
3046 {
3047 // Lookup table used decode the first byte of a multi-byte UTF8 character
3048 // clang-format off
3049 static const unsigned char utf8Trans1[] = {
3050 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
3051 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f,
3052 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17,
3053 0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f,
3054 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
3055 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f,
3056 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
3057 0x00, 0x01, 0x02, 0x03, 0x00, 0x01, 0x00, 0x00,
3058 };
3059 // clang-format on
3060
3061 uint32_t c;
3062 bytes = 0;
3063 c = z[0];
3064 if (c >= 0xc0)
3065 {
3066 c = utf8Trans1[c - 0xc0];
3067 int index = 1;
3068 while (index < nKey && (z[index] & 0xc0) == 0x80)
3069 {
3070 c = (c << 6) + (0x3f & z[index]);
3071 index++;
3072 }
3073 if (c < 0x80 || (c & 0xFFFFF800) == 0xD800 || (c & 0xFFFFFFFE) == 0xFFFE)
3074 c = 0xFFFD;
3075 bytes = static_cast<unsigned char>(index - 1);
3076 }
3077 return c;
3078 }
3079};
3080///@}
3081//------------------------------------------------------------------------------
3082
3083} /* namespace tools */
3084} /* namespace kodi */
3085
3086#endif /* __cplusplus */
diff --git a/xbmc/addons/kodi-dev-kit/include/kodi/tools/Thread.h b/xbmc/addons/kodi-dev-kit/include/kodi/tools/Thread.h
new file mode 100644
index 0000000..4cae13e
--- /dev/null
+++ b/xbmc/addons/kodi-dev-kit/include/kodi/tools/Thread.h
@@ -0,0 +1,399 @@
1/*
2 * Copyright (C) 2005-2020 Team Kodi
3 * This file is part of Kodi - https://kodi.tv
4 *
5 * SPDX-License-Identifier: GPL-2.0-or-later
6 * See LICENSES/README.md for more information.
7 */
8
9#pragma once
10
11#ifdef __cplusplus
12
13#include "../General.h"
14
15#include <chrono>
16#include <condition_variable>
17#include <future>
18#include <mutex>
19#include <thread>
20
21namespace kodi
22{
23namespace tools
24{
25
26//==============================================================================
27/// @defgroup cpp_kodi_tools_CThread class CThread
28/// @ingroup cpp_kodi_tools
29/// @brief **Helper class to represent threads of execution**\n
30/// An execution thread is a sequence of instructions that can run concurrently
31/// with other such sequences in multithreaded environments while sharing the
32/// same address space.
33///
34/// Is intended to reduce any code work of C++ on addons and to have them faster
35/// to use.
36///
37/// His code uses the support of platform-independent thread system introduced
38/// with C++11.
39///
40/// ----------------------------------------------------------------------------
41///
42/// **Example:**
43/// ~~~~~~~~~~~~~{.cpp}
44/// #include <kodi/tools/Thread.h>
45/// #include <kodi/AddonBase.h>
46///
47/// class ATTRIBUTE_HIDDEN CTestAddon
48/// : public kodi::addon::CAddonBase,
49/// public kodi::tools::CThread
50/// {
51/// public:
52/// CTestAddon() = default;
53///
54/// ADDON_STATUS Create() override;
55///
56/// void Process() override;
57/// };
58///
59/// ADDON_STATUS CTestAddon::Create()
60/// {
61/// kodi::Log(ADDON_LOG_INFO, "Starting thread");
62/// CreateThread();
63///
64/// Sleep(4000);
65///
66/// kodi::Log(ADDON_LOG_INFO, "Stopping thread");
67/// // This added as example and also becomes stopped by class destructor
68/// StopThread();
69///
70/// return ADDON_STATUS_OK;
71/// }
72///
73/// void CTestAddon::Process()
74/// {
75/// kodi::Log(ADDON_LOG_INFO, "Thread started");
76///
77/// while (!m_threadStop)
78/// {
79/// kodi::Log(ADDON_LOG_INFO, "Hello World");
80/// Sleep(1000);
81/// }
82///
83/// kodi::Log(ADDON_LOG_INFO, "Thread ended");
84/// }
85///
86/// ADDONCREATOR(CTestAddon)
87/// ~~~~~~~~~~~~~
88///
89///@{
90class CThread
91{
92public:
93 //============================================================================
94 /// @ingroup cpp_kodi_tools_CThread
95 /// @brief Class constructor.
96 ///
97 CThread() : m_threadStop(false) {}
98 //----------------------------------------------------------------------------
99
100 //============================================================================
101 /// @ingroup cpp_kodi_tools_CThread
102 /// @brief Class destructor.
103 ///
104 virtual ~CThread()
105 {
106 StopThread();
107 if (m_thread != nullptr)
108 {
109 m_thread->detach();
110 delete m_thread;
111 }
112 }
113 //----------------------------------------------------------------------------
114
115 //============================================================================
116 /// @ingroup cpp_kodi_tools_CThread
117 /// @brief Check auto delete is enabled on this thread class.
118 ///
119 /// @return true if auto delete is used, false otherwise
120 ///
121 bool IsAutoDelete() const { return m_autoDelete; }
122 //----------------------------------------------------------------------------
123
124 //============================================================================
125 /// @ingroup cpp_kodi_tools_CThread
126 /// @brief Check caller is on this running thread.
127 ///
128 /// @return true if called from thread inside the class, false if from another
129 /// thread
130 ///
131 bool IsCurrentThread() const { return m_threadId == std::this_thread::get_id(); }
132 //----------------------------------------------------------------------------
133
134 //============================================================================
135 /// @ingroup cpp_kodi_tools_CThread
136 /// @brief Check thread inside this class is running and active.
137 ///
138 /// @note This function should be used from outside and not within process to
139 /// check thread is active. Use use atomic bool @ref m_threadStop for this.
140 ///
141 /// @return true if running, false if not
142 ///
143 bool IsRunning() const
144 {
145 if (m_thread != nullptr)
146 {
147 // it's possible that the thread exited on it's own without a call to StopThread. If so then
148 // the promise should be fulfilled.
149 std::future_status stat = m_future.wait_for(std::chrono::milliseconds(0));
150 // a status of 'ready' means the future contains the value so the thread has exited
151 // since the thread can't exit without setting the future.
152 if (stat == std::future_status::ready) // this is an indication the thread has exited.
153 return false;
154 return true; // otherwise the thread is still active.
155 }
156 else
157 return false;
158 }
159 //----------------------------------------------------------------------------
160
161 //============================================================================
162 /// @ingroup cpp_kodi_tools_CThread
163 /// @brief Create a new thread defined by this class on child.
164 ///
165 /// This starts then @ref Process() where is available on the child by addon.
166 ///
167 /// @param[in] autoDelete To set thread to delete itself after end, default is
168 /// false
169 ///
170 void CreateThread(bool autoDelete = false)
171 {
172 if (m_thread != nullptr)
173 {
174 // if the thread exited on it's own, without a call to StopThread, then we can get here
175 // incorrectly. We should be able to determine this by checking the promise.
176 std::future_status stat = m_future.wait_for(std::chrono::milliseconds(0));
177 // a status of 'ready' means the future contains the value so the thread has exited
178 // since the thread can't exit without setting the future.
179 if (stat == std::future_status::ready) // this is an indication the thread has exited.
180 StopThread(true); // so let's just clean up
181 else
182 { // otherwise we have a problem.
183 kodi::Log(ADDON_LOG_FATAL, "%s - fatal error creating thread - old thread id not null",
184 __func__);
185 exit(1);
186 }
187 }
188
189 m_autoDelete = autoDelete;
190 m_threadStop = false;
191 m_startEvent.notify_all();
192 m_stopEvent.notify_all();
193
194 std::promise<bool> prom;
195 m_future = prom.get_future();
196
197 {
198 // The std::thread internals must be set prior to the lambda doing
199 // any work. This will cause the lambda to wait until m_thread
200 // is fully initialized. Interestingly, using a std::atomic doesn't
201 // have the appropriate memory barrier behavior to accomplish the
202 // same thing so a full system mutex needs to be used.
203 std::unique_lock<std::recursive_mutex> lock(m_threadMutex);
204 m_thread = new std::thread(
205 [](CThread* thread, std::promise<bool> promise) {
206 try
207 {
208 {
209 // Wait for the pThread->m_thread internals to be set. Otherwise we could
210 // get to a place where we're reading, say, the thread id inside this
211 // lambda's call stack prior to the thread that kicked off this lambda
212 // having it set. Once this lock is released, the CThread::Create function
213 // that kicked this off is done so everything should be set.
214 std::unique_lock<std::recursive_mutex> lock(thread->m_threadMutex);
215 }
216
217 thread->m_threadId = std::this_thread::get_id();
218 std::stringstream ss;
219 ss << thread->m_threadId;
220 std::string id = ss.str();
221 bool autodelete = thread->m_autoDelete;
222
223 kodi::Log(ADDON_LOG_DEBUG, "Thread %s start, auto delete: %s", id.c_str(),
224 (autodelete ? "true" : "false"));
225
226 thread->m_running = true;
227 thread->m_startEvent.notify_one();
228
229 thread->Process();
230
231 if (autodelete)
232 {
233 kodi::Log(ADDON_LOG_DEBUG, "Thread %s terminating (autodelete)", id.c_str());
234 delete thread;
235 thread = nullptr;
236 }
237 else
238 kodi::Log(ADDON_LOG_DEBUG, "Thread %s terminating", id.c_str());
239 }
240 catch (const std::exception& e)
241 {
242 kodi::Log(ADDON_LOG_DEBUG, "Thread Terminating with Exception: %s", e.what());
243 }
244 catch (...)
245 {
246 kodi::Log(ADDON_LOG_DEBUG, "Thread Terminating with Exception");
247 }
248
249 promise.set_value(true);
250 },
251 this, std::move(prom));
252
253 m_startEvent.wait(lock);
254 }
255 }
256 //----------------------------------------------------------------------------
257
258 //============================================================================
259 /// @ingroup cpp_kodi_tools_CThread
260 /// @brief Stop a running thread.
261 ///
262 /// @param[in] wait As true (default) to wait until thread is finished and
263 /// stopped, as false the function return directly and thread
264 /// becomes independently stopped.
265 ///
266 void StopThread(bool wait = true)
267 {
268 std::unique_lock<std::recursive_mutex> lock(m_threadMutex);
269
270 if (m_threadStop)
271 return;
272
273 if (m_thread && !m_running)
274 m_startEvent.wait(lock);
275 m_running = false;
276 m_threadStop = true;
277 m_stopEvent.notify_one();
278
279 std::thread* lthread = m_thread;
280 if (lthread != nullptr && wait && !IsCurrentThread())
281 {
282 lock.unlock();
283 if (lthread->joinable())
284 lthread->join();
285 delete m_thread;
286 m_thread = nullptr;
287 m_threadId = std::thread::id();
288 }
289 }
290 //----------------------------------------------------------------------------
291
292 //============================================================================
293 /// @ingroup cpp_kodi_tools_CThread
294 /// @brief Thread sleep with given amount of milliseconds.
295 ///
296 /// This makes a sleep in the thread with a given time value. If it is called
297 /// within the process itself, it is also checked whether the thread is
298 /// terminated and the sleep process is thereby interrupted.
299 ///
300 /// If the external point calls this, only a regular sleep is used, which runs
301 /// through completely.
302 ///
303 /// @param[in] milliseconds Time to sleep
304 ///
305 void Sleep(uint32_t milliseconds)
306 {
307 if (milliseconds > 10 && IsCurrentThread())
308 {
309 std::unique_lock<std::recursive_mutex> lock(m_threadMutex);
310 m_stopEvent.wait_for(lock, std::chrono::milliseconds(milliseconds));
311 }
312 else
313 {
314 std::this_thread::sleep_for(std::chrono::milliseconds(milliseconds));
315 }
316 }
317 //----------------------------------------------------------------------------
318
319 //============================================================================
320 /// @ingroup cpp_kodi_tools_CThread
321 /// @brief The function returns when the thread execution has completed or
322 /// timing is reached in milliseconds beforehand
323 ///
324 /// This synchronizes the moment this function returns with the completion of
325 /// all operations on the thread.
326 ///
327 /// @param[in] milliseconds Time to wait for join
328 ///
329 bool Join(unsigned int milliseconds)
330 {
331 std::unique_lock<std::recursive_mutex> lock(m_threadMutex);
332 std::thread* lthread = m_thread;
333 if (lthread != nullptr)
334 {
335 if (IsCurrentThread())
336 return false;
337
338 {
339 m_threadMutex.unlock(); // don't hold the thread lock while we're waiting
340 std::future_status stat = m_future.wait_for(std::chrono::milliseconds(milliseconds));
341 if (stat != std::future_status::ready)
342 return false;
343 m_threadMutex.lock();
344 }
345
346 // it's possible it's already joined since we released the lock above.
347 if (lthread->joinable())
348 m_thread->join();
349 return true;
350 }
351 else
352 return false;
353 }
354 //----------------------------------------------------------------------------
355
356protected:
357 //============================================================================
358 /// @ingroup cpp_kodi_tools_CThread
359 /// @brief The function to be added by the addon as a child to carry out the
360 /// process thread.
361 ///
362 /// Use @ref m_threadStop to check about active of thread and want stopped from
363 /// external place.
364 ///
365 /// @note This function is necessary and must be implemented by the addon.
366 ///
367 virtual void Process() = 0;
368 //----------------------------------------------------------------------------
369
370 //============================================================================
371 /// @ingroup cpp_kodi_tools_CThread
372 /// @brief Atomic bool to indicate thread is active.
373 ///
374 /// This should be used in @ref Process() to check the activity of the thread and,
375 /// if true, to terminate the process.
376 ///
377 /// - <b>`false`</b>: Thread active and should be run
378 /// - <b>`true`</b>: Thread ends and should be stopped
379 ///
380 std::atomic<bool> m_threadStop;
381 //----------------------------------------------------------------------------
382
383private:
384 bool m_autoDelete = false;
385 bool m_running = false;
386 std::condition_variable_any m_stopEvent;
387 std::condition_variable_any m_startEvent;
388 std::recursive_mutex m_threadMutex;
389 std::thread::id m_threadId;
390 std::thread* m_thread = nullptr;
391 std::future<bool> m_future;
392};
393///@}
394//------------------------------------------------------------------------------
395
396} /* namespace tools */
397} /* namespace kodi */
398
399#endif /* __cplusplus */
diff --git a/xbmc/addons/kodi-dev-kit/include/kodi/tools/Timer.h b/xbmc/addons/kodi-dev-kit/include/kodi/tools/Timer.h
new file mode 100644
index 0000000..0e0ced7
--- /dev/null
+++ b/xbmc/addons/kodi-dev-kit/include/kodi/tools/Timer.h
@@ -0,0 +1,315 @@
1/*
2 * Copyright (C) 2005-2020 Team Kodi
3 * This file is part of Kodi - https://kodi.tv
4 *
5 * SPDX-License-Identifier: GPL-2.0-or-later
6 * See LICENSES/README.md for more information.
7 */
8
9#pragma once
10
11#ifdef __cplusplus
12
13#include "Thread.h"
14
15#include <functional>
16
17namespace kodi
18{
19namespace tools
20{
21
22//==============================================================================
23/// @defgroup cpp_kodi_tools_CTimer class CTimer
24/// @ingroup cpp_kodi_tools
25/// @brief **Time interval management**\n
26/// Class which enables a time interval to be called up by a given function or
27/// class by means of a thread.
28///
29/// His code uses the support of platform-independent thread system introduced
30/// with C++11.
31///
32///
33/// ----------------------------------------------------------------------------
34///
35/// **Example:**
36/// ~~~~~~~~~~~~~{.cpp}
37/// #include <kodi/tools/Timer.h>
38///
39/// class ATTRIBUTE_HIDDEN CExample
40/// {
41/// public:
42/// CExample() : m_timer([this](){TimerCall();})
43/// {
44/// m_timer.Start(5000, true); // let call continuously all 5 seconds
45/// }
46///
47/// void TimerCall()
48/// {
49/// fprintf(stderr, "Hello World\n");
50/// }
51///
52/// private:
53/// kodi::tools::CTimer m_timer;
54/// };
55/// ~~~~~~~~~~~~~
56///
57///@{
58class CTimer : protected CThread
59{
60public:
61 class ITimerCallback;
62
63 //============================================================================
64 /// @ingroup cpp_kodi_tools_CTimer
65 /// @brief Class constructor to pass individual other class as callback.
66 ///
67 /// @param[in] callback Child class of parent @ref ITimerCallback with
68 /// implemented function @ref ITimerCallback::OnTimeout().
69 ///
70 explicit CTimer(kodi::tools::CTimer::ITimerCallback* callback)
71 : CTimer(std::bind(&ITimerCallback::OnTimeout, callback))
72 {
73 }
74 //----------------------------------------------------------------------------
75
76 //============================================================================
77 /// @ingroup cpp_kodi_tools_CTimer
78 /// @brief Class constructor to pass individual function as callback.
79 ///
80 /// @param[in] callback Function to pass as callback about timeout.
81 ///
82 /// **Callback function style:**
83 /// ~~~~~~~~~~~~~{.cpp}
84 /// void TimerCallback()
85 /// {
86 /// }
87 /// ~~~~~~~~~~~~~
88 explicit CTimer(std::function<void()> const& callback) : m_callback(callback) {}
89 //----------------------------------------------------------------------------
90
91 //============================================================================
92 /// @ingroup cpp_kodi_tools_CTimer
93 /// @brief Class destructor.
94 ///
95 ~CTimer() override { Stop(true); }
96 //----------------------------------------------------------------------------
97
98 //============================================================================
99 /// @ingroup cpp_kodi_tools_CTimer
100 /// @brief Start the timer by given time in milliseconds to make his call
101 /// by arrive of them.
102 ///
103 /// If interval is activated, it calls the associated callback function
104 /// continuously in the given interval.
105 ///
106 /// @param[in] timeout Timeout in milliseconds
107 /// @param[in] interval [opt] To run continuously if true, false only one time
108 /// and default
109 /// @return True if successfully done, false if not (callback missing,
110 /// timeout = 0 or was already running.
111 ///
112 bool Start(uint64_t timeout, bool interval = false)
113 {
114 using namespace std::chrono;
115
116 if (m_callback == nullptr || timeout == 0 || IsRunning())
117 return false;
118
119 m_timeout = milliseconds(timeout);
120 m_interval = interval;
121
122 CreateThread();
123 return true;
124 }
125 //----------------------------------------------------------------------------
126
127 //============================================================================
128 /// @ingroup cpp_kodi_tools_CTimer
129 /// @brief Stop the timer if it is active.
130 ///
131 /// @param[in] wait [opt] Wait until timer is stopped, false is default and
132 /// call unblocked
133 /// @return True if timer was active and was stopped, false if already was
134 /// stopped.
135 ///
136 bool Stop(bool wait = false)
137 {
138 if (!IsRunning())
139 return false;
140
141 m_threadStop = true;
142 m_eventTimeout.notify_all();
143 StopThread(wait);
144
145 return true;
146 }
147 //----------------------------------------------------------------------------
148
149 //============================================================================
150 /// @ingroup cpp_kodi_tools_CTimer
151 /// @brief Restart timer complete by stop and restart his thread again.
152 ///
153 /// @note Restart only possible as long the timer was running and not done his
154 /// work.
155 ///
156 /// @return True if start was successfully done, on error, or if was already
157 /// finished returned as false
158 ///
159 bool Restart()
160 {
161 using namespace std::chrono;
162
163 if (!IsRunning())
164 return false;
165
166 Stop(true);
167 return Start(duration_cast<milliseconds>(m_timeout).count(), m_interval);
168 }
169 //----------------------------------------------------------------------------
170
171 //============================================================================
172 /// @ingroup cpp_kodi_tools_CTimer
173 /// @brief Restart the timer with new timeout without touch of his thread.
174 ///
175 /// @param[in] timeout Time as milliseconds to wait for next call
176 ///
177 void RestartAsync(uint64_t timeout)
178 {
179 using namespace std::chrono;
180
181 m_timeout = milliseconds(timeout);
182 const auto now = system_clock::now();
183 m_endTime = now.time_since_epoch() + m_timeout;
184 m_eventTimeout.notify_all();
185 }
186 //----------------------------------------------------------------------------
187
188 //============================================================================
189 /// @ingroup cpp_kodi_tools_CTimer
190 /// @brief Check timer is still active to wait for next call.
191 ///
192 /// @return True if active, false if all his work done and no more running
193 ///
194 bool IsRunning() const { return CThread::IsRunning(); }
195 //----------------------------------------------------------------------------
196
197 //============================================================================
198 /// @ingroup cpp_kodi_tools_CTimer
199 /// @brief Get elapsed time as floating point of timer as seconds.
200 ///
201 /// @return Elapsed time
202 ///
203 float GetElapsedSeconds() const { return GetElapsedMilliseconds() / 1000.0f; }
204 //----------------------------------------------------------------------------
205
206 //============================================================================
207 /// @ingroup cpp_kodi_tools_CTimer
208 /// @brief Get elapsed time as floating point of timer as milliseconds.
209 ///
210 /// @return Elapsed time
211 ///
212 float GetElapsedMilliseconds() const
213 {
214 using namespace std::chrono;
215
216 if (!IsRunning())
217 return 0.0f;
218
219 const auto now = system_clock::now();
220 return static_cast<float>(duration_cast<milliseconds>(now.time_since_epoch() - (m_endTime - m_timeout)).count());
221 }
222 //----------------------------------------------------------------------------
223
224 //============================================================================
225 /// @defgroup cpp_kodi_tools_CTimer_CB class ITimerCallback
226 /// @ingroup cpp_kodi_tools_CTimer
227 /// @brief **Callback class of timer**\n
228 /// To give on contructor by @ref CTimer(kodi::tools::CTimer::ITimerCallback* callback)
229 ///
230 class ITimerCallback
231 {
232 public:
233 //==========================================================================
234 /// @ingroup cpp_kodi_tools_CTimer_CB
235 /// @brief Class destructor.
236 ///
237 virtual ~ITimerCallback() = default;
238 //--------------------------------------------------------------------------
239
240 //==========================================================================
241 /// @ingroup cpp_kodi_tools_CTimer_CB
242 /// @brief Callback function to implement if constuctor @ref CTimer(kodi::tools::CTimer::ITimerCallback* callback)
243 /// is used and this as parent on related class
244 ///
245 /// ----------------------------------------------------------------------------
246 ///
247 /// **Example:**
248 /// ~~~~~~~~~~~~~{.cpp}
249 /// #include <kodi/tools/Timer.h>
250 ///
251 /// class CExample : public kodi::tools::CTimer,
252 /// private kodi::tools::CTimer::ITimerCallback
253 /// {
254 /// public:
255 /// CExample() : kodi::tools::CTimer(this)
256 /// {
257 /// }
258 ///
259 /// void OnTimeout() override
260 /// {
261 /// // Some work
262 /// }
263 /// };
264 ///
265 /// ~~~~~~~~~~~~~
266 ///
267 virtual void OnTimeout() = 0;
268 //--------------------------------------------------------------------------
269 };
270 //----------------------------------------------------------------------------
271
272protected:
273 void Process() override
274 {
275 using namespace std::chrono;
276
277 while (!m_threadStop)
278 {
279 auto currentTime = system_clock::now();
280 m_endTime = currentTime.time_since_epoch() + m_timeout;
281
282 // wait the necessary time
283 std::mutex mutex;
284 std::unique_lock<std::mutex> lock(mutex);
285 const auto waitTime = duration_cast<milliseconds>(m_endTime - currentTime.time_since_epoch());
286 if (m_eventTimeout.wait_for(lock, waitTime) == std::cv_status::timeout)
287 {
288 currentTime = system_clock::now();
289 if (m_endTime.count() <= currentTime.time_since_epoch().count())
290 {
291 // execute OnTimeout() callback
292 m_callback();
293
294 // continue if this is an interval timer, or if it was restarted during callback
295 if (!m_interval && m_endTime.count() <= currentTime.time_since_epoch().count())
296 break;
297 }
298 }
299 }
300 }
301
302private:
303 bool m_interval = false;
304 std::function<void()> m_callback;
305 std::chrono::system_clock::duration m_timeout;
306 std::chrono::system_clock::duration m_endTime;
307 std::condition_variable_any m_eventTimeout;
308};
309///@}
310//------------------------------------------------------------------------------
311
312} /* namespace tools */
313} /* namespace kodi */
314
315#endif /* __cplusplus */
diff --git a/xbmc/addons/kodi-dev-kit/include/kodi/versions.h b/xbmc/addons/kodi-dev-kit/include/kodi/versions.h
new file mode 100644
index 0000000..e632f5a
--- /dev/null
+++ b/xbmc/addons/kodi-dev-kit/include/kodi/versions.h
@@ -0,0 +1,492 @@
1/*
2 * Copyright (C) 2016-2018 Team Kodi
3 * This file is part of Kodi - https://kodi.tv
4 *
5 * SPDX-License-Identifier: GPL-2.0-or-later
6 * See LICENSES/README.md for more information.
7 */
8
9#pragma once
10
11#include <string.h>
12
13#define STR_HELPER(x) #x
14#define STR(x) STR_HELPER(x)
15
16/*
17 *------------------------------------------------------------------------------
18 * Some parts on headers are only be used for Kodi itself and internally (not
19 * for add-on development).
20 *
21 * For this reason also no doxygen part with "///" defined there.
22 * -----------------------------------------------------------------------------
23 */
24
25/*
26 * Versions of all add-on globals and instances are defined below.
27 *
28 * This is added here and not in related header to prevent not
29 * needed includes during compile. Also have it here a better
30 * overview.
31 */
32
33// Ignore clang here, as this must be good in overview and as the main reason,
34// because cmake uses this area in this form to perform its addon dependency
35// check.
36// clang-format off
37#define ADDON_GLOBAL_VERSION_MAIN "1.2.4"
38#define ADDON_GLOBAL_VERSION_MAIN_MIN "1.2.0"
39#define ADDON_GLOBAL_VERSION_MAIN_XML_ID "kodi.binary.global.main"
40#define ADDON_GLOBAL_VERSION_MAIN_DEPENDS "AddonBase.h" \
41 "addon-instance/" \
42 "c-api/addon_base.h"
43
44#define ADDON_GLOBAL_VERSION_GENERAL "1.0.5"
45#define ADDON_GLOBAL_VERSION_GENERAL_MIN "1.0.4"
46#define ADDON_GLOBAL_VERSION_GENERAL_XML_ID "kodi.binary.global.general"
47#define ADDON_GLOBAL_VERSION_GENERAL_DEPENDS "General.h"
48
49#define ADDON_GLOBAL_VERSION_GUI "5.15.0"
50#define ADDON_GLOBAL_VERSION_GUI_MIN "5.15.0"
51#define ADDON_GLOBAL_VERSION_GUI_XML_ID "kodi.binary.global.gui"
52#define ADDON_GLOBAL_VERSION_GUI_DEPENDS "c-api/gui/input/action_ids.h" \
53 "c-api/gui/" \
54 "gui/"
55
56#define ADDON_GLOBAL_VERSION_AUDIOENGINE "1.1.1"
57#define ADDON_GLOBAL_VERSION_AUDIOENGINE_MIN "1.1.0"
58#define ADDON_GLOBAL_VERSION_AUDIOENGINE_XML_ID "kodi.binary.global.audioengine"
59#define ADDON_GLOBAL_VERSION_AUDIOENGINE_DEPENDS "AudioEngine.h" \
60 "c-api/audio_engine.h"
61
62#define ADDON_GLOBAL_VERSION_FILESYSTEM "1.1.6"
63#define ADDON_GLOBAL_VERSION_FILESYSTEM_MIN "1.1.0"
64#define ADDON_GLOBAL_VERSION_FILESYSTEM_XML_ID "kodi.binary.global.filesystem"
65#define ADDON_GLOBAL_VERSION_FILESYSTEM_DEPENDS "Filesystem.h" \
66 "c-api/filesystem.h" \
67 "gui/gl/Shader.h" \
68 "tools/DllHelper.h"
69
70#define ADDON_GLOBAL_VERSION_NETWORK "1.0.4"
71#define ADDON_GLOBAL_VERSION_NETWORK_MIN "1.0.0"
72#define ADDON_GLOBAL_VERSION_NETWORK_XML_ID "kodi.binary.global.network"
73#define ADDON_GLOBAL_VERSION_NETWORK_DEPENDS "Network.h" \
74 "c-api/network.h"
75
76#define ADDON_GLOBAL_VERSION_TOOLS "1.0.4"
77#define ADDON_GLOBAL_VERSION_TOOLS_MIN "1.0.0"
78#define ADDON_GLOBAL_VERSION_TOOLS_XML_ID "kodi.binary.global.tools"
79#define ADDON_GLOBAL_VERSION_TOOLS_DEPENDS "tools/DllHelper.h" \
80 "tools/EndTime.h" \
81 "tools/StringUtils.h" \
82 "tools/Thread.h" \
83 "tools/Timer.h"
84
85#define ADDON_INSTANCE_VERSION_AUDIODECODER "3.0.0"
86#define ADDON_INSTANCE_VERSION_AUDIODECODER_MIN "3.0.0"
87#define ADDON_INSTANCE_VERSION_AUDIODECODER_XML_ID "kodi.binary.instance.audiodecoder"
88#define ADDON_INSTANCE_VERSION_AUDIODECODER_DEPENDS "c-api/addon-instance/audio_decoder.h" \
89 "addon-instance/AudioDecoder.h"
90
91#define ADDON_INSTANCE_VERSION_AUDIOENCODER "2.1.0"
92#define ADDON_INSTANCE_VERSION_AUDIOENCODER_MIN "2.1.0"
93#define ADDON_INSTANCE_VERSION_AUDIOENCODER_XML_ID "kodi.binary.instance.audioencoder"
94#define ADDON_INSTANCE_VERSION_AUDIOENCODER_DEPENDS "c-api/addon-instance/audio_encoder.h" \
95 "addon-instance/AudioEncoder.h"
96
97#define ADDON_INSTANCE_VERSION_GAME "2.1.0"
98#define ADDON_INSTANCE_VERSION_GAME_MIN "2.1.0"
99#define ADDON_INSTANCE_VERSION_GAME_XML_ID "kodi.binary.instance.game"
100#define ADDON_INSTANCE_VERSION_GAME_DEPENDS "addon-instance/Game.h"
101
102#define ADDON_INSTANCE_VERSION_IMAGEDECODER "2.1.1"
103#define ADDON_INSTANCE_VERSION_IMAGEDECODER_MIN "2.1.0"
104#define ADDON_INSTANCE_VERSION_IMAGEDECODER_XML_ID "kodi.binary.instance.imagedecoder"
105#define ADDON_INSTANCE_VERSION_IMAGEDECODER_DEPENDS "addon-instance/ImageDecoder.h"
106
107#define ADDON_INSTANCE_VERSION_INPUTSTREAM "2.3.4"
108#define ADDON_INSTANCE_VERSION_INPUTSTREAM_MIN "2.3.4"
109#define ADDON_INSTANCE_VERSION_INPUTSTREAM_XML_ID "kodi.binary.instance.inputstream"
110#define ADDON_INSTANCE_VERSION_INPUTSTREAM_DEPENDS "addon-instance/Inputstream.h"
111
112#define ADDON_INSTANCE_VERSION_PERIPHERAL "2.0.0"
113#define ADDON_INSTANCE_VERSION_PERIPHERAL_MIN "2.0.0"
114#define ADDON_INSTANCE_VERSION_PERIPHERAL_XML_ID "kodi.binary.instance.peripheral"
115#define ADDON_INSTANCE_VERSION_PERIPHERAL_DEPENDS "addon-instance/Peripheral.h" \
116 "addon-instance/PeripheralUtils.h"
117
118#define ADDON_INSTANCE_VERSION_PVR "7.0.1"
119#define ADDON_INSTANCE_VERSION_PVR_MIN "7.0.0"
120#define ADDON_INSTANCE_VERSION_PVR_XML_ID "kodi.binary.instance.pvr"
121#define ADDON_INSTANCE_VERSION_PVR_DEPENDS "c-api/addon-instance/pvr.h" \
122 "c-api/addon-instance/pvr/pvr_channel_groups.h" \
123 "c-api/addon-instance/pvr/pvr_channels.h" \
124 "c-api/addon-instance/pvr/pvr_defines.h" \
125 "c-api/addon-instance/pvr/pvr_edl.h" \
126 "c-api/addon-instance/pvr/pvr_epg.h" \
127 "c-api/addon-instance/pvr/pvr_general.h" \
128 "c-api/addon-instance/pvr/pvr_menu_hook.h" \
129 "c-api/addon-instance/pvr/pvr_recordings.h" \
130 "c-api/addon-instance/pvr/pvr_stream.h" \
131 "c-api/addon-instance/pvr/pvr_timers.h" \
132 "addon-instance/PVR.h" \
133 "addon-instance/pvr/ChannelGroups.h" \
134 "addon-instance/pvr/Channels.h" \
135 "addon-instance/pvr/EDL.h" \
136 "addon-instance/pvr/EPG.h" \
137 "addon-instance/pvr/General.h" \
138 "addon-instance/pvr/MenuHook.h" \
139 "addon-instance/pvr/Recordings.h" \
140 "addon-instance/pvr/Stream.h" \
141 "addon-instance/pvr/Timers.h"
142
143#define ADDON_INSTANCE_VERSION_SCREENSAVER "2.1.0"
144#define ADDON_INSTANCE_VERSION_SCREENSAVER_MIN "2.1.0"
145#define ADDON_INSTANCE_VERSION_SCREENSAVER_XML_ID "kodi.binary.instance.screensaver"
146#define ADDON_INSTANCE_VERSION_SCREENSAVER_DEPENDS "c-api/addon-instance/screensaver.h" \
147 "addon-instance/Screensaver.h"
148
149#define ADDON_INSTANCE_VERSION_VFS "3.0.0"
150#define ADDON_INSTANCE_VERSION_VFS_MIN "3.0.0"
151#define ADDON_INSTANCE_VERSION_VFS_XML_ID "kodi.binary.instance.vfs"
152#define ADDON_INSTANCE_VERSION_VFS_DEPENDS "c-api/addon-instance/vfs.h" \
153 "addon-instance/VFS.h"
154
155#define ADDON_INSTANCE_VERSION_VISUALIZATION "3.0.0"
156#define ADDON_INSTANCE_VERSION_VISUALIZATION_MIN "3.0.0"
157#define ADDON_INSTANCE_VERSION_VISUALIZATION_XML_ID "kodi.binary.instance.visualization"
158#define ADDON_INSTANCE_VERSION_VISUALIZATION_DEPENDS "addon-instance/Visualization.h" \
159 "c-api/addon-instance/visualization.h"
160
161#define ADDON_INSTANCE_VERSION_VIDEOCODEC "1.0.4"
162#define ADDON_INSTANCE_VERSION_VIDEOCODEC_MIN "1.0.4"
163#define ADDON_INSTANCE_VERSION_VIDEOCODEC_XML_ID "kodi.binary.instance.videocodec"
164#define ADDON_INSTANCE_VERSION_VIDEOCODEC_DEPENDS "addon-instance/VideoCodec.h" \
165 "StreamCodec.h" \
166 "StreamCrypto.h"
167// clang-format on
168
169//==============================================================================
170///
171/// @ingroup cpp_kodi_addon_addonbase
172/// The currently available instance types for Kodi add-ons
173///
174/// \internal
175/// @note For add of new types take a new number on end. To change
176/// existing numbers can be make problems on already compiled add-ons.
177/// \endinternal
178///
179typedef enum ADDON_TYPE
180{
181 /* addon global parts */
182 ADDON_GLOBAL_MAIN = 0,
183 ADDON_GLOBAL_GUI = 1,
184 ADDON_GLOBAL_AUDIOENGINE = 2,
185 ADDON_GLOBAL_GENERAL = 3,
186 ADDON_GLOBAL_NETWORK = 4,
187 ADDON_GLOBAL_FILESYSTEM = 5,
188 ADDON_GLOBAL_TOOLS = 6,
189 // Last used global id, used in loops to check versions.
190 // Need to change if new global type becomes added!
191 ADDON_GLOBAL_MAX = 6,
192
193 /* addon type instances */
194
195 /// Audio decoder instance, see \ref cpp_kodi_addon_audiodecoder "kodi::addon::CInstanceAudioDecoder"
196 ADDON_INSTANCE_AUDIODECODER = 102,
197
198 /// Audio encoder instance, see \ref cpp_kodi_addon_audioencoder "kodi::addon::CInstanceAudioEncoder"
199 ADDON_INSTANCE_AUDIOENCODER = 103,
200
201 /// Game instance, see \ref cpp_kodi_addon_game "kodi::addon::CInstanceGame"
202 ADDON_INSTANCE_GAME = 104,
203
204 /// Input stream instance, see \ref cpp_kodi_addon_inputstream "kodi::addon::CInstanceInputStream"
205 ADDON_INSTANCE_INPUTSTREAM = 105,
206
207 /// Peripheral instance, see \ref cpp_kodi_addon_peripheral "kodi::addon::CInstancePeripheral"
208 ADDON_INSTANCE_PERIPHERAL = 106,
209
210 /// Game instance, see \ref cpp_kodi_addon_pvr "kodi::addon::CInstancePVRClient"
211 ADDON_INSTANCE_PVR = 107,
212
213 /// PVR client instance, see \ref cpp_kodi_addon_screensaver "kodi::addon::CInstanceScreensaver"
214 ADDON_INSTANCE_SCREENSAVER = 108,
215
216 /// Music visualization instance, see \ref cpp_kodi_addon_visualization "kodi::addon::CInstanceVisualization"
217 ADDON_INSTANCE_VISUALIZATION = 109,
218
219 /// Virtual Filesystem (VFS) instance, see \ref cpp_kodi_addon_vfs "kodi::addon::CInstanceVFS"
220 ADDON_INSTANCE_VFS = 110,
221
222 /// Image Decoder instance, see \ref cpp_kodi_addon_imagedecoder "kodi::addon::CInstanceImageDecoder"
223 ADDON_INSTANCE_IMAGEDECODER = 111,
224
225 /// Video Decoder instance, see \ref cpp_kodi_addon_videocodec "kodi::addon::CInstanceVideoCodec"
226 ADDON_INSTANCE_VIDEOCODEC = 112,
227} ADDON_TYPE;
228//------------------------------------------------------------------------------
229
230#ifdef __cplusplus
231extern "C" {
232namespace kodi {
233namespace addon {
234#endif
235
236///
237/// This is used from Kodi to get the active version of add-on parts.
238/// It is compiled in add-on and also in Kodi itself, with this can be Kodi
239/// compare the version from him with them on add-on.
240///
241/// @param[in] type The with 'enum ADDON_TYPE' type to ask
242/// @return version The current version of asked type
243///
244inline const char* GetTypeVersion(int type)
245{
246 /*
247 * #ifdef's below becomes set by cmake, no set by hand needed.
248 */
249 switch (type)
250 {
251 /* addon global parts */
252 case ADDON_GLOBAL_MAIN:
253 return ADDON_GLOBAL_VERSION_MAIN;
254#if !defined(BUILD_KODI_ADDON) || defined(ADDON_GLOBAL_VERSION_GENERAL_USED)
255 case ADDON_GLOBAL_GENERAL:
256 return ADDON_GLOBAL_VERSION_GENERAL;
257#endif
258#if !defined(BUILD_KODI_ADDON) || defined(ADDON_GLOBAL_VERSION_GUI_USED)
259 case ADDON_GLOBAL_GUI:
260 return ADDON_GLOBAL_VERSION_GUI;
261#endif
262#if !defined(BUILD_KODI_ADDON) || defined(ADDON_GLOBAL_VERSION_AUDIOENGINE_USED)
263 case ADDON_GLOBAL_AUDIOENGINE:
264 return ADDON_GLOBAL_VERSION_AUDIOENGINE;
265#endif
266#if !defined(BUILD_KODI_ADDON) || defined(ADDON_GLOBAL_VERSION_FILESYSTEM_USED)
267 case ADDON_GLOBAL_FILESYSTEM:
268 return ADDON_GLOBAL_VERSION_FILESYSTEM;
269#endif
270#if !defined(BUILD_KODI_ADDON) || defined(ADDON_GLOBAL_VERSION_NETWORK_USED)
271 case ADDON_GLOBAL_NETWORK:
272 return ADDON_GLOBAL_VERSION_NETWORK;
273#endif
274#if !defined(BUILD_KODI_ADDON) || defined(ADDON_GLOBAL_VERSION_TOOLS_USED)
275 case ADDON_GLOBAL_TOOLS:
276 return ADDON_GLOBAL_VERSION_TOOLS;
277#endif
278
279 /* addon type instances */
280#if !defined(BUILD_KODI_ADDON) || defined(ADDON_INSTANCE_VERSION_AUDIODECODER_USED)
281 case ADDON_INSTANCE_AUDIODECODER:
282 return ADDON_INSTANCE_VERSION_AUDIODECODER;
283#endif
284#if !defined(BUILD_KODI_ADDON) || defined(ADDON_INSTANCE_VERSION_AUDIOENCODER_USED)
285 case ADDON_INSTANCE_AUDIOENCODER:
286 return ADDON_INSTANCE_VERSION_AUDIOENCODER;
287#endif
288#if !defined(BUILD_KODI_ADDON) || defined(ADDON_INSTANCE_VERSION_GAME_USED)
289 case ADDON_INSTANCE_GAME:
290 return ADDON_INSTANCE_VERSION_GAME;
291#endif
292#if !defined(BUILD_KODI_ADDON) || defined(ADDON_INSTANCE_VERSION_IMAGEDECODER_USED)
293 case ADDON_INSTANCE_IMAGEDECODER:
294 return ADDON_INSTANCE_VERSION_IMAGEDECODER;
295#endif
296#if !defined(BUILD_KODI_ADDON) || defined(ADDON_INSTANCE_VERSION_INPUTSTREAM_USED)
297 case ADDON_INSTANCE_INPUTSTREAM:
298 return ADDON_INSTANCE_VERSION_INPUTSTREAM;
299#endif
300#if !defined(BUILD_KODI_ADDON) || defined(ADDON_INSTANCE_VERSION_PERIPHERAL_USED)
301 case ADDON_INSTANCE_PERIPHERAL:
302 return ADDON_INSTANCE_VERSION_PERIPHERAL;
303#endif
304#if !defined(BUILD_KODI_ADDON) || defined(ADDON_INSTANCE_VERSION_PVR_USED)
305 case ADDON_INSTANCE_PVR:
306 return ADDON_INSTANCE_VERSION_PVR;
307#endif
308#if !defined(BUILD_KODI_ADDON) || defined(ADDON_INSTANCE_VERSION_SCREENSAVER_USED)
309 case ADDON_INSTANCE_SCREENSAVER:
310 return ADDON_INSTANCE_VERSION_SCREENSAVER;
311#endif
312#if !defined(BUILD_KODI_ADDON) || defined(ADDON_INSTANCE_VERSION_VFS_USED)
313 case ADDON_INSTANCE_VFS:
314 return ADDON_INSTANCE_VERSION_VFS;
315#endif
316#if !defined(BUILD_KODI_ADDON) || defined(ADDON_INSTANCE_VERSION_VISUALIZATION_USED)
317 case ADDON_INSTANCE_VISUALIZATION:
318 return ADDON_INSTANCE_VERSION_VISUALIZATION;
319#endif
320#if !defined(BUILD_KODI_ADDON) || defined(ADDON_INSTANCE_VERSION_VIDEOCODEC_USED)
321 case ADDON_INSTANCE_VIDEOCODEC:
322 return ADDON_INSTANCE_VERSION_VIDEOCODEC;
323#endif
324 }
325 return "0.0.0";
326}
327
328///
329/// This is used from Kodi to get the minimum supported version of add-on parts.
330/// It is compiled in add-on and also in Kodi itself, with this can be Kodi
331/// compare the version from him with them on add-on.
332///
333/// @param[in] type The with 'enum ADDON_TYPE' type to ask
334/// @return version The minimum version of asked type
335///
336inline const char* GetTypeMinVersion(int type)
337{
338 switch (type)
339 {
340 /* addon global parts */
341 case ADDON_GLOBAL_MAIN:
342 return ADDON_GLOBAL_VERSION_MAIN_MIN;
343 case ADDON_GLOBAL_GUI:
344 return ADDON_GLOBAL_VERSION_GUI_MIN;
345 case ADDON_GLOBAL_GENERAL:
346 return ADDON_GLOBAL_VERSION_GENERAL_MIN;
347 case ADDON_GLOBAL_AUDIOENGINE:
348 return ADDON_GLOBAL_VERSION_AUDIOENGINE_MIN;
349 case ADDON_GLOBAL_FILESYSTEM:
350 return ADDON_GLOBAL_VERSION_FILESYSTEM_MIN;
351 case ADDON_GLOBAL_NETWORK:
352 return ADDON_GLOBAL_VERSION_NETWORK_MIN;
353 case ADDON_GLOBAL_TOOLS:
354 return ADDON_GLOBAL_VERSION_TOOLS_MIN;
355
356 /* addon type instances */
357 case ADDON_INSTANCE_AUDIODECODER:
358 return ADDON_INSTANCE_VERSION_AUDIODECODER_MIN;
359 case ADDON_INSTANCE_AUDIOENCODER:
360 return ADDON_INSTANCE_VERSION_AUDIOENCODER_MIN;
361 case ADDON_INSTANCE_GAME:
362 return ADDON_INSTANCE_VERSION_GAME_MIN;
363 case ADDON_INSTANCE_IMAGEDECODER:
364 return ADDON_INSTANCE_VERSION_IMAGEDECODER_MIN;
365 case ADDON_INSTANCE_INPUTSTREAM:
366 return ADDON_INSTANCE_VERSION_INPUTSTREAM_MIN;
367 case ADDON_INSTANCE_PERIPHERAL:
368 return ADDON_INSTANCE_VERSION_PERIPHERAL_MIN;
369 case ADDON_INSTANCE_PVR:
370 return ADDON_INSTANCE_VERSION_PVR_MIN;
371 case ADDON_INSTANCE_SCREENSAVER:
372 return ADDON_INSTANCE_VERSION_SCREENSAVER_MIN;
373 case ADDON_INSTANCE_VFS:
374 return ADDON_INSTANCE_VERSION_VFS_MIN;
375 case ADDON_INSTANCE_VISUALIZATION:
376 return ADDON_INSTANCE_VERSION_VISUALIZATION_MIN;
377 case ADDON_INSTANCE_VIDEOCODEC:
378 return ADDON_INSTANCE_VERSION_VIDEOCODEC_MIN;
379 }
380 return "0.0.0";
381}
382
383///
384/// Function used internally on add-on and in Kodi itself to get name
385/// about given type.
386///
387/// @param[in] type The with 'enum ADDON_TYPE' defined type to ask
388/// @return Name of the asked instance type
389///
390inline const char* GetTypeName(int type)
391{
392 switch (type)
393 {
394 /* addon global parts */
395 case ADDON_GLOBAL_MAIN:
396 return "Addon";
397 case ADDON_GLOBAL_GUI:
398 return "GUI";
399 case ADDON_GLOBAL_GENERAL:
400 return "General";
401 case ADDON_GLOBAL_AUDIOENGINE:
402 return "AudioEngine";
403 case ADDON_GLOBAL_FILESYSTEM:
404 return "Filesystem";
405 case ADDON_GLOBAL_NETWORK:
406 return "Network";
407 case ADDON_GLOBAL_TOOLS:
408 return "Tools";
409
410 /* addon type instances */
411 case ADDON_INSTANCE_AUDIODECODER:
412 return "AudioDecoder";
413 case ADDON_INSTANCE_AUDIOENCODER:
414 return "AudioEncoder";
415 case ADDON_INSTANCE_GAME:
416 return "Game";
417 case ADDON_INSTANCE_IMAGEDECODER:
418 return "ImageDecoder";
419 case ADDON_INSTANCE_INPUTSTREAM:
420 return "Inputstream";
421 case ADDON_INSTANCE_PERIPHERAL:
422 return "Peripheral";
423 case ADDON_INSTANCE_PVR:
424 return "PVR";
425 case ADDON_INSTANCE_SCREENSAVER:
426 return "ScreenSaver";
427 case ADDON_INSTANCE_VISUALIZATION:
428 return "Visualization";
429 case ADDON_INSTANCE_VIDEOCODEC:
430 return "VideoCodec";
431 }
432 return "unknown";
433}
434
435///
436/// Function used internally on add-on and in Kodi itself to get id number
437/// about given type name.
438///
439/// @param[in] name The type name string to ask
440/// @return Id number of the asked instance type
441///
442/// @warning String must be lower case here!
443///
444inline int GetTypeId(const char* name)
445{
446 if (name)
447 {
448 if (strcmp(name, "addon") == 0)
449 return ADDON_GLOBAL_MAIN;
450 else if (strcmp(name, "general") == 0)
451 return ADDON_GLOBAL_GENERAL;
452 else if (strcmp(name, "gui") == 0)
453 return ADDON_GLOBAL_GUI;
454 else if (strcmp(name, "audioengine") == 0)
455 return ADDON_GLOBAL_AUDIOENGINE;
456 else if (strcmp(name, "filesystem") == 0)
457 return ADDON_GLOBAL_FILESYSTEM;
458 else if (strcmp(name, "network") == 0)
459 return ADDON_GLOBAL_NETWORK;
460 else if (strcmp(name, "tools") == 0)
461 return ADDON_GLOBAL_TOOLS;
462 else if (strcmp(name, "audiodecoder") == 0)
463 return ADDON_INSTANCE_AUDIODECODER;
464 else if (strcmp(name, "audioencoder") == 0)
465 return ADDON_INSTANCE_AUDIOENCODER;
466 else if (strcmp(name, "game") == 0)
467 return ADDON_INSTANCE_GAME;
468 else if (strcmp(name, "imagedecoder") == 0)
469 return ADDON_INSTANCE_IMAGEDECODER;
470 else if (strcmp(name, "inputstream") == 0)
471 return ADDON_INSTANCE_INPUTSTREAM;
472 else if (strcmp(name, "peripheral") == 0)
473 return ADDON_INSTANCE_PERIPHERAL;
474 else if (strcmp(name, "pvr") == 0)
475 return ADDON_INSTANCE_PVR;
476 else if (strcmp(name, "screensaver") == 0)
477 return ADDON_INSTANCE_SCREENSAVER;
478 else if (strcmp(name, "vfs") == 0)
479 return ADDON_INSTANCE_VFS;
480 else if (strcmp(name, "visualization") == 0)
481 return ADDON_INSTANCE_VISUALIZATION;
482 else if (strcmp(name, "videocodec") == 0)
483 return ADDON_INSTANCE_VIDEOCODEC;
484 }
485 return -1;
486}
487
488#ifdef __cplusplus
489} /* namespace addon */
490} /* namespace kodi */
491} /* extern "C" */
492#endif