Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
10
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Open sidebar
VideoLAN
multicat
Commits
81cbec21
Commit
81cbec21
authored
Jul 15, 2015
by
Christophe Massiot
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add -l option for syslog logging
parent
41c95b65
Changes
7
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
148 additions
and
32 deletions
+148
-32
aggregartp.c
aggregartp.c
+15
-4
ingests.c
ingests.c
+15
-3
multicat.c
multicat.c
+15
-4
multicat_validate.c
multicat_validate.c
+15
-3
reordertp.c
reordertp.c
+15
-3
util.c
util.c
+70
-14
util.h
util.h
+3
-1
No files found.
aggregartp.c
View file @
81cbec21
/*****************************************************************************
* aggregartp.c: split an RTP stream for several contribution links
*****************************************************************************
* Copyright (C) 2009, 2011, 2014 VideoLAN
* Copyright (C) 2009, 2011, 2014
-2015
VideoLAN
* $Id$
*
* Authors: Christophe Massiot <massiot@via.ecp.fr>
...
...
@@ -36,6 +36,7 @@
#include <arpa/inet.h>
#include <pthread.h>
#include <poll.h>
#include <syslog.h>
#include <bitstream/ietf/rtp.h>
...
...
@@ -84,7 +85,7 @@ static uint64_t i_retx_buffer = DEFAULT_RETX_BUFFER * 27000;
static
void
usage
(
void
)
{
msg_Raw
(
NULL
,
"Usage: aggregartp [-i <RT priority>] [-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
,
"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
,
" -w: overwrite RTP timestamps"
);
msg_Raw
(
NULL
,
" -o: overwrite RTP SSRC"
);
...
...
@@ -249,6 +250,7 @@ int main( int i_argc, char **pp_argv )
{
int
c
;
int
i_priority
=
-
1
;
const
char
*
psz_syslog_tag
=
NULL
;
int
i_ttl
=
0
;
bool
b_udp
=
false
;
struct
pollfd
*
pfd
=
malloc
(
sizeof
(
struct
pollfd
));
...
...
@@ -260,7 +262,7 @@ int main( int i_argc, char **pp_argv )
pfd[i_nb_retx - 1].fd = i_fd; \
pfd[i_nb_retx - 1].events = POLLIN;
while
(
(
c
=
getopt
(
i_argc
,
pp_argv
,
"i:t:wo:x:X:Um:R:h"
))
!=
-
1
)
while
(
(
c
=
getopt
(
i_argc
,
pp_argv
,
"i:
l:
t:wo:x:X:Um:R:h"
))
!=
-
1
)
{
switch
(
c
)
{
...
...
@@ -268,6 +270,10 @@ int main( int i_argc, char **pp_argv )
i_priority
=
strtol
(
optarg
,
NULL
,
0
);
break
;
case
'l'
:
psz_syslog_tag
=
optarg
;
break
;
case
't'
:
i_ttl
=
strtol
(
optarg
,
NULL
,
0
);
break
;
...
...
@@ -326,6 +332,9 @@ int main( int i_argc, char **pp_argv )
if
(
optind
>=
i_argc
-
1
)
usage
();
if
(
psz_syslog_tag
!=
NULL
)
msg_Openlog
(
psz_syslog_tag
,
LOG_NDELAY
,
LOG_USER
);
i_input_fd
=
OpenSocket
(
pp_argv
[
optind
],
0
,
DEFAULT_PORT
,
0
,
NULL
,
&
b_input_tcp
,
NULL
);
if
(
i_input_fd
==
-
1
)
...
...
@@ -490,6 +499,8 @@ int main( int i_argc, char **pp_argv )
}
}
if
(
psz_syslog_tag
!=
NULL
)
msg_Closelog
();
return
EXIT_SUCCESS
;
}
ingests.c
View file @
81cbec21
/*****************************************************************************
* ingests.c: create the aux file for a transport stream file
*****************************************************************************
* Copyright (C) 2009, 2011 VideoLAN
* Copyright (C) 2009, 2011
, 2015
VideoLAN
* $Id$
*
* Authors: Christophe Massiot <massiot@via.ecp.fr>
...
...
@@ -30,6 +30,7 @@
#include <stdbool.h>
#include <string.h>
#include <errno.h>
#include <syslog.h>
#include <bitstream/mpeg/ts.h>
...
...
@@ -59,7 +60,7 @@ static uint64_t i_last_stc = 0;
static
void
usage
(
void
)
{
msg_Raw
(
NULL
,
"Usage: ingests -p <PCR PID> [-m <payload size>] <input ts>"
);
msg_Raw
(
NULL
,
"Usage: ingests
[-l <syslogtag>]
-p <PCR PID> [-m <payload size>] <input ts>"
);
exit
(
EXIT_FAILURE
);
}
...
...
@@ -184,6 +185,7 @@ static void TSHandle( uint8_t *p_ts )
*****************************************************************************/
int
main
(
int
i_argc
,
char
**
pp_argv
)
{
const
char
*
psz_syslog_tag
=
NULL
;
uint8_t
*
p_buffer
;
unsigned
int
i_payload_size
=
DEFAULT_PAYLOAD_SIZE
;
mode_t
i_mode
;
...
...
@@ -192,11 +194,15 @@ int main( int i_argc, char **pp_argv )
{
int
c
;
if
(
(
c
=
getopt
(
i_argc
,
pp_argv
,
"p:m:h"
))
==
-
1
)
if
(
(
c
=
getopt
(
i_argc
,
pp_argv
,
"
l:
p:m:h"
))
==
-
1
)
break
;
switch
(
c
)
{
case
'l'
:
psz_syslog_tag
=
optarg
;
break
;
case
'p'
:
i_pcr_pid
=
strtoul
(
optarg
,
NULL
,
0
);
break
;
...
...
@@ -220,6 +226,9 @@ int main( int i_argc, char **pp_argv )
if
(
optind
>=
i_argc
||
!
i_pcr_pid
)
usage
();
if
(
psz_syslog_tag
!=
NULL
)
msg_Openlog
(
psz_syslog_tag
,
LOG_NDELAY
,
LOG_USER
);
i_mode
=
StatFile
(
pp_argv
[
optind
]
);
if
(
S_ISCHR
(
i_mode
)
||
S_ISFIFO
(
i_mode
)
||
S_ISDIR
(
i_mode
)
)
usage
();
...
...
@@ -262,6 +271,9 @@ int main( int i_argc, char **pp_argv )
fclose
(
p_output_aux
);
close
(
i_fd
);
if
(
psz_syslog_tag
!=
NULL
)
msg_Closelog
();
return
0
;
}
multicat.c
View file @
81cbec21
/*****************************************************************************
* multicat.c: netcat-equivalent for multicast
*****************************************************************************
* Copyright (C) 2009, 2011-2012 VideoLAN
* Copyright (C) 2009, 2011-2012
, 2015
VideoLAN
* $Id$
*
* Authors: Christophe Massiot <massiot@via.ecp.fr>
...
...
@@ -42,6 +42,7 @@
#include <pthread.h>
#include <poll.h>
#include <sys/ioctl.h>
#include <syslog.h>
#ifdef SIOCGSTAMPNS
# define HAVE_TIMESTAMPS
...
...
@@ -93,7 +94,7 @@ void (*pf_ExitWrite)(void);
static
void
usage
(
void
)
{
msg_Raw
(
NULL
,
"Usage: multicat [-i <RT priority>] [-t <ttl>] [-X] [-T <file name>] [-f] [-p <PCR PID>] [-s <chunks>] [-n <chunks>] [-k <start time>] [-d <duration>] [-a] [-r <file duration>] [-S <SSRC IP>] [-u] [-U] [-m <payload size>] [-R <RTP header size>] [-w] <input item> <output item>"
);
msg_Raw
(
NULL
,
"Usage: multicat [-i <RT priority>]
[-l <syslogtag>]
[-t <ttl>] [-X] [-T <file name>] [-f] [-p <PCR PID>] [-s <chunks>] [-n <chunks>] [-k <start time>] [-d <duration>] [-a] [-r <file duration>] [-S <SSRC IP>] [-u] [-U] [-m <payload size>] [-R <RTP header size>] [-w] <input item> <output item>"
);
msg_Raw
(
NULL
,
" item format: <file path | device path | FIFO path | directory path | network host>"
);
msg_Raw
(
NULL
,
" host format: [<connect addr>[:<connect port>]][@[<bind addr][:<bind port>]]"
);
msg_Raw
(
NULL
,
" -X: also pass-through all packets to stdout"
);
...
...
@@ -762,6 +763,7 @@ static void GetPCR( const uint8_t *p_buffer, size_t i_read_size )
int
main
(
int
i_argc
,
char
**
pp_argv
)
{
int
i_priority
=
-
1
;
const
char
*
psz_syslog_tag
=
NULL
;
bool
b_passthrough
=
false
;
int
i_stc_fd
=
-
1
;
off_t
i_skip_chunks
=
0
,
i_nb_chunks
=
-
1
;
...
...
@@ -775,7 +777,7 @@ int main( int i_argc, char **pp_argv )
sigset_t
set
;
/* Parse options */
while
(
(
c
=
getopt
(
i_argc
,
pp_argv
,
"i:t:XT:fp:s:n:k:d:ar:S:uUm:R:wh"
))
!=
-
1
)
while
(
(
c
=
getopt
(
i_argc
,
pp_argv
,
"i:
l:
t:XT:fp:s:n:k:d:ar:S:uUm:R:wh"
))
!=
-
1
)
{
switch
(
c
)
{
...
...
@@ -783,6 +785,10 @@ int main( int i_argc, char **pp_argv )
i_priority
=
strtol
(
optarg
,
NULL
,
0
);
break
;
case
'l'
:
psz_syslog_tag
=
optarg
;
break
;
case
't'
:
i_ttl
=
strtol
(
optarg
,
NULL
,
0
);
break
;
...
...
@@ -869,6 +875,9 @@ int main( int i_argc, char **pp_argv )
if
(
optind
>=
i_argc
-
1
)
usage
();
if
(
psz_syslog_tag
!=
NULL
)
msg_Openlog
(
psz_syslog_tag
,
LOG_NDELAY
,
LOG_USER
);
/* Open sockets */
if
(
udp_InitRead
(
pp_argv
[
optind
],
i_asked_payload_size
,
i_skip_chunks
,
i_seek
)
<
0
)
...
...
@@ -1087,6 +1096,8 @@ dropped_packet:
pf_ExitRead
();
pf_ExitWrite
();
if
(
psz_syslog_tag
!=
NULL
)
msg_Closelog
();
return
b_error
?
EXIT_FAILURE
:
EXIT_SUCCESS
;
}
multicat_validate.c
View file @
81cbec21
/*****************************************************************************
* multicat_validate.c: validate position in directory input
*****************************************************************************
* Copyright (C) 2009, 2011 VideoLAN
* Copyright (C) 2009, 2011
, 2015
VideoLAN
* $Id$
*
* Authors: Christophe Massiot <massiot@via.ecp.fr>
...
...
@@ -31,6 +31,7 @@
#include <stdbool.h>
#include <inttypes.h>
#include <string.h>
#include <syslog.h>
#include "util.h"
...
...
@@ -49,7 +50,7 @@ static bool b_status = false;
static
void
usage
(
void
)
{
msg_Raw
(
NULL
,
"Usage: multicat_validate [-k <start time>] [-r <file duration>] [-W <tolerance>] [-m <payload size>] <input directory>"
);
msg_Raw
(
NULL
,
"Usage: multicat_validate
[-l <syslogtag>]
[-k <start time>] [-r <file duration>] [-W <tolerance>] [-m <payload size>] <input directory>"
);
msg_Raw
(
NULL
,
" -k: start at the given position (in 27 MHz units, negative = from the end)"
);
msg_Raw
(
NULL
,
" -r: in directory mode, rotate file after this duration (default: 97200000000 ticks = 1 hour)"
);
msg_Raw
(
NULL
,
" -W: maximum tolerated wait time before the forthcoming packet (by default: 27000000 ticks = 1 second)"
);
...
...
@@ -97,6 +98,7 @@ retry:
*****************************************************************************/
int
main
(
int
i_argc
,
char
**
pp_argv
)
{
const
char
*
psz_syslog_tag
=
NULL
;
off_t
i_nb_skipped_chunks
;
FILE
*
p_input_aux
;
int
c
;
...
...
@@ -104,10 +106,14 @@ int main( int i_argc, char **pp_argv )
setvbuf
(
stdout
,
NULL
,
_IOLBF
,
0
);
while
(
(
c
=
getopt
(
i_argc
,
pp_argv
,
"k:r:W:m:h"
))
!=
-
1
)
while
(
(
c
=
getopt
(
i_argc
,
pp_argv
,
"
l:
k:r:W:m:h"
))
!=
-
1
)
{
switch
(
c
)
{
case
'l'
:
psz_syslog_tag
=
optarg
;
break
;
case
'k'
:
i_delay
=
strtoull
(
optarg
,
NULL
,
0
);
break
;
...
...
@@ -135,6 +141,9 @@ int main( int i_argc, char **pp_argv )
psz_dir_name
=
pp_argv
[
optind
];
printf
(
"0
\n
"
);
if
(
psz_syslog_tag
!=
NULL
)
msg_Openlog
(
psz_syslog_tag
,
LOG_NDELAY
,
LOG_USER
);
if
(
i_delay
<=
0
)
{
i_delay
*=
-
1
;
...
...
@@ -196,4 +205,7 @@ int main( int i_argc, char **pp_argv )
HandleSTC
(
i_stc
);
}
if
(
psz_syslog_tag
!=
NULL
)
msg_Closelog
();
}
reordertp.c
View file @
81cbec21
/*****************************************************************************
* reordertp.c: rebuild an RTP stream from several aggregated links
*****************************************************************************
* Copyright (C) 2009, 2011, 2014 VideoLAN
* Copyright (C) 2009, 2011, 2014
-2015
VideoLAN
* $Id$
*
* Authors: Christophe Massiot <massiot@via.ecp.fr>
...
...
@@ -36,6 +36,7 @@
#include <arpa/inet.h>
#include <pthread.h>
#include <poll.h>
#include <syslog.h>
#include <bitstream/ietf/rtp.h>
...
...
@@ -113,7 +114,7 @@ static int i_last_retx_input = 0;
static
void
usage
(
void
)
{
msg_Raw
(
NULL
,
"Usage: reordertp [-i <RT priority>] [-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] [-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
,
" -b: buffer length in ms [default 400]"
);
...
...
@@ -439,6 +440,7 @@ int main( int i_argc, char **pp_argv )
{
int
i
,
c
;
int
i_priority
=
-
1
;
const
char
*
psz_syslog_tag
=
NULL
;
int
i_ttl
=
0
;
struct
pollfd
*
pfd
=
NULL
;
int
i_fd
;
...
...
@@ -454,7 +456,7 @@ int main( int i_argc, char **pp_argv )
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: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:Um:R:h"
))
!=
-
1
)
{
switch
(
c
)
{
...
...
@@ -462,6 +464,10 @@ int main( int i_argc, char **pp_argv )
i_priority
=
strtol
(
optarg
,
NULL
,
0
);
break
;
case
'l'
:
psz_syslog_tag
=
optarg
;
break
;
case
't'
:
i_ttl
=
strtol
(
optarg
,
NULL
,
0
);
break
;
...
...
@@ -522,6 +528,9 @@ int main( int i_argc, char **pp_argv )
if
(
optind
>=
i_argc
-
1
)
usage
();
if
(
psz_syslog_tag
!=
NULL
)
msg_Openlog
(
psz_syslog_tag
,
LOG_NDELAY
,
LOG_USER
);
while
(
optind
<
i_argc
-
1
)
{
i_fd
=
OpenSocket
(
pp_argv
[
optind
],
0
,
DEFAULT_PORT
,
0
,
NULL
,
...
...
@@ -656,6 +665,9 @@ int main( int i_argc, char **pp_argv )
}
}
if
(
psz_syslog_tag
!=
NULL
)
msg_Closelog
();
return
EXIT_SUCCESS
;
}
util.c
View file @
81cbec21
/*****************************************************************************
* util.c: Utils for the multicat suite
*****************************************************************************
* Copyright (C) 2004, 2009, 2011 VideoLAN
* Copyright (C) 2004, 2009, 2011
, 2015
VideoLAN
* $Id$
*
* Authors: Christophe Massiot <massiot@via.ecp.fr>
...
...
@@ -42,6 +42,7 @@
#include <unistd.h>
#include <sys/mman.h>
#include <netdb.h>
#include <syslog.h>
#include "util.h"
...
...
@@ -55,6 +56,25 @@
#define PSZ_TS_EXT "ts"
int
i_verbose
=
VERB_DBG
;
static
int
b_syslog
=
0
;
/*****************************************************************************
* msg_Openlog
*****************************************************************************/
void
msg_Openlog
(
const
char
*
ident
,
int
option
,
int
facility
)
{
openlog
(
ident
,
option
,
facility
);
b_syslog
=
1
;
}
/*****************************************************************************
* msg_Closelog
*****************************************************************************/
void
msg_Closelog
(
void
)
{
closelog
();
b_syslog
=
0
;
}
/*****************************************************************************
* msg_Info
...
...
@@ -62,14 +82,23 @@ int i_verbose = VERB_DBG;
void
msg_Info
(
void
*
_unused
,
const
char
*
psz_format
,
...
)
{
if
(
i_verbose
>=
VERB_INFO
)
return
;
va_list
args
;
va_start
(
args
,
psz_format
);
if
(
!
b_syslog
)
{
va_list
args
;
char
psz_fmt
[
MAX_MSG
];
va_start
(
args
,
psz_format
);
snprintf
(
psz_fmt
,
MAX_MSG
,
"info: %s
\n
"
,
psz_format
);
vfprintf
(
stderr
,
psz_fmt
,
args
);
}
else
{
vsyslog
(
LOG_INFO
,
psz_format
,
args
);
}
va_end
(
args
);
}
/*****************************************************************************
...
...
@@ -78,11 +107,20 @@ void msg_Info( void *_unused, const char *psz_format, ... )
void
msg_Err
(
void
*
_unused
,
const
char
*
psz_format
,
...
)
{
va_list
args
;
char
psz_fmt
[
MAX_MSG
];
va_start
(
args
,
psz_format
);
snprintf
(
psz_fmt
,
MAX_MSG
,
"error: %s
\n
"
,
psz_format
);
vfprintf
(
stderr
,
psz_fmt
,
args
);
if
(
!
b_syslog
)
{
char
psz_fmt
[
MAX_MSG
];
snprintf
(
psz_fmt
,
MAX_MSG
,
"error: %s
\n
"
,
psz_format
);
vfprintf
(
stderr
,
psz_fmt
,
args
);
}
else
{
vsyslog
(
LOG_ERR
,
psz_format
,
args
);
}
va_end
(
args
);
}
/*****************************************************************************
...
...
@@ -91,14 +129,23 @@ void msg_Err( void *_unused, const char *psz_format, ... )
void
msg_Warn
(
void
*
_unused
,
const
char
*
psz_format
,
...
)
{
if
(
i_verbose
>=
VERB_WARN
)
return
;
va_list
args
;
va_start
(
args
,
psz_format
);
if
(
!
b_syslog
)
{
va_list
args
;
char
psz_fmt
[
MAX_MSG
];
va_start
(
args
,
psz_format
);
snprintf
(
psz_fmt
,
MAX_MSG
,
"warning: %s
\n
"
,
psz_format
);
vfprintf
(
stderr
,
psz_fmt
,
args
);
}
else
{
vsyslog
(
LOG_WARNING
,
psz_format
,
args
);
}
va_end
(
args
);
}
/*****************************************************************************
...
...
@@ -107,18 +154,27 @@ void msg_Warn( void *_unused, const char *psz_format, ... )
void
msg_Dbg
(
void
*
_unused
,
const
char
*
psz_format
,
...
)
{
if
(
i_verbose
>=
VERB_DBG
)
return
;
va_list
args
;
va_start
(
args
,
psz_format
);
if
(
!
b_syslog
)
{
va_list
args
;
char
psz_fmt
[
MAX_MSG
];
va_start
(
args
,
psz_format
);
snprintf
(
psz_fmt
,
MAX_MSG
,
"debug: %s
\n
"
,
psz_format
);
vfprintf
(
stderr
,
psz_fmt
,
args
);
}
else
{
vsyslog
(
LOG_DEBUG
,
psz_format
,
args
);
}
va_end
(
args
);
}
/*****************************************************************************
* msg_Raw
* msg_Raw
: only used for usage()
*****************************************************************************/
void
msg_Raw
(
void
*
_unused
,
const
char
*
psz_format
,
...
)
{
...
...
util.h
View file @
81cbec21
/*****************************************************************************
* util.h: Utils for the multicat suite
*****************************************************************************
* Copyright (C) 2009, 2011, 2014 VideoLAN
* Copyright (C) 2009, 2011, 2014
-2015
VideoLAN
* $Id$
*
* Authors: Christophe Massiot <massiot@via.ecp.fr>
...
...
@@ -74,6 +74,8 @@ struct udprawpkt {
/*****************************************************************************
* Prototypes
*****************************************************************************/
void
msg_Openlog
(
const
char
*
ident
,
int
option
,
int
facility
);
void
msg_Closelog
(
void
);
void
msg_Info
(
void
*
_unused
,
const
char
*
psz_format
,
...
);
void
msg_Err
(
void
*
_unused
,
const
char
*
psz_format
,
...
);
void
msg_Warn
(
void
*
_unused
,
const
char
*
psz_format
,
...
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment