]> git.sesse.net Git - vlc/blob - modules/mux/dummy.c
73fbdc0eef32551ed6101f03adfc36ec169b2bde
[vlc] / modules / mux / dummy.c
1 /*****************************************************************************
2  * dummy.c
3  *****************************************************************************
4  * Copyright (C) 2001, 2002 VideoLAN
5  * $Id: dummy.c,v 1.6 2003/03/03 14:21:08 gbazin Exp $
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., 59 Temple Place - Suite 330, Boston, MA  02111, USA.
23  *****************************************************************************/
24
25 /*****************************************************************************
26  * Preamble
27  *****************************************************************************/
28 #include <stdlib.h>
29 #include <sys/types.h>
30 #include <sys/stat.h>
31 #include <string.h>
32 #include <errno.h>
33 #include <fcntl.h>
34
35 #include <vlc/vlc.h>
36 #include <vlc/input.h>
37 #include <vlc/sout.h>
38
39 #ifdef HAVE_UNISTD_H
40 #   include <unistd.h>
41 #endif
42
43 #include "codecs.h"
44
45 /*****************************************************************************
46  * Exported prototypes
47  *****************************************************************************/
48 static int     Open   ( vlc_object_t * );
49 static void    Close  ( vlc_object_t * );
50
51 static int Capability(sout_instance_t *, int, void *, void * );
52 static int AddStream( sout_instance_t *, sout_input_t * );
53 static int DelStream( sout_instance_t *, sout_input_t * );
54 static int Mux      ( sout_instance_t * );
55
56 /*****************************************************************************
57  * Module descriptor
58  *****************************************************************************/
59 vlc_module_begin();
60     set_description( _("Dummy muxer") );
61     set_capability( "sout mux", 5 );
62     add_shortcut( "dummy" );
63     set_callbacks( Open, Close );
64 vlc_module_end();
65
66 /*****************************************************************************
67  * Open:
68  *****************************************************************************/
69 static int Open( vlc_object_t *p_this )
70 {
71     sout_instance_t     *p_sout = (sout_instance_t*)p_this;
72
73     msg_Info( p_sout, "Open" );
74
75     p_sout->pf_mux_capacity  = Capability;
76     p_sout->pf_mux_addstream = AddStream;
77     p_sout->pf_mux_delstream = DelStream;
78     p_sout->pf_mux           = Mux;
79
80     return VLC_SUCCESS;
81 }
82
83 /*****************************************************************************
84  * Close:
85  *****************************************************************************/
86
87 static void Close( vlc_object_t * p_this )
88 {
89     sout_instance_t     *p_sout = (sout_instance_t*)p_this;
90     msg_Info( p_sout, "Close" );
91 }
92
93 static int Capability( sout_instance_t *p_sout, int i_query, void *p_args, void *p_answer )
94 {
95    switch( i_query )
96    {
97         case SOUT_MUX_CAP_GET_ADD_STREAM_ANY_TIME:
98             *(vlc_bool_t*)p_answer = VLC_TRUE;
99             return( SOUT_MUX_CAP_ERR_OK );
100         default:
101             return( SOUT_MUX_CAP_ERR_UNIMPLEMENTED );
102    }
103 }
104
105 static int AddStream( sout_instance_t *p_sout, sout_input_t *p_input )
106 {
107     msg_Dbg( p_sout, "adding input" );
108     return( 0 );
109 }
110
111 static int DelStream( sout_instance_t *p_sout, sout_input_t *p_input )
112 {
113
114     msg_Dbg( p_sout, "removing input" );
115     return( 0 );
116 }
117
118 static int Mux      ( sout_instance_t *p_sout )
119 {
120     int i;
121     for( i = 0; i < p_sout->i_nb_inputs; i++ )
122     {
123         int i_count;
124         sout_fifo_t *p_fifo;
125
126         p_fifo = p_sout->pp_inputs[i]->p_fifo;
127         i_count = p_fifo->i_depth;
128         while( i_count > 0 )
129         {
130             sout_buffer_t *p_data;
131
132             p_data = sout_FifoGet( p_fifo );
133
134             sout_AccessOutWrite( p_sout->p_access, p_data );
135
136             i_count--;
137         }
138
139     }
140     return( 0 );
141 }
142