LCOV - code coverage report
Current view: top level - gst/mpegdemux - flutspmtinfo.c (source / functions) Hit Total Coverage
Test: GStreamer Bad Plug-ins 0.10.21.1 Lines: 1 65 1.5 %
Date: 2011-03-25 Functions: 1 11 9.1 %
Branches: 1 48 2.1 %

           Branch data     Line data    Source code
       1                 :            :  /*
       2                 :            :   * This library is licensed under 2 different licenses and you
       3                 :            :   * can choose to use it under the terms of either one of them. The
       4                 :            :   * two licenses are the MPL 1.1 and the LGPL.
       5                 :            :   *
       6                 :            :   * MPL:
       7                 :            :   *
       8                 :            :   * The contents of this file are subject to the Mozilla Public License
       9                 :            :   * Version 1.1 (the "License"); you may not use this file except in
      10                 :            :   * compliance with the License. You may obtain a copy of the License at
      11                 :            :   * http://www.mozilla.org/MPL/.
      12                 :            :   *
      13                 :            :   * Software distributed under the License is distributed on an "AS IS"
      14                 :            :   * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
      15                 :            :   * License for the specific language governing rights and limitations
      16                 :            :   * under the License.
      17                 :            :   *
      18                 :            :   * LGPL:
      19                 :            :   *
      20                 :            :   * This library is free software; you can redistribute it and/or
      21                 :            :   * modify it under the terms of the GNU Library General Public
      22                 :            :   * License as published by the Free Software Foundation; either
      23                 :            :   * version 2 of the License, or (at your option) any later version.
      24                 :            :   *
      25                 :            :   * This library is distributed in the hope that it will be useful,
      26                 :            :   * but WITHOUT ANY WARRANTY; without even the implied warranty of
      27                 :            :   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
      28                 :            :   * Library General Public License for more details.
      29                 :            :   *
      30                 :            :   * You should have received a copy of the GNU Library General Public
      31                 :            :   * License along with this library; if not, write to the
      32                 :            :   * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
      33                 :            :   * Boston, MA 02111-1307, USA.
      34                 :            :   *
      35                 :            :   * The Original Code is Fluendo MPEG Demuxer plugin.
      36                 :            :   *
      37                 :            :   * The Initial Developer of the Original Code is Fluendo, S.L.
      38                 :            :   * Portions created by Fluendo, S.L. are Copyright (C) 2005
      39                 :            :   * Fluendo, S.L. All Rights Reserved.
      40                 :            :   *
      41                 :            :   * Contributor(s): Jan Schmidt <jan@fluendo.com>
      42                 :            :   */
      43                 :            : 
      44                 :            : #ifdef HAVE_CONFIG_H
      45                 :            : #include "config.h"
      46                 :            : #endif
      47                 :            : 
      48                 :            : #include <gst/gst.h>
      49                 :            : 
      50                 :            : #include "flutspmtinfo.h"
      51                 :            : 
      52                 :            : enum
      53                 :            : {
      54                 :            :   PROP_0,
      55                 :            :   PROP_PROGRAM_NO,
      56                 :            :   PROP_VERSION_NO,
      57                 :            :   PROP_PCR_PID,
      58                 :            :   PROP_DESCRIPTORS,
      59                 :            :   PROP_STREAMINFO
      60                 :            : };
      61                 :            : 
      62         [ +  - ]:          6 : GST_BOILERPLATE (MpegTsPmtInfo, mpegts_pmt_info, GObject, G_TYPE_OBJECT);
      63                 :            : 
      64                 :            : static void mpegts_pmt_info_finalize (GObject * object);
      65                 :            : static void mpegts_pmt_info_set_property (GObject * object, guint prop_id,
      66                 :            :     const GValue * value, GParamSpec * spec);
      67                 :            : static void mpegts_pmt_info_get_property (GObject * object, guint prop_id,
      68                 :            :     GValue * value, GParamSpec * spec);
      69                 :            : 
      70                 :            : static void
      71                 :          0 : mpegts_pmt_info_base_init (gpointer klass)
      72                 :            : {
      73                 :          0 : }
      74                 :            : 
      75                 :            : static void
      76                 :          0 : mpegts_pmt_info_class_init (MpegTsPmtInfoClass * klass)
      77                 :            : {
      78                 :          0 :   GObjectClass *gobject_klass = (GObjectClass *) klass;
      79                 :            : 
      80                 :          0 :   gobject_klass->finalize = mpegts_pmt_info_finalize;
      81                 :          0 :   gobject_klass->set_property = mpegts_pmt_info_set_property;
      82                 :          0 :   gobject_klass->get_property = mpegts_pmt_info_get_property;
      83                 :            : 
      84                 :          0 :   g_object_class_install_property (gobject_klass, PROP_PROGRAM_NO,
      85                 :            :       g_param_spec_uint ("program-number", "Program Number",
      86                 :            :           "Program Number for this program", 0, G_MAXUINT16, 1,
      87                 :            :           G_PARAM_READABLE | G_PARAM_STATIC_STRINGS));
      88                 :            : 
      89                 :          0 :   g_object_class_install_property (gobject_klass, PROP_PCR_PID,
      90                 :            :       g_param_spec_uint ("pcr-pid", "PID carrying the PCR for this program",
      91                 :            :           "PID which carries the PCR for this program", 1, G_MAXUINT16, 1,
      92                 :            :           G_PARAM_READABLE | G_PARAM_STATIC_STRINGS));
      93                 :            : 
      94                 :          0 :   g_object_class_install_property (gobject_klass, PROP_STREAMINFO,
      95                 :            :       g_param_spec_value_array ("stream-info",
      96                 :            :           "GValueArray containing GObjects with properties",
      97                 :            :           "Array of GObjects containing information about the program streams",
      98                 :            :           g_param_spec_object ("flu-pmt-streaminfo", "FluPMTStreamInfo",
      99                 :            :               "Fluendo TS Demuxer PMT Stream info object",
     100                 :            :               MPEGTS_TYPE_PMT_STREAM_INFO,
     101                 :            :               G_PARAM_READABLE | G_PARAM_STATIC_STRINGS),
     102                 :            :           G_PARAM_READABLE | G_PARAM_STATIC_STRINGS));
     103                 :            : 
     104                 :          0 :   g_object_class_install_property (gobject_klass, PROP_VERSION_NO,
     105                 :            :       g_param_spec_uint ("version-number", "Version Number",
     106                 :            :           "Version number of this program information", 0, G_MAXUINT8, 1,
     107                 :            :           G_PARAM_READABLE | G_PARAM_STATIC_STRINGS));
     108                 :            : 
     109                 :          0 :   g_object_class_install_property (gobject_klass, PROP_DESCRIPTORS,
     110                 :            :       g_param_spec_value_array ("descriptors",
     111                 :            :           "Descriptors",
     112                 :            :           "Value array of strings containing program descriptors",
     113                 :            :           g_param_spec_boxed ("descriptor",
     114                 :            :               "descriptor",
     115                 :            :               "", G_TYPE_GSTRING, G_PARAM_READABLE | G_PARAM_STATIC_STRINGS),
     116                 :            :           G_PARAM_READABLE | G_PARAM_STATIC_STRINGS));
     117                 :          0 : }
     118                 :            : 
     119                 :            : static void
     120                 :          0 : mpegts_pmt_info_init (MpegTsPmtInfo * pmt_info, MpegTsPmtInfoClass * klass)
     121                 :            : {
     122                 :          0 :   pmt_info->streams = g_value_array_new (0);
     123                 :          0 :   pmt_info->descriptors = g_value_array_new (0);
     124                 :          0 : }
     125                 :            : 
     126                 :            : MpegTsPmtInfo *
     127                 :          0 : mpegts_pmt_info_new (guint16 program_no, guint16 pcr_pid, guint8 version_no)
     128                 :            : {
     129                 :            :   MpegTsPmtInfo *info;
     130                 :            : 
     131                 :          0 :   info = g_object_new (MPEGTS_TYPE_PMT_INFO, NULL);
     132                 :            : 
     133                 :          0 :   info->program_no = program_no;
     134                 :          0 :   info->pcr_pid = pcr_pid;
     135                 :          0 :   info->version_no = version_no;
     136                 :            : 
     137                 :          0 :   return info;
     138                 :            : }
     139                 :            : 
     140                 :            : static void
     141                 :          0 : mpegts_pmt_info_finalize (GObject * object)
     142                 :            : {
     143                 :          0 :   MpegTsPmtInfo *info = MPEGTS_PMT_INFO (object);
     144                 :            : 
     145                 :          0 :   g_value_array_free (info->streams);
     146                 :          0 :   g_value_array_free (info->descriptors);
     147                 :            : 
     148                 :          0 :   G_OBJECT_CLASS (parent_class)->finalize (object);
     149                 :          0 : }
     150                 :            : 
     151                 :            : static void
     152                 :          0 : mpegts_pmt_info_set_property (GObject * object, guint prop_id,
     153                 :            :     const GValue * value, GParamSpec * spec)
     154                 :            : {
     155 [ #  # ][ #  # ]:          0 :   g_return_if_fail (MPEGTS_IS_PMT_INFO (object));
         [ #  # ][ #  # ]
     156                 :            : 
     157                 :            :   /* No settable properties */
     158                 :          0 :   G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, spec);
     159                 :            : }
     160                 :            : 
     161                 :            : static void
     162                 :          0 : mpegts_pmt_info_get_property (GObject * object, guint prop_id,
     163                 :            :     GValue * value, GParamSpec * spec)
     164                 :            : {
     165                 :            :   MpegTsPmtInfo *pmt_info;
     166                 :            : 
     167 [ #  # ][ #  # ]:          0 :   g_return_if_fail (MPEGTS_IS_PMT_INFO (object));
         [ #  # ][ #  # ]
     168                 :            : 
     169                 :          0 :   pmt_info = MPEGTS_PMT_INFO (object);
     170                 :            : 
     171   [ #  #  #  #  :          0 :   switch (prop_id) {
                   #  # ]
     172                 :            :     case PROP_PROGRAM_NO:
     173                 :          0 :       g_value_set_uint (value, pmt_info->program_no);
     174                 :          0 :       break;
     175                 :            :     case PROP_PCR_PID:
     176                 :          0 :       g_value_set_uint (value, pmt_info->pcr_pid);
     177                 :          0 :       break;
     178                 :            :     case PROP_STREAMINFO:
     179                 :          0 :       g_value_set_boxed (value, pmt_info->streams);
     180                 :          0 :       break;
     181                 :            :     case PROP_VERSION_NO:
     182                 :          0 :       g_value_set_uint (value, pmt_info->version_no);
     183                 :          0 :       break;
     184                 :            :     case PROP_DESCRIPTORS:
     185                 :          0 :       g_value_set_boxed (value, pmt_info->descriptors);
     186                 :          0 :       break;
     187                 :            :     default:
     188                 :          0 :       G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, spec);
     189                 :          0 :       break;
     190                 :            :   }
     191                 :            : }
     192                 :            : 
     193                 :            : void
     194                 :          0 : mpegts_pmt_info_add_descriptor (MpegTsPmtInfo * pmt_info,
     195                 :            :     const gchar * descriptor, guint length)
     196                 :            : {
     197                 :          0 :   GValue value = { 0 };
     198                 :            :   GString *string;
     199                 :            : 
     200 [ #  # ][ #  # ]:          0 :   g_return_if_fail (MPEGTS_IS_PMT_INFO (pmt_info));
         [ #  # ][ #  # ]
     201                 :            : 
     202                 :          0 :   string = g_string_new_len (descriptor, length);
     203                 :            : 
     204                 :          0 :   g_value_init (&value, G_TYPE_GSTRING);
     205                 :          0 :   g_value_take_boxed (&value, string);
     206                 :          0 :   g_value_array_append (pmt_info->descriptors, &value);
     207                 :          0 :   g_value_unset (&value);
     208                 :            : }
     209                 :            : 
     210                 :            : void
     211                 :          0 : mpegts_pmt_info_add_stream (MpegTsPmtInfo * pmt_info,
     212                 :            :     MpegTsPmtStreamInfo * stream)
     213                 :            : {
     214                 :          0 :   GValue v = { 0, };
     215                 :            : 
     216 [ #  # ][ #  # ]:          0 :   g_return_if_fail (MPEGTS_IS_PMT_INFO (pmt_info));
         [ #  # ][ #  # ]
     217 [ #  # ][ #  # ]:          0 :   g_return_if_fail (MPEGTS_IS_PMT_STREAM_INFO (stream));
         [ #  # ][ #  # ]
     218                 :            : 
     219                 :          0 :   g_value_init (&v, G_TYPE_OBJECT);
     220                 :          0 :   g_value_take_object (&v, stream);
     221                 :          0 :   g_value_array_append (pmt_info->streams, &v);
     222                 :          0 :   g_value_unset (&v);
     223                 :            : }

Generated by: LCOV version 1.9