Chromium Code Reviews

Side by Side Diff: webrtc/modules/audio_coding/codecs/g711/audio_encoder_pcm.cc

Issue 1883543002: Revert of Remove the deprecated EncodeInternal interface from AudioEncoder (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Created 4 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View unified diff |
OLDNEW
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 34 matching lines...)
45 config.num_channels * config.frame_size_ms * sample_rate_hz / 1000), 45 config.num_channels * config.frame_size_ms * sample_rate_hz / 1000),
46 first_timestamp_in_buffer_(0) { 46 first_timestamp_in_buffer_(0) {
47 RTC_CHECK_GT(sample_rate_hz, 0) << "Sample rate must be larger than 0 Hz"; 47 RTC_CHECK_GT(sample_rate_hz, 0) << "Sample rate must be larger than 0 Hz";
48 RTC_CHECK_EQ(config.frame_size_ms % 10, 0) 48 RTC_CHECK_EQ(config.frame_size_ms % 10, 0)
49 << "Frame size must be an integer multiple of 10 ms."; 49 << "Frame size must be an integer multiple of 10 ms.";
50 speech_buffer_.reserve(full_frame_samples_); 50 speech_buffer_.reserve(full_frame_samples_);
51 } 51 }
52 52
53 AudioEncoderPcm::~AudioEncoderPcm() = default; 53 AudioEncoderPcm::~AudioEncoderPcm() = default;
54 54
55 size_t AudioEncoderPcm::MaxEncodedBytes() const {
56 return full_frame_samples_ * BytesPerSample();
57 }
58
55 int AudioEncoderPcm::SampleRateHz() const { 59 int AudioEncoderPcm::SampleRateHz() const {
56 return sample_rate_hz_; 60 return sample_rate_hz_;
57 } 61 }
58 62
59 size_t AudioEncoderPcm::NumChannels() const { 63 size_t AudioEncoderPcm::NumChannels() const {
60 return num_channels_; 64 return num_channels_;
61 } 65 }
62 66
63 size_t AudioEncoderPcm::Num10MsFramesInNextPacket() const { 67 size_t AudioEncoderPcm::Num10MsFramesInNextPacket() const {
64 return num_10ms_frames_per_packet_; 68 return num_10ms_frames_per_packet_;
(...skipping 17 matching lines...)
82 } 86 }
83 speech_buffer_.insert(speech_buffer_.end(), audio.begin(), audio.end()); 87 speech_buffer_.insert(speech_buffer_.end(), audio.begin(), audio.end());
84 if (speech_buffer_.size() < full_frame_samples_) { 88 if (speech_buffer_.size() < full_frame_samples_) {
85 return EncodedInfo(); 89 return EncodedInfo();
86 } 90 }
87 RTC_CHECK_EQ(speech_buffer_.size(), full_frame_samples_); 91 RTC_CHECK_EQ(speech_buffer_.size(), full_frame_samples_);
88 EncodedInfo info; 92 EncodedInfo info;
89 info.encoded_timestamp = first_timestamp_in_buffer_; 93 info.encoded_timestamp = first_timestamp_in_buffer_;
90 info.payload_type = payload_type_; 94 info.payload_type = payload_type_;
91 info.encoded_bytes = 95 info.encoded_bytes =
92 encoded->AppendData(full_frame_samples_ * BytesPerSample(), 96 encoded->AppendData(MaxEncodedBytes(),
93 [&] (rtc::ArrayView<uint8_t> encoded) { 97 [&] (rtc::ArrayView<uint8_t> encoded) {
94 return EncodeCall(&speech_buffer_[0], 98 return EncodeCall(&speech_buffer_[0],
95 full_frame_samples_, 99 full_frame_samples_,
96 encoded.data()); 100 encoded.data());
97 }); 101 });
98 speech_buffer_.clear(); 102 speech_buffer_.clear();
99 return info; 103 return info;
100 } 104 }
101 105
102 void AudioEncoderPcm::Reset() { 106 void AudioEncoderPcm::Reset() {
(...skipping 20 matching lines...)
123 size_t input_len, 127 size_t input_len,
124 uint8_t* encoded) { 128 uint8_t* encoded) {
125 return WebRtcG711_EncodeU(audio, input_len, encoded); 129 return WebRtcG711_EncodeU(audio, input_len, encoded);
126 } 130 }
127 131
128 size_t AudioEncoderPcmU::BytesPerSample() const { 132 size_t AudioEncoderPcmU::BytesPerSample() const {
129 return 1; 133 return 1;
130 } 134 }
131 135
132 } // namespace webrtc 136 } // namespace webrtc
OLDNEW

Powered by Google App Engine