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

Side by Side Diff: webrtc/call/call.cc

Issue 2353033005: Refactoring: move ownership of RtcEventLog from Call to PeerConnection (Closed)
Patch Set: Moved the constructor Created 4 years, 2 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/call/bitrate_estimator_tests.cc ('k') | webrtc/call/call_perf_tests.cc » ('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 (c) 2013 The WebRTC project authors. All Rights Reserved. 2 * Copyright (c) 2013 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 91 matching lines...) Expand 10 before | Expand all | Expand 10 after
102 void OnSentPacket(const rtc::SentPacket& sent_packet) override; 102 void OnSentPacket(const rtc::SentPacket& sent_packet) override;
103 103
104 // Implements BitrateObserver. 104 // Implements BitrateObserver.
105 void OnNetworkChanged(uint32_t bitrate_bps, uint8_t fraction_loss, 105 void OnNetworkChanged(uint32_t bitrate_bps, uint8_t fraction_loss,
106 int64_t rtt_ms) override; 106 int64_t rtt_ms) override;
107 107
108 // Implements BitrateAllocator::LimitObserver. 108 // Implements BitrateAllocator::LimitObserver.
109 void OnAllocationLimitsChanged(uint32_t min_send_bitrate_bps, 109 void OnAllocationLimitsChanged(uint32_t min_send_bitrate_bps,
110 uint32_t max_padding_bitrate_bps) override; 110 uint32_t max_padding_bitrate_bps) override;
111 111
112 bool StartEventLog(rtc::PlatformFile log_file,
113 int64_t max_size_bytes) override {
114 return event_log_->StartLogging(log_file, max_size_bytes);
115 }
116
117 void StopEventLog() override { event_log_->StopLogging(); }
118
119 private: 112 private:
120 DeliveryStatus DeliverRtcp(MediaType media_type, const uint8_t* packet, 113 DeliveryStatus DeliverRtcp(MediaType media_type, const uint8_t* packet,
121 size_t length); 114 size_t length);
122 DeliveryStatus DeliverRtp(MediaType media_type, 115 DeliveryStatus DeliverRtp(MediaType media_type,
123 const uint8_t* packet, 116 const uint8_t* packet,
124 size_t length, 117 size_t length,
125 const PacketTime& packet_time); 118 const PacketTime& packet_time);
126 void ConfigureSync(const std::string& sync_group) 119 void ConfigureSync(const std::string& sync_group)
127 EXCLUSIVE_LOCKS_REQUIRED(receive_crit_); 120 EXCLUSIVE_LOCKS_REQUIRED(receive_crit_);
128 121
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
164 std::map<std::string, AudioReceiveStream*> sync_stream_mapping_ 157 std::map<std::string, AudioReceiveStream*> sync_stream_mapping_
165 GUARDED_BY(receive_crit_); 158 GUARDED_BY(receive_crit_);
166 159
167 std::unique_ptr<RWLockWrapper> send_crit_; 160 std::unique_ptr<RWLockWrapper> send_crit_;
168 // Audio and Video send streams are owned by the client that creates them. 161 // Audio and Video send streams are owned by the client that creates them.
169 std::map<uint32_t, AudioSendStream*> audio_send_ssrcs_ GUARDED_BY(send_crit_); 162 std::map<uint32_t, AudioSendStream*> audio_send_ssrcs_ GUARDED_BY(send_crit_);
170 std::map<uint32_t, VideoSendStream*> video_send_ssrcs_ GUARDED_BY(send_crit_); 163 std::map<uint32_t, VideoSendStream*> video_send_ssrcs_ GUARDED_BY(send_crit_);
171 std::set<VideoSendStream*> video_send_streams_ GUARDED_BY(send_crit_); 164 std::set<VideoSendStream*> video_send_streams_ GUARDED_BY(send_crit_);
172 165
173 VideoSendStream::RtpStateMap suspended_video_send_ssrcs_; 166 VideoSendStream::RtpStateMap suspended_video_send_ssrcs_;
174 167 webrtc::RtcEventLog* event_log_;
175 std::unique_ptr<webrtc::RtcEventLog> event_log_;
176 168
177 // The following members are only accessed (exclusively) from one thread and 169 // The following members are only accessed (exclusively) from one thread and
178 // from the destructor, and therefore doesn't need any explicit 170 // from the destructor, and therefore doesn't need any explicit
179 // synchronization. 171 // synchronization.
180 int64_t first_packet_sent_ms_; 172 int64_t first_packet_sent_ms_;
181 RateCounter received_bytes_per_second_counter_; 173 RateCounter received_bytes_per_second_counter_;
182 RateCounter received_audio_bytes_per_second_counter_; 174 RateCounter received_audio_bytes_per_second_counter_;
183 RateCounter received_video_bytes_per_second_counter_; 175 RateCounter received_video_bytes_per_second_counter_;
184 RateCounter received_rtcp_bytes_per_second_counter_; 176 RateCounter received_rtcp_bytes_per_second_counter_;
185 177
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
230 num_cpu_cores_(CpuInfo::DetectNumberOfCores()), 222 num_cpu_cores_(CpuInfo::DetectNumberOfCores()),
231 module_process_thread_(ProcessThread::Create("ModuleProcessThread")), 223 module_process_thread_(ProcessThread::Create("ModuleProcessThread")),
232 pacer_thread_(ProcessThread::Create("PacerThread")), 224 pacer_thread_(ProcessThread::Create("PacerThread")),
233 call_stats_(new CallStats(clock_)), 225 call_stats_(new CallStats(clock_)),
234 bitrate_allocator_(new BitrateAllocator(this)), 226 bitrate_allocator_(new BitrateAllocator(this)),
235 config_(config), 227 config_(config),
236 audio_network_state_(kNetworkUp), 228 audio_network_state_(kNetworkUp),
237 video_network_state_(kNetworkUp), 229 video_network_state_(kNetworkUp),
238 receive_crit_(RWLockWrapper::CreateRWLock()), 230 receive_crit_(RWLockWrapper::CreateRWLock()),
239 send_crit_(RWLockWrapper::CreateRWLock()), 231 send_crit_(RWLockWrapper::CreateRWLock()),
240 event_log_(RtcEventLog::Create(webrtc::Clock::GetRealTimeClock())), 232 event_log_(config.event_log),
241 first_packet_sent_ms_(-1), 233 first_packet_sent_ms_(-1),
242 received_bytes_per_second_counter_(clock_, nullptr, true), 234 received_bytes_per_second_counter_(clock_, nullptr, true),
243 received_audio_bytes_per_second_counter_(clock_, nullptr, true), 235 received_audio_bytes_per_second_counter_(clock_, nullptr, true),
244 received_video_bytes_per_second_counter_(clock_, nullptr, true), 236 received_video_bytes_per_second_counter_(clock_, nullptr, true),
245 received_rtcp_bytes_per_second_counter_(clock_, nullptr, true), 237 received_rtcp_bytes_per_second_counter_(clock_, nullptr, true),
246 min_allocated_send_bitrate_bps_(0), 238 min_allocated_send_bitrate_bps_(0),
247 configured_max_padding_bitrate_bps_(0), 239 configured_max_padding_bitrate_bps_(0),
248 estimated_send_bitrate_kbps_counter_(clock_, nullptr, true), 240 estimated_send_bitrate_kbps_counter_(clock_, nullptr, true),
249 pacer_bitrate_kbps_counter_(clock_, nullptr, true), 241 pacer_bitrate_kbps_counter_(clock_, nullptr, true),
250 remb_(clock_), 242 remb_(clock_),
251 congestion_controller_( 243 congestion_controller_(
252 new CongestionController(clock_, this, &remb_, event_log_.get())), 244 new CongestionController(clock_, this, &remb_, event_log_)),
253 video_send_delay_stats_(new SendDelayStats(clock_)), 245 video_send_delay_stats_(new SendDelayStats(clock_)),
254 start_ms_(clock_->TimeInMilliseconds()), 246 start_ms_(clock_->TimeInMilliseconds()),
255 worker_queue_("call_worker_queue") { 247 worker_queue_("call_worker_queue") {
256 RTC_DCHECK(configuration_thread_checker_.CalledOnValidThread()); 248 RTC_DCHECK(configuration_thread_checker_.CalledOnValidThread());
249 RTC_DCHECK(config.event_log != nullptr);
257 RTC_DCHECK_GE(config.bitrate_config.min_bitrate_bps, 0); 250 RTC_DCHECK_GE(config.bitrate_config.min_bitrate_bps, 0);
258 RTC_DCHECK_GE(config.bitrate_config.start_bitrate_bps, 251 RTC_DCHECK_GE(config.bitrate_config.start_bitrate_bps,
259 config.bitrate_config.min_bitrate_bps); 252 config.bitrate_config.min_bitrate_bps);
260 if (config.bitrate_config.max_bitrate_bps != -1) { 253 if (config.bitrate_config.max_bitrate_bps != -1) {
261 RTC_DCHECK_GE(config.bitrate_config.max_bitrate_bps, 254 RTC_DCHECK_GE(config.bitrate_config.max_bitrate_bps,
262 config.bitrate_config.start_bitrate_bps); 255 config.bitrate_config.start_bitrate_bps);
263 } 256 }
264
265 Trace::CreateTrace(); 257 Trace::CreateTrace();
266 call_stats_->RegisterStatsObserver(congestion_controller_.get()); 258 call_stats_->RegisterStatsObserver(congestion_controller_.get());
267 259
268 congestion_controller_->SetBweBitrates( 260 congestion_controller_->SetBweBitrates(
269 config_.bitrate_config.min_bitrate_bps, 261 config_.bitrate_config.min_bitrate_bps,
270 config_.bitrate_config.start_bitrate_bps, 262 config_.bitrate_config.start_bitrate_bps,
271 config_.bitrate_config.max_bitrate_bps); 263 config_.bitrate_config.max_bitrate_bps);
272 264
273 module_process_thread_->Start(); 265 module_process_thread_->Start();
274 module_process_thread_->RegisterModule(call_stats_.get()); 266 module_process_thread_->RegisterModule(call_stats_.get());
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after
373 // RTC_DCHECK(configuration_thread_checker_.CalledOnValidThread()); 365 // RTC_DCHECK(configuration_thread_checker_.CalledOnValidThread());
374 return this; 366 return this;
375 } 367 }
376 368
377 webrtc::AudioSendStream* Call::CreateAudioSendStream( 369 webrtc::AudioSendStream* Call::CreateAudioSendStream(
378 const webrtc::AudioSendStream::Config& config) { 370 const webrtc::AudioSendStream::Config& config) {
379 TRACE_EVENT0("webrtc", "Call::CreateAudioSendStream"); 371 TRACE_EVENT0("webrtc", "Call::CreateAudioSendStream");
380 RTC_DCHECK(configuration_thread_checker_.CalledOnValidThread()); 372 RTC_DCHECK(configuration_thread_checker_.CalledOnValidThread());
381 AudioSendStream* send_stream = new AudioSendStream( 373 AudioSendStream* send_stream = new AudioSendStream(
382 config, config_.audio_state, &worker_queue_, congestion_controller_.get(), 374 config, config_.audio_state, &worker_queue_, congestion_controller_.get(),
383 bitrate_allocator_.get(), event_log_.get()); 375 bitrate_allocator_.get(), event_log_);
384 { 376 {
385 WriteLockScoped write_lock(*send_crit_); 377 WriteLockScoped write_lock(*send_crit_);
386 RTC_DCHECK(audio_send_ssrcs_.find(config.rtp.ssrc) == 378 RTC_DCHECK(audio_send_ssrcs_.find(config.rtp.ssrc) ==
387 audio_send_ssrcs_.end()); 379 audio_send_ssrcs_.end());
388 audio_send_ssrcs_[config.rtp.ssrc] = send_stream; 380 audio_send_ssrcs_[config.rtp.ssrc] = send_stream;
389 } 381 }
390 send_stream->SignalNetworkState(audio_network_state_); 382 send_stream->SignalNetworkState(audio_network_state_);
391 UpdateAggregateNetworkState(); 383 UpdateAggregateNetworkState();
392 return send_stream; 384 return send_stream;
393 } 385 }
(...skipping 14 matching lines...) Expand all
408 RTC_DCHECK(num_deleted == 1); 400 RTC_DCHECK(num_deleted == 1);
409 } 401 }
410 UpdateAggregateNetworkState(); 402 UpdateAggregateNetworkState();
411 delete audio_send_stream; 403 delete audio_send_stream;
412 } 404 }
413 405
414 webrtc::AudioReceiveStream* Call::CreateAudioReceiveStream( 406 webrtc::AudioReceiveStream* Call::CreateAudioReceiveStream(
415 const webrtc::AudioReceiveStream::Config& config) { 407 const webrtc::AudioReceiveStream::Config& config) {
416 TRACE_EVENT0("webrtc", "Call::CreateAudioReceiveStream"); 408 TRACE_EVENT0("webrtc", "Call::CreateAudioReceiveStream");
417 RTC_DCHECK(configuration_thread_checker_.CalledOnValidThread()); 409 RTC_DCHECK(configuration_thread_checker_.CalledOnValidThread());
418 AudioReceiveStream* receive_stream = 410 AudioReceiveStream* receive_stream = new AudioReceiveStream(
419 new AudioReceiveStream(congestion_controller_.get(), config, 411 congestion_controller_.get(), config, config_.audio_state, event_log_);
420 config_.audio_state, event_log_.get());
421 { 412 {
422 WriteLockScoped write_lock(*receive_crit_); 413 WriteLockScoped write_lock(*receive_crit_);
423 RTC_DCHECK(audio_receive_ssrcs_.find(config.rtp.remote_ssrc) == 414 RTC_DCHECK(audio_receive_ssrcs_.find(config.rtp.remote_ssrc) ==
424 audio_receive_ssrcs_.end()); 415 audio_receive_ssrcs_.end());
425 audio_receive_ssrcs_[config.rtp.remote_ssrc] = receive_stream; 416 audio_receive_ssrcs_[config.rtp.remote_ssrc] = receive_stream;
426 ConfigureSync(config.sync_group); 417 ConfigureSync(config.sync_group);
427 } 418 }
428 receive_stream->SignalNetworkState(audio_network_state_); 419 receive_stream->SignalNetworkState(audio_network_state_);
429 UpdateAggregateNetworkState(); 420 UpdateAggregateNetworkState();
430 return receive_stream; 421 return receive_stream;
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
463 video_send_delay_stats_->AddSsrcs(config); 454 video_send_delay_stats_->AddSsrcs(config);
464 event_log_->LogVideoSendStreamConfig(config); 455 event_log_->LogVideoSendStreamConfig(config);
465 456
466 // TODO(mflodman): Base the start bitrate on a current bandwidth estimate, if 457 // TODO(mflodman): Base the start bitrate on a current bandwidth estimate, if
467 // the call has already started. 458 // the call has already started.
468 // Copy ssrcs from |config| since |config| is moved. 459 // Copy ssrcs from |config| since |config| is moved.
469 std::vector<uint32_t> ssrcs = config.rtp.ssrcs; 460 std::vector<uint32_t> ssrcs = config.rtp.ssrcs;
470 VideoSendStream* send_stream = new VideoSendStream( 461 VideoSendStream* send_stream = new VideoSendStream(
471 num_cpu_cores_, module_process_thread_.get(), &worker_queue_, 462 num_cpu_cores_, module_process_thread_.get(), &worker_queue_,
472 call_stats_.get(), congestion_controller_.get(), bitrate_allocator_.get(), 463 call_stats_.get(), congestion_controller_.get(), bitrate_allocator_.get(),
473 video_send_delay_stats_.get(), &remb_, event_log_.get(), 464 video_send_delay_stats_.get(), &remb_, event_log_, std::move(config),
474 std::move(config), std::move(encoder_config), 465 std::move(encoder_config), suspended_video_send_ssrcs_);
475 suspended_video_send_ssrcs_);
476 466
477 { 467 {
478 WriteLockScoped write_lock(*send_crit_); 468 WriteLockScoped write_lock(*send_crit_);
479 for (uint32_t ssrc : ssrcs) { 469 for (uint32_t ssrc : ssrcs) {
480 RTC_DCHECK(video_send_ssrcs_.find(ssrc) == video_send_ssrcs_.end()); 470 RTC_DCHECK(video_send_ssrcs_.find(ssrc) == video_send_ssrcs_.end());
481 video_send_ssrcs_[ssrc] = send_stream; 471 video_send_ssrcs_[ssrc] = send_stream;
482 } 472 }
483 video_send_streams_.insert(send_stream); 473 video_send_streams_.insert(send_stream);
484 } 474 }
485 send_stream->SignalNetworkState(video_network_state_); 475 send_stream->SignalNetworkState(video_network_state_);
(...skipping 394 matching lines...) Expand 10 before | Expand all | Expand 10 after
880 } 870 }
881 } 871 }
882 if (media_type == MediaType::ANY || media_type == MediaType::AUDIO) { 872 if (media_type == MediaType::ANY || media_type == MediaType::AUDIO) {
883 ReadLockScoped read_lock(*send_crit_); 873 ReadLockScoped read_lock(*send_crit_);
884 for (auto& kv : audio_send_ssrcs_) { 874 for (auto& kv : audio_send_ssrcs_) {
885 if (kv.second->DeliverRtcp(packet, length)) 875 if (kv.second->DeliverRtcp(packet, length))
886 rtcp_delivered = true; 876 rtcp_delivered = true;
887 } 877 }
888 } 878 }
889 879
890 if (event_log_ && rtcp_delivered) 880 if (rtcp_delivered)
891 event_log_->LogRtcpPacket(kIncomingPacket, media_type, packet, length); 881 event_log_->LogRtcpPacket(kIncomingPacket, media_type, packet, length);
892 882
893 return rtcp_delivered ? DELIVERY_OK : DELIVERY_PACKET_ERROR; 883 return rtcp_delivered ? DELIVERY_OK : DELIVERY_PACKET_ERROR;
894 } 884 }
895 885
896 PacketReceiver::DeliveryStatus Call::DeliverRtp(MediaType media_type, 886 PacketReceiver::DeliveryStatus Call::DeliverRtp(MediaType media_type,
897 const uint8_t* packet, 887 const uint8_t* packet,
898 size_t length, 888 size_t length,
899 const PacketTime& packet_time) { 889 const PacketTime& packet_time) {
900 TRACE_EVENT0("webrtc", "Call::DeliverRtp"); 890 TRACE_EVENT0("webrtc", "Call::DeliverRtp");
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
943 // thread. Then this check can be enabled. 933 // thread. Then this check can be enabled.
944 // RTC_DCHECK(!configuration_thread_checker_.CalledOnValidThread()); 934 // RTC_DCHECK(!configuration_thread_checker_.CalledOnValidThread());
945 if (RtpHeaderParser::IsRtcp(packet, length)) 935 if (RtpHeaderParser::IsRtcp(packet, length))
946 return DeliverRtcp(media_type, packet, length); 936 return DeliverRtcp(media_type, packet, length);
947 937
948 return DeliverRtp(media_type, packet, length, packet_time); 938 return DeliverRtp(media_type, packet, length, packet_time);
949 } 939 }
950 940
951 } // namespace internal 941 } // namespace internal
952 } // namespace webrtc 942 } // namespace webrtc
OLDNEW
« no previous file with comments | « webrtc/call/bitrate_estimator_tests.cc ('k') | webrtc/call/call_perf_tests.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698