Kaydet (Commit) 132f150d authored tarafından Minh Ngo's avatar Minh Ngo Kaydeden (comit) Tor Lillqvist

Cross-platform libvlc loading.

Conflicts:
	avmedia/source/vlc/wrapper/SymbolLoader.hxx

Change-Id: I2dcd86329419255751925e93db0c893da191be31
Reviewed-on: https://gerrit.libreoffice.org/5627Reviewed-by: 's avatarTor Lillqvist <tml@iki.fi>
Tested-by: 's avatarTor Lillqvist <tml@iki.fi>
üst 4ef149ba
...@@ -9,7 +9,10 @@ ...@@ -9,7 +9,10 @@
#ifndef _SYMBOL_LOADER_HXX #ifndef _SYMBOL_LOADER_HXX
#define _SYMBOL_LOADER_HXX #define _SYMBOL_LOADER_HXX
#if defined( WNT )
# include <windows.h>
# include <winreg.h>
#endif
#include <iostream> #include <iostream>
#include <osl/module.h> #include <osl/module.h>
#include <rtl/ustring.hxx> #include <rtl/ustring.hxx>
...@@ -26,11 +29,33 @@ struct ApiMap ...@@ -26,11 +29,33 @@ struct ApiMap
namespace namespace
{ {
const char *libNames[] = { #if defined( UNX )
"libvlc.so.5", const char LibName[] = "libvlc.so.5";
"libvlc.dll", #elif defined( MACOS )
"libvlc.dylib" const char LibName[] = "/Applications/VLC.app/libvlc.dylib";
}; #elif defined( WNT )
const char LibName[] = "libvlc.dll";
OUString GetVLCPath()
{
HKEY hKey;
TCHAR arCurrent[MAX_PATH];
DWORD dwType, dwCurrentSize = sizeof( arCurrent );
if ( ::RegOpenKeyEx( HKEY_LOCAL_MACHINE, _T( "Software\\VideoLAN\\VLC" ),
0, KEY_READ, &hKey ) == ERROR_SUCCESS )
{
if ( ::RegQueryValueEx( hKey, _T( "InstallDir" ), NULL, &dwType, ( LPBYTE )arCurrent, &dwCurrentSize ) == ERROR_SUCCESS )
{
::RegCloseKey( hKey );
return OUString::createFromAscii( arCurrent ) + "/";
}
::RegCloseKey( hKey );
}
}
#endif
template<size_t N> template<size_t N>
bool tryLink( oslModule &aModule, const ApiMap ( &pMap )[N] ) bool tryLink( oslModule &aModule, const ApiMap ( &pMap )[N] )
...@@ -58,16 +83,20 @@ namespace VLC ...@@ -58,16 +83,20 @@ namespace VLC
template<size_t N> template<size_t N>
bool InitApiMap( const ApiMap ( &pMap )[N] ) bool InitApiMap( const ApiMap ( &pMap )[N] )
{ {
oslModule aModule; #if defined( UNX ) || defined( MACOS )
const OUString& fullPath = OUString::createFromAscii(LibName);
#elif defined( WNT )
const OUString& fullPath = GetVLCPath() + OUString::createFromAscii(LibName);
#endif
for (uint j = 0; j < sizeof(libNames) / sizeof(libNames[0]); ++j) oslModule aModule = osl_loadModule( fullPath.pData,
{
aModule = osl_loadModule( OUString::createFromAscii
( libNames[ j ] ).pData,
SAL_LOADMODULE_DEFAULT ); SAL_LOADMODULE_DEFAULT );
if( aModule == NULL) if( aModule == NULL)
continue; {
std::cerr << "Cannot load libvlc" << std::endl;
return false;
}
if (tryLink( aModule, pMap )) if (tryLink( aModule, pMap ))
{ {
...@@ -76,9 +105,7 @@ namespace VLC ...@@ -76,9 +105,7 @@ namespace VLC
} }
osl_unloadModule( aModule ); osl_unloadModule( aModule );
}
std::cerr << "Cannot load libvlc" << std::endl;
return false; return false;
} }
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment