]> git.sesse.net Git - vlc/commitdiff
access/* : don't override demux setting made by user.
authorLaurent Aimar <fenrir@videolan.org>
Wed, 13 Nov 2002 20:23:21 +0000 (20:23 +0000)
committerLaurent Aimar <fenrir@videolan.org>
Wed, 13 Nov 2002 20:23:21 +0000 (20:23 +0000)
 modules/demux/demuxdump.c : a little demux that dump raw stream.
(should work with all access...)

configure.ac.in
modules/access/dvd/access.c
modules/access/dvdplay/access.c
modules/access/dvdread/input.c
modules/access/rtp.c
modules/access/vcd/vcd.c
modules/demux/Modules.am
modules/demux/demuxdump.c [new file with mode: 0644]

index 9d9b5effc99b9a00a516aa5bbba95a1abbdcef56..be31e2f070874af25437aed5149c422ffd08f628 100644 (file)
@@ -584,7 +584,7 @@ PLUGINS="${PLUGINS} aout_file"
 #PLUGINS="${PLUGINS} scope"
 PLUGINS="${PLUGINS} i420_rgb i420_yuy2 i422_yuy2 i420_ymga"
 PLUGINS="${PLUGINS} id3 m3u"
-PLUGINS="${PLUGINS} wav araw"
+PLUGINS="${PLUGINS} wav araw demuxdump"
 
 dnl
 dnl  Network modules
index d3249a1bf8a4d1ad04129d581298f95a0c196ef1..79cd9345e87db5d1b02d497347d6d09bdad0dfa3 100644 (file)
@@ -8,7 +8,7 @@
  *  -udf.* to find files
  *****************************************************************************
  * Copyright (C) 1998-2001 VideoLAN
- * $Id: access.c,v 1.4 2002/11/08 10:26:52 gbazin Exp $
+ * $Id: access.c,v 1.5 2002/11/13 20:23:21 fenrir Exp $
  *
  * Author: Stéphane Borel <stef@via.ecp.fr>
  *
@@ -252,7 +252,10 @@ int E_(DVDOpen) ( vlc_object_t *p_this )
 
     vlc_mutex_unlock( &p_input->stream.stream_lock );
 
-    p_input->psz_demux = "dvdold";
+    if( !p_input->psz_demux || !*p_input->psz_demux )
+    {
+        p_input->psz_demux = "dvdold";
+    }
 
     return 0;
 }
index 325cfd1760df349103614143c8e3a04f7ca02446..2d3036a06b21657c6f95d19b6d9b95f83aae5c33 100644 (file)
@@ -2,7 +2,7 @@
  * access.c: access capabilities for dvdplay plugin.
  *****************************************************************************
  * Copyright (C) 2001 VideoLAN
- * $Id: access.c,v 1.5 2002/11/06 18:07:57 sam Exp $
+ * $Id: access.c,v 1.6 2002/11/13 20:23:21 fenrir Exp $
  *
  * Author: Stéphane Borel <stef@via.ecp.fr>
  *
@@ -182,7 +182,10 @@ int E_(OpenDVD) ( vlc_object_t *p_this )
 
     vlc_mutex_unlock( &p_input->stream.stream_lock );
 
-    p_input->psz_demux = "dvdplay";
+    if( !p_input->psz_demux || !*p_input->psz_demux )
+    {
+        p_input->psz_demux = "dvdplay";
+    }
 
     /* FIXME: we might lose variables here */
     var_Create( p_input, "x-start", VLC_VAR_INTEGER );
index b9b77141b5477a474f9e1f68dfa1f87ead853b96..83494b4d22a829ede10a783afc8156116a00376d 100644 (file)
@@ -6,7 +6,7 @@
  * It depends on: libdvdread for ifo files and block reading.
  *****************************************************************************
  * Copyright (C) 2001 VideoLAN
- * $Id: input.c,v 1.8 2002/11/08 10:26:52 gbazin Exp $
+ * $Id: input.c,v 1.9 2002/11/13 20:23:21 fenrir Exp $
  *
  * Author: Stéphane Borel <stef@via.ecp.fr>
  *
@@ -419,7 +419,10 @@ int E_(OpenDVD) ( vlc_object_t *p_this )
 
     vlc_mutex_unlock( &p_input->stream.stream_lock );
 
-    p_input->psz_demux = "dvdread";
+    if( !p_input->psz_demux || !*p_input->psz_demux )
+    {
+        p_input->psz_demux = "dvdread";
+    }
 
     return 0;
 }
index 7dbdc9da3eeb64398639b7ffd7a600fce197f59b..621fed1897c11219ccfca4dc56741324ab11d3e4 100644 (file)
@@ -2,7 +2,7 @@
  * rtp.c: RTP access plug-in
  *****************************************************************************
  * Copyright (C) 2001, 2002 VideoLAN
