summaryrefslogtreecommitdiffstats
path: root/dom/media/platforms/ffmpeg/ffvpx/FFVPXRuntimeLinker.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'dom/media/platforms/ffmpeg/ffvpx/FFVPXRuntimeLinker.cpp')
-rw-r--r--dom/media/platforms/ffmpeg/ffvpx/FFVPXRuntimeLinker.cpp48
1 files changed, 26 insertions, 22 deletions
diff --git a/dom/media/platforms/ffmpeg/ffvpx/FFVPXRuntimeLinker.cpp b/dom/media/platforms/ffmpeg/ffvpx/FFVPXRuntimeLinker.cpp
index dfc8244f1d..c0a6e01f98 100644
--- a/dom/media/platforms/ffmpeg/ffvpx/FFVPXRuntimeLinker.cpp
+++ b/dom/media/platforms/ffmpeg/ffvpx/FFVPXRuntimeLinker.cpp
@@ -7,14 +7,10 @@
#include "FFVPXRuntimeLinker.h"
#include "FFmpegLibWrapper.h"
#include "FFmpegLog.h"
-#include "BinaryPath.h"
#include "mozilla/FileUtils.h"
#include "nsLocalFile.h"
-#include "prmem.h"
+#include "nsXPCOMPrivate.h"
#include "prlink.h"
-#ifdef XP_WIN
-# include <windows.h>
-#endif
namespace mozilla {
@@ -84,29 +80,37 @@ bool FFVPXRuntimeLinker::Init() {
sFFVPXLib.LinkVAAPILibs();
#endif
- nsCOMPtr<nsIFile> libFile;
- if (NS_FAILED(mozilla::BinaryPath::GetFile(getter_AddRefs(libFile)))) {
+#ifdef XP_WIN
+ PathString path =
+ GetLibraryFilePathname(LXUL_DLL, (PRFuncPtr)&FFVPXRuntimeLinker::Init);
+#else
+ PathString path =
+ GetLibraryFilePathname(XUL_DLL, (PRFuncPtr)&FFVPXRuntimeLinker::Init);
+#endif
+ if (path.IsEmpty()) {
+ return false;
+ }
+ nsCOMPtr<nsIFile> libFile = new nsLocalFile(path);
+ if (libFile->NativePath().IsEmpty()) {
return false;
}
-#ifdef XP_DARWIN
- if (!XRE_IsParentProcess() &&
- (XRE_GetChildProcBinPathType(XRE_GetProcessType()) ==
- BinPathType::PluginContainer)) {
- // On macOS, PluginContainer processes have their binary in a
- // plugin-container.app/Content/MacOS/ directory.
- nsCOMPtr<nsIFile> parentDir1, parentDir2;
- if (NS_FAILED(libFile->GetParent(getter_AddRefs(parentDir1)))) {
- return false;
- }
- if (NS_FAILED(parentDir1->GetParent(getter_AddRefs(parentDir2)))) {
- return false;
- }
- if (NS_FAILED(parentDir2->GetParent(getter_AddRefs(libFile)))) {
+ if (getenv("MOZ_RUN_GTEST")
+#ifdef FUZZING
+ || getenv("FUZZER")
+#endif
+ ) {
+ // The condition above is the same as in
+ // xpcom/glue/standalone/nsXPCOMGlue.cpp. This means we can't reach here
+ // without the gtest libxul being loaded. In turn, that means the path to
+ // libxul leads to a subdirectory of where the libmozav* libraries are, so
+ // we get the parent.
+ nsCOMPtr<nsIFile> parent;
+ if (NS_FAILED(libFile->GetParent(getter_AddRefs(parent)))) {
return false;
}
+ libFile = parent;
}
-#endif
if (NS_FAILED(libFile->SetNativeLeafName(MOZ_DLL_PREFIX
"mozavutil" MOZ_DLL_SUFFIX ""_ns))) {