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

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

Issue 2638423003: Revert of Make the new jitter buffer the default jitter buffer. (Closed)
Patch Set: Created 3 years, 11 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/video_receive_stream.h » ('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 181 matching lines...) Expand 10 before | Expand all | Expand 10 after
192 } 192 }
193 193
194 if (config_.rtp.rtcp_xr.receiver_reference_time_report) 194 if (config_.rtp.rtcp_xr.receiver_reference_time_report)
195 rtp_rtcp_->SetRtcpXrRrtrStatus(true); 195 rtp_rtcp_->SetRtcpXrRrtrStatus(true);
196 196
197 // Stats callback for CNAME changes. 197 // Stats callback for CNAME changes.
198 rtp_rtcp_->RegisterRtcpStatisticsCallback(receive_stats_proxy); 198 rtp_rtcp_->RegisterRtcpStatisticsCallback(receive_stats_proxy);
199 199
200 process_thread_->RegisterModule(rtp_rtcp_.get()); 200 process_thread_->RegisterModule(rtp_rtcp_.get());
201 201
202 nack_module_.reset( 202 jitter_buffer_experiment_ =
203 new NackModule(clock_, nack_sender, keyframe_request_sender)); 203 field_trial::FindFullName("WebRTC-NewVideoJitterBuffer") == "Enabled";
204 if (config_.rtp.nack.rtp_history_ms == 0)
205 nack_module_->Stop();
206 process_thread_->RegisterModule(nack_module_.get());
207 204
208 packet_buffer_ = video_coding::PacketBuffer::Create( 205 if (jitter_buffer_experiment_) {
209 clock_, kPacketBufferStartSize, kPacketBufferMaxSixe, this); 206 nack_module_.reset(
210 reference_finder_.reset(new video_coding::RtpFrameReferenceFinder(this)); 207 new NackModule(clock_, nack_sender, keyframe_request_sender));
208 process_thread_->RegisterModule(nack_module_.get());
209
210 packet_buffer_ = video_coding::PacketBuffer::Create(
211 clock_, kPacketBufferStartSize, kPacketBufferMaxSixe, this);
212 reference_finder_.reset(new video_coding::RtpFrameReferenceFinder(this));
213 }
211 } 214 }
212 215
213 RtpStreamReceiver::~RtpStreamReceiver() { 216 RtpStreamReceiver::~RtpStreamReceiver() {
214 process_thread_->DeRegisterModule(rtp_rtcp_.get()); 217 process_thread_->DeRegisterModule(rtp_rtcp_.get());
215 218
216 process_thread_->DeRegisterModule(nack_module_.get()); 219 if (jitter_buffer_experiment_)
220 process_thread_->DeRegisterModule(nack_module_.get());
217 221
218 packet_router_->RemoveRtpModule(rtp_rtcp_.get()); 222 packet_router_->RemoveRtpModule(rtp_rtcp_.get());
219 rtp_rtcp_->SetREMBStatus(false); 223 rtp_rtcp_->SetREMBStatus(false);
220 remb_->RemoveReceiveChannel(rtp_rtcp_.get()); 224 remb_->RemoveReceiveChannel(rtp_rtcp_.get());
221 UpdateHistograms(); 225 UpdateHistograms();
222 } 226 }
223 227
224 bool RtpStreamReceiver::AddReceiveCodec( 228 bool RtpStreamReceiver::AddReceiveCodec(
225 const VideoCodec& video_codec, 229 const VideoCodec& video_codec,
226 const std::map<std::string, std::string>& codec_params) { 230 const std::map<std::string, std::string>& codec_params) {
(...skipping 23 matching lines...) Expand all
250 } 254 }
251 255
252 int32_t RtpStreamReceiver::OnReceivedPayloadData( 256 int32_t RtpStreamReceiver::OnReceivedPayloadData(
253 const uint8_t* payload_data, 257 const uint8_t* payload_data,
254 size_t payload_size, 258 size_t payload_size,
255 const WebRtcRTPHeader* rtp_header) { 259 const WebRtcRTPHeader* rtp_header) {
256 RTC_DCHECK(video_receiver_); 260 RTC_DCHECK(video_receiver_);
257 WebRtcRTPHeader rtp_header_with_ntp = *rtp_header; 261 WebRtcRTPHeader rtp_header_with_ntp = *rtp_header;
258 rtp_header_with_ntp.ntp_time_ms = 262 rtp_header_with_ntp.ntp_time_ms =
259 ntp_estimator_.Estimate(rtp_header->header.timestamp); 263 ntp_estimator_.Estimate(rtp_header->header.timestamp);
260 VCMPacket packet(payload_data, payload_size, rtp_header_with_ntp); 264 if (jitter_buffer_experiment_) {
261 timing_->IncomingTimestamp(packet.timestamp, clock_->TimeInMilliseconds()); 265 VCMPacket packet(payload_data, payload_size, rtp_header_with_ntp);
262 packet.timesNacked = nack_module_->OnReceivedPacket(packet); 266 timing_->IncomingTimestamp(packet.timestamp, clock_->TimeInMilliseconds());
267 packet.timesNacked = nack_module_->OnReceivedPacket(packet);
263 268
264 if (packet.codec == kVideoCodecH264) { 269 if (packet.codec == kVideoCodecH264) {
265 // Only when we start to receive packets will we know what payload type 270 // Only when we start to receive packets will we know what payload type
266 // that will be used. When we know the payload type insert the correct 271 // that will be used. When we know the payload type insert the correct
267 // sps/pps into the tracker. 272 // sps/pps into the tracker.
268 if (packet.payloadType != last_payload_type_) { 273 if (packet.payloadType != last_payload_type_) {
269 last_payload_type_ = packet.payloadType; 274 last_payload_type_ = packet.payloadType;
270 InsertSpsPpsIntoTracker(packet.payloadType); 275 InsertSpsPpsIntoTracker(packet.payloadType);
276 }
277
278 switch (tracker_.CopyAndFixBitstream(&packet)) {
279 case video_coding::H264SpsPpsTracker::kRequestKeyframe:
280 keyframe_request_sender_->RequestKeyFrame();
281 FALLTHROUGH();
282 case video_coding::H264SpsPpsTracker::kDrop:
283 return 0;
284 case video_coding::H264SpsPpsTracker::kInsert:
285 break;
286 }
287 } else {
288 uint8_t* data = new uint8_t[packet.sizeBytes];
289 memcpy(data, packet.dataPtr, packet.sizeBytes);
290 packet.dataPtr = data;
271 } 291 }
272 292
273 switch (tracker_.CopyAndFixBitstream(&packet)) { 293 packet_buffer_->InsertPacket(&packet);
274 case video_coding::H264SpsPpsTracker::kRequestKeyframe: 294 } else {
275 keyframe_request_sender_->RequestKeyFrame(); 295 if (video_receiver_->IncomingPacket(payload_data, payload_size,
276 FALLTHROUGH(); 296 rtp_header_with_ntp) != 0) {
277 case video_coding::H264SpsPpsTracker::kDrop: 297 // Check this...
278 return 0; 298 return -1;
279 case video_coding::H264SpsPpsTracker::kInsert:
280 break;
281 } 299 }
282 } else {
283 uint8_t* data = new uint8_t[packet.sizeBytes];
284 memcpy(data, packet.dataPtr, packet.sizeBytes);
285 packet.dataPtr = data;
286 } 300 }
287
288 packet_buffer_->InsertPacket(&packet);
289 return 0; 301 return 0;
290 } 302 }
291 303
292 bool RtpStreamReceiver::OnRecoveredPacket(const uint8_t* rtp_packet, 304 bool RtpStreamReceiver::OnRecoveredPacket(const uint8_t* rtp_packet,
293 size_t rtp_packet_length) { 305 size_t rtp_packet_length) {
294 RTPHeader header; 306 RTPHeader header;
295 if (!rtp_header_parser_->Parse(rtp_packet, rtp_packet_length, &header)) { 307 if (!rtp_header_parser_->Parse(rtp_packet, rtp_packet_length, &header)) {
296 return false; 308 return false;
297 } 309 }
298 header.payload_type_frequency = kVideoPayloadTypeFrequency; 310 header.payload_type_frequency = kVideoPayloadTypeFrequency;
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after
415 { 427 {
416 rtc::CritScope lock(&last_seq_num_cs_); 428 rtc::CritScope lock(&last_seq_num_cs_);
417 video_coding::RtpFrameObject* rtp_frame = 429 video_coding::RtpFrameObject* rtp_frame =
418 static_cast<video_coding::RtpFrameObject*>(frame.get()); 430 static_cast<video_coding::RtpFrameObject*>(frame.get());
419 last_seq_num_for_pic_id_[rtp_frame->picture_id] = rtp_frame->last_seq_num(); 431 last_seq_num_for_pic_id_[rtp_frame->picture_id] = rtp_frame->last_seq_num();
420 } 432 }
421 complete_frame_callback_->OnCompleteFrame(std::move(frame)); 433 complete_frame_callback_->OnCompleteFrame(std::move(frame));
422 } 434 }
423 435
424 void RtpStreamReceiver::OnRttUpdate(int64_t avg_rtt_ms, int64_t max_rtt_ms) { 436 void RtpStreamReceiver::OnRttUpdate(int64_t avg_rtt_ms, int64_t max_rtt_ms) {
425 nack_module_->UpdateRtt(max_rtt_ms); 437 if (jitter_buffer_experiment_)
438 nack_module_->UpdateRtt(max_rtt_ms);
426 } 439 }
427 440
428 bool RtpStreamReceiver::ReceivePacket(const uint8_t* packet, 441 bool RtpStreamReceiver::ReceivePacket(const uint8_t* packet,
429 size_t packet_length, 442 size_t packet_length,
430 const RTPHeader& header, 443 const RTPHeader& header,
431 bool in_order) { 444 bool in_order) {
432 if (rtp_payload_registry_.IsEncapsulated(header)) { 445 if (rtp_payload_registry_.IsEncapsulated(header)) {
433 return ParseAndHandleEncapsulatingHeader(packet, packet_length, header); 446 return ParseAndHandleEncapsulatingHeader(packet, packet_length, header);
434 } 447 }
435 const uint8_t* payload = packet + header.headerLength; 448 const uint8_t* payload = packet + header.headerLength;
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after
543 &rtp_timestamp) != 0) { 556 &rtp_timestamp) != 0) {
544 // Waiting for RTCP. 557 // Waiting for RTCP.
545 return true; 558 return true;
546 } 559 }
547 ntp_estimator_.UpdateRtcpTimestamp(rtt, ntp_secs, ntp_frac, rtp_timestamp); 560 ntp_estimator_.UpdateRtcpTimestamp(rtt, ntp_secs, ntp_frac, rtp_timestamp);
548 561
549 return true; 562 return true;
550 } 563 }
551 564
552 void RtpStreamReceiver::FrameContinuous(uint16_t picture_id) { 565 void RtpStreamReceiver::FrameContinuous(uint16_t picture_id) {
553 int seq_num = -1; 566 if (jitter_buffer_experiment_) {
554 { 567 int seq_num = -1;
555 rtc::CritScope lock(&last_seq_num_cs_); 568 {
556 auto seq_num_it = last_seq_num_for_pic_id_.find(picture_id); 569 rtc::CritScope lock(&last_seq_num_cs_);
557 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);
558 seq_num = seq_num_it->second; 571 if (seq_num_it != last_seq_num_for_pic_id_.end())
572 seq_num = seq_num_it->second;
573 }
574 if (seq_num != -1)
575 nack_module_->ClearUpTo(seq_num);
559 } 576 }
560 if (seq_num != -1)
561 nack_module_->ClearUpTo(seq_num);
562 } 577 }
563 578
564 void RtpStreamReceiver::FrameDecoded(uint16_t picture_id) { 579 void RtpStreamReceiver::FrameDecoded(uint16_t picture_id) {
565 int seq_num = -1; 580 if (jitter_buffer_experiment_) {
566 { 581 int seq_num = -1;
567 rtc::CritScope lock(&last_seq_num_cs_); 582 {
568 auto seq_num_it = last_seq_num_for_pic_id_.find(picture_id); 583 rtc::CritScope lock(&last_seq_num_cs_);
569 if (seq_num_it != last_seq_num_for_pic_id_.end()) { 584 auto seq_num_it = last_seq_num_for_pic_id_.find(picture_id);
570 seq_num = seq_num_it->second; 585 if (seq_num_it != last_seq_num_for_pic_id_.end()) {
571 last_seq_num_for_pic_id_.erase(last_seq_num_for_pic_id_.begin(), 586 seq_num = seq_num_it->second;
572 ++seq_num_it); 587 last_seq_num_for_pic_id_.erase(last_seq_num_for_pic_id_.begin(),
588 ++seq_num_it);
589 }
573 } 590 }
574 } 591 if (seq_num != -1) {
575 if (seq_num != -1) { 592 packet_buffer_->ClearTo(seq_num);
576 packet_buffer_->ClearTo(seq_num); 593 reference_finder_->ClearTo(seq_num);
577 reference_finder_->ClearTo(seq_num); 594 }
578 } 595 }
579 } 596 }
580 597
581 void RtpStreamReceiver::SignalNetworkState(NetworkState state) { 598 void RtpStreamReceiver::SignalNetworkState(NetworkState state) {
582 rtp_rtcp_->SetRTCPStatus(state == kNetworkUp ? config_.rtp.rtcp_mode 599 rtp_rtcp_->SetRTCPStatus(state == kNetworkUp ? config_.rtp.rtcp_mode
583 : RtcpMode::kOff); 600 : RtcpMode::kOff);
584 } 601 }
585 602
586 void RtpStreamReceiver::StartReceive() { 603 void RtpStreamReceiver::StartReceive() {
587 rtc::CritScope lock(&receive_cs_); 604 rtc::CritScope lock(&receive_cs_);
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
664 if (sprop_base64_it == codec_params_it->second.end()) 681 if (sprop_base64_it == codec_params_it->second.end())
665 return; 682 return;
666 683
667 if (!sprop_decoder.DecodeSprop(sprop_base64_it->second)) 684 if (!sprop_decoder.DecodeSprop(sprop_base64_it->second))
668 return; 685 return;
669 686
670 tracker_.InsertSpsPps(sprop_decoder.sps_nalu(), sprop_decoder.pps_nalu()); 687 tracker_.InsertSpsPps(sprop_decoder.sps_nalu(), sprop_decoder.pps_nalu());
671 } 688 }
672 689
673 } // namespace webrtc 690 } // namespace webrtc
OLDNEW
« no previous file with comments | « webrtc/video/rtp_stream_receiver.h ('k') | webrtc/video/video_receive_stream.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698