1
0
mirror of https://github.com/qTox/qTox.git synced 2024-03-22 14:00:36 +08:00

fix(video): allow not integer framerates

Fix #4866 and #4764
This commit is contained in:
sudden6 2017-12-21 21:24:15 +01:00
parent f22def5a19
commit db7ee65d0e
No known key found for this signature in database
GPG Key ID: 279509B499E032B9
6 changed files with 14 additions and 12 deletions

View File

@ -1984,13 +1984,13 @@ void Settings::setCamVideoRes(QRect newValue)
}
}
unsigned short Settings::getCamVideoFPS() const
float Settings::getCamVideoFPS() const
{
QMutexLocker locker{&bigLock};
return camVideoFPS;
}
void Settings::setCamVideoFPS(unsigned short newValue)
void Settings::setCamVideoFPS(float newValue)
{
QMutexLocker locker{&bigLock};

View File

@ -117,7 +117,7 @@ class Settings : public QObject, public ICoreSettings, public IAudioSettings, pu
Q_PROPERTY(QRect camVideoRes READ getCamVideoRes WRITE setCamVideoRes NOTIFY camVideoResChanged FINAL)
Q_PROPERTY(QRect screenRegion READ getScreenRegion WRITE setScreenRegion NOTIFY screenRegionChanged FINAL)
Q_PROPERTY(bool screenGrabbed READ getScreenGrabbed WRITE setScreenGrabbed NOTIFY screenGrabbedChanged FINAL)
Q_PROPERTY(quint16 camVideoFPS READ getCamVideoFPS WRITE setCamVideoFPS NOTIFY camVideoFPSChanged FINAL)
Q_PROPERTY(float camVideoFPS READ getCamVideoFPS WRITE setCamVideoFPS NOTIFY camVideoFPSChanged FINAL)
public:
enum class StyleType
@ -394,8 +394,8 @@ public:
QRect getCamVideoRes() const override;
void setCamVideoRes(QRect newValue) override;
unsigned short getCamVideoFPS() const override;
void setCamVideoFPS(unsigned short newValue) override;
float getCamVideoFPS() const override;
void setCamVideoFPS(float newValue) override;
SIGNAL_IMPL(Settings, videoDevChanged, const QString& device)
SIGNAL_IMPL(Settings, screenRegionChanged, const QRect& region)
@ -658,7 +658,7 @@ private:
QRect camVideoRes;
QRect screenRegion;
bool screenGrabbed;
unsigned short camVideoFPS;
float camVideoFPS;
struct friendProp
{

View File

@ -153,9 +153,11 @@ CameraDevice* CameraDevice::open(QString devName, VideoMode mode)
return nullptr;
}
int FPS = 5;
if (mode.FPS) {
float FPS = 5;
if (mode.FPS > 0.0f) {
FPS = mode.FPS;
} else {
qWarning() << "VideoMode could be invalid!";
}
const std::string videoSize = QStringLiteral("%1x%2").arg(mode.width).arg(mode.height).toStdString();

View File

@ -20,8 +20,8 @@ public:
virtual QRect getCamVideoRes() const = 0;
virtual void setCamVideoRes(QRect newValue) = 0;
virtual unsigned short getCamVideoFPS() const = 0;
virtual void setCamVideoFPS(unsigned short newValue) = 0;
virtual float getCamVideoFPS() const = 0;
virtual void setCamVideoFPS(float newValue) = 0;
DECLARE_SIGNAL(videoDevChanged, const QString& device);
DECLARE_SIGNAL(screenRegionChanged, const QRect& region);

View File

@ -33,7 +33,7 @@
* @brief Frames per second supported by the device at this resolution
*/
VideoMode::VideoMode(int width, int height, int x, int y, int FPS, int format)
VideoMode::VideoMode(int width, int height, int x, int y, float FPS, int format)
: width(width)
, height(height)
, x(x)

View File

@ -30,7 +30,7 @@ struct VideoMode
float FPS;
uint32_t pixel_format;
VideoMode(int width = 0, int height = 0, int x = 0, int y = 0, int FPS = 0, int format = 0);
VideoMode(int width = 0, int height = 0, int x = 0, int y = 0, float FPS = 0.0f, int format = 0);
explicit VideoMode(QRect rect);