From 433318cc27d278c145d78a038535a2336485929c Mon Sep 17 00:00:00 2001
From: Emmanuel Lepage Vallee <emmanuel.lepage@savoirfairelinux.com>
Date: Mon, 31 Mar 2014 16:12:25 -0400
Subject: [PATCH] [ #44118 ] Fix rotate left/right buttons

---
 src/call.cpp          | 11 +++++++++++
 src/call.h            |  2 ++
 src/videorenderer.cpp | 18 ++++++++++++++++--
 src/videorenderer.h   | 15 ++++++++++-----
 4 files changed, 39 insertions(+), 7 deletions(-)

diff --git a/src/call.cpp b/src/call.cpp
index 0be3e5fe..eb86407f 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 18106da3..ec90b46f 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 89cd5600..e92f3b3c 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 d07607a7..cff3189f 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
-- 
GitLab