@@ -226,6 +226,20 @@ void JingleSession::Close() {
226
226
CloseInternal (OK);
227
227
}
228
228
229
+ void JingleSession::AddPendingRemoteCandidates (Transport* channel,
230
+ const std::string& name) {
231
+ std::list<JingleMessage::NamedCandidate>::iterator it =
232
+ pending_remote_candidates_.begin ();
233
+ while (it != pending_remote_candidates_.end ()) {
234
+ if (it->name == name) {
235
+ channel->AddRemoteCandidate (it->candidate );
236
+ it = pending_remote_candidates_.erase (it);
237
+ } else {
238
+ ++it;
239
+ }
240
+ }
241
+ }
242
+
229
243
void JingleSession::CreateStreamChannel (
230
244
const std::string& name,
231
245
const StreamChannelCallback& callback) {
@@ -237,6 +251,7 @@ void JingleSession::CreateStreamChannel(
237
251
session_manager_->transport_factory_ ->CreateStreamTransport ();
238
252
channel->Initialize (name, this , channel_authenticator.Pass ());
239
253
channel->Connect (callback);
254
+ AddPendingRemoteCandidates (channel.get (), name);
240
255
channels_[name] = channel.release ();
241
256
}
242
257
@@ -251,6 +266,7 @@ void JingleSession::CreateDatagramChannel(
251
266
session_manager_->transport_factory_ ->CreateDatagramTransport ();
252
267
channel->Initialize (name, this , channel_authenticator.Pass ());
253
268
channel->Connect (callback);
269
+ AddPendingRemoteCandidates (channel.get (), name);
254
270
channels_[name] = channel.release ();
255
271
}
256
272
@@ -489,11 +505,13 @@ void JingleSession::ProcessTransportInfo(const JingleMessage& message) {
489
505
message.candidates .begin ();
490
506
it != message.candidates .end (); ++it) {
491
507
ChannelsMap::iterator channel = channels_.find (it->name );
492
- if (channel == channels_.end ()) {
493
- LOG (WARNING) << " Received candidate for unknown channel " << it->name ;
494
- continue ;
508
+ if (channel != channels_.end ()) {
509
+ channel->second ->AddRemoteCandidate (it->candidate );
510
+ } else {
511
+ // Transport info was received before the channel was created.
512
+ // This could happen due to messages being reordered on the wire.
513
+ pending_remote_candidates_.push_back (*it);
495
514
}
496
- channel->second ->AddRemoteCandidate (it->candidate );
497
515
}
498
516
}
499
517
0 commit comments