]> git.ipfire.org Git - thirdparty/tvheadend.git/commitdiff
satip server: start streaming directly after SETUP, but RTCP only, fixes #4449
authorJaroslav Kysela <perex@perex.cz>
Tue, 20 Jun 2017 12:36:36 +0000 (14:36 +0200)
committerJaroslav Kysela <perex@perex.cz>
Thu, 6 Jul 2017 13:31:51 +0000 (15:31 +0200)
src/satip/rtp.c
src/satip/rtsp.c
src/satip/server.h

index 4ef931e0d564aecff298ec3926eb877ab5e4189e..32085c986ce39ebdc433409351030eaf87fb1946 100644 (file)
@@ -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;
index cfeeddc354cbcf3deb63000230cf81dc796653ff..89654cb84465c9de1074d6e2b37882853d27aa09 100644 (file)
@@ -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);
index 4035a11c1e0aa6210bf8e45fdb610a4524df640e..471027fcb7ead97ee099ac533488676b13a72f20 100644 (file)
@@ -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);