summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'Swiften/ScreenSharing')
-rw-r--r--Swiften/ScreenSharing/IncomingScreenSharing.cpp5
-rw-r--r--Swiften/ScreenSharing/IncomingScreenSharing.h2
-rw-r--r--Swiften/ScreenSharing/RTPSessionImpl.cpp51
-rw-r--r--Swiften/ScreenSharing/RTPSessionImpl.h8
-rw-r--r--Swiften/ScreenSharing/ScreenSharingManagerImpl.cpp3
5 files changed, 50 insertions, 19 deletions
diff --git a/Swiften/ScreenSharing/IncomingScreenSharing.cpp b/Swiften/ScreenSharing/IncomingScreenSharing.cpp
index 3807a0f..bbbfbad 100644
--- a/Swiften/ScreenSharing/IncomingScreenSharing.cpp
+++ b/Swiften/ScreenSharing/IncomingScreenSharing.cpp
@@ -79,6 +79,11 @@ void IncomingScreenSharing::accept()
onStateChange(ScreenSharing::Connecting);
}
+const JID &IncomingScreenSharing::getSender() const
+{
+ return jingleSession->getInitiator();
+}
+
JingleContentID IncomingScreenSharing::getContentID() const
{
return JingleContentID(initialContent->getName(), initialContent->getCreator());
diff --git a/Swiften/ScreenSharing/IncomingScreenSharing.h b/Swiften/ScreenSharing/IncomingScreenSharing.h
index f6d9b62..cc25a9f 100644
--- a/Swiften/ScreenSharing/IncomingScreenSharing.h
+++ b/Swiften/ScreenSharing/IncomingScreenSharing.h
@@ -30,6 +30,8 @@ namespace Swift {
void accept();
+ const JID& getSender() const;
+
public:
boost::signal<void (const Image&)> onNewImageReceived;
diff --git a/Swiften/ScreenSharing/RTPSessionImpl.cpp b/Swiften/ScreenSharing/RTPSessionImpl.cpp
index bbd3d72..922ffa2 100644
--- a/Swiften/ScreenSharing/RTPSessionImpl.cpp
+++ b/Swiften/ScreenSharing/RTPSessionImpl.cpp
@@ -20,11 +20,20 @@
#include <rtppacket.h>
#include <rtpsourcedata.h>
#include <rtpsessionparams.h>
+#include <rtpipv4address.h>
+#include <rtpipv6address.h>
+
+#include <arpa/inet.h>
namespace Swift {
Sender::Sender(boost::shared_ptr<UDPSocket> udpSocket)
- : udpSocket(udpSocket) {
+ : udpSocket(udpSocket), jRTPLocalAddress(RTPSessionImpl::nativeAddressToJRTPAddress(udpSocket->getLocalAddress())) {
+}
+
+Sender::~Sender()
+{
+ delete jRTPLocalAddress;
}
bool Sender::SendRTP(const void *data, size_t len) {
@@ -38,7 +47,7 @@ bool Sender::SendRTCP(const void* data, size_t len) {
}
bool Sender::ComesFromThisSender (const jrtplib::RTPAddress* address) {
- return RTPSessionImpl::nativeAddressToJRTPAddress(udpSocket->getLocalAddress()).IsSameAddress(address);
+ return jRTPLocalAddress->IsSameAddress(address);
}
void Sender::send(const void* data, size_t len) {
@@ -46,7 +55,7 @@ void Sender::send(const void* data, size_t len) {
udpSocket->send(SafeByteArray(uint8Data, uint8Data + len));
}
-RTPSessionImpl::RTPSessionImpl(boost::shared_ptr<UDPSocket> udpSocket, const RTPPayloadType &payloadType)
+RTPSessionImpl::RTPSessionImpl(boost::shared_ptr<UDPSocket> udpSocket, const RTPPayloadType& payloadType)
: udpSocket(udpSocket), payloadType(payloadType), jRTPRemotePeer(nativeAddressToJRTPAddress(udpSocket->getRemoteAddress())), sender(udpSocket)
{
jrtplib::RTPExternalTransmissionParams transparams(&sender, 0);
@@ -64,6 +73,7 @@ RTPSessionImpl::RTPSessionImpl(boost::shared_ptr<UDPSocket> udpSocket, const RTP
RTPSessionImpl::~RTPSessionImpl()
{
+ delete jRTPRemotePeer;
}
void RTPSessionImpl::poll()
@@ -74,7 +84,7 @@ void RTPSessionImpl::poll()
void RTPSessionImpl::checkIncomingPackets()
{
// session.BeginDataAccess(); // useless without threading
- if (session.GotoFirstSourceWithData() && session.GetCurrentSourceInfo()->GetRTPDataAddress()->IsSameAddress(&jRTPRemotePeer)) {
+ if (session.GotoFirstSourceWithData() && session.GetCurrentSourceInfo()->GetRTPDataAddress()->IsSameAddress(jRTPRemotePeer)) {
do {
jrtplib::RTPPacket *pack;
while ((pack = session.GetNextPacket()) != NULL) {
@@ -94,7 +104,7 @@ void RTPSessionImpl::sendPacket(const SafeByteArray& data, int timestampinc, boo
void RTPSessionImpl::injectData(const SafeByteArray& data)
{
- packetInjecter->InjectRTPorRTCP((void*)(data.data()), data.size(), jRTPRemotePeer);
+ packetInjecter->InjectRTPorRTCP((void*)(data.data()), data.size(), *jRTPRemotePeer);
checkIncomingPackets();
poll();
}
@@ -122,18 +132,29 @@ void RTPSessionImpl::handleDataRead(boost::shared_ptr<SafeByteArray> data)
injectData(*data);
}
-jrtplib::RTPIPv4Address RTPSessionImpl::nativeAddressToJRTPAddress(const HostAddressPort& hostAddressPort)
+jrtplib::RTPAddress* RTPSessionImpl::nativeAddressToJRTPAddress(const HostAddressPort& hostAddressPort)
{
- // Split address
- std::vector<std::string> subStrings;
+ jrtplib::RTPAddress* jrtpAddress = 0;
std::string ipAddress = hostAddressPort.getAddress().toString();
- boost::algorithm::split(subStrings, ipAddress, boost::is_any_of("."));
- // Cast sub strings array to array of byte
- uint8_t ipNumbers[4];
- for (int i = 0; i < std::min(4, (int)subStrings.size()); ++i)
- ipNumbers[i] = boost::numeric_cast<uint8_t>(boost::lexical_cast<int>(subStrings[i]));
-
- return jrtplib::RTPIPv4Address(ipNumbers, boost::numeric_cast<uint16_t>(hostAddressPort.getPort()));
+ uint16_t port = boost::numeric_cast<uint16_t>(hostAddressPort.getPort());
+
+ if (hostAddressPort.getAddress().getRawAddress().is_v4()) {
+ // Split address
+ std::vector<std::string> subStrings;
+ boost::algorithm::split(subStrings, ipAddress, boost::is_any_of("."));
+ // Cast sub strings array to array of byte
+ uint8_t ipNumbers[4];
+ for (int i = 0; i < std::min(4, (int)subStrings.size()); ++i)
+ ipNumbers[i] = boost::numeric_cast<uint8_t>(boost::lexical_cast<int>(subStrings[i]));
+
+ jrtpAddress = new jrtplib::RTPIPv4Address(ipNumbers, port);
+ }
+ else if (hostAddressPort.getAddress().getRawAddress().is_v6()) {
+ in6_addr addr;
+ inet_pton(AF_INET6, ipAddress.c_str(), &addr);
+ jrtpAddress = new jrtplib::RTPIPv6Address(addr, port);
+ }
+ return jrtpAddress;
}
}
diff --git a/Swiften/ScreenSharing/RTPSessionImpl.h b/Swiften/ScreenSharing/RTPSessionImpl.h
index 2c6fed2..47af60b 100644
--- a/Swiften/ScreenSharing/RTPSessionImpl.h
+++ b/Swiften/ScreenSharing/RTPSessionImpl.h
@@ -14,12 +14,13 @@
#include <rtpsession.h>
#pragma clang diagnostic pop
#include <rtpexternaltransmitter.h>
-#include <rtpipv4address.h>
+#include <rtpaddress.h>
namespace Swift {
class Sender : public jrtplib::RTPExternalSender {
public:
Sender(boost::shared_ptr<UDPSocket> udpSocket);
+ ~Sender();
virtual bool SendRTP(const void* data, size_t len);
virtual bool SendRTCP(const void* data, size_t len);
@@ -30,6 +31,7 @@ namespace Swift {
private:
boost::shared_ptr<UDPSocket> udpSocket;
+ jrtplib::RTPAddress* jRTPLocalAddress;
};
class RTPSessionImpl : public RTPSession {
@@ -49,7 +51,7 @@ namespace Swift {
virtual size_t getMaxRTPPayloadSize() const;
public:
- static jrtplib::RTPIPv4Address nativeAddressToJRTPAddress(const HostAddressPort& hostAddressPort);
+ static jrtplib::RTPAddress* nativeAddressToJRTPAddress(const HostAddressPort& hostAddressPort);
private:
void checkError(int rtperr) const;
@@ -58,7 +60,7 @@ namespace Swift {
private:
boost::shared_ptr<UDPSocket> udpSocket;
RTPPayloadType payloadType;
- jrtplib::RTPIPv4Address jRTPRemotePeer;
+ jrtplib::RTPAddress* jRTPRemotePeer;
Sender sender;
jrtplib::RTPSession session;
jrtplib::RTPExternalPacketInjecter *packetInjecter;
diff --git a/Swiften/ScreenSharing/ScreenSharingManagerImpl.cpp b/Swiften/ScreenSharing/ScreenSharingManagerImpl.cpp
index a747b81..b0e337a 100644
--- a/Swiften/ScreenSharing/ScreenSharingManagerImpl.cpp
+++ b/Swiften/ScreenSharing/ScreenSharingManagerImpl.cpp
@@ -56,7 +56,8 @@ boost::optional<JID> ScreenSharingManagerImpl::highestPriorityJIDSupportingScree
DiscoInfo::ref info = capsProvider->getCaps(pres->getFrom()); // look up caps from the jid
if (info && info->hasFeature(DiscoInfo::JingleFeature)
&& info->hasFeature(DiscoInfo::JingleRTPFeature)
- && info->hasFeature(DiscoInfo::JingleTransportRawUDPFeature)) {
+ && info->hasFeature(DiscoInfo::JingleTransportRawUDPFeature)
+ && info->hasFeature(DiscoInfo::JingleScreenSharingFeature)) {
priority = pres->getPriority();
fullRecipientJID = pres->getFrom();
}