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 FIREBOLT_RIALTO_CLIENT_MEDIA_KEYS_H_
21 : #define FIREBOLT_RIALTO_CLIENT_MEDIA_KEYS_H_
22 :
23 : #include "IMediaKeys.h"
24 : #include "IMediaKeysIpcFactory.h"
25 : #include <memory>
26 : #include <string>
27 : #include <vector>
28 :
29 : namespace firebolt::rialto
30 : {
31 : /**
32 : * @brief IMediaKeys factory class definition.
33 : */
34 : class MediaKeysFactory : public IMediaKeysFactory
35 : {
36 : public:
37 2 : MediaKeysFactory() = default;
38 2 : ~MediaKeysFactory() override = default;
39 :
40 : std::unique_ptr<IMediaKeys> createMediaKeys(const std::string &keySystem) const override;
41 :
42 : /**
43 : * @brief IMediaKeys factory method with factory parameters for mock injection.
44 : *
45 : * @param[in] keySystem : The key system for which to create a Media Keys instance
46 : * @param[in] mediaKeysIpcFactory : This was added for the test environment where a mock object needs to be passed in.
47 : *
48 : * @retval the new media keys instance or null on error.
49 : */
50 : std::unique_ptr<IMediaKeys>
51 : createMediaKeys(const std::string &keySystem,
52 : std::weak_ptr<firebolt::rialto::client::IMediaKeysIpcFactory> mediaKeysIpcFactory) const;
53 : };
54 :
55 : }; // namespace firebolt::rialto
56 :
57 : namespace firebolt::rialto::client
58 : {
59 : /**
60 : * @brief The definition of the MediaKeys.
61 : */
62 : class MediaKeys : public IMediaKeys
63 : {
64 : public:
65 : /**
66 : * @brief The constructor.
67 : *
68 : * @param[in] keySystem : The key system for which to create a Media Keys instance.
69 : * @param[in] mediaKeysIpcFactory : The media keys ipc factory.
70 : */
71 : explicit MediaKeys(const std::string &keySystem, const std::shared_ptr<IMediaKeysIpcFactory> &mediaKeysIpcFactory);
72 :
73 : /**
74 : * @brief Virtual destructor.
75 : */
76 : virtual ~MediaKeys();
77 :
78 : MediaKeyErrorStatus selectKeyId(int32_t keySessionId, const std::vector<uint8_t> &keyId) override;
79 :
80 : bool containsKey(int32_t keySessionId, const std::vector<uint8_t> &keyId) override;
81 :
82 : MediaKeyErrorStatus createKeySession(KeySessionType sessionType, std::weak_ptr<IMediaKeysClient> client,
83 : int32_t &keySessionId) override;
84 :
85 : MediaKeyErrorStatus generateRequest(int32_t keySessionId, InitDataType initDataType,
86 : const std::vector<uint8_t> &initData,
87 : const LimitedDurationLicense &ldlState) override;
88 :
89 : MediaKeyErrorStatus loadSession(int32_t keySessionId) override;
90 :
91 : MediaKeyErrorStatus updateSession(int32_t keySessionId, const std::vector<uint8_t> &responseData) override;
92 :
93 : MediaKeyErrorStatus setDrmHeader(int32_t keySessionId, const std::vector<uint8_t> &requestData) override;
94 :
95 : MediaKeyErrorStatus closeKeySession(int32_t keySessionId) override;
96 :
97 : MediaKeyErrorStatus removeKeySession(int32_t keySessionId) override;
98 :
99 : MediaKeyErrorStatus deleteDrmStore() override;
100 :
101 : MediaKeyErrorStatus deleteKeyStore() override;
102 :
103 : MediaKeyErrorStatus getDrmStoreHash(std::vector<unsigned char> &drmStoreHash) override;
104 :
105 : MediaKeyErrorStatus getKeyStoreHash(std::vector<unsigned char> &keyStoreHash) override;
106 :
107 : MediaKeyErrorStatus getLdlSessionsLimit(uint32_t &ldlLimit) override;
108 :
109 : MediaKeyErrorStatus getLastDrmError(int32_t keySessionId, uint32_t &errorCode) override;
110 :
111 : MediaKeyErrorStatus getDrmTime(uint64_t &drmTime) override;
112 :
113 : MediaKeyErrorStatus getCdmKeySessionId(int32_t keySessionId, std::string &cdmKeySessionId) override;
114 :
115 : MediaKeyErrorStatus releaseKeySession(int32_t keySessionId) override;
116 :
117 : MediaKeyErrorStatus getMetricSystemData(std::vector<uint8_t> &buffer) override;
118 :
119 : private:
120 : /**
121 : * @brief The media keys ipc object.
122 : */
123 : std::unique_ptr<IMediaKeys> m_mediaKeysIpc;
124 :
125 : /**
126 : * @brief The key system.
127 : */
128 : std::string m_keySystem;
129 : };
130 :
131 : }; // namespace firebolt::rialto::client
132 :
133 : #endif // FIREBOLT_RIALTO_CLIENT_MEDIA_KEYS_H_
|