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 211 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
222 | 222 |
223 void ViEChannel::UpdateHistograms() { | 223 void ViEChannel::UpdateHistograms() { |
224 int64_t now = Clock::GetRealTimeClock()->TimeInMilliseconds(); | 224 int64_t now = Clock::GetRealTimeClock()->TimeInMilliseconds(); |
225 | 225 |
226 if (sender_) { | 226 if (sender_) { |
227 RtcpPacketTypeCounter rtcp_counter; | 227 RtcpPacketTypeCounter rtcp_counter; |
228 GetSendRtcpPacketTypeCounter(&rtcp_counter); | 228 GetSendRtcpPacketTypeCounter(&rtcp_counter); |
229 int64_t elapsed_sec = rtcp_counter.TimeSinceFirstPacketInMs(now) / 1000; | 229 int64_t elapsed_sec = rtcp_counter.TimeSinceFirstPacketInMs(now) / 1000; |
230 if (elapsed_sec > metrics::kMinRunTimeInSeconds) { | 230 if (elapsed_sec > metrics::kMinRunTimeInSeconds) { |
231 RTC_HISTOGRAM_COUNTS_10000("WebRTC.Video.NackPacketsReceivedPerMinute", | 231 RTC_HISTOGRAM_COUNTS_10000("WebRTC.Video.NackPacketsReceivedPerMinute", |
232 rtcp_counter.nack_packets * 60 / elapsed_sec); | 232 rtcp_counter.nack_packets * 60 / elapsed_sec); |
233 RTC_HISTOGRAM_COUNTS_10000("WebRTC.Video.FirPacketsReceivedPerMinute", | 233 RTC_HISTOGRAM_COUNTS_10000("WebRTC.Video.FirPacketsReceivedPerMinute", |
234 rtcp_counter.fir_packets * 60 / elapsed_sec); | 234 rtcp_counter.fir_packets * 60 / elapsed_sec); |
235 RTC_HISTOGRAM_COUNTS_10000("WebRTC.Video.PliPacketsReceivedPerMinute", | 235 RTC_HISTOGRAM_COUNTS_10000("WebRTC.Video.PliPacketsReceivedPerMinute", |
236 rtcp_counter.pli_packets * 60 / elapsed_sec); | 236 rtcp_counter.pli_packets * 60 / elapsed_sec); |
237 if (rtcp_counter.nack_requests > 0) { | 237 if (rtcp_counter.nack_requests > 0) { |
238 RTC_HISTOGRAM_PERCENTAGE( | 238 RTC_HISTOGRAM_PERCENTAGE( |
239 "WebRTC.Video.UniqueNackRequestsReceivedInPercent", | 239 "WebRTC.Video.UniqueNackRequestsReceivedInPercent", |
240 rtcp_counter.UniqueNackRequestsInPercent()); | 240 rtcp_counter.UniqueNackRequestsInPercent()); |
241 } | 241 } |
242 int fraction_lost = report_block_stats_sender_->FractionLostInPercent(); | 242 int fraction_lost = report_block_stats_sender_->FractionLostInPercent(); |
243 if (fraction_lost != -1) { | 243 if (fraction_lost != -1) { |
244 RTC_HISTOGRAM_PERCENTAGE("WebRTC.Video.SentPacketsLostInPercent", | 244 RTC_HISTOGRAM_PERCENTAGE("WebRTC.Video.SentPacketsLostInPercent", |
245 fraction_lost); | 245 fraction_lost); |
| 246 } |
| 247 } |
| 248 |
| 249 StreamDataCounters rtp; |
| 250 StreamDataCounters rtx; |
| 251 GetSendStreamDataCounters(&rtp, &rtx); |
| 252 StreamDataCounters rtp_rtx = rtp; |
| 253 rtp_rtx.Add(rtx); |
| 254 elapsed_sec = rtp_rtx.TimeSinceFirstPacketInMs( |
| 255 Clock::GetRealTimeClock()->TimeInMilliseconds()) / |
| 256 1000; |
| 257 if (elapsed_sec > metrics::kMinRunTimeInSeconds) { |
| 258 RTC_HISTOGRAM_COUNTS_100000( |
| 259 "WebRTC.Video.BitrateSentInKbps", |
| 260 static_cast<int>(rtp_rtx.transmitted.TotalBytes() * 8 / elapsed_sec / |
| 261 1000)); |
| 262 RTC_HISTOGRAM_COUNTS_10000( |
| 263 "WebRTC.Video.MediaBitrateSentInKbps", |
| 264 static_cast<int>(rtp.MediaPayloadBytes() * 8 / elapsed_sec / 1000)); |
| 265 RTC_HISTOGRAM_COUNTS_10000( |
| 266 "WebRTC.Video.PaddingBitrateSentInKbps", |
| 267 static_cast<int>(rtp_rtx.transmitted.padding_bytes * 8 / elapsed_sec / |
| 268 1000)); |
| 269 RTC_HISTOGRAM_COUNTS_10000( |
| 270 "WebRTC.Video.RetransmittedBitrateSentInKbps", |
| 271 static_cast<int>(rtp_rtx.retransmitted.TotalBytes() * 8 / |
| 272 elapsed_sec / 1000)); |
| 273 if (rtp_rtcp_->RtxSendStatus() != kRtxOff) { |
| 274 RTC_HISTOGRAM_COUNTS_10000( |
| 275 "WebRTC.Video.RtxBitrateSentInKbps", |
| 276 static_cast<int>(rtx.transmitted.TotalBytes() * 8 / elapsed_sec / |
| 277 1000)); |
| 278 } |
| 279 bool fec_enabled = false; |
| 280 uint8_t pltype_red; |
| 281 uint8_t pltype_fec; |
| 282 rtp_rtcp_->GenericFECStatus(fec_enabled, pltype_red, pltype_fec); |
| 283 if (fec_enabled) { |
| 284 RTC_HISTOGRAM_COUNTS_10000("WebRTC.Video.FecBitrateSentInKbps", |
| 285 static_cast<int>(rtp_rtx.fec.TotalBytes() * |
| 286 8 / elapsed_sec / 1000)); |
246 } | 287 } |
247 } | 288 } |
248 } else if (vie_receiver_.GetRemoteSsrc() > 0) { | 289 } else if (vie_receiver_.GetRemoteSsrc() > 0) { |
249 // Get receive stats if we are receiving packets, i.e. there is a remote | 290 // Get receive stats if we are receiving packets, i.e. there is a remote |
250 // ssrc. | 291 // ssrc. |
251 RtcpPacketTypeCounter rtcp_counter; | 292 RtcpPacketTypeCounter rtcp_counter; |
252 GetReceiveRtcpPacketTypeCounter(&rtcp_counter); | 293 GetReceiveRtcpPacketTypeCounter(&rtcp_counter); |
253 int64_t elapsed_sec = rtcp_counter.TimeSinceFirstPacketInMs(now) / 1000; | 294 int64_t elapsed_sec = rtcp_counter.TimeSinceFirstPacketInMs(now) / 1000; |
254 if (elapsed_sec > metrics::kMinRunTimeInSeconds) { | 295 if (elapsed_sec > metrics::kMinRunTimeInSeconds) { |
255 RTC_HISTOGRAM_COUNTS_10000("WebRTC.Video.NackPacketsSentPerMinute", | 296 RTC_HISTOGRAM_COUNTS_10000("WebRTC.Video.NackPacketsSentPerMinute", |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
295 } | 336 } |
296 if (vie_receiver_.IsFecEnabled()) { | 337 if (vie_receiver_.IsFecEnabled()) { |
297 RTC_HISTOGRAM_COUNTS_10000("WebRTC.Video.FecBitrateReceivedInKbps", | 338 RTC_HISTOGRAM_COUNTS_10000("WebRTC.Video.FecBitrateReceivedInKbps", |
298 static_cast<int>(rtp_rtx.fec.TotalBytes() * | 339 static_cast<int>(rtp_rtx.fec.TotalBytes() * |
299 8 / elapsed_sec / 1000)); | 340 8 / elapsed_sec / 1000)); |
300 } | 341 } |
301 } | 342 } |
302 } | 343 } |
303 } | 344 } |
304 | 345 |
305 void ViEChannel::UpdateHistogramsAtStopSend() { | |
306 StreamDataCounters rtp; | |
307 StreamDataCounters rtx; | |
308 GetSendStreamDataCounters(&rtp, &rtx); | |
309 StreamDataCounters rtp_rtx = rtp; | |
310 rtp_rtx.Add(rtx); | |
311 | |
312 int64_t elapsed_sec = rtp_rtx.TimeSinceFirstPacketInMs( | |
313 Clock::GetRealTimeClock()->TimeInMilliseconds()) / 1000; | |
314 if (elapsed_sec < metrics::kMinRunTimeInSeconds) { | |
315 return; | |
316 } | |
317 RTC_HISTOGRAM_COUNTS_100000( | |
318 "WebRTC.Video.BitrateSentInKbps", | |
319 static_cast<int>(rtp_rtx.transmitted.TotalBytes() * 8 / elapsed_sec / | |
320 1000)); | |
321 RTC_HISTOGRAM_COUNTS_10000( | |
322 "WebRTC.Video.MediaBitrateSentInKbps", | |
323 static_cast<int>(rtp.MediaPayloadBytes() * 8 / elapsed_sec / 1000)); | |
324 RTC_HISTOGRAM_COUNTS_10000( | |
325 "WebRTC.Video.PaddingBitrateSentInKbps", | |
326 static_cast<int>(rtp_rtx.transmitted.padding_bytes * 8 / elapsed_sec / | |
327 1000)); | |
328 RTC_HISTOGRAM_COUNTS_10000( | |
329 "WebRTC.Video.RetransmittedBitrateSentInKbps", | |
330 static_cast<int>(rtp_rtx.retransmitted.TotalBytes() * 8 / elapsed_sec / | |
331 1000)); | |
332 if (rtp_rtcp_->RtxSendStatus() != kRtxOff) { | |
333 RTC_HISTOGRAM_COUNTS_10000("WebRTC.Video.RtxBitrateSentInKbps", | |
334 static_cast<int>(rtx.transmitted.TotalBytes() * | |
335 8 / elapsed_sec / 1000)); | |
336 } | |
337 bool fec_enabled = false; | |
338 uint8_t pltype_red; | |
339 uint8_t pltype_fec; | |
340 rtp_rtcp_->GenericFECStatus(fec_enabled, pltype_red, pltype_fec); | |
341 if (fec_enabled) { | |
342 RTC_HISTOGRAM_COUNTS_10000( | |
343 "WebRTC.Video.FecBitrateSentInKbps", | |
344 static_cast<int>(rtp_rtx.fec.TotalBytes() * 8 / elapsed_sec / 1000)); | |
345 } | |
346 } | |
347 | |
348 int32_t ViEChannel::SetSendCodec(const VideoCodec& video_codec, | 346 int32_t ViEChannel::SetSendCodec(const VideoCodec& video_codec, |
349 bool new_stream) { | 347 bool new_stream) { |
350 DCHECK(sender_); | 348 DCHECK(sender_); |
351 if (video_codec.codecType == kVideoCodecRED || | 349 if (video_codec.codecType == kVideoCodecRED || |
352 video_codec.codecType == kVideoCodecULPFEC) { | 350 video_codec.codecType == kVideoCodecULPFEC) { |
353 LOG_F(LS_ERROR) << "Not a valid send codec " << video_codec.codecType; | 351 LOG_F(LS_ERROR) << "Not a valid send codec " << video_codec.codecType; |
354 return -1; | 352 return -1; |
355 } | 353 } |
356 if (kMaxSimulcastStreams < video_codec.numberOfSimulcastStreams) { | 354 if (kMaxSimulcastStreams < video_codec.numberOfSimulcastStreams) { |
357 LOG_F(LS_ERROR) << "Incorrect config " | 355 LOG_F(LS_ERROR) << "Incorrect config " |
(...skipping 971 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1329 it++) { | 1327 it++) { |
1330 RtpRtcp* rtp_rtcp = *it; | 1328 RtpRtcp* rtp_rtcp = *it; |
1331 rtp_rtcp->SetSendingMediaStatus(true); | 1329 rtp_rtcp->SetSendingMediaStatus(true); |
1332 rtp_rtcp->SetSendingStatus(true); | 1330 rtp_rtcp->SetSendingStatus(true); |
1333 } | 1331 } |
1334 send_payload_router_->set_active(true); | 1332 send_payload_router_->set_active(true); |
1335 return 0; | 1333 return 0; |
1336 } | 1334 } |
1337 | 1335 |
1338 int32_t ViEChannel::StopSend() { | 1336 int32_t ViEChannel::StopSend() { |
1339 UpdateHistogramsAtStopSend(); | |
1340 send_payload_router_->set_active(false); | 1337 send_payload_router_->set_active(false); |
1341 CriticalSectionScoped cs(rtp_rtcp_cs_.get()); | 1338 CriticalSectionScoped cs(rtp_rtcp_cs_.get()); |
1342 rtp_rtcp_->SetSendingMediaStatus(false); | 1339 rtp_rtcp_->SetSendingMediaStatus(false); |
1343 for (std::list<RtpRtcp*>::iterator it = simulcast_rtp_rtcp_.begin(); | 1340 for (std::list<RtpRtcp*>::iterator it = simulcast_rtp_rtcp_.begin(); |
1344 it != simulcast_rtp_rtcp_.end(); | 1341 it != simulcast_rtp_rtcp_.end(); |
1345 it++) { | 1342 it++) { |
1346 RtpRtcp* rtp_rtcp = *it; | 1343 RtpRtcp* rtp_rtcp = *it; |
1347 rtp_rtcp->SetSendingMediaStatus(false); | 1344 rtp_rtcp->SetSendingMediaStatus(false); |
1348 } | 1345 } |
1349 if (!rtp_rtcp_->Sending()) { | 1346 if (!rtp_rtcp_->Sending()) { |
1350 return -1; | 1347 return -1; |
1351 } | 1348 } |
1352 | 1349 |
1353 // Reset. | |
1354 rtp_rtcp_->ResetSendDataCountersRTP(); | |
1355 if (rtp_rtcp_->SetSendingStatus(false) != 0) { | 1350 if (rtp_rtcp_->SetSendingStatus(false) != 0) { |
1356 return -1; | 1351 return -1; |
1357 } | 1352 } |
1358 for (std::list<RtpRtcp*>::iterator it = simulcast_rtp_rtcp_.begin(); | 1353 for (std::list<RtpRtcp*>::iterator it = simulcast_rtp_rtcp_.begin(); |
1359 it != simulcast_rtp_rtcp_.end(); | 1354 it != simulcast_rtp_rtcp_.end(); |
1360 it++) { | 1355 it++) { |
1361 RtpRtcp* rtp_rtcp = *it; | 1356 RtpRtcp* rtp_rtcp = *it; |
1362 rtp_rtcp->ResetSendDataCountersRTP(); | |
1363 rtp_rtcp->SetSendingStatus(false); | 1357 rtp_rtcp->SetSendingStatus(false); |
1364 } | 1358 } |
1365 return 0; | 1359 return 0; |
1366 } | 1360 } |
1367 | 1361 |
1368 bool ViEChannel::Sending() { | 1362 bool ViEChannel::Sending() { |
1369 return rtp_rtcp_->Sending(); | 1363 return rtp_rtcp_->Sending(); |
1370 } | 1364 } |
1371 | 1365 |
1372 void ViEChannel::StartReceive() { | 1366 void ViEChannel::StartReceive() { |
(...skipping 318 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1691 | 1685 |
1692 } | 1686 } |
1693 | 1687 |
1694 void ViEChannel::OnIncomingCSRCChanged(const int32_t id, | 1688 void ViEChannel::OnIncomingCSRCChanged(const int32_t id, |
1695 const uint32_t CSRC, | 1689 const uint32_t CSRC, |
1696 const bool added) { | 1690 const bool added) { |
1697 assert(channel_id_ == ChannelId(id)); | 1691 assert(channel_id_ == ChannelId(id)); |
1698 CriticalSectionScoped cs(callback_cs_.get()); | 1692 CriticalSectionScoped cs(callback_cs_.get()); |
1699 } | 1693 } |
1700 | 1694 |
1701 void ViEChannel::ResetStatistics(uint32_t ssrc) { | |
1702 StreamStatistician* statistician = | |
1703 vie_receiver_.GetReceiveStatistics()->GetStatistician(ssrc); | |
1704 if (statistician) | |
1705 statistician->ResetStatistics(); | |
1706 } | |
1707 | |
1708 void ViEChannel::RegisterSendFrameCountObserver( | 1695 void ViEChannel::RegisterSendFrameCountObserver( |
1709 FrameCountObserver* observer) { | 1696 FrameCountObserver* observer) { |
1710 send_frame_count_observer_.Set(observer); | 1697 send_frame_count_observer_.Set(observer); |
1711 } | 1698 } |
1712 | 1699 |
1713 void ViEChannel::RegisterReceiveStatisticsProxy( | 1700 void ViEChannel::RegisterReceiveStatisticsProxy( |
1714 ReceiveStatisticsProxy* receive_statistics_proxy) { | 1701 ReceiveStatisticsProxy* receive_statistics_proxy) { |
1715 CriticalSectionScoped cs(callback_cs_.get()); | 1702 CriticalSectionScoped cs(callback_cs_.get()); |
1716 vcm_receive_stats_callback_ = receive_statistics_proxy; | 1703 vcm_receive_stats_callback_ = receive_statistics_proxy; |
1717 } | 1704 } |
1718 | 1705 |
1719 void ViEChannel::SetIncomingVideoStream( | 1706 void ViEChannel::SetIncomingVideoStream( |
1720 IncomingVideoStream* incoming_video_stream) { | 1707 IncomingVideoStream* incoming_video_stream) { |
1721 CriticalSectionScoped cs(callback_cs_.get()); | 1708 CriticalSectionScoped cs(callback_cs_.get()); |
1722 incoming_video_stream_ = incoming_video_stream; | 1709 incoming_video_stream_ = incoming_video_stream; |
1723 } | 1710 } |
1724 } // namespace webrtc | 1711 } // namespace webrtc |
OLD | NEW |