[vlc-commits] access/rtp: define MSG_TRUNC on recv call if available.

Ilkka Ollakka git at videolan.org
Sun Dec 16 21:35:38 CET 2018


vlc/vlc-3.0 | branch: master | Ilkka Ollakka <ileoo at videolan.org> | Mon Oct 15 17:21:21 2018 +0300| [bbb70a65406afe9c01d637fd1137c2c6ef9ca357] | committer: Jean-Baptiste Kempf

access/rtp: define MSG_TRUNC on recv call if available.

recv() needs MSG_TRUNC flag so it will tell actual data-size if truncate
would happen additional to setting flag for it.

Tested the adjust of MTU by sending data to localhost via netcat:

cat ~/tmp/myfile.mp3|netcat -u 127.0.0.1 1234

and vlc -Idummy -vv rtp://@127.0.0.1:1234 --sout="#stat"

without this patch the rtp input constantly complains about trunced
input and doesn't adjust the receiving amount.

Signed-off-by: RĂ©mi Denis-Courmont <remi at remlab.net>
(cherry picked from commit 8b5c5e37c1b73227fde974408f9f9f5742f3954f)
Signed-off-by: Jean-Baptiste Kempf <jb at videolan.org>

> http://git.videolan.org/gitweb.cgi/vlc/vlc-3.0.git/?a=commit;h=bbb70a65406afe9c01d637fd1137c2c6ef9ca357
---

 modules/access/rtp/input.c | 18 +++++++++---------
 1 file changed, 9 insertions(+), 9 deletions(-)

diff --git a/modules/access/rtp/input.c b/modules/access/rtp/input.c
index cf9d9a7cad..7e7cd71360 100644
--- a/modules/access/rtp/input.c
+++ b/modules/access/rtp/input.c
@@ -109,6 +109,12 @@ void *rtp_dgram_thread (void *opaque)
     demux_sys_t *sys = demux->p_sys;
     mtime_t deadline = VLC_TS_INVALID;
     int rtp_fd = sys->fd;
+#ifdef __linux__
+    const int trunc_flag = MSG_TRUNC;
+#else
+    const int trunc_flag = 0;
+#endif
+
     struct iovec iov =
     {
         .iov_len = DEFAULT_MRU,
@@ -149,17 +155,12 @@ void *rtp_dgram_thread (void *opaque)
             }
 
             iov.iov_base = block->p_buffer;
-#ifdef __linux__
-            msg.msg_flags = MSG_TRUNC;
-#else
-            msg.msg_flags = 0;
-#endif
+            msg.msg_flags = trunc_flag;
 
-            ssize_t len = recvmsg (rtp_fd, &msg, 0);
+            ssize_t len = recvmsg (rtp_fd, &msg, trunc_flag);
             if (len != -1)
             {
-#ifdef MSG_TRUNC
-                if (msg.msg_flags & MSG_TRUNC)
+                if (msg.msg_flags & trunc_flag)
                 {
                     msg_Err(demux, "%zd bytes packet truncated (MRU was %zu)",
                             len, iov.iov_len);
@@ -167,7 +168,6 @@ void *rtp_dgram_thread (void *opaque)
                     iov.iov_len = len;
                 }
                 else
-#endif
                     block->i_buffer = len;
 
                 rtp_process (demux, block);



More information about the vlc-commits mailing list