]> git.sesse.net Git - vlc/blobdiff - modules/access_output/file.c
Improvements to preferences
[vlc] / modules / access_output / file.c
index b26db480e7abebf5328154fc396a31de70fd56ec..62a1e6d15b6a1109ac53f4746dc926725841d3c7 100644 (file)
 static int  Open ( vlc_object_t * );
 static void Close( vlc_object_t * );
 
+#define SOUT_CFG_PREFIX "sout-file-"
+#define APPEND_TEXT N_("Append to file")
+#define APPEND_LONGTEXT N_( "Append to file if it exists instead " \
+                            "of replacing it.")
+
 vlc_module_begin();
-    set_description( _("File stream ouput") );
+    set_description( _("File stream output") );
     set_capability( "sout access", 50 );
+    set_category( CAT_SOUT );
+    set_subcategory( SUBCAT_SOUT_ACO );
     add_shortcut( "file" );
+    add_shortcut( "stream" );
+    add_bool( SOUT_CFG_PREFIX "append", 0, NULL, APPEND_TEXT,APPEND_LONGTEXT,
+              VLC_TRUE );
     set_callbacks( Open, Close );
 vlc_module_end();
 
@@ -69,6 +79,10 @@ vlc_module_end();
 /*****************************************************************************
  * Exported prototypes
  *****************************************************************************/
+static const char *ppsz_sout_options[] = {
+    "append", NULL
+};
+
 static int Write( sout_access_out_t *, block_t * );
 static int Seek ( sout_access_out_t *, off_t  );
 static int Read ( sout_access_out_t *, block_t * );
@@ -85,6 +99,9 @@ static int Open( vlc_object_t *p_this )
 {
     sout_access_out_t   *p_access = (sout_access_out_t*)p_this;
     int                 i_flags;
+    vlc_value_t         val;
+
+    sout_CfgParse( p_access, SOUT_CFG_PREFIX, ppsz_sout_options, p_access->p_cfg );
 
     if( !( p_access->p_sys = malloc( sizeof( sout_access_out_sys_t ) ) ) )
     {
@@ -98,7 +115,9 @@ static int Open( vlc_object_t *p_this )
         return VLC_EGENERIC;
     }
     i_flags = O_RDWR|O_CREAT;
-    if( sout_cfg_find_value( p_access->p_cfg, "append" ) )
+
+    var_Get( p_access, SOUT_CFG_PREFIX "append", &val );
+    if( val.b_bool )
     {
         i_flags |= O_APPEND;
     }
@@ -125,6 +144,11 @@ static int Open( vlc_object_t *p_this )
     p_access->pf_seek  = Seek;
 
     msg_Dbg( p_access, "file access output opened (`%s')", p_access->psz_name );
+
+    /* Update pace control flag */
+    if( p_access->psz_access && !strcmp( p_access->psz_access, "stream" ) )
+        p_access->p_sout->i_out_pace_nocontrol++;
+
     return VLC_SUCCESS;
 }
 
@@ -144,6 +168,10 @@ static void Close( vlc_object_t * p_this )
     }
     free( p_access->p_sys );
 
+    /* Update pace control flag */
+    if( p_access->psz_access && !strcmp( p_access->psz_access, "stream" ) )
+        p_access->p_sout->i_out_pace_nocontrol--;
+
     msg_Dbg( p_access, "file access output closed" );
 }