From 598caf51709f273c32c42c0cee65ea48f846ba86 Mon Sep 17 00:00:00 2001
From: Nicolas Jager <nicolas.jager@savoirfairelinux.com>
Date: Mon, 4 Dec 2017 17:08:03 -0500
Subject: [PATCH] fix: conditionals for audio-only

Change-Id: Ic2796d22258e37ad531aec4e638196915e35969e
Reviewed-by: Guillaume Roguez <guillaume.roguez@savoirfairelinux.com>
---
 src/ringdht/ringaccount.cpp | 3 ++-
 src/sip/sipaccount.cpp      | 2 +-
 src/sip/sipcall.cpp         | 3 ++-
 3 files changed, 5 insertions(+), 3 deletions(-)

diff --git a/src/ringdht/ringaccount.cpp b/src/ringdht/ringaccount.cpp
index f33b416ece..1759d303e1 100644
--- a/src/ringdht/ringaccount.cpp
+++ b/src/ringdht/ringaccount.cpp
@@ -526,7 +526,8 @@ RingAccount::onConnectedOutgoingCall(SIPCall& call, const std::string& to_id, Ip
     sdp.setPublishedIP(addrSdp);
     const bool created = sdp.createOffer(
                             getActiveAccountCodecInfoList(MEDIA_AUDIO),
-                            getActiveAccountCodecInfoList(videoEnabled_ and call.isAudioOnly() ? MEDIA_NONE : MEDIA_VIDEO),
+                            getActiveAccountCodecInfoList(videoEnabled_ and not call.isAudioOnly() ? MEDIA_VIDEO
+                                                                                                   : MEDIA_NONE),
                             getSrtpKeyExchange()
                          );
 
diff --git a/src/sip/sipaccount.cpp b/src/sip/sipaccount.cpp
index caf6a87caf..ff20e246cc 100644
--- a/src/sip/sipaccount.cpp
+++ b/src/sip/sipaccount.cpp
@@ -232,7 +232,7 @@ SIPAccount::newOutgoingCall(const std::string& toUrl, const std::map<std::string
 
     const bool created = sdp.createOffer(
         getActiveAccountCodecInfoList(MEDIA_AUDIO),
-        getActiveAccountCodecInfoList(videoEnabled_ ? MEDIA_VIDEO : MEDIA_NONE),
+        getActiveAccountCodecInfoList(videoEnabled_ and not call->isAudioOnly() ? MEDIA_VIDEO : MEDIA_NONE),
         getSrtpKeyExchange()
     );
 
diff --git a/src/sip/sipcall.cpp b/src/sip/sipcall.cpp
index 776e023963..62dcad06cc 100644
--- a/src/sip/sipcall.cpp
+++ b/src/sip/sipcall.cpp
@@ -231,7 +231,8 @@ SIPCall::SIPSessionReinvite()
     sdp_->clearIce();
     auto& acc = getSIPAccount();
     if (not sdp_->createOffer(acc.getActiveAccountCodecInfoList(MEDIA_AUDIO),
-                              acc.getActiveAccountCodecInfoList(acc.isVideoEnabled() ? MEDIA_VIDEO : MEDIA_NONE),
+                              acc.getActiveAccountCodecInfoList(acc.isVideoEnabled() and not isAudioOnly() ? MEDIA_VIDEO
+                                                                                                           : MEDIA_NONE),
                               acc.getSrtpKeyExchange(),
                               getState() == CallState::HOLD))
         return !PJ_SUCCESS;
-- 
GitLab