-
Notifications
You must be signed in to change notification settings - Fork 18
Expand file tree
/
Copy pathOcdmSession.h
More file actions
164 lines (128 loc) · 5.79 KB
/
OcdmSession.h
File metadata and controls
164 lines (128 loc) · 5.79 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
/*
* If not stated otherwise in this file or this component's LICENSE file the
* following copyright and licenses apply:
*
* Copyright 2022 Sky UK
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef FIREBOLT_RIALTO_WRAPPERS_OCDM_SESSION_H_
#define FIREBOLT_RIALTO_WRAPPERS_OCDM_SESSION_H_
#include "IOcdmSession.h"
#include "IOcdmSessionClient.h"
#include "opencdm/open_cdm.h"
#include <memory>
#include <string>
namespace firebolt::rialto::wrappers
{
/**
* @brief The definition of the OcdmSession.
*/
class OcdmSession : public IOcdmSession
{
public:
/**
* @brief The constructor.
*
* @param[in] systemHandle : The system handle for this session.
* @param[in] client : Client object for callbacks.
*/
OcdmSession(struct OpenCDMSystem *systemHandle, IOcdmSessionClient *client);
/**
* @brief Virtual destructor.
*/
virtual ~OcdmSession();
MediaKeyErrorStatus constructSession(KeySessionType sessionType, InitDataType initDataType,
const uint8_t initData[], uint32_t initDataSize) override;
MediaKeyErrorStatus getChallengeData(bool isLDL, uint8_t *challenge, uint32_t *challengeSize) override;
MediaKeyErrorStatus storeLicenseData(const uint8_t challengeData[], uint32_t challengeSize) override;
MediaKeyErrorStatus load() override;
MediaKeyErrorStatus update(const uint8_t response[], uint32_t responseSize) override;
MediaKeyErrorStatus decryptBuffer(GstBuffer *encrypted, GstCaps *caps) override;
MediaKeyErrorStatus remove();
MediaKeyErrorStatus close();
MediaKeyErrorStatus cancelChallengeData();
MediaKeyErrorStatus cleanDecryptContext();
MediaKeyErrorStatus destructSession();
KeyStatus getStatus(const uint8_t keyId[], const uint8_t keyIdLength);
MediaKeyErrorStatus getCdmKeySessionId(std::string &cdmKeySessionId) override;
MediaKeyErrorStatus selectKeyId(uint8_t keyLength, const uint8_t keyId[]) override;
uint32_t hasKeyId(const uint8_t keyId[], const uint8_t keyIdSize) override;
MediaKeyErrorStatus setDrmHeader(const uint8_t drmHeader[], uint32_t drmHeaderSize) override;
MediaKeyErrorStatus getLastDrmError(uint32_t &errorCode) override;
void handleProcessChallenge(struct OpenCDMSession *session, const char url[], const uint8_t challenge[],
const uint16_t challengeLength);
void handleKeyUpdated(struct OpenCDMSession *session, const uint8_t keyId[], const uint8_t keyIdLength);
void handleAllKeysUpdated(const struct OpenCDMSession *session);
void handleError(struct OpenCDMSession *session, const char message[]);
private:
using OcdmGstSessionDecryptExFn = OpenCDMError (*)(struct OpenCDMSession *, GstBuffer *, GstBuffer *,
const uint32_t, GstBuffer *, GstBuffer *, uint32_t, GstCaps *);
using OcdmGstSessionDecryptBufferOnceFn = OpenCDMError (*)(struct OpenCDMSession *, GstBuffer *, GstCaps *);
/**
* @brief The System handle.
*/
struct OpenCDMSystem *m_systemHandle;
/**
* @brief The media keys client to callback.
*/
IOcdmSessionClient *m_ocdmSessionClient;
/**
* @brief The ocdm callback methods.
*/
OpenCDMSessionCallbacks m_ocdmCallbacks;
/**
* @brief The session pointer.
*/
struct OpenCDMSession *m_session;
static OcdmGstSessionDecryptExFn m_ocdmGstSessionDecryptEx;
static OcdmGstSessionDecryptBufferOnceFn m_ocdmGstSessionDecryptBufferOnce;
/**
* @brief Requests the processing of the challenge data.
*
* @param[in] session : The ocdm session object pointer.
* @param[in] user_data : The ocdm client pointer.
* @param[in] url : The url string.
* @param[in] challenge : The challenge id buffer.
* @param[in] challengeLength : The length of the challenge buffer.
*/
static void onProcessChallenge(struct OpenCDMSession *session, void *userData, const char url[],
const uint8_t challenge[], const uint16_t challengeLength);
/**
* @brief Notifys of a key status change for key_id.
*
* @param[in] session : The ocdm session object pointer.
* @param[in] user_data : The ocdm client pointer.
* @param[in] keyId : The key id buffer.
* @param[in] keyIdLength : The length of the key id buffer.
*/
static void onKeyUpdated(struct OpenCDMSession *session, void *userData, const uint8_t keyId[],
const uint8_t keyIdLength);
/**
* @brief Notifys that all the key statuses have been updated.
*
* @param[in] session : The ocdm session object pointer.
* @param[in] user_data : The ocdm client pointer.
*/
static void onAllKeysUpdated(const struct OpenCDMSession *session, void *userData);
/**
* @brief Notifys of a new ocdm error.
*
* @param[in] session : The ocdm session object pointer.
* @param[in] user_data : The ocdm client pointer.
* @param[in] message : The error message received.
*/
static void onError(struct OpenCDMSession *session, void *userData, const char message[]);
};
}; // namespace firebolt::rialto::wrappers
#endif // FIREBOLT_RIALTO_WRAPPERS_OCDM_SESSION_H_