LCOV - code coverage report
Current view: top level - media/public/include - IMediaPipeline.h (source / functions) Coverage Total Hit
Test: coverage.info Lines: 94.0 % 116 109
Test Date: 2025-06-25 09:25:33 Functions: 94.9 % 79 75

            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_I_MEDIA_PIPELINE_H_
      21              : #define FIREBOLT_RIALTO_I_MEDIA_PIPELINE_H_
      22              : 
      23              : /**
      24              :  * @file IMediaPipeline.h
      25              :  *
      26              :  * The definition of the IMediaPipeline interface.
      27              :  *
      28              :  * This interface defines the public API of Rialto for playback of AV content.
      29              :  */
      30              : 
      31              : #include <stdint.h>
      32              : 
      33              : #include <algorithm>
      34              : #include <memory>
      35              : #include <optional>
      36              : #include <string>
      37              : #include <vector>
      38              : 
      39              : #include "IMediaPipelineClient.h"
      40              : #include "MediaCommon.h"
      41              : 
      42              : namespace firebolt::rialto
      43              : {
      44              : class IMediaPipeline;
      45              : 
      46              : /**
      47              :  * @brief IMediaPipeline factory class, returns a concrete implementation of IMediaPipeline
      48              :  */
      49              : class IMediaPipelineFactory
      50              : {
      51              : public:
      52          132 :     IMediaPipelineFactory() = default;
      53          132 :     virtual ~IMediaPipelineFactory() = default;
      54              : 
      55              :     /**
      56              :      * @brief Create a IMediaPipelineFactory instance.
      57              :      *
      58              :      * @retval the factory instance or null on error.
      59              :      */
      60              :     static std::shared_ptr<IMediaPipelineFactory> createFactory();
      61              : 
      62              :     /**
      63              :      * @brief IMediaPipeline factory method, returns a concrete implementation of IMediaPipeline
      64              :      *
      65              :      * @param[in] client                  : The Rialto media player client.
      66              :      * @param[in] videoRequirements       : The video decoder requirements for the MediaPipeline session
      67              :      *
      68              :      * @retval the new backend instance or null on error.
      69              :      */
      70              :     virtual std::unique_ptr<IMediaPipeline> createMediaPipeline(std::weak_ptr<IMediaPipelineClient> client,
      71              :                                                                 const VideoRequirements &videoRequirements) const = 0;
      72              : };
      73              : 
      74              : /**
      75              :  * @brief The definition of the IMediaPipeline interface.
      76              :  *
      77              :  * This interface defines the public API of Rialto for playback of AV content which
      78              :  * should be implemented by both Rialto Client & Rialto Server.
      79              :  */
      80              : class IMediaPipeline
      81              : {
      82              : public:
      83          387 :     IMediaPipeline() = default;
      84          387 :     virtual ~IMediaPipeline() = default;
      85              : 
      86              :     IMediaPipeline(const IMediaPipeline &) = delete;
      87              :     IMediaPipeline &operator=(const IMediaPipeline &) = delete;
      88              :     IMediaPipeline(IMediaPipeline &&) = delete;
      89              :     IMediaPipeline &operator=(IMediaPipeline &&) = delete;
      90              : 
      91              :     /**
      92              :      * @brief A class that represents a source of media data.
      93              :      */
      94              :     class MediaSource
      95              :     {
      96              :     public:
      97              :         /**
      98              :          * @brief Virtual destructor.
      99              :          */
     100              :         virtual ~MediaSource() {}
     101              : 
     102              :         /**
     103              :          * @brief Create a copy
     104              :          */
     105              :         virtual std::unique_ptr<MediaSource> copy() const = 0;
     106              : 
     107              :         /**
     108              :          * @brief Return the source type.
     109              :          */
     110            0 :         virtual MediaSourceType getType() const { return MediaSourceType::UNKNOWN; }
     111              : 
     112              :         /**
     113              :          * @brief Return the MIME type.
     114              :          */
     115           78 :         std::string getMimeType() const { return m_mimeType; }
     116              : 
     117              :         /**
     118              :          * @brief Return if source has drm
     119              :          */
     120           47 :         bool getHasDrm() const { return m_hasDrm; }
     121              : 
     122              :         /**
     123              :          * @brief Return the source config type.
     124              :          */
     125           78 :         SourceConfigType getConfigType() const { return m_configType; }
     126              : 
     127              :         /**
     128              :          * @brief Return the source id.
     129              :          */
     130          112 :         int32_t getId() const { return m_id; }
     131              : 
     132              :         /**
     133              :          * @brief Set the source id.
     134              :          */
     135          109 :         void setId(int32_t id) { m_id = id; }
     136              : 
     137              :     protected:
     138              :         /**
     139              :          * @brief Default constructor.
     140              :          *
     141              :          * @param[in]  configType   : The source config type.
     142              :          * @param[in]  mimeType     : The mime type string.
     143              :          * @param[in]  hasDrm       : Information if source will use drm
     144              :          */
     145          152 :         explicit MediaSource(SourceConfigType configType = SourceConfigType::UNKNOWN,
     146              :                              const std::string &mimeType = std::string(), bool hasDrm = true)
     147          152 :             : m_id(0), m_configType(configType), m_mimeType(mimeType), m_hasDrm(hasDrm)
     148              :         {
     149              :         }
     150              :         /**
     151              :          * @brief The source id. Parameter will be set by a successful call to attachSource()
     152              :          */
     153              :         int32_t m_id;
     154              : 
     155              :         /**
     156              :          * @brief The source config type.
     157              :          */
     158              :         SourceConfigType m_configType;
     159              : 
     160              :         /**
     161              :          * @brief The MIME type.
     162              :          */
     163              :         std::string m_mimeType;
     164              : 
     165              :         /**
     166              :          * @brief Parameter to check if encrypted frames will be used for this source.
     167              :          */
     168              :         bool m_hasDrm;
     169              :     };
     170              : 
     171              :     /**
     172              :      * @brief A class that represents media source audio and video derived from MediaSource class, which represents the
     173              :      * source of media data
     174              :      */
     175              :     class MediaSourceAV : public MediaSource
     176              :     {
     177              :     public:
     178              :         ~MediaSourceAV() {}
     179            0 :         std::unique_ptr<MediaSource> copy() const { return std::make_unique<MediaSourceAV>(*this); }
     180              : 
     181              :         /**
     182              :          * @brief Gets the segment alignment
     183              :          */
     184           44 :         SegmentAlignment getSegmentAlignment() const { return m_alignment; }
     185              : 
     186              :         /**
     187              :          * @brief Gets the codec data
     188              :          */
     189           63 :         const std::shared_ptr<CodecData> &getCodecData() const { return m_codecData; }
     190              : 
     191              :         /**
     192              :          * @brief Gets the stream format
     193              :          */
     194           54 :         StreamFormat getStreamFormat() const { return m_streamFormat; }
     195              : 
     196              :     protected:
     197              :         /**
     198              :          * @brief Default constructor.
     199              :          *
     200              :          * @param[in]  configType   : The source config type.
     201              :          * @param[in]  mimeType     : The mime type string.
     202              :          * @param[in]  hasDrm       : Information if source will use drm
     203              :          * @param[in]  alignment    : The alignment of media segment.
     204              :          * @param[in]  streamFormat : The stream format
     205              :          * @param[in]  codecData    : The additional data for decoder
     206              :          */
     207          143 :         explicit MediaSourceAV(SourceConfigType configType = SourceConfigType::UNKNOWN,
     208              :                                const std::string &mimeType = std::string(), bool hasDrm = true,
     209              :                                SegmentAlignment alignment = SegmentAlignment::UNDEFINED,
     210              :                                StreamFormat streamFormat = StreamFormat::UNDEFINED,
     211              :                                const std::shared_ptr<CodecData> &codecData = nullptr)
     212          286 :             : MediaSource(configType, mimeType, hasDrm), m_alignment(alignment), m_streamFormat(streamFormat),
     213          143 :               m_codecData(codecData)
     214              :         {
     215              :         }
     216              :         /**
     217              :          * @brief The alignment of media segment
     218              :          */
     219              :         SegmentAlignment m_alignment;
     220              : 
     221              :         /**
     222              :          * @brief The stream format
     223              :          */
     224              :         StreamFormat m_streamFormat;
     225              : 
     226              :         /**
     227              :          * @brief Additional data for decoder
     228              :          */
     229              :         std::shared_ptr<CodecData> m_codecData;
     230              :     };
     231              : 
     232              :     /**
     233              :      * @brief A class that represents media source audio derived from MediaSource class, which represents the source of
     234              :      * media data
     235              :      */
     236              : 
     237              :     class MediaSourceAudio : public MediaSourceAV
     238              :     {
     239              :     public:
     240              :         /**
     241              :          * @brief Constructor for audio specific configuration.
     242              :          *
     243              :          * @param[in]  mimeType     : The mime type string.
     244              :          * @param[in]  hasDrm       : Information if source will use drm
     245              :          * @param[in]  audioConfig  : The audio specific configuration.
     246              :          * @param[in]  alignment    : The alignment of media segment.
     247              :          * @param[in]  streamFormat : The stream format
     248              :          * @param[in]  codecData    : The additional data for decoder
     249              :          */
     250           91 :         MediaSourceAudio(const std::string &mimeType, bool hasDrm = true, const AudioConfig &audioConfig = AudioConfig(),
     251              :                          SegmentAlignment alignment = SegmentAlignment::UNDEFINED,
     252              :                          StreamFormat streamFormat = StreamFormat::UNDEFINED,
     253              :                          const std::shared_ptr<CodecData> &codecData = nullptr)
     254           91 :             : MediaSourceAV(SourceConfigType::AUDIO, mimeType, hasDrm, alignment, streamFormat, codecData),
     255           91 :               m_audioConfig(audioConfig)
     256              :         {
     257              :         }
     258              : 
     259              :         ~MediaSourceAudio() {}
     260              : 
     261          142 :         MediaSourceType getType() const override { return MediaSourceType::AUDIO; }
     262           11 :         std::unique_ptr<MediaSource> copy() const override { return std::make_unique<MediaSourceAudio>(*this); }
     263              : 
     264              :         /**
     265              :          * @brief Gets the audio specific configuration
     266              :          *
     267              :          * @retval audio specific configuration
     268              :          */
     269           80 :         const AudioConfig &getAudioConfig() const { return m_audioConfig; }
     270              : 
     271              :     protected:
     272              :         /**
     273              :          * @brief Variable that stores the audio specific configuration
     274              :          */
     275              :         AudioConfig m_audioConfig;
     276              :     };
     277              : 
     278              :     /**
     279              :      * @brief A class that represents media source video derived from MediaSource class, which represents the source of
     280              :      * media data
     281              :      */
     282              : 
     283              :     class MediaSourceVideo : public MediaSourceAV
     284              :     {
     285              :     public:
     286              :         /**
     287              :          * @brief Constructor for video specific configuration.
     288              :          *
     289              :          * @param[in]  mimeType     : The mime type string.
     290              :          * @param[in]  hasDrm       : Information if source will use drm
     291              :          * @param[in]  width        : The width of the video
     292              :          * @param[in]  height       : The height of the video
     293              :          * @param[in]  alignment    : The alignment of media segment.
     294              :          * @param[in]  streamFormat : The stream format
     295              :          * @param[in]  codecData    : The additional data for decoder
     296              :          */
     297           43 :         MediaSourceVideo(const std::string &mimeType, bool hasDrm = true,
     298              :                          int32_t width = firebolt::rialto::kUndefinedSize,
     299              :                          int32_t height = firebolt::rialto::kUndefinedSize,
     300              :                          SegmentAlignment alignment = SegmentAlignment::UNDEFINED,
     301              :                          StreamFormat streamFormat = StreamFormat::UNDEFINED,
     302              :                          const std::shared_ptr<CodecData> &codecData = nullptr)
     303           43 :             : MediaSourceAV(SourceConfigType::VIDEO, mimeType, hasDrm, alignment, streamFormat, codecData),
     304           43 :               m_width(width), m_height(height)
     305              :         {
     306              :         }
     307              :         ~MediaSourceVideo() {}
     308              : 
     309          131 :         MediaSourceType getType() const override { return MediaSourceType::VIDEO; }
     310            8 :         std::unique_ptr<MediaSource> copy() const { return std::make_unique<MediaSourceVideo>(*this); }
     311              : 
     312              :         /**
     313              :          * @brief Gets the width of the video
     314              :          *
     315              :          * @retval width of the video
     316              :          */
     317           20 :         int32_t getWidth() const { return m_width; }
     318              : 
     319              :         /**
     320              :          * @brief Gets the height of the video
     321              :          *
     322              :          * @retval height of the video
     323              :          */
     324           20 :         int32_t getHeight() const { return m_height; }
     325              : 
     326              :     protected:
     327              :         /**
     328              :          * @brief Constructor for video specific configuration.
     329              :          *
     330              :          * @param[in]  sourceConfigType : The source config type
     331              :          * @param[in]  mimeType         : The mime type string.
     332              :          * @param[in]  hasDrm           : Information if source will use drm
     333              :          * @param[in]  width            : The width of the video
     334              :          * @param[in]  height           : The height of the video
     335              :          * @param[in]  alignment        : The alignment of media segment.
     336              :          * @param[in]  streamFormat     : The stream format
     337              :          * @param[in]  codecData        : The additional data for decoder
     338              :          */
     339            5 :         MediaSourceVideo(SourceConfigType sourceConfigType, const std::string &mimeType, bool hasDrm = true,
     340              :                          int32_t width = firebolt::rialto::kUndefinedSize,
     341              :                          int32_t height = firebolt::rialto::kUndefinedSize,
     342              :                          SegmentAlignment alignment = SegmentAlignment::UNDEFINED,
     343              :                          StreamFormat streamFormat = StreamFormat::UNDEFINED,
     344              :                          const std::shared_ptr<CodecData> &codecData = nullptr)
     345           10 :             : MediaSourceAV(sourceConfigType, mimeType, hasDrm, alignment, streamFormat, codecData), m_width(width),
     346            5 :               m_height(height)
     347              :         {
     348              :         }
     349              : 
     350              :     private:
     351              :         /**
     352              :          * @brief The video width
     353              :          */
     354              :         int m_width;
     355              : 
     356              :         /**
     357              :          * @brief The video height
     358              :          */
     359              :         int m_height;
     360              :     };
     361              : 
     362              :     /**
     363              :      * @brief A class that represents media source video dolby vision derived from media source video data
     364              :      */
     365              : 
     366              :     class MediaSourceVideoDolbyVision : public MediaSourceVideo
     367              :     {
     368              :     public:
     369              :         /**
     370              :          * @brief Constructor for dolby vision specific configuration.
     371              :          *
     372              :          * @param[in] mimeType           : The mime type string.
     373              :          * @param[in] dolbyVisionProfile : The dolby vision profile
     374              :          * @param[in] hasDrm             : Information if source will use drm
     375              :          * @param[in] width              : The width of the video
     376              :          * @param[in] height             : The height of the video
     377              :          * @param[in] alignment          : The alignment of media segment.
     378              :          * @param[in] streamFormat       : The stream format
     379              :          * @param[in] codecData          : The additional data for decoder
     380              :          */
     381            4 :         MediaSourceVideoDolbyVision(const std::string &mimeType, int32_t dolbyVisionProfile, bool hasDrm = true,
     382              :                                     int32_t width = firebolt::rialto::kUndefinedSize,
     383              :                                     int32_t height = firebolt::rialto::kUndefinedSize,
     384              :                                     SegmentAlignment alignment = SegmentAlignment::UNDEFINED,
     385              :                                     StreamFormat streamFormat = StreamFormat::UNDEFINED,
     386              :                                     const std::shared_ptr<CodecData> &codecData = nullptr)
     387            4 :             : MediaSourceVideo(SourceConfigType::VIDEO_DOLBY_VISION, mimeType, hasDrm, width, height, alignment,
     388              :                                streamFormat, codecData),
     389            4 :               m_dolbyVisionProfile(dolbyVisionProfile)
     390              :         {
     391              :         }
     392              :         ~MediaSourceVideoDolbyVision() {}
     393            1 :         std::unique_ptr<MediaSource> copy() const { return std::make_unique<MediaSourceVideoDolbyVision>(*this); }
     394              : 
     395              :         /**
     396              :          * @brief Gets the dolby vision profile
     397              :          *
     398              :          * @retval dolby vision profile
     399              :          */
     400            4 :         uint32_t getDolbyVisionProfile() const { return m_dolbyVisionProfile; }
     401              : 
     402              :     protected:
     403              :         /**
     404              :          * @brief Variable that stores the Dolby Vision Profile
     405              :          */
     406              :         uint32_t m_dolbyVisionProfile;
     407              :     };
     408              : 
     409              :     /**
     410              :      * @brief A class that represents media source subtitle derived from media source video data
     411              :      */
     412              :     class MediaSourceSubtitle : public MediaSource
     413              :     {
     414              :     public:
     415              :         /**
     416              :          * @brief Construct a new Media Source Subtitle object
     417              :          *
     418              :          * @param mimeType              : The mime type string
     419              :          * @param textTrackIdentifier   : The text track identifier string
     420              :          */
     421            4 :         MediaSourceSubtitle(const std::string &mimeType, const std::string &textTrackIdentifier)
     422            4 :             : MediaSource(SourceConfigType::SUBTITLE, mimeType, false), m_textTrackIdentifier(textTrackIdentifier)
     423              :         {
     424              :         }
     425              : 
     426              :         ~MediaSourceSubtitle() {}
     427              : 
     428            7 :         MediaSourceType getType() const override { return MediaSourceType::SUBTITLE; }
     429            1 :         std::unique_ptr<MediaSource> copy() const override { return std::make_unique<MediaSourceSubtitle>(*this); }
     430              : 
     431              :         /**
     432              :          * @brief Get the Text Track Identifier object
     433              :          *
     434              :          * @return the text track identifier
     435              :          */
     436            3 :         const std::string &getTextTrackIdentifier() const { return m_textTrackIdentifier; }
     437              : 
     438              :     protected:
     439              :         /**
     440              :          * @brief Variable that stores the text track identifier
     441              :          */
     442              :         std::string m_textTrackIdentifier;
     443              :     };
     444              : 
     445              :     /**
     446              :      * @brief A class that represents a media segment
     447              :      */
     448              :     class MediaSegment
     449              :     {
     450              :     public:
     451              :         /**
     452              :          * @brief Default constructor.
     453              :          *
     454              :          * @param[in] sourceId      : The source id. Value should be set to the MediaSource.id returned after attachSource()
     455              :          * @param[in] type          : The source type.
     456              :          * @param[in] timeStamp     : The timestamp in nanoseconds.
     457              :          * @param[in] duration      : The duration in nanoseconds.
     458              :          */
     459          130 :         MediaSegment(int32_t sourceId = 0, MediaSourceType type = MediaSourceType::UNKNOWN, int64_t timeStamp = 0,
     460              :                      int64_t duration = 0)
     461          130 :             : m_sourceId(sourceId), m_type(type), m_data(nullptr), m_dataLength(0u), m_timeStamp(timeStamp),
     462          390 :               m_duration(duration), m_encrypted(false), m_mediaKeySessionId(0), m_initWithLast15(0),
     463          130 :               m_alignment(SegmentAlignment::UNDEFINED), m_cipherMode(CipherMode::UNKNOWN), m_crypt(0), m_skip(0),
     464          130 :               m_encryptionPatternSet(false), m_displayOffset(std::nullopt)
     465              :         {
     466              :         }
     467              : 
     468              :         /**
     469              :          * @brief Virtual destructor.
     470              :          */
     471              :         virtual ~MediaSegment() {}
     472              : 
     473              :         /**
     474              :          * @brief Makes a shallow copy of the segment
     475              :          *
     476              :          * @retval Shallow copy of the segment
     477              :          */
     478            2 :         virtual std::unique_ptr<MediaSegment> copy() const { return std::make_unique<MediaSegment>(*this); }
     479              : 
     480              :         /**
     481              :          * @brief Return the source id.
     482              :          *
     483              :          * @retval the source id.
     484              :          */
     485           41 :         int32_t getId() const { return m_sourceId; }
     486              : 
     487              :         /**
     488              :          * @brief The source type for the data.
     489              :          *
     490              :          * @retval the source type.
     491              :          */
     492          139 :         MediaSourceType getType() const { return m_type; }
     493              : 
     494              :         /**
     495              :          * @brief Returns a pointer to the data.
     496              :          *
     497              :          * @retval the data.
     498              :          */
     499          142 :         const uint8_t *getData() const { return m_data; }
     500              : 
     501              :         /**
     502              :          * @brief Returns a the data length.
     503              :          *
     504              :          * @retval the data.
     505              :          */
     506          204 :         uint32_t getDataLength() const { return m_dataLength; }
     507              : 
     508              :         /**
     509              :          * @brief Returns the time stamp.
     510              :          *
     511              :          * @retval the timestamp in nanoseconds.
     512              :          */
     513           56 :         int64_t getTimeStamp() const { return m_timeStamp; }
     514              : 
     515              :         /**
     516              :          * @brief Sets the time stamp (value in nanoseconds).
     517              :          */
     518              :         void setTimeStamp(int64_t timeStamp) { m_timeStamp = timeStamp; }
     519              : 
     520              :         /**
     521              :          * @brief Returns the duration.
     522              :          *
     523              :          * @retval the duration in nanoseconds.
     524              :          */
     525           56 :         int64_t getDuration() const { return m_duration; }
     526              : 
     527              :         /**
     528              :          * @brief Returns a pointer to the extra data.
     529              :          *
     530              :          * @retval the data.
     531              :          */
     532          140 :         const std::vector<uint8_t> &getExtraData() const { return m_extraData; }
     533              : 
     534              :         /**
     535              :          * @brief Indicates that the data is encrypted.
     536              :          *
     537              :          * @retval true if the data is encrypted.
     538              :          */
     539           82 :         bool isEncrypted() const { return m_encrypted; }
     540              : 
     541              :         /**
     542              :          * @brief Returns the media key session id. Empty if unencrypted.
     543              :          *
     544              :          * @retval the media key session id.
     545              :          */
     546           22 :         const int32_t getMediaKeySessionId() const { return m_mediaKeySessionId; }
     547              : 
     548              :         /**
     549              :          * @brief Returns the key id. Empty if unencrypted.
     550              :          *
     551              :          * @retval the key id.
     552              :          */
     553           38 :         const std::vector<uint8_t> &getKeyId() const { return m_keyId; }
     554              : 
     555              :         /**
     556              :          * @brief Returns the initialisation vector. Empty if unencrypted.
     557              :          *
     558              :          * @retval the initialisation vector.
     559              :          */
     560           35 :         const std::vector<uint8_t> &getInitVector() const { return m_initVector; }
     561              : 
     562              :         /**
     563              :          * @brief Returns the sub samples. Empty if unencrypted.
     564              :          *
     565              :          * @retval the sub samples.
     566              :          */
     567           37 :         const std::vector<SubSamplePair> &getSubSamples() const { return m_subSamples; }
     568              : 
     569              :         /**
     570              :          * @brief Returns the initWithLast15 value
     571              :          *
     572              :          * @retval the initWithLast15 value.
     573              :          */
     574           20 :         const uint32_t getInitWithLast15() const { return m_initWithLast15; }
     575              : 
     576              :         /**
     577              :          * @brief Returns the segment alignment
     578              :          *
     579              :          * @retval the segment alignment
     580              :          */
     581           31 :         const SegmentAlignment getSegmentAlignment() const { return m_alignment; }
     582              : 
     583              :         /**
     584              :          * @brief Gets the codec data
     585              :          *
     586              :          * @retval the codec data
     587              :          */
     588           51 :         const std::shared_ptr<CodecData> &getCodecData() const { return m_codecData; }
     589              : 
     590              :         /**
     591              :          * @brief Gets the cipher mode for common encryption
     592              :          *
     593              :          * @retval cipher mode uses for this sample
     594              :          */
     595           17 :         const CipherMode &getCipherMode() const { return m_cipherMode; }
     596              : 
     597              :         /**
     598              :          * @brief Gets the crypt & skip byte block for pattern encryption
     599              :          *
     600              :          * @param[out] crypt : Crypt byte block value
     601              :          * @param[out] skip  : Skip byte block value
     602              :          *
     603              :          * @retval if the encryption pattern has been set
     604              :          */
     605           17 :         const bool getEncryptionPattern(uint32_t &crypt, uint32_t &skip) const
     606              :         {
     607           17 :             crypt = m_crypt;
     608           17 :             skip = m_skip;
     609           17 :             return m_encryptionPatternSet;
     610              :         }
     611              : 
     612              :         /**
     613              :          * @brief Gets the display offset
     614              :          *
     615              :          * @retval The offset in the source file of the beginning of the media segment.
     616              :          */
     617           34 :         std::optional<uint64_t> getDisplayOffset() const { return m_displayOffset; }
     618              : 
     619              :     protected:
     620              :         /**
     621              :          * @brief The source id.
     622              :          */
     623              :         int32_t m_sourceId;
     624              : 
     625              :         /**
     626              :          * @brief The source type.
     627              :          */
     628              :         MediaSourceType m_type;
     629              : 
     630              :         /**
     631              :          * @brief The data
     632              :          */
     633              :         const uint8_t *m_data;
     634              : 
     635              :         /**
     636              :          * @brief The data length
     637              :          */
     638              :         uint32_t m_dataLength;
     639              : 
     640              :         /**
     641              :          * @brief The time stamp.
     642              :          */
     643              :         int64_t m_timeStamp;
     644              : 
     645              :         /**
     646              :          * @brief The duration.
     647              :          */
     648              :         int64_t m_duration;
     649              : 
     650              :         /**
     651              :          * @brief Additional data for decoder
     652              :          */
     653              :         std::shared_ptr<CodecData> m_codecData;
     654              : 
     655              :         /**
     656              :          * @brief The data
     657              :          */
     658              :         std::vector<uint8_t> m_extraData;
     659              : 
     660              :         /**
     661              :          * @brief Indicates the data is encrypted.
     662              :          */
     663              :         bool m_encrypted;
     664              : 
     665              :         /**
     666              :          * @brief Key session ID to use for decryption - only required for Netflix.
     667              :          */
     668              :         int32_t m_mediaKeySessionId;
     669              : 
     670              :         /**
     671              :          * @brief The encryption key id.
     672              :          */
     673              :         std::vector<uint8_t> m_keyId;
     674              : 
     675              :         /**
     676              :          * @brief The encryption key initialisation vector.
     677              :          */
     678              :         std::vector<uint8_t> m_initVector;
     679              : 
     680              :         /**
     681              :          * @brief The sub-sample pairs.
     682              :          */
     683              :         std::vector<SubSamplePair> m_subSamples;
     684              : 
     685              :         /**
     686              :          * @brief Whether decryption context needs to be initialized with
     687              :          * last 15 bytes. Currently this only applies to PlayReady DRM.
     688              :          */
     689              :         uint32_t m_initWithLast15;
     690              : 
     691              :         /**
     692              :          * @brief The alignment of media segment
     693              :          */
     694              :         SegmentAlignment m_alignment;
     695              : 
     696              :         /**
     697              :          * @brief Cipher mode of the sample.
     698              :          */
     699              :         CipherMode m_cipherMode;
     700              : 
     701              :         /**
     702              :          * @brief Crypt byte block value.
     703              :          */
     704              :         uint32_t m_crypt;
     705              : 
     706              :         /**
     707              :          * @brief Skip byte block value.
     708              :          */
     709              :         uint32_t m_skip;
     710              : 
     711              :         /**
     712              :          * @brief Whether the encryption pattern has been set.
     713              :          */
     714              :         bool m_encryptionPatternSet;
     715              : 
     716              :         /**
     717              :          * @brief The offset in the source file of the beginning of the media segment.
     718              :          */
     719              :         std::optional<uint64_t> m_displayOffset;
     720              : 
     721              :     public:
     722              :         /**
     723              :          * @brief Sets the segment data.
     724              :          *
     725              :          * @warning Note that the caller must guarantee that the buffer referenced by 'data' must remain
     726              :          * valid until the corresponding call to haveData() has completed (at which point the data will
     727              :          * have been copied out).
     728              :          *
     729              :          * @note This is for performance reasons to avoid multiple copies of AV data. A raw pointer is
     730              :          * used for the same reason since most runtimes will expose a raw pointer to the data.
     731              :          *
     732              :          * @retval true on success.
     733              :          */
     734          104 :         bool setData(uint32_t dataLength, const uint8_t *data)
     735              :         {
     736          104 :             m_dataLength = dataLength;
     737          104 :             m_data = data;
     738          104 :             return true;
     739              :         }
     740              : 
     741              :         /**
     742              :          * @brief Sets the extra data.
     743              :          *
     744              :          * @retval true on success.
     745              :          */
     746           18 :         bool setExtraData(const std::vector<uint8_t> &extraData)
     747              :         {
     748           18 :             m_extraData = extraData;
     749           18 :             return true;
     750              :         }
     751              : 
     752              :         /**
     753              :          * @brief Sets the segment alignment
     754              :          *
     755              :          * @param[in] alignment : The new segment alignment
     756              :          */
     757            6 :         void setSegmentAlignment(const SegmentAlignment &alignment) { m_alignment = alignment; }
     758              : 
     759              :         /**
     760              :          * @brief Sets new codec_data for the segment.
     761              :          *
     762              :          * @note Should only be called if the codec data changes
     763              :          *
     764              :          * @param[in] codecData  The updated codec data for the source
     765              :          */
     766           10 :         void setCodecData(const std::shared_ptr<CodecData> &codecData) { m_codecData = codecData; }
     767              : 
     768              :         /**
     769              :          * @brief Sets the encrypted flag.
     770              :          *
     771              :          * @param[in] encrypted : Set true to indicated encrypted data.
     772              :          */
     773           22 :         void setEncrypted(bool encrypted) { m_encrypted = encrypted; }
     774              : 
     775              :         /**
     776              :          * @brief Sets the media key session id.
     777              :          *
     778              :          * @param[in] mksId : the media key session id.
     779              :          */
     780           15 :         void setMediaKeySessionId(int32_t mksId) { m_mediaKeySessionId = mksId; }
     781              : 
     782              :         /**
     783              :          * @brief Sets the key id.
     784              :          *
     785              :          * @param[in] keyId : The key id.
     786              :          */
     787           14 :         void setKeyId(const std::vector<uint8_t> &keyId) { m_keyId = keyId; }
     788              : 
     789              :         /**
     790              :          * @brief Sets the encryption initialisation vector.
     791              :          *
     792              :          * @param[in] initVector : The initialisation vector.
     793              :          */
     794           13 :         void setInitVector(const std::vector<uint8_t> &initVector) { m_initVector = initVector; }
     795              : 
     796              :         /**
     797              :          * @brief Adds a sub-sample pair to the sub samples.
     798              :          *
     799              :          * @param[in] numClearBytes     : The number of clear bytes.
     800              :          * @param[in] numEncryptedBytes : The number of encrypted bytes.
     801              :          */
     802           13 :         void addSubSample(size_t numClearBytes, size_t numEncryptedBytes)
     803              :         {
     804           13 :             m_subSamples.emplace_back(SubSamplePair{numClearBytes, numEncryptedBytes});
     805              :         }
     806              : 
     807              :         /**
     808              :          * @brief Sets initWithLast15 value
     809              :          *
     810              :          * @param[in] initWithLast15 : initWithLast15 value
     811              :          */
     812           13 :         void setInitWithLast15(uint32_t initWithLast15) { m_initWithLast15 = initWithLast15; }
     813              : 
     814              :         /**
     815              :          * @brief Sets the cipher mode for common encryption.
     816              :          *
     817              :          * @param[in] cipherMode : Specifies cipher mode uses for this sample.
     818              :          */
     819           11 :         void setCipherMode(CipherMode cipherMode) { m_cipherMode = cipherMode; }
     820              : 
     821              :         /**
     822              :          * @brief Sets the crypt & skip byte block for pattern encryption
     823              :          *
     824              :          * @param[in] crypt : Crypt byte block value
     825              :          * @param[in] skip  : Skip byte block value
     826              :          */
     827            6 :         void setEncryptionPattern(uint32_t crypt, uint32_t skip)
     828              :         {
     829            6 :             m_crypt = crypt;
     830            6 :             m_skip = skip;
     831            6 :             m_encryptionPatternSet = true;
     832              :         }
     833              : 
     834              :         /**
     835              :          * @brief Sets the display offset
     836              :          *
     837              :          * @param[in] displayOffset : The offset in the source file of the beginning of the media segment.
     838              :          */
     839           14 :         void setDisplayOffset(uint64_t displayOffset) { m_displayOffset = displayOffset; }
     840              : 
     841              :         /**
     842              :          * @brief Copies the data from other to this.
     843              :          */
     844              :         void copy(const MediaSegment &other);
     845              :     };
     846              : 
     847              :     /**
     848              :      * @brief A class that represents media source audio data
     849              :      */
     850              :     class MediaSegmentAudio : public MediaSegment
     851              :     {
     852              :     public:
     853              :         /**
     854              :          * @brief Default constructor.
     855              :          *
     856              :          * @param[in] sourceId         : The source id. Value should be set to the MediaSource.id returned after attachSource()
     857              :          * @param[in] timeStamp        : The timestamp in nanoseconds.
     858              :          * @param[in] duration         : The duration in nanoseconds.
     859              :          * @param[in] sampleRate       : The sample rate in samples per second.
     860              :          * @param[in] numberOfChannels : The number of audio channels.
     861              :          * @param[in] clippingStart    : The amount of audio to clip from start of buffer
     862              :          * @param[in] clippingEnd      : The amount of audio to clip from end of buffer
     863              :          */
     864           67 :         MediaSegmentAudio(int32_t sourceId = 0, int64_t timeStamp = 0, int64_t duration = 0, int32_t sampleRate = 0,
     865              :                           int32_t numberOfChannels = 0, uint64_t clippingStart = 0, uint64_t clippingEnd = 0)
     866          134 :             : MediaSegment(sourceId, MediaSourceType::AUDIO, timeStamp, duration), m_sampleRate(sampleRate),
     867           67 :               m_numberOfChannels(numberOfChannels), m_clippingStart(clippingStart), m_clippingEnd(clippingEnd)
     868              :         {
     869              :         }
     870              : 
     871              :         /**
     872              :          * @brief Copy constructor.
     873              :          */
     874            1 :         MediaSegmentAudio(const MediaSegmentAudio &other) : MediaSegment(other)
     875              :         {
     876            1 :             m_sampleRate = other.m_sampleRate;
     877            1 :             m_numberOfChannels = other.m_numberOfChannels;
     878              :         }
     879              : 
     880              :         /**
     881              :          * @brief Makes a shallow copy of the segment
     882              :          *
     883              :          * @retval Shallow copy of the segment
     884              :          */
     885            1 :         std::unique_ptr<MediaSegment> copy() const override { return std::make_unique<MediaSegmentAudio>(*this); }
     886              : 
     887              :         /**
     888              :          * @brief Return the audio sample rate.
     889              :          *
     890              :          * @retval the sample rate in samples per second.
     891              :          */
     892           27 :         int32_t getSampleRate() const { return m_sampleRate; }
     893              : 
     894              :         /**
     895              :          * @brief Return the number of audio channels.
     896              :          *
     897              :          * @retval the number of channels.
     898              :          */
     899           27 :         int32_t getNumberOfChannels() const { return m_numberOfChannels; }
     900              : 
     901              :         /**
     902              :          * @brief Return the amount of audio to clip from start of buffer
     903              :          *
     904              :          * @retval the amount of audio to clip from start of buffer
     905              :          */
     906           17 :         uint64_t getClippingStart() const { return m_clippingStart; }
     907              : 
     908              :         /**
     909              :          * @brief Return the amount of audio to clip from end of buffer
     910              :          *
     911              :          * @retval the amount of audio to clip from end of buffer
     912              :          */
     913           17 :         uint64_t getClippingEnd() const { return m_clippingEnd; }
     914              : 
     915              :         /**
     916              :          * @brief Copy assignment operator.
     917              :          *
     918              :          * @retval the copy.
     919              :          */
     920              :         MediaSegmentAudio &operator=(const MediaSegmentAudio &other)
     921              :         {
     922              :             copy(other);
     923              :             return *this;
     924              :         }
     925              : 
     926              :     protected:
     927              :         /**
     928              :          * @brief Copies the data from other to this.
     929              :          */
     930              :         void copy(const MediaSegmentAudio &other);
     931              : 
     932              :         /**
     933              :          * @brief The audio sample rate.
     934              :          */
     935              :         int32_t m_sampleRate;
     936              : 
     937              :         /**
     938              :          * @brief The number of audio channels.
     939              :          */
     940              :         int32_t m_numberOfChannels;
     941              : 
     942              :         /**
     943              :          * @brief The amount of audio to clip from start of buffer
     944              :          */
     945              :         uint64_t m_clippingStart;
     946              : 
     947              :         /**
     948              :          * @brief The amount of audio to clip from end of buffer
     949              :          */
     950              :         uint64_t m_clippingEnd;
     951              :     };
     952              : 
     953              :     /**
     954              :      * @brief A class that represents media source video data
     955              :      */
     956              :     class MediaSegmentVideo : public MediaSegment
     957              :     {
     958              :     public:
     959              :         /**
     960              :          * @brief Default constructor.
     961              :          *
     962              :          * @param[in] sourceId  : The source id. Value should be set to the MediaSource.id returned after attachSource()
     963              :          * @param[in] timeStamp : The timestamp in nanoseconds.
     964              :          * @param[in] duration  : The duration in nanoseconds.
     965              :          * @param[in] width     : The video width in pixels.
     966              :          * @param[in] height    : The video height in pixels.
     967              :          * @param[in] frameRate : The fractional framerate of the sample.
     968              :          */
     969           36 :         MediaSegmentVideo(int32_t sourceId = 0, int64_t timeStamp = 0, int64_t duration = 0,
     970              :                           int32_t width = firebolt::rialto::kUndefinedSize,
     971              :                           int32_t height = firebolt::rialto::kUndefinedSize,
     972              :                           firebolt::rialto::Fraction frameRate = {firebolt::rialto::kUndefinedSize,
     973              :                                                                   firebolt::rialto::kUndefinedSize})
     974           72 :             : MediaSegment(sourceId, MediaSourceType::VIDEO, timeStamp, duration), m_width(width), m_height(height),
     975           36 :               m_frameRate(frameRate)
     976              :         {
     977              :         }
     978              : 
     979              :         /**
     980              :          * @brief Copy constructor.
     981              :          */
     982            0 :         MediaSegmentVideo(const MediaSegmentVideo &other) : MediaSegment(other)
     983              :         {
     984            0 :             m_width = other.m_width;
     985            0 :             m_height = other.m_height;
     986            0 :             m_frameRate = other.m_frameRate;
     987              :         }
     988              : 
     989              :         /**
     990              :          * @brief Makes a shallow copy of the segment
     991              :          *
     992              :          * @retval Shallow copy of the segment
     993              :          */
     994            0 :         std::unique_ptr<MediaSegment> copy() const override { return std::make_unique<MediaSegmentVideo>(*this); }
     995              : 
     996              :         /**
     997              :          * @brief Return the video width.
     998              :          *
     999              :          * @retval the video width in pixels.
    1000              :          */
    1001           27 :         int32_t getWidth() const { return m_width; }
    1002              : 
    1003              :         /**
    1004              :          * @brief Return the video height.
    1005              :          *
    1006              :          * @retval the video height in pixels.
    1007              :          */
    1008           27 :         int32_t getHeight() const { return m_height; }
    1009              : 
    1010              :         /**
    1011              :          * @brief Return the video frameRate.
    1012              :          *
    1013              :          * @retval the fractional framerate of the sample.
    1014              :          */
    1015           26 :         firebolt::rialto::Fraction getFrameRate() const { return m_frameRate; }
    1016              : 
    1017              :         /**
    1018              :          * @brief Copy assignment operator.
    1019              :          *
    1020              :          * @retval the copy.
    1021              :          */
    1022              :         MediaSegmentVideo &operator=(const MediaSegmentVideo &other)
    1023              :         {
    1024              :             copy(other);
    1025              :             return *this;
    1026              :         }
    1027              : 
    1028              :     protected:
    1029              :         /**
    1030              :          * @brief Copies the data from other to this.
    1031              :          */
    1032              :         void copy(const MediaSegmentVideo &other);
    1033              : 
    1034              :         /**
    1035              :          * @brief The video width in pixels.
    1036              :          */
    1037              :         int32_t m_width;
    1038              : 
    1039              :         /**
    1040              :          * @brief The video height in pixels.
    1041              :          */
    1042              :         int32_t m_height;
    1043              : 
    1044              :         /**
    1045              :          * @brief The fractional framerate of the sample.
    1046              :          */
    1047              :         firebolt::rialto::Fraction m_frameRate;
    1048              :     };
    1049              : 
    1050              :     /**
    1051              :      * @brief A vector that contains one or more media segments.
    1052              :      */
    1053              :     typedef std::vector<std::unique_ptr<MediaSegment>> MediaSegmentVector;
    1054              : 
    1055              :     /**
    1056              :      * @brief Returns the media player client.
    1057              :      *
    1058              :      * @retval The media player client.
    1059              :      */
    1060              :     virtual std::weak_ptr<IMediaPipelineClient> getClient() = 0;
    1061              : 
    1062              :     /**
    1063              :      * @brief Loads the media and backend delegate.
    1064              :      *
    1065              :      * This method loads the media and backend appropriate for the media.
    1066              :      * The media type determines the backend delegate to use to play back
    1067              :      * the media. The MIME type confirms the type and CODECs for the media.
    1068              :      * The URL will comprise the media URL for types MediaType::URL and
    1069              :      * MediaType::HLS. For MediaType::MSE the URL will comprise a blob URL
    1070              :      * as the data is loaded by the browser.
    1071              :      *
    1072              :      * @param[in] type     : The media type.
    1073              :      * @param[in] mimeType : The MIME type.
    1074              :      * @param[in] url      : The URL.
    1075              :      */
    1076              :     virtual bool load(MediaType type, const std::string &mimeType, const std::string &url) = 0;
    1077              : 
    1078              :     /**
    1079              :      * @brief Attaches a source stream to the backend.
    1080              :      *
    1081              :      * This method is called by Rialto Client to attach a media source stream to
    1082              :      * the backend. It is only called when Media Source Extensions are
    1083              :      * being used. I.e. if the MediaType value in load() is
    1084              :      * MediaType::MSE.
    1085              :      *
    1086              :      * @param[in] source : The source.
    1087              :      *
    1088              :      * @retval true on success.
    1089              :      */
    1090              :     virtual bool attachSource(const std::unique_ptr<MediaSource> &source) = 0;
    1091              : 
    1092              :     /**
    1093              :      * @brief Unattaches a source.
    1094              :      *
    1095              :      * This method is called by Rialto Client to detach a media source stream from
    1096              :      * the backend. It is only called when Media Source Extensions are
    1097              :      * being used. I.e. if the MediaType value in load() is
    1098              :      * MediaType::MSE.
    1099              :      *
    1100              :      * @param[in] id : The source id. Value should be set to the MediaSource.id returned after attachSource()
    1101              :      *
    1102              :      * @retval true on success.
    1103              :      */
    1104              :     virtual bool removeSource(int32_t id) = 0;
    1105              : 
    1106              :     /**
    1107              :      * @brief Notifies Rialto Server that all sources were attached
    1108              :      *
    1109              :      * This method is called by Rialto Client to notify the RialtoServer
    1110              :      * that all sources were attached.
    1111              :      *
    1112              :      * Must be called, otherwise streaming cannot commence.
    1113              :      * Can be called only once.
    1114              :      *
    1115              :      * @retval true on success.
    1116              :      */
    1117              :     virtual bool allSourcesAttached() = 0;
    1118              : 
    1119              :     /**
    1120              :      * @brief Starts playback of the media.
    1121              :      *
    1122              :      * This method is considered to be asynchronous and MUST NOT block
    1123              :      * but should request playback and then return.
    1124              :      *
    1125              :      * Once the backend is successfully playing it should notify the
    1126              :      * media player client of playback state
    1127              :      * IMediaPipelineClient::PlaybackState::PLAYING.
    1128              :      *
    1129              :      * @retval true on success.
    1130              :      */
    1131              :     virtual bool play() = 0;
    1132              : 
    1133              :     /**
    1134              :      * @brief Pauses playback of the media.
    1135              :      *
    1136              :      * This method is considered to be asynchronous and MUST NOT block
    1137              :      * but should request the playback pause and then return.
    1138              :      *
    1139              :      * Once the backend is successfully playing it should notify the
    1140              :      * media player client of playback state
    1141              :      *IMediaPipelineClient::PlaybackState::PAUSED.
    1142              :      *
    1143              :      * @retval true on success.
    1144              :      */
    1145              :     virtual bool pause() = 0;
    1146              : 
    1147              :     /**
    1148              :      * @brief Stops playback of the media.
    1149              :      *
    1150              :      * This method is considered to be asynchronous and MUST NOT block
    1151              :      * but should request the playback stop and then return.
    1152              :      *
    1153              :      * Once the backend is successfully stopped it should notify the
    1154              :      * media player client of playback state
    1155              :      * IMediaPipelineClient::PlaybackState::STOPPED.
    1156              :      *
    1157              :      * @retval true on success.
    1158              :      */
    1159              :     virtual bool stop() = 0;
    1160              : 
    1161              :     /**
    1162              :      * @brief Set the playback rate
    1163              :      *
    1164              :      * This method sets the playback rate. The supported playback rates
    1165              :      * are dependent upon the backend playback method.
    1166              :      *
    1167              :      * @param[in] rate : The playback rate.
    1168              :      *
    1169              :      * @retval true on success.
    1170              :      */
    1171              :     virtual bool setPlaybackRate(double rate) = 0;
    1172              : 
    1173              :     /**
    1174              :      * @brief Set the playback position in nanoseconds.
    1175              :      *
    1176              :      * If playback has not started this method sets the start position
    1177              :      * for playback. If playback has started this method performs a seek.
    1178              :      *
    1179              :      * This method is considered to be asynchronous and MUST NOT block
    1180              :      * but should request the new playback position and then return.
    1181              :      *
    1182              :      * Once the backend is seeking it should notify the media player
    1183              :      * client of playback state
    1184              :      * IMediaPipelineClient::PlaybackState::SEEKING. When seeking has
    1185              :      * completed the state IMediaPipelineClient::PlaybackState::SEEK_DONE
    1186              :      * should be notified followed by
    1187              :      * IMediaPipelineClient::PlaybackState::PLAYING.
    1188              :      *
    1189              :      * @param[in] position : The playback position in nanoseconds.
    1190              :      *
    1191              :      * @retval true on success.
    1192              :      */
    1193              :     virtual bool setPosition(int64_t position) = 0;
    1194              : 
    1195              :     /**
    1196              :      * @brief Get the playback position in nanoseconds.
    1197              :      *
    1198              :      * This method is sychronous, it returns current playback position
    1199              :      *
    1200              :      * @param[out] position : The playback position in nanoseconds
    1201              :      *
    1202              :      * @retval true on success.
    1203              :      */
    1204              :     virtual bool getPosition(int64_t &position) = 0;
    1205              : 
    1206              :     /**
    1207              :      * @brief Get stats for this source.
    1208              :      *
    1209              :      * This method is sychronous, it returns dropped frames and rendered frames
    1210              :      *
    1211              :      * @param[in] sourceId  : The source id. Value should be set to the MediaSource.id returned after attachSource()
    1212              :      * @param[out] renderedFrames : The number of rendered frames
    1213              :      * @param[out] droppedFrames : The number of dropped frames
    1214              :      *
    1215              :      * @retval true on success.
    1216              :      */
    1217              :     virtual bool getStats(int32_t sourceId, uint64_t &renderedFrames, uint64_t &droppedFrames) = 0;
    1218              : 
    1219              :     /**
    1220              :      * @brief Sets the "Immediate Output" property for this source.
    1221              :      *
    1222              :      * This method is asynchronous, it will set the "Immediate Output" property
    1223              :      *
    1224              :      * @param[in] sourceId  : The source id. Value should be set to the MediaSource.id returned after attachSource()
    1225              :      * @param[in] immediateOutput : Set immediate output mode on the sink
    1226              :      *
    1227              :      * @retval true on success.
    1228              :      */
    1229              :     virtual bool setImmediateOutput(int32_t sourceId, bool immediateOutput) = 0;
    1230              : 
    1231              :     /**
    1232              :      * @brief Gets the "Immediate Output" property for this source.
    1233              :      *
    1234              :      * This method is sychronous, it gets the "Immediate Output" property
    1235              :      *
    1236              :      * @param[in] sourceId  : The source id. Value should be get to the MediaSource.id returned after attachSource()
    1237              :      * @param[out] immediateOutput : Get immediate output mode on the sink
    1238              :      *
    1239              :      * @retval true on success.
    1240              :      */
    1241              :     virtual bool getImmediateOutput(int32_t sourceId, bool &immediateOutput) = 0;
    1242              : 
    1243              :     /**
    1244              :      * @brief Sets the coordinates of where the video should be displayed.
    1245              :      *
    1246              :      * @param[in] x      : The x position in pixels.
    1247              :      * @param[in] y      : The y position in pixels.
    1248              :      * @param[in] width  : The width in pixels.
    1249              :      * @param[in] height : The height in pixels.
    1250              :      *
    1251              :      * @retval true on success.
    1252              :      */
    1253              :     virtual bool setVideoWindow(uint32_t x, uint32_t y, uint32_t width, uint32_t height) = 0;
    1254              : 
    1255              :     /**
    1256              :      * @brief Returns data requested using notifyNeedMediaData().
    1257              :      *
    1258              :      * This method is called as a result of calling notifyNeedMediaData() on
    1259              :      * the media client. The status value indicates the success or
    1260              :      * otherwise of the request. The client must first call addSegment() for
    1261              :      * for each media segment to be sent.
    1262              :      * A status of MediaSourceStatus::OK indicates success and there will
    1263              :      * be data within the data vector. A status of MediaSourceStatus::EOS
    1264              :      * indicates success but the end of the stream was reached. Again
    1265              :      * there will be data in the vector. A status of
    1266              :      * MediaSourceStatus::ERROR indicates an error occurred and no data
    1267              :      * was returned.
    1268              :      *
    1269              :      *
    1270              :      * @param[in] status : The status
    1271              :      * @param[in] needDataRequestId : Need data request id
    1272              :      */
    1273              :     virtual bool haveData(MediaSourceStatus status, uint32_t needDataRequestId) = 0;
    1274              : 
    1275              :     /**
    1276              :      * @brief Adds a single segment to Rialto in response to notifyNeedData()
    1277              :      *
    1278              :      * This method is should be called by the client as a result of a notifyNeedData()
    1279              :      * notification. The client should call this API for each segment to be sent in
    1280              :      * response to the notification and then call haveData() when all segments
    1281              :      * have been 'added'.
    1282              :      *
    1283              :      * If the return code is NO_SPACE the segment has not been accepted but this is
    1284              :      * not an error. The client should retain the segment until the next notifyNeedData()
    1285              :      * is received for the source and immediately call haveData() to trigger Rialto
    1286              :      * to start processing the segments already added.
    1287              :      *
    1288              :      * @param[in] needDataRequestId : The status
    1289              :      * @param[in] mediaSegment : The data returned.
    1290              :      *
    1291              :      * @retval status of adding segment
    1292              :      */
    1293              :     virtual AddSegmentStatus addSegment(uint32_t needDataRequestId, const std::unique_ptr<MediaSegment> &mediaSegment) = 0;
    1294              : 
    1295              :     /**
    1296              :      * @brief Requests to render a prerolled frame
    1297              :      */
    1298              :     virtual bool renderFrame() = 0;
    1299              : 
    1300              :     /**
    1301              :      * @brief Set the target volume level and transition duration with easing type.
    1302              :      *        By default volume is set immediately if duration and type are not set.
    1303              :      *
    1304              :      * @param[in] targetVolume : Target volume level (0.0 - 1.0)
    1305              :      * @param[in] volumeDuration : (Optional) Duration of the volume transition in milliseconds
    1306              :      * @param[in] easeType : (Optional) Easing type for the volume transition
    1307              :      *
    1308              :      * @retval true on success, false otherwise.
    1309              :      */
    1310              :     virtual bool setVolume(double targetVolume, uint32_t volumeDuration = 0,
    1311              :                            EaseType easeType = EaseType::EASE_LINEAR) = 0;
    1312              : 
    1313              :     /**
    1314              :      * @brief Get current audio level. Fetches the current volume level for the pipeline.
    1315              :      *
    1316              :      * @param[out] currentVolume : Current volume level (range 0.0 - 1.0)
    1317              :      *
    1318              :      * @retval true on success, false otherwise.
    1319              :      */
    1320              :     virtual bool getVolume(double &currentVolume) = 0;
    1321              : 
    1322              :     /**
    1323              :      * @brief Set mute status of pipeline.
    1324              :      *
    1325              :      * Change mute status of media source
    1326              :      *
    1327              :      * @param[in] sourceId Source, which mute status should be changed
    1328              :      * @param[in] mute   Desired mute state, true=muted, false=not muted
    1329              :      *
    1330              :      * @retval true on success false otherwise
    1331              :      */
    1332              :     virtual bool setMute(int32_t sourceId, bool mute) = 0;
    1333              : 
    1334              :     /**
    1335              :      * @brief Get current mute status of the media source
    1336              :      *
    1337              :      * @param[in] sourceId Source, which mute status should be fetched
    1338              :      * @param[out] mute   Current mute state
    1339              :      *
    1340              :      * @retval true on success false otherwise
    1341              :      */
    1342              :     virtual bool getMute(int32_t sourceId, bool &mute) = 0;
    1343              : 
    1344              :     /**
    1345              :      * @brief Change Text Track Identifier
    1346              :      *
    1347              :      * @param[in] textTrackIdentifier Text track identifier of subtitle stream
    1348              :      *
    1349              :      * @retval true on success false otherwise
    1350              :      */
    1351              :     virtual bool setTextTrackIdentifier(const std::string &textTrackIdentifier) = 0;
    1352              : 
    1353              :     /**
    1354              :      * @brief Get Text Track Identifier
    1355              :      *
    1356              :      * @param[in] textTrackIdentifier Text track identifier of subtitle stream
    1357              :      *
    1358              :      * @retval true on success false otherwise
    1359              :      */
    1360              :     virtual bool getTextTrackIdentifier(std::string &textTrackIdentifier) = 0;
    1361              : 
    1362              :     /**
    1363              :      * @brief Set low latency property on the audio sink. Default false.
    1364              :      *
    1365              :      * For use with gaming (no audio decoding, no a/v sync).
    1366              :      *
    1367              :      * @param[in] lowLatency : The low latency value to set.
    1368              :      *
    1369              :      * @retval true on success false otherwise
    1370              :      */
    1371              :     virtual bool setLowLatency(bool lowLatency) = 0;
    1372              : 
    1373              :     /**
    1374              :      * @brief Set sync property on the audio sink. Default false.
    1375              :      *
    1376              :      * Syncs the stream on the clock.
    1377              :      *
    1378              :      * @param[in] sync : The sync value to set.
    1379              :      *
    1380              :      * @retval true on success false otherwise
    1381              :      */
    1382              :     virtual bool setSync(bool sync) = 0;
    1383              : 
    1384              :     /**
    1385              :      * @brief Get sync property on the audio sink.
    1386              :      *
    1387              :      * @param[out] sync : Current sync value.
    1388              :      *
    1389              :      * @retval true on success false otherwise
    1390              :      */
    1391              :     virtual bool getSync(bool &sync) = 0;
    1392              : 
    1393              :     /**
    1394              :      * @brief Set sync off property on the audio decoder. Default false.
    1395              :      *
    1396              :      * Turn on free running audio. Must be set before pipeline is PLAYING state.
    1397              :      *
    1398              :      * @param[in] syncOff : The sync off value to set.
    1399              :      *
    1400              :      * @retval true on success false otherwise
    1401              :      */
    1402              :     virtual bool setSyncOff(bool syncOff) = 0;
    1403              : 
    1404              :     /**
    1405              :      * @brief Set stream sync mode property on the audio decoder or video filter. Default 0.
    1406              :      *
    1407              :      * 1 - Frame to decode frame will immediately proceed next frame sync.
    1408              :      * 0 - Frame decoded with no frame sync.
    1409              :      *
    1410              :      * @param[in] sourceId  : The source id. Value should be set to the MediaSource.id returned after attachSource()
    1411              :      * @param[in] streamSyncMode : The stream sync mode value to set.
    1412              :      *
    1413              :      * @retval true on success false otherwise
    1414              :      */
    1415              :     virtual bool setStreamSyncMode(int32_t sourceId, int32_t streamSyncMode) = 0;
    1416              : 
    1417              :     /**
    1418              :      * @brief Get stream sync mode property on the audio decoder.
    1419              :      *
    1420              :      * @param[out] streamSyncMode : Current stream sync mode value.
    1421              :      *
    1422              :      * @retval true on success false otherwise
    1423              :      */
    1424              :     virtual bool getStreamSyncMode(int32_t &streamSyncMode) = 0;
    1425              : 
    1426              :     /**
    1427              :      * @brief Flushes a source.
    1428              :      *
    1429              :      * This method is called by Rialto Client to flush out all queued data for a media source stream.
    1430              :      *
    1431              :      * @param[in]  sourceId  : The source id. Value should be set to the MediaSource.id returned after attachSource()
    1432              :      * @param[in]  resetTime : True if time should be reset
    1433              :      * @param[out] async     : True if flushed source is asynchronous (will preroll after flush)
    1434              :      *
    1435              :      * @retval true on success.
    1436              :      */
    1437              :     virtual bool flush(int32_t sourceId, bool resetTime, bool &async) = 0;
    1438              : 
    1439              :     /**
    1440              :      * @brief Set the source position in nanoseconds.
    1441              :      *
    1442              :      * This method sets the start position for a source.
    1443              :      *
    1444              :      * @param[in] sourceId    : The source id. Value should be set to the MediaSource.id returned after attachSource()
    1445              :      * @param[in] position    : The position in nanoseconds.
    1446              :      * @param[in] resetTime   : True if time should be reset
    1447              :      * @param[in] appliedRate : The applied rate after seek. Default value is 1.0.
    1448              :      * @param[in] stopPosition : The position of last pushed buffer
    1449              :      *
    1450              :      * @retval true on success.
    1451              :      */
    1452              :     virtual bool setSourcePosition(int32_t sourceId, int64_t position, bool resetTime = false, double appliedRate = 1.0,
    1453              :                                    uint64_t stopPosition = kUndefinedPosition) = 0;
    1454              : 
    1455              :     /**
    1456              :      * @brief Process audio gap
    1457              :      *
    1458              :      * This method handles audio gap in order to avoid audio pops during transitions.
    1459              :      *
    1460              :      * @param[in] position         : Audio pts fade position
    1461              :      * @param[in] duration         : Audio pts fade duration
    1462              :      * @param[in] discontinuityGap : Audio discontinuity gap
    1463              :      * @param[in] audioAac         : True if audio codec is AAC
    1464              :      *
    1465              :      * @retval true on success.
    1466              :      */
    1467              :     virtual bool processAudioGap(int64_t position, uint32_t duration, int64_t discontinuityGap, bool audioAac) = 0;
    1468              : 
    1469              :     /**
    1470              :      * @brief Set buffering limit
    1471              :      *
    1472              :      * This method enables/disables limit buffering and sets millisecond threshold used.
    1473              :      * Use kInvalidLimitBuffering to disable limit buffering
    1474              :      *
    1475              :      * @param[in] limitBufferingMs         : buffering limit in ms
    1476              :      *
    1477              :      * @retval true on success.
    1478              :      */
    1479              :     virtual bool setBufferingLimit(uint32_t limitBufferingMs) = 0;
    1480              : 
    1481              :     /**
    1482              :      * @brief Get buffering limit
    1483              :      *
    1484              :      * This method returns current value of buffering limit in milliseconds
    1485              :      * Method will return kInvalidLimitBuffering limit buffering is disabled
    1486              :      *
    1487              :      * @param[out] limitBufferingMs         : buffering limit in ms
    1488              :      *
    1489              :      * @retval true on success.
    1490              :      */
    1491              :     virtual bool getBufferingLimit(uint32_t &limitBufferingMs) = 0;
    1492              : 
    1493              :     /**
    1494              :      * @brief Enables/disables the buffering option
    1495              :      *
    1496              :      * This method enables the buffering option so that BUFFERING messages are
    1497              :      * emitted based on low-/high-percent thresholds.
    1498              :      *
    1499              :      * @param[in] useBuffering         : true if buffering option enabled.
    1500              :      *
    1501              :      * @retval true on success.
    1502              :      */
    1503              :     virtual bool setUseBuffering(bool useBuffering) = 0;
    1504              : 
    1505              :     /**
    1506              :      * @brief Checks, if buffering is enabled
    1507              :      *
    1508              :      * This method returns true, if buffering is enabled
    1509              :      *
    1510              :      * @param[out] useBuffering         : true if buffering option is enabled.
    1511              :      *
    1512              :      * @retval true on success.
    1513              :      */
    1514              :     virtual bool getUseBuffering(bool &useBuffering) = 0;
    1515              : 
    1516              :     /**
    1517              :      * @brief Switches a source stream.
    1518              :      *
    1519              :      * This method is called to switch a media source stream.
    1520              :      *
    1521              :      * @param[in] source : The source.
    1522              :      *
    1523              :      * @retval true on success.
    1524              :      */
    1525              :     virtual bool switchSource(const std::unique_ptr<MediaSource> &source) = 0;
    1526              : };
    1527              : 
    1528              : }; // namespace firebolt::rialto
    1529              : 
    1530              : #endif // FIREBOLT_RIALTO_I_MEDIA_PIPELINE_H_
        

Generated by: LCOV version 2.0-1