| 1 |
|
|---|
| 2 |
|
|---|
| 3 |
|
|---|
| 4 |
|
|---|
| 5 |
|
|---|
| 6 |
|
|---|
| 7 |
|
|---|
| 8 |
|
|---|
| 9 |
|
|---|
| 10 |
|
|---|
| 11 |
|
|---|
| 12 |
|
|---|
| 13 |
|
|---|
| 14 |
|
|---|
| 15 |
|
|---|
| 16 |
|
|---|
| 17 |
|
|---|
| 18 |
|
|---|
| 19 |
|
|---|
| 20 |
|
|---|
| 21 |
|
|---|
| 22 |
|
|---|
| 23 |
|
|---|
| 24 |
|
|---|
| 25 |
|
|---|
| 26 |
|
|---|
| 27 |
|
|---|
| 28 |
#ifdef HAVE_CONFIG_H |
|---|
| 29 |
# include "config.h" |
|---|
| 30 |
#endif |
|---|
| 31 |
|
|---|
| 32 |
#include <vlc_common.h> |
|---|
| 33 |
#include <vlc_plugin.h> |
|---|
| 34 |
#include <vlc_input.h> |
|---|
| 35 |
#include <vlc_block.h> |
|---|
| 36 |
#include <vlc_sout.h> |
|---|
| 37 |
|
|---|
| 38 |
#include <assert.h> |
|---|
| 39 |
|
|---|
| 40 |
|
|---|
| 41 |
|
|---|
| 42 |
|
|---|
| 43 |
static int Open ( vlc_object_t * ); |
|---|
| 44 |
static void Close ( vlc_object_t * ); |
|---|
| 45 |
|
|---|
| 46 |
static sout_stream_id_t *Add ( sout_stream_t *, es_format_t * ); |
|---|
| 47 |
static int Del ( sout_stream_t *, sout_stream_id_t * ); |
|---|
| 48 |
static int Send( sout_stream_t *, sout_stream_id_t *, block_t* ); |
|---|
| 49 |
|
|---|
| 50 |
|
|---|
| 51 |
|
|---|
| 52 |
|
|---|
| 53 |
vlc_module_begin(); |
|---|
| 54 |
set_description( N_("Description stream output") ); |
|---|
| 55 |
set_capability( "sout stream", 50 ); |
|---|
| 56 |
add_shortcut( "description" ); |
|---|
| 57 |
set_callbacks( Open, Close ); |
|---|
| 58 |
vlc_module_end(); |
|---|
| 59 |
|
|---|
| 60 |
struct sout_stream_sys_t |
|---|
| 61 |
{ |
|---|
| 62 |
input_thread_t *p_input; |
|---|
| 63 |
|
|---|
| 64 |
mtime_t i_stream_start; |
|---|
| 65 |
}; |
|---|
| 66 |
|
|---|
| 67 |
struct sout_stream_id_t |
|---|
| 68 |
{ |
|---|
| 69 |
int i_d_u_m_m_y; |
|---|
| 70 |
}; |
|---|
| 71 |
|
|---|
| 72 |
|
|---|
| 73 |
|
|---|
| 74 |
|
|---|
| 75 |
static int Open( vlc_object_t *p_this ) |
|---|
| 76 |
{ |
|---|
| 77 |
sout_stream_t *p_stream = (sout_stream_t*)p_this; |
|---|
| 78 |
sout_stream_sys_t *p_sys; |
|---|
| 79 |
|
|---|
| 80 |
p_stream->pf_add = Add; |
|---|
| 81 |
p_stream->pf_del = Del; |
|---|
| 82 |
p_stream->pf_send = Send; |
|---|
| 83 |
p_sys = p_stream->p_sys = malloc(sizeof(sout_stream_sys_t)); |
|---|
| 84 |
|
|---|
| 85 |
p_sys->p_input = NULL; |
|---|
| 86 |
|
|---|
| 87 |
p_sys->i_stream_start = 0; |
|---|
| 88 |
|
|---|
| 89 |
return VLC_SUCCESS; |
|---|
| 90 |
} |
|---|
| 91 |
|
|---|
| 92 |
|
|---|
| 93 |
|
|---|
| 94 |
|
|---|
| 95 |
static void Close( vlc_object_t *p_this ) |
|---|
| 96 |
{ |
|---|
| 97 |
sout_stream_t *p_stream = (sout_stream_t *)p_this; |
|---|
| 98 |
sout_stream_sys_t *p_sys = p_stream->p_sys; |
|---|
| 99 |
|
|---|
| 100 |
msg_Dbg( p_this, "Closing" ); |
|---|
| 101 |
|
|---|
| 102 |
free( p_sys ); |
|---|
| 103 |
} |
|---|
| 104 |
|
|---|
| 105 |
static sout_stream_id_t *Add( sout_stream_t *p_stream, es_format_t *p_fmt ) |
|---|
| 106 |
{ |
|---|
| 107 |
sout_stream_sys_t *p_sys = p_stream->p_sys; |
|---|
| 108 |
sout_stream_id_t *id; |
|---|
| 109 |
es_format_t *p_fmt_copy; |
|---|
| 110 |
input_item_t *p_item; |
|---|
| 111 |
|
|---|
| 112 |
msg_Dbg( p_stream, "Adding a stream" ); |
|---|
| 113 |
|
|---|
| 114 |
if( !p_sys->p_input ) |
|---|
| 115 |
{ |
|---|
| 116 |
p_sys->p_input = vlc_object_find( p_stream, VLC_OBJECT_INPUT, |
|---|
| 117 |
FIND_PARENT ); |
|---|
| 118 |
|
|---|
| 119 |
|
|---|
| 120 |
|
|---|
| 121 |
|
|---|
| 122 |
|
|---|
| 123 |
|
|---|
| 124 |
|
|---|
| 125 |
assert( p_sys->p_input ); |
|---|
| 126 |
vlc_object_release( p_sys->p_input ); |
|---|
| 127 |
} |
|---|
| 128 |
|
|---|
| 129 |
p_item = input_GetItem(p_sys->p_input); |
|---|
| 130 |
|
|---|
| 131 |
p_fmt_copy = malloc(sizeof(es_format_t)); |
|---|
| 132 |
es_format_Copy( p_fmt_copy, p_fmt ); |
|---|
| 133 |
|
|---|
| 134 |
vlc_mutex_lock( &p_item->lock ); |
|---|
| 135 |
TAB_APPEND( p_item->i_es, p_item->es, p_fmt_copy ); |
|---|
| 136 |
vlc_mutex_unlock( &p_item->lock ); |
|---|
| 137 |
|
|---|
| 138 |
if( p_sys->i_stream_start <= 0 ) |
|---|
| 139 |
p_sys->i_stream_start = mdate(); |
|---|
| 140 |
|
|---|
| 141 |
id = malloc( sizeof( sout_stream_id_t ) ); |
|---|
| 142 |
id->i_d_u_m_m_y = 0; |
|---|
| 143 |
return id; |
|---|
| 144 |
} |
|---|
| 145 |
|
|---|
| 146 |
static int Del( sout_stream_t *p_stream, sout_stream_id_t *id ) |
|---|
| 147 |
{ |
|---|
| 148 |
msg_Dbg( p_stream, "Removing a stream" ); |
|---|
| 149 |
|
|---|
| 150 |
free( id ); |
|---|
| 151 |
return VLC_SUCCESS; |
|---|
| 152 |
} |
|---|
| 153 |
|
|---|
| 154 |
static int Send( sout_stream_t *p_stream, sout_stream_id_t *id, |
|---|
| 155 |
block_t *p_buffer ) |
|---|
| 156 |
{ |
|---|
| 157 |
VLC_UNUSED(id); |
|---|
| 158 |
sout_stream_sys_t *p_sys = p_stream->p_sys; |
|---|
| 159 |
|
|---|
| 160 |
block_ChainRelease( p_buffer ); |
|---|
| 161 |
|
|---|
| 162 |
if( p_sys->p_input && p_sys->i_stream_start + 1500000 < mdate() ) |
|---|
| 163 |
p_sys->p_input->b_eof = true; |
|---|
| 164 |
|
|---|
| 165 |
return VLC_SUCCESS; |
|---|
| 166 |
} |
|---|