OLD | NEW |
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 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
119 static const char kSSrcAttributeLabel[] = "label"; | 119 static const char kSSrcAttributeLabel[] = "label"; |
120 static const char kAttributeSsrcGroup[] = "ssrc-group"; | 120 static const char kAttributeSsrcGroup[] = "ssrc-group"; |
121 static const char kAttributeCrypto[] = "crypto"; | 121 static const char kAttributeCrypto[] = "crypto"; |
122 static const char kAttributeCandidate[] = "candidate"; | 122 static const char kAttributeCandidate[] = "candidate"; |
123 static const char kAttributeCandidateTyp[] = "typ"; | 123 static const char kAttributeCandidateTyp[] = "typ"; |
124 static const char kAttributeCandidateRaddr[] = "raddr"; | 124 static const char kAttributeCandidateRaddr[] = "raddr"; |
125 static const char kAttributeCandidateRport[] = "rport"; | 125 static const char kAttributeCandidateRport[] = "rport"; |
126 static const char kAttributeCandidateUfrag[] = "ufrag"; | 126 static const char kAttributeCandidateUfrag[] = "ufrag"; |
127 static const char kAttributeCandidatePwd[] = "pwd"; | 127 static const char kAttributeCandidatePwd[] = "pwd"; |
128 static const char kAttributeCandidateGeneration[] = "generation"; | 128 static const char kAttributeCandidateGeneration[] = "generation"; |
| 129 static const char kAttributeCandidateNetworkCost[] = "network-cost"; |
129 static const char kAttributeFingerprint[] = "fingerprint"; | 130 static const char kAttributeFingerprint[] = "fingerprint"; |
130 static const char kAttributeSetup[] = "setup"; | 131 static const char kAttributeSetup[] = "setup"; |
131 static const char kAttributeFmtp[] = "fmtp"; | 132 static const char kAttributeFmtp[] = "fmtp"; |
132 static const char kAttributeRtpmap[] = "rtpmap"; | 133 static const char kAttributeRtpmap[] = "rtpmap"; |
133 static const char kAttributeSctpmap[] = "sctpmap"; | 134 static const char kAttributeSctpmap[] = "sctpmap"; |
134 static const char kAttributeRtcp[] = "rtcp"; | 135 static const char kAttributeRtcp[] = "rtcp"; |
135 static const char kAttributeIceUfrag[] = "ice-ufrag"; | 136 static const char kAttributeIceUfrag[] = "ice-ufrag"; |
136 static const char kAttributeIcePwd[] = "ice-pwd"; | 137 static const char kAttributeIcePwd[] = "ice-pwd"; |
137 static const char kAttributeIceLite[] = "ice-lite"; | 138 static const char kAttributeIceLite[] = "ice-lite"; |
138 static const char kAttributeIceOption[] = "ice-options"; | 139 static const char kAttributeIceOption[] = "ice-options"; |
(...skipping 916 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1055 } | 1056 } |
1056 } | 1057 } |
1057 | 1058 |
1058 // Extension | 1059 // Extension |
1059 // Though non-standard, we support the ICE ufrag and pwd being signaled on | 1060 // Though non-standard, we support the ICE ufrag and pwd being signaled on |
1060 // the candidate to avoid issues with confusing which generation a candidate | 1061 // the candidate to avoid issues with confusing which generation a candidate |
1061 // belongs to when trickling multiple generations at the same time. | 1062 // belongs to when trickling multiple generations at the same time. |
1062 std::string username; | 1063 std::string username; |
1063 std::string password; | 1064 std::string password; |
1064 uint32_t generation = 0; | 1065 uint32_t generation = 0; |
| 1066 uint32_t network_cost = 0; |
1065 for (size_t i = current_position; i + 1 < fields.size(); ++i) { | 1067 for (size_t i = current_position; i + 1 < fields.size(); ++i) { |
1066 // RFC 5245 | 1068 // RFC 5245 |
1067 // *(SP extension-att-name SP extension-att-value) | 1069 // *(SP extension-att-name SP extension-att-value) |
1068 if (fields[i] == kAttributeCandidateGeneration) { | 1070 if (fields[i] == kAttributeCandidateGeneration) { |
1069 if (!GetValueFromString(first_line, fields[++i], &generation, error)) { | 1071 if (!GetValueFromString(first_line, fields[++i], &generation, error)) { |
1070 return false; | 1072 return false; |
1071 } | 1073 } |
1072 } else if (fields[i] == kAttributeCandidateUfrag) { | 1074 } else if (fields[i] == kAttributeCandidateUfrag) { |
1073 username = fields[++i]; | 1075 username = fields[++i]; |
1074 } else if (fields[i] == kAttributeCandidatePwd) { | 1076 } else if (fields[i] == kAttributeCandidatePwd) { |
1075 password = fields[++i]; | 1077 password = fields[++i]; |
| 1078 } else if (fields[i] == kAttributeCandidateNetworkCost) { |
| 1079 if (!GetValueFromString(first_line, fields[++i], &network_cost, error)) { |
| 1080 return false; |
| 1081 } |
1076 } else { | 1082 } else { |
1077 // Skip the unknown extension. | 1083 // Skip the unknown extension. |
1078 ++i; | 1084 ++i; |
1079 } | 1085 } |
1080 } | 1086 } |
1081 | 1087 |
1082 *candidate = Candidate(component_id, cricket::ProtoToString(protocol), | 1088 *candidate = Candidate(component_id, cricket::ProtoToString(protocol), |
1083 address, priority, username, password, candidate_type, | 1089 address, priority, username, password, candidate_type, |
1084 generation, foundation); | 1090 generation, foundation); |
1085 candidate->set_related_address(related_address); | 1091 candidate->set_related_address(related_address); |
1086 candidate->set_tcptype(tcptype); | 1092 candidate->set_tcptype(tcptype); |
| 1093 candidate->set_network_cost(std::min(network_cost, cricket::kMaxNetworkCost)); |
1087 return true; | 1094 return true; |
1088 } | 1095 } |
1089 | 1096 |
1090 bool ParseIceOptions(const std::string& line, | 1097 bool ParseIceOptions(const std::string& line, |
1091 std::vector<std::string>* transport_options, | 1098 std::vector<std::string>* transport_options, |
1092 SdpParseError* error) { | 1099 SdpParseError* error) { |
1093 std::string ice_options; | 1100 std::string ice_options; |
1094 if (!GetValue(line, kAttributeIceOption, &ice_options, error)) { | 1101 if (!GetValue(line, kAttributeIceOption, &ice_options, error)) { |
1095 return false; | 1102 return false; |
1096 } | 1103 } |
(...skipping 654 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1751 | 1758 |
1752 if (it->protocol() == cricket::TCP_PROTOCOL_NAME) { | 1759 if (it->protocol() == cricket::TCP_PROTOCOL_NAME) { |
1753 os << kTcpCandidateType << " " << it->tcptype() << " "; | 1760 os << kTcpCandidateType << " " << it->tcptype() << " "; |
1754 } | 1761 } |
1755 | 1762 |
1756 // Extensions | 1763 // Extensions |
1757 os << kAttributeCandidateGeneration << " " << it->generation(); | 1764 os << kAttributeCandidateGeneration << " " << it->generation(); |
1758 if (include_ufrag && !it->username().empty()) { | 1765 if (include_ufrag && !it->username().empty()) { |
1759 os << " " << kAttributeCandidateUfrag << " " << it->username(); | 1766 os << " " << kAttributeCandidateUfrag << " " << it->username(); |
1760 } | 1767 } |
| 1768 if (it->network_cost() > 0) { |
| 1769 os << " " << kAttributeCandidateNetworkCost << " " << it->network_cost(); |
| 1770 } |
1761 | 1771 |
1762 AddLine(os.str(), message); | 1772 AddLine(os.str(), message); |
1763 } | 1773 } |
1764 } | 1774 } |
1765 | 1775 |
1766 void BuildIceOptions(const std::vector<std::string>& transport_options, | 1776 void BuildIceOptions(const std::vector<std::string>& transport_options, |
1767 std::string* message) { | 1777 std::string* message) { |
1768 if (!transport_options.empty()) { | 1778 if (!transport_options.empty()) { |
1769 std::ostringstream os; | 1779 std::ostringstream os; |
1770 InitAttrLine(kAttributeIceOption, &os); | 1780 InitAttrLine(kAttributeIceOption, &os); |
(...skipping 1286 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3057 UpdateCodec<AudioContentDescription, cricket::AudioCodec>( | 3067 UpdateCodec<AudioContentDescription, cricket::AudioCodec>( |
3058 media_desc, payload_type, feedback_param); | 3068 media_desc, payload_type, feedback_param); |
3059 } else if (media_type == cricket::MEDIA_TYPE_VIDEO) { | 3069 } else if (media_type == cricket::MEDIA_TYPE_VIDEO) { |
3060 UpdateCodec<VideoContentDescription, cricket::VideoCodec>( | 3070 UpdateCodec<VideoContentDescription, cricket::VideoCodec>( |
3061 media_desc, payload_type, feedback_param); | 3071 media_desc, payload_type, feedback_param); |
3062 } | 3072 } |
3063 return true; | 3073 return true; |
3064 } | 3074 } |
3065 | 3075 |
3066 } // namespace webrtc | 3076 } // namespace webrtc |
OLD | NEW |