Main Page | Modules | Class Hierarchy | Class List | Directories | File List | Class Members | File Members | Related Pages

description.c

00001 /*****************************************************************************
00002  * description.c: description stream output module (gathers ES info)
00003  *****************************************************************************
00004  * Copyright (C) 2003-2004 the VideoLAN team
00005  * $Id: description.c 11664 2005-07-09 06:17:09Z courmisch $
00006  *
00007  * Authors: Gildas Bazin <[email protected]>
00008  *
00009  * This program is free software; you can redistribute it and/or modify
00010  * it under the terms of the GNU General Public License as published by
00011  * the Free Software Foundation; either version 2 of the License, or
00012  * (at your option) any later version.
00013  *
00014  * This program is distributed in the hope that it will be useful,
00015  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00016  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00017  * GNU General Public License for more details.
00018  *
00019  * You should have received a copy of the GNU General Public License
00020  * along with this program; if not, write to the Free Software
00021  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111, USA.
00022  *****************************************************************************/
00023 
00024 /*****************************************************************************
00025  * Preamble
00026  *****************************************************************************/
00027 #include <stdlib.h>
00028 #include <string.h>
00029 
00030 #include <vlc/vlc.h>
00031 #include <vlc/input.h>
00032 #include <vlc/sout.h>
00033 
00034 /*****************************************************************************
00035  * Exported prototypes
00036  *****************************************************************************/
00037 static int      Open    ( vlc_object_t * );
00038 static void     Close   ( vlc_object_t * );
00039 
00040 static sout_stream_id_t *Add ( sout_stream_t *, es_format_t * );
00041 static int               Del ( sout_stream_t *, sout_stream_id_t * );
00042 static int               Send( sout_stream_t *, sout_stream_id_t *, block_t* );
00043 
00044 /*****************************************************************************
00045  * Module descriptor
00046  *****************************************************************************/
00047 vlc_module_begin();
00048     set_description( _("Description stream output") );
00049     set_capability( "sout stream", 50 );
00050     add_shortcut( "description" );
00051     set_callbacks( Open, Close );
00052 vlc_module_end();
00053 
00054 struct sout_stream_sys_t
00055 {
00056     input_thread_t *p_input;
00057     mtime_t i_stream_start;
00058 };
00059 
00060 struct sout_stream_id_t
00061 {
00062     int i_d_u_m_m_y;
00063 };
00064 
00065 /*****************************************************************************
00066  * Open:
00067  *****************************************************************************/
00068 static int Open( vlc_object_t *p_this )
00069 {
00070     sout_stream_t *p_stream = (sout_stream_t*)p_this;
00071     sout_stream_sys_t *p_sys;
00072 
00073     p_stream->pf_add  = Add;
00074     p_stream->pf_del  = Del;
00075     p_stream->pf_send = Send;
00076     p_sys = p_stream->p_sys = malloc(sizeof(sout_stream_sys_t));
00077 
00078     p_sys->p_input = vlc_object_find( p_this, VLC_OBJECT_INPUT, FIND_PARENT );
00079     if( !p_sys->p_input ) return VLC_EGENERIC;
00080 
00081     p_sys->i_stream_start = 0;
00082 
00083     return VLC_SUCCESS;
00084 }
00085 
00086 /*****************************************************************************
00087  * Close:
00088  *****************************************************************************/
00089 static void Close( vlc_object_t *p_this )
00090 {
00091     sout_stream_t *p_stream = (sout_stream_t *)p_this;
00092     vlc_object_release( p_stream->p_sys->p_input );
00093 }
00094 
00095 static sout_stream_id_t *Add( sout_stream_t *p_stream, es_format_t *p_fmt )
00096 {
00097     sout_stream_sys_t *p_sys = p_stream->p_sys;
00098     sout_stream_id_t *id;
00099     es_format_t *p_fmt_copy = malloc(sizeof(es_format_t));
00100 
00101     id = malloc( sizeof( sout_stream_id_t ) );
00102     id->i_d_u_m_m_y = 0;
00103 
00104     es_format_Copy( p_fmt_copy, p_fmt );
00105 
00106     vlc_mutex_lock( &p_sys->p_input->input.p_item->lock );
00107     TAB_APPEND( p_sys->p_input->input.p_item->i_es,
00108                 p_sys->p_input->input.p_item->es, p_fmt_copy );
00109     vlc_mutex_unlock( &p_sys->p_input->input.p_item->lock );
00110 
00111     if( p_sys->i_stream_start <= 0 ) p_sys->i_stream_start = mdate();
00112 
00113     return id;
00114 }
00115 
00116 static int Del( sout_stream_t *p_stream, sout_stream_id_t *id )
00117 {
00118     free( id );
00119     return VLC_SUCCESS;
00120 }
00121 
00122 static int Send( sout_stream_t *p_stream, sout_stream_id_t *id,
00123                  block_t *p_buffer )
00124 {
00125     sout_stream_sys_t *p_sys = p_stream->p_sys;
00126 
00127     block_ChainRelease( p_buffer );
00128 
00129     if( p_sys->i_stream_start + 1500000 < mdate() )
00130     {
00131         p_sys->p_input->b_eof = VLC_TRUE;
00132     }
00133 
00134     return VLC_SUCCESS;
00135 }

Generated on Tue Dec 20 10:14:49 2005 for vlc-0.8.4a by  doxygen 1.4.2