]> git.sesse.net Git - vlc/blobdiff - modules/control/rc.c
Merge back branch 0.8.6-playlist-vlm to trunk.
[vlc] / modules / control / rc.c
index 5d366c58e79cecfc51eea5c18466c2066e890bd8..897b8e24404bcbc46d93a65a0be4e704612efef4 100644 (file)
@@ -52,6 +52,7 @@
 
 #include "vlc_error.h"
 #include "network.h"
+#include "vlc_url.h"
 
 #if defined(AF_UNIX) && !defined(AF_LOCAL)
 #    define AF_LOCAL AF_UNIX
@@ -177,7 +178,7 @@ void __msg_rc( intf_thread_t *p_intf, const char *psz_fmt, ... )
 vlc_module_begin();
     set_shortname( _("RC"));
     set_category( CAT_INTERFACE );
-    set_subcategory( SUBCAT_INTERFACE_GENERAL );
+    set_subcategory( SUBCAT_INTERFACE_MAIN );
     set_description( _("Remote control interface") );
     add_bool( "rc-show-pos", 0, NULL, POS_TEXT, POS_LONGTEXT, VLC_TRUE );
 #ifdef HAVE_ISATTY
@@ -200,7 +201,6 @@ vlc_module_end();
 static int Activate( vlc_object_t *p_this )
 {
     intf_thread_t *p_intf = (intf_thread_t*)p_this;
-    playlist_t *p_playlist;
     char *psz_host, *psz_unix_path;
     int  *pi_socket = NULL;
 
@@ -279,7 +279,7 @@ static int Activate( vlc_object_t *p_this )
 
         vlc_UrlParse( &url, psz_host, 0 );
 
-        msg_Dbg( p_intf, "base %s port %d", url.psz_host, url.i_port );
+        msg_Dbg( p_intf, "base: %s, port: %d", url.psz_host, url.i_port );
 
         pi_socket = net_ListenTCP(p_this, url.psz_host, url.i_port);
         if( pi_socket == NULL )
@@ -320,18 +320,7 @@ static int Activate( vlc_object_t *p_this )
     CONSOLE_INTRO_MSG;
 #endif
 
-    /* Force "no-view" mode */
-    p_playlist = (playlist_t *)vlc_object_find( p_intf, VLC_OBJECT_PLAYLIST,
-                                                 FIND_ANYWHERE );
-    if( p_playlist )
-    {
-        vlc_mutex_lock( &p_playlist->object_lock );
-        p_playlist->status.i_view = -1;
-        vlc_mutex_unlock( &p_playlist->object_lock );
-        vlc_object_release( p_playlist );
-    }
-
-    msg_rc( _("Remote control interface initialized, `h' for help") );
+    msg_rc( _("Remote control interface initialized. Type `help' for help.") );
     return VLC_SUCCESS;
 }
 
@@ -427,6 +416,8 @@ static void RegisterCallbacks( intf_thread_t *p_intf )
     var_AddCallback( p_intf, "mosaic-rows", Other, NULL );
     var_Create( p_intf, "mosaic-cols", VLC_VAR_INTEGER | VLC_VAR_ISCOMMAND );
     var_AddCallback( p_intf, "mosaic-cols", Other, NULL );
+    var_Create( p_intf, "mosaic-order", VLC_VAR_INTEGER | VLC_VAR_ISCOMMAND );
+    var_AddCallback( p_intf, "mosaic-order", Other, NULL );
     var_Create( p_intf, "mosaic-keep-aspect-ratio",
                      VLC_VAR_INTEGER | VLC_VAR_ISCOMMAND );
     var_AddCallback( p_intf, "mosaic-keep-aspect-ratio", Other, NULL );
@@ -540,7 +531,7 @@ static void Run( intf_thread_t *p_intf )
     p_intf->p_sys->hConsoleIn = GetStdHandle(STD_INPUT_HANDLE);
     if( p_intf->p_sys->hConsoleIn == INVALID_HANDLE_VALUE )
     {
-        msg_Err( p_intf, "Couldn't open STD_INPUT_HANDLE" );
+        msg_Err( p_intf, "couldn't find user input handle" );
         p_intf->b_die = VLC_TRUE;
     }
 #endif
