Browse Source

Add CA system definitions

Georgi Chorbadzhiyski 8 years ago
parent
commit
79a16579f3
4 changed files with 32 additions and 3 deletions
  1. 7 0
      tsdata.h
  2. 3 0
      tsfuncs.h
  3. 18 0
      tsfuncs_cat.c
  4. 4 3
      tsfuncs_descriptors.c

+ 7 - 0
tsdata.h View File

@@ -223,6 +223,13 @@ struct ts_pat {
223 223
 	uint8_t						initialized;	// Set to 1 when full table is initialized
224 224
 };
225 225
 
226
+enum CA_system {
227
+	CA_IRDETO,		// 0x0600 - 0x06FF Irdeto
228
+	CA_CONNAX,		// 0x0B00 - 0x0BFF Norwegian Telekom
229
+	CA_CRYPTOWORKS,	// 0x0D00 - 0x0DFF CrytoWorks
230
+	CA_UNKNOWN,
231
+};
232
+
226 233
 struct ts_cat {
227 234
 	struct ts_header			ts_header;
228 235
 	struct ts_section_header	*section_header;

+ 3 - 0
tsfuncs.h View File

@@ -114,6 +114,9 @@ int				ts_cat_parse		(struct ts_cat *cat);
114 114
 void            ts_cat_dump			(struct ts_cat *cat);
115 115
 int				ts_cat_is_same		(struct ts_cat *cat1, struct ts_cat *cat2);
116 116
 
117
+enum CA_system	ts_get_CA_sys		(uint16_t CA_id);
118
+char *			ts_get_CA_sys_txt	(enum CA_system CA_sys);
119
+
117 120
 // PMT
118 121
 struct ts_pmt *	ts_pmt_alloc		();
119 122
 struct ts_pmt * ts_pmt_alloc_init	(uint16_t org_network_id, uint16_t transport_stream_id);

+ 18 - 0
tsfuncs_cat.c View File

@@ -191,3 +191,21 @@ int ts_cat_is_same(struct ts_cat *cat1, struct ts_cat *cat2) {
191 191
 
192 192
 	return 1; // Same
193 193
 }
194
+
195
+enum CA_system ts_get_CA_sys(uint16_t CA_id) {
196
+	if (CA_id >= 0x0600 && CA_id <= 0x06FF) return CA_IRDETO;
197
+	if (CA_id >= 0x0B00 && CA_id <= 0x0BFF) return CA_CONNAX;
198
+	if (CA_id >= 0x0D00 && CA_id <= 0x0DFF) return CA_CRYPTOWORKS;
199
+	return CA_UNKNOWN;
200
+}
201
+
202
+char * ts_get_CA_sys_txt(enum CA_system CA_sys) {
203
+	switch (CA_sys) {
204
+		case CA_IRDETO:			return "IRDETO CA";
205
+		case CA_CONNAX:			return "CONNAX CA";
206
+		case CA_CRYPTOWORKS:	return "CRYPTOWORKS CA";
207
+		case CA_UNKNOWN:
208
+		default:				return "UNKNOWN CA";
209
+	}
210
+}
211
+

+ 4 - 3
tsfuncs_descriptors.c View File

@@ -176,12 +176,13 @@ void ts_descriptor_dump(uint8_t *desc_data, int desc_data_len) {
176 176
 			case  9: { // CA descriptor
177 177
 				uint16_t CA_ID = (data[0] << 8) | data[1];
178 178
 				uint16_t CA_PID = ((data[2] & 0x1F) << 8) | data[3];
179
-				ts_LOGf("%sTag 0x%02x (%02d), sz: %d, CA descriptor: CAID 0x%04x (%02d) | CA PID 0x%04x (%d)\n",
180
-					pad,
179
+				ts_LOGf("Tag 0x%02x (%02d), sz: %d, CA descriptor: CAID 0x%04x (%02d) | CA PID 0x%04x (%d) | %s\n",
181 180
 					tag, tag,
182 181
 					this_length,
183 182
 					CA_ID, CA_ID,
184
-					CA_PID, CA_PID);
183
+					CA_PID, CA_PID,
184
+					ts_get_CA_sys_txt(ts_get_CA_sys(CA_ID))
185
+				);
185 186
 				break;
186 187
 			}
187 188
 			case 10: { // We'll assume the length is a multiple of 4