~gabriel1984sibiu/simplescreenrecorder/simplescreenrecorder

« back to all changes in this revision

Viewing changes to src/GUI/PageOutput.h

  • Committer: Grevutiu Gabriel
  • Date: 2014-12-24 12:30:41 UTC
  • Revision ID: gabriel1984sibiu@gmail.com-20141224123041-xndgql40iww2bh2m
original source code from upstreamer

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
Copyright (c) 2012-2014 Maarten Baert <maarten-baert@hotmail.com>
 
3
 
 
4
This file is part of SimpleScreenRecorder.
 
5
 
 
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.
 
10
 
 
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.
 
15
 
 
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/>.
 
18
*/
 
19
 
 
20
#pragma once
 
21
#include "Global.h"
 
22
 
 
23
#include "ProfileBox.h"
 
24
 
 
25
class MainWindow;
 
26
 
 
27
class PageOutput : public QWidget {
 
28
        Q_OBJECT
 
29
 
 
30
public:
 
31
        enum enum_container {
 
32
                CONTAINER_MKV,
 
33
                CONTAINER_MP4,
 
34
                CONTAINER_WEBM,
 
35
                CONTAINER_OGG,
 
36
                CONTAINER_OTHER,
 
37
                CONTAINER_COUNT // must be last
 
38
        };
 
39
        enum enum_video_codec {
 
40
                VIDEO_CODEC_H264,
 
41
                VIDEO_CODEC_VP8,
 
42
                VIDEO_CODEC_THEORA,
 
43
                VIDEO_CODEC_OTHER,
 
44
                VIDEO_CODEC_COUNT // must be last
 
45
        };
 
46
        enum enum_audio_codec {
 
47
                AUDIO_CODEC_VORBIS,
 
48
                AUDIO_CODEC_MP3,
 
49
                AUDIO_CODEC_AAC,
 
50
                AUDIO_CODEC_UNCOMPRESSED,
 
51
                AUDIO_CODEC_OTHER,
 
52
                AUDIO_CODEC_COUNT // must be last
 
53
        };
 
54
        enum enum_h264_preset {
 
55
                H264_PRESET_ULTRAFAST,
 
56
                H264_PRESET_SUPERFAST,
 
57
                H264_PRESET_VERYFAST,
 
58
                H264_PRESET_FASTER,
 
59
                H264_PRESET_FAST,
 
60
                H264_PRESET_MEDIUM,
 
61
                H264_PRESET_SLOW,
 
62
                H264_PRESET_SLOWER,
 
63
                H264_PRESET_VERYSLOW,
 
64
                H264_PRESET_PLACEBO,
 
65
                H264_PRESET_COUNT // must be last
 
66
        };
 
67
 
 
68
private:
 
69
        struct ContainerData {
 
70
                QString name, avname;
 
71
                QStringList suffixes;
 
72
                QString filter;
 
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); }
 
76
        };
 
77
        struct VideoCodecData {
 
78
                QString name, avname;
 
79
                inline bool operator<(const VideoCodecData& other) const { return (avname < other.avname); }
 
80
        };
 
81
        struct AudioCodecData {
 
82
                QString name, avname;
 
83
                inline bool operator<(const AudioCodecData& other) const { return (avname < other.avname); }
 
84
        };
 
85
 
 
86
private:
 
87
        MainWindow *m_main_window;
 
88
 
 
89
        enum_container m_old_container;
 
90
        unsigned int m_old_container_av;
 
91
 
 
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;
 
95
 
 
96
        ProfileBox *m_profile_box;
 
97
 
 
98
        QComboBox *m_combobox_profiles;
 
99
        QPushButton *m_pushbutton_profile_save, *m_pushbutton_profile_new, *m_pushbutton_profile_delete;
 
100
 
 
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;
 
106
 
 
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;
 
122
 
 
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;
 
131
 
 
132
public:
 
133
        PageOutput(MainWindow* main_window);
 
134
 
 
135
        void LoadSettings(QSettings* settings);
 
136
        void SaveSettings(QSettings* settings);
 
137
 
 
138
private:
 
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);
 
143
 
 
144
public:
 
145
        void PageStart();
 
146
 
 
147
        QString GetFileProtocol();
 
148
        QString GetContainerAVName();
 
149
        QString GetVideoCodecAVName();
 
150
        QString GetAudioCodecAVName();
 
151
 
 
152
private:
 
153
        unsigned int FindContainerAV(const QString& name);
 
154
        unsigned int FindVideoCodecAV(const QString& name);
 
155
        unsigned int FindAudioCodecAV(const QString& name);
 
156
 
 
157
private:
 
158
        void LoadProfiles();
 
159
        void LoadProfilesFromDir(const QString& path, bool can_delete);
 
160
        void UpdateProfileFields();
 
161
 
 
162
public slots:
 
163
        void OnUpdateSuffixAndContainerFields();
 
164
        void OnUpdateContainerFields();
 
165
        void OnUpdateVideoCodecFields();
 
166
        void OnUpdateAudioCodecFields();
 
167
 
 
168
private slots:
 
169
        void OnBrowse();
 
170
        void OnContinue();
 
171
 
 
172
public:
 
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(); }
 
190
 
 
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); }
 
208
 
 
209
};