[vlc-devel] [RFC 2/4] Create a input_SubtitleAdd function that can take both files and URLs

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


---
 src/input/input.c | 16 +++++++++++++++-
 1 file changed, 15 insertions(+), 1 deletion(-)

diff --git a/src/input/input.c b/src/input/input.c
index 3c6ed39..fbf0006 100644
--- a/src/input/input.c
+++ b/src/input/input.c
@@ -109,6 +109,7 @@ enum {
 
 static void input_SubtitleAddInternal( input_thread_t *, const char *, unsigned );
 static void input_SubtitleFileAdd( input_thread_t *, char *, unsigned );
+static void input_SubtitleAdd( input_thread_t *, const char *, unsigned );
 static void input_ChangeState( input_thread_t *p_input, int i_state ); /* TODO fix name */
 
 #undef input_Create
@@ -1930,7 +1931,7 @@ static bool Control( input_thread_t *p_input,
 
         case INPUT_CONTROL_ADD_SUBTITLE:
             if( val.psz_string )
-                input_SubtitleFileAdd( p_input, val.psz_string, true );
+                input_SubtitleAdd( p_input, val.psz_string, true );
             break;
 
         case INPUT_CONTROL_ADD_SLAVE:
@@ -2964,6 +2965,19 @@ static void MRLSections( const char *p,
 /*****************************************************************************
  * input_AddSubtitles: add a subtitle file and enable it
  *****************************************************************************/
+static void input_SubtitleAdd( input_thread_t *p_input,
+                               const char *url, unsigned i_flags )
+{
+    if( strstr(url, "://") )
+        input_SubtitleAddInternal( p_input, url, i_flags );
+    else
+    {
+        char *uri = vlc_path2uri( url, NULL );
+        input_SubtitleFileAdd( p_input, uri, i_flags );
+        free( uri );
+    }
+}
+
 static void input_SubtitleAddInternal( input_thread_t *p_input,
                                const char *url, unsigned i_flags )
 {
-- 
2.4.0




More information about the vlc-devel mailing list