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

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

Issue 2682073003: Revert Make the new jitter buffer the default jitter buffer. (Closed)
Patch Set: 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 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
73 rtp_rtcp->SetSendingStatus(false); 73 rtp_rtcp->SetSendingStatus(false);
74 rtp_rtcp->SetSendingMediaStatus(false); 74 rtp_rtcp->SetSendingMediaStatus(false);
75 rtp_rtcp->SetRTCPStatus(RtcpMode::kCompound); 75 rtp_rtcp->SetRTCPStatus(RtcpMode::kCompound);
76 76
77 return rtp_rtcp; 77 return rtp_rtcp;
78 } 78 }
79 79
80 static const int kPacketLogIntervalMs = 10000; 80 static const int kPacketLogIntervalMs = 10000;
81 81
82 RtpStreamReceiver::RtpStreamReceiver( 82 RtpStreamReceiver::RtpStreamReceiver(
83 vcm::VideoReceiver* video_receiver,
83 Transport* transport, 84 Transport* transport,
84 RtcpRttStats* rtt_stats, 85 RtcpRttStats* rtt_stats,
85 PacketRouter* packet_router, 86 PacketRouter* packet_router,
86 VieRemb* remb, 87 VieRemb* remb,
87 const VideoReceiveStream::Config* config, 88 const VideoReceiveStream::Config* config,
88 ReceiveStatisticsProxy* receive_stats_proxy, 89 ReceiveStatisticsProxy* receive_stats_proxy,
89 ProcessThread* process_thread, 90 ProcessThread* process_thread,
90 NackSender* nack_sender, 91 NackSender* nack_sender,
91 KeyFrameRequestSender* keyframe_request_sender, 92 KeyFrameRequestSender* keyframe_request_sender,
92 video_coding::OnCompleteFrameCallback* complete_frame_callback, 93 video_coding::OnCompleteFrameCallback* complete_frame_callback,
93 VCMTiming* timing) 94 VCMTiming* timing)
94 : clock_(Clock::GetRealTimeClock()), 95 : clock_(Clock::GetRealTimeClock()),
95 config_(*config), 96 config_(*config),
97 video_receiver_(video_receiver),
96 packet_router_(packet_router), 98 packet_router_(packet_router),
97 remb_(remb), 99 remb_(remb),
98 process_thread_(process_thread), 100 process_thread_(process_thread),
99 ntp_estimator_(clock_), 101 ntp_estimator_(clock_),
100 rtp_header_parser_(RtpHeaderParser::Create()), 102 rtp_header_parser_(RtpHeaderParser::Create()),
101 rtp_receiver_(RtpReceiver::CreateVideoReceiver(clock_, 103 rtp_receiver_(RtpReceiver::CreateVideoReceiver(clock_,
102 this, 104 this,
103 this, 105 this,
104 &rtp_payload_registry_)), 106 &rtp_payload_registry_)),
105 rtp_receive_statistics_(ReceiveStatistics::Create(clock_)), 107 rtp_receive_statistics_(ReceiveStatistics::Create(clock_)),
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
177 } 179 }
178 180
179 if (config_.rtp.rtcp_xr.receiver_reference_time_report) 181 if (config_.rtp.rtcp_xr.receiver_reference_time_report)
180 rtp_rtcp_->SetRtcpXrRrtrStatus(true); 182 rtp_rtcp_->SetRtcpXrRrtrStatus(true);
181 183
182 // Stats callback for CNAME changes. 184 // Stats callback for CNAME changes.
183 rtp_rtcp_->RegisterRtcpStatisticsCallback(receive_stats_proxy); 185 rtp_rtcp_->RegisterRtcpStatisticsCallback(receive_stats_proxy);
184 186
185 process_thread_->RegisterModule(rtp_rtcp_.get()); 187 process_thread_->RegisterModule(rtp_rtcp_.get());
186 188
187 nack_module_.reset( 189 jitter_buffer_experiment_ =
188 new NackModule(clock_, nack_sender, keyframe_request_sender)); 190 field_trial::FindFullName("WebRTC-NewVideoJitterBuffer") == "Enabled";
189 if (config_.rtp.nack.rtp_history_ms == 0)
190 nack_module_->Stop();
191 process_thread_->RegisterModule(nack_module_.get());
192 191
193 packet_buffer_ = video_coding::PacketBuffer::Create( 192 if (jitter_buffer_experiment_) {
194 clock_, kPacketBufferStartSize, kPacketBufferMaxSixe, this); 193 nack_module_.reset(
195 reference_finder_.reset(new video_coding::RtpFrameReferenceFinder(this)); 194 new NackModule(clock_, nack_sender, keyframe_request_sender));
195 process_thread_->RegisterModule(nack_module_.get());
196
197 packet_buffer_ = video_coding::PacketBuffer::Create(
198 clock_, kPacketBufferStartSize, kPacketBufferMaxSixe, this);
199 reference_finder_.reset(new video_coding::RtpFrameReferenceFinder(this));
200 }
196 } 201 }
197 202
198 RtpStreamReceiver::~RtpStreamReceiver() { 203 RtpStreamReceiver::~RtpStreamReceiver() {
199 process_thread_->DeRegisterModule(rtp_rtcp_.get()); 204 process_thread_->DeRegisterModule(rtp_rtcp_.get());
200 205
201 process_thread_->DeRegisterModule(nack_module_.get()); 206 if (jitter_buffer_experiment_)
207 process_thread_->DeRegisterModule(nack_module_.get());
202 208
203 packet_router_->RemoveRtpModule(rtp_rtcp_.get()); 209 packet_router_->RemoveRtpModule(rtp_rtcp_.get());
204 rtp_rtcp_->SetREMBStatus(false); 210 rtp_rtcp_->SetREMBStatus(false);
205 if (config_.rtp.remb) { 211 if (config_.rtp.remb) {
206 remb_->RemoveReceiveChannel(rtp_rtcp_.get()); 212 remb_->RemoveReceiveChannel(rtp_rtcp_.get());
207 } 213 }
208 UpdateHistograms(); 214 UpdateHistograms();
209 } 215 }
210 216
211 bool RtpStreamReceiver::AddReceiveCodec( 217 bool RtpStreamReceiver::AddReceiveCodec(
(...skipping 24 matching lines...) Expand all
236 return rtp_receiver_.get(); 242 return rtp_receiver_.get();
237 } 243 }
238 244
239 int32_t RtpStreamReceiver::OnReceivedPayloadData( 245 int32_t RtpStreamReceiver::OnReceivedPayloadData(
240 const uint8_t* payload_data, 246 const uint8_t* payload_data,
241 size_t payload_size, 247 size_t payload_size,
242 const WebRtcRTPHeader* rtp_header) { 248 const WebRtcRTPHeader* rtp_header) {
243 WebRtcRTPHeader rtp_header_with_ntp = *rtp_header; 249 WebRtcRTPHeader rtp_header_with_ntp = *rtp_header;
244 rtp_header_with_ntp.ntp_time_ms = 250 rtp_header_with_ntp.ntp_time_ms =
245 ntp_estimator_.Estimate(rtp_header->header.timestamp); 251 ntp_estimator_.Estimate(rtp_header->header.timestamp);
246 VCMPacket packet(payload_data, payload_size, rtp_header_with_ntp); 252 if (jitter_buffer_experiment_) {
247 packet.timesNacked = nack_module_->OnReceivedPacket(packet); 253 VCMPacket packet(payload_data, payload_size, rtp_header_with_ntp);
254 packet.timesNacked = nack_module_->OnReceivedPacket(packet);
248 255
249 if (packet.codec == kVideoCodecH264) { 256 if (packet.codec == kVideoCodecH264) {
250 // Only when we start to receive packets will we know what payload type 257 // Only when we start to receive packets will we know what payload type
251 // that will be used. When we know the payload type insert the correct 258 // that will be used. When we know the payload type insert the correct
252 // sps/pps into the tracker. 259 // sps/pps into the tracker.
253 if (packet.payloadType != last_payload_type_) { 260 if (packet.payloadType != last_payload_type_) {
254 last_payload_type_ = packet.payloadType; 261 last_payload_type_ = packet.payloadType;
255 InsertSpsPpsIntoTracker(packet.payloadType); 262 InsertSpsPpsIntoTracker(packet.payloadType);
263 }
264
265 switch (tracker_.CopyAndFixBitstream(&packet)) {
266 case video_coding::H264SpsPpsTracker::kRequestKeyframe:
267 keyframe_request_sender_->RequestKeyFrame();
268 FALLTHROUGH();
269 case video_coding::H264SpsPpsTracker::kDrop:
270 return 0;
271 case video_coding::H264SpsPpsTracker::kInsert:
272 break;
273 }
274 } else {
275 uint8_t* data = new uint8_t[packet.sizeBytes];
276 memcpy(data, packet.dataPtr, packet.sizeBytes);
277 packet.dataPtr = data;
256 } 278 }
257 279
258 switch (tracker_.CopyAndFixBitstream(&packet)) { 280 packet_buffer_->InsertPacket(&packet);
259 case video_coding::H264SpsPpsTracker::kRequestKeyframe: 281 } else {
260 keyframe_request_sender_->RequestKeyFrame(); 282 RTC_DCHECK(video_receiver_);
261 FALLTHROUGH(); 283 if (video_receiver_->IncomingPacket(payload_data, payload_size,
262 case video_coding::H264SpsPpsTracker::kDrop: 284 rtp_header_with_ntp) != 0) {
263 return 0; 285 // Check this...
264 case video_coding::H264SpsPpsTracker::kInsert: 286 return -1;
265 break;
266 } 287 }
267
268 } else {
269 uint8_t* data = new uint8_t[packet.sizeBytes];
270 memcpy(data, packet.dataPtr, packet.sizeBytes);
271 packet.dataPtr = data;
272 } 288 }
273
274 packet_buffer_->InsertPacket(&packet);
275 return 0; 289 return 0;
276 } 290 }
277 291
278 bool RtpStreamReceiver::OnRecoveredPacket(const uint8_t* rtp_packet, 292 bool RtpStreamReceiver::OnRecoveredPacket(const uint8_t* rtp_packet,
279 size_t rtp_packet_length) { 293 size_t rtp_packet_length) {
280 RTPHeader header; 294 RTPHeader header;
281 if (!rtp_header_parser_->Parse(rtp_packet, rtp_packet_length, &header)) { 295 if (!rtp_header_parser_->Parse(rtp_packet, rtp_packet_length, &header)) {
282 return false; 296 return false;
283 } 297 }
284 header.payload_type_frequency = kVideoPayloadTypeFrequency; 298 header.payload_type_frequency = kVideoPayloadTypeFrequency;
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after
399 { 413 {
400 rtc::CritScope lock(&last_seq_num_cs_); 414 rtc::CritScope lock(&last_seq_num_cs_);
401 video_coding::RtpFrameObject* rtp_frame = 415 video_coding::RtpFrameObject* rtp_frame =
402 static_cast<video_coding::RtpFrameObject*>(frame.get()); 416 static_cast<video_coding::RtpFrameObject*>(frame.get());
403 last_seq_num_for_pic_id_[rtp_frame->picture_id] = rtp_frame->last_seq_num(); 417 last_seq_num_for_pic_id_[rtp_frame->picture_id] = rtp_frame->last_seq_num();
404 } 418 }
405 complete_frame_callback_->OnCompleteFrame(std::move(frame)); 419 complete_frame_callback_->OnCompleteFrame(std::move(frame));
406 } 420 }
407 421
408 void RtpStreamReceiver::OnRttUpdate(int64_t avg_rtt_ms, int64_t max_rtt_ms) { 422 void RtpStreamReceiver::OnRttUpdate(int64_t avg_rtt_ms, int64_t max_rtt_ms) {
409 nack_module_->UpdateRtt(max_rtt_ms); 423 if (jitter_buffer_experiment_)
424 nack_module_->UpdateRtt(max_rtt_ms);
410 } 425 }
411 426
412 bool RtpStreamReceiver::ReceivePacket(const uint8_t* packet, 427 bool RtpStreamReceiver::ReceivePacket(const uint8_t* packet,
413 size_t packet_length, 428 size_t packet_length,
414 const RTPHeader& header, 429 const RTPHeader& header,
415 bool in_order) { 430 bool in_order) {
416 if (rtp_payload_registry_.IsEncapsulated(header)) { 431 if (rtp_payload_registry_.IsEncapsulated(header)) {
417 return ParseAndHandleEncapsulatingHeader(packet, packet_length, header); 432 return ParseAndHandleEncapsulatingHeader(packet, packet_length, header);
418 } 433 }
419 const uint8_t* payload = packet + header.headerLength; 434 const uint8_t* payload = packet + header.headerLength;
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after
527 &rtp_timestamp) != 0) { 542 &rtp_timestamp) != 0) {
528 // Waiting for RTCP. 543 // Waiting for RTCP.
529 return true; 544 return true;
530 } 545 }
531 ntp_estimator_.UpdateRtcpTimestamp(rtt, ntp_secs, ntp_frac, rtp_timestamp); 546 ntp_estimator_.UpdateRtcpTimestamp(rtt, ntp_secs, ntp_frac, rtp_timestamp);
532 547
533 return true; 548 return true;
534 } 549 }
535 550
536 void RtpStreamReceiver::FrameContinuous(uint16_t picture_id) { 551 void RtpStreamReceiver::FrameContinuous(uint16_t picture_id) {
537 int seq_num = -1; 552 if (jitter_buffer_experiment_) {
538 { 553 int seq_num = -1;
539 rtc::CritScope lock(&last_seq_num_cs_); 554 {
540 auto seq_num_it = last_seq_num_for_pic_id_.find(picture_id); 555 rtc::CritScope lock(&last_seq_num_cs_);
541 if (seq_num_it != last_seq_num_for_pic_id_.end()) 556 auto seq_num_it = last_seq_num_for_pic_id_.find(picture_id);
542 seq_num = seq_num_it->second; 557 if (seq_num_it != last_seq_num_for_pic_id_.end())
558 seq_num = seq_num_it->second;
559 }
560 if (seq_num != -1)
561 nack_module_->ClearUpTo(seq_num);
543 } 562 }
544 if (seq_num != -1)
545 nack_module_->ClearUpTo(seq_num);
546 } 563 }
547 564
548 void RtpStreamReceiver::FrameDecoded(uint16_t picture_id) { 565 void RtpStreamReceiver::FrameDecoded(uint16_t picture_id) {
549 int seq_num = -1; 566 if (jitter_buffer_experiment_) {
550 { 567 int seq_num = -1;
551 rtc::CritScope lock(&last_seq_num_cs_); 568 {
552 auto seq_num_it = last_seq_num_for_pic_id_.find(picture_id); 569 rtc::CritScope lock(&last_seq_num_cs_);
553 if (seq_num_it != last_seq_num_for_pic_id_.end()) { 570 auto seq_num_it = last_seq_num_for_pic_id_.find(picture_id);
554 seq_num = seq_num_it->second; 571 if (seq_num_it != last_seq_num_for_pic_id_.end()) {
555 last_seq_num_for_pic_id_.erase(last_seq_num_for_pic_id_.begin(), 572 seq_num = seq_num_it->second;
556 ++seq_num_it); 573 last_seq_num_for_pic_id_.erase(last_seq_num_for_pic_id_.begin(),
574 ++seq_num_it);
575 }
557 } 576 }
558 } 577 if (seq_num != -1) {
559 if (seq_num != -1) { 578 packet_buffer_->ClearTo(seq_num);
560 packet_buffer_->ClearTo(seq_num); 579 reference_finder_->ClearTo(seq_num);
561 reference_finder_->ClearTo(seq_num); 580 }
562 } 581 }
563 } 582 }
564 583
565 void RtpStreamReceiver::SignalNetworkState(NetworkState state) { 584 void RtpStreamReceiver::SignalNetworkState(NetworkState state) {
566 rtp_rtcp_->SetRTCPStatus(state == kNetworkUp ? config_.rtp.rtcp_mode 585 rtp_rtcp_->SetRTCPStatus(state == kNetworkUp ? config_.rtp.rtcp_mode
567 : RtcpMode::kOff); 586 : RtcpMode::kOff);
568 } 587 }
569 588
570 void RtpStreamReceiver::StartReceive() { 589 void RtpStreamReceiver::StartReceive() {
571 rtc::CritScope lock(&receive_cs_); 590 rtc::CritScope lock(&receive_cs_);
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
649 return; 668 return;
650 669
651 if (!sprop_decoder.DecodeSprop(sprop_base64_it->second.c_str())) 670 if (!sprop_decoder.DecodeSprop(sprop_base64_it->second.c_str()))
652 return; 671 return;
653 672
654 tracker_.InsertSpsPpsNalus(sprop_decoder.sps_nalu(), 673 tracker_.InsertSpsPpsNalus(sprop_decoder.sps_nalu(),
655 sprop_decoder.pps_nalu()); 674 sprop_decoder.pps_nalu());
656 } 675 }
657 676
658 } // namespace webrtc 677 } // 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