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

Side by Side Diff: webrtc/pc/peerconnection.cc

Issue 2794943002: Delete MediaController class, move Call ownership to PeerConnection. (Closed)
Patch Set: Move Call ownership to PeerConnection, and pass pointer to WebRtcSession constructor. Created 3 years, 7 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
« no previous file with comments | « webrtc/pc/peerconnection.h ('k') | webrtc/pc/peerconnectionfactory.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 408 matching lines...) Expand 10 before | Expand all | Expand 10 after
419 if (stats_collector_) { 419 if (stats_collector_) {
420 stats_collector_->WaitForPendingRequest(); 420 stats_collector_->WaitForPendingRequest();
421 stats_collector_ = nullptr; 421 stats_collector_ = nullptr;
422 } 422 }
423 // Now destroy session_ before destroying other members, 423 // Now destroy session_ before destroying other members,
424 // because its destruction fires signals (such as VoiceChannelDestroyed) 424 // because its destruction fires signals (such as VoiceChannelDestroyed)
425 // which will trigger some final actions in PeerConnection... 425 // which will trigger some final actions in PeerConnection...
426 session_.reset(nullptr); 426 session_.reset(nullptr);
427 // port_allocator_ lives on the network thread and should be destroyed there. 427 // port_allocator_ lives on the network thread and should be destroyed there.
428 network_thread()->Invoke<void>(RTC_FROM_HERE, 428 network_thread()->Invoke<void>(RTC_FROM_HERE,
429 [this] { port_allocator_.reset(nullptr); }); 429 [this] { port_allocator_.reset(); });
430 // call_ must be destroyed on the worker thread.
431 factory_->worker_thread()->Invoke<void>(RTC_FROM_HERE,
432 [this] { call_.reset(); });
430 } 433 }
431 434
432 bool PeerConnection::Initialize( 435 bool PeerConnection::Initialize(
433 const PeerConnectionInterface::RTCConfiguration& configuration, 436 const PeerConnectionInterface::RTCConfiguration& configuration,
434 std::unique_ptr<cricket::PortAllocator> allocator, 437 std::unique_ptr<cricket::PortAllocator> allocator,
435 std::unique_ptr<rtc::RTCCertificateGeneratorInterface> cert_generator, 438 std::unique_ptr<rtc::RTCCertificateGeneratorInterface> cert_generator,
436 PeerConnectionObserver* observer) { 439 PeerConnectionObserver* observer) {
437 TRACE_EVENT0("webrtc", "PeerConnection::Initialize"); 440 TRACE_EVENT0("webrtc", "PeerConnection::Initialize");
438 if (!allocator) { 441 if (!allocator) {
439 LOG(LS_ERROR) << "PeerConnection initialized without a PortAllocator? " 442 LOG(LS_ERROR) << "PeerConnection initialized without a PortAllocator? "
(...skipping 10 matching lines...) Expand all
450 port_allocator_ = std::move(allocator); 453 port_allocator_ = std::move(allocator);
451 454
452 // The port allocator lives on the network thread and should be initialized 455 // The port allocator lives on the network thread and should be initialized
453 // there. 456 // there.
454 if (!network_thread()->Invoke<bool>( 457 if (!network_thread()->Invoke<bool>(
455 RTC_FROM_HERE, rtc::Bind(&PeerConnection::InitializePortAllocator_n, 458 RTC_FROM_HERE, rtc::Bind(&PeerConnection::InitializePortAllocator_n,
456 this, configuration))) { 459 this, configuration))) {
457 return false; 460 return false;
458 } 461 }
459 462
460 media_controller_.reset(factory_->CreateMediaController( 463 // Call must be constructed on the worker thread.
461 configuration.media_config, event_log_.get())); 464 factory_->worker_thread()->Invoke<void>(
465 RTC_FROM_HERE, rtc::Bind(&PeerConnection::CreateCall_w,
466 this));
462 467
463 session_.reset(new WebRtcSession( 468 session_.reset(new WebRtcSession(
464 media_controller_.get(), factory_->network_thread(), 469 call_.get(), factory_->channel_manager(), configuration.media_config,
470 event_log_.get(),
471 factory_->network_thread(),
465 factory_->worker_thread(), factory_->signaling_thread(), 472 factory_->worker_thread(), factory_->signaling_thread(),
466 port_allocator_.get(), 473 port_allocator_.get(),
467 std::unique_ptr<cricket::TransportController>( 474 std::unique_ptr<cricket::TransportController>(
468 factory_->CreateTransportController( 475 factory_->CreateTransportController(
469 port_allocator_.get(), 476 port_allocator_.get(),
470 configuration.redetermine_role_on_ice_restart)), 477 configuration.redetermine_role_on_ice_restart)),
471 #ifdef HAVE_SCTP 478 #ifdef HAVE_SCTP
472 std::unique_ptr<cricket::SctpTransportInternalFactory>( 479 std::unique_ptr<cricket::SctpTransportInternalFactory>(
473 new cricket::SctpTransportFactory(factory_->network_thread())) 480 new cricket::SctpTransportFactory(factory_->network_thread()))
474 #else 481 #else
(...skipping 805 matching lines...) Expand 10 before | Expand all | Expand 10 after
1280 // Update stats here so that we have the most recent stats for tracks and 1287 // Update stats here so that we have the most recent stats for tracks and
1281 // streams before the channels are closed. 1288 // streams before the channels are closed.
1282 stats_->UpdateStats(kStatsOutputLevelStandard); 1289 stats_->UpdateStats(kStatsOutputLevelStandard);
1283 1290
1284 session_->Close(); 1291 session_->Close();
1285 event_log_.reset(); 1292 event_log_.reset();
1286 network_thread()->Invoke<void>( 1293 network_thread()->Invoke<void>(
1287 RTC_FROM_HERE, 1294 RTC_FROM_HERE,
1288 rtc::Bind(&cricket::PortAllocator::DiscardCandidatePool, 1295 rtc::Bind(&cricket::PortAllocator::DiscardCandidatePool,
1289 port_allocator_.get())); 1296 port_allocator_.get()));
1297
1298 factory_->worker_thread()->Invoke<void>(RTC_FROM_HERE,
1299 [this] { call_.reset(); });
1290 } 1300 }
1291 1301
1292 void PeerConnection::OnSessionStateChange(WebRtcSession* /*session*/, 1302 void PeerConnection::OnSessionStateChange(WebRtcSession* /*session*/,
1293 WebRtcSession::State state) { 1303 WebRtcSession::State state) {
1294 switch (state) { 1304 switch (state) {
1295 case WebRtcSession::STATE_INIT: 1305 case WebRtcSession::STATE_INIT:
1296 ChangeSignalingState(PeerConnectionInterface::kStable); 1306 ChangeSignalingState(PeerConnectionInterface::kStable);
1297 break; 1307 break;
1298 case WebRtcSession::STATE_SENTOFFER: 1308 case WebRtcSession::STATE_SENTOFFER:
1299 ChangeSignalingState(PeerConnectionInterface::kHaveLocalOffer); 1309 ChangeSignalingState(PeerConnectionInterface::kHaveLocalOffer);
(...skipping 1007 matching lines...) Expand 10 before | Expand all | Expand 10 after
2307 return false; 2317 return false;
2308 } 2318 }
2309 return event_log_->StartLogging(file, max_size_bytes); 2319 return event_log_->StartLogging(file, max_size_bytes);
2310 } 2320 }
2311 2321
2312 void PeerConnection::StopRtcEventLog_w() { 2322 void PeerConnection::StopRtcEventLog_w() {
2313 if (event_log_) { 2323 if (event_log_) {
2314 event_log_->StopLogging(); 2324 event_log_->StopLogging();
2315 } 2325 }
2316 } 2326 }
2327
2328 void PeerConnection::CreateCall_w() {
the sun 2017/05/02 20:30:20 DCHECK thread affinity?
nisse-webrtc 2017/05/04 09:24:01 Done.
2329 RTC_DCHECK(!call_);
2330
2331 const int kMinBandwidthBps = 30000;
2332 const int kStartBandwidthBps = 300000;
2333 const int kMaxBandwidthBps = 2000000;
2334
2335 webrtc::Call::Config call_config(event_log_.get());
2336 call_config.audio_state =
2337 factory_->channel_manager() ->media_engine()->GetAudioState();
2338 call_config.bitrate_config.min_bitrate_bps = kMinBandwidthBps;
2339 call_config.bitrate_config.start_bitrate_bps = kStartBandwidthBps;
2340 call_config.bitrate_config.max_bitrate_bps = kMaxBandwidthBps;
2341
2342 call_.reset(webrtc::Call::Create(call_config));
2343 }
2344
2317 } // namespace webrtc 2345 } // namespace webrtc
OLDNEW
« no previous file with comments | « webrtc/pc/peerconnection.h ('k') | webrtc/pc/peerconnectionfactory.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698