all repos — mgba @ 48cf8448c161b51f49d7ee0aa87303c329487d57

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 <memory>
 14
 15#include "CoreController.h"
 16
 17#include "ui_VideoView.h"
 18
 19#include "feature/ffmpeg/ffmpeg-encoder.h"
 20
 21namespace QGBA {
 22
 23class CoreController;
 24
 25class VideoView : public QWidget {
 26Q_OBJECT
 27
 28public:
 29	VideoView(QWidget* parent = nullptr);
 30	virtual ~VideoView();
 31
 32	mAVStream* getStream() { return &m_encoder.d; }
 33
 34public slots:
 35	void setController(std::shared_ptr<CoreController>);
 36
 37	void startRecording();
 38	void stopRecording();
 39	void setNativeResolution(const QSize&);
 40
 41signals:
 42	void recordingStarted(mAVStream*);
 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	void updatePresets();
 64
 65private:
 66	struct Preset {
 67		QString container;
 68		QString vcodec;
 69		QString acodec;
 70		int vbr;
 71		int abr;
 72		QSize dims;
 73
 74		bool compatible(const Preset&) const;
 75	};
 76
 77	bool validateSettings();
 78	void updateAspectRatio(int width, int height, bool force = false);
 79	static QString sanitizeCodec(const QString&, const QMap<QString, QString>& mapping);
 80	static void safelyCheck(QAbstractButton*, bool set = true);
 81	static void safelySet(QSpinBox*, int value);
 82	static void safelySet(QComboBox*, const QString& value);
 83
 84	void addPreset(QAbstractButton*, const Preset&);
 85	void setPreset(const Preset&);
 86
 87	QSize maintainAspect(const QSize&);
 88
 89	Ui::VideoView m_ui;
 90
 91	FFmpegEncoder m_encoder;
 92
 93	QString m_filename;
 94	QString m_audioCodec;
 95	QString m_videoCodec;
 96	QString m_container;
 97	char* m_audioCodecCstr = nullptr;
 98	char* m_videoCodecCstr = nullptr;
 99	char* m_containerCstr = nullptr;
100
101	int m_abr;
102	int m_vbr;
103
104	int m_width = 1;
105	int m_height = 1;
106
107	int m_nativeWidth = 0;
108	int m_nativeHeight = 0;
109
110	QMap<QAbstractButton*, Preset> m_presets;
111
112	static QMap<QString, QString> s_acodecMap;
113	static QMap<QString, QString> s_vcodecMap;
114	static QMap<QString, QString> s_containerMap;
115};
116
117}
118
119#endif
120
121#endif