From f83d9aea339d0e528a8a59819ac044553c50b8f2 Mon Sep 17 00:00:00 2001 From: Christophe Massiot Date: Sun, 16 Jul 2017 01:21:35 +0200 Subject: [PATCH] reordertp: no retx with multicast inputs --- NEWS | 1 + aggregartp.c | 12 ++++++++---- reordertp.c | 15 +++++++++++---- util.c | 11 ++++++++++- util.h | 1 + 5 files changed, 31 insertions(+), 9 deletions(-) diff --git a/NEWS b/NEWS index b5a6ea4..de1e517 100644 --- a/NEWS +++ b/NEWS @@ -1,6 +1,7 @@ Changes between 2.2 and 2.3: ---------------------------- * Fix potential segfault in aggregartp + * Do not do retx in reordertp with multicast inputs Changes between 2.1 and 2.2: ---------------------------- diff --git a/aggregartp.c b/aggregartp.c index dd2bceb..9a69ce4 100644 --- a/aggregartp.c +++ b/aggregartp.c @@ -1,8 +1,7 @@ /***************************************************************************** * aggregartp.c: split an RTP stream for several contribution links ***************************************************************************** - * Copyright (C) 2009, 2011, 2014-2015 VideoLAN - * $Id$ + * Copyright (C) 2009, 2011, 2014-2017 VideoLAN * * Authors: Christophe Massiot * @@ -345,10 +344,15 @@ int main( int i_argc, char **pp_argv ) while ( optind < i_argc ) { + bool b_multicast; + struct opensocket_opt opt; + memset(&opt, 0, sizeof(struct opensocket_opt)); + opt.pb_multicast = &b_multicast; + p_outputs = realloc( p_outputs, ++i_nb_outputs * sizeof(output_t) ); p_outputs[i_nb_outputs - 1].i_fd = i_fd = OpenSocket( pp_argv[optind++], i_ttl, 0, DEFAULT_PORT, - &p_outputs[i_nb_outputs - 1].i_weight, NULL, NULL ); + &p_outputs[i_nb_outputs - 1].i_weight, NULL, &opt ); if ( p_outputs[i_nb_outputs - 1].i_fd == -1 ) { msg_Err( NULL, "unable to open output socket" ); @@ -359,7 +363,7 @@ int main( int i_argc, char **pp_argv ) p_outputs[i_nb_outputs - 1].i_remainder = 0; i_max_weight += p_outputs[i_nb_outputs - 1].i_weight; - if ( i_retx_fd == -1 ) + if ( i_retx_fd == -1 && !b_multicast ) { ADD_RETX } diff --git a/reordertp.c b/reordertp.c index d53da09..8a2416c 100644 --- a/reordertp.c +++ b/reordertp.c @@ -1,8 +1,7 @@ /***************************************************************************** * reordertp.c: rebuild an RTP stream from several aggregated links ***************************************************************************** - * Copyright (C) 2009, 2011, 2014-2015 VideoLAN - * $Id$ + * Copyright (C) 2009, 2011, 2014-2017 VideoLAN * * Authors: Christophe Massiot * @@ -72,6 +71,7 @@ typedef struct input_t { int i_fd; bool b_tcp; + bool b_multicast; block_t *p_block; sockaddr_t peer; } input_t; @@ -241,7 +241,8 @@ static int RetxGetFd(sockaddr_t **pp_sockaddr) i_nb_tries++; i_last_retx_input++; i_last_retx_input %= i_nb_inputs; - if ( p_inputs[i_last_retx_input].peer.so.sa_family != AF_UNSPEC ) + if ( p_inputs[i_last_retx_input].peer.so.sa_family != AF_UNSPEC && + !p_inputs[i_last_retx_input].b_multicast ) break; } @@ -445,11 +446,13 @@ int main( int i_argc, char **pp_argv ) struct pollfd *pfd = NULL; int i_fd; bool b_tcp; + bool b_multicast = false; #define ADD_INPUT \ p_inputs = realloc( p_inputs, ++i_nb_inputs * sizeof(input_t) ); \ p_inputs[i_nb_inputs - 1].i_fd = i_fd; \ p_inputs[i_nb_inputs - 1].b_tcp = b_tcp; \ + p_inputs[i_nb_inputs - 1].b_multicast = b_multicast; \ p_inputs[i_nb_inputs - 1].p_block = NULL; \ p_inputs[i_nb_inputs - 1].peer.so.sa_family = AF_UNSPEC; \ pfd = realloc( pfd, i_nb_inputs * sizeof(struct pollfd) ); \ @@ -533,8 +536,12 @@ int main( int i_argc, char **pp_argv ) while ( optind < i_argc - 1 ) { + struct opensocket_opt opt; + memset(&opt, 0, sizeof(struct opensocket_opt)); + opt.pb_multicast = &b_multicast; + i_fd = OpenSocket( pp_argv[optind], 0, DEFAULT_PORT, 0, NULL, - &b_tcp, NULL ); + &b_tcp, &opt ); if ( i_fd == -1 ) { msg_Err( NULL, "unable to open input %s\n", pp_argv[optind] ); diff --git a/util.c b/util.c index 42012f7..79c5deb 100644 --- a/util.c +++ b/util.c @@ -555,7 +555,7 @@ int OpenSocket( const char *_psz_arg, int i_ttl, uint16_t i_bind_port, socklen_t i_sockaddr_len; bool b_host = false; bool b_raw_packets = false; - in_addr_t i_raw_srcaddr = INADDR_ANY; + in_addr_t i_raw_srcaddr = INADDR_ANY; int i_raw_srcport = 0; char *psz_ifname = NULL; #ifdef __FreeBSD__ @@ -569,6 +569,9 @@ int OpenSocket( const char *_psz_arg, int i_ttl, uint16_t i_bind_port, pb_tcp = &b_tcp; *pb_tcp = false; + if ( p_opt != NULL && p_opt->pb_multicast != NULL ) + *p_opt->pb_multicast = false; + psz_token2 = strrchr( psz_arg, ',' ); if ( psz_token2 ) { @@ -780,6 +783,9 @@ int OpenSocket( const char *_psz_arg, int i_ttl, uint16_t i_bind_port, &connect_addr ); exit(EXIT_FAILURE); } + + if ( p_opt != NULL && p_opt->pb_multicast != NULL ) + *p_opt->pb_multicast = true; } else #endif @@ -882,6 +888,9 @@ normal_bind: } #endif } + + if ( p_opt != NULL && p_opt->pb_multicast != NULL ) + *p_opt->pb_multicast = true; } if ( connect_addr.ss.ss_family != AF_UNSPEC ) diff --git a/util.h b/util.h index 2ec019c..1959a2e 100644 --- a/util.h +++ b/util.h @@ -76,6 +76,7 @@ struct udprawpkt { *****************************************************************************/ struct opensocket_opt { struct udprawpkt *p_raw_pktheader; + bool *pb_multicast; }; -- GitLab