LCOV - code coverage report
Current view: top level - media/server/ipc/source - MediaCapabilitiesModuleService.cpp (source / functions) Coverage Total Hit
Test: coverage.info Lines: 65.9 % 41 27
Test Date: 2026-09-29 14:28:21 Functions: 57.1 % 7 4

            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 2026 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 "MediaCapabilitiesModuleService.h"
      21              : #include "CapabilityConverters.h"
      22              : #include "RialtoServerLogging.h"
      23              : #include <IIpcController.h>
      24              : 
      25              : namespace firebolt::rialto::server::ipc
      26              : {
      27            0 : std::shared_ptr<IMediaCapabilitiesModuleServiceFactory> IMediaCapabilitiesModuleServiceFactory::createFactory()
      28              : {
      29            0 :     std::shared_ptr<IMediaCapabilitiesModuleServiceFactory> factory;
      30              : 
      31              :     try
      32              :     {
      33            0 :         factory = std::make_shared<MediaCapabilitiesModuleServiceFactory>();
      34              :     }
      35            0 :     catch (const std::exception &e)
      36              :     {
      37            0 :         RIALTO_SERVER_LOG_ERROR("Failed to create the media capabilities module service factory, reason: %s", e.what());
      38              :     }
      39              : 
      40            0 :     return factory;
      41              : }
      42              : 
      43              : std::shared_ptr<IMediaCapabilitiesModuleService>
      44            0 : MediaCapabilitiesModuleServiceFactory::create(service::IMediaPipelineService &mediaPipelineService) const
      45              : {
      46            0 :     std::shared_ptr<IMediaCapabilitiesModuleService> mediaCapabilitiesModule;
      47              : 
      48              :     try
      49              :     {
      50            0 :         mediaCapabilitiesModule = std::make_shared<MediaCapabilitiesModuleService>(mediaPipelineService);
      51              :     }
      52            0 :     catch (const std::exception &e)
      53              :     {
      54            0 :         RIALTO_SERVER_LOG_ERROR("Failed to create the media capabilities module service, reason: %s", e.what());
      55              :     }
      56              : 
      57            0 :     return mediaCapabilitiesModule;
      58              : }
      59              : 
      60            5 : MediaCapabilitiesModuleService::MediaCapabilitiesModuleService(service::IMediaPipelineService &mediaPipelineService)
      61            5 :     : m_mediaPipelineService{mediaPipelineService}
      62              : {
      63              : }
      64              : 
      65              : MediaCapabilitiesModuleService::~MediaCapabilitiesModuleService() {}
      66              : 
      67            1 : void MediaCapabilitiesModuleService::clientConnected(const std::shared_ptr<::firebolt::rialto::ipc::IClient> &ipcClient)
      68              : {
      69            1 :     RIALTO_SERVER_LOG_INFO("Client Connected!");
      70            1 :     ipcClient->exportService(shared_from_this());
      71              : }
      72              : 
      73            0 : void MediaCapabilitiesModuleService::clientDisconnected(const std::shared_ptr<::firebolt::rialto::ipc::IClient> &ipcClient)
      74              : {
      75            0 :     RIALTO_SERVER_LOG_INFO("Client disconnected!");
      76              : }
      77              : 
      78            2 : void MediaCapabilitiesModuleService::getSupportedAudioCapabilities(
      79              :     ::google::protobuf::RpcController *controller,
      80              :     const ::firebolt::rialto::GetSupportedAudioCapabilitiesRequest * /*request*/,
      81              :     ::firebolt::rialto::AudioCapabilities *response, ::google::protobuf::Closure *done)
      82              : {
      83            2 :     RIALTO_SERVER_LOG_DEBUG("entry:");
      84            2 :     auto ipcController = dynamic_cast<firebolt::rialto::ipc::IController *>(controller);
      85            2 :     if (!ipcController)
      86              :     {
      87            1 :         RIALTO_SERVER_LOG_ERROR("ipc library provided incompatible controller object");
      88            3 :         controller->SetFailed("ipc library provided incompatible controller object");
      89            1 :         done->Run();
      90            1 :         return;
      91              :     }
      92              : 
      93              :     const firebolt::rialto::common::AudioDecoderCapabilities kAudioCapabilities =
      94            1 :         m_mediaPipelineService.getSupportedAudioCapabilities();
      95            1 :     firebolt::rialto::ipc::common::serialiseAudioCapabilities(kAudioCapabilities, response);
      96              : 
      97            1 :     done->Run();
      98              : }
      99              : 
     100            2 : void MediaCapabilitiesModuleService::getSupportedVideoCapabilities(
     101              :     ::google::protobuf::RpcController *controller,
     102              :     const ::firebolt::rialto::GetSupportedVideoCapabilitiesRequest * /*request*/,
     103              :     ::firebolt::rialto::VideoCapabilities *response, ::google::protobuf::Closure *done)
     104              : {
     105            2 :     RIALTO_SERVER_LOG_DEBUG("entry:");
     106            2 :     auto ipcController = dynamic_cast<firebolt::rialto::ipc::IController *>(controller);
     107            2 :     if (!ipcController)
     108              :     {
     109            1 :         RIALTO_SERVER_LOG_ERROR("ipc library provided incompatible controller object");
     110            2 :         controller->SetFailed("ipc library provided incompatible controller object");
     111            1 :         done->Run();
     112            1 :         return;
     113              :     }
     114              : 
     115              :     const firebolt::rialto::common::VideoDecoderCapabilities kVideoCapabilities =
     116            1 :         m_mediaPipelineService.getSupportedVideoCapabilities();
     117            1 :     firebolt::rialto::ipc::common::serialiseVideoCapabilities(kVideoCapabilities, response);
     118              : 
     119            1 :     done->Run();
     120              : }
     121              : } // namespace firebolt::rialto::server::ipc
        

Generated by: LCOV version 2.0-1