LCOV - code coverage report
Current view: top level - media/client/main/source - MediaCapabilities.cpp (source / functions) Coverage Total Hit
Test: coverage.info Lines: 90.0 % 30 27
Test Date: 2026-09-29 14:28:21 Functions: 100.0 % 6 6

            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              : #include <stdexcept>
      21              : 
      22              : #include "IMediaCapabilitiesIpcFactory.h"
      23              : #include "MediaCapabilities.h"
      24              : #include "RialtoClientLogging.h"
      25              : 
      26              : namespace firebolt::rialto
      27              : {
      28            1 : std::shared_ptr<IMediaCapabilitiesFactory> IMediaCapabilitiesFactory::createFactory()
      29              : {
      30            1 :     std::shared_ptr<IMediaCapabilitiesFactory> factory;
      31              : 
      32              :     try
      33              :     {
      34            1 :         factory = std::make_shared<MediaCapabilitiesFactory>();
      35              :     }
      36            0 :     catch (const std::exception &e)
      37              :     {
      38            0 :         RIALTO_CLIENT_LOG_ERROR("Failed to create the media capabilities factory, reason: %s", e.what());
      39              :     }
      40              : 
      41            1 :     return factory;
      42              : }
      43              : 
      44            1 : std::unique_ptr<IMediaCapabilities> MediaCapabilitiesFactory::createMediaCapabilities() const
      45              : {
      46            1 :     std::unique_ptr<IMediaCapabilities> mediaCapabilities;
      47              :     try
      48              :     {
      49              :         // Client-side: Create IPC-backed capabilities stub
      50              :         // Preloaded capabilities are handled server-side only
      51              :         mediaCapabilities =
      52            2 :             std::make_unique<client::MediaCapabilities>(client::IMediaCapabilitiesIpcFactory::createFactory());
      53              :     }
      54            1 :     catch (const std::exception &e)
      55              :     {
      56            1 :         RIALTO_CLIENT_LOG_ERROR("Failed to create the media capabilities, reason: %s", e.what());
      57              :     }
      58              : 
      59            1 :     return mediaCapabilities;
      60              : }
      61              : 
      62              : }; // namespace firebolt::rialto
      63              : 
      64              : namespace firebolt::rialto::client
      65              : {
      66            5 : MediaCapabilities::MediaCapabilities(const std::shared_ptr<IMediaCapabilitiesIpcFactory> &mediaCapabilitiesIpcFactory)
      67              : {
      68            5 :     RIALTO_CLIENT_LOG_DEBUG("entry:");
      69            5 :     if (!mediaCapabilitiesIpcFactory)
      70              :     {
      71            0 :         throw std::runtime_error("Media capabilities IPC factory could not be created");
      72              :     }
      73            5 :     m_mediaCapabilitiesIpc = mediaCapabilitiesIpcFactory->createMediaCapabilitiesIpc();
      74            5 :     if (!m_mediaCapabilitiesIpc)
      75              :     {
      76            2 :         throw std::runtime_error("Media capabilities ipc could not be created");
      77              :     }
      78            7 : }
      79              : 
      80            6 : MediaCapabilities::~MediaCapabilities()
      81              : {
      82            3 :     RIALTO_CLIENT_LOG_DEBUG("entry:");
      83              : 
      84            3 :     m_mediaCapabilitiesIpc.reset();
      85            6 : }
      86              : 
      87            1 : common::AudioDecoderCapabilities MediaCapabilities::getSupportedAudioCapabilities()
      88              : {
      89            1 :     RIALTO_CLIENT_LOG_DEBUG("entry:");
      90              : 
      91            1 :     return m_mediaCapabilitiesIpc->getSupportedAudioCapabilities();
      92              : }
      93              : 
      94            1 : common::VideoDecoderCapabilities MediaCapabilities::getSupportedVideoCapabilities()
      95              : {
      96            1 :     RIALTO_CLIENT_LOG_DEBUG("entry:");
      97              : 
      98            1 :     return m_mediaCapabilitiesIpc->getSupportedVideoCapabilities();
      99              : }
     100              : 
     101              : }; // namespace firebolt::rialto::client
        

Generated by: LCOV version 2.0-1