1 #ifndef OpenCDMSessionAdapter_h
2 #define OpenCDMSessionAdapter_h
14 #include <open_cdm_adapter.h>
28 pthread_cond_t condition;
29 pthread_condattr_t condAttr;
31 Event() : signalled(
false), lock(PTHREAD_MUTEX_INITIALIZER), condition(PTHREAD_COND_INITIALIZER), condAttr() {
32 pthread_mutex_init(&lock, NULL);
33 pthread_condattr_init(&condAttr);
34 pthread_condattr_setclock(&condAttr, CLOCK_MONOTONIC );
35 pthread_cond_init(&condition, &condAttr);
38 pthread_cond_destroy(&condition);
39 pthread_mutex_destroy(&lock);
40 pthread_condattr_destroy(&condAttr);
43 inline bool wait(
const uint32_t waitTime)
46 pthread_mutex_lock(&lock);
49 ret = pthread_cond_wait(&condition, &lock);
52 clock_gettime(CLOCK_MONOTONIC, &time);
54 time.tv_nsec += ((waitTime % 1000) * 1000 * 1000);
55 time.tv_sec += (waitTime / 1000) + (time.tv_nsec / 1000000000);
56 time.tv_nsec = time.tv_nsec % 1000000000;
58 ret = pthread_cond_timedwait(&condition, &lock, &time);
64 pthread_mutex_unlock(&lock);
66 return ((ret == 0)?
true:
false);
71 pthread_mutex_lock(&lock);
73 pthread_cond_broadcast(&condition);
74 pthread_mutex_unlock(&lock);
85 pthread_mutex_t decryptMutex;
89 OpenCDMSession* m_pOpenCDMSession;
90 #ifdef USE_THUNDER_OCDM_API_0_2
91 struct OpenCDMSystem* m_pOpenCDMSystem;
93 struct OpenCDMAccessor* m_pOpenCDMSystem;
95 OpenCDMSessionCallbacks m_OCDMSessionCallbacks;
98 std::string m_challenge;
99 uint16_t m_challengeSize;
101 std::string m_destUrl;
102 KeyStatus m_keyStatus;
103 bool m_keyStateIndeterminate;
104 std::vector<uint8_t> m_keyStored;
106 Event m_challengeReady;
107 Event m_keyStatusReady;
108 Event m_keyStatusWait;
111 std::vector<uint8_t> m_keyId;
113 std::shared_ptr<AampDrmHelper> m_drmHelper;
116 bool verifyOutputProtection();
118 void processOCDMChallenge(
const char destUrl[],
const uint8_t challenge[],
const uint16_t challengeSize);
119 void keysUpdatedOCDM();
120 void keyUpdateOCDM(
const uint8_t key[],
const uint8_t keySize);
121 long long timeBeforeCallback;
124 void initAampDRMSystem();
131 void generateAampDRMSession(
const uint8_t *f_pbInitData,
132 uint32_t f_cbInitData, std::string &customData);
133 DrmData * aampGenerateKeyRequest(
string& destinationURL, uint32_t timeout);
134 int aampDRMProcessKey(
DrmData* key, uint32_t timeout);
136 void clearDecryptContext();
137 void setKeyId(
const std::vector<uint8_t>& keyId);
138 bool waitForState(
KeyState state,
const uint32_t timeout)
override;