]> git.ipfire.org Git - thirdparty/tvheadend.git/commitdiff
mpegts tsfile: fix PCR extraction for tsfile playback
authorAdam Sutton <dev@adamsutton.me.uk>
Wed, 16 Apr 2014 18:49:28 +0000 (19:49 +0100)
committerAdam Sutton <dev@adamsutton.me.uk>
Wed, 16 Apr 2014 18:50:32 +0000 (19:50 +0100)
src/input/mpegts.h
src/input/mpegts/mpegts_input.c
src/input/mpegts/tsfile/tsfile_input.c
src/input/mpegts/tsfile/tsfile_mux.c

index a4c5d7554c553dd0b216818379459c32484bb186..d6d5e5eb06a8000fabbfee1164f9758a16e6777d 100644 (file)
@@ -33,6 +33,7 @@
 #define MPEGTS_TSID_NONE        0xFFFF
 #define MPEGTS_PSI_SECTION_SIZE 5000
 #define MPEGTS_FULLMUX_PID      0x2000
+#define MPEGTS_PID_NONE         0xFFFF
 
 /* Types */
 typedef struct mpegts_table         mpegts_table_t;
index 0a0595568ca88f32862575f7eeef91dee93eeb4b..7a3a23c9b4ee96a5186e836d194efd0e5d827108 100644 (file)
@@ -459,14 +459,15 @@ mpegts_input_recv_packets
   //       without the potential need to buffer data (since that would
   //       require per mmi buffers, where this is generally not required)
 
-  /* Extract PCR */
-  // Note: this is only used by tsfile for timing the play out of packets
-  //       maybe we should move it?
+  /* Extract PCR (used for tsfile playback) */
   if (pcr && pcr_pid) {
     uint8_t *tmp = tsb;
     for (i = 0; i < p; i++) {
-      if (*pcr_pid == (((tmp[1] & 0x1f) << 8) | tmp[2]) || *pcr_pid == 0)
+      int pid = ((tmp[1] & 0x1f) << 8) | tmp[2];
+      if (*pcr_pid == MPEGTS_PID_NONE || *pcr_pid == pid) {
         ts_recv_packet1(NULL, tmp, pcr, 0);
+        if (*pcr != PTS_UNSET) *pcr_pid = pid;
+      }
       tmp += 188;
     }
   }
index edf23d954c22cb8f75cede44423deaae1f276156..aa56186c958b75f6a155d4bfe80fd01747337b83 100644 (file)
@@ -94,7 +94,7 @@ tsfile_input_thread ( void *aux )
   while (1) {
       
     /* Find PCR PID */
-    if (!tmi->mmi_tsfile_pcr_pid) { 
+    if (tmi->mmi_tsfile_pcr_pid == MPEGTS_PID_NONE) { 
       mpegts_service_t *s;
       pthread_mutex_lock(&tsfile_lock);
       LIST_FOREACH(s, &tmi->mmi_mux->mm_services, s_dvb_mux_link) {
index 000ae3e15f4ec4e51a50841828111d2c55c5e434..d7664264ccbf63392a4b8f32bb6d642a028b14c8 100644 (file)
@@ -31,7 +31,7 @@ tsfile_mux_instance_create
     mpegts_mux_instance_create(tsfile_mux_instance, NULL, mi, mm);
 #undef tsfile_mux_instance_class
   mmi->mmi_tsfile_path    = strdup(path);
-  mmi->mmi_tsfile_pcr_pid = 0;
+  mmi->mmi_tsfile_pcr_pid = MPEGTS_PID_NONE;
   tvhtrace("tsfile", "mmi created %p path %s", mmi, mmi->mmi_tsfile_path);
   return mmi;
 }