Audacity 3.2.0
Public Member Functions | Public Attributes | List of all members
FFmpegFunctions::Private Struct Referencefinal
Collaboration diagram for FFmpegFunctions::Private:
[legend]

Public Member Functions

std::shared_ptr< wxDynamicLibrary > LibraryWithSymbol (const char *symbol, bool fromUserPathOnly) const
 
bool Load (FFmpegFunctions &functions, const wxString &path, bool fromUserPathOnly)
 
std::shared_ptr< wxDynamicLibrary > LoadLibrary (const wxString &libraryName, bool fromUserPathOnly) const
 

Public Attributes

std::shared_ptr< wxDynamicLibrary > AVFormatLibrary
 
std::shared_ptr< wxDynamicLibrary > AVCodecLibrary
 
std::shared_ptr< wxDynamicLibrary > AVUtilLibrary
 
std::unique_ptr< FFmpegLogFFmpegLogCallbackSetter
 
AVFormatFactories FormatFactories
 
AVCodecFactories CodecFactories
 
AVUtilFactories UtilFactories
 

Detailed Description

Definition at line 142 of file FFmpegFunctions.cpp.

Member Function Documentation

◆ LibraryWithSymbol()

std::shared_ptr< wxDynamicLibrary > FFmpegFunctions::Private::LibraryWithSymbol ( const char *  symbol,
bool  fromUserPathOnly 
) const
inline

Definition at line 154 of file FFmpegFunctions.cpp.

155 {
156 if (AVFormatLibrary->HasSymbol(symbol))
157 return AVFormatLibrary;
158
159 void* addr = GetSymbolFromProcess(symbol);
160
161 if (addr == nullptr)
162 return nullptr;
163
164 const wxString path = FileNames::PathFromAddr(addr);
165
166 if (path.empty())
167 return nullptr;
168
169 return LoadLibrary(wxFileNameFromPath(path), fromUserPathOnly);
170 }
void * GetSymbolFromProcess(const char *name)
FILES_API FilePath PathFromAddr(void *addr)
std::shared_ptr< wxDynamicLibrary > AVFormatLibrary
std::shared_ptr< wxDynamicLibrary > LoadLibrary(const wxString &libraryName, bool fromUserPathOnly) const

References AVFormatLibrary, GetSymbolFromProcess(), LoadLibrary(), and FileNames::PathFromAddr().

Referenced by Load().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ Load()

bool FFmpegFunctions::Private::Load ( FFmpegFunctions functions,
const wxString &  path,
bool  fromUserPathOnly 
)
inline

Definition at line 172 of file FFmpegFunctions.cpp.

