int vlclua_var_toggle_or_set( lua_State *L, vlc_object_t *p_obj, const char *psz_name ) { bool b_bool; if( lua_gettop( L ) > 1 ) return vlclua_error( L ); if( lua_gettop( L ) == 0 ) { b_bool = var_ToggleBool( p_obj, psz_name ); goto end; } /* lua_gettop( L ) == 1 */ const char *s = luaL_checkstring( L, -1 ); lua_pop( L, 1 ); if( s && !strcmp(s, "on") ) b_bool = true; else if( s && !strcmp(s, "off") ) b_bool = false; else { b_bool = var_GetBool( p_obj, psz_name ); goto end; } if( b_bool != var_GetBool( p_obj, psz_name ) ) var_SetBool( p_obj, psz_name, b_bool ); end: lua_pushboolean( L, b_bool ); return 1; }
static int vlclua_togglebool( lua_State *L ) { vlc_object_t **pp_obj = luaL_checkudata( L, 1, "vlc_object" ); const char *psz_var = luaL_checkstring( L, 2 ); bool b_val = var_ToggleBool( *pp_obj, psz_var ); lua_pushboolean( L, b_val ); return 1; }
/** * TODO * This functions toggle the fullscreen mode * If there is no video, it should first activate Visualisations... * This has also to be fixed in enableVideo() */ void ActionsManager::fullscreen() { bool fs = var_ToggleBool( THEPL, "fullscreen" ); vout_thread_t *p_vout = THEMIM->getVout(); if( p_vout) { var_SetBool( p_vout, "fullscreen", fs ); vlc_object_release( p_vout ); } }
void CmdFullscreen::execute() { bool fs = var_ToggleBool( pl_Get( getIntf() ), "fullscreen" ); if( getIntf()->p_sys->p_input == NULL ) return; vout_thread_t *pVout = input_GetVout( getIntf()->p_sys->p_input ); if( pVout ) { // Switch fullscreen var_SetBool( pVout, "fullscreen", fs ); vlc_object_release( pVout ); } }
void libvlc_toggle_fullscreen( libvlc_media_player_t *p_mi ) { bool b_fullscreen = var_ToggleBool (p_mi, "fullscreen"); /* Apply to current video outputs (if any) */ size_t n; vout_thread_t **pp_vouts = GetVouts (p_mi, &n); for (size_t i = 0; i < n; i++) { vout_thread_t *p_vout = pp_vouts[i]; var_SetBool (p_vout, "fullscreen", b_fullscreen); vlc_object_release (p_vout); } free (pp_vouts); }
int __vlclua_var_toggle_or_set( lua_State *L, vlc_object_t *p_obj, const char *psz_name ) { bool b_bool; if( lua_gettop( L ) > 1 ) return vlclua_error( L ); if( lua_gettop( L ) == 0 ) b_bool = var_ToggleBool( p_obj, psz_name ); else /* lua_gettop( L ) == 1 */ { b_bool = luaL_checkboolean( L, -1 ); lua_pop( L, 1 ); if( b_bool != var_GetBool( p_obj, psz_name ) ) var_SetBool( p_obj, psz_name, b_bool ); } lua_pushboolean( L, b_bool ); return 1; }
void ActionsManager::record() { input_thread_t *p_input = THEMIM->getInput(); if( p_input ) { /* This method won't work fine if the stream can't be cut anywhere */ var_ToggleBool( p_input, "record" ); #if 0 else { /* 'record' access-filter is not loaded, we open Save dialog */ input_item_t *p_item = input_GetItem( p_input ); if( !p_item ) return; char *psz = input_item_GetURI( p_item ); if( psz ) THEDP->streamingDialog( NULL, qfu(psz), true ); } #endif }
static void test_booleans( libvlc_int_t *p_libvlc ) { int i; for( i = 0; i < i_var_count; i++ ) var_Create( p_libvlc, psz_var_name[i], VLC_VAR_BOOL ); for( i = 0; i < i_var_count; i++ ) { var_value[i].b_bool = (rand() > RAND_MAX/2); var_SetBool( p_libvlc, psz_var_name[i], var_value[i].b_bool ); } for( i = 0; i < i_var_count; i++ ) assert( var_GetBool( p_libvlc, psz_var_name[i] ) == var_value[i].b_bool ); for( i = 0; i < i_var_count; i++ ) var_ToggleBool( p_libvlc, psz_var_name[i] ); for( i = 0; i < i_var_count; i++ ) assert( var_GetBool( p_libvlc, psz_var_name[i] ) != var_value[i].b_bool ); for( i = 0; i < i_var_count; i++ ) var_Destroy( p_libvlc, psz_var_name[i] ); }
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; }
/***************************************************************************** * 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 ); }
void CmdToggleRecord::execute() { input_thread_t* pInput = getIntf()->p_sys->p_input; if( pInput ) var_ToggleBool( pInput, "record" ); }