| Index: webrtc/modules/rtp_rtcp/source/rtcp_receiver.cc
|
| diff --git a/webrtc/modules/rtp_rtcp/source/rtcp_receiver.cc b/webrtc/modules/rtp_rtcp/source/rtcp_receiver.cc
|
| index 3977ee4f20e3c6e48fec646b9ef4dbaf82dbce4a..1105493b64f2688090335addaf11e668e4174445 100644
|
| --- a/webrtc/modules/rtp_rtcp/source/rtcp_receiver.cc
|
| +++ b/webrtc/modules/rtp_rtcp/source/rtcp_receiver.cc
|
| @@ -73,7 +73,8 @@ struct RTCPReceiver::PacketInformation {
|
| rtc::Optional<BitrateAllocation> target_bitrate_allocation;
|
| };
|
|
|
| -struct RTCPReceiver::ReceiveInformation {
|
| +// Structure for handing TMMBR and TMMBN rtcp messages (RFC5104, section 3.5.4).
|
| +struct RTCPReceiver::TmmbrInformation {
|
| struct TimedTmmbrItem {
|
| rtcp::TmmbItem tmmbr_item;
|
| int64_t last_updated_ms;
|
| @@ -411,7 +412,7 @@ void RTCPReceiver::HandleSenderReport(const CommonHeader& rtcp_block,
|
|
|
| packet_information->remote_ssrc = remote_ssrc;
|
|
|
| - CreateReceiveInformation(remote_ssrc);
|
| + CreateTmmbrInformation(remote_ssrc);
|
|
|
| TRACE_EVENT_INSTANT2(TRACE_DISABLED_BY_DEFAULT("webrtc_rtp"), "SR",
|
| "remote_ssrc", remote_ssrc, "ssrc", main_ssrc_);
|
| @@ -453,7 +454,7 @@ void RTCPReceiver::HandleReceiverReport(const CommonHeader& rtcp_block,
|
|
|
| packet_information->remote_ssrc = remote_ssrc;
|
|
|
| - CreateReceiveInformation(remote_ssrc);
|
| + CreateTmmbrInformation(remote_ssrc);
|
|
|
| TRACE_EVENT_INSTANT2(TRACE_DISABLED_BY_DEFAULT("webrtc_rtp"), "RR",
|
| "remote_ssrc", remote_ssrc, "ssrc", main_ssrc_);
|
| @@ -534,17 +535,17 @@ void RTCPReceiver::HandleReportBlock(const ReportBlock& report_block,
|
| packet_information->report_blocks.push_back(report_block_info->report_block);
|
| }
|
|
|
| -void RTCPReceiver::CreateReceiveInformation(uint32_t remote_ssrc) {
|
| +void RTCPReceiver::CreateTmmbrInformation(uint32_t remote_ssrc) {
|
| // Create or find receive information.
|
| - ReceiveInformation* receive_info = &received_infos_[remote_ssrc];
|
| + TmmbrInformation* tmmbr_info = &tmmbr_infos_[remote_ssrc];
|
| // Update that this remote is alive.
|
| - receive_info->last_time_received_ms = clock_->TimeInMilliseconds();
|
| + tmmbr_info->last_time_received_ms = clock_->TimeInMilliseconds();
|
| }
|
|
|
| -RTCPReceiver::ReceiveInformation* RTCPReceiver::GetReceiveInformation(
|
| +RTCPReceiver::TmmbrInformation* RTCPReceiver::GetTmmbrInformation(
|
| uint32_t remote_ssrc) {
|
| - auto it = received_infos_.find(remote_ssrc);
|
| - if (it == received_infos_.end())
|
| + auto it = tmmbr_infos_.find(remote_ssrc);
|
| + if (it == tmmbr_infos_.end())
|
| return nullptr;
|
| return &it->second;
|
| }
|
| @@ -578,41 +579,39 @@ bool RTCPReceiver::RtcpRrSequenceNumberTimeout(int64_t rtcp_interval_ms) {
|
| return false;
|
| }
|
|
|
| -bool RTCPReceiver::UpdateRTCPReceiveInformationTimers() {
|
| +bool RTCPReceiver::UpdateTmmbrTimers() {
|
| rtc::CritScope lock(&rtcp_receiver_lock_);
|
|
|
| int64_t now_ms = clock_->TimeInMilliseconds();
|
| // Use audio define since we don't know what interval the remote peer use.
|
| int64_t timeout_ms = now_ms - 5 * RTCP_INTERVAL_AUDIO_MS;
|
|
|
| - if (oldest_received_info_ms_ >= timeout_ms)
|
| + if (oldest_tmmbr_info_ms_ >= timeout_ms)
|
| return false;
|
|
|
| bool update_bounding_set = false;
|
| - oldest_received_info_ms_ = -1;
|
| - for (auto receive_info_it = received_infos_.begin();
|
| - receive_info_it != received_infos_.end();) {
|
| - ReceiveInformation* receive_info = &receive_info_it->second;
|
| - if (receive_info->last_time_received_ms > 0) {
|
| - if (receive_info->last_time_received_ms < timeout_ms) {
|
| + oldest_tmmbr_info_ms_ = -1;
|
| + for (auto tmmbr_it = tmmbr_infos_.begin(); tmmbr_it != tmmbr_infos_.end();) {
|
| + TmmbrInformation* tmmbr_info = &tmmbr_it->second;
|
| + if (tmmbr_info->last_time_received_ms > 0) {
|
| + if (tmmbr_info->last_time_received_ms < timeout_ms) {
|
| // No rtcp packet for the last 5 regular intervals, reset limitations.
|
| - receive_info->tmmbr.clear();
|
| + tmmbr_info->tmmbr.clear();
|
| // Prevent that we call this over and over again.
|
| - receive_info->last_time_received_ms = 0;
|
| + tmmbr_info->last_time_received_ms = 0;
|
| // Send new TMMBN to all channels using the default codec.
|
| update_bounding_set = true;
|
| - } else if (oldest_received_info_ms_ == -1 ||
|
| - receive_info->last_time_received_ms <
|
| - oldest_received_info_ms_) {
|
| - oldest_received_info_ms_ = receive_info->last_time_received_ms;
|
| + } else if (oldest_tmmbr_info_ms_ == -1 ||
|
| + tmmbr_info->last_time_received_ms < oldest_tmmbr_info_ms_) {
|
| + oldest_tmmbr_info_ms_ = tmmbr_info->last_time_received_ms;
|
| }
|
| - ++receive_info_it;
|
| - } else if (receive_info->ready_for_delete) {
|
| + ++tmmbr_it;
|
| + } else if (tmmbr_info->ready_for_delete) {
|
| // When we dont have a last_time_received_ms and the object is marked
|
| // ready_for_delete it's removed from the map.
|
| - receive_info_it = received_infos_.erase(receive_info_it);
|
| + tmmbr_it = tmmbr_infos_.erase(tmmbr_it);
|
| } else {
|
| - ++receive_info_it;
|
| + ++tmmbr_it;
|
| }
|
| }
|
| return update_bounding_set;
|
| @@ -620,12 +619,12 @@ bool RTCPReceiver::UpdateRTCPReceiveInformationTimers() {
|
|
|
| std::vector<rtcp::TmmbItem> RTCPReceiver::BoundingSet(bool* tmmbr_owner) {
|
| rtc::CritScope lock(&rtcp_receiver_lock_);
|
| - ReceiveInformation* receive_info = GetReceiveInformation(remote_ssrc_);
|
| - if (!receive_info)
|
| + TmmbrInformation* tmmbr_info = GetTmmbrInformation(remote_ssrc_);
|
| + if (!tmmbr_info)
|
| return std::vector<rtcp::TmmbItem>();
|
|
|
| - *tmmbr_owner = TMMBRHelp::IsOwner(receive_info->tmmbn, main_ssrc_);
|
| - return receive_info->tmmbn;
|
| + *tmmbr_owner = TMMBRHelp::IsOwner(tmmbr_info->tmmbn, main_ssrc_);
|
| + return tmmbr_info->tmmbn;
|
| }
|
|
|
| void RTCPReceiver::HandleSdes(const CommonHeader& rtcp_block,
|
| @@ -683,10 +682,9 @@ void RTCPReceiver::HandleBye(const CommonHeader& rtcp_block) {
|
| for (auto& reports_per_receiver : received_report_blocks_)
|
| reports_per_receiver.second.erase(bye.sender_ssrc());
|
|
|
| - // We can't delete it due to TMMBR.
|
| - ReceiveInformation* receive_info = GetReceiveInformation(bye.sender_ssrc());
|
| - if (receive_info)
|
| - receive_info->ready_for_delete = true;
|
| + TmmbrInformation* tmmbr_info = GetTmmbrInformation(bye.sender_ssrc());
|
| + if (tmmbr_info)
|
| + tmmbr_info->ready_for_delete = true;
|
|
|
| last_fir_.erase(bye.sender_ssrc());
|
| received_cnames_.erase(bye.sender_ssrc());
|
| @@ -785,7 +783,7 @@ void RTCPReceiver::HandleTmmbr(const CommonHeader& rtcp_block,
|
| }
|
|
|
| uint32_t sender_ssrc = tmmbr.sender_ssrc();
|
| - ReceiveInformation* receive_info = GetReceiveInformation(sender_ssrc);
|
| + TmmbrInformation* receive_info = GetTmmbrInformation(sender_ssrc);
|
| if (!receive_info) // This remote SSRC must be saved before.
|
| return;
|
|
|
| @@ -816,7 +814,7 @@ void RTCPReceiver::HandleTmmbn(const CommonHeader& rtcp_block,
|
| return;
|
| }
|
|
|
| - ReceiveInformation* receive_info = GetReceiveInformation(tmmbn.sender_ssrc());
|
| + TmmbrInformation* receive_info = GetTmmbrInformation(tmmbn.sender_ssrc());
|
| if (!receive_info) // This remote SSRC must be saved before.
|
| return;
|
|
|
| @@ -929,7 +927,7 @@ void RTCPReceiver::HandleTransportFeedback(
|
| packet_information->transport_feedback = std::move(transport_feedback);
|
| }
|
|
|
| -void RTCPReceiver::UpdateTmmbr() {
|
| +void RTCPReceiver::NotifyTmmbrUpdated() {
|
| // Find bounding set.
|
| std::vector<rtcp::TmmbItem> bounding =
|
| TMMBRHelp::FindBoundingSet(TmmbrReceived());
|
| @@ -941,7 +939,7 @@ void RTCPReceiver::UpdateTmmbr() {
|
| rtcp_bandwidth_observer_->OnReceivedEstimatedBitrate(bitrate_bps);
|
| }
|
|
|
| - // Set bounding set: inform remote clients about the new bandwidth.
|
| + // Send tmmbn to inform remote clients about the new bandwidth.
|
| rtp_rtcp_->SetTmmbn(std::move(bounding));
|
| }
|
|
|
| @@ -963,7 +961,7 @@ void RTCPReceiver::TriggerCallbacksFromRtcpPacket(
|
| // to OnNetworkChanged.
|
| if (packet_information.packet_type_flags & kRtcpTmmbr) {
|
| // Might trigger a OnReceivedBandwidthEstimateUpdate.
|
| - UpdateTmmbr();
|
| + NotifyTmmbrUpdated();
|
| }
|
| uint32_t local_ssrc;
|
| std::set<uint32_t> registered_ssrcs;
|
| @@ -1085,7 +1083,7 @@ std::vector<rtcp::TmmbItem> RTCPReceiver::TmmbrReceived() {
|
| // Use audio define since we don't know what interval the remote peer use.
|
| int64_t timeout_ms = now_ms - 5 * RTCP_INTERVAL_AUDIO_MS;
|
|
|
| - for (auto& kv : received_infos_) {
|
| + for (auto& kv : tmmbr_infos_) {
|
| for (auto it = kv.second.tmmbr.begin(); it != kv.second.tmmbr.end();) {
|
| if (it->second.last_updated_ms < timeout_ms) {
|
| // Erase timeout entries.
|
|
|