Commit a1631eb0 authored by Rémi Denis-Courmont's avatar Rémi Denis-Courmont

RTCP: support for RTP/RTCP multiplexed on the same port

parent 500516e0
...@@ -59,22 +59,45 @@ struct rtcp_sender_t ...@@ -59,22 +59,45 @@ struct rtcp_sender_t
}; };
rtcp_sender_t *OpenRTCP (vlc_object_t *obj, int rtp_fd, int proto) rtcp_sender_t *OpenRTCP (vlc_object_t *obj, int rtp_fd, int proto,
vlc_bool_t mux)
{ {
rtcp_sender_t *rtcp; rtcp_sender_t *rtcp;
uint8_t *ptr; uint8_t *ptr;
char src[NI_MAXNUMERICHOST], dst[NI_MAXNUMERICHOST];
int sport, dport;
int fd; int fd;
char src[NI_MAXNUMERICHOST];
int sport;
if (net_GetSockAddress (rtp_fd, src, &sport) if (net_GetSockAddress (rtp_fd, src, &sport))
|| net_GetPeerAddress (rtp_fd, dst, &dport))
return NULL; return NULL;
sport++; if (mux)
dport++; {
/* RTP/RTCP mux: duplicate the socket */
#ifndef WIN32
fd = dup (rtp_fd);
#else
WSAPROTOCOL_INFO info;
WSADuplicateSocket (rtp_fd, GetProcessId (), &info);
fd = WSASocket (info.iAddressFamily, info.iSockets, info.iProtocol,
&info, 0, 0);
#endif
}
else
{
/* RTCP on a separate port */
char dst[NI_MAXNUMERICHOST];
int dport;
if (net_GetPeerAddress (rtp_fd, dst, &dport))
return NULL;
sport++;
dport++;
fd = net_OpenDgram (obj, src, sport, dst, dport, AF_UNSPEC, proto);
}
fd = net_OpenDgram (obj, src, sport, dst, dport, AF_UNSPEC, proto);
if (fd == -1) if (fd == -1)
return NULL; return NULL;
......
...@@ -1421,7 +1421,7 @@ static inline void rtp_packetize_send( sout_stream_id_t *id, block_t *out ) ...@@ -1421,7 +1421,7 @@ static inline void rtp_packetize_send( sout_stream_id_t *id, block_t *out )
int rtp_add_sink( sout_stream_id_t *id, int fd ) int rtp_add_sink( sout_stream_id_t *id, int fd )
{ {
rtp_sink_t sink = { fd, NULL }; rtp_sink_t sink = { fd, NULL };
sink.rtcp = OpenRTCP( VLC_OBJECT( id->p_stream ), fd, IPPROTO_UDP ); sink.rtcp = OpenRTCP( VLC_OBJECT( id->p_stream ), fd, IPPROTO_UDP, 0 );
if( sink.rtcp == NULL ) if( sink.rtcp == NULL )
msg_Err( id, "RTCP failed!" ); msg_Err( id, "RTCP failed!" );
......
...@@ -41,6 +41,7 @@ void rtp_del_sink( sout_stream_id_t *id, int fd ); ...@@ -41,6 +41,7 @@ void rtp_del_sink( sout_stream_id_t *id, int fd );
/* RTCP */ /* RTCP */
typedef struct rtcp_sender_t rtcp_sender_t; typedef struct rtcp_sender_t rtcp_sender_t;
rtcp_sender_t *OpenRTCP (vlc_object_t *obj, int rtp_fd, int proto); rtcp_sender_t *OpenRTCP (vlc_object_t *obj, int rtp_fd, int proto,
vlc_bool_t mux);
void CloseRTCP (rtcp_sender_t *rtcp); void CloseRTCP (rtcp_sender_t *rtcp);
void SendRTCP (rtcp_sender_t *restrict rtcp, const block_t *rtp); void SendRTCP (rtcp_sender_t *restrict rtcp, const block_t *rtp);
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment