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 140 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 152 of file FFmpegFunctions.cpp.

153 {
154 if (AVFormatLibrary->HasSymbol(symbol))
155 return AVFormatLibrary;
156
157 void* addr = GetSymbolFromProcess(symbol);
158
159 if (addr == nullptr)
160 return nullptr;
161
162 const wxString path = FileNames::PathFromAddr(addr);
163
164 if (path.empty())
165 return nullptr;
166
167 return LoadLibrary(wxFileNameFromPath(path), fromUserPathOnly);
168 }
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 170 of file FFmpegFunctions.cpp.

171 {
172 // We start by loading AVFormat
173 AVFormatLibrary = LoadLibrary(path, fromUserPathOnly);
174
175 if (AVFormatLibrary == nullptr)
176 return false;
177
178 if ((AVCodecLibrary = LibraryWithSymbol("avcodec_version", fromUserPathOnly)) == nullptr)
179 return false;
180
181 if ((AVUtilLibrary = LibraryWithSymbol("avutil_version", fromUserPathOnly)) == nullptr)
182 return false;
183
184 if (
186 !LoadAVCodecFunctions(*AVCodecLibrary, functions) ||
188 return false;
189
190 if (!FFmpegAPIResolver::Get().GetAVFormatFactories(
192 return false;
193
194 if (!FFmpegAPIResolver::Get().GetAVCodecFactories(
196 return false;
197
198 AVCodecIDResolver codecResolvers;
199
200 if (!FFmpegAPIResolver::Get().GetAVCodecIDResolver(
201 functions.AVCodecVersion.Major, codecResolvers))
202 return false;
203
204 functions.GetAVCodecID = codecResolvers.GetAVCodecID;
205 functions.GetAudacityCodecID = codecResolvers.GetAudacityCodecID;
206
207 if (!FFmpegAPIResolver::Get().GetAVUtilFactories(
209 return false;
210
211 wxLogInfo("FFmpeg libraries loaded successfully from: %s",
212 FileNames::PathFromAddr(AVFormatLibrary->GetSymbol("avformat_version")));
213
214 if (functions.avcodec_register_all)
215 functions.avcodec_register_all();
216
217 if (functions.av_register_all)
218 functions.av_register_all();
219
222
223 return true;
224 }
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 226 of file FFmpegFunctions.cpp.

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

Referenced by Load().

◆ AVFormatLibrary

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

Definition at line 142 of file FFmpegFunctions.cpp.

Referenced by LibraryWithSymbol(), and Load().

◆ AVUtilLibrary

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

Definition at line 144 of file FFmpegFunctions.cpp.

Referenced by Load().

◆ CodecFactories

AVCodecFactories FFmpegFunctions::Private::CodecFactories

Definition at line 149 of file FFmpegFunctions.cpp.

Referenced by Load().

◆ FFmpegLogCallbackSetter

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

Definition at line 146 of file FFmpegFunctions.cpp.

Referenced by Load().

◆ FormatFactories

AVFormatFactories FFmpegFunctions::Private::FormatFactories

Definition at line 148 of file FFmpegFunctions.cpp.

Referenced by Load().

◆ UtilFactories

AVUtilFactories FFmpegFunctions::Private::UtilFactories

Definition at line 150 of file FFmpegFunctions.cpp.

Referenced by Load().


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