00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
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
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
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
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
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 }