Index: webrtc/modules/audio_coding/codecs/isac/audio_encoder_isac_t_impl.h |
diff --git a/webrtc/modules/audio_coding/codecs/isac/audio_encoder_isac_t_impl.h b/webrtc/modules/audio_coding/codecs/isac/audio_encoder_isac_t_impl.h |
index b9da7f49e9f2f4c53df4a98e077dc4861eb86cca..3832216d579566c93f5772fdc3c48b7d699c8b98 100644 |
--- a/webrtc/modules/audio_coding/codecs/isac/audio_encoder_isac_t_impl.h |
+++ b/webrtc/modules/audio_coding/codecs/isac/audio_encoder_isac_t_impl.h |
@@ -117,8 +117,7 @@ template <typename T> |
AudioEncoder::EncodedInfo AudioEncoderIsacT<T>::EncodeInternal( |
uint32_t rtp_timestamp, |
rtc::ArrayView<const int16_t> audio, |
- size_t max_encoded_bytes, |
- uint8_t* encoded) { |
+ rtc::Buffer* encoded) { |
if (!packet_in_progress_) { |
// Starting a new packet; remember the timestamp for later. |
packet_in_progress_ = true; |
@@ -128,22 +127,26 @@ AudioEncoder::EncodedInfo AudioEncoderIsacT<T>::EncodeInternal( |
IsacBandwidthInfo bwinfo = bwinfo_->Get(); |
T::SetBandwidthInfo(isac_state_, &bwinfo); |
} |
- int r = T::Encode(isac_state_, audio.data(), encoded); |
- RTC_CHECK_GE(r, 0) << "Encode failed (error code " |
- << T::GetErrorCode(isac_state_) << ")"; |
- // T::Encode doesn't allow us to tell it the size of the output |
- // buffer. All we can do is check for an overrun after the fact. |
- RTC_CHECK_LE(static_cast<size_t>(r), max_encoded_bytes); |
+ size_t encoded_bytes = encoded->AppendData( |
+ kSufficientEncodeBufferSizeBytes, |
+ [&] (rtc::ArrayView<uint8_t> encoded) { |
+ int r = T::Encode(isac_state_, audio.data(), encoded.data()); |
- if (r == 0) |
+ RTC_CHECK_GE(r, 0) << "Encode failed (error code " |
+ << T::GetErrorCode(isac_state_) << ")"; |
+ |
+ return static_cast<size_t>(r); |
+ }); |
+ |
+ if (encoded_bytes == 0) |
return EncodedInfo(); |
// Got enough input to produce a packet. Return the saved timestamp from |
// the first chunk of input that went into the packet. |
packet_in_progress_ = false; |
EncodedInfo info; |
- info.encoded_bytes = r; |
+ info.encoded_bytes = encoded_bytes; |
info.encoded_timestamp = packet_timestamp_; |
info.payload_type = config_.payload_type; |
return info; |