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

Unified Diff: webrtc/p2p/base/p2ptransportchannel.cc

Issue 1207563002: Add flakiness check if there is no received packets in a certain period. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc@master
Patch Set: Address more comments Created 5 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « webrtc/p2p/base/p2ptransportchannel.h ('k') | webrtc/p2p/base/p2ptransportchannel_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: webrtc/p2p/base/p2ptransportchannel.cc
diff --git a/webrtc/p2p/base/p2ptransportchannel.cc b/webrtc/p2p/base/p2ptransportchannel.cc
index 83bcf840ee4350e39ad550738e676d1641f5dabd..1484d17158545bb90fd6e0cee82fda43c5ed7ad2 100644
--- a/webrtc/p2p/base/p2ptransportchannel.cc
+++ b/webrtc/p2p/base/p2ptransportchannel.cc
@@ -25,6 +25,7 @@ namespace {
enum {
MSG_SORT = 1,
MSG_PING,
+ MSG_CHECK_RECEIVING
};
// When the socket is unwritable, we will use 10 Kbps (ignoring IP+UDP headers)
@@ -40,6 +41,8 @@ static const uint32 UNWRITABLE_DELAY = 1000 * PING_PACKET_SIZE / 10000; // 50ms
// make sure it is pinged at this rate.
static const uint32 MAX_CURRENT_WRITABLE_DELAY = 900; // 2*WRITABLE_DELAY - bit
+static const int MIN_CHECK_RECEIVING_DELAY = 50; // ms
+
// The minimum improvement in RTT that justifies a switch.
static const double kMinImprovement = 10;
@@ -193,7 +196,9 @@ P2PTransportChannel::P2PTransportChannel(const std::string& content_name,
remote_ice_mode_(ICEMODE_FULL),
ice_role_(ICEROLE_UNKNOWN),
tiebreaker_(0),
- remote_candidate_generation_(0) {
+ remote_candidate_generation_(0),
+ check_receiving_delay_(MIN_CHECK_RECEIVING_DELAY * 5),
+ receiving_timeout_(MIN_CHECK_RECEIVING_DELAY * 50) {
}
P2PTransportChannel::~P2PTransportChannel() {
@@ -354,6 +359,12 @@ void P2PTransportChannel::SetRemoteIceMode(IceMode mode) {
remote_ice_mode_ = mode;
}
+void P2PTransportChannel::set_receiving_timeout(int receiving_timeout_ms) {
+ receiving_timeout_ = receiving_timeout_ms;
+ check_receiving_delay_ =
+ std::max(MIN_CHECK_RECEIVING_DELAY, receiving_timeout_ / 10);
+}
+
// Go into the state of processing candidates, and running in general
void P2PTransportChannel::Connect() {
ASSERT(worker_thread_ == rtc::Thread::Current());
@@ -369,6 +380,9 @@ void P2PTransportChannel::Connect() {
// Start pinging as the ports come in.
thread()->Post(this, MSG_PING);
+
+ thread()->PostDelayed(
+ check_receiving_delay_, this, MSG_CHECK_RECEIVING);
}
// A new port is available, attempt to make connections for it
@@ -1067,6 +1081,8 @@ void P2PTransportChannel::SwitchBestConnectionTo(Connection* conn) {
LOG_J(LS_INFO, this) << "New best connection: "
<< best_connection_->ToString();
SignalRouteChange(this, best_connection_->remote_candidate());
+ // When it just switched to a best connection, set receiving to true.
+ set_receiving(true);
} else {
LOG_J(LS_INFO, this) << "No best connection";
}
@@ -1148,6 +1164,9 @@ void P2PTransportChannel::OnMessage(rtc::Message *pmsg) {
case MSG_PING:
OnPing();
break;
+ case MSG_CHECK_RECEIVING:
+ OnCheckReceiving();
+ break;
default:
ASSERT(false);
break;
@@ -1176,6 +1195,19 @@ void P2PTransportChannel::OnPing() {
thread()->PostDelayed(delay, this, MSG_PING);
}
+void P2PTransportChannel::OnCheckReceiving() {
+ // Check receiving only if the best connection has received data packets
+ // because we want to detect not receiving any packets only after the media
+ // have started flowing.
+ if (best_connection_ && best_connection_->recv_total_bytes() > 0) {
+ bool receiving = rtc::Time() <=
+ best_connection_->last_received() + receiving_timeout_;
+ set_receiving(receiving);
+ }
+
+ thread()->PostDelayed(check_receiving_delay_, this, MSG_CHECK_RECEIVING);
+}
+
// Is the connection in a state for us to even consider pinging the other side?
// We consider a connection pingable even if it's not connected because that's
// how a TCP connection is kicked into reconnecting on the active side.
« no previous file with comments | « webrtc/p2p/base/p2ptransportchannel.h ('k') | webrtc/p2p/base/p2ptransportchannel_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698