Index: ChangeLog
===================================================================
RCS file: /cvs/gstreamer/gst-sandbox/dvb-elements/ts-tools/ChangeLog,v
retrieving revision 1.1
diff -u -r1.1 ChangeLog
--- ChangeLog	14 Sep 2004 19:16:14 -0000	1.1
+++ ChangeLog	15 Jun 2006 12:45:12 -0000
@@ -0,0 +1,4 @@
+2006-06-15  Johannes Schmid <jhs@cvs.gnome.org>
+
+	* Ported to gstreamer-0.10
+	* bumped version to 0.2
Index: configure.ac
===================================================================
RCS file: /cvs/gstreamer/gst-sandbox/dvb-elements/ts-tools/configure.ac,v
retrieving revision 1.1
diff -u -r1.1 configure.ac
--- configure.ac	14 Sep 2004 19:16:14 -0000	1.1
+++ configure.ac	15 Jun 2006 12:45:12 -0000
@@ -2,7 +2,7 @@
 
 dnl Fill in your package name and version here
 PACKAGE=gst-ts-tools
-VERSION=0.1.1
+VERSION=0.2.0
 
 dnl these AC_DEFINE_UNQUOTED's are necessary for make dist to work
 AC_DEFINE_UNQUOTED(PACKAGE, "$PACKAGE")
@@ -28,10 +28,10 @@
 dnl Now we're ready to ask for gstreamer libs and cflags
 dnl And we can also ask for the right version of gstreamer
                                                                                 
-GST_REQUIRED=0.8.0
+GST_REQUIRED=0.10.0
                                                                                 
-dnl start with 0.8
-GST_MAJORMINOR=0.8
+dnl start with 0.10
+GST_MAJORMINOR=0.10
 PKG_CHECK_MODULES(GST, \
   gstreamer-$GST_MAJORMINOR >= $GST_REQUIRED,
   HAVE_GST=yes,HAVE_GST=no)
@@ -49,7 +49,7 @@
 AC_SUBST(GST_MAJORMINOR)
 
 dnl If we need them, we can also use the plugin libraries
