1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 2 // Use of this source code is governed by a BSD-style license that can be 3 // found in the LICENSE file. 4 5 #ifndef REMOTING_PROTOCOL_TRANSPORT_H_ 6 #define REMOTING_PROTOCOL_TRANSPORT_H_ 7 8 #include <memory> 9 #include <string> 10 11 #include "base/callback_forward.h" 12 #include "base/macros.h" 13 #include "net/base/ip_endpoint.h" 14 #include "remoting/protocol/errors.h" 15 16 namespace jingle_xmpp { 17 class XmlElement; 18 } // namespace jingle_xmpp 19 20 namespace remoting { 21 namespace protocol { 22 23 class Authenticator; 24 25 enum class TransportRole { 26 SERVER, 27 CLIENT, 28 }; 29 30 struct TransportRoute { 31 enum RouteType { 32 DIRECT, 33 STUN, 34 RELAY, 35 ROUTE_TYPE_MAX = RELAY, 36 }; 37 38 // Helper method to get string representation of the type. 39 static std::string GetTypeString(RouteType type); 40 41 TransportRoute(); 42 ~TransportRoute(); 43 44 RouteType type; 45 net::IPEndPoint remote_address; 46 net::IPEndPoint local_address; 47 }; 48 49 // Transport represents a P2P connection that consists of one or more channels. 50 // This interface is used just to send and receive transport-info messages. 51 // Implementations should provide other methods to send and receive data. 52 class Transport { 53 public: 54 typedef base::RepeatingCallback<void( 55 std::unique_ptr<jingle_xmpp::XmlElement> transport_info)> 56 SendTransportInfoCallback; 57 ~Transport()58 virtual ~Transport() {} 59 60 // Sets the object responsible for delivering outgoing transport-info messages 61 // to the peer. 62 virtual void Start( 63 Authenticator* authenticator, 64 SendTransportInfoCallback send_transport_info_callback) = 0; 65 virtual bool ProcessTransportInfo(jingle_xmpp::XmlElement* transport_info) = 0; 66 }; 67 68 } // namespace protocol 69 } // namespace remoting 70 71 #endif // REMOTING_PROTOCOL_TRANSPORT_H_ 72