summaryrefslogtreecommitdiffstats
path: root/xbmc/addons/kodi-addon-dev-kit/include/kodi/addon-instance
diff options
context:
space:
mode:
authormanuel <manuel@mausz.at>2020-10-19 00:52:24 +0200
committermanuel <manuel@mausz.at>2020-10-19 00:52:24 +0200
commitbe933ef2241d79558f91796cc5b3a161f72ebf9c (patch)
treefe3ab2f130e20c99001f2d7a81d610c78c96a3f4 /xbmc/addons/kodi-addon-dev-kit/include/kodi/addon-instance
parent5f8335c1e49ce108ef3481863833c98efa00411b (diff)
downloadkodi-pvr-build-be933ef2241d79558f91796cc5b3a161f72ebf9c.tar.gz
kodi-pvr-build-be933ef2241d79558f91796cc5b3a161f72ebf9c.tar.bz2
kodi-pvr-build-be933ef2241d79558f91796cc5b3a161f72ebf9c.zip
sync with upstream
Diffstat (limited to 'xbmc/addons/kodi-addon-dev-kit/include/kodi/addon-instance')
-rw-r--r--xbmc/addons/kodi-addon-dev-kit/include/kodi/addon-instance/AudioDecoder.h363
-rw-r--r--xbmc/addons/kodi-addon-dev-kit/include/kodi/addon-instance/AudioEncoder.h218
-rw-r--r--xbmc/addons/kodi-addon-dev-kit/include/kodi/addon-instance/CMakeLists.txt16
-rw-r--r--xbmc/addons/kodi-addon-dev-kit/include/kodi/addon-instance/Game.h2360
-rw-r--r--xbmc/addons/kodi-addon-dev-kit/include/kodi/addon-instance/ImageDecoder.h315
-rw-r--r--xbmc/addons/kodi-addon-dev-kit/include/kodi/addon-instance/Inputstream.h881
-rw-r--r--xbmc/addons/kodi-addon-dev-kit/include/kodi/addon-instance/PVR.h3423
-rw-r--r--xbmc/addons/kodi-addon-dev-kit/include/kodi/addon-instance/Peripheral.h847
-rw-r--r--xbmc/addons/kodi-addon-dev-kit/include/kodi/addon-instance/PeripheralUtils.h735
-rw-r--r--xbmc/addons/kodi-addon-dev-kit/include/kodi/addon-instance/Screensaver.h460
-rw-r--r--xbmc/addons/kodi-addon-dev-kit/include/kodi/addon-instance/VFS.h1265
-rw-r--r--xbmc/addons/kodi-addon-dev-kit/include/kodi/addon-instance/VideoCodec.h246
-rw-r--r--xbmc/addons/kodi-addon-dev-kit/include/kodi/addon-instance/Visualization.h789
-rw-r--r--xbmc/addons/kodi-addon-dev-kit/include/kodi/addon-instance/pvr/CMakeLists.txt13
-rw-r--r--xbmc/addons/kodi-addon-dev-kit/include/kodi/addon-instance/pvr/ChannelGroups.h271
-rw-r--r--xbmc/addons/kodi-addon-dev-kit/include/kodi/addon-instance/pvr/Channels.h518
-rw-r--r--xbmc/addons/kodi-addon-dev-kit/include/kodi/addon-instance/pvr/EDL.h90
-rw-r--r--xbmc/addons/kodi-addon-dev-kit/include/kodi/addon-instance/pvr/EPG.h500
-rw-r--r--xbmc/addons/kodi-addon-dev-kit/include/kodi/addon-instance/pvr/General.h511
-rw-r--r--xbmc/addons/kodi-addon-dev-kit/include/kodi/addon-instance/pvr/MenuHook.h130
-rw-r--r--xbmc/addons/kodi-addon-dev-kit/include/kodi/addon-instance/pvr/Recordings.h520
-rw-r--r--xbmc/addons/kodi-addon-dev-kit/include/kodi/addon-instance/pvr/Stream.h330
-rw-r--r--xbmc/addons/kodi-addon-dev-kit/include/kodi/addon-instance/pvr/Timers.h896
23 files changed, 0 insertions, 15697 deletions
diff --git a/xbmc/addons/kodi-addon-dev-kit/include/kodi/addon-instance/AudioDecoder.h b/xbmc/addons/kodi-addon-dev-kit/include/kodi/addon-instance/AudioDecoder.h
deleted file mode 100644
index 25e39e2..0000000
--- a/xbmc/addons/kodi-addon-dev-kit/include/kodi/addon-instance/AudioDecoder.h
+++ /dev/null
@@ -1,363 +0,0 @@
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#ifdef BUILD_KODI_ADDON
13#include "../AEChannelData.h"
14#else
15#include "cores/AudioEngine/Utils/AEChannelData.h"
16#endif
17#include <stdint.h>
18
19namespace kodi
20{
21namespace addon
22{
23 class CInstanceAudioDecoder;
24} /* namespace addon */
25} /* namespace kodi */
26
27extern "C"
28{
29
30typedef struct AddonProps_AudioDecoder
31{
32 int dummy;
33} AddonProps_AudioDecoder;
34
35typedef struct AddonToKodiFuncTable_AudioDecoder
36{
37 void* kodiInstance;
38} AddonToKodiFuncTable_AudioDecoder;
39
40struct AddonInstance_AudioDecoder;
41typedef struct KodiToAddonFuncTable_AudioDecoder
42{
43 kodi::addon::CInstanceAudioDecoder* addonInstance;
44 bool (__cdecl* init)(const AddonInstance_AudioDecoder* instance,
45 const char* file, unsigned int filecache,
46 int* channels, int* samplerate,
47 int* bitspersample, int64_t* totaltime,
48 int* bitrate, AEDataFormat* format,
49 const AEChannel** info);
50 int (__cdecl* read_pcm)(const AddonInstance_AudioDecoder* instance, uint8_t* buffer, int size, int* actualsize);
51 int64_t (__cdecl* seek)(const AddonInstance_AudioDecoder* instance, int64_t time);
52 bool (__cdecl* read_tag)(const AddonInstance_AudioDecoder* instance,
53 const char* file, char* title,
54 char* artist, int* length);
55 int (__cdecl* track_count)(const AddonInstance_AudioDecoder* instance, const char* file);
56} KodiToAddonFuncTable_AudioDecoder;
57
58typedef struct AddonInstance_AudioDecoder
59{
60 AddonProps_AudioDecoder props;
61 AddonToKodiFuncTable_AudioDecoder toKodi;
62 KodiToAddonFuncTable_AudioDecoder toAddon;
63} AddonInstance_AudioDecoder;
64
65} /* extern "C" */
66
67namespace kodi
68{
69namespace addon
70{
71
72//==============================================================================
73///
74/// \addtogroup cpp_kodi_addon_audiodecoder
75/// @brief \cpp_class{ kodi::addon::CInstanceAudioDecoder }
76/// **Audio decoder add-on instance**
77///
78/// For audio decoders as binary add-ons. This class implements a way to handle
79/// special types of audio files.
80///
81/// The add-on handles loading of the source file and outputting the audio stream
82/// for consumption by the player.
83///
84/// The addon.xml defines the capabilities of this add-on.
85///
86/// @note The option to have multiple instances is possible with audio-decoder
87/// add-ons. This is useful, since some playback engines are riddled by global
88/// variables, making decoding of multiple streams using the same instance
89/// impossible.
90///
91///
92/// ----------------------------------------------------------------------------
93///
94/// **Here's an example on addon.xml:**
95/// ~~~~~~~~~~~~~{.xml}
96/// <extension
97/// point="kodi.audiodecoder"
98/// name="2sf"
99/// extension=".2sf|.mini2sf"
100/// tags="true"
101/// library_@PLATFORM@="@LIBRARY_FILENAME@"/>
102/// ~~~~~~~~~~~~~
103///
104/// Description to audio decoder related addon.xml values:
105/// | Name | Description
106/// |:------------------------------|----------------------------------------
107/// | <b>`point`</b> | Addon type specification<br>At all addon types and for this kind always <b>"kodi.audiodecoder"</b>.
108/// | <b>`library_@PLATFORM@`</b> | Sets the used library name, which is automatically set by cmake at addon build.
109/// | <b>`name`</b> | The name of the decoder used in Kodi for display.
110/// | <b>`extension`</b> | The file extensions / styles supported by this addon.
111/// | <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.
112///
113/// --------------------------------------------------------------------------
114///
115/// **Here is a code example how this addon is used:**
116///
117/// ~~~~~~~~~~~~~{.cpp}
118/// #include <kodi/addon-instance/AudioDecoder.h>
119///
120/// class CMyAudioDecoder : public ::kodi::addon::CInstanceAudioDecoder
121/// {
122/// public:
123/// CMyAudioDecoder(KODI_HANDLE instance);
124///
125/// bool Init(const std::string& filename, unsigned int filecache,
126/// int& channels, int& samplerate,
127/// int& bitspersample, int64_t& totaltime,
128/// int& bitrate, AEDataFormat& format,
129/// std::vector<AEChannel>& channellist) override;
130/// int ReadPCM(uint8_t* buffer, int size, int& actualsize) override;
131/// };
132///
133/// CMyAudioDecoder::CMyAudioDecoder(KODI_HANDLE instance)
134/// : CInstanceAudioDecoder(instance)
135/// {
136/// ...
137/// }
138///
139/// bool CMyAudioDecoder::Init(const std::string& filename, unsigned int filecache,
140/// int& channels, int& samplerate,
141/// int& bitspersample, int64_t& totaltime,
142/// int& bitrate, AEDataFormat& format,
143/// std::vector<AEChannel>& channellist)
144/// {
145/// ...
146/// return true;
147/// }
148///
149/// int CMyAudioDecoder::ReadPCM(uint8_t* buffer, int size, int& actualsize)
150/// {
151/// ...
152/// return 0;
153/// }
154///
155///
156/// /*----------------------------------------------------------------------*/
157///
158/// class CMyAddon : public ::kodi::addon::CAddonBase
159/// {
160/// public:
161/// CMyAddon() { }
162/// ADDON_STATUS CreateInstance(int instanceType,
163/// std::string instanceID,
164/// KODI_HANDLE instance,
165/// KODI_HANDLE& addonInstance) override;
166/// };
167///
168/// /* If you use only one instance in your add-on, can be instanceType and
169/// * instanceID ignored */
170/// ADDON_STATUS CMyAddon::CreateInstance(int instanceType,
171/// std::string instanceID,
172/// KODI_HANDLE instance,
173/// KODI_HANDLE& addonInstance)
174/// {
175/// if (instanceType == ADDON_INSTANCE_AUDIODECODER)
176/// {
177/// kodi::Log(ADDON_LOG_NOTICE, "Creating my audio decoder");
178/// addonInstance = new CMyAudioDecoder(instance);
179/// return ADDON_STATUS_OK;
180/// }
181/// else if (...)
182/// {
183/// ...
184/// }
185/// return ADDON_STATUS_UNKNOWN;
186/// }
187///
188/// ADDONCREATOR(CMyAddon)
189/// ~~~~~~~~~~~~~
190///
191/// The destruction of the example class `CMyAudioDecoder` is called from
192/// Kodi's header. Manually deleting the add-on instance is not required.
193///
194class ATTRIBUTE_HIDDEN CInstanceAudioDecoder : public IAddonInstance
195{
196public:
197 //==========================================================================
198 /// @ingroup cpp_kodi_addon_audiodecoder
199 /// @brief Class constructor
200 ///
201 /// @param[in] instance The addon instance class handler given by Kodi
202 /// at \ref kodi::addon::CAddonBase::CreateInstance(...)
203 /// @param[in] kodiVersion [opt] Version used in Kodi for this instance, to
204 /// allow compatibility to older Kodi versions.
205 /// @note Recommended to set.
206 ///
207 explicit CInstanceAudioDecoder(KODI_HANDLE instance, const std::string& kodiVersion = "")
208 : IAddonInstance(ADDON_INSTANCE_AUDIODECODER,
209 !kodiVersion.empty() ? kodiVersion
210 : GetKodiTypeVersion(ADDON_INSTANCE_AUDIODECODER))
211 {
212 if (CAddonBase::m_interface->globalSingleInstance != nullptr)
213 throw std::logic_error("kodi::addon::CInstanceAudioDecoder: Creation of multiple together with single instance way is not allowed!");
214
215 SetAddonStruct(instance);
216 }
217 //--------------------------------------------------------------------------
218
219 //==========================================================================
220 /// @ingroup cpp_kodi_addon_audiodecoder
221 /// @brief Initialize a decoder
222 ///
223 /// @param[in] filename The file to read
224 /// @param[in] filecache The file cache size
225 /// @param[out] channels Number of channels in output stream
226 /// @param[out] samplerate Samplerate of output stream
227 /// @param[out] bitspersample Bits per sample in output stream
228 /// @param[out] totaltime Total time for stream
229 /// @param[out] bitrate Average bitrate of input stream
230 /// @param[out] format Data format for output stream
231 /// @param[out] channellist Channel mapping for output stream
232 /// @return true if successfully done, otherwise
233 /// false
234 ///
235 virtual bool Init(const std::string& filename, unsigned int filecache,
236 int& channels, int& samplerate,
237 int& bitspersample, int64_t& totaltime,
238 int& bitrate, AEDataFormat& format,
239 std::vector<AEChannel>& channellist) = 0;
240 //--------------------------------------------------------------------------
241
242 //==========================================================================
243 /// @ingroup cpp_kodi_addon_audiodecoder
244 /// @brief Produce some noise
245 ///
246 /// @param[in] buffer Output buffer
247 /// @param[in] size Size of output buffer
248 /// @param[out] actualsize Actual number of bytes written to output buffer
249 /// @return Return with following possible values:
250 /// | Value | Description |
251 /// |:-----:|:-----------------------------|
252 /// | 0 | on success
253 /// | -1 | on end of stream
254 /// | 1 | on failure
255 ///
256 virtual int ReadPCM(uint8_t* buffer, int size, int& actualsize) = 0;
257 //--------------------------------------------------------------------------
258
259 //==========================================================================
260 /// @ingroup cpp_kodi_addon_audiodecoder
261 /// @brief Seek in output stream
262 ///
263 /// @param[in] time Time position to seek to in milliseconds
264 /// @return Time position seek ended up on
265 ///
266 virtual int64_t Seek(int64_t time) { return time; }
267 //--------------------------------------------------------------------------
268
269 //==========================================================================
270 /// @ingroup cpp_kodi_addon_audiodecoder
271 /// @brief Read tag of a file
272 ///
273 /// @param[in] file File to read tag for
274 /// @param[out] title Title of file
275 /// @param[out] artist Artist of file
276 /// @param[out] length Length of file
277 /// @return True on success, false on failure
278 ///
279 virtual bool ReadTag(const std::string& file, std::string& title, std::string& artist, int& length) { return false; }
280 //--------------------------------------------------------------------------
281
282 //==========================================================================
283 /// @ingroup cpp_kodi_addon_audiodecoder
284 /// @brief Get number of tracks in a file
285 ///
286 /// @param[in] file File to read tag for
287 /// @return Number of tracks in file
288 ///
289 virtual int TrackCount(const std::string& file) { return 1; }
290 //--------------------------------------------------------------------------
291
292private:
293 void SetAddonStruct(KODI_HANDLE instance)
294 {
295 if (instance == nullptr)
296 throw std::logic_error("kodi::addon::CInstanceAudioDecoder: Creation with empty addon structure not allowed, table must be given from Kodi!");
297
298 m_instanceData = static_cast<AddonInstance_AudioDecoder*>(instance);
299
300 m_instanceData->toAddon.addonInstance = this;
301 m_instanceData->toAddon.init = ADDON_Init;
302 m_instanceData->toAddon.read_pcm = ADDON_ReadPCM;
303 m_instanceData->toAddon.seek = ADDON_Seek;
304 m_instanceData->toAddon.read_tag = ADDON_ReadTag;
305 m_instanceData->toAddon.track_count = ADDON_TrackCount;
306 }
307
308 inline static bool ADDON_Init(const AddonInstance_AudioDecoder* instance, const char* file, unsigned int filecache,
309 int* channels, int* samplerate,
310 int* bitspersample, int64_t* totaltime,
311 int* bitrate, AEDataFormat* format,
312 const AEChannel** info)
313 {
314 instance->toAddon.addonInstance->m_channelList.clear();
315 bool ret = instance->toAddon.addonInstance->Init(file, filecache, *channels,
316 *samplerate, *bitspersample,
317 *totaltime, *bitrate, *format,
318 instance->toAddon.addonInstance->m_channelList);
319 if (!instance->toAddon.addonInstance->m_channelList.empty())
320 {
321 if (instance->toAddon.addonInstance->m_channelList.back() != AE_CH_NULL)
322 instance->toAddon.addonInstance->m_channelList.push_back(AE_CH_NULL);
323 *info = instance->toAddon.addonInstance->m_channelList.data();
324 }
325 else
326 *info = nullptr;
327 return ret;
328 }
329
330 inline static int ADDON_ReadPCM(const AddonInstance_AudioDecoder* instance, uint8_t* buffer, int size, int* actualsize)
331 {
332 return instance->toAddon.addonInstance->ReadPCM(buffer, size, *actualsize);
333 }
334
335 inline static int64_t ADDON_Seek(const AddonInstance_AudioDecoder* instance, int64_t time)
336 {
337 return instance->toAddon.addonInstance->Seek(time);
338 }
339
340 inline static bool ADDON_ReadTag(const AddonInstance_AudioDecoder* instance, const char* file, char* title, char* artist, int* length)
341 {
342 std::string intTitle;
343 std::string intArtist;
344 bool ret = instance->toAddon.addonInstance->ReadTag(file, intTitle, intArtist, *length);
345 if (ret)
346 {
347 strncpy(title, intTitle.c_str(), ADDON_STANDARD_STRING_LENGTH_SMALL-1);
348 strncpy(artist, intArtist.c_str(), ADDON_STANDARD_STRING_LENGTH_SMALL-1);
349 }
350 return ret;
351 }
352
353 inline static int ADDON_TrackCount(const AddonInstance_AudioDecoder* instance, const char* file)
354 {
355 return instance->toAddon.addonInstance->TrackCount(file);
356 }
357
358 std::vector<AEChannel> m_channelList;
359 AddonInstance_AudioDecoder* m_instanceData;
360};
361
362} /* namespace addon */
363} /* namespace kodi */
diff --git a/xbmc/addons/kodi-addon-dev-kit/include/kodi/addon-instance/AudioEncoder.h b/xbmc/addons/kodi-addon-dev-kit/include/kodi/addon-instance/AudioEncoder.h
deleted file mode 100644
index 36257e1..0000000
--- a/xbmc/addons/kodi-addon-dev-kit/include/kodi/addon-instance/AudioEncoder.h
+++ /dev/null
@@ -1,218 +0,0 @@
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
13namespace kodi { namespace addon { class CInstanceAudioEncoder; }}
14
15extern "C"
16{
17
18 typedef struct AddonProps_AudioEncoder
19 {
20 int dummy;
21 } AddonProps_AudioEncoder;
22
23 typedef struct AddonToKodiFuncTable_AudioEncoder
24 {
25 void* kodiInstance;
26 int (*write) (void* kodiInstance, const uint8_t* data, int len);
27 int64_t (*seek)(void* kodiInstance, int64_t pos, int whence);
28 } AddonToKodiFuncTable_AudioEncoder;
29
30 struct AddonInstance_AudioEncoder;
31 typedef struct KodiToAddonFuncTable_AudioEncoder
32 {
33 kodi::addon::CInstanceAudioEncoder* addonInstance;
34 bool (__cdecl* start) (const AddonInstance_AudioEncoder* instance, int in_channels, int in_rate, int in_bits,
35 const char* title, const char* artist,
36 const char* albumartist, const char* album,
37 const char* year, const char* track,
38 const char* genre, const char* comment,
39 int track_length);
40 int (__cdecl* encode) (const AddonInstance_AudioEncoder* instance, int num_bytes_read, const uint8_t* pbt_stream);
41 bool (__cdecl* finish) (const AddonInstance_AudioEncoder* instance);
42 } KodiToAddonFuncTable_AudioEncoder;
43
44 typedef struct AddonInstance_AudioEncoder
45 {
46 AddonProps_AudioEncoder props;
47 AddonToKodiFuncTable_AudioEncoder toKodi;
48 KodiToAddonFuncTable_AudioEncoder toAddon;
49 } AddonInstance_AudioEncoder;
50
51} /* extern "C" */
52
53namespace kodi
54{
55namespace addon
56{
57
58 class ATTRIBUTE_HIDDEN CInstanceAudioEncoder : public IAddonInstance
59 {
60 public:
61 //==========================================================================
62 /// @brief Class constructor
63 ///
64 /// @param[in] instance The from Kodi given instance given be
65 /// add-on CreateInstance call with instance
66 /// id ADDON_INSTANCE_AUDIOENCODER.
67 /// @param[in] kodiVersion [opt] Version used in Kodi for this instance, to
68 /// allow compatibility to older Kodi versions.
69 /// @note Recommended to set.
70 ///
71 explicit CInstanceAudioEncoder(KODI_HANDLE instance, const std::string& kodiVersion = "")
72 : IAddonInstance(ADDON_INSTANCE_AUDIOENCODER,
73 !kodiVersion.empty() ? kodiVersion
74 : GetKodiTypeVersion(ADDON_INSTANCE_AUDIOENCODER))
75 {
76 if (CAddonBase::m_interface->globalSingleInstance != nullptr)
77 throw std::logic_error("kodi::addon::CInstanceAudioEncoder: Creation of multiple together with single instance way is not allowed!");
78
79 SetAddonStruct(instance);
80 }
81 //--------------------------------------------------------------------------
82
83 //==========================================================================
84 /// \brief Start encoder (**required**)
85 ///
86 /// \param[in] inChannels Number of channels
87 /// \param[in] inRate Sample rate of input data
88 /// \param[in] inBits Bits per sample in input data
89 /// \param[in] title The title of the song
90 /// \param[in] artist The artist of the song
91 /// \param[in] albumartist The albumartist of the song
92 /// \param[in] year The year of the song
93 /// \param[in] track The track number of the song
94 /// \param[in] genre The genre of the song
95 /// \param[in] comment A comment to attach to the song
96 /// \param[in] trackLength Total track length in seconds
97 /// \return True on success, false on failure.
98 ///
99 virtual bool Start(int inChannels,
100 int inRate,
101 int inBits,
102 const std::string& title,
103 const std::string& artist,
104 const std::string& albumartist,
105 const std::string& album,
106 const std::string& year,
107 const std::string& track,
108 const std::string& genre,
109 const std::string& comment,
110 int trackLength) = 0;
111 //--------------------------------------------------------------------------
112
113 //==========================================================================
114 /// \brief Encode a chunk of audio (**required**)
115 ///
116 /// \param[in] numBytesRead Number of bytes in input buffer
117 /// \param[in] pbtStream the input buffer
118 /// \return Number of bytes consumed
119 ///
120 virtual int Encode(int numBytesRead, const uint8_t* pbtStream) = 0;
121 //--------------------------------------------------------------------------
122
123 //==========================================================================
124 /// \brief Finalize encoding (**optional**)
125 ///
126 /// \return True on success, false on failure.
127 ///
128 virtual bool Finish() { return true; }
129 //--------------------------------------------------------------------------
130
131 //==========================================================================
132 /// \brief Write block of data
133 ///
134 /// \param[in] data Pointer to the array of elements to be
135 /// written
136 /// \param[in] length Size in bytes to be written.
137 /// \return The total number of bytes
138 /// successfully written is returned.
139 int Write(const uint8_t* data, int length)
140 {
141 return m_instanceData->toKodi.write(m_instanceData->toKodi.kodiInstance, data, length);
142 }
143 //--------------------------------------------------------------------------
144
145 //==========================================================================
146 /// \brief Set the file's current position.
147 ///
148 /// The whence argument is optional and defaults to SEEK_SET (0)
149 ///
150 /// \param[in] position the position that you want to seek to
151 /// \param[in] whence [optional] offset relative to
152 /// You can set the value of whence to one
153 /// of three things:
154 /// | Value | int | Description |
155 /// |:--------:|:---:|:---------------------------------------------------|
156 /// | 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.
157 /// | 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."
158 /// | 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.
159 ///
160 /// \return Returns the resulting offset location as
161 /// measured in bytes from the beginning of
162 /// the file. On error, the value -1 is
163 /// returned.
164 int64_t Seek(int64_t position, int whence = SEEK_SET)
165 {
166 return m_instanceData->toKodi.seek(m_instanceData->toKodi.kodiInstance, position, whence);
167 }
168 //--------------------------------------------------------------------------
169
170 private:
171 void SetAddonStruct(KODI_HANDLE instance)
172 {
173 if (instance == nullptr)
174 throw std::logic_error("kodi::addon::CInstanceAudioEncoder: Creation with empty addon structure not allowed, table must be given from Kodi!");
175
176 m_instanceData = static_cast<AddonInstance_AudioEncoder*>(instance);
177 m_instanceData->toAddon.addonInstance = this;
178 m_instanceData->toAddon.start = ADDON_Start;
179 m_instanceData->toAddon.encode = ADDON_Encode;
180 m_instanceData->toAddon.finish = ADDON_Finish;
181 }
182
183 inline static bool ADDON_Start(const AddonInstance_AudioEncoder* instance, int inChannels, int inRate, int inBits,
184 const char* title, const char* artist,
185 const char* albumartist, const char* album,
186 const char* year, const char* track,
187 const char* genre, const char* comment,
188 int trackLength)
189 {
190 return instance->toAddon.addonInstance->Start(inChannels,
191 inRate,
192 inBits,
193 title,
194 artist,
195 albumartist,
196 album,
197 year,
198 track,
199 genre,
200 comment,
201 trackLength);
202 }
203
204 inline static int ADDON_Encode(const AddonInstance_AudioEncoder* instance, int numBytesRead, const uint8_t* pbtStream)
205 {
206 return instance->toAddon.addonInstance->Encode(numBytesRead, pbtStream);
207 }
208
209 inline static bool ADDON_Finish(const AddonInstance_AudioEncoder* instance)
210 {
211 return instance->toAddon.addonInstance->Finish();
212 }
213
214 AddonInstance_AudioEncoder* m_instanceData;
215 };
216
217} /* namespace addon */
218} /* namespace kodi */
diff --git a/xbmc/addons/kodi-addon-dev-kit/include/kodi/addon-instance/CMakeLists.txt b/xbmc/addons/kodi-addon-dev-kit/include/kodi/addon-instance/CMakeLists.txt
deleted file mode 100644
index 8fa6e05..0000000
--- a/xbmc/addons/kodi-addon-dev-kit/include/kodi/addon-instance/CMakeLists.txt
+++ /dev/null
@@ -1,16 +0,0 @@
1set(HEADERS AudioDecoder.h
2 AudioEncoder.h
3 Game.h
4 ImageDecoder.h
5 Inputstream.h
6 Peripheral.h
7 PeripheralUtils.h
8 PVR.h
9 Screensaver.h
10 VFS.h
11 VideoCodec.h
12 Visualization.h)
13
14if(NOT ENABLE_STATIC_LIBS)
15 core_add_library(addons_kodi-addon-dev-kit_include_kodi_addon-instance)
16endif()
diff --git a/xbmc/addons/kodi-addon-dev-kit/include/kodi/addon-instance/Game.h b/xbmc/addons/kodi-addon-dev-kit/include/kodi/addon-instance/Game.h
deleted file mode 100644
index a53f1e7..0000000
--- a/xbmc/addons/kodi-addon-dev-kit/include/kodi/addon-instance/Game.h
+++ /dev/null
@@ -1,2360 +0,0 @@
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
13#ifdef BUILD_KODI_ADDON
14#include "XBMC_vkeys.h"
15#else
16#include "input/XBMC_vkeys.h"
17#endif
18
19//==============================================================================
20/// @addtogroup cpp_kodi_addon_game
21///
22/// To use on Libretro and for stand-alone games or emulators that does not use
23/// the Libretro API.
24///
25/// Possible examples could be, Nvidia GameStream via Limelight or WINE capture
26/// could possible through the Game API.
27///
28
29namespace kodi
30{
31namespace addon
32{
33class CInstanceGame;
34}
35} // namespace kodi
36
37extern "C"
38{
39
40//==============================================================================
41/// \defgroup cpp_kodi_addon_game_Defs Definitions, structures and enumerators
42/// \ingroup cpp_kodi_addon_game
43/// @brief **Game add-on instance definition values**
44//------------------------------------------------------------------------------
45
46//==============================================================================
47/// \ingroup cpp_kodi_addon_game_Defs
48/// @brief **Port ID used when topology is unknown**
49#define DEFAULT_PORT_ID "1"
50//------------------------------------------------------------------------------
51
52//==============================================================================
53/// \ingroup cpp_kodi_addon_game_Defs
54/// @brief **Game add-on error codes**
55///
56/// Used as return values on most Game related functions.
57///
58typedef enum GAME_ERROR
59{
60 /// @brief no error occurred
61 GAME_ERROR_NO_ERROR,
62
63 /// @brief an unknown error occurred
64 GAME_ERROR_UNKNOWN,
65
66 /// @brief the method that the frontend called is not implemented
67 GAME_ERROR_NOT_IMPLEMENTED,
68
69 /// @brief the command was rejected by the game client
70 GAME_ERROR_REJECTED,
71
72 /// @brief the parameters of the method that was called are invalid for this operation
73 GAME_ERROR_INVALID_PARAMETERS,
74
75 /// @brief the command failed
76 GAME_ERROR_FAILED,
77
78 /// @brief no game is loaded
79 GAME_ERROR_NOT_LOADED,
80
81 /// @brief game requires restricted resources
82 GAME_ERROR_RESTRICTED,
83} GAME_ERROR;
84//------------------------------------------------------------------------------
85
86//--==----==----==----==----==----==----==----==----==----==----==----==----==--
87/// \defgroup cpp_kodi_addon_game_Defs_AudioStream 1. Audio stream
88/// \ingroup cpp_kodi_addon_game_Defs
89/// @brief **The for Audio stream used data system**
90///
91/// Used to give Addon currently used audio stream configuration on Kodi and
92/// arrays to give related data to Kodi on callbacks.
93///
94//@{
95
96//==============================================================================
97/// @brief **Stream Format**
98///
99/// From Kodi requested specified audio sample format.
100///
101typedef enum GAME_PCM_FORMAT
102{
103 GAME_PCM_FORMAT_UNKNOWN,
104
105 /// @brief S16NE sample format
106 GAME_PCM_FORMAT_S16NE,
107} GAME_PCM_FORMAT;
108//------------------------------------------------------------------------------
109
110//==============================================================================
111/// @brief **Audio channel**
112///
113/// Channel identification flags.
114///
115typedef enum GAME_AUDIO_CHANNEL
116{
117 /// @brief Channel list terminator
118 GAME_CH_NULL,
119
120 /// @brief Channel front left
121 GAME_CH_FL,
122
123 /// @brief Channel front right
124 GAME_CH_FR,
125
126 /// @brief Channel front center
127 GAME_CH_FC,
128
129 /// @brief Channel Low Frequency Effects / Subwoofer
130 GAME_CH_LFE,
131
132 /// @brief Channel back left
133 GAME_CH_BL,
134
135 /// @brief Channel back right
136 GAME_CH_BR,
137
138 /// @brief Channel front left over center
139 GAME_CH_FLOC,
140
141 /// @brief Channel front right over center
142 GAME_CH_FROC,
143
144 /// @brief Channel back center
145 GAME_CH_BC,
146
147 /// @brief Channel surround/side left
148 GAME_CH_SL,
149
150 /// @brief Channel surround/side right
151 GAME_CH_SR,
152
153 /// @brief Channel top front left
154 GAME_CH_TFL,
155
156 /// @brief Channel top front right
157 GAME_CH_TFR,
158
159 /// @brief Channel top front center
160 GAME_CH_TFC,
161
162 /// @brief Channel top center
163 GAME_CH_TC,
164
165 /// @brief Channel top back left
166 GAME_CH_TBL,
167
168 /// @brief Channel top back right
169 GAME_CH_TBR,
170
171 /// @brief Channel top back center
172 GAME_CH_TBC,
173
174 /// @brief Channel bacl left over center
175 GAME_CH_BLOC,
176
177 /// @brief Channel back right over center
178 GAME_CH_BROC,
179} GAME_AUDIO_CHANNEL;
180//------------------------------------------------------------------------------
181
182//==============================================================================
183/// @brief **Game audio stream properties**
184///
185/// Used by Kodi to pass the currently required audio stream settings to the addon
186///
187typedef struct game_stream_audio_properties
188{
189 GAME_PCM_FORMAT format;
190 const GAME_AUDIO_CHANNEL* channel_map;
191} ATTRIBUTE_PACKED game_stream_audio_properties;
192//------------------------------------------------------------------------------
193
194//==============================================================================
195/// @brief **Audio stream packet**
196///
197/// This packet contains audio stream data passed to Kodi.
198///
199typedef struct game_stream_audio_packet
200{
201 /// @brief Pointer for audio stream data given to Kodi
202 const uint8_t *data;
203
204 /// @brief Size of data array
205 size_t size;
206} ATTRIBUTE_PACKED game_stream_audio_packet;
207//------------------------------------------------------------------------------
208
209//@}
210
211//--==----==----==----==----==----==----==----==----==----==----==----==----==--
212/// \defgroup cpp_kodi_addon_game_Defs_VideoStream 2. Video stream
213/// \ingroup cpp_kodi_addon_game_Defs
214/// @brief **The for Video stream used data system**
215///
216/// Used to give Addon currently used video stream configuration on Kodi and
217/// arrays to give related data to Kodi on callbacks.
218///
219//@{
220
221//==============================================================================
222/// @brief **Pixel format**
223///
224/// From Kodi requested specified video RGB color model format.
225///
226typedef enum GAME_PIXEL_FORMAT
227{
228 GAME_PIXEL_FORMAT_UNKNOWN,
229
230 /// @brief 0RGB8888 Format
231 GAME_PIXEL_FORMAT_0RGB8888,
232
233 /// @brief RGB565 Format
234 GAME_PIXEL_FORMAT_RGB565,
235
236 /// @brief 0RGB1555 Format
237 GAME_PIXEL_FORMAT_0RGB1555,
238} GAME_PIXEL_FORMAT;
239//------------------------------------------------------------------------------
240
241//==============================================================================
242/// @brief **Video rotation position**
243///
244/// To define position how video becomes shown.
245///
246typedef enum GAME_VIDEO_ROTATION
247{
248 /// @brief 0° and Without rotation
249 GAME_VIDEO_ROTATION_0,
250
251 /// @brief rotate 90° counterclockwise
252 GAME_VIDEO_ROTATION_90_CCW,
253
254 /// @brief rotate 180° counterclockwise
255 GAME_VIDEO_ROTATION_180_CCW,
256
257 /// @brief rotate 270° counterclockwise
258 GAME_VIDEO_ROTATION_270_CCW,
259} GAME_VIDEO_ROTATION;
260//------------------------------------------------------------------------------
261
262//==============================================================================
263/// @brief **Game video stream properties**
264///
265/// Used by Kodi to pass the currently required video stream settings to the addon
266///
267typedef struct game_stream_video_properties
268{
269 /// @brief The to used pixel format
270 GAME_PIXEL_FORMAT format;
271
272 /// @brief The nominal used width
273 unsigned int nominal_width;
274
275 /// @brief The nominal used height
276 unsigned int nominal_height;
277
278 /// @brief The maximal used width
279 unsigned int max_width;
280
281 /// @brief The maximal used height
282 unsigned int max_height;
283
284 /// @brief On video stream used aspect ration
285 ///
286 /// @note If aspect_ratio is <= 0.0, an aspect ratio of nominal_width / nominal_height is assumed
287 float aspect_ratio;
288} ATTRIBUTE_PACKED game_stream_video_properties;
289//------------------------------------------------------------------------------
290
291//==============================================================================
292/// @brief **Video stream packet**
293///
294/// This packet contains video stream data passed to Kodi.
295///
296typedef struct game_stream_video_packet
297{
298 /// @brief Video height
299 unsigned int width;
300
301 /// @brief Video width
302 unsigned int height;
303
304 /// @brief Width @ref GAME_VIDEO_ROTATION defined rotation angle.
305 GAME_VIDEO_ROTATION rotation;
306
307 /// @brief Pointer for video stream data given to Kodi
308 const uint8_t *data;
309
310 /// @brief Size of data array
311 size_t size;
312} ATTRIBUTE_PACKED game_stream_video_packet;
313//------------------------------------------------------------------------------
314
315//@}
316
317//--==----==----==----==----==----==----==----==----==----==----==----==----==--
318/// \defgroup cpp_kodi_addon_game_Defs_HardwareFramebuffer 3. Hardware framebuffer stream
319/// \ingroup cpp_kodi_addon_game_Defs
320/// @brief **Hardware framebuffer stream data**
321///
322//@{
323
324//==============================================================================
325/// @brief **Hardware framebuffer type**
326///
327typedef enum GAME_HW_CONTEXT_TYPE
328{
329 /// @brief None context
330 GAME_HW_CONTEXT_NONE,
331
332 /// @brief OpenGL 2.x. Driver can choose to use latest compatibility context
333 GAME_HW_CONTEXT_OPENGL,
334
335 /// @brief OpenGL ES 2.0
336 GAME_HW_CONTEXT_OPENGLES2,
337
338 /// @brief Modern desktop core GL context. Use major/minor fields to set GL version
339 GAME_HW_CONTEXT_OPENGL_CORE,
340
341 /// @brief OpenGL ES 3.0
342 GAME_HW_CONTEXT_OPENGLES3,
343
344 /// @brief OpenGL ES 3.1+. Set major/minor fields.
345 GAME_HW_CONTEXT_OPENGLES_VERSION,
346
347 /// @brief Vulkan
348 GAME_HW_CONTEXT_VULKAN
349} GAME_HW_CONTEXT_TYPE;
350//------------------------------------------------------------------------------
351
352//==============================================================================
353/// @brief **Hardware framebuffer properties**
354///
355typedef struct game_stream_hw_framebuffer_properties
356{
357 /// @brief The API to use.
358 ///
359 GAME_HW_CONTEXT_TYPE context_type;
360
361 /// @brief Set if render buffers should have depth component attached.
362 ///
363 /// @todo: Obsolete
364 ///
365 bool depth;
366
367 /// @brief Set if stencil buffers should be attached.
368 ///
369 /// If depth and stencil are true, a packed 24/8 buffer will be added.
370 /// Only attaching stencil is invalid and will be ignored.
371 ///
372 /// @todo: Obsolete.
373 ///
374 bool stencil;
375
376 /// @brief Use conventional bottom-left origin convention.
377 ///
378 /// If false, standard top-left origin semantics are used.
379 ///
380 /// @todo: Move to GL specific interface
381 ///
382 bool bottom_left_origin;
383
384 /// @brief Major version number for core GL context or GLES 3.1+.
385 unsigned int version_major;
386
387 /// @brief Minor version number for core GL context or GLES 3.1+.
388 unsigned int version_minor;
389
390 /// @brief If this is true, the frontend will go very far to avoid resetting context
391 /// in scenarios like toggling fullscreen, etc.
392 ///
393 /// @todo: Obsolete? Maybe frontend should just always assume this...
394 ///
395 /// The reset callback might still be called in extreme situations such as if
396 /// the context is lost beyond recovery.
397 ///
398 /// For optimal stability, set this to false, and allow context to be reset at
399 /// any time.
400 ///
401 bool cache_context;
402
403 /// @brief Creates a debug context.
404 bool debug_context;
405} ATTRIBUTE_PACKED game_stream_hw_framebuffer_properties;
406//------------------------------------------------------------------------------
407
408//==============================================================================
409/// @brief **Hardware framebuffer buffer**
410///
411typedef struct game_stream_hw_framebuffer_buffer
412{
413 /// @brief
414 uintptr_t framebuffer;
415} ATTRIBUTE_PACKED game_stream_hw_framebuffer_buffer;
416//------------------------------------------------------------------------------
417
418//==============================================================================
419/// @brief **Hardware framebuffer packet**
420///
421typedef struct game_stream_hw_framebuffer_packet
422{
423 /// @brief
424 uintptr_t framebuffer;
425} ATTRIBUTE_PACKED game_stream_hw_framebuffer_packet;
426//------------------------------------------------------------------------------
427
428//==============================================================================
429/// @brief **Hardware framebuffer process function address**
430///
431typedef void (*game_proc_address_t)(void);
432//------------------------------------------------------------------------------
433
434//@}
435
436//--==----==----==----==----==----==----==----==----==----==----==----==----==--
437/// \defgroup cpp_kodi_addon_game_Defs_SoftwareFramebuffer 4. Software framebuffer stream
438/// \ingroup cpp_kodi_addon_game_Defs
439/// @brief **Software framebuffer stream data**
440///
441//@{
442
443//==============================================================================
444/// @brief **Game video stream properties**
445///
446/// Used by Kodi to pass the currently required video stream settings to the addon
447///
448typedef game_stream_video_properties game_stream_sw_framebuffer_properties;
449//------------------------------------------------------------------------------
450
451//==============================================================================
452/// @brief **Hardware framebuffer type**
453///
454typedef struct game_stream_sw_framebuffer_buffer
455{
456 GAME_PIXEL_FORMAT format;
457 uint8_t *data;
458 size_t size;
459} ATTRIBUTE_PACKED game_stream_sw_framebuffer_buffer;
460//------------------------------------------------------------------------------
461
462//==============================================================================
463/// @brief **Video stream packet**
464///
465/// This packet contains video stream data passed to Kodi.
466///
467typedef game_stream_video_packet game_stream_sw_framebuffer_packet;
468//------------------------------------------------------------------------------
469
470//@}
471
472//--==----==----==----==----==----==----==----==----==----==----==----==----==--
473/// \defgroup cpp_kodi_addon_game_Defs_StreamTypes 5. Stream types
474/// \ingroup cpp_kodi_addon_game_Defs
475/// @brief **Stream types data**
476///
477//@{
478
479//==============================================================================
480/// @brief **Game stream types**
481///
482typedef enum GAME_STREAM_TYPE
483{
484 /// @brief Unknown
485 GAME_STREAM_UNKNOWN,
486
487 /// @brief Audio stream
488 GAME_STREAM_AUDIO,
489
490 /// @brief Video stream
491 GAME_STREAM_VIDEO,
492
493 /// @brief Hardware framebuffer
494 GAME_STREAM_HW_FRAMEBUFFER,
495
496 /// @brief Software framebuffer
497 GAME_STREAM_SW_FRAMEBUFFER,
498} GAME_STREAM_TYPE;
499//------------------------------------------------------------------------------
500
501//==============================================================================
502/// @brief **Immutable stream metadata**
503///
504/// This metadata is provided when the stream is opened. If any stream
505/// properties change, a new stream must be opened.
506///
507typedef struct game_stream_properties
508{
509 /// @brief
510 GAME_STREAM_TYPE type;
511 union
512 {
513 /// @brief
514 game_stream_audio_properties audio;
515
516 /// @brief
517 game_stream_video_properties video;
518
519 /// @brief
520 game_stream_hw_framebuffer_properties hw_framebuffer;
521
522 /// @brief
523 game_stream_sw_framebuffer_properties sw_framebuffer;
524 };
525} ATTRIBUTE_PACKED game_stream_properties;
526//------------------------------------------------------------------------------
527
528//==============================================================================
529/// @brief **Stream buffers for hardware rendering and zero-copy support**
530///
531typedef struct game_stream_buffer
532{
533 /// @brief
534 GAME_STREAM_TYPE type;
535 union
536 {
537 /// @brief
538 game_stream_hw_framebuffer_buffer hw_framebuffer;
539
540 /// @brief
541 game_stream_sw_framebuffer_buffer sw_framebuffer;
542 };
543} ATTRIBUTE_PACKED game_stream_buffer;
544//------------------------------------------------------------------------------
545
546//==============================================================================
547/// @brief **Stream packet and ephemeral metadata**
548///
549/// This packet contains stream data and accompanying metadata. The metadata
550/// is ephemeral, meaning it only applies to the current packet and can change
551/// from packet to packet in the same stream.
552///
553typedef struct game_stream_packet
554{
555 /// @brief
556 GAME_STREAM_TYPE type;
557 union
558 {
559 /// @brief
560 game_stream_audio_packet audio;
561
562 /// @brief
563 game_stream_video_packet video;
564
565 /// @brief
566 game_stream_hw_framebuffer_packet hw_framebuffer;
567
568 /// @brief
569 game_stream_sw_framebuffer_packet sw_framebuffer;
570 };
571} ATTRIBUTE_PACKED game_stream_packet;
572//------------------------------------------------------------------------------
573
574//@}
575
576//--==----==----==----==----==----==----==----==----==----==----==----==----==--
577/// \defgroup cpp_kodi_addon_game_Defs_GameTypes 6. Game types
578/// \ingroup cpp_kodi_addon_game_Defs
579/// @brief **Game types data**
580///
581//@{
582
583//==============================================================================
584/// @brief **Game reguin definition**
585///
586/// Returned from game_get_region()
587typedef enum GAME_REGION
588{
589 /// @brief Game region unknown
590 GAME_REGION_UNKNOWN,
591
592 /// @brief Game region NTSC
593 GAME_REGION_NTSC,
594
595 /// @brief Game region PAL
596 GAME_REGION_PAL,
597} GAME_REGION;
598//------------------------------------------------------------------------------
599
600//==============================================================================
601/// @brief **Special game types passed into game_load_game_special().**
602///
603/// @remark Only used when multiple ROMs are required.
604///
605typedef enum SPECIAL_GAME_TYPE
606{
607 /// @brief Game Type BSX
608 SPECIAL_GAME_TYPE_BSX,
609
610 /// @brief Game Type BSX slotted
611 SPECIAL_GAME_TYPE_BSX_SLOTTED,
612
613 /// @brief Game Type sufami turbo
614 SPECIAL_GAME_TYPE_SUFAMI_TURBO,
615
616 /// @brief Game Type super game boy
617 SPECIAL_GAME_TYPE_SUPER_GAME_BOY,
618} SPECIAL_GAME_TYPE;
619//------------------------------------------------------------------------------
620
621//==============================================================================
622/// @brief **Game Memory**
623///
624typedef enum GAME_MEMORY
625{
626 /// @brief Passed to game_get_memory_data/size(). If the memory type doesn't apply
627 /// to the implementation NULL/0 can be returned.
628 GAME_MEMORY_MASK = 0xff,
629
630 /// @brief Regular save ram.
631 ///
632 /// This ram is usually found on a game cartridge, backed
633 /// up by a battery. If save game data is too complex for a single memory
634 /// buffer, the SYSTEM_DIRECTORY environment callback can be used.
635 GAME_MEMORY_SAVE_RAM = 0,
636
637 /// @brief Some games have a built-in clock to keep track of time.
638 ///
639 /// This memory is usually just a couple of bytes to keep track of time.
640 GAME_MEMORY_RTC = 1,
641
642 /// @brief System ram lets a frontend peek into a game systems main RAM
643 GAME_MEMORY_SYSTEM_RAM = 2,
644
645 /// @brief Video ram lets a frontend peek into a game systems video RAM (VRAM)
646 GAME_MEMORY_VIDEO_RAM = 3,
647
648 /// @brief Special memory type
649 GAME_MEMORY_SNES_BSX_RAM = ((1 << 8) | GAME_MEMORY_SAVE_RAM),
650
651 /// @brief Special memory type
652 GAME_MEMORY_SNES_BSX_PRAM = ((2 << 8) | GAME_MEMORY_SAVE_RAM),
653
654 /// @brief Special memory type
655 GAME_MEMORY_SNES_SUFAMI_TURBO_A_RAM = ((3 << 8) | GAME_MEMORY_SAVE_RAM),
656
657 /// @brief Special memory type
658 GAME_MEMORY_SNES_SUFAMI_TURBO_B_RAM = ((4 << 8) | GAME_MEMORY_SAVE_RAM),
659
660 /// @brief Special memory type
661 GAME_MEMORY_SNES_GAME_BOY_RAM = ((5 << 8) | GAME_MEMORY_SAVE_RAM),
662
663 /// @brief Special memory type
664 GAME_MEMORY_SNES_GAME_BOY_RTC = ((6 << 8) | GAME_MEMORY_RTC),
665} GAME_MEMORY;
666//------------------------------------------------------------------------------
667
668//==============================================================================
669/// @brief **ID values for SIMD CPU features**
670typedef enum GAME_SIMD
671{
672 /// @brief SIMD CPU SSE
673 GAME_SIMD_SSE = (1 << 0),
674
675 /// @brief SIMD CPU SSE2
676 GAME_SIMD_SSE2 = (1 << 1),
677
678 /// @brief SIMD CPU VMX
679 GAME_SIMD_VMX = (1 << 2),
680
681 /// @brief SIMD CPU VMX128
682 GAME_SIMD_VMX128 = (1 << 3),
683
684 /// @brief SIMD CPU AVX
685 GAME_SIMD_AVX = (1 << 4),
686
687 /// @brief SIMD CPU NEON
688 GAME_SIMD_NEON = (1 << 5),
689
690 /// @brief SIMD CPU SSE3
691 GAME_SIMD_SSE3 = (1 << 6),
692
693 /// @brief SIMD CPU SSSE3
694 GAME_SIMD_SSSE3 = (1 << 7),
695
696 /// @brief SIMD CPU MMX
697 GAME_SIMD_MMX = (1 << 8),
698
699 /// @brief SIMD CPU MMXEXT
700 GAME_SIMD_MMXEXT = (1 << 9),
701
702 /// @brief SIMD CPU SSE4
703 GAME_SIMD_SSE4 = (1 << 10),
704
705 /// @brief SIMD CPU SSE42
706 GAME_SIMD_SSE42 = (1 << 11),
707
708 /// @brief SIMD CPU AVX2
709 GAME_SIMD_AVX2 = (1 << 12),
710
711 /// @brief SIMD CPU VFPU
712 GAME_SIMD_VFPU = (1 << 13),
713} GAME_SIMD;
714//------------------------------------------------------------------------------
715
716//@}
717
718//--==----==----==----==----==----==----==----==----==----==----==----==----==--
719/// \defgroup cpp_kodi_addon_game_Defs_InputTypes 7. Input types
720/// \ingroup cpp_kodi_addon_game_Defs
721/// @brief **Input types**
722///
723//@{
724
725//==============================================================================
726/// @brief
727typedef enum GAME_INPUT_EVENT_SOURCE
728{
729 /// @brief
730 GAME_INPUT_EVENT_DIGITAL_BUTTON,
731
732 /// @brief
733 GAME_INPUT_EVENT_ANALOG_BUTTON,
734
735 /// @brief
736 GAME_INPUT_EVENT_AXIS,
737
738 /// @brief
739 GAME_INPUT_EVENT_ANALOG_STICK,
740
741 /// @brief
742 GAME_INPUT_EVENT_ACCELEROMETER,
743
744 /// @brief
745 GAME_INPUT_EVENT_KEY,
746
747 /// @brief
748 GAME_INPUT_EVENT_RELATIVE_POINTER,
749
750 /// @brief
751 GAME_INPUT_EVENT_ABSOLUTE_POINTER,
752
753 /// @brief
754 GAME_INPUT_EVENT_MOTOR,
755} GAME_INPUT_EVENT_SOURCE;
756//------------------------------------------------------------------------------
757
758//==============================================================================
759/// @brief
760typedef enum GAME_KEY_MOD
761{
762 /// @brief
763 GAME_KEY_MOD_NONE = 0x0000,
764
765 /// @brief
766 GAME_KEY_MOD_SHIFT = 0x0001,
767
768 /// @brief
769 GAME_KEY_MOD_CTRL = 0x0002,
770
771 /// @brief
772 GAME_KEY_MOD_ALT = 0x0004,
773
774 /// @brief
775 GAME_KEY_MOD_META = 0x0008,
776
777 /// @brief
778 GAME_KEY_MOD_SUPER = 0x0010,
779
780 /// @brief
781 GAME_KEY_MOD_NUMLOCK = 0x0100,
782
783 /// @brief
784 GAME_KEY_MOD_CAPSLOCK = 0x0200,
785
786 /// @brief
787 GAME_KEY_MOD_SCROLLOCK = 0x0400,
788} GAME_KEY_MOD;
789//------------------------------------------------------------------------------
790
791//==============================================================================
792/// @brief Type of port on the virtual game console
793typedef enum GAME_PORT_TYPE
794{
795 /// @brief Game port unknown
796 GAME_PORT_UNKNOWN,
797
798 /// @brief Game port Keyboard
799 GAME_PORT_KEYBOARD,
800
801 /// @brief Game port mouse
802 GAME_PORT_MOUSE,
803
804 /// @brief Game port controller
805 GAME_PORT_CONTROLLER,
806} GAME_PORT_TYPE;
807//------------------------------------------------------------------------------
808
809/*! \cond PRIVATE */
810/*!
811 * @brief "C" Game add-on controller layout.
812 *
813 * Structure used to interface in "C" between Kodi and Addon.
814 *
815 * See @ref AddonGameControllerLayout for description of values.
816 */
817typedef struct game_controller_layout
818{
819 char* controller_id;
820 bool provides_input; // False for multitaps
821 char** digital_buttons;
822 unsigned int digital_button_count;
823 char** analog_buttons;
824 unsigned int analog_button_count;
825 char** analog_sticks;
826 unsigned int analog_stick_count;
827 char** accelerometers;
828 unsigned int accelerometer_count;
829 char** keys;
830 unsigned int key_count;
831 char** rel_pointers;
832 unsigned int rel_pointer_count;
833 char** abs_pointers;
834 unsigned int abs_pointer_count;
835 char** motors;
836 unsigned int motor_count;
837} ATTRIBUTE_PACKED game_controller_layout;
838 /*! \endcond */
839
840//==============================================================================
841/// @brief
842struct AddonGameControllerLayout
843{
844 /*! \cond PRIVATE */
845 explicit AddonGameControllerLayout() = default;
846 AddonGameControllerLayout(const game_controller_layout& layout)
847 {
848 controller_id = layout.controller_id;
849 provides_input = layout.provides_input;
850 for (unsigned int i = 0; i < layout.digital_button_count; ++i)
851 digital_buttons.push_back(layout.digital_buttons[i]);
852 for (unsigned int i = 0; i < layout.analog_button_count; ++i)
853 analog_buttons.push_back(layout.analog_buttons[i]);
854 for (unsigned int i = 0; i < layout.analog_stick_count; ++i)
855 analog_sticks.push_back(layout.analog_sticks[i]);
856 for (unsigned int i = 0; i < layout.accelerometer_count; ++i)
857 accelerometers.push_back(layout.accelerometers[i]);
858 for (unsigned int i = 0; i < layout.key_count; ++i)
859 keys.push_back(layout.keys[i]);
860 for (unsigned int i = 0; i < layout.rel_pointer_count; ++i)
861 rel_pointers.push_back(layout.rel_pointers[i]);
862 for (unsigned int i = 0; i < layout.abs_pointer_count; ++i)
863 abs_pointers.push_back(layout.abs_pointers[i]);
864 for (unsigned int i = 0; i < layout.motor_count; ++i)
865 motors.push_back(layout.motors[i]);
866 }
867 /*! \endcond */
868
869 /// @brief
870 std::string controller_id;
871
872 /// @brief False for multitaps
873 bool provides_input;
874
875 /// @brief
876 std::vector<std::string> digital_buttons;
877
878 /// @brief
879 std::vector<std::string> analog_buttons;
880
881 /// @brief
882 std::vector<std::string> analog_sticks;
883
884 /// @brief
885 std::vector<std::string> accelerometers;
886
887 /// @brief
888 std::vector<std::string> keys;
889
890 /// @brief
891 std::vector<std::string> rel_pointers;
892
893 /// @brief
894 std::vector<std::string> abs_pointers;
895
896 /// @brief
897 std::vector<std::string> motors;
898};
899//------------------------------------------------------------------------------
900
901struct game_input_port;
902
903//==============================================================================
904/// @brief Device that can provide input
905typedef struct game_input_device
906{
907 /// @brief ID used in the Kodi controller API
908 const char* controller_id;
909
910 /// @brief
911 const char* port_address;
912
913 /// @brief
914 game_input_port* available_ports;
915
916 /// @brief
917 unsigned int port_count;
918} ATTRIBUTE_PACKED game_input_device;
919//------------------------------------------------------------------------------
920
921//==============================================================================
922/// @brief Port that can provide input
923///
924/// Ports can accept multiple devices and devices can have multiple ports, so
925/// the topology of possible configurations is a tree structure of alternating
926/// port and device nodes.
927///
928typedef struct game_input_port
929{
930 /// @brief
931 GAME_PORT_TYPE type;
932
933 /// @brief Required for GAME_PORT_CONTROLLER type
934 const char* port_id;
935
936 /// @brief
937 game_input_device* accepted_devices;
938
939 /// @brief
940 unsigned int device_count;
941} ATTRIBUTE_PACKED game_input_port;
942//------------------------------------------------------------------------------
943
944//==============================================================================
945/// @brief The input topology is the possible ways to connect input devices
946///
947/// This represents the logical topology, which is the possible connections that
948/// the game client's logic can handle. It is strictly a subset of the physical
949/// topology. Loops are not allowed.
950///
951typedef struct game_input_topology
952{
953 /// @brief The list of ports on the virtual game console
954 game_input_port *ports;
955
956 /// @brief The number of ports
957 unsigned int port_count;
958
959 /// @brief A limit on the number of input-providing devices, or -1 for no limit
960 int player_limit;
961} ATTRIBUTE_PACKED game_input_topology;
962//------------------------------------------------------------------------------
963
964//==============================================================================
965/// @brief
966typedef struct game_digital_button_event
967{
968 /// @brief
969 bool pressed;
970} ATTRIBUTE_PACKED game_digital_button_event;
971//------------------------------------------------------------------------------
972
973//==============================================================================
974/// @brief
975typedef struct game_analog_button_event
976{
977 /// @brief
978 float magnitude;
979} ATTRIBUTE_PACKED game_analog_button_event;
980//------------------------------------------------------------------------------
981
982//==============================================================================
983/// @brief
984typedef struct game_axis_event
985{
986 /// @brief
987 float position;
988} ATTRIBUTE_PACKED game_axis_event;
989//------------------------------------------------------------------------------
990
991//==============================================================================
992/// @brief
993typedef struct game_analog_stick_event
994{
995 /// @brief
996 float x;
997
998 /// @brief
999 float y;
1000} ATTRIBUTE_PACKED game_analog_stick_event;
1001//------------------------------------------------------------------------------
1002
1003//==============================================================================
1004/// @brief
1005typedef struct game_accelerometer_event
1006{
1007 /// @brief
1008 float x;
1009
1010 /// @brief
1011 float y;
1012
1013 /// @brief
1014 float z;
1015} ATTRIBUTE_PACKED game_accelerometer_event;
1016//------------------------------------------------------------------------------
1017
1018//==============================================================================
1019/// @brief
1020typedef struct game_key_event
1021{
1022 /// @brief
1023 bool pressed;
1024
1025 /// @brief If the keypress generates a printing character
1026 ///
1027 /// The unicode value contains the character generated. If the key is a
1028 /// non-printing character, e.g. a function or arrow key, the unicode value
1029 /// is zero.
1030 uint32_t unicode;
1031
1032 /// @brief
1033 GAME_KEY_MOD modifiers;
1034} ATTRIBUTE_PACKED game_key_event;
1035//------------------------------------------------------------------------------
1036
1037//==============================================================================
1038/// @brief
1039typedef struct game_rel_pointer_event
1040{
1041 /// @brief
1042 int x;
1043
1044 /// @brief
1045 int y;
1046} ATTRIBUTE_PACKED game_rel_pointer_event;
1047//------------------------------------------------------------------------------
1048
1049//==============================================================================
1050/// @brief
1051typedef struct game_abs_pointer_event
1052{
1053 /// @brief
1054 bool pressed;
1055
1056 /// @brief
1057 float x;
1058
1059 /// @brief
1060 float y;
1061} ATTRIBUTE_PACKED game_abs_pointer_event;
1062//------------------------------------------------------------------------------
1063
1064//==============================================================================
1065/// @brief
1066typedef struct game_motor_event
1067{
1068 /// @brief
1069 float magnitude;
1070} ATTRIBUTE_PACKED game_motor_event;
1071//------------------------------------------------------------------------------
1072
1073//==============================================================================
1074/// @brief
1075typedef struct game_input_event
1076{
1077 /// @brief
1078 GAME_INPUT_EVENT_SOURCE type;
1079
1080 /// @brief
1081 const char* controller_id;
1082
1083 /// @brief
1084 GAME_PORT_TYPE port_type;
1085
1086 /// @brief
1087 const char* port_address;
1088
1089 /// @brief
1090 const char* feature_name;
1091 union {
1092 /// @brief
1093 struct game_digital_button_event digital_button;
1094
1095 /// @brief
1096 struct game_analog_button_event analog_button;
1097
1098 /// @brief
1099 struct game_axis_event axis;
1100
1101 /// @brief
1102 struct game_analog_stick_event analog_stick;
1103
1104 /// @brief
1105 struct game_accelerometer_event accelerometer;
1106
1107 /// @brief
1108 struct game_key_event key;
1109
1110 /// @brief
1111 struct game_rel_pointer_event rel_pointer;
1112
1113 /// @brief
1114 struct game_abs_pointer_event abs_pointer;
1115
1116 /// @brief
1117 struct game_motor_event motor;
1118 };
1119} ATTRIBUTE_PACKED game_input_event;
1120//------------------------------------------------------------------------------
1121
1122//@}
1123
1124//--==----==----==----==----==----==----==----==----==----==----==----==----==--
1125/// \defgroup cpp_kodi_addon_game_Defs_EnvironmentTypes 8. Environment types
1126/// \ingroup cpp_kodi_addon_game_Defs
1127/// @brief **Environment types**
1128///
1129//@{
1130
1131//==============================================================================
1132/// @brief Game system timing
1133///
1134struct game_system_timing
1135{
1136 /// @brief FPS of video content.
1137 double fps;
1138
1139 /// @brief Sampling rate of audio.
1140 double sample_rate;
1141};
1142//------------------------------------------------------------------------------
1143
1144//@}
1145
1146
1147//--==----==----==----==----==----==----==----==----==----==----==----==----==--
1148
1149/*!
1150 * @brief Game properties
1151 *
1152 * Not to be used outside this header.
1153 */
1154typedef struct AddonProps_Game
1155{
1156 /*!
1157 * The path of the game client being loaded.
1158 */
1159 const char* game_client_dll_path;
1160
1161 /*!
1162 * Paths to proxy DLLs used to load the game client.
1163 */
1164 const char** proxy_dll_paths;
1165
1166 /*!
1167 * Number of proxy DLL paths provided.
1168 */
1169 unsigned int proxy_dll_count;
1170
1171 /*!
1172 * The "system" directories of the frontend. These directories can be used to
1173 * store system-specific ROMs such as BIOSes, configuration data, etc.
1174 */
1175 const char** resource_directories;
1176
1177 /*!
1178 * Number of resource directories provided
1179 */
1180 unsigned int resource_directory_count;
1181
1182 /*!
1183 * The writable directory of the frontend. This directory can be used to store
1184 * SRAM, memory cards, high scores, etc, if the game client cannot use the
1185 * regular memory interface, GetMemoryData().
1186 */
1187 const char* profile_directory;
1188
1189 /*!
1190 * The value of the <supports_vfs> property from addon.xml
1191 */
1192 bool supports_vfs;
1193
1194 /*!
1195 * The extensions in the <extensions> property from addon.xml
1196 */
1197 const char** extensions;
1198
1199 /*!
1200 * Number of extensions provided
1201 */
1202 unsigned int extension_count;
1203} AddonProps_Game;
1204
1205typedef AddonProps_Game game_client_properties;
1206
1207/*! Structure to transfer the methods from kodi_game_dll.h to Kodi */
1208
1209struct AddonInstance_Game;
1210
1211/*!
1212 * @brief Game callbacks
1213 *
1214 * Not to be used outside this header.
1215 */
1216typedef struct AddonToKodiFuncTable_Game
1217{
1218 KODI_HANDLE kodiInstance;
1219
1220 void (*CloseGame)(void* kodiInstance);
1221 void* (*OpenStream)(void*, const game_stream_properties*);
1222 bool (*GetStreamBuffer)(void*, void*, unsigned int, unsigned int, game_stream_buffer*);
1223 void (*AddStreamData)(void*, void*, const game_stream_packet*);
1224 void (*ReleaseStreamBuffer)(void*, void*, game_stream_buffer*);
1225 void (*CloseStream)(void*, void*);
1226 game_proc_address_t (*HwGetProcAddress)(void* kodiInstance, const char* symbol);
1227 bool (*InputEvent)(void* kodiInstance, const game_input_event* event);
1228} AddonToKodiFuncTable_Game;
1229
1230/*!
1231 * @brief Game function hooks
1232 *
1233 * Not to be used outside this header.
1234 */
1235typedef struct KodiToAddonFuncTable_Game
1236{
1237 kodi::addon::CInstanceGame* addonInstance;
1238
1239 GAME_ERROR(__cdecl* LoadGame)(const AddonInstance_Game*, const char*);
1240 GAME_ERROR(__cdecl* LoadGameSpecial)
1241 (const AddonInstance_Game*, SPECIAL_GAME_TYPE, const char**, size_t);
1242 GAME_ERROR(__cdecl* LoadStandalone)(const AddonInstance_Game*);
1243 GAME_ERROR(__cdecl* UnloadGame)(const AddonInstance_Game*);
1244 GAME_ERROR(__cdecl* GetGameTiming)(const AddonInstance_Game*, game_system_timing*);
1245 GAME_REGION(__cdecl* GetRegion)(const AddonInstance_Game*);
1246 bool(__cdecl* RequiresGameLoop)(const AddonInstance_Game*);
1247 GAME_ERROR(__cdecl* RunFrame)(const AddonInstance_Game*);
1248 GAME_ERROR(__cdecl* Reset)(const AddonInstance_Game*);
1249 GAME_ERROR(__cdecl* HwContextReset)(const AddonInstance_Game*);
1250 GAME_ERROR(__cdecl* HwContextDestroy)(const AddonInstance_Game*);
1251 bool(__cdecl* HasFeature)(const AddonInstance_Game*, const char*, const char*);
1252 game_input_topology*(__cdecl* GetTopology)(const AddonInstance_Game*);
1253 void(__cdecl* FreeTopology)(const AddonInstance_Game*, game_input_topology*);
1254 void(__cdecl* SetControllerLayouts)(const AddonInstance_Game*,
1255 const game_controller_layout*,
1256 unsigned int);
1257 bool(__cdecl* EnableKeyboard)(const AddonInstance_Game*, bool, const char*);
1258 bool(__cdecl* EnableMouse)(const AddonInstance_Game*, bool, const char*);
1259 bool(__cdecl* ConnectController)(const AddonInstance_Game*, bool, const char*, const char*);
1260 bool(__cdecl* InputEvent)(const AddonInstance_Game*, const game_input_event*);
1261 size_t(__cdecl* SerializeSize)(const AddonInstance_Game*);
1262 GAME_ERROR(__cdecl* Serialize)(const AddonInstance_Game*, uint8_t*, size_t);
1263 GAME_ERROR(__cdecl* Deserialize)(const AddonInstance_Game*, const uint8_t*, size_t);
1264 GAME_ERROR(__cdecl* CheatReset)(const AddonInstance_Game*);
1265 GAME_ERROR(__cdecl* GetMemory)(const AddonInstance_Game*, GAME_MEMORY, uint8_t**, size_t*);
1266 GAME_ERROR(__cdecl* SetCheat)(const AddonInstance_Game*, unsigned int, bool, const char*);
1267} KodiToAddonFuncTable_Game;
1268
1269/*!
1270 * @brief Game instance
1271 *
1272 * Not to be used outside this header.
1273 */
1274typedef struct AddonInstance_Game
1275{
1276 AddonProps_Game props;
1277 AddonToKodiFuncTable_Game toKodi;
1278 KodiToAddonFuncTable_Game toAddon;
1279} AddonInstance_Game;
1280
1281} /* extern "C" */
1282
1283namespace kodi
1284{
1285namespace addon
1286{
1287
1288//==============================================================================
1289///
1290/// \addtogroup cpp_kodi_addon_game
1291/// @brief \cpp_class{ kodi::addon::CInstanceGame }
1292/// **Game add-on instance**
1293///
1294/// This class is created at addon by Kodi.
1295///
1296//------------------------------------------------------------------------------
1297class ATTRIBUTE_HIDDEN CInstanceGame : public IAddonInstance
1298{
1299public:
1300 //============================================================================
1301 ///
1302 /// @defgroup cpp_kodi_addon_game_Base 1. Basic functions
1303 /// @ingroup cpp_kodi_addon_game
1304 /// @brief **Functions to manage the addon and get basic information about it**
1305 ///
1306 ///
1307 //@{
1308
1309 //============================================================================
1310 ///
1311 /// @brief Game class constructor
1312 ///
1313 /// Used by an add-on that only supports only Game and only in one instance.
1314 ///
1315 /// This class is created at addon by Kodi.
1316 ///
1317 ///
1318 /// --------------------------------------------------------------------------
1319 ///
1320 ///
1321 /// **Here's example about the use of this:**
1322 /// ~~~~~~~~~~~~~{.cpp}
1323 /// #include <kodi/addon-instance/Game.h>
1324 /// ...
1325 ///
1326 /// class ATTRIBUTE_HIDDEN CGameExample
1327 /// : public kodi::addon::CAddonBase,
1328 /// public kodi::addon::CInstanceGame
1329 /// {
1330 /// public:
1331 /// CGameExample()
1332 /// {
1333 /// }
1334 ///
1335 /// virtual ~CGameExample();
1336 /// {
1337 /// }
1338 ///
1339 /// ...
1340 /// };
1341 ///
1342 /// ADDONCREATOR(CGameExample)
1343 /// ~~~~~~~~~~~~~
1344 ///
1345 CInstanceGame() : IAddonInstance(ADDON_INSTANCE_GAME, GetKodiTypeVersion(ADDON_INSTANCE_GAME))
1346 {
1347 if (CAddonBase::m_interface->globalSingleInstance != nullptr)
1348 throw std::logic_error("kodi::addon::CInstanceGame: Creation of more as one in single "
1349 "instance way is not allowed!");
1350
1351 SetAddonStruct(CAddonBase::m_interface->firstKodiInstance);
1352 CAddonBase::m_interface->globalSingleInstance = this;
1353 }
1354 //----------------------------------------------------------------------------
1355
1356 //============================================================================
1357 ///
1358 /// @brief Destructor
1359 ///
1360 ~CInstanceGame() override = default;
1361 //----------------------------------------------------------------------------
1362
1363 //============================================================================
1364 ///
1365 /// @brief **Callback to Kodi Function**<br>The path of the game client being loaded.
1366 ///
1367 /// @return the used game client Dll path
1368 ///
1369 /// @remarks Only called from addon itself
1370 ///
1371 std::string GameClientDllPath() const
1372 {
1373 return m_instanceData->props.game_client_dll_path;
1374 }
1375 //----------------------------------------------------------------------------
1376
1377 //============================================================================
1378 ///
1379 /// @brief **Callback to Kodi Function**<br>Paths to proxy DLLs used to load the game client.
1380 ///
1381 /// @param[out] paths vector list to store available dll paths
1382 /// @return true if success and dll paths present
1383 ///
1384 /// @remarks Only called from addon itself
1385 ///
1386 bool ProxyDllPaths(std::vector<std::string>& paths)
1387 {
1388 for (unsigned int i = 0; i < m_instanceData->props.proxy_dll_count; ++i)
1389 {
1390 if (m_instanceData->props.proxy_dll_paths[i] != nullptr)
1391 paths.push_back(m_instanceData->props.proxy_dll_paths[i]);
1392 }
1393 return !paths.empty();
1394 }
1395 //----------------------------------------------------------------------------
1396
1397 //============================================================================
1398 ///
1399 /// @brief **Callback to Kodi Function**<br>The "system" directories of the frontend
1400 ///
1401 /// These directories can be used to store system-specific ROMs such as
1402 /// BIOSes, configuration data, etc.
1403 ///
1404 /// @return the used resource directory
1405 ///
1406 /// @remarks Only called from addon itself
1407 ///
1408 bool ResourceDirectories(std::vector<std::string>& dirs)
1409 {
1410 for (unsigned int i = 0; i < m_instanceData->props.resource_directory_count; ++i)
1411 {
1412 if (m_instanceData->props.resource_directories[i] != nullptr)
1413 dirs.push_back(m_instanceData->props.resource_directories[i]);
1414 }
1415 return !dirs.empty();
1416 }
1417 //----------------------------------------------------------------------------
1418
1419 //============================================================================
1420 ///
1421 /// @brief **Callback to Kodi Function**<br>The writable directory of the frontend
1422 ///
1423 /// This directory can be used to store SRAM, memory cards, high scores,
1424 /// etc, if the game client cannot use the regular memory interface,
1425 /// GetMemoryData().
1426 ///
1427 /// @return the used profile directory
1428 ///
1429 /// @remarks Only called from addon itself
1430 ///
1431 std::string ProfileDirectory() const
1432 {
1433 return m_instanceData->props.profile_directory;
1434 }
1435 //----------------------------------------------------------------------------
1436
1437 //============================================================================
1438 ///
1439 /// @brief **Callback to Kodi Function**<br>The value of the <supports_vfs> property from addon.xml
1440 ///
1441 /// @return true if VFS is supported
1442 ///
1443 /// @remarks Only called from addon itself
1444 ///
1445 bool SupportsVFS() const
1446 {
1447 return m_instanceData->props.supports_vfs;
1448 }
1449 //----------------------------------------------------------------------------
1450
1451 //============================================================================
1452 ///
1453 /// @brief **Callback to Kodi Function**<br>The extensions in the <extensions> property from addon.xml
1454 ///
1455 /// @param[out] extensions vector list to store available extension
1456 /// @return true if success and extensions present
1457 ///
1458 /// @remarks Only called from addon itself
1459 ///
1460 bool Extensions(std::vector<std::string>& extensions)
1461 {
1462 for (unsigned int i = 0; i < m_instanceData->props.extension_count; ++i)
1463 {
1464 if (m_instanceData->props.extensions[i] != nullptr)
1465 extensions.push_back(m_instanceData->props.extensions[i]);
1466 }
1467 return !extensions.empty();
1468 }
1469 //----------------------------------------------------------------------------
1470
1471 //@}
1472
1473//--==----==----==----==----==----==----==----==----==----==----==----==----==--
1474
1475 //============================================================================
1476 ///
1477 /// @defgroup cpp_kodi_addon_game_Operation 2. Game operations
1478 /// @ingroup cpp_kodi_addon_game
1479 /// @brief **Game operations**
1480 ///
1481 /// These are mandatory functions for using this addon to get the available
1482 /// channels.
1483 ///
1484 //@{
1485
1486 //============================================================================
1487 ///
1488 /// @brief Load a game
1489 ///
1490 /// @param[in] url The URL to load
1491 /// @return the error, or @ref GAME_ERROR_NO_ERROR if the game was loaded
1492 ///
1493 virtual GAME_ERROR LoadGame(const std::string& url)
1494 {
1495 return GAME_ERROR_NOT_IMPLEMENTED;
1496 }
1497 //----------------------------------------------------------------------------
1498
1499 //============================================================================
1500 ///
1501 /// @brief Load a game that requires multiple files
1502 ///
1503 /// @param[in] type The game type
1504 /// @param[in] urls An array of urls
1505 /// @return the error, or @ref GAME_ERROR_NO_ERROR if the game was loaded
1506 ///
1507 virtual GAME_ERROR LoadGameSpecial(SPECIAL_GAME_TYPE type, const std::vector<std::string>& urls)
1508 {
1509 return GAME_ERROR_NOT_IMPLEMENTED;
1510 }
1511 //----------------------------------------------------------------------------
1512
1513 //============================================================================
1514 ///
1515 /// @brief Begin playing without a game file
1516 ///
1517 /// If the add-on supports standalone mode, it must add the <supports_standalone>
1518 /// tag to the extension point in addon.xml:
1519 ///
1520 /// <supports_no_game>false</supports_no_game>
1521 ///
1522 /// @return the error, or @ref GAME_ERROR_NO_ERROR if the game add-on was loaded
1523 ///
1524 virtual GAME_ERROR LoadStandalone()
1525 {
1526 return GAME_ERROR_NOT_IMPLEMENTED;
1527 }
1528 //----------------------------------------------------------------------------
1529
1530 //============================================================================
1531 ///
1532 /// @brief Unload the current game
1533 ///
1534 /// Unloads a currently loaded game
1535 ///
1536 /// @return the error, or @ref GAME_ERROR_NO_ERROR if the game was unloaded
1537 ///
1538 virtual GAME_ERROR UnloadGame()
1539 {
1540 return GAME_ERROR_NOT_IMPLEMENTED;
1541 }
1542 //----------------------------------------------------------------------------
1543
1544 //============================================================================
1545 ///
1546 /// @brief Get timing information about the loaded game
1547 ///
1548 /// @param[out] timing_info The info structure to fill
1549 ///
1550 /// @return the error, or @ref GAME_ERROR_NO_ERROR if info was filled
1551 ///
1552 virtual GAME_ERROR GetGameTiming(game_system_timing& timing_info)
1553 {
1554 return GAME_ERROR_NOT_IMPLEMENTED;
1555 }
1556 //----------------------------------------------------------------------------
1557
1558 //============================================================================
1559 ///
1560 /// @brief Get region of the loaded game
1561 ///
1562 /// @return the region, or @ref GAME_REGION_UNKNOWN if unknown or no game is loaded
1563 ///
1564 virtual GAME_REGION GetRegion()
1565 {
1566 return GAME_REGION_UNKNOWN;
1567 }
1568 //----------------------------------------------------------------------------
1569
1570 //============================================================================
1571 ///
1572 /// @brief Return true if the client requires the frontend to provide a game loop
1573 ///
1574 /// The game loop is a thread that calls RunFrame() in a loop at a rate
1575 /// determined by the playback speed and the client's FPS.
1576 ///
1577 /// @return true if the frontend should provide a game loop, false otherwise
1578 ///
1579 virtual bool RequiresGameLoop()
1580 {
1581 return false;
1582 }
1583 //----------------------------------------------------------------------------
1584
1585 //============================================================================
1586 ///
1587 /// @brief Run a single frame for add-ons that use a game loop
1588 ///
1589 /// @return the error, or @ref GAME_ERROR_NO_ERROR if there was no error
1590 ///
1591 virtual GAME_ERROR RunFrame()
1592 {
1593 return GAME_ERROR_NOT_IMPLEMENTED;
1594 }
1595 //----------------------------------------------------------------------------
1596
1597 //============================================================================
1598 ///
1599 /// @brief Reset the current game
1600 ///
1601 /// @return the error, or @ref GAME_ERROR_NO_ERROR if the game was reset
1602 ///
1603 virtual GAME_ERROR Reset()
1604 {
1605 return GAME_ERROR_NOT_IMPLEMENTED;
1606 }
1607 //----------------------------------------------------------------------------
1608
1609 //==========================================================================
1610 ///
1611 /// @brief **Callback to Kodi Function**<br>Requests the frontend to stop the current game
1612 ///
1613 /// @remarks Only called from addon itself
1614 ///
1615 void CloseGame(void) { m_instanceData->toKodi.CloseGame(m_instanceData->toKodi.kodiInstance); }
1616 //----------------------------------------------------------------------------
1617
1618 //============================================================================
1619 ///
1620 /// @defgroup cpp_kodi_addon_game_Operation_CStream Class: CStream
1621 /// @ingroup cpp_kodi_addon_game_Operation
1622 /// @brief \cpp_class{ kodi::addon::CInstanceGame::CStream }
1623 /// **Game stream handler**
1624 ///
1625 /// This class will be integrated into the addon, which can then open it if
1626 /// necessary for the processing of an audio or video stream.
1627 ///
1628 ///
1629 /// @note Callback to Kodi class
1630 //@{
1631 class CStream
1632 {
1633 public:
1634 CStream() = default;
1635
1636 CStream(const game_stream_properties& properties)
1637 {
1638 Open(properties);
1639 }
1640
1641 ~CStream()
1642 {
1643 Close();
1644 }
1645
1646 //==========================================================================
1647 ///
1648 /// @ingroup cpp_kodi_addon_game_Operation_CStream
1649 /// @brief Create a stream for gameplay data
1650 ///
1651 /// @param[in] properties The stream properties
1652 /// @return A stream handle, or `nullptr` on failure
1653 ///
1654 /// @remarks Only called from addon itself
1655 ///
1656 bool Open(const game_stream_properties& properties)
1657 {
1658 if (!CAddonBase::m_interface->globalSingleInstance)
1659 return false;
1660
1661 if (m_handle)
1662 {
1663 kodi::Log(ADDON_LOG_INFO, "kodi::addon::CInstanceGame::CStream already becomes reopened");
1664 Close();
1665 }
1666
1667 AddonToKodiFuncTable_Game& cb =
1668 static_cast<CInstanceGame*>(CAddonBase::m_interface->globalSingleInstance)
1669 ->m_instanceData->toKodi;
1670 m_handle = cb.OpenStream(cb.kodiInstance, &properties);
1671 return m_handle != nullptr;
1672 }
1673 //--------------------------------------------------------------------------
1674
1675 //==========================================================================
1676 ///
1677 /// @ingroup cpp_kodi_addon_game_Operation_CStream
1678 /// @brief Free the specified stream
1679 ///
1680 /// @remarks Only called from addon itself
1681 ///
1682 void Close()
1683 {
1684 if (!m_handle || !CAddonBase::m_interface->globalSingleInstance)
1685 return;
1686
1687 AddonToKodiFuncTable_Game& cb =
1688 static_cast<CInstanceGame*>(CAddonBase::m_interface->globalSingleInstance)
1689 ->m_instanceData->toKodi;
1690 cb.CloseStream(cb.kodiInstance, m_handle);
1691 m_handle = nullptr;
1692 }
1693 //--------------------------------------------------------------------------
1694
1695 //==========================================================================
1696 ///
1697 /// @ingroup cpp_kodi_addon_game_Operation_CStream
1698 /// @brief Get a buffer for zero-copy stream data
1699 ///
1700 /// @param[in] width The framebuffer width, or 0 for no width specified
1701 /// @param[in] height The framebuffer height, or 0 for no height specified
1702 /// @param[out] buffer The buffer, or unmodified if false is returned
1703 /// @return True if buffer was set, false otherwise
1704 ///
1705 /// @note If this returns true, buffer must be freed using \ref ReleaseBuffer().
1706 ///
1707 /// @remarks Only called from addon itself
1708 ///
1709 bool GetBuffer(unsigned int width, unsigned int height, game_stream_buffer& buffer)
1710 {
1711 if (!m_handle || !CAddonBase::m_interface->globalSingleInstance)
1712 return false;
1713
1714 AddonToKodiFuncTable_Game& cb =
1715 static_cast<CInstanceGame*>(CAddonBase::m_interface->globalSingleInstance)
1716 ->m_instanceData->toKodi;
1717 return cb.GetStreamBuffer(cb.kodiInstance, m_handle, width, height, &buffer);
1718 }
1719 //--------------------------------------------------------------------------
1720
1721 //==========================================================================
1722 ///
1723 /// @ingroup cpp_kodi_addon_game_Operation_CStream
1724 /// @brief Add a data packet to a stream
1725 ///
1726 /// @param[in] packet The data packet
1727 ///
1728 /// @remarks Only called from addon itself
1729 ///
1730 void AddData(const game_stream_packet& packet)
1731 {
1732 if (!m_handle || !CAddonBase::m_interface->globalSingleInstance)
1733 return;
1734
1735 AddonToKodiFuncTable_Game& cb =
1736 static_cast<CInstanceGame*>(CAddonBase::m_interface->globalSingleInstance)
1737 ->m_instanceData->toKodi;
1738 cb.AddStreamData(cb.kodiInstance, m_handle, &packet);
1739 }
1740 //--------------------------------------------------------------------------
1741
1742 //==========================================================================
1743 ///
1744 /// @ingroup cpp_kodi_addon_game_Operation_CStream
1745 /// @brief Free an allocated buffer
1746 ///
1747 /// @param[in] buffer The buffer returned from GetStreamBuffer()
1748 ///
1749 /// @remarks Only called from addon itself
1750 ///
1751 void ReleaseBuffer(game_stream_buffer& buffer)
1752 {
1753 if (!m_handle || !CAddonBase::m_interface->globalSingleInstance)
1754 return;
1755
1756 AddonToKodiFuncTable_Game& cb =
1757 static_cast<CInstanceGame*>(CAddonBase::m_interface->globalSingleInstance)
1758 ->m_instanceData->toKodi;
1759 cb.ReleaseStreamBuffer(cb.kodiInstance, m_handle, &buffer);
1760 }
1761 //--------------------------------------------------------------------------
1762
1763 //==========================================================================
1764 ///
1765 /// @ingroup cpp_kodi_addon_game_Operation_CStream
1766 /// @brief To check stream open was OK, e.g. after use of constructor
1767 ///
1768 /// @return true if stream was successfully opened
1769 ///
1770 /// @remarks Only called from addon itself
1771 ///
1772 bool IsOpen() const { return m_handle != nullptr; }
1773 //--------------------------------------------------------------------------
1774
1775 private:
1776 void* m_handle = nullptr;
1777 };
1778 //@}
1779
1780 //@}
1781
1782//--==----==----==----==----==----==----==----==----==----==----==----==----==--
1783
1784 //============================================================================
1785 ///
1786 /// @defgroup cpp_kodi_addon_game_HardwareRendering 3. Hardware rendering operations
1787 /// @ingroup cpp_kodi_addon_game
1788 /// @brief **Hardware rendering operations**
1789 ///
1790 //@{
1791
1792 //============================================================================
1793 ///
1794 /// @brief Invalidates the current HW context and reinitializes GPU resources
1795 ///
1796 /// Any GL state is lost, and must not be deinitialized explicitly.
1797 ///
1798 /// @return the error, or @ref GAME_ERROR_NO_ERROR if the HW context was reset
1799 ///
1800 virtual GAME_ERROR HwContextReset()
1801 {
1802 return GAME_ERROR_NOT_IMPLEMENTED;
1803 }
1804 //----------------------------------------------------------------------------
1805
1806 //============================================================================
1807 ///
1808 /// @brief Called before the context is destroyed
1809 ///
1810 /// Resources can be deinitialized at this step.
1811 ///
1812 /// @return the error, or @ref GAME_ERROR_NO_ERROR if the HW context was destroyed
1813 ///
1814 virtual GAME_ERROR HwContextDestroy()
1815 {
1816 return GAME_ERROR_NOT_IMPLEMENTED;
1817 }
1818
1819 //============================================================================
1820 ///
1821 /// @brief **Callback to Kodi Function**<br>Get a symbol from the hardware context
1822 ///
1823 /// @param[in] sym The symbol's name
1824 ///
1825 /// @return A function pointer for the specified symbol
1826 ///
1827 /// @remarks Only called from addon itself
1828 ///
1829 game_proc_address_t HwGetProcAddress(const char* sym)
1830 {
1831 return m_instanceData->toKodi.HwGetProcAddress(m_instanceData->toKodi.kodiInstance, sym);
1832 }
1833 //----------------------------------------------------------------------------
1834
1835 //@}
1836
1837//--==----==----==----==----==----==----==----==----==----==----==----==----==--
1838
1839 //============================================================================
1840 ///
1841 /// @defgroup cpp_kodi_addon_game_InputOperations 4. Input operations
1842 /// @ingroup cpp_kodi_addon_game
1843 /// @brief **Input operations**
1844 ///
1845 //@{
1846
1847 //============================================================================
1848 ///
1849 /// @brief Check if input is accepted for a feature on the controller
1850 ///
1851 /// If only a subset of the controller profile is used, this can return false
1852 /// for unsupported features to not absorb their input.
1853 ///
1854 /// If the entire controller profile is used, this should always return true.
1855 ///
1856 /// @param[in] controller_id The ID of the controller profile
1857 /// @param[in] feature_name The name of a feature in that profile
1858 /// @return true if input is accepted for the feature, false otherwise
1859 ///
1860 virtual bool HasFeature(const std::string& controller_id, const std::string& feature_name)
1861 {
1862 return false;
1863 }
1864 //----------------------------------------------------------------------------
1865
1866 //============================================================================
1867 ///
1868 /// @brief Get the input topology that specifies which controllers can be connected
1869 ///
1870 /// @return The input topology, or null to use the default
1871 ///
1872 /// If this returns non-null, topology must be freed using FreeTopology().
1873 ///
1874 /// If this returns null, the topology will default to a single port that can
1875 /// accept all controllers imported by addon.xml. The port ID is set to
1876 /// the @ref DEFAULT_PORT_ID constant.
1877 ///
1878 virtual game_input_topology* GetTopology()
1879 {
1880 return nullptr;
1881 }
1882 //----------------------------------------------------------------------------
1883
1884 //============================================================================
1885 ///
1886 /// @brief Free the topology's resources
1887 ///
1888 /// @param[in] topology The topology returned by GetTopology()
1889 ///
1890 virtual void FreeTopology(game_input_topology* topology)
1891 {
1892 }
1893 //----------------------------------------------------------------------------
1894
1895 //============================================================================
1896 ///
1897 /// @brief Set the layouts for known controllers
1898 ///
1899 /// @param[in] controllers The controller layouts
1900 ///
1901 /// After loading the input topology, the frontend will call this with
1902 /// controller layouts for all controllers discovered in the topology.
1903 ///
1904 virtual void SetControllerLayouts(const std::vector<AddonGameControllerLayout>& controllers)
1905 {
1906 }
1907 //----------------------------------------------------------------------------
1908
1909 //============================================================================
1910 ///
1911 /// @brief Enable/disable keyboard input using the specified controller
1912 ///
1913 /// @param[in] enable True to enable input, false otherwise
1914 /// @param[in] controller_id The controller ID if enabling, or unused if disabling
1915 ///
1916 /// @return True if keyboard input was enabled, false otherwise
1917 ///
1918 virtual bool EnableKeyboard(bool enable, const std::string& controller_id)
1919 {
1920 return false;
1921 }
1922 //----------------------------------------------------------------------------
1923
1924 //============================================================================
1925 ///
1926 /// @brief Enable/disable mouse input using the specified controller
1927 ///
1928 /// @param[in] enable True to enable input, false otherwise
1929 /// @param[in] controller_id The controller ID if enabling, or unused if disabling
1930 ///
1931 /// @return True if mouse input was enabled, false otherwise
1932 ///
1933 virtual bool EnableMouse(bool enable, const std::string& controller_id)
1934 {
1935 return false;
1936 }
1937 //--------------------------------------------------------------------------
1938
1939 //==========================================================================
1940 ///
1941 /// @brief Connect/disconnect a controller to a port on the virtual game console
1942 ///
1943 /// @param[in] connect True to connect a controller, false to disconnect
1944 /// @param[in] port_address The address of the port
1945 /// @param[in] controller_id The controller ID if connecting, or unused if disconnecting
1946 /// @return True if the \p controller was (dis-)connected to the port, false otherwise
1947 ///
1948 /// The address is a string that allows traversal of the controller topology.
1949 /// It is formed by alternating port IDs and controller IDs separated by "/".
1950 ///
1951 /// For example, assume that the topology represented in XML for Snes9x is:
1952 ///
1953 /// ~~~~~~~~~~~~~{.xml}
1954 /// <logicaltopology>
1955 /// <port type="controller" id="1">
1956 /// <accepts controller="game.controller.snes"/>
1957 /// <accepts controller="game.controller.snes.multitap">
1958 /// <port type="controller" id="1">
1959 /// <accepts controller="game.controller.snes"/>
1960 /// </port>
1961 /// <port type="controller" id="2">
1962 /// <accepts controller="game.controller.snes"/>
1963 /// </port>
1964 /// ...
1965 /// </accepts>
1966 /// </port>
1967 /// </logicaltopology>
1968 /// ~~~~~~~~~~~~~
1969 ///
1970 /// To connect a multitap to the console's first port, the multitap's controller
1971 /// info is set using the port address:
1972 ///
1973 /// 1
1974 ///
1975 /// To connect a SNES controller to the second port of the multitap, the
1976 /// controller info is next set using the address:
1977 ///
1978 /// 1/game.controller.multitap/2
1979 ///
1980 /// Any attempts to connect a controller to a port on a disconnected multitap
1981 /// will return false.
1982 ///
1983 virtual bool ConnectController(bool connect,
1984 const std::string& port_address,
1985 const std::string& controller_id)
1986 {
1987 return false;
1988 }
1989 //----------------------------------------------------------------------------
1990
1991 //============================================================================
1992 ///
1993 /// @brief Notify the add-on of an input event
1994 ///
1995 /// @param[in] event The input event
1996 ///
1997 /// @return true if the event was handled, false otherwise
1998 ///
1999 virtual bool InputEvent(const game_input_event& event)
2000 {
2001 return false;
2002 }
2003 //----------------------------------------------------------------------------
2004
2005 //============================================================================
2006 ///
2007 /// @brief **Callback to Kodi Function**<br>Notify the port of an input event
2008 ///
2009 /// @param[in] event The input event
2010 /// @return true if the event was handled, false otherwise
2011 ///
2012 /// @note Input events can arrive for the following sources:
2013 /// - \ref GAME_INPUT_EVENT_MOTOR
2014 ///
2015 /// @remarks Only called from addon itself
2016 ///
2017 bool KodiInputEvent(const game_input_event& event)
2018 {
2019 return m_instanceData->toKodi.InputEvent(m_instanceData->toKodi.kodiInstance, &event);
2020 }
2021 //----------------------------------------------------------------------------
2022
2023 //@}
2024
2025//--==----==----==----==----==----==----==----==----==----==----==----==----==--
2026
2027 //============================================================================
2028 ///
2029 /// @defgroup cpp_kodi_addon_game_SerializationOperations 5. Serialization operations
2030 /// @ingroup cpp_kodi_addon_game
2031 /// @brief **Serialization operations**
2032 ///
2033 //@{
2034
2035 //============================================================================
2036 ///
2037 /// @brief Get the number of bytes required to serialize the game
2038 ///
2039 /// @return the number of bytes, or 0 if serialization is not supported
2040 ///
2041 virtual size_t SerializeSize()
2042 {
2043 return 0;
2044 }
2045 //----------------------------------------------------------------------------
2046
2047 //============================================================================
2048 ///
2049 /// @brief Serialize the state of the game
2050 ///
2051 /// @param[in] data The buffer receiving the serialized game data
2052 /// @param[in] size The size of the buffer
2053 ///
2054 /// @return the error, or @ref GAME_ERROR_NO_ERROR if the game was serialized into the buffer
2055 ///
2056 virtual GAME_ERROR Serialize(uint8_t* data, size_t size)
2057 {
2058 return GAME_ERROR_NOT_IMPLEMENTED;
2059 }
2060 //----------------------------------------------------------------------------
2061
2062 //============================================================================
2063 ///
2064 /// @brief Deserialize the game from the given state
2065 ///
2066 /// @param[in] data A buffer containing the game's new state
2067 /// @param[in] size The size of the buffer
2068 ///
2069 /// @return the error, or @ref GAME_ERROR_NO_ERROR if the game deserialized
2070 ///
2071 virtual GAME_ERROR Deserialize(const uint8_t* data, size_t size)
2072 {
2073 return GAME_ERROR_NOT_IMPLEMENTED;
2074 }
2075 //----------------------------------------------------------------------------
2076
2077 //@}
2078
2079//--==----==----==----==----==----==----==----==----==----==----==----==----==--
2080
2081 //============================================================================
2082 ///
2083 /// @defgroup cpp_kodi_addon_game_CheatOperations 6. Cheat operations
2084 /// @ingroup cpp_kodi_addon_game
2085 /// @brief **Cheat operations**
2086 ///
2087 //@{
2088
2089 //============================================================================
2090 ///
2091 /// @brief Reset the cheat system
2092 ///
2093 /// @return the error, or @ref GAME_ERROR_NO_ERROR if the cheat system was reset
2094 ///
2095 virtual GAME_ERROR CheatReset()
2096 {
2097 return GAME_ERROR_NOT_IMPLEMENTED;
2098 }
2099 //----------------------------------------------------------------------------
2100
2101 //============================================================================
2102 ///
2103 /// @brief Get a region of memory
2104 ///
2105 /// @param[in] type The type of memory to retrieve
2106 /// @param[in] data Set to the region of memory; must remain valid until UnloadGame() is called
2107 /// @param[in] size Set to the size of the region of memory
2108 ///
2109 /// @return the error, or @ref GAME_ERROR_NO_ERROR if data was set to a valid buffer
2110 ///
2111 virtual GAME_ERROR GetMemory(GAME_MEMORY type, uint8_t*& data, size_t& size)
2112 {
2113 return GAME_ERROR_NOT_IMPLEMENTED;
2114 }
2115 //----------------------------------------------------------------------------
2116
2117 //============================================================================
2118 ///
2119 /// @brief Set a cheat code
2120 ///
2121 /// @param[in] index
2122 /// @param[in] enabled
2123 /// @param[in] code
2124 ///
2125 /// @return the error, or @ref GAME_ERROR_NO_ERROR if the cheat was set
2126 ///
2127 virtual GAME_ERROR SetCheat(unsigned int index, bool enabled, const std::string& code)
2128 {
2129 return GAME_ERROR_NOT_IMPLEMENTED;
2130 }
2131 //----------------------------------------------------------------------------
2132
2133 //@}
2134
2135private:
2136 void SetAddonStruct(KODI_HANDLE instance)
2137 {
2138 if (instance == nullptr)
2139 throw std::logic_error("kodi::addon::CInstanceGame: Creation with empty addon structure not"
2140 "allowed, table must be given from Kodi!");
2141
2142 m_instanceData = static_cast<AddonInstance_Game*>(instance);
2143 m_instanceData->toAddon.addonInstance = this;
2144
2145 m_instanceData->toAddon.LoadGame = ADDON_LoadGame;
2146 m_instanceData->toAddon.LoadGameSpecial = ADDON_LoadGameSpecial;
2147 m_instanceData->toAddon.LoadStandalone = ADDON_LoadStandalone;
2148 m_instanceData->toAddon.UnloadGame = ADDON_UnloadGame;
2149 m_instanceData->toAddon.GetGameTiming = ADDON_GetGameTiming;
2150 m_instanceData->toAddon.GetRegion = ADDON_GetRegion;
2151 m_instanceData->toAddon.RequiresGameLoop = ADDON_RequiresGameLoop;
2152 m_instanceData->toAddon.RunFrame = ADDON_RunFrame;
2153 m_instanceData->toAddon.Reset = ADDON_Reset;
2154
2155 m_instanceData->toAddon.HwContextReset = ADDON_HwContextReset;
2156 m_instanceData->toAddon.HwContextDestroy = ADDON_HwContextDestroy;
2157
2158 m_instanceData->toAddon.HasFeature = ADDON_HasFeature;
2159 m_instanceData->toAddon.GetTopology = ADDON_GetTopology;
2160 m_instanceData->toAddon.FreeTopology = ADDON_FreeTopology;
2161 m_instanceData->toAddon.SetControllerLayouts = ADDON_SetControllerLayouts;
2162 m_instanceData->toAddon.EnableKeyboard = ADDON_EnableKeyboard;
2163 m_instanceData->toAddon.EnableMouse = ADDON_EnableMouse;
2164 m_instanceData->toAddon.ConnectController = ADDON_ConnectController;
2165 m_instanceData->toAddon.InputEvent = ADDON_InputEvent;
2166
2167 m_instanceData->toAddon.SerializeSize = ADDON_SerializeSize;
2168 m_instanceData->toAddon.Serialize = ADDON_Serialize;
2169 m_instanceData->toAddon.Deserialize = ADDON_Deserialize;
2170
2171 m_instanceData->toAddon.CheatReset = ADDON_CheatReset;
2172 m_instanceData->toAddon.GetMemory = ADDON_GetMemory;
2173 m_instanceData->toAddon.SetCheat = ADDON_SetCheat;
2174 }
2175
2176 // --- Game operations ---------------------------------------------------------
2177
2178 inline static GAME_ERROR ADDON_LoadGame(const AddonInstance_Game* instance, const char* url)
2179 {
2180 return instance->toAddon.addonInstance->LoadGame(url);
2181 }
2182
2183 inline static GAME_ERROR ADDON_LoadGameSpecial(const AddonInstance_Game* instance,
2184 SPECIAL_GAME_TYPE type,
2185 const char** urls,
2186 size_t urlCount)
2187 {
2188 std::vector<std::string> urlList;
2189 for (size_t i = 0; i < urlCount; ++i)
2190 {
2191 if (urls[i] != nullptr)
2192 urlList.push_back(urls[i]);
2193 }
2194
2195 return instance->toAddon.addonInstance->LoadGameSpecial(type, urlList);
2196 }
2197
2198 inline static GAME_ERROR ADDON_LoadStandalone(const AddonInstance_Game* instance)
2199 {
2200 return instance->toAddon.addonInstance->LoadStandalone();
2201 }
2202
2203 inline static GAME_ERROR ADDON_UnloadGame(const AddonInstance_Game* instance)
2204 {
2205 return instance->toAddon.addonInstance->UnloadGame();
2206 }
2207
2208 inline static GAME_ERROR ADDON_GetGameTiming(const AddonInstance_Game* instance,
2209 game_system_timing* timing_info)
2210 {
2211 return instance->toAddon.addonInstance->GetGameTiming(*timing_info);
2212 }
2213
2214 inline static GAME_REGION ADDON_GetRegion(const AddonInstance_Game* instance)
2215 {
2216 return instance->toAddon.addonInstance->GetRegion();
2217 }
2218
2219 inline static bool ADDON_RequiresGameLoop(const AddonInstance_Game* instance)
2220 {
2221 return instance->toAddon.addonInstance->RequiresGameLoop();
2222 }
2223
2224 inline static GAME_ERROR ADDON_RunFrame(const AddonInstance_Game* instance)
2225 {
2226 return instance->toAddon.addonInstance->RunFrame();
2227 }
2228
2229 inline static GAME_ERROR ADDON_Reset(const AddonInstance_Game* instance)
2230 {
2231 return instance->toAddon.addonInstance->Reset();
2232 }
2233
2234
2235 // --- Hardware rendering operations -------------------------------------------
2236
2237 inline static GAME_ERROR ADDON_HwContextReset(const AddonInstance_Game* instance)
2238 {
2239 return instance->toAddon.addonInstance->HwContextReset();
2240 }
2241
2242 inline static GAME_ERROR ADDON_HwContextDestroy(const AddonInstance_Game* instance)
2243 {
2244 return instance->toAddon.addonInstance->HwContextDestroy();
2245 }
2246
2247
2248 // --- Input operations --------------------------------------------------------
2249
2250 inline static bool ADDON_HasFeature(const AddonInstance_Game* instance,
2251 const char* controller_id,
2252 const char* feature_name)
2253 {
2254 return instance->toAddon.addonInstance->HasFeature(controller_id, feature_name);
2255 }
2256
2257 inline static game_input_topology* ADDON_GetTopology(const AddonInstance_Game* instance)
2258 {
2259 return instance->toAddon.addonInstance->GetTopology();
2260 }
2261
2262 inline static void ADDON_FreeTopology(const AddonInstance_Game* instance,
2263 game_input_topology* topology)
2264 {
2265 instance->toAddon.addonInstance->FreeTopology(topology);
2266 }
2267
2268 inline static void ADDON_SetControllerLayouts(const AddonInstance_Game* instance,
2269 const game_controller_layout* controllers,
2270 unsigned int controller_count)
2271 {
2272 if (controllers == nullptr)
2273 return;
2274
2275 std::vector<AddonGameControllerLayout> controllerList;
2276 for (unsigned int i = 0; i < controller_count; ++i)
2277 controllerList.push_back(controllers[i]);
2278
2279 instance->toAddon.addonInstance->SetControllerLayouts(controllerList);
2280 }
2281
2282 inline static bool ADDON_EnableKeyboard(const AddonInstance_Game* instance,
2283 bool enable,
2284 const char* controller_id)
2285 {
2286 return instance->toAddon.addonInstance->EnableKeyboard(enable, controller_id);
2287 }
2288
2289 inline static bool ADDON_EnableMouse(const AddonInstance_Game* instance,
2290 bool enable,
2291 const char* controller_id)
2292 {
2293 return instance->toAddon.addonInstance->EnableMouse(enable, controller_id);
2294 }
2295
2296 inline static bool ADDON_ConnectController(const AddonInstance_Game* instance,
2297 bool connect,
2298 const char* port_address,
2299 const char* controller_id)
2300 {
2301 return instance->toAddon.addonInstance->ConnectController(connect, port_address, controller_id);
2302 }
2303
2304 inline static bool ADDON_InputEvent(const AddonInstance_Game* instance,
2305 const game_input_event* event)
2306 {
2307 return instance->toAddon.addonInstance->InputEvent(*event);
2308 }
2309
2310
2311 // --- Serialization operations ------------------------------------------------
2312
2313 inline static size_t ADDON_SerializeSize(const AddonInstance_Game* instance)
2314 {
2315 return instance->toAddon.addonInstance->SerializeSize();
2316 }
2317
2318 inline static GAME_ERROR ADDON_Serialize(const AddonInstance_Game* instance,
2319 uint8_t* data,
2320 size_t size)
2321 {
2322 return instance->toAddon.addonInstance->Serialize(data, size);
2323 }
2324
2325 inline static GAME_ERROR ADDON_Deserialize(const AddonInstance_Game* instance,
2326 const uint8_t* data,
2327 size_t size)
2328 {
2329 return instance->toAddon.addonInstance->Deserialize(data, size);
2330 }
2331
2332
2333 // --- Cheat operations --------------------------------------------------------
2334
2335 inline static GAME_ERROR ADDON_CheatReset(const AddonInstance_Game* instance)
2336 {
2337 return instance->toAddon.addonInstance->CheatReset();
2338 }
2339
2340 inline static GAME_ERROR ADDON_GetMemory(const AddonInstance_Game* instance,
2341 GAME_MEMORY type,
2342 uint8_t** data,
2343 size_t* size)
2344 {
2345 return instance->toAddon.addonInstance->GetMemory(type, *data, *size);
2346 }
2347
2348 inline static GAME_ERROR ADDON_SetCheat(const AddonInstance_Game* instance,
2349 unsigned int index,
2350 bool enabled,
2351 const char* code)
2352 {
2353 return instance->toAddon.addonInstance->SetCheat(index, enabled, code);
2354 }
2355
2356 AddonInstance_Game* m_instanceData;
2357};
2358
2359} /* namespace addon */
2360} /* namespace kodi */
diff --git a/xbmc/addons/kodi-addon-dev-kit/include/kodi/addon-instance/ImageDecoder.h b/xbmc/addons/kodi-addon-dev-kit/include/kodi/addon-instance/ImageDecoder.h
deleted file mode 100644
index e41e5ef..0000000
--- a/xbmc/addons/kodi-addon-dev-kit/include/kodi/addon-instance/ImageDecoder.h
+++ /dev/null
@@ -1,315 +0,0 @@
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_NOTICE, "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-addon-dev-kit/include/kodi/addon-instance/Inputstream.h b/xbmc/addons/kodi-addon-dev-kit/include/kodi/addon-instance/Inputstream.h
deleted file mode 100644
index 354806e..0000000
--- a/xbmc/addons/kodi-addon-dev-kit/include/kodi/addon-instance/Inputstream.h
+++ /dev/null
@@ -1,881 +0,0 @@
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#ifdef __cplusplus
32extern "C"
33{
34#endif /* __cplusplus */
35
36 /*!
37 * @brief InputStream add-on capabilities. All capabilities are set to "false" as default.
38 */
39 struct INPUTSTREAM_CAPABILITIES
40 {
41 enum MASKTYPE : uint32_t
42 {
43 /// supports interface IDemux
44 SUPPORTS_IDEMUX = (1 << 0),
45
46 /// supports interface IPosTime
47 SUPPORTS_IPOSTIME = (1 << 1),
48
49 /// supports interface IDisplayTime
50 SUPPORTS_IDISPLAYTIME = (1 << 2),
51
52 /// supports seek
53 SUPPORTS_SEEK = (1 << 3),
54
55 /// supports pause
56 SUPPORTS_PAUSE = (1 << 4),
57
58 /// supports interface ITime
59 SUPPORTS_ITIME = (1 << 5),
60
61 /// supports interface IChapter
62 SUPPORTS_ICHAPTER = (1 << 6),
63 };
64
65 /// set of supported capabilities
66 uint32_t m_mask;
67 };
68
69 /*!
70 * @brief structure of key/value pairs passed to addon on Open()
71 */
72 struct INPUTSTREAM
73 {
74 const char* m_strURL;
75 const char* m_mimeType;
76
77 unsigned int m_nCountInfoValues;
78 struct LISTITEMPROPERTY
79 {
80 const char* m_strKey;
81 const char* m_strValue;
82 } m_ListItemProperties[STREAM_MAX_PROPERTY_COUNT];
83
84 const char* m_libFolder;
85 const char* m_profileFolder;
86 };
87
88 /*!
89 * @brief Array of stream IDs
90 */
91 struct INPUTSTREAM_IDS
92 {
93 static const unsigned int MAX_STREAM_COUNT = 256;
94 unsigned int m_streamCount;
95 unsigned int m_streamIds[MAX_STREAM_COUNT];
96 };
97
98 /*!
99 * @brief MASTERING Metadata
100 */
101 struct INPUTSTREAM_MASTERING_METADATA
102 {
103 double primary_r_chromaticity_x;
104 double primary_r_chromaticity_y;
105 double primary_g_chromaticity_x;
106 double primary_g_chromaticity_y;
107 double primary_b_chromaticity_x;
108 double primary_b_chromaticity_y;
109 double white_point_chromaticity_x;
110 double white_point_chromaticity_y;
111 double luminance_max;
112 double luminance_min;
113 };
114
115 /*!
116 * @brief CONTENTLIGHT Metadata
117 */
118 struct INPUTSTREAM_CONTENTLIGHT_METADATA
119 {
120 uint64_t max_cll;
121 uint64_t max_fall;
122 };
123
124 /*!
125 * @brief stream properties
126 */
127 struct INPUTSTREAM_INFO
128 {
129 enum STREAM_TYPE
130 {
131 TYPE_NONE = 0,
132 TYPE_VIDEO,
133 TYPE_AUDIO,
134 TYPE_SUBTITLE,
135 TYPE_TELETEXT,
136 TYPE_RDS,
137 } m_streamType;
138
139 enum Codec_FEATURES : uint32_t
140 {
141 FEATURE_DECODE = 1
142 };
143 uint32_t m_features;
144
145 enum STREAM_FLAGS : uint32_t
146 {
147 FLAG_NONE = 0x0000,
148 FLAG_DEFAULT = 0x0001,
149 FLAG_DUB = 0x0002,
150 FLAG_ORIGINAL = 0x0004,
151 FLAG_COMMENT = 0x0008,
152 FLAG_LYRICS = 0x0010,
153 FLAG_KARAOKE = 0x0020,
154 FLAG_FORCED = 0x0040,
155 FLAG_HEARING_IMPAIRED = 0x0080,
156 FLAG_VISUAL_IMPAIRED = 0x0100,
157 };
158
159 // Keep in sync with AVColorSpace
160 enum COLORSPACE
161 {
162 COLORSPACE_RGB = 0,
163 COLORSPACE_BT709 = 1,
164 COLORSPACE_UNSPECIFIED = 2,
165 COLORSPACE_UNKNOWN = COLORSPACE_UNSPECIFIED, // compatibility
166 COLORSPACE_RESERVED = 3,
167 COLORSPACE_FCC = 4,
168 COLORSPACE_BT470BG = 5,
169 COLORSPACE_SMPTE170M = 6,
170 COLORSPACE_SMPTE240M = 7,
171 COLORSPACE_YCGCO = 8,
172 COLORSPACE_YCOCG = COLORSPACE_YCGCO,
173 COLORSPACE_BT2020_NCL = 9,
174 COLORSPACE_BT2020_CL = 10,
175 COLORSPACE_SMPTE2085 = 11,
176 COLORSPACE_CHROMA_DERIVED_NCL = 12,
177 COLORSPACE_CHROMA_DERIVED_CL = 13,
178 COLORSPACE_ICTCP = 14,
179 COLORSPACE_MAX
180 };
181
182 // Keep in sync with AVColorPrimaries
183 enum COLORPRIMARIES : int32_t
184 {
185 COLORPRIMARY_RESERVED0 = 0,
186 COLORPRIMARY_BT709 = 1,
187 COLORPRIMARY_UNSPECIFIED = 2,
188 COLORPRIMARY_RESERVED = 3,
189 COLORPRIMARY_BT470M = 4,
190 COLORPRIMARY_BT470BG = 5,
191 COLORPRIMARY_SMPTE170M = 6,
192 COLORPRIMARY_SMPTE240M = 7,
193 COLORPRIMARY_FILM = 8,
194 COLORPRIMARY_BT2020 = 9,
195 COLORPRIMARY_SMPTE428 = 10,
196 COLORPRIMARY_SMPTEST428_1 = COLORPRIMARY_SMPTE428,
197 COLORPRIMARY_SMPTE431 = 11,
198 COLORPRIMARY_SMPTE432 = 12,
199 COLORPRIMARY_JEDEC_P22 = 22,
200 COLORPRIMARY_MAX
201 };
202
203 // Keep in sync with AVColorRange
204 enum COLORRANGE
205 {
206 COLORRANGE_UNKNOWN = 0,
207 COLORRANGE_LIMITED,
208 COLORRANGE_FULLRANGE,
209 COLORRANGE_MAX
210 };
211
212 // keep in sync with AVColorTransferCharacteristic
213 enum COLORTRC : int32_t
214 {
215 COLORTRC_RESERVED0 = 0,
216 COLORTRC_BT709 = 1,
217 COLORTRC_UNSPECIFIED = 2,
218 COLORTRC_RESERVED = 3,
219 COLORTRC_GAMMA22 = 4,
220 COLORTRC_GAMMA28 = 5,
221 COLORTRC_SMPTE170M = 6,
222 COLORTRC_SMPTE240M = 7,
223 COLORTRC_LINEAR = 8,
224 COLORTRC_LOG = 9,
225 COLORTRC_LOG_SQRT = 10,
226 COLORTRC_IEC61966_2_4 = 11,
227 COLORTRC_BT1361_ECG = 12,
228 COLORTRC_IEC61966_2_1 = 13,
229 COLORTRC_BT2020_10 = 14,
230 COLORTRC_BT2020_12 = 15,
231 COLORTRC_SMPTE2084 = 16,
232 COLORTRC_SMPTEST2084 = COLORTRC_SMPTE2084,
233 COLORTRC_SMPTE428 = 17,
234 COLORTRC_SMPTEST428_1 = COLORTRC_SMPTE428,
235 COLORTRC_ARIB_STD_B67 = 18,
236 COLORTRC_MAX
237 };
238
239 uint32_t m_flags;
240
241 char m_name[256]; /*!< @brief (optinal) name of the stream, \0 for default handling */
242 char m_codecName[32]; /*!< @brief (required) name of codec according to ffmpeg */
243 char m_codecInternalName
244 [32]; /*!< @brief (optional) internal name of codec (selectionstream info) */
245 STREAMCODEC_PROFILE m_codecProfile; /*!< @brief (optional) the profile of the codec */
246 unsigned int m_pID; /*!< @brief (required) physical index */
247
248 const uint8_t* m_ExtraData;
249 unsigned int m_ExtraSize;
250
251 char m_language[64]; /*!< @brief RFC 5646 language code (empty string if undefined) */
252
253 unsigned int
254 m_FpsScale; /*!< @brief Scale of 1000 and a rate of 29970 will result in 29.97 fps */
255 unsigned int m_FpsRate;
256 unsigned int m_Height; /*!< @brief height of the stream reported by the demuxer */
257 unsigned int m_Width; /*!< @brief width of the stream reported by the demuxer */
258 float m_Aspect; /*!< @brief display aspect of stream */
259
260
261 unsigned int m_Channels; /*!< @brief (required) amount of channels */
262 unsigned int m_SampleRate; /*!< @brief (required) sample rate */
263 unsigned int m_BitRate; /*!< @brief (required) bit rate */
264 unsigned int m_BitsPerSample; /*!< @brief (required) bits per sample */
265 unsigned int m_BlockAlign;
266
267 CRYPTO_INFO m_cryptoInfo;
268
269 // new in API version 2.0.8
270 unsigned int m_codecFourCC; /*!< @brief Codec If available, the fourcc code codec */
271 COLORSPACE m_colorSpace; /*!< @brief definition of colorspace */
272 COLORRANGE m_colorRange; /*!< @brief color range if available */
273
274 //new in API 2.0.9 / INPUTSTREAM_VERSION_LEVEL 1
275 COLORPRIMARIES m_colorPrimaries;
276 COLORTRC m_colorTransferCharacteristic;
277 INPUTSTREAM_MASTERING_METADATA* m_masteringMetadata; /*!< @brief mastering static Metadata */
278 INPUTSTREAM_CONTENTLIGHT_METADATA*
279 m_contentLightMetadata; /*!< @brief content light static Metadata */
280 };
281
282 struct INPUTSTREAM_TIMES
283 {
284 time_t startTime;
285 double ptsStart;
286 double ptsBegin;
287 double ptsEnd;
288 };
289
290 /*!
291 * @brief "C" ABI Structures to transfer the methods from this to Kodi
292 */
293
294 // this are properties given to the addon on create
295 // at this time we have no parameters for the addon
296 typedef struct AddonProps_InputStream /* internal */
297 {
298 int dummy;
299 } AddonProps_InputStream;
300
301 typedef struct AddonToKodiFuncTable_InputStream /* internal */
302 {
303 KODI_HANDLE kodiInstance;
304 DemuxPacket* (*allocate_demux_packet)(void* kodiInstance, int data_size);
305 DemuxPacket* (*allocate_encrypted_demux_packet)(void* kodiInstance,
306 unsigned int data_size,
307 unsigned int encrypted_subsample_count);
308 void (*free_demux_packet)(void* kodiInstance, DemuxPacket* packet);
309 } AddonToKodiFuncTable_InputStream;
310
311 struct AddonInstance_InputStream;
312 typedef struct KodiToAddonFuncTable_InputStream /* internal */
313 {
314 KODI_HANDLE addonInstance;
315
316 bool(__cdecl* open)(const AddonInstance_InputStream* instance, INPUTSTREAM* props);
317 void(__cdecl* close)(const AddonInstance_InputStream* instance);
318 const char*(__cdecl* get_path_list)(const AddonInstance_InputStream* instance);
319 void(__cdecl* get_capabilities)(const AddonInstance_InputStream* instance,
320 INPUTSTREAM_CAPABILITIES* capabilities);
321
322 // IDemux
323 struct INPUTSTREAM_IDS(__cdecl* get_stream_ids)(const AddonInstance_InputStream* instance);
324 struct INPUTSTREAM_INFO(__cdecl* get_stream)(const AddonInstance_InputStream* instance,
325 int streamid);
326 void(__cdecl* enable_stream)(const AddonInstance_InputStream* instance,
327 int streamid,
328 bool enable);
329 bool(__cdecl* open_stream)(const AddonInstance_InputStream* instance, int streamid);
330 void(__cdecl* demux_reset)(const AddonInstance_InputStream* instance);
331 void(__cdecl* demux_abort)(const AddonInstance_InputStream* instance);
332 void(__cdecl* demux_flush)(const AddonInstance_InputStream* instance);
333 DemuxPacket*(__cdecl* demux_read)(const AddonInstance_InputStream* instance);
334 bool(__cdecl* demux_seek_time)(const AddonInstance_InputStream* instance,
335 double time,
336 bool backwards,
337 double* startpts);
338 void(__cdecl* demux_set_speed)(const AddonInstance_InputStream* instance, int speed);
339 void(__cdecl* set_video_resolution)(const AddonInstance_InputStream* instance,
340 int width,
341 int height);
342
343 // IDisplayTime
344 int(__cdecl* get_total_time)(const AddonInstance_InputStream* instance);
345 int(__cdecl* get_time)(const AddonInstance_InputStream* instance);
346
347 // ITime
348 bool(__cdecl* get_times)(const AddonInstance_InputStream* instance, INPUTSTREAM_TIMES* times);
349
350 // IPosTime
351 bool(__cdecl* pos_time)(const AddonInstance_InputStream* instance, int ms);
352
353 int(__cdecl* read_stream)(const AddonInstance_InputStream* instance,
354 uint8_t* buffer,
355 unsigned int bufferSize);
356 int64_t(__cdecl* seek_stream)(const AddonInstance_InputStream* instance,
357 int64_t position,
358 int whence);
359 int64_t(__cdecl* position_stream)(const AddonInstance_InputStream* instance);
360 int64_t(__cdecl* length_stream)(const AddonInstance_InputStream* instance);
361 bool(__cdecl* is_real_time_stream)(const AddonInstance_InputStream* instance);
362
363 // IChapter
364 int(__cdecl* get_chapter)(const AddonInstance_InputStream* instance);
365 int(__cdecl* get_chapter_count)(const AddonInstance_InputStream* instance);
366 const char*(__cdecl* get_chapter_name)(const AddonInstance_InputStream* instance, int ch);
367 int64_t(__cdecl* get_chapter_pos)(const AddonInstance_InputStream* instance, int ch);
368 bool(__cdecl* seek_chapter)(const AddonInstance_InputStream* instance, int ch);
369
370 int(__cdecl* block_size_stream)(const AddonInstance_InputStream* instance);
371 } KodiToAddonFuncTable_InputStream;
372
373 typedef struct AddonInstance_InputStream /* internal */
374 {
375 AddonProps_InputStream props;
376 AddonToKodiFuncTable_InputStream toKodi;
377 KodiToAddonFuncTable_InputStream toAddon;
378 } AddonInstance_InputStream;
379
380#ifdef __cplusplus
381} /* extern "C" */
382
383namespace kodi
384{
385namespace addon
386{
387
388class ATTRIBUTE_HIDDEN CInstanceInputStream : public IAddonInstance
389{
390public:
391 explicit CInstanceInputStream(KODI_HANDLE instance, const std::string& kodiVersion = "")
392 : IAddonInstance(ADDON_INSTANCE_INPUTSTREAM,
393 !kodiVersion.empty() ? kodiVersion
394 : GetKodiTypeVersion(ADDON_INSTANCE_INPUTSTREAM))
395 {
396 if (CAddonBase::m_interface->globalSingleInstance != nullptr)
397 throw std::logic_error("kodi::addon::CInstanceInputStream: Creation of multiple together "
398 "with single instance way is not allowed!");
399
400 SetAddonStruct(instance, m_kodiVersion);
401 }
402
403 ~CInstanceInputStream() override = default;
404
405 /*!
406 * Open a stream.
407 * @param props
408 * @return True if the stream has been opened successfully, false otherwise.
409 * @remarks
410 */
411 virtual bool Open(INPUTSTREAM& props) = 0;
412
413 /*!
414 * Close an open stream.
415 * @remarks
416 */
417 virtual void Close() = 0;
418
419 /*!
420 * Get Capabilities of this addon.
421 * @param capabilities The add-on's capabilities.
422 * @remarks
423 */
424 virtual void GetCapabilities(INPUTSTREAM_CAPABILITIES& capabilities) = 0;
425
426 /*!
427 * Get IDs of available streams
428 * @remarks
429 */
430 virtual INPUTSTREAM_IDS GetStreamIds() = 0;
431
432 /*!
433 * Get stream properties of a stream.
434 * @param streamid unique id of stream
435 * @return struc of stream properties
436 * @remarks
437 */
438 virtual INPUTSTREAM_INFO GetStream(int streamid) = 0;
439
440 /*!
441 * Enable or disable a stream.
442 * A disabled stream does not send demux packets
443 * @param streamid unique id of stream
444 * @param enable true for enable, false for disable
445 * @remarks
446 */
447 virtual void EnableStream(int streamid, bool enable) = 0;
448
449 /*!
450 * Opens a stream for playback.
451 * @param streamid unique id of stream
452 * @remarks
453 */
454 virtual bool OpenStream(int streamid) = 0;
455
456 /*!
457 * Reset the demultiplexer in the add-on.
458 * @remarks Required if bHandlesDemuxing is set to true.
459 */
460 virtual void DemuxReset() {}
461
462 /*!
463 * Abort the demultiplexer thread in the add-on.
464 * @remarks Required if bHandlesDemuxing is set to true.
465 */
466 virtual void DemuxAbort() {}
467
468 /*!
469 * Flush all data that's currently in the demultiplexer buffer in the add-on.
470 * @remarks Required if bHandlesDemuxing is set to true.
471 */
472 virtual void DemuxFlush() {}
473
474 /*!
475 * Read the next packet from the demultiplexer, if there is one.
476 * @return The next packet.
477 * If there is no next packet, then the add-on should return the
478 * packet created by calling AllocateDemuxPacket(0) on the callback.
479 * If the stream changed and Kodi's player needs to be reinitialised,
480 * then, the add-on should call AllocateDemuxPacket(0) on the
481 * callback, and set the streamid to DMX_SPECIALID_STREAMCHANGE and
482 * return the value.
483 * The add-on should return NULL if an error occurred.
484 * @remarks Return NULL if this add-on won't provide this function.
485 */
486 virtual DemuxPacket* DemuxRead() { return nullptr; }
487
488 /*!
489 * Notify the InputStream addon/demuxer that Kodi wishes to seek the stream by time
490 * Demuxer is required to set stream to an IDR frame
491 * @param time The absolute time since stream start
492 * @param backwards True to seek to keyframe BEFORE time, else AFTER
493 * @param startpts can be updated to point to where display should start
494 * @return True if the seek operation was possible
495 * @remarks Optional, and only used if addon has its own demuxer.
496 */
497 virtual bool DemuxSeekTime(double time, bool backwards, double& startpts) { return false; }
498
499 /*!
500 * Notify the InputStream addon/demuxer that Kodi wishes to change playback speed
501 * @param speed The requested playback speed
502 * @remarks Optional, and only used if addon has its own demuxer.
503 */
504 virtual void DemuxSetSpeed(int speed) {}
505
506 /*!
507 * Sets desired width / height
508 * @param width / hight
509 */
510 virtual void SetVideoResolution(int width, int height) {}
511
512 /*!
513 * Totel time in ms
514 * @remarks
515 */
516 virtual int GetTotalTime() { return -1; }
517
518 /*!
519 * Playing time in ms
520 * @remarks
521 */
522 virtual int GetTime() { return -1; }
523
524 /*!
525 * Get current timing values in PTS scale
526 * @remarks
527 */
528 virtual bool GetTimes(INPUTSTREAM_TIMES& times) { return false; }
529
530 /*!
531 * Positions inputstream to playing time given in ms
532 * @remarks
533 */
534 virtual bool PosTime(int ms) { return false; }
535
536 /*!
537 * Return currently selected chapter
538 * @remarks
539 */
540 virtual int GetChapter() { return -1; };
541
542 /*!
543 * Return number of available chapters
544 * @remarks
545 */
546 virtual int GetChapterCount() { return 0; };
547
548 /*!
549 * Return name of chapter # ch
550 * @remarks
551 */
552 virtual const char* GetChapterName(int ch) { return nullptr; };
553
554 /*!
555 * Return position if chapter # ch in milliseconds
556 * @remarks
557 */
558 virtual int64_t GetChapterPos(int ch) { return 0; };
559
560 /*!
561 * Seek to the beginning of chapter # ch
562 * @remarks
563 */
564 virtual bool SeekChapter(int ch) { return false; };
565
566 /*!
567 * Read from an open stream.
568 * @param buffer The buffer to store the data in.
569 * @param bufferSize The amount of bytes to read.
570 * @return The amount of bytes that were actually read from the stream.
571 * @remarks Return -1 if this add-on won't provide this function.
572 */
573 virtual int ReadStream(uint8_t* buffer, unsigned int bufferSize) { return -1; }
574
575 /*!
576 * Seek in a stream.
577 * @param position The position to seek to.
578 * @param whence ?
579 * @return The new position.
580 * @remarks Return -1 if this add-on won't provide this function.
581 */
582 virtual int64_t SeekStream(int64_t position, int whence = SEEK_SET) { return -1; }
583
584 /*!
585 * @return The position in the stream that's currently being read.
586 * @remarks Return -1 if this add-on won't provide this function.
587 */
588 virtual int64_t PositionStream() { return -1; }
589
590 /*!
591 * @return The total length of the stream that's currently being read.
592 * @remarks Return -1 if this add-on won't provide this function.
593 */
594 virtual int64_t LengthStream() { return -1; }
595
596 /*!
597 * @return Obtain the chunk size to use when reading streams.
598 * @remarks Return 0 if this add-on won't provide this function.
599 */
600 virtual int GetBlockSize() { return 0; }
601
602 /*!
603 * Check for real-time streaming
604 * @return true if current stream is real-time
605 */
606 virtual bool IsRealTimeStream() { return true; }
607
608 /*!
609 * @brief Allocate a demux packet. Free with FreeDemuxPacket
610 * @param dataSize The size of the data that will go into the packet
611 * @return The allocated packet
612 */
613 DemuxPacket* AllocateDemuxPacket(int dataSize)
614 {
615 return m_instanceData->toKodi.allocate_demux_packet(m_instanceData->toKodi.kodiInstance,
616 dataSize);
617 }
618
619 /*!
620 * @brief Allocate a demux packet. Free with FreeDemuxPacket
621 * @param dataSize The size of the data that will go into the packet
622 * @return The allocated packet
623 */
624 DemuxPacket* AllocateEncryptedDemuxPacket(int dataSize, unsigned int encryptedSubsampleCount)
625 {
626 return m_instanceData->toKodi.allocate_encrypted_demux_packet(
627 m_instanceData->toKodi.kodiInstance, dataSize, encryptedSubsampleCount);
628 }
629
630 /*!
631 * @brief Free a packet that was allocated with AllocateDemuxPacket
632 * @param packet The packet to free
633 */
634 void FreeDemuxPacket(DemuxPacket* packet)
635 {
636 return m_instanceData->toKodi.free_demux_packet(m_instanceData->toKodi.kodiInstance, packet);
637 }
638
639private:
640 static int compareVersion(const int v1[3], const int v2[3])
641 {
642 for (unsigned i(0); i < 3; ++i)
643 if (v1[i] != v2[i])
644 return v1[i] - v2[i];
645 return 0;
646 }
647
648 void SetAddonStruct(KODI_HANDLE instance, const std::string& kodiVersion)
649 {
650 if (instance == nullptr)
651 throw std::logic_error("kodi::addon::CInstanceInputStream: Creation with empty addon "
652 "structure not allowed, table must be given from Kodi!");
653 int api[3] = { 0, 0, 0 };
654 sscanf(kodiVersion.c_str(), "%d.%d.%d", &api[0], &api[1], &api[2]);
655
656 m_instanceData = static_cast<AddonInstance_InputStream*>(instance);
657 m_instanceData->toAddon.addonInstance = this;
658 m_instanceData->toAddon.open = ADDON_Open;
659 m_instanceData->toAddon.close = ADDON_Close;
660 m_instanceData->toAddon.get_capabilities = ADDON_GetCapabilities;
661
662 m_instanceData->toAddon.get_stream_ids = ADDON_GetStreamIds;
663 m_instanceData->toAddon.get_stream = ADDON_GetStream;
664 m_instanceData->toAddon.enable_stream = ADDON_EnableStream;
665 m_instanceData->toAddon.open_stream = ADDON_OpenStream;
666 m_instanceData->toAddon.demux_reset = ADDON_DemuxReset;
667 m_instanceData->toAddon.demux_abort = ADDON_DemuxAbort;
668 m_instanceData->toAddon.demux_flush = ADDON_DemuxFlush;
669 m_instanceData->toAddon.demux_read = ADDON_DemuxRead;
670 m_instanceData->toAddon.demux_seek_time = ADDON_DemuxSeekTime;
671 m_instanceData->toAddon.demux_set_speed = ADDON_DemuxSetSpeed;
672 m_instanceData->toAddon.set_video_resolution = ADDON_SetVideoResolution;
673
674 m_instanceData->toAddon.get_total_time = ADDON_GetTotalTime;
675 m_instanceData->toAddon.get_time = ADDON_GetTime;
676
677 m_instanceData->toAddon.get_times = ADDON_GetTimes;
678 m_instanceData->toAddon.pos_time = ADDON_PosTime;
679
680 m_instanceData->toAddon.read_stream = ADDON_ReadStream;
681 m_instanceData->toAddon.seek_stream = ADDON_SeekStream;
682 m_instanceData->toAddon.position_stream = ADDON_PositionStream;
683 m_instanceData->toAddon.length_stream = ADDON_LengthStream;
684 m_instanceData->toAddon.is_real_time_stream = ADDON_IsRealTimeStream;
685
686 int minChapterVersion[3] = { 2, 0, 10 };
687 if (compareVersion(api, minChapterVersion) >= 0)
688 {
689 m_instanceData->toAddon.get_chapter = ADDON_GetChapter;
690 m_instanceData->toAddon.get_chapter_count = ADDON_GetChapterCount;
691 m_instanceData->toAddon.get_chapter_name = ADDON_GetChapterName;
692 m_instanceData->toAddon.get_chapter_pos = ADDON_GetChapterPos;
693 m_instanceData->toAddon.seek_chapter = ADDON_SeekChapter;
694 }
695
696 int minBlockSizeVersion[3] = {2, 0, 12};
697 if (compareVersion(api, minBlockSizeVersion) >= 0)
698 {
699 m_instanceData->toAddon.block_size_stream = ADDON_GetBlockSize;
700 }
701 }
702
703 inline static bool ADDON_Open(const AddonInstance_InputStream* instance, INPUTSTREAM* props)
704 {
705 return static_cast<CInstanceInputStream*>(instance->toAddon.addonInstance)->Open(*props);
706 }
707
708 inline static void ADDON_Close(const AddonInstance_InputStream* instance)
709 {
710 static_cast<CInstanceInputStream*>(instance->toAddon.addonInstance)->Close();
711 }
712
713 inline static void ADDON_GetCapabilities(const AddonInstance_InputStream* instance,
714 INPUTSTREAM_CAPABILITIES* capabilities)
715 {
716 static_cast<CInstanceInputStream*>(instance->toAddon.addonInstance)
717 ->GetCapabilities(*capabilities);
718 }
719
720
721 // IDemux
722 inline static struct INPUTSTREAM_IDS ADDON_GetStreamIds(const AddonInstance_InputStream* instance)
723 {
724 return static_cast<CInstanceInputStream*>(instance->toAddon.addonInstance)->GetStreamIds();
725 }
726
727 inline static struct INPUTSTREAM_INFO ADDON_GetStream(const AddonInstance_InputStream* instance,
728 int streamid)
729 {
730 return static_cast<CInstanceInputStream*>(instance->toAddon.addonInstance)->GetStream(streamid);
731 }
732
733 inline static void ADDON_EnableStream(const AddonInstance_InputStream* instance,
734 int streamid,
735 bool enable)
736 {
737 static_cast<CInstanceInputStream*>(instance->toAddon.addonInstance)
738 ->EnableStream(streamid, enable);
739 }
740
741 inline static bool ADDON_OpenStream(const AddonInstance_InputStream* instance, int streamid)
742 {
743 return static_cast<CInstanceInputStream*>(instance->toAddon.addonInstance)
744 ->OpenStream(streamid);
745 }
746
747 inline static void ADDON_DemuxReset(const AddonInstance_InputStream* instance)
748 {
749 static_cast<CInstanceInputStream*>(instance->toAddon.addonInstance)->DemuxReset();
750 }
751
752 inline static void ADDON_DemuxAbort(const AddonInstance_InputStream* instance)
753 {
754 static_cast<CInstanceInputStream*>(instance->toAddon.addonInstance)->DemuxAbort();
755 }
756
757 inline static void ADDON_DemuxFlush(const AddonInstance_InputStream* instance)
758 {
759 static_cast<CInstanceInputStream*>(instance->toAddon.addonInstance)->DemuxFlush();
760 }
761
762 inline static DemuxPacket* ADDON_DemuxRead(const AddonInstance_InputStream* instance)
763 {
764 return static_cast<CInstanceInputStream*>(instance->toAddon.addonInstance)->DemuxRead();
765 }
766
767 inline static bool ADDON_DemuxSeekTime(const AddonInstance_InputStream* instance,
768 double time,
769 bool backwards,
770 double* startpts)
771 {
772 return static_cast<CInstanceInputStream*>(instance->toAddon.addonInstance)
773 ->DemuxSeekTime(time, backwards, *startpts);
774 }
775
776 inline static void ADDON_DemuxSetSpeed(const AddonInstance_InputStream* instance, int speed)
777 {
778 static_cast<CInstanceInputStream*>(instance->toAddon.addonInstance)->DemuxSetSpeed(speed);
779 }
780
781 inline static void ADDON_SetVideoResolution(const AddonInstance_InputStream* instance,
782 int width,
783 int height)
784 {
785 static_cast<CInstanceInputStream*>(instance->toAddon.addonInstance)
786 ->SetVideoResolution(width, height);
787 }
788
789
790 // IDisplayTime
791 inline static int ADDON_GetTotalTime(const AddonInstance_InputStream* instance)
792 {
793 return static_cast<CInstanceInputStream*>(instance->toAddon.addonInstance)->GetTotalTime();
794 }
795
796 inline static int ADDON_GetTime(const AddonInstance_InputStream* instance)
797 {
798 return static_cast<CInstanceInputStream*>(instance->toAddon.addonInstance)->GetTime();
799 }
800
801 // ITime
802 inline static bool ADDON_GetTimes(const AddonInstance_InputStream* instance,
803 INPUTSTREAM_TIMES* times)
804 {
805 return static_cast<CInstanceInputStream*>(instance->toAddon.addonInstance)->GetTimes(*times);
806 }
807
808 // IPosTime
809 inline static bool ADDON_PosTime(const AddonInstance_InputStream* instance, int ms)
810 {
811 return static_cast<CInstanceInputStream*>(instance->toAddon.addonInstance)->PosTime(ms);
812 }
813
814 inline static int ADDON_GetChapter(const AddonInstance_InputStream* instance)
815 {
816 return static_cast<CInstanceInputStream*>(instance->toAddon.addonInstance)->GetChapter();
817 }
818
819 inline static int ADDON_GetChapterCount(const AddonInstance_InputStream* instance)
820 {
821 return static_cast<CInstanceInputStream*>(instance->toAddon.addonInstance)->GetChapterCount();
822 }
823
824 inline static const char* ADDON_GetChapterName(const AddonInstance_InputStream* instance, int ch)
825 {
826 return static_cast<CInstanceInputStream*>(instance->toAddon.addonInstance)->GetChapterName(ch);
827 }
828
829 inline static int64_t ADDON_GetChapterPos(const AddonInstance_InputStream* instance, int ch)
830 {
831 return static_cast<CInstanceInputStream*>(instance->toAddon.addonInstance)->GetChapterPos(ch);
832 }
833
834 inline static bool ADDON_SeekChapter(const AddonInstance_InputStream* instance, int ch)
835 {
836 return static_cast<CInstanceInputStream*>(instance->toAddon.addonInstance)->SeekChapter(ch);
837 }
838
839 inline static int ADDON_ReadStream(const AddonInstance_InputStream* instance,
840 uint8_t* buffer,
841 unsigned int bufferSize)
842 {
843 return static_cast<CInstanceInputStream*>(instance->toAddon.addonInstance)
844 ->ReadStream(buffer, bufferSize);
845 }
846
847 inline static int64_t ADDON_SeekStream(const AddonInstance_InputStream* instance,
848 int64_t position,
849 int whence)
850 {
851 return static_cast<CInstanceInputStream*>(instance->toAddon.addonInstance)
852 ->SeekStream(position, whence);
853 }
854
855 inline static int64_t ADDON_PositionStream(const AddonInstance_InputStream* instance)
856 {
857 return static_cast<CInstanceInputStream*>(instance->toAddon.addonInstance)->PositionStream();
858 }
859
860 inline static int64_t ADDON_LengthStream(const AddonInstance_InputStream* instance)
861 {
862 return static_cast<CInstanceInputStream*>(instance->toAddon.addonInstance)->LengthStream();
863 }
864
865 inline static int ADDON_GetBlockSize(const AddonInstance_InputStream* instance)
866 {
867 return static_cast<CInstanceInputStream*>(instance->toAddon.addonInstance)->GetBlockSize();
868 }
869
870 inline static bool ADDON_IsRealTimeStream(const AddonInstance_InputStream* instance)
871 {
872 return static_cast<CInstanceInputStream*>(instance->toAddon.addonInstance)->IsRealTimeStream();
873 }
874
875 AddonInstance_InputStream* m_instanceData;
876};
877
878} /* namespace addon */
879} /* namespace kodi */
880
881#endif /* __cplusplus */
diff --git a/xbmc/addons/kodi-addon-dev-kit/include/kodi/addon-instance/PVR.h b/xbmc/addons/kodi-addon-dev-kit/include/kodi/addon-instance/PVR.h
deleted file mode 100644
index 0bca8e2..0000000
--- a/xbmc/addons/kodi-addon-dev-kit/include/kodi/addon-instance/PVR.h
+++ /dev/null
@@ -1,3423 +0,0 @@
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_NOTICE, "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_NOTICE, "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 bytes.
627 /// @param[in] used The used disk space in bytes.
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 = 10 * 1024 * 1024 * 1024; // To set complete size of drive in bytes
639 /// used = 122324243; // 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-addon-dev-kit/include/kodi/addon-instance/Peripheral.h b/xbmc/addons/kodi-addon-dev-kit/include/kodi/addon-instance/Peripheral.h
deleted file mode 100644
index 2067d51..0000000
--- a/xbmc/addons/kodi-addon-dev-kit/include/kodi/addon-instance/Peripheral.h
+++ /dev/null
@@ -1,847 +0,0 @@
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
13namespace kodi { namespace addon { class CInstancePeripheral; }}
14
15/* indicates a joystick has no preference for port number */
16#define NO_PORT_REQUESTED (-1)
17
18/* joystick's driver button/hat/axis index is unknown */
19#define DRIVER_INDEX_UNKNOWN (-1)
20
21extern "C"
22{
23
24 /// @name Peripheral types
25 ///{
26
27 /*!
28 * @brief API error codes
29 */
30 typedef enum PERIPHERAL_ERROR
31 {
32 PERIPHERAL_NO_ERROR = 0, // no error occurred
33 PERIPHERAL_ERROR_UNKNOWN = -1, // an unknown error occurred
34 PERIPHERAL_ERROR_FAILED = -2, // the command failed
35 PERIPHERAL_ERROR_INVALID_PARAMETERS = -3, // the parameters of the method are invalid for this operation
36 PERIPHERAL_ERROR_NOT_IMPLEMENTED = -4, // the method that the frontend called is not implemented
37 PERIPHERAL_ERROR_NOT_CONNECTED = -5, // no peripherals are connected
38 PERIPHERAL_ERROR_CONNECTION_FAILED = -6, // peripherals are connected, but command was interrupted
39 } PERIPHERAL_ERROR;
40
41 /*!
42 * @brief Peripheral types
43 */
44 typedef enum PERIPHERAL_TYPE
45 {
46 PERIPHERAL_TYPE_UNKNOWN,
47 PERIPHERAL_TYPE_JOYSTICK,
48 PERIPHERAL_TYPE_KEYBOARD,
49 } PERIPHERAL_TYPE;
50
51 /*!
52 * @brief Information shared between peripherals
53 */
54 typedef struct PERIPHERAL_INFO
55 {
56 PERIPHERAL_TYPE type; /*!< @brief type of peripheral */
57 char* name; /*!< @brief name of peripheral */
58 uint16_t vendor_id; /*!< @brief vendor ID of peripheral, 0x0000 if unknown */
59 uint16_t product_id; /*!< @brief product ID of peripheral, 0x0000 if unknown */
60 unsigned int index; /*!< @brief the order in which the add-on identified this peripheral */
61 } ATTRIBUTE_PACKED PERIPHERAL_INFO;
62
63 /*!
64 * @brief Peripheral add-on capabilities.
65 */
66 typedef struct PERIPHERAL_CAPABILITIES
67 {
68 bool provides_joysticks; /*!< @brief true if the add-on provides joysticks */
69 bool provides_joystick_rumble;
70 bool provides_joystick_power_off;
71 bool provides_buttonmaps; /*!< @brief true if the add-on provides button maps */
72 } ATTRIBUTE_PACKED PERIPHERAL_CAPABILITIES;
73 ///}
74
75 /// @name Event types
76 ///{
77
78 /*!
79 * @brief Types of events that can be sent and received
80 */
81 typedef enum PERIPHERAL_EVENT_TYPE
82 {
83 PERIPHERAL_EVENT_TYPE_NONE, /*!< @brief unknown event */
84 PERIPHERAL_EVENT_TYPE_DRIVER_BUTTON, /*!< @brief state changed for joystick driver button */
85 PERIPHERAL_EVENT_TYPE_DRIVER_HAT, /*!< @brief state changed for joystick driver hat */
86 PERIPHERAL_EVENT_TYPE_DRIVER_AXIS, /*!< @brief state changed for joystick driver axis */
87 PERIPHERAL_EVENT_TYPE_SET_MOTOR, /*!< @brief set the state for joystick rumble motor */
88 } PERIPHERAL_EVENT_TYPE;
89
90 /*!
91 * @brief States a button can have
92 */
93 typedef enum JOYSTICK_STATE_BUTTON
94 {
95 JOYSTICK_STATE_BUTTON_UNPRESSED = 0x0, /*!< @brief button is released */
96 JOYSTICK_STATE_BUTTON_PRESSED = 0x1, /*!< @brief button is pressed */
97 } JOYSTICK_STATE_BUTTON;
98
99 /*!
100 * @brief States a D-pad (also called a hat) can have
101 */
102 typedef enum JOYSTICK_STATE_HAT
103 {
104 JOYSTICK_STATE_HAT_UNPRESSED = 0x0, /*!< @brief no directions are pressed */
105 JOYSTICK_STATE_HAT_LEFT = 0x1, /*!< @brief only left is pressed */
106 JOYSTICK_STATE_HAT_RIGHT = 0x2, /*!< @brief only right is pressed */
107 JOYSTICK_STATE_HAT_UP = 0x4, /*!< @brief only up is pressed */
108 JOYSTICK_STATE_HAT_DOWN = 0x8, /*!< @brief only down is pressed */
109 JOYSTICK_STATE_HAT_LEFT_UP = JOYSTICK_STATE_HAT_LEFT | JOYSTICK_STATE_HAT_UP,
110 JOYSTICK_STATE_HAT_LEFT_DOWN = JOYSTICK_STATE_HAT_LEFT | JOYSTICK_STATE_HAT_DOWN,
111 JOYSTICK_STATE_HAT_RIGHT_UP = JOYSTICK_STATE_HAT_RIGHT | JOYSTICK_STATE_HAT_UP,
112 JOYSTICK_STATE_HAT_RIGHT_DOWN = JOYSTICK_STATE_HAT_RIGHT | JOYSTICK_STATE_HAT_DOWN,
113 } JOYSTICK_STATE_HAT;
114
115 /*!
116 * @brief Axis value in the closed interval [-1.0, 1.0]
117 *
118 * The axis state uses the XInput coordinate system:
119 * - Negative values signify down or to the left
120 * - Positive values signify up or to the right
121 */
122 typedef float JOYSTICK_STATE_AXIS;
123
124 /*!
125 * @brief Motor value in the closed interval [0.0, 1.0]
126 */
127 typedef float JOYSTICK_STATE_MOTOR;
128
129 /*!
130 * @brief Event information
131 */
132 typedef struct PERIPHERAL_EVENT
133 {
134 /*! @brief Index of the peripheral handling/receiving the event */
135 unsigned int peripheral_index;
136
137 /*! @brief Type of the event used to determine which enum field to access below */
138 PERIPHERAL_EVENT_TYPE type;
139
140 /*! @brief The index of the event source */
141 unsigned int driver_index;
142
143 JOYSTICK_STATE_BUTTON driver_button_state;
144 JOYSTICK_STATE_HAT driver_hat_state;
145 JOYSTICK_STATE_AXIS driver_axis_state;
146 JOYSTICK_STATE_MOTOR motor_state;
147 } ATTRIBUTE_PACKED PERIPHERAL_EVENT;
148 ///}
149
150 /// @name Joystick types
151 ///{
152
153 /*!
154 * @brief Info specific to joystick peripherals
155 */
156 typedef struct JOYSTICK_INFO
157 {
158 PERIPHERAL_INFO peripheral; /*!< @brief peripheral info for this joystick */
159 char* provider; /*!< @brief name of the driver or interface providing the joystick */
160 int requested_port; /*!< @brief requested port number (such as for 360 controllers), or NO_PORT_REQUESTED */
161 unsigned int button_count; /*!< @brief number of buttons reported by the driver */
162 unsigned int hat_count; /*!< @brief number of hats reported by the driver */
163 unsigned int axis_count; /*!< @brief number of axes reported by the driver */
164 unsigned int motor_count; /*!< @brief number of motors reported by the driver */
165 bool supports_poweroff; /*!< @brief whether the joystick supports being powered off */
166 } ATTRIBUTE_PACKED JOYSTICK_INFO;
167
168 /*!
169 * @brief Driver input primitives
170 *
171 * Mapping lower-level driver values to higher-level controller features is
172 * non-injective; two triggers can share a single axis.
173 *
174 * To handle this, driver values are subdivided into "primitives" that map
175 * injectively to higher-level features.
176 */
177 typedef enum JOYSTICK_DRIVER_PRIMITIVE_TYPE
178 {
179 JOYSTICK_DRIVER_PRIMITIVE_TYPE_UNKNOWN,
180 JOYSTICK_DRIVER_PRIMITIVE_TYPE_BUTTON,
181 JOYSTICK_DRIVER_PRIMITIVE_TYPE_HAT_DIRECTION,
182 JOYSTICK_DRIVER_PRIMITIVE_TYPE_SEMIAXIS,
183 JOYSTICK_DRIVER_PRIMITIVE_TYPE_MOTOR,
184 JOYSTICK_DRIVER_PRIMITIVE_TYPE_KEY,
185 JOYSTICK_DRIVER_PRIMITIVE_TYPE_MOUSE_BUTTON,
186 JOYSTICK_DRIVER_PRIMITIVE_TYPE_RELPOINTER_DIRECTION,
187 } JOYSTICK_DRIVER_PRIMITIVE_TYPE;
188
189 /*!
190 * @brief Button primitive
191 */
192 typedef struct JOYSTICK_DRIVER_BUTTON
193 {
194 int index;
195 } ATTRIBUTE_PACKED JOYSTICK_DRIVER_BUTTON;
196
197 /*!
198 * @brief Hat direction
199 */
200 typedef enum JOYSTICK_DRIVER_HAT_DIRECTION
201 {
202 JOYSTICK_DRIVER_HAT_UNKNOWN,
203 JOYSTICK_DRIVER_HAT_LEFT,
204 JOYSTICK_DRIVER_HAT_RIGHT,
205 JOYSTICK_DRIVER_HAT_UP,
206 JOYSTICK_DRIVER_HAT_DOWN,
207 } JOYSTICK_DRIVER_HAT_DIRECTION;
208
209 /*!
210 * @brief Hat direction primitive
211 */
212 typedef struct JOYSTICK_DRIVER_HAT
213 {
214 int index;
215 JOYSTICK_DRIVER_HAT_DIRECTION direction;
216 } ATTRIBUTE_PACKED JOYSTICK_DRIVER_HAT;
217
218 /*!
219 * @brief Semiaxis direction
220 */
221 typedef enum JOYSTICK_DRIVER_SEMIAXIS_DIRECTION
222 {
223 JOYSTICK_DRIVER_SEMIAXIS_NEGATIVE = -1, /*!< @brief negative half of the axis */
224 JOYSTICK_DRIVER_SEMIAXIS_UNKNOWN = 0, /*!< @brief unknown direction */
225 JOYSTICK_DRIVER_SEMIAXIS_POSITIVE = 1, /*!< @brief positive half of the axis */
226 } JOYSTICK_DRIVER_SEMIAXIS_DIRECTION;
227
228 /*!
229 * @brief Semiaxis primitive
230 */
231 typedef struct JOYSTICK_DRIVER_SEMIAXIS
232 {
233 int index;
234 int center;
235 JOYSTICK_DRIVER_SEMIAXIS_DIRECTION direction;
236 unsigned int range;
237 } ATTRIBUTE_PACKED JOYSTICK_DRIVER_SEMIAXIS;
238
239 /*!
240 * @brief Motor primitive
241 */
242 typedef struct JOYSTICK_DRIVER_MOTOR
243 {
244 int index;
245 } ATTRIBUTE_PACKED JOYSTICK_DRIVER_MOTOR;
246
247 /*!
248 * @brief Keyboard key primitive
249 */
250 typedef struct JOYSTICK_DRIVER_KEY
251 {
252 char keycode[16];
253 } ATTRIBUTE_PACKED JOYSTICK_DRIVER_KEY;
254
255 /*!
256 * @brief Mouse buttons
257 */
258 typedef enum JOYSTICK_DRIVER_MOUSE_INDEX
259 {
260 JOYSTICK_DRIVER_MOUSE_INDEX_UNKNOWN,
261 JOYSTICK_DRIVER_MOUSE_INDEX_LEFT,
262 JOYSTICK_DRIVER_MOUSE_INDEX_RIGHT,
263 JOYSTICK_DRIVER_MOUSE_INDEX_MIDDLE,
264 JOYSTICK_DRIVER_MOUSE_INDEX_BUTTON4,
265 JOYSTICK_DRIVER_MOUSE_INDEX_BUTTON5,
266 JOYSTICK_DRIVER_MOUSE_INDEX_WHEEL_UP,
267 JOYSTICK_DRIVER_MOUSE_INDEX_WHEEL_DOWN,
268 JOYSTICK_DRIVER_MOUSE_INDEX_HORIZ_WHEEL_LEFT,
269 JOYSTICK_DRIVER_MOUSE_INDEX_HORIZ_WHEEL_RIGHT,
270 } JOYSTICK_DRIVER_MOUSE_INDEX;
271
272 /*!
273 * @brief Mouse button primitive
274 */
275 typedef struct JOYSTICK_DRIVER_MOUSE_BUTTON
276 {
277 JOYSTICK_DRIVER_MOUSE_INDEX button;
278 } ATTRIBUTE_PACKED JOYSTICK_DRIVER_MOUSE_BUTTON;
279
280 /*!
281 * @brief Relative pointer direction
282 */
283 typedef enum JOYSTICK_DRIVER_RELPOINTER_DIRECTION
284 {
285 JOYSTICK_DRIVER_RELPOINTER_UNKNOWN,
286 JOYSTICK_DRIVER_RELPOINTER_LEFT,
287 JOYSTICK_DRIVER_RELPOINTER_RIGHT,
288 JOYSTICK_DRIVER_RELPOINTER_UP,
289 JOYSTICK_DRIVER_RELPOINTER_DOWN,
290 } JOYSTICK_DRIVER_RELPOINTER_DIRECTION;
291
292 /*!
293 * @brief Relative pointer direction primitive
294 */
295 typedef struct JOYSTICK_DRIVER_RELPOINTER
296 {
297 JOYSTICK_DRIVER_RELPOINTER_DIRECTION direction;
298 } ATTRIBUTE_PACKED JOYSTICK_DRIVER_RELPOINTER;
299
300 /*!
301 * @brief Driver primitive struct
302 */
303 typedef struct JOYSTICK_DRIVER_PRIMITIVE
304 {
305 JOYSTICK_DRIVER_PRIMITIVE_TYPE type;
306 union
307 {
308 struct JOYSTICK_DRIVER_BUTTON button;
309 struct JOYSTICK_DRIVER_HAT hat;
310 struct JOYSTICK_DRIVER_SEMIAXIS semiaxis;
311 struct JOYSTICK_DRIVER_MOTOR motor;
312 struct JOYSTICK_DRIVER_KEY key;
313 struct JOYSTICK_DRIVER_MOUSE_BUTTON mouse;
314 struct JOYSTICK_DRIVER_RELPOINTER relpointer;
315 };
316 } ATTRIBUTE_PACKED JOYSTICK_DRIVER_PRIMITIVE;
317
318 /*!
319 * @brief Controller feature
320 *
321 * Controller features are an abstraction over driver values. Each feature
322 * maps to one or more driver primitives.
323 */
324 typedef enum JOYSTICK_FEATURE_TYPE
325 {
326 JOYSTICK_FEATURE_TYPE_UNKNOWN,
327 JOYSTICK_FEATURE_TYPE_SCALAR,
328 JOYSTICK_FEATURE_TYPE_ANALOG_STICK,
329 JOYSTICK_FEATURE_TYPE_ACCELEROMETER,
330 JOYSTICK_FEATURE_TYPE_MOTOR,
331 JOYSTICK_FEATURE_TYPE_RELPOINTER,
332 JOYSTICK_FEATURE_TYPE_ABSPOINTER,
333 JOYSTICK_FEATURE_TYPE_WHEEL,
334 JOYSTICK_FEATURE_TYPE_THROTTLE,
335 JOYSTICK_FEATURE_TYPE_KEY,
336 } JOYSTICK_FEATURE_TYPE;
337
338 /*!
339 * @brief Indices used to access a feature's driver primitives
340 */
341 typedef enum JOYSTICK_FEATURE_PRIMITIVE
342 {
343 // Scalar feature (a button, hat direction or semiaxis)
344 JOYSTICK_SCALAR_PRIMITIVE = 0,
345
346 // Analog stick
347 JOYSTICK_ANALOG_STICK_UP = 0,
348 JOYSTICK_ANALOG_STICK_DOWN = 1,
349 JOYSTICK_ANALOG_STICK_RIGHT = 2,
350 JOYSTICK_ANALOG_STICK_LEFT = 3,
351
352 // Accelerometer
353 JOYSTICK_ACCELEROMETER_POSITIVE_X = 0,
354 JOYSTICK_ACCELEROMETER_POSITIVE_Y = 1,
355 JOYSTICK_ACCELEROMETER_POSITIVE_Z = 2,
356
357 // Motor
358 JOYSTICK_MOTOR_PRIMITIVE = 0,
359
360 // Wheel
361 JOYSTICK_WHEEL_LEFT = 0,
362 JOYSTICK_WHEEL_RIGHT = 1,
363
364 // Throttle
365 JOYSTICK_THROTTLE_UP = 0,
366 JOYSTICK_THROTTLE_DOWN = 1,
367
368 // Key
369 JOYSTICK_KEY_PRIMITIVE = 0,
370
371 // Mouse button
372 JOYSTICK_MOUSE_BUTTON = 0,
373
374 // Relative pointer direction
375 JOYSTICK_RELPOINTER_UP = 0,
376 JOYSTICK_RELPOINTER_DOWN = 1,
377 JOYSTICK_RELPOINTER_RIGHT = 2,
378 JOYSTICK_RELPOINTER_LEFT = 3,
379
380 // Maximum number of primitives
381 JOYSTICK_PRIMITIVE_MAX = 4,
382 } JOYSTICK_FEATURE_PRIMITIVE;
383
384 /*!
385 * @brief Mapping between higher-level controller feature and its driver primitives
386 */
387 typedef struct JOYSTICK_FEATURE
388 {
389 char* name;
390 JOYSTICK_FEATURE_TYPE type;
391 struct JOYSTICK_DRIVER_PRIMITIVE primitives[JOYSTICK_PRIMITIVE_MAX];
392 } ATTRIBUTE_PACKED JOYSTICK_FEATURE;
393 ///}
394
395 typedef struct AddonProps_Peripheral
396 {
397 const char* user_path; /*!< @brief path to the user profile */
398 const char* addon_path; /*!< @brief path to this add-on */
399 } ATTRIBUTE_PACKED AddonProps_Peripheral;
400
401 struct AddonInstance_Peripheral;
402
403 typedef struct AddonToKodiFuncTable_Peripheral
404 {
405 KODI_HANDLE kodiInstance;
406 void (*trigger_scan)(void* kodiInstance);
407 void (*refresh_button_maps)(void* kodiInstance, const char* device_name, const char* controller_id);
408 unsigned int (*feature_count)(void* kodiInstance, const char* controller_id, JOYSTICK_FEATURE_TYPE type);
409 JOYSTICK_FEATURE_TYPE (*feature_type)(void* kodiInstance, const char* controller_id, const char* feature_name);
410 } AddonToKodiFuncTable_Peripheral;
411
412 //! @todo Mouse, light gun, multitouch
413
414 typedef struct KodiToAddonFuncTable_Peripheral
415 {
416 kodi::addon::CInstancePeripheral* addonInstance;
417
418 void (__cdecl* get_capabilities)(const AddonInstance_Peripheral* addonInstance, PERIPHERAL_CAPABILITIES* capabilities);
419 PERIPHERAL_ERROR (__cdecl* perform_device_scan)(const AddonInstance_Peripheral* addonInstance, unsigned int* peripheral_count, PERIPHERAL_INFO** scan_results);
420 void (__cdecl* free_scan_results)(const AddonInstance_Peripheral* addonInstance, unsigned int peripheral_count, PERIPHERAL_INFO* scan_results);
421 PERIPHERAL_ERROR (__cdecl* get_events)(const AddonInstance_Peripheral* addonInstance, unsigned int* event_count, PERIPHERAL_EVENT** events);
422 void (__cdecl* free_events)(const AddonInstance_Peripheral* addonInstance, unsigned int event_count, PERIPHERAL_EVENT* events);
423 bool (__cdecl* send_event)(const AddonInstance_Peripheral* addonInstance, const PERIPHERAL_EVENT* event);
424
425 /// @name Joystick operations
426 ///{
427 PERIPHERAL_ERROR (__cdecl* get_joystick_info)(const AddonInstance_Peripheral* addonInstance, unsigned int index, JOYSTICK_INFO* info);
428 void (__cdecl* free_joystick_info)(const AddonInstance_Peripheral* addonInstance, JOYSTICK_INFO* info);
429 PERIPHERAL_ERROR (__cdecl* get_features)(const AddonInstance_Peripheral* addonInstance, const JOYSTICK_INFO* joystick, const char* controller_id, unsigned int* feature_count, JOYSTICK_FEATURE** features);
430 void (__cdecl* free_features)(const AddonInstance_Peripheral* addonInstance, unsigned int feature_count, JOYSTICK_FEATURE* features);
431 PERIPHERAL_ERROR (__cdecl* map_features)(const AddonInstance_Peripheral* addonInstance, const JOYSTICK_INFO* joystick, const char* controller_id, unsigned int feature_count, const JOYSTICK_FEATURE* features);
432 PERIPHERAL_ERROR (__cdecl* get_ignored_primitives)(const AddonInstance_Peripheral* addonInstance, const JOYSTICK_INFO* joystick, unsigned int* feature_count, JOYSTICK_DRIVER_PRIMITIVE** primitives);
433 void (__cdecl* free_primitives)(const AddonInstance_Peripheral* addonInstance, unsigned int, JOYSTICK_DRIVER_PRIMITIVE* primitives);
434 PERIPHERAL_ERROR (__cdecl* set_ignored_primitives)(const AddonInstance_Peripheral* addonInstance, const JOYSTICK_INFO* joystick, unsigned int primitive_count, const JOYSTICK_DRIVER_PRIMITIVE* primitives);
435 void (__cdecl* save_button_map)(const AddonInstance_Peripheral* addonInstance, const JOYSTICK_INFO* joystick);
436 void (__cdecl* revert_button_map)(const AddonInstance_Peripheral* addonInstance, const JOYSTICK_INFO* joystick);
437 void (__cdecl* reset_button_map)(const AddonInstance_Peripheral* addonInstance, const JOYSTICK_INFO* joystick, const char* controller_id);
438 void (__cdecl* power_off_joystick)(const AddonInstance_Peripheral* addonInstance, unsigned int index);
439 ///}
440 } KodiToAddonFuncTable_Peripheral;
441
442 typedef struct AddonInstance_Peripheral
443 {
444 AddonProps_Peripheral props;
445 AddonToKodiFuncTable_Peripheral toKodi;
446 KodiToAddonFuncTable_Peripheral toAddon;
447 } AddonInstance_Peripheral;
448
449} /* extern "C" */
450
451namespace kodi
452{
453namespace addon
454{
455
456 class ATTRIBUTE_HIDDEN CInstancePeripheral : public IAddonInstance
457 {
458 public:
459 CInstancePeripheral()
460 : IAddonInstance(ADDON_INSTANCE_PERIPHERAL, GetKodiTypeVersion(ADDON_INSTANCE_PERIPHERAL))
461 {
462 if (CAddonBase::m_interface->globalSingleInstance != nullptr)
463 throw std::logic_error("kodi::addon::CInstancePeripheral: Creation of more as one in single instance way is not allowed!");
464
465 SetAddonStruct(CAddonBase::m_interface->firstKodiInstance);
466 CAddonBase::m_interface->globalSingleInstance = this;
467 }
468
469 explicit CInstancePeripheral(KODI_HANDLE instance, const std::string& kodiVersion = "")
470 : IAddonInstance(ADDON_INSTANCE_PERIPHERAL,
471 !kodiVersion.empty() ? kodiVersion
472 : GetKodiTypeVersion(ADDON_INSTANCE_PERIPHERAL))
473 {
474 if (CAddonBase::m_interface->globalSingleInstance != nullptr)
475 throw std::logic_error("kodi::addon::CInstancePeripheral: Creation of multiple together with single instance way is not allowed!");
476
477 SetAddonStruct(instance);
478 }
479
480 ~CInstancePeripheral() override = default;
481
482 /// @name Peripheral operations
483 ///{
484 /*!
485 * @brief Get the list of features that this add-on provides
486 * @param capabilities The add-on's capabilities.
487 * @remarks Valid implementation required.
488 *
489 * Called by the frontend to query the add-on's capabilities and supported
490 * peripherals. All capabilities that the add-on supports should be set to true.
491 *
492 */
493 virtual void GetCapabilities(PERIPHERAL_CAPABILITIES &capabilities) { }
494
495 /*!
496 * @brief Perform a scan for joysticks
497 * @param peripheral_count Assigned to the number of peripherals allocated
498 * @param scan_results Assigned to allocated memory
499 * @return PERIPHERAL_NO_ERROR if successful; peripherals must be freed using
500 * FreeScanResults() in this case
501 *
502 * The frontend calls this when a hardware change is detected. If an add-on
503 * detects a hardware change, it can trigger this function using the
504 * TriggerScan() callback.
505 */
506 virtual PERIPHERAL_ERROR PerformDeviceScan(unsigned int* peripheral_count, PERIPHERAL_INFO** scan_results) { return PERIPHERAL_ERROR_NOT_IMPLEMENTED; }
507
508 /*!
509 * @brief Free the memory allocated in PerformDeviceScan()
510 *
511 * Must be called if PerformDeviceScan() returns PERIPHERAL_NO_ERROR.
512 *
513 * @param peripheral_count The number of events allocated for the events array
514 * @param scan_results The array of allocated peripherals
515 */
516 virtual void FreeScanResults(unsigned int peripheral_count, PERIPHERAL_INFO* scan_results) { }
517
518 /*!
519 * @brief Get all events that have occurred since the last call to GetEvents()
520 * @return PERIPHERAL_NO_ERROR if successful; events must be freed using
521 * FreeEvents() in this case
522 */
523 virtual PERIPHERAL_ERROR GetEvents(unsigned int* event_count, PERIPHERAL_EVENT** events) { return PERIPHERAL_ERROR_NOT_IMPLEMENTED; }
524
525 /*!
526 * @brief Free the memory allocated in GetEvents()
527 *
528 * Must be called if GetEvents() returns PERIPHERAL_NO_ERROR.
529 *
530 * @param event_count The number of events allocated for the events array
531 * @param events The array of allocated events
532 */
533 virtual void FreeEvents(unsigned int event_count, PERIPHERAL_EVENT* events) { }
534
535 /*!
536 * @brief Send an input event to the peripheral
537 * @param event The input event
538 * @return true if the event was handled, false otherwise
539 */
540 virtual bool SendEvent(const PERIPHERAL_EVENT* event) { return false; }
541 ///}
542
543 /// @name Joystick operations
544 /*!
545 * @note #define PERIPHERAL_ADDON_JOYSTICKS before including kodi_peripheral_dll.h
546 * in the add-on if the add-on provides joysticks and add provides_joysticks="true"
547 * to the kodi.peripheral extension point node in addon.xml.
548 */
549 ///{
550 /*!
551 * @brief Get extended info about an attached joystick
552 * @param index The joystick's driver index
553 * @param info The container for the allocated joystick info
554 * @return PERIPHERAL_NO_ERROR if successful; array must be freed using
555 * FreeJoystickInfo() in this case
556 */
557 virtual PERIPHERAL_ERROR GetJoystickInfo(unsigned int index, JOYSTICK_INFO* info) { return PERIPHERAL_ERROR_NOT_IMPLEMENTED; }
558
559 /*!
560 * @brief Free the memory allocated in GetJoystickInfo()
561 */
562 virtual void FreeJoystickInfo(JOYSTICK_INFO* info) { }
563
564 /*!
565 * @brief Get the features that allow translating the joystick into the controller profile
566 * @param joystick The device's joystick properties; unknown values may be left at their default
567 * @param controller_id The controller profile being requested, e.g. game.controller.default
568 * @param feature_count The number of features allocated for the features array
569 * @param features The array of allocated features
570 * @return PERIPHERAL_NO_ERROR if successful; array must be freed using
571 * FreeButtonMap() in this case
572 */
573 virtual PERIPHERAL_ERROR GetFeatures(const JOYSTICK_INFO* joystick, const char* controller_id,
574 unsigned int* feature_count, JOYSTICK_FEATURE** features) { return PERIPHERAL_ERROR_NOT_IMPLEMENTED; }
575
576 /*!
577 * @brief Free the memory allocated in GetFeatures()
578 *
579 * Must be called if GetFeatures() returns PERIPHERAL_NO_ERROR.
580 *
581 * @param feature_count The number of features allocated for the features array
582 * @param features The array of allocated features
583 */
584 virtual void FreeFeatures(unsigned int feature_count, JOYSTICK_FEATURE* features) { }
585
586 /*!
587 * @brief Add or update joystick features
588 * @param joystick The device's joystick properties; unknown values may be left at their default
589 * @param controller_id The game controller profile being updated
590 * @param feature_count The number of features in the features array
591 * @param features The array of features
592 * @return PERIPHERAL_NO_ERROR if successful
593 */
594 virtual PERIPHERAL_ERROR MapFeatures(const JOYSTICK_INFO* joystick, const char* controller_id,
595 unsigned int feature_count, const JOYSTICK_FEATURE* features) { return PERIPHERAL_ERROR_NOT_IMPLEMENTED; }
596
597 /*!
598 * @brief Get the driver primitives that should be ignored while mapping the device
599 * @param joystick The device's joystick properties; unknown values may be left at their default
600 * @param primitive_count The number of features allocated for the primitives array
601 * @param primitives The array of allocated driver primitives to be ignored
602 * @return PERIPHERAL_NO_ERROR if successful; array must be freed using
603 * FreePrimitives() in this case
604 */
605 virtual PERIPHERAL_ERROR GetIgnoredPrimitives(const JOYSTICK_INFO* joystick,
606 unsigned int* primitive_count,
607 JOYSTICK_DRIVER_PRIMITIVE** primitives) { return PERIPHERAL_ERROR_NOT_IMPLEMENTED; }
608
609 /*!
610 * @brief Free the memory allocated in GetIgnoredPrimitives()
611 *
612 * Must be called if GetIgnoredPrimitives() returns PERIPHERAL_NO_ERROR.
613 *
614 * @param primitive_count The number of driver primitives allocated for the primitives array
615 * @param primitives The array of allocated driver primitives
616 */
617 virtual void FreePrimitives(unsigned int primitive_count, JOYSTICK_DRIVER_PRIMITIVE* primitives) { }
618
619 /*!
620 * @brief Set the list of driver primitives that are ignored for the device
621 * @param joystick The device's joystick properties; unknown values may be left at their default
622 * @param primitive_count The number of driver features in the primitives array
623 * @param primitives The array of driver primitives to ignore
624 * @return PERIPHERAL_NO_ERROR if successful
625 */
626 virtual PERIPHERAL_ERROR SetIgnoredPrimitives(const JOYSTICK_INFO* joystick,
627 unsigned int primitive_count,
628 const JOYSTICK_DRIVER_PRIMITIVE* primitives) { return PERIPHERAL_ERROR_NOT_IMPLEMENTED; }
629
630 /*!
631 * @brief Save the button map for the given joystick
632 * @param joystick The device's joystick properties
633 */
634 virtual void SaveButtonMap(const JOYSTICK_INFO* joystick) { }
635
636 /*!
637 * @brief Revert the button map to the last time it was loaded or committed to disk
638 * @param joystick The device's joystick properties
639 */
640 virtual void RevertButtonMap(const JOYSTICK_INFO* joystick) { }
641
642 /*!
643 * @brief Reset the button map for the given joystick and controller profile ID
644 * @param joystick The device's joystick properties
645 * @param controller_id The game controller profile being reset
646 */
647 virtual void ResetButtonMap(const JOYSTICK_INFO* joystick, const char* controller_id) { }
648
649 /*!
650 * @brief Powers off the given joystick if supported
651 * @param index The joystick's driver index
652 */
653 virtual void PowerOffJoystick(unsigned int index) { }
654
655 const std::string AddonPath() const
656 {
657 return m_instanceData->props.addon_path;
658 }
659
660 const std::string UserPath() const
661 {
662 return m_instanceData->props.user_path;
663 }
664
665 /*!
666 * @brief Trigger a scan for peripherals
667 *
668 * The add-on calls this if a change in hardware is detected.
669 */
670 void TriggerScan(void)
671 {
672 return m_instanceData->toKodi.trigger_scan(m_instanceData->toKodi.kodiInstance);
673 }
674
675 /*!
676 * @brief Notify the frontend that button maps have changed
677 *
678 * @param[optional] deviceName The name of the device to refresh, or empty/null for all devices
679 * @param[optional] controllerId The controller ID to refresh, or empty/null for all controllers
680 */
681 void RefreshButtonMaps(const std::string& deviceName = "", const std::string& controllerId = "")
682 {
683 return m_instanceData->toKodi.refresh_button_maps(m_instanceData->toKodi.kodiInstance, deviceName.c_str(), controllerId.c_str());
684 }
685
686 /*!
687 * @brief Return the number of features belonging to the specified controller
688 *
689 * @param controllerId The controller ID to enumerate
690 * @param type[optional] Type to filter by, or JOYSTICK_FEATURE_TYPE_UNKNOWN for all features
691 *
692 * @return The number of features matching the request parameters
693 */
694 unsigned int FeatureCount(const std::string& controllerId, JOYSTICK_FEATURE_TYPE type = JOYSTICK_FEATURE_TYPE_UNKNOWN)
695 {
696 return m_instanceData->toKodi.feature_count(m_instanceData->toKodi.kodiInstance, controllerId.c_str(), type);
697 }
698
699 /*!
700 * @brief Return the type of the feature
701 *
702 * @param controllerId The controller ID to check
703 * @param featureName The feature to check
704 *
705 * @return The type of the specified feature, or JOYSTICK_FEATURE_TYPE_UNKNOWN
706 * if unknown
707 */
708 JOYSTICK_FEATURE_TYPE FeatureType(const std::string& controllerId, const std::string &featureName)
709 {
710 return m_instanceData->toKodi.feature_type(m_instanceData->toKodi.kodiInstance, controllerId.c_str(), featureName.c_str());
711 }
712
713 private:
714 void SetAddonStruct(KODI_HANDLE instance)
715 {
716 if (instance == nullptr)
717 throw std::logic_error("kodi::addon::CInstancePeripheral: Creation with empty addon structure not allowed, table must be given from Kodi!");
718
719 m_instanceData = static_cast<AddonInstance_Peripheral*>(instance);
720 m_instanceData->toAddon.addonInstance = this;
721
722 m_instanceData->toAddon.get_capabilities = ADDON_GetCapabilities;
723 m_instanceData->toAddon.perform_device_scan = ADDON_PerformDeviceScan;
724 m_instanceData->toAddon.free_scan_results = ADDON_FreeScanResults;
725 m_instanceData->toAddon.get_events = ADDON_GetEvents;
726 m_instanceData->toAddon.free_events = ADDON_FreeEvents;
727 m_instanceData->toAddon.send_event = ADDON_SendEvent;
728
729 m_instanceData->toAddon.get_joystick_info = ADDON_GetJoystickInfo;
730 m_instanceData->toAddon.free_joystick_info = ADDON_FreeJoystickInfo;
731 m_instanceData->toAddon.get_features = ADDON_GetFeatures;
732 m_instanceData->toAddon.free_features = ADDON_FreeFeatures;
733 m_instanceData->toAddon.map_features = ADDON_MapFeatures;
734 m_instanceData->toAddon.get_ignored_primitives = ADDON_GetIgnoredPrimitives;
735 m_instanceData->toAddon.free_primitives = ADDON_FreePrimitives;
736 m_instanceData->toAddon.set_ignored_primitives = ADDON_SetIgnoredPrimitives;
737 m_instanceData->toAddon.save_button_map = ADDON_SaveButtonMap;
738 m_instanceData->toAddon.revert_button_map = ADDON_RevertButtonMap;
739 m_instanceData->toAddon.reset_button_map = ADDON_ResetButtonMap;
740 m_instanceData->toAddon.power_off_joystick = ADDON_PowerOffJoystick;
741 }
742
743 inline static void ADDON_GetCapabilities(const AddonInstance_Peripheral* addonInstance, PERIPHERAL_CAPABILITIES *capabilities)
744 {
745 addonInstance->toAddon.addonInstance->GetCapabilities(*capabilities);
746 }
747
748 inline static PERIPHERAL_ERROR ADDON_PerformDeviceScan(const AddonInstance_Peripheral* addonInstance, unsigned int* peripheral_count, PERIPHERAL_INFO** scan_results)
749 {
750 return addonInstance->toAddon.addonInstance->PerformDeviceScan(peripheral_count, scan_results);
751 }
752
753 inline static void ADDON_FreeScanResults(const AddonInstance_Peripheral* addonInstance, unsigned int peripheral_count, PERIPHERAL_INFO* scan_results)
754 {
755 addonInstance->toAddon.addonInstance->FreeScanResults(peripheral_count, scan_results);
756 }
757
758 inline static PERIPHERAL_ERROR ADDON_GetEvents(const AddonInstance_Peripheral* addonInstance, unsigned int* event_count, PERIPHERAL_EVENT** events)
759 {
760 return addonInstance->toAddon.addonInstance->GetEvents(event_count, events);
761 }
762
763 inline static void ADDON_FreeEvents(const AddonInstance_Peripheral* addonInstance, unsigned int event_count, PERIPHERAL_EVENT* events)
764 {
765 addonInstance->toAddon.addonInstance->FreeEvents(event_count, events);
766 }
767
768 inline static bool ADDON_SendEvent(const AddonInstance_Peripheral* addonInstance, const PERIPHERAL_EVENT* event)
769 {
770 return addonInstance->toAddon.addonInstance->SendEvent(event);
771 }
772
773
774 inline static PERIPHERAL_ERROR ADDON_GetJoystickInfo(const AddonInstance_Peripheral* addonInstance, unsigned int index, JOYSTICK_INFO* info)
775 {
776 return addonInstance->toAddon.addonInstance->GetJoystickInfo(index, info);
777 }
778
779 inline static void ADDON_FreeJoystickInfo(const AddonInstance_Peripheral* addonInstance, JOYSTICK_INFO* info)
780 {
781 addonInstance->toAddon.addonInstance->FreeJoystickInfo(info);
782 }
783
784 inline static PERIPHERAL_ERROR ADDON_GetFeatures(const AddonInstance_Peripheral* addonInstance,
785 const JOYSTICK_INFO* joystick, const char* controller_id,
786 unsigned int* feature_count, JOYSTICK_FEATURE** features)
787 {
788 return addonInstance->toAddon.addonInstance->GetFeatures(joystick, controller_id, feature_count, features);
789 }
790
791 inline static void ADDON_FreeFeatures(const AddonInstance_Peripheral* addonInstance, unsigned int feature_count, JOYSTICK_FEATURE* features)
792 {
793 addonInstance->toAddon.addonInstance->FreeFeatures(feature_count, features);
794 }
795
796 inline static PERIPHERAL_ERROR ADDON_MapFeatures(const AddonInstance_Peripheral* addonInstance,
797 const JOYSTICK_INFO* joystick, const char* controller_id,
798 unsigned int feature_count, const JOYSTICK_FEATURE* features)
799 {
800 return addonInstance->toAddon.addonInstance->MapFeatures(joystick, controller_id, feature_count, features);
801 }
802
803 inline static PERIPHERAL_ERROR ADDON_GetIgnoredPrimitives(const AddonInstance_Peripheral* addonInstance,
804 const JOYSTICK_INFO* joystick, unsigned int* primitive_count,
805 JOYSTICK_DRIVER_PRIMITIVE** primitives)
806 {
807 return addonInstance->toAddon.addonInstance->GetIgnoredPrimitives(joystick, primitive_count, primitives);
808 }
809
810 inline static void ADDON_FreePrimitives(const AddonInstance_Peripheral* addonInstance,
811 unsigned int primitive_count, JOYSTICK_DRIVER_PRIMITIVE* primitives)
812 {
813 addonInstance->toAddon.addonInstance->FreePrimitives(primitive_count, primitives);
814 }
815
816 inline static PERIPHERAL_ERROR ADDON_SetIgnoredPrimitives(const AddonInstance_Peripheral* addonInstance,
817 const JOYSTICK_INFO* joystick, unsigned int primitive_count,
818 const JOYSTICK_DRIVER_PRIMITIVE* primitives)
819 {
820 return addonInstance->toAddon.addonInstance->SetIgnoredPrimitives(joystick, primitive_count, primitives);
821 }
822
823 inline static void ADDON_SaveButtonMap(const AddonInstance_Peripheral* addonInstance, const JOYSTICK_INFO* joystick)
824 {
825 addonInstance->toAddon.addonInstance->SaveButtonMap(joystick);
826 }
827
828 inline static void ADDON_RevertButtonMap(const AddonInstance_Peripheral* addonInstance, const JOYSTICK_INFO* joystick)
829 {
830 addonInstance->toAddon.addonInstance->RevertButtonMap(joystick);
831 }
832
833 inline static void ADDON_ResetButtonMap(const AddonInstance_Peripheral* addonInstance, const JOYSTICK_INFO* joystick, const char* controller_id)
834 {
835 addonInstance->toAddon.addonInstance->ResetButtonMap(joystick, controller_id);
836 }
837
838 inline static void ADDON_PowerOffJoystick(const AddonInstance_Peripheral* addonInstance, unsigned int index)
839 {
840 addonInstance->toAddon.addonInstance->PowerOffJoystick(index);
841 }
842
843 AddonInstance_Peripheral* m_instanceData;
844 };
845
846} /* namespace addon */
847} /* namespace kodi */
diff --git a/xbmc/addons/kodi-addon-dev-kit/include/kodi/addon-instance/PeripheralUtils.h b/xbmc/addons/kodi-addon-dev-kit/include/kodi/addon-instance/PeripheralUtils.h
deleted file mode 100644
index 62e5a93..0000000
--- a/xbmc/addons/kodi-addon-dev-kit/include/kodi/addon-instance/PeripheralUtils.h
+++ /dev/null
@@ -1,735 +0,0 @@
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 "Peripheral.h"
12
13#include <array> // Requires c++11
14#include <cstring>
15#include <string>
16#include <utility>
17#include <vector>
18
19#define PERIPHERAL_SAFE_DELETE(x) do { delete (x); (x) = NULL; } while (0)
20#define PERIPHERAL_SAFE_DELETE_ARRAY(x) do { delete[] (x); (x) = NULL; } while (0)
21
22namespace kodi
23{
24namespace addon
25{
26 /*!
27 * Utility class to manipulate arrays of peripheral types.
28 */
29 template <class THE_CLASS, typename THE_STRUCT>
30 class PeripheralVector
31 {
32 public:
33 static void ToStructs(const std::vector<THE_CLASS>& vecObjects, THE_STRUCT** pStructs)
34 {
35 if (!pStructs)
36 return;
37
38 if (vecObjects.empty())
39 {
40 *pStructs = NULL;
41 }
42 else
43 {
44 (*pStructs) = new THE_STRUCT[vecObjects.size()];
45 for (unsigned int i = 0; i < vecObjects.size(); i++)
46 vecObjects.at(i).ToStruct((*pStructs)[i]);
47 }
48 }
49
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 FreeStructs(unsigned int structCount, THE_STRUCT* structs)
68 {
69 if (structs)
70 {
71 for (unsigned int i = 0; i < structCount; i++)
72 THE_CLASS::FreeStruct(structs[i]);
73 }
74 PERIPHERAL_SAFE_DELETE_ARRAY(structs);
75 }
76 };
77
78 /*!
79 * ADDON::Peripheral
80 *
81 * Wrapper class providing peripheral information. Classes can extend
82 * Peripheral to inherit peripheral properties.
83 */
84 class Peripheral
85 {
86 public:
87 Peripheral(PERIPHERAL_TYPE type = PERIPHERAL_TYPE_UNKNOWN, const std::string& strName = "") :
88 m_type(type),
89 m_strName(strName)
90 {
91 }
92
93 explicit Peripheral(const PERIPHERAL_INFO& info) :
94 m_type(info.type),
95 m_strName(info.name ? info.name : ""),
96 m_vendorId(info.vendor_id),
97 m_productId(info.product_id),
98 m_index(info.index)
99 {
100 }
101
102 virtual ~Peripheral(void) = default;
103
104 PERIPHERAL_TYPE Type(void) const { return m_type; }
105 const std::string& Name(void) const { return m_strName; }
106 uint16_t VendorID(void) const { return m_vendorId; }
107 uint16_t ProductID(void) const { return m_productId; }
108 unsigned int Index(void) const { return m_index; }
109
110 // Derived property: VID and PID are 0x0000 if unknown
111 bool IsVidPidKnown(void) const { return m_vendorId != 0 || m_productId != 0; }
112
113 void SetType(PERIPHERAL_TYPE type) { m_type = type; }
114 void SetName(const std::string& strName) { m_strName = strName; }
115 void SetVendorID(uint16_t vendorId) { m_vendorId = vendorId; }
116 void SetProductID(uint16_t productId) { m_productId = productId; }
117 void SetIndex(unsigned int index) { m_index = index; }
118
119 void ToStruct(PERIPHERAL_INFO& info) const
120 {
121 info.type = m_type;
122 info.name = new char[m_strName.size() + 1];
123 info.vendor_id = m_vendorId;
124 info.product_id = m_productId;
125 info.index = m_index;
126
127 std::strcpy(info.name, m_strName.c_str());
128 }
129
130 static void FreeStruct(PERIPHERAL_INFO& info)
131 {
132 PERIPHERAL_SAFE_DELETE_ARRAY(info.name);
133 }
134
135 private:
136 PERIPHERAL_TYPE m_type;
137 std::string m_strName;
138 uint16_t m_vendorId = 0;
139 uint16_t m_productId = 0;
140 unsigned int m_index = 0;
141 };
142
143 typedef PeripheralVector<Peripheral, PERIPHERAL_INFO> Peripherals;
144
145 /*!
146 * ADDON::PeripheralEvent
147 *
148 * Wrapper class for peripheral events.
149 */
150 class PeripheralEvent
151 {
152 public:
153 PeripheralEvent() = default;
154
155 PeripheralEvent(unsigned int peripheralIndex, unsigned int buttonIndex, JOYSTICK_STATE_BUTTON state) :
156 m_type(PERIPHERAL_EVENT_TYPE_DRIVER_BUTTON),
157 m_peripheralIndex(peripheralIndex),
158 m_driverIndex(buttonIndex),
159 m_buttonState(state)
160 {
161 }
162
163 PeripheralEvent(unsigned int peripheralIndex, unsigned int hatIndex, JOYSTICK_STATE_HAT state) :
164 m_type(PERIPHERAL_EVENT_TYPE_DRIVER_HAT),
165 m_peripheralIndex(peripheralIndex),
166 m_driverIndex(hatIndex),
167 m_hatState(state)
168 {
169 }
170
171 PeripheralEvent(unsigned int peripheralIndex, unsigned int axisIndex, JOYSTICK_STATE_AXIS state) :
172 m_type(PERIPHERAL_EVENT_TYPE_DRIVER_AXIS),
173 m_peripheralIndex(peripheralIndex),
174 m_driverIndex(axisIndex),
175 m_axisState(state)
176 {
177 }
178
179 explicit PeripheralEvent(const PERIPHERAL_EVENT& event) :
180 m_type(event.type),
181 m_peripheralIndex(event.peripheral_index),
182 m_driverIndex(event.driver_index),
183 m_buttonState(event.driver_button_state),
184 m_hatState(event.driver_hat_state),
185 m_axisState(event.driver_axis_state),
186 m_motorState(event.motor_state)
187 {
188 }
189
190 PERIPHERAL_EVENT_TYPE Type(void) const { return m_type; }
191 unsigned int PeripheralIndex(void) const { return m_peripheralIndex; }
192 unsigned int DriverIndex(void) const { return m_driverIndex; }
193 JOYSTICK_STATE_BUTTON ButtonState(void) const { return m_buttonState; }
194 JOYSTICK_STATE_HAT HatState(void) const { return m_hatState; }
195 JOYSTICK_STATE_AXIS AxisState(void) const { return m_axisState; }
196 JOYSTICK_STATE_MOTOR MotorState(void) const { return m_motorState; }
197
198 void SetType(PERIPHERAL_EVENT_TYPE type) { m_type = type; }
199 void SetPeripheralIndex(unsigned int index) { m_peripheralIndex = index; }
200 void SetDriverIndex(unsigned int index) { m_driverIndex = index; }
201 void SetButtonState(JOYSTICK_STATE_BUTTON state) { m_buttonState = state; }
202 void SetHatState(JOYSTICK_STATE_HAT state) { m_hatState = state; }
203 void SetAxisState(JOYSTICK_STATE_AXIS state) { m_axisState = state; }
204 void SetMotorState(JOYSTICK_STATE_MOTOR state) { m_motorState = state; }
205
206 void ToStruct(PERIPHERAL_EVENT& event) const
207 {
208 event.type = m_type;
209 event.peripheral_index = m_peripheralIndex;
210 event.driver_index = m_driverIndex;
211 event.driver_button_state = m_buttonState;
212 event.driver_hat_state = m_hatState;
213 event.driver_axis_state = m_axisState;
214 event.motor_state = m_motorState;
215 }
216
217 static void FreeStruct(PERIPHERAL_EVENT& event)
218 {
219 (void)event;
220 }
221
222 private:
223 PERIPHERAL_EVENT_TYPE m_type = PERIPHERAL_EVENT_TYPE_NONE;
224 unsigned int m_peripheralIndex = 0;
225 unsigned int m_driverIndex = 0;
226 JOYSTICK_STATE_BUTTON m_buttonState = JOYSTICK_STATE_BUTTON_UNPRESSED;
227 JOYSTICK_STATE_HAT m_hatState = JOYSTICK_STATE_HAT_UNPRESSED;
228 JOYSTICK_STATE_AXIS m_axisState = 0.0f;
229 JOYSTICK_STATE_MOTOR m_motorState = 0.0f;
230 };
231
232 typedef PeripheralVector<PeripheralEvent, PERIPHERAL_EVENT> PeripheralEvents;
233
234 /*!
235 * kodi::addon::Joystick
236 *
237 * Wrapper class providing additional joystick information not provided by
238 * ADDON::Peripheral.
239 */
240 class Joystick : public Peripheral
241 {
242 public:
243 Joystick(const std::string& provider = "", const std::string& strName = "") :
244 Peripheral(PERIPHERAL_TYPE_JOYSTICK, strName),
245 m_provider(provider),
246 m_requestedPort(NO_PORT_REQUESTED)
247 {
248 }
249
250 Joystick(const Joystick& other)
251 {
252 *this = other;
253 }
254
255 explicit Joystick(const JOYSTICK_INFO& info) :
256 Peripheral(info.peripheral),
257 m_provider(info.provider ? info.provider : ""),
258 m_requestedPort(info.requested_port),
259 m_buttonCount(info.button_count),
260 m_hatCount(info.hat_count),
261 m_axisCount(info.axis_count),
262 m_motorCount(info.motor_count),
263 m_supportsPowerOff(info.supports_poweroff)
264 {
265 }
266
267 ~Joystick(void) override = default;
268
269 Joystick& operator=(const Joystick& rhs)
270 {
271 if (this != &rhs)
272 {
273 Peripheral::operator=(rhs);
274
275 m_provider = rhs.m_provider;
276 m_requestedPort = rhs.m_requestedPort;
277 m_buttonCount = rhs.m_buttonCount;
278 m_hatCount = rhs.m_hatCount;
279 m_axisCount = rhs.m_axisCount;
280 m_motorCount = rhs.m_motorCount;
281 m_supportsPowerOff = rhs.m_supportsPowerOff;
282 }
283 return *this;
284 }
285
286 const std::string& Provider(void) const { return m_provider; }
287 int RequestedPort(void) const { return m_requestedPort; }
288 unsigned int ButtonCount(void) const { return m_buttonCount; }
289 unsigned int HatCount(void) const { return m_hatCount; }
290 unsigned int AxisCount(void) const { return m_axisCount; }
291 unsigned int MotorCount(void) const { return m_motorCount; }
292 bool SupportsPowerOff(void) const { return m_supportsPowerOff; }
293
294 void SetProvider(const std::string& provider) { m_provider = provider; }
295 void SetRequestedPort(int requestedPort) { m_requestedPort = requestedPort; }
296 void SetButtonCount(unsigned int buttonCount) { m_buttonCount = buttonCount; }
297 void SetHatCount(unsigned int hatCount) { m_hatCount = hatCount; }
298 void SetAxisCount(unsigned int axisCount) { m_axisCount = axisCount; }
299 void SetMotorCount(unsigned int motorCount) { m_motorCount = motorCount; }
300 void SetSupportsPowerOff(bool supportsPowerOff) { m_supportsPowerOff = supportsPowerOff; }
301
302 void ToStruct(JOYSTICK_INFO& info) const
303 {
304 Peripheral::ToStruct(info.peripheral);
305
306 info.provider = new char[m_provider.size() + 1];
307 info.requested_port = m_requestedPort;
308 info.button_count = m_buttonCount;
309 info.hat_count = m_hatCount;
310 info.axis_count = m_axisCount;
311 info.motor_count = m_motorCount;
312 info.supports_poweroff = m_supportsPowerOff;
313
314 std::strcpy(info.provider, m_provider.c_str());
315 }
316
317 static void FreeStruct(JOYSTICK_INFO& info)
318 {
319 Peripheral::FreeStruct(info.peripheral);
320
321 PERIPHERAL_SAFE_DELETE_ARRAY(info.provider);
322 }
323
324 private:
325 std::string m_provider;
326 int m_requestedPort;
327 unsigned int m_buttonCount = 0;
328 unsigned int m_hatCount = 0;
329 unsigned int m_axisCount = 0;
330 unsigned int m_motorCount = 0;
331 bool m_supportsPowerOff = false;
332 };
333
334 typedef PeripheralVector<Joystick, JOYSTICK_INFO> Joysticks;
335
336 /*!
337 * ADDON::DriverPrimitive
338 *
339 * Base class for joystick driver primitives. A driver primitive can be:
340 *
341 * 1) a button
342 * 2) a hat direction
343 * 3) a semiaxis (either the positive or negative half of an axis)
344 * 4) a motor
345 * 5) a keyboard key
346 * 6) a mouse button
347 * 7) a relative pointer direction
348 *
349 * The type determines the fields in use:
350 *
351 * Button:
352 * - driver index
353 *
354 * Hat direction:
355 * - driver index
356 * - hat direction
357 *
358 * Semiaxis:
359 * - driver index
360 * - center
361 * - semiaxis direction
362 * - range
363 *
364 * Motor:
365 * - driver index
366 *
367 * Key:
368 * - key code
369 *
370 * Mouse button:
371 * - driver index
372 *
373 * Relative pointer direction:
374 * - relative pointer direction
375 */
376 struct DriverPrimitive
377 {
378 protected:
379 /*!
380 * \brief Construct a driver primitive of the specified type
381 */
382 DriverPrimitive(JOYSTICK_DRIVER_PRIMITIVE_TYPE type, unsigned int driverIndex) :
383 m_type(type),
384 m_driverIndex(driverIndex)
385 {
386 }
387
388 public:
389 /*!
390 * \brief Construct an invalid driver primitive
391 */
392 DriverPrimitive(void) = default;
393
394 /*!
395 * \brief Construct a driver primitive representing a joystick button
396 */
397 static DriverPrimitive CreateButton(unsigned int buttonIndex)
398 {
399 return DriverPrimitive(JOYSTICK_DRIVER_PRIMITIVE_TYPE_BUTTON, buttonIndex);
400 }
401
402 /*!
403 * \brief Construct a driver primitive representing one of the four direction
404 * arrows on a dpad
405 */
406 DriverPrimitive(unsigned int hatIndex, JOYSTICK_DRIVER_HAT_DIRECTION direction) :
407 m_type(JOYSTICK_DRIVER_PRIMITIVE_TYPE_HAT_DIRECTION),
408 m_driverIndex(hatIndex),
409 m_hatDirection(direction)
410 {
411 }
412
413 /*!
414 * \brief Construct a driver primitive representing the positive or negative
415 * half of an axis
416 */
417 DriverPrimitive(unsigned int axisIndex, int center, JOYSTICK_DRIVER_SEMIAXIS_DIRECTION direction, unsigned int range) :
418 m_type(JOYSTICK_DRIVER_PRIMITIVE_TYPE_SEMIAXIS),
419 m_driverIndex(axisIndex),
420 m_center(center),
421 m_semiAxisDirection(direction),
422 m_range(range)
423 {
424 }
425
426 /*!
427 * \brief Construct a driver primitive representing a motor
428 */
429 static DriverPrimitive CreateMotor(unsigned int motorIndex)
430 {
431 return DriverPrimitive(JOYSTICK_DRIVER_PRIMITIVE_TYPE_MOTOR, motorIndex);
432 }
433
434 /*!
435 * \brief Construct a driver primitive representing a key on a keyboard
436 */
437 DriverPrimitive(std::string keycode) :
438 m_type(JOYSTICK_DRIVER_PRIMITIVE_TYPE_KEY),
439 m_keycode(std::move(keycode))
440 {
441 }
442
443 /*!
444 * \brief Construct a driver primitive representing a mouse button
445 */
446 static DriverPrimitive CreateMouseButton(JOYSTICK_DRIVER_MOUSE_INDEX buttonIndex)
447 {
448 return DriverPrimitive(JOYSTICK_DRIVER_PRIMITIVE_TYPE_MOUSE_BUTTON, static_cast<unsigned int>(buttonIndex));
449 }
450
451 /*!
452 * \brief Construct a driver primitive representing one of the four
453 * direction in which a relative pointer can move
454 */
455 DriverPrimitive(JOYSTICK_DRIVER_RELPOINTER_DIRECTION direction) :
456 m_type(JOYSTICK_DRIVER_PRIMITIVE_TYPE_RELPOINTER_DIRECTION),
457 m_relPointerDirection(direction)
458 {
459 }
460
461 explicit DriverPrimitive(const JOYSTICK_DRIVER_PRIMITIVE& primitive) :
462 m_type(primitive.type)
463 {
464 switch (m_type)
465 {
466 case JOYSTICK_DRIVER_PRIMITIVE_TYPE_BUTTON:
467 {
468 m_driverIndex = primitive.button.index;
469 break;
470 }
471 case JOYSTICK_DRIVER_PRIMITIVE_TYPE_HAT_DIRECTION:
472 {
473 m_driverIndex = primitive.hat.index;
474 m_hatDirection = primitive.hat.direction;
475 break;
476 }
477 case JOYSTICK_DRIVER_PRIMITIVE_TYPE_SEMIAXIS:
478 {
479 m_driverIndex = primitive.semiaxis.index;
480 m_center = primitive.semiaxis.center;
481 m_semiAxisDirection = primitive.semiaxis.direction;
482 m_range = primitive.semiaxis.range;
483 break;
484 }
485 case JOYSTICK_DRIVER_PRIMITIVE_TYPE_MOTOR:
486 {
487 m_driverIndex = primitive.motor.index;
488 break;
489 }
490 case JOYSTICK_DRIVER_PRIMITIVE_TYPE_KEY:
491 {
492 m_keycode = primitive.key.keycode;
493 break;
494 }
495 case JOYSTICK_DRIVER_PRIMITIVE_TYPE_MOUSE_BUTTON:
496 {
497 m_driverIndex = primitive.mouse.button;
498 break;
499 }
500 case JOYSTICK_DRIVER_PRIMITIVE_TYPE_RELPOINTER_DIRECTION:
501 {
502 m_relPointerDirection = primitive.relpointer.direction;
503 break;
504 }
505 default:
506 break;
507 }
508 }
509
510 JOYSTICK_DRIVER_PRIMITIVE_TYPE Type(void) const { return m_type; }
511 unsigned int DriverIndex(void) const { return m_driverIndex; }
512 JOYSTICK_DRIVER_HAT_DIRECTION HatDirection(void) const { return m_hatDirection; }
513 int Center(void) const { return m_center; }
514 JOYSTICK_DRIVER_SEMIAXIS_DIRECTION SemiAxisDirection(void) const { return m_semiAxisDirection; }
515 unsigned int Range(void) const { return m_range; }
516 const std::string& Keycode(void) const { return m_keycode; }
517 JOYSTICK_DRIVER_MOUSE_INDEX MouseIndex(void) const { return static_cast<JOYSTICK_DRIVER_MOUSE_INDEX>(m_driverIndex); }
518 JOYSTICK_DRIVER_RELPOINTER_DIRECTION RelPointerDirection(void) const { return m_relPointerDirection; }
519
520 bool operator==(const DriverPrimitive& other) const
521 {
522 if (m_type == other.m_type)
523 {
524 switch (m_type)
525 {
526 case JOYSTICK_DRIVER_PRIMITIVE_TYPE_BUTTON:
527 {
528 return m_driverIndex == other.m_driverIndex;
529 }
530 case JOYSTICK_DRIVER_PRIMITIVE_TYPE_HAT_DIRECTION:
531 {
532 return m_driverIndex == other.m_driverIndex &&
533 m_hatDirection == other.m_hatDirection;
534 }
535 case JOYSTICK_DRIVER_PRIMITIVE_TYPE_SEMIAXIS:
536 {
537 return m_driverIndex == other.m_driverIndex &&
538 m_center == other.m_center &&
539 m_semiAxisDirection == other.m_semiAxisDirection &&
540 m_range == other.m_range;
541 }
542 case JOYSTICK_DRIVER_PRIMITIVE_TYPE_KEY:
543 {
544 return m_keycode == other.m_keycode;
545 }
546 case JOYSTICK_DRIVER_PRIMITIVE_TYPE_MOTOR:
547 {
548 return m_driverIndex == other.m_driverIndex;
549 }
550 case JOYSTICK_DRIVER_PRIMITIVE_TYPE_MOUSE_BUTTON:
551 {
552 return m_driverIndex == other.m_driverIndex;
553 }
554 case JOYSTICK_DRIVER_PRIMITIVE_TYPE_RELPOINTER_DIRECTION:
555 {
556 return m_relPointerDirection == other.m_relPointerDirection;
557 }
558 default:
559 break;
560 }
561 }
562 return false;
563 }
564
565 void ToStruct(JOYSTICK_DRIVER_PRIMITIVE& driver_primitive) const
566 {
567 driver_primitive.type = m_type;
568 switch (m_type)
569 {
570 case JOYSTICK_DRIVER_PRIMITIVE_TYPE_BUTTON:
571 {
572 driver_primitive.button.index = m_driverIndex;
573 break;
574 }
575 case JOYSTICK_DRIVER_PRIMITIVE_TYPE_HAT_DIRECTION:
576 {
577 driver_primitive.hat.index = m_driverIndex;
578 driver_primitive.hat.direction = m_hatDirection;
579 break;
580 }
581 case JOYSTICK_DRIVER_PRIMITIVE_TYPE_SEMIAXIS:
582 {
583 driver_primitive.semiaxis.index = m_driverIndex;
584 driver_primitive.semiaxis.center = m_center;
585 driver_primitive.semiaxis.direction = m_semiAxisDirection;
586 driver_primitive.semiaxis.range = m_range;
587 break;
588 }
589 case JOYSTICK_DRIVER_PRIMITIVE_TYPE_MOTOR:
590 {
591 driver_primitive.motor.index = m_driverIndex;
592 break;
593 }
594 case JOYSTICK_DRIVER_PRIMITIVE_TYPE_KEY:
595 {
596 const size_t size = sizeof(driver_primitive.key.keycode);
597 std::strncpy(driver_primitive.key.keycode, m_keycode.c_str(), size - 1);
598 driver_primitive.key.keycode[size - 1] = '\0';
599 break;
600 }
601 case JOYSTICK_DRIVER_PRIMITIVE_TYPE_MOUSE_BUTTON:
602 {
603 driver_primitive.mouse.button = static_cast<JOYSTICK_DRIVER_MOUSE_INDEX>(m_driverIndex);
604 break;
605 }
606 case JOYSTICK_DRIVER_PRIMITIVE_TYPE_RELPOINTER_DIRECTION:
607 {
608 driver_primitive.relpointer.direction = m_relPointerDirection;
609 break;
610 }
611 default:
612 break;
613 }
614 }
615
616 static void FreeStruct(JOYSTICK_DRIVER_PRIMITIVE& primitive)
617 {
618 (void)primitive;
619 }
620
621 private:
622 JOYSTICK_DRIVER_PRIMITIVE_TYPE m_type = JOYSTICK_DRIVER_PRIMITIVE_TYPE_UNKNOWN;
623 unsigned int m_driverIndex = 0;
624 JOYSTICK_DRIVER_HAT_DIRECTION m_hatDirection = JOYSTICK_DRIVER_HAT_UNKNOWN;
625 int m_center = 0;
626 JOYSTICK_DRIVER_SEMIAXIS_DIRECTION m_semiAxisDirection = JOYSTICK_DRIVER_SEMIAXIS_UNKNOWN;
627 unsigned int m_range = 1;
628 std::string m_keycode;
629 JOYSTICK_DRIVER_RELPOINTER_DIRECTION m_relPointerDirection = JOYSTICK_DRIVER_RELPOINTER_UNKNOWN;
630 };
631
632 typedef PeripheralVector<DriverPrimitive, JOYSTICK_DRIVER_PRIMITIVE> DriverPrimitives;
633
634 /*!
635 * kodi::addon::JoystickFeature
636 *
637 * Class for joystick features. A feature can be:
638 *
639 * 1) scalar[1]
640 * 2) analog stick
641 * 3) accelerometer
642 * 4) motor
643 * 5) relative pointer[2]
644 * 6) absolute pointer
645 * 7) wheel
646 * 8) throttle
647 * 9) keyboard key
648 *
649 * [1] All three driver primitives (buttons, hats and axes) have a state that
650 * can be represented using a single scalar value. For this reason,
651 * features that map to a single primitive are called "scalar features".
652 *
653 * [2] Relative pointers are similar to analog sticks, but they use
654 * relative distances instead of positions.
655 */
656 class JoystickFeature
657 {
658 public:
659 JoystickFeature(const std::string& name = "", JOYSTICK_FEATURE_TYPE type = JOYSTICK_FEATURE_TYPE_UNKNOWN) :
660 m_name(name),
661 m_type(type),
662 m_primitives{}
663 {
664 }
665
666 JoystickFeature(const JoystickFeature& other)
667 {
668 *this = other;
669 }
670
671 explicit JoystickFeature(const JOYSTICK_FEATURE& feature) :
672 m_name(feature.name ? feature.name : ""),
673 m_type(feature.type)
674 {
675 for (unsigned int i = 0; i < JOYSTICK_PRIMITIVE_MAX; i++)
676 m_primitives[i] = DriverPrimitive(feature.primitives[i]);
677 }
678
679 JoystickFeature& operator=(const JoystickFeature& rhs)
680 {
681 if (this != &rhs)
682 {
683 m_name = rhs.m_name;
684 m_type = rhs.m_type;
685 m_primitives = rhs.m_primitives;
686 }
687 return *this;
688 }
689
690 bool operator==(const JoystickFeature& other) const
691 {
692 return m_name == other.m_name &&
693 m_type == other.m_type &&
694 m_primitives == other.m_primitives;
695 }
696
697 const std::string& Name(void) const { return m_name; }
698 JOYSTICK_FEATURE_TYPE Type(void) const { return m_type; }
699 bool IsValid() const { return m_type != JOYSTICK_FEATURE_TYPE_UNKNOWN; }
700
701 void SetName(const std::string& name) { m_name = name; }
702 void SetType(JOYSTICK_FEATURE_TYPE type) { m_type = type; }
703 void SetInvalid(void) { m_type = JOYSTICK_FEATURE_TYPE_UNKNOWN; }
704
705 const DriverPrimitive& Primitive(JOYSTICK_FEATURE_PRIMITIVE which) const { return m_primitives[which]; }
706 void SetPrimitive(JOYSTICK_FEATURE_PRIMITIVE which, const DriverPrimitive& primitive) { m_primitives[which] = primitive; }
707
708 std::array<DriverPrimitive, JOYSTICK_PRIMITIVE_MAX>& Primitives() { return m_primitives; }
709 const std::array<DriverPrimitive, JOYSTICK_PRIMITIVE_MAX>& Primitives() const { return m_primitives; }
710
711 void ToStruct(JOYSTICK_FEATURE& feature) const
712 {
713 feature.name = new char[m_name.length() + 1];
714 feature.type = m_type;
715 for (unsigned int i = 0; i < JOYSTICK_PRIMITIVE_MAX; i++)
716 m_primitives[i].ToStruct(feature.primitives[i]);
717
718 std::strcpy(feature.name, m_name.c_str());
719 }
720
721 static void FreeStruct(JOYSTICK_FEATURE& feature)
722 {
723 PERIPHERAL_SAFE_DELETE_ARRAY(feature.name);
724 }
725
726 private:
727 std::string m_name;
728 JOYSTICK_FEATURE_TYPE m_type;
729 std::array<DriverPrimitive, JOYSTICK_PRIMITIVE_MAX> m_primitives;
730 };
731
732 typedef PeripheralVector<JoystickFeature, JOYSTICK_FEATURE> JoystickFeatures;
733
734} /* namespace addon */
735} /* namespace kodi */
diff --git a/xbmc/addons/kodi-addon-dev-kit/include/kodi/addon-instance/Screensaver.h b/xbmc/addons/kodi-addon-dev-kit/include/kodi/addon-instance/Screensaver.h
deleted file mode 100644
index f8a7380..0000000
--- a/xbmc/addons/kodi-addon-dev-kit/include/kodi/addon-instance/Screensaver.h
+++ /dev/null
@@ -1,460 +0,0 @@
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 "../gui/renderHelper.h"
13
14namespace kodi { namespace addon { class CInstanceScreensaver; }}
15
16extern "C"
17{
18
19struct AddonInstance_Screensaver;
20
21/*!
22 * @brief Screensaver properties
23 *
24 * Not to be used outside this header.
25 */
26typedef struct AddonProps_Screensaver
27{
28 void *device;
29 int x;
30 int y;
31 int width;
32 int height;
33 float pixelRatio;
34 const char *name;
35 const char *presets;
36 const char *profile;
37} AddonProps_Screensaver;
38
39/*!
40 * @brief Screensaver callbacks
41 *
42 * Not to be used outside this header.
43 */
44typedef struct AddonToKodiFuncTable_Screensaver
45{
46 KODI_HANDLE kodiInstance;
47} AddonToKodiFuncTable_Screensaver;
48
49/*!
50 * @brief Screensaver function hooks
51 *
52 * Not to be used outside this header.
53 */
54typedef struct KodiToAddonFuncTable_Screensaver
55{
56 kodi::addon::CInstanceScreensaver* addonInstance;
57 bool (__cdecl* Start) (AddonInstance_Screensaver* instance);
58 void (__cdecl* Stop) (AddonInstance_Screensaver* instance);
59 void (__cdecl* Render) (AddonInstance_Screensaver* instance);
60} KodiToAddonFuncTable_Screensaver;
61
62/*!
63 * @brief Screensaver instance
64 *
65 * Not to be used outside this header.
66 */
67typedef struct AddonInstance_Screensaver
68{
69 AddonProps_Screensaver props;
70 AddonToKodiFuncTable_Screensaver toKodi;
71 KodiToAddonFuncTable_Screensaver toAddon;
72} AddonInstance_Screensaver;
73
74} /* extern "C" */
75
76namespace kodi
77{
78namespace addon
79{
80
81 //============================================================================
82 ///
83 /// \addtogroup cpp_kodi_addon_screensaver
84 /// @brief \cpp_class{ kodi::addon::CInstanceScreensaver }
85 /// **Screensaver add-on instance**
86 ///
87 /// A screensaver is a Kodi addon that fills the screen with moving images or
88 /// patterns when the computer is not in use. Initially designed to prevent
89 /// phosphor burn-in on CRT and plasma computer monitors (hence the name),
90 /// screensavers are now used primarily for entertainment, security or to
91 /// display system status information.
92 ///
93 /// Include the header \ref ScreenSaver.h "#include <kodi/addon-instance/ScreenSaver.h>"
94 /// to use this class.
95 ///
96 /// This interface allows the creating of screensavers for Kodi, based upon
97 /// **DirectX** or/and **OpenGL** rendering with `C++` code.
98 ///
99 /// The interface is small and easy usable. It has three functions:
100 ///
101 /// * <b><c>Start()</c></b> - Called on creation
102 /// * <b><c>Render()</c></b> - Called at render time
103 /// * <b><c>Stop()</c></b> - Called when the screensaver has no work
104 ///
105 /// Additionally, there are several \ref cpp_kodi_addon_screensaver_CB "other functions"
106 /// available in which the child class can ask about the current hardware,
107 /// including the device, display and several other parts.
108 ///
109 ///
110 /// --------------------------------------------------------------------------
111 ///
112 ///
113 /// **Here is an example of the minimum required code to start a screensaver:**
114 /// ~~~~~~~~~~~~~{.cpp}
115 /// #include <kodi/addon-instance/Screensaver.h>
116 ///
117 /// class CMyScreenSaver : public kodi::addon::CAddonBase,
118 /// public kodi::addon::CInstanceScreensaver
119 /// {
120 /// public:
121 /// CMyScreenSaver();
122 ///
123 /// bool Start() override;
124 /// void Render() override;
125 /// };
126 ///
127 /// CMyScreenSaver::CMyScreenSaver()
128 /// {
129 /// ...
130 /// }
131 ///
132 /// bool CMyScreenSaver::Start()
133 /// {
134 /// ...
135 /// return true;
136 /// }
137 ///
138 /// void CMyScreenSaver::Render()
139 /// {
140 /// ...
141 /// }
142 ///
143 /// ADDONCREATOR(CMyScreenSaver)
144 /// ~~~~~~~~~~~~~
145 ///
146 ///
147 /// --------------------------------------------------------------------------
148 ///
149 ///
150 /// **Here is another example where the screensaver is used together with
151 /// other instance types:**
152 ///
153 /// ~~~~~~~~~~~~~{.cpp}
154 /// #include <kodi/addon-instance/Screensaver.h>
155 ///
156 /// class CMyScreenSaver : public ::kodi::addon::CInstanceScreensaver
157 /// {
158 /// public:
159 /// CMyScreenSaver(KODI_HANDLE instance);
160 ///
161 /// bool Start() override;
162 /// void Render() override;
163 /// };
164 ///
165 /// CMyScreenSaver::CMyScreenSaver(KODI_HANDLE instance)
166 /// : CInstanceScreensaver(instance)
167 /// {
168 /// ...
169 /// }
170 ///
171 /// bool CMyScreenSaver::Start()
172 /// {
173 /// ...
174 /// return true;
175 /// }
176 ///
177 /// void CMyScreenSaver::Render()
178 /// {
179 /// ...
180 /// }
181 ///
182 ///
183 /// /*----------------------------------------------------------------------*/
184 ///
185 /// class CMyAddon : public ::kodi::addon::CAddonBase
186 /// {
187 /// public:
188 /// CMyAddon() { }
189 /// ADDON_STATUS CreateInstance(int instanceType,
190 /// std::string instanceID,
191 /// KODI_HANDLE instance,
192 /// KODI_HANDLE& addonInstance) override;
193 /// };
194 ///
195 /// /* If you use only one instance in your add-on, can be instanceType and
196 /// * instanceID ignored */
197 /// ADDON_STATUS CMyAddon::CreateInstance(int instanceType,
198 /// std::string instanceID,
199 /// KODI_HANDLE instance,
200 /// KODI_HANDLE& addonInstance)
201 /// {
202 /// if (instanceType == ADDON_INSTANCE_SCREENSAVER)
203 /// {
204 /// kodi::Log(ADDON_LOG_NOTICE, "Creating my Screensaver");
205 /// addonInstance = new CMyScreenSaver(instance);
206 /// return ADDON_STATUS_OK;
207 /// }
208 /// else if (...)
209 /// {
210 /// ...
211 /// }
212 /// return ADDON_STATUS_UNKNOWN;
213 /// }
214 ///
215 /// ADDONCREATOR(CMyAddon)
216 /// ~~~~~~~~~~~~~
217 ///
218 /// The destruction of the example class `CMyScreenSaver` is called from
219 /// Kodi's header. Manually deleting the add-on instance is not required.
220 ///
221 //----------------------------------------------------------------------------
222 class ATTRIBUTE_HIDDEN CInstanceScreensaver : public IAddonInstance
223 {
224 public:
225 //==========================================================================
226 ///
227 /// @ingroup cpp_kodi_addon_screensaver
228 /// @brief Screensaver class constructor
229 ///
230 /// Used by an add-on that only supports screensavers.
231 ///
232 CInstanceScreensaver()
233 : IAddonInstance(ADDON_INSTANCE_SCREENSAVER, GetKodiTypeVersion(ADDON_INSTANCE_SCREENSAVER))
234 {
235 if (CAddonBase::m_interface->globalSingleInstance != nullptr)
236 throw std::logic_error("kodi::addon::CInstanceScreensaver: Creation of more as one in single instance way is not allowed!");
237
238 SetAddonStruct(CAddonBase::m_interface->firstKodiInstance);
239 CAddonBase::m_interface->globalSingleInstance = this;
240 }
241 //--------------------------------------------------------------------------
242
243 //==========================================================================
244 ///
245 /// @ingroup cpp_kodi_addon_screensaver
246 /// @brief Screensaver class constructor used to support multiple instance
247 /// types
248 ///
249 /// @param[in] instance The instance value given to
250 /// <b>`kodi::addon::CAddonBase::CreateInstance(...)`</b>.
251 /// @param[in] kodiVersion [opt] Version used in Kodi for this instance, to
252 /// allow compatibility to older Kodi versions.
253 /// @note Recommended to set.
254 ///
255 /// @warning Only use `instance` from the CreateInstance call
256 ///
257 explicit CInstanceScreensaver(KODI_HANDLE instance, const std::string& kodiVersion = "")
258 : IAddonInstance(ADDON_INSTANCE_SCREENSAVER,
259 !kodiVersion.empty() ? kodiVersion
260 : GetKodiTypeVersion(ADDON_INSTANCE_SCREENSAVER))
261 {
262 if (CAddonBase::m_interface->globalSingleInstance != nullptr)
263 throw std::logic_error("kodi::addon::CInstanceScreensaver: Creation of multiple together with single instance way is not allowed!");
264
265 SetAddonStruct(instance);
266 }
267 //--------------------------------------------------------------------------
268
269 //==========================================================================
270 ///
271 /// @ingroup cpp_kodi_addon_screensaver
272 /// @brief Destructor
273 ///
274 ~CInstanceScreensaver() override = default;
275 //--------------------------------------------------------------------------
276
277 //==========================================================================
278 ///
279 /// @ingroup cpp_kodi_addon_screensaver
280 /// @brief Used to notify the screensaver that it has been started
281 ///
282 /// @return true if the screensaver was started
283 /// successfully, false otherwise
284 ///
285 virtual bool Start() { return true; }
286 //--------------------------------------------------------------------------
287
288 //==========================================================================
289 ///
290 /// @ingroup cpp_kodi_addon_screensaver
291 /// @brief Used to inform the screensaver that the rendering control was
292 /// stopped
293 ///
294 virtual void Stop() {}
295 //--------------------------------------------------------------------------
296
297 //==========================================================================
298 ///
299 /// @ingroup cpp_kodi_addon_screensaver
300 /// @brief Used to indicate when the add-on should render
301 ///
302 virtual void Render() {}
303 //--------------------------------------------------------------------------
304
305 //==========================================================================
306 ///
307 /// \defgroup cpp_kodi_addon_screensaver_CB Information functions
308 /// \ingroup cpp_kodi_addon_screensaver
309 /// @brief **To get info about the device, display and several other parts**
310 ///
311 //@{
312
313 //==========================================================================
314 ///
315 /// @ingroup cpp_kodi_addon_screensaver_CB
316 /// @brief Device that represents the display adapter
317 ///
318 /// @return A pointer to the device
319 ///
320 /// @note This is only available on **DirectX**, It us unused (`nullptr`) on
321 /// **OpenGL**
322 ///
323 inline void* Device() { return m_instanceData->props.device; }
324 //--------------------------------------------------------------------------
325
326 //==========================================================================
327 ///
328 /// @ingroup cpp_kodi_addon_screensaver_CB
329 /// @brief Returns the X position of the rendering window
330 ///
331 /// @return The X position, in pixels
332 ///
333 inline int X() { return m_instanceData->props.x; }
334 //--------------------------------------------------------------------------
335
336 //==========================================================================
337 ///
338 /// @ingroup cpp_kodi_addon_screensaver_CB
339 /// @brief Returns the Y position of the rendering window
340 ///
341 /// @return The Y position, in pixels
342 ///
343 inline int Y() { return m_instanceData->props.y; }
344 //--------------------------------------------------------------------------
345
346 //==========================================================================
347 ///
348 /// @ingroup cpp_kodi_addon_screensaver_CB
349 /// @brief Returns the width of the rendering window
350 ///
351 /// @return The width, in pixels
352 ///
353 inline int Width() { return m_instanceData->props.width; }
354 //--------------------------------------------------------------------------
355
356 //==========================================================================
357 ///
358 /// @ingroup cpp_kodi_addon_screensaver_CB
359 /// @brief Returns the height of the rendering window
360 ///
361 /// @return The height, in pixels
362 ///
363 inline int Height() { return m_instanceData->props.height; }
364 //--------------------------------------------------------------------------
365
366 //==========================================================================
367 ///
368 /// @ingroup cpp_kodi_addon_screensaver_CB
369 /// @brief Pixel aspect ratio (often abbreviated PAR) is a ratio that
370 /// describes how the width of a pixel compares to the height of that pixel.
371 ///
372 /// @return The pixel aspect ratio used by the display
373 ///
374 inline float PixelRatio() { return m_instanceData->props.pixelRatio; }
375 //--------------------------------------------------------------------------
376
377 //==========================================================================
378 ///
379 /// @ingroup cpp_kodi_addon_screensaver_CB
380 /// @brief Used to get the name of the add-on defined in `addon.xml`
381 ///
382 /// @return The add-on name
383 ///
384 inline std::string Name() { return m_instanceData->props.name; }
385 //--------------------------------------------------------------------------
386
387 //==========================================================================
388 ///
389 /// @ingroup cpp_kodi_addon_screensaver_CB
390 /// @brief Used to get the full path where the add-on is installed
391 ///
392 /// @return The add-on installation path
393 ///
394 inline std::string Presets() { return m_instanceData->props.presets; }
395 //--------------------------------------------------------------------------
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 private:
413 void SetAddonStruct(KODI_HANDLE instance)
414 {
415 if (instance == nullptr)
416 throw std::logic_error("kodi::addon::CInstanceScreensaver: Creation with empty addon structure not allowed, table must be given from Kodi!");
417
418 m_instanceData = static_cast<AddonInstance_Screensaver*>(instance);
419 m_instanceData->toAddon.addonInstance = this;
420 m_instanceData->toAddon.Start = ADDON_Start;
421 m_instanceData->toAddon.Stop = ADDON_Stop;
422 m_instanceData->toAddon.Render = ADDON_Render;
423 }
424
425 inline static bool ADDON_Start(AddonInstance_Screensaver* instance)
426 {
427 instance->toAddon.addonInstance->m_renderHelper = kodi::gui::GetRenderHelper();
428 return instance->toAddon.addonInstance->Start();
429 }
430
431 inline static void ADDON_Stop(AddonInstance_Screensaver* instance)
432 {
433 instance->toAddon.addonInstance->Stop();
434 instance->toAddon.addonInstance->m_renderHelper = nullptr;
435 }
436
437 inline static void ADDON_Render(AddonInstance_Screensaver* instance)
438 {
439 if (!instance->toAddon.addonInstance->m_renderHelper)
440 return;
441 instance->toAddon.addonInstance->m_renderHelper->Begin();
442 instance->toAddon.addonInstance->Render();
443 instance->toAddon.addonInstance->m_renderHelper->End();
444 }
445
446 /*
447 * Background render helper holds here and in addon base.
448 * In addon base also to have for the others, and stored here for the worst
449 * case where this class is independent from base and base becomes closed
450 * before.
451 *
452 * This is on Kodi with GL unused and the calls to there are empty (no work)
453 * On Kodi with Direct X where angle is present becomes this used.
454 */
455 std::shared_ptr<kodi::gui::IRenderHelper> m_renderHelper;
456 AddonInstance_Screensaver* m_instanceData;
457 };
458
459} /* namespace addon */
460} /* namespace kodi */
diff --git a/xbmc/addons/kodi-addon-dev-kit/include/kodi/addon-instance/VFS.h b/xbmc/addons/kodi-addon-dev-kit/include/kodi/addon-instance/VFS.h
deleted file mode 100644
index efd5de2..0000000
--- a/xbmc/addons/kodi-addon-dev-kit/include/kodi/addon-instance/VFS.h
+++ /dev/null
@@ -1,1265 +0,0 @@
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
13#if !defined(_WIN32)
14#include <sys/stat.h>
15#if !defined(__stat64)
16#if defined(TARGET_DARWIN) || defined(TARGET_FREEBSD)
17#define __stat64 stat
18#else
19#define __stat64 stat64
20#endif
21#endif
22#endif
23
24#ifdef __cplusplus
25extern "C"
26{
27#endif /* __cplusplus */
28
29 //============================================================================
30 /// @ingroup cpp_kodi_addon_vfs_Defs
31 /// @brief **VFS add-on URL data**\n
32 /// This class is used to inform the addon of the desired wanted connection.
33 ///
34 /// Used on mostly all addon functions to identify related target.
35 ///
36 struct VFSURL
37 {
38 /// @brief Desired URL of the file system to be edited
39 ///
40 /// This includes all available parts of the access and is structured as
41 /// follows:
42 /// - <b>`<PROTOCOL>`://`<USERNAME>`:`<PASSWORD>``@``<HOSTNAME>`:`<PORT>`/`<FILENAME>`?`<OPTIONS>`</b>
43 const char* url;
44
45 /// @brief The associated domain name, which is optional and not available
46 /// in all cases.
47 const char* domain;
48
49 /// @brief This includes the network address (e.g. `192.168.0.123`) or if
50 /// the addon refers to file packages the path to it
51 /// (e.g. `/home/by_me/MyPacket.rar`).
52 const char* hostname;
53
54 /// @brief With this variable the desired path to a folder or file within
55 /// the hostname is given (e.g. `storage/videos/00001.ts`).
56 const char* filename;
57
58 /// @brief [Networking port](https://en.wikipedia.org/wiki/Port_(computer_networking))
59 /// to use for protocol.
60 unsigned int port;
61
62 /// @brief Special options on opened URL, this can e.g. on RAR packages
63 /// <b>`?flags=8&nextvalue=123`</b> to inform about to not cache a read.
64 ///
65 /// Available options from Kodi:
66 /// | Value: | Description:
67 /// |-----------|-------------------
68 /// | flags=8 | Used on RAR packages so that no data is cached from the requested source.
69 /// | 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!
70 ///
71 /// In addition, other addons can use the URLs given by them to give options
72 /// that fit the respective VFS addon and allow special operations.
73 ///
74 /// @note This procedure is not yet standardized and is currently not
75 /// exactly available which are handed over.
76 const char* options;
77
78 /// @brief Desired username.
79 const char* username;
80
81 /// @brief Desired password.
82 const char* password;
83
84 /// @brief The complete URL is passed on here, but the user name and
85 /// password are not shown and only appear to there as `USERNAME:PASSWORD`.
86 ///
87 /// As example <b>`sftp://USERNAME:PASSWORD@192.168.178.123/storage/videos/00001.ts`</b>.
88 const char* redacted;
89
90 /// @brief The name which is taken as the basis by source and would be first
91 /// in folder view.
92 ///
93 /// As example on <b>`sftp://dudu:isprivate@192.168.178.123/storage/videos/00001.ts`</b>
94 /// becomes then <b>`storage`</b> used here.
95 const char* sharename;
96
97 /// @brief Protocol name used on this stream, e.g. <b>`sftp`</b>.
98 const char* protocol;
99 };
100 //----------------------------------------------------------------------------
101
102 //============================================================================
103 /// @ingroup cpp_kodi_addon_vfs_Defs
104 /// @brief <b>In/out value which is queried at @ref kodi::addon::CInstanceVFS::IoControl.</b>\n
105 /// This declares the requested value on the addon, this gets or has to
106 /// transfer data depending on the value.
107 enum VFS_IOCTRL
108 {
109 /// @brief For cases where not supported control becomes asked.
110 ///
111 /// @note Should normally not given to addon.
112 VFS_IOCTRL_INVALID = 0,
113
114 /// @brief @ref VFS_IOCTRL_NATIVE_DATA structure, containing what should be
115 /// passed to native ioctrl.
116 VFS_IOCTRL_NATIVE = 1,
117
118 /// @brief To check seek is possible.
119 ///
120 //// Return 0 if known not to work, 1 if it should work on related calls.
121 VFS_IOCTRL_SEEK_POSSIBLE = 2,
122
123 /// @brief @ref VFS_IOCTRL_CACHE_STATUS_DATA structure structure on related call
124 VFS_IOCTRL_CACHE_STATUS = 3,
125
126 /// @brief Unsigned int with speed limit for caching in bytes per second
127 VFS_IOCTRL_CACHE_SETRATE = 4,
128
129 /// @brief Enable/disable retry within the protocol handler (if supported)
130 VFS_IOCTRL_SET_RETRY = 16,
131 };
132 //----------------------------------------------------------------------------
133
134 //============================================================================
135 /// @ingroup cpp_kodi_addon_vfs_Defs
136 /// @brief <b>Structure used in @ref kodi::addon::CInstanceVFS::IoControl
137 /// if question value for @ref VFS_IOCTRL_NATIVE is set</b>\n
138 /// With this structure, data is transmitted to the Kodi addon.
139 ///
140 /// This corresponds to POSIX systems with regard to [ioctl](https://en.wikipedia.org/wiki/Ioctl)
141 /// data (emulated with Windows).
142 struct VFS_IOCTRL_NATIVE_DATA
143 {
144 unsigned long int request;
145 void* param;
146 };
147 //----------------------------------------------------------------------------
148
149 //============================================================================
150 /// @ingroup cpp_kodi_addon_vfs_Defs
151 /// @brief <b>Structure used in @ref kodi::addon::CInstanceVFS::IoControl
152 /// if question value for @ref VFS_IOCTRL_CACHE_STATUS is set</b>\n
153 /// This data is filled by the addon and returned to Kodi
154 struct VFS_IOCTRL_CACHE_STATUS_DATA
155 {
156 /// @brief Number of bytes cached forward of current position.
157 uint64_t forward;
158
159 /// @brief Maximum number of bytes per second cache is allowed to fill.
160 unsigned int maxrate;
161
162 /// @brief Average read rate from source file since last position change.
163 unsigned int currate;
164
165 /// @brief Cache low speed condition detected?
166 bool lowspeed;
167 };
168 //----------------------------------------------------------------------------
169
170 typedef struct VFSGetDirectoryCallbacks /* internal */
171 {
172 bool (__cdecl* get_keyboard_input)(void* ctx, const char* heading, char** input, bool hidden_input);
173 void (__cdecl* set_error_dialog)(void* ctx, const char* heading, const char* line1, const char* line2, const char* line3);
174 void (__cdecl* require_authentication)(void* ctx, const char* url);
175 void* ctx;
176 } VFSGetDirectoryCallbacks;
177
178 typedef struct AddonProps_VFSEntry /* internal */
179 {
180 int dummy;
181 } AddonProps_VFSEntry;
182
183 typedef struct AddonToKodiFuncTable_VFSEntry /* internal */
184 {
185 KODI_HANDLE kodiInstance;
186 } AddonToKodiFuncTable_VFSEntry;
187
188 struct AddonInstance_VFSEntry;
189 typedef struct KodiToAddonFuncTable_VFSEntry /* internal */
190 {
191 KODI_HANDLE addonInstance;
192
193 void*(__cdecl* open)(const struct AddonInstance_VFSEntry* instance, const struct VFSURL* url);
194 void*(__cdecl* open_for_write)(const struct AddonInstance_VFSEntry* instance,
195 const struct VFSURL* url,
196 bool overwrite);
197 ssize_t(__cdecl* read)(const struct AddonInstance_VFSEntry* instance,
198 void* context,
199 void* buffer,
200 size_t buf_size);
201 ssize_t(__cdecl* write)(const struct AddonInstance_VFSEntry* instance,
202 void* context,
203 const void* buffer,
204 size_t buf_size);
205 int64_t(__cdecl* seek)(const struct AddonInstance_VFSEntry* instance,
206 void* context,
207 int64_t position,
208 int whence);
209 int(__cdecl* truncate)(const struct AddonInstance_VFSEntry* instance,
210 void* context,
211 int64_t size);
212 int64_t(__cdecl* get_length)(const struct AddonInstance_VFSEntry* instance, void* context);
213 int64_t(__cdecl* get_position)(const struct AddonInstance_VFSEntry* instance, void* context);
214 int(__cdecl* get_chunk_size)(const struct AddonInstance_VFSEntry* instance, void* context);
215 int(__cdecl* io_control)(const struct AddonInstance_VFSEntry* instance,
216 void* context,
217 enum VFS_IOCTRL request,
218 void* param);
219 int(__cdecl* stat)(const struct AddonInstance_VFSEntry* instance,
220 const struct VFSURL* url,
221 struct __stat64* buffer);
222 bool(__cdecl* close)(const struct AddonInstance_VFSEntry* instance, void* context);
223 bool(__cdecl* exists)(const struct AddonInstance_VFSEntry* instance, const struct VFSURL* url);
224 void(__cdecl* clear_out_idle)(const struct AddonInstance_VFSEntry* instance);
225 void(__cdecl* disconnect_all)(const struct AddonInstance_VFSEntry* instance);
226 bool(__cdecl* delete_it)(const struct AddonInstance_VFSEntry* instance,
227 const struct VFSURL* url);
228 bool(__cdecl* rename)(const struct AddonInstance_VFSEntry* instance,
229 const struct VFSURL* url,
230 const struct VFSURL* url2);
231 bool(__cdecl* directory_exists)(const struct AddonInstance_VFSEntry* instance,
232 const struct VFSURL* url);
233 bool(__cdecl* remove_directory)(const struct AddonInstance_VFSEntry* instance,
234 const struct VFSURL* url);
235 bool(__cdecl* create_directory)(const struct AddonInstance_VFSEntry* instance,
236 const struct VFSURL* url);
237 bool(__cdecl* get_directory)(const struct AddonInstance_VFSEntry* instance,
238 const struct VFSURL* url,
239 struct VFSDirEntry** entries,
240 int* num_entries,
241 VFSGetDirectoryCallbacks* callbacks);
242 bool(__cdecl* contains_files)(const struct AddonInstance_VFSEntry* instance,
243 const struct VFSURL* url,
244 struct VFSDirEntry** entries,
245 int* num_entries,
246 char* rootpath);
247 void(__cdecl* free_directory)(const struct AddonInstance_VFSEntry* instance,
248 struct VFSDirEntry* entries,
249 int num_entries);
250 } KodiToAddonFuncTable_VFSEntry;
251
252 typedef struct AddonInstance_VFSEntry /* internal */
253 {
254 AddonProps_VFSEntry* props;
255 AddonToKodiFuncTable_VFSEntry* toKodi;
256 KodiToAddonFuncTable_VFSEntry* toAddon;
257 } AddonInstance_VFSEntry;
258
259#ifdef __cplusplus
260} /* extern "C" */
261
262namespace kodi
263{
264namespace addon
265{
266
267//##############################################################################
268/// @defgroup cpp_kodi_addon_vfs_Defs Definitions, structures and enumerators
269/// \ingroup cpp_kodi_addon_vfs
270/// @brief **VFS add-on general variables**
271///
272/// Used to exchange the available options between Kodi and addon.
273///
274///
275
276//==============================================================================
277///
278/// \addtogroup cpp_kodi_addon_vfs
279/// @brief \cpp_class{ kodi::addon::CInstanceVFS }
280/// **Virtual Filesystem (VFS) add-on instance**
281///
282/// This instance type is used to allow Kodi various additional file system
283/// types. Be it a special file system, a compressed package or a system
284/// available over the network, everything is possible with it.
285///
286/// This usage can be requested under various conditions, for example explicitly
287/// by another addon, by a Mimetype protocol defined in <b>`addon.xml`</b> or supported
288/// file extensions.
289///
290/// Include the header @ref VFS.h "#include <kodi/addon-instance/VFS.h>"
291/// to use this class.
292///
293/// ----------------------------------------------------------------------------
294///
295/// Here is an example of what the <b>`addon.xml.in`</b> would look like for an VFS addon:
296///
297/// ~~~~~~~~~~~~~{.xml}
298/// <?xml version="1.0" encoding="UTF-8"?>
299/// <addon
300/// id="vfs.myspecialnamefor"
301/// version="1.0.0"
302/// name="My VFS addon"
303/// provider-name="Your Name">
304/// <requires>@ADDON_DEPENDS@</requires>
305/// <extension
306/// point="kodi.vfs"
307/// protocols="myprot"
308/// extensions=".abc|.def"
309/// files="true"
310/// filedirectories="true"
311/// directories="true"
312/// encodedhostname="true"
313/// supportDialog="true"
314/// supportPath="true"
315/// supportUsername="true"
316/// supportPassword="true"
317/// supportPort="true"
318/// supportBrowsing="true"
319/// supportWrite="true"
320/// defaultPort="1234"
321/// label="30000"
322/// zeroconf="your_special_zeroconf_allowed_identifier"
323/// library_@PLATFORM@="@LIBRARY_FILENAME@"/>
324/// <extension point="xbmc.addon.metadata">
325/// <summary lang="en_GB">My VFS addon summary</summary>
326/// <description lang="en_GB">My VFS description</description>
327/// <platform>@PLATFORM@</platform>
328/// </extension>
329/// </addon>
330/// ~~~~~~~~~~~~~
331///
332/// @note Regarding boolean values with "false", these can also be omitted,
333/// since this would be the default.
334///
335///
336/// ### Standard values that can be declared for processing in `addon.xml`.
337///
338/// These values are used by Kodi to identify associated streams and file
339/// extensions and then to select the associated addon.
340///
341/// \table_start
342/// \table_h3{ Labels, Type, Description }
343/// \table_row3{ <b>`point`</b>,
344/// \anchor cpp_kodi_addon_vfs_point
345/// string,
346/// The identification of the addon instance to VFS is mandatory <b>`kodi.vfs`</b>.
347/// In addition\, the instance declared in the first <b>`<extension ... />`</b> is also the main type of addon.
348/// }
349/// \table_row3{ <b>`defaultPort`</b>,
350/// \anchor cpp_kodi_addon_vfs_defaultPort
351/// integer,
352/// Default [networking port](https://en.wikipedia.org/wiki/Port_(computer_networking))
353/// to use for protocol.
354/// }
355/// \table_row3{ <b>`directories`</b>,
356/// \anchor cpp_kodi_addon_vfs_directories
357/// boolean,
358/// VFS entry can list directories.
359/// }
360/// \table_row3{ <b>`extensions`</b>,
361/// \anchor cpp_kodi_addon_vfs_extensions
362/// string,
363/// Extensions for VFS entry.\n
364/// It is possible to declare several using <b>`|`</b>\, e.g. <b>`.abc|.def|.ghi`</b>.
365/// }
366/// \table_row3{ <b>`encodedhostname`</b>,
367/// \anchor cpp_kodi_addon_vfs_encodedhostname
368/// boolean,
369/// URL protocol from add-ons use encoded hostnames.
370/// }
371/// \table_row3{ <b>`filedirectories`</b>,
372/// \anchor cpp_kodi_addon_vfs_filedirectories
373/// boolean,
374/// VFS entry contains file directories.
375/// }
376/// \table_row3{ <b>`files`</b>,
377/// \anchor cpp_kodi_addon_vfs_directories
378/// boolean,
379/// Set to declare that VFS provides files.
380/// }
381/// \table_row3{ <b>`protocols`</b>,
382/// \anchor cpp_kodi_addon_vfs_protocols
383/// boolean,
384/// Protocols for VFS entry.\n
385/// It is possible to declare several using <b>`|`</b>\, e.g. <b>`myprot1|myprot2`</b>.\n
386/// @note This field also used to show on GUI\, see <b>`supportBrowsing`</b> below about <b>*2:</b>.
387/// When used there\, however\, only a **single** protocol is possible!
388/// }
389/// \table_row3{ <b>`supportWrite`</b>,
390/// \anchor cpp_kodi_addon_vfs_supportWrite
391/// boolean,
392/// Protocol supports write operations.
393/// }
394/// \table_row3{ <b>`zeroconf`</b>,
395/// \anchor cpp_kodi_addon_vfs_zeroconf
396/// string,
397/// [Zero conf](https://en.wikipedia.org/wiki/Zero-configuration_networking) announce string for VFS protocol.
398/// }
399/// \table_row3{ <b>`library_@PLATFORM@`</b>,
400/// \anchor cpp_kodi_addon_vfs_library
401/// string,
402/// The runtime library used for the addon. This is usually declared by `cmake` and correctly displayed in the translated <b>`addon.xml`</b>.
403/// }
404/// \table_end
405///
406///
407/// ### User selectable parts of the addon.
408///
409/// The following table describes the values that can be defined by <b>`addon.xml`</b>
410/// and which part they relate to for user input.
411///
412/// \table_start
413/// \table_h3{ Labels, Type, Description }
414/// \table_row3{ <b>`supportBrowsing`</b>,
415/// \anchor cpp_kodi_addon_vfs_protocol_supportBrowsing
416/// boolean,
417/// Protocol supports server browsing. Used to open related sources by users in the window.\n\n
418/// | Associated places in Kodi: |
419/// | :---- |
420/// | \image html cpp_kodi_addon_vfs_protocol_1.png |
421/// <br>
422/// <b>*1:</b> The entry in the menu represented by this option corresponds to the text given with <b>`label`</b>.
423/// When the button is pressed\, @ref CInstanceVFS::GetDirectory is called on the add-on to get its content.\n
424/// <b>*2:</b> Protocol name of the stream defined with <b>`protocols`</b> in xml.\n
425/// @remark See also <b>`supportDialog`</b> about <b>*3:</b>.
426/// }
427/// \table_row3{ <b>`supportDialog`</b>,
428/// \anchor cpp_kodi_addon_vfs_protocol_supportDialog
429/// boolean,
430/// 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
431/// This will be available when adding sources in Kodi under <b>"Add network location..."</b>.\n\n
432/// | Associated places in Kodi: |
433/// | :---- |
434/// | \image html cpp_kodi_addon_vfs_protocol_2.png |
435/// <br>
436/// <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
437/// <b>*2:</b> To set the associated server address. **Note:** *This field is always activated and cannot be changed by the addon.*\n
438/// <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
439/// <b>*4:</b> This field is available if <b>`supportPath`</b> is set to <b>`true`</b>.\n
440/// <b>*5:</b> To edit the connection port. This field is available if <b>`supportPort`</b> is set to <b>`true`</b>.\n
441/// <b>*6:</b> This sets the required username and is available when <b>`supportUsername`</b> is set to <b>`true`</b>.\n
442/// <b>*7:</b> This sets the required password and is available when <b>`supportPassword`</b> is set to <b>`true`</b>.
443/// }
444/// \table_row3{ <b>`supportPath`</b>,
445/// \anchor cpp_kodi_addon_vfs_protocol_supportPath
446/// boolean,
447/// Protocol has path in addition to server name (see <b>`supportDialog`</b> about <b>*4:</b>).
448/// }
449/// \table_row3{ <b>`supportPort`</b>,
450/// \anchor cpp_kodi_addon_vfs_protocol_supportPort
451/// boolean,
452/// Protocol supports port customization (see <b>`supportDialog`</b> about <b>*5:</b>).
453/// }
454/// \table_row3{ <b>`supportUsername`</b>,
455/// \anchor cpp_kodi_addon_vfs_protocol_supportUsername
456/// boolean,
457/// Protocol uses logins (see <b>`supportDialog`</b> about <b>*6:</b>).
458/// }
459/// \table_row3{ <b>`supportPassword`</b>,
460/// \anchor cpp_kodi_addon_vfs_protocol_supportPassword
461/// boolean,
462/// Protocol supports passwords (see <b>`supportDialog`</b> about <b>*7:</b>).
463/// }
464/// \table_row3{ <b>`protocols`</b>,
465/// \anchor cpp_kodi_addon_vfs_protocol_protocols
466/// string,
467/// Protocols for VFS entry.
468/// @note This field is not editable and only used on GUI to show his name\, see <b>`supportBrowsing`</b> about <b>*2:</b>
469/// }
470/// \table_row3{ <b>`label`</b>,
471/// \anchor cpp_kodi_addon_vfs_protocol_label
472/// integer,
473/// The text identification number used in Kodi for display in the menu at <b>`supportDialog`</b>
474/// as a selection option and at <b>`supportBrowsing`</b> (see his image reference <b>*1</b>) as a menu entry.\n
475/// This can be a text identifier in Kodi or from addon.\n
476/// @remark For addon within <b>30000</b>-<b>30999</b> or <b>32000</b>-<b>32999</b>.
477/// }
478/// \table_end
479///
480/// @remark For more detailed description of the <b>`addon.xml`</b>, see also https://kodi.wiki/view/Addon.xml.
481///
482///
483/// --------------------------------------------------------------------------
484///
485///
486/// **Example:**
487///
488/// ~~~~~~~~~~~~~{.cpp}
489/// #include <kodi/addon-instance/VFS.h>
490///
491/// class CMyVFS : public kodi::addon::CInstanceVFS
492/// {
493/// public:
494/// CMyVFS(KODI_HANDLE instance, const std::string& kodiVersion);
495///
496/// // Add all your required functions, the most CInstanceVFS functions of
497/// // must be included to have addon working correctly.
498/// ...
499/// };
500///
501/// CMyVFS::CMyVFS(KODI_HANDLE instance, const std::string& kodiVersion)
502/// : CInstanceVFS(instance, kodiVersion)
503/// {
504/// ...
505/// }
506///
507/// ...
508///
509/// /*----------------------------------------------------------------------*/
510///
511/// class CMyAddon : public kodi::addon::CAddonBase
512/// {
513/// public:
514/// CMyAddon() { }
515/// ADDON_STATUS CreateInstance(int instanceType,
516/// const std::string& instanceID,
517/// KODI_HANDLE instance,
518/// const std::string& version,
519/// KODI_HANDLE& addonInstance) override;
520/// };
521///
522/// // If you use only one instance in your add-on, can be instanceType and
523/// // instanceID ignored
524/// ADDON_STATUS CMyAddon::CreateInstance(int instanceType,
525/// const std::string& instanceID,
526/// KODI_HANDLE instance,
527/// const std::string& version,
528/// KODI_HANDLE& addonInstance)
529/// {
530/// if (instanceType == ADDON_INSTANCE_VFS)
531/// {
532/// kodi::Log(ADDON_LOG_NOTICE, "Creating my VFS instance");
533/// addonInstance = new CMyVFS(instance, version);
534/// return ADDON_STATUS_OK;
535/// }
536/// else if (...)
537/// {
538/// ...
539/// }
540/// return ADDON_STATUS_UNKNOWN;
541/// }
542///
543/// ADDONCREATOR(CMyAddon)
544/// ~~~~~~~~~~~~~
545///
546/// The destruction of the example class `CMyVFS` is called from
547/// Kodi's header. Manually deleting the add-on instance is not required.
548///
549//----------------------------------------------------------------------------
550class ATTRIBUTE_HIDDEN CInstanceVFS : public IAddonInstance
551{
552public:
553 //==========================================================================
554 ///
555 /// @ingroup cpp_kodi_addon_vfs
556 /// @brief VFS class constructor used to support multiple instance
557 /// types
558 ///
559 /// @param[in] instance The instance value given to
560 /// <b>`kodi::addon::CAddonBase::CreateInstance(...)`</b>.
561 /// @param[in] kodiVersion [opt] given from Kodi by @ref CAddonBase::CreateInstance
562 /// to identify his instance API version
563 ///
564 /// @note Instance path as a single is not supported by this type. It must
565 /// ensure that it can be called up several times.
566 ///
567 /// @warning Only use `instance` from the @ref CAddonBase::CreateInstance or
568 /// @ref CAddonBase::CreateInstance call.
569 ///
570 explicit CInstanceVFS(KODI_HANDLE instance, const std::string& kodiVersion = "")
571 : IAddonInstance(ADDON_INSTANCE_VFS,
572 !kodiVersion.empty() ? kodiVersion : GetKodiTypeVersion(ADDON_INSTANCE_VFS))
573 {
574 if (CAddonBase::m_interface->globalSingleInstance != nullptr)
575 throw std::logic_error("kodi::addon::CInstanceVFS: Creation of multiple together with single "
576 "instance way is not allowed!");
577
578 SetAddonStruct(instance);
579 }
580 //--------------------------------------------------------------------------
581
582 //==========================================================================
583 ///
584 /// @ingroup cpp_kodi_addon_vfs
585 /// @brief Destructor
586 ///
587 ~CInstanceVFS() override = default;
588 //--------------------------------------------------------------------------
589
590 //==========================================================================
591 ///
592 /// @defgroup cpp_kodi_addon_vfs_general 1. General access functions
593 /// @ingroup cpp_kodi_addon_vfs
594 /// @brief **General access functions**
595 ///
596 /// This functions which are intended for getting folders, editing storage
597 /// locations and file system queries.
598 ///
599
600 //==========================================================================
601 ///
602 /// @defgroup cpp_kodi_addon_vfs_filecontrol 2. File editing functions
603 /// @ingroup cpp_kodi_addon_vfs
604 /// @brief **File editing functions.**
605 ///
606 /// This value represents the addon-side handlers and to be able to identify
607 /// his own parts in the event of further access.
608 ///
609
610 //@{
611 //==========================================================================
612 ///
613 /// @ingroup cpp_kodi_addon_vfs_filecontrol
614 /// @brief Open a file for input
615 ///
616 /// @param[in] url The URL of the file
617 /// @return Context for the opened file
618 virtual void* Open(const VFSURL& url) { return nullptr; }
619
620 //==========================================================================
621 ///
622 /// @ingroup cpp_kodi_addon_vfs_filecontrol
623 /// @brief Open a file for output
624 ///
625 /// @param[in] url The URL of the file
626 /// @param[in] overWrite Whether or not to overwrite an existing file
627 /// @return Context for the opened file
628 ///
629 virtual void* OpenForWrite(const VFSURL& url, bool overWrite) { return nullptr; }
630 //--------------------------------------------------------------------------
631
632 //==========================================================================
633 ///
634 /// @ingroup cpp_kodi_addon_vfs_filecontrol
635 /// @brief Close a file
636 ///
637 /// @param[in] context The context of the file
638 /// @return True on success, false on failure
639 ///
640 virtual bool Close(void* context) { return false; }
641 //--------------------------------------------------------------------------
642
643 //==========================================================================
644 ///
645 /// @ingroup cpp_kodi_addon_vfs_filecontrol
646 /// @brief Read from a file
647 ///
648 /// @param[in] context The context of the file
649 /// @param[out] buffer The buffer to read data into
650 /// @param[in] uiBufSize Number of bytes to read
651 /// @return Number of bytes read
652 ///
653 virtual ssize_t Read(void* context, void* buffer, size_t uiBufSize) { return -1; }
654 //--------------------------------------------------------------------------
655
656 //==========================================================================
657 ///
658 /// @ingroup cpp_kodi_addon_vfs_filecontrol
659 /// @brief Write to a file
660 ///
661 /// @param[in] context The context of the file
662 /// @param[in] buffer The buffer to read data from
663 /// @param[in] uiBufSize Number of bytes to write
664 /// @return Number of bytes written
665 ///
666 virtual ssize_t Write(void* context, const void* buffer, size_t uiBufSize) { return -1; }
667 //--------------------------------------------------------------------------
668
669 //==========================================================================
670 ///
671 /// @ingroup cpp_kodi_addon_vfs_filecontrol
672 /// @brief Seek in a file
673 ///
674 /// @param[in] context The context of the file
675 /// @param[in] position The position to seek to
676 /// @param[in] whence Position in file 'position' is relative to (SEEK_CUR, SEEK_SET, SEEK_END)
677 /// @return Offset in file after seek
678 ///
679 virtual int64_t Seek(void* context, int64_t position, int whence) { return -1; }
680 //--------------------------------------------------------------------------
681
682 //==========================================================================
683 ///
684 /// @ingroup cpp_kodi_addon_vfs_filecontrol
685 /// @brief Truncate a file
686 ///
687 /// @param[in] context The context of the file
688 /// @param[in] size The size to truncate the file to
689 /// @return 0 on success, -1 on error
690 ///
691 virtual int Truncate(void* context, int64_t size) { return -1; }
692 //--------------------------------------------------------------------------
693
694 //==========================================================================
695 ///
696 /// @ingroup cpp_kodi_addon_vfs_filecontrol
697 /// @brief Get total size of a file
698 ///
699 /// @param[in] context The context of the file
700 /// @return Total file size
701 ///
702 virtual int64_t GetLength(void* context) { return 0; }
703 //--------------------------------------------------------------------------
704
705 //==========================================================================
706 ///
707 /// @ingroup cpp_kodi_addon_vfs_filecontrol
708 /// @brief Get current position in a file
709 ///
710 /// @param[in] context The context of the file
711 /// @return Current position
712 ///
713 virtual int64_t GetPosition(void* context) { return 0; }
714 //--------------------------------------------------------------------------
715
716 //==========================================================================
717 ///
718 /// @ingroup cpp_kodi_addon_vfs_filecontrol
719 /// @brief Get chunk size of a file
720 ///
721 /// @param[in] context The context of the file
722 /// @return Chunk size
723 ///
724 virtual int GetChunkSize(void* context) { return 1; }
725 //--------------------------------------------------------------------------
726
727 //==========================================================================
728 ///
729 /// @ingroup cpp_kodi_addon_vfs_filecontrol
730 /// @brief Perform an IO-control on the file
731 ///
732 /// @param[in] context The context of the file
733 /// @param[in] request The requested IO-control
734 /// @param[in] param Parameter attached to the IO-control
735 /// @return -1 on error, >= 0 on success
736 ///
737 virtual int IoControl(void* context, VFS_IOCTRL request, void* param) { return -1; }
738 //--------------------------------------------------------------------------
739 //@}
740
741 //@{
742 //==========================================================================
743 ///
744 /// @ingroup cpp_kodi_addon_vfs_general
745 /// @brief Stat a file
746 ///
747 /// @param[in] url The URL of the file
748 /// @param[in] buffer The buffer to store results in
749 /// @return -1 on error, 0 otherwise
750 ///
751 virtual int Stat(const VFSURL& url, struct __stat64* buffer) { return 0; }
752 //--------------------------------------------------------------------------
753
754 //==========================================================================
755 ///
756 /// @ingroup cpp_kodi_addon_vfs_general
757 /// @brief Check for file existence
758 ///
759 /// @param[in] url The URL of the file
760 /// @return True if file exists, false otherwise
761 ///
762 virtual bool Exists(const VFSURL& url) { return false; }
763 //--------------------------------------------------------------------------
764
765 //==========================================================================
766 ///
767 /// @ingroup cpp_kodi_addon_vfs_general
768 /// @brief Clear out any idle connections
769 ///
770 virtual void ClearOutIdle() {}
771 //--------------------------------------------------------------------------
772
773 //==========================================================================
774 ///
775 /// @ingroup cpp_kodi_addon_vfs_general
776 /// @brief Disconnect all connections
777 ///
778 virtual void DisconnectAll() {}
779 //--------------------------------------------------------------------------
780
781 //==========================================================================
782 ///
783 /// @ingroup cpp_kodi_addon_vfs_general
784 /// @brief Delete a file
785 ///
786 /// @param[in] url The URL of the file
787 /// @return True if deletion was successful, false otherwise
788 ///
789 virtual bool Delete(const VFSURL& url) { return false; }
790 //--------------------------------------------------------------------------
791
792 //==========================================================================
793 ///
794 /// @ingroup cpp_kodi_addon_vfs_general
795 /// @brief Rename a file
796 ///
797 /// @param[in] url The URL of the source file
798 /// @param[in] url2 The URL of the destination file
799 /// @return True if deletion was successful, false otherwise
800 ///
801 virtual bool Rename(const VFSURL& url, const VFSURL& url2) { return false; }
802 //--------------------------------------------------------------------------
803
804 //==========================================================================
805 ///
806 /// @ingroup cpp_kodi_addon_vfs_general
807 /// @brief Check for directory existence
808 ///
809 /// @param[in] url The URL of the file
810 /// @return True if directory exists, false otherwise
811 ///
812 virtual bool DirectoryExists(const VFSURL& url) { return false; }
813 //--------------------------------------------------------------------------
814
815 //==========================================================================
816 ///
817 /// @ingroup cpp_kodi_addon_vfs_general
818 /// @brief Remove a directory
819 ///
820 /// @param[in] url The URL of the directory
821 /// @return True if removal was successful, false otherwise
822 ///
823 virtual bool RemoveDirectory(const VFSURL& url) { return false; }
824 //--------------------------------------------------------------------------
825
826 //==========================================================================
827 ///
828 /// @ingroup cpp_kodi_addon_vfs_general
829 /// @brief Create a directory
830 ///
831 /// @param[in] url The URL of the file
832 /// @return True if creation was successful, false otherwise
833 ///
834 virtual bool CreateDirectory(const VFSURL& url) { return false; }
835 //--------------------------------------------------------------------------
836
837 //==========================================================================
838 ///
839 /// @defgroup cpp_kodi_addon_vfs_general_cb_GetDirectory **Callbacks GetDirectory()**
840 /// @ingroup cpp_kodi_addon_vfs_general
841 /// @brief Callback functions on GetDirectory()
842 ///
843 /// This functions becomes available during call of GetDirectory() from
844 /// Kodi.
845 ///
846 /// If GetDirectory() returns false becomes the parts from here used on
847 /// next call of the function.
848 ///
849 /// **Example:**
850 /// ~~~~~~~~~~~~~{.cpp}
851 ///
852 /// #include <kodi/addon-instance/VFS.h>
853 ///
854 /// ...
855 ///
856 /// bool CMyVFS::GetDirectory(const VFSURL& url, std::vector<kodi::vfs::CDirEntry>& items, CVFSCallbacks callbacks)
857 /// {
858 /// std::string neededString;
859 /// callbacks.GetKeyboardInput("Test", neededString, true);
860 /// if (neededString.empty())
861 /// return false;
862 ///
863 /// // Do the work
864 /// ...
865 /// return true;
866 /// }
867 /// ~~~~~~~~~~~~~
868 ///
869 class CVFSCallbacks
870 {
871 public:
872 /// @ingroup cpp_kodi_addon_vfs_general_cb_GetDirectory
873 /// @brief Require keyboard input
874 ///
875 /// Becomes called if GetDirectory() returns false and GetDirectory()
876 /// becomes after entry called again.
877 ///
878 /// @param[in] heading The heading of the keyboard dialog
879 /// @param[out] input The resulting string. Returns string after
880 /// second call!
881 /// @param[in] hiddenInput To show input only as "*" on dialog
882 /// @return True if input was received, false otherwise
883 ///
884 bool GetKeyboardInput(const std::string& heading, std::string& input, bool hiddenInput = false)
885 {
886 char* cInput = nullptr;
887 bool ret = m_cb->get_keyboard_input(m_cb->ctx, heading.c_str(), &cInput, hiddenInput);
888 if (cInput)
889 {
890 input = cInput;
891 ::kodi::addon::CAddonBase::m_interface->toKodi->free_string(
892 ::kodi::addon::CAddonBase::m_interface->toKodi->kodiBase, cInput);
893 }
894 return ret;
895 }
896
897 /// @ingroup cpp_kodi_addon_vfs_general_cb_GetDirectory
898 /// @brief Display an error dialog
899 ///
900 /// @param[in] heading The heading of the error dialog
901 /// @param[in] line1 The first line of the error dialog
902 /// @param[in] line2 [opt] The second line of the error dialog
903 /// @param[in] line3 [opt] The third line of the error dialog
904 ///
905 void SetErrorDialog(const std::string& heading,
906 const std::string& line1,
907 const std::string& line2 = "",
908 const std::string& line3 = "")
909 {
910 m_cb->set_error_dialog(m_cb->ctx, heading.c_str(), line1.c_str(), line2.c_str(),
911 line3.c_str());
912 }
913
914 /// @ingroup cpp_kodi_addon_vfs_general_cb_GetDirectory
915 /// @brief Prompt the user for authentication of a URL
916 ///
917 /// @param[in] url The URL
918 void RequireAuthentication(const std::string& url)
919 {
920 m_cb->require_authentication(m_cb->ctx, url.c_str());
921 }
922
923 explicit CVFSCallbacks(const VFSGetDirectoryCallbacks* cb) : m_cb(cb) {}
924
925 private:
926 const VFSGetDirectoryCallbacks* m_cb;
927 };
928 //--------------------------------------------------------------------------
929
930 //==========================================================================
931 ///
932 /// @ingroup cpp_kodi_addon_vfs_general
933 /// @brief List a directory
934 ///
935 /// @param[in] url The URL of the directory
936 /// @param[out] entries The entries in the directory, see
937 /// @ref cpp_kodi_vfs_CDirEntry "kodi::vfs::CDirEntry"
938 /// about his content
939 /// @param[in] callbacks A callback structure
940 /// @return Context for the directory listing
941 ///
942 ///
943 /// --------------------------------------------------------------------------
944 ///
945 /// ### Callbacks:
946 /// @copydetails cpp_kodi_addon_vfs_general_cb_GetDirectory
947 ///
948 /// **Available callback functions**
949 /// | Function: | Description
950 /// |--|--
951 /// | CVFSCallbacks::GetKeyboardInput | @copybrief CVFSCallbacks::GetKeyboardInput @copydetails CVFSCallbacks::GetKeyboardInput
952 /// | CVFSCallbacks::SetErrorDialog | @copybrief CVFSCallbacks::SetErrorDialog @copydetails CVFSCallbacks::SetErrorDialog
953 /// | CVFSCallbacks::RequireAuthentication | @copybrief CVFSCallbacks::RequireAuthentication @copydetails CVFSCallbacks::RequireAuthentication
954 ///
955 virtual bool GetDirectory(const VFSURL& url,
956 std::vector<kodi::vfs::CDirEntry>& entries,
957 CVFSCallbacks callbacks)
958 {
959 return false;
960 }
961 //--------------------------------------------------------------------------
962
963 //==========================================================================
964 ///
965 /// @ingroup cpp_kodi_addon_vfs_general
966 /// @brief Check if file should be presented as a directory (multiple streams)
967 ///
968 /// @param[in] url The URL of the file
969 /// @param[out] entries The entries in the directory, see
970 /// @ref cpp_kodi_vfs_CDirEntry "kodi::vfs::CDirEntry"
971 /// about his content
972 /// @param[out] rootPath Path to root directory if multiple entries
973 /// @return Context for the directory listing
974 ///
975 virtual bool ContainsFiles(const VFSURL& url,
976 std::vector<kodi::vfs::CDirEntry>& entries,
977 std::string& rootPath)
978 {
979 return false;
980 }
981 //--------------------------------------------------------------------------
982 //@}
983
984private:
985 void SetAddonStruct(KODI_HANDLE instance)
986 {
987 if (instance == nullptr)
988 throw std::logic_error("kodi::addon::CInstanceVFS: Creation with empty addon structure not "
989 "allowed, table must be given from Kodi!");
990
991 m_instanceData = static_cast<AddonInstance_VFSEntry*>(instance);
992 m_instanceData->toAddon->addonInstance = this;
993 m_instanceData->toAddon->open = ADDON_Open;
994 m_instanceData->toAddon->open_for_write = ADDON_OpenForWrite;
995 m_instanceData->toAddon->read = ADDON_Read;
996 m_instanceData->toAddon->write = ADDON_Write;
997 m_instanceData->toAddon->seek = ADDON_Seek;
998 m_instanceData->toAddon->truncate = ADDON_Truncate;
999 m_instanceData->toAddon->get_length = ADDON_GetLength;
1000 m_instanceData->toAddon->get_position = ADDON_GetPosition;
1001 m_instanceData->toAddon->get_chunk_size = ADDON_GetChunkSize;
1002 m_instanceData->toAddon->io_control = ADDON_IoControl;
1003 m_instanceData->toAddon->stat = ADDON_Stat;
1004 m_instanceData->toAddon->close = ADDON_Close;
1005 m_instanceData->toAddon->exists = ADDON_Exists;
1006 m_instanceData->toAddon->clear_out_idle = ADDON_ClearOutIdle;
1007 m_instanceData->toAddon->disconnect_all = ADDON_DisconnectAll;
1008 m_instanceData->toAddon->delete_it = ADDON_Delete;
1009 m_instanceData->toAddon->rename = ADDON_Rename;
1010 m_instanceData->toAddon->directory_exists = ADDON_DirectoryExists;
1011 m_instanceData->toAddon->remove_directory = ADDON_RemoveDirectory;
1012 m_instanceData->toAddon->create_directory = ADDON_CreateDirectory;
1013 m_instanceData->toAddon->get_directory = ADDON_GetDirectory;
1014 m_instanceData->toAddon->free_directory = ADDON_FreeDirectory;
1015 m_instanceData->toAddon->contains_files = ADDON_ContainsFiles;
1016 }
1017
1018 inline static void* ADDON_Open(const AddonInstance_VFSEntry* instance, const VFSURL* url)
1019 {
1020 return static_cast<CInstanceVFS*>(instance->toAddon->addonInstance)->Open(*url);
1021 }
1022
1023 inline static void* ADDON_OpenForWrite(const AddonInstance_VFSEntry* instance,
1024 const VFSURL* url,
1025 bool overWrite)
1026 {
1027 return static_cast<CInstanceVFS*>(instance->toAddon->addonInstance)
1028 ->OpenForWrite(*url, overWrite);
1029 }
1030
1031 inline static ssize_t ADDON_Read(const AddonInstance_VFSEntry* instance,
1032 void* context,
1033 void* buffer,
1034 size_t uiBufSize)
1035 {
1036 return static_cast<CInstanceVFS*>(instance->toAddon->addonInstance)
1037 ->Read(context, buffer, uiBufSize);
1038 }
1039
1040 inline static ssize_t ADDON_Write(const AddonInstance_VFSEntry* instance,
1041 void* context,
1042 const void* buffer,
1043 size_t uiBufSize)
1044 {
1045 return static_cast<CInstanceVFS*>(instance->toAddon->addonInstance)
1046 ->Write(context, buffer, uiBufSize);
1047 }
1048
1049 inline static int64_t ADDON_Seek(const AddonInstance_VFSEntry* instance,
1050 void* context,
1051 int64_t position,
1052 int whence)
1053 {
1054 return static_cast<CInstanceVFS*>(instance->toAddon->addonInstance)
1055 ->Seek(context, position, whence);
1056 }
1057
1058 inline static int ADDON_Truncate(const AddonInstance_VFSEntry* instance,
1059 void* context,
1060 int64_t size)
1061 {
1062 return static_cast<CInstanceVFS*>(instance->toAddon->addonInstance)->Truncate(context, size);
1063 }
1064
1065 inline static int64_t ADDON_GetLength(const AddonInstance_VFSEntry* instance, void* context)
1066 {
1067 return static_cast<CInstanceVFS*>(instance->toAddon->addonInstance)->GetLength(context);
1068 }
1069
1070 inline static int64_t ADDON_GetPosition(const AddonInstance_VFSEntry* instance, void* context)
1071 {
1072 return static_cast<CInstanceVFS*>(instance->toAddon->addonInstance)->GetPosition(context);
1073 }
1074
1075 inline static int ADDON_GetChunkSize(const AddonInstance_VFSEntry* instance, void* context)
1076 {
1077 return static_cast<CInstanceVFS*>(instance->toAddon->addonInstance)->GetChunkSize(context);
1078 }
1079
1080 inline static int ADDON_IoControl(const AddonInstance_VFSEntry* instance,
1081 void* context,
1082 enum VFS_IOCTRL request,
1083 void* param)
1084 {
1085 return static_cast<CInstanceVFS*>(instance->toAddon->addonInstance)
1086 ->IoControl(context, request, param);
1087 }
1088
1089 inline static int ADDON_Stat(const AddonInstance_VFSEntry* instance,
1090 const VFSURL* url,
1091 struct __stat64* buffer)
1092 {
1093 return static_cast<CInstanceVFS*>(instance->toAddon->addonInstance)->Stat(*url, buffer);
1094 }
1095
1096 inline static bool ADDON_Close(const AddonInstance_VFSEntry* instance, void* context)
1097 {
1098 return static_cast<CInstanceVFS*>(instance->toAddon->addonInstance)->Close(context);
1099 }
1100
1101 inline static bool ADDON_Exists(const AddonInstance_VFSEntry* instance, const VFSURL* url)
1102 {
1103 return static_cast<CInstanceVFS*>(instance->toAddon->addonInstance)->Exists(*url);
1104 }
1105
1106 inline static void ADDON_ClearOutIdle(const AddonInstance_VFSEntry* instance)
1107 {
1108 return static_cast<CInstanceVFS*>(instance->toAddon->addonInstance)->ClearOutIdle();
1109 }
1110
1111 inline static void ADDON_DisconnectAll(const AddonInstance_VFSEntry* instance)
1112 {
1113 return static_cast<CInstanceVFS*>(instance->toAddon->addonInstance)->DisconnectAll();
1114 }
1115
1116 inline static bool ADDON_Delete(const AddonInstance_VFSEntry* instance, const VFSURL* url)
1117 {
1118 return static_cast<CInstanceVFS*>(instance->toAddon->addonInstance)->Delete(*url);
1119 }
1120
1121 inline static bool ADDON_Rename(const AddonInstance_VFSEntry* instance,
1122 const VFSURL* url,
1123 const VFSURL* url2)
1124 {
1125 return static_cast<CInstanceVFS*>(instance->toAddon->addonInstance)->Rename(*url, *url2);
1126 }
1127
1128 inline static bool ADDON_DirectoryExists(const AddonInstance_VFSEntry* instance,
1129 const VFSURL* url)
1130 {
1131 return static_cast<CInstanceVFS*>(instance->toAddon->addonInstance)->DirectoryExists(*url);
1132 }
1133
1134 inline static bool ADDON_RemoveDirectory(const AddonInstance_VFSEntry* instance,
1135 const VFSURL* url)
1136 {
1137 return static_cast<CInstanceVFS*>(instance->toAddon->addonInstance)->RemoveDirectory(*url);
1138 }
1139
1140 inline static bool ADDON_CreateDirectory(const AddonInstance_VFSEntry* instance,
1141 const VFSURL* url)
1142 {
1143 return static_cast<CInstanceVFS*>(instance->toAddon->addonInstance)->CreateDirectory(*url);
1144 }
1145
1146 inline static bool ADDON_GetDirectory(const AddonInstance_VFSEntry* instance,
1147 const VFSURL* url,
1148 VFSDirEntry** retEntries,
1149 int* num_entries,
1150 VFSGetDirectoryCallbacks* callbacks)
1151 {
1152 std::vector<kodi::vfs::CDirEntry> addonEntries;
1153 bool ret = static_cast<CInstanceVFS*>(instance->toAddon->addonInstance)
1154 ->GetDirectory(*url, addonEntries, CVFSCallbacks(callbacks));
1155 if (ret)
1156 {
1157 VFSDirEntry* entries =
1158 static_cast<VFSDirEntry*>(malloc(sizeof(VFSDirEntry) * addonEntries.size()));
1159 for (unsigned int i = 0; i < addonEntries.size(); ++i)
1160 {
1161 entries[i].label = strdup(addonEntries[i].Label().c_str());
1162 entries[i].title = strdup(addonEntries[i].Title().c_str());
1163 entries[i].path = strdup(addonEntries[i].Path().c_str());
1164 entries[i].folder = addonEntries[i].IsFolder();
1165 entries[i].size = addonEntries[i].Size();
1166 entries[i].date_time = addonEntries[i].DateTime();
1167
1168 entries[i].num_props = 0;
1169 const std::map<std::string, std::string>& props = addonEntries[i].GetProperties();
1170 if (!props.empty())
1171 {
1172 entries[i].properties =
1173 static_cast<VFSProperty*>(malloc(sizeof(VFSProperty) * props.size()));
1174 for (const auto& prop : props)
1175 {
1176 entries[i].properties[entries[i].num_props].name = strdup(prop.first.c_str());
1177 entries[i].properties[entries[i].num_props].val = strdup(prop.second.c_str());
1178 ++entries[i].num_props;
1179 }
1180 }
1181 else
1182 entries[i].properties = nullptr;
1183 }
1184 *retEntries = entries;
1185 *num_entries = static_cast<int>(addonEntries.size());
1186 }
1187 return ret;
1188 }
1189
1190 inline static void ADDON_FreeDirectory(const AddonInstance_VFSEntry* instance,
1191 VFSDirEntry* entries,
1192 int num_entries)
1193 {
1194 for (int i = 0; i < num_entries; ++i)
1195 {
1196 if (entries[i].properties)
1197 {
1198 for (unsigned int j = 0; j < entries[i].num_props; ++j)
1199 {
1200 free(entries[i].properties[j].name);
1201 free(entries[i].properties[j].val);
1202 }
1203 free(entries[i].properties);
1204 }
1205 free(entries[i].label);
1206 free(entries[i].title);
1207 free(entries[i].path);
1208 }
1209 free(entries);
1210 }
1211
1212 inline static bool ADDON_ContainsFiles(const AddonInstance_VFSEntry* instance,
1213 const VFSURL* url,
1214 VFSDirEntry** retEntries,
1215 int* num_entries,
1216 char* rootpath)
1217 {
1218 std::string cppRootPath;
1219 std::vector<kodi::vfs::CDirEntry> addonEntries;
1220 bool ret = static_cast<CInstanceVFS*>(instance->toAddon->addonInstance)
1221 ->ContainsFiles(*url, addonEntries, cppRootPath);
1222 if (ret)
1223 {
1224 strncpy(rootpath, cppRootPath.c_str(), ADDON_STANDARD_STRING_LENGTH);
1225
1226 VFSDirEntry* entries =
1227 static_cast<VFSDirEntry*>(malloc(sizeof(VFSDirEntry) * addonEntries.size()));
1228 for (size_t i = 0; i < addonEntries.size(); ++i)
1229 {
1230 entries[i].label = strdup(addonEntries[i].Label().c_str());
1231 entries[i].title = strdup(addonEntries[i].Title().c_str());
1232 entries[i].path = strdup(addonEntries[i].Path().c_str());
1233 entries[i].folder = addonEntries[i].IsFolder();
1234 entries[i].size = addonEntries[i].Size();
1235 entries[i].date_time = addonEntries[i].DateTime();
1236
1237 entries[i].num_props = 0;
1238 const std::map<std::string, std::string>& props = addonEntries[i].GetProperties();
1239 if (!props.empty())
1240 {
1241 entries[i].properties =
1242 static_cast<VFSProperty*>(malloc(sizeof(VFSProperty) * props.size()));
1243 for (const auto& prop : props)
1244 {
1245 entries[i].properties[entries[i].num_props].name = strdup(prop.first.c_str());
1246 entries[i].properties[entries[i].num_props].val = strdup(prop.second.c_str());
1247 ++entries[i].num_props;
1248 }
1249 }
1250 else
1251 entries[i].properties = nullptr;
1252 }
1253 *retEntries = entries;
1254 *num_entries = static_cast<int>(addonEntries.size());
1255 }
1256 return ret;
1257 }
1258
1259 AddonInstance_VFSEntry* m_instanceData;
1260};
1261
1262} /* namespace addon */
1263} /* namespace kodi */
1264
1265#endif /* __cplusplus */
diff --git a/xbmc/addons/kodi-addon-dev-kit/include/kodi/addon-instance/VideoCodec.h b/xbmc/addons/kodi-addon-dev-kit/include/kodi/addon-instance/VideoCodec.h
deleted file mode 100644
index 54246f0..0000000
--- a/xbmc/addons/kodi-addon-dev-kit/include/kodi/addon-instance/VideoCodec.h
+++ /dev/null
@@ -1,246 +0,0 @@
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
21namespace kodi { namespace addon { class CInstanceVideoCodec; } }
22
23extern "C"
24{
25 enum VIDEOCODEC_FORMAT
26 {
27 UnknownVideoFormat = 0,
28 VideoFormatYV12,
29 VideoFormatI420,
30 MaxVideoFormats
31 };
32
33
34 struct VIDEOCODEC_INITDATA
35 {
36 enum Codec {
37 CodecUnknown = 0,
38 CodecVp8,
39 CodecH264,
40 CodecVp9
41 } codec;
42
43 STREAMCODEC_PROFILE codecProfile;
44
45 //UnknownVideoFormat is terminator
46 VIDEOCODEC_FORMAT *videoFormats;
47
48 uint32_t width, height;
49
50 const uint8_t *extraData;
51 unsigned int extraDataSize;
52
53 CRYPTO_INFO cryptoInfo;
54 };
55
56 struct VIDEOCODEC_PICTURE
57 {
58 enum VideoPlane {
59 YPlane = 0,
60 UPlane,
61 VPlane,
62 MaxPlanes = 3,
63 };
64
65 enum Flags : uint32_t {
66 FLAG_DROP,
67 FLAG_DRAIN
68 };
69
70 VIDEOCODEC_FORMAT videoFormat;
71 uint32_t flags;
72
73 uint32_t width, height;
74
75 uint8_t *decodedData;
76 size_t decodedDataSize;
77
78 uint32_t planeOffsets[VideoPlane::MaxPlanes];
79 uint32_t stride[VideoPlane::MaxPlanes];
80
81 int64_t pts;
82
83 KODI_HANDLE buffer; //< will be passed in release_frame_buffer
84 };
85
86 enum VIDEOCODEC_RETVAL
87 {
88 VC_NONE = 0, //< noop
89 VC_ERROR, //< an error occurred, no other messages will be returned
90 VC_BUFFER, //< the decoder needs more data
91 VC_PICTURE, //< the decoder got a picture
92 VC_EOF, //< the decoder signals EOF
93 };
94
95 // this are properties given to the addon on create
96 // at this time we have no parameters for the addon
97 typedef struct AddonProps_VideoCodec
98 {
99 int dummy;
100 } AddonProps_VideoCodec;
101
102 struct AddonInstance_VideoCodec;
103 typedef struct KodiToAddonFuncTable_VideoCodec
104 {
105 kodi::addon::CInstanceVideoCodec* addonInstance;
106
107 //! \brief Opens a codec
108 bool (__cdecl* open) (const AddonInstance_VideoCodec* instance, VIDEOCODEC_INITDATA *initData);
109
110 //! \brief Reconfigures a codec
111 bool (__cdecl* reconfigure) (const AddonInstance_VideoCodec* instance, VIDEOCODEC_INITDATA *initData);
112
113 //! \brief Feed codec if requested from GetPicture() (return VC_BUFFER)
114 bool (__cdecl* add_data) (const AddonInstance_VideoCodec* instance, const DemuxPacket *packet);
115
116 //! \brief Get a decoded picture / request new data
117 VIDEOCODEC_RETVAL (__cdecl* get_picture) (const AddonInstance_VideoCodec* instance, VIDEOCODEC_PICTURE *picture);
118
119 //! \brief Get the name of this video decoder
120 const char *(__cdecl* get_name) (const AddonInstance_VideoCodec* instance);
121
122 //! \brief Reset the codec
123 void (__cdecl* reset)(const AddonInstance_VideoCodec* instance);
124 } KodiToAddonFuncTable_VideoCodec;
125
126 typedef struct AddonToKodiFuncTable_VideoCodec
127 {
128 KODI_HANDLE kodiInstance;
129 bool(*get_frame_buffer)(void* kodiInstance, VIDEOCODEC_PICTURE *picture);
130 void(*release_frame_buffer)(void* kodiInstance, void *buffer);
131 } AddonToKodiFuncTable_VideoCodec;
132
133 typedef struct AddonInstance_VideoCodec
134 {
135 AddonProps_VideoCodec props;
136 AddonToKodiFuncTable_VideoCodec toKodi;
137 KodiToAddonFuncTable_VideoCodec toAddon;
138 } AddonInstance_VideoCodec;
139}
140
141namespace kodi
142{
143 namespace addon
144 {
145
146 class ATTRIBUTE_HIDDEN CInstanceVideoCodec : public IAddonInstance
147 {
148 public:
149 explicit CInstanceVideoCodec(KODI_HANDLE instance, const std::string& kodiVersion = "")
150 : IAddonInstance(ADDON_INSTANCE_VIDEOCODEC,
151 !kodiVersion.empty() ? kodiVersion
152 : GetKodiTypeVersion(ADDON_INSTANCE_VIDEOCODEC))
153 {
154 if (CAddonBase::m_interface->globalSingleInstance != nullptr)
155 throw std::logic_error("kodi::addon::CInstanceVideoCodec: Creation of multiple together with single instance way is not allowed!");
156
157 SetAddonStruct(instance);
158 }
159
160 ~CInstanceVideoCodec() override = default;
161
162 //! \copydoc CInstanceVideoCodec::Open
163 virtual bool Open(VIDEOCODEC_INITDATA &initData) { return false; };
164
165 //! \copydoc CInstanceVideoCodec::Reconfigure
166 virtual bool Reconfigure(VIDEOCODEC_INITDATA &initData) { return false; };
167
168 //! \copydoc CInstanceVideoCodec::AddData
169 virtual bool AddData(const DemuxPacket &packet) { return false; };
170
171 //! \copydoc CInstanceVideoCodec::GetPicture
172 virtual VIDEOCODEC_RETVAL GetPicture(VIDEOCODEC_PICTURE &picture) { return VC_ERROR; };
173
174 //! \copydoc CInstanceVideoCodec::GetName
175 virtual const char *GetName() { return nullptr; };
176
177 //! \copydoc CInstanceVideoCodec::Reset
178 virtual void Reset() {};
179
180 /*!
181 * @brief AddonToKodi interface
182 */
183
184 //! \copydoc CInstanceVideoCodec::GetFrameBuffer
185 bool GetFrameBuffer(VIDEOCODEC_PICTURE &picture)
186 {
187 return m_instanceData->toKodi.get_frame_buffer(m_instanceData->toKodi.kodiInstance, &picture);
188 }
189
190 //! \copydoc CInstanceVideoCodec::ReleaseFrameBuffer
191 void ReleaseFrameBuffer(void *buffer)
192 {
193 return m_instanceData->toKodi.release_frame_buffer(m_instanceData->toKodi.kodiInstance, 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 instance->toAddon.addonInstance->Open(*initData);
216 }
217
218 inline static bool ADDON_Reconfigure(const AddonInstance_VideoCodec* instance, VIDEOCODEC_INITDATA *initData)
219 {
220 return instance->toAddon.addonInstance->Reconfigure(*initData);
221 }
222
223 inline static bool ADDON_AddData(const AddonInstance_VideoCodec* instance, const DemuxPacket *packet)
224 {
225 return instance->toAddon.addonInstance->AddData(*packet);
226 }
227
228 inline static VIDEOCODEC_RETVAL ADDON_GetPicture(const AddonInstance_VideoCodec* instance, VIDEOCODEC_PICTURE *picture)
229 {
230 return instance->toAddon.addonInstance->GetPicture(*picture);
231 }
232
233 inline static const char *ADDON_GetName(const AddonInstance_VideoCodec* instance)
234 {
235 return instance->toAddon.addonInstance->GetName();
236 }
237
238 inline static void ADDON_Reset(const AddonInstance_VideoCodec* instance)
239 {
240 return instance->toAddon.addonInstance->Reset();
241 }
242
243 AddonInstance_VideoCodec* m_instanceData;
244 };
245 } // namespace addon
246} // namespace kodi
diff --git a/xbmc/addons/kodi-addon-dev-kit/include/kodi/addon-instance/Visualization.h b/xbmc/addons/kodi-addon-dev-kit/include/kodi/addon-instance/Visualization.h
deleted file mode 100644
index 4be785d..0000000
--- a/xbmc/addons/kodi-addon-dev-kit/include/kodi/addon-instance/Visualization.h
+++ /dev/null
@@ -1,789 +0,0 @@
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 "../gui/renderHelper.h"
18
19namespace kodi { namespace addon { class CInstanceVisualization; }}
20
21extern "C"
22{
23
24struct AddonInstance_Visualization;
25
26typedef enum VIS_ACTION : unsigned int /* internal */
27{
28 VIS_ACTION_NONE = 0,
29 VIS_ACTION_NEXT_PRESET,
30 VIS_ACTION_PREV_PRESET,
31 VIS_ACTION_LOAD_PRESET,
32 VIS_ACTION_RANDOM_PRESET,
33 VIS_ACTION_LOCK_PRESET,
34 VIS_ACTION_RATE_PRESET_PLUS,
35 VIS_ACTION_RATE_PRESET_MINUS,
36 VIS_ACTION_UPDATE_ALBUMART,
37 VIS_ACTION_UPDATE_TRACK
38} VIS_ACTION;
39
40struct VIS_INFO /* internal */
41{
42 bool bWantsFreq;
43 int iSyncDelay;
44};
45
46typedef struct AddonProps_Visualization /* internal */
47{
48 void *device;
49 int x;
50 int y;
51 int width;
52 int height;
53 float pixelRatio;
54 const char *name;
55 const char *presets;
56 const char *profile;
57} AddonProps_Visualization;
58
59typedef struct AddonToKodiFuncTable_Visualization /* internal */
60{
61 KODI_HANDLE kodiInstance;
62 void (__cdecl* transfer_preset) (void* kodiInstance, const char* preset);
63 void (__cdecl* clear_presets) (void* kodiInstance);
64} AddonToKodiFuncTable_Visualization;
65
66typedef struct KodiToAddonFuncTable_Visualization /* internal */
67{
68 kodi::addon::CInstanceVisualization* addonInstance;
69 bool (__cdecl* start)(const AddonInstance_Visualization* instance, int channels, int samples_per_sec, int bits_per_sample, const char* song_name);
70 void (__cdecl* stop)(const AddonInstance_Visualization* instance);
71 void (__cdecl* audio_data)(const AddonInstance_Visualization* instance, const float* audio_data, int audio_data_length, float *freq_data, int freq_data_length);
72 bool (__cdecl* is_dirty)(const AddonInstance_Visualization* instance);
73 void (__cdecl* render)(const AddonInstance_Visualization* instance);
74 void (__cdecl* get_info)(const AddonInstance_Visualization* instance, VIS_INFO *info);
75 bool (__cdecl* on_action)(const AddonInstance_Visualization* instance, VIS_ACTION action, const void *param);
76 unsigned int (__cdecl *get_presets)(const AddonInstance_Visualization* instance);
77 int (__cdecl *get_active_preset)(const AddonInstance_Visualization* instance);
78 bool (__cdecl* is_locked)(const AddonInstance_Visualization* instance);
79} KodiToAddonFuncTable_Visualization;
80
81typedef struct AddonInstance_Visualization /* internal */
82{
83 AddonProps_Visualization* props;
84 AddonToKodiFuncTable_Visualization* toKodi;
85 KodiToAddonFuncTable_Visualization* toAddon;
86} AddonInstance_Visualization;
87
88//============================================================================
89/// \defgroup cpp_kodi_addon_visualization_VisTrack class VisTrack
90/// \ingroup cpp_kodi_addon_visualization
91/// @brief **Visualization track information structure**
92///
93/// Called from kodi::addon::CInstanceVisualization::UpdateTrack() with the
94/// information of the currently-playing song.
95///
96//@{
97struct VisTrack
98{
99 /// @brief Title of the current song.
100 const char *title;
101
102 /// @brief Artist names, as a single string
103 const char *artist;
104
105 /// @brief Album that the current song is from.
106 const char *album;
107
108 /// @brief Album artist names, as a single string
109 const char *albumArtist;
110
111 /// @brief The genre name from the music tag, if present.
112 const char *genre;
113
114 /// @brief Comment of the current song stored in the ID tag info.
115 const char *comment;
116
117 /// @brief Lyrics of the current song, if available.
118 const char *lyrics;
119
120 const char *reserved1;
121 const char *reserved2;
122
123 /// @brief Track number of the current song.
124 int trackNumber;
125
126 /// @brief Disc number of the current song stored in the ID tag info.
127 int discNumber;
128
129 /// @brief Duration of the current song, in seconds.
130 int duration;
131
132 /// @brief Year that the current song was released.
133 int year;
134
135 /// @brief The user-defined rating of the current song.
136 int rating;
137
138 int reserved3;
139 int reserved4;
140};
141//@}
142//----------------------------------------------------------------------------
143
144} /* extern "C" */
145
146namespace kodi
147{
148namespace addon
149{
150
151 //============================================================================
152 ///
153 /// \addtogroup cpp_kodi_addon_visualization
154 /// @brief \cpp_class{ kodi::addon::CInstanceVisualization }
155 /// **Visualization add-on instance**
156 ///
157 /// [Music visualization](https://en.wikipedia.org/wiki/Music_visualization),
158 /// or music visualisation, is a feature in Kodi that generates animated
159 /// imagery based on a piece of music. The imagery is usually generated and
160 /// rendered in real time synchronized to the music.
161 ///
162 /// Visualization techniques range from simple ones (e.g., a simulation of an
163 /// oscilloscope display) to elaborate ones, which often include a plurality
164 /// of composited effects. The changes in the music's loudness and frequency
165 /// spectrum are among the properties used as input to the visualization.
166 ///
167 /// Include the header \ref Visualization.h "#include <kodi/addon-instance/Visualization.h>"
168 /// to use this class.
169 ///
170 /// This interface allows the creation of visualizations for Kodi, based upon
171 /// **DirectX** or/and **OpenGL** rendering with `C++` code.
172 ///
173 /// Additionally, there are several \ref cpp_kodi_addon_visualization_CB "other functions"
174 /// available in which the child class can ask about the current hardware,
175 /// including the device, display and several other parts.
176 ///
177 /// --------------------------------------------------------------------------
178 ///
179 ///
180 /// **Here is an example of the minimum required code to start a visualization:**
181 /// ~~~~~~~~~~~~~{.cpp}
182 /// #include <kodi/addon-instance/Visualization.h>
183 ///
184 /// class CMyVisualization : public kodi::addon::CAddonBase,
185 /// public kodi::addon::CInstanceVisualization
186 /// {
187 /// public:
188 /// CMyVisualization();
189 ///
190 /// bool Start(int channels, int samplesPerSec, int bitsPerSample, std::string songName) override;
191 /// void AudioData(const float* audioData, int audioDataLength, float* freqData, int freqDataLength) override;
192 /// void Render() override;
193 /// };
194 ///
195 /// CMyVisualization::CMyVisualization()
196 /// {
197 /// ...
198 /// }
199 ///
200 /// bool CMyVisualization::Start(int channels, int samplesPerSec, int bitsPerSample, std::string songName)
201 /// {
202 /// ...
203 /// return true;
204 /// }
205 ///
206 /// void CMyVisualization::AudioData(const float* audioData, int audioDataLength, float* freqData, int freqDataLength)
207 /// {
208 /// ...
209 /// }
210 ///
211 /// void CMyVisualization::Render()
212 /// {
213 /// ...
214 /// }
215 ///
216 /// ADDONCREATOR(CMyVisualization)
217 /// ~~~~~~~~~~~~~
218 ///
219 ///
220 /// --------------------------------------------------------------------------
221 ///
222 ///
223 /// **Here is another example where the visualization is used together with
224 /// other instance types:**
225 ///
226 /// ~~~~~~~~~~~~~{.cpp}
227 /// #include <kodi/addon-instance/Visualization.h>
228 ///
229 /// class CMyVisualization : public ::kodi::addon::CInstanceVisualization
230 /// {
231 /// public:
232 /// CMyVisualization(KODI_HANDLE instance);
233 ///
234 /// bool Start(int channels, int samplesPerSec, int bitsPerSample, std::string songName) override;
235 /// void AudioData(const float* audioData, int audioDataLength, float* freqData, int freqDataLength) override;
236 /// void Render() override;
237 /// };
238 ///
239 /// CMyVisualization::CMyVisualization(KODI_HANDLE instance)
240 /// : CInstanceVisualization(instance)
241 /// {
242 /// ...
243 /// }
244 ///
245 /// bool CMyVisualization::Start(int channels, int samplesPerSec, int bitsPerSample, std::string songName)
246 /// {
247 /// ...
248 /// return true;
249 /// }
250 ///
251 /// void CMyVisualization::AudioData(const float* audioData, int audioDataLength, float* freqData, int freqDataLength)
252 /// {
253 /// ...
254 /// }
255 ///
256 /// void CMyVisualization::Render()
257 /// {
258 /// ...
259 /// }
260 ///
261 ///
262 /// /*----------------------------------------------------------------------*/
263 ///
264 /// class CMyAddon : public ::kodi::addon::CAddonBase
265 /// {
266 /// public:
267 /// CMyAddon() { }
268 /// ADDON_STATUS CreateInstance(int instanceType,
269 /// std::string instanceID,
270 /// KODI_HANDLE instance,
271 /// KODI_HANDLE& addonInstance) override;
272 /// };
273 ///
274 /// /* If you use only one instance in your add-on, can be instanceType and
275 /// * instanceID ignored */
276 /// ADDON_STATUS CMyAddon::CreateInstance(int instanceType,
277 /// std::string instanceID,
278 /// KODI_HANDLE instance,
279 /// KODI_HANDLE& addonInstance)
280 /// {
281 /// if (instanceType == ADDON_INSTANCE_VISUALIZATION)
282 /// {
283 /// kodi::Log(ADDON_LOG_NOTICE, "Creating my Visualization");
284 /// addonInstance = new CMyVisualization(instance);
285 /// return ADDON_STATUS_OK;
286 /// }
287 /// else if (...)
288 /// {
289 /// ...
290 /// }
291 /// return ADDON_STATUS_UNKNOWN;
292 /// }
293 ///
294 /// ADDONCREATOR(CMyAddon)
295 /// ~~~~~~~~~~~~~
296 ///
297 /// The destruction of the example class `CMyVisualization` is called from
298 /// Kodi's header. Manually deleting the add-on instance is not required.
299 ///
300 //----------------------------------------------------------------------------
301 class ATTRIBUTE_HIDDEN CInstanceVisualization : public IAddonInstance
302 {
303 public:
304 //==========================================================================
305 ///
306 /// @ingroup cpp_kodi_addon_visualization
307 /// @brief Visualization class constructor
308 ///
309 /// Used by an add-on that only supports visualizations.
310 ///
311 CInstanceVisualization()
312 : IAddonInstance(ADDON_INSTANCE_VISUALIZATION,
313 GetKodiTypeVersion(ADDON_INSTANCE_VISUALIZATION))
314 {
315 if (CAddonBase::m_interface->globalSingleInstance != nullptr)
316 throw std::logic_error("kodi::addon::CInstanceVisualization: Cannot create multiple instances of add-on.");
317
318 SetAddonStruct(CAddonBase::m_interface->firstKodiInstance);
319 CAddonBase::m_interface->globalSingleInstance = this;
320 }
321 //--------------------------------------------------------------------------
322
323 //==========================================================================
324 ///
325 /// @ingroup cpp_kodi_addon_visualization
326 /// @brief Visualization class constructor used to support multiple instance
327 /// types
328 ///
329 /// @param[in] instance The instance value given to
330 /// <b>`kodi::addon::CAddonBase::CreateInstance(...)`</b>.
331 /// @param[in] kodiVersion [opt] Version used in Kodi for this instance, to
332 /// allow compatibility to older Kodi versions.
333 /// @note Recommended to set.
334 ///
335 /// @warning Only use `instance` from the CreateInstance call
336 ///
337 explicit CInstanceVisualization(KODI_HANDLE instance, const std::string& kodiVersion = "")
338 : IAddonInstance(ADDON_INSTANCE_VISUALIZATION,
339 !kodiVersion.empty() ? kodiVersion
340 : GetKodiTypeVersion(ADDON_INSTANCE_VISUALIZATION))
341 {
342 if (CAddonBase::m_interface->globalSingleInstance != nullptr)
343 throw std::logic_error("kodi::addon::CInstanceVisualization: Creation of multiple together with single instance way is not allowed!");
344
345 SetAddonStruct(instance);
346 }
347 //--------------------------------------------------------------------------
348
349 //==========================================================================
350 ///
351 /// @ingroup cpp_kodi_addon_visualization
352 /// @brief Destructor
353 ///
354 ~CInstanceVisualization() override = default;
355 //--------------------------------------------------------------------------
356
357 //==========================================================================
358 ///
359 /// @ingroup cpp_kodi_addon_visualization
360 /// @brief Used to notify the visualization that a new song has been started
361 ///
362 /// @param[in] channels Number of channels in the stream
363 /// @param[in] samplesPerSec Samples per second of stream
364 /// @param[in] bitsPerSample Number of bits in one sample
365 /// @param[in] songName The name of the currently-playing song
366 /// @return true if start successful done
367 ///
368 virtual bool Start(int channels, int samplesPerSec, int bitsPerSample, std::string songName) { return true; }
369 //--------------------------------------------------------------------------
370
371 //==========================================================================
372 ///
373 /// @ingroup cpp_kodi_addon_visualization
374 /// @brief Used to inform the visualization that the rendering control was
375 /// stopped
376 ///
377 virtual void Stop() {}
378 //--------------------------------------------------------------------------
379
380 //==========================================================================
381 ///
382 /// @ingroup cpp_kodi_addon_visualization
383 /// @brief Pass audio data to the visualization
384 ///
385 /// @param[in] audioData The raw audio data
386 /// @param[in] audioDataLength Length of the audioData array
387 /// @param[in] freqData The [FFT](https://en.wikipedia.org/wiki/Fast_Fourier_transform)
388 /// of the audio data
389 /// @param[in] freqDataLength Length of frequency data array
390 ///
391 /// Values **freqData** and **freqDataLength** are used if GetInfo() returns
392 /// true for the `wantsFreq` parameter. Otherwise, **freqData** is set to
393 /// `nullptr` and **freqDataLength** is `0`.
394 ///
395 virtual void AudioData(const float* audioData, int audioDataLength, float* freqData, int freqDataLength) {}
396 //--------------------------------------------------------------------------
397
398 //==========================================================================
399 ///
400 /// @ingroup cpp_kodi_addon_visualization
401 /// @brief Used to inform Kodi that the rendered region is dirty and need an
402 /// update
403 ///
404 /// @return True if dirty
405 ///
406 virtual bool IsDirty() { return true; }
407 //--------------------------------------------------------------------------
408
409 //==========================================================================
410 ///
411 /// @ingroup cpp_kodi_addon_visualization
412 /// @brief Used to indicate when the add-on should render
413 ///
414 virtual void Render() {}
415 //--------------------------------------------------------------------------
416
417 //==========================================================================
418 ///
419 /// @ingroup cpp_kodi_addon_visualization
420 /// @brief Used to get the number of buffers from the current visualization
421 ///
422 /// @param[out] wantsFreq Indicates whether the add-on wants FFT
423 /// data. If set to true, the **freqData**
424 /// and **freqDataLength** parameters of
425 /// AudioData() are used
426 /// @param[out] syncDelay The number of buffers to delay before
427 /// calling AudioData()
428 ///
429 /// @note If this function is not implemented, it will default to
430 /// `wantsFreq` = false and `syncDelay` = 0.
431 ///
432 virtual void GetInfo(bool& wantsFreq, int& syncDelay) { wantsFreq = false; syncDelay = 0; }
433 //--------------------------------------------------------------------------
434
435 //==========================================================================
436 ///
437 /// @ingroup cpp_kodi_addon_visualization
438 /// @brief Used to get a list of visualization presets the user can select
439 /// from
440 ///
441 /// @param[out] presets The vector list containing the names of
442 /// presets that the user can select
443 /// @return Return true if successful, or false if
444 /// there are no presets to choose from
445 ///
446 virtual bool GetPresets(std::vector<std::string>& presets) { return false; }
447 //--------------------------------------------------------------------------
448
449 //==========================================================================
450 ///
451 /// @ingroup cpp_kodi_addon_visualization
452 /// @brief Get the index of the current preset
453 ///
454 /// @return Index number of the current preset
455 ///
456 virtual int GetActivePreset() { return -1; }
457 //--------------------------------------------------------------------------
458
459 //==========================================================================
460 ///
461 /// @ingroup cpp_kodi_addon_visualization
462 /// @brief Check if the add-on is locked to the current preset
463 ///
464 /// @return True if locked to the current preset
465 ///
466 virtual bool IsLocked() { return false; }
467 //--------------------------------------------------------------------------
468
469 //==========================================================================
470 ///
471 /// @ingroup cpp_kodi_addon_visualization
472 /// @brief Load the previous visualization preset
473 ///
474 /// @return Return true if the previous preset was loaded
475 virtual bool PrevPreset() { return false; }
476 //--------------------------------------------------------------------------
477
478 //==========================================================================
479 ///
480 /// @ingroup cpp_kodi_addon_visualization
481 /// @brief Load the next visualization preset
482 ///
483 /// @return Return true if the next preset was loaded
484 virtual bool NextPreset() { return false; }
485 //--------------------------------------------------------------------------
486
487 //==========================================================================
488 ///
489 /// @ingroup cpp_kodi_addon_visualization
490 /// @brief Load a visualization preset
491 ///
492 /// This function is called after a new preset is selected.
493 ///
494 /// @param[in] select Preset index to use
495 /// @return Return true if the preset is loaded
496 virtual bool LoadPreset(int select) { return false; }
497 //--------------------------------------------------------------------------
498
499 //==========================================================================
500 ///
501 /// @ingroup cpp_kodi_addon_visualization
502 /// @brief Switch to a new random preset
503 ///
504 /// @return Return true if a random preset was loaded
505 virtual bool RandomPreset() { return false; }
506 //--------------------------------------------------------------------------
507
508 //==========================================================================
509 ///
510 /// @ingroup cpp_kodi_addon_visualization
511 /// @brief Lock the current visualization preset, preventing it from changing
512 ///
513 /// @param[in] lockUnlock If set to true, the preset should be locked
514 /// @return Return true if the current preset is locked
515 virtual bool LockPreset(bool lockUnlock) { return false; }
516 //--------------------------------------------------------------------------
517
518 //==========================================================================
519 ///
520 /// @ingroup cpp_kodi_addon_visualization
521 /// @brief Used to increase/decrease the visualization preset rating
522 ///
523 /// @param[in] plusMinus If set to true the rating is increased, otherwise
524 /// decreased
525 /// @return Return true if the rating is modified
526 virtual bool RatePreset(bool plusMinus) { return false; }
527 //--------------------------------------------------------------------------
528
529 //==========================================================================
530 ///
531 /// @ingroup cpp_kodi_addon_visualization
532 /// @brief Inform the visualization of the current album art image
533 ///
534 /// @param[in] albumart Path to the current album art image
535 /// @return Return true if the image is used
536 virtual bool UpdateAlbumart(std::string albumart) { return false; }
537 //--------------------------------------------------------------------------
538
539 //==========================================================================
540 ///
541 /// @ingroup cpp_kodi_addon_visualization
542 /// @brief Inform the visualization of the current track's tag information
543 ///
544 /// @param[in] track Visualization track information structure
545 /// @return Return true if the track information is used
546 virtual bool UpdateTrack(const VisTrack &track) { return false; }
547
548 //==========================================================================
549 ///
550 /// \defgroup cpp_kodi_addon_visualization_CB Information functions
551 /// \ingroup cpp_kodi_addon_visualization
552 /// @brief **To get info about the device, display and several other parts**
553 ///
554 //@{
555
556 //==========================================================================
557 ///
558 /// @ingroup cpp_kodi_addon_visualization_CB
559 /// @brief To transfer available presets on addon
560 ///
561 /// Used if @ref GetPresets not possible to use, e.g. where available presets
562 /// are only known during @ref Start call.
563 ///
564 /// @param[in] presets List to store available presets.
565 ///
566 /// @note The function should only be called once, if possible
567 ///
568 inline void TransferPresets(const std::vector<std::string>& presets)
569 {
570 m_instanceData->toKodi->clear_presets(m_instanceData->toKodi->kodiInstance);
571 for (auto it : presets)
572 m_instanceData->toKodi->transfer_preset(m_instanceData->toKodi->kodiInstance, it.c_str());
573 }
574 //--------------------------------------------------------------------------
575
576 //==========================================================================
577 ///
578 /// @ingroup cpp_kodi_addon_visualization_CB
579 /// @brief Device that represents the display adapter
580 ///
581 /// @return A pointer to the used device
582 ///
583 /// @note This is only available on **DirectX**, It us unused (`nullptr`) on
584 /// **OpenGL**
585 ///
586 inline void* Device() { return m_instanceData->props->device; }
587 //--------------------------------------------------------------------------
588
589 //==========================================================================
590 ///
591 /// @ingroup cpp_kodi_addon_visualization_CB
592 /// @brief Returns the X position of the rendering window
593 ///
594 /// @return The X position, in pixels
595 ///
596 inline int X() { return m_instanceData->props->x; }
597 //--------------------------------------------------------------------------
598
599 //==========================================================================
600 ///
601 /// @ingroup cpp_kodi_addon_visualization_CB
602 /// @brief Returns the Y position of the rendering window
603 ///
604 /// @return The Y position, in pixels
605 ///
606 inline int Y() { return m_instanceData->props->y; }
607 //--------------------------------------------------------------------------
608
609 //==========================================================================
610 ///
611 /// @ingroup cpp_kodi_addon_visualization_CB
612 /// @brief Returns the width of the rendering window
613 ///
614 /// @return The width, in pixels
615 ///
616 inline int Width() { return m_instanceData->props->width; }
617 //--------------------------------------------------------------------------
618
619 //==========================================================================
620 ///
621 /// @ingroup cpp_kodi_addon_visualization_CB
622 /// @brief Returns the height of the rendering window
623 ///
624 /// @return The height, in pixels
625 ///
626 inline int Height() { return m_instanceData->props->height; }
627 //--------------------------------------------------------------------------
628
629 //==========================================================================
630 ///
631 /// @ingroup cpp_kodi_addon_visualization_CB
632 /// @brief Pixel aspect ratio (often abbreviated PAR) is a ratio that
633 /// describes how the width of a pixel compares to the height of that pixel.
634 ///
635 /// @return The pixel aspect ratio used by the display
636 ///
637 inline float PixelRatio() { return m_instanceData->props->pixelRatio; }
638 //--------------------------------------------------------------------------
639
640 //==========================================================================
641 ///
642 /// @ingroup cpp_kodi_addon_visualization_CB
643 /// @brief Used to get the name of the add-on defined in `addon.xml`
644 ///
645 /// @return The add-on name
646 ///
647 inline std::string Name() { return m_instanceData->props->name; }
648 //--------------------------------------------------------------------------
649
650 //==========================================================================
651 ///
652 /// @ingroup cpp_kodi_addon_visualization_CB
653 /// @brief Used to get the full path where the add-on is installed
654 ///
655 /// @return The add-on installation path
656 ///
657 inline std::string Presets() { return m_instanceData->props->presets; }
658 //--------------------------------------------------------------------------
659
660 //==========================================================================
661 ///
662 /// @ingroup cpp_kodi_addon_visualization_CB
663 /// @brief Used to get the full path to the add-on's user profile
664 ///
665 /// @note The trailing folder (consisting of the add-on's ID) is not created
666 /// by default. If it is needed, you must call kodi::vfs::CreateDirectory()
667 /// to create the folder.
668 ///
669 /// @return Path to the user profile
670 ///
671 inline std::string Profile() { return m_instanceData->props->profile; }
672 //--------------------------------------------------------------------------
673 //@}
674
675 private:
676 void SetAddonStruct(KODI_HANDLE instance)
677 {
678 if (instance == nullptr)
679 throw std::logic_error("kodi::addon::CInstanceVisualization: Null pointer instance passed.");
680
681 m_instanceData = static_cast<AddonInstance_Visualization*>(instance);
682 m_instanceData->toAddon->addonInstance = this;
683 m_instanceData->toAddon->start = ADDON_Start;
684 m_instanceData->toAddon->stop = ADDON_Stop;
685 m_instanceData->toAddon->audio_data = ADDON_AudioData;
686 m_instanceData->toAddon->is_dirty = ADDON_IsDirty;
687 m_instanceData->toAddon->render = ADDON_Render;
688 m_instanceData->toAddon->get_info = ADDON_GetInfo;
689 m_instanceData->toAddon->on_action = ADDON_OnAction;
690 m_instanceData->toAddon->get_presets = ADDON_GetPresets;
691 m_instanceData->toAddon->get_active_preset = ADDON_GetActivePreset;
692 m_instanceData->toAddon->is_locked = ADDON_IsLocked;
693 }
694
695 inline static bool ADDON_Start(const AddonInstance_Visualization* addon, int channels, int samplesPerSec, int bitsPerSample, const char* songName)
696 {
697 addon->toAddon->addonInstance->m_renderHelper = kodi::gui::GetRenderHelper();
698 return addon->toAddon->addonInstance->Start(channels, samplesPerSec, bitsPerSample, songName);
699 }
700
701 inline static void ADDON_Stop(const AddonInstance_Visualization* addon)
702 {
703 addon->toAddon->addonInstance->Stop();
704 addon->toAddon->addonInstance->m_renderHelper = nullptr;
705 }
706
707 inline static void ADDON_AudioData(const AddonInstance_Visualization* addon, const float* audioData, int audioDataLength, float *freqData, int freqDataLength)
708 {
709 addon->toAddon->addonInstance->AudioData(audioData, audioDataLength, freqData, freqDataLength);
710 }
711
712 inline static bool ADDON_IsDirty(const AddonInstance_Visualization* addon)
713 {
714 return addon->toAddon->addonInstance->IsDirty();
715 }
716
717 inline static void ADDON_Render(const AddonInstance_Visualization* addon)
718 {
719 if (!addon->toAddon->addonInstance->m_renderHelper)
720 return;
721 addon->toAddon->addonInstance->m_renderHelper->Begin();
722 addon->toAddon->addonInstance->Render();
723 addon->toAddon->addonInstance->m_renderHelper->End();
724 }
725
726 inline static void ADDON_GetInfo(const AddonInstance_Visualization* addon, VIS_INFO *info)
727 {
728 addon->toAddon->addonInstance->GetInfo(info->bWantsFreq, info->iSyncDelay);
729 }
730
731 inline static bool ADDON_OnAction(const AddonInstance_Visualization* addon, VIS_ACTION action, const void *param)
732 {
733 switch (action)
734 {
735 case VIS_ACTION_NEXT_PRESET:
736 return addon->toAddon->addonInstance->NextPreset();
737 case VIS_ACTION_PREV_PRESET:
738 return addon->toAddon->addonInstance->PrevPreset();
739 case VIS_ACTION_LOAD_PRESET:
740 return addon->toAddon->addonInstance->LoadPreset(*static_cast<const int*>(param));
741 case VIS_ACTION_RANDOM_PRESET:
742 return addon->toAddon->addonInstance->RandomPreset();
743 case VIS_ACTION_LOCK_PRESET:
744 addon->toAddon->addonInstance->m_presetLockedByUser = !addon->toAddon->addonInstance->m_presetLockedByUser;
745 return addon->toAddon->addonInstance->LockPreset(addon->toAddon->addonInstance->m_presetLockedByUser);
746 case VIS_ACTION_RATE_PRESET_PLUS:
747 return addon->toAddon->addonInstance->RatePreset(true);
748 case VIS_ACTION_RATE_PRESET_MINUS:
749 return addon->toAddon->addonInstance->RatePreset(false);
750 case VIS_ACTION_UPDATE_ALBUMART:
751 return addon->toAddon->addonInstance->UpdateAlbumart(static_cast<const char*>(param));
752 case VIS_ACTION_UPDATE_TRACK:
753 return addon->toAddon->addonInstance->UpdateTrack(*static_cast<const VisTrack*>(param));
754 case VIS_ACTION_NONE:
755 default:
756 break;
757 }
758 return false;
759 }
760
761 inline static unsigned int ADDON_GetPresets(const AddonInstance_Visualization* addon)
762 {
763 std::vector<std::string> presets;
764 if (addon->toAddon->addonInstance->GetPresets(presets))
765 {
766 for (auto it : presets)
767 addon->toAddon->addonInstance->m_instanceData->toKodi->transfer_preset(addon->toKodi->kodiInstance, it.c_str());
768 }
769
770 return static_cast<unsigned int>(presets.size());
771 }
772
773 inline static int ADDON_GetActivePreset(const AddonInstance_Visualization* addon)
774 {
775 return addon->toAddon->addonInstance->GetActivePreset();
776 }
777
778 inline static bool ADDON_IsLocked(const AddonInstance_Visualization* addon)
779 {
780 return addon->toAddon->addonInstance->IsLocked();
781 }
782
783 std::shared_ptr<kodi::gui::IRenderHelper> m_renderHelper;
784 bool m_presetLockedByUser = false;
785 AddonInstance_Visualization* m_instanceData;
786 };
787
788} /* namespace addon */
789} /* namespace kodi */
diff --git a/xbmc/addons/kodi-addon-dev-kit/include/kodi/addon-instance/pvr/CMakeLists.txt b/xbmc/addons/kodi-addon-dev-kit/include/kodi/addon-instance/pvr/CMakeLists.txt
deleted file mode 100644
index 946849e..0000000
--- a/xbmc/addons/kodi-addon-dev-kit/include/kodi/addon-instance/pvr/CMakeLists.txt
+++ /dev/null
@@ -1,13 +0,0 @@
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-addon-dev-kit_include_kodi_addon-instance_pvr)
13endif()
diff --git a/xbmc/addons/kodi-addon-dev-kit/include/kodi/addon-instance/pvr/ChannelGroups.h b/xbmc/addons/kodi-addon-dev-kit/include/kodi/addon-instance/pvr/ChannelGroups.h
deleted file mode 100644
index 17995bb..0000000
--- a/xbmc/addons/kodi-addon-dev-kit/include/kodi/addon-instance/pvr/ChannelGroups.h
+++ /dev/null
@@ -1,271 +0,0 @@
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-addon-dev-kit/include/kodi/addon-instance/pvr/Channels.h b/xbmc/addons/kodi-addon-dev-kit/include/kodi/addon-instance/pvr/Channels.h
deleted file mode 100644
index 9c2f5d2..0000000
--- a/xbmc/addons/kodi-addon-dev-kit/include/kodi/addon-instance/pvr/Channels.h
+++ /dev/null
@@ -1,518 +0,0 @@
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-addon-dev-kit/include/kodi/addon-instance/pvr/EDL.h b/xbmc/addons/kodi-addon-dev-kit/include/kodi/addon-instance/pvr/EDL.h
deleted file mode 100644
index 34c7c41..0000000
--- a/xbmc/addons/kodi-addon-dev-kit/include/kodi/addon-instance/pvr/EDL.h
+++ /dev/null
@@ -1,90 +0,0 @@
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-addon-dev-kit/include/kodi/addon-instance/pvr/EPG.h b/xbmc/addons/kodi-addon-dev-kit/include/kodi/addon-instance/pvr/EPG.h
deleted file mode 100644
index e1fc04f..0000000
--- a/xbmc/addons/kodi-addon-dev-kit/include/kodi/addon-instance/pvr/EPG.h
+++ /dev/null
@@ -1,500 +0,0 @@
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-addon-dev-kit/include/kodi/addon-instance/pvr/General.h b/xbmc/addons/kodi-addon-dev-kit/include/kodi/addon-instance/pvr/General.h
deleted file mode 100644
index c7977c2..0000000
--- a/xbmc/addons/kodi-addon-dev-kit/include/kodi/addon-instance/pvr/General.h
+++ /dev/null
@@ -1,511 +0,0 @@
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-addon-dev-kit/include/kodi/addon-instance/pvr/MenuHook.h b/xbmc/addons/kodi-addon-dev-kit/include/kodi/addon-instance/pvr/MenuHook.h
deleted file mode 100644
index 053a4d5..0000000
--- a/xbmc/addons/kodi-addon-dev-kit/include/kodi/addon-instance/pvr/MenuHook.h
+++ /dev/null
@@ -1,130 +0,0 @@
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-addon-dev-kit/include/kodi/addon-instance/pvr/Recordings.h b/xbmc/addons/kodi-addon-dev-kit/include/kodi/addon-instance/pvr/Recordings.h
deleted file mode 100644
index 24ecf11..0000000
--- a/xbmc/addons/kodi-addon-dev-kit/include/kodi/addon-instance/pvr/Recordings.h
+++ /dev/null
@@ -1,520 +0,0 @@
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-addon-dev-kit/include/kodi/addon-instance/pvr/Stream.h b/xbmc/addons/kodi-addon-dev-kit/include/kodi/addon-instance/pvr/Stream.h
deleted file mode 100644
index 5613947..0000000
--- a/xbmc/addons/kodi-addon-dev-kit/include/kodi/addon-instance/pvr/Stream.h
+++ /dev/null
@@ -1,330 +0,0 @@
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-addon-dev-kit/include/kodi/addon-instance/pvr/Timers.h b/xbmc/addons/kodi-addon-dev-kit/include/kodi/addon-instance/pvr/Timers.h
deleted file mode 100644
index 6e05e55..0000000
--- a/xbmc/addons/kodi-addon-dev-kit/include/kodi/addon-instance/pvr/Timers.h
+++ /dev/null
@@ -1,896 +0,0 @@
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 */