all repos — mgba @ ec0b206fee166975fdb3667dee22da0ce50a1107

mGBA Game Boy Advance Emulator

src/platform/qt/VideoView.h (view raw)

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