Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(127)

Side by Side Diff: webrtc/p2p/base/udptransportchannel.h

Issue 2377883003: First step in providing a UdpTransportChannel. (Closed)
Patch Set: Fix typo. Created 4 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « webrtc/p2p/BUILD.gn ('k') | webrtc/p2p/base/udptransportchannel.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(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 class UdpTransportChannel : public rtc::PacketTransportInterface {
32 public:
33 enum class State { INIT, CONNECTING, CONNECTED, FAILED };
34 explicit UdpTransportChannel(const std::string& transport_name);
35 UdpTransportChannel(const std::string& transport_name, rtc::SocketServer* ss);
36 ~UdpTransportChannel();
37
38 const std::string debug_name() const override { return transport_name_; }
39
40 bool receiving() const override {
41 // TODO(johan): Implement method and signal.
42 return true;
43 }
44
45 bool writable() const override;
46
47 int SendPacket(const char* data,
48 size_t len,
49 const rtc::PacketOptions& options,
50 int flags) override;
51
52 int SetOption(rtc::Socket::Option opt, int value) override { return 0; }
53
54 int GetError() override { return send_error_; }
55
56 State state() const {
57 RTC_DCHECK_RUN_ON(&network_thread_checker_);
58 return state_;
59 }
60
61 // Create the local UDP socket and bind to port.
62 // Consider checking state() after calling CreateSocket().
63 void CreateSocket();
64
65 void SetRemoteParameters(const rtc::SocketAddress& remote);
66
67 // Returned optional does not hav a value if in the INIT or FAILED state.
Taylor Brandstetter 2016/11/09 00:53:42 hav -> have
68 // Consider checking state() before calling local_parameters().
69 rtc::Optional<rtc::SocketAddress> local_parameters() const {
70 return local_parameters_;
71 }
72
73 private:
74 void OnSocketReadPacket(rtc::AsyncPacketSocket* socket,
75 const char* data,
76 size_t len,
77 const rtc::SocketAddress& remote_addr,
78 const rtc::PacketTime& packet_time);
79 void OnSocketSentPacket(rtc::AsyncPacketSocket* socket,
80 const rtc::SentPacket& packet);
81 void SetState(State state); // Set State and Signal.
82 bool IsLocalConsistent();
83 void UpdateState();
84 std::string transport_name_;
85 rtc::SocketServer* socket_server_;
86 State state_ = State::INIT;
87 int send_error_ = 0;
88 std::unique_ptr<rtc::AsyncPacketSocket> socket_;
89 rtc::Optional<rtc::SocketAddress> local_parameters_;
90 rtc::Optional<rtc::SocketAddress> remote_parameters_;
91 rtc::ThreadChecker network_thread_checker_;
92 };
93 } // namespace cricket
94
95 #endif // WEBRTC_P2P_BASE_UDPTRANSPORTCHANNEL_H_
OLDNEW
« no previous file with comments | « webrtc/p2p/BUILD.gn ('k') | webrtc/p2p/base/udptransportchannel.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698