- * $Id: rtp.c,v 1.5 2002/11/12 13:57:12 sam Exp $
+ * $Id: rtp.c,v 1.6 2002/11/13 20:23:21 fenrir Exp $
  *
  * Authors: Tristan Leteurtre <tooney@via.ecp.fr>
  *
@@ -268,8 +268,10 @@ static int Open( vlc_object_t *p_this )
 
     p_access_data->i_handle = socket_desc.i_handle;
     p_input->i_mtu = socket_desc.i_mtu;
-
-    p_input->psz_demux = "ts";
+    if( !p_input->psz_demux || !*p_input->psz_demux )
+    {
+        p_input->psz_demux = "ts";
+    }
     
     return( 0 );
 }
index b702d9633e489d6838e4978b4b92ce2c07e5b40f..c4726ed2a684d2b201d83740cc484f0ddcfadabb 100644 (file)
@@ -2,7 +2,7 @@
  * vcd.c : VCD input module for vlc
  *****************************************************************************
  * Copyright (C) 2000 VideoLAN
- * $Id: vcd.c,v 1.10 2002/11/06 15:41:29 jobi Exp $
+ * $Id: vcd.c,v 1.11 2002/11/13 20:23:21 fenrir Exp $
  *
  * Author: Johan Bilien <jobi@via.ecp.fr>
  *
@@ -257,7 +257,10 @@ static int VCDOpen( vlc_object_t *p_this )
 
     vlc_mutex_unlock( &p_input->stream.stream_lock );
 
-    p_input->psz_demux = "ps";
+    if( !p_input->psz_demux || !*p_input->psz_demux )
+    {
+        p_input->psz_demux = "ps";
+    }
 
     return 0;
 }
index 7feb8110c324e3f6ac7e90fbdb26f23f9678b423..c03a994ce2cb6d775368016b0bee1c8b69393c57 100644 (file)
@@ -1,3 +1,4 @@
 SOURCES_a52sys = modules/demux/a52sys.c
 SOURCES_ogg = modules/demux/ogg.c
 SOURCES_m3u = modules/demux/m3u.c
