OLD | NEW |
| (Empty) |
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 | |
6 /* From dev/ppb_transport_dev.idl modified Wed Oct 5 14:06:02 2011. */ | |
7 | |
8 #ifndef PPAPI_C_DEV_PPB_TRANSPORT_DEV_H_ | |
9 #define PPAPI_C_DEV_PPB_TRANSPORT_DEV_H_ | |
10 | |
11 #include "ppapi/c/pp_bool.h" | |
12 #include "ppapi/c/pp_completion_callback.h" | |
13 #include "ppapi/c/pp_instance.h" | |
14 #include "ppapi/c/pp_macros.h" | |
15 #include "ppapi/c/pp_resource.h" | |
16 #include "ppapi/c/pp_stdint.h" | |
17 #include "ppapi/c/pp_var.h" | |
18 | |
19 #define PPB_TRANSPORT_DEV_INTERFACE_0_7 "PPB_Transport(Dev);0.7" | |
20 #define PPB_TRANSPORT_DEV_INTERFACE PPB_TRANSPORT_DEV_INTERFACE_0_7 | |
21 | |
22 /** | |
23 * @file | |
24 * This file defines the <code>PPB_Transport_Dev</code> interface. | |
25 */ | |
26 | |
27 | |
28 /** | |
29 * @addtogroup Enums | |
30 * @{ | |
31 */ | |
32 typedef enum { | |
33 PP_TRANSPORTTYPE_DATAGRAM = 0, | |
34 PP_TRANSPORTTYPE_STREAM = 1 | |
35 } PP_TransportType; | |
36 PP_COMPILE_ASSERT_SIZE_IN_BYTES(PP_TransportType, 4); | |
37 | |
38 typedef enum { | |
39 /** | |
40 * STUN server address and port, e.g "stun.example.com:19302". | |
41 */ | |
42 PP_TRANSPORTPROPERTY_STUN_SERVER = 0, | |
43 /** | |
44 * Relay server address and port, e.g. "relay.example.com:12344". | |
45 */ | |
46 PP_TRANSPORTPROPERTY_RELAY_SERVER = 1, | |
47 /** | |
48 * Username for the relay server. | |
49 */ | |
50 PP_TRANSPORTPROPERTY_RELAY_USERNAME = 2, | |
51 /** | |
52 * Password for the relay server. | |
53 */ | |
54 PP_TRANSPORTPROPERTY_RELAY_PASSWORD = 3, | |
55 /** | |
56 * Type of Relay server. Must be one of the PP_TransportRelayMode values. By | |
57 * default is set to PP_TRANSPORTRELAYMODE_TURN. | |
58 */ | |
59 PP_TRANSPORTPROPERTY_RELAY_MODE = 4, | |
60 /** | |
61 * TCP receive window in bytes. Takes effect only for PseudoTCP connections. | |
62 */ | |
63 PP_TRANSPORTPROPERTY_TCP_RECEIVE_WINDOW = 5, | |
64 /** | |
65 * TCP send window in bytes. Takes effect only for PseudoTCP connections. | |
66 */ | |
67 PP_TRANSPORTPROPERTY_TCP_SEND_WINDOW = 6, | |
68 /** | |
69 * Boolean value that disables Neagle's algorithm when set to true. When | |
70 * Neagle's algorithm is disabled, all outgoing packets are sent as soon as | |
71 * possible. When set to false (by default) data may be buffered until there | |
72 * is a sufficient amount to send. | |
73 */ | |
74 PP_TRANSPORTPROPERTY_TCP_NO_DELAY = 7, | |
75 /** | |
76 * Delay for ACK packets in milliseconds. By default set to 100ms. | |
77 */ | |
78 PP_TRANSPORTPROPERTY_TCP_ACK_DELAY = 8, | |
79 /** | |
80 * Boolean value that disables TCP-based transports when set to true. By | |
81 * default set to false. | |
82 */ | |
83 PP_TRANSPORTPROPERTY_DISABLE_TCP_TRANSPORT = 9 | |
84 } PP_TransportProperty; | |
85 PP_COMPILE_ASSERT_SIZE_IN_BYTES(PP_TransportProperty, 4); | |
86 | |
87 typedef enum { | |
88 /** | |
89 * RFC5766 compliant relay server. | |
90 */ | |
91 PP_TRANSPORTRELAYMODE_TURN = 0, | |
92 /** | |
93 * Legacy Google relay server. | |
94 */ | |
95 PP_TRANSPORTRELAYMODE_GOOGLE = 1 | |
96 } PP_TransportRelayMode; | |
97 PP_COMPILE_ASSERT_SIZE_IN_BYTES(PP_TransportRelayMode, 4); | |
98 /** | |
99 * @} | |
100 */ | |
101 | |
102 /** | |
103 * @addtogroup Interfaces | |
104 * @{ | |
105 */ | |
106 /** | |
107 * The transport interface provides peer-to-peer communication. | |
108 * | |
109 * TODO(juberti): other getters/setters | |
110 * connect state | |
111 * connect type, protocol | |
112 * RTT | |
113 */ | |
114 struct PPB_Transport_Dev_0_7 { | |
115 /** | |
116 * Creates a new transport object with the specified name using the | |
117 * specified protocol. | |
118 */ | |
119 PP_Resource (*CreateTransport)(PP_Instance instance, | |
120 const char* name, | |
121 PP_TransportType type); | |
122 /** | |
123 * Returns PP_TRUE if resource is a Transport, PP_FALSE otherwise. | |
124 */ | |
125 PP_Bool (*IsTransport)(PP_Resource resource); | |
126 /** | |
127 * Returns PP_TRUE if the transport is currently writable (i.e. can | |
128 * send data to the remote peer), PP_FALSE otherwise. | |
129 */ | |
130 PP_Bool (*IsWritable)(PP_Resource transport); | |
131 /** | |
132 * Sets various configuration properties of the transport. | |
133 */ | |
134 int32_t (*SetProperty)(PP_Resource transport, | |
135 PP_TransportProperty property, | |
136 struct PP_Var value); | |
137 /** | |
138 * Establishes a connection to the remote peer. Returns | |
139 * PP_OK_COMPLETIONPENDING and notifies on |cb| when connectivity is | |
140 * established (or timeout occurs). | |
141 */ | |
142 int32_t (*Connect)(PP_Resource transport, struct PP_CompletionCallback cb); | |
143 /** | |
144 * Obtains another ICE candidate address to be provided to the | |
145 * remote peer. Returns PP_OK_COMPLETIONPENDING if there are no more | |
146 * addresses to be sent. After the callback is called | |
147 * GetNextAddress() must be called again to get the address. | |
148 */ | |
149 int32_t (*GetNextAddress)(PP_Resource transport, | |
150 struct PP_Var* address, | |
151 struct PP_CompletionCallback cb); | |
152 /** | |
153 * Provides an ICE candidate address that was received from the remote peer. | |
154 */ | |
155 int32_t (*ReceiveRemoteAddress)(PP_Resource transport, struct PP_Var address); | |
156 /** | |
157 * Like recv(), receives data. Returns PP_OK_COMPLETIONPENDING if there is | |
158 * currently no data to receive. In that case, the |data| pointer should | |
159 * remain valid until the callback is called. | |
160 */ | |
161 int32_t (*Recv)(PP_Resource transport, | |
162 void* data, | |
163 uint32_t len, | |
164 struct PP_CompletionCallback cb); | |
165 /** | |
166 * Like send(), sends data. Returns PP_OK_COMPLETIONPENDING if the socket is | |
167 * currently flow-controlled. In that case, the |data| pointer should remain | |
168 * valid until the callback is called. | |
169 */ | |
170 int32_t (*Send)(PP_Resource transport, | |
171 const void* data, | |
172 uint32_t len, | |
173 struct PP_CompletionCallback cb); | |
174 /** | |
175 * Disconnects from the remote peer. | |
176 */ | |
177 int32_t (*Close)(PP_Resource transport); | |
178 }; | |
179 | |
180 typedef struct PPB_Transport_Dev_0_7 PPB_Transport_Dev; | |
181 /** | |
182 * @} | |
183 */ | |
184 | |
185 #endif /* PPAPI_C_DEV_PPB_TRANSPORT_DEV_H_ */ | |
186 | |
OLD | NEW |