diff --git a/code/Gstreamer/gstreamer-1.0.8/mpegtsdemux/mpegtsbase.c b/code/Gstreamer/gstreamer-1.0.8/mpegtsdemux_fixed/mpegtsbase.c
index 25b930f..375b082 100644
--- a/code/Gstreamer/gstreamer-1.0.8/mpegtsdemux/mpegtsbase.c
+++ b/code/Gstreamer/gstreamer-1.0.8/mpegtsdemux_fixed/mpegtsbase.c
@@ -43,6 +43,7 @@
 
 #include <gst/gst-i18n-plugin.h>
 #include "mpegtsbase.h"
+#include "tsdemux.h"
 #include "gstmpegdesc.h"
 
 /* latency in mseconds */
@@ -232,6 +233,13 @@ mpegts_base_reset (MpegTSBase * base)
 
   g_hash_table_foreach_remove (base->programs, (GHRFunc) remove_each_program,
       base);
+  
+  /*FIX: */
+  base->packetizer->requested_pcr_id 		 = -1;
+  base->packetizer->num_streams_in_program 	 = 0;
+  base->packetizer->seen_program 			 = FALSE;
+  base->packetizer->stream_found 			 = FALSE;
+  memset(base->packetizer->requested_pes_id, 0, sizeof(base->packetizer->requested_pes_id));
 
   if (klass->reset)
     klass->reset (base);
@@ -258,6 +266,7 @@ mpegts_base_init (MpegTSBase * base)
   base->program_size = sizeof (MpegTSBaseProgram);
   base->stream_size = sizeof (MpegTSBaseStream);
 
+  base->packetizer->requested_program_number = -1;
   mpegts_base_reset (base);
 }
 
