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

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

Issue 2825333002: Replace first_packet_sent_ms_ in Call. (Closed)
Patch Set: Created 3 years, 8 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 | « no previous file | webrtc/modules/congestion_controller/include/send_side_congestion_controller.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 (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 199 matching lines...) Expand 10 before | Expand all | Expand 10 after
210 210
211 void NotifyBweOfReceivedPacket(const RtpPacketReceived& packet, 211 void NotifyBweOfReceivedPacket(const RtpPacketReceived& packet,
212 MediaType media_type) 212 MediaType media_type)
213 SHARED_LOCKS_REQUIRED(receive_crit_); 213 SHARED_LOCKS_REQUIRED(receive_crit_);
214 214
215 rtc::Optional<RtpPacketReceived> ParseRtpPacket(const uint8_t* packet, 215 rtc::Optional<RtpPacketReceived> ParseRtpPacket(const uint8_t* packet,
216 size_t length, 216 size_t length,
217 const PacketTime& packet_time) 217 const PacketTime& packet_time)
218 SHARED_LOCKS_REQUIRED(receive_crit_); 218 SHARED_LOCKS_REQUIRED(receive_crit_);
219 219
220 void UpdateSendHistograms() EXCLUSIVE_LOCKS_REQUIRED(&bitrate_crit_); 220 void UpdateSendHistograms(int64_t first_sent_packet_ms)
221 EXCLUSIVE_LOCKS_REQUIRED(&bitrate_crit_);
221 void UpdateReceiveHistograms(); 222 void UpdateReceiveHistograms();
222 void UpdateHistograms(); 223 void UpdateHistograms();
223 void UpdateAggregateNetworkState(); 224 void UpdateAggregateNetworkState();
224 225
225 Clock* const clock_; 226 Clock* const clock_;
226 227
227 const int num_cpu_cores_; 228 const int num_cpu_cores_;
228 const std::unique_ptr<ProcessThread> module_process_thread_; 229 const std::unique_ptr<ProcessThread> module_process_thread_;
229 const std::unique_ptr<ProcessThread> pacer_thread_; 230 const std::unique_ptr<ProcessThread> pacer_thread_;
230 const std::unique_ptr<CallStats> call_stats_; 231 const std::unique_ptr<CallStats> call_stats_;
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
284 std::map<uint32_t, AudioSendStream*> audio_send_ssrcs_ GUARDED_BY(send_crit_); 285 std::map<uint32_t, AudioSendStream*> audio_send_ssrcs_ GUARDED_BY(send_crit_);
285 std::map<uint32_t, VideoSendStream*> video_send_ssrcs_ GUARDED_BY(send_crit_); 286 std::map<uint32_t, VideoSendStream*> video_send_ssrcs_ GUARDED_BY(send_crit_);
286 std::set<VideoSendStream*> video_send_streams_ GUARDED_BY(send_crit_); 287 std::set<VideoSendStream*> video_send_streams_ GUARDED_BY(send_crit_);
287 288
288 VideoSendStream::RtpStateMap suspended_video_send_ssrcs_; 289 VideoSendStream::RtpStateMap suspended_video_send_ssrcs_;
289 webrtc::RtcEventLog* event_log_; 290 webrtc::RtcEventLog* event_log_;
290 291
291 // The following members are only accessed (exclusively) from one thread and 292 // The following members are only accessed (exclusively) from one thread and
292 // from the destructor, and therefore doesn't need any explicit 293 // from the destructor, and therefore doesn't need any explicit
293 // synchronization. 294 // synchronization.
294 int64_t first_packet_sent_ms_;
295 RateCounter received_bytes_per_second_counter_; 295 RateCounter received_bytes_per_second_counter_;
296 RateCounter received_audio_bytes_per_second_counter_; 296 RateCounter received_audio_bytes_per_second_counter_;
297 RateCounter received_video_bytes_per_second_counter_; 297 RateCounter received_video_bytes_per_second_counter_;
298 RateCounter received_rtcp_bytes_per_second_counter_; 298 RateCounter received_rtcp_bytes_per_second_counter_;
299 299
300 // TODO(holmer): Remove this lock once BitrateController no longer calls 300 // TODO(holmer): Remove this lock once BitrateController no longer calls
301 // OnNetworkChanged from multiple threads. 301 // OnNetworkChanged from multiple threads.
302 rtc::CriticalSection bitrate_crit_; 302 rtc::CriticalSection bitrate_crit_;
303 uint32_t min_allocated_send_bitrate_bps_ GUARDED_BY(&bitrate_crit_); 303 uint32_t min_allocated_send_bitrate_bps_ GUARDED_BY(&bitrate_crit_);
304 uint32_t configured_max_padding_bitrate_bps_ GUARDED_BY(&bitrate_crit_); 304 uint32_t configured_max_padding_bitrate_bps_ GUARDED_BY(&bitrate_crit_);
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
350 module_process_thread_(ProcessThread::Create("ModuleProcessThread")), 350 module_process_thread_(ProcessThread::Create("ModuleProcessThread")),
351 pacer_thread_(ProcessThread::Create("PacerThread")), 351 pacer_thread_(ProcessThread::Create("PacerThread")),
352 call_stats_(new CallStats(clock_)), 352 call_stats_(new CallStats(clock_)),
353 bitrate_allocator_(new BitrateAllocator(this)), 353 bitrate_allocator_(new BitrateAllocator(this)),
354 config_(config), 354 config_(config),
355 audio_network_state_(kNetworkDown), 355 audio_network_state_(kNetworkDown),
356 video_network_state_(kNetworkDown), 356 video_network_state_(kNetworkDown),
357 receive_crit_(RWLockWrapper::CreateRWLock()), 357 receive_crit_(RWLockWrapper::CreateRWLock()),
358 send_crit_(RWLockWrapper::CreateRWLock()), 358 send_crit_(RWLockWrapper::CreateRWLock()),
359 event_log_(config.event_log), 359 event_log_(config.event_log),
360 first_packet_sent_ms_(-1),
361 received_bytes_per_second_counter_(clock_, nullptr, true), 360 received_bytes_per_second_counter_(clock_, nullptr, true),
362 received_audio_bytes_per_second_counter_(clock_, nullptr, true), 361 received_audio_bytes_per_second_counter_(clock_, nullptr, true),
363 received_video_bytes_per_second_counter_(clock_, nullptr, true), 362 received_video_bytes_per_second_counter_(clock_, nullptr, true),
364 received_rtcp_bytes_per_second_counter_(clock_, nullptr, true), 363 received_rtcp_bytes_per_second_counter_(clock_, nullptr, true),
365 min_allocated_send_bitrate_bps_(0), 364 min_allocated_send_bitrate_bps_(0),
366 configured_max_padding_bitrate_bps_(0), 365 configured_max_padding_bitrate_bps_(0),
367 estimated_send_bitrate_kbps_counter_(clock_, nullptr, true), 366 estimated_send_bitrate_kbps_counter_(clock_, nullptr, true),
368 pacer_bitrate_kbps_counter_(clock_, nullptr, true), 367 pacer_bitrate_kbps_counter_(clock_, nullptr, true),
369 remb_(clock_), 368 remb_(clock_),
370 receive_side_cc_(clock_, &remb_, transport_send->packet_router()), 369 receive_side_cc_(clock_, &remb_, transport_send->packet_router()),
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
419 pacer_thread_->DeRegisterModule(transport_send_->send_side_cc()->pacer()); 418 pacer_thread_->DeRegisterModule(transport_send_->send_side_cc()->pacer());
420 pacer_thread_->DeRegisterModule( 419 pacer_thread_->DeRegisterModule(
421 receive_side_cc_.GetRemoteBitrateEstimator(true)); 420 receive_side_cc_.GetRemoteBitrateEstimator(true));
422 module_process_thread_->DeRegisterModule(transport_send_->send_side_cc()); 421 module_process_thread_->DeRegisterModule(transport_send_->send_side_cc());
423 module_process_thread_->DeRegisterModule(&receive_side_cc_); 422 module_process_thread_->DeRegisterModule(&receive_side_cc_);
424 module_process_thread_->DeRegisterModule(call_stats_.get()); 423 module_process_thread_->DeRegisterModule(call_stats_.get());
425 module_process_thread_->Stop(); 424 module_process_thread_->Stop();
426 call_stats_->DeregisterStatsObserver(&receive_side_cc_); 425 call_stats_->DeregisterStatsObserver(&receive_side_cc_);
427 call_stats_->DeregisterStatsObserver(transport_send_->send_side_cc()); 426 call_stats_->DeregisterStatsObserver(transport_send_->send_side_cc());
428 427
428 int64_t first_sent_packet_ms =
429 transport_send_->send_side_cc()->GetFirstPacketTimeMs();
429 // Only update histograms after process threads have been shut down, so that 430 // Only update histograms after process threads have been shut down, so that
430 // they won't try to concurrently update stats. 431 // they won't try to concurrently update stats.
431 { 432 {
432 rtc::CritScope lock(&bitrate_crit_); 433 rtc::CritScope lock(&bitrate_crit_);
433 UpdateSendHistograms(); 434 UpdateSendHistograms(first_sent_packet_ms);
434 } 435 }
435 UpdateReceiveHistograms(); 436 UpdateReceiveHistograms();
436 UpdateHistograms(); 437 UpdateHistograms();
437 438
438 Trace::ReturnTrace(); 439 Trace::ReturnTrace();
439 } 440 }
440 441
441 rtc::Optional<RtpPacketReceived> Call::ParseRtpPacket( 442 rtc::Optional<RtpPacketReceived> Call::ParseRtpPacket(
442 const uint8_t* packet, 443 const uint8_t* packet,
443 size_t length, 444 size_t length,
(...skipping 16 matching lines...) Expand all
460 461
461 return rtc::Optional<RtpPacketReceived>(std::move(parsed_packet)); 462 return rtc::Optional<RtpPacketReceived>(std::move(parsed_packet));
462 } 463 }
463 464
464 void Call::UpdateHistograms() { 465 void Call::UpdateHistograms() {
465 RTC_HISTOGRAM_COUNTS_100000( 466 RTC_HISTOGRAM_COUNTS_100000(
466 "WebRTC.Call.LifetimeInSeconds", 467 "WebRTC.Call.LifetimeInSeconds",
467 (clock_->TimeInMilliseconds() - start_ms_) / 1000); 468 (clock_->TimeInMilliseconds() - start_ms_) / 1000);
468 } 469 }
469 470
470 void Call::UpdateSendHistograms() { 471 void Call::UpdateSendHistograms(int64_t first_sent_packet_ms) {
471 if (first_packet_sent_ms_ == -1) 472 if (first_sent_packet_ms == -1)
472 return; 473 return;
473 int64_t elapsed_sec = 474 int64_t elapsed_sec =
474 (clock_->TimeInMilliseconds() - first_packet_sent_ms_) / 1000; 475 (clock_->TimeInMilliseconds() - first_sent_packet_ms) / 1000;
475 if (elapsed_sec < metrics::kMinRunTimeInSeconds) 476 if (elapsed_sec < metrics::kMinRunTimeInSeconds)
476 return; 477 return;
477 const int kMinRequiredPeriodicSamples = 5; 478 const int kMinRequiredPeriodicSamples = 5;
478 AggregatedStats send_bitrate_stats = 479 AggregatedStats send_bitrate_stats =
479 estimated_send_bitrate_kbps_counter_.ProcessAndGetStats(); 480 estimated_send_bitrate_kbps_counter_.ProcessAndGetStats();
480 if (send_bitrate_stats.num_samples > kMinRequiredPeriodicSamples) { 481 if (send_bitrate_stats.num_samples > kMinRequiredPeriodicSamples) {
481 RTC_HISTOGRAM_COUNTS_100000("WebRTC.Call.EstimatedSendBitrateInKbps", 482 RTC_HISTOGRAM_COUNTS_100000("WebRTC.Call.EstimatedSendBitrateInKbps",
482 send_bitrate_stats.average); 483 send_bitrate_stats.average);
483 LOG(LS_INFO) << "WebRTC.Call.EstimatedSendBitrateInKbps, " 484 LOG(LS_INFO) << "WebRTC.Call.EstimatedSendBitrateInKbps, "
484 << send_bitrate_stats.ToString(); 485 << send_bitrate_stats.ToString();
(...skipping 559 matching lines...) Expand 10 before | Expand all | Expand 10 after
1044 aggregate_state = kNetworkUp; 1045 aggregate_state = kNetworkUp;
1045 } 1046 }
1046 1047
1047 LOG(LS_INFO) << "UpdateAggregateNetworkState: aggregate_state=" 1048 LOG(LS_INFO) << "UpdateAggregateNetworkState: aggregate_state="
1048 << (aggregate_state == kNetworkUp ? "up" : "down"); 1049 << (aggregate_state == kNetworkUp ? "up" : "down");
1049 1050
1050 transport_send_->send_side_cc()->SignalNetworkState(aggregate_state); 1051 transport_send_->send_side_cc()->SignalNetworkState(aggregate_state);
1051 } 1052 }
1052 1053
1053 void Call::OnSentPacket(const rtc::SentPacket& sent_packet) { 1054 void Call::OnSentPacket(const rtc::SentPacket& sent_packet) {
1054 if (first_packet_sent_ms_ == -1)
1055 first_packet_sent_ms_ = clock_->TimeInMilliseconds();
1056 video_send_delay_stats_->OnSentPacket(sent_packet.packet_id, 1055 video_send_delay_stats_->OnSentPacket(sent_packet.packet_id,
1057 clock_->TimeInMilliseconds()); 1056 clock_->TimeInMilliseconds());
1058 transport_send_->send_side_cc()->OnSentPacket(sent_packet); 1057 transport_send_->send_side_cc()->OnSentPacket(sent_packet);
1059 } 1058 }
1060 1059
1061 void Call::OnNetworkChanged(uint32_t target_bitrate_bps, 1060 void Call::OnNetworkChanged(uint32_t target_bitrate_bps,
1062 uint8_t fraction_loss, 1061 uint8_t fraction_loss,
1063 int64_t rtt_ms, 1062 int64_t rtt_ms,
1064 int64_t probing_interval_ms) { 1063 int64_t probing_interval_ms) {
1065 // TODO(perkj): Consider making sure CongestionController operates on 1064 // TODO(perkj): Consider making sure CongestionController operates on
(...skipping 256 matching lines...) Expand 10 before | Expand all | Expand 10 after
1322 (use_send_side_bwe && header.extension.hasTransportSequenceNumber)) { 1321 (use_send_side_bwe && header.extension.hasTransportSequenceNumber)) {
1323 receive_side_cc_.OnReceivedPacket( 1322 receive_side_cc_.OnReceivedPacket(
1324 packet.arrival_time_ms(), packet.payload_size() + packet.padding_size(), 1323 packet.arrival_time_ms(), packet.payload_size() + packet.padding_size(),
1325 header); 1324 header);
1326 } 1325 }
1327 } 1326 }
1328 1327
1329 } // namespace internal 1328 } // namespace internal
1330 1329
1331 } // namespace webrtc 1330 } // namespace webrtc
OLDNEW
« no previous file with comments | « no previous file | webrtc/modules/congestion_controller/include/send_side_congestion_controller.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698