LCOV - code coverage report
Current view: top level - src/lib/conversion/pid/segment_handlers.c (source / functions) Coverage Total Hit
Test: coverage.filtered.info Lines: 28.6 % 21 6
Test Date: 2025-09-18 00:43:48 Functions: 100.0 % 1 1

            Line data    Source code
       1              : /*
       2              :  *                      GPAC - Multimedia Framework C SDK
       3              :  *
       4              :  *                      Authors: Deniz Ugur, Romain Bouqueau, Sohaib Larbi
       5              :  *                      Copyright (c) Motion Spell
       6              :  *                              All rights reserved
       7              :  *
       8              :  *  This file is part of the GPAC/GStreamer wrapper
       9              :  *
      10              :  *  This GPAC/GStreamer wrapper is free software; you can redistribute it
      11              :  *  and/or modify it under the terms of the GNU Affero General Public License
      12              :  *  as published by the Free Software Foundation; either version 3, or (at
      13              :  *  your option) any later version.
      14              :  *
      15              :  *  This GPAC/GStreamer wrapper is distributed in the hope that it will be
      16              :  *  useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
      17              :  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
      18              :  *  GNU Affero General Public License for more details.
      19              :  *
      20              :  *  You should have received a copy of the GNU Affero General Public
      21              :  *  License along with this library; see the file LICENSE.  If not, write to
      22              :  *  the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
      23              :  *
      24              :  */
      25              : 
      26              : #include "common.h"
      27              : #include "gpacmessages.h"
      28              : #include "lib/pid.h"
      29              : 
      30              : #define SEGMENT_HANDLER_SIGNATURE(prop_nickname)                    \
      31              :   gboolean prop_nickname##_segment_handler(GPAC_PID_PROP_IMPL_ARGS)
      32              : 
      33              : #define DEFAULT_HANDLER(prop_nickname)                              \
      34              :   gboolean prop_nickname##_segment_handler(GPAC_PID_PROP_IMPL_ARGS) \
      35              :   {                                                                 \
      36              :     return FALSE;                                                   \
      37              :   }
      38              : 
      39              : //
      40              : // Default Segment handlers
      41              : //
      42              : 
      43              : //
      44              : // Segment handlers
      45              : //
      46           21 : SEGMENT_HANDLER_SIGNATURE(duration)
      47              : {
      48              :   const GF_PropertyValue* p;
      49              : 
      50              :   // Check if either start and stop is valid
      51           42 :   gboolean range_valid = GST_CLOCK_TIME_IS_VALID(priv->segment->start) &&
      52           21 :                          GST_CLOCK_TIME_IS_VALID(priv->segment->stop);
      53           21 :   gboolean duration_valid = GST_CLOCK_TIME_IS_VALID(priv->segment->duration);
      54              : 
      55              :   // Duration cannot be calculated from the segment
      56           21 :   if (!range_valid && !duration_valid)
      57           21 :     return FALSE;
      58              : 
      59              :   // Get the duration
      60              :   guint64 duration;
      61            0 :   if (duration_valid)
      62            0 :     duration = priv->segment->duration;
      63              :   else // if (range_valid)
      64            0 :     duration = priv->segment->stop - priv->segment->start;
      65              : 
      66              :   // Get the fps from the PID
      67            0 :   GF_Fraction fps = { 30, 1 };
      68            0 :   p = gf_filter_pid_get_property(pid, GF_PROP_PID_FPS);
      69            0 :   if (p)
      70            0 :     fps = p->value.frac;
      71              : 
      72              :   // Get the timescale from the PID
      73            0 :   guint64 timescale = GST_SECOND;
      74            0 :   p = gf_filter_pid_get_property(pid, GF_PROP_PID_TIMESCALE);
      75            0 :   if (p)
      76            0 :     timescale = p->value.uint;
      77              : 
      78              :   // Construct the duration
      79            0 :   GF_Fraction64 duration_fr = {
      80            0 :     .num = (s64)gpac_time_rescale_with_fps(duration, fps, timescale),
      81              :     .den = timescale,
      82              :   };
      83              : 
      84              :   // Set the duration
      85            0 :   SET_PROP(GF_PROP_PID_DURATION, PROP_FRAC64(duration_fr));
      86            0 :   return TRUE;
      87              : }
        

Generated by: LCOV version 2.0-1