OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2009 The WebRTC Project Authors. All rights reserved. | 2 * Copyright 2009 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 27 matching lines...) Expand all Loading... |
38 }; | 38 }; |
39 } // namespace | 39 } // namespace |
40 | 40 |
41 // Fake transport channel class, which can be passed to anything that needs a | 41 // Fake transport channel class, which can be passed to anything that needs a |
42 // transport channel. Can be informed of another FakeTransportChannel via | 42 // transport channel. Can be informed of another FakeTransportChannel via |
43 // SetDestination. | 43 // SetDestination. |
44 // TODO(hbos): Move implementation to .cc file, this and other classes in file. | 44 // TODO(hbos): Move implementation to .cc file, this and other classes in file. |
45 class FakeTransportChannel : public TransportChannelImpl, | 45 class FakeTransportChannel : public TransportChannelImpl, |
46 public rtc::MessageHandler { | 46 public rtc::MessageHandler { |
47 public: | 47 public: |
48 explicit FakeTransportChannel(const std::string& name, | 48 explicit FakeTransportChannel(Transport* transport, |
| 49 const std::string& name, |
49 int component) | 50 int component) |
50 : TransportChannelImpl(name, component), | 51 : TransportChannelImpl(name, component), |
| 52 transport_(transport), |
51 dtls_fingerprint_("", nullptr, 0) {} | 53 dtls_fingerprint_("", nullptr, 0) {} |
52 ~FakeTransportChannel() { Reset(); } | 54 ~FakeTransportChannel() { Reset(); } |
53 | 55 |
54 uint64_t IceTiebreaker() const { return tiebreaker_; } | 56 uint64_t IceTiebreaker() const { return tiebreaker_; } |
55 IceMode remote_ice_mode() const { return remote_ice_mode_; } | 57 IceMode remote_ice_mode() const { return remote_ice_mode_; } |
56 const std::string& ice_ufrag() const { return ice_ufrag_; } | 58 const std::string& ice_ufrag() const { return ice_ufrag_; } |
57 const std::string& ice_pwd() const { return ice_pwd_; } | 59 const std::string& ice_pwd() const { return ice_pwd_; } |
58 const std::string& remote_ice_ufrag() const { return remote_ice_ufrag_; } | 60 const std::string& remote_ice_ufrag() const { return remote_ice_ufrag_; } |
59 const std::string& remote_ice_pwd() const { return remote_ice_pwd_; } | 61 const std::string& remote_ice_pwd() const { return remote_ice_pwd_; } |
60 const rtc::SSLFingerprint& dtls_fingerprint() const { | 62 const rtc::SSLFingerprint& dtls_fingerprint() const { |
61 return dtls_fingerprint_; | 63 return dtls_fingerprint_; |
62 } | 64 } |
63 | 65 |
64 // If async, will send packets by "Post"-ing to message queue instead of | 66 // If async, will send packets by "Post"-ing to message queue instead of |
65 // synchronously "Send"-ing. | 67 // synchronously "Send"-ing. |
66 void SetAsync(bool async) { async_ = async; } | 68 void SetAsync(bool async) { async_ = async; } |
67 | 69 |
| 70 Transport* GetTransport() override { return transport_; } |
| 71 |
68 TransportChannelState GetState() const override { | 72 TransportChannelState GetState() const override { |
69 if (connection_count_ == 0) { | 73 if (connection_count_ == 0) { |
70 return had_connection_ ? TransportChannelState::STATE_FAILED | 74 return had_connection_ ? TransportChannelState::STATE_FAILED |
71 : TransportChannelState::STATE_INIT; | 75 : TransportChannelState::STATE_INIT; |
72 } | 76 } |
73 | 77 |
74 if (connection_count_ == 1) { | 78 if (connection_count_ == 1) { |
75 return TransportChannelState::STATE_COMPLETED; | 79 return TransportChannelState::STATE_COMPLETED; |
76 } | 80 } |
77 | 81 |
(...skipping 224 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
302 | 306 |
303 void set_ssl_max_protocol_version(rtc::SSLProtocolVersion version) { | 307 void set_ssl_max_protocol_version(rtc::SSLProtocolVersion version) { |
304 ssl_max_version_ = version; | 308 ssl_max_version_ = version; |
305 } | 309 } |
306 rtc::SSLProtocolVersion ssl_max_protocol_version() const { | 310 rtc::SSLProtocolVersion ssl_max_protocol_version() const { |
307 return ssl_max_version_; | 311 return ssl_max_version_; |
308 } | 312 } |
309 | 313 |
310 private: | 314 private: |
311 enum State { STATE_INIT, STATE_CONNECTING, STATE_CONNECTED }; | 315 enum State { STATE_INIT, STATE_CONNECTING, STATE_CONNECTED }; |
| 316 Transport* transport_; |
312 FakeTransportChannel* dest_ = nullptr; | 317 FakeTransportChannel* dest_ = nullptr; |
313 State state_ = STATE_INIT; | 318 State state_ = STATE_INIT; |
314 bool async_ = false; | 319 bool async_ = false; |
315 Candidates remote_candidates_; | 320 Candidates remote_candidates_; |
316 rtc::scoped_refptr<rtc::RTCCertificate> local_cert_; | 321 rtc::scoped_refptr<rtc::RTCCertificate> local_cert_; |
317 rtc::FakeSSLCertificate* remote_cert_ = nullptr; | 322 rtc::FakeSSLCertificate* remote_cert_ = nullptr; |
318 bool do_dtls_ = false; | 323 bool do_dtls_ = false; |
319 std::vector<int> srtp_ciphers_; | 324 std::vector<int> srtp_ciphers_; |
320 int chosen_crypto_suite_ = rtc::SRTP_INVALID_CRYPTO_SUITE; | 325 int chosen_crypto_suite_ = rtc::SRTP_INVALID_CRYPTO_SUITE; |
321 int receiving_timeout_ = -1; | 326 int receiving_timeout_ = -1; |
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
403 | 408 |
404 using Transport::local_description; | 409 using Transport::local_description; |
405 using Transport::remote_description; | 410 using Transport::remote_description; |
406 | 411 |
407 protected: | 412 protected: |
408 TransportChannelImpl* CreateTransportChannel(int component) override { | 413 TransportChannelImpl* CreateTransportChannel(int component) override { |
409 if (channels_.find(component) != channels_.end()) { | 414 if (channels_.find(component) != channels_.end()) { |
410 return nullptr; | 415 return nullptr; |
411 } | 416 } |
412 FakeTransportChannel* channel = | 417 FakeTransportChannel* channel = |
413 new FakeTransportChannel(name(), component); | 418 new FakeTransportChannel(this, name(), component); |
414 channel->set_ssl_max_protocol_version(ssl_max_version_); | 419 channel->set_ssl_max_protocol_version(ssl_max_version_); |
415 channel->SetAsync(async_); | 420 channel->SetAsync(async_); |
416 SetChannelDestination(component, channel); | 421 SetChannelDestination(component, channel); |
417 channels_[component] = channel; | 422 channels_[component] = channel; |
418 return channel; | 423 return channel; |
419 } | 424 } |
420 | 425 |
421 void DestroyTransportChannel(TransportChannelImpl* channel) override { | 426 void DestroyTransportChannel(TransportChannelImpl* channel) override { |
422 channels_.erase(channel->component()); | 427 channels_.erase(channel->component()); |
423 delete channel; | 428 delete channel; |
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
529 } | 534 } |
530 } | 535 } |
531 | 536 |
532 private: | 537 private: |
533 bool fail_create_channel_; | 538 bool fail_create_channel_; |
534 }; | 539 }; |
535 | 540 |
536 } // namespace cricket | 541 } // namespace cricket |
537 | 542 |
538 #endif // WEBRTC_P2P_BASE_FAKETRANSPORTCONTROLLER_H_ | 543 #endif // WEBRTC_P2P_BASE_FAKETRANSPORTCONTROLLER_H_ |
OLD | NEW |