]> git.ipfire.org Git - thirdparty/tvheadend.git/commitdiff
http: extra data - add may_discard flag for RTP data, issue #4598
authorJaroslav Kysela <perex@perex.cz>
Sat, 16 Sep 2017 11:54:56 +0000 (13:54 +0200)
committerJaroslav Kysela <perex@perex.cz>
Mon, 18 Sep 2017 13:18:29 +0000 (15:18 +0200)
src/http.c
src/http.h
src/satip/rtp.c

index 4423299bbc17d6fa8ca9732917712e6001dd5941..f336ccebc2d7c65e421697cd452372fc30e0c405 100644 (file)
@@ -794,22 +794,24 @@ http_extra_flush_partial(http_connection_t *hc)
  *
  */
 int
-http_extra_send(http_connection_t *hc, const void *data, size_t data_len)
+http_extra_send(http_connection_t *hc, const void *data,
+                size_t data_len, int may_discard)
 {
   uint8_t *b = malloc(data_len);
   memcpy(b, data, data_len);
-  return http_extra_send_prealloc(hc, b, data_len);
+  return http_extra_send_prealloc(hc, b, data_len, may_discard);
 }
 
 /**
  *
  */
 int
-http_extra_send_prealloc(http_connection_t *hc, const void *data, size_t data_len)
+http_extra_send_prealloc(http_connection_t *hc, const void *data,
+                         size_t data_len, int may_discard)
 {
   if (data == NULL) return 0;
   pthread_mutex_lock(&hc->hc_extra_lock);
-  if (hc->hc_extra.hq_size <= 1024*1024) {
+  if (!may_discard || hc->hc_extra.hq_size <= 1024*1024) {
     atomic_add(&hc->hc_extra_chunks, 1);
     htsbuf_append_prealloc(&hc->hc_extra, data, data_len);
   } else {
index 4dd9ee02079c59c5a5279e1e3ca8e24b595731e8..ad94a54b98ab73ad3b978493c4e719efc362b69f 100644 (file)
@@ -215,9 +215,11 @@ int http_extra_flush(http_connection_t *hc);
 
 int http_extra_flush_partial(http_connection_t *hc);
 
-int http_extra_send(http_connection_t *hc, const void *data, size_t data_len);
+int http_extra_send(http_connection_t *hc, const void *data,
+                    size_t data_len, int may_discard);
 
-int http_extra_send_prealloc(http_connection_t *hc, const void *data, size_t data_len);
+int http_extra_send_prealloc(http_connection_t *hc, const void *data,
+                             size_t data_len, int may_discard);
 
 static inline void http_send_begin(http_connection_t *hc)
 {
index a7add1d4eda0d69e2f72b7ac8d93702fc2b304ab..a062d5f987265f5bad3d524834c993819bce1f98 100644 (file)
@@ -268,14 +268,15 @@ found:
 }
 
 static int
-satip_rtp_tcp_data(satip_rtp_session_t *rtp, uint8_t stream, uint8_t *data, size_t data_len)
+satip_rtp_tcp_data(satip_rtp_session_t *rtp, uint8_t stream,
+                   uint8_t *data, size_t data_len, int may_discard)
 {
   assert(data_len <= 0xffff);
   data[0] = '$';
   data[1] = stream;
   data[2] = (data_len - 4) >> 8;
   data[3] = (data_len - 4) & 0xff;
-  return http_extra_send_prealloc(rtp->hc, data, data_len);
+  return http_extra_send_prealloc(rtp->hc, data, data_len, may_discard);
 }
 
 static inline int
@@ -285,7 +286,7 @@ satip_rtp_flush_tcp_data(satip_rtp_session_t *rtp)
   int r = 0;
 
   if (v->iov_len)
-    r = satip_rtp_tcp_data(rtp, 0, v->iov_base, v->iov_len);
+    r = satip_rtp_tcp_data(rtp, 0, v->iov_base, v->iov_len, 1);
   else
     free(v->iov_base);
   v->iov_base = NULL;
@@ -937,7 +938,7 @@ satip_rtcp_thread(void *aux)
         msg1 = malloc(len);
         if (msg1) {
           memcpy(msg1, msg, len);
-          err = satip_rtp_tcp_data(rtp, 1, msg1, len);
+          err = satip_rtp_tcp_data(rtp, 1, msg1, len, 0);
           r = err ? -1 : 0;
         } else {
           r = -1;