Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(174)

Side by Side Diff: webrtc/video/vie_receiver.cc

Issue 1739893005: Remove add/removal of ViEReceiver RTP modules. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: move comment Created 4 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « webrtc/video/vie_receiver.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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/remote_ntp_time_estimator.h"
21 #include "webrtc/modules/rtp_rtcp/include/rtp_cvo.h" 20 #include "webrtc/modules/rtp_rtcp/include/rtp_cvo.h"
22 #include "webrtc/modules/rtp_rtcp/include/rtp_header_parser.h" 21 #include "webrtc/modules/rtp_rtcp/include/rtp_header_parser.h"
23 #include "webrtc/modules/rtp_rtcp/include/rtp_payload_registry.h"
24 #include "webrtc/modules/rtp_rtcp/include/rtp_receiver.h" 22 #include "webrtc/modules/rtp_rtcp/include/rtp_receiver.h"
25 #include "webrtc/modules/rtp_rtcp/include/rtp_rtcp.h" 23 #include "webrtc/modules/rtp_rtcp/include/rtp_rtcp.h"
26 #include "webrtc/modules/video_coding/include/video_coding.h" 24 #include "webrtc/modules/video_coding/include/video_coding.h"
27 #include "webrtc/system_wrappers/include/metrics.h" 25 #include "webrtc/system_wrappers/include/metrics.h"
28 #include "webrtc/system_wrappers/include/tick_util.h" 26 #include "webrtc/system_wrappers/include/tick_util.h"
29 #include "webrtc/system_wrappers/include/timestamp_extrapolator.h" 27 #include "webrtc/system_wrappers/include/timestamp_extrapolator.h"
30 #include "webrtc/system_wrappers/include/trace.h" 28 #include "webrtc/system_wrappers/include/trace.h"
31 29
32 namespace webrtc { 30 namespace webrtc {
33 31
34 static const int kPacketLogIntervalMs = 10000; 32 static const int kPacketLogIntervalMs = 10000;
35 33
36 ViEReceiver::ViEReceiver(VideoCodingModule* module_vcm, 34 ViEReceiver::ViEReceiver(VideoCodingModule* module_vcm,
37 RemoteBitrateEstimator* remote_bitrate_estimator, 35 RemoteBitrateEstimator* remote_bitrate_estimator,
38 RtpFeedback* rtp_feedback) 36 RtpFeedback* rtp_feedback)
39 : clock_(Clock::GetRealTimeClock()), 37 : clock_(Clock::GetRealTimeClock()),
38 vcm_(module_vcm),
39 remote_bitrate_estimator_(remote_bitrate_estimator),
40 ntp_estimator_(clock_),
41 rtp_payload_registry_(RTPPayloadStrategy::CreateStrategy(false)),
40 rtp_header_parser_(RtpHeaderParser::Create()), 42 rtp_header_parser_(RtpHeaderParser::Create()),
41 rtp_payload_registry_( 43 rtp_receiver_(RtpReceiver::CreateVideoReceiver(clock_,
42 new RTPPayloadRegistry(RTPPayloadStrategy::CreateStrategy(false))), 44 this,
43 rtp_receiver_( 45 rtp_feedback,
44 RtpReceiver::CreateVideoReceiver(clock_, 46 &rtp_payload_registry_)),
45 this,
46 rtp_feedback,
47 rtp_payload_registry_.get())),
48 rtp_receive_statistics_(ReceiveStatistics::Create(clock_)), 47 rtp_receive_statistics_(ReceiveStatistics::Create(clock_)),
49 fec_receiver_(FecReceiver::Create(this)), 48 fec_receiver_(FecReceiver::Create(this)),
50 rtp_rtcp_(NULL),
51 vcm_(module_vcm),
52 remote_bitrate_estimator_(remote_bitrate_estimator),
53 ntp_estimator_(new RemoteNtpTimeEstimator(clock_)),
54 receiving_(false), 49 receiving_(false),
55 restored_packet_in_use_(false), 50 restored_packet_in_use_(false),
56 last_packet_log_ms_(-1) {} 51 last_packet_log_ms_(-1) {}
57 52
58 ViEReceiver::~ViEReceiver() { 53 ViEReceiver::~ViEReceiver() {
59 UpdateHistograms(); 54 UpdateHistograms();
60 } 55 }
61 56
62 void ViEReceiver::UpdateHistograms() { 57 void ViEReceiver::UpdateHistograms() {
63 FecPacketCounter counter = fec_receiver_->GetPacketCounter(); 58 FecPacketCounter counter = fec_receiver_->GetPacketCounter();
64 if (counter.num_packets > 0) { 59 if (counter.num_packets > 0) {
65 RTC_HISTOGRAM_PERCENTAGE( 60 RTC_HISTOGRAM_PERCENTAGE(
66 "WebRTC.Video.ReceivedFecPacketsInPercent", 61 "WebRTC.Video.ReceivedFecPacketsInPercent",
67 static_cast<int>(counter.num_fec_packets * 100 / counter.num_packets)); 62 static_cast<int>(counter.num_fec_packets * 100 / counter.num_packets));
68 } 63 }
69 if (counter.num_fec_packets > 0) { 64 if (counter.num_fec_packets > 0) {
70 RTC_HISTOGRAM_PERCENTAGE("WebRTC.Video.RecoveredMediaPacketsInPercentOfFec", 65 RTC_HISTOGRAM_PERCENTAGE("WebRTC.Video.RecoveredMediaPacketsInPercentOfFec",
71 static_cast<int>(counter.num_recovered_packets * 66 static_cast<int>(counter.num_recovered_packets *
72 100 / counter.num_fec_packets)); 67 100 / counter.num_fec_packets));
73 } 68 }
74 } 69 }
75 70
76 bool ViEReceiver::SetReceiveCodec(const VideoCodec& video_codec) { 71 bool ViEReceiver::SetReceiveCodec(const VideoCodec& video_codec) {
77 int8_t old_pltype = -1; 72 int8_t old_pltype = -1;
78 if (rtp_payload_registry_->ReceivePayloadType(video_codec.plName, 73 if (rtp_payload_registry_.ReceivePayloadType(
79 kVideoPayloadTypeFrequency, 74 video_codec.plName, kVideoPayloadTypeFrequency, 0,
80 0, 75 video_codec.maxBitrate, &old_pltype) != -1) {
81 video_codec.maxBitrate, 76 rtp_payload_registry_.DeRegisterReceivePayload(old_pltype);
82 &old_pltype) != -1) {
83 rtp_payload_registry_->DeRegisterReceivePayload(old_pltype);
84 } 77 }
85 78
86 return RegisterPayload(video_codec); 79 return rtp_receiver_->RegisterReceivePayload(
87 } 80 video_codec.plName, video_codec.plType, kVideoPayloadTypeFrequency,
88 81 0, 0) == 0;
89 bool ViEReceiver::RegisterPayload(const VideoCodec& video_codec) {
90 return rtp_receiver_->RegisterReceivePayload(video_codec.plName,
91 video_codec.plType,
92 kVideoPayloadTypeFrequency,
93 0,
94 video_codec.maxBitrate) == 0;
95 } 82 }
96 83
97 void ViEReceiver::SetNackStatus(bool enable, 84 void ViEReceiver::SetNackStatus(bool enable,
98 int max_nack_reordering_threshold) { 85 int max_nack_reordering_threshold) {
99 if (!enable) { 86 if (!enable) {
100 // Reset the threshold back to the lower default threshold when NACK is 87 // Reset the threshold back to the lower default threshold when NACK is
101 // disabled since we no longer will be receiving retransmissions. 88 // disabled since we no longer will be receiving retransmissions.
102 max_nack_reordering_threshold = kDefaultMaxReorderingThreshold; 89 max_nack_reordering_threshold = kDefaultMaxReorderingThreshold;
103 } 90 }
104 rtp_receive_statistics_->SetMaxReorderingThreshold( 91 rtp_receive_statistics_->SetMaxReorderingThreshold(
105 max_nack_reordering_threshold); 92 max_nack_reordering_threshold);
106 rtp_receiver_->SetNACKStatus(enable ? kNackRtcp : kNackOff); 93 rtp_receiver_->SetNACKStatus(enable ? kNackRtcp : kNackOff);
107 } 94 }
108 95
109 void ViEReceiver::SetRtxPayloadType(int payload_type, 96 void ViEReceiver::SetRtxPayloadType(int payload_type,
110 int associated_payload_type) { 97 int associated_payload_type) {
111 rtp_payload_registry_->SetRtxPayloadType(payload_type, 98 rtp_payload_registry_.SetRtxPayloadType(payload_type,
112 associated_payload_type); 99 associated_payload_type);
113 } 100 }
114 101
115 void ViEReceiver::SetUseRtxPayloadMappingOnRestore(bool val) { 102 void ViEReceiver::SetUseRtxPayloadMappingOnRestore(bool val) {
116 rtp_payload_registry_->set_use_rtx_payload_mapping_on_restore(val); 103 rtp_payload_registry_.set_use_rtx_payload_mapping_on_restore(val);
117 } 104 }
118 105
119 void ViEReceiver::SetRtxSsrc(uint32_t ssrc) { 106 void ViEReceiver::SetRtxSsrc(uint32_t ssrc) {
120 rtp_payload_registry_->SetRtxSsrc(ssrc); 107 rtp_payload_registry_.SetRtxSsrc(ssrc);
121 } 108 }
122 109
123 bool ViEReceiver::GetRtxSsrc(uint32_t* ssrc) const { 110 bool ViEReceiver::GetRtxSsrc(uint32_t* ssrc) const {
124 return rtp_payload_registry_->GetRtxSsrc(ssrc); 111 return rtp_payload_registry_.GetRtxSsrc(ssrc);
125 } 112 }
126 113
127 bool ViEReceiver::IsFecEnabled() const { 114 bool ViEReceiver::IsFecEnabled() const {
128 return rtp_payload_registry_->ulpfec_payload_type() > -1; 115 return rtp_payload_registry_.ulpfec_payload_type() > -1;
129 } 116 }
130 117
131 uint32_t ViEReceiver::GetRemoteSsrc() const { 118 uint32_t ViEReceiver::GetRemoteSsrc() const {
132 return rtp_receiver_->SSRC(); 119 return rtp_receiver_->SSRC();
133 } 120 }
134 121
135 int ViEReceiver::GetCsrcs(uint32_t* csrcs) const { 122 int ViEReceiver::GetCsrcs(uint32_t* csrcs) const {
136 return rtp_receiver_->CSRCs(csrcs); 123 return rtp_receiver_->CSRCs(csrcs);
137 } 124 }
138 125
139 void ViEReceiver::SetRtpRtcpModule(RtpRtcp* module) { 126 void ViEReceiver::Init(const std::vector<RtpRtcp*>& modules) {
140 rtp_rtcp_ = module; 127 rtp_rtcp_ = modules;
141 } 128 }
142 129
143 RtpReceiver* ViEReceiver::GetRtpReceiver() const { 130 RtpReceiver* ViEReceiver::GetRtpReceiver() const {
144 return rtp_receiver_.get(); 131 return rtp_receiver_.get();
145 } 132 }
146 133
147 void ViEReceiver::RegisterRtpRtcpModules(
148 const std::vector<RtpRtcp*>& rtp_modules) {
149 rtc::CritScope lock(&receive_cs_);
150 // Only change the "simulcast" modules, the base module can be accessed
151 // without a lock whereas the simulcast modules require locking as they can be
152 // changed in runtime.
153 rtp_rtcp_simulcast_ =
154 std::vector<RtpRtcp*>(rtp_modules.begin() + 1, rtp_modules.end());
155 }
156
157 void ViEReceiver::EnableReceiveRtpHeaderExtension(const std::string& extension, 134 void ViEReceiver::EnableReceiveRtpHeaderExtension(const std::string& extension,
158 int id) { 135 int id) {
159 RTC_DCHECK(RtpExtension::IsSupportedForVideo(extension)); 136 RTC_DCHECK(RtpExtension::IsSupportedForVideo(extension));
160 RTC_CHECK(rtp_header_parser_->RegisterRtpHeaderExtension( 137 RTC_CHECK(rtp_header_parser_->RegisterRtpHeaderExtension(
161 StringToRtpExtensionType(extension), id)); 138 StringToRtpExtensionType(extension), id));
162 } 139 }
163 140
164 int32_t ViEReceiver::OnReceivedPayloadData(const uint8_t* payload_data, 141 int32_t ViEReceiver::OnReceivedPayloadData(const uint8_t* payload_data,
165 const size_t payload_size, 142 const size_t payload_size,
166 const WebRtcRTPHeader* rtp_header) { 143 const WebRtcRTPHeader* rtp_header) {
167 RTC_DCHECK(vcm_); 144 RTC_DCHECK(vcm_);
168 WebRtcRTPHeader rtp_header_with_ntp = *rtp_header; 145 WebRtcRTPHeader rtp_header_with_ntp = *rtp_header;
169 rtp_header_with_ntp.ntp_time_ms = 146 rtp_header_with_ntp.ntp_time_ms =
170 ntp_estimator_->Estimate(rtp_header->header.timestamp); 147 ntp_estimator_.Estimate(rtp_header->header.timestamp);
171 if (vcm_->IncomingPacket(payload_data, 148 if (vcm_->IncomingPacket(payload_data,
172 payload_size, 149 payload_size,
173 rtp_header_with_ntp) != 0) { 150 rtp_header_with_ntp) != 0) {
174 // Check this... 151 // Check this...
175 return -1; 152 return -1;
176 } 153 }
177 return 0; 154 return 0;
178 } 155 }
179 156
180 bool ViEReceiver::OnRecoveredPacket(const uint8_t* rtp_packet, 157 bool ViEReceiver::OnRecoveredPacket(const uint8_t* rtp_packet,
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
228 LOG(LS_INFO) << ss.str(); 205 LOG(LS_INFO) << ss.str();
229 last_packet_log_ms_ = now_ms; 206 last_packet_log_ms_ = now_ms;
230 } 207 }
231 } 208 }
232 209
233 remote_bitrate_estimator_->IncomingPacket(arrival_time_ms, payload_length, 210 remote_bitrate_estimator_->IncomingPacket(arrival_time_ms, payload_length,
234 header, true); 211 header, true);
235 header.payload_type_frequency = kVideoPayloadTypeFrequency; 212 header.payload_type_frequency = kVideoPayloadTypeFrequency;
236 213
237 bool in_order = IsPacketInOrder(header); 214 bool in_order = IsPacketInOrder(header);
238 rtp_payload_registry_->SetIncomingPayloadType(header); 215 rtp_payload_registry_.SetIncomingPayloadType(header);
239 bool ret = ReceivePacket(rtp_packet, rtp_packet_length, header, in_order); 216 bool ret = ReceivePacket(rtp_packet, rtp_packet_length, header, in_order);
240 // Update receive statistics after ReceivePacket. 217 // Update receive statistics after ReceivePacket.
241 // Receive statistics will be reset if the payload type changes (make sure 218 // Receive statistics will be reset if the payload type changes (make sure
242 // that the first packet is included in the stats). 219 // that the first packet is included in the stats).
243 rtp_receive_statistics_->IncomingPacket( 220 rtp_receive_statistics_->IncomingPacket(
244 header, rtp_packet_length, IsPacketRetransmitted(header, in_order)); 221 header, rtp_packet_length, IsPacketRetransmitted(header, in_order));
245 return ret; 222 return ret;
246 } 223 }
247 224
248 bool ViEReceiver::ReceivePacket(const uint8_t* packet, 225 bool ViEReceiver::ReceivePacket(const uint8_t* packet,
249 size_t packet_length, 226 size_t packet_length,
250 const RTPHeader& header, 227 const RTPHeader& header,
251 bool in_order) { 228 bool in_order) {
252 if (rtp_payload_registry_->IsEncapsulated(header)) { 229 if (rtp_payload_registry_.IsEncapsulated(header)) {
253 return ParseAndHandleEncapsulatingHeader(packet, packet_length, header); 230 return ParseAndHandleEncapsulatingHeader(packet, packet_length, header);
254 } 231 }
255 const uint8_t* payload = packet + header.headerLength; 232 const uint8_t* payload = packet + header.headerLength;
256 assert(packet_length >= header.headerLength); 233 assert(packet_length >= header.headerLength);
257 size_t payload_length = packet_length - header.headerLength; 234 size_t payload_length = packet_length - header.headerLength;
258 PayloadUnion payload_specific; 235 PayloadUnion payload_specific;
259 if (!rtp_payload_registry_->GetPayloadSpecifics(header.payloadType, 236 if (!rtp_payload_registry_.GetPayloadSpecifics(header.payloadType,
260 &payload_specific)) { 237 &payload_specific)) {
261 return false; 238 return false;
262 } 239 }
263 return rtp_receiver_->IncomingRtpPacket(header, payload, payload_length, 240 return rtp_receiver_->IncomingRtpPacket(header, payload, payload_length,
264 payload_specific, in_order); 241 payload_specific, in_order);
265 } 242 }
266 243
267 bool ViEReceiver::ParseAndHandleEncapsulatingHeader(const uint8_t* packet, 244 bool ViEReceiver::ParseAndHandleEncapsulatingHeader(const uint8_t* packet,
268 size_t packet_length, 245 size_t packet_length,
269 const RTPHeader& header) { 246 const RTPHeader& header) {
270 if (rtp_payload_registry_->IsRed(header)) { 247 if (rtp_payload_registry_.IsRed(header)) {
271 int8_t ulpfec_pt = rtp_payload_registry_->ulpfec_payload_type(); 248 int8_t ulpfec_pt = rtp_payload_registry_.ulpfec_payload_type();
272 if (packet[header.headerLength] == ulpfec_pt) { 249 if (packet[header.headerLength] == ulpfec_pt) {
273 rtp_receive_statistics_->FecPacketReceived(header, packet_length); 250 rtp_receive_statistics_->FecPacketReceived(header, packet_length);
274 // Notify vcm about received FEC packets to avoid NACKing these packets. 251 // Notify vcm about received FEC packets to avoid NACKing these packets.
275 NotifyReceiverOfFecPacket(header); 252 NotifyReceiverOfFecPacket(header);
276 } 253 }
277 if (fec_receiver_->AddReceivedRedPacket( 254 if (fec_receiver_->AddReceivedRedPacket(
278 header, packet, packet_length, ulpfec_pt) != 0) { 255 header, packet, packet_length, ulpfec_pt) != 0) {
279 return false; 256 return false;
280 } 257 }
281 return fec_receiver_->ProcessReceivedFec() == 0; 258 return fec_receiver_->ProcessReceivedFec() == 0;
282 } else if (rtp_payload_registry_->IsRtx(header)) { 259 } else if (rtp_payload_registry_.IsRtx(header)) {
283 if (header.headerLength + header.paddingLength == packet_length) { 260 if (header.headerLength + header.paddingLength == packet_length) {
284 // This is an empty packet and should be silently dropped before trying to 261 // This is an empty packet and should be silently dropped before trying to
285 // parse the RTX header. 262 // parse the RTX header.
286 return true; 263 return true;
287 } 264 }
288 // Remove the RTX header and parse the original RTP header. 265 // Remove the RTX header and parse the original RTP header.
289 if (packet_length < header.headerLength) 266 if (packet_length < header.headerLength)
290 return false; 267 return false;
291 if (packet_length > sizeof(restored_packet_)) 268 if (packet_length > sizeof(restored_packet_))
292 return false; 269 return false;
293 rtc::CritScope lock(&receive_cs_); 270 rtc::CritScope lock(&receive_cs_);
294 if (restored_packet_in_use_) { 271 if (restored_packet_in_use_) {
295 LOG(LS_WARNING) << "Multiple RTX headers detected, dropping packet."; 272 LOG(LS_WARNING) << "Multiple RTX headers detected, dropping packet.";
296 return false; 273 return false;
297 } 274 }
298 if (!rtp_payload_registry_->RestoreOriginalPacket( 275 if (!rtp_payload_registry_.RestoreOriginalPacket(
299 restored_packet_, packet, &packet_length, rtp_receiver_->SSRC(), 276 restored_packet_, packet, &packet_length, rtp_receiver_->SSRC(),
300 header)) { 277 header)) {
301 LOG(LS_WARNING) << "Incoming RTX packet: Invalid RTP header ssrc: " 278 LOG(LS_WARNING) << "Incoming RTX packet: Invalid RTP header ssrc: "
302 << header.ssrc << " payload type: " 279 << header.ssrc << " payload type: "
303 << static_cast<int>(header.payloadType); 280 << static_cast<int>(header.payloadType);
304 return false; 281 return false;
305 } 282 }
306 restored_packet_in_use_ = true; 283 restored_packet_in_use_ = true;
307 bool ret = OnRecoveredPacket(restored_packet_, packet_length); 284 bool ret = OnRecoveredPacket(restored_packet_, packet_length);
308 restored_packet_in_use_ = false; 285 restored_packet_in_use_ = false;
309 return ret; 286 return ret;
310 } 287 }
311 return false; 288 return false;
312 } 289 }
313 290
314 void ViEReceiver::NotifyReceiverOfFecPacket(const RTPHeader& header) { 291 void ViEReceiver::NotifyReceiverOfFecPacket(const RTPHeader& header) {
315 int8_t last_media_payload_type = 292 int8_t last_media_payload_type =
316 rtp_payload_registry_->last_received_media_payload_type(); 293 rtp_payload_registry_.last_received_media_payload_type();
317 if (last_media_payload_type < 0) { 294 if (last_media_payload_type < 0) {
318 LOG(LS_WARNING) << "Failed to get last media payload type."; 295 LOG(LS_WARNING) << "Failed to get last media payload type.";
319 return; 296 return;
320 } 297 }
321 // Fake an empty media packet. 298 // Fake an empty media packet.
322 WebRtcRTPHeader rtp_header = {}; 299 WebRtcRTPHeader rtp_header = {};
323 rtp_header.header = header; 300 rtp_header.header = header;
324 rtp_header.header.payloadType = last_media_payload_type; 301 rtp_header.header.payloadType = last_media_payload_type;
325 rtp_header.header.paddingLength = 0; 302 rtp_header.header.paddingLength = 0;
326 PayloadUnion payload_specific; 303 PayloadUnion payload_specific;
327 if (!rtp_payload_registry_->GetPayloadSpecifics(last_media_payload_type, 304 if (!rtp_payload_registry_.GetPayloadSpecifics(last_media_payload_type,
328 &payload_specific)) { 305 &payload_specific)) {
329 LOG(LS_WARNING) << "Failed to get payload specifics."; 306 LOG(LS_WARNING) << "Failed to get payload specifics.";
330 return; 307 return;
331 } 308 }
332 rtp_header.type.Video.codec = payload_specific.Video.videoCodecType; 309 rtp_header.type.Video.codec = payload_specific.Video.videoCodecType;
333 rtp_header.type.Video.rotation = kVideoRotation_0; 310 rtp_header.type.Video.rotation = kVideoRotation_0;
334 if (header.extension.hasVideoRotation) { 311 if (header.extension.hasVideoRotation) {
335 rtp_header.type.Video.rotation = 312 rtp_header.type.Video.rotation =
336 ConvertCVOByteToVideoRotation(header.extension.videoRotation); 313 ConvertCVOByteToVideoRotation(header.extension.videoRotation);
337 } 314 }
338 OnReceivedPayloadData(NULL, 0, &rtp_header); 315 OnReceivedPayloadData(NULL, 0, &rtp_header);
339 } 316 }
340 317
341 bool ViEReceiver::DeliverRtcp(const uint8_t* rtcp_packet, 318 bool ViEReceiver::DeliverRtcp(const uint8_t* rtcp_packet,
342 size_t rtcp_packet_length) { 319 size_t rtcp_packet_length) {
320 // Should be set by owner at construction time.
321 RTC_DCHECK(!rtp_rtcp_.empty());
343 { 322 {
344 rtc::CritScope lock(&receive_cs_); 323 rtc::CritScope lock(&receive_cs_);
345 if (!receiving_) { 324 if (!receiving_) {
346 return false; 325 return false;
347 } 326 }
348
349 for (RtpRtcp* rtp_rtcp : rtp_rtcp_simulcast_)
350 rtp_rtcp->IncomingRtcpPacket(rtcp_packet, rtcp_packet_length);
351 }
352 assert(rtp_rtcp_); // Should be set by owner at construction time.
353 int ret = rtp_rtcp_->IncomingRtcpPacket(rtcp_packet, rtcp_packet_length);
354 if (ret != 0) {
355 return false;
356 } 327 }
357 328
329 for (RtpRtcp* rtp_rtcp : rtp_rtcp_)
330 rtp_rtcp->IncomingRtcpPacket(rtcp_packet, rtcp_packet_length);
331
358 int64_t rtt = 0; 332 int64_t rtt = 0;
359 rtp_rtcp_->RTT(rtp_receiver_->SSRC(), &rtt, NULL, NULL, NULL); 333 rtp_rtcp_[0]->RTT(rtp_receiver_->SSRC(), &rtt, NULL, NULL, NULL);
360 if (rtt == 0) { 334 if (rtt == 0) {
361 // Waiting for valid rtt. 335 // Waiting for valid rtt.
362 return true; 336 return true;
363 } 337 }
364 uint32_t ntp_secs = 0; 338 uint32_t ntp_secs = 0;
365 uint32_t ntp_frac = 0; 339 uint32_t ntp_frac = 0;
366 uint32_t rtp_timestamp = 0; 340 uint32_t rtp_timestamp = 0;
367 if (0 != rtp_rtcp_->RemoteNTP(&ntp_secs, &ntp_frac, NULL, NULL, 341 if (rtp_rtcp_[0]->RemoteNTP(&ntp_secs, &ntp_frac, NULL, NULL,
368 &rtp_timestamp)) { 342 &rtp_timestamp) != 0) {
369 // Waiting for RTCP. 343 // Waiting for RTCP.
370 return true; 344 return true;
371 } 345 }
372 ntp_estimator_->UpdateRtcpTimestamp(rtt, ntp_secs, ntp_frac, rtp_timestamp); 346 ntp_estimator_.UpdateRtcpTimestamp(rtt, ntp_secs, ntp_frac, rtp_timestamp);
373 347
374 return true; 348 return true;
375 } 349 }
376 350
377 void ViEReceiver::StartReceive() { 351 void ViEReceiver::StartReceive() {
378 rtc::CritScope lock(&receive_cs_); 352 rtc::CritScope lock(&receive_cs_);
379 receiving_ = true; 353 receiving_ = true;
380 } 354 }
381 355
382 void ViEReceiver::StopReceive() { 356 void ViEReceiver::StopReceive() {
383 rtc::CritScope lock(&receive_cs_); 357 rtc::CritScope lock(&receive_cs_);
384 receiving_ = false; 358 receiving_ = false;
385 } 359 }
386 360
387 ReceiveStatistics* ViEReceiver::GetReceiveStatistics() const { 361 ReceiveStatistics* ViEReceiver::GetReceiveStatistics() const {
388 return rtp_receive_statistics_.get(); 362 return rtp_receive_statistics_.get();
389 } 363 }
390 364
391 bool ViEReceiver::IsPacketInOrder(const RTPHeader& header) const { 365 bool ViEReceiver::IsPacketInOrder(const RTPHeader& header) const {
392 StreamStatistician* statistician = 366 StreamStatistician* statistician =
393 rtp_receive_statistics_->GetStatistician(header.ssrc); 367 rtp_receive_statistics_->GetStatistician(header.ssrc);
394 if (!statistician) 368 if (!statistician)
395 return false; 369 return false;
396 return statistician->IsPacketInOrder(header.sequenceNumber); 370 return statistician->IsPacketInOrder(header.sequenceNumber);
397 } 371 }
398 372
399 bool ViEReceiver::IsPacketRetransmitted(const RTPHeader& header, 373 bool ViEReceiver::IsPacketRetransmitted(const RTPHeader& header,
400 bool in_order) const { 374 bool in_order) const {
401 // Retransmissions are handled separately if RTX is enabled. 375 // Retransmissions are handled separately if RTX is enabled.
402 if (rtp_payload_registry_->RtxEnabled()) 376 if (rtp_payload_registry_.RtxEnabled())
403 return false; 377 return false;
404 StreamStatistician* statistician = 378 StreamStatistician* statistician =
405 rtp_receive_statistics_->GetStatistician(header.ssrc); 379 rtp_receive_statistics_->GetStatistician(header.ssrc);
406 if (!statistician) 380 if (!statistician)
407 return false; 381 return false;
408 // Check if this is a retransmission. 382 // Check if this is a retransmission.
409 int64_t min_rtt = 0; 383 int64_t min_rtt = 0;
410 rtp_rtcp_->RTT(rtp_receiver_->SSRC(), NULL, NULL, &min_rtt, NULL); 384 rtp_rtcp_[0]->RTT(rtp_receiver_->SSRC(), NULL, NULL, &min_rtt, NULL);
411 return !in_order && 385 return !in_order &&
412 statistician->IsRetransmitOfOldPacket(header, min_rtt); 386 statistician->IsRetransmitOfOldPacket(header, min_rtt);
413 } 387 }
414 } // namespace webrtc 388 } // namespace webrtc
OLDNEW
« no previous file with comments | « webrtc/video/vie_receiver.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698