summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authordknn <yoann.blein@free.fr>2012-07-08 20:26:03 (GMT)
committerdknn <yoann.blein@free.fr>2012-09-22 08:55:56 (GMT)
commit4e0236b08d3914d24af32f45bc99663a73c6d83a (patch)
tree054b63bad9da90762568ed096525099dab54de7e
parentdc259819a687fa9a6f9007ed15b443f737c5d473 (diff)
downloadswift-contrib-4e0236b08d3914d24af32f45bc99663a73c6d83a.zip
swift-contrib-4e0236b08d3914d24af32f45bc99663a73c6d83a.tar.bz2
RTP update
-rw-r--r--Swiften/ScreenSharing/RTPSession.cpp5
-rw-r--r--Swiften/ScreenSharing/RTPSession.h13
-rw-r--r--Swiften/ScreenSharing/RTPSessionImpl.cpp35
-rw-r--r--Swiften/ScreenSharing/RTPSessionImpl.h11
4 files changed, 41 insertions, 23 deletions
diff --git a/Swiften/ScreenSharing/RTPSession.cpp b/Swiften/ScreenSharing/RTPSession.cpp
index 9af62f1..3a22326 100644
--- a/Swiften/ScreenSharing/RTPSession.cpp
+++ b/Swiften/ScreenSharing/RTPSession.cpp
@@ -8,11 +8,6 @@
namespace Swift {
-RTPSession::RTPSession(const HostAddressPort &remotePeer, PayloadType payloadType, int frequency)
- : remotePeer(remotePeer), payloadType(payloadType), frequency(frequency)
-{
-}
-
RTPSession::~RTPSession()
{
}
diff --git a/Swiften/ScreenSharing/RTPSession.h b/Swiften/ScreenSharing/RTPSession.h
index 225132b..717ac17 100644
--- a/Swiften/ScreenSharing/RTPSession.h
+++ b/Swiften/ScreenSharing/RTPSession.h
@@ -10,17 +10,23 @@
#include <Swiften/Network/HostAddressPort.h>
#include <Swiften/Base/boost_bsignals.h>
+#include <boost/shared_ptr.hpp>
+
namespace Swift {
+ class UDPSocket;
+
class RTPSession {
public:
+ typedef boost::shared_ptr<RTPSession> ref;
+
enum PayloadType {
VP8 = 98,
};
public:
- RTPSession(const HostAddressPort& remotePeer, PayloadType payloadType, int frequency);
virtual ~RTPSession();
+ virtual void create(boost::shared_ptr<UDPSocket> udpSocket, const HostAddressPort& remotePeer, PayloadType payloadType, int frequency) = 0;
virtual void poll() = 0;
virtual void checkIncomingPackets() = 0;
virtual void sendPacket(const SafeByteArray& data, int timestampinc, bool marker = false) = 0;
@@ -29,10 +35,5 @@ namespace Swift {
public:
boost::signal<void (uint8_t* data, size_t len, bool marker)> onIncomingPacket;
-
- protected:
- HostAddressPort remotePeer;
- PayloadType payloadType;
- int frequency;
};
}
diff --git a/Swiften/ScreenSharing/RTPSessionImpl.cpp b/Swiften/ScreenSharing/RTPSessionImpl.cpp
index b8c443e..eb67d4e 100644
--- a/Swiften/ScreenSharing/RTPSessionImpl.cpp
+++ b/Swiften/ScreenSharing/RTPSessionImpl.cpp
@@ -7,11 +7,14 @@
#include <Swiften/ScreenSharing/RTPSessionImpl.h>
#include <Swiften/ScreenSharing/RTPException.h>
+#include <Swiften/Network/BoostUDPSocket.h>
+#include <Swiften/Base/boost_bsignals.h>
#include <boost/algorithm/string/split.hpp>
#include <boost/algorithm/string/classification.hpp>
#include <boost/lexical_cast.hpp>
#include <boost/numeric/conversion/cast.hpp>
+#include <boost/bind.hpp>
#include <rtppacket.h>
#include <rtpsourcedata.h>
@@ -19,9 +22,24 @@
namespace Swift {
-RTPSessionImpl::RTPSessionImpl(const HostAddressPort& remotePeer, PayloadType payloadType, int frequency)
- : RTPSession(remotePeer, payloadType, frequency)
+RTPSessionImpl::RTPSessionImpl()
+ : RTPSession()
{
+}
+
+RTPSessionImpl::~RTPSessionImpl()
+{
+}
+
+void RTPSessionImpl::create(boost::shared_ptr<UDPSocket> udpSocket, const HostAddressPort &remotePeer, RTPSession::PayloadType payloadType, int frequency)
+{
+ this->udpSocket = udpSocket;
+ this->udpSocket->onDataRead.connect(boost::bind(&RTPSessionImpl::handleDataRead, this, _1));
+
+ this->payloadType = payloadType;
+ this->frequency = frequency;
+ nativeAddressToJRTPAddress(remotePeer, jRTPRemotePeer);
+
jrtplib::RTPExternalTransmissionParams transparams(&sender, 0);
jrtplib::RTPSessionParams sessparams;
@@ -30,15 +48,7 @@ RTPSessionImpl::RTPSessionImpl(const HostAddressPort& remotePeer, PayloadType pa
checkError(session.Create(sessparams, &transparams, jrtplib::RTPTransmitter::ExternalProto));
- //session.SetDefaultPayloadType(VP8);
-
packetInjecter = static_cast<jrtplib::RTPExternalTransmissionInfo*>(session.GetTransmissionInfo())->GetPacketInjector();
-
- nativeAddressToJRTPAddress(remotePeer, jRTPRemotePeer);
-}
-
-RTPSessionImpl::~RTPSessionImpl()
-{
}
void RTPSessionImpl::poll()
@@ -86,6 +96,11 @@ void RTPSessionImpl::checkError(int rtperr) const
throw RTPException(jrtplib::RTPGetErrorString(rtperr));
}
+void RTPSessionImpl::handleDataRead(boost::shared_ptr<SafeByteArray> data)
+{
+ injectData(*data);
+}
+
void RTPSessionImpl::nativeAddressToJRTPAddress(const HostAddressPort& hostAddressPort, jrtplib::RTPIPv4Address& jRTPAddress)
{
// Split address
diff --git a/Swiften/ScreenSharing/RTPSessionImpl.h b/Swiften/ScreenSharing/RTPSessionImpl.h
index 15ca4b3..657a34a 100644
--- a/Swiften/ScreenSharing/RTPSessionImpl.h
+++ b/Swiften/ScreenSharing/RTPSessionImpl.h
@@ -16,7 +16,6 @@
#include <rtpipv4address.h>
namespace Swift {
-
// Temporary class
class Sender : public jrtplib::RTPExternalSender
{
@@ -41,9 +40,13 @@ namespace Swift {
class RTPSessionImpl : public RTPSession {
public:
- RTPSessionImpl(const HostAddressPort& remotePeer, PayloadType payloadType, int frequency);
+ typedef boost::shared_ptr<RTPSession> ref;
+
+ public:
+ RTPSessionImpl();
virtual ~RTPSessionImpl();
+ virtual void create(boost::shared_ptr<UDPSocket> udpSocket, const HostAddressPort &remotePeer, PayloadType payloadType, int frequency);
virtual void poll();
virtual void checkIncomingPackets();
virtual void sendPacket(const SafeByteArray &data, int timestampinc, bool marker = false);
@@ -55,8 +58,12 @@ namespace Swift {
private:
inline void checkError(int rtperr) const;
+ void handleDataRead(boost::shared_ptr<SafeByteArray> data);
private:
+ boost::shared_ptr<UDPSocket> udpSocket;
+ PayloadType payloadType;
+ int frequency;
jrtplib::RTPIPv4Address jRTPRemotePeer;
jrtplib::RTPSession session;
Sender sender;