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 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 132 | 132 |
| 133 const FeedbackState& feedback_state_; | 133 const FeedbackState& feedback_state_; |
| 134 const int32_t nack_size_; | 134 const int32_t nack_size_; |
| 135 const uint16_t* nack_list_; | 135 const uint16_t* nack_list_; |
| 136 const NtpTime now_; | 136 const NtpTime now_; |
| 137 }; | 137 }; |
| 138 | 138 |
| 139 RTCPSender::RTCPSender( | 139 RTCPSender::RTCPSender( |
| 140 bool audio, | 140 bool audio, |
| 141 Clock* clock, | 141 Clock* clock, |
| 142 ReceiveStatistics* receive_statistics, | 142 ReceiveStatisticsProvider* receive_statistics, |
| 143 RtcpPacketTypeCounterObserver* packet_type_counter_observer, | 143 RtcpPacketTypeCounterObserver* packet_type_counter_observer, |
| 144 RtcEventLog* event_log, | 144 RtcEventLog* event_log, |
| 145 Transport* outgoing_transport) | 145 Transport* outgoing_transport) |
| 146 : audio_(audio), | 146 : audio_(audio), |
| 147 clock_(clock), | 147 clock_(clock), |
| 148 random_(clock_->TimeInMicroseconds()), | 148 random_(clock_->TimeInMicroseconds()), |
| 149 method_(RtcpMode::kOff), | 149 method_(RtcpMode::kOff), |
| 150 event_log_(event_log), | 150 event_log_(event_log), |
| 151 transport_(outgoing_transport), | 151 transport_(outgoing_transport), |
| 152 using_nack_(false), | 152 using_nack_(false), |
| (...skipping 676 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 829 RTC_DCHECK(!(IsFlagPresent(kRtcpSr) && IsFlagPresent(kRtcpRr))); | 829 RTC_DCHECK(!(IsFlagPresent(kRtcpSr) && IsFlagPresent(kRtcpRr))); |
| 830 } | 830 } |
| 831 } | 831 } |
| 832 | 832 |
| 833 std::vector<rtcp::ReportBlock> RTCPSender::CreateReportBlocks( | 833 std::vector<rtcp::ReportBlock> RTCPSender::CreateReportBlocks( |
| 834 const FeedbackState& feedback_state) { | 834 const FeedbackState& feedback_state) { |
| 835 std::vector<rtcp::ReportBlock> result; | 835 std::vector<rtcp::ReportBlock> result; |
| 836 if (!receive_statistics_) | 836 if (!receive_statistics_) |
| 837 return result; | 837 return result; |
| 838 | 838 |
| 839 StatisticianMap statisticians = receive_statistics_->GetActiveStatisticians(); | 839 // TODO(danilchap): Support sending more than |RTCP_MAX_REPORT_BLOCKS| per |
| 840 result.reserve(statisticians.size()); | 840 // compound rtcp packet when single rtcp module is used for multiple media |
| 841 for (auto& statistician : statisticians) { | 841 // streams. |
| 842 // Do we have receive statistics to send? | 842 result = receive_statistics_->RtcpReportBlocks(RTCP_MAX_REPORT_BLOCKS); |
|
eladalon
2017/07/27 09:07:31
nit: Consider not passing this RFC-defined constan
danilchap
2017/07/27 10:04:32
I did that initially, but then introduce this para
eladalon
2017/07/27 10:40:18
Acknowledged.
| |
| 843 RtcpStatistics stats; | |
| 844 if (!statistician.second->GetStatistics(&stats, true)) | |
| 845 continue; | |
| 846 // TODO(danilchap): Support sending more than |RTCP_MAX_REPORT_BLOCKS| per | |
| 847 // compound rtcp packet when single rtcp module is used for multiple media | |
| 848 // streams. | |
| 849 if (result.size() >= RTCP_MAX_REPORT_BLOCKS) { | |
| 850 LOG(LS_WARNING) << "Too many report blocks."; | |
| 851 continue; | |
| 852 } | |
| 853 result.emplace_back(); | |
| 854 rtcp::ReportBlock& block = result.back(); | |
| 855 block.SetMediaSsrc(statistician.first); | |
| 856 block.SetFractionLost(stats.fraction_lost); | |
| 857 if (!block.SetCumulativeLost(stats.cumulative_lost)) { | |
| 858 LOG(LS_WARNING) << "Cumulative lost is oversized."; | |
| 859 result.pop_back(); | |
| 860 continue; | |
| 861 } | |
| 862 block.SetExtHighestSeqNum(stats.extended_max_sequence_number); | |
| 863 block.SetJitter(stats.jitter); | |
| 864 } | |
| 865 | 843 |
| 866 if (!result.empty() && ((feedback_state.last_rr_ntp_secs != 0) || | 844 if (!result.empty() && ((feedback_state.last_rr_ntp_secs != 0) || |
| 867 (feedback_state.last_rr_ntp_frac != 0))) { | 845 (feedback_state.last_rr_ntp_frac != 0))) { |
| 868 // Get our NTP as late as possible to avoid a race. | 846 // Get our NTP as late as possible to avoid a race. |
| 869 uint32_t now = CompactNtp(clock_->CurrentNtpTime()); | 847 uint32_t now = CompactNtp(clock_->CurrentNtpTime()); |
| 870 | 848 |
| 871 uint32_t receive_time = feedback_state.last_rr_ntp_secs & 0x0000FFFF; | 849 uint32_t receive_time = feedback_state.last_rr_ntp_secs & 0x0000FFFF; |
| 872 receive_time <<= 16; | 850 receive_time <<= 16; |
| 873 receive_time += (feedback_state.last_rr_ntp_frac & 0xffff0000) >> 16; | 851 receive_time += (feedback_state.last_rr_ntp_frac & 0xffff0000) >> 16; |
| 874 | 852 |
| (...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1007 max_packet_size = max_packet_size_; | 985 max_packet_size = max_packet_size_; |
| 1008 } | 986 } |
| 1009 | 987 |
| 1010 RTC_DCHECK_LE(max_packet_size, IP_PACKET_SIZE); | 988 RTC_DCHECK_LE(max_packet_size, IP_PACKET_SIZE); |
| 1011 uint8_t buffer[IP_PACKET_SIZE]; | 989 uint8_t buffer[IP_PACKET_SIZE]; |
| 1012 return packet.BuildExternalBuffer(buffer, max_packet_size, &sender) && | 990 return packet.BuildExternalBuffer(buffer, max_packet_size, &sender) && |
| 1013 !sender.send_failure_; | 991 !sender.send_failure_; |
| 1014 } | 992 } |
| 1015 | 993 |
| 1016 } // namespace webrtc | 994 } // namespace webrtc |
| OLD | NEW |