Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
L
libdvbpsi
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Redmine
Redmine
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Metrics
Environments
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
videolan
libdvbpsi
Commits
fbd3e6ee
Commit
fbd3e6ee
authored
Sep 09, 2014
by
Jean-Paul Saman
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
dvbinfo: make capture fifo buffersize configurable.
parent
031aae51
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
29 additions
and
7 deletions
+29
-7
examples/dvbinfo/dvbinfo.c
examples/dvbinfo/dvbinfo.c
+26
-7
examples/dvbinfo/dvbinfo.h
examples/dvbinfo/dvbinfo.h
+3
-0
No files found.
examples/dvbinfo/dvbinfo.c
View file @
fbd3e6ee
...
@@ -113,7 +113,7 @@ typedef struct dvbinfo_capture_s
...
@@ -113,7 +113,7 @@ typedef struct dvbinfo_capture_s
static
void
usage
(
void
)
static
void
usage
(
void
)
{
{
#ifdef HAVE_SYS_SOCKET_H
#ifdef HAVE_SYS_SOCKET_H
printf
(
"Usage: dvbinfo [-h] [-d <debug>] [-f
|-m
| [[-u|-t] -a <mcast_interface> -i <ipaddress:port>] -o <outputfile>
\n
"
);
printf
(
"Usage: dvbinfo [-h] [-d <debug>] [-f
<filename> | -m | -c <bufsize>
| [[-u|-t] -a <mcast_interface> -i <ipaddress:port>] -o <outputfile>
\n
"
);
printf
(
" [-s [bandwidth|table|packet] --summary-file <file> --summary-period <ms>]
\n
"
);
printf
(
" [-s [bandwidth|table|packet] --summary-file <file> --summary-period <ms>]
\n
"
);
#else
#else
printf
(
"Usage: dvbinfo [-h] [-d <debug>] [-f|
\n
"
);
printf
(
"Usage: dvbinfo [-h] [-d <debug>] [-f|
\n
"
);
...
@@ -139,6 +139,8 @@ static void usage(void)
...
@@ -139,6 +139,8 @@ static void usage(void)
// printf(" wire = print arrival time per packet (wireshark like)\n");
// printf(" wire = print arrival time per packet (wireshark like)\n");
printf
(
" -j | --summary-file : file to write summary information to (default: stdout)
\n
"
);
printf
(
" -j | --summary-file : file to write summary information to (default: stdout)
\n
"
);
printf
(
" -p | --summary-period : refresh summary file every n milliseconds (default: 1000ms)
\n
"
);
printf
(
" -p | --summary-period : refresh summary file every n milliseconds (default: 1000ms)
\n
"
);
printf
(
"
\n
Tuing options:
\n
"
);
printf
(
" -c | --capture buffer size : number of bytes in capture buffer (default: %d bytes)
\n
"
,
FIFO_THRESHOLD_SIZE
);
#endif
#endif
exit
(
EXIT_FAILURE
);
exit
(
EXIT_FAILURE
);
}
}
...
@@ -200,6 +202,9 @@ static params_t *params_init(void)
...
@@ -200,6 +202,9 @@ static params_t *params_init(void)
param
->
b_verbose
=
false
;
param
->
b_verbose
=
false
;
param
->
b_monitor
=
false
;
param
->
b_monitor
=
false
;
/* tuning options */
param
->
threshold
=
FIFO_THRESHOLD_SIZE
;
/* statistics */
/* statistics */
param
->
b_summary
=
false
;
param
->
b_summary
=
false
;
param
->
summary
.
mode
=
SUM_BANDWIDTH
;
param
->
summary
.
mode
=
SUM_BANDWIDTH
;
...
@@ -311,7 +316,7 @@ static void *dvbinfo_capture(void *data)
...
@@ -311,7 +316,7 @@ static void *dvbinfo_capture(void *data)
buffer
->
i_date
=
mdate
();
buffer
->
i_date
=
mdate
();
/* check fifo size */
/* check fifo size */
if
(
fifo_size
(
capture
->
fifo
)
>=
FIFO_THRESHOLD_SIZE
)
if
(
fifo_size
(
capture
->
fifo
)
>=
param
->
threshold
)
{
{
pthread_mutex_lock
(
&
capture
->
lock
);
pthread_mutex_lock
(
&
capture
->
lock
);
capture
->
b_fifo_full
=
true
;
capture
->
b_fifo_full
=
true
;
...
@@ -328,7 +333,7 @@ static void *dvbinfo_capture(void *data)
...
@@ -328,7 +333,7 @@ static void *dvbinfo_capture(void *data)
else
else
{
{
libdvbpsi_log
(
capture
->
params
,
DVBINFO_LOG_ERROR
,
libdvbpsi_log
(
capture
->
params
,
DVBINFO_LOG_ERROR
,
"error fifo full discarding buffer"
);
"error fifo full discarding buffer
\n
"
);
fifo_push
(
capture
->
empty
,
buffer
);
fifo_push
(
capture
->
empty
,
buffer
);
continue
;
continue
;
}
}
...
@@ -385,13 +390,13 @@ static int dvbinfo_process(dvbinfo_capture_t *capture)
...
@@ -385,13 +390,13 @@ static int dvbinfo_process(dvbinfo_capture_t *capture)
if
(
size
<
0
)
/* error writing */
if
(
size
<
0
)
/* error writing */
{
{
libdvbpsi_log
(
param
,
DVBINFO_LOG_ERROR
,
libdvbpsi_log
(
param
,
DVBINFO_LOG_ERROR
,
"error (%d) writting to %s"
,
errno
,
param
->
output
);
"error (%d) writting to %s
\n
"
,
errno
,
param
->
output
);
break
;
break
;
}
}
else
if
((
size_t
)
size
<
buffer
->
i_size
)
/* short writting disk full? */
else
if
((
size_t
)
size
<
buffer
->
i_size
)
/* short writting disk full? */
{
{
libdvbpsi_log
(
param
,
DVBINFO_LOG_ERROR
,
libdvbpsi_log
(
param
,
DVBINFO_LOG_ERROR
,
"error writting to %s (disk full?)"
,
param
->
output
);
"error writting to %s (disk full?)
\n
"
,
param
->
output
);
break
;
break
;
}
}
}
}
...
@@ -434,7 +439,7 @@ static int dvbinfo_process(dvbinfo_capture_t *capture)
...
@@ -434,7 +439,7 @@ static int dvbinfo_process(dvbinfo_capture_t *capture)
buffer
=
NULL
;
buffer
=
NULL
;
/* check fifo size */
/* check fifo size */
if
(
fifo_size
(
capture
->
fifo
)
<
FIFO_THRESHOLD_SIZE
)
if
(
fifo_size
(
capture
->
fifo
)
<
param
->
threshold
)
{
{
pthread_mutex_lock
(
&
capture
->
lock
);
pthread_mutex_lock
(
&
capture
->
lock
);
capture
->
b_fifo_full
=
false
;
capture
->
b_fifo_full
=
false
;
...
@@ -503,11 +508,13 @@ int main(int argc, char **pp_argv)
...
@@ -503,11 +508,13 @@ int main(int argc, char **pp_argv)
{
"summary"
,
required_argument
,
NULL
,
's'
},
{
"summary"
,
required_argument
,
NULL
,
's'
},
{
"summary-file"
,
required_argument
,
NULL
,
'j'
},
{
"summary-file"
,
required_argument
,
NULL
,
'j'
},
{
"summary-period"
,
required_argument
,
NULL
,
'p'
},
{
"summary-period"
,
required_argument
,
NULL
,
'p'
},
/* - tuning options - */
{
"capturesize"
,
required_argument
,
NULL
,
'c'
},
#endif
#endif
{
NULL
,
0
,
NULL
,
0
}
{
NULL
,
0
,
NULL
,
0
}
};
};
#ifdef HAVE_SYS_SOCKET_H
#ifdef HAVE_SYS_SOCKET_H
while
((
c
=
getopt_long
(
argc
,
pp_argv
,
"a:d:f:i:j:ho:p:ms:tu"
,
long_options
,
NULL
))
!=
-
1
)
while
((
c
=
getopt_long
(
argc
,
pp_argv
,
"a:
c:
d:f:i:j:ho:p:ms:tu"
,
long_options
,
NULL
))
!=
-
1
)
#else
#else
while
((
c
=
getopt_long
(
argc
,
pp_argv
,
"d:f:h"
,
long_options
,
NULL
))
!=
-
1
)
while
((
c
=
getopt_long
(
argc
,
pp_argv
,
"d:f:h"
,
long_options
,
NULL
))
!=
-
1
)
#endif
#endif
...
@@ -600,6 +607,18 @@ int main(int argc, char **pp_argv)
...
@@ -600,6 +607,18 @@ int main(int argc, char **pp_argv)
param
->
pf_read
=
udp_read
;
param
->
pf_read
=
udp_read
;
break
;
break
;
/* - tuning options - */
case
'c'
:
param
->
threshold
=
strtoul
(
optarg
,
NULL
,
10
);
if
(((
errno
==
ERANGE
)
&&
(
param
->
threshold
==
ULONG_MAX
))
||
((
errno
!=
0
)
&&
(
param
->
threshold
==
0
)))
{
fprintf
(
stderr
,
"Option --capturesize has invalid content %s
\n
"
,
optarg
);
params_free
(
param
);
usage
();
}
break
;
/* - Statistics */
/* - Statistics */
case
's'
:
case
's'
:
{
{
...
...
examples/dvbinfo/dvbinfo.h
View file @
fbd3e6ee
...
@@ -45,6 +45,9 @@ typedef struct params_s
...
@@ -45,6 +45,9 @@ typedef struct params_s
bool
b_tcp
;
bool
b_tcp
;
bool
b_file
;
bool
b_file
;
/* tuning options */
size_t
threshold
;
/* capture fifo threshold */
/* */
/* */
int
fd_in
;
int
fd_in
;
int
fd_out
;
int
fd_out
;
...
...
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