summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-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
@@ -7,13 +7,8 @@
#include <Swiften/ScreenSharing/RTPSession.h>
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
@@ -9,30 +9,31 @@
#include <Swiften/Base/SafeByteArray.h>
#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;
virtual void injectData(const SafeByteArray& data) = 0;
virtual void stop(int maxWaitMs = 100) = 0;
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
@@ -6,40 +6,50 @@
#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>
#include <rtpsessionparams.h>
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;
// IMPORTANT: The local timestamp unit MUST be set, otherwise RTCP Sender Report info will be calculated wrong
sessparams.SetOwnTimestampUnit(1.0 / frequency);
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()
{
@@ -85,8 +95,13 @@ void RTPSessionImpl::checkError(int rtperr) const
if (rtperr < 0)
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
std::vector<std::string> subStrings;
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
@@ -15,9 +15,8 @@
#include <rtpexternaltransmitter.h>
#include <rtpipv4address.h>
namespace Swift {
-
// Temporary class
class Sender : public jrtplib::RTPExternalSender
{
public:
@@ -40,11 +39,15 @@ 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);
virtual void injectData(const SafeByteArray &data);
@@ -54,10 +57,14 @@ namespace Swift {
static void nativeAddressToJRTPAddress(const HostAddressPort& hostAddressPort, jrtplib::RTPIPv4Address& jRTPAddress);
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;
jrtplib::RTPExternalPacketInjecter *packetInjecter;