src/platform/qt/VideoView.h (view raw)
1/* Copyright (c) 2013-2014 Jeffrey Pfau
2 *
3 * This Source Code Form is subject to the terms of the Mozilla Public
4 * License, v. 2.0. If a copy of the MPL was not distributed with this
5 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
6#ifndef QGBA_VIDEO_VIEW
7#define QGBA_VIDEO_VIEW
8
9#ifdef USE_FFMPEG
10
11#include <QWidget>
12
13#include "ui_VideoView.h"
14
15extern "C" {
16#include "feature/ffmpeg/ffmpeg-encoder.h"
17}
18
19namespace QGBA {
20
21class VideoView : public QWidget {
22Q_OBJECT
23
24public:
25 struct Preset {
26 QString container;
27 QString vcodec;
28 QString acodec;
29 int vbr;
30 int abr;
31 int width;
32 int height;
33
34 bool compatible(const Preset&) const;
35 };
36
37 VideoView(QWidget* parent = nullptr);
38 virtual ~VideoView();
39
40 mAVStream* getStream() { return &m_encoder.d; }
41
42public slots:
43 void startRecording();
44 void stopRecording();
45
46signals:
47 void recordingStarted(mAVStream*);
48 void recordingStopped();
49
50private slots:
51 void selectFile();
52 void setFilename(const QString&);
53 void setAudioCodec(const QString&, bool manual = true);
54 void setVideoCodec(const QString&, bool manual = true);
55 void setContainer(const QString&, bool manual = true);
56
57 void setAudioBitrate(int, bool manual = true);
58 void setVideoBitrate(int, bool manual = true);
59
60 void setWidth(int, bool manual = true);
61 void setHeight(int, bool manual = true);
62 void setAspectWidth(int, bool manual = true);
63 void setAspectHeight(int, bool manual = true);
64
65 void showAdvanced(bool);
66
67 void uncheckIncompatible();
68
69private:
70 bool validateSettings();
71 void updateAspectRatio(int width, int height, bool force = false);
72 static QString sanitizeCodec(const QString&, const QMap<QString, QString>& mapping);
73 static void safelyCheck(QAbstractButton*, bool set = true);
74 static void safelySet(QSpinBox*, int value);
75 static void safelySet(QComboBox*, const QString& value);
76
77 void addPreset(QAbstractButton*, const Preset&);
78 void setPreset(const Preset&);
79
80 Ui::VideoView m_ui;
81
82 FFmpegEncoder m_encoder;
83
84 QString m_filename;
85 QString m_audioCodec;
86 QString m_videoCodec;
87 QString m_container;
88 char* m_audioCodecCstr;
89 char* m_videoCodecCstr;
90 char* m_containerCstr;
91
92 int m_abr;
93 int m_vbr;
94
95 int m_width;
96 int m_height;
97
98 QMap<QAbstractButton*, Preset> m_presets;
99
100 static QMap<QString, QString> s_acodecMap;
101 static QMap<QString, QString> s_vcodecMap;
102 static QMap<QString, QString> s_containerMap;
103};
104
105}
106
107#endif
108
109#endif