Browse Source

Check if PUSI packet comes before table/pes gathering ihas finished.

Without this check broken transport streams that start new tables
before finishing old ones cause psi gathering to fail.
Georgi Chorbadzhiyski 12 years ago
parent
commit
9094238a7d
9 changed files with 27 additions and 0 deletions
  1. 3
    0
      cat.c
  2. 3
    0
      eit.c
  3. 3
    0
      nit.c
  4. 3
    0
      pat.c
  5. 3
    0
      pes.c
  6. 3
    0
      pmt.c
  7. 3
    0
      privsec.c
  8. 3
    0
      sdt.c
  9. 3
    0
      tdt.c

+ 3
- 0
cat.c View File

@@ -47,6 +47,9 @@ struct ts_cat *ts_cat_push_packet(struct ts_cat *cat, uint8_t *ts_packet) {
47 47
 	memset(&ts_header, 0, sizeof(struct ts_header));
48 48
 
49 49
 	if (ts_packet_header_parse(ts_packet, &ts_header)) {
50
+		// Received PUSI packet before table END, clear the table to start gathering new one
51
+		if (cat->ts_header.pusi)
52
+			ts_cat_clear(cat);
50 53
 		if (!cat->ts_header.pusi)
51 54
 			cat->ts_header = ts_header;
52 55
 	}

+ 3
- 0
eit.c View File

@@ -67,6 +67,9 @@ struct ts_eit *ts_eit_push_packet(struct ts_eit *eit, uint8_t *ts_packet) {
67 67
 		// EIT should be with PID 0x12
68 68
 		if (ts_header.pid != 0x12)
69 69
 			goto OUT;
70
+		// Received PUSI packet before table END, clear the table to start gathering new one
71
+		if (eit->ts_header.pusi)
72
+			ts_eit_clear(eit);
70 73
 		if (!eit->ts_header.pusi)
71 74
 			eit->ts_header = ts_header;
72 75
 	}

+ 3
- 0
nit.c View File

@@ -69,6 +69,9 @@ struct ts_nit *ts_nit_push_packet(struct ts_nit *nit, uint8_t *ts_packet) {
69 69
 		// NIT should be with PID 0x10
70 70
 		if (ts_header.pid != 0x10)
71 71
 			goto OUT;
72
+		// Received PUSI packet before table END, clear the table to start gathering new one
73
+		if (nit->ts_header.pusi)
74
+			ts_nit_clear(nit);
72 75
 		if (!nit->ts_header.pusi)
73 76
 			nit->ts_header = ts_header;
74 77
 	}

+ 3
- 0
pat.c View File

@@ -66,6 +66,9 @@ struct ts_pat *ts_pat_push_packet(struct ts_pat *pat, uint8_t *ts_packet) {
66 66
 		// PAT should be with PID 0x00
67 67
 		if (ts_header.pid != 0x00)
68 68
 			goto OUT;
69
+		// Received PUSI packet before table END, clear the table to start gathering new one
70
+		if (pat->ts_header.pusi)
71
+			ts_pat_clear(pat);
69 72
 		if (!pat->ts_header.pusi)
70 73
 			pat->ts_header = ts_header;
71 74
 	}

+ 3
- 0
pes.c View File

@@ -216,6 +216,9 @@ struct ts_pes *ts_pes_push_packet(struct ts_pes *pes, uint8_t *ts_packet, struct
216 216
 		goto OUT;
217 217
 
218 218
 	if (ts_header.pusi) {
219
+		// Received PUSI packet before PES END, clear the table to start gathering new one
220
+		if (pes->ts_header.pusi)
221
+			ts_pes_clear(pes);
219 222
 		uint8_t stream_id = 0;
220 223
 		int pes_packet_len = 0;
221 224
 		if (payload[0] == 0x00 && payload[1] == 0x00 && payload[2] == 0x01) { // pes_start_code_prefix

+ 3
- 0
pmt.c View File

@@ -67,6 +67,9 @@ struct ts_pmt *ts_pmt_push_packet(struct ts_pmt *pmt, uint8_t *ts_packet) {
67 67
 	memset(&ts_header, 0, sizeof(struct ts_header));
68 68
 
69 69
 	if (ts_packet_header_parse(ts_packet, &ts_header)) {
70
+		// Received PUSI packet before table END, clear the table to start gathering new one
71
+		if (pmt->ts_header.pusi)
72
+			ts_pmt_clear(pmt);
70 73
 		if (!pmt->ts_header.pusi)
71 74
 			pmt->ts_header = ts_header;
72 75
 	}

+ 3
- 0
privsec.c View File

@@ -53,6 +53,9 @@ struct ts_privsec *ts_privsec_push_packet(struct ts_privsec *privsec, uint8_t *t
53 53
 	memset(&ts_header, 0, sizeof(struct ts_header));
54 54
 
55 55
 	if (ts_packet_header_parse(ts_packet, &ts_header)) {
56
+		// Received PUSI packet before table END, clear the table to start gathering new one
57
+		if (privsec->ts_header.pusi)
58
+			ts_privsec_clear(privsec);
56 59
 		if (!privsec->ts_header.pusi)
57 60
 			privsec->ts_header = ts_header;
58 61
 	}

+ 3
- 0
sdt.c View File

@@ -67,6 +67,9 @@ struct ts_sdt *ts_sdt_push_packet(struct ts_sdt *sdt, uint8_t *ts_packet) {
67 67
 		// SDT should be with PID 0x11
68 68
 		if (ts_header.pid != 0x11)
69 69
 			goto OUT;
70
+		// Received PUSI packet before table END, clear the table to start gathering new one
71
+		if (sdt->ts_header.pusi)
72
+			ts_sdt_clear(sdt);
70 73
 		if (!sdt->ts_header.pusi)
71 74
 			sdt->ts_header = ts_header;
72 75
 	}

+ 3
- 0
tdt.c View File

@@ -51,6 +51,9 @@ struct ts_tdt *ts_tdt_push_packet(struct ts_tdt *tdt, uint8_t *ts_packet) {
51 51
 		// TDT/TOT should be with PID 0x11
52 52
 		if (ts_header.pid != 0x14)
53 53
 			goto OUT;
54
+		// Received PUSI packet before table END, clear the table to start gathering new one
55
+		if (tdt->ts_header.pusi)
56
+			ts_tdt_clear(tdt);
54 57
 		if (!tdt->ts_header.pusi)
55 58
 			tdt->ts_header = ts_header;
56 59
 	}

Loading…
Cancel
Save