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 |
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
98 process_thread_(process_thread), | 98 process_thread_(process_thread), |
99 ntp_estimator_(clock_), | 99 ntp_estimator_(clock_), |
100 rtp_header_parser_(RtpHeaderParser::Create()), | 100 rtp_header_parser_(RtpHeaderParser::Create()), |
101 rtp_receiver_(RtpReceiver::CreateVideoReceiver(clock_, | 101 rtp_receiver_(RtpReceiver::CreateVideoReceiver(clock_, |
102 this, | 102 this, |
103 this, | 103 this, |
104 &rtp_payload_registry_)), | 104 &rtp_payload_registry_)), |
105 rtp_receive_statistics_(ReceiveStatistics::Create(clock_)), | 105 rtp_receive_statistics_(ReceiveStatistics::Create(clock_)), |
106 ulpfec_receiver_(UlpfecReceiver::Create(config->rtp.remote_ssrc, this)), | 106 ulpfec_receiver_(UlpfecReceiver::Create(config->rtp.remote_ssrc, this)), |
107 receiving_(false), | 107 receiving_(false), |
108 restored_packet_in_use_(false), | |
109 last_packet_log_ms_(-1), | 108 last_packet_log_ms_(-1), |
110 rtp_rtcp_(CreateRtpRtcpModule(rtp_receive_statistics_.get(), | 109 rtp_rtcp_(CreateRtpRtcpModule(rtp_receive_statistics_.get(), |
111 transport, | 110 transport, |
112 rtt_stats, | 111 rtt_stats, |
113 receive_stats_proxy, | 112 receive_stats_proxy, |
114 packet_router)), | 113 packet_router)), |
115 complete_frame_callback_(complete_frame_callback), | 114 complete_frame_callback_(complete_frame_callback), |
116 keyframe_request_sender_(keyframe_request_sender), | 115 keyframe_request_sender_(keyframe_request_sender), |
117 timing_(timing), | 116 timing_(timing), |
118 has_received_frame_(false) { | 117 has_received_frame_(false) { |
(...skipping 20 matching lines...) Expand all Loading... |
139 config_.rtp.extensions[i].id); | 138 config_.rtp.extensions[i].id); |
140 } | 139 } |
141 | 140 |
142 static const int kMaxPacketAgeToNack = 450; | 141 static const int kMaxPacketAgeToNack = 450; |
143 const int max_reordering_threshold = (config_.rtp.nack.rtp_history_ms > 0) | 142 const int max_reordering_threshold = (config_.rtp.nack.rtp_history_ms > 0) |
144 ? kMaxPacketAgeToNack | 143 ? kMaxPacketAgeToNack |
145 : kDefaultMaxReorderingThreshold; | 144 : kDefaultMaxReorderingThreshold; |
146 rtp_receive_statistics_->SetMaxReorderingThreshold(max_reordering_threshold); | 145 rtp_receive_statistics_->SetMaxReorderingThreshold(max_reordering_threshold); |
147 | 146 |
148 if (config_.rtp.rtx_ssrc) { | 147 if (config_.rtp.rtx_ssrc) { |
| 148 // Needed for rtp_payload_registry_.RtxEnabled(). |
149 rtp_payload_registry_.SetRtxSsrc(config_.rtp.rtx_ssrc); | 149 rtp_payload_registry_.SetRtxSsrc(config_.rtp.rtx_ssrc); |
150 | |
151 for (const auto& kv : config_.rtp.rtx_associated_payload_types) { | |
152 RTC_DCHECK_NE(kv.first, 0); | |
153 rtp_payload_registry_.SetRtxPayloadType(kv.first, kv.second); | |
154 } | |
155 } | 150 } |
156 | 151 |
157 if (IsUlpfecEnabled()) { | 152 if (IsUlpfecEnabled()) { |
158 VideoCodec ulpfec_codec = {}; | 153 VideoCodec ulpfec_codec = {}; |
159 ulpfec_codec.codecType = kVideoCodecULPFEC; | 154 ulpfec_codec.codecType = kVideoCodecULPFEC; |
160 strncpy(ulpfec_codec.plName, "ulpfec", sizeof(ulpfec_codec.plName)); | 155 strncpy(ulpfec_codec.plName, "ulpfec", sizeof(ulpfec_codec.plName)); |
161 ulpfec_codec.plType = config_.rtp.ulpfec.ulpfec_payload_type; | 156 ulpfec_codec.plType = config_.rtp.ulpfec.ulpfec_payload_type; |
162 RTC_CHECK(AddReceiveCodec(ulpfec_codec)); | 157 RTC_CHECK(AddReceiveCodec(ulpfec_codec)); |
163 } | 158 } |
164 | 159 |
165 if (IsRedEnabled()) { | 160 if (IsRedEnabled()) { |
166 VideoCodec red_codec = {}; | 161 VideoCodec red_codec = {}; |
167 red_codec.codecType = kVideoCodecRED; | 162 red_codec.codecType = kVideoCodecRED; |
168 strncpy(red_codec.plName, "red", sizeof(red_codec.plName)); | 163 strncpy(red_codec.plName, "red", sizeof(red_codec.plName)); |
169 red_codec.plType = config_.rtp.ulpfec.red_payload_type; | 164 red_codec.plType = config_.rtp.ulpfec.red_payload_type; |
170 RTC_CHECK(AddReceiveCodec(red_codec)); | 165 RTC_CHECK(AddReceiveCodec(red_codec)); |
171 if (config_.rtp.ulpfec.red_rtx_payload_type != -1) { | |
172 rtp_payload_registry_.SetRtxPayloadType( | |
173 config_.rtp.ulpfec.red_rtx_payload_type, | |
174 config_.rtp.ulpfec.red_payload_type); | |
175 } | |
176 } | 166 } |
177 | 167 |
178 if (config_.rtp.rtcp_xr.receiver_reference_time_report) | 168 if (config_.rtp.rtcp_xr.receiver_reference_time_report) |
179 rtp_rtcp_->SetRtcpXrRrtrStatus(true); | 169 rtp_rtcp_->SetRtcpXrRrtrStatus(true); |
180 | 170 |
181 // Stats callback for CNAME changes. | 171 // Stats callback for CNAME changes. |
182 rtp_rtcp_->RegisterRtcpStatisticsCallback(receive_stats_proxy); | 172 rtp_rtcp_->RegisterRtcpStatisticsCallback(receive_stats_proxy); |
183 | 173 |
184 process_thread_->RegisterModule(rtp_rtcp_.get(), RTC_FROM_HERE); | 174 process_thread_->RegisterModule(rtp_rtcp_.get(), RTC_FROM_HERE); |
185 | 175 |
(...skipping 302 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
488 // Notify video_receiver about received FEC packets to avoid NACKing these | 478 // Notify video_receiver about received FEC packets to avoid NACKing these |
489 // packets. | 479 // packets. |
490 NotifyReceiverOfFecPacket(header); | 480 NotifyReceiverOfFecPacket(header); |
491 } | 481 } |
492 if (ulpfec_receiver_->AddReceivedRedPacket(header, packet, packet_length, | 482 if (ulpfec_receiver_->AddReceivedRedPacket(header, packet, packet_length, |
493 ulpfec_pt) != 0) { | 483 ulpfec_pt) != 0) { |
494 return; | 484 return; |
495 } | 485 } |
496 ulpfec_receiver_->ProcessReceivedFec(); | 486 ulpfec_receiver_->ProcessReceivedFec(); |
497 } else if (rtp_payload_registry_.IsRtx(header)) { | 487 } else if (rtp_payload_registry_.IsRtx(header)) { |
498 if (header.headerLength + header.paddingLength == packet_length) { | 488 LOG(LS_WARNING) << "Unexpected RTX packet on media ssrc"; |
499 // This is an empty packet and should be silently dropped before trying to | |
500 // parse the RTX header. | |
501 return; | |
502 } | |
503 // Remove the RTX header and parse the original RTP header. | |
504 if (packet_length < header.headerLength) | |
505 return; | |
506 if (packet_length > sizeof(restored_packet_)) | |
507 return; | |
508 if (restored_packet_in_use_) { | |
509 LOG(LS_WARNING) << "Multiple RTX headers detected, dropping packet."; | |
510 return; | |
511 } | |
512 if (!rtp_payload_registry_.RestoreOriginalPacket( | |
513 restored_packet_, packet, &packet_length, config_.rtp.remote_ssrc, | |
514 header)) { | |
515 LOG(LS_WARNING) << "Incoming RTX packet: Invalid RTP header ssrc: " | |
516 << header.ssrc << " payload type: " | |
517 << static_cast<int>(header.payloadType); | |
518 return; | |
519 } | |
520 restored_packet_in_use_ = true; | |
521 OnRecoveredPacket(restored_packet_, packet_length); | |
522 restored_packet_in_use_ = false; | |
523 } | 489 } |
524 } | 490 } |
525 | 491 |
526 void RtpVideoStreamReceiver::NotifyReceiverOfFecPacket( | 492 void RtpVideoStreamReceiver::NotifyReceiverOfFecPacket( |
527 const RTPHeader& header) { | 493 const RTPHeader& header) { |
528 int8_t last_media_payload_type = | 494 int8_t last_media_payload_type = |
529 rtp_payload_registry_.last_received_media_payload_type(); | 495 rtp_payload_registry_.last_received_media_payload_type(); |
530 if (last_media_payload_type < 0) { | 496 if (last_media_payload_type < 0) { |
531 LOG(LS_WARNING) << "Failed to get last media payload type."; | 497 LOG(LS_WARNING) << "Failed to get last media payload type."; |
532 return; | 498 return; |
(...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
708 return; | 674 return; |
709 | 675 |
710 if (!sprop_decoder.DecodeSprop(sprop_base64_it->second.c_str())) | 676 if (!sprop_decoder.DecodeSprop(sprop_base64_it->second.c_str())) |
711 return; | 677 return; |
712 | 678 |
713 tracker_.InsertSpsPpsNalus(sprop_decoder.sps_nalu(), | 679 tracker_.InsertSpsPpsNalus(sprop_decoder.sps_nalu(), |
714 sprop_decoder.pps_nalu()); | 680 sprop_decoder.pps_nalu()); |
715 } | 681 } |
716 | 682 |
717 } // namespace webrtc | 683 } // namespace webrtc |
OLD | NEW |