LCOV - code coverage report
Current view: top level - media/server/gstplayer/interface - IGstGenericPlayerClient.h (source / functions) Coverage Total Hit
Test: coverage.info Lines: 100.0 % 2 2
Test Date: 2026-07-07 06:27:16 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 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_I_GST_GENERIC_PLAYER_CLIENT_H_
      21              : #define FIREBOLT_RIALTO_SERVER_I_GST_GENERIC_PLAYER_CLIENT_H_
      22              : 
      23              : #include <MediaCommon.h>
      24              : #include <stdint.h>
      25              : #include <string>
      26              : 
      27              : /**
      28              :  * @file IGstGenericPlayerClient.h
      29              :  *
      30              :  * The definition of the IGstGenericPlayerClient interface.
      31              :  *
      32              :  * This file comprises the definition of the IGstGenericPlayerClient abstract
      33              :  * class. This is the API by which a IGstGenericPlayer implementation will
      34              :  * pass notifications to its client.
      35              :  */
      36              : 
      37              : namespace firebolt::rialto::server
      38              : {
      39              : /**
      40              :  * @brief The Rialto gstreamer player client interface.
      41              :  *
      42              :  * This is The Rialto gstreamer player client abstract base class. It should be
      43              :  * implemented by any object that wishes to be notified by changes in the
      44              :  * state of the gstreamer player or that provides data for playback.
      45              :  */
      46              : class IGstGenericPlayerClient
      47              : {
      48              : public:
      49          664 :     IGstGenericPlayerClient() = default;
      50          664 :     virtual ~IGstGenericPlayerClient() = default;
      51              : 
      52              :     IGstGenericPlayerClient(const IGstGenericPlayerClient &) = delete;
      53              :     IGstGenericPlayerClient &operator=(const IGstGenericPlayerClient &) = delete;
      54              :     IGstGenericPlayerClient(IGstGenericPlayerClient &&) = delete;
      55              :     IGstGenericPlayerClient &operator=(IGstGenericPlayerClient &&) = delete;
      56              : 
      57              :     /**
      58              :      * @brief Notifies the client of the playback state.
      59              :      *
      60              :      * The player will start IDLE. Once play() has been called the player
      61              :      * will be PLAYING, or once pause() has been called the player will be
      62              :      * PAUSED. A seek() request will result in SEEKING and once the seek
      63              :      * is complete SEEK_DONE will be issued followed by PLAYING. The STOPPED
      64              :      * state will be issued after a stop() request.
      65              :      *
      66              :      * @param[in] state : The new playback state.
      67              :      */
      68              :     virtual void notifyPlaybackState(PlaybackState state) = 0;
      69              : 
      70              :     /**
      71              :      * @brief Notifies the client that we need media data.
      72              :      *
      73              :      * This method notifies the client that we need media data from the
      74              :      * client. This is only used when Media Source Extensions are used.
      75              :      * In that case media is read by JavaScript and buffered by the
      76              :      * browser before being passed to this API for decoding.
      77              :      *
      78              :      * You cannot request data if a data request is currently pending.
      79              :      *
      80              :      * The frames the client sends should meet the criteria:
      81              :      *     numFramesSent <= frameCount
      82              :      *     numBytesSent <= maxBytes
      83              :      *
      84              :      * @param[in] mediaSourceType      : The media type of source to read data from.
      85              :      *
      86              :      * @retval True on success.
      87              :      */
      88              :     virtual bool notifyNeedMediaData(MediaSourceType mediaSourceType) = 0;
      89              : 
      90              :     /**
      91              :      * @brief Notifies the client that we need media data with a delay.
      92              :      *
      93              :      * This method notifies the client that we need media data from the
      94              :      * client. This is only used when Media Source Extensions are used.
      95              :      * In that case media is read by JavaScript and buffered by the
      96              :      * browser before being passed to this API for decoding.
      97              :      *
      98              :      * You cannot request data if a data request is currently pending.
      99              :      *
     100              :      * The frames the client sends should meet the criteria:
     101              :      *     numFramesSent <= frameCount
     102              :      *     numBytesSent <= maxBytes
     103              :      *
     104              :      * @param[in] mediaSourceType      : The media type of source to read data from.
     105              :      *
     106              :      * @retval True on success.
     107              :      */
     108              :     virtual bool notifyNeedMediaDataWithDelay(MediaSourceType mediaSourceType) = 0;
     109              : 
     110              :     /**
     111              :      * @brief Notifies the client of the current playback position.
     112              :      *
     113              :      * This method notifies the client of the current playback position
     114              :      * in nanoseconds.
     115              :      *
     116              :      * When playing this should be called often enough to provide
     117              :      * sufficient granularity of position reporting. Typically this will
     118              :      * be every 0.25s.
     119              :      *
     120              :      * @param[in] position : The playback position in nanoseconds.
     121              :      *
     122              :      */
     123              :     virtual void notifyPosition(std::int64_t position) = 0;
     124              : 
     125              :     /**
     126              :      * @brief Notifies the client of the network state.
     127              :      *
     128              :      * The network state reflects the state of the network. For backend
     129              :      * streaming, say using MediaPipelineURLDelegate, this is important
     130              :      * as the backend uses the network to obtain the media data directly.
     131              :      *
     132              :      * For streaming that uses the browser to obtain data, say Media Source
     133              :      * Extensions playback, only the states NetworkState::IDLE,
     134              :      * NetworkState::BUFFERED and NetworkState::DECODE_ERROR should be
     135              :      * indicated by the backend.
     136              :      *
     137              :      * @param[in] state : The new network state.
     138              :      *
     139              :      */
     140              :     virtual void notifyNetworkState(NetworkState state) = 0;
     141              : 
     142              :     /**
     143              :      * @brief Clears all active NeedMediaDataRequests cache for session
     144              :      *
     145              :      */
     146              :     virtual void clearActiveRequestsCache() = 0;
     147              : 
     148              :     /**
     149              :      * @brief Clears all active NeedMediaDataRequests cache for given Media Source Type
     150              :      *
     151              :      * @param[in] type : Media source type.
     152              :      *
     153              :      */
     154              :     virtual void invalidateActiveRequests(const MediaSourceType &type) = 0;
     155              : 
     156              :     /**
     157              :      * @brief Notifies the client of a Quality Of Service update from the Player.
     158              :      *
     159              :      * @param[in] qosInfo       : The Qos infomation extracted from the message.
     160              :      * @param[in] sourceType    : The type of source that sent the message.
     161              :      */
     162              :     virtual void notifyQos(MediaSourceType mediaSourceType, const QosInfo &qosInfo) = 0;
     163              : 
     164              :     /**
     165              :      * @brief Notifies the client that buffer underflow occurred.
     166              :      *
     167              :      * Notification shall be sent whenever a video/audio buffer underflow occurs
     168              :      *
     169              :      * @param[in] mediaSourceType  : The type of the source that produced the buffer underflow
     170              :      */
     171              :     virtual void notifyBufferUnderflow(MediaSourceType mediaSourceType) = 0;
     172              : 
     173              :     /**
     174              :      * @brief Notifies the client that the first frame has been received.
     175              :      *
     176              :      * Notification shall be sent whenever a video/audio first frame is received
     177              :      *
     178              :      * @param[in] mediaSourceType  : The type of the source that received the first frame
     179              :      */
     180              :     virtual void notifyFirstFrameReceived(MediaSourceType mediaSourceType) = 0;
     181              : 
     182              :     /**
     183              :      * @brief Notifies the client that a non-fatal error has occurred in the player.
     184              :      *
     185              :      * PlaybackState remains unchanged when an error occurs.
     186              :      *
     187              :      * @param[in] mediaSourceType  : The type of the source that produced the error.
     188              :      * @param[in] error            : The type of error that occurred.
     189              :      */
     190              :     virtual void notifyPlaybackError(MediaSourceType mediaSourceType, PlaybackError error) = 0;
     191              : 
     192              :     /**
     193              :      * @brief Notifies the client that the source has been flushed.
     194              :      *
     195              :      * Notification shall be sent whenever a flush procedure is finished.
     196              :      *
     197              :      * @param[in] mediaSourceType  : The type of the source that has been flushed.
     198              :      */
     199              :     virtual void notifySourceFlushed(MediaSourceType mediaSourceType) = 0;
     200              : 
     201              :     /**
     202              :      * @brief Notifies the client about the current playback state
     203              :      *
     204              :      * Notification shall be sent every 32ms after reaching the PLAYING state.
     205              :      *
     206              :      * @param[in] playbackInfo : The current playback information.
     207              :      */
     208              :     virtual void notifyPlaybackInfo(const PlaybackInfo &playbackInfo) = 0;
     209              : };
     210              : 
     211              : }; // namespace firebolt::rialto::server
     212              : 
     213              : #endif // FIREBOLT_RIALTO_SERVER_I_GST_GENERIC_PLAYER_CLIENT_H_
        

Generated by: LCOV version 2.0-1