[vlc-devel] [PATCH] Add INPUT_NAV_MENU

Petri Hintukainen phintuka at gmail.com
Thu May 12 12:56:05 CEST 2016


Currently DVD/BluRay menu call expects the menu to be in title 0.
It also seeks to chapter 2 or 0 (DVD menu type is selected by
selecting chapter). Using dedicated control allows the plugins to
decide how menu call should be handled.

Fixes problems with BluRay:
  - If menu call is not allowed, playback seeks to title start
  - Menu background video start position is ignored
---
 include/vlc_demux.h              |  2 ++
 include/vlc_input.h              |  2 ++
 modules/access/bluray.c          | 10 ++++++++++
 modules/access/dvdnav.c          | 20 ++++++++++++++++++++
 modules/gui/qt/input_manager.cpp | 16 +---------------
 src/input/control.c              |  1 +
 src/input/input.c                |  2 ++
 src/input/input_internal.h       |  1 +
 src/input/var.c                  | 12 ++++++++++++
 9 files changed, 51 insertions(+), 15 deletions(-)

diff --git a/include/vlc_demux.h b/include/vlc_demux.h
index addfa5a..f4baeea 100644
--- a/include/vlc_demux.h
+++ b/include/vlc_demux.h
@@ -278,6 +278,8 @@ enum demux_query_e
     DEMUX_NAV_RIGHT,
     /** Activate the popup Menu (for BD). Can fail */
     DEMUX_NAV_POPUP,
+    /** Activate disc Root Menu. Can fail */
+    DEMUX_NAV_MENU,            /* res=can fail */
 };
 
 /*************************************************************************
diff --git a/include/vlc_input.h b/include/vlc_input.h
index 0bda6d4..083c654 100644
--- a/include/vlc_input.h
+++ b/include/vlc_input.h
@@ -443,6 +443,8 @@ enum input_query_e
     INPUT_NAV_RIGHT,
     /** Activate the popup Menu (for BD). res=can fail */
     INPUT_NAV_POPUP,
+    /** Activate disc Root Menu. res=can fail */
+    INPUT_NAV_MENU,
 
     /* Meta datas */
     INPUT_ADD_INFO,   /* arg1= char* arg2= char* arg3=...     res=can fail */
diff --git a/modules/access/bluray.c b/modules/access/bluray.c
index 44f8fc5..aeb0d65 100644
--- a/modules/access/bluray.c
+++ b/modules/access/bluray.c
@@ -1961,6 +1961,16 @@ static int blurayControl(demux_t *p_demux, int query, va_list args)
         return sendKeyEvent(p_sys, BD_VK_RIGHT);
     case DEMUX_NAV_POPUP:
         return sendKeyEvent(p_sys, BD_VK_POPUP);
+    case DEMUX_NAV_MENU:
+        if (p_sys->b_menu) {
+            if (bd_menu_call(p_sys->bluray, -1) == 1) {
+                p_demux->info.i_update |= INPUT_UPDATE_TITLE | INPUT_UPDATE_SEEKPOINT;
+                return VLC_SUCCESS;
+            }
+            msg_Err(p_demux, "Can't select Top Menu title");
+            return sendKeyEvent(p_sys, BD_VK_POPUP);
+        }
+        return VLC_EGENERIC;
 
     case DEMUX_CAN_RECORD:
     case DEMUX_GET_FPS:
diff --git a/modules/access/dvdnav.c b/modules/access/dvdnav.c
index e1b6ade..9b6d266 100644
--- a/modules/access/dvdnav.c
+++ b/modules/access/dvdnav.c
@@ -736,6 +736,26 @@ static int Control( demux_t *p_demux, int i_query, va_list args )
             break;
         }
 
+        case DEMUX_NAV_MENU:
+        {
+            if( dvdnav_menu_call( p_sys->dvdnav, DVD_MENU_Title )
+                != DVDNAV_STATUS_OK )
+            {
+                msg_Warn( p_demux, "cannot select Title menu" );
+                if( dvdnav_menu_call( p_sys->dvdnav, DVD_MENU_Root )
+                    != DVDNAV_STATUS_OK )
+                {
+                    msg_Warn( p_demux, "cannot select Root menu" );
+                    return VLC_EGENERIC;
+                }
+            }
+            p_demux->info.i_update |=
+                INPUT_UPDATE_TITLE | INPUT_UPDATE_SEEKPOINT;
+            p_demux->info.i_title = 0;
+            p_demux->info.i_seekpoint = 2;
+            break;
+        }
+
         /* TODO implement others */
         default:
             return VLC_EGENERIC;
