#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;
// 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;
}
}
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) {
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;
}