]> git.sesse.net Git - vlc/commitdiff
* modules/misc/dummy/*: new --dummy-save-es option to specify if we want the dummy
authorGildas Bazin <gbazin@videolan.org>
Mon, 8 Dec 2003 18:42:08 +0000 (18:42 +0000)
committerGildas Bazin <gbazin@videolan.org>
Mon, 8 Dec 2003 18:42:08 +0000 (18:42 +0000)
decoder to save the raw codec data to a file. This is disabled by default (while
it was always on before).
* src/input/es_out.c: bug fix for ES autoselection.

modules/misc/dummy/decoder.c
modules/misc/dummy/dummy.c
src/input/es_out.c

index 317e4acf251786acd370b84f9dae5b7e752413f6..8a0971f2c760e09123f4b90f0ee55ec47613ec1b 100644 (file)
@@ -2,7 +2,7 @@
  * decoder.c: dummy decoder plugin for vlc.
  *****************************************************************************
  * Copyright (C) 2002 VideoLAN
- * $Id: decoder.c,v 1.8 2003/11/16 21:07:31 gbazin Exp $
+ * $Id: decoder.c,v 1.9 2003/12/08 18:42:07 gbazin Exp $
  *
  * Authors: Samuel Hocevar <sam@zoy.org>
  *
@@ -65,6 +65,7 @@ int E_(OpenDecoder) ( vlc_object_t *p_this )
     decoder_t *p_dec = (decoder_t*)p_this;
     decoder_sys_t *p_sys;
     char psz_file[ PATH_MAX ];
+    vlc_value_t val;
 
     /* Allocate the memory needed to store the decoder's structure */
     if( ( p_dec->p_sys = p_sys =
@@ -77,16 +78,25 @@ int E_(OpenDecoder) ( vlc_object_t *p_this )
     sprintf( psz_file, "stream.%i", p_dec->i_object_id );
 
 #ifndef UNDER_CE
-    p_sys->i_fd = open( psz_file, O_WRONLY | O_CREAT | O_TRUNC, 00644 );
-
-    if( p_sys->i_fd == -1 )
+    var_Create( p_dec, "dummy-save-es", VLC_VAR_BOOL | VLC_VAR_DOINHERIT );
+    var_Get( p_dec, "dummy-save-es", &val );
+    if( val.b_bool )
     {
-        msg_Err( p_dec, "cannot create `%s'", psz_file );
-        return VLC_EGENERIC;
+        p_sys->i_fd = open( psz_file, O_WRONLY | O_CREAT | O_TRUNC, 00644 );
+
+        if( p_sys->i_fd == -1 )
+        {
+            msg_Err( p_dec, "cannot create `%s'", psz_file );
+            return VLC_EGENERIC;
+        }
+
+        msg_Dbg( p_dec, "dumping stream to file `%s'", psz_file );
     }
+    else
 #endif
-
-    msg_Dbg( p_dec, "dumping stream to file `%s'", psz_file );
+    {
+        p_sys->i_fd = -1;
+    }
 
     /* Set callbacks */
     p_dec->pf_decode_video = (picture_t *(*)(decoder_t *, block_t **))
@@ -110,7 +120,7 @@ static void *DecodeBlock( decoder_t *p_dec, block_t **pp_block )
     if( !pp_block || !*pp_block ) return NULL;
     p_block = *pp_block;
 
-    if( p_block->i_buffer )
+    if( p_sys->i_fd >= 0 && p_block->i_buffer )
     {
 #ifndef UNDER_CE
         write( p_sys->i_fd, p_block->p_buffer, p_block->i_buffer );
@@ -132,7 +142,7 @@ void E_(CloseDecoder) ( vlc_object_t *p_this )
     decoder_sys_t *p_sys = p_dec->p_sys;
 
 #ifndef UNDER_CE
-    close( p_sys->i_fd );
+    if( p_sys->i_fd >= 0 ) close( p_sys->i_fd );
 #endif
 
     free( p_sys );
index 3fcca128089a72b88df5d2a6f81004f610c210a1..c829533a9c7cabff8fde16b3892c0ba8c9e8db03 100644 (file)
@@ -2,7 +2,7 @@
  * dummy.c : dummy plugin for vlc
  *****************************************************************************
  * Copyright (C) 2000, 2001 VideoLAN
- * $Id: dummy.c,v 1.10 2003/11/16 21:07:31 gbazin Exp $
+ * $Id: dummy.c,v 1.11 2003/12/08 18:42:08 gbazin Exp $
  *
  * Authors: Samuel Hocevar <sam@zoy.org>
  *
     "format instead of trying to improve performances by using the most " \
     "efficient one.")
 
+#define SAVE_TEXT N_("Save raw codec data")
+#define SAVE_LONGTEXT N_( \
+    "This option allows you to save the raw codec data if you have " \
+    "selected/forced the dummy decoder in the main options." )
+
 #ifdef WIN32
 #define QUIET_TEXT N_("Don't open a dos command box interface")
 #define QUIET_LONGTEXT N_( \
@@ -70,6 +75,7 @@ vlc_module_begin();
         set_description( _("dummy decoder function") );
         set_capability( "decoder", 0 );
         set_callbacks( E_(OpenDecoder), E_(CloseDecoder) );
+        add_bool( "dummy-save-es", 0, NULL, SAVE_TEXT, SAVE_LONGTEXT, VLC_FALSE );
     add_submodule();
         set_description( _("dummy encoder function") );
         set_capability( "encoder", 0 );
index 2fcea0b4dba23e253de872feea106577f99299db..63b0c6d25c7918914a1764d83aa92db6689314d8 100644 (file)
@@ -2,7 +2,7 @@
  * es_out.c: Es Out handler for input.
  *****************************************************************************
  * Copyright (C) 2003 VideoLAN
- * $Id: es_out.c,v 1.8 2003/12/07 17:17:04 gbazin Exp $
+ * $Id: es_out.c,v 1.9 2003/12/08 18:42:08 gbazin Exp $
  *
  * Authors: Laurent Aimar <fenrir@via.ecp.fr>
  *
@@ -519,6 +519,10 @@ static void EsOutDel( es_out_t *out, es_out_id_t *es )
     }
     input_DelES( p_sys->p_input, es->p_es );
 
+    if( p_sys->p_es_audio == es ) p_sys->p_es_audio = NULL;
+    if( p_sys->p_es_video == es ) p_sys->p_es_video = NULL;
+    if( p_sys->p_es_sub   == es ) p_sys->p_es_sub   = NULL;
+
     vlc_mutex_unlock( &p_sys->p_input->stream.stream_lock );
 
     free( es );