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

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

Issue 2928123002: Use the configured remote ssrc instead of relying on the first received packet. (Closed)
Patch Set: rebase Created 3 years, 6 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/rtp_video_stream_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
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after
120 RTC_DCHECK(config_.rtp.rtcp_mode != RtcpMode::kOff) 120 RTC_DCHECK(config_.rtp.rtcp_mode != RtcpMode::kOff)
121 << "A stream should not be configured with RTCP disabled. This value is " 121 << "A stream should not be configured with RTCP disabled. This value is "
122 "reserved for internal usage."; 122 "reserved for internal usage.";
123 RTC_DCHECK(config_.rtp.remote_ssrc != 0); 123 RTC_DCHECK(config_.rtp.remote_ssrc != 0);
124 // TODO(pbos): What's an appropriate local_ssrc for receive-only streams? 124 // TODO(pbos): What's an appropriate local_ssrc for receive-only streams?
125 RTC_DCHECK(config_.rtp.local_ssrc != 0); 125 RTC_DCHECK(config_.rtp.local_ssrc != 0);
126 RTC_DCHECK(config_.rtp.remote_ssrc != config_.rtp.local_ssrc); 126 RTC_DCHECK(config_.rtp.remote_ssrc != config_.rtp.local_ssrc);
127 127
128 rtp_rtcp_->SetRTCPStatus(config_.rtp.rtcp_mode); 128 rtp_rtcp_->SetRTCPStatus(config_.rtp.rtcp_mode);
129 rtp_rtcp_->SetSSRC(config_.rtp.local_ssrc); 129 rtp_rtcp_->SetSSRC(config_.rtp.local_ssrc);
130 rtp_rtcp_->SetRemoteSSRC(config_.rtp.remote_ssrc);
130 rtp_rtcp_->SetKeyFrameRequestMethod(kKeyFrameReqPliRtcp); 131 rtp_rtcp_->SetKeyFrameRequestMethod(kKeyFrameReqPliRtcp);
131 132
132 for (size_t i = 0; i < config_.rtp.extensions.size(); ++i) { 133 for (size_t i = 0; i < config_.rtp.extensions.size(); ++i) {
133 EnableReceiveRtpHeaderExtension(config_.rtp.extensions[i].uri, 134 EnableReceiveRtpHeaderExtension(config_.rtp.extensions[i].uri,
134 config_.rtp.extensions[i].id); 135 config_.rtp.extensions[i].id);
135 } 136 }
136 137
137 static const int kMaxPacketAgeToNack = 450; 138 static const int kMaxPacketAgeToNack = 450;
138 const int max_reordering_threshold = (config_.rtp.nack.rtp_history_ms > 0) 139 const int max_reordering_threshold = (config_.rtp.nack.rtp_history_ms > 0)
139 ? kMaxPacketAgeToNack 140 ? kMaxPacketAgeToNack
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
210 bool RtpVideoStreamReceiver::AddReceiveCodec(const VideoCodec& video_codec) { 211 bool RtpVideoStreamReceiver::AddReceiveCodec(const VideoCodec& video_codec) {
211 int8_t old_pltype = -1; 212 int8_t old_pltype = -1;
212 if (rtp_payload_registry_.ReceivePayloadType(video_codec, &old_pltype) != 213 if (rtp_payload_registry_.ReceivePayloadType(video_codec, &old_pltype) !=
213 -1) { 214 -1) {
214 rtp_payload_registry_.DeRegisterReceivePayload(old_pltype); 215 rtp_payload_registry_.DeRegisterReceivePayload(old_pltype);
215 } 216 }
216 return rtp_payload_registry_.RegisterReceivePayload(video_codec) == 0; 217 return rtp_payload_registry_.RegisterReceivePayload(video_codec) == 0;
217 } 218 }
218 219
219 uint32_t RtpVideoStreamReceiver::GetRemoteSsrc() const { 220 uint32_t RtpVideoStreamReceiver::GetRemoteSsrc() const {
220 return rtp_receiver_->SSRC(); 221 return config_.rtp.remote_ssrc;
221 } 222 }
222 223
223 int RtpVideoStreamReceiver::GetCsrcs(uint32_t* csrcs) const { 224 int RtpVideoStreamReceiver::GetCsrcs(uint32_t* csrcs) const {
224 return rtp_receiver_->CSRCs(csrcs); 225 return rtp_receiver_->CSRCs(csrcs);
225 } 226 }
226 227
227 RtpReceiver* RtpVideoStreamReceiver::GetRtpReceiver() const { 228 RtpReceiver* RtpVideoStreamReceiver::GetRtpReceiver() const {
228 return rtp_receiver_.get(); 229 return rtp_receiver_.get();
229 } 230 }
230 231
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
295 int32_t RtpVideoStreamReceiver::OnInitializeDecoder( 296 int32_t RtpVideoStreamReceiver::OnInitializeDecoder(
296 const int8_t payload_type, 297 const int8_t payload_type,
297 const char payload_name[RTP_PAYLOAD_NAME_SIZE], 298 const char payload_name[RTP_PAYLOAD_NAME_SIZE],
298 const int frequency, 299 const int frequency,
299 const size_t channels, 300 const size_t channels,
300 const uint32_t rate) { 301 const uint32_t rate) {
301 RTC_NOTREACHED(); 302 RTC_NOTREACHED();
302 return 0; 303 return 0;
303 } 304 }
304 305
305 void RtpVideoStreamReceiver::OnIncomingSSRCChanged(const uint32_t ssrc) {
306 rtp_rtcp_->SetRemoteSSRC(ssrc);
307 }
308
309 // This method handles both regular RTP packets and packets recovered 306 // This method handles both regular RTP packets and packets recovered
310 // via FlexFEC. 307 // via FlexFEC.
311 void RtpVideoStreamReceiver::OnRtpPacket(const RtpPacketReceived& packet) { 308 void RtpVideoStreamReceiver::OnRtpPacket(const RtpPacketReceived& packet) {
312 { 309 {
313 rtc::CritScope lock(&receive_cs_); 310 rtc::CritScope lock(&receive_cs_);
314 if (!receiving_) { 311 if (!receiving_) {
315 return; 312 return;
316 } 313 }
317 314
318 if (!packet.recovered()) { 315 if (!packet.recovered()) {
(...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after
474 if (packet_length < header.headerLength) 471 if (packet_length < header.headerLength)
475 return; 472 return;
476 if (packet_length > sizeof(restored_packet_)) 473 if (packet_length > sizeof(restored_packet_))
477 return; 474 return;
478 rtc::CritScope lock(&receive_cs_); 475 rtc::CritScope lock(&receive_cs_);
479 if (restored_packet_in_use_) { 476 if (restored_packet_in_use_) {
480 LOG(LS_WARNING) << "Multiple RTX headers detected, dropping packet."; 477 LOG(LS_WARNING) << "Multiple RTX headers detected, dropping packet.";
481 return; 478 return;
482 } 479 }
483 if (!rtp_payload_registry_.RestoreOriginalPacket( 480 if (!rtp_payload_registry_.RestoreOriginalPacket(
484 restored_packet_, packet, &packet_length, rtp_receiver_->SSRC(), 481 restored_packet_, packet, &packet_length, config_.rtp.remote_ssrc,
485 header)) { 482 header)) {
486 LOG(LS_WARNING) << "Incoming RTX packet: Invalid RTP header ssrc: " 483 LOG(LS_WARNING) << "Incoming RTX packet: Invalid RTP header ssrc: "
487 << header.ssrc << " payload type: " 484 << header.ssrc << " payload type: "
488 << static_cast<int>(header.payloadType); 485 << static_cast<int>(header.payloadType);
489 return; 486 return;
490 } 487 }
491 restored_packet_in_use_ = true; 488 restored_packet_in_use_ = true;
492 OnRecoveredPacket(restored_packet_, packet_length); 489 OnRecoveredPacket(restored_packet_, packet_length);
493 restored_packet_in_use_ = false; 490 restored_packet_in_use_ = false;
494 } 491 }
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after
616 bool in_order) const { 613 bool in_order) const {
617 // Retransmissions are handled separately if RTX is enabled. 614 // Retransmissions are handled separately if RTX is enabled.
618 if (rtp_payload_registry_.RtxEnabled()) 615 if (rtp_payload_registry_.RtxEnabled())
619 return false; 616 return false;
620 StreamStatistician* statistician = 617 StreamStatistician* statistician =
621 rtp_receive_statistics_->GetStatistician(header.ssrc); 618 rtp_receive_statistics_->GetStatistician(header.ssrc);
622 if (!statistician) 619 if (!statistician)
623 return false; 620 return false;
624 // Check if this is a retransmission. 621 // Check if this is a retransmission.
625 int64_t min_rtt = 0; 622 int64_t min_rtt = 0;
626 rtp_rtcp_->RTT(rtp_receiver_->SSRC(), nullptr, nullptr, &min_rtt, nullptr); 623 rtp_rtcp_->RTT(config_.rtp.remote_ssrc, nullptr, nullptr, &min_rtt, nullptr);
627 return !in_order && 624 return !in_order &&
628 statistician->IsRetransmitOfOldPacket(header, min_rtt); 625 statistician->IsRetransmitOfOldPacket(header, min_rtt);
629 } 626 }
630 627
631 void RtpVideoStreamReceiver::UpdateHistograms() { 628 void RtpVideoStreamReceiver::UpdateHistograms() {
632 FecPacketCounter counter = ulpfec_receiver_->GetPacketCounter(); 629 FecPacketCounter counter = ulpfec_receiver_->GetPacketCounter();
633 if (counter.first_packet_time_ms == -1) 630 if (counter.first_packet_time_ms == -1)
634 return; 631 return;
635 632
636 int64_t elapsed_sec = 633 int64_t elapsed_sec =
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
676 return; 673 return;
677 674
678 if (!sprop_decoder.DecodeSprop(sprop_base64_it->second.c_str())) 675 if (!sprop_decoder.DecodeSprop(sprop_base64_it->second.c_str()))
679 return; 676 return;
680 677
681 tracker_.InsertSpsPpsNalus(sprop_decoder.sps_nalu(), 678 tracker_.InsertSpsPpsNalus(sprop_decoder.sps_nalu(),
682 sprop_decoder.pps_nalu()); 679 sprop_decoder.pps_nalu());
683 } 680 }
684 681
685 } // namespace webrtc 682 } // namespace webrtc
OLDNEW
« no previous file with comments | « webrtc/video/rtp_video_stream_receiver.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698