]> git.sesse.net Git - vlc/blobdiff - modules/demux/subtitle.c
input options whitelisting, step 2 (refs #1371)
[vlc] / modules / demux / subtitle.c
index 2b9b8c4d16c035af949508d32a8b88ada9495338..36da2e0795defa11c8fafa841e31aa126575d6d5 100644 (file)
@@ -28,7 +28,6 @@
 #include <vlc/vlc.h>
 #include <vlc_input.h>
 
-#include <string.h>
 
 #include <errno.h>
 #ifdef HAVE_SYS_TYPES_H
@@ -70,12 +69,15 @@ vlc_module_begin();
     add_float( "sub-fps", 0.0, NULL,
                N_("Frames per second"),
                SUB_FPS_LONGTEXT, VLC_TRUE );
+        change_safe();
     add_integer( "sub-delay", 0, NULL,
                N_("Subtitles delay"),
                SUB_DELAY_LONGTEXT, VLC_TRUE );
+        change_safe();
     add_string( "sub-type", "auto", NULL, N_("Subtitles format"),
                 SUB_TYPE_LONGTEXT, VLC_TRUE );
         change_string_list( ppsz_sub_type, NULL, NULL );
+        change_safe();
     set_callbacks( Open, Close );
 
     add_shortcut( "subtitle" );
@@ -177,13 +179,12 @@ static int Open ( vlc_object_t *p_this )
     demux_t        *p_demux = (demux_t*)p_this;
     demux_sys_t    *p_sys;
     es_format_t    fmt;
-    input_thread_t *p_input;
     float          f_fps;
     char           *psz_type;
     int  (*pf_read)( demux_t *, subtitle_t* );
     int            i, i_max;
 
-    if( strcmp( p_demux->psz_demux, "subtitle" ) )
+    if( !p_demux->b_force )
     {
         msg_Dbg( p_demux, "subtitle demux discarded" );
         return VLC_EGENERIC;
@@ -199,16 +200,11 @@ static int Open ( vlc_object_t *p_this )
     p_sys->i_microsecperframe = 40000;
 
     /* Get the FPS */
-    p_input = (input_thread_t *)vlc_object_find( p_demux, VLC_OBJECT_INPUT, FIND_PARENT );
-    if( p_input )
-    {
-        f_fps = var_GetFloat( p_input, "sub-original-fps" );
-        if( f_fps >= 1.0 )
-            p_sys->i_microsecperframe = (int64_t)( (float)1000000 / f_fps );
+    f_fps = var_CreateGetFloat( p_demux, "sub-original-fps" );
+    if( f_fps >= 1.0 )
+        p_sys->i_microsecperframe = (int64_t)( (float)1000000 / f_fps );
 
-        msg_Dbg( p_demux, "Movie fps: %f", f_fps );
-        vlc_object_release( p_input );
-    }
+    msg_Dbg( p_demux, "Movie fps: %f", f_fps );
 
     /* Check for override of the fps */
     f_fps = var_CreateGetFloat( p_demux, "sub-fps" );
@@ -515,10 +511,11 @@ static int Control( demux_t *p_demux, int i_query, va_list args )
         case DEMUX_GET_META:
         case DEMUX_GET_ATTACHMENTS:
         case DEMUX_GET_TITLE_INFO:
+        case DEMUX_HAS_UNSUPPORTED_META:
             return VLC_EGENERIC;
 
         default:
-            msg_Err( p_demux, "unknown query in subtitle control" );
+            msg_Err( p_demux, "unknown query %d in subtitle control", i_query );
             return VLC_EGENERIC;
     }
 }
@@ -834,7 +831,7 @@ static int ParseSubRipSubViewer( demux_t *p_demux, subtitle_t *p_subtitle,
         if( b_replace_br )
         {
             char *p;
-            
             while( ( p = strstr( psz_text, "[br]" ) ) )
             {
                 *p++ = '\n';