]> git.sesse.net Git - vlc/blob - modules/mux/dummy.c
Remove most stray semi-colons in module descriptions
[vlc] / modules / mux / dummy.c
1 /*****************************************************************************
2  * dummy.c: dummy muxer module for vlc
3  *****************************************************************************
4  * Copyright (C) 2001, 2002 the VideoLAN team
5  * $Id$
6  *
7  * Authors: Laurent Aimar <fenrir@via.ecp.fr>
8  *          Eric Petit <titer@videolan.org>
9  *
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.
14  *
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.
19  *
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  *****************************************************************************/
24
25 /*****************************************************************************
26  * Preamble
27  *****************************************************************************/
28
29 #ifdef HAVE_CONFIG_H
30 # include "config.h"
31 #endif
32
33 #include <vlc_common.h>
34 #include <vlc_plugin.h>
35 #include <vlc_sout.h>
36 #include <vlc_block.h>
37
38 /*****************************************************************************
39  * Module descriptor
40  *****************************************************************************/
41 static int  Open   ( vlc_object_t * );
42 static void Close  ( vlc_object_t * );
43
44 vlc_module_begin ()
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" )
50     add_shortcut( "raw" )
51     add_shortcut( "es" )
52     set_callbacks( Open, Close )
53 vlc_module_end ()
54
55 /*****************************************************************************
56  * Exported prototypes
57  *****************************************************************************/
58 static int Control( sout_mux_t *, int, va_list );
59 static int AddStream( sout_mux_t *, sout_input_t * );
60 static int DelStream( sout_mux_t *, sout_input_t * );
61 static int Mux      ( sout_mux_t * );
62
63 struct sout_mux_sys_t
64 {
65     /* Some streams have special initialization data, we'll output this
66      * data as an header in the stream. */
67     bool b_header;
68 };
69
70 /*****************************************************************************
71  * Open:
72  *****************************************************************************/
73 static int Open( vlc_object_t *p_this )
74 {
75     sout_mux_t *p_mux = (sout_mux_t*)p_this;
76     sout_mux_sys_t  *p_sys;
77
78     msg_Dbg( p_mux, "Dummy/Raw muxer opened" );
79     msg_Info( p_mux, "Open" );
80
81     p_mux->pf_control   = Control;
82     p_mux->pf_addstream = AddStream;
83     p_mux->pf_delstream = DelStream;
84     p_mux->pf_mux       = Mux;
85
86     p_mux->p_sys = p_sys = malloc( sizeof( sout_mux_sys_t ) );
87     if( !p_sys )
88         return VLC_ENOMEM;
89     p_sys->b_header      = true;
90
91     return VLC_SUCCESS;
92 }
93
94 /*****************************************************************************
95  * Close:
96  *****************************************************************************/
97
98 static void Close( vlc_object_t * p_this )
99 {
100     sout_mux_t *p_mux = (sout_mux_t*)p_this;
101     sout_mux_sys_t *p_sys = p_mux->p_sys;
102
103     msg_Dbg( p_mux, "Dummy/Raw muxer closed" );
104     free( p_sys );
105 }
106
107 static int Control( sout_mux_t *p_mux, int i_query, va_list args )
108 {
109     VLC_UNUSED(p_mux);
110     bool *pb_bool;
111
112     switch( i_query )
113     {
114         case MUX_CAN_ADD_STREAM_WHILE_MUXING:
115             pb_bool = (bool*)va_arg( args, bool * );
116             *pb_bool = true;
117             return VLC_SUCCESS;
118
119         case MUX_GET_ADD_STREAM_WAIT:
120             pb_bool = (bool*)va_arg( args, bool * );
121             *pb_bool = false;
122             return VLC_SUCCESS;
123
124         case MUX_GET_MIME:   /* Unknown */
125         default:
126             return VLC_EGENERIC;
127    }
128 }
129
130 static int AddStream( sout_mux_t *p_mux, sout_input_t *p_input )
131 {
132     VLC_UNUSED(p_input);
133     msg_Dbg( p_mux, "adding input" );
134     return VLC_SUCCESS;
135 }
136
137 static int DelStream( sout_mux_t *p_mux, sout_input_t *p_input )
138 {
139     VLC_UNUSED(p_input);
140     msg_Dbg( p_mux, "removing input" );
141     return VLC_SUCCESS;
142 }
143
144 static int Mux( sout_mux_t *p_mux )
145 {
146     sout_mux_sys_t *p_sys = p_mux->p_sys;
147     int i;
148
149     for( i = 0; i < p_mux->i_nb_inputs; i++ )
150     {
151         block_fifo_t *p_fifo;
152         int i_count;
153
154         if( p_sys->b_header && p_mux->pp_inputs[i]->p_fmt->i_extra )
155         {
156             /* Write header data */
157             block_t *p_data;
158             p_data = block_New( p_mux, p_mux->pp_inputs[i]->p_fmt->i_extra );
159
160             memcpy( p_data->p_buffer, p_mux->pp_inputs[i]->p_fmt->p_extra,
161                     p_mux->pp_inputs[i]->p_fmt->i_extra );
162
163             msg_Dbg( p_mux, "writing header data" );
164             sout_AccessOutWrite( p_mux->p_access, p_data );
165         }
166
167         p_fifo = p_mux->pp_inputs[i]->p_fifo;
168         i_count = block_FifoCount( p_fifo );
169         while( i_count > 0 )
170         {
171             block_t *p_data = block_FifoGet( p_fifo );
172
173             sout_AccessOutWrite( p_mux->p_access, p_data );
174
175             i_count--;
176         }
177     }
178     p_sys->b_header = false;
179
180     return VLC_SUCCESS;
181 }