Browse Source

Fix for MPTS streams.

Without this if the input is MPTS, tsdecrypt incorrectly tries to
decrypt (and brokes) services that do not belong to the chosen
input services. An additional extra is that with this decrypting
a service in MPTS is a lot quicker since lots of unneeded work is
avoided.
Francesco Schiavarelli 12 years ago
parent
commit
f5667e75fb
1 changed files with 7 additions and 4 deletions
  1. 7
    4
      process.c

+ 7
- 4
process.c View File

@@ -128,9 +128,10 @@ static void decode_buffer(struct ts *ts, uint8_t *data, int data_len) {
128 128
 	for (i = 0; i < batch_sz; i++) {
129 129
 		uint8_t *ts_packet = data + (i * 188);
130 130
 
131
-		int scramble_idx = ts_packet_get_scrambled(ts_packet);
132
-		if (scramble_idx > 1) {
131
+		uint16_t pid = ts_packet_get_pid(ts_packet);
132
+		if (pidmap_get(&ts->pidmap, pid) && ts_packet_is_scrambled(ts_packet)) {
133 133
 			if (ts->key.is_valid_cw) {
134
+				int scramble_idx = ts_packet_get_scrambled(ts_packet);
134 135
 				uint8_t payload_ofs = ts_packet_get_payload_offset(ts_packet);
135 136
 				if (scramble_idx == 2) { // scramble_idx 2 == even key
136 137
 					even_pcks[even_packets].data = ts_packet + payload_ofs;
@@ -366,9 +367,11 @@ void process_packets(struct ts *ts, uint8_t *data, ssize_t data_len) {
366 367
 				}
367 368
 			}
368 369
 		} else {
369
-			decode_packet(ts, ts_packet);
370
+			int allowed_pid = pidmap_get(&ts->pidmap, pid);
371
+			if (allowed_pid) // PAT or allowed PIDs
372
+				decode_packet(ts, ts_packet);
370 373
 			if (ts->pid_filter) {
371
-				if (pidmap_get(&ts->pidmap, pid)) // PAT or allowed PIDs
374
+				if (allowed_pid) // PAT or allowed PIDs
372 375
 					output_write(ts, ts_packet, 188);
373 376
 			} else {
374 377
 				output_write(ts, ts_packet, 188);

Loading…
Cancel
Save