1 /*****************************************************************************
3 *****************************************************************************
4 * Copyright (C) 2001, 2002 VideoLAN
5 * $Id: standard.c,v 1.1 2003/04/13 20:00:21 fenrir Exp $
7 * Authors: Laurent Aimar <fenrir@via.ecp.fr>
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; either version 2 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 General Public License for more details.
19 * You should have received a copy of the GNU General Public License
20 * along with this program; if not, write to the Free Software
21 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111, USA.
22 *****************************************************************************/
24 /*****************************************************************************
26 *****************************************************************************/
33 /*****************************************************************************
35 *****************************************************************************/
36 static int Open ( vlc_object_t * );
37 static void Close ( vlc_object_t * );
39 static sout_stream_id_t *Add ( sout_stream_t *, sout_format_t * );
40 static int Del ( sout_stream_t *, sout_stream_id_t * );
41 static int Send( sout_stream_t *, sout_stream_id_t *, sout_buffer_t* );
43 /*****************************************************************************
45 *****************************************************************************/
47 set_description( _("Standard stream") );
48 set_capability( "sout stream", 50 );
49 add_shortcut( "standard" );
50 add_shortcut( "std" );
51 set_callbacks( Open, Close );
54 struct sout_stream_sys_t
59 /*****************************************************************************
61 *****************************************************************************/
62 static int Open( vlc_object_t *p_this )
64 sout_stream_t *p_stream = (sout_stream_t*)p_this;
65 sout_instance_t *p_sout = p_stream->p_sout;
66 sout_stream_sys_t *p_sys;
68 char *psz_mux = sout_cfg_find_value( p_stream->p_cfg, "mux" );
69 char *psz_access = sout_cfg_find_value( p_stream->p_cfg, "access" );
70 char *psz_url = sout_cfg_find_value( p_stream->p_cfg, "url" );
72 sout_access_out_t *p_access;
75 msg_Dbg( p_this, "creating `%s/%s://%s'",
76 psz_access, psz_mux, psz_url );
78 /* *** find and open appropriate access module *** */
79 p_access = sout_AccessOutNew( p_sout, psz_access, psz_url );
80 if( p_access == NULL )
82 msg_Err( p_stream, "no suitable sout access module for `%s/%s://%s'",
83 psz_access, psz_mux, psz_url );
84 return( VLC_EGENERIC );
86 msg_Dbg( p_stream, "access opened" );
88 /* *** find and open appropriate mux module *** */
89 p_mux = sout_MuxNew( p_sout, psz_mux, p_access );
92 msg_Err( p_stream, "no suitable sout mux module for `%s/%s://%s'",
93 psz_access, psz_mux, psz_url );
95 sout_AccessOutDelete( p_access );
96 return( VLC_EGENERIC );
98 msg_Dbg( p_stream, "mux opened" );
101 p_sout->i_preheader = __MAX( p_sout->i_preheader, p_mux->i_preheader );
103 p_sys = malloc( sizeof( sout_stream_sys_t ) );
104 p_sys->p_mux = p_mux;
106 p_stream->pf_add = Add;
107 p_stream->pf_del = Del;
108 p_stream->pf_send = Send;
110 p_stream->p_sys = p_sys;
115 /*****************************************************************************
117 *****************************************************************************/
119 static void Close( vlc_object_t * p_this )
121 sout_stream_t *p_stream = (sout_stream_t*)p_this;
122 sout_stream_sys_t *p_sys = p_stream->p_sys;
124 sout_access_out_t *p_access = p_sys->p_mux->p_access;
127 sout_MuxDelete( p_sys->p_mux );
128 sout_AccessOutDelete( p_access );
133 struct sout_stream_id_t
135 sout_input_t *p_input;
139 static sout_stream_id_t * Add ( sout_stream_t *p_stream, sout_format_t *p_fmt )
141 sout_stream_sys_t *p_sys = p_stream->p_sys;
142 sout_stream_id_t *id;
144 id = malloc( sizeof( sout_stream_id_t ) );
145 if( ( id->p_input = sout_MuxAddStream( p_sys->p_mux, p_fmt ) ) == NULL )
155 static int Del ( sout_stream_t *p_stream, sout_stream_id_t *id )
157 sout_stream_sys_t *p_sys = p_stream->p_sys;
159 sout_MuxDeleteStream( p_sys->p_mux, id->p_input );
166 static int Send ( sout_stream_t *p_stream, sout_stream_id_t *id, sout_buffer_t *p_buffer )
168 sout_stream_sys_t *p_sys = p_stream->p_sys;
170 sout_MuxSendBuffer( p_sys->p_mux, id->p_input, p_buffer );