[vlc-commits] commit: description: don't use vlc_object_find() (Pierre Ynard )
git at videolan.org
git at videolan.org
Thu Nov 25 18:13:03 CET 2010
vlc | branch: master | Pierre Ynard <linkfanel at yahoo.fr> | Thu Nov 25 18:09:30 2010 +0100| [ca29b79feed402d3c896005dfddab9d1026afd3f] | committer: 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
> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=ca29b79feed402d3c896005dfddab9d1026afd3f
---
include/vlc_sout.h | 8 ++++++++
modules/stream_out/description.c | 30 ++++++++++++------------------
src/input/vlm.c | 27 +++++++++++++++++----------
3 files changed, 37 insertions(+), 28 deletions(-)
diff --git a/include/vlc_sout.h b/include/vlc_sout.h
index 50704c1..2c8f2a1 100644
--- a/include/vlc_sout.h
+++ b/include/vlc_sout.h
@@ -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_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
}
diff --git a/modules/stream_out/description.c b/modules/stream_out/description.c
index 6930642..a53ae96 100644
--- a/modules/stream_out/description.c
+++ b/modules/stream_out/description.c
@@ -59,6 +59,7 @@ vlc_module_end ()
struct sout_stream_sys_t
{
+ sout_description_data_t *data;
mtime_t i_stream_start;
};
@@ -79,6 +80,14 @@ static int Open( vlc_object_t *p_this )
p_stream->pf_send = Send;
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;
return VLC_SUCCESS;
@@ -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_id_t *id;
es_format_t *p_fmt_copy;
- input_item_t *p_item;
- input_thread_t *p_input;
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));
es_format_Copy( p_fmt_copy, p_fmt );
- vlc_mutex_lock( &p_item->lock );
- TAB_APPEND( p_item->i_es, p_item->es, p_fmt_copy );
- vlc_mutex_unlock( &p_item->lock );
- vlc_object_release( p_input );
+ TAB_APPEND( p_sys->data->i_es, p_sys->data->es, p_fmt_copy );
if( p_sys->i_stream_start <= 0 )
p_sys->i_stream_start = mdate();
@@ -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() )
{
- input_thread_t *p_input;
-
- 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 );
- }
+ p_sys->data->stop = true;
+ vlc_sem_post(p_sys->data->sem);
}
return VLC_SUCCESS;
diff --git a/src/input/vlm.c b/src/input/vlm.c
index 38056b4..df2674d 100644
--- a/src/input/vlm.c
+++ b/src/input/vlm.c
@@ -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 )
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 );
if( p_input )
{
vlc_sem_t sem_preparse;
vlc_sem_init( &sem_preparse, 0 );
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 ) )
{
- 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 );
}
var_DelCallback( p_input, "intf-event", InputEventPreparse, &sem_preparse );
- vlc_sem_destroy( &sem_preparse );
input_Stop( p_input, true );
vlc_thread_join( p_input );
vlc_object_release( p_input );
+ vlc_sem_destroy( &sem_preparse );
}
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 )
{
const char *psz_mux;
@@ -647,7 +656,6 @@ static int vlm_OnMediaUpdate( vlm_t *p_vlm, vlm_media_sys_t *p_media )
else
psz_mux = p_cfg->vod.psz_mux;
- input_item_t item;
es_format_t es, *p_es = &es;
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 )
fourcc.text[2] = tolower(fourcc.text[2]);
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.es = &p_es;
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
{
- p_media->vod.p_media =
- p_vlm->p_vod->pf_media_new( p_vlm->p_vod, p_cfg->psz_name, p_media->vod.p_item );
+ item.i_es = data.i_es;
+ 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 )
More information about the vlc-commits
mailing list