summaryrefslogtreecommitdiffstats
path: root/xbmc/addons/kodi-dev-kit/include/kodi/addon-instance/Inputstream.h
diff options
context:
space:
mode:
Diffstat (limited to 'xbmc/addons/kodi-dev-kit/include/kodi/addon-instance/Inputstream.h')
-rw-r--r--xbmc/addons/kodi-dev-kit/include/kodi/addon-instance/Inputstream.h2302
1 files changed, 1703 insertions, 599 deletions
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 */