MCPcopy Create free account
hub / github.com/audacity/audacity / Open

Method Open

modules/import-export/mod-ffmpeg/ImportFFmpeg.cpp:285–329  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

283}
284
285std::unique_ptr<ImportFileHandle> FFmpegImportPlugin::Open(
286 const FilePath &filename, AudacityProject*)
287{
288 auto ffmpeg = FFmpegFunctions::Load();
289
290 //Check if we're loading explicitly supported format
291 wxString extension = filename.AfterLast(wxT('.'));
292 if (SupportsExtension(extension))
293 {
294 //Audacity is trying to load something that is declared as
295 //officially supported by this plugin.
296 //If we don't have FFmpeg configured - tell the user about it.
297 //Since this will be happening often, use disableable "FFmpeg not found" dialog
298 //insdead of usual AudacityMessageBox()
299 bool newsession = NewImportingSession.Read();
300 if (!ffmpeg)
301 {
302 auto dontShowDlg = FFmpegNotFoundDontShow.Read();
303 if (dontShowDlg == 0 && newsession)
304 {
305 NewImportingSession.Write(false);
306 gPrefs->Flush();
307 FFmpegNotFoundDialog{ nullptr }.ShowModal();
308
309 ffmpeg = FFmpegFunctions::Load();
310 }
311 }
312 }
313 if (!ffmpeg)
314 {
315 return nullptr;
316 }
317
318 // Construct the handle only after any reloading of ffmpeg functions
319 auto handle = std::make_unique<FFmpegImportFileHandle>(filename);
320
321 // Open the file for import
322 bool success = handle->Init();
323
324 if (!success) {
325 return nullptr;
326 }
327
328 return handle;
329}
330
331static Importer::RegisteredImportPlugin registered{ "FFmpeg",
332 std::make_unique< FFmpegImportPlugin >()

Callers 2

InitCodecsMethod · 0.45
InitCodecsMethod · 0.45

Calls 7

LoadFunction · 0.85
SupportsExtensionFunction · 0.85
ReadMethod · 0.45
WriteMethod · 0.45
FlushMethod · 0.45
ShowModalMethod · 0.45
InitMethod · 0.45

Tested by

no test coverage detected