From 4e0236b08d3914d24af32f45bc99663a73c6d83a Mon Sep 17 00:00:00 2001 From: dknn Date: Sun, 8 Jul 2012 22:26:03 +0200 Subject: RTP update 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 #include +#include + namespace Swift { + class UDPSocket; + class RTPSession { public: + typedef boost::shared_ptr ref; + enum PayloadType { VP8 = 98, }; public: - RTPSession(const HostAddressPort& remotePeer, PayloadType payloadType, int frequency); virtual ~RTPSession(); + virtual void create(boost::shared_ptr 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 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 #include +#include +#include #include #include #include #include +#include #include #include @@ -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, 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(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 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 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 ref; + + public: + RTPSessionImpl(); virtual ~RTPSessionImpl(); + virtual void create(boost::shared_ptr 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 data); private: + boost::shared_ptr udpSocket; + PayloadType payloadType; + int frequency; jrtplib::RTPIPv4Address jRTPRemotePeer; jrtplib::RTPSession session; Sender sender; -- cgit v0.10.2-6-g49f6