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

Generated by: LCOV version 2.0-1