-PKG_CHECK_MODULES(GST_LIBS, gstreamer-libs-$GST_MAJORMINOR >= $GST_REQUIRED,
+PKG_CHECK_MODULES(GST_LIBS, gstreamer-base-$GST_MAJORMINOR >= $GST_REQUIRED,
                   HAVE_GST_LIBS=yes, HAVE_GST_LIBS=no)
                                                                                 
 dnl Give a warning if we don't have gstreamer libs
Index: gstdvbsi.c
===================================================================
RCS file: /cvs/gstreamer/gst-sandbox/dvb-elements/ts-tools/gstdvbsi.c,v
retrieving revision 1.1
diff -u -r1.1 gstdvbsi.c
--- gstdvbsi.c	23 Nov 2004 13:24:09 -0000	1.1
+++ gstdvbsi.c	15 Jun 2006 12:45:12 -0000
@@ -36,29 +36,35 @@
 
 
 /* Object signals and args */
-enum {
+enum
+{
   LAST_SIGNAL
 };
 
 /* Arguments */
-enum {
+enum
+{
   ARG_0
 };
 
 
-static void	             gst_dvbsi_base_init      (GstDvbSiClass *klass);
-static void	             gst_dvbsi_class_init      (GstDvbSiClass *klass);
-static void	             gst_dvbsi_init	       (GstDvbSi *object);
-static void                  gst_dvbsi_dispose         (GObject *object);
-static void                  gst_dvbsi_finalize        (GObject *object);
-static void	             gst_dvbsi_set_property    (GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec);
-static void	             gst_dvbsi_get_property    (GObject *object, guint prop_id, GValue *value, GParamSpec *pspec);
-
-static void                  gst_dvbsi_loop            (GstElement* element);
-GstBuffer *                  gst_dvbsi_get             (GstPad * pad);
-SectionFilter*               gst_dvbsi_get_section_filter     (GstTsParse *object);
-void                         gst_dvbsi_parse_reserved_section (GstTsParse *object, const guint8 *section);
-void                         gst_dvbsi_parse_private_section  (GstTsParse *object, const guint8 *section);
+static void gst_dvbsi_base_init (GstDvbSiClass * klass);
+static void gst_dvbsi_class_init (GstDvbSiClass * klass);
+static void gst_dvbsi_init (GstDvbSi * object);
+static void gst_dvbsi_dispose (GObject * object);
+static void gst_dvbsi_finalize (GObject * object);
+static void gst_dvbsi_set_property (GObject * object, guint prop_id,
+				    const GValue * value, GParamSpec * pspec);
+static void gst_dvbsi_get_property (GObject * object, guint prop_id,
+				    GValue * value, GParamSpec * pspec);
+
+static void gst_dvbsi_loop (GstElement * element);
+GstBuffer *gst_dvbsi_get (GstPad * pad);
+SectionFilter *gst_dvbsi_get_section_filter (GstTsParse * object);
+void gst_dvbsi_parse_reserved_section (GstTsParse * object,
+				       const guint8 * section);
+void gst_dvbsi_parse_private_section (GstTsParse * object,
+				      const guint8 * section);
 
 
 static GstElementClass *parent_class = NULL;
@@ -94,50 +100,48 @@
   static GType gst_dvbsi_type = 0;
 
   if (!gst_dvbsi_type)
-  {
-    static const GTypeInfo dvbsi_info =
     {
-      sizeof (GstDvbSiClass),
-      (GBaseInitFunc) gst_dvbsi_base_init,
-      NULL,
-      (GClassInitFunc) gst_dvbsi_class_init,
-      NULL,
-      NULL,
-      sizeof (GstDvbSi),
-      0,
-      (GInstanceInitFunc) gst_dvbsi_init,
-    };
-    gst_dvbsi_type = g_type_register_static (GST_TYPE_TSPARSE,
-					      "GstDvbSi",
-					      &dvbsi_info, 0);
-    GST_DEBUG_CATEGORY_INIT (gstdvbsi_debug, "dvbsi", 0, "DVB-SI Parser");
+      static const GTypeInfo dvbsi_info = {
+	sizeof (GstDvbSiClass),
+	(GBaseInitFunc) gst_dvbsi_base_init,
+	NULL,
+	(GClassInitFunc) gst_dvbsi_class_init,
+	NULL,
+	NULL,
+	sizeof (GstDvbSi),
+	0,
+	(GInstanceInitFunc) gst_dvbsi_init,
+      };
+      gst_dvbsi_type = g_type_register_static (GST_TYPE_TSPARSE,
+					       "GstDvbSi", &dvbsi_info, 0);
+      GST_DEBUG_CATEGORY_INIT (gstdvbsi_debug, "dvbsi", 0, "DVB-SI Parser");
 
-  }
+    }
   return gst_dvbsi_type;
 }
 
 /* initialize the plugin's class */
 static void
-gst_dvbsi_base_init (GstDvbSiClass *klass)
+gst_dvbsi_base_init (GstDvbSiClass * klass)
 {
   GObjectClass *gobject_class;
-  GstElementClass *element_class = (GstElementClass*) klass;
+  GstElementClass *element_class = (GstElementClass *) klass;
 
 }
 
 /* initialize the plugin's class */
 static void
-gst_dvbsi_class_init (GstDvbSiClass *klass)
+gst_dvbsi_class_init (GstDvbSiClass * klass)
 {
   GObjectClass *gobject_class;
   GstElementClass *gstelement_class;
   GstTsParseClass *ts_parse_class;
 
-  GST_INFO("gst_dvbsi_class_init");
+  GST_INFO ("gst_dvbsi_class_init");
 
-  gobject_class = (GObjectClass*) klass;
-  gstelement_class = (GstElementClass*) klass;
-  ts_parse_class = (GstTsParseClass*) klass;
+  gobject_class = (GObjectClass *) klass;
+  gstelement_class = (GstElementClass *) klass;
+  ts_parse_class = (GstTsParseClass *) klass;
 
   parent_class = g_type_class_ref (GST_TYPE_TSPARSE);
 
@@ -149,7 +153,7 @@
   ts_parse_class->get_section_filter = gst_dvbsi_get_section_filter;
   ts_parse_class->parse_reserved_section = gst_dvbsi_parse_reserved_section;
   ts_parse_class->parse_private_section = gst_dvbsi_parse_private_section;
-  
+
 }
 
 /* initialize the new element
@@ -158,9 +162,9 @@
  * initialize structure
  */
 static void
-gst_dvbsi_init (GstDvbSi *object)
+gst_dvbsi_init (GstDvbSi * object)
 {
-  GstTsParse *ts_parse = (GstTsParse*) object;
+  GstTsParse *ts_parse = (GstTsParse *) object;
 
 
 }
@@ -168,24 +172,25 @@
 
 
 static void
-gst_dvbsi_set_property (GObject *_object, guint prop_id,
-			 const GValue *value, GParamSpec *pspec)
+gst_dvbsi_set_property (GObject * _object, guint prop_id,
+			const GValue * value, GParamSpec * pspec)
 {
   GstDvbSi *object;
 
   g_return_if_fail (GST_IS_DVBSI (_object));
   object = GST_DVBSI (_object);
 
-  switch (prop_id) {
-  default:
-    G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
-  }
+  switch (prop_id)
+    {
+    default:
+      G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+    }
 }
 
 
 static void
-gst_dvbsi_get_property (GObject *_object, guint prop_id,
-			 GValue *value, GParamSpec *pspec)
+gst_dvbsi_get_property (GObject * _object, guint prop_id,
+			GValue * value, GParamSpec * pspec)
 {
   GstDvbSi *object;
 
@@ -193,16 +198,16 @@
   object = GST_DVBSI (_object);
 
   switch (prop_id)
-  {
-  default:
-    G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
-  }
+    {
+    default:
+      G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+    }
 }
 
 
 
 static void
-gst_dvbsi_dispose (GObject *_object)
+gst_dvbsi_dispose (GObject * _object)
 {
   GstDvbSi *object;
 
@@ -213,11 +218,11 @@
 }
 
 static void
-gst_dvbsi_finalize (GObject *_object)
+gst_dvbsi_finalize (GObject * _object)
 {
   GstDvbSi *object;
 
-  GST_DEBUG("gst_dvbsi_finalize");
+  GST_DEBUG ("gst_dvbsi_finalize");
 
   g_return_if_fail (GST_IS_DVBSI (_object));
   object = GST_DVBSI (_object);
@@ -242,84 +247,90 @@
  * register the features
  */
 gboolean
-gst_dvbsi_plugin_init (GstPlugin *plugin)
+gst_dvbsi_plugin_init (GstPlugin * plugin)
 {
-  return gst_element_register (plugin, "dvbsi", GST_RANK_NONE, GST_TYPE_DVBSI);
+  return gst_element_register (plugin, "dvbsi", GST_RANK_NONE,
+			       GST_TYPE_DVBSI);
 }
 
 
-gst_dvbsi_parse_tdt(GstDvbSi *object, const guint8 *section) {
+gst_dvbsi_parse_tdt (GstDvbSi * object, const guint8 * section)
+{
   gint utc_time;
-  
+
 
 }
 
-SectionFilter*
-gst_dvbsi_get_section_filter (GstTsParse *object) {
+SectionFilter *
+gst_dvbsi_get_section_filter (GstTsParse * object)
+{
   if (object->pid < DVBSI_PID_BG || object->pid > DVBSI_PID_END)
     return NULL;
 
-  
-  return &GST_DVBSI(object)->section_filter[object->pid - DVBSI_PID_BG];
+
+  return &GST_DVBSI (object)->section_filter[object->pid - DVBSI_PID_BG];
 
 }
 
 void
-gst_dvbsi_parse_reserved_section (GstTsParse *object, const guint8 *section) {
+gst_dvbsi_parse_reserved_section (GstTsParse * object, const guint8 * section)
+{
   if (section[0] == TSDT_TID)
-    GST_INFO("Transport Stream Description");
+    GST_INFO ("Transport Stream Description");
 
 }
 
 void
-gst_dvbsi_parse_private_section (GstTsParse *object, const guint8 *section) {
+gst_dvbsi_parse_private_section (GstTsParse * object, const guint8 * section)
+{
+
+  switch (section[0])
+    {
+    case NIT_ACT_TID:
+      GST_INFO ("Network Information (actual network)");
+      break;
+    case NIT_OTH_TID:
+      GST_INFO ("Network Information (other network)");
+      break;
+    case SDT_ACT_TID:
+      GST_INFO ("Service Description (actual network)");
+      break;
+    case SDT_OTH_TID:
+      GST_INFO ("Service Description (other network)");
+      break;
+    case BAT_TID:
+      GST_INFO ("Bouquet Association");
+      break;
+    case EIT_ACT_TID:
+      GST_INFO ("Event Information (actual ts, present)");
+      break;
+    case EIT_OTH_TID:
+      GST_INFO ("Event Information (other ts, present)");
+      break;
+    case EIT_ACTUAL_NEXT_TID_BG...EIT_ACTUAL_NEXT_TID_END:
+      GST_INFO ("Event Information (actual ts, next)");
+      break;
+    case EIT_OTH_NEXT_TID_BG...EIT_OTH_NEXT_TID_END:
+      GST_INFO ("Event Information (other ts, next)");
+      break;
+    case TDT_TID:
+      GST_INFO ("Time, Date");
+      break;
+    case RST_TID:
+      GST_INFO ("Running Status");
+      break;
+    case ST_TID:
+      GST_INFO ("Stuffing");
+      break;
+    case TOT_TID:
+      GST_INFO ("Time Offset");
+      break;
+    case DISCONT_TID:
+      GST_INFO ("Discontinuity Information");
+      break;
+    case SEL_TID:
+      GST_INFO ("Selection Information");
+      break;
+    }
 
-  switch (section[0]) {
-  case NIT_ACT_TID:
-    GST_INFO("Network Information (actual network)");
-    break;
-  case NIT_OTH_TID:
-    GST_INFO("Network Information (other network)");
-    break;
-  case SDT_ACT_TID:
-    GST_INFO("Service Description (actual network)");
-    break;
-  case SDT_OTH_TID:
-    GST_INFO("Service Description (other network)");
-    break;
-  case BAT_TID:
-    GST_INFO("Bouquet Association");
-    break;
-  case EIT_ACT_TID:
-    GST_INFO("Event Information (actual ts, present)");
-    break;
-  case EIT_OTH_TID:
-    GST_INFO("Event Information (other ts, present)");
-    break;
-  case EIT_ACTUAL_NEXT_TID_BG ... EIT_ACTUAL_NEXT_TID_END:
-    GST_INFO("Event Information (actual ts, next)");
-    break;
-  case EIT_OTH_NEXT_TID_BG ... EIT_OTH_NEXT_TID_END:
-    GST_INFO("Event Information (other ts, next)");
-    break;
-  case TDT_TID:
-    GST_INFO("Time, Date");
-    break;
-  case RST_TID:
-    GST_INFO("Running Status");
-    break;
-  case ST_TID:
-    GST_INFO("Stuffing");
-    break;
-  case TOT_TID:
-    GST_INFO("Time Offset");
-    break;
-  case DISCONT_TID:
-    GST_INFO("Discontinuity Information");
-    break;
-  case  SEL_TID:
-    GST_INFO("Selection Information");
-    break;
-  }
-    
 }
Index: gstdvbsi.h
===================================================================
RCS file: /cvs/gstreamer/gst-sandbox/dvb-elements/ts-tools/gstdvbsi.h,v
retrieving revision 1.1
diff -u -r1.1 gstdvbsi.h
--- gstdvbsi.h	23 Nov 2004 13:24:09 -0000	1.1
+++ gstdvbsi.h	15 Jun 2006 12:45:12 -0000
@@ -4,7 +4,6 @@
 #include <glib.h>
 #include "gsttsparse.h"
 #include <gst/gst.h>
-#include <gst/bytestream/bytestream.h>
 
 G_BEGIN_DECLS
 
Index: gstts2ps.c
===================================================================
RCS file: /cvs/gstreamer/gst-sandbox/dvb-elements/ts-tools/gstts2ps.c,v
retrieving revision 1.2
diff -u -r1.2 gstts2ps.c
--- gstts2ps.c	23 Nov 2004 13:26:30 -0000	1.2
+++ gstts2ps.c	15 Jun 2006 12:45:12 -0000
@@ -37,12 +37,14 @@
 
 
 /* Object signals and args */
-enum {
+enum
+{
   LAST_SIGNAL
 };
 
 /* Arguments */
-enum {
+enum
+{
   ARG_0,
   ARG_TS2PS_V_PID,
   ARG_TS2PS_A_PID,
@@ -50,34 +52,36 @@
 };
 
 
-static GstStaticPadTemplate ps_src_factory =
-GST_STATIC_PAD_TEMPLATE (
-  "src",
-  GST_PAD_SRC,
-  GST_PAD_ALWAYS,
-  GST_STATIC_CAPS ("video/mpeg, "
-      "mpegversion = (int) 2, "
-      "systemstream = (boolean) TRUE"
-  )
-);
-
-
-static void	             gst_ts2ps_base_init      (GstTs2PsClass *klass);
-static void	             gst_ts2ps_class_init      (GstTs2PsClass *klass);
-static void	             gst_ts2ps_init	       (GstTs2Ps *object);
-static void                  gst_ts2ps_dispose         (GObject *object);
-static void                  gst_ts2ps_finalize        (GObject *object);
-static void	             gst_ts2ps_set_property    (GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec);
-static void	             gst_ts2ps_get_property    (GObject *object, guint prop_id, GValue *value, GParamSpec *pspec);
-
-static GstPadLinkReturn      gst_ts2ps_srcconnect_func (GstPad *pad, GstCaps *caps, gboolean newcaps);
+static GstStaticPadTemplate ps_src_factory = GST_STATIC_PAD_TEMPLATE ("src",
+								      GST_PAD_SRC,
+								      GST_PAD_ALWAYS,
+								      GST_STATIC_CAPS
+								      ("video/mpeg, "
+								       "mpegversion = (int) 2, "
+								       "systemstream = (boolean) TRUE"));
+
+
+static void gst_ts2ps_base_init (GstTs2PsClass * klass);
+static void gst_ts2ps_class_init (GstTs2PsClass * klass);
+static void gst_ts2ps_init (GstTs2Ps * object);
+static void gst_ts2ps_dispose (GObject * object);
+static void gst_ts2ps_finalize (GObject * object);
+static void gst_ts2ps_set_property (GObject * object, guint prop_id,
+				    const GValue * value, GParamSpec * pspec);
+static void gst_ts2ps_get_property (GObject * object, guint prop_id,
+				    GValue * value, GParamSpec * pspec);
+
+static GstPadLinkReturn gst_ts2ps_srcconnect_func (GstPad * pad,
+						   GstCaps * caps,
+						   gboolean newcaps);
 //static GstElementStateReturn gst_ts2ps_change_state    (GstElement *element);
-static void                  gst_ts2ps_loop            (GstElement* element);
-GstBuffer *                  gst_ts2ps_get             (GstPad * pad);
-static void                  gst_ts2ps_push            (uint8_t *buf, int count, void  *p);
-
-void                         gst_ts2ps_parse_payload   (GstTsParse *ts_parse, guint8 *data, int length);
-static void                  gst_ts2ps_handle_event    (GstTsParse *ts_parse, GstEvent *event);
+static void gst_ts2ps_loop (GstElement * element);
+GstBuffer *gst_ts2ps_get (GstPad * pad);
+static void gst_ts2ps_push (uint8_t * buf, int count, void *p);
+
+void gst_ts2ps_parse_payload (GstTsParse * ts_parse, guint8 * data,
+			      int length);
+static void gst_ts2ps_handle_event (GstTsParse * ts_parse, GstEvent * event);
 
 
 static GstTsParseClass *parent_class = NULL;
@@ -113,52 +117,52 @@
   static GType gst_ts2ps_type = 0;
 
   if (!gst_ts2ps_type)
-  {
-    static const GTypeInfo ts2ps_info =
     {
-      sizeof (GstTs2PsClass),
-      (GBaseInitFunc) gst_ts2ps_base_init,
-      NULL,
-      (GClassInitFunc) gst_ts2ps_class_init,
-      NULL,
-      NULL,
-      sizeof (GstTs2Ps),
-      0,
-      (GInstanceInitFunc) gst_ts2ps_init,
-    };
-    gst_ts2ps_type = g_type_register_static (GST_TYPE_TSPARSE,
-					      "GstTs2Ps",
-					      &ts2ps_info, 0);
-    GST_DEBUG_CATEGORY_INIT (gstts2ps_debug, "ts2ps", 0, "Mpeg TS to PS Element");
+      static const GTypeInfo ts2ps_info = {
+	sizeof (GstTs2PsClass),
+	(GBaseInitFunc) gst_ts2ps_base_init,
+	NULL,
+	(GClassInitFunc) gst_ts2ps_class_init,
+	NULL,
+	NULL,
+	sizeof (GstTs2Ps),
+	0,
+	(GInstanceInitFunc) gst_ts2ps_init,
+      };
+      gst_ts2ps_type = g_type_register_static (GST_TYPE_TSPARSE,
+					       "GstTs2Ps", &ts2ps_info, 0);
+      GST_DEBUG_CATEGORY_INIT (gstts2ps_debug, "ts2ps", 0,
+			       "Mpeg TS to PS Element");
 
-  }
+    }
   return gst_ts2ps_type;
 }
 
 /* initialize the plugin's class */
 static void
-gst_ts2ps_base_init (GstTs2PsClass *klass)
+gst_ts2ps_base_init (GstTs2PsClass * klass)
 {
   GObjectClass *gobject_class;
-  GstElementClass *element_class = (GstElementClass*) klass;
+  GstElementClass *element_class = (GstElementClass *) klass;
 
   gst_element_class_add_pad_template (element_class,
-		gst_static_pad_template_get (&ps_src_factory));
+				      gst_static_pad_template_get
+				      (&ps_src_factory));
 }
 
 /* initialize the plugin's class */
 static void
-gst_ts2ps_class_init (GstTs2PsClass *klass)
+gst_ts2ps_class_init (GstTs2PsClass * klass)
 {
   GObjectClass *gobject_class;
   GstElementClass *gstelement_class;
   GstTsParseClass *ts_parse_class;
 
-  GST_INFO("gst_ts2ps_class_init");
+  GST_INFO ("gst_ts2ps_class_init");
 
-  gobject_class = (GObjectClass*) klass;
-  gstelement_class = (GstElementClass*) klass;
-  ts_parse_class = (GstTsParseClass*) klass;
+  gobject_class = (GObjectClass *) klass;
+  gstelement_class = (GstElementClass *) klass;
+  ts_parse_class = (GstTsParseClass *) klass;
 
   parent_class = g_type_class_ref (GST_TYPE_TSPARSE);
 
@@ -172,24 +176,22 @@
 						     "vpid",
 						     "Video Program ID",
 						     0, G_MAXINT, 0,
-						     G_PARAM_READWRITE)
-				   );
+						     G_PARAM_READWRITE));
 
   g_object_class_install_property (gobject_class, ARG_TS2PS_A_PID,
 				   g_param_spec_int ("apid",
 						     "apid",
 						     "Audio Program ID",
 						     0, G_MAXINT, 0,
-						     G_PARAM_READWRITE)
-				   );
+						     G_PARAM_READWRITE));
 
   g_object_class_install_property (gobject_class, ARG_TS2PS_BUFFERSIZE,
 				   g_param_spec_int ("buffersize",
 						     "buffersize",
 						     "Buffersize in bytes",
-						     2048, G_MAXINT, DEFAULT_BUFFERSIZE,
-						     G_PARAM_READWRITE)
-				   );
+						     2048, G_MAXINT,
+						     DEFAULT_BUFFERSIZE,
+						     G_PARAM_READWRITE));
 
   ts_parse_class->parse_payload = gst_ts2ps_parse_payload;
   ts_parse_class->handle_event = gst_ts2ps_handle_event;
@@ -201,68 +203,64 @@
  * initialize structure
  */
 static void
-gst_ts2ps_init (GstTs2Ps *object)
+gst_ts2ps_init (GstTs2Ps * object)
 {
-  GstTsParse *ts_parse = (GstTsParse*) object;
-  GST_INFO("gst_ts2ps_init");
+  GstTsParse *ts_parse = (GstTsParse *) object;
+  GST_INFO ("gst_ts2ps_init");
 
   object->buffersize = DEFAULT_BUFFERSIZE;
 
-  /* set to something sane for testing purpose */
-  //* 3SAT (Germany)
-  object->apid = 220;
-  object->vpid = 210;
-  //*/
-
-  object->ps_buffer = g_malloc(object->buffersize);
+  object->ps_buffer = g_malloc (object->buffersize);
   object->ps_off = 0;
 
-  init_ipack(&object->pa, 2048, gst_ts2ps_push, 1);
-  init_ipack(&object->pv, 2048, gst_ts2ps_push, 1);
+  init_ipack (&object->pa, 2048, gst_ts2ps_push, 1);
+  init_ipack (&object->pv, 2048, gst_ts2ps_push, 1);
 
   /* Set private data in packet to our object */
   object->pa.data = object;
   object->pv.data = object;
 
-  
+
   gst_element_remove_pad (GST_ELEMENT (ts_parse), ts_parse->srcpad);
-  ts_parse->srcpad = gst_pad_new_from_template(
-		  gst_static_pad_template_get (&ps_src_factory), "src");
+  ts_parse->srcpad =
+    gst_pad_new_from_template (gst_static_pad_template_get (&ps_src_factory),
+			       "src");
   gst_element_add_pad (GST_ELEMENT (ts_parse), ts_parse->srcpad);
 }
 
 
 
 static void
