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 253 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
264 } | 264 } |
265 } | 265 } |
266 | 266 |
267 StreamDataCounters rtp; | 267 StreamDataCounters rtp; |
268 StreamDataCounters rtx; | 268 StreamDataCounters rtx; |
269 GetReceiveStreamDataCounters(&rtp, &rtx); | 269 GetReceiveStreamDataCounters(&rtp, &rtx); |
270 StreamDataCounters rtp_rtx = rtp; | 270 StreamDataCounters rtp_rtx = rtp; |
271 rtp_rtx.Add(rtx); | 271 rtp_rtx.Add(rtx); |
272 elapsed_sec = rtp_rtx.TimeSinceFirstPacketInMs(now) / 1000; | 272 elapsed_sec = rtp_rtx.TimeSinceFirstPacketInMs(now) / 1000; |
273 if (elapsed_sec > metrics::kMinRunTimeInSeconds) { | 273 if (elapsed_sec > metrics::kMinRunTimeInSeconds) { |
274 RTC_HISTOGRAM_COUNTS_10000("WebRTC.Video.BitrateReceivedInKbps", | 274 RTC_HISTOGRAM_COUNTS_10000( |
275 rtp_rtx.transmitted.TotalBytes() * 8 / elapsed_sec / 1000); | 275 "WebRTC.Video.BitrateReceivedInKbps", |
276 RTC_HISTOGRAM_COUNTS_10000("WebRTC.Video.MediaBitrateReceivedInKbps", | 276 static_cast<int>(rtp_rtx.transmitted.TotalBytes() * 8 / elapsed_sec / |
277 rtp.MediaPayloadBytes() * 8 / elapsed_sec / 1000); | 277 1000)); |
278 RTC_HISTOGRAM_COUNTS_10000("WebRTC.Video.PaddingBitrateReceivedInKbps", | 278 RTC_HISTOGRAM_COUNTS_10000( |
279 rtp_rtx.transmitted.padding_bytes * 8 / elapsed_sec / 1000); | 279 "WebRTC.Video.MediaBitrateReceivedInKbps", |
| 280 static_cast<int>(rtp.MediaPayloadBytes() * 8 / elapsed_sec / 1000)); |
| 281 RTC_HISTOGRAM_COUNTS_10000( |
| 282 "WebRTC.Video.PaddingBitrateReceivedInKbps", |
| 283 static_cast<int>(rtp_rtx.transmitted.padding_bytes * 8 / elapsed_sec / |
| 284 1000)); |
280 RTC_HISTOGRAM_COUNTS_10000( | 285 RTC_HISTOGRAM_COUNTS_10000( |
281 "WebRTC.Video.RetransmittedBitrateReceivedInKbps", | 286 "WebRTC.Video.RetransmittedBitrateReceivedInKbps", |
282 rtp_rtx.retransmitted.TotalBytes() * 8 / elapsed_sec / 1000); | 287 static_cast<int>(rtp_rtx.retransmitted.TotalBytes() * 8 / |
| 288 elapsed_sec / 1000)); |
283 uint32_t ssrc = 0; | 289 uint32_t ssrc = 0; |
284 if (vie_receiver_.GetRtxSsrc(&ssrc)) { | 290 if (vie_receiver_.GetRtxSsrc(&ssrc)) { |
285 RTC_HISTOGRAM_COUNTS_10000("WebRTC.Video.RtxBitrateReceivedInKbps", | 291 RTC_HISTOGRAM_COUNTS_10000( |
286 rtx.transmitted.TotalBytes() * 8 / elapsed_sec / 1000); | 292 "WebRTC.Video.RtxBitrateReceivedInKbps", |
| 293 static_cast<int>(rtx.transmitted.TotalBytes() * 8 / elapsed_sec / |
| 294 1000)); |
287 } | 295 } |
288 if (vie_receiver_.IsFecEnabled()) { | 296 if (vie_receiver_.IsFecEnabled()) { |
289 RTC_HISTOGRAM_COUNTS_10000("WebRTC.Video.FecBitrateReceivedInKbps", | 297 RTC_HISTOGRAM_COUNTS_10000("WebRTC.Video.FecBitrateReceivedInKbps", |
290 rtp_rtx.fec.TotalBytes() * 8 / elapsed_sec / 1000); | 298 static_cast<int>(rtp_rtx.fec.TotalBytes() * |
| 299 8 / elapsed_sec / 1000)); |
291 } | 300 } |
292 } | 301 } |
293 } | 302 } |
294 } | 303 } |
295 | 304 |
296 void ViEChannel::UpdateHistogramsAtStopSend() { | 305 void ViEChannel::UpdateHistogramsAtStopSend() { |
297 StreamDataCounters rtp; | 306 StreamDataCounters rtp; |
298 StreamDataCounters rtx; | 307 StreamDataCounters rtx; |
299 GetSendStreamDataCounters(&rtp, &rtx); | 308 GetSendStreamDataCounters(&rtp, &rtx); |
300 StreamDataCounters rtp_rtx = rtp; | 309 StreamDataCounters rtp_rtx = rtp; |
301 rtp_rtx.Add(rtx); | 310 rtp_rtx.Add(rtx); |
302 | 311 |
303 int64_t elapsed_sec = rtp_rtx.TimeSinceFirstPacketInMs( | 312 int64_t elapsed_sec = rtp_rtx.TimeSinceFirstPacketInMs( |
304 Clock::GetRealTimeClock()->TimeInMilliseconds()) / 1000; | 313 Clock::GetRealTimeClock()->TimeInMilliseconds()) / 1000; |
305 if (elapsed_sec < metrics::kMinRunTimeInSeconds) { | 314 if (elapsed_sec < metrics::kMinRunTimeInSeconds) { |
306 return; | 315 return; |
307 } | 316 } |
308 RTC_HISTOGRAM_COUNTS_100000("WebRTC.Video.BitrateSentInKbps", | 317 RTC_HISTOGRAM_COUNTS_100000( |
309 rtp_rtx.transmitted.TotalBytes() * 8 / elapsed_sec / 1000); | 318 "WebRTC.Video.BitrateSentInKbps", |
310 RTC_HISTOGRAM_COUNTS_10000("WebRTC.Video.MediaBitrateSentInKbps", | 319 static_cast<int>(rtp_rtx.transmitted.TotalBytes() * 8 / elapsed_sec / |
311 rtp.MediaPayloadBytes() * 8 / elapsed_sec / 1000); | 320 1000)); |
312 RTC_HISTOGRAM_COUNTS_10000("WebRTC.Video.PaddingBitrateSentInKbps", | 321 RTC_HISTOGRAM_COUNTS_10000( |
313 rtp_rtx.transmitted.padding_bytes * 8 / elapsed_sec / 1000); | 322 "WebRTC.Video.MediaBitrateSentInKbps", |
314 RTC_HISTOGRAM_COUNTS_10000("WebRTC.Video.RetransmittedBitrateSentInKbps", | 323 static_cast<int>(rtp.MediaPayloadBytes() * 8 / elapsed_sec / 1000)); |
315 rtp_rtx.retransmitted.TotalBytes() * 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)); |
316 if (rtp_rtcp_->RtxSendStatus() != kRtxOff) { | 332 if (rtp_rtcp_->RtxSendStatus() != kRtxOff) { |
317 RTC_HISTOGRAM_COUNTS_10000("WebRTC.Video.RtxBitrateSentInKbps", | 333 RTC_HISTOGRAM_COUNTS_10000("WebRTC.Video.RtxBitrateSentInKbps", |
318 rtx.transmitted.TotalBytes() * 8 / elapsed_sec / 1000); | 334 static_cast<int>(rtx.transmitted.TotalBytes() * |
| 335 8 / elapsed_sec / 1000)); |
319 } | 336 } |
320 bool fec_enabled = false; | 337 bool fec_enabled = false; |
321 uint8_t pltype_red; | 338 uint8_t pltype_red; |
322 uint8_t pltype_fec; | 339 uint8_t pltype_fec; |
323 rtp_rtcp_->GenericFECStatus(fec_enabled, pltype_red, pltype_fec); | 340 rtp_rtcp_->GenericFECStatus(fec_enabled, pltype_red, pltype_fec); |
324 if (fec_enabled) { | 341 if (fec_enabled) { |
325 RTC_HISTOGRAM_COUNTS_10000("WebRTC.Video.FecBitrateSentInKbps", | 342 RTC_HISTOGRAM_COUNTS_10000( |
326 rtp_rtx.fec.TotalBytes() * 8 / elapsed_sec / 1000); | 343 "WebRTC.Video.FecBitrateSentInKbps", |
| 344 static_cast<int>(rtp_rtx.fec.TotalBytes() * 8 / elapsed_sec / 1000)); |
327 } | 345 } |
328 } | 346 } |
329 | 347 |
330 int32_t ViEChannel::SetSendCodec(const VideoCodec& video_codec, | 348 int32_t ViEChannel::SetSendCodec(const VideoCodec& video_codec, |
331 bool new_stream) { | 349 bool new_stream) { |
332 if (!sender_) { | 350 if (!sender_) { |
333 return 0; | 351 return 0; |
334 } | 352 } |
335 if (video_codec.codecType == kVideoCodecRED || | 353 if (video_codec.codecType == kVideoCodecRED || |
336 video_codec.codecType == kVideoCodecULPFEC) { | 354 video_codec.codecType == kVideoCodecULPFEC) { |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
368 rtp_rtcp_->GenericFECStatus(fec_enabled, payload_type_red, payload_type_fec); | 386 rtp_rtcp_->GenericFECStatus(fec_enabled, payload_type_red, payload_type_fec); |
369 | 387 |
370 std::vector<RtpRtcp*> registered_modules; | 388 std::vector<RtpRtcp*> registered_modules; |
371 std::vector<RtpRtcp*> deregistered_modules; | 389 std::vector<RtpRtcp*> deregistered_modules; |
372 { | 390 { |
373 CriticalSectionScoped cs(rtp_rtcp_cs_.get()); | 391 CriticalSectionScoped cs(rtp_rtcp_cs_.get()); |
374 | 392 |
375 if (video_codec.numberOfSimulcastStreams > 0) { | 393 if (video_codec.numberOfSimulcastStreams > 0) { |
376 // Set correct bitrate to base layer. | 394 // Set correct bitrate to base layer. |
377 // Create our simulcast RTP modules. | 395 // Create our simulcast RTP modules. |
378 int num_modules_to_add = | 396 int num_modules_to_add = video_codec.numberOfSimulcastStreams - |
379 video_codec.numberOfSimulcastStreams - simulcast_rtp_rtcp_.size() - 1; | 397 static_cast<int>(simulcast_rtp_rtcp_.size()) - 1; |
380 if (num_modules_to_add < 0) { | 398 if (num_modules_to_add < 0) { |
381 num_modules_to_add = 0; | 399 num_modules_to_add = 0; |
382 } | 400 } |
383 | 401 |
384 // Add back removed rtp modules. Order is important (allocate from front | 402 // Add back removed rtp modules. Order is important (allocate from front |
385 // of removed modules) to preserve RTP settings such as SSRCs for | 403 // of removed modules) to preserve RTP settings such as SSRCs for |
386 // simulcast streams. | 404 // simulcast streams. |
387 std::list<RtpRtcp*> new_rtp_modules; | 405 std::list<RtpRtcp*> new_rtp_modules; |
388 for (; removed_rtp_rtcp_.size() > 0 && num_modules_to_add > 0; | 406 for (; removed_rtp_rtcp_.size() > 0 && num_modules_to_add > 0; |
389 --num_modules_to_add) { | 407 --num_modules_to_add) { |
(...skipping 28 matching lines...) Expand all Loading... |
418 rtp_rtcp->SetRtxSendPayloadType(payload_type_value.first, | 436 rtp_rtcp->SetRtxSendPayloadType(payload_type_value.first, |
419 payload_type_value.second); | 437 payload_type_value.second); |
420 rtp_rtcp->SetRtxSendStatus(rtp_rtcp_->RtxSendStatus()); | 438 rtp_rtcp->SetRtxSendStatus(rtp_rtcp_->RtxSendStatus()); |
421 simulcast_rtp_rtcp_.push_back(rtp_rtcp); | 439 simulcast_rtp_rtcp_.push_back(rtp_rtcp); |
422 | 440 |
423 // Silently ignore error. | 441 // Silently ignore error. |
424 registered_modules.push_back(rtp_rtcp); | 442 registered_modules.push_back(rtp_rtcp); |
425 } | 443 } |
426 | 444 |
427 // Remove last in list if we have too many. | 445 // Remove last in list if we have too many. |
428 for (int j = simulcast_rtp_rtcp_.size(); | 446 for (size_t j = simulcast_rtp_rtcp_.size(); |
429 j > (video_codec.numberOfSimulcastStreams - 1); j--) { | 447 j > static_cast<size_t>(video_codec.numberOfSimulcastStreams - 1); |
| 448 j--) { |
430 RtpRtcp* rtp_rtcp = simulcast_rtp_rtcp_.back(); | 449 RtpRtcp* rtp_rtcp = simulcast_rtp_rtcp_.back(); |
431 deregistered_modules.push_back(rtp_rtcp); | 450 deregistered_modules.push_back(rtp_rtcp); |
432 rtp_rtcp->SetSendingStatus(false); | 451 rtp_rtcp->SetSendingStatus(false); |
433 rtp_rtcp->SetSendingMediaStatus(false); | 452 rtp_rtcp->SetSendingMediaStatus(false); |
434 rtp_rtcp->RegisterRtcpStatisticsCallback(NULL); | 453 rtp_rtcp->RegisterRtcpStatisticsCallback(NULL); |
435 rtp_rtcp->RegisterSendChannelRtpStatisticsCallback(NULL); | 454 rtp_rtcp->RegisterSendChannelRtpStatisticsCallback(NULL); |
436 simulcast_rtp_rtcp_.pop_back(); | 455 simulcast_rtp_rtcp_.pop_back(); |
437 removed_rtp_rtcp_.push_front(rtp_rtcp); | 456 removed_rtp_rtcp_.push_front(rtp_rtcp); |
438 } | 457 } |
439 uint8_t idx = 0; | 458 uint8_t idx = 0; |
(...skipping 1264 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1704 CriticalSectionScoped cs(callback_cs_.get()); | 1723 CriticalSectionScoped cs(callback_cs_.get()); |
1705 vcm_receive_stats_callback_ = receive_statistics_proxy; | 1724 vcm_receive_stats_callback_ = receive_statistics_proxy; |
1706 } | 1725 } |
1707 | 1726 |
1708 void ViEChannel::SetIncomingVideoStream( | 1727 void ViEChannel::SetIncomingVideoStream( |
1709 IncomingVideoStream* incoming_video_stream) { | 1728 IncomingVideoStream* incoming_video_stream) { |
1710 CriticalSectionScoped cs(callback_cs_.get()); | 1729 CriticalSectionScoped cs(callback_cs_.get()); |
1711 incoming_video_stream_ = incoming_video_stream; | 1730 incoming_video_stream_ = incoming_video_stream; |
1712 } | 1731 } |
1713 } // namespace webrtc | 1732 } // namespace webrtc |
OLD | NEW |