📄 rc.c
字号:
} else if( !strcmp( psz_cmd, "time-size" ) ) { if( strlen( newval.psz_string ) > 0) { val.i_int = atoi( newval.psz_string ); var_Set( p_inp->p_libvlc, "time-size", val ); } } else if( !strcmp( psz_cmd, "logo-file" ) ) { if( strlen( newval.psz_string ) > 0 ) { val.psz_string = newval.psz_string; var_Set( p_inp->p_libvlc, "logo-file", val ); } } else if( !strcmp( psz_cmd, "logo-x" ) ) { if( strlen( newval.psz_string ) > 0) { val.i_int = atoi( newval.psz_string ); var_Set( p_inp->p_libvlc, "logo-x", val ); } } else if( !strcmp( psz_cmd, "logo-y" ) ) { if( strlen( newval.psz_string ) > 0) { val.i_int = atoi( newval.psz_string ); var_Set( p_inp->p_libvlc, "logo-y", val ); } } else if( !strcmp( psz_cmd, "logo-position" ) ) { if( strlen( newval.psz_string ) > 0) { val.i_int = atoi( newval.psz_string ); var_Set( p_inp->p_libvlc, "logo-position", val ); } } else if( !strcmp( psz_cmd, "logo-transparency" ) ) { if( strlen( newval.psz_string ) > 0) { val.i_int = strtol( newval.psz_string, NULL, 0 ); var_Set( p_inp->p_libvlc, "logo-transparency", val ); } } /* * sanity check */ else { msg_rc( "unknown command!\n" ); } vlc_object_release( p_pl ); vlc_object_release( p_inp ); return VLC_SUCCESS;}static int Quit( vlc_object_t *p_this, char const *psz_cmd, vlc_value_t oldval, vlc_value_t newval, void *p_data ){ p_this->p_vlc->b_die = VLC_TRUE; return VLC_SUCCESS;}static int Intf( vlc_object_t *p_this, char const *psz_cmd, vlc_value_t oldval, vlc_value_t newval, void *p_data ){ intf_thread_t *p_newintf; p_newintf = intf_Create( p_this->p_vlc, newval.psz_string ); if( p_newintf ) { p_newintf->b_block = VLC_FALSE; if( intf_RunThread( p_newintf ) ) { vlc_object_detach( p_newintf ); intf_Destroy( p_newintf ); } } return VLC_SUCCESS;}static int Volume( vlc_object_t *p_this, char const *psz_cmd, vlc_value_t oldval, vlc_value_t newval, void *p_data ){ intf_thread_t *p_intf = (intf_thread_t*)p_this; int i_error; if ( *newval.psz_string ) { /* Set. */ audio_volume_t i_volume = atoi( newval.psz_string ); if ( i_volume > AOUT_VOLUME_MAX ) { msg_rc( "Volume must be in the range %d-%d\n", AOUT_VOLUME_MIN, AOUT_VOLUME_MAX ); i_error = VLC_EBADVAR; } else i_error = aout_VolumeSet( p_this, i_volume ); } else { /* Get. */ audio_volume_t i_volume; if ( aout_VolumeGet( p_this, &i_volume ) < 0 ) { i_error = VLC_EGENERIC; } else { msg_rc( "Volume is %d\n", i_volume ); i_error = VLC_SUCCESS; } } return i_error;}static int VolumeMove( vlc_object_t *p_this, char const *psz_cmd, vlc_value_t oldval, vlc_value_t newval, void *p_data ){ intf_thread_t *p_intf = (intf_thread_t*)p_this; audio_volume_t i_volume; int i_nb_steps = atoi(newval.psz_string); int i_error = VLC_SUCCESS; if ( i_nb_steps <= 0 || i_nb_steps > (AOUT_VOLUME_MAX/AOUT_VOLUME_STEP) ) { i_nb_steps = 1; } if ( !strcmp(psz_cmd, "volup") ) { if ( aout_VolumeUp( p_this, i_nb_steps, &i_volume ) < 0 ) i_error = VLC_EGENERIC; } else { if ( aout_VolumeDown( p_this, i_nb_steps, &i_volume ) < 0 ) i_error = VLC_EGENERIC; } if ( !i_error ) msg_rc( "Volume is %d\n", i_volume ); return i_error;}static int AudioConfig( vlc_object_t *p_this, char const *psz_cmd, vlc_value_t oldval, vlc_value_t newval, void *p_data ){ intf_thread_t *p_intf = (intf_thread_t*)p_this; aout_instance_t * p_aout; const char * psz_variable; vlc_value_t val_name; int i_error; p_aout = vlc_object_find( p_this, VLC_OBJECT_AOUT, FIND_ANYWHERE ); if ( p_aout == NULL ) return VLC_ENOOBJ; if ( !strcmp( psz_cmd, "adev" ) ) { psz_variable = "audio-device"; } else { psz_variable = "audio-channels"; } /* Get the descriptive name of the variable */ var_Change( (vlc_object_t *)p_aout, psz_variable, VLC_VAR_GETTEXT, &val_name, NULL ); if( !val_name.psz_string ) val_name.psz_string = strdup(psz_variable); if ( !*newval.psz_string ) { /* Retrieve all registered ***. */ vlc_value_t val, text; int i, i_value; if ( var_Get( (vlc_object_t *)p_aout, psz_variable, &val ) < 0 ) { vlc_object_release( (vlc_object_t *)p_aout ); return VLC_EGENERIC; } i_value = val.i_int; if ( var_Change( (vlc_object_t *)p_aout, psz_variable, VLC_VAR_GETLIST, &val, &text ) < 0 ) { vlc_object_release( (vlc_object_t *)p_aout ); return VLC_EGENERIC; } msg_rc( "+----[ %s ]\n", val_name.psz_string ); for ( i = 0; i < val.p_list->i_count; i++ ) { if ( i_value == val.p_list->p_values[i].i_int ) msg_rc( "| %i - %s *\n", val.p_list->p_values[i].i_int, text.p_list->p_values[i].psz_string ); else msg_rc( "| %i - %s\n", val.p_list->p_values[i].i_int, text.p_list->p_values[i].psz_string ); } var_Change( (vlc_object_t *)p_aout, psz_variable, VLC_VAR_FREELIST, &val, &text ); msg_rc( "+----[ end of %s ]\n", val_name.psz_string ); if( val_name.psz_string ) free( val_name.psz_string ); i_error = VLC_SUCCESS; } else { vlc_value_t val; val.i_int = atoi( newval.psz_string ); i_error = var_Set( (vlc_object_t *)p_aout, psz_variable, val ); } vlc_object_release( (vlc_object_t *)p_aout ); return i_error;}#ifdef WIN32vlc_bool_t 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( !p_intf->b_die && *pi_size < MAX_LINE_LENGTH && ReadConsoleInput( p_intf->p_sys->hConsoleIn, &input_record, 1, &i_dw ) ) { if( input_record.EventType != KEY_EVENT || !input_record.Event.KeyEvent.bKeyDown || input_record.Event.KeyEvent.wVirtualKeyCode == VK_SHIFT || input_record.Event.KeyEvent.wVirtualKeyCode == VK_CONTROL|| input_record.Event.KeyEvent.wVirtualKeyCode == VK_MENU || input_record.Event.KeyEvent.wVirtualKeyCode == VK_CAPITAL ) { /* nothing interesting */ continue; } p_buffer[ *pi_size ] = input_record.Event.KeyEvent.uChar.AsciiChar; /* Echo out the command */ putc( p_buffer[ *pi_size ], stdout ); /* Handle special keys */ if( p_buffer[ *pi_size ] == '\r' || p_buffer[ *pi_size ] == '\n' ) { putc( '\n', stdout ); break; } switch( p_buffer[ *pi_size ] ) { case '\b': if( *pi_size ) { *pi_size -= 2; putc( ' ', stdout ); putc( '\b', stdout ); } break; case '\r': (*pi_size) --; break; } (*pi_size)++; } if( *pi_size == MAX_LINE_LENGTH || p_buffer[ *pi_size ] == '\r' || p_buffer[ *pi_size ] == '\n' ) { p_buffer[ *pi_size ] = 0; return VLC_TRUE; } } return VLC_FALSE;}#endifvlc_bool_t ReadCommand( intf_thread_t *p_intf, char *p_buffer, int *pi_size ){ int i_read = 0;#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 ) { msleep( INTF_IDLE_SLEEP ); return VLC_FALSE; }#endif while( !p_intf->b_die && *pi_size < MAX_LINE_LENGTH && (i_read = net_ReadNonBlock( p_intf, p_intf->p_sys->i_socket == -1 ? 0 /*STDIN_FILENO*/ : p_intf->p_sys->i_socket, NULL, p_buffer + *pi_size, 1, INTF_IDLE_SLEEP ) ) > 0 ) { if( p_buffer[ *pi_size ] == '\r' || p_buffer[ *pi_size ] == '\n' ) break; (*pi_size)++; } /* Connection closed */ if( i_read == -1 ) { p_intf->p_sys->i_socket = -1; p_buffer[ *pi_size ] = 0; return VLC_TRUE; } if( *pi_size == MAX_LINE_LENGTH || p_buffer[ *pi_size ] == '\r' || p_buffer[ *pi_size ] == '\n' ) { p_buffer[ *pi_size ] = 0; return VLC_TRUE; } return VLC_FALSE;}/***************************************************************************** * parse_MRL: build a playlist item from a full mrl ***************************************************************************** * MRL format: "simplified-mrl [:option-name[=option-value]]" * We don't check for '"' or '\'', we just assume that a ':' that follows a * space is a new option. Should be good enough for our purpose. *****************************************************************************/static playlist_item_t *parse_MRL( intf_thread_t *p_intf, char *psz_mrl ){#define SKIPSPACE( p ) { while( *p && ( *p == ' ' || *p == '\t' ) ) p++; }#define SKIPTRAILINGSPACE( p, d ) \ { char *e=d; while( e > p && (*(e-1)==' ' || *(e-1)=='\t') ){e--;*e=0;} } playlist_item_t *p_item = NULL; char *psz_item = NULL, *psz_item_mrl = NULL, *psz_orig; char **ppsz_options = NULL; int i, i_options = 0; if( !psz_mrl ) return 0; psz_mrl = psz_orig = strdup( psz_mrl ); while( *psz_mrl ) { SKIPSPACE( psz_mrl ); psz_item = psz_mrl; for( ; *psz_mrl; psz_mrl++ ) { if( (*psz_mrl == ' ' || *psz_mrl == '\t') && psz_mrl[1] == ':' ) { /* We have a complete item */ break; } if( (*psz_mrl == ' ' || *psz_mrl == '\t') && (psz_mrl[1] == '"' || psz_mrl[1] == '\'') && psz_mrl[2] == ':') { /* We have a complete item */ break; } } if( *psz_mrl ) { *psz_mrl = 0; psz_mrl++; } SKIPTRAILINGSPACE( psz_item, psz_item + strlen( psz_item ) ); /* Remove '"' and '\'' if necessary */ if( *psz_item == '"' && psz_item[strlen(psz_item)-1] == '"' ) { psz_item++; psz_item[strlen(psz_item)-1] = 0; } if( *psz_item == '\'' && psz_item[strlen(psz_item)-1] == '\'' ) { psz_item++; psz_item[strlen(psz_item)-1] = 0; } if( !psz_item_mrl ) psz_item_mrl = psz_item; else if( *psz_item ) { i_options++; ppsz_options = realloc( ppsz_options, i_options * sizeof(char *) ); ppsz_options[i_options - 1] = &psz_item[1]; } if( *psz_mrl ) SKIPSPACE( psz_mrl ); } /* Now create a playlist item */ if( psz_item_mrl ) { p_item = playlist_ItemNew( p_intf, psz_item_mrl, psz_item_mrl ); for( i = 0; i < i_options; i++ ) { playlist_ItemAddOption( p_item, ppsz_options[i] ); } } if( i_options ) free( ppsz_options ); free( psz_orig ); return p_item;}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -