diff options
Diffstat (limited to 'Swiften/ScreenSharing/IncomingScreenSharing.cpp')
-rw-r--r-- | Swiften/ScreenSharing/IncomingScreenSharing.cpp | 36 |
1 files changed, 32 insertions, 4 deletions
diff --git a/Swiften/ScreenSharing/IncomingScreenSharing.cpp b/Swiften/ScreenSharing/IncomingScreenSharing.cpp index d5ee56e..2ddfab9 100644 --- a/Swiften/ScreenSharing/IncomingScreenSharing.cpp +++ b/Swiften/ScreenSharing/IncomingScreenSharing.cpp @@ -8,27 +8,37 @@ #include <Swiften/Jingle/JingleSession.h> #include <Swiften/Elements/JingleRawUDPTransportPayload.h> +#include <Swiften/Elements/JingleRTPDescription.h> #include <Swiften/Network/UDPSocketFactory.h> #include <Swiften/Network/UDPSocket.h> +#include <Swiften/ScreenSharing/RTPSessionImpl.h> +#include <Swiften/ScreenSharing/VP8Decoder.h> +#include <Swiften/ScreenSharing/VP8RTPParser.h> + +#include <boost/bind.hpp> namespace Swift { IncomingScreenSharing::IncomingScreenSharing(boost::shared_ptr<JingleSession> session, UDPSocketFactory* udpSocketFactory, boost::shared_ptr<JingleContentPayload> content) : ScreenSharing(session, udpSocketFactory), - initialContent(content) + initialContent(content), parser(0), decoder(0) { onStateChange(ScreenSharing::WaitingForAccept); } IncomingScreenSharing::~IncomingScreenSharing() { + delete rtpSession; + delete parser; + delete decoder; } void IncomingScreenSharing::cancel() { - session->sendTerminate(JinglePayload::Reason::Cancel); - clientSocket->close(); + jingleSession->sendTerminate(JinglePayload::Reason::Cancel); + if (rtpSession) + rtpSession->stop(); onStateChange(ScreenSharing::Canceled); } @@ -36,8 +46,12 @@ void IncomingScreenSharing::accept() { JingleRawUDPTransportPayload::ref transport = boost::make_shared<JingleRawUDPTransportPayload>(); addBestCandidate(transport); + JingleRTPDescription::ref desc = initialContent->getDescription<JingleRTPDescription>(); + if (!desc->getPayloadTypes().empty()) + payloadTypeUsed = desc->getPayloadTypes().front(); + // TODO: create a valid description instead of copying the initator's one - session->sendAccept(getContentID(), initialContent->getDescriptions().front(), transport); + jingleSession->sendAccept(getContentID(), desc, transport); JingleRawUDPTransportPayload::ref initialTransport = initialContent->getTransport<JingleRawUDPTransportPayload>(); clientSocket = udpSocketFactory->createUDPSocket(); @@ -46,6 +60,15 @@ void IncomingScreenSharing::accept() SafeByteArray data(1, 0); clientSocket->send(data); + rtpSession = new RTPSessionImpl(clientSocket, payloadTypeUsed); + + if (payloadTypeUsed.getID() == 98 && payloadTypeUsed.getName() == "VP8") { + decoder = new VP8Decoder; + parser = new VP8RTPParser(decoder); + rtpSession->onIncomingPacket.connect(boost::bind(&VP8RTPParser::newPayloadReceived, parser, _1, _2, _3)); + decoder->onNewImageDecoded.connect(boost::bind(&IncomingScreenSharing::hangleNewImageDecoded, this, _1)); + } + onStateChange(ScreenSharing::Connecting); } @@ -54,4 +77,9 @@ JingleContentID IncomingScreenSharing::getContentID() const return JingleContentID(initialContent->getName(), initialContent->getCreator()); } +void IncomingScreenSharing::hangleNewImageDecoded(const Image& image) +{ + onNewImageReceived(image); +} + } |