Skip to content

Commit

Permalink
Don't provide secure decoder audio streams to kodi (not android specfic)
Browse files Browse the repository at this point in the history
  • Loading branch information
peak3d committed Mar 17, 2018
1 parent e826daa commit 6d2fd78
Show file tree
Hide file tree
Showing 7 changed files with 39 additions and 26 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -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.

Expand Down
2 changes: 1 addition & 1 deletion inputstream.adaptive/addon.xml.in
Original file line number Diff line number Diff line change
@@ -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>
Expand Down
1 change: 1 addition & 0 deletions src/SSD_dll.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
17 changes: 6 additions & 11 deletions src/common/AdaptiveTree.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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());
Expand Down
2 changes: 1 addition & 1 deletion src/common/AdaptiveTree.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
7 changes: 6 additions & 1 deletion src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand All @@ -2495,6 +2499,7 @@ struct INPUTSTREAM_IDS CInputStreamAdaptive::GetStreamIds()
}
iids.m_streamIds[iids.m_streamCount++] = i;
}
}
} else
iids.m_streamCount = 0;
return iids;
Expand Down
34 changes: 23 additions & 11 deletions wvdecrypter/wvdecrypter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down Expand Up @@ -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;
};
Expand Down Expand Up @@ -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)
{
Expand All @@ -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;
Expand Down

0 comments on commit 6d2fd78

Please sign in to comment.