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#pragma once
7
8#ifdef USE_FFMPEG
9
10#include <QWidget>
11
12#include <memory>
13
14#include "CoreController.h"
15
16#include "ui_VideoView.h"
17
18#include "feature/ffmpeg/ffmpeg-encoder.h"
19
20namespace QGBA {
21
22class CoreController;
23
24class VideoView : public QWidget {
25Q_OBJECT
26
27public:
28 VideoView(QWidget* parent = nullptr);
29 virtual ~VideoView();
30
31 mAVStream* getStream() { return &m_encoder.d; }
32
33public slots:
34 void setController(std::shared_ptr<CoreController>);
35
36 void startRecording();
37 void stopRecording();
38 void setNativeResolution(const QSize&);
39
40signals:
41 void recordingStarted(mAVStream*);
42 void recordingStopped();
43
44private slots:
45 void selectFile();
46 void setFilename(const QString&);
47 void setAudioCodec(const QString&, bool manual = true);
48 void setVideoCodec(const QString&, bool manual = true);
49 void setContainer(const QString&, bool manual = true);
50
51 void setAudioBitrate(int, bool manual = true);
52 void setVideoBitrate(int, bool manual = true);
53
54 void setWidth(int, bool manual = true);
55 void setHeight(int, bool manual = true);
56 void setAspectWidth(int, bool manual = true);
57 void setAspectHeight(int, bool manual = true);
58
59 void showAdvanced(bool);
60
61 void uncheckIncompatible();
62 void updatePresets();
63
64private:
65 struct Preset {
66 QString container;
67 QString vcodec;
68 QString acodec;
69 int vbr;
70 int abr;
71 QSize dims;
72
73 Preset() {}
74 Preset(QString container, QString vcodec, QString acodec, int vbr, int abr, QSize dims = QSize())
75 : container(container)
76 , vcodec(vcodec)
77 , acodec(acodec)
78 , vbr(vbr)
79 , abr(abr)
80 , dims(dims) {}
81 Preset(QSize dims) : dims(dims) {}
82 bool compatible(const Preset&) const;
83 };
84
85 bool validateSettings();
86 void updateAspectRatio(int width, int height, bool force = false);
87 static QString sanitizeCodec(const QString&, const QMap<QString, QString>& mapping);
88 static void safelyCheck(QAbstractButton*, bool set = true);
89 static void safelySet(QSpinBox*, int value);
90 static void safelySet(QComboBox*, const QString& value);
91
92 void addPreset(QAbstractButton*, const Preset&);
93 void setPreset(const Preset&);
94
95 QSize maintainAspect(const QSize&);
96
97 Ui::VideoView m_ui;
98
99 FFmpegEncoder m_encoder;
100
101 QString m_filename;
102 QString m_audioCodec;
103 QString m_videoCodec;
104 QString m_container;
105 char* m_audioCodecCstr = nullptr;
106 char* m_videoCodecCstr = nullptr;
107 char* m_containerCstr = nullptr;
108
109 int m_abr;
110 int m_vbr;
111
112 int m_width = 1;
113 int m_height = 1;
114
115 int m_nativeWidth = 0;
116 int m_nativeHeight = 0;
117
118 QMap<QAbstractButton*, Preset> m_presets;
119
120 static QMap<QString, QString> s_acodecMap;
121 static QMap<QString, QString> s_vcodecMap;
122 static QMap<QString, QString> s_containerMap;
123};
124
125}
126
127#endif