Skip to content
Permalink
Browse files

Don't provide secure decoder audio streams to kodi (not android specfic)

  • Loading branch information...
peak3d committed Mar 17, 2018
1 parent e826daa commit 6d2fd78d4c38e188d111e4be18d000eb48ffacef
Showing with 39 additions and 26 deletions.
  1. +1 −1 README.md
  2. +1 −1 inputstream.adaptive/addon.xml.in
  3. +1 −0 src/SSD_dll.h
  4. +6 −11 src/common/AdaptiveTree.cpp
  5. +1 −1 src/common/AdaptiveTree.h
  6. +6 −1 src/main.cpp
  7. +23 −11 wvdecrypter/wvdecrypter.cpp
@@ -1,4 +1,4 @@
# inputstream.adaptive (2.2.0)
# inputstream.adaptive (2.2.1)

This is an adaptive file addon for kodi's new InputStream Interface.

@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<addon
id="inputstream.adaptive"
version="2.2.0"
version="2.2.1"
name="InputStream Adaptive"
provider-name="peak3d">
<requires>@ADDON_DEPENDS@</requires>
@@ -149,6 +149,7 @@ namespace SSD
static const uint32_t SSD_HDCP_RESTRICTED = 8;
static const uint32_t SSD_SINGLE_DECRYPT = 16;
static const uint32_t SSD_SECURE_DECODER = 32;
static const uint32_t SSD_INVALID = 64;

static const uint32_t SSD_MEDIA_VIDEO = 1;
static const uint32_t SSD_MEDIA_AUDIO = 2;
@@ -186,22 +186,17 @@ namespace adaptive
pssh.iv = current_iv_;
switch (type)
{
case VIDEO: pssh.media_ = PSSH::MEDIA_VIDEO; break;
case AUDIO: pssh.media_ = PSSH::MEDIA_AUDIO; break;
case STREAM_TYPE_COUNT: pssh.media_ = PSSH::MEDIA_VIDEO | PSSH::MEDIA_AUDIO; break;
default: pssh.media_ = 0; break;
case VIDEO: pssh.media_ = PSSH::MEDIA_VIDEO; break;
case AUDIO: pssh.media_ = PSSH::MEDIA_AUDIO; break;
case STREAM_TYPE_COUNT: pssh.media_ = PSSH::MEDIA_VIDEO | PSSH::MEDIA_AUDIO; break;
default: pssh.media_ = 0; break;
}

std::vector<PSSH>::iterator pos(std::find(psshSets_.begin() + 1, psshSets_.end(), pssh));
if (pos == psshSets_.end())
pos = psshSets_.insert(psshSets_.end(), pssh);
else
{
if (pos->use_count_)
*pos = pssh;
else
pos->media_ |= pssh.media_;
}
else if (!pos->use_count_)
*pos = pssh;

++psshSets_[pos - psshSets_.begin()].use_count_;
return static_cast<uint16_t>(pos - psshSets_.begin());
@@ -316,7 +316,7 @@ namespace adaptive
static const uint32_t MEDIA_AUDIO = 2;

PSSH() :media_(0), use_count_(0) {};
bool operator == (const PSSH &other) const { return !use_count_ || (pssh_ == other.pssh_ && defaultKID_ == other.defaultKID_ && iv == other.iv); };
bool operator == (const PSSH &other) const { return !use_count_ || (media_ == other.media_ && pssh_ == other.pssh_ && defaultKID_ == other.defaultKID_ && iv == other.iv); };
std::string pssh_;
std::string defaultKID_;
std::string iv;
@@ -2485,7 +2485,11 @@ struct INPUTSTREAM_IDS CInputStreamAdaptive::GetStreamIds()
{
iids.m_streamCount = 0;
for (unsigned int i(1); i <= INPUTSTREAM_IDS::MAX_STREAM_COUNT && i <= m_session->GetStreamCount(); ++i)
if (m_session->GetStream(i)->valid && (m_session->GetMediaTypeMask() & static_cast<uint8_t>(1) << m_session->GetStream(i)->stream_.get_type()))
{
uint8_t cdmId(static_cast<uint8_t>(m_session->GetStream(i)->stream_.getRepresentation()->pssh_set_));
if (m_session->GetStream(i)->valid
&& (m_session->GetMediaTypeMask() & static_cast<uint8_t>(1) << m_session->GetStream(i)->stream_.get_type())
&& !(m_session->GetDecrypterCaps(cdmId).flags & SSD::SSD_DECRYPTER::SSD_CAPS::SSD_INVALID))
{
if (m_session->GetMediaTypeMask() != 0xFF)
{
@@ -2495,6 +2499,7 @@ struct INPUTSTREAM_IDS CInputStreamAdaptive::GetStreamIds()
}
iids.m_streamIds[iids.m_streamCount++] = i;
}
}
} else
iids.m_streamCount = 0;
return iids;
@@ -253,9 +253,13 @@ class WV_CencSingleSampleDecrypter : public AP4_CencSingleSampleDecrypter

