OLD | NEW |
1 /* | 1 /* |
2 * Copyright (c) 2015 The WebRTC project authors. All Rights Reserved. | 2 * Copyright (c) 2015 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 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
106 } | 106 } |
107 | 107 |
108 FeedbackPacket* RembReceiver::GetFeedback(int64_t now_ms) { | 108 FeedbackPacket* RembReceiver::GetFeedback(int64_t now_ms) { |
109 BWE_TEST_LOGGING_CONTEXT("Remb"); | 109 BWE_TEST_LOGGING_CONTEXT("Remb"); |
110 uint32_t estimated_bps = 0; | 110 uint32_t estimated_bps = 0; |
111 RembFeedback* feedback = NULL; | 111 RembFeedback* feedback = NULL; |
112 if (LatestEstimate(&estimated_bps)) { | 112 if (LatestEstimate(&estimated_bps)) { |
113 StatisticianMap statisticians = recv_stats_->GetActiveStatisticians(); | 113 StatisticianMap statisticians = recv_stats_->GetActiveStatisticians(); |
114 RTCPReportBlock report_block; | 114 RTCPReportBlock report_block; |
115 if (!statisticians.empty()) { | 115 if (!statisticians.empty()) { |
116 report_block = BuildReportBlock(statisticians.begin()->second); | 116 latest_report_block_ = BuildReportBlock(statisticians.begin()->second); |
117 } | 117 } |
118 | 118 |
119 feedback = new RembFeedback(flow_id_, now_ms * 1000, last_feedback_ms_, | 119 feedback = new RembFeedback(flow_id_, now_ms * 1000, last_feedback_ms_, |
120 estimated_bps, report_block); | 120 estimated_bps, latest_report_block_); |
121 last_feedback_ms_ = now_ms; | 121 last_feedback_ms_ = now_ms; |
122 | 122 |
123 double estimated_kbps = static_cast<double>(estimated_bps) / 1000.0; | 123 double estimated_kbps = static_cast<double>(estimated_bps) / 1000.0; |
124 RTC_UNUSED(estimated_kbps); | 124 RTC_UNUSED(estimated_kbps); |
125 if (plot_estimate_) { | 125 if (plot_estimate_) { |
126 BWE_TEST_LOGGING_PLOT(0, estimate_log_prefix_, | 126 BWE_TEST_LOGGING_PLOT(0, estimate_log_prefix_, |
127 clock_.TimeInMilliseconds(), estimated_kbps); | 127 clock_.TimeInMilliseconds(), estimated_kbps); |
128 } | 128 } |
129 } | 129 } |
130 return feedback; | 130 return feedback; |
131 } | 131 } |
132 | 132 |
133 void RembReceiver::OnReceiveBitrateChanged(const std::vector<uint32_t>& ssrcs, | 133 void RembReceiver::OnReceiveBitrateChanged(const std::vector<uint32_t>& ssrcs, |
134 uint32_t bitrate) {} | 134 uint32_t bitrate) {} |
135 | 135 |
136 RTCPReportBlock RembReceiver::BuildReportBlock( | 136 RTCPReportBlock RembReceiver::BuildReportBlock( |
137 StreamStatistician* statistician) { | 137 StreamStatistician* statistician) { |
138 RTCPReportBlock report_block; | 138 RTCPReportBlock report_block; |
139 RtcpStatistics stats; | 139 RtcpStatistics stats; |
140 if (!statistician->GetStatistics(&stats, true)) | 140 RTC_DCHECK(statistician->GetStatistics(&stats, true)); |
141 return report_block; | |
142 report_block.fractionLost = stats.fraction_lost; | 141 report_block.fractionLost = stats.fraction_lost; |
143 report_block.cumulativeLost = stats.cumulative_lost; | 142 report_block.cumulativeLost = stats.cumulative_lost; |
144 report_block.extendedHighSeqNum = stats.extended_max_sequence_number; | 143 report_block.extendedHighSeqNum = stats.extended_max_sequence_number; |
145 report_block.jitter = stats.jitter; | 144 report_block.jitter = stats.jitter; |
146 return report_block; | 145 return report_block; |
147 } | 146 } |
148 | 147 |
149 bool RembReceiver::LatestEstimate(uint32_t* estimate_bps) { | 148 bool RembReceiver::LatestEstimate(uint32_t* estimate_bps) { |
150 if (latest_estimate_bps_ < 0) { | 149 if (latest_estimate_bps_ < 0) { |
151 std::vector<uint32_t> ssrcs; | 150 std::vector<uint32_t> ssrcs; |
152 uint32_t bps = 0; | 151 uint32_t bps = 0; |
153 if (!estimator_->LatestEstimate(&ssrcs, &bps)) { | 152 if (!estimator_->LatestEstimate(&ssrcs, &bps)) { |
154 return false; | 153 return false; |
155 } | 154 } |
156 latest_estimate_bps_ = bps; | 155 latest_estimate_bps_ = bps; |
157 } | 156 } |
158 *estimate_bps = latest_estimate_bps_; | 157 *estimate_bps = latest_estimate_bps_; |
159 return true; | 158 return true; |
160 } | 159 } |
161 | 160 |
162 } // namespace bwe | 161 } // namespace bwe |
163 } // namespace testing | 162 } // namespace testing |
164 } // namespace webrtc | 163 } // namespace webrtc |
OLD | NEW |