LCOV - code coverage report
Current view: top level - media/server/gstplayer/include - GenericPlayerContext.h (source / functions) Coverage Total Hit
Test: coverage.info Lines: 100.0 % 4 4
Test Date: 2025-02-18 13:13:53 Functions: 100.0 % 4 4

            Line data    Source code
       1              : /*
       2              :  * If not stated otherwise in this file or this component's LICENSE file the
       3              :  * following copyright and licenses apply:
       4              :  *
       5              :  * Copyright 2022 Sky UK
       6              :  *
       7              :  * Licensed under the Apache License, Version 2.0 (the "License");
       8              :  * you may not use this file except in compliance with the License.
       9              :  * You may obtain a copy of the License at
      10              :  *
      11              :  * http://www.apache.org/licenses/LICENSE-2.0
      12              :  *
      13              :  * Unless required by applicable law or agreed to in writing, software
      14              :  * distributed under the License is distributed on an "AS IS" BASIS,
      15              :  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
      16              :  * See the License for the specific language governing permissions and
      17              :  * limitations under the License.
      18              :  */
      19              : 
      20              : #ifndef FIREBOLT_RIALTO_SERVER_GENERIC_PLAYER_CONTEXT_H_
      21              : #define FIREBOLT_RIALTO_SERVER_GENERIC_PLAYER_CONTEXT_H_
      22              : 
      23              : #include "IGstSrc.h"
      24              : #include "IRdkGstreamerUtilsWrapper.h"
      25              : #include "ITimer.h"
      26              : #include "MediaCommon.h"
      27              : #include <gst/gst.h>
      28              : #include <list>
      29              : #include <map>
      30              : #include <memory>
      31              : #include <mutex>
      32              : #include <unordered_map>
      33              : #include <vector>
      34              : 
      35              : namespace firebolt::rialto::server
      36              : {
      37              : constexpr double kNoPendingPlaybackRate{0.0};
      38              : 
      39              : enum class EosState
      40              : {
      41              :     PENDING,
      42              :     SET
      43              : };
      44              : 
      45              : /**
      46              :  * @brief Structure used for video geometry
      47              :  */
      48              : struct Rectangle
      49              : {
      50              :     int x, y, width, height;
      51          476 :     constexpr Rectangle() : x(0), y(0), width(0), height(0) {}
      52            1 :     constexpr Rectangle(int x_, int y_, int w_, int h_) : x(x_), y(y_), width(w_), height(h_) {}
      53              :     Rectangle(const Rectangle &rhs) = default;
      54            9 :     inline constexpr bool empty() { return (width == 0) || (height == 0); }
      55            2 :     inline void clear() { x = y = width = height = 0; }
      56              : };
      57              : 
      58              : /**
      59              :  * @brief Structure used for set source position
      60              :  */
      61              : struct SegmentData
      62              : {
      63              :     int64_t position;
      64              :     bool resetTime;
      65              :     double appliedRate;
      66              :     uint64_t stopPosition;
      67              : };
      68              : 
      69              : struct GenericPlayerContext
      70              : {
      71              :     /**
      72              :      * @brief The rialto src object.
      73              :      */
      74              :     std::shared_ptr<IGstSrc> gstSrc{nullptr};
      75              : 
      76              :     /**
      77              :      * @brief The gstreamer pipeline.
      78              :      */
      79              :     GstElement *pipeline{nullptr};
      80              : 
      81              :     /**
      82              :      * @brief The gstreamer source.
      83              :      */
      84              :     GstElement *source{nullptr};
      85              : 
      86              :     /**
      87              :      * @brief A map of streams attached to the source.
      88              :      */
      89              :     StreamInfoMap streamInfo{};
      90              : 
      91              :     /**
      92              :      * @brief Child sink of the autovideosink.
      93              :      */
      94              :     GstElement *autoVideoChildSink{nullptr};
      95              : 
      96              :     /**
      97              :      * @brief Child sink of the autoaudiosink.
      98              :      */
      99              :     GstElement *autoAudioChildSink{nullptr};
     100              : 
     101              :     /**
     102              :      * @brief The subtitle sink
     103              :      */
     104              :     GstElement *subtitleSink{nullptr};
     105              : 
     106              :     /**
     107              :      * @brief Flag used to check, if BUFFERED notification has been sent.
     108              :      *
     109              :      * Flag can be used only in worker thread
     110              :      */
     111              :     bool bufferedNotificationSent{false};
     112              : 
     113              :     /**
     114              :      * @brief Flag used to check, if the playback is in the playing state
     115              :      *
     116              :      * Flag can be used only in worker thread
     117              :      */
     118              :     bool isPlaying{false};
     119              : 
     120              :     /**
     121              :      * @brief Flag used to check, if EOS has been notified to the client
     122              :      *
     123              :      * Flag can be used only in worker thread
     124              :      */
     125              :     bool eosNotified{false};
     126              : 
     127              :     /**
     128              :      * @brief Pending video geometry
     129              :      */
     130              :     Rectangle pendingGeometry;
     131              : 
     132              :     /**
     133              :      * @brief Current playback rate
     134              :      */
     135              :     double playbackRate{1.0};
     136              : 
     137              :     /**
     138              :      * @brief Pending playback rate
     139              :      */
     140              :     double pendingPlaybackRate{kNoPendingPlaybackRate};
     141              : 
     142              :     /**
     143              :      * @brief Pending immediate output for MediaSourceType::VIDEO
     144              :      */
     145              :     std::optional<bool> pendingImmediateOutputForVideo{};
     146              : 
     147              :     /**
     148              :      * @brief Pending low latency
     149              :      */
     150              :     std::optional<bool> pendingLowLatency{};
     151              : 
     152              :     /**
     153              :      * @brief Pending sync
     154              :      */
     155              :     std::optional<bool> pendingSync{};
     156              : 
     157              :     /**
     158              :      * @brief Pending sync off
     159              :      */
     160              :     std::optional<bool> pendingSyncOff{};
     161              : 
     162              :     /**
     163              :      * @brief Pending buffering limit
     164              :      */
     165              :     std::optional<uint32_t> pendingBufferingLimit{};
     166              : 
     167              :     /**
     168              :      * @brief Pending use buffering
     169              :      */
     170              :     std::optional<bool> pendingUseBuffering{};
     171              : 
     172              :     /**
     173              :      * @brief Pending stream sync mode
     174              :      */
     175              :     std::map<MediaSourceType, int32_t> pendingStreamSyncMode{};
     176              : 
     177              :     /**
     178              :      * @brief Pending render frame
     179              :      */
     180              :     bool pendingRenderFrame{false};
     181              : 
     182              :     /**
     183              :      * @brief Last audio sample timestamps
     184              :      * TODO(LLDEV-31012) Needed to detect audio stream underflow
     185              :      */
     186              :     int64_t lastAudioSampleTimestamps{0};
     187              : 
     188              :     /**
     189              :      * @brief The decryption service.
     190              :      */
     191              :     IDecryptionService *decryptionService{nullptr};
     192              : 
     193              :     /**
     194              :      * @brief Flag used to check, if audio source has been recently removed
     195              :      *
     196              :      * Flag can be used only in worker thread
     197              :      */
     198              :     bool audioSourceRemoved{false};
     199              : 
     200              :     /**
     201              :      * @brief Audio elements of gst pipeline.
     202              :      *
     203              :      * Attribute can be used only in worker thread
     204              :      */
     205              :     firebolt::rialto::wrappers::PlaybackGroupPrivate playbackGroup;
     206              : 
     207              :     /**
     208              :      * @brief A map of streams that have ended.
     209              :      */
     210              :     std::unordered_map<MediaSourceType, EosState> endOfStreamInfo{};
     211              : 
     212              :     /**
     213              :      * @brief Flag used to check if client already notified server that all sources were attached
     214              :      *
     215              :      * Attribute can be used only in worker thread
     216              :      */
     217              :     bool wereAllSourcesAttached{false};
     218              : 
     219              :     /**
     220              :      * @brief Flag used to check if FinishSetupSource is finished. It is needed to avoid need data overwriting.
     221              :      *
     222              :      * Attribute can be used only in worker thread
     223              :      */
     224              :     bool setupSourceFinished{false};
     225              : 
     226              :     /**
     227              :      * @brief Queued source positions. Used by SetSourcePosition task to request pushing new sample.
     228              :      *
     229              :      * Attribute can be used only in worker thread
     230              :      */
     231              :     std::map<GstElement *, std::vector<SegmentData>> initialPositions;
     232              : 
     233              :     /**
     234              :      * @brief The mutex, which protects properties, which are read/written by main/worker thread.
     235              :      *        This mutex should be removed in future, when we find out better solution for
     236              :      *        property read-write.
     237              :      */
     238              :     std::mutex propertyMutex;
     239              : 
     240              :     /**
     241              :      * @brief Flag used to check if audio fade is enabled
     242              :      *
     243              :      * Attribute can be used only in worker thread
     244              :      */
     245              :     std::atomic_bool audioFadeEnabled{false};
     246              : };
     247              : } // namespace firebolt::rialto::server
     248              : 
     249              : #endif // FIREBOLT_RIALTO_SERVER_GENERIC_PLAYER_CONTEXT_H_
        

Generated by: LCOV version 2.0-1