Search code examples
gstreamermpeg

Segmentation fault using GStreamer


Im using gst_mpegts_section_get_pat for reading the PAT table but it is raising segmentation fault. I'm passing a ts file to read. I used all the logics and everything what i can think of but I'm unable to find it out . The code snippet is as follows. BTW I took most of the code form the code i have taken from

static void dump_pat (GstMpegTsSection * section)
{
 printf ("dumb_pet \n");
 int i, len;
 GPtrArray *pat;

         pat = gst_mpegts_section_get_pat (section);
         len = pat->len;
         g_printf (" %d program(s):\n", len);

         for (i = 0; i < len; i++) {
             GstMpegTsPatProgram *patp = g_ptr_array_index (pat, i);

             g_print
                 (" program_number:%6d (0x%04x), network_or_program_map_PID:0x%04x\n",
                  patp->program_number, patp->program_number,
                  patp->network_or_program_map_PID);
         }

         g_ptr_array_unref (pat);

}

Solution

  • Are you sure you are using the API correctly ? dump_pat is expecting a defined structure as a parameter, not a TS file, cf gst-libs/gst/mpegts/gstmpegtssection.h:

    typedef struct _GstMpegTsSection GstMpegTsSection;
    

    Have a look at the FAQ and the Documentation of Gstreamer.