| 283 | } |
| 284 | |
| 285 | std::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 | |
| 331 | static Importer::RegisteredImportPlugin registered{ "FFmpeg", |
| 332 | std::make_unique< FFmpegImportPlugin >() |