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 |
11 #include "webrtc/video/rtp_stream_receiver.h" | 11 #include "webrtc/video/rtp_stream_receiver.h" |
12 | 12 |
13 #include <vector> | 13 #include <vector> |
14 | 14 |
15 #include "webrtc/base/checks.h" | 15 #include "webrtc/base/checks.h" |
16 #include "webrtc/base/logging.h" | 16 #include "webrtc/base/logging.h" |
17 #include "webrtc/common_types.h" | 17 #include "webrtc/common_types.h" |
18 #include "webrtc/config.h" | 18 #include "webrtc/config.h" |
19 #include "webrtc/modules/pacing/packet_router.h" | 19 #include "webrtc/modules/pacing/packet_router.h" |
20 #include "webrtc/modules/remote_bitrate_estimator/include/remote_bitrate_estimat
or.h" | 20 #include "webrtc/modules/remote_bitrate_estimator/include/remote_bitrate_estimat
or.h" |
21 #include "webrtc/modules/rtp_rtcp/include/fec_receiver.h" | |
22 #include "webrtc/modules/rtp_rtcp/include/receive_statistics.h" | 21 #include "webrtc/modules/rtp_rtcp/include/receive_statistics.h" |
23 #include "webrtc/modules/rtp_rtcp/include/rtp_cvo.h" | 22 #include "webrtc/modules/rtp_rtcp/include/rtp_cvo.h" |
24 #include "webrtc/modules/rtp_rtcp/include/rtp_header_parser.h" | 23 #include "webrtc/modules/rtp_rtcp/include/rtp_header_parser.h" |
25 #include "webrtc/modules/rtp_rtcp/include/rtp_receiver.h" | 24 #include "webrtc/modules/rtp_rtcp/include/rtp_receiver.h" |
26 #include "webrtc/modules/rtp_rtcp/include/rtp_rtcp.h" | 25 #include "webrtc/modules/rtp_rtcp/include/rtp_rtcp.h" |
| 26 #include "webrtc/modules/rtp_rtcp/include/ulpfec_receiver.h" |
27 #include "webrtc/modules/video_coding/video_coding_impl.h" | 27 #include "webrtc/modules/video_coding/video_coding_impl.h" |
28 #include "webrtc/system_wrappers/include/metrics.h" | 28 #include "webrtc/system_wrappers/include/metrics.h" |
29 #include "webrtc/system_wrappers/include/timestamp_extrapolator.h" | 29 #include "webrtc/system_wrappers/include/timestamp_extrapolator.h" |
30 #include "webrtc/system_wrappers/include/trace.h" | 30 #include "webrtc/system_wrappers/include/trace.h" |
31 #include "webrtc/video/receive_statistics_proxy.h" | 31 #include "webrtc/video/receive_statistics_proxy.h" |
32 #include "webrtc/video/vie_remb.h" | 32 #include "webrtc/video/vie_remb.h" |
33 | 33 |
34 namespace webrtc { | 34 namespace webrtc { |
35 | 35 |
36 std::unique_ptr<RtpRtcp> CreateRtpRtcpModule( | 36 std::unique_ptr<RtpRtcp> CreateRtpRtcpModule( |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
92 remb_(remb), | 92 remb_(remb), |
93 process_thread_(process_thread), | 93 process_thread_(process_thread), |
94 ntp_estimator_(clock_), | 94 ntp_estimator_(clock_), |
95 rtp_payload_registry_(RTPPayloadStrategy::CreateStrategy(false)), | 95 rtp_payload_registry_(RTPPayloadStrategy::CreateStrategy(false)), |
96 rtp_header_parser_(RtpHeaderParser::Create()), | 96 rtp_header_parser_(RtpHeaderParser::Create()), |
97 rtp_receiver_(RtpReceiver::CreateVideoReceiver(clock_, | 97 rtp_receiver_(RtpReceiver::CreateVideoReceiver(clock_, |
98 this, | 98 this, |
99 this, | 99 this, |
100 &rtp_payload_registry_)), | 100 &rtp_payload_registry_)), |
101 rtp_receive_statistics_(ReceiveStatistics::Create(clock_)), | 101 rtp_receive_statistics_(ReceiveStatistics::Create(clock_)), |
102 fec_receiver_(FecReceiver::Create(this)), | 102 ulpfec_receiver_(UlpfecReceiver::Create(this)), |
103 receiving_(false), | 103 receiving_(false), |
104 restored_packet_in_use_(false), | 104 restored_packet_in_use_(false), |
105 last_packet_log_ms_(-1), | 105 last_packet_log_ms_(-1), |
106 rtp_rtcp_(CreateRtpRtcpModule(rtp_receive_statistics_.get(), | 106 rtp_rtcp_(CreateRtpRtcpModule(rtp_receive_statistics_.get(), |
107 transport, | 107 transport, |
108 rtt_stats, | 108 rtt_stats, |
109 receive_stats_proxy, | 109 receive_stats_proxy, |
110 remote_bitrate_estimator_, | 110 remote_bitrate_estimator_, |
111 paced_sender, | 111 paced_sender, |
112 packet_router, | 112 packet_router, |
(...skipping 264 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
377 bool RtpStreamReceiver::ParseAndHandleEncapsulatingHeader( | 377 bool RtpStreamReceiver::ParseAndHandleEncapsulatingHeader( |
378 const uint8_t* packet, size_t packet_length, const RTPHeader& header) { | 378 const uint8_t* packet, size_t packet_length, const RTPHeader& header) { |
379 if (rtp_payload_registry_.IsRed(header)) { | 379 if (rtp_payload_registry_.IsRed(header)) { |
380 int8_t ulpfec_pt = rtp_payload_registry_.ulpfec_payload_type(); | 380 int8_t ulpfec_pt = rtp_payload_registry_.ulpfec_payload_type(); |
381 if (packet[header.headerLength] == ulpfec_pt) { | 381 if (packet[header.headerLength] == ulpfec_pt) { |
382 rtp_receive_statistics_->FecPacketReceived(header, packet_length); | 382 rtp_receive_statistics_->FecPacketReceived(header, packet_length); |
383 // Notify video_receiver about received FEC packets to avoid NACKing these | 383 // Notify video_receiver about received FEC packets to avoid NACKing these |
384 // packets. | 384 // packets. |
385 NotifyReceiverOfFecPacket(header); | 385 NotifyReceiverOfFecPacket(header); |
386 } | 386 } |
387 if (fec_receiver_->AddReceivedRedPacket( | 387 if (ulpfec_receiver_->AddReceivedRedPacket(header, packet, packet_length, |
388 header, packet, packet_length, ulpfec_pt) != 0) { | 388 ulpfec_pt) != 0) { |
389 return false; | 389 return false; |
390 } | 390 } |
391 return fec_receiver_->ProcessReceivedFec() == 0; | 391 return ulpfec_receiver_->ProcessReceivedFec() == 0; |
392 } else if (rtp_payload_registry_.IsRtx(header)) { | 392 } else if (rtp_payload_registry_.IsRtx(header)) { |
393 if (header.headerLength + header.paddingLength == packet_length) { | 393 if (header.headerLength + header.paddingLength == packet_length) { |
394 // This is an empty packet and should be silently dropped before trying to | 394 // This is an empty packet and should be silently dropped before trying to |
395 // parse the RTX header. | 395 // parse the RTX header. |
396 return true; | 396 return true; |
397 } | 397 } |
398 // Remove the RTX header and parse the original RTP header. | 398 // Remove the RTX header and parse the original RTP header. |
399 if (packet_length < header.headerLength) | 399 if (packet_length < header.headerLength) |
400 return false; | 400 return false; |
401 if (packet_length > sizeof(restored_packet_)) | 401 if (packet_length > sizeof(restored_packet_)) |
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
512 if (!statistician) | 512 if (!statistician) |
513 return false; | 513 return false; |
514 // Check if this is a retransmission. | 514 // Check if this is a retransmission. |
515 int64_t min_rtt = 0; | 515 int64_t min_rtt = 0; |
516 rtp_rtcp_->RTT(rtp_receiver_->SSRC(), nullptr, nullptr, &min_rtt, nullptr); | 516 rtp_rtcp_->RTT(rtp_receiver_->SSRC(), nullptr, nullptr, &min_rtt, nullptr); |
517 return !in_order && | 517 return !in_order && |
518 statistician->IsRetransmitOfOldPacket(header, min_rtt); | 518 statistician->IsRetransmitOfOldPacket(header, min_rtt); |
519 } | 519 } |
520 | 520 |
521 void RtpStreamReceiver::UpdateHistograms() { | 521 void RtpStreamReceiver::UpdateHistograms() { |
522 FecPacketCounter counter = fec_receiver_->GetPacketCounter(); | 522 FecPacketCounter counter = ulpfec_receiver_->GetPacketCounter(); |
523 if (counter.num_packets > 0) { | 523 if (counter.num_packets > 0) { |
524 RTC_HISTOGRAM_PERCENTAGE( | 524 RTC_HISTOGRAM_PERCENTAGE( |
525 "WebRTC.Video.ReceivedFecPacketsInPercent", | 525 "WebRTC.Video.ReceivedFecPacketsInPercent", |
526 static_cast<int>(counter.num_fec_packets * 100 / counter.num_packets)); | 526 static_cast<int>(counter.num_fec_packets * 100 / counter.num_packets)); |
527 } | 527 } |
528 if (counter.num_fec_packets > 0) { | 528 if (counter.num_fec_packets > 0) { |
529 RTC_HISTOGRAM_PERCENTAGE("WebRTC.Video.RecoveredMediaPacketsInPercentOfFec", | 529 RTC_HISTOGRAM_PERCENTAGE("WebRTC.Video.RecoveredMediaPacketsInPercentOfFec", |
530 static_cast<int>(counter.num_recovered_packets * | 530 static_cast<int>(counter.num_recovered_packets * |
531 100 / counter.num_fec_packets)); | 531 100 / counter.num_fec_packets)); |
532 } | 532 } |
533 } | 533 } |
534 | 534 |
535 void RtpStreamReceiver::EnableReceiveRtpHeaderExtension( | 535 void RtpStreamReceiver::EnableReceiveRtpHeaderExtension( |
536 const std::string& extension, int id) { | 536 const std::string& extension, int id) { |
537 // One-byte-extension local identifiers are in the range 1-14 inclusive. | 537 // One-byte-extension local identifiers are in the range 1-14 inclusive. |
538 RTC_DCHECK_GE(id, 1); | 538 RTC_DCHECK_GE(id, 1); |
539 RTC_DCHECK_LE(id, 14); | 539 RTC_DCHECK_LE(id, 14); |
540 RTC_DCHECK(RtpExtension::IsSupportedForVideo(extension)); | 540 RTC_DCHECK(RtpExtension::IsSupportedForVideo(extension)); |
541 RTC_CHECK(rtp_header_parser_->RegisterRtpHeaderExtension( | 541 RTC_CHECK(rtp_header_parser_->RegisterRtpHeaderExtension( |
542 StringToRtpExtensionType(extension), id)); | 542 StringToRtpExtensionType(extension), id)); |
543 } | 543 } |
544 | 544 |
545 } // namespace webrtc | 545 } // namespace webrtc |
OLD | NEW |