@@ -519,7 +528,7 @@ mpegts_base_program_add_stream (MpegTSBase * base,
   MpegTSBaseClass *klass = GST_MPEGTS_BASE_GET_CLASS (base);
   MpegTSBaseStream *stream;
 
-  GST_DEBUG ("pid:0x%04x, stream_type:0x%03x, stream_info:%" GST_PTR_FORMAT,
+  GST_DEBUG ("pid:0x%04x, stream_type:0x%03x, stream_info:%" GST_PTR_FORMAT,
       pid, stream_type, stream_info);
 
   if (G_UNLIKELY (program->streams[pid])) {
@@ -701,6 +710,7 @@ mpegts_base_activate_program (MpegTSBase * base, MpegTSBaseProgram * program,
   const GValue *new_streams;
   const GValue *value;
   MpegTSBaseClass *klass;
+  gint index=0;
 
   if (G_UNLIKELY (program->active))
     return;
@@ -720,6 +730,15 @@ mpegts_base_activate_program (MpegTSBase * base, MpegTSBaseProgram * program,
   new_streams = gst_structure_id_get_value (pmt_info, QUARK_STREAMS);
   nbstreams = gst_value_list_get_size (new_streams);
 
+  if((program->program_number == base->packetizer->requested_program_number) || 
+	(base->packetizer->requested_program_number == -1))
+  {
+	base->packetizer->requested_program_number  = program->program_number;
+	base->packetizer->seen_program 			 	= TRUE;
+	base->packetizer->requested_pcr_id 		 	= program->pcr_pid;
+	base->packetizer->num_streams_in_program 	= nbstreams;
+  }
+
   for (i = 0; i < nbstreams; ++i) {
     value = gst_value_list_get_value (new_streams, i);
     stream = g_value_get_boxed (value);
@@ -727,9 +746,20 @@ mpegts_base_activate_program (MpegTSBase * base, MpegTSBaseProgram * program,
     gst_structure_id_get (stream, QUARK_PID, G_TYPE_UINT, &pid,
         QUARK_STREAM_TYPE, G_TYPE_UINT, &stream_type, NULL);
     MPEGTS_BIT_SET (base->is_pes, pid);
+	
+	if((program->program_number == base->packetizer->requested_program_number))
+	 {
+		if (i4_index < MAX_STREAMS)
+		{
+			base->packetizer->requested_pes_id[i4_index] = pid;
+			index++;
+		}
+		else
+			GST_WARNING("Number of streams in a program are exceeding RS_MAX_STREAM limit!!!");
+	 }
     mpegts_base_program_add_stream (base, program,
         (guint16) pid, (guint8) stream_type, stream);
-
+
   }
   /* We add the PCR pid last. If that PID is already used by one of the media
    * streams above, no new stream will be created */
@@ -1082,7 +1112,7 @@ mpegts_base_handle_psi (MpegTSBase * base, MpegTSPacketizerSection * section)
         mpegts_base_apply_pat (base, structure);
         if (base->seen_pat == FALSE) {
           base->seen_pat = TRUE;
-          GST_DEBUG ("First PAT offset: %" G_GUINT64_FORMAT, section->offset);
+          GST_DEBUG ("First PAT offset: %" G_GUINT64_FORMAT, section->offset);
           mpegts_packetizer_set_reference_offset (base->packetizer,
               section->offset);
         }
diff --git a/code/Gstreamer/gstreamer-1.0.8/mpegtsdemux/mpegtspacketizer.c b/code/Gstreamer/gstreamer-1.0.8/mpegtsdemux_fixed/mpegtspacketizer.c
index 7323c3e..ec2d977 100644
--- a/code/Gstreamer/gstreamer-1.0.8/mpegtsdemux/mpegtspacketizer.c
+++ b/code/Gstreamer/gstreamer-1.0.8/mpegtsdemux_fixed/mpegtspacketizer.c
@@ -558,6 +558,24 @@ mpegts_packetizer_parse_packet (MpegTSPacketizer2 * packetizer,
   /* PID 13 */
   packet->pid = GST_READ_UINT16_BE (data) & 0x1FFF;
   data += 2;
+  
+  /* Dont parse the packet if the pid doesnt match with the requested pid */
+  packetizer->stream_found = FALSE;
+  if(packetizer->seen_program)
+  {
+	gint index;
+	for( index=0; index < packetizer->num_streams_in_program; index++ )
+	{
+		if(packet->pid == packetizer->requested_pes_id[index])
+		{
+			packetizer->stream_found = TRUE;
+			break;
+		}
+	}
+
+	if(!packetizer->stream_found)
+		return PACKET_BAD;
+  }
 
   /* transport_scrambling_control 2 */
   if (G_UNLIKELY (*data >> 6))
diff --git a/code/Gstreamer/gstreamer-1.0.8/mpegtsdemux/mpegtspacketizer.h b/code/Gstreamer/gstreamer-1.0.8/mpegtsdemux_fixed/mpegtspacketizer.h
index 01bb9a0..eb2d354 100644
--- a/code/Gstreamer/gstreamer-1.0.8/mpegtsdemux/mpegtspacketizer.h
+++ b/code/Gstreamer/gstreamer-1.0.8/mpegtsdemux_fixed/mpegtspacketizer.h
@@ -81,6 +81,9 @@ typedef struct
   guint64 offset;
 } MpegTSPacketizerStream;
 
+/*we are assuming 16 maximum streams in a program */
+#define MAX_STREAMS 16
+
 struct _MpegTSPacketizer2 {
   GObject     parent;
 
@@ -104,6 +107,14 @@ struct _MpegTSPacketizer2 {
   gboolean       calculate_offset;
 
   MpegTSPacketizerPrivate *priv;
+
+  /* FIX: */
+  gint 		requested_program_number;
+  guint 	requested_pes_id[MAX_STREAMS];
+  gint 		requested_pcr_id;
+  gint 		num_streams_in_program;
+  gboolean 	seen_program;
+  gboolean	stream_found;
 };
 
 struct _MpegTSPacketizer2Class {
diff --git a/code/Gstreamer/gstreamer-1.0.8/mpegtsdemux/tsdemux.c b/code/Gstreamer/gstreamer-1.0.8/mpegtsdemux_fixed/tsdemux.c
index f67b67d..bb0c9b7 100644
--- a/code/Gstreamer/gstreamer-1.0.8/mpegtsdemux/tsdemux.c
+++ b/code/Gstreamer/gstreamer-1.0.8/mpegtsdemux_fixed/tsdemux.c
@@ -337,10 +337,12 @@ gst_ts_demux_init (GstTSDemux * demux)
 {
   GST_MPEGTS_BASE (demux)->stream_size = sizeof (TSDemuxStream);
 
+  demux->requested_program_number = -1;
+  GST_MPEGTS_BASE (demux)->packetizer->requested_program_number = -1;
   gst_ts_demux_reset ((MpegTSBase *) demux);
 }
 
-
+
 static void
 gst_ts_demux_set_property (GObject * object, guint prop_id,
     const GValue * value, GParamSpec * pspec)
@@ -351,8 +353,9 @@ gst_ts_demux_set_property (GObject * object, guint prop_id,
     case PROP_PROGRAM_NUMBER:
       /* FIXME: do something if program is switched as opposed to set at
        * beginning */
-      demux->program_number = g_value_get_int (value);
-      break;
+      demux->requested_program_number = g_value_get_int (value);
+      GST_MPEGTS_BASE (demux)->packetizer->requested_program_number = demux->requested_program_number;  
+	 break;
     case PROP_EMIT_STATS:
       demux->emit_statistics = g_value_get_boolean (value);
       break;
@@ -369,7 +372,8 @@ gst_ts_demux_get_property (GObject * object, guint prop_id,
 
   switch (prop_id) {
     case PROP_PROGRAM_NUMBER:
-      g_value_set_int (value, demux->program_number);
+      g_value_set_int (value, demux->requested_program_number);
+	  GST_MPEGTS_BASE (demux)->packetizer->requested_program_number = demux->requested_program_number;
       break;
     case PROP_EMIT_STATS:
       g_value_set_boolean (value, demux->emit_statistics);
@@ -1106,11 +1110,12 @@ gst_ts_demux_program_started (MpegTSBase * base, MpegTSBaseProgram * program)
 {
   GstTSDemux *demux = GST_TS_DEMUX (base);
 
-  GST_DEBUG ("Current program %d, new program %d",
-      demux->program_number, program->program_number);
+  GST_DEBUG ("Current program %d, new program %d requested program %d",
+      (gint) demux->program_number, program->program_number,
+      demux->requested_program_number);
 
-  if (demux->program_number == -1 ||
-      demux->program_number == program->program_number) {
+  if (demux->requested_program_number == program->program_number ||
+     (demux->requested_program_number == -1 && demux->program_number == -1)) {
 
     GST_LOG ("program %d started", program->program_number);
     demux->program_number = program->program_number;
diff --git a/code/Gstreamer/gstreamer-1.0.8/mpegtsdemux/tsdemux.h b/code/Gstreamer/gstreamer-1.0.8/mpegtsdemux_fixed/tsdemux.h
index 5dee984..ccba1a6 100644
--- a/code/Gstreamer/gstreamer-1.0.8/mpegtsdemux/tsdemux.h
+++ b/code/Gstreamer/gstreamer-1.0.8/mpegtsdemux_fixed/tsdemux.h
@@ -55,7 +55,8 @@ struct _GstTSDemux
 
   /* the following vars must be protected with the OBJECT_LOCK as they can be
    * accessed from the application thread and the streaming thread */
-  guint program_number;		/* Required program number (ignore:-1) */
+  gint requested_program_number;		/* Required program number (ignore:-1) */
+  guint program_number;		
   gboolean emit_statistics;
 
   /*< private >*/
