LCOV - code coverage report
Current view: top level - media/server/gstplayer/interface - IGstGenericPlayer.h (source / functions) Coverage Total Hit
Test: coverage.info Lines: 100.0 % 4 4
Test Date: 2026-07-31 13:30:47 Functions: 100.0 % 4 4

            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_I_GST_GENERIC_PLAYER_H_
      21              : #define FIREBOLT_RIALTO_SERVER_I_GST_GENERIC_PLAYER_H_
      22              : 
      23              : #include <MediaCommon.h>
      24              : #include <memory>
      25              : #include <stdint.h>
      26              : #include <string>
      27              : 
      28              : #include "IDataReader.h"
      29              : #include "IDecryptionService.h"
      30              : #include "IGstGenericPlayerClient.h"
      31              : #include "IGstProfiler.h"
      32              : #include "IHeartbeatHandler.h"
      33              : #include "IMediaPipeline.h"
      34              : #include "IRdkGstreamerUtilsWrapper.h"
      35              : 
      36              : namespace firebolt::rialto::server
      37              : {
      38              : class IGstGenericPlayer;
      39              : 
      40              : /**
      41              :  * @brief IGstGenericPlayer factory class, returns a concrete implementation of IGstGenericPlayer
      42              :  */
      43              : class IGstGenericPlayerFactory
      44              : {
      45              : public:
      46          169 :     IGstGenericPlayerFactory() = default;
      47          169 :     virtual ~IGstGenericPlayerFactory() = default;
      48              : 
      49              :     /**
      50              :      * @brief Gets the IGstGenericPlayerFactory instance.
      51              :      *
      52              :      * @retval the factory instance or null on error.
      53              :      */
      54              :     static std::shared_ptr<IGstGenericPlayerFactory> getFactory();
      55              : 
      56              :     /**
      57              :      * @brief Creates an IGstGenericPlayer object.
      58              :      *
      59              :      * @param[in] client                       : The gstreamer player client.
      60              :      * @param[in] decryptionService            : The decryption service.
      61              :      * @param[in] type                         : The media type the gstreamer player shall support.
      62              :      * @param[in] videoRequirements            : The video requirements for the playback.
      63              :      * @param[in] isLive                       : Indicates if the media is live.
      64              :      * @param[in] rdkGstreamerUtilsWrapperFactory : The rdk gstreamer utils wrapper factory.
      65              :      * @param[in] gstProfilerFactory           : The gst profiler factory. Defaults to nullptr; when null, the
      66              :      *                                                concrete factory falls back to IGstProfilerFactory::getFactory().
      67              :      *                                                This avoids evaluating the real singleton at mocked call sites.
      68              :      *
      69              :      * @retval the new player instance or null on error.
      70              :      */
      71              :     virtual std::unique_ptr<IGstGenericPlayer> createGstGenericPlayer(
      72              :         IGstGenericPlayerClient *client, IDecryptionService &decryptionService, MediaType type,
      73              :         const VideoRequirements &videoRequirements, bool isLive,
      74              :         const std::shared_ptr<firebolt::rialto::wrappers::IRdkGstreamerUtilsWrapperFactory> &rdkGstreamerUtilsWrapperFactory,
      75              :         const std::shared_ptr<IGstProfilerFactory> &gstProfilerFactory = nullptr) = 0;
      76              : };
      77              : 
      78              : class IGstGenericPlayer
      79              : {
      80              : public:
      81          402 :     IGstGenericPlayer() = default;
      82          402 :     virtual ~IGstGenericPlayer() = default;
      83              : 
      84              :     IGstGenericPlayer(const IGstGenericPlayer &) = delete;
      85              :     IGstGenericPlayer &operator=(const IGstGenericPlayer &) = delete;
      86              :     IGstGenericPlayer(IGstGenericPlayer &&) = delete;
      87              :     IGstGenericPlayer &operator=(IGstGenericPlayer &&) = delete;
      88              : 
      89              :     /**
      90              :      * @brief Attaches a source to gstreamer.
      91              :      *
      92              :      * @param[in] mediaSource : The media source.
      93              :      *
      94              :      */
      95              :     virtual void attachSource(const std::unique_ptr<IMediaPipeline::MediaSource> &mediaSource) = 0;
      96              : 
      97              :     /**
      98              :      * @brief Removes a source from gstreamer.
      99              :      *
     100              :      * @param[in] mediaSourceType : The media source type.
     101              :      *
     102              :      */
     103              :     virtual void removeSource(const MediaSourceType &mediaSourceType) = 0;
     104              : 
     105              :     /**
     106              :      * @brief Handles notification that all sources were attached
     107              :      *
     108              :      */
     109              :     virtual void allSourcesAttached() = 0;
     110              : 
     111              :     /**
     112              :      * @brief Starts playback of the media.
     113              :      *
     114              :      * Once the backend is successfully playing it should notify the
     115              :      * media player client of playback state
     116              :      * IMediaPipelineClient::PlaybackState::PLAYING.
     117              :      *
     118              :      * @param[out] async     : True if play method call is asynchronous
     119              :      *
     120              :      * @retval true on success.
     121              :      */
     122              :     virtual void play(bool &async) = 0;
     123              : 
     124              :     /**
     125              :      * @brief Pauses playback of the media.
     126              :      *
     127              :      * This method is considered to be asynchronous and MUST NOT block
     128              :      * but should request the playback pause and then return.
     129              :      *
     130              :      * Once the backend is successfully paused it should notify the
     131              :      * media player client of playback state PlaybackState::PAUSED.
     132              :      *
     133              :      */
     134              :     virtual void pause() = 0;
     135              : 
     136              :     /**
     137              :      * @brief Stops playback of the media.
     138              :      *
     139              :      * This method is considered to be asynchronous and MUST NOT block
     140              :      * but should request the playback stop and then return.
     141              :      *
     142              :      * Once the backend is successfully stopped it should notify the
     143              :      * media player client of playback state PlaybackState::STOPPED.
     144              :      *
     145              :      */
     146              :     virtual void stop() = 0;
     147              : 
     148              :     /**
     149              :      * @brief Sets video geometry
     150              :      *
     151              :      * @param[in] x      : X position of rectangle on video
     152              :      * @param[in] y      : Y position of rectangle on video
     153              :      * @param[in] width  : width of rectangle
     154              :      * @param[in] height : height of rectangle
     155              :      *
     156              :      */
     157              :     virtual void setVideoGeometry(int x, int y, int width, int height) = 0;
     158              : 
     159              :     /**
     160              :      * @brief Queues the end of stream notification at the end of the gstreamer buffers.
     161              :      *
     162              :      * @param[in] type : the media source type to set eos
     163              :      *
     164              :      */
     165              :     virtual void setEos(const firebolt::rialto::MediaSourceType &type) = 0;
     166              : 
     167              :     /**
     168              :      * @brief Attaches new samples
     169              :      *
     170              :      * This method is considered to be asynchronous and MUST NOT block
     171              :      * but should request to attach new sample and then return.
     172              :      */
     173              :     virtual void attachSamples(const IMediaPipeline::MediaSegmentVector &mediaSegments) = 0;
     174              : 
     175              :     /**
     176              :      * @brief Attaches new samples
     177              :      *
     178              :      * This method is considered to be asynchronous and MUST NOT block
     179              :      * but should request to attach new sample and then return.
     180              :      */
     181              :     virtual void attachSamples(const std::shared_ptr<IDataReader> &dataReader) = 0;
     182              : 
     183              :     /**
     184              :      * @brief Set the playback position in nanoseconds.
     185              :      *
     186              :      * If playback has not started this method sets the start position
     187              :      * for playback. If playback has started this method performs a seek.
     188              :      *
     189              :      * @param[in] position : The playback position in nanoseconds.
     190              :      *
     191              :      */
     192              :     virtual void setPosition(std::int64_t position) = 0;
     193              : 
     194              :     /**
     195              :      * @brief Get the playback position in nanoseconds.
     196              :      *
     197              :      * @param[out] position : The playback position in nanoseconds.
     198              :      *
     199              :      * @retval True on success
     200              :      */
     201              :     virtual bool getPosition(std::int64_t &position) = 0;
     202              : 
     203              :     /**
     204              :      * @brief Get the playback duration in nanoseconds.
     205              :      *
     206              :      * @param[out] duration : The playback duration in nanoseconds.
     207              :      *
     208              :      * @retval True on success
     209              :      */
     210              :     virtual bool getDuration(std::int64_t &duration) = 0;
     211              : 
     212              :     /**
     213              :      * @brief Sets the "Immediate Output" property for this source.
     214              :      *
     215              :      * @param[in] mediaSourceType : The media source type
     216              :      * @param[in] immediateOutput : Set immediate output mode on the sink
     217              :      *
     218              :      * @retval true on success.
     219              :      */
     220              :     virtual bool setImmediateOutput(const MediaSourceType &mediaSourceType, bool immediateOutput) = 0;
     221              : 
     222              :     /**
     223              :      * @brief Sets the "Report Decode Error" property for this source.
     224              :      *
     225              :      * @param[in] mediaSourceType : The media source type
     226              :      * @param[in] reportDecodeErrors : Set report decode error
     227              :      *
     228              :      * @retval true on success.
     229              :      */
     230              :     virtual bool setReportDecodeErrors(const MediaSourceType &mediaSourceType, bool reportDecodeErrors) = 0;
     231              : 
     232              :     /**
     233              :      * @brief Gets the queued frames for this source.
     234              :      *
     235              :      * @param[out] queuedFrames : Get queued frames mode on the decoder
     236              :      *
     237              :      * @retval true on success.
     238              :      */
     239              :     virtual bool getQueuedFrames(uint32_t &queuedFrames) = 0;
     240              : 
     241              :     /**
     242              :      * @brief Gets the "Immediate Output" property for this source.
     243              :      *
     244              :      * @param[in] mediaSourceType : The media source type
     245              :      * @param[out] immediateOutput : Get immediate output mode on the sink
     246              :      *
     247              :      * @retval true on success.
     248              :      */
     249              :     virtual bool getImmediateOutput(const MediaSourceType &mediaSourceType, bool &immediateOutput) = 0;
     250              : 
     251              :     /**
     252              :      * @brief Get stats for this source.
     253              :      *
     254              :      * @param[in] mediaSourceType : The media source type to get stats for
     255              :      * @param[out] renderedFrames : The number of rendered frames
     256              :      * @param[out] droppedFrames : The number of dropped frames
     257              :      *
     258              :      * @retval true on success.
     259              :      */
     260              :     virtual bool getStats(const MediaSourceType &mediaSourceType, uint64_t &renderedFrames, uint64_t &droppedFrames) = 0;
     261              : 
     262              :     /**
     263              :      * @brief Set the playback rate.
     264              :      *
     265              :      * @param[in] rate : The playback rate.
     266              :      *
     267              :      */
     268              :     virtual void setPlaybackRate(double rate) = 0;
     269              : 
     270              :     /**
     271              :      * @brief Requests to render a prerolled frame
     272              :      *
     273              :      */
     274              :     virtual void renderFrame() = 0;
     275              : 
     276              :     /**
     277              :      * @brief Set level and transition of audio attenuation.
     278              :      *        Sets the current volume for the pipeline (0.0 silent -> 1.0 full volume)
     279              :      *
     280              :      * @param[in] volume : Target volume level (0.0 - 1.0)
     281              :      */
     282              :     virtual void setVolume(double targetVolume, uint32_t volumeDuration, firebolt::rialto::EaseType easeType) = 0;
     283              : 
     284              :     /**
     285              :      * @brief Get current audio level. Fetches the current volume level for the pipeline.
     286              :      *
     287              :      * @param[out] volume : Current volume level (range 0.0 - 1.0)
     288              :      *
     289              :      * @retval True on success
     290              :      */
     291              :     virtual bool getVolume(double &volume) = 0;
     292              : 
     293              :     /**
     294              :      * @brief Set mute status of pipeline
     295              :      *
     296              :      * Muting does not change the underlying volyme setting so when
     297              :      * unmuted the user will hear audio at the same volume as previously
     298              :      * set.
     299              :      *
     300              :      * @param[in] mute : Desired mute state, true=muted, false=not muted
     301              :      */
     302              :     virtual void setMute(const MediaSourceType &mediaSourceType, bool mute) = 0;
     303              : 
     304              :     /**
     305              :      * @brief Get current mute status of the pipeline
     306              :      *
     307              :      * @param[out] mute : Current mute state
     308              :      *
     309              :      * @retval True in success, false otherwise
     310              :      */
     311              :     virtual bool getMute(const MediaSourceType &mediaSourceType, bool &mute) = 0;
     312              : 
     313              :     /**
     314              :      * @brief Change Text Track Identifier
     315              :      *
     316              :      * @param[in] textTrackIdentifier Text track identifier of subtitle stream
     317              :      *
     318              :      * @retval true on success false otherwise
     319              :      */
     320              :     virtual void setTextTrackIdentifier(const std::string &textTrackIdentifier) = 0;
     321              : 
     322              :     /**
     323              :      * @brief Get Text Track Identifier
     324              :      *
     325              :      * @param[in] textTrackIdentifier Text track identifier of subtitle stream
     326              :      *
     327              :      * @retval true on success false otherwise
     328              :      */
     329              :     virtual bool getTextTrackIdentifier(std::string &textTrackIdentifier) = 0;
     330              : 
     331              :     /**
     332              :      * @brief Set low latency property on the pipeline. Default false.
     333              :      *
     334              :      * @param[in] lowLatency : The low latency value to set.
     335              :      *
     336              :      * @retval true on success false otherwise
     337              :      */
     338              :     virtual bool setLowLatency(bool lowLatency) = 0;
     339              : 
     340              :     /**
     341              :      * @brief Set sync property on the pipeline. Default false.
     342              :      *
     343              :      * @param[in] sync : The sync value to set.
     344              :      *
     345              :      * @retval true on success false otherwise
     346              :      */
     347              :     virtual bool setSync(bool sync) = 0;
     348              : 
     349              :     /**
     350              :      * @brief Get sync property on the pipeline.
     351              :      *
     352              :      * @param[out] sync : Current sync value.
     353              :      *
     354              :      * @retval true on success false otherwise
     355              :      */
     356              :     virtual bool getSync(bool &sync) = 0;
     357              : 
     358              :     /**
     359              :      * @brief Set sync off property on the pipeline. Default false.
     360              :      *
     361              :      * @param[in] syncOff : The sync off value to set.
     362              :      *
     363              :      * @retval true on success false otherwise
     364              :      */
     365              :     virtual bool setSyncOff(bool syncOff) = 0;
     366              : 
     367              :     /**
     368              :      * @brief Set stream sync mode property on the pipeline. Default 0.
     369              :      *
     370              :      * @param[in] mediaSourceType : The media source type to set stream sync mode.
     371              :      * @param[in] streamSyncMode : The stream sync mode value to set.
     372              :      *
     373              :      * @retval true on success false otherwise
     374              :      */
     375              :     virtual bool setStreamSyncMode(const MediaSourceType &mediaSourceType, int32_t streamSyncMode) = 0;
     376              : 
     377              :     /**
     378              :      * @brief Get stream sync mode property on the pipeline.
     379              :      *
     380              :      * @param[out] streamSyncMode : Current stream sync mode value.
     381              :      *
     382              :      * @retval true on success false otherwise
     383              :      */
     384              :     virtual bool getStreamSyncMode(int32_t &streamSyncMode) = 0;
     385              : 
     386              :     /**
     387              :      * @brief Checks if worker thread is not deadlocked
     388              :      *
     389              :      * @param[out] heartbeatHandler : The heartbeat handler instance
     390              :      *
     391              :      */
     392              :     virtual void ping(std::unique_ptr<IHeartbeatHandler> &&heartbeatHandler) = 0;
     393              : 
     394              :     /**
     395              :      * @brief Flushes a source.
     396              :      *
     397              :      * @param[in] mediaSourceType : The media source type to flush.
     398              :      * @param[in] resetTime : True if time should be reset
     399              :      * @param[out] async     : True if flushed source is asynchronous (will preroll after flush)
     400              :      *
     401              :      */
     402              :     virtual void flush(const MediaSourceType &mediaSourceType, bool resetTime, bool &async) = 0;
     403              : 
     404              :     /**
     405              :      * @brief Set the source position in nanoseconds.
     406              :      *
     407              :      * This method sets the start position for a source.
     408              :      *
     409              :      * @param[in] mediaSourceType : The media source type to flush.
     410              :      * @param[in] position : The position in nanoseconds.
     411              :      * @param[in] resetTime : True if time should be reset
     412              :      * @param[in] appliedRate : The applied rate after seek
     413              :      * @param[in] stopPosition : The position of last pushed buffer
     414              :      */
     415              :     virtual void setSourcePosition(const MediaSourceType &mediaSourceType, int64_t position, bool resetTime,
     416              :                                    double appliedRate, uint64_t stopPosition) = 0;
     417              : 
     418              :     /**
     419              :      * @brief Sets the subtitle offset.
     420              :      *
     421              :      * This method sets the subtitle offset to synchronize subtitle timing.
     422              :      *
     423              :      * @param[in] position : The subtitle offset position in nanoseconds.
     424              :      */
     425              :     virtual void setSubtitleOffset(int64_t position) = 0;
     426              : 
     427              :     /**
     428              :      * @brief Process audio gap
     429              :      *
     430              :      * This method handles audio gap in order to avoid audio pops during transitions.
     431              :      *
     432              :      * @param[in] position         : Audio pts fade position value
     433              :      * @param[in] duration         : Audio pts fade duration
     434              :      * @param[in] discontinuityGap : Audio discontinuity gap
     435              :      * @param[in] audioAac         : True if audio codec is AAC
     436              :      */
     437              :     virtual void processAudioGap(int64_t position, uint32_t duration, int64_t discontinuityGap, bool audioAac) = 0;
     438              : 
     439              :     /**
     440              :      * @brief Set buffering limit
     441              :      *
     442              :      * This method enables/disables limit buffering and sets millisecond threshold used.
     443              :      * Use kInvalidLimitBuffering to disable limit buffering
     444              :      *
     445              :      * @param[in] limitBufferingMs         : buffering limit in ms
     446              :      *
     447              :      */
     448              :     virtual void setBufferingLimit(uint32_t limitBufferingMs) = 0;
     449              : 
     450              :     /**
     451              :      * @brief Get buffering limit
     452              :      *
     453              :      * This method returns current value of buffering limit in milliseconds
     454              :      * Method will return kInvalidLimitBuffering limit buffering is disabled
     455              :      *
     456              :      * @param[out] limitBufferingMs         : buffering limit in ms
     457              :      *
     458              :      * @retval true on success.
     459              :      */
     460              :     virtual bool getBufferingLimit(uint32_t &limitBufferingMs) = 0;
     461              : 
     462              :     /**
     463              :      * @brief Enables/disables the buffering option
     464              :      *
     465              :      * This method enables the buffering option so that BUFFERING messages are
     466              :      * emitted based on low-/high-percent thresholds.
     467              :      *
     468              :      * @param[in] useBuffering         : true if buffering option enabled.
     469              :      *
     470              :      */
     471              :     virtual void setUseBuffering(bool useBuffering) = 0;
     472              : 
     473              :     /**
     474              :      * @brief Checks, if buffering is enabled
     475              :      *
     476              :      * This method returns true, if buffering is enabled
     477              :      *
     478              :      * @param[out] useBuffering         : true if buffering option is enabled.
     479              :      *
     480              :      * @retval true on success.
     481              :      */
     482              :     virtual bool getUseBuffering(bool &useBuffering) = 0;
     483              : 
     484              :     /**
     485              :      * @brief Switches a source.
     486              :      *
     487              :      * @param[in] mediaSource : The media source.
     488              :      *
     489              :      */
     490              :     virtual void switchSource(const std::unique_ptr<IMediaPipeline::MediaSource> &mediaSource) = 0;
     491              : };
     492              : 
     493              : }; // namespace firebolt::rialto::server
     494              : 
     495              : #endif // FIREBOLT_RIALTO_SERVER_I_GST_GENERIC_PLAYER_H_
        

Generated by: LCOV version 2.0-1