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: 2025-02-18 13:13:53 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          603 :     IGstGenericPlayerClient() = default;
      50          603 :     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 of the current playback position.
      92              :      *
      93              :      * This method notifies the client of the current playback position
      94              :      * in nanoseconds.
      95              :      *
      96              :      * When playing this should be called often enough to provide
      97              :      * sufficient granularity of position reporting. Typically this will
      98              :      * be every 0.25s.
      99              :      *
     100              :      * @param[in] position : The playback position in nanoseconds.
     101              :      *
     102              :      */
     103              :     virtual void notifyPosition(std::int64_t position) = 0;
     104              : 
     105              :     /**
     106              :      * @brief Notifies the client of the network state.
     107              :      *
     108              :      * The network state reflects the state of the network. For backend
     109              :      * streaming, say using MediaPipelineURLDelegate, this is important
     110              :      * as the backend uses the network to obtain the media data directly.
     111              :      *
     112              :      * For streaming that uses the browser to obtain data, say Media Source
     113              :      * Extensions playback, only the states NetworkState::IDLE,
     114              :      * NetworkState::BUFFERED and NetworkState::DECODE_ERROR should be
     115              :      * indicated by the backend.
     116              :      *
     117              :      * @param[in] state : The new network state.
     118              :      *
     119              :      */
     120              :     virtual void notifyNetworkState(NetworkState state) = 0;
     121              : 
     122              :     /**
     123              :      * @brief Clears all active NeedMediaDataRequests cache for session
     124              :      *
     125              :      */
     126              :     virtual void clearActiveRequestsCache() = 0;
     127              : 
     128              :     /**
     129              :      * @brief Clears all active NeedMediaDataRequests cache for given Media Source Type
     130              :      *
     131              :      * @param[in] type : Media source type.
     132              :      *
     133              :      */
     134              :     virtual void invalidateActiveRequests(const MediaSourceType &type) = 0;
     135              : 
     136              :     /**
     137              :      * @brief Notifies the client of a Quality Of Service update from the Player.
     138              :      *
     139              :      * @param[in] qosInfo       : The Qos infomation extracted from the message.
     140              :      * @param[in] sourceType    : The type of source that sent the message.
     141              :      */
     142              :     virtual void notifyQos(MediaSourceType mediaSourceType, const QosInfo &qosInfo) = 0;
     143              : 
     144              :     /**
     145              :      * @brief Notifies the client that buffer underflow occurred.
     146              :      *
     147              :      * Notification shall be sent whenever a video/audio buffer underflow occurs
     148              :      *
     149              :      * @param[in] mediaSourceType  : The type of the source that produced the buffer underflow
     150              :      */
     151              :     virtual void notifyBufferUnderflow(MediaSourceType mediaSourceType) = 0;
     152              : 
     153              :     /**
     154              :      * @brief Notifies the client that a non-fatal error has occurred in the player.
     155              :      *
     156              :      * PlaybackState remains unchanged when an error occurs.
     157              :      *
     158              :      * @param[in] mediaSourceType  : The type of the source that produced the error.
     159              :      * @param[in] error            : The type of error that occurred.
     160              :      */
     161              :     virtual void notifyPlaybackError(MediaSourceType mediaSourceType, PlaybackError error) = 0;
     162              : 
     163              :     /**
     164              :      * @brief Notifies the client that the source has been flushed.
     165              :      *
     166              :      * Notification shall be sent whenever a flush procedure is finished.
     167              :      *
     168              :      * @param[in] mediaSourceType  : The type of the source that has been flushed.
     169              :      */
     170              :     virtual void notifySourceFlushed(MediaSourceType mediaSourceType) = 0;
     171              : };
     172              : 
     173              : }; // namespace firebolt::rialto::server
     174              : 
     175              : #endif // FIREBOLT_RIALTO_SERVER_I_GST_GENERIC_PLAYER_CLIENT_H_
        

Generated by: LCOV version 2.0-1