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/vie_receiver.h" | 11 #include "webrtc/video/vie_receiver.h" |
12 | 12 |
13 #include <vector> | 13 #include <vector> |
14 | 14 |
15 #include "webrtc/base/logging.h" | 15 #include "webrtc/base/logging.h" |
16 #include "webrtc/config.h" | 16 #include "webrtc/config.h" |
17 #include "webrtc/modules/remote_bitrate_estimator/include/remote_bitrate_estimat
or.h" | 17 #include "webrtc/modules/remote_bitrate_estimator/include/remote_bitrate_estimat
or.h" |
18 #include "webrtc/modules/rtp_rtcp/include/fec_receiver.h" | 18 #include "webrtc/modules/rtp_rtcp/include/fec_receiver.h" |
19 #include "webrtc/modules/rtp_rtcp/include/receive_statistics.h" | 19 #include "webrtc/modules/rtp_rtcp/include/receive_statistics.h" |
20 #include "webrtc/modules/rtp_rtcp/include/rtp_cvo.h" | 20 #include "webrtc/modules/rtp_rtcp/include/rtp_cvo.h" |
21 #include "webrtc/modules/rtp_rtcp/include/rtp_header_parser.h" | 21 #include "webrtc/modules/rtp_rtcp/include/rtp_header_parser.h" |
22 #include "webrtc/modules/rtp_rtcp/include/rtp_receiver.h" | 22 #include "webrtc/modules/rtp_rtcp/include/rtp_receiver.h" |
23 #include "webrtc/modules/rtp_rtcp/include/rtp_rtcp.h" | 23 #include "webrtc/modules/rtp_rtcp/include/rtp_rtcp.h" |
24 #include "webrtc/modules/video_coding/include/video_coding.h" | 24 #include "webrtc/modules/video_coding/video_coding_impl.h" |
25 #include "webrtc/system_wrappers/include/metrics.h" | 25 #include "webrtc/system_wrappers/include/metrics.h" |
26 #include "webrtc/system_wrappers/include/tick_util.h" | 26 #include "webrtc/system_wrappers/include/tick_util.h" |
27 #include "webrtc/system_wrappers/include/timestamp_extrapolator.h" | 27 #include "webrtc/system_wrappers/include/timestamp_extrapolator.h" |
28 #include "webrtc/system_wrappers/include/trace.h" | 28 #include "webrtc/system_wrappers/include/trace.h" |
29 | 29 |
30 namespace webrtc { | 30 namespace webrtc { |
31 | 31 |
32 static const int kPacketLogIntervalMs = 10000; | 32 static const int kPacketLogIntervalMs = 10000; |
33 | 33 |
34 ViEReceiver::ViEReceiver(VideoCodingModule* module_vcm, | 34 ViEReceiver::ViEReceiver(vcm::VideoReceiver* video_receiver, |
35 RemoteBitrateEstimator* remote_bitrate_estimator, | 35 RemoteBitrateEstimator* remote_bitrate_estimator, |
36 RtpFeedback* rtp_feedback) | 36 RtpFeedback* rtp_feedback) |
37 : clock_(Clock::GetRealTimeClock()), | 37 : clock_(Clock::GetRealTimeClock()), |
38 vcm_(module_vcm), | 38 video_receiver_(video_receiver), |
39 remote_bitrate_estimator_(remote_bitrate_estimator), | 39 remote_bitrate_estimator_(remote_bitrate_estimator), |
40 ntp_estimator_(clock_), | 40 ntp_estimator_(clock_), |
41 rtp_payload_registry_(RTPPayloadStrategy::CreateStrategy(false)), | 41 rtp_payload_registry_(RTPPayloadStrategy::CreateStrategy(false)), |
42 rtp_header_parser_(RtpHeaderParser::Create()), | 42 rtp_header_parser_(RtpHeaderParser::Create()), |
43 rtp_receiver_(RtpReceiver::CreateVideoReceiver(clock_, | 43 rtp_receiver_(RtpReceiver::CreateVideoReceiver(clock_, |
44 this, | 44 this, |
45 rtp_feedback, | 45 rtp_feedback, |
46 &rtp_payload_registry_)), | 46 &rtp_payload_registry_)), |
47 rtp_receive_statistics_(ReceiveStatistics::Create(clock_)), | 47 rtp_receive_statistics_(ReceiveStatistics::Create(clock_)), |
48 fec_receiver_(FecReceiver::Create(this)), | 48 fec_receiver_(FecReceiver::Create(this)), |
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
135 void ViEReceiver::EnableReceiveRtpHeaderExtension(const std::string& extension, | 135 void ViEReceiver::EnableReceiveRtpHeaderExtension(const std::string& extension, |
136 int id) { | 136 int id) { |
137 RTC_DCHECK(RtpExtension::IsSupportedForVideo(extension)); | 137 RTC_DCHECK(RtpExtension::IsSupportedForVideo(extension)); |
138 RTC_CHECK(rtp_header_parser_->RegisterRtpHeaderExtension( | 138 RTC_CHECK(rtp_header_parser_->RegisterRtpHeaderExtension( |
139 StringToRtpExtensionType(extension), id)); | 139 StringToRtpExtensionType(extension), id)); |
140 } | 140 } |
141 | 141 |
142 int32_t ViEReceiver::OnReceivedPayloadData(const uint8_t* payload_data, | 142 int32_t ViEReceiver::OnReceivedPayloadData(const uint8_t* payload_data, |
143 const size_t payload_size, | 143 const size_t payload_size, |
144 const WebRtcRTPHeader* rtp_header) { | 144 const WebRtcRTPHeader* rtp_header) { |
145 RTC_DCHECK(vcm_); | 145 RTC_DCHECK(video_receiver_); |
146 WebRtcRTPHeader rtp_header_with_ntp = *rtp_header; | 146 WebRtcRTPHeader rtp_header_with_ntp = *rtp_header; |
147 rtp_header_with_ntp.ntp_time_ms = | 147 rtp_header_with_ntp.ntp_time_ms = |
148 ntp_estimator_.Estimate(rtp_header->header.timestamp); | 148 ntp_estimator_.Estimate(rtp_header->header.timestamp); |
149 if (vcm_->IncomingPacket(payload_data, | 149 if (video_receiver_->IncomingPacket(payload_data, payload_size, |
150 payload_size, | 150 rtp_header_with_ntp) != 0) { |
151 rtp_header_with_ntp) != 0) { | |
152 // Check this... | 151 // Check this... |
153 return -1; | 152 return -1; |
154 } | 153 } |
155 return 0; | 154 return 0; |
156 } | 155 } |
157 | 156 |
158 bool ViEReceiver::OnRecoveredPacket(const uint8_t* rtp_packet, | 157 bool ViEReceiver::OnRecoveredPacket(const uint8_t* rtp_packet, |
159 size_t rtp_packet_length) { | 158 size_t rtp_packet_length) { |
160 RTPHeader header; | 159 RTPHeader header; |
161 if (!rtp_header_parser_->Parse(rtp_packet, rtp_packet_length, &header)) { | 160 if (!rtp_header_parser_->Parse(rtp_packet, rtp_packet_length, &header)) { |
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
242 payload_specific, in_order); | 241 payload_specific, in_order); |
243 } | 242 } |
244 | 243 |
245 bool ViEReceiver::ParseAndHandleEncapsulatingHeader(const uint8_t* packet, | 244 bool ViEReceiver::ParseAndHandleEncapsulatingHeader(const uint8_t* packet, |
246 size_t packet_length, | 245 size_t packet_length, |
247 const RTPHeader& header) { | 246 const RTPHeader& header) { |
248 if (rtp_payload_registry_.IsRed(header)) { | 247 if (rtp_payload_registry_.IsRed(header)) { |
249 int8_t ulpfec_pt = rtp_payload_registry_.ulpfec_payload_type(); | 248 int8_t ulpfec_pt = rtp_payload_registry_.ulpfec_payload_type(); |
250 if (packet[header.headerLength] == ulpfec_pt) { | 249 if (packet[header.headerLength] == ulpfec_pt) { |
251 rtp_receive_statistics_->FecPacketReceived(header, packet_length); | 250 rtp_receive_statistics_->FecPacketReceived(header, packet_length); |
252 // Notify vcm about received FEC packets to avoid NACKing these packets. | 251 // Notify video_receiver about received FEC packets to avoid NACKing these |
| 252 // packets. |
253 NotifyReceiverOfFecPacket(header); | 253 NotifyReceiverOfFecPacket(header); |
254 } | 254 } |
255 if (fec_receiver_->AddReceivedRedPacket( | 255 if (fec_receiver_->AddReceivedRedPacket( |
256 header, packet, packet_length, ulpfec_pt) != 0) { | 256 header, packet, packet_length, ulpfec_pt) != 0) { |
257 return false; | 257 return false; |
258 } | 258 } |
259 return fec_receiver_->ProcessReceivedFec() == 0; | 259 return fec_receiver_->ProcessReceivedFec() == 0; |
260 } else if (rtp_payload_registry_.IsRtx(header)) { | 260 } else if (rtp_payload_registry_.IsRtx(header)) { |
261 if (header.headerLength + header.paddingLength == packet_length) { | 261 if (header.headerLength + header.paddingLength == packet_length) { |
262 // This is an empty packet and should be silently dropped before trying to | 262 // This is an empty packet and should be silently dropped before trying to |
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
377 rtp_receive_statistics_->GetStatistician(header.ssrc); | 377 rtp_receive_statistics_->GetStatistician(header.ssrc); |
378 if (!statistician) | 378 if (!statistician) |
379 return false; | 379 return false; |
380 // Check if this is a retransmission. | 380 // Check if this is a retransmission. |
381 int64_t min_rtt = 0; | 381 int64_t min_rtt = 0; |
382 rtp_rtcp_->RTT(rtp_receiver_->SSRC(), nullptr, nullptr, &min_rtt, nullptr); | 382 rtp_rtcp_->RTT(rtp_receiver_->SSRC(), nullptr, nullptr, &min_rtt, nullptr); |
383 return !in_order && | 383 return !in_order && |
384 statistician->IsRetransmitOfOldPacket(header, min_rtt); | 384 statistician->IsRetransmitOfOldPacket(header, min_rtt); |
385 } | 385 } |
386 } // namespace webrtc | 386 } // namespace webrtc |
OLD | NEW |