OLD | NEW |
1 /* | 1 /* |
2 * libjingle | 2 * libjingle |
3 * Copyright 2013 Google Inc. | 3 * Copyright 2013 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 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
103 } | 103 } |
104 | 104 |
105 void WebRtcIdentityRequestObserver::OnSuccess( | 105 void WebRtcIdentityRequestObserver::OnSuccess( |
106 rtc::scoped_ptr<rtc::SSLIdentity> identity) { | 106 rtc::scoped_ptr<rtc::SSLIdentity> identity) { |
107 SignalCertificateReady(rtc::RTCCertificate::Create(identity.Pass())); | 107 SignalCertificateReady(rtc::RTCCertificate::Create(identity.Pass())); |
108 } | 108 } |
109 | 109 |
110 // static | 110 // static |
111 void WebRtcSessionDescriptionFactory::CopyCandidatesFromSessionDescription( | 111 void WebRtcSessionDescriptionFactory::CopyCandidatesFromSessionDescription( |
112 const SessionDescriptionInterface* source_desc, | 112 const SessionDescriptionInterface* source_desc, |
| 113 cricket::MediaType media_type, |
113 SessionDescriptionInterface* dest_desc) { | 114 SessionDescriptionInterface* dest_desc) { |
114 if (!source_desc) | 115 if (!source_desc) { |
115 return; | 116 return; |
| 117 } |
| 118 const cricket::ContentInfos& contents = |
| 119 source_desc->description()->contents(); |
| 120 const cricket::ContentInfo* cinfo = |
| 121 GetFirstMediaContent(contents, media_type); |
| 122 if (!cinfo) { |
| 123 return; |
| 124 } |
116 for (size_t m = 0; m < source_desc->number_of_mediasections() && | 125 for (size_t m = 0; m < source_desc->number_of_mediasections() && |
117 m < dest_desc->number_of_mediasections(); ++m) { | 126 m < dest_desc->number_of_mediasections(); ++m) { |
118 const IceCandidateCollection* source_candidates = | 127 if (&contents[m] == cinfo) { |
119 source_desc->candidates(m); | 128 const IceCandidateCollection* source_candidates = |
120 const IceCandidateCollection* dest_candidates = dest_desc->candidates(m); | 129 source_desc->candidates(m); |
121 for (size_t n = 0; n < source_candidates->count(); ++n) { | 130 const IceCandidateCollection* dest_candidates = dest_desc->candidates(m); |
122 const IceCandidateInterface* new_candidate = source_candidates->at(n); | 131 for (size_t n = 0; n < source_candidates->count(); ++n) { |
123 if (!dest_candidates->HasCandidate(new_candidate)) | 132 const IceCandidateInterface* new_candidate = source_candidates->at(n); |
124 dest_desc->AddCandidate(source_candidates->at(n)); | 133 if (!dest_candidates->HasCandidate(new_candidate)) { |
| 134 dest_desc->AddCandidate(source_candidates->at(n)); |
| 135 } |
| 136 } |
| 137 return; |
125 } | 138 } |
126 } | 139 } |
127 } | 140 } |
128 | 141 |
129 // Private constructor called by other constructors. | 142 // Private constructor called by other constructors. |
130 WebRtcSessionDescriptionFactory::WebRtcSessionDescriptionFactory( | 143 WebRtcSessionDescriptionFactory::WebRtcSessionDescriptionFactory( |
131 rtc::Thread* signaling_thread, | 144 rtc::Thread* signaling_thread, |
132 cricket::ChannelManager* channel_manager, | 145 cricket::ChannelManager* channel_manager, |
133 rtc::scoped_ptr<DtlsIdentityStoreInterface> dtls_identity_store, | 146 rtc::scoped_ptr<DtlsIdentityStoreInterface> dtls_identity_store, |
134 const rtc::scoped_refptr<WebRtcIdentityRequestObserver>& | 147 const rtc::scoped_refptr<WebRtcIdentityRequestObserver>& |
(...skipping 247 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
382 ASSERT(session_version_ + 1 > session_version_); | 395 ASSERT(session_version_ + 1 > session_version_); |
383 JsepSessionDescription* offer(new JsepSessionDescription( | 396 JsepSessionDescription* offer(new JsepSessionDescription( |
384 JsepSessionDescription::kOffer)); | 397 JsepSessionDescription::kOffer)); |
385 if (!offer->Initialize(desc, session_id_, | 398 if (!offer->Initialize(desc, session_id_, |
386 rtc::ToString(session_version_++))) { | 399 rtc::ToString(session_version_++))) { |
387 delete offer; | 400 delete offer; |
388 PostCreateSessionDescriptionFailed(request.observer, | 401 PostCreateSessionDescriptionFailed(request.observer, |
389 "Failed to initialize the offer."); | 402 "Failed to initialize the offer."); |
390 return; | 403 return; |
391 } | 404 } |
392 if (session_->local_description() && | 405 if (session_->local_description()) { |
393 !request.options.transport_options.ice_restart) { | |
394 // Include all local ice candidates in the SessionDescription unless | 406 // Include all local ice candidates in the SessionDescription unless |
395 // the an ice restart has been requested. | 407 // an ICE restart has been requested. |
396 CopyCandidatesFromSessionDescription(session_->local_description(), offer); | 408 if (!request.options.audio_ice_restart) { |
| 409 CopyCandidatesFromSessionDescription(session_->local_description(), |
| 410 cricket::MEDIA_TYPE_AUDIO, offer); |
| 411 } |
| 412 if (!request.options.video_ice_restart) { |
| 413 CopyCandidatesFromSessionDescription(session_->local_description(), |
| 414 cricket::MEDIA_TYPE_VIDEO, offer); |
| 415 } |
| 416 if (!request.options.data_ice_restart) { |
| 417 CopyCandidatesFromSessionDescription(session_->local_description(), |
| 418 cricket::MEDIA_TYPE_DATA, offer); |
| 419 } |
397 } | 420 } |
398 PostCreateSessionDescriptionSucceeded(request.observer, offer); | 421 PostCreateSessionDescriptionSucceeded(request.observer, offer); |
399 } | 422 } |
400 | 423 |
401 void WebRtcSessionDescriptionFactory::InternalCreateAnswer( | 424 void WebRtcSessionDescriptionFactory::InternalCreateAnswer( |
402 CreateSessionDescriptionRequest request) { | 425 CreateSessionDescriptionRequest request) { |
403 // According to http://tools.ietf.org/html/rfc5245#section-9.2.1.1 | 426 // According to http://tools.ietf.org/html/rfc5245#section-9.2.1.1 |
404 // an answer should also contain new ice ufrag and password if an offer has | 427 // an answer should also contain new ice ufrag and password if an offer has |
405 // been received with new ufrag and password. | 428 // been received with new ufrag and password. |
406 request.options.transport_options.ice_restart = session_->IceRestartPending(); | 429 request.options.audio_ice_restart = session_->AudioIceRestartPending(); |
| 430 request.options.video_ice_restart = session_->VideoIceRestartPending(); |
| 431 request.options.data_ice_restart = session_->DataIceRestartPending(); |
407 // We should pass current ssl role to the transport description factory, if | 432 // We should pass current ssl role to the transport description factory, if |
408 // there is already an existing ongoing session. | 433 // there is already an existing ongoing session. |
409 rtc::SSLRole ssl_role; | 434 rtc::SSLRole ssl_role; |
410 if (session_->GetSslRole(&ssl_role)) { | 435 if (session_->GetSslRole(&ssl_role)) { |
411 request.options.transport_options.prefer_passive_role = | 436 request.options.transport_options.prefer_passive_role = |
412 (rtc::SSL_SERVER == ssl_role); | 437 (rtc::SSL_SERVER == ssl_role); |
413 } | 438 } |
414 | 439 |
415 cricket::SessionDescription* desc(session_desc_factory_.CreateAnswer( | 440 cricket::SessionDescription* desc(session_desc_factory_.CreateAnswer( |
416 session_->remote_description() | 441 session_->remote_description() |
(...skipping 12 matching lines...) Expand all Loading... |
429 ASSERT(session_version_ + 1 > session_version_); | 454 ASSERT(session_version_ + 1 > session_version_); |
430 JsepSessionDescription* answer(new JsepSessionDescription( | 455 JsepSessionDescription* answer(new JsepSessionDescription( |
431 JsepSessionDescription::kAnswer)); | 456 JsepSessionDescription::kAnswer)); |
432 if (!answer->Initialize(desc, session_id_, | 457 if (!answer->Initialize(desc, session_id_, |
433 rtc::ToString(session_version_++))) { | 458 rtc::ToString(session_version_++))) { |
434 delete answer; | 459 delete answer; |
435 PostCreateSessionDescriptionFailed(request.observer, | 460 PostCreateSessionDescriptionFailed(request.observer, |
436 "Failed to initialize the answer."); | 461 "Failed to initialize the answer."); |
437 return; | 462 return; |
438 } | 463 } |
439 if (session_->local_description() && | 464 if (session_->local_description()) { |
440 !request.options.transport_options.ice_restart) { | |
441 // Include all local ice candidates in the SessionDescription unless | 465 // Include all local ice candidates in the SessionDescription unless |
442 // the remote peer has requested an ice restart. | 466 // the remote peer has requested an ICE restart. |
443 CopyCandidatesFromSessionDescription(session_->local_description(), answer); | 467 if (!request.options.audio_ice_restart) { |
| 468 CopyCandidatesFromSessionDescription(session_->local_description(), |
| 469 cricket::MEDIA_TYPE_AUDIO, answer); |
| 470 } |
| 471 if (!request.options.video_ice_restart) { |
| 472 CopyCandidatesFromSessionDescription(session_->local_description(), |
| 473 cricket::MEDIA_TYPE_VIDEO, answer); |
| 474 } |
| 475 if (!request.options.data_ice_restart) { |
| 476 CopyCandidatesFromSessionDescription(session_->local_description(), |
| 477 cricket::MEDIA_TYPE_DATA, answer); |
| 478 } |
444 } | 479 } |
445 session_->ResetIceRestartLatch(); | |
446 PostCreateSessionDescriptionSucceeded(request.observer, answer); | 480 PostCreateSessionDescriptionSucceeded(request.observer, answer); |
447 } | 481 } |
448 | 482 |
449 void WebRtcSessionDescriptionFactory::FailPendingRequests( | 483 void WebRtcSessionDescriptionFactory::FailPendingRequests( |
450 const std::string& reason) { | 484 const std::string& reason) { |
451 ASSERT(signaling_thread_->IsCurrent()); | 485 ASSERT(signaling_thread_->IsCurrent()); |
452 while (!create_session_description_requests_.empty()) { | 486 while (!create_session_description_requests_.empty()) { |
453 const CreateSessionDescriptionRequest& request = | 487 const CreateSessionDescriptionRequest& request = |
454 create_session_description_requests_.front(); | 488 create_session_description_requests_.front(); |
455 PostCreateSessionDescriptionFailed(request.observer, | 489 PostCreateSessionDescriptionFailed(request.observer, |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
499 if (create_session_description_requests_.front().type == | 533 if (create_session_description_requests_.front().type == |
500 CreateSessionDescriptionRequest::kOffer) { | 534 CreateSessionDescriptionRequest::kOffer) { |
501 InternalCreateOffer(create_session_description_requests_.front()); | 535 InternalCreateOffer(create_session_description_requests_.front()); |
502 } else { | 536 } else { |
503 InternalCreateAnswer(create_session_description_requests_.front()); | 537 InternalCreateAnswer(create_session_description_requests_.front()); |
504 } | 538 } |
505 create_session_description_requests_.pop(); | 539 create_session_description_requests_.pop(); |
506 } | 540 } |
507 } | 541 } |
508 } // namespace webrtc | 542 } // namespace webrtc |
OLD | NEW |