LCOV - code coverage report
Current view: top level - media/server/gstplayer/source - GstProtectionMetadataHelper.cpp (source / functions) Coverage Total Hit
Test: coverage.info Lines: 90.9 % 22 20
Test Date: 2025-02-18 13:13:53 Functions: 100.0 % 5 5

            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 "GstProtectionMetadataHelper.h"
      21              : #include "GstProtectionMetadataHelperFactory.h"
      22              : #include "RialtoServerLogging.h"
      23              : 
      24              : namespace firebolt::rialto::server
      25              : {
      26            1 : std::shared_ptr<IGstProtectionMetadataHelperFactory> IGstProtectionMetadataHelperFactory::createFactory()
      27              : {
      28            1 :     std::shared_ptr<IGstProtectionMetadataHelperFactory> factory;
      29              : 
      30              :     try
      31              :     {
      32            1 :         factory = std::make_shared<GstProtectionMetadataHelperFactory>();
      33              :     }
      34            0 :     catch (const std::exception &e)
      35              :     {
      36            0 :         RIALTO_SERVER_LOG_ERROR("Failed to create the protection metadata wrapper factory, reason: %s", e.what());
      37              :     }
      38              : 
      39            1 :     return factory;
      40              : }
      41              : 
      42            1 : std::unique_ptr<IGstProtectionMetadataHelper> GstProtectionMetadataHelperFactory::createProtectionMetadataWrapper(
      43              :     const std::shared_ptr<firebolt::rialto::wrappers::IGstWrapper> &gstWrapper) const
      44              : {
      45            1 :     return std::make_unique<GstProtectionMetadataHelper>(gstWrapper);
      46              : }
      47              : 
      48            1 : GstMeta *GstProtectionMetadataHelper::addProtectionMetadata(GstBuffer *gstBuffer, GstRialtoProtectionData &data)
      49              : {
      50            1 :     return m_gstWrapper->gstBufferAddMeta(gstBuffer, GST_RIALTO_PROTECTION_METADATA_INFO, &data);
      51              : }
      52              : 
      53            2 : GstRialtoProtectionData *GstProtectionMetadataHelper::getProtectionMetadataData(GstBuffer *gstBuffer)
      54              : {
      55            2 :     GstMeta *meta = m_gstWrapper->gstBufferGetMeta(gstBuffer, GST_RIALTO_PROTECTION_METADATA_GET_TYPE);
      56            2 :     if (!meta)
      57              :     {
      58            1 :         return nullptr;
      59              :     }
      60              : 
      61            1 :     GstRialtoProtectionMetadata *protectionMetadata = reinterpret_cast<GstRialtoProtectionMetadata *>(meta);
      62            1 :     return &protectionMetadata->data;
      63              : }
      64              : 
      65            3 : void GstProtectionMetadataHelper::removeProtectionMetadata(GstBuffer *gstBuffer)
      66              : {
      67            3 :     GstMeta *meta = m_gstWrapper->gstBufferGetMeta(gstBuffer, GST_RIALTO_PROTECTION_METADATA_GET_TYPE);
      68            3 :     if (meta)
      69              :     {
      70            2 :         if (!m_gstWrapper->gstBufferRemoveMeta(gstBuffer, meta))
      71              :         {
      72            1 :             RIALTO_SERVER_LOG_ERROR("Failed to remove metadata");
      73              :         }
      74              :     }
      75            3 : }
      76              : 
      77              : } // namespace firebolt::rialto::server
        

Generated by: LCOV version 2.0-1