]> git.sesse.net Git - vlc/blobdiff - modules/stream_out/rtcp.c
Pah; we cannot free these variables, since they are const.
[vlc] / modules / stream_out / rtcp.c
index 5525b7683f9a9710142d4d3611c412a8d30e2281..83420b9e17051b24264be28c9766c7072d737a90 100644 (file)
 
 #include <vlc_network.h>
 #include <vlc_sout.h>
+#include <vlc_fs.h>
 #include "rtp.h"
 
 #include <assert.h>
 
+#ifndef SOL_IP
+# define SOL_IP IPPROTO_IP
+#endif
+
 /*
  * NOTE on RTCP implementation:
  * - there is a single sender (us), no conferencing here! => n = sender = 1,
@@ -78,7 +83,10 @@ rtcp_sender_t *OpenRTCP (vlc_object_t *obj, int rtp_fd, int proto,
     {
         /* RTP/RTCP mux: duplicate the socket */
 #ifndef WIN32
-        fd = dup (rtp_fd);
+        fd = vlc_dup (rtp_fd);
+#elif defined(UNDER_CE)
+ #warning Muxed RTP/RTCP unimplemented!
+        fd = -1;
 #else
         WSAPROTOCOL_INFO info;
         WSADuplicateSocket (rtp_fd, GetCurrentProcessId (), &info);
@@ -99,6 +107,18 @@ rtcp_sender_t *OpenRTCP (vlc_object_t *obj, int rtp_fd, int proto,
         dport++;
 
         fd = net_OpenDgram (obj, src, sport, dst, dport, AF_UNSPEC, proto);
+        if (fd != -1)
+        {
+            /* Copy the multicast IPv4 TTL value (useless for IPv6) */
+            int ttl;
+            socklen_t len = sizeof (ttl);
+
+            if (!getsockopt (rtp_fd, SOL_IP, IP_MULTICAST_TTL, &ttl, &len))
+                setsockopt (fd, SOL_IP, IP_MULTICAST_TTL, &ttl, len);
+
+            /* Ignore all incoming RTCP-RR packets */
+            setsockopt (fd, SOL_SOCKET, SO_RCVBUF, &(int){ 0 }, sizeof (int));
+        }
     }
 
     if (fd == -1)
@@ -179,6 +199,7 @@ void CloseRTCP (rtcp_sender_t *rtcp)
      * we can afford not to check bandwidth constraints here. */
     send (rtcp->handle, rtcp->payload, rtcp->length, 0);
     net_Close (rtcp->handle);
+    free (rtcp);
 }