[vlc-commits] [Git][videolan/vlc][master] 7 commits: resource: track stream output string
Rémi Denis-Courmont (@Courmisch)
gitlab at videolan.org
Thu Jul 15 17:43:59 UTC 2021
Rémi Denis-Courmont pushed to branch master at VideoLAN / VLC
Commits:
159d7aa0 by Rémi Denis-Courmont at 2021-07-15T17:23:03+00:00
resource: track stream output string
- - - - -
05cbaa19 by Rémi Denis-Courmont at 2021-07-15T17:23:03+00:00
sout: remove sout_instance_t.psz_sout
The stream output core code has no use for this. This was only for the
benefit of the input resource, and indeed the other call site does not
need this.
- - - - -
9c4bb58c by Rémi Denis-Courmont at 2021-07-15T17:23:03+00:00
sout: don't cache wants-substreams
- - - - -
3e557009 by Rémi Denis-Courmont at 2021-07-15T17:23:03+00:00
sout: remove sout_instance_t indirection
This just wraps a sout_stream_t. We get more flexibility by using
sout_stream_t directly.
- - - - -
a2476d06 by Rémi Denis-Courmont at 2021-07-15T17:23:03+00:00
sout: remove sout_instance_t for real
(also sout_cfg_t)
- - - - -
f5033c4d by Rémi Denis-Courmont at 2021-07-15T17:23:03+00:00
sout: inline/remove sout_instance_ControlsPace()
- - - - -
2b51b9cf by Rémi Denis-Courmont at 2021-07-15T17:23:03+00:00
sout: inline/remove sout_DeleteInstance()
- - - - -
12 changed files:
- extras/analyser/vlc.vim
- include/vlc_common.h
- include/vlc_objects.h
- src/input/decoder.c
- src/input/decoder.h
- src/input/es_out.c
- src/input/input.c
- src/input/input_internal.h
- src/input/resource.c
- src/input/resource.h
- src/stream_output/stream_output.c
- src/stream_output/stream_output.h
Changes:
=====================================
extras/analyser/vlc.vim
=====================================
@@ -66,7 +66,6 @@ function VlcSyntax()
" Images
syn keyword cType image_handler_t
" Sout
- syn keyword cType sout_instance_t sout_cfg_t
syn keyword cType sout_input_t sout_packetizer_input_t
syn keyword cType sout_access_out_t sout_access_out_sys_t
syn keyword cType sout_mux_t sout_mux_sys_t
=====================================
include/vlc_common.h
=====================================
@@ -395,8 +395,6 @@ typedef struct subpicture_region_t subpicture_region_t;
typedef struct image_handler_t image_handler_t;
/* Stream output */
-typedef struct sout_instance_t sout_instance_t;
-
typedef struct sout_input_t sout_input_t;
typedef struct sout_packetizer_input_t sout_packetizer_input_t;
=====================================
include/vlc_objects.h
=====================================
@@ -98,7 +98,6 @@ vlc_object_cast(audio_output)
vlc_object_cast(vout_thread_t)
vlc_object_cast(vout_display_t)
vlc_object_cast(vout_window_t)
-vlc_object_cast(sout_instance_t)
vlc_object_cast(sout_stream_t)
vlc_object_cast(sout_access_out_t)
vlc_object_cast(extensions_manager_t)
=====================================
src/input/decoder.c
=====================================
@@ -75,7 +75,7 @@ struct vlc_input_decoder_t
ssize_t i_spu_channel;
int64_t i_spu_order;
- sout_instance_t *p_sout;
+ sout_stream_t *p_sout;
sout_packetizer_input_t *p_sout_input;
vlc_thread_t thread;
@@ -899,10 +899,15 @@ static void DecoderThread_ProcessSout( vlc_input_decoder_t *p_owner, block_t *p_
while( p_sout_block )
{
block_t *p_next = p_sout_block->p_next;
+ bool b_wants_substreams;
p_sout_block->p_next = NULL;
- if( p_owner->p_sout->b_wants_substreams && p_dec->pf_get_cc )
+ if( p_dec->pf_get_cc
+ && sout_StreamControl( p_owner->p_sout,
+ SOUT_STREAM_WANTS_SUBSTREAMS,
+ &b_wants_substreams ) == VLC_SUCCESS
+ && b_wants_substreams )
{
if( p_owner->cc.p_sout_input ||
!p_owner->cc.b_sout_created )
@@ -1766,7 +1771,7 @@ static const struct decoder_owner_callbacks dec_spu_cbs =
static vlc_input_decoder_t *
CreateDecoder( vlc_object_t *p_parent,
const es_format_t *fmt, vlc_clock_t *p_clock,
- input_resource_t *p_resource, sout_instance_t *p_sout,
+ input_resource_t *p_resource, sout_stream_t *p_sout,
bool b_thumbnailing, const struct vlc_input_decoder_callbacks *cbs,
void *cbs_userdata )
{
@@ -2025,7 +2030,7 @@ static void DecoderUnsupportedCodec( decoder_t *p_dec, const es_format_t *fmt, b
static vlc_input_decoder_t *
decoder_New( vlc_object_t *p_parent, const es_format_t *fmt,
vlc_clock_t *p_clock, input_resource_t *p_resource,
- sout_instance_t *p_sout, bool thumbnailing,
+ sout_stream_t *p_sout, bool thumbnailing,
const struct vlc_input_decoder_callbacks *cbs, void *userdata)
{
const char *psz_type = p_sout ? N_("packetizer") : N_("decoder");
@@ -2098,7 +2103,7 @@ decoder_New( vlc_object_t *p_parent, const es_format_t *fmt,
vlc_input_decoder_t *
vlc_input_decoder_New( vlc_object_t *parent, es_format_t *fmt,
vlc_clock_t *p_clock, input_resource_t *resource,
- sout_instance_t *p_sout, bool thumbnailing,
+ sout_stream_t *p_sout, bool thumbnailing,
const struct vlc_input_decoder_callbacks *cbs,
void *cbs_userdata)
{
=====================================
src/input/decoder.h
=====================================
@@ -52,7 +52,7 @@ struct vlc_input_decoder_callbacks {
vlc_input_decoder_t *
vlc_input_decoder_New( vlc_object_t *parent, es_format_t *, vlc_clock_t *,
- input_resource_t *, sout_instance_t *, bool thumbnailing,
+ input_resource_t *, sout_stream_t *, bool thumbnailing,
const struct vlc_input_decoder_callbacks *cbs,
void *userdata ) VLC_USED;
=====================================
src/input/es_out.c
=====================================
@@ -223,7 +223,7 @@ typedef struct
vlc_tick_t i_buffering_extra_system;
/* Record */
- sout_instance_t *p_sout_record;
+ sout_stream_t *p_sout_record;
/* Used only to limit debugging output */
int i_prev_stream_level;
@@ -865,7 +865,7 @@ static int EsOutSetRecord( es_out_t *out, bool b_record )
p_es->p_dec_record = NULL;
}
#ifdef ENABLE_SOUT
- sout_DeleteInstance( p_sys->p_sout_record );
+ sout_StreamChainDelete( p_sys->p_sout_record, NULL );
#endif
p_sys->p_sout_record = NULL;
}
@@ -2909,12 +2909,12 @@ static int EsOutSend( es_out_t *out, es_out_id_t *es, block_t *p_block )
/* Check for sout mode */
if( input_priv(p_input)->p_sout )
{
- bool pace = sout_instance_ControlsPace(input_priv(p_input)->p_sout);
+ bool async = !sout_StreamIsSynchronous(input_priv(p_input)->p_sout);
- if( input_priv(p_input)->b_out_pace_control != pace )
+ if( input_priv(p_input)->b_out_pace_control != async )
{
- msg_Dbg( p_input, "switching to %ssync mode", pace ? "a" : "" );
- input_priv(p_input)->b_out_pace_control = pace;
+ msg_Dbg( p_input, "switching to %ssync mode", async ? "a" : "" );
+ input_priv(p_input)->b_out_pace_control = async;
}
}
#endif
=====================================
src/input/input.c
=====================================
@@ -1366,7 +1366,7 @@ static int Init( input_thread_t * p_input )
#ifdef ENABLE_SOUT
if( !priv->b_preparsing && priv->p_sout )
{
- priv->b_out_pace_control = !sout_instance_ControlsPace(priv->p_sout);
+ priv->b_out_pace_control = sout_StreamIsSynchronous(priv->p_sout);
msg_Dbg( p_input, "starting in %ssync mode",
priv->b_out_pace_control ? "a" : "" );
}
=====================================
src/input/input_internal.h
=====================================
@@ -491,7 +491,7 @@ typedef struct input_thread_private_t
/* Output */
bool b_out_pace_control; /* XXX Move it ot es_sout ? */
- sout_instance_t *p_sout; /* Idem ? */
+ sout_stream_t *p_sout; /* Idem ? */
es_out_t *p_es_out;
es_out_t *p_es_out_display;
vlc_viewpoint_t viewpoint;
=====================================
src/input/resource.c
=====================================
@@ -66,7 +66,8 @@ struct input_resource_t
/* */
input_thread_t *p_input;
- sout_instance_t *p_sout;
+ sout_stream_t *p_sout;
+ char *psz_sout;
vout_thread_t *p_vout_dummy;
struct vout_resource *vout_rsc_free;
@@ -135,7 +136,8 @@ static void DestroySout( input_resource_t *p_resource )
if( p_resource->p_sout )
{
msg_Dbg( p_resource->p_parent, "destroying stream output" );
- sout_DeleteInstance( p_resource->p_sout );
+ sout_StreamChainDelete( p_resource->p_sout, NULL );
+ free(p_resource->psz_sout);
}
#endif
p_resource->p_sout = NULL;
@@ -571,16 +573,16 @@ void input_resource_StopFreeVout(input_resource_t *p_resource)
}
/* */
-sout_instance_t *input_resource_RequestSout( input_resource_t *p_resource, const char *psz_sout )
+sout_stream_t *input_resource_RequestSout( input_resource_t *p_resource, const char *psz_sout )
{
- sout_instance_t *sout;
+ sout_stream_t *sout;
assert(psz_sout != NULL);
vlc_mutex_lock( &p_resource->lock );
#ifdef ENABLE_SOUT
/* Check the validity of the sout */
if (p_resource->p_sout != NULL
- && strcmp(p_resource->p_sout->psz_sout, psz_sout) != 0)
+ && strcmp(p_resource->psz_sout, psz_sout) != 0)
{
msg_Dbg(p_resource->p_parent, "destroying unusable sout");
DestroySout(p_resource);
@@ -598,7 +600,10 @@ sout_instance_t *input_resource_RequestSout( input_resource_t *p_resource, const
else
{
/* Create a new one */
- sout = sout_NewInstance(p_resource->p_parent, psz_sout);
+ p_resource->psz_sout = strdup(psz_sout);
+
+ if (likely(p_resource->psz_sout != NULL))
+ sout = sout_NewInstance(p_resource->p_parent, psz_sout);
}
#else
sout = NULL;
@@ -607,7 +612,7 @@ sout_instance_t *input_resource_RequestSout( input_resource_t *p_resource, const
return sout;
}
-void input_resource_PutSout(input_resource_t *resource, sout_instance_t *sout)
+void input_resource_PutSout(input_resource_t *resource, sout_stream_t *sout)
{
if (sout == NULL)
{
=====================================
src/input/resource.h
=====================================
@@ -35,8 +35,8 @@ void input_resource_SetInput( input_resource_t *, input_thread_t * );
/**
* This function handles sout request.
*/
-sout_instance_t *input_resource_RequestSout( input_resource_t *, const char * );
-void input_resource_PutSout(input_resource_t *, sout_instance_t *);
+sout_stream_t *input_resource_RequestSout( input_resource_t *, const char * );
+void input_resource_PutSout(input_resource_t *, sout_stream_t *);
vout_thread_t *input_resource_RequestVout(input_resource_t *, vlc_video_context *,
const vout_configuration_t *,
=====================================
src/stream_output/stream_output.c
=====================================
@@ -77,9 +77,9 @@ static void mrl_Clean( mrl_t *p_mrl );
/*****************************************************************************
* sout_NewInstance: creates a new stream output instance
*****************************************************************************/
-sout_instance_t *sout_NewInstance( vlc_object_t *p_parent, const char *psz_dest )
+sout_stream_t *sout_NewInstance( vlc_object_t *p_parent, const char *psz_dest )
{
- sout_instance_t *p_sout;
+ sout_stream_t *p_sout;
char *psz_chain;
assert( psz_dest != NULL );
@@ -96,59 +96,14 @@ sout_instance_t *sout_NewInstance( vlc_object_t *p_parent, const char *psz_dest
if(!psz_chain)
return NULL;
- /* *** Allocate descriptor *** */
- p_sout = malloc(sizeof (*p_sout));
- if( p_sout == NULL )
- {
- free( psz_chain );
- return NULL;
- }
-
msg_Dbg(p_parent, "creating stream output chain `%s'", psz_chain);
- /* *** init descriptor *** */
- p_sout->psz_sout = strdup( psz_dest );
- p_sout->b_wants_substreams = false;
-
- p_sout->p_stream = NULL;
-
- p_sout->p_stream = sout_StreamChainNew(p_parent, psz_chain, NULL);
- if( p_sout->p_stream )
- {
- free( psz_chain );
- sout_StreamControl( p_sout->p_stream,
- SOUT_STREAM_WANTS_SUBSTREAMS,
- &p_sout->b_wants_substreams );
- return p_sout;
- }
-
- msg_Err(p_parent, "failed to create stream output chain `%s'", psz_chain);
- free( psz_chain );
-
- FREENULL( p_sout->psz_sout );
-
- free(p_sout);
- return NULL;
-}
-
-/*****************************************************************************
- * sout_DeleteInstance: delete a previously allocated instance
- *****************************************************************************/
-void sout_DeleteInstance( sout_instance_t * p_sout )
-{
- /* remove the stream out chain */
- sout_StreamChainDelete( p_sout->p_stream, NULL );
-
- /* *** free all string *** */
- FREENULL( p_sout->psz_sout );
-
- /* *** free structure *** */
- free(p_sout);
-}
-
-bool sout_instance_ControlsPace( sout_instance_t *sout )
-{
- return !sout_StreamIsSynchronous(sout->p_stream);
+ p_sout = sout_StreamChainNew(p_parent, psz_chain, NULL);
+ if (p_sout == NULL)
+ msg_Err(p_parent, "failed to create stream output chain `%s'",
+ psz_chain);
+ free(psz_chain);
+ return p_sout;
}
/*****************************************************************************
@@ -161,7 +116,7 @@ struct sout_packetizer_input_t
bool b_flushed;
};
-sout_packetizer_input_t *sout_InputNew( sout_instance_t *p_sout,
+sout_packetizer_input_t *sout_InputNew( sout_stream_t *p_sout,
const es_format_t *p_fmt )
{
sout_packetizer_input_t *p_input;
@@ -172,16 +127,15 @@ sout_packetizer_input_t *sout_InputNew( sout_instance_t *p_sout,
p_input->b_flushed = false;
- msg_Dbg(p_sout->p_stream, "adding an output ES for `%4.4s` (%p)",
+ msg_Dbg(p_sout, "adding an output ES for `%4.4s` (%p)",
(char *)&p_fmt->i_codec, (void *)p_input);
/* *** add it to the stream chain */
- p_input->id = sout_StreamIdAdd( p_sout->p_stream, p_fmt );
+ p_input->id = sout_StreamIdAdd( p_sout, p_fmt );
if( p_input->id == NULL )
{
- msg_Warn(p_sout->p_stream, "failed to add output ES (%p)",
- (void *)p_input);
+ msg_Warn(p_sout, "failed to add output ES (%p)", (void *)p_input);
free( p_input );
p_input = NULL;
}
@@ -192,32 +146,31 @@ sout_packetizer_input_t *sout_InputNew( sout_instance_t *p_sout,
/*****************************************************************************
*
*****************************************************************************/
-int sout_InputDelete( sout_instance_t *p_sout,
+int sout_InputDelete( sout_stream_t *p_sout,
sout_packetizer_input_t *p_input )
{
- msg_Dbg(p_sout->p_stream, "removing an output ES (%p)", (void *)p_input);
+ msg_Dbg(p_sout, "removing an output ES (%p)", (void *)p_input);
- sout_StreamIdDel( p_sout->p_stream, p_input->id );
+ sout_StreamIdDel( p_sout, p_input->id );
free( p_input );
return( VLC_SUCCESS);
}
-static int sout_InputControlVa( sout_instance_t *p_sout,
+static int sout_InputControlVa( sout_stream_t *p_sout,
sout_packetizer_input_t *p_input,
int i_query, va_list args )
{
if( i_query == SOUT_INPUT_SET_SPU_HIGHLIGHT )
{
- return sout_StreamControl( p_sout->p_stream,
- SOUT_STREAM_ID_SPU_HIGHLIGHT,
- p_input->id, va_arg(args, void *) );
+ return sout_StreamControl( p_sout, SOUT_STREAM_ID_SPU_HIGHLIGHT,
+ p_input->id, va_arg(args, void *) );
}
return VLC_EGENERIC;
}
-int sout_InputControl( sout_instance_t *p_sout,
+int sout_InputControl( sout_stream_t *p_sout,
sout_packetizer_input_t *p_input, int i_query, ... )
{
va_list args;
@@ -229,17 +182,17 @@ int sout_InputControl( sout_instance_t *p_sout,
return i_result;
}
-void sout_InputFlush( sout_instance_t *p_sout,
+void sout_InputFlush( sout_stream_t *p_sout,
sout_packetizer_input_t *p_input )
{
- sout_StreamFlush( p_sout->p_stream, p_input->id );
+ sout_StreamFlush( p_sout, p_input->id );
p_input->b_flushed = true;
}
/*****************************************************************************
*
*****************************************************************************/
-int sout_InputSendBuffer( sout_instance_t *p_sout,
+int sout_InputSendBuffer( sout_stream_t *p_sout,
sout_packetizer_input_t *p_input,
block_t *p_buffer )
{
@@ -248,7 +201,7 @@ int sout_InputSendBuffer( sout_instance_t *p_sout,
p_buffer->i_flags |= BLOCK_FLAG_DISCONTINUITY;
p_input->b_flushed = false;
}
- return sout_StreamIdSend( p_sout->p_stream, p_input->id, p_buffer );
+ return sout_StreamIdSend( p_sout, p_input->id, p_buffer );
}
#undef sout_AccessOutNew
=====================================
src/stream_output/stream_output.h
=====================================
@@ -30,31 +30,20 @@
# include <vlc_network.h>
/** Stream output instance */
-struct sout_instance_t
-{
- char *psz_sout;
-
- bool b_wants_substreams;
- sout_stream_t *p_stream;
-};
-
-sout_instance_t *sout_NewInstance( vlc_object_t *, const char * );
+sout_stream_t *sout_NewInstance( vlc_object_t *, const char * );
#define sout_NewInstance(a,b) sout_NewInstance(VLC_OBJECT(a),b)
-void sout_DeleteInstance( sout_instance_t * );
-
-bool sout_instance_ControlsPace( sout_instance_t *sout );
-sout_packetizer_input_t *sout_InputNew( sout_instance_t *, const es_format_t * );
-int sout_InputDelete( sout_instance_t *, sout_packetizer_input_t * );
-int sout_InputSendBuffer( sout_instance_t *, sout_packetizer_input_t *,
+sout_packetizer_input_t *sout_InputNew( sout_stream_t *, const es_format_t * );
+int sout_InputDelete( sout_stream_t *, sout_packetizer_input_t * );
+int sout_InputSendBuffer( sout_stream_t *, sout_packetizer_input_t *,
block_t * );
enum sout_input_query_e
{
SOUT_INPUT_SET_SPU_HIGHLIGHT, /* arg1=const vlc_spu_highlight_t *, can fail */
};
-int sout_InputControl( sout_instance_t *, sout_packetizer_input_t *,
+int sout_InputControl( sout_stream_t *, sout_packetizer_input_t *,
int i_query, ... );
-void sout_InputFlush( sout_instance_t *, sout_packetizer_input_t * );
+void sout_InputFlush( sout_stream_t *, sout_packetizer_input_t * );
#endif
View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/850e0bcfa0a99ed500adee9567c083fe77506565...2b51b9cf28d523ffa5588df9f7b534deddec7fab
--
View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/850e0bcfa0a99ed500adee9567c083fe77506565...2b51b9cf28d523ffa5588df9f7b534deddec7fab
You're receiving this email because of your account on code.videolan.org.
More information about the vlc-commits
mailing list