void libvlc_toggle_teletext( libvlc_media_player_t *p_mi, libvlc_exception_t *p_e ) { input_thread_t *p_input_thread; vlc_object_t *p_vbi; int i_ret; p_input_thread = libvlc_get_input_thread(p_mi, p_e); if( !p_input_thread ) return; p_vbi = (vlc_object_t *) vlc_object_find_name( p_input_thread, "zvbi", FIND_ANYWHERE ); if( p_vbi ) { const int i_teletext_es = var_GetInteger( p_input_thread, "teletext-es" ); const int i_spu_es = var_GetInteger( p_input_thread, "spu-es" ); if( (i_teletext_es >= 0) && (i_teletext_es == i_spu_es) ) { int i_page = 100; i_page = var_GetInteger( p_vbi, "vbi-page" ); i_page = (i_teletext_es >= 0) ? i_page : 0; i_ret = var_SetInteger( p_vbi, "vbi-page", i_page ); if( i_ret ) libvlc_exception_raise( p_e, "Unexpected error while setting teletext page" ); } else if( i_teletext_es >= 0 ) { bool opaque = true; opaque = var_GetBool( p_vbi, "vbi-opaque" ); i_ret = var_SetBool( p_vbi, "vbi-opaque", !opaque ); if( i_ret ) libvlc_exception_raise( p_e, "Unexpected error while setting teletext transparency" ); } vlc_object_release( p_vbi ); } else { /* Teletext is not enabled yet, so enable it. * Only after it is enable it is possible to view teletext pages */ const int i_teletext_es = var_GetInteger( p_input_thread, "teletext-es" ); if( i_teletext_es >= 0 ) { const int i_spu_es = var_GetInteger( p_input_thread, "spu-es" ); if( i_teletext_es == i_spu_es ) var_SetInteger( p_input_thread, "spu-es", -1 ); else var_SetInteger( p_input_thread, "spu-es", i_teletext_es ); } } vlc_object_release( p_input_thread ); }
static int vlclua_object_find_name( lua_State *L ) { const char *psz_name = luaL_checkstring( L, 2 ); const char *psz_mode = luaL_checkstring( L, 3 ); vlc_object_t *p_this; int i_mode = vlc_object_search_mode_from_string( psz_mode ); vlc_object_t *p_result; if( !i_mode ) return luaL_error( L, "\"%s\" is not a valid search mode.", psz_mode ); if( lua_type( L, 1 ) == LUA_TNIL ) p_this = vlclua_get_this( L ); else { vlc_object_t **p_obj = luaL_checkudata( L, 1, "vlc_object" ); p_this = *p_obj; } p_result = vlc_object_find_name( p_this, psz_name, i_mode ); if( !p_result ) lua_pushnil( L ); else vlclua_push_vlc_object( L, p_result, vlclua_gc_release ); return 1; }
/********************************************************************** * Execute a var command on an object identified by its name **********************************************************************/ int var_Command( vlc_object_t *p_this, const char *psz_name, const char *psz_cmd, const char *psz_arg, char **psz_msg ) { vlc_object_t *p_obj = vlc_object_find_name( p_this->p_libvlc, psz_name ); int i_type, i_ret; if( !p_obj ) { if( psz_msg ) *psz_msg = strdup( "Unknown destination object." ); return VLC_ENOOBJ; } i_type = var_Type( p_obj, psz_cmd ); if( !( i_type&VLC_VAR_ISCOMMAND ) ) { vlc_object_release( p_obj ); if( psz_msg ) *psz_msg = strdup( "Variable doesn't exist or isn't a command." ); return VLC_EGENERIC; } i_type &= VLC_VAR_CLASS; switch( i_type ) { case VLC_VAR_INTEGER: i_ret = var_SetInteger( p_obj, psz_cmd, atoi( psz_arg ) ); break; case VLC_VAR_FLOAT: i_ret = var_SetFloat( p_obj, psz_cmd, us_atof( psz_arg ) ); break; case VLC_VAR_STRING: i_ret = var_SetString( p_obj, psz_cmd, psz_arg ); break; case VLC_VAR_BOOL: i_ret = var_SetBool( p_obj, psz_cmd, atoi( psz_arg ) ); break; default: i_ret = VLC_EGENERIC; break; } vlc_object_release( p_obj ); if( psz_msg ) { if( asprintf( psz_msg, "%s on object %s returned %i (%s)", psz_cmd, psz_name, i_ret, vlc_error( i_ret ) ) == -1) *psz_msg = NULL; } return i_ret; }
/***************************************************************************** * DumpCommand: print the current vlc structure ***************************************************************************** * This function prints either an ASCII tree showing the connections between * vlc objects, and additional information such as their refcount, thread ID, * etc. (command "tree"), or the same data as a simple list (command "list"). *****************************************************************************/ static int DumpCommand( vlc_object_t *p_this, char const *psz_cmd, vlc_value_t oldval, vlc_value_t newval, void *p_data ) { (void)oldval; (void)p_data; vlc_object_t *p_object = NULL; if( *newval.psz_string ) { /* try using the object's name to find it */ p_object = vlc_object_find_name( p_this, newval.psz_string, FIND_ANYWHERE ); if( !p_object ) { return VLC_ENOOBJ; } } libvlc_lock (p_this->p_libvlc); if( *psz_cmd == 't' ) { char psz_foo[2 * MAX_DUMPSTRUCTURE_DEPTH + 1]; if( !p_object ) p_object = VLC_OBJECT(p_this->p_libvlc); psz_foo[0] = '|'; DumpStructure( vlc_internals(p_object), 0, psz_foo ); } else if( *psz_cmd == 'v' ) { if( !p_object ) p_object = p_this->p_libvlc ? VLC_OBJECT(p_this->p_libvlc) : p_this; PrintObject( vlc_internals(p_object), "" ); vlc_mutex_lock( &vlc_internals( p_object )->var_lock ); if( vlc_internals( p_object )->var_root == NULL ) puts( " `-o No variables" ); else twalk( vlc_internals( p_object )->var_root, DumpVariable ); vlc_mutex_unlock( &vlc_internals( p_object )->var_lock ); } libvlc_unlock (p_this->p_libvlc); if( *newval.psz_string ) { vlc_object_release( p_object ); } return VLC_SUCCESS; }
int libvlc_video_get_teletext( libvlc_media_player_t *p_mi, libvlc_exception_t *p_e ) { vout_thread_t *p_vout = GetVout( p_mi, p_e ); vlc_object_t *p_vbi; int i_ret = -1; if( !p_vout ) return i_ret; p_vbi = (vlc_object_t *) vlc_object_find_name( p_vout, "zvbi", FIND_ANYWHERE ); if( p_vbi ) { i_ret = var_GetInteger( p_vbi, "vbi-page" ); vlc_object_release( p_vbi ); } vlc_object_release( p_vout ); return i_ret; }
void libvlc_video_set_teletext( libvlc_media_player_t *p_mi, int i_page, libvlc_exception_t *p_e ) { vout_thread_t *p_vout = GetVout( p_mi, p_e ); vlc_object_t *p_vbi; int i_ret = -1; if( !p_vout ) return; p_vbi = (vlc_object_t *) vlc_object_find_name( p_vout, "zvbi", FIND_ANYWHERE ); if( p_vbi ) { i_ret = var_SetInteger( p_vbi, "vbi-page", i_page ); vlc_object_release( p_vbi ); if( i_ret ) libvlc_exception_raise( p_e, "Unexpected error while setting teletext page" ); } vlc_object_release( p_vout ); }
/** * Finds a named object and increment its reference count. * Beware that objects found in this manner can be "owned" by another thread, * be of _any_ type, and be attached to any module (if any). With such an * object reference, you can set or get object variables, emit log messages, * and read write-once object parameters (psz_object_type, etc). * You CANNOT cast the object to a more specific object type, and you * definitely cannot invoke object type-specific callbacks with this. * * @param p_this object to search from * @param psz_name name of the object to search for * @param i_mode search direction: FIND_PARENT, FIND_CHILD or FIND_ANYWHERE. * * @return a matching object (must be released by the caller), * or NULL on error. */ vlc_object_t *vlc_object_find_name( vlc_object_t *p_this, const char *psz_name, int i_mode ) { vlc_object_t *p_found; /* Reading psz_object_name from a separate inhibits thread-safety. * Use a libvlc address variable instead for that sort of things! */ msg_Warn( p_this, "%s(%s) is not safe!", __func__, psz_name ); /* If have the requested name ourselves, don't look further */ if( !objnamecmp(p_this, psz_name) ) { vlc_object_hold( p_this ); return p_this; } /* Otherwise, recursively look for the object */ if (i_mode == FIND_ANYWHERE) return vlc_object_find_name (VLC_OBJECT(p_this->p_libvlc), psz_name, FIND_CHILD); libvlc_lock (p_this->p_libvlc); vlc_mutex_lock (&name_lock); switch (i_mode) { case FIND_PARENT: p_found = FindParentName (p_this, psz_name); break; case FIND_CHILD: p_found = FindChildName (vlc_internals (p_this), psz_name); break; default: assert (0); } vlc_mutex_unlock (&name_lock); libvlc_unlock (p_this->p_libvlc); return p_found; }
static void RunIntf( intf_thread_t *p_intf ) { int i_x, i_oldx = 0, i_sum = 0, i = 0; int p_oldx[FILTER_LENGTH]; memset( p_oldx, 0, FILTER_LENGTH * sizeof( int ) ); for( ;; ) { const char *psz_filter, *psz_type; bool b_change = false; /* Wait a bit, get orientation, change filter if necessary */ #warning FIXME: check once (or less) per picture, not once per interval msleep( INTF_IDLE_SLEEP ); int canc = vlc_savecancel(); i_x = GetOrientation( p_intf ); i_sum += i_x - p_oldx[i]; p_oldx[i++] = i_x; if( i == FILTER_LENGTH ) i = 0; i_x = i_sum / FILTER_LENGTH; if( p_intf->p_sys->b_use_rotate ) { if( i_oldx != i_x ) { /* TODO: cache object pointer */ vlc_object_t *p_obj = vlc_object_find_name( p_intf->p_libvlc, "rotate" ); if( p_obj ) { var_SetInteger( p_obj, "rotate-deciangle", ((3600+i_x/2)%3600) ); i_oldx = i_x; vlc_object_release( p_obj ); } } goto loop; } if( i_x < -HIGH_THRESHOLD && i_oldx > -LOW_THRESHOLD ) { b_change = true; psz_filter = "transform"; psz_type = "270"; } else if( ( i_x > -LOW_THRESHOLD && i_oldx < -HIGH_THRESHOLD ) || ( i_x < LOW_THRESHOLD && i_oldx > HIGH_THRESHOLD ) ) { b_change = true; psz_filter = ""; psz_type = ""; } else if( i_x > HIGH_THRESHOLD && i_oldx < LOW_THRESHOLD ) { b_change = true; psz_filter = "transform"; psz_type = "90"; } if( b_change ) { #warning FIXME: refactor this plugin as a video filter! input_thread_t *p_input; p_input = playlist_CurrentInput( pl_Get( p_intf ) ); if( p_input ) { vout_thread_t *p_vout; p_vout = input_GetVout( p_input ); if( p_vout ) { #warning FIXME: do not override the permanent configuration! #warning FIXME: transform-type does not exist anymore config_PutPsz( p_vout, "transform-type", psz_type ); var_SetString( p_vout, "video-filter", psz_filter ); vlc_object_release( p_vout ); } vlc_object_release( p_input ); i_oldx = i_x; } } loop: vlc_restorecancel( canc ); } }
/* Main Menu that sticks everything together */ void QVLCMenu::PopupMenu( intf_thread_t *p_intf, bool show ) { /* Delete old popup if there is one */ if( p_intf->p_sys->p_popup_menu ) delete p_intf->p_sys->p_popup_menu; if( !show ) { p_intf->p_sys->p_popup_menu = NULL; return; } /* */ QMenu *menu = new QMenu(); QAction *action; bool b_isFullscreen = false; MainInterface *mi = p_intf->p_sys->p_mi; POPUP_BOILERPLATE; PopupPlayEntries( menu, p_intf, p_input ); PopupMenuPlaylistControlEntries( menu, p_intf ); menu->addSeparator(); if( p_input ) { QMenu *submenu; vout_thread_t *p_vout = THEMIM->getVout(); /* Add a fullscreen switch button, since it is the most used function */ if( p_vout ) { vlc_value_t val; var_Get( p_vout, "fullscreen", &val ); b_isFullscreen = !( !val.b_bool ); if( b_isFullscreen ) CreateAndConnect( menu, "fullscreen", qtr( "Leave Fullscreen" ),"" , ITEM_NORMAL, VLC_OBJECT(p_vout), val, VLC_VAR_BOOL, b_isFullscreen ); vlc_object_release( p_vout ); menu->addSeparator(); } /* Input menu */ InputAutoMenuBuilder( p_input, objects, varnames ); /* Audio menu */ submenu = new QMenu( menu ); action = menu->addMenu( AudioMenu( p_intf, submenu ) ); action->setText( qtr( "&Audio" ) ); if( action->menu()->isEmpty() ) action->setEnabled( false ); /* Video menu */ submenu = new QMenu( menu ); action = menu->addMenu( VideoMenu( p_intf, submenu ) ); action->setText( qtr( "&Video" ) ); if( action->menu()->isEmpty() ) action->setEnabled( false ); /* Playback menu for chapters */ submenu = new QMenu( menu ); action = menu->addMenu( NavigMenu( p_intf, submenu ) ); action->setText( qtr( "&Playback" ) ); if( action->menu()->isEmpty() ) action->setEnabled( false ); } menu->addSeparator(); /* Add some special entries for windowed mode: Interface Menu */ if( !b_isFullscreen ) { QMenu *submenu = new QMenu( qtr( "Interface" ), menu ); QMenu *tools = ToolsMenu( submenu ); submenu->addSeparator(); /* In skins interface, append some items */ if( !mi ) { vlc_object_t *p_object = ( vlc_object_t* ) vlc_object_find_name( p_intf, "skins2", FIND_PARENT ); if( p_object ) { objects.clear(); varnames.clear(); objects.push_back( p_object ); varnames.push_back( "intf-skins" ); Populate( p_intf, submenu, varnames, objects ); objects.clear(); varnames.clear(); objects.push_back( p_object ); varnames.push_back( "intf-skins-interactive" ); Populate( p_intf, submenu, varnames, objects ); vlc_object_release( p_object ); } else msg_Warn( p_intf, "could not find parent interface" ); } else menu->addMenu( ViewMenu( p_intf, mi, false )); menu->addMenu( submenu ); } /* Static entries for ending, like open */ PopupMenuStaticEntries( menu ); p_intf->p_sys->p_popup_menu = menu; p_intf->p_sys->p_popup_menu->popup( QCursor::pos() ); }