Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions middleware/drm/DrmSessionFactory.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
/**
* @brief Creates an appropriate DRM session based on the given DrmHelper
*/
DrmSession* DrmSessionFactory::GetDrmSession(DrmHelperPtr drmHelper, DrmCallbacks *drmCallbacks)
std::shared_ptr<DrmSession> DrmSessionFactory::GetDrmSession(DrmHelperPtr drmHelper, DrmCallbacks *drmCallbacks)
{
const std::string systemId = drmHelper->ocdmSystemId();

Expand All @@ -42,23 +42,23 @@ DrmSession* DrmSessionFactory::GetDrmSession(DrmHelperPtr drmHelper, DrmCallback
#if defined(USE_CLEARKEY)
if (systemId == CLEAR_KEY_SYSTEM_STRING)
{
return new ClearKeySession();
return std::make_shared<ClearKeySession>();
}
else
#endif
{
return new OCDMBasicSessionAdapter(drmHelper, drmCallbacks);
return std::make_shared<OCDMBasicSessionAdapter>(drmHelper, drmCallbacks);
}
}
else
{
return new OCDMGSTSessionAdapter(drmHelper, drmCallbacks);
return std::make_shared<OCDMGSTSessionAdapter>(drmHelper, drmCallbacks);
}
#else // No form of OCDM support. Attempt to fallback to hardcoded session classes
if (systemId == CLEAR_KEY_SYSTEM_STRING)
{
#if defined(USE_CLEARKEY)
return new ClearKeySession();
return std::make_shared<ClearKeySession>();
#endif // USE_CLEARKEY
}
#endif // Not USE_OPENCDM_ADAPTER
Expand Down
2 changes: 1 addition & 1 deletion middleware/drm/DrmSessionFactory.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,6 @@ class DrmSessionFactory
* @param[in] drmHelper - DrmHelper instance
* @return Pointer to DrmSession.
*/
static DrmSession* GetDrmSession(DrmHelperPtr drmHelper, DrmCallbacks *drmCallbacks);
static std::shared_ptr<DrmSession> GetDrmSession(DrmHelperPtr drmHelper, DrmCallbacks *drmCallbacks);
};
#endif
15 changes: 9 additions & 6 deletions middleware/drm/DrmSessionManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,8 @@ void DrmSessionManager::clearSessionData()
{
if (drmSessionContexts != NULL && drmSessionContexts[i].drmSession != NULL)
{
MW_SAFE_DELETE(drmSessionContexts[i].drmSession);

drmSessionContexts[i].drmSession.reset();
drmSessionContexts[i] = DrmSessionContext();
}

Expand Down Expand Up @@ -198,7 +199,8 @@ void DrmSessionManager::clearDrmSession(bool forceClearSession)
if (drmSessionContexts[i].drmSession != NULL)
{
MW_LOG_WARN("DrmSessionManager:: Clearing failed Session Data Slot : %d", i);
MW_SAFE_DELETE(drmSessionContexts[i].drmSession);

drmSessionContexts[i].drmSession.reset();
}
}
}
Expand Down Expand Up @@ -359,7 +361,7 @@ int DrmSessionManager::getSlotIdForSession(DrmSession* session)
{
for (int i = 0; i < mMaxDRMSessions; i++)
{
if (drmSessionContexts[i].drmSession == session)
if (drmSessionContexts[i].drmSession.get() == session)
{
MW_LOG_INFO("DRM Session found at slot:%d", i);
slot = i;
Expand Down Expand Up @@ -473,7 +475,7 @@ DrmSession* DrmSessionManager::createDrmSession(int &responseCode, int &err, std
mCustomData = ContentUpdateCb(drmHelper, streamType, std::move(keyId), isContentProcess);
if (code == KEY_READY)
{
return drmSessionContexts[selectedSlot].drmSession;
return drmSessionContexts[selectedSlot].drmSession.get();
}

if ((code != KEY_INIT) || (selectedSlot == INVALID_SESSION_SLOT))
Expand Down Expand Up @@ -523,7 +525,7 @@ DrmSession* DrmSessionManager::createDrmSession(int &responseCode, int &err, std
drmSessionContexts[selectedSlot].drmSession->setSecManagerSession(localSession);
}

return drmSessionContexts[selectedSlot].drmSession;
return drmSessionContexts[selectedSlot].drmSession.get();
}

/**
Expand Down Expand Up @@ -703,7 +705,8 @@ KeyState DrmSessionManager::getDrmSession(int &err, std::shared_ptr<DrmHelper> d
MW_LOG_WARN("existing DRM session for %s has different key in slot %d", drmSessionContexts[sessionSlot].drmSession->getKeySystem().c_str(), sessionSlot);
}
MW_LOG_WARN("deleting existing DRM session for %s ", drmSessionContexts[sessionSlot].drmSession->getKeySystem().c_str());
MW_SAFE_DELETE(drmSessionContexts[sessionSlot].drmSession);

drmSessionContexts[sessionSlot].drmSession.reset();
}
this->ProfileUpdateCb();

Expand Down
2 changes: 1 addition & 1 deletion middleware/drm/DrmSessionManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ struct DrmSessionContext
{
std::vector<uint8_t> data;
std::mutex sessionMutex;
DrmSession * drmSession;
std::shared_ptr<DrmSession> drmSession;

DrmSessionContext() : sessionMutex(), drmSession(NULL),data()
{
Expand Down