OLD | NEW |
1 /* Copyright (c) 2010 The Chromium Authors. All rights reserved. | 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 | 2 * Use of this source code is governed by a BSD-style license that can be |
3 * found in the LICENSE file. | 3 * found in the LICENSE file. |
4 */ | 4 */ |
5 #ifndef PPAPI_C_PPB_TRANSPORT_DEV_H_ | 5 #ifndef PPAPI_C_PPB_TRANSPORT_DEV_H_ |
6 #define PPAPI_C_PPB_TRANSPORT_DEV_H_ | 6 #define PPAPI_C_PPB_TRANSPORT_DEV_H_ |
7 | 7 |
8 #include "ppapi/c/pp_bool.h" | 8 #include "ppapi/c/pp_bool.h" |
9 #include "ppapi/c/pp_completion_callback.h" | 9 #include "ppapi/c/pp_completion_callback.h" |
10 #include "ppapi/c/pp_module.h" | 10 #include "ppapi/c/pp_module.h" |
11 #include "ppapi/c/pp_instance.h" | 11 #include "ppapi/c/pp_instance.h" |
12 #include "ppapi/c/pp_resource.h" | 12 #include "ppapi/c/pp_resource.h" |
13 #include "ppapi/c/pp_stdint.h" | 13 #include "ppapi/c/pp_stdint.h" |
14 #include "ppapi/c/pp_var.h" | 14 #include "ppapi/c/pp_var.h" |
15 | 15 |
16 #define PPB_TRANSPORT_DEV_INTERFACE "PPB_Transport;0.4" | 16 #define PPB_TRANSPORT_DEV_INTERFACE "PPB_Transport;0.4" |
17 | 17 |
18 struct PPB_Transport_Dev { | 18 struct PPB_Transport_Dev { |
19 // Creates a new transport object with the specified name | 19 // Creates a new transport object with the specified name using the |
20 // using the specified protocol. | 20 // specified protocol. |
21 PP_Resource (*CreateTransport)(PP_Instance instance, | 21 PP_Resource (*CreateTransport)(PP_Instance instance, |
22 const char* name, | 22 const char* name, |
23 const char* proto); | 23 const char* proto); |
24 | 24 |
25 // Returns PP_TRUE if resource is a Transport, PP_FALSE otherwise. | 25 // Returns PP_TRUE if resource is a Transport, PP_FALSE otherwise. |
26 PP_Bool (*IsTransport)(PP_Resource resource); | 26 PP_Bool (*IsTransport)(PP_Resource resource); |
27 | 27 |
28 // Returns PP_TRUE if the transport is currently writable | 28 // Returns PP_TRUE if the transport is currently writable (i.e. can |
29 // (i.e. can send data to the remote peer), PP_FALSE otherwise. | 29 // send data to the remote peer), PP_FALSE otherwise. |
30 PP_Bool (*IsWritable)(PP_Resource transport); | 30 PP_Bool (*IsWritable)(PP_Resource transport); |
31 // TODO(juberti): other getters/setters | 31 // TODO(juberti): other getters/setters |
32 // connect state | 32 // connect state |
33 // connect type, protocol | 33 // connect type, protocol |
34 // RTT | 34 // RTT |
35 | 35 |
36 // Establishes a connection to the remote peer. | 36 // Establishes a connection to the remote peer. Returns |
37 // Returns PP_ERROR_WOULDBLOCK and notifies on |cb| | 37 // PP_ERROR_WOULDBLOCK and notifies on |cb| when connectivity is |
38 // when connectivity is established (or timeout occurs). | 38 // established (or timeout occurs). |
39 int32_t (*Connect)(PP_Resource transport, | 39 int32_t (*Connect)(PP_Resource transport, |
40 struct PP_CompletionCallback cb); | 40 struct PP_CompletionCallback cb); |
41 | 41 |
42 // Obtains another ICE candidate address to be provided | 42 // Obtains another ICE candidate address to be provided to the |
43 // to the remote peer. Returns PP_ERROR_WOULDBLOCK | 43 // remote peer. Returns PP_ERROR_WOULDBLOCK if there are no more |
44 // if there are no more addresses to be sent. | 44 // addresses to be sent. After the callback is called |
| 45 // GetNextAddress() must be called again to get the address. |
45 int32_t (*GetNextAddress)(PP_Resource transport, | 46 int32_t (*GetNextAddress)(PP_Resource transport, |
46 struct PP_Var* address, | 47 struct PP_Var* address, |
47 struct PP_CompletionCallback cb); | 48 struct PP_CompletionCallback cb); |
48 // Provides an ICE candidate address that was received | 49 // Provides an ICE candidate address that was received |
49 // from the remote peer. | 50 // from the remote peer. |
50 int32_t (*ReceiveRemoteAddress)(PP_Resource transport, | 51 int32_t (*ReceiveRemoteAddress)(PP_Resource transport, |
51 struct PP_Var address); | 52 struct PP_Var address); |
52 | 53 |
53 // Like recv(), receives data. Returns PP_ERROR_WOULDBLOCK | 54 // Like recv(), receives data. Returns PP_ERROR_WOULDBLOCK if there |
54 // if there is currently no data to receive. | 55 // is currently no data to receive. In that case, the |data| pointer |
| 56 // should remain valid until the callback is called. |
55 int32_t (*Recv)(PP_Resource transport, | 57 int32_t (*Recv)(PP_Resource transport, |
56 void* data, | 58 void* data, |
57 uint32_t len, | 59 uint32_t len, |
58 struct PP_CompletionCallback cb); | 60 struct PP_CompletionCallback cb); |
59 // Like send(), sends data. Returns PP_ERROR_WOULDBLOCK | 61 // Like send(), sends data. Returns PP_ERROR_WOULDBLOCK if the |
60 // if the socket is currently flow-controlled. | 62 // socket is currently flow-controlled. In that case, the |data| |
| 63 // pointer should remain valid until the callback is called. |
61 int32_t (*Send)(PP_Resource transport, | 64 int32_t (*Send)(PP_Resource transport, |
62 const void* data, | 65 const void* data, |
63 uint32_t len, | 66 uint32_t len, |
64 struct PP_CompletionCallback cb); | 67 struct PP_CompletionCallback cb); |
65 | 68 |
66 // Disconnects from the remote peer. | 69 // Disconnects from the remote peer. |
67 int32_t (*Close)(PP_Resource transport); | 70 int32_t (*Close)(PP_Resource transport); |
68 }; | 71 }; |
69 | 72 |
70 #endif /* PPAPI_C_PPB_TRANSPORT_DEV_H_ */ | 73 #endif /* PPAPI_C_PPB_TRANSPORT_DEV_H_ */ |
71 | |
OLD | NEW |