summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'Swiften/ScreenSharing/ScreenSharing.cpp')
-rw-r--r--Swiften/ScreenSharing/ScreenSharing.cpp58
1 files changed, 20 insertions, 38 deletions
diff --git a/Swiften/ScreenSharing/ScreenSharing.cpp b/Swiften/ScreenSharing/ScreenSharing.cpp
index f2977a2..de0b430 100644
--- a/Swiften/ScreenSharing/ScreenSharing.cpp
+++ b/Swiften/ScreenSharing/ScreenSharing.cpp
@@ -13,13 +13,14 @@
#include <Swiften/Network/UDPSocketFactory.h>
#include <Swiften/ScreenSharing/RTPSession.h>
#include <Swiften/Jingle/JingleSession.h>
+#include <Swiften/FileTransfer/ConnectivityManager.h>
#include <boost/bind.hpp>
namespace Swift {
-ScreenSharing::ScreenSharing(boost::shared_ptr<JingleSession> session, UDPSocketFactory* udpSocketFactory)
- : rtpSession(0), jingleSession(session), udpSocketFactory(udpSocketFactory)
+ScreenSharing::ScreenSharing(boost::shared_ptr<JingleSession> session, UDPSocketFactory* udpSocketFactory, ConnectivityManager* connectivityManager)
+ : rtpSession(0), jingleSession(session), udpSocketFactory(udpSocketFactory), connectivityManager(connectivityManager)
{
jingleSession->onSessionTerminateReceived.connect(boost::bind(&ScreenSharing::handleSessionTerminateReceived, this, _1));
}
@@ -52,19 +53,7 @@ bool ScreenSharing::addBestCandidate(boost::shared_ptr<JingleRawUDPTransportPayl
serverSocket = udpSocketFactory->createUDPSocket();
- // Find the first ip which is not loopback
- /*foreach (const NetworkInterface& interface, interfaces) {
- if (!interface.isLoopback() && !interface.getAddresses().empty()) { // exclude loopback
- serverSocket->bindOnAvailablePort(interface.getAddresses().front());
-
- candidate.hostAddressPort = serverSocket->getLocalAddress();
- candidate.type = JingleRawUDPTransportPayload::Candidate::Host;
- transport->addCandidate(candidate);
-
- return true;
- }
- }*/
-
+ /*
SWIFT_LOG(debug) << "Screen sharing: Addresses available: " << std::endl;
foreach (const NetworkInterface& interface, interfaces) {
SWIFT_LOG(debug) << "\tInterface: " << interface.getName() << std::endl;
@@ -72,6 +61,22 @@ bool ScreenSharing::addBestCandidate(boost::shared_ptr<JingleRawUDPTransportPayl
SWIFT_LOG(debug) << "\t\t" << addr.getRawAddress().to_string() << std::endl;
}
}
+ */
+
+ std::vector<HostAddressPort> assisted = connectivityManager->getAssistedHostAddressPorts(NATPortMapping::UDP);
+ foreach (HostAddressPort hap, assisted) {
+ int port = serverSocket->bind(HostAddressPort(HostAddress("0.0.0.0"), hap.getPort()));
+ if (port != hap.getPort())
+ continue;
+
+ SWIFT_LOG(debug) << "Listening on " << port << std::endl;
+
+ candidate.hostAddressPort = hap;
+ candidate.type = JingleRawUDPTransportPayload::Candidate::Host;
+ transport->addCandidate(candidate);
+
+ return true;
+ }
std::string scopeLinkBeginning("fe80");
foreach (const NetworkInterface& interface, interfaces) {
@@ -99,29 +104,6 @@ bool ScreenSharing::addBestCandidate(boost::shared_ptr<JingleRawUDPTransportPayl
}
}
- /*
- int port = serverSocket->bind(HostAddressPort(HostAddress("0.0.0.0"), 29999));
- if (!port)
- return false;
-
- candidate.hostAddressPort = HostAddressPort(HostAddress("82.225.14.174"), 29999);
- candidate.type = JingleRawUDPTransportPayload::Candidate::Host;
- transport->addCandidate(candidate);
-
- return true;
-*/
-
- // else loopback for self sharing
- /*if (!interfaces.empty() && !interfaces.front().getAddresses().empty()) {
- int port = serverSocket->bindOnAvailablePort(interfaces.front().getAddresses().front());
- if (port) {
- candidate.hostAddressPort = serverSocket->getLocalAddress();
- candidate.type = JingleRawUDPTransportPayload::Candidate::Host;
- transport->addCandidate(candidate);
- return true;
- }
- }*/
-
return false;
}