summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authordknn <yoann.blein@free.fr>2012-08-04 09:13:14 (GMT)
committerdknn <yoann.blein@free.fr>2012-09-22 09:01:49 (GMT)
commit5ed2b62239eda07de84142e63fad31ccc194d379 (patch)
tree47d7dd469b7f637ee125371d267eaae17a6978a7
parent292967c02ffc2ff0b53df526af2965a03916290c (diff)
downloadswift-contrib-5ed2b62239eda07de84142e63fad31ccc194d379.zip
swift-contrib-5ed2b62239eda07de84142e63fad31ccc194d379.tar.bz2
Fix bug with ipv6 + add new feature in disco
-rw-r--r--Swiften/Elements/DiscoInfo.cpp1
-rw-r--r--Swiften/Elements/DiscoInfo.h1
-rw-r--r--Swiften/Examples/ScreenSharing/Client.cpp1
-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
8 files changed, 53 insertions, 19 deletions
diff --git a/Swiften/Elements/DiscoInfo.cpp b/Swiften/Elements/DiscoInfo.cpp
index c20f989..6aaee54 100644
--- a/Swiften/Elements/DiscoInfo.cpp
+++ b/Swiften/Elements/DiscoInfo.cpp
@@ -24,8 +24,9 @@ const std::string DiscoInfo::Bytestream = std::string("http://jabber.org/protoco
const std::string DiscoInfo::MessageDeliveryReceiptsFeature = std::string("urn:xmpp:receipts");
const std::string DiscoInfo::WhiteboardFeature = std::string("http://swift.im/whiteboard");
const std::string DiscoInfo::JingleRTPFeature = std::string("urn:xmpp:jingle:apps:rtp:1");
const std::string DiscoInfo::JingleTransportRawUDPFeature = std::string("urn:xmpp:jingle:transports:raw-udp:1");
+const std::string DiscoInfo::JingleScreenSharingFeature = std::string("urn:xmpp:jingle:apps:screen-sharing:0");
bool DiscoInfo::Identity::operator<(const Identity& other) const {
if (category_ == other.category_) {
if (type_ == other.type_) {
diff --git a/Swiften/Elements/DiscoInfo.h b/Swiften/Elements/DiscoInfo.h
index 9ef3ab6..12d32fd 100644
--- a/Swiften/Elements/DiscoInfo.h
+++ b/Swiften/Elements/DiscoInfo.h
@@ -35,8 +35,9 @@ namespace Swift {
static const std::string MessageDeliveryReceiptsFeature;
static const std::string WhiteboardFeature;
static const std::string JingleRTPFeature;
static const std::string JingleTransportRawUDPFeature;
+ static const std::string JingleScreenSharingFeature;
class Identity {
public:
Identity(const std::string& name, const std::string& category = "client", const std::string& type = "pc", const std::string& lang = "") : name_(name), category_(category), type_(type), lang_(lang) {
diff --git a/Swiften/Examples/ScreenSharing/Client.cpp b/Swiften/Examples/ScreenSharing/Client.cpp
index 71dff34..6d5a6b3 100644
--- a/Swiften/Examples/ScreenSharing/Client.cpp
+++ b/Swiften/Examples/ScreenSharing/Client.cpp
@@ -70,8 +70,9 @@ class ScreenReceiver {
discoInfo.addIdentity(DiscoInfo::Identity(CLIENT_NAME, "client", "pc"));
discoInfo.addFeature(DiscoInfo::JingleFeature);
discoInfo.addFeature(DiscoInfo::JingleRTPFeature);
discoInfo.addFeature(DiscoInfo::JingleTransportRawUDPFeature);
+ discoInfo.addFeature(DiscoInfo::JingleScreenSharingFeature);
client->getDiscoManager()->setCapsNode(CLIENT_NODE);
client->getDiscoManager()->setDiscoInfo(discoInfo);
client->getPresenceSender()->sendPresence(Presence::create());
}
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
@@ -78,8 +78,13 @@ 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
@@ -29,8 +29,10 @@ namespace Swift {
virtual void cancel();
void accept();
+ const JID& getSender() const;
+
public:
boost::signal<void (const Image&)> onNewImageReceived;
private:
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
@@ -19,13 +19,22 @@
#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) {
send(data, len);
@@ -37,17 +46,17 @@ bool Sender::SendRTCP(const void* data, size_t len) {
return true;
}
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) {
uint8_t* uint8Data = (uint8_t*)data;
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);
jrtplib::RTPSessionParams sessparams;
@@ -63,8 +72,9 @@ RTPSessionImpl::RTPSessionImpl(boost::shared_ptr<UDPSocket> udpSocket, const RTP
}
RTPSessionImpl::~RTPSessionImpl()
{
+ delete jRTPRemotePeer;
}
void RTPSessionImpl::poll()
{
@@ -73,9 +83,9 @@ 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) {
onIncomingPacket(pack->GetPayloadData(), pack->GetPayloadLength(), pack->HasMarker());
@@ -93,9 +103,9 @@ 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();
}
@@ -121,19 +131,30 @@ 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
@@ -13,14 +13,15 @@
#pragma clang diagnostic ignored "-Wunused-parameter"
#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);
virtual bool ComesFromThisSender (const jrtplib::RTPAddress* address);
@@ -29,8 +30,9 @@ namespace Swift {
void send(const void* data, size_t len);
private:
boost::shared_ptr<UDPSocket> udpSocket;
+ jrtplib::RTPAddress* jRTPLocalAddress;
};
class RTPSessionImpl : public RTPSession {
public:
@@ -48,18 +50,18 @@ 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;
void handleDataRead(boost::shared_ptr<SafeByteArray> data);
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
@@ -55,9 +55,10 @@ boost::optional<JID> ScreenSharingManagerImpl::highestPriorityJIDSupportingScree
if (pres->getPriority() > priority) {
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();
}
}