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