Commit e6399831 authored by Ronan Abhamon's avatar Ronan Abhamon

feat(src/components/camera/Camera): limit cpu usage

parent cb55e676
...@@ -83,6 +83,7 @@ QOpenGLFramebufferObject *CameraRenderer::createFramebufferObject (const QSize & ...@@ -83,6 +83,7 @@ QOpenGLFramebufferObject *CameraRenderer::createFramebufferObject (const QSize &
m_context_info->width = size.width(); m_context_info->width = size.width();
m_context_info->height = size.height(); m_context_info->height = size.height();
m_context_info->functions = MSFunctions::getInstance()->getFunctions(); m_context_info->functions = MSFunctions::getInstance()->getFunctions();
m_update_context_info = true;
// It's not the same thread as render. // It's not the same thread as render.
core->lockVideoRender(); core->lockVideoRender();
...@@ -136,6 +137,14 @@ void CameraRenderer::synchronize (QQuickFramebufferObject *item) { ...@@ -136,6 +137,14 @@ void CameraRenderer::synchronize (QQuickFramebufferObject *item) {
} }
void CameraRenderer::updateWindowId () { void CameraRenderer::updateWindowId () {
if (!m_update_context_info)
return;
m_update_context_info = false;
qInfo() << "Thread" << QThread::currentThread() << QStringLiteral("Set context info (width: %1, height: %2, is_preview: %3).")
.arg(m_context_info->width).arg(m_context_info->height).arg(m_is_preview);
if (m_is_preview) if (m_is_preview)
CoreManager::getInstance()->getCore()->setNativePreviewWindowId(m_context_info); CoreManager::getInstance()->getCore()->setNativePreviewWindowId(m_context_info);
else if (m_linphone_call) else if (m_linphone_call)
...@@ -152,7 +161,7 @@ Camera::Camera (QQuickItem *parent) : QQuickFramebufferObject(parent) { ...@@ -152,7 +161,7 @@ Camera::Camera (QQuickItem *parent) : QQuickFramebufferObject(parent) {
setMirrorVertically(true); setMirrorVertically(true);
m_refresh_timer = new QTimer(this); m_refresh_timer = new QTimer(this);
m_refresh_timer->setInterval(1 / 60 * 1000); m_refresh_timer->setInterval(1 / 30 * 1000);
QObject::connect(m_refresh_timer, &QTimer::timeout, this, &QQuickFramebufferObject::update); QObject::connect(m_refresh_timer, &QTimer::timeout, this, &QQuickFramebufferObject::update);
m_refresh_timer->start(); m_refresh_timer->start();
......
...@@ -50,6 +50,7 @@ private: ...@@ -50,6 +50,7 @@ private:
void updateWindowId (); void updateWindowId ();
ContextInfo *m_context_info; ContextInfo *m_context_info;
bool m_update_context_info = false;
bool m_is_preview = false; bool m_is_preview = false;
shared_ptr<linphone::Call> m_linphone_call; shared_ptr<linphone::Call> m_linphone_call;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment