void caclient_done(void);
void tsdebugcw_service_start(struct service *t);
-void tsdebugcw_new_keys(struct service *t, int type, uint8_t *odd, uint8_t *even);
+void tsdebugcw_new_keys(struct service *t, int type, uint16_t pid, uint8_t *odd, uint8_t *even);
void tsdebugcw_go(void);
void tsdebugcw_init(void);
}
fin:
- pthread_mutex_unlock(&t->s_stream_mutex);
#if ENABLE_TSDEBUG
if (j) {
tsdebug_packet_t *tp = malloc(sizeof(*tp));
uint16_t keylen = tk->key_csa.csa_keylen;
- uint16_t sid = ((mpegts_service_t *)td->td_service)->s_dvb_service_id;
+ mpegts_service_t *ms = (mpegts_service_t *)t;
+ uint16_t sid = ms->s_dvb_service_id;
uint32_t pos = 0, crc;
- mpegts_mux_t *mm = ((mpegts_service_t *)td->td_service)->s_dvb_mux;
- if (!mm->mm_active) {
+ mpegts_mux_t *mm = ms->s_dvb_mux;
+ mpegts_mux_instance_t *mmi = mm ? mm->mm_active : NULL;
+ mpegts_input_t *mi = mmi ? mmi->mmi_input : NULL;
+ if (mi == NULL) {
free(tp);
return;
- }
- pthread_mutex_lock(&mm->mm_active->mmi_input->mi_output_lock);
+ }
+ pthread_mutex_unlock(&t->s_stream_mutex);
+ pthread_mutex_lock(&mi->mi_output_lock);
tp->pos = mm->mm_tsdebug_pos;
memset(tp->pkt, 0xff, sizeof(tp->pkt));
tp->pkt[pos++] = 0x47; /* sync byte */
tp->pkt[pos++] = (crc >> 8) & 0xff;
tp->pkt[pos++] = crc & 0xff;
TAILQ_INSERT_HEAD(&mm->mm_tsdebug_packets, tp, link);
- pthread_mutex_unlock(&mm->mm_active->mmi_input->mi_output_lock);
+ pthread_mutex_unlock(&mi->mi_output_lock);
+ return;
}
#endif
+ pthread_mutex_unlock(&t->s_stream_mutex);
}
void
th_descrambler_t;
int tdcw_type;
+ uint16_t tdcw_pid;
uint8_t tdcw_key_even[16]; /* DES or AES key */
uint8_t tdcw_key_odd [16]; /* DES or AES key */
*
*/
void
-tsdebugcw_new_keys(service_t *t, int type, uint8_t *odd, uint8_t *even)
+tsdebugcw_new_keys(service_t *t, int type, uint16_t pid, uint8_t *odd, uint8_t *even)
{
static char empty[16] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
th_descrambler_t *td;
tsdebugcw_service_t *ct;
tsdebugcw_request_t *ctr;
- int keylen = type == DESCRAMBLER_AES ? 16 : 8;
+ int keylen = type == DESCRAMBLER_AES_ECB ? 16 : 8;
LIST_FOREACH(td, &t->s_descramblers, td_service_link)
if (td->td_stop == tsdebugcw_service_destroy)
return;
ct = (tsdebugcw_service_t *)td;
ct->tdcw_type = type;
- if (memcmp(empty, odd, keylen))
+ ct->tdcw_pid = pid;
+ if (odd && memcmp(empty, odd, keylen))
memcpy(ct->tdcw_key_odd, odd, keylen);
- if (memcmp(empty, even, keylen))
+ if (even && memcmp(empty, even, keylen))
memcpy(ct->tdcw_key_even, even, keylen);
ctr = malloc(sizeof(*ctr));
ctr->ct = ct;
pthread_mutex_unlock(&tsdebugcw_mutex);
if (!ctr) break;
ct = ctr->ct;
- descrambler_keys((th_descrambler_t *)ct, ct->tdcw_type,
+ descrambler_keys((th_descrambler_t *)ct,
+ ct->tdcw_type, ct->tdcw_pid,
ct->tdcw_key_odd, ct->tdcw_key_even);
free(ctr);
}
static void
tsdebug_check_tspkt( mpegts_mux_t *mm, uint8_t *pkt, int len )
{
- void tsdebugcw_new_keys(service_t *t, int type, uint8_t *odd, uint8_t *even);
+ void tsdebugcw_new_keys(service_t *t, int type, uint16_t pid, uint8_t *odd, uint8_t *even);
uint32_t pos, type, keylen, sid, crc;
+ uint16_t pid;
mpegts_service_t *t;
for ( ; len > 0; pkt += 188, len -= 188) {
if (t->s_dvb_service_id == sid) break;
if (!t)
return;
- pos = 4 + 24 + 4;
+ pos = 4 + 24 + 4;
tvhdebug(LS_DESCRAMBLER, "Keys from MPEG-TS source (PID 0x1FFF)!");
- tsdebugcw_new_keys((service_t *)t, type, pkt + pos, pkt + pos + keylen);
+ tsdebugcw_new_keys((service_t *)t, type, pid, pkt + pos, pkt + pos + keylen);
}
}
#endif