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

Side by Side Diff: talk/app/webrtc/peerconnection.cc

Issue 1269843005: Added DtlsCertificate, a ref counted object owning an SSLIdentity (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Trying to get iOS to compile Created 5 years, 4 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
OLDNEW
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
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 (!InitializeCommon(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,
362 dtls_identity_store.Pass(), configuration)) {
363 return false;
364 }
365 InitializeSessionAfterInit();
366 return true;
367 }
368
369 bool PeerConnection::Initialize(
370 const PeerConnectionInterface::RTCConfiguration& configuration,
371 const MediaConstraintsInterface* constraints,
372 PortAllocatorFactoryInterface* allocator_factory,
373 const rtc::scoped_refptr<DtlsCertificate>& certificate,
374 PeerConnectionObserver* observer) {
375 DCHECK(certificate.get());
376 if (!InitializeCommon(configuration, constraints, allocator_factory,
377 observer)) {
378 return false;
379 }
380
381 // Initialize the WebRtcSession with our |certificate|.
382 // It creates transport channels etc.
383 if (!session_->Initialize(factory_->options(), constraints,
384 certificate, configuration)) {
385 return false;
386 }
387 InitializeSessionAfterInit();
388 return true;
389 }
390
391 bool PeerConnection::InitializeCommon(
Henrik Grunell WebRTC 2015/08/12 14:46:29 InitializeInternal() is slightly better imo.
hbos 2015/08/14 14:09:38 Done.
392 const PeerConnectionInterface::RTCConfiguration& configuration,
393 const MediaConstraintsInterface* constraints,
394 PortAllocatorFactoryInterface* allocator_factory,
395 PeerConnectionObserver* observer) {
354 ASSERT(observer != NULL); 396 ASSERT(observer != NULL);
355 if (!observer) 397 if (!observer)
356 return false; 398 return false;
357 observer_ = observer; 399 observer_ = observer;
358 400
359 std::vector<PortAllocatorFactoryInterface::StunConfiguration> stun_config; 401 std::vector<PortAllocatorFactoryInterface::StunConfiguration> stun_config;
360 std::vector<PortAllocatorFactoryInterface::TurnConfiguration> turn_config; 402 std::vector<PortAllocatorFactoryInterface::TurnConfiguration> turn_config;
361 if (!ParseIceServers(configuration.servers, &stun_config, &turn_config)) { 403 if (!ParseIceServers(configuration.servers, &stun_config, &turn_config)) {
362 return false; 404 return false;
363 } 405 }
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
395 factory_->signaling_thread(), this, factory_->channel_manager())); 437 factory_->signaling_thread(), this, factory_->channel_manager()));
396 438
397 session_.reset(new WebRtcSession(factory_->channel_manager(), 439 session_.reset(new WebRtcSession(factory_->channel_manager(),
398 factory_->signaling_thread(), 440 factory_->signaling_thread(),
399 factory_->worker_thread(), 441 factory_->worker_thread(),
400 port_allocator_.get(), 442 port_allocator_.get(),
401 mediastream_signaling_.get())); 443 mediastream_signaling_.get()));
402 stream_handler_container_.reset(new MediaStreamHandlerContainer( 444 stream_handler_container_.reset(new MediaStreamHandlerContainer(
403 session_.get(), session_.get())); 445 session_.get(), session_.get()));
404 stats_.reset(new StatsCollector(session_.get())); 446 stats_.reset(new StatsCollector(session_.get()));
447 return true;
448 }
405 449
406 // Initialize the WebRtcSession. It creates transport channels etc. 450 void PeerConnection::InitializeSessionAfterInit() {
Henrik Grunell WebRTC 2015/08/12 14:46:29 Maybe RegisterAsIceObserver()?
hbos 2015/08/14 14:09:38 Function not needed anymore.
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. 451 // Register PeerConnection as receiver of local ice candidates.
412 // All the callbacks will be posted to the application from PeerConnection. 452 // All the callbacks will be posted to the application from PeerConnection.
413 session_->RegisterIceObserver(this); 453 session_->RegisterIceObserver(this);
414 session_->SignalState.connect(this, &PeerConnection::OnSessionStateChange); 454 session_->SignalState.connect(this, &PeerConnection::OnSessionStateChange);
415 return true;
416 } 455 }
417 456
418 rtc::scoped_refptr<StreamCollectionInterface> 457 rtc::scoped_refptr<StreamCollectionInterface>
419 PeerConnection::local_streams() { 458 PeerConnection::local_streams() {
420 return mediastream_signaling_->local_streams(); 459 return mediastream_signaling_->local_streams();
421 } 460 }
422 461
423 rtc::scoped_refptr<StreamCollectionInterface> 462 rtc::scoped_refptr<StreamCollectionInterface>
424 PeerConnection::remote_streams() { 463 PeerConnection::remote_streams() {
425 return mediastream_signaling_->remote_streams(); 464 return mediastream_signaling_->remote_streams();
(...skipping 479 matching lines...) Expand 10 before | Expand all | Expand 10 after
905 if (ice_gathering_state_ != kIceGatheringComplete) { 944 if (ice_gathering_state_ != kIceGatheringComplete) {
906 ice_gathering_state_ = kIceGatheringComplete; 945 ice_gathering_state_ = kIceGatheringComplete;
907 observer_->OnIceGatheringChange(ice_gathering_state_); 946 observer_->OnIceGatheringChange(ice_gathering_state_);
908 } 947 }
909 } 948 }
910 observer_->OnSignalingChange(signaling_state_); 949 observer_->OnSignalingChange(signaling_state_);
911 observer_->OnStateChange(PeerConnectionObserver::kSignalingState); 950 observer_->OnStateChange(PeerConnectionObserver::kSignalingState);
912 } 951 }
913 952
914 } // namespace webrtc 953 } // namespace webrtc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698