📄 rc.c
字号:
printf( "no input\n" ); } } else switch( psz_cmd[0] ) { case 'f': case 'F': if( p_input ) { vout_thread_t *p_vout; p_vout = vlc_object_find( p_input, VLC_OBJECT_VOUT, FIND_CHILD ); if( p_vout ) { p_vout->i_changes |= VOUT_FULLSCREEN_CHANGE; vlc_object_release( p_vout ); } } break; case 's': case 'S': ; break; case '?': case 'h': case 'H': printf("+----[ Remote control commands ]\n"); printf("| \n"); printf("| add XYZ . . . . . . . . . . add XYZ to playlist\n"); printf("| playlist . . . show items currently in playlist\n"); printf("| play . . . . . . . . . . . . . . . . play stream\n"); printf("| stop . . . . . . . . . . . . . . . . stop stream\n"); printf("| next . . . . . . . . . . . . next playlist item\n"); printf("| prev . . . . . . . . . . previous playlist item\n"); printf("| title [X] . . . . set/get title in current item\n"); printf("| title_n . . . . . . next title in current item\n"); printf("| title_p . . . . previous title in current item\n"); printf("| chapter [X] . . set/get chapter in current item\n"); printf("| chapter_n . . . . next chapter in current item\n"); printf("| chapter_p . . previous chapter in current item\n"); printf("| \n"); printf("| seek X . seek in seconds, for instance `seek 12'\n"); printf("| pause . . . . . . . . . . . . . . toggle pause\n"); printf("| f . . . . . . . . . . . . . . toggle fullscreen\n"); printf("| info . . . information about the current stream\n"); printf("| \n"); printf("| volume [X] . . . . . . . . set/get audio volume\n"); printf("| volup [X] . . . . . raise audio volume X steps\n"); printf("| voldown [X] . . . . lower audio volume X steps\n"); printf("| adev [X] . . . . . . . . . set/get audio device\n"); printf("| achan [X]. . . . . . . . set/get audio channels\n"); printf("| \n"); printf("| help . . . . . . . . . . . . . this help message\n"); printf("| quit . . . . . . . . . . . . . . . . . quit vlc\n"); printf("| \n"); printf("+----[ end of help ]\n"); break; case '\0': /* Ignore empty lines */ break; default: printf( "unknown command `%s', type `help' for help\n", psz_cmd ); break; } } } if( p_input ) { vlc_object_release( p_input ); p_input = NULL; } if( p_playlist ) { vlc_object_release( p_playlist ); p_playlist = NULL; }}static int Input( vlc_object_t *p_this, char const *psz_cmd, vlc_value_t oldval, vlc_value_t newval, void *p_data ){ input_thread_t * p_input; vlc_value_t val; p_input = vlc_object_find( p_this, VLC_OBJECT_INPUT, FIND_ANYWHERE ); if( !p_input ) { return VLC_ENOOBJ; } /* Parse commands that only require an input */ if( !strcmp( psz_cmd, "pause" ) ) { val.i_int = PAUSE_S; var_Set( p_input, "state", val ); vlc_object_release( p_input ); return VLC_SUCCESS; } else if( !strcmp( psz_cmd, "seek" ) ) { if( strlen( newval.psz_string ) > 0 && newval.psz_string[strlen( newval.psz_string ) - 1] == '%' ) { val.f_float = (float)atoi( newval.psz_string ) / 100.0; var_Set( p_input, "position", val ); } else { val.i_time = ((int64_t)atoi( newval.psz_string )) * 1000000; var_Set( p_input, "time", val ); } vlc_object_release( p_input ); return VLC_SUCCESS; } else if( !strcmp( psz_cmd, "chapter" ) || !strcmp( psz_cmd, "chapter_n" ) || !strcmp( psz_cmd, "chapter_p" ) ) { if( !strcmp( psz_cmd, "chapter" ) ) { if ( *newval.psz_string ) { /* Set. */ val.i_int = atoi( newval.psz_string ); var_Set( p_input, "chapter", val ); } else { vlc_value_t val_list; /* Get. */ var_Get( p_input, "chapter", &val ); var_Change( p_input, "chapter", VLC_VAR_GETCHOICES, &val_list, NULL ); printf( "Currently playing chapter %d/%d\n", val.i_int, val_list.p_list->i_count ); var_Change( p_this, "chapter", VLC_VAR_FREELIST, &val_list, NULL ); } } else if( !strcmp( psz_cmd, "chapter_n" ) ) { val.b_bool = VLC_TRUE; var_Set( p_input, "next-chapter", val ); } else if( !strcmp( psz_cmd, "chapter_p" ) ) { val.b_bool = VLC_TRUE; var_Set( p_input, "prev-chapter", val ); } vlc_object_release( p_input ); return VLC_SUCCESS; } else if( !strcmp( psz_cmd, "title" ) || !strcmp( psz_cmd, "title_n" ) || !strcmp( psz_cmd, "title_p" ) ) { if( !strcmp( psz_cmd, "title" ) ) { if ( *newval.psz_string ) { /* Set. */ val.i_int = atoi( newval.psz_string ); var_Set( p_input, "title", val ); } else { vlc_value_t val_list; /* Get. */ var_Get( p_input, "title", &val ); var_Change( p_input, "title", VLC_VAR_GETCHOICES, &val_list, NULL ); printf( "Currently playing title %d/%d\n", val.i_int, val_list.p_list->i_count ); var_Change( p_this, "title", VLC_VAR_FREELIST, &val_list, NULL ); } } else if( !strcmp( psz_cmd, "title_n" ) ) { val.b_bool = VLC_TRUE; var_Set( p_input, "next-title", val ); } else if( !strcmp( psz_cmd, "title_p" ) ) { val.b_bool = VLC_TRUE; var_Set( p_input, "prev-title", val ); } vlc_object_release( p_input ); return VLC_SUCCESS; } /* Never reached. */ return VLC_EGENERIC;}static int Playlist( vlc_object_t *p_this, char const *psz_cmd, vlc_value_t oldval, vlc_value_t newval, void *p_data ){ playlist_t * p_playlist; p_playlist = vlc_object_find( p_this, VLC_OBJECT_PLAYLIST, FIND_ANYWHERE ); if( !p_playlist ) { return VLC_ENOOBJ; } /* Parse commands that require a playlist */ if( !strcmp( psz_cmd, "prev" ) ) { playlist_Prev( p_playlist ); } else if( !strcmp( psz_cmd, "next" ) ) { playlist_Next( p_playlist ); } else if( !strcmp( psz_cmd, "play" ) ) { playlist_Play( p_playlist ); } else if( !strcmp( psz_cmd, "stop" ) ) { playlist_Stop( p_playlist ); } else if( !strcmp( psz_cmd, "add" ) ) { printf( "trying to add %s to playlist\n", newval.psz_string ); playlist_Add( p_playlist, newval.psz_string, newval.psz_string, PLAYLIST_GO|PLAYLIST_APPEND, PLAYLIST_END ); } else if( !strcmp( psz_cmd, "playlist" ) ) { int i; for ( i = 0; i < p_playlist->i_size; i++ ) { printf( "|%s%s %s|\n", i == p_playlist->i_index?"*":" ", p_playlist->pp_items[i]->psz_name, p_playlist->pp_items[i]->psz_uri ); } if ( i == 0 ) { printf( "| no entries\n" ); } } /* * sanity check */ else { printf( "unknown command!\n" ); } vlc_object_release( p_playlist ); 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 ){ int i_error; if ( *newval.psz_string ) { /* Set. */ audio_volume_t i_volume = atoi( newval.psz_string ); if ( i_volume > AOUT_VOLUME_MAX ) { printf( "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 { printf( "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 ){ 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 ) printf( "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 ){ 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; } printf( "+----[ %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 ) printf( "| %i - %s *\n", val.p_list->p_values[i].i_int, text.p_list->p_values[i].psz_string ); else printf( "| %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 ); printf( "+----[ 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;}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -