diff -Nupr a/src/dvr/dvr_rec.c b/src/dvr/dvr_rec.c --- a/src/dvr/dvr_rec.c 2012-06-07 01:42:39.000000000 +0200 +++ b/src/dvr/dvr_rec.c 2012-06-07 01:40:04.000000000 +0200 @@ -424,7 +424,8 @@ dvr_thread(void *aux) dvr_config_t *cfg = dvr_config_find_by_name_default(de->de_config_name); streaming_tsbuf_t pat_pmt_tsbuf; struct mk_ts_pat_pmt pat_pmt_buf; - int ts_packets_cnt = 1000; + uint32_t ts_packets_cnt = 1000; + uint8_t pat_pmt_packets_cnt = 0; int run = 1; pthread_mutex_lock(&sq->sq_mutex); @@ -460,7 +461,6 @@ dvr_thread(void *aux) if (strcmp(cfg->dvr_format, "mpegts") == 0) { struct streaming_start *ss = sm->sm_data; run = mk_ts_build_pat_pmt(&pat_pmt_buf, ss, de->de_s->ths_service->s_pmt_pid, de->de_s->ths_service->s_pcr_pid); - pat_pmt_tsbuf.ts_data = (uint8_t *)&pat_pmt_buf; pat_pmt_tsbuf.ts_cnt = 2; } @@ -541,11 +541,16 @@ dvr_thread(void *aux) if(de->de_mkts != NULL) { streaming_tsbuf_t *tsbuf = sm->sm_data; - ts_packets_cnt += tsbuf->ts_cnt; if(ts_packets_cnt >= 1000) { ts_packets_cnt = 0; + + pat_pmt_buf.pat_ts[3] = (pat_pmt_buf.pat_ts[3] & 0xf0) | (pat_pmt_packets_cnt & 0x0f); + pat_pmt_buf.pmt_ts[3] = (pat_pmt_buf.pmt_ts[3] & 0xf0) | (pat_pmt_packets_cnt & 0x0f); + pat_pmt_packets_cnt++; + mk_ts_write(de->de_mkts, &pat_pmt_tsbuf); } + ts_packets_cnt += tsbuf->ts_cnt; mk_ts_write(de->de_mkts, tsbuf); } diff -Nupr a/src/webui/webui.c b/src/webui/webui.c --- a/src/webui/webui.c 2012-06-07 01:41:55.000000000 +0200 +++ b/src/webui/webui.c 2012-06-07 01:40:04.000000000 +0200 @@ -134,7 +134,8 @@ http_stream_run(http_connection_t *hc, s streaming_message_t *sm; mk_mux_t *mkm = NULL; struct mk_ts_pat_pmt pat_pmt_buf; - int ts_packets_cnt = 1000; + uint32_t ts_packets_cnt = 1000; + uint8_t pat_pmt_packets_cnt = 0; int run = 1; int timeouts = 0; uint32_t event_id = 0; @@ -237,12 +238,17 @@ http_stream_run(http_connection_t *hc, s streaming_tsbuf_t *tsbuf = sm->sm_data; uint32_t size = tsbuf->ts_cnt * 188; - ts_packets_cnt += tsbuf->ts_cnt; if (ts_packets_cnt >= 1000) { ts_packets_cnt = 0; + + pat_pmt_buf.pat_ts[3] = (pat_pmt_buf.pat_ts[3] & 0xf0) | (pat_pmt_packets_cnt & 0x0f); + pat_pmt_buf.pmt_ts[3] = (pat_pmt_buf.pmt_ts[3] & 0xf0) | (pat_pmt_packets_cnt & 0x0f); + pat_pmt_packets_cnt++; + run = write(hc->hc_fd, pat_pmt_buf.pat_ts, 188) == 188; run = write(hc->hc_fd, pat_pmt_buf.pmt_ts, 188) == 188; } + ts_packets_cnt += tsbuf->ts_cnt; if(!run) break;