all repos — mgba @ 4c38f769565e8ddd7d3a8eef1a41975206c129a0

mGBA Game Boy Advance Emulator

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