| 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 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 81 size_t AudioEncoderPcm::Max10MsFramesInAPacket() const { | 81 size_t AudioEncoderPcm::Max10MsFramesInAPacket() const { |
| 82 return num_10ms_frames_per_packet_; | 82 return num_10ms_frames_per_packet_; |
| 83 } | 83 } |
| 84 | 84 |
| 85 int AudioEncoderPcm::GetTargetBitrate() const { | 85 int AudioEncoderPcm::GetTargetBitrate() const { |
| 86 return 8 * BytesPerSample() * SampleRateHz() * NumChannels(); | 86 return 8 * BytesPerSample() * SampleRateHz() * NumChannels(); |
| 87 } | 87 } |
| 88 | 88 |
| 89 AudioEncoder::EncodedInfo AudioEncoderPcm::EncodeInternal( | 89 AudioEncoder::EncodedInfo AudioEncoderPcm::EncodeInternal( |
| 90 uint32_t rtp_timestamp, | 90 uint32_t rtp_timestamp, |
| 91 const int16_t* audio, | 91 rtc::ArrayView<const int16_t> audio, |
| 92 size_t max_encoded_bytes, | 92 size_t max_encoded_bytes, |
| 93 uint8_t* encoded) { | 93 uint8_t* encoded) { |
| 94 const int num_samples = SampleRateHz() / 100 * NumChannels(); | |
| 95 if (speech_buffer_.empty()) { | 94 if (speech_buffer_.empty()) { |
| 96 first_timestamp_in_buffer_ = rtp_timestamp; | 95 first_timestamp_in_buffer_ = rtp_timestamp; |
| 97 } | 96 } |
| 98 for (int i = 0; i < num_samples; ++i) { | 97 speech_buffer_.insert(speech_buffer_.end(), audio.begin(), audio.end()); |
| 99 speech_buffer_.push_back(audio[i]); | |
| 100 } | |
| 101 if (speech_buffer_.size() < full_frame_samples_) { | 98 if (speech_buffer_.size() < full_frame_samples_) { |
| 102 return EncodedInfo(); | 99 return EncodedInfo(); |
| 103 } | 100 } |
| 104 RTC_CHECK_EQ(speech_buffer_.size(), full_frame_samples_); | 101 RTC_CHECK_EQ(speech_buffer_.size(), full_frame_samples_); |
| 105 RTC_CHECK_GE(max_encoded_bytes, full_frame_samples_); | 102 RTC_CHECK_GE(max_encoded_bytes, full_frame_samples_); |
| 106 EncodedInfo info; | 103 EncodedInfo info; |
| 107 info.encoded_timestamp = first_timestamp_in_buffer_; | 104 info.encoded_timestamp = first_timestamp_in_buffer_; |
| 108 info.payload_type = payload_type_; | 105 info.payload_type = payload_type_; |
| 109 info.encoded_bytes = | 106 info.encoded_bytes = |
| 110 EncodeCall(&speech_buffer_[0], full_frame_samples_, encoded); | 107 EncodeCall(&speech_buffer_[0], full_frame_samples_, encoded); |
| (...skipping 25 matching lines...) Expand all Loading... |
| 136 size_t input_len, | 133 size_t input_len, |
| 137 uint8_t* encoded) { | 134 uint8_t* encoded) { |
| 138 return WebRtcG711_EncodeU(audio, input_len, encoded); | 135 return WebRtcG711_EncodeU(audio, input_len, encoded); |
| 139 } | 136 } |
| 140 | 137 |
| 141 int AudioEncoderPcmU::BytesPerSample() const { | 138 int AudioEncoderPcmU::BytesPerSample() const { |
| 142 return 1; | 139 return 1; |
| 143 } | 140 } |
| 144 | 141 |
| 145 } // namespace webrtc | 142 } // namespace webrtc |
| OLD | NEW |