00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028 #include <stdlib.h>
00029
00030 #include <vlc/vlc.h>
00031 #include <vlc/sout.h>
00032
00033
00034
00035
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
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
00062
00063 vlc_bool_t b_header;
00064 };
00065
00066
00067
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
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:
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
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 }