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

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

Issue 2647593003: Accept SDP with TRANSPORT attributes missing from bundled m= sections. (Closed)
Patch Set: Fixing tests due to bool's meaning being reversed in patchset 4 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
« no previous file with comments | « webrtc/pc/peerconnection_unittest.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 145 matching lines...) Expand 10 before | Expand all | Expand 10 after
156 static_cast<const MediaContentDescription*>( 156 static_cast<const MediaContentDescription*>(
157 answer->contents()[i].description); 157 answer->contents()[i].description);
158 if (offer_mdesc->type() != answer_mdesc->type()) { 158 if (offer_mdesc->type() != answer_mdesc->type()) {
159 return false; 159 return false;
160 } 160 }
161 } 161 }
162 return true; 162 return true;
163 } 163 }
164 164
165 // Checks that each non-rejected content has SDES crypto keys or a DTLS 165 // Checks that each non-rejected content has SDES crypto keys or a DTLS
166 // fingerprint. Mismatches, such as replying with a DTLS fingerprint to SDES 166 // fingerprint, unless it's in a BUNDLE group, in which case only the
167 // keys, will be caught in Transport negotiation, and backstopped by Channel's 167 // BUNDLE-tag section (first media section/description in the BUNDLE group)
168 // |srtp_required| check. 168 // needs a ufrag and pwd. Mismatches, such as replying with a DTLS fingerprint
169 // to SDES keys, will be caught in JsepTransport negotiation, and backstopped
170 // by Channel's |srtp_required| check.
169 static bool VerifyCrypto(const SessionDescription* desc, 171 static bool VerifyCrypto(const SessionDescription* desc,
170 bool dtls_enabled, 172 bool dtls_enabled,
171 std::string* error) { 173 std::string* error) {
174 const cricket::ContentGroup* bundle =
175 desc->GetGroupByName(cricket::GROUP_TYPE_BUNDLE);
172 const ContentInfos& contents = desc->contents(); 176 const ContentInfos& contents = desc->contents();
173 for (size_t index = 0; index < contents.size(); ++index) { 177 for (size_t index = 0; index < contents.size(); ++index) {
174 const ContentInfo* cinfo = &contents[index]; 178 const ContentInfo* cinfo = &contents[index];
175 if (cinfo->rejected) { 179 if (cinfo->rejected) {
176 continue; 180 continue;
177 } 181 }
182 if (bundle && bundle->HasContentName(cinfo->name) &&
183 cinfo->name != *(bundle->FirstContentName())) {
184 // This isn't the first media section in the BUNDLE group, so it's not
185 // required to have crypto attributes, since only the crypto attributes
186 // from the first section actually get used.
187 continue;
188 }
178 189
179 // If the content isn't rejected, crypto must be present. 190 // If the content isn't rejected or bundled into another m= section, crypto
191 // must be present.
180 const MediaContentDescription* media = 192 const MediaContentDescription* media =
181 static_cast<const MediaContentDescription*>(cinfo->description); 193 static_cast<const MediaContentDescription*>(cinfo->description);
182 const TransportInfo* tinfo = desc->GetTransportInfoByName(cinfo->name); 194 const TransportInfo* tinfo = desc->GetTransportInfoByName(cinfo->name);
183 if (!media || !tinfo) { 195 if (!media || !tinfo) {
184 // Something is not right. 196 // Something is not right.
185 LOG(LS_ERROR) << kInvalidSdp; 197 LOG(LS_ERROR) << kInvalidSdp;
186 *error = kInvalidSdp; 198 *error = kInvalidSdp;
187 return false; 199 return false;
188 } 200 }
189 if (dtls_enabled) { 201 if (dtls_enabled) {
190 if (!tinfo->description.identity_fingerprint) { 202 if (!tinfo->description.identity_fingerprint) {
191 LOG(LS_WARNING) << 203 LOG(LS_WARNING) <<
192 "Session description must have DTLS fingerprint if DTLS enabled."; 204 "Session description must have DTLS fingerprint if DTLS enabled.";
193 *error = kSdpWithoutDtlsFingerprint; 205 *error = kSdpWithoutDtlsFingerprint;
194 return false; 206 return false;
195 } 207 }
196 } else { 208 } else {
197 if (media->cryptos().empty()) { 209 if (media->cryptos().empty()) {
198 LOG(LS_WARNING) << 210 LOG(LS_WARNING) <<
199 "Session description must have SDES when DTLS disabled."; 211 "Session description must have SDES when DTLS disabled.";
200 *error = kSdpWithoutSdesCrypto; 212 *error = kSdpWithoutSdesCrypto;
201 return false; 213 return false;
202 } 214 }
203 } 215 }
204 } 216 }
205 217
206 return true; 218 return true;
207 } 219 }
208 220
209 // Checks that each non-rejected content has ice-ufrag and ice-pwd set. 221 // Checks that each non-rejected content has ice-ufrag and ice-pwd set, unless
222 // it's in a BUNDLE group, in which case only the BUNDLE-tag section (first
223 // media section/description in the BUNDLE group) needs a ufrag and pwd.
210 static bool VerifyIceUfragPwdPresent(const SessionDescription* desc) { 224 static bool VerifyIceUfragPwdPresent(const SessionDescription* desc) {
225 const cricket::ContentGroup* bundle =
226 desc->GetGroupByName(cricket::GROUP_TYPE_BUNDLE);
211 const ContentInfos& contents = desc->contents(); 227 const ContentInfos& contents = desc->contents();
212 for (size_t index = 0; index < contents.size(); ++index) { 228 for (size_t index = 0; index < contents.size(); ++index) {
213 const ContentInfo* cinfo = &contents[index]; 229 const ContentInfo* cinfo = &contents[index];
214 if (cinfo->rejected) { 230 if (cinfo->rejected) {
215 continue; 231 continue;
216 } 232 }
233 if (bundle && bundle->HasContentName(cinfo->name) &&
234 cinfo->name != *(bundle->FirstContentName())) {
235 // This isn't the first media section in the BUNDLE group, so it's not
236 // required to have ufrag/password, since only the ufrag/password from
237 // the first section actually get used.
238 continue;
239 }
217 240
218 // If the content isn't rejected, ice-ufrag and ice-pwd must be present. 241 // If the content isn't rejected or bundled into another m= section,
242 // ice-ufrag and ice-pwd must be present.
219 const TransportInfo* tinfo = desc->GetTransportInfoByName(cinfo->name); 243 const TransportInfo* tinfo = desc->GetTransportInfoByName(cinfo->name);
220 if (!tinfo) { 244 if (!tinfo) {
221 // Something is not right. 245 // Something is not right.
222 LOG(LS_ERROR) << kInvalidSdp; 246 LOG(LS_ERROR) << kInvalidSdp;
223 return false; 247 return false;
224 } 248 }
225 if (tinfo->description.ice_ufrag.empty() || 249 if (tinfo->description.ice_ufrag.empty() ||
226 tinfo->description.ice_pwd.empty()) { 250 tinfo->description.ice_pwd.empty()) {
227 LOG(LS_ERROR) << "Session description must have ice ufrag and pwd."; 251 LOG(LS_ERROR) << "Session description must have ice ufrag and pwd.";
228 return false; 252 return false;
(...skipping 2130 matching lines...) Expand 10 before | Expand all | Expand 10 after
2359 (rtp_data_channel_->rtcp_dtls_transport() != nullptr); 2383 (rtp_data_channel_->rtcp_dtls_transport() != nullptr);
2360 channel_manager_->DestroyRtpDataChannel(rtp_data_channel_.release()); 2384 channel_manager_->DestroyRtpDataChannel(rtp_data_channel_.release());
2361 transport_controller_->DestroyDtlsTransport( 2385 transport_controller_->DestroyDtlsTransport(
2362 transport_name, cricket::ICE_CANDIDATE_COMPONENT_RTP); 2386 transport_name, cricket::ICE_CANDIDATE_COMPONENT_RTP);
2363 if (need_to_delete_rtcp) { 2387 if (need_to_delete_rtcp) {
2364 transport_controller_->DestroyDtlsTransport( 2388 transport_controller_->DestroyDtlsTransport(
2365 transport_name, cricket::ICE_CANDIDATE_COMPONENT_RTCP); 2389 transport_name, cricket::ICE_CANDIDATE_COMPONENT_RTCP);
2366 } 2390 }
2367 } 2391 }
2368 } // namespace webrtc 2392 } // namespace webrtc
OLDNEW
« no previous file with comments | « webrtc/pc/peerconnection_unittest.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698