mpegtsdemux: Only take PCR from the active stream for bitrate estimation.
authorEdward Hervey <bilboed@bilboed.com>
Mon, 11 May 2009 14:58:58 +0000 (16:58 +0200)
committerEdward Hervey <bilboed@bilboed.com>
Mon, 11 May 2009 14:58:58 +0000 (16:58 +0200)
gst/mpegdemux/gstmpegtsdemux.c

index 213a4a2..f07e174 100644 (file)
@@ -1694,16 +1694,23 @@ gst_mpegts_demux_parse_adaptation_field (GstMpegTSStream * stream,
         }
         stream->last_PCR_difference = pcr - stream->last_PCR;
       }
+
       GST_DEBUG_OBJECT (demux,
           "valid pcr: %d last PCR difference: %" G_GUINT64_FORMAT, valid_pcr,
           stream->last_PCR_difference);
       if (valid_pcr) {
-        if (demux->pcr[0] == -1) {
-          demux->pcr[0] = pcr;
-          demux->num_packets = 0;
-        } /* Considering a difference of 1 sec ie 90000 ticks */
-        else if (demux->pcr[1] == -1 && ((pcr - demux->pcr[0]) >= 90000)) {
-          demux->pcr[1] = pcr;
+        GstMpegTSStream *PMT_stream = demux->streams[demux->current_PMT];
+
+        if (PMT_stream && PMT_stream->PMT.PCR_PID == stream->PID) {
+          if (demux->pcr[0] == -1) {
+            GST_DEBUG ("RECORDING pcr[0]:%" G_GUINT64_FORMAT, pcr);
+            demux->pcr[0] = pcr;
+            demux->num_packets = 0;
+          } /* Considering a difference of 1 sec ie 90000 ticks */
+          else if (demux->pcr[1] == -1 && ((pcr - demux->pcr[0]) >= 90000)) {
+            GST_DEBUG ("RECORDING pcr[1]:%" G_GUINT64_FORMAT, pcr);
+            demux->pcr[1] = pcr;
+          }
         }
         stream->last_PCR = pcr;