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

Generated by: LCOV version 2.0-1