diff options
Diffstat (limited to 'Swiften/ScreenSharing/ScreenSharing.cpp')
-rw-r--r-- | Swiften/ScreenSharing/ScreenSharing.cpp | 38 |
1 files changed, 33 insertions, 5 deletions
diff --git a/Swiften/ScreenSharing/ScreenSharing.cpp b/Swiften/ScreenSharing/ScreenSharing.cpp index 532b73d..d5ab921 100644 --- a/Swiften/ScreenSharing/ScreenSharing.cpp +++ b/Swiften/ScreenSharing/ScreenSharing.cpp @@ -6,24 +6,35 @@ #include <Swiften/ScreenSharing/ScreenSharing.h> -#include <Swiften/Network/PlatformNetworkEnvironment.h> -#include <Swiften/Elements/JingleRawUDPTransportPayload.h> #include <Swiften/Base/foreach.h> - -#include <Swiften/Network/UDPSocketFactory.h> +#include <Swiften/Elements/JingleRawUDPTransportPayload.h> +#include <Swiften/Network/PlatformNetworkEnvironment.h> #include <Swiften/Network/UDPSocket.h> +#include <Swiften/Network/UDPSocketFactory.h> +#include <Swiften/ScreenSharing/RTPSession.h> +#include <Swiften/Jingle/JingleSession.h> + +#include <boost/bind.hpp> namespace Swift { ScreenSharing::ScreenSharing(boost::shared_ptr<JingleSession> session, UDPSocketFactory* udpSocketFactory) - : session(session), udpSocketFactory(udpSocketFactory) + : rtpSession(0), jingleSession(session), udpSocketFactory(udpSocketFactory) { + session->onSessionTerminateReceived.connect(boost::bind(&ScreenSharing::handleSessionTerminateReceived, this, _1)); } ScreenSharing::~ScreenSharing() { } +void ScreenSharing::stop() +{ + jingleSession->sendTerminate(JinglePayload::Reason::Success); + if (rtpSession) + rtpSession->stop(); +} + bool ScreenSharing::addBestCandidate(boost::shared_ptr<JingleRawUDPTransportPayload> transport) { // TODO: NAT traversal @@ -65,4 +76,21 @@ bool ScreenSharing::addBestCandidate(boost::shared_ptr<JingleRawUDPTransportPayl return false; } +void ScreenSharing::handleSessionTerminateReceived(boost::optional<JinglePayload::Reason> reason) +{ + if (rtpSession) + rtpSession->stop(); + + if (reason.is_initialized() && reason.get().type == JinglePayload::Reason::Cancel) { + onStateChange(ScreenSharing::Canceled); + //onFinished(FileTransferError(FileTransferError::PeerError)); + } else if (reason.is_initialized() && reason.get().type == JinglePayload::Reason::Success) { + onStateChange(ScreenSharing::Finished); + //onFinished(boost::optional<FileTransferError>()); + } else { + onStateChange(ScreenSharing::Failed); + //onFinished(FileTransferError(FileTransferError::PeerError)); + } +} + } |