Fix bug parsing media descriptions: the final field isn't a codec type for any of DTLS/SCTP, SCTP, or SCTP/DTLS.
BUG=none TEST=none R=juberti@webrtc.org Review URL: https://webrtc-codereview.appspot.com/34029004 Cr-Commit-Position: refs/heads/master@{#8369} git-svn-id: http://webrtc.googlecode.com/svn/trunk@8369 4adac7df-926f-26a2-2b94-8c16560cd09d
This commit is contained in:
@ -261,7 +261,8 @@ static void BuildCandidate(const std::vector<Candidate>& candidates,
|
|||||||
std::string* message);
|
std::string* message);
|
||||||
static void BuildIceOptions(const std::vector<std::string>& transport_options,
|
static void BuildIceOptions(const std::vector<std::string>& transport_options,
|
||||||
std::string* message);
|
std::string* message);
|
||||||
|
static bool IsRtp(const std::string& protocol);
|
||||||
|
static bool IsDtlsSctp(const std::string& protocol);
|
||||||
static bool ParseSessionDescription(const std::string& message, size_t* pos,
|
static bool ParseSessionDescription(const std::string& message, size_t* pos,
|
||||||
std::string* session_id,
|
std::string* session_id,
|
||||||
std::string* session_version,
|
std::string* session_version,
|
||||||
@ -1191,7 +1192,6 @@ void BuildMediaDescription(const ContentInfo* content_info,
|
|||||||
content_info->description);
|
content_info->description);
|
||||||
ASSERT(media_desc != NULL);
|
ASSERT(media_desc != NULL);
|
||||||
|
|
||||||
bool is_sctp = (media_desc->protocol() == cricket::kMediaProtocolDtlsSctp);
|
|
||||||
int sctp_port = cricket::kSctpDefaultPort;
|
int sctp_port = cricket::kSctpDefaultPort;
|
||||||
|
|
||||||
// RFC 4566
|
// RFC 4566
|
||||||
@ -1229,7 +1229,7 @@ void BuildMediaDescription(const ContentInfo* content_info,
|
|||||||
} else if (media_type == cricket::MEDIA_TYPE_DATA) {
|
} else if (media_type == cricket::MEDIA_TYPE_DATA) {
|
||||||
const DataContentDescription* data_desc =
|
const DataContentDescription* data_desc =
|
||||||
static_cast<const DataContentDescription*>(media_desc);
|
static_cast<const DataContentDescription*>(media_desc);
|
||||||
if (is_sctp) {
|
if (IsDtlsSctp(media_desc->protocol())) {
|
||||||
fmt.append(" ");
|
fmt.append(" ");
|
||||||
|
|
||||||
for (std::vector<cricket::DataCodec>::const_iterator it =
|
for (std::vector<cricket::DataCodec>::const_iterator it =
|
||||||
@ -1292,11 +1292,7 @@ void BuildMediaDescription(const ContentInfo* content_info,
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Add the a=rtcp line.
|
// Add the a=rtcp line.
|
||||||
bool is_rtp =
|
if (IsRtp(media_desc->protocol())) {
|
||||||
media_desc->protocol().empty() ||
|
|
||||||
rtc::starts_with(media_desc->protocol().data(),
|
|
||||||
cricket::kMediaProtocolRtpPrefix);
|
|
||||||
if (is_rtp) {
|
|
||||||
std::string rtcp_line = GetRtcpLine(candidates);
|
std::string rtcp_line = GetRtcpLine(candidates);
|
||||||
if (!rtcp_line.empty()) {
|
if (!rtcp_line.empty()) {
|
||||||
AddLine(rtcp_line, message);
|
AddLine(rtcp_line, message);
|
||||||
@ -1357,9 +1353,9 @@ void BuildMediaDescription(const ContentInfo* content_info,
|
|||||||
os << kSdpDelimiterColon << content_info->name;
|
os << kSdpDelimiterColon << content_info->name;
|
||||||
AddLine(os.str(), message);
|
AddLine(os.str(), message);
|
||||||
|
|
||||||
if (is_sctp) {
|
if (IsDtlsSctp(media_desc->protocol())) {
|
||||||
BuildSctpContentAttributes(message, sctp_port);
|
BuildSctpContentAttributes(message, sctp_port);
|
||||||
} else {
|
} else if (IsRtp(media_desc->protocol())) {
|
||||||
BuildRtpContentAttributes(media_desc, media_type, message);
|
BuildRtpContentAttributes(media_desc, media_type, message);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1806,6 +1802,16 @@ void BuildIceOptions(const std::vector<std::string>& transport_options,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool IsRtp(const std::string& protocol) {
|
||||||
|
return protocol.empty() ||
|
||||||
|
(protocol.find(cricket::kMediaProtocolRtpPrefix) != std::string::npos);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool IsDtlsSctp(const std::string& protocol) {
|
||||||
|
// This intentionally excludes "SCTP" and "SCTP/DTLS".
|
||||||
|
return protocol.find(cricket::kMediaProtocolDtlsSctp) != std::string::npos;
|
||||||
|
}
|
||||||
|
|
||||||
bool ParseSessionDescription(const std::string& message, size_t* pos,
|
bool ParseSessionDescription(const std::string& message, size_t* pos,
|
||||||
std::string* session_id,
|
std::string* session_id,
|
||||||
std::string* session_version,
|
std::string* session_version,
|
||||||
@ -2188,11 +2194,10 @@ bool ParseMediaDescription(const std::string& message,
|
|||||||
}
|
}
|
||||||
|
|
||||||
std::string protocol = fields[2];
|
std::string protocol = fields[2];
|
||||||
bool is_sctp = (protocol == cricket::kMediaProtocolDtlsSctp);
|
|
||||||
|
|
||||||
// <fmt>
|
// <fmt>
|
||||||
std::vector<int> codec_preference;
|
std::vector<int> codec_preference;
|
||||||
if (!is_sctp) {
|
if (IsRtp(protocol)) {
|
||||||
for (size_t j = 3 ; j < fields.size(); ++j) {
|
for (size_t j = 3 ; j < fields.size(); ++j) {
|
||||||
// TODO(wu): Remove when below bug is fixed.
|
// TODO(wu): Remove when below bug is fixed.
|
||||||
// https://bugzilla.mozilla.org/show_bug.cgi?id=996329
|
// https://bugzilla.mozilla.org/show_bug.cgi?id=996329
|
||||||
@ -2240,8 +2245,7 @@ bool ParseMediaDescription(const std::string& message,
|
|||||||
content.reset(data_desc);
|
content.reset(data_desc);
|
||||||
|
|
||||||
int p;
|
int p;
|
||||||
if (data_desc && protocol == cricket::kMediaProtocolDtlsSctp &&
|
if (data_desc && IsDtlsSctp(protocol) && rtc::FromString(fields[3], &p)) {
|
||||||
rtc::FromString(fields[3], &p)) {
|
|
||||||
if (!AddSctpDataCodec(data_desc, p))
|
if (!AddSctpDataCodec(data_desc, p))
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -2265,7 +2269,7 @@ bool ParseMediaDescription(const std::string& message,
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!is_sctp) {
|
if (IsRtp(protocol)) {
|
||||||
// Make sure to set the media direction correctly. If the direction is not
|
// Make sure to set the media direction correctly. If the direction is not
|
||||||
// MD_RECVONLY or Inactive and no streams are parsed,
|
// MD_RECVONLY or Inactive and no streams are parsed,
|
||||||
// a default MediaStream will be created to prepare for receiving media.
|
// a default MediaStream will be created to prepare for receiving media.
|
||||||
@ -2288,8 +2292,8 @@ bool ParseMediaDescription(const std::string& message,
|
|||||||
}
|
}
|
||||||
content->set_protocol(protocol);
|
content->set_protocol(protocol);
|
||||||
desc->AddContent(content_name,
|
desc->AddContent(content_name,
|
||||||
is_sctp ? cricket::NS_JINGLE_DRAFT_SCTP :
|
IsDtlsSctp(protocol) ? cricket::NS_JINGLE_DRAFT_SCTP :
|
||||||
cricket::NS_JINGLE_RTP,
|
cricket::NS_JINGLE_RTP,
|
||||||
rejected,
|
rejected,
|
||||||
content.release());
|
content.release());
|
||||||
// Create TransportInfo with the media level "ice-pwd" and "ice-ufrag".
|
// Create TransportInfo with the media level "ice-pwd" and "ice-ufrag".
|
||||||
@ -2495,11 +2499,6 @@ bool ParseContent(const std::string& message,
|
|||||||
std::string maxptime_as_string;
|
std::string maxptime_as_string;
|
||||||
std::string ptime_as_string;
|
std::string ptime_as_string;
|
||||||
|
|
||||||
bool is_rtp =
|
|
||||||
protocol.empty() ||
|
|
||||||
rtc::starts_with(protocol.data(),
|
|
||||||
cricket::kMediaProtocolRtpPrefix);
|
|
||||||
|
|
||||||
// Loop until the next m line
|
// Loop until the next m line
|
||||||
while (!IsLineType(message, kLineTypeMedia, *pos)) {
|
while (!IsLineType(message, kLineTypeMedia, *pos)) {
|
||||||
if (!GetLine(message, pos, &line)) {
|
if (!GetLine(message, pos, &line)) {
|
||||||
@ -2577,7 +2576,7 @@ bool ParseContent(const std::string& message,
|
|||||||
if (!ParseDtlsSetup(line, &(transport->connection_role), error)) {
|
if (!ParseDtlsSetup(line, &(transport->connection_role), error)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
} else if (HasAttribute(line, kAttributeSctpPort)) {
|
} else if (IsDtlsSctp(protocol) && HasAttribute(line, kAttributeSctpPort)) {
|
||||||
int sctp_port;
|
int sctp_port;
|
||||||
if (!ParseSctpPort(line, &sctp_port, error)) {
|
if (!ParseSctpPort(line, &sctp_port, error)) {
|
||||||
return false;
|
return false;
|
||||||
@ -2586,7 +2585,7 @@ bool ParseContent(const std::string& message,
|
|||||||
sctp_port)) {
|
sctp_port)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
} else if (is_rtp) {
|
} else if (IsRtp(protocol)) {
|
||||||
//
|
//
|
||||||
// RTP specific attrubtes
|
// RTP specific attrubtes
|
||||||
//
|
//
|
||||||
|
Reference in New Issue
Block a user