[vlc-devel] [PATCH 2/5] add es call back

Aaron Wang hughwung at gmail.com
Wed Sep 23 10:18:01 CEST 2015


---
 lib/media_player.c         |  2 ++
 src/input/input_internal.h |  2 ++
 src/input/var.c            | 28 ++++++++++++++++++++++------
 3 files changed, 26 insertions(+), 6 deletions(-)

diff --git a/lib/media_player.c b/lib/media_player.c
index 2136ab8..c82f33b 100644
--- a/lib/media_player.c
+++ b/lib/media_player.c
@@ -861,6 +861,7 @@ static void add_es_callbacks( input_thread_t *p_input_thread, libvlc_media_playe
     var_AddCallback( p_input_thread, "video-es", input_es_selected, p_mi );
     var_AddCallback( p_input_thread, "audio-es", input_es_selected, p_mi );
     var_AddCallback( p_input_thread, "spu-es", input_es_selected, p_mi );
+    var_AddCallback( p_input_thread, "spu-es2", input_es_selected, p_mi );
 }
 
 static void del_es_callbacks( input_thread_t *p_input_thread, libvlc_media_player_t *p_mi )
@@ -871,6 +872,7 @@ static void del_es_callbacks( input_thread_t *p_input_thread, libvlc_media_playe
     var_DelCallback( p_input_thread, "video-es", input_es_selected, p_mi );
     var_DelCallback( p_input_thread, "audio-es", input_es_selected, p_mi );
     var_DelCallback( p_input_thread, "spu-es", input_es_selected, p_mi );
+    var_DelCallback( p_input_thread, "spu-es2", input_es_selected, p_mi );
 }
 
 /**************************************************************************
diff --git a/src/input/input_internal.h b/src/input/input_internal.h
index cf27ff3..1706b5e 100644
--- a/src/input/input_internal.h
+++ b/src/input/input_internal.h
@@ -201,6 +201,8 @@ enum input_control_e
 
     INPUT_CONTROL_SET_ES,
     INPUT_CONTROL_RESTART_ES,
+    INPUT_CONTROL_SET_ES2,
+    INPUT_CONTROL_RESTART_ES2,
 
     INPUT_CONTROL_SET_AUDIO_DELAY,
     INPUT_CONTROL_SET_SPU_DELAY,
diff --git a/src/input/var.c b/src/input/var.c
index 47f4b88..1286a9b 100644
--- a/src/input/var.c
+++ b/src/input/var.c
@@ -103,6 +103,7 @@ static const vlc_input_callback_t p_input_callbacks[] =
     CALLBACK( "video-es", ESCallback ),
     CALLBACK( "audio-es", ESCallback ),
     CALLBACK( "spu-es", ESCallback ),
+    CALLBACK( "spu-es2", ESCallback ),
     CALLBACK( "record", RecordCallback ),
     CALLBACK( "frame-next", FrameNextCallback ),
 
@@ -200,6 +201,10 @@ void input_ControlVarInit ( input_thread_t *p_input )
     var_Create( p_input, "spu-es", VLC_VAR_INTEGER | VLC_VAR_HASCHOICE );
     text.psz_string = _("Subtitle Track");
     var_Change( p_input, "spu-es", VLC_VAR_SETTEXT, &text, NULL );
+    /*the 2nd Spu Es the choices are the same*/
+    var_Create( p_input, "spu-es2", VLC_VAR_INTEGER);
+    text.psz_string = _("2nd Subtitle Track");
+    var_Change( p_input, "spu-es2", VLC_VAR_SETTEXT, &text, NULL );
 
     var_Create( p_input, "spu-choice", VLC_VAR_INTEGER );
     var_SetInteger( p_input, "spu-choice", -1 );
@@ -740,7 +745,18 @@ static int ESCallback( vlc_object_t *p_this, char const *psz_cmd,
     input_thread_t *p_input = (input_thread_t*)p_this;
     VLC_UNUSED(oldval); VLC_UNUSED(p_data);
 
-    if( newval.i_int < 0 )
+    int i_type = INPUT_CONTROL_SET_ES;
+    if( !strcmp( psz_cmd, "spu-es2" ))
+    {
+        i_type =  INPUT_CONTROL_SET_ES2;
+        msg_Dbg(p_input, "ESCallback spu-es2 val %d", newval.i_int);
+    }
+    if( !strcmp( psz_cmd, "spu-es" ))
+    {
+        i_type =  INPUT_CONTROL_SET_ES;
+        msg_Dbg(p_input, "ESCallback spu-es val %d", newval.i_int);
+    }
+    if( newval.i_int < 0 )//if set to negative, only cat matters
     {
         vlc_value_t v;
         /* Hack */
@@ -748,16 +764,16 @@ static int ESCallback( vlc_object_t *p_this, char const *psz_cmd,
             v.i_int = -AUDIO_ES;
         else if( !strcmp( psz_cmd, "video-es" ) )
             v.i_int = -VIDEO_ES;
-        else if( !strcmp( psz_cmd, "spu-es" ) )
-            v.i_int = -SPU_ES;
+        else if( !strcmp( psz_cmd, "spu-es" )|| !strcmp(psz_cmd, "spu-es2") )
+            v.i_int = -SPU_ES; //-1 is the id for disable
         else
             v.i_int = 0;
-        if( v.i_int != 0 )
-            input_ControlPush( p_input, INPUT_CONTROL_SET_ES, &v );
+        if( v.i_int != 0 )//push it, so input thread will process it later
+            input_ControlPush( p_input, i_type, &v );
     }
     else
     {
-        input_ControlPush( p_input, INPUT_CONTROL_SET_ES, &newval );
+        input_ControlPush( p_input, i_type, &newval );
     }
 
     return VLC_SUCCESS;
-- 
1.9.1



More information about the vlc-devel mailing list