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

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

Issue 2656983002: Revert of Make the new jitter buffer the default jitter buffer. (Closed)
Patch Set: Rebase Created 3 years, 10 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_stream_receiver.h ('k') | webrtc/video/rtp_stream_receiver_unittest.cc » ('j') | 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 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
74 rtp_rtcp->SetSendingStatus(false); 74 rtp_rtcp->SetSendingStatus(false);
75 rtp_rtcp->SetSendingMediaStatus(false); 75 rtp_rtcp->SetSendingMediaStatus(false);
76 rtp_rtcp->SetRTCPStatus(RtcpMode::kCompound); 76 rtp_rtcp->SetRTCPStatus(RtcpMode::kCompound);
77 77
78 return rtp_rtcp; 78 return rtp_rtcp;
79 } 79 }
80 80
81 static const int kPacketLogIntervalMs = 10000; 81 static const int kPacketLogIntervalMs = 10000;
82 82
83 RtpStreamReceiver::RtpStreamReceiver( 83 RtpStreamReceiver::RtpStreamReceiver(
84 vcm::VideoReceiver* video_receiver,
84 RemoteBitrateEstimator* remote_bitrate_estimator, 85 RemoteBitrateEstimator* remote_bitrate_estimator,
85 Transport* transport, 86 Transport* transport,
86 RtcpRttStats* rtt_stats, 87 RtcpRttStats* rtt_stats,
87 PacketRouter* packet_router, 88 PacketRouter* packet_router,
88 VieRemb* remb, 89 VieRemb* remb,
89 const VideoReceiveStream::Config* config, 90 const VideoReceiveStream::Config* config,
90 ReceiveStatisticsProxy* receive_stats_proxy, 91 ReceiveStatisticsProxy* receive_stats_proxy,
91 ProcessThread* process_thread, 92 ProcessThread* process_thread,
92 NackSender* nack_sender, 93 NackSender* nack_sender,
93 KeyFrameRequestSender* keyframe_request_sender, 94 KeyFrameRequestSender* keyframe_request_sender,
94 video_coding::OnCompleteFrameCallback* complete_frame_callback, 95 video_coding::OnCompleteFrameCallback* complete_frame_callback,
95 VCMTiming* timing) 96 VCMTiming* timing)
96 : clock_(Clock::GetRealTimeClock()), 97 : clock_(Clock::GetRealTimeClock()),
97 config_(*config), 98 config_(*config),
99 video_receiver_(video_receiver),
98 remote_bitrate_estimator_(remote_bitrate_estimator), 100 remote_bitrate_estimator_(remote_bitrate_estimator),
99 packet_router_(packet_router), 101 packet_router_(packet_router),
100 remb_(remb), 102 remb_(remb),
101 process_thread_(process_thread), 103 process_thread_(process_thread),
102 ntp_estimator_(clock_), 104 ntp_estimator_(clock_),
103 rtp_header_parser_(RtpHeaderParser::Create()), 105 rtp_header_parser_(RtpHeaderParser::Create()),
104 rtp_receiver_(RtpReceiver::CreateVideoReceiver(clock_, 106 rtp_receiver_(RtpReceiver::CreateVideoReceiver(clock_,
105 this, 107 this,
106 this, 108 this,
107 &rtp_payload_registry_)), 109 &rtp_payload_registry_)),
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
182 } 184 }
183 185
184 if (config_.rtp.rtcp_xr.receiver_reference_time_report) 186 if (config_.rtp.rtcp_xr.receiver_reference_time_report)
185 rtp_rtcp_->SetRtcpXrRrtrStatus(true); 187 rtp_rtcp_->SetRtcpXrRrtrStatus(true);
186 188
187 // Stats callback for CNAME changes. 189 // Stats callback for CNAME changes.
188 rtp_rtcp_->RegisterRtcpStatisticsCallback(receive_stats_proxy); 190 rtp_rtcp_->RegisterRtcpStatisticsCallback(receive_stats_proxy);
189 191
190 process_thread_->RegisterModule(rtp_rtcp_.get()); 192 process_thread_->RegisterModule(rtp_rtcp_.get());
191 193
192 nack_module_.reset( 194 jitter_buffer_experiment_ =
193 new NackModule(clock_, nack_sender, keyframe_request_sender)); 195 field_trial::FindFullName("WebRTC-NewVideoJitterBuffer") == "Enabled";
194 if (config_.rtp.nack.rtp_history_ms == 0)
195 nack_module_->Stop();
196 process_thread_->RegisterModule(nack_module_.get());
197 196
198 packet_buffer_ = video_coding::PacketBuffer::Create( 197 if (jitter_buffer_experiment_) {
199 clock_, kPacketBufferStartSize, kPacketBufferMaxSixe, this); 198 nack_module_.reset(
200 reference_finder_.reset(new video_coding::RtpFrameReferenceFinder(this)); 199 new NackModule(clock_, nack_sender, keyframe_request_sender));
200 process_thread_->RegisterModule(nack_module_.get());
201
202 packet_buffer_ = video_coding::PacketBuffer::Create(
203 clock_, kPacketBufferStartSize, kPacketBufferMaxSixe, this);
204 reference_finder_.reset(new video_coding::RtpFrameReferenceFinder(this));
205 }
201 } 206 }
202 207
203 RtpStreamReceiver::~RtpStreamReceiver() { 208 RtpStreamReceiver::~RtpStreamReceiver() {
204 process_thread_->DeRegisterModule(rtp_rtcp_.get()); 209 process_thread_->DeRegisterModule(rtp_rtcp_.get());
205 210
206 process_thread_->DeRegisterModule(nack_module_.get()); 211 if (jitter_buffer_experiment_)
212 process_thread_->DeRegisterModule(nack_module_.get());
207 213
208 packet_router_->RemoveRtpModule(rtp_rtcp_.get()); 214 packet_router_->RemoveRtpModule(rtp_rtcp_.get());
209 rtp_rtcp_->SetREMBStatus(false); 215 rtp_rtcp_->SetREMBStatus(false);
210 if (config_.rtp.remb) { 216 if (config_.rtp.remb) {
211 remb_->RemoveReceiveChannel(rtp_rtcp_.get()); 217 remb_->RemoveReceiveChannel(rtp_rtcp_.get());
212 } 218 }
213 UpdateHistograms(); 219 UpdateHistograms();
214 } 220 }
215 221
216 bool RtpStreamReceiver::AddReceiveCodec( 222 bool RtpStreamReceiver::AddReceiveCodec(
(...skipping 24 matching lines...) Expand all
241 return rtp_receiver_.get(); 247 return rtp_receiver_.get();
242 } 248 }
243 249
244 int32_t RtpStreamReceiver::OnReceivedPayloadData( 250 int32_t RtpStreamReceiver::OnReceivedPayloadData(
245 const uint8_t* payload_data, 251 const uint8_t* payload_data,
246 size_t payload_size, 252 size_t payload_size,
247 const WebRtcRTPHeader* rtp_header) { 253 const WebRtcRTPHeader* rtp_header) {
248 WebRtcRTPHeader rtp_header_with_ntp = *rtp_header; 254 WebRtcRTPHeader rtp_header_with_ntp = *rtp_header;
249 rtp_header_with_ntp.ntp_time_ms = 255 rtp_header_with_ntp.ntp_time_ms =
250 ntp_estimator_.Estimate(rtp_header->header.timestamp); 256 ntp_estimator_.Estimate(rtp_header->header.timestamp);
251 VCMPacket packet(payload_data, payload_size, rtp_header_with_ntp); 257 if (jitter_buffer_experiment_) {
252 timing_->IncomingTimestamp(packet.timestamp, clock_->TimeInMilliseconds()); 258 VCMPacket packet(payload_data, payload_size, rtp_header_with_ntp);
253 packet.timesNacked = nack_module_->OnReceivedPacket(packet); 259 timing_->IncomingTimestamp(packet.timestamp, clock_->TimeInMilliseconds());
260 packet.timesNacked = nack_module_->OnReceivedPacket(packet);
254 261
255 if (packet.codec == kVideoCodecH264) { 262 if (packet.codec == kVideoCodecH264) {
256 // Only when we start to receive packets will we know what payload type 263 // Only when we start to receive packets will we know what payload type
257 // that will be used. When we know the payload type insert the correct 264 // that will be used. When we know the payload type insert the correct
258 // sps/pps into the tracker. 265 // sps/pps into the tracker.
259 if (packet.payloadType != last_payload_type_) { 266 if (packet.payloadType != last_payload_type_) {
260 last_payload_type_ = packet.payloadType; 267 last_payload_type_ = packet.payloadType;
261 InsertSpsPpsIntoTracker(packet.payloadType); 268 InsertSpsPpsIntoTracker(packet.payloadType);
269 }
270
271 switch (tracker_.CopyAndFixBitstream(&packet)) {
272 case video_coding::H264SpsPpsTracker::kRequestKeyframe:
273 keyframe_request_sender_->RequestKeyFrame();
274 FALLTHROUGH();
275 case video_coding::H264SpsPpsTracker::kDrop:
276 return 0;
277 case video_coding::H264SpsPpsTracker::kInsert:
278 break;
279 }
280 } else {
281 uint8_t* data = new uint8_t[packet.sizeBytes];
282 memcpy(data, packet.dataPtr, packet.sizeBytes);
283 packet.dataPtr = data;
262 } 284 }
263 285
264 switch (tracker_.CopyAndFixBitstream(&packet)) { 286 packet_buffer_->InsertPacket(&packet);
265 case video_coding::H264SpsPpsTracker::kRequestKeyframe: 287 } else {
266 keyframe_request_sender_->RequestKeyFrame(); 288 RTC_DCHECK(video_receiver_);
267 FALLTHROUGH(); 289 if (video_receiver_->IncomingPacket(payload_data, payload_size,
268 case video_coding::H264SpsPpsTracker::kDrop: 290 rtp_header_with_ntp) != 0) {
269 return 0; 291 // Check this...
270 case video_coding::H264SpsPpsTracker::kInsert: 292 return -1;
271 break;
272 } 293 }
273
274 } else {
275 uint8_t* data = new uint8_t[packet.sizeBytes];
276 memcpy(data, packet.dataPtr, packet.sizeBytes);
277 packet.dataPtr = data;
278 } 294 }
279
280 packet_buffer_->InsertPacket(&packet);
281 return 0; 295 return 0;
282 } 296 }
283 297
284 bool RtpStreamReceiver::OnRecoveredPacket(const uint8_t* rtp_packet, 298 bool RtpStreamReceiver::OnRecoveredPacket(const uint8_t* rtp_packet,
285 size_t rtp_packet_length) { 299 size_t rtp_packet_length) {
286 RTPHeader header; 300 RTPHeader header;
287 if (!rtp_header_parser_->Parse(rtp_packet, rtp_packet_length, &header)) { 301 if (!rtp_header_parser_->Parse(rtp_packet, rtp_packet_length, &header)) {
288 return false; 302 return false;
289 } 303 }
290 header.payload_type_frequency = kVideoPayloadTypeFrequency; 304 header.payload_type_frequency = kVideoPayloadTypeFrequency;
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after
407 { 421 {
408 rtc::CritScope lock(&last_seq_num_cs_); 422 rtc::CritScope lock(&last_seq_num_cs_);
409 video_coding::RtpFrameObject* rtp_frame = 423 video_coding::RtpFrameObject* rtp_frame =
410 static_cast<video_coding::RtpFrameObject*>(frame.get()); 424 static_cast<video_coding::RtpFrameObject*>(frame.get());
411 last_seq_num_for_pic_id_[rtp_frame->picture_id] = rtp_frame->last_seq_num(); 425 last_seq_num_for_pic_id_[rtp_frame->picture_id] = rtp_frame->last_seq_num();
412 } 426 }
413 complete_frame_callback_->OnCompleteFrame(std::move(frame)); 427 complete_frame_callback_->OnCompleteFrame(std::move(frame));
414 } 428 }
415 429
416 void RtpStreamReceiver::OnRttUpdate(int64_t avg_rtt_ms, int64_t max_rtt_ms) { 430 void RtpStreamReceiver::OnRttUpdate(int64_t avg_rtt_ms, int64_t max_rtt_ms) {
417 nack_module_->UpdateRtt(max_rtt_ms); 431 if (jitter_buffer_experiment_)
432 nack_module_->UpdateRtt(max_rtt_ms);
418 } 433 }
419 434
420 bool RtpStreamReceiver::ReceivePacket(const uint8_t* packet, 435 bool RtpStreamReceiver::ReceivePacket(const uint8_t* packet,
421 size_t packet_length, 436 size_t packet_length,
422 const RTPHeader& header, 437 const RTPHeader& header,
423 bool in_order) { 438 bool in_order) {
424 if (rtp_payload_registry_.IsEncapsulated(header)) { 439 if (rtp_payload_registry_.IsEncapsulated(header)) {
425 return ParseAndHandleEncapsulatingHeader(packet, packet_length, header); 440 return ParseAndHandleEncapsulatingHeader(packet, packet_length, header);
426 } 441 }
427 const uint8_t* payload = packet + header.headerLength; 442 const uint8_t* payload = packet + header.headerLength;
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after
535 &rtp_timestamp) != 0) { 550 &rtp_timestamp) != 0) {
536 // Waiting for RTCP. 551 // Waiting for RTCP.
537 return true; 552 return true;
538 } 553 }
539 ntp_estimator_.UpdateRtcpTimestamp(rtt, ntp_secs, ntp_frac, rtp_timestamp); 554 ntp_estimator_.UpdateRtcpTimestamp(rtt, ntp_secs, ntp_frac, rtp_timestamp);
540 555
541 return true; 556 return true;
542 } 557 }
543 558
544 void RtpStreamReceiver::FrameContinuous(uint16_t picture_id) { 559 void RtpStreamReceiver::FrameContinuous(uint16_t picture_id) {
545 int seq_num = -1; 560 if (jitter_buffer_experiment_) {
546 { 561 int seq_num = -1;
547 rtc::CritScope lock(&last_seq_num_cs_); 562 {
548 auto seq_num_it = last_seq_num_for_pic_id_.find(picture_id); 563 rtc::CritScope lock(&last_seq_num_cs_);
549 if (seq_num_it != last_seq_num_for_pic_id_.end()) 564 auto seq_num_it = last_seq_num_for_pic_id_.find(picture_id);
550 seq_num = seq_num_it->second; 565 if (seq_num_it != last_seq_num_for_pic_id_.end())
566 seq_num = seq_num_it->second;
567 }
568 if (seq_num != -1)
569 nack_module_->ClearUpTo(seq_num);
551 } 570 }
552 if (seq_num != -1)
553 nack_module_->ClearUpTo(seq_num);
554 } 571 }
555 572
556 void RtpStreamReceiver::FrameDecoded(uint16_t picture_id) { 573 void RtpStreamReceiver::FrameDecoded(uint16_t picture_id) {
557 int seq_num = -1; 574 if (jitter_buffer_experiment_) {
558 { 575 int seq_num = -1;
559 rtc::CritScope lock(&last_seq_num_cs_); 576 {
560 auto seq_num_it = last_seq_num_for_pic_id_.find(picture_id); 577 rtc::CritScope lock(&last_seq_num_cs_);
561 if (seq_num_it != last_seq_num_for_pic_id_.end()) { 578 auto seq_num_it = last_seq_num_for_pic_id_.find(picture_id);
562 seq_num = seq_num_it->second; 579 if (seq_num_it != last_seq_num_for_pic_id_.end()) {
563 last_seq_num_for_pic_id_.erase(last_seq_num_for_pic_id_.begin(), 580 seq_num = seq_num_it->second;
564 ++seq_num_it); 581 last_seq_num_for_pic_id_.erase(last_seq_num_for_pic_id_.begin(),
582 ++seq_num_it);
583 }
565 } 584 }
566 } 585 if (seq_num != -1) {
567 if (seq_num != -1) { 586 packet_buffer_->ClearTo(seq_num);
568 packet_buffer_->ClearTo(seq_num); 587 reference_finder_->ClearTo(seq_num);
569 reference_finder_->ClearTo(seq_num); 588 }
570 } 589 }
571 } 590 }
572 591
573 void RtpStreamReceiver::SignalNetworkState(NetworkState state) { 592 void RtpStreamReceiver::SignalNetworkState(NetworkState state) {
574 rtp_rtcp_->SetRTCPStatus(state == kNetworkUp ? config_.rtp.rtcp_mode 593 rtp_rtcp_->SetRTCPStatus(state == kNetworkUp ? config_.rtp.rtcp_mode
575 : RtcpMode::kOff); 594 : RtcpMode::kOff);
576 } 595 }
577 596
578 void RtpStreamReceiver::StartReceive() { 597 void RtpStreamReceiver::StartReceive() {
579 rtc::CritScope lock(&receive_cs_); 598 rtc::CritScope lock(&receive_cs_);
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
657 return; 676 return;
658 677
659 if (!sprop_decoder.DecodeSprop(sprop_base64_it->second.c_str())) 678 if (!sprop_decoder.DecodeSprop(sprop_base64_it->second.c_str()))
660 return; 679 return;
661 680
662 tracker_.InsertSpsPpsNalus(sprop_decoder.sps_nalu(), 681 tracker_.InsertSpsPpsNalus(sprop_decoder.sps_nalu(),
663 sprop_decoder.pps_nalu()); 682 sprop_decoder.pps_nalu());
664 } 683 }
665 684
666 } // namespace webrtc 685 } // namespace webrtc
OLDNEW
« no previous file with comments | « webrtc/video/rtp_stream_receiver.h ('k') | webrtc/video/rtp_stream_receiver_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698