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 2023 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 : #include "MediaKeysCapabilitiesBackend.h"
21 :
22 11 : MediaKeysCapabilitiesBackend &MediaKeysCapabilitiesBackend::instance()
23 : {
24 11 : static MediaKeysCapabilitiesBackend mkcBackend;
25 11 : return mkcBackend;
26 : }
27 :
28 1 : std::vector<std::string> MediaKeysCapabilitiesBackend::getSupportedKeySystems()
29 : {
30 1 : std::vector<std::string> result{};
31 1 : if (m_mediaKeysCapabilities)
32 : {
33 1 : result = m_mediaKeysCapabilities->getSupportedKeySystems();
34 : }
35 1 : return result;
36 : }
37 :
38 3 : OpenCDMError MediaKeysCapabilitiesBackend::supportsKeySystem(const std::string &keySystem)
39 : {
40 3 : OpenCDMError result{ERROR_FAIL};
41 3 : if (m_mediaKeysCapabilities)
42 : {
43 3 : result = ERROR_KEYSYSTEM_NOT_SUPPORTED;
44 3 : if (m_mediaKeysCapabilities->supportsKeySystem(keySystem))
45 : {
46 2 : result = ERROR_NONE;
47 : }
48 : }
49 3 : return result;
50 : }
51 :
52 4 : bool MediaKeysCapabilitiesBackend::getSupportedKeySystemVersion(const std::string &keySystem, std::string &version)
53 : {
54 4 : bool result{false};
55 4 : if (m_mediaKeysCapabilities)
56 : {
57 4 : result = m_mediaKeysCapabilities->getSupportedKeySystemVersion(keySystem, version);
58 : }
59 4 : return result;
60 : }
61 :
62 3 : bool MediaKeysCapabilitiesBackend::isServerCertificateSupported(const std::string &keySystem)
63 : {
64 3 : bool result{false};
65 3 : if (m_mediaKeysCapabilities)
66 : {
67 3 : result = m_mediaKeysCapabilities->isServerCertificateSupported(keySystem);
68 : }
69 3 : return result;
70 : }
71 :
72 1 : MediaKeysCapabilitiesBackend::MediaKeysCapabilitiesBackend()
73 : {
74 : std::shared_ptr<firebolt::rialto::IMediaKeysCapabilitiesFactory> factory =
75 1 : firebolt::rialto::IMediaKeysCapabilitiesFactory::createFactory();
76 1 : if (factory)
77 : {
78 1 : m_mediaKeysCapabilities = factory->getMediaKeysCapabilities();
79 : }
80 : }
81 :
82 1 : MediaKeysCapabilitiesBackend::~MediaKeysCapabilitiesBackend()
83 : {
84 1 : m_mediaKeysCapabilities.reset();
85 : }
|