LCOV - code coverage report
Current view: top level - media/server/ipc/source - MediaPipelineModuleService.cpp (source / functions) Coverage Total Hit
Test: coverage.info Lines: 86.8 % 484 420
Test Date: 2026-09-11 17:36:12 Functions: 96.4 % 56 54

            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 "MediaPipelineModuleService.h"
      21              : #include "IMediaPipelineService.h"
      22              : #include "IPrivateMetricsModuleService.h"
      23              : #include "MediaPipelineClient.h"
      24              : #include "RialtoCommonModule.h"
      25              : #include "RialtoServerLogging.h"
      26              : #include <IIpcController.h>
      27              : #include <algorithm>
      28              : #include <cstdint>
      29              : #include <unordered_map>
      30              : #include <utility>
      31              : 
      32              : namespace
      33              : {
      34           28 : int generateSessionId()
      35              : {
      36              :     static int sessionId{0};
      37           28 :     return sessionId++;
      38              : }
      39              : 
      40            2 : firebolt::rialto::MediaType convertMediaType(const firebolt::rialto::LoadRequest_MediaType &mediaType)
      41              : {
      42            2 :     switch (mediaType)
      43              :     {
      44            0 :     case firebolt::rialto::LoadRequest_MediaType::LoadRequest_MediaType_UNKNOWN:
      45              :     {
      46            0 :         return firebolt::rialto::MediaType::UNKNOWN;
      47              :     }
      48            2 :     case firebolt::rialto::LoadRequest_MediaType::LoadRequest_MediaType_MSE:
      49              :     {
      50            2 :         return firebolt::rialto::MediaType::MSE;
      51              :     }
      52              :     }
      53            0 :     return firebolt::rialto::MediaType::UNKNOWN;
      54              : }
      55              : 
      56            2 : firebolt::rialto::EaseType convertEaseType(const firebolt::rialto::SetVolumeRequest_EaseType &easeType)
      57              : {
      58            2 :     switch (easeType)
      59              :     {
      60            2 :     case firebolt::rialto::SetVolumeRequest_EaseType::SetVolumeRequest_EaseType_EASE_LINEAR:
      61              :     {
      62            2 :         return firebolt::rialto::EaseType::EASE_LINEAR;
      63              :     }
      64            0 :     case firebolt::rialto::SetVolumeRequest_EaseType::SetVolumeRequest_EaseType_EASE_IN_CUBIC:
      65              :     {
      66            0 :         return firebolt::rialto::EaseType::EASE_IN_CUBIC;
      67              :     }
      68            0 :     case firebolt::rialto::SetVolumeRequest_EaseType::SetVolumeRequest_EaseType_EASE_OUT_CUBIC:
      69              :     {
      70            0 :         return firebolt::rialto::EaseType::EASE_OUT_CUBIC;
      71              :     }
      72              :     }
      73            0 :     return firebolt::rialto::EaseType::EASE_LINEAR;
      74              : }
      75              : 
      76              : firebolt::rialto::MediaSourceStatus
      77            2 : convertMediaSourceStatus(const firebolt::rialto::HaveDataRequest_MediaSourceStatus &status)
      78              : {
      79            2 :     switch (status)
      80              :     {
      81            0 :     case firebolt::rialto::HaveDataRequest_MediaSourceStatus_UNKNOWN:
      82              :     {
      83            0 :         return firebolt::rialto::MediaSourceStatus::ERROR;
      84              :     }
      85            0 :     case firebolt::rialto::HaveDataRequest_MediaSourceStatus_OK:
      86              :     {
      87            0 :         return firebolt::rialto::MediaSourceStatus::OK;
      88              :     }
      89            0 :     case firebolt::rialto::HaveDataRequest_MediaSourceStatus_EOS:
      90              :     {
      91            0 :         return firebolt::rialto::MediaSourceStatus::EOS;
      92              :     }
      93            0 :     case firebolt::rialto::HaveDataRequest_MediaSourceStatus_ERROR:
      94              :     {
      95            0 :         return firebolt::rialto::MediaSourceStatus::ERROR;
      96              :     }
      97            2 :     case firebolt::rialto::HaveDataRequest_MediaSourceStatus_CODEC_CHANGED:
      98              :     {
      99            2 :         return firebolt::rialto::MediaSourceStatus::CODEC_CHANGED;
     100              :     }
     101            0 :     case firebolt::rialto::HaveDataRequest_MediaSourceStatus_NO_AVAILABLE_SAMPLES:
     102              :     {
     103            0 :         return firebolt::rialto::MediaSourceStatus::NO_AVAILABLE_SAMPLES;
     104              :     }
     105            0 :     case firebolt::rialto::HaveDataRequest_MediaSourceStatus_NO_SPACE_FOR_SAMPLES:
     106              :     {
     107            0 :         return firebolt::rialto::MediaSourceStatus::NO_SPACE_FOR_SAMPLES;
     108              :     }
     109              :     }
     110            0 :     return firebolt::rialto::MediaSourceStatus::ERROR;
     111              : }
     112              : 
     113            9 : firebolt::rialto::SourceConfigType convertConfigType(const firebolt::rialto::AttachSourceRequest_ConfigType &configType)
     114              : {
     115            9 :     switch (configType)
     116              :     {
     117            1 :     case firebolt::rialto::AttachSourceRequest_ConfigType_CONFIG_TYPE_UNKNOWN:
     118              :     {
     119            1 :         return firebolt::rialto::SourceConfigType::UNKNOWN;
     120              :     }
     121            5 :     case firebolt::rialto::AttachSourceRequest_ConfigType_CONFIG_TYPE_AUDIO:
     122              :     {
     123            5 :         return firebolt::rialto::SourceConfigType::AUDIO;
     124              :     }
     125            1 :     case firebolt::rialto::AttachSourceRequest_ConfigType_CONFIG_TYPE_VIDEO:
     126              :     {
     127            1 :         return firebolt::rialto::SourceConfigType::VIDEO;
     128              :     }
     129            1 :     case firebolt::rialto::AttachSourceRequest_ConfigType_CONFIG_TYPE_VIDEO_DOLBY_VISION:
     130              :     {
     131            1 :         return firebolt::rialto::SourceConfigType::VIDEO_DOLBY_VISION;
     132              :     }
     133            1 :     case firebolt::rialto::AttachSourceRequest_ConfigType_CONFIG_TYPE_SUBTITLE:
     134              :     {
     135            1 :         return firebolt::rialto::SourceConfigType::SUBTITLE;
     136              :     }
     137              :     }
     138            0 :     return firebolt::rialto::SourceConfigType::UNKNOWN;
     139              : }
     140              : 
     141              : firebolt::rialto::SegmentAlignment
     142            7 : convertSegmentAlignment(const firebolt::rialto::AttachSourceRequest_SegmentAlignment &alignment)
     143              : {
     144            7 :     switch (alignment)
     145              :     {
     146            7 :     case firebolt::rialto::AttachSourceRequest_SegmentAlignment_ALIGNMENT_UNDEFINED:
     147              :     {
     148            7 :         return firebolt::rialto::SegmentAlignment::UNDEFINED;
     149              :     }
     150            0 :     case firebolt::rialto::AttachSourceRequest_SegmentAlignment_ALIGNMENT_NAL:
     151              :     {
     152            0 :         return firebolt::rialto::SegmentAlignment::NAL;
     153              :     }
     154            0 :     case firebolt::rialto::AttachSourceRequest_SegmentAlignment_ALIGNMENT_AU:
     155              :     {
     156            0 :         return firebolt::rialto::SegmentAlignment::AU;
     157              :     }
     158              :     }
     159              : 
     160            0 :     return firebolt::rialto::SegmentAlignment::UNDEFINED;
     161              : }
     162              : 
     163            7 : firebolt::rialto::StreamFormat convertStreamFormat(const firebolt::rialto::AttachSourceRequest_StreamFormat &streamFormat)
     164              : {
     165            7 :     switch (streamFormat)
     166              :     {
     167            1 :     case firebolt::rialto::AttachSourceRequest_StreamFormat_STREAM_FORMAT_RAW:
     168              :     {
     169            1 :         return firebolt::rialto::StreamFormat::RAW;
     170              :     }
     171            0 :     case firebolt::rialto::AttachSourceRequest_StreamFormat_STREAM_FORMAT_AVC:
     172              :     {
     173            0 :         return firebolt::rialto::StreamFormat::AVC;
     174              :     }
     175            0 :     case firebolt::rialto::AttachSourceRequest_StreamFormat_STREAM_FORMAT_BYTE_STREAM:
     176              :     {
     177            0 :         return firebolt::rialto::StreamFormat::BYTE_STREAM;
     178              :     }
     179            0 :     case firebolt::rialto::AttachSourceRequest_StreamFormat_STREAM_FORMAT_HVC1:
     180              :     {
     181            0 :         return firebolt::rialto::StreamFormat::HVC1;
     182              :     }
     183            0 :     case firebolt::rialto::AttachSourceRequest_StreamFormat_STREAM_FORMAT_HEV1:
     184              :     {
     185            0 :         return firebolt::rialto::StreamFormat::HEV1;
     186              :     }
     187            6 :     default:
     188            6 :         return firebolt::rialto::StreamFormat::UNDEFINED;
     189              :     }
     190              : }
     191              : 
     192            1 : firebolt::rialto::CodecDataType convertCodecDataType(const firebolt::rialto::AttachSourceRequest_CodecData_Type &type)
     193              : {
     194            1 :     if (firebolt::rialto::AttachSourceRequest_CodecData_Type_STRING == type)
     195              :     {
     196            0 :         return firebolt::rialto::CodecDataType::STRING;
     197              :     }
     198            1 :     return firebolt::rialto::CodecDataType::BUFFER;
     199              : }
     200              : 
     201            1 : firebolt::rialto::Format convertFormat(const firebolt::rialto::AttachSourceRequest_AudioConfig_Format &format)
     202              : {
     203              :     static const std::unordered_map<firebolt::rialto::AttachSourceRequest_AudioConfig_Format, firebolt::rialto::Format>
     204              :         kFormatConversionMap{
     205              :             {firebolt::rialto::AttachSourceRequest_AudioConfig_Format_S8, firebolt::rialto::Format::S8},
     206              :             {firebolt::rialto::AttachSourceRequest_AudioConfig_Format_U8, firebolt::rialto::Format::U8},
     207              :             {firebolt::rialto::AttachSourceRequest_AudioConfig_Format_S16LE, firebolt::rialto::Format::S16LE},
     208              :             {firebolt::rialto::AttachSourceRequest_AudioConfig_Format_S16BE, firebolt::rialto::Format::S16BE},
     209              :             {firebolt::rialto::AttachSourceRequest_AudioConfig_Format_U16LE, firebolt::rialto::Format::U16LE},
     210              :             {firebolt::rialto::AttachSourceRequest_AudioConfig_Format_U16BE, firebolt::rialto::Format::U16BE},
     211              :             {firebolt::rialto::AttachSourceRequest_AudioConfig_Format_S24_32LE, firebolt::rialto::Format::S24_32LE},
     212              :             {firebolt::rialto::AttachSourceRequest_AudioConfig_Format_S24_32BE, firebolt::rialto::Format::S24_32BE},
     213              :             {firebolt::rialto::AttachSourceRequest_AudioConfig_Format_U24_32LE, firebolt::rialto::Format::U24_32LE},
     214              :             {firebolt::rialto::AttachSourceRequest_AudioConfig_Format_U24_32BE, firebolt::rialto::Format::U24_32BE},
     215              :             {firebolt::rialto::AttachSourceRequest_AudioConfig_Format_S32LE, firebolt::rialto::Format::S32LE},
     216              :             {firebolt::rialto::AttachSourceRequest_AudioConfig_Format_S32BE, firebolt::rialto::Format::S32BE},
     217              :             {firebolt::rialto::AttachSourceRequest_AudioConfig_Format_U32LE, firebolt::rialto::Format::U32LE},
     218              :             {firebolt::rialto::AttachSourceRequest_AudioConfig_Format_U32BE, firebolt::rialto::Format::U32BE},
     219              :             {firebolt::rialto::AttachSourceRequest_AudioConfig_Format_S24LE, firebolt::rialto::Format::S24LE},
     220              :             {firebolt::rialto::AttachSourceRequest_AudioConfig_Format_S24BE, firebolt::rialto::Format::S24BE},
     221              :             {firebolt::rialto::AttachSourceRequest_AudioConfig_Format_U24LE, firebolt::rialto::Format::U24LE},
     222              :             {firebolt::rialto::AttachSourceRequest_AudioConfig_Format_U24BE, firebolt::rialto::Format::U24BE},
     223              :             {firebolt::rialto::AttachSourceRequest_AudioConfig_Format_S20LE, firebolt::rialto::Format::S20LE},
     224              :             {firebolt::rialto::AttachSourceRequest_AudioConfig_Format_S20BE, firebolt::rialto::Format::S20BE},
     225              :             {firebolt::rialto::AttachSourceRequest_AudioConfig_Format_U20LE, firebolt::rialto::Format::U20LE},
     226              :             {firebolt::rialto::AttachSourceRequest_AudioConfig_Format_U20BE, firebolt::rialto::Format::U20BE},
     227              :             {firebolt::rialto::AttachSourceRequest_AudioConfig_Format_S18LE, firebolt::rialto::Format::S18LE},
     228              :             {firebolt::rialto::AttachSourceRequest_AudioConfig_Format_S18BE, firebolt::rialto::Format::S18BE},
     229              :             {firebolt::rialto::AttachSourceRequest_AudioConfig_Format_U18LE, firebolt::rialto::Format::U18LE},
     230              :             {firebolt::rialto::AttachSourceRequest_AudioConfig_Format_U18BE, firebolt::rialto::Format::U18BE},
     231              :             {firebolt::rialto::AttachSourceRequest_AudioConfig_Format_F32LE, firebolt::rialto::Format::F32LE},
     232              :             {firebolt::rialto::AttachSourceRequest_AudioConfig_Format_F32BE, firebolt::rialto::Format::F32BE},
     233              :             {firebolt::rialto::AttachSourceRequest_AudioConfig_Format_F64LE, firebolt::rialto::Format::F64LE},
     234            3 :             {firebolt::rialto::AttachSourceRequest_AudioConfig_Format_F64BE, firebolt::rialto::Format::F64BE}};
     235            1 :     const auto kIt = kFormatConversionMap.find(format);
     236            1 :     if (kFormatConversionMap.end() != kIt)
     237              :     {
     238            1 :         return kIt->second;
     239              :     }
     240            0 :     return firebolt::rialto::Format::S8;
     241              : }
     242              : 
     243            1 : firebolt::rialto::Layout convertLayout(const firebolt::rialto::AttachSourceRequest_AudioConfig_Layout &layout)
     244              : {
     245              :     static const std::unordered_map<firebolt::rialto::AttachSourceRequest_AudioConfig_Layout, firebolt::rialto::Layout>
     246              :         kLayoutConversionMap{{firebolt::rialto::AttachSourceRequest_AudioConfig_Layout_INTERLEAVED,
     247              :                               firebolt::rialto::Layout::INTERLEAVED},
     248              :                              {firebolt::rialto::AttachSourceRequest_AudioConfig_Layout_NON_INTERLEAVED,
     249            3 :                               firebolt::rialto::Layout::NON_INTERLEAVED}};
     250            1 :     const auto kIt = kLayoutConversionMap.find(layout);
     251            1 :     if (kLayoutConversionMap.end() != kIt)
     252              :     {
     253            1 :         return kIt->second;
     254              :     }
     255            0 :     return firebolt::rialto::Layout::INTERLEAVED;
     256              : }
     257              : } // namespace
     258              : 
     259              : namespace firebolt::rialto::server::ipc
     260              : {
     261            1 : std::shared_ptr<IMediaPipelineModuleServiceFactory> IMediaPipelineModuleServiceFactory::createFactory()
     262              : {
     263            1 :     std::shared_ptr<IMediaPipelineModuleServiceFactory> factory;
     264              : 
     265              :     try
     266              :     {
     267            1 :         factory = std::make_shared<MediaPipelineModuleServiceFactory>();
     268              :     }
     269            0 :     catch (const std::exception &e)
     270              :     {
     271            0 :         RIALTO_SERVER_LOG_ERROR("Failed to create the media player module service factory, reason: %s", e.what());
     272              :     }
     273              : 
     274            1 :     return factory;
     275              : }
     276              : 
     277              : std::shared_ptr<IMediaPipelineModuleService>
     278            1 : MediaPipelineModuleServiceFactory::create(service::IMediaPipelineService &mediaPipelineService) const
     279              : {
     280            1 :     std::shared_ptr<IMediaPipelineModuleService> mediaPipelineModule;
     281              : 
     282              :     try
     283              :     {
     284            1 :         mediaPipelineModule = std::make_shared<MediaPipelineModuleService>(mediaPipelineService);
     285              :     }
     286            0 :     catch (const std::exception &e)
     287              :     {
     288            0 :         RIALTO_SERVER_LOG_ERROR("Failed to create the media player module service, reason: %s", e.what());
     289              :     }
     290              : 
     291            1 :     return mediaPipelineModule;
     292              : }
     293              : 
     294           98 : MediaPipelineModuleService::MediaPipelineModuleService(service::IMediaPipelineService &mediaPipelineService)
     295           98 :     : m_mediaPipelineService{mediaPipelineService}
     296              : {
     297              : }
     298              : 
     299              : MediaPipelineModuleService::~MediaPipelineModuleService() {}
     300              : 
     301            2 : void MediaPipelineModuleService::clientConnected(const std::shared_ptr<::firebolt::rialto::ipc::IClient> &ipcClient)
     302              : {
     303            2 :     RIALTO_SERVER_LOG_INFO("Client Connected!");
     304              :     {
     305            2 :         m_clientSessions.emplace(ipcClient, std::set<int>());
     306              :     }
     307            2 :     ipcClient->exportService(shared_from_this());
     308              : }
     309              : 
     310            1 : void MediaPipelineModuleService::clientDisconnected(const std::shared_ptr<::firebolt::rialto::ipc::IClient> &ipcClient)
     311              : {
     312            1 :     RIALTO_SERVER_LOG_INFO("Client disconnected!");
     313            1 :     std::set<int> sessionIds;
     314              :     {
     315            1 :         auto sessionIter = m_clientSessions.find(ipcClient);
     316            1 :         if (sessionIter == m_clientSessions.end())
     317              :         {
     318            0 :             RIALTO_SERVER_LOG_ERROR("unknown client disconnected");
     319            0 :             return;
     320              :         }
     321            1 :         sessionIds = sessionIter->second; // copy to avoid deadlock
     322            1 :         m_clientSessions.erase(sessionIter);
     323              :     }
     324            2 :     for (const auto &sessionId : sessionIds)
     325              :     {
     326            1 :         m_mediaPipelineService.destroySession(sessionId);
     327              :     }
     328              : }
     329              : 
     330           28 : void MediaPipelineModuleService::createSession(::google::protobuf::RpcController *controller,
     331              :                                                const ::firebolt::rialto::CreateSessionRequest *request,
     332              :                                                ::firebolt::rialto::CreateSessionResponse *response,
     333              :                                                ::google::protobuf::Closure *done)
     334              : {
     335           28 :     RIALTO_SERVER_LOG_DEBUG("entry:");
     336           28 :     auto ipcController = dynamic_cast<firebolt::rialto::ipc::IController *>(controller);
     337           28 :     if (!ipcController)
     338              :     {
     339            0 :         RIALTO_SERVER_LOG_ERROR("ipc library provided incompatible controller object");
     340            0 :         controller->SetFailed("ipc library provided incompatible controller object");
     341            0 :         done->Run();
     342            0 :         return;
     343              :     }
     344              : 
     345           28 :     int sessionId = generateSessionId();
     346              :     bool sessionCreated =
     347           56 :         m_mediaPipelineService.createSession(sessionId,
     348           56 :                                              std::make_shared<MediaPipelineClient>(sessionId, ipcController->getClient()),
     349              :                                              request->max_width(), request->max_height());
     350           28 :     if (sessionCreated)
     351              :     {
     352              :         // Assume that IPC library works well and client is present
     353           27 :         m_clientSessions[ipcController->getClient()].insert(sessionId);
     354           27 :         response->set_session_id(sessionId);
     355              :     }
     356              :     else
     357              :     {
     358            1 :         RIALTO_SERVER_LOG_ERROR("Create session failed");
     359            3 :         controller->SetFailed("Operation failed");
     360              :     }
     361           28 :     done->Run();
     362              : }
     363              : 
     364            2 : void MediaPipelineModuleService::destroySession(::google::protobuf::RpcController *controller,
     365              :                                                 const ::firebolt::rialto::DestroySessionRequest *request,
     366              :                                                 ::firebolt::rialto::DestroySessionResponse *response,
     367              :                                                 ::google::protobuf::Closure *done)
     368              : {
     369            2 :     RIALTO_SERVER_LOG_DEBUG("entry:");
     370            2 :     auto ipcController = dynamic_cast<firebolt::rialto::ipc::IController *>(controller);
     371            2 :     if (!ipcController)
     372              :     {
     373            0 :         RIALTO_SERVER_LOG_ERROR("ipc library provided incompatible controller object");
     374            0 :         controller->SetFailed("ipc library provided incompatible controller object");
     375            0 :         done->Run();
     376            1 :         return;
     377              :     }
     378              : 
     379            2 :     if (!m_mediaPipelineService.destroySession(request->session_id()))
     380              :     {
     381            1 :         RIALTO_SERVER_LOG_ERROR("Destroy session failed");
     382            2 :         controller->SetFailed("Operation failed");
     383            1 :         done->Run();
     384            1 :         return;
     385              :     }
     386            1 :     auto sessionIter = m_clientSessions.find(ipcController->getClient());
     387            1 :     if (sessionIter != m_clientSessions.end())
     388              :     {
     389            0 :         sessionIter->second.erase(request->session_id());
     390              :     }
     391            1 :     done->Run();
     392              : }
     393              : 
     394            2 : void MediaPipelineModuleService::load(::google::protobuf::RpcController *controller,
     395              :                                       const ::firebolt::rialto::LoadRequest *request,
     396              :                                       ::firebolt::rialto::LoadResponse *response, ::google::protobuf::Closure *done)
     397              : {
     398            2 :     RIALTO_SERVER_LOG_DEBUG("entry:");
     399            2 :     if (!m_mediaPipelineService.load(request->session_id(), convertMediaType(request->type()), request->mime_type(),
     400            2 :                                      request->url(), request->is_live()))
     401              :     {
     402            1 :         RIALTO_SERVER_LOG_ERROR("Load failed");
     403            3 :         controller->SetFailed("Operation failed");
     404              :     }
     405            2 :     done->Run();
     406              : }
     407              : 
     408            2 : void MediaPipelineModuleService::setVideoWindow(::google::protobuf::RpcController *controller,
     409              :                                                 const ::firebolt::rialto::SetVideoWindowRequest *request,
     410              :                                                 ::firebolt::rialto::SetVideoWindowResponse *response,
     411              :                                                 ::google::protobuf::Closure *done)
     412              : {
     413            2 :     RIALTO_SERVER_LOG_DEBUG("entry:");
     414            2 :     if (!m_mediaPipelineService.setVideoWindow(request->session_id(), request->x(), request->y(), request->width(),
     415              :                                                request->height()))
     416              :     {
     417            1 :         RIALTO_SERVER_LOG_ERROR("Set Video Window failed");
     418            3 :         controller->SetFailed("Operation failed");
     419              :     }
     420            2 :     done->Run();
     421              : }
     422              : 
     423            9 : void MediaPipelineModuleService::attachSource(::google::protobuf::RpcController *controller,
     424              :                                               const ::firebolt::rialto::AttachSourceRequest *request,
     425              :                                               ::firebolt::rialto::AttachSourceResponse *response,
     426              :                                               ::google::protobuf::Closure *done)
     427              : {
     428            9 :     RIALTO_SERVER_LOG_DEBUG("mime_type: %s", request->mime_type().c_str());
     429              : 
     430            9 :     std::shared_ptr<CodecData> codecData{};
     431            9 :     if (request->has_codec_data())
     432              :     {
     433            1 :         const auto &kCodecDataProto = request->codec_data();
     434            1 :         codecData = std::make_shared<CodecData>();
     435            1 :         codecData->data = std::vector<std::uint8_t>(kCodecDataProto.data().begin(), kCodecDataProto.data().end());
     436            1 :         codecData->type = convertCodecDataType(kCodecDataProto.type());
     437              :     }
     438            9 :     std::unique_ptr<IMediaPipeline::MediaSource> mediaSource;
     439            9 :     firebolt::rialto::SourceConfigType configType = convertConfigType(request->config_type());
     440            9 :     bool hasDrm = request->has_drm();
     441              : 
     442            9 :     if (configType == firebolt::rialto::SourceConfigType::AUDIO)
     443              :     {
     444            5 :         const auto &kConfig = request->audio_config();
     445            5 :         uint32_t numberofchannels = kConfig.number_of_channels();
     446            5 :         uint32_t sampleRate = kConfig.sample_rate();
     447              : 
     448            5 :         std::vector<uint8_t> codecSpecificConfig;
     449            5 :         if (kConfig.has_codec_specific_config())
     450              :         {
     451            1 :             auto codecSpecificConfigStr = kConfig.codec_specific_config();
     452            1 :             codecSpecificConfig.assign(codecSpecificConfigStr.begin(), codecSpecificConfigStr.end());
     453              :         }
     454            5 :         std::optional<firebolt::rialto::Format> format{std::nullopt};
     455            5 :         if (kConfig.has_format())
     456              :         {
     457            1 :             format = convertFormat(kConfig.format());
     458              :         }
     459            5 :         std::optional<firebolt::rialto::Layout> layout{std::nullopt};
     460            5 :         if (kConfig.has_layout())
     461              :         {
     462            1 :             layout = convertLayout(kConfig.layout());
     463              :         }
     464            5 :         std::optional<uint64_t> channelMask{std::nullopt};
     465            5 :         if (kConfig.has_channel_mask())
     466              :         {
     467            1 :             channelMask = kConfig.channel_mask();
     468              :         }
     469            5 :         std::vector<std::vector<uint8_t>> streamHeaders;
     470            6 :         for (int i = 0; i < kConfig.stream_header_size(); ++i)
     471              :         {
     472            1 :             auto streamHeaderStr = kConfig.stream_header(i);
     473            2 :             streamHeaders.push_back(std::vector<uint8_t>{streamHeaderStr.begin(), streamHeaderStr.end()});
     474            1 :         }
     475            5 :         std::optional<bool> framed;
     476            5 :         if (kConfig.has_framed())
     477              :         {
     478            1 :             framed = kConfig.framed();
     479              :         }
     480            5 :         AudioConfig audioConfig{numberofchannels, sampleRate,  std::move(codecSpecificConfig), format,
     481            5 :                                 layout,           channelMask, std::move(streamHeaders),       framed};
     482              : 
     483              :         mediaSource =
     484           10 :             std::make_unique<IMediaPipeline::MediaSourceAudio>(request->mime_type(), hasDrm, audioConfig,
     485            5 :                                                                convertSegmentAlignment(request->segment_alignment()),
     486           10 :                                                                convertStreamFormat(request->stream_format()), codecData);
     487            5 :     }
     488            4 :     else if (configType == firebolt::rialto::SourceConfigType::VIDEO)
     489              :     {
     490              :         mediaSource =
     491            2 :             std::make_unique<IMediaPipeline::MediaSourceVideo>(request->mime_type().c_str(), hasDrm, request->width(),
     492            1 :                                                                request->height(),
     493            1 :                                                                convertSegmentAlignment(request->segment_alignment()),
     494            3 :                                                                convertStreamFormat(request->stream_format()), codecData);
     495              :     }
     496            3 :     else if (configType == firebolt::rialto::SourceConfigType::VIDEO_DOLBY_VISION)
     497              :     {
     498              :         mediaSource =
     499            2 :             std::make_unique<IMediaPipeline::MediaSourceVideoDolbyVision>(request->mime_type().c_str(),
     500            1 :                                                                           request->dolby_vision_profile(), hasDrm,
     501            1 :                                                                           request->width(), request->height(),
     502            1 :                                                                           convertSegmentAlignment(
     503            1 :                                                                               request->segment_alignment()),
     504            2 :                                                                           convertStreamFormat(request->stream_format()),
     505            1 :                                                                           codecData);
     506              :     }
     507            2 :     else if (configType == firebolt::rialto::SourceConfigType::SUBTITLE)
     508              :     {
     509            2 :         mediaSource = std::make_unique<IMediaPipeline::MediaSourceSubtitle>(request->mime_type().c_str(),
     510            2 :                                                                             request->text_track_identifier());
     511              :     }
     512              :     else
     513              :     {
     514            1 :         RIALTO_SERVER_LOG_ERROR("Unknown source type");
     515            2 :         controller->SetFailed("Operation failed");
     516            1 :         done->Run();
     517            1 :         return;
     518              :     }
     519              : 
     520            8 :     if (!request->has_switch_source() || !request->switch_source())
     521              :     {
     522            6 :         RIALTO_SERVER_LOG_DEBUG("Attaching source");
     523            6 :         if (!m_mediaPipelineService.attachSource(request->session_id(), mediaSource))
     524              :         {
     525            1 :             RIALTO_SERVER_LOG_ERROR("Attach source failed");
     526            3 :             controller->SetFailed("Operation failed");
     527              :         }
     528              :     }
     529              :     else
     530              :     {
     531            2 :         RIALTO_SERVER_LOG_DEBUG("Switching source");
     532            2 :         if (!m_mediaPipelineService.switchSource(request->session_id(), mediaSource))
     533              :         {
     534            1 :             RIALTO_SERVER_LOG_ERROR("Switch source failed");
     535            3 :             controller->SetFailed("Operation failed");
     536              :         }
     537              :     }
     538            8 :     response->set_source_id(mediaSource->getId());
     539            8 :     done->Run();
     540           10 : }
     541              : 
     542            0 : void MediaPipelineModuleService::removeSource(::google::protobuf::RpcController *controller,
     543              :                                               const ::firebolt::rialto::RemoveSourceRequest *request,
     544              :                                               ::firebolt::rialto::RemoveSourceResponse *response,
     545              :                                               ::google::protobuf::Closure *done)
     546              : {
     547            0 :     RIALTO_SERVER_LOG_DEBUG("entry:");
     548            0 :     if (!m_mediaPipelineService.removeSource(request->session_id(), request->source_id()))
     549              :     {
     550            0 :         RIALTO_SERVER_LOG_ERROR("Remove source failed");
     551            0 :         controller->SetFailed("Operation failed");
     552              :     }
     553            0 :     done->Run();
     554              : }
     555              : 
     556            2 : void MediaPipelineModuleService::allSourcesAttached(::google::protobuf::RpcController *controller,
     557              :                                                     const ::firebolt::rialto::AllSourcesAttachedRequest *request,
     558              :                                                     ::firebolt::rialto::AllSourcesAttachedResponse *response,
     559              :                                                     ::google::protobuf::Closure *done)
     560              : {
     561            2 :     RIALTO_SERVER_LOG_DEBUG("entry:");
     562            2 :     if (!m_mediaPipelineService.allSourcesAttached(request->session_id()))
     563              :     {
     564            1 :         RIALTO_SERVER_LOG_ERROR("All sources attached failed");
     565            3 :         controller->SetFailed("Operation failed");
     566              :     }
     567            2 :     done->Run();
     568              : }
     569              : 
     570            2 : void MediaPipelineModuleService::play(::google::protobuf::RpcController *controller,
     571              :                                       const ::firebolt::rialto::PlayRequest *request,
     572              :                                       ::firebolt::rialto::PlayResponse *response, ::google::protobuf::Closure *done)
     573              : {
     574            2 :     RIALTO_SERVER_LOG_DEBUG("entry:");
     575            2 :     bool async{false};
     576            2 :     if (!m_mediaPipelineService.play(request->session_id(), async))
     577              :     {
     578            1 :         RIALTO_SERVER_LOG_ERROR("Play failed");
     579            3 :         controller->SetFailed("Operation failed");
     580              :     }
     581            2 :     response->set_async(async);
     582            2 :     done->Run();
     583              : }
     584              : 
     585            2 : void MediaPipelineModuleService::pause(::google::protobuf::RpcController *controller,
     586              :                                        const ::firebolt::rialto::PauseRequest *request,
     587              :                                        ::firebolt::rialto::PauseResponse *response, ::google::protobuf::Closure *done)
     588              : {
     589            2 :     RIALTO_SERVER_LOG_DEBUG("entry:");
     590            2 :     if (!m_mediaPipelineService.pause(request->session_id()))
     591              :     {
     592            1 :         RIALTO_SERVER_LOG_ERROR("pause failed");
     593            3 :         controller->SetFailed("Operation failed");
     594              :     }
     595            2 :     done->Run();
     596              : }
     597              : 
     598            2 : void MediaPipelineModuleService::stop(::google::protobuf::RpcController *controller,
     599              :                                       const ::firebolt::rialto::StopRequest *request,
     600              :                                       ::firebolt::rialto::StopResponse *response, ::google::protobuf::Closure *done)
     601              : {
     602            2 :     RIALTO_SERVER_LOG_DEBUG("entry:");
     603            2 :     if (!m_mediaPipelineService.stop(request->session_id()))
     604              :     {
     605            1 :         RIALTO_SERVER_LOG_ERROR("Stop failed");
     606            3 :         controller->SetFailed("Operation failed");
     607              :     }
     608            2 :     done->Run();
     609              : }
     610              : 
     611            2 : void MediaPipelineModuleService::setPosition(::google::protobuf::RpcController *controller,
     612              :                                              const ::firebolt::rialto::SetPositionRequest *request,
     613              :                                              ::firebolt::rialto::SetPositionResponse *response,
     614              :                                              ::google::protobuf::Closure *done)
     615              : {
     616            2 :     RIALTO_SERVER_LOG_DEBUG("entry:");
     617            2 :     if (!m_mediaPipelineService.setPosition(request->session_id(), request->position()))
     618              :     {
     619            1 :         RIALTO_SERVER_LOG_ERROR("Set Position failed");
     620            3 :         controller->SetFailed("Operation failed");
     621              :     }
     622            2 :     done->Run();
     623              : }
     624              : 
     625            2 : void MediaPipelineModuleService::haveData(::google::protobuf::RpcController *controller,
     626              :                                           const ::firebolt::rialto::HaveDataRequest *request,
     627              :                                           ::firebolt::rialto::HaveDataResponse *response,
     628              :                                           ::google::protobuf::Closure *done)
     629              : {
     630            2 :     RIALTO_SERVER_LOG_DEBUG("entry:");
     631            2 :     firebolt::rialto::MediaSourceStatus status{convertMediaSourceStatus(request->status())};
     632            2 :     if (!m_mediaPipelineService.haveData(request->session_id(), status, request->num_frames(), request->request_id()))
     633              :     {
     634            1 :         RIALTO_SERVER_LOG_ERROR("Have data failed");
     635            3 :         controller->SetFailed("Operation failed");
     636              :     }
     637            2 :     done->Run();
     638              : }
     639              : 
     640            2 : void MediaPipelineModuleService::setPlaybackRate(::google::protobuf::RpcController *controller,
     641              :                                                  const ::firebolt::rialto::SetPlaybackRateRequest *request,
     642              :                                                  ::firebolt::rialto::SetPlaybackRateResponse *response,
     643              :                                                  ::google::protobuf::Closure *done)
     644              : {
     645            2 :     RIALTO_SERVER_LOG_DEBUG("entry:");
     646            2 :     if (!m_mediaPipelineService.setPlaybackRate(request->session_id(), request->rate()))
     647              :     {
     648            1 :         RIALTO_SERVER_LOG_ERROR("Set playback rate failed");
     649            3 :         controller->SetFailed("Operation failed");
     650              :     }
     651            2 :     done->Run();
     652              : }
     653              : 
     654            2 : void MediaPipelineModuleService::getPosition(::google::protobuf::RpcController *controller,
     655              :                                              const ::firebolt::rialto::GetPositionRequest *request,
     656              :                                              ::firebolt::rialto::GetPositionResponse *response,
     657              :                                              ::google::protobuf::Closure *done)
     658              : {
     659            2 :     RIALTO_SERVER_LOG_DEBUG("entry:");
     660            2 :     int64_t position{};
     661            2 :     if (!m_mediaPipelineService.getPosition(request->session_id(), position))
     662              :     {
     663            1 :         RIALTO_SERVER_LOG_ERROR("Get position failed");
     664            3 :         controller->SetFailed("Operation failed");
     665              :     }
     666              :     else
     667              :     {
     668            1 :         response->set_position(position);
     669              :     }
     670            2 :     done->Run();
     671              : }
     672              : 
     673            2 : void MediaPipelineModuleService::getDuration(::google::protobuf::RpcController *controller,
     674              :                                              const ::firebolt::rialto::GetDurationRequest *request,
     675              :                                              ::firebolt::rialto::GetDurationResponse *response,
     676              :                                              ::google::protobuf::Closure *done)
     677              : {
     678            2 :     RIALTO_SERVER_LOG_DEBUG("entry:");
     679            2 :     int64_t duration{};
     680            2 :     if (!m_mediaPipelineService.getDuration(request->session_id(), duration))
     681              :     {
     682            1 :         RIALTO_SERVER_LOG_ERROR("Get duration failed");
     683            3 :         controller->SetFailed("Operation failed");
     684              :     }
     685              :     else
     686              :     {
     687            1 :         response->set_duration(duration);
     688              :     }
     689            2 :     done->Run();
     690              : }
     691              : 
     692            2 : void MediaPipelineModuleService::setImmediateOutput(::google::protobuf::RpcController *controller,
     693              :                                                     const ::firebolt::rialto::SetImmediateOutputRequest *request,
     694              :                                                     ::firebolt::rialto::SetImmediateOutputResponse *response,
     695              :                                                     ::google::protobuf::Closure *done)
     696              : {
     697            2 :     RIALTO_SERVER_LOG_DEBUG("entry:");
     698            2 :     if (!m_mediaPipelineService.setImmediateOutput(request->session_id(), request->source_id(),
     699            2 :                                                    request->immediate_output()))
     700              :     {
     701            1 :         RIALTO_SERVER_LOG_ERROR("Set Immediate Output failed");
     702            3 :         controller->SetFailed("Operation failed");
     703              :     }
     704            2 :     done->Run();
     705              : }
     706              : 
     707            2 : void MediaPipelineModuleService::setReportDecodeErrors(::google::protobuf::RpcController *controller,
     708              :                                                        const ::firebolt::rialto::SetReportDecodeErrorsRequest *request,
     709              :                                                        ::firebolt::rialto::SetReportDecodeErrorsResponse *response,
     710              :                                                        ::google::protobuf::Closure *done)
     711              : {
     712            2 :     RIALTO_SERVER_LOG_DEBUG("entry:");
     713            2 :     if (!m_mediaPipelineService.setReportDecodeErrors(request->session_id(), request->source_id(),
     714            2 :                                                       request->report_decode_errors()))
     715              :     {
     716            1 :         RIALTO_SERVER_LOG_ERROR("Set Report Decode Error failed");
     717            3 :         controller->SetFailed("Operation failed");
     718              :     }
     719            2 :     done->Run();
     720              : }
     721              : 
     722            2 : void MediaPipelineModuleService::getQueuedFrames(::google::protobuf::RpcController *controller,
     723              :                                                  const ::firebolt::rialto::GetQueuedFramesRequest *request,
     724              :                                                  ::firebolt::rialto::GetQueuedFramesResponse *response,
     725              :                                                  ::google::protobuf::Closure *done)
     726              : {
     727            2 :     RIALTO_SERVER_LOG_DEBUG("entry:");
     728              :     uint32_t queuedFramesNumber;
     729            2 :     if (!m_mediaPipelineService.getQueuedFrames(request->session_id(), request->source_id(), queuedFramesNumber))
     730              :     {
     731            1 :         RIALTO_SERVER_LOG_ERROR("Get queued frames failed");
     732            3 :         controller->SetFailed("Operation failed");
     733              :     }
     734              :     else
     735              :     {
     736            1 :         response->set_queued_frames(queuedFramesNumber);
     737              :     }
     738            2 :     done->Run();
     739              : }
     740              : 
     741            2 : void MediaPipelineModuleService::getImmediateOutput(::google::protobuf::RpcController *controller,
     742              :                                                     const ::firebolt::rialto::GetImmediateOutputRequest *request,
     743              :                                                     ::firebolt::rialto::GetImmediateOutputResponse *response,
     744              :                                                     ::google::protobuf::Closure *done)
     745              : {
     746            2 :     RIALTO_SERVER_LOG_DEBUG("entry:");
     747              :     bool immediateOutputState;
     748            2 :     if (!m_mediaPipelineService.getImmediateOutput(request->session_id(), request->source_id(), immediateOutputState))
     749              :     {
     750            1 :         RIALTO_SERVER_LOG_ERROR("Get Immediate Output failed");
     751            3 :         controller->SetFailed("Operation failed");
     752              :     }
     753              :     else
     754              :     {
     755            1 :         response->set_immediate_output(immediateOutputState);
     756              :     }
     757            2 :     done->Run();
     758              : }
     759              : 
     760            2 : void MediaPipelineModuleService::getStats(::google::protobuf::RpcController *controller,
     761              :                                           const ::firebolt::rialto::GetStatsRequest *request,
     762              :                                           ::firebolt::rialto::GetStatsResponse *response,
     763              :                                           ::google::protobuf::Closure *done)
     764              : {
     765            2 :     RIALTO_SERVER_LOG_DEBUG("entry:");
     766              :     uint64_t renderedFrames;
     767              :     uint64_t droppedFrames;
     768            2 :     if (!m_mediaPipelineService.getStats(request->session_id(), request->source_id(), renderedFrames, droppedFrames))
     769              :     {
     770            1 :         RIALTO_SERVER_LOG_ERROR("Get stats failed");
     771            3 :         controller->SetFailed("Operation failed");
     772              :     }
     773              :     else
     774              :     {
     775            1 :         response->set_rendered_frames(renderedFrames);
     776            1 :         response->set_dropped_frames(droppedFrames);
     777              :     }
     778            2 :     done->Run();
     779              : }
     780              : 
     781            2 : void MediaPipelineModuleService::renderFrame(::google::protobuf::RpcController *controller,
     782              :                                              const ::firebolt::rialto::RenderFrameRequest *request,
     783              :                                              ::firebolt::rialto::RenderFrameResponse *response,
     784              :                                              ::google::protobuf::Closure *done)
     785              : {
     786            2 :     RIALTO_SERVER_LOG_DEBUG("entry:");
     787              : 
     788            2 :     if (!m_mediaPipelineService.renderFrame(request->session_id()))
     789              :     {
     790            1 :         RIALTO_SERVER_LOG_ERROR("Render frame");
     791            3 :         controller->SetFailed("Operation failed");
     792              :     }
     793              : 
     794            2 :     done->Run();
     795              : }
     796              : 
     797            2 : void MediaPipelineModuleService::setVolume(::google::protobuf::RpcController *controller,
     798              :                                            const ::firebolt::rialto::SetVolumeRequest *request,
     799              :                                            ::firebolt::rialto::SetVolumeResponse *response,
     800              :                                            ::google::protobuf::Closure *done)
     801              : {
     802            2 :     RIALTO_SERVER_LOG_DEBUG("entry:");
     803              : 
     804            2 :     if (!m_mediaPipelineService.setVolume(request->session_id(), request->volume(), request->volume_duration(),
     805            4 :                                           convertEaseType(request->ease_type())))
     806              :     {
     807            1 :         RIALTO_SERVER_LOG_ERROR("Set volume failed.");
     808            3 :         controller->SetFailed("Operation failed");
     809              :     }
     810              : 
     811            2 :     done->Run();
     812              : }
     813              : 
     814            2 : void MediaPipelineModuleService::getVolume(::google::protobuf::RpcController *controller,
     815              :                                            const ::firebolt::rialto::GetVolumeRequest *request,
     816              :                                            ::firebolt::rialto::GetVolumeResponse *response,
     817              :                                            ::google::protobuf::Closure *done)
     818              : {
     819            2 :     RIALTO_SERVER_LOG_DEBUG("entry:");
     820            2 :     double volume{};
     821              : 
     822            2 :     if (!m_mediaPipelineService.getVolume(request->session_id(), volume))
     823              :     {
     824            1 :         RIALTO_SERVER_LOG_ERROR("Get volume failed.");
     825            3 :         controller->SetFailed("Operation failed");
     826              :     }
     827              :     else
     828              :     {
     829            1 :         response->set_volume(volume);
     830              :     }
     831              : 
     832            2 :     done->Run();
     833              : }
     834              : 
     835            2 : void MediaPipelineModuleService::setMute(::google::protobuf::RpcController *controller,
     836              :                                          const ::firebolt::rialto::SetMuteRequest *request,
     837              :                                          ::firebolt::rialto::SetMuteResponse *response, ::google::protobuf::Closure *done)
     838              : {
     839            2 :     RIALTO_SERVER_LOG_DEBUG("entry:");
     840              : 
     841            2 :     if (!m_mediaPipelineService.setMute(request->session_id(), request->source_id(), request->mute()))
     842              :     {
     843            1 :         RIALTO_SERVER_LOG_ERROR("Set mute failed.");
     844            3 :         controller->SetFailed("Operation failed");
     845              :     }
     846              : 
     847            2 :     done->Run();
     848              : }
     849              : 
     850            2 : void MediaPipelineModuleService::getMute(::google::protobuf::RpcController *controller,
     851              :                                          const ::firebolt::rialto::GetMuteRequest *request,
     852              :                                          ::firebolt::rialto::GetMuteResponse *response, ::google::protobuf::Closure *done)
     853              : {
     854            2 :     RIALTO_SERVER_LOG_DEBUG("entry:");
     855            2 :     bool mute{};
     856              : 
     857            2 :     if (!m_mediaPipelineService.getMute(request->session_id(), request->source_id(), mute))
     858              :     {
     859            1 :         RIALTO_SERVER_LOG_ERROR("Get mute failed.");
     860            3 :         controller->SetFailed("Operation failed");
     861              :     }
     862              :     else
     863              :     {
     864            1 :         response->set_mute(mute);
     865              :     }
     866              : 
     867            2 :     done->Run();
     868              : }
     869              : 
     870            2 : void MediaPipelineModuleService::setTextTrackIdentifier(::google::protobuf::RpcController *controller,
     871              :                                                         const ::firebolt::rialto::SetTextTrackIdentifierRequest *request,
     872              :                                                         ::firebolt::rialto::SetTextTrackIdentifierResponse *response,
     873              :                                                         ::google::protobuf::Closure *done)
     874              : {
     875            2 :     RIALTO_SERVER_LOG_DEBUG("entry:");
     876              : 
     877            2 :     if (!m_mediaPipelineService.setTextTrackIdentifier(request->session_id(), request->text_track_identifier()))
     878              :     {
     879            1 :         RIALTO_SERVER_LOG_ERROR("Set text track identifier failed.");
     880            3 :         controller->SetFailed("Operation failed");
     881              :     }
     882              : 
     883            2 :     done->Run();
     884              : }
     885              : 
     886            2 : void MediaPipelineModuleService::getTextTrackIdentifier(::google::protobuf::RpcController *controller,
     887              :                                                         const ::firebolt::rialto::GetTextTrackIdentifierRequest *request,
     888              :                                                         ::firebolt::rialto::GetTextTrackIdentifierResponse *response,
     889              :                                                         ::google::protobuf::Closure *done)
     890              : {
     891            2 :     RIALTO_SERVER_LOG_DEBUG("entry:");
     892            2 :     std::string textTrackIdentifier{};
     893              : 
     894            2 :     if (!m_mediaPipelineService.getTextTrackIdentifier(request->session_id(), textTrackIdentifier))
     895              :     {
     896            1 :         RIALTO_SERVER_LOG_ERROR("Get TextTrackIdentifier failed.");
     897            3 :         controller->SetFailed("Operation failed");
     898              :     }
     899              :     else
     900              :     {
     901              :         response->set_text_track_identifier(textTrackIdentifier);
     902              :     }
     903              : 
     904            2 :     done->Run();
     905              : }
     906              : 
     907            2 : void MediaPipelineModuleService::setLowLatency(::google::protobuf::RpcController *controller,
     908              :                                                const ::firebolt::rialto::SetLowLatencyRequest *request,
     909              :                                                ::firebolt::rialto::SetLowLatencyResponse *response,
     910              :                                                ::google::protobuf::Closure *done)
     911              : {
     912            2 :     RIALTO_SERVER_LOG_DEBUG("entry:");
     913              : 
     914            2 :     if (!m_mediaPipelineService.setLowLatency(request->session_id(), request->low_latency()))
     915              :     {
     916            1 :         RIALTO_SERVER_LOG_ERROR("Set low latency failed.");
     917            3 :         controller->SetFailed("Operation failed");
     918              :     }
     919              : 
     920            2 :     done->Run();
     921              : }
     922              : 
     923            2 : void MediaPipelineModuleService::setSync(::google::protobuf::RpcController *controller,
     924              :                                          const ::firebolt::rialto::SetSyncRequest *request,
     925              :                                          ::firebolt::rialto::SetSyncResponse *response, ::google::protobuf::Closure *done)
     926              : {
     927            2 :     RIALTO_SERVER_LOG_DEBUG("entry:");
     928              : 
     929            2 :     if (!m_mediaPipelineService.setSync(request->session_id(), request->sync()))
     930              :     {
     931            1 :         RIALTO_SERVER_LOG_ERROR("Set sync failed.");
     932            3 :         controller->SetFailed("Operation failed");
     933              :     }
     934              : 
     935            2 :     done->Run();
     936              : }
     937              : 
     938            2 : void MediaPipelineModuleService::getSync(::google::protobuf::RpcController *controller,
     939              :                                          const ::firebolt::rialto::GetSyncRequest *request,
     940              :                                          ::firebolt::rialto::GetSyncResponse *response, ::google::protobuf::Closure *done)
     941              : {
     942            2 :     RIALTO_SERVER_LOG_DEBUG("entry:");
     943            2 :     bool sync{};
     944              : 
     945            2 :     if (!m_mediaPipelineService.getSync(request->session_id(), sync))
     946              :     {
     947            1 :         RIALTO_SERVER_LOG_ERROR("Get sync failed.");
     948            3 :         controller->SetFailed("Operation failed");
     949              :     }
     950              :     else
     951              :     {
     952            1 :         response->set_sync(sync);
     953              :     }
     954              : 
     955            2 :     done->Run();
     956              : }
     957              : 
     958            2 : void MediaPipelineModuleService::setSyncOff(::google::protobuf::RpcController *controller,
     959              :                                             const ::firebolt::rialto::SetSyncOffRequest *request,
     960              :                                             ::firebolt::rialto::SetSyncOffResponse *response,
     961              :                                             ::google::protobuf::Closure *done)
     962              : {
     963            2 :     RIALTO_SERVER_LOG_DEBUG("entry:");
     964              : 
     965            2 :     if (!m_mediaPipelineService.setSyncOff(request->session_id(), request->sync_off()))
     966              :     {
     967            1 :         RIALTO_SERVER_LOG_ERROR("Set sync off failed.");
     968            3 :         controller->SetFailed("Operation failed");
     969              :     }
     970              : 
     971            2 :     done->Run();
     972              : }
     973              : 
     974            2 : void MediaPipelineModuleService::setStreamSyncMode(::google::protobuf::RpcController *controller,
     975              :                                                    const ::firebolt::rialto::SetStreamSyncModeRequest *request,
     976              :                                                    ::firebolt::rialto::SetStreamSyncModeResponse *response,
     977              :                                                    ::google::protobuf::Closure *done)
     978              : {
     979            2 :     RIALTO_SERVER_LOG_DEBUG("entry:");
     980              : 
     981            2 :     if (!m_mediaPipelineService.setStreamSyncMode(request->session_id(), request->source_id(),
     982              :                                                   request->stream_sync_mode()))
     983              :     {
     984            1 :         RIALTO_SERVER_LOG_ERROR("Set stream sync mode failed.");
     985            3 :         controller->SetFailed("Operation failed");
     986              :     }
     987              : 
     988            2 :     done->Run();
     989              : }
     990              : 
     991            2 : void MediaPipelineModuleService::getStreamSyncMode(::google::protobuf::RpcController *controller,
     992              :                                                    const ::firebolt::rialto::GetStreamSyncModeRequest *request,
     993              :                                                    ::firebolt::rialto::GetStreamSyncModeResponse *response,
     994              :                                                    ::google::protobuf::Closure *done)
     995              : {
     996            2 :     RIALTO_SERVER_LOG_DEBUG("entry:");
     997            2 :     int32_t streamSyncMode{};
     998              : 
     999            2 :     if (!m_mediaPipelineService.getStreamSyncMode(request->session_id(), streamSyncMode))
    1000              :     {
    1001            1 :         RIALTO_SERVER_LOG_ERROR("Get stream sync mode failed.");
    1002            3 :         controller->SetFailed("Operation failed");
    1003              :     }
    1004              :     else
    1005              :     {
    1006            1 :         response->set_stream_sync_mode(streamSyncMode);
    1007              :     }
    1008              : 
    1009            2 :     done->Run();
    1010              : }
    1011              : 
    1012            2 : void MediaPipelineModuleService::flush(::google::protobuf::RpcController *controller,
    1013              :                                        const ::firebolt::rialto::FlushRequest *request,
    1014              :                                        ::firebolt::rialto::FlushResponse *response, ::google::protobuf::Closure *done)
    1015              : {
    1016            2 :     RIALTO_SERVER_LOG_DEBUG("entry:");
    1017              : 
    1018            2 :     bool isAsync{false};
    1019            2 :     if (!m_mediaPipelineService.flush(request->session_id(), request->source_id(), request->reset_time(), isAsync))
    1020              :     {
    1021            1 :         RIALTO_SERVER_LOG_ERROR("Flush failed.");
    1022            3 :         controller->SetFailed("Operation failed");
    1023              :     }
    1024            2 :     response->set_async(isAsync);
    1025              : 
    1026            2 :     done->Run();
    1027              : }
    1028              : 
    1029            2 : void MediaPipelineModuleService::setSourcePosition(::google::protobuf::RpcController *controller,
    1030              :                                                    const ::firebolt::rialto::SetSourcePositionRequest *request,
    1031              :                                                    ::firebolt::rialto::SetSourcePositionResponse *response,
    1032              :                                                    ::google::protobuf::Closure *done)
    1033              : {
    1034            2 :     RIALTO_SERVER_LOG_DEBUG("entry:");
    1035            4 :     if (!m_mediaPipelineService.setSourcePosition(request->session_id(), request->source_id(), request->position(),
    1036            2 :                                                   request->reset_time(), request->applied_rate(),
    1037              :                                                   request->stop_position()))
    1038              :     {
    1039            1 :         RIALTO_SERVER_LOG_ERROR("Set Source Position failed.");
    1040            3 :         controller->SetFailed("Operation failed");
    1041              :     }
    1042            2 :     done->Run();
    1043              : }
    1044              : 
    1045            0 : void MediaPipelineModuleService::setSubtitleOffset(::google::protobuf::RpcController *controller,
    1046              :                                                    const ::firebolt::rialto::SetSubtitleOffsetRequest *request,
    1047              :                                                    ::firebolt::rialto::SetSubtitleOffsetResponse *response,
    1048              :                                                    ::google::protobuf::Closure *done)
    1049              : {
    1050            0 :     RIALTO_SERVER_LOG_DEBUG("entry:");
    1051            0 :     if (!m_mediaPipelineService.setSubtitleOffset(request->session_id(), request->source_id(), request->position()))
    1052              :     {
    1053            0 :         RIALTO_SERVER_LOG_ERROR("Set Subtitle Offset failed.");
    1054            0 :         controller->SetFailed("Operation failed");
    1055              :     }
    1056            0 :     done->Run();
    1057              : }
    1058              : 
    1059            2 : void MediaPipelineModuleService::processAudioGap(::google::protobuf::RpcController *controller,
    1060              :                                                  const ::firebolt::rialto::ProcessAudioGapRequest *request,
    1061              :                                                  ::firebolt::rialto::ProcessAudioGapResponse *response,
    1062              :                                                  ::google::protobuf::Closure *done)
    1063              : {
    1064            2 :     RIALTO_SERVER_LOG_DEBUG("entry:");
    1065            2 :     if (!m_mediaPipelineService.processAudioGap(request->session_id(), request->position(), request->duration(),
    1066            2 :                                                 request->discontinuity_gap(), request->audio_aac()))
    1067              :     {
    1068            1 :         RIALTO_SERVER_LOG_ERROR("Process audio gap failed.");
    1069            3 :         controller->SetFailed("Operation failed");
    1070              :     }
    1071            2 :     done->Run();
    1072              : }
    1073              : 
    1074            2 : void MediaPipelineModuleService::setBufferingLimit(::google::protobuf::RpcController *controller,
    1075              :                                                    const ::firebolt::rialto::SetBufferingLimitRequest *request,
    1076              :                                                    ::firebolt::rialto::SetBufferingLimitResponse *response,
    1077              :                                                    ::google::protobuf::Closure *done)
    1078              : {
    1079            2 :     RIALTO_SERVER_LOG_DEBUG("entry:");
    1080            2 :     if (!m_mediaPipelineService.setBufferingLimit(request->session_id(), request->limit_buffering_ms()))
    1081              :     {
    1082            1 :         RIALTO_SERVER_LOG_ERROR("Set buffering limit failed.");
    1083            3 :         controller->SetFailed("Operation failed");
    1084              :     }
    1085            2 :     done->Run();
    1086              : }
    1087              : 
    1088            2 : void MediaPipelineModuleService::getBufferingLimit(::google::protobuf::RpcController *controller,
    1089              :                                                    const ::firebolt::rialto::GetBufferingLimitRequest *request,
    1090              :                                                    ::firebolt::rialto::GetBufferingLimitResponse *response,
    1091              :                                                    ::google::protobuf::Closure *done)
    1092              : {
    1093            2 :     RIALTO_SERVER_LOG_DEBUG("entry:");
    1094            2 :     uint32_t bufferingLimit{};
    1095              : 
    1096            2 :     if (!m_mediaPipelineService.getBufferingLimit(request->session_id(), bufferingLimit))
    1097              :     {
    1098            1 :         RIALTO_SERVER_LOG_ERROR("Get buffering limit failed.");
    1099            3 :         controller->SetFailed("Operation failed");
    1100              :     }
    1101              :     else
    1102              :     {
    1103            1 :         response->set_limit_buffering_ms(bufferingLimit);
    1104              :     }
    1105              : 
    1106            2 :     done->Run();
    1107              : }
    1108              : 
    1109            2 : void MediaPipelineModuleService::setUseBuffering(::google::protobuf::RpcController *controller,
    1110              :                                                  const ::firebolt::rialto::SetUseBufferingRequest *request,
    1111              :                                                  ::firebolt::rialto::SetUseBufferingResponse *response,
    1112              :                                                  ::google::protobuf::Closure *done)
    1113              : {
    1114            2 :     RIALTO_SERVER_LOG_DEBUG("entry:");
    1115            2 :     if (!m_mediaPipelineService.setUseBuffering(request->session_id(), request->use_buffering()))
    1116              :     {
    1117            1 :         RIALTO_SERVER_LOG_ERROR("Set use buffering failed.");
    1118            3 :         controller->SetFailed("Operation failed");
    1119              :     }
    1120            2 :     done->Run();
    1121              : }
    1122              : 
    1123            2 : void MediaPipelineModuleService::getUseBuffering(::google::protobuf::RpcController *controller,
    1124              :                                                  const ::firebolt::rialto::GetUseBufferingRequest *request,
    1125              :                                                  ::firebolt::rialto::GetUseBufferingResponse *response,
    1126              :                                                  ::google::protobuf::Closure *done)
    1127              : {
    1128            2 :     RIALTO_SERVER_LOG_DEBUG("entry:");
    1129            2 :     bool useBuffering{};
    1130              : 
    1131            2 :     if (!m_mediaPipelineService.getUseBuffering(request->session_id(), useBuffering))
    1132              :     {
    1133            1 :         RIALTO_SERVER_LOG_ERROR("Get use buffering failed.");
    1134            3 :         controller->SetFailed("Operation failed");
    1135              :     }
    1136              :     else
    1137              :     {
    1138            1 :         response->set_use_buffering(useBuffering);
    1139              :     }
    1140              : 
    1141            2 :     done->Run();
    1142              : }
    1143              : } // namespace firebolt::rialto::server::ipc
        

Generated by: LCOV version 2.0-1