]> git.ipfire.org Git - thirdparty/tvheadend.git/commitdiff
satip server: signalize pernament 'no data' state to rtsp layer, fixes #4499
authorJaroslav Kysela <perex@perex.cz>
Thu, 27 Jul 2017 15:00:45 +0000 (17:00 +0200)
committerJaroslav Kysela <perex@perex.cz>
Mon, 18 Sep 2017 13:05:08 +0000 (15:05 +0200)
src/satip/rtp.c
src/satip/rtsp.c
src/satip/server.h

index 889db1d93f0c3f40b08dfacb72ad2de3f84952a0..42becb9202b477e91b95bf580b9bfd93e52460a2 100644 (file)
@@ -71,6 +71,8 @@ typedef struct satip_rtp_session {
   pthread_mutex_t *tcp_lock;
   uint8_t *table_data;
   int table_data_len;
+  void (*no_data_cb)(void *opaque);
+  void *no_data_opaque;
 } satip_rtp_session_t;
 
 static pthread_mutex_t satip_rtp_lock;
@@ -403,6 +405,8 @@ satip_rtp_thread(void *aux)
       break;
     case SMT_NOSTART:
     case SMT_EXIT:
+      if (rtp->no_data_cb)
+        rtp->no_data_cb(rtp->no_data_opaque);
       alive = 0;
       break;
 
@@ -440,7 +444,9 @@ void *satip_rtp_queue(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 allow_data, int perm_lock)
+                      mpegts_apids_t *pids, int allow_data, int perm_lock,
+                      void (*no_data_cb)(void *opaque),
+                      void *no_data_opaque)
 {
   satip_rtp_session_t *rtp = calloc(1, sizeof(*rtp));
   int dscp;
@@ -458,6 +464,8 @@ void *satip_rtp_queue(th_subscription_t *subs,
   rtp->subs = subs;
   rtp->sq = sq;
   rtp->tcp_lock = tcp_lock;
+  rtp->no_data_cb = no_data_cb;
+  rtp->no_data_opaque = no_data_opaque;
   atomic_set(&rtp->allow_data, allow_data);
   mpegts_pid_init(&rtp->pids);
   mpegts_pid_copy(&rtp->pids, pids);
index 6093a88899e0c992131e189e25b80edeb9d9ae3c..7bc42ce1186cc5e146e8b18c18fa648b1c7dc58d 100644 (file)
@@ -56,6 +56,7 @@ typedef struct session {
   http_connection_t *shutdown_on_close;
   http_connection_t *tcp_data;
   int perm_lock;
+  int no_data;
   uint32_t nsession;
   char session[9];
   dvb_mux_conf_t dmc;
@@ -402,6 +403,16 @@ rtsp_clean(session_t *rs)
   rs->mux_created = 0;
 }
 
+/*
+ *
+ */
+static void
+rtsp_no_data(void *opaque)
+{
+  session_t *rs = opaque;
+  rs->no_data = 1;
+}
+
 /*
  *
  */
@@ -576,8 +587,11 @@ rtsp_start
               (rtsp_muxcnf == MUXCNF_REJECT || rtsp_muxcnf == MUXCNF_REJECT_EXACT_MATCH ) ? " (configuration)" : "");
       goto endclean;
     }
-    if (rs->mux == mux && rs->subs)
+    if (rs->mux == mux && rs->subs) {
+      if (rs->no_data)
+        goto endclean;
       goto pids;
+    }
     rtsp_clean(rs);
     rs->dmc_tuned = dmc;
     rs->mux = mux;
@@ -612,6 +626,7 @@ pids:
   if (cmd != RTSP_CMD_DESCRIBE && rs->state != STATE_PLAY) {
     if (rs->mux == NULL)
       goto endclean;
+    rs->no_data = 0;
     rs->rtp_handle =
       satip_rtp_queue(rs->subs, &rs->prch.prch_sq,
                       &hc->hc_fd_lock, hc->hc_peer, rs->rtp_peer_port,
@@ -620,7 +635,7 @@ pids:
                       rs->findex, rs->src, &rs->dmc_tuned,
                       &rs->pids,
                       cmd == RTSP_CMD_PLAY || oldstate == STATE_PLAY,
-                      rs->perm_lock);
+                      rs->perm_lock, rtsp_no_data, rs);
     if (rs->rtp_handle == NULL) {
       res = HTTP_STATUS_INTERNAL;
       goto endclean;
index d42d74559657aaa8621128006aaa6c2fb1115242..eaa475c6dc7301709b2de14dd83da3870ed0a792 100644 (file)
@@ -73,13 +73,9 @@ void *satip_rtp_queue(th_subscription_t *subs,
                       int frontend, int source,
                       dvb_mux_conf_t *dmc,
                       mpegts_apids_t *pids,
-                      int allow_data, int perm_lock);
-void satip_rtp_update(void *_rtp, 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);
+                      int allow_data, int perm_lock,
+                      void (*no_data_cb)(void *opaque),
+                      void *no_data_opaque);
 void satip_rtp_allow_data(void *_rtp);
 void satip_rtp_update_pids(void *_rtp, mpegts_apids_t *pids);
 void satip_rtp_update_pmt_pids(void *_rtp, mpegts_apids_t *pmt_pids);