RDK Documentation (Open Sourced RDK Components)
opencdmMocks.cpp
1 /*
2  * If not stated otherwise in this file or this component's license file the
3  * following copyright and licenses apply:
4  *
5  * Copyright 2022 RDK Management
6  *
7  * Licensed under the Apache License, Version 2.0 (the "License");
8  * you may not use this file except in compliance with the License.
9  * You may obtain a copy of the License at
10  *
11  * http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing, software
14  * distributed under the License is distributed on an "AS IS" BASIS,
15  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16  * See the License for the specific language governing permissions and
17  * limitations under the License.
18  */
19 
20 #include "opencdmMocks.h"
21 
22 AampMockOpenCdm *g_mockOpenCdm;
23 
24 struct OpenCDMSystem* opencdm_create_system(const char keySystem[])
25 {
26  return g_mockOpenCdm->opencdm_create_system(keySystem);
27 }
28 
29 OpenCDMError opencdm_construct_session(struct OpenCDMSystem* system,
30  const LicenseType licenseType,
31  const char initDataType[],
32  const uint8_t initData[],
33  const uint16_t initDataLength,
34  const uint8_t CDMData[],
35  const uint16_t CDMDataLength,
36  OpenCDMSessionCallbacks* callbacks,
37  void* userData,
38  struct OpenCDMSession** session)
39 {
40  return g_mockOpenCdm->opencdm_construct_session(system,
41  licenseType,
42  initDataType,
43  initData,
44  initDataLength,
45  CDMData,
46  CDMDataLength,
47  callbacks,
48  userData,
49  session);
50 }
51 
52 OpenCDMError opencdm_destruct_system(struct OpenCDMSystem* system)
53 {
54  return g_mockOpenCdm->opencdm_destruct_system(system);
55 }
56 
57 KeyStatus opencdm_session_status(const struct OpenCDMSession* session,
58  const uint8_t keyId[],
59  const uint8_t length)
60 {
61  return g_mockOpenCdm->opencdm_session_status(session, keyId, length);
62 }
63 
64 OpenCDMError opencdm_session_update(struct OpenCDMSession* session,
65  const uint8_t keyMessage[],
66  const uint16_t keyLength)
67 {
68  return g_mockOpenCdm->opencdm_session_update(session, keyMessage, keyLength);
69 }
70 
71 OpenCDMError opencdm_gstreamer_session_decrypt(struct OpenCDMSession* session,
72  GstBuffer* buffer,
73  GstBuffer* subSample,
74  const uint32_t subSampleCount,
75  GstBuffer* IV,
76  GstBuffer* keyID,
77  uint32_t initWithLast15)
78 {
79  return g_mockOpenCdm->opencdm_gstreamer_session_decrypt(session, buffer, subSample, subSampleCount, IV, keyID,initWithLast15);
80 }
81 
82 OpenCDMError opencdm_session_decrypt(struct OpenCDMSession* session,
83  uint8_t encrypted[],
84  const uint32_t encryptedLength,
85  const uint8_t* IV,
86  uint16_t IVLength,
87  const uint8_t* keyId,
88  const uint16_t keyIdLength,
89  uint32_t initWithLast15,
90  uint8_t* streamInfo,
91  uint16_t streamInfoLength)
92 {
93  return g_mockOpenCdm->opencdm_session_decrypt(session, encrypted, encryptedLength, IV, IVLength, keyId, keyIdLength, initWithLast15, streamInfo, streamInfoLength);
94 }
95 
96 OpenCDMError opencdm_session_close(struct OpenCDMSession* session)
97 {
98  return g_mockOpenCdm->opencdm_session_close(session);
99 }
100 
101 OpenCDMError opencdm_destruct_session(struct OpenCDMSession* session)
102 {
103  return ERROR_NONE;
104 }
AampMockOpenCdm
Definition: opencdmMocks.h:28