OLD | NEW |
---|---|
(Empty) | |
1 /* | |
2 * Copyright 2016 The WebRTC project authors. All Rights Reserved. | |
3 * | |
4 * Use of this source code is governed by a BSD-style license | |
5 * that can be found in the LICENSE file in the root of the source | |
6 * tree. An additional intellectual property rights grant can be found | |
7 * in the file PATENTS. All contributing project authors may | |
8 * be found in the AUTHORS file in the root of the source tree. | |
9 */ | |
10 | |
11 #ifndef WEBRTC_P2P_BASE_UDPTRANSPORTCHANNEL_H_ | |
12 #define WEBRTC_P2P_BASE_UDPTRANSPORTCHANNEL_H_ | |
13 | |
14 #include <memory> | |
15 #include <string> | |
16 | |
17 #include "webrtc/base/optional.h" | |
18 #include "webrtc/base/thread_checker.h" | |
19 #include "webrtc/p2p/base/packettransportinterface.h" | |
20 | |
21 namespace rtc { | |
22 class AsyncPacketSocket; | |
23 class PhysicalSocketServer; | |
24 class SocketAddress; | |
25 class SocketServer; | |
26 class Thread; | |
27 } | |
28 | |
29 namespace cricket { | |
30 | |
31 enum UdpTransportState { | |
32 UDPTRANSPORT_STATE_INIT, | |
33 UDPTRANSPORT_STATE_CONNECTING, | |
34 UDPTRANSPORT_STATE_COMPLETED, | |
35 UDPTRANSPORT_STATE_FAILED | |
36 }; | |
pthatcher1
2016/11/04 22:58:58
Can you use enum class, in which case you don't ne
johan
2016/11/07 17:51:53
Sounds good. Doing the enum class, and declaring t
| |
37 | |
38 class UdpTransportChannel : public rtc::PacketTransportInterface { | |
39 public: | |
40 UdpTransportChannel(const std::string& transport_name, int component); | |
41 UdpTransportChannel(const std::string& transport_name, | |
42 int component, | |
pthatcher1
2016/11/04 22:58:58
I thought you said you removed the components. Ca
johan
2016/11/07 17:51:53
Done.
| |
43 rtc::SocketServer* ss); | |
44 ~UdpTransportChannel(); | |
45 | |
46 const std::string debug_name() const override { return debug_name_; } | |
47 | |
48 bool receiving() const override { | |
49 // TODO(johan): Implement method and signal. | |
50 return true; | |
51 } | |
52 | |
53 bool writable() const override; | |
54 | |
55 int SendPacket(const char* data, | |
56 size_t len, | |
57 const rtc::PacketOptions& options, | |
58 int flags) override; | |
59 | |
60 int SetOption(rtc::Socket::Option opt, int value) override { return 0; } | |
61 | |
62 int GetError() override { return send_error_; } | |
63 | |
64 UdpTransportState GetState() const { | |
pthatcher1
2016/11/04 22:58:58
Why not just "state()"?
johan
2016/11/07 17:51:53
Method name is an artifact from the TransportChann
| |
65 RTC_DCHECK_RUN_ON(&network_thread_checker_); | |
66 return state_; | |
67 } | |
68 | |
69 // Check GetState() for resulting state. | |
pthatcher1
2016/11/04 22:58:58
I'm not sure what meaning this comment has.
And
johan
2016/11/07 17:51:53
It is public, because it is not called from any ot
pthatcher1
2016/11/09 16:34:59
I'd be in favor of a Start method.
johan
2016/11/09 17:22:03
Renamed CreateSocket to Start and rephrased commen
| |
70 void CreateSocket(); | |
71 | |
72 void SetRemoteParameters(const rtc::SocketAddress& remote); | |
73 | |
74 // Returns default value, if local candidate is not set. | |
pthatcher1
2016/11/04 22:58:58
"value, if" => "value if"
And what does "local ca
johan
2016/11/07 17:51:53
Rephrasing the comment, as the return type changed
| |
75 // Consider checking GetState() before calling local_parameters(). | |
76 const rtc::SocketAddress& local_parameters(); | |
77 | |
78 private: | |
79 void OnSocketReadPacket(rtc::AsyncPacketSocket* socket, | |
80 const char* data, | |
81 size_t len, | |
82 const rtc::SocketAddress& remote_addr, | |
83 const rtc::PacketTime& packet_time); | |
84 void OnSocketSentPacket(rtc::AsyncPacketSocket* socket, | |
85 const rtc::SentPacket& packet); | |
86 void SetTransportChannelState( | |
87 UdpTransportState state); // Set State and Signal. | |
88 UdpTransportState state_ = UDPTRANSPORT_STATE_INIT; | |
pthatcher1
2016/11/04 22:58:58
Fields should go below methods
johan
2016/11/07 17:51:53
Acknowledged.
| |
89 bool IsLocalConsistent(); | |
90 void UpdateState(); | |
91 void UpdateDebugName(); | |
92 int send_error_ = 0; | |
93 std::string transport_name_; | |
94 std::string debug_name_; | |
95 int component_; | |
96 std::unique_ptr<rtc::AsyncPacketSocket> socket_; | |
97 rtc::Optional<rtc::SocketAddress> local_parameters_; | |
98 rtc::Optional<rtc::SocketAddress> remote_parameters_; | |
99 rtc::SocketServer* socket_server_; | |
100 rtc::ThreadChecker network_thread_checker_; | |
pthatcher1
2016/11/04 22:58:58
The fields filled by the constructor should go fir
johan
2016/11/07 17:51:53
Ok, transport_name_ and socket_server_ first.
| |
101 }; | |
102 } // namespace cricket | |
103 | |
104 #endif // WEBRTC_P2P_BASE_UDPTRANSPORTCHANNEL_H_ | |
OLD | NEW |