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

Side by Side Diff: webrtc/modules/rtp_rtcp/source/rtcp_receiver.cc

Issue 2664163002: Fix perf issue when timinig out receivers infos in RTCP. (Closed)
Patch Set: Fix mistake. Created 3 years, 10 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 * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. 2 * Copyright (c) 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 127 matching lines...) Expand 10 before | Expand all | Expand 10 after
138 138
139 PacketInformation packet_information; 139 PacketInformation packet_information;
140 if (!ParseCompoundPacket(packet, packet + packet_size, &packet_information)) 140 if (!ParseCompoundPacket(packet, packet + packet_size, &packet_information))
141 return false; 141 return false;
142 TriggerCallbacksFromRtcpPacket(packet_information); 142 TriggerCallbacksFromRtcpPacket(packet_information);
143 return true; 143 return true;
144 } 144 }
145 145
146 int64_t RTCPReceiver::LastReceivedReceiverReport() const { 146 int64_t RTCPReceiver::LastReceivedReceiverReport() const {
147 rtc::CritScope lock(&rtcp_receiver_lock_); 147 rtc::CritScope lock(&rtcp_receiver_lock_);
148 int64_t last_received_rr = -1; 148 return last_received_rr_ms_;
149 for (const auto& kv : received_infos_)
150 if (kv.second.last_time_received_ms > last_received_rr)
151 last_received_rr = kv.second.last_time_received_ms;
152 return last_received_rr;
153 } 149 }
154 150
155 void RTCPReceiver::SetRemoteSSRC(uint32_t ssrc) { 151 void RTCPReceiver::SetRemoteSSRC(uint32_t ssrc) {
156 rtc::CritScope lock(&rtcp_receiver_lock_); 152 rtc::CritScope lock(&rtcp_receiver_lock_);
157 // New SSRC reset old reports. 153 // New SSRC reset old reports.
158 memset(&remote_sender_info_, 0, sizeof(remote_sender_info_)); 154 memset(&remote_sender_info_, 0, sizeof(remote_sender_info_));
159 last_received_sr_ntp_.Reset(); 155 last_received_sr_ntp_.Reset();
160 remote_ssrc_ = ssrc; 156 remote_ssrc_ = ssrc;
161 } 157 }
162 158
(...skipping 275 matching lines...) Expand 10 before | Expand all | Expand 10 after
438 } 434 }
439 435
440 void RTCPReceiver::HandleReceiverReport(const CommonHeader& rtcp_block, 436 void RTCPReceiver::HandleReceiverReport(const CommonHeader& rtcp_block,
441 PacketInformation* packet_information) { 437 PacketInformation* packet_information) {
442 rtcp::ReceiverReport receiver_report; 438 rtcp::ReceiverReport receiver_report;
443 if (!receiver_report.Parse(rtcp_block)) { 439 if (!receiver_report.Parse(rtcp_block)) {
444 ++num_skipped_packets_; 440 ++num_skipped_packets_;
445 return; 441 return;
446 } 442 }
447 443
444 last_received_rr_ms_ = clock_->TimeInMilliseconds();
445
448 const uint32_t remote_ssrc = receiver_report.sender_ssrc(); 446 const uint32_t remote_ssrc = receiver_report.sender_ssrc();
449 447
450 packet_information->remote_ssrc = remote_ssrc; 448 packet_information->remote_ssrc = remote_ssrc;
451 449
452 CreateReceiveInformation(remote_ssrc); 450 CreateReceiveInformation(remote_ssrc);
453 451
454 TRACE_EVENT_INSTANT2(TRACE_DISABLED_BY_DEFAULT("webrtc_rtp"), "RR", 452 TRACE_EVENT_INSTANT2(TRACE_DISABLED_BY_DEFAULT("webrtc_rtp"), "RR",
455 "remote_ssrc", remote_ssrc, "ssrc", main_ssrc_); 453 "remote_ssrc", remote_ssrc, "ssrc", main_ssrc_);
456 454
457 packet_information->packet_type_flags |= kRtcpRr; 455 packet_information->packet_type_flags |= kRtcpRr;
(...skipping 13 matching lines...) Expand all
471 469
472 // |report_block.source_ssrc()| is the SSRC identifier of the source to 470 // |report_block.source_ssrc()| is the SSRC identifier of the source to
473 // which the information in this reception report block pertains. 471 // which the information in this reception report block pertains.
474 472
475 // Filter out all report blocks that are not for us. 473 // Filter out all report blocks that are not for us.
476 if (registered_ssrcs_.count(report_block.source_ssrc()) == 0) 474 if (registered_ssrcs_.count(report_block.source_ssrc()) == 0)
477 return; 475 return;
478 476
479 ReportBlockWithRtt* report_block_info = 477 ReportBlockWithRtt* report_block_info =
480 &received_report_blocks_[report_block.source_ssrc()][remote_ssrc]; 478 &received_report_blocks_[report_block.source_ssrc()][remote_ssrc];
481
482 last_received_rr_ms_ = clock_->TimeInMilliseconds();
483 report_block_info->report_block.remoteSSRC = remote_ssrc; 479 report_block_info->report_block.remoteSSRC = remote_ssrc;
484 report_block_info->report_block.sourceSSRC = report_block.source_ssrc(); 480 report_block_info->report_block.sourceSSRC = report_block.source_ssrc();
485 report_block_info->report_block.fractionLost = report_block.fraction_lost(); 481 report_block_info->report_block.fractionLost = report_block.fraction_lost();
486 report_block_info->report_block.cumulativeLost = 482 report_block_info->report_block.cumulativeLost =
487 report_block.cumulative_lost(); 483 report_block.cumulative_lost();
488 if (report_block.extended_high_seq_num() > 484 if (report_block.extended_high_seq_num() >
489 report_block_info->report_block.extendedHighSeqNum) { 485 report_block_info->report_block.extendedHighSeqNum) {
490 // We have successfully delivered new RTP packets to the remote side after 486 // We have successfully delivered new RTP packets to the remote side after
491 // the last RR was sent from the remote side. 487 // the last RR was sent from the remote side.
492 last_increased_sequence_number_ms_ = last_received_rr_ms_; 488 last_increased_sequence_number_ms_ = clock_->TimeInMilliseconds();
493 } 489 }
494 report_block_info->report_block.extendedHighSeqNum = 490 report_block_info->report_block.extendedHighSeqNum =
495 report_block.extended_high_seq_num(); 491 report_block.extended_high_seq_num();
496 report_block_info->report_block.jitter = report_block.jitter(); 492 report_block_info->report_block.jitter = report_block.jitter();
497 report_block_info->report_block.delaySinceLastSR = 493 report_block_info->report_block.delaySinceLastSR =
498 report_block.delay_since_last_sr(); 494 report_block.delay_since_last_sr();
499 report_block_info->report_block.lastSR = report_block.last_sr(); 495 report_block_info->report_block.lastSR = report_block.last_sr();
500 496
501 int64_t rtt_ms = 0; 497 int64_t rtt_ms = 0;
502 uint32_t send_time_ntp = report_block.last_sr(); 498 uint32_t send_time_ntp = report_block.last_sr();
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
572 // Reset the timer to only trigger one log. 568 // Reset the timer to only trigger one log.
573 last_increased_sequence_number_ms_ = 0; 569 last_increased_sequence_number_ms_ = 0;
574 return true; 570 return true;
575 } 571 }
576 return false; 572 return false;
577 } 573 }
578 574
579 bool RTCPReceiver::UpdateRTCPReceiveInformationTimers() { 575 bool RTCPReceiver::UpdateRTCPReceiveInformationTimers() {
580 rtc::CritScope lock(&rtcp_receiver_lock_); 576 rtc::CritScope lock(&rtcp_receiver_lock_);
581 577
582 bool update_bounding_set = false;
583 int64_t now_ms = clock_->TimeInMilliseconds(); 578 int64_t now_ms = clock_->TimeInMilliseconds();
584 // Use audio define since we don't know what interval the remote peer use. 579 // Use audio define since we don't know what interval the remote peer use.
585 int64_t timeouted_ms = now_ms - 5 * RTCP_INTERVAL_AUDIO_MS; 580 int64_t timeout_ms = now_ms - 5 * RTCP_INTERVAL_AUDIO_MS;
586 581
582 if (oldest_received_info_ms_ >= timeout_ms)
583 return false;
584
585 bool update_bounding_set = false;
586 oldest_received_info_ms_ = -1;
587 for (auto receive_info_it = received_infos_.begin(); 587 for (auto receive_info_it = received_infos_.begin();
588 receive_info_it != received_infos_.end();) { 588 receive_info_it != received_infos_.end();) {
589 ReceiveInformation* receive_info = &receive_info_it->second; 589 ReceiveInformation* receive_info = &receive_info_it->second;
590 if (receive_info->last_time_received_ms > 0) { 590 if (receive_info->last_time_received_ms > 0) {
591 if (receive_info->last_time_received_ms < timeouted_ms) { 591 if (receive_info->last_time_received_ms < timeout_ms) {
592 // No rtcp packet for the last 5 regular intervals, reset limitations. 592 // No rtcp packet for the last 5 regular intervals, reset limitations.
593 receive_info->tmmbr.clear(); 593 receive_info->tmmbr.clear();
594 // Prevent that we call this over and over again. 594 // Prevent that we call this over and over again.
595 receive_info->last_time_received_ms = 0; 595 receive_info->last_time_received_ms = 0;
596 // Send new TMMBN to all channels using the default codec. 596 // Send new TMMBN to all channels using the default codec.
597 update_bounding_set = true; 597 update_bounding_set = true;
598 } else if (oldest_received_info_ms_ == -1 ||
599 receive_info->last_time_received_ms <
600 oldest_received_info_ms_) {
601 oldest_received_info_ms_ = receive_info->last_time_received_ms;
598 } 602 }
599 ++receive_info_it; 603 ++receive_info_it;
600 } else if (receive_info->ready_for_delete) { 604 } else if (receive_info->ready_for_delete) {
601 // When we dont have a last_time_received_ms and the object is marked 605 // When we dont have a last_time_received_ms and the object is marked
602 // ready_for_delete it's removed from the map. 606 // ready_for_delete it's removed from the map.
603 receive_info_it = received_infos_.erase(receive_info_it); 607 receive_info_it = received_infos_.erase(receive_info_it);
604 } else { 608 } else {
605 ++receive_info_it; 609 ++receive_info_it;
606 } 610 }
607 } 611 }
(...skipping 455 matching lines...) Expand 10 before | Expand all | Expand 10 after
1063 cName[length] = 0; 1067 cName[length] = 0;
1064 return 0; 1068 return 0;
1065 } 1069 }
1066 1070
1067 std::vector<rtcp::TmmbItem> RTCPReceiver::TmmbrReceived() { 1071 std::vector<rtcp::TmmbItem> RTCPReceiver::TmmbrReceived() {
1068 rtc::CritScope lock(&rtcp_receiver_lock_); 1072 rtc::CritScope lock(&rtcp_receiver_lock_);
1069 std::vector<rtcp::TmmbItem> candidates; 1073 std::vector<rtcp::TmmbItem> candidates;
1070 1074
1071 int64_t now_ms = clock_->TimeInMilliseconds(); 1075 int64_t now_ms = clock_->TimeInMilliseconds();
1072 // Use audio define since we don't know what interval the remote peer use. 1076 // Use audio define since we don't know what interval the remote peer use.
1073 int64_t timeouted_ms = now_ms - 5 * RTCP_INTERVAL_AUDIO_MS; 1077 int64_t timeout_ms = now_ms - 5 * RTCP_INTERVAL_AUDIO_MS;
1074 1078
1075 for (auto& kv : received_infos_) { 1079 for (auto& kv : received_infos_) {
1076 for (auto it = kv.second.tmmbr.begin(); it != kv.second.tmmbr.end();) { 1080 for (auto it = kv.second.tmmbr.begin(); it != kv.second.tmmbr.end();) {
1077 if (it->second.last_updated_ms < timeouted_ms) { 1081 if (it->second.last_updated_ms < timeout_ms) {
1078 // Erase timeout entries. 1082 // Erase timeout entries.
1079 it = kv.second.tmmbr.erase(it); 1083 it = kv.second.tmmbr.erase(it);
1080 } else { 1084 } else {
1081 candidates.push_back(it->second.tmmbr_item); 1085 candidates.push_back(it->second.tmmbr_item);
1082 ++it; 1086 ++it;
1083 } 1087 }
1084 } 1088 }
1085 } 1089 }
1086 return candidates; 1090 return candidates;
1087 } 1091 }
1088 1092
1089 } // namespace webrtc 1093 } // namespace webrtc
OLDNEW
« no previous file with comments | « webrtc/modules/rtp_rtcp/source/rtcp_receiver.h ('k') | webrtc/modules/rtp_rtcp/source/rtp_rtcp_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698