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