RDK Documentation (Open Sourced RDK Components)
AampOcdmBasicSessionAdapter.cpp
Go to the documentation of this file.
1 /**
2  * @file AampOcdmBasicSessionAdapter.cpp
3  * @brief Handles operations on OCDM session
4  */
5 
6 #include "AampOcdmBasicSessionAdapter.h"
7 #include "AampMutex.h"
8 
9 int AAMPOCDMBasicSessionAdapter::decrypt(const uint8_t *f_pbIV, uint32_t f_cbIV, const uint8_t *payloadData,
10  uint32_t payloadDataSize, uint8_t **ppOpaqueData)
11 {
12  if (!verifyOutputProtection())
13  {
14  return HDCP_COMPLIANCE_CHECK_FAILURE;
15  }
16 
17  AampMutexHold decryptMutexHold(decryptMutex);
18 
19  uint8_t *dataToSend = const_cast<uint8_t *>(payloadData);
20  uint32_t sizeToSend = payloadDataSize;
21  std::vector<uint8_t> vdata;
22 
23  if (m_drmHelper->getMemorySystem() != nullptr)
24  {
25  if (!m_drmHelper->getMemorySystem()->encode(payloadData, payloadDataSize, vdata))
26  {
27  AAMPLOG_WARN("Failed to encode memory for transmission");
28  return -1;
29  }
30  sizeToSend = vdata.size();
31  dataToSend = vdata.data();
32  }
33 
34  int retvalue = opencdm_session_decrypt(m_pOpenCDMSession,
35  dataToSend,
36  sizeToSend,
37  f_pbIV, f_cbIV,
38  m_keyId.data(), m_keyId.size());
39  if (retvalue != 0)
40  {
41  if (m_drmHelper->getMemorySystem() != nullptr)
42  {
43  m_drmHelper->getMemorySystem()->terminateEarly();
44  }
45  AAMPLOG_INFO("decrypt returned : %d", retvalue);
46  }
47  else if (m_drmHelper->getMemorySystem() != nullptr)
48  {
49  if (!m_drmHelper->getMemorySystem()->decode(dataToSend, sizeToSend, const_cast<uint8_t*>(payloadData), payloadDataSize))
50  {
51  AAMPLOG_WARN("Failed to decode memory for transmission");
52  return -1;
53  }
54  }
55  return retvalue;
56 }
AampMutexHold
auto Lock the provided mutex during the object scope
Definition: AampMutex.h:34
AAMPOCDMBasicSessionAdapter::decrypt
int decrypt(const uint8_t *f_pbIV, uint32_t f_cbIV, const uint8_t *payloadData, uint32_t payloadDataSize, uint8_t **ppOpaqueData)
Function to decrypt stream buffer.
Definition: AampOcdmBasicSessionAdapter.cpp:9
AampMutex.h
Helper class for scoped mutex lock.