]> git.ipfire.org Git - thirdparty/tvheadend.git/commitdiff
Slightly better error reporting when no scrambler is available
authorAndreas Öman <andreas@lonelycoder.com>
Fri, 2 May 2008 14:55:49 +0000 (14:55 +0000)
committerAndreas Öman <andreas@lonelycoder.com>
Fri, 2 May 2008 14:55:49 +0000 (14:55 +0000)
cwc.c
tsdemux.c

diff --git a/cwc.c b/cwc.c
index a60364e937397d3857c35c8e50b8ec80ed4477da..8a8295a4b6461ecf1fde3eb15c67b3560c307d03 100644 (file)
--- a/cwc.c
+++ b/cwc.c
@@ -499,7 +499,6 @@ cwc_dispatch_running_reply(cwc_t *cwc, uint8_t msgtype, uint8_t *msg, int len)
     if(len < 19) {
 
       if(ct->ct_keystate != CT_FORBIDDEN) {
-       transport_signal_error(t, TRANSPORT_ERROR_NO_ACCESS);
        syslog(LOG_ERR, 
               "Can not descramble \"%s\" for service \"%s\", access denied",
               t->tht_identifier, t->tht_servicename);
@@ -698,14 +697,17 @@ cwc_descramble(th_descrambler_t *td, th_transport_t *t, struct th_stream *st,
   unsigned char *vec[3];
   uint8_t *t0;
 
+  if(ct->ct_keystate == CT_FORBIDDEN)
+    return TRANSPORT_ERROR_NO_ACCESS;
+
   if(ct->ct_keystate != CT_RESOLVED)
-    return 0;
+    return -1;
 
   memcpy(ct->ct_tsbcluster + ct->ct_fill * 188, tsb, 188);
   ct->ct_fill++;
 
   if(ct->ct_fill != CT_CLUSTER_SIZE)
-    return 1;
+    return 0;
 
   ct->ct_fill = 0;
 
@@ -723,7 +725,7 @@ cwc_descramble(th_descrambler_t *td, th_transport_t *t, struct th_stream *st,
       t0 += 188;
     }
   }
-  return 1;
+  return 0;
 }
 
 
@@ -755,8 +757,19 @@ cwc_transport_start(th_transport_t *t)
   cwc_t *cwc;
   cwc_transport_t *ct;
   th_descrambler_t *td;
+  th_stream_t *st;
 
   LIST_FOREACH(cwc, &cwcs, cwc_link) {
+
+    LIST_FOREACH(st, &t->tht_streams, st_link)
+      if(st->st_caid == cwc->cwc_caid)
+       break;
+
+    if(st == NULL)
+      continue;
+
+    printf("Ok CWC found\n");
+
     ct = calloc(1, sizeof(cwc_transport_t));
     ct->ct_keys = get_key_struct();
     ct->ct_cwc = cwc;
index 3563756d262a0d26db9fb2175dee29b1fae1512b..fd64043c4f41c45ee083eb084ecb191ef89cbf4f 100644 (file)
--- a/tsdemux.c
+++ b/tsdemux.c
@@ -195,7 +195,7 @@ void
 ts_recv_packet1(th_transport_t *t, uint8_t *tsb)
 {
   th_stream_t *st;
-  int pid;
+  int pid, n, m, r;
   th_descrambler_t *td;
 
   pid = (tsb[1] & 0x1f) << 8 | tsb[2];
@@ -216,10 +216,24 @@ ts_recv_packet1(th_transport_t *t, uint8_t *tsb)
 
   if(tsb[3] & 0xc0) {
     /* scrambled stream */
-    LIST_FOREACH(td, &t->tht_descramblers, td_transport_link)
-      if(td->td_descramble(td, t, st, tsb))
-       break;
-    
+    n = m = 0;
+
+    LIST_FOREACH(td, &t->tht_descramblers, td_transport_link) {
+      n++;
+      
+      r = td->td_descramble(td, t, st, tsb);
+      if(r == 0)
+       return;
+      
+      if(r == TRANSPORT_ERROR_NO_ACCESS)
+       m++;
+    }
+
+    if(n == 0) {
+      transport_signal_error(t, TRANSPORT_ERROR_NO_DESCRAMBLER);
+    } else if(m == n) {
+      transport_signal_error(t, TRANSPORT_ERROR_NO_ACCESS);
+    }
     return;
   }