Skip to content

Commit

Permalink
Fix playback of HLS encrypted streams.
Browse files Browse the repository at this point in the history
The allows ABC iView on iPad to stream to Myth
  • Loading branch information
jyavenard committed Dec 28, 2012
1 parent 83872a3 commit c5a4229
Showing 1 changed file with 13 additions and 6 deletions.
19 changes: 13 additions & 6 deletions mythtv/libs/libmythtv/HLS/httplivestreambuffer.cpp
Expand Up @@ -265,11 +265,18 @@ class HLSSegment
return RET_OK;
QByteArray key;
bool ret = downloadURL(m_psz_key_path, &key);
if (ret != RET_OK || key.size() != AES_BLOCK_SIZE)
if (!ret || key.size() != AES_BLOCK_SIZE)
{
LOG(VB_PLAYBACK, LOG_ERR, LOC +
QString("The AES key loaded doesn't have the right size (%1)")
.arg(key.size()));
if (ret)
{
LOG(VB_PLAYBACK, LOG_ERR, LOC +
QString("The AES key loaded doesn't have the right size (%1)")
.arg(key.size()));
}
else
{
LOG(VB_PLAYBACK, LOG_ERR, LOC + "Failed to download AES key");
}
return RET_ERROR;
}
AES_set_decrypt_key((const unsigned char*)key.constData(), 128, &m_aeskey);
Expand Down Expand Up @@ -309,7 +316,7 @@ class HLSSegment
m_data.size() - aeslen);

// remove the PKCS#7 padding from the buffer
int pad = m_data[m_data.size()-1];
int pad = decrypted_data[m_data.size()-1];
if (pad <= 0 || pad > AES_BLOCK_SIZE)
{
LOG(VB_PLAYBACK, LOG_ERR, LOC +
Expand Down Expand Up @@ -1987,7 +1994,7 @@ int HLSRingBuffer::ParseKey(HLSStream *hls, const QString line)
hls->SetKeyPath(decoded_URI(uri.remove(QChar(QLatin1Char('"')))));

iv = ParseAttributes(line, "IV");
if (!hls->SetAESIV(iv))
if (!iv.isNull() && !hls->SetAESIV(iv))
{
LOG(VB_PLAYBACK, LOG_ERR, LOC + "invalid IV");
err = RET_ERROR;
Expand Down

0 comments on commit c5a4229

Please sign in to comment.