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

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: Cleanup 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 DTLSIdentityServiceInterface* dtls_identity_service, 352 DTLSIdentityServiceInterface* dtls_identity_service,
353 PeerConnectionObserver* observer) { 353 PeerConnectionObserver* observer) {
354 if (!InitializeCommon(configuration, constraints, allocator_factory,
355 observer)) {
356 if (dtls_identity_service) {
357 // Since we have the ownership of |dtls_identity_service| and will not
358 // pass it to WebRtcSession::Initialize it is our job to delete it.
359 delete dtls_identity_service;
360 }
361 return false;
362 }
363
364 // Initialize the WebRtcSession with our optional |dtls_identity_service|.
365 // It creates transport channels etc.
366 // Note: |session_| takes ownership of |dtls_identity_service|.
367 if (!session_->Initialize(factory_->options(), constraints,
368 dtls_identity_service, configuration)) {
369 return false;
370 }
371 InitializeSessionAfterInit();
372 return true;
373 }
374
375 bool PeerConnection::Initialize(
376 const PeerConnectionInterface::RTCConfiguration& configuration,
377 const MediaConstraintsInterface* constraints,
378 PortAllocatorFactoryInterface* allocator_factory,
379 rtc::scoped_refptr<DtlsCertificate> certificate,
380 PeerConnectionObserver* observer) {
381 DCHECK(certificate.get());
382
383 if (!InitializeCommon(configuration, constraints, allocator_factory,
384 observer)) {
385 return false;
386 }
387
388 // Initialize the WebRtcSession with our |certificate|.
389 // It creates transport channels etc.
390 if (!session_->Initialize(factory_->options(), constraints,
391 certificate, configuration)) {
392 return false;
393 }
394 InitializeSessionAfterInit();
395 return true;
396 }
397
398 bool PeerConnection::InitializeCommon(
399 const PeerConnectionInterface::RTCConfiguration& configuration,
400 const MediaConstraintsInterface* constraints,
401 PortAllocatorFactoryInterface* allocator_factory,
402 PeerConnectionObserver* observer) {
354 ASSERT(observer != NULL); 403 ASSERT(observer != NULL);
355 if (!observer) 404 if (!observer)
356 return false; 405 return false;
357 observer_ = observer; 406 observer_ = observer;
358 407
359 std::vector<PortAllocatorFactoryInterface::StunConfiguration> stun_config; 408 std::vector<PortAllocatorFactoryInterface::StunConfiguration> stun_config;
360 std::vector<PortAllocatorFactoryInterface::TurnConfiguration> turn_config; 409 std::vector<PortAllocatorFactoryInterface::TurnConfiguration> turn_config;
361 if (!ParseIceServers(configuration.servers, &stun_config, &turn_config)) { 410 if (!ParseIceServers(configuration.servers, &stun_config, &turn_config)) {
362 return false; 411 return false;
363 } 412 }
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
395 factory_->signaling_thread(), this, factory_->channel_manager())); 444 factory_->signaling_thread(), this, factory_->channel_manager()));
396 445
397 session_.reset(new WebRtcSession(factory_->channel_manager(), 446 session_.reset(new WebRtcSession(factory_->channel_manager(),
398 factory_->signaling_thread(), 447 factory_->signaling_thread(),
399 factory_->worker_thread(), 448 factory_->worker_thread(),
400 port_allocator_.get(), 449 port_allocator_.get(),
401 mediastream_signaling_.get())); 450 mediastream_signaling_.get()));
402 stream_handler_container_.reset(new MediaStreamHandlerContainer( 451 stream_handler_container_.reset(new MediaStreamHandlerContainer(
403 session_.get(), session_.get())); 452 session_.get(), session_.get()));
404 stats_.reset(new StatsCollector(session_.get())); 453 stats_.reset(new StatsCollector(session_.get()));
454 return true;
455 }
405 456
406 // Initialize the WebRtcSession. It creates transport channels etc. 457 void PeerConnection::InitializeSessionAfterInit() {
407 if (!session_->Initialize(factory_->options(), constraints,
408 dtls_identity_service, configuration))
409 return false;
410
411 // Register PeerConnection as receiver of local ice candidates. 458 // Register PeerConnection as receiver of local ice candidates.
412 // All the callbacks will be posted to the application from PeerConnection. 459 // All the callbacks will be posted to the application from PeerConnection.
413 session_->RegisterIceObserver(this); 460 session_->RegisterIceObserver(this);
414 session_->SignalState.connect(this, &PeerConnection::OnSessionStateChange); 461 session_->SignalState.connect(this, &PeerConnection::OnSessionStateChange);
415 return true;
416 } 462 }
417 463
418 rtc::scoped_refptr<StreamCollectionInterface> 464 rtc::scoped_refptr<StreamCollectionInterface>
419 PeerConnection::local_streams() { 465 PeerConnection::local_streams() {
420 return mediastream_signaling_->local_streams(); 466 return mediastream_signaling_->local_streams();
421 } 467 }
422 468
423 rtc::scoped_refptr<StreamCollectionInterface> 469 rtc::scoped_refptr<StreamCollectionInterface>
424 PeerConnection::remote_streams() { 470 PeerConnection::remote_streams() {
425 return mediastream_signaling_->remote_streams(); 471 return mediastream_signaling_->remote_streams();
(...skipping 479 matching lines...) Expand 10 before | Expand all | Expand 10 after
905 if (ice_gathering_state_ != kIceGatheringComplete) { 951 if (ice_gathering_state_ != kIceGatheringComplete) {
906 ice_gathering_state_ = kIceGatheringComplete; 952 ice_gathering_state_ = kIceGatheringComplete;
907 observer_->OnIceGatheringChange(ice_gathering_state_); 953 observer_->OnIceGatheringChange(ice_gathering_state_);
908 } 954 }
909 } 955 }
910 observer_->OnSignalingChange(signaling_state_); 956 observer_->OnSignalingChange(signaling_state_);
911 observer_->OnStateChange(PeerConnectionObserver::kSignalingState); 957 observer_->OnStateChange(PeerConnectionObserver::kSignalingState);
912 } 958 }
913 959
914 } // namespace webrtc 960 } // namespace webrtc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698