/* static */ bool FFVPXRuntimeLinker::Link() { if (sLinkStatus) { return sLinkStatus == LinkStatus_SUCCEEDED; } MOZ_ASSERT(NS_IsMainThread()); // We retrieve the path of the XUL library as this is where mozavcodec and // mozavutil libs are located. char* path = PR_GetLibraryFilePathname(XUL_DLL, (PRFuncPtr)&FFVPXRuntimeLinker::Link); if (!path) { return false; } nsCOMPtr<nsIFile> xulFile = do_CreateInstance(NS_LOCAL_FILE_CONTRACTID); if (!xulFile || NS_FAILED(xulFile->InitWithNativePath(nsDependentCString(path)))) { PR_Free(path); return false; } PR_Free(path); nsCOMPtr<nsIFile> rootDir; if (NS_FAILED(xulFile->GetParent(getter_AddRefs(rootDir))) || !rootDir) { return false; } nsAutoCString rootPath; if (NS_FAILED(rootDir->GetNativePath(rootPath))) { return false; } char* libname = NULL; /* Get the platform-dependent library name of the module */ libname = PR_GetLibraryName(rootPath.get(), "mozavutil"); if (!libname) { return false; } sLinkedUtilLib = MozAVLink(libname); PR_FreeLibraryName(libname); libname = PR_GetLibraryName(rootPath.get(), "mozavcodec"); if (libname) { sLinkedLib = MozAVLink(libname); PR_FreeLibraryName(libname); if (sLinkedLib && sLinkedUtilLib) { if (Bind("mozavcodec")) { sLinkStatus = LinkStatus_SUCCEEDED; return true; } } } Unlink(); sLinkStatus = LinkStatus_FAILED; return false; }
/* static */ bool FFVPXRuntimeLinker::Init() { if (sLinkStatus) { return sLinkStatus == LinkStatus_SUCCEEDED; } MOZ_ASSERT(NS_IsMainThread()); sLinkStatus = LinkStatus_FAILED; // We retrieve the path of the lgpllibs library as this is where mozavcodec // and mozavutil libs are located. PathString lgpllibsname = GetLibraryName(nullptr, "lgpllibs"); if (lgpllibsname.IsEmpty()) { return false; } PathString path = GetLibraryFilePathname(lgpllibsname.get(), (PRFuncPtr)&soundtouch::SoundTouch::getVersionId); if (path.IsEmpty()) { return false; } RefPtr<nsLocalFile> xulFile = new nsLocalFile(path); if (xulFile->NativePath().IsEmpty()) { return false; } nsCOMPtr<nsIFile> rootDir; if (NS_FAILED(xulFile->GetParent(getter_AddRefs(rootDir))) || !rootDir) { return false; } PathString rootPath = rootDir->NativePath(); /* Get the platform-dependent library name of the module */ PathString libname = GetLibraryName(rootPath.get(), "mozavutil"); if (libname.IsEmpty()) { return false; } RefPtr<nsLocalFile> libFile = new nsLocalFile(libname); if (libFile->NativePath().IsEmpty()) { return false; } sFFVPXLib.mAVUtilLib = MozAVLink(libFile); libname = GetLibraryName(rootPath.get(), "mozavcodec"); if (!libname.IsEmpty()) { libFile = new nsLocalFile(libname); if (!libFile->NativePath().IsEmpty()) { sFFVPXLib.mAVCodecLib = MozAVLink(libFile); } } if (sFFVPXLib.Link() == FFmpegLibWrapper::LinkResult::Success) { sLinkStatus = LinkStatus_SUCCEEDED; return true; } return false; }