+SOURCES_demuxdump = modules/demux/demuxdump.c
diff --git a/modules/demux/demuxdump.c b/modules/demux/demuxdump.c
new file mode 100644 (file)
index 0000000..8abb779
--- /dev/null
@@ -0,0 +1,233 @@
+/*****************************************************************************
+ * demuxdump.c : Pseudo demux module for vlc (dump raw stream)
+ *****************************************************************************
+ * Copyright (C) 2001 VideoLAN
+ * $Id: demuxdump.c,v 1.1 2002/11/13 20:23:21 fenrir Exp $
+ *
+ * Authors: Laurent Aimar <fenrir@via.ecp.fr>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ * 
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111, USA.
+ *****************************************************************************/
+
+/*****************************************************************************
+ * Preamble
+ *****************************************************************************/
+#include <stdlib.h>                                      /* malloc(), free() */
+#include <string.h>                                              /* strdup() */
+#include <errno.h>
+
+#include <vlc/vlc.h>
+#include <vlc/input.h>
+
+#include <sys/types.h>
+
+/*****************************************************************************
+ * Local prototypes
+ *****************************************************************************/
+static int  Activate ( vlc_object_t * );
+static int  Demux ( input_thread_t * );
+static void Desactivate ( vlc_object_t * );
+
+#define DUMP_BLOCKSIZE  16384
+
+/*****************************************************************************
+ * Module descriptor
+ *****************************************************************************/
+vlc_module_begin();
+    set_description( _("Dump Demux input") );
+    set_capability( "demux", 0 );
+    add_category_hint( "File", NULL );
+        add_string( "demuxdump-file", NULL, NULL, 
+                    "dump file name", 
+                    "file name for dumping raw stream read by demux" );
+    set_callbacks( Activate, Desactivate );
+    add_shortcut( "dump" );
+vlc_module_end();
+
+struct demux_sys_t
+{
+    char        *psz_name;
+    FILE        *p_file;
+    uint64_t    i_write;
+
+    void        *p_demux_data_sav;
+};
+
+/*
+ * Data reading functions
+ */
+
+/*****************************************************************************
+ * Activate: initializes dump structures
+ *****************************************************************************/
+static int Activate( vlc_object_t * p_this )
+{
+    input_thread_t      *p_input = (input_thread_t *)p_this;
+    demux_sys_t         *p_demux;
+
+    char                *psz_name;
+
+    /* Set the demux function */
+    p_input->pf_demux = Demux;
+
+    /* Initialize access plug-in structures. */
+    if( p_input->i_mtu == 0 )
+    {
+        /* Improve speed. */
+        p_input->i_bufsize = INPUT_DEFAULT_BUFSIZE;
+    }
+    
+    psz_name = config_GetPsz( p_input, "demuxdump-file" );
+    if( !psz_name || !*psz_name )
+    {
+        psz_name = strdup( "stream-demux.dump" );
+    }
+
+    p_demux = malloc( sizeof( demux_sys_t ) );
+    memset( p_demux, 0, sizeof( demux_sys_t ) );
+
+    if( !( p_demux->p_file = fopen( psz_name, "wb" ) ) )
+    {
+        msg_Err( p_input,
+                 "cannot create `%s' for writing", 
+                 psz_name );
+        free( p_demux );
+        return( -1 );
+    }
+    else
+    {
+        msg_Info( p_input,
+                  "dumping raw stream to file `%s'", 
+                  psz_name );
+        p_demux->psz_name = psz_name;
+    }
+    
+    p_demux->i_write = 0;
+    p_demux->p_demux_data_sav = p_input->p_demux_data;
+
+    if( p_input->stream.p_selected_program != NULL )
+    {
+        /* workaround for dvd access */
+        msg_Warn( p_input, "demux data already initializated (by access?)" );
+    }
+    else
+    {
+    
+        if( input_InitStream( p_input, 0 ) == -1 )
+        {
+            fclose( p_demux->p_file );
+            free( p_demux );
+            return( -1 );
+        }
+        input_AddProgram( p_input, 0, 0 );
+        p_input->stream.p_selected_program = p_input->stream.pp_programs[0];
+        
+        vlc_mutex_lock( &p_input->stream.stream_lock );
+        p_input->stream.p_selected_area->i_tell = 0;
+        vlc_mutex_unlock( &p_input->stream.stream_lock );
+    }
+
+    p_input->p_demux_data = p_demux;
+
+    vlc_mutex_lock( &p_input->stream.stream_lock );
+    p_input->stream.p_selected_program->b_is_ok = 1;
+    vlc_mutex_unlock( &p_input->stream.stream_lock );
+    
+    return( 0 );
+}
+
+/*****************************************************************************
+ * Desctivate: initializes dump structures
+ *****************************************************************************/
+static void Desactivate ( vlc_object_t *p_this )
+{
+    input_thread_t      *p_input = (input_thread_t *)p_this;
+    demux_sys_t         *p_demux = (demux_sys_t*)p_input->p_demux_data;
+    
+    msg_Info( p_input, 
+              "closing %s (%d Kbytes dumped)", 
+              p_demux->psz_name,
+              p_demux->i_write / 1024 );
+   
+    if( p_demux->p_file )
+    {
+        fclose( p_demux->p_file );
+        p_demux->p_file = NULL;
+    }
+    if( p_demux->psz_name )
+    {
+        free( p_demux->psz_name );    
+    }
+    p_input->p_demux_data = p_demux->p_demux_data_sav;
+    free( p_demux );
+}
+
+/*****************************************************************************
+ * Demux: reads and demuxes data packets
+ *****************************************************************************
+ * Returns -1 in case of error, 0 in case of EOF, 1 otherwise
+ *****************************************************************************/
+static int Demux( input_thread_t * p_input )
+{
+    demux_sys_t         *p_demux = (demux_sys_t*)p_input->p_demux_data;
+
+    ssize_t         i_read;
+    data_packet_t * p_data;
+    int             i_write;
+
+    p_input->p_demux_data = p_demux->p_demux_data_sav;
+    i_read = input_SplitBuffer( p_input, &p_data, DUMP_BLOCKSIZE );
+    p_input->p_demux_data = p_demux;
+    
+    if ( i_read <= 0 )
+    {
+        return i_read;
+    }
+
+    i_write = fwrite( p_data->p_payload_start,
+                       1,
+                       i_read,
+                       p_demux->p_file );
+    
+    input_DeletePacket( p_input->p_method_data, p_data );
+
+    if( i_write < 0 )
+    {
+        msg_Err( p_input, 
+                 "failed to write %d bytes",
+                 i_write );
+        return( -1 );
+    }
+    else
+    {
+        msg_Dbg( p_input,
+                 "dumped %d bytes",
+                 i_write );
+        p_demux->i_write += i_write;
+    }
+
+
+    if( (p_input->stream.p_selected_program->i_synchro_state == SYNCHRO_REINIT)
+         | (input_ClockManageControl( p_input, 
+                      p_input->stream.p_selected_program,
+                         (mtime_t)0 ) == PAUSE_S) )
+    {
+        msg_Warn( p_input, "synchro reinit" );
+        p_input->stream.p_selected_program->i_synchro_state = SYNCHRO_OK;
+    }
+
+    return( 1 );
+}
+