Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(231)

Unified Diff: webrtc/modules/audio_coding/codecs/audio_encoder.cc

Issue 1725143003: Changed AudioEncoder::Encode to take an rtc::Buffer* instead of uint8_t* and a maximum size. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Added more fixes for override hiding in AudioEncoder implementations. Created 4 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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;
}

Powered by Google App Engine
This is Rietveld 408576698