/***************************************************************************** * libvlc_audio_set_track : Set the current audio track *****************************************************************************/ void libvlc_audio_set_track( libvlc_media_player_t *p_mi, int i_track, libvlc_exception_t *p_e ) { input_thread_t *p_input_thread = libvlc_get_input_thread( p_mi, p_e ); vlc_value_t val_list; vlc_value_t newval; int i_ret = -1; if( !p_input_thread ) return; var_Change( p_input_thread, "audio-es", VLC_VAR_GETCHOICES, &val_list, NULL ); if( (i_track < 0) || (i_track > val_list.p_list->i_count) ) { libvlc_exception_raise( p_e ); libvlc_printerr( "Audio track out of range" ); goto end; } newval = val_list.p_list->p_values[i_track]; i_ret = var_Set( p_input_thread, "audio-es", newval ); if( i_ret < 0 ) { libvlc_exception_raise( p_e ); libvlc_printerr( "Audio track out of range" ); /* Race... */ } end: var_FreeList( &val_list, NULL ); vlc_object_release( p_input_thread ); }
static void test_choices( libvlc_int_t *p_libvlc ) { vlc_value_t val, val2; var_Create( p_libvlc, "bla", VLC_VAR_INTEGER | VLC_VAR_HASCHOICE | VLC_VAR_ISCOMMAND ); val.i_int = 1; val2.psz_string = (char*)"one"; var_Change( p_libvlc, "bla", VLC_VAR_ADDCHOICE, &val, &val2 ); val.i_int = 2; val2.psz_string = (char*)"two"; var_Change( p_libvlc, "bla", VLC_VAR_ADDCHOICE, &val, &val2 ); assert( var_CountChoices( p_libvlc, "bla" ) == 2 ); var_Change( p_libvlc, "bla", VLC_VAR_DELCHOICE, &val, &val2 ); assert( var_CountChoices( p_libvlc, "bla" ) == 1 ); var_Change( p_libvlc, "bla", VLC_VAR_GETCHOICES, &val, &val2 ); assert( val.p_list->i_count == 1 && val.p_list->p_values[0].i_int == 1 && val2.p_list->i_count == 1 && !strcmp( val2.p_list->p_values[0].psz_string, "one" ) ); var_FreeList( &val, &val2 ); var_Change( p_libvlc, "bla", VLC_VAR_CLEARCHOICES, NULL, NULL ); assert( var_CountChoices( p_libvlc, "bla" ) == 0 ); var_Destroy( p_libvlc, "bla" ); }
/***************************************************************************** * libvlc_audio_set_track : Set the current audio track *****************************************************************************/ int libvlc_audio_set_track( libvlc_media_player_t *p_mi, int i_track ) { input_thread_t *p_input_thread = libvlc_get_input_thread( p_mi ); vlc_value_t val_list; int i_ret = -1; if( !p_input_thread ) return -1; var_Change( p_input_thread, "audio-es", VLC_VAR_GETCHOICES, &val_list, NULL ); for( int i = 0; i < val_list.p_list->i_count; i++ ) { if( i_track == val_list.p_list->p_values[i].i_int ) { if( var_SetInteger( p_input_thread, "audio-es", i_track ) < 0 ) break; i_ret = 0; goto end; } } libvlc_printerr( "Track identifier not found" ); end: var_FreeList( &val_list, NULL ); vlc_object_release( p_input_thread ); return i_ret; }
/***************************************************************************** * libvlc_audio_get_track : Get the current audio track *****************************************************************************/ int libvlc_audio_get_track( libvlc_media_player_t *p_mi, libvlc_exception_t *p_e ) { input_thread_t *p_input_thread = libvlc_get_input_thread( p_mi, p_e ); vlc_value_t val_list; vlc_value_t val; int i_track = -1; int i_ret = -1; int i; if( !p_input_thread ) return -1; i_ret = var_Get( p_input_thread, "audio-es", &val ); if( i_ret < 0 ) { vlc_object_release( p_input_thread ); libvlc_exception_raise( p_e ); libvlc_printerr( "Audio track information not found" ); return i_ret; } var_Change( p_input_thread, "audio-es", VLC_VAR_GETCHOICES, &val_list, NULL ); for( i = 0; i < val_list.p_list->i_count; i++ ) { if( val_list.p_list->p_values[i].i_int == val.i_int ) { i_track = i; break; } } var_FreeList( &val_list, NULL ); vlc_object_release( p_input_thread ); return i_track; }
/* internal function, used by audio, video */ libvlc_track_description_t * libvlc_get_track_description( libvlc_media_player_t *p_mi, const char *psz_variable ) { input_thread_t *p_input = libvlc_get_input_thread( p_mi ); libvlc_track_description_t *p_track_description = NULL, *p_actual, *p_previous; if( !p_input ) return NULL; vlc_value_t val_list, text_list; int i_ret = var_Change( p_input, psz_variable, VLC_VAR_GETLIST, &val_list, &text_list ); if( i_ret != VLC_SUCCESS ) return NULL; /* no tracks */ if( val_list.p_list->i_count <= 0 ) goto end; p_track_description = ( libvlc_track_description_t * ) malloc( sizeof( libvlc_track_description_t ) ); if ( !p_track_description ) { libvlc_printerr( "Not enough memory" ); goto end; } p_actual = p_track_description; p_previous = NULL; for( int i = 0; i < val_list.p_list->i_count; i++ ) { if( !p_actual ) { p_actual = ( libvlc_track_description_t * ) malloc( sizeof( libvlc_track_description_t ) ); if ( !p_actual ) { libvlc_track_description_list_release( p_track_description ); libvlc_printerr( "Not enough memory" ); goto end; } } p_actual->i_id = val_list.p_list->p_values[i].i_int; p_actual->psz_name = strdup( text_list.p_list->p_values[i].psz_string ); p_actual->p_next = NULL; if( p_previous ) p_previous->p_next = p_actual; p_previous = p_actual; p_actual = NULL; } end: var_FreeList( &val_list, &text_list ); vlc_object_release( p_input ); return p_track_description; }
static int vlclua_var_get_list( lua_State *L ) { vlc_value_t val; vlc_value_t text; vlc_object_t **pp_obj = luaL_checkudata( L, 1, "vlc_object" ); const char *psz_var = luaL_checkstring( L, 2 ); int i_ret = var_Change( *pp_obj, psz_var, VLC_VAR_GETLIST, &val, &text ); if( i_ret < 0 ) return vlclua_push_ret( L, i_ret ); vlclua_pushvalue( L, VLC_VAR_LIST, val ); vlclua_pushvalue( L, VLC_VAR_LIST, text ); var_FreeList( &val, &text ); return 2; }
static bool IsMenuEmpty( const char *psz_var, vlc_object_t *p_object, bool b_root ) { vlc_value_t val, val_list; int i_type, i_result, i; /* Check the type of the object variable */ i_type = var_Type( p_object, psz_var ); /* Check if we want to display the variable */ if( !( i_type & VLC_VAR_HASCHOICE ) ) return false; var_Change( p_object, psz_var, VLC_VAR_CHOICESCOUNT, &val, NULL ); if( val.i_int == 0 ) return true; if( ( i_type & VLC_VAR_TYPE ) != VLC_VAR_VARIABLE ) { if( val.i_int == 1 && b_root ) return true; else return false; } /* Check children variables in case of VLC_VAR_VARIABLE */ if( var_Change( p_object, psz_var, VLC_VAR_GETLIST, &val_list, NULL ) < 0 ) { return true; } for( i = 0, i_result = true; i < val_list.p_list->i_count; i++ ) { if( !IsMenuEmpty( val_list.p_list->p_values[i].psz_string, p_object, false ) ) { i_result = false; break; } } /* clean up everything */ var_FreeList( &val_list, NULL ); return i_result; }
/***************************************************************************** * ChapterMenu::AttachedToWindow *****************************************************************************/ void ChapterMenu::AttachedToWindow() { BMenuItem * item; while( ( item = RemoveItem( 0L ) ) ) { delete item; } input_thread_t * p_input; p_input = (input_thread_t *) vlc_object_find( p_intf, VLC_OBJECT_INPUT, FIND_ANYWHERE ); if( !p_input ) { return; } vlc_value_t val; BMessage * message; if( !var_Get( p_input, "chapter", &val ) ) { vlc_value_t val_list, text_list; var_Change( p_input, "chapter", VLC_VAR_GETCHOICES, &val_list, &text_list ); for( int i = 0; i < val_list.p_list->i_count; i++ ) { message = new BMessage( TOGGLE_CHAPTER ); message->AddInt32( "index", val_list.p_list->p_values[i].i_int ); item = new BMenuItem( text_list.p_list->p_values[i].psz_string, message ); if( val_list.p_list->p_values[i].i_int == val.i_int ) { item->SetMarked( true ); } AddItem( item ); } var_FreeList( &val_list, &text_list ); } vlc_object_release( p_input ); BMenu::AttachedToWindow(); }
/***************************************************************************** * LanguageMenu::AttachedToWindow *****************************************************************************/ void LanguageMenu::AttachedToWindow() { BMenuItem * item; // remove all items while( ( item = RemoveItem( 0L ) ) ) { delete item; } SetRadioMode( true ); input_thread_t * p_input = (input_thread_t *) vlc_object_find( p_intf, VLC_OBJECT_INPUT, FIND_ANYWHERE ); if( !p_input ) { return; } vlc_value_t val_list, text_list; BMessage * message; int i_current; i_current = var_GetInteger( p_input, psz_variable ); var_Change( p_input, psz_variable, VLC_VAR_GETLIST, &val_list, &text_list ); for( int i = 0; i < val_list.p_list->i_count; i++ ) { message = new BMessage( SELECT_CHANNEL ); message->AddInt32( psz_variable, val_list.p_list->p_values[i].i_int ); item = new BMenuItem( text_list.p_list->p_values[i].psz_string, message ); if( val_list.p_list->p_values[i].i_int == i_current ) { item->SetMarked( true ); } AddItem( item ); } var_FreeList( &val_list, &text_list ); vlc_object_release( p_input ); BMenu::AttachedToWindow(); }
void InputManager::sectionMenu() { if( hasInput() ) { vlc_value_t val, text; if( var_Change( p_input, "title 0", VLC_VAR_GETLIST, &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 ); } }
void AspectRatioComboBox::updateRatios() { /* Clear the list before updating */ clear(); vlc_value_t val_list, text_list; vout_thread_t* p_vout = THEMIM->getVout(); /* Disable if there is no vout */ if( p_vout == NULL ) { addItem( qtr("Aspect Ratio") ); setDisabled( true ); return; } var_Change( p_vout, "aspect-ratio", VLC_VAR_GETLIST, &val_list, &text_list ); for( int i = 0; i < val_list.p_list->i_count; i++ ) addItem( qfu( text_list.p_list->p_values[i].psz_string ), QString( val_list.p_list->p_values[i].psz_string ) ); setEnabled( true ); var_FreeList( &val_list, &text_list ); vlc_object_release( p_vout ); }
void InputManager::activateTeletext( bool b_enable ) { vlc_value_t list; vlc_value_t text; if( hasInput() && !var_Change( p_input, "teletext-es", VLC_VAR_GETLIST, &list, &text ) ) { if( list.p_list->i_count > 0 ) { /* Prefer the page 100 if it is present */ int i; for( i = 0; i < text.p_list->i_count; i++ ) { /* The description is the page number as a string */ const char *psz_page = text.p_list->p_values[i].psz_string; if( psz_page && !strcmp( psz_page, "100" ) ) break; } if( i >= list.p_list->i_count ) i = 0; var_SetInteger( p_input, "spu-es", b_enable ? list.p_list->p_values[i].i_int : -1 ); } var_FreeList( &list, &text ); } }
/***************************************************************************** * RunIntf: main loop *****************************************************************************/ static void RunIntf( intf_thread_t *p_intf ) { intf_sys_t *p_sys = p_intf->p_sys; int canc = vlc_savecancel(); input_thread_t *p_input; /* Main loop */ while( vlc_object_alive( p_intf ) ) { vlc_mutex_lock( &p_sys->lock ); /* * mouse cursor */ if( p_sys->b_got_gesture ) { int i_interval = 0; /* Do something */ /* If you modify this, please try to follow this convention: Start with LEFT, RIGHT for playback related commands and UP, DOWN, for other commands */ playlist_t * p_playlist = pl_Get( p_intf ); switch( p_sys->i_pattern ) { case LEFT: msg_Dbg( p_intf, "Go backward in the movie!" ); p_input = playlist_CurrentInput( p_playlist ); if( p_input ) { i_interval = var_InheritInteger( p_intf , "short-jump-size" ); if ( i_interval > 0 ) { mtime_t i_time = ( (mtime_t)( -i_interval ) * 1000000L); var_SetTime( p_input, "time-offset", i_time ); } vlc_object_release( p_input ); } break; case RIGHT: msg_Dbg( p_intf, "Go forward in the movie!" ); p_input = playlist_CurrentInput( p_playlist ); if( p_input ) { i_interval = var_InheritInteger( p_intf , "short-jump-size" ); if ( i_interval > 0 ) { mtime_t i_time = ( (mtime_t)( i_interval ) * 1000000L); var_SetTime( p_input, "time-offset", i_time ); } vlc_object_release( p_input ); } break; case GESTURE(LEFT,UP,NONE,NONE): msg_Dbg( p_intf, "Going slower." ); p_input = playlist_CurrentInput( p_playlist ); if( p_input ) { var_TriggerCallback( p_input, "rate-slower" ); vlc_object_release( p_input ); } break; case GESTURE(RIGHT,UP,NONE,NONE): msg_Dbg( p_intf, "Going faster." ); p_input = playlist_CurrentInput( p_playlist ); if( p_input ) { var_TriggerCallback( p_input, "rate-faster" ); vlc_object_release( p_input ); } break; case GESTURE(LEFT,RIGHT,NONE,NONE): case GESTURE(RIGHT,LEFT,NONE,NONE): msg_Dbg( p_intf, "Play/Pause" ); p_input = playlist_CurrentInput( p_playlist ); if( p_input ) { int i_state = var_GetInteger( p_input, "state" ); var_SetInteger( p_input, "state", ( i_state != PLAYING_S ) ? PLAYING_S : PAUSE_S ); vlc_object_release( p_input ); } break; case GESTURE(LEFT,DOWN,NONE,NONE): playlist_Prev( p_playlist ); break; case GESTURE(RIGHT,DOWN,NONE,NONE): playlist_Next( p_playlist ); break; case UP: msg_Dbg(p_intf, "Louder"); aout_VolumeUp( p_playlist, 1, NULL ); break; case DOWN: msg_Dbg(p_intf, "Quieter"); aout_VolumeDown( p_playlist, 1, NULL ); break; case GESTURE(UP,DOWN,NONE,NONE): case GESTURE(DOWN,UP,NONE,NONE): msg_Dbg( p_intf, "Mute sound" ); aout_ToggleMute( p_playlist, NULL ); break; case GESTURE(UP,RIGHT,NONE,NONE): { vlc_value_t list, list2; int i_count, i, i_audio_es; p_input = playlist_CurrentInput( p_playlist ); if( !p_input ) break; i_audio_es = var_GetInteger( p_input, "audio-es" ); var_Change( p_input, "audio-es", VLC_VAR_GETCHOICES, &list, &list2 ); i_count = list.p_list->i_count; if( i_count <= 1 ) { var_FreeList( &list, &list2 ); vlc_object_release( p_input ); break; } for( i = 0; i < i_count; i++ ) { if( i_audio_es == list.p_list->p_values[i].i_int ) break; } /* value of audio-es was not in choices list */ if( i == i_count ) { msg_Warn( p_input, "invalid current audio track, selecting 0" ); i = 0; } else if( i == i_count - 1 ) i = 1; else i++; var_SetInteger( p_input, "audio-es", list.p_list->p_values[i].i_int ); var_FreeList( &list, &list2 ); vlc_object_release( p_input ); } break; case GESTURE(DOWN,RIGHT,NONE,NONE): { vlc_value_t list, list2; int i_count, i, i_spu_es; p_input = playlist_CurrentInput( p_playlist ); if( !p_input ) break; i_spu_es = var_GetInteger( p_input, "spu-es" ); var_Change( p_input, "spu-es", VLC_VAR_GETCHOICES, &list, &list2 ); i_count = list.p_list->i_count; if( i_count <= 1 ) { vlc_object_release( p_input ); var_FreeList( &list, &list2 ); break; } for( i = 0; i < i_count; i++ ) { if( i_spu_es == list.p_list->p_values[i].i_int ) { break; } } /* value of spu-es was not in choices list */ if( i == i_count ) { msg_Warn( p_input, "invalid current subtitle track, selecting 0" ); i = 0; } else if( i == i_count - 1 ) i = 0; else i++; var_SetInteger( p_input, "spu-es", list.p_list->p_values[i].i_int); var_FreeList( &list, &list2 ); vlc_object_release( p_input ); } break; case GESTURE(UP,LEFT,NONE,NONE): { bool val = var_ToggleBool( pl_Get( p_intf ), "fullscreen" ); if( p_sys->p_vout ) var_SetBool( p_sys->p_vout, "fullscreen", val ); break; } case GESTURE(DOWN,LEFT,NONE,NONE): /* FIXME: Should close the vout!"*/ libvlc_Quit( p_intf->p_libvlc ); break; case GESTURE(DOWN,LEFT,UP,RIGHT): case GESTURE(UP,RIGHT,DOWN,LEFT): msg_Dbg( p_intf, "a square was drawn!" ); break; default: break; } p_sys->i_num_gestures = 0; p_sys->i_pattern = 0; p_sys->b_got_gesture = false; } /* * video output */ if( p_sys->p_vout && !vlc_object_alive( p_sys->p_vout ) ) { var_DelCallback( p_sys->p_vout, "mouse-moved", MouseEvent, p_intf ); var_DelCallback( p_sys->p_vout, "mouse-button-down", MouseEvent, p_intf ); vlc_object_release( p_sys->p_vout ); p_sys->p_vout = NULL; } if( p_sys->p_vout == NULL ) { p_input = playlist_CurrentInput( pl_Get( p_intf ) ); if( p_input ) { p_sys->p_vout = input_GetVout( p_input ); vlc_object_release( p_input ); } if( p_sys->p_vout ) { var_AddCallback( p_sys->p_vout, "mouse-moved", MouseEvent, p_intf ); var_AddCallback( p_sys->p_vout, "mouse-button-down", MouseEvent, p_intf ); } } vlc_mutex_unlock( &p_sys->lock ); /* Wait a bit */ msleep( INTF_IDLE_SLEEP ); } vlc_restorecancel( canc ); }
int QVLCMenu::CreateChoicesMenu( QMenu *submenu, const char *psz_var, vlc_object_t *p_object, bool b_root ) { vlc_value_t val, val_list, text_list; int i_type, i; /* Check the type of the object variable */ i_type = var_Type( p_object, psz_var ); /* Make sure we want to display the variable */ if( submenu->isEmpty() && IsMenuEmpty( psz_var, p_object, b_root ) ) return VLC_EGENERIC; switch( i_type & VLC_VAR_TYPE ) { case VLC_VAR_VOID: case VLC_VAR_BOOL: case VLC_VAR_VARIABLE: case VLC_VAR_STRING: case VLC_VAR_INTEGER: case VLC_VAR_FLOAT: break; default: /* Variable doesn't exist or isn't handled */ return VLC_EGENERIC; } if( var_Change( p_object, psz_var, VLC_VAR_GETLIST, &val_list, &text_list ) < 0 ) { return VLC_EGENERIC; } #define CURVAL val_list.p_list->p_values[i] #define CURTEXT text_list.p_list->p_values[i].psz_string for( i = 0; i < val_list.p_list->i_count; i++ ) { vlc_value_t another_val; QString menutext; QMenu *subsubmenu = new QMenu( submenu ); switch( i_type & VLC_VAR_TYPE ) { case VLC_VAR_VARIABLE: CreateChoicesMenu( subsubmenu, CURVAL.psz_string, p_object, false ); subsubmenu->setTitle( qfu( CURTEXT ? CURTEXT :CURVAL.psz_string ) ); submenu->addMenu( subsubmenu ); break; case VLC_VAR_STRING: var_Get( p_object, psz_var, &val ); another_val.psz_string = strdup( CURVAL.psz_string ); menutext = qfu( CURTEXT ? CURTEXT : another_val.psz_string ); CreateAndConnect( submenu, psz_var, menutext, "", ITEM_RADIO, p_object, another_val, i_type, val.psz_string && !strcmp( val.psz_string, CURVAL.psz_string ) ); free( val.psz_string ); break; case VLC_VAR_INTEGER: var_Get( p_object, psz_var, &val ); if( CURTEXT ) menutext = qfu( CURTEXT ); else menutext.sprintf( "%d", CURVAL.i_int ); CreateAndConnect( submenu, psz_var, menutext, "", ITEM_RADIO, p_object, CURVAL, i_type, ( CURVAL.i_int == val.i_int ) && CheckTitle( p_object, psz_var ) ); break; case VLC_VAR_FLOAT: var_Get( p_object, psz_var, &val ); if( CURTEXT ) menutext = qfu( CURTEXT ); else menutext.sprintf( "%.2f", CURVAL.f_float ); CreateAndConnect( submenu, psz_var, menutext, "", ITEM_RADIO, p_object, CURVAL, i_type, CURVAL.f_float == val.f_float ); break; default: break; } } currentGroup = NULL; /* clean up everything */ var_FreeList( &val_list, &text_list ); #undef CURVAL #undef CURTEXT return submenu->isEmpty() ? VLC_EGENERIC : VLC_SUCCESS; }
static int CreateChoicesMenu( intf_thread_t *p_intf, GtkMenu *submenu, const char *psz_var, vlc_object_t *p_object, bool b_root ) { vlc_value_t val, val_list, text_list; int i_type, i; /* Check the type of the object variable */ i_type = var_Type( p_object, psz_var ); /* Make sure we want to display the variable */ if( !g_list_length(GTK_MENU_SHELL(submenu)->children) && IsMenuEmpty( psz_var, p_object, b_root ) ) return VLC_EGENERIC; switch( i_type & VLC_VAR_TYPE ) { case VLC_VAR_VOID: case VLC_VAR_BOOL: case VLC_VAR_VARIABLE: case VLC_VAR_STRING: case VLC_VAR_INTEGER: case VLC_VAR_FLOAT: break; default: /* Variable doesn't exist or isn't handled */ return VLC_EGENERIC; } if( var_Change( p_object, psz_var, VLC_VAR_GETLIST, &val_list, &text_list ) < 0 ) { return VLC_EGENERIC; } #define CURVAL val_list.p_list->p_values[i] #define CURTEXT text_list.p_list->p_values[i].psz_string for( i = 0; i < val_list.p_list->i_count; i++ ) { vlc_value_t another_val; char string[16] = {0}; char *menutext = string; switch( i_type & VLC_VAR_TYPE ) { case VLC_VAR_VARIABLE: { GtkWidget *subsubmenu = gtk_menu_new(); GtkWidget *submenuitem = gtk_menu_item_new_with_label( CURTEXT ? CURTEXT : CURVAL.psz_string ); gtk_menu_item_set_submenu(GTK_MENU_ITEM(submenuitem), subsubmenu); gtk_menu_append( submenu, submenuitem ); CreateChoicesMenu( p_intf, GTK_MENU(subsubmenu), CURVAL.psz_string, p_object, false ); break; } case VLC_VAR_STRING: var_Get( p_object, psz_var, &val ); another_val.psz_string = strdup( CURVAL.psz_string ); menutext = CURTEXT ? CURTEXT : another_val.psz_string; CreateAndConnect( p_intf, submenu, psz_var, menutext, "", ITEM_RADIO, p_object, another_val, i_type, val.psz_string && !strcmp( val.psz_string, CURVAL.psz_string ) ); free( val.psz_string ); break; case VLC_VAR_INTEGER: var_Get( p_object, psz_var, &val ); if( CURTEXT ) menutext = CURTEXT; else snprintf( menutext, sizeof(string)-1, "%"PRId64, CURVAL.i_int ); CreateAndConnect( p_intf, submenu, psz_var, menutext, "", ITEM_RADIO, p_object, CURVAL, i_type, ( CURVAL.i_int == val.i_int ) && CheckTitle( p_object, psz_var ) ); break; case VLC_VAR_FLOAT: var_Get( p_object, psz_var, &val ); if( CURTEXT ) menutext = CURTEXT; else snprintf( menutext, sizeof(string)-1, "%.2f", CURVAL.f_float ); CreateAndConnect( p_intf, submenu, psz_var, menutext, "", ITEM_RADIO, p_object, CURVAL, i_type, CURVAL.f_float == val.f_float ); break; default: break; } } /* clean up everything */ var_FreeList( &val_list, &text_list ); #undef CURVAL #undef CURTEXT return !g_list_length(GTK_MENU_SHELL(submenu)->children) ? VLC_EGENERIC : VLC_SUCCESS; }
mvar_t *mvar_InputVarSetNew( intf_thread_t *p_intf, char *name, input_thread_t *p_input, const char *psz_variable ) { intf_sys_t *p_sys = p_intf->p_sys; mvar_t *s = mvar_New( name, "set" ); vlc_value_t val, val_list, text_list; int i_type, i; if( p_input == NULL ) { return s; } /* Check the type of the object variable */ i_type = var_Type( p_sys->p_input, psz_variable ); /* Make sure we want to display the variable */ if( i_type & VLC_VAR_HASCHOICE ) { var_Change( p_sys->p_input, psz_variable, VLC_VAR_CHOICESCOUNT, &val, NULL ); if( val.i_int == 0 ) return s; if( (i_type & VLC_VAR_TYPE) != VLC_VAR_VARIABLE && val.i_int == 1 ) return s; } else { return s; } switch( i_type & VLC_VAR_TYPE ) { case VLC_VAR_VOID: case VLC_VAR_BOOL: case VLC_VAR_VARIABLE: case VLC_VAR_STRING: case VLC_VAR_INTEGER: break; default: /* Variable doesn't exist or isn't handled */ return s; } if( var_Get( p_sys->p_input, psz_variable, &val ) < 0 ) { return s; } if( var_Change( p_sys->p_input, psz_variable, VLC_VAR_GETLIST, &val_list, &text_list ) < 0 ) { if( (i_type & VLC_VAR_TYPE) == VLC_VAR_STRING ) free( val.psz_string ); return s; } for( i = 0; i < val_list.p_list->i_count; i++ ) { char psz_int[16]; mvar_t *itm; switch( i_type & VLC_VAR_TYPE ) { case VLC_VAR_STRING: itm = mvar_New( name, "set" ); mvar_AppendNewVar( itm, "name", text_list.p_list->p_values[i].psz_string ); mvar_AppendNewVar( itm, "id", val_list.p_list->p_values[i].psz_string ); snprintf( psz_int, sizeof(psz_int), "%d", ( !strcmp( val.psz_string, val_list.p_list->p_values[i].psz_string ) && !( i_type & VLC_VAR_ISCOMMAND ) ) ); mvar_AppendNewVar( itm, "selected", psz_int ); mvar_AppendVar( s, itm ); break; case VLC_VAR_INTEGER: itm = mvar_New( name, "set" ); mvar_AppendNewVar( itm, "name", text_list.p_list->p_values[i].psz_string ); snprintf( psz_int, sizeof(psz_int), "%d", val_list.p_list->p_values[i].i_int ); mvar_AppendNewVar( itm, "id", psz_int ); snprintf( psz_int, sizeof(psz_int), "%d", ( val.i_int == val_list.p_list->p_values[i].i_int ) && !( i_type & VLC_VAR_ISCOMMAND ) ); mvar_AppendNewVar( itm, "selected", psz_int ); mvar_AppendVar( s, itm ); break; default: break; } } /* clean up everything */ if( (i_type & VLC_VAR_TYPE) == VLC_VAR_STRING ) free( val.psz_string ); var_FreeList( &val_list, &text_list ); return s; }
HMENU CreateChoicesMenu( intf_thread_t *p_intf, vector<MenuItemExt*> *p_menu_list, char *psz_var, vlc_object_t *p_object, int *pi_item_id ) { MenuItemExt *pMenuItemExt; vlc_value_t val, val_list, text_list; int i_type, i; HMENU hSubMenu = CreatePopupMenu(); /* Check the type of the object variable */ i_type = var_Type( p_object, psz_var ); /* Make sure we want to display the variable */ if( i_type & VLC_VAR_HASCHOICE ) { var_Change( p_object, psz_var, VLC_VAR_CHOICESCOUNT, &val, NULL ); if( val.i_int == 0 ) return NULL; if( (i_type & VLC_VAR_TYPE) != VLC_VAR_VARIABLE && val.i_int == 1 ) return NULL; } else { return NULL; } switch( i_type & VLC_VAR_TYPE ) { case VLC_VAR_VOID: case VLC_VAR_BOOL: case VLC_VAR_VARIABLE: case VLC_VAR_STRING: case VLC_VAR_INTEGER: break; default: /* Variable doesn't exist or isn't handled */ return NULL; } if( var_Get( p_object, psz_var, &val ) < 0 ) return NULL; if( var_Change( p_object, psz_var, VLC_VAR_GETLIST, &val_list, &text_list ) < 0 ) { if( (i_type & VLC_VAR_TYPE) == VLC_VAR_STRING ) free( val.psz_string ); return NULL; } for( i = 0; i < val_list.p_list->i_count; i++ ) { vlc_value_t another_val; HMENU hMenuItem; char *psz_tmp; switch( i_type & VLC_VAR_TYPE ) { case VLC_VAR_VARIABLE: hMenuItem = CreateChoicesMenu( p_intf, p_menu_list, val_list.p_list->p_values[i].psz_string, p_object, pi_item_id ); AppendMenu( hSubMenu, MF_STRING | MF_POPUP, (UINT)hMenuItem, _FROMMB(text_list.p_list->p_values[i].psz_string ? text_list.p_list->p_values[i].psz_string : val_list.p_list->p_values[i].psz_string) ); break; case VLC_VAR_STRING: another_val.psz_string = strdup(val_list.p_list->p_values[i].psz_string); AppendMenu( hSubMenu, MF_STRING, ++(*pi_item_id), _FROMMB(text_list.p_list->p_values[i].psz_string ? text_list.p_list->p_values[i].psz_string : val_list.p_list->p_values[i].psz_string) ); pMenuItemExt = new MenuItemExt( p_intf, *pi_item_id, psz_var, p_object, another_val, i_type ); p_menu_list->push_back( pMenuItemExt ); if( !(i_type & VLC_VAR_ISCOMMAND) && val.psz_string && !strcmp( val.psz_string, val_list.p_list->p_values[i].psz_string ) ) CheckMenuItem( hSubMenu, *pi_item_id, MF_CHECKED | MF_BYCOMMAND); break; case VLC_VAR_INTEGER: asprintf( &psz_tmp, "%d", val_list.p_list->p_values[i].i_int ); AppendMenu( hSubMenu, MF_STRING, ++(*pi_item_id), _FROMMB(text_list.p_list->p_values[i].psz_string ? text_list.p_list->p_values[i].psz_string : psz_tmp)); free( psz_tmp ); pMenuItemExt = new MenuItemExt( p_intf, *pi_item_id, psz_var, p_object, val_list.p_list->p_values[i], i_type ); p_menu_list->push_back( pMenuItemExt ); if( val_list.p_list->p_values[i].i_int == val.i_int ) CheckMenuItem( hSubMenu, *pi_item_id, MF_CHECKED | MF_BYCOMMAND); break; default: break; } } /* Clean up everything */ if( (i_type & VLC_VAR_TYPE) == VLC_VAR_STRING ) free( val.psz_string ); var_FreeList( &val_list, &text_list ); return hSubMenu; }
static void ProcessGesture( intf_thread_t *p_intf ) { intf_sys_t *p_sys = p_intf->p_sys; playlist_t *p_playlist = pl_Get( p_intf ); /* Do something */ /* If you modify this, please try to follow this convention: Start with LEFT, RIGHT for playback related commands and UP, DOWN, for other commands */ switch( p_sys->i_pattern ) { case LEFT: { msg_Dbg( p_intf, "Go backward in the movie!" ); input_thread_t *p_input = playlist_CurrentInput( p_playlist ); if( p_input == NULL ) break; int it = var_InheritInteger( p_intf , "short-jump-size" ); if( it > 0 ) var_SetTime( p_input, "time-offset", -CLOCK_FREQ * it ); vlc_object_release( p_input ); break; } case RIGHT: { msg_Dbg( p_intf, "Go forward in the movie!" ); input_thread_t *p_input = playlist_CurrentInput( p_playlist ); if( p_input == NULL ) break; int it = var_InheritInteger( p_intf , "short-jump-size" ); if( it > 0 ) var_SetTime( p_input, "time-offset", CLOCK_FREQ * it ); vlc_object_release( p_input ); break; } case GESTURE(LEFT,UP,NONE,NONE): msg_Dbg( p_intf, "Going slower." ); var_TriggerCallback( p_playlist, "rate-slower" ); break; case GESTURE(RIGHT,UP,NONE,NONE): msg_Dbg( p_intf, "Going faster." ); var_TriggerCallback( p_playlist, "rate-faster" ); break; case GESTURE(LEFT,RIGHT,NONE,NONE): case GESTURE(RIGHT,LEFT,NONE,NONE): { msg_Dbg( p_intf, "Play/Pause" ); input_thread_t *p_input = playlist_CurrentInput( p_playlist ); if( p_input == NULL ) break; int i_state = var_GetInteger( p_input, "state" ); i_state = (i_state == PLAYING_S) ? PAUSE_S : PLAYING_S; var_SetInteger( p_input, "state", i_state ); vlc_object_release( p_input ); break; } case GESTURE(LEFT,DOWN,NONE,NONE): playlist_Prev( p_playlist ); break; case GESTURE(RIGHT,DOWN,NONE,NONE): playlist_Next( p_playlist ); break; case UP: msg_Dbg(p_intf, "Louder"); playlist_VolumeUp( p_playlist, 1, NULL ); break; case DOWN: msg_Dbg(p_intf, "Quieter"); playlist_VolumeDown( p_playlist, 1, NULL ); break; case GESTURE(UP,DOWN,NONE,NONE): case GESTURE(DOWN,UP,NONE,NONE): msg_Dbg( p_intf, "Mute sound" ); playlist_MuteToggle( p_playlist ); break; case GESTURE(UP,RIGHT,NONE,NONE): { input_thread_t *p_input = playlist_CurrentInput( p_playlist ); if( p_input == NULL ) break; vlc_value_t list, list2; var_Change( p_input, "audio-es", VLC_VAR_GETCHOICES, &list, &list2 ); if( list.p_list->i_count > 1 ) { int i_audio_es = var_GetInteger( p_input, "audio-es" ); int i; for( i = 0; i < list.p_list->i_count; i++ ) if( i_audio_es == list.p_list->p_values[i].i_int ) break; /* value of audio-es was not in choices list */ if( i == list.p_list->i_count ) { msg_Warn( p_input, "invalid current audio track, selecting 0" ); i = 0; } else if( i == list.p_list->i_count - 1 ) i = 1; else i++; var_SetInteger( p_input, "audio-es", list.p_list->p_values[i].i_int ); } var_FreeList( &list, &list2 ); vlc_object_release( p_input ); break; } case GESTURE(DOWN,RIGHT,NONE,NONE): { input_thread_t *p_input = playlist_CurrentInput( p_playlist ); if( p_input == NULL ) break; vlc_value_t list, list2; var_Change( p_input, "spu-es", VLC_VAR_GETCHOICES, &list, &list2 ); if( list.p_list->i_count > 1 ) { int i_audio_es = var_GetInteger( p_input, "spu-es" ); int i; for( i = 0; i < list.p_list->i_count; i++ ) if( i_audio_es == list.p_list->p_values[i].i_int ) break; /* value of audio-es was not in choices list */ if( i == list.p_list->i_count ) { msg_Warn( p_input, "invalid current subtitle track, selecting 0" ); i = 0; } else if( i == list.p_list->i_count - 1 ) i = 1; else i++; var_SetInteger( p_input, "audio-es", list.p_list->p_values[i].i_int ); } var_FreeList( &list, &list2 ); vlc_object_release( p_input ); break; } case GESTURE(UP,LEFT,NONE,NONE): { bool val = var_ToggleBool( pl_Get( p_intf ), "fullscreen" ); if( p_sys->p_vout ) var_SetBool( p_sys->p_vout, "fullscreen", val ); break; } case GESTURE(DOWN,LEFT,NONE,NONE): /* FIXME: Should close the vout!"*/ libvlc_Quit( p_intf->p_libvlc ); break; case GESTURE(DOWN,LEFT,UP,RIGHT): case GESTURE(UP,RIGHT,DOWN,LEFT): msg_Dbg( p_intf, "a square was drawn!" ); break; } p_sys->i_num_gestures = 0; p_sys->i_pattern = 0; }