diff --git a/src/dvb/dvb_fe.c b/src/dvb/dvb_fe.c index 25da835a..97536abe 100644 --- a/src/dvb/dvb_fe.c +++ b/src/dvb/dvb_fe.c @@ -39,6 +39,8 @@ #include "diseqc.h" #include "notify.h" #include "dvr/dvr.h" +#include "service.h" +#include "streaming.h" #include "epggrab.h" @@ -91,6 +93,9 @@ dvb_fe_monitor(void *aux) int status, v, update = 0, vv, i, fec, q; th_dvb_mux_instance_t *tdmi = tda->tda_mux_current; char buf[50]; + signal_status_t sigstat; + streaming_message_t sm; + struct service *t; gtimer_arm(&tda->tda_fe_monitor_timer, dvb_fe_monitor, tda, 1); @@ -194,6 +199,22 @@ dvb_fe_monitor(void *aux) dvb_mux_save(tdmi); } + + /* Streaming message */ + sigstat.status_text = dvb_mux_status(tdmi); + sigstat.snr = tdmi->tdmi_snr; + sigstat.signal = tdmi->tdmi_signal; + sigstat.ber = tdmi->tdmi_ber; + sigstat.unc = tdmi->tdmi_uncorrected_blocks; + sm.sm_type = SMT_SIGNAL_STATUS; + sm.sm_data = &sigstat; + LIST_FOREACH(t, &tda->tda_transports, s_active_link) + if(t->s_dvb_mux_instance == tda->tda_mux_current && t->s_status == SERVICE_RUNNING ) { + pthread_mutex_lock(&t->s_stream_mutex); + streaming_pad_deliver(&t->s_streaming_pad, &sm); + pthread_mutex_unlock(&t->s_stream_mutex); + } + } diff --git a/src/dvr/dvr_rec.c b/src/dvr/dvr_rec.c index 1dd0d57a..9ba9e103 100755 --- a/src/dvr/dvr_rec.c +++ b/src/dvr/dvr_rec.c @@ -516,6 +516,9 @@ dvr_thread(void *aux) } break; + case SMT_SIGNAL_STATUS: + break; + case SMT_EXIT: run = 0; break; diff --git a/src/htsp.c b/src/htsp.c index 0fc0259b..91011c27 100644 --- a/src/htsp.c +++ b/src/htsp.c @@ -1915,6 +1915,27 @@ htsp_subscription_service_status(htsp_subscription_t *hs, int status) } } +/** + * + */ +static void +htsp_subscription_signal_status(htsp_subscription_t *hs, signal_status_t *sig) +{ + htsmsg_t *m = htsmsg_create_map(); + htsmsg_add_str(m, "method", "signalStatus"); + htsmsg_add_u32(m, "subscriptionId", hs->hs_sid); + htsmsg_add_str(m, "feStatus", sig->status_text); + if(sig->snr != -2) + htsmsg_add_u32(m, "feSNR", sig->snr); + if(sig->signal != -2) + htsmsg_add_u32(m, "feSignal", sig->signal); + if(sig->ber != -2) + htsmsg_add_u32(m, "feBER", sig->ber); + if(sig->unc != -2) + htsmsg_add_u32(m, "feUNC", sig->unc); + htsp_send_message(hs->hs_htsp, m, &hs->hs_htsp->htsp_hmq_qstatus); +} + /** * */ @@ -1941,6 +1962,10 @@ htsp_streaming_input(void *opaque, streaming_message_t *sm) htsp_subscription_service_status(hs, sm->sm_code); break; + case SMT_SIGNAL_STATUS: + htsp_subscription_signal_status(hs, sm->sm_data); + break; + case SMT_NOSTART: htsp_subscription_status(hs, streaming_code2txt(sm->sm_code)); break; diff --git a/src/plumbing/globalheaders.c b/src/plumbing/globalheaders.c index 62a8315f..d776f34c 100644 --- a/src/plumbing/globalheaders.c +++ b/src/plumbing/globalheaders.c @@ -252,6 +252,7 @@ gh_hold(globalheaders_t *gh, streaming_message_t *sm) case SMT_EXIT: case SMT_SERVICE_STATUS: + case SMT_SIGNAL_STATUS: case SMT_NOSTART: case SMT_MPEGTS: streaming_target_deliver2(gh->gh_output, sm); @@ -279,6 +280,7 @@ gh_pass(globalheaders_t *gh, streaming_message_t *sm) // FALLTHRU case SMT_EXIT: case SMT_SERVICE_STATUS: + case SMT_SIGNAL_STATUS: case SMT_NOSTART: case SMT_MPEGTS: streaming_target_deliver2(gh->gh_output, sm); diff --git a/src/plumbing/tsfix.c b/src/plumbing/tsfix.c index 9bd26338..d04e610d 100644 --- a/src/plumbing/tsfix.c +++ b/src/plumbing/tsfix.c @@ -363,6 +363,7 @@ tsfix_input(void *opaque, streaming_message_t *sm) case SMT_EXIT: case SMT_SERVICE_STATUS: + case SMT_SIGNAL_STATUS: case SMT_NOSTART: case SMT_MPEGTS: break; diff --git a/src/streaming.c b/src/streaming.c index cb74b054..ea564dae 100755 --- a/src/streaming.c +++ b/src/streaming.c @@ -182,6 +182,11 @@ streaming_msg_clone(streaming_message_t *src) atomic_add(&ss->ss_refcount, 1); break; + case SMT_SIGNAL_STATUS: + dst->sm_data = malloc(sizeof(signal_status_t)); + memcpy(dst->sm_data, src->sm_data, sizeof(signal_status_t)); + break; + case SMT_STOP: case SMT_SERVICE_STATUS: case SMT_NOSTART: @@ -250,6 +255,7 @@ streaming_msg_free(streaming_message_t *sm) case SMT_NOSTART: break; + case SMT_SIGNAL_STATUS: case SMT_MPEGTS: free(sm->sm_data); break; diff --git a/src/tvheadend.h b/src/tvheadend.h index 1d8cc9f6..f7bb0f7e 100644 --- a/src/tvheadend.h +++ b/src/tvheadend.h @@ -235,6 +235,13 @@ typedef enum { */ SMT_SERVICE_STATUS, + /** + * Signal status + * + * Notification about frontend signal status + */ + SMT_SIGNAL_STATUS, + /** * Streaming stop. * diff --git a/src/webui/webui.c b/src/webui/webui.c index 78b92bad..6c1041e7 100644 --- a/src/webui/webui.c +++ b/src/webui/webui.c @@ -222,6 +222,9 @@ http_stream_run(http_connection_t *hc, streaming_queue_t *sq, } break; + case SMT_SIGNAL_STATUS: + break; + case SMT_NOSTART: tvhlog(LOG_DEBUG, "webui", "Couldn't start stream for %s", hc->hc_url_orig); run = 0;