Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
V
vlc
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
Commits
e7a4311d
Commit
e7a4311d
authored
May 26, 2015
by
Rémi Denis-Courmont
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
access_out_file: reorder to avoid forward declarations
parent
07b2c439
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
110 additions
and
132 deletions
+110
-132
modules/access_output/file.c
modules/access_output/file.c
+110
-132
No files found.
modules/access_output/file.c
View file @
e7a4311d
...
...
@@ -46,61 +46,98 @@
#include <vlc_strings.h>
#include <vlc_dialog.h>
#if defined( _WIN32 ) || defined( __OS2__ )
# include <io.h>
#endif
#ifndef _WIN32
# include <unistd.h>
#endif
#ifndef O_LARGEFILE
# define O_LARGEFILE 0
#endif
#define SOUT_CFG_PREFIX "sout-file-"
/*****************************************************************************
*
Module descriptor
*
Read: standard read on a file descriptor.
*****************************************************************************/
static
int
Open
(
vlc_object_t
*
);
static
void
Close
(
vlc_object_t
*
);
static
ssize_t
Read
(
sout_access_out_t
*
p_access
,
block_t
*
p_buffer
)
{
ssize_t
val
;
#define SOUT_CFG_PREFIX "sout-file-"
#define OVERWRITE_TEXT N_("Overwrite existing file")
#define OVERWRITE_LONGTEXT N_( \
"If the file already exists, it will be overwritten.")
#define APPEND_TEXT N_("Append to file")
#define APPEND_LONGTEXT N_( "Append to file if it exists instead " \
"of replacing it.")
#define FORMAT_TEXT N_("Format time and date")
#define FORMAT_LONGTEXT N_("Perform ISO C time and date formatting " \
"on the file path")
#define SYNC_TEXT N_("Synchronous writing")
#define SYNC_LONGTEXT N_( "Open the file with synchronous writing.")
do
val
=
read
(
(
intptr_t
)
p_access
->
p_sys
,
p_buffer
->
p_buffer
,
p_buffer
->
i_buffer
);
while
(
val
==
-
1
&&
errno
==
EINTR
);
return
val
;
}
vlc_module_begin
()
set_description
(
N_
(
"File stream output"
)
)
set_shortname
(
N_
(
"File"
))
set_capability
(
"sout access"
,
50
)
set_category
(
CAT_SOUT
)
s
et_subcategory
(
SUBCAT_SOUT_ACO
)
add_shortcut
(
"file"
,
"stream"
,
"fd"
)
add_bool
(
SOUT_CFG_PREFIX
"overwrite"
,
true
,
OVERWRITE_TEXT
,
OVERWRITE_LONGTEXT
,
true
)
add_bool
(
SOUT_CFG_PREFIX
"append"
,
false
,
APPEND_TEXT
,
APPEND_LONGTEXT
,
true
)
add_bool
(
SOUT_CFG_PREFIX
"format"
,
false
,
FORMAT_TEXT
,
FORMAT_LONGTEXT
,
true
)
#ifdef O_SYNC
add_bool
(
SOUT_CFG_PREFIX
"sync"
,
false
,
SYNC_TEXT
,
SYNC_LONGTEXT
,
false
)
#endif
set_callbacks
(
Open
,
Close
)
vlc_module_end
()
/*****************************************************************************
* Write: standard write on a file descriptor.
*****************************************************************************/
static
ssize_t
Write
(
sout_access_out_t
*
p_access
,
block_t
*
p_buffer
)
{
s
ize_t
i_write
=
0
;
while
(
p_buffer
)
{
ssize_t
val
=
write
((
intptr_t
)
p_access
->
p_sys
,
p_buffer
->
p_buffer
,
p_buffer
->
i_buffer
);
if
(
val
<=
0
)
{
if
(
errno
==
EINTR
)
continue
;
block_ChainRelease
(
p_buffer
);
msg_Err
(
p_access
,
"cannot write: %s"
,
vlc_strerror_c
(
errno
)
);
return
-
1
;
}
if
((
size_t
)
val
>=
p_buffer
->
i_buffer
)
{
block_t
*
p_next
=
p_buffer
->
p_next
;
block_Release
(
p_buffer
);
p_buffer
=
p_next
;
}
else
{
p_buffer
->
p_buffer
+=
val
;
p_buffer
->
i_buffer
-=
val
;
}
i_write
+=
val
;
}
return
i_write
;
}
/*****************************************************************************
*
Exported prototypes
*
Seek: seek to a specific location in a file
*****************************************************************************/
static
int
Seek
(
sout_access_out_t
*
p_access
,
off_t
i_pos
)
{
return
lseek
(
(
intptr_t
)
p_access
->
p_sys
,
i_pos
,
SEEK_SET
);
}
static
int
Control
(
sout_access_out_t
*
p_access
,
int
i_query
,
va_list
args
)
{
switch
(
i_query
)
{
case
ACCESS_OUT_CONTROLS_PACE
:
{
bool
*
pb
=
va_arg
(
args
,
bool
*
);
*
pb
=
strcmp
(
p_access
->
psz_access
,
"stream"
);
break
;
}
case
ACCESS_OUT_CAN_SEEK
:
{
bool
*
pb
=
va_arg
(
args
,
bool
*
);
struct
stat
st
;
if
(
fstat
(
(
intptr_t
)
p_access
->
p_sys
,
&
st
)
==
-
1
)
*
pb
=
false
;
else
*
pb
=
S_ISREG
(
st
.
st_mode
)
||
S_ISBLK
(
st
.
st_mode
);
break
;
}
default:
return
VLC_EGENERIC
;
}
return
VLC_SUCCESS
;
}
static
const
char
*
const
ppsz_sout_options
[]
=
{
"append"
,
"format"
,
...
...
@@ -111,11 +148,6 @@ static const char *const ppsz_sout_options[] = {
NULL
};
static
ssize_t
Write
(
sout_access_out_t
*
,
block_t
*
);
static
int
Seek
(
sout_access_out_t
*
,
off_t
);
static
ssize_t
Read
(
sout_access_out_t
*
,
block_t
*
);
static
int
Control
(
sout_access_out_t
*
,
int
,
va_list
);
/*****************************************************************************
* Open: open the file
*****************************************************************************/
...
...
@@ -238,88 +270,34 @@ static void Close( vlc_object_t * p_this )
msg_Dbg
(
p_access
,
"file access output closed"
);
}
static
int
Control
(
sout_access_out_t
*
p_access
,
int
i_query
,
va_list
args
)
{
switch
(
i_query
)
{
case
ACCESS_OUT_CONTROLS_PACE
:
{
bool
*
pb
=
va_arg
(
args
,
bool
*
);
*
pb
=
strcmp
(
p_access
->
psz_access
,
"stream"
);
break
;
}
case
ACCESS_OUT_CAN_SEEK
:
{
bool
*
pb
=
va_arg
(
args
,
bool
*
);
struct
stat
st
;
if
(
fstat
(
(
intptr_t
)
p_access
->
p_sys
,
&
st
)
==
-
1
)
*
pb
=
false
;
else
*
pb
=
S_ISREG
(
st
.
st_mode
)
||
S_ISBLK
(
st
.
st_mode
);
break
;
}
default:
return
VLC_EGENERIC
;
}
return
VLC_SUCCESS
;
}
/*****************************************************************************
* Read: standard read on a file descriptor.
*****************************************************************************/
static
ssize_t
Read
(
sout_access_out_t
*
p_access
,
block_t
*
p_buffer
)
{
ssize_t
val
;
do
val
=
read
(
(
intptr_t
)
p_access
->
p_sys
,
p_buffer
->
p_buffer
,
p_buffer
->
i_buffer
);
while
(
val
==
-
1
&&
errno
==
EINTR
);
return
val
;
}
/*****************************************************************************
* Write: standard write on a file descriptor.
*****************************************************************************/
static
ssize_t
Write
(
sout_access_out_t
*
p_access
,
block_t
*
p_buffer
)
{
size_t
i_write
=
0
;
while
(
p_buffer
)
{
ssize_t
val
=
write
((
intptr_t
)
p_access
->
p_sys
,
p_buffer
->
p_buffer
,
p_buffer
->
i_buffer
);
if
(
val
<=
0
)
{
if
(
errno
==
EINTR
)
continue
;
block_ChainRelease
(
p_buffer
);
msg_Err
(
p_access
,
"cannot write: %s"
,
vlc_strerror_c
(
errno
)
);
return
-
1
;
}
if
((
size_t
)
val
>=
p_buffer
->
i_buffer
)
{
block_t
*
p_next
=
p_buffer
->
p_next
;
block_Release
(
p_buffer
);
p_buffer
=
p_next
;
}
else
{
p_buffer
->
p_buffer
+=
val
;
p_buffer
->
i_buffer
-=
val
;
}
i_write
+=
val
;
}
return
i_write
;
}
#define OVERWRITE_TEXT N_("Overwrite existing file")
#define OVERWRITE_LONGTEXT N_( \
"If the file already exists, it will be overwritten.")
#define APPEND_TEXT N_("Append to file")
#define APPEND_LONGTEXT N_( "Append to file if it exists instead " \
"of replacing it.")
#define FORMAT_TEXT N_("Format time and date")
#define FORMAT_LONGTEXT N_("Perform ISO C time and date formatting " \
"on the file path")
#define SYNC_TEXT N_("Synchronous writing")
#define SYNC_LONGTEXT N_( "Open the file with synchronous writing.")
/*****************************************************************************
* Seek: seek to a specific location in a file
*****************************************************************************/
static
int
Seek
(
sout_access_out_t
*
p_access
,
off_t
i_pos
)
{
return
lseek
(
(
intptr_t
)
p_access
->
p_sys
,
i_pos
,
SEEK_SET
);
}
vlc_module_begin
()
set_description
(
N_
(
"File stream output"
)
)
set_shortname
(
N_
(
"File"
))
set_capability
(
"sout access"
,
50
)
set_category
(
CAT_SOUT
)
set_subcategory
(
SUBCAT_SOUT_ACO
)
add_shortcut
(
"file"
,
"stream"
,
"fd"
)
add_bool
(
SOUT_CFG_PREFIX
"overwrite"
,
true
,
OVERWRITE_TEXT
,
OVERWRITE_LONGTEXT
,
true
)
add_bool
(
SOUT_CFG_PREFIX
"append"
,
false
,
APPEND_TEXT
,
APPEND_LONGTEXT
,
true
)
add_bool
(
SOUT_CFG_PREFIX
"format"
,
false
,
FORMAT_TEXT
,
FORMAT_LONGTEXT
,
true
)
#ifdef O_SYNC
add_bool
(
SOUT_CFG_PREFIX
"sync"
,
false
,
SYNC_TEXT
,
SYNC_LONGTEXT
,
false
)
#endif
set_callbacks
(
Open
,
Close
)
vlc_module_end
()
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