From 3cb8aa05f8cee9e860cf83531682ff0ed4af6a4f Mon Sep 17 00:00:00 2001 From: manuel Date: Thu, 4 Mar 2021 23:36:40 +0100 Subject: sync with upstream --- .../addon-instance/inputstream/CMakeLists.txt | 9 ++ .../addon-instance/inputstream/demux_packet.h | 117 ++++++++++++++++++ .../addon-instance/inputstream/stream_codec.h | 131 +++++++++++++++++++++ .../addon-instance/inputstream/stream_constants.h | 49 ++++++++ .../addon-instance/inputstream/stream_crypto.h | 129 ++++++++++++++++++++ .../addon-instance/inputstream/timing_constants.h | 42 +++++++ 6 files changed, 477 insertions(+) create mode 100644 xbmc/addons/kodi-dev-kit/include/kodi/c-api/addon-instance/inputstream/CMakeLists.txt create mode 100644 xbmc/addons/kodi-dev-kit/include/kodi/c-api/addon-instance/inputstream/demux_packet.h create mode 100644 xbmc/addons/kodi-dev-kit/include/kodi/c-api/addon-instance/inputstream/stream_codec.h create mode 100644 xbmc/addons/kodi-dev-kit/include/kodi/c-api/addon-instance/inputstream/stream_constants.h create mode 100644 xbmc/addons/kodi-dev-kit/include/kodi/c-api/addon-instance/inputstream/stream_crypto.h create mode 100644 xbmc/addons/kodi-dev-kit/include/kodi/c-api/addon-instance/inputstream/timing_constants.h (limited to 'xbmc/addons/kodi-dev-kit/include/kodi/c-api/addon-instance/inputstream') diff --git a/xbmc/addons/kodi-dev-kit/include/kodi/c-api/addon-instance/inputstream/CMakeLists.txt b/xbmc/addons/kodi-dev-kit/include/kodi/c-api/addon-instance/inputstream/CMakeLists.txt new file mode 100644 index 0000000..9a22c44 --- /dev/null +++ b/xbmc/addons/kodi-dev-kit/include/kodi/c-api/addon-instance/inputstream/CMakeLists.txt @@ -0,0 +1,9 @@ +set(HEADERS demux_packet.h + stream_codec.h + stream_constants.h + stream_crypto.h + timing_constants.h) + +if(NOT ENABLE_STATIC_LIBS) + core_add_library(addons_kodi-dev-kit_include_kodi_c-api_addon-instance_inputstream) +endif() diff --git a/xbmc/addons/kodi-dev-kit/include/kodi/c-api/addon-instance/inputstream/demux_packet.h b/xbmc/addons/kodi-dev-kit/include/kodi/c-api/addon-instance/inputstream/demux_packet.h new file mode 100644 index 0000000..79686ab --- /dev/null +++ b/xbmc/addons/kodi-dev-kit/include/kodi/c-api/addon-instance/inputstream/demux_packet.h @@ -0,0 +1,117 @@ +/* + * Copyright (C) 2005-2020 Team Kodi + * This file is part of Kodi - https://kodi.tv + * + * SPDX-License-Identifier: GPL-2.0-or-later + * See LICENSES/README.md for more information. + */ + +#ifndef C_API_ADDONINSTANCE_INPUTSTREAM_DEMUXPACKET_H +#define C_API_ADDONINSTANCE_INPUTSTREAM_DEMUXPACKET_H + +#include "timing_constants.h" + +#include +#include + +#define DEMUX_SPECIALID_STREAMINFO -10 +#define DEMUX_SPECIALID_STREAMCHANGE -11 + +#ifdef __cplusplus +extern "C" +{ +#endif /* __cplusplus */ + + struct DEMUX_CRYPTO_INFO; + + //============================================================================ + /// @defgroup cpp_kodi_addon_inputstream_Defs_Interface_DEMUX_PACKET struct DEMUX_PACKET + /// @ingroup cpp_kodi_addon_inputstream_Defs_Interface + /// @brief **Demux packet**\n + /// To processed codec and demux inputstream stream. + /// + /// This part is in the "C" style in order to have better performance and + /// possibly to be used in "C" libraries. + /// + /// The structure should be created with @ref kodi::addon::CInstanceInputStream::AllocateDemuxPacket() + /// or @ref kodi::addon::CInstanceInputStream::AllocateEncryptedDemuxPacket() + /// and if not added to Kodi with @ref kodi::addon::CInstanceInputStream::FreeDemuxPacket() + /// be deleted again. + /// + /// Packages that have been given to Kodi and processed will then be deleted + /// by him. + /// + ///@{ + struct DEMUX_PACKET + { + /// @brief Stream package which is given for decoding. + /// + /// @note Associated storage from here is created using + /// @ref kodi::addon::CInstanceInputStream::AllocateDemuxPacket() + /// or @ref kodi::addon::CInstanceInputStream::AllocateEncryptedDemuxPacket(). + uint8_t* pData; + + /// @brief Size of the package given at @ref pData. + int iSize; + + /// @brief Identification of the stream. + int iStreamId; + + /// @brief Identification of the associated demuxer, this can be identical + /// on several streams. + int64_t demuxerId; + + /// @brief The group this data belongs to, used to group data from different + /// streams together. + int iGroupId; + + //------------------------------------------ + + /// @brief Additional packet data that can be provided by the container. + /// + /// Packet can contain several types of side information. + /// + /// This is usually based on that of ffmpeg, see + /// [AVPacketSideData](https://ffmpeg.org/doxygen/trunk/structAVPacketSideData.html). + void* pSideData; + + /// @brief Data elements stored at @ref pSideData. + int iSideDataElems; + + //------------------------------------------ + + /// @brief Presentation time stamp (PTS). + double pts; + + /// @brief Decoding time stamp (DTS). + double dts; + + /// @brief Duration in @ref STREAM_TIME_BASE if available + double duration; + + /// @brief Display time from input stream + int dispTime; + + /// @brief To show that this package allows recreating the presentation by + /// mistake. + bool recoveryPoint; + + //------------------------------------------ + + /// @brief Optional data to allow decryption at processing site if + /// necessary. + /// + /// This can be created using @ref kodi::addon::CInstanceInputStream::AllocateEncryptedDemuxPacket(), + /// otherwise this is declared as `nullptr`. + /// + /// See @ref DEMUX_CRYPTO_INFO for their style. + struct DEMUX_CRYPTO_INFO* cryptoInfo; + }; + ///@} + //---------------------------------------------------------------------------- + +#ifdef __cplusplus +} /* extern "C" */ +#endif /* __cplusplus */ + +#endif /* !C_API_ADDONINSTANCE_INPUTSTREAM_DEMUXPACKET_H */ diff --git a/xbmc/addons/kodi-dev-kit/include/kodi/c-api/addon-instance/inputstream/stream_codec.h b/xbmc/addons/kodi-dev-kit/include/kodi/c-api/addon-instance/inputstream/stream_codec.h new file mode 100644 index 0000000..b489cb9 --- /dev/null +++ b/xbmc/addons/kodi-dev-kit/include/kodi/c-api/addon-instance/inputstream/stream_codec.h @@ -0,0 +1,131 @@ +/* + * Copyright (C) 2017-2018 Team Kodi + * This file is part of Kodi - https://kodi.tv + * + * SPDX-License-Identifier: GPL-2.0-or-later + * See LICENSES/README.md for more information. + */ + +#ifndef C_API_ADDONINSTANCE_INPUTSTREAM_STREAMCODEC_H +#define C_API_ADDONINSTANCE_INPUTSTREAM_STREAMCODEC_H + +#ifdef __cplusplus +extern "C" +{ +#endif /* __cplusplus */ + + //============================================================================== + /// @defgroup cpp_kodi_addon_inputstream_Defs_StreamEncryption_STREAMCODEC_PROFILE enum STREAMCODEC_PROFILE + /// @ingroup cpp_kodi_addon_inputstream_Defs_StreamCodec + /// @brief **The standard defines several sets of capabilities.**\n + /// Which are referred to as profiles, targeting specific classes of applications. + /// + ///@{ + enum STREAMCODEC_PROFILE + { + /// @brief Unknown codec profile + CodecProfileUnknown = 0, + + /// @brief If a codec profile is not required + CodecProfileNotNeeded, + + /// @brief **H264** Baseline Profile (BP, 66)\n + /// \n + /// Primarily for low-cost applications that require additional data loss + /// robustness, this profile is used in some videoconferencing and mobile + /// applications. This profile includes all features that are supported + /// in the Constrained Baseline Profile, plus three additional features + /// that can be used for loss robustness (or for other purposes such as + /// low-delay multi-point video stream compositing). The importance of + /// this profile has faded somewhat since the definition of the Constrained + /// Baseline Profile in 2009. All Constrained Baseline Profile bitstreams + /// are also considered to be Baseline Profile bitstreams, as these two + /// profiles share the same profile identifier code value. + H264CodecProfileBaseline, + + /// @brief **H264** Main Profile (MP, 77)\n + /// \n + /// This profile is used for standard-definition digital TV broadcasts that + /// use the MPEG-4 format as defined in the + /// [DVB standard](http://www.etsi.org/deliver/etsi_ts/101100_101199/101154/01.09.01_60/ts_101154v010901p.pdf). + /// It is not, however, used for high-definition television broadcasts, as the + /// importance of this profile faded when the High Profile was developed + /// in 2004 for that application. + H264CodecProfileMain, + + /// @brief **H264** Extended Profile (XP, 88)\n + /// \n + /// Intended as the streaming video profile, this profile has relatively high + /// compression capability and some extra tricks for robustness to data losses + /// and server stream switching. + H264CodecProfileExtended, + + /// @brief **H264** High Profile (HiP, 100)\n + /// \n + /// The primary profile for broadcast and disc storage applications, + /// particularly for high-definition television applications (for example, + /// this is the profile adopted by the [Blu-ray Disc](https://en.wikipedia.org/wiki/Blu-ray_Disc) + /// storage format and the [DVB](https://en.wikipedia.org/wiki/Digital_Video_Broadcasting) + /// HDTV broadcast service). + H264CodecProfileHigh, + + /// @brief **H264** High 10 Profile (Hi10P, 110)\n + /// \n + /// Going beyond typical mainstream consumer product capabilities, this + /// profile builds on top of the High Profile, adding support for up to 10 + /// bits per sample of decoded picture precision. + H264CodecProfileHigh10, + + /// @brief **H264** High 4:2:2 Profile (Hi422P, 122)\n + /// \n + /// Primarily targeting professional applications that use interlaced video, + /// this profile builds on top of the High 10 Profile, adding support for the + /// 4:2:2 chroma sampling format while using up to 10 bits per sample of + /// decoded picture precision. + H264CodecProfileHigh422, + + /// @brief **H264** High 4:4:4 Predictive Profile (Hi444PP, 244)\n + /// \n + /// This profile builds on top of the High 4:2:2 Profile, supporting up to + /// 4:4:4 chroma sampling, up to 14 bits per sample, and additionally + /// supporting efficient lossless region coding and the coding of each + /// picture as three separate color planes. + H264CodecProfileHigh444Predictive, + + /// @brief **VP9** profile 0\n + /// \n + /// There are several variants of the VP9 format (known as "coding profiles"), + /// which successively allow more features; profile 0 is the basic variant, + /// requiring the least from a hardware implementation. + /// + /// [Color depth](https://en.wikipedia.org/wiki/Color_depth): 8 bit/sample, + /// [chroma subsampling](https://en.wikipedia.org/wiki/Chroma_subsampling): 4:2:0 + VP9CodecProfile0 = 20, + + /// @brief **VP9** profile 1\n + /// \n + /// [Color depth](https://en.wikipedia.org/wiki/Color_depth): 8 bit, + /// [chroma subsampling](https://en.wikipedia.org/wiki/Chroma_subsampling): 4:2:0, 4:2:2, 4:4:4 + VP9CodecProfile1, + + /// @brief **VP9** profile 2\n + /// \n + /// [Color depth](https://en.wikipedia.org/wiki/Color_depth): 10–12 bit, + /// [chroma subsampling](https://en.wikipedia.org/wiki/Chroma_subsampling): 4:2:0 + VP9CodecProfile2, + + /// @brief **VP9** profile 3\n + /// \n + /// [Color depth](https://en.wikipedia.org/wiki/Color_depth): 10–12 bit, + /// [chroma subsampling](https://en.wikipedia.org/wiki/Chroma_subsampling): 4:2:0, 4:2:2, 4:4:4, + /// see [VP9 Bitstream & Decoding Process Specification](https://storage.googleapis.com/downloads.webmproject.org/docs/vp9/vp9-bitstream-specification-v0.6-20160331-draft.pdf) + VP9CodecProfile3, + }; + ///@} + //------------------------------------------------------------------------------ + +#ifdef __cplusplus +} /* extern "C" */ +#endif /* __cplusplus */ + +#endif /* !C_API_ADDONINSTANCE_INPUTSTREAM_STREAMCODEC_H */ diff --git a/xbmc/addons/kodi-dev-kit/include/kodi/c-api/addon-instance/inputstream/stream_constants.h b/xbmc/addons/kodi-dev-kit/include/kodi/c-api/addon-instance/inputstream/stream_constants.h new file mode 100644 index 0000000..f442d64 --- /dev/null +++ b/xbmc/addons/kodi-dev-kit/include/kodi/c-api/addon-instance/inputstream/stream_constants.h @@ -0,0 +1,49 @@ +/* + * Copyright (C) 2017-2020 Team Kodi + * This file is part of Kodi - https://kodi.tv + * + * SPDX-License-Identifier: GPL-2.0-or-later + * See LICENSES/README.md for more information. + */ + +#ifndef C_API_ADDONINSTANCE_INPUTSTREAM_STREAMCONSTANTS_H +#define C_API_ADDONINSTANCE_INPUTSTREAM_STREAMCONSTANTS_H + +/// @ingroup cpp_kodi_addon_inputstream_Defs_StreamConstants +/// @brief The name of the inputstream add-on that should be used by Kodi to +/// play the stream. +/// +/// Leave blank to use Kodi's built-in playing capabilities or to allow +/// ffmpeg to handle directly set to @ref STREAM_PROPERTY_VALUE_INPUTSTREAMFFMPEG. +#define STREAM_PROPERTY_INPUTSTREAM "inputstream" + +/// @ingroup cpp_kodi_addon_inputstream_Defs_StreamConstants +/// @brief Identification string for an input stream. +/// +/// This value can be used in addition to @ref STREAM_PROPERTY_INPUTSTREAM. It is +/// used to provide the respective inpustream addon with additional +/// identification. +/// +/// The difference between this and other stream properties is that it is also +/// passed in the associated @ref kodi::addon::CAddonBase::CreateInstance call. +/// +/// This makes it possible to select different processing classes within the +/// associated add-on. +#define STREAM_PROPERTY_INPUTSTREAM_INSTANCE_ID "inputstream-instance-id" + +/// @ingroup cpp_kodi_addon_inputstream_Defs_StreamConstants +/// @brief "true" to denote that the stream that should be played is a +/// realtime stream. Any other value indicates that this is not a realtime +/// stream. +#define STREAM_PROPERTY_ISREALTIMESTREAM "isrealtimestream" + +/// @ingroup cpp_kodi_addon_inputstream_Defs_StreamConstants +/// @brief Special value for @ref STREAM_PROPERTY_INPUTSTREAM to use +/// ffmpeg to directly play a stream URL. +#define STREAM_PROPERTY_VALUE_INPUTSTREAMFFMPEG "inputstream.ffmpeg" + +/// @ingroup cpp_kodi_addon_inputstream_Defs_StreamConstants +/// @brief Max number of properties that can be sent to an Inputstream addon +#define STREAM_MAX_PROPERTY_COUNT 30 + +#endif /* !C_API_ADDONINSTANCE_INPUTSTREAM_STREAMCONSTANTS_H */ diff --git a/xbmc/addons/kodi-dev-kit/include/kodi/c-api/addon-instance/inputstream/stream_crypto.h b/xbmc/addons/kodi-dev-kit/include/kodi/c-api/addon-instance/inputstream/stream_crypto.h new file mode 100644 index 0000000..4b60306 --- /dev/null +++ b/xbmc/addons/kodi-dev-kit/include/kodi/c-api/addon-instance/inputstream/stream_crypto.h @@ -0,0 +1,129 @@ +/* + * Copyright (C) 2017-2018 Team Kodi + * This file is part of Kodi - https://kodi.tv + * + * SPDX-License-Identifier: GPL-2.0-or-later + * See LICENSES/README.md for more information. + */ + +#ifndef C_API_ADDONINSTANCE_INPUTSTREAM_STREAMCRYPTO_H +#define C_API_ADDONINSTANCE_INPUTSTREAM_STREAMCRYPTO_H + +#include +#include + +#define STREAMCRYPTO_VERSION_LEVEL 2 + +#ifdef __cplusplus +extern "C" +{ +#endif /* __cplusplus */ + + //============================================================================ + /// @defgroup cpp_kodi_addon_inputstream_Defs_StreamEncryption_STREAM_CRYPTO_KEY_SYSTEM enum STREAM_CRYPTO_KEY_SYSTEM + /// @ingroup cpp_kodi_addon_inputstream_Defs_StreamEncryption + /// @brief **Available ways to process stream cryptography**\n + /// For @ref cpp_kodi_addon_inputstream_Defs_StreamEncryption_StreamCryptoSession, + /// this defines the used and required auxiliary modules which are required to + /// process the encryption stream. + /// + /// Used to set wanted [digital rights management](https://en.wikipedia.org/wiki/Digital_rights_management) + /// (DRM) technology provider for stream. + ///@{ + enum STREAM_CRYPTO_KEY_SYSTEM + { + /// @brief **0** - If no path is to be used, this is the default + STREAM_CRYPTO_KEY_SYSTEM_NONE = 0, + + /// @brief **1** - To use [Widevine](https://en.wikipedia.org/wiki/Widevine) for processing + STREAM_CRYPTO_KEY_SYSTEM_WIDEVINE, + + /// @brief **2** - To use [Playready](https://en.wikipedia.org/wiki/PlayReady) for processing + STREAM_CRYPTO_KEY_SYSTEM_PLAYREADY, + + /// @brief **3** - To use Wiseplay for processing + STREAM_CRYPTO_KEY_SYSTEM_WISEPLAY, + + /// @brief **4** - The maximum value to use in a list. + STREAM_CRYPTO_KEY_SYSTEM_COUNT + }; + ///@} + //---------------------------------------------------------------------------- + + //============================================================================ + /// @defgroup cpp_kodi_addon_inputstream_Defs_StreamEncryption_STREAM_CRYPTO_FLAGS enum STREAM_CRYPTO_FLAGS + /// @ingroup cpp_kodi_addon_inputstream_Defs_StreamEncryption + /// @brief **Cryptography flags to use special conditions**\n + /// To identify special extra conditions. + /// + /// @note These variables are bit flags which are created using "|" can be used + /// together. + /// + ///@{ + enum STREAM_CRYPTO_FLAGS + { + /// @brief **0000 0000** - Empty to set if nothing is used. + STREAM_CRYPTO_FLAG_NONE = 0, + + /// @brief **0000 0001** - Is set in flags if decoding has to be done in + /// [trusted execution environment (TEE)](https://en.wikipedia.org/wiki/Trusted_execution_environment). + STREAM_CRYPTO_FLAG_SECURE_DECODER = (1 << 0) + }; + ///@} + //---------------------------------------------------------------------------- + + //============================================================================ + /// @defgroup cpp_kodi_addon_inputstream_Defs_StreamEncryption_DEMUX_CRYPTO_INFO struct DEMUX_CRYPTO_INFO + /// @ingroup cpp_kodi_addon_inputstream_Defs_StreamEncryption + /// @brief **C data structure for processing encrypted streams.**\n + /// If required, this structure is used for every DEMUX_PACKET to be processed. + /// + ///@{ + struct DEMUX_CRYPTO_INFO + { + /// @brief Number of subsamples. + uint16_t numSubSamples; + + /// @brief Flags for later use. + uint16_t flags; + + /// @brief @ref numSubSamples uint16_t's wich define the size of clear size + /// of a subsample. + uint16_t* clearBytes; + + /// @brief @ref numSubSamples uint32_t's wich define the size of cipher size + /// of a subsample. + uint32_t* cipherBytes; + + /// @brief Initialization vector + uint8_t iv[16]; + + /// @brief Key id + uint8_t kid[16]; + }; + ///@} + //---------------------------------------------------------------------------- + + // Data to manage stream cryptography + struct STREAM_CRYPTO_SESSION + { + // keysystem for encrypted media, STREAM_CRYPTO_KEY_SYSTEM_NONE for unencrypted + // media. + // + // See STREAM_CRYPTO_KEY_SYSTEM for available options. + enum STREAM_CRYPTO_KEY_SYSTEM keySystem; + + // Flags to use special conditions, see STREAM_CRYPTO_FLAGS for available flags. + uint8_t flags; + + // The crypto session key id. + char sessionId[256]; + }; + ///@} + //---------------------------------------------------------------------------- + +#ifdef __cplusplus +} /* extern "C" */ +#endif /* __cplusplus */ + +#endif /* !C_API_ADDONINSTANCE_INPUTSTREAM_STREAMCRYPTO_H */ diff --git a/xbmc/addons/kodi-dev-kit/include/kodi/c-api/addon-instance/inputstream/timing_constants.h b/xbmc/addons/kodi-dev-kit/include/kodi/c-api/addon-instance/inputstream/timing_constants.h new file mode 100644 index 0000000..a226a0d --- /dev/null +++ b/xbmc/addons/kodi-dev-kit/include/kodi/c-api/addon-instance/inputstream/timing_constants.h @@ -0,0 +1,42 @@ +/* + * Copyright (C) 2015-2020 Team Kodi + * This file is part of Kodi - https://kodi.tv + * + * SPDX-License-Identifier: GPL-2.0-or-later + * See LICENSES/README.md for more information. + */ + +#ifndef C_API_ADDONINSTANCE_INPUTSTREAM_TIMINGCONSTANTS_H +#define C_API_ADDONINSTANCE_INPUTSTREAM_TIMINGCONSTANTS_H + +/// @ingroup cpp_kodi_addon_inputstream_Defs_TimingConstants +/// @brief Speed value to pause stream in playback. +/// +#define STREAM_PLAYSPEED_PAUSE 0 // frame stepping + +/// @ingroup cpp_kodi_addon_inputstream_Defs_TimingConstants +/// @brief Speed value to perform stream playback at normal speed. +/// +/// See @ref STREAM_PLAYSPEED_PAUSE for pause of stream. +/// +#define STREAM_PLAYSPEED_NORMAL 1000 + +/// @ingroup cpp_kodi_addon_inputstream_Defs_TimingConstants +/// @brief Time base represented as integer. +/// +#define STREAM_TIME_BASE 1000000 + +/// @ingroup cpp_kodi_addon_inputstream_Defs_TimingConstants +/// @brief Undefined timestamp value. +/// +/// Usually reported by demuxer that work on containers that do not provide +/// either pts or dts. +/// +#define STREAM_NOPTS_VALUE 0xFFF0000000000000 + +// "C" defines to translate stream times +#define STREAM_TIME_TO_MSEC(x) ((int)((double)(x)*1000 / STREAM_TIME_BASE)) +#define STREAM_SEC_TO_TIME(x) ((double)(x)*STREAM_TIME_BASE) +#define STREAM_MSEC_TO_TIME(x) ((double)(x)*STREAM_TIME_BASE / 1000) + +#endif /* !C_API_ADDONINSTANCE_INPUTSTREAM_TIMINGCONSTANTS_H */ -- cgit v1.2.3