LCOV - code coverage report
Current view: top level - src/lib/conversion/pid/query_handlers.c (source / functions) Coverage Total Hit
Test: coverage.filtered.info Lines: 89.5 % 19 17
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 QUERY_HANDLER_SIGNATURE(prop_nickname)                    \
      31              :   gboolean prop_nickname##_query_handler(GPAC_PID_PROP_IMPL_ARGS)
      32              : 
      33              : #define DEFAULT_HANDLER(prop_nickname)                            \
      34              :   gboolean prop_nickname##_query_handler(GPAC_PID_PROP_IMPL_ARGS) \
      35              :   {                                                               \
      36              :     return FALSE;                                                 \
      37              :   }
      38              : 
      39              : //
      40              : // Default Query handlers
      41              : //
      42              : 
      43              : //
      44              : // Query handlers
      45              : //
      46           21 : QUERY_HANDLER_SIGNATURE(duration)
      47              : {
      48              :   const GF_PropertyValue* p;
      49              : 
      50              :   // Query the duration
      51           42 :   g_autoptr(GstQuery) query = gst_query_new_duration(GST_FORMAT_TIME);
      52           21 :   gboolean ret = gst_pad_peer_query(priv->self, query);
      53           21 :   if (!ret) {
      54            0 :     GST_ELEMENT_ERROR(
      55              :       priv->self, LIBRARY, FAILED, (NULL), ("Failed to query duration"));
      56            0 :     return FALSE;
      57              :   }
      58              : 
      59              :   // Parse the duration
      60              :   gint64 duration;
      61           21 :   gst_query_parse_duration(query, NULL, &duration);
      62              : 
      63              :   // Get the fps from the PID
      64           21 :   GF_Fraction fps = { 30, 1 };
      65           21 :   p = gf_filter_pid_get_property(pid, GF_PROP_PID_FPS);
      66           21 :   if (p)
      67           18 :     fps = p->value.frac;
      68              : 
      69              :   // Get the timescale from the PID
      70           21 :   guint64 timescale = GST_SECOND;
      71           21 :   p = gf_filter_pid_get_property(pid, GF_PROP_PID_TIMESCALE);
      72           21 :   if (p)
      73           21 :     timescale = p->value.uint;
      74              : 
      75              :   // Construct the duration
      76           21 :   GF_Fraction64 duration_fr = {
      77           21 :     .num = (s64)gpac_time_rescale_with_fps(duration, fps, timescale),
      78              :     .den = timescale,
      79              :   };
      80              : 
      81              :   // Set the duration
      82           21 :   SET_PROP(GF_PROP_PID_DURATION, PROP_FRAC64(duration_fr));
      83           21 :   return TRUE;
      84              : }
        

Generated by: LCOV version 2.0-1