Skip to content

Commit

Permalink
fix out of range
Browse files Browse the repository at this point in the history
  • Loading branch information
CastagnaIT committed Oct 31, 2024
1 parent f72388e commit a17ba62
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions src/Session.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1268,14 +1268,21 @@ bool SESSION::CSession::OnGetStream(int streamid, kodi::addon::InputstreamInfo&
if (psshSetPos != PSSHSET_POS_DEFAULT ||
stream->m_adStream.getPeriod()->GetEncryptionState() == EncryptionState::NOT_SUPPORTED)
{
if (!GetSingleSampleDecryptor(psshSetPos))
// NOTE "psshSetPos < m_cdmSessions.size()" CONDITION:
// is required because the GetNextRepresentation method called by AdaptiveStream "ensure segment" method
// can change stream quality that download new manifests, parsing new manifests may add new PSSH's,
// so there will be a higher psshSetPos value than m_cdmSessions
// this happens for HLS case because the m_cdmSessions is updated with OpenStream.
// On DEMUX_SPECIALID_STREAMCHANGE event Kodi query all streams by calling GetStream in advance
// than OpenStream so there is a higher psshSetPos value and GetSingleSampleDecryptor cannot get a ptr
if (psshSetPos < m_cdmSessions.size() && !GetSingleSampleDecryptor(psshSetPos))
{
// If the stream is protected with a unsupported DRM, we have to stop the playback,
// since there are no ways to stop playback when Kodi request streams
// we are forced to delete all CStream's here, so that when demux reader will starts
// will have no data to process, and so stop the playback
// (other streams may have been requested/opened before this one)
LOG::Log(LOGERROR, "GetStream(%d): Decrypter for the stream not found");
LOG::Log(LOGERROR, "GetStream(%d): Decrypter for the stream not found", streamid);
DeleteStreams();
return false;
}
Expand Down

0 comments on commit a17ba62

Please sign in to comment.