Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
V
vlc-2-2
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
vlc-2-2
Commits
4d6f7ee7
Commit
4d6f7ee7
authored
Nov 27, 2012
by
Rémi Denis-Courmont
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
dump: clean up and simplify
parent
a4a65a5e
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
44 additions
and
103 deletions
+44
-103
modules/demux/demuxdump.c
modules/demux/demuxdump.c
+44
-103
No files found.
modules/demux/demuxdump.c
View file @
4d6f7ee7
...
@@ -2,7 +2,6 @@
...
@@ -2,7 +2,6 @@
* demuxdump.c : Pseudo demux module for vlc (dump raw stream)
* demuxdump.c : Pseudo demux module for vlc (dump raw stream)
*****************************************************************************
*****************************************************************************
* Copyright (C) 2001-2004 VLC authors and VideoLAN
* Copyright (C) 2001-2004 VLC authors and VideoLAN
* $Id$
*
*
* Authors: Laurent Aimar <fenrir@via.ecp.fr>
* Authors: Laurent Aimar <fenrir@via.ecp.fr>
*
*
...
@@ -21,10 +20,6 @@
...
@@ -21,10 +20,6 @@
* Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
* Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
*****************************************************************************/
*****************************************************************************/
/*****************************************************************************
* Preamble
*****************************************************************************/
#ifdef HAVE_CONFIG_H
#ifdef HAVE_CONFIG_H
# include "config.h"
# include "config.h"
#endif
#endif
...
@@ -34,9 +29,6 @@
...
@@ -34,9 +29,6 @@
#include <vlc_demux.h>
#include <vlc_demux.h>
#include <vlc_fs.h>
#include <vlc_fs.h>
/*****************************************************************************
* Module descriptor
*****************************************************************************/
#define FILE_TEXT N_("Dump filename")
#define FILE_TEXT N_("Dump filename")
#define FILE_LONGTEXT N_( \
#define FILE_LONGTEXT N_( \
"Name of the file to which the raw stream will be dumped." )
"Name of the file to which the raw stream will be dumped." )
...
@@ -61,140 +53,89 @@ vlc_module_begin ()
...
@@ -61,140 +53,89 @@ vlc_module_begin ()
add_shortcut
(
"dump"
)
add_shortcut
(
"dump"
)
vlc_module_end
()
vlc_module_end
()
#define DUMP_BLOCKSIZE 16384
/*****************************************************************************
* Local prototypes
*****************************************************************************/
static
int
Demux
(
demux_t
*
);
static
int
Demux
(
demux_t
*
);
static
int
Control
(
demux_t
*
,
int
,
va_list
);
static
int
Control
(
demux_t
*
,
int
,
va_list
);
#define DUMP_BLOCKSIZE 16384
/**
* Initializes the raw dump pseudo-demuxer.
struct
demux_sys_t
{
char
*
psz_file
;
FILE
*
p_file
;
uint64_t
i_write
;
uint8_t
buffer
[
DUMP_BLOCKSIZE
];
};
/*
* Data reading functions
*/
*/
/*****************************************************************************
* Open: initializes dump structures
*****************************************************************************/
static
int
Open
(
vlc_object_t
*
p_this
)
static
int
Open
(
vlc_object_t
*
p_this
)
{
{
demux_t
*
p_demux
=
(
demux_t
*
)
p_this
;
demux_t
*
p_demux
=
(
demux_t
*
)
p_this
;
demux_sys_t
*
p_sys
;
const
char
*
psz_mode
;
bool
b_append
;
/* Accept only if forced */
/* Accept only if forced */
if
(
!
p_demux
->
b_force
)
if
(
!
p_demux
->
b_force
)
return
VLC_EGENERIC
;
return
VLC_EGENERIC
;
p_demux
->
p_sys
=
p_sys
=
malloc
(
sizeof
(
demux_sys_t
)
);
const
char
*
mode
=
"wb"
;
if
(
!
p_sys
)
if
(
var_InheritBool
(
p_demux
,
"demuxdump-append"
)
)
return
VLC_ENOMEM
;
mode
=
"ab"
;
b_append
=
var_CreateGetBool
(
p_demux
,
"demuxdump-append"
);
if
(
b_append
)
psz_mode
=
"ab"
;
else
psz_mode
=
"wb"
;
p_demux
->
pf_demux
=
Demux
;
p_demux
->
pf_control
=
Control
;
p_sys
->
i_write
=
0
;
char
*
path
=
var_InheritString
(
p_demux
,
"demuxdump-file"
);
p_sys
->
p_file
=
NULL
;
if
(
path
==
NULL
)
p_sys
->
psz_file
=
var_CreateGetString
(
p_demux
,
"demuxdump-file"
);
return
VLC_ENOMEM
;
if
(
*
p_sys
->
psz_file
==
'\0'
)
{
msg_Warn
(
p_demux
,
"no dump file name given"
);
free
(
p_sys
->
psz_file
);
free
(
p_sys
);
return
VLC_EGENERIC
;
}
if
(
!
strcmp
(
p_sys
->
psz_file
,
"-"
)
)
FILE
*
stream
;
if
(
!
strcmp
(
path
,
"-"
)
)
{
{
msg_Info
(
p_demux
,
"dumping raw stream to standard output"
);
msg_Info
(
p_demux
,
"dumping raw stream to standard output"
);
p_sys
->
p_file
=
stdout
;
stream
=
stdout
;
}
}
else
if
(
(
p_sys
->
p_file
=
vlc_fopen
(
p_sys
->
psz_file
,
psz_mode
)
)
==
NULL
)
else
{
{
msg_Err
(
p_demux
,
"cannot create `%s' for writing"
,
p_sys
->
psz_file
);
stream
=
vlc_fopen
(
path
,
mode
);
free
(
p_sys
->
psz_file
);
if
(
stream
==
NULL
)
free
(
p_sys
);
msg_Err
(
p_demux
,
"cannot write `%s': %m"
,
path
);
else
msg_Info
(
p_demux
,
"writing raw stream to file `%s'"
,
path
);
free
(
path
);
if
(
stream
==
NULL
)
return
VLC_EGENERIC
;
return
VLC_EGENERIC
;
}
}
msg_Info
(
p_demux
,
"%s raw stream to file `%s'"
,
b_append
?
"appending"
:
"dumping"
,
p_sys
->
psz_file
);
p_demux
->
p_sys
=
(
void
*
)
stream
;
p_demux
->
pf_demux
=
Demux
;
p_demux
->
pf_control
=
Control
;
return
VLC_SUCCESS
;
return
VLC_SUCCESS
;
}
}
/**
***************************************************************************
/**
*
Close:
*
Destroys the pseudo-demuxer.
*
****************************************************************************
/
*/
static
void
Close
(
vlc_object_t
*
p_this
)
static
void
Close
(
vlc_object_t
*
p_this
)
{
{
demux_t
*
p_demux
=
(
demux_t
*
)
p_this
;
demux_t
*
p_demux
=
(
demux_t
*
)
p_this
;
demux_sys_t
*
p_sys
=
p_demux
->
p_sys
;
FILE
*
stream
=
(
void
*
)
p_demux
->
p_sys
;
msg_Info
(
p_demux
,
"closing %s (%"
PRId64
" KiB dumped)"
,
p_sys
->
psz_file
,
if
(
stream
!=
stdout
)
p_sys
->
i_write
/
1024
);
fclose
(
stream
);
if
(
p_sys
->
p_file
!=
stdout
)
{
fclose
(
p_sys
->
p_file
);
}
free
(
p_sys
->
psz_file
);
free
(
p_sys
);
}
}
/*****************************************************************************
/**
* Demux: reads and demuxes data packets
* Copy data from input stream to dump file.
*****************************************************************************
*/
* Returns -1 in case of error, 0 in case of EOF, 1 otherwise
*****************************************************************************/
static
int
Demux
(
demux_t
*
p_demux
)
static
int
Demux
(
demux_t
*
p_demux
)
{
{
demux_sys_t
*
p_sys
=
p_demux
->
p_sys
;
FILE
*
stream
=
(
void
*
)
p_demux
->
p_sys
;
char
buf
[
DUMP_BLOCKSIZE
];
int
i_data
;
i_data
=
stream_Read
(
p_demux
->
s
,
p_sys
->
buffer
,
DUMP_BLOCKSIZE
);
if
(
i_data
<=
0
)
return
i_data
;
i_data
=
fwrite
(
p_sys
->
buffer
,
1
,
i_data
,
p_sys
->
p_file
);
int
rd
=
stream_Read
(
p_demux
->
s
,
buf
,
sizeof
(
buf
)
);
if
(
rd
<=
0
)
return
rd
;
if
(
i_data
==
0
)
size_t
wr
=
fwrite
(
buf
,
1
,
rd
,
stream
);
if
(
wr
!=
(
size_t
)
rd
)
{
{
msg_Err
(
p_demux
,
"
failed to write data
"
);
msg_Err
(
p_demux
,
"
cannot write data: %m
"
);
return
-
1
;
return
-
1
;
}
}
#if 0
msg_Dbg( p_demux, "dumped %d bytes", i_data );
#endif
p_sys
->
i_write
+=
i_data
;
return
1
;
return
1
;
}
}
/*****************************************************************************
* Demux: reads and demuxes data packets
*****************************************************************************/
static
int
Control
(
demux_t
*
p_demux
,
int
i_query
,
va_list
args
)
static
int
Control
(
demux_t
*
p_demux
,
int
i_query
,
va_list
args
)
{
{
return
demux_vaControlHelper
(
p_demux
->
s
,
0
,
-
1
,
0
,
1
,
i_query
,
args
);
return
demux_vaControlHelper
(
p_demux
->
s
,
0
,
-
1
,
0
,
1
,
i_query
,
args
);
}
}
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