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 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 42 #include "webrtc/modules/rtp_rtcp/source/rtcp_utility.h" | 42 #include "webrtc/modules/rtp_rtcp/source/rtcp_utility.h" |
| 43 #include "webrtc/modules/rtp_rtcp/source/time_util.h" | 43 #include "webrtc/modules/rtp_rtcp/source/time_util.h" |
| 44 #include "webrtc/modules/rtp_rtcp/source/tmmbr_help.h" | 44 #include "webrtc/modules/rtp_rtcp/source/tmmbr_help.h" |
| 45 #include "webrtc/system_wrappers/include/ntp_time.h" | 45 #include "webrtc/system_wrappers/include/ntp_time.h" |
| 46 | 46 |
| 47 namespace webrtc { | 47 namespace webrtc { |
| 48 namespace { | 48 namespace { |
| 49 | 49 |
| 50 using rtcp::CommonHeader; | 50 using rtcp::CommonHeader; |
| 51 using rtcp::ReportBlock; | 51 using rtcp::ReportBlock; |
| 52 using RTCPHelp::RTCPReportBlockInformation; | |
| 53 | 52 |
| 54 // The number of RTCP time intervals needed to trigger a timeout. | 53 // The number of RTCP time intervals needed to trigger a timeout. |
| 55 const int kRrTimeoutIntervals = 3; | 54 const int kRrTimeoutIntervals = 3; |
| 56 | 55 |
| 57 const int64_t kMaxWarningLogIntervalMs = 10000; | 56 const int64_t kMaxWarningLogIntervalMs = 10000; |
| 58 | 57 |
| 59 } // namespace | 58 } // namespace |
| 60 | 59 |
| 61 struct RTCPReceiver::PacketInformation { | 60 struct RTCPReceiver::PacketInformation { |
| 62 uint32_t packet_type_flags = 0; // RTCPPacketTypeFlags bit field. | 61 uint32_t packet_type_flags = 0; // RTCPPacketTypeFlags bit field. |
| (...skipping 18 matching lines...) Expand all Loading... | |
| 81 | 80 |
| 82 int64_t last_fir_request_ms = 0; | 81 int64_t last_fir_request_ms = 0; |
| 83 int32_t last_fir_sequence_number = -1; | 82 int32_t last_fir_sequence_number = -1; |
| 84 | 83 |
| 85 bool ready_for_delete = false; | 84 bool ready_for_delete = false; |
| 86 | 85 |
| 87 std::vector<rtcp::TmmbItem> tmmbn; | 86 std::vector<rtcp::TmmbItem> tmmbn; |
| 88 std::map<uint32_t, TimedTmmbrItem> tmmbr; | 87 std::map<uint32_t, TimedTmmbrItem> tmmbr; |
| 89 }; | 88 }; |
| 90 | 89 |
| 90 struct RTCPReceiver::ReportBlockInformation { | |
|
philipel
2016/10/03 12:33:17
WDYT about |AggregatedRttInfo| instead of |ReportB
danilchap
2016/10/03 16:10:12
The structure still hold the ReportBlock itself.
(
| |
| 91 RTCPReportBlock remote_receive_block; | |
| 92 | |
| 93 int64_t last_rtt_ms = 0; | |
| 94 int64_t min_rtt_ms = 0; | |
| 95 int64_t max_rtt_ms = 0; | |
| 96 int64_t sum_rtt_ms = 0; | |
| 97 size_t num_rtts = 0; | |
| 98 }; | |
| 99 | |
| 91 RTCPReceiver::RTCPReceiver( | 100 RTCPReceiver::RTCPReceiver( |
| 92 Clock* clock, | 101 Clock* clock, |
| 93 bool receiver_only, | 102 bool receiver_only, |
| 94 RtcpPacketTypeCounterObserver* packet_type_counter_observer, | 103 RtcpPacketTypeCounterObserver* packet_type_counter_observer, |
| 95 RtcpBandwidthObserver* rtcp_bandwidth_observer, | 104 RtcpBandwidthObserver* rtcp_bandwidth_observer, |
| 96 RtcpIntraFrameObserver* rtcp_intra_frame_observer, | 105 RtcpIntraFrameObserver* rtcp_intra_frame_observer, |
| 97 TransportFeedbackObserver* transport_feedback_observer, | 106 TransportFeedbackObserver* transport_feedback_observer, |
| 98 ModuleRtpRtcp* owner) | 107 ModuleRtpRtcp* owner) |
| 99 : _clock(clock), | 108 : _clock(clock), |
| 100 receiver_only_(receiver_only), | 109 receiver_only_(receiver_only), |
| (...skipping 12 matching lines...) Expand all Loading... | |
| 113 xr_rr_rtt_ms_(0), | 122 xr_rr_rtt_ms_(0), |
| 114 _lastReceivedRrMs(0), | 123 _lastReceivedRrMs(0), |
| 115 _lastIncreasedSequenceNumberMs(0), | 124 _lastIncreasedSequenceNumberMs(0), |
| 116 stats_callback_(NULL), | 125 stats_callback_(NULL), |
| 117 packet_type_counter_observer_(packet_type_counter_observer), | 126 packet_type_counter_observer_(packet_type_counter_observer), |
| 118 num_skipped_packets_(0), | 127 num_skipped_packets_(0), |
| 119 last_skipped_packets_warning_(clock->TimeInMilliseconds()) { | 128 last_skipped_packets_warning_(clock->TimeInMilliseconds()) { |
| 120 memset(&_remoteSenderInfo, 0, sizeof(_remoteSenderInfo)); | 129 memset(&_remoteSenderInfo, 0, sizeof(_remoteSenderInfo)); |
| 121 } | 130 } |
| 122 | 131 |
| 123 RTCPReceiver::~RTCPReceiver() { | 132 RTCPReceiver::~RTCPReceiver() {} |
| 124 ReportBlockMap::iterator it = _receivedReportBlockMap.begin(); | |
| 125 for (; it != _receivedReportBlockMap.end(); ++it) { | |
| 126 ReportBlockInfoMap* info_map = &(it->second); | |
| 127 while (!info_map->empty()) { | |
| 128 ReportBlockInfoMap::iterator it_info = info_map->begin(); | |
| 129 delete it_info->second; | |
| 130 info_map->erase(it_info); | |
| 131 } | |
| 132 } | |
| 133 } | |
| 134 | 133 |
| 135 bool RTCPReceiver::IncomingPacket(const uint8_t* packet, size_t packet_size) { | 134 bool RTCPReceiver::IncomingPacket(const uint8_t* packet, size_t packet_size) { |
| 136 if (packet_size == 0) { | 135 if (packet_size == 0) { |
| 137 LOG(LS_WARNING) << "Incoming empty RTCP packet"; | 136 LOG(LS_WARNING) << "Incoming empty RTCP packet"; |
| 138 return false; | 137 return false; |
| 139 } | 138 } |
| 140 | 139 |
| 141 PacketInformation packet_information; | 140 PacketInformation packet_information; |
| 142 if (!ParseCompoundPacket(packet, packet + packet_size, &packet_information)) | 141 if (!ParseCompoundPacket(packet, packet + packet_size, &packet_information)) |
| 143 return false; | 142 return false; |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 179 main_ssrc_ = main_ssrc; | 178 main_ssrc_ = main_ssrc; |
| 180 registered_ssrcs_ = registered_ssrcs; | 179 registered_ssrcs_ = registered_ssrcs; |
| 181 } | 180 } |
| 182 { | 181 { |
| 183 if (_cbRtcpIntraFrameObserver && old_ssrc != main_ssrc) { | 182 if (_cbRtcpIntraFrameObserver && old_ssrc != main_ssrc) { |
| 184 _cbRtcpIntraFrameObserver->OnLocalSsrcChanged(old_ssrc, main_ssrc); | 183 _cbRtcpIntraFrameObserver->OnLocalSsrcChanged(old_ssrc, main_ssrc); |
| 185 } | 184 } |
| 186 } | 185 } |
| 187 } | 186 } |
| 188 | 187 |
| 189 int32_t RTCPReceiver::RTT(uint32_t remoteSSRC, | 188 int32_t RTCPReceiver::RTT(uint32_t remote_ssrc, |
| 190 int64_t* RTT, | 189 int64_t* last_rtt_ms, |
| 191 int64_t* avgRTT, | 190 int64_t* avg_rtt_ms, |
| 192 int64_t* minRTT, | 191 int64_t* min_rtt_ms, |
| 193 int64_t* maxRTT) const { | 192 int64_t* max_rtt_ms) const { |
| 194 rtc::CritScope lock(&_criticalSectionRTCPReceiver); | 193 rtc::CritScope lock(&_criticalSectionRTCPReceiver); |
| 195 | 194 |
| 196 RTCPReportBlockInformation* reportBlock = | 195 auto it = received_report_blocks_.find(main_ssrc_); |
| 197 GetReportBlockInformation(remoteSSRC, main_ssrc_); | 196 if (it == received_report_blocks_.end()) |
| 197 return -1; | |
| 198 | 198 |
| 199 if (reportBlock == NULL) { | 199 auto it_info = it->second.find(remote_ssrc); |
| 200 if (it_info == it->second.end()) | |
| 200 return -1; | 201 return -1; |
| 201 } | 202 |
| 202 if (RTT) { | 203 const ReportBlockInformation* report_block = &it_info->second; |
| 203 *RTT = reportBlock->RTT; | 204 |
| 204 } | 205 if (report_block->num_rtts == 0) |
| 205 if (avgRTT) { | 206 return -1; |
| 206 *avgRTT = reportBlock->avgRTT; | 207 |
| 207 } | 208 if (last_rtt_ms) |
| 208 if (minRTT) { | 209 *last_rtt_ms = report_block->last_rtt_ms; |
| 209 *minRTT = reportBlock->minRTT; | 210 |
| 210 } | 211 if (avg_rtt_ms) |
| 211 if (maxRTT) { | 212 *avg_rtt_ms = report_block->sum_rtt_ms / report_block->num_rtts; |
| 212 *maxRTT = reportBlock->maxRTT; | 213 |
| 213 } | 214 if (min_rtt_ms) |
| 215 *min_rtt_ms = report_block->min_rtt_ms; | |
| 216 | |
| 217 if (max_rtt_ms) | |
| 218 *max_rtt_ms = report_block->max_rtt_ms; | |
| 219 | |
| 214 return 0; | 220 return 0; |
| 215 } | 221 } |
| 216 | 222 |
| 217 void RTCPReceiver::SetRtcpXrRrtrStatus(bool enable) { | 223 void RTCPReceiver::SetRtcpXrRrtrStatus(bool enable) { |
| 218 rtc::CritScope lock(&_criticalSectionRTCPReceiver); | 224 rtc::CritScope lock(&_criticalSectionRTCPReceiver); |
| 219 xr_rrtr_status_ = enable; | 225 xr_rrtr_status_ = enable; |
| 220 } | 226 } |
| 221 | 227 |
| 222 bool RTCPReceiver::GetAndResetXrRrRtt(int64_t* rtt_ms) { | 228 bool RTCPReceiver::GetAndResetXrRrRtt(int64_t* rtt_ms) { |
| 223 assert(rtt_ms); | 229 assert(rtt_ms); |
| (...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 285 int32_t RTCPReceiver::SenderInfoReceived(RTCPSenderInfo* senderInfo) const { | 291 int32_t RTCPReceiver::SenderInfoReceived(RTCPSenderInfo* senderInfo) const { |
| 286 assert(senderInfo); | 292 assert(senderInfo); |
| 287 rtc::CritScope lock(&_criticalSectionRTCPReceiver); | 293 rtc::CritScope lock(&_criticalSectionRTCPReceiver); |
| 288 if (_lastReceivedSRNTPsecs == 0) { | 294 if (_lastReceivedSRNTPsecs == 0) { |
| 289 return -1; | 295 return -1; |
| 290 } | 296 } |
| 291 memcpy(senderInfo, &(_remoteSenderInfo), sizeof(RTCPSenderInfo)); | 297 memcpy(senderInfo, &(_remoteSenderInfo), sizeof(RTCPSenderInfo)); |
| 292 return 0; | 298 return 0; |
| 293 } | 299 } |
| 294 | 300 |
| 295 // statistics | 301 // We can get multiple receive reports when we receive the report from a CE. |
| 296 // we can get multiple receive reports when we receive the report from a CE | |
| 297 int32_t RTCPReceiver::StatisticsReceived( | 302 int32_t RTCPReceiver::StatisticsReceived( |
| 298 std::vector<RTCPReportBlock>* receiveBlocks) const { | 303 std::vector<RTCPReportBlock>* receive_blocks) const { |
| 299 assert(receiveBlocks); | 304 RTC_DCHECK(receive_blocks); |
| 300 rtc::CritScope lock(&_criticalSectionRTCPReceiver); | 305 rtc::CritScope lock(&_criticalSectionRTCPReceiver); |
| 301 ReportBlockMap::const_iterator it = _receivedReportBlockMap.begin(); | 306 for (const auto& reports_per_receiver : received_report_blocks_) |
| 302 for (; it != _receivedReportBlockMap.end(); ++it) { | 307 for (const auto& report : reports_per_receiver.second) |
| 303 const ReportBlockInfoMap* info_map = &(it->second); | 308 receive_blocks->push_back(report.second.remote_receive_block); |
| 304 ReportBlockInfoMap::const_iterator it_info = info_map->begin(); | |
| 305 for (; it_info != info_map->end(); ++it_info) { | |
| 306 receiveBlocks->push_back(it_info->second->remoteReceiveBlock); | |
| 307 } | |
| 308 } | |
| 309 return 0; | 309 return 0; |
| 310 } | 310 } |
| 311 | 311 |
| 312 bool RTCPReceiver::ParseCompoundPacket(const uint8_t* packet_begin, | 312 bool RTCPReceiver::ParseCompoundPacket(const uint8_t* packet_begin, |
| 313 const uint8_t* packet_end, | 313 const uint8_t* packet_end, |
| 314 PacketInformation* packet_information) { | 314 PacketInformation* packet_information) { |
| 315 rtc::CritScope lock(&_criticalSectionRTCPReceiver); | 315 rtc::CritScope lock(&_criticalSectionRTCPReceiver); |
| 316 | 316 |
| 317 CommonHeader rtcp_block; | 317 CommonHeader rtcp_block; |
| 318 for (const uint8_t* next_block = packet_begin; next_block != packet_end; | 318 for (const uint8_t* next_block = packet_begin; next_block != packet_end; |
| (...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 474 "remote_ssrc", remoteSSRC, "ssrc", main_ssrc_); | 474 "remote_ssrc", remoteSSRC, "ssrc", main_ssrc_); |
| 475 | 475 |
| 476 packet_information->packet_type_flags |= kRtcpRr; | 476 packet_information->packet_type_flags |= kRtcpRr; |
| 477 | 477 |
| 478 for (const ReportBlock& report_block : receiver_report.report_blocks()) | 478 for (const ReportBlock& report_block : receiver_report.report_blocks()) |
| 479 HandleReportBlock(report_block, packet_information, remoteSSRC); | 479 HandleReportBlock(report_block, packet_information, remoteSSRC); |
| 480 } | 480 } |
| 481 | 481 |
| 482 void RTCPReceiver::HandleReportBlock(const ReportBlock& report_block, | 482 void RTCPReceiver::HandleReportBlock(const ReportBlock& report_block, |
| 483 PacketInformation* packet_information, | 483 PacketInformation* packet_information, |
| 484 uint32_t remoteSSRC) { | 484 uint32_t remote_ssrc) { |
| 485 // This will be called once per report block in the RTCP packet. | 485 // This will be called once per report block in the RTCP packet. |
| 486 // We filter out all report blocks that are not for us. | 486 // We filter out all report blocks that are not for us. |
| 487 // Each packet has max 31 RR blocks. | 487 // Each packet has max 31 RR blocks. |
| 488 // | 488 // |
| 489 // We can calc RTT if we send a send report and get a report block back. | 489 // We can calc RTT if we send a send report and get a report block back. |
| 490 | 490 |
| 491 // |rtcpPacket.ReportBlockItem.SSRC| is the SSRC identifier of the source to | 491 // |report_block.source_ssrc()| is the SSRC identifier of the source to |
| 492 // which the information in this reception report block pertains. | 492 // which the information in this reception report block pertains. |
| 493 | 493 |
| 494 // Filter out all report blocks that are not for us. | 494 // Filter out all report blocks that are not for us. |
| 495 if (registered_ssrcs_.count(report_block.source_ssrc()) == 0) | 495 if (registered_ssrcs_.count(report_block.source_ssrc()) == 0) |
| 496 return; | 496 return; |
| 497 | 497 |
| 498 RTCPReportBlockInformation* reportBlock = | 498 ReportBlockInformation* report_block_info = |
| 499 CreateOrGetReportBlockInformation(remoteSSRC, report_block.source_ssrc()); | 499 &received_report_blocks_[report_block.source_ssrc()][remote_ssrc]; |
| 500 if (reportBlock == NULL) { | |
| 501 LOG(LS_WARNING) << "Failed to CreateReportBlockInformation(" << remoteSSRC | |
| 502 << ")"; | |
| 503 return; | |
| 504 } | |
| 505 | 500 |
| 506 _lastReceivedRrMs = _clock->TimeInMilliseconds(); | 501 _lastReceivedRrMs = _clock->TimeInMilliseconds(); |
| 507 reportBlock->remoteReceiveBlock.remoteSSRC = remoteSSRC; | 502 report_block_info->remote_receive_block.remoteSSRC = remote_ssrc; |
| 508 reportBlock->remoteReceiveBlock.sourceSSRC = report_block.source_ssrc(); | 503 report_block_info->remote_receive_block.sourceSSRC = |
| 509 reportBlock->remoteReceiveBlock.fractionLost = report_block.fraction_lost(); | 504 report_block.source_ssrc(); |
| 510 reportBlock->remoteReceiveBlock.cumulativeLost = | 505 report_block_info->remote_receive_block.fractionLost = |
| 506 report_block.fraction_lost(); | |
| 507 report_block_info->remote_receive_block.cumulativeLost = | |
| 511 report_block.cumulative_lost(); | 508 report_block.cumulative_lost(); |
| 512 if (report_block.extended_high_seq_num() > | 509 if (report_block.extended_high_seq_num() > |
| 513 reportBlock->remoteReceiveBlock.extendedHighSeqNum) { | 510 report_block_info->remote_receive_block.extendedHighSeqNum) { |
| 514 // We have successfully delivered new RTP packets to the remote side after | 511 // We have successfully delivered new RTP packets to the remote side after |
| 515 // the last RR was sent from the remote side. | 512 // the last RR was sent from the remote side. |
| 516 _lastIncreasedSequenceNumberMs = _lastReceivedRrMs; | 513 _lastIncreasedSequenceNumberMs = _lastReceivedRrMs; |
| 517 } | 514 } |
| 518 reportBlock->remoteReceiveBlock.extendedHighSeqNum = | 515 report_block_info->remote_receive_block.extendedHighSeqNum = |
| 519 report_block.extended_high_seq_num(); | 516 report_block.extended_high_seq_num(); |
| 520 reportBlock->remoteReceiveBlock.jitter = report_block.jitter(); | 517 report_block_info->remote_receive_block.jitter = report_block.jitter(); |
| 521 reportBlock->remoteReceiveBlock.delaySinceLastSR = | 518 report_block_info->remote_receive_block.delaySinceLastSR = |
| 522 report_block.delay_since_last_sr(); | 519 report_block.delay_since_last_sr(); |
| 523 reportBlock->remoteReceiveBlock.lastSR = report_block.last_sr(); | 520 report_block_info->remote_receive_block.lastSR = report_block.last_sr(); |
| 524 | 521 |
| 525 if (report_block.jitter() > reportBlock->remoteMaxJitter) | 522 int64_t rtt_ms = 0; |
| 526 reportBlock->remoteMaxJitter = report_block.jitter(); | |
| 527 | |
| 528 int64_t rtt = 0; | |
| 529 uint32_t send_time = report_block.last_sr(); | 523 uint32_t send_time = report_block.last_sr(); |
| 530 // RFC3550, section 6.4.1, LSR field discription states: | 524 // RFC3550, section 6.4.1, LSR field discription states: |
| 531 // If no SR has been received yet, the field is set to zero. | 525 // If no SR has been received yet, the field is set to zero. |
| 532 // Receiver rtp_rtcp module is not expected to calculate rtt using | 526 // Receiver rtp_rtcp module is not expected to calculate rtt using |
| 533 // Sender Reports even if it accidentally can. | 527 // Sender Reports even if it accidentally can. |
| 534 if (!receiver_only_ && send_time != 0) { | 528 if (!receiver_only_ && send_time != 0) { |
| 535 uint32_t delay = report_block.delay_since_last_sr(); | 529 uint32_t delay = report_block.delay_since_last_sr(); |
| 536 // Local NTP time. | 530 // Local NTP time. |
| 537 uint32_t receive_time = CompactNtp(NtpTime(*_clock)); | 531 uint32_t receive_time = CompactNtp(NtpTime(*_clock)); |
| 538 | 532 |
| 539 // RTT in 1/(2^16) seconds. | 533 // RTT in 1/(2^16) seconds. |
| 540 uint32_t rtt_ntp = receive_time - delay - send_time; | 534 uint32_t rtt_ntp = receive_time - delay - send_time; |
| 541 // Convert to 1/1000 seconds (milliseconds). | 535 // Convert to 1/1000 seconds (milliseconds). |
| 542 rtt = CompactNtpRttToMs(rtt_ntp); | 536 rtt_ms = CompactNtpRttToMs(rtt_ntp); |
| 543 if (rtt > reportBlock->maxRTT) { | 537 if (rtt_ms > report_block_info->max_rtt_ms) |
| 544 // Store max RTT. | 538 report_block_info->max_rtt_ms = rtt_ms; |
| 545 reportBlock->maxRTT = rtt; | |
| 546 } | |
| 547 if (reportBlock->minRTT == 0) { | |
| 548 // First RTT. | |
| 549 reportBlock->minRTT = rtt; | |
| 550 } else if (rtt < reportBlock->minRTT) { | |
| 551 // Store min RTT. | |
| 552 reportBlock->minRTT = rtt; | |
| 553 } | |
| 554 // Store last RTT. | |
| 555 reportBlock->RTT = rtt; | |
| 556 | 539 |
| 557 // store average RTT | 540 if (report_block_info->num_rtts == 0 || |
| 558 if (reportBlock->numAverageCalcs != 0) { | 541 rtt_ms < report_block_info->min_rtt_ms) |
| 559 float ac = static_cast<float>(reportBlock->numAverageCalcs); | 542 report_block_info->min_rtt_ms = rtt_ms; |
| 560 float newAverage = | 543 |
| 561 ((ac / (ac + 1)) * reportBlock->avgRTT) + ((1 / (ac + 1)) * rtt); | 544 report_block_info->last_rtt_ms = rtt_ms; |
| 562 reportBlock->avgRTT = static_cast<int64_t>(newAverage + 0.5f); | 545 report_block_info->sum_rtt_ms += rtt_ms; |
| 563 } else { | 546 ++report_block_info->num_rtts; |
| 564 // First RTT. | |
| 565 reportBlock->avgRTT = rtt; | |
| 566 } | |
| 567 reportBlock->numAverageCalcs++; | |
| 568 } | 547 } |
| 569 | 548 |
| 570 TRACE_COUNTER_ID1(TRACE_DISABLED_BY_DEFAULT("webrtc_rtp"), "RR_RTT", | 549 TRACE_COUNTER_ID1(TRACE_DISABLED_BY_DEFAULT("webrtc_rtp"), "RR_RTT", |
| 571 report_block.source_ssrc(), rtt); | 550 report_block.source_ssrc(), rtt_ms); |
| 572 | 551 |
| 573 packet_information->rtt_ms = rtt; | 552 packet_information->rtt_ms = rtt_ms; |
| 574 packet_information->report_blocks.push_back(reportBlock->remoteReceiveBlock); | 553 packet_information->report_blocks.push_back( |
| 575 } | 554 report_block_info->remote_receive_block); |
| 576 | |
| 577 RTCPReportBlockInformation* RTCPReceiver::CreateOrGetReportBlockInformation( | |
| 578 uint32_t remote_ssrc, | |
| 579 uint32_t source_ssrc) { | |
| 580 RTCPReportBlockInformation* info = | |
| 581 GetReportBlockInformation(remote_ssrc, source_ssrc); | |
| 582 if (info == NULL) { | |
| 583 info = new RTCPReportBlockInformation; | |
| 584 _receivedReportBlockMap[source_ssrc][remote_ssrc] = info; | |
| 585 } | |
| 586 return info; | |
| 587 } | |
| 588 | |
| 589 RTCPReportBlockInformation* RTCPReceiver::GetReportBlockInformation( | |
| 590 uint32_t remote_ssrc, | |
| 591 uint32_t source_ssrc) const { | |
| 592 ReportBlockMap::const_iterator it = _receivedReportBlockMap.find(source_ssrc); | |
| 593 if (it == _receivedReportBlockMap.end()) { | |
| 594 return NULL; | |
| 595 } | |
| 596 const ReportBlockInfoMap* info_map = &(it->second); | |
| 597 ReportBlockInfoMap::const_iterator it_info = info_map->find(remote_ssrc); | |
| 598 if (it_info == info_map->end()) { | |
| 599 return NULL; | |
| 600 } | |
| 601 return it_info->second; | |
| 602 } | 555 } |
| 603 | 556 |
| 604 void RTCPReceiver::CreateReceiveInformation(uint32_t remote_ssrc) { | 557 void RTCPReceiver::CreateReceiveInformation(uint32_t remote_ssrc) { |
| 605 // Create or find receive information. | 558 // Create or find receive information. |
| 606 ReceiveInformation* receive_info = &received_infos_[remote_ssrc]; | 559 ReceiveInformation* receive_info = &received_infos_[remote_ssrc]; |
| 607 // Update that this remote is alive. | 560 // Update that this remote is alive. |
| 608 receive_info->last_time_received_ms = _clock->TimeInMilliseconds(); | 561 receive_info->last_time_received_ms = _clock->TimeInMilliseconds(); |
| 609 } | 562 } |
| 610 | 563 |
| 611 RTCPReceiver::ReceiveInformation* RTCPReceiver::GetReceiveInformation( | 564 RTCPReceiver::ReceiveInformation* RTCPReceiver::GetReceiveInformation( |
| (...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 730 } | 683 } |
| 731 | 684 |
| 732 void RTCPReceiver::HandleBYE(const CommonHeader& rtcp_block) { | 685 void RTCPReceiver::HandleBYE(const CommonHeader& rtcp_block) { |
| 733 rtcp::Bye bye; | 686 rtcp::Bye bye; |
| 734 if (!bye.Parse(rtcp_block)) { | 687 if (!bye.Parse(rtcp_block)) { |
| 735 ++num_skipped_packets_; | 688 ++num_skipped_packets_; |
| 736 return; | 689 return; |
| 737 } | 690 } |
| 738 | 691 |
| 739 // clear our lists | 692 // clear our lists |
| 740 ReportBlockMap::iterator it = _receivedReportBlockMap.begin(); | 693 for (auto& reports_per_receiver : received_report_blocks_) |
| 741 for (; it != _receivedReportBlockMap.end(); ++it) { | 694 reports_per_receiver.second.erase(bye.sender_ssrc()); |
| 742 ReportBlockInfoMap* info_map = &(it->second); | |
| 743 ReportBlockInfoMap::iterator it_info = info_map->find(bye.sender_ssrc()); | |
| 744 if (it_info != info_map->end()) { | |
| 745 delete it_info->second; | |
| 746 info_map->erase(it_info); | |
| 747 } | |
| 748 } | |
| 749 | 695 |
| 750 // We can't delete it due to TMMBR. | 696 // We can't delete it due to TMMBR. |
| 751 ReceiveInformation* receive_info = GetReceiveInformation(bye.sender_ssrc()); | 697 ReceiveInformation* receive_info = GetReceiveInformation(bye.sender_ssrc()); |
| 752 if (receive_info) | 698 if (receive_info) |
| 753 receive_info->ready_for_delete = true; | 699 receive_info->ready_for_delete = true; |
| 754 | 700 |
| 755 received_cnames_.erase(bye.sender_ssrc()); | 701 received_cnames_.erase(bye.sender_ssrc()); |
| 756 xr_rr_rtt_ms_ = 0; | 702 xr_rr_rtt_ms_ = 0; |
| 757 } | 703 } |
| 758 | 704 |
| (...skipping 372 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1131 } else { | 1077 } else { |
| 1132 candidates.push_back(it->second.tmmbr_item); | 1078 candidates.push_back(it->second.tmmbr_item); |
| 1133 ++it; | 1079 ++it; |
| 1134 } | 1080 } |
| 1135 } | 1081 } |
| 1136 } | 1082 } |
| 1137 return candidates; | 1083 return candidates; |
| 1138 } | 1084 } |
| 1139 | 1085 |
| 1140 } // namespace webrtc | 1086 } // namespace webrtc |
| OLD | NEW |