| 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 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 73 } | 73 } |
| 74 | 74 |
| 75 int AudioEncoderPcm::GetTargetBitrate() const { | 75 int AudioEncoderPcm::GetTargetBitrate() const { |
| 76 return static_cast<int>( | 76 return static_cast<int>( |
| 77 8 * BytesPerSample() * SampleRateHz() * NumChannels()); | 77 8 * BytesPerSample() * SampleRateHz() * NumChannels()); |
| 78 } | 78 } |
| 79 | 79 |
| 80 AudioEncoder::EncodedInfo AudioEncoderPcm::EncodeInternal( | 80 AudioEncoder::EncodedInfo AudioEncoderPcm::EncodeInternal( |
| 81 uint32_t rtp_timestamp, | 81 uint32_t rtp_timestamp, |
| 82 rtc::ArrayView<const int16_t> audio, | 82 rtc::ArrayView<const int16_t> audio, |
| 83 size_t max_encoded_bytes, | 83 rtc::Buffer* encoded) { |
| 84 uint8_t* encoded) { | |
| 85 if (speech_buffer_.empty()) { | 84 if (speech_buffer_.empty()) { |
| 86 first_timestamp_in_buffer_ = rtp_timestamp; | 85 first_timestamp_in_buffer_ = rtp_timestamp; |
| 87 } | 86 } |
| 88 speech_buffer_.insert(speech_buffer_.end(), audio.begin(), audio.end()); | 87 speech_buffer_.insert(speech_buffer_.end(), audio.begin(), audio.end()); |
| 89 if (speech_buffer_.size() < full_frame_samples_) { | 88 if (speech_buffer_.size() < full_frame_samples_) { |
| 90 return EncodedInfo(); | 89 return EncodedInfo(); |
| 91 } | 90 } |
| 92 RTC_CHECK_EQ(speech_buffer_.size(), full_frame_samples_); | 91 RTC_CHECK_EQ(speech_buffer_.size(), full_frame_samples_); |
| 93 RTC_CHECK_GE(max_encoded_bytes, full_frame_samples_); | |
| 94 EncodedInfo info; | 92 EncodedInfo info; |
| 95 info.encoded_timestamp = first_timestamp_in_buffer_; | 93 info.encoded_timestamp = first_timestamp_in_buffer_; |
| 96 info.payload_type = payload_type_; | 94 info.payload_type = payload_type_; |
| 97 info.encoded_bytes = | 95 info.encoded_bytes = |
| 98 EncodeCall(&speech_buffer_[0], full_frame_samples_, encoded); | 96 encoded->AppendData(MaxEncodedBytes(), |
| 97 [&] (rtc::ArrayView<uint8_t> encoded) { |
| 98 return EncodeCall(&speech_buffer_[0], |
| 99 full_frame_samples_, |
| 100 encoded.data()); |
| 101 }); |
| 99 speech_buffer_.clear(); | 102 speech_buffer_.clear(); |
| 100 return info; | 103 return info; |
| 101 } | 104 } |
| 102 | 105 |
| 103 void AudioEncoderPcm::Reset() { | 106 void AudioEncoderPcm::Reset() { |
| 104 speech_buffer_.clear(); | 107 speech_buffer_.clear(); |
| 105 } | 108 } |
| 106 | 109 |
| 107 AudioEncoderPcmA::AudioEncoderPcmA(const CodecInst& codec_inst) | 110 AudioEncoderPcmA::AudioEncoderPcmA(const CodecInst& codec_inst) |
| 108 : AudioEncoderPcmA(CreateConfig<AudioEncoderPcmA>(codec_inst)) {} | 111 : AudioEncoderPcmA(CreateConfig<AudioEncoderPcmA>(codec_inst)) {} |
| (...skipping 15 matching lines...) Expand all Loading... |
| 124 size_t input_len, | 127 size_t input_len, |
| 125 uint8_t* encoded) { | 128 uint8_t* encoded) { |
| 126 return WebRtcG711_EncodeU(audio, input_len, encoded); | 129 return WebRtcG711_EncodeU(audio, input_len, encoded); |
| 127 } | 130 } |
| 128 | 131 |
| 129 size_t AudioEncoderPcmU::BytesPerSample() const { | 132 size_t AudioEncoderPcmU::BytesPerSample() const { |
| 130 return 1; | 133 return 1; |
| 131 } | 134 } |
| 132 | 135 |
| 133 } // namespace webrtc | 136 } // namespace webrtc |
| OLD | NEW |