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 168 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
179 } | 179 } |
180 | 180 |
181 if (config_.rtp.rtcp_xr.receiver_reference_time_report) | 181 if (config_.rtp.rtcp_xr.receiver_reference_time_report) |
182 rtp_rtcp_->SetRtcpXrRrtrStatus(true); | 182 rtp_rtcp_->SetRtcpXrRrtrStatus(true); |
183 | 183 |
184 // Stats callback for CNAME changes. | 184 // Stats callback for CNAME changes. |
185 rtp_rtcp_->RegisterRtcpStatisticsCallback(receive_stats_proxy); | 185 rtp_rtcp_->RegisterRtcpStatisticsCallback(receive_stats_proxy); |
186 | 186 |
187 process_thread_->RegisterModule(rtp_rtcp_.get()); | 187 process_thread_->RegisterModule(rtp_rtcp_.get()); |
188 | 188 |
189 nack_module_.reset( | 189 if (config_.rtp.nack.rtp_history_ms != 0) { |
190 new NackModule(clock_, nack_sender, keyframe_request_sender)); | 190 nack_module_.reset( |
191 if (config_.rtp.nack.rtp_history_ms == 0) | 191 new NackModule(clock_, nack_sender, keyframe_request_sender)); |
192 nack_module_->Stop(); | 192 process_thread_->RegisterModule(nack_module_.get()); |
193 process_thread_->RegisterModule(nack_module_.get()); | 193 } |
194 | 194 |
195 packet_buffer_ = video_coding::PacketBuffer::Create( | 195 packet_buffer_ = video_coding::PacketBuffer::Create( |
196 clock_, kPacketBufferStartSize, kPacketBufferMaxSixe, this); | 196 clock_, kPacketBufferStartSize, kPacketBufferMaxSixe, this); |
197 reference_finder_.reset(new video_coding::RtpFrameReferenceFinder(this)); | 197 reference_finder_.reset(new video_coding::RtpFrameReferenceFinder(this)); |
198 } | 198 } |
199 | 199 |
200 RtpStreamReceiver::~RtpStreamReceiver() { | 200 RtpStreamReceiver::~RtpStreamReceiver() { |
201 if (nack_module_) { | |
202 process_thread_->DeRegisterModule(nack_module_.get()); | |
203 } | |
204 | |
201 process_thread_->DeRegisterModule(rtp_rtcp_.get()); | 205 process_thread_->DeRegisterModule(rtp_rtcp_.get()); |
202 | 206 |
203 process_thread_->DeRegisterModule(nack_module_.get()); | |
204 | |
205 packet_router_->RemoveRtpModule(rtp_rtcp_.get()); | 207 packet_router_->RemoveRtpModule(rtp_rtcp_.get()); |
206 rtp_rtcp_->SetREMBStatus(false); | 208 rtp_rtcp_->SetREMBStatus(false); |
207 if (config_.rtp.remb) { | 209 if (config_.rtp.remb) { |
208 remb_->RemoveReceiveChannel(rtp_rtcp_.get()); | 210 remb_->RemoveReceiveChannel(rtp_rtcp_.get()); |
209 } | 211 } |
210 UpdateHistograms(); | 212 UpdateHistograms(); |
211 } | 213 } |
212 | 214 |
213 bool RtpStreamReceiver::AddReceiveCodec( | 215 bool RtpStreamReceiver::AddReceiveCodec( |
214 const VideoCodec& video_codec, | 216 const VideoCodec& video_codec, |
(...skipping 24 matching lines...) Expand all Loading... | |
239 } | 241 } |
240 | 242 |
241 int32_t RtpStreamReceiver::OnReceivedPayloadData( | 243 int32_t RtpStreamReceiver::OnReceivedPayloadData( |
242 const uint8_t* payload_data, | 244 const uint8_t* payload_data, |
243 size_t payload_size, | 245 size_t payload_size, |
244 const WebRtcRTPHeader* rtp_header) { | 246 const WebRtcRTPHeader* rtp_header) { |
245 WebRtcRTPHeader rtp_header_with_ntp = *rtp_header; | 247 WebRtcRTPHeader rtp_header_with_ntp = *rtp_header; |
246 rtp_header_with_ntp.ntp_time_ms = | 248 rtp_header_with_ntp.ntp_time_ms = |
247 ntp_estimator_.Estimate(rtp_header->header.timestamp); | 249 ntp_estimator_.Estimate(rtp_header->header.timestamp); |
248 VCMPacket packet(payload_data, payload_size, rtp_header_with_ntp); | 250 VCMPacket packet(payload_data, payload_size, rtp_header_with_ntp); |
249 packet.timesNacked = nack_module_->OnReceivedPacket(packet); | 251 packet.timesNacked = |
252 nack_module_ ? nack_module_->OnReceivedPacket(packet) : -1; | |
250 | 253 |
251 if (packet.codec == kVideoCodecH264) { | 254 if (packet.codec == kVideoCodecH264) { |
252 // Only when we start to receive packets will we know what payload type | 255 // Only when we start to receive packets will we know what payload type |
253 // that will be used. When we know the payload type insert the correct | 256 // that will be used. When we know the payload type insert the correct |
254 // sps/pps into the tracker. | 257 // sps/pps into the tracker. |
255 if (packet.payloadType != last_payload_type_) { | 258 if (packet.payloadType != last_payload_type_) { |
256 last_payload_type_ = packet.payloadType; | 259 last_payload_type_ = packet.payloadType; |
257 InsertSpsPpsIntoTracker(packet.payloadType); | 260 InsertSpsPpsIntoTracker(packet.payloadType); |
258 } | 261 } |
259 | 262 |
(...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
398 { | 401 { |
399 rtc::CritScope lock(&last_seq_num_cs_); | 402 rtc::CritScope lock(&last_seq_num_cs_); |
400 video_coding::RtpFrameObject* rtp_frame = | 403 video_coding::RtpFrameObject* rtp_frame = |
401 static_cast<video_coding::RtpFrameObject*>(frame.get()); | 404 static_cast<video_coding::RtpFrameObject*>(frame.get()); |
402 last_seq_num_for_pic_id_[rtp_frame->picture_id] = rtp_frame->last_seq_num(); | 405 last_seq_num_for_pic_id_[rtp_frame->picture_id] = rtp_frame->last_seq_num(); |
403 } | 406 } |
404 complete_frame_callback_->OnCompleteFrame(std::move(frame)); | 407 complete_frame_callback_->OnCompleteFrame(std::move(frame)); |
405 } | 408 } |
406 | 409 |
407 void RtpStreamReceiver::OnRttUpdate(int64_t avg_rtt_ms, int64_t max_rtt_ms) { | 410 void RtpStreamReceiver::OnRttUpdate(int64_t avg_rtt_ms, int64_t max_rtt_ms) { |
408 nack_module_->UpdateRtt(max_rtt_ms); | 411 if (nack_module_) |
412 nack_module_->UpdateRtt(max_rtt_ms); | |
409 } | 413 } |
410 | 414 |
411 // TODO(nisse): Drop return value. | 415 // TODO(nisse): Drop return value. |
412 bool RtpStreamReceiver::ReceivePacket(const uint8_t* packet, | 416 bool RtpStreamReceiver::ReceivePacket(const uint8_t* packet, |
413 size_t packet_length, | 417 size_t packet_length, |
414 const RTPHeader& header, | 418 const RTPHeader& header, |
415 bool in_order) { | 419 bool in_order) { |
416 if (rtp_payload_registry_.IsEncapsulated(header)) { | 420 if (rtp_payload_registry_.IsEncapsulated(header)) { |
417 return ParseAndHandleEncapsulatingHeader(packet, packet_length, header); | 421 return ParseAndHandleEncapsulatingHeader(packet, packet_length, header); |
418 } | 422 } |
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
526 if (rtp_rtcp_->RemoteNTP(&ntp_secs, &ntp_frac, nullptr, nullptr, | 530 if (rtp_rtcp_->RemoteNTP(&ntp_secs, &ntp_frac, nullptr, nullptr, |
527 &rtp_timestamp) != 0) { | 531 &rtp_timestamp) != 0) { |
528 // Waiting for RTCP. | 532 // Waiting for RTCP. |
529 return true; | 533 return true; |
530 } | 534 } |
531 ntp_estimator_.UpdateRtcpTimestamp(rtt, ntp_secs, ntp_frac, rtp_timestamp); | 535 ntp_estimator_.UpdateRtcpTimestamp(rtt, ntp_secs, ntp_frac, rtp_timestamp); |
532 | 536 |
533 return true; | 537 return true; |
534 } | 538 } |
535 | 539 |
536 void RtpStreamReceiver::FrameContinuous(uint16_t picture_id) { | 540 void RtpStreamReceiver::FrameContinuous(uint16_t picture_id) { |
philipel
2017/02/27 09:31:22
If |nack_module_| is null then we can return immed
tommi
2017/02/27 09:35:17
nice - done.
| |
537 int seq_num = -1; | 541 int seq_num = -1; |
538 { | 542 { |
539 rtc::CritScope lock(&last_seq_num_cs_); | 543 rtc::CritScope lock(&last_seq_num_cs_); |
540 auto seq_num_it = last_seq_num_for_pic_id_.find(picture_id); | 544 auto seq_num_it = last_seq_num_for_pic_id_.find(picture_id); |
541 if (seq_num_it != last_seq_num_for_pic_id_.end()) | 545 if (seq_num_it != last_seq_num_for_pic_id_.end()) |
542 seq_num = seq_num_it->second; | 546 seq_num = seq_num_it->second; |
543 } | 547 } |
544 if (seq_num != -1) | 548 if (seq_num != -1 && nack_module_) |
545 nack_module_->ClearUpTo(seq_num); | 549 nack_module_->ClearUpTo(seq_num); |
546 } | 550 } |
547 | 551 |
548 void RtpStreamReceiver::FrameDecoded(uint16_t picture_id) { | 552 void RtpStreamReceiver::FrameDecoded(uint16_t picture_id) { |
549 int seq_num = -1; | 553 int seq_num = -1; |
550 { | 554 { |
551 rtc::CritScope lock(&last_seq_num_cs_); | 555 rtc::CritScope lock(&last_seq_num_cs_); |
552 auto seq_num_it = last_seq_num_for_pic_id_.find(picture_id); | 556 auto seq_num_it = last_seq_num_for_pic_id_.find(picture_id); |
553 if (seq_num_it != last_seq_num_for_pic_id_.end()) { | 557 if (seq_num_it != last_seq_num_for_pic_id_.end()) { |
554 seq_num = seq_num_it->second; | 558 seq_num = seq_num_it->second; |
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
649 return; | 653 return; |
650 | 654 |
651 if (!sprop_decoder.DecodeSprop(sprop_base64_it->second.c_str())) | 655 if (!sprop_decoder.DecodeSprop(sprop_base64_it->second.c_str())) |
652 return; | 656 return; |
653 | 657 |
654 tracker_.InsertSpsPpsNalus(sprop_decoder.sps_nalu(), | 658 tracker_.InsertSpsPpsNalus(sprop_decoder.sps_nalu(), |
655 sprop_decoder.pps_nalu()); | 659 sprop_decoder.pps_nalu()); |
656 } | 660 } |
657 | 661 |
658 } // namespace webrtc | 662 } // namespace webrtc |
OLD | NEW |