aboutsummaryrefslogtreecommitdiff
path: root/talk
diff options
context:
space:
mode:
authorhonghaiz <honghaiz@webrtc.org>2015-12-16 18:37:23 -0800
committerCommit bot <commit-bot@chromium.org>2015-12-17 02:37:27 +0000
commita54a0801121e05f797e514731cc5c9bad2f5e597 (patch)
treef21c59483ce1609f7daff9c4f9917054b7f0c200 /talk
parent3514cbe554cf510042395a2de35ad3fead670a06 (diff)
downloadwebrtc-a54a0801121e05f797e514731cc5c9bad2f5e597.tar.gz
Add ufrag to the ICE candidate signaling.
On the receiving side, if a candidate arrives with an old ufrag, it will be dropped. If it contains a new frag that has never seen before, it will hold the ufrag and create connections, although those connections are not pingable until the ICE credentials are received. This could avoid a bunch of ICE generation issues. BUG=webrtc:5138,webrt:5292 Review URL: https://codereview.webrtc.org/1498993002 Cr-Commit-Position: refs/heads/master@{#11060}
Diffstat (limited to 'talk')
-rw-r--r--talk/app/webrtc/webrtcsdp.cc30
-rw-r--r--talk/app/webrtc/webrtcsdp_unittest.cc16
2 files changed, 30 insertions, 16 deletions
diff --git a/talk/app/webrtc/webrtcsdp.cc b/talk/app/webrtc/webrtcsdp.cc
index bc5dc1d1da..60cc53966c 100644
--- a/talk/app/webrtc/webrtcsdp.cc
+++ b/talk/app/webrtc/webrtcsdp.cc
@@ -140,8 +140,8 @@ static const char kAttributeCandidate[] = "candidate";
static const char kAttributeCandidateTyp[] = "typ";
static const char kAttributeCandidateRaddr[] = "raddr";
static const char kAttributeCandidateRport[] = "rport";
-static const char kAttributeCandidateUsername[] = "username";
-static const char kAttributeCandidatePassword[] = "password";
+static const char kAttributeCandidateUfrag[] = "ufrag";
+static const char kAttributeCandidatePwd[] = "pwd";
static const char kAttributeCandidateGeneration[] = "generation";
static const char kAttributeFingerprint[] = "fingerprint";
static const char kAttributeSetup[] = "setup";
@@ -262,6 +262,7 @@ static void BuildRtpMap(const MediaContentDescription* media_desc,
const MediaType media_type,
std::string* message);
static void BuildCandidate(const std::vector<Candidate>& candidates,
+ bool include_ufrag,
std::string* message);
static void BuildIceOptions(const std::vector<std::string>& transport_options,
std::string* message);
@@ -878,7 +879,7 @@ std::string SdpSerializeCandidate(
std::string message;
std::vector<cricket::Candidate> candidates;
candidates.push_back(candidate.candidate());
- BuildCandidate(candidates, &message);
+ BuildCandidate(candidates, true, &message);
// From WebRTC draft section 4.8.1.1 candidate-attribute will be
// just candidate:<candidate> not a=candidate:<blah>CRLF
ASSERT(message.find("a=") == 0);
@@ -1072,10 +1073,9 @@ bool ParseCandidate(const std::string& message, Candidate* candidate,
}
// Extension
- // Empty string as the candidate username and password.
- // Will be updated later with the ice-ufrag and ice-pwd.
- // TODO: Remove the username/password extension, which is currently
- // kept for backwards compatibility.
+ // Though non-standard, we support the ICE ufrag and pwd being signaled on
+ // the candidate to avoid issues with confusing which generation a candidate
+ // belongs to when trickling multiple generations at the same time.
std::string username;
std::string password;
uint32_t generation = 0;
@@ -1086,9 +1086,9 @@ bool ParseCandidate(const std::string& message, Candidate* candidate,
if (!GetValueFromString(first_line, fields[++i], &generation, error)) {
return false;
}
- } else if (fields[i] == kAttributeCandidateUsername) {
+ } else if (fields[i] == kAttributeCandidateUfrag) {
username = fields[++i];
- } else if (fields[i] == kAttributeCandidatePassword) {
+ } else if (fields[i] == kAttributeCandidatePwd) {
password = fields[++i];
} else {
// Skip the unknown extension.
@@ -1285,8 +1285,9 @@ void BuildMediaDescription(const ContentInfo* content_info,
}
}
- // Build the a=candidate lines.
- BuildCandidate(candidates, message);
+ // Build the a=candidate lines. We don't include ufrag and pwd in the
+ // candidates in the SDP to avoid redundancy.
+ BuildCandidate(candidates, false, message);
// Use the transport_info to build the media level ice-ufrag and ice-pwd.
if (transport_info) {
@@ -1717,6 +1718,7 @@ void BuildRtpMap(const MediaContentDescription* media_desc,
}
void BuildCandidate(const std::vector<Candidate>& candidates,
+ bool include_ufrag,
std::string* message) {
std::ostringstream os;
@@ -1766,6 +1768,9 @@ void BuildCandidate(const std::vector<Candidate>& candidates,
// Extensions
os << kAttributeCandidateGeneration << " " << it->generation();
+ if (include_ufrag && !it->username().empty()) {
+ os << " " << kAttributeCandidateUfrag << " " << it->username();
+ }
AddLine(os.str(), message);
}
@@ -2677,7 +2682,8 @@ bool ParseContent(const std::string& message,
// Update the candidates with the media level "ice-pwd" and "ice-ufrag".
for (Candidates::iterator it = candidates_orig.begin();
it != candidates_orig.end(); ++it) {
- ASSERT((*it).username().empty());
+ ASSERT((*it).username().empty() ||
+ (*it).username() == transport->ice_ufrag);
(*it).set_username(transport->ice_ufrag);
ASSERT((*it).password().empty());
(*it).set_password(transport->ice_pwd);
diff --git a/talk/app/webrtc/webrtcsdp_unittest.cc b/talk/app/webrtc/webrtcsdp_unittest.cc
index fb55e31c9c..97b6a26a26 100644
--- a/talk/app/webrtc/webrtcsdp_unittest.cc
+++ b/talk/app/webrtc/webrtcsdp_unittest.cc
@@ -396,9 +396,9 @@ static const char kRawIPV6Candidate[] =
"abcd::abcd::abcd::abcd::abcd::abcd::abcd::abcd 1234 typ host generation 2";
// One candidate reference string.
-static const char kSdpOneCandidateOldFormat[] =
+static const char kSdpOneCandidateWithUfragPwd[] =
"a=candidate:a0+B/1 1 udp 2130706432 192.168.1.5 1234 typ host network_name"
- " eth0 username user_rtp password password_rtp generation 2\r\n";
+ " eth0 ufrag user_rtp pwd password_rtp generation 2\r\n";
// Session id and version
static const char kSessionId[] = "18446744069414584320";
@@ -1727,6 +1727,13 @@ TEST_F(WebRtcSdpTest, SerializeSessionDescriptionWithExtmap) {
TEST_F(WebRtcSdpTest, SerializeCandidates) {
std::string message = webrtc::SdpSerializeCandidate(*jcandidate_);
EXPECT_EQ(std::string(kRawCandidate), message);
+
+ Candidate candidate_with_ufrag(candidates_.front());
+ candidate_with_ufrag.set_username("ABC");
+ jcandidate_.reset(new JsepIceCandidate(std::string("audio_content_name"), 0,
+ candidate_with_ufrag));
+ message = webrtc::SdpSerializeCandidate(*jcandidate_);
+ EXPECT_EQ(std::string(kRawCandidate) + " ufrag ABC", message);
}
// TODO(mallinath) : Enable this test once WebRTCSdp capable of parsing
@@ -2323,9 +2330,10 @@ TEST_F(WebRtcSdpTest, DeserializeCandidateWithDifferentTransport) {
EXPECT_TRUE(jcandidate.candidate().IsEquivalent(jcandidate_->candidate()));
}
-TEST_F(WebRtcSdpTest, DeserializeCandidateOldFormat) {
+TEST_F(WebRtcSdpTest, DeserializeCandidateWithUfragPwd) {
JsepIceCandidate jcandidate(kDummyMid, kDummyIndex);
- EXPECT_TRUE(SdpDeserializeCandidate(kSdpOneCandidateOldFormat,&jcandidate));
+ EXPECT_TRUE(
+ SdpDeserializeCandidate(kSdpOneCandidateWithUfragPwd, &jcandidate));
EXPECT_EQ(kDummyMid, jcandidate.sdp_mid());
EXPECT_EQ(kDummyIndex, jcandidate.sdp_mline_index());
Candidate ref_candidate = jcandidate_->candidate();