Add framework for notifying subscribers if a transports gets in trouble.
Currently only implemented for access denied in code word client.
This commit is contained in:
parent
e1df4376e3
commit
87c553ea36
5 changed files with 47 additions and 3 deletions
7
cwc.c
7
cwc.c
|
@ -34,6 +34,7 @@
|
|||
#include "tsdemux.h"
|
||||
#include "ffdecsa/FFdecsa.h"
|
||||
#include "dispatch.h"
|
||||
#include "transports.h"
|
||||
|
||||
#define CWC_KEEPALIVE_INTERVAL 600
|
||||
|
||||
|
@ -497,12 +498,14 @@ cwc_dispatch_running_reply(cwc_t *cwc, uint8_t msgtype, uint8_t *msg, int len)
|
|||
|
||||
if(len < 19) {
|
||||
|
||||
if(ct->ct_keystate != CT_FORBIDDEN)
|
||||
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);
|
||||
ct->ct_keystate = CT_FORBIDDEN;
|
||||
}
|
||||
|
||||
ct->ct_keystate = CT_FORBIDDEN;
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
|
@ -111,6 +111,18 @@ sp_packet_input(void *opaque, th_muxstream_t *tms, th_pkt_t *pkt)
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Callback when transport hits an error
|
||||
*/
|
||||
static void
|
||||
sp_err_callback(struct th_subscription *s, int errorcode, void *opaque)
|
||||
{
|
||||
sp_t *sp = opaque;
|
||||
|
||||
sp->sp_ok = 0;
|
||||
dtimer_arm(&sp->sp_timer, sp_timeout, sp, 0);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Setup IPTV (TS over UDP) output
|
||||
|
@ -132,7 +144,8 @@ serviceprobe_engage(void)
|
|||
sp->sp_s = s = calloc(1, sizeof(th_subscription_t));
|
||||
s->ths_title = "probe";
|
||||
s->ths_weight = INT32_MAX;
|
||||
|
||||
s->ths_opaque = sp;
|
||||
|
||||
if(t->tht_status != TRANSPORT_RUNNING)
|
||||
transport_start(t, INT32_MAX);
|
||||
|
||||
|
@ -142,6 +155,8 @@ serviceprobe_engage(void)
|
|||
sp->sp_muxer = tm = muxer_init(s, sp_packet_input, sp);
|
||||
muxer_play(tm, AV_NOPTS_VALUE);
|
||||
|
||||
s->ths_err_callback = sp_err_callback;
|
||||
|
||||
dtimer_arm(&sp->sp_timer, sp_timeout, sp, 4);
|
||||
}
|
||||
|
||||
|
|
12
transports.c
12
transports.c
|
@ -586,3 +586,15 @@ transport_is_available(th_transport_t *t)
|
|||
{
|
||||
return transport_servicetype_txt(t) && LIST_FIRST(&t->tht_streams);
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
void
|
||||
transport_signal_error(th_transport_t *t, int errorcode)
|
||||
{
|
||||
th_subscription_t *s;
|
||||
LIST_FOREACH(s, &t->tht_subscriptions, ths_transport_link)
|
||||
if(s->ths_err_callback != NULL)
|
||||
s->ths_err_callback(s, errorcode, s->ths_opaque);
|
||||
}
|
||||
|
|
|
@ -53,4 +53,6 @@ int transport_is_available(th_transport_t *t);
|
|||
|
||||
void transport_destroy(th_transport_t *t);
|
||||
|
||||
void transport_signal_error(th_transport_t *t, int errorcode);
|
||||
|
||||
#endif /* TRANSPORTS_H */
|
||||
|
|
12
tvhead.h
12
tvhead.h
|
@ -809,6 +809,16 @@ typedef void (subscription_raw_input_t)(struct th_subscription *s,
|
|||
th_stream_t *st,
|
||||
void *opaque);
|
||||
|
||||
|
||||
#define TRANSPORT_ERROR_NO_DESCRAMBLER 1
|
||||
#define TRANSPORT_ERROR_NO_ACCESS 2
|
||||
#define TRANSPORT_ERROR_MUX_ERROR 3
|
||||
|
||||
|
||||
typedef void (subscription_err_callback_t)(struct th_subscription *s,
|
||||
int errorcode,
|
||||
void *opaque);
|
||||
|
||||
typedef struct th_subscription {
|
||||
LIST_ENTRY(th_subscription) ths_global_link;
|
||||
int ths_weight;
|
||||
|
@ -834,6 +844,8 @@ typedef struct th_subscription {
|
|||
|
||||
th_muxer_t *ths_muxer;
|
||||
|
||||
subscription_err_callback_t *ths_err_callback;
|
||||
|
||||
} th_subscription_t;
|
||||
|
||||
/**
|
||||
|
|
Loading…
Add table
Reference in a new issue