1 /*****************************************************************************
2 * dummy.c: dummy muxer module for vlc
3 *****************************************************************************
4 * Copyright (C) 2001, 2002 the VideoLAN team
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., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
23 *****************************************************************************/
25 /*****************************************************************************
27 *****************************************************************************/
33 #include <vlc_common.h>
34 #include <vlc_plugin.h>
36 #include <vlc_block.h>
38 /*****************************************************************************
40 *****************************************************************************/
41 static int Open ( vlc_object_t
* );
42 static void Close ( vlc_object_t
* );
45 set_description( N_("Dummy/Raw muxer") )
46 set_capability( "sout mux", 5 )
47 set_category( CAT_SOUT
)
48 set_subcategory( SUBCAT_SOUT_MUX
)
49 add_shortcut( "dummy", "raw", "es" )
50 set_callbacks( Open
, Close
)
53 /*****************************************************************************
55 *****************************************************************************/
56 static int Control( sout_mux_t
*, int, va_list );
57 static int AddStream( sout_mux_t
*, sout_input_t
* );
58 static int DelStream( sout_mux_t
*, sout_input_t
* );
59 static int Mux ( sout_mux_t
* );
63 /* Some streams have special initialization data, we'll output this
64 * data as an header in the stream. */
68 /*****************************************************************************
70 *****************************************************************************/
71 static int Open( vlc_object_t
*p_this
)
73 sout_mux_t
*p_mux
= (sout_mux_t
*)p_this
;
74 sout_mux_sys_t
*p_sys
;
76 msg_Dbg( p_mux
, "Dummy/Raw muxer opened" );
77 msg_Info( p_mux
, "Open" );
79 p_mux
->pf_control
= Control
;
80 p_mux
->pf_addstream
= AddStream
;
81 p_mux
->pf_delstream
= DelStream
;
84 p_mux
->p_sys
= p_sys
= malloc( sizeof( sout_mux_sys_t
) );
87 p_sys
->b_header
= true;
92 /*****************************************************************************
94 *****************************************************************************/
96 static void Close( vlc_object_t
* p_this
)
98 sout_mux_t
*p_mux
= (sout_mux_t
*)p_this
;
99 sout_mux_sys_t
*p_sys
= p_mux
->p_sys
;
101 msg_Dbg( p_mux
, "Dummy/Raw muxer closed" );
105 static int Control( sout_mux_t
*p_mux
, int i_query
, va_list args
)
112 case MUX_CAN_ADD_STREAM_WHILE_MUXING
:
113 pb_bool
= (bool*)va_arg( args
, bool * );
117 case MUX_GET_ADD_STREAM_WAIT
:
118 pb_bool
= (bool*)va_arg( args
, bool * );
122 case MUX_GET_MIME
: /* Unknown */
128 static int AddStream( sout_mux_t
*p_mux
, sout_input_t
*p_input
)
131 msg_Dbg( p_mux
, "adding input" );
135 static int DelStream( sout_mux_t
*p_mux
, sout_input_t
*p_input
)
138 msg_Dbg( p_mux
, "removing input" );
142 static int Mux( sout_mux_t
*p_mux
)
144 sout_mux_sys_t
*p_sys
= p_mux
->p_sys
;
147 for( i
= 0; i
< p_mux
->i_nb_inputs
; i
++ )
149 block_fifo_t
*p_fifo
;
152 if( p_sys
->b_header
&& p_mux
->pp_inputs
[i
]->p_fmt
->i_extra
)
154 /* Write header data */
156 p_data
= block_New( p_mux
, p_mux
->pp_inputs
[i
]->p_fmt
->i_extra
);
158 memcpy( p_data
->p_buffer
, p_mux
->pp_inputs
[i
]->p_fmt
->p_extra
,
159 p_mux
->pp_inputs
[i
]->p_fmt
->i_extra
);
161 msg_Dbg( p_mux
, "writing header data" );
162 sout_AccessOutWrite( p_mux
->p_access
, p_data
);
165 p_fifo
= p_mux
->pp_inputs
[i
]->p_fifo
;
166 i_count
= block_FifoCount( p_fifo
);
169 block_t
*p_data
= block_FifoGet( p_fifo
);
171 sout_AccessOutWrite( p_mux
->p_access
, p_data
);
176 p_sys
->b_header
= false;