/* * Copyright (c) 2012 Yoann Blein * Licensed under the simplified BSD license. * See Documentation/Licenses/BSD-simplified.txt for more information. */ #include #include #include #include #include namespace Swift { IncomingScreenSharing::IncomingScreenSharing(boost::shared_ptr session, UDPSocketFactory* udpSocketFactory, boost::shared_ptr content) : ScreenSharing(session, udpSocketFactory), initialContent(content) { onStateChange(ScreenSharing::WaitingForAccept); } IncomingScreenSharing::~IncomingScreenSharing() { } void IncomingScreenSharing::cancel() { session->sendTerminate(JinglePayload::Reason::Cancel); clientSocket->close(); onStateChange(ScreenSharing::Canceled); } void IncomingScreenSharing::accept() { JingleRawUDPTransportPayload::ref transport = boost::make_shared(); addBestCandidate(transport); // TODO: create a valid description instead of copying the initator's one session->sendAccept(getContentID(), initialContent->getDescriptions().front(), transport); JingleRawUDPTransportPayload::ref initialTransport = initialContent->getTransport(); clientSocket = udpSocketFactory->createUDPSocket(); clientSocket->connect(initialTransport->getCandidates().front().hostAddressPort); // Send a empty packet to let the server know about us SafeByteArray data(1, 0); clientSocket->send(data); onStateChange(ScreenSharing::Connecting); } JingleContentID IncomingScreenSharing::getContentID() const { return JingleContentID(initialContent->getName(), initialContent->getCreator()); } }