From: Jaroslav Kysela Date: Tue, 20 Jun 2017 12:36:36 +0000 (+0200) Subject: satip server: start streaming directly after SETUP, but RTCP only, fixes #4449 X-Git-Tag: v4.2.4~106 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=550ed7e6aab4f33a555472a3fac135f7d5770ac2;p=thirdparty%2Ftvheadend.git satip server: start streaming directly after SETUP, but RTCP only, fixes #4449 --- diff --git a/src/satip/rtp.c b/src/satip/rtp.c index 4ef931e0d..32085c986 100644 --- a/src/satip/rtp.c +++ b/src/satip/rtp.c @@ -57,6 +57,7 @@ typedef struct satip_rtp_session { int frontend; int source; int disable_rtcp; + int allow_data; dvb_mux_conf_t dmc; mpegts_apids_t pids; TAILQ_HEAD(, satip_rtp_table) pmt_tables; @@ -389,13 +390,15 @@ satip_rtp_thread(void *aux) case SMT_MPEGTS: pb = sm->sm_data; subscription_add_bytes_out(subs, pktbuf_len(pb)); - pthread_mutex_lock(&rtp->lock); - if (tcp) - r = satip_rtp_tcp_loop(rtp, pktbuf_ptr(pb), pktbuf_len(pb)); - else - r = satip_rtp_loop(rtp, pktbuf_ptr(pb), pktbuf_len(pb)); - pthread_mutex_unlock(&rtp->lock); - if (r) fatal = 1; + if (atomic_get(&rtp->allow_data)) { + pthread_mutex_lock(&rtp->lock); + if (tcp) + r = satip_rtp_tcp_loop(rtp, pktbuf_ptr(pb), pktbuf_len(pb)); + else + r = satip_rtp_loop(rtp, pktbuf_ptr(pb), pktbuf_len(pb)); + pthread_mutex_unlock(&rtp->lock); + if (r) fatal = 1; + } break; case SMT_SIGNAL_STATUS: satip_rtp_signal_status(rtp, sm->sm_data); @@ -453,7 +456,7 @@ void satip_rtp_queue(void *id, th_subscription_t *subs, struct sockaddr_storage *peer, int port, int fd_rtp, int fd_rtcp, int frontend, int source, dvb_mux_conf_t *dmc, - mpegts_apids_t *pids, int perm_lock) + mpegts_apids_t *pids, int allow_data, int perm_lock) { satip_rtp_session_t *rtp = calloc(1, sizeof(*rtp)); int dscp; @@ -472,6 +475,7 @@ void satip_rtp_queue(void *id, th_subscription_t *subs, rtp->subs = subs; rtp->sq = sq; rtp->tcp_lock = tcp_lock; + atomic_set(&rtp->allow_data, allow_data); mpegts_pid_init(&rtp->pids); mpegts_pid_copy(&rtp->pids, pids); TAILQ_INIT(&rtp->pmt_tables); @@ -505,6 +509,17 @@ void satip_rtp_queue(void *id, th_subscription_t *subs, pthread_mutex_unlock(&satip_rtp_lock); } +void satip_rtp_allow_data(void *id) +{ + satip_rtp_session_t *rtp; + + pthread_mutex_lock(&satip_rtp_lock); + rtp = satip_rtp_find(id); + if (rtp) + atomic_set(&rtp->allow_data, 1); + pthread_mutex_unlock(&satip_rtp_lock); +} + void satip_rtp_update_pids(void *id, mpegts_apids_t *pids) { satip_rtp_session_t *rtp; diff --git a/src/satip/rtsp.c b/src/satip/rtsp.c index cfeeddc35..89654cb84 100644 --- a/src/satip/rtsp.c +++ b/src/satip/rtsp.c @@ -512,6 +512,7 @@ rtsp_start dvb_mux_conf_t dmc; char buf[384]; int res = HTTP_STATUS_NOT_ALLOWED, qsize = 3000000, created = 0, weight; + int osetup = setup; pthread_mutex_lock(&global_lock); weight = satip_server_conf.satip_weight; @@ -592,8 +593,9 @@ rtsp_start goto endclean; if (!rs->pids.all && rs->pids.count == 0) mpegts_pid_add(&rs->pids, 0, MPS_WEIGHT_RAW); + /* trigger play when first SETUP arrived */ /* retrigger play when new setup arrived */ - if (oldstate) { + if (oldstate != STATE_DESCRIBE || setup) { setup = 0; rs->state = STATE_SETUP; } @@ -618,13 +620,15 @@ pids: rs->udp_rtp ? rs->udp_rtp->fd : hc->hc_fd, rs->udp_rtcp ? rs->udp_rtcp->fd : -1, rs->frontend, rs->findex, &rs->dmc_tuned, - &rs->pids, rs->perm_lock); + &rs->pids, osetup == 0, rs->perm_lock); rs->tcp_data = rs->udp_rtp ? NULL : hc; if (!rs->pids.all && rs->pids.count == 0) mpegts_pid_add(&rs->pids, 0, MPS_WEIGHT_RAW); svc = (mpegts_service_t *)rs->subs->ths_raw_service; svc->s_update_pids(svc, &rs->pids); rs->state = STATE_PLAY; + } else if (osetup == 0) { + satip_rtp_allow_data((void *)(intptr_t)rs->stream); } rtsp_manage_descramble(rs); pthread_mutex_unlock(&global_lock); diff --git a/src/satip/server.h b/src/satip/server.h index 4035a11c1..471027fcb 100644 --- a/src/satip/server.h +++ b/src/satip/server.h @@ -72,13 +72,15 @@ void satip_rtp_queue(void *id, th_subscription_t *subs, int fd_rtp, int fd_rtcp, int frontend, int source, dvb_mux_conf_t *dmc, - mpegts_apids_t *pids, int perm_lock); + mpegts_apids_t *pids, + int allow_data, int perm_lock); void satip_rtp_update(void *id, th_subscription_t *subs, streaming_queue_t *sq, int frontend, int source, dvb_mux_conf_t *dmc, mpegts_apids_t *pids, mpegts_apids_t *pmt_pids); +void satip_rtp_allow_data(void *id); void satip_rtp_update_pids(void *id, mpegts_apids_t *pids); void satip_rtp_update_pmt_pids(void *id, mpegts_apids_t *pmt_pids); int satip_rtp_status(void *id, char *buf, int len);