OLD | NEW |
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 |
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
134 const std::string& old_pwd, | 134 const std::string& old_pwd, |
135 const std::string& new_ufrag, | 135 const std::string& new_ufrag, |
136 const std::string& new_pwd); | 136 const std::string& new_pwd); |
137 | 137 |
138 class Transport : public rtc::MessageHandler, | 138 class Transport : public rtc::MessageHandler, |
139 public sigslot::has_slots<> { | 139 public sigslot::has_slots<> { |
140 public: | 140 public: |
141 Transport(rtc::Thread* signaling_thread, | 141 Transport(rtc::Thread* signaling_thread, |
142 rtc::Thread* worker_thread, | 142 rtc::Thread* worker_thread, |
143 const std::string& content_name, | 143 const std::string& content_name, |
144 const std::string& type, | |
145 PortAllocator* allocator); | 144 PortAllocator* allocator); |
146 virtual ~Transport(); | 145 virtual ~Transport(); |
147 | 146 |
148 // Returns the signaling thread. The app talks to Transport on this thread. | 147 // Returns the signaling thread. The app talks to Transport on this thread. |
149 rtc::Thread* signaling_thread() { return signaling_thread_; } | 148 rtc::Thread* signaling_thread() { return signaling_thread_; } |
150 // Returns the worker thread. The actual networking is done on this thread. | 149 // Returns the worker thread. The actual networking is done on this thread. |
151 rtc::Thread* worker_thread() { return worker_thread_; } | 150 rtc::Thread* worker_thread() { return worker_thread_; } |
152 | 151 |
153 // Returns the content_name of this transport. | 152 // Returns the content_name of this transport. |
154 const std::string& content_name() const { return content_name_; } | 153 const std::string& content_name() const { return content_name_; } |
155 // Returns the type of this transport. | |
156 const std::string& type() const { return type_; } | |
157 | 154 |
158 // Returns the port allocator object for this transport. | 155 // Returns the port allocator object for this transport. |
159 PortAllocator* port_allocator() { return allocator_; } | 156 PortAllocator* port_allocator() { return allocator_; } |
160 | 157 |
161 // Returns the readable and states of this manager. These bits are the ORs | 158 // Returns the readable and states of this manager. These bits are the ORs |
162 // of the corresponding bits on the managed channels. Each time one of these | 159 // of the corresponding bits on the managed channels. Each time one of these |
163 // states changes, a signal is raised. | 160 // states changes, a signal is raised. |
164 // TODO: Replace uses of readable() and writable() with | 161 // TODO: Replace uses of readable() and writable() with |
165 // any_channels_readable() and any_channels_writable(). | 162 // any_channels_readable() and any_channels_writable(). |
166 bool readable() const { return any_channels_readable(); } | 163 bool readable() const { return any_channels_readable(); } |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
204 | 201 |
205 // Must be called before applying local session description. | 202 // Must be called before applying local session description. |
206 void SetIdentity(rtc::SSLIdentity* identity); | 203 void SetIdentity(rtc::SSLIdentity* identity); |
207 | 204 |
208 // Get a copy of the local identity provided by SetIdentity. | 205 // Get a copy of the local identity provided by SetIdentity. |
209 bool GetIdentity(rtc::SSLIdentity** identity); | 206 bool GetIdentity(rtc::SSLIdentity** identity); |
210 | 207 |
211 // Get a copy of the remote certificate in use by the specified channel. | 208 // Get a copy of the remote certificate in use by the specified channel. |
212 bool GetRemoteCertificate(rtc::SSLCertificate** cert); | 209 bool GetRemoteCertificate(rtc::SSLCertificate** cert); |
213 | 210 |
214 TransportProtocol protocol() const { return protocol_; } | |
215 | |
216 // Create, destroy, and lookup the channels of this type by their components. | 211 // Create, destroy, and lookup the channels of this type by their components. |
217 TransportChannelImpl* CreateChannel(int component); | 212 TransportChannelImpl* CreateChannel(int component); |
218 // Note: GetChannel may lead to race conditions, since the mutex is not held | 213 // Note: GetChannel may lead to race conditions, since the mutex is not held |
219 // after the pointer is returned. | 214 // after the pointer is returned. |
220 TransportChannelImpl* GetChannel(int component); | 215 TransportChannelImpl* GetChannel(int component); |
221 // Note: HasChannel does not lead to race conditions, unlike GetChannel. | 216 // Note: HasChannel does not lead to race conditions, unlike GetChannel. |
222 bool HasChannel(int component) { | 217 bool HasChannel(int component) { |
223 return (NULL != GetChannel(component)); | 218 return (NULL != GetChannel(component)); |
224 } | 219 } |
225 bool HasChannels(); | 220 bool HasChannels(); |
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
315 // Derived classes can override, but must call the base as well. | 310 // Derived classes can override, but must call the base as well. |
316 virtual bool ApplyLocalTransportDescription_w(TransportChannelImpl* channel, | 311 virtual bool ApplyLocalTransportDescription_w(TransportChannelImpl* channel, |
317 std::string* error_desc); | 312 std::string* error_desc); |
318 | 313 |
319 // Pushes down remote ice credentials from the remote description to the | 314 // Pushes down remote ice credentials from the remote description to the |
320 // transport channel. | 315 // transport channel. |
321 virtual bool ApplyRemoteTransportDescription_w(TransportChannelImpl* ch, | 316 virtual bool ApplyRemoteTransportDescription_w(TransportChannelImpl* ch, |
322 std::string* error_desc); | 317 std::string* error_desc); |
323 | 318 |
324 // Negotiates the transport parameters based on the current local and remote | 319 // Negotiates the transport parameters based on the current local and remote |
325 // transport description, such at the version of ICE to use, and whether DTLS | 320 // transport description, such as the ICE role to use, and whether DTLS |
326 // should be activated. | 321 // should be activated. |
327 // Derived classes can negotiate their specific parameters here, but must call | 322 // Derived classes can negotiate their specific parameters here, but must call |
328 // the base as well. | 323 // the base as well. |
329 virtual bool NegotiateTransportDescription_w(ContentAction local_role, | 324 virtual bool NegotiateTransportDescription_w(ContentAction local_role, |
330 std::string* error_desc); | 325 std::string* error_desc); |
331 | 326 |
332 // Pushes down the transport parameters obtained via negotiation. | 327 // Pushes down the transport parameters obtained via negotiation. |
333 // Derived classes can set their specific parameters here, but must call the | 328 // Derived classes can set their specific parameters here, but must call the |
334 // base as well. | 329 // base as well. |
335 virtual bool ApplyNegotiatedTransportDescription_w( | 330 virtual bool ApplyNegotiatedTransportDescription_w( |
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
441 bool GetRemoteCertificate_w(rtc::SSLCertificate** cert); | 436 bool GetRemoteCertificate_w(rtc::SSLCertificate** cert); |
442 | 437 |
443 void SetChannelReceivingTimeout_w(int timeout_ms); | 438 void SetChannelReceivingTimeout_w(int timeout_ms); |
444 | 439 |
445 // Sends SignalCompleted if we are now in that state. | 440 // Sends SignalCompleted if we are now in that state. |
446 void MaybeCompleted_w(); | 441 void MaybeCompleted_w(); |
447 | 442 |
448 rtc::Thread* const signaling_thread_; | 443 rtc::Thread* const signaling_thread_; |
449 rtc::Thread* const worker_thread_; | 444 rtc::Thread* const worker_thread_; |
450 const std::string content_name_; | 445 const std::string content_name_; |
451 const std::string type_; | |
452 PortAllocator* const allocator_; | 446 PortAllocator* const allocator_; |
453 bool destroyed_; | 447 bool destroyed_; |
454 TransportState readable_; | 448 TransportState readable_; |
455 TransportState writable_; | 449 TransportState writable_; |
456 TransportState receiving_; | 450 TransportState receiving_; |
457 bool was_writable_; | 451 bool was_writable_; |
458 bool connect_requested_; | 452 bool connect_requested_; |
459 IceRole ice_role_; | 453 IceRole ice_role_; |
460 uint64 tiebreaker_; | 454 uint64 tiebreaker_; |
461 TransportProtocol protocol_; | |
462 IceMode remote_ice_mode_; | 455 IceMode remote_ice_mode_; |
463 int channel_receiving_timeout_; | 456 int channel_receiving_timeout_; |
464 rtc::scoped_ptr<TransportDescription> local_description_; | 457 rtc::scoped_ptr<TransportDescription> local_description_; |
465 rtc::scoped_ptr<TransportDescription> remote_description_; | 458 rtc::scoped_ptr<TransportDescription> remote_description_; |
466 | 459 |
467 // TODO(tommi): Make sure we only use this on the worker thread. | 460 // TODO(tommi): Make sure we only use this on the worker thread. |
468 ChannelMap channels_; | 461 ChannelMap channels_; |
469 // Buffers the ready_candidates so that SignalCanidatesReady can | 462 // Buffers the ready_candidates so that SignalCanidatesReady can |
470 // provide them in multiples. | 463 // provide them in multiples. |
471 std::vector<Candidate> ready_candidates_; | 464 std::vector<Candidate> ready_candidates_; |
472 // Protects changes to channels and messages | 465 // Protects changes to channels and messages |
473 rtc::CriticalSection crit_; | 466 rtc::CriticalSection crit_; |
474 | 467 |
475 DISALLOW_COPY_AND_ASSIGN(Transport); | 468 DISALLOW_COPY_AND_ASSIGN(Transport); |
476 }; | 469 }; |
477 | 470 |
478 // Extract a TransportProtocol from a TransportDescription. | |
479 TransportProtocol TransportProtocolFromDescription( | |
480 const TransportDescription* desc); | |
481 | 471 |
482 } // namespace cricket | 472 } // namespace cricket |
483 | 473 |
484 #endif // WEBRTC_P2P_BASE_TRANSPORT_H_ | 474 #endif // WEBRTC_P2P_BASE_TRANSPORT_H_ |
OLD | NEW |