Skip to content

Commit

Permalink
Merge pull request xbmc#23541 from CastagnaIT/is_audio_profiles
Browse files Browse the repository at this point in the history
[InputStream] Add support to audio codec profiles /  ClearKey crypto type
  • Loading branch information
CastagnaIT authored Aug 24, 2023
2 parents 086ecf1 + cd613c4 commit 0fb3076
Show file tree
Hide file tree
Showing 9 changed files with 130 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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,
};
///@}
//------------------------------------------------------------------------------
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
};
///@}
Expand Down
8 changes: 4 additions & 4 deletions xbmc/addons/kodi-dev-kit/include/kodi/versions.h
Original file line number Diff line number Diff line change
Expand Up @@ -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" \
Expand Down Expand Up @@ -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" \
Expand Down
3 changes: 3 additions & 0 deletions xbmc/cores/VideoPlayer/DVDCodecs/Video/AddonVideoCodec.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 {}",
Expand Down
4 changes: 2 additions & 2 deletions xbmc/cores/VideoPlayer/DVDDemuxers/DVDDemuxClient.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -604,9 +604,9 @@ void CDVDDemuxClient::SetStreamProps(CDemuxStream *stream, std::map<int, std::sh
toStream = streamGen;
}

// only update profile / level if we create a new stream
// only update profile / level if we create a new stream or has been reset stream properties
// existing streams may be corrected by ParsePacket
if (!currentStream || !CodecHasExtraData(stream->codec))
if (!currentStream || forceInit)
{
toStream->profile = stream->profile;
toStream->level = stream->level;
Expand Down
58 changes: 54 additions & 4 deletions xbmc/cores/VideoPlayer/DVDInputStreams/InputStreamAddon.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -538,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<DemuxCryptoSession>(
new DemuxCryptoSession(map[stream->m_cryptoSession.keySystem],
Expand Down Expand Up @@ -721,6 +721,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};
Expand Down
1 change: 1 addition & 0 deletions xbmc/cores/VideoPlayer/DVDInputStreams/InputStreamAddon.h
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,7 @@ class CInputStreamAddon

protected:
static int ConvertVideoCodecProfile(STREAMCODEC_PROFILE profile);
static int ConvertAudioCodecProfile(STREAMCODEC_PROFILE profile);

IVideoPlayer* m_player;

Expand Down
1 change: 1 addition & 0 deletions xbmc/cores/VideoPlayer/Interface/DemuxCrypto.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 0fb3076

Please sign in to comment.