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

Generated by: LCOV version 2.0-1