Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(816)

Side by Side Diff: webrtc/p2p/base/port.h

Issue 2163403002: Prepare for ICE-renomination (Closed) Base URL: https://chromium.googlesource.com/external/webrtc@master
Patch Set: . Created 4 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 394 matching lines...) Expand 10 before | Expand all | Expand 10 after
405 friend class Connection; 405 friend class Connection;
406 }; 406 };
407 407
408 // Represents a communication link between a port on the local client and a 408 // Represents a communication link between a port on the local client and a
409 // port on the remote client. 409 // port on the remote client.
410 class Connection : public CandidatePairInterface, 410 class Connection : public CandidatePairInterface,
411 public rtc::MessageHandler, 411 public rtc::MessageHandler,
412 public sigslot::has_slots<> { 412 public sigslot::has_slots<> {
413 public: 413 public:
414 struct SentPing { 414 struct SentPing {
415 SentPing(const std::string id, int64_t sent_time) 415 SentPing(const std::string id, int64_t sent_time, int nomination_value)
416 : id(id), sent_time(sent_time) {} 416 : id(id), sent_time(sent_time), nomination_value(nomination_value) {}
417 417
418 std::string id; 418 std::string id;
419 int64_t sent_time; 419 int64_t sent_time;
420 int nomination_value;
420 }; 421 };
421 422
422 // States are from RFC 5245. http://tools.ietf.org/html/rfc5245#section-5.7.4 423 // States are from RFC 5245. http://tools.ietf.org/html/rfc5245#section-5.7.4
423 enum State { 424 enum State {
424 STATE_WAITING = 0, // Check has not been performed, Waiting pair on CL. 425 STATE_WAITING = 0, // Check has not been performed, Waiting pair on CL.
425 STATE_INPROGRESS, // Check has been sent, transaction is in progress. 426 STATE_INPROGRESS, // Check has been sent, transaction is in progress.
426 STATE_SUCCEEDED, // Check already done, produced a successful result. 427 STATE_SUCCEEDED, // Check already done, produced a successful result.
427 STATE_FAILED // Check for this connection failed. 428 STATE_FAILED // Check for this connection failed.
428 }; 429 };
429 430
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
499 // Called when a connection is determined to be no longer useful to us. We 500 // Called when a connection is determined to be no longer useful to us. We
500 // still keep it around in case the other side wants to use it. But we can 501 // still keep it around in case the other side wants to use it. But we can
501 // safely stop pinging on it and we can allow it to time out if the other 502 // safely stop pinging on it and we can allow it to time out if the other
502 // side stops using it as well. 503 // side stops using it as well.
503 bool pruned() const { return pruned_; } 504 bool pruned() const { return pruned_; }
504 void Prune(); 505 void Prune();
505 506
506 bool use_candidate_attr() const { return use_candidate_attr_; } 507 bool use_candidate_attr() const { return use_candidate_attr_; }
507 void set_use_candidate_attr(bool enable); 508 void set_use_candidate_attr(bool enable);
508 509
509 bool nominated() const { return nominated_; } 510 int nominating_value() const { return nominating_value_; }
510 void set_nominated(bool nominated) { nominated_ = nominated; } 511 void set_nominating_value(int value) {
512 if (value > nominating_value_) {
513 nominating_value_ = value;
514 nomination_acknowledged_ = false;
515 }
Taylor Brandstetter 2016/07/22 17:36:01 RTC_DCHECK if value < nominating_value_? Or have t
honghaiz3 2016/07/22 22:50:11 It may set a zero-value. If we are not using the
Taylor Brandstetter 2016/07/22 23:48:29 I'm suggesting to use the return value in a DCHECK
honghaiz3 2016/07/25 22:24:41 I changed the implementation a little. Basically w
516 }
517 bool nomination_acknowledged() const { return nomination_acknowledged_; }
518
519 int nominated_value() const { return nominated_value_; }
520 void set_nominated_value(int nominated_value) {
Taylor Brandstetter 2016/07/22 17:36:01 Why is this public? Isn't it only set internally u
honghaiz3 2016/07/22 22:50:11 This is made public for testing. I am really repl
Taylor Brandstetter 2016/07/22 23:48:28 If this is public only for unit tests, can you mak
honghaiz3 2016/07/25 22:24:40 Done.
521 if (nominated_value > nominated_value_) {
522 nominated_value_ = nominated_value;
523 }
524 }
511 525
512 void set_remote_ice_mode(IceMode mode) { 526 void set_remote_ice_mode(IceMode mode) {
513 remote_ice_mode_ = mode; 527 remote_ice_mode_ = mode;
514 } 528 }
515 529
516 void set_receiving_timeout(int64_t receiving_timeout_ms) { 530 void set_receiving_timeout(int64_t receiving_timeout_ms) {
517 receiving_timeout_ = receiving_timeout_ms; 531 receiving_timeout_ = receiving_timeout_ms;
518 } 532 }
519 533
520 // Makes the connection go away. 534 // Makes the connection go away.
521 void Destroy(); 535 void Destroy();
522 536
523 // Makes the connection go away, in a failed state. 537 // Makes the connection go away, in a failed state.
524 void FailAndDestroy(); 538 void FailAndDestroy();
525 539
526 // Prunes the connection and sets its state to STATE_FAILED, 540 // Prunes the connection and sets its state to STATE_FAILED,
527 // It will not be used or send pings although it can still receive packets. 541 // It will not be used or send pings although it can still receive packets.
528 void FailAndPrune(); 542 void FailAndPrune();
529 543
530 // Checks that the state of this connection is up-to-date. The argument is 544 // Checks that the state of this connection is up-to-date. The argument is
531 // the current time, which is compared against various timeouts. 545 // the current time, which is compared against various timeouts.
532 void UpdateState(int64_t now); 546 void UpdateState(int64_t now);
533 547
534 // Called when this connection should try checking writability again. 548 // Called when this connection should try checking writability again.
535 int64_t last_ping_sent() const { return last_ping_sent_; } 549 int64_t last_ping_sent() const { return last_ping_sent_; }
536 void Ping(int64_t now); 550 void Ping(int64_t now);
537 void ReceivedPingResponse(int rtt); 551 void ReceivedPingResponse(int rtt, const std::string& request_id);
538 int64_t last_ping_response_received() const { 552 int64_t last_ping_response_received() const {
539 return last_ping_response_received_; 553 return last_ping_response_received_;
540 } 554 }
541 555
542 // Called whenever a valid ping is received on this connection. This is 556 // Called whenever a valid ping is received on this connection. This is
543 // public because the connection intercepts the first ping for us. 557 // public because the connection intercepts the first ping for us.
544 int64_t last_ping_received() const { return last_ping_received_; } 558 int64_t last_ping_received() const { return last_ping_received_; }
545 void ReceivedPing(); 559 void ReceivedPing();
546 // Handles the binding request; sends a response if this is a valid request. 560 // Handles the binding request; sends a response if this is a valid request.
547 void HandleBindingRequest(IceMessage* msg); 561 void HandleBindingRequest(IceMessage* msg);
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after
633 Candidate remote_candidate_; 647 Candidate remote_candidate_;
634 WriteState write_state_; 648 WriteState write_state_;
635 bool receiving_; 649 bool receiving_;
636 bool connected_; 650 bool connected_;
637 bool pruned_; 651 bool pruned_;
638 // By default |use_candidate_attr_| flag will be true, 652 // By default |use_candidate_attr_| flag will be true,
639 // as we will be using aggressive nomination. 653 // as we will be using aggressive nomination.
640 // But when peer is ice-lite, this flag "must" be initialized to false and 654 // But when peer is ice-lite, this flag "must" be initialized to false and
641 // turn on when connection becomes "best connection". 655 // turn on when connection becomes "best connection".
642 bool use_candidate_attr_; 656 bool use_candidate_attr_;
643 // Whether this connection has been nominated by the controlling side via 657 // Used by the controlling side to indicate that this connection will be
644 // the use_candidate attribute. 658 // selected for transmission if the peer supports ICE-renomination if this
645 bool nominated_; 659 // value is positive. A larger-value indicates that a connection is nominated
660 // later and should be selected by the controlled side with higher precedence.
661 // It should start from zero to indicate not nominating this connection yet.
662 int nominating_value_ = 0;
663 // Whether the current nominating_value has been acknowledged by the peer.
664 // If yes, no nomination-value attribute is needed in the ping request on the
665 // same connection.
666 bool nomination_acknowledged_;
667 // Used by the controlled side to remember the nomination value received from
668 // the controlling side. When the peer does not support ICE re-nomination,
669 // its value will be 1 if the connection is nominated.
670 int nominated_value_ = 0;
671
646 IceMode remote_ice_mode_; 672 IceMode remote_ice_mode_;
647 StunRequestManager requests_; 673 StunRequestManager requests_;
648 int rtt_; 674 int rtt_;
649 int rtt_samples_ = 0; 675 int rtt_samples_ = 0;
650 int64_t last_ping_sent_; // last time we sent a ping to the other side 676 int64_t last_ping_sent_; // last time we sent a ping to the other side
651 int64_t last_ping_received_; // last time we received a ping from the other 677 int64_t last_ping_received_; // last time we received a ping from the other
652 // side 678 // side
653 int64_t last_data_received_; 679 int64_t last_data_received_;
654 int64_t last_ping_response_received_; 680 int64_t last_ping_response_received_;
655 int64_t receiving_unchanged_since_ = 0; 681 int64_t receiving_unchanged_since_ = 0;
(...skipping 29 matching lines...) Expand all
685 const rtc::PacketOptions& options) override; 711 const rtc::PacketOptions& options) override;
686 int GetError() override { return error_; } 712 int GetError() override { return error_; }
687 713
688 private: 714 private:
689 int error_ = 0; 715 int error_ = 0;
690 }; 716 };
691 717
692 } // namespace cricket 718 } // namespace cricket
693 719
694 #endif // WEBRTC_P2P_BASE_PORT_H_ 720 #endif // WEBRTC_P2P_BASE_PORT_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698