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
 	memset(&ts_header, 0, sizeof(struct ts_header));
47
 	memset(&ts_header, 0, sizeof(struct ts_header));
48
 
48
 
49
 	if (ts_packet_header_parse(ts_packet, &ts_header)) {
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
 		if (!cat->ts_header.pusi)
53
 		if (!cat->ts_header.pusi)
51
 			cat->ts_header = ts_header;
54
 			cat->ts_header = ts_header;
52
 	}
55
 	}

+ 3
- 0
eit.c View File

67
 		// EIT should be with PID 0x12
67
 		// EIT should be with PID 0x12
68
 		if (ts_header.pid != 0x12)
68
 		if (ts_header.pid != 0x12)
69
 			goto OUT;
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
 		if (!eit->ts_header.pusi)
73
 		if (!eit->ts_header.pusi)
71
 			eit->ts_header = ts_header;
74
 			eit->ts_header = ts_header;
72
 	}
75
 	}

+ 3
- 0
nit.c View File

69
 		// NIT should be with PID 0x10
69
 		// NIT should be with PID 0x10
70
 		if (ts_header.pid != 0x10)
70
 		if (ts_header.pid != 0x10)
71
 			goto OUT;
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
 		if (!nit->ts_header.pusi)
75
 		if (!nit->ts_header.pusi)
73
 			nit->ts_header = ts_header;
76
 			nit->ts_header = ts_header;
74
 	}
77
 	}

+ 3
- 0
pat.c View File

66
 		// PAT should be with PID 0x00
66
 		// PAT should be with PID 0x00
67
 		if (ts_header.pid != 0x00)
67
 		if (ts_header.pid != 0x00)
68
 			goto OUT;
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
 		if (!pat->ts_header.pusi)
72
 		if (!pat->ts_header.pusi)
70
 			pat->ts_header = ts_header;
73
 			pat->ts_header = ts_header;
71
 	}
74
 	}

+ 3
- 0
pes.c View File

216
 		goto OUT;
216
 		goto OUT;
217
 
217
 
218
 	if (ts_header.pusi) {
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
 		uint8_t stream_id = 0;
222
 		uint8_t stream_id = 0;
220
 		int pes_packet_len = 0;
223
 		int pes_packet_len = 0;
221
 		if (payload[0] == 0x00 && payload[1] == 0x00 && payload[2] == 0x01) { // pes_start_code_prefix
224
 		if (payload[0] == 0x00 && payload[1] == 0x00 && payload[2] == 0x01) { // pes_start_code_prefix

+ 3
- 0
pmt.c View File

67
 	memset(&ts_header, 0, sizeof(struct ts_header));
67
 	memset(&ts_header, 0, sizeof(struct ts_header));
68
 
68
 
69
 	if (ts_packet_header_parse(ts_packet, &ts_header)) {
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
 		if (!pmt->ts_header.pusi)
73
 		if (!pmt->ts_header.pusi)
71
 			pmt->ts_header = ts_header;
74
 			pmt->ts_header = ts_header;
72
 	}
75
 	}

+ 3
- 0
privsec.c View File

53
 	memset(&ts_header, 0, sizeof(struct ts_header));
53
 	memset(&ts_header, 0, sizeof(struct ts_header));
54
 
54
 
55
 	if (ts_packet_header_parse(ts_packet, &ts_header)) {
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
 		if (!privsec->ts_header.pusi)
59
 		if (!privsec->ts_header.pusi)
57
 			privsec->ts_header = ts_header;
60
 			privsec->ts_header = ts_header;
58
 	}
61
 	}

+ 3
- 0
sdt.c View File

67
 		// SDT should be with PID 0x11
67
 		// SDT should be with PID 0x11
68
 		if (ts_header.pid != 0x11)
68
 		if (ts_header.pid != 0x11)
69
 			goto OUT;
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
 		if (!sdt->ts_header.pusi)
73
 		if (!sdt->ts_header.pusi)
71
 			sdt->ts_header = ts_header;
74
 			sdt->ts_header = ts_header;
72
 	}
75
 	}

+ 3
- 0
tdt.c View File

51
 		// TDT/TOT should be with PID 0x11
51
 		// TDT/TOT should be with PID 0x11
52
 		if (ts_header.pid != 0x14)
52
 		if (ts_header.pid != 0x14)
53
 			goto OUT;
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
 		if (!tdt->ts_header.pusi)
57
 		if (!tdt->ts_header.pusi)
55
 			tdt->ts_header = ts_header;
58
 			tdt->ts_header = ts_header;
56
 	}
59
 	}

Loading…
Cancel
Save