@@ -582,7 +573,7 @@ static void Run( intf_thread_t *p_intf )
             {
                 if( !p_input->b_dead || !p_input->b_die )
                 {
-                    msg_rc( STATUS_CHANGE "( New input: %s )", p_input->input.p_item->psz_uri );
+                    msg_rc( STATUS_CHANGE "( new input: %s )", p_input->input.p_item->psz_uri );
                     msg_rc( STATUS_CHANGE "( audio volume: %d )", config_GetInt( p_intf, "volume" ));
                 }
                 var_AddCallback( p_input, "state", StateChanged, p_intf );
@@ -843,7 +834,7 @@ static void Run( intf_thread_t *p_intf )
             break;
 
         default:
-            msg_rc(_("unknown command `%s', type `help' for help"), psz_cmd);
+            msg_rc(_("Unknown command `%s'. Type `help' for help."), psz_cmd);
             break;
         }
 
@@ -903,6 +894,10 @@ static void Help( intf_thread_t *p_intf, vlc_bool_t b_longhelp)
     msg_rc(_("| normal . . . . . . . .  normal playing of stream"));
     msg_rc(_("| f [on|off] . . . . . . . . . . toggle fullscreen"));
     msg_rc(_("| info . . .  information about the current stream"));
+    msg_rc(_("| get_time . . seconds elapsed since stream's beginning"));
+    msg_rc(_("| is_playing . .  1 if a stream plays, 0 otherwise"));
+    msg_rc(_("| get_title . . .  the title of the current stream"));
+    msg_rc(_("| get_length . .  the length of the current stream"));
     msg_rc(  "| ");
     msg_rc(_("| volume [X] . . . . . . . .  set/get audio volume"));
     msg_rc(_("| volup [X]  . . . . .  raise audio volume X steps"));
@@ -931,7 +926,7 @@ static void Help( intf_thread_t *p_intf, vlc_bool_t b_longhelp)
         msg_rc(_("| time-opacity # . . . . . . . . . . . . . opacity"));
         msg_rc(_("| time-size # . . . . . . . . font size, in pixels"));
         msg_rc(  "| ");
-        msg_rc(_("| logo-file STRING . . . the overlay file path/name"));
+        msg_rc(_("| logo-file STRING . . .the overlay file path/name"));
         msg_rc(_("| logo-x X . . . . . . . . . . . .offset from left"));
         msg_rc(_("| logo-y Y . . . . . . . . . . . . offset from top"));
         msg_rc(_("| logo-position #. . . . . . . . relative position"));
@@ -948,6 +943,7 @@ static void Help( intf_thread_t *p_intf, vlc_bool_t b_longhelp)
         msg_rc(_("| mosaic-position {0=auto,1=fixed} . . . .position"));
         msg_rc(_("| mosaic-rows #. . . . . . . . . . .number of rows"));
         msg_rc(_("| mosaic-cols #. . . . . . . . . . .number of cols"));
