[vlc-devel] [RFC PATCH 6/9] input: pass a specific es_out for each slaves
Thomas Guillem
thomas at gllm.fr
Wed Feb 12 15:43:24 CET 2020
---
src/input/input.c | 42 +++++++++++++++++++++++++++++++-------
src/input/input_internal.h | 1 +
2 files changed, 36 insertions(+), 7 deletions(-)
diff --git a/src/input/input.c b/src/input/input.c
index 9aee8b09d8e..cec7d7dab21 100644
--- a/src/input/input.c
+++ b/src/input/input.c
@@ -87,7 +87,7 @@ static void UpdateTitleListfromDemux( input_thread_t * );
static void MRLSections( const char *, int *, int *, int *, int *);
-static input_source_t *InputSourceNew( input_thread_t *, const char *,
+static input_source_t *InputSourceNew( input_thread_t *, bool, const char *,
const char *psz_forced_demux,
bool b_in_can_fail );
static void InputSourceDestroy( input_source_t * );
@@ -1265,7 +1265,7 @@ static int Init( input_thread_t * p_input )
goto error;
/* */
- master = InputSourceNew( p_input, priv->p_item->psz_uri, NULL, false );
+ master = InputSourceNew( p_input, true, priv->p_item->psz_uri, NULL, false );
if( master == NULL )
goto error;
priv->master = master;
@@ -2482,7 +2482,7 @@ static void input_SplitMRL( const char **, const char **, const char **,
/*****************************************************************************
* InputSourceNew:
*****************************************************************************/
-static input_source_t *InputSourceNew( input_thread_t *p_input,
+static input_source_t *InputSourceNew( input_thread_t *p_input, bool master,
const char *psz_mrl,
const char *psz_forced_demux,
bool b_in_can_fail )
@@ -2574,8 +2574,30 @@ static input_source_t *InputSourceNew( input_thread_t *p_input,
char *url;
if( likely(asprintf( &url, "%s://%s", psz_access, psz_path ) >= 0) )
{
- in->p_demux = InputDemuxNew( p_input, priv->p_es_out, in, url,
- psz_demux, psz_anchor );
+ es_out_t *es_out;
+ if( !master )
+ {
+ /* Use the last segment of the url as a source identifier. */
+ char *source_id = strrchr(url, '/');
+ if( !source_id )
+ source_id = url;
+ else
+ source_id++;
+ es_out_ctx_t *ctx = es_out_ctx_New( source_id );
+ if( ctx )
+ {
+ in->p_slave_es_out = input_EsOutContextNew( priv->p_es_out, ctx );
+ es_out = in->p_slave_es_out;
+ }
+ else
+ es_out = NULL;
+ }
+ else
+ es_out = priv->p_es_out;
+
+ if( es_out )
+ in->p_demux = InputDemuxNew( p_input, es_out, in, url,
+ psz_demux, psz_anchor );
free( url );
}
else
@@ -2590,6 +2612,8 @@ static input_source_t *InputSourceNew( input_thread_t *p_input,
vlc_dialog_display_error( p_input, _("Your input can't be opened"),
_("VLC is unable to open the MRL '%s'."
" Check the log for details."), psz_mrl );
+ if( in->p_slave_es_out )
+ es_out_Delete( in->p_slave_es_out );
free( in );
return NULL;
}
@@ -2612,6 +2636,8 @@ static input_source_t *InputSourceNew( input_thread_t *p_input,
if( in->p_demux == NULL )
{
msg_Err(p_input, "Failed to create demux filter");
+ if( in->p_slave_es_out )
+ es_out_Delete( in->p_slave_es_out );
free( in );
return NULL;
}
@@ -2722,6 +2748,8 @@ static void InputSourceDestroy( input_source_t *in )
if( in->p_demux )
demux_Delete( in->p_demux );
+ if( in->p_slave_es_out )
+ es_out_Delete( in->p_slave_es_out );
if( in->i_title > 0 )
{
@@ -3267,12 +3295,12 @@ static int input_SlaveSourceAdd( input_thread_t *p_input,
priv->i_last_es_cat = UNKNOWN_ES;
- input_source_t *p_source = InputSourceNew( p_input, psz_uri,
+ input_source_t *p_source = InputSourceNew( p_input, false, psz_uri,
psz_forced_demux,
b_can_fail || psz_forced_demux );
if( psz_forced_demux && p_source == NULL )
- p_source = InputSourceNew( p_input, psz_uri, NULL, b_can_fail );
+ p_source = InputSourceNew( p_input, false, psz_uri, NULL, b_can_fail );
if( p_source == NULL )
{
diff --git a/src/input/input_internal.h b/src/input/input_internal.h
index 83f3a9e899b..ec8a9c5b423 100644
--- a/src/input/input_internal.h
+++ b/src/input/input_internal.h
@@ -367,6 +367,7 @@ input_item_t* input_GetItem( input_thread_t * ) VLC_USED;
typedef struct
{
demux_t *p_demux; /**< Demux object (most downstream) */
+ es_out_t *p_slave_es_out; /**< Slave es out */
/* Title infos for that input */
bool b_title_demux; /* Titles/Seekpoints provided by demux */
--
2.20.1
More information about the vlc-devel
mailing list