all repos — mgba @ cec4d48c8afb49e7e81e0e3e5eeeb7588331bc32

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
 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	void setNativeFrameRate(const QPair<unsigned, unsigned>& ratio);
 33
 34signals:
 35	void recordingStarted(mAVStream*);
 36	void recordingStopped();
 37
 38private slots:
 39	void selectFile();
 40	void setFilename(const QString&);
 41	void setAudioCodec(const QString&, bool manual = true);
 42	void setVideoCodec(const QString&, bool manual = true);
 43	void setContainer(const QString&, bool manual = true);
 44
 45	void setAudioBitrate(int, bool manual = true);
 46	void setVideoBitrate(int, bool manual = true);
 47
 48	void setWidth(int, bool manual = true);
 49	void setHeight(int, bool manual = true);
 50	void setAspectWidth(int, bool manual = true);
 51	void setAspectHeight(int, bool manual = true);
 52
 53	void showAdvanced(bool);
 54
 55	void uncheckIncompatible();
 56	void updatePresets();
 57
 58private:
 59	struct Preset {
 60		QString container;
 61		QString vcodec;
 62		QString acodec;
 63		int vbr;
 64		int abr;
 65		QSize dims;
 66
 67		bool compatible(const Preset&) const;
 68	};
 69
 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	QSize maintainAspect(const QSize&);
 81
 82	Ui::VideoView m_ui;
 83
 84	FFmpegEncoder m_encoder;
 85
 86	QString m_filename;
 87	QString m_audioCodec;
 88	QString m_videoCodec;
 89	QString m_container;
 90	char* m_audioCodecCstr;
 91	char* m_videoCodecCstr;
 92	char* m_containerCstr;
 93
 94	int m_abr;
 95	int m_vbr;
 96
 97	int m_width;
 98	int m_height;
 99
100	int m_nativeWidth;
101	int m_nativeHeight;
102
103	QMap<QAbstractButton*, Preset> m_presets;
104
105	static QMap<QString, QString> s_acodecMap;
106	static QMap<QString, QString> s_vcodecMap;
107	static QMap<QString, QString> s_containerMap;
108};
109
110}
111
112#endif
113
114#endif