Index: webrtc/pc/webrtcsdp.cc |
diff --git a/webrtc/pc/webrtcsdp.cc b/webrtc/pc/webrtcsdp.cc |
index 13d09a6ee96efd33219e6e7df89ba5983cb49d7e..404e45fe0c53547375a1fb910205f0b37d52ca55 100644 |
--- a/webrtc/pc/webrtcsdp.cc |
+++ b/webrtc/pc/webrtcsdp.cc |
@@ -1900,6 +1900,31 @@ bool IsDtlsSctp(const std::string& protocol) { |
return protocol.find(cricket::kMediaProtocolDtlsSctp) != std::string::npos; |
} |
+bool ParseConnectionData(const std::string line, rtc::SocketAddress* addr) { |
Taylor Brandstetter
2017/03/10 22:41:18
Meant to be const ref string?
Zhi Huang
2017/03/15 04:04:59
Ah, yes. I missed the &.
|
+ // Parse the line from left to right. |
+ std::string token; |
+ std::string rightpart; |
+ // RFC 4566 |
+ // c=<nettype> <addrtype> <connection-address> |
+ // Skip "c=<nettype>". |
Taylor Brandstetter
2017/03/10 22:41:18
We should verify that "nettype" is "IN" since that
Zhi Huang
2017/03/15 04:04:59
Done.
|
+ if (!rtc::tokenize_first(line, kSdpDelimiterSpace, &token, &rightpart)) { |
+ return false; |
+ } |
+ // Skip the "<addrtype>". |
Taylor Brandstetter
2017/03/10 22:41:18
To be more thorough, we could verify that addrtype
Zhi Huang
2017/03/15 04:04:59
Done.
|
+ if (!rtc::tokenize_first(rightpart, kSdpDelimiterSpace, &token, &rightpart)) { |
+ return false; |
+ } |
+ // Extract the IP address. The rightpart part should be the IP address without |
+ // the slash which is used for multicast. |
+ if (rightpart.find('/') != std::string::npos) { |
+ LOG(LS_ERROR) << "Failed to parse the connection data. Multicast is not " |
Taylor Brandstetter
2017/03/10 22:41:18
This method should take an error output parameter
Zhi Huang
2017/03/15 04:04:59
Done.
|
+ "currently supported."; |
+ return false; |
+ } |
+ addr->SetIP(rightpart); |
+ return true; |
+} |
+ |
bool ParseSessionDescription(const std::string& message, size_t* pos, |
std::string* session_id, |
std::string* session_version, |
@@ -1962,7 +1987,15 @@ bool ParseSessionDescription(const std::string& message, size_t* pos, |
// RFC 4566 |
// c=* (connection information -- not required if included in |
// all media) |
- GetLineWithType(message, pos, &line, kLineTypeConnection); |
+ if (GetLineWithType(message, pos, &line, kLineTypeConnection)) { |
+ rtc::SocketAddress addr; |
+ if (!ParseConnectionData(line, &addr)) { |
+ LOG(LS_ERROR) << "Failed to parse the session level connection data:" |
Taylor Brandstetter
2017/03/10 22:41:18
This doesn't need to log an error if ParseConnecti
Zhi Huang
2017/03/15 04:04:59
Done.
|
+ << line; |
+ return false; |
+ } |
+ desc->set_session_connection_addr(rtc::Optional<rtc::SocketAddress>(addr)); |
+ } |
// RFC 4566 |
// b=* (zero or more bandwidth information lines) |
@@ -2266,7 +2299,7 @@ static C* ParseContentDescription(const std::string& message, |
pos, content_name, bundle_only, media_desc, transport, |
candidates, error)) { |
delete media_desc; |
- return NULL; |
+ return nullptr; |
} |
// Sort the codecs according to the m-line fmt list. |
std::unordered_map<int, int> payload_type_preferences; |
@@ -2668,6 +2701,19 @@ bool ParseContent(const std::string& message, |
continue; |
} |
+ // Parse the media level connection data. |
+ if (IsLineType(line, kLineTypeConnection)) { |
+ rtc::SocketAddress addr; |
+ if (!ParseConnectionData(line, &addr)) { |
+ LOG(LS_ERROR) << "Failed to parse the session level connection data:" |
+ << line; |
+ return false; |
+ } |
+ media_desc->set_media_connection_addr( |
+ rtc::Optional<rtc::SocketAddress>(addr)); |
+ continue; |
+ } |
+ |
if (!IsLineType(line, kLineTypeAttributes)) { |
// TODO: Handle other lines if needed. |
LOG(LS_INFO) << "Ignored line: " << line; |