diff --git a/modules/gui/qt/input_manager.cpp b/modules/gui/qt/input_manager.cpp
index b771002..3b8df79 100644
--- a/modules/gui/qt/input_manager.cpp
+++ b/modules/gui/qt/input_manager.cpp
@@ -827,21 +827,7 @@ void InputManager::sectionMenu()
 {
     if( hasInput() )
     {
-        vlc_value_t val, text;
-
-        if( var_Change( p_input, "title  0", VLC_VAR_GETCHOICES, &val, &text ) < 0 )
-            return;
-
-        /* XXX is it "Root" or "Title" we want here ?" (set 0 by default) */
-        int root = 0;
-        for( int i = 0; i < val.p_list->i_count; i++ )
-        {
-            if( !strcmp( text.p_list->p_values[i].psz_string, "Title" ) )
-                root = i;
-        }
-        var_FreeList( &val, &text );
-
-        var_SetInteger( p_input, "title  0", root );
+        var_TriggerCallback( p_input, "menu-title" );
     }
 }
 
diff --git a/src/input/control.c b/src/input/control.c
index a856737..7a2a5d3 100644
--- a/src/input/control.c
+++ b/src/input/control.c
@@ -142,6 +142,7 @@ int input_vaControl( input_thread_t *p_input, int i_query, va_list args )
         case INPUT_NAV_LEFT:
         case INPUT_NAV_RIGHT:
         case INPUT_NAV_POPUP:
+        case INPUT_NAV_MENU:
             input_ControlPush( p_input, i_query - INPUT_NAV_ACTIVATE
                                + INPUT_CONTROL_NAV_ACTIVATE, NULL );
             return VLC_SUCCESS;
diff --git a/src/input/input.c b/src/input/input.c
index 75e4c11..bea3d51 100644
--- a/src/input/input.c
+++ b/src/input/input.c
@@ -1498,6 +1498,7 @@ static bool ControlIsSeekRequest( int i_type )
     case INPUT_CONTROL_NAV_LEFT:
     case INPUT_CONTROL_NAV_RIGHT:
     case INPUT_CONTROL_NAV_POPUP:
+    case INPUT_CONTROL_NAV_MENU:
         return true;
     default:
         return false;
@@ -1977,6 +1978,7 @@ static bool Control( input_thread_t *p_input,
         case INPUT_CONTROL_NAV_LEFT:
         case INPUT_CONTROL_NAV_RIGHT:
         case INPUT_CONTROL_NAV_POPUP:
+        case INPUT_CONTROL_NAV_MENU:
             demux_Control( p_input->p->master->p_demux, i_type
                            - INPUT_CONTROL_NAV_ACTIVATE + DEMUX_NAV_ACTIVATE );
             break;
diff --git a/src/input/input_internal.h b/src/input/input_internal.h
index b68bec7..18e0bff 100644
--- a/src/input/input_internal.h
+++ b/src/input/input_internal.h
@@ -200,6 +200,7 @@ enum input_control_e
     INPUT_CONTROL_NAV_LEFT,
     INPUT_CONTROL_NAV_RIGHT,
     INPUT_CONTROL_NAV_POPUP,
+    INPUT_CONTROL_NAV_MENU,
 
     INPUT_CONTROL_SET_ES,
     INPUT_CONTROL_RESTART_ES,
diff --git a/src/input/var.c b/src/input/var.c
index 0cc1217..6534603 100644
--- a/src/input/var.c
+++ b/src/input/var.c
@@ -113,6 +113,7 @@ static const vlc_input_callback_t p_input_navigation_callbacks[] =
     CALLBACK( "next-title", TitleCallback ),
     CALLBACK( "prev-title", TitleCallback ),
     CALLBACK( "menu-popup", TitleCallback ),
+    CALLBACK( "menu-title", TitleCallback ),
 
     CALLBACK( NULL, NULL )
 };
@@ -271,6 +272,13 @@ void input_ControlVarNavigation( input_thread_t *p_input )
             var_AddCallback( p_input, "prev-title", TitleCallback, NULL );
         }
 
+        if( var_Type( p_input, "menu-title" ) == 0 ) {
+            var_Create( p_input, "menu-title", VLC_VAR_VOID );
+            text.psz_string = _("Menu title");
+            var_Change( p_input, "menu-title", VLC_VAR_SETTEXT, &text, NULL );
+            var_AddCallback( p_input, "menu-title", TitleCallback, NULL );
+        }
+
         if( var_Type( p_input, "menu-popup" ) == 0 ) {
             var_Create( p_input, "menu-popup", VLC_VAR_VOID );
             text.psz_string = _("Menu popup");
@@ -680,6 +688,10 @@ static int TitleCallback( vlc_object_t *p_this, char const *psz_cmd,
         if( val.i_int >= 0 )
             var_Change( p_input, "title", VLC_VAR_SETVALUE, &val, NULL );
     }
+    else if( !strcmp( psz_cmd, "menu-title" ) )
+    {
+        input_ControlPush( p_input, INPUT_CONTROL_NAV_MENU, NULL );
+    }
     else if( !strcmp( psz_cmd, "menu-popup" ) )
     {
         input_ControlPush( p_input, INPUT_CONTROL_NAV_POPUP, NULL );
-- 
2.7.4



More information about the vlc-devel mailing list