Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 66 std::vector<uint16_t> nack_sequence_numbers; | 66 std::vector<uint16_t> nack_sequence_numbers; |
| 67 ReportBlockList report_blocks; | 67 ReportBlockList report_blocks; |
| 68 int64_t rtt_ms = 0; | 68 int64_t rtt_ms = 0; |
| 69 uint8_t sli_picture_id = 0; | 69 uint8_t sli_picture_id = 0; |
| 70 uint64_t rpsi_picture_id = 0; | 70 uint64_t rpsi_picture_id = 0; |
| 71 uint32_t receiver_estimated_max_bitrate_bps = 0; | 71 uint32_t receiver_estimated_max_bitrate_bps = 0; |
| 72 std::unique_ptr<rtcp::TransportFeedback> transport_feedback; | 72 std::unique_ptr<rtcp::TransportFeedback> transport_feedback; |
| 73 rtc::Optional<BitrateAllocation> target_bitrate_allocation; | 73 rtc::Optional<BitrateAllocation> target_bitrate_allocation; |
| 74 }; | 74 }; |
| 75 | 75 |
| 76 struct RTCPReceiver::ReceiveInformation { | 76 struct RTCPReceiver::TmmbrInformation { |
|
nisse-webrtc
2017/02/20 12:28:20
I'm a bit confused about the context here... Can y
danilchap
2017/02/20 12:44:42
Done.
| |
| 77 struct TimedTmmbrItem { | 77 struct TimedTmmbrItem { |
| 78 rtcp::TmmbItem tmmbr_item; | 78 rtcp::TmmbItem tmmbr_item; |
|
nisse-webrtc
2017/02/20 12:28:20
Is it intentional that the type is TmmbItem and no
danilchap
2017/02/20 12:44:42
yes, because it is part of both
TMMBR (Temporary M
| |
| 79 int64_t last_updated_ms; | 79 int64_t last_updated_ms; |
| 80 }; | 80 }; |
| 81 | 81 |
| 82 int64_t last_time_received_ms = 0; | 82 int64_t last_time_received_ms = 0; |
| 83 | 83 |
| 84 bool ready_for_delete = false; | 84 bool ready_for_delete = false; |
| 85 | 85 |
| 86 std::vector<rtcp::TmmbItem> tmmbn; | 86 std::vector<rtcp::TmmbItem> tmmbn; |
| 87 std::map<uint32_t, TimedTmmbrItem> tmmbr; | 87 std::map<uint32_t, TimedTmmbrItem> tmmbr; |
| 88 }; | 88 }; |
| (...skipping 315 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 404 rtcp::SenderReport sender_report; | 404 rtcp::SenderReport sender_report; |
| 405 if (!sender_report.Parse(rtcp_block)) { | 405 if (!sender_report.Parse(rtcp_block)) { |
| 406 ++num_skipped_packets_; | 406 ++num_skipped_packets_; |
| 407 return; | 407 return; |
| 408 } | 408 } |
| 409 | 409 |
| 410 const uint32_t remote_ssrc = sender_report.sender_ssrc(); | 410 const uint32_t remote_ssrc = sender_report.sender_ssrc(); |
| 411 | 411 |
| 412 packet_information->remote_ssrc = remote_ssrc; | 412 packet_information->remote_ssrc = remote_ssrc; |
| 413 | 413 |
| 414 CreateReceiveInformation(remote_ssrc); | 414 CreateTmmbrInformation(remote_ssrc); |
| 415 | 415 |
| 416 TRACE_EVENT_INSTANT2(TRACE_DISABLED_BY_DEFAULT("webrtc_rtp"), "SR", | 416 TRACE_EVENT_INSTANT2(TRACE_DISABLED_BY_DEFAULT("webrtc_rtp"), "SR", |
| 417 "remote_ssrc", remote_ssrc, "ssrc", main_ssrc_); | 417 "remote_ssrc", remote_ssrc, "ssrc", main_ssrc_); |
| 418 | 418 |
| 419 // Have I received RTP packets from this party? | 419 // Have I received RTP packets from this party? |
| 420 if (remote_ssrc_ == remote_ssrc) { | 420 if (remote_ssrc_ == remote_ssrc) { |
| 421 // Only signal that we have received a SR when we accept one. | 421 // Only signal that we have received a SR when we accept one. |
| 422 packet_information->packet_type_flags |= kRtcpSr; | 422 packet_information->packet_type_flags |= kRtcpSr; |
| 423 | 423 |
| 424 // Save the NTP time of this report. | 424 // Save the NTP time of this report. |
| (...skipping 21 matching lines...) Expand all Loading... | |
| 446 ++num_skipped_packets_; | 446 ++num_skipped_packets_; |
| 447 return; | 447 return; |
| 448 } | 448 } |
| 449 | 449 |
| 450 last_received_rr_ms_ = clock_->TimeInMilliseconds(); | 450 last_received_rr_ms_ = clock_->TimeInMilliseconds(); |
| 451 | 451 |
| 452 const uint32_t remote_ssrc = receiver_report.sender_ssrc(); | 452 const uint32_t remote_ssrc = receiver_report.sender_ssrc(); |
| 453 | 453 |
| 454 packet_information->remote_ssrc = remote_ssrc; | 454 packet_information->remote_ssrc = remote_ssrc; |
| 455 | 455 |
| 456 CreateReceiveInformation(remote_ssrc); | 456 CreateTmmbrInformation(remote_ssrc); |
| 457 | 457 |
| 458 TRACE_EVENT_INSTANT2(TRACE_DISABLED_BY_DEFAULT("webrtc_rtp"), "RR", | 458 TRACE_EVENT_INSTANT2(TRACE_DISABLED_BY_DEFAULT("webrtc_rtp"), "RR", |
| 459 "remote_ssrc", remote_ssrc, "ssrc", main_ssrc_); | 459 "remote_ssrc", remote_ssrc, "ssrc", main_ssrc_); |
| 460 | 460 |
| 461 packet_information->packet_type_flags |= kRtcpRr; | 461 packet_information->packet_type_flags |= kRtcpRr; |
| 462 | 462 |
| 463 for (const ReportBlock& report_block : receiver_report.report_blocks()) | 463 for (const ReportBlock& report_block : receiver_report.report_blocks()) |
| 464 HandleReportBlock(report_block, packet_information, remote_ssrc); | 464 HandleReportBlock(report_block, packet_information, remote_ssrc); |
| 465 } | 465 } |
| 466 | 466 |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 527 ++report_block_info->num_rtts; | 527 ++report_block_info->num_rtts; |
| 528 } | 528 } |
| 529 | 529 |
| 530 TRACE_COUNTER_ID1(TRACE_DISABLED_BY_DEFAULT("webrtc_rtp"), "RR_RTT", | 530 TRACE_COUNTER_ID1(TRACE_DISABLED_BY_DEFAULT("webrtc_rtp"), "RR_RTT", |
| 531 report_block.source_ssrc(), rtt_ms); | 531 report_block.source_ssrc(), rtt_ms); |
| 532 | 532 |
| 533 packet_information->rtt_ms = rtt_ms; | 533 packet_information->rtt_ms = rtt_ms; |
| 534 packet_information->report_blocks.push_back(report_block_info->report_block); | 534 packet_information->report_blocks.push_back(report_block_info->report_block); |
| 535 } | 535 } |
| 536 | 536 |
| 537 void RTCPReceiver::CreateReceiveInformation(uint32_t remote_ssrc) { | 537 void RTCPReceiver::CreateTmmbrInformation(uint32_t remote_ssrc) { |
| 538 // Create or find receive information. | 538 // Create or find receive information. |
| 539 ReceiveInformation* receive_info = &received_infos_[remote_ssrc]; | 539 TmmbrInformation* tmmbr_info = &tmmbr_infos_[remote_ssrc]; |
| 540 // Update that this remote is alive. | 540 // Update that this remote is alive. |
| 541 receive_info->last_time_received_ms = clock_->TimeInMilliseconds(); | 541 tmmbr_info->last_time_received_ms = clock_->TimeInMilliseconds(); |
| 542 } | 542 } |
| 543 | 543 |
| 544 RTCPReceiver::ReceiveInformation* RTCPReceiver::GetReceiveInformation( | 544 RTCPReceiver::TmmbrInformation* RTCPReceiver::GetTmmbrInformation( |
| 545 uint32_t remote_ssrc) { | 545 uint32_t remote_ssrc) { |
| 546 auto it = received_infos_.find(remote_ssrc); | 546 auto it = tmmbr_infos_.find(remote_ssrc); |
| 547 if (it == received_infos_.end()) | 547 if (it == tmmbr_infos_.end()) |
| 548 return nullptr; | 548 return nullptr; |
| 549 return &it->second; | 549 return &it->second; |
| 550 } | 550 } |
| 551 | 551 |
| 552 bool RTCPReceiver::RtcpRrTimeout(int64_t rtcp_interval_ms) { | 552 bool RTCPReceiver::RtcpRrTimeout(int64_t rtcp_interval_ms) { |
| 553 rtc::CritScope lock(&rtcp_receiver_lock_); | 553 rtc::CritScope lock(&rtcp_receiver_lock_); |
| 554 if (last_received_rr_ms_ == 0) | 554 if (last_received_rr_ms_ == 0) |
| 555 return false; | 555 return false; |
| 556 | 556 |
| 557 int64_t time_out_ms = kRrTimeoutIntervals * rtcp_interval_ms; | 557 int64_t time_out_ms = kRrTimeoutIntervals * rtcp_interval_ms; |
| (...skipping 13 matching lines...) Expand all Loading... | |
| 571 int64_t time_out_ms = kRrTimeoutIntervals * rtcp_interval_ms; | 571 int64_t time_out_ms = kRrTimeoutIntervals * rtcp_interval_ms; |
| 572 if (clock_->TimeInMilliseconds() > | 572 if (clock_->TimeInMilliseconds() > |
| 573 last_increased_sequence_number_ms_ + time_out_ms) { | 573 last_increased_sequence_number_ms_ + time_out_ms) { |
| 574 // Reset the timer to only trigger one log. | 574 // Reset the timer to only trigger one log. |
| 575 last_increased_sequence_number_ms_ = 0; | 575 last_increased_sequence_number_ms_ = 0; |
| 576 return true; | 576 return true; |
| 577 } | 577 } |
| 578 return false; | 578 return false; |
| 579 } | 579 } |
| 580 | 580 |
| 581 bool RTCPReceiver::UpdateRTCPReceiveInformationTimers() { | 581 bool RTCPReceiver::UpdateTmmbrTimers() { |
| 582 rtc::CritScope lock(&rtcp_receiver_lock_); | 582 rtc::CritScope lock(&rtcp_receiver_lock_); |
| 583 | 583 |
| 584 int64_t now_ms = clock_->TimeInMilliseconds(); | 584 int64_t now_ms = clock_->TimeInMilliseconds(); |
| 585 // Use audio define since we don't know what interval the remote peer use. | 585 // Use audio define since we don't know what interval the remote peer use. |
| 586 int64_t timeout_ms = now_ms - 5 * RTCP_INTERVAL_AUDIO_MS; | 586 int64_t timeout_ms = now_ms - 5 * RTCP_INTERVAL_AUDIO_MS; |
| 587 | 587 |
| 588 if (oldest_received_info_ms_ >= timeout_ms) | 588 if (oldest_tmmbr_info_ms_ >= timeout_ms) |
| 589 return false; | 589 return false; |
| 590 | 590 |
| 591 bool update_bounding_set = false; | 591 bool update_bounding_set = false; |
| 592 oldest_received_info_ms_ = -1; | 592 oldest_tmmbr_info_ms_ = -1; |
| 593 for (auto receive_info_it = received_infos_.begin(); | 593 for (auto tmmbr_it = tmmbr_infos_.begin(); tmmbr_it != tmmbr_infos_.end();) { |
| 594 receive_info_it != received_infos_.end();) { | 594 TmmbrInformation* tmmbr_info = &tmmbr_it->second; |
| 595 ReceiveInformation* receive_info = &receive_info_it->second; | 595 if (tmmbr_info->last_time_received_ms > 0) { |
| 596 if (receive_info->last_time_received_ms > 0) { | 596 if (tmmbr_info->last_time_received_ms < timeout_ms) { |
| 597 if (receive_info->last_time_received_ms < timeout_ms) { | |
| 598 // No rtcp packet for the last 5 regular intervals, reset limitations. | 597 // No rtcp packet for the last 5 regular intervals, reset limitations. |
| 599 receive_info->tmmbr.clear(); | 598 tmmbr_info->tmmbr.clear(); |
| 600 // Prevent that we call this over and over again. | 599 // Prevent that we call this over and over again. |
| 601 receive_info->last_time_received_ms = 0; | 600 tmmbr_info->last_time_received_ms = 0; |
| 602 // Send new TMMBN to all channels using the default codec. | 601 // Send new TMMBN to all channels using the default codec. |
| 603 update_bounding_set = true; | 602 update_bounding_set = true; |
| 604 } else if (oldest_received_info_ms_ == -1 || | 603 } else if (oldest_tmmbr_info_ms_ == -1 || |
| 605 receive_info->last_time_received_ms < | 604 tmmbr_info->last_time_received_ms < oldest_tmmbr_info_ms_) { |
| 606 oldest_received_info_ms_) { | 605 oldest_tmmbr_info_ms_ = tmmbr_info->last_time_received_ms; |
| 607 oldest_received_info_ms_ = receive_info->last_time_received_ms; | |
| 608 } | 606 } |
| 609 ++receive_info_it; | 607 ++tmmbr_it; |
| 610 } else if (receive_info->ready_for_delete) { | 608 } else if (tmmbr_info->ready_for_delete) { |
| 611 // When we dont have a last_time_received_ms and the object is marked | 609 // When we dont have a last_time_received_ms and the object is marked |
| 612 // ready_for_delete it's removed from the map. | 610 // ready_for_delete it's removed from the map. |
| 613 receive_info_it = received_infos_.erase(receive_info_it); | 611 tmmbr_it = tmmbr_infos_.erase(tmmbr_it); |
| 614 } else { | 612 } else { |
| 615 ++receive_info_it; | 613 ++tmmbr_it; |
| 616 } | 614 } |
| 617 } | 615 } |
| 618 return update_bounding_set; | 616 return update_bounding_set; |
| 619 } | 617 } |
| 620 | 618 |
| 621 std::vector<rtcp::TmmbItem> RTCPReceiver::BoundingSet(bool* tmmbr_owner) { | 619 std::vector<rtcp::TmmbItem> RTCPReceiver::BoundingSet(bool* tmmbr_owner) { |
| 622 rtc::CritScope lock(&rtcp_receiver_lock_); | 620 rtc::CritScope lock(&rtcp_receiver_lock_); |
| 623 ReceiveInformation* receive_info = GetReceiveInformation(remote_ssrc_); | 621 TmmbrInformation* tmmbr_info = GetTmmbrInformation(remote_ssrc_); |
| 624 if (!receive_info) | 622 if (!tmmbr_info) |
| 625 return std::vector<rtcp::TmmbItem>(); | 623 return std::vector<rtcp::TmmbItem>(); |
| 626 | 624 |
| 627 *tmmbr_owner = TMMBRHelp::IsOwner(receive_info->tmmbn, main_ssrc_); | 625 *tmmbr_owner = TMMBRHelp::IsOwner(tmmbr_info->tmmbn, main_ssrc_); |
| 628 return receive_info->tmmbn; | 626 return tmmbr_info->tmmbn; |
| 629 } | 627 } |
| 630 | 628 |
| 631 void RTCPReceiver::HandleSdes(const CommonHeader& rtcp_block, | 629 void RTCPReceiver::HandleSdes(const CommonHeader& rtcp_block, |
| 632 PacketInformation* packet_information) { | 630 PacketInformation* packet_information) { |
| 633 rtcp::Sdes sdes; | 631 rtcp::Sdes sdes; |
| 634 if (!sdes.Parse(rtcp_block)) { | 632 if (!sdes.Parse(rtcp_block)) { |
| 635 ++num_skipped_packets_; | 633 ++num_skipped_packets_; |
| 636 return; | 634 return; |
| 637 } | 635 } |
| 638 | 636 |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 676 rtcp::Bye bye; | 674 rtcp::Bye bye; |
| 677 if (!bye.Parse(rtcp_block)) { | 675 if (!bye.Parse(rtcp_block)) { |
| 678 ++num_skipped_packets_; | 676 ++num_skipped_packets_; |
| 679 return; | 677 return; |
| 680 } | 678 } |
| 681 | 679 |
| 682 // Clear our lists. | 680 // Clear our lists. |
| 683 for (auto& reports_per_receiver : received_report_blocks_) | 681 for (auto& reports_per_receiver : received_report_blocks_) |
| 684 reports_per_receiver.second.erase(bye.sender_ssrc()); | 682 reports_per_receiver.second.erase(bye.sender_ssrc()); |
| 685 | 683 |
| 686 // We can't delete it due to TMMBR. | 684 TmmbrInformation* tmmbr_info = GetTmmbrInformation(bye.sender_ssrc()); |
| 687 ReceiveInformation* receive_info = GetReceiveInformation(bye.sender_ssrc()); | 685 if (tmmbr_info) |
| 688 if (receive_info) | 686 tmmbr_info->ready_for_delete = true; |
| 689 receive_info->ready_for_delete = true; | |
| 690 | 687 |
| 691 last_fir_.erase(bye.sender_ssrc()); | 688 last_fir_.erase(bye.sender_ssrc()); |
| 692 received_cnames_.erase(bye.sender_ssrc()); | 689 received_cnames_.erase(bye.sender_ssrc()); |
| 693 xr_rr_rtt_ms_ = 0; | 690 xr_rr_rtt_ms_ = 0; |
| 694 } | 691 } |
| 695 | 692 |
| 696 void RTCPReceiver::HandleXr(const CommonHeader& rtcp_block, | 693 void RTCPReceiver::HandleXr(const CommonHeader& rtcp_block, |
| 697 PacketInformation* packet_information) { | 694 PacketInformation* packet_information) { |
| 698 rtcp::ExtendedReports xr; | 695 rtcp::ExtendedReports xr; |
| 699 if (!xr.Parse(rtcp_block)) { | 696 if (!xr.Parse(rtcp_block)) { |
| (...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 778 | 775 |
| 779 void RTCPReceiver::HandleTmmbr(const CommonHeader& rtcp_block, | 776 void RTCPReceiver::HandleTmmbr(const CommonHeader& rtcp_block, |
| 780 PacketInformation* packet_information) { | 777 PacketInformation* packet_information) { |
| 781 rtcp::Tmmbr tmmbr; | 778 rtcp::Tmmbr tmmbr; |
| 782 if (!tmmbr.Parse(rtcp_block)) { | 779 if (!tmmbr.Parse(rtcp_block)) { |
| 783 ++num_skipped_packets_; | 780 ++num_skipped_packets_; |
| 784 return; | 781 return; |
| 785 } | 782 } |
| 786 | 783 |
| 787 uint32_t sender_ssrc = tmmbr.sender_ssrc(); | 784 uint32_t sender_ssrc = tmmbr.sender_ssrc(); |
| 788 ReceiveInformation* receive_info = GetReceiveInformation(sender_ssrc); | 785 TmmbrInformation* receive_info = GetTmmbrInformation(sender_ssrc); |
| 789 if (!receive_info) // This remote SSRC must be saved before. | 786 if (!receive_info) // This remote SSRC must be saved before. |
| 790 return; | 787 return; |
| 791 | 788 |
| 792 if (tmmbr.media_ssrc()) { | 789 if (tmmbr.media_ssrc()) { |
| 793 // media_ssrc() SHOULD be 0 if same as SenderSSRC. | 790 // media_ssrc() SHOULD be 0 if same as SenderSSRC. |
| 794 // In relay mode this is a valid number. | 791 // In relay mode this is a valid number. |
| 795 sender_ssrc = tmmbr.media_ssrc(); | 792 sender_ssrc = tmmbr.media_ssrc(); |
| 796 } | 793 } |
| 797 | 794 |
| 798 for (const rtcp::TmmbItem& request : tmmbr.requests()) { | 795 for (const rtcp::TmmbItem& request : tmmbr.requests()) { |
| (...skipping 10 matching lines...) Expand all Loading... | |
| 809 } | 806 } |
| 810 | 807 |
| 811 void RTCPReceiver::HandleTmmbn(const CommonHeader& rtcp_block, | 808 void RTCPReceiver::HandleTmmbn(const CommonHeader& rtcp_block, |
| 812 PacketInformation* packet_information) { | 809 PacketInformation* packet_information) { |
| 813 rtcp::Tmmbn tmmbn; | 810 rtcp::Tmmbn tmmbn; |
| 814 if (!tmmbn.Parse(rtcp_block)) { | 811 if (!tmmbn.Parse(rtcp_block)) { |
| 815 ++num_skipped_packets_; | 812 ++num_skipped_packets_; |
| 816 return; | 813 return; |
| 817 } | 814 } |
| 818 | 815 |
| 819 ReceiveInformation* receive_info = GetReceiveInformation(tmmbn.sender_ssrc()); | 816 TmmbrInformation* receive_info = GetTmmbrInformation(tmmbn.sender_ssrc()); |
| 820 if (!receive_info) // This remote SSRC must be saved before. | 817 if (!receive_info) // This remote SSRC must be saved before. |
| 821 return; | 818 return; |
| 822 | 819 |
| 823 packet_information->packet_type_flags |= kRtcpTmmbn; | 820 packet_information->packet_type_flags |= kRtcpTmmbn; |
| 824 | 821 |
| 825 for (const auto& item : tmmbn.items()) | 822 for (const auto& item : tmmbn.items()) |
| 826 receive_info->tmmbn.push_back(item); | 823 receive_info->tmmbn.push_back(item); |
| 827 } | 824 } |
| 828 | 825 |
| 829 void RTCPReceiver::HandleSrReq(const CommonHeader& rtcp_block, | 826 void RTCPReceiver::HandleSrReq(const CommonHeader& rtcp_block, |
| (...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 922 new rtcp::TransportFeedback()); | 919 new rtcp::TransportFeedback()); |
| 923 if (!transport_feedback->Parse(rtcp_block)) { | 920 if (!transport_feedback->Parse(rtcp_block)) { |
| 924 ++num_skipped_packets_; | 921 ++num_skipped_packets_; |
| 925 return; | 922 return; |
| 926 } | 923 } |
| 927 | 924 |
| 928 packet_information->packet_type_flags |= kRtcpTransportFeedback; | 925 packet_information->packet_type_flags |= kRtcpTransportFeedback; |
| 929 packet_information->transport_feedback = std::move(transport_feedback); | 926 packet_information->transport_feedback = std::move(transport_feedback); |
| 930 } | 927 } |
| 931 | 928 |
| 932 void RTCPReceiver::UpdateTmmbr() { | 929 void RTCPReceiver::NotifyTmmbrUpdated() { |
| 933 // Find bounding set. | 930 // Find bounding set. |
| 934 std::vector<rtcp::TmmbItem> bounding = | 931 std::vector<rtcp::TmmbItem> bounding = |
| 935 TMMBRHelp::FindBoundingSet(TmmbrReceived()); | 932 TMMBRHelp::FindBoundingSet(TmmbrReceived()); |
| 936 | 933 |
| 937 if (!bounding.empty() && rtcp_bandwidth_observer_) { | 934 if (!bounding.empty() && rtcp_bandwidth_observer_) { |
| 938 // We have a new bandwidth estimate on this channel. | 935 // We have a new bandwidth estimate on this channel. |
| 939 uint64_t bitrate_bps = TMMBRHelp::CalcMinBitrateBps(bounding); | 936 uint64_t bitrate_bps = TMMBRHelp::CalcMinBitrateBps(bounding); |
| 940 if (bitrate_bps <= std::numeric_limits<uint32_t>::max()) | 937 if (bitrate_bps <= std::numeric_limits<uint32_t>::max()) |
| 941 rtcp_bandwidth_observer_->OnReceivedEstimatedBitrate(bitrate_bps); | 938 rtcp_bandwidth_observer_->OnReceivedEstimatedBitrate(bitrate_bps); |
| 942 } | 939 } |
| 943 | 940 |
| 944 // Set bounding set: inform remote clients about the new bandwidth. | 941 // Send tmmbn to inform remote clients about the new bandwidth. |
| 945 rtp_rtcp_->SetTmmbn(std::move(bounding)); | 942 rtp_rtcp_->SetTmmbn(std::move(bounding)); |
| 946 } | 943 } |
| 947 | 944 |
| 948 void RTCPReceiver::RegisterRtcpStatisticsCallback( | 945 void RTCPReceiver::RegisterRtcpStatisticsCallback( |
| 949 RtcpStatisticsCallback* callback) { | 946 RtcpStatisticsCallback* callback) { |
| 950 rtc::CritScope cs(&feedbacks_lock_); | 947 rtc::CritScope cs(&feedbacks_lock_); |
| 951 stats_callback_ = callback; | 948 stats_callback_ = callback; |
| 952 } | 949 } |
| 953 | 950 |
| 954 RtcpStatisticsCallback* RTCPReceiver::GetRtcpStatisticsCallback() { | 951 RtcpStatisticsCallback* RTCPReceiver::GetRtcpStatisticsCallback() { |
| 955 rtc::CritScope cs(&feedbacks_lock_); | 952 rtc::CritScope cs(&feedbacks_lock_); |
| 956 return stats_callback_; | 953 return stats_callback_; |
| 957 } | 954 } |
| 958 | 955 |
| 959 // Holding no Critical section. | 956 // Holding no Critical section. |
| 960 void RTCPReceiver::TriggerCallbacksFromRtcpPacket( | 957 void RTCPReceiver::TriggerCallbacksFromRtcpPacket( |
| 961 const PacketInformation& packet_information) { | 958 const PacketInformation& packet_information) { |
| 962 // Process TMMBR and REMB first to avoid multiple callbacks | 959 // Process TMMBR and REMB first to avoid multiple callbacks |
| 963 // to OnNetworkChanged. | 960 // to OnNetworkChanged. |
| 964 if (packet_information.packet_type_flags & kRtcpTmmbr) { | 961 if (packet_information.packet_type_flags & kRtcpTmmbr) { |
| 965 // Might trigger a OnReceivedBandwidthEstimateUpdate. | 962 // Might trigger a OnReceivedBandwidthEstimateUpdate. |
| 966 UpdateTmmbr(); | 963 NotifyTmmbrUpdated(); |
| 967 } | 964 } |
| 968 uint32_t local_ssrc; | 965 uint32_t local_ssrc; |
| 969 std::set<uint32_t> registered_ssrcs; | 966 std::set<uint32_t> registered_ssrcs; |
| 970 { | 967 { |
| 971 // We don't want to hold this critsect when triggering the callbacks below. | 968 // We don't want to hold this critsect when triggering the callbacks below. |
| 972 rtc::CritScope lock(&rtcp_receiver_lock_); | 969 rtc::CritScope lock(&rtcp_receiver_lock_); |
| 973 local_ssrc = main_ssrc_; | 970 local_ssrc = main_ssrc_; |
| 974 registered_ssrcs = registered_ssrcs_; | 971 registered_ssrcs = registered_ssrcs_; |
| 975 } | 972 } |
| 976 if (!receiver_only_ && (packet_information.packet_type_flags & kRtcpSrReq)) { | 973 if (!receiver_only_ && (packet_information.packet_type_flags & kRtcpSrReq)) { |
| (...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1078 } | 1075 } |
| 1079 | 1076 |
| 1080 std::vector<rtcp::TmmbItem> RTCPReceiver::TmmbrReceived() { | 1077 std::vector<rtcp::TmmbItem> RTCPReceiver::TmmbrReceived() { |
| 1081 rtc::CritScope lock(&rtcp_receiver_lock_); | 1078 rtc::CritScope lock(&rtcp_receiver_lock_); |
| 1082 std::vector<rtcp::TmmbItem> candidates; | 1079 std::vector<rtcp::TmmbItem> candidates; |
| 1083 | 1080 |
| 1084 int64_t now_ms = clock_->TimeInMilliseconds(); | 1081 int64_t now_ms = clock_->TimeInMilliseconds(); |
| 1085 // Use audio define since we don't know what interval the remote peer use. | 1082 // Use audio define since we don't know what interval the remote peer use. |
| 1086 int64_t timeout_ms = now_ms - 5 * RTCP_INTERVAL_AUDIO_MS; | 1083 int64_t timeout_ms = now_ms - 5 * RTCP_INTERVAL_AUDIO_MS; |
| 1087 | 1084 |
| 1088 for (auto& kv : received_infos_) { | 1085 for (auto& kv : tmmbr_infos_) { |
| 1089 for (auto it = kv.second.tmmbr.begin(); it != kv.second.tmmbr.end();) { | 1086 for (auto it = kv.second.tmmbr.begin(); it != kv.second.tmmbr.end();) { |
| 1090 if (it->second.last_updated_ms < timeout_ms) { | 1087 if (it->second.last_updated_ms < timeout_ms) { |
| 1091 // Erase timeout entries. | 1088 // Erase timeout entries. |
| 1092 it = kv.second.tmmbr.erase(it); | 1089 it = kv.second.tmmbr.erase(it); |
| 1093 } else { | 1090 } else { |
| 1094 candidates.push_back(it->second.tmmbr_item); | 1091 candidates.push_back(it->second.tmmbr_item); |
| 1095 ++it; | 1092 ++it; |
| 1096 } | 1093 } |
| 1097 } | 1094 } |
| 1098 } | 1095 } |
| 1099 return candidates; | 1096 return candidates; |
| 1100 } | 1097 } |
| 1101 | 1098 |
| 1102 } // namespace webrtc | 1099 } // namespace webrtc |
| OLD | NEW |