From 0f491796ba3ae4a3da9f77bc4e9d8d988e99adff Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Adrien=20B=C3=A9raud?= <adrien.beraud@savoirfairelinux.com>
Date: Tue, 4 May 2021 12:08:15 -0400
Subject: [PATCH] getIceOptions: cleanup

Change-Id: Ibc4a5181ef33e4f09beeaa0ecbe09cf9db4e9996
---
 src/jamidht/connectionmanager.cpp | 10 +++++-----
 src/jamidht/jamiaccount.cpp       | 10 +++++-----
 src/jamidht/jamiaccount.h         |  2 +-
 src/sip/sipaccountbase.cpp        |  2 +-
 src/sip/sipaccountbase.h          |  2 +-
 5 files changed, 13 insertions(+), 13 deletions(-)

diff --git a/src/jamidht/connectionmanager.cpp b/src/jamidht/connectionmanager.cpp
index ee210b8bfc..fd73ea9bc7 100644
--- a/src/jamidht/connectionmanager.cpp
+++ b/src/jamidht/connectionmanager.cpp
@@ -472,13 +472,13 @@ ConnectionManager::Impl::connectDevice(const std::shared_ptr<dht::crypto::Certif
         };
 
         // If no socket exists, we need to initiate an ICE connection.
-        sthis->account.getIceOptions(std::move([w,
+        sthis->account.getIceOptions([w,
                                      cbId,
                                      deviceId = std::move(deviceId),
                                      name = std::move(name),
                                      cert = std::move(cert),
                                      vid,
-                                     eraseInfo](auto ice_config) {
+                                     eraseInfo](auto&& ice_config) {
             auto sthis = w.lock();
             if (!sthis)
                 return;
@@ -552,7 +552,7 @@ ConnectionManager::Impl::connectDevice(const std::shared_ptr<dht::crypto::Certif
                     pending.cb(nullptr, deviceId);
                 eraseInfo();
             }
-        }));
+        });
     });
 }
 
@@ -826,7 +826,7 @@ ConnectionManager::Impl::onDhtPeerRequest(const PeerConnectionRequest& req,
     }
 
     // Because the connection is accepted, create an ICE socket.
-    account.getIceOptions(std::move([w=weak(), req](auto ice_config) {
+    account.getIceOptions([w=weak(), req](auto&& ice_config) {
         auto deviceId = req.from.toString();
         auto shared = w.lock();
         if (!shared)
@@ -898,7 +898,7 @@ ConnectionManager::Impl::onDhtPeerRequest(const PeerConnectionRequest& req,
                 shared->connReadyCb_(req.from, "", nullptr);
             eraseInfo();
         }
-    }));
+    });
 }
 
 void
diff --git a/src/jamidht/jamiaccount.cpp b/src/jamidht/jamiaccount.cpp
index 35c4955f8c..28b3103767 100644
--- a/src/jamidht/jamiaccount.cpp
+++ b/src/jamidht/jamiaccount.cpp
@@ -718,7 +718,7 @@ JamiAccount::onConnectedOutgoingCall(const std::shared_ptr<SIPCall>& call,
         return;
     JAMI_DBG("[call:%s] outgoing call connected to %s", call->getCallId().c_str(), to_id.c_str());
 
-    getIceOptions(std::move([=](auto opts) {
+    getIceOptions([=](auto&& opts) {
         opts.onInitDone = [w = weak(), target = std::move(target), call](bool ok) {
             if (!ok) {
                 JAMI_ERR("ICE medias are not initialized");
@@ -780,7 +780,7 @@ JamiAccount::onConnectedOutgoingCall(const std::shared_ptr<SIPCall>& call,
         call->setIPToIP(true);
         call->setPeerNumber(to_id);
         call->initIceMediaTransport(true, std::move(opts));
-    }));
+    });
 }
 
 bool
@@ -2696,7 +2696,7 @@ JamiAccount::incomingCall(dht::IceCandidates&& msg,
         return;
     }
     auto callId = call->getCallId();
-    getIceOptions(std::move([=](auto iceOptions) {
+    getIceOptions([=](auto&& iceOptions) {
         iceOptions.onNegoDone = [callId, w = weak()](bool) {
             runOnMainThread([callId, w]() {
                 if (auto shared = w.lock())
@@ -2736,7 +2736,7 @@ JamiAccount::incomingCall(dht::IceCandidates&& msg,
             account->replyToIncomingIceMsg(call, ice, ice_tcp, msg, from_cert, from);
             return false;
         });
-    }));
+    });
 }
 
 void
@@ -3669,7 +3669,7 @@ JamiAccount::onIsComposing(const std::string& peer, bool isWriting)
 }
 
 void
-JamiAccount::getIceOptions(std::function<void(IceTransportOptions)> cb) noexcept
+JamiAccount::getIceOptions(std::function<void(IceTransportOptions&&)> cb) noexcept
 {
     storeActiveIpAddress([this, cb=std::move(cb)] {
         auto opts = SIPAccountBase::getIceOptions();
diff --git a/src/jamidht/jamiaccount.h b/src/jamidht/jamiaccount.h
index c27e62dace..4e30c5bdd2 100644
--- a/src/jamidht/jamiaccount.h
+++ b/src/jamidht/jamiaccount.h
@@ -440,7 +440,7 @@ public:
     /**
      * Create and return ICE options.
      */
-    void getIceOptions(std::function<void(IceTransportOptions)> cb) noexcept;
+    void getIceOptions(std::function<void(IceTransportOptions&&)> cb) noexcept;
 
 #ifdef DRING_TESTABLE
     ConnectionManager& connectionManager() { return *connectionManager_; }
diff --git a/src/sip/sipaccountbase.cpp b/src/sip/sipaccountbase.cpp
index 1017a494ac..92f5ce85ae 100644
--- a/src/sip/sipaccountbase.cpp
+++ b/src/sip/sipaccountbase.cpp
@@ -465,7 +465,7 @@ SIPAccountBase::generateVideoPort() const
 }
 #endif
 
-const IceTransportOptions
+IceTransportOptions
 SIPAccountBase::getIceOptions() const noexcept
 {
     IceTransportOptions opts;
diff --git a/src/sip/sipaccountbase.h b/src/sip/sipaccountbase.h
index 447f142f1b..62d734605d 100644
--- a/src/sip/sipaccountbase.h
+++ b/src/sip/sipaccountbase.h
@@ -243,7 +243,7 @@ public:
 
     void setStunServer(const std::string& srv) { stunServer_ = srv; }
 
-    const IceTransportOptions getIceOptions() const noexcept;
+    IceTransportOptions getIceOptions() const noexcept;
 
     virtual void sendTextMessage(const std::string& to,
                                  const std::map<std::string, std::string>& payloads,
-- 
GitLab