Browse Source

Add ts_get_ecm_info() and ts_get_emm_info()

Georgi Chorbadzhiyski 13 years ago
parent
commit
14babc9c76
2 changed files with 31 additions and 0 deletions
  1. 3
    0
      tsfuncs.h
  2. 28
    0
      tsfuncs_cat.c

+ 3
- 0
tsfuncs.h View File

117
 enum CA_system	ts_get_CA_sys		(uint16_t CA_id);
117
 enum CA_system	ts_get_CA_sys		(uint16_t CA_id);
118
 char *			ts_get_CA_sys_txt	(enum CA_system CA_sys);
118
 char *			ts_get_CA_sys_txt	(enum CA_system CA_sys);
119
 
119
 
120
+int				ts_get_emm_info		(struct ts_cat *cat, enum CA_system CA_sys, uint16_t *CA_id, uint16_t *CA_pid);
121
+int				ts_get_ecm_info		(struct ts_pmt *pmt, enum CA_system CA_sys, uint16_t *CA_id, uint16_t *CA_pid);
122
+
120
 // PMT
123
 // PMT
121
 struct ts_pmt *	ts_pmt_alloc		();
124
 struct ts_pmt *	ts_pmt_alloc		();
122
 struct ts_pmt * ts_pmt_alloc_init	(uint16_t org_network_id, uint16_t transport_stream_id);
125
 struct ts_pmt * ts_pmt_alloc_init	(uint16_t org_network_id, uint16_t transport_stream_id);

+ 28
- 0
tsfuncs_cat.c View File

209
 	}
209
 	}
210
 }
210
 }
211
 
211
 
212
+static int find_CA_descriptor(uint8_t *data, int data_len, enum CA_system req_CA_type, uint16_t *CA_id, uint16_t *CA_pid) {
213
+	while (data_len >= 2) {
214
+		uint8_t tag         = data[0];
215
+		uint8_t this_length = data[1];
216
+		data     += 2;
217
+		data_len -= 2;
218
+		if (tag == 9 && this_length == 4) {
219
+			uint16_t CA_ID = (data[0] << 8) | data[1];
220
+			uint16_t CA_PID = ((data[2] & 0x1F) << 8) | data[3];
221
+			if (ts_get_CA_sys(CA_ID) == req_CA_type) {
222
+				*CA_id = CA_ID;
223
+				*CA_pid = CA_PID;
224
+				return 1;
225
+			}
226
+		}
227
+		data_len -= this_length;
228
+		data += this_length;
229
+	}
230
+	return 0;
231
+}
232
+
233
+int ts_get_emm_info(struct ts_cat *cat, enum CA_system req_CA_type, uint16_t *CA_id, uint16_t *CA_pid) {
234
+	return find_CA_descriptor(cat->program_info, cat->program_info_size, req_CA_type, CA_id, CA_pid);
235
+}
236
+
237
+int ts_get_ecm_info(struct ts_pmt *pmt, enum CA_system req_CA_type, uint16_t *CA_id, uint16_t *CA_pid) {
238
+	return find_CA_descriptor(pmt->program_info, pmt->program_info_size, req_CA_type, CA_id, CA_pid);
239
+}

Loading…
Cancel
Save