]> git.ipfire.org Git - thirdparty/tvheadend.git/commitdiff
Add RTSP body support and request position in keep alive loop
authorspdfrk <spdfrk123456@gmail.com>
Wed, 2 Mar 2016 20:47:37 +0000 (21:47 +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
src/rtsp.c

index 22ae0d32bdfff1c707ca2e85b25be45674e3b66b..3fe7dc04b9ddb9f6956989063d715a58176e695e 100644 (file)
@@ -391,8 +391,14 @@ void http_client_unpause( http_client_t *hc );
  * RTSP helpers
  */
 
-int rtsp_send( http_client_t *hc, http_cmd_t cmd, const char *path,
-               const char *query, http_arg_list_t *hdr );
+int rtsp_send_ext( http_client_t *hc, http_cmd_t cmd, const char *path,
+               const char *query, http_arg_list_t *hdr, const char *body, size_t size );
+
+static inline int
+rtsp_send( http_client_t *hc, http_cmd_t cmd, const char *path,
+               const char *query, http_arg_list_t *hdr ) {
+  return rtsp_send_ext( hc, cmd, path, query, hdr, NULL, 0 );
+}
                       
 void rtsp_clear_session( http_client_t *hc );
 
@@ -421,7 +427,10 @@ rtsp_teardown( http_client_t *hc, const char *path, const char *query ) {
 }
 
 static inline int rtsp_get_parameter( http_client_t *hc, const char *parameter ) {
-  return rtsp_send(hc, RTSP_CMD_GET_PARAMETER, NULL, parameter, NULL);
+  http_arg_list_t hdr;
+  http_arg_init(&hdr);
+  http_arg_set(&hdr, "Content-Type", "text/parameters");
+  return rtsp_send_ext(hc, RTSP_CMD_GET_PARAMETER, NULL, NULL, &hdr, parameter, strlen(parameter));
 }
 
 int rtsp_describe_decode( http_client_t *hc );
index 80f2adbb1d9835068f9ad15ccbf7c56543098d5f..04d5a3e26ddba159098393468560f07e68c218cc 100644 (file)
@@ -53,7 +53,7 @@ iptv_rtsp_alive_cb ( void *aux )
   iptv_mux_t *im = aux;
   rtsp_priv_t *rp = im->im_data;
   if(rp->hc->hc_rtsp_keep_alive_cmd == RTSP_CMD_GET_PARAMETER)
-    rtsp_get_parameter(rp->hc, "");
+    rtsp_get_parameter(rp->hc, "position");
   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
index 2b59edfbdc0928208d57da4a6a45621688dbb337..78c990ec903655218f6d17de062c0d1caabc530d 100644 (file)
  * Utils
  */
 int
-rtsp_send( http_client_t *hc, http_cmd_t cmd,
+rtsp_send_ext( http_client_t *hc, http_cmd_t cmd,
            const char *path, const char *query,
-           http_arg_list_t *hdr )
+           http_arg_list_t *hdr,
+           const char *body, size_t size )
 {
   http_arg_list_t h;
   size_t blen = 7 + strlen(hc->hc_host) +
@@ -38,6 +39,7 @@ rtsp_send( http_client_t *hc, http_cmd_t cmd,
                 (path ? strlen(path) : 1) + 1;
   char *buf = alloca(blen);
   char buf2[7];
+  char buf_body[size + 3];
 
   if (hc->hc_rtsp_session) {
     if (hdr == NULL) {
@@ -46,13 +48,28 @@ rtsp_send( http_client_t *hc, http_cmd_t cmd,
     }
     http_arg_set(hdr, "Session", hc->hc_rtsp_session);
   }
+
+  if (size > 0) {
+    if (hdr == NULL) {
+      hdr = &h;
+      http_arg_init(&h);
+    }
+    strncpy(buf_body, body, sizeof(buf_body));
+    strncat(buf_body, "\r\n", 2);
+    snprintf(buf2, sizeof(buf2), "%lu", size + 2);
+    http_arg_set(hdr, "Content-Length", buf2);
+  }
+
   http_client_basic_auth(hc, hdr, hc->hc_rtsp_user, hc->hc_rtsp_pass);
   if (hc->hc_port != 554)
     snprintf(buf2, sizeof(buf2), ":%d", hc->hc_port);
   else
     buf2[0] = '\0';
   snprintf(buf, blen, "rtsp://%s%s%s", hc->hc_host, buf2, path ? path : "/");
-  return http_client_send(hc, cmd, buf, query, hdr, NULL, 0);
+  if(size > 0)
+    return http_client_send(hc, cmd, buf, query, hdr, buf_body, size + 2);
+  else
+    return http_client_send(hc, cmd, buf, query, hdr, NULL, 0);
 }
 
 void