OLD | NEW |
---|---|
1 /* | 1 /* |
2 * libjingle | 2 * libjingle |
3 * Copyright 2012 Google Inc. | 3 * Copyright 2012 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 333 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
344 if (stream_handler_container_) | 344 if (stream_handler_container_) |
345 stream_handler_container_->TearDown(); | 345 stream_handler_container_->TearDown(); |
346 } | 346 } |
347 | 347 |
348 bool PeerConnection::Initialize( | 348 bool PeerConnection::Initialize( |
349 const PeerConnectionInterface::RTCConfiguration& configuration, | 349 const PeerConnectionInterface::RTCConfiguration& configuration, |
350 const MediaConstraintsInterface* constraints, | 350 const MediaConstraintsInterface* constraints, |
351 PortAllocatorFactoryInterface* allocator_factory, | 351 PortAllocatorFactoryInterface* allocator_factory, |
352 rtc::scoped_ptr<DtlsIdentityStoreInterface> dtls_identity_store, | 352 rtc::scoped_ptr<DtlsIdentityStoreInterface> dtls_identity_store, |
353 PeerConnectionObserver* observer) { | 353 PeerConnectionObserver* observer) { |
354 if (!InitializeInternal(configuration, constraints, allocator_factory, | |
355 observer)) { | |
356 return false; | |
357 } | |
358 | |
359 // Initialize the WebRtcSession with our optional |dtls_identity_store|. | |
360 // It creates transport channels etc. | |
361 if (!session_->Initialize(factory_->options(), constraints, | |
tommi (sloooow) - chröme
2015/08/18 14:49:35
return session_->Initialize(...);
| |
362 dtls_identity_store.Pass(), configuration)) { | |
363 return false; | |
tommi (sloooow) - chröme
2015/08/18 14:49:35
if we hit this, do we have to undo some of the wor
| |
364 } | |
365 return true; | |
366 } | |
367 | |
368 bool PeerConnection::Initialize( | |
369 const PeerConnectionInterface::RTCConfiguration& configuration, | |
370 const MediaConstraintsInterface* constraints, | |
371 PortAllocatorFactoryInterface* allocator_factory, | |
372 const rtc::scoped_refptr<DtlsCertificate>& certificate, | |
373 PeerConnectionObserver* observer) { | |
374 DCHECK(certificate.get()); | |
375 if (!InitializeInternal(configuration, constraints, allocator_factory, | |
376 observer)) { | |
377 return false; | |
378 } | |
379 | |
380 // Initialize the WebRtcSession with our |certificate|. | |
381 // It creates transport channels etc. | |
382 if (!session_->Initialize(factory_->options(), constraints, | |
tommi (sloooow) - chröme
2015/08/18 14:49:35
nit:
return session_->Initialize(...);
| |
383 certificate, configuration)) { | |
384 return false; | |
385 } | |
386 return true; | |
387 } | |
388 | |
389 bool PeerConnection::InitializeInternal( | |
390 const PeerConnectionInterface::RTCConfiguration& configuration, | |
391 const MediaConstraintsInterface* constraints, | |
392 PortAllocatorFactoryInterface* allocator_factory, | |
393 PeerConnectionObserver* observer) { | |
354 ASSERT(observer != NULL); | 394 ASSERT(observer != NULL); |
355 if (!observer) | 395 if (!observer) |
356 return false; | 396 return false; |
357 observer_ = observer; | 397 observer_ = observer; |
358 | 398 |
359 std::vector<PortAllocatorFactoryInterface::StunConfiguration> stun_config; | 399 std::vector<PortAllocatorFactoryInterface::StunConfiguration> stun_config; |
360 std::vector<PortAllocatorFactoryInterface::TurnConfiguration> turn_config; | 400 std::vector<PortAllocatorFactoryInterface::TurnConfiguration> turn_config; |
361 if (!ParseIceServers(configuration.servers, &stun_config, &turn_config)) { | 401 if (!ParseIceServers(configuration.servers, &stun_config, &turn_config)) { |
362 return false; | 402 return false; |
363 } | 403 } |
(...skipping 28 matching lines...) Expand all Loading... | |
392 port_allocator_->set_step_delay(cricket::kMinimumStepDelay); | 432 port_allocator_->set_step_delay(cricket::kMinimumStepDelay); |
393 | 433 |
394 mediastream_signaling_.reset(new MediaStreamSignaling( | 434 mediastream_signaling_.reset(new MediaStreamSignaling( |
395 factory_->signaling_thread(), this, factory_->channel_manager())); | 435 factory_->signaling_thread(), this, factory_->channel_manager())); |
396 | 436 |
397 session_.reset(new WebRtcSession(factory_->channel_manager(), | 437 session_.reset(new WebRtcSession(factory_->channel_manager(), |
398 factory_->signaling_thread(), | 438 factory_->signaling_thread(), |
399 factory_->worker_thread(), | 439 factory_->worker_thread(), |
400 port_allocator_.get(), | 440 port_allocator_.get(), |
401 mediastream_signaling_.get())); | 441 mediastream_signaling_.get())); |
402 stream_handler_container_.reset(new MediaStreamHandlerContainer( | |
403 session_.get(), session_.get())); | |
404 stats_.reset(new StatsCollector(session_.get())); | |
405 | |
406 // Initialize the WebRtcSession. It creates transport channels etc. | |
407 if (!session_->Initialize(factory_->options(), constraints, | |
408 dtls_identity_store.Pass(), configuration)) | |
409 return false; | |
410 | |
411 // Register PeerConnection as receiver of local ice candidates. | 442 // Register PeerConnection as receiver of local ice candidates. |
412 // All the callbacks will be posted to the application from PeerConnection. | 443 // All the callbacks will be posted to the application from PeerConnection. |
413 session_->RegisterIceObserver(this); | 444 session_->RegisterIceObserver(this); |
414 session_->SignalState.connect(this, &PeerConnection::OnSessionStateChange); | 445 session_->SignalState.connect(this, &PeerConnection::OnSessionStateChange); |
446 | |
447 stream_handler_container_.reset(new MediaStreamHandlerContainer( | |
448 session_.get(), session_.get())); | |
449 stats_.reset(new StatsCollector(session_.get())); | |
415 return true; | 450 return true; |
416 } | 451 } |
417 | 452 |
418 rtc::scoped_refptr<StreamCollectionInterface> | 453 rtc::scoped_refptr<StreamCollectionInterface> |
419 PeerConnection::local_streams() { | 454 PeerConnection::local_streams() { |
420 return mediastream_signaling_->local_streams(); | 455 return mediastream_signaling_->local_streams(); |
421 } | 456 } |
422 | 457 |
423 rtc::scoped_refptr<StreamCollectionInterface> | 458 rtc::scoped_refptr<StreamCollectionInterface> |
424 PeerConnection::remote_streams() { | 459 PeerConnection::remote_streams() { |
(...skipping 480 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
905 if (ice_gathering_state_ != kIceGatheringComplete) { | 940 if (ice_gathering_state_ != kIceGatheringComplete) { |
906 ice_gathering_state_ = kIceGatheringComplete; | 941 ice_gathering_state_ = kIceGatheringComplete; |
907 observer_->OnIceGatheringChange(ice_gathering_state_); | 942 observer_->OnIceGatheringChange(ice_gathering_state_); |
908 } | 943 } |
909 } | 944 } |
910 observer_->OnSignalingChange(signaling_state_); | 945 observer_->OnSignalingChange(signaling_state_); |
911 observer_->OnStateChange(PeerConnectionObserver::kSignalingState); | 946 observer_->OnStateChange(PeerConnectionObserver::kSignalingState); |
912 } | 947 } |
913 | 948 |
914 } // namespace webrtc | 949 } // namespace webrtc |
OLD | NEW |