Browse Source

Add --service option, to choose service id (program) in MPTS input.

Georgi Chorbadzhiyski 12 years ago
parent
commit
721a9b5040
5 changed files with 50 additions and 5 deletions
  1. 3
    0
      ChangeLog
  2. 1
    0
      data.h
  3. 31
    4
      tables.c
  4. 6
    0
      tsdecrypt.1
  5. 9
    1
      tsdecrypt.c

+ 3
- 0
ChangeLog View File

@@ -1,3 +1,6 @@
1
+xxxx-xx-xx : Version next
2
+ * Add --service option, to choose service id (program) in MPTS input.
3
+
1 4
 2011-11-18 : Version 4.0
2 5
  * Set CAMD sockets NODELAY to avoid OSCAM errors when many packets are sent.
3 6
  * Add --syslog parameter to enable local syslog logging.

+ 1
- 0
data.h View File

@@ -113,6 +113,7 @@ struct ts {
113 113
 	struct ts_privsec	*tmp_ecm;
114 114
 	uint16_t			pmt_pid;
115 115
 	uint16_t			service_id;
116
+	uint16_t			forced_service_id;
116 117
 	uint16_t			emm_caid, emm_pid;
117 118
 	uint16_t			ecm_caid, ecm_pid;
118 119
 	uint16_t			forced_caid;

+ 31
- 4
tables.c View File

@@ -43,6 +43,8 @@ extern void show_ts_pack(struct ts *ts, uint16_t pid, char *wtf, char *extra, ui
43 43
 
44 44
 void process_pat(struct ts *ts, uint16_t pid, uint8_t *ts_packet) {
45 45
 	int i;
46
+	int num_services = 0;
47
+	uint16_t f_service = 0, f_pid = 0;
46 48
 	if (pid != 0x00)
47 49
 		return;
48 50
 
@@ -50,13 +52,38 @@ void process_pat(struct ts *ts, uint16_t pid, uint8_t *ts_packet) {
50 52
 
51 53
 	for (i=0;i<ts->pat->programs_num;i++) {
52 54
 		struct ts_pat_program *prg = ts->pat->programs[i];
53
-		if (prg->pid) {
54
-			if (prg->program != 0) {
55
-				ts->pmt_pid    = prg->pid;
56
-				ts->service_id = prg->program;
55
+		if (prg->pid && prg->program != 0) {
56
+			num_services++;
57
+			ts->pmt_pid    = prg->pid;
58
+			ts->service_id = prg->program;
59
+			if (prg->program == ts->forced_service_id) {
60
+				f_pid     = prg->pid;
61
+				f_service = prg->program;
57 62
 			}
58 63
 		}
59 64
 	}
65
+
66
+	if (f_service && f_pid) {
67
+		ts->pmt_pid    = f_pid;
68
+		ts->service_id = f_service;
69
+	}
70
+
71
+	if (num_services > 1 && !f_service) {
72
+		ts_LOGf("PAT | %d services exists. Consider using --service parameter.\n",
73
+			num_services);
74
+		for (i = 0; i < ts->pat->programs_num; i++) {
75
+			struct ts_pat_program *prg = ts->pat->programs[i];
76
+			if (prg->pid && prg->program != 0) {
77
+				ts_LOGf("PAT | Service 0x%04x (%5d) with PMT PID %04x (%d)\n",
78
+					prg->program, prg->program,
79
+					prg->pid, prg->pid);
80
+			}
81
+		}
82
+	}
83
+
84
+	ts_LOGf("PAT | Using service 0x%04x (%d), PMT pid: %04x (%d)\n",
85
+		ts->service_id, ts->service_id,
86
+		ts->pmt_pid, ts->pmt_pid);
60 87
 }
61 88
 
62 89
 void process_cat(struct ts *ts, uint16_t pid, uint8_t *ts_packet) {

+ 6
- 0
tsdecrypt.1 View File

@@ -68,6 +68,12 @@ stream over UDP multicast.
68 68
 \fB\-z\fR, \fB\-\-input\-ignore\-disc\fR
69 69
 Do not report input discontinuity or RTP discontinuity errors.
70 70
 .TP
71
+\fB\-M\fR, \fB\-\-service\fR <service_id>
72
+Choose the service id. This option must be used when the input is MPTS
73
+in order to select the correct service (program). If the input is MPTS
74
+and \fB\-\-service\fR is not used, tsdecrypt chooses the last service
75
+listed in PAT.
76
+.TP
71 77
 .SH OUTPUT OPTIONS
72 78
 .PP
73 79
 .TP

+ 9
- 1
tsdecrypt.c View File

@@ -65,6 +65,7 @@ static const struct option long_options[] = {
65 65
 	{ "input",				required_argument, NULL, 'I' },
66 66
 	{ "input-rtp",			no_argument,       NULL, 'R' },
67 67
 	{ "input-ignore-disc",	no_argument,       NULL, 'z' },
68
+	{ "service",			required_argument, NULL, 'M' },
68 69
 
69 70
 	{ "output",				required_argument, NULL, 'O' },
70 71
 	{ "output-intf",		required_argument, NULL, 'o' },
@@ -118,6 +119,7 @@ static void show_help(struct ts *ts) {
118 119
 	printf("                            .    -I -              (read from stdin) (default)\n");
119 120
 	printf(" -R --input-rtp             | Enable RTP input\n");
120 121
 	printf(" -z --input-ignore-disc     | Do not report discontinuty errors in input.\n");
122
+	printf(" -M --service <service_id>  | Choose service id when input is MPTS.\n");
121 123
 	printf("\n");
122 124
 	printf("Output options:\n");
123 125
 	printf(" -O --output <dest>         | Where to send output. File or multicast address.\n");
@@ -199,7 +201,7 @@ static int parse_io_param(struct io *io, char *opt, int open_flags, mode_t open_
199 201
 
200 202
 static void parse_options(struct ts *ts, int argc, char **argv) {
201 203
 	int j, i, ca_err = 0, server_err = 1, input_addr_err = 0, output_addr_err = 0, output_intf_err = 0, ident_err = 0;
202
-	while ( (j = getopt_long(argc, argv, "i:d:N:l:L:I:RzO:o:t:pc:C:s:U:P:y:eZ:Ef:X:H:G:KJ:D:hV", long_options, NULL)) != -1 ) {
204
+	while ( (j = getopt_long(argc, argv, "i:d:N:l:L:I:RzM:O:o:t:pc:C:s:U:P:y:eZ:Ef:X:H:G:KJ:D:hV", long_options, NULL)) != -1 ) {
203 205
 		char *p = NULL;
204 206
 		switch (j) {
205 207
 			case 'i':
@@ -239,6 +241,9 @@ static void parse_options(struct ts *ts, int argc, char **argv) {
239 241
 			case 'z':
240 242
 				ts->ts_discont = !ts->ts_discont;
241 243
 				break;
244
+			case 'M':
245
+				ts->forced_service_id = strtoul(optarg, NULL, 0) & 0xffff;
246
+				break;
242 247
 
243 248
 			case 'O':
244 249
 				output_addr_err = parse_io_param(&ts->output, optarg,
@@ -404,6 +409,9 @@ static void parse_options(struct ts *ts, int argc, char **argv) {
404 409
 	} else if (ts->input.type == FILE_IO) {
405 410
 		ts_LOGf("Input file : %s\n", ts->input.fd == 0 ? "STDIN" : ts->input.fname);
406 411
 	}
412
+	if (ts->forced_service_id)
413
+		ts_LOGf("Service id : 0x%04x (%d)\n",
414
+			ts->forced_service_id, ts->forced_service_id);
407 415
 	if (ts->req_CA_sys == CA_IRDETO)
408 416
 		ts_LOGf("Irdeto ECM : %d\n", ts->irdeto_ecm);
409 417
 

Loading…
Cancel
Save