Skip to content
Commits on Source (4)
......@@ -50,7 +50,7 @@ multicat_validate: $(OBJ_MULTICAT_VALIDATE)
$(CC) -o $@ $(OBJ_MULTICAT_VALIDATE) $(LDLIBS)
clean:
-rm -f multicat $(OBJ_MULTICAT) ingests $(OBJ_INGESTS) aggregartp $(OBJ_AGGREGARTP) reordertp $(OBJ_REORDERTP) offsets $(OBJ_OFFSETS) lasts $(OBJ_LASTS) multicat_validate
-rm -f multicat $(OBJ_MULTICAT) ingests $(OBJ_INGESTS) aggregartp $(OBJ_AGGREGARTP) reordertp $(OBJ_REORDERTP) offsets $(OBJ_OFFSETS) lasts $(OBJ_LASTS) multicat_validate $(OBJ_MULTICAT_VALIDATE)
install: all
@install -d $(BIN)
......
Changes between 2.2 and 2.3:
----------------------------
* Fix potential segfault in aggregartp
* Do not do retx in reordertp with multicast inputs
* Add support for null weights in aggregartp and reordertp
Changes between 2.1 and 2.2:
----------------------------
* Various portability fixes
......
/*****************************************************************************
* 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 <massiot@via.ecp.fr>
*
......@@ -87,6 +86,7 @@ static void usage(void)
{
msg_Raw( NULL, "Usage: aggregartp [-i <RT priority>] [-l <syslogtag>] [-t <ttl>] [-w] [-o <SSRC IP>] [-U] [-x <retx buffer>] [-X <retx URL>] [-m <payload size>] [-R <RTP header>] @<src host> <dest host 1>[,<weight 1>] ... [<dest host N>,<weight N>]" );
msg_Raw( NULL, " host format: [<connect addr>[:<connect port>]][@[<bind addr][:<bind port>]]" );
msg_Raw( NULL, " weight: integer, higher value means more capacity, or 0 for all packets" );
msg_Raw( NULL, " -w: overwrite RTP timestamps" );
msg_Raw( NULL, " -o: overwrite RTP SSRC" );
msg_Raw( NULL, " -U: prepend RTP header" );
......@@ -140,6 +140,17 @@ static void SendBlock( int i_fd, struct sockaddr *p_sout,
}
}
/*****************************************************************************
* SendBlock0: send a block to all outputs with weight 0
*****************************************************************************/
static void SendBlock0( block_t *p_block )
{
int i;
for ( i = 0; i < i_nb_outputs; i++ )
if ( !p_outputs[i].i_weight )
SendBlock( p_outputs[i].i_fd, NULL, 0, p_block);
}
/*****************************************************************************
* RetxQueue: store a packet in the retx queue
*****************************************************************************/
......@@ -345,10 +356,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,13 +375,13 @@ 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
}
}
msg_Dbg( NULL, "%d outputs weight %u%s", i_nb_outputs, i_max_weight,
i_retx_fd != -1 ? ", with retx" : "" );
i_nb_retx > 1 ? ", with retx" : "" );
p_retx_block = malloc( sizeof(block_t) + RETX_HEADER_SIZE );
p_retx_block->p_data = (uint8_t *)p_retx_block + sizeof(block_t);
......@@ -389,7 +405,7 @@ int main( int i_argc, char **pp_argv )
for ( ; ; )
{
uint64_t i_current_date;
if ( poll( pfd, i_nb_retx + 1, -1 ) < 0 )
if ( poll( pfd, i_nb_retx, -1 ) < 0 )
{
int saved_errno = errno;
msg_Warn( NULL, "couldn't poll(): %s", strerror(errno) );
......@@ -472,13 +488,18 @@ int main( int i_argc, char **pp_argv )
}
/* Output block */
output_t *p_output = NextOutput();
SendBlock( p_output->i_fd, NULL, 0, p_input_block );
SendBlock0( p_input_block );
p_output->i_weighted_size += (i_size + p_output->i_remainder)
/ p_output->i_weight;
p_output->i_remainder = (i_size + p_output->i_remainder)
% p_output->i_weight;
if ( i_max_weight )
{
output_t *p_output = NextOutput();
SendBlock( p_output->i_fd, NULL, 0, p_input_block );
p_output->i_weighted_size += (i_size + p_output->i_remainder)
/ p_output->i_weight;
p_output->i_remainder = (i_size + p_output->i_remainder)
% p_output->i_weight;
}
RetxQueue( p_input_block, i_current_date );
p_input_block = NULL;
......@@ -490,11 +511,11 @@ int main( int i_argc, char **pp_argv )
}
int i;
for ( i = 0; i < i_nb_retx; i++ )
for ( i = 1; i < i_nb_retx; i++ )
{
if ( pfd[i + 1].revents & POLLIN )
if ( pfd[i].revents & POLLIN )
{
RetxHandle( pfd[i + 1].fd );
RetxHandle( pfd[i].fd );
}
}
}
......
/*****************************************************************************
* 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 <massiot@via.ecp.fr>
*
......@@ -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;
......@@ -83,6 +83,7 @@ static int i_output_fd;
static input_t *p_inputs = NULL;
static int i_nb_inputs = 0;
static int b_udp = 0;
static int b_redundance = 0;
static block_t *p_first = NULL;
static block_t **pp_retx = NULL;
......@@ -114,9 +115,10 @@ static int i_last_retx_input = 0;
static void usage(void)
{
msg_Raw( NULL, "Usage: reordertp [-i <RT priority>] [-l <syslogtag>] [-t <ttl>] [-b <buffer length>] [-U] [-g <max gap>] [-j <max jitter>] [-r <# of clock ref>] [-n <max retx burst>] [-x <reorder/retx delay>] [-X <retx URL>] [-m <payload size>] [-R <RTP header>] <src host 1> ... [<src host N>] <dest host>" );
msg_Raw( NULL, "Usage: reordertp [-i <RT priority>] [-l <syslogtag>] [-t <ttl>] [-b <buffer length>] [-U] [-D] [-g <max gap>] [-j <max jitter>] [-r <# of clock ref>] [-n <max retx burst>] [-x <reorder/retx delay>] [-X <retx URL>] [-m <payload size>] [-R <RTP header>] <src host 1> ... [<src host N>] <dest host>" );
msg_Raw( NULL, " host format: [<connect addr>[:<connect port>]][@[<bind addr][:<bind port>]]" );
msg_Raw( NULL, " -U: strip RTP header" );
msg_Raw( NULL, " -D: input has redundant packets" );
msg_Raw( NULL, " -b: buffer length in ms [default 400]" );
msg_Raw( NULL, " -g: max gap between two clock references in ms [default 300]" );
msg_Raw( NULL, " -j: max jitter in ms [default 150]" );
......@@ -241,7 +243,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;
}
......@@ -281,7 +284,9 @@ static void RetxCheck( uint64_t i_current_date )
if ( i_current_seqnum == i_prev_seqnum )
{
msg_Dbg( NULL, "duplicate RTP packet %hu", i_current_seqnum );
if ( !b_redundance )
msg_Dbg( NULL, "duplicate RTP packet %hu",
i_current_seqnum );
RetxDereference( p_current );
free( p_current );
continue;
......@@ -445,18 +450,20 @@ 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) ); \
pfd[i_nb_inputs - 1].fd = i_fd; \
pfd[i_nb_inputs - 1].events = POLLIN | POLLERR | POLLRDHUP | POLLHUP;
while ( (c = getopt( i_argc, pp_argv, "i:l:t:b:g:j:r:n:x:X:Um:R:h" )) != -1 )
while ( (c = getopt( i_argc, pp_argv, "i:l:t:b:g:j:r:n:x:X:UDm:R:h" )) != -1 )
{
switch ( c )
{
......@@ -511,6 +518,10 @@ int main( int i_argc, char **pp_argv )
b_udp = 1;
break;
case 'D':
b_redundance = 1;
break;
case 'm':
i_asked_payload_size = strtol( optarg, NULL, 0 );
break;
......@@ -533,8 +544,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] );
......
......@@ -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 )
......
......@@ -76,6 +76,7 @@ struct udprawpkt {
*****************************************************************************/
struct opensocket_opt {
struct udprawpkt *p_raw_pktheader;
bool *pb_multicast;
};
......