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