Index: webrtc/modules/audio_coding/codecs/ilbc/audio_encoder_ilbc.cc |
diff --git a/webrtc/modules/audio_coding/codecs/ilbc/audio_encoder_ilbc.cc b/webrtc/modules/audio_coding/codecs/ilbc/audio_encoder_ilbc.cc |
index ddd6dde31c9e3594346fc08f82a0ba6f63c6d087..419fdfb54a5d7989cffff71de9a49726c5374bdc 100644 |
--- a/webrtc/modules/audio_coding/codecs/ilbc/audio_encoder_ilbc.cc |
+++ b/webrtc/modules/audio_coding/codecs/ilbc/audio_encoder_ilbc.cc |
@@ -92,16 +92,13 @@ int AudioEncoderIlbc::GetTargetBitrate() const { |
AudioEncoder::EncodedInfo AudioEncoderIlbc::EncodeInternal( |
uint32_t rtp_timestamp, |
rtc::ArrayView<const int16_t> audio, |
- size_t max_encoded_bytes, |
- uint8_t* encoded) { |
- RTC_DCHECK_GE(max_encoded_bytes, RequiredOutputSizeBytes()); |
+ rtc::Buffer* encoded) { |
// Save timestamp if starting a new packet. |
if (num_10ms_frames_buffered_ == 0) |
first_timestamp_in_buffer_ = rtp_timestamp; |
// Buffer input. |
- RTC_DCHECK_EQ(static_cast<size_t>(kSampleRateHz / 100), audio.size()); |
std::copy(audio.cbegin(), audio.cend(), |
input_buffer_ + kSampleRateHz / 100 * num_10ms_frames_buffered_); |
@@ -114,15 +111,24 @@ AudioEncoder::EncodedInfo AudioEncoderIlbc::EncodeInternal( |
// Encode buffered input. |
RTC_DCHECK_EQ(num_10ms_frames_buffered_, num_10ms_frames_per_packet_); |
num_10ms_frames_buffered_ = 0; |
- const int output_len = WebRtcIlbcfix_Encode( |
- encoder_, |
- input_buffer_, |
- kSampleRateHz / 100 * num_10ms_frames_per_packet_, |
- encoded); |
- RTC_CHECK_GE(output_len, 0); |
+ size_t encoded_bytes = |
+ encoded->AppendData( |
+ RequiredOutputSizeBytes(), |
+ [&] (rtc::ArrayView<uint8_t> encoded) { |
+ const int r = WebRtcIlbcfix_Encode( |
+ encoder_, |
+ input_buffer_, |
+ kSampleRateHz / 100 * num_10ms_frames_per_packet_, |
+ encoded.data()); |
+ RTC_CHECK_GE(r, 0); |
+ |
+ return static_cast<size_t>(r); |
+ }); |
+ |
+ RTC_DCHECK_EQ(encoded_bytes, RequiredOutputSizeBytes()); |
+ |
EncodedInfo info; |
- info.encoded_bytes = static_cast<size_t>(output_len); |
- RTC_DCHECK_EQ(info.encoded_bytes, RequiredOutputSizeBytes()); |
+ info.encoded_bytes = encoded_bytes; |
info.encoded_timestamp = first_timestamp_in_buffer_; |
info.payload_type = config_.payload_type; |
return info; |