| Index: webrtc/api/webrtcsdp.cc
|
| diff --git a/webrtc/api/webrtcsdp.cc b/webrtc/api/webrtcsdp.cc
|
| index 93d4acc6c3fad5fd2e2612ff22af02de2554baeb..f74485e5bfa949b3ac5c758de5097fa0844ce696 100644
|
| --- a/webrtc/api/webrtcsdp.cc
|
| +++ b/webrtc/api/webrtcsdp.cc
|
| @@ -1297,9 +1297,9 @@ void BuildMediaDescription(const ContentInfo* content_info,
|
|
|
| // RFC 4566
|
| // b=AS:<bandwidth>
|
| - if (media_desc->bandwidth() >= 1000) {
|
| + if (media_desc->bandwidth() && (*media_desc->bandwidth() >= 1000)) {
|
| InitLine(kLineTypeSessionBandwidth, kApplicationSpecificMaximum, &os);
|
| - os << kSdpDelimiterColon << (media_desc->bandwidth() / 1000);
|
| + os << kSdpDelimiterColon << (*media_desc->bandwidth() / 1000);
|
| AddLine(os.str(), message);
|
| }
|
|
|
| @@ -2558,22 +2558,28 @@ bool ParseContent(const std::string& message,
|
| if (!GetValue(line, kApplicationSpecificMaximum, &bandwidth, error)) {
|
| return false;
|
| } else {
|
| - int b = 0;
|
| - if (!GetValueFromString(line, bandwidth, &b, error)) {
|
| + int bandwidth_value = 0;
|
| + if (!GetValueFromString(line, bandwidth, &bandwidth_value, error)) {
|
| return false;
|
| }
|
| + if (bandwidth_value < 0) {
|
| + std::ostringstream description;
|
| + description << "The bandwidth value must not be negative";
|
| + return ParseFailed(line, description.str(), error);
|
| + }
|
| +
|
| // We should never use more than the default bandwidth for RTP-based
|
| // data channels. Don't allow SDP to set the bandwidth, because
|
| // that would give JS the opportunity to "break the Internet".
|
| // See: https://code.google.com/p/chromium/issues/detail?id=280726
|
| if (media_type == cricket::MEDIA_TYPE_DATA && IsRtp(protocol) &&
|
| - b > cricket::kDataMaxBandwidth / 1000) {
|
| + bandwidth_value > cricket::kDataMaxBandwidth / 1000) {
|
| std::ostringstream description;
|
| description << "RTP-based data channels may not send more than "
|
| << cricket::kDataMaxBandwidth / 1000 << "kbps.";
|
| return ParseFailed(line, description.str(), error);
|
| }
|
| - media_desc->set_bandwidth(b * 1000);
|
| + media_desc->set_bandwidth(rtc::Optional<int>(1000 * bandwidth_value));
|
| }
|
| }
|
| continue;
|
|
|