Skip to content

Commit

Permalink
Implement serialization for ICE candidates with hostname addresses.
Browse files Browse the repository at this point in the history
Bug: webrtc:4165
Change-Id: I5ba0f25e458013ac3982648fc33d92d2a00e8fdd
Reviewed-on: https://webrtc-review.googlesource.com/93250
Reviewed-by: Steve Anton <[email protected]>
Reviewed-by: Seth Hampson <[email protected]>
Commit-Queue: Zach Stein <[email protected]>
Cr-Commit-Position: refs/heads/master@{#24275}
  • Loading branch information
Zach Stein authored and Commit Bot committed Aug 13, 2018
1 parent ee562d8 commit b336c27
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 3 deletions.
7 changes: 4 additions & 3 deletions pc/webrtcsdp.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1887,9 +1887,10 @@ void BuildCandidate(const std::vector<Candidate>& candidates,
InitAttrLine(kAttributeCandidate, &os);
os << kSdpDelimiterColon << it->foundation() << " " << it->component()
<< " " << it->protocol() << " " << it->priority() << " "
<< it->address().ipaddr().ToString() << " "
<< it->address().PortAsString() << " " << kAttributeCandidateTyp << " "
<< type << " ";
<< (it->address().ipaddr().IsNil() ? it->address().hostname()
: it->address().ipaddr().ToString())
<< " " << it->address().PortAsString() << " " << kAttributeCandidateTyp
<< " " << type << " ";

// Related address
if (!it->related_address().IsNil()) {
Expand Down
16 changes: 16 additions & 0 deletions pc/webrtcsdp_unittest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -708,6 +708,9 @@ static const char kSdpOneCandidateWithUfragPwd[] =
"a=candidate:a0+B/1 1 udp 2130706432 192.168.1.5 1234 typ host network_name"
" eth0 ufrag user_rtp pwd password_rtp generation 2\r\n";

static const char kRawHostnameCandidate[] =
"candidate:a0+B/1 1 udp 2130706432 a.test 1234 typ host generation 2";

// Session id and version
static const char kSessionId[] = "18446744069414584320";
static const char kSessionVersion[] = "18446462598732840960";
Expand Down Expand Up @@ -2139,6 +2142,16 @@ TEST_F(WebRtcSdpTest, SerializeCandidates) {
message);
}

TEST_F(WebRtcSdpTest, SerializeHostnameCandidate) {
rtc::SocketAddress address("a.test", 1234);
cricket::Candidate candidate(
cricket::ICE_CANDIDATE_COMPONENT_RTP, "udp", address, kCandidatePriority,
"", "", LOCAL_PORT_TYPE, kCandidateGeneration, kCandidateFoundation1);
JsepIceCandidate jcandidate(std::string("audio_content_name"), 0, candidate);
std::string message = webrtc::SdpSerializeCandidate(jcandidate);
EXPECT_EQ(std::string(kRawHostnameCandidate), message);
}

// TODO(mallinath) : Enable this test once WebRTCSdp capable of parsing
// RFC 6544.
TEST_F(WebRtcSdpTest, SerializeTcpCandidates) {
Expand Down Expand Up @@ -2502,6 +2515,9 @@ TEST_F(WebRtcSdpTest, DeserializeRawCandidateAttribute) {

// Candidate line with IPV6 address.
EXPECT_TRUE(SdpDeserializeCandidate(kRawIPV6Candidate, &jcandidate));

// Candidate line with hostname address.
EXPECT_TRUE(SdpDeserializeCandidate(kRawHostnameCandidate, &jcandidate));
}

// This test verifies that the deserialization of an invalid candidate string
Expand Down

0 comments on commit b336c27

Please sign in to comment.