summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'Swiften/ScreenSharing')
-rw-r--r--Swiften/ScreenSharing/IncomingScreenSharing.cpp9
-rw-r--r--Swiften/ScreenSharing/OutgoingScreenSharing.cpp20
-rw-r--r--Swiften/ScreenSharing/ScreenSharing.cpp40
3 files changed, 47 insertions, 22 deletions
diff --git a/Swiften/ScreenSharing/IncomingScreenSharing.cpp b/Swiften/ScreenSharing/IncomingScreenSharing.cpp
index 2ddfab9..3807a0f 100644
--- a/Swiften/ScreenSharing/IncomingScreenSharing.cpp
+++ b/Swiften/ScreenSharing/IncomingScreenSharing.cpp
@@ -45,7 +45,14 @@ void IncomingScreenSharing::cancel()
void IncomingScreenSharing::accept()
{
JingleRawUDPTransportPayload::ref transport = boost::make_shared<JingleRawUDPTransportPayload>();
- addBestCandidate(transport);
+ if (!addBestCandidate(transport)) {
+ SWIFT_LOG(error) << "Screen sharing: Unable to listening on any interface" << std::endl;
+ jingleSession->sendTerminate(JinglePayload::Reason::FailedTransport);
+ onStateChange(ScreenSharing::Failed);
+ onFinished();
+ return;
+ }
+
JingleRTPDescription::ref desc = initialContent->getDescription<JingleRTPDescription>();
if (!desc->getPayloadTypes().empty())
payloadTypeUsed = desc->getPayloadTypes().front();
diff --git a/Swiften/ScreenSharing/OutgoingScreenSharing.cpp b/Swiften/ScreenSharing/OutgoingScreenSharing.cpp
index 906bd68..005e204 100644
--- a/Swiften/ScreenSharing/OutgoingScreenSharing.cpp
+++ b/Swiften/ScreenSharing/OutgoingScreenSharing.cpp
@@ -50,8 +50,6 @@ void OutgoingScreenSharing::cancel()
void OutgoingScreenSharing::start(unsigned int width, unsigned int height)
{
//onStateChange(ScreenSharing::WaitingForStart);
- SWIFT_LOG(debug) << "Screen sharing: start" << std::endl;
-
this->width = width;
this->height = height;
@@ -60,13 +58,17 @@ void OutgoingScreenSharing::start(unsigned int width, unsigned int height)
desc->addPayloadType(payloadTypeUsed);
JingleRawUDPTransportPayload::ref transport = boost::make_shared<JingleRawUDPTransportPayload>();
- addBestCandidate(transport);
-
- jingleSession->sendInitiate(contentID, desc, transport);
- onStateChange(ScreenSharing::WaitingForAccept);
-
- serverSocket->onConnected.connect(boost::bind(&OutgoingScreenSharing::handleSocketConnected, this));
- serverSocket->connectToFirstIncoming();
+ if (addBestCandidate(transport)) {
+ SWIFT_LOG(debug) << "Screen sharing: start" << std::endl;
+ jingleSession->sendInitiate(contentID, desc, transport);
+ serverSocket->onConnected.connect(boost::bind(&OutgoingScreenSharing::handleSocketConnected, this));
+ serverSocket->connectToFirstIncoming();
+ onStateChange(ScreenSharing::WaitingForAccept);
+ } else {
+ SWIFT_LOG(error) << "Screen sharing: Unable to listening on any interface" << std::endl;
+ onStateChange(ScreenSharing::Failed);
+ onFinished();
+ }
}
void OutgoingScreenSharing::addImage(const Image &image)
diff --git a/Swiften/ScreenSharing/ScreenSharing.cpp b/Swiften/ScreenSharing/ScreenSharing.cpp
index c6c78e0..0a477c2 100644
--- a/Swiften/ScreenSharing/ScreenSharing.cpp
+++ b/Swiften/ScreenSharing/ScreenSharing.cpp
@@ -50,10 +50,11 @@ bool ScreenSharing::addBestCandidate(boost::shared_ptr<JingleRawUDPTransportPayl
PlatformNetworkEnvironment env;
std::vector<NetworkInterface> interfaces = env.getNetworkInterfaces();
+ serverSocket = udpSocketFactory->createUDPSocket();
+
// Find the first ip which is not loopback
- foreach (const NetworkInterface& interface, interfaces) {
+ /*foreach (const NetworkInterface& interface, interfaces) {
if (!interface.isLoopback() && !interface.getAddresses().empty()) { // exclude loopback
- serverSocket = udpSocketFactory->createUDPSocket();
serverSocket->bindOnAvailablePort(interface.getAddresses().front());
candidate.hostAddressPort = serverSocket->getLocalAddress();
@@ -62,19 +63,34 @@ bool ScreenSharing::addBestCandidate(boost::shared_ptr<JingleRawUDPTransportPayl
return true;
}
+ }*/
+
+ foreach (const NetworkInterface& interface, interfaces) {
+ if (!interface.isLoopback()) { // exclude loopback
+ foreach (const HostAddress& addr, interface.getAddresses()) {
+ int port = serverSocket->bindOnAvailablePort(addr);
+ if (!port)
+ continue;
+
+ candidate.hostAddressPort = serverSocket->getLocalAddress();
+ candidate.type = JingleRawUDPTransportPayload::Candidate::Host;
+ transport->addCandidate(candidate);
+
+ return true;
+ }
+ }
}
// else loopback for self sharing
- if (!interfaces.empty() && !interfaces.front().getAddresses().empty()) {
- serverSocket = udpSocketFactory->createUDPSocket();
- serverSocket->bindOnAvailablePort(interfaces.front().getAddresses().front());
-
- candidate.hostAddressPort = serverSocket->getLocalAddress();
- candidate.type = JingleRawUDPTransportPayload::Candidate::Host;
- transport->addCandidate(candidate);
-
- return true;
- }
+ /*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;
}