LCOV - code coverage report
Current view: top level - media/server/main/include - IMediaKeySession.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_I_MEDIA_KEY_SESSION_H_
      21              : #define FIREBOLT_RIALTO_SERVER_I_MEDIA_KEY_SESSION_H_
      22              : 
      23              : #include "IMediaKeysClient.h"
      24              : #include "IOcdmSystem.h"
      25              : #include "MediaCommon.h"
      26              : #include <memory>
      27              : #include <string>
      28              : #include <vector>
      29              : 
      30              : namespace firebolt::rialto::server
      31              : {
      32              : class IMediaKeySession;
      33              : 
      34              : /**
      35              :  * @brief IMediaKeySession factory class, returns a concrete implementation of IMediaKeySession
      36              :  */
      37              : class IMediaKeySessionFactory
      38              : {
      39              : public:
      40           72 :     IMediaKeySessionFactory() = default;
      41           72 :     virtual ~IMediaKeySessionFactory() = default;
      42              : 
      43              :     /**
      44              :      * @brief Create a IMediaKeySessionFactory instance.
      45              :      *
      46              :      * @retval the factory instance or null on error.
      47              :      */
      48              :     static std::shared_ptr<IMediaKeySessionFactory> createFactory();
      49              : 
      50              :     /**
      51              :      * @brief IMediaKeySession factory method, returns a concrete implementation of IMediaKeySession
      52              :      *
      53              :      * @param[in]  keySystem    : The key system for this session.
      54              :      * @param[in]  keySessionId : The key session id for this session.
      55              :      * @param[in]  ocdmSystem   : The ocdm system object to create the session on.
      56              :      * @param[in]  sessionType  : The session type.
      57              :      * @param[in]  client       : Client object for callbacks.
      58              :      * @param[in]  isLDL        : Is this an LDL.
      59              :      *
      60              :      * @retval the new media keys instance or null on error.
      61              :      */
      62              :     virtual std::unique_ptr<IMediaKeySession>
      63              :     createMediaKeySession(const std::string &keySystem, int32_t keySessionId,
      64              :                           const firebolt::rialto::wrappers::IOcdmSystem &ocdmSystem, KeySessionType sessionType,
      65              :                           std::weak_ptr<IMediaKeysClient> client, bool isLDL) const = 0;
      66              : };
      67              : 
      68              : /**
      69              :  * @brief The definition of the IMediaKeySession interface.
      70              :  */
      71              : class IMediaKeySession
      72              : {
      73              : public:
      74          123 :     IMediaKeySession() = default;
      75          123 :     virtual ~IMediaKeySession() = default;
      76              : 
      77              :     IMediaKeySession(const IMediaKeySession &) = delete;
      78              :     IMediaKeySession &operator=(const IMediaKeySession &) = delete;
      79              :     IMediaKeySession(IMediaKeySession &&) = delete;
      80              :     IMediaKeySession &operator=(IMediaKeySession &&) = delete;
      81              : 
      82              :     /**
      83              :      * @brief Generates a licence request.
      84              :      *
      85              :      * @param[in]  initDataType : The init data type.
      86              :      * @param[in]  initData     : The init data.
      87              :      *
      88              :      * @retval an error status.
      89              :      */
      90              :     virtual MediaKeyErrorStatus generateRequest(InitDataType initDataType, const std::vector<uint8_t> &initData) = 0;
      91              : 
      92              :     /**
      93              :      * @brief Loads the existing key session.
      94              :      *
      95              :      * @retval an error status.
      96              :      */
      97              :     virtual MediaKeyErrorStatus loadSession() = 0;
      98              : 
      99              :     /**
     100              :      * @brief Updates the key session's state.
     101              :      *
     102              :      * @param[in] responseData : The license response data.
     103              :      *
     104              :      * @retval an error status.
     105              :      */
     106              :     virtual MediaKeyErrorStatus updateSession(const std::vector<uint8_t> &responseData) = 0;
     107              : 
     108              :     /**
     109              :      * @brief Decrypts the buffer.
     110              :      *
     111              :      * @param[in]  encrypted        : Gstreamer buffer containing encrypted data and related meta data. If applicable,
     112              :      *                                decrypted data will be stored here after this call returns.
     113              :      * @param[in] caps              : The gst caps of buffer.
     114              :      *
     115              :      * @retval an error status.
     116              :      */
     117              :     virtual MediaKeyErrorStatus decrypt(GstBuffer *encrypted, GstCaps *caps) = 0;
     118              : 
     119              :     /**
     120              :      * @brief Closes the key session.
     121              :      *
     122              :      * @retval an error status.
     123              :      */
     124              :     virtual MediaKeyErrorStatus closeKeySession() = 0;
     125              : 
     126              :     /**
     127              :      * @brief Removes the key session.
     128              :      *
     129              :      * @retval an error status.
     130              :      */
     131              :     virtual MediaKeyErrorStatus removeKeySession() = 0;
     132              : 
     133              :     /**
     134              :      * @brief Get the internal CDM key session ID
     135              :      *
     136              :      * @param[out]  cdmKeySessionId  : The internal CDM key session ID
     137              :      *
     138              :      * @retval the return status.
     139              :      */
     140              :     virtual MediaKeyErrorStatus getCdmKeySessionId(std::string &cdmKeySessionId) = 0;
     141              : 
     142              :     /**
     143              :      * @brief Returns true if the Key Session object contains the specified key.
     144              :      *
     145              :      * @param[in] keyId        : The key id.
     146              :      *
     147              :      * @retval true if it contains the key.
     148              :      */
     149              :     virtual bool containsKey(const std::vector<uint8_t> &keyId) = 0;
     150              : 
     151              :     /**
     152              :      * @brief Set DRM Header for a key session
     153              :      *
     154              :      * This method updates a key session's DRM header. If the session id does
     155              :      * not exist an MediaKeyErrorStatus:BAD_SESSION_ID is returned.If the session
     156              :      * state is invalid an MediaKeyErrorStatus:INVALID_STATE is returned. Any
     157              :      * other errors will result in MediaKeyErrorStatus:FAIL.
     158              :      *
     159              :      * @param[in] requestData  : The request data.
     160              :      *
     161              :      * @retval an error status.
     162              :      */
     163              :     virtual MediaKeyErrorStatus setDrmHeader(const std::vector<uint8_t> &requestData) = 0;
     164              : 
     165              :     /**
     166              :      * @brief Get the last cdm specific DRM error code
     167              :      *
     168              :      * @param[out] errorCode : the error code.
     169              :      *
     170              :      * @retval the return status value.
     171              :      */
     172              :     virtual MediaKeyErrorStatus getLastDrmError(uint32_t &errorCode) = 0;
     173              : 
     174              :     /**
     175              :      * @brief Selects the specified keyId for the key session. Netflix specific API.
     176              :      *
     177              :      * @param[in] keyId        : The key id to select.
     178              :      *
     179              :      * @retval an error status.
     180              :      */
     181              :     virtual MediaKeyErrorStatus selectKeyId(const std::vector<uint8_t> &keyId) = 0;
     182              : 
     183              :     /**
     184              :      * @brief Checks, if key system of media key session is Netflix playready.
     185              :      *
     186              :      * @retval true if key system is Netflix playready
     187              :      */
     188              :     virtual bool isNetflixPlayreadyKeySystem() const = 0;
     189              : };
     190              : } // namespace firebolt::rialto::server
     191              : 
     192              : #endif // FIREBOLT_RIALTO_SERVER_I_MEDIA_KEY_SESSION_H_
        

Generated by: LCOV version 2.0-1