Skip to content
This repository has been archived by the owner on Feb 12, 2023. It is now read-only.

Commit

Permalink
fix(video): allow not integer framerates
Browse files Browse the repository at this point in the history
Fix #4866 and #4764
  • Loading branch information
sudden6 committed Dec 21, 2017
1 parent f22def5 commit db7ee65
Show file tree
Hide file tree
Showing 6 changed files with 14 additions and 12 deletions.
4 changes: 2 additions & 2 deletions src/persistence/settings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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};

Expand Down
8 changes: 4 additions & 4 deletions src/persistence/settings.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -394,8 +394,8 @@ public slots:
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)
Expand Down Expand Up @@ -658,7 +658,7 @@ public slots:
QRect camVideoRes;
QRect screenRegion;
bool screenGrabbed;
unsigned short camVideoFPS;
float camVideoFPS;

struct friendProp
{
Expand Down
6 changes: 4 additions & 2 deletions src/video/cameradevice.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
4 changes: 2 additions & 2 deletions src/video/ivideosettings.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ class IVideoSettings {
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);
Expand Down
2 changes: 1 addition & 1 deletion src/video/videomode.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion src/video/videomode.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down

0 comments on commit db7ee65

Please sign in to comment.