From e1b19d8f1df501e27d58a5eda4f589b126bddf15 Mon Sep 17 00:00:00 2001
From: Tristan Matthews <tristan.matthews@savoirfairelinux.com>
Date: Wed, 23 Apr 2014 15:42:07 -0400
Subject: [PATCH] conference: only create video mixer if needed

This avoids video mixer/camera access for calls with no video

Refs #45998

Change-Id: I5d1a6776a861bbd883863e02c6a02e682def4b0e
---
 daemon/src/conference.cpp              | 4 +++-
 daemon/src/video/video_rtp_session.cpp | 3 ++-
 2 files changed, 5 insertions(+), 2 deletions(-)

diff --git a/daemon/src/conference.cpp b/daemon/src/conference.cpp
index 0d745868eb..d098495ba2 100644
--- a/daemon/src/conference.cpp
+++ b/daemon/src/conference.cpp
@@ -51,7 +51,7 @@ Conference::Conference()
     , confState_(ACTIVE_ATTACHED)
     , participants_()
 #ifdef SFL_VIDEO
-    , videoMixer_(new sfl_video::VideoMixer(id_))
+    , videoMixer_(nullptr)
 #endif
 {
     Recordable::initRecFilename(id_);
@@ -184,6 +184,8 @@ std::string Conference::getConfID() const {
 #ifdef SFL_VIDEO
 std::shared_ptr<sfl_video::VideoMixer> Conference::getVideoMixer()
 {
+    if (!videoMixer_)
+        videoMixer_.reset(new sfl_video::VideoMixer(id_));
     return videoMixer_;
 }
 #endif
diff --git a/daemon/src/video/video_rtp_session.cpp b/daemon/src/video/video_rtp_session.cpp
index e72a67ef3e..a3b753be45 100644
--- a/daemon/src/video/video_rtp_session.cpp
+++ b/daemon/src/video/video_rtp_session.cpp
@@ -246,7 +246,8 @@ void VideoRtpSession::setupConferenceVideoPipeline()
 void VideoRtpSession::getMixerFromConference(Conference &conf)
 {
     std::lock_guard<std::mutex> lock(mutex_);
-    videoMixerSP_ = std::move(conf.getVideoMixer());
+    if (sending_ or receiving_)
+        videoMixerSP_ = std::move(conf.getVideoMixer());
 }
 
 void VideoRtpSession::enterConference(Conference *conf)
-- 
GitLab