qt: playlist: use item title if available
[vlc.git] / modules / mux / dummy.c
blobd9600f41e97d59d1c4b849e52c932b027a2ae786
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 /*****************************************************************************
25 * Preamble
26 *****************************************************************************/
28 #ifdef HAVE_CONFIG_H
29 # include "config.h"
30 #endif
32 #include <vlc_common.h>
33 #include <vlc_plugin.h>
34 #include <vlc_sout.h>
35 #include <vlc_block.h>
37 /*****************************************************************************
38 * Module descriptor
39 *****************************************************************************/
40 static int Open ( vlc_object_t * );
41 static void Close ( vlc_object_t * );
43 vlc_module_begin ()
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 )
50 vlc_module_end ()
52 /*****************************************************************************
53 * Exported prototypes
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 * );
60 typedef struct
62 /* Some streams have special initialization data, we'll output this
63 * data as an header in the stream. */
64 bool b_header;
65 } sout_mux_sys_t;
67 /*****************************************************************************
68 * Open:
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;
81 p_mux->pf_mux = Mux;
83 p_mux->p_sys = p_sys = malloc( sizeof( sout_mux_sys_t ) );
84 if( !p_sys )
85 return VLC_ENOMEM;
86 p_sys->b_header = true;
88 return VLC_SUCCESS;
91 /*****************************************************************************
92 * Close:
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" );
101 free( p_sys );
104 static int Control( sout_mux_t *p_mux, int i_query, va_list args )
106 VLC_UNUSED(p_mux);
107 bool *pb_bool;
109 switch( i_query )
111 case MUX_CAN_ADD_STREAM_WHILE_MUXING:
112 pb_bool = va_arg( args, bool * );
113 *pb_bool = true;
114 return VLC_SUCCESS;
116 case MUX_GET_MIME: /* Unknown */
117 default:
118 return VLC_EGENERIC;
122 static int AddStream( sout_mux_t *p_mux, sout_input_t *p_input )
124 VLC_UNUSED(p_input);
125 msg_Dbg( p_mux, "adding input" );
126 return VLC_SUCCESS;
129 static void DelStream( sout_mux_t *p_mux, sout_input_t *p_input )
131 VLC_UNUSED(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;
138 int i;
140 for( i = 0; i < p_mux->i_nb_inputs; i++ )
142 block_fifo_t *p_fifo;
143 int i_count;
145 if( p_sys->b_header && p_mux->pp_inputs[i]->p_fmt->i_extra )
147 /* Write header data */
148 block_t *p_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 );
162 while( i_count > 0 )
164 block_t *p_data = block_FifoGet( p_fifo );
166 sout_AccessOutWrite( p_mux->p_access, p_data );
168 i_count--;
171 p_sys->b_header = false;
173 return VLC_SUCCESS;