| OLD | NEW |
| (Empty) |
| 1 // Copyright (c) 2011 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 WEBKIT_GLUE_P2P_TRANSPORT_H_ | |
| 6 #define WEBKIT_GLUE_P2P_TRANSPORT_H_ | |
| 7 | |
| 8 #include <string> | |
| 9 #include <vector> | |
| 10 | |
| 11 #include "base/basictypes.h" | |
| 12 #include "webkit/glue/webkit_glue_export.h" | |
| 13 | |
| 14 namespace net { | |
| 15 class Socket; | |
| 16 } // namespace net | |
| 17 | |
| 18 namespace WebKit { | |
| 19 class WebFrame; | |
| 20 } // namespace WebKit | |
| 21 | |
| 22 namespace webkit_glue { | |
| 23 | |
| 24 // Interface for P2P transport. | |
| 25 class P2PTransport { | |
| 26 public: | |
| 27 enum State { | |
| 28 STATE_NONE = 0, | |
| 29 STATE_WRITABLE = 1, | |
| 30 STATE_READABLE = 2, | |
| 31 }; | |
| 32 | |
| 33 enum Protocol { | |
| 34 PROTOCOL_UDP = 0, | |
| 35 PROTOCOL_TCP = 1, | |
| 36 }; | |
| 37 | |
| 38 class EventHandler { | |
| 39 public: | |
| 40 virtual ~EventHandler() {} | |
| 41 | |
| 42 // Called for each local candidate. | |
| 43 virtual void OnCandidateReady(const std::string& address) = 0; | |
| 44 | |
| 45 // Called when readable of writable state of the stream changes. | |
| 46 virtual void OnStateChange(State state) = 0; | |
| 47 | |
| 48 // Called when an error occures (e.g. TCP handshake | |
| 49 // failed). P2PTransport object is not usable after that and | |
| 50 // should be destroyed. | |
| 51 virtual void OnError(int error) = 0; | |
| 52 }; | |
| 53 | |
| 54 struct WEBKIT_GLUE_EXPORT Config { | |
| 55 Config(); | |
| 56 ~Config(); | |
| 57 | |
| 58 // STUN server address and port. | |
| 59 std::string stun_server; | |
| 60 int stun_server_port; | |
| 61 | |
| 62 // Relay server address and port. | |
| 63 std::string relay_server; | |
| 64 int relay_server_port; | |
| 65 | |
| 66 // Relay server username. | |
| 67 std::string relay_username; | |
| 68 | |
| 69 // Relay server password. | |
| 70 std::string relay_password; | |
| 71 | |
| 72 // When set to true relay is a legacy Google relay (not TURN | |
| 73 // compliant). | |
| 74 bool legacy_relay; | |
| 75 | |
| 76 // TCP window sizes. Default size is used when set to 0. | |
| 77 int tcp_receive_window; | |
| 78 int tcp_send_window; | |
| 79 | |
| 80 // Disables Neagle's algorithm when set to true. | |
| 81 bool tcp_no_delay; | |
| 82 | |
| 83 // TCP ACK delay. | |
| 84 int tcp_ack_delay_ms; | |
| 85 | |
| 86 // Disable TCP-based transport when set to true. | |
| 87 bool disable_tcp_transport; | |
| 88 }; | |
| 89 | |
| 90 virtual ~P2PTransport() {} | |
| 91 | |
| 92 // Initialize transport using specified configuration. |web_frame| | |
| 93 // is used to make HTTP requests to relay servers. Returns true | |
| 94 // if initialization succeeded. | |
| 95 virtual bool Init(WebKit::WebFrame* web_frame, | |
| 96 const std::string& name, | |
| 97 Protocol protocol, | |
| 98 const Config& config, | |
| 99 EventHandler* event_handler) = 0; | |
| 100 | |
| 101 // Add candidate received from the remote peer. Returns false if the | |
| 102 // provided address is not in a valid format. | |
| 103 virtual bool AddRemoteCandidate(const std::string& address) = 0; | |
| 104 | |
| 105 // Returns socket interface that can be used to send/receive | |
| 106 // data. Returned object is owned by the transport. Pending calls on | |
| 107 // the socket are canceled when the transport is destroyed. | |
| 108 virtual net::Socket* GetChannel() = 0; | |
| 109 }; | |
| 110 | |
| 111 } // namespace webkit_glue | |
| 112 | |
| 113 #endif // WEBKIT_GLUE_P2P_TRANSPORT_H_ | |
| OLD | NEW |