Browse Source

If the input is MPTS rewrite output PAT.

When the input is MPTS and output filtering is enabled, rewrite output
PAT to include only the single program that is decoded.
Georgi Chorbadzhiyski 12 years ago
parent
commit
49de3a80bc
6 changed files with 23 additions and 1 deletions
  1. 2
    0
      ChangeLog
  2. 2
    0
      data.c
  3. 2
    0
      data.h
  4. 1
    1
      libtsfuncs
  5. 10
    0
      process.c
  6. 6
    0
      tables.c

+ 2
- 0
ChangeLog View File

@@ -4,6 +4,8 @@ xxxx-xx-xx : Version next
4 4
  * Fix payload offset detection, a bug which broke packets that have
5 5
    adaptation with whole packet size (libtsfuncs).
6 6
  * Add --input-service option, to choose service id (program) in MPTS input.
7
+ * When the input is MPTS and output filtering is enabled, rewrite output
8
+   PAT to include only the single program that is decoded.
7 9
  * Parse SDT and display provider and service name.
8 10
 
9 11
 2011-11-18 : Version 4.0

+ 2
- 0
data.c View File

@@ -26,6 +26,7 @@ void data_init(struct ts *ts) {
26 26
 	// Stream
27 27
 	ts->pat	     = ts_pat_alloc();
28 28
 	ts->curpat   = ts_pat_alloc();
29
+	ts->genpat   = ts_pat_alloc();
29 30
 
30 31
 	ts->cat      = ts_cat_alloc();
31 32
 	ts->curcat   = ts_cat_alloc();
@@ -100,6 +101,7 @@ void data_init(struct ts *ts) {
100 101
 void data_free(struct ts *ts) {
101 102
 	ts_pat_free(&ts->pat);
102 103
 	ts_pat_free(&ts->curpat);
104
+	ts_pat_free(&ts->genpat);
103 105
 	ts_cat_free(&ts->cat);
104 106
 	ts_cat_free(&ts->curcat);
105 107
 	ts_pmt_free(&ts->pmt);

+ 2
- 0
data.h View File

@@ -105,6 +105,8 @@ struct io {
105 105
 struct ts {
106 106
 	// Stream handling
107 107
 	struct ts_pat		*pat, *curpat;
108
+	struct ts_pat		*genpat;
109
+	uint8_t				genpat_cc;
108 110
 	struct ts_cat		*cat, *curcat;
109 111
 	struct ts_pmt		*pmt, *curpmt;
110 112
 	struct ts_sdt		*sdt, *cursdt;

+ 1
- 1
libtsfuncs

@@ -1 +1 @@
1
-Subproject commit f36a478d2d9f849ece86da566b52ded75b836864
1
+Subproject commit 968352d1ecf5270c788e8d21f520cb05c1689da5

+ 10
- 0
process.c View File

@@ -283,6 +283,16 @@ void process_packets(struct ts *ts, uint8_t *data, ssize_t data_len) {
283 283
 		if (ts->emm_only)
284 284
 			continue;
285 285
 
286
+		// Return rewritten PAT
287
+		if (pid == 0x00 && ts->pid_filter && ts->genpat->initialized) {
288
+			if (!ts_packet_is_pusi(ts_packet))
289
+				continue;
290
+			ts_packet_set_cont(ts->genpat->section_header->packet_data, ts->genpat_cc);
291
+			ts->genpat->ts_header.continuity = ts->genpat_cc;
292
+			ts_packet = ts->genpat->section_header->packet_data;
293
+			ts->genpat_cc = (ts->genpat_cc + 1) & 0x0f;
294
+		}
295
+
286 296
 		if (ts->threaded) {
287 297
 			// Add to decode buffer. The decoder thread will handle it
288 298
 			if (cbuf_fill(ts->decode_buf, ts_packet, 188) != 0) {

+ 6
- 0
tables.c View File

@@ -84,6 +84,12 @@ void process_pat(struct ts *ts, uint16_t pid, uint8_t *ts_packet) {
84 84
 	ts_LOGf("PAT | Using service 0x%04x (%d), PMT pid: %04x (%d)\n",
85 85
 		ts->service_id, ts->service_id,
86 86
 		ts->pmt_pid, ts->pmt_pid);
87
+
88
+	if (num_services > 1) {
89
+		ts_pat_clear(ts->genpat);
90
+		ts->genpat = ts_pat_init(ts->genpat, ts->pat->section_header->ts_id_number);
91
+		ts_pat_add_program(ts->genpat, ts->service_id, ts->pmt_pid);
92
+	}
87 93
 }
88 94
 
89 95
 void process_cat(struct ts *ts, uint16_t pid, uint8_t *ts_packet) {

Loading…
Cancel
Save