LCOV - code coverage report
Current view: top level - media/server/main/include - MediaPipelineServerInternal.h (source / functions) Coverage Total Hit
Test: coverage.info Lines: 100.0 % 2 2
Test Date: 2026-03-04 13:20:25 Functions: 100.0 % 2 2

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

Generated by: LCOV version 2.0-1