From: Jaroslav Kysela Date: Tue, 30 May 2017 11:53:02 +0000 (+0200) Subject: tsdebug: fix compilation X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=9340aa258ac54774e112704ccb3ee727ed7fd0a8;p=thirdparty%2Ftvheadend.git tsdebug: fix compilation --- diff --git a/src/descrambler/caclient.h b/src/descrambler/caclient.h index d7db76512..b02c6349d 100644 --- a/src/descrambler/caclient.h +++ b/src/descrambler/caclient.h @@ -78,7 +78,7 @@ void caclient_init(void); 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); diff --git a/src/descrambler/descrambler.c b/src/descrambler/descrambler.c index 24dcec586..5c35aeb41 100644 --- a/src/descrambler/descrambler.c +++ b/src/descrambler/descrambler.c @@ -619,19 +619,22 @@ descrambler_keys ( th_descrambler_t *td, int type, uint16_t pid, } 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 */ @@ -655,9 +658,11 @@ fin: 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 diff --git a/src/descrambler/tsdebugcw.c b/src/descrambler/tsdebugcw.c index c50230f5b..b42449ac1 100644 --- a/src/descrambler/tsdebugcw.c +++ b/src/descrambler/tsdebugcw.c @@ -29,6 +29,7 @@ typedef struct tsdebugcw_service { 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 */ @@ -109,13 +110,13 @@ tsdebugcw_service_start(service_t *t) * */ 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) @@ -124,9 +125,10 @@ tsdebugcw_new_keys(service_t *t, int type, uint8_t *odd, uint8_t *even) 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; @@ -152,7 +154,8 @@ tsdebugcw_go(void) 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); } diff --git a/src/input/mpegts/mpegts_input.c b/src/input/mpegts/mpegts_input.c index e432f36b0..fff35f4f2 100644 --- a/src/input/mpegts/mpegts_input.c +++ b/src/input/mpegts/mpegts_input.c @@ -1278,8 +1278,9 @@ mpegts_input_table_waiting ( mpegts_input_t *mi, mpegts_mux_t *mm ) 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) { @@ -1301,9 +1302,9 @@ tsdebug_check_tspkt( mpegts_mux_t *mm, uint8_t *pkt, int len ) 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