summaryrefslogtreecommitdiffstats
path: root/xbmc/addons/kodi-dev-kit/include/kodi/addon-instance
diff options
context:
space:
mode:
authormanuel <manuel@mausz.at>2021-03-04 23:36:40 +0100
committermanuel <manuel@mausz.at>2021-03-04 23:36:40 +0100
commit3cb8aa05f8cee9e860cf83531682ff0ed4af6a4f (patch)
tree921f4829b32126f80f9113c124f2e14c0ebce8d9 /xbmc/addons/kodi-dev-kit/include/kodi/addon-instance
parentbe933ef2241d79558f91796cc5b3a161f72ebf9c (diff)
downloadkodi-pvr-build-Matrix.tar.gz
kodi-pvr-build-Matrix.tar.bz2
kodi-pvr-build-Matrix.zip
sync with upstreamMatrix
Diffstat (limited to 'xbmc/addons/kodi-dev-kit/include/kodi/addon-instance')
-rw-r--r--xbmc/addons/kodi-dev-kit/include/kodi/addon-instance/AudioDecoder.h8
-rw-r--r--xbmc/addons/kodi-dev-kit/include/kodi/addon-instance/Inputstream.h2302
-rw-r--r--xbmc/addons/kodi-dev-kit/include/kodi/addon-instance/PVR.h80
-rw-r--r--xbmc/addons/kodi-dev-kit/include/kodi/addon-instance/Screensaver.h2
-rw-r--r--xbmc/addons/kodi-dev-kit/include/kodi/addon-instance/VFS.h4
-rw-r--r--xbmc/addons/kodi-dev-kit/include/kodi/addon-instance/VideoCodec.h651
-rw-r--r--xbmc/addons/kodi-dev-kit/include/kodi/addon-instance/Visualization.h4
-rw-r--r--xbmc/addons/kodi-dev-kit/include/kodi/addon-instance/inputstream/CMakeLists.txt8
-rw-r--r--xbmc/addons/kodi-dev-kit/include/kodi/addon-instance/inputstream/DemuxPacket.h12
-rw-r--r--xbmc/addons/kodi-dev-kit/include/kodi/addon-instance/inputstream/StreamCodec.h11
-rw-r--r--xbmc/addons/kodi-dev-kit/include/kodi/addon-instance/inputstream/StreamConstants.h11
-rw-r--r--xbmc/addons/kodi-dev-kit/include/kodi/addon-instance/inputstream/StreamCrypto.h99
-rw-r--r--xbmc/addons/kodi-dev-kit/include/kodi/addon-instance/inputstream/TimingConstants.h59
-rw-r--r--xbmc/addons/kodi-dev-kit/include/kodi/addon-instance/peripheral/PeripheralUtils.h2
-rw-r--r--xbmc/addons/kodi-dev-kit/include/kodi/addon-instance/pvr/Stream.h2
15 files changed, 2407 insertions, 848 deletions
diff --git a/xbmc/addons/kodi-dev-kit/include/kodi/addon-instance/AudioDecoder.h b/xbmc/addons/kodi-dev-kit/include/kodi/addon-instance/AudioDecoder.h
index a6bea7d..747225f 100644
--- a/xbmc/addons/kodi-dev-kit/include/kodi/addon-instance/AudioDecoder.h
+++ b/xbmc/addons/kodi-dev-kit/include/kodi/addon-instance/AudioDecoder.h
@@ -241,7 +241,7 @@ private:
241 241
242//============================================================================== 242//==============================================================================
243/// 243///
244/// \addtogroup cpp_kodi_addon_audiodecoder 244/// @addtogroup cpp_kodi_addon_audiodecoder
245/// @brief \cpp_class{ kodi::addon::CInstanceAudioDecoder } 245/// @brief \cpp_class{ kodi::addon::CInstanceAudioDecoder }
246/// **Audio decoder add-on instance** 246/// **Audio decoder add-on instance**
247/// 247///
@@ -289,9 +289,11 @@ private:
289/// |:------------------------------|---------------------------------------- 289/// |:------------------------------|----------------------------------------
290/// | <b>`point`</b> | Addon type specification<br>At all addon types and for this kind always <b>"kodi.audiodecoder"</b>. 290/// | <b>`point`</b> | Addon type specification<br>At all addon types and for this kind always <b>"kodi.audiodecoder"</b>.
291/// | <b>`library_@PLATFORM@`</b> | Sets the used library name, which is automatically set by cmake at addon build. 291/// | <b>`library_@PLATFORM@`</b> | Sets the used library name, which is automatically set by cmake at addon build.
292/// | <b>`name`</b> | The name of the decoder used in Kodi for display.
293/// | <b>`extension`</b> | The file extensions / styles supported by this addon. 292/// | <b>`extension`</b> | The file extensions / styles supported by this addon.
294/// | <b>`tags`</b> | Boolean to point out that addon can bring own information to replayed file, if <b>`false`</b> only the file name is used as info.<br>If <b>`true`</b>, \ref CInstanceAudioDecoder::ReadTag is used and must be implemented. 293/// | <b>`mimetype`</b> | A stream URL mimetype where can be used to force to this addon.
294/// | <b>`name`</b> | The name of the decoder used in Kodi for display.
295/// | <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.
296/// | <b>`tracks`</b> | Boolean to in inform one file can contains several different streams.
295/// 297///
296/// -------------------------------------------------------------------------- 298/// --------------------------------------------------------------------------
297/// 299///
diff --git a/xbmc/addons/kodi-dev-kit/include/kodi/addon-instance/Inputstream.h b/xbmc/addons/kodi-dev-kit/include/kodi/addon-instance/Inputstream.h
index 396b92e..c4c7aca 100644
--- a/xbmc/addons/kodi-dev-kit/include/kodi/addon-instance/Inputstream.h
+++ b/xbmc/addons/kodi-dev-kit/include/kodi/addon-instance/Inputstream.h
@@ -8,682 +8,1757 @@
8 8
9#pragma once 9#pragma once
10 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" 11#include "../AddonBase.h"
17#include "../StreamCodec.h" 12#include "../c-api/addon-instance/inputstream.h"
18#include "../StreamCrypto.h" 13#include "inputstream/StreamCodec.h"
14#include "inputstream/StreamConstants.h"
15#include "inputstream/StreamCrypto.h"
16#include "inputstream/TimingConstants.h"
19 17
20#ifdef BUILD_KODI_ADDON 18#ifdef __cplusplus
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 19
28//Increment this level always if you add features which can lead to compile failures in the addon 20#include <map>
29#define INPUTSTREAM_VERSION_LEVEL 2
30 21
31#define INPUTSTREAM_MAX_STREAM_COUNT 256 22namespace kodi
32#define INPUTSTREAM_MAX_STRING_NAME_SIZE 256 23{
33#define INPUTSTREAM_MAX_STRING_CODEC_SIZE 32 24namespace addon
34#define INPUTSTREAM_MAX_STRING_LANGUAGE_SIZE 64 25{
35 26
36#ifdef __cplusplus 27//¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯
37extern "C" 28// "C++" Doxygen group set for the definitions
29//{{{
30
31//==============================================================================
32/// @defgroup cpp_kodi_addon_inputstream_Defs Definitions, structures and enumerators
33/// @ingroup cpp_kodi_addon_inputstream
34/// @brief **Inputstream add-on instance definition values**\n
35/// All inputstream functions associated data structures.
36///
37/// Used to exchange the available options between Kodi and addon.\n
38/// The groups described here correspond to the groups of functions on inputstream
39/// instance class.
40///
41/// In addition, some of the things described here are also used on the
42/// @ref cpp_kodi_addon_videocodec "video codec" addon.
43///
44
45//##############################################################################
46/// @defgroup cpp_kodi_addon_inputstream_Defs_Interface 1. Interface
47/// @ingroup cpp_kodi_addon_inputstream_Defs
48/// @brief **Inputstream add-on general variables**\n
49/// Used to exchange the available options between Kodi and addon.
50///
51
52//##############################################################################
53/// @defgroup cpp_kodi_addon_inputstream_Defs_StreamConstants 2. Stream constants
54/// @ingroup cpp_kodi_addon_inputstream_Defs
55/// @brief **Used to exchange any additional data between the caller and processor.**\n
56/// This includes the standardized values, in addition, an addon can also use
57/// its own special uses to be exchanged in the same way.
58///
59/// These values can be used by other addons (e.g. video addon) or stream files
60/// to select the respective inputstream addon and to transfer additional values.
61///
62/// ----------------------------------------------------------------------------
63///
64/// **Example:**
65///
66/// This example use the @ref STREAM_PROPERTY_INPUTSTREAM on a <b>`*.strm`</b>
67/// file to select needed addon and a additional value where related to selected
68/// addon itself.
69///
70/// ~~~~~~~~~~~~
71/// #KODIPROP:inputstream=inputstream.adaptive
72/// #KODIPROP:inputstream.adaptive.manifest_type=mpd
73/// http://rdmedia.bbc.co.uk/dash/ondemand/testcard/1/client_manifest-events-multilang.mpd
74/// ~~~~~~~~~~~~
75///
76/// These are then given to Kodi and the respectively selected addon by means of
77/// his @ref kodi::addon::CInstanceInputStream::Open "Open" call
78/// in @ref kodi::addon::InputstreamProperty::GetProperties.
79///
80/// The largest possible amount of these <b>`#KODIPROP`</b> values is defined
81/// with @ref STREAM_MAX_PROPERTY_COUNT.
82///
83
84//##############################################################################
85/// @defgroup cpp_kodi_addon_inputstream_Defs_TimingConstants 3. Stream timing
86/// @ingroup cpp_kodi_addon_inputstream_Defs
87/// @brief **Timebase and timestamp definitions.**\n
88/// Used to exchange the available options between Kodi and addon.
89///
90
91//##############################################################################
92/// @defgroup cpp_kodi_addon_inputstream_Defs_StreamCodec 4. Stream codec
93/// @ingroup cpp_kodi_addon_inputstream_Defs
94/// @brief **Inputstream codec control**\n
95/// Used to manage stream codec data.
96///
97
98//##############################################################################
99/// @defgroup cpp_kodi_addon_inputstream_Defs_StreamEncryption 5. Stream encryption
100/// @ingroup cpp_kodi_addon_inputstream_Defs
101/// @brief **Inputstream encryption control**\n
102/// Used to manage encrypted streams within addon.
103///
104
105//}}}
106//______________________________________________________________________________
107
108class CInstanceInputStream;
109
110//==============================================================================
111/// @defgroup cpp_kodi_addon_inputstream_Defs_InputstreamProperty class InputstreamProperty
112/// @ingroup cpp_kodi_addon_inputstream_Defs_Interface
113/// @brief <b>URL and Data of key/value pairs passed to addon on @ref kodi::addon::CInstanceInputStream::Open "Open".</b>\n
114/// This is used to have the necessary data of the stream to be opened.
115///
116/// ----------------------------------------------------------------------------
117///
118/// @copydetails cpp_kodi_addon_inputstream_Defs_InputstreamProperty_Help
119///
120/// @warning This data are only given from Kodi to addon and can't be used
121/// on other places on addon.
122///
123///@{
124class ATTRIBUTE_HIDDEN InputstreamProperty
125 : public CStructHdl<InputstreamProperty, INPUTSTREAM_PROPERTY>
38{ 126{
39#endif /* __cplusplus */ 127 /*! \cond PRIVATE */
128 friend class CInstanceInputStream;
129 /*! \endcond */
40 130
41 /*! 131public:
42 * @brief InputStream add-on capabilities. All capabilities are set to "false" as default. 132 /// @defgroup cpp_kodi_addon_inputstream_Defs_InputstreamProperty_Help Value Help
43 */ 133 /// @ingroup cpp_kodi_addon_inputstream_Defs_InputstreamProperty
44 struct INPUTSTREAM_CAPABILITIES 134 ///
135 /// <b>The following table contains values that can be set with @ref cpp_kodi_addon_inputstream_Defs_InputstreamProperty :</b>
136 /// | Name | Type | Get call
137 /// |------|------|----------
138 /// | **Stream URL** | `std::string` | @ref InputstreamProperty::GetURL "GetURL"
139 /// | **Mime type** | `std::string` | @ref InputstreamProperty::GetMimeType "GetMimeType"
140 /// | **Available amount of properties** | `unsigned int` | @ref InputstreamProperty::GetPropertiesAmount "GetPropertiesAmount"
141 /// | **List of properties** | `std::map<std::string, std::string>` | @ref InputstreamProperty::GetProperties "GetProperties"
142 /// | **Get addon library folder** | `std::string` | @ref InputstreamProperty::GetLibFolder "GetLibFolder"
143 /// | **Get addon profile/user folder** | `std::string` | @ref InputstreamProperty::GetProfileFolder "GetProfileFolder"
144
145 /// @addtogroup cpp_kodi_addon_inputstream_Defs_InputstreamProperty
146 ///@{
147
148 /// @brief Stream URL to open.
149 std::string GetURL() const { return m_cStructure->m_strURL; }
150
151 /// @brief Stream mime type.
152 std::string GetMimeType() const { return m_cStructure->m_mimeType; }
153
154 /// @brief Amount of available properties.
155 unsigned int GetPropertiesAmount() const
45 { 156 {
46 enum MASKTYPE : uint32_t 157 return m_cStructure->m_nCountInfoValues;
158 }
159
160 /// @brief List of available properties-
161 const std::map<std::string, std::string> GetProperties() const
162 {
163 std::map<std::string, std::string> props;
164 for (unsigned int i = 0; i < m_cStructure->m_nCountInfoValues; ++i)
47 { 165 {
48 /// supports interface IDemux 166 props.emplace(m_cStructure->m_ListItemProperties[i].m_strKey,
49 SUPPORTS_IDEMUX = (1 << 0), 167 m_cStructure->m_ListItemProperties[i].m_strValue);
168 }
169 return props;
170 }
171
172 /// @brief Get addon library folder.
173 ///
174 /// @note As alternative can also @ref kodi::GetAddonPath used.
175 std::string GetLibFolder() const { return m_cStructure->m_libFolder; }
176
177 /// @brief Get addon profile/user folder.
178 ///
179 /// @note As alternative can also @ref kodi::GetBaseUserPath used.
180 std::string GetProfileFolder() const { return m_cStructure->m_profileFolder; }
181
182 ///@}
183
184private:
185 InputstreamProperty() = delete;
186 InputstreamProperty(const InputstreamProperty& stream) = delete;
187 InputstreamProperty(const INPUTSTREAM_PROPERTY* stream) : CStructHdl(stream) {}
188 InputstreamProperty(INPUTSTREAM_PROPERTY* stream) : CStructHdl(stream) {}
189};
190///@}
191//------------------------------------------------------------------------------
192
193//==============================================================================
194/// @defgroup cpp_kodi_addon_inputstream_Defs_Interface_InputstreamCapabilities class InputstreamCapabilities
195/// @ingroup cpp_kodi_addon_inputstream_Defs_Interface
196/// @brief **InputStream add-on capabilities. All capabilities are set to "false" as default.**\n
197/// Asked to addon on @ref kodi::addon::CInstanceInputStream::GetCapabilities "GetCapabilities".
198///
199/// ----------------------------------------------------------------------------
200///
201/// @copydetails cpp_kodi_addon_inputstream_Defs_Interface_InputstreamCapabilities_Help
202///
203///@{
204class ATTRIBUTE_HIDDEN InputstreamCapabilities
205 : public CStructHdl<InputstreamCapabilities, INPUTSTREAM_CAPABILITIES>
206{
207 /*! \cond PRIVATE */
208 friend class CInstanceInputStream;
209 /*! \endcond */
50 210
51 /// supports interface IPosTime 211public:
52 SUPPORTS_IPOSTIME = (1 << 1), 212 /*! \cond PRIVATE */
213 InputstreamCapabilities() = default;
214 InputstreamCapabilities(const InputstreamCapabilities& stream) : CStructHdl(stream) {}
215 /*! \endcond */
53 216
54 /// supports interface IDisplayTime 217 /// @defgroup cpp_kodi_addon_inputstream_Defs_Interface_InputstreamCapabilities_Help Value Help
55 SUPPORTS_IDISPLAYTIME = (1 << 2), 218 /// @ingroup cpp_kodi_addon_inputstream_Defs_Interface_InputstreamCapabilities
219 ///
220 /// <b>The following table contains values that can be set with @ref cpp_kodi_addon_inputstream_Defs_Interface_InputstreamCapabilities :</b>
221 /// | Name | Type | Set call | Get call
222 /// |------|------|----------|----------
223 /// | **Capabilities bit mask** | `uint32_t` | @ref InputstreamCapabilities::SetMask "SetMask" | @ref InputstreamCapabilities::GetMask "GetMask"
56 224
57 /// supports seek 225 /// @addtogroup cpp_kodi_addon_inputstream_Defs_Interface_InputstreamCapabilities
58 SUPPORTS_SEEK = (1 << 3), 226 ///@{
59 227
60 /// supports pause 228 /// @brief Set of supported capabilities.
61 SUPPORTS_PAUSE = (1 << 4), 229 void SetMask(uint32_t mask) const { m_cStructure->m_mask = mask; }
62 230
63 /// supports interface ITime 231 /// @brief Get of supported capabilities.
64 SUPPORTS_ITIME = (1 << 5), 232 uint32_t GetMask() const { return m_cStructure->m_mask; }
65 233
66 /// supports interface IChapter 234 ///@}
67 SUPPORTS_ICHAPTER = (1 << 6),
68 };
69 235
70 /// set of supported capabilities 236private:
71 uint32_t m_mask; 237 InputstreamCapabilities(const INPUTSTREAM_CAPABILITIES* stream) : CStructHdl(stream) {}
72 }; 238 InputstreamCapabilities(INPUTSTREAM_CAPABILITIES* stream) : CStructHdl(stream) {}
239};
240///@}
241//------------------------------------------------------------------------------
242
243//==============================================================================
244/// @defgroup cpp_kodi_addon_inputstream_Defs_Interface_InputstreamMasteringMetadata class InputstreamMasteringMetadata
245/// @ingroup cpp_kodi_addon_inputstream_Defs_Interface
246/// @brief **Mastering metadata.**\n
247/// Describes the metadata for [HDR10](https://en.wikipedia.org/wiki/High-dynamic-range_video).
248///
249/// Used when video is compressed using [High Efficiency Video Coding (HEVC)](https://en.wikipedia.org/wiki/High_Efficiency_Video_Coding).
250/// This is used to describe the capabilities of the display used to master the
251/// content and the luminance values of the content.
252///
253/// Used on @ref kodi::addon::InputstreamInfo::SetMasteringMetadata and @ref kodi::addon::InputstreamInfo::GetMasteringMetadata.
254///
255/// ----------------------------------------------------------------------------
256///
257/// @copydetails cpp_kodi_addon_inputstream_Defs_Interface_InputstreamMasteringMetadata_Help
258///
259///@{
260class ATTRIBUTE_HIDDEN InputstreamMasteringMetadata
261 : public CStructHdl<InputstreamMasteringMetadata, INPUTSTREAM_MASTERING_METADATA>
262{
263 /*! \cond PRIVATE */
264 friend class CInstanceInputStream;
265 friend class InputstreamInfo;
266 /*! \endcond */
73 267
74 /*! 268public:
75 * @brief structure of key/value pairs passed to addon on Open() 269 /*! \cond PRIVATE */
76 */ 270 InputstreamMasteringMetadata() = default;
77 struct INPUTSTREAM 271 InputstreamMasteringMetadata(const InputstreamMasteringMetadata& stream) : CStructHdl(stream) {}
272 /*! \endcond */
273
274 /// @defgroup cpp_kodi_addon_inputstream_Defs_Interface_InputstreamMasteringMetadata_Help Value Help
275 /// @ingroup cpp_kodi_addon_inputstream_Defs_Interface_InputstreamMasteringMetadata
276 ///
277 /// <b>The following table contains values that can be set with @ref cpp_kodi_addon_inputstream_Defs_Interface_InputstreamMasteringMetadata :</b>
278 /// | Name | Type | Set call | Get call
279 /// |------|------|----------|----------
280 /// | **Chromaticity X coordinates of the red** | `double` | @ref InputstreamMasteringMetadata::SetPrimaryR_ChromaticityX "SetPrimaryR_ChromaticityX" | @ref InputstreamMasteringMetadata::GetPrimaryR_ChromaticityX "GetPrimaryR_ChromaticityX"
281 /// | **Chromaticity Y coordinates of the red** | `double` | @ref InputstreamMasteringMetadata::SetPrimaryR_ChromaticityY "SetPrimaryR_ChromaticityY" | @ref InputstreamMasteringMetadata::GetPrimaryR_ChromaticityY "GetPrimaryR_ChromaticityY"
282 /// | **Chromaticity X coordinates of the green** | `double` | @ref InputstreamMasteringMetadata::SetPrimaryG_ChromaticityX "SetPrimaryG_ChromaticityX" | @ref InputstreamMasteringMetadata::GetPrimaryG_ChromaticityX "GetPrimaryG_ChromaticityX"
283 /// | **Chromaticity Y coordinates of the green** | `double` | @ref InputstreamMasteringMetadata::SetPrimaryG_ChromaticityY "SetPrimaryG_ChromaticityY" | @ref InputstreamMasteringMetadata::GetPrimaryG_ChromaticityY "GetPrimaryG_ChromaticityY"
284 /// | **Chromaticity X coordinates of the blue** | `double` | @ref InputstreamMasteringMetadata::SetPrimaryB_ChromaticityX "SetPrimaryB_ChromaticityX" | @ref InputstreamMasteringMetadata::GetPrimaryB_ChromaticityX "GetPrimaryB_ChromaticityX"
285 /// | **Chromaticity Y coordinates of the blue** | `double` | @ref InputstreamMasteringMetadata::SetPrimaryB_ChromaticityY "SetPrimaryB_ChromaticityY" | @ref InputstreamMasteringMetadata::GetPrimaryB_ChromaticityY "GetPrimaryB_ChromaticityY"
286 /// | **Chromaticity X coordinates of the white point** | `double` | @ref InputstreamMasteringMetadata::SetWhitePoint_ChromaticityX "SetWhitePoint_ChromaticityX" | @ref InputstreamMasteringMetadata::GetWhitePoint_ChromaticityX "GetWhitePoint_ChromaticityX"
287 /// | **Chromaticity Y coordinates of the white point** | `double` | @ref InputstreamMasteringMetadata::SetWhitePoint_ChromaticityY "SetWhitePoint_ChromaticityY" | @ref InputstreamMasteringMetadata::GetWhitePoint_ChromaticityY "GetWhitePoint_ChromaticityY"
288 /// | **Maximum number of bits of the display** | `double` | @ref InputstreamMasteringMetadata::SetLuminanceMax "SetLuminanceMax" | @ref InputstreamMasteringMetadata::GetLuminanceMax "GetLuminanceMax"
289 /// | **Minimum number of bits of the display** | `double` | @ref InputstreamMasteringMetadata::SetLuminanceMin "SetLuminanceMin" | @ref InputstreamMasteringMetadata::GetLuminanceMin "GetLuminanceMin"
290
291 /// @addtogroup cpp_kodi_addon_inputstream_Defs_Interface_InputstreamMasteringMetadata
292 ///@{
293
294 /// @brief Metadata class compare.
295 ///
296 /// To compare the metadata with another one.
297 ///
298 /// @return true if they equal, false otherwise
299 bool operator==(const kodi::addon::InputstreamMasteringMetadata& right) const
78 { 300 {
79 const char* m_strURL; 301 if (memcmp(m_cStructure, right.m_cStructure, sizeof(INPUTSTREAM_MASTERING_METADATA)) == 0)
80 const char* m_mimeType; 302 return true;
303 return false;
304 }
81 305
82 unsigned int m_nCountInfoValues; 306 /// @brief Set the chromaticity coordinates of the red value in the
83 struct LISTITEMPROPERTY 307 /// [CIE1931](https://en.wikipedia.org/wiki/CIE_1931_color_space) color space.
84 { 308 ///
85 const char* m_strKey; 309 /// X coordinate. The values are normalized to 50,000.
86 const char* m_strValue; 310 void SetPrimaryR_ChromaticityX(double value) { m_cStructure->primary_r_chromaticity_x = value; }
87 } m_ListItemProperties[STREAM_MAX_PROPERTY_COUNT]; 311
88 312 /// @brief Get the chromaticity X coordinates of the red value.
89 const char* m_libFolder; 313 double GetPrimaryR_ChromaticityX() { return m_cStructure->primary_r_chromaticity_x; }
90 const char* m_profileFolder; 314
91 }; 315 /// @brief The chromaticity coordinates of the red value in the
92 316 /// [CIE1931](https://en.wikipedia.org/wiki/CIE_1931_color_space) color space.
93 /*! 317 ///
94 * @brief Array of stream IDs 318 /// Y coordinate. The values are normalized to 50,000.
95 */ 319 void SetPrimaryR_ChromaticityY(double value) { m_cStructure->primary_r_chromaticity_y = value; }
96 struct INPUTSTREAM_IDS 320
97 { 321 /// @brief Get the chromaticity Y coordinates of the red value.
98 unsigned int m_streamCount; 322 double GetPrimaryR_ChromaticityY() { return m_cStructure->primary_r_chromaticity_y; }
99 unsigned int m_streamIds[INPUTSTREAM_MAX_STREAM_COUNT]; 323
100 }; 324 /// @brief Set the chromaticity coordinates of the green value in the
101 325 /// [CIE1931](https://en.wikipedia.org/wiki/CIE_1931_color_space) color space.
102 /*! 326 ///
103 * @brief MASTERING Metadata 327 /// X coordinate. The values are normalized to 50,000.
104 */ 328 void SetPrimaryG_ChromaticityX(double value) { m_cStructure->primary_g_chromaticity_x = value; }
105 struct INPUTSTREAM_MASTERING_METADATA 329
106 { 330 /// @brief Get the chromaticity X coordinates of the green value.
107 double primary_r_chromaticity_x; 331 double GetPrimaryG_ChromaticityX() { return m_cStructure->primary_g_chromaticity_x; }
108 double primary_r_chromaticity_y; 332
109 double primary_g_chromaticity_x; 333 /// @brief Set the chromaticity coordinates of the green value in the
110 double primary_g_chromaticity_y; 334 /// [CIE1931](https://en.wikipedia.org/wiki/CIE_1931_color_space) color space.
111 double primary_b_chromaticity_x; 335 ///
112 double primary_b_chromaticity_y; 336 /// Y coordinate. The values are normalized to 50,000.
113 double white_point_chromaticity_x; 337 void SetPrimaryG_ChromaticityY(double value) { m_cStructure->primary_g_chromaticity_y = value; }
114 double white_point_chromaticity_y; 338
115 double luminance_max; 339 /// @brief Get the chromaticity Y coordinates of the green value.
116 double luminance_min; 340 double GetPrimaryG_ChromaticityY() { return m_cStructure->primary_g_chromaticity_y; }
117 }; 341
118 342 /// @brief The chromaticity coordinates of the blue value in the
119 /*! 343 /// [CIE1931](https://en.wikipedia.org/wiki/CIE_1931_color_space) color space.
120 * @brief CONTENTLIGHT Metadata 344 ///
121 */ 345 /// X coordinate. The values are normalized to 50,000.
122 struct INPUTSTREAM_CONTENTLIGHT_METADATA 346 void SetPrimaryB_ChromaticityX(double value) { m_cStructure->primary_b_chromaticity_x = value; }
123 { 347
124 uint64_t max_cll; 348 /// @brief Get the chromaticity X coordinates of the blue value.
125 uint64_t max_fall; 349 double GetPrimaryB_ChromaticityX() { return m_cStructure->primary_b_chromaticity_x; }
126 }; 350
127 351 /// @brief The chromaticity coordinates of the blue value in the
128 /*! 352 /// [CIE1931](https://en.wikipedia.org/wiki/CIE_1931_color_space) color space.
129 * @brief stream properties 353 ///
130 */ 354 /// Y coordinate. The values are normalized to 50,000.
131 struct INPUTSTREAM_INFO 355 void SetPrimaryB_ChromaticityY(double value) { m_cStructure->primary_b_chromaticity_y = value; }
132 { 356
133 enum STREAM_TYPE 357 /// @brief Get the chromaticity Y coordinates of the blue value.
134 { 358 double GetPrimaryB_ChromaticityY() { return m_cStructure->primary_b_chromaticity_y; }
135 TYPE_NONE = 0, 359
136 TYPE_VIDEO, 360 /// @brief Set the chromaticity coordinates of the white point in the
137 TYPE_AUDIO, 361 /// [CIE1931](https://en.wikipedia.org/wiki/CIE_1931_color_space) color space.
138 TYPE_SUBTITLE, 362 ///
139 TYPE_TELETEXT, 363 /// X coordinate. The values are normalized to 50,000.
140 TYPE_RDS, 364 void SetWhitePoint_ChromaticityX(double value)
141 } m_streamType; 365 {
142 366 m_cStructure->white_point_chromaticity_x = value;
143 enum Codec_FEATURES : uint32_t 367 }
144 {
145 FEATURE_DECODE = 1
146 };
147 uint32_t m_features;
148 368
149 enum STREAM_FLAGS : uint32_t 369 /// @brief Get the chromaticity X coordinates of the white point
150 { 370 double GetWhitePoint_ChromaticityX() { return m_cStructure->white_point_chromaticity_x; }
151 FLAG_NONE = 0x0000, 371
152 FLAG_DEFAULT = 0x0001, 372 /// @brief Set the chromaticity coordinates of the white point in the
153 FLAG_DUB = 0x0002, 373 /// [CIE1931](https://en.wikipedia.org/wiki/CIE_1931_color_space) color space.
154 FLAG_ORIGINAL = 0x0004, 374 ///
155 FLAG_COMMENT = 0x0008, 375 /// Y coordinate. The values are normalized to 50,000.
156 FLAG_LYRICS = 0x0010, 376 void SetWhitePoint_ChromaticityY(double value)
157 FLAG_KARAOKE = 0x0020, 377 {
158 FLAG_FORCED = 0x0040, 378 m_cStructure->white_point_chromaticity_y = value;
159 FLAG_HEARING_IMPAIRED = 0x0080, 379 }
160 FLAG_VISUAL_IMPAIRED = 0x0100, 380
161 }; 381 /// @brief Get the chromaticity Y coordinates of the white point.
162 382 double GetWhitePoint_ChromaticityY() { return m_cStructure->white_point_chromaticity_y; }
163 // Keep in sync with AVColorSpace 383
164 enum COLORSPACE 384 /// @brief Set the maximum number of bits of the display used to master the content.
165 { 385 ///
166 COLORSPACE_RGB = 0, 386 /// Values are normalized to 10,000.
167 COLORSPACE_BT709 = 1, 387 void SetLuminanceMax(double value) { m_cStructure->luminance_max = value; }
168 COLORSPACE_UNSPECIFIED = 2, 388
169 COLORSPACE_UNKNOWN = COLORSPACE_UNSPECIFIED, // compatibility 389 /// @brief Get the maximum number of bits of the display.
170 COLORSPACE_RESERVED = 3, 390 double GetLuminanceMax() { return m_cStructure->luminance_max; }
171 COLORSPACE_FCC = 4, 391
172 COLORSPACE_BT470BG = 5, 392 /// @brief Set the minimum number of bits of the display used to master the content.
173 COLORSPACE_SMPTE170M = 6, 393 ///
174 COLORSPACE_SMPTE240M = 7, 394 /// Values are normalized to 10,000.
175 COLORSPACE_YCGCO = 8, 395 void SetLuminanceMin(double value) { m_cStructure->luminance_min = value; }
176 COLORSPACE_YCOCG = COLORSPACE_YCGCO, 396
177 COLORSPACE_BT2020_NCL = 9, 397 /// @brief Get the minimum number of bits of the display.
178 COLORSPACE_BT2020_CL = 10, 398 double GetLuminanceMin() { return m_cStructure->luminance_min; }
179 COLORSPACE_SMPTE2085 = 11, 399
180 COLORSPACE_CHROMA_DERIVED_NCL = 12, 400 ///@}
181 COLORSPACE_CHROMA_DERIVED_CL = 13, 401
182 COLORSPACE_ICTCP = 14, 402private:
183 COLORSPACE_MAX 403 InputstreamMasteringMetadata(const INPUTSTREAM_MASTERING_METADATA* stream) : CStructHdl(stream) {}
184 }; 404 InputstreamMasteringMetadata(INPUTSTREAM_MASTERING_METADATA* stream) : CStructHdl(stream) {}
185 405};
186 // Keep in sync with AVColorPrimaries 406///@}
187 enum COLORPRIMARIES : int32_t 407//------------------------------------------------------------------------------
188 { 408
189 COLORPRIMARY_RESERVED0 = 0, 409//==============================================================================
190 COLORPRIMARY_BT709 = 1, 410/// @defgroup cpp_kodi_addon_inputstream_Defs_Interface_InputstreamContentlightMetadata class InputstreamContentlightMetadata
191 COLORPRIMARY_UNSPECIFIED = 2, 411/// @ingroup cpp_kodi_addon_inputstream_Defs_Interface
192 COLORPRIMARY_RESERVED = 3, 412/// @brief **Contentlight metadata**\n
193 COLORPRIMARY_BT470M = 4, 413/// Describes the metadata for [HDR10](https://en.wikipedia.org/wiki/High-dynamic-range_video).
194 COLORPRIMARY_BT470BG = 5, 414/// See also @ref cpp_kodi_addon_inputstream_Defs_Interface_InputstreamMasteringMetadata "InputstreamMasteringMetadata".
195 COLORPRIMARY_SMPTE170M = 6, 415///
196 COLORPRIMARY_SMPTE240M = 7, 416/// Used on @ref kodi::addon::InputstreamInfo::SetContentLightMetadata and @ref kodi::addon::InputstreamInfo::GetContentLightMetadata.
197 COLORPRIMARY_FILM = 8, 417///
198 COLORPRIMARY_BT2020 = 9, 418/// ----------------------------------------------------------------------------
199 COLORPRIMARY_SMPTE428 = 10, 419///
200 COLORPRIMARY_SMPTEST428_1 = COLORPRIMARY_SMPTE428, 420/// @copydetails cpp_kodi_addon_inputstream_Defs_Interface_InputstreamContentlightMetadata_Help
201 COLORPRIMARY_SMPTE431 = 11, 421///
202 COLORPRIMARY_SMPTE432 = 12, 422///@{
203 COLORPRIMARY_JEDEC_P22 = 22, 423class ATTRIBUTE_HIDDEN InputstreamContentlightMetadata
204 COLORPRIMARY_MAX 424 : public CStructHdl<InputstreamContentlightMetadata, INPUTSTREAM_CONTENTLIGHT_METADATA>
205 }; 425{
206 426 /*! \cond PRIVATE */
207 // Keep in sync with AVColorRange 427 friend class CInstanceInputStream;
208 enum COLORRANGE 428 friend class InputstreamInfo;
429 /*! \endcond */
430
431public:
432 /*! \cond PRIVATE */
433 InputstreamContentlightMetadata() = default;
434 InputstreamContentlightMetadata(const InputstreamContentlightMetadata& stream)
435 : CStructHdl(stream)
436 {
437 }
438 /*! \endcond */
439
440 /// @defgroup cpp_kodi_addon_inputstream_Defs_Interface_InputstreamContentlightMetadata_Help Value Help
441 /// @ingroup cpp_kodi_addon_inputstream_Defs_Interface_InputstreamContentlightMetadata
442 ///
443 /// <b>The following table contains values that can be set with @ref cpp_kodi_addon_inputstream_Defs_Interface_InputstreamContentlightMetadata :</b>
444 /// | Name | Type | Set call | Get call
445 /// |------|------|----------|----------
446 /// | **Maximum content light level** | `double` | @ref InputstreamContentlightMetadata::SetMaxCll "SetMaxCll" | @ref InputstreamContentlightMetadata::GetMaxCll "GetMaxCll"
447 /// | **Maximum frame average light level** | `double` | @ref InputstreamContentlightMetadata::SetMaxFall "SetMaxFall" | @ref InputstreamContentlightMetadata::GetMaxFall "GetMaxFall"
448
449 /// @addtogroup cpp_kodi_addon_inputstream_Defs_Interface_InputstreamContentlightMetadata
450 ///@{
451
452 /// @brief Metadata class compare.
453 ///
454 /// To compare the metadata with another one.
455 ///
456 /// @return true if they equal, false otherwise
457 bool operator==(const kodi::addon::InputstreamContentlightMetadata& right) const
458 {
459 if (memcmp(m_cStructure, right.m_cStructure, sizeof(INPUTSTREAM_CONTENTLIGHT_METADATA)) == 0)
460 return true;
461 return false;
462 }
463
464 /// @brief Set the maximum content light level (MaxCLL).
465 ///
466 /// This is the bit value corresponding to the brightest pixel used anywhere
467 /// in the content.
468 void SetMaxCll(uint64_t value) { m_cStructure->max_cll = value; }
469
470 /// @brief Get the maximum content light level (MaxCLL).
471 uint64_t GetMaxCll() { return m_cStructure->max_cll; }
472
473 /// @brief Set the maximum frame average light level (MaxFALL).
474 ///
475 /// This is the bit value corresponding to the average luminance of the frame
476 /// which has the brightest average luminance anywhere in the content.
477 void SetMaxFall(uint64_t value) { m_cStructure->max_fall = value; }
478
479 /// @brief Get the maximum frame average light level (MaxFALL).
480 uint64_t GetMaxFall() { return m_cStructure->max_fall; }
481
482 ///@}
483
484private:
485 InputstreamContentlightMetadata(const INPUTSTREAM_CONTENTLIGHT_METADATA* stream)
486 : CStructHdl(stream)
487 {
488 }
489 InputstreamContentlightMetadata(INPUTSTREAM_CONTENTLIGHT_METADATA* stream) : CStructHdl(stream) {}
490};
491///@}
492//------------------------------------------------------------------------------
493
494//==============================================================================
495/// @defgroup cpp_kodi_addon_inputstream_Defs_Interface_InputstreamInfo class InputstreamInfo
496/// @ingroup cpp_kodi_addon_inputstream_Defs_Interface
497/// @brief **Inputstream add-on stream info**\n
498/// This is used to give Kodi the associated and necessary data for an open stream.
499///
500/// Used on @ref kodi::addon::CInstanceInputStream::GetStream().
501///
502/// ----------------------------------------------------------------------------
503///
504/// @copydetails cpp_kodi_addon_inputstream_Defs_Interface_InputstreamInfo_Help
505///
506///@{
507class ATTRIBUTE_HIDDEN InputstreamInfo : public CStructHdl<InputstreamInfo, INPUTSTREAM_INFO>
508{
509 /*! \cond PRIVATE */
510 friend class CInstanceInputStream;
511 /*! \endcond */
512
513public:
514 /*! \cond PRIVATE */
515 InputstreamInfo() = default;
516 InputstreamInfo(const InputstreamInfo& stream) : CStructHdl(stream)
517 {
518 SetCryptoSession(stream.GetCryptoSession());
519 CopyExtraData();
520 }
521 /*! \endcond */
522
523 /// @defgroup cpp_kodi_addon_inputstream_Defs_Interface_InputstreamInfo_Help Value Help
524 /// @ingroup cpp_kodi_addon_inputstream_Defs_Interface_InputstreamInfo
525 ///
526 /// <b>The following table contains values that can be set with @ref cpp_kodi_addon_inputstream_Defs_Interface_InputstreamInfo :</b>
527 /// | Name | Type used | Required | Set call | Get call
528 /// |------|-----------|----------|----------|---------
529 /// | **Stream type** | all | yes | @ref InputstreamInfo::SetStreamType "SetStreamType" | @ref InputstreamInfo::GetStreamType "GetStreamType"
530 /// | **Feature flags** | all | yes | @ref InputstreamInfo::SetFeatures "SetFeatures" | @ref InputstreamInfo::GetFeatures "GetFeatures"
531 /// | **Flags** | all | yes | @ref InputstreamInfo::SetFlags "SetFlags" | @ref InputstreamInfo::GetFlags "GetFlags"
532 /// | **Name** | all | no | @ref InputstreamInfo::SetName "SetName" | @ref InputstreamInfo::GetName "GetName"
533 /// | **Codec name** | all | yes | @ref InputstreamInfo::SetCodecName "SetCodecName" | @ref InputstreamInfo::GetCodecName "GetCodecName"
534 /// | **Codec internal name** | all | no | @ref InputstreamInfo::SetCodecInternalName "SetCodecInternalName" | @ref InputstreamInfo::GetCodecInternalName "GetCodecInternalName"
535 /// | **Codec Profile** | all | no | @ref InputstreamInfo::SetCodecProfile "SetCodecProfile" | @ref InputstreamInfo::GetCodecProfile "GetCodecProfile"
536 /// | **Physical index** | all | yes | @ref InputstreamInfo::SetPhysicalIndex "SetPhysicalIndex" | @ref InputstreamInfo::GetPhysicalIndex "GetPhysicalIndex"
537 /// | **Extra data** | Subtitle / all | Type related required | @ref InputstreamInfo::SetExtraData "SetExtraData" | @ref InputstreamInfo::GetExtraData "GetExtraData"
538 /// | **RFC 5646 language code** | all | no | @ref InputstreamInfo::SetLanguage "SetLanguage" | @ref InputstreamInfo::GetLanguage "GetLanguage"
539 /// | **FPS scale** | Video | Type related required | @ref InputstreamInfo::SetFpsScale "SetFpsScale" | @ref InputstreamInfo::GetFpsScale "GetFpsScale"
540 /// | **FPS rate** | Video | Type related required | @ref InputstreamInfo::SetFpsRate "SetFpsRate" | @ref InputstreamInfo::GetFpsRate "GetFpsRate"
541 /// | **Height** | Video | Type related required | @ref InputstreamInfo::SetHeight "SetHeight" | @ref InputstreamInfo::GetHeight "GetHeight"
542 /// | **Width** | Video | Type related required | @ref InputstreamInfo::SetWidth "SetWidth" | @ref InputstreamInfo::GetWidth "GetWidth"
543 /// | **Aspect** | Video | Type related required | @ref InputstreamInfo::SetAspect "SetAspect" | @ref InputstreamInfo::GetAspect "GetAspect"
544 /// | **Channel quantity** | Audio | Type related required | @ref InputstreamInfo::SetChannels "SetChannels" | @ref InputstreamInfo::GetChannels "GetChannels"
545 /// | **Sample rate** | Audio | Type related required | @ref InputstreamInfo::SetSampleRate "SetSampleRate" | @ref InputstreamInfo::GetSampleRate "GetSampleRate"
546 /// | **Bit rate** | Audio | Type related required | @ref InputstreamInfo::SetBitRate "SetBitRate" | @ref InputstreamInfo::GetBitRate "GetBitRate"
547 /// | **Bits per sample** | Audio | Type related required | @ref InputstreamInfo::SetBitsPerSample "SetBitsPerSample" | @ref InputstreamInfo::GetBitsPerSample "GetBitsPerSample"
548 /// | **Block align** | | no | @ref InputstreamInfo::SetBlockAlign "SetBlockAlign" | @ref InputstreamInfo::GetBlockAlign "GetBlockAlign"
549 /// | **Crypto session info** | | no | @ref InputstreamInfo::SetCryptoSession "SetCryptoSession" | @ref InputstreamInfo::GetCryptoSession "GetCryptoSession"
550 /// | **Four CC code** | | no | @ref InputstreamInfo::SetCodecFourCC "SetCodecFourCC" | @ref InputstreamInfo::GetCodecFourCC "GetCodecFourCC"
551 /// | **Color space** | | no | @ref InputstreamInfo::SetColorSpace "SetColorSpace" | @ref InputstreamInfo::GetColorSpace "GetColorSpace"
552 /// | **Color range** | | no | @ref InputstreamInfo::SetColorRange "SetColorRange" | @ref InputstreamInfo::GetColorRange "GetColorRange"
553 /// | **Color primaries** | | no | @ref InputstreamInfo::SetColorPrimaries "SetColorPrimaries" | @ref InputstreamInfo::GetColorPrimaries "GetColorPrimaries"
554 /// | **Color transfer characteristic** | | no | @ref InputstreamInfo::SetColorTransferCharacteristic "SetColorTransferCharacteristic" | @ref InputstreamInfo::GetColorTransferCharacteristic "GetColorTransferCharacteristic"
555 /// | **Mastering metadata** | | no | @ref InputstreamInfo::SetMasteringMetadata "SetMasteringMetadata" | @ref InputstreamInfo::GetMasteringMetadata "GetMasteringMetadata"
556 /// | **Content light metadata** | | no | @ref InputstreamInfo::SetContentLightMetadata "SetContentLightMetadata" | @ref InputstreamInfo::GetContentLightMetadata "GetContentLightMetadata"
557 ///
558
559 /// @addtogroup cpp_kodi_addon_inputstream_Defs_Interface_InputstreamInfo
560 ///@{
561
562 /// @brief Set the wanted stream type.
563 ///
564 /// @param[in] streamType By @ref INPUTSTREAM_TYPE defined type
565 void SetStreamType(INPUTSTREAM_TYPE streamType) { m_cStructure->m_streamType = streamType; }
566
567 /// @brief To get with @ref SetStreamType changed values.
568 INPUTSTREAM_TYPE GetStreamType() const { return m_cStructure->m_streamType; }
569
570 /// @brief Set special supported feature flags of inputstream.
571 ///
572 /// @param[in] features By @ref INPUTSTREAM_CODEC_FEATURES defined type
573 void SetFeatures(uint32_t features) { m_cStructure->m_features = features; }
574
575 /// @brief To get with @ref SetFeatures changed values.
576 uint32_t GetFeatures() const { return m_cStructure->m_features; }
577
578 /// @brief Set supported flags of inputstream.
579 ///
580 /// @param[in] flags The on @ref INPUTSTREAM_FLAGS defined flags to set
581 void SetFlags(uint32_t flags) { m_cStructure->m_flags = flags; }
582
583 /// @brief To get with @ref SetFeatures changed values.
584 uint32_t GetFlags() const { return m_cStructure->m_flags; }
585
586 /// @brief (optional) Name of the stream, leave empty for default handling.
587 ///
588 /// @param[in] name Stream name
589 void SetName(const std::string& name)
590 {
591 strncpy(m_cStructure->m_name, name.c_str(), INPUTSTREAM_MAX_STRING_NAME_SIZE);
592 }
593
594 /// @brief To get with @ref SetName changed values.
595 std::string GetName() const { return m_cStructure->m_name; }
596
597 /// @brief (required) Name of codec according to ffmpeg.
598 ///
599 /// See https://github.com/FFmpeg/FFmpeg/blob/master/libavcodec/codec_desc.c about
600 /// available names.
601 ///
602 /// @remark On @ref INPUTSTREAM_TYPE_TELETEXT and @ref INPUTSTREAM_TYPE_RDS
603 /// this can be ignored and leaved empty.
604 ///
605 /// @param[in] codeName Codec name
606 void SetCodecName(const std::string& codecName)
607 {
608 strncpy(m_cStructure->m_codecName, codecName.c_str(), INPUTSTREAM_MAX_STRING_CODEC_SIZE);
609 }
610
611 /// @brief To get with @ref SetCodecName changed values.
612 std::string GetCodecName() const { return m_cStructure->m_codecName; }
613
614 /// @brief (optional) Internal name of codec (selectionstream info).
615 ///
616 /// @param[in] codecName Internal codec name
617 void SetCodecInternalName(const std::string& codecName)
618 {
619 strncpy(m_cStructure->m_codecInternalName, codecName.c_str(),
620 INPUTSTREAM_MAX_STRING_CODEC_SIZE);
621 }
622
623 /// @brief To get with @ref SetCodecInternalName changed values.
624 std::string GetCodecInternalName() const { return m_cStructure->m_codecInternalName; }
625
626 /// @brief (optional) The profile of the codec.
627 ///
628 /// @param[in] codecProfile Values with @ref STREAMCODEC_PROFILE to use
629 void SetCodecProfile(STREAMCODEC_PROFILE codecProfile)
630 {
631 m_cStructure->m_codecProfile = codecProfile;
632 }
633
634 /// @brief To get with @ref SetCodecProfile changed values.
635 STREAMCODEC_PROFILE GetCodecProfile() const { return m_cStructure->m_codecProfile; }
636
637 /// @brief (required) Physical index.
638 ///
639 /// @param[in] id Index identifier
640 void SetPhysicalIndex(unsigned int id) { m_cStructure->m_pID = id; }
641
642 /// @brief To get with @ref SetPhysicalIndex changed values.
643 unsigned int GetPhysicalIndex() const { return m_cStructure->m_pID; }
644
645 /// @brief Additional data where can needed on streams.
646 ///
647 /// @param[in] extraData List with memory of extra data
648 void SetExtraData(const std::vector<uint8_t>& extraData)
649 {
650 m_extraData = extraData;
651 m_cStructure->m_ExtraData = m_extraData.data();
652 m_cStructure->m_ExtraSize = m_extraData.size();
653 }
654
655 /// @brief Additional data where can needed on streams.
656 ///
657 /// @param[in] extraData Pointer with memory of extra data
658 /// @param[in] extraSize Size to store
659 void SetExtraData(const uint8_t* extraData, size_t extraSize)
660 {
661 m_extraData.clear();
662 if (extraData && extraSize > 0)
209 { 663 {
210 COLORRANGE_UNKNOWN = 0, 664 for (size_t i = 0; i < extraSize; ++i)
211 COLORRANGE_LIMITED, 665 m_extraData.emplace_back(extraData[i]);
212 COLORRANGE_FULLRANGE, 666 }
213 COLORRANGE_MAX 667
214 }; 668 m_cStructure->m_ExtraData = m_extraData.data();
215 669 m_cStructure->m_ExtraSize = m_extraData.size();
216 // keep in sync with AVColorTransferCharacteristic 670 }
217 enum COLORTRC : int32_t 671
672 /// @brief To get with @ref SetExtraData changed values.
673 const std::vector<uint8_t>& GetExtraData() { return m_extraData; }
674
675 /// @brief To get size with @ref SetExtraData changed values.
676 size_t GetExtraDataSize() { return m_extraData.size(); }
677
678 /// @brief Compare extra data from outside with class
679 ///
680 /// @param[in] extraData Pointer with memory of extra data for compare
681 /// @param[in] extraSize Size to compare
682 /// @return true if they equal, false otherwise
683 bool CompareExtraData(const uint8_t* extraData, size_t extraSize) const
684 {
685 if (!extraData || m_extraData.size() != extraSize)
686 return false;
687 for (size_t i = 0; i < extraSize; ++i)
218 { 688 {
219 COLORTRC_RESERVED0 = 0, 689 if (m_extraData[i] != extraData[i])
220 COLORTRC_BT709 = 1, 690 return false;
221 COLORTRC_UNSPECIFIED = 2, 691 }
222 COLORTRC_RESERVED = 3, 692 return true;
223 COLORTRC_GAMMA22 = 4, 693 }
224 COLORTRC_GAMMA28 = 5,
225 COLORTRC_SMPTE170M = 6,
226 COLORTRC_SMPTE240M = 7,
227 COLORTRC_LINEAR = 8,
228 COLORTRC_LOG = 9,
229 COLORTRC_LOG_SQRT = 10,
230 COLORTRC_IEC61966_2_4 = 11,
231 COLORTRC_BT1361_ECG = 12,
232 COLORTRC_IEC61966_2_1 = 13,
233 COLORTRC_BT2020_10 = 14,
234 COLORTRC_BT2020_12 = 15,
235 COLORTRC_SMPTE2084 = 16,
236 COLORTRC_SMPTEST2084 = COLORTRC_SMPTE2084,
237 COLORTRC_SMPTE428 = 17,
238 COLORTRC_SMPTEST428_1 = COLORTRC_SMPTE428,
239 COLORTRC_ARIB_STD_B67 = 18,
240 COLORTRC_MAX
241 };
242 694
243 uint32_t m_flags; 695 /// @brief Clear additional data.
696 void ClearExtraData()
697 {
698 m_extraData.clear();
699 m_cStructure->m_ExtraData = m_extraData.data();
700 m_cStructure->m_ExtraSize = m_extraData.size();
701 }
244 702
245 //! @brief (optional) name of the stream, \0 for default handling 703 /// @brief RFC 5646 language code (empty string if undefined).
246 char m_name[INPUTSTREAM_MAX_STRING_NAME_SIZE]; 704 ///
705 /// @param[in] language The language to set
706 void SetLanguage(const std::string& language)
707 {
708 strncpy(m_cStructure->m_language, language.c_str(), INPUTSTREAM_MAX_STRING_LANGUAGE_SIZE);
709 }
247 710
248 //! @brief (required) name of codec according to ffmpeg 711 /// @brief To get with @ref SetLanguage changed values.
249 char m_codecName[INPUTSTREAM_MAX_STRING_CODEC_SIZE]; 712 std::string GetLanguage() const { return m_cStructure->m_language; }
250 713
251 //! @brief (optional) internal name of codec (selectionstream info) 714 /// @brief Scale of 1000 and a rate of 29970 will result in 29.97 fps.
252 char m_codecInternalName[INPUTSTREAM_MAX_STRING_CODEC_SIZE]; 715 ///
716 /// @param[in] fpsScale Scale rate
717 void SetFpsScale(unsigned int fpsScale) { m_cStructure->m_FpsScale = fpsScale; }
253 718
254 //! @brief (optional) the profile of the codec 719 /// @brief To get with @ref SetFpsScale changed values.
255 STREAMCODEC_PROFILE m_codecProfile; 720 unsigned int GetFpsScale() const { return m_cStructure->m_FpsScale; }
256 721
257 //! @brief (required) physical index 722 /// @brief Rate to use for stream.
258 unsigned int m_pID; 723 ///
724 /// @param[in] fpsRate Rate to use
725 void SetFpsRate(unsigned int fpsRate) { m_cStructure->m_FpsRate = fpsRate; }
259 726
260 const uint8_t* m_ExtraData; 727 /// @brief To get with @ref SetFpsRate changed values.
261 unsigned int m_ExtraSize; 728 unsigned int GetFpsRate() const { return m_cStructure->m_FpsRate; }
262 729
263 //! @brief RFC 5646 language code (empty string if undefined) 730 /// @brief Height of the stream reported by the demuxer.
264 char m_language[INPUTSTREAM_MAX_STRING_LANGUAGE_SIZE]; 731 ///
732 /// @param[in] height Height to use
733 void SetHeight(unsigned int height) { m_cStructure->m_Height = height; }
265 734
266 //! Video stream related data 735 /// @brief To get with @ref SetHeight changed values.
267 //@{ 736 unsigned int GetHeight() const { return m_cStructure->m_Height; }
268 737
269 //! @brief Scale of 1000 and a rate of 29970 will result in 29.97 fps 738 /// @brief Width of the stream reported by the demuxer.
270 unsigned int m_FpsScale; 739 ///
740 /// @param[in] width Width to use
741 void SetWidth(unsigned int width) { m_cStructure->m_Width = width; }
271 742
272 unsigned int m_FpsRate; 743 /// @brief To get with @ref SetWidth changed values.
744 unsigned int GetWidth() const { return m_cStructure->m_Width; }
273 745
274 //! @brief height of the stream reported by the demuxer 746 /// @brief Display aspect of stream.
275 unsigned int m_Height; 747 ///
748 /// @param[in] aspect Aspect ratio to use
749 void SetAspect(float aspect) { m_cStructure->m_Aspect = aspect; }
276 750
277 //! @brief width of the stream reported by the demuxer 751 /// @brief To get with @ref SetAspect changed values.
278 unsigned int m_Width; 752 float GetAspect() const { return m_cStructure->m_Aspect; }
279 753
280 //! @brief display aspect of stream 754 /// @brief (required) Amount of channels.
281 float m_Aspect; 755 ///
282 756 /// @param[in] sampleRate Channels to use
283 //@} 757 void SetChannels(unsigned int channels) { m_cStructure->m_Channels = channels; }
284
285 //! Audio stream related data
286 //@{
287
288 //! @brief (required) amount of channels
289 unsigned int m_Channels;
290
291 //! @brief (required) sample rate
292 unsigned int m_SampleRate;
293
294 //! @brief (required) bit rate
295 unsigned int m_BitRate;
296
297 //! @brief (required) bits per sample
298 unsigned int m_BitsPerSample;
299
300 unsigned int m_BlockAlign;
301
302 //@}
303
304 CRYPTO_INFO m_cryptoInfo;
305
306 // new in API version 2.0.8
307 //@{
308 //! @brief Codec If available, the fourcc code codec
309 unsigned int m_codecFourCC;
310
311 //! @brief definition of colorspace
312 COLORSPACE m_colorSpace;
313
314 //! @brief color range if available
315 COLORRANGE m_colorRange;
316 //@}
317
318 //new in API 2.0.9 / INPUTSTREAM_VERSION_LEVEL 1
319 //@{
320 COLORPRIMARIES m_colorPrimaries;
321 COLORTRC m_colorTransferCharacteristic;
322 //@}
323
324 //! @brief mastering static Metadata
325 INPUTSTREAM_MASTERING_METADATA* m_masteringMetadata;
326
327 //! @brief content light static Metadata
328 INPUTSTREAM_CONTENTLIGHT_METADATA* m_contentLightMetadata;
329 };
330 758
331 struct INPUTSTREAM_TIMES 759 /// @brief To get with @ref SetChannels changed values.
332 { 760 unsigned int GetChannels() const { return m_cStructure->m_Channels; }
333 time_t startTime;
334 double ptsStart;
335 double ptsBegin;
336 double ptsEnd;
337 };
338 761
339 /*! 762 /// @brief (required) Sample rate.
340 * @brief "C" ABI Structures to transfer the methods from this to Kodi 763 ///
341 */ 764 /// @param[in] sampleRate Rate to use
765 void SetSampleRate(unsigned int sampleRate) { m_cStructure->m_SampleRate = sampleRate; }
342 766
343 // this are properties given to the addon on create 767 /// @brief To get with @ref SetSampleRate changed values.
344 // at this time we have no parameters for the addon 768 unsigned int GetSampleRate() const { return m_cStructure->m_SampleRate; }
345 typedef struct AddonProps_InputStream /* internal */ 769
770 /// @brief Bit rate.
771 ///
772 /// @param[in] bitRate Rate to use
773 void SetBitRate(unsigned int bitRate) { m_cStructure->m_BitRate = bitRate; }
774
775 /// @brief To get with @ref SetBitRate changed values.
776 unsigned int GetBitRate() const { return m_cStructure->m_BitRate; }
777
778 /// @brief (required) Bits per sample.
779 ///
780 /// @param[in] bitsPerSample Bits per sample to use
781 void SetBitsPerSample(unsigned int bitsPerSample)
346 { 782 {
347 int dummy; 783 m_cStructure->m_BitsPerSample = bitsPerSample;
348 } AddonProps_InputStream; 784 }
785
786 /// @brief To get with @ref SetBitsPerSample changed values.
787 unsigned int GetBitsPerSample() const { return m_cStructure->m_BitsPerSample; }
788
789 /// @brief To set the necessary stream block alignment size.
790 ///
791 /// @param[in] blockAlign Block size in byte
792 void SetBlockAlign(unsigned int blockAlign) { m_cStructure->m_BlockAlign = blockAlign; }
793
794 /// @brief To get with @ref SetBlockAlign changed values.
795 unsigned int GetBlockAlign() const { return m_cStructure->m_BlockAlign; }
349 796
350 typedef struct AddonToKodiFuncTable_InputStream /* internal */ 797 /// @brief To set stream crypto session informations.
798 ///
799 /// @param[in] cryptoSession The with @ref cpp_kodi_addon_inputstream_Defs_Interface_StreamCryptoSession setable info
800 ///
801 void SetCryptoSession(const kodi::addon::StreamCryptoSession& cryptoSession)
351 { 802 {
352 KODI_HANDLE kodiInstance; 803 m_cryptoSession = cryptoSession;
353 DemuxPacket* (*allocate_demux_packet)(void* kodiInstance, int data_size); 804 memcpy(&m_cStructure->m_cryptoSession, m_cryptoSession.GetCStructure(),
354 DemuxPacket* (*allocate_encrypted_demux_packet)(void* kodiInstance, 805 sizeof(STREAM_CRYPTO_SESSION));
355 unsigned int data_size, 806 }
356 unsigned int encrypted_subsample_count); 807
357 void (*free_demux_packet)(void* kodiInstance, DemuxPacket* packet); 808 /// @brief To get with @ref GetCryptoSession changed values.
358 } AddonToKodiFuncTable_InputStream; 809 const kodi::addon::StreamCryptoSession& GetCryptoSession() const { return m_cryptoSession; }
810
811 /// @brief Codec If available, the fourcc code codec.
812 ///
813 /// @param[in] codecFourCC Codec four CC code
814 void SetCodecFourCC(unsigned int codecFourCC) { m_cStructure->m_codecFourCC = codecFourCC; }
815
816 /// @brief To get with @ref SetCodecFourCC changed values
817 unsigned int GetCodecFourCC() const { return m_cStructure->m_codecFourCC; }
818
819 /// @brief Definition of colorspace.
820 ///
821 /// @param[in] colorSpace The with @ref INPUTSTREAM_COLORSPACE setable color space
822 void SetColorSpace(INPUTSTREAM_COLORSPACE colorSpace) { m_cStructure->m_colorSpace = colorSpace; }
823
824 /// @brief To get with @ref SetColorSpace changed values.
825 INPUTSTREAM_COLORSPACE GetColorSpace() const { return m_cStructure->m_colorSpace; }
826
827 /// @brief Color range if available.
828 ///
829 /// @param[in] colorRange The with @ref INPUTSTREAM_COLORRANGE setable color space
830 void SetColorRange(INPUTSTREAM_COLORRANGE colorRange) { m_cStructure->m_colorRange = colorRange; }
359 831
360 struct AddonInstance_InputStream; 832 /// @brief To get with @ref SetColorRange changed values.
361 typedef struct KodiToAddonFuncTable_InputStream /* internal */ 833 INPUTSTREAM_COLORRANGE GetColorRange() const { return m_cStructure->m_colorRange; }
834
835 /// @brief Chromaticity coordinates of the source primaries. These values match the ones defined by ISO/IEC 23001-8_2013 § 7.1.
836 ///
837 /// @param[in] colorPrimaries The with @ref INPUTSTREAM_COLORPRIMARIES setable values
838 void SetColorPrimaries(INPUTSTREAM_COLORPRIMARIES colorPrimaries)
362 { 839 {
363 KODI_HANDLE addonInstance; 840 m_cStructure->m_colorPrimaries = colorPrimaries;
841 }
364 842
365 bool(__cdecl* open)(const AddonInstance_InputStream* instance, INPUTSTREAM* props); 843 /// @brief To get with @ref SetColorPrimaries changed values.
366 void(__cdecl* close)(const AddonInstance_InputStream* instance); 844 INPUTSTREAM_COLORPRIMARIES GetColorPrimaries() const { return m_cStructure->m_colorPrimaries; }
367 const char*(__cdecl* get_path_list)(const AddonInstance_InputStream* instance);
368 void(__cdecl* get_capabilities)(const AddonInstance_InputStream* instance,
369 INPUTSTREAM_CAPABILITIES* capabilities);
370 845
371 // IDemux 846 /// @brief Color Transfer Characteristic. These values match the ones defined by ISO/IEC 23001-8_2013 § 7.2.
372 struct INPUTSTREAM_IDS(__cdecl* get_stream_ids)(const AddonInstance_InputStream* instance); 847 ///
373 struct INPUTSTREAM_INFO(__cdecl* get_stream)(const AddonInstance_InputStream* instance, 848 /// @param[in] colorTransferCharacteristic The with @ref INPUTSTREAM_COLORTRC setable characteristic
374 int streamid); 849 void SetColorTransferCharacteristic(INPUTSTREAM_COLORTRC colorTransferCharacteristic)
375 void(__cdecl* enable_stream)(const AddonInstance_InputStream* instance, 850 {
376 int streamid, 851 m_cStructure->m_colorTransferCharacteristic = colorTransferCharacteristic;
377 bool enable); 852 }
378 bool(__cdecl* open_stream)(const AddonInstance_InputStream* instance, int streamid);
379 void(__cdecl* demux_reset)(const AddonInstance_InputStream* instance);
380 void(__cdecl* demux_abort)(const AddonInstance_InputStream* instance);
381 void(__cdecl* demux_flush)(const AddonInstance_InputStream* instance);
382 DemuxPacket*(__cdecl* demux_read)(const AddonInstance_InputStream* instance);
383 bool(__cdecl* demux_seek_time)(const AddonInstance_InputStream* instance,
384 double time,
385 bool backwards,
386 double* startpts);
387 void(__cdecl* demux_set_speed)(const AddonInstance_InputStream* instance, int speed);
388 void(__cdecl* set_video_resolution)(const AddonInstance_InputStream* instance,
389 int width,
390 int height);
391
392 // IDisplayTime
393 int(__cdecl* get_total_time)(const AddonInstance_InputStream* instance);
394 int(__cdecl* get_time)(const AddonInstance_InputStream* instance);
395
396 // ITime
397 bool(__cdecl* get_times)(const AddonInstance_InputStream* instance, INPUTSTREAM_TIMES* times);
398
399 // IPosTime
400 bool(__cdecl* pos_time)(const AddonInstance_InputStream* instance, int ms);
401
402 int(__cdecl* read_stream)(const AddonInstance_InputStream* instance,
403 uint8_t* buffer,
404 unsigned int bufferSize);
405 int64_t(__cdecl* seek_stream)(const AddonInstance_InputStream* instance,
406 int64_t position,
407 int whence);
408 int64_t(__cdecl* position_stream)(const AddonInstance_InputStream* instance);
409 int64_t(__cdecl* length_stream)(const AddonInstance_InputStream* instance);
410 bool(__cdecl* is_real_time_stream)(const AddonInstance_InputStream* instance);
411
412 // IChapter
413 int(__cdecl* get_chapter)(const AddonInstance_InputStream* instance);
414 int(__cdecl* get_chapter_count)(const AddonInstance_InputStream* instance);
415 const char*(__cdecl* get_chapter_name)(const AddonInstance_InputStream* instance, int ch);
416 int64_t(__cdecl* get_chapter_pos)(const AddonInstance_InputStream* instance, int ch);
417 bool(__cdecl* seek_chapter)(const AddonInstance_InputStream* instance, int ch);
418
419 int(__cdecl* block_size_stream)(const AddonInstance_InputStream* instance);
420 } KodiToAddonFuncTable_InputStream;
421
422 typedef struct AddonInstance_InputStream /* internal */
423 {
424 AddonProps_InputStream* props;
425 AddonToKodiFuncTable_InputStream* toKodi;
426 KodiToAddonFuncTable_InputStream* toAddon;
427 } AddonInstance_InputStream;
428 853
429#ifdef __cplusplus 854 /// @brief To get with @ref SetColorTransferCharacteristic changed values.
430} /* extern "C" */ 855 INPUTSTREAM_COLORTRC GetColorTransferCharacteristic() const
856 {
857 return m_cStructure->m_colorTransferCharacteristic;
858 }
431 859
432namespace kodi 860 /// @brief Mastering static Metadata.
433{ 861 ///
434namespace addon 862 /// Describes the metadata for HDR10, used when video is compressed using High
435{ 863 /// Efficiency Video Coding (HEVC). This is used to describe the capabilities
864 /// of the display used to master the content and the luminance values of the
865 /// content.
866 ///
867 /// @param[in] masteringMetadata The with @ref cpp_kodi_addon_inputstream_Defs_Interface_InputstreamMasteringMetadata setable metadata
868 void SetMasteringMetadata(const kodi::addon::InputstreamMasteringMetadata& masteringMetadata)
869 {
870 m_masteringMetadata = masteringMetadata;
871 m_cStructure->m_masteringMetadata = m_masteringMetadata;
872 }
436 873
437class ATTRIBUTE_HIDDEN CInstanceInputStream : public IAddonInstance 874 /// @brief To get with @ref SetMasteringMetadata changed values.
438{ 875 const kodi::addon::InputstreamMasteringMetadata& GetMasteringMetadata() const
439public:
440 explicit CInstanceInputStream(KODI_HANDLE instance, const std::string& kodiVersion = "")
441 : IAddonInstance(ADDON_INSTANCE_INPUTSTREAM,
442 !kodiVersion.empty() ? kodiVersion
443 : GetKodiTypeVersion(ADDON_INSTANCE_INPUTSTREAM))
444 { 876 {
445 if (CAddonBase::m_interface->globalSingleInstance != nullptr) 877 return m_masteringMetadata;
446 throw std::logic_error("kodi::addon::CInstanceInputStream: Creation of multiple together " 878 }
447 "with single instance way is not allowed!");
448 879
449 SetAddonStruct(instance, m_kodiVersion); 880 /// @brief Clear mastering static Metadata.
881 void ClearMasteringMetadata() { m_cStructure->m_masteringMetadata = nullptr; }
882
883 /// @brief Content light static Metadata.
884 ///
885 /// The maximum content light level (MaxCLL) and frame average light level
886 /// (MaxFALL) for the metadata for HDR10.
887 ///
888 /// @param[in] contentLightMetadata The with @ref cpp_kodi_addon_inputstream_Defs_Interface_InputstreamContentlightMetadata setable metadata
889 void SetContentLightMetadata(
890 const kodi::addon::InputstreamContentlightMetadata& contentLightMetadata)
891 {
892 m_contentLightMetadata = contentLightMetadata;
893 m_cStructure->m_contentLightMetadata = m_contentLightMetadata;
450 } 894 }
451 895
452 ~CInstanceInputStream() override = default; 896 /// @brief To get with @ref SetContentLightMetadata changed values.
897 const kodi::addon::InputstreamContentlightMetadata& GetContentLightMetadata() const
898 {
899 return m_contentLightMetadata;
900 }
453 901
454 /*! 902 /// @brief Clear content light static Metadata.
455 * Open a stream. 903 void ClearContentLightMetadata() { m_cStructure->m_contentLightMetadata = nullptr; }
456 * @param props
457 * @return True if the stream has been opened successfully, false otherwise.
458 * @remarks
459 */
460 virtual bool Open(INPUTSTREAM& props) = 0;
461
462 /*!
463 * Close an open stream.
464 * @remarks
465 */
466 virtual void Close() = 0;
467 904
468 /*! 905 ///@}
469 * Get Capabilities of this addon.
470 * @param capabilities The add-on's capabilities.
471 * @remarks
472 */
473 virtual void GetCapabilities(INPUTSTREAM_CAPABILITIES& capabilities) = 0;
474
475 /*!
476 * Get IDs of available streams
477 * @remarks
478 */
479 virtual INPUTSTREAM_IDS GetStreamIds() = 0;
480
481 /*!
482 * Get stream properties of a stream.
483 * @param streamid unique id of stream
484 * @return struc of stream properties
485 * @remarks
486 */
487 virtual INPUTSTREAM_INFO GetStream(int streamid) = 0;
488
489 /*!
490 * Enable or disable a stream.
491 * A disabled stream does not send demux packets
492 * @param streamid unique id of stream
493 * @param enable true for enable, false for disable
494 * @remarks
495 */
496 virtual void EnableStream(int streamid, bool enable) = 0;
497
498 /*!
499 * Opens a stream for playback.
500 * @param streamid unique id of stream
501 * @remarks
502 */
503 virtual bool OpenStream(int streamid) = 0;
504 906
505 /*! 907private:
506 * Reset the demultiplexer in the add-on. 908 InputstreamInfo(const INPUTSTREAM_INFO* stream) : CStructHdl(stream)
507 * @remarks Required if bHandlesDemuxing is set to true. 909 {
508 */ 910 SetCryptoSession(StreamCryptoSession(&stream->m_cryptoSession));
509 virtual void DemuxReset() {} 911 CopyExtraData();
912 }
913 InputstreamInfo(INPUTSTREAM_INFO* stream) : CStructHdl(stream)
914 {
915 SetCryptoSession(StreamCryptoSession(&stream->m_cryptoSession));
916 CopyExtraData();
917 }
510 918
511 /*! 919 void CopyExtraData()
512 * Abort the demultiplexer thread in the add-on. 920 {
513 * @remarks Required if bHandlesDemuxing is set to true. 921 if (m_cStructure->m_ExtraData && m_cStructure->m_ExtraSize > 0)
514 */ 922 {
515 virtual void DemuxAbort() {} 923 for (unsigned int i = 0; i < m_cStructure->m_ExtraSize; ++i)
924 m_extraData.emplace_back(m_cStructure->m_ExtraData[i]);
925 }
926 if (m_cStructure->m_masteringMetadata)
927 m_masteringMetadata = m_cStructure->m_masteringMetadata;
928 if (m_cStructure->m_contentLightMetadata)
929 m_contentLightMetadata = m_cStructure->m_contentLightMetadata;
930 }
931 std::vector<uint8_t> m_extraData;
932 StreamCryptoSession m_cryptoSession;
933 InputstreamMasteringMetadata m_masteringMetadata;
934 InputstreamContentlightMetadata m_contentLightMetadata;
935};
936///@}
937//------------------------------------------------------------------------------
938
939//==============================================================================
940/// @defgroup cpp_kodi_addon_inputstream_Defs_Interface_InputstreamTimes class InputstreamTimes
941/// @ingroup cpp_kodi_addon_inputstream_Defs_Interface
942/// @brief **Inputstream add-on times**\n
943/// Used on @ref kodi::addon::CInstanceInputStream::GetTimes().
944///
945/// ----------------------------------------------------------------------------
946///
947/// @copydetails cpp_kodi_addon_inputstream_Defs_Interface_InputstreamTimes_Help
948///
949///@{
950class ATTRIBUTE_HIDDEN InputstreamTimes : public CStructHdl<InputstreamTimes, INPUTSTREAM_TIMES>
951{
952 /*! \cond PRIVATE */
953 friend class CInstanceInputStream;
954 /*! \endcond */
516 955
517 /*! 956public:
518 * Flush all data that's currently in the demultiplexer buffer in the add-on. 957 /*! \cond PRIVATE */
519 * @remarks Required if bHandlesDemuxing is set to true. 958 InputstreamTimes() = default;
520 */ 959 InputstreamTimes(const InputstreamTimes& stream) : CStructHdl(stream) {}
521 virtual void DemuxFlush() {} 960 /*! \endcond */
522 961
523 /*! 962 /// @defgroup cpp_kodi_addon_inputstream_Defs_Interface_InputstreamTimes_Help Value Help
524 * Read the next packet from the demultiplexer, if there is one. 963 /// @ingroup cpp_kodi_addon_inputstream_Defs_Interface_InputstreamTimes
525 * @return The next packet. 964 ///
526 * If there is no next packet, then the add-on should return the 965 /// <b>The following table contains values that can be set with @ref cpp_kodi_addon_inputstream_Defs_Interface_InputstreamTimes :</b>
527 * packet created by calling AllocateDemuxPacket(0) on the callback. 966 /// | Name | Type | Set call | Get call
528 * If the stream changed and Kodi's player needs to be reinitialised, 967 /// |------|------|----------|--------------------
529 * then, the add-on should call AllocateDemuxPacket(0) on the 968 /// | **Start time** | `time_t` | @ref InputstreamTimes::SetStartTime "SetStartTime" | @ref InputstreamTimes::GetStartTime "GetStartTime"
530 * callback, and set the streamid to DMX_SPECIALID_STREAMCHANGE and 969 /// | **PTS start** | `double` | @ref InputstreamTimes::SetPtsStart "SetPtsStart" | @ref InputstreamTimes::GetPtsStart "GetPtsStart"
531 * return the value. 970 /// | **PTS begin** | `double` | @ref InputstreamTimes::SetPtsBegin "SetPtsBegin" | @ref InputstreamTimes::GetPtsBegin "GetPtsBegin"
532 * The add-on should return NULL if an error occurred. 971 /// | **PTS end** | `double` | @ref InputstreamTimes::SetPtsEnd "SetPtsEnd" | @ref InputstreamTimes::GetPtsEnd "GetPtsEnd"
533 * @remarks Return NULL if this add-on won't provide this function. 972 ///
534 */
535 virtual DemuxPacket* DemuxRead() { return nullptr; }
536
537 /*!
538 * Notify the InputStream addon/demuxer that Kodi wishes to seek the stream by time
539 * Demuxer is required to set stream to an IDR frame
540 * @param time The absolute time since stream start
541 * @param backwards True to seek to keyframe BEFORE time, else AFTER
542 * @param startpts can be updated to point to where display should start
543 * @return True if the seek operation was possible
544 * @remarks Optional, and only used if addon has its own demuxer.
545 */
546 virtual bool DemuxSeekTime(double time, bool backwards, double& startpts) { return false; }
547 973
548 /*! 974 /// @addtogroup cpp_kodi_addon_inputstream_Defs_Interface_InputstreamTimes
549 * Notify the InputStream addon/demuxer that Kodi wishes to change playback speed 975 ///@{
550 * @param speed The requested playback speed
551 * @remarks Optional, and only used if addon has its own demuxer.
552 */
553 virtual void DemuxSetSpeed(int speed) {}
554 976
555 /*! 977 /// @brief Start time in milliseconds
556 * Sets desired width / height 978 void SetStartTime(time_t startTime) const { m_cStructure->startTime = startTime; }
557 * @param width / hight
558 */
559 virtual void SetVideoResolution(int width, int height) {}
560 979
561 /*! 980 /// @brief To get with @ref SetStartTime changed values
562 * Totel time in ms 981 time_t GetStartTime() const { return m_cStructure->startTime; }
563 * @remarks
564 */
565 virtual int GetTotalTime() { return -1; }
566 982
567 /*! 983 /// @brief Start PTS
568 * Playing time in ms 984 void SetPtsStart(double ptsStart) const { m_cStructure->ptsStart = ptsStart; }
569 * @remarks
570 */
571 virtual int GetTime() { return -1; }
572 985
573 /*! 986 /// @brief To get with @ref SetPtsStart changed values
574 * Get current timing values in PTS scale 987 double GetPtsStart() const { return m_cStructure->ptsStart; }
575 * @remarks
576 */
577 virtual bool GetTimes(INPUTSTREAM_TIMES& times) { return false; }
578 988
579 /*! 989 /// @brief Begin PTS
580 * Positions inputstream to playing time given in ms 990 void SetPtsBegin(double ptsBegin) const { m_cStructure->ptsBegin = ptsBegin; }
581 * @remarks
582 */
583 virtual bool PosTime(int ms) { return false; }
584 991
585 /*! 992 /// @brief To get with @ref SetPtsBegin changed values
586 * Return currently selected chapter 993 double GetPtsBegin() const { return m_cStructure->ptsBegin; }
587 * @remarks
588 */
589 virtual int GetChapter() { return -1; };
590 994
591 /*! 995 /// @brief End PTS
592 * Return number of available chapters 996 void SetPtsEnd(double ptsEnd) const { m_cStructure->ptsEnd = ptsEnd; }
593 * @remarks
594 */
595 virtual int GetChapterCount() { return 0; };
596 997
597 /*! 998 /// @brief To get with @ref SetPtsEnd changed values
598 * Return name of chapter # ch 999 double GetPtsEnd() const { return m_cStructure->ptsEnd; }
599 * @remarks
600 */
601 virtual const char* GetChapterName(int ch) { return nullptr; };
602 1000
603 /*! 1001 ///@}
604 * Return position if chapter # ch in milliseconds
605 * @remarks
606 */
607 virtual int64_t GetChapterPos(int ch) { return 0; };
608 1002
609 /*! 1003private:
610 * Seek to the beginning of chapter # ch 1004 InputstreamTimes(const INPUTSTREAM_TIMES* stream) : CStructHdl(stream) {}
611 * @remarks 1005 InputstreamTimes(INPUTSTREAM_TIMES* stream) : CStructHdl(stream) {}
612 */ 1006};
613 virtual bool SeekChapter(int ch) { return false; }; 1007///@}
1008//------------------------------------------------------------------------------
1009
1010//============================================================================
1011///
1012/// @addtogroup cpp_kodi_addon_inputstream
1013/// @brief \cpp_class{ kodi::addon::CInstanceInputStream }
1014/// **Inputstream add-on instance**
1015///
1016/// This instance type is for using input streams to video and audio, to process
1017/// and then give them to Kodi.
1018///
1019/// This usage can be requested under various conditions, for example explicitly
1020/// by another addon, by a Mimetype protocol defined in `addon.xml` or supported
1021/// file extensions.
1022///
1023/// In addition, stream files (* .strm) can be linked to an inputstream addon
1024/// using <b>`#KODIPROP:inputstream=<ADDON_NAME>`</b>.
1025///
1026/// Include the header @ref Inputstream.h "#include <kodi/addon-instance/Inputstream.h>"
1027/// to use this class.
1028///
1029/// ----------------------------------------------------------------------------
1030///
1031/// Here is an example of what the <b>`addon.xml.in`</b> would look like for an inputstream addon:
1032///
1033/// ~~~~~~~~~~~~~{.xml}
1034/// <?xml version="1.0" encoding="UTF-8"?>
1035/// <addon
1036/// id="inputstream.myspecialnamefor"
1037/// version="1.0.0"
1038/// name="My InputStream addon"
1039/// provider-name="Your Name">
1040/// <requires>@ADDON_DEPENDS@</requires>
1041/// <extension
1042/// point="kodi.inputstream"
1043/// extension=".xyz|.zyx"
1044/// listitemprops="license_type|license_key|license_data|license_flags"
1045/// protocols="myspecialnamefor|myspecialnamefors"
1046/// library_@PLATFORM@="@LIBRARY_FILENAME@"/>
1047/// <extension point="xbmc.addon.metadata">
1048/// <summary lang="en_GB">My InputStream addon</summary>
1049/// <description lang="en_GB">My InputStream description</description>
1050/// <platform>@PLATFORM@</platform>
1051/// </extension>
1052/// </addon>
1053/// ~~~~~~~~~~~~~
1054///
1055///
1056/// At <b>`<extension point="kodi.inputstream" ...>`</b> the basic instance definition is declared, this is intended to identify the addon as an input stream and to see its supported types:
1057/// | Name | Description
1058/// |------|----------------------
1059/// | <b>`point`</b> | The identification of the addon instance to inputstream is mandatory <b>`kodi.inputstream`</b>. In addition, the instance declared in the first <b>`<extension ... />`</b> is also
1060/// | <b>`extension`</b> | A filename extension is an identifier specified as a suffix to the name of a computer file where supported by addon.
1061/// | <b>`listitemprops`</b> | Values that are available to the addon at @ref InputstreamProperty::GetProperties() and that can be passed to @ref CInstanceInputStream::Open() ith the respective values.
1062/// | <b>`protocols`</b> | The streaming protocol is a special protocol supported by the addon for the transmission of streaming media data over a network.
1063/// | <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`.
1064///
1065///
1066/// @remark For more detailed description of the <b>`addon.xml`</b>, see also https://kodi.wiki/view/Addon.xml.
1067///
1068///
1069/// --------------------------------------------------------------------------
1070///
1071///
1072/// **Example:**
1073///
1074/// ~~~~~~~~~~~~~{.cpp}
1075/// #include <kodi/addon-instance/Inputstream.h>
1076///
1077/// class CMyInputstream : public kodi::addon::CInstanceInputStream
1078/// {
1079/// public:
1080/// CMyInputstream(KODI_HANDLE instance, const std::string& kodiVersion);
1081///
1082/// void GetCapabilities(kodi::addon::InputstreamCapabilities& capabilities) override;
1083/// bool Open(const kodi::addon::InputstreamProperty& props) override;
1084/// void Close() override;
1085/// ...
1086/// };
1087///
1088/// CMyInputstream::CMyInputstream(KODI_HANDLE instance, const std::string& kodiVersion)
1089/// : kodi::addon::CInstanceInputStream(instance, kodiVersion)
1090/// {
1091/// ...
1092/// }
1093///
1094/// void CMyInputstream::GetCapabilities(kodi::addon::InputstreamCapabilities& capabilities)
1095/// {
1096/// capabilities.SetMask(INPUTSTREAM_SUPPORTS_IDEMUX | INPUTSTREAM_SUPPORTS_PAUSE);
1097/// }
1098///
1099/// void CMyInputstream::Open(const kodi::addon::InputstreamProperty& props)
1100/// {
1101/// std::string url = props.GetURL();
1102/// ...
1103/// }
1104///
1105/// void CMyInputstream::Close()
1106/// {
1107/// ...
1108/// }
1109///
1110/// ...
1111///
1112/// //----------------------------------------------------------------------
1113///
1114/// class CMyAddon : public kodi::addon::CAddonBase
1115/// {
1116/// public:
1117/// CMyAddon() = default;
1118/// ADDON_STATUS CreateInstance(int instanceType,
1119/// std::string instanceID,
1120/// KODI_HANDLE instance,
1121/// const std::string& version,
1122/// KODI_HANDLE& addonInstance) override;
1123/// };
1124///
1125/// // If you use only one instance in your add-on, can be instanceType and
1126/// // instanceID ignored
1127/// ADDON_STATUS CMyAddon::CreateInstance(int instanceType,
1128/// std::string instanceID,
1129/// KODI_HANDLE instance,
1130/// const std::string& version,
1131/// KODI_HANDLE& addonInstance)
1132/// {
1133/// if (instanceType == ADDON_INSTANCE_INPUTSTREAM)
1134/// {
1135/// kodi::Log(ADDON_LOG_NOTICE, "Creating my Inputstream");
1136/// addonInstance = new CMyInputstream(instance, version);
1137/// return ADDON_STATUS_OK;
1138/// }
1139/// else if (...)
1140/// {
1141/// ...
1142/// }
1143/// return ADDON_STATUS_UNKNOWN;
1144/// }
1145///
1146/// ADDONCREATOR(CMyAddon)
1147/// ~~~~~~~~~~~~~
1148///
1149/// The destruction of the example class `CMyInputstream` is called from
1150/// Kodi's header. Manually deleting the add-on instance is not required.
1151///
1152//------------------------------------------------------------------------------
1153class ATTRIBUTE_HIDDEN CInstanceInputStream : public IAddonInstance
1154{
1155public:
1156 //============================================================================
1157 /// @ingroup cpp_kodi_addon_inputstream
1158 /// @brief Inputstream class constructor used to support multiple instance
1159 /// types
1160 ///
1161 /// @param[in] instance The instance value given to <b>`kodi::addon::CAddonBase::CreateInstance(...)`</b>
1162 /// @param[in] kodiVersion [opt] Version used in Kodi for this instance, to
1163 /// allow compatibility to older Kodi versions.
1164 ///
1165 /// @warning Only use `instance` from the @ref CAddonBase::CreateInstance call.
1166 ///
1167 explicit CInstanceInputStream(KODI_HANDLE instance, const std::string& kodiVersion = "")
1168 : IAddonInstance(ADDON_INSTANCE_INPUTSTREAM,
1169 !kodiVersion.empty() ? kodiVersion
1170 : GetKodiTypeVersion(ADDON_INSTANCE_INPUTSTREAM))
1171 {
1172 if (CAddonBase::m_interface->globalSingleInstance != nullptr)
1173 throw std::logic_error("kodi::addon::CInstanceInputStream: Creation of multiple together "
1174 "with single instance way is not allowed!");
614 1175
615 /*! 1176 SetAddonStruct(instance, m_kodiVersion);
616 * Read from an open stream. 1177 }
617 * @param buffer The buffer to store the data in. 1178 //----------------------------------------------------------------------------
618 * @param bufferSize The amount of bytes to read.
619 * @return The amount of bytes that were actually read from the stream.
620 * @remarks Return -1 if this add-on won't provide this function.
621 */
622 virtual int ReadStream(uint8_t* buffer, unsigned int bufferSize) { return -1; }
623 1179
624 /*! 1180 //============================================================================
625 * Seek in a stream. 1181 /// @ingroup cpp_kodi_addon_inputstream
626 * @param position The position to seek to. 1182 /// @brief Destructor
627 * @param whence ? 1183 ///
628 * @return The new position. 1184 ~CInstanceInputStream() override = default;
629 * @remarks Return -1 if this add-on won't provide this function. 1185 //----------------------------------------------------------------------------
630 */ 1186
1187 //============================================================================
1188 /// @ingroup cpp_kodi_addon_inputstream
1189 /// @brief Get the list of features that this add-on provides.
1190 ///
1191 /// Called by Kodi to query the add-on's capabilities.
1192 /// Used to check which options should be presented in the UI, which methods to call, etc.
1193 /// All capabilities that the add-on supports should be set to true.
1194 ///
1195 /// @param[out] capabilities The with @ref cpp_kodi_addon_inputstream_Defs_Capabilities defined add-on's capabilities.
1196 ///
1197 ///
1198 /// --------------------------------------------------------------------------
1199 ///
1200 /// @copydetails cpp_kodi_addon_inputstream_Defs_Interface_InputstreamCapabilities_Help
1201 ///
1202 /// --------------------------------------------------------------------------
1203 /// @note Valid implementation required.
1204 ///
1205 ///
1206 /// --------------------------------------------------------------------------
1207 ///
1208 /// **Example:**
1209 ///
1210 /// ~~~~~~~~~~~~~{.cpp}
1211 /// void CMyInputstream::GetCapabilities(kodi::addon::InputstreamCapabilities& capabilities)
1212 /// {
1213 /// capabilities.SetMask(INPUTSTREAM_SUPPORTS_IDEMUX | INPUTSTREAM_SUPPORTS_PAUSE);
1214 /// }
1215 /// ~~~~~~~~~~~~~
1216 ///
1217 virtual void GetCapabilities(kodi::addon::InputstreamCapabilities& capabilities) = 0;
1218 //----------------------------------------------------------------------------
1219
1220 //============================================================================
1221 /// @ingroup cpp_kodi_addon_inputstream
1222 /// @brief Open a stream.
1223 ///
1224 /// @param[in] props The used properties about the stream
1225 /// @return True if the stream has been opened successfully, false otherwise.
1226 ///
1227 ///
1228 /// --------------------------------------------------------------------------
1229 ///
1230 /// @copydetails cpp_kodi_addon_inputstream_Defs_InputstreamProperty_Help
1231 ///
1232 /// --------------------------------------------------------------------------
1233 /// @note Valid implementation required.
1234 ///
1235 ///
1236 /// --------------------------------------------------------------------------
1237 ///
1238 /// **Example:**
1239 ///
1240 /// ~~~~~~~~~~~~~{.cpp}
1241 /// void CMyInputstream::Open(const kodi::addon::InputstreamProperty& props)
1242 /// {
1243 /// std::string url = props.GetURL();
1244 /// std::string license_key = props.GetProperties()["inputstream.myspecialnamefor.license_key"];
1245 /// ...
1246 /// }
1247 /// ~~~~~~~~~~~~~
1248 ///
1249 virtual bool Open(const kodi::addon::InputstreamProperty& props) = 0;
1250 //----------------------------------------------------------------------------
1251
1252 //============================================================================
1253 /// @ingroup cpp_kodi_addon_inputstream
1254 /// @brief Close an open stream.
1255 ///
1256 /// @remarks
1257 ///
1258 ///
1259 /// --------------------------------------------------------------------------
1260 /// @note Valid implementation required.
1261 ///
1262 virtual void Close() = 0;
1263 //----------------------------------------------------------------------------
1264
1265 //============================================================================
1266 /// @ingroup cpp_kodi_addon_inputstream
1267 /// @brief Check for real-time streaming
1268 ///
1269 /// @return true if current stream is real-time
1270 ///
1271 virtual bool IsRealTimeStream() { return true; }
1272 //----------------------------------------------------------------------------
1273
1274 //############################################################################
1275 /// @defgroup cpp_kodi_addon_inputstream_Read 1. Stream read
1276 /// @brief **Functions required to read streams direct and demux inside Kodi.**
1277 ///
1278 /// This part contains at least the functions necessary for addon that have to
1279 /// be supported. This can only be ignored if you use your own demux.
1280 ///
1281 /// The data loaded by Kodi is then processed in it itself. The source does not
1282 /// matter, only Kodi must be able to process this stream data itself and is
1283 /// therefore limited in some things.
1284 ///
1285 /// For more complex things, the addon must integrate its own demuxer and,
1286 /// if necessary, even its own codec processing (see @ref cpp_kodi_addon_codec "Codec").
1287 ///
1288 /// @note These are used and must be set by the addon if the @ref INPUTSTREAM_SUPPORTS_IDEMUX
1289 /// is <em><b>undefined</b></em> in the capabilities (see @ref GetCapabilities()).
1290 /// Otherwise becomes @ref cpp_kodi_addon_inputstream_Demux "demuxing" used.
1291 ///
1292 /// @ingroup cpp_kodi_addon_inputstream
1293 ///@{
1294
1295 //============================================================================
1296 /// @brief Read from an open stream.
1297 ///
1298 /// @param[in] buffer The buffer to store the data in.
1299 /// @param[in] bufferSize The amount of bytes to read.
1300 /// @return The amount of bytes that were actually read from the stream.
1301 ///
1302 virtual int ReadStream(uint8_t* buffer, unsigned int bufferSize) { return -1; }
1303 //----------------------------------------------------------------------------
1304
1305 //============================================================================
1306 /// @brief Seek in a stream.
1307 ///
1308 /// @param[in] position The position to seek to
1309 /// @param[in] whence offset relative to<br>
1310 /// You can set the value of whence to one of three things:
1311 /// | Value | int | Description |
1312 /// |:------------:|:-----:|:----------------------------------------------------|
1313 /// | **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.
1314 /// | **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."
1315 /// | **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.
1316 ///
1317 /// @return Returns the resulting offset location as measured in bytes from
1318 /// the beginning of the file. On error, the value -1 is returned.
1319 ///
1320 /// @remarks Optional and can leaved away or return -1 if this add-on won't
1321 /// provide this function.
1322 ///
631 virtual int64_t SeekStream(int64_t position, int whence = SEEK_SET) { return -1; } 1323 virtual int64_t SeekStream(int64_t position, int whence = SEEK_SET) { return -1; }
632 1324 //----------------------------------------------------------------------------
633 /*! 1325
634 * @return The position in the stream that's currently being read. 1326 //============================================================================
635 * @remarks Return -1 if this add-on won't provide this function. 1327 /// @brief The position in the stream that's currently being read.
636 */ 1328 ///
1329 /// @return Stream position
1330 ///
1331 /// @remarks Optional and can leaved away or return -1 if this add-on won't
1332 /// provide this function.
1333 ///
637 virtual int64_t PositionStream() { return -1; } 1334 virtual int64_t PositionStream() { return -1; }
638 1335 //----------------------------------------------------------------------------
639 /*! 1336
640 * @return The total length of the stream that's currently being read. 1337 //============================================================================
641 * @remarks Return -1 if this add-on won't provide this function. 1338 /// @brief The Total length of the stream that's currently being read.
642 */ 1339 ///
1340 /// @return Length of the stream
1341 ///
1342 /// @remarks Optional and can leaved away or return -1 if this add-on won't
1343 /// provide this function.
1344 ///
643 virtual int64_t LengthStream() { return -1; } 1345 virtual int64_t LengthStream() { return -1; }
644 1346 //--------------------------------------------------------------------------
645 /*! 1347
646 * @return Obtain the chunk size to use when reading streams. 1348 //==========================================================================
647 * @remarks Return 0 if this add-on won't provide this function. 1349 /// @brief Obtain the chunk size to use when reading streams.
648 */ 1350 ///
1351 /// @return Block chunk size
1352 ///
1353 /// @remarks Optional and can leaved away or return 0 if this add-on won't
1354 /// provide this function.
1355 ///
649 virtual int GetBlockSize() { return 0; } 1356 virtual int GetBlockSize() { return 0; }
1357 //--------------------------------------------------------------------------
1358
1359 ///@}
1360
1361 //############################################################################
1362 /// @defgroup cpp_kodi_addon_inputstream_Demux 2. Stream demuxing (optional)
1363 /// @brief **Read demux streams.**
1364 ///
1365 /// @note These are used and must be set by the addon if the @ref INPUTSTREAM_SUPPORTS_IDEMUX is set in the capabilities (see @ref GetCapabilities()).
1366 ///
1367 /// @ingroup cpp_kodi_addon_inputstream
1368 ///@{
1369
1370 //============================================================================
1371 /// @brief Get IDs of available streams
1372 ///
1373 /// @param[in] ids list of used identifications
1374 /// @return true if successfully done, otherwise false
1375 ///
1376 /// @remarks This id's are used to identify wanted data on @ref GetStream call.
1377 ///
1378 ///
1379 /// --------------------------------------------------------------------------
1380 ///
1381 /// **Example:**
1382 ///
1383 /// ~~~~~~~~~~~~~{.cpp}
1384 ///
1385 /// bool CMyInputstream::GetStreamIds(std::vector<unsigned int>& ids)
1386 /// {
1387 /// kodi::Log(ADDON_LOG_DEBUG, "GetStreamIds(...)");
1388 ///
1389 /// if (m_opened)
1390 /// {
1391 /// // This check not needed to have, the ABI checks also about, but make
1392 /// // sure you not give more as 32 streams.
1393 /// if (m_myStreams.size() > MAX_STREAM_COUNT)
1394 /// {
1395 /// kodi::Log(ADDON_LOG_ERROR, "Too many streams, only %u supported", MAX_STREAM_COUNT);
1396 /// return false;
1397 /// }
1398 ///
1399 /// ids.emplace_back(m_myAudioStreamId);
1400 ///
1401 /// for (const auto& streamPair : m_myOtherStreams)
1402 /// {
1403 /// ids.emplace_back(streamPair.second->uniqueId);
1404 /// }
1405 /// }
1406 ///
1407 /// return !ids.empty();
1408 /// }
1409 /// ~~~~~~~~~~~~~
1410 ///
1411 virtual bool GetStreamIds(std::vector<unsigned int>& ids) { return false; }
1412 //----------------------------------------------------------------------------
1413
1414 //============================================================================
1415 /// @brief Function for giving detailed stream information
1416 ///
1417 /// The associated information is set here for IDs previously given with
1418 /// @ref GetStreamIds.
1419 ///
1420 /// This data is required to identify the associated codec and, if necessary,
1421 /// to refer to your own codec (if available in the addon).
1422 ///
1423 /// @param[in] streamid unique id of stream
1424 /// @param[out] stream Information data of wanted stream
1425 /// @return true if successfully done, otherwise false
1426 ///
1427 /// @remarks Available stream id's previously asked by @ref GetStreamIds
1428 ///
1429 ///
1430 /// --------------------------------------------------------------------------
1431 ///
1432 /// @copydetails cpp_kodi_addon_inputstream_Defs_Interface_InputstreamInfo_Help
1433 ///
1434 /// --------------------------------------------------------------------------
1435 ///
1436 /// **Example:**
1437 ///
1438 /// ~~~~~~~~~~~~~{.cpp}
1439 /// bool CMyInputstream::GetStream(int streamid, kodi::addon::InputstreamInfo& stream)
1440 /// {
1441 /// // This is just a small example, this type will be significantly larger
1442 /// // for larger and more complex streams.
1443 /// if (streamid == m_myAudioStreamId)
1444 /// {
1445 /// // This only a minimal exampl
1446 /// stream.SetStreamType(INPUTSTREAM_TYPE_AUDIO);
1447 /// stream.SetFeatures(INPUTSTREAM_FEATURE_NONE); // Only added to example, INPUTSTREAM_FEATURE_NONE is default and no need to call
1448 /// stream.SetFlags(INPUTSTREAM_FLAG_NONE); // Only added to example, INPUTSTREAM_FLAG_NONE is default and no need to call
1449 /// stream.SetCodecName("mp2"); // Codec name, string must by equal with FFmpeg, see https://github.com/FFmpeg/FFmpeg/blob/master/libavcodec/codec_desc.c
1450 /// stream.SetPhysicalIndex(1); // Identifier required to set
1451 /// stream.SetLanguage("en");
1452 /// stream.SetChannels(2);
1453 /// stream.SetSampleRate(48000);
1454 /// stream.SetBitRate(0);
1455 /// stream.SetBitsPerSample(16);
1456 /// }
1457 /// else ...
1458 /// ...
1459 /// return true;
1460 /// }
1461 /// ~~~~~~~~~~~~~
1462 ///
1463 virtual bool GetStream(int streamid, kodi::addon::InputstreamInfo& stream) { return false; }
1464 //----------------------------------------------------------------------------
1465
1466 //============================================================================
1467 /// @brief Enable or disable a stream.
1468 ///
1469 /// A disabled stream does not send demux packets
1470 ///
1471 /// @param[in] streamid unique id of stream
1472 /// @param[in] enable true for enable, false for disable
1473 ///
1474 /// @remarks Available stream id's previously asked by @ref GetStreamIds
1475 ///
1476 ///
1477 /// --------------------------------------------------------------------------
1478 /// @note Valid implementation required.
1479 ///
1480 virtual void EnableStream(int streamid, bool enable) {}
1481 //----------------------------------------------------------------------------
1482
1483 //============================================================================
1484 /// @brief Opens a stream for playback.
1485 ///
1486 /// @param[in] streamid unique id of stream
1487 ///
1488 /// @remarks Available stream id's previously asked by @ref GetStreamIds
1489 ///
1490 ///
1491 /// --------------------------------------------------------------------------
1492 /// @note Valid implementation required.
1493 ///
1494 virtual bool OpenStream(int streamid) { return false; }
1495 //----------------------------------------------------------------------------
1496
1497 //============================================================================
1498 /// @brief Reset the demultiplexer in the add-on.
1499 ///
1500 /// @remarks Optional, and only used if addon has its own demuxer.
1501 ///
1502 virtual void DemuxReset() {}
1503 //----------------------------------------------------------------------------
650 1504
651 /*! 1505 //============================================================================
652 * Check for real-time streaming 1506 /// @brief Abort the demultiplexer thread in the add-on.
653 * @return true if current stream is real-time 1507 ///
654 */ 1508 /// @remarks Optional, and only used if addon has its own demuxer.
655 virtual bool IsRealTimeStream() { return true; } 1509 ///
1510 virtual void DemuxAbort() {}
1511 //----------------------------------------------------------------------------
656 1512
657 /*! 1513 //============================================================================
658 * @brief Allocate a demux packet. Free with FreeDemuxPacket 1514 /// @brief Flush all data that's currently in the demultiplexer buffer in the add-on.
659 * @param dataSize The size of the data that will go into the packet 1515 ///
660 * @return The allocated packet 1516 /// @remarks Optional, and only used if addon has its own demuxer.
661 */ 1517 ///
662 DemuxPacket* AllocateDemuxPacket(int dataSize) 1518 virtual void DemuxFlush() {}
1519 //----------------------------------------------------------------------------
1520
1521 //============================================================================
1522 /// @brief Read the next packet from the demultiplexer, if there is one.
1523 ///
1524 /// @return The next packet.
1525 /// If there is no next packet, then the add-on should return the
1526 /// packet created by calling @ref AllocateDemuxPacket "AllocateDemuxPacket(0)" on the callback.
1527 /// If the stream changed and Kodi's player needs to be reinitialised,
1528 /// then, the add-on should call @ref AllocateDemuxPacket "AllocateDemuxPacket(0)" on the
1529 /// callback, and set the streamid to DMX_SPECIALID_STREAMCHANGE and
1530 /// return the value.
1531 /// The add-on should return <b>`nullptr`</b> if an error occured.
1532 ///
1533 /// @remarks Return <b>`nullptr`</b> if this add-on won't provide this function.
1534 ///
1535 virtual DEMUX_PACKET* DemuxRead() { return nullptr; }
1536 //----------------------------------------------------------------------------
1537
1538 //============================================================================
1539 /// @brief Notify the InputStream addon/demuxer that Kodi wishes to seek the stream by time
1540 ///
1541 /// Demuxer is required to set stream to an IDR frame
1542 ///
1543 /// @param[in] time The absolute time since stream start
1544 /// @param[in] backwards True to seek to keyframe BEFORE time, else AFTER
1545 /// @param[in] startpts can be updated to point to where display should start
1546 /// @return True if the seek operation was possible
1547 ///
1548 /// @remarks Optional, and only used if addon has its own demuxer.
1549 ///
1550 virtual bool DemuxSeekTime(double time, bool backwards, double& startpts) { return false; }
1551 //----------------------------------------------------------------------------
1552
1553 //============================================================================
1554 /// @brief Notify the InputStream addon/demuxer that Kodi wishes to change playback speed
1555 ///
1556 /// @param[in] speed The requested playback speed
1557 ///
1558 /// @remarks Optional, and only used if addon has its own demuxer.
1559 ///
1560 virtual void DemuxSetSpeed(int speed) {}
1561 //----------------------------------------------------------------------------
1562
1563 //============================================================================
1564 /// @brief Sets desired width / height
1565 ///
1566 /// @param[in] width Width to set
1567 /// @param[in] height Height to set
1568 ///
1569 virtual void SetVideoResolution(int width, int height) {}
1570 //----------------------------------------------------------------------------
1571
1572 //=============================================================================
1573 /// @brief Allocate a demux packet. Free with @ref FreeDemuxPacket
1574 ///
1575 /// @param[in] dataSize The size of the data that will go into the packet
1576 /// @return The allocated packet
1577 ///
1578 /// @remarks Only called from addon itself
1579 ///
1580 DEMUX_PACKET* AllocateDemuxPacket(int dataSize)
663 { 1581 {
664 return m_instanceData->toKodi->allocate_demux_packet(m_instanceData->toKodi->kodiInstance, 1582 return m_instanceData->toKodi->allocate_demux_packet(m_instanceData->toKodi->kodiInstance,
665 dataSize); 1583 dataSize);
666 } 1584 }
667 1585 //----------------------------------------------------------------------------
668 /*! 1586
669 * @brief Allocate a demux packet. Free with FreeDemuxPacket 1587 //============================================================================
670 * @param dataSize The size of the data that will go into the packet 1588 /// @brief Allocate a encrypted demux packet. Free with @ref FreeDemuxPacket
671 * @return The allocated packet 1589 ///
672 */ 1590 /// @param[in] dataSize The size of the data that will go into the packet
673 DemuxPacket* AllocateEncryptedDemuxPacket(int dataSize, unsigned int encryptedSubsampleCount) 1591 /// @param[in] encryptedSubsampleCount The encrypted subsample count
1592 /// @return The allocated packet
1593 ///
1594 /// @remarks Only called from addon itself
1595 ///
1596 DEMUX_PACKET* AllocateEncryptedDemuxPacket(int dataSize, unsigned int encryptedSubsampleCount)
674 { 1597 {
675 return m_instanceData->toKodi->allocate_encrypted_demux_packet( 1598 return m_instanceData->toKodi->allocate_encrypted_demux_packet(
676 m_instanceData->toKodi->kodiInstance, dataSize, encryptedSubsampleCount); 1599 m_instanceData->toKodi->kodiInstance, dataSize, encryptedSubsampleCount);
677 } 1600 }
678 1601 //----------------------------------------------------------------------------
679 /*! 1602
680 * @brief Free a packet that was allocated with AllocateDemuxPacket 1603 //============================================================================
681 * @param packet The packet to free 1604 /// @brief Free a packet that was allocated with AllocateDemuxPacket
682 */ 1605 ///
683 void FreeDemuxPacket(DemuxPacket* packet) 1606 /// @param[in] packet The packet to free
1607 ///
1608 /// @remarks Only called from addon itself
1609 ///
1610 void FreeDemuxPacket(DEMUX_PACKET* packet)
684 { 1611 {
685 return m_instanceData->toKodi->free_demux_packet(m_instanceData->toKodi->kodiInstance, packet); 1612 return m_instanceData->toKodi->free_demux_packet(m_instanceData->toKodi->kodiInstance, packet);
686 } 1613 }
1614 //----------------------------------------------------------------------------
1615
1616 ///@}
1617
1618 //############################################################################
1619 /// @defgroup cpp_kodi_addon_inputstream_Time 3. Time (optional)
1620 /// @brief **To get stream position time.**
1621 ///
1622 /// @note These are used and must be set by the addon if the @ref INPUTSTREAM_SUPPORTS_IDISPLAYTIME is set in the capabilities (see @ref GetCapabilities()).
1623 ///
1624 /// @ingroup cpp_kodi_addon_inputstream
1625 ///@{
1626
1627 //==========================================================================
1628 /// @brief Totel time in ms
1629 ///
1630 /// @return Total time in milliseconds
1631 ///
1632 /// @remarks
1633 ///
1634 virtual int GetTotalTime() { return -1; }
1635 //--------------------------------------------------------------------------
1636
1637 //==========================================================================
1638 /// @brief Playing time in ms
1639 ///
1640 /// @return Playing time in milliseconds
1641 ///
1642 /// @remarks
1643 ///
1644 virtual int GetTime() { return -1; }
1645 //--------------------------------------------------------------------------
1646
1647 ///@}
1648
1649 //############################################################################
1650 /// @defgroup cpp_kodi_addon_inputstream_Times 4. Times (optional)
1651 /// @brief **Another way to get stream position time.**
1652 ///
1653 /// @note These are used and must be set by the addon if the @ref INPUTSTREAM_SUPPORTS_ITIME is set in the capabilities (see @ref GetCapabilities()).
1654 ///
1655 /// @ingroup cpp_kodi_addon_inputstream
1656 ///@{
1657
1658 //============================================================================
1659 /// @brief Get current timing values in PTS scale
1660 ///
1661 /// @param[out] times The with @ref InputstreamTimes to given times
1662 /// @return true if successfully done, false if not
1663 ///
1664 /// @copydetails cpp_kodi_addon_inputstream_Defs_Times_Help
1665 ///
1666 /// @remarks
1667 ///
1668 virtual bool GetTimes(InputstreamTimes& times) { return false; }
1669 //----------------------------------------------------------------------------
1670
1671 ///@}
1672
1673 //############################################################################
1674 /// @defgroup cpp_kodi_addon_inputstream_PosTime 5. Position time (optional)
1675 /// @brief **Third way get stream position time.**
1676 ///
1677 /// @note These are used and must be set by the addon if the @ref INPUTSTREAM_SUPPORTS_IPOSTIME is set in the capabilities (see @ref GetCapabilities()).
1678 ///
1679 /// @ingroup cpp_kodi_addon_inputstream
1680 ///@{
1681
1682 //============================================================================
1683 /// @brief Positions inputstream to playing time given in ms
1684 ///
1685 /// @param[in] ms Position time in milliseconds
1686 ///
1687 /// @remarks
1688 ///
1689 virtual bool PosTime(int ms) { return false; }
1690 //----------------------------------------------------------------------------
1691
1692 ///@}
1693
1694 //############################################################################
1695 /// @defgroup cpp_kodi_addon_inputstream_Chapter 6. Chapter (optional)
1696 /// @brief **Used to get available chapters.**
1697 ///
1698 /// @note These are used and must be set by the addon if the @ref INPUTSTREAM_SUPPORTS_ICHAPTER is set in the capabilities (see @ref GetCapabilities()).
1699 ///
1700 /// @ingroup cpp_kodi_addon_inputstream
1701 ///@{
1702
1703 //==========================================================================
1704 ///
1705 /// @brief Return currently selected chapter
1706 ///
1707 /// @return Chapter number
1708 ///
1709 /// @remarks
1710 ///
1711 virtual int GetChapter() { return -1; };
1712 //--------------------------------------------------------------------------
1713
1714 //==========================================================================
1715 ///
1716 /// @brief Return number of available chapters
1717 ///
1718 /// @return Chapter count
1719 ///
1720 /// @remarks
1721 ///
1722 virtual int GetChapterCount() { return 0; };
1723 //--------------------------------------------------------------------------
1724
1725 //==========================================================================
1726 ///
1727 /// @brief Return name of chapter
1728 ///
1729 /// @param[in] ch Chapter identifier
1730 /// @return Chapter name
1731 ///
1732 /// @remarks
1733 ///
1734 virtual const char* GetChapterName(int ch) { return nullptr; };
1735 //--------------------------------------------------------------------------
1736
1737 //==========================================================================
1738 ///
1739 /// @brief Return position if chapter # ch in milliseconds
1740 ///
1741 /// @param[in] ch Chapter to get position from
1742 /// @return Position in milliseconds
1743 ///
1744 /// @remarks
1745 ///
1746 virtual int64_t GetChapterPos(int ch) { return 0; };
1747 //--------------------------------------------------------------------------
1748
1749 //==========================================================================
1750 ///
1751 /// @brief Seek to the beginning of chapter # ch
1752 ///
1753 /// @param[in] ch Chapter to seek
1754 /// @return True if successfully done, false if not
1755 ///
1756 /// @remarks
1757 ///
1758 virtual bool SeekChapter(int ch) { return false; };
1759 //--------------------------------------------------------------------------
1760
1761 ///@}
687 1762
688private: 1763private:
689 static int compareVersion(const int v1[3], const int v2[3]) 1764 static int compareVersion(const int v1[3], const int v2[3])
@@ -752,9 +1827,10 @@ private:
752 */ 1827 */
753 } 1828 }
754 1829
755 inline static bool ADDON_Open(const AddonInstance_InputStream* instance, INPUTSTREAM* props) 1830 inline static bool ADDON_Open(const AddonInstance_InputStream* instance,
1831 INPUTSTREAM_PROPERTY* props)
756 { 1832 {
757 return static_cast<CInstanceInputStream*>(instance->toAddon->addonInstance)->Open(*props); 1833 return static_cast<CInstanceInputStream*>(instance->toAddon->addonInstance)->Open(props);
758 } 1834 }
759 1835
760 inline static void ADDON_Close(const AddonInstance_InputStream* instance) 1836 inline static void ADDON_Close(const AddonInstance_InputStream* instance)
@@ -765,22 +1841,48 @@ private:
765 inline static void ADDON_GetCapabilities(const AddonInstance_InputStream* instance, 1841 inline static void ADDON_GetCapabilities(const AddonInstance_InputStream* instance,
766 INPUTSTREAM_CAPABILITIES* capabilities) 1842 INPUTSTREAM_CAPABILITIES* capabilities)
767 { 1843 {
768 static_cast<CInstanceInputStream*>(instance->toAddon->addonInstance) 1844 InputstreamCapabilities caps(capabilities);
769 ->GetCapabilities(*capabilities); 1845 static_cast<CInstanceInputStream*>(instance->toAddon->addonInstance)->GetCapabilities(caps);
770 } 1846 }
771 1847
772 1848
773 // IDemux 1849 // IDemux
774 inline static struct INPUTSTREAM_IDS ADDON_GetStreamIds(const AddonInstance_InputStream* instance) 1850 inline static bool ADDON_GetStreamIds(const AddonInstance_InputStream* instance,
1851 struct INPUTSTREAM_IDS* ids)
775 { 1852 {
776 return static_cast<CInstanceInputStream*>(instance->toAddon->addonInstance)->GetStreamIds(); 1853 std::vector<unsigned int> idList;
1854 bool ret =
1855 static_cast<CInstanceInputStream*>(instance->toAddon->addonInstance)->GetStreamIds(idList);
1856 if (ret)
1857 {
1858 for (size_t i = 0; i < idList.size() && i < INPUTSTREAM_MAX_STREAM_COUNT; ++i)
1859 {
1860 ids->m_streamCount++;
1861 ids->m_streamIds[i] = idList[i];
1862 }
1863 }
1864 return ret;
777 } 1865 }
778 1866
779 inline static struct INPUTSTREAM_INFO ADDON_GetStream(const AddonInstance_InputStream* instance, 1867 inline static bool ADDON_GetStream(
780 int streamid) 1868 const AddonInstance_InputStream* instance,
1869 int streamid,
1870 struct INPUTSTREAM_INFO* info,
1871 KODI_HANDLE* demuxStream,
1872 KODI_HANDLE (*transfer_stream)(KODI_HANDLE handle,
1873 int streamId,
1874 struct INPUTSTREAM_INFO* stream))
781 { 1875 {
782 return static_cast<CInstanceInputStream*>(instance->toAddon->addonInstance) 1876 InputstreamInfo infoData(info);
783 ->GetStream(streamid); 1877 bool ret = static_cast<CInstanceInputStream*>(instance->toAddon->addonInstance)
1878 ->GetStream(streamid, infoData);
1879 if (ret && transfer_stream)
1880 {
1881 // Do this with given callback to prevent memory problems and leaks. This
1882 // then create on Kodi the needed class where then given back on demuxStream.
1883 *demuxStream = transfer_stream(instance->toKodi->kodiInstance, streamid, info);
1884 }
1885 return ret;
784 } 1886 }
785 1887
786 inline static void ADDON_EnableStream(const AddonInstance_InputStream* instance, 1888 inline static void ADDON_EnableStream(const AddonInstance_InputStream* instance,
@@ -812,7 +1914,7 @@ private:
812 static_cast<CInstanceInputStream*>(instance->toAddon->addonInstance)->DemuxFlush(); 1914 static_cast<CInstanceInputStream*>(instance->toAddon->addonInstance)->DemuxFlush();
813 } 1915 }
814 1916
815 inline static DemuxPacket* ADDON_DemuxRead(const AddonInstance_InputStream* instance) 1917 inline static DEMUX_PACKET* ADDON_DemuxRead(const AddonInstance_InputStream* instance)
816 { 1918 {
817 return static_cast<CInstanceInputStream*>(instance->toAddon->addonInstance)->DemuxRead(); 1919 return static_cast<CInstanceInputStream*>(instance->toAddon->addonInstance)->DemuxRead();
818 } 1920 }
@@ -855,7 +1957,8 @@ private:
855 inline static bool ADDON_GetTimes(const AddonInstance_InputStream* instance, 1957 inline static bool ADDON_GetTimes(const AddonInstance_InputStream* instance,
856 INPUTSTREAM_TIMES* times) 1958 INPUTSTREAM_TIMES* times)
857 { 1959 {
858 return static_cast<CInstanceInputStream*>(instance->toAddon->addonInstance)->GetTimes(*times); 1960 InputstreamTimes cppTimes(times);
1961 return static_cast<CInstanceInputStream*>(instance->toAddon->addonInstance)->GetTimes(cppTimes);
859 } 1962 }
860 1963
861 // IPosTime 1964 // IPosTime
@@ -927,6 +2030,7 @@ private:
927 2030
928 AddonInstance_InputStream* m_instanceData; 2031 AddonInstance_InputStream* m_instanceData;
929}; 2032};
2033//------------------------------------------------------------------------------
930 2034
931} /* namespace addon */ 2035} /* namespace addon */
932} /* namespace kodi */ 2036} /* namespace kodi */
diff --git a/xbmc/addons/kodi-dev-kit/include/kodi/addon-instance/PVR.h b/xbmc/addons/kodi-dev-kit/include/kodi/addon-instance/PVR.h
index d5977a7..61e294f 100644
--- a/xbmc/addons/kodi-dev-kit/include/kodi/addon-instance/PVR.h
+++ b/xbmc/addons/kodi-dev-kit/include/kodi/addon-instance/PVR.h
@@ -36,7 +36,7 @@
36 * Only must be min version increased if a new compile of addon breaks after 36 * Only must be min version increased if a new compile of addon breaks after
37 * changes here. 37 * changes here.
38 * 38 *
39 * Have by add of new parts a look about **Doxygen** `\\ingroup`, so that 39 * Have by add of new parts a look about **Doxygen** `\@ingroup`, so that
40 * added parts included in documentation. 40 * added parts included in documentation.
41 * 41 *
42 * If you add addon side related documentation, where his dev need know, use `///`. 42 * If you add addon side related documentation, where his dev need know, use `///`.
@@ -1477,22 +1477,39 @@ public:
1477 //---------------------------------------------------------------------------- 1477 //----------------------------------------------------------------------------
1478 1478
1479 //============================================================================ 1479 //============================================================================
1480 /// @brief Tell the client the time frame to use when notifying epg events back to Kodi 1480 /// @brief Tell the client the past time frame to use when notifying epg events back to Kodi
1481 /// 1481 ///
1482 /// The client might push epg events asynchronously to Kodi using the callback function 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 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 1484 /// interest for Kodi, client needs to know about the epg time frame Kodi uses. Kodi supplies
1485 /// supplies the current epg time frame value in @ref EpgMaxDays() when creating the 1485 /// the current epg max past time frame value @ref EpgMaxPastDays() when creating the addon
1486 /// addon and calls @ref SetEPGTimeFrame later whenever Kodi's epg time frame value 1486 /// and calls @ref SetEPGMaxPastDays later whenever Kodi's epg time frame value changes.
1487 /// changes.
1488 /// 1487 ///
1489 /// @param[in] days number of days from "now". @ref EPG_TIMEFRAME_UNLIMITED means that Kodi 1488 /// @param[in] pastDays number of days before "now". @ref EPG_TIMEFRAME_UNLIMITED means that Kodi
1490 /// is interested in all epg events, regardless of event times. 1489 /// is interested in all epg events, regardless of event times.
1491 /// @return @ref PVR_ERROR_NO_ERROR if new value was successfully set. 1490 /// @return @ref PVR_ERROR_NO_ERROR if new value was successfully set.
1492 /// 1491 ///
1493 /// @remarks Required if @ref PVRCapabilities::SetSupportsEPG "supportsEPG" is set to true. 1492 /// @remarks Required if @ref PVRCapabilities::SetSupportsEPG "supportsEPG" is set to true.
1494 /// 1493 ///
1495 virtual PVR_ERROR SetEPGTimeFrame(int days) { return PVR_ERROR_NOT_IMPLEMENTED; } 1494 virtual PVR_ERROR SetEPGMaxPastDays(int pastDays) { return PVR_ERROR_NOT_IMPLEMENTED; }
1495 //----------------------------------------------------------------------------
1496
1497 //============================================================================
1498 /// @brief Tell the client the future time frame to use when notifying epg events back to Kodi
1499 ///
1500 /// The client might push epg events asynchronously to Kodi using the callback function
1501 /// @ref EpgEventStateChange. To be able to only push events that are actually of
1502 /// interest for Kodi, client needs to know about the epg time frame Kodi uses. Kodi supplies
1503 /// the current epg max future time frame value @ref EpgMaxFutureDays() when creating the addon
1504 /// and calls @ref SetEPGMaxFutureDays later whenever Kodi's epg time frame value changes.
1505 ///
1506 /// @param[in] futureDays number of days from "now". @ref EPG_TIMEFRAME_UNLIMITED means that Kodi
1507 /// is interested in all epg events, regardless of event times.
1508 /// @return @ref PVR_ERROR_NO_ERROR if new value was successfully set.
1509 ///
1510 /// @remarks Required if @ref PVRCapabilities::SetSupportsEPG "supportsEPG" is set to true.
1511 ///
1512 virtual PVR_ERROR SetEPGMaxFutureDays(int futureDays) { return PVR_ERROR_NOT_IMPLEMENTED; }
1496 //---------------------------------------------------------------------------- 1513 //----------------------------------------------------------------------------
1497 1514
1498 //========================================================================== 1515 //==========================================================================
@@ -1518,15 +1535,28 @@ public:
1518 1535
1519 //========================================================================== 1536 //==========================================================================
1520 /// @brief **Callback to Kodi Function**\n 1537 /// @brief **Callback to Kodi Function**\n
1521 /// Get the Max days handled by Kodi. 1538 /// Get the Max past days handled by Kodi.
1522 /// 1539 ///
1523 /// If > @ref EPG_TIMEFRAME_UNLIMITED, in async epg mode, deliver only events 1540 /// If > @ref EPG_TIMEFRAME_UNLIMITED, in async epg mode, deliver only events in the
1524 /// in the range from 'end time > now' to 'start time < now + EpgMaxDays(). 1541 /// range from 'end time > now - EpgMaxPastDays()' to 'start time < now + EpgMaxFutureDays().
1525 /// @ref EPG_TIMEFRAME_UNLIMITED, notify all events. 1542 /// @ref EPG_TIMEFRAME_UNLIMITED, notify all events.
1526 /// 1543 ///
1527 /// @return The Max days handled by Kodi 1544 /// @return The Max past days handled by Kodi
1528 /// 1545 ///
1529 inline int EpgMaxDays() const { return m_instanceData->props->iEpgMaxDays; } 1546 inline int EpgMaxPastDays() const { return m_instanceData->props->iEpgMaxPastDays; }
1547 //----------------------------------------------------------------------------
1548
1549 //==========================================================================
1550 /// @brief **Callback to Kodi Function**\n
1551 /// Get the Max future days handled by Kodi.
1552 ///
1553 /// If > @ref EPG_TIMEFRAME_UNLIMITED, in async epg mode, deliver only events in the
1554 /// range from 'end time > now - EpgMaxPastDays()' to 'start time < now + EpgMaxFutureDays().
1555 /// @ref EPG_TIMEFRAME_UNLIMITED, notify all events.
1556 ///
1557 /// @return The Max future days handled by Kodi
1558 ///
1559 inline int EpgMaxFutureDays() const { return m_instanceData->props->iEpgMaxFutureDays; }
1530 //---------------------------------------------------------------------------- 1560 //----------------------------------------------------------------------------
1531 1561
1532 //========================================================================== 1562 //==========================================================================
@@ -2324,7 +2354,7 @@ public:
2324 /// @remarks Required, and only used if addon has its own demuxer. 2354 /// @remarks Required, and only used if addon has its own demuxer.
2325 /// Return `nullptr` if this add-on won't provide this function. 2355 /// Return `nullptr` if this add-on won't provide this function.
2326 /// 2356 ///
2327 virtual DemuxPacket* DemuxRead() { return nullptr; } 2357 virtual DEMUX_PACKET* DemuxRead() { return nullptr; }
2328 //---------------------------------------------------------------------------- 2358 //----------------------------------------------------------------------------
2329 2359
2330 //============================================================================ 2360 //============================================================================
@@ -2413,7 +2443,7 @@ public:
2413 /// 2443 ///
2414 /// @remarks Only called from addon itself 2444 /// @remarks Only called from addon itself
2415 /// 2445 ///
2416 inline DemuxPacket* AllocateDemuxPacket(int iDataSize) 2446 inline DEMUX_PACKET* AllocateDemuxPacket(int iDataSize)
2417 { 2447 {
2418 return m_instanceData->toKodi->AllocateDemuxPacket(m_instanceData->toKodi->kodiInstance, 2448 return m_instanceData->toKodi->AllocateDemuxPacket(m_instanceData->toKodi->kodiInstance,
2419 iDataSize); 2449 iDataSize);
@@ -2428,7 +2458,7 @@ public:
2428 /// 2458 ///
2429 /// @remarks Only called from addon itself. 2459 /// @remarks Only called from addon itself.
2430 /// 2460 ///
2431 inline void FreeDemuxPacket(DemuxPacket* pPacket) 2461 inline void FreeDemuxPacket(DEMUX_PACKET* pPacket)
2432 { 2462 {
2433 m_instanceData->toKodi->FreeDemuxPacket(m_instanceData->toKodi->kodiInstance, pPacket); 2463 m_instanceData->toKodi->FreeDemuxPacket(m_instanceData->toKodi->kodiInstance, pPacket);
2434 } 2464 }
@@ -2662,7 +2692,8 @@ private:
2662 m_instanceData->toAddon->IsEPGTagPlayable = ADDON_IsEPGTagPlayable; 2692 m_instanceData->toAddon->IsEPGTagPlayable = ADDON_IsEPGTagPlayable;
2663 m_instanceData->toAddon->GetEPGTagEdl = ADDON_GetEPGTagEdl; 2693 m_instanceData->toAddon->GetEPGTagEdl = ADDON_GetEPGTagEdl;
2664 m_instanceData->toAddon->GetEPGTagStreamProperties = ADDON_GetEPGTagStreamProperties; 2694 m_instanceData->toAddon->GetEPGTagStreamProperties = ADDON_GetEPGTagStreamProperties;
2665 m_instanceData->toAddon->SetEPGTimeFrame = ADDON_SetEPGTimeFrame; 2695 m_instanceData->toAddon->SetEPGMaxPastDays = ADDON_SetEPGMaxPastDays;
2696 m_instanceData->toAddon->SetEPGMaxFutureDays = ADDON_SetEPGMaxFutureDays;
2666 m_instanceData->toAddon->CallEPGMenuHook = ADDON_CallEPGMenuHook; 2697 m_instanceData->toAddon->CallEPGMenuHook = ADDON_CallEPGMenuHook;
2667 //--==----==----==----==----==----==----==----==----==----==----==----==----== 2698 //--==----==----==----==----==----==----==----==----==----==----==----==----==
2668 m_instanceData->toAddon->GetRecordingsAmount = ADDON_GetRecordingsAmount; 2699 m_instanceData->toAddon->GetRecordingsAmount = ADDON_GetRecordingsAmount;
@@ -2998,10 +3029,17 @@ private:
2998 return error; 3029 return error;
2999 } 3030 }
3000 3031
3001 inline static PVR_ERROR ADDON_SetEPGTimeFrame(const AddonInstance_PVR* instance, int days) 3032 inline static PVR_ERROR ADDON_SetEPGMaxPastDays(const AddonInstance_PVR* instance, int pastDays)
3033 {
3034 return static_cast<CInstancePVRClient*>(instance->toAddon->addonInstance)
3035 ->SetEPGMaxPastDays(pastDays);
3036 }
3037
3038 inline static PVR_ERROR ADDON_SetEPGMaxFutureDays(const AddonInstance_PVR* instance,
3039 int futureDays)
3002 { 3040 {
3003 return static_cast<CInstancePVRClient*>(instance->toAddon->addonInstance) 3041 return static_cast<CInstancePVRClient*>(instance->toAddon->addonInstance)
3004 ->SetEPGTimeFrame(days); 3042 ->SetEPGMaxFutureDays(futureDays);
3005 } 3043 }
3006 3044
3007 inline static PVR_ERROR ADDON_CallEPGMenuHook(const AddonInstance_PVR* instance, 3045 inline static PVR_ERROR ADDON_CallEPGMenuHook(const AddonInstance_PVR* instance,
@@ -3364,7 +3402,7 @@ private:
3364 static_cast<CInstancePVRClient*>(instance->toAddon->addonInstance)->DemuxFlush(); 3402 static_cast<CInstancePVRClient*>(instance->toAddon->addonInstance)->DemuxFlush();
3365 } 3403 }
3366 3404
3367 inline static DemuxPacket* ADDON_DemuxRead(const AddonInstance_PVR* instance) 3405 inline static DEMUX_PACKET* ADDON_DemuxRead(const AddonInstance_PVR* instance)
3368 { 3406 {
3369 return static_cast<CInstancePVRClient*>(instance->toAddon->addonInstance)->DemuxRead(); 3407 return static_cast<CInstancePVRClient*>(instance->toAddon->addonInstance)->DemuxRead();
3370 } 3408 }
diff --git a/xbmc/addons/kodi-dev-kit/include/kodi/addon-instance/Screensaver.h b/xbmc/addons/kodi-dev-kit/include/kodi/addon-instance/Screensaver.h
index 4902fcb..d4ac1aa 100644
--- a/xbmc/addons/kodi-dev-kit/include/kodi/addon-instance/Screensaver.h
+++ b/xbmc/addons/kodi-dev-kit/include/kodi/addon-instance/Screensaver.h
@@ -41,7 +41,7 @@ namespace addon
41/// * <b><c>Render()</c></b> - Called at render time 41/// * <b><c>Render()</c></b> - Called at render time
42/// * <b><c>Stop()</c></b> - Called when the screensaver has no work 42/// * <b><c>Stop()</c></b> - Called when the screensaver has no work
43/// 43///
44/// Additionally, there are several \ref cpp_kodi_addon_screensaver_CB "other functions" 44/// Additionally, there are several @ref cpp_kodi_addon_screensaver_CB "other functions"
45/// available in which the child class can ask about the current hardware, 45/// available in which the child class can ask about the current hardware,
46/// including the device, display and several other parts. 46/// including the device, display and several other parts.
47/// 47///
diff --git a/xbmc/addons/kodi-dev-kit/include/kodi/addon-instance/VFS.h b/xbmc/addons/kodi-dev-kit/include/kodi/addon-instance/VFS.h
index 177bf72..dbfb833 100644
--- a/xbmc/addons/kodi-dev-kit/include/kodi/addon-instance/VFS.h
+++ b/xbmc/addons/kodi-dev-kit/include/kodi/addon-instance/VFS.h
@@ -152,7 +152,7 @@ private:
152 152
153//############################################################################## 153//##############################################################################
154/// @defgroup cpp_kodi_addon_vfs_Defs Definitions, structures and enumerators 154/// @defgroup cpp_kodi_addon_vfs_Defs Definitions, structures and enumerators
155/// \ingroup cpp_kodi_addon_vfs 155/// @ingroup cpp_kodi_addon_vfs
156/// @brief **VFS add-on general variables** 156/// @brief **VFS add-on general variables**
157/// 157///
158/// Used to exchange the available options between Kodi and addon. 158/// Used to exchange the available options between Kodi and addon.
@@ -161,7 +161,7 @@ private:
161 161
162//============================================================================== 162//==============================================================================
163/// 163///
164/// \addtogroup cpp_kodi_addon_vfs 164/// @addtogroup cpp_kodi_addon_vfs
165/// @brief \cpp_class{ kodi::addon::CInstanceVFS } 165/// @brief \cpp_class{ kodi::addon::CInstanceVFS }
166/// **Virtual Filesystem (VFS) add-on instance** 166/// **Virtual Filesystem (VFS) add-on instance**
167/// 167///
diff --git a/xbmc/addons/kodi-dev-kit/include/kodi/addon-instance/VideoCodec.h b/xbmc/addons/kodi-dev-kit/include/kodi/addon-instance/VideoCodec.h
index 12893db..7cf58a0 100644
--- a/xbmc/addons/kodi-dev-kit/include/kodi/addon-instance/VideoCodec.h
+++ b/xbmc/addons/kodi-dev-kit/include/kodi/addon-instance/VideoCodec.h
@@ -9,241 +9,456 @@
9#pragma once 9#pragma once
10 10
11#include "../AddonBase.h" 11#include "../AddonBase.h"
12#include "../StreamCrypto.h" 12#include "../c-api/addon-instance/video_codec.h"
13#include "../StreamCodec.h" 13#include "inputstream/DemuxPacket.h"
14#include "inputstream/StreamCodec.h"
15#include "inputstream/StreamCrypto.h"
14 16
15#ifdef BUILD_KODI_ADDON 17#ifdef __cplusplus
16#include "../DemuxPacket.h"
17#else
18#include "cores/VideoPlayer/Interface/Addon/DemuxPacket.h"
19#endif
20 18
21extern "C" 19namespace kodi
20{
21namespace addon
22{ 22{
23 enum VIDEOCODEC_FORMAT
24 {
25 UnknownVideoFormat = 0,
26 VideoFormatYV12,
27 VideoFormatI420,
28 MaxVideoFormats
29 };
30
31 23
32 struct VIDEOCODEC_INITDATA 24class CInstanceVideoCodec;
25
26//==============================================================================
27/// @defgroup cpp_kodi_addon_videocodec_Defs_VideoCodecInitdata class VideoCodecInitdata
28/// @ingroup cpp_kodi_addon_videocodec_Defs
29/// @brief Initialization data to open a video codec stream.
30///
31/// ----------------------------------------------------------------------------
32///
33/// @copydetails cpp_kodi_addon_videocodec_Defs_VideoCodecInitdata_Help
34///
35///@{
36class ATTRIBUTE_HIDDEN VideoCodecInitdata
37 : public CStructHdl<VideoCodecInitdata, VIDEOCODEC_INITDATA>
38{
39 /*! \cond PRIVATE */
40 friend class CInstanceVideoCodec;
41 /*! \endcond */
42
43public:
44 /// @defgroup cpp_kodi_addon_videocodec_Defs_VideoCodecInitdata_Help Value Help
45 /// @ingroup cpp_kodi_addon_videocodec_Defs_VideoCodecInitdata
46 ///
47 /// <b>The following table contains values that can be set with @ref cpp_kodi_addon_videocodec_Defs_VideoCodecInitdata :</b>
48 /// | Name | Type | Get call
49 /// |------|------|----------
50 /// | **Codec type** | `VIDEOCODEC_TYPE` | @ref VideoCodecInitdata::GetCodecType "GetCodecType"
51 /// | **Codec profile** | `STREAMCODEC_PROFILE` | @ref VideoCodecInitdata::GetCodecProfile "GetCodecProfile"
52 /// | **Video formats** | `std::vector<VIDEOCODEC_FORMAT>` | @ref VideoCodecInitdata::GetVideoFormats "GetVideoFormats"
53 /// | **Width** | `uint32_t` | @ref VideoCodecInitdata::GetWidth "GetWidth"
54 /// | **Height** | `uint32_t` | @ref VideoCodecInitdata::GetHeight "GetHeight"
55 /// | **Extra data** | `const uint8_t*` | @ref VideoCodecInitdata::GetExtraData "GetExtraData"
56 /// | **Extra data size** | `unsigned int` | @ref VideoCodecInitdata::GetExtraDataSize "GetExtraDataSize"
57 /// | **Crypto session** | `kodi::addon::StreamCryptoSession` | @ref VideoCodecInitdata::GetCryptoSession "GetCryptoSession"
58 ///
59
60 /// @addtogroup cpp_kodi_addon_videocodec_Defs_VideoCodecInitdata
61 ///@{
62
63 /// @brief The codec type required by Kodi to process the stream.
64 ///
65 /// See @ref VIDEOCODEC_TYPE for possible values.
66 VIDEOCODEC_TYPE GetCodecType() const { return m_cStructure->codec; }
67
68 /// @brief Used profiles for non-scalable 2D video
69 STREAMCODEC_PROFILE GetCodecProfile() const { return m_cStructure->codecProfile; }
70
71 /// @brief The video stream representations requested by Kodi
72 ///
73 /// This contains a list of the required video formats. One of them has to
74 /// select the addon to return the created image.
75 ///
76 std::vector<VIDEOCODEC_FORMAT> GetVideoFormats() const
33 { 77 {
34 enum Codec { 78 std::vector<VIDEOCODEC_FORMAT> formats;
35 CodecUnknown = 0, 79 unsigned int i = 0;
36 CodecVp8, 80 while (i < VIDEOCODEC_FORMAT_MAXFORMATS &&
37 CodecH264, 81 m_cStructure->videoFormats[i] != VIDEOCODEC_FORMAT_UNKNOWN)
38 CodecVp9 82 formats.emplace_back(m_cStructure->videoFormats[i++]);
39 } codec; 83 if (formats.empty())
40 84 formats.emplace_back(VIDEOCODEC_FORMAT_UNKNOWN);
41 STREAMCODEC_PROFILE codecProfile; 85 return formats;
42 86 }
43 //UnknownVideoFormat is terminator 87
44 VIDEOCODEC_FORMAT *videoFormats; 88 /// @brief Picture width.
45 89 uint32_t GetWidth() const { return m_cStructure->width; }
46 uint32_t width, height; 90
47 91 /// @brief Picture height.
48 const uint8_t *extraData; 92 uint32_t GetHeight() const { return m_cStructure->height; }
49 unsigned int extraDataSize; 93
50 94 /// @brief Depending on the required decoding, additional data given by the stream.
51 CRYPTO_INFO cryptoInfo; 95 const uint8_t* GetExtraData() const { return m_cStructure->extraData; }
52 }; 96
53 97 /// @brief Size of the data given with @ref extraData.
54 struct VIDEOCODEC_PICTURE 98 unsigned int GetExtraDataSize() const { return m_cStructure->extraDataSize; }
99
100 /// @brief **Data to manage stream cryptography**\n
101 /// To get class structure manages any encryption values required in order to have
102 /// them available in their stream processing.
103 ///
104 /// ----------------------------------------------------------------------------
105 ///
106 /// @copydetails cpp_kodi_addon_inputstream_Defs_Info_StreamCryptoSession_Help
107 ///
108 kodi::addon::StreamCryptoSession GetCryptoSession() const { return &m_cStructure->cryptoSession; }
109
110 ///@}
111
112private:
113 VideoCodecInitdata() = delete;
114 VideoCodecInitdata(const VideoCodecInitdata& session) : CStructHdl(session) {}
115 VideoCodecInitdata(const VIDEOCODEC_INITDATA* session) : CStructHdl(session) {}
116 VideoCodecInitdata(VIDEOCODEC_INITDATA* session) : CStructHdl(session) {}
117};
118///@}
119//------------------------------------------------------------------------------
120
121//##############################################################################
122/// @defgroup cpp_kodi_addon_videocodec_Defs Definitions, structures and enumerators
123/// @ingroup cpp_kodi_addon_videocodec
124/// @brief **Video codec add-on general variables**
125///
126/// Used to exchange the available options between Kodi and addon.
127///
128///
129
130//============================================================================
131///
132/// @addtogroup cpp_kodi_addon_videocodec
133/// @brief \cpp_class{ kodi::addon::CInstanceVideoCodec }
134/// **Video codec add-on instance**
135///
136/// This is an addon instance class to add an additional video decoder to Kodi
137/// using addon.
138///
139/// This means that either a new type of decoding can be introduced to an input
140/// stream add-on that requires special types of decoding.
141///
142/// When using the inputstream addon, @ref cpp_kodi_addon_inputstream_Defs_Interface_InputstreamInfo
143/// to @ref cpp_kodi_addon_inputstream_Defs_Info is used to declare that the
144/// decoder stored in the addon is used.
145///
146/// @note At the moment this can only be used together with input stream addons,
147/// independent use as a codec addon is not yet possible.
148///
149/// Include the header @ref VideoCodec.h "#include <kodi/addon-instance/VideoCodec.h>"
150/// to use this class.
151///
152/// --------------------------------------------------------------------------
153///
154/// **Example:**
155/// This as an example when used together with @ref cpp_kodi_addon_inputstream "kodi::addon::CInstanceInputStream".
156///
157/// ~~~~~~~~~~~~~{.cpp}
158/// #include <kodi/addon-instance/Inputstream.h>
159/// #include <kodi/addon-instance/VideoCodec.h>
160///
161/// class CMyVideoCodec : public kodi::addon::CInstanceVideoCodec
162/// {
163/// public:
164/// CMyVideoCodec(KODI_HANDLE instance, CMyInputstream* inputstream);
165/// ...
166///
167/// private:
168/// CMyInputstream* m_inputstream;
169/// };
170///
171/// CMyVideoCodec::CMyVideoCodec(KODI_HANDLE instance,
172/// const std::string& version,
173/// CMyInputstream* inputstream)
174/// : kodi::addon::CInstanceVideoCodec(instance, version),
175/// m_inputstream(inputstream)
176/// {
177/// ...
178/// }
179/// ...
180///
181/// //----------------------------------------------------------------------
182///
183/// class CMyInputstream : public kodi::addon::CInstanceInputStream
184/// {
185/// public:
186/// CMyInputstream(KODI_HANDLE instance, const std::string& kodiVersion);
187///
188/// ADDON_STATUS CreateInstance(int instanceType,
189/// std::string instanceID,
190/// KODI_HANDLE instance,
191/// const std::string& version,
192/// KODI_HANDLE& addonInstance) override;
193/// ...
194/// };
195///
196/// CMyInputstream::CMyInputstream(KODI_HANDLE instance, const std::string& kodiVersion)
197/// : kodi::addon::CInstanceInputStream(instance, kodiVersion)
198/// {
199/// ...
200/// }
201///
202/// ADDON_STATUS CMyInputstream::CreateInstance(int instanceType,
203/// std::string instanceID,
204/// KODI_HANDLE instance,
205/// const std::string& version,
206/// KODI_HANDLE& addonInstance)
207/// {
208/// if (instanceType == ADDON_INSTANCE_VIDEOCODEC)
209/// {
210/// addonInstance = new CMyVideoCodec(instance, version, this);
211/// return ADDON_STATUS_OK;
212/// }
213/// return ADDON_STATUS_NOT_IMPLEMENTED;
214/// }
215///
216/// ...
217///
218/// //----------------------------------------------------------------------
219///
220/// class CMyAddon : public kodi::addon::CAddonBase
221/// {
222/// public:
223/// CMyAddon() { }
224/// ADDON_STATUS CreateInstance(int instanceType,
225/// std::string instanceID,
226/// KODI_HANDLE instance,
227/// const std::string& version,
228/// KODI_HANDLE& addonInstance) override;
229/// };
230///
231/// // If you use only one instance in your add-on, can be instanceType and
232/// // instanceID ignored
233/// ADDON_STATUS CMyAddon::CreateInstance(int instanceType,
234/// std::string instanceID,
235/// KODI_HANDLE instance,
236/// const std::string& version,
237/// KODI_HANDLE& addonInstance)
238/// {
239/// if (instanceType == ADDON_INSTANCE_INPUTSTREAM)
240/// {
241/// kodi::Log(ADDON_LOG_NOTICE, "Creating my Inputstream");
242/// addonInstance = new CMyInputstream(instance, version);
243/// return ADDON_STATUS_OK;
244/// }
245/// else if (...)
246/// {
247/// ...
248/// }
249/// return ADDON_STATUS_UNKNOWN;
250/// }
251///
252/// ADDONCREATOR(CMyAddon)
253/// ~~~~~~~~~~~~~
254///
255/// The destruction of the example class `CMyInputstream` is called from
256/// Kodi's header. Manually deleting the add-on instance is not required.
257///
258///
259class ATTRIBUTE_HIDDEN CInstanceVideoCodec : public IAddonInstance
260{
261public:
262 //============================================================================
263 /// @ingroup cpp_kodi_addon_videocodec
264 /// @brief Video codec class constructor used to support multiple instance
265 /// types
266 ///
267 /// @param[in] instance The instance value given to <b>`kodi::addon::CAddonBase::CreateInstance(...)`</b>,
268 /// or by a inputstream instance if them declared as parent.
269 /// @param[in] kodiVersion [opt] Version used in Kodi for this instance, to
270 /// allow compatibility to older Kodi versions.
271 ///
272 explicit CInstanceVideoCodec(KODI_HANDLE instance, const std::string& kodiVersion = "")
273 : IAddonInstance(ADDON_INSTANCE_VIDEOCODEC,
274 !kodiVersion.empty() ? kodiVersion
275 : GetKodiTypeVersion(ADDON_INSTANCE_VIDEOCODEC))
55 { 276 {
56 enum VideoPlane { 277 if (CAddonBase::m_interface->globalSingleInstance != nullptr)
57 YPlane = 0, 278 throw std::logic_error("kodi::addon::CInstanceVideoCodec: Creation of multiple together with "
58 UPlane, 279 "single instance way is not allowed!");
59 VPlane, 280
60 MaxPlanes = 3, 281 SetAddonStruct(instance);
61 }; 282 }
62 283 //----------------------------------------------------------------------------
63 enum Flags : uint32_t { 284
64 FLAG_DROP, 285 //============================================================================
65 FLAG_DRAIN 286 /// @ingroup cpp_kodi_addon_videocodec
66 }; 287 /// @brief Destructor
67 288 ///
68 VIDEOCODEC_FORMAT videoFormat; 289 ~CInstanceVideoCodec() override = default;
69 uint32_t flags; 290 //----------------------------------------------------------------------------
70 291
71 uint32_t width, height; 292 //============================================================================
72 293 /// @ingroup cpp_kodi_addon_videocodec
73 uint8_t *decodedData; 294 /// @brief Open the decoder, returns true on success
74 size_t decodedDataSize; 295 ///
75 296 /// Decoders not capable of running multiple instances should return false in case
76 uint32_t planeOffsets[VideoPlane::MaxPlanes]; 297 /// there is already a instance open.
77 uint32_t stride[VideoPlane::MaxPlanes]; 298 ///
78 299 /// @param[in] initData Video codec init data
79 int64_t pts; 300 /// @return true if successfully done
80 301 ///
81 KODI_HANDLE videoBufferHandle; //< will be passed in release_frame_buffer 302 ///
82 }; 303 /// ----------------------------------------------------------------------------
83 304 ///
84 enum VIDEOCODEC_RETVAL 305 /// @copydetails cpp_kodi_addon_videocodec_Defs_VideoCodecInitdata_Help
306 ///
307 virtual bool Open(const kodi::addon::VideoCodecInitdata& initData) { return false; }
308 //----------------------------------------------------------------------------
309
310 //============================================================================
311 /// @ingroup cpp_kodi_addon_videocodec
312 /// @brief Reconfigure the decoder, returns true on success
313 ///
314 /// Decoders not capable of runnung multiple instances may be capable of reconfiguring
315 /// the running instance. If Reconfigure returns false, player will close / open
316 /// the decoder
317 ///
318 /// @param[in] initData Video codec reconfigure data
319 /// @return true if successfully done
320 ///
321 virtual bool Reconfigure(const kodi::addon::VideoCodecInitdata& initData) { return false; }
322 //----------------------------------------------------------------------------
323
324 //============================================================================
325 /// @ingroup cpp_kodi_addon_videocodec
326 /// @brief add data, decoder has to consume the entire packet
327 ///
328 /// @param[in] packet Data to process for decode
329 /// @return true if the packet was consumed or if resubmitting it is useless
330 ///
331 virtual bool AddData(const DEMUX_PACKET& packet) { return false; }
332 //----------------------------------------------------------------------------
333
334 //============================================================================
335 /// @ingroup cpp_kodi_addon_videocodec
336 /// @brief GetPicture controls decoding.
337 ///
338 /// Player calls it on every cycle it can signal a picture, request a buffer,
339 /// or return none, if nothing applies the data is valid until the next
340 /// GetPicture return @ref VC_PICTURE
341 ///
342 /// @param[in,out] Structure which contains the necessary data
343 /// @return The with @ref VIDEOCODEC_RETVAL return values
344 ///
345 virtual VIDEOCODEC_RETVAL GetPicture(VIDEOCODEC_PICTURE& picture) { return VC_ERROR; }
346 //----------------------------------------------------------------------------
347
348 //============================================================================
349 /// @ingroup cpp_kodi_addon_videocodec
350 /// @brief should return codecs name
351 ///
352 /// @return Codec name
353 ///
354 virtual const char* GetName() { return nullptr; }
355 //----------------------------------------------------------------------------
356
357 //============================================================================
358 /// @ingroup cpp_kodi_addon_videocodec
359 /// @brief Reset the decoder
360 ///
361 virtual void Reset() {}
362 //----------------------------------------------------------------------------
363
364 /*!
365 * @brief AddonToKodi interface
366 */
367
368 //============================================================================
369 /// @ingroup cpp_kodi_addon_videocodec
370 /// @brief All picture members can be expected to be set correctly except
371 /// decodedData and pts.
372 ///
373 /// GetFrameBuffer has to set decodedData to a valid memory address and return true.
374 ///
375 /// @param[out] picture The buffer, or unmodified if false is returned
376 /// @return In case buffer allocation fails, it return false.
377 ///
378 /// @note If this returns true, buffer must be freed using @ref ReleaseFrameBuffer().
379 ///
380 /// @remarks Only called from addon itself
381 ///
382 bool GetFrameBuffer(VIDEOCODEC_PICTURE& picture)
85 { 383 {
86 VC_NONE = 0, //< noop 384 return m_instanceData->toKodi->get_frame_buffer(m_instanceData->toKodi->kodiInstance, &picture);
87 VC_ERROR, //< an error occurred, no other messages will be returned 385 }
88 VC_BUFFER, //< the decoder needs more data 386 //----------------------------------------------------------------------------
89 VC_PICTURE, //< the decoder got a picture 387
90 VC_EOF, //< the decoder signals EOF 388 //============================================================================
91 }; 389 ///
92 390 /// @ingroup cpp_kodi_addon_videocodec
93 // this are properties given to the addon on create 391 /// @brief Release the with @ref GetFrameBuffer() given framebuffer.
94 // at this time we have no parameters for the addon 392 ///
95 typedef struct AddonProps_VideoCodec 393 /// @param[in] handle the on @ref VIDEOCODEC_PICTURE.videoBufferHandle defined buffer handle
394 ///
395 /// @remarks Only called from addon itself
396 ///
397 void ReleaseFrameBuffer(void* buffer)
96 { 398 {
97 int dummy; 399 return m_instanceData->toKodi->release_frame_buffer(m_instanceData->toKodi->kodiInstance,
98 } AddonProps_VideoCodec; 400 buffer);
401 }
402 //----------------------------------------------------------------------------
99 403
100 struct AddonInstance_VideoCodec; 404private:
101 typedef struct KodiToAddonFuncTable_VideoCodec 405 void SetAddonStruct(KODI_HANDLE instance)
102 { 406 {
103 KODI_HANDLE addonInstance; 407 if (instance == nullptr)
104 408 throw std::logic_error("kodi::addon::CInstanceVideoCodec: Creation with empty addon "
105 //! \brief Opens a codec 409 "structure not allowed, table must be given from Kodi!");
106 bool (__cdecl* open) (const AddonInstance_VideoCodec* instance, VIDEOCODEC_INITDATA *initData); 410
107 411 m_instanceData = static_cast<AddonInstance_VideoCodec*>(instance);
108 //! \brief Reconfigures a codec 412
109 bool (__cdecl* reconfigure) (const AddonInstance_VideoCodec* instance, VIDEOCODEC_INITDATA *initData); 413 m_instanceData->toAddon->addonInstance = this;
110 414 m_instanceData->toAddon->open = ADDON_Open;
111 //! \brief Feed codec if requested from GetPicture() (return VC_BUFFER) 415 m_instanceData->toAddon->reconfigure = ADDON_Reconfigure;
112 bool (__cdecl* add_data) (const AddonInstance_VideoCodec* instance, const DemuxPacket *packet); 416 m_instanceData->toAddon->add_data = ADDON_AddData;
113 417 m_instanceData->toAddon->get_picture = ADDON_GetPicture;
114 //! \brief Get a decoded picture / request new data 418 m_instanceData->toAddon->get_name = ADDON_GetName;
115 VIDEOCODEC_RETVAL (__cdecl* get_picture) (const AddonInstance_VideoCodec* instance, VIDEOCODEC_PICTURE *picture); 419 m_instanceData->toAddon->reset = ADDON_Reset;
420 }
421
422 inline static bool ADDON_Open(const AddonInstance_VideoCodec* instance,
423 VIDEOCODEC_INITDATA* initData)
424 {
425 return static_cast<CInstanceVideoCodec*>(instance->toAddon->addonInstance)->Open(initData);
426 }
116 427
117 //! \brief Get the name of this video decoder 428 inline static bool ADDON_Reconfigure(const AddonInstance_VideoCodec* instance,
118 const char *(__cdecl* get_name) (const AddonInstance_VideoCodec* instance); 429 VIDEOCODEC_INITDATA* initData)
430 {
431 return static_cast<CInstanceVideoCodec*>(instance->toAddon->addonInstance)
432 ->Reconfigure(initData);
433 }
119 434
120 //! \brief Reset the codec 435 inline static bool ADDON_AddData(const AddonInstance_VideoCodec* instance,
121 void (__cdecl* reset)(const AddonInstance_VideoCodec* instance); 436 const DEMUX_PACKET* packet)
122 } KodiToAddonFuncTable_VideoCodec; 437 {
438 return static_cast<CInstanceVideoCodec*>(instance->toAddon->addonInstance)->AddData(*packet);
439 }
123 440
124 typedef struct AddonToKodiFuncTable_VideoCodec 441 inline static VIDEOCODEC_RETVAL ADDON_GetPicture(const AddonInstance_VideoCodec* instance,
442 VIDEOCODEC_PICTURE* picture)
125 { 443 {
126 KODI_HANDLE kodiInstance; 444 return static_cast<CInstanceVideoCodec*>(instance->toAddon->addonInstance)
127 bool(*get_frame_buffer)(void* kodiInstance, VIDEOCODEC_PICTURE *picture); 445 ->GetPicture(*picture);
128 void(*release_frame_buffer)(void* kodiInstance, void *buffer); 446 }
129 } AddonToKodiFuncTable_VideoCodec;
130 447
131 typedef struct AddonInstance_VideoCodec 448 inline static const char* ADDON_GetName(const AddonInstance_VideoCodec* instance)
132 { 449 {
133 AddonProps_VideoCodec* props; 450 return static_cast<CInstanceVideoCodec*>(instance->toAddon->addonInstance)->GetName();
134 AddonToKodiFuncTable_VideoCodec* toKodi; 451 }
135 KodiToAddonFuncTable_VideoCodec* toAddon;
136 } AddonInstance_VideoCodec;
137}
138 452
139namespace kodi 453 inline static void ADDON_Reset(const AddonInstance_VideoCodec* instance)
140{
141 namespace addon
142 { 454 {
455 return static_cast<CInstanceVideoCodec*>(instance->toAddon->addonInstance)->Reset();
456 }
457
458 AddonInstance_VideoCodec* m_instanceData;
459};
143 460
144 class ATTRIBUTE_HIDDEN CInstanceVideoCodec : public IAddonInstance 461} // namespace addon
145 {
146 public:
147 explicit CInstanceVideoCodec(KODI_HANDLE instance, const std::string& kodiVersion = "")
148 : IAddonInstance(ADDON_INSTANCE_VIDEOCODEC,
149 !kodiVersion.empty() ? kodiVersion
150 : GetKodiTypeVersion(ADDON_INSTANCE_VIDEOCODEC))
151 {
152 if (CAddonBase::m_interface->globalSingleInstance != nullptr)
153 throw std::logic_error("kodi::addon::CInstanceVideoCodec: Creation of multiple together with single instance way is not allowed!");
154
155 SetAddonStruct(instance);
156 }
157
158 ~CInstanceVideoCodec() override = default;
159
160 //! \copydoc CInstanceVideoCodec::Open
161 virtual bool Open(VIDEOCODEC_INITDATA &initData) { return false; };
162
163 //! \copydoc CInstanceVideoCodec::Reconfigure
164 virtual bool Reconfigure(VIDEOCODEC_INITDATA &initData) { return false; };
165
166 //! \copydoc CInstanceVideoCodec::AddData
167 virtual bool AddData(const DemuxPacket &packet) { return false; };
168
169 //! \copydoc CInstanceVideoCodec::GetPicture
170 virtual VIDEOCODEC_RETVAL GetPicture(VIDEOCODEC_PICTURE &picture) { return VC_ERROR; };
171
172 //! \copydoc CInstanceVideoCodec::GetName
173 virtual const char *GetName() { return nullptr; };
174
175 //! \copydoc CInstanceVideoCodec::Reset
176 virtual void Reset() {};
177
178 /*!
179 * @brief AddonToKodi interface
180 */
181
182 //! \copydoc CInstanceVideoCodec::GetFrameBuffer
183 bool GetFrameBuffer(VIDEOCODEC_PICTURE &picture)
184 {
185 return m_instanceData->toKodi->get_frame_buffer(m_instanceData->toKodi->kodiInstance,
186 &picture);
187 }
188
189 //! \copydoc CInstanceVideoCodec::ReleaseFrameBuffer
190 void ReleaseFrameBuffer(void *buffer)
191 {
192 return m_instanceData->toKodi->release_frame_buffer(m_instanceData->toKodi->kodiInstance,
193 buffer);
194 }
195
196 private:
197 void SetAddonStruct(KODI_HANDLE instance)
198 {
199 if (instance == nullptr)
200 throw std::logic_error("kodi::addon::CInstanceVideoCodec: Creation with empty addon structure not allowed, table must be given from Kodi!");
201
202 m_instanceData = static_cast<AddonInstance_VideoCodec*>(instance);
203
204 m_instanceData->toAddon->addonInstance = this;
205 m_instanceData->toAddon->open = ADDON_Open;
206 m_instanceData->toAddon->reconfigure = ADDON_Reconfigure;
207 m_instanceData->toAddon->add_data = ADDON_AddData;
208 m_instanceData->toAddon->get_picture = ADDON_GetPicture;
209 m_instanceData->toAddon->get_name = ADDON_GetName;
210 m_instanceData->toAddon->reset = ADDON_Reset;
211 }
212
213 inline static bool ADDON_Open(const AddonInstance_VideoCodec* instance, VIDEOCODEC_INITDATA *initData)
214 {
215 return static_cast<CInstanceVideoCodec*>(instance->toAddon->addonInstance)->Open(*initData);
216 }
217
218 inline static bool ADDON_Reconfigure(const AddonInstance_VideoCodec* instance, VIDEOCODEC_INITDATA *initData)
219 {
220 return static_cast<CInstanceVideoCodec*>(instance->toAddon->addonInstance)
221 ->Reconfigure(*initData);
222 }
223
224 inline static bool ADDON_AddData(const AddonInstance_VideoCodec* instance, const DemuxPacket *packet)
225 {
226 return static_cast<CInstanceVideoCodec*>(instance->toAddon->addonInstance)
227 ->AddData(*packet);
228 }
229
230 inline static VIDEOCODEC_RETVAL ADDON_GetPicture(const AddonInstance_VideoCodec* instance, VIDEOCODEC_PICTURE *picture)
231 {
232 return static_cast<CInstanceVideoCodec*>(instance->toAddon->addonInstance)
233 ->GetPicture(*picture);
234 }
235
236 inline static const char *ADDON_GetName(const AddonInstance_VideoCodec* instance)
237 {
238 return static_cast<CInstanceVideoCodec*>(instance->toAddon->addonInstance)->GetName();
239 }
240
241 inline static void ADDON_Reset(const AddonInstance_VideoCodec* instance)
242 {
243 return static_cast<CInstanceVideoCodec*>(instance->toAddon->addonInstance)->Reset();
244 }
245
246 AddonInstance_VideoCodec* m_instanceData;
247 };
248 } // namespace addon
249} // namespace kodi 462} // namespace kodi
463
464#endif /* __cplusplus */
diff --git a/xbmc/addons/kodi-dev-kit/include/kodi/addon-instance/Visualization.h b/xbmc/addons/kodi-dev-kit/include/kodi/addon-instance/Visualization.h
index 7b1db65..1dddea2 100644
--- a/xbmc/addons/kodi-dev-kit/include/kodi/addon-instance/Visualization.h
+++ b/xbmc/addons/kodi-dev-kit/include/kodi/addon-instance/Visualization.h
@@ -721,7 +721,7 @@ public:
721 inline void TransferPresets(const std::vector<std::string>& presets) 721 inline void TransferPresets(const std::vector<std::string>& presets)
722 { 722 {
723 m_instanceData->toKodi->clear_presets(m_instanceData->toKodi->kodiInstance); 723 m_instanceData->toKodi->clear_presets(m_instanceData->toKodi->kodiInstance);
724 for (auto it : presets) 724 for (const auto& it : presets)
725 m_instanceData->toKodi->transfer_preset(m_instanceData->toKodi->kodiInstance, it.c_str()); 725 m_instanceData->toKodi->transfer_preset(m_instanceData->toKodi->kodiInstance, it.c_str());
726 } 726 }
727 //---------------------------------------------------------------------------- 727 //----------------------------------------------------------------------------
@@ -915,7 +915,7 @@ private:
915 std::vector<std::string> presets; 915 std::vector<std::string> presets;
916 if (thisClass->GetPresets(presets)) 916 if (thisClass->GetPresets(presets))
917 { 917 {
918 for (auto it : presets) 918 for (const auto& it : presets)
919 thisClass->m_instanceData->toKodi->transfer_preset(addon->toKodi->kodiInstance, it.c_str()); 919 thisClass->m_instanceData->toKodi->transfer_preset(addon->toKodi->kodiInstance, it.c_str());
920 } 920 }
921 921
diff --git a/xbmc/addons/kodi-dev-kit/include/kodi/addon-instance/inputstream/CMakeLists.txt b/xbmc/addons/kodi-dev-kit/include/kodi/addon-instance/inputstream/CMakeLists.txt
new file mode 100644
index 0000000..a551b4b
--- /dev/null
+++ b/xbmc/addons/kodi-dev-kit/include/kodi/addon-instance/inputstream/CMakeLists.txt
@@ -0,0 +1,8 @@
1set(HEADERS DemuxPacket.h
2 StreamCodec.h
3 StreamConstants.h
4 TimingConstants.h)
5
6if(NOT ENABLE_STATIC_LIBS)
7 core_add_library(addons_kodi-dev-kit_include_kodi_addon-instance_inputstream)
8endif()
diff --git a/xbmc/addons/kodi-dev-kit/include/kodi/addon-instance/inputstream/DemuxPacket.h b/xbmc/addons/kodi-dev-kit/include/kodi/addon-instance/inputstream/DemuxPacket.h
new file mode 100644
index 0000000..f965b9f
--- /dev/null
+++ b/xbmc/addons/kodi-dev-kit/include/kodi/addon-instance/inputstream/DemuxPacket.h
@@ -0,0 +1,12 @@
1/*
2 * Copyright (C) 2005-2020 Team Kodi
3 * This file is part of Kodi - https://kodi.tv
4 *
5 * SPDX-License-Identifier: GPL-2.0-or-later
6 * See LICENSES/README.md for more information.
7 */
8
9#pragma once
10
11#include "TimingConstants.h"
12#include "../../c-api/addon-instance/inputstream/demux_packet.h"
diff --git a/xbmc/addons/kodi-dev-kit/include/kodi/addon-instance/inputstream/StreamCodec.h b/xbmc/addons/kodi-dev-kit/include/kodi/addon-instance/inputstream/StreamCodec.h
new file mode 100644
index 0000000..e80e2ca
--- /dev/null
+++ b/xbmc/addons/kodi-dev-kit/include/kodi/addon-instance/inputstream/StreamCodec.h
@@ -0,0 +1,11 @@
1/*
2 * Copyright (C) 2005-2020 Team Kodi
3 * This file is part of Kodi - https://kodi.tv
4 *
5 * SPDX-License-Identifier: GPL-2.0-or-later
6 * See LICENSES/README.md for more information.
7 */
8
9#pragma once
10
11#include "../../c-api/addon-instance/inputstream/stream_codec.h"
diff --git a/xbmc/addons/kodi-dev-kit/include/kodi/addon-instance/inputstream/StreamConstants.h b/xbmc/addons/kodi-dev-kit/include/kodi/addon-instance/inputstream/StreamConstants.h
new file mode 100644
index 0000000..200631b
--- /dev/null
+++ b/xbmc/addons/kodi-dev-kit/include/kodi/addon-instance/inputstream/StreamConstants.h
@@ -0,0 +1,11 @@
1/*
2 * Copyright (C) 2005-2020 Team Kodi
3 * This file is part of Kodi - https://kodi.tv
4 *
5 * SPDX-License-Identifier: GPL-2.0-or-later
6 * See LICENSES/README.md for more information.
7 */
8
9#pragma once
10
11#include "../../c-api/addon-instance/inputstream/stream_constants.h"
diff --git a/xbmc/addons/kodi-dev-kit/include/kodi/addon-instance/inputstream/StreamCrypto.h b/xbmc/addons/kodi-dev-kit/include/kodi/addon-instance/inputstream/StreamCrypto.h
new file mode 100644
index 0000000..8a85121
--- /dev/null
+++ b/xbmc/addons/kodi-dev-kit/include/kodi/addon-instance/inputstream/StreamCrypto.h
@@ -0,0 +1,99 @@
1/*
2 * Copyright (C) 2005-2020 Team Kodi
3 * This file is part of Kodi - https://kodi.tv
4 *
5 * SPDX-License-Identifier: GPL-2.0-or-later
6 * See LICENSES/README.md for more information.
7 */
8
9#pragma once
10
11#include "../../c-api/addon-instance/inputstream/stream_crypto.h"
12#include "../../AddonBase.h"
13
14#ifdef __cplusplus
15
16namespace kodi
17{
18namespace addon
19{
20
21class CInstanceInputStream;
22class InputstreamInfo;
23class VideoCodecInitdata;
24
25//==============================================================================
26/// @defgroup cpp_kodi_addon_inputstream_Defs_StreamEncryption_StreamCryptoSession class StreamCryptoSession
27/// @ingroup cpp_kodi_addon_inputstream_Defs_StreamEncryption
28/// @brief **Data to manage stream cryptography**\n
29/// This class structure manages any encryption values required in order to have
30/// them available in their stream processing.
31///
32/// Used on inputstream by @ref kodi::addon::InputstreamInfo::SetCryptoSession /
33/// @ref kodi::addon::InputstreamInfo::GetCryptoSession and are given to the
34/// used video codec to decrypt related data.
35///
36/// ----------------------------------------------------------------------------
37///
38/// @copydetails cpp_kodi_addon_inputstream_Defs_Info_StreamCryptoSession_Help
39///
40///@{
41class ATTRIBUTE_HIDDEN StreamCryptoSession
42 : public CStructHdl<StreamCryptoSession, STREAM_CRYPTO_SESSION>
43{
44 /*! \cond PRIVATE */
45 friend class CInstanceInputStream;
46 friend class InputstreamInfo;
47 friend class VideoCodecInitdata;
48 /*! \endcond */
49
50public:
51 /*! \cond PRIVATE */
52 StreamCryptoSession() { memset(m_cStructure, 0, sizeof(STREAM_CRYPTO_SESSION)); }
53 StreamCryptoSession(const StreamCryptoSession& session) : CStructHdl(session) {}
54 /*! \endcond */
55
56 /// @defgroup cpp_kodi_addon_inputstream_Defs_Info_StreamCryptoSession_Help Value Help
57 /// @ingroup cpp_kodi_addon_inputstream_Defs_Info_StreamCryptoSession
58 ///
59 /// <b>The following table contains values that can be set with @ref cpp_kodi_addon_inputstream_Defs_Info_StreamCryptoSession :</b>
60 /// | Name | Type | Set call | Get call
61 /// |------|------|----------|----------
62 /// | **Keysystem for encrypted media** | @ref STREAM_CRYPTO_KEY_SYSTEM | @ref StreamCryptoSession::SetKeySystem "SetKeySystem" | @ref StreamCryptoSession::GetKeySystem "GetKeySystem"
63 /// | **Flags for special conditions** | `uint8_t` | @ref StreamCryptoSession::SetFlags "SetFlags" | @ref StreamCryptoSession::GetFlags "GetFlags"
64 /// | **Crypto session key id** | `std::string` | @ref StreamCryptoSession::SetSessionId "SetSessionId" | @ref StreamCryptoSession::GetSessionId "GetSessionId"
65
66 /// @brief To set keysystem for encrypted media, @ref STREAM_CRYPTO_KEY_SYSTEM_NONE for
67 /// unencrypted media.
68 ///
69 /// See @ref STREAM_CRYPTO_KEY_SYSTEM for available options.
70 void SetKeySystem(STREAM_CRYPTO_KEY_SYSTEM keySystem) { m_cStructure->keySystem = keySystem; }
71
72 /// @brief Get keysystem for encrypted media.
73 STREAM_CRYPTO_KEY_SYSTEM GetKeySystem() const { return m_cStructure->keySystem; }
74
75 /// @brief Set bit flags to use special conditions, see @ref STREAM_CRYPTO_FLAGS
76 /// for available flags.
77 void SetFlags(uint8_t flags) { m_cStructure->flags = flags; }
78
79 /// @brief Get flags for special conditions.
80 uint8_t GetFlags() const { return m_cStructure->flags; }
81
82 /// @brief To set the crypto session key identifier.
83 void SetSessionId(const std::string& sessionId)
84 {
85 strncpy(m_cStructure->sessionId, sessionId.c_str(), sizeof(m_cStructure->sessionId) - 1);
86 }
87
88 /// @brief To get the crypto session key identifier.
89 std::string GetSessionId() const { return m_cStructure->sessionId; }
90
91private:
92 StreamCryptoSession(const STREAM_CRYPTO_SESSION* session) : CStructHdl(session) {}
93 StreamCryptoSession(STREAM_CRYPTO_SESSION* session) : CStructHdl(session) {}
94};
95
96} /* namespace addon */
97} /* namespace kodi */
98
99#endif /* __cplusplus */
diff --git a/xbmc/addons/kodi-dev-kit/include/kodi/addon-instance/inputstream/TimingConstants.h b/xbmc/addons/kodi-dev-kit/include/kodi/addon-instance/inputstream/TimingConstants.h
new file mode 100644
index 0000000..22f8952
--- /dev/null
+++ b/xbmc/addons/kodi-dev-kit/include/kodi/addon-instance/inputstream/TimingConstants.h
@@ -0,0 +1,59 @@
1/*
2 * Copyright (C) 2005-2020 Team Kodi
3 * This file is part of Kodi - https://kodi.tv
4 *
5 * SPDX-License-Identifier: GPL-2.0-or-later
6 * See LICENSES/README.md for more information.
7 */
8
9#pragma once
10
11#include "../../c-api/addon-instance/inputstream/timing_constants.h"
12
13#ifdef __cplusplus
14
15// Unset the on timing_constants.h given defines
16#undef STREAM_TIME_TO_MSEC
17#undef STREAM_SEC_TO_TIME
18#undef STREAM_MSEC_TO_TIME
19
20/// @ingroup cpp_kodi_addon_inputstream_Defs_TimingConstants
21/// @brief Converts a stream time to milliseconds as an integer value.
22///
23/// @param[in] x Stream time
24/// @return Milliseconds
25///
26/// @note Within "C" code this is used as `#define`.
27///
28constexpr int STREAM_TIME_TO_MSEC(double x)
29{
30 return static_cast<int>(x * 1000 / STREAM_TIME_BASE);
31}
32
33/// @ingroup cpp_kodi_addon_inputstream_Defs_TimingConstants
34/// @brief Converts a time in seconds to the used stream time format.
35///
36/// @param[in] x Seconds
37/// @return Stream time
38///
39/// @note Within "C" code this is used as `#define`.
40///
41constexpr double STREAM_SEC_TO_TIME(double x)
42{
43 return x * STREAM_TIME_BASE;
44}
45
46/// @ingroup cpp_kodi_addon_inputstream_Defs_TimingConstants
47/// @brief Converts a time in milliseconds to the used stream time format.
48///
49/// @param[in] x Milliseconds
50/// @return Stream time
51///
52/// @note Within "C" code this is used as `#define`.
53///
54constexpr double STREAM_MSEC_TO_TIME(double x)
55{
56 return x * STREAM_TIME_BASE / 1000;
57}
58
59#endif /* __cplusplus */
diff --git a/xbmc/addons/kodi-dev-kit/include/kodi/addon-instance/peripheral/PeripheralUtils.h b/xbmc/addons/kodi-dev-kit/include/kodi/addon-instance/peripheral/PeripheralUtils.h
index febaeb9..1a6cc63 100644
--- a/xbmc/addons/kodi-dev-kit/include/kodi/addon-instance/peripheral/PeripheralUtils.h
+++ b/xbmc/addons/kodi-dev-kit/include/kodi/addon-instance/peripheral/PeripheralUtils.h
@@ -806,7 +806,7 @@ struct DriverPrimitive
806{ 806{
807protected: 807protected:
808 /*! 808 /*!
809 * \brief Construct a driver primitive of the specified type 809 * @brief Construct a driver primitive of the specified type
810 */ 810 */
811 DriverPrimitive(JOYSTICK_DRIVER_PRIMITIVE_TYPE type, unsigned int driverIndex) 811 DriverPrimitive(JOYSTICK_DRIVER_PRIMITIVE_TYPE type, unsigned int driverIndex)
812 : m_type(type), m_driverIndex(driverIndex) 812 : m_type(type), m_driverIndex(driverIndex)
diff --git a/xbmc/addons/kodi-dev-kit/include/kodi/addon-instance/pvr/Stream.h b/xbmc/addons/kodi-dev-kit/include/kodi/addon-instance/pvr/Stream.h
index 5613947..4241c23 100644
--- a/xbmc/addons/kodi-dev-kit/include/kodi/addon-instance/pvr/Stream.h
+++ b/xbmc/addons/kodi-dev-kit/include/kodi/addon-instance/pvr/Stream.h
@@ -166,7 +166,7 @@ public:
166 m_cStructure->strLanguage[0] = language[0]; 166 m_cStructure->strLanguage[0] = language[0];
167 m_cStructure->strLanguage[1] = language[1]; 167 m_cStructure->strLanguage[1] = language[1];
168 m_cStructure->strLanguage[2] = language[2]; 168 m_cStructure->strLanguage[2] = language[2];
169 m_cStructure->strLanguage[2] = 0; 169 m_cStructure->strLanguage[3] = 0;
170 } 170 }
171 171
172 /// @brief To get with @ref SetLanguage() changed values. 172 /// @brief To get with @ref SetLanguage() changed values.