-gst_ts2ps_set_property (GObject *_object, guint prop_id,
-			 const GValue *value, GParamSpec *pspec)
+gst_ts2ps_set_property (GObject * _object, guint prop_id,
+			const GValue * value, GParamSpec * pspec)
 {
   GstTs2Ps *object;
 
   g_return_if_fail (GST_IS_TS2PS (_object));
   object = GST_TS2PS (_object);
 
-  switch (prop_id) {
-  case ARG_TS2PS_V_PID:
-    object->vpid = g_value_get_int(value);
-    break;
-  case ARG_TS2PS_A_PID:
-    object->apid = g_value_get_int(value);
-    break;
-  case ARG_TS2PS_BUFFERSIZE:
-    object->buffersize = g_value_get_int(value);
-    g_free(object->ps_buffer);
-    object->ps_buffer = g_malloc(object->buffersize);
-    break;
-  default:
-    G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
-  }
+  switch (prop_id)
+    {
+    case ARG_TS2PS_V_PID:
+      object->vpid = g_value_get_int (value);
+      break;
+    case ARG_TS2PS_A_PID:
+      object->apid = g_value_get_int (value);
+      break;
+    case ARG_TS2PS_BUFFERSIZE:
+      object->buffersize = g_value_get_int (value);
+      g_free (object->ps_buffer);
+      object->ps_buffer = g_malloc (object->buffersize);
+      break;
+    default:
+      G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+    }
 }
 
 
 static void
-gst_ts2ps_get_property (GObject *_object, guint prop_id,
-			 GValue *value, GParamSpec *pspec)
+gst_ts2ps_get_property (GObject * _object, guint prop_id,
+			GValue * value, GParamSpec * pspec)
 {
   GstTs2Ps *object;
 
@@ -270,29 +268,29 @@
   object = GST_TS2PS (_object);
 
   switch (prop_id)
-  {
-  case ARG_TS2PS_V_PID: 
-    g_value_set_int(value, object->vpid);
-    break;
-  case ARG_TS2PS_A_PID:
-    g_value_set_int(value, object->apid);
-    break;
-  case ARG_TS2PS_BUFFERSIZE:
-    g_value_set_int(value, object->buffersize);
-    break;
-  default:
-    G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
-  }
+    {
+    case ARG_TS2PS_V_PID:
+      g_value_set_int (value, object->vpid);
+      break;
+    case ARG_TS2PS_A_PID:
+      g_value_set_int (value, object->apid);
+      break;
+    case ARG_TS2PS_BUFFERSIZE:
+      g_value_set_int (value, object->buffersize);
+      break;
+    default:
+      G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+    }
 }
 
 
 
 static void
-gst_ts2ps_dispose (GObject *_object)
+gst_ts2ps_dispose (GObject * _object)
 {
   GstTs2Ps *object;
 
-  GST_DEBUG("gst_ts2ps_dispose");
+  GST_DEBUG ("gst_ts2ps_dispose");
 
   g_return_if_fail (GST_IS_TS2PS (_object));
   object = GST_TS2PS (_object);
@@ -301,11 +299,11 @@
 }
 
 static void
