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 : #ifndef FIREBOLT_RIALTO_SERVER_MEDIA_PIPELINE_SERVER_INTERNAL_H_
21 : #define FIREBOLT_RIALTO_SERVER_MEDIA_PIPELINE_SERVER_INTERNAL_H_
22 :
23 : #include "DataReaderFactory.h"
24 : #include "IActiveRequests.h"
25 : #include "IGstGenericPlayer.h"
26 : #include "IMainThread.h"
27 : #include "IMediaPipelineServerInternal.h"
28 : #include "ITimer.h"
29 : #include <map>
30 : #include <memory>
31 : #include <shared_mutex>
32 : #include <string>
33 : #include <unordered_map>
34 : #include <vector>
35 :
36 : namespace firebolt::rialto::server
37 : {
38 : /**
39 : * @brief IMediaPipelineServerInternal factory class definition.
40 : */
41 : class MediaPipelineServerInternalFactory : public server::IMediaPipelineServerInternalFactory
42 : {
43 : public:
44 2 : MediaPipelineServerInternalFactory() = default;
45 2 : ~MediaPipelineServerInternalFactory() override = default;
46 :
47 : std::unique_ptr<IMediaPipeline> createMediaPipeline(std::weak_ptr<IMediaPipelineClient> client,
48 : const VideoRequirements &videoRequirements) const override;
49 :
50 : std::unique_ptr<server::IMediaPipelineServerInternal> createMediaPipelineServerInternal(
51 : std::weak_ptr<IMediaPipelineClient> client, const VideoRequirements &videoRequirements, int sessionId,
52 : const std::shared_ptr<ISharedMemoryBuffer> &shmBuffer, IDecryptionService &decryptionService) const override;
53 :
54 : /**
55 : * @brief Create the generic media player factory object.
56 : *
57 : * @retval the generic media player factory instance or null on error.
58 : */
59 : static std::shared_ptr<MediaPipelineServerInternalFactory> createFactory();
60 : };
61 :
62 : /**
63 : * @brief The definition of the MediaPipelineServerInternal.
64 : */
65 : class MediaPipelineServerInternal : public IMediaPipelineServerInternal, public IGstGenericPlayerClient
66 : {
67 : public:
68 : /**
69 : * @brief The constructor.
70 : *
71 : * @param[in] client : The Rialto media player client.
72 : * @param[in] videoRequirements : The video decoder requirements for the MediaPipeline session.
73 : * @param[in] gstPlayerFactory : The gstreamer player factory.
74 : * @param[in] sessionId : The session id
75 : * @param[in] shmBuffer : The shared memory buffer
76 : * @param[in] mainThreadFactory : The main thread factory.
77 : * @param[in] dataReaderFactory : The data reader factory
78 : * @param[in] activeRequests : The active requests
79 : * @param[in] decryptionService : The decryption service
80 : */
81 : MediaPipelineServerInternal(std::shared_ptr<IMediaPipelineClient> client, const VideoRequirements &videoRequirements,
82 : const std::shared_ptr<IGstGenericPlayerFactory> &gstPlayerFactory, int sessionId,
83 : const std::shared_ptr<ISharedMemoryBuffer> &shmBuffer,
84 : const std::shared_ptr<IMainThreadFactory> &mainThreadFactory,
85 : std::shared_ptr<common::ITimerFactory> timerFactory,
86 : std::unique_ptr<IDataReaderFactory> &&dataReaderFactory,
87 : std::unique_ptr<IActiveRequests> &&activeRequests, IDecryptionService &decryptionService);
88 :
89 : /**
90 : * @brief Virtual destructor.
91 : */
92 : virtual ~MediaPipelineServerInternal();
93 :
94 : bool load(MediaType type, const std::string &mimeType, const std::string &url) override;
95 :
96 : bool attachSource(const std::unique_ptr<MediaSource> &source) override;
97 :
98 : bool removeSource(int32_t id) override;
99 :
100 : bool allSourcesAttached() override;
101 :
102 : bool play(bool &async) override;
103 :
104 : bool pause() override;
105 :
106 : bool stop() override;
107 :
108 : bool setPlaybackRate(double rate) override;
109 :
110 : bool setPosition(int64_t position) override;
111 :
112 : bool getPosition(int64_t &position) override;
113 :
114 : bool setImmediateOutput(int32_t sourceId, bool immediateOutput) override;
115 :
116 : bool getImmediateOutput(int32_t sourceId, bool &immediateOutput) override;
117 :
118 : bool getStats(int32_t sourceId, uint64_t &renderedFrames, uint64_t &droppedFrames) override;
119 :
120 : bool setVideoWindow(uint32_t x, uint32_t y, uint32_t width, uint32_t height) override;
121 :
122 : bool haveData(MediaSourceStatus status, uint32_t needDataRequestId) override;
123 :
124 : bool haveData(MediaSourceStatus status, uint32_t numFrames, uint32_t needDataRequestId) override;
125 :
126 : void ping(std::unique_ptr<IHeartbeatHandler> &&heartbeatHandler) override;
127 :
128 : bool renderFrame() override;
129 :
130 : bool setVolume(double targetVolume, uint32_t volumeDuration, EaseType easeType) override;
131 :
132 : bool getVolume(double ¤tVolume) override;
133 :
134 : bool setMute(std::int32_t sourceId, bool mute) override;
135 :
136 : bool getMute(std::int32_t sourceId, bool &mute) override;
137 :
138 : bool setTextTrackIdentifier(const std::string &textTrackIdentifier) override;
139 :
140 : bool getTextTrackIdentifier(std::string &textTrackIdentifier) override;
141 :
142 : bool setLowLatency(bool lowLatency) override;
143 :
144 : bool setSync(bool sync) override;
145 :
146 : bool getSync(bool &sync) override;
147 :
148 : bool setSyncOff(bool syncOff) override;
149 :
150 : bool setStreamSyncMode(int32_t sourceId, int32_t streamSyncMode) override;
151 :
152 : bool getStreamSyncMode(int32_t &streamSyncMode) override;
153 :
154 : bool flush(int32_t sourceId, bool resetTime, bool &async) override;
155 :
156 : bool setSourcePosition(int32_t sourceId, int64_t position, bool resetTime, double appliedRate,
157 : uint64_t stopPosition) override;
158 :
159 : bool setSubtitleOffset(int32_t sourceId, int64_t position) override;
160 :
161 : bool processAudioGap(int64_t position, uint32_t duration, int64_t discontinuityGap, bool audioAac) override;
162 :
163 : bool setBufferingLimit(uint32_t limitBufferingMs) override;
164 :
165 : bool getBufferingLimit(uint32_t &limitBufferingMs) override;
166 :
167 : bool setUseBuffering(bool useBuffering) override;
168 :
169 : bool getUseBuffering(bool &useBuffering) override;
170 :
171 : bool switchSource(const std::unique_ptr<MediaSource> &source) override;
172 :
173 : AddSegmentStatus addSegment(uint32_t needDataRequestId, const std::unique_ptr<MediaSegment> &mediaSegment) override;
174 :
175 : std::weak_ptr<IMediaPipelineClient> getClient() override;
176 :
177 : void notifyPlaybackState(PlaybackState state) override;
178 :
179 : bool notifyNeedMediaData(MediaSourceType mediaSourceType) override;
180 :
181 : void notifyPosition(std::int64_t position) override;
182 :
183 : void notifyNetworkState(NetworkState state) override;
184 :
185 : void clearActiveRequestsCache() override;
186 :
187 : void invalidateActiveRequests(const MediaSourceType &type) override;
188 :
189 : void notifyQos(MediaSourceType mediaSourceType, const QosInfo &qosInfo) override;
190 :
191 : void notifyBufferUnderflow(MediaSourceType mediaSourceType) override;
192 :
193 : void notifyPlaybackError(MediaSourceType mediaSourceType, PlaybackError error) override;
194 :
195 : void notifySourceFlushed(MediaSourceType mediaSourceType) override;
196 :
197 : void notifyPlaybackInfo(const PlaybackInfo &playbackInfo) override;
198 :
199 : protected:
200 : /**
201 : * @brief The media player client.
202 : */
203 : std::shared_ptr<IMediaPipelineClient> m_mediaPipelineClient;
204 :
205 : /**
206 : * @brief The mainThread object.
207 : */
208 : std::shared_ptr<IMainThread> m_mainThread;
209 :
210 : /**
211 : * @brief The gstreamer player factory object.
212 : */
213 : const std::shared_ptr<IGstGenericPlayerFactory> m_kGstPlayerFactory;
214 :
215 : /**
216 : * @brief The gstreamer player.
217 : */
218 : std::unique_ptr<IGstGenericPlayer> m_gstPlayer;
219 :
220 : /**
221 : * @brief The video decoder requirements for the MediaPipeline session.
222 : */
223 : const VideoRequirements m_kVideoRequirements;
224 :
225 : /**
226 : * @brief ID of a session represented by this MediaPipeline
227 : */
228 : int m_sessionId;
229 :
230 : /**
231 : * @brief Shared memory buffer
232 : */
233 : std::shared_ptr<ISharedMemoryBuffer> m_shmBuffer;
234 :
235 : /**
236 : * @brief DataReader factory
237 : */
238 : std::unique_ptr<IDataReaderFactory> m_dataReaderFactory;
239 :
240 : /**
241 : * @brief Factory creating timers
242 : */
243 : std::shared_ptr<common::ITimerFactory> m_timerFactory;
244 :
245 : /**
246 : * @brief Object containing all active NeedDataRequests
247 : */
248 : std::unique_ptr<IActiveRequests> m_activeRequests;
249 :
250 : /**
251 : * @brief This objects id registered on the main thread
252 : */
253 : uint32_t m_mainThreadClientId;
254 :
255 : /**
256 : * @brief Decryption service
257 : */
258 : IDecryptionService &m_decryptionService;
259 :
260 : /**
261 : * @brief Current playback state
262 : */
263 : PlaybackState m_currentPlaybackState;
264 :
265 : /**
266 : * @brief Map containing scheduled need media data requests.
267 : */
268 : std::unordered_map<MediaSourceType, std::unique_ptr<firebolt::rialto::common::ITimer>> m_needMediaDataTimers;
269 :
270 : /**
271 : * @brief Currently attached sources
272 : */
273 : std::map<MediaSourceType, std::int32_t> m_attachedSources;
274 :
275 : /**
276 : * @brief Map to keep track of the count of MediaSourceStatus with the value NO_AVAILABLE_SAMPLES for each MediaSource
277 : */
278 : std::map<MediaSourceType, unsigned int> m_noAvailableSamplesCounter;
279 :
280 : /**
281 : * @brief Flag used to check if allSourcesAttached was already called
282 : */
283 : bool m_wasAllSourcesAttachedCalled;
284 :
285 : /**
286 : * @brief Flag used to check if low latency is set for video source
287 : */
288 : bool m_IsLowLatencyVideoPlayer{false};
289 :
290 : /**
291 : * @brief Flag used to check if low latency is set for audio source
292 : */
293 : bool m_IsLowLatencyAudioPlayer{false};
294 :
295 : /**
296 : * @brief Map of flags used to check if Eos has been set on the media type for this playback
297 : */
298 : std::map<MediaSourceType, bool> m_isMediaTypeEosMap;
299 :
300 : /**
301 : * @brief Mutex to protect gstPlayer access in getPosition method
302 : */
303 : std::shared_mutex m_getPropertyMutex;
304 :
305 : /**
306 : * @brief Flag to check, if setting volume is in progress
307 : */
308 : std::atomic_bool m_isSetVolumeInProgress{false};
309 :
310 : /**
311 : * @brief Load internally, only to be called on the main thread.
312 : *
313 : * @param[in] type : The media type.
314 : * @param[in] mimeType : The MIME type.
315 : * @param[in] url : The URL.
316 : *
317 : * @retval true on success.
318 : */
319 : bool loadInternal(MediaType type, const std::string &mimeType, const std::string &url);
320 :
321 : /**
322 : * @brief Attach source internally, only to be called on the main thread.
323 : *
324 : * @param[in] source : The source.
325 : *
326 : * @retval true on success.
327 : */
328 : bool attachSourceInternal(const std::unique_ptr<MediaSource> &source);
329 :
330 : /**
331 : * @brief Remove source internally, only to be called on the main thread.
332 : *
333 : * @param[in] id : The source id.
334 : *
335 : * @retval true on success.
336 : */
337 : bool removeSourceInternal(int32_t id);
338 :
339 : /**
340 : * @brief Notify all sources attached internally, only to be called on the main thread.
341 : *
342 : * @retval true on success.
343 : */
344 : bool allSourcesAttachedInternal();
345 :
346 : /**
347 : * @brief Play internally, only to be called on the main thread.
348 : *
349 : * @param[out] async : True if play method call is asynchronous
350 : *
351 : * @retval true on success.
352 : */
353 : bool playInternal(bool &async);
354 :
355 : /**
356 : * @brief Pause internally, only to be called on the main thread.
357 : *
358 : * @retval true on success.
359 : */
360 : bool pauseInternal();
361 :
362 : /**
363 : * @brief Stop internally, only to be called on the main thread.
364 : *
365 : * @retval true on success.
366 : */
367 : bool stopInternal();
368 :
369 : /**
370 : * @brief Set the playback rate internally, only to be called on the main thread.
371 : *
372 : * @param[in] rate : The playback rate.
373 : *
374 : * @retval true on success.
375 : */
376 : bool setPlaybackRateInternal(double rate);
377 :
378 : /**
379 : * @brief Set the position internally, only to be called on the main thread.
380 : *
381 : * @param[in] position : The playback position in nanoseconds.
382 : *
383 : * @retval true on success.
384 : */
385 : bool setPositionInternal(int64_t position);
386 :
387 : /**
388 : * @brief Sets the "Immediate Output" property for this source.
389 : *
390 : * This method is asynchronous
391 : *
392 : * @param[in] sourceId : The source id. Value should be set to the MediaSource.id returned after attachSource()
393 : * @param[in] immediateOutput : The desired immediate output mode on the sink
394 : *
395 : * @retval true on success.
396 : */
397 : bool setImmediateOutputInternal(int32_t sourceId, bool immediateOutput);
398 :
399 : /**
400 : * @brief Gets the "Immediate Output" property for this source.
401 : *
402 : * This method is sychronous
403 : *
404 : * @param[in] sourceId : The source id. Value should be set to the MediaSource.id returned after attachSource()
405 : * @param[out] immediateOutput : Returns the immediate output mode on the sink
406 : *
407 : * @retval true on success.
408 : */
409 : bool getImmediateOutputInternal(int32_t sourceId, bool &immediateOutput);
410 :
411 : /**
412 : * @brief Get stats for this source.
413 : *
414 : * This method is sychronous, it returns dropped frames and rendered frames
415 : *
416 : * @param[in] sourceId : The source id. Value should be set to the MediaSource.id returned after attachSource()
417 : * @param[out] renderedFrames : The number of rendered frames
418 : * @param[out] droppedFrames : The number of dropped frames
419 : *
420 : * @retval true on success.
421 : */
422 : bool getStatsInternal(int32_t sourceId, uint64_t &renderedFrames, uint64_t &droppedFrames);
423 :
424 : /**
425 : * @brief Set video window internally, only to be called on the main thread.
426 : *
427 : * @param[in] x : The x position in pixels.
428 : * @param[in] y : The y position in pixels.
429 : * @param[in] width : The width in pixels.
430 : * @param[in] height : The height in pixels.
431 : *
432 : * @retval true on success.
433 : */
434 : bool setVideoWindowInternal(uint32_t x, uint32_t y, uint32_t width, uint32_t height);
435 :
436 : /**
437 : * @brief Have data internally, only to be called on the main thread.
438 : *
439 : * @param[in] status : The status
440 : * @param[in] needDataRequestId : Need data request id
441 : *
442 : * @retval true on success.
443 : */
444 : bool haveDataInternal(MediaSourceStatus status, uint32_t needDataRequestId);
445 :
446 : /**
447 : * @brief Render frame internally, only to be called on the main thread.
448 : *
449 : * @retval true on success.
450 : */
451 : bool renderFrameInternal();
452 :
453 : /**
454 : * @brief Have data internally, only to be called on the main thread.
455 : *
456 : * @param[in] status : The status
457 : * @param[in] numFrames : The number of frames written.
458 : * @param[in] needDataRequestId : Need data request id
459 : *
460 : * @retval true on success.
461 : */
462 : bool haveDataInternal(MediaSourceStatus status, uint32_t numFrames, uint32_t needDataRequestId);
463 :
464 : /**
465 : * @brief Add segment internally, only to be called on the main thread.
466 : *
467 : * @param[in] needDataRequestId : The status
468 : * @param[in] mediaSegment : The data returned.
469 : *
470 : * @retval status of adding segment
471 : */
472 : AddSegmentStatus addSegmentInternal(uint32_t needDataRequestId, const std::unique_ptr<MediaSegment> &mediaSegment);
473 :
474 : /**
475 : * @brief Notify need media data internally, only to be called on the main thread.
476 : *
477 : * @param[in] mediaSourceType : The media source type.
478 : */
479 : bool notifyNeedMediaDataInternal(MediaSourceType mediaSourceType);
480 :
481 : /**
482 : * @brief Schedules resending of NeedMediaData after a short delay. Used when no segments were received in the
483 : * haveData() call to prevent a storm of needData()/haveData() calls, only to be called on the main thread.
484 : *
485 : * @param[in] mediaSourceType : The media source type.
486 : */
487 : void scheduleNotifyNeedMediaData(MediaSourceType mediaSourceType);
488 :
489 : /**
490 : * @brief Set the target volume level with a transition internally, only to be called on the main thread.
491 : *
492 : * @param[in] targetVolume : Target volume level (0.0 - 1.0)
493 : * @param[in] volumeDuration : Duration of the volume transition in milliseconds
494 : * @param[in] ease_type : Easing type for the volume transition
495 : *
496 : * @retval true on success, false otherwise
497 : */
498 : bool setVolumeInternal(double targetVolume, uint32_t volumeDuration, EaseType easeType);
499 :
500 : /**
501 : * @brief Get the current volume level internally, only to be called on the main thread.
502 : * Fetches the current volume level for the pipeline.
503 : *
504 : * @param[out] currentVolume : Current volume level (range 0.0 - 1.0)
505 : *
506 : * @retval true on success, false otherwise
507 : */
508 : bool getVolumeInternal(double ¤tVolume);
509 :
510 : /**
511 : * @brief Set mute internally, only to be called on the main thread.
512 : *
513 : * @param[in] mute Desired mute state, true=muted, false=not muted
514 : *
515 : * @retval true on success false otherwise
516 : */
517 : bool setMuteInternal(std::int32_t sourceId, bool mute);
518 :
519 : /**
520 : * @brief Get mute internally, only to be called on the main thread.
521 : *
522 : * @param[out] mute Current mute state
523 : *
524 : * @retval true on success false otherwise
525 : */
526 : bool getMuteInternal(std::int32_t sourceId, bool &mute);
527 :
528 : /**
529 : * @brief Change Text Track Identifier
530 : *
531 : * @param[in] textTrackIdentifier Text track identifier of subtitle stream
532 : *
533 : * @retval true on success false otherwise
534 : */
535 : bool setTextTrackIdentifierInternal(const std::string &textTrackIdentifier);
536 :
537 : /**
538 : * @brief Get Text Track Identifier
539 : *
540 : * @param[in] textTrackIdentifier Text track identifier of subtitle stream
541 : *
542 : * @retval true on success false otherwise
543 : */
544 : bool getTextTrackIdentifierInternal(std::string &textTrackIdentifier);
545 :
546 : /**
547 : * @brief Set low latency internally, only to be called on the main thread.
548 : *
549 : * @param[in] lowLatency : The low latency value to set.
550 : *
551 : * @retval true on success false otherwise
552 : */
553 : bool setLowLatencyInternal(bool lowLatency);
554 :
555 : /**
556 : * @brief Set sync internally, only to be called on the main thread.
557 : *
558 : * @param[in] sync : The sync value to set.
559 : *
560 : * @retval true on success false otherwise
561 : */
562 : bool setSyncInternal(bool sync);
563 :
564 : /**
565 : * @brief Get sync internally, only to be called on the main thread.
566 : *
567 : * @param[out] sync : Current sync value.
568 : *
569 : * @retval true on success false otherwise
570 : */
571 : bool getSyncInternal(bool &sync);
572 :
573 : /**
574 : * @brief Set sync off internally, only to be called on the main thread.
575 : *
576 : * @param[in] syncOff : The sync off value to set.
577 : *
578 : * @retval true on success false otherwise
579 : */
580 : bool setSyncOffInternal(bool syncOff);
581 :
582 : /**
583 : * @brief Set stream sync mode internally, only to be called on the main thread.
584 : *
585 : * @param[in] sourceId : The source id. Value should be set to the MediaSource.id returned after attachSource()
586 : * @param[in] streamSyncMode : The stream sync mode value to set.
587 : *
588 : * @retval true on success false otherwise
589 : */
590 : bool setStreamSyncModeInternal(int32_t sourceId, int32_t streamSyncMode);
591 :
592 : /**
593 : * @brief Get stream sync mode internally, only to be called on the main thread.
594 : *
595 : * @param[out] streamSyncMode : Current stream sync mode value.
596 : *
597 : * @retval true on success false otherwise
598 : */
599 : bool getStreamSyncModeInternal(int32_t &streamSyncMode);
600 :
601 : /**
602 : * @brief Checks if MediaPipeline threads are not deadlocked internally
603 : *
604 : * @param[out] heartbeatHandler : The heartbeat handler instance
605 : */
606 : void pingInternal(std::unique_ptr<IHeartbeatHandler> &&heartbeatHandler);
607 :
608 : /**
609 : * @brief Flushes a source.
610 : *
611 : * @param[in] sourceId : The source id. Value should be set to the MediaSource.id returned after attachSource()
612 : * @param[in] resetTime : True if time should be reset
613 : * @param[out] async : True if flushed source is asynchronous (will preroll after flush)
614 : *
615 : * @retval true on success.
616 : */
617 : bool flushInternal(int32_t sourceId, bool resetTime, bool &async);
618 :
619 : /**
620 : * @brief Set the source position in nanoseconds.
621 : *
622 : * This method sets the start position for a source.
623 : *
624 : * @param[in] sourceId : The source id. Value should be set to the MediaSource.id returned after attachSource()
625 : * @param[in] position : The position in nanoseconds.
626 : * @param[in] resetTime : True if time should be reset
627 : * @param[in] appliedRate : The applied rate after seek
628 : * @param[in] stopPosition : The position of last pushed buffer
629 : *
630 : * @retval true on success.
631 : */
632 : bool setSourcePositionInternal(int32_t sourceId, int64_t position, bool resetTime, double appliedRate,
633 : uint64_t stopPosition);
634 :
635 : /**
636 : * @brief Set subtitle offset for a subtitle source.
637 : *
638 : * This method is used to set the subtitle offset for a subtitle source.
639 : *
640 : * @param[in] sourceId : The id of the subtitle source
641 : * @param[in] position : The subtitle offset position in nanoseconds
642 : *
643 : * @retval true on success.
644 : */
645 : bool setSubtitleOffsetInternal(int32_t sourceId, int64_t position);
646 :
647 : /**
648 : * @brief Process audio gap
649 : *
650 : * This method handles audio gap in order to avoid audio pops during transitions.
651 : *
652 : * @param[in] position : Audio pts fade position
653 : * @param[in] duration : Audio pts fade duration
654 : * @param[in] discontinuityGap : Audio discontinuity gap
655 : * @param[in] audioAac : True if audio codec is AAC
656 : *
657 : * @retval true on success.
658 : */
659 : bool processAudioGapInternal(int64_t position, uint32_t duration, int64_t discontinuityGap, bool audioAac);
660 :
661 : /**
662 : * @brief Set buffering limit
663 : *
664 : * This method enables/disables limit buffering and sets millisecond threshold used.
665 : * Use kInvalidLimitBuffering to disable limit buffering
666 : *
667 : * @param[in] limitBufferingMs : buffering limit in ms
668 : *
669 : * @retval true on success.
670 : */
671 : bool setBufferingLimitInternal(uint32_t limitBufferingMs);
672 :
673 : /**
674 : * @brief Get buffering limit
675 : *
676 : * This method returns current value of buffering limit in milliseconds
677 : * Method will return kInvalidLimitBuffering limit buffering is disabled
678 : *
679 : * @param[out] limitBufferingMs : buffering limit in ms
680 : *
681 : * @retval true on success.
682 : */
683 : bool getBufferingLimitInternal(uint32_t &limitBufferingMs);
684 :
685 : /**
686 : * @brief Enables/disables the buffering option
687 : *
688 : * This method enables the buffering option so that BUFFERING messages are
689 : * emitted based on low-/high-percent thresholds.
690 : *
691 : * @param[in] useBuffering : true if buffering option enabled.
692 : *
693 : * @retval true on success.
694 : */
695 : bool setUseBufferingInternal(bool useBuffering);
696 :
697 : /**
698 : * @brief Checks, if buffering is enabled
699 : *
700 : * This method returns true, if buffering is enabled
701 : *
702 : * @param[out] useBuffering : true if buffering option is enabled.
703 : *
704 : * @retval true on success.
705 : */
706 : bool getUseBufferingInternal(bool &useBuffering);
707 :
708 : /**
709 : * @brief Switches a source.
710 : *
711 : * @param[in] mediaSource : The media source.
712 : *
713 : */
714 : bool switchSourceInternal(const std::unique_ptr<MediaSource> &source);
715 :
716 : /**
717 : * @brief Returns how long should we wait to send next NeedMediaData
718 : * if rialto client returns NO_AVAILABLE_SAMPLES
719 : *
720 : * @param[in] mediaSourceType : The media source type.
721 : *
722 : * @retval NeedMediaData timeout
723 : */
724 : std::chrono::milliseconds getNeedMediaDataTimeout(MediaSourceType mediaSourceType) const;
725 : };
726 :
727 : }; // namespace firebolt::rialto::server
728 :
729 : #endif // FIREBOLT_RIALTO_SERVER_MEDIA_PIPELINE_SERVER_INTERNAL_H_
|