LCOV - code coverage report
Current view: top level - media/server/metrics/include - IRialtoMetrics.h (source / functions) Coverage Total Hit
Test: coverage.info Lines: 100.0 % 2 2
Test Date: 2026-12-04 20:46:59 Functions: 100.0 % 2 2

            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 2025 Sky UK
       6              :  *
       7              :  * Licensed under the Apache License, Version 2.0 (the "License");
       8              :  * you may not use this file except in compliance with the License.
       9              :  * You may obtain a copy of the License at
      10              :  *
      11              :  * http://www.apache.org/licenses/LICENSE-2.0
      12              :  *
      13              :  * Unless required by applicable law or agreed to in writing, software
      14              :  * distributed under the License is distributed on an "AS IS" BASIS,
      15              :  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
      16              :  * See the License for the specific language governing permissions and
      17              :  * limitations under the License.
      18              :  */
      19              : 
      20              : #ifndef FIREBOLT_RIALTO_SERVER_I_RIALTO_METRICS_H_
      21              : #define FIREBOLT_RIALTO_SERVER_I_RIALTO_METRICS_H_
      22              : 
      23              : #include <MediaCommon.h>
      24              : #include <gst/gst.h>
      25              : 
      26              : #include <cstdint>
      27              : #include <functional>
      28              : #include <optional>
      29              : #include <utility>
      30              : 
      31              : namespace firebolt::rialto::wrappers
      32              : {
      33              : class IGlibWrapper;
      34              : class IGstWrapper;
      35              : } // namespace firebolt::rialto::wrappers
      36              : 
      37              : namespace firebolt::rialto::server
      38              : {
      39              : class ElementToSourceMapper;
      40              : 
      41              : /**
      42              :  * Server-side cache entry: the public frame counters plus the monotonic time they were last updated.
      43              :  */
      44              : struct CounterSnapshot
      45              : {
      46              :     VideoFrameCounters counters;
      47              :     uint64_t timestamp{0};
      48              : };
      49              : 
      50              : class IRialtoMetrics
      51              : {
      52              : public:
      53              :     /**
      54              :      * Reads the current rendered/dropped counts from a sink. Returns false if they are unavailable.
      55              :      */
      56              :     using SinkStatsGetter = std::function<bool(const MediaSourceType &mediaSourceType, std::uint64_t &renderedFrames,
      57              :                                                std::uint64_t &droppedFrames)>;
      58              : 
      59          276 :     virtual ~IRialtoMetrics() = default;
      60              :     virtual void setSessionId(int32_t sessionId) = 0;
      61              :     virtual std::optional<MetricEvent> onMetricMessage(GstMessage *message) = 0;
      62              :     virtual void updateFrameCounters(int32_t sessionId, int32_t sourceId, const CounterSnapshot &snapshot) = 0;
      63              :     virtual void updateSinkStats(int32_t sessionId, int32_t sourceId, std::uint64_t renderedFrames,
      64              :                                  std::uint64_t droppedFrames) = 0;
      65              :     virtual bool getFrameCounters(int32_t sessionId, int32_t sourceId, const MediaSourceType &mediaSourceType,
      66              :                                   CounterSnapshot &snapshot) = 0;
      67              :     virtual ElementToSourceMapper *getElementToSourceMapper() = 0;
      68              : };
      69              : 
      70              : class ElementToSourceMapper
      71              : {
      72              : public:
      73          276 :     virtual ~ElementToSourceMapper() = default;
      74              :     virtual void RegisterElement(GstElement *element, uint32_t session_id, uint32_t source_id) = 0;
      75              :     virtual bool MapElement(GstElement *element, uint32_t &out_session_id, uint32_t &out_source_id) = 0;
      76              :     virtual void UnregisterElement(GstElement *element) = 0;
      77              :     virtual void UnregisterAllElements() = 0;
      78              : };
      79              : 
      80              : GstFlowReturn validateMediaPipelineMetric(const GstStructure *msg, MetricEvent &out, GstMessage *gstMessage = nullptr,
      81              :                                           ElementToSourceMapper *mapper = nullptr, int32_t *outSessionId = nullptr);
      82              : 
      83              : GstFlowReturn validateMediaPipelineMetric(const wrappers::IGstWrapper &gstWrapper,
      84              :                                           const wrappers::IGlibWrapper &glibWrapper, const GstStructure *msg,
      85              :                                           MetricEvent &out, GstMessage *gstMessage, ElementToSourceMapper *mapper,
      86              :                                           int32_t *outSessionId);
      87              : 
      88              : } // namespace firebolt::rialto::server
      89              : 
      90              : #endif // FIREBOLT_RIALTO_SERVER_I_RIALTO_METRICS_H_
        

Generated by: LCOV version 2.0-1