Browse Source

Show more timing information.

Anton Tinchev 12 years ago
parent
commit
c6f5c1c4d4
4 changed files with 28 additions and 3 deletions
  1. 5
    3
      camd.c
  2. 1
    0
      data.h
  3. 14
    0
      process.c
  4. 8
    0
      tables.c

+ 5
- 3
camd.c View File

@@ -116,10 +116,12 @@ static int camd_recv_cw(struct ts *ts) {
116 116
 	}
117 117
 
118 118
 	if (ts->ecm_cw_log) {
119
-		ts_LOGf("CW  | CAID: 0x%04x [ %5llu ms ] ( %6llu ms ) ------ IDX: 0x%04x Data: %s\n",
120
-			ca_id, timeval_diff_msec(&tv1, &tv2),
119
+		ts_LOGf("CW  | SID 0x%04x CAID: 0x%04x CW_recv: %5llu ms LastKey: %5llu ms Data: %s\n",
120
+			ts->service_id,
121
+			ca_id,
122
+			timeval_diff_msec(&tv1, &tv2),
121 123
 			timeval_diff_msec(&last_ts_keyset, &tv2),
122
-			idx, cw_dump );
124
+			cw_dump );
123 125
 	}
124 126
 
125 127
 	return 1;

+ 1
- 0
data.h View File

@@ -220,6 +220,7 @@ struct ts {
220 220
 	unsigned int		cw_warn_sec;
221 221
 	time_t				cw_last_warn;
222 222
 	time_t				cw_next_warn;
223
+	struct timeval		ecm_change_time;
223 224
 
224 225
 	unsigned int		pid_report;
225 226
 	unsigned int		pid_stats[MAX_PIDS];

+ 14
- 0
process.c View File

@@ -124,6 +124,8 @@ static void decode_buffer(struct ts *ts, uint8_t *data, int data_len) {
124 124
 	struct dvbcsa_bs_batch_s even_pcks[batch_sz + 1];
125 125
 	struct dvbcsa_bs_batch_s odd_pcks [batch_sz + 1];
126 126
 
127
+	int scramble_idx_old = 0;
128
+
127 129
 	// Prepare batch structure
128 130
 	for (i = 0; i < batch_sz; i++) {
129 131
 		uint8_t *ts_packet = data + (i * 188);
@@ -132,6 +134,8 @@ static void decode_buffer(struct ts *ts, uint8_t *data, int data_len) {
132 134
 		if (pidmap_get(&ts->pidmap, pid) && ts_packet_is_scrambled(ts_packet)) {
133 135
 			if (ts->key.is_valid_cw) {
134 136
 				int scramble_idx = ts_packet_get_scrambled(ts_packet);
137
+				if (!scramble_idx_old)
138
+					scramble_idx_old = scramble_idx;
135 139
 				uint8_t payload_ofs = ts_packet_get_payload_offset(ts_packet);
136 140
 				if (scramble_idx == 2) { // scramble_idx 2 == even key
137 141
 					even_pcks[even_packets].data = ts_packet + payload_ofs;
@@ -144,6 +148,15 @@ static void decode_buffer(struct ts *ts, uint8_t *data, int data_len) {
144 148
 					odd_packets++;
145 149
 				}
146 150
 				ts_packet_set_not_scrambled(ts_packet);
151
+				if (scramble_idx_old != scramble_idx) {
152
+					struct timeval tv;
153
+					gettimeofday(&tv, NULL);
154
+					ts_LOGf("CWC | SID 0x%04x ------------ EcmTime: %5llu ms CW_time: %5llu ms\n",
155
+						ts->service_id,
156
+						timeval_diff_msec(&ts->ecm_change_time, &tv),
157
+						timeval_diff_msec(&ts->key.ts_keyset, &tv));
158
+				}
159
+				scramble_idx_old = scramble_idx;
147 160
 			} else {
148 161
 				if (ts->pid_filter)
149 162
 					ts_packet_set_pid(ts_packet, 0x1fff);
@@ -307,6 +320,7 @@ void process_packets(struct ts *ts, uint8_t *data, ssize_t data_len) {
307 320
 		if (ts->pid_report)
308 321
 			ts->pid_stats[pid]++;
309 322
 
323
+
310 324
 		ts_pack_shown = 0;
311 325
 
312 326
 		process_pat(ts, pid, ts_packet);

+ 8
- 0
tables.c View File

@@ -307,8 +307,15 @@ static void __process_ecm(struct ts *ts, uint16_t pid, uint8_t *ts_packet) {
307 307
 	int duplicate = ts_privsec_is_same(ts->ecm, ts->last_ecm);
308 308
 	if (duplicate && !ts->is_cw_error)
309 309
 		ts->ecm_duplicate_count++;
310
+	if (!ts->ecm_change_time.tv_sec)
311
+		gettimeofday(&ts->ecm_change_time, NULL);
310 312
 	if (!duplicate || ts->is_cw_error) {
311 313
 		if (ts->ecm_cw_log) {
314
+			struct timeval tv;
315
+			gettimeofday(&tv, NULL);
316
+			ts_LOGf("ECC | SID 0x%04x ------------ EcmChng: %5llu ms\n",
317
+				ts->service_id,
318
+				timeval_diff_msec(&ts->ecm_change_time, &tv));
312 319
 			ts_hex_dump_buf(dump, dump_buf_sz, sec->section_data, min(dump_sz, sec->section_data_len), 0);
313 320
 			ts_LOGf("ECM | SID 0x%04x CAID: 0x%04x PID 0x%04x Table: 0x%02x Length: %4d Data: %s..\n",
314 321
 				ts->service_id,
@@ -317,6 +324,7 @@ static void __process_ecm(struct ts *ts, uint16_t pid, uint8_t *ts_packet) {
317 324
 				sec->table_id,
318 325
 				sec->section_data_len,
319 326
 				dump);
327
+			gettimeofday(&ts->ecm_change_time, NULL);
320 328
 		}
321 329
 		ts->is_cw_error = 0;
322 330
 		camd_process_packet(ts, camd_msg_alloc(ECM_MSG, ts->ecm_caid, ts->service_id, sec->section_data, sec->section_data_len));

Loading…
Cancel
Save