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