[vlc-devel] [RFC 3/4] Add --sub-mrl option

Jean-Baptiste Kempf jb at videolan.org
Mon May 11 20:46:04 CEST 2015


---
 src/input/input.c   | 8 ++++++++
 src/input/var.c     | 1 +
 src/libvlc-module.c | 4 ++++
 3 files changed, 13 insertions(+)

diff --git a/src/input/input.c b/src/input/input.c
index fbf0006..414be12 100644
--- a/src/input/input.c
+++ b/src/input/input.c
@@ -998,6 +998,14 @@ static void LoadSubtitles( input_thread_t *p_input )
     }
     free( psz_subtitle );
 
+    psz_subtitle = var_GetNonEmptyString( p_input, "sub-mrl" );
+    if( psz_subtitle != NULL )
+    {
+        msg_Err( p_input, "forced subtitle MRL: %s", psz_subtitle );
+        input_SubtitleAdd( p_input, psz_subtitle, i_flags );
+        i_flags = SUB_NOFLAG;
+    }
+
     /* Load subtitles from attachments */
     int i_attachment = 0;
     input_attachment_t **pp_attachment = NULL;
diff --git a/src/input/var.c b/src/input/var.c
index 258b5f4..6d37fac 100644
--- a/src/input/var.c
+++ b/src/input/var.c
@@ -444,6 +444,7 @@ void input_ConfigVarInit ( input_thread_t *p_input )
                     VLC_VAR_INTEGER|VLC_VAR_DOINHERIT );
 
         var_Create( p_input, "sub-file", VLC_VAR_STRING | VLC_VAR_DOINHERIT );
+        var_Create( p_input, "sub-mrl", VLC_VAR_STRING | VLC_VAR_DOINHERIT );
         var_Create( p_input, "sub-autodetect-file", VLC_VAR_BOOL |
                     VLC_VAR_DOINHERIT );
         var_Create( p_input, "sub-autodetect-path", VLC_VAR_STRING |
diff --git a/src/libvlc-module.c b/src/libvlc-module.c
index 42502bd..493956a 100644
--- a/src/libvlc-module.c
+++ b/src/libvlc-module.c
@@ -742,6 +742,7 @@ static const char *const ppsz_prefres[] = {
 #define SUB_FILE_LONGTEXT N_( \
     "Load this subtitle file. To be used when autodetect cannot detect " \
     "your subtitle file.")
+#define SUB_MRL_TEXT N_("Use subtitle MRL")
 
 /* DVD and VCD devices */
 #define DVD_DEV_TEXT N_("DVD device")
@@ -1624,6 +1625,9 @@ vlc_module_begin ()
     add_loadfile( "sub-file", NULL, SUB_FILE_TEXT,
                   SUB_FILE_LONGTEXT, false )
         change_safe()
+    add_loadfile( "sub-mrl", NULL, SUB_MRL_TEXT,
+                  SUB_MRL_TEXT, false )
+        change_safe()
     add_bool( "sub-autodetect-file", true,
                  SUB_AUTO_TEXT, SUB_AUTO_LONGTEXT, false )
     add_integer( "sub-autodetect-fuzzy", 3,
-- 
2.4.0




More information about the vlc-devel mailing list