OLD | NEW |
1 /* | 1 /* |
2 * Copyright (c) 2014 The WebRTC project authors. All Rights Reserved. | 2 * Copyright (c) 2014 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 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
75 sid_frame_interval_ms_(config.sid_frame_interval_ms), | 75 sid_frame_interval_ms_(config.sid_frame_interval_ms), |
76 last_frame_active_(true), | 76 last_frame_active_(true), |
77 vad_(config.vad ? std::unique_ptr<Vad>(config.vad) | 77 vad_(config.vad ? std::unique_ptr<Vad>(config.vad) |
78 : CreateVad(config.vad_mode)) { | 78 : CreateVad(config.vad_mode)) { |
79 cng_inst_ = CreateCngInst(SampleRateHz(), sid_frame_interval_ms_, | 79 cng_inst_ = CreateCngInst(SampleRateHz(), sid_frame_interval_ms_, |
80 num_cng_coefficients_); | 80 num_cng_coefficients_); |
81 } | 81 } |
82 | 82 |
83 AudioEncoderCng::~AudioEncoderCng() = default; | 83 AudioEncoderCng::~AudioEncoderCng() = default; |
84 | 84 |
| 85 size_t AudioEncoderCng::MaxEncodedBytes() const { |
| 86 const size_t max_encoded_bytes_active = speech_encoder_->MaxEncodedBytes(); |
| 87 const size_t max_encoded_bytes_passive = |
| 88 rtc::CheckedDivExact(kMaxFrameSizeMs, 10) * SamplesPer10msFrame(); |
| 89 return std::max(max_encoded_bytes_active, max_encoded_bytes_passive); |
| 90 } |
| 91 |
85 int AudioEncoderCng::SampleRateHz() const { | 92 int AudioEncoderCng::SampleRateHz() const { |
86 return speech_encoder_->SampleRateHz(); | 93 return speech_encoder_->SampleRateHz(); |
87 } | 94 } |
88 | 95 |
89 size_t AudioEncoderCng::NumChannels() const { | 96 size_t AudioEncoderCng::NumChannels() const { |
90 return 1; | 97 return 1; |
91 } | 98 } |
92 | 99 |
93 int AudioEncoderCng::RtpTimestampRateHz() const { | 100 int AudioEncoderCng::RtpTimestampRateHz() const { |
94 return speech_encoder_->RtpTimestampRateHz(); | 101 return speech_encoder_->RtpTimestampRateHz(); |
(...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
268 } | 275 } |
269 } | 276 } |
270 return info; | 277 return info; |
271 } | 278 } |
272 | 279 |
273 size_t AudioEncoderCng::SamplesPer10msFrame() const { | 280 size_t AudioEncoderCng::SamplesPer10msFrame() const { |
274 return rtc::CheckedDivExact(10 * SampleRateHz(), 1000); | 281 return rtc::CheckedDivExact(10 * SampleRateHz(), 1000); |
275 } | 282 } |
276 | 283 |
277 } // namespace webrtc | 284 } // namespace webrtc |
OLD | NEW |