LCOV - code coverage report
Current view: top level - media/client/ipc/interface - IMediaPipelineIpc.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_CLIENT_I_MEDIA_PIPELINE_IPC_H_
      21              : #define FIREBOLT_RIALTO_CLIENT_I_MEDIA_PIPELINE_IPC_H_
      22              : 
      23              : #include <stdint.h>
      24              : 
      25              : #include <memory>
      26              : #include <string>
      27              : 
      28              : #include "IMediaPipeline.h"
      29              : #include "IMediaPipelineIpcClient.h"
      30              : #include "MediaCommon.h"
      31              : 
      32              : namespace firebolt::rialto::client
      33              : {
      34              : class IMediaPipelineIpc;
      35              : class IIpcClient;
      36              : 
      37              : /**
      38              :  * @brief IMediaPipelineIpc factory class, returns a concrete implementation of IMediaPipelineIpc
      39              :  */
      40              : class IMediaPipelineIpcFactory
      41              : {
      42              : public:
      43          121 :     IMediaPipelineIpcFactory() = default;
      44          121 :     virtual ~IMediaPipelineIpcFactory() = default;
      45              : 
      46              :     /**
      47              :      * @brief Gets the IMediaPipelineIpcFactory instance.
      48              :      *
      49              :      * @retval the factory instance or null on error.
      50              :      */
      51              :     static std::shared_ptr<IMediaPipelineIpcFactory> getFactory();
      52              : 
      53              :     /**
      54              :      * @brief Creates a IMediaPipelineIpc object.
      55              :      *
      56              :      * @param[in] client            : The Rialto ipc media player client.
      57              :      * @param[in] videoRequirements : The video decoder requirements for the MediaPipeline session.
      58              :      *
      59              :      * @retval the new media player ipc instance or null on error.
      60              :      */
      61              :     virtual std::unique_ptr<IMediaPipelineIpc> createMediaPipelineIpc(IMediaPipelineIpcClient *client,
      62              :                                                                       const VideoRequirements &videoRequirements,
      63              :                                                                       std::weak_ptr<IIpcClient> ipcClient = {}) = 0;
      64              : };
      65              : 
      66              : /**
      67              :  * @brief The definition of the IMediaPipelineIpc interface.
      68              :  *
      69              :  * This interface defines the media player ipc APIs that are used to communicate with the Rialto server.
      70              :  */
      71              : class IMediaPipelineIpc
      72              : {
      73              : public:
      74          299 :     IMediaPipelineIpc() = default;
      75          299 :     virtual ~IMediaPipelineIpc() = default;
      76              : 
      77              :     IMediaPipelineIpc(const IMediaPipelineIpc &) = delete;
      78              :     IMediaPipelineIpc &operator=(const IMediaPipelineIpc &) = delete;
      79              :     IMediaPipelineIpc(IMediaPipelineIpc &&) = delete;
      80              :     IMediaPipelineIpc &operator=(IMediaPipelineIpc &&) = delete;
      81              : 
      82              :     /**
      83              :      * @brief Request to attach the source to the server backend.
      84              :      *
      85              :      * @param[in] source    : The source.
      86              :      * @param[out] sourceId : The unique id of the media source.
      87              :      *
      88              :      * @retval true on success.
      89              :      */
      90              :     virtual bool attachSource(const std::unique_ptr<IMediaPipeline::MediaSource> &source, int32_t &sourceId) = 0;
      91              : 
      92              :     /**
      93              :      * @brief Request to remove the source to the server backend.
      94              :      *
      95              :      * @param[in] sourceId : The unique id of the media source.
      96              :      *
      97              :      * @retval true on success.
      98              :      */
      99              :     virtual bool removeSource(int32_t sourceId) = 0;
     100              : 
     101              :     virtual bool allSourcesAttached() = 0;
     102              : 
     103              :     /**
     104              :      * @brief Request to load the media pipeline.
     105              :      *
     106              :      * @param[in] type     : The media type.
     107              :      * @param[in] mimeType : The MIME type.
     108              :      * @param[in] url      : The URL.
     109              :      * @param[in] isLive   : Indicates if the media is live.
     110              :      *
     111              :      * @retval true on success.
     112              :      */
     113              :     virtual bool load(MediaType type, const std::string &mimeType, const std::string &url, bool isLive) = 0;
     114              : 
     115              :     /**
     116              :      * @brief Request to set the coordinates of the video window.
     117              :      *
     118              :      * @param[in] x      : The x position in pixels.
     119              :      * @param[in] y      : The y position in pixels.
     120              :      * @param[in] width  : The width in pixels.
     121              :      * @param[in] height : The height in pixels.
     122              :      *
     123              :      * @retval true on success.
     124              :      */
     125              :     virtual bool setVideoWindow(uint32_t x, uint32_t y, uint32_t width, uint32_t height) = 0;
     126              : 
     127              :     /**
     128              :      * @brief Request play on the playback session.
     129              :      *
     130              :      * @param[out] async     : True if play method call is asynchronous
     131              :      *
     132              :      * @retval true on success.
     133              :      */
     134              :     virtual bool play(bool &async) = 0;
     135              : 
     136              :     /**
     137              :      * @brief Request pause on the playback session.
     138              :      *
     139              :      * @retval true on success.
     140              :      */
     141              :     virtual bool pause() = 0;
     142              : 
     143              :     /**
     144              :      * @brief Request stop on the playback session.
     145              :      *
     146              :      * @retval true on success.
     147              :      */
     148              :     virtual bool stop() = 0;
     149              : 
     150              :     /**
     151              :      * @brief Notify server that the data has been written to the shared memory.
     152              :      *
     153              :      * @param[in] status    : The status.
     154              :      * @param[in] requestId : The Need data request id.
     155              :      *
     156              :      * @retval true on success.
     157              :      */
     158              :     virtual bool haveData(MediaSourceStatus status, uint32_t numFrames, uint32_t requestId) = 0;
     159              : 
     160              :     /**
     161              :      * @brief Request new playback position.
     162              :      *
     163              :      * @param[in] position : The playback position in nanoseconds.
     164              :      *
     165              :      * @retval true on success.
     166              :      */
     167              :     virtual bool setPosition(int64_t position) = 0;
     168              : 
     169              :     /**
     170              :      * @brief Get the playback position in nanoseconds.
     171              :      *
     172              :      * This method is sychronous, it returns current playback position
     173              :      *
     174              :      * @param[out] position : The playback position in nanoseconds
     175              :      *
     176              :      * @retval true on success.
     177              :      */
     178              :     virtual bool getPosition(int64_t &position) = 0;
     179              : 
     180              :     /**
     181              :      * @brief Sets the "Immediate Output" property for this source.
     182              :      *
     183              :      * This method is asynchronous
     184              :      *
     185              :      * @param[in] sourceId : The source id. Value should be set to the MediaSource.id returned after attachSource()
     186              :      * @param[in] immediateOutput : The desired immediate output mode on the sink
     187              :      *
     188              :      * @retval true on success.
     189              :      */
     190              :     virtual bool setImmediateOutput(int32_t sourceId, bool immediateOutput) = 0;
     191              : 
     192              :     /**
     193              :      * @brief Gets the "Immediate Output" property for this source.
     194              :      *
     195              :      * This method is sychronous
     196              :      *
     197              :      * @param[in] sourceId : The source id. Value should be set to the MediaSource.id returned after attachSource()
     198              :      * @param[out] immediateOutput : Returns the immediate output mode of the sink
     199              :      *
     200              :      * @retval true on success.
     201              :      */
     202              :     virtual bool getImmediateOutput(int32_t sourceId, bool &immediateOutput) = 0;
     203              : 
     204              :     /**
     205              :      * @brief Get stats for this source.
     206              :      *
     207              :      * This method is sychronous, it returns dropped frames and rendered frames
     208              :      *
     209              :      * @param[in] sourceId : The source id. Value should be set to the MediaSource.id returned after attachSource()
     210              :      * @param[out] droppedFrames : The number of dropped frames
     211              :      * @param[out] renderedFrames : The number of rendered frames
     212              :      *
     213              :      * @retval true on success.
     214              :      */
     215              :     virtual bool getStats(int32_t sourceId, uint64_t &renderedFrames, uint64_t &droppedFrames) = 0;
     216              : 
     217              :     /**
     218              :      * @brief Request new playback rate.
     219              :      *
     220              :      * @param[in] rate : The playback rate.
     221              :      *
     222              :      * @retval true on success.
     223              :      */
     224              :     virtual bool setPlaybackRate(double rate) = 0;
     225              : 
     226              :     /**
     227              :      * @brief Requests to render a prerolled frame
     228              :      */
     229              :     virtual bool renderFrame() = 0;
     230              : 
     231              :     /**
     232              :      * @brief Set level and transition of audio attenuation.
     233              :      *        Sets the current volume for the pipeline (0.0 silent -> 1.0 full volume)
     234              :      *
     235              :      * @param[in] targetVolume : Target volume level (0.0 - 1.0)
     236              :      * @param[in] volumeDuration : Duration of the volume transition in milliseconds
     237              :      * @param[in] ease_type : Easing type for the volume transition
     238              :      *
     239              :      * @retval true on success false otherwise
     240              :      */
     241              :     virtual bool setVolume(double targetVolume, uint32_t volumeDuration, EaseType easeType) = 0;
     242              : 
     243              :     /**
     244              :      * @brief Get current audio level. Fetches the current volume level for the pipeline.
     245              :      *
     246              :      * @param[out] volume Current volume level (range 0.0 - 1.0)
     247              :      *
     248              :      * @retval true on success false otherwise
     249              :      */
     250              :     virtual bool getVolume(double &volume) = 0;
     251              : 
     252              :     /**
     253              :      * @brief Set mute status of pipeline.
     254              :      *
     255              :      * Change mute status of media source
     256              :      *
     257              :      * @param[in] sourceId Source, which mute status should be changed
     258              :      * @param[in] mute   Desired mute state, true=muted, false=not muted
     259              :      *
     260              :      * @retval true on success false otherwise
     261              :      */
     262              :     virtual bool setMute(int32_t sourceId, bool mute) = 0;
     263              : 
     264              :     /**
     265              :      * @brief Get current mute status of the media source
     266              :      *
     267              :      * @param[in] sourceId Source, which mute status should be fetched
     268              :      * @param[out] mute   Current mute state
     269              :      *
     270              :      * @retval true on success false otherwise
     271              :      */
     272              :     virtual bool getMute(int32_t sourceId, bool &mute) = 0;
     273              : 
     274              :     /**
     275              :      * @brief Change Text Track Identifier
     276              :      *
     277              :      * @param[in] textTrackIdentifier Text track identifier of subtitle stream
     278              :      *
     279              :      * @retval true on success false otherwise
     280              :      */
     281              :     virtual bool setTextTrackIdentifier(const std::string &textTrackIdentifier) = 0;
     282              : 
     283              :     /**
     284              :      * @brief Get Text Track Identifier
     285              :      *
     286              :      * @param[in] textTrackIdentifier Text track identifier of subtitle stream
     287              :      *
     288              :      * @retval true on success false otherwise
     289              :      */
     290              :     virtual bool getTextTrackIdentifier(std::string &textTrackIdentifier) = 0;
     291              : 
     292              :     /**
     293              :      * @brief Set low latency property on the pipeline. Default false.
     294              :      *
     295              :      * @param[in] lowLatency : The low latency value to set.
     296              :      *
     297              :      * @retval true on success false otherwise
     298              :      */
     299              :     virtual bool setLowLatency(bool lowLatency) = 0;
     300              : 
     301              :     /**
     302              :      * @brief Set sync property on the pipeline. Default false.
     303              :      *
     304              :      * @param[in] sync : The sync value to set.
     305              :      *
     306              :      * @retval true on success false otherwise
     307              :      */
     308              :     virtual bool setSync(bool sync) = 0;
     309              : 
     310              :     /**
     311              :      * @brief Get sync property on the pipeline.
     312              :      *
     313              :      * @param[out] sync : Current sync value.
     314              :      *
     315              :      * @retval true on success false otherwise
     316              :      */
     317              :     virtual bool getSync(bool &sync) = 0;
     318              : 
     319              :     /**
     320              :      * @brief Set sync off property on the pipeline. Default false.
     321              :      *
     322              :      * @param[in] syncOff : The sync off value to set.
     323              :      *
     324              :      * @retval true on success false otherwise
     325              :      */
     326              :     virtual bool setSyncOff(bool syncOff) = 0;
     327              : 
     328              :     /**
     329              :      * @brief Set stream sync mode property on the pipeline. Default 0.
     330              :      *
     331              :      * @param[in] sourceId  : The source id. Value should be set to the MediaSource.id returned after attachSource()
     332              :      * @param[in] streamSyncMode : The stream sync mode value to set.
     333              :      *
     334              :      * @retval true on success false otherwise
     335              :      */
     336              :     virtual bool setStreamSyncMode(int32_t sourceId, int32_t streamSyncMode) = 0;
     337              : 
     338              :     /**
     339              :      * @brief Get stream sync mode property on the pipeline.
     340              :      *
     341              :      * @param[out] streamSyncMode : Current stream sync mode value.
     342              :      *
     343              :      * @retval true on success false otherwise
     344              :      */
     345              :     virtual bool getStreamSyncMode(int32_t &streamSyncMode) = 0;
     346              : 
     347              :     /**
     348              :      * @brief Flushes a source.
     349              :      *
     350              :      * This method is called by Rialto Client to flush out all queued data for a media source stream.
     351              :      *
     352              :      * @param[in]  sourceId  : The source id. Value should be set to the MediaSource.id returned after attachSource()
     353              :      * @param[in]  resetTime : True if time should be reset
     354              :      * @param[out] async     : True if flushed source is asynchronous (will preroll after flush)
     355              :      *
     356              :      * @retval true on success.
     357              :      */
     358              :     virtual bool flush(int32_t sourceId, bool resetTime, bool &async) = 0;
     359              : 
     360              :     /**
     361              :      * @brief Set the source position in nanoseconds.
     362              :      *
     363              :      * This method sets the start position for a source.
     364              :      *
     365              :      * @param[in] sourceId    : The source id. Value should be set to the MediaSource.id returned after attachSource()
     366              :      * @param[in] position    : The position in nanoseconds.
     367              :      * @param[in] resetTime   : True if time should be reset
     368              :      * @param[in] appliedRate : The applied rate after seek
     369              :      * @param[in] stopPosition : The position of last pushed buffer
     370              :      *
     371              :      * @retval true on success.
     372              :      */
     373              :     virtual bool setSourcePosition(int32_t sourceId, int64_t position, bool resetTime, double appliedRate,
     374              :                                    uint64_t stopPosition) = 0;
     375              : 
     376              :     /**
     377              :      * @brief Set the subtitle offset in nanoseconds.
     378              :      *
     379              :      * This method sets the subtitle offset for a subtitle source.
     380              :      *
     381              :      * @param[in] sourceId : The source id. Value should be set to the MediaSource.id returned after attachSource()
     382              :      * @param[in] position : The offset position in nanoseconds.
     383              :      *
     384              :      * @retval true on success.
     385              :      */
     386              :     virtual bool setSubtitleOffset(int32_t sourceId, int64_t position) = 0;
     387              : 
     388              :     /**
     389              :      * @brief Process audio gap
     390              :      *
     391              :      * This method handles audio gap in order to avoid audio pops during transitions.
     392              :      *
     393              :      * @param[in] position         : Audio pts fade pts value
     394              :      * @param[in] duration         : Audio pts fade duration
     395              :      * @param[in] discontinuityGap : Audio discontinuity gap
     396              :      * @param[in] audioAac         : True if audio codec is AAC
     397              :      *
     398              :      * @retval true on success.
     399              :      */
     400              :     virtual bool processAudioGap(int64_t position, uint32_t duration, int64_t discontinuityGap, bool audioAac) = 0;
     401              : 
     402              :     /**
     403              :      * @brief Set buffering limit
     404              :      *
     405              :      * This method enables/disables limit buffering and sets millisecond threshold used.
     406              :      * Use kInvalidLimitBuffering to disable limit buffering
     407              :      *
     408              :      * @param[in] limitBufferingMs         : buffering limit in ms
     409              :      *
     410              :      * @retval true on success.
     411              :      */
     412              :     virtual bool setBufferingLimit(uint32_t limitBufferingMs) = 0;
     413              : 
     414              :     /**
     415              :      * @brief Get buffering limit
     416              :      *
     417              :      * This method returns current value of buffering limit in milliseconds
     418              :      * Method will return kInvalidLimitBuffering limit buffering is disabled
     419              :      *
     420              :      * @param[out] limitBufferingMs         : buffering limit in ms
     421              :      *
     422              :      * @retval true on success.
     423              :      */
     424              :     virtual bool getBufferingLimit(uint32_t &limitBufferingMs) = 0;
     425              : 
     426              :     /**
     427              :      * @brief Enables/disables the buffering option
     428              :      *
     429              :      * This method enables the buffering option so that BUFFERING messages are
     430              :      * emitted based on low-/high-percent thresholds.
     431              :      *
     432              :      * @param[in] useBuffering         : true if buffering option enabled.
     433              :      *
     434              :      * @retval true on success.
     435              :      */
     436              :     virtual bool setUseBuffering(bool useBuffering) = 0;
     437              : 
     438              :     /**
     439              :      * @brief Check, if buffering is enabled
     440              :      *
     441              :      * This method returns true, if buffering is enabled
     442              :      *
     443              :      * @param[out] useBuffering         : true if buffering option is enabled.
     444              :      *
     445              :      * @retval true on success.
     446              :      */
     447              :     virtual bool getUseBuffering(bool &useBuffering) = 0;
     448              : 
     449              :     /**
     450              :      * @brief Request to switch the source to the server backend.
     451              :      *
     452              :      * @param[in] source    : The source.
     453              :      *
     454              :      * @retval true on success.
     455              :      */
     456              :     virtual bool switchSource(const std::unique_ptr<IMediaPipeline::MediaSource> &source) = 0;
     457              : 
     458              :     /**
     459              :      * @brief Get the playback duration in nanoseconds.
     460              :      *
     461              :      * This method is synchronous, it returns current playback duration
     462              :      *
     463              :      * @param[out] duration : The playback duration in nanoseconds
     464              :      *
     465              :      * @retval true on success.
     466              :      */
     467              :     virtual bool getDuration(int64_t &duration) = 0;
     468              : };
     469              : 
     470              : }; // namespace firebolt::rialto::client
     471              : 
     472              : #endif // FIREBOLT_RIALTO_CLIENT_I_MEDIA_PIPELINE_IPC_H_
        

Generated by: LCOV version 2.0-1