[vlc-commits] commit: file output: support for writing to an already open file descriptor ( =?UTF-8?Q?R=C3=A9mi=20Denis=2DCourmont=20?=)
git at videolan.org
git at videolan.org
Fri Nov 19 21:28:33 CET 2010
vlc | branch: master | Rémi Denis-Courmont <remi at remlab.net> | Fri Nov 19 18:11:36 2010 +0200| [23af3705afeb76416c6697b064af2e314590f3f2] | committer: Rémi Denis-Courmont
file output: support for writing to an already open file descriptor
> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=23af3705afeb76416c6697b064af2e314590f3f2
---
modules/access_output/file.c | 44 ++++++++++++++++++++++++++++++-----------
1 files changed, 32 insertions(+), 12 deletions(-)
diff --git a/modules/access_output/file.c b/modules/access_output/file.c
index cb30317..f104f59 100644
--- a/modules/access_output/file.c
+++ b/modules/access_output/file.c
@@ -72,7 +72,7 @@ vlc_module_begin ()
set_capability( "sout access", 50 )
set_category( CAT_SOUT )
set_subcategory( SUBCAT_SOUT_ACO )
- add_shortcut( "file", "stream" )
+ add_shortcut( "file", "stream", "fd" )
add_bool( SOUT_CFG_PREFIX "append", false, APPEND_TEXT,APPEND_LONGTEXT,
true )
#ifdef O_SYNC
@@ -122,19 +122,40 @@ static int Open( vlc_object_t *p_this )
bool append = var_GetBool( p_access, SOUT_CFG_PREFIX "append" );
- if( !strcmp( p_access->psz_path, "-" ) )
+ if (!strcmp (p_access->psz_access, "fd"))
{
+ char *end;
+
+ fd = strtol (p_access->psz_path, &end, 0);
+ if (!*p_access->psz_path || *end)
+ {
+ msg_Err (p_access, "invalid file descriptor: %s",
+ p_access->psz_path);
+ return VLC_EGENERIC;
+ }
+ fd = vlc_dup (fd);
+ if (fd == -1)
+ {
+ msg_Err (p_access, "cannot use file descriptor: %m");
+ return VLC_EGENERIC;
+ }
+ }
#ifndef UNDER_CE
+ else
+ if( !strcmp( p_access->psz_path, "-" ) )
+ {
#ifdef WIN32
setmode (fileno (stdout), O_BINARY);
#endif
fd = vlc_dup (fileno (stdout));
+ if (fd == -1)
+ {
+ msg_Err (p_access, "cannot use standard output: %m");
+ return VLC_EGENERIC;
+ }
msg_Dbg( p_access, "using stdout" );
-#else
-#warning stdout is not supported on Windows Mobile, but may be used on Windows CE
- fd = -1;
-#endif
}
+#endif
else
{
char *psz_tmp = str_format( p_access, p_access->psz_path );
@@ -146,12 +167,11 @@ static int Open( vlc_object_t *p_this )
#endif
(append ? 0 : O_TRUNC), 0666 );
free( psz_tmp );
- }
-
- if (fd == -1)
- {
- msg_Err( p_access, "cannot open `%s' (%m)", p_access->psz_path );
- return VLC_EGENERIC;
+ if (fd == -1)
+ {
+ msg_Err (p_access, "cannot create %s: %m", p_access->psz_path);
+ return VLC_EGENERIC;
+ }
}
p_access->pf_write = Write;
More information about the vlc-commits
mailing list