+        msg_rc(_("| mosaic-order id(,id)* . . . . order of pictures "));
         msg_rc(_("| mosaic-keep-aspect-ratio {0,1} . . .aspect ratio"));
         msg_rc(  "| ");
         msg_rc(_("| check-updates [newer] [equal] [older]\n"
@@ -1066,7 +1062,7 @@ static int Input( vlc_object_t *p_this, char const *psz_cmd,
     if( ( ( val.i_int == PAUSE_S ) || ( val.i_int == PLAYLIST_PAUSED ) ) &&
         ( strcmp( psz_cmd, "pause" ) != 0 ) )
     {
-        msg_rc( _("press menu select or pause to continue") );
+        msg_rc( _("Press menu select or pause to continue.") );
         vlc_object_release( p_input );
         return VLC_EGENERIC;
     }
@@ -1150,7 +1146,7 @@ static int Input( vlc_object_t *p_this, char const *psz_cmd,
                 var_Get( p_input, "chapter", &val );
                 var_Change( p_input, "chapter", VLC_VAR_GETCHOICES,
                             &val_list, NULL );
-                msg_rc( "Currently playing chapter %d/%d",
+                msg_rc( "Currently playing chapter %d/%d.",
                         val.i_int, val_list.p_list->i_count );
                 var_Change( p_this, "chapter", VLC_VAR_FREELIST,
                             &val_list, NULL );
@@ -1189,7 +1185,7 @@ static int Input( vlc_object_t *p_this, char const *psz_cmd,
                 var_Get( p_input, "title", &val );
                 var_Change( p_input, "title", VLC_VAR_GETCHOICES,
                             &val_list, NULL );
-                msg_rc( "Currently playing title %d/%d",
+                msg_rc( "Currently playing title %d/%d.",
                         val.i_int, val_list.p_list->i_count );
                 var_Change( p_this, "title", VLC_VAR_FREELIST,
                             &val_list, NULL );
@@ -1226,6 +1222,7 @@ static int Playlist( vlc_object_t *p_this, char const *psz_cmd,
                                            FIND_ANYWHERE );
     if( !p_playlist )
     {
+        msg_Err( p_this, "no playlist" );
         return VLC_ENOOBJ;
     }
 
@@ -1233,8 +1230,9 @@ static int Playlist( vlc_object_t *p_this, char const *psz_cmd,
     {
         vlc_value_t val;
         var_Get( p_playlist->p_input, "state", &val );
-        if( ( val.i_int == PAUSE_S ) || ( val.i_int == PLAYLIST_PAUSED ) )        {
-            msg_rc( _("press menu select or pause to continue") );
+        if( ( val.i_int == PAUSE_S ) || ( val.i_int == PLAYLIST_PAUSED ) )
+        {
+            msg_rc( _("Type 'menu select' or 'pause' to continue.") );
             vlc_object_release( p_playlist );
             return VLC_EGENERIC;
         }
@@ -1251,29 +1249,12 @@ static int Playlist( vlc_object_t *p_this, char const *psz_cmd,
     }
     else if( !strcmp( psz_cmd, "play" ) )
     {
-        if( p_playlist->p_input )
-        {
-            vlc_value_t val;
-
-            var_Get( p_playlist->p_input, "rate", &val );
-            if( val.i_int != INPUT_RATE_DEFAULT )
-            {
-                val.i_int = INPUT_RATE_DEFAULT;
-                var_Set( p_playlist->p_input, "rate", val );
-            }
-            else
-            {
-                playlist_Play( p_playlist );
-            }
-        }
+        msg_Warn( p_playlist, "play" );
+        playlist_Play( p_playlist );
     }
     else if (!strcmp( psz_cmd, "goto" ) )
     {
-        if( strlen( newval.psz_string ) > 0)
-        {
-            val.i_int = atoi( newval.psz_string );
-            playlist_Goto( p_playlist, val.i_int);
-        }
+        msg_Err( p_playlist, "goto is deprecated" );
     }
     else if( !strcmp( psz_cmd, "stop" ) )
     {
@@ -1293,34 +1274,24 @@ static int Playlist( vlc_object_t *p_this, char const *psz_cmd,
 
         if( p_item )
         {
-            msg_rc( "trying to add %s to playlist", newval.psz_string );
-            playlist_AddItem( p_playlist, p_item,
-                              PLAYLIST_GO|PLAYLIST_APPEND, PLAYLIST_END );
+            msg_rc( "Trying to add %s to playlist.", newval.psz_string );
+//            playlist_AddItem( p_playlist, p_item,
+//                              PLAYLIST_GO|PLAYLIST_APPEND, PLAYLIST_END );
         }
     }
     else if( !strcmp( psz_cmd, "playlist" ) )
     {
         int i;
-
-        for ( i = 0; i < p_playlist->i_size; i++ )
-        {
-            msg_rc( "|%s%s   %s|%s|", i == p_playlist->i_index ? "*" : " ",
-                    p_playlist->pp_items[i]->input.psz_name,
-                    p_playlist->pp_items[i]->input.psz_uri,
-                    p_playlist->pp_items[i]->i_parents > 0 ?
-                    p_playlist->pp_items[i]->pp_parents[0]->p_parent->input.psz_name : "" );
-        }
-        if ( i == 0 )
-        {
-            msg_rc( "| no entries" );
-        }
+        playlist_view_t *p_view;
+        playlist_NodeDump( p_playlist, p_playlist->p_root_category, 0 );
+        playlist_NodeDump( p_playlist, p_playlist->p_root_onelevel, 0 );
     }
     else if( !strcmp( psz_cmd, "status" ) )
     {
         if( p_playlist->p_input )
         {
             /* Replay the current state of the system. */
-            msg_rc( STATUS_CHANGE "( New input: %s )", p_playlist->p_input->input.p_item->psz_uri );
+            msg_rc( STATUS_CHANGE "( new input: %s )", p_playlist->p_input->input.p_item->psz_uri );
             msg_rc( STATUS_CHANGE "( audio volume: %d )", config_GetInt( p_intf, "volume" ));
 
             vlc_mutex_lock( &p_playlist->object_lock );
@@ -1381,7 +1352,7 @@ static int Other( vlc_object_t *p_this, char const *psz_cmd,
         var_Get( p_input, "state", &val );
         if( ( val.i_int == PAUSE_S ) || ( val.i_int == PLAYLIST_PAUSED ) )
         {
-            msg_rc( _("press pause to continue") );
+            msg_rc( _("Type 'pause' to continue.") );
             vlc_object_release( p_playlist );
             vlc_object_release( p_input );
             return VLC_EGENERIC;
@@ -1546,6 +1517,14 @@ static int Other( vlc_object_t *p_this, char const *psz_cmd,
             var_Set( p_input->p_libvlc, "mosaic-cols", val );
         }
     }
+    else if( !strcmp( psz_cmd, "mosaic-order" ) )
+    {
+        if( strlen( newval.psz_string ) > 0)
+        {
+            val.psz_string = newval.psz_string;
+            var_Set( p_input->p_libvlc, "mosaic-order", val );
+        }
+    }
     else if( !strcmp( psz_cmd, "mosaic-keep-aspect-ratio" ) )
     {
         if( strlen( newval.psz_string ) > 0)
@@ -1661,7 +1640,7 @@ static int Other( vlc_object_t *p_this, char const *psz_cmd,
      */
     else
     {
-        msg_rc( "unknown command!" );
+        msg_rc( "Unknown command!" );
     }
 
     vlc_object_release( p_playlist );
@@ -1721,7 +1700,7 @@ static int Volume( vlc_object_t *p_this, char const *psz_cmd,
         var_Get( p_input, "state", &val );
         if( ( val.i_int == PAUSE_S ) || ( val.i_int == PLAYLIST_PAUSED ) )
         {
-            msg_rc( _("press menu select or pause to continue") );
+            msg_rc( _("Type 'menu select' or 'pause' to continue.") );
             vlc_object_release( p_input );
             return VLC_EGENERIC;
         }
@@ -1734,7 +1713,7 @@ static int Volume( vlc_object_t *p_this, char const *psz_cmd,
         audio_volume_t i_volume = atoi( newval.psz_string );
         if ( (i_volume > (audio_volume_t)AOUT_VOLUME_MAX) )
         {
-            msg_rc( "Volume must be in the range %d-%d", AOUT_VOLUME_MIN,
+            msg_rc( "Volume must be in the range %d-%d.", AOUT_VOLUME_MIN,
                     AOUT_VOLUME_MAX );
             i_error = VLC_EBADVAR;
         }
@@ -1791,7 +1770,7 @@ static int VolumeMove( vlc_object_t *p_this, char const *psz_cmd,
         var_Get( p_input, "state", &val );
         if( ( val.i_int == PAUSE_S ) || ( val.i_int == PLAYLIST_PAUSED ) )
         {
-            msg_rc( _("press menu select or pause to continue") );
+            msg_rc( _("Type 'menu select' or 'pause' to continue.") );
             vlc_object_release( p_input );
             return VLC_EGENERIC;
         }
@@ -1840,7 +1819,7 @@ static int AudioConfig( vlc_object_t *p_this, char const *psz_cmd,
 
         var_Get( p_input, "state", &val );
         if( ( val.i_int == PAUSE_S ) || ( val.i_int == PLAYLIST_PAUSED ) )        {
-            msg_rc( _("press menu select or pause to continue") );
+            msg_rc( _("Type 'menu select' or 'pause' to continue.") );
             vlc_object_release( p_input );
             return VLC_EGENERIC;
         }
@@ -1924,7 +1903,7 @@ static int Menu( vlc_object_t *p_this, char const *psz_cmd,
 
     if ( !*newval.psz_string )
     {
-        msg_rc( _("please provide one of the following paramaters") );
+        msg_rc( _("Please provide one of the following parameters:") );
         msg_rc( "[on|off|up|down|left|right|select]" );
         return i_error;
     }
@@ -1939,7 +1918,7 @@ static int Menu( vlc_object_t *p_this, char const *psz_cmd,
         if( ( ( val.i_int == PAUSE_S ) || ( val.i_int == PLAYLIST_PAUSED ) ) &&
             ( strcmp( newval.psz_string, "select" ) != 0 ) )
         {
-            msg_rc( _("press menu select or pause to continue") );
+            msg_rc( _("Type 'menu select' or 'pause' to continue.") );
             vlc_object_release( p_playlist );
             return VLC_EGENERIC;
         }
@@ -1963,7 +1942,7 @@ static int Menu( vlc_object_t *p_this, char const *psz_cmd,
         osd_MenuActivate( p_this );
     else
     {
-        msg_rc( _("please provide one of the following paramaters") );
+        msg_rc( _("Please provide one of the following parameters:") );
         msg_rc( "[on|off|up|down|left|right|select]" );
         if( val.psz_string ) free( val.psz_string );
             return i_error;