Index: webrtc/modules/audio_coding/codecs/audio_encoder.cc |
diff --git a/webrtc/modules/audio_coding/codecs/audio_encoder.cc b/webrtc/modules/audio_coding/codecs/audio_encoder.cc |
index e99fc30995995dea55ba1bcae4347b784e4691f3..0520918f9f1971bb1983f90d8267d39fc86ad87e 100644 |
--- a/webrtc/modules/audio_coding/codecs/audio_encoder.cc |
+++ b/webrtc/modules/audio_coding/codecs/audio_encoder.cc |
@@ -26,6 +26,28 @@ int AudioEncoder::RtpTimestampRateHz() const { |
AudioEncoder::EncodedInfo AudioEncoder::Encode( |
uint32_t rtp_timestamp, |
rtc::ArrayView<const int16_t> audio, |
+ rtc::Buffer* encoded) { |
+ TRACE_EVENT0("webrtc", "AudioEncoder::Encode"); |
+ RTC_CHECK_EQ(audio.size(), |
+ static_cast<size_t>(NumChannels() * SampleRateHz() / 100)); |
+ |
+ const size_t old_size = encoded->size(); |
+ EncodedInfo info = EncodeInternal(rtp_timestamp, audio, encoded); |
+ RTC_CHECK_EQ(encoded->size() - old_size, info.encoded_bytes); |
+ return info; |
+} |
+ |
+AudioEncoder::EncodedInfo AudioEncoder::Encode( |
+ uint32_t rtp_timestamp, |
+ rtc::ArrayView<const int16_t> audio, |
+ size_t max_encoded_bytes, |
+ uint8_t* encoded) { |
+ return DEPRECATED_Encode(rtp_timestamp, audio, max_encoded_bytes, encoded); |
+} |
+ |
+AudioEncoder::EncodedInfo AudioEncoder::DEPRECATED_Encode( |
+ uint32_t rtp_timestamp, |
+ rtc::ArrayView<const int16_t> audio, |
size_t max_encoded_bytes, |
uint8_t* encoded) { |
TRACE_EVENT0("webrtc", "AudioEncoder::Encode"); |
@@ -37,6 +59,33 @@ AudioEncoder::EncodedInfo AudioEncoder::Encode( |
return info; |
} |
+AudioEncoder::EncodedInfo AudioEncoder::EncodeInternal( |
+ uint32_t rtp_timestamp, |
+ rtc::ArrayView<const int16_t> audio, |
+ rtc::Buffer* encoded) |
+{ |
+ EncodedInfo info; |
+ encoded->AppendData(MaxEncodedBytes(), [&] (rtc::ArrayView<uint8_t> encoded) { |
+ info = EncodeInternal(rtp_timestamp, audio, |
+ encoded.size(), encoded.data()); |
+ return info.encoded_bytes; |
+ }); |
+ return info; |
+} |
+ |
+AudioEncoder::EncodedInfo AudioEncoder::EncodeInternal( |
+ uint32_t rtp_timestamp, |
+ rtc::ArrayView<const int16_t> audio, |
+ size_t max_encoded_bytes, |
+ uint8_t* encoded) |
+{ |
+ rtc::Buffer temp_buffer; |
+ EncodedInfo info = EncodeInternal(rtp_timestamp, audio, &temp_buffer); |
+ RTC_DCHECK_LE(temp_buffer.size(), max_encoded_bytes); |
+ std::memcpy(encoded, temp_buffer.data(), info.encoded_bytes); |
+ return info; |
+} |
+ |
bool AudioEncoder::SetFec(bool enable) { |
return !enable; |
} |