X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;ds=sidebyside;f=modules%2Fstream_out%2Frtcp.c;h=83420b9e17051b24264be28c9766c7072d737a90;hb=9372cb45f24bedcffb895d41a643890393162450;hp=438f3d976ab988ed664bf866ea333536496a5ed0;hpb=3561b9b28f58eb7a4183e158a8fd973800d31ceb;p=vlc diff --git a/modules/stream_out/rtcp.c b/modules/stream_out/rtcp.c index 438f3d976a..83420b9e17 100644 --- a/modules/stream_out/rtcp.c +++ b/modules/stream_out/rtcp.c @@ -32,10 +32,15 @@ #include #include +#include #include "rtp.h" #include +#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, @@ -53,7 +58,7 @@ struct rtcp_sender_t { size_t length; /* RTCP packet length */ - uint8_t payload[28 + 8 + (2 * 257)]; + uint8_t payload[28 + 8 + (2 * 257) + 8]; int handle; /* RTCP socket handler */ uint32_t packets; /* RTP packets sent */ @@ -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) @@ -164,16 +184,22 @@ void CloseRTCP (rtcp_sender_t *rtcp) return; uint8_t *ptr = rtcp->payload; + uint64_t now64 = NTPtime64 (); + SetQWBE (ptr + 8, now64); /* Update the Sender Report timestamp */ + /* Bye */ + ptr += rtcp->length; ptr[0] = (2 << 6) | 1; /* V = 2, P = 0, SC = 1 */ ptr[1] = 203; /* payload type: Bye */ SetWBE (ptr + 2, 1); - /* SSRC is already there :) */ + memcpy (ptr + 4, rtcp->payload + 4, 4); /* Copy SSRC from Sender Report */ + rtcp->length += 8; /* We are THE sender, so we are more important than anybody else, so * we can afford not to check bandwidth constraints here. */ - send (rtcp->handle, rtcp->payload, 8, 0); + send (rtcp->handle, rtcp->payload, rtcp->length, 0); net_Close (rtcp->handle); + free (rtcp); }