[vlc-devel] [RFC PATCH 04/10] input: Provide the potential renderer upon input item creation
Hugo Beauzée-Luyssen
hugo at beauzee.fr
Thu Sep 7 16:13:06 CEST 2017
On Thu, Sep 7, 2017, at 04:05 PM, Rémi Denis-Courmont wrote:
> Le 7 septembre 2017 16:46:00 GMT+03:00, "Hugo Beauzée-Luyssen"
> <hugo at beauzee.fr> a écrit :
> >---
> > include/vlc_input.h | 8 +++++---
> > lib/media_player.c | 2 +-
> > modules/misc/fingerprinter.c | 2 +-
> > src/input/input.c | 29 ++++++++++++++++++++++-------
> > src/input/vlm.c | 5 +++--
> > src/playlist/thread.c | 5 ++++-
> > 6 files changed, 36 insertions(+), 15 deletions(-)
> >
> >diff --git a/include/vlc_input.h b/include/vlc_input.h
> >index 3641f13295..13fe107fb6 100644
> >--- a/include/vlc_input.h
> >+++ b/include/vlc_input.h
> >@@ -494,8 +494,10 @@ enum input_query_e
> > * Prototypes
> >*****************************************************************************/
> >
> >-VLC_API input_thread_t * input_Create( vlc_object_t *p_parent,
> >input_item_t *, const char *psz_log, input_resource_t * ) VLC_USED;
> >-#define input_Create(a,b,c,d) input_Create(VLC_OBJECT(a),b,c,d)
> >+VLC_API input_thread_t * input_Create( vlc_object_t *p_parent,
> >input_item_t *,
> >+ const char *psz_log,
> >input_resource_t *,
> >+ vlc_renderer_item_t* p_renderer
> >) VLC_USED;
> >+#define input_Create(a,b,c,d,e) input_Create(VLC_OBJECT(a),b,c,d,e)
> >
> > VLC_API int input_Start( input_thread_t * );
> >
> >@@ -521,7 +523,7 @@ static inline
> > input_thread_t *input_CreateAndStart( vlc_object_t *parent,
> > input_item_t *item, const char *log )
> > {
> >- input_thread_t *input = input_Create( parent, item, log, NULL );
> >+ input_thread_t *input = input_Create( parent, item, log, NULL,
> >NULL );
> > if( input != NULL && input_Start( input ) )
> > {
> > vlc_object_release( input );
> >diff --git a/lib/media_player.c b/lib/media_player.c
> >index 65632952c2..3f073fa477 100644
> >--- a/lib/media_player.c
> >+++ b/lib/media_player.c
> >@@ -967,7 +967,7 @@ int libvlc_media_player_play( libvlc_media_player_t
> >*p_mi )
> > media_attach_preparsed_event( p_mi->p_md );
> >
> > p_input_thread = input_Create( p_mi, p_mi->p_md->p_input_item, NULL,
> >- p_mi->input.p_resource );
> >+ p_mi->input.p_resource, NULL );
> > unlock(p_mi);
> > if( !p_input_thread )
> > {
> >diff --git a/modules/misc/fingerprinter.c
> >b/modules/misc/fingerprinter.c
> >index 6f09362747..593b2ff8cc 100644
> >--- a/modules/misc/fingerprinter.c
> >+++ b/modules/misc/fingerprinter.c
> >@@ -183,7 +183,7 @@ static void DoFingerprint( fingerprinter_thread_t
> >*p_fingerprinter,
> > }
> > input_item_SetURI( p_item, psz_uri ) ;
> >
> >- input_thread_t *p_input = input_Create( p_fingerprinter, p_item,
> >"fingerprinter", NULL );
> >+ input_thread_t *p_input = input_Create( p_fingerprinter, p_item,
> >"fingerprinter", NULL, NULL );
> > input_item_Release( p_item );
> >
> > if( p_input == NULL )
> >diff --git a/src/input/input.c b/src/input/input.c
> >index 95a50b1488..956d441982 100644
> >--- a/src/input/input.c
> >+++ b/src/input/input.c
> >@@ -63,7 +63,8 @@ static void *Run( void * );
> > static void *Preparse( void * );
> >
> > static input_thread_t * Create ( vlc_object_t *, input_item_t *,
> >- const char *, bool, input_resource_t
> >* );
> >+ const char *, bool, input_resource_t
> >*,
> >+ vlc_renderer_item_t * );
> > static int Init ( input_thread_t *p_input );
> > static void End ( input_thread_t *p_input );
> >static void MainLoop( input_thread_t *p_input, bool
> >b_interactive );
> >@@ -126,9 +127,10 @@ static void input_ChangeState( input_thread_t
> >*p_input, int i_state ); /* TODO f
> > */
> > input_thread_t *input_Create( vlc_object_t *p_parent,
> > input_item_t *p_item,
> >- const char *psz_log, input_resource_t
> >*p_resource )
> >+ const char *psz_log, input_resource_t
> >*p_resource,
> >+ vlc_renderer_item_t *p_renderer )
> > {
> >- return Create( p_parent, p_item, psz_log, false, p_resource );
> >+ return Create( p_parent, p_item, psz_log, false, p_resource,
> >p_renderer );
> > }
> >
> > #undef input_Read
> >@@ -141,7 +143,7 @@ input_thread_t *input_Create( vlc_object_t
> >*p_parent,
> > */
> > int input_Read( vlc_object_t *p_parent, input_item_t *p_item )
> > {
> >- input_thread_t *p_input = Create( p_parent, p_item, NULL, false,
> >NULL );
> >+ input_thread_t *p_input = Create( p_parent, p_item, NULL, false,
> >NULL, NULL );
> > if( !p_input )
> > return VLC_EGENERIC;
> >
> >@@ -158,7 +160,7 @@ int input_Read( vlc_object_t *p_parent,
> >input_item_t *p_item )
> > input_thread_t *input_CreatePreparser( vlc_object_t *parent,
> > input_item_t *item )
> > {
> >- return Create( parent, item, NULL, true, NULL );
> >+ return Create( parent, item, NULL, true, NULL, NULL );
> > }
> >
> > /**
> >@@ -282,7 +284,8 @@ input_item_t *input_GetItem( input_thread_t
> >*p_input )
> >*****************************************************************************/
> >static input_thread_t *Create( vlc_object_t *p_parent, input_item_t
> >*p_item,
> > const char *psz_header, bool b_preparsing,
> >- input_resource_t *p_resource )
> >+ input_resource_t *p_resource,
> >+ vlc_renderer_item_t *p_renderer )
> > {
> > /* Allocate descriptor */
> > input_thread_private_t *priv;
> >@@ -323,6 +326,10 @@ static input_thread_t *Create( vlc_object_t
> >*p_parent, input_item_t *p_item,
> > priv->attachment_demux = NULL;
> > priv->p_sout = NULL;
> > priv->b_out_pace_control = false;
> >+ if( p_renderer )
> >+ priv->p_renderer = vlc_renderer_item_hold( p_renderer );
> >+ else
> >+ priv->p_renderer = NULL;
> >
> > priv->viewpoint_changed = false;
> > /* Fetch the viewpoint from the mediaplayer or the playlist if any */
> >@@ -839,7 +846,15 @@ static int InitSout( input_thread_t * p_input )
> > return VLC_SUCCESS;
> >
> > /* Find a usable sout and attach it to p_input */
> >- char *psz = var_GetNonEmptyString( p_input, "sout" );
> >+ char *psz = NULL;
> >+ if( priv->p_renderer )
> >+ {
> >+ const char *psz_renderer_sout = vlc_renderer_item_sout(
> >priv->p_renderer );
> >+ if( asprintf( &psz, "#%s", psz_renderer_sout ) < 0 )
> >+ return VLC_ENOMEM;
> >+ }
> >+ if( !psz )
> >+ psz = var_GetNonEmptyString( p_input, "sout" );
> > if( psz && strncasecmp( priv->p_item->psz_uri, "vlc:", 4 ) )
> > {
> >priv->p_sout = input_resource_RequestSout( priv->p_resource, NULL, psz
> >);
> >diff --git a/src/input/vlm.c b/src/input/vlm.c
> >index ccd5c36a65..99e0e5862b 100644
> >--- a/src/input/vlm.c
> >+++ b/src/input/vlm.c
> >@@ -624,7 +624,7 @@ static int vlm_OnMediaUpdate( vlm_t *p_vlm,
> >vlm_media_sys_t *p_media )
> > 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, NULL );
> > if( p_input )
> > {
> > vlc_sem_t sem_preparse;
> >@@ -998,7 +998,8 @@ static int vlm_ControlMediaInstanceStart( vlm_t
> >*p_vlm, int64_t id, const char *
> > {
> > p_instance->p_input = input_Create( p_instance->p_parent,
> > p_instance->p_item, psz_log,
> >-
> >p_instance->p_input_resource );
> >+
> >p_instance->p_input_resource,
> >+ NULL );
> > if( p_instance->p_input )
> > {
> >var_AddCallback( p_instance->p_input, "intf-event", InputEvent, p_media
> >);
> >diff --git a/src/playlist/thread.c b/src/playlist/thread.c
> >index 5632babe4d..9ee57ddc4d 100644
> >--- a/src/playlist/thread.c
> >+++ b/src/playlist/thread.c
> >@@ -195,6 +195,7 @@ static bool PlayItem( playlist_t *p_playlist,
> >playlist_item_t *p_item )
> > {
> > playlist_private_t *p_sys = pl_priv(p_playlist);
> > input_item_t *p_input = p_item->p_input;
> >+ vlc_renderer_item_t *p_renderer;
> >
> > PL_ASSERT_LOCKED;
> >
> >@@ -202,13 +203,15 @@ static bool PlayItem( playlist_t *p_playlist,
> >playlist_item_t *p_item )
> >
> > p_item->i_nb_played++;
> > set_current_status_item( p_playlist, p_item );
> >+ p_renderer = p_sys->p_renderer;
> > assert( p_sys->p_input == NULL );
> > PL_UNLOCK;
> >
> > libvlc_MetadataCancel( p_playlist->obj.libvlc, p_item );
> >
> >input_thread_t *p_input_thread = input_Create( p_playlist, p_input,
> >NULL,
> >-
> >p_sys->p_input_resource );
> >+
> >p_sys->p_input_resource,
> >+ p_renderer );
> > if( likely(p_input_thread != NULL) )
> > {
> > var_AddCallback( p_input_thread, "intf-event",
> >--
> >2.11.0
> >
> >_______________________________________________
> >vlc-devel mailing list
> >To unsubscribe or modify your subscription options:
> >https://mailman.videolan.org/listinfo/vlc-devel
>
> Description does not seem to match code.
Indeed, will fix. Thanks
--
Hugo Beauzée-Luyssen
hugo at beauzee.fr
More information about the vlc-devel
mailing list