Commit ca29b79f authored by Pierre Ynard's avatar Pierre Ynard

description: don't use vlc_object_find()

If you want to use #description, you need to set up the appropriate
struct on pass it down as a variable
parent 1a0ad6c1
...@@ -267,6 +267,14 @@ VLC_EXPORT( char *, vlc_sdp_Start, ( vlc_object_t *obj, const char *cfgpref, con ...@@ -267,6 +267,14 @@ VLC_EXPORT( char *, vlc_sdp_Start, ( vlc_object_t *obj, const char *cfgpref, con
VLC_EXPORT( char *, sdp_AddMedia, (char **sdp, const char *type, const char *protocol, int dport, unsigned pt, bool bw_indep, unsigned bw, const char *ptname, unsigned clockrate, unsigned channels, const char *fmtp) ); VLC_EXPORT( char *, sdp_AddMedia, (char **sdp, const char *type, const char *protocol, int dport, unsigned pt, bool bw_indep, unsigned bw, const char *ptname, unsigned clockrate, unsigned channels, const char *fmtp) );
VLC_EXPORT( char *, sdp_AddAttribute, (char **sdp, const char *name, const char *fmt, ...) LIBVLC_FORMAT( 3, 4 ) ); VLC_EXPORT( char *, sdp_AddAttribute, (char **sdp, const char *name, const char *fmt, ...) LIBVLC_FORMAT( 3, 4 ) );
/** Description module */
typedef struct sout_description_data_t
{
int i_es;
es_format_t **es;
vlc_sem_t *sem;
bool stop;
} sout_description_data_t;
#ifdef __cplusplus #ifdef __cplusplus
} }
......
...@@ -59,6 +59,7 @@ vlc_module_end () ...@@ -59,6 +59,7 @@ vlc_module_end ()
struct sout_stream_sys_t struct sout_stream_sys_t
{ {
sout_description_data_t *data;
mtime_t i_stream_start; mtime_t i_stream_start;
}; };
...@@ -79,6 +80,14 @@ static int Open( vlc_object_t *p_this ) ...@@ -79,6 +80,14 @@ static int Open( vlc_object_t *p_this )
p_stream->pf_send = Send; p_stream->pf_send = Send;
p_sys = p_stream->p_sys = malloc(sizeof(sout_stream_sys_t)); p_sys = p_stream->p_sys = malloc(sizeof(sout_stream_sys_t));
p_sys->data = var_InheritAddress(p_stream, "sout-description-data");
if (p_sys->data == NULL)
{
msg_Err(p_stream, "Missing data: the description stream output is "
"not meant to be used without special setup from the core");
free(p_sys);
return VLC_EGENERIC;
}
p_sys->i_stream_start = 0; p_sys->i_stream_start = 0;
return VLC_SUCCESS; return VLC_SUCCESS;
...@@ -102,22 +111,13 @@ static sout_stream_id_t *Add( sout_stream_t *p_stream, es_format_t *p_fmt ) ...@@ -102,22 +111,13 @@ static sout_stream_id_t *Add( sout_stream_t *p_stream, es_format_t *p_fmt )
sout_stream_sys_t *p_sys = p_stream->p_sys; sout_stream_sys_t *p_sys = p_stream->p_sys;
sout_stream_id_t *id; sout_stream_id_t *id;
es_format_t *p_fmt_copy; es_format_t *p_fmt_copy;
input_item_t *p_item;
input_thread_t *p_input;
msg_Dbg( p_stream, "Adding a stream" ); msg_Dbg( p_stream, "Adding a stream" );
p_input = vlc_object_find( p_stream, VLC_OBJECT_INPUT, FIND_PARENT );
assert( p_input );
p_item = input_GetItem(p_input);
p_fmt_copy = malloc(sizeof(es_format_t)); p_fmt_copy = malloc(sizeof(es_format_t));
es_format_Copy( p_fmt_copy, p_fmt ); es_format_Copy( p_fmt_copy, p_fmt );
vlc_mutex_lock( &p_item->lock ); TAB_APPEND( p_sys->data->i_es, p_sys->data->es, p_fmt_copy );
TAB_APPEND( p_item->i_es, p_item->es, p_fmt_copy );
vlc_mutex_unlock( &p_item->lock );
vlc_object_release( p_input );
if( p_sys->i_stream_start <= 0 ) if( p_sys->i_stream_start <= 0 )
p_sys->i_stream_start = mdate(); p_sys->i_stream_start = mdate();
...@@ -144,14 +144,8 @@ static int Send( sout_stream_t *p_stream, sout_stream_id_t *id, ...@@ -144,14 +144,8 @@ static int Send( sout_stream_t *p_stream, sout_stream_id_t *id,
if( p_sys->i_stream_start + 1500000 < mdate() ) if( p_sys->i_stream_start + 1500000 < mdate() )
{ {
input_thread_t *p_input; p_sys->data->stop = true;
vlc_sem_post(p_sys->data->sem);
p_input = vlc_object_find( p_stream, VLC_OBJECT_INPUT, FIND_PARENT );
if( p_input )
{
input_Stop( p_input, true );
vlc_object_release( p_input );
}
} }
return VLC_SUCCESS; return VLC_SUCCESS;
......
...@@ -615,28 +615,37 @@ static int vlm_OnMediaUpdate( vlm_t *p_vlm, vlm_media_sys_t *p_media ) ...@@ -615,28 +615,37 @@ static int vlm_OnMediaUpdate( vlm_t *p_vlm, vlm_media_sys_t *p_media )
if( asprintf( &psz_header, _("Media: %s"), p_cfg->psz_name ) == -1 ) if( asprintf( &psz_header, _("Media: %s"), p_cfg->psz_name ) == -1 )
psz_header = NULL; psz_header = NULL;
sout_description_data_t data;
TAB_INIT(data.i_es, data.es);
p_input = input_Create( p_vlm->p_vod, p_media->vod.p_item, psz_header, NULL ); p_input = input_Create( p_vlm->p_vod, p_media->vod.p_item, psz_header, NULL );
if( p_input ) if( p_input )
{ {
vlc_sem_t sem_preparse; vlc_sem_t sem_preparse;
vlc_sem_init( &sem_preparse, 0 ); vlc_sem_init( &sem_preparse, 0 );
var_AddCallback( p_input, "intf-event", InputEventPreparse, &sem_preparse ); var_AddCallback( p_input, "intf-event", InputEventPreparse, &sem_preparse );
data.stop = false;
data.sem = &sem_preparse;
var_Create( p_input, "sout-description-data", VLC_VAR_ADDRESS );
var_SetAddress( p_input, "sout-description-data", &data );
if( !input_Start( p_input ) ) if( !input_Start( p_input ) )
{ {
while( !p_input->b_dead && ( !p_cfg->vod.psz_mux || !input_item_IsPreparsed( p_media->vod.p_item ) ) ) while( !data.stop && !p_input->b_dead && ( !p_cfg->vod.psz_mux || !input_item_IsPreparsed( p_media->vod.p_item ) ) )
vlc_sem_wait( &sem_preparse ); vlc_sem_wait( &sem_preparse );
} }
var_DelCallback( p_input, "intf-event", InputEventPreparse, &sem_preparse ); var_DelCallback( p_input, "intf-event", InputEventPreparse, &sem_preparse );
vlc_sem_destroy( &sem_preparse );
input_Stop( p_input, true ); input_Stop( p_input, true );
vlc_thread_join( p_input ); vlc_thread_join( p_input );
vlc_object_release( p_input ); vlc_object_release( p_input );
vlc_sem_destroy( &sem_preparse );
} }
free( psz_header ); free( psz_header );
/* XXX: Don't do it that way, but properly use a new input item ref. */
input_item_t item = *p_media->vod.p_item;;
if( p_cfg->vod.psz_mux ) if( p_cfg->vod.psz_mux )
{ {
const char *psz_mux; const char *psz_mux;
...@@ -647,7 +656,6 @@ static int vlm_OnMediaUpdate( vlm_t *p_vlm, vlm_media_sys_t *p_media ) ...@@ -647,7 +656,6 @@ static int vlm_OnMediaUpdate( vlm_t *p_vlm, vlm_media_sys_t *p_media )
else else
psz_mux = p_cfg->vod.psz_mux; psz_mux = p_cfg->vod.psz_mux;
input_item_t item;
es_format_t es, *p_es = &es; es_format_t es, *p_es = &es;
union { char text[5]; uint32_t value; } fourcc; union { char text[5]; uint32_t value; } fourcc;
...@@ -657,20 +665,19 @@ static int vlm_OnMediaUpdate( vlm_t *p_vlm, vlm_media_sys_t *p_media ) ...@@ -657,20 +665,19 @@ static int vlm_OnMediaUpdate( vlm_t *p_vlm, vlm_media_sys_t *p_media )
fourcc.text[2] = tolower(fourcc.text[2]); fourcc.text[2] = tolower(fourcc.text[2]);
fourcc.text[3] = tolower(fourcc.text[3]); fourcc.text[3] = tolower(fourcc.text[3]);
/* XXX: Don't do it that way, but properly use a new input item ref. */
item = *p_media->vod.p_item;
item.i_es = 1; item.i_es = 1;
item.es = &p_es; item.es = &p_es;
es_format_Init( &es, VIDEO_ES, fourcc.value ); es_format_Init( &es, VIDEO_ES, fourcc.value );
p_media->vod.p_media =
p_vlm->p_vod->pf_media_new( p_vlm->p_vod, p_cfg->psz_name, &item );
} }
else else
{ {
p_media->vod.p_media = item.i_es = data.i_es;
p_vlm->p_vod->pf_media_new( p_vlm->p_vod, p_cfg->psz_name, p_media->vod.p_item ); item.es = data.es;
} }
p_media->vod.p_media = p_vlm->p_vod->pf_media_new( p_vlm->p_vod,
p_cfg->psz_name, &item );
TAB_CLEAN(data.i_es, data.es);
} }
} }
else if ( p_cfg->b_vod ) else if ( p_cfg->b_vod )
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment