1 /*****************************************************************************
2 * dummy.c: dummy muxer module for vlc
3 *****************************************************************************
4 * Copyright (C) 2001, 2002 VideoLAN
5 * $Id: dummy.c,v 1.10 2003/12/14 22:49:28 gbazin Exp $
7 * Authors: Laurent Aimar <fenrir@via.ecp.fr>
8 * Eric Petit <titer@videolan.org>
10 * This program is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License as published by
12 * the Free Software Foundation; either version 2 of the License, or
13 * (at your option) any later version.
15 * This program is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU General Public License for more details.
20 * You should have received a copy of the GNU General Public License
21 * along with this program; if not, write to the Free Software
22 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111, USA.
23 *****************************************************************************/
25 /*****************************************************************************
27 *****************************************************************************/
31 #include <vlc/input.h>
36 /*****************************************************************************
38 *****************************************************************************/
39 static int Open ( vlc_object_t * );
40 static void Close ( vlc_object_t * );
43 set_description( _("Dummy/Raw muxer") );
44 set_capability( "sout mux", 5 );
45 add_shortcut( "dummy" );
46 add_shortcut( "raw" );
48 set_callbacks( Open, Close );
51 /*****************************************************************************
53 *****************************************************************************/
54 static int Capability(sout_mux_t *, int, void *, void * );
55 static int AddStream( sout_mux_t *, sout_input_t * );
56 static int DelStream( sout_mux_t *, sout_input_t * );
57 static int Mux ( sout_mux_t * );
61 /* Some streams have special initialization data, we'll output this
62 * data as an header in the stream. */
66 /*****************************************************************************
68 *****************************************************************************/
69 static int Open( vlc_object_t *p_this )
71 sout_mux_t *p_mux = (sout_mux_t*)p_this;
72 sout_mux_sys_t *p_sys;
74 msg_Dbg( p_mux, "Dummy/Raw muxer opened" );
75 msg_Info( p_mux, "Open" );
77 p_mux->pf_capacity = Capability;
78 p_mux->pf_addstream = AddStream;
79 p_mux->pf_delstream = DelStream;
82 p_mux->p_sys = p_sys = malloc( sizeof( sout_mux_sys_t ) );
83 p_sys->b_header = VLC_TRUE;
88 /*****************************************************************************
90 *****************************************************************************/
92 static void Close( vlc_object_t * p_this )
94 sout_mux_t *p_mux = (sout_mux_t*)p_this;
95 sout_mux_sys_t *p_sys = p_mux->p_sys;
97 msg_Dbg( p_mux, "Dummy/Raw muxer closed" );
101 static int Capability( sout_mux_t *p_mux, int i_query,
102 void *p_args, void *p_answer )
106 case SOUT_MUX_CAP_GET_ADD_STREAM_ANY_TIME:
107 *(vlc_bool_t*)p_answer = VLC_TRUE;
108 return( SOUT_MUX_CAP_ERR_OK );
110 return( SOUT_MUX_CAP_ERR_UNIMPLEMENTED );
114 static int AddStream( sout_mux_t *p_mux, sout_input_t *p_input )
116 msg_Dbg( p_mux, "adding input" );
120 static int DelStream( sout_mux_t *p_mux, sout_input_t *p_input )
122 msg_Dbg( p_mux, "removing input" );
126 static int Mux( sout_mux_t *p_mux )
128 sout_mux_sys_t *p_sys = p_mux->p_sys;
131 for( i = 0; i < p_mux->i_nb_inputs; i++ )
136 if( p_sys->b_header && p_mux->pp_inputs[i]->p_fmt->i_extra )
138 /* Write header data */
139 sout_buffer_t *p_data;
140 p_data = sout_BufferNew( p_mux->p_sout,
141 p_mux->pp_inputs[i]->p_fmt->i_extra );
143 memcpy( p_data->p_buffer, p_mux->pp_inputs[i]->p_fmt->p_extra,
144 p_mux->pp_inputs[i]->p_fmt->i_extra );
146 p_data->i_size = p_mux->pp_inputs[i]->p_fmt->i_extra;
147 p_data->i_dts = p_data->i_pts = p_data->i_length = 0;
149 msg_Dbg( p_mux, "writing header data" );
150 sout_AccessOutWrite( p_mux->p_access, p_data );
153 p_fifo = p_mux->pp_inputs[i]->p_fifo;
154 i_count = p_fifo->i_depth;
157 sout_buffer_t *p_data;
159 p_data = sout_FifoGet( p_fifo );
161 sout_AccessOutWrite( p_mux->p_access, p_data );
167 p_sys->b_header = VLC_FALSE;