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,
int i_flags, int i_hmargin, int i_vmargin,
mtime_t i_start, mtime_t i_stop )
{
return osd_ShowTextAbsolute( vout_GetSpu( p_vout ), i_channel,
psz_string, p_style,
i_flags, i_hmargin, i_vmargin,
i_start, i_stop );
(void)p_style; (void)i_hmargin; (void)i_vmargin;
vout_OSDText( p_vout, i_channel, i_flags & ~SUBPICTURE_ALIGN_MASK,
i_stop - i_start, psz_string );
}
......
......@@ -60,7 +60,6 @@ struct spu_t
VLC_EXPORT( spu_t *, spu_Create, ( vlc_object_t * ) );
#define spu_Create(a) spu_Create(VLC_OBJECT(a))
VLC_EXPORT( int, spu_Init, ( spu_t * ) );
VLC_EXPORT( void, spu_Destroy, ( spu_t * ) );
void spu_Attach( spu_t *, vlc_object_t *, bool );
......@@ -97,6 +96,11 @@ VLC_EXPORT( int, spu_RegisterChannel, ( spu_t * ) );
*/
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
......
......@@ -168,15 +168,6 @@ VLC_EXPORT( void, vout_PutSubpicture, ( vout_thread_t *, subpicture_
VLC_EXPORT( int, vout_RegisterSubpictureChannel, ( vout_thread_t * ) );
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 ) );
/**@}*/
......
......@@ -370,10 +370,7 @@ void ExtVideo::ChangeVFiltersString( const char *psz_name, bool b_add )
p_vout = THEMIM->getVout();
if( p_vout )
{
if( !strcmp( psz_filter_type, "sub-filter" ) )
var_SetString( vout_GetSpu( p_vout ), psz_filter_type, psz_string );
else
var_SetString( p_vout, psz_filter_type, psz_string );
var_SetString( p_vout, psz_filter_type, psz_string );
vlc_object_release( p_vout );
}
......
......@@ -84,10 +84,7 @@ int transcode_osd_new( sout_stream_t *p_stream, sout_stream_id_t *id )
}
if( !p_sys->p_spu )
{
p_sys->p_spu = spu_Create( p_stream );
spu_Init( p_sys->p_spu );
}
return VLC_SUCCESS;
......@@ -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" );
if( !p_sys->p_spu )
{
p_sys->p_spu = spu_Create( p_stream );
spu_Init( p_sys->p_spu );
}
}
if( p_subpic )
......
......@@ -91,10 +91,7 @@ int transcode_spu_new( sout_stream_t *p_stream, sout_stream_id_t *id )
}
if( !p_sys->p_spu )
{
p_sys->p_spu = spu_Create( p_stream );
spu_Init( p_sys->p_spu );
}
return VLC_SUCCESS;
}
......
......@@ -450,9 +450,8 @@ static int Open( vlc_object_t *p_this )
if( val.psz_string && *val.psz_string )
{
p_sys->p_spu = spu_Create( p_stream );
var_Create( p_sys->p_spu, "sub-filter", VLC_VAR_STRING );
var_Set( p_sys->p_spu, "sub-filter", val );
spu_Init( p_sys->p_spu );
if( p_sys->p_spu )
spu_ChangeFilters( p_sys->p_spu, val.psz_string );
}
free( val.psz_string );
......@@ -465,7 +464,6 @@ static int Open( vlc_object_t *p_this )
var_Get( p_stream, SOUT_CFG_PREFIX "osd", &val );
if( val.b_bool )
{
vlc_value_t osd_val;
char *psz_next;
psz_next = config_ChainCreate( &p_sys->psz_osdenc,
......@@ -478,18 +476,13 @@ static int Open( vlc_object_t *p_this )
if( !p_sys->p_spu )
{
osd_val.psz_string = strdup("osdmenu");
p_sys->p_spu = spu_Create( p_stream );
var_Create( p_sys->p_spu, "sub-filter", VLC_VAR_STRING );
var_Set( p_sys->p_spu, "sub-filter", osd_val );
spu_Init( p_sys->p_spu );
free( osd_val.psz_string );
if( p_sys->p_spu )
spu_ChangeFilters( p_sys->p_spu, "osdmenu" );
}
else
{
osd_val.psz_string = strdup("osdmenu");
var_Set( p_sys->p_spu, "sub-filter", osd_val );
free( osd_val.psz_string );
spu_ChangeFilters( p_sys->p_spu, "osdmenu" );
}
}
......
......@@ -385,7 +385,7 @@ sout_UpdateStatistic
spu_Create
spu_Destroy
spu_DisplaySubpicture
spu_Init
spu_ChangeFilters
spu_RenderSubpictures
spu_SortSubpictures
spu_RegisterChannel
......@@ -621,7 +621,6 @@ vout_RegisterSubpictureChannel
vout_FlushSubpictureChannel
vout_EnableFilter
vout_GetSnapshot
vout_GetSpu
vout_OSDIcon
vout_OSDMessage
vout_OSDEpg
......
......@@ -40,6 +40,7 @@ void vout_control_cmd_Clean(vout_control_cmd_t *cmd)
switch (cmd->type) {
case VOUT_CONTROL_OSD_TITLE:
case VOUT_CONTROL_CHANGE_FILTERS:
case VOUT_CONTROL_CHANGE_SUB_FILTERS:
free(cmd->u.string);
break;
default:
......
......@@ -41,6 +41,7 @@ enum {
#endif
VOUT_CONTROL_OSD_TITLE, /* string */
VOUT_CONTROL_CHANGE_FILTERS, /* string */
VOUT_CONTROL_CHANGE_SUB_FILTERS, /* string */
VOUT_CONTROL_PAUSE,
VOUT_CONTROL_RESET,
......
......@@ -177,9 +177,6 @@ vout_thread_t *(vout_Create)(vlc_object_t *object, const video_format_t *fmt)
/* Initialize subpicture unit */
vout->p->p_spu = spu_Create(vout);
/* */
spu_Init(vout->p->p_spu);
/* Take care of some "interface/control" related initialisations */
vout_IntfInit(vout);
......@@ -362,11 +359,6 @@ void vout_FlushSubpictureChannel( vout_thread_t *vout, int 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 */
void vout_ControlChangeFullscreen(vout_thread_t *vout, bool fullscreen)
{
......@@ -429,6 +421,11 @@ void vout_ControlChangeFilters(vout_thread_t *vout, const char *filters)
vout_control_PushString(&vout->p->control, VOUT_CONTROL_CHANGE_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)
......@@ -689,6 +686,11 @@ static void ThreadChangeFilters(vout_thread_t *vout, const char *filters)
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)
{
assert(!vout->p->pause.is_on || !is_paused);
......@@ -991,6 +993,9 @@ static void *Thread(void *object)
case VOUT_CONTROL_CHANGE_FILTERS:
ThreadChangeFilters(vout, cmd.u.string);
break;
case VOUT_CONTROL_CHANGE_SUB_FILTERS:
ThreadChangeSubFilters(vout, cmd.u.string);
break;
case VOUT_CONTROL_PAUSE:
ThreadChangePause(vout, cmd.u.pause.is_on, cmd.u.pause.date);
break;
......
......@@ -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_ControlChangeCropBorder(vout_thread_t *, int left, int top, int right, int bottom);
void vout_ControlChangeFilters(vout_thread_t *, const char *);
void vout_ControlChangeSubFilters(vout_thread_t *, const char *);
/* */
void vout_IntfInit( vout_thread_t * );
......
......@@ -73,6 +73,8 @@ static int VideoFilterCallback( vlc_object_t *, char const *,
vlc_value_t, vlc_value_t, void * );
static int VideoSplitterCallback( vlc_object_t *, char const *,
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 *,
vlc_value_t, vlc_value_t, void * );
......@@ -369,6 +371,12 @@ void vout_IntfInit( vout_thread_t *p_vout )
var_Change( p_vout, "vout-filter", VLC_VAR_SETTEXT, &text, 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 */
var_Create( p_vout, "mouse-button-down", VLC_VAR_INTEGER );
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,
}
module_release( p_obj );
if( !strcmp( psz_filter_type, "sub-filter") )
psz_string = var_GetString( vout_GetSpu( p_vout ), psz_filter_type );
else
psz_string = var_GetString( p_vout, psz_filter_type );
psz_string = var_GetString( p_vout, psz_filter_type );
/* Todo : Use some generic chain manipulation functions */
if( !psz_string ) psz_string = strdup("");
......@@ -619,16 +624,10 @@ void vout_EnableFilter( vout_thread_t *p_vout, const char *psz_name,
if( b_setconfig )
{
if( !strcmp( psz_filter_type, "sub-filter") )
config_PutPsz( vout_GetSpu( p_vout ), psz_filter_type, psz_string );
else
config_PutPsz( p_vout, psz_filter_type, psz_string );
config_PutPsz( p_vout, psz_filter_type, psz_string );
}
if( !strcmp( psz_filter_type, "sub-filter") )
var_SetString( vout_GetSpu( p_vout ), psz_filter_type, psz_string );
else
var_SetString( p_vout, psz_filter_type, psz_string );
var_SetString( p_vout, psz_filter_type, psz_string );
free( psz_string );
}
......@@ -781,6 +780,16 @@ static int VideoSplitterCallback( vlc_object_t *p_this, char const *psz_cmd,
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,
vlc_value_t oldval, vlc_value_t newval, void *p_data )
{
......
......@@ -171,9 +171,6 @@ static picture_t *spu_new_video_buffer( filter_t * );
static void spu_del_video_buffer( filter_t *, picture_t * );
/* 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 void SubFilterAllocationClean( filter_t * );
......@@ -238,20 +235,6 @@ spu_t *spu_Create( vlc_object_t *p_this )
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
*
......@@ -261,8 +244,6 @@ void spu_Destroy( spu_t *p_spu )
{
spu_private_t *p_sys = p_spu->p;
var_DelCallback( p_spu, "sub-filter", SubFilterCallback, p_spu );
if( p_sys->p_blend )
filter_DeleteBlend( p_sys->p_blend );
......@@ -744,6 +725,18 @@ void spu_ClearChannel( spu_t *p_spu, int i_channel )
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
*****************************************************************************/
......@@ -1917,20 +1910,3 @@ static void SubFilterAllocationClean( filter_t *p_filter )
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