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 @@
#ifndef _SYMBOL_LOADER_HXX
#define _SYMBOL_LOADER_HXX
#if defined( WNT )
# include <windows.h>
# include <winreg.h>
#endif
#include <iostream>
#include <osl/module.h>
#include <rtl/ustring.hxx>
......@@ -26,11 +29,33 @@ struct ApiMap
namespace
{
const char *libNames[] = {
"libvlc.so.5",
"libvlc.dll",
"libvlc.dylib"
};
#if defined( UNX )
const char LibName[] = "libvlc.so.5";
#elif defined( MACOS )
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>
bool tryLink( oslModule &aModule, const ApiMap ( &pMap )[N] )
......@@ -58,27 +83,29 @@ namespace VLC
template<size_t N>
bool InitApiMap( const ApiMap ( &pMap )[N] )
{
oslModule aModule;
for (uint j = 0; j < sizeof(libNames) / sizeof(libNames[0]); ++j)
{
aModule = osl_loadModule( OUString::createFromAscii
( libNames[ j ] ).pData,
SAL_LOADMODULE_DEFAULT );
#if defined( UNX ) || defined( MACOS )
const OUString& fullPath = OUString::createFromAscii(LibName);
#elif defined( WNT )
const OUString& fullPath = GetVLCPath() + OUString::createFromAscii(LibName);
#endif
if( aModule == NULL)
continue;
oslModule aModule = osl_loadModule( fullPath.pData,
SAL_LOADMODULE_DEFAULT );
if (tryLink( aModule, pMap ))
{
osl_unloadModule( aModule );
return true;
}
if( aModule == NULL)
{
std::cerr << "Cannot load libvlc" << std::endl;
return false;
}
if (tryLink( aModule, pMap ))
{
osl_unloadModule( aModule );
return true;
}
std::cerr << "Cannot load libvlc" << std::endl;
osl_unloadModule( aModule );
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