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 #if defined(USE_FFMPEG)
47 XO("No compatible FFmpeg library was found");
48 #else
49 XO("FFmpeg support is not compiled in");
50 #endif
51
52 pState->FFmpegVersion = S
53 .Position(wxALIGN_CENTRE_VERTICAL)
54 .AddReadOnlyText(XO("FFmpeg Library Version:"), version.Translation());
55
56 S.AddVariableText(XO("FFmpeg Library:"),
57 true, wxALL | wxALIGN_RIGHT | wxALIGN_CENTRE_VERTICAL);
58
59 auto pFindButton =
60 S
61#if !defined(USE_FFMPEG) || defined(DISABLE_DYNAMIC_LOADING_FFMPEG)
62 .Disable()
63#endif
64 .AddButton(XXO("Loca&te..."),
65 wxALL | wxALIGN_LEFT | wxALIGN_CENTRE_VERTICAL);
66 pFindButton->Bind(wxEVT_BUTTON, [pState](wxCommandEvent&){
67 OnFFmpegFindButton(*pState);
68 });
69
70 S.AddVariableText(XO("FFmpeg Library:"),
71 true, wxALL | wxALIGN_RIGHT | wxALIGN_CENTRE_VERTICAL);
72
73 auto pDownButton =
74 S
75#if !defined(USE_FFMPEG) || defined(DISABLE_DYNAMIC_LOADING_FFMPEG)
76 .Disable()
77#endif
78 .AddButton(XXO("Dow&nload"),
79 wxALL | wxALIGN_LEFT | wxALIGN_CENTRE_VERTICAL);
80 pDownButton->Bind(wxEVT_BUTTON, [pState](wxCommandEvent&){
81 HelpSystem::ShowHelp(pState->parent,
82 wxT("FAQ:Installing_the_FFmpeg_Import_Export_Library"), true);
83 });
84 }
85 S.EndTwoColumn();
86 }
87 S.EndStatic();
88
89 SetFFmpegVersionText(*pState);
90}
91
93{
94#ifdef USE_FFMPEG
95 bool showerrs =
96#if defined(_DEBUG)
97 true;
98#else
99 false;
100#endif
101 // Load the libs ('true' means that all errors will be shown)
102 bool locate = !LoadFFmpeg(showerrs);
103
104 // Libs are fine, don't show "locate" dialog unless user really wants it
105 if (!locate) {
106 int response = AudacityMessageBox(
107 XO(
108"Audacity has automatically detected valid FFmpeg libraries.\nDo you still want to locate them manually?"),
109 XO("Success"),
110 wxCENTRE | wxYES_NO | wxNO_DEFAULT |wxICON_QUESTION);
111 if (response == wxYES) {
112 locate = true;
113 }
114 }
115
116 if (locate) {
117 // Show "Locate FFmpeg" dialog
118 FindFFmpegLibs(state.parent);
119 LoadFFmpeg(showerrs);
120 }
122#endif
123}
124
126
127}
wxT("CloseDown"))
int AudacityMessageBox(const TranslatableString &message, const TranslatableString &caption, long style, wxWindow *parent, int x, int y)
TranslatableString GetFFmpegVersion()
Definition: FFmpeg.cpp:82
bool FindFFmpegLibs(wxWindow *parent)
Definition: FFmpeg.cpp:310
bool LoadFFmpeg(bool showerror)
Definition: FFmpeg.cpp:46
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:233
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:625
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