static std::string getHRTFPath(filter_t *p_filter) { std::string HRTFPath; char *userHRTFPath = var_InheritString(p_filter, "hrtf-file"); if (userHRTFPath != NULL) { HRTFPath = std::string(userHRTFPath); free(userHRTFPath); } else { char *dataDir = config_GetDataDir(); if (dataDir != NULL) { std::stringstream ss; ss << std::string(dataDir) << DIR_SEP << DEFAULT_HRTF_PATH; HRTFPath = ss.str(); free(dataDir); } } return HRTFPath; }
/***************************************************************************** * Directories configuration *****************************************************************************/ static int vlclua_datadir( lua_State *L ) { char *psz_data = config_GetDataDir(); lua_pushstring( L, psz_data ); free( psz_data ); return 1; }
bool X11Factory::init() { // make sure xlib is safe-thread if( !vlc_xlib_init( VLC_OBJECT( getIntf() ) ) ) { msg_Err( getIntf(), "initializing xlib for multi-threading failed" ); return false; } // Create the X11 display m_pDisplay = new X11Display( getIntf() ); // Get the display Display *pDisplay = m_pDisplay->getDisplay(); if( pDisplay == NULL ) { // Initialization failed return false; } // Create the timer loop m_pTimerLoop = new X11TimerLoop( getIntf(), ConnectionNumber( pDisplay ) ); // Initialize the resource path char *datadir = config_GetUserDir( VLC_DATA_DIR ); m_resourcePath.push_back( (std::string)datadir + "/skins2" ); free( datadir ); m_resourcePath.push_back( (std::string)"share/skins2" ); datadir = config_GetDataDir(); m_resourcePath.push_back( (std::string)datadir + "/skins2" ); free( datadir ); // Determine the monitor geometry getDefaultGeometry( &m_screenWidth, &m_screenHeight ); // list all available monitors int num_screen; XineramaScreenInfo* info = XineramaQueryScreens( pDisplay, &num_screen ); if( info ) { msg_Dbg( getIntf(), "number of monitors detected : %i", num_screen ); for( int i = 0; i < num_screen; i++ ) msg_Dbg( getIntf(), " monitor #%i : %ix%i at +%i+%i", i, info[i].width, info[i].height, info[i].x_org, info[i].y_org ); XFree( info ); } return true; }
int vlclua_dir_list( vlc_object_t *p_this, const char *luadirname, char ***pppsz_dir_list ) { #define MAX_DIR_LIST_SIZE 5 *pppsz_dir_list = malloc(MAX_DIR_LIST_SIZE*sizeof(char *)); if (!*pppsz_dir_list) return VLC_EGENERIC; char **ppsz_dir_list = *pppsz_dir_list; int i = 0; char *datadir = config_GetUserDir( VLC_DATA_DIR ); if( likely(datadir != NULL) && likely(asprintf( &ppsz_dir_list[i], "%s"DIR_SEP"lua"DIR_SEP"%s", datadir, luadirname ) != -1) ) i++; free( datadir ); #if !(defined(__APPLE__) || defined(WIN32) || defined(__OS2__)) char *psz_libpath = config_GetLibDir(); if( likely(psz_libpath != NULL) ) { if( likely(asprintf( &ppsz_dir_list[i], "%s"DIR_SEP"lua"DIR_SEP"%s", psz_libpath, luadirname ) != -1) ) i++; free( psz_libpath ); } #endif char *psz_datapath = config_GetDataDir(); if( likely(psz_datapath != NULL) ) { if( likely(asprintf( &ppsz_dir_list[i], "%s"DIR_SEP"lua"DIR_SEP"%s", psz_datapath, luadirname ) != -1) ) i++; #if defined(__APPLE__) if( likely(asprintf( &ppsz_dir_list[i], "%s"DIR_SEP"share"DIR_SEP"lua"DIR_SEP"%s", psz_datapath, luadirname ) != -1) ) i++; #endif free( psz_datapath ); } ppsz_dir_list[i] = NULL; assert( i < MAX_DIR_LIST_SIZE); return VLC_SUCCESS; }
/** * ProjectM update thread which do the rendering * @param p_this: the p_thread object */ static void *Thread( void *p_data ) { filter_t *p_filter = (filter_t*)p_data; filter_sys_t *p_sys = p_filter->p_sys; video_format_t fmt; vlc_gl_t *gl; unsigned int i_last_width = 0; unsigned int i_last_height = 0; locale_t loc; locale_t oldloc; projectM *p_projectm; #ifndef HAVE_PROJECTM2 char *psz_config; #else char *psz_preset_path; char *psz_title_font; char *psz_menu_font; projectM::Settings settings; #endif vlc_savecancel(); /* Create the openGL provider */ p_sys->p_vout = (vout_thread_t *)vlc_object_create( p_filter, sizeof(vout_thread_t) ); if( !p_sys->p_vout ) goto error; /* */ video_format_Init( &fmt, 0 ); video_format_Setup( &fmt, VLC_CODEC_RGB32, p_sys->i_width, p_sys->i_height, 0, 1 ); fmt.i_sar_num = 1; fmt.i_sar_den = 1; vout_display_state_t state; memset( &state, 0, sizeof(state) ); state.cfg.display.sar.num = 1; state.cfg.display.sar.den = 1; state.cfg.is_display_filled = true; state.cfg.zoom.num = 1; state.cfg.zoom.den = 1; state.sar.num = 1; state.sar.den = 1; p_sys->p_vd = vout_NewDisplay( p_sys->p_vout, &fmt, &state, "opengl", 300000, 1000000 ); if( !p_sys->p_vd ) { vlc_object_release( p_sys->p_vout ); goto error; } var_Create( p_sys->p_vout, "fullscreen", VLC_VAR_BOOL ); var_AddCallback( p_sys->p_vout, "fullscreen", VoutCallback, p_sys->p_vd ); gl = vout_GetDisplayOpengl( p_sys->p_vd ); if( !gl ) { vout_DeleteDisplay( p_sys->p_vd, NULL ); vlc_object_release( p_sys->p_vout ); goto error; } /* Work-around the projectM locale bug */ loc = newlocale (LC_NUMERIC_MASK, "C", NULL); oldloc = uselocale (loc); /* Create the projectM object */ #ifndef HAVE_PROJECTM2 psz_config = var_InheritString( p_filter, "projectm-config" ); p_projectm = new projectM( psz_config ); free( psz_config ); #else psz_preset_path = var_InheritString( p_filter, "projectm-preset-path" ); #ifdef WIN32 if ( psz_preset_path == NULL ) { char *psz_data_path = config_GetDataDir( p_filter ); asprintf( &psz_preset_path, "%s" DIR_SEP "visualization", psz_data_path ); free( psz_data_path ); } #endif psz_title_font = var_InheritString( p_filter, "projectm-title-font" ); psz_menu_font = var_InheritString( p_filter, "projectm-menu-font" ); settings.meshX = var_InheritInteger( p_filter, "projectm-meshx" ); settings.meshY = var_InheritInteger( p_filter, "projectm-meshy" ); settings.fps = 35; settings.textureSize = var_InheritInteger( p_filter, "projectm-texture-size" ); settings.windowWidth = p_sys->i_width; settings.windowHeight = p_sys->i_height; settings.presetURL = psz_preset_path; settings.titleFontURL = psz_title_font; settings.menuFontURL = psz_menu_font; settings.smoothPresetDuration = 5; settings.presetDuration = 30; settings.beatSensitivity = 10; settings.aspectCorrection = 1; settings.easterEgg = 1; settings.shuffleEnabled = 1; p_projectm = new projectM( settings ); free( psz_menu_font ); free( psz_title_font ); free( psz_preset_path ); #endif /* HAVE_PROJECTM2 */ p_sys->i_buffer_size = p_projectm->pcm()->maxsamples; p_sys->p_buffer = (float*)calloc( p_sys->i_buffer_size, sizeof( float ) ); vlc_sem_post( &p_sys->ready ); /* Choose a preset randomly or projectM will always show the first one */ if ( p_projectm->getPlaylistSize() > 0 ) p_projectm->selectPreset( (unsigned)vlc_mrand48() % p_projectm->getPlaylistSize() ); /* */ for( ;; ) { const mtime_t i_deadline = mdate() + CLOCK_FREQ / 50; /* 50 fps max */ /* Manage the events */ vout_ManageDisplay( p_sys->p_vd, true ); if( p_sys->p_vd->cfg->display.width != i_last_width || p_sys->p_vd->cfg->display.height != i_last_height ) { /* FIXME it is not perfect as we will have black bands */ vout_display_place_t place; vout_display_PlacePicture( &place, &p_sys->p_vd->source, p_sys->p_vd->cfg, false ); p_projectm->projectM_resetGL( place.width, place.height ); i_last_width = p_sys->p_vd->cfg->display.width; i_last_height = p_sys->p_vd->cfg->display.height; } /* Render the image and swap the buffers */ vlc_mutex_lock( &p_sys->lock ); if( p_sys->i_nb_samples > 0 ) { p_projectm->pcm()->addPCMfloat( p_sys->p_buffer, p_sys->i_nb_samples ); p_sys->i_nb_samples = 0; } if( p_sys->b_quit ) { vlc_mutex_unlock( &p_sys->lock ); delete p_projectm; vout_DeleteDisplay( p_sys->p_vd, NULL ); vlc_object_release( p_sys->p_vout ); if (loc != (locale_t)0) { uselocale (oldloc); freelocale (loc); } return NULL; } vlc_mutex_unlock( &p_sys->lock ); p_projectm->renderFrame(); /* */ mwait( i_deadline ); if( !vlc_gl_Lock(gl) ) { vlc_gl_Swap( gl ); vlc_gl_Unlock( gl ); } } abort(); error: p_sys->b_error = true; vlc_sem_post( &p_sys->ready ); return NULL; }
bool OS2Factory::init() { PCSZ vlc_name = "VLC Media Player"; PCSZ vlc_icon = "VLC_ICON"; PCSZ vlc_class = "SkinWindowClass"; MorphToPM(); m_hab = WinInitialize( 0 ); // save FPU CW unsigned saved_cw = _control87( 0, 0 ); // WinCreateMsgQueue() changes FPU CW but does not restore it m_hmq = WinCreateMsgQueue( m_hab, 0 ); // restore FPU CW _control87( saved_cw, MCW_EM | MCW_IC | MCW_RC | MCW_PC ); if( !WinRegisterClass( m_hab, vlc_class, OS2Factory::OS2Proc, CS_SIZEREDRAW, sizeof( PVOID ))) { msg_Err( getIntf(), "cannot register window class" ); return false; } ULONG flFrame = FCF_SYSMENU | FCF_MINBUTTON | FCF_TASKLIST /* | FCF_ICON */; m_hParentWindow = WinCreateStdWindow( HWND_DESKTOP, 0, &flFrame, vlc_class, vlc_name, 0, NULLHANDLE, 0/* ID_VLC_ICON */, &m_hParentClientWindow ); if( !m_hParentWindow ) { msg_Err( getIntf(), "cannot create parent window" ); return false; } // Store with it a pointer to the interface thread WinSetWindowPtr( m_hParentClientWindow, 0, getIntf()); WinSetWindowPos( m_hParentWindow, HWND_TOP, 0, 0, 0, 0, SWP_ACTIVATE | SWP_ZORDER | SWP_MOVE | SWP_SIZE | SWP_SHOW ); // Set the mouse pointer to a default arrow changeCursor( kDefaultArrow ); // Initialize the resource path char *datadir = config_GetUserDir( VLC_DATA_DIR ); m_resourcePath.push_back( (string)datadir + "\\skins" ); free( datadir ); datadir = config_GetDataDir(); m_resourcePath.push_back( (string)datadir + "\\skins" ); m_resourcePath.push_back( (string)datadir + "\\skins2" ); m_resourcePath.push_back( (string)datadir + "\\share\\skins" ); m_resourcePath.push_back( (string)datadir + "\\share\\skins2" ); m_resourcePath.push_back( (string)datadir + "\\vlc\\skins" ); m_resourcePath.push_back( (string)datadir + "\\vlc\\skins2" ); free( datadir ); // All went well return true; }
/***************************************************************************** * Activate: initialize and create stuff *****************************************************************************/ static int Open( vlc_object_t *p_this ) { intf_thread_t *p_intf = (intf_thread_t*)p_this; intf_sys_t *p_sys; char *psz_address; char *psz_cert = NULL, *psz_key = NULL, *psz_ca = NULL, *psz_crl = NULL; int i_port = 0; char *psz_src = NULL; psz_address = var_CreateGetNonEmptyString( p_intf, "http-host" ); if( psz_address != NULL ) { char *psz_parser = strrchr( psz_address, ':' ); if( psz_parser ) { *psz_parser++ = '\0'; i_port = atoi( psz_parser ); } } else psz_address = strdup(""); p_intf->p_sys = p_sys = malloc( sizeof( intf_sys_t ) ); if( !p_intf->p_sys ) { free( psz_address ); return( VLC_ENOMEM ); } p_sys->p_playlist = pl_Get( p_this ); p_sys->p_input = NULL; p_sys->p_vlm = NULL; p_sys->psz_address = psz_address; p_sys->i_port = i_port; p_sys->p_art_handler = NULL; /* determine file handler associations */ p_sys->i_handlers = 0; p_sys->pp_handlers = NULL; #if defined( HAVE_FORK ) || defined( WIN32 ) psz_src = var_InheritString( p_intf, "http-handlers" ); if( psz_src != NULL ) { char *p = psz_src; while( p != NULL ) { http_association_t *p_handler; char *psz_ext = p; char *psz_program, *psz_options; p = strchr( p, '=' ); if( p == NULL ) break; *p++ = '\0'; psz_program = p; p = strchr( p, ',' ); if( p != NULL ) *p++ = '\0'; p_handler = malloc( sizeof( http_association_t ) ); p_handler->psz_ext = strdup( psz_ext ); psz_options = FirstWord( psz_program, psz_program ); p_handler->i_argc = 0; p_handler->ppsz_argv = NULL; TAB_APPEND( p_handler->i_argc, p_handler->ppsz_argv, strdup( psz_program ) ); while( psz_options != NULL && *psz_options ) { char *psz_next = FirstWord( psz_options, psz_options ); TAB_APPEND( p_handler->i_argc, p_handler->ppsz_argv, strdup( psz_options ) ); psz_options = psz_next; } /* NULL will be appended later on */ TAB_APPEND( p_sys->i_handlers, p_sys->pp_handlers, p_handler ); } free( psz_src ); } #endif /* determine SSL configuration */ psz_cert = var_InheritString( p_intf, "http-intf-cert" ); if ( psz_cert != NULL ) { msg_Dbg( p_intf, "enabling TLS for HTTP interface (cert file: %s)", psz_cert ); psz_key = var_InheritString( p_intf, "http-intf-key" ); psz_ca = var_InheritString( p_intf, "http-intf-ca" ); psz_crl = var_InheritString( p_intf, "http-intf-crl" ); if( i_port <= 0 ) i_port = 8443; } else { if( i_port <= 0 ) i_port= 8080; } msg_Dbg( p_intf, "base %s:%d", psz_address, i_port ); p_sys->p_httpd_host = httpd_TLSHostNew( VLC_OBJECT(p_intf), psz_address, i_port, psz_cert, psz_key, psz_ca, psz_crl ); free( psz_cert ); free( psz_key ); free( psz_ca ); free( psz_crl ); if( p_sys->p_httpd_host == NULL ) { msg_Err( p_intf, "cannot listen on %s:%d", psz_address, i_port ); free( p_sys->psz_address ); free( p_sys ); return VLC_EGENERIC; } else { char psz_tmp[NI_MAXHOST + 6]; /* Ugly hack to run several HTTP servers on different ports */ snprintf( psz_tmp, sizeof (psz_tmp), "%s:%d", psz_address, i_port + 1 ); var_Create(p_intf->p_libvlc, "http-host", VLC_VAR_STRING ); var_SetString( p_intf->p_libvlc, "http-host", psz_tmp ); } p_sys->i_files = 0; p_sys->pp_files = NULL; psz_src = var_InheritString( p_intf, "http-src" ); if( psz_src == NULL ) { char *data_path = config_GetDataDir( p_intf ); if( asprintf( &psz_src, "%s" DIR_SEP "http", data_path ) == -1 ) psz_src = NULL; free( data_path ); } if( psz_src == NULL ) { msg_Err( p_intf, "invalid web interface source directory" ); goto failed; } /* remove trainling \ or / */ if( psz_src[strlen( psz_src ) - 1] == '\\' || psz_src[strlen( psz_src ) - 1] == '/' ) { psz_src[strlen( psz_src ) - 1] = '\0'; } ParseDirectory( p_intf, psz_src, psz_src ); if( p_sys->i_files <= 0 ) { msg_Err( p_intf, "cannot find any file in directory %s", psz_src ); goto failed; } if( var_InheritBool( p_intf, "http-album-art" ) ) { /* FIXME: we're leaking h */ httpd_handler_sys_t *h = malloc( sizeof( httpd_handler_sys_t ) ); if( !h ) goto failed; h->file.p_intf = p_intf; h->file.file = NULL; h->file.name = NULL; /* TODO: use ACL and login/password stuff here too */ h->p_handler = httpd_HandlerNew( p_sys->p_httpd_host, "/art", NULL, NULL, NULL, ArtCallback, h ); p_sys->p_art_handler = h->p_handler; } free( psz_src ); return VLC_SUCCESS; failed: free( psz_src ); free( p_sys->pp_files ); httpd_HostDelete( p_sys->p_httpd_host ); free( p_sys->psz_address ); free( p_sys ); return VLC_EGENERIC; }
/***************************************************************************** * ItemChange: Playlist item change callback *****************************************************************************/ static int ItemChange( vlc_object_t *p_this, const char *psz_var, vlc_value_t oldval, vlc_value_t newval, void *param ) { VLC_UNUSED(psz_var); VLC_UNUSED(oldval); VLC_UNUSED(newval); char psz_tmp[MAX_LENGTH]; char psz_notify[MAX_LENGTH]; char *psz_title; char *psz_artist; char *psz_album; char *psz_arturl; input_thread_t *p_input = playlist_CurrentInput( (playlist_t*)p_this ); intf_thread_t *p_intf = param; intf_sys_t *p_sys = p_intf->p_sys; if( !p_input ) return VLC_SUCCESS; if( p_input->b_dead ) { /* Not playing anything ... */ vlc_object_release( p_input ); return VLC_SUCCESS; } /* Wait a tad so the meta has been fetched * FIXME that's awfully wrong */ msleep( 10000 ); /* Playing something ... */ input_item_t *p_input_item = input_GetItem( p_input ); psz_title = input_item_GetTitleFbName( p_input_item ); /* We need at least a title */ if( EMPTY_STR( psz_title ) ) { free( psz_title ); vlc_object_release( p_input ); return VLC_SUCCESS; } psz_artist = input_item_GetArtist( p_input_item ); psz_album = input_item_GetAlbum( p_input_item ); if( !EMPTY_STR( psz_artist ) ) { if( !EMPTY_STR( psz_album ) ) snprintf( psz_tmp, MAX_LENGTH, "<b>%s</b>\n%s\n[%s]", psz_title, psz_artist, psz_album ); else snprintf( psz_tmp, MAX_LENGTH, "<b>%s</b>\n%s", psz_title, psz_artist ); } else snprintf( psz_tmp, MAX_LENGTH, "<b>%s</b>", psz_title ); free( psz_title ); free( psz_artist ); free( psz_album ); GdkPixbuf *pix = NULL; psz_arturl = input_item_GetArtURL( p_input_item ); vlc_object_release( p_input ); if( psz_arturl ) { char *psz = make_path( psz_arturl ); free( psz_arturl ); psz_arturl = psz; } if( psz_arturl ) { /* scale the art to show it in notify popup */ GError *p_error = NULL; pix = gdk_pixbuf_new_from_file_at_scale( psz_arturl, 72, 72, TRUE, &p_error ); } else /* else we show state-of-the art logo */ { /* First try to get an icon from the current theme. */ GtkIconTheme* p_theme = gtk_icon_theme_get_default(); pix = gtk_icon_theme_load_icon( p_theme, "vlc", 72, 0, NULL); if( !pix ) { /* Load icon from share/ */ GError *p_error = NULL; char *psz_pixbuf; char *psz_data = config_GetDataDir( p_this ); if( asprintf( &psz_pixbuf, "%s/icons/48x48/vlc.png", psz_data ) >= 0 ) { pix = gdk_pixbuf_new_from_file( psz_pixbuf, &p_error ); free( psz_pixbuf ); } free( psz_data ); } } free( psz_arturl ); /* we need to replace '&' with '&' because '&' is a keyword of * notification-daemon parser */ const int i_len = strlen( psz_tmp ); int i_notify = 0; for( int i = 0; i < i_len && i_notify < ( MAX_LENGTH - 5 ); i++ ) { /* we use MAX_LENGTH - 5 because if the last char of psz_tmp is '&' * we will need 5 more characters: 'amp;\0' . * however that's unlikely to happen because the last char is '\0' */ if( psz_tmp[i] != '&' ) { psz_notify[i_notify] = psz_tmp[i]; } else { strcpy( &psz_notify[i_notify], "&" ); i_notify += 4; } i_notify++; } psz_notify[i_notify] = '\0'; vlc_mutex_lock( &p_sys->lock ); Notify( p_this, psz_notify, pix, p_intf ); vlc_mutex_unlock( &p_sys->lock ); return VLC_SUCCESS; }
bool Win32Factory::init() { LPCTSTR vlc_name = TEXT("VLC Media Player"); LPCTSTR vlc_icon = TEXT("VLC_ICON"); LPCTSTR vlc_class = TEXT("SkinWindowClass"); // Get instance handle m_hInst = GetModuleHandle( NULL ); if( m_hInst == NULL ) { msg_Err( getIntf(), "Cannot get module handle" ); } // Create window class WNDCLASS skinWindowClass; skinWindowClass.style = CS_DBLCLKS; skinWindowClass.lpfnWndProc = (WNDPROC)Win32Factory::Win32Proc; skinWindowClass.lpszClassName = vlc_class; skinWindowClass.lpszMenuName = NULL; skinWindowClass.cbClsExtra = 0; skinWindowClass.cbWndExtra = 0; skinWindowClass.hbrBackground = NULL; skinWindowClass.hCursor = LoadCursor( NULL, IDC_ARROW ); skinWindowClass.hIcon = LoadIcon( m_hInst, vlc_icon ); skinWindowClass.hInstance = m_hInst; // Register class and check it if( !RegisterClass( &skinWindowClass ) ) { WNDCLASS wndclass; // Check why it failed. If it's because the class already exists // then fine, otherwise return with an error. if( !GetClassInfo( m_hInst, vlc_class, &wndclass ) ) { msg_Err( getIntf(), "cannot register window class" ); return false; } } // Create Window m_hParentWindow = CreateWindowEx( WS_EX_TOOLWINDOW, vlc_class, vlc_name, WS_POPUP | WS_SYSMENU | WS_MINIMIZEBOX, -200, -200, 0, 0, 0, 0, m_hInst, 0 ); if( m_hParentWindow == NULL ) { msg_Err( getIntf(), "cannot create parent window" ); return false; } // Store with it a pointer to the interface thread SetWindowLongPtr( m_hParentWindow, GWLP_USERDATA, (LONG_PTR)getIntf() ); // We do it this way otherwise CreateWindowEx will fail // if WS_EX_LAYERED is not supported SetWindowLongPtr( m_hParentWindow, GWL_EXSTYLE, GetWindowLongPtr( m_hParentWindow, GWL_EXSTYLE ) | WS_EX_LAYERED ); ShowWindow( m_hParentWindow, SW_SHOW ); // Initialize the systray icon m_trayIcon.cbSize = sizeof( NOTIFYICONDATA ); m_trayIcon.hWnd = m_hParentWindow; m_trayIcon.uID = 42; m_trayIcon.uFlags = NIF_ICON|NIF_TIP|NIF_MESSAGE; m_trayIcon.uCallbackMessage = MY_WM_TRAYACTION; m_trayIcon.hIcon = LoadIcon( m_hInst, vlc_icon ); // _tcscpy( m_trayIcon.szTip, vlc_name ); strcpy(m_trayIcon.szTip, vlc_name); // sunqueen modify // Show the systray icon if needed if( var_InheritBool( getIntf(), "skins2-systray" ) ) { addInTray(); } // Show the task in the task bar if needed if( var_InheritBool( getIntf(), "skins2-taskbar" ) ) { addInTaskBar(); } // Initialize the OLE library (for drag & drop) OleInitialize( NULL ); // Initialize the resource path char *datadir = config_GetUserDir( VLC_DATA_DIR ); m_resourcePath.push_back( (string)datadir + "\\skins" ); free( datadir ); datadir = config_GetDataDir(); m_resourcePath.push_back( (string)datadir + "\\skins" ); m_resourcePath.push_back( (string)datadir + "\\skins2" ); m_resourcePath.push_back( (string)datadir + "\\share\\skins" ); m_resourcePath.push_back( (string)datadir + "\\share\\skins2" ); free( datadir ); // Enumerate all monitors available EnumDisplayMonitors( NULL, NULL, MonitorEnumProc, (LPARAM)&m_monitorList ); int num = 0; for( list<HMONITOR>::iterator it = m_monitorList.begin(); it != m_monitorList.end(); ++it, num++ ) { MONITORINFO mi; mi.cbSize = sizeof( MONITORINFO ); if( GetMonitorInfo( *it, &mi ) ) { msg_Dbg( getIntf(), "monitor #%i, %ldx%ld at +%ld+%ld", num, mi.rcMonitor.right - mi.rcMonitor.left, mi.rcMonitor.bottom - mi.rcMonitor.top, mi.rcMonitor.left, mi.rcMonitor.top ); } } // All went well return true; }
/** * ProjectM update thread which do the rendering * @param p_this: the p_thread object */ static void *Thread( void *p_data ) { filter_t *p_filter = (filter_t*)p_data; filter_sys_t *p_sys = p_filter->p_sys; vlc_gl_t *gl = p_sys->gl; locale_t loc; locale_t oldloc; projectM *p_projectm; #ifndef HAVE_PROJECTM2 char *psz_config; #else char *psz_preset_path; char *psz_title_font; char *psz_menu_font; projectM::Settings settings; #endif vlc_gl_MakeCurrent( gl ); /* Work-around the projectM locale bug */ loc = newlocale (LC_NUMERIC_MASK, "C", NULL); oldloc = uselocale (loc); /* Create the projectM object */ #ifndef HAVE_PROJECTM2 psz_config = var_InheritString( p_filter, "projectm-config" ); p_projectm = new projectM( psz_config ); free( psz_config ); #else psz_preset_path = var_InheritString( p_filter, "projectm-preset-path" ); #ifdef _WIN32 if ( psz_preset_path == NULL ) { char *psz_data_path = config_GetDataDir(); asprintf( &psz_preset_path, "%s" DIR_SEP "visualization", psz_data_path ); free( psz_data_path ); } #endif psz_title_font = var_InheritString( p_filter, "projectm-title-font" ); psz_menu_font = var_InheritString( p_filter, "projectm-menu-font" ); settings.meshX = var_InheritInteger( p_filter, "projectm-meshx" ); settings.meshY = var_InheritInteger( p_filter, "projectm-meshy" ); settings.fps = 35; settings.textureSize = var_InheritInteger( p_filter, "projectm-texture-size" ); settings.windowWidth = var_InheritInteger( p_filter, "projectm-width" ); settings.windowHeight = var_CreateGetInteger( p_filter, "projectm-height" ); settings.presetURL = psz_preset_path; settings.titleFontURL = psz_title_font; settings.menuFontURL = psz_menu_font; settings.smoothPresetDuration = 5; settings.presetDuration = 30; settings.beatSensitivity = 10; settings.aspectCorrection = 1; settings.easterEgg = 1; settings.shuffleEnabled = 1; settings.softCutRatingsEnabled= false; p_projectm = new projectM( settings ); free( psz_menu_font ); free( psz_title_font ); free( psz_preset_path ); #endif /* HAVE_PROJECTM2 */ p_sys->i_buffer_size = p_projectm->pcm()->maxsamples; p_sys->p_buffer = (float*)calloc( p_sys->i_buffer_size, sizeof( float ) ); /* Choose a preset randomly or projectM will always show the first one */ if ( p_projectm->getPlaylistSize() > 0 ) p_projectm->selectPreset( (unsigned)vlc_mrand48() % p_projectm->getPlaylistSize() ); /* */ for( ;; ) { const mtime_t i_deadline = mdate() + CLOCK_FREQ / 50; /* 50 fps max */ /* Manage the events */ unsigned width, height; bool quit; if( vlc_gl_surface_CheckSize( gl, &width, &height ) ) p_projectm->projectM_resetGL( width, height ); /* Render the image and swap the buffers */ vlc_mutex_lock( &p_sys->lock ); if( p_sys->i_nb_samples > 0 ) { p_projectm->pcm()->addPCMfloat( p_sys->p_buffer, p_sys->i_nb_samples ); p_sys->i_nb_samples = 0; } quit = p_sys->b_quit; vlc_mutex_unlock( &p_sys->lock ); if( quit ) break; p_projectm->renderFrame(); /* */ mwait( i_deadline ); if( !vlc_gl_Lock(gl) ) { vlc_gl_Swap( gl ); vlc_gl_Unlock( gl ); } } delete p_projectm; if (loc != (locale_t)0) { uselocale (oldloc); freelocale (loc); } vlc_gl_ReleaseCurrent( gl ); return NULL; }
bool Win32Factory::init() { const char* vlc_name = "VLC Media Player"; const char* vlc_icon = "VLC_ICON"; const char* vlc_class = "SkinWindowClass"; // Get instance handle m_hInst = GetModuleHandle( NULL ); if( m_hInst == NULL ) { msg_Err( getIntf(), "Cannot get module handle" ); } // Create window class WNDCLASS skinWindowClass; skinWindowClass.style = CS_DBLCLKS; skinWindowClass.lpfnWndProc = (WNDPROC)Win32Factory::Win32Proc; skinWindowClass.lpszClassName = _T(vlc_class); skinWindowClass.lpszMenuName = NULL; skinWindowClass.cbClsExtra = 0; skinWindowClass.cbWndExtra = 0; skinWindowClass.hbrBackground = NULL; skinWindowClass.hCursor = LoadCursor( NULL, IDC_ARROW ); skinWindowClass.hIcon = LoadIcon( m_hInst, _T(vlc_icon) ); skinWindowClass.hInstance = m_hInst; // Register class and check it if( !RegisterClass( &skinWindowClass ) ) { WNDCLASS wndclass; // Check why it failed. If it's because the class already exists // then fine, otherwise return with an error. if( !GetClassInfo( m_hInst, _T(vlc_class), &wndclass ) ) { msg_Err( getIntf(), "cannot register window class" ); return false; } } // Create Window m_hParentWindow = CreateWindowEx( WS_EX_TOOLWINDOW, _T(vlc_class), _T(vlc_name), WS_POPUP | WS_SYSMENU | WS_MINIMIZEBOX, -200, -200, 0, 0, 0, 0, m_hInst, 0 ); if( m_hParentWindow == NULL ) { msg_Err( getIntf(), "cannot create parent window" ); return false; } // Store with it a pointer to the interface thread SetWindowLongPtr( m_hParentWindow, GWLP_USERDATA, (LONG_PTR)getIntf() ); // We do it this way otherwise CreateWindowEx will fail // if WS_EX_LAYERED is not supported SetWindowLongPtr( m_hParentWindow, GWL_EXSTYLE, GetWindowLongPtr( m_hParentWindow, GWL_EXSTYLE ) | WS_EX_LAYERED ); ShowWindow( m_hParentWindow, SW_SHOW ); // Initialize the systray icon m_trayIcon.cbSize = sizeof( NOTIFYICONDATA ); m_trayIcon.hWnd = m_hParentWindow; m_trayIcon.uID = 42; m_trayIcon.uFlags = NIF_ICON|NIF_TIP|NIF_MESSAGE; m_trayIcon.uCallbackMessage = MY_WM_TRAYACTION; m_trayIcon.hIcon = LoadIcon( m_hInst, _T(vlc_icon) ); strcpy( m_trayIcon.szTip, vlc_name ); // Show the systray icon if needed if( var_InheritBool( getIntf(), "skins2-systray" ) ) { addInTray(); } // Show the task in the task bar if needed if( var_InheritBool( getIntf(), "skins2-taskbar" ) ) { addInTaskBar(); } // Initialize the OLE library (for drag & drop) OleInitialize( NULL ); // Initialize the resource path char *datadir = config_GetUserDir( VLC_DATA_DIR ); m_resourcePath.push_back( (string)datadir + "\\skins" ); free( datadir ); datadir = config_GetDataDir( getIntf() ); m_resourcePath.push_back( (string)datadir + "\\skins" ); m_resourcePath.push_back( (string)datadir + "\\skins2" ); m_resourcePath.push_back( (string)datadir + "\\share\\skins" ); m_resourcePath.push_back( (string)datadir + "\\share\\skins2" ); free( datadir ); // All went well return true; }
/***************************************************************************** * Initialize and launch the interface *****************************************************************************/ static void *Thread( void *obj ) { intf_thread_t *p_intf = (intf_thread_t *)obj; const char *p_args[] = { "vlc" }; int i_args = sizeof(p_args)/sizeof(char *); char **pp_args = (char **)p_args; HildonProgram *program; HildonWindow *window; GtkWidget *main_vbox, *bottom_hbox; GtkWidget *video, *seekbar; GtkWidget *play_button, *prev_button, *next_button; GtkWidget *stop_button, *playlist_button; gtk_init( &i_args, &pp_args ); program = HILDON_PROGRAM( hildon_program_get_instance() ); g_set_application_name( "VLC Media Player" ); window = HILDON_WINDOW( hildon_window_new() ); hildon_program_add_window( program, window ); gtk_object_set_data( GTK_OBJECT( window ), "p_intf", p_intf ); p_intf->p_sys->p_main_window = window; g_signal_connect( GTK_WIDGET(window), "key-press-event", G_CALLBACK( key_cb ), p_intf ); g_signal_connect (GTK_WIDGET(window), "delete_event", GTK_SIGNAL_FUNC( quit_event), p_intf ); // A little theming char *psz_rc_file = NULL; char *psz_data = config_GetDataDir( p_intf ); if( asprintf( &psz_rc_file, "%s/maemo/vlc_intf.rc", psz_data ) != -1 ) { gtk_rc_parse( psz_rc_file ); free( psz_rc_file ); } free( psz_data ); // We create the main vertical box main_vbox = gtk_vbox_new( FALSE, 0 ); gtk_container_add( GTK_CONTAINER( window ), main_vbox ); // Menubar GtkWidget *main_menu = create_menu( p_intf ); #ifdef HAVE_MAEMO hildon_window_set_menu( HILDON_WINDOW( p_intf->p_sys->p_main_window ), GTK_MENU( main_menu ) ); #else GtkWidget *menu_bar = gtk_menu_bar_new (); GtkWidget *item = gtk_menu_item_new_with_label ("Menu"); gtk_menu_bar_append(menu_bar, item); gtk_menu_item_set_submenu(GTK_MENU_ITEM(item), main_menu); gtk_widget_show_all (menu_bar); gtk_box_pack_start(GTK_BOX(main_vbox), menu_bar, FALSE, FALSE, 0); #endif // We put first the embedded video video = gtk_event_box_new(); GdkColor black = {0,0,0,0}; gtk_widget_modify_bg(video, GTK_STATE_NORMAL, &black); p_intf->p_sys->p_video_window = video; gtk_box_pack_start( GTK_BOX( main_vbox ), video, TRUE, TRUE, 0 ); create_playlist( p_intf ); gtk_box_pack_start( GTK_BOX( main_vbox ), p_intf->p_sys->p_playlist_window, TRUE, TRUE, 0 ); // We put the horizontal box which contains all the buttons p_intf->p_sys->p_control_window = bottom_hbox = gtk_hbox_new( FALSE, 0 ); // We create the buttons play_button = gtk_button_new(); gtk_button_set_image( GTK_BUTTON( play_button ), gtk_image_new_from_stock( "vlc-play", GTK_ICON_SIZE_BUTTON ) ); p_intf->p_sys->p_play_button = play_button; stop_button = gtk_button_new(); gtk_button_set_image( GTK_BUTTON( stop_button ), gtk_image_new_from_stock( "vlc-stop", GTK_ICON_SIZE_BUTTON ) ); prev_button = gtk_button_new(); gtk_button_set_image( GTK_BUTTON( prev_button ), gtk_image_new_from_stock( "vlc-previous", GTK_ICON_SIZE_BUTTON ) ); next_button = gtk_button_new(); gtk_button_set_image( GTK_BUTTON( next_button ), gtk_image_new_from_stock( "vlc-next", GTK_ICON_SIZE_BUTTON ) ); playlist_button = gtk_button_new(); gtk_button_set_image( GTK_BUTTON( playlist_button ), gtk_image_new_from_stock( "vlc-playlist", GTK_ICON_SIZE_BUTTON ) ); seekbar = hildon_seekbar_new(); p_intf->p_sys->p_seekbar = HILDON_SEEKBAR( seekbar ); // We add them to the hbox gtk_box_pack_start( GTK_BOX( bottom_hbox ), play_button, FALSE, FALSE, 0 ); gtk_box_pack_start( GTK_BOX( bottom_hbox ), stop_button, FALSE, FALSE, 0 ); gtk_box_pack_start( GTK_BOX( bottom_hbox ), prev_button, FALSE, FALSE, 0 ); gtk_box_pack_start( GTK_BOX( bottom_hbox ), next_button, FALSE, FALSE, 0 ); gtk_box_pack_start( GTK_BOX( bottom_hbox ), playlist_button, FALSE, FALSE, 0 ); gtk_box_pack_start( GTK_BOX( bottom_hbox ), seekbar , TRUE , TRUE , 5 ); // We add the hbox to the main vbox gtk_box_pack_start( GTK_BOX( main_vbox ), bottom_hbox, FALSE, FALSE, 0 ); g_signal_connect( play_button, "clicked", G_CALLBACK( play_cb ), NULL ); g_signal_connect( stop_button, "clicked", G_CALLBACK( stop_cb ), NULL ); g_signal_connect( prev_button, "clicked", G_CALLBACK( prev_cb ), NULL ); g_signal_connect( next_button, "clicked", G_CALLBACK( next_cb ), NULL ); g_signal_connect( playlist_button, "clicked", G_CALLBACK( playlist_cb ), NULL ); g_signal_connect( seekbar, "change-value", G_CALLBACK( seekbar_changed_cb ), NULL ); gtk_widget_show_all( GTK_WIDGET( window ) ); gtk_widget_hide_all( p_intf->p_sys->p_playlist_window ); #if 1 /* HACK: Only one X11 client can subscribe to mouse button press events. * VLC currently handles those in the video display. * Force GTK to unsubscribe from mouse press and release events. */ Display *dpy = GDK_WINDOW_XDISPLAY( gtk_widget_get_window(p_intf->p_sys->p_video_window) ); Window w = GDK_WINDOW_XID( gtk_widget_get_window(p_intf->p_sys->p_video_window) ); XWindowAttributes attr; XGetWindowAttributes( dpy, w, &attr ); attr.your_event_mask &= ~(ButtonPressMask|ButtonReleaseMask); XSelectInput( dpy, w, attr.your_event_mask ); #endif // The embedded video is only ready after gtk_main and windows are shown g_idle_add( interface_ready, p_intf ); gtk_main(); delete_input( p_intf ); delete_playlist( p_intf ); gtk_object_destroy( GTK_OBJECT( main_menu ) ); gtk_object_destroy( GTK_OBJECT( window ) ); return NULL; }
/***************************************************************************** * ItemChange: Playlist item change callback *****************************************************************************/ static int ItemChange( vlc_object_t *p_this, const char *psz_var, vlc_value_t oldval, vlc_value_t newval, void *param ) { VLC_UNUSED(psz_var); VLC_UNUSED(oldval); VLC_UNUSED(newval); char psz_tmp[MAX_LENGTH]; char psz_notify[MAX_LENGTH]; char *psz_title = NULL; char *psz_artist = NULL; char *psz_album = NULL; char *psz_arturl = NULL; input_thread_t *p_input = playlist_CurrentInput( (playlist_t*) p_this ); intf_thread_t *p_intf = param; intf_sys_t *p_sys = p_intf->p_sys; if( !p_input ) return VLC_SUCCESS; if( p_input->b_dead ) { /* Not playing anything ... */ vlc_object_release( p_input ); return VLC_SUCCESS; } /* Wait a tad so the meta has been fetched * FIXME that's awfully wrong */ msleep( 1000*4 ); /* Playing something ... */ input_item_t *p_input_item = input_GetItem( p_input ); psz_artist = input_item_GetArtist( p_input_item ); psz_album = input_item_GetAlbum( p_input_item ); psz_title = input_item_GetTitleFbName( p_input_item ); if( EMPTY_STR( psz_title ) ) { /* Not enough metadata ... */ free( psz_title ); free( psz_artist ); free( psz_album ); vlc_object_release( p_input ); return VLC_SUCCESS; } if( EMPTY_STR( psz_artist ) ) { free( psz_artist ); psz_artist = NULL; } if( EMPTY_STR( psz_album ) ) { free( psz_album ); psz_album = NULL; } if( psz_artist && psz_album ) snprintf( psz_tmp, MAX_LENGTH, "<b>%s</b>\n%s\n[%s]", psz_title, psz_artist, psz_album ); else if( psz_artist ) snprintf( psz_tmp, MAX_LENGTH, "<b>%s</b>\n%s", psz_title, psz_artist ); else snprintf( psz_tmp, MAX_LENGTH, "<b>%s</b>", psz_title ); free( psz_title ); free( psz_artist ); free( psz_album ); GdkPixbuf *pix = NULL; psz_arturl = input_item_GetArtURL( p_input_item ); vlc_object_release( p_input ); if( psz_arturl && !strncmp( psz_arturl, "file://", 7 ) && decode_URI( psz_arturl + 7 ) ) { /* scale the art to show it in notify popup */ GError *p_error = NULL; pix = gdk_pixbuf_new_from_file_at_scale( &psz_arturl[7], 72, 72, TRUE, &p_error ); } else /* else we show state-of-the art logo */ { GError *p_error = NULL; char *psz_pixbuf; if( asprintf( &psz_pixbuf, "%s/vlc48x48.png", config_GetDataDir() ) >= 0 ) { pix = gdk_pixbuf_new_from_file( psz_pixbuf, &p_error ); free( psz_pixbuf ); } } free( psz_arturl ); /* we need to replace '&' with '&' because '&' is a keyword of * notification-daemon parser */ const int i_len = strlen( psz_tmp ); int i_notify = 0; for( int i = 0; i < i_len && i_notify < ( MAX_LENGTH - 5 ); i++ ) { /* we use MAX_LENGTH - 5 because if the last char of psz_tmp is '&' * we will need 5 more characters: 'amp;\0' . * however that's unlikely to happen because the last char is '\0' */ if( psz_tmp[i] != '&' ) { psz_notify[i_notify] = psz_tmp[i]; } else { snprintf( &psz_notify[i_notify], 6, "&" ); i_notify += 4; } i_notify++; } psz_notify[i_notify] = '\0'; vlc_mutex_lock( &p_sys->lock ); Notify( p_this, psz_notify, pix, p_intf ); vlc_mutex_unlock( &p_sys->lock ); return VLC_SUCCESS; }
int ArtCallback( httpd_handler_sys_t *p_args, httpd_handler_t *p_handler, char *_p_url, uint8_t *p_request, int i_type, uint8_t *p_in, int i_in, char *psz_remote_addr, char *psz_remote_host, uint8_t **pp_data, int *pi_data ) { VLC_UNUSED(p_handler); VLC_UNUSED(_p_url); VLC_UNUSED(i_type); VLC_UNUSED(p_in); VLC_UNUSED(i_in); VLC_UNUSED(psz_remote_addr); VLC_UNUSED(psz_remote_host); VLC_UNUSED(p_request); char *psz_art = NULL; intf_thread_t *p_intf = p_args->file.p_intf; intf_sys_t *p_sys = p_intf->p_sys; input_item_t *p_item = NULL; p_sys->p_input = playlist_CurrentInput( p_sys->p_playlist ); /* Workaround a stupid assert in input_GetItem */ if( p_sys->p_input && p_sys->p_input->p ) p_item = input_GetItem( p_sys->p_input ); if( p_item ) { psz_art = input_item_GetArtURL( p_item ); } if( psz_art ) { char *psz = make_path( psz_art ); free( psz_art ); psz_art = psz; } if( psz_art == NULL ) { msg_Dbg( p_intf, "didn't find any art, so use default" ); char *psz_src = var_InheritString( p_intf, "http-src" ); if( psz_src == NULL ) { char *data_path = config_GetDataDir( p_intf ); if( asprintf( &psz_src, "%s" DIR_SEP "http", data_path ) == -1 ) psz_src = NULL; free( data_path ); } if( asprintf( &psz_art, "%s" DIR_SEP "images" DIR_SEP "default_album_art.png", psz_src ) == -1 ) psz_art = NULL; free( psz_src ); } FILE *f = vlc_fopen( psz_art, "r" ); if( f == NULL ) { Callback404( &p_args->file, (char**)pp_data, pi_data ); free( psz_art ); return VLC_SUCCESS; } free( psz_art ); char *p_data = NULL; int i_data; FileLoad( f, &p_data, &i_data ); fclose( f ); char *psz_ext = strrchr( psz_art, '.' ); if( psz_ext ) psz_ext++; #define HEADER "Content-Type: image/%s\n" \ "Content-Length: %d\n" \ "\n" char *psz_header; int i_header_size = asprintf( &psz_header, HEADER, psz_ext, i_data ); #undef HEADER if( likely(i_header_size != -1) ) { *pp_data = malloc( i_header_size + i_data ); if( likely(*pp_data != NULL) ) { *pi_data = i_header_size + i_data; memcpy( *pp_data, psz_header, i_header_size ); memcpy( *pp_data+i_header_size, p_data, i_data ); } free( psz_header ); } free( p_data ); return VLC_SUCCESS; }