Main Page | Modules | Class Hierarchy | Class List | Directories | File List | Class Members | File Members | Related Pages

dummy.c

00001 /*****************************************************************************
00002  * dummy.c: dummy muxer module for vlc
00003  *****************************************************************************
00004  * Copyright (C) 2001, 2002 the VideoLAN team
00005  * $Id: dummy.c 11664 2005-07-09 06:17:09Z courmisch $
00006  *
00007  * Authors: Laurent Aimar <[email protected]>
00008  *          Eric Petit <[email protected]>
00009  *
00010  * This program is free software; you can redistribute it and/or modify
00011  * it under the terms of the GNU General Public License as published by
00012  * the Free Software Foundation; either version 2 of the License, or
00013  * (at your option) any later version.
00014  *
00015  * This program is distributed in the hope that it will be useful,
00016  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00017  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00018  * GNU General Public License for more details.
00019  *
00020  * You should have received a copy of the GNU General Public License
00021  * along with this program; if not, write to the Free Software
00022  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111, USA.
00023  *****************************************************************************/
00024 
00025 /*****************************************************************************
00026  * Preamble
00027  *****************************************************************************/
00028 #include <stdlib.h>
00029 
00030 #include <vlc/vlc.h>
00031 #include <vlc/sout.h>
00032 
00033 
00034 /*****************************************************************************
00035  * Module descriptor
00036  *****************************************************************************/
00037 static int  Open   ( vlc_object_t * );
00038 static void Close  ( vlc_object_t * );
00039 
00040 vlc_module_begin();
00041     set_description( _("Dummy/Raw muxer") );
00042     set_capability( "sout mux", 5 );
00043     set_category( CAT_SOUT );
00044     set_subcategory( SUBCAT_SOUT_MUX );
00045     add_shortcut( "dummy" );
00046     add_shortcut( "raw" );
00047     add_shortcut( "es" );
00048     set_callbacks( Open, Close );
00049 vlc_module_end();
00050 
00051 /*****************************************************************************
00052  * Exported prototypes
00053  *****************************************************************************/
00054 static int Control( sout_mux_t *, int, va_list );
00055 static int AddStream( sout_mux_t *, sout_input_t * );
00056 static int DelStream( sout_mux_t *, sout_input_t * );
00057 static int Mux      ( sout_mux_t * );
00058 
00059 struct sout_mux_sys_t
00060 {
00061     /* Some streams have special initialization data, we'll output this
00062      * data as an header in the stream. */
00063     vlc_bool_t b_header;
00064 };
00065 
00066 /*****************************************************************************
00067  * Open:
00068  *****************************************************************************/
00069 static int Open( vlc_object_t *p_this )
00070 {
00071     sout_mux_t *p_mux = (sout_mux_t*)p_this;
00072     sout_mux_sys_t  *p_sys;
00073 
00074     msg_Dbg( p_mux, "Dummy/Raw muxer opened" );
00075     msg_Info( p_mux, "Open" );
00076 
00077     p_mux->pf_control   = Control;
00078     p_mux->pf_addstream = AddStream;
00079     p_mux->pf_delstream = DelStream;
00080     p_mux->pf_mux       = Mux;
00081 
00082     p_mux->p_sys = p_sys = malloc( sizeof( sout_mux_sys_t ) );
00083     p_sys->b_header      = VLC_TRUE;
00084 
00085     return VLC_SUCCESS;
00086 }
00087 
00088 /*****************************************************************************
00089  * Close:
00090  *****************************************************************************/
00091 
00092 static void Close( vlc_object_t * p_this )
00093 {
00094     sout_mux_t *p_mux = (sout_mux_t*)p_this;
00095     sout_mux_sys_t *p_sys = p_mux->p_sys;
00096 
00097     msg_Dbg( p_mux, "Dummy/Raw muxer closed" );
00098     free( p_sys );
00099 }
00100 
00101 static int Control( sout_mux_t *p_mux, int i_query, va_list args )
00102 {
00103     vlc_bool_t *pb_bool;
00104 
00105    switch( i_query )
00106    {
00107        case MUX_CAN_ADD_STREAM_WHILE_MUXING:
00108            pb_bool = (vlc_bool_t*)va_arg( args, vlc_bool_t * );
00109            *pb_bool = VLC_TRUE;
00110            return VLC_SUCCESS;
00111 
00112        case MUX_GET_ADD_STREAM_WAIT:
00113            pb_bool = (vlc_bool_t*)va_arg( args, vlc_bool_t * );
00114            *pb_bool = VLC_FALSE;
00115            return VLC_SUCCESS;
00116 
00117        case MUX_GET_MIME:   /* Unknown */
00118         default:
00119             return VLC_EGENERIC;
00120    }
00121 }
00122 
00123 static int AddStream( sout_mux_t *p_mux, sout_input_t *p_input )
00124 {
00125     msg_Dbg( p_mux, "adding input" );
00126     return VLC_SUCCESS;
00127 }
00128 
00129 static int DelStream( sout_mux_t *p_mux, sout_input_t *p_input )
00130 {
00131     msg_Dbg( p_mux, "removing input" );
00132     return VLC_SUCCESS;
00133 }
00134 
00135 static int Mux( sout_mux_t *p_mux )
00136 {
00137     sout_mux_sys_t *p_sys = p_mux->p_sys;
00138     int i;
00139 
00140     for( i = 0; i < p_mux->i_nb_inputs; i++ )
00141     {
00142         block_fifo_t *p_fifo;
00143         int i_count;
00144 
00145         if( p_sys->b_header && p_mux->pp_inputs[i]->p_fmt->i_extra )
00146         {
00147             /* Write header data */
00148             block_t *p_data;
00149             p_data = block_New( p_mux, p_mux->pp_inputs[i]->p_fmt->i_extra );
00150 
00151             memcpy( p_data->p_buffer, p_mux->pp_inputs[i]->p_fmt->p_extra,
00152                     p_mux->pp_inputs[i]->p_fmt->i_extra );
00153 
00154             msg_Dbg( p_mux, "writing header data" );
00155             sout_AccessOutWrite( p_mux->p_access, p_data );
00156         }
00157 
00158         p_fifo = p_mux->pp_inputs[i]->p_fifo;
00159         i_count = p_fifo->i_depth;
00160         while( i_count > 0 )
00161         {
00162             block_t *p_data = block_FifoGet( p_fifo );
00163 
00164             sout_AccessOutWrite( p_mux->p_access, p_data );
00165 
00166             i_count--;
00167         }
00168     }
00169     p_sys->b_header = VLC_FALSE;
00170 
00171     return VLC_SUCCESS;
00172 }

Generated on Tue Dec 20 10:14:27 2005 for vlc-0.8.4a by  doxygen 1.4.2