4 #include "open_cdm_adapter.h"
7 #include "opencdmMocks.h"
9 #include "CppUTestExt/MockSupport.h"
23 return &f_mockInstance.sessionInfo;
28 f_mockInstance.callbacks = callbacks;
29 f_mockInstance.mockUserData = mockUserData;
32 void MockOpenCdmReset(
void)
34 memset(&f_mockInstance, 0,
sizeof(f_mockInstance));
38 struct OpenCDMSystem* opencdm_create_system(
const char keySystem[])
40 return (OpenCDMSystem *)mock(
"OpenCDM").actualCall(
"opencdm_create_system")
41 .withParameter(
"keySystem", keySystem)
42 .returnPointerValueOrDefault(0);
45 OpenCDMError opencdm_construct_session(
struct OpenCDMSystem* system,
46 const LicenseType licenseType,
const char initDataType[],
47 const uint8_t initData[],
const uint16_t initDataLength,
48 const uint8_t CDMData[],
const uint16_t CDMDataLength,
49 OpenCDMSessionCallbacks* callbacks,
void* userData,
50 struct OpenCDMSession** session)
52 OpenCDMError retValue = (OpenCDMError)mock(
"OpenCDM").actualCall(
"opencdm_construct_session")
53 .withOutputParameter(
"session", session)
54 .returnIntValueOrDefault(ERROR_NONE);
56 f_mockInstance.sessionInfo.session = *session;
57 f_mockInstance.sessionInfo.callbacks = *callbacks;
58 f_mockInstance.sessionInfo.userData = userData;
60 if (f_mockInstance.callbacks.constructSessionCallback)
62 f_mockInstance.callbacks.constructSessionCallback(&f_mockInstance.sessionInfo, f_mockInstance.mockUserData);
68 OpenCDMError opencdm_destruct_system(
struct OpenCDMSystem* system)
73 KeyStatus opencdm_session_status(
const struct OpenCDMSession* session,
74 const uint8_t keyId[],
const uint8_t length)
79 OpenCDMError opencdm_session_update(
struct OpenCDMSession* session,
80 const uint8_t keyMessage[],
81 const uint16_t keyLength)
83 OpenCDMError retValue = (OpenCDMError)mock(
"OpenCDM").actualCall(
"opencdm_session_update")
84 .withMemoryBufferParameter(
"keyMessage", keyMessage, (
size_t)keyLength)
85 .withIntParameter(
"keyLength", keyLength)
86 .returnIntValueOrDefault(ERROR_NONE);
88 if (f_mockInstance.callbacks.sessionUpdateCallback)
90 f_mockInstance.callbacks.sessionUpdateCallback(&f_mockInstance.sessionInfo, keyMessage, keyLength);
96 OpenCDMError opencdm_gstreamer_session_decrypt(
struct OpenCDMSession* session, GstBuffer* buffer,
97 GstBuffer* subSample,
const uint32_t subSampleCount,
98 GstBuffer* IV, GstBuffer* keyID, uint32_t initWithLast15)
103 OpenCDMError opencdm_session_decrypt(
struct OpenCDMSession* session,
105 const uint32_t encryptedLength,
106 const uint8_t* IV, uint16_t IVLength,
107 const uint8_t* keyId,
const uint16_t keyIdLength,
108 uint32_t initWithLast15)
110 return (OpenCDMError)mock(
"OpenCDM").actualCall(
"opencdm_session_decrypt")
111 .withPointerParameter(
"session", session)
112 .withMemoryBufferParameter(
"encrypted", encrypted, encryptedLength)
113 .withOutputParameter(
"encrypted", encrypted)
114 .withIntParameter(
"encryptedLength", encryptedLength)
115 .withPointerParameter(
"iv", (
void*)IV)
116 .withIntParameter(
"ivLength", IVLength)
117 .withMemoryBufferParameter(
"keyId", keyId, keyIdLength)
118 .withIntParameter(
"keyIdLength", keyIdLength)
119 .returnIntValueOrDefault(ERROR_NONE);
122 OpenCDMError opencdm_session_close(
struct OpenCDMSession* session)
127 OpenCDMError opencdm_destruct_session(
struct OpenCDMSession* session)