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

Side by Side Diff: webrtc/api/webrtcsession.cc

Issue 2647593003: Accept SDP with TRANSPORT attributes missing from bundled m= sections. (Closed)
Patch Set: Fix "a=fingerprint" too. Created 3 years, 11 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 2012 The WebRTC project authors. All Rights Reserved. 2 * Copyright 2012 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 146 matching lines...) Expand 10 before | Expand all | Expand 10 after
157 static_cast<const MediaContentDescription*>( 157 static_cast<const MediaContentDescription*>(
158 answer->contents()[i].description); 158 answer->contents()[i].description);
159 if (offer_mdesc->type() != answer_mdesc->type()) { 159 if (offer_mdesc->type() != answer_mdesc->type()) {
160 return false; 160 return false;
161 } 161 }
162 } 162 }
163 return true; 163 return true;
164 } 164 }
165 165
166 // Checks that each non-rejected content has SDES crypto keys or a DTLS 166 // Checks that each non-rejected content has SDES crypto keys or a DTLS
167 // fingerprint. Mismatches, such as replying with a DTLS fingerprint to SDES 167 // fingerprint, unless it's in a BUNDLE group, in which case only the
168 // keys, will be caught in Transport negotiation, and backstopped by Channel's 168 // BUNDLE-tag section needs a ufrag and pwd. Mismatches, such as replying with
pthatcher1 2017/02/17 19:17:32 I translation from spec speak to understandable te
Taylor Brandstetter 2017/02/17 21:49:14 Done.
169 // |srtp_required| check. 169 // a DTLS fingerprint to SDES keys, will be caught in JsepTransport
170 // negotiation, and backstopped by Channel's |srtp_required| check.
170 static bool VerifyCrypto(const SessionDescription* desc, 171 static bool VerifyCrypto(const SessionDescription* desc,
171 bool dtls_enabled, 172 bool dtls_enabled,
172 std::string* error) { 173 std::string* error) {
174 const cricket::ContentGroup* bundle =
175 desc->GetGroupByName(cricket::GROUP_TYPE_BUNDLE);
173 const ContentInfos& contents = desc->contents(); 176 const ContentInfos& contents = desc->contents();
174 for (size_t index = 0; index < contents.size(); ++index) { 177 for (size_t index = 0; index < contents.size(); ++index) {
175 const ContentInfo* cinfo = &contents[index]; 178 const ContentInfo* cinfo = &contents[index];
176 if (cinfo->rejected) { 179 if (cinfo->rejected) {
177 continue; 180 continue;
178 } 181 }
182 if (bundle && bundle->HasContentName(cinfo->name) &&
183 cinfo->name != *(bundle->FirstContentName())) {
184 continue;
pthatcher1 2017/02/17 19:17:32 A comment here like "It's not the first, so it spe
Taylor Brandstetter 2017/02/17 21:49:14 Done.
185 }
179 186
180 // If the content isn't rejected, crypto must be present. 187 // If the content isn't rejected or bundled into another m= section, crypto
188 // must be present.
181 const MediaContentDescription* media = 189 const MediaContentDescription* media =
182 static_cast<const MediaContentDescription*>(cinfo->description); 190 static_cast<const MediaContentDescription*>(cinfo->description);
183 const TransportInfo* tinfo = desc->GetTransportInfoByName(cinfo->name); 191 const TransportInfo* tinfo = desc->GetTransportInfoByName(cinfo->name);
184 if (!media || !tinfo) { 192 if (!media || !tinfo) {
185 // Something is not right. 193 // Something is not right.
186 LOG(LS_ERROR) << kInvalidSdp; 194 LOG(LS_ERROR) << kInvalidSdp;
187 *error = kInvalidSdp; 195 *error = kInvalidSdp;
188 return false; 196 return false;
189 } 197 }
190 if (dtls_enabled) { 198 if (dtls_enabled) {
191 if (!tinfo->description.identity_fingerprint) { 199 if (!tinfo->description.identity_fingerprint) {
192 LOG(LS_WARNING) << 200 LOG(LS_WARNING) <<
193 "Session description must have DTLS fingerprint if DTLS enabled."; 201 "Session description must have DTLS fingerprint if DTLS enabled.";
194 *error = kSdpWithoutDtlsFingerprint; 202 *error = kSdpWithoutDtlsFingerprint;
195 return false; 203 return false;
196 } 204 }
197 } else { 205 } else {
198 if (media->cryptos().empty()) { 206 if (media->cryptos().empty()) {
199 LOG(LS_WARNING) << 207 LOG(LS_WARNING) <<
200 "Session description must have SDES when DTLS disabled."; 208 "Session description must have SDES when DTLS disabled.";
201 *error = kSdpWithoutSdesCrypto; 209 *error = kSdpWithoutSdesCrypto;
202 return false; 210 return false;
203 } 211 }
204 } 212 }
205 } 213 }
206 214
207 return true; 215 return true;
208 } 216 }
209 217
210 // Checks that each non-rejected content has ice-ufrag and ice-pwd set. 218 // Checks that each non-rejected content has ice-ufrag and ice-pwd set, unless
219 // it's in a BUNDLE group, in which case only the BUNDLE-tag section needs a
220 // ufrag and pwd.
pthatcher1 2017/02/17 19:17:32 Like the comment above, please translate "BUNDLE-t
Taylor Brandstetter 2017/02/17 21:49:14 Done.
211 static bool VerifyIceUfragPwdPresent(const SessionDescription* desc) { 221 static bool VerifyIceUfragPwdPresent(const SessionDescription* desc) {
222 const cricket::ContentGroup* bundle =
223 desc->GetGroupByName(cricket::GROUP_TYPE_BUNDLE);
212 const ContentInfos& contents = desc->contents(); 224 const ContentInfos& contents = desc->contents();
213 for (size_t index = 0; index < contents.size(); ++index) { 225 for (size_t index = 0; index < contents.size(); ++index) {
214 const ContentInfo* cinfo = &contents[index]; 226 const ContentInfo* cinfo = &contents[index];
215 if (cinfo->rejected) { 227 if (cinfo->rejected) {
216 continue; 228 continue;
217 } 229 }
230 if (bundle && bundle->HasContentName(cinfo->name) &&
231 cinfo->name != *(bundle->FirstContentName())) {
232 continue;
233 }
218 234
219 // If the content isn't rejected, ice-ufrag and ice-pwd must be present. 235 // If the content isn't rejected or bundled into another m= section,
236 // ice-ufrag and ice-pwd must be present.
220 const TransportInfo* tinfo = desc->GetTransportInfoByName(cinfo->name); 237 const TransportInfo* tinfo = desc->GetTransportInfoByName(cinfo->name);
221 if (!tinfo) { 238 if (!tinfo) {
222 // Something is not right. 239 // Something is not right.
223 LOG(LS_ERROR) << kInvalidSdp; 240 LOG(LS_ERROR) << kInvalidSdp;
224 return false; 241 return false;
225 } 242 }
226 if (tinfo->description.ice_ufrag.empty() || 243 if (tinfo->description.ice_ufrag.empty() ||
227 tinfo->description.ice_pwd.empty()) { 244 tinfo->description.ice_pwd.empty()) {
228 LOG(LS_ERROR) << "Session description must have ice ufrag and pwd."; 245 LOG(LS_ERROR) << "Session description must have ice ufrag and pwd.";
229 return false; 246 return false;
(...skipping 2195 matching lines...) Expand 10 before | Expand all | Expand 10 after
2425 bool need_to_delete_rtcp = (rtp_data_channel_->rtcp_transport() != nullptr); 2442 bool need_to_delete_rtcp = (rtp_data_channel_->rtcp_transport() != nullptr);
2426 channel_manager_->DestroyRtpDataChannel(rtp_data_channel_.release()); 2443 channel_manager_->DestroyRtpDataChannel(rtp_data_channel_.release());
2427 transport_controller_->DestroyTransportChannel( 2444 transport_controller_->DestroyTransportChannel(
2428 transport_name, cricket::ICE_CANDIDATE_COMPONENT_RTP); 2445 transport_name, cricket::ICE_CANDIDATE_COMPONENT_RTP);
2429 if (need_to_delete_rtcp) { 2446 if (need_to_delete_rtcp) {
2430 transport_controller_->DestroyTransportChannel( 2447 transport_controller_->DestroyTransportChannel(
2431 transport_name, cricket::ICE_CANDIDATE_COMPONENT_RTCP); 2448 transport_name, cricket::ICE_CANDIDATE_COMPONENT_RTCP);
2432 } 2449 }
2433 } 2450 }
2434 } // namespace webrtc 2451 } // namespace webrtc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698