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: 2026-11-10 16:58:19 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           61 :     IMediaKeySessionFactory() = default;
      41           61 :     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              :      *
      59              :      * @retval the new media keys instance or null on error.
      60              :      */
      61              :     virtual std::unique_ptr<IMediaKeySession>
      62              :     createMediaKeySession(const std::string &keySystem, int32_t keySessionId,
      63              :                           const firebolt::rialto::wrappers::IOcdmSystem &ocdmSystem, KeySessionType sessionType,
      64              :                           std::weak_ptr<IMediaKeysClient> client) const = 0;
      65              : };
      66              : 
      67              : /**
      68              :  * @brief The definition of the IMediaKeySession interface.
      69              :  */
      70              : class IMediaKeySession
      71              : {
      72              : public:
      73          115 :     IMediaKeySession() = default;
      74          115 :     virtual ~IMediaKeySession() = default;
      75              : 
      76              :     IMediaKeySession(const IMediaKeySession &) = delete;
      77              :     IMediaKeySession &operator=(const IMediaKeySession &) = delete;
      78              :     IMediaKeySession(IMediaKeySession &&) = delete;
      79              :     IMediaKeySession &operator=(IMediaKeySession &&) = delete;
      80              : 
      81              :     /**
      82              :      * @brief Generates a licence request.
      83              :      *
      84              :      * @param[in]  initDataType : The init data type.
      85              :      * @param[in]  initData     : The init data.
      86              :      * @param[in]  ldlState     : The Limited Duration License state. Most of key systems do not need this parameter.
      87              :      *
      88              :      * @retval an error status.
      89              :      */
      90              :     virtual MediaKeyErrorStatus generateRequest(InitDataType initDataType, const std::vector<uint8_t> &initData,
      91              :                                                 const LimitedDurationLicense &ldlState) = 0;
      92              :     /**
      93              :      * @brief Loads the existing key session.
      94              :      *
      95              :      * @param[in] cdmKeySessionId : The internal CDM key session ID.
      96              :      *
      97              :      * @retval an error status.
      98              :      */
      99              :     virtual MediaKeyErrorStatus loadSession(const std::string &cdmKeySessionId) = 0;
     100              : 
     101              :     /**
     102              :      * @brief Updates the key session's state.
     103              :      *
     104              :      * @param[in] responseData : The license response data.
     105              :      *
     106              :      * @retval an error status.
     107              :      */
     108              :     virtual MediaKeyErrorStatus updateSession(const std::vector<uint8_t> &responseData) = 0;
     109              : 
     110              :     /**
     111              :      * @brief Decrypts the buffer.
     112              :      *
     113              :      * @param[in]  encrypted        : Gstreamer buffer containing encrypted data and related meta data. If applicable,
     114              :      *                                decrypted data will be stored here after this call returns.
     115              :      * @param[in] caps              : The gst caps of buffer.
     116              :      *
     117              :      * @retval an error status.
     118              :      */
     119              :     virtual MediaKeyErrorStatus decrypt(GstBuffer *encrypted, GstCaps *caps) = 0;
     120              : 
     121              :     /**
     122              :      * @brief Closes the key session.
     123              :      *
     124              :      * @retval an error status.
     125              :      */
     126              :     virtual MediaKeyErrorStatus closeKeySession() = 0;
     127              : 
     128              :     /**
     129              :      * @brief Removes the key session.
     130              :      *
     131              :      * @retval an error status.
     132              :      */
     133              :     virtual MediaKeyErrorStatus removeKeySession() = 0;
     134              : 
     135              :     /**
     136              :      * @brief Get the internal CDM key session ID
     137              :      *
     138              :      * @param[out]  cdmKeySessionId  : The internal CDM key session ID
     139              :      *
     140              :      * @retval the return status.
     141              :      */
     142              :     virtual MediaKeyErrorStatus getCdmKeySessionId(std::string &cdmKeySessionId) = 0;
     143              : 
     144              :     /**
     145              :      * @brief Returns true if the Key Session object contains the specified key.
     146              :      *
     147              :      * @param[in] keyId        : The key id.
     148              :      *
     149              :      * @retval true if it contains the key.
     150              :      */
     151              :     virtual bool containsKey(const std::vector<uint8_t> &keyId) = 0;
     152              : 
     153              :     /**
     154              :      * @brief Set DRM Header for a key session
     155              :      *
     156              :      * This method updates a key session's DRM header. If the session id does
     157              :      * not exist an MediaKeyErrorStatus:BAD_SESSION_ID is returned.If the session
     158              :      * state is invalid an MediaKeyErrorStatus:INVALID_STATE is returned. Any
     159              :      * other errors will result in MediaKeyErrorStatus:FAIL.
     160              :      *
     161              :      * @param[in] requestData  : The request data.
     162              :      *
     163              :      * @retval an error status.
     164              :      */
     165              :     virtual MediaKeyErrorStatus setDrmHeader(const std::vector<uint8_t> &requestData) = 0;
     166              : 
     167              :     /**
     168              :      * @brief Get the last cdm specific DRM error code
     169              :      *
     170              :      * @param[out] errorCode : the error code.
     171              :      *
     172              :      * @retval the return status value.
     173              :      */
     174              :     virtual MediaKeyErrorStatus getLastDrmError(uint32_t &errorCode) = 0;
     175              : 
     176              :     /**
     177              :      * @brief Selects the specified keyId for the key session. Netflix specific API.
     178              :      *
     179              :      * @param[in] keyId        : The key id to select.
     180              :      *
     181              :      * @retval an error status.
     182              :      */
     183              :     virtual MediaKeyErrorStatus selectKeyId(const std::vector<uint8_t> &keyId) = 0;
     184              : };
     185              : } // namespace firebolt::rialto::server
     186              : 
     187              : #endif // FIREBOLT_RIALTO_SERVER_I_MEDIA_KEY_SESSION_H_
        

Generated by: LCOV version 2.0-1