1 /*****************************************************************************
2 * dummy.c: dummy muxer module for vlc
3 *****************************************************************************
4 * Copyright (C) 2001, 2002 VLC authors and VideoLAN
6 * Authors: Laurent Aimar <fenrir@via.ecp.fr>
7 * Eric Petit <titer@videolan.org>
9 * This program is free software; you can redistribute it and/or modify it
10 * under the terms of the GNU Lesser General Public License as published by
11 * the Free Software Foundation; either version 2.1 of the License, or
12 * (at your option) any later version.
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU Lesser General Public License for more details.
19 * You should have received a copy of the GNU Lesser General Public License
20 * along with this program; if not, write to the Free Software Foundation,
21 * Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
22 *****************************************************************************/
24 /*****************************************************************************
26 *****************************************************************************/
32 #include <vlc_common.h>
33 #include <vlc_plugin.h>
35 #include <vlc_block.h>
37 /*****************************************************************************
39 *****************************************************************************/
40 static int Open ( vlc_object_t
* );
41 static void Close ( vlc_object_t
* );
44 set_description( N_("Dummy/Raw muxer") )
45 set_capability( "sout mux", 5 )
46 set_category( CAT_SOUT
)
47 set_subcategory( SUBCAT_SOUT_MUX
)
48 add_shortcut( "dummy", "raw", "es" )
49 set_callbacks( Open
, Close
)
52 /*****************************************************************************
54 *****************************************************************************/
55 static int Control( sout_mux_t
*, int, va_list );
56 static int AddStream( sout_mux_t
*, sout_input_t
* );
57 static void DelStream( sout_mux_t
*, sout_input_t
* );
58 static int Mux ( sout_mux_t
* );
62 /* Some streams have special initialization data, we'll output this
63 * data as an header in the stream. */
67 /*****************************************************************************
69 *****************************************************************************/
70 static int Open( vlc_object_t
*p_this
)
72 sout_mux_t
*p_mux
= (sout_mux_t
*)p_this
;
73 sout_mux_sys_t
*p_sys
;
75 msg_Dbg( p_mux
, "Dummy/Raw muxer opened" );
76 msg_Info( p_mux
, "Open" );
78 p_mux
->pf_control
= Control
;
79 p_mux
->pf_addstream
= AddStream
;
80 p_mux
->pf_delstream
= DelStream
;
83 p_mux
->p_sys
= p_sys
= malloc( sizeof( sout_mux_sys_t
) );
86 p_sys
->b_header
= true;
91 /*****************************************************************************
93 *****************************************************************************/
95 static void Close( vlc_object_t
* p_this
)
97 sout_mux_t
*p_mux
= (sout_mux_t
*)p_this
;
98 sout_mux_sys_t
*p_sys
= p_mux
->p_sys
;
100 msg_Dbg( p_mux
, "Dummy/Raw muxer closed" );
104 static int Control( sout_mux_t
*p_mux
, int i_query
, va_list args
)
111 case MUX_CAN_ADD_STREAM_WHILE_MUXING
:
112 pb_bool
= va_arg( args
, bool * );
116 case MUX_GET_MIME
: /* Unknown */
122 static int AddStream( sout_mux_t
*p_mux
, sout_input_t
*p_input
)
125 msg_Dbg( p_mux
, "adding input" );
129 static void DelStream( sout_mux_t
*p_mux
, sout_input_t
*p_input
)
132 msg_Dbg( p_mux
, "removing input" );
135 static int Mux( sout_mux_t
*p_mux
)
137 sout_mux_sys_t
*p_sys
= p_mux
->p_sys
;
140 for( i
= 0; i
< p_mux
->i_nb_inputs
; i
++ )
142 block_fifo_t
*p_fifo
;
145 if( p_sys
->b_header
&& p_mux
->pp_inputs
[i
]->p_fmt
->i_extra
)
147 /* Write header data */
149 p_data
= block_Alloc( p_mux
->pp_inputs
[i
]->p_fmt
->i_extra
);
151 memcpy( p_data
->p_buffer
, p_mux
->pp_inputs
[i
]->p_fmt
->p_extra
,
152 p_mux
->pp_inputs
[i
]->p_fmt
->i_extra
);
154 p_data
->i_flags
|= BLOCK_FLAG_HEADER
;
156 msg_Dbg( p_mux
, "writing header data" );
157 sout_AccessOutWrite( p_mux
->p_access
, p_data
);
160 p_fifo
= p_mux
->pp_inputs
[i
]->p_fifo
;
161 i_count
= block_FifoCount( p_fifo
);
164 block_t
*p_data
= block_FifoGet( p_fifo
);
166 sout_AccessOutWrite( p_mux
->p_access
, p_data
);
171 p_sys
->b_header
= false;