LCOV - code coverage report
Current view: top level - media/server/gstplayer/source - GstProtectionMetadata.cpp (source / functions) Coverage Total Hit
Test: coverage.info Lines: 35.7 % 28 10
Test Date: 2025-02-18 13:13:53 Functions: 50.0 % 4 2

            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 "GstProtectionMetadata.h"
      21              : #include "RialtoServerLogging.h"
      22              : #include <gst/gstconfig.h>
      23              : #include <stdio.h>
      24              : 
      25            0 : static gboolean rialto_eme_protection_metadata_init(GstMeta *meta, gpointer params, // NOLINT(build/function_format)
      26              :                                                     GstBuffer *buffer)
      27              : {
      28            0 :     GstRialtoProtectionMetadata *emeta = reinterpret_cast<GstRialtoProtectionMetadata *>(meta);
      29            0 :     GstRialtoProtectionData *data = static_cast<GstRialtoProtectionData *>(params);
      30            0 :     emeta->data = *data;
      31              : 
      32            0 :     if (emeta->data.decryptionService)
      33              :     {
      34            0 :         emeta->data.decryptionService->incrementSessionIdUsageCounter(emeta->data.keySessionId);
      35              :     }
      36              : 
      37            0 :     return true;
      38              : }
      39              : 
      40            0 : static gboolean rialto_eme_protection_metadata_free(GstMeta *meta, GstBuffer *buffer) // NOLINT(build/function_format)
      41              : {
      42            0 :     GstRialtoProtectionMetadata *protectionMeta = reinterpret_cast<GstRialtoProtectionMetadata *>(meta);
      43              : 
      44            0 :     if (protectionMeta->data.decryptionService)
      45              :     {
      46            0 :         protectionMeta->data.decryptionService->decrementSessionIdUsageCounter(protectionMeta->data.keySessionId);
      47              :     }
      48              : 
      49            0 :     if (protectionMeta->data.subsamples)
      50              :     {
      51            0 :         gst_buffer_unref(protectionMeta->data.subsamples);
      52              :     }
      53            0 :     if (protectionMeta->data.iv)
      54              :     {
      55            0 :         gst_buffer_unref(protectionMeta->data.iv);
      56              :     }
      57            0 :     if (protectionMeta->data.key)
      58              :     {
      59            0 :         gst_buffer_unref(protectionMeta->data.key);
      60              :     }
      61              : 
      62            0 :     return true;
      63              : }
      64              : 
      65           11 : GST_EXPORT GType rialto_eme_protection_metadata_get_type() // NOLINT(build/function_format)
      66              : {
      67              :     static GType g_type;
      68              :     static const gchar *api_tags[] = {"rialto", "protection", NULL};
      69              : 
      70           11 :     if (g_once_init_enter(&g_type))
      71              :     {
      72            1 :         GType _type = gst_meta_api_type_register("GstRialtoProtectionMetadataAPI", api_tags);
      73            1 :         g_once_init_leave(&g_type, _type);
      74              :     }
      75           11 :     return g_type;
      76              : }
      77              : 
      78            2 : const GstMetaInfo *rialto_mse_protection_metadata_get_info() // NOLINT(build/function_format)
      79              : {
      80              :     static const GstMetaInfo *kMetainfo = NULL;
      81            2 :     if (g_once_init_enter(&kMetainfo))
      82              :     {
      83              :         const GstMetaInfo *kGstMeta =
      84            1 :             gst_meta_register(GST_RIALTO_PROTECTION_METADATA_GET_TYPE, "GstRialtoProtectionMetadata",
      85              :                               sizeof(GstRialtoProtectionMetadata),
      86              :                               (GstMetaInitFunction)rialto_eme_protection_metadata_init,
      87              :                               (GstMetaFreeFunction)rialto_eme_protection_metadata_free, (GstMetaTransformFunction)NULL);
      88              : 
      89            1 :         g_once_init_leave(&kMetainfo, kGstMeta);
      90              :     }
      91            2 :     return kMetainfo;
      92              : }
        

Generated by: LCOV version 2.0-1