OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2012 The WebRTC project authors. All Rights Reserved. | 2 * Copyright 2012 The WebRTC project authors. All Rights Reserved. |
3 * | 3 * |
4 * Use of this source code is governed by a BSD-style license | 4 * Use of this source code is governed by a BSD-style license |
5 * that can be found in the LICENSE file in the root of the source | 5 * that can be found in the LICENSE file in the root of the source |
6 * tree. An additional intellectual property rights grant can be found | 6 * tree. An additional intellectual property rights grant can be found |
7 * in the file PATENTS. All contributing project authors may | 7 * in the file PATENTS. All contributing project authors may |
8 * be found in the AUTHORS file in the root of the source tree. | 8 * be found in the AUTHORS file in the root of the source tree. |
9 */ | 9 */ |
10 | 10 |
(...skipping 373 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
384 for (auto& kv : session_options->transport_options) { | 384 for (auto& kv : session_options->transport_options) { |
385 kv.second.ice_restart = ice_restart; | 385 kv.second.ice_restart = ice_restart; |
386 } | 386 } |
387 | 387 |
388 if (!constraints) { | 388 if (!constraints) { |
389 return true; | 389 return true; |
390 } | 390 } |
391 return mandatory_constraints_satisfied == constraints->GetMandatory().size(); | 391 return mandatory_constraints_satisfied == constraints->GetMandatory().size(); |
392 } | 392 } |
393 | 393 |
394 PeerConnection::PeerConnection(PeerConnectionFactory* factory) | 394 PeerConnection::PeerConnection(PeerConnectionFactory* factory, |
| 395 std::unique_ptr<RtcEventLog> event_log, |
| 396 std::unique_ptr<Call> call) |
395 : factory_(factory), | 397 : factory_(factory), |
396 observer_(NULL), | 398 observer_(NULL), |
397 uma_observer_(NULL), | 399 uma_observer_(NULL), |
398 event_log_(RtcEventLog::Create()), | 400 event_log_(std::move(event_log)), |
399 signaling_state_(kStable), | 401 signaling_state_(kStable), |
400 ice_connection_state_(kIceConnectionNew), | 402 ice_connection_state_(kIceConnectionNew), |
401 ice_gathering_state_(kIceGatheringNew), | 403 ice_gathering_state_(kIceGatheringNew), |
402 rtcp_cname_(GenerateRtcpCname()), | 404 rtcp_cname_(GenerateRtcpCname()), |
403 local_streams_(StreamCollection::Create()), | 405 local_streams_(StreamCollection::Create()), |
404 remote_streams_(StreamCollection::Create()) {} | 406 remote_streams_(StreamCollection::Create()), |
| 407 call_(std::move(call)) {} |
405 | 408 |
406 PeerConnection::~PeerConnection() { | 409 PeerConnection::~PeerConnection() { |
407 TRACE_EVENT0("webrtc", "PeerConnection::~PeerConnection"); | 410 TRACE_EVENT0("webrtc", "PeerConnection::~PeerConnection"); |
408 RTC_DCHECK(signaling_thread()->IsCurrent()); | 411 RTC_DCHECK(signaling_thread()->IsCurrent()); |
409 // Need to detach RTP senders/receivers from WebRtcSession, | 412 // Need to detach RTP senders/receivers from WebRtcSession, |
410 // since it's about to be destroyed. | 413 // since it's about to be destroyed. |
411 for (const auto& sender : senders_) { | 414 for (const auto& sender : senders_) { |
412 sender->internal()->Stop(); | 415 sender->internal()->Stop(); |
413 } | 416 } |
414 for (const auto& receiver : receivers_) { | 417 for (const auto& receiver : receivers_) { |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
453 port_allocator_ = std::move(allocator); | 456 port_allocator_ = std::move(allocator); |
454 | 457 |
455 // The port allocator lives on the network thread and should be initialized | 458 // The port allocator lives on the network thread and should be initialized |
456 // there. | 459 // there. |
457 if (!network_thread()->Invoke<bool>( | 460 if (!network_thread()->Invoke<bool>( |
458 RTC_FROM_HERE, rtc::Bind(&PeerConnection::InitializePortAllocator_n, | 461 RTC_FROM_HERE, rtc::Bind(&PeerConnection::InitializePortAllocator_n, |
459 this, configuration))) { | 462 this, configuration))) { |
460 return false; | 463 return false; |
461 } | 464 } |
462 | 465 |
463 // Call must be constructed on the worker thread. | |
464 factory_->worker_thread()->Invoke<void>( | |
465 RTC_FROM_HERE, rtc::Bind(&PeerConnection::CreateCall_w, | |
466 this)); | |
467 | 466 |
468 session_.reset(new WebRtcSession( | 467 session_.reset(new WebRtcSession( |
469 call_.get(), factory_->channel_manager(), configuration.media_config, | 468 call_.get(), factory_->channel_manager(), configuration.media_config, |
470 event_log_.get(), | 469 event_log_.get(), |
471 factory_->network_thread(), | 470 factory_->network_thread(), |
472 factory_->worker_thread(), factory_->signaling_thread(), | 471 factory_->worker_thread(), factory_->signaling_thread(), |
473 port_allocator_.get(), | 472 port_allocator_.get(), |
474 std::unique_ptr<cricket::TransportController>( | 473 std::unique_ptr<cricket::TransportController>( |
475 factory_->CreateTransportController( | 474 factory_->CreateTransportController( |
476 port_allocator_.get(), | 475 port_allocator_.get(), |
(...skipping 1891 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2368 } | 2367 } |
2369 return event_log_->StartLogging(file, max_size_bytes); | 2368 return event_log_->StartLogging(file, max_size_bytes); |
2370 } | 2369 } |
2371 | 2370 |
2372 void PeerConnection::StopRtcEventLog_w() { | 2371 void PeerConnection::StopRtcEventLog_w() { |
2373 if (event_log_) { | 2372 if (event_log_) { |
2374 event_log_->StopLogging(); | 2373 event_log_->StopLogging(); |
2375 } | 2374 } |
2376 } | 2375 } |
2377 | 2376 |
2378 void PeerConnection::CreateCall_w() { | |
2379 RTC_DCHECK(!call_); | |
2380 | |
2381 const int kMinBandwidthBps = 30000; | |
2382 const int kStartBandwidthBps = 300000; | |
2383 const int kMaxBandwidthBps = 2000000; | |
2384 | |
2385 webrtc::Call::Config call_config(event_log_.get()); | |
2386 call_config.audio_state = | |
2387 factory_->channel_manager() ->media_engine()->GetAudioState(); | |
2388 call_config.bitrate_config.min_bitrate_bps = kMinBandwidthBps; | |
2389 call_config.bitrate_config.start_bitrate_bps = kStartBandwidthBps; | |
2390 call_config.bitrate_config.max_bitrate_bps = kMaxBandwidthBps; | |
2391 | |
2392 call_.reset(webrtc::Call::Create(call_config)); | |
2393 } | |
2394 | |
2395 } // namespace webrtc | 2377 } // namespace webrtc |
OLD | NEW |