]> git.ipfire.org Git - thirdparty/tvheadend.git/commitdiff
If GET_PARAMETER fails use OPTIONS for keep alive loop
authorspdfrk <spdfrk123456@gmail.com>
Wed, 2 Mar 2016 20:02:29 +0000 (21:02 +0100)
committerJaroslav Kysela <perex@perex.cz>
Wed, 16 Mar 2016 07:56:34 +0000 (08:56 +0100)
src/http.h
src/input/mpegts/iptv/iptv_rtsp.c

index 8b24fb394d9a79d763d0f531d223e9f47b3a95f8..22ae0d32bdfff1c707ca2e85b25be45674e3b66b 100644 (file)
@@ -345,6 +345,7 @@ struct http_client {
   int          hc_rtp_timeout;
   char        *hc_rtsp_user;
   char        *hc_rtsp_pass;
+  char         hc_rtsp_keep_alive_cmd;
 
   struct http_client_ssl *hc_ssl; /* ssl internals */
 
index fc9639f7371a594b4c8175453bbc2eeefac24914..80f2adbb1d9835068f9ad15ccbf7c56543098d5f 100644 (file)
@@ -52,8 +52,12 @@ iptv_rtsp_alive_cb ( void *aux )
 {
   iptv_mux_t *im = aux;
   rtsp_priv_t *rp = im->im_data;
-
-  rtsp_get_parameter(rp->hc, "");
+  if(rp->hc->hc_rtsp_keep_alive_cmd == RTSP_CMD_GET_PARAMETER)
+    rtsp_get_parameter(rp->hc, "");
+  else if(rp->hc->hc_rtsp_keep_alive_cmd == RTSP_CMD_OPTIONS)
+    rtsp_send(rp->hc, RTSP_CMD_OPTIONS, rp->path, rp->query, NULL);
+  else
+    return;
   mtimer_arm_rel(&rp->alive_timer, iptv_rtsp_alive_cb, im,
                  sec2mono(MAX(1, (rp->hc->hc_rtp_timeout / 2) - 1)));
 }
@@ -78,6 +82,13 @@ iptv_rtsp_header ( http_client_t *hc )
     return 0;
   }
 
+  if (hc->hc_cmd == RTSP_CMD_GET_PARAMETER && hc->hc_code != HTTP_STATUS_OK) {
+    tvherror("iptv", "GET_PARAMETER command returned invalid error code %d for '%s', "
+        "fall back to OPTIONS in keep alive loop.", hc->hc_code, im->mm_iptv_url_raw);
+    hc->hc_rtsp_keep_alive_cmd = RTSP_CMD_OPTIONS;
+    return 0;
+  }
+
   if (hc->hc_code != HTTP_STATUS_OK) {
     tvherror("iptv", "invalid error code %d for '%s'", hc->hc_code, im->mm_iptv_url_raw);
     return 0;
@@ -160,10 +171,11 @@ iptv_rtsp_start
     return SM_CODE_TUNING_FAILED;
   }
 
-  hc->hc_hdr_received    = iptv_rtsp_header;
-  hc->hc_data_received   = iptv_rtsp_data;
-  hc->hc_handle_location = 1;        /* allow redirects */
-  http_client_register(hc);          /* register to the HTTP thread */
+  hc->hc_hdr_received        = iptv_rtsp_header;
+  hc->hc_data_received       = iptv_rtsp_data;
+  hc->hc_handle_location     = 1;                      /* allow redirects */
+  hc->hc_rtsp_keep_alive_cmd = RTSP_CMD_GET_PARAMETER; /* start keep alive loop with GET_PARAMETER */
+  http_client_register(hc);                            /* register to the HTTP thread */
   r = rtsp_setup(hc, u->path, u->query, NULL,
                  ntohs(IP_PORT(rtp->ip)),
                  ntohs(IP_PORT(rtcp->ip)));