OLD | NEW |
---|---|
1 /* | 1 /* |
2 * libjingle | 2 * libjingle |
3 * Copyright 2011 Google Inc. | 3 * Copyright 2011 Google Inc. |
4 * | 4 * |
5 * Redistribution and use in source and binary forms, with or without | 5 * Redistribution and use in source and binary forms, with or without |
6 * modification, are permitted provided that the following conditions are met: | 6 * modification, are permitted provided that the following conditions are met: |
7 * | 7 * |
8 * 1. Redistributions of source code must retain the above copyright notice, | 8 * 1. Redistributions of source code must retain the above copyright notice, |
9 * this list of conditions and the following disclaimer. | 9 * this list of conditions and the following disclaimer. |
10 * 2. Redistributions in binary form must reproduce the above copyright notice, | 10 * 2. Redistributions in binary form must reproduce the above copyright notice, |
(...skipping 1256 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1267 transport_info->description.identity_fingerprint.get() : NULL; | 1267 transport_info->description.identity_fingerprint.get() : NULL; |
1268 | 1268 |
1269 // Add the m and c lines. | 1269 // Add the m and c lines. |
1270 InitLine(kLineTypeMedia, type, &os); | 1270 InitLine(kLineTypeMedia, type, &os); |
1271 os << " " << port << " " << media_desc->protocol() << fmt; | 1271 os << " " << port << " " << media_desc->protocol() << fmt; |
1272 std::string mline = os.str(); | 1272 std::string mline = os.str(); |
1273 UpdateMediaDefaultDestination(candidates, mline, message); | 1273 UpdateMediaDefaultDestination(candidates, mline, message); |
1274 | 1274 |
1275 // RFC 4566 | 1275 // RFC 4566 |
1276 // b=AS:<bandwidth> | 1276 // b=AS:<bandwidth> |
1277 // We should always use the default bandwidth for RTP-based data | 1277 if (media_desc->bandwidth() >= 1000) { |
1278 // channels. Don't allow SDP to set the bandwidth, because that | |
1279 // would give JS the opportunity to "break the Internet". | |
1280 // TODO(pthatcher): But we need to temporarily allow the SDP to control | |
1281 // this for backwards-compatibility. Once we don't need that any | |
1282 // more, remove this. | |
1283 bool support_dc_sdp_bandwidth_temporarily = true; | |
1284 if (media_desc->bandwidth() >= 1000 && | |
1285 (media_type != cricket::MEDIA_TYPE_DATA || | |
1286 support_dc_sdp_bandwidth_temporarily)) { | |
1287 InitLine(kLineTypeSessionBandwidth, kApplicationSpecificMaximum, &os); | 1278 InitLine(kLineTypeSessionBandwidth, kApplicationSpecificMaximum, &os); |
1288 os << kSdpDelimiterColon << (media_desc->bandwidth() / 1000); | 1279 os << kSdpDelimiterColon << (media_desc->bandwidth() / 1000); |
1289 AddLine(os.str(), message); | 1280 AddLine(os.str(), message); |
1290 } | 1281 } |
1291 | 1282 |
1292 // Add the a=rtcp line. | 1283 // Add the a=rtcp line. |
1293 if (IsRtp(media_desc->protocol())) { | 1284 if (IsRtp(media_desc->protocol())) { |
1294 std::string rtcp_line = GetRtcpLine(candidates); | 1285 std::string rtcp_line = GetRtcpLine(candidates); |
1295 if (!rtcp_line.empty()) { | 1286 if (!rtcp_line.empty()) { |
1296 AddLine(rtcp_line, message); | 1287 AddLine(rtcp_line, message); |
(...skipping 945 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2242 message, cricket::MEDIA_TYPE_DATA, mline_index, protocol, | 2233 message, cricket::MEDIA_TYPE_DATA, mline_index, protocol, |
2243 codec_preference, pos, &content_name, | 2234 codec_preference, pos, &content_name, |
2244 &transport, candidates, error); | 2235 &transport, candidates, error); |
2245 content.reset(data_desc); | 2236 content.reset(data_desc); |
2246 | 2237 |
2247 int p; | 2238 int p; |
2248 if (data_desc && IsDtlsSctp(protocol) && rtc::FromString(fields[3], &p)) { | 2239 if (data_desc && IsDtlsSctp(protocol) && rtc::FromString(fields[3], &p)) { |
2249 if (!AddSctpDataCodec(data_desc, p)) | 2240 if (!AddSctpDataCodec(data_desc, p)) |
2250 return false; | 2241 return false; |
2251 } | 2242 } |
2252 | |
2253 // We should always use the default bandwidth for RTP-based data | |
2254 // channels. Don't allow SDP to set the bandwidth, because that | |
2255 // would give JS the opportunity to "break the Internet". | |
2256 // TODO(pthatcher): But we need to temporarily allow the SDP to control | |
2257 // this for backwards-compatibility. Once we don't need that any | |
2258 // more, remove this. | |
2259 bool support_dc_sdp_bandwidth_temporarily = true; | |
2260 if (content.get() && !support_dc_sdp_bandwidth_temporarily) { | |
2261 content->set_bandwidth(cricket::kAutoBandwidth); | |
2262 } | |
2263 } else { | 2243 } else { |
2264 LOG(LS_WARNING) << "Unsupported media type: " << line; | 2244 LOG(LS_WARNING) << "Unsupported media type: " << line; |
2265 continue; | 2245 continue; |
2266 } | 2246 } |
2267 if (!content.get()) { | 2247 if (!content.get()) { |
2268 // ParseContentDescription returns NULL if failed. | 2248 // ParseContentDescription returns NULL if failed. |
2269 return false; | 2249 return false; |
2270 } | 2250 } |
2271 | 2251 |
2272 if (IsRtp(protocol)) { | 2252 if (IsRtp(protocol)) { |
(...skipping 237 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2510 if (IsLineType(line, kLineTypeSessionBandwidth)) { | 2490 if (IsLineType(line, kLineTypeSessionBandwidth)) { |
2511 std::string bandwidth; | 2491 std::string bandwidth; |
2512 if (HasAttribute(line, kApplicationSpecificMaximum)) { | 2492 if (HasAttribute(line, kApplicationSpecificMaximum)) { |
2513 if (!GetValue(line, kApplicationSpecificMaximum, &bandwidth, error)) { | 2493 if (!GetValue(line, kApplicationSpecificMaximum, &bandwidth, error)) { |
2514 return false; | 2494 return false; |
2515 } else { | 2495 } else { |
2516 int b = 0; | 2496 int b = 0; |
2517 if (!GetValueFromString(line, bandwidth, &b, error)) { | 2497 if (!GetValueFromString(line, bandwidth, &b, error)) { |
2518 return false; | 2498 return false; |
2519 } | 2499 } |
2500 // We should never use more than the default bandwidth for RTP-based | |
2501 // data channels. Don't allow SDP to set the bandwidth, because | |
2502 // that would give JS the opportunity to "break the Internet". | |
pthatcher1
2015/06/24 20:01:56
Please reference the bug URL here.
Just say "See
Taylor Brandstetter
2015/06/24 21:41:24
Done.
| |
2503 if (media_type == cricket::MEDIA_TYPE_DATA && | |
2504 b > cricket::kDataMaxBandwidth / 1000) { | |
pthatcher1
2015/06/24 20:01:56
&& IsRtp(media_desc->protocol())
Taylor Brandstetter
2015/06/24 21:41:24
Done.
| |
2505 std::ostringstream description; | |
2506 description << "SDP data bandwidth must not exceed " | |
pthatcher1
2015/06/24 20:01:57
A more accurate message would be "RTP-based data c
Taylor Brandstetter
2015/06/24 21:41:24
Done.
| |
2507 << cricket::kDataMaxBandwidth / 1000 << "kbps."; | |
2508 return ParseFailed(line, description.str(), error); | |
2509 } | |
2520 media_desc->set_bandwidth(b * 1000); | 2510 media_desc->set_bandwidth(b * 1000); |
2521 } | 2511 } |
2522 } | 2512 } |
2523 continue; | 2513 continue; |
2524 } | 2514 } |
2525 | 2515 |
2526 if (!IsLineType(line, kLineTypeAttributes)) { | 2516 if (!IsLineType(line, kLineTypeAttributes)) { |
2527 // TODO: Handle other lines if needed. | 2517 // TODO: Handle other lines if needed. |
2528 LOG(LS_INFO) << "Ignored line: " << line; | 2518 LOG(LS_INFO) << "Ignored line: " << line; |
2529 continue; | 2519 continue; |
(...skipping 577 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3107 UpdateCodec<AudioContentDescription, cricket::AudioCodec>( | 3097 UpdateCodec<AudioContentDescription, cricket::AudioCodec>( |
3108 media_desc, payload_type, feedback_param); | 3098 media_desc, payload_type, feedback_param); |
3109 } else if (media_type == cricket::MEDIA_TYPE_VIDEO) { | 3099 } else if (media_type == cricket::MEDIA_TYPE_VIDEO) { |
3110 UpdateCodec<VideoContentDescription, cricket::VideoCodec>( | 3100 UpdateCodec<VideoContentDescription, cricket::VideoCodec>( |
3111 media_desc, payload_type, feedback_param); | 3101 media_desc, payload_type, feedback_param); |
3112 } | 3102 } |
3113 return true; | 3103 return true; |
3114 } | 3104 } |
3115 | 3105 |
3116 } // namespace webrtc | 3106 } // namespace webrtc |
OLD | NEW |