LCOV - code coverage report
Current view: top level - source - OpenCDMSystemPrivate.cpp (source / functions) Coverage Total Hit
Test: coverage.info Lines: 100.0 % 55 55
Test Date: 2025-07-07 09:31:15 Functions: 100.0 % 13 13

            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 "OpenCDMSystemPrivate.h"
      21              : #include "ActiveSessions.h"
      22              : #include "IMediaKeys.h"
      23              : #include <MediaCommon.h>
      24              : 
      25            1 : OpenCDMSystem *createSystem(const char system[], const std::string &metadata)
      26              : {
      27            2 :     const std::string kKeySystem{system};
      28            1 :     auto messageDispatcher{std::make_shared<MessageDispatcher>()};
      29              :     auto cdmBackend{std::make_shared<CdmBackend>(kKeySystem, messageDispatcher,
      30            1 :                                                  firebolt::rialto::IMediaKeysFactory::createFactory())};
      31            2 :     return new OpenCDMSystemPrivate(kKeySystem, metadata, messageDispatcher, cdmBackend);
      32            1 : }
      33              : 
      34           25 : OpenCDMSystemPrivate::OpenCDMSystemPrivate(const std::string &system, const std::string &metadata,
      35              :                                            const std::shared_ptr<MessageDispatcher> &messageDispatcher,
      36           25 :                                            const std::shared_ptr<CdmBackend> &cdmBackend)
      37           50 :     : m_log{"OpenCDMSystemPrivate"}, m_keySystem(system), m_metadata(metadata),
      38           25 :       m_control{firebolt::rialto::IControlFactory::createFactory()->createControl()},
      39           50 :       m_messageDispatcher{messageDispatcher}, m_cdmBackend{cdmBackend}
      40              : {
      41           25 :     m_log << debug << "constructed: " << static_cast<void *>(this);
      42           25 :     if (!m_control || !m_cdmBackend)
      43              :     {
      44            7 :         return;
      45              :     }
      46           18 :     firebolt::rialto::ApplicationState initialState{firebolt::rialto::ApplicationState::UNKNOWN};
      47           18 :     m_control->registerClient(m_cdmBackend, initialState);
      48           18 :     m_cdmBackend->initialize(initialState);
      49              : }
      50              : 
      51           50 : OpenCDMSystemPrivate::~OpenCDMSystemPrivate()
      52              : {
      53           25 :     m_log << debug << "destructed: " << static_cast<void *>(this);
      54           50 : }
      55              : 
      56            1 : const std::string &OpenCDMSystemPrivate::keySystem() const
      57              : {
      58            1 :     return m_keySystem;
      59              : }
      60              : 
      61            1 : const std::string &OpenCDMSystemPrivate::metadata() const
      62              : {
      63            1 :     return m_metadata;
      64              : }
      65              : 
      66            1 : OpenCDMSession *OpenCDMSystemPrivate::createSession(const LicenseType licenseType, OpenCDMSessionCallbacks *callbacks,
      67              :                                                     void *userData, const std::string &initDataType,
      68              :                                                     const std::vector<uint8_t> &initData) const
      69              : {
      70            2 :     return ActiveSessions::instance().create(m_cdmBackend, m_messageDispatcher, licenseType, callbacks, userData,
      71            2 :                                              initDataType, initData);
      72              : }
      73              : 
      74            3 : bool OpenCDMSystemPrivate::getDrmTime(uint64_t &drmTime) const
      75              : {
      76            3 :     if (!m_cdmBackend)
      77              :     {
      78            1 :         return false;
      79              :     }
      80            2 :     return m_cdmBackend->getDrmTime(drmTime);
      81              : }
      82              : 
      83            3 : bool OpenCDMSystemPrivate::getLdlSessionsLimit(uint32_t &ldlLimit) const
      84              : {
      85            3 :     if (!m_cdmBackend)
      86              :     {
      87            1 :         return false;
      88              :     }
      89            2 :     return m_cdmBackend->getLdlSessionsLimit(ldlLimit);
      90              : }
      91              : 
      92            3 : bool OpenCDMSystemPrivate::getKeyStoreHash(std::vector<unsigned char> &keyStoreHash) const
      93              : {
      94            3 :     if (!m_cdmBackend)
      95              :     {
      96            1 :         return false;
      97              :     }
      98            2 :     return m_cdmBackend->getKeyStoreHash(keyStoreHash);
      99              : }
     100              : 
     101            3 : bool OpenCDMSystemPrivate::getDrmStoreHash(std::vector<unsigned char> &drmStoreHash) const
     102              : {
     103            3 :     if (!m_cdmBackend)
     104              :     {
     105            1 :         return false;
     106              :     }
     107            2 :     return m_cdmBackend->getDrmStoreHash(drmStoreHash);
     108              : }
     109              : 
     110            3 : bool OpenCDMSystemPrivate::deleteKeyStore() const
     111              : {
     112            3 :     if (!m_cdmBackend)
     113              :     {
     114            1 :         return false;
     115              :     }
     116            2 :     return m_cdmBackend->deleteKeyStore();
     117              : }
     118              : 
     119            3 : bool OpenCDMSystemPrivate::deleteDrmStore() const
     120              : {
     121            3 :     if (!m_cdmBackend)
     122              :     {
     123            1 :         return false;
     124              :     }
     125            2 :     return m_cdmBackend->deleteDrmStore();
     126              : }
     127              : 
     128            3 : bool OpenCDMSystemPrivate::getMetricSystemData(std::vector<uint8_t> &buffer) const
     129              : {
     130            3 :     if (!m_cdmBackend)
     131              :     {
     132            1 :         return false;
     133              :     }
     134              : 
     135            2 :     return m_cdmBackend->getMetricSystemData(buffer);
     136              : }
        

Generated by: LCOV version 2.0-1