Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(36)

Side by Side Diff: webrtc/pc/webrtcsdp.cc

Issue 2690943011: Use the same draft version in SDP data channel answers as used in the offer. (Closed)
Patch Set: No actual changes from Patch Set 1 (learning the tools). Created 3 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 /* 1 /*
2 * Copyright 2011 The WebRTC project authors. All Rights Reserved. 2 * Copyright 2011 The WebRTC project authors. All Rights Reserved.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license 4 * Use of this source code is governed by a BSD-style license
5 * that can be found in the LICENSE file in the root of the source 5 * that can be found in the LICENSE file in the root of the source
6 * tree. An additional intellectual property rights grant can be found 6 * tree. An additional intellectual property rights grant can be found
7 * in the file PATENTS. All contributing project authors may 7 * in the file PATENTS. All contributing project authors may
8 * be found in the AUTHORS file in the root of the source tree. 8 * be found in the AUTHORS file in the root of the source tree.
9 */ 9 */
10 10
(...skipping 214 matching lines...) Expand 10 before | Expand all | Expand 10 after
225 typedef std::vector<SsrcGroup> SsrcGroupVec; 225 typedef std::vector<SsrcGroup> SsrcGroupVec;
226 226
227 template <class T> 227 template <class T>
228 static void AddFmtpLine(const T& codec, std::string* message); 228 static void AddFmtpLine(const T& codec, std::string* message);
229 static void BuildMediaDescription(const ContentInfo* content_info, 229 static void BuildMediaDescription(const ContentInfo* content_info,
230 const TransportInfo* transport_info, 230 const TransportInfo* transport_info,
231 const MediaType media_type, 231 const MediaType media_type,
232 const std::vector<Candidate>& candidates, 232 const std::vector<Candidate>& candidates,
233 bool unified_plan_sdp, 233 bool unified_plan_sdp,
234 std::string* message); 234 std::string* message);
235 static void BuildSctpContentAttributes(std::string* message, int sctp_port); 235 static void BuildSctpContentAttributes(std::string* message,
236 int sctp_port,
237 bool use_sctpmap);
236 static void BuildRtpContentAttributes(const MediaContentDescription* media_desc, 238 static void BuildRtpContentAttributes(const MediaContentDescription* media_desc,
237 const MediaType media_type, 239 const MediaType media_type,
238 bool unified_plan_sdp, 240 bool unified_plan_sdp,
239 std::string* message); 241 std::string* message);
240 static void BuildRtpMap(const MediaContentDescription* media_desc, 242 static void BuildRtpMap(const MediaContentDescription* media_desc,
241 const MediaType media_type, 243 const MediaType media_type,
242 std::string* message); 244 std::string* message);
243 static void BuildCandidate(const std::vector<Candidate>& candidates, 245 static void BuildCandidate(const std::vector<Candidate>& candidates,
244 bool include_ufrag, 246 bool include_ufrag,
245 std::string* message); 247 std::string* message);
(...skipping 1010 matching lines...) Expand 10 before | Expand all | Expand 10 after
1256 it != audio_desc->codecs().end(); ++it) { 1258 it != audio_desc->codecs().end(); ++it) {
1257 fmt.append(" "); 1259 fmt.append(" ");
1258 fmt.append(rtc::ToString<int>(it->id)); 1260 fmt.append(rtc::ToString<int>(it->id));
1259 } 1261 }
1260 } else if (media_type == cricket::MEDIA_TYPE_DATA) { 1262 } else if (media_type == cricket::MEDIA_TYPE_DATA) {
1261 const DataContentDescription* data_desc = 1263 const DataContentDescription* data_desc =
1262 static_cast<const DataContentDescription*>(media_desc); 1264 static_cast<const DataContentDescription*>(media_desc);
1263 if (IsDtlsSctp(media_desc->protocol())) { 1265 if (IsDtlsSctp(media_desc->protocol())) {
1264 fmt.append(" "); 1266 fmt.append(" ");
1265 1267
1266 for (std::vector<cricket::DataCodec>::const_iterator it = 1268 if (data_desc->use_sctpmap()) {
1267 data_desc->codecs().begin(); 1269 for (std::vector<cricket::DataCodec>::const_iterator it =
1268 it != data_desc->codecs().end(); ++it) { 1270 data_desc->codecs().begin();
1269 if (cricket::CodecNamesEq(it->name, cricket::kGoogleSctpDataCodecName) 1271 it != data_desc->codecs().end(); ++it) {
1270 && it->GetParam(cricket::kCodecParamPort, &sctp_port)) { 1272 if (cricket::CodecNamesEq(it->name,
1271 break; 1273 cricket::kGoogleSctpDataCodecName) &&
1274 it->GetParam(cricket::kCodecParamPort, &sctp_port)) {
1275 break;
1276 }
1272 } 1277 }
1278
1279 fmt.append(rtc::ToString<int>(sctp_port));
1280 } else {
1281 fmt.append(kDefaultSctpmapProtocol);
1273 } 1282 }
1274
1275 fmt.append(rtc::ToString<int>(sctp_port));
1276 } else { 1283 } else {
1277 for (std::vector<cricket::DataCodec>::const_iterator it = 1284 for (std::vector<cricket::DataCodec>::const_iterator it =
1278 data_desc->codecs().begin(); 1285 data_desc->codecs().begin();
1279 it != data_desc->codecs().end(); ++it) { 1286 it != data_desc->codecs().end(); ++it) {
1280 fmt.append(" "); 1287 fmt.append(" ");
1281 fmt.append(rtc::ToString<int>(it->id)); 1288 fmt.append(rtc::ToString<int>(it->id));
1282 } 1289 }
1283 } 1290 }
1284 } 1291 }
1285 // The fmt must never be empty. If no codecs are found, set the fmt attribute 1292 // The fmt must never be empty. If no codecs are found, set the fmt attribute
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after
1388 1395
1389 // RFC 3388 1396 // RFC 3388
1390 // mid-attribute = "a=mid:" identification-tag 1397 // mid-attribute = "a=mid:" identification-tag
1391 // identification-tag = token 1398 // identification-tag = token
1392 // Use the content name as the mid identification-tag. 1399 // Use the content name as the mid identification-tag.
1393 InitAttrLine(kAttributeMid, &os); 1400 InitAttrLine(kAttributeMid, &os);
1394 os << kSdpDelimiterColon << content_info->name; 1401 os << kSdpDelimiterColon << content_info->name;
1395 AddLine(os.str(), message); 1402 AddLine(os.str(), message);
1396 1403
1397 if (IsDtlsSctp(media_desc->protocol())) { 1404 if (IsDtlsSctp(media_desc->protocol())) {
1398 BuildSctpContentAttributes(message, sctp_port); 1405 const DataContentDescription* data_desc =
1406 static_cast<const DataContentDescription*>(media_desc);
1407 bool use_sctpmap = data_desc != nullptr ? data_desc->use_sctpmap() : true;
Taylor Brandstetter 2017/02/17 02:10:56 It won't be possible for data_desc to be nullptr h
Zach Stein 2017/02/17 21:29:17 Done. This is the block I would like to try and mo
1408 BuildSctpContentAttributes(message, sctp_port, use_sctpmap);
1399 } else if (IsRtp(media_desc->protocol())) { 1409 } else if (IsRtp(media_desc->protocol())) {
1400 BuildRtpContentAttributes(media_desc, media_type, unified_plan_sdp, 1410 BuildRtpContentAttributes(media_desc, media_type, unified_plan_sdp,
1401 message); 1411 message);
1402 } 1412 }
1403 } 1413 }
1404 1414
1405 void BuildSctpContentAttributes(std::string* message, int sctp_port) { 1415 void BuildSctpContentAttributes(std::string* message,
1406 // draft-ietf-mmusic-sctp-sdp-04 1416 int sctp_port,
1407 // a=sctpmap:sctpmap-number protocol [streams] 1417 bool use_sctpmap) {
1408 // TODO(lally): switch this over to mmusic-sctp-sdp-12 (or later), with
1409 // 'a=sctp-port:'
1410 std::ostringstream os; 1418 std::ostringstream os;
1411 InitAttrLine(kAttributeSctpmap, &os); 1419 if (use_sctpmap) {
1412 os << kSdpDelimiterColon << sctp_port << kSdpDelimiterSpace 1420 // draft-ietf-mmusic-sctp-sdp-04
1413 << kDefaultSctpmapProtocol << kSdpDelimiterSpace 1421 // a=sctpmap:sctpmap-number protocol [streams]
1414 << cricket::kMaxSctpStreams; 1422 InitAttrLine(kAttributeSctpmap, &os);
1423 os << kSdpDelimiterColon << sctp_port << kSdpDelimiterSpace
1424 << kDefaultSctpmapProtocol << kSdpDelimiterSpace
1425 << cricket::kMaxSctpStreams;
1426 } else {
1427 // draft-ietf-mmusic-sctp-sdp-23
1428 // a=sctp-port:<port>
1429 InitAttrLine(kAttributeSctpPort, &os);
1430 os << kSdpDelimiterColon << sctp_port;
1431 // TODO(zstein): emit max-message-size here
1432 }
1415 AddLine(os.str(), message); 1433 AddLine(os.str(), message);
1416 } 1434 }
1417 1435
1418 // If unified_plan_sdp is true, will use "a=msid". 1436 // If unified_plan_sdp is true, will use "a=msid".
1419 void BuildRtpContentAttributes(const MediaContentDescription* media_desc, 1437 void BuildRtpContentAttributes(const MediaContentDescription* media_desc,
1420 const MediaType media_type, 1438 const MediaType media_type,
1421 bool unified_plan_sdp, 1439 bool unified_plan_sdp,
1422 std::string* message) { 1440 std::string* message) {
1423 std::ostringstream os; 1441 std::ostringstream os;
1424 // RFC 5285 1442 // RFC 5285
(...skipping 840 matching lines...) Expand 10 before | Expand all | Expand 10 after
2265 2283
2266 // Zero or more media descriptions 2284 // Zero or more media descriptions
2267 // RFC 4566 2285 // RFC 4566
2268 // m=<media> <port> <proto> <fmt> 2286 // m=<media> <port> <proto> <fmt>
2269 while (GetLineWithType(message, pos, &line, kLineTypeMedia)) { 2287 while (GetLineWithType(message, pos, &line, kLineTypeMedia)) {
2270 ++mline_index; 2288 ++mline_index;
2271 2289
2272 std::vector<std::string> fields; 2290 std::vector<std::string> fields;
2273 rtc::split(line.substr(kLinePrefixLength), 2291 rtc::split(line.substr(kLinePrefixLength),
2274 kSdpDelimiterSpace, &fields); 2292 kSdpDelimiterSpace, &fields);
2293
2275 const size_t expected_min_fields = 4; 2294 const size_t expected_min_fields = 4;
2276 if (fields.size() < expected_min_fields) { 2295 if (fields.size() < expected_min_fields) {
2277 return ParseFailedExpectMinFieldNum(line, expected_min_fields, error); 2296 return ParseFailedExpectMinFieldNum(line, expected_min_fields, error);
2278 } 2297 }
2279 bool port_rejected = false; 2298 bool port_rejected = false;
2280 // RFC 3264 2299 // RFC 3264
2281 // To reject an offered stream, the port number in the corresponding stream 2300 // To reject an offered stream, the port number in the corresponding stream
2282 // in the answer MUST be set to zero. 2301 // in the answer MUST be set to zero.
2283 if (fields[1] == kMediaPortRejected) { 2302 if (fields[1] == kMediaPortRejected) {
2284 port_rejected = true; 2303 port_rejected = true;
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
2325 payload_types, pos, &content_name, &bundle_only, &transport, 2344 payload_types, pos, &content_name, &bundle_only, &transport,
2326 candidates, error)); 2345 candidates, error));
2327 } else if (HasAttribute(line, kMediaTypeData)) { 2346 } else if (HasAttribute(line, kMediaTypeData)) {
2328 DataContentDescription* data_desc = 2347 DataContentDescription* data_desc =
2329 ParseContentDescription<DataContentDescription>( 2348 ParseContentDescription<DataContentDescription>(
2330 message, cricket::MEDIA_TYPE_DATA, mline_index, protocol, 2349 message, cricket::MEDIA_TYPE_DATA, mline_index, protocol,
2331 payload_types, pos, &content_name, &bundle_only, &transport, 2350 payload_types, pos, &content_name, &bundle_only, &transport,
2332 candidates, error); 2351 candidates, error);
2333 content.reset(data_desc); 2352 content.reset(data_desc);
2334 2353
2335 int p; 2354 if (data_desc && IsDtlsSctp(protocol)) {
2336 if (data_desc && IsDtlsSctp(protocol) && rtc::FromString(fields[3], &p)) { 2355 int p;
2337 if (!AddSctpDataCodec(data_desc, p)) 2356 if (rtc::FromString(fields[3], &p)) {
2338 return false; 2357 if (!AddSctpDataCodec(data_desc, p)) {
2358 return false;
2359 }
2360 } else if (fields[3] == kDefaultSctpmapProtocol) {
2361 data_desc->set_use_sctpmap(false);
2362 }
2339 } 2363 }
2340 } else { 2364 } else {
2341 LOG(LS_WARNING) << "Unsupported media type: " << line; 2365 LOG(LS_WARNING) << "Unsupported media type: " << line;
2342 continue; 2366 continue;
2343 } 2367 }
2344 if (!content.get()) { 2368 if (!content.get()) {
2345 // ParseContentDescription returns NULL if failed. 2369 // ParseContentDescription returns NULL if failed.
2346 return false; 2370 return false;
2347 } 2371 }
2348 2372
(...skipping 844 matching lines...) Expand 10 before | Expand all | Expand 10 after
3193 UpdateCodec<AudioContentDescription, cricket::AudioCodec>( 3217 UpdateCodec<AudioContentDescription, cricket::AudioCodec>(
3194 media_desc, payload_type, feedback_param); 3218 media_desc, payload_type, feedback_param);
3195 } else if (media_type == cricket::MEDIA_TYPE_VIDEO) { 3219 } else if (media_type == cricket::MEDIA_TYPE_VIDEO) {
3196 UpdateCodec<VideoContentDescription, cricket::VideoCodec>( 3220 UpdateCodec<VideoContentDescription, cricket::VideoCodec>(
3197 media_desc, payload_type, feedback_param); 3221 media_desc, payload_type, feedback_param);
3198 } 3222 }
3199 return true; 3223 return true;
3200 } 3224 }
3201 3225
3202 } // namespace webrtc 3226 } // namespace webrtc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698