1 /*****************************************************************************
2 * description.c: description stream output module (gathers ES info)
3 *****************************************************************************
4 * Copyright (C) 2003-2004 VLC authors and VideoLAN
7 * Authors: Gildas Bazin <gbazin@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>
34 #include <vlc_input.h>
35 #include <vlc_block.h>
40 /*****************************************************************************
42 *****************************************************************************/
43 static int Open ( vlc_object_t * );
44 static void Close ( vlc_object_t * );
46 static sout_stream_id_sys_t *Add ( sout_stream_t *, es_format_t * );
47 static int Del ( sout_stream_t *, sout_stream_id_sys_t * );
48 static int Send( sout_stream_t *, sout_stream_id_sys_t *, block_t* );
50 /*****************************************************************************
52 *****************************************************************************/
54 set_description( N_("Description stream output") )
55 set_capability( "sout stream", 50 )
56 add_shortcut( "description" )
57 set_callbacks( Open, Close )
60 struct sout_stream_sys_t
62 sout_description_data_t *data;
63 mtime_t i_stream_start;
66 struct sout_stream_id_sys_t
70 /*****************************************************************************
72 *****************************************************************************/
73 static int Open( vlc_object_t *p_this )
75 sout_stream_t *p_stream = (sout_stream_t*)p_this;
76 sout_stream_sys_t *p_sys;
78 p_stream->pf_add = Add;
79 p_stream->pf_del = Del;
80 p_stream->pf_send = Send;
81 p_sys = p_stream->p_sys = malloc(sizeof(sout_stream_sys_t));
83 p_sys->data = var_InheritAddress(p_stream, "sout-description-data");
84 if (p_sys->data == NULL)
86 msg_Err(p_stream, "Missing data: the description stream output is "
87 "not meant to be used without special setup from the core");
91 p_sys->i_stream_start = 0;
96 /*****************************************************************************
98 *****************************************************************************/
99 static void Close( vlc_object_t *p_this )
101 sout_stream_t *p_stream = (sout_stream_t *)p_this;
102 sout_stream_sys_t *p_sys = p_stream->p_sys;
104 msg_Dbg( p_this, "Closing" );
109 static sout_stream_id_sys_t *Add( sout_stream_t *p_stream, es_format_t *p_fmt )
111 sout_stream_sys_t *p_sys = p_stream->p_sys;
112 sout_stream_id_sys_t *id;
113 es_format_t *p_fmt_copy;
115 msg_Dbg( p_stream, "Adding a stream" );
117 p_fmt_copy = malloc(sizeof(es_format_t));
118 es_format_Copy( p_fmt_copy, p_fmt );
120 TAB_APPEND( p_sys->data->i_es, p_sys->data->es, p_fmt_copy );
122 if( p_sys->i_stream_start <= 0 )
123 p_sys->i_stream_start = mdate();
125 id = malloc( sizeof( sout_stream_id_sys_t ) );
129 static int Del( sout_stream_t *p_stream, sout_stream_id_sys_t *id )
131 msg_Dbg( p_stream, "Removing a stream" );
137 static int Send( sout_stream_t *p_stream, sout_stream_id_sys_t *id,
141 sout_stream_sys_t *p_sys = p_stream->p_sys;
143 block_ChainRelease( p_buffer );
145 if( p_sys->i_stream_start + 1500000 < mdate() )
146 vlc_sem_post(p_sys->data->sem);