-gst_ts2ps_finalize (GObject *_object)
+gst_ts2ps_finalize (GObject * _object)
 {
   GstTs2Ps *object;
 
-  GST_DEBUG("gst_ts2ps_finalize");
+  GST_DEBUG ("gst_ts2ps_finalize");
 
   g_return_if_fail (GST_IS_TS2PS (_object));
   object = GST_TS2PS (_object);
@@ -330,120 +328,133 @@
  * register the features
  */
 gboolean
-gst_ts2ps_plugin_init (GstPlugin *plugin)
+gst_ts2ps_plugin_init (GstPlugin * plugin)
 {
-  return gst_element_register (plugin, "ts2ps", GST_RANK_NONE, GST_TYPE_TS2PS);
+  return gst_element_register (plugin, "ts2ps", GST_RANK_NONE,
+			       GST_TYPE_TS2PS);
 }
 
 static void
-gst_ts2ps_handle_event(GstTsParse *ts_parse, GstEvent *event) {
-  GstTs2Ps *object = GST_TS2PS(ts_parse);
+gst_ts2ps_handle_event (GstTsParse * ts_parse, GstEvent * event)
+{
+  GstTs2Ps *object = GST_TS2PS (ts_parse);
   gint etype;
 
   etype = event ? GST_EVENT_TYPE (event) : GST_EVENT_EOS;
-  
-  switch (etype) {
+
+  switch (etype)
+    {
     case GST_EVENT_EOS:
       break;
-    case GST_EVENT_DISCONTINUOUS:
-      fprintf(stderr, "gst_ts2ps handling discont\n");
-      
-      if (GST_EVENT_DISCONT_NEW_MEDIA(event)) {
-	init_ipack(&object->pa, 2048, gst_ts2ps_push, 1);
-	init_ipack(&object->pv, 2048, gst_ts2ps_push, 1);
-      }
-      break;
-    case GST_EVENT_FLUSH:
+    /*case GST_EVENT_DISCONTINUOUS:
+      fprintf (stderr, "gst_ts2ps handling discont\n");
+
+      if (GST_EVENT_DISCONT_NEW_MEDIA (event))
+	{
+	  init_ipack (&object->pa, 2048, gst_ts2ps_push, 1);
+	  init_ipack (&object->pv, 2048, gst_ts2ps_push, 1);
+	}
+      break;*/
+    case GST_EVENT_FLUSH_START:
       break;
     }
-  
-  parent_class->handle_event(object, event);
+
+  parent_class->handle_event (GST_TSPARSE(object), event);
 
 }
 
 
 /* The output routine for sending a PS */
-static void 
-gst_ts2ps_push(uint8_t *buf, int count, void  *p)
+static void
+gst_ts2ps_push (uint8_t * buf, int count, void *p)
 {
-  GstTs2Ps *object = GST_TS2PS(p);
+  GstTs2Ps *object = GST_TS2PS (p);
   GstBuffer *gst_buf;
-  GST_DEBUG("%s (..., %d, ...)", __FUNCTION__, count);
+  GST_DEBUG ("%s (..., %d, ...)", __FUNCTION__, count);
 
 
   /* will we fill the ps_buffer? */
-  if (object->ps_off+count >= object->buffersize) {
-    int r = object->ps_off +count - object->buffersize;
+  if (object->ps_off + count >= object->buffersize)
+    {
+      int r = object->ps_off + count - object->buffersize;
+
+      /* fill buffer, and make a copy */
+      memcpy (object->ps_buffer + object->ps_off, buf, count - r);
+      object->out_buffer = g_memdup (object->ps_buffer, object->buffersize);
+
+      /* take care about the rest */
+      memcpy (object->ps_buffer, buf + count - r, r);
+      object->ps_off = r;
+
+      /* one buffer finished */
+      object->finished = TRUE;
+    }
+  else
+    {
+      memcpy (object->ps_buffer + object->ps_off, buf, count);
+      object->ps_off += count;
+    }
 
-    /* fill buffer, and make a copy */
-    memcpy(object->ps_buffer + object->ps_off, buf, count-r);
-    object->out_buffer = g_memdup(object->ps_buffer, object->buffersize);
-
-    /* take care about the rest */
-    memcpy(object->ps_buffer, buf+count-r, r);
-    object->ps_off = r;
-    
-    /* one buffer finished */
-    object->finished = TRUE;
-  }
-  else {
-    memcpy(object->ps_buffer + object->ps_off, buf, count);
-    object->ps_off += count;
-  }
 
-  
 
 }
 
 
 void
-gst_ts2ps_parse_payload (GstTsParse *ts_parse, guint8 *data, int length)
+gst_ts2ps_parse_payload (GstTsParse * ts_parse, guint8 * data, int length)
 {
-  GstTs2Ps *object = GST_TS2PS(ts_parse);
-  GstBuffer* buf;
-  ipack* p;
+  GstTs2Ps *object = GST_TS2PS (ts_parse);
+  GstBuffer *buf;
+  ipack *p;
 
-  GST_DEBUG("Data: 0x%x, Length: %d", data, length);
+  GST_INFO ("Data: 0x%x, Length: %d", data, length);
 
-  if (ts_parse->transport_error) {
-    GST_DEBUG("Transport Error");
-    return;
-  }
-  
-  if (ts_parse->pid == object->vpid) {
-    GST_DEBUG("Video PID");
-    p = &object->pv;
-  }
-  else if (ts_parse->pid == object->apid) {
-    GST_DEBUG("Audio PID");
-    p = &object->pa;
-  }
-  else {
-    GST_INFO("Additional PID in TS: %d\n", ts_parse->pid);
-    return;
-  }
-  
-  if (ts_parse->unit_start) {
-    if (p->plength == MMAX_PLENGTH-6){
-      p->plength = p->found-6;
-      p->found = 0;
-      GST_DEBUG("Unit Start pushing???");
-      send_ipack(p);
-      reset_ipack(p);
+  if (ts_parse->transport_error)
+    {
+      GST_INFO ("Transport Error");
+      return;
+    }
+
+  if (ts_parse->pid == object->vpid)
+    {
+      GST_INFO ("Video PID");
+      p = &object->pv;
+    }
+  else if (ts_parse->pid == object->apid)
+    {
+      GST_INFO ("Audio PID");
+      p = &object->pa;
+    }
+  else
+    {
+      GST_INFO ("Additional PID in TS: %d\n", ts_parse->pid);
+      return;
+    }
+
+  if (ts_parse->unit_start)
+    {
+      if (p->plength == MMAX_PLENGTH - 6)
+	{
+	  p->plength = p->found - 6;
+	  p->found = 0;
+	  GST_INFO ("Unit Start pushing???");
+	  send_ipack (p);
+	  reset_ipack (p);
+	}
+    }
+
+  instant_repack (data, length, p);
+
+  if (object->finished)
+    {
+      GST_DEBUG ("pushing buffer");
+      buf = gst_buffer_new ();
+      GST_BUFFER_DATA (buf) = object->out_buffer;
+      GST_BUFFER_SIZE (buf) = object->buffersize;
+      GST_BUFFER_TIMESTAMP (buf) = GST_CLOCK_TIME_NONE;
+      gst_pad_push (ts_parse->srcpad, buf);
+      object->finished = FALSE;
     }
-  }
-  
-  instant_repack(data, length, p);
-  
-  if (object->finished) {
-    GST_DEBUG ("pushing buffer");
-    buf = gst_buffer_new();
-    GST_BUFFER_DATA(buf) = object->out_buffer;
-    GST_BUFFER_SIZE(buf) = object->buffersize;
-    GST_BUFFER_TIMESTAMP(buf) = GST_CLOCK_TIME_NONE;
-    gst_pad_push(ts_parse->srcpad, GST_DATA(buf));
-    object->finished = FALSE;
-  }
 
 }
 
Index: gsttsparse.c
===================================================================
RCS file: /cvs/gstreamer/gst-sandbox/dvb-elements/ts-tools/gsttsparse.c,v
retrieving revision 1.3
diff -u -r1.3 gsttsparse.c
--- gsttsparse.c	19 Dec 2004 23:24:06 -0000	1.3
+++ gsttsparse.c	15 Jun 2006 12:45:12 -0000
@@ -20,6 +20,7 @@
  */
 
 #include "gsttsparse.h"
+#include <string.h>
 #include <gst/gst.h>
 
 GST_DEBUG_CATEGORY_STATIC (gsttsparse_debug);
@@ -27,10 +28,10 @@
 
 
 static GstElementDetails tsparse_details = {
-  "TS Parser",
-  "Filter/TS",
-  "Parsing of MPEG Transport Stream",
-  "P2P-VCR, C-Lab, University of Paderborn"
+	"TS Parser",
+	"Filter/TS",
+	"Parsing of MPEG Transport Stream",
+	"P2P-VCR, C-Lab, University of Paderborn"
 };
 
 #define CLASS(o)	GST_TSPARSE_CLASS (G_OBJECT_GET_CLASS (o))
@@ -58,53 +59,52 @@
 
 
 /* Object signals and args */
-enum {
-  LAST_SIGNAL
+enum
+{
+	LAST_SIGNAL
 };
 
 /* Arguments */
-enum {
-  ARG_0
+enum
+{
+	ARG_0
 };
-static void                  gst_tsparse_base_init       (GstTsParse *klass);
-static void	             gst_tsparse_class_init 	 (GstTsParseClass *klass);
-static void	             gst_tsparse_init	         (GstTsParse *object);
-static void                  gst_tsparse_dispose         (GObject *object);
-static void                  gst_tsparse_finalize        (GObject *object);
-static void	             gst_tsparse_set_property    (GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec);
-static void	             gst_tsparse_get_property    (GObject *object, guint prop_id, GValue *value, GParamSpec *pspec);
-
-static GstElementStateReturn gst_tsparse_change_state    (GstElement *element);
-static void                  gst_tsparse_loop            (GstElement* element);
-GstBuffer *                  gst_tsparse_get             (GstPad * pad);
-static void                  gst_tsparse_push            (guint8 *buf, int count, void  *p);
-static void                  gst_tsparse_handle_discont  (GstTsParse *object, GstEvent *event);
-static void                  gst_tsparse_handle_event    (GstTsParse *object, GstEvent *event);
+static void gst_tsparse_base_init (GstTsParse * klass);
+static void gst_tsparse_class_init (GstTsParseClass * klass);
+static void gst_tsparse_init (GstTsParse * object);
+static void gst_tsparse_dispose (GObject * object);
+static void gst_tsparse_finalize (GObject * object);
+static void gst_tsparse_set_property (GObject * object, guint prop_id,
+									  const GValue * value, GParamSpec * pspec);
+static void gst_tsparse_get_property (GObject * object, guint prop_id,
+									  GValue * value, GParamSpec * pspec);
+
+static GstStateChangeReturn gst_tsparse_change_state (GstElement * element, GstStateChange transition);
+GstBuffer *gst_tsparse_get (GstPad * pad);
+static void gst_tsparse_handle_discont (GstTsParse * object, GstEvent * event);
+static void gst_tsparse_handle_event (GstTsParse * object, GstEvent * event);
+
+static GstFlowReturn
+gst_tsparse_chain (GstPad * pad, GstBuffer* buffer);
 
 static GstElementClass *parent_class = NULL;
 
 
-static GstStaticPadTemplate sink_factory =
-GST_STATIC_PAD_TEMPLATE (
-  "sink",
-  GST_PAD_SINK,
-  GST_PAD_ALWAYS,
-  GST_STATIC_CAPS ("video/mpeg-ts, "
-      "mpegversion = (int) 2, "
-      "systemstream = (boolean) TRUE"
-  )
-);
-
-static GstStaticPadTemplate src_factory =
-GST_STATIC_PAD_TEMPLATE (
-  "src",
-  GST_PAD_SRC,
-  GST_PAD_ALWAYS,
-  GST_STATIC_CAPS ("video/mpeg-ts, "
-      "mpegversion = (int) 2, "
-      "systemstream = (boolean) TRUE"
-  )
-);
+static GstStaticPadTemplate sink_factory = GST_STATIC_PAD_TEMPLATE ("sink",
+																	GST_PAD_SINK,
+																	GST_PAD_ALWAYS,
+																	GST_STATIC_CAPS
+																	("video/mpegts, "
+																	 "mpegversion = (int) 2, "
+																	 "systemstream = (boolean) TRUE"));
+
+static GstStaticPadTemplate src_factory = GST_STATIC_PAD_TEMPLATE ("src",
+																   GST_PAD_SRC,
+																   GST_PAD_ALWAYS,
+																   GST_STATIC_CAPS
+																   ("video/mpeg, "
+																	"mpegversion = (int) 2, "
+																	"systemstream = (boolean) TRUE"));
 
 
 
@@ -119,168 +119,194 @@
  */
 
 inline static int
-get_pid(const guint8 *data) {
-  int pid = 0;
-  pid = (data[0] & PID_HIGH_MASK) << 8;
-  pid = pid | data[1];
-  return pid;
+get_pid (const guint8 * data)
+{
+	int pid = 0;
+	pid = (data[0] & PID_HIGH_MASK) << 8;
+	pid = pid | data[1];
+	return pid;
 }
 
 inline static int
-section_length(const guint8* buf) {
-  return ((buf[1] & 0x0F) << 8) + buf[2];
+section_length (const guint8 * buf)
+{
+	return ((buf[1] & 0x0F) << 8) + buf[2];
 }
 
 static int
 compare_pids (const void *a, const void *b)
 {
-  const gint *c = (const gint *) a;
-  const gint *d = (const gint *) b;
-  
-  return (*c > *d) - (*c < *d);
+	const gint *c = (const gint *) a;
+	const gint *d = (const gint *) b;
+
+	return (*c > *d) - (*c < *d);
 }
 
 static void
-add_pid(gint* arr, gint size, gint pid) {
-  gint i=0;
-  g_assert(pid >= 0);
-  g_assert(pid <= 8192);
+add_pid (gint * arr, gint size, gint pid)
+{
+	gint i = 0;
+	g_assert (pid >= 0);
+	g_assert (pid <= 8192);
 
-  if (bsearch(&pid, arr, size, sizeof(gint), compare_pids) != NULL)
-    return;
+	if (bsearch (&pid, arr, size, sizeof (gint), compare_pids) != NULL)
+		return;
 
-  for (i=0; i<size; i++)
-    if (arr[i] == 8193) {
-      arr[i] = pid;
-      qsort(arr, size, sizeof(gint), compare_pids);
-      return;
-    }
+	for (i = 0; i < size; i++)
+		if (arr[i] == 8193)
+		{
+			arr[i] = pid;
+			qsort (arr, size, sizeof (gint), compare_pids);
+			return;
+		}
 }
 
 static void
-gst_tsparse_add_ts_pid(GstTsParse* object, gint pid) {
-  add_pid(object->ts_pids, MAX_PIDS, pid);
+gst_tsparse_add_ts_pid (GstTsParse * object, gint pid)
+{
+	add_pid (object->ts_pids, MAX_PIDS, pid);
 }
 
 
-static SectionFilter*
-gst_tsparse_get_section_filter(GstTsParse* object, gint pid) {
-  SectionFilter *f = NULL;
-  gint i = 0;
-  while ((f = g_array_index(object->section_filt, SectionFilter *, i)) != NULL) {
-    if (f->pid == pid) {
-      return f;
-    }
-    i++;
-  }
-  return NULL;
+static SectionFilter *
+gst_tsparse_get_section_filter (GstTsParse * object, gint pid)
+{
+	SectionFilter *f = NULL;
+	gint i = 0;
+	while ((f =
+			g_array_index (object->section_filt, SectionFilter *, i)) != NULL)
+	{
+		if (f->pid == pid)
+		{
+			return f;
+		}
+		i++;
+	}
+	return NULL;
 }
 
 static void
-gst_tsparse_add_section_filter(GstTsParse* object, gint pid) {
-  SectionFilter *f = NULL;
+gst_tsparse_add_section_filter (GstTsParse * object, gint pid)
+{
+	SectionFilter *f = NULL;
 
-  g_assert(pid >= 0);
-  g_assert(pid <= 8192);
+	g_assert (pid >= 0);
+	g_assert (pid <= 8192);
 
-  if (gst_tsparse_get_section_filter(object, pid) != NULL)
-    return;
+	if (gst_tsparse_get_section_filter (object, pid) != NULL)
+		return;
 
-  f = g_malloc(sizeof(SectionFilter));
-  f->pid=pid;
-  f->count=0;
-  object->section_filt = g_array_append_val(object->section_filt, f); 
+	f = g_malloc (sizeof (SectionFilter));
+	f->pid = pid;
+	f->count = 0;
+	object->section_filt = g_array_append_val (object->section_filt, f);
 }
 
 static void
-gst_tsparse_clear_section_filter(GstTsParse *object) {
-  SectionFilter *f = NULL;
+gst_tsparse_clear_section_filter (GstTsParse * object)
+{
+	SectionFilter *f = NULL;
 
-  while ((f = g_array_index(object->section_filt, SectionFilter *, 0)) != NULL) {
-    g_free(f);
-    object->section_filt = g_array_remove_index_fast(object->section_filt, 0);
-  }
+	while ((f =
+			g_array_index (object->section_filt, SectionFilter *, 0)) != NULL)
+	{
+		g_free (f);
+		object->section_filt =
+			g_array_remove_index_fast (object->section_filt, 0);
+	}
 }
 
 static void
-gst_tsparse_init_section_filter(GstTsParse *object) {
-  gst_tsparse_clear_section_filter(object);
+gst_tsparse_init_section_filter (GstTsParse * object)
+{
+	gst_tsparse_clear_section_filter (object);
 
-  /* Add PAT, CAT filter again*/
-  gst_tsparse_add_section_filter(object, 0);
-  gst_tsparse_add_section_filter(object, 1);
+	/* Add PAT, CAT filter again */
+	gst_tsparse_add_section_filter (object, 0);
+	gst_tsparse_add_section_filter (object, 1);
 }
 
 
 
 /* Accessors for Program Maps */
 
-static ProgramMap*
-gst_tsparse_get_program_map(GstTsParse* object, gint prog_number) {
-  ProgramMap *pm = NULL;
-  gint i = 0;
+static ProgramMap *
+gst_tsparse_get_program_map (GstTsParse * object, gint prog_number)
+{
+	ProgramMap *pm = NULL;
+	gint i = 0;
 
-  while ((pm = g_array_index(object->programs, ProgramMap *, i)) != NULL) {
-    if (pm->program_number == prog_number) {
-      return pm;
-    }
-    i++;
-  }
-  return NULL;
+	while ((pm = g_array_index (object->programs, ProgramMap *, i)) != NULL)
+	{
+		if (pm->program_number == prog_number)
+		{
+			return pm;
+		}
+		i++;
+	}
+	return NULL;
 
 }
 
 static void
-gst_tsparse_clear_programs(GstTsParse *object) {
-  ProgramMap *pm = NULL;
-  GList *es_node = NULL;
-
-  while ((pm = g_array_index(object->programs, ProgramMap *, 0)) != NULL) {
-    es_node = pm->elem_streams;
-    while (es_node != NULL) {
-      /* free descriptor */
-      g_free(((EsInfo *)es_node->data)->descr);
-      /* free the data */
-      g_free(es_node->data);
-      es_node = g_list_next(es_node);
-    }
-    g_list_free(pm->elem_streams);
-    pm->elem_streams = NULL;
-    g_free(pm->descr);
-    g_array_remove_index_fast(object->programs, 0);
-    g_free(pm);
-    pm = NULL;
-  }
+gst_tsparse_clear_programs (GstTsParse * object)
+{
+	ProgramMap *pm = NULL;
+	GList *es_node = NULL;
+
+	while ((pm = g_array_index (object->programs, ProgramMap *, 0)) != NULL)
+	{
+		es_node = pm->elem_streams;
+		while (es_node != NULL)
+		{
+			/* free descriptor */
+			g_free (((EsInfo *) es_node->data)->descr);
+			/* free the data */
+			g_free (es_node->data);
+			es_node = g_list_next (es_node);
+		}
+		g_list_free (pm->elem_streams);
+		pm->elem_streams = NULL;
+		g_free (pm->descr);
+		g_array_remove_index_fast (object->programs, 0);
+		g_free (pm);
+		pm = NULL;
+	}
 }
 
 static void
-gst_tsparse_add_program(GstTsParse *object, ProgramMap *pm) {
-  g_array_append_val(object->programs, pm);
+gst_tsparse_add_program (GstTsParse * object, ProgramMap * pm)
+{
+	g_array_append_val (object->programs, pm);
 }
 
 
 static void
-remove_pid(gint* arr, gint size, gint pid) {
-  gint *result = NULL;
-  g_assert(pid >= 0);
-  g_assert(pid <= 8192);
+remove_pid (gint * arr, gint size, gint pid)
+{
+	gint *result = NULL;
+	g_assert (pid >= 0);
+	g_assert (pid <= 8192);
 
-  result = bsearch(&pid, arr, size, sizeof(gint), compare_pids);
-  if (result == NULL)
-    return;
+	result = bsearch (&pid, arr, size, sizeof (gint), compare_pids);
+	if (result == NULL)
+		return;
 
-  /* 0 to 8192 are valid pids */
-  *result=8193;
-  qsort(arr, size, sizeof(gint), compare_pids);
+	/* 0 to 8192 are valid pids */
+	*result = 8193;
+	qsort (arr, size, sizeof (gint), compare_pids);
 }
 
-remove_ts_pid(GstTsParse *object, gint pid) {
-  remove_pid(object->ts_pids, MAX_PIDS, pid);
+remove_ts_pid (GstTsParse * object, gint pid)
+{
+	remove_pid (object->ts_pids, MAX_PIDS, pid);
 }
 
 inline static gboolean
-unknown_pid(GstTsParse* object, gint pid) {
-  return bsearch(&pid, object->ts_pids, MAX_PIDS, sizeof(gint), compare_pids) == NULL;
+unknown_pid (GstTsParse * object, gint pid)
+{
+	return bsearch (&pid, object->ts_pids, MAX_PIDS, sizeof (gint),
+					compare_pids) == NULL;
 }
 
 
@@ -298,76 +324,77 @@
 GType
 gst_tsparse_get_type (void)
 {
-  static GType gst_tsparse_type = 0;
+	static GType gst_tsparse_type = 0;
 
-  if (!gst_tsparse_type)
-  {
-    static const GTypeInfo tsparse_info =
-    {
-      sizeof (GstTsParseClass),
-      (GBaseInitFunc)gst_tsparse_base_init,
-      NULL,
-      (GClassInitFunc) gst_tsparse_class_init,
-      NULL,
-      NULL,
-      sizeof (GstTsParse),
-      0,
-      (GInstanceInitFunc) gst_tsparse_init,
-    };
-    gst_tsparse_type = g_type_register_static (GST_TYPE_ELEMENT,
-					      "TsParse",
-					      &tsparse_info, 0);
+	if (!gst_tsparse_type)
+	{
+		static const GTypeInfo tsparse_info = {
+			sizeof (GstTsParseClass),
+			(GBaseInitFunc) gst_tsparse_base_init,
+			NULL,
+			(GClassInitFunc) gst_tsparse_class_init,
+			NULL,
+			NULL,
+			sizeof (GstTsParse),
+			0,
+			(GInstanceInitFunc) gst_tsparse_init,
+		};
+		gst_tsparse_type = g_type_register_static (GST_TYPE_ELEMENT,
+												   "TsParse", &tsparse_info, 0);
 
-    GST_DEBUG_CATEGORY_INIT (gsttsparse_debug, "tsparse", 0, "Generic MPEG Transport Stream Parser");
+		GST_DEBUG_CATEGORY_INIT (gsttsparse_debug, "tsparse", 0,
+								 "Generic MPEG Transport Stream Parser");
 
-  }
-  return gst_tsparse_type;
+	}
+	return gst_tsparse_type;
 }
 
 
 static void
-gst_tsparse_base_init (GstTsParse *klass)
+gst_tsparse_base_init (GstTsParse * klass)
 {
-  GstElementClass *element_class = GST_ELEMENT_CLASS (klass);
+	GstElementClass *element_class = GST_ELEMENT_CLASS (klass);
 
-  gst_element_class_set_details (element_class, &tsparse_details);
+	gst_element_class_set_details (element_class, &tsparse_details);
 }
 
 
 /* initialize the plugin's class */
 static void
-gst_tsparse_class_init (GstTsParseClass *klass)
+gst_tsparse_class_init (GstTsParseClass * klass)
 {
-  GObjectClass *gobject_class;
-  GstElementClass *gstelement_class;
+	GObjectClass *gobject_class;
+	GstElementClass *gstelement_class;
 
-  GST_INFO("gst_tsparse_class_init");
+	GST_INFO ("gst_tsparse_class_init");
 
-  gobject_class = (GObjectClass*) klass;
-  gstelement_class = (GstElementClass*) klass;
-
-  parent_class = g_type_class_ref (GST_TYPE_ELEMENT);
-
-  gobject_class->set_property = gst_tsparse_set_property;
-  gobject_class->get_property = gst_tsparse_get_property;
-  gobject_class->dispose = gst_tsparse_dispose;
-  gobject_class->finalize = gst_tsparse_finalize;
-
-  gstelement_class->change_state = gst_tsparse_change_state;
-
-  /* FIXME: this is a hack.  We add the pad templates here instead
-   * in the base_init function, since the derived class (mpegdemux)
-   * uses different pads.  IMO, this is wrong. */
-  gst_element_class_add_pad_template (gstelement_class,
-		gst_static_pad_template_get (&src_factory));
-  gst_element_class_add_pad_template (gstelement_class,
-		gst_static_pad_template_get (&sink_factory));
-
-  klass->parse_payload = NULL;
-  klass->parse_reserved_section = NULL;
-  klass->parse_private_section = NULL;
-  klass->get_section_filter = NULL;
-  klass->handle_event = gst_tsparse_handle_event;
+	gobject_class = (GObjectClass *) klass;
+	gstelement_class = (GstElementClass *) klass;
+
+	parent_class = g_type_class_ref (GST_TYPE_ELEMENT);
+
+	gobject_class->set_property = gst_tsparse_set_property;
+	gobject_class->get_property = gst_tsparse_get_property;
+	gobject_class->dispose = gst_tsparse_dispose;
+	gobject_class->finalize = gst_tsparse_finalize;
+
+	gstelement_class->change_state = gst_tsparse_change_state;
+
+	/* FIXME: this is a hack.  We add the pad templates here instead
+	 * in the base_init function, since the derived class (mpegdemux)
+	 * uses different pads.  IMO, this is wrong. */
+	gst_element_class_add_pad_template (gstelement_class,
+										gst_static_pad_template_get
+										(&src_factory));
+	gst_element_class_add_pad_template (gstelement_class,
+										gst_static_pad_template_get
+										(&sink_factory));
+
+	klass->parse_payload = NULL;
+	klass->parse_reserved_section = NULL;
+	klass->parse_private_section = NULL;
+	klass->get_section_filter = NULL;
+	klass->handle_event = gst_tsparse_handle_event;
 }
 
 /* initialize the new element
@@ -376,97 +403,99 @@
  * initialize structure
  */
 static void
-gst_tsparse_init (GstTsParse *object)
+gst_tsparse_init (GstTsParse * object)
 {
-  SectionFilter *f;
-  gint i=0;
-
-  object->sinkpad = gst_pad_new_from_template(
-		  gst_static_pad_template_get (&sink_factory), "sink");
-  gst_element_add_pad(GST_ELEMENT(object),object->sinkpad);
-
-  object->srcpad = gst_pad_new_from_template(
-		  gst_static_pad_template_get (&src_factory), "src");
-  gst_element_add_pad(GST_ELEMENT(object), object->srcpad);
+	SectionFilter *f;
+	gint i = 0;
 
-  object->bs = gst_bytestream_new (object->sinkpad);
+	object->sinkpad =
+		gst_pad_new_from_template (gst_static_pad_template_get (&sink_factory),
+								   "sink");
+	gst_element_add_pad (GST_ELEMENT (object), object->sinkpad);
 
+	object->srcpad =
+		gst_pad_new_from_template (gst_static_pad_template_get (&src_factory),
+								   "src");
+	gst_element_add_pad (GST_ELEMENT (object), object->srcpad);
 
-  /* initialize with invalid pid */
-  for (i=0; i<MAX_PIDS; i++)
-    object->ts_pids[i] = 8193;
+	object->ad = gst_adapter_new ();
 
-  object->section_filt = g_array_new(TRUE, FALSE, sizeof(SectionFilter *));
-  object->programs = g_array_new(TRUE, FALSE, sizeof(ProgramMap *));
+	gst_pad_set_chain_function (object->sinkpad, gst_tsparse_chain);
+	
+	/* initialize with invalid pid */
+	for (i = 0; i < MAX_PIDS; i++)
+		object->ts_pids[i] = 8193;
 
-  gst_tsparse_init_section_filter(object);
+	object->section_filt = g_array_new (TRUE, FALSE, sizeof (SectionFilter *));
+	object->programs = g_array_new (TRUE, FALSE, sizeof (ProgramMap *));
 
-  object->pat_version = -1;
+	gst_tsparse_init_section_filter (object);
 
-  gst_element_set_loop_function (GST_ELEMENT(object), gst_tsparse_loop);
+	object->pat_version = -1;
 }
 
 
 static void
-gst_tsparse_set_property (GObject *_object, guint prop_id,
-			 const GValue *value, GParamSpec *pspec)
+gst_tsparse_set_property (GObject * _object, guint prop_id,
+						  const GValue * value, GParamSpec * pspec)
 {
-  GstTsParse *object;
+	GstTsParse *object;
 
-  g_return_if_fail (GST_IS_TSPARSE (_object));
-  object = GST_TSPARSE (_object);
+	g_return_if_fail (GST_IS_TSPARSE (_object));
+	object = GST_TSPARSE (_object);
 
-  switch (prop_id) {
-  default:
-    G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
-  }
+	switch (prop_id)
+	{
+	default:
+		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+	}
 }
 
 
 static void
-gst_tsparse_get_property (GObject *_object, guint prop_id,
-			 GValue *value, GParamSpec *pspec)
+gst_tsparse_get_property (GObject * _object, guint prop_id,
+						  GValue * value, GParamSpec * pspec)
 {
-  GstTsParse *object;
+	GstTsParse *object;
 
-  g_return_if_fail (GST_IS_TSPARSE (_object));
-  object = GST_TSPARSE (_object);
+	g_return_if_fail (GST_IS_TSPARSE (_object));
+	object = GST_TSPARSE (_object);
 
-  switch (prop_id)
-  {
-  default:
-    G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
-  }
+	switch (prop_id)
+	{
+	default:
+		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+	}
 }
 
 
 static void
-gst_tsparse_dispose (GObject *_object)
+gst_tsparse_dispose (GObject * _object)
 {
-  GstTsParse *object;
+	GstTsParse *object;
 
-  GST_DEBUG("gst_tsparse_dispose");
+	GST_DEBUG ("gst_tsparse_dispose");
 
-  g_return_if_fail (GST_IS_TSPARSE (_object));
-  object = GST_TSPARSE (_object);
+	g_return_if_fail (GST_IS_TSPARSE (_object));
+	object = GST_TSPARSE (_object);
 
-  G_OBJECT_CLASS (parent_class)->dispose (_object);
+	G_OBJECT_CLASS (parent_class)->dispose (_object);
 }
 
 static void
-gst_tsparse_finalize (GObject *_object)
+gst_tsparse_finalize (GObject * _object)
 {
-  GstTsParse *object;
+	GstTsParse *object;
 
-  GST_DEBUG("gst_tsparse_finalize");
+	GST_DEBUG ("gst_tsparse_finalize");
 
-  gst_tsparse_clear_section_filter(object);
-  gst_tsparse_clear_programs(object);
+	gst_tsparse_clear_section_filter (object);
+	gst_tsparse_clear_programs (object);
 
-  g_return_if_fail (GST_IS_TSPARSE (_object));
-  object = GST_TSPARSE (_object);
+	g_return_if_fail (GST_IS_TSPARSE (_object));
+	object = GST_TSPARSE (_object);
 
-  G_OBJECT_CLASS(parent_class)->finalize(_object);
+	G_OBJECT_CLASS (parent_class)->finalize (_object);
 }
 
 
@@ -486,505 +515,525 @@
  * register the features
  */
 static gboolean
-plugin_init (GstPlugin *plugin)
+plugin_init (GstPlugin * plugin)
 {
-  /* this filter needs the bytestream package */
-  if (!gst_library_load ("gstbytestream"))
-    return FALSE;
-
-  if (!gst_element_register (plugin, "tsparse", GST_RANK_NONE, GST_TYPE_TSPARSE))
-    return FALSE;
-
-  if (!gst_ts2ps_plugin_init(plugin)) return FALSE;
-  if (!gst_dvbsi_plugin_init(plugin)) return FALSE;
-
-  return TRUE;
-}
-
-GST_PLUGIN_DEFINE (
-  GST_VERSION_MAJOR,
-  GST_VERSION_MINOR,
-  "ts-tools",
-  "Transport Stream Parser",
-  plugin_init,
-  VERSION,
-  "LGPL",
-  "Martin Eikermann (meiker@uni-paderborn.de)",
-  "University of Paderborn"
-  )
+	if (!gst_element_register
+		(plugin, "tsparse", GST_RANK_NONE, GST_TYPE_TSPARSE))
+		return FALSE;
+
+	if (!gst_ts2ps_plugin_init (plugin))
+		return FALSE;
+	if (!gst_dvbsi_plugin_init (plugin))
+		return FALSE;
+
+	return TRUE;
+}
+
+GST_PLUGIN_DEFINE (GST_VERSION_MAJOR,
+				   GST_VERSION_MINOR,
+				   "ts-tools",
+				   "Transport Stream Parser",
+				   plugin_init,
+				   VERSION,
+				   "LGPL",
+				   "Martin Eikermann (meiker@uni-paderborn.de)",
+				   "University of Paderborn")
+
+static gboolean find_start_code (GstTsParse * object)
+{
+	GstAdapter *ad = object->ad;
+	guint8 *buf;
+	gint offset = 0;
+	guint8 code;
+	const gint chunksize = 188;
+
+	if (gst_adapter_available (ad) <= chunksize)
+		return FALSE;
+		
+	buf = gst_adapter_peek (ad, chunksize);
+
+	code = buf[offset];
+
+	GST_DEBUG ("code = %02x %p", code, buf);
+
+	while (code != PACK_START_CODE)
+	{
+		code = (code << 8) | buf[offset++];
+
+		GST_DEBUG ("  code = %02x %p", code, buf);
+
+		if (offset == chunksize)
+		{
+			gst_adapter_flush (ad, offset - 1);
+			return FALSE;
+		}
+	}
+	if (offset > 0)
+		gst_adapter_flush (ad, offset - 1);
+	return TRUE;
+}
 
+static void
+gst_tsparse_handle_discont (GstTsParse * object, GstEvent * event)
+{
+	gint i = 0;
 
+	GST_INFO ("Statistics: %" G_GUINT64_FORMAT " packets % " G_GUINT64_FORMAT
+			  " Bytes Data\n", object->packet_count, object->payload_count);
+	object->payload_count = 0;
+	object->packet_count = 0;
 
-static gboolean
-find_start_code (GstTsParse *object) {
-  GstByteStream *bs = object->bs;
-  guchar *buf;
-  gint offset=0;
-  guint8 code;
-  gint chunksize;
-
-  chunksize = gst_bytestream_peek_bytes (bs, (guint8**)&buf, 4096);
-  /* need at least one TS Packet */
-  if (chunksize < 188)
-    return FALSE;
-
-  code = buf[offset];
-
-  GST_DEBUG ("code = %02x %p", code, buf);
-
-  while (code != PACK_START_CODE) {
-    code = (code << 8) | buf[offset++];
-    
-    GST_DEBUG ("  code = %02x %p", code, buf);
-
-    if (offset == chunksize) {
-      gst_bytestream_flush_fast (bs, offset);
-
-      chunksize = gst_bytestream_peek_bytes (bs, (guint8**)&buf, 4096);
-      if (chunksize == 0)
-	return FALSE;
-      else if (chunksize < 4096)
-	return FALSE;
-
-      offset = 0;
-    }
-  }
-  if (offset > 0)
-    gst_bytestream_flush_fast (bs, offset-1);
-  return TRUE;
-}
-
-static void
-gst_tsparse_handle_discont (GstTsParse *object, GstEvent *event) {
-  gint i = 0;
-
-  GST_INFO ("Statistics: %" G_GUINT64_FORMAT " packets % " G_GUINT64_FORMAT " Bytes Data\n", object->packet_count, object->payload_count);
-  object->payload_count = 0;
-  object->packet_count = 0;
-
-  /* new media? then we'll get new pids, pat, pmt, everything */
-  if (GST_EVENT_DISCONT_NEW_MEDIA(event)) {
-    /* clear found pids */
-    for (i=0; i<MAX_PIDS; i++)
-      object->ts_pids[i] = 8193;
-    
-    /* clear section filter */
-    gst_tsparse_clear_section_filter(object);
-    
-    /* reset pat version */
-    object->pat_version = -1;
-  }
-}
-
-static void
-gst_tsparse_handle_event(GstTsParse *object, GstEvent *event) {
-    gint etype;
-
-    etype = event? GST_EVENT_TYPE (event) : GST_EVENT_EOS;
-    
-    switch (etype) {
-    case GST_EVENT_EOS:
-      GST_DEBUG ("EOS reached.\n");
-      GST_INFO ("Statistics: %" G_GUINT64_FORMAT " packets % " G_GUINT64_FORMAT " Bytes Data\n", object->packet_count, object->payload_count);
-      object->payload_count = 0;
-      object->packet_count = 0;
-      break;
-    case GST_EVENT_DISCONTINUOUS:
-      GST_DEBUG ("discont\n");
-      //TODO      gst_bytestream_flush_fast (object->bs, remaining);
-      gst_tsparse_handle_discont(object, event);
-
-      /* subclass might want to do some cleanup on new-media as well 
-      if (CLASS(object)->handle_discont != NULL)
-	CLASS(object)->handle_discont(object, event);
-      */
-      break;
-    case GST_EVENT_FLUSH:
-      //TODO   gst_bytestream_flush_fast (object->bs, remaining);
-      break;
-    }
-    
-    gst_pad_event_default(object->sinkpad, event);
-    return;
-}
-
-
-static void
-gst_tsparse_pat(GstTsParse *object, const guint8 *section) {
-  guint16 ts_id;
-  guint8 version;
-  gboolean current;
-  guint s_length;
-  gint count;
-
-  version = (section[5] & 0x1D) >> 1;
-
-  if (version == object->pat_version) 
-    return;
-  object->pat_version = version;
-
-  s_length = section_length(section);
-  ts_id = section[3] << 8;
-  ts_id += section[4];
-  current = section[5] & 0x01;
-
-  /* Invalidate Section Filter */
-  gst_tsparse_init_section_filter(object);
-
-  /* Invalidate Program Informations */
-  gst_tsparse_clear_programs(object);
-
-
-  count = 8;
-  while (count < s_length-4) {
-    gint pid;
-    gint prog_number;
-    prog_number = section[count] << 8;
-    prog_number += section[count+1];
-
-    GST_INFO("Program: %d", prog_number);
-    pid = get_pid(&section[count+2]);
-
-    if (prog_number == 0) {
-      GST_INFO("Network Pid: %d", pid);
-      object->net_pid = pid;
-    }
-    else {
-      GST_INFO("PMT Pid: %d", pid);
-      gst_tsparse_add_section_filter(object, pid);
-    }
-
-    count += 4;
-  }
-}
-
-static void
-gst_tsparse_cat(GstTsParse *object, const guint8 *section) {
-
-}
-
-static void
-gst_tsparse_pmt(GstTsParse *object, const guint8 *section) {
-  ProgramMap *pm;
-  guint16 prog_number;
-  guint8 version;
-  gboolean current;
-  guint s_length;
-  gint count = 0;
-
-
-  /* Has this section normal Stream Syntax */
-  if (!(section[1] & 0x80)) {
-    GST_INFO("Private Section");
-    return;
-  }
-  
-  prog_number = section[3] << 8;
-  prog_number += section[4];
-  version = (section[5] & 0x1D) >> 1;
-
-  pm = gst_tsparse_get_program_map(object, prog_number);
-
-  if (pm != NULL && pm->version == version)
-    return;
-
-  if (pm == NULL) {
-    pm = g_malloc(sizeof(ProgramMap));
-    pm->elem_streams = NULL;
-    gst_tsparse_add_program(object, pm);
-  }
-
-  GST_INFO("Parsing PMT section");
-
-  s_length = section_length(section);
-  current = section[5] & 0x01;
-  pm->program_number = prog_number;
-  pm->version = version;
-  pm->pcr_pid = get_pid(section+8);
-  pm->descr_length = (section[10] & 0x0F) << 8;
-  pm->descr_length += section[11];
-  pm->descr = g_memdup(section+12, pm->descr_length);
-
-
-  GST_INFO("Section Length: %d", s_length);
-  GST_INFO("Program Number: %d", prog_number);
-  GST_INFO("Version: %d", version);
-  GST_INFO("Current: %d", current);
-  GST_INFO("PCR Pid: %d", pm->pcr_pid);
-  GST_INFO("Program Info Length: %d", pm->descr_length);
-
-
-  count = 12 + pm->descr_length;
-
-  while (count < s_length-4) {
-    EsInfo *es_info = g_malloc(sizeof(EsInfo));
-    
-    es_info->stream_type = section[count];
-    es_info->pid = get_pid(section+count+1);
-    es_info->descr_length = (section[count+3] & 0x0F) << 8;
-    es_info->descr_length += section[count+4];
-
-    GST_INFO("   " "Stream Type: %s", stream_type_str[es_info->stream_type]);
-    GST_INFO("   " "ES Pid: %d", es_info->pid);
-    GST_INFO("   " "ES Info Length: %d", es_info->descr_length);
+	/* new media? then we'll get new pids, pat, pmt, everything */
+	if (GST_EVENT_DISCONT_NEW_MEDIA (event))
+	{
+		/* clear found pids */
+		for (i = 0; i < MAX_PIDS; i++)
+			object->ts_pids[i] = 8193;
+
+		/* clear section filter */
+		gst_tsparse_clear_section_filter (object);
+
+		/* reset pat version */
+		object->pat_version = -1;
+	}
+}
+
+static void
+gst_tsparse_handle_event (GstTsParse * object, GstEvent * event)
+{
+	gint etype;
+
+	etype = event ? GST_EVENT_TYPE (event) : GST_EVENT_EOS;
+
+	switch (etype)
+	{
+	case GST_EVENT_EOS:
+		GST_DEBUG ("EOS reached.\n");
+		GST_INFO ("Statistics: %" G_GUINT64_FORMAT " packets % "
+				  G_GUINT64_FORMAT " Bytes Data\n", object->packet_count,
+				  object->payload_count);
+		object->payload_count = 0;
+		object->packet_count = 0;
+		break;
+	}
+
+	gst_pad_event_default (object->sinkpad, event);
+	return;
+}
+
+
+static void
+gst_tsparse_pat (GstTsParse * object, const guint8 * section)
+{
+	guint16 ts_id;
+	guint8 version;
+	gboolean current;
+	guint s_length;
+	gint count;
+
+	version = (section[5] & 0x1D) >> 1;
+
+	if (version == object->pat_version)
+		return;
+	object->pat_version = version;
+
+	s_length = section_length (section);
+	ts_id = section[3] << 8;
+	ts_id += section[4];
+	current = section[5] & 0x01;
+
+	/* Invalidate Section Filter */
+	gst_tsparse_init_section_filter (object);
+
+	/* Invalidate Program Informations */
+	gst_tsparse_clear_programs (object);
+
+
+	count = 8;
+	while (count < s_length - 4)
+	{
+		gint pid;
+		gint prog_number;
+		prog_number = section[count] << 8;
+		prog_number += section[count + 1];
+
+		GST_INFO ("Program: %d", prog_number);
+		pid = get_pid (&section[count + 2]);
+
+		if (prog_number == 0)
+		{
+			GST_INFO ("Network Pid: %d", pid);
+			object->net_pid = pid;
+		}
+		else
+		{
+			GST_INFO ("PMT Pid: %d", pid);
+			gst_tsparse_add_section_filter (object, pid);
+		}
+
+		count += 4;
+	}
+}
+
+static void
+gst_tsparse_cat (GstTsParse * object, const guint8 * section)
+{
+
+}
+
+static void
+gst_tsparse_pmt (GstTsParse * object, const guint8 * section)
+{
+	ProgramMap *pm;
+	guint16 prog_number;
+	guint8 version;
+	gboolean current;
+	guint s_length;
+	gint count = 0;
+
+
+	/* Has this section normal Stream Syntax */
+	if (!(section[1] & 0x80))
+	{
+		GST_INFO ("Private Section");
+		return;
+	}
+
+	prog_number = section[3] << 8;
+	prog_number += section[4];
+	version = (section[5] & 0x1D) >> 1;
+
+	pm = gst_tsparse_get_program_map (object, prog_number);
+
+	if (pm != NULL && pm->version == version)
+		return;
+
+	if (pm == NULL)
+	{
+		pm = g_malloc (sizeof (ProgramMap));
+		pm->elem_streams = NULL;
+		gst_tsparse_add_program (object, pm);
+	}
 
-    es_info->descr = g_memdup(section+count+5, es_info->descr_length);
-    pm->elem_streams = g_list_append(pm->elem_streams, es_info);
+	GST_INFO ("Parsing PMT section");
 
-    count += 5 + es_info->descr_length;
-  }
+	s_length = section_length (section);
+	current = section[5] & 0x01;
+	pm->program_number = prog_number;
+	pm->version = version;
+	pm->pcr_pid = get_pid (section + 8);
+	pm->descr_length = (section[10] & 0x0F) << 8;
+	pm->descr_length += section[11];
+	pm->descr = g_memdup (section + 12, pm->descr_length);
+
+
+	GST_INFO ("Section Length: %d", s_length);
+	GST_INFO ("Program Number: %d", prog_number);
+	GST_INFO ("Version: %d", version);
+	GST_INFO ("Current: %d", current);
+	GST_INFO ("PCR Pid: %d", pm->pcr_pid);
+	GST_INFO ("Program Info Length: %d", pm->descr_length);
+
+
+	count = 12 + pm->descr_length;
+
+	while (count < s_length - 4)
+	{
+		EsInfo *es_info = g_malloc (sizeof (EsInfo));
+
+		es_info->stream_type = section[count];
+		es_info->pid = get_pid (section + count + 1);
+		es_info->descr_length = (section[count + 3] & 0x0F) << 8;
+		es_info->descr_length += section[count + 4];
+
+		GST_INFO ("   " "Stream Type: %s",
+				  stream_type_str[es_info->stream_type]);
+		GST_INFO ("   " "ES Pid: %d", es_info->pid);
+		GST_INFO ("   " "ES Info Length: %d", es_info->descr_length);
+
+		es_info->descr = g_memdup (section + count + 5, es_info->descr_length);
+		pm->elem_streams = g_list_append (pm->elem_streams, es_info);
+
+		count += 5 + es_info->descr_length;
+	}
 
 
 }
 
 
 void
-gst_tsparse_handle_section(GstTsParse *object, const guint8 *section) {
-  
-  GST_DEBUG("Table ID: %d", section[0]);
-
-  if (section) {
-    /*switch over table id*/
-    switch (section[0]) {
-    case PAT_TID:
-      gst_tsparse_pat(object, section);
-      break;
-    case CAT_TID:
-      gst_tsparse_cat(object, section);
-      break;
-    case PMT_TID:
-      gst_tsparse_pmt(object, section);
-      break;
-    case RESERVED_TID_BG ... RESERVED_TID_END:
-      if (CLASS(object)->parse_reserved_section != NULL)
-	CLASS(object)->parse_reserved_section(object, section);
-      break;
-    case PRIVATE_TID_BG ... PRIVATE_TID_END:
-      if (CLASS(object)->parse_private_section != NULL)
-	CLASS(object)->parse_private_section(object, section);
-      break;
-    default:
-      GST_WARN("Syntax Error in Transport Stream");
-      break;
-    }
-  }
+gst_tsparse_handle_section (GstTsParse * object, const guint8 * section)
+{
+
+	GST_DEBUG ("Table ID: %d", section[0]);
+
+	if (section)
+	{
+		/*switch over table id */
+		switch (section[0])
+		{
+		case PAT_TID:
+			gst_tsparse_pat (object, section);
+			break;
+		case CAT_TID:
+			gst_tsparse_cat (object, section);
+			break;
+		case PMT_TID:
+			gst_tsparse_pmt (object, section);
+			break;
+		case RESERVED_TID_BG...RESERVED_TID_END:
+			if (CLASS (object)->parse_reserved_section != NULL)
+				CLASS (object)->parse_reserved_section (object, section);
+			break;
+		case PRIVATE_TID_BG...PRIVATE_TID_END:
+			if (CLASS (object)->parse_private_section != NULL)
+				CLASS (object)->parse_private_section (object, section);
+			break;
+		default:
+			GST_DEBUG ("Syntax Error in Transport Stream");
+			break;
+		}
+	}
 }
 
 void
-gst_tsparse_section(GstTsParse *object, const guint8* payload, gint p_length) {
-  SectionFilter *f = NULL;
-  gint s_length = 0;
-
-  /* do we have a section filter for this pid */
-  if (CLASS(object)->get_section_filter != NULL) 
-    f = CLASS(object)->get_section_filter(object);
-
-  if (f == NULL)
-    f = gst_tsparse_get_section_filter(object, object->pid);
-
-  if (f == NULL)
-    return;
-
-  
-  GST_DEBUG("Parse Section for Pid %d: %dbytes", object->pid, p_length, payload);
-
-
-  /* check continuity counter */
-  if ((f->cont_count + 1 & 0x0F) != object->cont_count) {
-    f->cont_count = object->cont_count;
-    /* Discard what has been read so far */
-    f->count = 0;
-    return;
-  }
-
-  f->cont_count = object->cont_count;
-
-  if (object->unit_start) {
-
-    GST_DEBUG("Unit Start");
-
-    guint8 section_off = payload[0]; // start of the new section
-    GST_DEBUG("Pointer: %d", section_off);
-
-    if (section_off > p_length) // points beyond payload
-      return;
-    
-    if (section_off > 0) { // rest of last section
-      GST_INFO("Finish last section");
-      memcpy(f->data + f->count, payload+1, section_off);
-      f->count += section_off;
-      gst_tsparse_handle_section(object, f->data);
-      f->count = 0;
-    }
-    
-    /* copy new section payload+pointer ... max(p_length, f->length) */
-    if (p_length - section_off >= 3) {
-      s_length = section_length(payload+section_off+1);
-      if (s_length <= p_length - section_off) { // Section will be complete
-	memcpy(f->data, payload+section_off+1, s_length);
-	gst_tsparse_handle_section(object, f->data);
-	f->count = 0;
-	return;
-      }
-    }
-    // copy until payload end, complete next time
-    memcpy(f->data, payload+section_off+1, p_length-section_off);
-    f->count = p_length-section_off-1;
-    return;
-  }
-  else { // complete the section
-    if (f->count >= 3) {
-      s_length = section_length(f->data);
-
-      if (s_length - f->count <= p_length) { // Last byte of section in payload
-	memcpy(f->data + f->count, payload, s_length - f->count);
-	gst_tsparse_handle_section(object, g_memdup(f->data, MAX_SECTION_LENGTH));
-	f->count = 0;
-	return;
-      }
+gst_tsparse_section (GstTsParse * object, const guint8 * payload, gint p_length)
+{
+	SectionFilter *f = NULL;
+	gint s_length = 0;
+
+	/* do we have a section filter for this pid */
+	if (CLASS (object)->get_section_filter != NULL)
+		f = CLASS (object)->get_section_filter (object);
 
-    }
+	if (f == NULL)
+		f = gst_tsparse_get_section_filter (object, object->pid);
 
-    // Take all of the payload, complete section next time
-    memcpy(f->data + f->count, payload, p_length); 
-    f->count += p_length;
-  }
-}
-
-static void
-gst_tsparse_loop (GstElement *element)
-{
-  GstTsParse *object = NULL;
-  GstBuffer *buf = NULL;
-  guint8 *data = NULL;
-  guint32 got_bytes;
-  guint8 adapt_field_length = 0;
-  gint count = 0;
-  gint off = 0;
-
-  static GstEvent *event = NULL;
-  guint32 remaining;
-  gboolean event_pending = FALSE;
-  
-  g_return_if_fail (GST_IS_TSPARSE (element));
-  object = GST_TSPARSE(element);
-
-  if (!find_start_code(object)) {
-    gst_bytestream_get_status (object->bs, &remaining, &event);
-    CLASS(object)->handle_event(object, event);
-    //    gst_tsparse_handle_event(object);
-  }
-
-  /* read chunk */
-  got_bytes = gst_bytestream_read(object->bs, &buf, PACK_NUM*TS_SIZE);
-  if (got_bytes < PACK_NUM*TS_SIZE) {
-    event = NULL;
-    gst_bytestream_get_status (object->bs, &remaining, &event);
-    if (event)
-      event_pending= TRUE;
-  }
-
-  /* and parse it */
-  data = GST_BUFFER_DATA(buf);
-
-  while (off < got_bytes) {
-
-    if (data[off] != PACK_START_CODE) {
-      off++;
-      continue;
-    }
-
-    adapt_field_length = 0;
-    object->transport_error = data[off+1] & TRANS_ERR_FLAG;
-    object->unit_start      = data[off+1] & UNIT_START_FLAG;
-    object->transport_prio  = data[off+1] & TRANS_PRIO_FLAG;
-    object->have_payload    = data[off+3] & HAVE_PAYLOAD_FLAG;
-
-    object->scramble_contr  = (data[off+3] & SCRAMBLE_MASK) >> 4;
-    object->cont_count      = data[off+3] & CONT_COUNT_MASK;
-    
-    object->pid = get_pid(&data[off+1]);
-
-    if (unknown_pid(object, object->pid)) {
-      GST_INFO("Found PID in TS: %d", object->pid);
-      gst_tsparse_add_ts_pid(object, object->pid);
-    }
-
-    
-    if (data[off+3] & ADAPT_FIELD_FLAG) {
-      /* Adaption Field is present */
-      adapt_field_length = data[off+4] + 1; /* length including length field */
-      if (adapt_field_length > 1) {
-	GST_LOG("Have adaption field of length %d: %x", adapt_field_length, data[off+5]);
-	if (data[off+5] & DISCONT_FLAG)    
-	  GST_LOG ("Discont");
-	if (data[off+5] & RAND_ACC_FLAG) { 
-	  GST_LOG ("RAND Access");
-	  object->rand = TRUE;
-	}
-	if (data[off+5] & ES_PRIO_FLAG)
-	  GST_LOG ("ES Prio Ind");
-	if (data[off+5] & PCR_FLAG) {
-	  guint64 pcr = 0LL;
-	  pcr |= data[off+6]; pcr = pcr << 8;
-	  pcr |= data[off+7]; pcr = pcr << 8;
-	  pcr |= data[off+8]; pcr = pcr << 8;
-	  pcr |= data[off+9]; pcr = pcr << 1;
-	  pcr |= data[off+10];
-	  GST_DEBUG ("Have PCR%" G_GUINT64_FORMAT "\n", pcr);
-	}
-	if (data[off+5] & OPCR_FLAG)      GST_LOG ("OPCR Flag");
-	if (data[off+5] & SPLICE_FLAG)    GST_LOG ("Splicing Point");
-	if (data[off+5] & PRIV_DATA_FLAG) GST_LOG ("Private Data");
-	if (data[off+5] & ADAPT_EXT_FLAG) GST_LOG ("Adapt Extension");
-      }
-    }
-    
-    if (!object->transport_error && CLASS(object)->parse_payload != NULL) {
-      /* Payload */
-      CLASS(object)->parse_payload(object, data+off+4+adapt_field_length, TS_SIZE-(4+adapt_field_length));
-    }
-    else if (!object->transport_error) {
-      /* Section */
-      gst_tsparse_section(object, data+off+4+adapt_field_length, TS_SIZE-(4+adapt_field_length));
-    }
-   
-    object->payload_count += TS_SIZE-(4+adapt_field_length);
-    object->packet_count++;
-    count++;
-    off += TS_SIZE;
-  }
-
-  if (event_pending)
-    CLASS(object)->handle_event(object, event);
-
-  gst_buffer_unref(buf);
-}
-
-
-static GstElementStateReturn
-gst_tsparse_change_state (GstElement *element)
-{
-  GstTsParse *object;
-
-  object = GST_TSPARSE (element);
-
-  GST_INFO ("gst_tsparse_change_state");
-
-  switch (GST_STATE_TRANSITION (element)) {
-  case GST_STATE_READY_TO_PAUSED:
-    break;
-  case GST_STATE_PAUSED_TO_PLAYING:
-    break;
-  case GST_STATE_PLAYING_TO_PAUSED:
-    break;
-  case GST_STATE_PAUSED_TO_READY:
-    break;
-  }
- 
-  parent_class->change_state (element);
+	if (f == NULL)
+		return;
 
-  return GST_STATE_SUCCESS;
+
+	GST_DEBUG ("Parse Section for Pid %d: %dbytes", object->pid, p_length,
+			   payload);
+
+
+	/* check continuity counter */
+	if ((f->cont_count + 1 & 0x0F) != object->cont_count)
+	{
+		f->cont_count = object->cont_count;
+		/* Discard what has been read so far */
+		f->count = 0;
+		return;
+	}
+
+	f->cont_count = object->cont_count;
+
+	if (object->unit_start)
+	{
+
+		GST_DEBUG ("Unit Start");
+
+		guint8 section_off = payload[0];	// start of the new section
+		GST_DEBUG ("Pointer: %d", section_off);
+
+		if (section_off > p_length)	// points beyond payload
+			return;
+
+		if (section_off > 0)
+		{						// rest of last section
+			GST_INFO ("Finish last section");
+			memcpy (f->data + f->count, payload + 1, section_off);
+			f->count += section_off;
+			gst_tsparse_handle_section (object, f->data);
+			f->count = 0;
+		}
+
+		/* copy new section payload+pointer ... max(p_length, f->length) */
+		if (p_length - section_off >= 3)
+		{
+			s_length = section_length (payload + section_off + 1);
+			if (s_length <= p_length - section_off)
+			{					// Section will be complete
+				memcpy (f->data, payload + section_off + 1, s_length);
+				gst_tsparse_handle_section (object, f->data);
+				f->count = 0;
+				return;
+			}
+		}
+		// copy until payload end, complete next time
+		memcpy (f->data, payload + section_off + 1, p_length - section_off);
+		f->count = p_length - section_off - 1;
+		return;
+	}
+	else
+	{							// complete the section
+		if (f->count >= 3)
+		{
+			s_length = section_length (f->data);
+
+			if (s_length - f->count <= p_length)
+			{					// Last byte of section in payload
+				memcpy (f->data + f->count, payload, s_length - f->count);
+				gst_tsparse_handle_section (object,
+											g_memdup (f->data,
+													  MAX_SECTION_LENGTH));
+				f->count = 0;
+				return;
+			}
+
+		}
+
+		// Take all of the payload, complete section next time
+		memcpy (f->data + f->count, payload, p_length);
+		f->count += p_length;
+	}
+}
+
+static GstStateChangeReturn
+gst_tsparse_change_state (GstElement * element, GstStateChange transition)
+{
+	GstTsParse *object;
+
+	object = GST_TSPARSE (element);
+
+	GST_INFO ("gst_tsparse_change_state");
+
+	switch (transition)
+	{
+	case GST_STATE_CHANGE_READY_TO_PAUSED:
+		break;
+	case GST_STATE_CHANGE_PAUSED_TO_PLAYING:
+		break;
+	case GST_STATE_CHANGE_PLAYING_TO_PAUSED:
+		break;
+	case GST_STATE_CHANGE_PAUSED_TO_READY:
+		break;
+	}
+
+	return	parent_class->change_state (element, transition);
+}
+
+static GstFlowReturn
+gst_tsparse_chain (GstPad * pad, GstBuffer* buffer)
+{
+	GstTsParse *object = NULL;
+	guint8 *data = NULL;
+	const guint32 got_bytes = PACK_NUM * TS_SIZE;
+	guint8 adapt_field_length = 0;
+	gint count = 0;
+	gint off = 0;
+	static GstEvent *event = NULL;
+	guint32 remaining;
+	gboolean event_pending = FALSE;
+
+	object = GST_TSPARSE (GST_OBJECT_PARENT (pad));
+	gst_adapter_push(object->ad, buffer);
+
+	if (!find_start_code (object))
+	{
+		return GST_FLOW_OK;
+	}
+
+	/* read chunk */
+	while (gst_adapter_available(object->ad) > got_bytes)
+	{
+		data = gst_adapter_peek (object->ad, got_bytes);
+
+		while (off < got_bytes)
+		{
+
+			if (data[off] != PACK_START_CODE)
+			{
+				off++;
+				continue;
+			}
+
+			adapt_field_length = 0;
+			object->transport_error = data[off + 1] & TRANS_ERR_FLAG;
+			object->unit_start = data[off + 1] & UNIT_START_FLAG;
+			object->transport_prio = data[off + 1] & TRANS_PRIO_FLAG;
+			object->have_payload = data[off + 3] & HAVE_PAYLOAD_FLAG;
+
+			object->scramble_contr = (data[off + 3] & SCRAMBLE_MASK) >> 4;
+			object->cont_count = data[off + 3] & CONT_COUNT_MASK;
+
+			object->pid = get_pid (&data[off + 1]);
+
+			if (unknown_pid (object, object->pid))
+			{
+				GST_INFO ("Found PID in TS: %d", object->pid);
+				gst_tsparse_add_ts_pid (object, object->pid);
+			}
+
+
+			if (data[off + 3] & ADAPT_FIELD_FLAG)
+			{
+				/* Adaption Field is present */
+				adapt_field_length = data[off + 4] + 1;	/* length including length field */
+				if (adapt_field_length > 1)
+				{
+					GST_LOG ("Have adaption field of length %d: %x",
+						 adapt_field_length, data[off + 5]);
+					if (data[off + 5] & DISCONT_FLAG)
+						GST_LOG ("Discont");
+					if (data[off + 5] & RAND_ACC_FLAG)
+					{
+						GST_LOG ("RAND Access");
+						object->rand = TRUE;
+					}
+					if (data[off + 5] & ES_PRIO_FLAG)
+						GST_LOG ("ES Prio Ind");
+					if (data[off + 5] & PCR_FLAG)
+					{
+						guint64 pcr = 0LL;
+						pcr |= data[off + 6];
+						pcr = pcr << 8;
+						pcr |= data[off + 7];
+						pcr = pcr << 8;
+						pcr |= data[off + 8];
+						pcr = pcr << 8;
+						pcr |= data[off + 9];
+						pcr = pcr << 1;
+						pcr |= data[off + 10];
+						GST_DEBUG ("Have PCR%" G_GUINT64_FORMAT "\n", pcr);
+					}
+					if (data[off + 5] & OPCR_FLAG)
+						GST_LOG ("OPCR Flag");
+					if (data[off + 5] & SPLICE_FLAG)
+						GST_LOG ("Splicing Point");
+					if (data[off + 5] & PRIV_DATA_FLAG)
+						GST_LOG ("Private Data");
+					if (data[off + 5] & ADAPT_EXT_FLAG)
+						GST_LOG ("Adapt Extension");
+				}
+			}
+
+			if (!object->transport_error && CLASS (object)->parse_payload != NULL)
+			{
+				/* Payload */
+				CLASS (object)->parse_payload (object,
+										   data + off + 4 + adapt_field_length,
+										   TS_SIZE - (4 + adapt_field_length));
+			}
+			else if (!object->transport_error)
+			{
+				/* Section */
+				gst_tsparse_section (object, data + off + 4 + adapt_field_length,
+								 TS_SIZE - (4 + adapt_field_length));
+			}
+
+			object->payload_count += TS_SIZE - (4 + adapt_field_length);
+			object->packet_count++;
+			count++;
+			off += TS_SIZE;
+		}
+
+		if (event_pending)
+			CLASS (object)->handle_event (object, event);
+
+		gst_adapter_flush(object->ad, got_bytes);
+	}
+	return GST_FLOW_OK;
 }
 
 
Index: gsttsparse.h
===================================================================
RCS file: /cvs/gstreamer/gst-sandbox/dvb-elements/ts-tools/gsttsparse.h,v
retrieving revision 1.2
diff -u -r1.2 gsttsparse.h
--- gsttsparse.h	23 Nov 2004 13:26:30 -0000	1.2
+++ gsttsparse.h	15 Jun 2006 12:45:12 -0000
@@ -3,26 +3,24 @@
 
 #include <glib.h>
 #include <gst/gst.h>
-#include <gst/bytestream/bytestream.h>
+#include <gst/base/gstadapter.h>
 
-G_BEGIN_DECLS
-
-static char* stream_type_str[] = {
-    "ITU-T | ISO/IEC Reserved",
-    "ISO/IEC 11172 Video",
-    "ITU-T Rec. H.262 | ISO/IEC 13818-2 Video or ISO/IEC 11172-2 constrained parameter video stream",
-    "ISO/IEC 11172",
-    "Audio ISO/IEC 13818-3",
-    "Audio ITU-T Rec. H.222.0 | ISO/IEC 13818-1 private_sections",
-    "ITU-T Rec. H.222.0 | ISO/IEC 13818-1 PES packets containing private data",
-    "ISO/IEC 13522 MHEG",
-    "ITU-T Rec. H.222.0 | ISO/IEC 13818-1 Annex A DSM CC",
-    "ITU-T Rec. H.222.1",
-    "ISO/IEC 13818-6 type A",
-    "ISO/IEC 13818-6 type B",
-    "ISO/IEC 13818-6 type C",
-    "ISO/IEC 13818-6 type D",
-    "ISO/IEC 13818-1 auxiliary"
+G_BEGIN_DECLS static char *stream_type_str[] = {
+  "ITU-T | ISO/IEC Reserved",
+  "ISO/IEC 11172 Video",
+  "ITU-T Rec. H.262 | ISO/IEC 13818-2 Video or ISO/IEC 11172-2 constrained parameter video stream",
+  "ISO/IEC 11172",
+  "Audio ISO/IEC 13818-3",
+  "Audio ITU-T Rec. H.222.0 | ISO/IEC 13818-1 private_sections",
+  "ITU-T Rec. H.222.0 | ISO/IEC 13818-1 PES packets containing private data",
+  "ISO/IEC 13522 MHEG",
+  "ITU-T Rec. H.222.0 | ISO/IEC 13818-1 Annex A DSM CC",
+  "ITU-T Rec. H.222.1",
+  "ISO/IEC 13818-6 type A",
+  "ISO/IEC 13818-6 type B",
+  "ISO/IEC 13818-6 type C",
+  "ISO/IEC 13818-6 type D",
+  "ISO/IEC 13818-1 auxiliary"
     //0x0f-0x7f "ITU-T Rec. H.222.0 | ISO/IEC 13818-1 Reserved User Private" 
     //0x80-0xff "User Private"
 };
@@ -61,34 +59,37 @@
   (G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_TSPARSE))
 
 
-typedef struct _GstTsParse      GstTsParse;
+typedef struct _GstTsParse GstTsParse;
 typedef struct _GstTsParseClass GstTsParseClass;
 
 
-typedef struct {
+typedef struct
+{
   guint16 pid;
-  guint8  stream_type;
-  gint    descr_length;
-  gchar   *descr;
+  guint8 stream_type;
+  gint descr_length;
+  gchar *descr;
 } EsInfo;
 
 
-typedef struct {
+typedef struct
+{
   guint16 program_number;
   guint16 pcr_pid;
   guint16 net_pid;
   guint16 pmt_pid;
-  guint8  version;
-  GList   *elem_streams;
-  gint    descr_length;
-  gchar   *descr;
+  guint8 version;
+  GList *elem_streams;
+  gint descr_length;
+  gchar *descr;
 } ProgramMap;
 
-typedef struct {
-  gint    pid;
-  guint8  data[MAX_SECTION_LENGTH];
+typedef struct
+{
+  gint pid;
+  guint8 data[MAX_SECTION_LENGTH];
   guint16 count;
-  gint    cont_count;
+  gint cont_count;
 } SectionFilter;
 
 struct _GstTsParse
@@ -101,28 +102,28 @@
   gboolean transport_error;
   gboolean unit_start;
   gboolean transport_prio;
-  gint     scramble_contr;
-  gint     cont_count;
+  gint scramble_contr;
+  gint cont_count;
   gboolean have_payload;
-  gint     pid;
+  gint pid;
 
   /* Adaption Field Flags */
   gboolean rand;
   gboolean discont;
 
-  GstByteStream *bs;
+  GstAdapter *ad;
 
   /* Pids found in the stream */
   /* TODO: pids are never removed, add decay mechanism */
   gint ts_pids[MAX_PIDS];
 
-  /* Array of section filter for dynamic PMT sections*/
+  /* Array of section filter for dynamic PMT sections */
   GArray *section_filt;
 
   /* PSI */
-  gint   pat_version;
+  gint pat_version;
   GArray *programs;
-  gint   net_pid;
+  gint net_pid;
 
   /* statistics */
   guint64 packet_count;
@@ -130,21 +131,21 @@
 
 };
 
-struct _GstTsParseClass 
+struct _GstTsParseClass
 {
   GstElementClass parent_class;
 
-  void (*parse_payload) (GstTsParse *object, guint8 *data, int length);
-  void (*parse_reserved_section) (GstTsParse *object, const guint8 *section);
-  void (*parse_private_section) (GstTsParse *object, const guint8 *section);
+  void (*parse_payload) (GstTsParse * object, guint8 * data, int length);
+  void (*parse_reserved_section) (GstTsParse * object,
+				  const guint8 * section);
+  void (*parse_private_section) (GstTsParse * object, const guint8 * section);
   // Subclasses can define their own section filter
-  SectionFilter* (*get_section_filter) (GstTsParse *object);
+  SectionFilter *(*get_section_filter) (GstTsParse * object);
 
-  void (*handle_event) (GstTsParse *object, GstEvent *event);
+  void (*handle_event) (GstTsParse * object, GstEvent * event);
 };
 
 GType gst_tsparse_get_type (void);
 
 G_END_DECLS
-
 #endif /* __GST_TSPARSE_H__ */
