Skip to content

Commit

Permalink
Moved "sub-filter" from spu_t to vout_thread_t.
Browse files Browse the repository at this point in the history
  • Loading branch information
Laurent Aimar committed May 18, 2010
1 parent ef785d7 commit 5a6ee79
Show file tree
Hide file tree
Showing 14 changed files with 64 additions and 97 deletions.
7 changes: 3 additions & 4 deletions bindings/mediacontrol/mediacontrol_audio_video.c
Original file line number Diff line number Diff line change
Expand Up @@ -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 );
}


Expand Down
6 changes: 5 additions & 1 deletion include/vlc_spu.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 );

Expand Down Expand Up @@ -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
Expand Down
9 changes: 0 additions & 9 deletions include/vlc_vout.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 ) );

/**@}*/
Expand Down
5 changes: 1 addition & 4 deletions modules/gui/qt4/components/extended_panels.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 );
}

Expand Down
6 changes: 0 additions & 6 deletions modules/stream_out/transcode/osd.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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 )
Expand Down
3 changes: 0 additions & 3 deletions modules/stream_out/transcode/spu.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
17 changes: 5 additions & 12 deletions modules/stream_out/transcode/transcode.c
Original file line number Diff line number Diff line change
Expand Up @@ -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 );

Expand All @@ -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,
Expand All @@ -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" );
}
}

Expand Down
3 changes: 1 addition & 2 deletions src/libvlccore.sym
Original file line number Diff line number Diff line change
Expand Up @@ -385,7 +385,7 @@ sout_UpdateStatistic
spu_Create
spu_Destroy
spu_DisplaySubpicture
spu_Init
spu_ChangeFilters
spu_RenderSubpictures
spu_SortSubpictures
spu_RegisterChannel
Expand Down Expand Up @@ -621,7 +621,6 @@ vout_RegisterSubpictureChannel
vout_FlushSubpictureChannel
vout_EnableFilter
vout_GetSnapshot
vout_GetSpu
vout_OSDIcon
vout_OSDMessage
vout_OSDEpg
Expand Down
1 change: 1 addition & 0 deletions src/video_output/control.c
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
1 change: 1 addition & 0 deletions src/video_output/control.h
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
21 changes: 13 additions & 8 deletions src/video_output/video_output.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down Expand Up @@ -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)
{
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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;
Expand Down
1 change: 1 addition & 0 deletions src/video_output/vout_internal.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 * );
Expand Down
33 changes: 21 additions & 12 deletions src/video_output/vout_intf.c
Original file line number Diff line number Diff line change
Expand Up @@ -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 * );
Expand Down Expand Up @@ -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 );
Expand Down Expand Up @@ -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("");
Expand Down Expand Up @@ -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 );
}
Expand Down Expand Up @@ -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 )
{
Expand Down
48 changes: 12 additions & 36 deletions src/video_output/vout_subpictures.c
Original file line number Diff line number Diff line change
Expand Up @@ -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 * );

Expand Down Expand Up @@ -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
*
Expand All @@ -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 );

Expand Down Expand Up @@ -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
*****************************************************************************/
Expand Down Expand Up @@ -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;
}

0 comments on commit 5a6ee79

Please sign in to comment.