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 195 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
206 rtc::Thread::Current()->Post(this, 0, packet); | 206 rtc::Thread::Current()->Post(this, 0, packet); |
207 } else { | 207 } else { |
208 rtc::Thread::Current()->Send(this, 0, packet); | 208 rtc::Thread::Current()->Send(this, 0, packet); |
209 } | 209 } |
210 rtc::SentPacket sent_packet(options.packet_id, rtc::Time64()); | 210 rtc::SentPacket sent_packet(options.packet_id, rtc::Time64()); |
211 SignalSentPacket(this, sent_packet); | 211 SignalSentPacket(this, sent_packet); |
212 return static_cast<int>(len); | 212 return static_cast<int>(len); |
213 } | 213 } |
214 int SetOption(rtc::Socket::Option opt, int value) override { return true; } | 214 int SetOption(rtc::Socket::Option opt, int value) override { return true; } |
215 bool GetOption(rtc::Socket::Option opt, int* value) override { return true; } | 215 bool GetOption(rtc::Socket::Option opt, int* value) override { return true; } |
216 int GetError() override { return 0; } | 216 int GetError() override { return -1; } |
217 | 217 |
218 void AddRemoteCandidate(const Candidate& candidate) override { | 218 void AddRemoteCandidate(const Candidate& candidate) override { |
219 remote_candidates_.push_back(candidate); | 219 remote_candidates_.push_back(candidate); |
220 } | 220 } |
221 | 221 |
222 void RemoveRemoteCandidate(const Candidate& candidate) override {} | 222 void RemoveRemoteCandidate(const Candidate& candidate) override {} |
223 | 223 |
224 const Candidates& remote_candidates() const { return remote_candidates_; } | 224 const Candidates& remote_candidates() const { return remote_candidates_; } |
225 | 225 |
226 void OnMessage(rtc::Message* msg) override { | 226 void OnMessage(rtc::Message* msg) override { |
(...skipping 269 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
496 explicit FakeTransportController(rtc::Thread* worker_thread) | 496 explicit FakeTransportController(rtc::Thread* worker_thread) |
497 : TransportController(rtc::Thread::Current(), worker_thread, nullptr), | 497 : TransportController(rtc::Thread::Current(), worker_thread, nullptr), |
498 fail_create_channel_(false) {} | 498 fail_create_channel_(false) {} |
499 | 499 |
500 FakeTransportController(rtc::Thread* worker_thread, IceRole role) | 500 FakeTransportController(rtc::Thread* worker_thread, IceRole role) |
501 : TransportController(rtc::Thread::Current(), worker_thread, nullptr), | 501 : TransportController(rtc::Thread::Current(), worker_thread, nullptr), |
502 fail_create_channel_(false) { | 502 fail_create_channel_(false) { |
503 SetIceRole(role); | 503 SetIceRole(role); |
504 } | 504 } |
505 | 505 |
506 FakeTransport* GetTransport_w(const std::string& transport_name) { | 506 FakeTransport* GetTransport_n(const std::string& transport_name) { |
507 return static_cast<FakeTransport*>( | 507 return static_cast<FakeTransport*>( |
508 TransportController::GetTransport_w(transport_name)); | 508 TransportController::GetTransport_n(transport_name)); |
509 } | 509 } |
510 | 510 |
511 void Connect(FakeTransportController* dest) { | 511 void Connect(FakeTransportController* dest) { |
512 worker_thread()->Invoke<void>( | 512 network_thread()->Invoke<void>( |
513 rtc::Bind(&FakeTransportController::Connect_w, this, dest)); | 513 rtc::Bind(&FakeTransportController::Connect_n, this, dest)); |
514 } | 514 } |
515 | 515 |
516 TransportChannel* CreateTransportChannel_w(const std::string& transport_name, | 516 TransportChannel* CreateTransportChannel_n(const std::string& transport_name, |
517 int component) override { | 517 int component) override { |
518 if (fail_create_channel_) { | 518 if (fail_create_channel_) { |
519 return nullptr; | 519 return nullptr; |
520 } | 520 } |
521 return TransportController::CreateTransportChannel_w(transport_name, | 521 return TransportController::CreateTransportChannel_n(transport_name, |
522 component); | 522 component); |
523 } | 523 } |
524 | 524 |
525 FakeCandidatePair* CreateFakeCandidatePair( | 525 FakeCandidatePair* CreateFakeCandidatePair( |
526 const rtc::SocketAddress& local_address, | 526 const rtc::SocketAddress& local_address, |
527 int16_t local_network_id, | 527 int16_t local_network_id, |
528 const rtc::SocketAddress& remote_address, | 528 const rtc::SocketAddress& remote_address, |
529 int16_t remote_network_id) { | 529 int16_t remote_network_id) { |
530 Candidate local_candidate(0, "udp", local_address, 0u, "", "", "local", 0, | 530 Candidate local_candidate(0, "udp", local_address, 0u, "", "", "local", 0, |
531 "foundation", local_network_id, 0); | 531 "foundation", local_network_id, 0); |
532 Candidate remote_candidate(0, "udp", remote_address, 0u, "", "", "local", 0, | 532 Candidate remote_candidate(0, "udp", remote_address, 0u, "", "", "local", 0, |
533 "foundation", remote_network_id, 0); | 533 "foundation", remote_network_id, 0); |
534 return new FakeCandidatePair(local_candidate, remote_candidate); | 534 return new FakeCandidatePair(local_candidate, remote_candidate); |
535 } | 535 } |
536 | 536 |
537 void set_fail_channel_creation(bool fail_channel_creation) { | 537 void set_fail_channel_creation(bool fail_channel_creation) { |
538 fail_create_channel_ = fail_channel_creation; | 538 fail_create_channel_ = fail_channel_creation; |
539 } | 539 } |
540 | 540 |
541 protected: | 541 protected: |
542 Transport* CreateTransport_w(const std::string& transport_name) override { | 542 Transport* CreateTransport_n(const std::string& transport_name) override { |
543 return new FakeTransport(transport_name); | 543 return new FakeTransport(transport_name); |
544 } | 544 } |
545 | 545 |
546 void Connect_w(FakeTransportController* dest) { | 546 void Connect_n(FakeTransportController* dest) { |
547 // Simulate the exchange of candidates. | 547 // Simulate the exchange of candidates. |
548 ConnectChannels_w(); | 548 ConnectChannels_n(); |
549 dest->ConnectChannels_w(); | 549 dest->ConnectChannels_n(); |
550 for (auto& kv : transports()) { | 550 for (auto& kv : transports()) { |
551 FakeTransport* transport = static_cast<FakeTransport*>(kv.second); | 551 FakeTransport* transport = static_cast<FakeTransport*>(kv.second); |
552 transport->SetDestination(dest->GetTransport_w(kv.first)); | 552 transport->SetDestination(dest->GetTransport_n(kv.first)); |
553 } | 553 } |
554 } | 554 } |
555 | 555 |
556 void ConnectChannels_w() { | 556 void ConnectChannels_n() { |
557 TransportDescription faketransport_desc( | 557 TransportDescription faketransport_desc( |
558 std::vector<std::string>(), | 558 std::vector<std::string>(), |
559 rtc::CreateRandomString(cricket::ICE_UFRAG_LENGTH), | 559 rtc::CreateRandomString(cricket::ICE_UFRAG_LENGTH), |
560 rtc::CreateRandomString(cricket::ICE_PWD_LENGTH), cricket::ICEMODE_FULL, | 560 rtc::CreateRandomString(cricket::ICE_PWD_LENGTH), cricket::ICEMODE_FULL, |
561 cricket::CONNECTIONROLE_NONE, nullptr); | 561 cricket::CONNECTIONROLE_NONE, nullptr); |
562 for (auto& kv : transports()) { | 562 for (auto& kv : transports()) { |
563 FakeTransport* transport = static_cast<FakeTransport*>(kv.second); | 563 FakeTransport* transport = static_cast<FakeTransport*>(kv.second); |
564 // Set local transport description for FakeTransport before connecting. | 564 // Set local transport description for FakeTransport before connecting. |
565 // Otherwise, the RTC_CHECK in Transport.ConnectChannel will fail. | 565 // Otherwise, the RTC_CHECK in Transport.ConnectChannel will fail. |
566 if (!transport->local_description()) { | 566 if (!transport->local_description()) { |
567 transport->SetLocalTransportDescription(faketransport_desc, | 567 transport->SetLocalTransportDescription(faketransport_desc, |
568 cricket::CA_OFFER, nullptr); | 568 cricket::CA_OFFER, nullptr); |
569 } | 569 } |
570 transport->ConnectChannels(); | 570 transport->ConnectChannels(); |
571 transport->MaybeStartGathering(); | 571 transport->MaybeStartGathering(); |
572 } | 572 } |
573 } | 573 } |
574 | 574 |
575 private: | 575 private: |
576 bool fail_create_channel_; | 576 bool fail_create_channel_; |
577 }; | 577 }; |
578 | 578 |
579 } // namespace cricket | 579 } // namespace cricket |
580 | 580 |
581 #endif // WEBRTC_P2P_BASE_FAKETRANSPORTCONTROLLER_H_ | 581 #endif // WEBRTC_P2P_BASE_FAKETRANSPORTCONTROLLER_H_ |
OLD | NEW |