[gst-cvs] gst-plugins-bad: mpegtsparse: Ignore subtable extension when parsing PAT

Zaheer Abbas Merali zaheer at kemper.freedesktop.org
Sun May 3 09:32:26 PDT 2009


Module: gst-plugins-bad
Branch: master
Commit: e41401e3174b80b2e2ce4febf99f15e766dfc5c6
URL:    http://cgit.freedesktop.org/gstreamer/gst-plugins-bad/commit/?id=e41401e3174b80b2e2ce4febf99f15e766dfc5c6

Author: Vincent Genieux <mutex at runbox.com>
Date:   Sun May  3 17:42:44 2009 +0100

mpegtsparse: Ignore subtable extension when parsing PAT

Fixes #569673.

---

 gst/mpegdemux/mpegtspacketizer.c |   19 ++++++++++++++++++-
 gst/mpegdemux/mpegtspacketizer.h |    2 ++
 gst/mpegdemux/mpegtsparse.c      |    7 +++----
 3 files changed, 23 insertions(+), 5 deletions(-)

diff --git a/gst/mpegdemux/mpegtspacketizer.c b/gst/mpegdemux/mpegtspacketizer.c
index 1abbf1f..b986fa6 100644
--- a/gst/mpegdemux/mpegtspacketizer.c
+++ b/gst/mpegdemux/mpegtspacketizer.c
@@ -241,7 +241,8 @@ mpegts_packetizer_parse_section_header (MpegTSPacketizer * packetizer,
   data = GST_BUFFER_DATA (section->buffer);
 
   section->table_id = *data++;
-  if ((data[0] & 0x80) == 0)
+  /* if table_id is 0 (pat) then ignore the subtable extension */
+  if ((data[0] & 0x80) == 0 || section->table_id == 0)
     section->subtable_extension = 0;
   else
     section->subtable_extension = GST_READ_UINT16_BE (data + 2);
@@ -1844,6 +1845,22 @@ mpegts_packetizer_clear (MpegTSPacketizer * packetizer)
   gst_adapter_clear (packetizer->adapter);
 }
 
+void
+mpegts_packetizer_remove_stream (MpegTSPacketizer * packetizer, gint16 pid)
+{
+  MpegTSPacketizerStream *stream =
+      (MpegTSPacketizerStream *) g_hash_table_lookup (packetizer->streams,
+      GINT_TO_POINTER ((gint) pid));
+  if (stream) {
+    GST_INFO ("Removing stream for PID %d", pid);
+
+    g_hash_table_remove (packetizer->streams, GINT_TO_POINTER ((gint) pid));
+
+    g_object_unref (stream->section_adapter);
+    g_free (stream);
+  }
+}
+
 MpegTSPacketizer *
 mpegts_packetizer_new ()
 {
diff --git a/gst/mpegdemux/mpegtspacketizer.h b/gst/mpegdemux/mpegtspacketizer.h
index c54228a..97e15cf 100644
--- a/gst/mpegdemux/mpegtspacketizer.h
+++ b/gst/mpegdemux/mpegtspacketizer.h
@@ -116,6 +116,8 @@ gboolean mpegts_packetizer_next_packet (MpegTSPacketizer *packetizer,
   MpegTSPacketizerPacket *packet);
 void mpegts_packetizer_clear_packet (MpegTSPacketizer *packetizer,
   MpegTSPacketizerPacket *packet);
+void mpegts_packetizer_remove_stream(MpegTSPacketizer *packetizer, 
+  gint16 pid);
 
 gboolean mpegts_packetizer_push_section (MpegTSPacketizer *packetzer,
   MpegTSPacketizerPacket *packet, MpegTSPacketizerSection *section);
diff --git a/gst/mpegdemux/mpegtsparse.c b/gst/mpegdemux/mpegtsparse.c
index de4de35..614da36 100644
--- a/gst/mpegdemux/mpegtsparse.c
+++ b/gst/mpegdemux/mpegtsparse.c
@@ -350,7 +350,7 @@ mpegts_parse_add_program (MpegTSParse * parse,
   program->pcr_pid = G_MAXUINT16;
   program->streams = g_hash_table_new_full (g_direct_hash, g_direct_equal,
       NULL, (GDestroyNotify) mpegts_parse_free_stream);
-  program->patcount = 1;
+  program->patcount = 0;
   program->selected = 0;
   program->active = FALSE;
 
@@ -890,14 +890,12 @@ mpegts_parse_apply_pat (MpegTSParse * parse, GstStructure * pat_info)
         g_hash_table_insert (parse->psi_pids,
             GINT_TO_POINTER ((gint) pid), GINT_TO_POINTER (1));
       }
-
-      program->patcount += 1;
     } else {
       g_hash_table_insert (parse->psi_pids,
           GINT_TO_POINTER ((gint) pid), GINT_TO_POINTER (1));
       program = mpegts_parse_add_program (parse, program_number, pid);
     }
-
+    program->patcount += 1;
     if (program->selected && !program->active)
       parse->pads_to_add = g_list_append (parse->pads_to_add,
           mpegts_parse_activate_program (parse, program));
@@ -938,6 +936,7 @@ mpegts_parse_apply_pat (MpegTSParse * parse, GstStructure * pat_info)
 
       mpegts_parse_remove_program (parse, program_number);
       g_hash_table_remove (parse->psi_pids, GINT_TO_POINTER ((gint) pid));
+      mpegts_packetizer_remove_stream (parse->packetizer, pid);
     }
 
     gst_structure_free (old_pat);





More information about the Gstreamer-commits mailing list