- oh how I despise windows, another evil hack to get proper detection of vlc plugins
This commit is contained in:
parent
e3c2719458
commit
093d22ce8b
|
@ -506,7 +506,8 @@ Intro::Intro(Program *program):
|
||||||
screen->w,
|
screen->w,
|
||||||
screen->h,
|
screen->h,
|
||||||
screen->format->BitsPerPixel,
|
screen->format->BitsPerPixel,
|
||||||
vlcPluginsPath);
|
vlcPluginsPath,
|
||||||
|
SystemFlags::VERBOSE_MODE_ENABLED);
|
||||||
player.PlayVideo();
|
player.PlayVideo();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
|
@ -11,6 +11,7 @@
|
||||||
#ifdef WIN32
|
#ifdef WIN32
|
||||||
#include <winsock2.h>
|
#include <winsock2.h>
|
||||||
#include <winsock.h>
|
#include <winsock.h>
|
||||||
|
#include <process.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include "math_wrapper.h"
|
#include "math_wrapper.h"
|
||||||
|
@ -2725,6 +2726,75 @@ int glestMain(int argc, char** argv) {
|
||||||
// printf("END ALLOC char 200\n");
|
// printf("END ALLOC char 200\n");
|
||||||
// return -1;
|
// return -1;
|
||||||
|
|
||||||
|
|
||||||
|
#if defined(WIN32)
|
||||||
|
//printf("*** VLC START ****\n");
|
||||||
|
//if(verboseEnabled) printf("Trying [%s]\n",getenv("VLC_PLUGIN_PATH"));
|
||||||
|
if(getenv("VLC_PLUGIN_PATH") == NULL) {
|
||||||
|
//printf("*** VLC C ****\n");
|
||||||
|
|
||||||
|
// For windows check registry for install path
|
||||||
|
std::string strValue = getRegKey("Software\\VideoLAN\\VLC", "InstallDir");
|
||||||
|
if(strValue != "") {
|
||||||
|
if(strValue.length() >= 2) {
|
||||||
|
if(strValue[0] == '"') {
|
||||||
|
strValue = strValue.erase(0);
|
||||||
|
}
|
||||||
|
if(strValue[strValue.length()-1] == '"') {
|
||||||
|
strValue = strValue.erase(strValue.length()-1);
|
||||||
|
}
|
||||||
|
if(strValue[strValue.length()-1] != '\\') {
|
||||||
|
strValue += "\\";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
strValue += "plugins";
|
||||||
|
string newstrValue = "VLC_PLUGIN_PATH=" + strValue;
|
||||||
|
_putenv(newstrValue.c_str());
|
||||||
|
//bool result = SetEnvironmentVariableA("VLC_PLUGIN_PATH",strValue.c_str());
|
||||||
|
|
||||||
|
//Open the registry key.
|
||||||
|
wstring subKey = L"Environment";
|
||||||
|
HKEY keyHandle;
|
||||||
|
DWORD dwDisposition;
|
||||||
|
RegCreateKeyEx(HKEY_CURRENT_USER,subKey.c_str(),0, NULL, 0, KEY_ALL_ACCESS, NULL, &keyHandle, &dwDisposition);
|
||||||
|
//Set the value.
|
||||||
|
std::auto_ptr<wchar_t> wstr(Ansi2WideString(strValue.c_str()));
|
||||||
|
|
||||||
|
wstring vlcPluginPath = wstring(wstr.get());
|
||||||
|
DWORD len = (DWORD) sizeof(wchar_t) * vlcPluginPath.length() + 1;
|
||||||
|
RegSetValueEx(keyHandle, L"VLC_PLUGIN_PATH", 0, REG_SZ, (PBYTE)vlcPluginPath.c_str(), len);
|
||||||
|
RegCloseKey(keyHandle);
|
||||||
|
|
||||||
|
subKey = L"System\\CurrentControlSet\\Control\\Session Manager\\Environment";
|
||||||
|
RegCreateKeyEx(HKEY_LOCAL_MACHINE,subKey.c_str(),0, NULL, 0, KEY_ALL_ACCESS, NULL, &keyHandle, &dwDisposition);
|
||||||
|
//Set the value.
|
||||||
|
wstr.reset(Ansi2WideString(strValue.c_str()));
|
||||||
|
vlcPluginPath = wstring(wstr.get());
|
||||||
|
len = (DWORD) sizeof(wchar_t) * vlcPluginPath.length() + 1;
|
||||||
|
RegSetValueEx(keyHandle, L"VLC_PLUGIN_PATH", 0, REG_SZ, (PBYTE)vlcPluginPath.c_str(), len);
|
||||||
|
RegCloseKey(keyHandle);
|
||||||
|
|
||||||
|
RegFlushKey(keyHandle);
|
||||||
|
|
||||||
|
string test = "SET " + newstrValue;
|
||||||
|
system(test.c_str());
|
||||||
|
DWORD dwReturnValue=0;
|
||||||
|
LRESULT error1 = SendMessageTimeout(HWND_BROADCAST, WM_SETTINGCHANGE, 0, (LPARAM)
|
||||||
|
L"Environment", SMTO_ABORTIFHUNG, 5000, &dwReturnValue);
|
||||||
|
//SendMessageTimeout(HWND_BROADCAST, WM_SETTINGCHANGE, 0, (LPARAM) "Environment", SMTO_ABORTIFHUNG, 10000, NULL );
|
||||||
|
//SendMessageTimeout(HWND_BROADCAST, WM_SETTINGCHANGE, 0, (LPARAM) L"Environment", SMTO_ABORTIFHUNG, 10000, NULL );
|
||||||
|
//SendMessageTimeout(HWND_BROADCAST, WM_SETTINGCHANGE, 0, (LPARAM) TEXT("Environment"), SMTO_ABORTIFHUNG,10000, &dwReturnValue);
|
||||||
|
|
||||||
|
//printf("*** VLC D [%s] error1 = %d dwReturnValue = %d ****\n",getenv("VLC_PLUGIN_PATH"),error1,dwReturnValue);
|
||||||
|
//system(argv[0]);
|
||||||
|
const char *const *newargv = &argv[1];
|
||||||
|
_execv( argv[0], newargv );
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
PlatformExceptionHandler::application_binary= executable_path(argv[0],true);
|
PlatformExceptionHandler::application_binary= executable_path(argv[0],true);
|
||||||
mg_app_name = GameConstants::application_name;
|
mg_app_name = GameConstants::application_name;
|
||||||
mailStringSupport = mailString;
|
mailStringSupport = mailString;
|
||||||
|
|
|
@ -26,12 +26,13 @@ protected:
|
||||||
int height;
|
int height;
|
||||||
int colorBits;
|
int colorBits;
|
||||||
string pluginsPath;
|
string pluginsPath;
|
||||||
|
bool verboseEnabled;
|
||||||
|
|
||||||
bool stop;
|
bool stop;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
VideoPlayer(string filename, SDL_Surface *surface, int width, int height,
|
VideoPlayer(string filename, SDL_Surface *surface, int width, int height,
|
||||||
int colorBits, string pluginsPath);
|
int colorBits, string pluginsPath,bool verboseEnabled=false);
|
||||||
virtual ~VideoPlayer();
|
virtual ~VideoPlayer();
|
||||||
|
|
||||||
void PlayVideo();
|
void PlayVideo();
|
||||||
|
|
|
@ -90,6 +90,7 @@ LONG WINAPI UnhandledExceptionFilter2(struct _EXCEPTION_POINTERS *ExceptionInfo)
|
||||||
LPWSTR Ansi2WideString(LPCSTR lpaszString);
|
LPWSTR Ansi2WideString(LPCSTR lpaszString);
|
||||||
std::string utf8_encode(const std::wstring wstr);
|
std::string utf8_encode(const std::wstring wstr);
|
||||||
std::wstring utf8_decode(const std::string &str);
|
std::wstring utf8_decode(const std::string &str);
|
||||||
|
std::string getRegKey(const std::string& location, const std::string& name);
|
||||||
|
|
||||||
void message(string message);
|
void message(string message);
|
||||||
bool ask(string message);
|
bool ask(string message);
|
||||||
|
|
|
@ -14,6 +14,7 @@
|
||||||
#include <SDL.h>
|
#include <SDL.h>
|
||||||
#include <SDL_mutex.h>
|
#include <SDL_mutex.h>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
#if defined(WIN32)
|
#if defined(WIN32)
|
||||||
#include <windows.h>
|
#include <windows.h>
|
||||||
#endif
|
#endif
|
||||||
|
@ -22,6 +23,35 @@
|
||||||
#include <vlc/vlc.h>
|
#include <vlc/vlc.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#if defined(WIN32)
|
||||||
|
/**
|
||||||
|
* @param location The location of the registry key. For example "Software\\Bethesda Softworks\\Morrowind"
|
||||||
|
* @param name the name of the registry key, for example "Installed Path"
|
||||||
|
* @return the value of the key or an empty string if an error occured.
|
||||||
|
*/
|
||||||
|
std::string getRegKey(const std::string& location, const std::string& name){
|
||||||
|
HKEY key;
|
||||||
|
CHAR value[1024];
|
||||||
|
DWORD bufLen = 1024*sizeof(CHAR);
|
||||||
|
long ret;
|
||||||
|
ret = RegOpenKeyExA(HKEY_LOCAL_MACHINE, location.c_str(), 0, KEY_QUERY_VALUE, &key);
|
||||||
|
if( ret != ERROR_SUCCESS ){
|
||||||
|
return std::string();
|
||||||
|
}
|
||||||
|
ret = RegQueryValueExA(key, name.c_str(), 0, 0, (LPBYTE) value, &bufLen);
|
||||||
|
RegCloseKey(key);
|
||||||
|
if ( (ret != ERROR_SUCCESS) || (bufLen > 1024*sizeof(TCHAR)) ){
|
||||||
|
return std::string();
|
||||||
|
}
|
||||||
|
string stringValue = value;
|
||||||
|
size_t i = stringValue.length();
|
||||||
|
while( i > 0 && stringValue[i-1] == '\0' ){
|
||||||
|
--i;
|
||||||
|
}
|
||||||
|
return stringValue.substr(0,i);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
struct ctx {
|
struct ctx {
|
||||||
GLuint textureId; // Texture ID
|
GLuint textureId; // Texture ID
|
||||||
SDL_Surface *surf;
|
SDL_Surface *surf;
|
||||||
|
@ -77,13 +107,16 @@ static void display(void *data, void *id) {
|
||||||
}
|
}
|
||||||
|
|
||||||
VideoPlayer::VideoPlayer(string filename, SDL_Surface *surface,
|
VideoPlayer::VideoPlayer(string filename, SDL_Surface *surface,
|
||||||
int width, int height,int colorBits,string pluginsPath) {
|
int width, int height,int colorBits,string pluginsPath,
|
||||||
|
bool verboseEnabled) {
|
||||||
this->filename = filename;
|
this->filename = filename;
|
||||||
this->surface = surface;
|
this->surface = surface;
|
||||||
this->width = width;
|
this->width = width;
|
||||||
this->height = height;
|
this->height = height;
|
||||||
this->colorBits = colorBits;
|
this->colorBits = colorBits;
|
||||||
this->pluginsPath = pluginsPath;
|
this->pluginsPath = pluginsPath;
|
||||||
|
this->verboseEnabled = verboseEnabled;
|
||||||
|
|
||||||
this->stop = false;
|
this->stop = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -112,7 +145,10 @@ void VideoPlayer::PlayVideo() {
|
||||||
std::vector<const char *> vlc_argv;
|
std::vector<const char *> vlc_argv;
|
||||||
vlc_argv.push_back("--no-xlib" /* tell VLC to not use Xlib */);
|
vlc_argv.push_back("--no-xlib" /* tell VLC to not use Xlib */);
|
||||||
vlc_argv.push_back("--no-video-title-show");
|
vlc_argv.push_back("--no-video-title-show");
|
||||||
// vlc_argv.push_back(pluginParam.c_str());
|
if(verboseEnabled) vlc_argv.push_back("--verbose=2");
|
||||||
|
#if defined(WIN32)
|
||||||
|
if(verboseEnabled) _putenv("VLC_VERBOSE=2");
|
||||||
|
#endif
|
||||||
int vlc_argc = vlc_argv.size();
|
int vlc_argc = vlc_argv.size();
|
||||||
|
|
||||||
// char const *vlc_argv[] =
|
// char const *vlc_argv[] =
|
||||||
|
@ -155,73 +191,55 @@ void VideoPlayer::PlayVideo() {
|
||||||
/*
|
/*
|
||||||
* Initialise libVLC
|
* Initialise libVLC
|
||||||
*/
|
*/
|
||||||
|
if(verboseEnabled) printf("Trying [%s]\n",getenv("VLC_PLUGIN_PATH"));
|
||||||
libvlc = libvlc_new(vlc_argc, &vlc_argv[0]);
|
libvlc = libvlc_new(vlc_argc, &vlc_argv[0]);
|
||||||
|
#if defined(WIN32)
|
||||||
if(libvlc == NULL) {
|
if(libvlc == NULL) {
|
||||||
// For windows check registry for install path
|
// For windows check registry for install path
|
||||||
#if defined(WIN32) && !defined(__MINGW32__)
|
std::string strValue = getRegKey("Software\\VideoLAN\\VLC", "InstallDir");
|
||||||
//Open the registry key.
|
if(strValue != "") {
|
||||||
wstring subKey = L"Software\\VideoLAN\\VLC";
|
if(strValue.length() >= 2) {
|
||||||
HKEY keyHandle;
|
if(strValue[0] == '"') {
|
||||||
//DWORD dwDisposition;
|
strValue = strValue.erase(0);
|
||||||
LONG lres = RegOpenKeyEx(HKEY_LOCAL_MACHINE,subKey.c_str(),0, KEY_READ, &keyHandle);
|
}
|
||||||
if(lres == ERROR_SUCCESS) {
|
if(strValue[strValue.length()-1] == '"') {
|
||||||
std::string strValue;
|
strValue = strValue.erase(strValue.length()-1);
|
||||||
//GetStringRegKey(keyHandle, L"", strValue, L"");
|
|
||||||
char szBuffer[4096];
|
|
||||||
DWORD dwBufferSize = sizeof(szBuffer);
|
|
||||||
ULONG nError = RegQueryValueEx(keyHandle, L"", 0, NULL, (LPBYTE)szBuffer, &dwBufferSize);
|
|
||||||
if (ERROR_SUCCESS == nError) {
|
|
||||||
strValue = szBuffer;
|
|
||||||
}
|
|
||||||
|
|
||||||
RegCloseKey(keyHandle);
|
|
||||||
|
|
||||||
if(strValue != "") {
|
|
||||||
#if defined(WIN32)
|
|
||||||
strValue = "VLC_PLUGIN_PATH=" + strValue;
|
|
||||||
_putenv(strValue.c_str());
|
|
||||||
#else
|
|
||||||
setenv("VLC_PLUGIN_PATH",strValue.c_str(),1);
|
|
||||||
#endif
|
|
||||||
libvlc = libvlc_new(vlc_argc, &vlc_argv[0]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
if(libvlc == NULL) {
|
|
||||||
#if defined(WIN32)
|
|
||||||
_putenv("VLC_PLUGIN_PATH=c:\\program files\\videolan\\vlc\\plugins");
|
|
||||||
#else
|
|
||||||
setenv("VLC_PLUGIN_PATH","c:\\program files\\videolan\\vlc\\plugins",1);
|
|
||||||
#endif
|
|
||||||
libvlc = libvlc_new(vlc_argc, &vlc_argv[0]);
|
|
||||||
}
|
|
||||||
if(libvlc == NULL) {
|
|
||||||
#if defined(WIN32)
|
|
||||||
_putenv("VLC_PLUGIN_PATH=\\program files\\videolan\\vlc\\plugins");
|
|
||||||
#else
|
|
||||||
setenv("VLC_PLUGIN_PATH","\\program files\\videolan\\vlc\\plugins",1);
|
|
||||||
#endif
|
|
||||||
libvlc = libvlc_new(vlc_argc, &vlc_argv[0]);
|
|
||||||
if(libvlc == NULL) {
|
|
||||||
#if defined(WIN32)
|
|
||||||
_putenv("VLC_PLUGIN_PATH=c:\\program files (x86)\\videolan\\vlc\\plugins");
|
|
||||||
#else
|
|
||||||
setenv("VLC_PLUGIN_PATH","c:\\program files (x86)\\videolan\\vlc\\plugins",1);
|
|
||||||
#endif
|
|
||||||
libvlc = libvlc_new(vlc_argc, &vlc_argv[0]);
|
|
||||||
|
|
||||||
if(libvlc == NULL) {
|
|
||||||
#if defined(WIN32)
|
|
||||||
_putenv("VLC_PLUGIN_PATH=\\program files (x86)\\videolan\\vlc\\plugins");
|
|
||||||
#else
|
|
||||||
setenv("VLC_PLUGIN_PATH","\\program files (x86)\\videolan\\vlc\\plugins",1);
|
|
||||||
#endif
|
|
||||||
libvlc = libvlc_new(vlc_argc, &vlc_argv[0]);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
strValue = "VLC_PLUGIN_PATH=" + strValue;
|
||||||
|
_putenv(strValue.c_str());
|
||||||
|
|
||||||
|
if(verboseEnabled) printf("Trying [%s]\n",getenv("VLC_PLUGIN_PATH"));
|
||||||
|
libvlc = libvlc_new(vlc_argc, &vlc_argv[0]);
|
||||||
|
}
|
||||||
|
|
||||||
|
if(libvlc == NULL) {
|
||||||
|
_putenv("VLC_PLUGIN_PATH=c:\\program files\\videolan\\vlc\\plugins");
|
||||||
|
|
||||||
|
if(verboseEnabled) printf("Trying [%s]\n",getenv("VLC_PLUGIN_PATH"));
|
||||||
|
libvlc = libvlc_new(vlc_argc, &vlc_argv[0]);
|
||||||
|
}
|
||||||
|
if(libvlc == NULL) {
|
||||||
|
_putenv("VLC_PLUGIN_PATH=\\program files\\videolan\\vlc\\plugins");
|
||||||
|
|
||||||
|
if(verboseEnabled) printf("Trying [%s]\n",getenv("VLC_PLUGIN_PATH"));
|
||||||
|
libvlc = libvlc_new(vlc_argc, &vlc_argv[0]);
|
||||||
|
}
|
||||||
|
if(libvlc == NULL) {
|
||||||
|
_putenv("VLC_PLUGIN_PATH=c:\\program files (x86)\\videolan\\vlc\\plugins");
|
||||||
|
|
||||||
|
if(verboseEnabled) printf("Trying [%s]\n",getenv("VLC_PLUGIN_PATH"));
|
||||||
|
libvlc = libvlc_new(vlc_argc, &vlc_argv[0]);
|
||||||
|
}
|
||||||
|
if(libvlc == NULL) {
|
||||||
|
_putenv("VLC_PLUGIN_PATH=\\program files (x86)\\videolan\\vlc\\plugins");
|
||||||
|
|
||||||
|
if(verboseEnabled) printf("Trying [%s]\n",getenv("VLC_PLUGIN_PATH"));
|
||||||
|
libvlc = libvlc_new(vlc_argc, &vlc_argv[0]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
if(libvlc != NULL) {
|
if(libvlc != NULL) {
|
||||||
m = libvlc_media_new_path(libvlc, filename.c_str());
|
m = libvlc_media_new_path(libvlc, filename.c_str());
|
||||||
mp = libvlc_media_player_new_from_media(m);
|
mp = libvlc_media_player_new_from_media(m);
|
||||||
|
|
|
@ -75,6 +75,32 @@ std::wstring utf8_decode(const std::string &str) {
|
||||||
return wstrTo;
|
return wstrTo;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param location The location of the registry key. For example "Software\\Bethesda Softworks\\Morrowind"
|
||||||
|
* @param name the name of the registry key, for example "Installed Path"
|
||||||
|
* @return the value of the key or an empty string if an error occured.
|
||||||
|
*/
|
||||||
|
std::string getRegKey(const std::string& location, const std::string& name){
|
||||||
|
HKEY key;
|
||||||
|
CHAR value[1024];
|
||||||
|
DWORD bufLen = 1024*sizeof(CHAR);
|
||||||
|
long ret;
|
||||||
|
ret = RegOpenKeyExA(HKEY_LOCAL_MACHINE, location.c_str(), 0, KEY_QUERY_VALUE, &key);
|
||||||
|
if( ret != ERROR_SUCCESS ){
|
||||||
|
return std::string();
|
||||||
|
}
|
||||||
|
ret = RegQueryValueExA(key, name.c_str(), 0, 0, (LPBYTE) value, &bufLen);
|
||||||
|
RegCloseKey(key);
|
||||||
|
if ( (ret != ERROR_SUCCESS) || (bufLen > 1024*sizeof(TCHAR)) ){
|
||||||
|
return std::string();
|
||||||
|
}
|
||||||
|
string stringValue = value;
|
||||||
|
size_t i = stringValue.length();
|
||||||
|
while( i > 0 && stringValue[i-1] == '\0' ){
|
||||||
|
--i;
|
||||||
|
}
|
||||||
|
return stringValue.substr(0,i);
|
||||||
|
}
|
||||||
|
|
||||||
LONG WINAPI PlatformExceptionHandler::handler(LPEXCEPTION_POINTERS pointers){
|
LONG WINAPI PlatformExceptionHandler::handler(LPEXCEPTION_POINTERS pointers){
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user