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