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

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

Issue 2290153002: NetEq: Change member variables for current RTP types to rtc::Optionals (Closed)
Patch Set: Updates after review Created 4 years, 3 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
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 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
88 expand_factory_(std::move(deps.expand_factory)), 88 expand_factory_(std::move(deps.expand_factory)),
89 accelerate_factory_(std::move(deps.accelerate_factory)), 89 accelerate_factory_(std::move(deps.accelerate_factory)),
90 preemptive_expand_factory_(std::move(deps.preemptive_expand_factory)), 90 preemptive_expand_factory_(std::move(deps.preemptive_expand_factory)),
91 last_mode_(kModeNormal), 91 last_mode_(kModeNormal),
92 decoded_buffer_length_(kMaxFrameSize), 92 decoded_buffer_length_(kMaxFrameSize),
93 decoded_buffer_(new int16_t[decoded_buffer_length_]), 93 decoded_buffer_(new int16_t[decoded_buffer_length_]),
94 playout_timestamp_(0), 94 playout_timestamp_(0),
95 new_codec_(false), 95 new_codec_(false),
96 timestamp_(0), 96 timestamp_(0),
97 reset_decoder_(false), 97 reset_decoder_(false),
98 current_rtp_payload_type_(0xFF), // Invalid RTP payload type.
99 current_cng_rtp_payload_type_(0xFF), // Invalid RTP payload type.
100 ssrc_(0), 98 ssrc_(0),
101 first_packet_(true), 99 first_packet_(true),
102 error_code_(0), 100 error_code_(0),
103 decoder_error_code_(0), 101 decoder_error_code_(0),
104 background_noise_mode_(config.background_noise_mode), 102 background_noise_mode_(config.background_noise_mode),
105 playout_mode_(config.playout_mode), 103 playout_mode_(config.playout_mode),
106 enable_fast_accelerate_(config.enable_fast_accelerate), 104 enable_fast_accelerate_(config.enable_fast_accelerate),
107 nack_enabled_(false), 105 nack_enabled_(false),
108 enable_muted_state_(config.enable_muted_state) { 106 enable_muted_state_(config.enable_muted_state) {
109 LOG(LS_INFO) << "NetEq config: " << config.ToString(); 107 LOG(LS_INFO) << "NetEq config: " << config.ToString();
(...skipping 420 matching lines...) Expand 10 before | Expand all | Expand 10 after
530 } 528 }
531 // Sanity checks for sync-packets. 529 // Sanity checks for sync-packets.
532 if (is_sync_packet) { 530 if (is_sync_packet) {
533 if (decoder_database_->IsDtmf(rtp_header.header.payloadType) || 531 if (decoder_database_->IsDtmf(rtp_header.header.payloadType) ||
534 decoder_database_->IsRed(rtp_header.header.payloadType) || 532 decoder_database_->IsRed(rtp_header.header.payloadType) ||
535 decoder_database_->IsComfortNoise(rtp_header.header.payloadType)) { 533 decoder_database_->IsComfortNoise(rtp_header.header.payloadType)) {
536 LOG_F(LS_ERROR) << "Sync-packet with an unacceptable payload type " 534 LOG_F(LS_ERROR) << "Sync-packet with an unacceptable payload type "
537 << static_cast<int>(rtp_header.header.payloadType); 535 << static_cast<int>(rtp_header.header.payloadType);
538 return kSyncPacketNotAccepted; 536 return kSyncPacketNotAccepted;
539 } 537 }
540 if (first_packet_ || 538 if (first_packet_ || !current_rtp_payload_type_ ||
541 rtp_header.header.payloadType != current_rtp_payload_type_ || 539 rtp_header.header.payloadType != *current_rtp_payload_type_ ||
542 rtp_header.header.ssrc != ssrc_) { 540 rtp_header.header.ssrc != ssrc_) {
543 // Even if |current_rtp_payload_type_| is 0xFF, sync-packet isn't 541 // Even if |current_rtp_payload_type_| is empty, sync-packet isn't
544 // accepted. 542 // accepted.
545 LOG_F(LS_ERROR) 543 LOG_F(LS_ERROR)
546 << "Changing codec, SSRC or first packet with sync-packet."; 544 << "Changing codec, SSRC or first packet with sync-packet.";
547 return kSyncPacketNotAccepted; 545 return kSyncPacketNotAccepted;
548 } 546 }
549 } 547 }
550 PacketList packet_list; 548 PacketList packet_list;
551 RTPHeader main_header; 549 RTPHeader main_header;
552 { 550 {
553 // Convert to Packet. 551 // Convert to Packet.
(...skipping 182 matching lines...) Expand 10 before | Expand all | Expand 10 after
736 PacketBuffer::DeleteAllPackets(&packet_list); 734 PacketBuffer::DeleteAllPackets(&packet_list);
737 return kOtherError; 735 return kOtherError;
738 } 736 }
739 737
740 if (first_packet_) { 738 if (first_packet_) {
741 first_packet_ = false; 739 first_packet_ = false;
742 // Update the codec on the next GetAudio call. 740 // Update the codec on the next GetAudio call.
743 new_codec_ = true; 741 new_codec_ = true;
744 } 742 }
745 743
746 RTC_DCHECK(current_rtp_payload_type_ == 0xFF || 744 if (current_rtp_payload_type_) {
747 decoder_database_->GetDecoderInfo(current_rtp_payload_type_)) 745 RTC_DCHECK(decoder_database_->GetDecoderInfo(*current_rtp_payload_type_))
748 << "Payload type " << static_cast<int>(current_rtp_payload_type_) 746 << "Payload type " << static_cast<int>(*current_rtp_payload_type_)
749 << " is unknown where it shouldn't be"; 747 << " is unknown where it shouldn't be";
748 }
750 749
751 if (update_sample_rate_and_channels && !packet_buffer_->Empty()) { 750 if (update_sample_rate_and_channels && !packet_buffer_->Empty()) {
752 // We do not use |current_rtp_payload_type_| to |set payload_type|, but 751 // We do not use |current_rtp_payload_type_| to |set payload_type|, but
753 // get the next RTP header from |packet_buffer_| to obtain the payload type. 752 // get the next RTP header from |packet_buffer_| to obtain the payload type.
754 // The reason for it is the following corner case. If NetEq receives a 753 // The reason for it is the following corner case. If NetEq receives a
755 // CNG packet with a sample rate different than the current CNG then it 754 // CNG packet with a sample rate different than the current CNG then it
756 // flushes its buffer, assuming send codec must have been changed. However, 755 // flushes its buffer, assuming send codec must have been changed. However,
757 // payload type of the hypothetically new send codec is not known. 756 // payload type of the hypothetically new send codec is not known.
758 const RTPHeader* rtp_header = packet_buffer_->NextRtpHeader(); 757 const RTPHeader* rtp_header = packet_buffer_->NextRtpHeader();
759 assert(rtp_header); 758 assert(rtp_header);
(...skipping 1375 matching lines...) Expand 10 before | Expand all | Expand 10 after
2135 } 2134 }
2136 } 2135 }
2137 2136
2138 void NetEqImpl::CreateDecisionLogic() { 2137 void NetEqImpl::CreateDecisionLogic() {
2139 decision_logic_.reset(DecisionLogic::Create( 2138 decision_logic_.reset(DecisionLogic::Create(
2140 fs_hz_, output_size_samples_, playout_mode_, decoder_database_.get(), 2139 fs_hz_, output_size_samples_, playout_mode_, decoder_database_.get(),
2141 *packet_buffer_.get(), delay_manager_.get(), buffer_level_filter_.get(), 2140 *packet_buffer_.get(), delay_manager_.get(), buffer_level_filter_.get(),
2142 tick_timer_.get())); 2141 tick_timer_.get()));
2143 } 2142 }
2144 } // namespace webrtc 2143 } // namespace webrtc
OLDNEW
« no previous file with comments | « webrtc/modules/audio_coding/neteq/neteq_impl.h ('k') | webrtc/modules/audio_coding/neteq/neteq_impl_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698