Index: talk/app/webrtc/webrtcsessiondescriptionfactory.cc |
diff --git a/talk/app/webrtc/webrtcsessiondescriptionfactory.cc b/talk/app/webrtc/webrtcsessiondescriptionfactory.cc |
index 25965af79d30f92cddd20b999436d67d4a95f601..2cdf5c039ea98f99945b9213a68860a6b2d44c9e 100644 |
--- a/talk/app/webrtc/webrtcsessiondescriptionfactory.cc |
+++ b/talk/app/webrtc/webrtcsessiondescriptionfactory.cc |
@@ -110,18 +110,31 @@ void WebRtcIdentityRequestObserver::OnSuccess( |
// static |
void WebRtcSessionDescriptionFactory::CopyCandidatesFromSessionDescription( |
const SessionDescriptionInterface* source_desc, |
+ cricket::MediaType media_type, |
SessionDescriptionInterface* dest_desc) { |
- if (!source_desc) |
+ if (!source_desc) { |
return; |
+ } |
+ const cricket::ContentInfos& contents = |
+ source_desc->description()->contents(); |
+ const cricket::ContentInfo* cinfo = |
+ GetFirstMediaContent(contents, media_type); |
+ if (!cinfo) { |
+ return; |
+ } |
for (size_t m = 0; m < source_desc->number_of_mediasections() && |
m < dest_desc->number_of_mediasections(); ++m) { |
- const IceCandidateCollection* source_candidates = |
- source_desc->candidates(m); |
- const IceCandidateCollection* dest_candidates = dest_desc->candidates(m); |
- for (size_t n = 0; n < source_candidates->count(); ++n) { |
- const IceCandidateInterface* new_candidate = source_candidates->at(n); |
- if (!dest_candidates->HasCandidate(new_candidate)) |
- dest_desc->AddCandidate(source_candidates->at(n)); |
+ if (&contents[m] == cinfo) { |
+ const IceCandidateCollection* source_candidates = |
+ source_desc->candidates(m); |
+ const IceCandidateCollection* dest_candidates = dest_desc->candidates(m); |
+ for (size_t n = 0; n < source_candidates->count(); ++n) { |
+ const IceCandidateInterface* new_candidate = source_candidates->at(n); |
+ if (!dest_candidates->HasCandidate(new_candidate)) { |
+ dest_desc->AddCandidate(source_candidates->at(n)); |
+ } |
+ } |
+ return; |
} |
} |
} |
@@ -389,11 +402,21 @@ void WebRtcSessionDescriptionFactory::InternalCreateOffer( |
"Failed to initialize the offer."); |
return; |
} |
- if (session_->local_description() && |
- !request.options.transport_options.ice_restart) { |
+ if (session_->local_description()) { |
// Include all local ice candidates in the SessionDescription unless |
- // the an ice restart has been requested. |
- CopyCandidatesFromSessionDescription(session_->local_description(), offer); |
+ // an ICE restart has been requested. |
+ if (!request.options.audio_ice_restart) { |
+ CopyCandidatesFromSessionDescription(session_->local_description(), |
+ cricket::MEDIA_TYPE_AUDIO, offer); |
+ } |
+ if (!request.options.video_ice_restart) { |
+ CopyCandidatesFromSessionDescription(session_->local_description(), |
+ cricket::MEDIA_TYPE_VIDEO, offer); |
+ } |
+ if (!request.options.data_ice_restart) { |
+ CopyCandidatesFromSessionDescription(session_->local_description(), |
+ cricket::MEDIA_TYPE_DATA, offer); |
+ } |
} |
PostCreateSessionDescriptionSucceeded(request.observer, offer); |
} |
@@ -403,7 +426,9 @@ void WebRtcSessionDescriptionFactory::InternalCreateAnswer( |
// According to http://tools.ietf.org/html/rfc5245#section-9.2.1.1 |
// an answer should also contain new ice ufrag and password if an offer has |
// been received with new ufrag and password. |
- request.options.transport_options.ice_restart = session_->IceRestartPending(); |
+ request.options.audio_ice_restart = session_->AudioIceRestartPending(); |
+ request.options.video_ice_restart = session_->VideoIceRestartPending(); |
+ request.options.data_ice_restart = session_->DataIceRestartPending(); |
// We should pass current ssl role to the transport description factory, if |
// there is already an existing ongoing session. |
rtc::SSLRole ssl_role; |
@@ -436,13 +461,22 @@ void WebRtcSessionDescriptionFactory::InternalCreateAnswer( |
"Failed to initialize the answer."); |
return; |
} |
- if (session_->local_description() && |
- !request.options.transport_options.ice_restart) { |
+ if (session_->local_description()) { |
// Include all local ice candidates in the SessionDescription unless |
- // the remote peer has requested an ice restart. |
- CopyCandidatesFromSessionDescription(session_->local_description(), answer); |
+ // the remote peer has requested an ICE restart. |
+ if (!request.options.audio_ice_restart) { |
+ CopyCandidatesFromSessionDescription(session_->local_description(), |
+ cricket::MEDIA_TYPE_AUDIO, answer); |
+ } |
+ if (!request.options.video_ice_restart) { |
+ CopyCandidatesFromSessionDescription(session_->local_description(), |
+ cricket::MEDIA_TYPE_VIDEO, answer); |
+ } |
+ if (!request.options.data_ice_restart) { |
+ CopyCandidatesFromSessionDescription(session_->local_description(), |
+ cricket::MEDIA_TYPE_DATA, answer); |
+ } |
} |
- session_->ResetIceRestartLatch(); |
PostCreateSessionDescriptionSucceeded(request.observer, answer); |
} |