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 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
91 const size_t samples_per_10ms_frame = SamplesPer10msFrame(); | 91 const size_t samples_per_10ms_frame = SamplesPer10msFrame(); |
92 RTC_CHECK_EQ(speech_buffer_.size(), | 92 RTC_CHECK_EQ(speech_buffer_.size(), |
93 rtp_timestamps_.size() * samples_per_10ms_frame); | 93 rtp_timestamps_.size() * samples_per_10ms_frame); |
94 rtp_timestamps_.push_back(rtp_timestamp); | 94 rtp_timestamps_.push_back(rtp_timestamp); |
95 RTC_DCHECK_EQ(samples_per_10ms_frame, audio.size()); | 95 RTC_DCHECK_EQ(samples_per_10ms_frame, audio.size()); |
96 speech_buffer_.insert(speech_buffer_.end(), audio.cbegin(), audio.cend()); | 96 speech_buffer_.insert(speech_buffer_.end(), audio.cbegin(), audio.cend()); |
97 const size_t frames_to_encode = speech_encoder_->Num10MsFramesInNextPacket(); | 97 const size_t frames_to_encode = speech_encoder_->Num10MsFramesInNextPacket(); |
98 if (rtp_timestamps_.size() < frames_to_encode) { | 98 if (rtp_timestamps_.size() < frames_to_encode) { |
99 return EncodedInfo(); | 99 return EncodedInfo(); |
100 } | 100 } |
101 RTC_CHECK_LE(static_cast<int>(frames_to_encode * 10), kMaxFrameSizeMs) | 101 RTC_CHECK_LE(frames_to_encode * 10, kMaxFrameSizeMs) |
102 << "Frame size cannot be larger than " << kMaxFrameSizeMs | 102 << "Frame size cannot be larger than " << kMaxFrameSizeMs |
103 << " ms when using VAD/CNG."; | 103 << " ms when using VAD/CNG."; |
104 | 104 |
105 // Group several 10 ms blocks per VAD call. Call VAD once or twice using the | 105 // Group several 10 ms blocks per VAD call. Call VAD once or twice using the |
106 // following split sizes: | 106 // following split sizes: |
107 // 10 ms = 10 + 0 ms; 20 ms = 20 + 0 ms; 30 ms = 30 + 0 ms; | 107 // 10 ms = 10 + 0 ms; 20 ms = 20 + 0 ms; 30 ms = 30 + 0 ms; |
108 // 40 ms = 20 + 20 ms; 50 ms = 30 + 20 ms; 60 ms = 30 + 30 ms. | 108 // 40 ms = 20 + 20 ms; 50 ms = 30 + 20 ms; 60 ms = 30 + 30 ms. |
109 size_t blocks_in_first_vad_call = | 109 size_t blocks_in_first_vad_call = |
110 (frames_to_encode > 3 ? 3 : frames_to_encode); | 110 (frames_to_encode > 3 ? 3 : frames_to_encode); |
111 if (frames_to_encode == 4) | 111 if (frames_to_encode == 4) |
(...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
247 } | 247 } |
248 } | 248 } |
249 return info; | 249 return info; |
250 } | 250 } |
251 | 251 |
252 size_t AudioEncoderCng::SamplesPer10msFrame() const { | 252 size_t AudioEncoderCng::SamplesPer10msFrame() const { |
253 return rtc::CheckedDivExact(10 * SampleRateHz(), 1000); | 253 return rtc::CheckedDivExact(10 * SampleRateHz(), 1000); |
254 } | 254 } |
255 | 255 |
256 } // namespace webrtc | 256 } // namespace webrtc |
OLD | NEW |