Browse Source

Add --caid option to choose exact CAID.

Georgi Chorbadzhiyski 12 years ago
parent
commit
7419a19581
5 changed files with 50 additions and 11 deletions
  1. 1
    0
      data.h
  2. 1
    1
      libtsfuncs
  3. 20
    6
      tables.c
  4. 8
    1
      tsdecrypt.1
  5. 20
    3
      tsdecrypt.c

+ 1
- 0
data.h View File

@@ -97,6 +97,7 @@ struct ts {
97 97
 	uint16_t			service_id;
98 98
 	uint16_t			emm_caid, emm_pid;
99 99
 	uint16_t			ecm_caid, ecm_pid;
100
+	uint16_t			forced_caid;
100 101
 	uint16_t			forced_emm_pid;
101 102
 	uint16_t			forced_ecm_pid;
102 103
 	uint16_t			ecm_counter;

+ 1
- 1
libtsfuncs

@@ -1 +1 @@
1
-Subproject commit d9734150a39af5019cb8cef21f3efea914222575
1
+Subproject commit e9ba8bcf8f26ad1b2242f434f293faa22fd290e5

+ 20
- 6
tables.c View File

@@ -65,9 +65,16 @@ void process_cat(struct ts *ts, uint16_t pid, uint8_t *ts_packet) {
65 65
 
66 66
 	handle_table_changes(cat);
67 67
 
68
-	ts_get_emm_info(ts->cat, ts->req_CA_sys, &ts->emm_caid, &ts->emm_pid);
69
-	if (!ts->emm_caid && ts->forced_emm_pid)
70
-		ts->emm_caid = 0xffff;
68
+	if (ts->forced_caid) {
69
+		ts->emm_caid = ts->forced_caid;
70
+		ts_get_emm_info_by_caid(ts->cat, ts->emm_caid, &ts->emm_pid);
71
+	} else {
72
+		ts_get_emm_info(ts->cat, ts->req_CA_sys, &ts->emm_caid, &ts->emm_pid);
73
+	}
74
+
75
+	if (ts->forced_emm_pid)
76
+		ts_get_emm_info_by_pid(ts->cat, &ts->emm_caid, ts->forced_emm_pid);
77
+
71 78
 	if (ts->emm_caid) {
72 79
 		char *CA_sys = ts_get_CA_sys_txt(ts_get_CA_sys(ts->emm_caid));
73 80
 		ts_LOGf("--- | EMM CAID: 0x%04x (%s)\n", ts->emm_caid, CA_sys);
@@ -100,9 +107,16 @@ void process_pmt(struct ts *ts, uint16_t pid, uint8_t *ts_packet) {
100 107
 		pidmap_set(&ts->pidmap, stream->pid); // Data
101 108
 	}
102 109
 
103
-	ts_get_ecm_info(ts->pmt, ts->req_CA_sys, &ts->ecm_caid, &ts->ecm_pid);
104
-	if (!ts->ecm_caid && ts->forced_ecm_pid)
105
-		ts->ecm_caid = 0xffff;
110
+	if (ts->forced_caid) {
111
+		ts->ecm_caid = ts->forced_caid;
112
+		ts_get_ecm_info_by_caid(ts->pmt, ts->ecm_caid, &ts->ecm_pid);
113
+	} else {
114
+		ts_get_ecm_info(ts->pmt, ts->req_CA_sys, &ts->ecm_caid, &ts->ecm_pid);
115
+	}
116
+
117
+	if (ts->forced_ecm_pid)
118
+		ts_get_ecm_info_by_pid(ts->pmt, &ts->ecm_caid, ts->forced_ecm_pid);
119
+
106 120
 	if (ts->ecm_caid) {
107 121
 		char *CA_sys = ts_get_CA_sys_txt(ts_get_CA_sys(ts->ecm_caid));
108 122
 		ts_LOGf("--- | ECM CAID: 0x%04x (%s)\n", ts->ecm_caid, CA_sys);

+ 8
- 1
tsdecrypt.1 View File

@@ -70,7 +70,7 @@ Enable output filtering. When output filter is enabled only PAT/PMT/SDT
70 70
 and data packets are left in the output. Everything else not mentioned
71 71
 in PMT like NIT, EIT, TDT tables and unknown pids is removed.
72 72
 .TP
73
-.SH CAMD OPTIONS
73
+.SH CA OPTIONS
74 74
 .PP
75 75
 .TP
76 76
 \fB\-c\fR, \fB\-\-ca\-system\fR <ca_sys>
@@ -81,6 +81,13 @@ probably working) are \fBSECA\fR (\fBMEDIAGUARD\fR), \fBVIDEOGUARD\fR
81 81
 (\fBNDS\fR), \fBNAGRA\fR and \fBDRECRYPT\fR. The default <ca_sys>
82 82
 is \fBCONAX\fR.
83 83
 .TP
84
+\fB\-C\fR, \fB\-\-caid\fR <caid>
85
+Directly set CAID. This is useful if you have couple of CA streams from
86
+one CA but with different CAIDs.
87
+.TP
88
+.SH CAMD OPTIONS
89
+.PP
90
+.TP
84 91
 \fB\-s\fR, \fB\-\-camd\-server\fR <addr[:port]>
85 92
 Set CAMD server ip and port (10.0.1.1:2233). Is not set default port is
86 93
 \fB2233\fR. tsdecrypt is tested and working with OSCAM using cs378x protocol

+ 20
- 3
tsdecrypt.c View File

@@ -64,6 +64,7 @@ static const struct option long_options[] = {
64 64
 	{ "output-filter",		no_argument,       NULL, 'p' },
65 65
 
66 66
 	{ "ca-system",			required_argument, NULL, 'c' },
67
+	{ "caid",				required_argument, NULL, 'C' },
67 68
 	{ "camd-server",		required_argument, NULL, 's' },
68 69
 	{ "camd-user",			required_argument, NULL, 'U' },
69 70
 	{ "camd-pass",			required_argument, NULL, 'P' },
@@ -115,11 +116,14 @@ static void show_help(struct ts *ts) {
115 116
 	printf(" -t --output-ttl <ttl>      | Set multicast ttl. Default: %d\n", ts->output.ttl);
116 117
 	printf(" -p --output-filter         | Enable or disable output filter. Default: %s\n", ts->pid_filter ? "enabled" : "disabled");
117 118
 	printf("\n");
118
-	printf("CAMD server options:\n");
119
+	printf("CA options:\n");
119 120
 	printf(" -c --ca-system <ca_sys>    | Process input EMM/ECM from <ca_sys>.\n");
120 121
 	printf("                            | Valid systems are: CONAX (default), CRYPTOWORKS,\n");
121 122
 	printf("                            .   IRDETO, SECA (MEDIAGUARD), VIACCESS,\n");
122 123
 	printf("                            .   VIDEOGUARD (NDS), NAGRA and DRECRYPT.\n");
124
+	printf(" -C --caid <caid>           | Set CAID. Default: Taken from --ca-system.\n");
125
+	printf("\n");
126
+	printf("CAMD server options:\n");
123 127
 	printf(" -s --camd-server <addr>    | Set CAMD server ip address and port (1.2.3.4:2233).\n");
124 128
 	printf(" -U --camd-user <user>      | Set CAMD server user. Default: %s\n", ts->camd35.user);
125 129
 	printf(" -P --camd-pass <pass>      | Set CAMD server password. Default: %s\n", ts->camd35.pass);
@@ -181,7 +185,7 @@ static int parse_io_param(struct io *io, char *opt, int open_flags, mode_t open_
181 185
 
182 186
 static void parse_options(struct ts *ts, int argc, char **argv) {
183 187
 	int j, i, ca_err = 0, server_err = 1, input_addr_err = 0, output_addr_err = 0, output_intf_err = 0, ident_err = 0;
184
-	while ( (j = getopt_long(argc, argv, "i:d:l:L:I:RzO:o:t:pc:s:U:P:y:eZ:Ef:X:G:KJ:D:h", long_options, NULL)) != -1 ) {
188
+	while ( (j = getopt_long(argc, argv, "i:d:l:L:I:RzO:o:t:pc:C:s:U:P:y:eZ:Ef:X:G:KJ:D:h", long_options, NULL)) != -1 ) {
185 189
 		char *p = NULL;
186 190
 		switch (j) {
187 191
 			case 'i':
@@ -249,6 +253,10 @@ static void parse_options(struct ts *ts, int argc, char **argv) {
249 253
 				else
250 254
 					ca_err = 1;
251 255
 				break;
256
+			case 'C':
257
+				ts->forced_caid = strtoul(optarg, NULL, 0) & 0xffff;
258
+				break;
259
+
252 260
 			case 's':
253 261
 				p = strrchr(optarg, ':');
254 262
 				if (p) {
@@ -349,7 +357,16 @@ static void parse_options(struct ts *ts, int argc, char **argv) {
349 357
 		ts_LOGf("Syslog     : %s:%d\n", ts->syslog_host, ts->syslog_port);
350 358
 	else
351 359
 		ts_LOGf("Syslog     : disabled\n");
352
-	ts_LOGf("CA System  : %s\n", ts_get_CA_sys_txt(ts->req_CA_sys));
360
+
361
+	if (ts->forced_caid)
362
+		ts->req_CA_sys = ts_get_CA_sys(ts->forced_caid);
363
+	if (!ts->forced_caid)
364
+		ts_LOGf("CA System  : %s\n", ts_get_CA_sys_txt(ts->req_CA_sys));
365
+	else
366
+		ts_LOGf("CA System  : %s | CAID: 0x%04x (%d)\n",
367
+			ts_get_CA_sys_txt(ts->req_CA_sys),
368
+			ts->forced_caid, ts->forced_caid);
369
+
353 370
 	if (ts->input.type == NET_IO) {
354 371
 		ts_LOGf("Input addr : %s://%s:%u/\n",
355 372
 			ts->rtp_input ? "rtp" : "udp",

Loading…
Cancel
Save