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/rtp_stream_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/pacing/packet_router.h" | 17 #include "webrtc/modules/pacing/packet_router.h" |
18 #include "webrtc/modules/remote_bitrate_estimator/include/remote_bitrate_estimat
or.h" | 18 #include "webrtc/modules/remote_bitrate_estimator/include/remote_bitrate_estimat
or.h" |
19 #include "webrtc/modules/rtp_rtcp/include/fec_receiver.h" | 19 #include "webrtc/modules/rtp_rtcp/include/fec_receiver.h" |
20 #include "webrtc/modules/rtp_rtcp/include/receive_statistics.h" | 20 #include "webrtc/modules/rtp_rtcp/include/receive_statistics.h" |
21 #include "webrtc/modules/rtp_rtcp/include/rtp_cvo.h" | 21 #include "webrtc/modules/rtp_rtcp/include/rtp_cvo.h" |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
60 rtp_rtcp->SetSendingStatus(false); | 60 rtp_rtcp->SetSendingStatus(false); |
61 rtp_rtcp->SetSendingMediaStatus(false); | 61 rtp_rtcp->SetSendingMediaStatus(false); |
62 rtp_rtcp->SetRTCPStatus(RtcpMode::kCompound); | 62 rtp_rtcp->SetRTCPStatus(RtcpMode::kCompound); |
63 | 63 |
64 return rtp_rtcp; | 64 return rtp_rtcp; |
65 } | 65 } |
66 | 66 |
67 | 67 |
68 static const int kPacketLogIntervalMs = 10000; | 68 static const int kPacketLogIntervalMs = 10000; |
69 | 69 |
70 ViEReceiver::ViEReceiver(vcm::VideoReceiver* video_receiver, | 70 RtpStreamReceiver::RtpStreamReceiver( |
71 RemoteBitrateEstimator* remote_bitrate_estimator, | 71 vcm::VideoReceiver* video_receiver, |
72 RtpFeedback* rtp_feedback, | 72 RemoteBitrateEstimator* remote_bitrate_estimator, |
73 Transport* transport, | 73 Transport* transport, |
74 RtcpRttStats* rtt_stats, | 74 RtcpRttStats* rtt_stats, |
75 PacedSender* paced_sender, | 75 PacedSender* paced_sender, |
76 PacketRouter* packet_router) | 76 PacketRouter* packet_router) |
77 : clock_(Clock::GetRealTimeClock()), | 77 : clock_(Clock::GetRealTimeClock()), |
78 video_receiver_(video_receiver), | 78 video_receiver_(video_receiver), |
79 remote_bitrate_estimator_(remote_bitrate_estimator), | 79 remote_bitrate_estimator_(remote_bitrate_estimator), |
80 packet_router_(packet_router), | 80 packet_router_(packet_router), |
81 ntp_estimator_(clock_), | 81 ntp_estimator_(clock_), |
82 rtp_payload_registry_(RTPPayloadStrategy::CreateStrategy(false)), | 82 rtp_payload_registry_(RTPPayloadStrategy::CreateStrategy(false)), |
83 rtp_header_parser_(RtpHeaderParser::Create()), | 83 rtp_header_parser_(RtpHeaderParser::Create()), |
84 rtp_receiver_(RtpReceiver::CreateVideoReceiver(clock_, | 84 rtp_receiver_(RtpReceiver::CreateVideoReceiver(clock_, |
85 this, | 85 this, |
86 rtp_feedback, | 86 this, |
87 &rtp_payload_registry_)), | 87 &rtp_payload_registry_)), |
88 rtp_receive_statistics_(ReceiveStatistics::Create(clock_)), | 88 rtp_receive_statistics_(ReceiveStatistics::Create(clock_)), |
89 fec_receiver_(FecReceiver::Create(this)), | 89 fec_receiver_(FecReceiver::Create(this)), |
90 receiving_(false), | 90 receiving_(false), |
91 restored_packet_in_use_(false), | 91 restored_packet_in_use_(false), |
92 last_packet_log_ms_(-1), | 92 last_packet_log_ms_(-1), |
93 rtp_rtcp_(CreateRtpRtcpModule(rtp_receive_statistics_.get(), | 93 rtp_rtcp_(CreateRtpRtcpModule(rtp_receive_statistics_.get(), |
94 transport, | 94 transport, |
95 rtt_stats, | 95 rtt_stats, |
96 &rtcp_packet_type_counter_observer_, | 96 &rtcp_packet_type_counter_observer_, |
97 remote_bitrate_estimator_, | 97 remote_bitrate_estimator_, |
98 paced_sender, | 98 paced_sender, |
99 packet_router)) { | 99 packet_router)) { |
100 packet_router_->AddRtpModule(rtp_rtcp_.get()); | 100 packet_router_->AddRtpModule(rtp_rtcp_.get()); |
101 rtp_rtcp_->SetKeyFrameRequestMethod(kKeyFrameReqPliRtcp); | 101 rtp_rtcp_->SetKeyFrameRequestMethod(kKeyFrameReqPliRtcp); |
102 } | 102 } |
103 | 103 |
104 ViEReceiver::~ViEReceiver() { | 104 RtpStreamReceiver::~RtpStreamReceiver() { |
105 packet_router_->RemoveRtpModule(rtp_rtcp_.get()); | 105 packet_router_->RemoveRtpModule(rtp_rtcp_.get()); |
106 UpdateHistograms(); | 106 UpdateHistograms(); |
107 } | 107 } |
108 | 108 |
109 void ViEReceiver::UpdateHistograms() { | 109 void RtpStreamReceiver::UpdateHistograms() { |
110 FecPacketCounter counter = fec_receiver_->GetPacketCounter(); | 110 FecPacketCounter counter = fec_receiver_->GetPacketCounter(); |
111 if (counter.num_packets > 0) { | 111 if (counter.num_packets > 0) { |
112 RTC_LOGGED_HISTOGRAM_PERCENTAGE( | 112 RTC_LOGGED_HISTOGRAM_PERCENTAGE( |
113 "WebRTC.Video.ReceivedFecPacketsInPercent", | 113 "WebRTC.Video.ReceivedFecPacketsInPercent", |
114 static_cast<int>(counter.num_fec_packets * 100 / counter.num_packets)); | 114 static_cast<int>(counter.num_fec_packets * 100 / counter.num_packets)); |
115 } | 115 } |
116 if (counter.num_fec_packets > 0) { | 116 if (counter.num_fec_packets > 0) { |
117 RTC_LOGGED_HISTOGRAM_PERCENTAGE( | 117 RTC_LOGGED_HISTOGRAM_PERCENTAGE( |
118 "WebRTC.Video.RecoveredMediaPacketsInPercentOfFec", | 118 "WebRTC.Video.RecoveredMediaPacketsInPercentOfFec", |
119 static_cast<int>(counter.num_recovered_packets * 100 / | 119 static_cast<int>(counter.num_recovered_packets * 100 / |
120 counter.num_fec_packets)); | 120 counter.num_fec_packets)); |
121 } | 121 } |
122 } | 122 } |
123 | 123 |
124 bool ViEReceiver::SetReceiveCodec(const VideoCodec& video_codec) { | 124 bool RtpStreamReceiver::SetReceiveCodec(const VideoCodec& video_codec) { |
125 int8_t old_pltype = -1; | 125 int8_t old_pltype = -1; |
126 if (rtp_payload_registry_.ReceivePayloadType( | 126 if (rtp_payload_registry_.ReceivePayloadType( |
127 video_codec.plName, kVideoPayloadTypeFrequency, 0, | 127 video_codec.plName, kVideoPayloadTypeFrequency, 0, |
128 video_codec.maxBitrate, &old_pltype) != -1) { | 128 video_codec.maxBitrate, &old_pltype) != -1) { |
129 rtp_payload_registry_.DeRegisterReceivePayload(old_pltype); | 129 rtp_payload_registry_.DeRegisterReceivePayload(old_pltype); |
130 } | 130 } |
131 | 131 |
132 return rtp_receiver_->RegisterReceivePayload( | 132 return rtp_receiver_->RegisterReceivePayload( |
133 video_codec.plName, video_codec.plType, kVideoPayloadTypeFrequency, | 133 video_codec.plName, video_codec.plType, kVideoPayloadTypeFrequency, |
134 0, 0) == 0; | 134 0, 0) == 0; |
135 } | 135 } |
136 | 136 |
137 void ViEReceiver::SetNackStatus(bool enable, | 137 void RtpStreamReceiver::SetNackStatus(bool enable, |
138 int max_nack_reordering_threshold) { | 138 int max_nack_reordering_threshold) { |
139 if (!enable) { | 139 if (!enable) { |
140 // Reset the threshold back to the lower default threshold when NACK is | 140 // Reset the threshold back to the lower default threshold when NACK is |
141 // disabled since we no longer will be receiving retransmissions. | 141 // disabled since we no longer will be receiving retransmissions. |
142 max_nack_reordering_threshold = kDefaultMaxReorderingThreshold; | 142 max_nack_reordering_threshold = kDefaultMaxReorderingThreshold; |
143 } | 143 } |
144 rtp_receive_statistics_->SetMaxReorderingThreshold( | 144 rtp_receive_statistics_->SetMaxReorderingThreshold( |
145 max_nack_reordering_threshold); | 145 max_nack_reordering_threshold); |
146 rtp_receiver_->SetNACKStatus(enable ? kNackRtcp : kNackOff); | 146 rtp_receiver_->SetNACKStatus(enable ? kNackRtcp : kNackOff); |
147 } | 147 } |
148 | 148 |
149 void ViEReceiver::SetRtxPayloadType(int payload_type, | 149 void RtpStreamReceiver::SetRtxPayloadType(int payload_type, |
150 int associated_payload_type) { | 150 int associated_payload_type) { |
151 rtp_payload_registry_.SetRtxPayloadType(payload_type, | 151 rtp_payload_registry_.SetRtxPayloadType(payload_type, |
152 associated_payload_type); | 152 associated_payload_type); |
153 } | 153 } |
154 | 154 |
155 void ViEReceiver::SetUseRtxPayloadMappingOnRestore(bool val) { | 155 void RtpStreamReceiver::SetUseRtxPayloadMappingOnRestore(bool val) { |
156 rtp_payload_registry_.set_use_rtx_payload_mapping_on_restore(val); | 156 rtp_payload_registry_.set_use_rtx_payload_mapping_on_restore(val); |
157 } | 157 } |
158 | 158 |
159 void ViEReceiver::SetRtxSsrc(uint32_t ssrc) { | 159 void RtpStreamReceiver::SetRtxSsrc(uint32_t ssrc) { |
160 rtp_payload_registry_.SetRtxSsrc(ssrc); | 160 rtp_payload_registry_.SetRtxSsrc(ssrc); |
161 } | 161 } |
162 | 162 |
163 bool ViEReceiver::GetRtxSsrc(uint32_t* ssrc) const { | 163 bool RtpStreamReceiver::GetRtxSsrc(uint32_t* ssrc) const { |
164 return rtp_payload_registry_.GetRtxSsrc(ssrc); | 164 return rtp_payload_registry_.GetRtxSsrc(ssrc); |
165 } | 165 } |
166 | 166 |
167 bool ViEReceiver::IsFecEnabled() const { | 167 bool RtpStreamReceiver::IsFecEnabled() const { |
168 return rtp_payload_registry_.ulpfec_payload_type() > -1; | 168 return rtp_payload_registry_.ulpfec_payload_type() > -1; |
169 } | 169 } |
170 | 170 |
171 uint32_t ViEReceiver::GetRemoteSsrc() const { | 171 uint32_t RtpStreamReceiver::GetRemoteSsrc() const { |
172 return rtp_receiver_->SSRC(); | 172 return rtp_receiver_->SSRC(); |
173 } | 173 } |
174 | 174 |
175 int ViEReceiver::GetCsrcs(uint32_t* csrcs) const { | 175 int RtpStreamReceiver::GetCsrcs(uint32_t* csrcs) const { |
176 return rtp_receiver_->CSRCs(csrcs); | 176 return rtp_receiver_->CSRCs(csrcs); |
177 } | 177 } |
178 | 178 |
179 RtpReceiver* ViEReceiver::GetRtpReceiver() const { | 179 RtpReceiver* RtpStreamReceiver::GetRtpReceiver() const { |
180 return rtp_receiver_.get(); | 180 return rtp_receiver_.get(); |
181 } | 181 } |
182 | 182 |
183 void ViEReceiver::EnableReceiveRtpHeaderExtension(const std::string& extension, | 183 void RtpStreamReceiver::EnableReceiveRtpHeaderExtension( |
184 int id) { | 184 const std::string& extension, int id) { |
185 RTC_DCHECK(RtpExtension::IsSupportedForVideo(extension)); | 185 RTC_DCHECK(RtpExtension::IsSupportedForVideo(extension)); |
186 RTC_CHECK(rtp_header_parser_->RegisterRtpHeaderExtension( | 186 RTC_CHECK(rtp_header_parser_->RegisterRtpHeaderExtension( |
187 StringToRtpExtensionType(extension), id)); | 187 StringToRtpExtensionType(extension), id)); |
188 } | 188 } |
189 | 189 |
190 void ViEReceiver::RegisterRtcpPacketTypeCounterObserver( | 190 void RtpStreamReceiver::RegisterRtcpPacketTypeCounterObserver( |
191 RtcpPacketTypeCounterObserver* observer) { | 191 RtcpPacketTypeCounterObserver* observer) { |
192 rtcp_packet_type_counter_observer_.Set(observer); | 192 rtcp_packet_type_counter_observer_.Set(observer); |
193 } | 193 } |
194 | 194 |
195 | 195 |
196 int32_t ViEReceiver::OnReceivedPayloadData(const uint8_t* payload_data, | 196 int32_t RtpStreamReceiver::OnReceivedPayloadData( |
197 const size_t payload_size, | 197 const uint8_t* payload_data, |
198 const WebRtcRTPHeader* rtp_header) { | 198 const size_t payload_size, |
| 199 const WebRtcRTPHeader* rtp_header) { |
199 RTC_DCHECK(video_receiver_); | 200 RTC_DCHECK(video_receiver_); |
200 WebRtcRTPHeader rtp_header_with_ntp = *rtp_header; | 201 WebRtcRTPHeader rtp_header_with_ntp = *rtp_header; |
201 rtp_header_with_ntp.ntp_time_ms = | 202 rtp_header_with_ntp.ntp_time_ms = |
202 ntp_estimator_.Estimate(rtp_header->header.timestamp); | 203 ntp_estimator_.Estimate(rtp_header->header.timestamp); |
203 if (video_receiver_->IncomingPacket(payload_data, payload_size, | 204 if (video_receiver_->IncomingPacket(payload_data, payload_size, |
204 rtp_header_with_ntp) != 0) { | 205 rtp_header_with_ntp) != 0) { |
205 // Check this... | 206 // Check this... |
206 return -1; | 207 return -1; |
207 } | 208 } |
208 return 0; | 209 return 0; |
209 } | 210 } |
210 | 211 |
211 bool ViEReceiver::OnRecoveredPacket(const uint8_t* rtp_packet, | 212 bool RtpStreamReceiver::OnRecoveredPacket(const uint8_t* rtp_packet, |
212 size_t rtp_packet_length) { | 213 size_t rtp_packet_length) { |
213 RTPHeader header; | 214 RTPHeader header; |
214 if (!rtp_header_parser_->Parse(rtp_packet, rtp_packet_length, &header)) { | 215 if (!rtp_header_parser_->Parse(rtp_packet, rtp_packet_length, &header)) { |
215 return false; | 216 return false; |
216 } | 217 } |
217 header.payload_type_frequency = kVideoPayloadTypeFrequency; | 218 header.payload_type_frequency = kVideoPayloadTypeFrequency; |
218 bool in_order = IsPacketInOrder(header); | 219 bool in_order = IsPacketInOrder(header); |
219 return ReceivePacket(rtp_packet, rtp_packet_length, header, in_order); | 220 return ReceivePacket(rtp_packet, rtp_packet_length, header, in_order); |
220 } | 221 } |
221 | 222 |
222 bool ViEReceiver::DeliverRtp(const uint8_t* rtp_packet, | 223 // TODO(pbos): Remove as soon as audio can handle a changing payload type |
223 size_t rtp_packet_length, | 224 // without this callback. |
224 const PacketTime& packet_time) { | 225 int32_t RtpStreamReceiver::OnInitializeDecoder( |
| 226 const int8_t payload_type, |
| 227 const char payload_name[RTP_PAYLOAD_NAME_SIZE], |
| 228 const int frequency, |
| 229 const size_t channels, |
| 230 const uint32_t rate) { |
| 231 RTC_NOTREACHED(); |
| 232 return 0; |
| 233 } |
| 234 |
| 235 void RtpStreamReceiver::OnIncomingSSRCChanged(const uint32_t ssrc) { |
| 236 rtp_rtcp_->SetRemoteSSRC(ssrc); |
| 237 } |
| 238 |
| 239 bool RtpStreamReceiver::DeliverRtp(const uint8_t* rtp_packet, |
| 240 size_t rtp_packet_length, |
| 241 const PacketTime& packet_time) { |
225 RTC_DCHECK(remote_bitrate_estimator_); | 242 RTC_DCHECK(remote_bitrate_estimator_); |
226 { | 243 { |
227 rtc::CritScope lock(&receive_cs_); | 244 rtc::CritScope lock(&receive_cs_); |
228 if (!receiving_) { | 245 if (!receiving_) { |
229 return false; | 246 return false; |
230 } | 247 } |
231 } | 248 } |
232 | 249 |
233 RTPHeader header; | 250 RTPHeader header; |
234 if (!rtp_header_parser_->Parse(rtp_packet, rtp_packet_length, | 251 if (!rtp_header_parser_->Parse(rtp_packet, rtp_packet_length, |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
269 rtp_payload_registry_.SetIncomingPayloadType(header); | 286 rtp_payload_registry_.SetIncomingPayloadType(header); |
270 bool ret = ReceivePacket(rtp_packet, rtp_packet_length, header, in_order); | 287 bool ret = ReceivePacket(rtp_packet, rtp_packet_length, header, in_order); |
271 // Update receive statistics after ReceivePacket. | 288 // Update receive statistics after ReceivePacket. |
272 // Receive statistics will be reset if the payload type changes (make sure | 289 // Receive statistics will be reset if the payload type changes (make sure |
273 // that the first packet is included in the stats). | 290 // that the first packet is included in the stats). |
274 rtp_receive_statistics_->IncomingPacket( | 291 rtp_receive_statistics_->IncomingPacket( |
275 header, rtp_packet_length, IsPacketRetransmitted(header, in_order)); | 292 header, rtp_packet_length, IsPacketRetransmitted(header, in_order)); |
276 return ret; | 293 return ret; |
277 } | 294 } |
278 | 295 |
279 bool ViEReceiver::ReceivePacket(const uint8_t* packet, | 296 bool RtpStreamReceiver::ReceivePacket(const uint8_t* packet, |
280 size_t packet_length, | 297 size_t packet_length, |
281 const RTPHeader& header, | 298 const RTPHeader& header, |
282 bool in_order) { | 299 bool in_order) { |
283 if (rtp_payload_registry_.IsEncapsulated(header)) { | 300 if (rtp_payload_registry_.IsEncapsulated(header)) { |
284 return ParseAndHandleEncapsulatingHeader(packet, packet_length, header); | 301 return ParseAndHandleEncapsulatingHeader(packet, packet_length, header); |
285 } | 302 } |
286 const uint8_t* payload = packet + header.headerLength; | 303 const uint8_t* payload = packet + header.headerLength; |
287 assert(packet_length >= header.headerLength); | 304 assert(packet_length >= header.headerLength); |
288 size_t payload_length = packet_length - header.headerLength; | 305 size_t payload_length = packet_length - header.headerLength; |
289 PayloadUnion payload_specific; | 306 PayloadUnion payload_specific; |
290 if (!rtp_payload_registry_.GetPayloadSpecifics(header.payloadType, | 307 if (!rtp_payload_registry_.GetPayloadSpecifics(header.payloadType, |
291 &payload_specific)) { | 308 &payload_specific)) { |
292 return false; | 309 return false; |
293 } | 310 } |
294 return rtp_receiver_->IncomingRtpPacket(header, payload, payload_length, | 311 return rtp_receiver_->IncomingRtpPacket(header, payload, payload_length, |
295 payload_specific, in_order); | 312 payload_specific, in_order); |
296 } | 313 } |
297 | 314 |
298 bool ViEReceiver::ParseAndHandleEncapsulatingHeader(const uint8_t* packet, | 315 bool RtpStreamReceiver::ParseAndHandleEncapsulatingHeader( |
299 size_t packet_length, | 316 const uint8_t* packet, size_t packet_length, const RTPHeader& header) { |
300 const RTPHeader& header) { | |
301 if (rtp_payload_registry_.IsRed(header)) { | 317 if (rtp_payload_registry_.IsRed(header)) { |
302 int8_t ulpfec_pt = rtp_payload_registry_.ulpfec_payload_type(); | 318 int8_t ulpfec_pt = rtp_payload_registry_.ulpfec_payload_type(); |
303 if (packet[header.headerLength] == ulpfec_pt) { | 319 if (packet[header.headerLength] == ulpfec_pt) { |
304 rtp_receive_statistics_->FecPacketReceived(header, packet_length); | 320 rtp_receive_statistics_->FecPacketReceived(header, packet_length); |
305 // Notify video_receiver about received FEC packets to avoid NACKing these | 321 // Notify video_receiver about received FEC packets to avoid NACKing these |
306 // packets. | 322 // packets. |
307 NotifyReceiverOfFecPacket(header); | 323 NotifyReceiverOfFecPacket(header); |
308 } | 324 } |
309 if (fec_receiver_->AddReceivedRedPacket( | 325 if (fec_receiver_->AddReceivedRedPacket( |
310 header, packet, packet_length, ulpfec_pt) != 0) { | 326 header, packet, packet_length, ulpfec_pt) != 0) { |
(...skipping 25 matching lines...) Expand all Loading... |
336 return false; | 352 return false; |
337 } | 353 } |
338 restored_packet_in_use_ = true; | 354 restored_packet_in_use_ = true; |
339 bool ret = OnRecoveredPacket(restored_packet_, packet_length); | 355 bool ret = OnRecoveredPacket(restored_packet_, packet_length); |
340 restored_packet_in_use_ = false; | 356 restored_packet_in_use_ = false; |
341 return ret; | 357 return ret; |
342 } | 358 } |
343 return false; | 359 return false; |
344 } | 360 } |
345 | 361 |
346 void ViEReceiver::NotifyReceiverOfFecPacket(const RTPHeader& header) { | 362 void RtpStreamReceiver::NotifyReceiverOfFecPacket(const RTPHeader& header) { |
347 int8_t last_media_payload_type = | 363 int8_t last_media_payload_type = |
348 rtp_payload_registry_.last_received_media_payload_type(); | 364 rtp_payload_registry_.last_received_media_payload_type(); |
349 if (last_media_payload_type < 0) { | 365 if (last_media_payload_type < 0) { |
350 LOG(LS_WARNING) << "Failed to get last media payload type."; | 366 LOG(LS_WARNING) << "Failed to get last media payload type."; |
351 return; | 367 return; |
352 } | 368 } |
353 // Fake an empty media packet. | 369 // Fake an empty media packet. |
354 WebRtcRTPHeader rtp_header = {}; | 370 WebRtcRTPHeader rtp_header = {}; |
355 rtp_header.header = header; | 371 rtp_header.header = header; |
356 rtp_header.header.payloadType = last_media_payload_type; | 372 rtp_header.header.payloadType = last_media_payload_type; |
357 rtp_header.header.paddingLength = 0; | 373 rtp_header.header.paddingLength = 0; |
358 PayloadUnion payload_specific; | 374 PayloadUnion payload_specific; |
359 if (!rtp_payload_registry_.GetPayloadSpecifics(last_media_payload_type, | 375 if (!rtp_payload_registry_.GetPayloadSpecifics(last_media_payload_type, |
360 &payload_specific)) { | 376 &payload_specific)) { |
361 LOG(LS_WARNING) << "Failed to get payload specifics."; | 377 LOG(LS_WARNING) << "Failed to get payload specifics."; |
362 return; | 378 return; |
363 } | 379 } |
364 rtp_header.type.Video.codec = payload_specific.Video.videoCodecType; | 380 rtp_header.type.Video.codec = payload_specific.Video.videoCodecType; |
365 rtp_header.type.Video.rotation = kVideoRotation_0; | 381 rtp_header.type.Video.rotation = kVideoRotation_0; |
366 if (header.extension.hasVideoRotation) { | 382 if (header.extension.hasVideoRotation) { |
367 rtp_header.type.Video.rotation = | 383 rtp_header.type.Video.rotation = |
368 ConvertCVOByteToVideoRotation(header.extension.videoRotation); | 384 ConvertCVOByteToVideoRotation(header.extension.videoRotation); |
369 } | 385 } |
370 OnReceivedPayloadData(nullptr, 0, &rtp_header); | 386 OnReceivedPayloadData(nullptr, 0, &rtp_header); |
371 } | 387 } |
372 | 388 |
373 bool ViEReceiver::DeliverRtcp(const uint8_t* rtcp_packet, | 389 bool RtpStreamReceiver::DeliverRtcp(const uint8_t* rtcp_packet, |
374 size_t rtcp_packet_length) { | 390 size_t rtcp_packet_length) { |
375 { | 391 { |
376 rtc::CritScope lock(&receive_cs_); | 392 rtc::CritScope lock(&receive_cs_); |
377 if (!receiving_) { | 393 if (!receiving_) { |
378 return false; | 394 return false; |
379 } | 395 } |
380 } | 396 } |
381 | 397 |
382 rtp_rtcp_->IncomingRtcpPacket(rtcp_packet, rtcp_packet_length); | 398 rtp_rtcp_->IncomingRtcpPacket(rtcp_packet, rtcp_packet_length); |
383 | 399 |
384 int64_t rtt = 0; | 400 int64_t rtt = 0; |
385 rtp_rtcp_->RTT(rtp_receiver_->SSRC(), &rtt, nullptr, nullptr, nullptr); | 401 rtp_rtcp_->RTT(rtp_receiver_->SSRC(), &rtt, nullptr, nullptr, nullptr); |
386 if (rtt == 0) { | 402 if (rtt == 0) { |
387 // Waiting for valid rtt. | 403 // Waiting for valid rtt. |
388 return true; | 404 return true; |
389 } | 405 } |
390 uint32_t ntp_secs = 0; | 406 uint32_t ntp_secs = 0; |
391 uint32_t ntp_frac = 0; | 407 uint32_t ntp_frac = 0; |
392 uint32_t rtp_timestamp = 0; | 408 uint32_t rtp_timestamp = 0; |
393 if (rtp_rtcp_->RemoteNTP(&ntp_secs, &ntp_frac, nullptr, nullptr, | 409 if (rtp_rtcp_->RemoteNTP(&ntp_secs, &ntp_frac, nullptr, nullptr, |
394 &rtp_timestamp) != 0) { | 410 &rtp_timestamp) != 0) { |
395 // Waiting for RTCP. | 411 // Waiting for RTCP. |
396 return true; | 412 return true; |
397 } | 413 } |
398 ntp_estimator_.UpdateRtcpTimestamp(rtt, ntp_secs, ntp_frac, rtp_timestamp); | 414 ntp_estimator_.UpdateRtcpTimestamp(rtt, ntp_secs, ntp_frac, rtp_timestamp); |
399 | 415 |
400 return true; | 416 return true; |
401 } | 417 } |
402 | 418 |
403 void ViEReceiver::StartReceive() { | 419 void RtpStreamReceiver::StartReceive() { |
404 rtc::CritScope lock(&receive_cs_); | 420 rtc::CritScope lock(&receive_cs_); |
405 receiving_ = true; | 421 receiving_ = true; |
406 } | 422 } |
407 | 423 |
408 void ViEReceiver::StopReceive() { | 424 void RtpStreamReceiver::StopReceive() { |
409 rtc::CritScope lock(&receive_cs_); | 425 rtc::CritScope lock(&receive_cs_); |
410 receiving_ = false; | 426 receiving_ = false; |
411 } | 427 } |
412 | 428 |
413 ReceiveStatistics* ViEReceiver::GetReceiveStatistics() const { | 429 ReceiveStatistics* RtpStreamReceiver::GetReceiveStatistics() const { |
414 return rtp_receive_statistics_.get(); | 430 return rtp_receive_statistics_.get(); |
415 } | 431 } |
416 | 432 |
417 bool ViEReceiver::IsPacketInOrder(const RTPHeader& header) const { | 433 bool RtpStreamReceiver::IsPacketInOrder(const RTPHeader& header) const { |
418 StreamStatistician* statistician = | 434 StreamStatistician* statistician = |
419 rtp_receive_statistics_->GetStatistician(header.ssrc); | 435 rtp_receive_statistics_->GetStatistician(header.ssrc); |
420 if (!statistician) | 436 if (!statistician) |
421 return false; | 437 return false; |
422 return statistician->IsPacketInOrder(header.sequenceNumber); | 438 return statistician->IsPacketInOrder(header.sequenceNumber); |
423 } | 439 } |
424 | 440 |
425 bool ViEReceiver::IsPacketRetransmitted(const RTPHeader& header, | 441 bool RtpStreamReceiver::IsPacketRetransmitted(const RTPHeader& header, |
426 bool in_order) const { | 442 bool in_order) const { |
427 // Retransmissions are handled separately if RTX is enabled. | 443 // Retransmissions are handled separately if RTX is enabled. |
428 if (rtp_payload_registry_.RtxEnabled()) | 444 if (rtp_payload_registry_.RtxEnabled()) |
429 return false; | 445 return false; |
430 StreamStatistician* statistician = | 446 StreamStatistician* statistician = |
431 rtp_receive_statistics_->GetStatistician(header.ssrc); | 447 rtp_receive_statistics_->GetStatistician(header.ssrc); |
432 if (!statistician) | 448 if (!statistician) |
433 return false; | 449 return false; |
434 // Check if this is a retransmission. | 450 // Check if this is a retransmission. |
435 int64_t min_rtt = 0; | 451 int64_t min_rtt = 0; |
436 rtp_rtcp_->RTT(rtp_receiver_->SSRC(), nullptr, nullptr, &min_rtt, nullptr); | 452 rtp_rtcp_->RTT(rtp_receiver_->SSRC(), nullptr, nullptr, &min_rtt, nullptr); |
437 return !in_order && | 453 return !in_order && |
438 statistician->IsRetransmitOfOldPacket(header, min_rtt); | 454 statistician->IsRetransmitOfOldPacket(header, min_rtt); |
439 } | 455 } |
440 } // namespace webrtc | 456 } // namespace webrtc |
OLD | NEW |