2
Copyright (c) 2012-2014 Maarten Baert <maarten-baert@hotmail.com>
4
This file is part of SimpleScreenRecorder.
6
SimpleScreenRecorder is free software: you can redistribute it and/or modify
7
it under the terms of the GNU General Public License as published by
8
the Free Software Foundation, either version 3 of the License, or
9
(at your option) any later version.
11
SimpleScreenRecorder is distributed in the hope that it will be useful,
12
but WITHOUT ANY WARRANTY; without even the implied warranty of
13
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
GNU General Public License for more details.
16
You should have received a copy of the GNU General Public License
17
along with SimpleScreenRecorder. If not, see <http://www.gnu.org/licenses/>.
23
#include "ProfileBox.h"
27
class PageOutput : public QWidget {
37
CONTAINER_COUNT // must be last
39
enum enum_video_codec {
44
VIDEO_CODEC_COUNT // must be last
46
enum enum_audio_codec {
50
AUDIO_CODEC_UNCOMPRESSED,
52
AUDIO_CODEC_COUNT // must be last
54
enum enum_h264_preset {
55
H264_PRESET_ULTRAFAST,
56
H264_PRESET_SUPERFAST,
65
H264_PRESET_COUNT // must be last
69
struct ContainerData {
73
std::set<enum_video_codec> supported_video_codecs;
74
std::set<enum_audio_codec> supported_audio_codecs;
75
inline bool operator<(const ContainerData& other) const { return (avname < other.avname); }
77
struct VideoCodecData {
79
inline bool operator<(const VideoCodecData& other) const { return (avname < other.avname); }
81
struct AudioCodecData {
83
inline bool operator<(const AudioCodecData& other) const { return (avname < other.avname); }
87
MainWindow *m_main_window;
89
enum_container m_old_container;
90
unsigned int m_old_container_av;
92
std::vector<ContainerData> m_containers, m_containers_av;
93
std::vector<VideoCodecData> m_video_codecs, m_video_codecs_av;
94
std::vector<AudioCodecData> m_audio_codecs, m_audio_codecs_av;
96
ProfileBox *m_profile_box;
98
QComboBox *m_combobox_profiles;
99
QPushButton *m_pushbutton_profile_save, *m_pushbutton_profile_new, *m_pushbutton_profile_delete;
101
QLineEdit *m_lineedit_file;
102
QCheckBox *m_checkbox_separate_files;
103
QComboBox *m_combobox_container;
104
QLabel *m_label_container_av;
105
QComboBox *m_combobox_container_av;
107
QComboBox *m_combobox_video_codec;
108
QLabel *m_label_video_codec_av;
109
QComboBox *m_combobox_video_codec_av;
110
QLabel *m_label_video_kbit_rate;
111
QLineEdit *m_lineedit_video_kbit_rate;
112
QLabel *m_label_h264_crf;
113
QSlider *m_slider_h264_crf;
114
QLabel *m_label_h264_crf_value;
115
QLabel *m_label_h264_preset;
116
QComboBox *m_combobox_h264_preset;
117
QLabel *m_label_vp8_cpu_used;
118
QComboBox *m_combobox_vp8_cpu_used;
119
QLabel *m_label_video_options;
120
QLineEdit *m_lineedit_video_options;
121
QCheckBox *m_checkbox_video_allow_frame_skipping;
123
QGroupBox *m_groupbox_audio;
124
QComboBox *m_combobox_audio_codec;
125
QLabel *m_label_audio_codec_av;
126
QComboBox *m_combobox_audio_codec_av;
127
QLabel *m_label_audio_kbit_rate;
128
QLineEdit *m_lineedit_audio_kbit_rate;
129
QLabel *m_label_audio_options;
130
QLineEdit *m_lineedit_audio_options;
133
PageOutput(MainWindow* main_window);
135
void LoadSettings(QSettings* settings);
136
void SaveSettings(QSettings* settings);
139
static void LoadProfileSettingsCallback(QSettings* settings, void* userdata);
140
static void SaveProfileSettingsCallback(QSettings* settings, void* userdata);
141
void LoadProfileSettings(QSettings* settings);
142
void SaveProfileSettings(QSettings* settings);
147
QString GetFileProtocol();
148
QString GetContainerAVName();
149
QString GetVideoCodecAVName();
150
QString GetAudioCodecAVName();
153
unsigned int FindContainerAV(const QString& name);
154
unsigned int FindVideoCodecAV(const QString& name);
155
unsigned int FindAudioCodecAV(const QString& name);
159
void LoadProfilesFromDir(const QString& path, bool can_delete);
160
void UpdateProfileFields();
163
void OnUpdateSuffixAndContainerFields();
164
void OnUpdateContainerFields();
165
void OnUpdateVideoCodecFields();
166
void OnUpdateAudioCodecFields();
173
inline unsigned int GetProfile() { return m_profile_box->GetProfile(); }
174
inline QString GetFile() { return m_lineedit_file->text(); }
175
inline bool GetSeparateFiles() { return m_checkbox_separate_files->isChecked(); }
176
inline enum_container GetContainer() { return (enum_container) clamp(m_combobox_container->currentIndex(), 0, CONTAINER_COUNT - 1); }
177
inline unsigned int GetContainerAV() { return clamp(m_combobox_container_av->currentIndex(), 0, (int) m_containers_av.size() - 1); }
178
inline enum_video_codec GetVideoCodec() { return (enum_video_codec) clamp(m_combobox_video_codec->currentIndex(), 0, VIDEO_CODEC_COUNT - 1); }
179
inline unsigned int GetVideoCodecAV() { return clamp(m_combobox_video_codec_av->currentIndex(), 0, (int) m_video_codecs_av.size() - 1); }
180
inline unsigned int GetVideoKBitRate() { return m_lineedit_video_kbit_rate->text().toUInt(); }
181
inline unsigned int GetH264CRF() { return m_slider_h264_crf->value(); }
182
inline enum_h264_preset GetH264Preset() { return (enum_h264_preset) clamp(m_combobox_h264_preset->currentIndex(), 0, H264_PRESET_COUNT - 1); }
183
inline unsigned int GetVP8CPUUsed() { return clamp(5 - m_combobox_vp8_cpu_used->currentIndex(), 0, 5); }
184
inline QString GetVideoOptions() { return m_lineedit_video_options->text(); }
185
inline bool GetVideoAllowFrameSkipping() { return m_checkbox_video_allow_frame_skipping->isChecked(); }
186
inline enum_audio_codec GetAudioCodec() { return (enum_audio_codec) clamp(m_combobox_audio_codec->currentIndex(), 0, AUDIO_CODEC_COUNT - 1); }
187
inline unsigned int GetAudioCodecAV() { return clamp(m_combobox_audio_codec_av->currentIndex(), 0, (int) m_audio_codecs_av.size() - 1); }
188
inline unsigned int GetAudioKBitRate() { return m_lineedit_audio_kbit_rate->text().toUInt(); }
189
inline QString GetAudioOptions() { return m_lineedit_audio_options->text(); }
191
inline void SetProfile(unsigned int profile) { m_profile_box->SetProfile(profile); }
192
inline void SetContainer(enum_container container) { m_combobox_container->setCurrentIndex(clamp((unsigned int) container, 0u, (unsigned int) CONTAINER_COUNT - 1)); }
193
inline void SetContainerAV(unsigned int container) { m_combobox_container_av->setCurrentIndex(clamp(container, 0u, (unsigned int) m_containers_av.size() - 1)); }
194
inline void SetFile(const QString& file) { m_lineedit_file->setText(file); }
195
inline void SetSeparateFiles(bool separate_files) { m_checkbox_separate_files->setChecked(separate_files); }
196
inline void SetVideoCodec(enum_video_codec video_codec) { m_combobox_video_codec->setCurrentIndex(clamp((unsigned int) video_codec, 0u, (unsigned int) VIDEO_CODEC_COUNT - 1)); }
197
inline void SetVideoCodecAV(unsigned int video_codec_av) { m_combobox_video_codec_av->setCurrentIndex(clamp(video_codec_av, 0u, (unsigned int) m_video_codecs_av.size() - 1)); }
198
inline void SetVideoKBitRate(unsigned int kbit_rate) { m_lineedit_video_kbit_rate->setText(QString::number(kbit_rate)); }
199
inline void SetH264CRF(unsigned int crf) { m_slider_h264_crf->setValue(crf); }
200
inline void SetH264Preset(enum_h264_preset preset) { m_combobox_h264_preset->setCurrentIndex(clamp((unsigned int) preset, 0u, (unsigned int) H264_PRESET_COUNT - 1)); }
201
inline void SetVP8CPUUsed(unsigned int cpu_used) { m_combobox_vp8_cpu_used->setCurrentIndex(clamp(5 - (int) cpu_used, 0, 5)); }
202
inline void SetVideoOptions(const QString& options) { m_lineedit_video_options->setText(options); }
203
inline void SetVideoAllowFrameSkipping(bool allow_frame_skipping) { return m_checkbox_video_allow_frame_skipping->setChecked(allow_frame_skipping); }
204
inline void SetAudioCodec(enum_audio_codec audio_codec) { m_combobox_audio_codec->setCurrentIndex(clamp((unsigned int) audio_codec, 0u, (unsigned int) AUDIO_CODEC_COUNT - 1)); }
205
inline void SetAudioCodecAV(unsigned int audio_codec_av) { m_combobox_audio_codec_av->setCurrentIndex(clamp(audio_codec_av, 0u, (unsigned int) m_audio_codecs_av.size() - 1)); }
206
inline void SetAudioKBitRate(unsigned int kbit_rate) { m_lineedit_audio_kbit_rate->setText(QString::number(kbit_rate)); }
207
inline void SetAudioOptions(const QString& options) { m_lineedit_audio_options->setText(options); }