Line data Source code
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 Sky UK
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 : #ifndef OPENCDM_SESSION_H_
21 : #define OPENCDM_SESSION_H_
22 :
23 : #include <MediaCommon.h>
24 : #include <functional>
25 : #include <opencdm/open_cdm.h>
26 : #include <stdint.h>
27 : #include <string>
28 : #include <utility>
29 : #include <vector>
30 :
31 : struct _GstCaps;
32 : struct _GstBuffer;
33 : typedef struct _GstCaps GstCaps;
34 : typedef struct _GstBuffer GstBuffer;
35 :
36 : class OpenCDMSession
37 : {
38 : public:
39 : typedef std::function<void(const std::vector<uint8_t> &license_renewal_message, uint64_t session_id)> LicenseRenewalCallback;
40 : typedef std::function<void(const std::vector<std::pair<std::vector<uint8_t>, firebolt::rialto::KeyStatus>> &key_statuses,
41 : uint64_t session_id)>
42 : KeyStatusesChangedCallback;
43 :
44 166 : OpenCDMSession() = default;
45 166 : virtual ~OpenCDMSession() = default;
46 :
47 : virtual bool initialize() = 0;
48 : virtual bool initialize(bool) = 0;
49 : virtual bool generateRequest(const std::string &initDataType, const std::vector<uint8_t> &initData,
50 : const std::vector<uint8_t> &cdmData) = 0;
51 : virtual bool loadSession() = 0;
52 : virtual bool updateSession(const std::vector<uint8_t> &license) = 0;
53 : virtual bool getChallengeData(std::vector<uint8_t> &challengeData) = 0;
54 : virtual bool containsKey(const std::vector<uint8_t> &keyId) = 0;
55 : virtual bool setDrmHeader(const std::vector<uint8_t> &drmHeader) = 0;
56 : virtual bool selectKeyId(const std::vector<uint8_t> &keyId) = 0;
57 : virtual void addProtectionMeta(GstBuffer *buffer, GstBuffer *subSample, const uint32_t subSampleCount,
58 : GstBuffer *IV, GstBuffer *keyID, uint32_t initWithLast15) = 0;
59 : virtual bool addProtectionMeta(GstBuffer *buffer) = 0;
60 : virtual bool closeSession() = 0;
61 : virtual bool removeSession() = 0;
62 : virtual KeyStatus status(const std::vector<uint8_t> &key) const = 0;
63 :
64 : virtual const std::string &getSessionId() const = 0;
65 : virtual uint32_t getLastDrmError() const = 0;
66 : };
67 :
68 : #endif // OPENCDM_SESSION_H_
|