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

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

Issue 2702373002: Reduce usage of tmmbr information structure (Closed)
Patch Set: CreateTmmbrInformation -> FindOrCreateTmmbrInfo 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
« no previous file with comments | « webrtc/modules/rtp_rtcp/source/rtcp_receiver.h ('k') | no next file » | 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) 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 394 matching lines...) Expand 10 before | Expand all | Expand 10 after
405 rtcp::SenderReport sender_report; 405 rtcp::SenderReport sender_report;
406 if (!sender_report.Parse(rtcp_block)) { 406 if (!sender_report.Parse(rtcp_block)) {
407 ++num_skipped_packets_; 407 ++num_skipped_packets_;
408 return; 408 return;
409 } 409 }
410 410
411 const uint32_t remote_ssrc = sender_report.sender_ssrc(); 411 const uint32_t remote_ssrc = sender_report.sender_ssrc();
412 412
413 packet_information->remote_ssrc = remote_ssrc; 413 packet_information->remote_ssrc = remote_ssrc;
414 414
415 CreateTmmbrInformation(remote_ssrc); 415 UpdateTmmbrRemoteIsAlive(remote_ssrc);
416 416
417 TRACE_EVENT_INSTANT2(TRACE_DISABLED_BY_DEFAULT("webrtc_rtp"), "SR", 417 TRACE_EVENT_INSTANT2(TRACE_DISABLED_BY_DEFAULT("webrtc_rtp"), "SR",
418 "remote_ssrc", remote_ssrc, "ssrc", main_ssrc_); 418 "remote_ssrc", remote_ssrc, "ssrc", main_ssrc_);
419 419
420 // Have I received RTP packets from this party? 420 // Have I received RTP packets from this party?
421 if (remote_ssrc_ == remote_ssrc) { 421 if (remote_ssrc_ == remote_ssrc) {
422 // Only signal that we have received a SR when we accept one. 422 // Only signal that we have received a SR when we accept one.
423 packet_information->packet_type_flags |= kRtcpSr; 423 packet_information->packet_type_flags |= kRtcpSr;
424 424
425 // Save the NTP time of this report. 425 // Save the NTP time of this report.
(...skipping 21 matching lines...) Expand all
447 ++num_skipped_packets_; 447 ++num_skipped_packets_;
448 return; 448 return;
449 } 449 }
450 450
451 last_received_rr_ms_ = clock_->TimeInMilliseconds(); 451 last_received_rr_ms_ = clock_->TimeInMilliseconds();
452 452
453 const uint32_t remote_ssrc = receiver_report.sender_ssrc(); 453 const uint32_t remote_ssrc = receiver_report.sender_ssrc();
454 454
455 packet_information->remote_ssrc = remote_ssrc; 455 packet_information->remote_ssrc = remote_ssrc;
456 456
457 CreateTmmbrInformation(remote_ssrc); 457 UpdateTmmbrRemoteIsAlive(remote_ssrc);
458 458
459 TRACE_EVENT_INSTANT2(TRACE_DISABLED_BY_DEFAULT("webrtc_rtp"), "RR", 459 TRACE_EVENT_INSTANT2(TRACE_DISABLED_BY_DEFAULT("webrtc_rtp"), "RR",
460 "remote_ssrc", remote_ssrc, "ssrc", main_ssrc_); 460 "remote_ssrc", remote_ssrc, "ssrc", main_ssrc_);
461 461
462 packet_information->packet_type_flags |= kRtcpRr; 462 packet_information->packet_type_flags |= kRtcpRr;
463 463
464 for (const ReportBlock& report_block : receiver_report.report_blocks()) 464 for (const ReportBlock& report_block : receiver_report.report_blocks())
465 HandleReportBlock(report_block, packet_information, remote_ssrc); 465 HandleReportBlock(report_block, packet_information, remote_ssrc);
466 } 466 }
467 467
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
528 ++report_block_info->num_rtts; 528 ++report_block_info->num_rtts;
529 } 529 }
530 530
531 TRACE_COUNTER_ID1(TRACE_DISABLED_BY_DEFAULT("webrtc_rtp"), "RR_RTT", 531 TRACE_COUNTER_ID1(TRACE_DISABLED_BY_DEFAULT("webrtc_rtp"), "RR_RTT",
532 report_block.source_ssrc(), rtt_ms); 532 report_block.source_ssrc(), rtt_ms);
533 533
534 packet_information->rtt_ms = rtt_ms; 534 packet_information->rtt_ms = rtt_ms;
535 packet_information->report_blocks.push_back(report_block_info->report_block); 535 packet_information->report_blocks.push_back(report_block_info->report_block);
536 } 536 }
537 537
538 void RTCPReceiver::CreateTmmbrInformation(uint32_t remote_ssrc) { 538 RTCPReceiver::TmmbrInformation* RTCPReceiver::FindOrCreateTmmbrInfo(
539 uint32_t remote_ssrc) {
539 // Create or find receive information. 540 // Create or find receive information.
540 TmmbrInformation* tmmbr_info = &tmmbr_infos_[remote_ssrc]; 541 TmmbrInformation* tmmbr_info = &tmmbr_infos_[remote_ssrc];
541 // Update that this remote is alive. 542 // Update that this remote is alive.
542 tmmbr_info->last_time_received_ms = clock_->TimeInMilliseconds(); 543 tmmbr_info->last_time_received_ms = clock_->TimeInMilliseconds();
544 return tmmbr_info;
545 }
546
547 void RTCPReceiver::UpdateTmmbrRemoteIsAlive(uint32_t remote_ssrc) {
548 auto tmmbr_it = tmmbr_infos_.find(remote_ssrc);
549 if (tmmbr_it != tmmbr_infos_.end())
550 tmmbr_it->second.last_time_received_ms = clock_->TimeInMilliseconds();
543 } 551 }
544 552
545 RTCPReceiver::TmmbrInformation* RTCPReceiver::GetTmmbrInformation( 553 RTCPReceiver::TmmbrInformation* RTCPReceiver::GetTmmbrInformation(
546 uint32_t remote_ssrc) { 554 uint32_t remote_ssrc) {
547 auto it = tmmbr_infos_.find(remote_ssrc); 555 auto it = tmmbr_infos_.find(remote_ssrc);
548 if (it == tmmbr_infos_.end()) 556 if (it == tmmbr_infos_.end())
549 return nullptr; 557 return nullptr;
550 return &it->second; 558 return &it->second;
551 } 559 }
552 560
(...skipping 223 matching lines...) Expand 10 before | Expand all | Expand 10 after
776 784
777 void RTCPReceiver::HandleTmmbr(const CommonHeader& rtcp_block, 785 void RTCPReceiver::HandleTmmbr(const CommonHeader& rtcp_block,
778 PacketInformation* packet_information) { 786 PacketInformation* packet_information) {
779 rtcp::Tmmbr tmmbr; 787 rtcp::Tmmbr tmmbr;
780 if (!tmmbr.Parse(rtcp_block)) { 788 if (!tmmbr.Parse(rtcp_block)) {
781 ++num_skipped_packets_; 789 ++num_skipped_packets_;
782 return; 790 return;
783 } 791 }
784 792
785 uint32_t sender_ssrc = tmmbr.sender_ssrc(); 793 uint32_t sender_ssrc = tmmbr.sender_ssrc();
786 TmmbrInformation* receive_info = GetTmmbrInformation(sender_ssrc);
787 if (!receive_info) // This remote SSRC must be saved before.
788 return;
789
790 if (tmmbr.media_ssrc()) { 794 if (tmmbr.media_ssrc()) {
791 // media_ssrc() SHOULD be 0 if same as SenderSSRC. 795 // media_ssrc() SHOULD be 0 if same as SenderSSRC.
792 // In relay mode this is a valid number. 796 // In relay mode this is a valid number.
793 sender_ssrc = tmmbr.media_ssrc(); 797 sender_ssrc = tmmbr.media_ssrc();
794 } 798 }
795 799
796 for (const rtcp::TmmbItem& request : tmmbr.requests()) { 800 for (const rtcp::TmmbItem& request : tmmbr.requests()) {
797 if (main_ssrc_ == request.ssrc() && request.bitrate_bps()) { 801 if (main_ssrc_ != request.ssrc() || request.bitrate_bps() == 0)
798 auto* entry = &receive_info->tmmbr[sender_ssrc]; 802 continue;
799 entry->tmmbr_item = rtcp::TmmbItem(sender_ssrc,
800 request.bitrate_bps(),
801 request.packet_overhead());
802 entry->last_updated_ms = clock_->TimeInMilliseconds();
803 803
804 packet_information->packet_type_flags |= kRtcpTmmbr; 804 TmmbrInformation* tmmbr_info = FindOrCreateTmmbrInfo(tmmbr.sender_ssrc());
805 } 805 auto* entry = &tmmbr_info->tmmbr[sender_ssrc];
806 entry->tmmbr_item = rtcp::TmmbItem(sender_ssrc,
807 request.bitrate_bps(),
808 request.packet_overhead());
809 entry->last_updated_ms = clock_->TimeInMilliseconds();
810
811 packet_information->packet_type_flags |= kRtcpTmmbr;
812 break;
806 } 813 }
807 } 814 }
808 815
809 void RTCPReceiver::HandleTmmbn(const CommonHeader& rtcp_block, 816 void RTCPReceiver::HandleTmmbn(const CommonHeader& rtcp_block,
810 PacketInformation* packet_information) { 817 PacketInformation* packet_information) {
811 rtcp::Tmmbn tmmbn; 818 rtcp::Tmmbn tmmbn;
812 if (!tmmbn.Parse(rtcp_block)) { 819 if (!tmmbn.Parse(rtcp_block)) {
813 ++num_skipped_packets_; 820 ++num_skipped_packets_;
814 return; 821 return;
815 } 822 }
816 823
817 TmmbrInformation* receive_info = GetTmmbrInformation(tmmbn.sender_ssrc()); 824 TmmbrInformation* tmmbr_info = FindOrCreateTmmbrInfo(tmmbn.sender_ssrc());
818 if (!receive_info) // This remote SSRC must be saved before.
819 return;
820 825
821 packet_information->packet_type_flags |= kRtcpTmmbn; 826 packet_information->packet_type_flags |= kRtcpTmmbn;
822 827
823 for (const auto& item : tmmbn.items()) 828 tmmbr_info->tmmbn = tmmbn.items();
824 receive_info->tmmbn.push_back(item);
825 } 829 }
826 830
827 void RTCPReceiver::HandleSrReq(const CommonHeader& rtcp_block, 831 void RTCPReceiver::HandleSrReq(const CommonHeader& rtcp_block,
828 PacketInformation* packet_information) { 832 PacketInformation* packet_information) {
829 rtcp::RapidResyncRequest sr_req; 833 rtcp::RapidResyncRequest sr_req;
830 if (!sr_req.Parse(rtcp_block)) { 834 if (!sr_req.Parse(rtcp_block)) {
831 ++num_skipped_packets_; 835 ++num_skipped_packets_;
832 return; 836 return;
833 } 837 }
834 838
(...skipping 256 matching lines...) Expand 10 before | Expand all | Expand 10 after
1091 } else { 1095 } else {
1092 candidates.push_back(it->second.tmmbr_item); 1096 candidates.push_back(it->second.tmmbr_item);
1093 ++it; 1097 ++it;
1094 } 1098 }
1095 } 1099 }
1096 } 1100 }
1097 return candidates; 1101 return candidates;
1098 } 1102 }
1099 1103
1100 } // namespace webrtc 1104 } // namespace webrtc
OLDNEW
« no previous file with comments | « webrtc/modules/rtp_rtcp/source/rtcp_receiver.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698