diff --git a/src/call.cpp b/src/call.cpp index 0be3e5fea3272436dba7934b2d817af995078514..eb86407f7868cf1dd0723ce46745bba807809f7e 100644 --- a/src/call.cpp +++ b/src/call.cpp @@ -608,6 +608,17 @@ AbstractHistoryBackend* Call::backend() const } +///Does this call currently has video +bool Call::hasVideo() const +{ + #ifdef ENABLE_VIDEO + return VideoModel::instance()->getRenderer(this) != nullptr; + #else + return false; + #endif +} + + ///Get the current state Call::State Call::state() const { diff --git a/src/call.h b/src/call.h index 18106da3f2936c614d2ee79501abed6ba88ea0db..ec90b46f07bdbc60ff092cdc634bb09dc2294edb 100644 --- a/src/call.h +++ b/src/call.h @@ -279,6 +279,7 @@ public: Q_PROPERTY( QString toHumanStateName READ toHumanStateName ) Q_PROPERTY( bool missed READ isMissed ) Q_PROPERTY( Direction direction READ direction ) + Q_PROPERTY( bool hasVideo READ hasVideo ) Q_PROPERTY( Call::LegacyHistoryState historyState READ historyState ) //Read/write properties @@ -329,6 +330,7 @@ public: bool isMissed () const; Call::Direction direction () const; AbstractHistoryBackend* backend () const; + bool hasVideo () const; //Automated function Call::State stateChanged(const QString & newState); diff --git a/src/videorenderer.cpp b/src/videorenderer.cpp index 89cd560095c8b83de874bfdb5223092dd7478b59..e92f3b3c25292206940d17811f67bd4ddf03663c 100644 --- a/src/videorenderer.cpp +++ b/src/videorenderer.cpp @@ -29,8 +29,7 @@ #include <sys/mman.h> #include <semaphore.h> #include <errno.h> -// #include <linux/time.h> -#include <time.h> + #ifndef CLOCK_REALTIME #define CLOCK_REALTIME 0 @@ -265,6 +264,15 @@ void VideoRenderer::timedEvents() bool ok = renderToBitmap(); if (ok == true) { + + //Compute the FPS shown to the client + if (m_CurrentTime.second() != QTime::currentTime().second()) { + m_Fps = m_fpsC; + m_fpsC=0; + m_CurrentTime = QTime::currentTime(); + } + m_fpsC++; + emit frameUpdated(); } else { @@ -349,6 +357,12 @@ QMutex* VideoRenderer::mutex() return m_pMutex; } +///Get the current frame rate of this renderer +int VideoRenderer::fps() const +{ + return m_Fps; +} + /***************************************************************************** * * diff --git a/src/videorenderer.h b/src/videorenderer.h index d07607a7a27bfdc16e1fd6a61fd74ed73c3fdca5..cff3189f02b1fdfffa8409475d06b0070e2e6fb9 100644 --- a/src/videorenderer.h +++ b/src/videorenderer.h @@ -20,6 +20,7 @@ //Base #include <QtCore/QObject> +#include <QtCore/QTime> #include "typedefs.h" #include <time.h> @@ -49,11 +50,12 @@ class LIB_EXPORT VideoRenderer : public QObject { bool startShm (); //Getters - const char* rawData (); - bool isRendering (); - QByteArray currentFrame (); - Resolution activeResolution(); - QMutex* mutex (); + const char* rawData () ; + bool isRendering () ; + QByteArray currentFrame () ; + Resolution activeResolution() ; + QMutex* mutex () ; + int fps () const; //Setters void setResolution(QSize size); @@ -76,6 +78,9 @@ class LIB_EXPORT VideoRenderer : public QObject { QMutex* m_pMutex ; QMutex* m_pSSMutex ; QString m_Id ; + int m_fpsC ; + int m_Fps ; + QTime m_CurrentTime; //Constants static const int TIMEOUT_SEC = 1; // 1 second