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

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

Issue 2063823008: Adding IceConfig option to assume TURN/TURN candidate pairs will work. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Rename IceConfig option and fix transition to STATE_WRITE_UNRELIABLE. Created 4 years, 6 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 160 matching lines...) Expand 10 before | Expand all | Expand 10 after
171 void set_component(int component) { component_ = component; } 171 void set_component(int component) { component_ = component; }
172 172
173 bool send_retransmit_count_attribute() const { 173 bool send_retransmit_count_attribute() const {
174 return send_retransmit_count_attribute_; 174 return send_retransmit_count_attribute_;
175 } 175 }
176 void set_send_retransmit_count_attribute(bool enable) { 176 void set_send_retransmit_count_attribute(bool enable) {
177 send_retransmit_count_attribute_ = enable; 177 send_retransmit_count_attribute_ = enable;
178 } 178 }
179 179
180 // Identifies the generation that this port was created in. 180 // Identifies the generation that this port was created in.
181 uint32_t generation() { return generation_; } 181 uint32_t generation() const { return generation_; }
182 void set_generation(uint32_t generation) { generation_ = generation; } 182 void set_generation(uint32_t generation) { generation_ = generation; }
183 183
184 const std::string username_fragment() const; 184 const std::string username_fragment() const;
185 const std::string& password() const { return password_; } 185 const std::string& password() const { return password_; }
186 186
187 // May be called when this port was initially created by a pooled 187 // May be called when this port was initially created by a pooled
188 // PortAllocatorSession, and is now being assigned to an ICE transport. 188 // PortAllocatorSession, and is now being assigned to an ICE transport.
189 // Updates the information for candidates as well. 189 // Updates the information for candidates as well.
190 void SetIceParameters(int component, 190 void SetIceParameters(int component,
191 const std::string& username_fragment, 191 const std::string& username_fragment,
(...skipping 236 matching lines...) Expand 10 before | Expand all | Expand 10 after
428 STATE_FAILED // Check for this connection failed. 428 STATE_FAILED // Check for this connection failed.
429 }; 429 };
430 430
431 virtual ~Connection(); 431 virtual ~Connection();
432 432
433 // The local port where this connection sends and receives packets. 433 // The local port where this connection sends and receives packets.
434 Port* port() { return port_; } 434 Port* port() { return port_; }
435 const Port* port() const { return port_; } 435 const Port* port() const { return port_; }
436 436
437 // Implementation of virtual methods in CandidatePairInterface. 437 // Implementation of virtual methods in CandidatePairInterface.
438 // Returns the description of the local port 438 // Returns the description of the local port.
439 virtual const Candidate& local_candidate() const; 439 virtual const Candidate& local_candidate() const;
440 // Returns the description of the remote port to which we communicate. 440 // Returns the description of the remote port to which we communicate.
441 virtual const Candidate& remote_candidate() const; 441 virtual const Candidate& remote_candidate() const;
442 442
443 // Returns the pair priority. 443 // Returns the pair priority.
444 uint64_t priority() const; 444 uint64_t priority() const;
445 445
446 enum WriteState { 446 enum WriteState {
447 STATE_WRITABLE = 0, // we have received ping responses recently 447 STATE_WRITABLE = 0, // We have received ping responses recently.
448 STATE_WRITE_UNRELIABLE = 1, // we have had a few ping failures 448 STATE_PRESUMED_WRITABLE = 1, // We haven't received a ping response, but
449 STATE_WRITE_INIT = 2, // we have yet to receive a ping response 449 // we presume we're writable, because we're a
450 STATE_WRITE_TIMEOUT = 3, // we have had a large number of ping failures 450 // TURN-TURN connection and CreatePermission
451 // isn't required.
452 STATE_WRITE_UNRELIABLE = 2, // We have had a few ping failures.
453 STATE_WRITE_INIT = 3, // We have yet to receive a ping response.
454 STATE_WRITE_TIMEOUT = 4, // We have had a large number of ping failures.
451 }; 455 };
452 456
453 WriteState write_state() const { return write_state_; } 457 WriteState write_state() const { return write_state_; }
454 bool writable() const { return write_state_ == STATE_WRITABLE; } 458 bool writable() const { return write_state_ == STATE_WRITABLE; }
459 bool presumed_writable() const {
460 return write_state_ == STATE_WRITABLE ||
461 write_state_ == STATE_PRESUMED_WRITABLE;
462 }
455 bool receiving() const { return receiving_; } 463 bool receiving() const { return receiving_; }
456 464
457 // Determines whether the connection has finished connecting. This can only 465 // Determines whether the connection has finished connecting. This can only
458 // be false for TCP connections. 466 // be false for TCP connections.
459 bool connected() const { return connected_; } 467 bool connected() const { return connected_; }
460 bool weak() const { return !(writable() && receiving() && connected()); } 468 bool weak() const { return !(writable() && receiving() && connected()); }
461 bool active() const { 469 bool active() const {
462 return write_state_ != STATE_WRITE_TIMEOUT; 470 return write_state_ != STATE_WRITE_TIMEOUT;
463 } 471 }
464 // A connection is dead if it can be safely deleted. 472 // A connection is dead if it can be safely deleted.
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after
582 void MaybeUpdatePeerReflexiveCandidate(const Candidate& new_candidate); 590 void MaybeUpdatePeerReflexiveCandidate(const Candidate& new_candidate);
583 591
584 // Returns the last received time of any data, stun request, or stun 592 // Returns the last received time of any data, stun request, or stun
585 // response in milliseconds 593 // response in milliseconds
586 int64_t last_received() const; 594 int64_t last_received() const;
587 595
588 protected: 596 protected:
589 enum { MSG_DELETE = 0, MSG_FIRST_AVAILABLE }; 597 enum { MSG_DELETE = 0, MSG_FIRST_AVAILABLE };
590 598
591 // Constructs a new connection to the given remote port. 599 // Constructs a new connection to the given remote port.
592 Connection(Port* port, size_t index, const Candidate& candidate); 600 Connection(Port* port,
601 size_t index,
602 const Candidate& candidate,
603 const IceConfig& config);
593 604
594 // Called back when StunRequestManager has a stun packet to send 605 // Called back when StunRequestManager has a stun packet to send
595 void OnSendStunPacket(const void* data, size_t size, StunRequest* req); 606 void OnSendStunPacket(const void* data, size_t size, StunRequest* req);
596 607
597 // Callbacks from ConnectionRequest 608 // Callbacks from ConnectionRequest
598 virtual void OnConnectionRequestResponse(ConnectionRequest* req, 609 virtual void OnConnectionRequestResponse(ConnectionRequest* req,
599 StunMessage* response); 610 StunMessage* response);
600 void OnConnectionRequestErrorResponse(ConnectionRequest* req, 611 void OnConnectionRequestErrorResponse(ConnectionRequest* req,
601 StunMessage* response); 612 StunMessage* response);
602 void OnConnectionRequestTimeout(ConnectionRequest* req); 613 void OnConnectionRequestTimeout(ConnectionRequest* req);
603 void OnConnectionRequestSent(ConnectionRequest* req); 614 void OnConnectionRequestSent(ConnectionRequest* req);
604 615
616 // May be STATE_WRITE_INIT or STATE_PRESUMED_WRITABLE depending on ICE
617 // config and candidate types.
618 WriteState InitialWriteState() const;
619
605 // Changes the state and signals if necessary. 620 // Changes the state and signals if necessary.
606 void set_write_state(WriteState value); 621 void set_write_state(WriteState value);
607 void set_receiving(bool value); 622 void set_receiving(bool value);
608 void set_state(State state); 623 void set_state(State state);
609 void set_connected(bool value); 624 void set_connected(bool value);
610 625
611 void OnMessage(rtc::Message *pmsg); 626 void OnMessage(rtc::Message *pmsg);
612 627
613 Port* port_; 628 Port* port_;
614 size_t local_candidate_index_; 629 size_t local_candidate_index_;
(...skipping 28 matching lines...) Expand all
643 private: 658 private:
644 void MaybeAddPrflxCandidate(ConnectionRequest* request, 659 void MaybeAddPrflxCandidate(ConnectionRequest* request,
645 StunMessage* response); 660 StunMessage* response);
646 661
647 bool reported_; 662 bool reported_;
648 State state_; 663 State state_;
649 // Time duration to switch from receiving to not receiving. 664 // Time duration to switch from receiving to not receiving.
650 int receiving_timeout_; 665 int receiving_timeout_;
651 int64_t time_created_ms_; 666 int64_t time_created_ms_;
652 int num_pings_sent_ = 0; 667 int num_pings_sent_ = 0;
668 bool presume_writable_when_fully_relayed_;
653 669
654 friend class Port; 670 friend class Port;
655 friend class ConnectionRequest; 671 friend class ConnectionRequest;
656 }; 672 };
657 673
658 // ProxyConnection defers all the interesting work to the port. 674 // ProxyConnection defers all the interesting work to the port.
659 class ProxyConnection : public Connection { 675 class ProxyConnection : public Connection {
660 public: 676 public:
661 ProxyConnection(Port* port, size_t index, const Candidate& remote_candidate); 677 ProxyConnection(Port* port,
678 size_t index,
679 const Candidate& remote_candidate,
680 const IceConfig& config);
662 681
663 int Send(const void* data, 682 int Send(const void* data,
664 size_t size, 683 size_t size,
665 const rtc::PacketOptions& options) override; 684 const rtc::PacketOptions& options) override;
666 int GetError() override { return error_; } 685 int GetError() override { return error_; }
667 686
668 private: 687 private:
669 int error_ = 0; 688 int error_ = 0;
670 }; 689 };
671 690
672 } // namespace cricket 691 } // namespace cricket
673 692
674 #endif // WEBRTC_P2P_BASE_PORT_H_ 693 #endif // WEBRTC_P2P_BASE_PORT_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698