Rename ReceiveInfo to TmmbrInfo
together with related functions and variables to stress it is used for Tmmbr only. This is explicitly pure rename CL with no functional changes. BUG=webrtc:5565 Review-Url: https://codereview.webrtc.org/2707763004 Cr-Commit-Position: refs/heads/master@{#16720}
This commit is contained in:
parent
424e6cfd58
commit
9bf610ea8c
@ -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.
|
||||
|
||||
@ -105,23 +105,20 @@ class RTCPReceiver {
|
||||
bool RtcpRrSequenceNumberTimeout(int64_t rtcp_interval_ms);
|
||||
|
||||
std::vector<rtcp::TmmbItem> TmmbrReceived();
|
||||
|
||||
bool UpdateRTCPReceiveInformationTimers();
|
||||
|
||||
// Return true if new bandwidth should be set.
|
||||
bool UpdateTmmbrTimers();
|
||||
std::vector<rtcp::TmmbItem> BoundingSet(bool* tmmbr_owner);
|
||||
|
||||
void UpdateTmmbr();
|
||||
// Set new bandwidth and notify remote clients about it.
|
||||
void NotifyTmmbrUpdated();
|
||||
|
||||
void RegisterRtcpStatisticsCallback(RtcpStatisticsCallback* callback);
|
||||
RtcpStatisticsCallback* GetRtcpStatisticsCallback();
|
||||
|
||||
private:
|
||||
struct PacketInformation;
|
||||
struct ReceiveInformation;
|
||||
struct TmmbrInformation;
|
||||
struct ReportBlockWithRtt;
|
||||
struct LastFirStatus;
|
||||
// Mapped by remote ssrc.
|
||||
using ReceivedInfoMap = std::map<uint32_t, ReceiveInformation>;
|
||||
// RTCP report blocks mapped by remote SSRC.
|
||||
using ReportBlockInfoMap = std::map<uint32_t, ReportBlockWithRtt>;
|
||||
// RTCP report blocks map mapped by source SSRC.
|
||||
@ -134,9 +131,9 @@ class RTCPReceiver {
|
||||
void TriggerCallbacksFromRtcpPacket(
|
||||
const PacketInformation& packet_information);
|
||||
|
||||
void CreateReceiveInformation(uint32_t remote_ssrc)
|
||||
void CreateTmmbrInformation(uint32_t remote_ssrc)
|
||||
EXCLUSIVE_LOCKS_REQUIRED(rtcp_receiver_lock_);
|
||||
ReceiveInformation* GetReceiveInformation(uint32_t remote_ssrc)
|
||||
TmmbrInformation* GetTmmbrInformation(uint32_t remote_ssrc)
|
||||
EXCLUSIVE_LOCKS_REQUIRED(rtcp_receiver_lock_);
|
||||
|
||||
void HandleSenderReport(const rtcp::CommonHeader& rtcp_block,
|
||||
@ -242,10 +239,12 @@ class RTCPReceiver {
|
||||
bool xr_rrtr_status_ GUARDED_BY(rtcp_receiver_lock_);
|
||||
int64_t xr_rr_rtt_ms_;
|
||||
|
||||
// Received report blocks.
|
||||
int64_t oldest_tmmbr_info_ms_ GUARDED_BY(rtcp_receiver_lock_);
|
||||
// Mapped by remote ssrc.
|
||||
std::map<uint32_t, TmmbrInformation> tmmbr_infos_
|
||||
GUARDED_BY(rtcp_receiver_lock_);
|
||||
|
||||
ReportBlockMap received_report_blocks_ GUARDED_BY(rtcp_receiver_lock_);
|
||||
ReceivedInfoMap received_infos_ GUARDED_BY(rtcp_receiver_lock_);
|
||||
int64_t oldest_received_info_ms_ GUARDED_BY(rtcp_receiver_lock_);
|
||||
std::map<uint32_t, LastFirStatus> last_fir_ GUARDED_BY(rtcp_receiver_lock_);
|
||||
std::map<uint32_t, std::string> received_cnames_
|
||||
GUARDED_BY(rtcp_receiver_lock_);
|
||||
|
||||
@ -211,9 +211,8 @@ void ModuleRtpRtcpImpl::Process() {
|
||||
if (rtcp_sender_.TimeToSendRTCPReport())
|
||||
rtcp_sender_.SendRTCP(GetFeedbackState(), kRtcpReport);
|
||||
|
||||
if (TMMBR() && rtcp_receiver_.UpdateRTCPReceiveInformationTimers()) {
|
||||
// A receiver has timed out.
|
||||
rtcp_receiver_.UpdateTmmbr();
|
||||
if (TMMBR() && rtcp_receiver_.UpdateTmmbrTimers()) {
|
||||
rtcp_receiver_.NotifyTmmbrUpdated();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user