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