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..e8da81d58c5d38076cd8f8f388ef9365495e0f5f 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,27 @@ 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); |
ossu
2016/02/24 13:24:34
This check should now be covered by the overrun ch
kwiberg-webrtc
2016/02/25 00:29:04
Acknowledged.
|
+ 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_) << ")"; |
kwiberg-webrtc
2016/02/25 00:29:04
Indentation looks off. Did you run clang-format?
ossu
2016/02/25 10:39:51
I did not, though I've been using google-c-style.e
|
+ |
+ return (r >= 0) ? static_cast<size_t>(r) : 0; |
kwiberg-webrtc
2016/02/25 00:29:04
Just static_cast<size_t>(r) will do, because of th
ossu
2016/02/25 10:39:51
Acknowledged.
|
+ }); |
+ |
+ 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; |