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

Side by Side Diff: talk/app/webrtc/webrtcsdp.cc

Issue 1668073002: Add network cost as part of the connection comparison. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Created 4 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 * 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 125 matching lines...) Expand 10 before | Expand all | Expand 10 after
136 static const char kSSrcAttributeLabel[] = "label"; 136 static const char kSSrcAttributeLabel[] = "label";
137 static const char kAttributeSsrcGroup[] = "ssrc-group"; 137 static const char kAttributeSsrcGroup[] = "ssrc-group";
138 static const char kAttributeCrypto[] = "crypto"; 138 static const char kAttributeCrypto[] = "crypto";
139 static const char kAttributeCandidate[] = "candidate"; 139 static const char kAttributeCandidate[] = "candidate";
140 static const char kAttributeCandidateTyp[] = "typ"; 140 static const char kAttributeCandidateTyp[] = "typ";
141 static const char kAttributeCandidateRaddr[] = "raddr"; 141 static const char kAttributeCandidateRaddr[] = "raddr";
142 static const char kAttributeCandidateRport[] = "rport"; 142 static const char kAttributeCandidateRport[] = "rport";
143 static const char kAttributeCandidateUfrag[] = "ufrag"; 143 static const char kAttributeCandidateUfrag[] = "ufrag";
144 static const char kAttributeCandidatePwd[] = "pwd"; 144 static const char kAttributeCandidatePwd[] = "pwd";
145 static const char kAttributeCandidateGeneration[] = "generation"; 145 static const char kAttributeCandidateGeneration[] = "generation";
146 static const char kAttributeCandidateCost[] = "cost";
146 static const char kAttributeFingerprint[] = "fingerprint"; 147 static const char kAttributeFingerprint[] = "fingerprint";
147 static const char kAttributeSetup[] = "setup"; 148 static const char kAttributeSetup[] = "setup";
148 static const char kAttributeFmtp[] = "fmtp"; 149 static const char kAttributeFmtp[] = "fmtp";
149 static const char kAttributeRtpmap[] = "rtpmap"; 150 static const char kAttributeRtpmap[] = "rtpmap";
150 static const char kAttributeSctpmap[] = "sctpmap"; 151 static const char kAttributeSctpmap[] = "sctpmap";
151 static const char kAttributeRtcp[] = "rtcp"; 152 static const char kAttributeRtcp[] = "rtcp";
152 static const char kAttributeIceUfrag[] = "ice-ufrag"; 153 static const char kAttributeIceUfrag[] = "ice-ufrag";
153 static const char kAttributeIcePwd[] = "ice-pwd"; 154 static const char kAttributeIcePwd[] = "ice-pwd";
154 static const char kAttributeIceLite[] = "ice-lite"; 155 static const char kAttributeIceLite[] = "ice-lite";
155 static const char kAttributeIceOption[] = "ice-options"; 156 static const char kAttributeIceOption[] = "ice-options";
(...skipping 916 matching lines...) Expand 10 before | Expand all | Expand 10 after
1072 } 1073 }
1073 } 1074 }
1074 1075
1075 // Extension 1076 // Extension
1076 // Though non-standard, we support the ICE ufrag and pwd being signaled on 1077 // Though non-standard, we support the ICE ufrag and pwd being signaled on
1077 // the candidate to avoid issues with confusing which generation a candidate 1078 // the candidate to avoid issues with confusing which generation a candidate
1078 // belongs to when trickling multiple generations at the same time. 1079 // belongs to when trickling multiple generations at the same time.
1079 std::string username; 1080 std::string username;
1080 std::string password; 1081 std::string password;
1081 uint32_t generation = 0; 1082 uint32_t generation = 0;
1083 uint32_t cost = 0;
1082 for (size_t i = current_position; i + 1 < fields.size(); ++i) { 1084 for (size_t i = current_position; i + 1 < fields.size(); ++i) {
1083 // RFC 5245 1085 // RFC 5245
1084 // *(SP extension-att-name SP extension-att-value) 1086 // *(SP extension-att-name SP extension-att-value)
1085 if (fields[i] == kAttributeCandidateGeneration) { 1087 if (fields[i] == kAttributeCandidateGeneration) {
1086 if (!GetValueFromString(first_line, fields[++i], &generation, error)) { 1088 if (!GetValueFromString(first_line, fields[++i], &generation, error)) {
1087 return false; 1089 return false;
1088 } 1090 }
1089 } else if (fields[i] == kAttributeCandidateUfrag) { 1091 } else if (fields[i] == kAttributeCandidateUfrag) {
1090 username = fields[++i]; 1092 username = fields[++i];
1091 } else if (fields[i] == kAttributeCandidatePwd) { 1093 } else if (fields[i] == kAttributeCandidatePwd) {
1092 password = fields[++i]; 1094 password = fields[++i];
1095 } else if (fields[i] == kAttributeCandidateCost) {
1096 if (!GetValueFromString(first_line, fields[++i], &cost, error)) {
1097 return false;
1098 }
1093 } else { 1099 } else {
1094 // Skip the unknown extension. 1100 // Skip the unknown extension.
1095 ++i; 1101 ++i;
1096 } 1102 }
1097 } 1103 }
1098 1104
1099 *candidate = Candidate(component_id, cricket::ProtoToString(protocol), 1105 *candidate = Candidate(component_id, cricket::ProtoToString(protocol),
1100 address, priority, username, password, candidate_type, 1106 address, priority, username, password, candidate_type,
1101 generation, foundation); 1107 generation, foundation);
1102 candidate->set_related_address(related_address); 1108 candidate->set_related_address(related_address);
1103 candidate->set_tcptype(tcptype); 1109 candidate->set_tcptype(tcptype);
1110 candidate->set_network_cost(std::min(cost, cricket::kMaxNetworkCost));
pthatcher1 2016/02/04 23:16:20 I think we should pick "cost" or "network cost" bu
honghaiz3 2016/02/05 01:36:46 Discussed in other comments.
honghaiz3 2016/02/11 21:12:28 I think it might be good to put "cost" on the sign
1104 return true; 1111 return true;
1105 } 1112 }
1106 1113
1107 bool ParseIceOptions(const std::string& line, 1114 bool ParseIceOptions(const std::string& line,
1108 std::vector<std::string>* transport_options, 1115 std::vector<std::string>* transport_options,
1109 SdpParseError* error) { 1116 SdpParseError* error) {
1110 std::string ice_options; 1117 std::string ice_options;
1111 if (!GetValue(line, kAttributeIceOption, &ice_options, error)) { 1118 if (!GetValue(line, kAttributeIceOption, &ice_options, error)) {
1112 return false; 1119 return false;
1113 } 1120 }
(...skipping 654 matching lines...) Expand 10 before | Expand all | Expand 10 after
1768 1775
1769 if (it->protocol() == cricket::TCP_PROTOCOL_NAME) { 1776 if (it->protocol() == cricket::TCP_PROTOCOL_NAME) {
1770 os << kTcpCandidateType << " " << it->tcptype() << " "; 1777 os << kTcpCandidateType << " " << it->tcptype() << " ";
1771 } 1778 }
1772 1779
1773 // Extensions 1780 // Extensions
1774 os << kAttributeCandidateGeneration << " " << it->generation(); 1781 os << kAttributeCandidateGeneration << " " << it->generation();
1775 if (include_ufrag && !it->username().empty()) { 1782 if (include_ufrag && !it->username().empty()) {
1776 os << " " << kAttributeCandidateUfrag << " " << it->username(); 1783 os << " " << kAttributeCandidateUfrag << " " << it->username();
1777 } 1784 }
1785 os << " " << kAttributeCandidateCost << " " << it->network_cost();
1778 1786
1779 AddLine(os.str(), message); 1787 AddLine(os.str(), message);
1780 } 1788 }
1781 } 1789 }
1782 1790
1783 void BuildIceOptions(const std::vector<std::string>& transport_options, 1791 void BuildIceOptions(const std::vector<std::string>& transport_options,
1784 std::string* message) { 1792 std::string* message) {
1785 if (!transport_options.empty()) { 1793 if (!transport_options.empty()) {
1786 std::ostringstream os; 1794 std::ostringstream os;
1787 InitAttrLine(kAttributeIceOption, &os); 1795 InitAttrLine(kAttributeIceOption, &os);
(...skipping 1286 matching lines...) Expand 10 before | Expand all | Expand 10 after
3074 UpdateCodec<AudioContentDescription, cricket::AudioCodec>( 3082 UpdateCodec<AudioContentDescription, cricket::AudioCodec>(
3075 media_desc, payload_type, feedback_param); 3083 media_desc, payload_type, feedback_param);
3076 } else if (media_type == cricket::MEDIA_TYPE_VIDEO) { 3084 } else if (media_type == cricket::MEDIA_TYPE_VIDEO) {
3077 UpdateCodec<VideoContentDescription, cricket::VideoCodec>( 3085 UpdateCodec<VideoContentDescription, cricket::VideoCodec>(
3078 media_desc, payload_type, feedback_param); 3086 media_desc, payload_type, feedback_param);
3079 } 3087 }
3080 return true; 3088 return true;
3081 } 3089 }
3082 3090
3083 } // namespace webrtc 3091 } // namespace webrtc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698