void AddSessionKey(const uint8_t *data, size_t data_size, uint32_t status)
{
keys_.push_back(WVSKEY());
keys_.back().keyid = std::string((const char*)data, data_size);
keys_.back().status = static_cast<cdm::KeyStatus>(status);
WVSKEY key;
std::vector<WVSKEY>::iterator res;

key.keyid = std::string((const char*)data, data_size);
if ((res = std::find(keys_.begin(), keys_.end(), key)) == keys_.end())
res = keys_.insert(res, key);
res->status = static_cast<cdm::KeyStatus>(status);
}
bool HasKeyId(const uint8_t *keyid);

@@ -293,6 +297,7 @@ class WV_CencSingleSampleDecrypter : public AP4_CencSingleSampleDecrypter
AP4_DataBuffer pssh_, challenge_;
struct WVSKEY
{
bool operator == (WVSKEY const &other) const { return keyid == other.keyid; };
std::string keyid;
cdm::KeyStatus status;
};
@@ -565,16 +570,18 @@ void WV_CencSingleSampleDecrypter::GetCapabilities(const uint8_t* key, uint32_t
//caps.flags |= (SSD_DECRYPTER::SSD_CAPS::SSD_SECURE_PATH | SSD_DECRYPTER::SSD_CAPS::SSD_ANNEXB_REQUIRED);
//return;

if (media == SSD_DECRYPTER::SSD_CAPS::SSD_MEDIA_VIDEO)
{
for (auto k : keys_)
if (!key || memcmp(k.keyid.data(), key, 16) == 0)
for (auto k : keys_)
if (!key || memcmp(k.keyid.data(), key, 16) == 0)
{
if (k.status != 0)
{
if (k.status != 0)
if (media == SSD_DECRYPTER::SSD_CAPS::SSD_MEDIA_VIDEO)
caps.flags |= (SSD_DECRYPTER::SSD_CAPS::SSD_SECURE_PATH | SSD_DECRYPTER::SSD_CAPS::SSD_ANNEXB_REQUIRED);
break;
else
caps.flags = SSD_DECRYPTER::SSD_CAPS::SSD_INVALID;
}
}
break;
}

if (caps.flags == SSD_DECRYPTER::SSD_CAPS::SSD_SUPPORTS_DECODING)
{
@@ -594,7 +601,12 @@ void WV_CencSingleSampleDecrypter::GetCapabilities(const uint8_t* key, uint32_t
encb[0] = 12;
clearb[0] = 0;
if (DecryptSampleData(poolid, in, out, iv, 1, clearb, encb) != AP4_SUCCESS)
caps.flags |= (SSD_DECRYPTER::SSD_CAPS::SSD_SECURE_PATH | SSD_DECRYPTER::SSD_CAPS::SSD_ANNEXB_REQUIRED);
{
if (media == SSD_DECRYPTER::SSD_CAPS::SSD_MEDIA_VIDEO)
caps.flags |= (SSD_DECRYPTER::SSD_CAPS::SSD_SECURE_PATH | SSD_DECRYPTER::SSD_CAPS::SSD_ANNEXB_REQUIRED);
else
caps.flags = SSD_DECRYPTER::SSD_CAPS::SSD_INVALID;
}
else
{
caps.flags |= SSD_DECRYPTER::SSD_CAPS::SSD_SINGLE_DECRYPT;

0 comments on commit 6d2fd78

Please sign in to comment.
You can’t perform that action at this time.