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-07-22 11:07:41 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          126 :     IMediaPipelineIpcFactory() = default;
      44          126 :     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          314 :     IMediaPipelineIpc() = default;
      75          314 :     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 Sets the "Report Decode Errors" property for this source.
     194              :      *
     195              :      * This method is asynchronous, it will set the "Report Decode Errors" property
     196              :      *
     197              :      * @param[in] sourceId  : The source id. Value should be set to the MediaSource.id returned after attachSource()
     198              :      * @param[in] reportDecodeErrors : Set Report Decode Errors mode on the sink
     199              :      *
     200              :      * @retval true on success.
     201              :      */
     202              :     virtual bool setReportDecodeErrors(int32_t sourceId, bool reportDecodeErrors) = 0;
     203              : 
     204              :     /**
     205              :      * @brief Gets the queued frames for this source.
     206              :      *
     207              :      * This method is synchronous, it gets the queued frames property
     208              :      *
     209              :      * @param[in] sourceId  : The source id. Value should be set to the MediaSource.id returned after attachSource()
     210              :      * @param[out] queuedFrames : Get queued frames on the decoder
     211              :      *
     212              :      * @retval true on success.
     213              :      */
     214              :     virtual bool getQueuedFrames(int32_t sourceId, uint32_t &queuedFrames) = 0;
     215              : 
     216              :     /**
     217              :      * @brief Gets the "Immediate Output" property for this source.
     218              :      *
     219              :      * This method is sychronous
     220              :      *
     221              :      * @param[in] sourceId : The source id. Value should be set to the MediaSource.id returned after attachSource()
     222              :      * @param[out] immediateOutput : Returns the immediate output mode of the sink
     223              :      *
     224              :      * @retval true on success.
     225              :      */
     226              :     virtual bool getImmediateOutput(int32_t sourceId, bool &immediateOutput) = 0;
     227              : 
     228              :     /**
     229              :      * @brief Get stats for this source.
     230              :      *
     231              :      * This method is sychronous, it returns dropped frames and rendered frames
     232              :      *
     233              :      * @param[in] sourceId : The source id. Value should be set to the MediaSource.id returned after attachSource()
     234              :      * @param[out] droppedFrames : The number of dropped frames
     235              :      * @param[out] renderedFrames : The number of rendered frames
     236              :      *
     237              :      * @retval true on success.
     238              :      */
     239              :     virtual bool getStats(int32_t sourceId, uint64_t &renderedFrames, uint64_t &droppedFrames) = 0;
     240              : 
     241              :     /**
     242              :      * @brief Request new playback rate.
     243              :      *
     244              :      * @param[in] rate : The playback rate.
     245              :      *
     246              :      * @retval true on success.
     247              :      */
     248              :     virtual bool setPlaybackRate(double rate) = 0;
     249              : 
     250              :     /**
     251              :      * @brief Requests to render a prerolled frame
     252              :      */
     253              :     virtual bool renderFrame() = 0;
     254              : 
     255              :     /**
     256              :      * @brief Set level and transition of audio attenuation.
     257              :      *        Sets the current volume for the pipeline (0.0 silent -> 1.0 full volume)
     258              :      *
     259              :      * @param[in] targetVolume : Target volume level (0.0 - 1.0)
     260              :      * @param[in] volumeDuration : Duration of the volume transition in milliseconds
     261              :      * @param[in] ease_type : Easing type for the volume transition
     262              :      *
     263              :      * @retval true on success false otherwise
     264              :      */
     265              :     virtual bool setVolume(double targetVolume, uint32_t volumeDuration, EaseType easeType) = 0;
     266              : 
     267              :     /**
     268              :      * @brief Get current audio level. Fetches the current volume level for the pipeline.
     269              :      *
     270              :      * @param[out] volume Current volume level (range 0.0 - 1.0)
     271              :      *
     272              :      * @retval true on success false otherwise
     273              :      */
     274              :     virtual bool getVolume(double &volume) = 0;
     275              : 
     276              :     /**
     277              :      * @brief Set mute status of pipeline.
     278              :      *
     279              :      * Change mute status of media source
     280              :      *
     281              :      * @param[in] sourceId Source, which mute status should be changed
     282              :      * @param[in] mute   Desired mute state, true=muted, false=not muted
     283              :      *
     284              :      * @retval true on success false otherwise
     285              :      */
     286              :     virtual bool setMute(int32_t sourceId, bool mute) = 0;
     287              : 
     288              :     /**
     289              :      * @brief Get current mute status of the media source
     290              :      *
     291              :      * @param[in] sourceId Source, which mute status should be fetched
     292              :      * @param[out] mute   Current mute state
     293              :      *
     294              :      * @retval true on success false otherwise
     295              :      */
     296              :     virtual bool getMute(int32_t sourceId, bool &mute) = 0;
     297              : 
     298              :     /**
     299              :      * @brief Change Text Track Identifier
     300              :      *
     301              :      * @param[in] textTrackIdentifier Text track identifier of subtitle stream
     302              :      *
     303              :      * @retval true on success false otherwise
     304              :      */
     305              :     virtual bool setTextTrackIdentifier(const std::string &textTrackIdentifier) = 0;
     306              : 
     307              :     /**
     308              :      * @brief Get Text Track Identifier
     309              :      *
     310              :      * @param[in] textTrackIdentifier Text track identifier of subtitle stream
     311              :      *
     312              :      * @retval true on success false otherwise
     313              :      */
     314              :     virtual bool getTextTrackIdentifier(std::string &textTrackIdentifier) = 0;
     315              : 
     316              :     /**
     317              :      * @brief Set low latency property on the pipeline. Default false.
     318              :      *
     319              :      * @param[in] lowLatency : The low latency value to set.
     320              :      *
     321              :      * @retval true on success false otherwise
     322              :      */
     323              :     virtual bool setLowLatency(bool lowLatency) = 0;
     324              : 
     325              :     /**
     326              :      * @brief Set sync property on the pipeline. Default false.
     327              :      *
     328              :      * @param[in] sync : The sync value to set.
     329              :      *
     330              :      * @retval true on success false otherwise
     331              :      */
     332              :     virtual bool setSync(bool sync) = 0;
     333              : 
     334              :     /**
     335              :      * @brief Get sync property on the pipeline.
     336              :      *
     337              :      * @param[out] sync : Current sync value.
     338              :      *
     339              :      * @retval true on success false otherwise
     340              :      */
     341              :     virtual bool getSync(bool &sync) = 0;
     342              : 
     343              :     /**
     344              :      * @brief Set sync off property on the pipeline. Default false.
     345              :      *
     346              :      * @param[in] syncOff : The sync off value to set.
     347              :      *
     348              :      * @retval true on success false otherwise
     349              :      */
     350              :     virtual bool setSyncOff(bool syncOff) = 0;
     351              : 
     352              :     /**
     353              :      * @brief Set stream sync mode property on the pipeline. Default 0.
     354              :      *
     355              :      * @param[in] sourceId  : The source id. Value should be set to the MediaSource.id returned after attachSource()
     356              :      * @param[in] streamSyncMode : The stream sync mode value to set.
     357              :      *
     358              :      * @retval true on success false otherwise
     359              :      */
     360              :     virtual bool setStreamSyncMode(int32_t sourceId, int32_t streamSyncMode) = 0;
     361              : 
     362              :     /**
     363              :      * @brief Get stream sync mode property on the pipeline.
     364              :      *
     365              :      * @param[out] streamSyncMode : Current stream sync mode value.
     366              :      *
     367              :      * @retval true on success false otherwise
     368              :      */
     369              :     virtual bool getStreamSyncMode(int32_t &streamSyncMode) = 0;
     370              : 
     371              :     /**
     372              :      * @brief Flushes a source.
     373              :      *
     374              :      * This method is called by Rialto Client to flush out all queued data for a media source stream.
     375              :      *
     376              :      * @param[in]  sourceId  : The source id. Value should be set to the MediaSource.id returned after attachSource()
     377              :      * @param[in]  resetTime : True if time should be reset
     378              :      * @param[out] async     : True if flushed source is asynchronous (will preroll after flush)
     379              :      *
     380              :      * @retval true on success.
     381              :      */
     382              :     virtual bool flush(int32_t sourceId, bool resetTime, bool &async) = 0;
     383              : 
     384              :     /**
     385              :      * @brief Set the source position in nanoseconds.
     386              :      *
     387              :      * This method sets the start position for a source.
     388              :      *
     389              :      * @param[in] sourceId    : The source id. Value should be set to the MediaSource.id returned after attachSource()
     390              :      * @param[in] position    : The position in nanoseconds.
     391              :      * @param[in] resetTime   : True if time should be reset
     392              :      * @param[in] appliedRate : The applied rate after seek
     393              :      * @param[in] stopPosition : The position of last pushed buffer
     394              :      *
     395              :      * @retval true on success.
     396              :      */
     397              :     virtual bool setSourcePosition(int32_t sourceId, int64_t position, bool resetTime, double appliedRate,
     398              :                                    uint64_t stopPosition) = 0;
     399              : 
     400              :     /**
     401              :      * @brief Set the subtitle offset in nanoseconds.
     402              :      *
     403              :      * This method sets the subtitle offset for a subtitle source.
     404              :      *
     405              :      * @param[in] sourceId : The source id. Value should be set to the MediaSource.id returned after attachSource()
     406              :      * @param[in] position : The offset position in nanoseconds.
     407              :      *
     408              :      * @retval true on success.
     409              :      */
     410              :     virtual bool setSubtitleOffset(int32_t sourceId, int64_t position) = 0;
     411              : 
     412              :     /**
     413              :      * @brief Process audio gap
     414              :      *
     415              :      * This method handles audio gap in order to avoid audio pops during transitions.
     416              :      *
     417              :      * @param[in] position         : Audio pts fade pts value
     418              :      * @param[in] duration         : Audio pts fade duration
     419              :      * @param[in] discontinuityGap : Audio discontinuity gap
     420              :      * @param[in] audioAac         : True if audio codec is AAC
     421              :      *
     422              :      * @retval true on success.
     423              :      */
     424              :     virtual bool processAudioGap(int64_t position, uint32_t duration, int64_t discontinuityGap, bool audioAac) = 0;
     425              : 
     426              :     /**
     427              :      * @brief Set buffering limit
     428              :      *
     429              :      * This method enables/disables limit buffering and sets millisecond threshold used.
     430              :      * Use kInvalidLimitBuffering to disable limit buffering
     431              :      *
     432              :      * @param[in] limitBufferingMs         : buffering limit in ms
     433              :      *
     434              :      * @retval true on success.
     435              :      */
     436              :     virtual bool setBufferingLimit(uint32_t limitBufferingMs) = 0;
     437              : 
     438              :     /**
     439              :      * @brief Get buffering limit
     440              :      *
     441              :      * This method returns current value of buffering limit in milliseconds
     442              :      * Method will return kInvalidLimitBuffering limit buffering is disabled
     443              :      *
     444              :      * @param[out] limitBufferingMs         : buffering limit in ms
     445              :      *
     446              :      * @retval true on success.
     447              :      */
     448              :     virtual bool getBufferingLimit(uint32_t &limitBufferingMs) = 0;
     449              : 
     450              :     /**
     451              :      * @brief Enables/disables the buffering option
     452              :      *
     453              :      * This method enables the buffering option so that BUFFERING messages are
     454              :      * emitted based on low-/high-percent thresholds.
     455              :      *
     456              :      * @param[in] useBuffering         : true if buffering option enabled.
     457              :      *
     458              :      * @retval true on success.
     459              :      */
     460              :     virtual bool setUseBuffering(bool useBuffering) = 0;
     461              : 
     462              :     /**
     463              :      * @brief Check, if buffering is enabled
     464              :      *
     465              :      * This method returns true, if buffering is enabled
     466              :      *
     467              :      * @param[out] useBuffering         : true if buffering option is enabled.
     468              :      *
     469              :      * @retval true on success.
     470              :      */
     471              :     virtual bool getUseBuffering(bool &useBuffering) = 0;
     472              : 
     473              :     /**
     474              :      * @brief Request to switch the source to the server backend.
     475              :      *
     476              :      * @param[in] source    : The source.
     477              :      *
     478              :      * @retval true on success.
     479              :      */
     480              :     virtual bool switchSource(const std::unique_ptr<IMediaPipeline::MediaSource> &source) = 0;
     481              : 
     482              :     /**
     483              :      * @brief Get the playback duration in nanoseconds.
     484              :      *
     485              :      * This method is synchronous, it returns current playback duration
     486              :      *
     487              :      * @param[out] duration : The playback duration in nanoseconds
     488              :      *
     489              :      * @retval true on success.
     490              :      */
     491              :     virtual bool getDuration(int64_t &duration) = 0;
     492              : };
     493              : 
     494              : }; // namespace firebolt::rialto::client
     495              : 
     496              : #endif // FIREBOLT_RIALTO_CLIENT_I_MEDIA_PIPELINE_IPC_H_
        

Generated by: LCOV version 2.0-1