173 {
174 // We start by loading AVFormat
175 AVFormatLibrary = LoadLibrary(path, fromUserPathOnly);
176
177 if (AVFormatLibrary == nullptr)
178 return false;
179
180 if ((AVCodecLibrary = LibraryWithSymbol("avcodec_version", fromUserPathOnly)) == nullptr)
181 return false;
182
183 if ((AVUtilLibrary = LibraryWithSymbol("avutil_version", fromUserPathOnly)) == nullptr)
184 return false;
185
186 if (
188 !LoadAVCodecFunctions(*AVCodecLibrary, functions) ||
190 return false;
191
192 if (!FFmpegAPIResolver::Get().GetAVFormatFactories(
194 return false;
195
196 if (!FFmpegAPIResolver::Get().GetAVCodecFactories(
198 return false;
199
200 AVCodecIDResolver codecResolvers;
201
202 if (!FFmpegAPIResolver::Get().GetAVCodecIDResolver(
203 functions.AVCodecVersion.Major, codecResolvers))
204 return false;
205
206 functions.GetAVCodecID = codecResolvers.GetAVCodecID;
207 functions.GetAudacityCodecID = codecResolvers.GetAudacityCodecID;
208
209 if (!FFmpegAPIResolver::Get().GetAVUtilFactories(
211 return false;
212
213 wxLogInfo("FFmpeg libraries loaded successfully from: %s",
214 FileNames::PathFromAddr(AVFormatLibrary->GetSymbol("avformat_version")));
215
216 if (functions.avcodec_register_all)
217 functions.avcodec_register_all();
218
219 if (functions.av_register_all)
220 functions.av_register_all();
221
224
225 return true;
226 }
bool LoadAVCodecFunctions(const wxDynamicLibrary &lib, AVCodecFunctions &functions)
bool LoadAVFormatFunctions(const wxDynamicLibrary &lib, AVFormatFunctions &functions)
bool LoadAVUtilFunctions(const wxDynamicLibrary &lib, AVUtilFunctions &functions)
static FFmpegAPIResolver & Get()
FFMPegVersion AVCodecVersion
void(* avcodec_register_all)(void)
AudacityAVCodecID(* GetAudacityCodecID)(AVCodecIDFwd)
AVCodecIDFwd(* GetAVCodecID)(AudacityAVCodecID)
void(* av_register_all)(void)
FFMPegVersion AVFormatVersion
std::unique_ptr< FFmpegLog >(* CreateLogCallbackSetter)(const FFmpegFunctions &)
FFMPegVersion AVUtilVersion
unsigned Major
Definition: FFmpegTypes.h:169
std::shared_ptr< wxDynamicLibrary > LibraryWithSymbol(const char *symbol, bool fromUserPathOnly) const
AVCodecFactories CodecFactories
AVFormatFactories FormatFactories
std::shared_ptr< wxDynamicLibrary > AVCodecLibrary
std::unique_ptr< FFmpegLog > FFmpegLogCallbackSetter
std::shared_ptr< wxDynamicLibrary > AVUtilLibrary
AudacityAVCodecID(* GetAudacityCodecID)(AVCodecIDFwd)
AVCodecIDFwd(* GetAVCodecID)(AudacityAVCodecID)

References AVFormatFunctions::av_register_all, AVCodecFunctions::avcodec_register_all, AVCodecLibrary, AVCodecFunctions::AVCodecVersion, AVFormatLibrary, AVFormatFunctions::AVFormatVersion, AVUtilLibrary, AVUtilFunctions::AVUtilVersion, CodecFactories, AVUtilFactories::CreateLogCallbackSetter, FFmpegLogCallbackSetter, FormatFactories, FFmpegAPIResolver::Get(), FFmpegFunctions::GetAudacityCodecID, AVCodecIDResolver::GetAudacityCodecID, FFmpegFunctions::GetAVCodecID, AVCodecIDResolver::GetAVCodecID, LibraryWithSymbol(), LoadAVCodecFunctions(), LoadAVFormatFunctions(), LoadAVUtilFunctions(), LoadLibrary(), FFMPegVersion::Major, FileNames::PathFromAddr(), and UtilFactories.

Here is the call graph for this function:

◆ LoadLibrary()

std::shared_ptr< wxDynamicLibrary > FFmpegFunctions::Private::LoadLibrary ( const wxString &  libraryName,
bool  fromUserPathOnly 
) const
inline

Definition at line 228 of file FFmpegFunctions.cpp.

229 {
230#if defined(__WXMAC__)
231 // On macOS dyld reads environment only when application starts.
232 // Let's emulate the process manually
233 for (const wxString& path : FFmpegFunctions::GetSearchPaths(fromUserPathOnly))
234 {
235 const wxString fullName = wxFileName(path, libraryName).GetFullPath();
236
237 if (!wxFileExists(fullName))
238 continue;
239
240 auto library = std::make_shared<wxDynamicLibrary>(fullName);
241
242 if (library->IsLoaded())
243 return library;
244 }
245#endif
246 auto library = std::make_shared<wxDynamicLibrary> (libraryName);
247
248 if (library->IsLoaded())
249 return library;
250
251 return {};
252 }
static std::vector< wxString > GetSearchPaths(bool fromUserPathOnly)

References FFmpegFunctions::GetSearchPaths().

Referenced by LibraryWithSymbol(), and Load().

Here is the call graph for this function:
Here is the caller graph for this function:

Member Data Documentation

◆ AVCodecLibrary

std::shared_ptr<wxDynamicLibrary> FFmpegFunctions::Private::AVCodecLibrary

Definition at line 145 of file FFmpegFunctions.cpp.

Referenced by Load().

◆ AVFormatLibrary

std::shared_ptr<wxDynamicLibrary> FFmpegFunctions::Private::AVFormatLibrary

Definition at line 144 of file FFmpegFunctions.cpp.

Referenced by LibraryWithSymbol(), and Load().

◆ AVUtilLibrary

std::shared_ptr<wxDynamicLibrary> FFmpegFunctions::Private::AVUtilLibrary

Definition at line 146 of file FFmpegFunctions.cpp.

Referenced by Load().

◆ CodecFactories

AVCodecFactories FFmpegFunctions::Private::CodecFactories

Definition at line 151 of file FFmpegFunctions.cpp.

Referenced by Load().

◆ FFmpegLogCallbackSetter

std::unique_ptr<FFmpegLog> FFmpegFunctions::Private::FFmpegLogCallbackSetter

Definition at line 148 of file FFmpegFunctions.cpp.

Referenced by Load().

◆ FormatFactories

AVFormatFactories FFmpegFunctions::Private::FormatFactories

Definition at line 150 of file FFmpegFunctions.cpp.

Referenced by Load().

◆ UtilFactories

AVUtilFactories FFmpegFunctions::Private::UtilFactories

Definition at line 152 of file FFmpegFunctions.cpp.

Referenced by Load().


The documentation for this struct was generated from the following file: