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

Side by Side Diff: webrtc/modules/audio_coding/neteq/neteq_impl.cc

Issue 2743063005: Fixed problems in neteq when RTP and decoder timestamps increment with (Closed)
Patch Set: Fixed TestRedFec, G722_20ms and G722_stereo_20ms unittest failures. Created 3 years, 9 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/modules/audio_coding/acm2/audio_coding_module_unittest.cc ('k') | no next file » | 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 576 matching lines...) Expand 10 before | Expand all | Expand 10 after
587 Packet packet; 587 Packet packet;
588 packet.payload_type = rtp_header.header.payloadType; 588 packet.payload_type = rtp_header.header.payloadType;
589 packet.sequence_number = rtp_header.header.sequenceNumber; 589 packet.sequence_number = rtp_header.header.sequenceNumber;
590 packet.timestamp = rtp_header.header.timestamp; 590 packet.timestamp = rtp_header.header.timestamp;
591 packet.payload.SetData(payload.data(), payload.size()); 591 packet.payload.SetData(payload.data(), payload.size());
592 // Waiting time will be set upon inserting the packet in the buffer. 592 // Waiting time will be set upon inserting the packet in the buffer.
593 RTC_DCHECK(!packet.waiting_time); 593 RTC_DCHECK(!packet.waiting_time);
594 return packet; 594 return packet;
595 }()); 595 }());
596 596
597 bool update_sample_rate_and_channels = false; 597 bool update_sample_rate_and_channels = first_packet_ ||
598 (rtp_header.header.ssrc != ssrc_);
599
600 if (update_sample_rate_and_channels) {
601 // Reset timestamp scaling.
602 timestamp_scaler_->Reset();
603 }
604
605 if (!decoder_database_->IsRed(rtp_header.header.payloadType)) {
ossu 2017/03/14 16:57:14 Hmm... I'm not sure this _should_ be necessary. I'
606 // Scale timestamp to internal domain (only for some codecs).
607 timestamp_scaler_->ToInternal(&packet_list);
608 }
609
610 // Store these for later use, since the first packet may very well disappear
611 // before we need these values.
612 uint32_t main_timestamp = packet_list.front().timestamp;
613 uint8_t main_payload_type = packet_list.front().payload_type;
614 uint16_t main_sequence_number = packet_list.front().sequence_number;
615
598 // Reinitialize NetEq if it's needed (changed SSRC or first call). 616 // Reinitialize NetEq if it's needed (changed SSRC or first call).
599 if ((rtp_header.header.ssrc != ssrc_) || first_packet_) { 617 if (update_sample_rate_and_channels) {
600 // Note: |first_packet_| will be cleared further down in this method, once 618 // Note: |first_packet_| will be cleared further down in this method, once
601 // the packet has been successfully inserted into the packet buffer. 619 // the packet has been successfully inserted into the packet buffer.
602 620
603 rtcp_.Init(rtp_header.header.sequenceNumber); 621 rtcp_.Init(rtp_header.header.sequenceNumber);
604 622
605 // Flush the packet buffer and DTMF buffer. 623 // Flush the packet buffer and DTMF buffer.
606 packet_buffer_->Flush(); 624 packet_buffer_->Flush();
607 dtmf_buffer_->Flush(); 625 dtmf_buffer_->Flush();
608 626
609 // Store new SSRC. 627 // Store new SSRC.
610 ssrc_ = rtp_header.header.ssrc; 628 ssrc_ = rtp_header.header.ssrc;
611 629
612 // Update audio buffer timestamp. 630 // Update audio buffer timestamp.
613 sync_buffer_->IncreaseEndTimestamp(rtp_header.header.timestamp - 631 sync_buffer_->IncreaseEndTimestamp(main_timestamp - timestamp_);
614 timestamp_);
615 632
616 // Update codecs. 633 // Update codecs.
617 timestamp_ = rtp_header.header.timestamp; 634 timestamp_ = main_timestamp;
618
619 // Reset timestamp scaling.
620 timestamp_scaler_->Reset();
621
622 // Trigger an update of sampling rate and the number of channels.
623 update_sample_rate_and_channels = true;
624 } 635 }
625 636
626 // Update RTCP statistics, only for regular packets. 637 // Update RTCP statistics, only for regular packets.
627 rtcp_.Update(rtp_header.header, receive_timestamp); 638 rtcp_.Update(rtp_header.header, receive_timestamp);
628 639
629 if (nack_enabled_) { 640 if (nack_enabled_) {
630 RTC_DCHECK(nack_); 641 RTC_DCHECK(nack_);
631 if (update_sample_rate_and_channels) { 642 if (update_sample_rate_and_channels) {
632 nack_->Reset(); 643 nack_->Reset();
633 } 644 }
(...skipping 11 matching lines...) Expand all
645 red_payload_splitter_->CheckRedPayloads(&packet_list, *decoder_database_); 656 red_payload_splitter_->CheckRedPayloads(&packet_list, *decoder_database_);
646 } 657 }
647 658
648 // Check payload types. 659 // Check payload types.
649 if (decoder_database_->CheckPayloadTypes(packet_list) == 660 if (decoder_database_->CheckPayloadTypes(packet_list) ==
650 DecoderDatabase::kDecoderNotFound) { 661 DecoderDatabase::kDecoderNotFound) {
651 return kUnknownRtpPayloadType; 662 return kUnknownRtpPayloadType;
652 } 663 }
653 664
654 RTC_DCHECK(!packet_list.empty()); 665 RTC_DCHECK(!packet_list.empty());
655 // Store these for later use, since the first packet may very well disappear
656 // before we need these values.
657 const uint32_t main_timestamp = packet_list.front().timestamp;
658 const uint8_t main_payload_type = packet_list.front().payload_type;
659 const uint16_t main_sequence_number = packet_list.front().sequence_number;
660 666
661 // Scale timestamp to internal domain (only for some codecs). 667 // Update main_timestamp, if new packets appear in the list
662 timestamp_scaler_->ToInternal(&packet_list); 668 // after RED splitting.
669 if (decoder_database_->IsRed(rtp_header.header.payloadType)) {
670 timestamp_scaler_->ToInternal(&packet_list);
671 main_timestamp = packet_list.front().timestamp;
672 main_payload_type = packet_list.front().payload_type;
673 main_sequence_number = packet_list.front().sequence_number;
674 }
663 675
664 // Process DTMF payloads. Cycle through the list of packets, and pick out any 676 // Process DTMF payloads. Cycle through the list of packets, and pick out any
665 // DTMF payloads found. 677 // DTMF payloads found.
666 PacketList::iterator it = packet_list.begin(); 678 PacketList::iterator it = packet_list.begin();
667 while (it != packet_list.end()) { 679 while (it != packet_list.end()) {
668 const Packet& current_packet = (*it); 680 const Packet& current_packet = (*it);
669 RTC_DCHECK(!current_packet.payload.empty()); 681 RTC_DCHECK(!current_packet.payload.empty());
670 if (decoder_database_->IsDtmf(current_packet.payload_type)) { 682 if (decoder_database_->IsDtmf(current_packet.payload_type)) {
671 DtmfEvent event; 683 DtmfEvent event;
672 int ret = DtmfBuffer::ParseEvent(current_packet.timestamp, 684 int ret = DtmfBuffer::ParseEvent(current_packet.timestamp,
(...skipping 1455 matching lines...) Expand 10 before | Expand all | Expand 10 after
2128 } 2140 }
2129 } 2141 }
2130 2142
2131 void NetEqImpl::CreateDecisionLogic() { 2143 void NetEqImpl::CreateDecisionLogic() {
2132 decision_logic_.reset(DecisionLogic::Create( 2144 decision_logic_.reset(DecisionLogic::Create(
2133 fs_hz_, output_size_samples_, playout_mode_, decoder_database_.get(), 2145 fs_hz_, output_size_samples_, playout_mode_, decoder_database_.get(),
2134 *packet_buffer_.get(), delay_manager_.get(), buffer_level_filter_.get(), 2146 *packet_buffer_.get(), delay_manager_.get(), buffer_level_filter_.get(),
2135 tick_timer_.get())); 2147 tick_timer_.get()));
2136 } 2148 }
2137 } // namespace webrtc 2149 } // namespace webrtc
OLDNEW
« no previous file with comments | « webrtc/modules/audio_coding/acm2/audio_coding_module_unittest.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698