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