LCOV - code coverage report
Current view: top level - media/public/include - IMediaKeys.h (source / functions) Coverage Total Hit
Test: coverage.info Lines: 100.0 % 4 4
Test Date: 2025-03-21 11:02:39 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_I_MEDIA_KEYS_H_
      21              : #define FIREBOLT_RIALTO_I_MEDIA_KEYS_H_
      22              : 
      23              : /**
      24              :  * @file IMediaKeys.h
      25              :  *
      26              :  * The definition of the IMediaKeys interface.
      27              :  *
      28              :  * This interface defines the public API of Rialto for EME decryption of AV content.
      29              :  */
      30              : 
      31              : #include <memory>
      32              : #include <string>
      33              : #include <vector>
      34              : 
      35              : #include "IMediaKeysClient.h"
      36              : #include "MediaCommon.h"
      37              : 
      38              : namespace firebolt::rialto
      39              : {
      40              : class IMediaKeys;
      41              : 
      42              : /**
      43              :  * @brief IMediaKeys factory class, returns a concrete implementation of IMediaKeys
      44              :  */
      45              : class IMediaKeysFactory
      46              : {
      47              : public:
      48           94 :     IMediaKeysFactory() = default;
      49           94 :     virtual ~IMediaKeysFactory() = default;
      50              : 
      51              :     /**
      52              :      * @brief Create a IMediaKeysFactory instance.
      53              :      *
      54              :      * @retval the factory instance or null on error.
      55              :      */
      56              :     static std::shared_ptr<IMediaKeysFactory> createFactory();
      57              : 
      58              :     /**
      59              :      * @brief IMediaKeys factory method, returns a concrete implementation of IMediaKeys
      60              :      *
      61              :      * @param[in] keySystem           : The key system for which to create a Media Keys instance.
      62              :      *
      63              :      * @retval the new media keys instance or null on error.
      64              :      */
      65              :     virtual std::unique_ptr<IMediaKeys> createMediaKeys(const std::string &keySystem) const = 0;
      66              : };
      67              : 
      68              : /**
      69              :  * @brief The definition of the IMediaKeys interface.
      70              :  *
      71              :  * This interface defines the public API of Rialto for EME decryption of AV content
      72              :  * which should be implemented by both Rialto Client & Rialto Server.
      73              :  */
      74              : class IMediaKeys
      75              : {
      76              : public:
      77          308 :     IMediaKeys() = default;
      78          308 :     virtual ~IMediaKeys() = default;
      79              : 
      80              :     IMediaKeys(const IMediaKeys &) = delete;
      81              :     IMediaKeys &operator=(const IMediaKeys &) = delete;
      82              :     IMediaKeys(IMediaKeys &&) = delete;
      83              :     IMediaKeys &operator=(IMediaKeys &&) = delete;
      84              : 
      85              :     /**
      86              :      * @brief Selects the specified keyId for the key session. Netflix specific API.
      87              :      *
      88              :      * @param[in] keySessionId : The key session id for the session.
      89              :      * @param[in] keyId        : The key id to select.
      90              :      *
      91              :      * @retval an error status.
      92              :      */
      93              :     virtual MediaKeyErrorStatus selectKeyId(int32_t keySessionId, const std::vector<uint8_t> &keyId) = 0;
      94              : 
      95              :     /**
      96              :      * @brief Returns true if the Key Session object contains the specified key.
      97              :      *
      98              :      * @param[in] keySessionId : The key session id for the session.
      99              :      * @param[in] keyId        : The key id.
     100              :      *
     101              :      * @retval true if it contains the key.
     102              :      */
     103              :     virtual bool containsKey(int32_t keySessionId, const std::vector<uint8_t> &keyId) = 0;
     104              : 
     105              :     /**
     106              :      * @brief Creates a session and returns the session id.
     107              :      *
     108              :      * This method creates a new session and returns the session id in
     109              :      * the specified string. Any other errors will result in MediaKeyErrorStatus:FAIL.
     110              :      *
     111              :      * @param[in]  sessionType : The session type.
     112              :      * @param[in]  client      : Client object for callbacks
     113              :      * @param[in]  isLDL       : Is this an LDL
     114              :      * @param[out] keySessionId: The key session id
     115              :      *
     116              :      * @retval an error status.
     117              :      */
     118              :     virtual MediaKeyErrorStatus createKeySession(KeySessionType sessionType, std::weak_ptr<IMediaKeysClient> client,
     119              :                                                  bool isLDL, int32_t &keySessionId) = 0;
     120              : 
     121              :     /**
     122              :      * @brief Generates a licence request.
     123              :      *
     124              :      * This method triggers generation of a licence request. If the session
     125              :      * id does not exist an MediaKeyErrorStatus:BAD_SESSION_ID is returned. If the
     126              :      * session type or init data type is not supported a
     127              :      * MediaKeyErrorStatus:NOT_SUPPORTED value is be returned. Any other
     128              :      * errors will result in MediaKeyErrorStatus:FAIL.
     129              :      *
     130              :      * @param[in]  keySessionId : The key session id for the session.
     131              :      * @param[in]  initDataType : The init data type.
     132              :      * @param[in]  initData     : The init data.
     133              :      *
     134              :      * @retval an error status.
     135              :      */
     136              :     virtual MediaKeyErrorStatus generateRequest(int32_t keySessionId, InitDataType initDataType,
     137              :                                                 const std::vector<uint8_t> &initData) = 0;
     138              : 
     139              :     /**
     140              :      * @brief Loads an existing key session
     141              :      *
     142              :      * This method loads an existing key session. If the session id does
     143              :      * not exist an MediaKeyErrorStatus:BAD_SESSION_ID is returned. If the
     144              :      * session type or init data type is not supported a
     145              :      * MediaKeyErrorStatus:NOT_SUPPORTED value must be returned. If the session
     146              :      * state is invalid an MediaKeyErrorStatus:INVALID_STATE is returned. Any
     147              :      * other errors will result in MediaKeyErrorStatus:FAIL.
     148              :      *
     149              :      * @param[in] keySessionId : The key session id for the session.
     150              :      *
     151              :      * @retval an error status.
     152              :      */
     153              :     virtual MediaKeyErrorStatus loadSession(int32_t keySessionId) = 0;
     154              : 
     155              :     /**
     156              :      * @brief Updates a key session's state.
     157              :      *
     158              :      * This method updates a session's state. If the session id does
     159              :      * not exist an MediaKeyErrorStatus:BAD_SESSION_ID is returned. If the session
     160              :      * state is invalid an MediaKeyErrorStatus:INVALID_STATE is returned. Any
     161              :      * other errors will result in MediaKeyErrorStatus:FAIL.
     162              :      *
     163              :      * @param[in] keySessionId : The key session id for the session.
     164              :      * @param[in] responseData : The license response data.
     165              :      *
     166              :      * @retval an error status.
     167              :      */
     168              :     virtual MediaKeyErrorStatus updateSession(int32_t keySessionId, const std::vector<uint8_t> &responseData) = 0;
     169              : 
     170              :     /**
     171              :      * @brief Set DRM Header for a key session
     172              :      *
     173              :      * This method updates a key session's DRM header. If the session id does
     174              :      * not exist an MediaKeyErrorStatus:BAD_SESSION_ID is returned.If the session
     175              :      * state is invalid an MediaKeyErrorStatus:INVALID_STATE is returned. Any
     176              :      * other errors will result in MediaKeyErrorStatus:FAIL.
     177              :      *
     178              :      * @param[in] keySessionId : The session id for the session.
     179              :      * @param[in] requestData  : The request data.
     180              :      *
     181              :      * @retval an error status.
     182              :      */
     183              :     virtual MediaKeyErrorStatus setDrmHeader(int32_t keySessionId, const std::vector<uint8_t> &requestData) = 0;
     184              : 
     185              :     /**
     186              :      * @brief Closes a key session
     187              :      *
     188              :      * This method closes an open session. If the session id does
     189              :      * not exist an MediaKeyErrorStatus:BAD_SESSION_ID is returned. Any other
     190              :      * errors will result in MediaKeyErrorStatus:FAIL.
     191              :      *
     192              :      * @param[in] keySessionId : The key session id.
     193              :      *
     194              :      * @retval an error status.
     195              :      */
     196              :     virtual MediaKeyErrorStatus closeKeySession(int32_t keySessionId) = 0;
     197              : 
     198              :     /**
     199              :      * @brief Removes a key session
     200              :      *
     201              :      * This method removes an open session. If the session id does
     202              :      * not exist an MediaKeyErrorStatus:BAD_SESSION_ID is returned. Any other
     203              :      * errors will result in MediaKeyErrorStatus:FAIL.
     204              :      *
     205              :      * @param[in] keySessionId : The key session id.
     206              :      *
     207              :      * @retval an error status.
     208              :      */
     209              :     virtual MediaKeyErrorStatus removeKeySession(int32_t keySessionId) = 0;
     210              : 
     211              :     /**
     212              :      * @brief Delete the DRM store for the object's key system
     213              :      *
     214              :      * @retval the return status value.
     215              :      */
     216              :     virtual MediaKeyErrorStatus deleteDrmStore() = 0;
     217              : 
     218              :     /**
     219              :      * @brief Delete the key store for the object's key system
     220              :      *
     221              :      * @retval the return status value.
     222              :      */
     223              :     virtual MediaKeyErrorStatus deleteKeyStore() = 0;
     224              : 
     225              :     /**
     226              :      * @brief Gets a hash of the DRM store for the object's key system
     227              :      *
     228              :      * @param[out] drmStoreHash : the hash value
     229              :      *
     230              :      * @retval the return status value.
     231              :      */
     232              :     virtual MediaKeyErrorStatus getDrmStoreHash(std::vector<unsigned char> &drmStoreHash) = 0;
     233              : 
     234              :     /**
     235              :      * @brief Gets a hash of the Key store for the object's key system
     236              :      *
     237              :      * @param[out] keyStoreHash : the hash value
     238              :      *
     239              :      * @retval the return status value.
     240              :      */
     241              :     virtual MediaKeyErrorStatus getKeyStoreHash(std::vector<unsigned char> &keyStoreHash) = 0;
     242              : 
     243              :     /**
     244              :      * @brief Get the limit on the number of ldl key sessions for the object's key system
     245              :      *
     246              :      * @param[out] ldlLimit : the limit on the number of ldl key sessions.
     247              :      *
     248              :      * @retval the return status value.
     249              :      */
     250              :     virtual MediaKeyErrorStatus getLdlSessionsLimit(uint32_t &ldlLimit) = 0;
     251              : 
     252              :     /**
     253              :      * @brief Get the last cdm specific DRM error code
     254              :      *
     255              :      * @param[in] keySessionId : The key session id.
     256              :      * @param[out] errorCode : the error code.
     257              :      *
     258              :      * @retval the return status value.
     259              :      */
     260              :     virtual MediaKeyErrorStatus getLastDrmError(int32_t keySessionId, uint32_t &errorCode) = 0;
     261              : 
     262              :     /**
     263              :      * @brief Get the DRM system time for the object's key system
     264              :      *
     265              :      * @param[out]  drmTime : the DRM system time
     266              :      *
     267              :      * @retval the return status value.
     268              :      */
     269              :     virtual MediaKeyErrorStatus getDrmTime(uint64_t &drmTime) = 0;
     270              : 
     271              :     /**
     272              :      * @brief Get the internal CDM key session ID
     273              :      *
     274              :      * @param[in]   keySessionId    : The key session id for the session.
     275              :      * @param[out]  cdmKeySessionId : The internal CDM key session ID
     276              :      *
     277              :      * @retval the return status value.
     278              :      */
     279              :     virtual MediaKeyErrorStatus getCdmKeySessionId(int32_t keySessionId, std::string &cdmKeySessionId) = 0;
     280              : 
     281              :     /**
     282              :      * @brief Releases a key session
     283              :      *
     284              :      * This method releases an open session. If the session id does
     285              :      * not exist an MediaKeyErrorStatus:BAD_SESSION_ID is returned. Any other
     286              :      * errors will result in MediaKeyErrorStatus:FAIL.
     287              :      *
     288              :      * @param[in] keySessionId : The key session id.
     289              :      *
     290              :      * @retval an error status.
     291              :      */
     292              :     virtual MediaKeyErrorStatus releaseKeySession(int32_t keySessionId) = 0;
     293              : };
     294              : 
     295              : }; // namespace firebolt::rialto
     296              : 
     297              : #endif // FIREBOLT_RIALTO_I_MEDIA_KEYS_H_
        

Generated by: LCOV version 2.0-1