Commit 5a6ee796 authored by Laurent Aimar's avatar Laurent Aimar

Moved "sub-filter" from spu_t to vout_thread_t.

parent ef785d7a
...@@ -114,10 +114,9 @@ int mediacontrol_showtext( vout_thread_t *p_vout, int i_channel, ...@@ -114,10 +114,9 @@ int mediacontrol_showtext( vout_thread_t *p_vout, int i_channel,
int i_flags, int i_hmargin, int i_vmargin, int i_flags, int i_hmargin, int i_vmargin,
mtime_t i_start, mtime_t i_stop ) mtime_t i_start, mtime_t i_stop )
{ {
return osd_ShowTextAbsolute( vout_GetSpu( p_vout ), i_channel, (void)p_style; (void)i_hmargin; (void)i_vmargin;
psz_string, p_style, vout_OSDText( p_vout, i_channel, i_flags & ~SUBPICTURE_ALIGN_MASK,
i_flags, i_hmargin, i_vmargin, i_stop - i_start, psz_string );
i_start, i_stop );
} }
......
...@@ -60,7 +60,6 @@ struct spu_t ...@@ -60,7 +60,6 @@ struct spu_t
VLC_EXPORT( spu_t *, spu_Create, ( vlc_object_t * ) ); VLC_EXPORT( spu_t *, spu_Create, ( vlc_object_t * ) );
#define spu_Create(a) spu_Create(VLC_OBJECT(a)) #define spu_Create(a) spu_Create(VLC_OBJECT(a))
VLC_EXPORT( int, spu_Init, ( spu_t * ) );
VLC_EXPORT( void, spu_Destroy, ( spu_t * ) ); VLC_EXPORT( void, spu_Destroy, ( spu_t * ) );
void spu_Attach( spu_t *, vlc_object_t *, bool ); void spu_Attach( spu_t *, vlc_object_t *, bool );
...@@ -97,6 +96,11 @@ VLC_EXPORT( int, spu_RegisterChannel, ( spu_t * ) ); ...@@ -97,6 +96,11 @@ VLC_EXPORT( int, spu_RegisterChannel, ( spu_t * ) );
*/ */
VLC_EXPORT( void, spu_ClearChannel, ( spu_t *, int ) ); VLC_EXPORT( void, spu_ClearChannel, ( spu_t *, int ) );
/**
* It changes the sub filters list
*/
VLC_EXPORT( void, spu_ChangeFilters, ( spu_t *, const char * ) );
/** @}*/ /** @}*/
#ifdef __cplusplus #ifdef __cplusplus
......
...@@ -168,15 +168,6 @@ VLC_EXPORT( void, vout_PutSubpicture, ( vout_thread_t *, subpicture_ ...@@ -168,15 +168,6 @@ VLC_EXPORT( void, vout_PutSubpicture, ( vout_thread_t *, subpicture_
VLC_EXPORT( int, vout_RegisterSubpictureChannel, ( vout_thread_t * ) ); VLC_EXPORT( int, vout_RegisterSubpictureChannel, ( vout_thread_t * ) );
VLC_EXPORT( void, vout_FlushSubpictureChannel, ( vout_thread_t *, int ) ); VLC_EXPORT( void, vout_FlushSubpictureChannel, ( vout_thread_t *, int ) );
/**
* Return the spu_t object associated to a vout_thread_t.
*
* The return object is valid only as long as the vout is. You must not
* release the spu_t object returned.
* It cannot return NULL so no need to check.
*/
VLC_EXPORT( spu_t *, vout_GetSpu, ( vout_thread_t * ) );
VLC_EXPORT( void, vout_EnableFilter, ( vout_thread_t *, const char *,bool , bool ) ); VLC_EXPORT( void, vout_EnableFilter, ( vout_thread_t *, const char *,bool , bool ) );
/**@}*/ /**@}*/
......
...@@ -370,10 +370,7 @@ void ExtVideo::ChangeVFiltersString( const char *psz_name, bool b_add ) ...@@ -370,10 +370,7 @@ void ExtVideo::ChangeVFiltersString( const char *psz_name, bool b_add )
p_vout = THEMIM->getVout(); p_vout = THEMIM->getVout();
if( p_vout ) if( p_vout )
{ {
if( !strcmp( psz_filter_type, "sub-filter" ) ) var_SetString( p_vout, psz_filter_type, psz_string );
var_SetString( vout_GetSpu( p_vout ), psz_filter_type, psz_string );
else
var_SetString( p_vout, psz_filter_type, psz_string );
vlc_object_release( p_vout ); vlc_object_release( p_vout );
} }
......
...@@ -84,10 +84,7 @@ int transcode_osd_new( sout_stream_t *p_stream, sout_stream_id_t *id ) ...@@ -84,10 +84,7 @@ int transcode_osd_new( sout_stream_t *p_stream, sout_stream_id_t *id )
} }
if( !p_sys->p_spu ) if( !p_sys->p_spu )
{
p_sys->p_spu = spu_Create( p_stream ); p_sys->p_spu = spu_Create( p_stream );
spu_Init( p_sys->p_spu );
}
return VLC_SUCCESS; return VLC_SUCCESS;
...@@ -127,10 +124,7 @@ int transcode_osd_process( sout_stream_t *p_stream, sout_stream_id_t *id, ...@@ -127,10 +124,7 @@ int transcode_osd_process( sout_stream_t *p_stream, sout_stream_id_t *id,
{ {
msg_Warn( p_stream, "spu channel not initialized, doing it now" ); msg_Warn( p_stream, "spu channel not initialized, doing it now" );
if( !p_sys->p_spu ) if( !p_sys->p_spu )
{
p_sys->p_spu = spu_Create( p_stream ); p_sys->p_spu = spu_Create( p_stream );
spu_Init( p_sys->p_spu );
}
} }
if( p_subpic ) if( p_subpic )
......
...@@ -91,10 +91,7 @@ int transcode_spu_new( sout_stream_t *p_stream, sout_stream_id_t *id ) ...@@ -91,10 +91,7 @@ int transcode_spu_new( sout_stream_t *p_stream, sout_stream_id_t *id )
} }
if( !p_sys->p_spu ) if( !p_sys->p_spu )
{
p_sys->p_spu = spu_Create( p_stream ); p_sys->p_spu = spu_Create( p_stream );
spu_Init( p_sys->p_spu );
}
return VLC_SUCCESS; return VLC_SUCCESS;
} }
......
...@@ -450,9 +450,8 @@ static int Open( vlc_object_t *p_this ) ...@@ -450,9 +450,8 @@ static int Open( vlc_object_t *p_this )
if( val.psz_string && *val.psz_string ) if( val.psz_string && *val.psz_string )
{ {
p_sys->p_spu = spu_Create( p_stream ); p_sys->p_spu = spu_Create( p_stream );
var_Create( p_sys->p_spu, "sub-filter", VLC_VAR_STRING ); if( p_sys->p_spu )
var_Set( p_sys->p_spu, "sub-filter", val ); spu_ChangeFilters( p_sys->p_spu, val.psz_string );
spu_Init( p_sys->p_spu );
} }
free( val.psz_string ); free( val.psz_string );
...@@ -465,7 +464,6 @@ static int Open( vlc_object_t *p_this ) ...@@ -465,7 +464,6 @@ static int Open( vlc_object_t *p_this )
var_Get( p_stream, SOUT_CFG_PREFIX "osd", &val ); var_Get( p_stream, SOUT_CFG_PREFIX "osd", &val );
if( val.b_bool ) if( val.b_bool )
{ {
vlc_value_t osd_val;
char *psz_next; char *psz_next;
psz_next = config_ChainCreate( &p_sys->psz_osdenc, psz_next = config_ChainCreate( &p_sys->psz_osdenc,
...@@ -478,18 +476,13 @@ static int Open( vlc_object_t *p_this ) ...@@ -478,18 +476,13 @@ static int Open( vlc_object_t *p_this )
if( !p_sys->p_spu ) if( !p_sys->p_spu )
{ {
osd_val.psz_string = strdup("osdmenu");
p_sys->p_spu = spu_Create( p_stream ); p_sys->p_spu = spu_Create( p_stream );
var_Create( p_sys->p_spu, "sub-filter", VLC_VAR_STRING ); if( p_sys->p_spu )
var_Set( p_sys->p_spu, "sub-filter", osd_val ); spu_ChangeFilters( p_sys->p_spu, "osdmenu" );
spu_Init( p_sys->p_spu );
free( osd_val.psz_string );
} }
else else
{ {
osd_val.psz_string = strdup("osdmenu"); spu_ChangeFilters( p_sys->p_spu, "osdmenu" );
var_Set( p_sys->p_spu, "sub-filter", osd_val );
free( osd_val.psz_string );
} }
} }
......
...@@ -385,7 +385,7 @@ sout_UpdateStatistic ...@@ -385,7 +385,7 @@ sout_UpdateStatistic
spu_Create spu_Create
spu_Destroy spu_Destroy
spu_DisplaySubpicture spu_DisplaySubpicture
spu_Init spu_ChangeFilters
spu_RenderSubpictures spu_RenderSubpictures
spu_SortSubpictures spu_SortSubpictures
spu_RegisterChannel spu_RegisterChannel
...@@ -621,7 +621,6 @@ vout_RegisterSubpictureChannel ...@@ -621,7 +621,6 @@ vout_RegisterSubpictureChannel
vout_FlushSubpictureChannel vout_FlushSubpictureChannel
vout_EnableFilter vout_EnableFilter
vout_GetSnapshot vout_GetSnapshot
vout_GetSpu
vout_OSDIcon vout_OSDIcon
vout_OSDMessage vout_OSDMessage
vout_OSDEpg vout_OSDEpg
......
...@@ -40,6 +40,7 @@ void vout_control_cmd_Clean(vout_control_cmd_t *cmd) ...@@ -40,6 +40,7 @@ void vout_control_cmd_Clean(vout_control_cmd_t *cmd)
switch (cmd->type) { switch (cmd->type) {
case VOUT_CONTROL_OSD_TITLE: case VOUT_CONTROL_OSD_TITLE:
case VOUT_CONTROL_CHANGE_FILTERS: case VOUT_CONTROL_CHANGE_FILTERS:
case VOUT_CONTROL_CHANGE_SUB_FILTERS:
free(cmd->u.string); free(cmd->u.string);
break; break;
default: default:
......
...@@ -41,6 +41,7 @@ enum { ...@@ -41,6 +41,7 @@ enum {
#endif #endif
VOUT_CONTROL_OSD_TITLE, /* string */ VOUT_CONTROL_OSD_TITLE, /* string */
VOUT_CONTROL_CHANGE_FILTERS, /* string */ VOUT_CONTROL_CHANGE_FILTERS, /* string */
VOUT_CONTROL_CHANGE_SUB_FILTERS, /* string */
VOUT_CONTROL_PAUSE, VOUT_CONTROL_PAUSE,
VOUT_CONTROL_RESET, VOUT_CONTROL_RESET,
......
...@@ -177,9 +177,6 @@ vout_thread_t *(vout_Create)(vlc_object_t *object, const video_format_t *fmt) ...@@ -177,9 +177,6 @@ vout_thread_t *(vout_Create)(vlc_object_t *object, const video_format_t *fmt)
/* Initialize subpicture unit */ /* Initialize subpicture unit */
vout->p->p_spu = spu_Create(vout); vout->p->p_spu = spu_Create(vout);
/* */
spu_Init(vout->p->p_spu);
/* Take care of some "interface/control" related initialisations */ /* Take care of some "interface/control" related initialisations */
vout_IntfInit(vout); vout_IntfInit(vout);
...@@ -362,11 +359,6 @@ void vout_FlushSubpictureChannel( vout_thread_t *vout, int channel ) ...@@ -362,11 +359,6 @@ void vout_FlushSubpictureChannel( vout_thread_t *vout, int channel )
spu_ClearChannel(vout->p->p_spu, channel); spu_ClearChannel(vout->p->p_spu, channel);
} }
spu_t *vout_GetSpu(vout_thread_t *vout)
{
return vout->p->p_spu;
}
/* vout_Control* are usable by anyone at anytime */ /* vout_Control* are usable by anyone at anytime */
void vout_ControlChangeFullscreen(vout_thread_t *vout, bool fullscreen) void vout_ControlChangeFullscreen(vout_thread_t *vout, bool fullscreen)
{ {
...@@ -429,6 +421,11 @@ void vout_ControlChangeFilters(vout_thread_t *vout, const char *filters) ...@@ -429,6 +421,11 @@ void vout_ControlChangeFilters(vout_thread_t *vout, const char *filters)
vout_control_PushString(&vout->p->control, VOUT_CONTROL_CHANGE_FILTERS, vout_control_PushString(&vout->p->control, VOUT_CONTROL_CHANGE_FILTERS,
filters); filters);
} }
void vout_ControlChangeSubFilters(vout_thread_t *vout, const char *filters)
{
vout_control_PushString(&vout->p->control, VOUT_CONTROL_CHANGE_SUB_FILTERS,
filters);
}
/* */ /* */
static picture_t *VoutVideoFilterNewPicture(filter_t *filter) static picture_t *VoutVideoFilterNewPicture(filter_t *filter)
...@@ -689,6 +686,11 @@ static void ThreadChangeFilters(vout_thread_t *vout, const char *filters) ...@@ -689,6 +686,11 @@ static void ThreadChangeFilters(vout_thread_t *vout, const char *filters)
vlc_mutex_unlock(&vout->p->vfilter_lock); vlc_mutex_unlock(&vout->p->vfilter_lock);
} }
static void ThreadChangeSubFilters(vout_thread_t *vout, const char *filters)
{
spu_ChangeFilters(vout->p->p_spu, filters);
}
static void ThreadChangePause(vout_thread_t *vout, bool is_paused, mtime_t date) static void ThreadChangePause(vout_thread_t *vout, bool is_paused, mtime_t date)
{ {
assert(!vout->p->pause.is_on || !is_paused); assert(!vout->p->pause.is_on || !is_paused);
...@@ -991,6 +993,9 @@ static void *Thread(void *object) ...@@ -991,6 +993,9 @@ static void *Thread(void *object)
case VOUT_CONTROL_CHANGE_FILTERS: case VOUT_CONTROL_CHANGE_FILTERS:
ThreadChangeFilters(vout, cmd.u.string); ThreadChangeFilters(vout, cmd.u.string);
break; break;
case VOUT_CONTROL_CHANGE_SUB_FILTERS:
ThreadChangeSubFilters(vout, cmd.u.string);
break;
case VOUT_CONTROL_PAUSE: case VOUT_CONTROL_PAUSE:
ThreadChangePause(vout, cmd.u.pause.is_on, cmd.u.pause.date); ThreadChangePause(vout, cmd.u.pause.is_on, cmd.u.pause.date);
break; break;
......
...@@ -129,6 +129,7 @@ void vout_ControlChangeCropRatio(vout_thread_t *, unsigned num, unsigned den); ...@@ -129,6 +129,7 @@ void vout_ControlChangeCropRatio(vout_thread_t *, unsigned num, unsigned den);
void vout_ControlChangeCropWindow(vout_thread_t *, int x, int y, int width, int height); void vout_ControlChangeCropWindow(vout_thread_t *, int x, int y, int width, int height);
void vout_ControlChangeCropBorder(vout_thread_t *, int left, int top, int right, int bottom); void vout_ControlChangeCropBorder(vout_thread_t *, int left, int top, int right, int bottom);
void vout_ControlChangeFilters(vout_thread_t *, const char *); void vout_ControlChangeFilters(vout_thread_t *, const char *);
void vout_ControlChangeSubFilters(vout_thread_t *, const char *);
/* */ /* */
void vout_IntfInit( vout_thread_t * ); void vout_IntfInit( vout_thread_t * );
......
...@@ -73,6 +73,8 @@ static int VideoFilterCallback( vlc_object_t *, char const *, ...@@ -73,6 +73,8 @@ static int VideoFilterCallback( vlc_object_t *, char const *,
vlc_value_t, vlc_value_t, void * ); vlc_value_t, vlc_value_t, void * );
static int VideoSplitterCallback( vlc_object_t *, char const *, static int VideoSplitterCallback( vlc_object_t *, char const *,
vlc_value_t, vlc_value_t, void * ); vlc_value_t, vlc_value_t, void * );
static int SubFilterCallback( vlc_object_t *, char const *,
vlc_value_t, vlc_value_t, void * );
static int TitleShowCallback( vlc_object_t *, char const *, static int TitleShowCallback( vlc_object_t *, char const *,
vlc_value_t, vlc_value_t, void * ); vlc_value_t, vlc_value_t, void * );
...@@ -369,6 +371,12 @@ void vout_IntfInit( vout_thread_t *p_vout ) ...@@ -369,6 +371,12 @@ void vout_IntfInit( vout_thread_t *p_vout )
var_Change( p_vout, "vout-filter", VLC_VAR_SETTEXT, &text, NULL ); var_Change( p_vout, "vout-filter", VLC_VAR_SETTEXT, &text, NULL );
var_AddCallback( p_vout, "vout-filter", VideoSplitterCallback, NULL ); var_AddCallback( p_vout, "vout-filter", VideoSplitterCallback, NULL );
/* Add a sub-filter variable */
var_Create( p_vout, "sub-filter",
VLC_VAR_STRING | VLC_VAR_DOINHERIT | VLC_VAR_ISCOMMAND );
var_AddCallback( p_vout, "sub-filter", SubFilterCallback, NULL );
var_TriggerCallback( p_vout, "sub-filter" );
/* Mouse coordinates */ /* Mouse coordinates */
var_Create( p_vout, "mouse-button-down", VLC_VAR_INTEGER ); var_Create( p_vout, "mouse-button-down", VLC_VAR_INTEGER );
var_Create( p_vout, "mouse-moved", VLC_VAR_COORDS ); var_Create( p_vout, "mouse-moved", VLC_VAR_COORDS );
...@@ -571,10 +579,7 @@ void vout_EnableFilter( vout_thread_t *p_vout, const char *psz_name, ...@@ -571,10 +579,7 @@ void vout_EnableFilter( vout_thread_t *p_vout, const char *psz_name,
} }
module_release( p_obj ); module_release( p_obj );
if( !strcmp( psz_filter_type, "sub-filter") ) psz_string = var_GetString( p_vout, psz_filter_type );
psz_string = var_GetString( vout_GetSpu( p_vout ), psz_filter_type );
else
psz_string = var_GetString( p_vout, psz_filter_type );
/* Todo : Use some generic chain manipulation functions */ /* Todo : Use some generic chain manipulation functions */
if( !psz_string ) psz_string = strdup(""); if( !psz_string ) psz_string = strdup("");
...@@ -619,16 +624,10 @@ void vout_EnableFilter( vout_thread_t *p_vout, const char *psz_name, ...@@ -619,16 +624,10 @@ void vout_EnableFilter( vout_thread_t *p_vout, const char *psz_name,
if( b_setconfig ) if( b_setconfig )
{ {
if( !strcmp( psz_filter_type, "sub-filter") ) config_PutPsz( p_vout, psz_filter_type, psz_string );
config_PutPsz( vout_GetSpu( p_vout ), psz_filter_type, psz_string );
else
config_PutPsz( p_vout, psz_filter_type, psz_string );
} }
if( !strcmp( psz_filter_type, "sub-filter") ) var_SetString( p_vout, psz_filter_type, psz_string );
var_SetString( vout_GetSpu( p_vout ), psz_filter_type, psz_string );
else
var_SetString( p_vout, psz_filter_type, psz_string );
free( psz_string ); free( psz_string );
} }
...@@ -781,6 +780,16 @@ static int VideoSplitterCallback( vlc_object_t *p_this, char const *psz_cmd, ...@@ -781,6 +780,16 @@ static int VideoSplitterCallback( vlc_object_t *p_this, char const *psz_cmd,
return VLC_SUCCESS; return VLC_SUCCESS;
} }
static int SubFilterCallback( vlc_object_t *p_this, char const *psz_cmd,
vlc_value_t oldval, vlc_value_t newval, void *p_data)
{
vout_thread_t *p_vout = (vout_thread_t *)p_this;
VLC_UNUSED(psz_cmd); VLC_UNUSED(oldval); VLC_UNUSED(p_data);
vout_ControlChangeSubFilters( p_vout, newval.psz_string );
return VLC_SUCCESS;
}
static int TitleShowCallback( vlc_object_t *p_this, char const *psz_cmd, static int TitleShowCallback( vlc_object_t *p_this, char const *psz_cmd,
vlc_value_t oldval, vlc_value_t newval, void *p_data ) vlc_value_t oldval, vlc_value_t newval, void *p_data )
{ {
......
...@@ -171,9 +171,6 @@ static picture_t *spu_new_video_buffer( filter_t * ); ...@@ -171,9 +171,6 @@ static picture_t *spu_new_video_buffer( filter_t * );
static void spu_del_video_buffer( filter_t *, picture_t * ); static void spu_del_video_buffer( filter_t *, picture_t * );
/* Buffer aloccation fir SUB filter */ /* Buffer aloccation fir SUB filter */
static int SubFilterCallback( vlc_object_t *, char const *,
vlc_value_t, vlc_value_t, void * );
static int SubFilterAllocationInit( filter_t *, void * ); static int SubFilterAllocationInit( filter_t *, void * );
static void SubFilterAllocationClean( filter_t * ); static void SubFilterAllocationClean( filter_t * );
...@@ -238,20 +235,6 @@ spu_t *spu_Create( vlc_object_t *p_this ) ...@@ -238,20 +235,6 @@ spu_t *spu_Create( vlc_object_t *p_this )
return p_spu; return p_spu;
} }
/**
* Initialise the subpicture unit
*
* \param p_spu the subpicture unit object
*/
int spu_Init( spu_t *p_spu )
{
var_Create( p_spu, "sub-filter", VLC_VAR_STRING | VLC_VAR_DOINHERIT );
var_AddCallback( p_spu, "sub-filter", SubFilterCallback, p_spu );
var_TriggerCallback( p_spu, "sub-filter" );
return VLC_SUCCESS;
}
/** /**
* Destroy the subpicture unit * Destroy the subpicture unit
* *
...@@ -261,8 +244,6 @@ void spu_Destroy( spu_t *p_spu ) ...@@ -261,8 +244,6 @@ void spu_Destroy( spu_t *p_spu )
{ {
spu_private_t *p_sys = p_spu->p; spu_private_t *p_sys = p_spu->p;
var_DelCallback( p_spu, "sub-filter", SubFilterCallback, p_spu );
if( p_sys->p_blend ) if( p_sys->p_blend )
filter_DeleteBlend( p_sys->p_blend ); filter_DeleteBlend( p_sys->p_blend );
...@@ -744,6 +725,18 @@ void spu_ClearChannel( spu_t *p_spu, int i_channel ) ...@@ -744,6 +725,18 @@ void spu_ClearChannel( spu_t *p_spu, int i_channel )
vlc_mutex_unlock( &p_sys->lock ); vlc_mutex_unlock( &p_sys->lock );
} }
void spu_ChangeFilters( spu_t *p_spu, const char *psz_filters )
{
spu_private_t *p_sys = p_spu->p;
vlc_mutex_lock( &p_sys->lock );
free( p_sys->psz_chain_update );
p_sys->psz_chain_update = strdup( psz_filters );
vlc_mutex_unlock( &p_sys->lock );
}
/***************************************************************************** /*****************************************************************************
* subpicture_t allocation * subpicture_t allocation
*****************************************************************************/ *****************************************************************************/
...@@ -1917,20 +1910,3 @@ static void SubFilterAllocationClean( filter_t *p_filter ) ...@@ -1917,20 +1910,3 @@ static void SubFilterAllocationClean( filter_t *p_filter )
free( p_filter->p_owner ); free( p_filter->p_owner );
} }
static int SubFilterCallback( vlc_object_t *p_object, char const *psz_var,
vlc_value_t oldval, vlc_value_t newval, void *p_data )
{
spu_t *p_spu = p_data;
spu_private_t *p_sys = p_spu->p;
VLC_UNUSED(p_object); VLC_UNUSED(oldval); VLC_UNUSED(psz_var);
vlc_mutex_lock( &p_sys->lock );
free( p_sys->psz_chain_update );
p_sys->psz_chain_update = strdup( newval.psz_string );
vlc_mutex_unlock( &p_sys->lock );
return VLC_SUCCESS;
}
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