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

            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 "MessageDispatcher.h"
      21              : 
      22            4 : MessageDispatcher::MessageDispatcherClient::MessageDispatcherClient(MessageDispatcher &dispatcher,
      23            4 :                                                                     firebolt::rialto::IMediaKeysClient *client)
      24            4 :     : m_dispatcher{dispatcher}, m_client{client}
      25              : {
      26            4 :     m_dispatcher.addClient(m_client);
      27              : }
      28              : 
      29            8 : MessageDispatcher::MessageDispatcherClient::~MessageDispatcherClient()
      30              : {
      31            4 :     m_dispatcher.removeClient(m_client);
      32            8 : }
      33              : 
      34            4 : std::unique_ptr<IMessageDispatcherClient> MessageDispatcher::createClient(firebolt::rialto::IMediaKeysClient *client)
      35              : {
      36            4 :     return std::make_unique<MessageDispatcherClient>(*this, client);
      37              : }
      38              : 
      39            4 : void MessageDispatcher::addClient(firebolt::rialto::IMediaKeysClient *client)
      40              : {
      41            4 :     std::unique_lock<std::mutex> lock{m_mutex};
      42            4 :     m_clients.emplace(client);
      43              : }
      44              : 
      45            4 : void MessageDispatcher::removeClient(firebolt::rialto::IMediaKeysClient *client)
      46              : {
      47            4 :     std::unique_lock<std::mutex> lock{m_mutex};
      48            4 :     m_clients.erase(client);
      49              : }
      50              : 
      51            3 : void MessageDispatcher::onLicenseRequest(int32_t keySessionId, const std::vector<unsigned char> &licenseRequestMessage,
      52              :                                          const std::string &url)
      53              : {
      54            3 :     std::unique_lock<std::mutex> lock{m_mutex};
      55            4 :     for (auto *client : m_clients)
      56              :     {
      57            1 :         client->onLicenseRequest(keySessionId, licenseRequestMessage, url);
      58              :     }
      59            3 : }
      60              : 
      61            3 : void MessageDispatcher::onLicenseRenewal(int32_t keySessionId, const std::vector<unsigned char> &licenseRenewalMessage)
      62              : {
      63            3 :     std::unique_lock<std::mutex> lock{m_mutex};
      64            4 :     for (auto *client : m_clients)
      65              :     {
      66            1 :         client->onLicenseRenewal(keySessionId, licenseRenewalMessage);
      67              :     }
      68            3 : }
      69              : 
      70            3 : void MessageDispatcher::onKeyStatusesChanged(int32_t keySessionId, const firebolt::rialto::KeyStatusVector &keyStatuses)
      71              : {
      72            3 :     std::unique_lock<std::mutex> lock{m_mutex};
      73            4 :     for (auto *client : m_clients)
      74              :     {
      75            1 :         client->onKeyStatusesChanged(keySessionId, keyStatuses);
      76              :     }
      77            3 : }
        

Generated by: LCOV version 2.0-1