LCOV - code coverage report
Current view: top level - media/client/ipc/source - MediaKeysIpc.cpp (source / functions) Coverage Total Hit
Test: coverage.info Lines: 83.3 % 526 438
Test Date: 2026-12-04 20:46:59 Functions: 92.3 % 39 36

            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              : #include "MediaKeysIpc.h"
      21              : #include "RialtoClientLogging.h"
      22              : 
      23              : namespace
      24              : {
      25              : firebolt::rialto::MediaKeyErrorStatus
      26           69 : convertMediaKeyErrorStatus(const firebolt::rialto::ProtoMediaKeyErrorStatus &errorStatus)
      27              : {
      28           69 :     switch (errorStatus)
      29              :     {
      30           52 :     case firebolt::rialto::ProtoMediaKeyErrorStatus::OK:
      31              :     {
      32           52 :         return firebolt::rialto::MediaKeyErrorStatus::OK;
      33              :     }
      34           17 :     case firebolt::rialto::ProtoMediaKeyErrorStatus::BAD_SESSION_ID:
      35              :     {
      36           17 :         return firebolt::rialto::MediaKeyErrorStatus::BAD_SESSION_ID;
      37              :     }
      38            0 :     case firebolt::rialto::ProtoMediaKeyErrorStatus::INTERFACE_NOT_IMPLEMENTED:
      39              :     {
      40            0 :         return firebolt::rialto::MediaKeyErrorStatus::INTERFACE_NOT_IMPLEMENTED;
      41              :     }
      42            0 :     case firebolt::rialto::ProtoMediaKeyErrorStatus::BUFFER_TOO_SMALL:
      43              :     {
      44            0 :         return firebolt::rialto::MediaKeyErrorStatus::BUFFER_TOO_SMALL;
      45              :     }
      46            0 :     case firebolt::rialto::ProtoMediaKeyErrorStatus::NOT_SUPPORTED:
      47              :     {
      48            0 :         return firebolt::rialto::MediaKeyErrorStatus::NOT_SUPPORTED;
      49              :     }
      50            0 :     case firebolt::rialto::ProtoMediaKeyErrorStatus::INVALID_STATE:
      51              :     {
      52            0 :         return firebolt::rialto::MediaKeyErrorStatus::INVALID_STATE;
      53              :     }
      54            0 :     case firebolt::rialto::ProtoMediaKeyErrorStatus::FAIL:
      55              :     {
      56            0 :         return firebolt::rialto::MediaKeyErrorStatus::FAIL;
      57              :     }
      58            0 :     case firebolt::rialto::ProtoMediaKeyErrorStatus::OUTPUT_RESTRICTED:
      59              :     {
      60            0 :         return firebolt::rialto::MediaKeyErrorStatus::OUTPUT_RESTRICTED;
      61              :     }
      62              :     }
      63            0 :     return firebolt::rialto::MediaKeyErrorStatus::FAIL;
      64              : }
      65              : 
      66            3 : firebolt::rialto::KeyStatus convertKeyStatus(const firebolt::rialto::KeyStatusesChangedEvent_KeyStatus &protoKeyStatus)
      67              : {
      68            3 :     switch (protoKeyStatus)
      69              :     {
      70            1 :     case firebolt::rialto::KeyStatusesChangedEvent_KeyStatus_USABLE:
      71              :     {
      72            1 :         return firebolt::rialto::KeyStatus::USABLE;
      73              :     }
      74            1 :     case firebolt::rialto::KeyStatusesChangedEvent_KeyStatus_EXPIRED:
      75              :     {
      76            1 :         return firebolt::rialto::KeyStatus::EXPIRED;
      77              :     }
      78            1 :     case firebolt::rialto::KeyStatusesChangedEvent_KeyStatus_OUTPUT_RESTRICTED:
      79              :     {
      80            1 :         return firebolt::rialto::KeyStatus::OUTPUT_RESTRICTED;
      81              :     }
      82            0 :     case firebolt::rialto::KeyStatusesChangedEvent_KeyStatus_PENDING:
      83              :     {
      84            0 :         return firebolt::rialto::KeyStatus::PENDING;
      85              :     }
      86            0 :     case firebolt::rialto::KeyStatusesChangedEvent_KeyStatus_INTERNAL_ERROR:
      87              :     {
      88            0 :         return firebolt::rialto::KeyStatus::INTERNAL_ERROR;
      89              :     }
      90            0 :     case firebolt::rialto::KeyStatusesChangedEvent_KeyStatus_RELEASED:
      91              :     {
      92            0 :         return firebolt::rialto::KeyStatus::RELEASED;
      93              :     }
      94              :     }
      95            0 :     return firebolt::rialto::KeyStatus::INTERNAL_ERROR;
      96              : }
      97              : 
      98           17 : const char *toString(const firebolt::rialto::MediaKeyErrorStatus &errorStatus)
      99              : {
     100           17 :     switch (errorStatus)
     101              :     {
     102            0 :     case firebolt::rialto::MediaKeyErrorStatus::OK:
     103              :     {
     104            0 :         return "OK";
     105              :     }
     106           17 :     case firebolt::rialto::MediaKeyErrorStatus::BAD_SESSION_ID:
     107              :     {
     108           17 :         return "BAD_SESSION_ID";
     109              :     }
     110            0 :     case firebolt::rialto::MediaKeyErrorStatus::INTERFACE_NOT_IMPLEMENTED:
     111              :     {
     112            0 :         return "INTERFACE_NOT_IMPLEMENTED";
     113              :     }
     114            0 :     case firebolt::rialto::MediaKeyErrorStatus::BUFFER_TOO_SMALL:
     115              :     {
     116            0 :         return "BUFFER_TOO_SMALL";
     117              :     }
     118            0 :     case firebolt::rialto::MediaKeyErrorStatus::NOT_SUPPORTED:
     119              :     {
     120            0 :         return "NOT_SUPPORTED";
     121              :     }
     122            0 :     case firebolt::rialto::MediaKeyErrorStatus::INVALID_STATE:
     123              :     {
     124            0 :         return "INVALID_STATE";
     125              :     }
     126            0 :     case firebolt::rialto::MediaKeyErrorStatus::FAIL:
     127              :     {
     128            0 :         return "FAIL";
     129              :     }
     130            0 :     case firebolt::rialto::MediaKeyErrorStatus::OUTPUT_RESTRICTED:
     131              :     {
     132            0 :         return "OUTPUT_RESTRICTED";
     133              :     }
     134              :     }
     135            0 :     return "UNKNOWN";
     136              : }
     137              : } // namespace
     138              : 
     139              : namespace firebolt::rialto::client
     140              : {
     141            0 : std::shared_ptr<IMediaKeysIpcFactory> IMediaKeysIpcFactory::createFactory()
     142              : {
     143            0 :     std::shared_ptr<IMediaKeysIpcFactory> factory;
     144              : 
     145              :     try
     146              :     {
     147            0 :         factory = std::make_shared<MediaKeysIpcFactory>();
     148              :     }
     149            0 :     catch (const std::exception &e)
     150              :     {
     151            0 :         RIALTO_CLIENT_LOG_ERROR("Failed to create the media keys ipc factory, reason: %s", e.what());
     152              :     }
     153              : 
     154            0 :     return factory;
     155              : }
     156              : 
     157            0 : std::unique_ptr<IMediaKeys> MediaKeysIpcFactory::createMediaKeysIpc(const std::string &keySystem) const
     158              : {
     159            0 :     std::unique_ptr<IMediaKeys> mediaKeysIpc;
     160              :     try
     161              :     {
     162              :         mediaKeysIpc =
     163            0 :             std::make_unique<client::MediaKeysIpc>(keySystem, IIpcClientAccessor::instance().getIpcClient(),
     164            0 :                                                    firebolt::rialto::common::IEventThreadFactory::createFactory());
     165              :     }
     166            0 :     catch (const std::exception &e)
     167              :     {
     168            0 :         RIALTO_CLIENT_LOG_ERROR("Failed to create the media keys ipc, reason: %s", e.what());
     169              :     }
     170              : 
     171            0 :     return mediaKeysIpc;
     172              : }
     173              : 
     174          109 : MediaKeysIpc::MediaKeysIpc(const std::string &keySystem, IIpcClient &ipcClient,
     175          109 :                            const std::shared_ptr<common::IEventThreadFactory> &eventThreadFactory)
     176          327 :     : IpcModule(ipcClient), m_eventThread(eventThreadFactory->createEventThread("rialto-media-keys-events"))
     177              : {
     178          109 :     RIALTO_CLIENT_LOG_DEBUG("entry:");
     179              : 
     180          109 :     if (!attachChannel())
     181              :     {
     182            3 :         throw std::runtime_error("Failed attach to the ipc channel");
     183              :     }
     184              : 
     185          106 :     if (!createMediaKeys(keySystem))
     186              :     {
     187            1 :         detachChannel();
     188            1 :         throw std::runtime_error("Could not create the media keys instance");
     189              :     }
     190          125 : }
     191              : 
     192          210 : MediaKeysIpc::~MediaKeysIpc()
     193              : {
     194          105 :     RIALTO_CLIENT_LOG_DEBUG("entry:");
     195              : 
     196          105 :     destroyMediaKeys();
     197              : 
     198          105 :     detachChannel();
     199              : 
     200          105 :     m_eventThread.reset();
     201          210 : }
     202              : 
     203          143 : bool MediaKeysIpc::createRpcStubs(const std::shared_ptr<ipc::IChannel> &ipcChannel)
     204              : {
     205          143 :     m_mediaKeysStub = std::make_unique<::firebolt::rialto::MediaKeysModule_Stub>(ipcChannel.get());
     206          143 :     if (!m_mediaKeysStub)
     207              :     {
     208            0 :         return false;
     209              :     }
     210          143 :     return true;
     211              : }
     212              : 
     213          143 : bool MediaKeysIpc::subscribeToEvents(const std::shared_ptr<ipc::IChannel> &ipcChannel)
     214              : {
     215          143 :     if (!ipcChannel)
     216              :     {
     217            0 :         return false;
     218              :     }
     219              : 
     220          286 :     int eventTag = ipcChannel->subscribe<firebolt::rialto::LicenseRequestEvent>(
     221          143 :         [this](const std::shared_ptr<firebolt::rialto::LicenseRequestEvent> &event)
     222          146 :         { m_eventThread->add(&MediaKeysIpc::onLicenseRequest, this, event); });
     223          143 :     if (eventTag < 0)
     224            0 :         return false;
     225          143 :     m_eventTags.push_back(eventTag);
     226              : 
     227          286 :     eventTag = ipcChannel->subscribe<firebolt::rialto::LicenseRenewalEvent>(
     228          143 :         [this](const std::shared_ptr<firebolt::rialto::LicenseRenewalEvent> &event)
     229            6 :         { m_eventThread->add(&MediaKeysIpc::onLicenseRenewal, this, event); });
     230          143 :     if (eventTag < 0)
     231            1 :         return false;
     232          142 :     m_eventTags.push_back(eventTag);
     233              : 
     234          284 :     eventTag = ipcChannel->subscribe<firebolt::rialto::LicenseReleaseEvent>(
     235          142 :         [this](const std::shared_ptr<firebolt::rialto::LicenseReleaseEvent> &event)
     236            3 :         { m_eventThread->add(&MediaKeysIpc::onLicenseRelease, this, event); });
     237          142 :     if (eventTag < 0)
     238            0 :         return false;
     239          142 :     m_eventTags.push_back(eventTag);
     240              : 
     241          284 :     eventTag = ipcChannel->subscribe<firebolt::rialto::KeyStatusesChangedEvent>(
     242          142 :         [this](const std::shared_ptr<firebolt::rialto::KeyStatusesChangedEvent> &event)
     243            3 :         { m_eventThread->add(&MediaKeysIpc::onKeyStatusesChanged, this, event); });
     244          142 :     if (eventTag < 0)
     245            0 :         return false;
     246          142 :     m_eventTags.push_back(eventTag);
     247              : 
     248          142 :     return true;
     249              : }
     250              : 
     251          106 : bool MediaKeysIpc::createMediaKeys(const std::string &keySystem)
     252              : {
     253          106 :     if (!reattachChannelIfRequired())
     254              :     {
     255            0 :         RIALTO_CLIENT_LOG_ERROR("Reattachment of the ipc channel failed, ipc disconnected");
     256            0 :         return false;
     257              :     }
     258              : 
     259          106 :     firebolt::rialto::CreateMediaKeysRequest request;
     260              : 
     261              :     request.set_key_system(keySystem);
     262              : 
     263          106 :     firebolt::rialto::CreateMediaKeysResponse response;
     264          106 :     auto ipcController = m_ipc.createRpcController();
     265          106 :     auto blockingClosure = m_ipc.createBlockingClosure();
     266          106 :     m_mediaKeysStub->createMediaKeys(ipcController.get(), &request, &response, blockingClosure.get());
     267              : 
     268              :     // wait for the call to complete
     269          106 :     blockingClosure->wait();
     270              : 
     271              :     // check the result
     272          106 :     if (ipcController->Failed())
     273              :     {
     274            1 :         RIALTO_CLIENT_LOG_ERROR("failed to create media keys due to '%s'", ipcController->ErrorText().c_str());
     275            1 :         return false;
     276              :     }
     277              : 
     278          105 :     m_mediaKeysHandle = response.media_keys_handle();
     279              : 
     280          105 :     return true;
     281          106 : }
     282              : 
     283          105 : void MediaKeysIpc::destroyMediaKeys()
     284              : {
     285          105 :     if (!reattachChannelIfRequired())
     286              :     {
     287            1 :         RIALTO_CLIENT_LOG_ERROR("Reattachment of the ipc channel failed, ipc disconnected");
     288            1 :         return;
     289              :     }
     290              : 
     291          104 :     firebolt::rialto::DestroyMediaKeysRequest request;
     292          104 :     request.set_media_keys_handle(m_mediaKeysHandle);
     293              : 
     294          104 :     firebolt::rialto::DestroyMediaKeysResponse response;
     295          104 :     auto ipcController = m_ipc.createRpcController();
     296          104 :     auto blockingClosure = m_ipc.createBlockingClosure();
     297          104 :     m_mediaKeysStub->destroyMediaKeys(ipcController.get(), &request, &response, blockingClosure.get());
     298              : 
     299              :     // wait for the call to complete
     300          104 :     blockingClosure->wait();
     301              : 
     302              :     // check the result
     303          104 :     if (ipcController->Failed())
     304              :     {
     305            1 :         RIALTO_CLIENT_LOG_ERROR("failed to destroy media keys due to '%s'", ipcController->ErrorText().c_str());
     306              :     }
     307          104 : }
     308              : 
     309            0 : MediaKeyErrorStatus MediaKeysIpc::selectKeyId(int32_t keySessionId, const std::vector<uint8_t> &keyId)
     310              : {
     311            0 :     RIALTO_CLIENT_LOG_ERROR("Not Implemented");
     312            0 :     return MediaKeyErrorStatus::FAIL;
     313              : }
     314              : 
     315            5 : bool MediaKeysIpc::containsKey(int32_t keySessionId, const std::vector<uint8_t> &keyId)
     316              : {
     317            5 :     if (!reattachChannelIfRequired())
     318              :     {
     319            1 :         RIALTO_CLIENT_LOG_ERROR("Reattachment of the ipc channel failed, ipc disconnected");
     320            1 :         return false;
     321              :     }
     322              : 
     323            4 :     firebolt::rialto::ContainsKeyRequest request;
     324            4 :     request.set_media_keys_handle(m_mediaKeysHandle);
     325            4 :     request.set_key_session_id(keySessionId);
     326           16 :     for (const auto &keyIdItem : keyId)
     327              :     {
     328           12 :         request.add_key_id(keyIdItem);
     329              :     }
     330              : 
     331            4 :     firebolt::rialto::ContainsKeyResponse response;
     332              :     // Default return value to false
     333            4 :     response.set_contains_key(false);
     334              : 
     335            4 :     auto ipcController = m_ipc.createRpcController();
     336            4 :     auto blockingClosure = m_ipc.createBlockingClosure();
     337            4 :     m_mediaKeysStub->containsKey(ipcController.get(), &request, &response, blockingClosure.get());
     338              : 
     339              :     // wait for the call to complete
     340            4 :     blockingClosure->wait();
     341              : 
     342            4 :     if (ipcController->Failed())
     343              :     {
     344            1 :         RIALTO_CLIENT_LOG_ERROR("containsKey failed due to '%s'", ipcController->ErrorText().c_str());
     345            1 :         return false;
     346              :     }
     347              : 
     348            3 :     return response.contains_key();
     349            4 : }
     350              : 
     351           23 : MediaKeyErrorStatus MediaKeysIpc::createKeySession(KeySessionType sessionType, std::weak_ptr<IMediaKeysClient> client,
     352              :                                                    int32_t &keySessionId)
     353              : {
     354           23 :     if (!reattachChannelIfRequired())
     355              :     {
     356            1 :         RIALTO_CLIENT_LOG_ERROR("Reattachment of the ipc channel failed, ipc disconnected");
     357            1 :         return MediaKeyErrorStatus::FAIL;
     358              :     }
     359              : 
     360           22 :     CreateKeySessionRequest_KeySessionType protoSessionType = CreateKeySessionRequest_KeySessionType_UNKNOWN;
     361           22 :     switch (sessionType)
     362              :     {
     363            0 :     case KeySessionType::TEMPORARY:
     364            0 :         protoSessionType = CreateKeySessionRequest_KeySessionType_TEMPORARY;
     365            0 :         break;
     366           22 :     case KeySessionType::PERSISTENT_LICENCE:
     367           22 :         protoSessionType = CreateKeySessionRequest_KeySessionType_PERSISTENT_LICENCE;
     368           22 :         break;
     369            0 :     case KeySessionType::PERSISTENT_RELEASE_MESSAGE:
     370            0 :         protoSessionType = CreateKeySessionRequest_KeySessionType_PERSISTENT_RELEASE_MESSAGE;
     371            0 :         break;
     372            0 :     default:
     373            0 :         RIALTO_CLIENT_LOG_WARN("Recieved unknown key session type");
     374            0 :         break;
     375              :     }
     376              : 
     377           44 :     firebolt::rialto::CreateKeySessionRequest request;
     378           22 :     request.set_media_keys_handle(m_mediaKeysHandle);
     379           22 :     request.set_session_type(protoSessionType);
     380              : 
     381           44 :     firebolt::rialto::CreateKeySessionResponse response;
     382              :     // Default error status to FAIL
     383           22 :     response.set_error_status(ProtoMediaKeyErrorStatus::FAIL);
     384              : 
     385           44 :     auto ipcController = m_ipc.createRpcController();
     386           22 :     auto blockingClosure = m_ipc.createBlockingClosure();
     387           22 :     m_mediaKeysStub->createKeySession(ipcController.get(), &request, &response, blockingClosure.get());
     388              : 
     389              :     // wait for the call to complete
     390           22 :     blockingClosure->wait();
     391              : 
     392              :     MediaKeyErrorStatus status =
     393           44 :         getMediaKeyErrorStatusFromResponse("createKeySession", ipcController, response.error_status());
     394           22 :     if (MediaKeyErrorStatus::OK == status)
     395              :     {
     396           20 :         keySessionId = response.key_session_id();
     397           20 :         m_mediaKeysIpcClient = client;
     398              :     }
     399              : 
     400           22 :     return status;
     401              : }
     402              : 
     403            5 : MediaKeyErrorStatus MediaKeysIpc::generateRequest(int32_t keySessionId, InitDataType initDataType,
     404              :                                                   const std::vector<uint8_t> &initData,
     405              :                                                   const LimitedDurationLicense &ldlState)
     406              : {
     407            5 :     if (!reattachChannelIfRequired())
     408              :     {
     409            1 :         RIALTO_CLIENT_LOG_ERROR("Reattachment of the ipc channel failed, ipc disconnected");
     410            1 :         return MediaKeyErrorStatus::FAIL;
     411              :     }
     412              : 
     413            4 :     GenerateRequestRequest_InitDataType protoInitDataType = GenerateRequestRequest_InitDataType_UNKNOWN;
     414            4 :     switch (initDataType)
     415              :     {
     416            0 :     case InitDataType::CENC:
     417            0 :         protoInitDataType = GenerateRequestRequest_InitDataType_CENC;
     418            0 :         break;
     419            4 :     case InitDataType::KEY_IDS:
     420            4 :         protoInitDataType = GenerateRequestRequest_InitDataType_KEY_IDS;
     421            4 :         break;
     422            0 :     case InitDataType::WEBM:
     423            0 :         protoInitDataType = GenerateRequestRequest_InitDataType_WEBM;
     424            0 :         break;
     425            0 :     case InitDataType::DRMHEADER:
     426            0 :         protoInitDataType = GenerateRequestRequest_InitDataType_DRMHEADER;
     427            0 :         break;
     428            0 :     default:
     429            0 :         RIALTO_CLIENT_LOG_WARN("Recieved unknown init data type");
     430            0 :         break;
     431              :     }
     432              : 
     433            4 :     GenerateRequestRequest_LimitedDurationLicense protoLimitedDurationLicense{
     434              :         GenerateRequestRequest_LimitedDurationLicense_NOT_SPECIFIED};
     435            4 :     switch (ldlState)
     436              :     {
     437            4 :     case LimitedDurationLicense::NOT_SPECIFIED:
     438            4 :         protoLimitedDurationLicense = GenerateRequestRequest_LimitedDurationLicense_NOT_SPECIFIED;
     439            4 :         break;
     440            0 :     case LimitedDurationLicense::ENABLED:
     441            0 :         protoLimitedDurationLicense = GenerateRequestRequest_LimitedDurationLicense_ENABLED;
     442            0 :         break;
     443            0 :     case LimitedDurationLicense::DISABLED:
     444            0 :         protoLimitedDurationLicense = GenerateRequestRequest_LimitedDurationLicense_DISABLED;
     445            0 :         break;
     446            0 :     default:
     447            0 :         RIALTO_CLIENT_LOG_WARN("Received unknown limited duration license state");
     448            0 :         break;
     449              :     }
     450              : 
     451            8 :     firebolt::rialto::GenerateRequestRequest request;
     452            4 :     request.set_media_keys_handle(m_mediaKeysHandle);
     453            4 :     request.set_key_session_id(keySessionId);
     454            4 :     request.set_init_data_type(protoInitDataType);
     455            4 :     request.set_ldl_state(protoLimitedDurationLicense);
     456              : 
     457           16 :     for (auto it = initData.begin(); it != initData.end(); it++)
     458              :     {
     459           12 :         request.add_init_data(*it);
     460              :     }
     461              : 
     462            8 :     firebolt::rialto::GenerateRequestResponse response;
     463              :     // Default error status to FAIL
     464            4 :     response.set_error_status(ProtoMediaKeyErrorStatus::FAIL);
     465              : 
     466            8 :     auto ipcController = m_ipc.createRpcController();
     467            4 :     auto blockingClosure = m_ipc.createBlockingClosure();
     468            4 :     m_mediaKeysStub->generateRequest(ipcController.get(), &request, &response, blockingClosure.get());
     469              : 
     470              :     // wait for the call to complete
     471            4 :     blockingClosure->wait();
     472              : 
     473           12 :     return getMediaKeyErrorStatusFromResponse("generateRequest", ipcController, response.error_status());
     474              : }
     475              : 
     476            5 : MediaKeyErrorStatus MediaKeysIpc::loadSession(int32_t keySessionId, const std::string &cdmKeySessionId)
     477              : {
     478            5 :     if (!reattachChannelIfRequired())
     479              :     {
     480            1 :         RIALTO_CLIENT_LOG_ERROR("Reattachment of the ipc channel failed, ipc disconnected");
     481            1 :         return MediaKeyErrorStatus::FAIL;
     482              :     }
     483              : 
     484            4 :     firebolt::rialto::LoadSessionRequest request;
     485            4 :     request.set_media_keys_handle(m_mediaKeysHandle);
     486            4 :     request.set_key_session_id(keySessionId);
     487              :     request.set_cdm_key_session_id(cdmKeySessionId);
     488              : 
     489            4 :     firebolt::rialto::LoadSessionResponse response;
     490              :     // Default error status to FAIL
     491            4 :     response.set_error_status(ProtoMediaKeyErrorStatus::FAIL);
     492              : 
     493            4 :     auto ipcController = m_ipc.createRpcController();
     494            4 :     auto blockingClosure = m_ipc.createBlockingClosure();
     495            4 :     m_mediaKeysStub->loadSession(ipcController.get(), &request, &response, blockingClosure.get());
     496              : 
     497              :     // wait for the call to complete
     498            4 :     blockingClosure->wait();
     499              : 
     500            8 :     return getMediaKeyErrorStatusFromResponse("loadSession", ipcController, response.error_status());
     501            4 : }
     502              : 
     503            5 : MediaKeyErrorStatus MediaKeysIpc::updateSession(int32_t keySessionId, const std::vector<uint8_t> &responseData)
     504              : {
     505            5 :     if (!reattachChannelIfRequired())
     506              :     {
     507            1 :         RIALTO_CLIENT_LOG_ERROR("Reattachment of the ipc channel failed, ipc disconnected");
     508            1 :         return MediaKeyErrorStatus::FAIL;
     509              :     }
     510              : 
     511            4 :     firebolt::rialto::UpdateSessionRequest request;
     512            4 :     request.set_media_keys_handle(m_mediaKeysHandle);
     513            4 :     request.set_key_session_id(keySessionId);
     514              : 
     515           16 :     for (auto it = responseData.begin(); it != responseData.end(); it++)
     516              :     {
     517           12 :         request.add_response_data(*it);
     518              :     }
     519              : 
     520            4 :     firebolt::rialto::UpdateSessionResponse response;
     521              :     // Default error status to FAIL
     522            4 :     response.set_error_status(ProtoMediaKeyErrorStatus::FAIL);
     523              : 
     524            4 :     auto ipcController = m_ipc.createRpcController();
     525            4 :     auto blockingClosure = m_ipc.createBlockingClosure();
     526            4 :     m_mediaKeysStub->updateSession(ipcController.get(), &request, &response, blockingClosure.get());
     527              : 
     528              :     // wait for the call to complete
     529            4 :     blockingClosure->wait();
     530              : 
     531            8 :     return getMediaKeyErrorStatusFromResponse("updateSession", ipcController, response.error_status());
     532            4 : }
     533              : 
     534            5 : MediaKeyErrorStatus MediaKeysIpc::setDrmHeader(int32_t keySessionId, const std::vector<uint8_t> &requestData)
     535              : {
     536            5 :     if (!reattachChannelIfRequired())
     537              :     {
     538            1 :         RIALTO_CLIENT_LOG_ERROR("Reattachment of the ipc channel failed, ipc disconnected");
     539            1 :         return MediaKeyErrorStatus::FAIL;
     540              :     }
     541              : 
     542            4 :     firebolt::rialto::SetDrmHeaderRequest request;
     543            4 :     request.set_media_keys_handle(m_mediaKeysHandle);
     544            4 :     request.set_key_session_id(keySessionId);
     545           16 :     for (const auto &requestDataItem : requestData)
     546              :     {
     547           12 :         request.add_request_data(requestDataItem);
     548              :     }
     549              : 
     550            4 :     firebolt::rialto::SetDrmHeaderResponse response;
     551              :     // Default error status to FAIL
     552            4 :     response.set_error_status(ProtoMediaKeyErrorStatus::FAIL);
     553              : 
     554            4 :     auto ipcController = m_ipc.createRpcController();
     555            4 :     auto blockingClosure = m_ipc.createBlockingClosure();
     556            4 :     m_mediaKeysStub->setDrmHeader(ipcController.get(), &request, &response, blockingClosure.get());
     557              : 
     558              :     // wait for the call to complete
     559            4 :     blockingClosure->wait();
     560              : 
     561            8 :     return getMediaKeyErrorStatusFromResponse("setDrmHeader", ipcController, response.error_status());
     562            4 : }
     563              : 
     564            5 : MediaKeyErrorStatus MediaKeysIpc::closeKeySession(int32_t keySessionId)
     565              : {
     566            5 :     if (!reattachChannelIfRequired())
     567              :     {
     568            1 :         RIALTO_CLIENT_LOG_ERROR("Reattachment of the ipc channel failed, ipc disconnected");
     569            1 :         return MediaKeyErrorStatus::FAIL;
     570              :     }
     571              : 
     572              :     // Reset client
     573            4 :     m_mediaKeysIpcClient.reset();
     574              : 
     575            4 :     firebolt::rialto::CloseKeySessionRequest request;
     576            4 :     request.set_media_keys_handle(m_mediaKeysHandle);
     577            4 :     request.set_key_session_id(keySessionId);
     578              : 
     579            4 :     firebolt::rialto::CloseKeySessionResponse response;
     580              :     // Default error status to FAIL
     581            4 :     response.set_error_status(ProtoMediaKeyErrorStatus::FAIL);
     582              : 
     583            4 :     auto ipcController = m_ipc.createRpcController();
     584            4 :     auto blockingClosure = m_ipc.createBlockingClosure();
     585            4 :     m_mediaKeysStub->closeKeySession(ipcController.get(), &request, &response, blockingClosure.get());
     586              : 
     587              :     // wait for the call to complete
     588            4 :     blockingClosure->wait();
     589              : 
     590            8 :     return getMediaKeyErrorStatusFromResponse("closeKeySession", ipcController, response.error_status());
     591            4 : }
     592              : 
     593            5 : MediaKeyErrorStatus MediaKeysIpc::removeKeySession(int32_t keySessionId)
     594              : {
     595            5 :     if (!reattachChannelIfRequired())
     596              :     {
     597            1 :         RIALTO_CLIENT_LOG_ERROR("Reattachment of the ipc channel failed, ipc disconnected");
     598            1 :         return MediaKeyErrorStatus::FAIL;
     599              :     }
     600              : 
     601            4 :     firebolt::rialto::RemoveKeySessionRequest request;
     602            4 :     request.set_media_keys_handle(m_mediaKeysHandle);
     603            4 :     request.set_key_session_id(keySessionId);
     604              : 
     605            4 :     firebolt::rialto::RemoveKeySessionResponse response;
     606              :     // Default error status to FAIL
     607            4 :     response.set_error_status(ProtoMediaKeyErrorStatus::FAIL);
     608              : 
     609            4 :     auto ipcController = m_ipc.createRpcController();
     610            4 :     auto blockingClosure = m_ipc.createBlockingClosure();
     611            4 :     m_mediaKeysStub->removeKeySession(ipcController.get(), &request, &response, blockingClosure.get());
     612              : 
     613              :     // wait for the call to complete
     614            4 :     blockingClosure->wait();
     615              : 
     616            8 :     return getMediaKeyErrorStatusFromResponse("removeKeySession", ipcController, response.error_status());
     617            4 : }
     618              : 
     619            5 : MediaKeyErrorStatus MediaKeysIpc::deleteDrmStore()
     620              : {
     621            5 :     if (!reattachChannelIfRequired())
     622              :     {
     623            1 :         RIALTO_CLIENT_LOG_ERROR("Reattachment of the ipc channel failed, ipc disconnected");
     624            1 :         return MediaKeyErrorStatus::FAIL;
     625              :     }
     626              : 
     627            4 :     firebolt::rialto::DeleteDrmStoreRequest request;
     628            4 :     request.set_media_keys_handle(m_mediaKeysHandle);
     629              : 
     630            4 :     firebolt::rialto::DeleteDrmStoreResponse response;
     631              :     // Default error status to FAIL
     632            4 :     response.set_error_status(ProtoMediaKeyErrorStatus::FAIL);
     633              : 
     634            4 :     auto ipcController = m_ipc.createRpcController();
     635            4 :     auto blockingClosure = m_ipc.createBlockingClosure();
     636            4 :     m_mediaKeysStub->deleteDrmStore(ipcController.get(), &request, &response, blockingClosure.get());
     637              : 
     638              :     // wait for the call to complete
     639            4 :     blockingClosure->wait();
     640              : 
     641            8 :     return getMediaKeyErrorStatusFromResponse("deleteDrmStore", ipcController, response.error_status());
     642            4 : }
     643              : 
     644            5 : MediaKeyErrorStatus MediaKeysIpc::deleteKeyStore()
     645              : {
     646            5 :     if (!reattachChannelIfRequired())
     647              :     {
     648            1 :         RIALTO_CLIENT_LOG_ERROR("Reattachment of the ipc channel failed, ipc disconnected");
     649            1 :         return MediaKeyErrorStatus::FAIL;
     650              :     }
     651              : 
     652            4 :     firebolt::rialto::DeleteKeyStoreRequest request;
     653            4 :     request.set_media_keys_handle(m_mediaKeysHandle);
     654              : 
     655            4 :     firebolt::rialto::DeleteKeyStoreResponse response;
     656              :     // Default error status to FAIL
     657            4 :     response.set_error_status(ProtoMediaKeyErrorStatus::FAIL);
     658              : 
     659            4 :     auto ipcController = m_ipc.createRpcController();
     660            4 :     auto blockingClosure = m_ipc.createBlockingClosure();
     661            4 :     m_mediaKeysStub->deleteKeyStore(ipcController.get(), &request, &response, blockingClosure.get());
     662              : 
     663              :     // wait for the call to complete
     664            4 :     blockingClosure->wait();
     665              : 
     666            8 :     return getMediaKeyErrorStatusFromResponse("deleteKeyStore", ipcController, response.error_status());
     667            4 : }
     668              : 
     669            5 : MediaKeyErrorStatus MediaKeysIpc::getDrmStoreHash(std::vector<unsigned char> &drmStoreHash)
     670              : {
     671            5 :     if (!reattachChannelIfRequired())
     672              :     {
     673            1 :         RIALTO_CLIENT_LOG_ERROR("Reattachment of the ipc channel failed, ipc disconnected");
     674            1 :         return MediaKeyErrorStatus::FAIL;
     675              :     }
     676              : 
     677            4 :     firebolt::rialto::GetDrmStoreHashRequest request;
     678            4 :     request.set_media_keys_handle(m_mediaKeysHandle);
     679              : 
     680            4 :     firebolt::rialto::GetDrmStoreHashResponse response;
     681              :     // Default error status to FAIL
     682            4 :     response.set_error_status(ProtoMediaKeyErrorStatus::FAIL);
     683              : 
     684            4 :     auto ipcController = m_ipc.createRpcController();
     685            4 :     auto blockingClosure = m_ipc.createBlockingClosure();
     686            4 :     m_mediaKeysStub->getDrmStoreHash(ipcController.get(), &request, &response, blockingClosure.get());
     687              : 
     688              :     // wait for the call to complete
     689            4 :     blockingClosure->wait();
     690              : 
     691            4 :     if (ProtoMediaKeyErrorStatus::OK == response.error_status())
     692              :     {
     693            4 :         drmStoreHash = std::vector<unsigned char>(response.drm_store_hash().begin(), response.drm_store_hash().end());
     694              :     }
     695              : 
     696            8 :     return getMediaKeyErrorStatusFromResponse("getDrmStoreHash", ipcController, response.error_status());
     697            4 : }
     698              : 
     699            5 : MediaKeyErrorStatus MediaKeysIpc::getKeyStoreHash(std::vector<unsigned char> &keyStoreHash)
     700              : {
     701            5 :     if (!reattachChannelIfRequired())
     702              :     {
     703            1 :         RIALTO_CLIENT_LOG_ERROR("Reattachment of the ipc channel failed, ipc disconnected");
     704            1 :         return MediaKeyErrorStatus::FAIL;
     705              :     }
     706              : 
     707            4 :     firebolt::rialto::GetKeyStoreHashRequest request;
     708            4 :     request.set_media_keys_handle(m_mediaKeysHandle);
     709              : 
     710            4 :     firebolt::rialto::GetKeyStoreHashResponse response;
     711              :     // Default error status to FAIL
     712            4 :     response.set_error_status(ProtoMediaKeyErrorStatus::FAIL);
     713              : 
     714            4 :     auto ipcController = m_ipc.createRpcController();
     715            4 :     auto blockingClosure = m_ipc.createBlockingClosure();
     716            4 :     m_mediaKeysStub->getKeyStoreHash(ipcController.get(), &request, &response, blockingClosure.get());
     717              : 
     718              :     // wait for the call to complete
     719            4 :     blockingClosure->wait();
     720              : 
     721            4 :     if (ProtoMediaKeyErrorStatus::OK == response.error_status())
     722              :     {
     723            4 :         keyStoreHash = std::vector<unsigned char>(response.key_store_hash().begin(), response.key_store_hash().end());
     724              :     }
     725              : 
     726            8 :     return getMediaKeyErrorStatusFromResponse("getKeyStoreHash", ipcController, response.error_status());
     727            4 : }
     728              : 
     729            5 : MediaKeyErrorStatus MediaKeysIpc::getLdlSessionsLimit(uint32_t &ldlLimit)
     730              : {
     731            5 :     if (!reattachChannelIfRequired())
     732              :     {
     733            1 :         RIALTO_CLIENT_LOG_ERROR("Reattachment of the ipc channel failed, ipc disconnected");
     734            1 :         return MediaKeyErrorStatus::FAIL;
     735              :     }
     736              : 
     737            4 :     firebolt::rialto::GetLdlSessionsLimitRequest request;
     738            4 :     request.set_media_keys_handle(m_mediaKeysHandle);
     739              : 
     740            4 :     firebolt::rialto::GetLdlSessionsLimitResponse response;
     741              :     // Default error status to FAIL
     742            4 :     response.set_error_status(ProtoMediaKeyErrorStatus::FAIL);
     743              : 
     744            4 :     auto ipcController = m_ipc.createRpcController();
     745            4 :     auto blockingClosure = m_ipc.createBlockingClosure();
     746            4 :     m_mediaKeysStub->getLdlSessionsLimit(ipcController.get(), &request, &response, blockingClosure.get());
     747              : 
     748              :     // wait for the call to complete
     749            4 :     blockingClosure->wait();
     750              : 
     751            4 :     if (ProtoMediaKeyErrorStatus::OK == response.error_status())
     752              :     {
     753            2 :         ldlLimit = response.ldl_limit();
     754              :     }
     755              : 
     756            8 :     return getMediaKeyErrorStatusFromResponse("getLdlSessionsLimit", ipcController, response.error_status());
     757            4 : }
     758              : 
     759            5 : MediaKeyErrorStatus MediaKeysIpc::getLastDrmError(int32_t keySessionId, uint32_t &errorCode)
     760              : {
     761            5 :     if (!reattachChannelIfRequired())
     762              :     {
     763            1 :         RIALTO_CLIENT_LOG_ERROR("Reattachment of the ipc channel failed, ipc disconnected");
     764            1 :         return MediaKeyErrorStatus::FAIL;
     765              :     }
     766              : 
     767            4 :     firebolt::rialto::GetLastDrmErrorRequest request;
     768            4 :     request.set_media_keys_handle(m_mediaKeysHandle);
     769            4 :     request.set_key_session_id(keySessionId);
     770              : 
     771            4 :     firebolt::rialto::GetLastDrmErrorResponse response;
     772              :     // Default error status to FAIL
     773            4 :     response.set_error_status(ProtoMediaKeyErrorStatus::FAIL);
     774              : 
     775            4 :     auto ipcController = m_ipc.createRpcController();
     776            4 :     auto blockingClosure = m_ipc.createBlockingClosure();
     777            4 :     m_mediaKeysStub->getLastDrmError(ipcController.get(), &request, &response, blockingClosure.get());
     778              : 
     779              :     // wait for the call to complete
     780            4 :     blockingClosure->wait();
     781              : 
     782            4 :     if (ProtoMediaKeyErrorStatus::OK == response.error_status())
     783              :     {
     784            2 :         errorCode = response.error_code();
     785              :     }
     786              : 
     787            8 :     return getMediaKeyErrorStatusFromResponse("getLastDrmError", ipcController, response.error_status());
     788            4 : }
     789              : 
     790            5 : MediaKeyErrorStatus MediaKeysIpc::getDrmTime(uint64_t &drmTime)
     791              : {
     792            5 :     if (!reattachChannelIfRequired())
     793              :     {
     794            1 :         RIALTO_CLIENT_LOG_ERROR("Reattachment of the ipc channel failed, ipc disconnected");
     795            1 :         return MediaKeyErrorStatus::FAIL;
     796              :     }
     797              : 
     798            4 :     firebolt::rialto::GetDrmTimeRequest request;
     799            4 :     request.set_media_keys_handle(m_mediaKeysHandle);
     800              : 
     801            4 :     firebolt::rialto::GetDrmTimeResponse response;
     802              :     // Default error status to FAIL
     803            4 :     response.set_error_status(ProtoMediaKeyErrorStatus::FAIL);
     804              : 
     805            4 :     auto ipcController = m_ipc.createRpcController();
     806            4 :     auto blockingClosure = m_ipc.createBlockingClosure();
     807            4 :     m_mediaKeysStub->getDrmTime(ipcController.get(), &request, &response, blockingClosure.get());
     808              : 
     809              :     // wait for the call to complete
     810            4 :     blockingClosure->wait();
     811              : 
     812            4 :     if (ProtoMediaKeyErrorStatus::OK == response.error_status())
     813              :     {
     814            2 :         drmTime = response.drm_time();
     815              :     }
     816              : 
     817            8 :     return getMediaKeyErrorStatusFromResponse("getDrmTime", ipcController, response.error_status());
     818            4 : }
     819              : 
     820            5 : MediaKeyErrorStatus MediaKeysIpc::getCdmKeySessionId(int32_t keySessionId, std::string &cdmKeySessionId)
     821              : {
     822            5 :     if (!reattachChannelIfRequired())
     823              :     {
     824            1 :         RIALTO_CLIENT_LOG_ERROR("Reattachment of the ipc channel failed, ipc disconnected");
     825            1 :         return MediaKeyErrorStatus::FAIL;
     826              :     }
     827              : 
     828            4 :     firebolt::rialto::GetCdmKeySessionIdRequest request;
     829            4 :     request.set_media_keys_handle(m_mediaKeysHandle);
     830            4 :     request.set_key_session_id(keySessionId);
     831              : 
     832            4 :     firebolt::rialto::GetCdmKeySessionIdResponse response;
     833              :     // Default error status to FAIL
     834            4 :     response.set_error_status(ProtoMediaKeyErrorStatus::FAIL);
     835              : 
     836            4 :     auto ipcController = m_ipc.createRpcController();
     837            4 :     auto blockingClosure = m_ipc.createBlockingClosure();
     838            4 :     m_mediaKeysStub->getCdmKeySessionId(ipcController.get(), &request, &response, blockingClosure.get());
     839              : 
     840              :     // wait for the call to complete
     841            4 :     blockingClosure->wait();
     842              : 
     843            4 :     cdmKeySessionId = response.cdm_key_session_id();
     844              : 
     845            8 :     return getMediaKeyErrorStatusFromResponse("getCdmKeySessionId", ipcController, response.error_status());
     846            4 : }
     847              : 
     848            5 : MediaKeyErrorStatus MediaKeysIpc::releaseKeySession(int32_t keySessionId)
     849              : {
     850            5 :     if (!reattachChannelIfRequired())
     851              :     {
     852            1 :         RIALTO_CLIENT_LOG_ERROR("Reattachment of the ipc channel failed, ipc disconnected");
     853            1 :         return MediaKeyErrorStatus::FAIL;
     854              :     }
     855              : 
     856              :     // Reset client
     857            4 :     m_mediaKeysIpcClient.reset();
     858              : 
     859            4 :     firebolt::rialto::ReleaseKeySessionRequest request;
     860            4 :     request.set_media_keys_handle(m_mediaKeysHandle);
     861            4 :     request.set_key_session_id(keySessionId);
     862              : 
     863            4 :     firebolt::rialto::ReleaseKeySessionResponse response;
     864              :     // Default error status to FAIL
     865            4 :     response.set_error_status(ProtoMediaKeyErrorStatus::FAIL);
     866              : 
     867            4 :     auto ipcController = m_ipc.createRpcController();
     868            4 :     auto blockingClosure = m_ipc.createBlockingClosure();
     869            4 :     m_mediaKeysStub->releaseKeySession(ipcController.get(), &request, &response, blockingClosure.get());
     870              : 
     871              :     // wait for the call to complete
     872            4 :     blockingClosure->wait();
     873              : 
     874            8 :     return getMediaKeyErrorStatusFromResponse("releaseKeySession", ipcController, response.error_status());
     875            4 : }
     876              : 
     877            3 : void MediaKeysIpc::onLicenseRequest(const std::shared_ptr<firebolt::rialto::LicenseRequestEvent> &event)
     878              : {
     879            3 :     std::shared_ptr<IMediaKeysClient> mediaKeysIpcClient = m_mediaKeysIpcClient.lock();
     880              : 
     881              :     /* Ignore event if not for this session or no client */
     882            3 :     if ((event->media_keys_handle() == m_mediaKeysHandle) && (mediaKeysIpcClient))
     883              :     {
     884            1 :         std::vector<unsigned char> messageVector = std::vector<unsigned char>{event->license_request_message().begin(),
     885            2 :                                                                               event->license_request_message().end()};
     886            1 :         mediaKeysIpcClient->onLicenseRequest(event->key_session_id(), messageVector, event->url());
     887              :     }
     888            3 : }
     889              : 
     890            6 : void MediaKeysIpc::onLicenseRenewal(const std::shared_ptr<firebolt::rialto::LicenseRenewalEvent> &event)
     891              : {
     892            6 :     std::shared_ptr<IMediaKeysClient> mediaKeysIpcClient = m_mediaKeysIpcClient.lock();
     893              : 
     894              :     /* Ignore event if not for this session or no client */
     895            6 :     if ((event->media_keys_handle() == m_mediaKeysHandle) && (mediaKeysIpcClient))
     896              :     {
     897            2 :         std::vector<unsigned char> messageVector = std::vector<unsigned char>{event->license_renewal_message().begin(),
     898            4 :                                                                               event->license_renewal_message().end()};
     899            2 :         mediaKeysIpcClient->onLicenseRenewal(event->key_session_id(), messageVector);
     900              :     }
     901            6 : }
     902              : 
     903            3 : void MediaKeysIpc::onLicenseRelease(const std::shared_ptr<firebolt::rialto::LicenseReleaseEvent> &event)
     904              : {
     905            3 :     std::shared_ptr<IMediaKeysClient> mediaKeysIpcClient = m_mediaKeysIpcClient.lock();
     906              : 
     907              :     /* Ignore event if not for this session or no client */
     908            3 :     if ((event->media_keys_handle() == m_mediaKeysHandle) && (mediaKeysIpcClient))
     909              :     {
     910            1 :         std::vector<unsigned char> messageVector = std::vector<unsigned char>{event->license_release_message().begin(),
     911            2 :                                                                               event->license_release_message().end()};
     912            1 :         mediaKeysIpcClient->onLicenseRelease(event->key_session_id(), messageVector, event->url());
     913              :     }
     914            3 : }
     915              : 
     916            3 : void MediaKeysIpc::onKeyStatusesChanged(const std::shared_ptr<firebolt::rialto::KeyStatusesChangedEvent> &event)
     917              : {
     918            3 :     std::shared_ptr<IMediaKeysClient> mediaKeysIpcClient = m_mediaKeysIpcClient.lock();
     919              : 
     920              :     /* Ignore event if not for this session or no client */
     921            3 :     if ((event->media_keys_handle() == m_mediaKeysHandle) && (mediaKeysIpcClient))
     922              :     {
     923            1 :         KeyStatusVector keyStatuses;
     924            4 :         for (auto it = event->key_statuses().begin(); it != event->key_statuses().end(); it++)
     925              :         {
     926            6 :             std::vector<unsigned char> keyVector = std::vector<unsigned char>{it->key_id().begin(), it->key_id().end()};
     927            3 :             KeyStatus keyStatus = convertKeyStatus(it->key_status());
     928            3 :             keyStatuses.push_back(std::make_pair(keyVector, keyStatus));
     929              :         }
     930            1 :         mediaKeysIpcClient->onKeyStatusesChanged(event->key_session_id(), keyStatuses);
     931              :     }
     932            3 : }
     933              : 
     934              : MediaKeyErrorStatus
     935           86 : MediaKeysIpc::getMediaKeyErrorStatusFromResponse(const std::string methodName,
     936              :                                                  const std::shared_ptr<google::protobuf::RpcController> &controller,
     937              :                                                  ProtoMediaKeyErrorStatus status)
     938              : {
     939           86 :     if (controller->Failed())
     940              :     {
     941           17 :         RIALTO_CLIENT_LOG_ERROR("%s failed due to '%s'", methodName.c_str(), controller->ErrorText().c_str());
     942           17 :         return MediaKeyErrorStatus::FAIL;
     943              :     }
     944           69 :     MediaKeyErrorStatus returnStatus = convertMediaKeyErrorStatus(status);
     945           69 :     if (MediaKeyErrorStatus::OK != returnStatus)
     946              :     {
     947           17 :         RIALTO_CLIENT_LOG_ERROR("%s failed due to MediaKeyErrorStatus '%s'", methodName.c_str(), toString(returnStatus));
     948           17 :         return returnStatus;
     949              :     }
     950              : 
     951           52 :     return returnStatus;
     952              : }
     953              : 
     954            5 : MediaKeyErrorStatus MediaKeysIpc::getMetricSystemData(std::vector<uint8_t> &buffer)
     955              : {
     956            5 :     if (!reattachChannelIfRequired())
     957              :     {
     958            1 :         RIALTO_CLIENT_LOG_ERROR("Reattachment of the ipc channel failed, ipc disconnected");
     959            1 :         return MediaKeyErrorStatus::FAIL;
     960              :     }
     961              : 
     962            4 :     firebolt::rialto::GetMetricSystemDataRequest request;
     963            4 :     request.set_media_keys_handle(m_mediaKeysHandle);
     964              : 
     965            4 :     firebolt::rialto::GetMetricSystemDataResponse response;
     966              :     // Default error status to FAIL
     967            4 :     response.set_error_status(ProtoMediaKeyErrorStatus::FAIL);
     968              : 
     969            4 :     auto ipcController = m_ipc.createRpcController();
     970            4 :     auto blockingClosure = m_ipc.createBlockingClosure();
     971            4 :     m_mediaKeysStub->getMetricSystemData(ipcController.get(), &request, &response, blockingClosure.get());
     972              : 
     973              :     // wait for the call to complete
     974            4 :     blockingClosure->wait();
     975              : 
     976            4 :     if (ProtoMediaKeyErrorStatus::OK == response.error_status())
     977              :     {
     978            4 :         buffer = std::vector<uint8_t>(response.buffer().begin(), response.buffer().end());
     979              :     }
     980              : 
     981            8 :     return getMediaKeyErrorStatusFromResponse("getMetricSystemData", ipcController, response.error_status());
     982            4 : }
     983              : 
     984              : }; // namespace firebolt::rialto::client
        

Generated by: LCOV version 2.0-1