Audacity 3.2.0
FFmpegPrefs.cpp
Go to the documentation of this file.
1/**********************************************************************
2
3 Audacity: A Digital Audio Editor
4
5 @file FFmpegPrefs.cpp
6 @brief adds controls for FFmpeg import/export to Library preferences
7
8 Paul Licameli split from LibraryPrefs.cpp
9
10**********************************************************************/
11
12#include "../FFmpeg.h"
13#include "Internat.h"
14#include "ShuttleGui.h"
15#include "prefs/LibraryPrefs.h"
16#include "AudacityMessageBox.h"
17#include "HelpSystem.h"
18#include "ReadOnlyText.h"
19#include <wx/stattext.h>
20
21namespace {
22
23struct State {
24 wxWindow *parent = nullptr;
25 ReadOnlyText *FFmpegVersion = nullptr;
26};
27
28void OnFFmpegFindButton(State &state);
29
31{
32 auto FFmpegVersion = state.FFmpegVersion;
33 FFmpegVersion->SetValue(GetFFmpegVersion());
34}
35
37{
38 auto pState = std::make_shared<State>();
39 pState->parent = S.GetParent();
40
41 S.StartStatic(XO("FFmpeg Import/Export Library"));
42 {
43 S.StartTwoColumn();
44 {
45 auto version =
46 XO("No compatible FFmpeg library was found");
47
48 pState->FFmpegVersion = S
49 .Position(wxALIGN_CENTRE_VERTICAL)
50 .AddReadOnlyText(XO("FFmpeg Library Version:"), version.Translation());
51
52 S.AddVariableText(XO("FFmpeg Library:"),
53 true, wxALL | wxALIGN_RIGHT | wxALIGN_CENTRE_VERTICAL);
54
55 auto pFindButton =
56 S
57#if defined(DISABLE_DYNAMIC_LOADING_FFMPEG)
58 .Disable()
59#endif
60 .AddButton(XXO("Loca&te..."),
61 wxALL | wxALIGN_LEFT | wxALIGN_CENTRE_VERTICAL);
62 if (pFindButton)
63 pFindButton->Bind(wxEVT_BUTTON, [pState](wxCommandEvent&){
64 OnFFmpegFindButton(*pState);
65 });
66
67 S.AddVariableText(XO("FFmpeg Library:"),
68 true, wxALL | wxALIGN_RIGHT | wxALIGN_CENTRE_VERTICAL);
69
70 auto pDownButton =
71 S
72#if defined(DISABLE_DYNAMIC_LOADING_FFMPEG)
73 .Disable()
74#endif
75 .AddButton(XXO("Dow&nload"),
76 wxALL | wxALIGN_LEFT | wxALIGN_CENTRE_VERTICAL);
77 if (pDownButton)
78 pDownButton->Bind(wxEVT_BUTTON, [pState](wxCommandEvent&){
79 HelpSystem::ShowHelp(pState->parent,
80 wxT("FAQ:Installing_the_FFmpeg_Import_Export_Library"), true);
81 });
82 }
83 S.EndTwoColumn();
84 }
85 S.EndStatic();
86
87 SetFFmpegVersionText(*pState);
88}
89
91{
92 bool showerrs =
93#if defined(_DEBUG)
94 true;
95#else
96 false;
97#endif
98 // Load the libs ('true' means that all errors will be shown)
99 bool locate = !LoadFFmpeg(showerrs);
100
101 // Libs are fine, don't show "locate" dialog unless user really wants it
102 if (!locate) {
103 int response = AudacityMessageBox(
104 XO(
105"Audacity has automatically detected valid FFmpeg libraries.\nDo you still want to locate them manually?"),
106 XO("Success"),
107 wxCENTRE | wxYES_NO | wxNO_DEFAULT |wxICON_QUESTION);
108 if (response == wxYES) {
109 locate = true;
110 }
111 }
112
113 if (locate) {
114 // Show "Locate FFmpeg" dialog
115 FindFFmpegLibs(state.parent);
116 LoadFFmpeg(showerrs);
117 }
119}
120
122
123}
wxT("CloseDown"))
int AudacityMessageBox(const TranslatableString &message, const TranslatableString &caption, long style, wxWindow *parent, int x, int y)
TranslatableString GetFFmpegVersion()
Definition: FFmpeg.cpp:75
bool FindFFmpegLibs(wxWindow *parent)
Definition: FFmpeg.cpp:303
bool LoadFFmpeg(bool showerror)
Definition: FFmpeg.cpp:39
XO("Cut/Copy/Paste")
XXO("&Cut/Copy/Paste Toolbar")
#define S(N)
Definition: ToChars.cpp:64
static void ShowHelp(wxWindow *parent, const FilePath &localFileName, const URLString &remoteURL, bool bModal=false, bool alwaysDefaultBrowser=false)
Definition: HelpSystem.cpp:231
void SetValue(const wxString &value)
Definition: ReadOnlyText.h:124
Derived from ShuttleGuiBase, an Audacity specific class for shuttling data to and from GUI.
Definition: ShuttleGui.h:640
void SetFFmpegVersionText(State &state)
Definition: FFmpegPrefs.cpp:30
LibraryPrefs::RegisteredControls reg
To be statically constructed, it registers additions to the Library preference page.
Definition: LibraryPrefs.h:38