aboutsummaryrefslogtreecommitdiff
path: root/webrtc/p2p/base/port.cc
diff options
context:
space:
mode:
authorguoweis@webrtc.org <guoweis@webrtc.org>2014-12-15 23:03:10 +0000
committerguoweis@webrtc.org <guoweis@webrtc.org>2014-12-15 23:03:10 +0000
commitaaf02cc2d4f696345ce0e6d5715f2cfa22aea689 (patch)
treed630cc9bd5d2d751a398d6cf8d4a119bb6ee1abc /webrtc/p2p/base/port.cc
parent0b1534c52eab79372557a6d81aaf4dd9407f55d3 (diff)
downloadwebrtc-aaf02cc2d4f696345ce0e6d5715f2cfa22aea689.tar.gz
Add adapter_type into Candidate object.
Expose adapter_type from Candidate such that we could add jmidata on top of this. Created a new type of report just for Ice candidate. The candidate's id is used as part of report identifier. This code change only reports the best connection's local candidate's adapter type. There should be cleaning later to move other candidate's attributes to the new report. This is migrated from issue 32599004 BUG= R=juberti@webrtc.org Committed: https://code.google.com/p/webrtc/source/detail?r=7885 Review URL: https://webrtc-codereview.appspot.com/36379004 git-svn-id: http://webrtc.googlecode.com/svn/trunk@7906 4adac7df-926f-26a2-2b94-8c16560cd09d
Diffstat (limited to 'webrtc/p2p/base/port.cc')
-rw-r--r--webrtc/p2p/base/port.cc27
1 files changed, 27 insertions, 0 deletions
diff --git a/webrtc/p2p/base/port.cc b/webrtc/p2p/base/port.cc
index 59344547d6..ad193c8ec4 100644
--- a/webrtc/p2p/base/port.cc
+++ b/webrtc/p2p/base/port.cc
@@ -26,6 +26,14 @@
namespace {
+// The following is the enum RTCStatsIceCandidateType from
+// http://w3c.github.io/webrtc-stats/#rtcstatsicecandidatetype-enum such that
+// our stats report for ice candidate type could conform to that.
+const char STATSREPORT_LOCAL_PORT_TYPE[] = "host";
+const char STATSREPORT_STUN_PORT_TYPE[] = "serverreflexive";
+const char STATSREPORT_PRFLX_PORT_TYPE[] = "peerreflexive";
+const char STATSREPORT_RELAY_PORT_TYPE[] = "relayed";
+
// Determines whether we have seen at least the given maximum number of
// pings fail to have a response.
inline bool TooManyFailures(
@@ -131,6 +139,23 @@ bool StringToProto(const char* value, ProtocolType* proto) {
return false;
}
+const char* IceCandidateTypeToStatsType(const std::string& candidate_type) {
+ if (candidate_type == LOCAL_PORT_TYPE) {
+ return STATSREPORT_LOCAL_PORT_TYPE;
+ }
+ if (candidate_type == STUN_PORT_TYPE) {
+ return STATSREPORT_STUN_PORT_TYPE;
+ }
+ if (candidate_type == PRFLX_PORT_TYPE) {
+ return STATSREPORT_PRFLX_PORT_TYPE;
+ }
+ if (candidate_type == RELAY_PORT_TYPE) {
+ return STATSREPORT_RELAY_PORT_TYPE;
+ }
+ ASSERT(false);
+ return "unknown";
+}
+
// RFC 6544, TCP candidate encoding rules.
const int DISCARD_PORT = 9;
const char TCPTYPE_ACTIVE_STR[] = "active";
@@ -270,6 +295,7 @@ void Port::AddAddress(const rtc::SocketAddress& address,
c.set_username(username_fragment());
c.set_password(password_);
c.set_network_name(network_->name());
+ c.set_network_type(network_->type());
c.set_generation(generation_);
c.set_related_address(related_address);
c.set_foundation(ComputeFoundation(type, protocol, base_address));
@@ -1430,6 +1456,7 @@ void Connection::MaybeAddPrflxCandidate(ConnectionRequest* request,
new_local_candidate.set_username(local_candidate().username());
new_local_candidate.set_password(local_candidate().password());
new_local_candidate.set_network_name(local_candidate().network_name());
+ new_local_candidate.set_network_type(local_candidate().network_type());
new_local_candidate.set_related_address(local_candidate().address());
new_local_candidate.set_foundation(
ComputeFoundation(PRFLX_PORT_TYPE, local_candidate().protocol(),