diff --git a/src/input/mpegts.h b/src/input/mpegts.h index a4c5d755..d6d5e5eb 100644 --- a/src/input/mpegts.h +++ b/src/input/mpegts.h @@ -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; diff --git a/src/input/mpegts/mpegts_input.c b/src/input/mpegts/mpegts_input.c index 0a059556..7a3a23c9 100644 --- a/src/input/mpegts/mpegts_input.c +++ b/src/input/mpegts/mpegts_input.c @@ -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; } } diff --git a/src/input/mpegts/tsfile/tsfile_input.c b/src/input/mpegts/tsfile/tsfile_input.c index edf23d95..aa56186c 100644 --- a/src/input/mpegts/tsfile/tsfile_input.c +++ b/src/input/mpegts/tsfile/tsfile_input.c @@ -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) { diff --git a/src/input/mpegts/tsfile/tsfile_mux.c b/src/input/mpegts/tsfile/tsfile_mux.c index 000ae3e1..d7664264 100644 --- a/src/input/mpegts/tsfile/tsfile_mux.c +++ b/src/input/mpegts/tsfile/tsfile_mux.c @@ -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; }