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 162 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
173 } | 173 } |
174 for (size_t i = 0; i < num_active_rtp_rtcp_modules_; ++i) | 174 for (size_t i = 0; i < num_active_rtp_rtcp_modules_; ++i) |
175 packet_router_->RemoveRtpModule(rtp_rtcp_modules_[i], sender_); | 175 packet_router_->RemoveRtpModule(rtp_rtcp_modules_[i], sender_); |
176 for (RtpRtcp* rtp_rtcp : rtp_rtcp_modules_) { | 176 for (RtpRtcp* rtp_rtcp : rtp_rtcp_modules_) { |
177 module_process_thread_->DeRegisterModule(rtp_rtcp); | 177 module_process_thread_->DeRegisterModule(rtp_rtcp); |
178 delete rtp_rtcp; | 178 delete rtp_rtcp; |
179 } | 179 } |
180 } | 180 } |
181 | 181 |
182 void ViEChannel::UpdateHistograms() { | 182 void ViEChannel::UpdateHistograms() { |
183 int64_t now = Clock::GetRealTimeClock()->TimeInMilliseconds(); | |
184 | |
185 if (sender_) { | 183 if (sender_) { |
186 RtcpPacketTypeCounter rtcp_counter; | |
187 GetSendRtcpPacketTypeCounter(&rtcp_counter); | |
188 int64_t elapsed_sec = rtcp_counter.TimeSinceFirstPacketInMs(now) / 1000; | |
189 if (elapsed_sec > metrics::kMinRunTimeInSeconds) { | |
190 RTC_HISTOGRAM_COUNTS_10000("WebRTC.Video.NackPacketsReceivedPerMinute", | |
191 rtcp_counter.nack_packets * 60 / elapsed_sec); | |
192 RTC_HISTOGRAM_COUNTS_10000("WebRTC.Video.FirPacketsReceivedPerMinute", | |
193 rtcp_counter.fir_packets * 60 / elapsed_sec); | |
194 RTC_HISTOGRAM_COUNTS_10000("WebRTC.Video.PliPacketsReceivedPerMinute", | |
195 rtcp_counter.pli_packets * 60 / elapsed_sec); | |
196 if (rtcp_counter.nack_requests > 0) { | |
197 RTC_HISTOGRAM_PERCENTAGE( | |
198 "WebRTC.Video.UniqueNackRequestsReceivedInPercent", | |
199 rtcp_counter.UniqueNackRequestsInPercent()); | |
200 } | |
201 } | |
202 | |
203 StreamDataCounters rtp; | 184 StreamDataCounters rtp; |
204 StreamDataCounters rtx; | 185 StreamDataCounters rtx; |
205 GetSendStreamDataCounters(&rtp, &rtx); | 186 GetSendStreamDataCounters(&rtp, &rtx); |
206 StreamDataCounters rtp_rtx = rtp; | 187 StreamDataCounters rtp_rtx = rtp; |
207 rtp_rtx.Add(rtx); | 188 rtp_rtx.Add(rtx); |
208 elapsed_sec = rtp_rtx.TimeSinceFirstPacketInMs( | 189 int64_t elapsed_sec = rtp_rtx.TimeSinceFirstPacketInMs( |
209 Clock::GetRealTimeClock()->TimeInMilliseconds()) / | 190 Clock::GetRealTimeClock()->TimeInMilliseconds()) / |
210 1000; | 191 1000; |
211 if (elapsed_sec > metrics::kMinRunTimeInSeconds) { | 192 if (elapsed_sec > metrics::kMinRunTimeInSeconds) { |
212 RTC_HISTOGRAM_COUNTS_100000( | 193 RTC_HISTOGRAM_COUNTS_100000( |
213 "WebRTC.Video.BitrateSentInKbps", | 194 "WebRTC.Video.BitrateSentInKbps", |
214 static_cast<int>(rtp_rtx.transmitted.TotalBytes() * 8 / elapsed_sec / | 195 static_cast<int>(rtp_rtx.transmitted.TotalBytes() * 8 / elapsed_sec / |
215 1000)); | 196 1000)); |
216 RTC_HISTOGRAM_COUNTS_10000( | 197 RTC_HISTOGRAM_COUNTS_10000( |
217 "WebRTC.Video.MediaBitrateSentInKbps", | 198 "WebRTC.Video.MediaBitrateSentInKbps", |
218 static_cast<int>(rtp.MediaPayloadBytes() * 8 / elapsed_sec / 1000)); | 199 static_cast<int>(rtp.MediaPayloadBytes() * 8 / elapsed_sec / 1000)); |
219 RTC_HISTOGRAM_COUNTS_10000( | 200 RTC_HISTOGRAM_COUNTS_10000( |
220 "WebRTC.Video.PaddingBitrateSentInKbps", | 201 "WebRTC.Video.PaddingBitrateSentInKbps", |
(...skipping 13 matching lines...) Expand all Loading... |
234 uint8_t pltype_red; | 215 uint8_t pltype_red; |
235 uint8_t pltype_fec; | 216 uint8_t pltype_fec; |
236 rtp_rtcp_modules_[0]->GenericFECStatus(&fec_enabled, &pltype_red, | 217 rtp_rtcp_modules_[0]->GenericFECStatus(&fec_enabled, &pltype_red, |
237 &pltype_fec); | 218 &pltype_fec); |
238 if (fec_enabled) { | 219 if (fec_enabled) { |
239 RTC_HISTOGRAM_COUNTS_10000("WebRTC.Video.FecBitrateSentInKbps", | 220 RTC_HISTOGRAM_COUNTS_10000("WebRTC.Video.FecBitrateSentInKbps", |
240 static_cast<int>(rtp_rtx.fec.TotalBytes() * | 221 static_cast<int>(rtp_rtx.fec.TotalBytes() * |
241 8 / elapsed_sec / 1000)); | 222 8 / elapsed_sec / 1000)); |
242 } | 223 } |
243 } | 224 } |
244 } else if (vie_receiver_.GetRemoteSsrc() > 0) { | |
245 // Get receive stats if we are receiving packets, i.e. there is a remote | |
246 // ssrc. | |
247 RtcpPacketTypeCounter rtcp_counter; | |
248 GetReceiveRtcpPacketTypeCounter(&rtcp_counter); | |
249 int64_t elapsed_sec = rtcp_counter.TimeSinceFirstPacketInMs(now) / 1000; | |
250 if (elapsed_sec > metrics::kMinRunTimeInSeconds) { | |
251 RTC_HISTOGRAM_COUNTS_10000("WebRTC.Video.NackPacketsSentPerMinute", | |
252 rtcp_counter.nack_packets * 60 / elapsed_sec); | |
253 RTC_HISTOGRAM_COUNTS_10000("WebRTC.Video.FirPacketsSentPerMinute", | |
254 rtcp_counter.fir_packets * 60 / elapsed_sec); | |
255 RTC_HISTOGRAM_COUNTS_10000("WebRTC.Video.PliPacketsSentPerMinute", | |
256 rtcp_counter.pli_packets * 60 / elapsed_sec); | |
257 if (rtcp_counter.nack_requests > 0) { | |
258 RTC_HISTOGRAM_PERCENTAGE("WebRTC.Video.UniqueNackRequestsSentInPercent", | |
259 rtcp_counter.UniqueNackRequestsInPercent()); | |
260 } | |
261 } | |
262 } | 225 } |
263 } | 226 } |
264 | 227 |
265 int32_t ViEChannel::SetSendCodec(const VideoCodec& video_codec, | 228 int32_t ViEChannel::SetSendCodec(const VideoCodec& video_codec, |
266 bool new_stream) { | 229 bool new_stream) { |
267 RTC_DCHECK(sender_); | 230 RTC_DCHECK(sender_); |
268 if (video_codec.codecType == kVideoCodecRED || | 231 if (video_codec.codecType == kVideoCodecRED || |
269 video_codec.codecType == kVideoCodecULPFEC) { | 232 video_codec.codecType == kVideoCodecULPFEC) { |
270 LOG_F(LS_ERROR) << "Not a valid send codec " << video_codec.codecType; | 233 LOG_F(LS_ERROR) << "Not a valid send codec " << video_codec.codecType; |
271 return -1; | 234 return -1; |
(...skipping 234 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
506 *rtx_counters = StreamDataCounters(); | 469 *rtx_counters = StreamDataCounters(); |
507 for (RtpRtcp* rtp_rtcp : rtp_rtcp_modules_) { | 470 for (RtpRtcp* rtp_rtcp : rtp_rtcp_modules_) { |
508 StreamDataCounters rtp_data; | 471 StreamDataCounters rtp_data; |
509 StreamDataCounters rtx_data; | 472 StreamDataCounters rtx_data; |
510 rtp_rtcp->GetSendStreamDataCounters(&rtp_data, &rtx_data); | 473 rtp_rtcp->GetSendStreamDataCounters(&rtp_data, &rtx_data); |
511 rtp_counters->Add(rtp_data); | 474 rtp_counters->Add(rtp_data); |
512 rtx_counters->Add(rtx_data); | 475 rtx_counters->Add(rtx_data); |
513 } | 476 } |
514 } | 477 } |
515 | 478 |
516 void ViEChannel::GetSendRtcpPacketTypeCounter( | |
517 RtcpPacketTypeCounter* packet_counter) const { | |
518 std::map<uint32_t, RtcpPacketTypeCounter> counter_map = | |
519 rtcp_packet_type_counter_observer_.GetPacketTypeCounterMap(); | |
520 | |
521 RtcpPacketTypeCounter counter; | |
522 for (RtpRtcp* rtp_rtcp : rtp_rtcp_modules_) | |
523 counter.Add(counter_map[rtp_rtcp->SSRC()]); | |
524 *packet_counter = counter; | |
525 } | |
526 | |
527 void ViEChannel::GetReceiveRtcpPacketTypeCounter( | |
528 RtcpPacketTypeCounter* packet_counter) const { | |
529 std::map<uint32_t, RtcpPacketTypeCounter> counter_map = | |
530 rtcp_packet_type_counter_observer_.GetPacketTypeCounterMap(); | |
531 | |
532 RtcpPacketTypeCounter counter; | |
533 counter.Add(counter_map[vie_receiver_.GetRemoteSsrc()]); | |
534 | |
535 *packet_counter = counter; | |
536 } | |
537 | |
538 void ViEChannel::RegisterSendSideDelayObserver( | 479 void ViEChannel::RegisterSendSideDelayObserver( |
539 SendSideDelayObserver* observer) { | 480 SendSideDelayObserver* observer) { |
540 send_side_delay_observer_.Set(observer); | 481 send_side_delay_observer_.Set(observer); |
541 } | 482 } |
542 | 483 |
543 void ViEChannel::RegisterSendBitrateObserver( | 484 void ViEChannel::RegisterSendBitrateObserver( |
544 BitrateStatisticsObserver* observer) { | 485 BitrateStatisticsObserver* observer) { |
545 send_bitrate_observer_.Set(observer); | 486 send_bitrate_observer_.Set(observer); |
546 } | 487 } |
547 | 488 |
(...skipping 244 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
792 rtc::CritScope lock(&crit_); | 733 rtc::CritScope lock(&crit_); |
793 receive_stats_callback_ = receive_statistics_proxy; | 734 receive_stats_callback_ = receive_statistics_proxy; |
794 } | 735 } |
795 | 736 |
796 void ViEChannel::SetIncomingVideoStream( | 737 void ViEChannel::SetIncomingVideoStream( |
797 IncomingVideoStream* incoming_video_stream) { | 738 IncomingVideoStream* incoming_video_stream) { |
798 rtc::CritScope lock(&crit_); | 739 rtc::CritScope lock(&crit_); |
799 incoming_video_stream_ = incoming_video_stream; | 740 incoming_video_stream_ = incoming_video_stream; |
800 } | 741 } |
801 } // namespace webrtc | 742 } // namespace webrtc |
OLD | NEW |