]> git.sesse.net Git - vlc/blobdiff - modules/demux/demuxdump.c
Change default aspect to 16:9.
[vlc] / modules / demux / demuxdump.c
index 0a97bf45b65f7d6a48c63e861258be593740ebe4..2a642929978885abb6d00e8544a6c0d011d968ed 100644 (file)
 # include "config.h"
 #endif
 
-#include <errno.h>
-
 #include <vlc_common.h>
 #include <vlc_plugin.h>
 #include <vlc_demux.h>
-#include <vlc_charset.h>
+#include <vlc_fs.h>
 
 /*****************************************************************************
  * Module descriptor
@@ -77,6 +75,8 @@ struct demux_sys_t
     char        *psz_file;
     FILE        *p_file;
     uint64_t    i_write;
+
+    uint8_t     buffer[DUMP_BLOCKSIZE];
 };
 
 /*
@@ -91,7 +91,6 @@ static int Open( vlc_object_t * p_this )
     demux_t     *p_demux = (demux_t*)p_this;
     demux_sys_t *p_sys;
     const char  *psz_mode;
-    vlc_value_t val;
     bool  b_append;
 
     /* Accept only if forced */
@@ -102,9 +101,7 @@ static int Open( vlc_object_t * p_this )
     if( !p_sys )
         return VLC_ENOMEM;
 
-    var_Create( p_demux, "demuxdump-append", VLC_VAR_BOOL|VLC_VAR_DOINHERIT );
-    var_Get( p_demux, "demuxdump-append", &val );
-    b_append = val.b_bool;
+    b_append = var_CreateGetBool( p_demux, "demuxdump-append" );
     if ( b_append )
         psz_mode = "ab";
     else
@@ -129,7 +126,7 @@ static int Open( vlc_object_t * p_this )
         msg_Info( p_demux, "dumping raw stream to standard output" );
         p_sys->p_file = stdout;
     }
-    else if( ( p_sys->p_file = utf8_fopen( p_sys->psz_file, psz_mode ) ) == NULL )
+    else if( ( p_sys->p_file = vlc_fopen( p_sys->psz_file, psz_mode ) ) == NULL )
     {
         msg_Err( p_demux, "cannot create `%s' for writing", p_sys->psz_file );
         free( p_sys->psz_file );
@@ -151,7 +148,7 @@ static void Close( vlc_object_t *p_this )
     demux_t     *p_demux = (demux_t*)p_this;
     demux_sys_t *p_sys = p_demux->p_sys;
 
-    msg_Info( p_demux ,"closing %s (%"PRId64" Kbytes dumped)", p_sys->psz_file,
+    msg_Info( p_demux ,"closing %s (%"PRId64" KiB dumped)", p_sys->psz_file,
               p_sys->i_write / 1024 );
 
     if( p_sys->p_file != stdout )
@@ -171,14 +168,13 @@ static int Demux( demux_t *p_demux )
 {
     demux_sys_t *p_sys = p_demux->p_sys;
 
-    const uint8_t *p_peek;
     int i_data;
 
-    i_data = stream_Peek( p_demux->s, &p_peek, DUMP_BLOCKSIZE );
+    i_data = stream_Read( p_demux->s, p_sys->buffer, DUMP_BLOCKSIZE );
     if ( i_data <= 0 )
         return i_data;
 
-    i_data = fwrite( p_peek, 1, i_data, p_sys->p_file );
+    i_data = fwrite( p_sys->buffer, 1, i_data, p_sys->p_file );
 
     if( i_data == 0 )
     {
@@ -189,7 +185,6 @@ static int Demux( demux_t *p_demux )
     msg_Dbg( p_demux, "dumped %d bytes", i_data );
 #endif
 
-    stream_Read( p_demux->s, NULL, i_data );
     p_sys->i_write += i_data;
 
     return 1;