Skip to content

Commit

Permalink
Merge pull request #1667 from CastagnaIT/fix_sessions_init_omega
Browse files Browse the repository at this point in the history
[backport][Session][CDM] Dont initialize already initialized sessions
  • Loading branch information
CastagnaIT authored Aug 28, 2024
2 parents f10b5bf + 41661c7 commit fe7294c
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions src/Session.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -399,6 +399,17 @@ bool CSession::InitializeDRM(bool addDefaultKID /* = false */)
// cdmSession 0 is reserved for unencrypted streams
for (size_t ses{1}; ses < m_cdmSessions.size(); ++ses)
{
CCdmSession& session{m_cdmSessions[ses]};

// Check if the decrypter has been previously initialized, if so skip it,
// sessions are collected and never removed and InitializeDRM can be called more times
// depending on how it is used:
// 1) CSession::Initialize->InitializePeriod->InitializeDRM - Used by DASH/SS (single call)
// 2) CInputStreamAdaptive::DemuxRead->m_session->InitializePeriod()->InitializeDRM - On chapter change (single call)
// 3) CInputStreamAdaptive::OpenStream->m_session->PrepareStream->InitializeDRM - Used by HLS (a call for each stream)
if (session.m_cencSingleSampleDecrypter)
continue;

std::vector<uint8_t> initData;
std::string drmOptionalKeyParam;

Expand Down Expand Up @@ -474,8 +485,6 @@ bool CSession::InitializeDRM(bool addDefaultKID /* = false */)
}
}

CCdmSession& session{m_cdmSessions[ses]};

if (addDefaultKID && ses == 1 && session.m_cencSingleSampleDecrypter)
{
// If the CDM has been pre-initialized, on non-android systems
Expand Down

0 comments on commit fe7294c

Please sign in to comment.