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

Side by Side Diff: webrtc/modules/audio_coding/acm2/acm_receiver.cc

Issue 2355483003: Voe::Channel: Turned GetPlayoutFrequency into GetRtpTimestampRateHz. (Closed)
Patch Set: Handle zero clockrate, make better comments, fix bad spel Created 4 years, 2 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) 2013 The WebRTC project authors. All Rights Reserved. 2 * Copyright (c) 2013 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 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
91 receive_timestamp = NowInTimestamp(ci->plfreq); 91 receive_timestamp = NowInTimestamp(ci->plfreq);
92 92
93 if (STR_CASE_CMP(ci->plname, "cn") == 0) { 93 if (STR_CASE_CMP(ci->plname, "cn") == 0) {
94 if (last_audio_decoder_ && last_audio_decoder_->channels > 1) { 94 if (last_audio_decoder_ && last_audio_decoder_->channels > 1) {
95 // This is a CNG and the audio codec is not mono, so skip pushing in 95 // This is a CNG and the audio codec is not mono, so skip pushing in
96 // packets into NetEq. 96 // packets into NetEq.
97 return 0; 97 return 0;
98 } 98 }
99 } else { 99 } else {
100 last_audio_decoder_ = ci; 100 last_audio_decoder_ = ci;
101 last_audio_format_ = neteq_->GetDecoderFormat(ci->pltype);
102 RTC_DCHECK(last_audio_format_);
101 last_packet_sample_rate_hz_ = rtc::Optional<int>(ci->plfreq); 103 last_packet_sample_rate_hz_ = rtc::Optional<int>(ci->plfreq);
102 } 104 }
103 105
104 } // |crit_sect_| is released. 106 } // |crit_sect_| is released.
105 107
106 if (neteq_->InsertPacket(rtp_header, incoming_payload, receive_timestamp) < 108 if (neteq_->InsertPacket(rtp_header, incoming_payload, receive_timestamp) <
107 0) { 109 0) {
108 LOG(LERROR) << "AcmReceiver::InsertPacket " 110 LOG(LERROR) << "AcmReceiver::InsertPacket "
109 << static_cast<int>(header->payloadType) 111 << static_cast<int>(header->payloadType)
110 << " Failed to insert packet"; 112 << " Failed to insert packet";
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after
231 } 233 }
232 234
233 void AcmReceiver::FlushBuffers() { 235 void AcmReceiver::FlushBuffers() {
234 neteq_->FlushBuffers(); 236 neteq_->FlushBuffers();
235 } 237 }
236 238
237 void AcmReceiver::RemoveAllCodecs() { 239 void AcmReceiver::RemoveAllCodecs() {
238 rtc::CritScope lock(&crit_sect_); 240 rtc::CritScope lock(&crit_sect_);
239 neteq_->RemoveAllPayloadTypes(); 241 neteq_->RemoveAllPayloadTypes();
240 last_audio_decoder_ = rtc::Optional<CodecInst>(); 242 last_audio_decoder_ = rtc::Optional<CodecInst>();
243 last_audio_format_ = rtc::Optional<SdpAudioFormat>();
241 last_packet_sample_rate_hz_ = rtc::Optional<int>(); 244 last_packet_sample_rate_hz_ = rtc::Optional<int>();
242 } 245 }
243 246
244 int AcmReceiver::RemoveCodec(uint8_t payload_type) { 247 int AcmReceiver::RemoveCodec(uint8_t payload_type) {
245 rtc::CritScope lock(&crit_sect_); 248 rtc::CritScope lock(&crit_sect_);
246 if (neteq_->RemovePayloadType(payload_type) != NetEq::kOK && 249 if (neteq_->RemovePayloadType(payload_type) != NetEq::kOK &&
247 neteq_->LastError() != NetEq::kDecoderNotFound) { 250 neteq_->LastError() != NetEq::kDecoderNotFound) {
248 LOG(LERROR) << "AcmReceiver::RemoveCodec" << static_cast<int>(payload_type); 251 LOG(LERROR) << "AcmReceiver::RemoveCodec" << static_cast<int>(payload_type);
249 return -1; 252 return -1;
250 } 253 }
251 if (last_audio_decoder_ && payload_type == last_audio_decoder_->pltype) { 254 if (last_audio_decoder_ && payload_type == last_audio_decoder_->pltype) {
252 last_audio_decoder_ = rtc::Optional<CodecInst>(); 255 last_audio_decoder_ = rtc::Optional<CodecInst>();
256 last_audio_format_ = rtc::Optional<SdpAudioFormat>();
253 last_packet_sample_rate_hz_ = rtc::Optional<int>(); 257 last_packet_sample_rate_hz_ = rtc::Optional<int>();
254 } 258 }
255 return 0; 259 return 0;
256 } 260 }
257 261
258 rtc::Optional<uint32_t> AcmReceiver::GetPlayoutTimestamp() { 262 rtc::Optional<uint32_t> AcmReceiver::GetPlayoutTimestamp() {
259 return neteq_->GetPlayoutTimestamp(); 263 return neteq_->GetPlayoutTimestamp();
260 } 264 }
261 265
262 int AcmReceiver::FilteredCurrentDelayMs() const { 266 int AcmReceiver::FilteredCurrentDelayMs() const {
263 return neteq_->FilteredCurrentDelayMs(); 267 return neteq_->FilteredCurrentDelayMs();
264 } 268 }
265 269
266 int AcmReceiver::LastAudioCodec(CodecInst* codec) const { 270 int AcmReceiver::LastAudioCodec(CodecInst* codec) const {
267 rtc::CritScope lock(&crit_sect_); 271 rtc::CritScope lock(&crit_sect_);
268 if (!last_audio_decoder_) { 272 if (!last_audio_decoder_) {
269 return -1; 273 return -1;
270 } 274 }
271 *codec = *last_audio_decoder_; 275 *codec = *last_audio_decoder_;
272 return 0; 276 return 0;
273 } 277 }
274 278
279 rtc::Optional<SdpAudioFormat> AcmReceiver::LastAudioFormat() const {
280 rtc::CritScope lock(&crit_sect_);
281 return last_audio_format_;
282 }
283
275 void AcmReceiver::GetNetworkStatistics(NetworkStatistics* acm_stat) { 284 void AcmReceiver::GetNetworkStatistics(NetworkStatistics* acm_stat) {
276 NetEqNetworkStatistics neteq_stat; 285 NetEqNetworkStatistics neteq_stat;
277 // NetEq function always returns zero, so we don't check the return value. 286 // NetEq function always returns zero, so we don't check the return value.
278 neteq_->NetworkStatistics(&neteq_stat); 287 neteq_->NetworkStatistics(&neteq_stat);
279 288
280 acm_stat->currentBufferSize = neteq_stat.current_buffer_size_ms; 289 acm_stat->currentBufferSize = neteq_stat.current_buffer_size_ms;
281 acm_stat->preferredBufferSize = neteq_stat.preferred_buffer_size_ms; 290 acm_stat->preferredBufferSize = neteq_stat.preferred_buffer_size_ms;
282 acm_stat->jitterPeaksFound = neteq_stat.jitter_peaks_found ? true : false; 291 acm_stat->jitterPeaksFound = neteq_stat.jitter_peaks_found ? true : false;
283 acm_stat->currentPacketLossRate = neteq_stat.packet_loss_rate; 292 acm_stat->currentPacketLossRate = neteq_stat.packet_loss_rate;
284 acm_stat->currentDiscardRate = neteq_stat.packet_discard_rate; 293 acm_stat->currentDiscardRate = neteq_stat.packet_discard_rate;
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
354 363
355 void AcmReceiver::GetDecodingCallStatistics( 364 void AcmReceiver::GetDecodingCallStatistics(
356 AudioDecodingCallStats* stats) const { 365 AudioDecodingCallStats* stats) const {
357 rtc::CritScope lock(&crit_sect_); 366 rtc::CritScope lock(&crit_sect_);
358 *stats = call_stats_.GetDecodingStatistics(); 367 *stats = call_stats_.GetDecodingStatistics();
359 } 368 }
360 369
361 } // namespace acm2 370 } // namespace acm2
362 371
363 } // namespace webrtc 372 } // namespace webrtc
OLDNEW
« no previous file with comments | « webrtc/modules/audio_coding/acm2/acm_receiver.h ('k') | webrtc/modules/audio_coding/acm2/audio_coding_module.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698