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

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

Issue 1246913005: TransportController refactoring (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Set media engine on voice channel Created 5 years, 4 months 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
1 /* 1 /*
2 * Copyright 2004 The WebRTC Project Authors. All rights reserved. 2 * Copyright 2004 The WebRTC Project Authors. All rights reserved.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license 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 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 6 * tree. An additional intellectual property rights grant can be found
7 * in the file PATENTS. All contributing project authors may 7 * in the file PATENTS. All contributing project authors may
8 * be found in the AUTHORS file in the root of the source tree. 8 * be found in the AUTHORS file in the root of the source tree.
9 */ 9 */
10 10
11 #ifndef WEBRTC_P2P_BASE_RAWTRANSPORTCHANNEL_H_ 11 #ifndef WEBRTC_P2P_BASE_RAWTRANSPORTCHANNEL_H_
12 #define WEBRTC_P2P_BASE_RAWTRANSPORTCHANNEL_H_ 12 #define WEBRTC_P2P_BASE_RAWTRANSPORTCHANNEL_H_
13 13
14 #include <string> 14 #include <string>
15 #include <vector> 15 #include <vector>
16 #include "webrtc/p2p/base/candidate.h" 16 #include "webrtc/p2p/base/candidate.h"
17 #include "webrtc/p2p/base/rawtransport.h" 17 #include "webrtc/p2p/base/rawtransport.h"
18 #include "webrtc/p2p/base/transportchannelimpl.h" 18 #include "webrtc/p2p/base/transportchannelimpl.h"
19 #include "webrtc/base/messagequeue.h" 19 #include "webrtc/base/messagequeue.h"
20 20
21 #if defined(FEATURE_ENABLE_PSTN) 21 #if defined(FEATURE_ENABLE_PSTN)
22 22
23 namespace rtc {
24 class Thread;
25 }
26
27 namespace cricket { 23 namespace cricket {
28 24
29 class Connection; 25 class Connection;
30 class PortAllocator; 26 class PortAllocator;
31 class PortAllocatorSession; 27 class PortAllocatorSession;
32 class PortInterface; 28 class PortInterface;
33 class RelayPort; 29 class RelayPort;
34 class StunPort; 30 class StunPort;
35 31
36 // Implements a channel that just sends bare packets once we have received the 32 // Implements a channel that just sends bare packets once we have received the
37 // address of the other side. We pick a single address to send them based on 33 // address of the other side. We pick a single address to send them based on
38 // a simple investigation of NAT type. 34 // a simple investigation of NAT type.
39 class RawTransportChannel : public TransportChannelImpl, 35 class RawTransportChannel : public TransportChannelImpl {
40 public rtc::MessageHandler {
41 public: 36 public:
42 RawTransportChannel(const std::string& content_name, 37 RawTransportChannel(const std::string& content_name,
43 int component, 38 int component,
44 RawTransport* transport, 39 RawTransport* transport,
45 rtc::Thread *worker_thread, 40 PortAllocator* allocator);
46 PortAllocator *allocator);
47 virtual ~RawTransportChannel(); 41 virtual ~RawTransportChannel();
48 42
49 // Implementation of normal channel packet sending. 43 // Implementation of normal channel packet sending.
50 virtual int SendPacket(const char *data, size_t len, 44 virtual int SendPacket(const char *data, size_t len,
51 const rtc::PacketOptions& options, int flags); 45 const rtc::PacketOptions& options, int flags);
52 virtual int SetOption(rtc::Socket::Option opt, int value); 46 virtual int SetOption(rtc::Socket::Option opt, int value);
53 virtual bool GetOption(rtc::Socket::Option opt, int* value); 47 virtual bool GetOption(rtc::Socket::Option opt, int* value);
54 virtual int GetError(); 48 virtual int GetError();
55 49
56 // Implements TransportChannelImpl. 50 // Implements TransportChannelImpl.
57 virtual Transport* GetTransport() { return raw_transport_; } 51 virtual Transport* GetTransport() { return raw_transport_; }
58 virtual TransportChannelState GetState() const { 52 virtual TransportChannelState GetState() const {
59 return TransportChannelState::STATE_COMPLETED; 53 return TransportChannelState::STATE_COMPLETED;
60 } 54 }
61 virtual void SetIceCredentials(const std::string& ice_ufrag, 55 virtual void SetIceCredentials(const std::string& ice_ufrag,
62 const std::string& ice_pwd) {} 56 const std::string& ice_pwd) {}
63 virtual void SetRemoteIceCredentials(const std::string& ice_ufrag, 57 virtual void SetRemoteIceCredentials(const std::string& ice_ufrag,
64 const std::string& ice_pwd) {} 58 const std::string& ice_pwd) {}
65 59
66 // Creates an allocator session to start figuring out which type of 60 // Creates an allocator session to start figuring out which type of
67 // port we should send to the other client. This will send 61 // port we should send to the other client. This will send
68 // SignalAvailableCandidate once we have decided. 62 // SignalAvailableCandidate once we have decided.
69 virtual void Connect(); 63 virtual void Connect();
70 64
65 virtual GatheringState gathering_state() const { return kGatheringNew; }
66
71 // Resets state back to unconnected. 67 // Resets state back to unconnected.
72 virtual void Reset(); 68 virtual void Reset();
73 69
74 // We don't actually worry about signaling since we can't send new candidates.
75 virtual void OnSignalingReady() {}
76
77 // Handles a message setting the remote address. We are writable once we 70 // Handles a message setting the remote address. We are writable once we
78 // have this since we now know where to send. 71 // have this since we now know where to send.
79 virtual void OnCandidate(const Candidate& candidate); 72 virtual void OnCandidate(const Candidate& candidate);
80 73
81 void OnRemoteAddress(const rtc::SocketAddress& remote_address); 74 void OnRemoteAddress(const rtc::SocketAddress& remote_address);
82 75
83 // Below ICE specific virtual methods not implemented. 76 // Below ICE specific virtual methods not implemented.
84 virtual IceRole GetIceRole() const { return ICEROLE_UNKNOWN; } 77 virtual IceRole GetIceRole() const { return ICEROLE_UNKNOWN; }
85 virtual void SetIceRole(IceRole role) {} 78 virtual void SetIceRole(IceRole role) {}
86 virtual void SetIceTiebreaker(uint64 tiebreaker) {} 79 virtual void SetIceTiebreaker(uint64 tiebreaker) {}
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
153 const std::string& digest_alg, 146 const std::string& digest_alg,
154 const uint8* digest, 147 const uint8* digest,
155 size_t digest_len) { 148 size_t digest_len) {
156 return false; 149 return false;
157 } 150 }
158 151
159 void SetReceivingTimeout(int timeout) override {} 152 void SetReceivingTimeout(int timeout) override {}
160 153
161 private: 154 private:
162 RawTransport* raw_transport_; 155 RawTransport* raw_transport_;
163 rtc::Thread *worker_thread_;
164 PortAllocator* allocator_; 156 PortAllocator* allocator_;
165 PortAllocatorSession* allocator_session_; 157 PortAllocatorSession* allocator_session_;
166 StunPort* stun_port_; 158 StunPort* stun_port_;
167 RelayPort* relay_port_; 159 RelayPort* relay_port_;
168 PortInterface* port_; 160 PortInterface* port_;
169 bool use_relay_; 161 bool use_relay_;
170 rtc::SocketAddress remote_address_; 162 rtc::SocketAddress remote_address_;
171 163
172 // Called when the allocator creates another port. 164 // Called when the allocator creates another port.
173 void OnPortReady(PortAllocatorSession* session, PortInterface* port); 165 void OnPortReady(PortAllocatorSession* session, PortInterface* port);
174 166
175 // Called when one of the ports we are using has determined its address. 167 // Called when one of the ports we are using has determined its address.
176 void OnCandidatesReady(PortAllocatorSession *session, 168 void OnCandidatesReady(PortAllocatorSession *session,
177 const std::vector<Candidate>& candidates); 169 const std::vector<Candidate>& candidates);
178 170
179 // Called once we have chosen the port to use for communication with the 171 // Called once we have chosen the port to use for communication with the
180 // other client. This will send its address and prepare the port for use. 172 // other client. This will send its address and prepare the port for use.
181 void SetPort(PortInterface* port); 173 void SetPort(PortInterface* port);
182 174
183 // Called once we have a port and a remote address. This will set mark the 175 // Called once we have a port and a remote address. This will set mark the
184 // channel as writable and signal the route to the client. 176 // channel as writable and signal the route to the client.
185 void SetWritable(); 177 void SetWritable();
186 178
187 // Called when we receive a packet from the other client. 179 // Called when we receive a packet from the other client.
188 void OnReadPacket(PortInterface* port, const char* data, size_t size, 180 void OnReadPacket(PortInterface* port, const char* data, size_t size,
189 const rtc::SocketAddress& addr); 181 const rtc::SocketAddress& addr);
190 182
191 // Handles a message to destroy unused ports. 183 void DestroyUnusedPorts();
192 virtual void OnMessage(rtc::Message *msg);
193 184
194 DISALLOW_COPY_AND_ASSIGN(RawTransportChannel); 185 DISALLOW_COPY_AND_ASSIGN(RawTransportChannel);
195 }; 186 };
196 187
197 } // namespace cricket 188 } // namespace cricket
198 189
199 #endif // defined(FEATURE_ENABLE_PSTN) 190 #endif // defined(FEATURE_ENABLE_PSTN)
200 #endif // WEBRTC_P2P_BASE_RAWTRANSPORTCHANNEL_H_ 191 #endif // WEBRTC_P2P_BASE_RAWTRANSPORTCHANNEL_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698