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

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

Issue 2597423003: RTCIceCandidatePairStats.[state/priority] added, ConnectionInfo updated. (Closed)
Patch Set: Created 3 years, 12 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 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
85 ICE_TYPE_PREFERENCE_RELAY_TLS = 0, 85 ICE_TYPE_PREFERENCE_RELAY_TLS = 0,
86 ICE_TYPE_PREFERENCE_RELAY_TCP = 1, 86 ICE_TYPE_PREFERENCE_RELAY_TCP = 1,
87 ICE_TYPE_PREFERENCE_RELAY_UDP = 2, 87 ICE_TYPE_PREFERENCE_RELAY_UDP = 2,
88 ICE_TYPE_PREFERENCE_PRFLX_TCP = 80, 88 ICE_TYPE_PREFERENCE_PRFLX_TCP = 80,
89 ICE_TYPE_PREFERENCE_HOST_TCP = 90, 89 ICE_TYPE_PREFERENCE_HOST_TCP = 90,
90 ICE_TYPE_PREFERENCE_SRFLX = 100, 90 ICE_TYPE_PREFERENCE_SRFLX = 100,
91 ICE_TYPE_PREFERENCE_PRFLX = 110, 91 ICE_TYPE_PREFERENCE_PRFLX = 110,
92 ICE_TYPE_PREFERENCE_HOST = 126 92 ICE_TYPE_PREFERENCE_HOST = 126
93 }; 93 };
94 94
95 // States are from RFC 5245. http://tools.ietf.org/html/rfc5245#section-5.7.4
96 enum class IceCandidatePairState {
97 // TODO(hbos): Add and support the |FROZEN| state.
Taylor Brandstetter 2016/12/23 18:59:45 For now, nothing is ever frozen, FYI. The Earth ma
hbos 2016/12/27 10:24:34 Ack. Updated the comment and removed the "TODO" bi
98 WAITING = 0, // Check has not been performed, Waiting pair on CL.
99 IN_PROGRESS, // Check has been sent, transaction is in progress.
100 SUCCEEDED, // Check already done, produced a successful result.
101 FAILED, // Check for this connection failed.
102 };
103
95 const char* ProtoToString(ProtocolType proto); 104 const char* ProtoToString(ProtocolType proto);
96 bool StringToProto(const char* value, ProtocolType* proto); 105 bool StringToProto(const char* value, ProtocolType* proto);
97 106
98 struct ProtocolAddress { 107 struct ProtocolAddress {
99 rtc::SocketAddress address; 108 rtc::SocketAddress address;
100 ProtocolType proto; 109 ProtocolType proto;
101 110
102 ProtocolAddress(const rtc::SocketAddress& a, ProtocolType p) 111 ProtocolAddress(const rtc::SocketAddress& a, ProtocolType p)
103 : address(a), proto(p) {} 112 : address(a), proto(p) {}
104 113
(...skipping 307 matching lines...) Expand 10 before | Expand all | Expand 10 after
412 public: 421 public:
413 struct SentPing { 422 struct SentPing {
414 SentPing(const std::string id, int64_t sent_time, uint32_t nomination) 423 SentPing(const std::string id, int64_t sent_time, uint32_t nomination)
415 : id(id), sent_time(sent_time), nomination(nomination) {} 424 : id(id), sent_time(sent_time), nomination(nomination) {}
416 425
417 std::string id; 426 std::string id;
418 int64_t sent_time; 427 int64_t sent_time;
419 uint32_t nomination; 428 uint32_t nomination;
420 }; 429 };
421 430
422 // States are from RFC 5245. http://tools.ietf.org/html/rfc5245#section-5.7.4
423 enum State {
424 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_SUCCEEDED, // Check already done, produced a successful result.
427 STATE_FAILED // Check for this connection failed.
428 };
429
430 virtual ~Connection(); 431 virtual ~Connection();
431 432
432 // The local port where this connection sends and receives packets. 433 // The local port where this connection sends and receives packets.
433 Port* port() { return port_; } 434 Port* port() { return port_; }
434 const Port* port() const { return port_; } 435 const Port* port() const { return port_; }
435 436
436 // Implementation of virtual methods in CandidatePairInterface. 437 // Implementation of virtual methods in CandidatePairInterface.
437 // Returns the description of the local port 438 // Returns the description of the local port
438 virtual const Candidate& local_candidate() const; 439 virtual const Candidate& local_candidate() const;
439 // Returns the description of the remote port to which we communicate. 440 // Returns the description of the remote port to which we communicate.
(...skipping 20 matching lines...) Expand all
460 bool active() const { 461 bool active() const {
461 return write_state_ != STATE_WRITE_TIMEOUT; 462 return write_state_ != STATE_WRITE_TIMEOUT;
462 } 463 }
463 464
464 // A connection is dead if it can be safely deleted. 465 // A connection is dead if it can be safely deleted.
465 bool dead(int64_t now) const; 466 bool dead(int64_t now) const;
466 467
467 // Estimate of the round-trip time over this connection. 468 // Estimate of the round-trip time over this connection.
468 int rtt() const { return rtt_; } 469 int rtt() const { return rtt_; }
469 470
470 ConnectionInfo stats(); 471 ConnectionInfo stats(bool is_best_connection = false);
471 472
472 sigslot::signal1<Connection*> SignalStateChange; 473 sigslot::signal1<Connection*> SignalStateChange;
473 474
474 // Sent when the connection has decided that it is no longer of value. It 475 // Sent when the connection has decided that it is no longer of value. It
475 // will delete itself immediately after this call. 476 // will delete itself immediately after this call.
476 sigslot::signal1<Connection*> SignalDestroyed; 477 sigslot::signal1<Connection*> SignalDestroyed;
477 478
478 // The connection can send and receive packets asynchronously. This matches 479 // The connection can send and receive packets asynchronously. This matches
479 // the interface of AsyncPacketSocket, which may use UDP or TCP under the 480 // the interface of AsyncPacketSocket, which may use UDP or TCP under the
480 // covers. 481 // covers.
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after
568 bool reported() const { return reported_; } 569 bool reported() const { return reported_; }
569 void set_reported(bool reported) { reported_ = reported;} 570 void set_reported(bool reported) { reported_ = reported;}
570 571
571 // This signal will be fired if this connection is nominated by the 572 // This signal will be fired if this connection is nominated by the
572 // controlling side. 573 // controlling side.
573 sigslot::signal1<Connection*> SignalNominated; 574 sigslot::signal1<Connection*> SignalNominated;
574 575
575 // Invoked when Connection receives STUN error response with 487 code. 576 // Invoked when Connection receives STUN error response with 487 code.
576 void HandleRoleConflictFromPeer(); 577 void HandleRoleConflictFromPeer();
577 578
578 State state() const { return state_; } 579 IceCandidatePairState state() const { return state_; }
579 580
580 int num_pings_sent() const { return num_pings_sent_; } 581 int num_pings_sent() const { return num_pings_sent_; }
581 582
582 IceMode remote_ice_mode() const { return remote_ice_mode_; } 583 IceMode remote_ice_mode() const { return remote_ice_mode_; }
583 584
584 uint32_t ComputeNetworkCost() const; 585 uint32_t ComputeNetworkCost() const;
585 586
586 // Update the ICE password and/or generation of the remote candidate if the 587 // Update the ICE password and/or generation of the remote candidate if the
587 // ufrag in |params| matches the candidate's ufrag, and the 588 // ufrag in |params| matches the candidate's ufrag, and the
588 // candidate's password and/or ufrag has not been set. 589 // candidate's password and/or ufrag has not been set.
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
623 624
624 bool rtt_converged() const; 625 bool rtt_converged() const;
625 626
626 // If the response is not received within 2 * RTT, the response is assumed to 627 // If the response is not received within 2 * RTT, the response is assumed to
627 // be missing. 628 // be missing.
628 bool missing_responses(int64_t now) const; 629 bool missing_responses(int64_t now) const;
629 630
630 // Changes the state and signals if necessary. 631 // Changes the state and signals if necessary.
631 void set_write_state(WriteState value); 632 void set_write_state(WriteState value);
632 void UpdateReceiving(int64_t now); 633 void UpdateReceiving(int64_t now);
633 void set_state(State state); 634 void set_state(IceCandidatePairState state);
634 void set_connected(bool value); 635 void set_connected(bool value);
635 636
636 uint32_t nomination() const { return nomination_; } 637 uint32_t nomination() const { return nomination_; }
637 638
638 void OnMessage(rtc::Message *pmsg); 639 void OnMessage(rtc::Message *pmsg);
639 640
640 Port* port_; 641 Port* port_;
641 size_t local_candidate_index_; 642 size_t local_candidate_index_;
642 Candidate remote_candidate_; 643 Candidate remote_candidate_;
643 644
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
679 int rtt_samples_ = 0; 680 int rtt_samples_ = 0;
680 int64_t last_ping_sent_; // last time we sent a ping to the other side 681 int64_t last_ping_sent_; // last time we sent a ping to the other side
681 int64_t last_ping_received_; // last time we received a ping from the other 682 int64_t last_ping_received_; // last time we received a ping from the other
682 // side 683 // side
683 int64_t last_data_received_; 684 int64_t last_data_received_;
684 int64_t last_ping_response_received_; 685 int64_t last_ping_response_received_;
685 int64_t receiving_unchanged_since_ = 0; 686 int64_t receiving_unchanged_since_ = 0;
686 std::vector<SentPing> pings_since_last_response_; 687 std::vector<SentPing> pings_since_last_response_;
687 688
688 bool reported_; 689 bool reported_;
689 State state_; 690 IceCandidatePairState state_;
690 // Time duration to switch from receiving to not receiving. 691 // Time duration to switch from receiving to not receiving.
691 int receiving_timeout_; 692 int receiving_timeout_;
692 int64_t time_created_ms_; 693 int64_t time_created_ms_;
693 int num_pings_sent_ = 0; 694 int num_pings_sent_ = 0;
694 695
695 friend class Port; 696 friend class Port;
696 friend class ConnectionRequest; 697 friend class ConnectionRequest;
697 }; 698 };
698 699
699 // ProxyConnection defers all the interesting work to the port. 700 // ProxyConnection defers all the interesting work to the port.
700 class ProxyConnection : public Connection { 701 class ProxyConnection : public Connection {
701 public: 702 public:
702 ProxyConnection(Port* port, size_t index, const Candidate& remote_candidate); 703 ProxyConnection(Port* port, size_t index, const Candidate& remote_candidate);
703 704
704 int Send(const void* data, 705 int Send(const void* data,
705 size_t size, 706 size_t size,
706 const rtc::PacketOptions& options) override; 707 const rtc::PacketOptions& options) override;
707 int GetError() override { return error_; } 708 int GetError() override { return error_; }
708 709
709 private: 710 private:
710 int error_ = 0; 711 int error_ = 0;
711 }; 712 };
712 713
713 } // namespace cricket 714 } // namespace cricket
714 715
715 #endif // WEBRTC_P2P_BASE_PORT_H_ 716 #endif // WEBRTC_P2P_BASE_PORT_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698