# include "config.h"
#endif
-#include <vlc_common.h>
-#include <vlc_plugin.h>
-
#include <errno.h> /* ENOMEM */
#include <signal.h>
#include <assert.h>
#include <math.h>
+#define VLC_MODULE_LICENSE VLC_LICENSE_GPL_2_PLUS
+#include <vlc_common.h>
+#include <vlc_plugin.h>
#include <vlc_interface.h>
+#include <vlc_input.h>
#include <vlc_aout.h>
#include <vlc_vout.h>
#include <vlc_playlist.h>
#include <vlc_keys.h>
-#ifdef HAVE_UNISTD_H
-# include <unistd.h>
-#endif
#include <sys/types.h>
+#include <unistd.h>
+
#include <vlc_network.h>
#include <vlc_url.h>
-
#include <vlc_charset.h>
#if defined(PF_UNIX) && !defined(PF_LOCAL)
# define PF_LOCAL PF_UNIX
#endif
-#if defined(AF_LOCAL) && ! defined(WIN32)
+#if defined(AF_LOCAL) && ! defined(_WIN32)
# include <sys/un.h>
#endif
input_thread_t *p_input;
bool b_input_buffering;
-#ifdef WIN32
+#ifdef _WIN32
HANDLE hConsoleIn;
bool b_quiet;
#endif
#define HOST_LONGTEXT N_("Accept commands over a socket rather than stdin. " \
"You can set the address and port the interface will bind to." )
-#ifdef WIN32
+#ifdef _WIN32
#define QUIET_TEXT N_("Do not open a DOS command box interface")
#define QUIET_LONGTEXT N_( \
"By default the rc interface plugin will start a DOS command box. " \
"Enabling the quiet mode will not bring this command box but can also " \
"be pretty annoying when you want to stop VLC and no video window is " \
"open." )
+#include "intromsg.h"
#endif
vlc_module_begin ()
set_description( N_("Remote control interface") )
add_bool( "rc-show-pos", false, POS_TEXT, POS_LONGTEXT, true )
-#ifdef WIN32
+#ifdef _WIN32
add_bool( "rc-quiet", false, QUIET_TEXT, QUIET_LONGTEXT, false )
#else
#if defined (HAVE_ISATTY)
set_capability( "interface", 20 )
set_callbacks( Activate, Deactivate )
-#ifdef WIN32
+#ifdef _WIN32
add_shortcut( "rc" )
#endif
vlc_module_end ()
char *psz_host, *psz_unix_path = NULL;
int *pi_socket = NULL;
-#ifndef WIN32
+#ifndef _WIN32
#if defined(HAVE_ISATTY)
/* Check that stdin is a TTY */
if( !var_InheritBool( p_intf, "rc-fake-tty" ) && !isatty( 0 ) )
if( (i_socket = vlc_socket( PF_LOCAL, SOCK_STREAM, 0, false ) ) < 0 )
{
- msg_Warn( p_intf, "can't open socket: %m" );
+ msg_Warn( p_intf, "can't open socket: %s", vlc_strerror_c(errno) );
free( psz_unix_path );
return VLC_EGENERIC;
}
if (bind (i_socket, (struct sockaddr *)&addr, sizeof (addr)))
{
- msg_Err (p_intf, "cannot bind UNIX socket at %s: %m",
- psz_unix_path);
+ msg_Err (p_intf, "cannot bind UNIX socket at %s: %s",
+ psz_unix_path, vlc_strerror_c(errno));
free (psz_unix_path);
net_Close (i_socket);
return VLC_EGENERIC;
if( listen( i_socket, 1 ) )
{
- msg_Warn( p_intf, "can't listen on socket: %m");
+ msg_Warn (p_intf, "can't listen on socket: %s",
+ vlc_strerror_c(errno));
free( psz_unix_path );
net_Close( i_socket );
return VLC_EGENERIC;
pi_socket[1] = -1;
#endif /* AF_LOCAL */
}
-#endif /* !WIN32 */
+#endif /* !_WIN32 */
if( ( pi_socket == NULL ) &&
( psz_host = var_InheritString( p_intf, "rc-host" ) ) != NULL )
intf_sys_t *p_sys = malloc( sizeof( *p_sys ) );
if( unlikely(p_sys == NULL) )
+ {
+ net_ListenClose( pi_socket );
+ free( psz_unix_path );
return VLC_ENOMEM;
+ }
p_intf->p_sys = p_sys;
p_sys->pi_socket_listen = pi_socket;
/* Non-buffered stdout */
setvbuf( stdout, (char *)NULL, _IOLBF, 0 );
-#ifdef WIN32
+#ifdef _WIN32
p_sys->b_quiet = var_InheritBool( p_intf, "rc-quiet" );
+# if !VLC_WINSTORE_APP
if( !p_sys->b_quiet )
+ intf_consoleIntroMsg( p_intf );
+# endif
#endif
- {
- CONSOLE_INTRO_MSG;
- }
if( vlc_clone( &p_sys->thread, Run, p_intf, VLC_THREAD_PRIORITY_LOW ) )
abort();
net_Close( p_sys->i_socket );
if( p_sys->psz_unix_path != NULL )
{
-#if defined(AF_LOCAL) && !defined(WIN32)
+#if defined(AF_LOCAL) && !defined(_WIN32)
unlink( p_sys->psz_unix_path );
#endif
free( p_sys->psz_unix_path );
p_buffer[0] = 0;
-#ifdef WIN32
+#ifdef _WIN32
/* Get the file descriptor of the console input */
p_intf->p_sys->hConsoleIn = GetStdHandle(STD_INPUT_HANDLE);
if( p_intf->p_sys->hConsoleIn == INVALID_HANDLE_VALUE )
{
msg_Err( p_intf, "couldn't find user input handle" );
- return;
+ return NULL;
}
#endif
else
fs = var_ToggleBool( p_sys->p_playlist, "fullscreen" );
- if( p_sys->p_input == NULL )
+ if( p_sys->p_input != NULL )
{
vout_thread_t *p_vout = input_GetVout( p_sys->p_input );
if( p_vout )
msg_rc("%s", _("| snapshot . . . . . . . . . . . . take video snapshot"));
msg_rc("%s", _("| strack [X] . . . . . . . . . set/get subtitle track"));
msg_rc("%s", _("| key [hotkey name] . . . . . . simulate hotkey press"));
- msg_rc("%s", _("| menu . . [on|off|up|down|left|right|select] use menu"));
msg_rc( "| ");
msg_rc("%s", _("| help . . . . . . . . . . . . . . . this help message"));
msg_rc("%s", _("| logout . . . . . . . exit (if in socket connection)"));
if( ( state == PAUSE_S ) &&
( strcmp( psz_cmd, "pause" ) != 0 ) && (strcmp( psz_cmd,"frame") != 0 ) )
{
- msg_rc( "%s", _("Press menu select or pause to continue.") );
+ msg_rc( "%s", _("Press pause to continue.") );
}
else
/* Parse commands that only require an input */
if( !strcmp( psz_cmd, "pause" ) )
{
- playlist_Pause( p_intf->p_sys->p_playlist );
+ playlist_TogglePause( p_intf->p_sys->p_playlist );
i_error = VLC_SUCCESS;
}
else if( !strcmp( psz_cmd, "seek" ) )
i_value = val.i_int;
if ( var_Change( p_input, psz_variable,
- VLC_VAR_GETLIST, &val, &text ) < 0 )
+ VLC_VAR_GETCHOICES, &val, &text ) < 0 )
goto out;
msg_rc( "+----[ %s ]", val_name.psz_string );
if( state == PAUSE_S )
{
- msg_rc( "%s", _("Type 'menu select' or 'pause' to continue.") );
+ msg_rc( "%s", _("Type 'pause' to continue.") );
return VLC_EGENERIC;
}
}
static int Intf( vlc_object_t *p_this, char const *psz_cmd,
vlc_value_t oldval, vlc_value_t newval, void *p_data )
{
- VLC_UNUSED(psz_cmd); VLC_UNUSED(oldval); VLC_UNUSED(p_data);
+ intf_thread_t *intf = (intf_thread_t *)p_this;
- return intf_Create( p_this->p_libvlc, newval.psz_string );
+ VLC_UNUSED(psz_cmd); VLC_UNUSED(oldval); VLC_UNUSED(p_data);
+ return intf_Create(pl_Get(intf), newval.psz_string );
}
static int Volume( vlc_object_t *p_this, char const *psz_cmd,
vlc_object_release( p_input );
if( state == PAUSE_S )
{
- msg_rc( "%s", _("Type 'menu select' or 'pause' to continue.") );
+ msg_rc( "%s", _("Type 'pause' to continue.") );
return VLC_EGENERIC;
}
}
vlc_object_release( p_input );
if( state == PAUSE_S )
{
- msg_rc( "%s", _("Type 'menu select' or 'pause' to continue.") );
+ msg_rc( "%s", _("Type 'pause' to continue.") );
return VLC_EGENERIC;
}
}
else
/* This case can't happen */
- assert( 0 );
+ vlc_assert_unreachable();
if( newval.psz_string && *newval.psz_string )
{
}
if ( var_Change( p_vout, psz_variable,
- VLC_VAR_GETLIST, &val, &text ) < 0 )
+ VLC_VAR_GETCHOICES, &val, &text ) < 0 )
{
vlc_object_release( p_vout );
free( psz_value );
/* Retrieve all registered ***. */
vlc_value_t val, text;
if ( var_Change( p_aout, "stereo-mode",
- VLC_VAR_GETLIST, &val, &text ) < 0 )
+ VLC_VAR_GETCHOICES, &val, &text ) < 0 )
{
ret = VLC_ENOVAR;
goto out;
return VLC_SUCCESS;
}
-#ifdef WIN32
+#ifdef _WIN32
static bool ReadWin32( intf_thread_t *p_intf, char *p_buffer, int *pi_size )
{
INPUT_RECORD input_record;
DWORD i_dw;
/* On Win32, select() only works on socket descriptors */
- while( WaitForSingleObject( p_intf->p_sys->hConsoleIn,
- INTF_IDLE_SLEEP/1000 ) == WAIT_OBJECT_0 )
+ while( WaitForSingleObjectEx( p_intf->p_sys->hConsoleIn,
+ INTF_IDLE_SLEEP/1000, TRUE ) == WAIT_OBJECT_0 )
{
while( *pi_size < MAX_LINE_LENGTH &&
ReadConsoleInput( p_intf->p_sys->hConsoleIn, &input_record,
}
}
+ vlc_testcancel ();
+
return false;
}
#endif
{
int i_read = 0;
-#ifdef WIN32
+#ifdef _WIN32
if( p_intf->p_sys->i_socket == -1 && !p_intf->p_sys->b_quiet )
return ReadWin32( p_intf, p_buffer, pi_size );
else if( p_intf->p_sys->i_socket == -1 )