Commit dfa6af95 authored by Antoine Cellerier's avatar Antoine Cellerier

Add --sout-bridge-in-placeholder-switch-on-iframe

Add default enabled option to force placeholder state toggling to
happen only on iframes. This removes artifacts at the expense of a
longer switch delay.
parent e51f0436
...@@ -69,9 +69,16 @@ ...@@ -69,9 +69,16 @@
"be used to configure a place holder stream when the real source " \ "be used to configure a place holder stream when the real source " \
"breaks. Source and placeholder streams should have the same format. " ) "breaks. Source and placeholder streams should have the same format. " )
#define PLACEHOLDER_DELAY_TEXT N_( "Place holder delay" ) #define PLACEHOLDER_DELAY_TEXT N_( "Placeholder delay" )
#define PLACEHOLDER_DELAY_LONGTEXT N_( \ #define PLACEHOLDER_DELAY_LONGTEXT N_( \
"Delay (in ms) before the place holder kicks in." ) "Delay (in ms) before the placeholder kicks in." )
#define PLACEHOLDER_IFRAME_TEXT N_( "Wait for I frame before toggling placholder" )
#define PLACEHOLDER_IFRAME_LONGTEXT N_( \
"If enabled, switching between the placeholder and the normal stream " \
"will only occur on I frames. This will remove artifacts on stream " \
"switching at the expense of a slightly longer delay, depending on " \
"the frequence of I frames in the streams." )
static int OpenOut ( vlc_object_t * ); static int OpenOut ( vlc_object_t * );
static void CloseOut( vlc_object_t * ); static void CloseOut( vlc_object_t * );
...@@ -113,6 +120,8 @@ vlc_module_begin(); ...@@ -113,6 +120,8 @@ vlc_module_begin();
PLACEHOLDER_TEXT, PLACEHOLDER_LONGTEXT, false ); PLACEHOLDER_TEXT, PLACEHOLDER_LONGTEXT, false );
add_integer( SOUT_CFG_PREFIX_IN "placeholder-delay", 200, NULL, add_integer( SOUT_CFG_PREFIX_IN "placeholder-delay", 200, NULL,
PLACEHOLDER_DELAY_TEXT, PLACEHOLDER_DELAY_LONGTEXT, false ); PLACEHOLDER_DELAY_TEXT, PLACEHOLDER_DELAY_LONGTEXT, false );
add_bool( SOUT_CFG_PREFIX_IN "placeholder-switch-on-iframe", true, NULL,
PLACEHOLDER_IFRAME_TEXT, PLACEHOLDER_IFRAME_LONGTEXT, false );
set_callbacks( OpenIn, CloseIn ); set_callbacks( OpenIn, CloseIn );
vlc_module_end(); vlc_module_end();
...@@ -126,7 +135,9 @@ static const char *const ppsz_sout_options_out[] = { ...@@ -126,7 +135,9 @@ static const char *const ppsz_sout_options_out[] = {
}; };
static const char *const ppsz_sout_options_in[] = { static const char *const ppsz_sout_options_in[] = {
"delay", "id-offset", "name", "placeholder", "placeholder-delay", NULL "delay", "id-offset", "name",
"placeholder", "placeholder-delay", "placeholder-switch-on-iframe",
NULL
}; };
static sout_stream_id_t *AddOut ( sout_stream_t *, es_format_t * ); static sout_stream_id_t *AddOut ( sout_stream_t *, es_format_t * );
...@@ -381,6 +392,8 @@ typedef struct in_sout_stream_sys_t ...@@ -381,6 +392,8 @@ typedef struct in_sout_stream_sys_t
char *psz_name; char *psz_name;
bool b_placeholder; bool b_placeholder;
bool b_switch_on_iframe;
int i_state;
mtime_t i_placeholder_delay; mtime_t i_placeholder_delay;
sout_stream_id_t *id_video; sout_stream_id_t *id_video;
mtime_t i_last_video; mtime_t i_last_video;
...@@ -388,6 +401,8 @@ typedef struct in_sout_stream_sys_t ...@@ -388,6 +401,8 @@ typedef struct in_sout_stream_sys_t
mtime_t i_last_audio; mtime_t i_last_audio;
} in_sout_stream_sys_t; } in_sout_stream_sys_t;
enum { placeholder_on, placeholder_off };
/***************************************************************************** /*****************************************************************************
* OpenIn: * OpenIn:
*****************************************************************************/ *****************************************************************************/
...@@ -432,6 +447,11 @@ static int OpenIn( vlc_object_t *p_this ) ...@@ -432,6 +447,11 @@ static int OpenIn( vlc_object_t *p_this )
var_Get( p_stream, SOUT_CFG_PREFIX_IN "placeholder", &val ); var_Get( p_stream, SOUT_CFG_PREFIX_IN "placeholder", &val );
p_sys->b_placeholder = val.b_bool; p_sys->b_placeholder = val.b_bool;
var_Get( p_stream, SOUT_CFG_PREFIX_IN "placeholder-switch-on-iframe", &val);
p_sys->b_switch_on_iframe = val.b_bool;
p_sys->i_state = placeholder_on;
var_Get( p_stream, SOUT_CFG_PREFIX_IN "placeholder-delay", &val ); var_Get( p_stream, SOUT_CFG_PREFIX_IN "placeholder-delay", &val );
p_sys->i_placeholder_delay = (mtime_t)val.i_int * 1000; p_sys->i_placeholder_delay = (mtime_t)val.i_int * 1000;
...@@ -629,16 +649,31 @@ static int SendIn( sout_stream_t *p_stream, sout_stream_id_t *id, ...@@ -629,16 +649,31 @@ static int SendIn( sout_stream_t *p_stream, sout_stream_id_t *id,
case VIDEO_ES: case VIDEO_ES:
p_sys->i_last_video = i_date; p_sys->i_last_video = i_date;
newid = p_sys->id_video; newid = p_sys->id_video;
if( !p_sys->b_switch_on_iframe ||
p_sys->i_state == placeholder_off ||
( p_bridge->pp_es[i]->fmt.i_cat == VIDEO_ES &&
p_bridge->pp_es[i]->p_block->i_flags & BLOCK_FLAG_TYPE_I ) )
{
p_sys->p_out->pf_send( p_sys->p_out,
newid?newid:p_bridge->pp_es[i]->id,
p_bridge->pp_es[i]->p_block );
p_sys->i_state = placeholder_off;
}
break; break;
case AUDIO_ES: case AUDIO_ES:
newid = p_sys->id_audio; newid = p_sys->id_audio;
p_sys->i_last_audio = i_date; p_sys->i_last_audio = i_date;
default:
p_sys->p_out->pf_send( p_sys->p_out,
newid?newid:p_bridge->pp_es[i]->id,
p_bridge->pp_es[i]->p_block );
break; break;
} }
} }
p_sys->p_out->pf_send( p_sys->p_out, else /* !b_placeholder */
newid ? newid : p_bridge->pp_es[i]->id, p_sys->p_out->pf_send( p_sys->p_out,
p_bridge->pp_es[i]->p_block ); p_bridge->pp_es[i]->id,
p_bridge->pp_es[i]->p_block );
} }
else else
{ {
...@@ -665,8 +700,14 @@ static int SendIn( sout_stream_t *p_stream, sout_stream_id_t *id, ...@@ -665,8 +700,14 @@ static int SendIn( sout_stream_t *p_stream, sout_stream_id_t *id,
switch( id->i_cat ) switch( id->i_cat )
{ {
case VIDEO_ES: case VIDEO_ES:
if( p_sys->i_last_video + p_sys->i_placeholder_delay < i_date ) if( ( p_sys->i_last_video + p_sys->i_placeholder_delay < i_date
&& ( !p_sys->b_switch_on_iframe
|| p_buffer->i_flags & BLOCK_FLAG_TYPE_I ) )
|| p_sys->i_state == placeholder_on )
{
p_sys->p_out->pf_send( p_sys->p_out, id->id, p_buffer ); p_sys->p_out->pf_send( p_sys->p_out, id->id, p_buffer );
p_sys->i_state = placeholder_on;
}
else else
block_Release( p_buffer ); block_Release( p_buffer );
break; break;
......
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