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

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

Issue 2377883003: First step in providing a UdpTransportChannel. (Closed)
Patch Set: Rebase: receiving(). 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
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/socketaddress.h"
18 #include "webrtc/base/thread_checker.h"
19 #include "webrtc/p2p/base/transportchannel.h"
Taylor Brandstetter 2016/11/01 21:32:49 It would be nice if this could depend only on Pack
pthatcher1 2016/11/02 06:19:38 I agree. Just make a new state enum.
johan 2016/11/02 15:14:04 Ok
20 #include "webrtc/p2p/base/transportchannelimpl.h"
21
22 namespace rtc {
23 class AsyncUDPSocket;
24 class PhysicalSocketServer;
25 class SocketServer;
26 class Thread;
27 }
28
29 namespace cricket {
30
Taylor Brandstetter 2016/11/01 21:32:49 If this class encapsulates a combination of RTP/RT
pthatcher1 2016/11/02 06:19:37 It doesn't. This should be one UDP socket/port an
Taylor Brandstetter 2016/11/02 19:15:20 It's not clear to me how that will work, or how it
31 class UdpTransportChannel : public rtc::PacketTransportInterface {
32 public:
33 UdpTransportChannel(const std::string& transport_name, int component);
Taylor Brandstetter 2016/11/01 21:32:48 If this is always RTP+RTCP, it doesn't need a comp
pthatcher1 2016/11/02 06:19:37 As far as I can tell, the component is only used f
johan 2016/11/02 15:14:04 Can do that.
34 UdpTransportChannel(const std::string& transport_name,
35 int component,
36 rtc::SocketServer* ss);
37 ~UdpTransportChannel();
38
39 const std::string debug_name() const override { return debug_name_; }
40
41 bool receiving() const override {
42 // TODO(johan): Implement method and signal.
43 return true;
pthatcher1 2016/11/02 06:19:37 Might as well implement it. It's basically just r
johan 2016/11/02 15:14:04 Yes, receiving() is no rocket science, but I would
44 }
45
46 bool writable() const override;
47
48 int SendPacket(const char* data,
49 size_t len,
50 const rtc::PacketOptions& options,
51 int flags) override;
52
53 int SetOption(rtc::Socket::Option opt, int value) override { return 0; }
54
55 int GetError() override { return send_error_; }
56
57 // TODO(johan): Reusing TransportChannelState is ugly. On the other hand there
58 // are already too many state enums for very similar states troughout the code
59 // base.
60 TransportChannelState GetState() const {
Taylor Brandstetter 2016/11/01 21:32:48 I agree there are a lot of states, but in my opini
pthatcher1 2016/11/02 06:19:37 I agree. Make a new enum.
johan 2016/11/02 15:14:04 Done.
61 RTC_DCHECK_RUN_ON(&network_thread_checker_);
62 return state_;
63 }
64
65 // Check GetState() for resulting state.
66 void TryAllocateSocket();
67
68 void AddRemoteCandidate(const Candidate& candidate);
Taylor Brandstetter 2016/11/01 21:32:48 As long as this is (now) a new interface, we could
pthatcher1 2016/11/02 06:19:37 Yeah, we shouldn't use candidates. They are speci
johan 2016/11/02 15:14:04 Done.
69
70 // Returns default values, if local candidate is not set.
71 // Consider checking GetState() before calling GetLocalCandidate().
72 const Candidate& GetLocalCandidate();
pthatcher1 2016/11/02 06:19:37 I would call this local_parameters()
johan 2016/11/02 15:14:04 Ok, the naming pattern for cheap functions from th
73
74 private:
75 void OnSocketReadPacket(rtc::AsyncPacketSocket* socket,
76 const char* data,
77 size_t len,
78 const rtc::SocketAddress& remote_addr,
79 const rtc::PacketTime& packet_time);
80 void OnSocketSentPacket(rtc::AsyncPacketSocket* socket,
81 const rtc::SentPacket& packet);
82 void SetTransportChannelState(
83 TransportChannelState state); // Set State and Signal.
84 TransportChannelState state_ = STATE_INIT;
85 bool IsLocalConsistent();
86 bool IsRemoteConsistent();
87 void UpdateState();
88 void UpdateDebugName();
89 int send_error_ = 0;
90 std::string transport_name_;
91 std::string debug_name_;
92 int component_;
93 std::unique_ptr<rtc::AsyncPacketSocket> socket_;
94 // TODO(johan): use a non-ICE datatype for parameters with
95 // PacketTransportInterface.
96 rtc::Optional<Candidate> local_parameters_;
97 rtc::Optional<Candidate> remote_parameters_;
98 rtc::SocketServer* socket_server_;
99 rtc::ThreadChecker network_thread_checker_;
100 };
101 } // namespace cricket
102
103 #endif // WEBRTC_P2P_BASE_UDPTRANSPORTCHANNEL_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698