From d36056441e721c33ac8093718e113f0351f891dc Mon Sep 17 00:00:00 2001 From: CastagnaIT Date: Thu, 24 Aug 2023 08:19:32 +0200 Subject: [PATCH 1/4] [InputStream] Add support to audio codec profiles --- .../addon-instance/inputstream/stream_codec.h | 59 +++++++++++++++++++ .../DVDInputStreams/InputStreamAddon.cpp | 51 ++++++++++++++++ .../DVDInputStreams/InputStreamAddon.h | 1 + 3 files changed, 111 insertions(+) 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 index 91789e73d623f..34f41ba8ea337 100644 --- 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 @@ -141,6 +141,65 @@ extern "C" /// [chroma subsampling](https://en.wikipedia.org/wiki/Chroma_subsampling): 4:2:0, 4:2:2, 4:4:4 /// see [AV1 specification](https://aomedia.org/av1/specification/) AV1CodecProfileProfessional, + + // Audio codec profiles + + /// @brief **AAC** Main Profile + AACCodecProfileMAIN, + + /// @brief **AAC** Low Profile + AACCodecProfileLOW, + + /// @brief **AAC** SSR Profile + AACCodecProfileSSR, + + /// @brief **AAC** LTP Profile + AACCodecProfileLTP, + + /// @brief **High Efficiency AAC** Profile + AACCodecProfileHE, + + /// @brief **High Efficiency AAC** v2 Profile + AACCodecProfileHEV2, + + /// @brief **AAC** LD Profile + AACCodecProfileLD, + + /// @brief **AAC** ELD Profile + AACCodecProfileELD, + + /// @brief **MPEG2 AAC** LOW Profile + MPEG2AACCodecProfileLOW, + + /// @brief **MPEG2 High Efficiency AAC** Profile + MPEG2AACCodecProfileHE, + + /// @brief **DTS** Profile + DTSCodecProfile, + + /// @brief **DTS** Extended Surround Profile + DTSCodecProfileES, + + /// @brief **DTS** 96/24 (96kHz / 24bit) Profile + DTSCodecProfile9624, + + /// @brief **DTS** High-Definition High Resolution Audio Profile + DTSCodecProfileHDHRA, + + /// @brief **DTS** High-Definition Master Audio Profile + DTSCodecProfileHDMA, + + /// @brief **DTS** High-Definition Express Profile + DTSCodecProfileHDExpress, + + /// @brief **DTS** High-Definition Master Audio + DTS:X Profile + DTSCodecProfileHDMAX, + + /// @brief **DTS** High-Definition Master Audio + DTS:X IMAX Profile + DTSCodecProfileHDMAIMAX, + + /// @brief **Dolby Digital** Atmos Profile + DDPlusCodecProfileAtmos, }; ///@} //------------------------------------------------------------------------------ diff --git a/xbmc/cores/VideoPlayer/DVDInputStreams/InputStreamAddon.cpp b/xbmc/cores/VideoPlayer/DVDInputStreams/InputStreamAddon.cpp index f5bfe16264b2a..0901ba8944bb1 100644 --- a/xbmc/cores/VideoPlayer/DVDInputStreams/InputStreamAddon.cpp +++ b/xbmc/cores/VideoPlayer/DVDInputStreams/InputStreamAddon.cpp @@ -415,6 +415,7 @@ KODI_HANDLE CInputStreamAddon::cb_get_stream_transfer(KODI_HANDLE handle, audioStream->iBlockAlign = stream->m_BlockAlign; audioStream->iBitRate = stream->m_BitRate; audioStream->iBitsPerSample = stream->m_BitsPerSample; + audioStream->profile = ConvertAudioCodecProfile(stream->m_codecProfile); demuxStream = audioStream; } else if (stream->m_streamType == INPUTSTREAM_TYPE_VIDEO) @@ -721,6 +722,56 @@ int CInputStreamAddon::ConvertVideoCodecProfile(STREAMCODEC_PROFILE profile) } } +int CInputStreamAddon::ConvertAudioCodecProfile(STREAMCODEC_PROFILE profile) +{ + switch (profile) + { + case AACCodecProfileMAIN: + return FF_PROFILE_AAC_MAIN; + case AACCodecProfileLOW: + return FF_PROFILE_AAC_LOW; + case AACCodecProfileSSR: + return FF_PROFILE_AAC_SSR; + case AACCodecProfileLTP: + return FF_PROFILE_AAC_LTP; + case AACCodecProfileHE: + return FF_PROFILE_AAC_HE; + case AACCodecProfileHEV2: + return FF_PROFILE_AAC_HE_V2; + case AACCodecProfileLD: + return FF_PROFILE_AAC_LD; + case AACCodecProfileELD: + return FF_PROFILE_AAC_ELD; + case MPEG2AACCodecProfileLOW: + return FF_PROFILE_MPEG2_AAC_LOW; + case MPEG2AACCodecProfileHE: + return FF_PROFILE_MPEG2_AAC_HE; + case DTSCodecProfile: + return FF_PROFILE_DTS; + case DTSCodecProfileES: + return FF_PROFILE_DTS_ES; + case DTSCodecProfile9624: + return FF_PROFILE_DTS_96_24; + case DTSCodecProfileHDHRA: + return FF_PROFILE_DTS_HD_HRA; + case DTSCodecProfileHDMA: + return FF_PROFILE_DTS_HD_MA; + case DTSCodecProfileHDExpress: + return FF_PROFILE_DTS_EXPRESS; + case DTSCodecProfileHDMAX: + //! @todo: with ffmpeg >= 6.1 set the appropriate profile + return FF_PROFILE_UNKNOWN; // FF_PROFILE_DTS_HD_MA_X + case DTSCodecProfileHDMAIMAX: + //! @todo: with ffmpeg >= 6.1 set the appropriate profile + return FF_PROFILE_UNKNOWN; // FF_PROFILE_DTS_HD_MA_X_IMAX + case DDPlusCodecProfileAtmos: + //! @todo: with ffmpeg >= 6.1 set the appropriate profile + return FF_PROFILE_UNKNOWN; // FF_PROFILE_EAC3_DDP_ATMOS + default: + return FF_PROFILE_UNKNOWN; + } +} + void CInputStreamAddon::DetectScreenResolution() { unsigned int videoWidth{1280}; diff --git a/xbmc/cores/VideoPlayer/DVDInputStreams/InputStreamAddon.h b/xbmc/cores/VideoPlayer/DVDInputStreams/InputStreamAddon.h index 8471404564357..54546e8305850 100644 --- a/xbmc/cores/VideoPlayer/DVDInputStreams/InputStreamAddon.h +++ b/xbmc/cores/VideoPlayer/DVDInputStreams/InputStreamAddon.h @@ -105,6 +105,7 @@ class CInputStreamAddon protected: static int ConvertVideoCodecProfile(STREAMCODEC_PROFILE profile); + static int ConvertAudioCodecProfile(STREAMCODEC_PROFILE profile); IVideoPlayer* m_player; From 8c8d1ce64a7188f72aff74bbcefca47d817282a6 Mon Sep 17 00:00:00 2001 From: Glenn Guy Date: Mon, 14 Aug 2023 14:20:09 +0200 Subject: [PATCH 2/4] [Android] support ClearKey crypto type --- .../kodi/c-api/addon-instance/inputstream/stream_crypto.h | 5 ++++- xbmc/cores/VideoPlayer/DVDCodecs/Video/AddonVideoCodec.cpp | 3 +++ .../DVDCodecs/Video/DVDVideoCodecAndroidMediaCodec.cpp | 2 ++ .../cores/VideoPlayer/DVDInputStreams/InputStreamAddon.cpp | 7 +++---- xbmc/cores/VideoPlayer/Interface/DemuxCrypto.h | 1 + 5 files changed, 13 insertions(+), 5 deletions(-) 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 index 3d4f62131de38..d15b48ec6ad51 100644 --- 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 @@ -44,7 +44,10 @@ extern "C" /// @brief **3** - To use Wiseplay for processing STREAM_CRYPTO_KEY_SYSTEM_WISEPLAY, - /// @brief **4** - The maximum value to use in a list. + /// @brief **4** - To use ClearKey for processing + STREAM_CRYPTO_KEY_SYSTEM_CLEARKEY, + + /// @brief **5** - The maximum value to use in a list. STREAM_CRYPTO_KEY_SYSTEM_COUNT }; ///@} diff --git a/xbmc/cores/VideoPlayer/DVDCodecs/Video/AddonVideoCodec.cpp b/xbmc/cores/VideoPlayer/DVDCodecs/Video/AddonVideoCodec.cpp index 71f530c484a7e..a0f4d3edaff7c 100644 --- a/xbmc/cores/VideoPlayer/DVDCodecs/Video/AddonVideoCodec.cpp +++ b/xbmc/cores/VideoPlayer/DVDCodecs/Video/AddonVideoCodec.cpp @@ -221,6 +221,9 @@ bool CAddonVideoCodec::CopyToInitData(VIDEOCODEC_INITDATA &initData, CDVDStreamI case CRYPTO_SESSION_SYSTEM_WISEPLAY: initData.cryptoSession.keySystem = STREAM_CRYPTO_KEY_SYSTEM_WISEPLAY; break; + case CRYPTO_SESSION_SYSTEM_CLEARKEY: + initData.cryptoSession.keySystem = STREAM_CRYPTO_KEY_SYSTEM_CLEARKEY; + break; default: return false; } diff --git a/xbmc/cores/VideoPlayer/DVDCodecs/Video/DVDVideoCodecAndroidMediaCodec.cpp b/xbmc/cores/VideoPlayer/DVDCodecs/Video/DVDVideoCodecAndroidMediaCodec.cpp index 0470092aac1fc..b966607aef76c 100644 --- a/xbmc/cores/VideoPlayer/DVDCodecs/Video/DVDVideoCodecAndroidMediaCodec.cpp +++ b/xbmc/cores/VideoPlayer/DVDCodecs/Video/DVDVideoCodecAndroidMediaCodec.cpp @@ -658,6 +658,8 @@ bool CDVDVideoCodecAndroidMediaCodec::Open(CDVDStreamInfo &hints, CDVDCodecOptio uuid = CJNIUUID(0x9A04F07998404286LL, 0xAB92E65BE0885F95LL); else if (m_hints.cryptoSession->keySystem == CRYPTO_SESSION_SYSTEM_WISEPLAY) uuid = CJNIUUID(0X3D5E6D359B9A41E8LL, 0XB843DD3C6E72C42CLL); + else if (m_hints.cryptoSession->keySystem == CRYPTO_SESSION_SYSTEM_CLEARKEY) + uuid = CJNIUUID(0XE2719D58A985B3C9LL, 0X781AB030AF78D30ELL); else { CLog::Log(LOGERROR, "CDVDVideoCodecAndroidMediaCodec::Open Unsupported crypto-keysystem {}", diff --git a/xbmc/cores/VideoPlayer/DVDInputStreams/InputStreamAddon.cpp b/xbmc/cores/VideoPlayer/DVDInputStreams/InputStreamAddon.cpp index 0901ba8944bb1..be8f46d8ab81b 100644 --- a/xbmc/cores/VideoPlayer/DVDInputStreams/InputStreamAddon.cpp +++ b/xbmc/cores/VideoPlayer/DVDInputStreams/InputStreamAddon.cpp @@ -539,10 +539,9 @@ KODI_HANDLE CInputStreamAddon::cb_get_stream_transfer(KODI_HANDLE handle, stream->m_cryptoSession.keySystem < STREAM_CRYPTO_KEY_SYSTEM_COUNT) { static const CryptoSessionSystem map[] = { - CRYPTO_SESSION_SYSTEM_NONE, - CRYPTO_SESSION_SYSTEM_WIDEVINE, - CRYPTO_SESSION_SYSTEM_PLAYREADY, - CRYPTO_SESSION_SYSTEM_WISEPLAY, + CRYPTO_SESSION_SYSTEM_NONE, CRYPTO_SESSION_SYSTEM_WIDEVINE, + CRYPTO_SESSION_SYSTEM_PLAYREADY, CRYPTO_SESSION_SYSTEM_WISEPLAY, + CRYPTO_SESSION_SYSTEM_CLEARKEY, }; demuxStream->cryptoSession = std::shared_ptr( new DemuxCryptoSession(map[stream->m_cryptoSession.keySystem], diff --git a/xbmc/cores/VideoPlayer/Interface/DemuxCrypto.h b/xbmc/cores/VideoPlayer/Interface/DemuxCrypto.h index 4d2a859b3d6ed..b5a7dffee48a7 100644 --- a/xbmc/cores/VideoPlayer/Interface/DemuxCrypto.h +++ b/xbmc/cores/VideoPlayer/Interface/DemuxCrypto.h @@ -20,6 +20,7 @@ enum CryptoSessionSystem : uint8_t CRYPTO_SESSION_SYSTEM_WIDEVINE, CRYPTO_SESSION_SYSTEM_PLAYREADY, CRYPTO_SESSION_SYSTEM_WISEPLAY, + CRYPTO_SESSION_SYSTEM_CLEARKEY, }; struct DemuxCryptoSession From 83fa9d312703ed4d114b8135ccdccca7a7f61812 Mon Sep 17 00:00:00 2001 From: CastagnaIT Date: Mon, 14 Aug 2023 09:22:12 +0200 Subject: [PATCH 3/4] [addons] increase global API to 3.3.0, videocodec to 2.1.0 --- xbmc/addons/kodi-dev-kit/include/kodi/versions.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/xbmc/addons/kodi-dev-kit/include/kodi/versions.h b/xbmc/addons/kodi-dev-kit/include/kodi/versions.h index 7d180cde11f8f..1f887a4ebe02c 100644 --- a/xbmc/addons/kodi-dev-kit/include/kodi/versions.h +++ b/xbmc/addons/kodi-dev-kit/include/kodi/versions.h @@ -108,8 +108,8 @@ #define ADDON_INSTANCE_VERSION_IMAGEDECODER_DEPENDS "c-api/addon-instance/imagedecoder.h" \ "addon-instance/ImageDecoder.h" -#define ADDON_INSTANCE_VERSION_INPUTSTREAM "3.2.0" -#define ADDON_INSTANCE_VERSION_INPUTSTREAM_MIN "3.2.0" +#define ADDON_INSTANCE_VERSION_INPUTSTREAM "3.3.0" +#define ADDON_INSTANCE_VERSION_INPUTSTREAM_MIN "3.3.0" #define ADDON_INSTANCE_VERSION_INPUTSTREAM_XML_ID "kodi.binary.instance.inputstream" #define ADDON_INSTANCE_VERSION_INPUTSTREAM_DEPENDS "c-api/addon-instance/inputstream.h" \ "c-api/addon-instance/inputstream/demux_packet.h" \ @@ -174,8 +174,8 @@ #define ADDON_INSTANCE_VERSION_VISUALIZATION_DEPENDS "addon-instance/Visualization.h" \ "c-api/addon-instance/visualization.h" -#define ADDON_INSTANCE_VERSION_VIDEOCODEC "2.0.4" -#define ADDON_INSTANCE_VERSION_VIDEOCODEC_MIN "2.0.4" +#define ADDON_INSTANCE_VERSION_VIDEOCODEC "2.1.0" +#define ADDON_INSTANCE_VERSION_VIDEOCODEC_MIN "2.1.0" #define ADDON_INSTANCE_VERSION_VIDEOCODEC_XML_ID "kodi.binary.instance.videocodec" #define ADDON_INSTANCE_VERSION_VIDEOCODEC_DEPENDS "c-api/addon-instance/video_codec.h" \ "c-api/addon-instance/inputstream/stream_codec.h" \ From cd613c4d64278cd182c2ed661c6b105703e770de Mon Sep 17 00:00:00 2001 From: CastagnaIT Date: Fri, 18 Aug 2023 09:50:25 +0200 Subject: [PATCH 4/4] [DVDDemuxClient] Allow update profile on stream reset When InputStream interface do OpenStream addon callback the addon may change codec but also profiles, this is the case with InputStream Adaptive since it initially set stream info by using the manifest data, but the demuxer that act after may change these info (so reset stream properties) --- xbmc/cores/VideoPlayer/DVDDemuxers/DVDDemuxClient.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/xbmc/cores/VideoPlayer/DVDDemuxers/DVDDemuxClient.cpp b/xbmc/cores/VideoPlayer/DVDDemuxers/DVDDemuxClient.cpp index e6986467fa8b8..21ded53a1b9fd 100644 --- a/xbmc/cores/VideoPlayer/DVDDemuxers/DVDDemuxClient.cpp +++ b/xbmc/cores/VideoPlayer/DVDDemuxers/DVDDemuxClient.cpp @@ -604,9 +604,9 @@ void CDVDDemuxClient::SetStreamProps(CDemuxStream *stream, std::mapcodec)) + if (!currentStream || forceInit) { toStream->profile = stream->profile; toStream->level = stream->level;