LCOV - code coverage report
Current view: top level - media/server/ipc/source - MediaPipelineModuleService.cpp (source / functions) Coverage Total Hit
Test: coverage.info Lines: 86.5 % 458 396
Test Date: 2025-12-11 15:40:11 Functions: 96.2 % 53 51

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

Generated by: LCOV version 2.0-1