diff options
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.h | 621 |
1 files changed, 621 insertions, 0 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 new file mode 100644 index 0000000..76cfe92 --- /dev/null +++ b/xbmc/addons/kodi-addon-dev-kit/include/kodi/addon-instance/Inputstream.h | |||
| @@ -0,0 +1,621 @@ | |||
| 1 | #pragma once | ||
| 2 | /* | ||
| 3 | * Copyright (C) 2005-2017 Team Kodi | ||
| 4 | * http://kodi.tv | ||
| 5 | * | ||
| 6 | * This Program is free software; you can redistribute it and/or modify | ||
| 7 | * it under the terms of the GNU General Public License as published by | ||
| 8 | * the Free Software Foundation; either version 2, or (at your option) | ||
| 9 | * any later version. | ||
| 10 | * | ||
| 11 | * This Program is distributed in the hope that it will be useful, | ||
| 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| 14 | * GNU General Public License for more details. | ||
| 15 | * | ||
| 16 | * You should have received a copy of the GNU General Public License | ||
| 17 | * along with Kodi; see the file COPYING. If not, see | ||
| 18 | * <http://www.gnu.org/licenses/>. | ||
| 19 | * | ||
| 20 | */ | ||
| 21 | |||
| 22 | /* | ||
| 23 | * Parts with a comment named "internal" are only used inside header and not | ||
| 24 | * used or accessed direct during add-on development! | ||
| 25 | */ | ||
| 26 | |||
| 27 | #include "../AddonBase.h" | ||
| 28 | #include "../StreamCrypto.h" | ||
| 29 | #include "../StreamCodec.h" | ||
| 30 | |||
| 31 | #ifdef BUILD_KODI_ADDON | ||
| 32 | #include "../DVDDemuxPacket.h" | ||
| 33 | #else | ||
| 34 | #include "cores/VideoPlayer/DVDDemuxers/DVDDemuxPacket.h" | ||
| 35 | #endif | ||
| 36 | |||
| 37 | namespace kodi { namespace addon { class CInstanceInputStream; }} | ||
| 38 | |||
| 39 | extern "C" { | ||
| 40 | |||
| 41 | /*! | ||
| 42 | * @brief InputStream add-on capabilities. All capabilities are set to "false" as default. | ||
| 43 | */ | ||
| 44 | typedef struct INPUTSTREAM_CAPABILITIES | ||
| 45 | { | ||
| 46 | enum MASKTYPE: uint32_t | ||
| 47 | { | ||
| 48 | /// supports interface IDemux | ||
| 49 | SUPPORTS_IDEMUX = (1 << 0), | ||
| 50 | |||
| 51 | /// supports interface IPosTime | ||
| 52 | SUPPORTS_IPOSTIME = (1 << 1), | ||
| 53 | |||
| 54 | /// supports interface IDisplayTime | ||
| 55 | SUPPORTS_IDISPLAYTIME = (1 << 2), | ||
| 56 | |||
| 57 | /// supports seek | ||
| 58 | SUPPORTS_SEEK = (1 << 3), | ||
| 59 | |||
| 60 | /// supports pause | ||
| 61 | SUPPORTS_PAUSE = (1 << 4) | ||
| 62 | }; | ||
| 63 | |||
| 64 | /// set of supported capabilities | ||
| 65 | uint32_t m_mask; | ||
| 66 | } INPUTSTREAM_CAPABILITIES; | ||
| 67 | |||
| 68 | /*! | ||
| 69 | * @brief structure of key/value pairs passed to addon on Open() | ||
| 70 | */ | ||
| 71 | typedef struct INPUTSTREAM | ||
| 72 | { | ||
| 73 | static const unsigned int MAX_INFO_COUNT = 8; | ||
| 74 | |||
| 75 | const char *m_strURL; | ||
| 76 | |||
| 77 | unsigned int m_nCountInfoValues; | ||
| 78 | struct LISTITEMPROPERTY | ||
| 79 | { | ||
| 80 | const char *m_strKey; | ||
| 81 | const char *m_strValue; | ||
| 82 | } m_ListItemProperties[MAX_INFO_COUNT]; | ||
| 83 | |||
| 84 | const char *m_libFolder; | ||
| 85 | const char *m_profileFolder; | ||
| 86 | } INPUTSTREAM; | ||
| 87 | |||
| 88 | /*! | ||
| 89 | * @brief Array of stream IDs | ||
| 90 | */ | ||
| 91 | typedef struct INPUTSTREAM_IDS | ||
| 92 | { | ||
| 93 | static const unsigned int MAX_STREAM_COUNT = 32; | ||
| 94 | unsigned int m_streamCount; | ||
| 95 | unsigned int m_streamIds[MAX_STREAM_COUNT]; | ||
| 96 | } INPUTSTREAM_IDS; | ||
| 97 | |||
| 98 | /*! | ||
| 99 | * @brief stream properties | ||
| 100 | */ | ||
| 101 | typedef struct INPUTSTREAM_INFO | ||
| 102 | { | ||
| 103 | enum STREAM_TYPE | ||
| 104 | { | ||
| 105 | TYPE_NONE, | ||
| 106 | TYPE_VIDEO, | ||
| 107 | TYPE_AUDIO, | ||
| 108 | TYPE_SUBTITLE, | ||
| 109 | TYPE_TELETEXT | ||
| 110 | } m_streamType; | ||
| 111 | |||
| 112 | enum Codec_FEATURES | ||
| 113 | { | ||
| 114 | FEATURE_DECODE = 1 | ||
| 115 | }; | ||
| 116 | unsigned int m_features; | ||
| 117 | |||
| 118 | char m_codecName[32]; /*!< @brief (required) name of codec according to ffmpeg */ | ||
| 119 | char m_codecInternalName[32]; /*!< @brief (optional) internal name of codec (selectionstream info) */ | ||
| 120 | STREAMCODEC_PROFILE m_codecProfile; /*!< @brief (optional) the profile of the codec */ | ||
| 121 | unsigned int m_pID; /*!< @brief (required) physical index */ | ||
| 122 | |||
| 123 | const uint8_t *m_ExtraData; | ||
| 124 | unsigned int m_ExtraSize; | ||
| 125 | |||
| 126 | char m_language[4]; /*!< @brief ISO 639 3-letter language code (empty string if undefined) */ | ||
| 127 | |||
| 128 | unsigned int m_FpsScale; /*!< @brief Scale of 1000 and a rate of 29970 will result in 29.97 fps */ | ||
| 129 | unsigned int m_FpsRate; | ||
| 130 | unsigned int m_Height; /*!< @brief height of the stream reported by the demuxer */ | ||
| 131 | unsigned int m_Width; /*!< @brief width of the stream reported by the demuxer */ | ||
| 132 | float m_Aspect; /*!< @brief display aspect of stream */ | ||
| 133 | |||
| 134 | unsigned int m_Channels; /*!< @brief (required) amount of channels */ | ||
| 135 | unsigned int m_SampleRate; /*!< @brief (required) sample rate */ | ||
| 136 | unsigned int m_BitRate; /*!< @brief (required) bit rate */ | ||
| 137 | unsigned int m_BitsPerSample; /*!< @brief (required) bits per sample */ | ||
| 138 | unsigned int m_BlockAlign; | ||
| 139 | |||
| 140 | CRYPTO_INFO m_cryptoInfo; | ||
| 141 | } INPUTSTREAM_INFO; | ||
| 142 | |||
| 143 | /*! | ||
| 144 | * @brief Structure to transfer the methods from xbmc_inputstream_dll.h to XBMC | ||
| 145 | */ | ||
| 146 | |||
| 147 | // this are properties given to the addon on create | ||
| 148 | // at this time we have no parameters for the addon | ||
| 149 | typedef struct AddonProps_InputStream /* internal */ | ||
| 150 | { | ||
| 151 | int dummy; | ||
| 152 | } AddonProps_InputStream; | ||
| 153 | |||
| 154 | typedef struct AddonToKodiFuncTable_InputStream /* internal */ | ||
| 155 | { | ||
| 156 | KODI_HANDLE kodiInstance; | ||
| 157 | DemuxPacket* (*allocate_demux_packet)(void* kodiInstance, int data_size); | ||
| 158 | DemuxPacket* (*allocate_encrypted_demux_packet)(void* kodiInstance, unsigned int data_size, unsigned int encrypted_subsample_count); | ||
| 159 | void (*free_demux_packet)(void* kodiInstance, DemuxPacket* packet); | ||
| 160 | } AddonToKodiFuncTable_InputStream; | ||
| 161 | |||
| 162 | struct AddonInstance_InputStream; | ||
| 163 | typedef struct KodiToAddonFuncTable_InputStream /* internal */ | ||
| 164 | { | ||
| 165 | kodi::addon::CInstanceInputStream* addonInstance; | ||
| 166 | |||
| 167 | bool (__cdecl* open)(const AddonInstance_InputStream* instance, INPUTSTREAM* props); | ||
| 168 | void (__cdecl* close)(const AddonInstance_InputStream* instance); | ||
| 169 | const char* (__cdecl* get_path_list)(const AddonInstance_InputStream* instance); | ||
| 170 | void (__cdecl* get_capabilities)(const AddonInstance_InputStream* instance, INPUTSTREAM_CAPABILITIES* capabilities); | ||
| 171 | |||
| 172 | // IDemux | ||
| 173 | struct INPUTSTREAM_IDS (__cdecl* get_stream_ids)(const AddonInstance_InputStream* instance); | ||
| 174 | struct INPUTSTREAM_INFO (__cdecl* get_stream)(const AddonInstance_InputStream* instance, int streamid); | ||
| 175 | void (__cdecl* enable_stream)(const AddonInstance_InputStream* instance, int streamid, bool enable); | ||
| 176 | void(__cdecl* open_stream)(const AddonInstance_InputStream* instance, int streamid); | ||
| 177 | void (__cdecl* demux_reset)(const AddonInstance_InputStream* instance); | ||
| 178 | void (__cdecl* demux_abort)(const AddonInstance_InputStream* instance); | ||
| 179 | void (__cdecl* demux_flush)(const AddonInstance_InputStream* instance); | ||
| 180 | DemuxPacket* (__cdecl* demux_read)(const AddonInstance_InputStream* instance); | ||
| 181 | bool (__cdecl* demux_seek_time)(const AddonInstance_InputStream* instance, double time, bool backwards, double* startpts); | ||
| 182 | void (__cdecl* demux_set_speed)(const AddonInstance_InputStream* instance, int speed); | ||
| 183 | void (__cdecl* set_video_resolution)(const AddonInstance_InputStream* instance, int width, int height); | ||
| 184 | |||
| 185 | // IDisplayTime | ||
| 186 | int (__cdecl* get_total_time)(const AddonInstance_InputStream* instance); | ||
| 187 | int (__cdecl* get_time)(const AddonInstance_InputStream* instance); | ||
| 188 | |||
| 189 | // IPosTime | ||
| 190 | bool (__cdecl* pos_time)(const AddonInstance_InputStream* instance, int ms); | ||
| 191 | |||
| 192 | // Seekable (mandatory) | ||
| 193 | bool (__cdecl* can_pause_stream)(const AddonInstance_InputStream* instance); | ||
| 194 | bool (__cdecl* can_seek_stream)(const AddonInstance_InputStream* instance); | ||
| 195 | |||
| 196 | int (__cdecl* read_stream)(const AddonInstance_InputStream* instance, uint8_t* buffer, unsigned int bufferSize); | ||
| 197 | int64_t(__cdecl* seek_stream)(const AddonInstance_InputStream* instance, int64_t position, int whence); | ||
| 198 | int64_t (__cdecl* position_stream)(const AddonInstance_InputStream* instance); | ||
| 199 | int64_t (__cdecl* length_stream)(const AddonInstance_InputStream* instance); | ||
| 200 | void (__cdecl* pause_stream)(const AddonInstance_InputStream* instance, double time); | ||
| 201 | bool (__cdecl* is_real_time_stream)(const AddonInstance_InputStream* instance); | ||
| 202 | } KodiToAddonFuncTable_InputStream; | ||
| 203 | |||
| 204 | typedef struct AddonInstance_InputStream /* internal */ | ||
| 205 | { | ||
| 206 | AddonProps_InputStream props; | ||
| 207 | AddonToKodiFuncTable_InputStream toKodi; | ||
| 208 | KodiToAddonFuncTable_InputStream toAddon; | ||
| 209 | } AddonInstance_InputStream; | ||
| 210 | |||
| 211 | } /* extern "C" */ | ||
| 212 | |||
| 213 | namespace kodi | ||
| 214 | { | ||
| 215 | namespace addon | ||
| 216 | { | ||
| 217 | |||
| 218 | class CInstanceInputStream : public IAddonInstance | ||
| 219 | { | ||
| 220 | public: | ||
| 221 | CInstanceInputStream(KODI_HANDLE instance) | ||
| 222 | : IAddonInstance(ADDON_INSTANCE_INPUTSTREAM) | ||
| 223 | { | ||
| 224 | if (CAddonBase::m_interface->globalSingleInstance != nullptr) | ||
| 225 | throw std::logic_error("kodi::addon::CInstanceInputStream: Creation of multiple together with single instance way is not allowed!"); | ||
| 226 | |||
| 227 | SetAddonStruct(instance); | ||
| 228 | } | ||
| 229 | |||
| 230 | ~CInstanceInputStream() override = default; | ||
| 231 | |||
| 232 | /*! | ||
| 233 | * Open a stream. | ||
| 234 | * @param props | ||
| 235 | * @return True if the stream has been opened successfully, false otherwise. | ||
| 236 | * @remarks | ||
| 237 | */ | ||
| 238 | virtual bool Open(INPUTSTREAM& props) = 0; | ||
| 239 | |||
| 240 | /*! | ||
| 241 | * Close an open stream. | ||
| 242 | * @remarks | ||
| 243 | */ | ||
| 244 | virtual void Close() = 0; | ||
| 245 | |||
| 246 | /*! | ||
| 247 | * Get Capabilities of this addon. | ||
| 248 | * @param capabilities The add-on's capabilities. | ||
| 249 | * @remarks | ||
| 250 | */ | ||
| 251 | virtual void GetCapabilities(INPUTSTREAM_CAPABILITIES& capabilities) = 0; | ||
| 252 | |||
| 253 | /*! | ||
| 254 | * Get IDs of available streams | ||
| 255 | * @remarks | ||
| 256 | */ | ||
| 257 | virtual INPUTSTREAM_IDS GetStreamIds() = 0; | ||
| 258 | |||
| 259 | /*! | ||
| 260 | * Get stream properties of a stream. | ||
| 261 | * @param streamid unique id of stream | ||
| 262 | * @return struc of stream properties | ||
| 263 | * @remarks | ||
| 264 | */ | ||
| 265 | virtual INPUTSTREAM_INFO GetStream(int streamid) = 0; | ||
| 266 | |||
| 267 | /*! | ||
| 268 | * Enable or disable a stream. | ||
| 269 | * A disabled stream does not send demux packets | ||
| 270 | * @param streamid unique id of stream | ||
| 271 | * @param enable true for enable, false for disable | ||
| 272 | * @remarks | ||
| 273 | */ | ||
| 274 | virtual void EnableStream(int streamid, bool enable) = 0; | ||
| 275 | |||
| 276 | /*! | ||
| 277 | * Opens a stream for playback. | ||
| 278 | * @param streamid unique id of stream | ||
| 279 | * @remarks | ||
| 280 | */ | ||
| 281 | virtual void OpenStream(int streamid) = 0; | ||
| 282 | |||
| 283 | /*! | ||
| 284 | * Reset the demultiplexer in the add-on. | ||
| 285 | * @remarks Required if bHandlesDemuxing is set to true. | ||
| 286 | */ | ||
| 287 | virtual void DemuxReset() { } | ||
| 288 | |||
| 289 | /*! | ||
| 290 | * Abort the demultiplexer thread in the add-on. | ||
| 291 | * @remarks Required if bHandlesDemuxing is set to true. | ||
| 292 | */ | ||
| 293 | virtual void DemuxAbort() { } | ||
| 294 | |||
| 295 | /*! | ||
| 296 | * Flush all data that's currently in the demultiplexer buffer in the add-on. | ||
| 297 | * @remarks Required if bHandlesDemuxing is set to true. | ||
| 298 | */ | ||
| 299 | virtual void DemuxFlush() { } | ||
| 300 | |||
| 301 | /*! | ||
| 302 | * Read the next packet from the demultiplexer, if there is one. | ||
| 303 | * @return The next packet. | ||
| 304 | * If there is no next packet, then the add-on should return the | ||
| 305 | * packet created by calling AllocateDemuxPacket(0) on the callback. | ||
| 306 | * If the stream changed and Kodi's player needs to be reinitialised, | ||
| 307 | * then, the add-on should call AllocateDemuxPacket(0) on the | ||
| 308 | * callback, and set the streamid to DMX_SPECIALID_STREAMCHANGE and | ||
| 309 | * return the value. | ||
| 310 | * The add-on should return NULL if an error occured. | ||
| 311 | * @remarks Return NULL if this add-on won't provide this function. | ||
| 312 | */ | ||
| 313 | virtual DemuxPacket* DemuxRead() { return nullptr; } | ||
| 314 | |||
| 315 | /*! | ||
| 316 | * Notify the InputStream addon/demuxer that Kodi wishes to seek the stream by time | ||
| 317 | * Demuxer is required to set stream to an IDR frame | ||
| 318 | * @param time The absolute time since stream start | ||
| 319 | * @param backwards True to seek to keyframe BEFORE time, else AFTER | ||
| 320 | * @param startpts can be updated to point to where display should start | ||
| 321 | * @return True if the seek operation was possible | ||
| 322 | * @remarks Optional, and only used if addon has its own demuxer. | ||
| 323 | */ | ||
| 324 | virtual bool DemuxSeekTime(double time, bool backwards, double &startpts) { return false; } | ||
| 325 | |||
| 326 | /*! | ||
| 327 | * Notify the InputStream addon/demuxer that Kodi wishes to change playback speed | ||
| 328 | * @param speed The requested playback speed | ||
| 329 | * @remarks Optional, and only used if addon has its own demuxer. | ||
| 330 | */ | ||
| 331 | virtual void DemuxSetSpeed(int speed) { } | ||
| 332 | |||
| 333 | /*! | ||
| 334 | * Sets desired width / height | ||
| 335 | * @param width / hight | ||
| 336 | */ | ||
| 337 | virtual void SetVideoResolution(int width, int height) { } | ||
| 338 | |||
| 339 | /*! | ||
| 340 | * Totel time in ms | ||
| 341 | * @remarks | ||
| 342 | */ | ||
| 343 | virtual int GetTotalTime() { return -1; } | ||
| 344 | |||
| 345 | /*! | ||
| 346 | * Playing time in ms | ||
| 347 | * @remarks | ||
| 348 | */ | ||
| 349 | virtual int GetTime() { return -1; } | ||
| 350 | |||
| 351 | /*! | ||
| 352 | * Positions inputstream to playing time given in ms | ||
| 353 | * @remarks | ||
| 354 | */ | ||
| 355 | virtual bool PosTime(int ms) { return false; } | ||
| 356 | |||
| 357 | |||
| 358 | /*! | ||
| 359 | * Check if the backend support pausing the currently playing stream | ||
| 360 | * This will enable/disable the pause button in Kodi based on the return value | ||
| 361 | * @return false if the InputStream addon/backend does not support pausing, true if possible | ||
| 362 | */ | ||
| 363 | virtual bool CanPauseStream() { return false; } | ||
| 364 | |||
| 365 | /*! | ||
| 366 | * Check if the backend supports seeking for the currently playing stream | ||
| 367 | * This will enable/disable the rewind/forward buttons in Kodi based on the return value | ||
| 368 | * @return false if the InputStream addon/backend does not support seeking, true if possible | ||
| 369 | */ | ||
| 370 | virtual bool CanSeekStream() { return false; } | ||
| 371 | |||
| 372 | /*! | ||
| 373 | * Read from an open stream. | ||
| 374 | * @param buffer The buffer to store the data in. | ||
| 375 | * @param bufferSize The amount of bytes to read. | ||
| 376 | * @return The amount of bytes that were actually read from the stream. | ||
| 377 | * @remarks Return -1 if this add-on won't provide this function. | ||
| 378 | */ | ||
| 379 | virtual int ReadStream(uint8_t* buffer, unsigned int bufferSize) { return -1; } | ||
| 380 | |||
| 381 | /*! | ||
| 382 | * Seek in a stream. | ||
| 383 | * @param position The position to seek to. | ||
| 384 | * @param whence ? | ||
| 385 | * @return The new position. | ||
| 386 | * @remarks Return -1 if this add-on won't provide this function. | ||
| 387 | */ | ||
| 388 | virtual int64_t SeekStream(int64_t position, int whence = SEEK_SET) { return -1; } | ||
| 389 | |||
| 390 | /*! | ||
| 391 | * @return The position in the stream that's currently being read. | ||
| 392 | * @remarks Return -1 if this add-on won't provide this function. | ||
| 393 | */ | ||
| 394 | virtual int64_t PositionStream() { return -1; } | ||
| 395 | |||
| 396 | /*! | ||
| 397 | * @return The total length of the stream that's currently being read. | ||
| 398 | * @remarks Return -1 if this add-on won't provide this function. | ||
| 399 | */ | ||
| 400 | virtual int64_t LengthStream() { return -1; } | ||
| 401 | |||
| 402 | |||
| 403 | /*! | ||
| 404 | * @brief Notify the InputStream addon that Kodi (un)paused the currently playing stream | ||
| 405 | */ | ||
| 406 | virtual void PauseStream(double time) { } | ||
| 407 | |||
| 408 | |||
| 409 | /*! | ||
| 410 | * Check for real-time streaming | ||
| 411 | * @return true if current stream is real-time | ||
| 412 | */ | ||
| 413 | virtual bool IsRealTimeStream() { return true; } | ||
| 414 | |||
| 415 | /*! | ||
| 416 | * @brief Allocate a demux packet. Free with FreeDemuxPacket | ||
| 417 | * @param dataSize The size of the data that will go into the packet | ||
| 418 | * @return The allocated packet | ||
| 419 | */ | ||
| 420 | DemuxPacket* AllocateDemuxPacket(int dataSize) | ||
| 421 | { | ||
| 422 | return m_instanceData->toKodi.allocate_demux_packet(m_instanceData->toKodi.kodiInstance, dataSize); | ||
| 423 | } | ||
| 424 | |||
| 425 | /*! | ||
| 426 | * @brief Allocate a demux packet. Free with FreeDemuxPacket | ||
| 427 | * @param dataSize The size of the data that will go into the packet | ||
| 428 | * @return The allocated packet | ||
| 429 | */ | ||
| 430 | DemuxPacket* AllocateEncryptedDemuxPacket(int dataSize, unsigned int encryptedSubsampleCount) | ||
| 431 | { | ||
| 432 | return m_instanceData->toKodi.allocate_encrypted_demux_packet(m_instanceData->toKodi.kodiInstance, dataSize, encryptedSubsampleCount); | ||
| 433 | } | ||
| 434 | |||
| 435 | /*! | ||
| 436 | * @brief Free a packet that was allocated with AllocateDemuxPacket | ||
| 437 | * @param packet The packet to free | ||
| 438 | */ | ||
| 439 | void FreeDemuxPacket(DemuxPacket* packet) | ||
| 440 | { | ||
| 441 | return m_instanceData->toKodi.free_demux_packet(m_instanceData->toKodi.kodiInstance, packet); | ||
| 442 | } | ||
| 443 | |||
| 444 | private: | ||
| 445 | void SetAddonStruct(KODI_HANDLE instance) | ||
| 446 | { | ||
| 447 | if (instance == nullptr) | ||
| 448 | throw std::logic_error("kodi::addon::CInstanceInputStream: Creation with empty addon structure not allowed, table must be given from Kodi!"); | ||
| 449 | |||
| 450 | m_instanceData = static_cast<AddonInstance_InputStream*>(instance); | ||
| 451 | m_instanceData->toAddon.addonInstance = this; | ||
| 452 | m_instanceData->toAddon.open = ADDON_Open; | ||
| 453 | m_instanceData->toAddon.close = ADDON_Close; | ||
| 454 | m_instanceData->toAddon.get_capabilities = ADDON_GetCapabilities; | ||
| 455 | |||
| 456 | m_instanceData->toAddon.get_stream_ids = ADDON_GetStreamIds; | ||
| 457 | m_instanceData->toAddon.get_stream = ADDON_GetStream; | ||
| 458 | m_instanceData->toAddon.enable_stream = ADDON_EnableStream; | ||
| 459 | m_instanceData->toAddon.open_stream = ADDON_OpenStream; | ||
| 460 | m_instanceData->toAddon.demux_reset = ADDON_DemuxReset; | ||
| 461 | m_instanceData->toAddon.demux_abort = ADDON_DemuxAbort; | ||
| 462 | m_instanceData->toAddon.demux_flush = ADDON_DemuxFlush; | ||
| 463 | m_instanceData->toAddon.demux_read = ADDON_DemuxRead; | ||
| 464 | m_instanceData->toAddon.demux_seek_time = ADDON_DemuxSeekTime; | ||
| 465 | m_instanceData->toAddon.demux_set_speed = ADDON_DemuxSetSpeed; | ||
| 466 | m_instanceData->toAddon.set_video_resolution = ADDON_SetVideoResolution; | ||
| 467 | |||
| 468 | m_instanceData->toAddon.get_total_time = ADDON_GetTotalTime; | ||
| 469 | m_instanceData->toAddon.get_time = ADDON_GetTime; | ||
| 470 | |||
| 471 | m_instanceData->toAddon.pos_time = ADDON_PosTime; | ||
| 472 | |||
| 473 | m_instanceData->toAddon.can_pause_stream = ADDON_CanPauseStream; | ||
| 474 | m_instanceData->toAddon.can_seek_stream = ADDON_CanSeekStream; | ||
| 475 | |||
| 476 | m_instanceData->toAddon.read_stream = ADDON_ReadStream; | ||
| 477 | m_instanceData->toAddon.seek_stream = ADDON_SeekStream; | ||
| 478 | m_instanceData->toAddon.position_stream = ADDON_PositionStream; | ||
| 479 | m_instanceData->toAddon.length_stream = ADDON_LengthStream; | ||
| 480 | m_instanceData->toAddon.pause_stream = ADDON_PauseStream; | ||
| 481 | m_instanceData->toAddon.is_real_time_stream = ADDON_IsRealTimeStream; | ||
| 482 | } | ||
| 483 | |||
| 484 | inline static bool ADDON_Open(const AddonInstance_InputStream* instance, INPUTSTREAM* props) | ||
| 485 | { | ||
| 486 | return instance->toAddon.addonInstance->Open(*props); | ||
| 487 | } | ||
| 488 | |||
| 489 | inline static void ADDON_Close(const AddonInstance_InputStream* instance) | ||
| 490 | { | ||
| 491 | instance->toAddon.addonInstance->Close(); | ||
| 492 | } | ||
| 493 | |||
| 494 | inline static void ADDON_GetCapabilities(const AddonInstance_InputStream* instance, INPUTSTREAM_CAPABILITIES* capabilities) | ||
| 495 | { | ||
| 496 | instance->toAddon.addonInstance->GetCapabilities(*capabilities); | ||
| 497 | } | ||
| 498 | |||
| 499 | |||
| 500 | // IDemux | ||
| 501 | inline static struct INPUTSTREAM_IDS ADDON_GetStreamIds(const AddonInstance_InputStream* instance) | ||
| 502 | { | ||
| 503 | return instance->toAddon.addonInstance->GetStreamIds(); | ||
| 504 | } | ||
| 505 | |||
| 506 | inline static struct INPUTSTREAM_INFO ADDON_GetStream(const AddonInstance_InputStream* instance, int streamid) | ||
| 507 | { | ||
| 508 | return instance->toAddon.addonInstance->GetStream(streamid); | ||
| 509 | } | ||
| 510 | |||
| 511 | inline static void ADDON_EnableStream(const AddonInstance_InputStream* instance, int streamid, bool enable) | ||
| 512 | { | ||
| 513 | instance->toAddon.addonInstance->EnableStream(streamid, enable); | ||
| 514 | } | ||
| 515 | |||
| 516 | inline static void ADDON_OpenStream(const AddonInstance_InputStream* instance, int streamid) | ||
| 517 | { | ||
| 518 | instance->toAddon.addonInstance->OpenStream(streamid); | ||
| 519 | } | ||
| 520 | |||
| 521 | inline static void ADDON_DemuxReset(const AddonInstance_InputStream* instance) | ||
| 522 | { | ||
| 523 | instance->toAddon.addonInstance->DemuxReset(); | ||
| 524 | } | ||
| 525 | |||
| 526 | inline static void ADDON_DemuxAbort(const AddonInstance_InputStream* instance) | ||
| 527 | { | ||
| 528 | instance->toAddon.addonInstance->DemuxAbort(); | ||
| 529 | } | ||
| 530 | |||
| 531 | inline static void ADDON_DemuxFlush(const AddonInstance_InputStream* instance) | ||
| 532 | { | ||
| 533 | instance->toAddon.addonInstance->DemuxFlush(); | ||
| 534 | } | ||
| 535 | |||
| 536 | inline static DemuxPacket* ADDON_DemuxRead(const AddonInstance_InputStream* instance) | ||
| 537 | { | ||
| 538 | return instance->toAddon.addonInstance->DemuxRead(); | ||
| 539 | } | ||
| 540 | |||
| 541 | inline static bool ADDON_DemuxSeekTime(const AddonInstance_InputStream* instance, double time, bool backwards, double *startpts) | ||
| 542 | { | ||
| 543 | return instance->toAddon.addonInstance->DemuxSeekTime(time, backwards, *startpts); | ||
| 544 | } | ||
| 545 | |||
| 546 | inline static void ADDON_DemuxSetSpeed(const AddonInstance_InputStream* instance, int speed) | ||
| 547 | { | ||
| 548 | instance->toAddon.addonInstance->DemuxSetSpeed(speed); | ||
| 549 | } | ||
| 550 | |||
| 551 | inline static void ADDON_SetVideoResolution(const AddonInstance_InputStream* instance, int width, int height) | ||
| 552 | { | ||
| 553 | instance->toAddon.addonInstance->SetVideoResolution(width, height); | ||
| 554 | } | ||
| 555 | |||
| 556 | |||
| 557 | // IDisplayTime | ||
| 558 | inline static int ADDON_GetTotalTime(const AddonInstance_InputStream* instance) | ||
| 559 | { | ||
| 560 | return instance->toAddon.addonInstance->GetTotalTime(); | ||
| 561 | } | ||
| 562 | |||
| 563 | inline static int ADDON_GetTime(const AddonInstance_InputStream* instance) | ||
| 564 | { | ||
| 565 | return instance->toAddon.addonInstance->GetTime(); | ||
| 566 | } | ||
| 567 | |||
| 568 | |||
| 569 | // IPosTime | ||
| 570 | inline static bool ADDON_PosTime(const AddonInstance_InputStream* instance, int ms) | ||
| 571 | { | ||
| 572 | return instance->toAddon.addonInstance->PosTime(ms); | ||
| 573 | } | ||
| 574 | |||
| 575 | // Seekable (mandatory) | ||
| 576 | inline static bool ADDON_CanPauseStream(const AddonInstance_InputStream* instance) | ||
| 577 | { | ||
| 578 | return instance->toAddon.addonInstance->CanPauseStream(); | ||
| 579 | } | ||
| 580 | |||
| 581 | inline static bool ADDON_CanSeekStream(const AddonInstance_InputStream* instance) | ||
| 582 | { | ||
| 583 | return instance->toAddon.addonInstance->CanSeekStream(); | ||
| 584 | } | ||
| 585 | |||
| 586 | |||
| 587 | inline static int ADDON_ReadStream(const AddonInstance_InputStream* instance, uint8_t* buffer, unsigned int bufferSize) | ||
| 588 | { | ||
| 589 | return instance->toAddon.addonInstance->ReadStream(buffer, bufferSize); | ||
| 590 | } | ||
| 591 | |||
| 592 | inline static int64_t ADDON_SeekStream(const AddonInstance_InputStream* instance, int64_t position, int whence) | ||
| 593 | { | ||
| 594 | return instance->toAddon.addonInstance->SeekStream(position, whence); | ||
| 595 | } | ||
| 596 | |||
| 597 | inline static int64_t ADDON_PositionStream(const AddonInstance_InputStream* instance) | ||
| 598 | { | ||
| 599 | return instance->toAddon.addonInstance->PositionStream(); | ||
| 600 | } | ||
| 601 | |||
| 602 | inline static int64_t ADDON_LengthStream(const AddonInstance_InputStream* instance) | ||
| 603 | { | ||
| 604 | return instance->toAddon.addonInstance->LengthStream(); | ||
| 605 | } | ||
| 606 | |||
| 607 | inline static void ADDON_PauseStream(const AddonInstance_InputStream* instance, double time) | ||
| 608 | { | ||
| 609 | instance->toAddon.addonInstance->PauseStream(time); | ||
| 610 | } | ||
| 611 | |||
| 612 | inline static bool ADDON_IsRealTimeStream(const AddonInstance_InputStream* instance) | ||
| 613 | { | ||
| 614 | return instance->toAddon.addonInstance->IsRealTimeStream(); | ||
| 615 | } | ||
| 616 | |||
| 617 | AddonInstance_InputStream* m_instanceData; | ||
| 618 | }; | ||
| 619 | |||
| 620 | } /* namespace addon */ | ||
| 621 | } /* namespace kodi */ | ||
