Merge remote-tracking branch 'origin/pr/251'
This commit is contained in:
commit
ea37cc3aba
1 changed files with 18 additions and 31 deletions
49
src/cwc.c
49
src/cwc.c
|
@ -1,6 +1,6 @@
|
|||
/*
|
||||
* tvheadend, CWC interface
|
||||
* Copyright (C) 2007 Andreas Öman
|
||||
* Copyright (C) 2007 Andreas Öman
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
|
@ -774,15 +774,10 @@ handle_ecm_reply(cwc_service_t *ct, ecm_section_t *es, uint8_t *msg,
|
|||
char chaninfo[32];
|
||||
int i;
|
||||
int64_t delay = (getmonoclock() - es->es_time) / 1000LL; // in ms
|
||||
|
||||
if(es->es_channel != -1) {
|
||||
snprintf(chaninfo, sizeof(chaninfo), " (channel %d)", es->es_channel);
|
||||
} else {
|
||||
chaninfo[0] = 0;
|
||||
}
|
||||
|
||||
es->es_pending = 0;
|
||||
|
||||
snprintf(chaninfo, sizeof(chaninfo), " (PID %d)", es->es_channel);
|
||||
|
||||
if(len < 19) {
|
||||
|
||||
/* ERROR */
|
||||
|
@ -835,14 +830,19 @@ forbid:
|
|||
"Req delay: %"PRId64" ms)",
|
||||
t->s_svcname, seq, delay);
|
||||
ct->cs_keystate = CS_FORBIDDEN;
|
||||
|
||||
/* reset prefcapid if descrambling fails */
|
||||
t->s_prefcapid = 0;
|
||||
service_request_save(t, 0);
|
||||
|
||||
return;
|
||||
|
||||
} else {
|
||||
|
||||
ct->cs_okchannel = es->es_channel;
|
||||
tvhlog(LOG_DEBUG, "cwc", "es->es_nok %d t->tht_prefcapid %d", es->es_nok, t->s_prefcapid);
|
||||
if(es->es_nok == 1 || t->s_prefcapid == 0) {
|
||||
t->s_prefcapid = ct->cs_okchannel;
|
||||
tvhlog(LOG_DEBUG, "cwc", "Saving prefered PID %d", t->s_prefcapid);
|
||||
service_request_save(t, 0);
|
||||
}
|
||||
es->es_nok = 0;
|
||||
|
@ -892,7 +892,7 @@ forbid:
|
|||
for(i = 0; i < 256; i++)
|
||||
free(ep->ep_sections[i]);
|
||||
LIST_REMOVE(ep, ep_link);
|
||||
tvhlog(LOG_WARNING, "cwc", "Delete ECMpid %d", ep->ep_pid);
|
||||
tvhlog(LOG_WARNING, "cwc", "Delete ECM (PID %d) for service \"%s\"", ep->ep_pid, t->s_svcname);
|
||||
free(ep);
|
||||
ep = epn;
|
||||
}
|
||||
|
@ -1632,30 +1632,22 @@ cwc_table_input(struct th_descrambler *td, struct service *t,
|
|||
if (ct->cs_okchannel == -2) {
|
||||
t->s_prefcapid = 0;
|
||||
ct->cs_okchannel = -1;
|
||||
tvhlog(LOG_DEBUG, "cwc", "Insert after unexpected reply");
|
||||
tvhlog(LOG_DEBUG, "cwc", "Reset after unexpected reply for service \"%s\"", t->s_svcname);
|
||||
}
|
||||
|
||||
if (ct->cs_okchannel == -3 && t->s_prefcapid != 0) {
|
||||
if (t->s_prefcapid == st->es_pid) {
|
||||
ep = calloc(1, sizeof(ecm_pid_t));
|
||||
ep->ep_pid = t->s_prefcapid;
|
||||
LIST_INSERT_HEAD(&ct->cs_pids, ep, ep_link);
|
||||
tvhlog(LOG_DEBUG, "cwc", "Insert only one new ECM channel %d for service id %d", t->s_prefcapid, sid);
|
||||
} else {
|
||||
// check if prefcapid wrong
|
||||
struct elementary_stream *prefca = service_stream_find(t, t->s_prefcapid);
|
||||
|
||||
if (!prefca || prefca->es_type != SCT_CA) {
|
||||
t->s_prefcapid = 0;
|
||||
}
|
||||
}
|
||||
tvhlog(LOG_DEBUG, "cwc", "Insert prefered ECM (PID %d) for service \"%s\"", t->s_prefcapid, t->s_svcname);
|
||||
ct->cs_okchannel = -4;
|
||||
}
|
||||
|
||||
if (ct->cs_okchannel == -1 || (ct->cs_okchannel == -3 && t->s_prefcapid == 0)) {
|
||||
ep = calloc(1, sizeof(ecm_pid_t));
|
||||
ep->ep_pid = st->es_pid;
|
||||
LIST_INSERT_HEAD(&ct->cs_pids, ep, ep_link);
|
||||
tvhlog(LOG_DEBUG, "cwc", "Insert new ECM channel %d", st->es_pid);
|
||||
tvhlog(LOG_DEBUG, "cwc", "Insert new ECM (PID %d) for service \"%s\"", st->es_pid, t->s_svcname);
|
||||
}
|
||||
else {
|
||||
return;
|
||||
|
@ -1680,19 +1672,15 @@ cwc_table_input(struct th_descrambler *td, struct service *t,
|
|||
/* ECM */
|
||||
|
||||
if(cwc->cwc_caid >> 8 == 6) {
|
||||
channel = data[6] << 8 | data[7];
|
||||
snprintf(chaninfo, sizeof(chaninfo), " (channel %d)", channel);
|
||||
ep->ep_last_section = data[5];
|
||||
section = data[4];
|
||||
} else {
|
||||
channel = -1;
|
||||
chaninfo[0] = 0;
|
||||
ep->ep_last_section = 0;
|
||||
section = 0;
|
||||
}
|
||||
|
||||
channel = st->es_pid;
|
||||
snprintf(chaninfo, sizeof(chaninfo), " (channel %d)", channel);
|
||||
snprintf(chaninfo, sizeof(chaninfo), " (PID %d)", channel);
|
||||
|
||||
if(ep->ep_sections[section] == NULL)
|
||||
ep->ep_sections[section] = calloc(1, sizeof(ecm_section_t));
|
||||
|
@ -1720,16 +1708,15 @@ cwc_table_input(struct th_descrambler *td, struct service *t,
|
|||
|
||||
if(ct->cs_okchannel >= 0 && channel != -1 &&
|
||||
ct->cs_okchannel != channel) {
|
||||
tvhlog(LOG_DEBUG, "cwc", "Filtering ECM channel %d", channel);
|
||||
tvhlog(LOG_DEBUG, "cwc", "Filtering ECM (PID %d)", channel);
|
||||
return;
|
||||
}
|
||||
|
||||
es->es_seq = cwc_send_msg(cwc, data, len, sid, 1);
|
||||
|
||||
tvhlog(LOG_DEBUG, "cwc",
|
||||
"Sending ECM%s section=%d/%d, for service %s (seqno: %d) PID %d",
|
||||
chaninfo, section, ep->ep_last_section, t->s_svcname, es->es_seq,
|
||||
st->es_pid);
|
||||
"Sending ECM%s section=%d/%d, for service \"%s\" (seqno: %d)",
|
||||
chaninfo, section, ep->ep_last_section, t->s_svcname, es->es_seq);
|
||||
es->es_time = getmonoclock();
|
||||
break;
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue