Created
November 25, 2021 16:32
-
-
Save jeferwang/af8dd7cbe5ffcde3721b845731b44f5d to your computer and use it in GitHub Desktop.
Unreal Engine 4 Use Custom Dll Path
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
void FVideoPlayerModule::SetDllPath() | |
{ | |
//FString AbsPath = FileManager::Get().ConvertToAbsolutePathForExternalAppForRead(*MyLibPath); | |
const auto PluginBaseDir = IPluginManager::Get().FindPlugin("VideoPlayer")->GetBaseDir(); | |
const auto PluginBaseDirAbs = FPaths::ConvertRelativePathToFull(PluginBaseDir); | |
XVideoDllPath = FPaths::Combine(PluginBaseDirAbs, TEXT("Source/VideoPlayer/ThirdParty/XVideo/bin/")); | |
FPlatformProcess::AddDllDirectory(*XVideoDllPath); | |
FPlatformProcess::PushDllDirectory(*XVideoDllPath); | |
// not need load and manage dll manually, will be auto load | |
//const auto Dlls = { | |
// // FFMpeg | |
// FString("avutil-56.dll"), | |
// FString("swscale-5.dll"), | |
// FString("swresample-3.dll"), | |
// FString("postproc-55.dll"), | |
// FString("avcodec-58.dll"), | |
// FString("avformat-58.dll"), | |
// FString("avfilter-7.dll"), | |
// FString("avdevice-58.dll"), | |
// // XVideo | |
// FString("XLog.dll"), | |
// FString("XGraphic.dll"), | |
// FString("XVideo.dll"), | |
//}; | |
//for (const FString& Dll : Dlls) | |
//{ | |
// //const auto Handler = FPlatformProcess::GetDllHandle(*FPaths::Combine(XVideoBaseDir, *Dll)); | |
// const auto Handler = FPlatformProcess::GetDllHandle(*Dll); | |
// DllHandlers.Add(Handler); | |
//} | |
} | |
void FVideoPlayerModule::UnsetDllPath() | |
{ | |
/*for (int32 i = DllHandlers.Num() - 1; i >= 0; i--) | |
{ | |
FPlatformProcess::FreeDllHandle(DllHandlers[i]); | |
}*/ | |
// must pop this dll path (or maybe?) | |
FPlatformProcess::PopDllDirectory(*XVideoDllPath); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment