Moved "sub-filter" from spu_t to vout_thread_t.
authorLaurent Aimar <fenrir@videolan.org>
Tue, 18 May 2010 20:45:17 +0000 (22:45 +0200)
committerLaurent Aimar <fenrir@videolan.org>
Tue, 18 May 2010 21:10:29 +0000 (23:10 +0200)
14 files changed:
bindings/mediacontrol/mediacontrol_audio_video.c
include/vlc_spu.h
include/vlc_vout.h
modules/gui/qt4/components/extended_panels.cpp
modules/stream_out/transcode/osd.c
modules/stream_out/transcode/spu.c
modules/stream_out/transcode/transcode.c
src/libvlccore.sym
src/video_output/control.c
src/video_output/control.h
src/video_output/video_output.c
src/video_output/vout_internal.h
src/video_output/vout_intf.c
src/video_output/vout_subpictures.c

index 5b70613..0d04316 100644 (file)
@@ -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 );
 }
 
 
index 55a94d5..5e454bc 100644 (file)
@@ -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
index 84c04fa..8c75c72 100644 (file)
@@ -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  ) );
 
 /**@}*/
index ceac89e..874277a 100644 (file)
@@ -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 );
     }
 
index 2448541..a895084 100644 (file)
@@ -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 )
index c53a3c2..d031d9a 100644 (file)
@@ -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;
 }
index 3d4a846..0c5a01b 100644 (file)
@@ -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" );
         }
     }
 
index 6f3fea9..7e23043 100644 (file)
@@ -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
index 583be54..9540ebd 100644 (file)
@@ -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:
index 59202e1..8048e6d 100644 (file)
@@ -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,
index 63ee9f8..5b06f51 100644 (file)
@@ -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;
index 5d19e88..b6c0b78 100644 (file)
@@ -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 * );
index 8e3713b..666fcc2 100644 (file)
@@ -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 )
 {
index 469102c..ee608b9 100644 (file)
@@ -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 * );
 
@@ -239,20 +236,6 @@ spu_t *spu_Create( vlc_object_t *p_this )
 }
 
 /**
- * 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
  *
  * \param p_this the parent object which destroys 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;
-}
-