LCOV - code coverage report
Current view: top level - media/server/ipc/source - MediaPipelineModuleService.cpp (source / functions) Coverage Total Hit
Test: coverage.info Lines: 86.4 % 470 406
Test Date: 2026-07-07 06:27:16 Functions: 96.3 % 54 52

            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           24 : int generateSessionId()
      34              : {
      35              :     static int sessionId{0};
      36           24 :     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           94 : MediaPipelineModuleService::MediaPipelineModuleService(service::IMediaPipelineService &mediaPipelineService)
     294           94 :     : 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           24 : 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           24 :     RIALTO_SERVER_LOG_DEBUG("entry:");
     335           24 :     auto ipcController = dynamic_cast<firebolt::rialto::ipc::IController *>(controller);
     336           24 :     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           24 :     int sessionId = generateSessionId();
     345              :     bool sessionCreated =
     346           48 :         m_mediaPipelineService.createSession(sessionId,
     347           48 :                                              std::make_shared<MediaPipelineClient>(sessionId, ipcController->getClient()),
     348              :                                              request->max_width(), request->max_height());
     349           24 :     if (sessionCreated)
     350              :     {
     351              :         // Assume that IPC library works well and client is present
     352           23 :         m_clientSessions[ipcController->getClient()].insert(sessionId);
     353           23 :         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           24 :     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 :         auto codecDataProto = request->codec_data();
     433            1 :         codecData = std::make_shared<CodecData>();
     434            1 :         codecData->data = std::vector<std::uint8_t>(codecDataProto.data().begin(), codecDataProto.data().end());
     435            1 :         codecData->type = convertCodecDataType(codecDataProto.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::getImmediateOutput(::google::protobuf::RpcController *controller,
     707              :                                                     const ::firebolt::rialto::GetImmediateOutputRequest *request,
     708              :                                                     ::firebolt::rialto::GetImmediateOutputResponse *response,
     709              :                                                     ::google::protobuf::Closure *done)
     710              : {
     711            2 :     RIALTO_SERVER_LOG_DEBUG("entry:");
     712              :     bool immediateOutputState;
     713            2 :     if (!m_mediaPipelineService.getImmediateOutput(request->session_id(), request->source_id(), immediateOutputState))
     714              :     {
     715            1 :         RIALTO_SERVER_LOG_ERROR("Get Immediate Output failed");
     716            3 :         controller->SetFailed("Operation failed");
     717              :     }
     718              :     else
     719              :     {
     720            1 :         response->set_immediate_output(immediateOutputState);
     721              :     }
     722            2 :     done->Run();
     723              : }
     724              : 
     725            2 : void MediaPipelineModuleService::getStats(::google::protobuf::RpcController *controller,
     726              :                                           const ::firebolt::rialto::GetStatsRequest *request,
     727              :                                           ::firebolt::rialto::GetStatsResponse *response,
     728              :                                           ::google::protobuf::Closure *done)
     729              : {
     730            2 :     RIALTO_SERVER_LOG_DEBUG("entry:");
     731              :     uint64_t renderedFrames;
     732              :     uint64_t droppedFrames;
     733            2 :     if (!m_mediaPipelineService.getStats(request->session_id(), request->source_id(), renderedFrames, droppedFrames))
     734              :     {
     735            1 :         RIALTO_SERVER_LOG_ERROR("Get stats failed");
     736            3 :         controller->SetFailed("Operation failed");
     737              :     }
     738              :     else
     739              :     {
     740            1 :         response->set_rendered_frames(renderedFrames);
     741            1 :         response->set_dropped_frames(droppedFrames);
     742              :     }
     743            2 :     done->Run();
     744              : }
     745              : 
     746            2 : void MediaPipelineModuleService::renderFrame(::google::protobuf::RpcController *controller,
     747              :                                              const ::firebolt::rialto::RenderFrameRequest *request,
     748              :                                              ::firebolt::rialto::RenderFrameResponse *response,
     749              :                                              ::google::protobuf::Closure *done)
     750              : {
     751            2 :     RIALTO_SERVER_LOG_DEBUG("entry:");
     752              : 
     753            2 :     if (!m_mediaPipelineService.renderFrame(request->session_id()))
     754              :     {
     755            1 :         RIALTO_SERVER_LOG_ERROR("Render frame");
     756            3 :         controller->SetFailed("Operation failed");
     757              :     }
     758              : 
     759            2 :     done->Run();
     760              : }
     761              : 
     762            2 : void MediaPipelineModuleService::setVolume(::google::protobuf::RpcController *controller,
     763              :                                            const ::firebolt::rialto::SetVolumeRequest *request,
     764              :                                            ::firebolt::rialto::SetVolumeResponse *response,
     765              :                                            ::google::protobuf::Closure *done)
     766              : {
     767            2 :     RIALTO_SERVER_LOG_DEBUG("entry:");
     768              : 
     769            2 :     if (!m_mediaPipelineService.setVolume(request->session_id(), request->volume(), request->volume_duration(),
     770            4 :                                           convertEaseType(request->ease_type())))
     771              :     {
     772            1 :         RIALTO_SERVER_LOG_ERROR("Set volume failed.");
     773            3 :         controller->SetFailed("Operation failed");
     774              :     }
     775              : 
     776            2 :     done->Run();
     777              : }
     778              : 
     779            2 : void MediaPipelineModuleService::getVolume(::google::protobuf::RpcController *controller,
     780              :                                            const ::firebolt::rialto::GetVolumeRequest *request,
     781              :                                            ::firebolt::rialto::GetVolumeResponse *response,
     782              :                                            ::google::protobuf::Closure *done)
     783              : {
     784            2 :     RIALTO_SERVER_LOG_DEBUG("entry:");
     785            2 :     double volume{};
     786              : 
     787            2 :     if (!m_mediaPipelineService.getVolume(request->session_id(), volume))
     788              :     {
     789            1 :         RIALTO_SERVER_LOG_ERROR("Get volume failed.");
     790            3 :         controller->SetFailed("Operation failed");
     791              :     }
     792              :     else
     793              :     {
     794            1 :         response->set_volume(volume);
     795              :     }
     796              : 
     797            2 :     done->Run();
     798              : }
     799              : 
     800            2 : void MediaPipelineModuleService::setMute(::google::protobuf::RpcController *controller,
     801              :                                          const ::firebolt::rialto::SetMuteRequest *request,
     802              :                                          ::firebolt::rialto::SetMuteResponse *response, ::google::protobuf::Closure *done)
     803              : {
     804            2 :     RIALTO_SERVER_LOG_DEBUG("entry:");
     805              : 
     806            2 :     if (!m_mediaPipelineService.setMute(request->session_id(), request->source_id(), request->mute()))
     807              :     {
     808            1 :         RIALTO_SERVER_LOG_ERROR("Set mute failed.");
     809            3 :         controller->SetFailed("Operation failed");
     810              :     }
     811              : 
     812            2 :     done->Run();
     813              : }
     814              : 
     815            2 : void MediaPipelineModuleService::getMute(::google::protobuf::RpcController *controller,
     816              :                                          const ::firebolt::rialto::GetMuteRequest *request,
     817              :                                          ::firebolt::rialto::GetMuteResponse *response, ::google::protobuf::Closure *done)
     818              : {
     819            2 :     RIALTO_SERVER_LOG_DEBUG("entry:");
     820            2 :     bool mute{};
     821              : 
     822            2 :     if (!m_mediaPipelineService.getMute(request->session_id(), request->source_id(), mute))
     823              :     {
     824            1 :         RIALTO_SERVER_LOG_ERROR("Get mute failed.");
     825            3 :         controller->SetFailed("Operation failed");
     826              :     }
     827              :     else
     828              :     {
     829            1 :         response->set_mute(mute);
     830              :     }
     831              : 
     832            2 :     done->Run();
     833              : }
     834              : 
     835            2 : void MediaPipelineModuleService::setTextTrackIdentifier(::google::protobuf::RpcController *controller,
     836              :                                                         const ::firebolt::rialto::SetTextTrackIdentifierRequest *request,
     837              :                                                         ::firebolt::rialto::SetTextTrackIdentifierResponse *response,
     838              :                                                         ::google::protobuf::Closure *done)
     839              : {
     840            2 :     RIALTO_SERVER_LOG_DEBUG("entry:");
     841              : 
     842            2 :     if (!m_mediaPipelineService.setTextTrackIdentifier(request->session_id(), request->text_track_identifier()))
     843              :     {
     844            1 :         RIALTO_SERVER_LOG_ERROR("Set text track identifier failed.");
     845            3 :         controller->SetFailed("Operation failed");
     846              :     }
     847              : 
     848            2 :     done->Run();
     849              : }
     850              : 
     851            2 : void MediaPipelineModuleService::getTextTrackIdentifier(::google::protobuf::RpcController *controller,
     852              :                                                         const ::firebolt::rialto::GetTextTrackIdentifierRequest *request,
     853              :                                                         ::firebolt::rialto::GetTextTrackIdentifierResponse *response,
     854              :                                                         ::google::protobuf::Closure *done)
     855              : {
     856            2 :     RIALTO_SERVER_LOG_DEBUG("entry:");
     857            2 :     std::string textTrackIdentifier{};
     858              : 
     859            2 :     if (!m_mediaPipelineService.getTextTrackIdentifier(request->session_id(), textTrackIdentifier))
     860              :     {
     861            1 :         RIALTO_SERVER_LOG_ERROR("Get TextTrackIdentifier failed.");
     862            3 :         controller->SetFailed("Operation failed");
     863              :     }
     864              :     else
     865              :     {
     866              :         response->set_text_track_identifier(textTrackIdentifier);
     867              :     }
     868              : 
     869            2 :     done->Run();
     870              : }
     871              : 
     872            2 : void MediaPipelineModuleService::setLowLatency(::google::protobuf::RpcController *controller,
     873              :                                                const ::firebolt::rialto::SetLowLatencyRequest *request,
     874              :                                                ::firebolt::rialto::SetLowLatencyResponse *response,
     875              :                                                ::google::protobuf::Closure *done)
     876              : {
     877            2 :     RIALTO_SERVER_LOG_DEBUG("entry:");
     878              : 
     879            2 :     if (!m_mediaPipelineService.setLowLatency(request->session_id(), request->low_latency()))
     880              :     {
     881            1 :         RIALTO_SERVER_LOG_ERROR("Set low latency failed.");
     882            3 :         controller->SetFailed("Operation failed");
     883              :     }
     884              : 
     885            2 :     done->Run();
     886              : }
     887              : 
     888            2 : void MediaPipelineModuleService::setSync(::google::protobuf::RpcController *controller,
     889              :                                          const ::firebolt::rialto::SetSyncRequest *request,
     890              :                                          ::firebolt::rialto::SetSyncResponse *response, ::google::protobuf::Closure *done)
     891              : {
     892            2 :     RIALTO_SERVER_LOG_DEBUG("entry:");
     893              : 
     894            2 :     if (!m_mediaPipelineService.setSync(request->session_id(), request->sync()))
     895              :     {
     896            1 :         RIALTO_SERVER_LOG_ERROR("Set sync failed.");
     897            3 :         controller->SetFailed("Operation failed");
     898              :     }
     899              : 
     900            2 :     done->Run();
     901              : }
     902              : 
     903            2 : void MediaPipelineModuleService::getSync(::google::protobuf::RpcController *controller,
     904              :                                          const ::firebolt::rialto::GetSyncRequest *request,
     905              :                                          ::firebolt::rialto::GetSyncResponse *response, ::google::protobuf::Closure *done)
     906              : {
     907            2 :     RIALTO_SERVER_LOG_DEBUG("entry:");
     908            2 :     bool sync{};
     909              : 
     910            2 :     if (!m_mediaPipelineService.getSync(request->session_id(), sync))
     911              :     {
     912            1 :         RIALTO_SERVER_LOG_ERROR("Get sync failed.");
     913            3 :         controller->SetFailed("Operation failed");
     914              :     }
     915              :     else
     916              :     {
     917            1 :         response->set_sync(sync);
     918              :     }
     919              : 
     920            2 :     done->Run();
     921              : }
     922              : 
     923            2 : void MediaPipelineModuleService::setSyncOff(::google::protobuf::RpcController *controller,
     924              :                                             const ::firebolt::rialto::SetSyncOffRequest *request,
     925              :                                             ::firebolt::rialto::SetSyncOffResponse *response,
     926              :                                             ::google::protobuf::Closure *done)
     927              : {
     928            2 :     RIALTO_SERVER_LOG_DEBUG("entry:");
     929              : 
     930            2 :     if (!m_mediaPipelineService.setSyncOff(request->session_id(), request->sync_off()))
     931              :     {
     932            1 :         RIALTO_SERVER_LOG_ERROR("Set sync off failed.");
     933            3 :         controller->SetFailed("Operation failed");
     934              :     }
     935              : 
     936            2 :     done->Run();
     937              : }
     938              : 
     939            2 : void MediaPipelineModuleService::setStreamSyncMode(::google::protobuf::RpcController *controller,
     940              :                                                    const ::firebolt::rialto::SetStreamSyncModeRequest *request,
     941              :                                                    ::firebolt::rialto::SetStreamSyncModeResponse *response,
     942              :                                                    ::google::protobuf::Closure *done)
     943              : {
     944            2 :     RIALTO_SERVER_LOG_DEBUG("entry:");
     945              : 
     946            2 :     if (!m_mediaPipelineService.setStreamSyncMode(request->session_id(), request->source_id(),
     947              :                                                   request->stream_sync_mode()))
     948              :     {
     949            1 :         RIALTO_SERVER_LOG_ERROR("Set stream sync mode failed.");
     950            3 :         controller->SetFailed("Operation failed");
     951              :     }
     952              : 
     953            2 :     done->Run();
     954              : }
     955              : 
     956            2 : void MediaPipelineModuleService::getStreamSyncMode(::google::protobuf::RpcController *controller,
     957              :                                                    const ::firebolt::rialto::GetStreamSyncModeRequest *request,
     958              :                                                    ::firebolt::rialto::GetStreamSyncModeResponse *response,
     959              :                                                    ::google::protobuf::Closure *done)
     960              : {
     961            2 :     RIALTO_SERVER_LOG_DEBUG("entry:");
     962            2 :     int32_t streamSyncMode{};
     963              : 
     964            2 :     if (!m_mediaPipelineService.getStreamSyncMode(request->session_id(), streamSyncMode))
     965              :     {
     966            1 :         RIALTO_SERVER_LOG_ERROR("Get stream sync mode failed.");
     967            3 :         controller->SetFailed("Operation failed");
     968              :     }
     969              :     else
     970              :     {
     971            1 :         response->set_stream_sync_mode(streamSyncMode);
     972              :     }
     973              : 
     974            2 :     done->Run();
     975              : }
     976              : 
     977            2 : void MediaPipelineModuleService::flush(::google::protobuf::RpcController *controller,
     978              :                                        const ::firebolt::rialto::FlushRequest *request,
     979              :                                        ::firebolt::rialto::FlushResponse *response, ::google::protobuf::Closure *done)
     980              : {
     981            2 :     RIALTO_SERVER_LOG_DEBUG("entry:");
     982              : 
     983            2 :     bool isAsync{false};
     984            2 :     if (!m_mediaPipelineService.flush(request->session_id(), request->source_id(), request->reset_time(), isAsync))
     985              :     {
     986            1 :         RIALTO_SERVER_LOG_ERROR("Flush failed.");
     987            3 :         controller->SetFailed("Operation failed");
     988              :     }
     989            2 :     response->set_async(isAsync);
     990              : 
     991            2 :     done->Run();
     992              : }
     993              : 
     994            2 : void MediaPipelineModuleService::setSourcePosition(::google::protobuf::RpcController *controller,
     995              :                                                    const ::firebolt::rialto::SetSourcePositionRequest *request,
     996              :                                                    ::firebolt::rialto::SetSourcePositionResponse *response,
     997              :                                                    ::google::protobuf::Closure *done)
     998              : {
     999            2 :     RIALTO_SERVER_LOG_DEBUG("entry:");
    1000            4 :     if (!m_mediaPipelineService.setSourcePosition(request->session_id(), request->source_id(), request->position(),
    1001            2 :                                                   request->reset_time(), request->applied_rate(),
    1002              :                                                   request->stop_position()))
    1003              :     {
    1004            1 :         RIALTO_SERVER_LOG_ERROR("Set Source Position failed.");
    1005            3 :         controller->SetFailed("Operation failed");
    1006              :     }
    1007            2 :     done->Run();
    1008              : }
    1009              : 
    1010            0 : void MediaPipelineModuleService::setSubtitleOffset(::google::protobuf::RpcController *controller,
    1011              :                                                    const ::firebolt::rialto::SetSubtitleOffsetRequest *request,
    1012              :                                                    ::firebolt::rialto::SetSubtitleOffsetResponse *response,
    1013              :                                                    ::google::protobuf::Closure *done)
    1014              : {
    1015            0 :     RIALTO_SERVER_LOG_DEBUG("entry:");
    1016            0 :     if (!m_mediaPipelineService.setSubtitleOffset(request->session_id(), request->source_id(), request->position()))
    1017              :     {
    1018            0 :         RIALTO_SERVER_LOG_ERROR("Set Subtitle Offset failed.");
    1019            0 :         controller->SetFailed("Operation failed");
    1020              :     }
    1021            0 :     done->Run();
    1022              : }
    1023              : 
    1024            2 : void MediaPipelineModuleService::processAudioGap(::google::protobuf::RpcController *controller,
    1025              :                                                  const ::firebolt::rialto::ProcessAudioGapRequest *request,
    1026              :                                                  ::firebolt::rialto::ProcessAudioGapResponse *response,
    1027              :                                                  ::google::protobuf::Closure *done)
    1028              : {
    1029            2 :     RIALTO_SERVER_LOG_DEBUG("entry:");
    1030            2 :     if (!m_mediaPipelineService.processAudioGap(request->session_id(), request->position(), request->duration(),
    1031            2 :                                                 request->discontinuity_gap(), request->audio_aac()))
    1032              :     {
    1033            1 :         RIALTO_SERVER_LOG_ERROR("Process audio gap failed.");
    1034            3 :         controller->SetFailed("Operation failed");
    1035              :     }
    1036            2 :     done->Run();
    1037              : }
    1038              : 
    1039            2 : void MediaPipelineModuleService::setBufferingLimit(::google::protobuf::RpcController *controller,
    1040              :                                                    const ::firebolt::rialto::SetBufferingLimitRequest *request,
    1041              :                                                    ::firebolt::rialto::SetBufferingLimitResponse *response,
    1042              :                                                    ::google::protobuf::Closure *done)
    1043              : {
    1044            2 :     RIALTO_SERVER_LOG_DEBUG("entry:");
    1045            2 :     if (!m_mediaPipelineService.setBufferingLimit(request->session_id(), request->limit_buffering_ms()))
    1046              :     {
    1047            1 :         RIALTO_SERVER_LOG_ERROR("Set buffering limit failed.");
    1048            3 :         controller->SetFailed("Operation failed");
    1049              :     }
    1050            2 :     done->Run();
    1051              : }
    1052              : 
    1053            2 : void MediaPipelineModuleService::getBufferingLimit(::google::protobuf::RpcController *controller,
    1054              :                                                    const ::firebolt::rialto::GetBufferingLimitRequest *request,
    1055              :                                                    ::firebolt::rialto::GetBufferingLimitResponse *response,
    1056              :                                                    ::google::protobuf::Closure *done)
    1057              : {
    1058            2 :     RIALTO_SERVER_LOG_DEBUG("entry:");
    1059            2 :     uint32_t bufferingLimit{};
    1060              : 
    1061            2 :     if (!m_mediaPipelineService.getBufferingLimit(request->session_id(), bufferingLimit))
    1062              :     {
    1063            1 :         RIALTO_SERVER_LOG_ERROR("Get buffering limit failed.");
    1064            3 :         controller->SetFailed("Operation failed");
    1065              :     }
    1066              :     else
    1067              :     {
    1068            1 :         response->set_limit_buffering_ms(bufferingLimit);
    1069              :     }
    1070              : 
    1071            2 :     done->Run();
    1072              : }
    1073              : 
    1074            2 : void MediaPipelineModuleService::setUseBuffering(::google::protobuf::RpcController *controller,
    1075              :                                                  const ::firebolt::rialto::SetUseBufferingRequest *request,
    1076              :                                                  ::firebolt::rialto::SetUseBufferingResponse *response,
    1077              :                                                  ::google::protobuf::Closure *done)
    1078              : {
    1079            2 :     RIALTO_SERVER_LOG_DEBUG("entry:");
    1080            2 :     if (!m_mediaPipelineService.setUseBuffering(request->session_id(), request->use_buffering()))
    1081              :     {
    1082            1 :         RIALTO_SERVER_LOG_ERROR("Set use buffering failed.");
    1083            3 :         controller->SetFailed("Operation failed");
    1084              :     }
    1085            2 :     done->Run();
    1086              : }
    1087              : 
    1088            2 : void MediaPipelineModuleService::getUseBuffering(::google::protobuf::RpcController *controller,
    1089              :                                                  const ::firebolt::rialto::GetUseBufferingRequest *request,
    1090              :                                                  ::firebolt::rialto::GetUseBufferingResponse *response,
    1091              :                                                  ::google::protobuf::Closure *done)
    1092              : {
    1093            2 :     RIALTO_SERVER_LOG_DEBUG("entry:");
    1094            2 :     bool useBuffering{};
    1095              : 
    1096            2 :     if (!m_mediaPipelineService.getUseBuffering(request->session_id(), useBuffering))
    1097              :     {
    1098            1 :         RIALTO_SERVER_LOG_ERROR("Get use buffering failed.");
    1099            3 :         controller->SetFailed("Operation failed");
    1100              :     }
    1101              :     else
    1102              :     {
    1103            1 :         response->set_use_buffering(useBuffering);
    1104              :     }
    1105              : 
    1106            2 :     done->Run();
    1107              : }
    1108              : } // namespace firebolt::rialto::server::ipc
        

Generated by: LCOV version 2.0-1