summaryrefslogtreecommitdiffstats
path: root/xbmc/addons/kodi-addon-dev-kit/include/kodi/addon-instance/Inputstream.h
diff options
context:
space:
mode:
Diffstat (limited to 'xbmc/addons/kodi-addon-dev-kit/include/kodi/addon-instance/Inputstream.h')
-rw-r--r--xbmc/addons/kodi-addon-dev-kit/include/kodi/addon-instance/Inputstream.h843
1 files changed, 520 insertions, 323 deletions
diff --git a/xbmc/addons/kodi-addon-dev-kit/include/kodi/addon-instance/Inputstream.h b/xbmc/addons/kodi-addon-dev-kit/include/kodi/addon-instance/Inputstream.h
index 252edbf..354806e 100644
--- a/xbmc/addons/kodi-addon-dev-kit/include/kodi/addon-instance/Inputstream.h
+++ b/xbmc/addons/kodi-addon-dev-kit/include/kodi/addon-instance/Inputstream.h
@@ -14,25 +14,31 @@
14 */ 14 */
15 15
16#include "../AddonBase.h" 16#include "../AddonBase.h"
17#include "../StreamCrypto.h"
18#include "../StreamCodec.h" 17#include "../StreamCodec.h"
18#include "../StreamCrypto.h"
19 19
20#ifdef BUILD_KODI_ADDON 20#ifdef BUILD_KODI_ADDON
21#include "../DemuxPacket.h" 21#include "../DemuxPacket.h"
22#include "../InputStreamConstants.h"
22#else 23#else
23#include "cores/VideoPlayer/Interface/Addon/DemuxPacket.h" 24#include "cores/VideoPlayer/Interface/Addon/DemuxPacket.h"
25#include "cores/VideoPlayer/Interface/Addon/InputStreamConstants.h"
24#endif 26#endif
25 27
26namespace kodi { namespace addon { class CInstanceInputStream; }} 28//Increment this level always if you add features which can lead to compile failures in the addon
29#define INPUTSTREAM_VERSION_LEVEL 2
27 30
28extern "C" { 31#ifdef __cplusplus
32extern "C"
33{
34#endif /* __cplusplus */
29 35
30 /*! 36 /*!
31 * @brief InputStream add-on capabilities. All capabilities are set to "false" as default. 37 * @brief InputStream add-on capabilities. All capabilities are set to "false" as default.
32 */ 38 */
33 struct INPUTSTREAM_CAPABILITIES 39 struct INPUTSTREAM_CAPABILITIES
34 { 40 {
35 enum MASKTYPE: uint32_t 41 enum MASKTYPE : uint32_t
36 { 42 {
37 /// supports interface IDemux 43 /// supports interface IDemux
38 SUPPORTS_IDEMUX = (1 << 0), 44 SUPPORTS_IDEMUX = (1 << 0),
@@ -50,7 +56,10 @@ extern "C" {
50 SUPPORTS_PAUSE = (1 << 4), 56 SUPPORTS_PAUSE = (1 << 4),
51 57
52 /// supports interface ITime 58 /// supports interface ITime
53 SUPPORTS_ITIME = (1 << 5) 59 SUPPORTS_ITIME = (1 << 5),
60
61 /// supports interface IChapter
62 SUPPORTS_ICHAPTER = (1 << 6),
54 }; 63 };
55 64
56 /// set of supported capabilities 65 /// set of supported capabilities
@@ -62,19 +71,18 @@ extern "C" {
62 */ 71 */
63 struct INPUTSTREAM 72 struct INPUTSTREAM
64 { 73 {
65 static const unsigned int MAX_INFO_COUNT = 8; 74 const char* m_strURL;
66 75 const char* m_mimeType;
67 const char *m_strURL;
68 76
69 unsigned int m_nCountInfoValues; 77 unsigned int m_nCountInfoValues;
70 struct LISTITEMPROPERTY 78 struct LISTITEMPROPERTY
71 { 79 {
72 const char *m_strKey; 80 const char* m_strKey;
73 const char *m_strValue; 81 const char* m_strValue;
74 } m_ListItemProperties[MAX_INFO_COUNT]; 82 } m_ListItemProperties[STREAM_MAX_PROPERTY_COUNT];
75 83
76 const char *m_libFolder; 84 const char* m_libFolder;
77 const char *m_profileFolder; 85 const char* m_profileFolder;
78 }; 86 };
79 87
80 /*! 88 /*!
@@ -82,23 +90,50 @@ extern "C" {
82 */ 90 */
83 struct INPUTSTREAM_IDS 91 struct INPUTSTREAM_IDS
84 { 92 {
85 static const unsigned int MAX_STREAM_COUNT = 32; 93 static const unsigned int MAX_STREAM_COUNT = 256;
86 unsigned int m_streamCount; 94 unsigned int m_streamCount;
87 unsigned int m_streamIds[MAX_STREAM_COUNT]; 95 unsigned int m_streamIds[MAX_STREAM_COUNT];
88 }; 96 };
89 97
90 /*! 98 /*!
99 * @brief MASTERING Metadata
100 */
101 struct INPUTSTREAM_MASTERING_METADATA
102 {
103 double primary_r_chromaticity_x;
104 double primary_r_chromaticity_y;
105 double primary_g_chromaticity_x;
106 double primary_g_chromaticity_y;
107 double primary_b_chromaticity_x;
108 double primary_b_chromaticity_y;
109 double white_point_chromaticity_x;
110 double white_point_chromaticity_y;
111 double luminance_max;
112 double luminance_min;
113 };
114
115 /*!
116 * @brief CONTENTLIGHT Metadata
117 */
118 struct INPUTSTREAM_CONTENTLIGHT_METADATA
119 {
120 uint64_t max_cll;
121 uint64_t max_fall;
122 };
123
124 /*!
91 * @brief stream properties 125 * @brief stream properties
92 */ 126 */
93 struct INPUTSTREAM_INFO 127 struct INPUTSTREAM_INFO
94 { 128 {
95 enum STREAM_TYPE 129 enum STREAM_TYPE
96 { 130 {
97 TYPE_NONE, 131 TYPE_NONE = 0,
98 TYPE_VIDEO, 132 TYPE_VIDEO,
99 TYPE_AUDIO, 133 TYPE_AUDIO,
100 TYPE_SUBTITLE, 134 TYPE_SUBTITLE,
101 TYPE_TELETEXT 135 TYPE_TELETEXT,
136 TYPE_RDS,
102 } m_streamType; 137 } m_streamType;
103 138
104 enum Codec_FEATURES : uint32_t 139 enum Codec_FEATURES : uint32_t
@@ -118,65 +153,130 @@ extern "C" {
118 FLAG_KARAOKE = 0x0020, 153 FLAG_KARAOKE = 0x0020,
119 FLAG_FORCED = 0x0040, 154 FLAG_FORCED = 0x0040,
120 FLAG_HEARING_IMPAIRED = 0x0080, 155 FLAG_HEARING_IMPAIRED = 0x0080,
121 FLAG_VISUAL_IMPAIRED = 0x0100 156 FLAG_VISUAL_IMPAIRED = 0x0100,
122 }; 157 };
123 158
124 enum INPUTSTREAM_COLORSPACE 159 // Keep in sync with AVColorSpace
125 { 160 enum COLORSPACE
126 COLORSPACE_UNKNOWN, 161 {
127 COLORSPACE_BT709, 162 COLORSPACE_RGB = 0,
128 COLORSPACE_BT470M, 163 COLORSPACE_BT709 = 1,
129 COLORSPACE_BT470BG, 164 COLORSPACE_UNSPECIFIED = 2,
130 COLORSPACE_SMPTE170M, 165 COLORSPACE_UNKNOWN = COLORSPACE_UNSPECIFIED, // compatibility
131 COLORSPACE_SMPTE240M, 166 COLORSPACE_RESERVED = 3,
132 COLORSPACE_FILM, 167 COLORSPACE_FCC = 4,
133 COLORSPACE_BT2020, 168 COLORSPACE_BT470BG = 5,
134 COLORSPACE_SMPTE428, 169 COLORSPACE_SMPTE170M = 6,
135 COLORSPACE_SMPTEST428_1, 170 COLORSPACE_SMPTE240M = 7,
136 COLORSPACE_SMPTE431, 171 COLORSPACE_YCGCO = 8,
137 COLORSPACE_SMPTE432, 172 COLORSPACE_YCOCG = COLORSPACE_YCGCO,
138 COLORSPACE_JEDEC_P22 173 COLORSPACE_BT2020_NCL = 9,
174 COLORSPACE_BT2020_CL = 10,
175 COLORSPACE_SMPTE2085 = 11,
176 COLORSPACE_CHROMA_DERIVED_NCL = 12,
177 COLORSPACE_CHROMA_DERIVED_CL = 13,
178 COLORSPACE_ICTCP = 14,
179 COLORSPACE_MAX
180 };
181
182 // Keep in sync with AVColorPrimaries
183 enum COLORPRIMARIES : int32_t
184 {
185 COLORPRIMARY_RESERVED0 = 0,
186 COLORPRIMARY_BT709 = 1,
187 COLORPRIMARY_UNSPECIFIED = 2,
188 COLORPRIMARY_RESERVED = 3,
189 COLORPRIMARY_BT470M = 4,
190 COLORPRIMARY_BT470BG = 5,
191 COLORPRIMARY_SMPTE170M = 6,
192 COLORPRIMARY_SMPTE240M = 7,
193 COLORPRIMARY_FILM = 8,
194 COLORPRIMARY_BT2020 = 9,
195 COLORPRIMARY_SMPTE428 = 10,
196 COLORPRIMARY_SMPTEST428_1 = COLORPRIMARY_SMPTE428,
197 COLORPRIMARY_SMPTE431 = 11,
198 COLORPRIMARY_SMPTE432 = 12,
199 COLORPRIMARY_JEDEC_P22 = 22,
200 COLORPRIMARY_MAX
139 }; 201 };
140 202
141 enum INPUTSTREAM_COLORRANGE 203 // Keep in sync with AVColorRange
204 enum COLORRANGE
142 { 205 {
143 COLORRANGE_UNKNOWN, 206 COLORRANGE_UNKNOWN = 0,
144 COLORRANGE_LIMITED, 207 COLORRANGE_LIMITED,
145 COLORRANGE_FULLRANGE 208 COLORRANGE_FULLRANGE,
209 COLORRANGE_MAX
210 };
211
212 // keep in sync with AVColorTransferCharacteristic
213 enum COLORTRC : int32_t
214 {
215 COLORTRC_RESERVED0 = 0,
216 COLORTRC_BT709 = 1,
217 COLORTRC_UNSPECIFIED = 2,
218 COLORTRC_RESERVED = 3,
219 COLORTRC_GAMMA22 = 4,
220 COLORTRC_GAMMA28 = 5,
221 COLORTRC_SMPTE170M = 6,
222 COLORTRC_SMPTE240M = 7,
223 COLORTRC_LINEAR = 8,
224 COLORTRC_LOG = 9,
225 COLORTRC_LOG_SQRT = 10,
226 COLORTRC_IEC61966_2_4 = 11,
227 COLORTRC_BT1361_ECG = 12,
228 COLORTRC_IEC61966_2_1 = 13,
229 COLORTRC_BT2020_10 = 14,
230 COLORTRC_BT2020_12 = 15,
231 COLORTRC_SMPTE2084 = 16,
232 COLORTRC_SMPTEST2084 = COLORTRC_SMPTE2084,
233 COLORTRC_SMPTE428 = 17,
234 COLORTRC_SMPTEST428_1 = COLORTRC_SMPTE428,
235 COLORTRC_ARIB_STD_B67 = 18,
236 COLORTRC_MAX
146 }; 237 };
147 238
148 uint32_t m_flags; 239 uint32_t m_flags;
149 240
150 char m_name[256]; /*!< @brief (optinal) name of the stream, \0 for default handling */ 241 char m_name[256]; /*!< @brief (optinal) name of the stream, \0 for default handling */
151 char m_codecName[32]; /*!< @brief (required) name of codec according to ffmpeg */ 242 char m_codecName[32]; /*!< @brief (required) name of codec according to ffmpeg */
152 char m_codecInternalName[32]; /*!< @brief (optional) internal name of codec (selectionstream info) */ 243 char m_codecInternalName
153 STREAMCODEC_PROFILE m_codecProfile; /*!< @brief (optional) the profile of the codec */ 244 [32]; /*!< @brief (optional) internal name of codec (selectionstream info) */
154 unsigned int m_pID; /*!< @brief (required) physical index */ 245 STREAMCODEC_PROFILE m_codecProfile; /*!< @brief (optional) the profile of the codec */
246 unsigned int m_pID; /*!< @brief (required) physical index */
155 247
156 const uint8_t *m_ExtraData; 248 const uint8_t* m_ExtraData;
157 unsigned int m_ExtraSize; 249 unsigned int m_ExtraSize;
158 250
159 char m_language[64]; /*!< @brief RFC 5646 language code (empty string if undefined) */ 251 char m_language[64]; /*!< @brief RFC 5646 language code (empty string if undefined) */
160 252
161 unsigned int m_FpsScale; /*!< @brief Scale of 1000 and a rate of 29970 will result in 29.97 fps */ 253 unsigned int
254 m_FpsScale; /*!< @brief Scale of 1000 and a rate of 29970 will result in 29.97 fps */
162 unsigned int m_FpsRate; 255 unsigned int m_FpsRate;
163 unsigned int m_Height; /*!< @brief height of the stream reported by the demuxer */ 256 unsigned int m_Height; /*!< @brief height of the stream reported by the demuxer */
164 unsigned int m_Width; /*!< @brief width of the stream reported by the demuxer */ 257 unsigned int m_Width; /*!< @brief width of the stream reported by the demuxer */
165 float m_Aspect; /*!< @brief display aspect of stream */ 258 float m_Aspect; /*!< @brief display aspect of stream */
166 259
167 260
168 unsigned int m_Channels; /*!< @brief (required) amount of channels */ 261 unsigned int m_Channels; /*!< @brief (required) amount of channels */
169 unsigned int m_SampleRate; /*!< @brief (required) sample rate */ 262 unsigned int m_SampleRate; /*!< @brief (required) sample rate */
170 unsigned int m_BitRate; /*!< @brief (required) bit rate */ 263 unsigned int m_BitRate; /*!< @brief (required) bit rate */
171 unsigned int m_BitsPerSample; /*!< @brief (required) bits per sample */ 264 unsigned int m_BitsPerSample; /*!< @brief (required) bits per sample */
172 unsigned int m_BlockAlign; 265 unsigned int m_BlockAlign;
173 266
174 CRYPTO_INFO m_cryptoInfo; 267 CRYPTO_INFO m_cryptoInfo;
175 268
176 // new in API version 2.0.8 269 // new in API version 2.0.8
177 unsigned int m_codecFourCC; /*!< @brief Codec If available, the fourcc code codec */ 270 unsigned int m_codecFourCC; /*!< @brief Codec If available, the fourcc code codec */
178 INPUTSTREAM_COLORSPACE m_colorSpace; /*!< @brief definition of colorspace */ 271 COLORSPACE m_colorSpace; /*!< @brief definition of colorspace */
179 INPUTSTREAM_COLORRANGE m_colorRange; /*!< @brief color range if available */ 272 COLORRANGE m_colorRange; /*!< @brief color range if available */
273
274 //new in API 2.0.9 / INPUTSTREAM_VERSION_LEVEL 1
275 COLORPRIMARIES m_colorPrimaries;
276 COLORTRC m_colorTransferCharacteristic;
277 INPUTSTREAM_MASTERING_METADATA* m_masteringMetadata; /*!< @brief mastering static Metadata */
278 INPUTSTREAM_CONTENTLIGHT_METADATA*
279 m_contentLightMetadata; /*!< @brief content light static Metadata */
180 }; 280 };
181 281
182 struct INPUTSTREAM_TIMES 282 struct INPUTSTREAM_TIMES
@@ -188,7 +288,7 @@ extern "C" {
188 }; 288 };
189 289
190 /*! 290 /*!
191 * @brief Structure to transfer the methods from xbmc_inputstream_dll.h to XBMC 291 * @brief "C" ABI Structures to transfer the methods from this to Kodi
192 */ 292 */
193 293
194 // this are properties given to the addon on create 294 // this are properties given to the addon on create
@@ -202,53 +302,72 @@ extern "C" {
202 { 302 {
203 KODI_HANDLE kodiInstance; 303 KODI_HANDLE kodiInstance;
204 DemuxPacket* (*allocate_demux_packet)(void* kodiInstance, int data_size); 304 DemuxPacket* (*allocate_demux_packet)(void* kodiInstance, int data_size);
205 DemuxPacket* (*allocate_encrypted_demux_packet)(void* kodiInstance, unsigned int data_size, unsigned int encrypted_subsample_count); 305 DemuxPacket* (*allocate_encrypted_demux_packet)(void* kodiInstance,
306 unsigned int data_size,
307 unsigned int encrypted_subsample_count);
206 void (*free_demux_packet)(void* kodiInstance, DemuxPacket* packet); 308 void (*free_demux_packet)(void* kodiInstance, DemuxPacket* packet);
207 } AddonToKodiFuncTable_InputStream; 309 } AddonToKodiFuncTable_InputStream;
208 310
209 struct AddonInstance_InputStream; 311 struct AddonInstance_InputStream;
210 typedef struct KodiToAddonFuncTable_InputStream /* internal */ 312 typedef struct KodiToAddonFuncTable_InputStream /* internal */
211 { 313 {
212 kodi::addon::CInstanceInputStream* addonInstance; 314 KODI_HANDLE addonInstance;
213 315
214 bool (__cdecl* open)(const AddonInstance_InputStream* instance, INPUTSTREAM* props); 316 bool(__cdecl* open)(const AddonInstance_InputStream* instance, INPUTSTREAM* props);
215 void (__cdecl* close)(const AddonInstance_InputStream* instance); 317 void(__cdecl* close)(const AddonInstance_InputStream* instance);
216 const char* (__cdecl* get_path_list)(const AddonInstance_InputStream* instance); 318 const char*(__cdecl* get_path_list)(const AddonInstance_InputStream* instance);
217 void (__cdecl* get_capabilities)(const AddonInstance_InputStream* instance, INPUTSTREAM_CAPABILITIES* capabilities); 319 void(__cdecl* get_capabilities)(const AddonInstance_InputStream* instance,
320 INPUTSTREAM_CAPABILITIES* capabilities);
218 321
219 // IDemux 322 // IDemux
220 struct INPUTSTREAM_IDS (__cdecl* get_stream_ids)(const AddonInstance_InputStream* instance); 323 struct INPUTSTREAM_IDS(__cdecl* get_stream_ids)(const AddonInstance_InputStream* instance);
221 struct INPUTSTREAM_INFO (__cdecl* get_stream)(const AddonInstance_InputStream* instance, int streamid); 324 struct INPUTSTREAM_INFO(__cdecl* get_stream)(const AddonInstance_InputStream* instance,
222 void (__cdecl* enable_stream)(const AddonInstance_InputStream* instance, int streamid, bool enable); 325 int streamid);
326 void(__cdecl* enable_stream)(const AddonInstance_InputStream* instance,
327 int streamid,
328 bool enable);
223 bool(__cdecl* open_stream)(const AddonInstance_InputStream* instance, int streamid); 329 bool(__cdecl* open_stream)(const AddonInstance_InputStream* instance, int streamid);
224 void (__cdecl* demux_reset)(const AddonInstance_InputStream* instance); 330 void(__cdecl* demux_reset)(const AddonInstance_InputStream* instance);
225 void (__cdecl* demux_abort)(const AddonInstance_InputStream* instance); 331 void(__cdecl* demux_abort)(const AddonInstance_InputStream* instance);
226 void (__cdecl* demux_flush)(const AddonInstance_InputStream* instance); 332 void(__cdecl* demux_flush)(const AddonInstance_InputStream* instance);
227 DemuxPacket* (__cdecl* demux_read)(const AddonInstance_InputStream* instance); 333 DemuxPacket*(__cdecl* demux_read)(const AddonInstance_InputStream* instance);
228 bool (__cdecl* demux_seek_time)(const AddonInstance_InputStream* instance, double time, bool backwards, double* startpts); 334 bool(__cdecl* demux_seek_time)(const AddonInstance_InputStream* instance,
229 void (__cdecl* demux_set_speed)(const AddonInstance_InputStream* instance, int speed); 335 double time,
230 void (__cdecl* set_video_resolution)(const AddonInstance_InputStream* instance, int width, int height); 336 bool backwards,
337 double* startpts);
338 void(__cdecl* demux_set_speed)(const AddonInstance_InputStream* instance, int speed);
339 void(__cdecl* set_video_resolution)(const AddonInstance_InputStream* instance,
340 int width,
341 int height);
231 342
232 // IDisplayTime 343 // IDisplayTime
233 int (__cdecl* get_total_time)(const AddonInstance_InputStream* instance); 344 int(__cdecl* get_total_time)(const AddonInstance_InputStream* instance);
234 int (__cdecl* get_time)(const AddonInstance_InputStream* instance); 345 int(__cdecl* get_time)(const AddonInstance_InputStream* instance);
235 346
236 // ITime 347 // ITime
237 bool(__cdecl* get_times)(const AddonInstance_InputStream* instance, INPUTSTREAM_TIMES *times); 348 bool(__cdecl* get_times)(const AddonInstance_InputStream* instance, INPUTSTREAM_TIMES* times);
238 349
239 // IPosTime 350 // IPosTime
240 bool (__cdecl* pos_time)(const AddonInstance_InputStream* instance, int ms); 351 bool(__cdecl* pos_time)(const AddonInstance_InputStream* instance, int ms);
241 352
242 // Seekable (mandatory) 353 int(__cdecl* read_stream)(const AddonInstance_InputStream* instance,
243 bool (__cdecl* can_pause_stream)(const AddonInstance_InputStream* instance); 354 uint8_t* buffer,
244 bool (__cdecl* can_seek_stream)(const AddonInstance_InputStream* instance); 355 unsigned int bufferSize);
245 356 int64_t(__cdecl* seek_stream)(const AddonInstance_InputStream* instance,
246 int (__cdecl* read_stream)(const AddonInstance_InputStream* instance, uint8_t* buffer, unsigned int bufferSize); 357 int64_t position,
247 int64_t(__cdecl* seek_stream)(const AddonInstance_InputStream* instance, int64_t position, int whence); 358 int whence);
248 int64_t (__cdecl* position_stream)(const AddonInstance_InputStream* instance); 359 int64_t(__cdecl* position_stream)(const AddonInstance_InputStream* instance);
249 int64_t (__cdecl* length_stream)(const AddonInstance_InputStream* instance); 360 int64_t(__cdecl* length_stream)(const AddonInstance_InputStream* instance);
250 void (__cdecl* pause_stream)(const AddonInstance_InputStream* instance, double time); 361 bool(__cdecl* is_real_time_stream)(const AddonInstance_InputStream* instance);
251 bool (__cdecl* is_real_time_stream)(const AddonInstance_InputStream* instance); 362
363 // IChapter
364 int(__cdecl* get_chapter)(const AddonInstance_InputStream* instance);
365 int(__cdecl* get_chapter_count)(const AddonInstance_InputStream* instance);
366 const char*(__cdecl* get_chapter_name)(const AddonInstance_InputStream* instance, int ch);
367 int64_t(__cdecl* get_chapter_pos)(const AddonInstance_InputStream* instance, int ch);
368 bool(__cdecl* seek_chapter)(const AddonInstance_InputStream* instance, int ch);
369
370 int(__cdecl* block_size_stream)(const AddonInstance_InputStream* instance);
252 } KodiToAddonFuncTable_InputStream; 371 } KodiToAddonFuncTable_InputStream;
253 372
254 typedef struct AddonInstance_InputStream /* internal */ 373 typedef struct AddonInstance_InputStream /* internal */
@@ -258,6 +377,7 @@ extern "C" {
258 KodiToAddonFuncTable_InputStream toAddon; 377 KodiToAddonFuncTable_InputStream toAddon;
259 } AddonInstance_InputStream; 378 } AddonInstance_InputStream;
260 379
380#ifdef __cplusplus
261} /* extern "C" */ 381} /* extern "C" */
262 382
263namespace kodi 383namespace kodi
@@ -265,90 +385,93 @@ namespace kodi
265namespace addon 385namespace addon
266{ 386{
267 387
268 class CInstanceInputStream : public IAddonInstance 388class ATTRIBUTE_HIDDEN CInstanceInputStream : public IAddonInstance
389{
390public:
391 explicit CInstanceInputStream(KODI_HANDLE instance, const std::string& kodiVersion = "")
392 : IAddonInstance(ADDON_INSTANCE_INPUTSTREAM,
393 !kodiVersion.empty() ? kodiVersion
394 : GetKodiTypeVersion(ADDON_INSTANCE_INPUTSTREAM))
269 { 395 {
270 public: 396 if (CAddonBase::m_interface->globalSingleInstance != nullptr)
271 explicit CInstanceInputStream(KODI_HANDLE instance) 397 throw std::logic_error("kodi::addon::CInstanceInputStream: Creation of multiple together "
272 : IAddonInstance(ADDON_INSTANCE_INPUTSTREAM) 398 "with single instance way is not allowed!");
273 {
274 if (CAddonBase::m_interface->globalSingleInstance != nullptr)
275 throw std::logic_error("kodi::addon::CInstanceInputStream: Creation of multiple together with single instance way is not allowed!");
276 399
277 SetAddonStruct(instance); 400 SetAddonStruct(instance, m_kodiVersion);
278 } 401 }
279 402
280 ~CInstanceInputStream() override = default; 403 ~CInstanceInputStream() override = default;
281 404
282 /*! 405 /*!
283 * Open a stream. 406 * Open a stream.
284 * @param props 407 * @param props
285 * @return True if the stream has been opened successfully, false otherwise. 408 * @return True if the stream has been opened successfully, false otherwise.
286 * @remarks 409 * @remarks
287 */ 410 */
288 virtual bool Open(INPUTSTREAM& props) = 0; 411 virtual bool Open(INPUTSTREAM& props) = 0;
289 412
290 /*! 413 /*!
291 * Close an open stream. 414 * Close an open stream.
292 * @remarks 415 * @remarks
293 */ 416 */
294 virtual void Close() = 0; 417 virtual void Close() = 0;
295 418
296 /*! 419 /*!
297 * Get Capabilities of this addon. 420 * Get Capabilities of this addon.
298 * @param capabilities The add-on's capabilities. 421 * @param capabilities The add-on's capabilities.
299 * @remarks 422 * @remarks
300 */ 423 */
301 virtual void GetCapabilities(INPUTSTREAM_CAPABILITIES& capabilities) = 0; 424 virtual void GetCapabilities(INPUTSTREAM_CAPABILITIES& capabilities) = 0;
302 425
303 /*! 426 /*!
304 * Get IDs of available streams 427 * Get IDs of available streams
305 * @remarks 428 * @remarks
306 */ 429 */
307 virtual INPUTSTREAM_IDS GetStreamIds() = 0; 430 virtual INPUTSTREAM_IDS GetStreamIds() = 0;
308 431
309 /*! 432 /*!
310 * Get stream properties of a stream. 433 * Get stream properties of a stream.
311 * @param streamid unique id of stream 434 * @param streamid unique id of stream
312 * @return struc of stream properties 435 * @return struc of stream properties
313 * @remarks 436 * @remarks
314 */ 437 */
315 virtual INPUTSTREAM_INFO GetStream(int streamid) = 0; 438 virtual INPUTSTREAM_INFO GetStream(int streamid) = 0;
316 439
317 /*! 440 /*!
318 * Enable or disable a stream. 441 * Enable or disable a stream.
319 * A disabled stream does not send demux packets 442 * A disabled stream does not send demux packets
320 * @param streamid unique id of stream 443 * @param streamid unique id of stream
321 * @param enable true for enable, false for disable 444 * @param enable true for enable, false for disable
322 * @remarks 445 * @remarks
323 */ 446 */
324 virtual void EnableStream(int streamid, bool enable) = 0; 447 virtual void EnableStream(int streamid, bool enable) = 0;
325 448
326 /*! 449 /*!
327 * Opens a stream for playback. 450 * Opens a stream for playback.
328 * @param streamid unique id of stream 451 * @param streamid unique id of stream
329 * @remarks 452 * @remarks
330 */ 453 */
331 virtual bool OpenStream(int streamid) = 0; 454 virtual bool OpenStream(int streamid) = 0;
332 455
333 /*! 456 /*!
334 * Reset the demultiplexer in the add-on. 457 * Reset the demultiplexer in the add-on.
335 * @remarks Required if bHandlesDemuxing is set to true. 458 * @remarks Required if bHandlesDemuxing is set to true.
336 */ 459 */
337 virtual void DemuxReset() { } 460 virtual void DemuxReset() {}
338 461
339 /*! 462 /*!
340 * Abort the demultiplexer thread in the add-on. 463 * Abort the demultiplexer thread in the add-on.
341 * @remarks Required if bHandlesDemuxing is set to true. 464 * @remarks Required if bHandlesDemuxing is set to true.
342 */ 465 */
343 virtual void DemuxAbort() { } 466 virtual void DemuxAbort() {}
344 467
345 /*! 468 /*!
346 * Flush all data that's currently in the demultiplexer buffer in the add-on. 469 * Flush all data that's currently in the demultiplexer buffer in the add-on.
347 * @remarks Required if bHandlesDemuxing is set to true. 470 * @remarks Required if bHandlesDemuxing is set to true.
348 */ 471 */
349 virtual void DemuxFlush() { } 472 virtual void DemuxFlush() {}
350 473
351 /*! 474 /*!
352 * Read the next packet from the demultiplexer, if there is one. 475 * Read the next packet from the demultiplexer, if there is one.
353 * @return The next packet. 476 * @return The next packet.
354 * If there is no next packet, then the add-on should return the 477 * If there is no next packet, then the add-on should return the
@@ -357,12 +480,12 @@ namespace addon
357 * then, the add-on should call AllocateDemuxPacket(0) on the 480 * then, the add-on should call AllocateDemuxPacket(0) on the
358 * callback, and set the streamid to DMX_SPECIALID_STREAMCHANGE and 481 * callback, and set the streamid to DMX_SPECIALID_STREAMCHANGE and
359 * return the value. 482 * return the value.
360 * The add-on should return NULL if an error occured. 483 * The add-on should return NULL if an error occurred.
361 * @remarks Return NULL if this add-on won't provide this function. 484 * @remarks Return NULL if this add-on won't provide this function.
362 */ 485 */
363 virtual DemuxPacket* DemuxRead() { return nullptr; } 486 virtual DemuxPacket* DemuxRead() { return nullptr; }
364 487
365 /*! 488 /*!
366 * Notify the InputStream addon/demuxer that Kodi wishes to seek the stream by time 489 * Notify the InputStream addon/demuxer that Kodi wishes to seek the stream by time
367 * Demuxer is required to set stream to an IDR frame 490 * Demuxer is required to set stream to an IDR frame
368 * @param time The absolute time since stream start 491 * @param time The absolute time since stream start
@@ -371,314 +494,388 @@ namespace addon
371 * @return True if the seek operation was possible 494 * @return True if the seek operation was possible
372 * @remarks Optional, and only used if addon has its own demuxer. 495 * @remarks Optional, and only used if addon has its own demuxer.
373 */ 496 */
374 virtual bool DemuxSeekTime(double time, bool backwards, double &startpts) { return false; } 497 virtual bool DemuxSeekTime(double time, bool backwards, double& startpts) { return false; }
375 498
376 /*! 499 /*!
377 * Notify the InputStream addon/demuxer that Kodi wishes to change playback speed 500 * Notify the InputStream addon/demuxer that Kodi wishes to change playback speed
378 * @param speed The requested playback speed 501 * @param speed The requested playback speed
379 * @remarks Optional, and only used if addon has its own demuxer. 502 * @remarks Optional, and only used if addon has its own demuxer.
380 */ 503 */
381 virtual void DemuxSetSpeed(int speed) { } 504 virtual void DemuxSetSpeed(int speed) {}
382 505
383 /*! 506 /*!
384 * Sets desired width / height 507 * Sets desired width / height
385 * @param width / hight 508 * @param width / hight
386 */ 509 */
387 virtual void SetVideoResolution(int width, int height) { } 510 virtual void SetVideoResolution(int width, int height) {}
388 511
389 /*! 512 /*!
390 * Totel time in ms 513 * Totel time in ms
391 * @remarks 514 * @remarks
392 */ 515 */
393 virtual int GetTotalTime() { return -1; } 516 virtual int GetTotalTime() { return -1; }
394 517
395 /*! 518 /*!
396 * Playing time in ms 519 * Playing time in ms
397 * @remarks 520 * @remarks
398 */ 521 */
399 virtual int GetTime() { return -1; } 522 virtual int GetTime() { return -1; }
400 523
401 /*! 524 /*!
402 * Get current timing values in PTS scale 525 * Get current timing values in PTS scale
403 * @remarks 526 * @remarks
404 */ 527 */
405 virtual bool GetTimes(INPUTSTREAM_TIMES &times) { return false; } 528 virtual bool GetTimes(INPUTSTREAM_TIMES& times) { return false; }
406 529
407 /*! 530 /*!
408 * Positions inputstream to playing time given in ms 531 * Positions inputstream to playing time given in ms
409 * @remarks 532 * @remarks
410 */ 533 */
411 virtual bool PosTime(int ms) { return false; } 534 virtual bool PosTime(int ms) { return false; }
412 535
536 /*!
537 * Return currently selected chapter
538 * @remarks
539 */
540 virtual int GetChapter() { return -1; };
413 541
414 /*! 542 /*!
415 * Check if the backend support pausing the currently playing stream 543 * Return number of available chapters
416 * This will enable/disable the pause button in Kodi based on the return value 544 * @remarks
417 * @return false if the InputStream addon/backend does not support pausing, true if possible 545 */
418 */ 546 virtual int GetChapterCount() { return 0; };
419 virtual bool CanPauseStream() { return false; }
420 547
421 /*! 548 /*!
422 * Check if the backend supports seeking for the currently playing stream 549 * Return name of chapter # ch
423 * This will enable/disable the rewind/forward buttons in Kodi based on the return value 550 * @remarks
424 * @return false if the InputStream addon/backend does not support seeking, true if possible 551 */
425 */ 552 virtual const char* GetChapterName(int ch) { return nullptr; };
426 virtual bool CanSeekStream() { return false; } 553
554 /*!
555 * Return position if chapter # ch in milliseconds
556 * @remarks
557 */
558 virtual int64_t GetChapterPos(int ch) { return 0; };
559
560 /*!
561 * Seek to the beginning of chapter # ch
562 * @remarks
563 */
564 virtual bool SeekChapter(int ch) { return false; };
427 565
428 /*! 566 /*!
429 * Read from an open stream. 567 * Read from an open stream.
430 * @param buffer The buffer to store the data in. 568 * @param buffer The buffer to store the data in.
431 * @param bufferSize The amount of bytes to read. 569 * @param bufferSize The amount of bytes to read.
432 * @return The amount of bytes that were actually read from the stream. 570 * @return The amount of bytes that were actually read from the stream.
433 * @remarks Return -1 if this add-on won't provide this function. 571 * @remarks Return -1 if this add-on won't provide this function.
434 */ 572 */
435 virtual int ReadStream(uint8_t* buffer, unsigned int bufferSize) { return -1; } 573 virtual int ReadStream(uint8_t* buffer, unsigned int bufferSize) { return -1; }
436 574
437 /*! 575 /*!
438 * Seek in a stream. 576 * Seek in a stream.
439 * @param position The position to seek to. 577 * @param position The position to seek to.
440 * @param whence ? 578 * @param whence ?
441 * @return The new position. 579 * @return The new position.
442 * @remarks Return -1 if this add-on won't provide this function. 580 * @remarks Return -1 if this add-on won't provide this function.
443 */ 581 */
444 virtual int64_t SeekStream(int64_t position, int whence = SEEK_SET) { return -1; } 582 virtual int64_t SeekStream(int64_t position, int whence = SEEK_SET) { return -1; }
445 583
446 /*! 584 /*!
447 * @return The position in the stream that's currently being read. 585 * @return The position in the stream that's currently being read.
448 * @remarks Return -1 if this add-on won't provide this function. 586 * @remarks Return -1 if this add-on won't provide this function.
449 */ 587 */
450 virtual int64_t PositionStream() { return -1; } 588 virtual int64_t PositionStream() { return -1; }
451 589
452 /*! 590 /*!
453 * @return The total length of the stream that's currently being read. 591 * @return The total length of the stream that's currently being read.
454 * @remarks Return -1 if this add-on won't provide this function. 592 * @remarks Return -1 if this add-on won't provide this function.
455 */ 593 */
456 virtual int64_t LengthStream() { return -1; } 594 virtual int64_t LengthStream() { return -1; }
457
458 595
459 /*! 596 /*!
460 * @brief Notify the InputStream addon that Kodi (un)paused the currently playing stream 597 * @return Obtain the chunk size to use when reading streams.
598 * @remarks Return 0 if this add-on won't provide this function.
461 */ 599 */
462 virtual void PauseStream(double time) { } 600 virtual int GetBlockSize() { return 0; }
463
464 601
465 /*! 602 /*!
466 * Check for real-time streaming 603 * Check for real-time streaming
467 * @return true if current stream is real-time 604 * @return true if current stream is real-time
468 */ 605 */
469 virtual bool IsRealTimeStream() { return true; } 606 virtual bool IsRealTimeStream() { return true; }
470 607
471 /*! 608 /*!
472 * @brief Allocate a demux packet. Free with FreeDemuxPacket 609 * @brief Allocate a demux packet. Free with FreeDemuxPacket
473 * @param dataSize The size of the data that will go into the packet 610 * @param dataSize The size of the data that will go into the packet
474 * @return The allocated packet 611 * @return The allocated packet
475 */ 612 */
476 DemuxPacket* AllocateDemuxPacket(int dataSize) 613 DemuxPacket* AllocateDemuxPacket(int dataSize)
477 { 614 {
478 return m_instanceData->toKodi.allocate_demux_packet(m_instanceData->toKodi.kodiInstance, dataSize); 615 return m_instanceData->toKodi.allocate_demux_packet(m_instanceData->toKodi.kodiInstance,
479 } 616 dataSize);
617 }
480 618
481 /*! 619 /*!
482 * @brief Allocate a demux packet. Free with FreeDemuxPacket 620 * @brief Allocate a demux packet. Free with FreeDemuxPacket
483 * @param dataSize The size of the data that will go into the packet 621 * @param dataSize The size of the data that will go into the packet
484 * @return The allocated packet 622 * @return The allocated packet
485 */ 623 */
486 DemuxPacket* AllocateEncryptedDemuxPacket(int dataSize, unsigned int encryptedSubsampleCount) 624 DemuxPacket* AllocateEncryptedDemuxPacket(int dataSize, unsigned int encryptedSubsampleCount)
487 { 625 {
488 return m_instanceData->toKodi.allocate_encrypted_demux_packet(m_instanceData->toKodi.kodiInstance, dataSize, encryptedSubsampleCount); 626 return m_instanceData->toKodi.allocate_encrypted_demux_packet(
489 } 627 m_instanceData->toKodi.kodiInstance, dataSize, encryptedSubsampleCount);
628 }
490 629
491 /*! 630 /*!
492 * @brief Free a packet that was allocated with AllocateDemuxPacket 631 * @brief Free a packet that was allocated with AllocateDemuxPacket
493 * @param packet The packet to free 632 * @param packet The packet to free
494 */ 633 */
495 void FreeDemuxPacket(DemuxPacket* packet) 634 void FreeDemuxPacket(DemuxPacket* packet)
496 { 635 {
497 return m_instanceData->toKodi.free_demux_packet(m_instanceData->toKodi.kodiInstance, packet); 636 return m_instanceData->toKodi.free_demux_packet(m_instanceData->toKodi.kodiInstance, packet);
498 } 637 }
499 638
500 private: 639private:
501 void SetAddonStruct(KODI_HANDLE instance) 640 static int compareVersion(const int v1[3], const int v2[3])
502 { 641 {
503 if (instance == nullptr) 642 for (unsigned i(0); i < 3; ++i)
504 throw std::logic_error("kodi::addon::CInstanceInputStream: Creation with empty addon structure not allowed, table must be given from Kodi!"); 643 if (v1[i] != v2[i])
505 644 return v1[i] - v2[i];
506 m_instanceData = static_cast<AddonInstance_InputStream*>(instance); 645 return 0;
507 m_instanceData->toAddon.addonInstance = this; 646 }
508 m_instanceData->toAddon.open = ADDON_Open;
509 m_instanceData->toAddon.close = ADDON_Close;
510 m_instanceData->toAddon.get_capabilities = ADDON_GetCapabilities;
511
512 m_instanceData->toAddon.get_stream_ids = ADDON_GetStreamIds;
513 m_instanceData->toAddon.get_stream = ADDON_GetStream;
514 m_instanceData->toAddon.enable_stream = ADDON_EnableStream;
515 m_instanceData->toAddon.open_stream = ADDON_OpenStream;
516 m_instanceData->toAddon.demux_reset = ADDON_DemuxReset;
517 m_instanceData->toAddon.demux_abort = ADDON_DemuxAbort;
518 m_instanceData->toAddon.demux_flush = ADDON_DemuxFlush;
519 m_instanceData->toAddon.demux_read = ADDON_DemuxRead;
520 m_instanceData->toAddon.demux_seek_time = ADDON_DemuxSeekTime;
521 m_instanceData->toAddon.demux_set_speed = ADDON_DemuxSetSpeed;
522 m_instanceData->toAddon.set_video_resolution = ADDON_SetVideoResolution;
523
524 m_instanceData->toAddon.get_total_time = ADDON_GetTotalTime;
525 m_instanceData->toAddon.get_time = ADDON_GetTime;
526
527 m_instanceData->toAddon.get_times = ADDON_GetTimes;
528
529 m_instanceData->toAddon.pos_time = ADDON_PosTime;
530
531 m_instanceData->toAddon.can_pause_stream = ADDON_CanPauseStream;
532 m_instanceData->toAddon.can_seek_stream = ADDON_CanSeekStream;
533
534 m_instanceData->toAddon.read_stream = ADDON_ReadStream;
535 m_instanceData->toAddon.seek_stream = ADDON_SeekStream;
536 m_instanceData->toAddon.position_stream = ADDON_PositionStream;
537 m_instanceData->toAddon.length_stream = ADDON_LengthStream;
538 m_instanceData->toAddon.pause_stream = ADDON_PauseStream;
539 m_instanceData->toAddon.is_real_time_stream = ADDON_IsRealTimeStream;
540 }
541 647
542 inline static bool ADDON_Open(const AddonInstance_InputStream* instance, INPUTSTREAM* props) 648 void SetAddonStruct(KODI_HANDLE instance, const std::string& kodiVersion)
543 { 649 {
544 return instance->toAddon.addonInstance->Open(*props); 650 if (instance == nullptr)
651 throw std::logic_error("kodi::addon::CInstanceInputStream: Creation with empty addon "
652 "structure not allowed, table must be given from Kodi!");
653 int api[3] = { 0, 0, 0 };
654 sscanf(kodiVersion.c_str(), "%d.%d.%d", &api[0], &api[1], &api[2]);
655
656 m_instanceData = static_cast<AddonInstance_InputStream*>(instance);
657 m_instanceData->toAddon.addonInstance = this;
658 m_instanceData->toAddon.open = ADDON_Open;
659 m_instanceData->toAddon.close = ADDON_Close;
660 m_instanceData->toAddon.get_capabilities = ADDON_GetCapabilities;
661
662 m_instanceData->toAddon.get_stream_ids = ADDON_GetStreamIds;
663 m_instanceData->toAddon.get_stream = ADDON_GetStream;
664 m_instanceData->toAddon.enable_stream = ADDON_EnableStream;
665 m_instanceData->toAddon.open_stream = ADDON_OpenStream;
666 m_instanceData->toAddon.demux_reset = ADDON_DemuxReset;
667 m_instanceData->toAddon.demux_abort = ADDON_DemuxAbort;
668 m_instanceData->toAddon.demux_flush = ADDON_DemuxFlush;
669 m_instanceData->toAddon.demux_read = ADDON_DemuxRead;
670 m_instanceData->toAddon.demux_seek_time = ADDON_DemuxSeekTime;
671 m_instanceData->toAddon.demux_set_speed = ADDON_DemuxSetSpeed;
672 m_instanceData->toAddon.set_video_resolution = ADDON_SetVideoResolution;
673
674 m_instanceData->toAddon.get_total_time = ADDON_GetTotalTime;
675 m_instanceData->toAddon.get_time = ADDON_GetTime;
676
677 m_instanceData->toAddon.get_times = ADDON_GetTimes;
678 m_instanceData->toAddon.pos_time = ADDON_PosTime;
679
680 m_instanceData->toAddon.read_stream = ADDON_ReadStream;
681 m_instanceData->toAddon.seek_stream = ADDON_SeekStream;
682 m_instanceData->toAddon.position_stream = ADDON_PositionStream;
683 m_instanceData->toAddon.length_stream = ADDON_LengthStream;
684 m_instanceData->toAddon.is_real_time_stream = ADDON_IsRealTimeStream;
685
686 int minChapterVersion[3] = { 2, 0, 10 };
687 if (compareVersion(api, minChapterVersion) >= 0)
688 {
689 m_instanceData->toAddon.get_chapter = ADDON_GetChapter;
690 m_instanceData->toAddon.get_chapter_count = ADDON_GetChapterCount;
691 m_instanceData->toAddon.get_chapter_name = ADDON_GetChapterName;
692 m_instanceData->toAddon.get_chapter_pos = ADDON_GetChapterPos;
693 m_instanceData->toAddon.seek_chapter = ADDON_SeekChapter;
545 } 694 }
546 695
547 inline static void ADDON_Close(const AddonInstance_InputStream* instance) 696 int minBlockSizeVersion[3] = {2, 0, 12};
697 if (compareVersion(api, minBlockSizeVersion) >= 0)
548 { 698 {
549 instance->toAddon.addonInstance->Close(); 699 m_instanceData->toAddon.block_size_stream = ADDON_GetBlockSize;
550 } 700 }
701 }
551 702
552 inline static void ADDON_GetCapabilities(const AddonInstance_InputStream* instance, INPUTSTREAM_CAPABILITIES* capabilities) 703 inline static bool ADDON_Open(const AddonInstance_InputStream* instance, INPUTSTREAM* props)
553 { 704 {
554 instance->toAddon.addonInstance->GetCapabilities(*capabilities); 705 return static_cast<CInstanceInputStream*>(instance->toAddon.addonInstance)->Open(*props);
555 } 706 }
556 707
708 inline static void ADDON_Close(const AddonInstance_InputStream* instance)
709 {
710 static_cast<CInstanceInputStream*>(instance->toAddon.addonInstance)->Close();
711 }
557 712
558 // IDemux 713 inline static void ADDON_GetCapabilities(const AddonInstance_InputStream* instance,
559 inline static struct INPUTSTREAM_IDS ADDON_GetStreamIds(const AddonInstance_InputStream* instance) 714 INPUTSTREAM_CAPABILITIES* capabilities)
560 { 715 {
561 return instance->toAddon.addonInstance->GetStreamIds(); 716 static_cast<CInstanceInputStream*>(instance->toAddon.addonInstance)
562 } 717 ->GetCapabilities(*capabilities);
718 }
563 719
564 inline static struct INPUTSTREAM_INFO ADDON_GetStream(const AddonInstance_InputStream* instance, int streamid)
565 {
566 return instance->toAddon.addonInstance->GetStream(streamid);
567 }
568 720
569 inline static void ADDON_EnableStream(const AddonInstance_InputStream* instance, int streamid, bool enable) 721 // IDemux
570 { 722 inline static struct INPUTSTREAM_IDS ADDON_GetStreamIds(const AddonInstance_InputStream* instance)
571 instance->toAddon.addonInstance->EnableStream(streamid, enable); 723 {
572 } 724 return static_cast<CInstanceInputStream*>(instance->toAddon.addonInstance)->GetStreamIds();
725 }
573 726
574 inline static bool ADDON_OpenStream(const AddonInstance_InputStream* instance, int streamid) 727 inline static struct INPUTSTREAM_INFO ADDON_GetStream(const AddonInstance_InputStream* instance,
575 { 728 int streamid)
576 return instance->toAddon.addonInstance->OpenStream(streamid); 729 {
577 } 730 return static_cast<CInstanceInputStream*>(instance->toAddon.addonInstance)->GetStream(streamid);
731 }
578 732
579 inline static void ADDON_DemuxReset(const AddonInstance_InputStream* instance) 733 inline static void ADDON_EnableStream(const AddonInstance_InputStream* instance,
580 { 734 int streamid,
581 instance->toAddon.addonInstance->DemuxReset(); 735 bool enable)
582 } 736 {
737 static_cast<CInstanceInputStream*>(instance->toAddon.addonInstance)
738 ->EnableStream(streamid, enable);
739 }
583 740
584 inline static void ADDON_DemuxAbort(const AddonInstance_InputStream* instance) 741 inline static bool ADDON_OpenStream(const AddonInstance_InputStream* instance, int streamid)
585 { 742 {
586 instance->toAddon.addonInstance->DemuxAbort(); 743 return static_cast<CInstanceInputStream*>(instance->toAddon.addonInstance)
587 } 744 ->OpenStream(streamid);
745 }
588 746
589 inline static void ADDON_DemuxFlush(const AddonInstance_InputStream* instance) 747 inline static void ADDON_DemuxReset(const AddonInstance_InputStream* instance)
590 { 748 {
591 instance->toAddon.addonInstance->DemuxFlush(); 749 static_cast<CInstanceInputStream*>(instance->toAddon.addonInstance)->DemuxReset();
592 } 750 }
593 751
594 inline static DemuxPacket* ADDON_DemuxRead(const AddonInstance_InputStream* instance) 752 inline static void ADDON_DemuxAbort(const AddonInstance_InputStream* instance)
595 { 753 {
596 return instance->toAddon.addonInstance->DemuxRead(); 754 static_cast<CInstanceInputStream*>(instance->toAddon.addonInstance)->DemuxAbort();
597 } 755 }
598 756
599 inline static bool ADDON_DemuxSeekTime(const AddonInstance_InputStream* instance, double time, bool backwards, double *startpts) 757 inline static void ADDON_DemuxFlush(const AddonInstance_InputStream* instance)
600 { 758 {
601 return instance->toAddon.addonInstance->DemuxSeekTime(time, backwards, *startpts); 759 static_cast<CInstanceInputStream*>(instance->toAddon.addonInstance)->DemuxFlush();
602 } 760 }
603 761
604 inline static void ADDON_DemuxSetSpeed(const AddonInstance_InputStream* instance, int speed) 762 inline static DemuxPacket* ADDON_DemuxRead(const AddonInstance_InputStream* instance)
605 { 763 {
606 instance->toAddon.addonInstance->DemuxSetSpeed(speed); 764 return static_cast<CInstanceInputStream*>(instance->toAddon.addonInstance)->DemuxRead();
607 } 765 }
608 766
609 inline static void ADDON_SetVideoResolution(const AddonInstance_InputStream* instance, int width, int height) 767 inline static bool ADDON_DemuxSeekTime(const AddonInstance_InputStream* instance,
610 { 768 double time,
611 instance->toAddon.addonInstance->SetVideoResolution(width, height); 769 bool backwards,
612 } 770 double* startpts)
771 {
772 return static_cast<CInstanceInputStream*>(instance->toAddon.addonInstance)
773 ->DemuxSeekTime(time, backwards, *startpts);
774 }
613 775
776 inline static void ADDON_DemuxSetSpeed(const AddonInstance_InputStream* instance, int speed)
777 {
778 static_cast<CInstanceInputStream*>(instance->toAddon.addonInstance)->DemuxSetSpeed(speed);
779 }
614 780
615 // IDisplayTime 781 inline static void ADDON_SetVideoResolution(const AddonInstance_InputStream* instance,
616 inline static int ADDON_GetTotalTime(const AddonInstance_InputStream* instance) 782 int width,
617 { 783 int height)
618 return instance->toAddon.addonInstance->GetTotalTime(); 784 {
619 } 785 static_cast<CInstanceInputStream*>(instance->toAddon.addonInstance)
786 ->SetVideoResolution(width, height);
787 }
620 788
621 inline static int ADDON_GetTime(const AddonInstance_InputStream* instance)
622 {
623 return instance->toAddon.addonInstance->GetTime();
624 }
625 789
626 // ITime 790 // IDisplayTime
627 inline static bool ADDON_GetTimes(const AddonInstance_InputStream* instance, INPUTSTREAM_TIMES *times) 791 inline static int ADDON_GetTotalTime(const AddonInstance_InputStream* instance)
628 { 792 {
629 return instance->toAddon.addonInstance->GetTimes(*times); 793 return static_cast<CInstanceInputStream*>(instance->toAddon.addonInstance)->GetTotalTime();
630 } 794 }
631 795
632 // IPosTime 796 inline static int ADDON_GetTime(const AddonInstance_InputStream* instance)
633 inline static bool ADDON_PosTime(const AddonInstance_InputStream* instance, int ms) 797 {
634 { 798 return static_cast<CInstanceInputStream*>(instance->toAddon.addonInstance)->GetTime();
635 return instance->toAddon.addonInstance->PosTime(ms); 799 }
636 }
637 800
638 // Seekable (mandatory) 801 // ITime
639 inline static bool ADDON_CanPauseStream(const AddonInstance_InputStream* instance) 802 inline static bool ADDON_GetTimes(const AddonInstance_InputStream* instance,
640 { 803 INPUTSTREAM_TIMES* times)
641 return instance->toAddon.addonInstance->CanPauseStream(); 804 {
642 } 805 return static_cast<CInstanceInputStream*>(instance->toAddon.addonInstance)->GetTimes(*times);
806 }
643 807
644 inline static bool ADDON_CanSeekStream(const AddonInstance_InputStream* instance) 808 // IPosTime
645 { 809 inline static bool ADDON_PosTime(const AddonInstance_InputStream* instance, int ms)
646 return instance->toAddon.addonInstance->CanSeekStream(); 810 {
647 } 811 return static_cast<CInstanceInputStream*>(instance->toAddon.addonInstance)->PosTime(ms);
812 }
648 813
814 inline static int ADDON_GetChapter(const AddonInstance_InputStream* instance)
815 {
816 return static_cast<CInstanceInputStream*>(instance->toAddon.addonInstance)->GetChapter();
817 }
649 818
650 inline static int ADDON_ReadStream(const AddonInstance_InputStream* instance, uint8_t* buffer, unsigned int bufferSize) 819 inline static int ADDON_GetChapterCount(const AddonInstance_InputStream* instance)
651 { 820 {
652 return instance->toAddon.addonInstance->ReadStream(buffer, bufferSize); 821 return static_cast<CInstanceInputStream*>(instance->toAddon.addonInstance)->GetChapterCount();
653 } 822 }
654 823
655 inline static int64_t ADDON_SeekStream(const AddonInstance_InputStream* instance, int64_t position, int whence) 824 inline static const char* ADDON_GetChapterName(const AddonInstance_InputStream* instance, int ch)
656 { 825 {
657 return instance->toAddon.addonInstance->SeekStream(position, whence); 826 return static_cast<CInstanceInputStream*>(instance->toAddon.addonInstance)->GetChapterName(ch);
658 } 827 }
659 828
660 inline static int64_t ADDON_PositionStream(const AddonInstance_InputStream* instance) 829 inline static int64_t ADDON_GetChapterPos(const AddonInstance_InputStream* instance, int ch)
661 { 830 {
662 return instance->toAddon.addonInstance->PositionStream(); 831 return static_cast<CInstanceInputStream*>(instance->toAddon.addonInstance)->GetChapterPos(ch);
663 } 832 }
664 833
665 inline static int64_t ADDON_LengthStream(const AddonInstance_InputStream* instance) 834 inline static bool ADDON_SeekChapter(const AddonInstance_InputStream* instance, int ch)
666 { 835 {
667 return instance->toAddon.addonInstance->LengthStream(); 836 return static_cast<CInstanceInputStream*>(instance->toAddon.addonInstance)->SeekChapter(ch);
668 } 837 }
669 838
670 inline static void ADDON_PauseStream(const AddonInstance_InputStream* instance, double time) 839 inline static int ADDON_ReadStream(const AddonInstance_InputStream* instance,
671 { 840 uint8_t* buffer,
672 instance->toAddon.addonInstance->PauseStream(time); 841 unsigned int bufferSize)
673 } 842 {
843 return static_cast<CInstanceInputStream*>(instance->toAddon.addonInstance)
844 ->ReadStream(buffer, bufferSize);
845 }
674 846
675 inline static bool ADDON_IsRealTimeStream(const AddonInstance_InputStream* instance) 847 inline static int64_t ADDON_SeekStream(const AddonInstance_InputStream* instance,
676 { 848 int64_t position,
677 return instance->toAddon.addonInstance->IsRealTimeStream(); 849 int whence)
678 } 850 {
851 return static_cast<CInstanceInputStream*>(instance->toAddon.addonInstance)
852 ->SeekStream(position, whence);
853 }
679 854
680 AddonInstance_InputStream* m_instanceData; 855 inline static int64_t ADDON_PositionStream(const AddonInstance_InputStream* instance)
681 }; 856 {
857 return static_cast<CInstanceInputStream*>(instance->toAddon.addonInstance)->PositionStream();
858 }
859
860 inline static int64_t ADDON_LengthStream(const AddonInstance_InputStream* instance)
861 {
862 return static_cast<CInstanceInputStream*>(instance->toAddon.addonInstance)->LengthStream();
863 }
864
865 inline static int ADDON_GetBlockSize(const AddonInstance_InputStream* instance)
866 {
867 return static_cast<CInstanceInputStream*>(instance->toAddon.addonInstance)->GetBlockSize();
868 }
869
870 inline static bool ADDON_IsRealTimeStream(const AddonInstance_InputStream* instance)
871 {
872 return static_cast<CInstanceInputStream*>(instance->toAddon.addonInstance)->IsRealTimeStream();
873 }
874
875 AddonInstance_InputStream* m_instanceData;
876};
682 877
683} /* namespace addon */ 878} /* namespace addon */
684} /* namespace kodi */ 879} /* namespace kodi */
880
881#endif /* __cplusplus */